# HG changeset patch # User Thierry Florac # Date 1542701371 -3600 # Node ID c86acac9dff5b98b03315fa7231fb2e7c0e4abe0 # Parent 0a21be6342aa336e70e75b2a49b8f7d048112c8e Version 0.1.27 diff -r 0a21be6342aa -r c86acac9dff5 .installed.cfg --- a/.installed.cfg Mon Nov 19 15:20:20 2018 +0100 +++ b/.installed.cfg Tue Nov 20 09:09:31 2018 +0100 @@ -122,3 +122,27 @@ [buildout] parts = package i18n pyflakes test + +[buildout] +installed_develop_eggs = /home/tflorac/Dropbox/src/PyAMS/pyams_skin/develop-eggs/pyams-file.egg-link + /home/tflorac/Dropbox/src/PyAMS/pyams_skin/develop-eggs/lingua.egg-link + /home/tflorac/Dropbox/src/PyAMS/pyams_skin/develop-eggs/pyams-template.egg-link + /home/tflorac/Dropbox/src/PyAMS/pyams_skin/develop-eggs/pyams-skin.egg-link + /home/tflorac/Dropbox/src/PyAMS/pyams_skin/develop-eggs/pyams-pagelet.egg-link + /home/tflorac/Dropbox/src/PyAMS/pyams_skin/develop-eggs/pyams-viewlet.egg-link + /home/tflorac/Dropbox/src/PyAMS/pyams_skin/develop-eggs/pyams-i18n.egg-link + /home/tflorac/Dropbox/src/PyAMS/pyams_skin/develop-eggs/pyams-catalog.egg-link + /home/tflorac/Dropbox/src/PyAMS/pyams_skin/develop-eggs/pyams-form.egg-link + /home/tflorac/Dropbox/src/PyAMS/pyams_skin/develop-eggs/pyams-utils.egg-link + +[buildout] +parts = i18n pyflakes test package + +[buildout] +parts = pyflakes test package i18n + +[buildout] +parts = test package i18n pyflakes + +[buildout] +parts = package i18n pyflakes test diff -r 0a21be6342aa -r c86acac9dff5 buildout.cfg --- a/buildout.cfg Mon Nov 19 15:20:20 2018 +0100 +++ b/buildout.cfg Tue Nov 20 09:09:31 2018 +0100 @@ -80,4 +80,4 @@ eggs = pyams_skin [test] [versions] -pyams_skin = 0.1.26 +pyams_skin = 0.1.27 diff -r 0a21be6342aa -r c86acac9dff5 setup.py --- a/setup.py Mon Nov 19 15:20:20 2018 +0100 +++ b/setup.py Tue Nov 20 09:09:31 2018 +0100 @@ -25,7 +25,7 @@ README = os.path.join(DOCS, 'README.txt') HISTORY = os.path.join(DOCS, 'HISTORY.txt') -version = '0.1.26' +version = '0.1.27' long_description = open(README).read() + '\n\n' + open(HISTORY).read() tests_require = [] diff -r 0a21be6342aa -r c86acac9dff5 src/pyams_skin.egg-info/PKG-INFO --- a/src/pyams_skin.egg-info/PKG-INFO Mon Nov 19 15:20:20 2018 +0100 +++ b/src/pyams_skin.egg-info/PKG-INFO Tue Nov 20 09:09:31 2018 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: pyams-skin -Version: 0.1.26 +Version: 0.1.27 Summary: PyAMS base skin interfaces and classes Home-page: http://hg.ztfy.org/pyams/pyams_skin Author: Thierry Florac diff -r 0a21be6342aa -r c86acac9dff5 src/pyams_skin.egg-info/SOURCES.txt --- a/src/pyams_skin.egg-info/SOURCES.txt Mon Nov 19 15:20:20 2018 +0100 +++ b/src/pyams_skin.egg-info/SOURCES.txt Tue Nov 20 09:09:31 2018 +0100 @@ -468,6 +468,8 @@ src/pyams_skin/resources/js/myams-menus.min.js src/pyams_skin/resources/js/myams-notify.js src/pyams_skin/resources/js/myams-notify.min.js +src/pyams_skin/resources/js/myams-plugins-loader.js +src/pyams_skin/resources/js/myams-plugins-loader.min.js src/pyams_skin/resources/js/myams-plugins.js src/pyams_skin/resources/js/myams-plugins.min.js src/pyams_skin/resources/js/myams-skin.js diff -r 0a21be6342aa -r c86acac9dff5 src/pyams_skin/resources/js/myams-ajax.min.js --- a/src/pyams_skin/resources/js/myams-ajax.min.js Mon Nov 19 15:20:20 2018 +0100 +++ b/src/pyams_skin/resources/js/myams-ajax.min.js Tue Nov 20 09:09:31 2018 +0100 @@ -1,1 +1,1 @@ -!function(e,t){var o=t.MyAMS,n=o;o.ajax={check:function(t,o,a,s){function i(e,t){if(void 0!==a){a instanceof Array||(a=[a]);for(var o=0;o0?e.when.apply(e,l).then(function(){i(!0,s)}):i(!1,s)}else void 0===t?"string"==typeof o&&n.getScript(o,function(){i(!0,s)},c):i(!1,s)},getAddr:function(t){var o=t||e("HTML HEAD BASE").attr("href")||window.location.href;return o.substr(0,o.lastIndexOf("/")+1)},start:function(){e("#ajax-gear").show()},stop:function(){e("#ajax-gear").hide()},progress:function(e){e.lengthComputable&&(e.loaded>=e.total||console&&console.log&&console.log(parseInt(e.loaded/e.total*100,10)+"%"))},getJSON:function(){return function(e){var t=e.url;delete e.url,n.ajax.post(t,e,function(e,t,o){n.ajax.handleJSON(e)})}},post:function(o,a,s,i){var r;r=o.startsWith(window.location.protocol)?o:this.getAddr()+o,"function"==typeof s?(i=s,s={}):s||(s={}),void 0===i&&(i=s.callback),"string"==typeof i&&(i=n.getFunctionByName(i)),delete s.callback;var c,l={url:r,type:"post",cache:!1,async:"function"==typeof i,data:e.param(a),dataType:"json",beforeSend:function(e,o){if(void 0!==t.Cookies){var a=Cookies.get(n.csrfCookieName);a&&e.setRequestHeader(n.csrfHeaderName,a)}},success:i||function(e){c=e.result}},f=e.extend({},l,s);return e.ajax(f),c},getResponse:function(e){var t,o,a=e.getResponseHeader("content-type");if(a)if(a.startsWith("application/javascript"))t="script",o=e.responseText;else if(a.startsWith("text/html"))t="html",o=e.responseText;else if(a.startsWith("text/xml"))t="xml",o=e.responseText;else if(o=e.responseJSON)t="json";else try{o=JSON.parse(e.responseText),t="json"}catch(n){o=e.responseText,t="text"}else t="json",o={status:"alert",alert:{title:n.i18n.ERROR_OCCURED,content:n.i18n.NO_SERVER_RESPONSE}};return{contentType:t,data:o}},handleJSON:function(o,a,s){var i,r=o.status;switch(r){case"alert":t.alert&&t.alert(o.alert.title+"\n\n"+o.alert.content);break;case"error":n.form.showErrors(a,o);break;case"info":case"success":void 0!==a&&(n.form.resetChanged(a),!1!==o.close_form&&n.dialog.close(a));break;case"message":case"messagebox":break;case"notify":case"callback":case"callbacks":void 0!==a&&(n.form.resetChanged(a),!1!==o.close_form&&n.dialog.close(a));break;case"modal":n.dialog.open(o.location);break;case"reload":void 0!==a&&(n.form.resetChanged(a),!1!==o.close_form&&n.dialog.close(a)),(i=o.location||window.location.hash).startsWith("#")&&(i=i.substr(1));var c=e(o.target||s||"#content");n.skin.loadURL(i,c,{preLoadCallback:n.getFunctionByName(o.pre_reload)||function(){e("[data-ams-pre-reload]",c).each(function(){n.executeFunctionByName(e(this).data("ams-pre-reload"))})},preLoadCallbackOptions:o.pre_reload_options,afterLoadCallback:n.getFunctionByName(o.post_reload)||function(){e("[data-ams-post-reload]",c).each(function(){n.executeFunctionByName(e(this).data("ams-post-reload"))})},afterLoadCallbackOptions:o.post_reload_options});break;case"redirect":void 0!==a&&(n.form.resetChanged(a),!0===o.close_form&&n.dialog.close(a)),(i=o.location||window.location.href).endsWith("##")&&(i=i.replace(/##/,window.location.hash)),o.window?window.open(i,o.window,o.options):window.location.href===i?window.location.reload(!0):window.location.href=i;break;default:console&&console.log&&console.log("Unhandled status: "+r)}var l,f,d;if(o.content&&(f=o.content,d=e(f.target||s||a||"#content"),!0===f.raw?d.text(f.text):(d.html(f.html),n.initContent(d)),f.keep_hidden||d.removeClass("hidden")),o.contents){var u=o.contents;for(l=0;l=e.total||console&&console.log&&console.log(parseInt(e.loaded/e.total*100,10)+"%"))},getJSON:function(){return function(e){var t=e.url;delete e.url,h.ajax.post(t,e,function(e,t,o){h.ajax.handleJSON(e)})}},post:function(e,t,o,n){var a,s;a=e.startsWith(window.location.protocol)?e:this.getAddr()+e,"function"==typeof o?(n=o,o={}):o||(o={}),void 0===n&&(n=o.callback),"string"==typeof n&&(n=h.getFunctionByName(n)),delete o.callback;var i={url:a,type:"post",cache:!1,async:"function"==typeof n,data:p.param(t),dataType:"json",beforeSend:function(e,t){if(void 0!==g.Cookies){var o=Cookies.get(h.csrfCookieName);o&&e.setRequestHeader(h.csrfHeaderName,o)}},success:n||function(e){s=e.result}},r=p.extend({},i,o);return p.ajax(r),s},getResponse:function(t){var o,n,e=t.getResponseHeader("content-type");if(e)if(e.startsWith("application/javascript"))o="script",n=t.responseText;else if(e.startsWith("text/html"))o="html",n=t.responseText;else if(e.startsWith("text/xml"))o="xml",n=t.responseText;else if(n=t.responseJSON)o="json";else try{n=JSON.parse(t.responseText),o="json"}catch(e){n=t.responseText,o="text"}else o="json",n={status:"alert",alert:{title:h.i18n.ERROR_OCCURED,content:h.i18n.NO_SERVER_RESPONSE}};return{contentType:o,data:n}},handleJSON:function(e,t,o){var n,a,s,i,r,c,l,f=e.status;switch(f){case"alert":g.alert&&g.alert(e.alert.title+"\n\n"+e.alert.content);break;case"error":h.form.showErrors(t,e);break;case"info":case"success":void 0!==t&&(h.form.resetChanged(t),!1!==e.close_form&&h.dialog.close(t));break;case"message":case"messagebox":break;case"notify":case"callback":case"callbacks":void 0!==t&&(h.form.resetChanged(t),!1!==e.close_form&&h.dialog.close(t));break;case"modal":h.dialog.open(e.location);break;case"reload":void 0!==t&&(h.form.resetChanged(t),!1!==e.close_form&&h.dialog.close(t)),(n=e.location||window.location.hash).startsWith("#")&&(n=n.substr(1));var d=p(e.target||o||"#content");h.skin.loadURL(n,d,{preLoadCallback:h.getFunctionByName(e.pre_reload)||function(){p("[data-ams-pre-reload]",d).each(function(){h.executeFunctionByName(p(this).data("ams-pre-reload"))})},preLoadCallbackOptions:e.pre_reload_options,afterLoadCallback:h.getFunctionByName(e.post_reload)||function(){p("[data-ams-post-reload]",d).each(function(){h.executeFunctionByName(p(this).data("ams-post-reload"))})},afterLoadCallbackOptions:e.post_reload_options});break;case"redirect":void 0!==t&&(h.form.resetChanged(t),!0===e.close_form&&h.dialog.close(t)),(n=e.location||window.location.href).endsWith("##")&&(n=n.replace(/##/,window.location.hash)),e.window?window.open(n,e.window,e.options):window.location.href===n?window.location.reload(!0):window.location.href=n;break;default:console&&console.log&&console.log("Unhandled status: "+f)}if(e.content&&(s=e.content,i=p(s.target||o||t||"#content"),!0===s.raw?i.text(s.text):(i.html(s.html),h.initContent(i)),s.keep_hidden||i.removeClass("hidden")),e.contents){var u=e.contents;for(a=0;a
'),"string"==typeof g)h={},m=g;else{h=g.data(),m=g.attr("href")||h.amsUrl;var e=p.getFunctionByName(m);"function"==typeof e&&(m=e.call(g))}m&&(v("body").modalmanager("loading"),0===m.indexOf("#")?v(m).modal("show"):v.ajax({url:m,type:"get",cache:void 0!==h.amsAllowCache&&h.amsAllowCache,data:o,success:function(a,e,o){v("body").modalmanager("removeLoading");var l=p.ajax.getResponse(o),t=l.contentType,s=l.data;switch(t){case"json":p.ajax.handleJSON(s,v(v(g).data("ams-json-target")||"#content"));break;case"script":case"xml":break;case"html":case"text":default:var d=v(s),i=v(".modal-dialog",d.wrap("
").parent()),n=i.data(),c={backdrop:"static",overflow:n.amsModalOverflow||".modal-viewport",maxHeight:void 0===n.amsModalMaxHeight?function(){return v(window).height()-v(".modal-header",d).outerHeight(!0)-v("footer",d).outerHeight(!0)-85}:p.getFunctionByName(n.amsModalMaxHeight)},r=v.extend({},c,n.amsModalOptions);r=p.executeFunctionByName(n.amsModalInitCallback,i,r)||r,f&&(f.shown&&p.dialog.registerShownCallback(f.shown,d),f.hide&&p.dialog.registerHideCallback(f.hide,d)),v("
").addClass("modal fade").append(d).modal(r).on("shown",p.dialog.shown).on("hidden",p.dialog.hidden),p.initContent(d),!1!==h.amsLogEvent&&p.stats.logPageview(m)}}}))})})},shown:function(a){function e(a){var e=v(".scrollmarker.top",t),o=t.scrollTop();0=t.get(0).scrollHeight?l.hide():l.show()}var o,l=a.target,t=v(".modal-viewport",l);if(t.exists()){var s=parseInt(t.css("max-height")),d=v.scrollbarWidth();"hidden"!==t.css("overflow")&&t.height()===s?(v("
").addClass("scrollmarker").addClass("top").css("top",0).css("width",t.width()-d).hide().appendTo(t),v("
").addClass("scrollmarker").addClass("bottom").css("top",s-20).css("width",t.width()-d).appendTo(t),t.scroll(e),t.off("resize").on("resize",e)):v(".scrollmarker",t).remove()}v("[data-ams-shown-callback]",l).each(function(){var a=p.getFunctionByName(v(this).data("ams-shown-callback"));a&&a.call(l,this)});var i=v(".modal-dialog",l).data("shown-callbacks");if(i)for(o=0;o
');var d,i;if("string"==typeof e)d={},i=e;else{d=e.data(),i=e.attr("href")||d.amsUrl;var n=l.getFunctionByName(i);"function"==typeof n&&(i=n.call(e))}i&&(a("body").modalmanager("loading"),0===i.indexOf("#")?a(i).modal("show"):a.ajax({url:i,type:"get",cache:void 0!==d.amsAllowCache&&d.amsAllowCache,data:o,success:function(o,s,n){a("body").modalmanager("removeLoading");var c=l.ajax.getResponse(n),r=c.contentType,h=c.data;switch(r){case"json":l.ajax.handleJSON(h,a(a(e).data("ams-json-target")||"#content"));break;case"script":case"xml":break;case"html":case"text":default:var m=a(h),g=a(".modal-dialog",m.wrap("
").parent()),f=g.data()||{},v={backdrop:"static",overflow:f.amsModalOverflow||".modal-viewport",maxHeight:void 0===f.amsModalMaxHeight?function(){return a(window).height()-a(".modal-header",m).outerHeight(!0)-a("footer",m).outerHeight(!0)-85}:l.getFunctionByName(f.amsModalMaxHeight)},p=a.extend({},v,f.amsModalOptions);p=l.executeFunctionByName(f.amsModalInitCallback,g,p)||p,t&&(t.shown&&l.dialog.registerShownCallback(t.shown,m),t.hide&&l.dialog.registerHideCallback(t.hide,m)),a("
").addClass("modal fade").append(m).modal(p).on("shown",l.dialog.shown).on("hidden",l.dialog.hidden),l.initContent(m),!1!==d.amsLogEvent&&l.stats.logPageview(i)}}}))})})},shown:function(e){function o(e){var o=a(".scrollmarker.top",s),l=s.scrollTop();l>0?o.show():o.hide();var t=a(".scrollmarker.bottom",s);d+l>=s.get(0).scrollHeight?t.hide():t.show()}var t=e.target,s=a(".modal-viewport",t);if(s.exists()){var d=parseInt(s.css("max-height")),i=a.scrollbarWidth();"hidden"!==s.css("overflow")&&s.height()===d?(a("
").addClass("scrollmarker").addClass("top").css("top",0).css("width",s.width()-i).hide().appendTo(s),a("
").addClass("scrollmarker").addClass("bottom").css("top",d-20).css("width",s.width()-i).appendTo(s),s.scroll(o),s.off("resize").on("resize",o)):a(".scrollmarker",s).remove()}a("[data-ams-shown-callback]",t).each(function(){var e=l.getFunctionByName(a(this).data("ams-shown-callback"));e&&e.call(t,this)});var n,c=a(".modal-dialog",t).data("shown-callbacks");if(c)for(n=0;n=0&&o.hide()}},hidden:function(e){var o=e.target;l.skin.cleanContainer(o),a("[data-ams-hidden-callback]",o).each(function(){var e=l.getFunctionByName(a(this).data("ams-hidden-callback"));e&&e.call(o,this)});var t,s=a(".modal-dialog",o).data("hide-callbacks");if(s)for(t=0;t=0)){var m=n.plugins.enabled[l];if(m)switch(typeof m){case"function":m(a);break;default:for(var d=0;d=0)console&&console.warn&&console.warn("Plugin "+a+" is already registered!");else if("object"==typeof e){var s=e.src;s?n.ajax.check(e.callback,s,function(s){s&&(n.plugins.enabled[a]=n.getFunctionByName(e.callback),e.css&&n.getCSS(e.css,a+"_css"),t&&n.executeFunctionByName(t))}):(n.plugins.enabled[a]=n.getFunctionByName(e.callback),e.css&&n.getCSS(e.css,a+"_css"),t&&n.executeFunctionByName(t))}else"function"==typeof e&&(n.plugins.enabled[a]=e,t&&n.executeFunctionByName(t))},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 t=e(".hint:not(:parents(.nohints))",a);t.length>0&&n.ajax.check(e.fn.tipsy,n.baseURL+"ext/jquery-tipsy"+n.devext+".js",function(){n.getCSS(n.baseURL+"../css/ext/jquery-tipsy"+n.devext+".css","jquery-tipsy",function(){t.each(function(){var a=e(this),t=a.data(),s={html:void 0===t.amsHintHtml?(a.attr("title")||"").startsWith("<"):t.amsHintHtml,title:n.getFunctionByName(t.amsHintTitleGetter)||function(){var a=e(this),n=a.attr("original-title")||a.attr(t.amsHintTitleAttr||"title")||(t.amsHintHtml?a.html():a.text());return n=n.replace(/\?_="/,"?_="+(new Date).getTime()+'"')},opacity:t.amsHintOpacity||.95,gravity:t.amsHintGravity||"sw",offset:t.amsHintOffset||0},i=e.extend({},s,t.amsHintOptions);i=n.executeFunctionByName(t.amsHintInitCallback,a,i)||i;var r=a.tipsy(i);n.executeFunctionByName(t.amsHintAfterInitCallback,a,r,i)})})})},contextMenu:function(a){var t=e(".context-menu",a);t.length>0&&t.each(function(){var a=e(this),t=a.data(),s={menuSelector:t.amsContextmenuSelector,menuSelected:n.helpers.contextMenuHandler},i=e.extend({},s,t.amsContextmenuOptions);i=n.executeFunctionByName(t.amsContextmenuInitCallback,a,i)||i;var r=a.contextMenu(i);n.executeFunctionByName(t.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('').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),t=a.parent("fieldset"),s=a.data();if(!s.amsChecker){var i=e(''),r=s.amsCheckerFieldname||"checker_"+n.generateId(),c=r.replace(/\./,"_"),o=s.amsCheckerHiddenPrefix,l=null,m=s.amsCheckerHiddenValueOn||"true",d=s.amsCheckerHiddenValueOff||"false",u=s.amsCheckerMarker||!1;o?l=e('').attr("name",o+r).val("on"===s.amsCheckerState?m:d).prependTo(a):u&&e('').attr("name",u).attr("value",1).prependTo(a);var b=e('').attr("name",r).attr("id",c).data("ams-checker-hidden-input",l).data("ams-checker-init",!0).val(s.amsCheckerValue||!0).attr("checked","on"===s.amsCheckerState?"checked":null);s.amsCheckerReadonly?b.attr("disabled","disabled"):b.on("change",function(i){i.preventDefault();var r={},c=e(this).is(":checked");if(a.trigger("ams.checker.before-switch",[a,r]),r.veto)e(this).prop("checked",!c);else if(n.executeFunctionByName(s.amsCheckerChangeHandler,a,c),!s.amsCheckerCancelDefault){var o=b.data("ams-checker-hidden-input");c?("disable"===s.amsCheckerMode?(t.removeAttr("disabled"),e(".select2",t).removeAttr("disabled")):t.removeClass("switched"),o&&o.val(m),e("[data-required]",t).attr("required","required"),a.trigger("ams.checker.opened",[a])):("disable"===s.amsCheckerMode?(t.prop("disabled","disabled"),e(".select2",t).attr("disabled","disabled")):t.addClass("switched"),o&&o.val(d),e("[data-required]",t).removeAttr("required"),a.trigger("ams.checker.closed",[a]))}}),b.appendTo(i),e(">label",a).attr("for",b.attr("id")),i.append("").prependTo(a);var h=e("[required]",t);h.attr("data-required",!0),"on"===s.amsCheckerState?b.attr("checked",!0):("disable"===s.amsCheckerMode?(t.attr("disabled","disabled"),e(".select2",t).attr("disabled","disabled")):t.addClass("switched"),h.removeAttr("required")),a.data("ams-checker","on")}})},slider:function(a){var t=e(".slider",a);t.length>0&&n.ajax.check(e.fn.slider,n.baseURL+"ext/bootstrap-slider-2.0.0"+n.devext+".js",function(){t.each(function(){var a=e(this),t=a.data(),s=e.extend({},{},a.data.amsSliderOptions);s=n.executeFunctionByName(t.amsSliderInitCallback,a,s)||s;var i=a.slider(s);n.executeFunctionByName(t.amsSliderAfterInitCallback,a,i,s)})})},draggable:function(a){var t=e(".draggable",a);t.length>0&&t.each(function(){var a=e(this),t=a.data(),s={cursor:t.amsDraggableCursor||"move",containment:t.amsDraggableContainment,handle:t.amsDraggableHandle,connectToSortable:t.amsDraggableConnectSortable,helper:n.getFunctionByName(t.amsDraggableHelper)||t.amsDraggableHelper,start:n.getFunctionByName(t.amsDraggableStart),stop:n.getFunctionByName(t.amsDraggableStop)},i=e.extend({},s,t.amsDraggableOptions);i=n.executeFunctionByName(t.amsDraggableInitCallback,a,i)||i;var r=a.draggable(i);a.disableSelection(),n.executeFunctionByName(t.amsDraggableAfterInitCallback,a,r,i)})},droppable:function(a){var t=e(".droppable",a);t.length>0&&t.each(function(){var a=e(this),t=a.data(),s={accept:t.amsdroppableAccept,drop:n.getFunctionByName(t.amsDroppableDrop)},i=e.extend({},s,t.amsDroppableOptions);i=n.executeFunctionByName(t.amsDroppableInitCallback,a,i)||i;var r=a.droppable(i);n.executeFunctionByName(t.amsDroppableAfterInitCallback,a,r,i)})},sortable:function(a){var t=e(".sortable",a);t.length>0&&t.each(function(){var a=e(this),t=a.data(),s={items:t.amsSortableItems,handle:t.amsSortableHandle,helper:t.amsSortableHelper,connectWith:t.amsSortableConnectwith,start:n.getFunctionByName(t.amsSortableStart),over:n.getFunctionByName(t.amsSortableOver),containment:t.amsSortableContainment,placeholder:t.amsSortablePlaceholder,stop:n.getFunctionByName(t.amsSortableStop)},i=e.extend({},s,t.amsSortableOptions);i=n.executeFunctionByName(t.amsSortableInitCallback,a,i)||i;var r=a.sortable(i);a.disableSelection(),n.executeFunctionByName(t.amsSortableAfterInitCallback,a,r,i)})},resizable:function(a){var t=e(".resizable",a);t.length>0&&t.each(function(){var a=e(this),t=a.data(),s={autoHide:!1===t.amsResizableAutohide||t.amsResizableAutohide,containment:t.amsResizableContainment,grid:t.amsResizableGrid,handles:t.amsResizableHandles,start:n.getFunctionByName(t.amsResizableStart),stop:n.getFunctionByName(t.amsResizableStop)},i=e.extend({},s,t.amsResizableOptions);i=n.executeFunctionByName(t.amsResizableInitCallback,a,i)||i;var r=a.resizable(i);a.disableSelection(),n.executeFunctionByName(t.amsResizableAfterInitCallback,a,r,i)})},typeahead:function(a){var t=e(".typeahead",a);t.length>0&&n.ajax.check(e.fn.typeahead,n.baseURL+"ext/jquery-typeahead"+n.devext+".js",function(){t.each(function(){var a=e(this),t=a.data(),s=e.extend({},{},t.amsTypeaheadOptions);s=n.executeFunctionByName(t.amsTypeaheadInitCallback,a,s)||s;var i=a.typeahead(s);n.executeFunctionByName(t.amsTypeaheadAfterInitCallback,a,i,s)})})},treeview:function(a){var t=e(".treeview",a);t.length>0&&n.ajax.check(e.fn.treview,n.baseURL+"ext/bootstrap-treeview"+n.devext+".js",function(){n.getCSS(n.baseURL+"../css/ext/bootstrap-treeview"+n.devext+".css","bootstrap-treeview",function(){t.each(function(){var a=e(this),t=a.data(),s={data:t.amsTreeviewData,levels:t.amsTreeviewLevels,injectStyle:t.amsTreeviewInjectStyle,expandIcon:t.amsTreeviewExpandIcon||"fa fa-fw fa-plus-square-o",collapseIcon:t.amsTreeviewCollaspeIcon||"fa fa-fw fa-minus-square-o",emptyIcon:t.amsTreeviewEmptyIcon||"fa fa-fw",nodeIcon:t.amsTreeviewNodeIcon,selectedIcon:t.amsTreeviewSelectedIcon,checkedIcon:t.amsTreeviewCheckedIcon||"fa fa-fw fa-check-square-o",uncheckedIcon:t.amsTreeviewUncheckedIcon||"fa fa-fw fa-square-o",color:t.amsTreeviewColor,backColor:t.amsTreeviewBackColor,borderColor:t.amsTreeviewBorderColor,onHoverColor:t.amsTreeviewHoverColor,selectedColor:t.amsTreeviewSelectedColor,selectedBackColor:t.amsTreeviewSelectedBackColor,unselectableColor:t.amsTreeviewUnselectableColor||"rgba(1,1,1,0.25)",unselectableBackColor:t.amsTreeviewUnselectableBackColor||"rgba(1,1,1,0.25)",enableLinks:t.amsTreeviewEnableLinks,highlightSelected:t.amsTreeviewHighlightSelected,highlightSearchResults:t.amsTreeviewhighlightSearchResults,showBorder:t.amsTreeviewShowBorder,showIcon:t.amsTreeviewShowIcon,showCheckbox:t.amsTreeviewShowCheckbox,showTags:t.amsTreeviewShowTags,toggleUnselectable:t.amsTreeviewToggleUnselectable,multiSelect:t.amsTreeviewMultiSelect,onNodeChecked:n.getFunctionByName(t.amsTreeviewNodeChecked),onNodeCollapsed:n.getFunctionByName(t.amsTreeviewNodeCollapsed),onNodeDisabled:n.getFunctionByName(t.amsTreeviewNodeDisabled),onNodeEnabled:n.getFunctionByName(t.amsTreeviewNodeEnabled),onNodeExpanded:n.getFunctionByName(t.amsTreeviewNodeExpanded),onNodeSelected:n.getFunctionByName(t.amsTreeviewNodeSelected),onNodeUnchecked:n.getFunctionByName(t.amsTreeviewNodeUnchecked),onNodeUnselected:n.getFunctionByName(t.amsTreeviewNodeUnselected),onSearchComplete:n.getFunctionByName(t.amsTreeviewSearchComplete),onSearchCleared:n.getFunctionByName(t.amsTreeviewSearchCleared)},i=e.extend({},s,t.amsTreeviewOptions);i=n.executeFunctionByName(t.amsTreeviewInitcallback,a,i)||i;var r=a.treeview(i);n.executeFunctionByName(t.amsTreeviewAfterInitCallback,a,r,i)})})})},select2:function(a){var t=e(".select2",a);t.length>0&&n.ajax.check(e.fn.select2,n.baseURL+"ext/jquery-select2-3.5.4"+n.devext+".js",function(){t.each(function(){var a=e(this),t=a.data();if(!t.select2){var s={placeholder:t.amsSelect2Placeholder,multiple:t.amsSelect2Multiple,minimumInputLength:t.amsSelect2MinimumInputLength||0,maximumSelectionSize:t.amsSelect2MaximumSelectionSize,openOnEnter:void 0===t.amsSelect2EnterOpen||t.amsSelect2EnterOpen,allowClear:void 0===t.amsSelect2AllowClear||t.amsSelect2AllowClear,width:t.amsSelect2Width||"100%",initSelection:n.getFunctionByName(t.amsSelect2InitSelection),formatSelection:void 0===t.amsSelect2FormatSelection?n.helpers.select2FormatSelection:n.getFunctionByName(t.amsSelect2FormatSelection),formatResult:n.getFunctionByName(t.amsSelect2FormatResult),formatMatches:void 0===t.amsSelect2FormatMatches?function(e){return 1===e?n.i18n.SELECT2_MATCH:e+n.i18n.SELECT2_MATCHES}:n.getFunctionByName(t.amsSelect2FormatMatches),formatNoMatches:void 0===t.amsSelect2FormatResult?function(e){return n.i18n.SELECT2_NOMATCHES}:n.getFunctionByName(t.amsSelect2FormatResult),formatInputTooShort:void 0===t.amsSelect2FormatInputTooShort?function(e,a){var t=a-e.length;return n.i18n.SELECT2_INPUT_TOOSHORT.replace(/\{0\}/,t).replace(/\{1\}/,1===t?"":n.i18n.SELECT2_PLURAL)}:n.getFunctionByName(t.amsSelect2FormatInputTooShort),formatInputTooLong:void 0===t.amsSelect2FormatInputTooLong?function(e,a){var t=e.length-a;return n.i18n.SELECT2_INPUT_TOOLONG.replace(/\{0\}/,t).replace(/\{1\}/,1===t?"":n.i18n.SELECT2_PLURAL)}:n.getFunctionByName(t.amsSelect2FormatInputTooLong),formatSelectionTooBig:void 0===t.amsSelect2FormatSelectionTooBig?function(e){return n.i18n.SELECT2_SELECTION_TOOBIG.replace(/\{0\}/,e).replace(/\{1\}/,1===e?"":n.i18n.SELECT2_PLURAL)}:n.getFunctionByName(t.amsSelect2FormatSelectionTooBig),formatLoadMore:void 0===t.amsSelect2FormatLoadMore?function(e){return n.i18n.SELECT2_LOADMORE}:n.getFunctionByName(t.amsSelect2FormatLoadMore),formatSearching:void 0===t.amsSelect2FormatSearching?function(){return n.i18n.SELECT2_SEARCHING}:n.getFunctionByName(t.amsSelect2FormatSearching),separator:t.amsSelect2Separator||",",tokenSeparators:t.amsSelect2TokensSeparators||[","],tokenizer:n.getFunctionByName(t.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[]}):t.amsSelect2Query?(s.query=n.getFunctionByName(t.amsSelect2Query),s.minimumInputLength=t.amsSelect2MinimumInputLength||1):t.amsSelect2QueryUrl?(s.ajax={url:t.amsSelect2QueryUrl,quietMillis:t.amsSelect2QuietMillis||200,type:t.amsSelect2QueryType||"POST",dataType:t.amsSelect2QueryDatatype||"json",data:function(a,n,s){var i={};return i[t.amsSelect2QueryParamName||"query"]=a,i[t.amsSelect2PageParamName||"page"]=n,i[t.amsSelect2ContextParamName||"context"]=s,e.extend({},i,t.amsSelect2QueryOptions)},results:n.helpers.select2QueryUrlResultsCallback},s.minimumInputLength=t.amsSelect2MinimumInputLength||1):t.amsSelect2QueryMethod?(s.query=function(s){var i={id:(new Date).getTime(),params:t.amsSelect2QueryParams||{},success:function(e){return n.helpers.select2QueryMethodSuccessCallback.call(a,e,"success",s)},error:n.error.show};i.params[t.amsSelect2QueryParamName||"query"]=s.term,i.params[t.amsSelect2PageParamName||"page"]=s.page,i.params[t.amsSelect2ContextParamName||"context"]=s.context,i=e.extend({},i,t.amsSelect2QueryOptions),i=n.executeFunctionByName(t.amsSelect2QueryInitCallback,a,i)||i,n.ajax.check(e.jsonRPC,n.baseURL+"ext/jquery-jsonrpc"+n.devext+".js",function(){e.jsonRPC.withOptions({endPoint:t.amsSelect2MethodTarget||n.jsonrpc.getAddr(),namespace:t.amsSelect2MethodNamespace,cache:!1},function(){e.jsonRPC.request(t.amsSelect2QueryMethod,i)})})},s.minimumInputLength=t.amsSelect2MinimumInputLength||1):t.amsSelect2Tags?s.tags=t.amsSelect2Tags:t.amsSelect2Data&&(s.data=t.amsSelect2Data),t.amsSelect2EnableFreeTags&&(s.createSearchChoice=function(e){return{id:e,text:(t.amsSelect2FreeTagsPrefix||n.i18n.SELECT2_FREETAG_PREFIX)+e}});var r=e.extend({},s,t.amsSelect2Options);r=n.executeFunctionByName(t.amsSelect2InitCallback,a,r)||r;var c=a.select2(r);n.executeFunctionByName(t.amsSelect2AfterInitCallback,a,c,r),a.hasClass("ordered")&&n.ajax.check(e.fn.select2Sortable,n.baseURL+"ext/jquery-select2-sortable"+n.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 t=e("[data-mask]",a);t.length>0&&n.ajax.check(e.fn.mask,n.baseURL+"ext/jquery-maskedinput-1.4.1"+n.devext+".js",function(){t.each(function(){var a=e(this),t=a.data(),s={placeholder:void 0===t.amsMaskeditPlaceholder?"X":t.amsMaskeditPlaceholder,complete:n.getFunctionByName(t.amsMaskeditComplete)},i=e.extend({},s,t.amsMaskeditOptions);i=n.executeFunctionByName(t.amsMaskeditInitCallback,a,i)||i;var r=a.mask(a.attr("data-mask"),i);n.executeFunctionByName(t.amsMaskeditAfterInitCallback,a,r,i)})})},inputmask:function(a){var t=e("input[data-input-mask]",a);t.length>0&&n.ajax.check(e.fn.inputmask,n.baseURL+"ext/jquery-inputmask-bundle-3.2.8"+n.devext+".js",function(){t.each(function(){var a,t=e(this),s=t.data();a="object"==typeof s.inputMask?s.inputMask:{mask:s.inputMask.toString()};var i=e.extend({},a,s.amsInputmaskOptions);i=n.executeFunctionByName(s.amsInputmaskInitCallback,t,i)||i;var r=t.inputmask(i);n.executeFunctionByName(s.amsInputmaskAfterInitCallback,t,r,i)})})},datepicker:function(a){var t=e(".datepicker",a);t.length>0&&n.ajax.check(e.fn.datetimepicker,n.baseURL+"ext/jquery-datetimepicker"+n.devext+".js",function(a){a&&n.dialog.registerHideCallback(n.helpers.datetimepickerDialogHiddenCallback),n.getCSS(n.baseURL+"../css/ext/jquery-datetimepicker"+n.devext+".css","jquery-datetimepicker",function(){t.each(function(){var a=e(this),t=a.data(),s={lang:t.amsDatetimepickerLang||n.lang,format:t.amsDatetimepickerFormat||"d/m/y",datepicker:!0,dayOfWeekStart:1,timepicker:!1,closeOnDateSelect:void 0===t.amsDatetimepickerCloseOnSelect||t.amsDatetimepickerCloseOnSelect,weeks:t.amsDatetimepickerWeeks},i=e.extend({},s,t.amsDatetimepickerOptions);i=n.executeFunctionByName(t.amsDatetimepickerInitCallback,a,i)||i;var r=a.datetimepicker(i);n.executeFunctionByName(t.amsDatetimepickerAfterInitCallback,a,r,i)})})})},datetimepicker:function(a){var t=e(".datetimepicker",a);t.length>0&&n.ajax.check(e.fn.datetimepicker,n.baseURL+"ext/jquery-datetimepicker"+n.devext+".js",function(a){a&&n.dialog.registerHideCallback(n.helpers.datetimepickerDialogHiddenCallback),n.getCSS(n.baseURL+"../css/ext/jquery-datetimepicker"+n.devext+".css","jquery-datetimepicker",function(){t.each(function(){var a=e(this),t=a.data(),s={lang:t.amsDatetimepickerLang||n.lang,format:t.amsDatetimepickerFormat||"d/m/y H:i",datepicker:!0,dayOfWeekStart:1,timepicker:!0,closeOnDateSelect:void 0===t.amsDatetimepickerCloseOnSelect||t.amsDatetimepickerCloseOnSelect,closeOnTimeSelect:void 0===t.amsDatetimepickerCloseOnSelect||t.amsDatetimepickerCloseOnSelect,weeks:t.amsDatetimepickerWeeks},i=e.extend({},s,t.amsDatetimepickerOptions);i=n.executeFunctionByName(t.amsDatetimepickerInitCallback,a,i)||i;var r=a.datetimepicker(i);n.executeFunctionByName(t.amsDatetimepickerAfterInitCallback,a,r,i)})})})},timepicker:function(a){var t=e(".timepicker",a);t.length>0&&n.ajax.check(e.fn.datetimepicker,n.baseURL+"ext/jquery-datetimepicker"+n.devext+".js",function(a){a&&n.dialog.registerHideCallback(n.helpers.datetimepickerDialogHiddenCallback),n.getCSS(n.baseURL+"../css/ext/jquery-datetimepicker"+n.devext+".css","jquery-datetimepicker",function(){t.each(function(){var a=e(this),t=a.data(),s={lang:t.amsDatetimepickerLang||n.lang,format:t.amsDatetimepickerFormat||"H:i",datepicker:!1,timepicker:!0,closeOnTimeSelect:void 0===t.amsDatetimepickerCloseOnSelect||t.amsDatetimepickerCloseOnSelect},i=e.extend({},s,t.amsDatetimepickerOptions);i=n.executeFunctionByName(t.amsDatetimepickerInitCallback,a,i)||i;var r=a.datetimepicker(i);n.executeFunctionByName(t.amsDatetimepickerAfterInitCallback,a,r,i)})})})},colorpicker:function(a){var t=e(".colorpicker",a);t.length>0&&n.ajax.check(e.fn.minicolors,n.baseURL+"ext/jquery-minicolors"+n.devext+".js",function(){n.getCSS(n.baseURL+"../css/ext/jquery-minicolors"+n.devext+".css","jquery-minicolors",function(){t.each(function(){var a=e(this),t=a.data(),s={position:t.amsColorpickerPosition||a.closest(".input").data("ams-colorpicker-position")||"bottom left"},i=e.extend({},s,t.amsColorpickerOptions);i=n.executeFunctionByName(t.amsColorpickerInitCallback,a,i)||i;var r=a.minicolors(i);n.executeFunctionByName(t.amsDatetimepickerAfterInitCallback,a,r,i)})})})},dndupload:function(a){var t=e(".dndupload",a);t.length>0&&n.ajax.check(e.fn.dndupload,n.baseURL+"ext/jquery-dndupload"+n.devext+".js",function(){n.getCSS(n.baseURL+"../css/ext/jquery-dndupload"+n.devext+".css","jquery-dndupload",function(){t.each(function(){var a=e(this),t=a.data(),s={action:t.amsDnduploadAction||a.attr("action")||"upload-files",fieldname:t.amsDnduploadFieldname||"files",autosubmit:t.amsDnduploadAutosubmit},i=e.extend({},s,t.amsDnduploadOptions);i=n.executeFunctionByName(t.amsDnduploadInitCallback,a,i)||i;var r=a.dndupload(i);n.executeFunctionByName(t.amsDnduploadAfterInitcallback,a,r,i)})})})},validate:function(a){var t=e("FORM:not([novalidate])",a);t.length>0&&n.ajax.check(e.fn.validate,n.baseURL+"ext/jquery-validate-1.17.0"+n.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:first");t.length?e.insertAfter(t):e.insertAfter(a)}}),n.plugins.i18n)){for(var s in n.plugins.i18n.validate)if(n.plugins.i18n.validate.hasOwnProperty(s)){var i=n.plugins.i18n.validate[s];"string"==typeof i&&i.indexOf("{0}")>-1&&(n.plugins.i18n.validate[s]=e.validator.format(i))}e.extend(e.validator.messages,n.plugins.i18n.validate)}t.each(function(){var a=e(this),t=a.data(),s={ignore:null,submitHandler:void 0!==a.attr("data-async")?void 0===t.amsFormSubmitHandler?function(){return e(".state-error",a).removeClass("state-error"),n.ajax.check(e.fn.ajaxSubmit,n.baseURL+"ext/jquery-form-3.49"+n.devext+".js"),n.form.submit(a)}:n.getFunctionByName(t.amsFormSubmitHandler):void 0,invalidHandler:void 0!==a.attr("data-async")?void 0===t.amsFormInvalidHandler?function(t,n){e(".state-error",a).removeClass("state-error");for(var s=0;s0){var c=e(".nav-tabs",e(i.element).parents(".tabforms"));e("li:nth-child("+r+")",c).removeClassPrefix("state-").addClass("state-error"),e("li.state-error:first a",c).click()}}}:n.getFunctionByName(t.amsFormInvalidHandler):void 0};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")});var i=e.extend({},s,t.amsValidateOptions);i=n.executeFunctionByName(t.amsValidateInitCallback,a,i)||i;var r=a.validate(i);n.executeFunctionByName(t.amsValidateAfterInitCallback,a,r,i)})})},datatable:function(a){var t=e(".datatable",a);t.length>0&&n.ajax.check(e.fn.dataTable,n.baseURL+"ext/jquery-dataTables-1.9.4"+n.devext+".js",function(){n.ajax.check(e.fn.dataTableExt.oPagination.bootstrap_full,n.baseURL+"myams-dataTables"+n.devext+".js",function(){e(t).each(function(){var a,t=e(this),s=t.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>>",c=s.amsDatatableSorting;if("string"==typeof c){var o=c.split(";");for(c=[],a=0;a=0,bPaginate:!1!==s.amsDatatablePagination,bInfo:!1!==s.amsDatatableInfo,bSort:!1!==s.amsDatatableSort,aaSorting:c,aoColumns:d.length>0?d:void 0,bDeferRender:!0,bAutoWidth:!1,iDisplayLength:s.amsDatatableDisplayLength||25,sPaginationType:s.amsDatatablePaginationType||"bootstrap_full",sDom:r,oLanguage:n.plugins.i18n.datatables,fnInitComplete:function(a,t){e(".ColVis_Button").addClass("btn btn-default btn-sm").html((n.plugins.i18n.datatables.sColumns||"Columns")+' ')}},g=e.extend({},f,s.amsDatatableOptions),v=[],y=[],x=[];if(i.length>0)for(a=0;a0)for(a=0;a0)for(a=0;a0&&n.ajax.check(e.fn.tableDnD,n.baseURL+"ext/jquery-tablednd"+n.devext+".js",function(){t.each(function(){var a=e(this),t=a.data();t.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:t.amsTabledndDragClass||"dragging-row",onDragStart:n.getFunctionByName(t.amsTabledndDragStart),dragHandle:t.amsTabledndDragHandle,scrollAmount:t.amsTabledndScrollAmount,onAllowDrop:t.amsTabledndAllowDrop,onDrop:n.getFunctionByName(t.amsTabledndDrop)||function(s,i){var r=t.amsTabledndDropTarget;if(r){e(i).data("ams-disabled-handlers","click");try{var c=[];e(s.rows).each(function(){var a=e(this).data("ams-element-name");a&&c.push(a)});var o=n.getFunctionByName(r);if("function"==typeof o)o.call(a,s,c);else{if(!r.startsWith(window.location.protocol)){var l=t.amsLocation;l&&(r=l+"/"+r)}n.ajax.post(r,{names:JSON.stringify(c)})}}finally{setTimeout(function(){e(i).removeData("ams-disabled-handlers")},50)}}return!1}},i=e.extend({},s,t.amsTabledndOptions);i=n.executeFunctionByName(t.amsTabledndInitCallback,a,i)||i;var r=a.tableDnD(i);n.executeFunctionByName(t.amsTabledndAfterInitCallback,a,r,i)})})},wizard:function(a){var t=e(".wizard",a);t.length>0&&n.ajax.check(e.fn.bootstrapWizard,n.baseURL+"ext/bootstrap-wizard-1.4.2"+n.devext+".js",function(){t.each(function(){var a=e(this),t=a.data(),s={withVisible:void 0===t.amsWizardWithVisible||t.amsWizardWithVisible,tabClass:t.amsWizardTabClass,firstSelector:t.amsWizardFirstSelector,previousSelector:t.amsWizardPreviousSelector,nextSelector:t.amsWizardNextSelector,lastSelector:t.amsWizardLastSelector,finishSelector:t.amsWizardFinishSelector,backSelector:t.amsWizardBackSelector,onInit:n.getFunctionByName(t.amsWizardInit),onShow:n.getFunctionByName(t.amsWizardShow),onNext:n.getFunctionByName(t.amsWizardNext),onPrevious:n.getFunctionByName(t.amsWizardPrevious),onFirst:n.getFunctionByName(t.amsWizardFirst),onLast:n.getFunctionByName(t.amsWizardLast),onBack:n.getFunctionByName(t.amsWizardBack),onFinish:n.getFunctionByName(t.amsWizardFinish),onTabChange:n.getFunctionByName(t.amsWizardTabChange),onTabClick:n.getFunctionByName(t.amsWizardTabClick),onTabShow:n.getFunctionByName(t.amsWizardTabShow)},i=e.extend({},s,t.amsWizardOptions);i=n.executeFunctionByName(t.amsWizardInitCallback,a,i)||i;var r=a.bootstrapWizard(i);n.executeFunctionByName(t.amsWizardAfterInitCallback,a,r,i)})})},tinymce:function(a){function t(){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=n.baseURL+"ext/tinymce"+(n.devmode?"/dev":"");n.ajax.check(window.tinymce,i+"/tinymce"+n.devext+".js",function(a){function r(){s.each(function(){var a=e(this),t=a.data(),s={theme:t.amsTinymceTheme||"modern",language:n.lang,menubar:!1!==t.amsTinymceMenubar,statusbar:!1!==t.amsTinymceStatusbar,plugins:t.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:t.amsTinymceToolbar,toolbar1:!1!==t.amsTinymceToolbar1&&(t.amsTinymceToolbar1||"undo redo | pastetext | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent"),toolbar2:!1!==t.amsTinymceToolbar2&&(t.amsTinymceToolbar2||"forecolor backcolor emoticons | charmap link image media | fullscreen preview print | code"),content_css:t.amsTinymceContentCss,formats:t.amsTinymceFormats,style_formats:t.amsTinymceStyleFormats,block_formats:t.amsTinymceBlockFormats,valid_classes:t.amsTinymceValidClasses,image_advtab:!0,image_list:n.getFunctionByName(t.amsTinymceImageList)||t.amsTinymceImageList,image_class_list:t.amsTinymceImageClassList,link_list:n.getFunctionByName(t.amsTinymceLinkList)||t.amsTinymceLinkList,link_class_list:t.amsTinymceLinkClassList,paste_as_text:void 0===t.amsTinymcePasteAsText||t.amsTinymcePasteAsText,paste_auto_cleanup_on_paste:void 0===t.amsTinymcePasteAutoCleanup||t.amsTinymcePasteAutoCleanup,paste_strip_class_attributes:t.amsTinymcePasteStripClassAttributes||"all",paste_remove_spans:void 0===t.amsTinymcePaseRemoveSpans||t.amsTinymcePasteRemoveSpans,paste_remove_styles:void 0===t.amsTinymcePasteRemoveStyles||t.amsTinymcePasteRemoveStyles,height:t.amsTinymceHeight||50,min_height:50,resize:!0,autoresize_min_height:50,autoresize_max_height:500};if(t.amsTinymceExternalPlugins){var i=t.amsTinymceExternalPlugins.split(/\s+/);for(var r in i)if(i.hasOwnProperty(r)){var c=a.data("ams-tinymce-plugin-"+i[r]);tinymce.PluginManager.load(i[r],n.getSource(c))}}var o=e.extend({},s,t.amsTinymceOptions);o=n.executeFunctionByName(t.amsTinymceInitCallback,a,o)||o;var l=a.tinymce(o);n.executeFunctionByName(t.amsTinymceAfterInitCallback,a,l,o)})}a?n.getScript(i+"/jquery.tinymce"+n.devext+".js",function(){tinymce.baseURL=i,tinymce.suffix=n.devext,n.skin.registerCleanCallback(t),r()}):r()})}},imgareaselect:function(a){var t=e(".imgareaselect",a);t.length>0&&n.ajax.check(e.fn.imgAreaSelect,n.baseURL+"ext/jquery-imgareaselect-0.9.11-rc1"+n.devext+".js",function(){n.getCSS(n.baseURL+"../css/ext/jquery-imgareaselect"+n.devext+".css","jquery-imgareaselect",function(){t.each(function(){var a=e(this),t=a.data(),s=t.amsImgareaselectParent?a.parents(t.amsImgareaselectParent):"body",i={instance:!0,handles:!0,parent:s,x1:t.amsImgareaselectX1||0,y1:t.amsImgareaselectY1||0,x2:t.amsImgareaselectX2||t.amsImgareaselectImageWidth,y2:t.amsImgareaselectY2||t.amsImgareaselectImageHeight,imageWidth:t.amsImgareaselectImageWidth,imageHeight:t.amsImgareaselectImageHeight,minWidth:128,minHeight:128,aspectRatio:t.amsImgareaselectRatio,onSelectEnd:n.getFunctionByName(t.amsImgareaselectSelectEnd)||function(a,n){var i=t.amsImgareaselectTargetField||"image_";e('input[name="'+i+'x1"]',s).val(n.x1),e('input[name="'+i+'y1"]',s).val(n.y1),e('input[name="'+i+'x2"]',s).val(n.x2),e('input[name="'+i+'y2"]',s).val(n.y2)}},r=e.extend({},i,t.amsImgareaselectOptions);r=n.executeFunctionByName(t.amsImgareaselectInitCallback,a,r)||r;var c=a.imgAreaSelect(r);n.executeFunctionByName(t.amsImgareaselectAfterInitCallback,a,c,r),setTimeout(function(){c.update()},250)})})})},fancybox:function(a){var t=e(".fancybox",a);t.length>0&&n.ajax.check(e.fn.fancybox,n.baseURL+"ext/jquery-fancybox-2.1.5"+n.devext+".js",function(){n.getCSS(n.baseURL+"../css/ext/jquery-fancybox-2.1.5"+n.devext+".css","jquery-fancybox",function(){t.each(function(){var a,t=e(this),s=t.data(),i=t;s.amsFancyboxElements&&(i=e(s.amsFancyboxElements,t));var r=(s.amsFancyboxHelpers||"").split(/\s+/);if(r.length>0)for(a=0;a0)for(a=0;a0&&n.ajax.check(e.fn.plot,n.baseURL+"flot/jquery.flot"+n.devext+".js",function(){t.each(function(){var a=e(this),t=a.data(),s=(t.amsChartPlugins||"").split(/\s+/);if(s.length>0)for(var i in s)if(s.hasOwnProperty(i)){var r=s[i];(function(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})(r)||n.getScript(n.baseURL+"flot/jquery.flot."+r+n.devext+".js")}var c=e.extend({},{},t.amsChartOptions);c=n.executeFunctionByName(t.amsChartInitCallback,a,c)||c;var o=t.amsChartData;o=n.executeFunctionByName(t.amsChartInitData,a,o)||o;var l=a.plot(o,c);n.executeFunctionByName(t.amsChartAfterInitCallback,a,l,c)})})},graphs:function(a){var t=e(".sparkline",a);t.length>0&&n.ajax.check(n.graphs,n.baseURL+"myams-graphs"+n.devext+".js",function(){n.graphs.init(t)})},scrollbars:function(a){var t=e(".scrollbar",a);t.length>0&&n.ajax.check(e.event.special.mousewheel,n.baseURL+"ext/jquery-mousewheel.min.js",function(){n.ajax.check(e.fn.mCustomScrollbar,n.baseURL+"ext/jquery-mCustomScrollbar"+n.devext+".js",function(){n.getCSS(n.baseURL+"../css/ext/jquery-mCustomScrollbar.css","jquery-mCustomScrollbar",function(){t.each(function(){var a=e(this),t=a.data(),s={theme:t.amsScrollbarTheme||"light"},i=e.extend({},s,t.amsScrollbarOptions);i=n.executeFunctionByName(t.amsScrollbarInitCallback,a,i)||i;var r=a.mCustomScrollbar(i);n.executeFunctionByName(t.amsScrollbarAfterInitCallback,a,r,i)})})})})}}}}(jQuery,this); +!function(y,e){var x=e.MyAMS;y.extend(x.plugins.enabled,{svg:function(e){var a=y(".svg-container",e);0').prependTo(y(this)).addClass("open"===s.amsSwitcherState?s.amsSwitcherMinusClass||"fa-minus":s.amsSwitcherPlusClass||"fa-plus"),n.on("click",function(e){e.preventDefault();var a={};if(n.trigger("ams.switcher.before-switch",[n,a]),!a.veto)if(i.hasClass("switched")){i.removeClass("switched"),y(".fa",n).removeClass(s.amsSwitcherPlusClass||"fa-plus").addClass(s.amsSwitcherMinusClass||"fa-minus"),n.trigger("ams.switcher.opened",[n]);var t=n.attr("id");t&&y('legend.switcher[data-ams-switcher-sync="'+t+'"]',i).each(function(){var e=y(this);e.parents("fieldset").hasClass("switched")&&e.click()})}else i.addClass("switched"),y(".fa",n).removeClass(s.amsSwitcherMinusClass||"fa-minus").addClass(s.amsSwitcherPlusClass||"fa-plus"),n.trigger("ams.switcher.closed",[n])}),"open"!==s.amsSwitcherState&&i.addClass("switched"),n.data("ams-switcher","on"))})},checker:function(e){y("LEGEND.checker",e).each(function(){var i=y(this),s=i.parent("fieldset"),r=i.data();if(!r.amsChecker){var e=y(''),a=r.amsCheckerFieldname||"checker_"+x.generateId(),t=a.replace(/\./,"_"),n=r.amsCheckerHiddenPrefix,o=null,c=r.amsCheckerHiddenValueOn||"true",l=r.amsCheckerHiddenValueOff||"false",m=r.amsCheckerMarker||!1;n?o=y('').attr("name",n+a).val("on"===r.amsCheckerState?c:l).prependTo(i):m&&y('').attr("name",m).attr("value",1).prependTo(i);var d=y('').attr("name",a).attr("id",t).data("ams-checker-hidden-input",o).data("ams-checker-init",!0).val(r.amsCheckerValue||!0).attr("checked","on"===r.amsCheckerState?"checked":null);r.amsCheckerReadonly?d.attr("disabled","disabled"):d.on("change",function(e){e.preventDefault();var a={},t=y(this).is(":checked");if(i.trigger("ams.checker.before-switch",[i,a]),a.veto)y(this).prop("checked",!t);else if(x.executeFunctionByName(r.amsCheckerChangeHandler,i,t),!r.amsCheckerCancelDefault){var n=d.data("ams-checker-hidden-input");t?("disable"===r.amsCheckerMode?(s.removeAttr("disabled"),y(".select2",s).removeAttr("disabled")):s.removeClass("switched"),n&&n.val(c),y("[data-required]",s).attr("required","required"),i.trigger("ams.checker.opened",[i])):("disable"===r.amsCheckerMode?(s.prop("disabled","disabled"),y(".select2",s).attr("disabled","disabled")):s.addClass("switched"),n&&n.val(l),y("[data-required]",s).removeAttr("required"),i.trigger("ams.checker.closed",[i]))}}),d.appendTo(e),y(">label",i).attr("for",d.attr("id")),e.append("").prependTo(i);var u=y("[required]",s);u.attr("data-required",!0),"on"===r.amsCheckerState?d.attr("checked",!0):("disable"===r.amsCheckerMode?(s.attr("disabled","disabled"),y(".select2",s).attr("disabled","disabled")):s.addClass("switched"),u.removeAttr("required")),i.data("ams-checker","on")}})},slider:function(e){var a=y(".slider",e);0r<'dt-wrapper't"+(0<=h.indexOf("scroller")?"S":"")+"><'dt-row dt-bottom-row'<'row'<'col-sm-6'"+(!1===b.amsDatatableInformation?"":"i")+"><'col-sm-6 text-right'p>>",a=b.amsDatatableSorting;if("string"==typeof a){var t=a.split(";");for(a=[],d=0;d')}},p=y.extend({},m,b.amsDatatableOptions),f=[],g=[],v=[];if(0
').parent()); - var dialogData = dialog.data(); + var dialogData = dialog.data() || {}; var dataOptions = { backdrop: 'static', overflow: dialogData.amsModalOverflow || '.modal-viewport', @@ -2858,7 +2861,7 @@ })(jQuery, this); /** - * MyAMS standard plug-ins + * MyAMS standard plug-ins loader * * Only basic JQuery, Bootstrap and MyAMS javascript extensions are typically loaded from main page. * Other JQuery plug-ins may be loaded dynamically. @@ -2878,6 +2881,11 @@ MyAMS.plugins = { /** + * Container of enabled plug-ins + */ + enabled: {}, + + /** * Initialize list of content plug-ins */ init: function(element) { @@ -3124,1699 +3132,1719 @@ ams.executeFunctionByName(callback); } } + } + }; + +})(jQuery, this); + +/** + * MyAMS standard plug-ins + * + * Only basic JQuery, Bootstrap and MyAMS javascript extensions are typically loaded from main page. + * Other JQuery plug-ins may be loaded dynamically. + * Several JQuery extension plug-ins are already included and pre-configured by MyAMS. Other external + * plug-ins can be defined and loaded dynamically using simple "data" attributes. + * + * WARNING: any plug-in implicated into a form submit process (like JQuery-form or JQuery-progressbar) + * must be loaded in a synchronous way. Otherwise, if you use named buttons to submit your forms, + * dynamic hidden input fields created by JQuery-validate plug-in will be removed from the form + * before the form is submitted! + */ +(function($, globals) { + + var MyAMS = globals.MyAMS, + ams = MyAMS; + + /** + * Map of enabled plug-ins + * This map can be extended by external plug-ins. + * + * Standard MyAMS plug-ins management method generally includes: + * - applying a class matching plug-in name on a set of HTML entities to apply the plug-in + * - defining a set of data-attributes on each of these entities to customize the plug-in + * For each standard plug-in, you can also provide an options object (to define plug-in options not handled + * by default MyAMS initialization engine) and an initialization callback (to define these options dynamically). + * Another callback can also be provided to be called after plug-in initialization. + * + * You can also register plug-ins using the 'register' function + */ + $.extend(ams.plugins.enabled, { + + /** + * SVG containers + */ + svg: function(element) { + var svgs = $('.svg-container', element); + if (svgs.length > 0) { + svgs.each(function() { + var container = $(this); + var svg = $('svg', container), + width = svg.attr('width'), + height = svg.attr('height'); + if (width && height) { + svg.get(0).setAttribute('viewBox', + '0 0 ' + Math.round(parseFloat(width)) + ' ' + + Math.round(parseFloat(height))); + } + svg.attr('width', '100%') + .attr('height', 'auto'); + }) + } + }, + + /** + * Label hints + */ + hint: function(element) { + var hints = $('.hint:not(:parents(.nohints))', element); + if (hints.length > 0) { + ams.ajax.check($.fn.tipsy, + ams.baseURL + 'ext/jquery-tipsy' + ams.devext + '.js', + function() { + ams.getCSS(ams.baseURL + '../css/ext/jquery-tipsy' + ams.devext + '.css', + 'jquery-tipsy', function() { + hints.each(function () { + var hint = $(this); + var data = hint.data(); + var dataOptions = { + html: data.amsHintHtml === undefined ? (hint.attr('title') || '').startsWith('<') : data.amsHintHtml, + title: ams.getFunctionByName(data.amsHintTitleGetter) || function () { + var hint = $(this); + var result = hint.attr('original-title') || + hint.attr(data.amsHintTitleAttr || 'title') || + (data.amsHintHtml ? hint.html() : hint.text()); + result = result.replace(/\?_="/, '?_=' + new Date().getTime() + '"'); + return result; + }, + opacity: data.amsHintOpacity || 0.95, + gravity: data.amsHintGravity || 'sw', + offset: data.amsHintOffset || 0 + }; + var settings = $.extend({}, dataOptions, data.amsHintOptions); + settings = ams.executeFunctionByName(data.amsHintInitCallback, hint, settings) || settings; + var plugin = hint.tipsy(settings); + ams.executeFunctionByName(data.amsHintAfterInitCallback, hint, plugin, settings); + }); + }); + }); + } + }, + + /** + * Context menu plug-in + */ + contextMenu: function(element) { + var menus = $('.context-menu', element); + if (menus.length > 0) { + menus.each(function() { + var menu = $(this); + var data = menu.data(); + var dataOptions = { + menuSelector: data.amsContextmenuSelector, + menuSelected: ams.helpers.contextMenuHandler + }; + var settings = $.extend({}, dataOptions, data.amsContextmenuOptions); + settings = ams.executeFunctionByName(data.amsContextmenuInitCallback, menu, settings) || settings; + var plugin = menu.contextMenu(settings); + ams.executeFunctionByName(data.amsContextmenuAfterInitCallback, menu, plugin, settings); + }); + } + }, + + /** + * Fieldset legend switcher + */ + switcher: function(element) { + $('LEGEND.switcher', element).each(function() { + var legend = $(this); + var fieldset = legend.parent('fieldset'); + var data = legend.data(); + if (!data.amsSwitcher) { + $('') + .prependTo($(this)) + .addClass(data.amsSwitcherState === 'open' ? + (data.amsSwitcherMinusClass || 'fa-minus') : + (data.amsSwitcherPlusClass || 'fa-plus')); + legend.on('click', function(e) { + e.preventDefault(); + var veto = {}; + legend.trigger('ams.switcher.before-switch', [legend, veto]); + if (veto.veto) { + return; + } + if (fieldset.hasClass('switched')) { + fieldset.removeClass('switched'); + $('.fa', legend).removeClass(data.amsSwitcherPlusClass || 'fa-plus') + .addClass(data.amsSwitcherMinusClass || 'fa-minus'); + legend.trigger('ams.switcher.opened', [legend]); + var id = legend.attr('id'); + if (id) { + $('legend.switcher[data-ams-switcher-sync="'+id+'"]', fieldset).each(function() { + var switcher = $(this); + if (switcher.parents('fieldset').hasClass('switched')) { + switcher.click(); + } + }); + } + } else { + fieldset.addClass('switched'); + $('.fa', legend).removeClass(data.amsSwitcherMinusClass || 'fa-minus') + .addClass(data.amsSwitcherPlusClass || 'fa-plus'); + legend.trigger('ams.switcher.closed', [legend]); + } + }); + if (data.amsSwitcherState !== 'open') { + fieldset.addClass('switched'); + } + legend.data('ams-switcher', 'on'); + } + }); + }, + + /** + * Fieldset legend checker + */ + checker: function(element) { + $('LEGEND.checker', element).each(function() { + var legend = $(this); + var fieldset = legend.parent('fieldset'); + var data = legend.data(); + if (!data.amsChecker) { + var checker = $(''); + var fieldname = data.amsCheckerFieldname || ('checker_'+ams.generateId()); + var checkboxId = fieldname.replace(/\./, '_'); + var prefix = data.amsCheckerHiddenPrefix; + var hidden = null; + var checkedValue = data.amsCheckerHiddenValueOn || 'true'; + var uncheckedValue = data.amsCheckerHiddenValueOff || 'false'; + var marker = data.amsCheckerMarker || false; + if (prefix) { + hidden = $('').attr('name', prefix + fieldname) + .val(data.amsCheckerState === 'on' ? checkedValue : uncheckedValue) + .prependTo(legend); + } else if (marker) { + $('').attr('name', marker) + .attr('value', 1) + .prependTo(legend); + } + var input = $('').attr('name', fieldname) + .attr('id', checkboxId) + .data('ams-checker-hidden-input', hidden) + .data('ams-checker-init', true) + .val(data.amsCheckerValue || true) + .attr('checked', data.amsCheckerState === 'on' ? 'checked' : null); + if (data.amsCheckerReadonly) { + input.attr('disabled', 'disabled'); + } else { + input.on('change', function(e) { + e.preventDefault(); + var veto = {}; + var isChecked = $(this).is(':checked'); + legend.trigger('ams.checker.before-switch', [legend, veto]); + if (veto.veto) { + // reset checked status because event is fired after change... + $(this).prop('checked', !isChecked); + return; + } + ams.executeFunctionByName(data.amsCheckerChangeHandler, legend, isChecked); + if (!data.amsCheckerCancelDefault) { + var hidden = input.data('ams-checker-hidden-input'); + if (isChecked) { + if (data.amsCheckerMode === 'disable') { + fieldset.removeAttr('disabled'); + $('.select2', fieldset).removeAttr('disabled'); + } else { + fieldset.removeClass('switched'); + } + if (hidden) { + hidden.val(checkedValue); + } + $('[data-required]', fieldset).attr('required', 'required'); + legend.trigger('ams.checker.opened', [legend]); + } else { + if (data.amsCheckerMode === 'disable') { + fieldset.prop('disabled', 'disabled'); + $('.select2', fieldset).attr('disabled', 'disabled'); + } else { + fieldset.addClass('switched'); + } + if (hidden) { + hidden.val(uncheckedValue); + } + $('[data-required]', fieldset).removeAttr('required'); + legend.trigger('ams.checker.closed', [legend]); + } + } + }); + } + input.appendTo(checker); + $('>label', legend).attr('for', input.attr('id')); + checker.append('') + .prependTo(legend); + var required = $('[required]', fieldset); + required.attr('data-required', true); + if (data.amsCheckerState === 'on') { + input.attr('checked', true); + } else { + if (data.amsCheckerMode === 'disable') { + fieldset.attr('disabled', 'disabled'); + $('.select2', fieldset).attr('disabled', 'disabled'); + } else { + fieldset.addClass('switched'); + } + required.removeAttr('required'); + } + legend.data('ams-checker', 'on'); + } + }); + }, + + /** + * Sliders + */ + slider: function(element) { + var sliders = $('.slider', element); + if (sliders.length > 0) { + ams.ajax.check($.fn.slider, + ams.baseURL + 'ext/bootstrap-slider-2.0.0' + ams.devext + '.js', + function() { + sliders.each(function() { + var slider = $(this); + var data = slider.data(); + var dataOptions = {}; + var settings = $.extend({}, dataOptions, slider.data.amsSliderOptions); + settings = ams.executeFunctionByName(data.amsSliderInitCallback, slider, settings) || settings; + var plugin = slider.slider(settings); + ams.executeFunctionByName(data.amsSliderAfterInitCallback, slider, plugin, settings); + }); + }); + } + }, + + /** + * Draggable plug-in + */ + draggable: function(element) { + var draggables = $('.draggable', element); + if (draggables.length > 0) { + draggables.each(function() { + var draggable = $(this); + var data = draggable.data(); + var dataOptions = { + cursor: data.amsDraggableCursor || 'move', + containment: data.amsDraggableContainment, + handle: data.amsDraggableHandle, + connectToSortable: data.amsDraggableConnectSortable, + helper: ams.getFunctionByName(data.amsDraggableHelper) || data.amsDraggableHelper, + start: ams.getFunctionByName(data.amsDraggableStart), + stop: ams.getFunctionByName(data.amsDraggableStop) + }; + var settings = $.extend({}, dataOptions, data.amsDraggableOptions); + settings = ams.executeFunctionByName(data.amsDraggableInitCallback, draggable, settings) || settings; + var plugin = draggable.draggable(settings); + draggable.disableSelection(); + ams.executeFunctionByName(data.amsDraggableAfterInitCallback, draggable, plugin, settings); + }); + } + }, + + /** + * Droppable plug-in + */ + droppable: function(element) { + var droppables = $('.droppable', element); + if (droppables.length > 0) { + droppables.each(function() { + var droppable = $(this); + var data = droppable.data(); + var dataOptions = { + accept: data.amsdroppableAccept, + drop: ams.getFunctionByName(data.amsDroppableDrop) + }; + var settings = $.extend({}, dataOptions, data.amsDroppableOptions); + settings = ams.executeFunctionByName(data.amsDroppableInitCallback, droppable, settings) || settings; + var plugin = droppable.droppable(settings); + ams.executeFunctionByName(data.amsDroppableAfterInitCallback, droppable, plugin, settings); + }); + } + }, + + /** + * Sortable plug-in + */ + sortable: function(element) { + var sortables = $('.sortable', element); + if (sortables.length > 0) { + sortables.each(function() { + var sortable = $(this); + var data = sortable.data(); + var dataOptions = { + items: data.amsSortableItems, + handle: data.amsSortableHandle, + helper: data.amsSortableHelper, + connectWith: data.amsSortableConnectwith, + start: ams.getFunctionByName(data.amsSortableStart), + over: ams.getFunctionByName(data.amsSortableOver), + containment: data.amsSortableContainment, + placeholder: data.amsSortablePlaceholder, + stop: ams.getFunctionByName(data.amsSortableStop) + }; + var settings = $.extend({}, dataOptions, data.amsSortableOptions); + settings = ams.executeFunctionByName(data.amsSortableInitCallback, sortable, settings) || settings; + var plugin = sortable.sortable(settings); + sortable.disableSelection(); + ams.executeFunctionByName(data.amsSortableAfterInitCallback, sortable, plugin, settings); + }); + } + }, + + /** + * Resizable plug-in + */ + resizable: function(element) { + var resizables = $('.resizable', element); + if (resizables.length > 0) { + resizables.each(function() { + var resizable = $(this); + var data = resizable.data(); + var dataOptions = { + autoHide: data.amsResizableAutohide === false ? true : data.amsResizableAutohide, + containment: data.amsResizableContainment, + grid: data.amsResizableGrid, + handles: data.amsResizableHandles, + start: ams.getFunctionByName(data.amsResizableStart), + stop: ams.getFunctionByName(data.amsResizableStop) + }; + var settings = $.extend({}, dataOptions, data.amsResizableOptions); + settings = ams.executeFunctionByName(data.amsResizableInitCallback, resizable, settings) || settings; + var plugin = resizable.resizable(settings); + resizable.disableSelection(); + ams.executeFunctionByName(data.amsResizableAfterInitCallback, resizable, plugin, settings); + }); + } + }, + + /** + * JQuery typeahead plug-in + */ + typeahead: function(element) { + var typeaheads = $('.typeahead', element); + if (typeaheads.length > 0) { + ams.ajax.check($.fn.typeahead, + ams.baseURL + 'ext/jquery-typeahead' + ams.devext + '.js', + function() { + typeaheads.each(function() { + var input = $(this); + var data = input.data(); + var dataOptions = {}; + var settings = $.extend({}, dataOptions, data.amsTypeaheadOptions); + settings = ams.executeFunctionByName(data.amsTypeaheadInitCallback, input, settings) || settings; + var plugin = input.typeahead(settings); + ams.executeFunctionByName(data.amsTypeaheadAfterInitCallback, input, plugin, settings); + }); + }); + } + }, + + /** + * Treeview plug-in + */ + treeview: function(element) { + var treeviews = $('.treeview', element); + if (treeviews.length > 0) { + ams.ajax.check($.fn.treview, + ams.baseURL + 'ext/bootstrap-treeview' + ams.devext + '.js', + function() { + ams.getCSS(ams.baseURL + '../css/ext/bootstrap-treeview' + ams.devext + '.css', + 'bootstrap-treeview', + function() { + treeviews.each(function () { + var treeview = $(this); + var data = treeview.data(); + var dataOptions = { + data: data.amsTreeviewData, + levels: data.amsTreeviewLevels, + injectStyle: data.amsTreeviewInjectStyle, + expandIcon: data.amsTreeviewExpandIcon || 'fa fa-fw fa-plus-square-o', + collapseIcon: data.amsTreeviewCollaspeIcon || 'fa fa-fw fa-minus-square-o', + emptyIcon: data.amsTreeviewEmptyIcon || 'fa fa-fw', + nodeIcon: data.amsTreeviewNodeIcon, + selectedIcon: data.amsTreeviewSelectedIcon, + checkedIcon: data.amsTreeviewCheckedIcon || 'fa fa-fw fa-check-square-o', + uncheckedIcon: data.amsTreeviewUncheckedIcon || 'fa fa-fw fa-square-o', + color: data.amsTreeviewColor, + backColor: data.amsTreeviewBackColor, + borderColor: data.amsTreeviewBorderColor, + onHoverColor: data.amsTreeviewHoverColor, + selectedColor: data.amsTreeviewSelectedColor, + selectedBackColor: data.amsTreeviewSelectedBackColor, + unselectableColor: data.amsTreeviewUnselectableColor || 'rgba(1,1,1,0.25)', + unselectableBackColor: data.amsTreeviewUnselectableBackColor || 'rgba(1,1,1,0.25)', + enableLinks: data.amsTreeviewEnableLinks, + highlightSelected: data.amsTreeviewHighlightSelected, + highlightSearchResults: data.amsTreeviewhighlightSearchResults, + showBorder: data.amsTreeviewShowBorder, + showIcon: data.amsTreeviewShowIcon, + showCheckbox: data.amsTreeviewShowCheckbox, + showTags: data.amsTreeviewShowTags, + toggleUnselectable: data.amsTreeviewToggleUnselectable, + multiSelect: data.amsTreeviewMultiSelect, + onNodeChecked: ams.getFunctionByName(data.amsTreeviewNodeChecked), + onNodeCollapsed: ams.getFunctionByName(data.amsTreeviewNodeCollapsed), + onNodeDisabled: ams.getFunctionByName(data.amsTreeviewNodeDisabled), + onNodeEnabled: ams.getFunctionByName(data.amsTreeviewNodeEnabled), + onNodeExpanded: ams.getFunctionByName(data.amsTreeviewNodeExpanded), + onNodeSelected: ams.getFunctionByName(data.amsTreeviewNodeSelected), + onNodeUnchecked: ams.getFunctionByName(data.amsTreeviewNodeUnchecked), + onNodeUnselected: ams.getFunctionByName(data.amsTreeviewNodeUnselected), + onSearchComplete: ams.getFunctionByName(data.amsTreeviewSearchComplete), + onSearchCleared: ams.getFunctionByName(data.amsTreeviewSearchCleared) + }; + var settings = $.extend({}, dataOptions, data.amsTreeviewOptions); + settings = ams.executeFunctionByName(data.amsTreeviewInitcallback, treeview, settings) || settings; + var plugin = treeview.treeview(settings); + ams.executeFunctionByName(data.amsTreeviewAfterInitCallback, treeview, plugin, settings); + }); + }); + }); + } + }, + + /** + * Select2 plug-in + */ + select2: function(element) { + var selects = $('.select2', element); + if (selects.length > 0) { + ams.ajax.check($.fn.select2, + ams.baseURL + 'ext/jquery-select2-3.5.4' + ams.devext + '.js', + function() { + selects.each(function() { + var select = $(this); + var data = select.data(); + if (data.select2) { + // Already initialized + return; + } + var dataOptions = { + placeholder: data.amsSelect2Placeholder, + multiple: data.amsSelect2Multiple, + minimumInputLength: data.amsSelect2MinimumInputLength || 0, + maximumSelectionSize: data.amsSelect2MaximumSelectionSize, + openOnEnter: data.amsSelect2EnterOpen === undefined ? true : data.amsSelect2EnterOpen, + allowClear: data.amsSelect2AllowClear === undefined ? true : data.amsSelect2AllowClear, + width: data.amsSelect2Width || '100%', + initSelection: ams.getFunctionByName(data.amsSelect2InitSelection), + formatSelection: data.amsSelect2FormatSelection === undefined ? + ams.helpers.select2FormatSelection + : ams.getFunctionByName(data.amsSelect2FormatSelection), + formatResult: ams.getFunctionByName(data.amsSelect2FormatResult), + formatMatches: data.amsSelect2FormatMatches === undefined ? + function(matches) { + if (matches === 1) { + return ams.i18n.SELECT2_MATCH; + } else { + return matches + ams.i18n.SELECT2_MATCHES; + } + } + : ams.getFunctionByName(data.amsSelect2FormatMatches), + formatNoMatches: data.amsSelect2FormatResult === undefined ? + function(term) { + return ams.i18n.SELECT2_NOMATCHES; + } + : ams.getFunctionByName(data.amsSelect2FormatResult), + formatInputTooShort: data.amsSelect2FormatInputTooShort === undefined ? + function(input, min) { + var n = min - input.length; + return ams.i18n.SELECT2_INPUT_TOOSHORT + .replace(/\{0\}/, n) + .replace(/\{1\}/, n === 1 ? "" : ams.i18n.SELECT2_PLURAL); + } + : ams.getFunctionByName(data.amsSelect2FormatInputTooShort), + formatInputTooLong: data.amsSelect2FormatInputTooLong === undefined ? + function(input, max) { + var n = input.length - max; + return ams.i18n.SELECT2_INPUT_TOOLONG + .replace(/\{0\}/, n) + .replace(/\{1\}/, n === 1 ? "" : ams.i18n.SELECT2_PLURAL); + } + : ams.getFunctionByName(data.amsSelect2FormatInputTooLong), + formatSelectionTooBig: data.amsSelect2FormatSelectionTooBig === undefined ? + function(limit) { + return ams.i18n.SELECT2_SELECTION_TOOBIG + .replace(/\{0\}/, limit) + .replace(/\{1\}/, limit === 1 ? "" : ams.i18n.SELECT2_PLURAL); + } + : ams.getFunctionByName(data.amsSelect2FormatSelectionTooBig), + formatLoadMore: data.amsSelect2FormatLoadMore === undefined ? + function (pageNumber) { + return ams.i18n.SELECT2_LOADMORE; + } + : ams.getFunctionByName(data.amsSelect2FormatLoadMore), + formatSearching: data.amsSelect2FormatSearching === undefined ? + function() { + return ams.i18n.SELECT2_SEARCHING; + } + : ams.getFunctionByName(data.amsSelect2FormatSearching), + separator: data.amsSelect2Separator || ',', + tokenSeparators: data.amsSelect2TokensSeparators || [','], + tokenizer: ams.getFunctionByName(data.amsSelect2Tokenizer) + }; + + switch (select.context.type) { + case 'text': + case 'hidden': + if (!dataOptions.initSelection) { + var valuesData = select.data('ams-select2-values'); + if (valuesData) { + dataOptions.initSelection = function(element, callback) { + var data = []; + $(element.val().split(dataOptions.separator)).each(function() { + data.push({id: this, + text: valuesData[this] || this}); + }); + callback(data); + }; + } + } + break; + default: + break; + } + + if (select.attr('readonly')) { + if (select.attr('type') === 'hidden') { + dataOptions.query = function () { + return []; + }; + } + } else if (data.amsSelect2Query) { + // Custom query method + dataOptions.query = ams.getFunctionByName(data.amsSelect2Query); + dataOptions.minimumInputLength = data.amsSelect2MinimumInputLength || 1; + } else if (data.amsSelect2QueryUrl) { + // AJAX query + dataOptions.ajax = { + url: data.amsSelect2QueryUrl, + quietMillis: data.amsSelect2QuietMillis || 200, + type: data.amsSelect2QueryType || 'POST', + dataType: data.amsSelect2QueryDatatype || 'json', + data: function(term, page, context) { + var options = {}; + options[data.amsSelect2QueryParamName || 'query'] = term; + options[data.amsSelect2PageParamName || 'page'] = page; + options[data.amsSelect2ContextParamName || 'context'] = context; + return $.extend({}, options, data.amsSelect2QueryOptions); + }, + results: ams.helpers.select2QueryUrlResultsCallback + }; + dataOptions.minimumInputLength = data.amsSelect2MinimumInputLength || 1; + } else if (data.amsSelect2QueryMethod) { + // JSON-RPC query + dataOptions.query = function(options) { + var settings = { + id: new Date().getTime(), + params: data.amsSelect2QueryParams || {}, + success: function(result) { + return ams.helpers.select2QueryMethodSuccessCallback.call(select, result, 'success', options); + }, + error: ams.error.show + }; + settings.params[data.amsSelect2QueryParamName || 'query'] = options.term; + settings.params[data.amsSelect2PageParamName || 'page'] = options.page; + settings.params[data.amsSelect2ContextParamName || 'context'] = options.context; + settings = $.extend({}, settings, data.amsSelect2QueryOptions); + settings = ams.executeFunctionByName(data.amsSelect2QueryInitCallback, select, settings) || settings; + ams.ajax.check($.jsonRPC, + ams.baseURL + 'ext/jquery-jsonrpc' + ams.devext + '.js', + function() { + $.jsonRPC.withOptions({ + endPoint: data.amsSelect2MethodTarget || ams.jsonrpc.getAddr(), + namespace: data.amsSelect2MethodNamespace, + cache: false + }, function() { + $.jsonRPC.request(data.amsSelect2QueryMethod, settings); + }); + }); + }; + dataOptions.minimumInputLength = data.amsSelect2MinimumInputLength || 1; + } else if (data.amsSelect2Tags) { + // Tags mode + dataOptions.tags = data.amsSelect2Tags; + } else if (data.amsSelect2Data) { + // Provided data mode + dataOptions.data = data.amsSelect2Data; + } + + if (data.amsSelect2EnableFreeTags) { + dataOptions.createSearchChoice = function(term) { + return {id: term, + text: (data.amsSelect2FreeTagsPrefix || ams.i18n.SELECT2_FREETAG_PREFIX) + term}; + }; + } + + var settings = $.extend({}, dataOptions, data.amsSelect2Options); + settings = ams.executeFunctionByName(data.amsSelect2InitCallback, select, settings) || settings; + var plugin = select.select2(settings); + ams.executeFunctionByName(data.amsSelect2AfterInitCallback, select, plugin, settings); + if (select.hasClass('ordered')) { + ams.ajax.check($.fn.select2Sortable, + ams.baseURL + 'ext/jquery-select2-sortable' + ams.devext + '.js', + function() { + select.select2Sortable({ + bindOrder: 'sortableStop' + }); + }); + } + + select.on('change', function() { + var validator = $(select.get(0).form).data('validator'); + if (validator !== undefined) { + $(select).valid(); + } + }); + }); + }); + } + }, + + /** + * Edit mask plug-in + */ + maskedit: function(element) { + var masks = $('[data-mask]', element); + if (masks.length > 0) { + ams.ajax.check($.fn.mask, + ams.baseURL + 'ext/jquery-maskedinput-1.4.1' + ams.devext + '.js', + function() { + masks.each(function() { + var mask = $(this); + var data = mask.data(); + var dataOptions = { + placeholder: data.amsMaskeditPlaceholder === undefined ? 'X' : data.amsMaskeditPlaceholder, + complete: ams.getFunctionByName(data.amsMaskeditComplete) + }; + var settings = $.extend({}, dataOptions, data.amsMaskeditOptions); + settings = ams.executeFunctionByName(data.amsMaskeditInitCallback, mask, settings) || settings; + var plugin = mask.mask(mask.attr('data-mask'), settings); + ams.executeFunctionByName(data.amsMaskeditAfterInitCallback, mask, plugin, settings); + }); + }); + } + }, + + /** + * JQuery input-mask plug-in + * + * Mask value can be set in a "data-input-mask" attribute defined: + * - as a simple string containing mask + * - as a JSON object defining all mask attributes, for example: + * data-input-mask='{"alias": "integer", "allowPlus": false, "allowMinus": false}' + */ + inputmask: function(element) { + var masks = $('input[data-input-mask]', element); + if (masks.length > 0) { + ams.ajax.check($.fn.inputmask, + ams.baseURL + 'ext/jquery-inputmask-bundle-3.2.8' + ams.devext + '.js', + function() { + masks.each(function() { + var input = $(this); + var data = input.data(); + var dataOptions; + if (typeof(data.inputMask) === 'object') { + dataOptions = data.inputMask; + } else { + dataOptions = { + mask: data.inputMask.toString() + }; + } + var settings = $.extend({}, dataOptions, data.amsInputmaskOptions); + settings = ams.executeFunctionByName(data.amsInputmaskInitCallback, input, settings) || settings; + var plugin = input.inputmask(settings); + ams.executeFunctionByName(data.amsInputmaskAfterInitCallback, input, plugin, settings); + }); + }); + } + }, + + /** + * JQuery date picker + */ + datepicker: function(element) { + var datepickers = $('.datepicker', element); + if (datepickers.length > 0) { + ams.ajax.check($.fn.datetimepicker, + ams.baseURL + 'ext/jquery-datetimepicker' + ams.devext + '.js', + function(first_load) { + if (first_load) { + ams.dialog.registerHideCallback(ams.helpers.datetimepickerDialogHiddenCallback); + } + ams.getCSS(ams.baseURL + '../css/ext/jquery-datetimepicker' + ams.devext + '.css', + 'jquery-datetimepicker', + function () { + datepickers.each(function () { + var input = $(this); + var data = input.data(); + var dataOptions = { + lang: data.amsDatetimepickerLang || ams.lang, + format: data.amsDatetimepickerFormat || 'd/m/y', + datepicker: true, + dayOfWeekStart: 1, + timepicker: false, + closeOnDateSelect: data.amsDatetimepickerCloseOnSelect === undefined ? true : data.amsDatetimepickerCloseOnSelect, + weeks: data.amsDatetimepickerWeeks + }; + var settings = $.extend({}, dataOptions, data.amsDatetimepickerOptions); + settings = ams.executeFunctionByName(data.amsDatetimepickerInitCallback, input, settings) || settings; + var plugin = input.datetimepicker(settings); + ams.executeFunctionByName(data.amsDatetimepickerAfterInitCallback, input, plugin, settings); + }); + }); + }); + } + }, + + /** + * JQuery datetime picker + */ + datetimepicker: function(element) { + var datetimepickers = $('.datetimepicker', element); + if (datetimepickers.length > 0) { + ams.ajax.check($.fn.datetimepicker, + ams.baseURL + 'ext/jquery-datetimepicker' + ams.devext + '.js', + function(first_load) { + if (first_load) { + ams.dialog.registerHideCallback(ams.helpers.datetimepickerDialogHiddenCallback); + } + ams.getCSS(ams.baseURL + '../css/ext/jquery-datetimepicker' + ams.devext + '.css', + 'jquery-datetimepicker', + function () { + datetimepickers.each(function () { + var input = $(this); + var data = input.data(); + var dataOptions = { + lang: data.amsDatetimepickerLang || ams.lang, + format: data.amsDatetimepickerFormat || 'd/m/y H:i', + datepicker: true, + dayOfWeekStart: 1, + timepicker: true, + closeOnDateSelect: data.amsDatetimepickerCloseOnSelect === undefined ? true : data.amsDatetimepickerCloseOnSelect, + closeOnTimeSelect: data.amsDatetimepickerCloseOnSelect === undefined ? true : data.amsDatetimepickerCloseOnSelect, + weeks: data.amsDatetimepickerWeeks + }; + var settings = $.extend({}, dataOptions, data.amsDatetimepickerOptions); + settings = ams.executeFunctionByName(data.amsDatetimepickerInitCallback, input, settings) || settings; + var plugin = input.datetimepicker(settings); + ams.executeFunctionByName(data.amsDatetimepickerAfterInitCallback, input, plugin, settings); + }); + }); + }); + } + }, + + /** + * JQuery time picker + */ + timepicker: function(element) { + var timepickers = $('.timepicker', element); + if (timepickers.length > 0) { + ams.ajax.check($.fn.datetimepicker, + ams.baseURL + 'ext/jquery-datetimepicker' + ams.devext + '.js', + function(first_load) { + if (first_load) { + ams.dialog.registerHideCallback(ams.helpers.datetimepickerDialogHiddenCallback); + } + ams.getCSS(ams.baseURL + '../css/ext/jquery-datetimepicker' + ams.devext + '.css', + 'jquery-datetimepicker', + function() { + timepickers.each(function () { + var input = $(this); + var data = input.data(); + var dataOptions = { + lang: data.amsDatetimepickerLang || ams.lang, + format: data.amsDatetimepickerFormat || 'H:i', + datepicker: false, + timepicker: true, + closeOnTimeSelect: data.amsDatetimepickerCloseOnSelect === undefined ? true : data.amsDatetimepickerCloseOnSelect + }; + var settings = $.extend({}, dataOptions, data.amsDatetimepickerOptions); + settings = ams.executeFunctionByName(data.amsDatetimepickerInitCallback, input, settings) || settings; + var plugin = input.datetimepicker(settings); + ams.executeFunctionByName(data.amsDatetimepickerAfterInitCallback, input, plugin, settings); + }); + }); + }); + } }, /** - * Map of enabled plug-ins - * This map can be extended by external plug-ins. - * - * Standard MyAMS plug-ins management method generally includes: - * - applying a class matching plug-in name on a set of HTML entities to apply the plug-in - * - defining a set of data-attributes on each of these entities to customize the plug-in - * For each standard plug-in, you can also provide an options object (to define plug-in options not handled - * by default MyAMS initialization engine) and an initialization callback (to define these options dynamically). - * Another callback can also be provided to be called after plug-in initialization. - * - * You can also register plug-ins using the 'register' function + * JQuery color picker + */ + colorpicker: function(element) { + var colorpickers = $('.colorpicker', element); + if (colorpickers.length > 0) { + ams.ajax.check($.fn.minicolors, + ams.baseURL + 'ext/jquery-minicolors' + ams.devext + '.js', + function() { + ams.getCSS(ams.baseURL + '../css/ext/jquery-minicolors' + ams.devext + '.css', + 'jquery-minicolors', + function () { + colorpickers.each(function () { + var input = $(this); + var data = input.data(); + var dataOptions = { + position: data.amsColorpickerPosition || input.closest('.input').data('ams-colorpicker-position') || 'bottom left' + }; + var settings = $.extend({}, dataOptions, data.amsColorpickerOptions); + settings = ams.executeFunctionByName(data.amsColorpickerInitCallback, input, settings) || settings; + var plugin = input.minicolors(settings); + ams.executeFunctionByName(data.amsDatetimepickerAfterInitCallback, input, plugin, settings); + }); + }); + }); + } + }, + + /** + * Drag & drop upload plug-in */ - enabled: { - - /** - * SVG containers - */ - svg: function(element) { - var svgs = $('.svg-container', element); - if (svgs.length > 0) { - svgs.each(function() { - var container = $(this); - var svg = $('svg', container), - width = svg.attr('width'), - height = svg.attr('height'); - if (width && height) { - svg.get(0).setAttribute('viewBox', - '0 0 ' + Math.round(parseFloat(width)) + ' ' + - Math.round(parseFloat(height))); - } - svg.attr('width', '100%') - .attr('height', 'auto'); - }) - } - }, - - /** - * Label hints - */ - hint: function(element) { - var hints = $('.hint:not(:parents(.nohints))', element); - if (hints.length > 0) { - ams.ajax.check($.fn.tipsy, - ams.baseURL + 'ext/jquery-tipsy' + ams.devext + '.js', - function() { - ams.getCSS(ams.baseURL + '../css/ext/jquery-tipsy' + ams.devext + '.css', - 'jquery-tipsy', function() { - hints.each(function () { - var hint = $(this); - var data = hint.data(); - var dataOptions = { - html: data.amsHintHtml === undefined ? (hint.attr('title') || '').startsWith('<') : data.amsHintHtml, - title: ams.getFunctionByName(data.amsHintTitleGetter) || function () { - var hint = $(this); - var result = hint.attr('original-title') || - hint.attr(data.amsHintTitleAttr || 'title') || - (data.amsHintHtml ? hint.html() : hint.text()); - result = result.replace(/\?_="/, '?_=' + new Date().getTime() + '"'); - return result; - }, - opacity: data.amsHintOpacity || 0.95, - gravity: data.amsHintGravity || 'sw', - offset: data.amsHintOffset || 0 - }; - var settings = $.extend({}, dataOptions, data.amsHintOptions); - settings = ams.executeFunctionByName(data.amsHintInitCallback, hint, settings) || settings; - var plugin = hint.tipsy(settings); - ams.executeFunctionByName(data.amsHintAfterInitCallback, hint, plugin, settings); - }); - }); - }); - } - }, - - /** - * Context menu plug-in - */ - contextMenu: function(element) { - var menus = $('.context-menu', element); - if (menus.length > 0) { - menus.each(function() { - var menu = $(this); - var data = menu.data(); - var dataOptions = { - menuSelector: data.amsContextmenuSelector, - menuSelected: ams.helpers.contextMenuHandler - }; - var settings = $.extend({}, dataOptions, data.amsContextmenuOptions); - settings = ams.executeFunctionByName(data.amsContextmenuInitCallback, menu, settings) || settings; - var plugin = menu.contextMenu(settings); - ams.executeFunctionByName(data.amsContextmenuAfterInitCallback, menu, plugin, settings); - }); - } - }, - - /** - * Fieldset legend switcher - */ - switcher: function(element) { - $('LEGEND.switcher', element).each(function() { - var legend = $(this); - var fieldset = legend.parent('fieldset'); - var data = legend.data(); - if (!data.amsSwitcher) { - $('') - .prependTo($(this)) - .addClass(data.amsSwitcherState === 'open' ? - (data.amsSwitcherMinusClass || 'fa-minus') : - (data.amsSwitcherPlusClass || 'fa-plus')); - legend.on('click', function(e) { - e.preventDefault(); - var veto = {}; - legend.trigger('ams.switcher.before-switch', [legend, veto]); - if (veto.veto) { - return; - } - if (fieldset.hasClass('switched')) { - fieldset.removeClass('switched'); - $('.fa', legend).removeClass(data.amsSwitcherPlusClass || 'fa-plus') - .addClass(data.amsSwitcherMinusClass || 'fa-minus'); - legend.trigger('ams.switcher.opened', [legend]); - var id = legend.attr('id'); - if (id) { - $('legend.switcher[data-ams-switcher-sync="'+id+'"]', fieldset).each(function() { - var switcher = $(this); - if (switcher.parents('fieldset').hasClass('switched')) { - switcher.click(); + dndupload: function(element) { + var uploads = $('.dndupload', element); + if (uploads.length > 0) { + ams.ajax.check($.fn.dndupload, + ams.baseURL + 'ext/jquery-dndupload' + ams.devext + '.js', + function() { + ams.getCSS(ams.baseURL + '../css/ext/jquery-dndupload' + ams.devext + '.css', + 'jquery-dndupload', + function () { + uploads.each(function () { + var upload = $(this); + var data = upload.data(); + var dataOptions = { + action: data.amsDnduploadAction || upload.attr('action') || 'upload-files', + fieldname: data.amsDnduploadFieldname || 'files', + autosubmit: data.amsDnduploadAutosubmit + }; + var settings = $.extend({}, dataOptions, data.amsDnduploadOptions); + settings = ams.executeFunctionByName(data.amsDnduploadInitCallback, upload, settings) || settings; + var plugin = upload.dndupload(settings); + ams.executeFunctionByName(data.amsDnduploadAfterInitcallback, upload, plugin, settings); + }); + }); + }); + } + }, + + /** + * JQuery validation plug-in + */ + validate: function(element) { + var forms = $('FORM:not([novalidate])', element); + if (forms.length > 0) { + ams.ajax.check($.fn.validate, + ams.baseURL + 'ext/jquery-validate-1.17.0' + ams.devext + '.js', + function(first_load) { + if (first_load) { + $.validator.setDefaults({ + highlight: function(element) { + $(element).closest('.form-group, label:not(:parents(.form-group))').addClass('state-error'); + }, + unhighlight: function(element) { + $(element).closest('.form-group, label:not(:parents(.form-group))').removeClass('state-error'); + }, + errorElement: 'span', + errorClass: 'state-error', + errorPlacement: function(error, element) { + var label = element.parents('label:first'); + if (label.length) { + error.insertAfter(label); + } else { + error.insertAfter(element); + } + } + }); + if (ams.plugins.i18n) { + for (var key in ams.plugins.i18n.validate) { + if (!ams.plugins.i18n.validate.hasOwnProperty(key)) { + continue; + } + var message = ams.plugins.i18n.validate[key]; + if ((typeof(message) === 'string') && + (message.indexOf('{0}') > -1)) { + ams.plugins.i18n.validate[key] = $.validator.format(message); + } + } + $.extend($.validator.messages, ams.plugins.i18n.validate); } - }); - } - } else { - fieldset.addClass('switched'); - $('.fa', legend).removeClass(data.amsSwitcherMinusClass || 'fa-minus') - .addClass(data.amsSwitcherPlusClass || 'fa-plus'); - legend.trigger('ams.switcher.closed', [legend]); - } - }); - if (data.amsSwitcherState !== 'open') { - fieldset.addClass('switched'); - } - legend.data('ams-switcher', 'on'); - } - }); - }, - - /** - * Fieldset legend checker - */ - checker: function(element) { - $('LEGEND.checker', element).each(function() { - var legend = $(this); - var fieldset = legend.parent('fieldset'); - var data = legend.data(); - if (!data.amsChecker) { - var checker = $(''); - var fieldname = data.amsCheckerFieldname || ('checker_'+ams.generateId()); - var checkboxId = fieldname.replace(/\./, '_'); - var prefix = data.amsCheckerHiddenPrefix; - var hidden = null; - var checkedValue = data.amsCheckerHiddenValueOn || 'true'; - var uncheckedValue = data.amsCheckerHiddenValueOff || 'false'; - var marker = data.amsCheckerMarker || false; - if (prefix) { - hidden = $('').attr('name', prefix + fieldname) - .val(data.amsCheckerState === 'on' ? checkedValue : uncheckedValue) - .prependTo(legend); - } else if (marker) { - $('').attr('name', marker) - .attr('value', 1) - .prependTo(legend); - } - var input = $('').attr('name', fieldname) - .attr('id', checkboxId) - .data('ams-checker-hidden-input', hidden) - .data('ams-checker-init', true) - .val(data.amsCheckerValue || true) - .attr('checked', data.amsCheckerState === 'on' ? 'checked' : null); - if (data.amsCheckerReadonly) { - input.attr('disabled', 'disabled'); - } else { - input.on('change', function(e) { - e.preventDefault(); - var veto = {}; - var isChecked = $(this).is(':checked'); - legend.trigger('ams.checker.before-switch', [legend, veto]); - if (veto.veto) { - // reset checked status because event is fired after change... - $(this).prop('checked', !isChecked); - return; - } - ams.executeFunctionByName(data.amsCheckerChangeHandler, legend, isChecked); - if (!data.amsCheckerCancelDefault) { - var hidden = input.data('ams-checker-hidden-input'); - if (isChecked) { - if (data.amsCheckerMode === 'disable') { - fieldset.removeAttr('disabled'); - $('.select2', fieldset).removeAttr('disabled'); - } else { - fieldset.removeClass('switched'); - } - if (hidden) { - hidden.val(checkedValue); - } - $('[data-required]', fieldset).attr('required', 'required'); - legend.trigger('ams.checker.opened', [legend]); - } else { - if (data.amsCheckerMode === 'disable') { - fieldset.prop('disabled', 'disabled'); - $('.select2', fieldset).attr('disabled', 'disabled'); - } else { - fieldset.addClass('switched'); - } - if (hidden) { - hidden.val(uncheckedValue); - } - $('[data-required]', fieldset).removeAttr('required'); - legend.trigger('ams.checker.closed', [legend]); } - } - }); - } - input.appendTo(checker); - $('>label', legend).attr('for', input.attr('id')); - checker.append('') - .prependTo(legend); - var required = $('[required]', fieldset); - required.attr('data-required', true); - if (data.amsCheckerState === 'on') { - input.attr('checked', true); - } else { - if (data.amsCheckerMode === 'disable') { - fieldset.attr('disabled', 'disabled'); - $('.select2', fieldset).attr('disabled', 'disabled'); - } else { - fieldset.addClass('switched'); - } - required.removeAttr('required'); - } - legend.data('ams-checker', 'on'); - } - }); - }, - - /** - * Sliders - */ - slider: function(element) { - var sliders = $('.slider', element); - if (sliders.length > 0) { - ams.ajax.check($.fn.slider, - ams.baseURL + 'ext/bootstrap-slider-2.0.0' + ams.devext + '.js', - function() { - sliders.each(function() { - var slider = $(this); - var data = slider.data(); - var dataOptions = {}; - var settings = $.extend({}, dataOptions, slider.data.amsSliderOptions); - settings = ams.executeFunctionByName(data.amsSliderInitCallback, slider, settings) || settings; - var plugin = slider.slider(settings); - ams.executeFunctionByName(data.amsSliderAfterInitCallback, slider, plugin, settings); - }); - }); - } - }, - - /** - * Draggable plug-in - */ - draggable: function(element) { - var draggables = $('.draggable', element); - if (draggables.length > 0) { - draggables.each(function() { - var draggable = $(this); - var data = draggable.data(); - var dataOptions = { - cursor: data.amsDraggableCursor || 'move', - containment: data.amsDraggableContainment, - handle: data.amsDraggableHandle, - connectToSortable: data.amsDraggableConnectSortable, - helper: ams.getFunctionByName(data.amsDraggableHelper) || data.amsDraggableHelper, - start: ams.getFunctionByName(data.amsDraggableStart), - stop: ams.getFunctionByName(data.amsDraggableStop) - }; - var settings = $.extend({}, dataOptions, data.amsDraggableOptions); - settings = ams.executeFunctionByName(data.amsDraggableInitCallback, draggable, settings) || settings; - var plugin = draggable.draggable(settings); - draggable.disableSelection(); - ams.executeFunctionByName(data.amsDraggableAfterInitCallback, draggable, plugin, settings); - }); - } - }, - - /** - * Droppable plug-in - */ - droppable: function(element) { - var droppables = $('.droppable', element); - if (droppables.length > 0) { - droppables.each(function() { - var droppable = $(this); - var data = droppable.data(); - var dataOptions = { - accept: data.amsdroppableAccept, - drop: ams.getFunctionByName(data.amsDroppableDrop) - }; - var settings = $.extend({}, dataOptions, data.amsDroppableOptions); - settings = ams.executeFunctionByName(data.amsDroppableInitCallback, droppable, settings) || settings; - var plugin = droppable.droppable(settings); - ams.executeFunctionByName(data.amsDroppableAfterInitCallback, droppable, plugin, settings); - }); - } - }, - - /** - * Sortable plug-in - */ - sortable: function(element) { - var sortables = $('.sortable', element); - if (sortables.length > 0) { - sortables.each(function() { - var sortable = $(this); - var data = sortable.data(); - var dataOptions = { - items: data.amsSortableItems, - handle: data.amsSortableHandle, - helper: data.amsSortableHelper, - connectWith: data.amsSortableConnectwith, - start: ams.getFunctionByName(data.amsSortableStart), - over: ams.getFunctionByName(data.amsSortableOver), - containment: data.amsSortableContainment, - placeholder: data.amsSortablePlaceholder, - stop: ams.getFunctionByName(data.amsSortableStop) - }; - var settings = $.extend({}, dataOptions, data.amsSortableOptions); - settings = ams.executeFunctionByName(data.amsSortableInitCallback, sortable, settings) || settings; - var plugin = sortable.sortable(settings); - sortable.disableSelection(); - ams.executeFunctionByName(data.amsSortableAfterInitCallback, sortable, plugin, settings); - }); - } - }, - - /** - * Resizable plug-in - */ - resizable: function(element) { - var resizables = $('.resizable', element); - if (resizables.length > 0) { - resizables.each(function() { - var resizable = $(this); - var data = resizable.data(); - var dataOptions = { - autoHide: data.amsResizableAutohide === false ? true : data.amsResizableAutohide, - containment: data.amsResizableContainment, - grid: data.amsResizableGrid, - handles: data.amsResizableHandles, - start: ams.getFunctionByName(data.amsResizableStart), - stop: ams.getFunctionByName(data.amsResizableStop) - }; - var settings = $.extend({}, dataOptions, data.amsResizableOptions); - settings = ams.executeFunctionByName(data.amsResizableInitCallback, resizable, settings) || settings; - var plugin = resizable.resizable(settings); - resizable.disableSelection(); - ams.executeFunctionByName(data.amsResizableAfterInitCallback, resizable, plugin, settings); - }); - } - }, - - /** - * JQuery typeahead plug-in - */ - typeahead: function(element) { - var typeaheads = $('.typeahead', element); - if (typeaheads.length > 0) { - ams.ajax.check($.fn.typeahead, - ams.baseURL + 'ext/jquery-typeahead' + ams.devext + '.js', - function() { - typeaheads.each(function() { - var input = $(this); - var data = input.data(); - var dataOptions = {}; - var settings = $.extend({}, dataOptions, data.amsTypeaheadOptions); - settings = ams.executeFunctionByName(data.amsTypeaheadInitCallback, input, settings) || settings; - var plugin = input.typeahead(settings); - ams.executeFunctionByName(data.amsTypeaheadAfterInitCallback, input, plugin, settings); - }); - }); - } - }, - - /** - * Treeview plug-in - */ - treeview: function(element) { - var treeviews = $('.treeview', element); - if (treeviews.length > 0) { - ams.ajax.check($.fn.treview, - ams.baseURL + 'ext/bootstrap-treeview' + ams.devext + '.js', - function() { - ams.getCSS(ams.baseURL + '../css/ext/bootstrap-treeview' + ams.devext + '.css', - 'bootstrap-treeview', - function() { - treeviews.each(function () { - var treeview = $(this); - var data = treeview.data(); - var dataOptions = { - data: data.amsTreeviewData, - levels: data.amsTreeviewLevels, - injectStyle: data.amsTreeviewInjectStyle, - expandIcon: data.amsTreeviewExpandIcon || 'fa fa-fw fa-plus-square-o', - collapseIcon: data.amsTreeviewCollaspeIcon || 'fa fa-fw fa-minus-square-o', - emptyIcon: data.amsTreeviewEmptyIcon || 'fa fa-fw', - nodeIcon: data.amsTreeviewNodeIcon, - selectedIcon: data.amsTreeviewSelectedIcon, - checkedIcon: data.amsTreeviewCheckedIcon || 'fa fa-fw fa-check-square-o', - uncheckedIcon: data.amsTreeviewUncheckedIcon || 'fa fa-fw fa-square-o', - color: data.amsTreeviewColor, - backColor: data.amsTreeviewBackColor, - borderColor: data.amsTreeviewBorderColor, - onHoverColor: data.amsTreeviewHoverColor, - selectedColor: data.amsTreeviewSelectedColor, - selectedBackColor: data.amsTreeviewSelectedBackColor, - unselectableColor: data.amsTreeviewUnselectableColor || 'rgba(1,1,1,0.25)', - unselectableBackColor: data.amsTreeviewUnselectableBackColor || 'rgba(1,1,1,0.25)', - enableLinks: data.amsTreeviewEnableLinks, - highlightSelected: data.amsTreeviewHighlightSelected, - highlightSearchResults: data.amsTreeviewhighlightSearchResults, - showBorder: data.amsTreeviewShowBorder, - showIcon: data.amsTreeviewShowIcon, - showCheckbox: data.amsTreeviewShowCheckbox, - showTags: data.amsTreeviewShowTags, - toggleUnselectable: data.amsTreeviewToggleUnselectable, - multiSelect: data.amsTreeviewMultiSelect, - onNodeChecked: ams.getFunctionByName(data.amsTreeviewNodeChecked), - onNodeCollapsed: ams.getFunctionByName(data.amsTreeviewNodeCollapsed), - onNodeDisabled: ams.getFunctionByName(data.amsTreeviewNodeDisabled), - onNodeEnabled: ams.getFunctionByName(data.amsTreeviewNodeEnabled), - onNodeExpanded: ams.getFunctionByName(data.amsTreeviewNodeExpanded), - onNodeSelected: ams.getFunctionByName(data.amsTreeviewNodeSelected), - onNodeUnchecked: ams.getFunctionByName(data.amsTreeviewNodeUnchecked), - onNodeUnselected: ams.getFunctionByName(data.amsTreeviewNodeUnselected), - onSearchComplete: ams.getFunctionByName(data.amsTreeviewSearchComplete), - onSearchCleared: ams.getFunctionByName(data.amsTreeviewSearchCleared) - }; - var settings = $.extend({}, dataOptions, data.amsTreeviewOptions); - settings = ams.executeFunctionByName(data.amsTreeviewInitcallback, treeview, settings) || settings; - var plugin = treeview.treeview(settings); - ams.executeFunctionByName(data.amsTreeviewAfterInitCallback, treeview, plugin, settings); - }); - }); - }); - } - }, - - /** - * Select2 plug-in - */ - select2: function(element) { - var selects = $('.select2', element); - if (selects.length > 0) { - ams.ajax.check($.fn.select2, - ams.baseURL + 'ext/jquery-select2-3.5.4' + ams.devext + '.js', - function() { - selects.each(function() { - var select = $(this); - var data = select.data(); - if (data.select2) { - // Already initialized - return; - } - var dataOptions = { - placeholder: data.amsSelect2Placeholder, - multiple: data.amsSelect2Multiple, - minimumInputLength: data.amsSelect2MinimumInputLength || 0, - maximumSelectionSize: data.amsSelect2MaximumSelectionSize, - openOnEnter: data.amsSelect2EnterOpen === undefined ? true : data.amsSelect2EnterOpen, - allowClear: data.amsSelect2AllowClear === undefined ? true : data.amsSelect2AllowClear, - width: data.amsSelect2Width || '100%', - initSelection: ams.getFunctionByName(data.amsSelect2InitSelection), - formatSelection: data.amsSelect2FormatSelection === undefined ? - ams.helpers.select2FormatSelection - : ams.getFunctionByName(data.amsSelect2FormatSelection), - formatResult: ams.getFunctionByName(data.amsSelect2FormatResult), - formatMatches: data.amsSelect2FormatMatches === undefined ? - function(matches) { - if (matches === 1) { - return ams.i18n.SELECT2_MATCH; - } else { - return matches + ams.i18n.SELECT2_MATCHES; + forms.each(function() { + var form = $(this); + var data = form.data(); + var dataOptions = { + ignore: null, + submitHandler: form.attr('data-async') !== undefined ? + data.amsFormSubmitHandler === undefined ? + function() { + // JQuery-form plug-in must be loaded synchronously!! + // Otherwise, hidden input fields created by jquery-validate plug-in + // and matching named buttons will be deleted (on first form submit) + // before JQuery-form plug-in can get them when submitting the form... + $('.state-error', form).removeClass('state-error'); + ams.ajax.check($.fn.ajaxSubmit, + ams.baseURL + 'ext/jquery-form-3.49' + ams.devext + '.js'); + return ams.form.submit(form); + } + : ams.getFunctionByName(data.amsFormSubmitHandler) + : undefined, + invalidHandler: form.attr('data-async') !== undefined ? + data.amsFormInvalidHandler === undefined ? + function(event, validator) { + $('.state-error', form).removeClass('state-error'); + for (var index=0; index < validator.errorList.length; index++) { + var error = validator.errorList[index]; + var tabIndex = $(error.element).parents('.tab-pane').index() + 1; + if (tabIndex > 0) { + var navTabs = $('.nav-tabs', $(error.element).parents('.tabforms')); + $('li:nth-child(' + tabIndex + ')', navTabs) + .removeClassPrefix('state-') + .addClass('state-error'); + $('li.state-error:first a', navTabs).click(); } } - : ams.getFunctionByName(data.amsSelect2FormatMatches), - formatNoMatches: data.amsSelect2FormatResult === undefined ? - function(term) { - return ams.i18n.SELECT2_NOMATCHES; - } - : ams.getFunctionByName(data.amsSelect2FormatResult), - formatInputTooShort: data.amsSelect2FormatInputTooShort === undefined ? - function(input, min) { - var n = min - input.length; - return ams.i18n.SELECT2_INPUT_TOOSHORT - .replace(/\{0\}/, n) - .replace(/\{1\}/, n === 1 ? "" : ams.i18n.SELECT2_PLURAL); - } - : ams.getFunctionByName(data.amsSelect2FormatInputTooShort), - formatInputTooLong: data.amsSelect2FormatInputTooLong === undefined ? - function(input, max) { - var n = input.length - max; - return ams.i18n.SELECT2_INPUT_TOOLONG - .replace(/\{0\}/, n) - .replace(/\{1\}/, n === 1 ? "" : ams.i18n.SELECT2_PLURAL); - } - : ams.getFunctionByName(data.amsSelect2FormatInputTooLong), - formatSelectionTooBig: data.amsSelect2FormatSelectionTooBig === undefined ? - function(limit) { - return ams.i18n.SELECT2_SELECTION_TOOBIG - .replace(/\{0\}/, limit) - .replace(/\{1\}/, limit === 1 ? "" : ams.i18n.SELECT2_PLURAL); - } - : ams.getFunctionByName(data.amsSelect2FormatSelectionTooBig), - formatLoadMore: data.amsSelect2FormatLoadMore === undefined ? - function (pageNumber) { - return ams.i18n.SELECT2_LOADMORE; - } - : ams.getFunctionByName(data.amsSelect2FormatLoadMore), - formatSearching: data.amsSelect2FormatSearching === undefined ? - function() { - return ams.i18n.SELECT2_SEARCHING; - } - : ams.getFunctionByName(data.amsSelect2FormatSearching), - separator: data.amsSelect2Separator || ',', - tokenSeparators: data.amsSelect2TokensSeparators || [','], - tokenizer: ams.getFunctionByName(data.amsSelect2Tokenizer) - }; - - switch (select.context.type) { - case 'text': - case 'hidden': - if (!dataOptions.initSelection) { - var valuesData = select.data('ams-select2-values'); - if (valuesData) { - dataOptions.initSelection = function(element, callback) { - var data = []; - $(element.val().split(dataOptions.separator)).each(function() { - data.push({id: this, - text: valuesData[this] || this}); - }); - callback(data); - }; - } - } - break; - default: - break; + } + : ams.getFunctionByName(data.amsFormInvalidHandler) + : undefined + }; + $('[data-ams-validate-rules]', form).each(function(index) { + if (index === 0) { + dataOptions.rules = {}; } - - if (select.attr('readonly')) { - if (select.attr('type') === 'hidden') { - dataOptions.query = function () { - return []; - }; - } - } else if (data.amsSelect2Query) { - // Custom query method - dataOptions.query = ams.getFunctionByName(data.amsSelect2Query); - dataOptions.minimumInputLength = data.amsSelect2MinimumInputLength || 1; - } else if (data.amsSelect2QueryUrl) { - // AJAX query - dataOptions.ajax = { - url: data.amsSelect2QueryUrl, - quietMillis: data.amsSelect2QuietMillis || 200, - type: data.amsSelect2QueryType || 'POST', - dataType: data.amsSelect2QueryDatatype || 'json', - data: function(term, page, context) { - var options = {}; - options[data.amsSelect2QueryParamName || 'query'] = term; - options[data.amsSelect2PageParamName || 'page'] = page; - options[data.amsSelect2ContextParamName || 'context'] = context; - return $.extend({}, options, data.amsSelect2QueryOptions); - }, - results: ams.helpers.select2QueryUrlResultsCallback - }; - dataOptions.minimumInputLength = data.amsSelect2MinimumInputLength || 1; - } else if (data.amsSelect2QueryMethod) { - // JSON-RPC query - dataOptions.query = function(options) { - var settings = { - id: new Date().getTime(), - params: data.amsSelect2QueryParams || {}, - success: function(result) { - return ams.helpers.select2QueryMethodSuccessCallback.call(select, result, 'success', options); - }, - error: ams.error.show - }; - settings.params[data.amsSelect2QueryParamName || 'query'] = options.term; - settings.params[data.amsSelect2PageParamName || 'page'] = options.page; - settings.params[data.amsSelect2ContextParamName || 'context'] = options.context; - settings = $.extend({}, settings, data.amsSelect2QueryOptions); - settings = ams.executeFunctionByName(data.amsSelect2QueryInitCallback, select, settings) || settings; - ams.ajax.check($.jsonRPC, - ams.baseURL + 'ext/jquery-jsonrpc' + ams.devext + '.js', - function() { - $.jsonRPC.withOptions({ - endPoint: data.amsSelect2MethodTarget || ams.jsonrpc.getAddr(), - namespace: data.amsSelect2MethodNamespace, - cache: false - }, function() { - $.jsonRPC.request(data.amsSelect2QueryMethod, settings); - }); - }); - }; - dataOptions.minimumInputLength = data.amsSelect2MinimumInputLength || 1; - } else if (data.amsSelect2Tags) { - // Tags mode - dataOptions.tags = data.amsSelect2Tags; - } else if (data.amsSelect2Data) { - // Provided data mode - dataOptions.data = data.amsSelect2Data; - } - - if (data.amsSelect2EnableFreeTags) { - dataOptions.createSearchChoice = function(term) { - return {id: term, - text: (data.amsSelect2FreeTagsPrefix || ams.i18n.SELECT2_FREETAG_PREFIX) + term}; - }; - } - - var settings = $.extend({}, dataOptions, data.amsSelect2Options); - settings = ams.executeFunctionByName(data.amsSelect2InitCallback, select, settings) || settings; - var plugin = select.select2(settings); - ams.executeFunctionByName(data.amsSelect2AfterInitCallback, select, plugin, settings); - if (select.hasClass('ordered')) { - ams.ajax.check($.fn.select2Sortable, - ams.baseURL + 'ext/jquery-select2-sortable' + ams.devext + '.js', - function() { - select.select2Sortable({ - bindOrder: 'sortableStop' - }); - }); - } - - select.on('change', function() { - var validator = $(select.get(0).form).data('validator'); - if (validator !== undefined) { - $(select).valid(); - } - }); + dataOptions.rules[$(this).attr('name')] = $(this).data('ams-validate-rules'); }); - }); - } - }, - - /** - * Edit mask plug-in - */ - maskedit: function(element) { - var masks = $('input[data-mask]', element); - if (masks.length > 0) { - ams.ajax.check($.fn.mask, - ams.baseURL + 'ext/jquery-maskedinput-1.4.1' + ams.devext + '.js', - function() { - masks.each(function() { - var mask = $(this); - var data = mask.data(); - var dataOptions = { - placeholder: data.amsMaskeditPlaceholder === undefined ? 'X' : data.amsMaskeditPlaceholder, - complete: ams.getFunctionByName(data.amsMaskeditComplete) - }; - var settings = $.extend({}, dataOptions, data.amsMaskeditOptions); - settings = ams.executeFunctionByName(data.amsMaskeditInitCallback, mask, settings) || settings; - var plugin = mask.mask(mask.attr('data-mask'), settings); - ams.executeFunctionByName(data.amsMaskeditAfterInitCallback, mask, plugin, settings); - }); - }); - } - }, - - /** - * JQuery input-mask plug-in - * - * Mask value can be set in a "data-input-mask" attribute defined: - * - as a simple string containing mask - * - as a JSON object defining all mask attributes, for example: - * data-input-mask='{"alias": "integer", "allowPlus": false, "allowMinus": false}' - */ - inputmask: function(element) { - var masks = $('input[data-input-mask]', element); - if (masks.length > 0) { - ams.ajax.check($.fn.inputmask, - ams.baseURL + 'ext/jquery-inputmask-bundle-3.2.8' + ams.devext + '.js', - function() { - masks.each(function() { - var input = $(this); - var data = input.data(); - var dataOptions; - if (typeof(data.inputMask) === 'object') { - dataOptions = data.inputMask; - } else { - dataOptions = { - mask: data.inputMask.toString() - }; - } - var settings = $.extend({}, dataOptions, data.amsInputmaskOptions); - settings = ams.executeFunctionByName(data.amsInputmaskInitCallback, input, settings) || settings; - var plugin = input.inputmask(settings); - ams.executeFunctionByName(data.amsInputmaskAfterInitCallback, input, plugin, settings); - }); - }); - } - }, - - /** - * JQuery date picker - */ - datepicker: function(element) { - var datepickers = $('.datepicker', element); - if (datepickers.length > 0) { - ams.ajax.check($.fn.datetimepicker, - ams.baseURL + 'ext/jquery-datetimepicker' + ams.devext + '.js', - function(first_load) { - if (first_load) { - ams.dialog.registerHideCallback(ams.helpers.datetimepickerDialogHiddenCallback); - } - ams.getCSS(ams.baseURL + '../css/ext/jquery-datetimepicker' + ams.devext + '.css', - 'jquery-datetimepicker', - function () { - datepickers.each(function () { - var input = $(this); - var data = input.data(); + var settings = $.extend({}, dataOptions, data.amsValidateOptions); + settings = ams.executeFunctionByName(data.amsValidateInitCallback, form, settings) || settings; + var plugin = form.validate(settings); + ams.executeFunctionByName(data.amsValidateAfterInitCallback, form, plugin, settings); + }); + }); + } + }, + + /** + * JQuery dataTables + */ + datatable: function(element) { + var tables = $('.datatable', element); + if (tables.length > 0) { + ams.ajax.check($.fn.dataTable, + ams.baseURL + 'ext/jquery-dataTables-1.9.4' + ams.devext + '.js', + function() { + ams.ajax.check($.fn.dataTableExt.oPagination.bootstrap_full, + ams.baseURL + 'myams-dataTables' + ams.devext + '.js', + function() { + $(tables).each(function () { + var table = $(this); + var data = table.data(); + var extensions = (data.amsDatatableExtensions || '').split(/\s+/); + // Check DOM elements + var sDom = data.amsDatatableSdom || + "W" + + ((extensions.indexOf('colreorder') >= 0 || + extensions.indexOf('colreorderwithresize') >= 0) ? 'R' : '') + + "<'dt-top-row'" + + (extensions.indexOf('colvis') >= 0 ? 'C' : '') + + ((data.amsDatatablePagination === false || + data.amsDatatablePaginationSize === false) ? '' : 'L') + + (data.amsDatatableGlobalFilter === false ? '' : 'F') + + ">r<'dt-wrapper't" + + (extensions.indexOf('scroller') >= 0 ? 'S' : '') + + "><'dt-row dt-bottom-row'<'row'<'col-sm-6'" + + (data.amsDatatableInformation === false ? '' : 'i') + + "><'col-sm-6 text-right'p>>"; + + var index; + // Check initial sorting + var sorting = data.amsDatatableSorting; + if (typeof(sorting) === 'string') { + var sortings = sorting.split(';'); + sorting = []; + for (index = 0; index < sortings.length; index++) { + var colSorting = sortings[index].split(','); + colSorting[0] = parseInt(colSorting[0]); + sorting.push(colSorting); + } + } + // Check columns sortings + var columns = []; + var column; + var sortables = $('th', table).listattr('data-ams-datatable-sortable'); + for (index = 0; index < sortables.length; index++) { + var sortable = sortables[index]; + if (sortable !== undefined) { + column = columns[index] || {}; + column.bSortable = typeof(sortable) === 'string' ? JSON.parse(sortable) : sortable; + columns[index] = column; + } else { + columns[index] = columns[index] || {}; + } + } + // Check columns types + var sortTypes = $('th', table).listattr('data-ams-datatable-stype'); + for (index = 0; index < sortTypes.length; index++) { + var sortType = sortTypes[index]; + if (sortType) { + column = columns[index] || {}; + column.sType = sortType; + columns[index] = column; + } else { + columns[index] = columns[index] || {}; + } + } + // Set options var dataOptions = { - lang: data.amsDatetimepickerLang || ams.lang, - format: data.amsDatetimepickerFormat || 'd/m/y', - datepicker: true, - dayOfWeekStart: 1, - timepicker: false, - closeOnDateSelect: data.amsDatetimepickerCloseOnSelect === undefined ? true : data.amsDatetimepickerCloseOnSelect, - weeks: data.amsDatetimepickerWeeks + bJQueryUI: false, + bServerSide: data.amsDatatableServerSide || false, + sAjaxSource: data.amsDatatableServerSide === true ? data.amsDatatableAjaxSource : undefined, + sServerMethod: data.amsDatatableServerSide === true ? 'POST' : undefined, + bFilter: data.amsDatatableGlobalFilter !== false || extensions.indexOf('columnfilter') >= 0, + bPaginate: data.amsDatatablePagination !== false, + bInfo: data.amsDatatableInfo !== false, + bSort: data.amsDatatableSort !== false, + aaSorting: sorting, + aoColumns: columns.length > 0 ? columns : undefined, + bDeferRender: true, + bAutoWidth: false, + iDisplayLength: data.amsDatatableDisplayLength || 25, + sPaginationType: data.amsDatatablePaginationType || 'bootstrap_full', + sDom: sDom, + oLanguage: ams.plugins.i18n.datatables, + fnInitComplete: function (oSettings, json) { + $('.ColVis_Button').addClass('btn btn-default btn-sm') + .html((ams.plugins.i18n.datatables.sColumns || "Columns") + + ' '); + } }; - var settings = $.extend({}, dataOptions, data.amsDatetimepickerOptions); - settings = ams.executeFunctionByName(data.amsDatetimepickerInitCallback, input, settings) || settings; - var plugin = input.datetimepicker(settings); - ams.executeFunctionByName(data.amsDatetimepickerAfterInitCallback, input, plugin, settings); - }); - }); - }); - } - }, - - /** - * JQuery datetime picker - */ - datetimepicker: function(element) { - var datetimepickers = $('.datetimepicker', element); - if (datetimepickers.length > 0) { - ams.ajax.check($.fn.datetimepicker, - ams.baseURL + 'ext/jquery-datetimepicker' + ams.devext + '.js', - function(first_load) { - if (first_load) { - ams.dialog.registerHideCallback(ams.helpers.datetimepickerDialogHiddenCallback); - } - ams.getCSS(ams.baseURL + '../css/ext/jquery-datetimepicker' + ams.devext + '.css', - 'jquery-datetimepicker', - function () { - datetimepickers.each(function () { - var input = $(this); - var data = input.data(); - var dataOptions = { - lang: data.amsDatetimepickerLang || ams.lang, - format: data.amsDatetimepickerFormat || 'd/m/y H:i', - datepicker: true, - dayOfWeekStart: 1, - timepicker: true, - closeOnDateSelect: data.amsDatetimepickerCloseOnSelect === undefined ? true : data.amsDatetimepickerCloseOnSelect, - closeOnTimeSelect: data.amsDatetimepickerCloseOnSelect === undefined ? true : data.amsDatetimepickerCloseOnSelect, - weeks: data.amsDatetimepickerWeeks - }; - var settings = $.extend({}, dataOptions, data.amsDatetimepickerOptions); - settings = ams.executeFunctionByName(data.amsDatetimepickerInitCallback, input, settings) || settings; - var plugin = input.datetimepicker(settings); - ams.executeFunctionByName(data.amsDatetimepickerAfterInitCallback, input, plugin, settings); - }); - }); - }); - } - }, - - /** - * JQuery time picker - */ - timepicker: function(element) { - var timepickers = $('.timepicker', element); - if (timepickers.length > 0) { - ams.ajax.check($.fn.datetimepicker, - ams.baseURL + 'ext/jquery-datetimepicker' + ams.devext + '.js', - function(first_load) { - if (first_load) { - ams.dialog.registerHideCallback(ams.helpers.datetimepickerDialogHiddenCallback); - } - ams.getCSS(ams.baseURL + '../css/ext/jquery-datetimepicker' + ams.devext + '.css', - 'jquery-datetimepicker', - function() { - timepickers.each(function () { - var input = $(this); - var data = input.data(); - var dataOptions = { - lang: data.amsDatetimepickerLang || ams.lang, - format: data.amsDatetimepickerFormat || 'H:i', - datepicker: false, - timepicker: true, - closeOnTimeSelect: data.amsDatetimepickerCloseOnSelect === undefined ? true : data.amsDatetimepickerCloseOnSelect - }; - var settings = $.extend({}, dataOptions, data.amsDatetimepickerOptions); - settings = ams.executeFunctionByName(data.amsDatetimepickerInitCallback, input, settings) || settings; - var plugin = input.datetimepicker(settings); - ams.executeFunctionByName(data.amsDatetimepickerAfterInitCallback, input, plugin, settings); - }); - }); - }); - } - }, - - /** - * JQuery color picker - */ - colorpicker: function(element) { - var colorpickers = $('.colorpicker', element); - if (colorpickers.length > 0) { - ams.ajax.check($.fn.minicolors, - ams.baseURL + 'ext/jquery-minicolors' + ams.devext + '.js', - function() { - ams.getCSS(ams.baseURL + '../css/ext/jquery-minicolors' + ams.devext + '.css', - 'jquery-minicolors', - function () { - colorpickers.each(function () { - var input = $(this); - var data = input.data(); - var dataOptions = { - position: data.amsColorpickerPosition || input.closest('.input').data('ams-colorpicker-position') || 'bottom left' - }; - var settings = $.extend({}, dataOptions, data.amsColorpickerOptions); - settings = ams.executeFunctionByName(data.amsColorpickerInitCallback, input, settings) || settings; - var plugin = input.minicolors(settings); - ams.executeFunctionByName(data.amsDatetimepickerAfterInitCallback, input, plugin, settings); - }); - }); - }); - } - }, - - /** - * Drag & drop upload plug-in - */ - dndupload: function(element) { - var uploads = $('.dndupload', element); - if (uploads.length > 0) { - ams.ajax.check($.fn.dndupload, - ams.baseURL + 'ext/jquery-dndupload' + ams.devext + '.js', - function() { - ams.getCSS(ams.baseURL + '../css/ext/jquery-dndupload' + ams.devext + '.css', - 'jquery-dndupload', - function () { - uploads.each(function () { - var upload = $(this); - var data = upload.data(); - var dataOptions = { - action: data.amsDnduploadAction || upload.attr('action') || 'upload-files', - fieldname: data.amsDnduploadFieldname || 'files', - autosubmit: data.amsDnduploadAutosubmit - }; - var settings = $.extend({}, dataOptions, data.amsDnduploadOptions); - settings = ams.executeFunctionByName(data.amsDnduploadInitCallback, upload, settings) || settings; - var plugin = upload.dndupload(settings); - ams.executeFunctionByName(data.amsDnduploadAfterInitcallback, upload, plugin, settings); - }); - }); - }); - } - }, - - /** - * JQuery validation plug-in - */ - validate: function(element) { - var forms = $('FORM:not([novalidate])', element); - if (forms.length > 0) { - ams.ajax.check($.fn.validate, - ams.baseURL + 'ext/jquery-validate-1.17.0' + ams.devext + '.js', - function(first_load) { - if (first_load) { - $.validator.setDefaults({ - highlight: function(element) { - $(element).closest('.form-group, label:not(:parents(.form-group))').addClass('state-error'); - }, - unhighlight: function(element) { - $(element).closest('.form-group, label:not(:parents(.form-group))').removeClass('state-error'); - }, - errorElement: 'span', - errorClass: 'state-error', - errorPlacement: function(error, element) { - var label = element.parents('label:first'); - if (label.length) { - error.insertAfter(label); - } else { - error.insertAfter(element); - } - } - }); - if (ams.plugins.i18n) { - for (var key in ams.plugins.i18n.validate) { - if (!ams.plugins.i18n.validate.hasOwnProperty(key)) { - continue; - } - var message = ams.plugins.i18n.validate[key]; - if ((typeof(message) === 'string') && - (message.indexOf('{0}') > -1)) { - ams.plugins.i18n.validate[key] = $.validator.format(message); - } - } - $.extend($.validator.messages, ams.plugins.i18n.validate); - } - } - forms.each(function() { - var form = $(this); - var data = form.data(); - var dataOptions = { - ignore: null, - submitHandler: form.attr('data-async') !== undefined ? - data.amsFormSubmitHandler === undefined ? - function() { - // JQuery-form plug-in must be loaded synchronously!! - // Otherwise, hidden input fields created by jquery-validate plug-in - // and matching named buttons will be deleted (on first form submit) - // before JQuery-form plug-in can get them when submitting the form... - $('.state-error', form).removeClass('state-error'); - ams.ajax.check($.fn.ajaxSubmit, - ams.baseURL + 'ext/jquery-form-3.49' + ams.devext + '.js'); - return ams.form.submit(form); - } - : ams.getFunctionByName(data.amsFormSubmitHandler) - : undefined, - invalidHandler: form.attr('data-async') !== undefined ? - data.amsFormInvalidHandler === undefined ? - function(event, validator) { - $('.state-error', form).removeClass('state-error'); - for (var index=0; index < validator.errorList.length; index++) { - var error = validator.errorList[index]; - var tabIndex = $(error.element).parents('.tab-pane').index() + 1; - if (tabIndex > 0) { - var navTabs = $('.nav-tabs', $(error.element).parents('.tabforms')); - $('li:nth-child(' + tabIndex + ')', navTabs) - .removeClassPrefix('state-') - .addClass('state-error'); - $('li.state-error:first a', navTabs).click(); - } - } - } - : ams.getFunctionByName(data.amsFormInvalidHandler) - : undefined - }; - $('[data-ams-validate-rules]', form).each(function(index) { - if (index === 0) { - dataOptions.rules = {}; - } - dataOptions.rules[$(this).attr('name')] = $(this).data('ams-validate-rules'); - }); - var settings = $.extend({}, dataOptions, data.amsValidateOptions); - settings = ams.executeFunctionByName(data.amsValidateInitCallback, form, settings) || settings; - var plugin = form.validate(settings); - ams.executeFunctionByName(data.amsValidateAfterInitCallback, form, plugin, settings); - }); - }); - } - }, - - /** - * JQuery dataTables - */ - datatable: function(element) { - var tables = $('.datatable', element); - if (tables.length > 0) { - ams.ajax.check($.fn.dataTable, - ams.baseURL + 'ext/jquery-dataTables-1.9.4' + ams.devext + '.js', - function() { - ams.ajax.check($.fn.dataTableExt.oPagination.bootstrap_full, - ams.baseURL + 'myams-dataTables' + ams.devext + '.js', - function() { - $(tables).each(function () { - var table = $(this); - var data = table.data(); - var extensions = (data.amsDatatableExtensions || '').split(/\s+/); - // Check DOM elements - var sDom = data.amsDatatableSdom || - "W" + - ((extensions.indexOf('colreorder') >= 0 || - extensions.indexOf('colreorderwithresize') >= 0) ? 'R' : '') + - "<'dt-top-row'" + - (extensions.indexOf('colvis') >= 0 ? 'C' : '') + - ((data.amsDatatablePagination === false || - data.amsDatatablePaginationSize === false) ? '' : 'L') + - (data.amsDatatableGlobalFilter === false ? '' : 'F') + - ">r<'dt-wrapper't" + - (extensions.indexOf('scroller') >= 0 ? 'S' : '') + - "><'dt-row dt-bottom-row'<'row'<'col-sm-6'" + - (data.amsDatatableInformation === false ? '' : 'i') + - "><'col-sm-6 text-right'p>>"; - - var index; - // Check initial sorting - var sorting = data.amsDatatableSorting; - if (typeof(sorting) === 'string') { - var sortings = sorting.split(';'); - sorting = []; - for (index = 0; index < sortings.length; index++) { - var colSorting = sortings[index].split(','); - colSorting[0] = parseInt(colSorting[0]); - sorting.push(colSorting); + var settings = $.extend({}, dataOptions, data.amsDatatableOptions); + var checkers = []; + var sources = []; + var callbacks = []; + if (extensions.length > 0) { + for (index = 0; index < extensions.length; index++) { + switch (extensions[index]) { + case 'autofill': + checkers.push($.fn.dataTable.AutoFill); + sources.push(ams.baseURL + 'ext/jquery-dataTables-autoFill' + ams.devext + '.js'); + break; + case 'columnfilter': + checkers.push($.fn.columnFilter); + sources.push(ams.baseURL + 'ext/jquery-dataTables-columnFilter' + ams.devext + '.js'); + break; + case 'colreorder': + checkers.push($.fn.dataTable.ColReorder); + sources.push(ams.baseURL + 'ext/jquery-dataTables-colReorder' + ams.devext + '.js'); + break; + case 'colreorderwithresize': + checkers.push(window.ColReorder); + sources.push(ams.baseURL + 'ext/jquery-dataTables-colReorderWithResize' + ams.devext + '.js'); + break; + case 'colvis': + checkers.push($.fn.dataTable.ColVis); + sources.push(ams.baseURL + 'ext/jquery-dataTables-colVis' + ams.devext + '.js'); + callbacks.push(function () { + var cvDefault = { + activate: 'click', + sAlign: 'right' + }; + settings.oColVis = $.extend({}, cvDefault, data.amsDatatableColvisOptions); + }); + break; + case 'editable': + checkers.push($.fn.editable); + sources.push(ams.baseURL + 'ext/jquery-jeditable' + ams.devext + '.js'); + checkers.push($.fn.makeEditable); + sources.push(ams.baseURL + 'ext/jquery-dataTables-editable' + ams.devext + '.js'); + break; + case 'fixedcolumns': + checkers.push($.fn.dataTable.FixedColumns); + sources.push(ams.baseURL + 'ext/jquery-dataTables-fixedColumns' + ams.devext + '.js'); + break; + case 'fixedheader': + checkers.push($.fn.dataTable.Fixedheader); + sources.push(ams.baseURL + 'ext/jquery-dataTables-fixedHeader' + ams.devext + '.js'); + break; + case 'keytable': + checkers.push(window.keyTable); + sources.push(ams.baseURL + 'ext/jquery-dataTables-keyTable' + ams.devext + '.js'); + break; + case 'rowgrouping': + checkers.push($.fn.rowGrouping); + sources.push(ams.baseURL + 'ext/jquery-dataTables-rowGrouping' + ams.devext + '.js'); + break; + case 'rowreordering': + checkers.push($.fn.rowReordering); + sources.push(ams.baseURL + 'ext/jquery-dataTables-rowReordering' + ams.devext + '.js'); + break; + case 'scroller': + checkers.push($.fn.dataTable.Scroller); + sources.push(ams.baseURL + 'ext/jquery-dataTables-scroller' + ams.devext + '.js'); + break; + default: + break; } } - // Check columns sortings - var columns = []; - var column; - var sortables = $('th', table).listattr('data-ams-datatable-sortable'); - for (index = 0; index < sortables.length; index++) { - var sortable = sortables[index]; - if (sortable !== undefined) { - column = columns[index] || {}; - column.bSortable = typeof(sortable) === 'string' ? JSON.parse(sortable) : sortable; - columns[index] = column; - } else { - columns[index] = columns[index] || {}; - } - } - // Check columns types - var sortTypes = $('th', table).listattr('data-ams-datatable-stype'); - for (index = 0; index < sortTypes.length; index++) { - var sortType = sortTypes[index]; - if (sortType) { - column = columns[index] || {}; - column.sType = sortType; - columns[index] = column; - } else { - columns[index] = columns[index] || {}; - } - } - // Set options - var dataOptions = { - bJQueryUI: false, - bServerSide: data.amsDatatableServerSide || false, - sAjaxSource: data.amsDatatableServerSide === true ? data.amsDatatableAjaxSource : undefined, - sServerMethod: data.amsDatatableServerSide === true ? 'POST' : undefined, - bFilter: data.amsDatatableGlobalFilter !== false || extensions.indexOf('columnfilter') >= 0, - bPaginate: data.amsDatatablePagination !== false, - bInfo: data.amsDatatableInfo !== false, - bSort: data.amsDatatableSort !== false, - aaSorting: sorting, - aoColumns: columns.length > 0 ? columns : undefined, - bDeferRender: true, - bAutoWidth: false, - iDisplayLength: data.amsDatatableDisplayLength || 25, - sPaginationType: data.amsDatatablePaginationType || 'bootstrap_full', - sDom: sDom, - oLanguage: ams.plugins.i18n.datatables, - fnInitComplete: function (oSettings, json) { - $('.ColVis_Button').addClass('btn btn-default btn-sm') - .html((ams.plugins.i18n.datatables.sColumns || "Columns") + - ' '); + } + + function initTable() { + settings = ams.executeFunctionByName(data.amsDatatableInitCallback, table, settings) || settings; + try { // Some settings can easily generate DataTables exceptions... + var plugin = table.dataTable(settings); + ams.executeFunctionByName(data.amsDatatableAfterInitCallback, table, plugin, settings); + if (extensions.length > 0) { + for (index = 0; index < extensions.length; index++) { + switch (extensions[index]) { + case 'autofill': + var afSettings = $.extend({}, data.amsDatatableAutofillOptions, settings.autofill); + afSettings = ams.executeFunctionByName(data.amsDatatableAutofillInitCallback, table, afSettings) || afSettings; + table.data('ams-autofill', data.amsDatatableAutofillConstructor === undefined ? + new $.fn.dataTable.AutoFill(table, afSettings) + : ams.executeFunctionByName(data.amsDatatableAutofillConstructor, table, plugin, afSettings)); + break; + case 'columnfilter': + var cfDefault = { + sPlaceHolder: 'head:after' + }; + var cfSettings = $.extend({}, cfDefault, data.amsDatatableColumnfilterOptions, settings.columnfilter); + cfSettings = ams.executeFunctionByName(data.amsDatatableColumnfilterInitCallback, table, cfSettings) || cfSettings; + table.data('ams-columnfilter', data.amsDatatableColumnfilterConstructor === undefined ? + plugin.columnFilter(cfSettings) + : ams.executeFunctionByName(data.amsDatatableColumnfilterConstructor, table, plugin, cfSettings)); + break; + case 'editable': + var edSettings = $.extend({}, data.amsDatatableEditableOptions, settings.editable); + edSettings = ams.executeFunctionByName(data.amsDatatableEditableInitCallback, table, edSettings) || edSettings; + table.data('ams-editable', data.amsDatatableEditableConstructor === undefined ? + table.makeEditable(edSettings) + : ams.executeFunctionByName(data.amsDatatableEditableConstructor, table, plugin, edSettings)); + break; + case 'fixedcolumns': + var fcSettings = $.extend({}, data.amsDatatableFixedcolumnsOptions, settings.fixedcolumns); + fcSettings = ams.executeFunctionByName(data.amsDatatableFixedcolumnsInitCallback, table, fcSettings) || fcSettings; + table.data('ams-fixedcolumns', data.amsDatatableFixedcolumnsConstructor === undefined ? + new $.fn.dataTable.FixedColumns(table, fcSettings) + : ams.executeFunctionByName(data.amsDatatableFixedcolumnsConstructor, table, plugin, fcSettings)); + break; + case 'fixedheader': + var fhSettings = $.extend({}, data.amsDatatableFixedheaderOptions, settings.fixedheader); + fhSettings = ams.executeFunctionByName(data.amsDatatableFixedheadeInitCallback, table, fhSettings) || fhSettings; + table.data('ams-fixedheader', data.amsDatatableFixedheaderConstructor === undefined ? + new $.fn.dataTable.FixedHeader(table, fhSettings) + : ams.executeFunctionByName(data.amsDatatableFixedheaderConstructor, table, plugin, fhSettings)); + break; + case 'keytable': + var ktDefault = { + table: table.get(0), + datatable: plugin + }; + var ktSettings = $.extend({}, ktDefault, data.amsDatatableKeytableOptions, settings.keytable); + ktSettings = ams.executeFunctionByName(data.amsDatatableKeytableInitCallback, table, ktSettings) || ktSettings; + table.data('ams-keytable', data.amsDatatableKeytableConstructor === undefined ? + new KeyTable(ktSettings) + : ams.executeFunctionByName(data.amsDatatableKeytableConstructor, table, plugin, ktSettings)); + break; + case 'rowgrouping': + var rgSettings = $.extend({}, data.amsDatatableRowgroupingOptions, settings.rowgrouping); + rgSettings = ams.executeFunctionByName(data.amsDatatableRowgroupingInitCallback, table, rgSettings) || rgSettings; + table.data('ams-rowgrouping', data.amsDatatableRowgroupingConstructor === undefined ? + table.rowGrouping(rgSettings) + : ams.executeFunctionByName(data.amsDatatableRowgroupingConstructor, table, plugin, rgSettings)); + break; + case 'rowreordering': + var rrSettings = $.extend({}, data.amsDatatableRowreorderingOptions, settings.rowreordering); + rrSettings = ams.executeFunctionByName(data.amsDatatableRowreorderingInitCallback, table, rrSettings) || rrSettings; + table.data('ams-rowreordering', data.amsDatatableRowreorderingConstructor === undefined ? + table.rowReordering(rrSettings) + : ams.executeFunctionByName(data.amsDatatableRowreorderingConstructor, table, plugin, rrSettings)); + break; + default: + break; + } + } } - }; - var settings = $.extend({}, dataOptions, data.amsDatatableOptions); - var checkers = []; - var sources = []; - var callbacks = []; - if (extensions.length > 0) { - for (index = 0; index < extensions.length; index++) { - switch (extensions[index]) { - case 'autofill': - checkers.push($.fn.dataTable.AutoFill); - sources.push(ams.baseURL + 'ext/jquery-dataTables-autoFill' + ams.devext + '.js'); - break; - case 'columnfilter': - checkers.push($.fn.columnFilter); - sources.push(ams.baseURL + 'ext/jquery-dataTables-columnFilter' + ams.devext + '.js'); - break; - case 'colreorder': - checkers.push($.fn.dataTable.ColReorder); - sources.push(ams.baseURL + 'ext/jquery-dataTables-colReorder' + ams.devext + '.js'); - break; - case 'colreorderwithresize': - checkers.push(window.ColReorder); - sources.push(ams.baseURL + 'ext/jquery-dataTables-colReorderWithResize' + ams.devext + '.js'); - break; - case 'colvis': - checkers.push($.fn.dataTable.ColVis); - sources.push(ams.baseURL + 'ext/jquery-dataTables-colVis' + ams.devext + '.js'); - callbacks.push(function () { - var cvDefault = { - activate: 'click', - sAlign: 'right' - }; - settings.oColVis = $.extend({}, cvDefault, data.amsDatatableColvisOptions); - }); - break; - case 'editable': - checkers.push($.fn.editable); - sources.push(ams.baseURL + 'ext/jquery-jeditable' + ams.devext + '.js'); - checkers.push($.fn.makeEditable); - sources.push(ams.baseURL + 'ext/jquery-dataTables-editable' + ams.devext + '.js'); - break; - case 'fixedcolumns': - checkers.push($.fn.dataTable.FixedColumns); - sources.push(ams.baseURL + 'ext/jquery-dataTables-fixedColumns' + ams.devext + '.js'); - break; - case 'fixedheader': - checkers.push($.fn.dataTable.Fixedheader); - sources.push(ams.baseURL + 'ext/jquery-dataTables-fixedHeader' + ams.devext + '.js'); - break; - case 'keytable': - checkers.push(window.keyTable); - sources.push(ams.baseURL + 'ext/jquery-dataTables-keyTable' + ams.devext + '.js'); - break; - case 'rowgrouping': - checkers.push($.fn.rowGrouping); - sources.push(ams.baseURL + 'ext/jquery-dataTables-rowGrouping' + ams.devext + '.js'); - break; - case 'rowreordering': - checkers.push($.fn.rowReordering); - sources.push(ams.baseURL + 'ext/jquery-dataTables-rowReordering' + ams.devext + '.js'); - break; - case 'scroller': - checkers.push($.fn.dataTable.Scroller); - sources.push(ams.baseURL + 'ext/jquery-dataTables-scroller' + ams.devext + '.js'); - break; - default: - break; + if (data.amsDatatableFinalizeCallback) { + var finalizers = data.amsDatatableFinalizeCallback.split(/\s+/); + if (finalizers.length > 0) { + for (index = 0; index < finalizers.length; index++) { + ams.executeFunctionByName(finalizers[index], table, plugin, settings); + } } } } - - function initTable() { - settings = ams.executeFunctionByName(data.amsDatatableInitCallback, table, settings) || settings; - try { // Some settings can easily generate DataTables exceptions... - var plugin = table.dataTable(settings); - ams.executeFunctionByName(data.amsDatatableAfterInitCallback, table, plugin, settings); - if (extensions.length > 0) { - for (index = 0; index < extensions.length; index++) { - switch (extensions[index]) { - case 'autofill': - var afSettings = $.extend({}, data.amsDatatableAutofillOptions, settings.autofill); - afSettings = ams.executeFunctionByName(data.amsDatatableAutofillInitCallback, table, afSettings) || afSettings; - table.data('ams-autofill', data.amsDatatableAutofillConstructor === undefined ? - new $.fn.dataTable.AutoFill(table, afSettings) - : ams.executeFunctionByName(data.amsDatatableAutofillConstructor, table, plugin, afSettings)); - break; - case 'columnfilter': - var cfDefault = { - sPlaceHolder: 'head:after' - }; - var cfSettings = $.extend({}, cfDefault, data.amsDatatableColumnfilterOptions, settings.columnfilter); - cfSettings = ams.executeFunctionByName(data.amsDatatableColumnfilterInitCallback, table, cfSettings) || cfSettings; - table.data('ams-columnfilter', data.amsDatatableColumnfilterConstructor === undefined ? - plugin.columnFilter(cfSettings) - : ams.executeFunctionByName(data.amsDatatableColumnfilterConstructor, table, plugin, cfSettings)); - break; - case 'editable': - var edSettings = $.extend({}, data.amsDatatableEditableOptions, settings.editable); - edSettings = ams.executeFunctionByName(data.amsDatatableEditableInitCallback, table, edSettings) || edSettings; - table.data('ams-editable', data.amsDatatableEditableConstructor === undefined ? - table.makeEditable(edSettings) - : ams.executeFunctionByName(data.amsDatatableEditableConstructor, table, plugin, edSettings)); - break; - case 'fixedcolumns': - var fcSettings = $.extend({}, data.amsDatatableFixedcolumnsOptions, settings.fixedcolumns); - fcSettings = ams.executeFunctionByName(data.amsDatatableFixedcolumnsInitCallback, table, fcSettings) || fcSettings; - table.data('ams-fixedcolumns', data.amsDatatableFixedcolumnsConstructor === undefined ? - new $.fn.dataTable.FixedColumns(table, fcSettings) - : ams.executeFunctionByName(data.amsDatatableFixedcolumnsConstructor, table, plugin, fcSettings)); - break; - case 'fixedheader': - var fhSettings = $.extend({}, data.amsDatatableFixedheaderOptions, settings.fixedheader); - fhSettings = ams.executeFunctionByName(data.amsDatatableFixedheadeInitCallback, table, fhSettings) || fhSettings; - table.data('ams-fixedheader', data.amsDatatableFixedheaderConstructor === undefined ? - new $.fn.dataTable.FixedHeader(table, fhSettings) - : ams.executeFunctionByName(data.amsDatatableFixedheaderConstructor, table, plugin, fhSettings)); - break; - case 'keytable': - var ktDefault = { - table: table.get(0), - datatable: plugin - }; - var ktSettings = $.extend({}, ktDefault, data.amsDatatableKeytableOptions, settings.keytable); - ktSettings = ams.executeFunctionByName(data.amsDatatableKeytableInitCallback, table, ktSettings) || ktSettings; - table.data('ams-keytable', data.amsDatatableKeytableConstructor === undefined ? - new KeyTable(ktSettings) - : ams.executeFunctionByName(data.amsDatatableKeytableConstructor, table, plugin, ktSettings)); - break; - case 'rowgrouping': - var rgSettings = $.extend({}, data.amsDatatableRowgroupingOptions, settings.rowgrouping); - rgSettings = ams.executeFunctionByName(data.amsDatatableRowgroupingInitCallback, table, rgSettings) || rgSettings; - table.data('ams-rowgrouping', data.amsDatatableRowgroupingConstructor === undefined ? - table.rowGrouping(rgSettings) - : ams.executeFunctionByName(data.amsDatatableRowgroupingConstructor, table, plugin, rgSettings)); - break; - case 'rowreordering': - var rrSettings = $.extend({}, data.amsDatatableRowreorderingOptions, settings.rowreordering); - rrSettings = ams.executeFunctionByName(data.amsDatatableRowreorderingInitCallback, table, rrSettings) || rrSettings; - table.data('ams-rowreordering', data.amsDatatableRowreorderingConstructor === undefined ? - table.rowReordering(rrSettings) - : ams.executeFunctionByName(data.amsDatatableRowreorderingConstructor, table, plugin, rrSettings)); - break; - default: - break; - } - } - } - if (data.amsDatatableFinalizeCallback) { - var finalizers = data.amsDatatableFinalizeCallback.split(/\s+/); - if (finalizers.length > 0) { - for (index = 0; index < finalizers.length; index++) { - ams.executeFunctionByName(finalizers[index], table, plugin, settings); - } - } - } - } - catch (e) { - } + catch (e) { } - - callbacks.push(initTable); - ams.ajax.check(checkers, sources, callbacks); - }); + } + + callbacks.push(initTable); + ams.ajax.check(checkers, sources, callbacks); }); - }); - } - }, - - /** - * TableDND plug-in - */ - tablednd: function(element) { - var tables = $('.table-dnd', element); - if (tables.length > 0) { - ams.ajax.check($.fn.tableDnD, - ams.baseURL + 'ext/jquery-tablednd' + ams.devext + '.js', - function() { - tables.each(function() { - var table = $(this); - var data = table.data(); - if (data.amsTabledndDragHandle) { - $('tr', table).addClass('no-drag-handle'); - } else { - $(table).on('mouseover', 'tr', function () { - $(this.cells[0]).addClass('drag-handle'); - }).on('mouseout', 'tr', function () { - $(this.cells[0]).removeClass('drag-handle'); - }); - } - var dataOptions = { - onDragClass: data.amsTabledndDragClass || 'dragging-row', - onDragStart: ams.getFunctionByName(data.amsTabledndDragStart), - dragHandle: data.amsTabledndDragHandle, - scrollAmount: data.amsTabledndScrollAmount, - onAllowDrop: data.amsTabledndAllowDrop, - onDrop: ams.getFunctionByName(data.amsTabledndDrop) || function(dnd_table, row) { - var target = data.amsTabledndDropTarget; - if (target) { - // Disable row click handler - $(row).data('ams-disabled-handlers', 'click'); - try { - var rows = []; - $(dnd_table.rows).each(function() { - var rowId = $(this).data('ams-element-name'); - if (rowId) { - rows.push(rowId); + }); + }); + } + }, + + /** + * TableDND plug-in + */ + tablednd: function(element) { + var tables = $('.table-dnd', element); + if (tables.length > 0) { + ams.ajax.check($.fn.tableDnD, + ams.baseURL + 'ext/jquery-tablednd' + ams.devext + '.js', + function() { + tables.each(function() { + var table = $(this); + var data = table.data(); + if (data.amsTabledndDragHandle) { + $('tr', table).addClass('no-drag-handle'); + } else { + $(table).on('mouseover', 'tr', function () { + $(this.cells[0]).addClass('drag-handle'); + }).on('mouseout', 'tr', function () { + $(this.cells[0]).removeClass('drag-handle'); + }); + } + var dataOptions = { + onDragClass: data.amsTabledndDragClass || 'dragging-row', + onDragStart: ams.getFunctionByName(data.amsTabledndDragStart), + dragHandle: data.amsTabledndDragHandle, + scrollAmount: data.amsTabledndScrollAmount, + onAllowDrop: data.amsTabledndAllowDrop, + onDrop: ams.getFunctionByName(data.amsTabledndDrop) || function(dnd_table, row) { + var target = data.amsTabledndDropTarget; + if (target) { + // Disable row click handler + $(row).data('ams-disabled-handlers', 'click'); + try { + var rows = []; + $(dnd_table.rows).each(function() { + var rowId = $(this).data('ams-element-name'); + if (rowId) { + rows.push(rowId); + } + }); + var localTarget = ams.getFunctionByName(target); + if (typeof(localTarget) === 'function') { + localTarget.call(table, dnd_table, rows); + } else { + if (!target.startsWith(window.location.protocol)) { + var location = data.amsLocation; + if (location) { + target = location + '/' + target; } - }); - var localTarget = ams.getFunctionByName(target); - if (typeof(localTarget) === 'function') { - localTarget.call(table, dnd_table, rows); - } else { - if (!target.startsWith(window.location.protocol)) { - var location = data.amsLocation; - if (location) { - target = location + '/' + target; - } - } - ams.ajax.post(target, {names: JSON.stringify(rows)}); } - } finally { - // Restore row click handler - setTimeout(function() { - $(row).removeData('ams-disabled-handlers'); - }, 50); + ams.ajax.post(target, {names: JSON.stringify(rows)}); } - } - return false; - } - }; - var settings = $.extend({}, dataOptions, data.amsTabledndOptions); - settings = ams.executeFunctionByName(data.amsTabledndInitCallback, table, settings) || settings; - var plugin = table.tableDnD(settings); - ams.executeFunctionByName(data.amsTabledndAfterInitCallback, table, plugin, settings); - }); - }); - } - }, - - /** - * Wizard plug-in - */ - wizard: function(element) { - var wizards = $('.wizard', element); - if (wizards.length > 0) { - ams.ajax.check($.fn.bootstrapWizard, - ams.baseURL + 'ext/bootstrap-wizard-1.4.2' + ams.devext + '.js', - function() { - wizards.each(function() { - var wizard = $(this); - var data = wizard.data(); - var dataOptions = { - withVisible: data.amsWizardWithVisible === undefined ? true : data.amsWizardWithVisible, - tabClass: data.amsWizardTabClass, - firstSelector: data.amsWizardFirstSelector, - previousSelector: data.amsWizardPreviousSelector, - nextSelector: data.amsWizardNextSelector, - lastSelector: data.amsWizardLastSelector, - finishSelector: data.amsWizardFinishSelector, - backSelector: data.amsWizardBackSelector, - onInit: ams.getFunctionByName(data.amsWizardInit), - onShow: ams.getFunctionByName(data.amsWizardShow), - onNext: ams.getFunctionByName(data.amsWizardNext), - onPrevious: ams.getFunctionByName(data.amsWizardPrevious), - onFirst: ams.getFunctionByName(data.amsWizardFirst), - onLast: ams.getFunctionByName(data.amsWizardLast), - onBack: ams.getFunctionByName(data.amsWizardBack), - onFinish: ams.getFunctionByName(data.amsWizardFinish), - onTabChange: ams.getFunctionByName(data.amsWizardTabChange), - onTabClick: ams.getFunctionByName(data.amsWizardTabClick), - onTabShow: ams.getFunctionByName(data.amsWizardTabShow) - }; - var settings = $.extend({}, dataOptions, data.amsWizardOptions); - settings = ams.executeFunctionByName(data.amsWizardInitCallback, wizard, settings) || settings; - var plugin = wizard.bootstrapWizard(settings); - ams.executeFunctionByName(data.amsWizardAfterInitCallback, wizard, plugin, settings); - }); - }); - } - }, - - /** - * TinyMCE plug-in - */ - tinymce: function(element) { - - function cleanEditors() { - $('.tinymce', $(this)).each(function() { - var editor = tinymce.get($(this).attr('id')); - if (editor) { - editor.remove(); - } - }); - } - - var editors = $('.tinymce', element); - if (editors.length > 0) { - var baseURL = ams.baseURL + 'ext/tinymce' + (ams.devmode ? '/dev' : ''); - ams.ajax.check(window.tinymce, - baseURL + '/tinymce' + ams.devext + '.js', - function(first_load) { - - function initEditors() { - editors.each(function() { - var editor = $(this); - var data = editor.data(); - var dataOptions = { - theme: data.amsTinymceTheme || "modern", - language: ams.lang, - menubar: data.amsTinymceMenubar !== false, - statusbar: data.amsTinymceStatusbar !== false, - plugins: data.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: data.amsTinymceToolbar, - toolbar1: data.amsTinymceToolbar1 === false ? false : data.amsTinymceToolbar1 || - "undo redo | pastetext | styleselect | bold italic | alignleft " + - "aligncenter alignright alignjustify | bullist numlist " + - "outdent indent", - toolbar2: data.amsTinymceToolbar2 === false ? false : data.amsTinymceToolbar2 || - "forecolor backcolor emoticons | charmap link image media | " + - "fullscreen preview print | code", - content_css: data.amsTinymceContentCss, - formats: data.amsTinymceFormats, - style_formats: data.amsTinymceStyleFormats, - block_formats: data.amsTinymceBlockFormats, - valid_classes: data.amsTinymceValidClasses, - image_advtab: true, - image_list: ams.getFunctionByName(data.amsTinymceImageList) || data.amsTinymceImageList, - image_class_list: data.amsTinymceImageClassList, - link_list: ams.getFunctionByName(data.amsTinymceLinkList) || data.amsTinymceLinkList, - link_class_list: data.amsTinymceLinkClassList, - paste_as_text: data.amsTinymcePasteAsText === undefined ? true : data.amsTinymcePasteAsText, - paste_auto_cleanup_on_paste: data.amsTinymcePasteAutoCleanup === undefined ? true : data.amsTinymcePasteAutoCleanup, - paste_strip_class_attributes: data.amsTinymcePasteStripClassAttributes || 'all', - paste_remove_spans: data.amsTinymcePaseRemoveSpans === undefined ? true : data.amsTinymcePasteRemoveSpans, - paste_remove_styles: data.amsTinymcePasteRemoveStyles === undefined ? true : data.amsTinymcePasteRemoveStyles, - height: data.amsTinymceHeight || 50, - min_height: 50, - resize: true, - autoresize_min_height: 50, - autoresize_max_height: 500 - }; - if (data.amsTinymceExternalPlugins) { - var names = data.amsTinymceExternalPlugins.split(/\s+/); - for (var index in names) { - if (!names.hasOwnProperty(index)) { - continue; - } - var pluginSrc = editor.data('ams-tinymce-plugin-' + names[index]); - tinymce.PluginManager.load(names[index], ams.getSource(pluginSrc)); + } finally { + // Restore row click handler + setTimeout(function() { + $(row).removeData('ams-disabled-handlers'); + }, 50); } } - var settings = $.extend({}, dataOptions, data.amsTinymceOptions); - settings = ams.executeFunctionByName(data.amsTinymceInitCallback, editor, settings) || settings; - var plugin = editor.tinymce(settings); - ams.executeFunctionByName(data.amsTinymceAfterInitCallback, editor, plugin, settings); - }); - } - - if (first_load) { - ams.getScript(baseURL + '/jquery.tinymce' + ams.devext + '.js', function() { - tinymce.baseURL = baseURL; - tinymce.suffix = ams.devext; - ams.skin.registerCleanCallback(cleanEditors); - initEditors(); - }); - } else { - initEditors(); - } - }); - } - }, - - /** - * Image area select plug-in - */ - imgareaselect: function(element) { - var images = $('.imgareaselect', element); - if (images.length > 0) { - ams.ajax.check($.fn.imgAreaSelect, - ams.baseURL + 'ext/jquery-imgareaselect-0.9.11-rc1' + ams.devext + '.js', - function() { - ams.getCSS(ams.baseURL + '../css/ext/jquery-imgareaselect' + ams.devext + '.css', - 'jquery-imgareaselect', - function() { - images.each(function () { - var image = $(this); - var data = image.data(); - var parent = data.amsImgareaselectParent ? image.parents(data.amsImgareaselectParent) : 'body'; - var dataOptions = { - instance: true, - handles: true, - parent: parent, - x1: data.amsImgareaselectX1 || 0, - y1: data.amsImgareaselectY1 || 0, - x2: data.amsImgareaselectX2 || data.amsImgareaselectImageWidth, - y2: data.amsImgareaselectY2 || data.amsImgareaselectImageHeight, - imageWidth: data.amsImgareaselectImageWidth, - imageHeight: data.amsImgareaselectImageHeight, - minWidth: 128, - minHeight: 128, - aspectRatio: data.amsImgareaselectRatio, - onSelectEnd: ams.getFunctionByName(data.amsImgareaselectSelectEnd) || function (img, selection) { - var target = data.amsImgareaselectTargetField || 'image_'; - $('input[name="' + target + 'x1"]', parent).val(selection.x1); - $('input[name="' + target + 'y1"]', parent).val(selection.y1); - $('input[name="' + target + 'x2"]', parent).val(selection.x2); - $('input[name="' + target + 'y2"]', parent).val(selection.y2); - } - }; - var settings = $.extend({}, dataOptions, data.amsImgareaselectOptions); - settings = ams.executeFunctionByName(data.amsImgareaselectInitCallback, image, settings) || settings; - var plugin = image.imgAreaSelect(settings); - ams.executeFunctionByName(data.amsImgareaselectAfterInitCallback, image, plugin, settings); - // Add update timeout when plug-in is displayed into a modal dialog - setTimeout(function () { - plugin.update(); - }, 250); - }); - }); - }); - } - }, - - /** - * FancyBox plug-in - */ - fancybox: function(element) { - var fancyboxes = $('.fancybox', element); - if (fancyboxes.length > 0) { - ams.ajax.check($.fn.fancybox, - ams.baseURL + 'ext/jquery-fancybox-2.1.5' + ams.devext + '.js', - function() { - ams.getCSS(ams.baseURL + '../css/ext/jquery-fancybox-2.1.5' + ams.devext + '.css', - 'jquery-fancybox', - function() { - fancyboxes.each(function () { - var fancybox = $(this); - var data = fancybox.data(); - var elements = fancybox; - var index, - helper; - if (data.amsFancyboxElements) { - elements = $(data.amsFancyboxElements, fancybox); + return false; + } + }; + var settings = $.extend({}, dataOptions, data.amsTabledndOptions); + settings = ams.executeFunctionByName(data.amsTabledndInitCallback, table, settings) || settings; + var plugin = table.tableDnD(settings); + ams.executeFunctionByName(data.amsTabledndAfterInitCallback, table, plugin, settings); + }); + }); + } + }, + + /** + * Wizard plug-in + */ + wizard: function(element) { + var wizards = $('.wizard', element); + if (wizards.length > 0) { + ams.ajax.check($.fn.bootstrapWizard, + ams.baseURL + 'ext/bootstrap-wizard-1.4.2' + ams.devext + '.js', + function() { + wizards.each(function() { + var wizard = $(this); + var data = wizard.data(); + var dataOptions = { + withVisible: data.amsWizardWithVisible === undefined ? true : data.amsWizardWithVisible, + tabClass: data.amsWizardTabClass, + firstSelector: data.amsWizardFirstSelector, + previousSelector: data.amsWizardPreviousSelector, + nextSelector: data.amsWizardNextSelector, + lastSelector: data.amsWizardLastSelector, + finishSelector: data.amsWizardFinishSelector, + backSelector: data.amsWizardBackSelector, + onInit: ams.getFunctionByName(data.amsWizardInit), + onShow: ams.getFunctionByName(data.amsWizardShow), + onNext: ams.getFunctionByName(data.amsWizardNext), + onPrevious: ams.getFunctionByName(data.amsWizardPrevious), + onFirst: ams.getFunctionByName(data.amsWizardFirst), + onLast: ams.getFunctionByName(data.amsWizardLast), + onBack: ams.getFunctionByName(data.amsWizardBack), + onFinish: ams.getFunctionByName(data.amsWizardFinish), + onTabChange: ams.getFunctionByName(data.amsWizardTabChange), + onTabClick: ams.getFunctionByName(data.amsWizardTabClick), + onTabShow: ams.getFunctionByName(data.amsWizardTabShow) + }; + var settings = $.extend({}, dataOptions, data.amsWizardOptions); + settings = ams.executeFunctionByName(data.amsWizardInitCallback, wizard, settings) || settings; + var plugin = wizard.bootstrapWizard(settings); + ams.executeFunctionByName(data.amsWizardAfterInitCallback, wizard, plugin, settings); + }); + }); + } + }, + + /** + * TinyMCE plug-in + */ + tinymce: function(element) { + + function cleanEditors() { + $('.tinymce', $(this)).each(function() { + var editor = tinymce.get($(this).attr('id')); + if (editor) { + editor.remove(); + } + }); + } + + var editors = $('.tinymce', element); + if (editors.length > 0) { + var baseURL = ams.baseURL + 'ext/tinymce' + (ams.devmode ? '/dev' : ''); + ams.ajax.check(window.tinymce, + baseURL + '/tinymce' + ams.devext + '.js', + function(first_load) { + + function initEditors() { + editors.each(function() { + var editor = $(this); + var data = editor.data(); + var dataOptions = { + theme: data.amsTinymceTheme || "modern", + language: ams.lang, + menubar: data.amsTinymceMenubar !== false, + statusbar: data.amsTinymceStatusbar !== false, + plugins: data.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: data.amsTinymceToolbar, + toolbar1: data.amsTinymceToolbar1 === false ? false : data.amsTinymceToolbar1 || + "undo redo | pastetext | styleselect | bold italic | alignleft " + + "aligncenter alignright alignjustify | bullist numlist " + + "outdent indent", + toolbar2: data.amsTinymceToolbar2 === false ? false : data.amsTinymceToolbar2 || + "forecolor backcolor emoticons | charmap link image media | " + + "fullscreen preview print | code", + content_css: data.amsTinymceContentCss, + formats: data.amsTinymceFormats, + style_formats: data.amsTinymceStyleFormats, + block_formats: data.amsTinymceBlockFormats, + valid_classes: data.amsTinymceValidClasses, + image_advtab: true, + image_list: ams.getFunctionByName(data.amsTinymceImageList) || data.amsTinymceImageList, + image_class_list: data.amsTinymceImageClassList, + link_list: ams.getFunctionByName(data.amsTinymceLinkList) || data.amsTinymceLinkList, + link_class_list: data.amsTinymceLinkClassList, + paste_as_text: data.amsTinymcePasteAsText === undefined ? true : data.amsTinymcePasteAsText, + paste_auto_cleanup_on_paste: data.amsTinymcePasteAutoCleanup === undefined ? true : data.amsTinymcePasteAutoCleanup, + paste_strip_class_attributes: data.amsTinymcePasteStripClassAttributes || 'all', + paste_remove_spans: data.amsTinymcePaseRemoveSpans === undefined ? true : data.amsTinymcePasteRemoveSpans, + paste_remove_styles: data.amsTinymcePasteRemoveStyles === undefined ? true : data.amsTinymcePasteRemoveStyles, + height: data.amsTinymceHeight || 50, + min_height: 50, + resize: true, + autoresize_min_height: 50, + autoresize_max_height: 500 + }; + if (data.amsTinymceExternalPlugins) { + var names = data.amsTinymceExternalPlugins.split(/\s+/); + for (var index in names) { + if (!names.hasOwnProperty(index)) { + continue; } - var helpers = (data.amsFancyboxHelpers || '').split(/\s+/); - if (helpers.length > 0) { - for (index = 0; index < helpers.length; index++) { - helper = helpers[index]; - switch (helper) { - case 'buttons': - ams.ajax.check($.fancybox.helpers.buttons, - ams.baseURL + 'ext/fancybox-helpers/fancybox-buttons' + ams.devext + '.js'); - break; - case 'thumbs': - ams.ajax.check($.fancybox.helpers.thumbs, - ams.baseURL + 'ext/fancybox-helpers/fancybox-thumbs' + ams.devext + '.js'); - break; - case 'media': - ams.ajax.check($.fancybox.helpers.media, - ams.baseURL + 'ext/fancybox-helpers/fancybox-media' + ams.devext + '.js'); - break; - default: - break; - } - } - } - var dataOptions = { - type: data.amsFancyboxType, - padding: data.amsFancyboxPadding || 10, - margin: data.amsFancyboxMargin || 10, - loop: data.amsFancyboxLoop, - beforeLoad: ams.getFunctionByName(data.amsFancyboxBeforeLoad) || function () { - var title; - if (data.amsFancyboxTitleGetter) { - title = ams.executeFunctionByName(data.amsFancyboxTitleGetter, this); - } - if (!title) { - var content = $('*:first', this.element); - title = content.attr('original-title') || content.attr('title'); - if (!title) { - title = $(this.element).attr('original-title') || $(this.element).attr('title'); - } - } - this.title = title; - }, - afterLoad: ams.getFunctionByName(data.amsFancyboxAfterLoad), - helpers: { - title: { - type: 'inside' - } - } - }; - if (helpers.length > 0) { - for (index = 0; index < helpers.length; index++) { - helper = helpers[index]; - switch (helper) { - case 'buttons': - dataOptions.helpers.buttons = { - position: data.amsFancyboxButtonsPosition || 'top' - }; - break; - case 'thumbs': - dataOptions.helpers.thumbs = { - width: data.amsFancyboxThumbsWidth || 50, - height: data.amsFancyboxThumbsHeight || 50 - }; - break; - case 'media': - dataOptions.helpers.media = true; - break; - } - } - } - var settings = $.extend({}, dataOptions, data.amsFancyboxOptions); - settings = ams.executeFunctionByName(data.amsFancyboxInitCallback, fancybox, settings) || settings; - var plugin = elements.fancybox(settings); - ams.executeFunctionByName(data.amsFancyboxAfterInitCallback, fancybox, plugin, settings); - }); - }); - }); - } - }, - - /** - * Flot charts - */ - chart: function(element) { - var charts = $('.chart', element); - if (charts.length > 0) { - ams.ajax.check($.fn.plot, - ams.baseURL + 'flot/jquery.flot' + ams.devext + '.js', - function() { - charts.each(function() { - - 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; + var pluginSrc = editor.data('ams-tinymce-plugin-' + names[index]); + tinymce.PluginManager.load(names[index], ams.getSource(pluginSrc)); + } + } + var settings = $.extend({}, dataOptions, data.amsTinymceOptions); + settings = ams.executeFunctionByName(data.amsTinymceInitCallback, editor, settings) || settings; + var plugin = editor.tinymce(settings); + ams.executeFunctionByName(data.amsTinymceAfterInitCallback, editor, plugin, settings); + }); + } + + if (first_load) { + ams.getScript(baseURL + '/jquery.tinymce' + ams.devext + '.js', function() { + tinymce.baseURL = baseURL; + tinymce.suffix = ams.devext; + ams.skin.registerCleanCallback(cleanEditors); + initEditors(); + }); + } else { + initEditors(); + } + }); + } + }, + + /** + * Image area select plug-in + */ + imgareaselect: function(element) { + var images = $('.imgareaselect', element); + if (images.length > 0) { + ams.ajax.check($.fn.imgAreaSelect, + ams.baseURL + 'ext/jquery-imgareaselect-0.9.11-rc1' + ams.devext + '.js', + function() { + ams.getCSS(ams.baseURL + '../css/ext/jquery-imgareaselect' + ams.devext + '.css', + 'jquery-imgareaselect', + function() { + images.each(function () { + var image = $(this); + var data = image.data(); + var parent = data.amsImgareaselectParent ? image.parents(data.amsImgareaselectParent) : 'body'; + var dataOptions = { + instance: true, + handles: true, + parent: parent, + x1: data.amsImgareaselectX1 || 0, + y1: data.amsImgareaselectY1 || 0, + x2: data.amsImgareaselectX2 || data.amsImgareaselectImageWidth, + y2: data.amsImgareaselectY2 || data.amsImgareaselectImageHeight, + imageWidth: data.amsImgareaselectImageWidth, + imageHeight: data.amsImgareaselectImageHeight, + minWidth: 128, + minHeight: 128, + aspectRatio: data.amsImgareaselectRatio, + onSelectEnd: ams.getFunctionByName(data.amsImgareaselectSelectEnd) || function (img, selection) { + var target = data.amsImgareaselectTargetField || 'image_'; + $('input[name="' + target + 'x1"]', parent).val(selection.x1); + $('input[name="' + target + 'y1"]', parent).val(selection.y1); + $('input[name="' + target + 'x2"]', parent).val(selection.x2); + $('input[name="' + target + 'y2"]', parent).val(selection.y2); + } + }; + var settings = $.extend({}, dataOptions, data.amsImgareaselectOptions); + settings = ams.executeFunctionByName(data.amsImgareaselectInitCallback, image, settings) || settings; + var plugin = image.imgAreaSelect(settings); + ams.executeFunctionByName(data.amsImgareaselectAfterInitCallback, image, plugin, settings); + // Add update timeout when plug-in is displayed into a modal dialog + setTimeout(function () { + plugin.update(); + }, 250); + }); + }); + }); + } + }, + + /** + * FancyBox plug-in + */ + fancybox: function(element) { + var fancyboxes = $('.fancybox', element); + if (fancyboxes.length > 0) { + ams.ajax.check($.fn.fancybox, + ams.baseURL + 'ext/jquery-fancybox-2.1.5' + ams.devext + '.js', + function() { + ams.getCSS(ams.baseURL + '../css/ext/jquery-fancybox-2.1.5' + ams.devext + '.css', + 'jquery-fancybox', + function() { + fancyboxes.each(function () { + var fancybox = $(this); + var data = fancybox.data(); + var elements = fancybox; + var index, + helper; + if (data.amsFancyboxElements) { + elements = $(data.amsFancyboxElements, fancybox); + } + var helpers = (data.amsFancyboxHelpers || '').split(/\s+/); + if (helpers.length > 0) { + for (index = 0; index < helpers.length; index++) { + helper = helpers[index]; + switch (helper) { + case 'buttons': + ams.ajax.check($.fancybox.helpers.buttons, + ams.baseURL + 'ext/fancybox-helpers/fancybox-buttons' + ams.devext + '.js'); + break; + case 'thumbs': + ams.ajax.check($.fancybox.helpers.thumbs, + ams.baseURL + 'ext/fancybox-helpers/fancybox-thumbs' + ams.devext + '.js'); + break; + case 'media': + ams.ajax.check($.fancybox.helpers.media, + ams.baseURL + 'ext/fancybox-helpers/fancybox-media' + ams.devext + '.js'); + break; + default: + break; } } } - return null; - } - - var chart = $(this); - var data = chart.data(); - var dataOptions = {}; - var plugins = (data.amsChartPlugins || '').split(/\s+/); - if (plugins.length > 0) { - for (var index in plugins) { - if (plugins.hasOwnProperty(index)) { - var pluginName = plugins[index]; - if (!checkPlugin(pluginName)) { - ams.getScript(ams.baseURL + 'flot/jquery.flot.' + pluginName + ams.devext + '.js'); + var dataOptions = { + type: data.amsFancyboxType, + padding: data.amsFancyboxPadding || 10, + margin: data.amsFancyboxMargin || 10, + loop: data.amsFancyboxLoop, + beforeLoad: ams.getFunctionByName(data.amsFancyboxBeforeLoad) || function () { + var title; + if (data.amsFancyboxTitleGetter) { + title = ams.executeFunctionByName(data.amsFancyboxTitleGetter, this); + } + if (!title) { + var content = $('*:first', this.element); + title = content.attr('original-title') || content.attr('title'); + if (!title) { + title = $(this.element).attr('original-title') || $(this.element).attr('title'); + } + } + this.title = title; + }, + afterLoad: ams.getFunctionByName(data.amsFancyboxAfterLoad), + helpers: { + title: { + type: 'inside' } } + }; + if (helpers.length > 0) { + for (index = 0; index < helpers.length; index++) { + helper = helpers[index]; + switch (helper) { + case 'buttons': + dataOptions.helpers.buttons = { + position: data.amsFancyboxButtonsPosition || 'top' + }; + break; + case 'thumbs': + dataOptions.helpers.thumbs = { + width: data.amsFancyboxThumbsWidth || 50, + height: data.amsFancyboxThumbsHeight || 50 + }; + break; + case 'media': + dataOptions.helpers.media = true; + break; + } + } + } + var settings = $.extend({}, dataOptions, data.amsFancyboxOptions); + settings = ams.executeFunctionByName(data.amsFancyboxInitCallback, fancybox, settings) || settings; + var plugin = elements.fancybox(settings); + ams.executeFunctionByName(data.amsFancyboxAfterInitCallback, fancybox, plugin, settings); + }); + }); + }); + } + }, + + /** + * Flot charts + */ + chart: function(element) { + var charts = $('.chart', element); + if (charts.length > 0) { + ams.ajax.check($.fn.plot, + ams.baseURL + 'flot/jquery.flot' + ams.devext + '.js', + function() { + charts.each(function() { + + 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; + } } } - var settings = $.extend({}, dataOptions, data.amsChartOptions); - settings = ams.executeFunctionByName(data.amsChartInitCallback, chart, settings) || settings; - var chartData = data.amsChartData; - chartData = ams.executeFunctionByName(data.amsChartInitData, chart, chartData) || chartData; - var plugin = chart.plot(chartData, settings); - ams.executeFunctionByName(data.amsChartAfterInitCallback, chart, plugin, settings); - }); - }); - } - }, - - /** - * Sparkline graphs - */ - graphs: function(element) { - var graphs = $('.sparkline', element); - if (graphs.length > 0) { - ams.ajax.check(ams.graphs, - ams.baseURL + 'myams-graphs' + ams.devext + '.js', - function() { - ams.graphs.init(graphs); - }); - } - }, - - /** - * Custom scrollbars - */ - scrollbars: function(element) { - var scrollbars = $('.scrollbar', element); - if (scrollbars.length > 0) { - ams.ajax.check($.event.special.mousewheel, - ams.baseURL + 'ext/jquery-mousewheel.min.js', - function() { - ams.ajax.check($.fn.mCustomScrollbar, - ams.baseURL + 'ext/jquery-mCustomScrollbar' + ams.devext + '.js', - function() { - ams.getCSS(ams.baseURL + '../css/ext/jquery-mCustomScrollbar.css', - 'jquery-mCustomScrollbar', - function () { - scrollbars.each(function () { - var scrollbar = $(this); - var data = scrollbar.data(); - var dataOptions = { - theme: data.amsScrollbarTheme || 'light' - }; - var settings = $.extend({}, dataOptions, data.amsScrollbarOptions); - settings = ams.executeFunctionByName(data.amsScrollbarInitCallback, scrollbar, settings) || settings; - var plugin = scrollbar.mCustomScrollbar(settings); - ams.executeFunctionByName(data.amsScrollbarAfterInitCallback, scrollbar, plugin, settings); - }); + return null; + } + + var chart = $(this); + var data = chart.data(); + var dataOptions = {}; + var plugins = (data.amsChartPlugins || '').split(/\s+/); + if (plugins.length > 0) { + for (var index in plugins) { + if (plugins.hasOwnProperty(index)) { + var pluginName = plugins[index]; + if (!checkPlugin(pluginName)) { + ams.getScript(ams.baseURL + 'flot/jquery.flot.' + pluginName + ams.devext + '.js'); + } + } + } + } + var settings = $.extend({}, dataOptions, data.amsChartOptions); + settings = ams.executeFunctionByName(data.amsChartInitCallback, chart, settings) || settings; + var chartData = data.amsChartData; + chartData = ams.executeFunctionByName(data.amsChartInitData, chart, chartData) || chartData; + var plugin = chart.plot(chartData, settings); + ams.executeFunctionByName(data.amsChartAfterInitCallback, chart, plugin, settings); + }); + }); + } + }, + + /** + * Sparkline graphs + */ + graphs: function(element) { + var graphs = $('.sparkline', element); + if (graphs.length > 0) { + ams.ajax.check(ams.graphs, + ams.baseURL + 'myams-graphs' + ams.devext + '.js', + function() { + ams.graphs.init(graphs); + }); + } + }, + + /** + * Custom scrollbars + */ + scrollbars: function(element) { + var scrollbars = $('.scrollbar', element); + if (scrollbars.length > 0) { + ams.ajax.check($.event.special.mousewheel, + ams.baseURL + 'ext/jquery-mousewheel.min.js', + function() { + ams.ajax.check($.fn.mCustomScrollbar, + ams.baseURL + 'ext/jquery-mCustomScrollbar' + ams.devext + '.js', + function() { + ams.getCSS(ams.baseURL + '../css/ext/jquery-mCustomScrollbar.css', + 'jquery-mCustomScrollbar', + function () { + scrollbars.each(function () { + var scrollbar = $(this); + var data = scrollbar.data(); + var dataOptions = { + theme: data.amsScrollbarTheme || 'light' + }; + var settings = $.extend({}, dataOptions, data.amsScrollbarOptions); + settings = ams.executeFunctionByName(data.amsScrollbarInitCallback, scrollbar, settings) || settings; + var plugin = scrollbar.mCustomScrollbar(settings); + ams.executeFunctionByName(data.amsScrollbarAfterInitCallback, scrollbar, plugin, settings); }); - }); - }); - } + }); + }); + }); } } - }; + }); })(jQuery, this); @@ -6553,7 +6581,10 @@ var modal = $(e.target); ams.form.confirmChangedForm(modal, function() { // Confirm closing if OK - modal.data('modal').isShown = true; + var bsModal = modal.data('modal') || modal.data('bs.modal'); + if (bsModal) { + bsModal.isShown = true; + } return true; }, function() { // Prevent closing if cancelled diff -r 0a21be6342aa -r c86acac9dff5 src/pyams_skin/resources/js/myams.min.js --- a/src/pyams_skin/resources/js/myams.min.js Mon Nov 19 15:20:20 2018 +0100 +++ b/src/pyams_skin/resources/js/myams.min.js Tue Nov 20 09:09:31 2018 +0100 @@ -1,1 +1,1 @@ -"use strict";!function(e,a){var t=a.console;String.prototype.startsWith=function(e){var a=this.length,t=e.length;return!(a0},void 0===e.scrollbarWidth&&(e.scrollbarWidth=function(){var a=e('
').appendTo("body"),t=a.children(),n=t.innerWidth()-t.height(99).innerWidth();return a.remove(),n}),e.fn.extend({exists:function(){return e(this).length>0},objectOrParentWithClass:function(e){return this.hasClass(e)?this:this.parents("."+e)},listattr:function(a){var t=[];return this.each(function(){t.push(e(this).attr(a))}),t},style:function(e,a,t){if(void 0!==this.get(0)){var n=this.get(0).style;return void 0!==e?void 0!==a?(t=void 0!==t?t:"",n.setProperty(e,a,t),this):n.getPropertyValue(e):n}},removeClassPrefix:function(a){return this.each(function(t,n){var s=n.className.split(" ").map(function(e){return e.startsWith(a)?"":e});n.className=e.trim(s.join(" "))}),this}}),void 0===a.MyAMS&&(a.MyAMS={devmode:!0,devext:"",lang:"en",throttleDelay:350,menuSpeed:235,navbarHeight:49,ajaxNav:!0,safeMethods:["GET","HEAD","OPTIONS","TRACE"],csrfCookieName:"csrf_token",csrfHeaderName:"X-CSRF-Token",enableWidgets:!0,enableMobile:!1,enableFastclick:!1,warnOnFormChange:!1,ismobile:/iphone|ipad|ipod|android|blackberry|mini|windows\sce|palm/i.test(navigator.userAgent.toLowerCase())});var n=a.MyAMS,s=n;n.baseURL=function(){var a=e('script[src*="/myams.js"], script[src*="/myams.min.js"]').attr("src");return s.devmode=a.indexOf(".min.js")<0,s.devext=s.devmode?"":".min",a.substring(0,a.lastIndexOf("/")+1)}(),n.log=function(){t&&t.debug&&t.debug(this,arguments)},n.getQueryVar=function(e,a){if(e.indexOf("?")<0)return!1;e.endsWith("&")||(e+="&");var t=new RegExp(".*?[&\\?]"+a+"=(.*?)&.*"),n=e.replace(t,"$1");return n!==e&&n},n.rgb2hex=function(a){return"#"+e.map(a.match(/\b(\d+)\b/g),function(e){return("0"+parseInt(e).toString(16)).slice(-2)}).join("")},n.generateId=function(){function e(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}return e()+e()+e()+e()},n.generateUUID=function(){var e=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(a){var t=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"===a?t:3&t|8).toString(16)})},n.getObject=function(e,a){if(e){if("string"!=typeof e)return e;var t=e.split(".");a=void 0===a||null===a?window:a;for(var n=0;n").attr("data-ams-id",t).text('@import "'+s.getSource(a)+'";'),n)var c=setInterval(function(){try{o[0].sheet.cssRules;n.call(window,!0,i),clearInterval(c)}catch(e){}},10);o.appendTo(r)}else n&&n.call(window,!1,i)}}(jQuery,this),jQuery.UTF8={encode:function(e){e=e.replace(/\r\n/g,"\n");for(var a="",t=0;t127&&n<2048?(a+=String.fromCharCode(n>>6|192),a+=String.fromCharCode(63&n|128)):(a+=String.fromCharCode(n>>12|224),a+=String.fromCharCode(n>>6&63|128),a+=String.fromCharCode(63&n|128))}return a},decode:function(e){for(var a="",t=0,n=0,s=0,i=0;t191&&n<224?(s=e.charCodeAt(t+1),a+=String.fromCharCode((31&n)<<6|63&s),t+=2):(s=e.charCodeAt(t+1),i=e.charCodeAt(t+2),a+=String.fromCharCode((15&n)<<12|(63&s)<<6|63&i),t+=3);return a}},function(e,a){var t=a.MyAMS;e.fn.extend({contextMenu:function(a){function n(t,n,s){var i=e(window)[n](),r=e(a.menuSelector)[n](),o=t;return t+r>i&&r',openedSign:''},a),n=e(this);n.find("LI").each(function(){var a=e(this);if(a.find("UL").size()>0){a.find("A:first").append(""+t.closedSign+"");var n=a.find("A:first");"#"===n.attr("href")&&n.click(function(){return!1})}}),n.find("LI.active").each(function(){var a=e(this).parents("UL"),n=a.parent("LI");a.slideDown(t.speed),n.find("b:first").html(t.openedSign),n.addClass("open")}),n.find("LI A").on("click",function(){var a=e(this);if(!a.hasClass("active")){var s=a.attr("href").replace(/^#/,""),i=a.parent().find("UL");if(t.accordion){var r=a.parent().parents("UL"),o=n.find("UL:visible");o.each(function(a){var n=!0;if(r.each(function(e){if(r[e]===o[a])return n=!1,!1}),n&&i!==o[a]){var c=e(o[a]);!s&&c.hasClass("active")||c.slideUp(t.speed,function(){e(this).parent("LI").removeClass("open").find("B:first").delay(t.speed).html(t.closedSign)})}})}var c=a.parent().find("UL:first");s||!c.is(":visible")||c.hasClass("active")?c.slideDown(t.speed,function(){a.parent("LI").addClass("open").find("B:first").delay(t.speed).html(t.openedSign)}):c.slideUp(t.speed,function(){a.parent("LI").removeClass("open").find("B:first").delay(t.speed).html(t.closedSign)})}})}})}(jQuery,this),function(e,a){var t=a.MyAMS;t.event={stop:function(e){e||(e=window.event),e&&"string"!=typeof e&&(e.stopPropagation?(e.stopPropagation(),e.preventDefault()):(e.cancelBubble=!0,e.returnValue=!1))}}}(jQuery,this),function(e,a){var t=a.MyAMS,n=t;t.browser={getInternetExplorerVersion:function(){var e=-1;if("Microsoft Internet Explorer"===navigator.appName){var a=navigator.userAgent;null!==new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})").exec(a)&&(e=parseFloat(RegExp.$1))}return e},checkVersion:function(){var e="You're not using Windows Internet Explorer.",t=this.getInternetExplorerVersion();t>-1&&(e=t>=8?"You're using a recent copy of Windows Internet Explorer.":"You should upgrade your copy of Windows Internet Explorer."),a.alert&&a.alert(e)},isIE8orlower:function(){var e="0",a=this.getInternetExplorerVersion();return a>-1&&(e=a>=9?0:1),e},copyToClipboard:function(s){function i(s){var i=!1;if(window.clipboardData&&window.clipboardData.setData)i=clipboardData.setData("Text",s);else if(document.queryCommandSupported&&document.queryCommandSupported("copy")){var r=e("