From caeefe0cf49971d26c2b8f5306e2a150bd169669 Mon Sep 17 00:00:00 2001 From: Giuseppe Criscione Date: Sun, 17 Jun 2018 11:28:05 +0200 Subject: [PATCH] Rename `.no-reorder` to `.not-sortable` for consistency --- admin/assets/js/app.js | 440 ++++++++++++++++++------------------ admin/assets/js/app.min.js | 2 +- admin/assets/js/src/main.js | 4 +- admin/views/pages/list.php | 2 +- 4 files changed, 224 insertions(+), 224 deletions(-) diff --git a/admin/assets/js/app.js b/admin/assets/js/app.js index 720531f6..de74cec3 100755 --- a/admin/assets/js/app.js +++ b/admin/assets/js/app.js @@ -174,7 +174,7 @@ $(function() { if ($this.data('sortable') === false) return; var sortable = Sortable.create(this, { - filter: '.no-reorder', + filter: '.not-sortable', forceFallback: true, onStart: function(event) { $('.pages-children').each(function() { @@ -187,7 +187,7 @@ $(function() { }).css('opacity', '0.5'); }, onMove: function(event) { - return !$(event.related).hasClass('no-reorder'); + return !$(event.related).hasClass('not-sortable'); }, onEnd: function (event) { $('.pages-children').each(function() { @@ -519,6 +519,224 @@ var Tooltip = function(referenceElement, text, options) { }; +var Chart = (function(element, data) { + var options = { + showArea: true, + fullWidth: true, + scaleMinSpace: 20, + divisor: 5, + chartPadding: 20, + lineSmooth: false, + low: 0, + axisX: { + showGrid: false, + labelOffset: {x: 0, y: 10} + }, + axisY: { + onlyInteger: true, + offset: 15, + labelOffset: {x: 0, y: 5} + } + }; + + new Chartist.Line(element, data, options); +}); + +$(function() { + $('[data-chart-data]').each(function() { + new Chart(this, $(this).data('chart-data')); + }); + $('.ct-chart').on('mouseover', '.ct-point', function() { + new Tooltip($(this), $(this).attr('ct:value'), {offset: {x: 0, y: -8}}); + }); +}); + +var ImagePicker = (function() { + $(function() { + $('.image-input').click(function() { + var $this = $(this); + var value = $this.val(); + Modal.show('imagesModal', null, function($modal) { + $modal.find('.image-picker-confirm').data('target', $this); + $modal.find('.image-picker-thumbnail').each(function() { + if ($(this).data('text') == value) { + $(this).addClass('selected'); + return false; + } + }); + }); + }); + + $('.image-picker').each(function() { + var $this = $(this); + var options = $this.children('option'); + var container = $('
', {class: 'image-picker-thumbnails'}); + for (var i = 0; i < options.length; i++) { + $('
', { + class: 'image-picker-thumbnail', + 'data-value': options[i].value, + 'data-text': options[i].text + }).css({ + 'background-image': 'url(' + options[i].value + ')' + }).appendTo(container); + } + $this.before(container); + $this.hide(); + }); + + $('.image-picker-confirm').click(function() { + $(this).data('target').val($(this).parent().find('.image-picker-thumbnail.selected').data('text')); + }); + + $('.image-picker-thumbnail').click(function() { + $(this).siblings().removeClass('selected'); + $(this).addClass('selected'); + $(this).parent().siblings('.image-input').val($(this).data('value')); + }); + }); +})(); + +var Modal = (function() { + $(function() { + $('.modal [data-dismiss]').click(function() { + if ($(this).is('[data-validate]')) { + var valid = Modal.validate($(this).data('dismiss')); + if (!valid) return; + } + Modal.hide($(this).data('dismiss')); + }); + $('.modal').click(function(event) { + if (event.target === this) Modal.hide(); + }); + }); + + return { + show: function (id, action, callback) { + var $modal = $('#' + id); + $modal.addClass('show'); + if (action !== null) { + $modal.find('form').attr('action', action); + } + $modal.find('[autofocus]').first().focus(); // Firefox bug + if (typeof callback === 'function') callback($modal); + this.createBackdrop(); + }, + hide: function(id) { + var $modal = id === undefined ? $('.modal') : $('#' + id); + $modal.removeClass('show'); + this.removeBackdrop(); + }, + createBackdrop: function() { + if (!$('.modal-backdrop').length) { + $('
', { + class: 'modal-backdrop' + }).appendTo('body'); + } + }, + removeBackdrop: function() { + $('.modal-backdrop').remove(); + }, + validate: function(id) { + var valid = false; + var $modal = $('#' + id); + $modal.find('[required]').each(function() { + if ($(this).val() === '') { + $(this).addClass('animated shake'); + $(this).focus(); + $modal.find('.modal-error').show(); + valid = false; + return false; + } + valid = true; + }); + return valid; + } + }; +})(); + +var Utils = (function() { + return { + debounce: function(callback, delay, leading) { + var timer = null; + var context; + var args; + + function wrapper() { + context = this; + args = arguments; + + if (timer) clearTimeout(timer); + + if (leading && !timer) callback.apply(context, args); + + timer = setTimeout(function() { + if (!leading) callback.apply(context, args); + timer = null; + }, delay); + } + + return wrapper; + }, + escapeRegExp: function(string) { + return string.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); + }, + offset: function(element) { + var rect = element.getBoundingClientRect(); + var doc = document.documentElement; + var body = document.body; + + var XOffset = window.pageXOffset || doc.scrollLeft || body.scrollLeft; + var YOffset = window.pageYOffset || doc.scrollTop || body.scrollTop; + + return { + top: rect.top + YOffset, + left: rect.left + XOffset + }; + }, + slug: function(string) { + var translate = {"\t": "", "\r": "", "!": "", "\"": "", "#": "", "$": "", "%": "", "'": "", "(": "", ")": "", "*": "", "+": "", ",": "", ".": "", ":": "", ";": "", "<": "", "=": "", ">": "", "?": "", "@": "", "[": "", "]": "", "^": "", "`": "", "{": "", "|": "", "}": "", "¡": "", "£": "", "¤": "", "¥": "", "¦": "", "§": "", "«": "", "°": "", "»": "", "‘": "", "’": "", "“": "", "”": "", "\n": "-", " ": "-", "-": "-", "–": "-", "—": "-", "\/": "-", "\\": "-", "_": "-", "~": "-", "À": "A", "Á": "A", "Â": "A", "Ã": "A", "Ä": "A", "Å": "A", "Æ": "Ae", "Ç": "C", "Ð": "D", "È": "E", "É": "E", "Ê": "E", "Ë": "E", "Ì": "I", "Í": "I", "Î": "I", "Ï": "I", "Ñ": "N", "Ò": "O", "Ó": "O", "Ô": "O", "Õ": "O", "Ö": "O", "Ø": "O", "Œ": "Oe", "Š": "S", "Þ": "Th", "Ù": "U", "Ú": "U", "Û": "U", "Ü": "U", "Ý": "Y", "à": "a", "á": "a", "â": "a", "ã": "a", "ä": "ae", "å": "a", "æ": "ae", "¢": "c", "ç": "c", "ð": "d", "è": "e", "é": "e", "ê": "e", "ë": "e", "ì": "i", "í": "i", "î": "i", "ï": "i", "ñ": "n", "ò": "o", "ó": "o", "ô": "o", "õ": "o", "ö": "oe", "ø": "o", "œ": "oe", "š": "s", "ß": "ss", "þ": "th", "ù": "u", "ú": "u", "û": "u", "ü": "ue", "ý": "y", "ÿ": "y", "Ÿ": "y"}; + var char; + string = string.toLowerCase(); + for (char in translate) { + string = string.split(char).join(translate[char]); + } + return string.replace(/[^a-z0-9-]/g, '').replace(/^-+|-+$/g, '').replace(/-+/g, '-'); + }, + throttle: function(callback, delay) { + var timer = null; + var context; + var args; + + function wrapper() { + context = this; + args = arguments; + + if (timer) return; + + callback.apply(context, args); + + timer = setTimeout(function() { + wrapper.apply(context, args); + timer = null; + }, delay); + } + + return wrapper; + }, + uriPrependBase: function(base, path) { + var regexp = /^\/+|\/+$/im; + base = base.replace(regexp, '').split('/'); + path = path.replace(regexp, '').split('/'); + for (i = 0; i < base.length; i++) { + if (base[i] === path[0] && base[i + 1] !== path[0]) { + base = base.slice(0, i); + } + } + return '/' + base.concat(path).join('/') + '/'; + } + }; +})(); + (function($) { $.fn.datePicker = function(options) { var $input; @@ -972,221 +1190,3 @@ var Tooltip = function(referenceElement, text, options) { }); }; }(jQuery)); - -var Chart = (function(element, data) { - var options = { - showArea: true, - fullWidth: true, - scaleMinSpace: 20, - divisor: 5, - chartPadding: 20, - lineSmooth: false, - low: 0, - axisX: { - showGrid: false, - labelOffset: {x: 0, y: 10} - }, - axisY: { - onlyInteger: true, - offset: 15, - labelOffset: {x: 0, y: 5} - } - }; - - new Chartist.Line(element, data, options); -}); - -$(function() { - $('[data-chart-data]').each(function() { - new Chart(this, $(this).data('chart-data')); - }); - $('.ct-chart').on('mouseover', '.ct-point', function() { - new Tooltip($(this), $(this).attr('ct:value'), {offset: {x: 0, y: -8}}); - }); -}); - -var ImagePicker = (function() { - $(function() { - $('.image-input').click(function() { - var $this = $(this); - var value = $this.val(); - Modal.show('imagesModal', null, function($modal) { - $modal.find('.image-picker-confirm').data('target', $this); - $modal.find('.image-picker-thumbnail').each(function() { - if ($(this).data('text') == value) { - $(this).addClass('selected'); - return false; - } - }); - }); - }); - - $('.image-picker').each(function() { - var $this = $(this); - var options = $this.children('option'); - var container = $('
', {class: 'image-picker-thumbnails'}); - for (var i = 0; i < options.length; i++) { - $('
', { - class: 'image-picker-thumbnail', - 'data-value': options[i].value, - 'data-text': options[i].text - }).css({ - 'background-image': 'url(' + options[i].value + ')' - }).appendTo(container); - } - $this.before(container); - $this.hide(); - }); - - $('.image-picker-confirm').click(function() { - $(this).data('target').val($(this).parent().find('.image-picker-thumbnail.selected').data('text')); - }); - - $('.image-picker-thumbnail').click(function() { - $(this).siblings().removeClass('selected'); - $(this).addClass('selected'); - $(this).parent().siblings('.image-input').val($(this).data('value')); - }); - }); -})(); - -var Modal = (function() { - $(function() { - $('.modal [data-dismiss]').click(function() { - if ($(this).is('[data-validate]')) { - var valid = Modal.validate($(this).data('dismiss')); - if (!valid) return; - } - Modal.hide($(this).data('dismiss')); - }); - $('.modal').click(function(event) { - if (event.target === this) Modal.hide(); - }); - }); - - return { - show: function (id, action, callback) { - var $modal = $('#' + id); - $modal.addClass('show'); - if (action !== null) { - $modal.find('form').attr('action', action); - } - $modal.find('[autofocus]').first().focus(); // Firefox bug - if (typeof callback === 'function') callback($modal); - this.createBackdrop(); - }, - hide: function(id) { - var $modal = id === undefined ? $('.modal') : $('#' + id); - $modal.removeClass('show'); - this.removeBackdrop(); - }, - createBackdrop: function() { - if (!$('.modal-backdrop').length) { - $('
', { - class: 'modal-backdrop' - }).appendTo('body'); - } - }, - removeBackdrop: function() { - $('.modal-backdrop').remove(); - }, - validate: function(id) { - var valid = false; - var $modal = $('#' + id); - $modal.find('[required]').each(function() { - if ($(this).val() === '') { - $(this).addClass('animated shake'); - $(this).focus(); - $modal.find('.modal-error').show(); - valid = false; - return false; - } - valid = true; - }); - return valid; - } - }; -})(); - -var Utils = (function() { - return { - debounce: function(callback, delay, leading) { - var timer = null; - var context; - var args; - - function wrapper() { - context = this; - args = arguments; - - if (timer) clearTimeout(timer); - - if (leading && !timer) callback.apply(context, args); - - timer = setTimeout(function() { - if (!leading) callback.apply(context, args); - timer = null; - }, delay); - } - - return wrapper; - }, - escapeRegExp: function(string) { - return string.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); - }, - offset: function(element) { - var rect = element.getBoundingClientRect(); - var doc = document.documentElement; - var body = document.body; - - var XOffset = window.pageXOffset || doc.scrollLeft || body.scrollLeft; - var YOffset = window.pageYOffset || doc.scrollTop || body.scrollTop; - - return { - top: rect.top + YOffset, - left: rect.left + XOffset - }; - }, - slug: function(string) { - var translate = {"\t": "", "\r": "", "!": "", "\"": "", "#": "", "$": "", "%": "", "'": "", "(": "", ")": "", "*": "", "+": "", ",": "", ".": "", ":": "", ";": "", "<": "", "=": "", ">": "", "?": "", "@": "", "[": "", "]": "", "^": "", "`": "", "{": "", "|": "", "}": "", "¡": "", "£": "", "¤": "", "¥": "", "¦": "", "§": "", "«": "", "°": "", "»": "", "‘": "", "’": "", "“": "", "”": "", "\n": "-", " ": "-", "-": "-", "–": "-", "—": "-", "\/": "-", "\\": "-", "_": "-", "~": "-", "À": "A", "Á": "A", "Â": "A", "Ã": "A", "Ä": "A", "Å": "A", "Æ": "Ae", "Ç": "C", "Ð": "D", "È": "E", "É": "E", "Ê": "E", "Ë": "E", "Ì": "I", "Í": "I", "Î": "I", "Ï": "I", "Ñ": "N", "Ò": "O", "Ó": "O", "Ô": "O", "Õ": "O", "Ö": "O", "Ø": "O", "Œ": "Oe", "Š": "S", "Þ": "Th", "Ù": "U", "Ú": "U", "Û": "U", "Ü": "U", "Ý": "Y", "à": "a", "á": "a", "â": "a", "ã": "a", "ä": "ae", "å": "a", "æ": "ae", "¢": "c", "ç": "c", "ð": "d", "è": "e", "é": "e", "ê": "e", "ë": "e", "ì": "i", "í": "i", "î": "i", "ï": "i", "ñ": "n", "ò": "o", "ó": "o", "ô": "o", "õ": "o", "ö": "oe", "ø": "o", "œ": "oe", "š": "s", "ß": "ss", "þ": "th", "ù": "u", "ú": "u", "û": "u", "ü": "ue", "ý": "y", "ÿ": "y", "Ÿ": "y"}; - var char; - string = string.toLowerCase(); - for (char in translate) { - string = string.split(char).join(translate[char]); - } - return string.replace(/[^a-z0-9-]/g, '').replace(/^-+|-+$/g, '').replace(/-+/g, '-'); - }, - throttle: function(callback, delay) { - var timer = null; - var context; - var args; - - function wrapper() { - context = this; - args = arguments; - - if (timer) return; - - callback.apply(context, args); - - timer = setTimeout(function() { - wrapper.apply(context, args); - timer = null; - }, delay); - } - - return wrapper; - }, - uriPrependBase: function(base, path) { - var regexp = /^\/+|\/+$/im; - base = base.replace(regexp, '').split('/'); - path = path.replace(regexp, '').split('/'); - for (i = 0; i < base.length; i++) { - if (base[i] === path[0] && base[i + 1] !== path[0]) { - base = base.slice(0, i); - } - } - return '/' + base.concat(path).join('/') + '/'; - } - }; -})(); diff --git a/admin/assets/js/app.min.js b/admin/assets/js/app.min.js index 929f5a51..f42c9d85 100755 --- a/admin/assets/js/app.min.js +++ b/admin/assets/js/app.min.js @@ -1 +1 @@ -$(function(){$("[data-modal]").click(function(){var t=$(this),e=t.data("modal"),a=t.data("modal-action");a?Modal.show(e,a):Modal.show(e)}),$(".input-reset").click(function(){var t=$("#"+$(this).data("reset"));t.val(""),t.change()}),$("[data-auto-upload]").change(function(){$(this).closest("form").submit()}),$(".file-input-label").on("drag dragstart dragend dragover dragenter dragleave drop",function(t){t.preventDefault()}).on("drop",function(t){var e=$("#"+$(this).attr("for"));e.prop("files",t.originalEvent.dataTransfer.files),e.change()}).on("dragover dragenter",function(){$(this).addClass("drag")}).on("dragleave drop",function(){$(this).removeClass("drag")}),$("input:file").change(function(){var t=$(this).prop("files");t.length&&$('label[for="'+$(this).attr("id")+'"] span').text(t[0].name)}),$(".page-children-toggle").click(function(t){t.stopPropagation(),$(this).closest("li").children(".pages-list").toggle(),$(this).toggleClass("toggle-expanded toggle-collapsed")}),$(".page-details a").click(function(t){t.stopPropagation()}),$("#expand-all-pages").click(function(){$(this).blur(),$(".pages-children").show(),$(".pages-list").find(".page-children-toggle").removeClass("toggle-collapsed").addClass("toggle-expanded")}),$("#collapse-all-pages").click(function(){$(this).blur(),$(".pages-children").hide(),$(".pages-list").find(".page-children-toggle").removeClass("toggle-expanded").addClass("toggle-collapsed")}),$(".page-search").focus(function(){$(".pages-children").each(function(){$(this).data("visible",$(this).is(":visible"))})}),$(".page-search").keyup(Utils.debounce(function(){var t=$(this).val();if(0==t.length)$(".pages-children").each(function(){$(this).toggle($(this).data("visible"))}),$(".page-details").css("padding-left",""),$(".pages-item, .page-children-toggle").show();else{$(".pages-children").show(),$(".page-children-toggle").hide(),$(".page-details").css("padding-left","0");var a=new RegExp(Utils.escapeRegExp(t),"i");$(".page-title a").each(function(){var t=$(this).closest(".pages-item"),e=!!$(this).text().match(a);e&&0,t.toggle(e)})}},100)),$(".page-details").click(function(){var t=$(this).find(".page-children-toggle").first();t.length&&t.click()}),$("#page-title","#newPageModal").keyup(function(){$("#page-slug","#newPageModal").val(Utils.slug($(this).val()))}),$("#page-slug","#newPageModal").keyup(function(){$(this).val($(this).val().replace(" ","-").replace(/[^A-Za-z0-9\-]/g,""))}).blur(function(){""==$(this).val()&&$("#page-title","#newPageModal").trigger("keyup")}),$("#page-parent","#newPageModal").change(function(){var t=$(this).find("option:selected"),e=$("#page-template","#newPageModal"),a=t.data("allowed-templates");a?(a=a.split(", "),e.data("previous-value",e.val()).val(a[0]).find("option").each(function(){-1==a.indexOf($(this).val())&&$(this).attr("disabled",!0)})):e.find("option[disabled]").length&&e.val(e.data("previous-value")).removeData("previous-value").find("option").removeAttr("disabled")}),$(document).keyup(function(t){27==t.which&&Modal.hide()}).keydown(function(t){if((t.ctrlKey||t.metaKey)&&70==t.which&&$(".page-search:not(:focus)").length)return $(".page-search").focus(),!1}),$(".tabs-tab[data-tab]").click(function(){$(this).addClass("active").siblings().removeClass("active")}),$(".tag-input").tagInput(),$("input[data-enable]").change(function(){var a=$(this).is(":checked");$.each($(this).data("enable").split(","),function(t,e){$('input[name="'+e+'"]').attr("disabled",!a)})}),$(".toggle-navigation").click(function(){$(".sidebar").toggleClass("show")}),$(".overflow-title").mouseover(function(){var t=$(this);t.prop("offsetWidth") ":("\n"===t?"\n":"\n\n")+"> ","")}),$("[data-command=link]",e).click(function(){var t=textarea.selectionStart,e=textarea.selectionEnd,a=t===e?"":textarea.value.substring(t,e),n=textarea.value.substring(0,t),i=textarea.value.substring(e,textarea.value.length);/^(https?:\/\/|mailto:)/i.test(a)?(textarea.value=n+"[]("+a+")"+i,textarea.focus(),textarea.setSelectionRange(t+1,t+1)):""!==a?(textarea.value=n+"["+a+"](http://)"+i,textarea.focus(),textarea.setSelectionRange(t+a.length+10,t+a.length+10)):s(textarea,"[","](http://)")}),$("[data-command=image]",e).click(function(){var t=o(textarea),e="\n\n";"\n"===t?e="\n":void 0===t&&(e=""),s(textarea,e+"![](",")")}),$("[data-command=summary]",e).click(function(){var t=o(textarea);a()||(console.log(t),s(textarea,(void 0===t||"\n"===t?"":"\n")+"\n===\n\n",""),$(this).attr("disabled",!0))})},Form=function(t){var e=$(t),a=function(){return e.serialize()!=e.data("original-data")};return e.data("original-data",e.serialize()),$(window).on("beforeunload",function(){if(a())return!0}),e.submit(function(){$(window).off("beforeunload")}),$('a[href]:not([href^="#"]):not([target="_blank"])').click(function(t){if(a()){var e=this;t.preventDefault(),Modal.show("changesModal",null,function(t){t.find(".button-continue").click(function(){$(window).off("beforeunload"),window.location.href=$(this).data("href")}).attr("data-href",e.href)})}}),{hasChanged:a}},Notification=function(t,e,a){var n=!1;if(0<$(".notification").length){var i=$(".notification:last");n=i.offset().top+i.outerHeight(!0)}var o=$("
",{class:"notification"}).text(t).appendTo("body");n&&o.css("top",n),e&&o.addClass("notification-"+e),setTimeout(function(){offset=o.outerHeight(!0),$(".notification").each(function(){var t=$(this);t.is(o)?t.addClass("fadeout"):t.css("top","-="+offset)}),setTimeout(function(){o.remove()},400)},a)},Request=function(t,e){var a=$.ajax(t);return"function"==typeof e&&a.always(function(){var t=a.responseJSON||{};403==(t.code||a.status)?location.reload():e(t,a)}),a},Tooltip=function(t,e,s){var a={container:document.body,position:"top",offset:{x:0,y:0},delay:500};s=$.extend({},a,s);var n,r=$(t);function i(){n=setTimeout(function(){var t=$('