-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathasys.min.js
More file actions
8 lines (8 loc) · 25.7 KB
/
asys.min.js
File metadata and controls
8 lines (8 loc) · 25.7 KB
1
2
3
4
5
6
7
8
/*!
* asys.js (C)nabe@abk
* https://github.com/nabe-abk/asys.js
*
* This module need jQuery.
*/
"use strict";String.prototype.chop=function(){return this.slice(0,-1)},String.prototype.tr=function(t,e){function n(t){return null==t?"":t.replace(/(.)\-(.)/g,(function(t,e,n){const a=e.charCodeAt(0),o=n.charCodeAt(0);let i="";for(let t=a,e=0;t<=o&&e<5e3;t++,e++)i+=String.fromCharCode(t);return i}))}const a=n(t),o=n(e);if(a.length!=o.length)throw"String.tr() not match pattern length";return this.split("").map((function(t){const e=a.indexOf(t);return e<0?t:o[e]})).join("")},$.secure=function(t){if(t.match(/^#[^\s,"]+$/)){const e=$(document).find('[id="'+t.substr(1)+'"]');return e.length<2?e:(console.error('$.secure() error. "'+t+'" is duplicate.'),$([]))}return $(document).find(t)},$.fn.showDelay=function(){let t=Array.from(arguments);return t.unshift($$.DefaultShowSpeed),$.fn.show.apply(this,t)},$.fn.hideDelay=function(){let t=Array.from(arguments);return t.unshift($$.DefaultShowSpeed),$.fn.hide.apply(this,t)},$.fn.toggleDelay=function(){let t=Array.from(arguments);return t.unshift($$.DefaultShowSpeed),$.fn.toggle.apply(this,t)},$.fn.findx=function(){return $.fn.filter.apply(this,arguments).add($.fn.find.apply(this,arguments))},$.fn.rootfind=function(t){return this.parents().last().find(t)},$.fn.existsData=function(t){return void 0!==this.data(t)},$.fn.parseFormHash=function(t){return this._parseForm(!1,t)},$.fn.parseFormFD=function(t){return this._parseForm(!0,t)},$.fn._parseForm=function(t,e){const n=t?new FormData:{},a=e instanceof $||void 0===e?e:$(e);return this.find("input, select, textarea").each((function(e,o){if(o.disabled)return;if("checkbox"==o.type&&!o.checked)return;if(a&&a.find(o).length)return;const i=o.name;if("INPUT"!=o.tagName||"file"!=o.type)null!=i&&""!=i&&(t?n.append(i,$(o).val()):n[i]=$(o).val());else{if(!t)return;const e=o.files;for(let t=0;t<e.length;t++)n.append(i,e[t])}})),n},$.fn.anySerialize=function(){return this.find("input, textarea, select").serialize()},$.fn.anySerializeArray=function(){return this.find("input, textarea, select").serializeArray()},$.fn.onSequence=function(t,e,n){const a="_on_"+t.replace(/[^\w]/g,"_");return this.each((function(o,i){const s=$(i);if(!s.data(a)){const e=[];s.data(a,e),s.on(t,(function(){for(var t in e){if(!e[t].func.apply(this,arguments))return!1}return!0}))}const r=s.data(a);r.push({priority:e,func:n}),s.data(a,r.sort((function(t,e){return t.priority-e.priority})))})),this},$.fn.triggerWithOE=function(t,e){const n=jQuery.Event(t,{originalEvent:e}),a=Array.from(arguments);a.unshift(n),$.fn.trigger.apply(this,a)},$.fn.dndEmulation=function(t){function e(t,e,n){const a=$.Event(t);return a.altKey=e.altKey,a.metaKey=e.metaKey,a.ctrlKey=e.ctrlKey,a.shiftKey=e.shiftKey,a.clientX=n.clientX,a.clientY=n.clientY,a.screenX=n.screenX,a.screenY=n.screenY,a.pageX=n.pageX,a.pageY=n.pageY,a.which=1,a}function n(t){for(var e=[];t&&(e.push(t),t!=self);)t=t.parentNode;return e}t||(t={}),this.each((function(a,o){!function(a){let o,i,s,r;a.addEventListener("touchstart",(function(t){o=t.target,r=t.touches[0];const n=e("mousedown",t,t.touches[0]);$(o).trigger(n),i=!1,s=setTimeout((function(){s=!1,i=!0}),$$.TouchDnDTime)}),{passive:!0}),a.addEventListener("touchend",(function(t){s&&clearTimeout(s),s=!1;const n=e("mouseup",t,t.changedTouches[0]);$(t.target).trigger(n)})),a.addEventListener("touchmove",(function(a){if(!i)return s&&clearTimeout(s),void(s=!1);const r=a.changedTouches[0],c=document.elementFromPoint(r.clientX,r.clientY),l=n(c),d=e("mousemove",a,r);if($(l).trigger(d),a.cancelable&&a.preventDefault(),!t.leave||c==o)return;const u=n(o);for(;u.length&&l.length&&u[u.length-1]==l[l.length-1];)u.pop(),l.pop();const f=e("mouseleave",a,r),p=e("mouseout",a,r),h=e("mouseenter",a,r),g=e("mouseover",a,r);$(u).trigger(f),$(o).trigger(p),$(l).trigger(h),$(c).trigger(g),o=c}),{passive:!1})}(o)}))},$.event.special.mydbltap={setup:function(){let t,e;this.addEventListener("click",(function(n){if(t){if(t=!1,e)return;return $(n.target).trigger("mydbltap")}t=!0,e=!0,setTimeout((function(){t=!1}),$$.DoubleTapTime)}),{passive:!0}),this.addEventListener("touchstart",(function(){e=!1}),{passive:!0})}};export class PrefixStorage{constructor(t){this.ls=localStorage,this.prefix=String(t)+"::"}set(t,e){this.ls[this.prefix+t]=e}get(t){return this.ls[this.prefix+t]}getInt(t){const e=parseInt(this.ls[this.prefix+t]);return isNaN(e)?0:e}defined(t){return void 0!==this.ls[this.prefix+t]}remove(t){this.ls.removeItem(this.prefix+t)}clear=function(){const t=this.ls,e=this.prefix,n=e.length,a=[];for(let o=0;o<t.length;o++){const i=t.key(o);i.substr(0,n)===e&&a.push(i)}for(var o in a)delete t[a[o]]}}$.fn.adiaryDialog=function(t={}){const e=this;if("open"===t)return this.adiaryDialogOpen();if("close"===t)return this.adiaryDialogClose();$(window);const n=$("<dialog>").addClass("ui-dialog").attr("tabindex",-1),a=t.minWidth||200,o=t.minHeight||150;let i=t.width||300;i<0&&(i="auto"),n.css({width:i,minWidth:a,minHeight:o}),t.maxWidth&&n.css("max-width",t.maxWidth),t.maxHeight&&n.css("max-height",t.maxHeight),t.dialogClass&&n.addClass(t.dialogClass);const s=this.adiaryUIData("dialog",{...t});s.$dialog=n,s.min_h=o;const r=$("<div>").addClass("ui-dialog-titlebar ui-widget-header"),c=$("<span>").addClass("ui-dialog-title").html(t.title||this.attr("title")||" ");if(r.append(c),n.append(r),t.noExit)n.on("cancel",(function(t){return!1}));else{const l=$("<button>").addClass("ui-button").attr({type:"button",title:"Close"});function d(n){t.exit&&t.exit(),e.adiaryDialogClose()}l.append($("<span>").addClass("ui-icon ui-icon-closethick")),r.append(l),l.on("click",d),n.on("cancel",d),t.modal||(n.on("keydown",(t=>{"Escape"===t.key&&l.click()})),n.on("click",(t=>{$(this).closest("dialog").focus()})))}if(s.$header=r,s.$restore=this.parent(),s.display=this.css("display"),this.addClass("ui-dialog-content"),n.append(this),this.show(),t.buttons){const u=$("<div>").addClass("ui-dialog-buttonpane"),f=$("<div>").addClass("ui-dialog-buttonset"),p=t.buttons,h=[];for(let g in p){let m=$("<button>").addClass("ui-button").attr("type","button").text(g);m.on("click",p[g]),f.append(m),h.push(m)}u.append(f),n.append(u),s.$footer=u}return t&&!t.autoOpen&&"autoOpen"in t?this:this.adiaryDialogOpen()},$.fn.adiaryDialogOpen=function(){const t=this.adiaryUIData("dialog"),e=t.$dialog;if(!e)throw"Do not open dialog!";$("body").append(e),t.modal?(e.attr("closedby","none"),e[0].showModal()):e[0].show(),e.focus();const n=$(window),a=t.$header.outerHeight()+(t.$footer?t.$footer.outerHeight():0);this.css("min-height",t.min_h-a+"px"),this.css("max-height",n.height()-a+"px");const o=n.scrollLeft()+(n.width()-e.outerWidth())/2,i=n.scrollTop()+(n.height()-e.outerHeight())/2;return e.css({left:o,top:i}),e.adiaryDraggable({handle:".ui-dialog-titlebar"}),t.open&&t.open(null,this),this},$.fn.adiaryDialogClose=function(){const t=this.adiaryUIData("dialog"),e=t.$dialog;if(!e)throw"Do not close dialog!";return t.beforeClose&&t.beforeClose.call(null,this),e[0].close(),e.detach(),t.$dialog=null,t.$restore&&t.$restore.length&&(this.css("display",t.display),t.$restore.append(this)),t.close&&t.close.call(null,this),this},$.adiaryShowOverlay=function(){const t=$("<dialog>").addClass("ui-overlay").attr("closedby","none").attr("tabindex",-1).on("cancel",(function(t){return!1}));return $("body").append(t),t[0].showModal(),t.close=function(){return this[0].close(),this.detach(),this},t},$.fn.adiaryProgressbar=function(t){const e=this.adiaryUIData("progress");if("value"===t)return e.value;let n;t.change&&(e.change=t.change),t.complete&&(e.complete=t.complete),"$value"in e||(this.find(".ui-progressbar-value").remove(),e.$value=$("<div>").addClass("ui-progressbar-value"),this.addClass("ui-progressbar"),this.append(e.$value),n=!0);const a=e.value,o=t.value;return e.value=o,e.$value.css("width",o+"%"),(n||e.change&&a!=o)&&e.change(e.value),e.complete&&100<=o&&e.complete(e.value),this},$.fn.adiaryAccordion=function(t){const e=this.children("h1,h2,h3,h4,h5,h6");e.click((function(t){const e=$(t.target).next("div");e.length&&e.toggleDelay()})),e.next("div").hide()},$.fn.adiaryDraggable=function(t){let e,n,a;function o(t){const o=e+t.pageX,i=n+t.pageY;a.css({position:"absolute",left:o+"px",top:i+"px"}),t.preventDefault()}this.addClass("aui-draggable"),this.on("mousedown",(function(i){$("iframe").css("pointer-events","none");const s=$(i.target);if(a=s.hasClass("aui-draggable")?s:s.closest(".aui-draggable"),t){const e=s;if(s!=a&&e.add(s.parentsUntil(".aui-draggable")),t.cancel&&e.filter(t.cancel).length)return;if(t.handle&&!e.filter(t.handle).length)return}const r=a.offset();e=r.left-i.pageX,n=r.top-i.pageY,document.addEventListener("mousemove",o),i.preventDefault()})),this.on("mouseup",(function(t){$("iframe").css("pointer-events","auto"),document.removeEventListener("mousemove",o),t.preventDefault()}))},$.fn.adiaryUIData=function(t,e){return t="aui_"+t,2==arguments.length?this[t]=e:this[t]||={}};export const $$={SameSite:"Lax",DefaultShowSpeed:300,TouchDnDTime:100,DoubleTapTime:400,PopupDelayTime:300,PopupOffsetX:15,PopupOffsetY:10,$head:$("head"),$body:$("body")};$$.msg=function(t,e){const n=(this.msgs||{})[t];return void 0===n?e||t.toUpperCase():n},$$.set_msg=function(t,e){const n=this.msgs||={};"object"==typeof t?this.msgs={...n,...t}:n[t]=e},$$.dialog=function(t,e={}){if(!e.callback){const n=this;return new Promise(((a,o)=>{n.dialog(t,{...e,callback:a})}))}const n=e.ok||this.msg("ok"),a={};a[n]=function(){t.adiaryDialog("close"),e.callback&&e.callback("FORM"!==t.prop("tagName")||t.parseFormHash())},e.cancelBtn&&(a[e.cancel||this.msg("cancel")]=function(){t.adiaryDialog("close"),e.callback&&e.callback(!1)});const o=function(t){return 13!==t.which||(a[n](),!1)};t.on("keypress","input",o),t.adiaryDialog({noExit:e.noExit,modal:!("modal"in e)||e.modal,title:e.title,dialogClass:e.class,buttons:a,open:function(){const n=t.siblings(".ui-dialog-buttonpane");"ok"===e.focus&&n.find("button:eq(0)").focus(),"cancel"===e.focus&&n.find("button:eq(1)").focus()},exit:function(){e.callback&&e.callback(!1)},beforeClose:function(){t.off("keypress","input",o)},minWidth:e.minWidth||t.data("min-width"),minHeight:e.minHeight||t.data("min-height"),width:e.width||t.data("width")})},$$.dialog_base=function(t,e,n,a){let o;return a||"function"!=typeof n||(a=n,n=null),e instanceof $?o=e:(e instanceof Object&&(t={...t,...e},e=e.html),e&&"#"===e.substr(0,1)?o=$.secure(e):(o=$("<div>"),n&&(e=(e=e.replace(/%([A-Za-z])/g,(function(t,e){return n[e]}))).replace(/%[A-Za-z]/g,"")),o.html(e))),t.title||=o&&o.data("title")||this.msg("confirm"),a&&(t.callback=a),this.dialog(o,t)},$$.show_dialog=function(t,e,n,a={}){return this.dialog_base(a,t,e,n)},$$.show_error=function(t,e,n,a){return this.dialog_base({class:"error-dialog",title:this.msg("error"),...a},t,e,n)},$$.confirm=function(t,e,n,a){return this.dialog_base({cancelBtn:!0,title:this.msg("confirm"),...a},t,e,n)},$$.form_dialog=function(t,e,n){let a;if(e instanceof $)a=e;else{a=$("<form>"),Array.isArray(e)||(e=[e]);for(const t of e){if("string"==typeof t){a.append($("<div>").html(t));continue}if("p"==t.type){a.append($("<p>").html(t.html));continue}if("textarea"==t.type){const e=$("<textarea>").attr({rows:t.rows||5,name:t.name}).addClass("w100p");""!=t.val&&e.text(t.val),a.append(e);continue}if("*"==t.type){a.append(t.html);continue}const e=$("<div>");"before"in t&&e.append(t.before),e.append($("<input>").attr({type:t.type||"text",name:t.name,value:t.value}).addClass(t.class||"w80p")),t.iclass&&e.addClass(t.iclass),"after"in t&&e.append(t.after),a.append(e)}}return this.dialog(a,{title:t,callback:n})},$$.send_ajax=function(t){const e=this;if(!t.success&&!t.error_dialog_callback)return new Promise(((n,a)=>{e.send_ajax({...t,success:n,error_dialog_callback:a})}));function n(n){if(t.error&&!t.error(n))return;let a="";if(n){if(n.msg&&(a+="<p>"+e.tag_esc(n.msg.toString())+"</p>"),n.errs){const t=[],o=n.errs,i=o._order||Object.keys(o);for(let n in i)null!=o[i[n]]&&""!=o[i[n]]&&t.push(e.tag_esc(o[i[n]]));a+='<p class="ni">'+t.join("<br>")+"</p>"}n._debug&&(a+='<p class="ni">'+n._debug.replace(/\n/g,"<br>")+"</p>")}else a="<p>"+e.msg("server_response_error","response data error!")+"</p>";e.show_error(a,(function(){t.error_dialog_callback&&t.error_dialog_callback(n)}))}const a=t.data;return $.ajax(t.url||e.vars.myself||"./",{method:"POST",data:"[object Object]"===a.toString()?$.param(a):a,processData:!1,contentType:!1,dataType:"json",error:()=>n(),success:function(e){if("0"!=e.ret||e._debug)return n(e);t.success&&t.success(e)},complete:t.complete})},$$.popup=function(t){const e=this,n=$(t.target);let a=n.data("delay")||this.PopupDelayTime;if(a<1&&(a=1),!t.data.$div){const e=$("<div>").addClass("popup-block");this.$body.append(e),t.data.$div=e}n.on("mouseleave",t.data,(function(t){e.popup_hide(t)})),n.data("timer",setTimeout((function(){e.popup_show(t)}),a))},$$.popup_show=function(t){const e=$(t.target),n=t.data.$div;n.is(":animated")||(t.data.show&&t.data.show(t,e,n),n.css("left",this.SP?0:t.pageX+this.PopupOffsetX),n.css("top",t.pageY+this.PopupOffsetY),n.showDelay())},$$.popup_hide=function(t){const e=$(t.target),n=t.data.$div;e.data("timer")&&(clearTimeout(e.data("timer")),e.data("timer",null)),e.off("mouseout"),n.hide(),t.data.hide&&t.data.hide(t,e,n)},$("link.css-defer").attr("rel","stylesheet"),$$.$body.on("mouseover",".help[data-help]",{show:function(t,e,n){const a=$$.tag_esc_br(e.data("help"));n.addClass("popup popup-help"),n.html(a)}},(function(t){$$.popup(t)})),$$.$body.on("click","button[data-href]",(function(t){location.href=$(t.target).data("href")})),$$.$body.on("click","button.js-set-value[data-target]",(function(t){const e=$(t.target);$.secure(e.data("target")).val(e.attr("value"))})),$$.$body.on("keypress","input.no-enter-submit, form.no-enter-submit input",(function(t){return 13!==t.which})),$$.$body.on("click","button.js-file-btn",(function(t){const e=$(t.target),n=$.secure(e.data("target"));n.length&&(n.data("target")&&!n.data("--regist-change-evt")&&(n.data("--regist-change-evt",!0),n.on("change",(function(t){const e=n.rootfind(n.data("target")),a=n.val().replace(/^.*?([^\\\/]*)$/,"$1");e.text(a)}))),n.click())})),$$.$body.on("click","button.js-reset-btn",(function(t){const e=$(t.target),n=$.secure(e.data("target"));n.length&&""!=n.val()&&n.val("").change()})),$$.$body.on("change","input.js-checked",(function(t){const e=$(t.target);$.secure(e.data("target")).prop("checked",e.is(":checked"))})),$$.$body.on("change",".js-on-change-submit",(function(t){$(t.target).closest("form").trigger("submit")})),$(window).on("pageshow",(t=>{("back_foward"==performance.getEntriesByType("navigation")[0].type||t.originalEvent.persisted)&&$$.$body.find("form:has(.js-on-change-submit)").each(((t,e)=>e.reset()))})),$$.$body.on("click","tbody.js-line-checked",(function(t){const e=$(t.target),n=e.parents("tr");if(n.add(e).filter("a,input,button,label,.line-checked-cancel").length)return;n.last().find('input[type="checkbox"],input[type="radio"]').first().click()})),$$.js_combo_dummy="eeeee\n\n",$$.$body.on("focus","select.js-combo",(function(t){const e=$(t.target);e.data("current",e.val());const n=$$.js_combo_dummy;if(e.find('option[value="'+n+'"]').length)return;const a=$("<option>").attr("value",n).text($$.msg("other"));e.append(a),e.on("change",(async function(t){const e=$(t.target),a=e.val();if(a!==n)return e.data("current",a);const o=e.data("current");e.val(o);const i={name:"data",value:o,class:e.data("class")},s=(e.data("format")||"").match(/^(.*)%v(.*)$/);s&&(i.before=s[1],i.after=s[2]);const r=await $$.form_dialog(e.data("title"),i);if(r){const t=r.data;if(""==t||e.val()==t)return;$$.set_value_on_select(e,t)}}))})),$$.set_value_on_select=function(t,e){if(t.val(e),t.val()!=e){const n=(t.data("format")||"%v").replace(/%v/g,e),a=$("<option>").attr("value",e).text(n);t.append(a),t.val(e)}t.data("current",e),t.change()},$$.$body.on("click","table.js-sortable-value thead",(function(t){const e=$(t.target).filter("th,td"),n=e.length?e:$(t.target).closest("th,td");if(n.hasClass("disable-sort"))return;let a=0,o=n;for(;o.length;)o=o.prev(),a++;const i=n.closest("table").children("tbody"),s="td:nth-child("+a+")",r=i.data("_sortable_prev_cnt")==a;i.data("_sortable_prev_cnt",r?-1:a),i.each((function(t,e){const n=$(e);let a=!0;const o=[];n.children("tr").each((function(t,e){const n=$(e),i=n.children(s),r=i.existsData("sort")?i.data("sort"):i.text().replace(/^\s+/,"").replace(/\s+$/,""),c=Number(r);isNaN(c)&&(a=!1),o.push({val:r,num:c,$tr:n})})),a?o.sort((function(t,e){return t.num-e.num})):o.sort((function(t,e){return t.val===e.val?0:t.val<e.val})),r&&o.reverse(),n.empty();for(let t in o)n.append(o[t].$tr)}))})),function(){const t=[];let e;$$.dom_init=function(n,a){if("function"==typeof n)return e&&(a&&console.warn("dom_init() initialized, but priority set",a),n.call(this,this.$body)),t.push({func:n,p:a||100});t.sort((function(t,e){return t.p-e.p}));const o=n||this.$body;for(var i=0;i<t.length;i++)t[i].func.call(this,o);e=!0}}(),$$.dom_init((function(t){const e=this;t.findx("button.js-check-form").on("click",(function(t){const e=$(t.target),n=e.parents("form.js-check-form");n.length&&(n.data("confirm",e.data("confirm")),n.data("focus",e.data("focus")),n.data("button",e))})),t.findx("form.js-check-form").onSequence("submit",10,(function(t){const n=$(t.target),a=n.data("target");let o=0;if(a&&(o=n.rootfind(a+":checked").length,!o))return!1;let i=n.data("confirm");return!i||(n.data("--js-check-form-ok")?(n.data("--js-check-form-ok",!1),!0):(e.dialog_base({title:e.msg("confirm"),focus:n.data("focus"),cancelBtn:!0},i,{c:o},(function(e){if(e){if(n.data("--js-check-form-ok",!0),n.data("button"))return n.data("button").click();n.triggerWithOE(t.originalEvent)}})),!1))}))})),$$.dom_init((function(t){const e=this;t.find("form.js-ajax").onSequence("submit",100,(function(t){const n=$(t.target),a=function(){!function(t,n){n.find(".error").removeClass("error");const a=n.data("generator");let o=a?a(n,t):new FormData(n[0]);const i=t.originalEvent&&t.originalEvent.submitter;if(i&&"BUTTON"===i.tagName&&""!==i.name&&o.append(i.name,i.value),a||n.find('input[type="file"]').length||(o=new URLSearchParams(o)),!n.data("reentry")){if(n.data("--js-ajax-stop"))return;n.data("--js-ajax-stop",!0),n.prop("disabled",!0)}const s=n.data("overlay")&&$.adiaryShowOverlay(),r=n.data("start"),c=n.data("complete");"function"==typeof r&&r(n),e.send_ajax({url:n.attr("action"),data:o,success:function(t){s&&s.close();const a=n.data("success"),o=n.data("url");return"function"==typeof a?a(t):"string"==typeof a&&""!=a?e.show_dialog(a,(function(){o&&(location=o)})):void(o&&(location=o))},error:function(t){s&&s.close();const e=n.data("error");if("function"==typeof e)return e(t);if(!t||!t.errs)return!0;const a=t.errs;for(let t in a){if("_order"==t)continue;const e=t.match(/^(.*)#(\d+)$/),o=e?e[2]:void 0;t=e?e[1]:t;try{let e=n.find('[name="'+t+'"], [data-name="'+t+'"]');o&&(e=$(e[o])),e.addClass("error")}catch(a){console.error(a)}}return!0},error_dialog_callback:function(){const t=n.data("error_dialog_callback");if("function"==typeof t)return t()},complete:function(t){"function"==typeof c&&c(n),n.data("--js-ajax-stop")&&(n.data("--js-ajax-stop",!1),n.prop("disabled",!1))}})}(t,n)},o=n.data("checker");return!("function"==typeof o&&!o(n,a))&&(a(),!1)}))})),$$.dom_init((function(t){const e=this;t.findx("input.js-save, select.js-save").each((function(t,n){const a=$(n),o=a[0].type;let i="radio"!=o&&a.attr("id");if(i||(i="name="+a.attr("name")),!i)return;if("checkbox"==o)return a.change((function(t){const n=$(t.target);e.Storage.set(i,n.prop("checked")?1:0)})),void(e.Storage.defined(i)&&a.prop("checked",0!=e.Storage.get(i)));if("radio"==o){const t=a.attr("value");return a.change((function(n){$(n.target);e.Storage.set(i,t)})),void(e.Storage.defined(i)&&t==e.Storage.get(i)&&a.prop("checked",1))}a.change((function(t){const n=$(t.target);n.val()!=e.js_combo_dummy&&e.Storage.set(i,n.val())}));const s=e.Storage.get(i);return s?"SELECT"==n.tagName?e.set_value_on_select(a,s):a.val(s):void 0}))})),$$.dom_init((function(t){const e=t.findx("input.js-enable, input.js-disable, select.js-enable, select.js-disable");let n;e.change((function(t){const e=$(t.target),a=e.rootfind(e.data("target")),o=e[0].type;if("radio"==o){if(e.prop("disabled")||!e.prop("checked"))return;let t=e.data("state");return e.hasClass("js-enable")&&(t=!t),void a.prop("disabled",t)}let i;if("checkbox"==o)i=!e.prop("disabled")&&e.prop("checked");else if("number"==o||"int"==e.data("type")){var s=e.val();i=s.length&&s>0}else i=!(e.val()+"").match(/^\s*$/);if(!n&&e.data("_flag")===i)return;e.data("_flag",i);const r=e.hasClass("js-disable")?"_disable_c":"_enable_c",c=i?1:n?0:-1;a.each((function(t,n){const a=$(n);a.data(r,(a.data(r)||0)+c);const o=(a.data("_disable_c")||0)-(a.data("_enable_c")||0)+(e.hasClass("js-enable")?.1:0);a.prop("disabled",o>0)}))})),n=!0,e.change(),n=!1})),function(){function t(t,e){if("A"==t[0].tagName)return!0;if(e&&"INPUT"!=t[0].tagName&&"BUTTON"!=t[0].tagName){const e=$("<span>");e.addClass("ui-icon switch-icon"),t.prepend(e).addClass("sw-show")}const n="INPUT"==t[0].tagName&&t[0].type;let a=t.data("target");if(!a){if(!(t=t.closest(".js-switch")).length)return;a=t.data("target")}const o=$.secure(a);if(!o.length)return!1;const i=t.existsData("save")?this.Storage:null,s=t.attr("id")||t.attr("name")||a;let r;e&&i&&i.defined(s)?(r=!!i.getInt(s),"checkbox"!=n&&"radio"!=n||t.prop("checked",r)):r="checkbox"==n||"radio"==n?t.prop("checked"):!(!e||"show"!=t.data("default"))||(!e||"hide"!=t.data("default"))&&(e?!o.is(":hidden"):o.is(":hidden")),t.data("negative")&&(r=!r);let c=t.data("delay");if(void 0!==c&&""!==c||(c=this.DefaultShowSpeed),t.data("fast")){const t="--css--"+s.replace(/[^\w\-]/g,"-");let e=$("#"+t);return e.length||(e=$("<style>").attr("id",t),$("head").append(e)),e.text(r?"":a+"{ display: none; }"),!0}if(r?(t.addClass("sw-show"),t.removeClass("sw-hide"),e?o.show():o.show(c),i&&i.set(s,"1")):(t.addClass("sw-hide"),t.removeClass("sw-show"),e?o.hide():o.hide(c),i&&i.set(s,"0")),"button"==n){const e=r?t.data("show-val"):t.data("hide-val");null!=e&&t.val(e)}return!0}$$.dom_init((function(e){const n=this,a=function(e){const a=$(e.target);if("radio"!=a[0].type)return t.call(n,a);const o=a.attr("name");$('input.js-switch[name="'+o+'"]').each((function(e,a){t.call(n,$(a))}))};e.findx(".js-switch").each((function(e,o){const i=$(o);t.call(n,i,!0)&&i.on("INPUT"==o.tagName?"change":"click",a)}))}))}(),$$.dom_init((function(t){const e=t.findx(".js-accordion");e.length&&e.adiaryAccordion()})),$$.dom_init((function(t){t.findx("select.js-multiple").each((function(t,e){const n=$(e);if(n.prop("multiple"))return;const a=n.clone(!0).prop("multiple",!0).removeClass("js-multiple").css("display","none");n.data("__multi",a),n.removeAttr("id"),n.removeAttr("name"),a.find("option.js-multiple-ignore").remove(),a.insertAfter(n);const o=a.find("option");o.each((function(t,e){const n=$(e);n.prop("selected",n.data("selected"))}));const i=function(t){const e=[];if(o.each((function(t,n){const a=$(n);a.prop("selected")&&e.push(a.html())})),e.length){const t=$("<option>").addClass("js-multple-selected").html(e[0]+(e[1]?"...":""));n.find(".js-multple-selected").remove(),n.append(t.prop("selected",!0))}};i(),a.on("change",i)}))})),$$.$body.on("mousedown keydown","select.js-multiple",(function(t){const e=$(t.currentTarget),n=e.data("__multi")||e,a=n.data("label-class"),o=n.data("custom-dialog"),i=o?$(o):$("<div>").data("title",n.data("title")),s={};return n.find("option").each((function(t,e){const n=$(e);if(n.hasClass("js-multiple-ignore"))return;const r=n.val();if(s[r]=n,o)return;const c=$("<label>").html(n.html());""!==a&&void 0!==a&&c.addClass(a),c.prepend($("<input>").attr({type:"checkbox",value:r}).prop("checked",n.prop("selected"))).addClass(n.data("label-class")),i.append(c)})),$$.show_dialog(i,(function(t){if(!t)return;let e;i.find("input").each((function(t,n){const a=$(n),o=a.val(),i=s[o],r=a.prop("checked");!a.hasClass("js-multiple-ignore")&&i&&(r!=i.prop("selected")&&(e=!0),i.prop("selected",r))})),e&&n.change()})),t.preventDefault(),!1})),function(){const t={};$$.load_script=function(e){return new Promise(((n,a)=>{const o=t[e];if(o)return 1===o?n():void o.on("load",n);const i=t[e]=$(document.createElement("script")).attr("src",e).prop("async",!0);i.on("load",(a=>{t[e]=1,n(a)})),this.$head[0].appendChild(i[0])}))}}(),$$.tag_esc=function(t){return t.replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")},$$.tag_esc_br=function(t){return this.tag_esc(t).replace(/\n|\\n/g,"<br>")},$$.tag_esc_amp=function(t){return this.tag_esc(t.replace(/&/g,"&"))},$$.tag_unesc=function(t){return t.replace(/'/g,"'").replace(/"/g,'"').replace(/>/g,">").replace(/</g,"<").replace(/\/g,"\\")},$$.tag_unesc_amp=function(t){return this.tag_unesc(t).replace(/&/g,"&")},$$.set_cookie=function(t,e){document.cookie=encodeURIComponent(t)+"="+encodeURIComponent(e)+"; SameSite="+this.SameSite+";"},$$.get_cookie=function(t){const e=document.cookie.split(/; */);for(const n of e){const e=n.split("=",2);if(t==decodeURIComponent(e[0]))return decodeURIComponent(e[1])}},$$.parse_json_html=function(t){if(!t.length)return;const e=t.html().replace(/^\s*<!--\s*/,"").replace(/\s*-->\s*$/,"");return JSON.parse(e)},$$.format_size=function(t){return t>107374182400?Math.round(t/1073741824).toLocaleString()+" GB":t>1047527424?(t/1073741824).toPrecision(3)+" GB":t>1022976?(t/1048576).toPrecision(3)+" MB":t>999?(t/1024).toPrecision(3)+" KB":t+" Byte"},$$.int=function(t){const e=parseInt(t);return isNaN(e)?0:e},$$.float=function(t){const e=parseFloat(t);return isNaN(e)?0:e},function(){const t=$.secure("#asys-vars"),e=$$.vars=1==t.length?$$.parse_json_html(t):{},n=$.secure("#asys-msgs");if(1==n.length){const t=$$.parse_json_html(n);$$.set_msg(t)}$$.Storage=new PrefixStorage(e.myself||"/"),globalThis[e.name||"asys"]=$$,$$.dom_init();const a=$('script[type="priority-script"]');for(const t of a){const e=document.createElement("script");e.innerHTML='"use strict";(function(){'+t.innerHTML+"})()",t.innerHTML="",t.appendChild(e)}}();export default $$;
//# sourceMappingURL=asys.min.js.map