1785 $('.state-error', form).removeClass('state-error'); |
1785 $('.state-error', form).removeClass('state-error'); |
1786 header = errors.error_header || |
1786 header = errors.error_header || |
1787 (errors.widgets && (errors.widgets.length > 1) ? ams.i18n.ERRORS_OCCURED : ams.i18n.ERROR_OCCURED); |
1787 (errors.widgets && (errors.widgets.length > 1) ? ams.i18n.ERRORS_OCCURED : ams.i18n.ERROR_OCCURED); |
1788 var message = []; |
1788 var message = []; |
1789 var index; |
1789 var index; |
1790 for (index=0; index < errors.messages.length; index++) { |
1790 if (errors.messages) { |
1791 var msg = errors.messages[index]; |
1791 for (index = 0; index < errors.messages.length; index++) { |
1792 if (msg.header) { |
1792 var msg = errors.messages[index]; |
1793 message.push('<strong>' + msg.header + '</strong><br />' + msg.message); |
1793 if (msg.header) { |
1794 } else { |
1794 message.push('<strong>' + msg.header + '</strong><br />' + msg.message); |
1795 message.push(msg.message || msg); |
1795 } else { |
|
1796 message.push(msg.message || msg); |
|
1797 } |
1796 } |
1798 } |
1797 } |
1799 } |
1798 if (errors.widgets) { |
1800 if (errors.widgets) { |
1799 for (index = 0; index < errors.widgets.length; index++) { |
1801 for (index = 0; index < errors.widgets.length; index++) { |
1800 // set widget status message |
1802 // set widget status message |
2264 disabled.push(plugins[index]); |
2266 disabled.push(plugins[index]); |
2265 } |
2267 } |
2266 }); |
2268 }); |
2267 |
2269 |
2268 // Load and register new plug-ins |
2270 // Load and register new plug-ins |
2269 var plugin; |
|
2270 $('[data-ams-plugins]', element).each(function() { |
2271 $('[data-ams-plugins]', element).each(function() { |
2271 var source = $(this); |
2272 var source = $(this); |
2272 var plugins = {}; |
2273 var plugins = {}; |
2273 var name; |
2274 var name; |
2274 if (typeof(source.data('ams-plugins')) === 'string') { |
2275 if (typeof(source.data('ams-plugins')) === 'string') { |
2284 }; |
2285 }; |
2285 } |
2286 } |
2286 } else { |
2287 } else { |
2287 plugins = source.data('ams-plugins'); |
2288 plugins = source.data('ams-plugins'); |
2288 } |
2289 } |
2289 |
|
2290 function executePlugin() { |
|
2291 var callback = plugin.callback; |
|
2292 if (callback) { |
|
2293 var called = ams.getFunctionByName(callback); |
|
2294 if (plugin.register !== false) { |
|
2295 ams.plugins.enabled[name] = called; |
|
2296 } |
|
2297 } else { |
|
2298 if (plugin.register !== false) { |
|
2299 ams.plugins.enabled[name] = null; |
|
2300 } |
|
2301 } |
|
2302 var css = plugin.css; |
|
2303 if (css) { |
|
2304 ams.getCSS(css, name + '_css'); |
|
2305 } |
|
2306 } |
|
2307 |
|
2308 for (name in plugins) { |
2290 for (name in plugins) { |
2309 if (ams.plugins.enabled[name] === undefined) { |
2291 if (ams.plugins.enabled[name] === undefined) { |
2310 plugin = plugins[name]; |
2292 var plugin = plugins[name]; |
2311 ams.getScript(plugin.src, executePlugin, { |
2293 ams.getScript(plugin.src, function() { |
|
2294 var callback = plugin.callback; |
|
2295 if (callback) { |
|
2296 var called = ams.getFunctionByName(callback); |
|
2297 if (plugin.register !== false) |
|
2298 ams.plugins.enabled[name] = called; |
|
2299 } else { |
|
2300 if (plugin.register !== false) |
|
2301 ams.plugins.enabled[name] = null; |
|
2302 } |
|
2303 var css = plugin['css']; |
|
2304 if (css) { |
|
2305 ams.getCSS(css, name + '_css'); |
|
2306 } |
|
2307 }, { |
2312 async: plugin.async === undefined ? true : plugin.async |
2308 async: plugin.async === undefined ? true : plugin.async |
2313 }); |
2309 }); |
2314 } |
2310 } |
2315 } |
2311 } |
2316 }); |
2312 }); |