--- a/src/pyams_skin/resources/js/myams-ajax.min.js Mon Nov 19 15:18:31 2018 +0100
+++ b/src/pyams_skin/resources/js/myams-ajax.min.js Mon Nov 19 15:19:16 2018 +0100
@@ -1,1 +1,1 @@
-!function(p,g){var e=g.MyAMS,h=e;e.ajax={check:function(e,t,a,o){function n(e,t){if(void 0!==a){a instanceof Array||(a=[a]);for(var o=0;o<a.length;o++){var n=h.getFunctionByName(a[o]);"function"==typeof n&&n(e,t)}}}a instanceof Array||"object"==typeof a&&(o=a,a=void 0);var s={async:"function"==typeof a},i=p.extend({},s,o);if(e instanceof Array){for(var r=[],c=0;c<e.length;c++)void 0===e[c]&&r.push(h.getScript(t[c],{async:!0}));0<r.length?p.when.apply(p,r).then(function(){n(!0,o)}):n(!1,o)}else void 0===e?"string"==typeof t&&h.getScript(t,function(){n(!0,o)},i):n(!1,o)},getAddr:function(e){var t=e||p("HTML HEAD BASE").attr("href")||window.location.href;return t.substr(0,t.lastIndexOf("/")+1)},start:function(){p("#ajax-gear").show()},stop:function(){p("#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,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,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<u.length;a++)s=u[a],i=p(s.target),!0===s.raw?i.text(s.text):(i.html(s.html),h.initContent(i)),s.keep_hidden||i.removeClass("hidden")}if(e.message&&("string"==typeof(r=e.message)?"info"===f||"success"===f?h.skin.smallBox(f,{title:r,icon:"fa fa-fw fa-info-circle font-xs align-top margin-top-10",timeout:3e3}):h.skin.alert(p(t||"#content"),f,r):h.skin.alert(p(r.target||o||t||"#content"),r.status||"success",r.header,r.body,r.subtitle)),e.smallbox&&("string"==typeof(r=e.smallbox)?h.skin.smallBox(e.smallbox_status||f,{title:e.smallbox,icon:e.smallbox_icon||"fa fa-fw fa-info-circle font-xs align-top margin-top-10",timeout:e.smallbox_timeout||3e3}):h.skin.smallBox(r.status||f,{title:r.message,icon:r.icon||"fa fa-fw fa-info-circle font-xs align-top margin-top-10",timeout:r.timeout||3e3})),e.messagebox)if("string"==typeof(r=e.messagebox))h.skin.messageBox("info",{title:h.i18n.ERROR_OCCURED,content:r,timeout:1e4});else{var m=r.status||"info";"error"===m&&t&&o&&h.executeFunctionByName(t.data("ams-form-submit-error")||"MyAMS.form.finalizeSubmitOnError",t,o),h.skin.messageBox(m,{title:r.title||h.i18n.ERROR_OCCURED,content:r.content,icon:r.icon,number:r.number,timeout:null===r.timeout?void 0:r.timeout||1e4})}if(e.event&&t.trigger(e.event,e.event_options),e.events)for(void 0===t&&(t=p(document)),a=0;a<e.events.length;a++)null!==(c=e.events[a])&&("string"==typeof c?t.trigger(c,e.events_options):t.trigger(c.event,c.options));if(e.callback&&h.executeFunctionByName(e.callback,t,e.options),e.callbacks)for(a=0;a<e.callbacks.length;a++)"function"==typeof(l=e.callbacks[a])?h.executeFunctionByName(l,t,l.options):h.executeFunctionByName(l.callback,t,l.options)}}}(jQuery,this);
+!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;o<a.length;o++){var s=n.getFunctionByName(a[o]);"function"==typeof s&&s(e,t)}}}a instanceof Array||"object"==typeof a&&(s=a,a=void 0);var r={async:"function"==typeof a},c=e.extend({},r,s);if(t instanceof Array){for(var l=[],f=0;f<t.length;f++)void 0===t[f]&&l.push(n.getScript(o[f],{async:!0}));l.length>0?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<u.length;l++)f=u[l],d=e(f.target),!0===f.raw?d.text(f.text):(d.html(f.html),n.initContent(d)),f.keep_hidden||d.removeClass("hidden")}var m;if(o.message&&("string"==typeof(m=o.message)?"info"===r||"success"===r?n.skin.smallBox(r,{title:m,icon:"fa fa-fw fa-info-circle font-xs align-top margin-top-10",timeout:3e3}):n.skin.alert(e(a||"#content"),r,m):n.skin.alert(e(m.target||s||a||"#content"),m.status||"success",m.header,m.body,m.subtitle)),o.smallbox&&("string"==typeof(m=o.smallbox)?n.skin.smallBox(o.smallbox_status||r,{title:o.smallbox,icon:o.smallbox_icon||"fa fa-fw fa-info-circle font-xs align-top margin-top-10",timeout:o.smallbox_timeout||3e3}):n.skin.smallBox(m.status||r,{title:m.message,icon:m.icon||"fa fa-fw fa-info-circle font-xs align-top margin-top-10",timeout:m.timeout||3e3})),o.messagebox)if("string"==typeof(m=o.messagebox))n.skin.messageBox("info",{title:n.i18n.ERROR_OCCURED,content:m,timeout:1e4});else{var p=m.status||"info";"error"===p&&a&&s&&n.executeFunctionByName(a.data("ams-form-submit-error")||"MyAMS.form.finalizeSubmitOnError",a,s),n.skin.messageBox(p,{title:m.title||n.i18n.ERROR_OCCURED,content:m.content,icon:m.icon,number:m.number,timeout:null===m.timeout?void 0:m.timeout||1e4})}if(o.event&&a.trigger(o.event,o.event_options),o.events){var g;for(void 0===a&&(a=e(document)),l=0;l<o.events.length;l++)null!==(g=o.events[l])&&("string"==typeof g?a.trigger(g,o.events_options):a.trigger(g.event,g.options))}if(o.callback&&n.executeFunctionByName(o.callback,a,o.options),o.callbacks){var h;for(l=0;l<o.callbacks.length;l++)"function"==typeof(h=o.callbacks[l])?n.executeFunctionByName(h,a,h.options):n.executeFunctionByName(h.callback,a,h.options)}}}}(jQuery,this);