X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/2f9cb34a07fcd98effda2fa900e48c31813f14c8..b2d61af6200bf8281e5466a183eae491440f4c1a:/redakcja/static/js/catalogue/catalogue.js diff --git a/redakcja/static/js/catalogue/catalogue.js b/redakcja/static/js/catalogue/catalogue.js index 2b5a9420..04fedce7 100755 --- a/redakcja/static/js/catalogue/catalogue.js +++ b/redakcja/static/js/catalogue/catalogue.js @@ -36,8 +36,8 @@ weekStart: 1, onRender: function(date) { return date.valueOf() < now.valueOf() ? 'disabled' : ''; - }, - }).on('changeDate', function(ev) { + } + }).on('changeDate', function() { checkout.hide(); }).data('datepicker'); }); @@ -47,40 +47,52 @@ var helpdiv = $(this).next(); if (helpdiv.hasClass('help-text')) { var helptext = $("option:selected", this).attr('data-help'); - helpdiv.html($("option:selected", this).attr('data-help') || ''); + helpdiv.html(helptext || ''); } }); + if ($.isFunction($.fn.chosen)) { + $('.chosen-select').chosen().each(function () { + var widget = $(this.nextSibling), $t = $(this); + $.each($.merge([], this.attributes), function () { + if (this.name.substr(0, 5) === 'data-') { + $t.removeAttr(this.name); + widget.attr(this.name, this.value); + } + }); + }); + } // tutorial mode - var tutorial; + var tutorial, tutorial_no; var start; var first_reset = true; function tutreset() { if (start) $(start).popover('hide'); start = null; + tutorial_no = 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} )); if (first_reset) { $.each(tutorial, function(i, e) { - var but = (i < tutorial.length - 1) ? '>>' : 'OK'; + var but = (i < tutorial.length - 1) ? '>>' : 'OK', + but_prev_html = i === 0 ? '' : '<<'; $(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); + $(e).popover('disable'); }); first_reset = false; } @@ -89,40 +101,58 @@ function tuton() { sessionStorage.setItem("tutorial", "on"); tutreset(); - $('#tutModal').modal('show'); + var $tutModal = $('#tutModal'); + if($tutModal.length === 0) { + tutnext(); + } 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 (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'); - //~ } + function tut(next) { + if (start) { + $(start).popover('hide').popover('disable'); + } + if (tutorial_no === null) + tutorial_no = 0; + else if (next) + tutorial_no++; + else + tutorial_no--; + if (tutorial_no < tutorial.length && tutorial_no >= 0) { + start = tutorial[tutorial_no]; + $(start).popover('enable').popover('show'); } else { + tutorial_no = null; start = null; } return false; } - $('#tutModal').on('hidden.bs.modal', tut); - - if (sessionStorage.getItem("tutorial") == "on" && $("#tuton").length == 0) { - tutreset(); - tut(); + function tutnext() { + tut(true); } - $("#tuton").on('click', tuton); - + function tutprev() { + tut(false); + } + $('#tutModal').on('hidden.bs.modal', tutnext); + if (sessionStorage.getItem("tutorial") === "on" && $('#tuton').length === 0) { + tutreset(); + tutnext(); + } + $(document).on('click', '#tuton', tuton); + $(document).on('click', '.tutorial-off', tutoff); + $(document).on('click', '.tutorial-next', tutnext); + $(document).on('click', '.tutorial-prev', tutprev); }); })(jQuery);