EasyImages2.0/public/static/zui/js/zui.min.js

16 lines
96 KiB
JavaScript
Raw Normal View History

/*!
2022-07-10 14:48:21 +00:00
* ZUI: Standard edition - v1.10.0 - 2022-05-20
* http://openzui.com
* GitHub: https://github.com/easysoft/zui.git
2022-07-10 14:48:21 +00:00
* Copyright (c) 2022 cnezsoft.com; Licensed MIT
*/
/*! Some code copy from Bootstrap v3.0.0 by @fat and @mdo. (Copyright 2013 Twitter, Inc. Licensed under http://www.apache.org/licenses/)*/
2022-07-10 14:48:21 +00:00
!function(t,e,n){"use strict";if("undefined"==typeof t)throw new Error("ZUI requires jQuery");Number.isNaN||"function"!=typeof isNaN||(Number.isNaN=isNaN),Number.parseInt||"function"!=typeof parseInt||(Number.parseInt=parseInt),Number.parseFloat||"function"!=typeof parseFloat||(Number.parseFloat=parseFloat),t.zui||(t.zui=function(e){t.isPlainObject(e)&&t.extend(t.zui,e)});var i={all:-1,left:0,middle:1,right:2},o=0;t.zui({uuid:function(t){var e=1e5*(Date.now()-1580890015292)+10*Math.floor(1e4*Math.random())+o++%10;return t?e:e.toString(36)},callEvent:function(t,e,i){if("function"==typeof t){i!==n&&(t=t.bind(i));var o=t(e);return e&&(e.result=o),!(o!==n&&!o)}return 1},strCode:function(t){var e=0;if("string"!=typeof t&&(t=String(t)),t&&t.length)for(var n=0;n<t.length;++n)e+=(n+1)*t.charCodeAt(n);return e},getMouseButtonCode:function(t){return"number"!=typeof t&&(t=i[t]),t!==n&&null!==t||(t=-1),t},defaultLang:"en",clientLang:function(){var n,i=e.config;if("undefined"!=typeof i&&i.clientLang&&(n=i.clientLang),!n){var o=t("html").attr("lang");n=o?o:navigator.userLanguage||navigator.userLanguage||t.zui.defaultLang}return n.replace("-","_").toLowerCase()},langDataMap:{},addLangData:function(e,n,i){var o={};i&&n&&e?(o[n]={},o[n][e]=i):e&&n&&!i?(i=n,t.each(i,function(t){o[t]={},o[t][e]=i[t]})):!e||n||i||t.each(e,function(e){var n=i[e];t.each(n,function(t){o[t]||(o[t]={}),o[t][e]=n[t]})}),t.extend(!0,t.zui.langDataMap,o)},getLangData:function(e,n,i){if(!arguments.length)return t.extend({},t.zui.langDataMap);if(1===arguments.length)return t.extend({},t.zui.langDataMap[e]);if(2===arguments.length){var o=t.zui.langDataMap[e];return o?n?o[n]:o:{}}if(3===arguments.length){n=n||t.zui.clientLang();var o=t.zui.langDataMap[e],a=o?o[n]:{};return t.extend(!0,{},i[n]||i.en||i.zh_cn,a)}return null},lang:function(){return arguments.length&&t.isPlainObject(arguments[arguments.length-1])?t.zui.addLangData.apply(null,arguments):t.zui.getLangData.apply(null,arguments)},_scrollbarWidth:0,getScrollbarSize:function(){var e=t.zui._scrollbarWidth;if(!e){var n=document.createElement("div");n.className="scrollbar-measure",document.body.appendChild(n),t.zui._scrollbarWidth=e=n.offsetWidth-n.clientWidth,document.body.removeChild(n)}return e},checkBodyScrollbar:function(){return document.body.clientWidth>=e.innerWidth?0:t.zui.getScrollbarSize()},fixBodyScrollbar:function(){if(t.zui.checkBodyScrollbar()){var e=t("body"),n=parseInt(e.css("padding-right")||0,10);return t.zui._scrollbarWidth&&e.css({paddingRight:n+t.zui._scrollbarWidth,overflowY:"hidden"}),!0}},resetBodyScrollbar:function(){t("body").css({paddingRight:"",overflowY:""})}}),t.fn.callEvent=function(e,i,o){var a=t(this),r=e.indexOf(".zui."),s=r<0?e:e.substring(0,r),l=t.Event(s,i);if(o===n&&r>0&&(o=a.data(e.substring(r+1))),o&&o.options){var d=o.options[s];"function"==typeof d&&(l.result=t.zui.callEvent(d,l,o))}return a.trigger(l),l},t.fn.callComEvent=function(t,e,i){i===n||Array.isArray(i)||(i=[i]);var o,a=this;a.trigger(e,i);var r=t.options[e];return r&&(o=r.apply(t,i)),o}}(jQuery,window,void 0),function(){"use strict";function t(t,e){return n&&!e?requestAnimationFrame(t):setTimeout(t,e||0)}function e(t){return n?cancelAnimationFrame(t):void clearTimeout(t)}var n="function"==typeof window.requestAnimationFrame;$.zui({asap:t,clearAsap:e})}(),function(t){"use strict";t.fn.fixOlPd=function(e){return e=e||10,this.each(function(){var n=t(this);n.css("paddingLeft",Math.ceil(Math.log10(n.children().length))*e+10)})},t(function(){t(".ol-pd-fix,.article ol").fixOlPd()})}(jQuery),+function(t){"use strict";var e=function(n,i){this.$element=t(n),this.options=t.extend({},e.DEFAULTS,i),this.isLoading=!1};e.DEFAULTS={loadingText:"loading..."},e.prototype.setState=function(t){var e="disabled",n=this.$element,i=n.is("input")?"val":"html",o=n.data();t+="Text",o.resetText||n.data("resetText",n[i]()),n[i](o[t]||this.options[t]),setTimeout(function(){"loadingText"==t?(this.isLoading=!0,n.addClass(e).attr(e,e)):this.isLoading&&(this.isLoading=!1,n.removeClass(e).removeAttr(e))}.bind(this),0)},e.prototype.toggle=function
* jQuery resize event - v1.1
* http://benalman.com/projects/jquery-resize-plugin/
* Copyright (c) 2010 "Cowboy" Ben Alman
* MIT & GPL http://benalman.com/about/license/
*/
2022-07-10 14:48:21 +00:00
function(t,e,n){"$:nomunge";function i(){o=e[s](function(){a.each(function(){var e=t(this),n=e.width(),i=e.height(),o=t.data(this,d);n===o.w&&i===o.h||e.trigger(l,[o.w=n,o.h=i])}),i()},r[c])}var o,a=t([]),r=t.resize=t.extend(t.resize,{}),s="setTimeout",l="resize",d=l+"-special-event",c="delay",p="throttleWindow";r[c]=250,r[p]=!0,t.event.special[l]={setup:function(){if(!r[p]&&this[s])return!1;var e=t(this);a=a.add(e),t.data(this,d,{w:e.width(),h:e.height()}),1===a.length&&i()},teardown:function(){if(!r[p]&&this[s])return!1;var e=t(this);a=a.not(e),e.removeData(d),a.length||clearTimeout(o)},add:function(e){function i(e,i,a){var r=t(this),s=t.data(this,d)||{};s.w=i!==n?i:r.width(),s.h=a!==n?a:r.height(),o.apply(this,arguments)}if(!r[p]&&this[s])return!1;var o;return"function"==typeof e?(o=e,i):(o=e.handler,void(e.handler=i))}}}(jQuery,this),+function(t){"use strict";function e(i,o){var a,r=this.process.bind(this);this.$element=t(t(i).is("body")?window:i),this.$body=t("body"),this.$scrollElement=this.$element.on("scroll."+n+".data-api",r),this.options=t.extend({},e.DEFAULTS,o),this.selector||(this.selector=(this.options.target||(a=t(i).attr("href"))&&a.replace(/.*(?=#[^\s]+$)/,"")||"")+" .nav li > a"),this.offsets=t([]),this.targets=t([]),this.activeTarget=null,this.refresh(),this.process()}var n="zui.scrollspy";e.DEFAULTS={offset:10},e.prototype.refresh=function(){var e=this.$element[0]==window?"offset":"position";this.offsets=t([]),this.targets=t([]);var n=this;this.$body.find(this.selector).map(function(){var i=t(this),o=i.data("target")||i.attr("href"),a=/^#./.test(o)&&t(o);return a&&a.length&&a.is(":visible")&&[[a[e]().top+(!t.isWindow(n.$scrollElement.get(0))&&n.$scrollElement.scrollTop()),o]]||null}).sort(function(t,e){return t[0]-e[0]}).each(function(){n.offsets.push(this[0]),n.targets.push(this[1])})},e.prototype.process=function(){var t,e=this.$scrollElement.scrollTop()+this.options.offset,n=this.$scrollElement[0].scrollHeight||this.$body[0].scrollHeight,i=n-this.$scrollElement.height(),o=this.offsets,a=this.targets,r=this.activeTarget;if(e>=i)return r!=(t=a.last()[0])&&this.activate(t);if(r&&e<=o[0])return r!=(t=a[0])&&this.activate(t);for(t=o.length;t--;)r!=a[t]&&e>=o[t]&&(!o[t+1]||e<=o[t+1])&&this.activate(a[t])},e.prototype.activate=function(e){this.activeTarget=e,t(this.selector).parentsUntil(this.options.target,".active").removeClass("active");var i=this.selector+'[data-target="'+e+'"],'+this.selector+'[href="'+e+'"]',o=t(i).parents("li").addClass("active");o.parent(".dropdown-menu").length&&(o=o.closest("li.dropdown").addClass("active")),o.trigger("activate."+n)};var i=t.fn.scrollspy;t.fn.scrollspy=function(i){return this.each(function(){var o=t(this),a=o.data(n),r="object"==typeof i&&i;a||o.data(n,a=new e(this,r)),"string"==typeof i&&a[i]()})},t.fn.scrollspy.Constructor=e,t.fn.scrollspy.noConflict=function(){return t.fn.scrollspy=i,this},t(window).on("load",function(){t('[data-spy="scroll"]').each(function(){var e=t(this);e.scrollspy(e.data())})})}(jQuery),function(t,e){"use strict";var n,i,o="localStorage",a="page_"+t.location.pathname+t.location.search,r=function(){this.silence=!0;try{o in t&&t[o]&&t[o].setItem&&(this.enable=!0,n=t[o])}catch(r){}this.enable||(i={},n={getLength:function(){var t=0;return e.each(i,function(){t++}),t},key:function(t){var n,o=0;return e.each(i,function(e){return o===t?(n=e,!1):void o++}),n},removeItem:function(t){delete i[t]},getItem:function(t){return i[t]},setItem:function(t,e){i[t]=e},clear:function(){i={}}}),this.storage=n,this.page=this.get(a,{})};r.prototype.pageSave=function(){if(e.isEmptyObject(this.page))this.remove(a);else{var t,n=[];for(t in this.page){var i=this.page[t];null===i&&n.push(t)}for(t=n.length-1;t>=0;t--)delete this.page[n[t]];this.set(a,this.page)}},r.prototype.pageRemove=function(t){"undefined"!=typeof this.page[t]&&(this.page[t]=null,this.pageSave())},r.prototype.pageClear=function(){this.page={},this.pageSave()},r.prototype.pageGet=function(t,e){var n=this.page[t];return void 0===e||null!==n&&void 0!==n?n:e},r.prototype.pageSet=function(t,n){e.isPla
"out"==t&&i.leave(i)};t.support.transition&&i.$tip.hasClass("fade")?o.one("bsTransitionEnd",y).emulateTransitionEnd(150):y()}},e.prototype.applyPlacement=function(t,e){var n,i=this.tip(),o=i[0].offsetWidth,a=i[0].offsetHeight,r=parseInt(i.css("margin-top"),10),s=parseInt(i.css("margin-left"),10);isNaN(r)&&(r=0),isNaN(s)&&(s=0),t.top=t.top+r,t.left=t.left+s,i.offset(t).addClass("in");var l=i[0].offsetWidth,d=i[0].offsetHeight;if("top"==e&&d!=a&&(n=!0,t.top=t.top+a-d),/bottom|top/.test(e)){var c=0;t.left<0&&(c=t.left*-2,t.left=0,i.offset(t),l=i[0].offsetWidth,d=i[0].offsetHeight),this.replaceArrow(c-o+l,l,"left")}else this.replaceArrow(d-a,d,"top");n&&i.offset(t)},e.prototype.replaceArrow=function(t,e,n){this.arrow().css(n,t?50*(1-t/e)+"%":"")},e.prototype.setContent=function(t){var e=this.tip(),n=t||this.getTitle();this.options.tipId&&e.attr("id",this.options.tipId),this.options.tipClass&&e.addClass(this.options.tipClass),e.find(".tooltip-inner")[this.options.html?"html":"text"](n),e.removeClass("fade in top bottom left right")},e.prototype.hide=function(){function e(){"in"!=n.hoverState&&i.detach()}var n=this,i=this.tip(),o=t.Event("hide.zui."+this.type);if(this.$element.trigger(o),!o.isDefaultPrevented())return i.removeClass("in"),t.support.transition&&this.$tip.hasClass("fade")?i.one(t.support.transition.end,e).emulateTransitionEnd(150):e(),this.$element.trigger("hidden.zui."+this.type),this},e.prototype.fixTitle=function(){var t=this.$element;(t.attr("title")||"string"!=typeof t.attr("data-original-title"))&&t.attr("data-original-title",t.attr("title")||"").attr("title","")},e.prototype.hasContent=function(){return this.getTitle()},e.prototype.getPosition=function(){var e=this.$element[0];return t.extend({},"function"==typeof e.getBoundingClientRect?e.getBoundingClientRect():{width:e.offsetWidth,height:e.offsetHeight},this.$element.offset())},e.prototype.getCalculatedOffset=function(t,e,n,i){return"bottom"==t?{top:e.top+e.height,left:e.left+e.width/2-n/2}:"top"==t?{top:e.top-i,left:e.left+e.width/2-n/2}:"left"==t?{top:e.top+e.height/2-i/2,left:e.left-n}:{top:e.top+e.height/2-i/2,left:e.left+e.width}},e.prototype.getTitle=function(){var t,e=this.$element,n=this.options;return t=e.attr("data-original-title")||("function"==typeof n.title?n.title.call(e[0]):n.title)},e.prototype.tip=function(){return this.$tip=this.$tip||t(this.options.template)},e.prototype.arrow=function(){return this.$arrow=this.$arrow||this.tip().find(".tooltip-arrow")},e.prototype.validate=function(){this.$element[0].parentNode||(this.hide(),this.$element=null,this.options=null)},e.prototype.enable=function(){this.enabled=!0},e.prototype.disable=function(){this.enabled=!1},e.prototype.toggleEnabled=function(){this.enabled=!this.enabled},e.prototype.toggle=function(e){var n=e?t(e.currentTarget)[this.type](this.getDelegateOptions()).data("zui."+this.type):this;n.tip().hasClass("in")?n.leave(n):n.enter(n)},e.prototype.destroy=function(){this.hide().$element.off("."+this.type).removeData("zui."+this.type)};var n=t.fn.tooltip;t.fn.tooltip=function(n,i){return this.each(function(){var o=t(this),a=o.data("zui.tooltip"),r="object"==typeof n&&n;a||o.data("zui.tooltip",a=new e(this,r)),"string"==typeof n&&a[n](i)})},t.fn.tooltip.Constructor=e,t.fn.tooltip.noConflict=function(){return t.fn.tooltip=n,this}}(window.jQuery),+function(t){"use strict";var e=function(t,e){this.init("popover",t,e)};if(!t.fn.tooltip)throw new Error("Popover requires tooltip.js");e.DEFAULTS=t.extend({},t.fn.tooltip.Constructor.DEFAULTS,{placement:"right",trigger:"click",content:"",template:'<div class="popover"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'}),e.prototype=t.extend({},t.fn.tooltip.Constructor.prototype),e.prototype.constructor=e,e.prototype.getDefaults=function(){return e.DEFAULTS},e.prototype.setContent=function(){var t=this.tip(),e=this.getTarget();if(e)return e.find(".arrow").length<1&&t.addClass("no-arrow"),void t.html(e.html());var n=this.getTitle(),i=this.getContent();t.find(".popover-title")[this.options.html?"ht
function(t){"use strict";t.zui.imgReady=function(){var t=[],e=null,n=function(){for(var e=0;e<t.length;e++)t[e].end?t.splice(e--,1):t[e]();!t.length&&i()},i=function(){clearInterval(e),e=null};return function(i,o,a,r){var s,l,d,c,p,u=new Image;return u.src=i,u.complete?(o.call(u),void(a&&a.call(u))):(l=u.width,d=u.height,u.onerror=function(){r&&r.call(u),s.end=!0,u=u.onload=u.onerror=null},s=function(){c=u.width,p=u.height,(c!==l||p!==d||c*p>1024)&&(o.call(u),s.end=!0)},s(),u.onload=function(){!s.end&&s(),a&&a.call(u),u=u.onload=u.onerror=null},void(s.end||(t.push(s),null===e&&(e=setInterval(n,40)))))}}()}(jQuery),function(t,e,n){"use strict";if(!t.fn.modalTrigger)throw new Error("modal & modalTrigger requires for lightbox");if(!t.zui.imgReady)throw new Error("imgReady requires for lightbox");var i=function(e,n){this.$=t(e),this.options=this.getOptions(n),this.init()};i.DEFAULTS={modalTeamplate:'<div class="icon-spinner icon-spin loader"></div><div class="modal-dialog"><button class="close" data-dismiss="modal" aria-hidden="true"><i class="icon-remove"></i></button><button class="controller prev"><i class="icon icon-chevron-left"></i></button><button class="controller next"><i class="icon icon-chevron-right"></i></button><img class="lightbox-img" src="{image}" alt="" data-dismiss="modal" /><div class="caption"><div class="content">{caption}<div></div></div>'},i.prototype.getOptions=function(e){var n="image";return e=t.extend({},i.DEFAULTS,this.$.data(),e),e[n]||(e[n]=this.$.attr("src")||this.$.attr("href")||this.$.find("img").attr("src"),this.$.data(n,e[n])),e},i.prototype.init=function(){this.bindEvents()},i.prototype.initGroups=function(){var e=this.$.data("groups");e||(e=t('[data-toggle="lightbox"][data-group="'+this.options.group+'"], [data-lightbox-group="'+this.options.group+'"]'),this.$.data("groups",e),e.each(function(e){t(this).attr("data-group-index",e)})),this.groups=e,this.groupIndex=parseInt(this.$.data("group-index"))},i.prototype.setImage=function(t,e){void 0!==t&&(this.options.image=t),void 0!==e&&(this.options.caption=e)},i.prototype.show=function(t,e){this.setImage(t,e),this.$.triggerHandler("click")},i.prototype.bindEvents=function(){var i=this.$,o=this,a=this.options;return!!a.image&&void i.modalTrigger({type:"custom",name:"lightboxModal",position:"center",custom:function(i){o.initGroups();var r=i.modal,s=o.groups,l=o.groupIndex;r.addClass("modal-lightbox").html(a.modalTeamplate.format(a)).toggleClass("lightbox-with-caption","string"==typeof a.caption).removeClass("lightbox-full").data("group-index",l);var d=r.find(".modal-dialog"),c=t(e).width();t.zui.imgReady(a.image,function(){d.css({width:n.min(c,this.width)}),c<this.width+30&&r.addClass("lightbox-full"),i.ready(200)}),r.find(".prev").toggleClass("show",s.filter('[data-group-index="'+(l-1)+'"]').length>0),r.find(".next").toggleClass("show",s.filter('[data-group-index="'+(l+1)+'"]').length>0),r.find(".controller").click(function(){var o=t(this),a=r.data("group-index")+(o.hasClass("prev")?-1:1),l=s.filter('[data-group-index="'+a+'"]');if(l.length){var p=l.data("image"),u=l.data("caption");r.addClass("modal-loading").data("group-index",a).toggleClass("lightbox-with-caption","string"==typeof u).removeClass("lightbox-full"),r.find(".lightbox-img").attr("src",p),r.find(".caption > .content").text(u),c=t(e).width(),t.zui.imgReady(p,function(){d.css({width:n.min(c,this.width)}),c<this.width+30&&r.addClass("lightbox-full"),i.ready()})}return r.find(".prev").toggleClass("show",s.filter('[data-group-index="'+(a-1)+'"]').length>0),r.find(".next").toggleClass("show",s.filter('[data-group-index="'+(a+1)+'"]').length>0),!1})}})},t.fn.lightbox=function(e){var n="group"+(new Date).getTime();return this.each(function(){var o=t(this),a="object"==typeof e&&e;"object"==typeof a&&a.group?o.attr("data-lightbox-group",a.group):o.data("group")?o.attr("data-lightbox-group",o.data("group")):o.attr("data-lightbox-group",n),o.data("group",o.data("lightbox-group"));var r=o.data("zui.lightbox");r||o.data("zui.lightbox",r=new i(this,a)),"string"==typeof e&&r[e]()})},t.fn.lightb