atsid/amd-plugins

View on GitHub
amd-plugins-min.js

Summary

Maintainability
A
0 mins
Test Coverage
define("plugins/ioc",["module"],function(e){var t=e.config(),n=t?t.beans:{},r={load:function(e,t,r,i){var s=n[e],o,u=[],a=i&&i.params;if(!s)throw new Error("IOC bean ["+e+"] requested, but no config found.");a=a||s.params,o=[s.type],Object.keys(a||{}).forEach(function(e){var t=a[e].toString().split("ref:");t.length>1&&(o.push(t[1]),u.push(e))}),t(o,function(){var e,t=arguments;u.forEach(function(e,n){a[e]=t[n+1]}),e=new arguments[0](a),r(e)})}};return r}),define("plugins/xhr",[],function(){return function(e,t,n){var r=new XMLHttpRequest;r.open("GET",e,!0),r.onreadystatechange=function(){var i;r.readyState===4&&(i=r.status,i>=400&&i<600?n&&n(new Error("Problem loading ["+e+"] status: ["+i+"]")):t(r.responseText))},r.send(null)}}),define("plugins/jsonschema",["./xhr","module"],function(e,t){function n(e){return e}function a(e,n,r){function u(e){function t(e,n){return Object.keys(e).forEach(function(r){var i=e[r];r==="$ref"&&!n[i]?n[i]=!0:typeof i=="object"&&t(i,n)}),n}return t(e,{})}function a(e,t){var n;return t.some(function(t){if(t.id===e)return n=t,!0}),n}function f(n,r,i){var s=u(n,{}),o=[];Object.keys(s).forEach(function(n){n!==e&&o.push(t.id+"!"+n)}),o.length>0?r(o,function(){var e=Array.prototype.slice.call(arguments);e.push(n),n=l(n,e),i(n)}):i(n)}function l(e,t){function n(e,t){return Object.keys(e).forEach(function(r){var i=e[r],s;r==="$ref"?(s=a(i,t),e=s,e.resolved||(e.resolved=!0,e=n(e,t))):typeof i=="object"&&(i.resolved||(i.resolved=!0,i=n(i,t)),e[r]=i)}),e}return n(e,t)}var c=i(e);s(n.toUrl(c),function(e){var t=JSON.parse(e);f(t,n,r)},o)}var r=t.config()||{},i=r.formatter||n,s=r.fetch||e,o=r.errorHandler,u;return u={load:function(e,t,n){a(e,t,n)}},u}),define("plugins/properties",["./xhr","module"],function(e,t){var n=t.config()||{},r=n.fetch||e,i=n.errorHandler,s={load:function(e,t,n){r(t.toUrl(e),function(e){var t={};e&&e.length>0&&e.split("\n").forEach(function(e){e=e.trim();if(e.indexOf("#")!==0&&e.indexOf("!")!==0){var n=e.split("="),r=n[0].trim(),i=n[1].trim();t[r]=i}}),n(t)},i)}};return s}),define("plugins/windower",[],function(){function e(t){return t.opener?window.windowerName===t.opener.windowerName?t:e(t.opener):t}var t=function(){var e={},t=0,n={};return{addChild:function(t){e[t.windowerName]=t},removeChild:function(t){delete e[t.windowerName]},iterateChildren:function(t){Object.keys(e).forEach(function(n){t.call(this,e[n])})},getNewWindowName:function(){return"window-"+ ++t},getData:function(e){return n[e]},setData:function(e,t){n[e]=t}}},n=e(window),r=null;return n.windowerFunctions||(n.windowerFunctions=t()),function(){window.windowerName=n.windowerFunctions.getNewWindowName(),window.postMessageProxy=function(e){window.postMessage(e,window.location.origin)},window.windowerName!==n.windowerName?(n.windowerFunctions.addChild(window),window.addEventListener("unload",function(){n.windowerFunctions.removeChild(this)})):(window.addEventListener("message",function(e){var t=e.data._type,r=e.data.key,i=e.data._getter,s,o;e.origin===window.location.origin&&(t==="data-set-request"?(s=e.data.data,n.windowerFunctions.setData(r,s)):t==="data-get-request"?(s=n.windowerFunctions.getData(r),o={key:r,data:s,_type:"data-get-response",_getter:i},i===window.windowerName?window.postMessageProxy(o):n.windowerFunctions.iterateChildren(function(e){i===e.windowerName&&e.postMessageProxy(o)})):n.windowerFunctions.iterateChildren(function(t){t.postMessageProxy(e.data)}))},!1),window.addEventListener("unload",function(){n.windowerFunctions.iterateChildren(function(e){e.close()})}))}(),{send:function(e){n.postMessageProxy({_sender:window.windowerName,message:e})},listen:function(e){if(r)throw new Error(window.windowerName+" already has a listener - please use windower.unlisten() first");r=function(t){t.origin===window.location.origin&&!t.data._type&&window.windowerName!==t.data._sender&&e.call(window,t.data.message)},window.addEventListener("message",r)},unlisten:function(){r&&(window.removeEventListener("message",r),r=null)},set:function(e,t){n.postMessageProxy({key:e,data:t,_type:"data-set-request",_setter:window.windowerName})},get:function(e,t){var r=function(n){n.origin===window.location.origin&&n.data._type==="data-get-response"&&n.data.key===e&&(window.removeEventListener("message",r),t(n.data.data))};window.addEventListener("message",r),n.postMessageProxy({key:e,_type:"data-get-request",_getter:window.windowerName})}}});