X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/c3bcc0703d6255b78c2a6813bbea03e9581609e0..1c521c34f50f40df350c7cfe9587ba0248dd8331:/redakcja/static/js/catalogue/catalogue.js?ds=inline diff --git a/redakcja/static/js/catalogue/catalogue.js b/redakcja/static/js/catalogue/catalogue.js index e6a210e3..cb96d113 100755 --- a/redakcja/static/js/catalogue/catalogue.js +++ b/redakcja/static/js/catalogue/catalogue.js @@ -27,6 +27,99 @@ }); + var nowTemp = new Date(); + var now = new Date(nowTemp.getFullYear(), nowTemp.getMonth(), nowTemp.getDate(), 0, 0, 0, 0); + + $('.datepicker-field').each(function() { + var checkout = $(this).datepicker({ + format: 'yyyy-mm-dd', + weekStart: 1, + onRender: function(date) { + return date.valueOf() < now.valueOf() ? 'disabled' : ''; + }, + }).on('changeDate', function(ev) { + checkout.hide(); + }).data('datepicker'); + }); + + + $("select").change(function() { + 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') || ''); + } + }); + + + + // tutorial mode + var tutorial; + var start; + + var first_reset = true; + function tutreset() { + if (start) $(start).popover('hide'); + start = null; + var all_tutorial = $('[data-toggle="tutorial"]'); + + tutorial = $.makeArray(all_tutorial.sort( + function(a, b) {return $(a).attr('data-tutorial') < $(b).attr('data-tutorial') ? -1 : 1} + )); + + if (first_reset) { + $.each(tutorial, function(i, e) { + var but = (i < tutorial.length - 1) ? '>>' : 'OK'; + $(e).popover({ + title: '×Tutorial', + trigger: 'focus', + html: 'true', + template: '' + }); + }); + first_reset = false; + } else { + all_tutorial.popover('enable'); + } + } + + function tuton() { + sessionStorage.setItem("tutorial", "on"); + tutreset(); + $('#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').popover('disable'); + } + if (tutorial.length) { + start = tutorial.shift(); + $(start).popover('show'); + } + else { + start = null; + } + return false; + } + $('#tutModal').on('hidden.bs.modal', tut); + + var $tuton = $("#tuton"); + if (sessionStorage.getItem("tutorial") == "on" && $tuton.length == 0) { + tutreset(); + tut(); + } + $tuton.on('click', tuton); + $(document).on('click', '.tutorial-off', tutoff); + $(document).on('click', '.tutorial-next', tut); }); -})(jQuery) +})(jQuery);