# HG changeset patch # User Thierry Florac # Date 1544606018 -3600 # Node ID 48b7cea0d9031f1d51e034766b557c7ea228e056 # Parent bd3550a252eaae825b1ce4b23e32b2dd27030dae Updated MyAMS resources diff -r bd3550a252ea -r 48b7cea0d903 src/pyams_skin/resources/js/myams-ajax.js --- a/src/pyams_skin/resources/js/myams-ajax.js Wed Dec 12 10:13:00 2018 +0100 +++ b/src/pyams_skin/resources/js/myams-ajax.js Wed Dec 12 10:13:38 2018 +0100 @@ -3,10 +3,9 @@ */ (function($, globals) { - var MyAMS = globals.MyAMS, - ams = MyAMS; + var ams = globals.MyAMS; - MyAMS.ajax = { + ams.ajax = { /** * Check for given feature and download script if necessary diff -r bd3550a252ea -r 48b7cea0d903 src/pyams_skin/resources/js/myams-ajax.min.js --- a/src/pyams_skin/resources/js/myams-ajax.min.js Wed Dec 12 10:13:00 2018 +0100 +++ b/src/pyams_skin/resources/js/myams-ajax.min.js Wed Dec 12 10:13:38 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;l0?e.when.apply(e,l).then(function(){i(!0,s)}):i(!1,s)}else void 0===t?"string"==typeof n&&o.getScript(n,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,o.ajax.post(t,e,function(e,t,n){o.ajax.handleJSON(e)})}},post:function(n,a,s,i){var r;r=n.startsWith(window.location.protocol)?n:this.getAddr()+n,"function"==typeof s?(i=s,s={}):s||(s={}),void 0===i&&(i=s.callback),"string"==typeof i&&(i=o.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,n){if(void 0!==t.Cookies){var a=Cookies.get(o.csrfCookieName);a&&e.setRequestHeader(o.csrfHeaderName,a)}},success:i||function(e){c=e.result}},f=e.extend({},l,s);return e.ajax(f),c},getResponse:function(e){var t,n,a=e.getResponseHeader("content-type");if(a)if(a.startsWith("application/javascript"))t="script",n=e.responseText;else if(a.startsWith("text/html"))t="html",n=e.responseText;else if(a.startsWith("text/xml"))t="xml",n=e.responseText;else if(n=e.responseJSON)t="json";else try{n=JSON.parse(e.responseText),t="json"}catch(o){n=e.responseText,t="text"}else t="json",n={status:"alert",alert:{title:o.i18n.ERROR_OCCURED,content:o.i18n.NO_SERVER_RESPONSE}};return{contentType:t,data:n}},handleJSON:function(n,a,s){var i,r=n.status;switch(r){case"alert":t.alert&&t.alert(n.alert.title+"\n\n"+n.alert.content);break;case"error":o.form.showErrors(a,n);break;case"info":case"success":void 0!==a&&(o.form.resetChanged(a),!1!==n.close_form&&o.dialog.close(a));break;case"message":case"messagebox":break;case"notify":case"callback":case"callbacks":void 0!==a&&(o.form.resetChanged(a),!1!==n.close_form&&o.dialog.close(a));break;case"modal":o.dialog.open(n.location);break;case"reload":void 0!==a&&(o.form.resetChanged(a),!1!==n.close_form&&o.dialog.close(a)),(i=n.location||window.location.hash).startsWith("#")&&(i=i.substr(1));var c=e(n.target||s||"#content");o.skin.loadURL(i,c,{preLoadCallback:o.getFunctionByName(n.pre_reload)||function(){e("[data-ams-pre-reload]",c).each(function(){o.executeFunctionByName(e(this).data("ams-pre-reload"))})},preLoadCallbackOptions:n.pre_reload_options,afterLoadCallback:o.getFunctionByName(n.post_reload)||function(){e("[data-ams-post-reload]",c).each(function(){o.executeFunctionByName(e(this).data("ams-post-reload"))})},afterLoadCallbackOptions:n.post_reload_options});break;case"redirect":void 0!==a&&(o.form.resetChanged(a),!0===n.close_form&&o.dialog.close(a)),(i=n.location||window.location.href).endsWith("##")&&(i=i.replace(/##/,window.location.hash)),n.window?window.open(i,n.window,n.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(n.content&&(f=n.content,d=e(f.target||s||a||"#content"),!0===f.raw?d.text(f.text):(d.html(f.html),o.initContent(d)),f.keep_hidden||d.removeClass("hidden")),n.contents){var u=n.contents;for(l=0;l");r.val(e),r.css("position","fixed"),r.appendTo(n("body")),r.get(0).select();try{document.execCommand("copy"),o=!0}catch(e){console&&console.warn&&console.warn("Copy to clipboard failed.",e)}finally{r.remove()}}o?i.skin.smallBox("success",{title:1-1&&(e=r>=8?"You're using a recent copy of Windows Internet Explorer.":"You should upgrade your copy of Windows Internet Explorer."),o.alert&&o.alert(e)},isIE8orlower:function(){var e="0",o=this.getInternetExplorerVersion();return o>-1&&(e=o>=9?0:1),e},copyToClipboard:function(n){function t(n){var t=!1;if(window.clipboardData&&window.clipboardData.setData)t=clipboardData.setData("Text",n);else if(document.queryCommandSupported&&document.queryCommandSupported("copy")){var a=e("