X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/2f9cb34a07fcd98effda2fa900e48c31813f14c8..2c85a46e149380dccf5a69694402bd2519e80203:/redakcja/static/js/catalogue/catalogue.js diff --git a/redakcja/static/js/catalogue/catalogue.js b/redakcja/static/js/catalogue/catalogue.js index 2b5a9420..fa3f5f2b 100755 --- a/redakcja/static/js/catalogue/catalogue.js +++ b/redakcja/static/js/catalogue/catalogue.js @@ -61,53 +61,59 @@ function tutreset() { if (start) $(start).popover('hide'); start = null; + var all_tutorial = $('[data-toggle="tutorial"]'); - tutorial = $.makeArray($('[data-toggle="tutorial"]').sort( - function(a, b) {return $(a).attr('data-tutorial') < $(b).attr('data-tutorial') ? -1 : 1} + function sortKey(a) { + return parseInt($(a).attr('data-tutorial')); + } + tutorial = $.makeArray(all_tutorial.sort( + function(a, b) {return sortKey(a) < sortKey(b) ? -1 : 1} )); + console.log($(tutorial[0]).data('popover')); + console.log($(tutorial[16]).data('popover')); if (first_reset) { $.each(tutorial, function(i, e) { var but = (i < tutorial.length - 1) ? '>>' : 'OK'; $(e).popover({ - title: 'Tutorial', + title: '×Tutorial', trigger: 'focus', - template: '' - }).on('shown.bs.popover', function () { - if (!$(e).data('tut-yet')) { - $("#tutoff"+i).on('click', tutoff); - $("#nt"+i).on('click', tut); - $(e).data('tut-yet', 'yes'); - } + html: 'true', + template: '' }); - //$(start).on('hide.bs.popover', tut); }); first_reset = false; + } else { + all_tutorial.popover('enable'); } } function tuton() { sessionStorage.setItem("tutorial", "on"); tutreset(); - $('#tutModal').modal('show'); + var $tutModal = $('#tutModal'); + if($tutModal.length === 0) { + tut(); + } else { + $tutModal.modal('show'); + } return false; } function tutoff() { + $(this).popover('hide'); if (start) $(start).popover('hide'); start = null; sessionStorage.removeItem("tutorial"); + $('[data-toggle="tutorial"]').popover('disable'); return false; } function tut() { - if (start) $(start).popover('hide'); + if (start) { + $(start).popover('hide').popover('disable'); + } if (tutorial.length) { start = tutorial.shift(); $(start).popover('show'); - //~ if (!$(start).data('tut-yet')) { - //~ $(".popover .tutorial-off").on('click', tutoff); - //~ $(".popover .tutorial-next").on('click', tut); - //~ $(start).data('tut-yet', 'yes'); - //~ } } else { start = null; @@ -115,14 +121,14 @@ return false; } $('#tutModal').on('hidden.bs.modal', tut); - - if (sessionStorage.getItem("tutorial") == "on" && $("#tuton").length == 0) { + + if (sessionStorage.getItem("tutorial") == "on" && $('#tuton').length == 0) { tutreset(); tut(); } - $("#tuton").on('click', tuton); - - + $(document).on('click', '#tuton', tuton); + $(document).on('click', '.tutorial-off', tutoff); + $(document).on('click', '.tutorial-next', tut); }); })(jQuery);