diff -r d58af89193e3 -r 68dd5a05c059 src/ztfy/myams/resources/js/myams.js --- a/src/ztfy/myams/resources/js/myams.js Fri Dec 09 12:55:38 2016 +0100 +++ b/src/ztfy/myams/resources/js/myams.js Fri Mar 10 13:19:03 2017 +0100 @@ -548,7 +548,7 @@ if (!element.exists()) { return false; } - return globals.document.contains(element[0]); + return globals.document.body.contains(element[0]); }; /** @@ -759,12 +759,30 @@ async: typeof(callback) === 'function' }; var settings = $.extend({}, defaults, options); - if (checker === undefined) { - ams.getScript(source, function() { - if (typeof(callback) === 'function') { - callback(true, options); + if (checker instanceof Array) { + var deferred = []; + for (var index = 0; index < checker.length; index++) { + if (checker[index] === undefined) { + deferred.push(ams.getScript(source[index], {async: true})); } - }, settings); + } + if (deferred.length > 0) { + $.when.apply($, deferred).then(function () { + if (typeof(callback) === 'function') { + callback(true, options); + } + }); + } else if (typeof(callback) === 'function') { + callback(false, options); + } + } else if (checker === undefined) { + if (typeof(source) === 'string') { + ams.getScript(source, function () { + if (typeof(callback) === 'function') { + callback(true, options); + } + }, settings); + } } else { if (typeof(callback) === 'function') { callback(false, options); @@ -2555,6 +2573,9 @@ } for (name in plugins) { + if (!plugins.hasOwnProperty(name)) { + continue; + } plugin = plugins[name]; if (ams.plugins.enabled[name] === undefined) { ams.getScript(plugin.src, _loadPlugin, { @@ -2611,7 +2632,11 @@ if (data) { for (var name in data) { if (data.hasOwnProperty(name)) { - dataElement.attr('data-' + name, data[name]); + var elementData = data[name]; + if (typeof(elementData) !== 'string') { + elementData = JSON.stringify(elementData); + } + dataElement.attr('data-' + name, elementData); } } } @@ -4126,6 +4151,8 @@ } else { tr.remove(); } + } else { + MyAMS.ajax.handleJSON(result); } }); } @@ -4412,12 +4439,13 @@ if (menu.exists()) { updateActiveMenus(menu); } - ams.skin.loadURL(url, container); - var prefix = $('html head title').data('ams-title-prefix'); - document.title = (prefix ? prefix + ' > ' : '') + - ($('[data-ams-page-title]:first', container).data('ams-page-title') || - menu.attr('title') || - document.title); + ams.skin.loadURL(url, container, {afterLoadCallback: function() { + var prefix = $('html head title').data('ams-title-prefix'); + document.title = (prefix ? prefix + ' > ' : '') + + ($('[data-ams-page-title]:first', container).data('ams-page-title') || + menu.attr('title') || + document.title); + }}); } else { var activeUrl = $('[data-ams-active-menu]').data('ams-active-menu'); if (activeUrl) { @@ -4484,6 +4512,8 @@ if (typeof(options) === 'function') { callback = options; options = {}; + } else if (options === undefined) { + options = {}; } container = $(container); var defaults = { @@ -4493,7 +4523,7 @@ cache: false, beforeSend: function() { ams.skin.cleanContainer(container); - container.html('

Loading...

'); + container.html('

' + ams.i18n.LOADING + '

'); if (container[0] === $('#content')[0]) { ams.skin._drawBreadCrumb(); var prefix = $('html head title').data('ams-title-prefix'); @@ -4546,7 +4576,7 @@ ams.i18n.ERROR + error + '' + request.responseText); }, - async: false + async: options.async === undefined ? true : options.async }; var settings = $.extend({}, defaults, options); $.ajax(settings); @@ -5031,10 +5061,11 @@ } try { link.append(''); - ams.skin.loadURL(data.amsUrl, link.attr('href')); - if (data.amsTabLoadOnce) { - link.data('ams-tab-loaded', true); - } + ams.skin.loadURL(data.amsUrl, link.attr('href'), {afterLoadCallback: function() { + if (data.amsTabLoadOnce) { + link.data('ams-tab-loaded', true); + } + }}); } finally { $('i', link).remove(); @@ -5114,6 +5145,7 @@ WARNING: "!! WARNING !!", ERROR: "ERROR: ", + LOADING: "Loading...", WAIT: "Please wait!", FORM_SUBMITTED: "This form was already submitted...", NO_SERVER_RESPONSE: "No response from server!",