Updated chart initialization
authorThierry Florac <tflorac@ulthar.net>
Fri, 11 Dec 2020 08:47:56 +0100
changeset 23 fa5083469321
parent 22 134baf796a61
child 24 5ea89334a159
Updated chart initialization
src/myams/resources/js/myams-plugins.js
src/myams/resources/js/myams-plugins.min.js
--- a/src/myams/resources/js/myams-plugins.js	Thu Dec 10 16:24:03 2020 +0100
+++ b/src/myams/resources/js/myams-plugins.js	Fri Dec 11 08:47:56 2020 +0100
@@ -1702,69 +1702,64 @@
 						ams.ajax.check($.plot,
 							ams.baseURL + 'ext/flot/jquery.flot' + ams.devext + '.js',
 							function () {
-								ams.ajax.check($.plot.uiConstants,
-									ams.baseURL + 'ext/flot/jquery.flot.uiConstants' + ams.devext + '.js',
-									function() {
-										charts.each(function () {
 
-											var chart = $(this),
-												data = chart.data(),
-												dataOptions = {},
-												plugin,
-												flotPlugins = (data.amsChartPlugins || '').split(/\s+/);
+								var flotPlugins = new Set();
+								charts.each(function() {
+									var chart = $(this),
+										data = chart.data(),
+										chartPlugins = (data.amsChartPlugins || '').split(/\s+/);
+									$.each(chartPlugins, function(idx, elt) {
+										flotPlugins.add(elt);
+									});
+								});
 
-											function checkPlugin(plugin) {
-												for (var index in $.plot.plugins) {
-													if ($.plot.plugins.hasOwnProperty(index)) {
-														var pluginInfo = $.plot.plugins[index];
-														if (pluginInfo.name === plugin) {
-															return pluginInfo;
-														}
-													}
-												}
-												return null;
+								function checkPlugin(plugin) {
+									for (var index in $.plot.plugins) {
+										if ($.plot.plugins.hasOwnProperty(index)) {
+											var pluginInfo = $.plot.plugins[index];
+											if (pluginInfo.name === plugin) {
+												return pluginInfo;
 											}
+										}
+									}
+									return null;
+								}
 
-											function initChart() {
-												var settings = $.extend({}, dataOptions, data.amsChartOptions);
-												settings = ams.executeFunctionByName(data.amsChartInitCallback, chart, settings) || settings;
-												var chartData = data.amsChartData,
-													chartDataLoader = data.amsChartDataLoader;
-												if (chartDataLoader) {
-													$.getJSON(chartDataLoader, chartData).done(function (data) {
-														settings = $.extend({}, settings, data.settings);
-														createChart(data.data, settings);
-													});
-												} else {
-													createChart(data, settings);
-												}
-											}
+								var deferred = [];
+								for (var pluginName of flotPlugins.values()) {
+									if (!checkPlugin(pluginName)) {
+										deferred.push(ams.getScript(ams.baseURL + 'ext/flot/jquery.flot.' + pluginName + ams.devext + '.js'));
+									}
+								}
+
+								$.when.apply($, deferred).then(function() {
+
+									charts.each(function() {
+
+										var chart = $(this),
+											data = chart.data(),
+											dataOptions = {};
 
-											function createChart(chartData, settings) {
-												chartData = ams.executeFunctionByName(data.amsChartInitData, chart, chartData) || chartData;
-												plugin = chart.plot(chartData, settings);
-												ams.executeFunctionByName(data.amsChartAfterInitCallback, chart, plugin, settings);
-											}
+										function createChart(chartData, settings) {
+											chartData = ams.executeFunctionByName(data.amsChartInitData, chart, chartData) || chartData;
+											var plugin = chart.plot(chartData, settings);
+											ams.executeFunctionByName(data.amsChartAfterInitCallback, chart, plugin, settings);
+										}
 
-											var deferred = [];
-											if (flotPlugins.length > 0) {
-												for (var index in flotPlugins) {
-													if (flotPlugins.hasOwnProperty(index)) {
-														var pluginName = flotPlugins[index];
-														if (!checkPlugin(pluginName)) {
-															deferred.push(ams.getScript(ams.baseURL + 'ext/flot/jquery.flot.' + pluginName + ams.devext + '.js'));
-														}
-													}
-												}
-											}
-											if (deferred.length > 0) {
-												$.when.apply($, deferred).then(function () {
-													initChart();
-												})
-											} else {
-												initChart();
-											}
-										});
+										var settings = $.extend({}, dataOptions, data.amsChartOptions);
+										settings = ams.executeFunctionByName(data.amsChartInitCallback, chart, settings) || settings;
+										var chartData = data.amsChartData,
+											chartDataLoader = data.amsChartDataLoader;
+										if (chartDataLoader) {
+											$.getJSON(chartDataLoader, chartData).done(function(data) {
+												settings = $.extend({}, settings, data.settings);
+												createChart(data.data, settings);
+											});
+										} else {
+											createChart(chartData, settings);
+										}
+
+									});
 								});
 							});
 					});
--- a/src/myams/resources/js/myams-plugins.min.js	Thu Dec 10 16:24:03 2020 +0100
+++ b/src/myams/resources/js/myams-plugins.min.js	Fri Dec 11 08:47:56 2020 +0100
@@ -1,1 +1,1 @@
-!function(e,a){var t=a.MyAMS;e.extend(t.plugins.enabled,{svg:function(a){var t=e(".svg-container",a);t.length>0&&t.each((function(){var a=e(this),t=e("svg",a),n=t.attr("width"),s=t.attr("height");n&&s&&t.get(0).setAttribute("viewBox","0 0 "+Math.round(parseFloat(n))+" "+Math.round(parseFloat(s))),t.attr("width","100%").attr("height","auto")}))},hint:function(a){var n=e(".hint:not(:parents(.nohints))",a);n.length>0&&t.ajax&&t.ajax.check(e.fn.tipsy,t.baseURL+"ext/jquery-tipsy"+t.devext+".js",(function(){t.getCSS(t.baseURL+"../css/ext/jquery-tipsy"+t.devext+".css","jquery-tipsy",(function(){n.each((function(){var a=e(this),n=a.data(),s={html:void 0===n.amsHintHtml?(a.attr("title")||"").startsWith("<"):n.amsHintHtml,title:t.getFunctionByName(n.amsHintTitleGetter)||function(){var a=e(this),t=a.attr("original-title")||a.attr(n.amsHintTitleAttr||"title")||(n.amsHintHtml?a.html():a.text());return t=t.replace(/\?_="/,"?_="+(new Date).getTime()+'"')},opacity:n.amsHintOpacity||.95,gravity:n.amsHintGravity||"sw",offset:n.amsHintOffset||0},i=e.extend({},s,n.amsHintOptions);i=t.executeFunctionByName(n.amsHintInitCallback,a,i)||i;var r=a.tipsy(i);t.executeFunctionByName(n.amsHintAfterInitCallback,a,r,i)}))}))}))},contextMenu:function(a){var n=e(".context-menu",a);n.length>0&&n.each((function(){var a=e(this),n=a.data(),s={menuSelector:n.amsContextmenuSelector,menuSelected:t.helpers&&t.helpers.contextMenuHandler},i=e.extend({},s,n.amsContextmenuOptions);i=t.executeFunctionByName(n.amsContextmenuInitCallback,a,i)||i;var r=a.contextMenu(i);t.executeFunctionByName(n.amsContextmenuAfterInitCallback,a,r,i)}))},switcher:function(a){e("LEGEND.switcher",a).each((function(){var a=e(this),t=a.parent("fieldset"),n=a.data();n.amsSwitcher||(e('<i class="fa fa-fw"></i>').prependTo(e(this)).addClass("open"===n.amsSwitcherState?n.amsSwitcherMinusClass||"fa-minus":n.amsSwitcherPlusClass||"fa-plus"),a.on("click",(function(s){s.preventDefault();var i={};if(a.trigger("ams.switcher.before-switch",[a,i]),!i.veto)if(t.hasClass("switched")){t.removeClass("switched"),e(".fa",a).removeClass(n.amsSwitcherPlusClass||"fa-plus").addClass(n.amsSwitcherMinusClass||"fa-minus"),a.trigger("ams.switcher.opened",[a]);var r=a.attr("id");r&&e('legend.switcher[data-ams-switcher-sync="'+r+'"]',t).each((function(){var a=e(this);a.parents("fieldset").hasClass("switched")&&a.click()}))}else t.addClass("switched"),e(".fa",a).removeClass(n.amsSwitcherMinusClass||"fa-minus").addClass(n.amsSwitcherPlusClass||"fa-plus"),a.trigger("ams.switcher.closed",[a])})),"open"!==n.amsSwitcherState&&t.addClass("switched"),a.data("ams-switcher","on"))}))},checker:function(a){e("LEGEND.checker",a).each((function(){var a=e(this),n=a.parent("fieldset"),s=a.data();if(!s.amsChecker){var i=e('<label class="checkbox"></label>'),r=s.amsCheckerFieldname||"checker_"+t.generateId(),o=r.replace(/\./,"_"),c=s.amsCheckerHiddenPrefix,l=null,m=s.amsCheckerHiddenValueOn||"true",d=s.amsCheckerHiddenValueOff||"false",u=s.amsCheckerMarker||!1;c?l=e('<input type="hidden">').attr("name",c+r).val("on"===s.amsCheckerState?m:d).prependTo(a):u&&e('<input type="hidden">').attr("name",u).attr("value",1).prependTo(a);var h=e('<input type="checkbox">').attr("name",r).attr("id",o).data("ams-checker-hidden-input",l).data("ams-checker-init",!0).val(s.amsCheckerValue||!0).attr("checked","on"===s.amsCheckerState?"checked":null);s.amsCheckerReadonly?h.attr("disabled","disabled"):h.on("change",(function(i){i.preventDefault();var r={},o=e(this).is(":checked");if(a.trigger("ams.checker.before-switch",[a,r]),r.veto)e(this).prop("checked",!o);else if(t.executeFunctionByName(s.amsCheckerChangeHandler,a,o),!s.amsCheckerCancelDefault){var c=h.data("ams-checker-hidden-input");o?("disable"===s.amsCheckerMode?(n.removeAttr("disabled"),e(".select2",n).removeAttr("disabled")):n.removeClass("switched"),c&&c.val(m),e("[data-required]",n).attr("required","required"),a.trigger("ams.checker.opened",[a])):("disable"===s.amsCheckerMode?(n.prop("disabled","disabled"),e(".select2",n).attr("disabled","disabled")):n.addClass("switched"),c&&c.val(d),e("[data-required]",n).removeAttr("required"),a.trigger("ams.checker.closed",[a]))}})),h.appendTo(i),e(">label",a).attr("for",h.attr("id")),i.append("<i></i>").prependTo(a);var b=e("[required]",n);b.attr("data-required",!0),"on"===s.amsCheckerState?h.attr("checked",!0):("disable"===s.amsCheckerMode?(n.attr("disabled","disabled"),e(".select2",n).attr("disabled","disabled")):n.addClass("switched"),b.removeAttr("required")),a.data("ams-checker","on")}}))},slider:function(a){var n=e(".slider",a);n.length>0&&t.ajax&&t.ajax.check(e.fn.slider,t.baseURL+"ext/bootstrap-slider-2.0.0"+t.devext+".js",(function(){n.each((function(){var a=e(this),n=a.data(),s=e.extend({},{},a.data.amsSliderOptions);s=t.executeFunctionByName(n.amsSliderInitCallback,a,s)||s;var i=a.slider(s);t.executeFunctionByName(n.amsSliderAfterInitCallback,a,i,s)}))}))},draggable:function(a){var n=e(".draggable",a);n.length>0&&n.each((function(){var a=e(this),n=a.data(),s={cursor:n.amsDraggableCursor||"move",containment:n.amsDraggableContainment,handle:n.amsDraggableHandle,connectToSortable:n.amsDraggableConnectSortable,helper:t.getFunctionByName(n.amsDraggableHelper)||n.amsDraggableHelper,start:t.getFunctionByName(n.amsDraggableStart),stop:t.getFunctionByName(n.amsDraggableStop)},i=e.extend({},s,n.amsDraggableOptions);i=t.executeFunctionByName(n.amsDraggableInitCallback,a,i)||i;var r=a.draggable(i);a.disableSelection(),t.executeFunctionByName(n.amsDraggableAfterInitCallback,a,r,i)}))},droppable:function(a){var n=e(".droppable",a);n.length>0&&n.each((function(){var a=e(this),n=a.data(),s={accept:n.amsDroppableAccept,drop:t.getFunctionByName(n.amsDroppableDrop)},i=e.extend({},s,n.amsDroppableOptions);i=t.executeFunctionByName(n.amsDroppableInitCallback,a,i)||i;var r=a.droppable(i);t.executeFunctionByName(n.amsDroppableAfterInitCallback,a,r,i)}))},sortable:function(a){var n=e(".sortable",a);n.length>0&&n.each((function(){var a=e(this),n=a.data(),s={items:n.amsSortableItems,handle:n.amsSortableHandle,helper:n.amsSortableHelper,connectWith:n.amsSortableConnectwith,start:t.getFunctionByName(n.amsSortableStart),over:t.getFunctionByName(n.amsSortableOver),containment:n.amsSortableContainment,placeholder:n.amsSortablePlaceholder,stop:t.getFunctionByName(n.amsSortableStop)},i=e.extend({},s,n.amsSortableOptions);i=t.executeFunctionByName(n.amsSortableInitCallback,a,i)||i;var r=a.sortable(i);a.disableSelection(),t.executeFunctionByName(n.amsSortableAfterInitCallback,a,r,i)}))},resizable:function(a){var n=e(".resizable",a);n.length>0&&n.each((function(){var a=e(this),n=a.data(),s={autoHide:!1===n.amsResizableAutohide||n.amsResizableAutohide,containment:n.amsResizableContainment,grid:n.amsResizableGrid,handles:n.amsResizableHandles,start:t.getFunctionByName(n.amsResizableStart),stop:t.getFunctionByName(n.amsResizableStop)},i=e.extend({},s,n.amsResizableOptions);i=t.executeFunctionByName(n.amsResizableInitCallback,a,i)||i;var r=a.resizable(i);a.disableSelection(),t.executeFunctionByName(n.amsResizableAfterInitCallback,a,r,i)}))},typeahead:function(a){var n=e(".typeahead",a);n.length>0&&t.ajax&&t.ajax.check(e.fn.typeahead,t.baseURL+"ext/jquery-typeahead"+t.devext+".js",(function(){n.each((function(){var a=e(this),n=a.data(),s=e.extend({},{},n.amsTypeaheadOptions);s=t.executeFunctionByName(n.amsTypeaheadInitCallback,a,s)||s;var i=a.typeahead(s);t.executeFunctionByName(n.amsTypeaheadAfterInitCallback,a,i,s)}))}))},treeview:function(a){var n=e(".treeview",a);n.length>0&&t.ajax&&t.ajax.check(e.fn.treview,t.baseURL+"ext/bootstrap-treeview"+t.devext+".js",(function(){t.getCSS(t.baseURL+"../css/ext/bootstrap-treeview"+t.devext+".css","bootstrap-treeview",(function(){n.each((function(){var a=e(this),n=a.data(),s={data:n.amsTreeviewData,levels:n.amsTreeviewLevels,injectStyle:n.amsTreeviewInjectStyle,expandIcon:n.amsTreeviewExpandIcon||"fa fa-fw fa-plus-square-o",collapseIcon:n.amsTreeviewCollaspeIcon||"fa fa-fw fa-minus-square-o",emptyIcon:n.amsTreeviewEmptyIcon||"fa fa-fw",nodeIcon:n.amsTreeviewNodeIcon,selectedIcon:n.amsTreeviewSelectedIcon,checkedIcon:n.amsTreeviewCheckedIcon||"fa fa-fw fa-check-square-o",uncheckedIcon:n.amsTreeviewUncheckedIcon||"fa fa-fw fa-square-o",color:n.amsTreeviewColor,backColor:n.amsTreeviewBackColor,borderColor:n.amsTreeviewBorderColor,onHoverColor:n.amsTreeviewHoverColor,selectedColor:n.amsTreeviewSelectedColor,selectedBackColor:n.amsTreeviewSelectedBackColor,unselectableColor:n.amsTreeviewUnselectableColor||"rgba(1,1,1,0.25)",unselectableBackColor:n.amsTreeviewUnselectableBackColor||"rgba(1,1,1,0.25)",enableLinks:n.amsTreeviewEnableLinks,highlightSelected:n.amsTreeviewHighlightSelected,highlightSearchResults:n.amsTreeviewhighlightSearchResults,showBorder:n.amsTreeviewShowBorder,showIcon:n.amsTreeviewShowIcon,showCheckbox:n.amsTreeviewShowCheckbox,showTags:n.amsTreeviewShowTags,toggleUnselectable:n.amsTreeviewToggleUnselectable,multiSelect:n.amsTreeviewMultiSelect,onNodeChecked:t.getFunctionByName(n.amsTreeviewNodeChecked),onNodeCollapsed:t.getFunctionByName(n.amsTreeviewNodeCollapsed),onNodeDisabled:t.getFunctionByName(n.amsTreeviewNodeDisabled),onNodeEnabled:t.getFunctionByName(n.amsTreeviewNodeEnabled),onNodeExpanded:t.getFunctionByName(n.amsTreeviewNodeExpanded),onNodeSelected:t.getFunctionByName(n.amsTreeviewNodeSelected),onNodeUnchecked:t.getFunctionByName(n.amsTreeviewNodeUnchecked),onNodeUnselected:t.getFunctionByName(n.amsTreeviewNodeUnselected),onSearchComplete:t.getFunctionByName(n.amsTreeviewSearchComplete),onSearchCleared:t.getFunctionByName(n.amsTreeviewSearchCleared)},i=e.extend({},s,n.amsTreeviewOptions);i=t.executeFunctionByName(n.amsTreeviewInitcallback,a,i)||i;var r=a.treeview(i);t.executeFunctionByName(n.amsTreeviewAfterInitCallback,a,r,i)}))}))}))},select2:function(a){var n=e(".select2",a);n.length>0&&t.ajax&&t.ajax.check(e.fn.select2,t.baseURL+"ext/jquery-select2-3.5.4"+t.devext+".js",(function(){n.each((function(){var a=e(this),n=a.data();if(!n.select2){var s={placeholder:n.amsSelect2Placeholder,multiple:n.amsSelect2Multiple,minimumInputLength:n.amsSelect2MinimumInputLength||0,maximumSelectionSize:n.amsSelect2MaximumSelectionSize,openOnEnter:void 0===n.amsSelect2EnterOpen||n.amsSelect2EnterOpen,allowClear:void 0===n.amsSelect2AllowClear||n.amsSelect2AllowClear,width:n.amsSelect2Width||"100%",initSelection:t.getFunctionByName(n.amsSelect2InitSelection),formatSelection:void 0===n.amsSelect2FormatSelection?t.helpers&&t.helpers.select2FormatSelection:t.getFunctionByName(n.amsSelect2FormatSelection),formatResult:t.getFunctionByName(n.amsSelect2FormatResult),formatMatches:void 0===n.amsSelect2FormatMatches?function(e){return 1===e?t.i18n.SELECT2_MATCH:e+t.i18n.SELECT2_MATCHES}:t.getFunctionByName(n.amsSelect2FormatMatches),formatNoMatches:void 0===n.amsSelect2FormatResult?function(e){return t.i18n.SELECT2_NOMATCHES}:t.getFunctionByName(n.amsSelect2FormatResult),formatInputTooShort:void 0===n.amsSelect2FormatInputTooShort?function(e,a){var n=a-e.length;return t.i18n.SELECT2_INPUT_TOOSHORT.replace(/\{0\}/,n).replace(/\{1\}/,1===n?"":t.i18n.SELECT2_PLURAL)}:t.getFunctionByName(n.amsSelect2FormatInputTooShort),formatInputTooLong:void 0===n.amsSelect2FormatInputTooLong?function(e,a){var n=e.length-a;return t.i18n.SELECT2_INPUT_TOOLONG.replace(/\{0\}/,n).replace(/\{1\}/,1===n?"":t.i18n.SELECT2_PLURAL)}:t.getFunctionByName(n.amsSelect2FormatInputTooLong),formatSelectionTooBig:void 0===n.amsSelect2FormatSelectionTooBig?function(e){return t.i18n.SELECT2_SELECTION_TOOBIG.replace(/\{0\}/,e).replace(/\{1\}/,1===e?"":t.i18n.SELECT2_PLURAL)}:t.getFunctionByName(n.amsSelect2FormatSelectionTooBig),formatLoadMore:void 0===n.amsSelect2FormatLoadMore?function(e){return t.i18n.SELECT2_LOADMORE}:t.getFunctionByName(n.amsSelect2FormatLoadMore),formatSearching:void 0===n.amsSelect2FormatSearching?function(){return t.i18n.SELECT2_SEARCHING}:t.getFunctionByName(n.amsSelect2FormatSearching),separator:n.amsSelect2Separator||",",tokenSeparators:n.amsSelect2TokensSeparators||[","],tokenizer:t.getFunctionByName(n.amsSelect2Tokenizer)};switch(a.context.type){case"text":case"hidden":if(!s.initSelection){var i=a.data("ams-select2-values");i&&(s.initSelection=function(a,t){var n=[];e(a.val().split(s.separator)).each((function(){n.push({id:this,text:i[this]||this})})),t(n)})}}a.attr("readonly")?"hidden"===a.attr("type")&&(s.query=function(){return[]}):n.amsSelect2Query?(s.query=t.getFunctionByName(n.amsSelect2Query),s.minimumInputLength=n.amsSelect2MinimumInputLength||1):n.amsSelect2QueryUrl?(s.ajax={url:n.amsSelect2QueryUrl,quietMillis:n.amsSelect2QuietMillis||200,type:n.amsSelect2QueryType||"POST",dataType:n.amsSelect2QueryDatatype||"json",data:function(a,t,s){var i={};return i[n.amsSelect2QueryParamName||"query"]=a,i[n.amsSelect2PageParamName||"page"]=t,i[n.amsSelect2ContextParamName||"context"]=s,e.extend({},i,n.amsSelect2QueryOptions)},results:t.helpers&&t.helpers.select2QueryUrlResultsCallback},s.minimumInputLength=n.amsSelect2MinimumInputLength||1):n.amsSelect2QueryMethod?(s.query=function(s){var i={id:(new Date).getTime(),params:n.amsSelect2QueryParams||{},success:function(e){return t.helpers&&t.helpers.select2QueryMethodSuccessCallback.call(a,e,"success",s)},error:t.error&&t.error.show};i.params[n.amsSelect2QueryParamName||"query"]=s.term,i.params[n.amsSelect2PageParamName||"page"]=s.page,i.params[n.amsSelect2ContextParamName||"context"]=s.context,i=e.extend({},i,n.amsSelect2QueryOptions),i=t.executeFunctionByName(n.amsSelect2QueryInitCallback,a,i)||i,t.ajax&&t.ajax.check(e.jsonRPC,t.baseURL+"ext/jquery-jsonrpc"+t.devext+".js",(function(){e.jsonRPC.withOptions({endPoint:n.amsSelect2MethodTarget||t.jsonrpc&&t.jsonrpc.getAddr(),namespace:n.amsSelect2MethodNamespace,cache:!1},(function(){e.jsonRPC.request(n.amsSelect2QueryMethod,i)}))}))},s.minimumInputLength=n.amsSelect2MinimumInputLength||1):n.amsSelect2Tags?s.tags=n.amsSelect2Tags:n.amsSelect2Data&&(s.data=n.amsSelect2Data),n.amsSelect2EnableFreeTags&&(s.createSearchChoice=function(e){return{id:e,text:(n.amsSelect2FreeTagsPrefix||t.i18n.SELECT2_FREETAG_PREFIX)+e}});var r=e.extend({},s,n.amsSelect2Options);r=t.executeFunctionByName(n.amsSelect2InitCallback,a,r)||r;var o=a.select2(r);t.executeFunctionByName(n.amsSelect2AfterInitCallback,a,o,r),a.hasClass("ordered")&&!a.prop("disabled")&&t.ajax&&t.ajax.check(e.fn.select2Sortable,t.baseURL+"ext/jquery-select2-sortable"+t.devext+".js",(function(){a.select2Sortable({bindOrder:"sortableStop"})})),a.on("change",(function(){void 0!==e(a.get(0).form).data("validator")&&e(a).valid()}))}}))}))},maskedit:function(a){var n=e("[data-mask]",a);n.length>0&&t.ajax&&t.ajax.check(e.fn.mask,t.baseURL+"ext/jquery-maskedinput-1.4.1"+t.devext+".js",(function(){n.each((function(){var a=e(this),n=a.data(),s={placeholder:void 0===n.amsMaskeditPlaceholder?"X":n.amsMaskeditPlaceholder,complete:t.getFunctionByName(n.amsMaskeditComplete)},i=e.extend({},s,n.amsMaskeditOptions);i=t.executeFunctionByName(n.amsMaskeditInitCallback,a,i)||i;var r=a.mask(a.attr("data-mask"),i);t.executeFunctionByName(n.amsMaskeditAfterInitCallback,a,r,i)}))}))},inputmask:function(a){var n=e("input[data-input-mask]",a);n.length>0&&t.ajax&&t.ajax.check(e.fn.inputmask,t.baseURL+"ext/jquery-inputmask-bundle-3.2.8"+t.devext+".js",(function(){n.each((function(){var a,n=e(this),s=n.data();a="object"==typeof s.inputMask?s.inputMask:{mask:s.inputMask.toString()};var i=e.extend({},a,s.amsInputmaskOptions);i=t.executeFunctionByName(s.amsInputmaskInitCallback,n,i)||i;var r=n.inputmask(i);t.executeFunctionByName(s.amsInputmaskAfterInitCallback,n,r,i)}))}))},datepicker:function(a){var n=e(".datepicker",a);n.length>0&&t.ajax&&t.ajax.check(e.fn.datetimepicker,t.baseURL+"ext/jquery-datetimepicker"+t.devext+".js",(function(a){a&&t.dialog&&t.dialog.registerHideCallback(t.helpers&&t.helpers.datetimepickerDialogHiddenCallback),t.getCSS(t.baseURL+"../css/ext/jquery-datetimepicker"+t.devext+".css","jquery-datetimepicker",(function(){n.each((function(){var a=e(this),n=a.data(),s={lang:n.amsDatetimepickerLang||t.lang,format:n.amsDatetimepickerFormat||"d/m/y",datepicker:!0,dayOfWeekStart:1,timepicker:!1,closeOnDateSelect:void 0===n.amsDatetimepickerCloseOnSelect||n.amsDatetimepickerCloseOnSelect,weeks:n.amsDatetimepickerWeeks},i=e.extend({},s,n.amsDatetimepickerOptions);i=t.executeFunctionByName(n.amsDatetimepickerInitCallback,a,i)||i;var r=a.datetimepicker(i);t.executeFunctionByName(n.amsDatetimepickerAfterInitCallback,a,r,i)}))}))}))},datetimepicker:function(a){var n=e(".datetimepicker",a);n.length>0&&t.ajax&&t.ajax.check(e.fn.datetimepicker,t.baseURL+"ext/jquery-datetimepicker"+t.devext+".js",(function(a){a&&t.dialog&&t.dialog.registerHideCallback(t.helpers&&t.helpers.datetimepickerDialogHiddenCallback),t.getCSS(t.baseURL+"../css/ext/jquery-datetimepicker"+t.devext+".css","jquery-datetimepicker",(function(){n.each((function(){var a=e(this),n=a.data(),s={lang:n.amsDatetimepickerLang||t.lang,format:n.amsDatetimepickerFormat||"d/m/y H:i",datepicker:!0,dayOfWeekStart:1,timepicker:!0,closeOnDateSelect:void 0===n.amsDatetimepickerCloseOnSelect||n.amsDatetimepickerCloseOnSelect,closeOnTimeSelect:void 0===n.amsDatetimepickerCloseOnSelect||n.amsDatetimepickerCloseOnSelect,weeks:n.amsDatetimepickerWeeks},i=e.extend({},s,n.amsDatetimepickerOptions);i=t.executeFunctionByName(n.amsDatetimepickerInitCallback,a,i)||i;var r=a.datetimepicker(i);t.executeFunctionByName(n.amsDatetimepickerAfterInitCallback,a,r,i)}))}))}))},timepicker:function(a){var n=e(".timepicker",a);n.length>0&&t.ajax&&t.ajax.check(e.fn.datetimepicker,t.baseURL+"ext/jquery-datetimepicker"+t.devext+".js",(function(a){a&&t.dialog&&t.dialog.registerHideCallback(t.helpers&&t.helpers.datetimepickerDialogHiddenCallback),t.getCSS(t.baseURL+"../css/ext/jquery-datetimepicker"+t.devext+".css","jquery-datetimepicker",(function(){n.each((function(){var a=e(this),n=a.data(),s={lang:n.amsDatetimepickerLang||t.lang,format:n.amsDatetimepickerFormat||"H:i",datepicker:!1,timepicker:!0,closeOnTimeSelect:void 0===n.amsDatetimepickerCloseOnSelect||n.amsDatetimepickerCloseOnSelect},i=e.extend({},s,n.amsDatetimepickerOptions);i=t.executeFunctionByName(n.amsDatetimepickerInitCallback,a,i)||i;var r=a.datetimepicker(i);t.executeFunctionByName(n.amsDatetimepickerAfterInitCallback,a,r,i)}))}))}))},colorpicker:function(a){var n=e(".colorpicker",a);n.length>0&&t.ajax&&t.ajax.check(e.fn.minicolors,t.baseURL+"ext/jquery-minicolors"+t.devext+".js",(function(){t.getCSS(t.baseURL+"../css/ext/jquery-minicolors"+t.devext+".css","jquery-minicolors",(function(){n.each((function(){var a=e(this),n=a.data(),s={position:n.amsColorpickerPosition||a.closest(".input").data("ams-colorpicker-position")||"bottom left"},i=e.extend({},s,n.amsColorpickerOptions);i=t.executeFunctionByName(n.amsColorpickerInitCallback,a,i)||i;var r=a.minicolors(i);t.executeFunctionByName(n.amsDatetimepickerAfterInitCallback,a,r,i)}))}))}))},dndupload:function(a){var n=e(".dndupload",a);n.length>0&&t.ajax&&t.ajax.check(e.fn.dndupload,t.baseURL+"ext/jquery-dndupload"+t.devext+".js",(function(){t.getCSS(t.baseURL+"../css/ext/jquery-dndupload"+t.devext+".css","jquery-dndupload",(function(){n.each((function(){var a=e(this),n=a.data(),s={action:n.amsDnduploadAction||a.attr("action")||"upload-files",fieldname:n.amsDnduploadFieldname||"files",autosubmit:n.amsDnduploadAutosubmit},i=e.extend({},s,n.amsDnduploadOptions);i=t.executeFunctionByName(n.amsDnduploadInitCallback,a,i)||i;var r=a.dndupload(i);t.executeFunctionByName(n.amsDnduploadAfterInitcallback,a,r,i)}))}))}))},validate:function(a){var n=e("FORM:not([novalidate])",a);n.length>0&&t.ajax&&t.ajax.check(e.fn.validate,t.baseURL+"ext/jquery-validate-1.17.0"+t.devext+".js",(function(a){if(a&&(e.validator.setDefaults({highlight:function(a){e(a).closest(".form-group, label:not(:parents(.form-group))").addClass("state-error")},unhighlight:function(a){e(a).closest(".form-group, label:not(:parents(.form-group))").removeClass("state-error")},errorElement:"span",errorClass:"state-error",errorPlacement:function(e,a){var t=a.parents("label, .input").first();t.length?e.insertAfter(t):e.insertAfter(a)}}),t.plugins&&t.plugins.i18n)){for(var s in t.plugins.i18n.validate)if(t.plugins.i18n.validate.hasOwnProperty(s)){var i=t.plugins.i18n.validate[s];"string"==typeof i&&i.indexOf("{0}")>-1&&(t.plugins.i18n.validate[s]=e.validator.format(i))}e.extend(e.validator.messages,t.plugins.i18n.validate)}n.each((function(){var a=e(this),n=a.data(),s={ignore:null,submitHandler:void 0!==a.attr("data-async")?void 0===n.amsFormSubmitHandler?function(){return e(".state-error",a).removeClass("state-error"),t.ajax&&t.ajax.check(e.fn.ajaxSubmit,t.baseURL+"ext/jquery-form-3.49"+t.devext+".js"),t.form&&t.form.submit(a)}:t.getFunctionByName(n.amsFormSubmitHandler):void 0,invalidHandler:void 0===n.amsFormInvalidHandler?function(t,n){e(".state-error",a).removeClass("state-error");for(var s=0;s<n.errorList.length;s++){var i=n.errorList[s],r=e(i.element).parents(".tab-pane").index()+1;if(r>0){var o=e(".nav-tabs",e(i.element).parents(".tabforms"));e("li:nth-child("+r+")",o).removeClassPrefix("state-").addClass("state-error"),e("li.state-error:first a",o).click()}}}:t.getFunctionByName(n.amsFormInvalidHandler)};e("[data-ams-validate-rules]",a).each((function(a){0===a&&(s.rules={}),s.rules[e(this).attr("name")]=e(this).data("ams-validate-rules")})),e("[data-ams-validate-messages]",a).each((function(a){0===a&&(s.messages={}),s.messages[e(this).attr("name")]=e(this).data("ams-validate-messages")}));var i=e.extend({},s,n.amsValidateOptions);i=t.executeFunctionByName(n.amsValidateInitCallback,a,i)||i;var r=a.validate(i);t.executeFunctionByName(n.amsValidateAfterInitCallback,a,r,i)}))}))},datatable:function(a){var n=e(".datatable",a);n.length>0&&t.ajax&&t.ajax.check(e.fn.dataTable,t.baseURL+"ext/jquery-dataTables-1.9.4"+t.devext+".js",(function(){t.ajax.check(e.fn.dataTableExt.oPagination.bootstrap_full,t.baseURL+"myams-dataTables"+t.devext+".js",(function(){e(n).each((function(){var a,n=e(this),s=n.data(),i=(s.amsDatatableExtensions||"").split(/\s+/),r=s.amsDatatableSdom||"W"+(i.indexOf("colreorder")>=0||i.indexOf("colreorderwithresize")>=0?"R":"")+"<'dt-top-row'"+(i.indexOf("colvis")>=0?"C":"")+(!1===s.amsDatatablePagination||!1===s.amsDatatablePaginationSize?"":"L")+(!1===s.amsDatatableGlobalFilter?"":"F")+">r<'dt-wrapper't"+(i.indexOf("scroller")>=0?"S":"")+"><'dt-row dt-bottom-row'<'row'<'col-sm-6'"+(!1===s.amsDatatableInformation?"":"i")+"><'col-sm-6 text-right'p>>",o=s.amsDatatableSorting;if("string"==typeof o){var c=o.split(";");for(o=[],a=0;a<c.length;a++){var l=c[a].split(",");l[0]=parseInt(l[0]),o.push(l)}}var m,d=[],u=e("th",n).listattr("data-ams-datatable-sortable");for(a=0;a<u.length;a++){var h=u[a];void 0!==h?((m=d[a]||{}).bSortable="string"==typeof h?JSON.parse(h):h,d[a]=m):d[a]=d[a]||{}}var b=e("th",n).listattr("data-ams-datatable-stype");for(a=0;a<b.length;a++){var p=b[a];p?((m=d[a]||{}).sType=p,d[a]=m):d[a]=d[a]||{}}var f={bJQueryUI:!1,bServerSide:s.amsDatatableServerSide||!1,sAjaxSource:!0===s.amsDatatableServerSide?s.amsDatatableAjaxSource:void 0,sServerMethod:!0===s.amsDatatableServerSide?"POST":void 0,bFilter:!1!==s.amsDatatableGlobalFilter||i.indexOf("columnfilter")>=0,bPaginate:!1!==s.amsDatatablePagination,bInfo:!1!==s.amsDatatableInfo,bSort:!1!==s.amsDatatableSort,aaSorting:o,aoColumns:d.length>0?d:void 0,bDeferRender:!0,bAutoWidth:!1,iDisplayLength:s.amsDatatableDisplayLength||25,sPaginationType:s.amsDatatablePaginationType||"bootstrap_full",sDom:r,oLanguage:t.plugins&&t.plugins.i18n.datatables,fnInitComplete:function(a,n){e(".ColVis_Button").addClass("btn btn-default btn-sm").html((t.plugins&&t.plugins.i18n.datatables.sColumns||"Columns")+' <i class="fa fa-fw fa-caret-down"></i>')}},x=e.extend({},f,s.amsDatatableOptions),g=[],v=[],y=[];if(i.length>0)for(a=0;a<i.length;a++)switch(i[a]){case"autofill":g.push(e.fn.dataTable.AutoFill),v.push(t.baseURL+"ext/jquery-dataTables-autoFill"+t.devext+".js");break;case"columnfilter":g.push(e.fn.columnFilter),v.push(t.baseURL+"ext/jquery-dataTables-columnFilter"+t.devext+".js");break;case"colreorder":g.push(e.fn.dataTable.ColReorder),v.push(t.baseURL+"ext/jquery-dataTables-colReorder"+t.devext+".js");break;case"colreorderwithresize":g.push(window.ColReorder),v.push(t.baseURL+"ext/jquery-dataTables-colReorderWithResize"+t.devext+".js");break;case"colvis":g.push(e.fn.dataTable.ColVis),v.push(t.baseURL+"ext/jquery-dataTables-colVis"+t.devext+".js"),y.push((function(){x.oColVis=e.extend({},{activate:"click",sAlign:"right"},s.amsDatatableColvisOptions)}));break;case"editable":g.push(e.fn.editable),v.push(t.baseURL+"ext/jquery-jeditable"+t.devext+".js"),g.push(e.fn.makeEditable),v.push(t.baseURL+"ext/jquery-dataTables-editable"+t.devext+".js");break;case"fixedcolumns":g.push(e.fn.dataTable.FixedColumns),v.push(t.baseURL+"ext/jquery-dataTables-fixedColumns"+t.devext+".js");break;case"fixedheader":g.push(e.fn.dataTable.Fixedheader),v.push(t.baseURL+"ext/jquery-dataTables-fixedHeader"+t.devext+".js");break;case"keytable":g.push(window.keyTable),v.push(t.baseURL+"ext/jquery-dataTables-keyTable"+t.devext+".js");break;case"rowgrouping":g.push(e.fn.rowGrouping),v.push(t.baseURL+"ext/jquery-dataTables-rowGrouping"+t.devext+".js");break;case"rowreordering":g.push(e.fn.rowReordering),v.push(t.baseURL+"ext/jquery-dataTables-rowReordering"+t.devext+".js");break;case"scroller":g.push(e.fn.dataTable.Scroller),v.push(t.baseURL+"ext/jquery-dataTables-scroller"+t.devext+".js")}y.push((function(){x=t.executeFunctionByName(s.amsDatatableInitCallback,n,x)||x;try{var r=n.dataTable(x);if(t.executeFunctionByName(s.amsDatatableAfterInitCallback,n,r,x),i.length>0)for(a=0;a<i.length;a++)switch(i[a]){case"autofill":var o=e.extend({},s.amsDatatableAutofillOptions,x.autofill);o=t.executeFunctionByName(s.amsDatatableAutofillInitCallback,n,o)||o,n.data("ams-autofill",void 0===s.amsDatatableAutofillConstructor?new e.fn.dataTable.AutoFill(n,o):t.executeFunctionByName(s.amsDatatableAutofillConstructor,n,r,o));break;case"columnfilter":var c=e.extend({},{sPlaceHolder:"head:after"},s.amsDatatableColumnfilterOptions,x.columnfilter);c=t.executeFunctionByName(s.amsDatatableColumnfilterInitCallback,n,c)||c,n.data("ams-columnfilter",void 0===s.amsDatatableColumnfilterConstructor?r.columnFilter(c):t.executeFunctionByName(s.amsDatatableColumnfilterConstructor,n,r,c));break;case"editable":var l=e.extend({},s.amsDatatableEditableOptions,x.editable);l=t.executeFunctionByName(s.amsDatatableEditableInitCallback,n,l)||l,n.data("ams-editable",void 0===s.amsDatatableEditableConstructor?n.makeEditable(l):t.executeFunctionByName(s.amsDatatableEditableConstructor,n,r,l));break;case"fixedcolumns":var m=e.extend({},s.amsDatatableFixedcolumnsOptions,x.fixedcolumns);m=t.executeFunctionByName(s.amsDatatableFixedcolumnsInitCallback,n,m)||m,n.data("ams-fixedcolumns",void 0===s.amsDatatableFixedcolumnsConstructor?new e.fn.dataTable.FixedColumns(n,m):t.executeFunctionByName(s.amsDatatableFixedcolumnsConstructor,n,r,m));break;case"fixedheader":var d=e.extend({},s.amsDatatableFixedheaderOptions,x.fixedheader);d=t.executeFunctionByName(s.amsDatatableFixedheadeInitCallback,n,d)||d,n.data("ams-fixedheader",void 0===s.amsDatatableFixedheaderConstructor?new e.fn.dataTable.FixedHeader(n,d):t.executeFunctionByName(s.amsDatatableFixedheaderConstructor,n,r,d));break;case"keytable":var u={table:n.get(0),datatable:r},h=e.extend({},u,s.amsDatatableKeytableOptions,x.keytable);h=t.executeFunctionByName(s.amsDatatableKeytableInitCallback,n,h)||h,n.data("ams-keytable",void 0===s.amsDatatableKeytableConstructor?new KeyTable(h):t.executeFunctionByName(s.amsDatatableKeytableConstructor,n,r,h));break;case"rowgrouping":var b=e.extend({},s.amsDatatableRowgroupingOptions,x.rowgrouping);b=t.executeFunctionByName(s.amsDatatableRowgroupingInitCallback,n,b)||b,n.data("ams-rowgrouping",void 0===s.amsDatatableRowgroupingConstructor?n.rowGrouping(b):t.executeFunctionByName(s.amsDatatableRowgroupingConstructor,n,r,b));break;case"rowreordering":var p=e.extend({},s.amsDatatableRowreorderingOptions,x.rowreordering);p=t.executeFunctionByName(s.amsDatatableRowreorderingInitCallback,n,p)||p,n.data("ams-rowreordering",void 0===s.amsDatatableRowreorderingConstructor?n.rowReordering(p):t.executeFunctionByName(s.amsDatatableRowreorderingConstructor,n,r,p))}if(s.amsDatatableFinalizeCallback){var f=s.amsDatatableFinalizeCallback.split(/\s+/);if(f.length>0)for(a=0;a<f.length;a++)t.executeFunctionByName(f[a],n,r,x)}}catch(e){}})),t.ajax&&t.ajax.check(g,v,y)}))}))}))},tablednd:function(a){var n=e(".table-dnd",a);n.length>0&&t.ajax&&t.ajax.check(e.fn.tableDnD,t.baseURL+"ext/jquery-tablednd"+t.devext+".js",(function(){n.each((function(){var a=e(this),n=a.data();n.amsTabledndDragHandle?e("tr",a).addClass("no-drag-handle"):e(a).on("mouseover","tr",(function(){e(this.cells[0]).addClass("drag-handle")})).on("mouseout","tr",(function(){e(this.cells[0]).removeClass("drag-handle")}));var s={onDragClass:n.amsTabledndDragClass||"dragging-row",onDragStart:t.getFunctionByName(n.amsTabledndDragStart),dragHandle:n.amsTabledndDragHandle,scrollAmount:n.amsTabledndScrollAmount,onAllowDrop:n.amsTabledndAllowDrop,onDrop:t.getFunctionByName(n.amsTabledndDrop)||function(s,i){var r=n.amsTabledndDropTarget;if(r){e(i).data("ams-disabled-handlers","click");try{var o=[];e(s.rows).each((function(){var a=e(this).data("ams-element-name");a&&o.push(a)}));var c=t.getFunctionByName(r);if("function"==typeof c)c.call(a,s,o);else{if(!r.startsWith(window.location.protocol)){var l=n.amsLocation;l&&(r=l+"/"+r)}t.ajax&&t.ajax.post(r,{names:JSON.stringify(o)},(function(e,a){"success"!==e.status&&t.ajax.handleJSON(e)}))}}finally{setTimeout((function(){e(i).removeData("ams-disabled-handlers")}),50)}}return!1}},i=e.extend({},s,n.amsTabledndOptions);i=t.executeFunctionByName(n.amsTabledndInitCallback,a,i)||i;var r=a.tableDnD(i);t.executeFunctionByName(n.amsTabledndAfterInitCallback,a,r,i)}))}))},wizard:function(a){var n=e(".wizard",a);n.length>0&&t.ajax&&t.ajax.check(e.fn.bootstrapWizard,t.baseURL+"ext/bootstrap-wizard-1.4.2"+t.devext+".js",(function(){n.each((function(){var a=e(this),n=a.data(),s={withVisible:void 0===n.amsWizardWithVisible||n.amsWizardWithVisible,tabClass:n.amsWizardTabClass,firstSelector:n.amsWizardFirstSelector,previousSelector:n.amsWizardPreviousSelector,nextSelector:n.amsWizardNextSelector,lastSelector:n.amsWizardLastSelector,finishSelector:n.amsWizardFinishSelector,backSelector:n.amsWizardBackSelector,onInit:t.getFunctionByName(n.amsWizardInit),onShow:t.getFunctionByName(n.amsWizardShow),onNext:t.getFunctionByName(n.amsWizardNext),onPrevious:t.getFunctionByName(n.amsWizardPrevious),onFirst:t.getFunctionByName(n.amsWizardFirst),onLast:t.getFunctionByName(n.amsWizardLast),onBack:t.getFunctionByName(n.amsWizardBack),onFinish:t.getFunctionByName(n.amsWizardFinish),onTabChange:t.getFunctionByName(n.amsWizardTabChange),onTabClick:t.getFunctionByName(n.amsWizardTabClick),onTabShow:t.getFunctionByName(n.amsWizardTabShow)},i=e.extend({},s,n.amsWizardOptions);i=t.executeFunctionByName(n.amsWizardInitCallback,a,i)||i;var r=a.bootstrapWizard(i);t.executeFunctionByName(n.amsWizardAfterInitCallback,a,r,i)}))}))},tinymce:function(a){function n(){e(".tinymce",e(this)).each((function(){var a=tinymce.get(e(this).attr("id"));a&&a.remove()}))}var s=e(".tinymce",a);if(s.length>0){var i=t.baseURL+"ext/tinymce"+(t.devmode?"/dev":"");t.ajax&&t.ajax.check(window.tinymce,i+"/tinymce"+t.devext+".js",(function(a){function r(){s.each((function(){var a=e(this),n=a.data(),s={theme:n.amsTinymceTheme||"modern",language:t.lang,menubar:!1!==n.amsTinymceMenubar,statusbar:!1!==n.amsTinymceStatusbar,plugins:n.amsTinymcePlugins||["advlist autosave autolink lists link charmap print preview hr anchor pagebreak","searchreplace wordcount visualblocks visualchars code fullscreen","insertdatetime nonbreaking save table contextmenu directionality","emoticons paste textcolor colorpicker textpattern autoresize"],toolbar:n.amsTinymceToolbar,toolbar1:!1!==n.amsTinymceToolbar1&&(n.amsTinymceToolbar1||"undo redo | pastetext | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent"),toolbar2:!1!==n.amsTinymceToolbar2&&(n.amsTinymceToolbar2||"forecolor backcolor emoticons | charmap link image media | fullscreen preview print | code"),content_css:n.amsTinymceContentCss,formats:n.amsTinymceFormats,style_formats:n.amsTinymceStyleFormats,block_formats:n.amsTinymceBlockFormats,valid_classes:n.amsTinymceValidClasses,image_advtab:!0,image_list:t.getFunctionByName(n.amsTinymceImageList)||n.amsTinymceImageList,image_class_list:n.amsTinymceImageClassList,link_list:t.getFunctionByName(n.amsTinymceLinkList)||n.amsTinymceLinkList,link_class_list:n.amsTinymceLinkClassList,paste_as_text:void 0===n.amsTinymcePasteAsText||n.amsTinymcePasteAsText,paste_auto_cleanup_on_paste:void 0===n.amsTinymcePasteAutoCleanup||n.amsTinymcePasteAutoCleanup,paste_strip_class_attributes:n.amsTinymcePasteStripClassAttributes||"all",paste_remove_spans:void 0===n.amsTinymcePaseRemoveSpans||n.amsTinymcePasteRemoveSpans,paste_remove_styles:void 0===n.amsTinymcePasteRemoveStyles||n.amsTinymcePasteRemoveStyles,height:n.amsTinymceHeight||50,min_height:50,resize:!0,autoresize_min_height:50,autoresize_max_height:500};if(n.amsTinymceExternalPlugins){var i=n.amsTinymceExternalPlugins.split(/\s+/);for(var r in i)if(i.hasOwnProperty(r)){var o=a.data("ams-tinymce-plugin-"+i[r]);tinymce.PluginManager.load(i[r],t.getSource(o))}}var c=e.extend({},s,n.amsTinymceOptions);c=t.executeFunctionByName(n.amsTinymceInitCallback,a,c)||c;var l=a.tinymce(c);t.executeFunctionByName(n.amsTinymceAfterInitCallback,a,l,c)}))}a?t.getScript(i+"/jquery.tinymce"+t.devext+".js",(function(){tinymce.baseURL=i,tinymce.suffix=t.devext,t.skin&&t.skin.registerCleanCallback(n),r()})):r()}))}},editor:function(n){var s=e(".text-editor textarea",n);s.length>0&&t.ajax&&t.ajax.check(a.ace,t.baseURL+"ext/ace/ace.js",(function(n){var i=function(){a.ace_loaded=!0,s.each((function(){var a=e(this),n=a.parents(".text-editor"),s=n.data(),i=ace.require("ace/ext/modelist"),r=s.amsEditorMode||i.getModeForPath(s.amsEditorFilename||"editor.txt").mode,o=e("<div>",{position:"absolute",width:a.width(),height:a.height(),class:a.attr("class")}).insertBefore(a);a.css("display","none");var c=ace.edit(o[0]),l={mode:r,tabSize:4,useSoftTabs:!1,showGutter:!0,showLineNumbers:!0,printMargin:132,showInvisibles:!0},m=e.extend({},l,s.amsEditorOptions);m=t.executeFunctionByName(s.amsEditorInitCallback,a,m)||m,c.setOptions(m),c.session.setValue(a.val()),c.session.on("change",(function(){a.val(c.session.getValue())})),n.data("editor",c),t.executeFunctionByName(s.amsEditorAfterInitCallback,a,c,m)}))};n?(ace.config.set("basePath",t.baseURL+"ext/ace"),t.ajax.check(a.ace_loaded,[t.baseURL+"ext/ace/ext-modelist.js"],i)):i()}))},imgareaselect:function(a){var n=e(".imgareaselect",a);n.length>0&&t.ajax&&t.ajax.check(e.fn.imgAreaSelect,t.baseURL+"ext/jquery-imgareaselect-0.9.11-rc1"+t.devext+".js",(function(){t.getCSS(t.baseURL+"../css/ext/jquery-imgareaselect"+t.devext+".css","jquery-imgareaselect",(function(){n.each((function(){var a=e(this),n=a.data(),s=n.amsImgareaselectParent?a.parents(n.amsImgareaselectParent):"body",i={instance:!0,handles:!0,parent:s,x1:n.amsImgareaselectX1||0,y1:n.amsImgareaselectY1||0,x2:n.amsImgareaselectX2||n.amsImgareaselectImageWidth,y2:n.amsImgareaselectY2||n.amsImgareaselectImageHeight,imageWidth:n.amsImgareaselectImageWidth,imageHeight:n.amsImgareaselectImageHeight,minWidth:128,minHeight:128,aspectRatio:n.amsImgareaselectRatio,onSelectEnd:t.getFunctionByName(n.amsImgareaselectSelectEnd)||function(a,t){var i=n.amsImgareaselectTargetField||"image_";e('input[name="'+i+'x1"]',s).val(t.x1),e('input[name="'+i+'y1"]',s).val(t.y1),e('input[name="'+i+'x2"]',s).val(t.x2),e('input[name="'+i+'y2"]',s).val(t.y2)}},r=e.extend({},i,n.amsImgareaselectOptions);r=t.executeFunctionByName(n.amsImgareaselectInitCallback,a,r)||r;var o=a.imgAreaSelect(r);t.executeFunctionByName(n.amsImgareaselectAfterInitCallback,a,o,r),setTimeout((function(){o.update()}),250)}))}))}))},fancybox:function(a){var n=e(".fancybox",a);n.length>0&&t.ajax&&t.ajax.check(e.fn.fancybox,t.baseURL+"ext/jquery-fancybox-2.1.5"+t.devext+".js",(function(){t.getCSS(t.baseURL+"../css/ext/jquery-fancybox-2.1.5"+t.devext+".css","jquery-fancybox",(function(){n.each((function(){var a,n=e(this),s=n.data(),i=n;s.amsFancyboxElements&&(i=e(s.amsFancyboxElements,n));var r=(s.amsFancyboxHelpers||"").split(/\s+/);if(r.length>0)for(a=0;a<r.length;a++)switch(r[a]){case"buttons":t.ajax&&t.ajax.check(e.fancybox.helpers.buttons,t.baseURL+"ext/fancybox-helpers/fancybox-buttons"+t.devext+".js");break;case"thumbs":t.ajax&&t.ajax.check(e.fancybox.helpers.thumbs,t.baseURL+"ext/fancybox-helpers/fancybox-thumbs"+t.devext+".js");break;case"media":t.ajax&&t.ajax.check(e.fancybox.helpers.media,t.baseURL+"ext/fancybox-helpers/fancybox-media"+t.devext+".js")}var o={type:s.amsFancyboxType,padding:s.amsFancyboxPadding||10,margin:s.amsFancyboxMargin||10,loop:s.amsFancyboxLoop,beforeLoad:t.getFunctionByName(s.amsFancyboxBeforeLoad)||function(){var a;if(s.amsFancyboxTitleGetter&&(a=t.executeFunctionByName(s.amsFancyboxTitleGetter,this)),!a){var n=e("*:first",this.element);(a=n.attr("original-title")||n.attr("title"))||(a=e(this.element).attr("original-title")||e(this.element).attr("title"))}this.title=a},afterLoad:t.getFunctionByName(s.amsFancyboxAfterLoad),helpers:{title:{type:"inside"}}};if(r.length>0)for(a=0;a<r.length;a++)switch(r[a]){case"buttons":o.helpers.buttons={position:s.amsFancyboxButtonsPosition||"top"};break;case"thumbs":o.helpers.thumbs={width:s.amsFancyboxThumbsWidth||50,height:s.amsFancyboxThumbsHeight||50};break;case"media":o.helpers.media=!0}var c=e.extend({},o,s.amsFancyboxOptions);c=t.executeFunctionByName(s.amsFancyboxInitCallback,n,c)||c;var l=i.fancybox(c);t.executeFunctionByName(s.amsFancyboxAfterInitCallback,n,l,c)}))}))}))},chart:function(a){var n=e(".chart",a);n.length>0&&t.ajax&&t.ajax.check([window.Flot,e.color],[t.baseURL+"ext/flot/jquery.canvaswrapper"+t.devext+".js",t.baseURL+"ext/flot/jquery.colorhelpers"+t.devext+".js"],(function(){t.ajax.check(e.plot,t.baseURL+"ext/flot/jquery.flot"+t.devext+".js",(function(){t.ajax.check(e.plot.uiConstants,t.baseURL+"ext/flot/jquery.flot.uiConstants"+t.devext+".js",(function(){n.each((function(){var a,n=e(this),s=n.data(),i={},r=(s.amsChartPlugins||"").split(/\s+/);function o(a){for(var t in e.plot.plugins)if(e.plot.plugins.hasOwnProperty(t)){var n=e.plot.plugins[t];if(n.name===a)return n}return null}function c(){var a=e.extend({},i,s.amsChartOptions);a=t.executeFunctionByName(s.amsChartInitCallback,n,a)||a;var r=s.amsChartData,o=s.amsChartDataLoader;o?e.getJSON(o,r).done((function(t){a=e.extend({},a,t.settings),l(t.data,a)})):l(s,a)}function l(e,i){e=t.executeFunctionByName(s.amsChartInitData,n,e)||e,a=n.plot(e,i),t.executeFunctionByName(s.amsChartAfterInitCallback,n,a,i)}var m=[];if(r.length>0)for(var d in r)if(r.hasOwnProperty(d)){var u=r[d];o(u)||m.push(t.getScript(t.baseURL+"ext/flot/jquery.flot."+u+t.devext+".js"))}m.length>0?e.when.apply(e,m).then((function(){c()})):c()}))}))}))}))},graphs:function(a){var n=e(".sparkline",a);n.length>0&&t.ajax&&t.ajax.check(t.graphs,t.baseURL+"myams-graphs"+t.devext+".js",(function(){t.graphs.init(n)}))},scrollbars:function(a){var n=e(".scrollbar",a);n.length>0&&t.ajax&&t.ajax.check(e.event.special.mousewheel,t.baseURL+"ext/jquery-mousewheel.min.js",(function(){t.ajax.check(e.fn.mCustomScrollbar,t.baseURL+"ext/jquery-mCustomScrollbar"+t.devext+".js",(function(){t.getCSS(t.baseURL+"../css/ext/jquery-mCustomScrollbar.css","jquery-mCustomScrollbar",(function(){n.each((function(){var a=e(this),n=a.data(),s={theme:n.amsScrollbarTheme||"light"},i=e.extend({},s,n.amsScrollbarOptions);i=t.executeFunctionByName(n.amsScrollbarInitCallback,a,i)||i;var r=a.mCustomScrollbar(i);t.executeFunctionByName(n.amsScrollbarAfterInitCallback,a,r,i)}))}))}))}))}})}(jQuery,this);
+!function(e,a){var t=a.MyAMS;e.extend(t.plugins.enabled,{svg:function(a){var t=e(".svg-container",a);t.length>0&&t.each((function(){var a=e(this),t=e("svg",a),n=t.attr("width"),s=t.attr("height");n&&s&&t.get(0).setAttribute("viewBox","0 0 "+Math.round(parseFloat(n))+" "+Math.round(parseFloat(s))),t.attr("width","100%").attr("height","auto")}))},hint:function(a){var n=e(".hint:not(:parents(.nohints))",a);n.length>0&&t.ajax&&t.ajax.check(e.fn.tipsy,t.baseURL+"ext/jquery-tipsy"+t.devext+".js",(function(){t.getCSS(t.baseURL+"../css/ext/jquery-tipsy"+t.devext+".css","jquery-tipsy",(function(){n.each((function(){var a=e(this),n=a.data(),s={html:void 0===n.amsHintHtml?(a.attr("title")||"").startsWith("<"):n.amsHintHtml,title:t.getFunctionByName(n.amsHintTitleGetter)||function(){var a=e(this),t=a.attr("original-title")||a.attr(n.amsHintTitleAttr||"title")||(n.amsHintHtml?a.html():a.text());return t=t.replace(/\?_="/,"?_="+(new Date).getTime()+'"')},opacity:n.amsHintOpacity||.95,gravity:n.amsHintGravity||"sw",offset:n.amsHintOffset||0},i=e.extend({},s,n.amsHintOptions);i=t.executeFunctionByName(n.amsHintInitCallback,a,i)||i;var r=a.tipsy(i);t.executeFunctionByName(n.amsHintAfterInitCallback,a,r,i)}))}))}))},contextMenu:function(a){var n=e(".context-menu",a);n.length>0&&n.each((function(){var a=e(this),n=a.data(),s={menuSelector:n.amsContextmenuSelector,menuSelected:t.helpers&&t.helpers.contextMenuHandler},i=e.extend({},s,n.amsContextmenuOptions);i=t.executeFunctionByName(n.amsContextmenuInitCallback,a,i)||i;var r=a.contextMenu(i);t.executeFunctionByName(n.amsContextmenuAfterInitCallback,a,r,i)}))},switcher:function(a){e("LEGEND.switcher",a).each((function(){var a=e(this),t=a.parent("fieldset"),n=a.data();n.amsSwitcher||(e('<i class="fa fa-fw"></i>').prependTo(e(this)).addClass("open"===n.amsSwitcherState?n.amsSwitcherMinusClass||"fa-minus":n.amsSwitcherPlusClass||"fa-plus"),a.on("click",(function(s){s.preventDefault();var i={};if(a.trigger("ams.switcher.before-switch",[a,i]),!i.veto)if(t.hasClass("switched")){t.removeClass("switched"),e(".fa",a).removeClass(n.amsSwitcherPlusClass||"fa-plus").addClass(n.amsSwitcherMinusClass||"fa-minus"),a.trigger("ams.switcher.opened",[a]);var r=a.attr("id");r&&e('legend.switcher[data-ams-switcher-sync="'+r+'"]',t).each((function(){var a=e(this);a.parents("fieldset").hasClass("switched")&&a.click()}))}else t.addClass("switched"),e(".fa",a).removeClass(n.amsSwitcherMinusClass||"fa-minus").addClass(n.amsSwitcherPlusClass||"fa-plus"),a.trigger("ams.switcher.closed",[a])})),"open"!==n.amsSwitcherState&&t.addClass("switched"),a.data("ams-switcher","on"))}))},checker:function(a){e("LEGEND.checker",a).each((function(){var a=e(this),n=a.parent("fieldset"),s=a.data();if(!s.amsChecker){var i=e('<label class="checkbox"></label>'),r=s.amsCheckerFieldname||"checker_"+t.generateId(),o=r.replace(/\./,"_"),c=s.amsCheckerHiddenPrefix,l=null,m=s.amsCheckerHiddenValueOn||"true",d=s.amsCheckerHiddenValueOff||"false",u=s.amsCheckerMarker||!1;c?l=e('<input type="hidden">').attr("name",c+r).val("on"===s.amsCheckerState?m:d).prependTo(a):u&&e('<input type="hidden">').attr("name",u).attr("value",1).prependTo(a);var h=e('<input type="checkbox">').attr("name",r).attr("id",o).data("ams-checker-hidden-input",l).data("ams-checker-init",!0).val(s.amsCheckerValue||!0).attr("checked","on"===s.amsCheckerState?"checked":null);s.amsCheckerReadonly?h.attr("disabled","disabled"):h.on("change",(function(i){i.preventDefault();var r={},o=e(this).is(":checked");if(a.trigger("ams.checker.before-switch",[a,r]),r.veto)e(this).prop("checked",!o);else if(t.executeFunctionByName(s.amsCheckerChangeHandler,a,o),!s.amsCheckerCancelDefault){var c=h.data("ams-checker-hidden-input");o?("disable"===s.amsCheckerMode?(n.removeAttr("disabled"),e(".select2",n).removeAttr("disabled")):n.removeClass("switched"),c&&c.val(m),e("[data-required]",n).attr("required","required"),a.trigger("ams.checker.opened",[a])):("disable"===s.amsCheckerMode?(n.prop("disabled","disabled"),e(".select2",n).attr("disabled","disabled")):n.addClass("switched"),c&&c.val(d),e("[data-required]",n).removeAttr("required"),a.trigger("ams.checker.closed",[a]))}})),h.appendTo(i),e(">label",a).attr("for",h.attr("id")),i.append("<i></i>").prependTo(a);var b=e("[required]",n);b.attr("data-required",!0),"on"===s.amsCheckerState?h.attr("checked",!0):("disable"===s.amsCheckerMode?(n.attr("disabled","disabled"),e(".select2",n).attr("disabled","disabled")):n.addClass("switched"),b.removeAttr("required")),a.data("ams-checker","on")}}))},slider:function(a){var n=e(".slider",a);n.length>0&&t.ajax&&t.ajax.check(e.fn.slider,t.baseURL+"ext/bootstrap-slider-2.0.0"+t.devext+".js",(function(){n.each((function(){var a=e(this),n=a.data(),s=e.extend({},{},a.data.amsSliderOptions);s=t.executeFunctionByName(n.amsSliderInitCallback,a,s)||s;var i=a.slider(s);t.executeFunctionByName(n.amsSliderAfterInitCallback,a,i,s)}))}))},draggable:function(a){var n=e(".draggable",a);n.length>0&&n.each((function(){var a=e(this),n=a.data(),s={cursor:n.amsDraggableCursor||"move",containment:n.amsDraggableContainment,handle:n.amsDraggableHandle,connectToSortable:n.amsDraggableConnectSortable,helper:t.getFunctionByName(n.amsDraggableHelper)||n.amsDraggableHelper,start:t.getFunctionByName(n.amsDraggableStart),stop:t.getFunctionByName(n.amsDraggableStop)},i=e.extend({},s,n.amsDraggableOptions);i=t.executeFunctionByName(n.amsDraggableInitCallback,a,i)||i;var r=a.draggable(i);a.disableSelection(),t.executeFunctionByName(n.amsDraggableAfterInitCallback,a,r,i)}))},droppable:function(a){var n=e(".droppable",a);n.length>0&&n.each((function(){var a=e(this),n=a.data(),s={accept:n.amsDroppableAccept,drop:t.getFunctionByName(n.amsDroppableDrop)},i=e.extend({},s,n.amsDroppableOptions);i=t.executeFunctionByName(n.amsDroppableInitCallback,a,i)||i;var r=a.droppable(i);t.executeFunctionByName(n.amsDroppableAfterInitCallback,a,r,i)}))},sortable:function(a){var n=e(".sortable",a);n.length>0&&n.each((function(){var a=e(this),n=a.data(),s={items:n.amsSortableItems,handle:n.amsSortableHandle,helper:n.amsSortableHelper,connectWith:n.amsSortableConnectwith,start:t.getFunctionByName(n.amsSortableStart),over:t.getFunctionByName(n.amsSortableOver),containment:n.amsSortableContainment,placeholder:n.amsSortablePlaceholder,stop:t.getFunctionByName(n.amsSortableStop)},i=e.extend({},s,n.amsSortableOptions);i=t.executeFunctionByName(n.amsSortableInitCallback,a,i)||i;var r=a.sortable(i);a.disableSelection(),t.executeFunctionByName(n.amsSortableAfterInitCallback,a,r,i)}))},resizable:function(a){var n=e(".resizable",a);n.length>0&&n.each((function(){var a=e(this),n=a.data(),s={autoHide:!1===n.amsResizableAutohide||n.amsResizableAutohide,containment:n.amsResizableContainment,grid:n.amsResizableGrid,handles:n.amsResizableHandles,start:t.getFunctionByName(n.amsResizableStart),stop:t.getFunctionByName(n.amsResizableStop)},i=e.extend({},s,n.amsResizableOptions);i=t.executeFunctionByName(n.amsResizableInitCallback,a,i)||i;var r=a.resizable(i);a.disableSelection(),t.executeFunctionByName(n.amsResizableAfterInitCallback,a,r,i)}))},typeahead:function(a){var n=e(".typeahead",a);n.length>0&&t.ajax&&t.ajax.check(e.fn.typeahead,t.baseURL+"ext/jquery-typeahead"+t.devext+".js",(function(){n.each((function(){var a=e(this),n=a.data(),s=e.extend({},{},n.amsTypeaheadOptions);s=t.executeFunctionByName(n.amsTypeaheadInitCallback,a,s)||s;var i=a.typeahead(s);t.executeFunctionByName(n.amsTypeaheadAfterInitCallback,a,i,s)}))}))},treeview:function(a){var n=e(".treeview",a);n.length>0&&t.ajax&&t.ajax.check(e.fn.treview,t.baseURL+"ext/bootstrap-treeview"+t.devext+".js",(function(){t.getCSS(t.baseURL+"../css/ext/bootstrap-treeview"+t.devext+".css","bootstrap-treeview",(function(){n.each((function(){var a=e(this),n=a.data(),s={data:n.amsTreeviewData,levels:n.amsTreeviewLevels,injectStyle:n.amsTreeviewInjectStyle,expandIcon:n.amsTreeviewExpandIcon||"fa fa-fw fa-plus-square-o",collapseIcon:n.amsTreeviewCollaspeIcon||"fa fa-fw fa-minus-square-o",emptyIcon:n.amsTreeviewEmptyIcon||"fa fa-fw",nodeIcon:n.amsTreeviewNodeIcon,selectedIcon:n.amsTreeviewSelectedIcon,checkedIcon:n.amsTreeviewCheckedIcon||"fa fa-fw fa-check-square-o",uncheckedIcon:n.amsTreeviewUncheckedIcon||"fa fa-fw fa-square-o",color:n.amsTreeviewColor,backColor:n.amsTreeviewBackColor,borderColor:n.amsTreeviewBorderColor,onHoverColor:n.amsTreeviewHoverColor,selectedColor:n.amsTreeviewSelectedColor,selectedBackColor:n.amsTreeviewSelectedBackColor,unselectableColor:n.amsTreeviewUnselectableColor||"rgba(1,1,1,0.25)",unselectableBackColor:n.amsTreeviewUnselectableBackColor||"rgba(1,1,1,0.25)",enableLinks:n.amsTreeviewEnableLinks,highlightSelected:n.amsTreeviewHighlightSelected,highlightSearchResults:n.amsTreeviewhighlightSearchResults,showBorder:n.amsTreeviewShowBorder,showIcon:n.amsTreeviewShowIcon,showCheckbox:n.amsTreeviewShowCheckbox,showTags:n.amsTreeviewShowTags,toggleUnselectable:n.amsTreeviewToggleUnselectable,multiSelect:n.amsTreeviewMultiSelect,onNodeChecked:t.getFunctionByName(n.amsTreeviewNodeChecked),onNodeCollapsed:t.getFunctionByName(n.amsTreeviewNodeCollapsed),onNodeDisabled:t.getFunctionByName(n.amsTreeviewNodeDisabled),onNodeEnabled:t.getFunctionByName(n.amsTreeviewNodeEnabled),onNodeExpanded:t.getFunctionByName(n.amsTreeviewNodeExpanded),onNodeSelected:t.getFunctionByName(n.amsTreeviewNodeSelected),onNodeUnchecked:t.getFunctionByName(n.amsTreeviewNodeUnchecked),onNodeUnselected:t.getFunctionByName(n.amsTreeviewNodeUnselected),onSearchComplete:t.getFunctionByName(n.amsTreeviewSearchComplete),onSearchCleared:t.getFunctionByName(n.amsTreeviewSearchCleared)},i=e.extend({},s,n.amsTreeviewOptions);i=t.executeFunctionByName(n.amsTreeviewInitcallback,a,i)||i;var r=a.treeview(i);t.executeFunctionByName(n.amsTreeviewAfterInitCallback,a,r,i)}))}))}))},select2:function(a){var n=e(".select2",a);n.length>0&&t.ajax&&t.ajax.check(e.fn.select2,t.baseURL+"ext/jquery-select2-3.5.4"+t.devext+".js",(function(){n.each((function(){var a=e(this),n=a.data();if(!n.select2){var s={placeholder:n.amsSelect2Placeholder,multiple:n.amsSelect2Multiple,minimumInputLength:n.amsSelect2MinimumInputLength||0,maximumSelectionSize:n.amsSelect2MaximumSelectionSize,openOnEnter:void 0===n.amsSelect2EnterOpen||n.amsSelect2EnterOpen,allowClear:void 0===n.amsSelect2AllowClear||n.amsSelect2AllowClear,width:n.amsSelect2Width||"100%",initSelection:t.getFunctionByName(n.amsSelect2InitSelection),formatSelection:void 0===n.amsSelect2FormatSelection?t.helpers&&t.helpers.select2FormatSelection:t.getFunctionByName(n.amsSelect2FormatSelection),formatResult:t.getFunctionByName(n.amsSelect2FormatResult),formatMatches:void 0===n.amsSelect2FormatMatches?function(e){return 1===e?t.i18n.SELECT2_MATCH:e+t.i18n.SELECT2_MATCHES}:t.getFunctionByName(n.amsSelect2FormatMatches),formatNoMatches:void 0===n.amsSelect2FormatResult?function(e){return t.i18n.SELECT2_NOMATCHES}:t.getFunctionByName(n.amsSelect2FormatResult),formatInputTooShort:void 0===n.amsSelect2FormatInputTooShort?function(e,a){var n=a-e.length;return t.i18n.SELECT2_INPUT_TOOSHORT.replace(/\{0\}/,n).replace(/\{1\}/,1===n?"":t.i18n.SELECT2_PLURAL)}:t.getFunctionByName(n.amsSelect2FormatInputTooShort),formatInputTooLong:void 0===n.amsSelect2FormatInputTooLong?function(e,a){var n=e.length-a;return t.i18n.SELECT2_INPUT_TOOLONG.replace(/\{0\}/,n).replace(/\{1\}/,1===n?"":t.i18n.SELECT2_PLURAL)}:t.getFunctionByName(n.amsSelect2FormatInputTooLong),formatSelectionTooBig:void 0===n.amsSelect2FormatSelectionTooBig?function(e){return t.i18n.SELECT2_SELECTION_TOOBIG.replace(/\{0\}/,e).replace(/\{1\}/,1===e?"":t.i18n.SELECT2_PLURAL)}:t.getFunctionByName(n.amsSelect2FormatSelectionTooBig),formatLoadMore:void 0===n.amsSelect2FormatLoadMore?function(e){return t.i18n.SELECT2_LOADMORE}:t.getFunctionByName(n.amsSelect2FormatLoadMore),formatSearching:void 0===n.amsSelect2FormatSearching?function(){return t.i18n.SELECT2_SEARCHING}:t.getFunctionByName(n.amsSelect2FormatSearching),separator:n.amsSelect2Separator||",",tokenSeparators:n.amsSelect2TokensSeparators||[","],tokenizer:t.getFunctionByName(n.amsSelect2Tokenizer)};switch(a.context.type){case"text":case"hidden":if(!s.initSelection){var i=a.data("ams-select2-values");i&&(s.initSelection=function(a,t){var n=[];e(a.val().split(s.separator)).each((function(){n.push({id:this,text:i[this]||this})})),t(n)})}}a.attr("readonly")?"hidden"===a.attr("type")&&(s.query=function(){return[]}):n.amsSelect2Query?(s.query=t.getFunctionByName(n.amsSelect2Query),s.minimumInputLength=n.amsSelect2MinimumInputLength||1):n.amsSelect2QueryUrl?(s.ajax={url:n.amsSelect2QueryUrl,quietMillis:n.amsSelect2QuietMillis||200,type:n.amsSelect2QueryType||"POST",dataType:n.amsSelect2QueryDatatype||"json",data:function(a,t,s){var i={};return i[n.amsSelect2QueryParamName||"query"]=a,i[n.amsSelect2PageParamName||"page"]=t,i[n.amsSelect2ContextParamName||"context"]=s,e.extend({},i,n.amsSelect2QueryOptions)},results:t.helpers&&t.helpers.select2QueryUrlResultsCallback},s.minimumInputLength=n.amsSelect2MinimumInputLength||1):n.amsSelect2QueryMethod?(s.query=function(s){var i={id:(new Date).getTime(),params:n.amsSelect2QueryParams||{},success:function(e){return t.helpers&&t.helpers.select2QueryMethodSuccessCallback.call(a,e,"success",s)},error:t.error&&t.error.show};i.params[n.amsSelect2QueryParamName||"query"]=s.term,i.params[n.amsSelect2PageParamName||"page"]=s.page,i.params[n.amsSelect2ContextParamName||"context"]=s.context,i=e.extend({},i,n.amsSelect2QueryOptions),i=t.executeFunctionByName(n.amsSelect2QueryInitCallback,a,i)||i,t.ajax&&t.ajax.check(e.jsonRPC,t.baseURL+"ext/jquery-jsonrpc"+t.devext+".js",(function(){e.jsonRPC.withOptions({endPoint:n.amsSelect2MethodTarget||t.jsonrpc&&t.jsonrpc.getAddr(),namespace:n.amsSelect2MethodNamespace,cache:!1},(function(){e.jsonRPC.request(n.amsSelect2QueryMethod,i)}))}))},s.minimumInputLength=n.amsSelect2MinimumInputLength||1):n.amsSelect2Tags?s.tags=n.amsSelect2Tags:n.amsSelect2Data&&(s.data=n.amsSelect2Data),n.amsSelect2EnableFreeTags&&(s.createSearchChoice=function(e){return{id:e,text:(n.amsSelect2FreeTagsPrefix||t.i18n.SELECT2_FREETAG_PREFIX)+e}});var r=e.extend({},s,n.amsSelect2Options);r=t.executeFunctionByName(n.amsSelect2InitCallback,a,r)||r;var o=a.select2(r);t.executeFunctionByName(n.amsSelect2AfterInitCallback,a,o,r),a.hasClass("ordered")&&!a.prop("disabled")&&t.ajax&&t.ajax.check(e.fn.select2Sortable,t.baseURL+"ext/jquery-select2-sortable"+t.devext+".js",(function(){a.select2Sortable({bindOrder:"sortableStop"})})),a.on("change",(function(){void 0!==e(a.get(0).form).data("validator")&&e(a).valid()}))}}))}))},maskedit:function(a){var n=e("[data-mask]",a);n.length>0&&t.ajax&&t.ajax.check(e.fn.mask,t.baseURL+"ext/jquery-maskedinput-1.4.1"+t.devext+".js",(function(){n.each((function(){var a=e(this),n=a.data(),s={placeholder:void 0===n.amsMaskeditPlaceholder?"X":n.amsMaskeditPlaceholder,complete:t.getFunctionByName(n.amsMaskeditComplete)},i=e.extend({},s,n.amsMaskeditOptions);i=t.executeFunctionByName(n.amsMaskeditInitCallback,a,i)||i;var r=a.mask(a.attr("data-mask"),i);t.executeFunctionByName(n.amsMaskeditAfterInitCallback,a,r,i)}))}))},inputmask:function(a){var n=e("input[data-input-mask]",a);n.length>0&&t.ajax&&t.ajax.check(e.fn.inputmask,t.baseURL+"ext/jquery-inputmask-bundle-3.2.8"+t.devext+".js",(function(){n.each((function(){var a,n=e(this),s=n.data();a="object"==typeof s.inputMask?s.inputMask:{mask:s.inputMask.toString()};var i=e.extend({},a,s.amsInputmaskOptions);i=t.executeFunctionByName(s.amsInputmaskInitCallback,n,i)||i;var r=n.inputmask(i);t.executeFunctionByName(s.amsInputmaskAfterInitCallback,n,r,i)}))}))},datepicker:function(a){var n=e(".datepicker",a);n.length>0&&t.ajax&&t.ajax.check(e.fn.datetimepicker,t.baseURL+"ext/jquery-datetimepicker"+t.devext+".js",(function(a){a&&t.dialog&&t.dialog.registerHideCallback(t.helpers&&t.helpers.datetimepickerDialogHiddenCallback),t.getCSS(t.baseURL+"../css/ext/jquery-datetimepicker"+t.devext+".css","jquery-datetimepicker",(function(){n.each((function(){var a=e(this),n=a.data(),s={lang:n.amsDatetimepickerLang||t.lang,format:n.amsDatetimepickerFormat||"d/m/y",datepicker:!0,dayOfWeekStart:1,timepicker:!1,closeOnDateSelect:void 0===n.amsDatetimepickerCloseOnSelect||n.amsDatetimepickerCloseOnSelect,weeks:n.amsDatetimepickerWeeks},i=e.extend({},s,n.amsDatetimepickerOptions);i=t.executeFunctionByName(n.amsDatetimepickerInitCallback,a,i)||i;var r=a.datetimepicker(i);t.executeFunctionByName(n.amsDatetimepickerAfterInitCallback,a,r,i)}))}))}))},datetimepicker:function(a){var n=e(".datetimepicker",a);n.length>0&&t.ajax&&t.ajax.check(e.fn.datetimepicker,t.baseURL+"ext/jquery-datetimepicker"+t.devext+".js",(function(a){a&&t.dialog&&t.dialog.registerHideCallback(t.helpers&&t.helpers.datetimepickerDialogHiddenCallback),t.getCSS(t.baseURL+"../css/ext/jquery-datetimepicker"+t.devext+".css","jquery-datetimepicker",(function(){n.each((function(){var a=e(this),n=a.data(),s={lang:n.amsDatetimepickerLang||t.lang,format:n.amsDatetimepickerFormat||"d/m/y H:i",datepicker:!0,dayOfWeekStart:1,timepicker:!0,closeOnDateSelect:void 0===n.amsDatetimepickerCloseOnSelect||n.amsDatetimepickerCloseOnSelect,closeOnTimeSelect:void 0===n.amsDatetimepickerCloseOnSelect||n.amsDatetimepickerCloseOnSelect,weeks:n.amsDatetimepickerWeeks},i=e.extend({},s,n.amsDatetimepickerOptions);i=t.executeFunctionByName(n.amsDatetimepickerInitCallback,a,i)||i;var r=a.datetimepicker(i);t.executeFunctionByName(n.amsDatetimepickerAfterInitCallback,a,r,i)}))}))}))},timepicker:function(a){var n=e(".timepicker",a);n.length>0&&t.ajax&&t.ajax.check(e.fn.datetimepicker,t.baseURL+"ext/jquery-datetimepicker"+t.devext+".js",(function(a){a&&t.dialog&&t.dialog.registerHideCallback(t.helpers&&t.helpers.datetimepickerDialogHiddenCallback),t.getCSS(t.baseURL+"../css/ext/jquery-datetimepicker"+t.devext+".css","jquery-datetimepicker",(function(){n.each((function(){var a=e(this),n=a.data(),s={lang:n.amsDatetimepickerLang||t.lang,format:n.amsDatetimepickerFormat||"H:i",datepicker:!1,timepicker:!0,closeOnTimeSelect:void 0===n.amsDatetimepickerCloseOnSelect||n.amsDatetimepickerCloseOnSelect},i=e.extend({},s,n.amsDatetimepickerOptions);i=t.executeFunctionByName(n.amsDatetimepickerInitCallback,a,i)||i;var r=a.datetimepicker(i);t.executeFunctionByName(n.amsDatetimepickerAfterInitCallback,a,r,i)}))}))}))},colorpicker:function(a){var n=e(".colorpicker",a);n.length>0&&t.ajax&&t.ajax.check(e.fn.minicolors,t.baseURL+"ext/jquery-minicolors"+t.devext+".js",(function(){t.getCSS(t.baseURL+"../css/ext/jquery-minicolors"+t.devext+".css","jquery-minicolors",(function(){n.each((function(){var a=e(this),n=a.data(),s={position:n.amsColorpickerPosition||a.closest(".input").data("ams-colorpicker-position")||"bottom left"},i=e.extend({},s,n.amsColorpickerOptions);i=t.executeFunctionByName(n.amsColorpickerInitCallback,a,i)||i;var r=a.minicolors(i);t.executeFunctionByName(n.amsDatetimepickerAfterInitCallback,a,r,i)}))}))}))},dndupload:function(a){var n=e(".dndupload",a);n.length>0&&t.ajax&&t.ajax.check(e.fn.dndupload,t.baseURL+"ext/jquery-dndupload"+t.devext+".js",(function(){t.getCSS(t.baseURL+"../css/ext/jquery-dndupload"+t.devext+".css","jquery-dndupload",(function(){n.each((function(){var a=e(this),n=a.data(),s={action:n.amsDnduploadAction||a.attr("action")||"upload-files",fieldname:n.amsDnduploadFieldname||"files",autosubmit:n.amsDnduploadAutosubmit},i=e.extend({},s,n.amsDnduploadOptions);i=t.executeFunctionByName(n.amsDnduploadInitCallback,a,i)||i;var r=a.dndupload(i);t.executeFunctionByName(n.amsDnduploadAfterInitcallback,a,r,i)}))}))}))},validate:function(a){var n=e("FORM:not([novalidate])",a);n.length>0&&t.ajax&&t.ajax.check(e.fn.validate,t.baseURL+"ext/jquery-validate-1.17.0"+t.devext+".js",(function(a){if(a&&(e.validator.setDefaults({highlight:function(a){e(a).closest(".form-group, label:not(:parents(.form-group))").addClass("state-error")},unhighlight:function(a){e(a).closest(".form-group, label:not(:parents(.form-group))").removeClass("state-error")},errorElement:"span",errorClass:"state-error",errorPlacement:function(e,a){var t=a.parents("label, .input").first();t.length?e.insertAfter(t):e.insertAfter(a)}}),t.plugins&&t.plugins.i18n)){for(var s in t.plugins.i18n.validate)if(t.plugins.i18n.validate.hasOwnProperty(s)){var i=t.plugins.i18n.validate[s];"string"==typeof i&&i.indexOf("{0}")>-1&&(t.plugins.i18n.validate[s]=e.validator.format(i))}e.extend(e.validator.messages,t.plugins.i18n.validate)}n.each((function(){var a=e(this),n=a.data(),s={ignore:null,submitHandler:void 0!==a.attr("data-async")?void 0===n.amsFormSubmitHandler?function(){return e(".state-error",a).removeClass("state-error"),t.ajax&&t.ajax.check(e.fn.ajaxSubmit,t.baseURL+"ext/jquery-form-3.49"+t.devext+".js"),t.form&&t.form.submit(a)}:t.getFunctionByName(n.amsFormSubmitHandler):void 0,invalidHandler:void 0===n.amsFormInvalidHandler?function(t,n){e(".state-error",a).removeClass("state-error");for(var s=0;s<n.errorList.length;s++){var i=n.errorList[s],r=e(i.element).parents(".tab-pane").index()+1;if(r>0){var o=e(".nav-tabs",e(i.element).parents(".tabforms"));e("li:nth-child("+r+")",o).removeClassPrefix("state-").addClass("state-error"),e("li.state-error:first a",o).click()}}}:t.getFunctionByName(n.amsFormInvalidHandler)};e("[data-ams-validate-rules]",a).each((function(a){0===a&&(s.rules={}),s.rules[e(this).attr("name")]=e(this).data("ams-validate-rules")})),e("[data-ams-validate-messages]",a).each((function(a){0===a&&(s.messages={}),s.messages[e(this).attr("name")]=e(this).data("ams-validate-messages")}));var i=e.extend({},s,n.amsValidateOptions);i=t.executeFunctionByName(n.amsValidateInitCallback,a,i)||i;var r=a.validate(i);t.executeFunctionByName(n.amsValidateAfterInitCallback,a,r,i)}))}))},datatable:function(a){var n=e(".datatable",a);n.length>0&&t.ajax&&t.ajax.check(e.fn.dataTable,t.baseURL+"ext/jquery-dataTables-1.9.4"+t.devext+".js",(function(){t.ajax.check(e.fn.dataTableExt.oPagination.bootstrap_full,t.baseURL+"myams-dataTables"+t.devext+".js",(function(){e(n).each((function(){var a,n=e(this),s=n.data(),i=(s.amsDatatableExtensions||"").split(/\s+/),r=s.amsDatatableSdom||"W"+(i.indexOf("colreorder")>=0||i.indexOf("colreorderwithresize")>=0?"R":"")+"<'dt-top-row'"+(i.indexOf("colvis")>=0?"C":"")+(!1===s.amsDatatablePagination||!1===s.amsDatatablePaginationSize?"":"L")+(!1===s.amsDatatableGlobalFilter?"":"F")+">r<'dt-wrapper't"+(i.indexOf("scroller")>=0?"S":"")+"><'dt-row dt-bottom-row'<'row'<'col-sm-6'"+(!1===s.amsDatatableInformation?"":"i")+"><'col-sm-6 text-right'p>>",o=s.amsDatatableSorting;if("string"==typeof o){var c=o.split(";");for(o=[],a=0;a<c.length;a++){var l=c[a].split(",");l[0]=parseInt(l[0]),o.push(l)}}var m,d=[],u=e("th",n).listattr("data-ams-datatable-sortable");for(a=0;a<u.length;a++){var h=u[a];void 0!==h?((m=d[a]||{}).bSortable="string"==typeof h?JSON.parse(h):h,d[a]=m):d[a]=d[a]||{}}var b=e("th",n).listattr("data-ams-datatable-stype");for(a=0;a<b.length;a++){var p=b[a];p?((m=d[a]||{}).sType=p,d[a]=m):d[a]=d[a]||{}}var f={bJQueryUI:!1,bServerSide:s.amsDatatableServerSide||!1,sAjaxSource:!0===s.amsDatatableServerSide?s.amsDatatableAjaxSource:void 0,sServerMethod:!0===s.amsDatatableServerSide?"POST":void 0,bFilter:!1!==s.amsDatatableGlobalFilter||i.indexOf("columnfilter")>=0,bPaginate:!1!==s.amsDatatablePagination,bInfo:!1!==s.amsDatatableInfo,bSort:!1!==s.amsDatatableSort,aaSorting:o,aoColumns:d.length>0?d:void 0,bDeferRender:!0,bAutoWidth:!1,iDisplayLength:s.amsDatatableDisplayLength||25,sPaginationType:s.amsDatatablePaginationType||"bootstrap_full",sDom:r,oLanguage:t.plugins&&t.plugins.i18n.datatables,fnInitComplete:function(a,n){e(".ColVis_Button").addClass("btn btn-default btn-sm").html((t.plugins&&t.plugins.i18n.datatables.sColumns||"Columns")+' <i class="fa fa-fw fa-caret-down"></i>')}},x=e.extend({},f,s.amsDatatableOptions),g=[],v=[],y=[];if(i.length>0)for(a=0;a<i.length;a++)switch(i[a]){case"autofill":g.push(e.fn.dataTable.AutoFill),v.push(t.baseURL+"ext/jquery-dataTables-autoFill"+t.devext+".js");break;case"columnfilter":g.push(e.fn.columnFilter),v.push(t.baseURL+"ext/jquery-dataTables-columnFilter"+t.devext+".js");break;case"colreorder":g.push(e.fn.dataTable.ColReorder),v.push(t.baseURL+"ext/jquery-dataTables-colReorder"+t.devext+".js");break;case"colreorderwithresize":g.push(window.ColReorder),v.push(t.baseURL+"ext/jquery-dataTables-colReorderWithResize"+t.devext+".js");break;case"colvis":g.push(e.fn.dataTable.ColVis),v.push(t.baseURL+"ext/jquery-dataTables-colVis"+t.devext+".js"),y.push((function(){x.oColVis=e.extend({},{activate:"click",sAlign:"right"},s.amsDatatableColvisOptions)}));break;case"editable":g.push(e.fn.editable),v.push(t.baseURL+"ext/jquery-jeditable"+t.devext+".js"),g.push(e.fn.makeEditable),v.push(t.baseURL+"ext/jquery-dataTables-editable"+t.devext+".js");break;case"fixedcolumns":g.push(e.fn.dataTable.FixedColumns),v.push(t.baseURL+"ext/jquery-dataTables-fixedColumns"+t.devext+".js");break;case"fixedheader":g.push(e.fn.dataTable.Fixedheader),v.push(t.baseURL+"ext/jquery-dataTables-fixedHeader"+t.devext+".js");break;case"keytable":g.push(window.keyTable),v.push(t.baseURL+"ext/jquery-dataTables-keyTable"+t.devext+".js");break;case"rowgrouping":g.push(e.fn.rowGrouping),v.push(t.baseURL+"ext/jquery-dataTables-rowGrouping"+t.devext+".js");break;case"rowreordering":g.push(e.fn.rowReordering),v.push(t.baseURL+"ext/jquery-dataTables-rowReordering"+t.devext+".js");break;case"scroller":g.push(e.fn.dataTable.Scroller),v.push(t.baseURL+"ext/jquery-dataTables-scroller"+t.devext+".js")}y.push((function(){x=t.executeFunctionByName(s.amsDatatableInitCallback,n,x)||x;try{var r=n.dataTable(x);if(t.executeFunctionByName(s.amsDatatableAfterInitCallback,n,r,x),i.length>0)for(a=0;a<i.length;a++)switch(i[a]){case"autofill":var o=e.extend({},s.amsDatatableAutofillOptions,x.autofill);o=t.executeFunctionByName(s.amsDatatableAutofillInitCallback,n,o)||o,n.data("ams-autofill",void 0===s.amsDatatableAutofillConstructor?new e.fn.dataTable.AutoFill(n,o):t.executeFunctionByName(s.amsDatatableAutofillConstructor,n,r,o));break;case"columnfilter":var c=e.extend({},{sPlaceHolder:"head:after"},s.amsDatatableColumnfilterOptions,x.columnfilter);c=t.executeFunctionByName(s.amsDatatableColumnfilterInitCallback,n,c)||c,n.data("ams-columnfilter",void 0===s.amsDatatableColumnfilterConstructor?r.columnFilter(c):t.executeFunctionByName(s.amsDatatableColumnfilterConstructor,n,r,c));break;case"editable":var l=e.extend({},s.amsDatatableEditableOptions,x.editable);l=t.executeFunctionByName(s.amsDatatableEditableInitCallback,n,l)||l,n.data("ams-editable",void 0===s.amsDatatableEditableConstructor?n.makeEditable(l):t.executeFunctionByName(s.amsDatatableEditableConstructor,n,r,l));break;case"fixedcolumns":var m=e.extend({},s.amsDatatableFixedcolumnsOptions,x.fixedcolumns);m=t.executeFunctionByName(s.amsDatatableFixedcolumnsInitCallback,n,m)||m,n.data("ams-fixedcolumns",void 0===s.amsDatatableFixedcolumnsConstructor?new e.fn.dataTable.FixedColumns(n,m):t.executeFunctionByName(s.amsDatatableFixedcolumnsConstructor,n,r,m));break;case"fixedheader":var d=e.extend({},s.amsDatatableFixedheaderOptions,x.fixedheader);d=t.executeFunctionByName(s.amsDatatableFixedheadeInitCallback,n,d)||d,n.data("ams-fixedheader",void 0===s.amsDatatableFixedheaderConstructor?new e.fn.dataTable.FixedHeader(n,d):t.executeFunctionByName(s.amsDatatableFixedheaderConstructor,n,r,d));break;case"keytable":var u={table:n.get(0),datatable:r},h=e.extend({},u,s.amsDatatableKeytableOptions,x.keytable);h=t.executeFunctionByName(s.amsDatatableKeytableInitCallback,n,h)||h,n.data("ams-keytable",void 0===s.amsDatatableKeytableConstructor?new KeyTable(h):t.executeFunctionByName(s.amsDatatableKeytableConstructor,n,r,h));break;case"rowgrouping":var b=e.extend({},s.amsDatatableRowgroupingOptions,x.rowgrouping);b=t.executeFunctionByName(s.amsDatatableRowgroupingInitCallback,n,b)||b,n.data("ams-rowgrouping",void 0===s.amsDatatableRowgroupingConstructor?n.rowGrouping(b):t.executeFunctionByName(s.amsDatatableRowgroupingConstructor,n,r,b));break;case"rowreordering":var p=e.extend({},s.amsDatatableRowreorderingOptions,x.rowreordering);p=t.executeFunctionByName(s.amsDatatableRowreorderingInitCallback,n,p)||p,n.data("ams-rowreordering",void 0===s.amsDatatableRowreorderingConstructor?n.rowReordering(p):t.executeFunctionByName(s.amsDatatableRowreorderingConstructor,n,r,p))}if(s.amsDatatableFinalizeCallback){var f=s.amsDatatableFinalizeCallback.split(/\s+/);if(f.length>0)for(a=0;a<f.length;a++)t.executeFunctionByName(f[a],n,r,x)}}catch(e){}})),t.ajax&&t.ajax.check(g,v,y)}))}))}))},tablednd:function(a){var n=e(".table-dnd",a);n.length>0&&t.ajax&&t.ajax.check(e.fn.tableDnD,t.baseURL+"ext/jquery-tablednd"+t.devext+".js",(function(){n.each((function(){var a=e(this),n=a.data();n.amsTabledndDragHandle?e("tr",a).addClass("no-drag-handle"):e(a).on("mouseover","tr",(function(){e(this.cells[0]).addClass("drag-handle")})).on("mouseout","tr",(function(){e(this.cells[0]).removeClass("drag-handle")}));var s={onDragClass:n.amsTabledndDragClass||"dragging-row",onDragStart:t.getFunctionByName(n.amsTabledndDragStart),dragHandle:n.amsTabledndDragHandle,scrollAmount:n.amsTabledndScrollAmount,onAllowDrop:n.amsTabledndAllowDrop,onDrop:t.getFunctionByName(n.amsTabledndDrop)||function(s,i){var r=n.amsTabledndDropTarget;if(r){e(i).data("ams-disabled-handlers","click");try{var o=[];e(s.rows).each((function(){var a=e(this).data("ams-element-name");a&&o.push(a)}));var c=t.getFunctionByName(r);if("function"==typeof c)c.call(a,s,o);else{if(!r.startsWith(window.location.protocol)){var l=n.amsLocation;l&&(r=l+"/"+r)}t.ajax&&t.ajax.post(r,{names:JSON.stringify(o)},(function(e,a){"success"!==e.status&&t.ajax.handleJSON(e)}))}}finally{setTimeout((function(){e(i).removeData("ams-disabled-handlers")}),50)}}return!1}},i=e.extend({},s,n.amsTabledndOptions);i=t.executeFunctionByName(n.amsTabledndInitCallback,a,i)||i;var r=a.tableDnD(i);t.executeFunctionByName(n.amsTabledndAfterInitCallback,a,r,i)}))}))},wizard:function(a){var n=e(".wizard",a);n.length>0&&t.ajax&&t.ajax.check(e.fn.bootstrapWizard,t.baseURL+"ext/bootstrap-wizard-1.4.2"+t.devext+".js",(function(){n.each((function(){var a=e(this),n=a.data(),s={withVisible:void 0===n.amsWizardWithVisible||n.amsWizardWithVisible,tabClass:n.amsWizardTabClass,firstSelector:n.amsWizardFirstSelector,previousSelector:n.amsWizardPreviousSelector,nextSelector:n.amsWizardNextSelector,lastSelector:n.amsWizardLastSelector,finishSelector:n.amsWizardFinishSelector,backSelector:n.amsWizardBackSelector,onInit:t.getFunctionByName(n.amsWizardInit),onShow:t.getFunctionByName(n.amsWizardShow),onNext:t.getFunctionByName(n.amsWizardNext),onPrevious:t.getFunctionByName(n.amsWizardPrevious),onFirst:t.getFunctionByName(n.amsWizardFirst),onLast:t.getFunctionByName(n.amsWizardLast),onBack:t.getFunctionByName(n.amsWizardBack),onFinish:t.getFunctionByName(n.amsWizardFinish),onTabChange:t.getFunctionByName(n.amsWizardTabChange),onTabClick:t.getFunctionByName(n.amsWizardTabClick),onTabShow:t.getFunctionByName(n.amsWizardTabShow)},i=e.extend({},s,n.amsWizardOptions);i=t.executeFunctionByName(n.amsWizardInitCallback,a,i)||i;var r=a.bootstrapWizard(i);t.executeFunctionByName(n.amsWizardAfterInitCallback,a,r,i)}))}))},tinymce:function(a){function n(){e(".tinymce",e(this)).each((function(){var a=tinymce.get(e(this).attr("id"));a&&a.remove()}))}var s=e(".tinymce",a);if(s.length>0){var i=t.baseURL+"ext/tinymce"+(t.devmode?"/dev":"");t.ajax&&t.ajax.check(window.tinymce,i+"/tinymce"+t.devext+".js",(function(a){function r(){s.each((function(){var a=e(this),n=a.data(),s={theme:n.amsTinymceTheme||"modern",language:t.lang,menubar:!1!==n.amsTinymceMenubar,statusbar:!1!==n.amsTinymceStatusbar,plugins:n.amsTinymcePlugins||["advlist autosave autolink lists link charmap print preview hr anchor pagebreak","searchreplace wordcount visualblocks visualchars code fullscreen","insertdatetime nonbreaking save table contextmenu directionality","emoticons paste textcolor colorpicker textpattern autoresize"],toolbar:n.amsTinymceToolbar,toolbar1:!1!==n.amsTinymceToolbar1&&(n.amsTinymceToolbar1||"undo redo | pastetext | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent"),toolbar2:!1!==n.amsTinymceToolbar2&&(n.amsTinymceToolbar2||"forecolor backcolor emoticons | charmap link image media | fullscreen preview print | code"),content_css:n.amsTinymceContentCss,formats:n.amsTinymceFormats,style_formats:n.amsTinymceStyleFormats,block_formats:n.amsTinymceBlockFormats,valid_classes:n.amsTinymceValidClasses,image_advtab:!0,image_list:t.getFunctionByName(n.amsTinymceImageList)||n.amsTinymceImageList,image_class_list:n.amsTinymceImageClassList,link_list:t.getFunctionByName(n.amsTinymceLinkList)||n.amsTinymceLinkList,link_class_list:n.amsTinymceLinkClassList,paste_as_text:void 0===n.amsTinymcePasteAsText||n.amsTinymcePasteAsText,paste_auto_cleanup_on_paste:void 0===n.amsTinymcePasteAutoCleanup||n.amsTinymcePasteAutoCleanup,paste_strip_class_attributes:n.amsTinymcePasteStripClassAttributes||"all",paste_remove_spans:void 0===n.amsTinymcePaseRemoveSpans||n.amsTinymcePasteRemoveSpans,paste_remove_styles:void 0===n.amsTinymcePasteRemoveStyles||n.amsTinymcePasteRemoveStyles,height:n.amsTinymceHeight||50,min_height:50,resize:!0,autoresize_min_height:50,autoresize_max_height:500};if(n.amsTinymceExternalPlugins){var i=n.amsTinymceExternalPlugins.split(/\s+/);for(var r in i)if(i.hasOwnProperty(r)){var o=a.data("ams-tinymce-plugin-"+i[r]);tinymce.PluginManager.load(i[r],t.getSource(o))}}var c=e.extend({},s,n.amsTinymceOptions);c=t.executeFunctionByName(n.amsTinymceInitCallback,a,c)||c;var l=a.tinymce(c);t.executeFunctionByName(n.amsTinymceAfterInitCallback,a,l,c)}))}a?t.getScript(i+"/jquery.tinymce"+t.devext+".js",(function(){tinymce.baseURL=i,tinymce.suffix=t.devext,t.skin&&t.skin.registerCleanCallback(n),r()})):r()}))}},editor:function(n){var s=e(".text-editor textarea",n);s.length>0&&t.ajax&&t.ajax.check(a.ace,t.baseURL+"ext/ace/ace.js",(function(n){var i=function(){a.ace_loaded=!0,s.each((function(){var a=e(this),n=a.parents(".text-editor"),s=n.data(),i=ace.require("ace/ext/modelist"),r=s.amsEditorMode||i.getModeForPath(s.amsEditorFilename||"editor.txt").mode,o=e("<div>",{position:"absolute",width:a.width(),height:a.height(),class:a.attr("class")}).insertBefore(a);a.css("display","none");var c=ace.edit(o[0]),l={mode:r,tabSize:4,useSoftTabs:!1,showGutter:!0,showLineNumbers:!0,printMargin:132,showInvisibles:!0},m=e.extend({},l,s.amsEditorOptions);m=t.executeFunctionByName(s.amsEditorInitCallback,a,m)||m,c.setOptions(m),c.session.setValue(a.val()),c.session.on("change",(function(){a.val(c.session.getValue())})),n.data("editor",c),t.executeFunctionByName(s.amsEditorAfterInitCallback,a,c,m)}))};n?(ace.config.set("basePath",t.baseURL+"ext/ace"),t.ajax.check(a.ace_loaded,[t.baseURL+"ext/ace/ext-modelist.js"],i)):i()}))},imgareaselect:function(a){var n=e(".imgareaselect",a);n.length>0&&t.ajax&&t.ajax.check(e.fn.imgAreaSelect,t.baseURL+"ext/jquery-imgareaselect-0.9.11-rc1"+t.devext+".js",(function(){t.getCSS(t.baseURL+"../css/ext/jquery-imgareaselect"+t.devext+".css","jquery-imgareaselect",(function(){n.each((function(){var a=e(this),n=a.data(),s=n.amsImgareaselectParent?a.parents(n.amsImgareaselectParent):"body",i={instance:!0,handles:!0,parent:s,x1:n.amsImgareaselectX1||0,y1:n.amsImgareaselectY1||0,x2:n.amsImgareaselectX2||n.amsImgareaselectImageWidth,y2:n.amsImgareaselectY2||n.amsImgareaselectImageHeight,imageWidth:n.amsImgareaselectImageWidth,imageHeight:n.amsImgareaselectImageHeight,minWidth:128,minHeight:128,aspectRatio:n.amsImgareaselectRatio,onSelectEnd:t.getFunctionByName(n.amsImgareaselectSelectEnd)||function(a,t){var i=n.amsImgareaselectTargetField||"image_";e('input[name="'+i+'x1"]',s).val(t.x1),e('input[name="'+i+'y1"]',s).val(t.y1),e('input[name="'+i+'x2"]',s).val(t.x2),e('input[name="'+i+'y2"]',s).val(t.y2)}},r=e.extend({},i,n.amsImgareaselectOptions);r=t.executeFunctionByName(n.amsImgareaselectInitCallback,a,r)||r;var o=a.imgAreaSelect(r);t.executeFunctionByName(n.amsImgareaselectAfterInitCallback,a,o,r),setTimeout((function(){o.update()}),250)}))}))}))},fancybox:function(a){var n=e(".fancybox",a);n.length>0&&t.ajax&&t.ajax.check(e.fn.fancybox,t.baseURL+"ext/jquery-fancybox-2.1.5"+t.devext+".js",(function(){t.getCSS(t.baseURL+"../css/ext/jquery-fancybox-2.1.5"+t.devext+".css","jquery-fancybox",(function(){n.each((function(){var a,n=e(this),s=n.data(),i=n;s.amsFancyboxElements&&(i=e(s.amsFancyboxElements,n));var r=(s.amsFancyboxHelpers||"").split(/\s+/);if(r.length>0)for(a=0;a<r.length;a++)switch(r[a]){case"buttons":t.ajax&&t.ajax.check(e.fancybox.helpers.buttons,t.baseURL+"ext/fancybox-helpers/fancybox-buttons"+t.devext+".js");break;case"thumbs":t.ajax&&t.ajax.check(e.fancybox.helpers.thumbs,t.baseURL+"ext/fancybox-helpers/fancybox-thumbs"+t.devext+".js");break;case"media":t.ajax&&t.ajax.check(e.fancybox.helpers.media,t.baseURL+"ext/fancybox-helpers/fancybox-media"+t.devext+".js")}var o={type:s.amsFancyboxType,padding:s.amsFancyboxPadding||10,margin:s.amsFancyboxMargin||10,loop:s.amsFancyboxLoop,beforeLoad:t.getFunctionByName(s.amsFancyboxBeforeLoad)||function(){var a;if(s.amsFancyboxTitleGetter&&(a=t.executeFunctionByName(s.amsFancyboxTitleGetter,this)),!a){var n=e("*:first",this.element);(a=n.attr("original-title")||n.attr("title"))||(a=e(this.element).attr("original-title")||e(this.element).attr("title"))}this.title=a},afterLoad:t.getFunctionByName(s.amsFancyboxAfterLoad),helpers:{title:{type:"inside"}}};if(r.length>0)for(a=0;a<r.length;a++)switch(r[a]){case"buttons":o.helpers.buttons={position:s.amsFancyboxButtonsPosition||"top"};break;case"thumbs":o.helpers.thumbs={width:s.amsFancyboxThumbsWidth||50,height:s.amsFancyboxThumbsHeight||50};break;case"media":o.helpers.media=!0}var c=e.extend({},o,s.amsFancyboxOptions);c=t.executeFunctionByName(s.amsFancyboxInitCallback,n,c)||c;var l=i.fancybox(c);t.executeFunctionByName(s.amsFancyboxAfterInitCallback,n,l,c)}))}))}))},chart:function(a){var n=e(".chart",a);n.length>0&&t.ajax&&t.ajax.check([window.Flot,e.color],[t.baseURL+"ext/flot/jquery.canvaswrapper"+t.devext+".js",t.baseURL+"ext/flot/jquery.colorhelpers"+t.devext+".js"],(function(){t.ajax.check(e.plot,t.baseURL+"ext/flot/jquery.flot"+t.devext+".js",(function(){var a=new Set;function s(a){for(var t in e.plot.plugins)if(e.plot.plugins.hasOwnProperty(t)){var n=e.plot.plugins[t];if(n.name===a)return n}return null}n.each((function(){var t=(e(this).data().amsChartPlugins||"").split(/\s+/);e.each(t,(function(e,t){a.add(t)}))}));var i=[];for(var r of a.values())s(r)||i.push(t.getScript(t.baseURL+"ext/flot/jquery.flot."+r+t.devext+".js"));e.when.apply(e,i).then((function(){n.each((function(){var a=e(this),n=a.data();function s(e,s){e=t.executeFunctionByName(n.amsChartInitData,a,e)||e;var i=a.plot(e,s);t.executeFunctionByName(n.amsChartAfterInitCallback,a,i,s)}var i=e.extend({},{},n.amsChartOptions);i=t.executeFunctionByName(n.amsChartInitCallback,a,i)||i;var r=n.amsChartData,o=n.amsChartDataLoader;o?e.getJSON(o,r).done((function(a){i=e.extend({},i,a.settings),s(a.data,i)})):s(r,i)}))}))}))}))},graphs:function(a){var n=e(".sparkline",a);n.length>0&&t.ajax&&t.ajax.check(t.graphs,t.baseURL+"myams-graphs"+t.devext+".js",(function(){t.graphs.init(n)}))},scrollbars:function(a){var n=e(".scrollbar",a);n.length>0&&t.ajax&&t.ajax.check(e.event.special.mousewheel,t.baseURL+"ext/jquery-mousewheel.min.js",(function(){t.ajax.check(e.fn.mCustomScrollbar,t.baseURL+"ext/jquery-mCustomScrollbar"+t.devext+".js",(function(){t.getCSS(t.baseURL+"../css/ext/jquery-mCustomScrollbar.css","jquery-mCustomScrollbar",(function(){n.each((function(){var a=e(this),n=a.data(),s={theme:n.amsScrollbarTheme||"light"},i=e.extend({},s,n.amsScrollbarOptions);i=t.executeFunctionByName(n.amsScrollbarInitCallback,a,i)||i;var r=a.mCustomScrollbar(i);t.executeFunctionByName(n.amsScrollbarAfterInitCallback,a,r,i)}))}))}))}))}})}(jQuery,this);