/*
RequireJS 1.0.7 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
Available via the MIT or new BSD license.
see: http://github.com/jrburke/requirejs for details
*/
var requirejs,require,define;
(function(){function J(a){return N.call(a)==="[object Function]"}function F(a){return N.call(a)==="[object Array]"}function Z(a,c,l){for(var j in c)if(!(j in K)&&(!(j in a)||l))a[j]=c[j];return d}function O(a,c,d){a=Error(c+"\nhttp://requirejs.org/docs/errors.html#"+a);if(d)a.originalError=d;return a}function $(a,c,d){var j,k,s;for(j=0;s=c[j];j++){s=typeof s==="string"?{name:s}:s;k=s.location;if(d&&(!k||k.indexOf("/")!==0&&k.indexOf(":")===-1))k=d+"/"+(k||s.name);a[s.name]={name:s.name,location:k||
s.name,main:(s.main||"main").replace(ea,"").replace(aa,"")}}}function U(a,c){a.holdReady?a.holdReady(c):c?a.readyWait+=1:a.ready(!0)}function fa(a){function c(b,f){var g,m;if(b&&b.charAt(0)===".")if(f){q.pkgs[f]?f=[f]:(f=f.split("/"),f=f.slice(0,f.length-1));g=b=f.concat(b.split("/"));var a;for(m=0;a=g[m];m++)if(a===".")g.splice(m,1),m-=1;else if(a==="..")if(m===1&&(g[2]===".."||g[0]===".."))break;else m>0&&(g.splice(m-1,2),m-=2);m=q.pkgs[g=b[0]];b=b.join("/");m&&b===g+"/"+m.main&&(b=g)}else b.indexOf("./")===
0&&(b=b.substring(2));return b}function l(b,f){var g=b?b.indexOf("!"):-1,m=null,a=f?f.name:null,h=b,e,d;g!==-1&&(m=b.substring(0,g),b=b.substring(g+1,b.length));m&&(m=c(m,a));b&&(m?e=(g=n[m])&&g.normalize?g.normalize(b,function(b){return c(b,a)}):c(b,a):(e=c(b,a),d=F[e],d||(d=i.nameToUrl(b,null,f),F[e]=d)));return{prefix:m,name:e,parentMap:f,url:d,originalName:h,fullName:m?m+"!"+(e||""):e}}function j(){var b=!0,f=q.priorityWait,g,a;if(f){for(a=0;g=f[a];a++)if(!r[g]){b=!1;break}b&&delete q.priorityWait}return b}
function k(b,f,g){return function(){var a=ga.call(arguments,0),c;if(g&&J(c=a[a.length-1]))c.__requireJsBuild=!0;a.push(f);return b.apply(null,a)}}function s(b,f,g){f=k(g||i.require,b,f);Z(f,{nameToUrl:k(i.nameToUrl,b),toUrl:k(i.toUrl,b),defined:k(i.requireDefined,b),specified:k(i.requireSpecified,b),isBrowser:d.isBrowser});return f}function p(b){var f,g,a,c=b.callback,h=b.map,e=h.fullName,ba=b.deps;a=b.listeners;if(c&&J(c)){if(q.catchError.define)try{g=d.execCb(e,b.callback,ba,n[e])}catch(j){f=j}else g=
d.execCb(e,b.callback,ba,n[e]);if(e)(c=b.cjsModule)&&c.exports!==void 0&&c.exports!==n[e]?g=n[e]=b.cjsModule.exports:g===void 0&&b.usingExports?g=n[e]:(n[e]=g,G[e]&&(S[e]=!0))}else e&&(g=n[e]=c,G[e]&&(S[e]=!0));if(w[b.id])delete w[b.id],b.isDone=!0,i.waitCount-=1,i.waitCount===0&&(I=[]);delete L[e];if(d.onResourceLoad&&!b.placeholder)d.onResourceLoad(i,h,b.depArray);if(f)return g=(e?l(e).url:"")||f.fileName||f.sourceURL,a=f.moduleTree,f=O("defineerror",'Error evaluating module "'+e+'" at location "'+
g+'":\n'+f+"\nfileName:"+g+"\nlineNumber: "+(f.lineNumber||f.line),f),f.moduleName=e,f.moduleTree=a,d.onError(f);for(f=0;c=a[f];f++)c(g)}function t(b,f){return function(g){b.depDone[f]||(b.depDone[f]=!0,b.deps[f]=g,b.depCount-=1,b.depCount||p(b))}}function o(b,f){var g=f.map,a=g.fullName,c=g.name,h=M[b]||(M[b]=n[b]),e;if(!f.loading)f.loading=!0,e=function(b){f.callback=function(){return b};p(f);r[f.id]=!0;z()},e.fromText=function(b,f){var g=P;r[b]=!1;i.scriptCount+=1;i.fake[b]=!0;g&&(P=!1);d.exec(f);
g&&(P=!0);i.completeLoad(b)},a in n?e(n[a]):h.load(c,s(g.parentMap,!0,function(b,a){var c=[],e,m;for(e=0;m=b[e];e++)m=l(m,g.parentMap),b[e]=m.fullName,m.prefix||c.push(b[e]);f.moduleDeps=(f.moduleDeps||[]).concat(c);return i.require(b,a)}),e,q)}function x(b){w[b.id]||(w[b.id]=b,I.push(b),i.waitCount+=1)}function C(b){this.listeners.push(b)}function u(b,f){var g=b.fullName,a=b.prefix,c=a?M[a]||(M[a]=n[a]):null,h,e;g&&(h=L[g]);if(!h&&(e=!0,h={id:(a&&!c?N++ +"__p@:":"")+(g||"__r@"+N++),map:b,depCount:0,
depDone:[],depCallbacks:[],deps:[],listeners:[],add:C},A[h.id]=!0,g&&(!a||M[a])))L[g]=h;a&&!c?(g=l(a),a in n&&!n[a]&&(delete n[a],delete Q[g.url]),a=u(g,!0),a.add(function(){var f=l(b.originalName,b.parentMap),f=u(f,!0);h.placeholder=!0;f.add(function(b){h.callback=function(){return b};p(h)})})):e&&f&&(r[h.id]=!1,i.paused.push(h),x(h));return h}function B(b,f,a,c){var b=l(b,c),d=b.name,h=b.fullName,e=u(b),j=e.id,k=e.deps,o;if(h){if(h in n||r[j]===!0||h==="jquery"&&q.jQuery&&q.jQuery!==a().fn.jquery)return;
A[j]=!0;r[j]=!0;h==="jquery"&&a&&V(a())}e.depArray=f;e.callback=a;for(a=0;a0)){if(q.priorityWait)if(j())z();else return;for(h in r)if(!(h in K)&&(c=!0,!r[h]))if(b)a+=h+" ";else if(l=!0,h.indexOf("!")===-1){k=[];break}else(e=L[h]&&L[h].moduleDeps)&&k.push.apply(k,e);if(c||i.waitCount){if(b&&a)return b=O("timeout","Load timeout for modules: "+a),b.requireType="timeout",b.requireModules=a,b.contextName=i.contextName,d.onError(b);if(l&&k.length)for(a=
0;h=w[k[a]];a++)if(h=E(h,{})){y(h,{});break}if(!b&&(l||i.scriptCount)){if((H||ca)&&!W)W=setTimeout(function(){W=0;D()},50)}else{if(i.waitCount){for(a=0;h=I[a];a++)y(h,{});i.paused.length&&z();X<5&&(X+=1,D())}X=0;d.checkReadyState()}}}}var i,z,q={waitSeconds:7,baseUrl:"./",paths:{},pkgs:{},catchError:{}},R=[],A={require:!0,exports:!0,module:!0},F={},n={},r={},w={},I=[],Q={},N=0,L={},M={},G={},S={},Y=0;V=function(b){if(!i.jQuery&&(b=b||(typeof jQuery!=="undefined"?jQuery:null))&&!(q.jQuery&&b.fn.jquery!==
q.jQuery)&&("holdReady"in b||"readyWait"in b))if(i.jQuery=b,v(["jquery",[],function(){return jQuery}]),i.scriptCount)U(b,!0),i.jQueryIncremented=!0};z=function(){var b,a,c,l,k,h;i.takeGlobalQueue();Y+=1;if(i.scriptCount<=0)i.scriptCount=0;for(;R.length;)if(b=R.shift(),b[0]===null)return d.onError(O("mismatch","Mismatched anonymous define() module: "+b[b.length-1]));else v(b);if(!q.priorityWait||j())for(;i.paused.length;){k=i.paused;i.pausedCount+=k.length;i.paused=[];for(l=0;b=k[l];l++)a=b.map,c=
a.url,h=a.fullName,a.prefix?o(a.prefix,b):!Q[c]&&!r[h]&&(d.load(i,h,c),c.indexOf("empty:")!==0&&(Q[c]=!0));i.startTime=(new Date).getTime();i.pausedCount-=k.length}Y===1&&D();Y-=1};i={contextName:a,config:q,defQueue:R,waiting:w,waitCount:0,specified:A,loaded:r,urlMap:F,urlFetched:Q,scriptCount:0,defined:n,paused:[],pausedCount:0,plugins:M,needFullExec:G,fake:{},fullExec:S,managerCallbacks:L,makeModuleMap:l,normalize:c,configure:function(b){var a,c,d;b.baseUrl&&b.baseUrl.charAt(b.baseUrl.length-1)!==
"/"&&(b.baseUrl+="/");a=q.paths;d=q.pkgs;Z(q,b,!0);if(b.paths){for(c in b.paths)c in K||(a[c]=b.paths[c]);q.paths=a}if((a=b.packagePaths)||b.packages){if(a)for(c in a)c in K||$(d,a[c],c);b.packages&&$(d,b.packages);q.pkgs=d}if(b.priority)c=i.requireWait,i.requireWait=!1,z(),i.require(b.priority),z(),i.requireWait=c,q.priorityWait=b.priority;if(b.deps||b.callback)i.require(b.deps||[],b.callback)},requireDefined:function(b,a){return l(b,a).fullName in n},requireSpecified:function(b,a){return l(b,a).fullName in
A},require:function(b,c,g){if(typeof b==="string"){if(J(c))return d.onError(O("requireargs","Invalid require call"));if(d.get)return d.get(i,b,c);c=l(b,c);b=c.fullName;return!(b in n)?d.onError(O("notloaded","Module name '"+c.fullName+"' has not been loaded yet for context: "+a)):n[b]}(b&&b.length||c)&&B(null,b,c,g);if(!i.requireWait)for(;!i.scriptCount&&i.paused.length;)z();return i.require},takeGlobalQueue:function(){T.length&&(ia.apply(i.defQueue,[i.defQueue.length-1,0].concat(T)),T=[])},completeLoad:function(b){var a;
for(i.takeGlobalQueue();R.length;)if(a=R.shift(),a[0]===null){a[0]=b;break}else if(a[0]===b)break;else v(a),a=null;a?v(a):v([b,[],b==="jquery"&&typeof jQuery!=="undefined"?function(){return jQuery}:null]);d.isAsync&&(i.scriptCount-=1);z();d.isAsync||(i.scriptCount-=1)},toUrl:function(b,a){var c=b.lastIndexOf("."),d=null;c!==-1&&(d=b.substring(c,b.length),b=b.substring(0,c));return i.nameToUrl(b,d,a)},nameToUrl:function(b,a,g){var l,k,h,e,j=i.config,b=c(b,g&&g.fullName);if(d.jsExtRegExp.test(b))a=
b+(a?a:"");else{l=j.paths;k=j.pkgs;g=b.split("/");for(e=g.length;e>0;e--)if(h=g.slice(0,e).join("/"),l[h]){g.splice(0,e,l[h]);break}else if(h=k[h]){b=b===h.name?h.location+"/"+h.main:h.location;g.splice(0,e,b);break}a=g.join("/")+(a||".js");a=(a.charAt(0)==="/"||a.match(/^\w+:/)?"":j.baseUrl)+a}return j.urlArgs?a+((a.indexOf("?")===-1?"?":"&")+j.urlArgs):a}};i.jQueryCheck=V;i.resume=z;return i}function ja(){var a,c,d;if(B&&B.readyState==="interactive")return B;a=document.getElementsByTagName("script");
for(c=a.length-1;c>-1&&(d=a[c]);c--)if(d.readyState==="interactive")return B=d;return null}var ka=/(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,la=/require\(\s*["']([^'"\s]+)["']\s*\)/g,ea=/^\.\//,aa=/\.js$/,N=Object.prototype.toString,t=Array.prototype,ga=t.slice,ia=t.splice,H=!!(typeof window!=="undefined"&&navigator&&document),ca=!H&&typeof importScripts!=="undefined",ma=H&&navigator.platform==="PLAYSTATION 3"?/^complete$/:/^(complete|loaded)$/,da=typeof opera!=="undefined"&&opera.toString()==="[object Opera]",
K={},C={},T=[],B=null,X=0,P=!1,ha={require:!0,module:!0,exports:!0},d,t={},I,x,u,D,o,v,E,A,y,V,W;if(typeof define==="undefined"){if(typeof requirejs!=="undefined")if(J(requirejs))return;else t=requirejs,requirejs=void 0;typeof require!=="undefined"&&!J(require)&&(t=require,require=void 0);d=requirejs=function(a,c,d){var j="_",k;!F(a)&&typeof a!=="string"&&(k=a,F(c)?(a=c,c=d):a=[]);if(k&&k.context)j=k.context;d=C[j]||(C[j]=fa(j));k&&d.configure(k);return d.require(a,c)};d.config=function(a){return d(a)};
require||(require=d);d.toUrl=function(a){return C._.toUrl(a)};d.version="1.0.7";d.jsExtRegExp=/^\/|:|\?|\.js$/;x=d.s={contexts:C,skipAsync:{}};if(d.isAsync=d.isBrowser=H)if(u=x.head=document.getElementsByTagName("head")[0],D=document.getElementsByTagName("base")[0])u=x.head=D.parentNode;d.onError=function(a){throw a;};d.load=function(a,c,l){d.resourcesReady(!1);a.scriptCount+=1;d.attach(l,a,c);if(a.jQuery&&!a.jQueryIncremented)U(a.jQuery,!0),a.jQueryIncremented=!0};define=function(a,c,d){var j,k;
typeof a!=="string"&&(d=c,c=a,a=null);F(c)||(d=c,c=[]);!c.length&&J(d)&&d.length&&(d.toString().replace(ka,"").replace(la,function(a,d){c.push(d)}),c=(d.length===1?["require"]:["require","exports","module"]).concat(c));if(P&&(j=I||ja()))a||(a=j.getAttribute("data-requiremodule")),k=C[j.getAttribute("data-requirecontext")];(k?k.defQueue:T).push([a,c,d])};define.amd={multiversion:!0,plugins:!0,jQuery:!0};d.exec=function(a){return eval(a)};d.execCb=function(a,c,d,j){return c.apply(j,d)};d.addScriptToDom=
function(a){I=a;D?u.insertBefore(a,D):u.appendChild(a);I=null};d.onScriptLoad=function(a){var c=a.currentTarget||a.srcElement,l;if(a.type==="load"||c&&ma.test(c.readyState))B=null,a=c.getAttribute("data-requirecontext"),l=c.getAttribute("data-requiremodule"),C[a].completeLoad(l),c.detachEvent&&!da?c.detachEvent("onreadystatechange",d.onScriptLoad):c.removeEventListener("load",d.onScriptLoad,!1)};d.attach=function(a,c,l,j,k,o){var p;if(H)return j=j||d.onScriptLoad,p=c&&c.config&&c.config.xhtml?document.createElementNS("http://www.w3.org/1999/xhtml",
"html:script"):document.createElement("script"),p.type=k||c&&c.config.scriptType||"text/javascript",p.charset="utf-8",p.async=!x.skipAsync[a],c&&p.setAttribute("data-requirecontext",c.contextName),p.setAttribute("data-requiremodule",l),p.attachEvent&&!da?(P=!0,o?p.onreadystatechange=function(){if(p.readyState==="loaded")p.onreadystatechange=null,p.attachEvent("onreadystatechange",j),o(p)}:p.attachEvent("onreadystatechange",j)):p.addEventListener("load",j,!1),p.src=/a,o||d.addScriptToDom(p),p;else ca&&
(importScripts(a),c.completeLoad(l));return null};if(H){o=document.getElementsByTagName("script");for(A=o.length-1;A>-1&&(v=o[A]);A--){if(!u)u=v.parentNode;if(E=v.getAttribute("data-main")){if(!t.baseUrl)o=E.split("/"),v=o.pop(),o=o.length?o.join("/")+"/":"./",t.baseUrl=o,E=v.replace(aa,"");t.deps=t.deps?t.deps.concat(E):[E];break}}}d.checkReadyState=function(){var a=x.contexts,c;for(c in a)if(!(c in K)&&a[c].waitCount)return;d.resourcesReady(!0)};d.resourcesReady=function(a){var c,l;d.resourcesDone=
a;if(d.resourcesDone)for(l in a=x.contexts,a)if(!(l in K)&&(c=a[l],c.jQueryIncremented))U(c.jQuery,!1),c.jQueryIncremented=!1};d.pageLoaded=function(){if(document.readyState!=="complete")document.readyState="complete"};if(H&&document.addEventListener&&!document.readyState)document.readyState="loading",window.addEventListener("load",d.pageLoaded,!1);d(t);if(d.isAsync&&typeof setTimeout!=="undefined")y=x.contexts[t.context||"_"],y.requireWait=!0,setTimeout(function(){y.requireWait=!1;y.scriptCount||
y.resume();d.checkReadyState()},0)}})();
(function(window) {
if (typeof define === "function" && define.amd) {
define("diysdk.jquery", [], function () {
return window.jQuery;
});
define("core.jquery", [], function () {
return window.jQuery;
});
}
})(window);/**
* jQuery JSON Plugin
* version: 2.3 (2011-09-17)
*
* This document is licensed as free software under the terms of the
* MIT License: http://www.opensource.org/licenses/mit-license.php
*
* Brantley Harris wrote this plugin. It is based somewhat on the JSON.org
* website's http://www.json.org/json2.js, which proclaims:
* "NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.", a sentiment that
* I uphold.
*
* It is also influenced heavily by MochiKit's serializeJSON, which is
* copyrighted 2005 by Bob Ippolito.
*/
require(['diysdk.jquery'], function ($) {
var escapeable = /["\\\x00-\x1f\x7f-\x9f]/g,
meta = {
'\b': '\\b',
'\t': '\\t',
'\n': '\\n',
'\f': '\\f',
'\r': '\\r',
'"': '\\"',
'\\': '\\\\'
};
/**
* jQuery.toJSON
* Converts the given argument into a JSON respresentation.
*
* @param o {Mixed} The json-serializble *thing* to be converted
*
* If an object has a toJSON prototype, that will be used to get the representation.
* Non-integer/string keys are skipped in the object, as are keys that point to a
* function.
*
*/
$.toJSON = typeof JSON === 'object' && JSON.stringify
? JSON.stringify
: function (o) {
if (o === null) {
return 'null';
}
var type = typeof o;
if (type === 'undefined') {
return undefined;
}
if (type === 'number' || type === 'boolean') {
return '' + o;
}
if (type === 'string') {
return $.quoteString(o);
}
if (type === 'object') {
if (typeof o.toJSON === 'function') {
return $.toJSON(o.toJSON());
}
if (o.constructor === Date) {
var month = o.getUTCMonth() + 1,
day = o.getUTCDate(),
year = o.getUTCFullYear(),
hours = o.getUTCHours(),
minutes = o.getUTCMinutes(),
seconds = o.getUTCSeconds(),
milli = o.getUTCMilliseconds();
if (month < 10) {
month = '0' + month;
}
if (day < 10) {
day = '0' + day;
}
if (hours < 10) {
hours = '0' + hours;
}
if (minutes < 10) {
minutes = '0' + minutes;
}
if (seconds < 10) {
seconds = '0' + seconds;
}
if (milli < 100) {
milli = '0' + milli;
}
if (milli < 10) {
milli = '0' + milli;
}
return '"' + year + '-' + month + '-' + day + 'T' +
hours + ':' + minutes + ':' + seconds +
'.' + milli + 'Z"';
}
if (o.constructor === Array) {
var ret = [];
for (var i = 0; i < o.length; i++) {
ret.push($.toJSON(o[i]) || 'null');
}
return '[' + ret.join(',') + ']';
}
var name,
val,
pairs = [];
for (var k in o) {
type = typeof k;
if (type === 'number') {
name = '"' + k + '"';
} else if (type === 'string') {
name = $.quoteString(k);
} else {
// Keys must be numerical or string. Skip others
continue;
}
type = typeof o[k];
if (type === 'function' || type === 'undefined') {
// Invalid values like these return undefined
// from toJSON, however those object members
// shouldn't be included in the JSON string at all.
continue;
}
val = $.toJSON(o[k]);
pairs.push(name + ':' + val);
}
return '{' + pairs.join(',') + '}';
}
};
/**
* jQuery.evalJSON
* Evaluates a given piece of json source.
*
* @param src {String}
*/
$.evalJSON = typeof JSON === 'object' && JSON.parse
? JSON.parse
: function (src) {
return eval('(' + src + ')');
};
/**
* jQuery.secureEvalJSON
* Evals JSON in a way that is *more* secure.
*
* @param src {String}
*/
$.secureEvalJSON = typeof JSON === 'object' && JSON.parse
? JSON.parse
: function (src) {
var filtered =
src
.replace(/\\["\\\/bfnrtu]/g, '@')
.replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']')
.replace(/(?:^|:|,)(?:\s*\[)+/g, '');
if (/^[\],:{}\s]*$/.test(filtered)) {
return eval('(' + src + ')');
} else {
throw new SyntaxError('Error parsing JSON, source is not valid.');
}
};
/**
* jQuery.quoteString
* Returns a string-repr of a string, escaping quotes intelligently.
* Mostly a support function for toJSON.
* Examples:
* >>> jQuery.quoteString('apple')
* "apple"
*
* >>> jQuery.quoteString('"Where are we going?", she asked.')
* "\"Where are we going?\", she asked."
*/
$.quoteString = function (string) {
if (string.match(escapeable)) {
return '"' + string.replace(escapeable, function (a) {
var c = meta[a];
if (typeof c === 'string') {
return c;
}
c = a.charCodeAt();
return '\\u00' + Math.floor(c / 16).toString(16) + (c % 16).toString(16);
}) + '"';
}
return '"' + string + '"';
};
});/**
* Replacement for $.browser, which was removed in $ 1.10
* This is copy-paste from jQuery-migrate plugin
*/
require(['diysdk.jquery'], function (jQuery) {
;(function ($, undefined) {
var matched, browser, uaMatch;
uaMatch = function (ua) {
ua = ua.toLowerCase();
var match = /(chrome)[ \/]([\w.]+)/.exec(ua) ||
/(webkit)[ \/]([\w.]+)/.exec(ua) ||
/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(ua) ||
/(msie) ([\w.]+)/.exec(ua) ||
ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(ua) ||
[];
return {
browser: match[ 1 ] || "",
version: match[ 2 ] || "0"
};
};
// Don't clobber any existing $.browser in case it's different
if (!$.browser) {
matched = uaMatch(navigator.userAgent);
browser = {};
if (matched.browser) {
browser[ matched.browser ] = true;
browser.version = matched.version;
}
// Chrome is Webkit, but Webkit is also Safari.
if (browser.chrome) {
browser.webkit = true;
} else if (browser.webkit) {
browser.safari = true;
}
$.browser = browser;
}
}(jQuery));
});/**
* jQuery subclass plugin. This subclasses a jQuery instance so that plugins
* can be added to the new one without polluting the original instance
*
* Plugin code copied from jquery-migrate plugin. Code is identical to jQuery.sub()
* which was removed in jQuery 1.8
*/
require(['diysdk.jquery'], function (jQuery) {
;(function ($) {
$.sub = function () {
function jQuerySub(selector, context) {
return new jQuerySub.fn.init(selector, context);
}
$.extend(true, jQuerySub, this);
jQuerySub.superclass = this;
jQuerySub.fn = jQuerySub.prototype = this();
jQuerySub.fn.constructor = jQuerySub;
jQuerySub.sub = this.sub;
jQuerySub.fn.init = function init(selector, context) {
if (context && context instanceof $ && !(context instanceof jQuerySub)) {
context = jQuerySub(context);
}
return $.fn.init.call(this, selector, context, rootjQuerySub);
};
jQuerySub.fn.init.prototype = jQuerySub.fn;
var rootjQuerySub = jQuerySub(document);
return jQuerySub;
};
}(jQuery));
});(function (window) {
if (typeof window.diysdk == 'undefined') {
window.diysdk = {};
}
if (typeof window.diysdk.webcomponents == 'undefined') {
window.diysdk.webcomponents = {};
}
})(window);/**
* Simple javascript inheritance class
*
* Modifications by 1&1:
* - added static inheritance (lines 64-70)
*/
(function ($) {
var initializing = false, fnTest = /xyz/.test(function () {
xyz;
}) ? /\b_super\b/ : /.*/;
// The base Class implementation (does nothing)
this.Class = function () {
};
// Create a new Class that inherits from this class
Class.extend = function (prop) {
var _super = this.prototype;
// Instantiate a base class (but only create the instance,
// don't run the init constructor)
initializing = true;
var prototype = new this();
initializing = false;
// Copy the properties over onto the new prototype
for (var name in prop) {
// Check if we're overwriting an existing function
prototype[name] = typeof prop[name] == "function" &&
typeof _super[name] == "function" && fnTest.test(prop[name]) ?
(function (name, fn) {
return function () {
var tmp = this._super;
// Add a new ._super() method that is the same method
// but on the super-class
this._super = _super[name];
// The method only need to be bound temporarily, so we
// remove it when we're done executing
var ret = fn.apply(this, arguments);
this._super = tmp;
return ret;
};
})(name, prop[name]) :
prop[name];
}
// The dummy class constructor
function Class() {
// All construction is actually done in the init method
if (!initializing && this.init)
this.init.apply(this, arguments);
}
// Populate our constructed prototype object
Class.prototype = prototype;
// Enforce the constructor to be what we expect
Class.prototype.constructor = Class;
// And make this class extendable
Class.extend = arguments.callee;
// Add "static" properties
for (var cName in this) {
if (cName != 'extend' && cName != 'mixin' && cName != 'prototype') {
Class[cName] = cloneObject(this[cName]);
}
}
return Class;
};
// quick fix for deep cloning objects (no references)
// TODO: remove jQuery, implement recursive function
function cloneObject(obj) {
if (typeof obj != "object") {
return obj;
}
if ($) {
return $.extend(true, {}, obj);
} else if (JSON && typeof JSON.decode == "function" && typeof JSON.encode == "function") {
return JSON.decode(JSON.encode(obj));
} else {
throw new Exception("clone not supported");
}
}
})(window.jQuery);(function($) {
/**
* Integrator-class for handling the initialisation of webcomponents before
* rendering.
*
* - creates object of web/uicomponents from basic.js (or derived classes)
* - creates objects of embedded web/uicomponents
* - loads js/css files
* - handles initial wiring of events between ui-components in a webcomponent.
*/
diysdk.webcomponentIntegrator = Class.extend({
loadedResources : [],
/**
* Loads resources by using requirejs.
*
* Initial call for create an instance of a webcomponent
*
* @param {object} data - json-ified data coming from the server
*
* @param {string} baseSaveUrl
*
* @param {function} callback - hook for actions after creating an wc instance.
*
* @retrun {string} instanceId the id of the created instance
*
*/
create : function(data, baseSaveUrl, callback) {
diysdk.cssloader.load(data.resources.css);
var absoluteUrl = /^https?:\/\//i;
var makeProxyUrl = function(url) {
return absoluteUrl.test(url) || url.indexOf('//') === 0 ? url : baseSaveUrl + url;
};
var jsResources = $.map(data.resources.js, $.proxy(function(url) {
url = this.resourceUrl(url);
if (url.indexOf('order!') === 0) {
return 'order!' + makeProxyUrl(url.substr(6));
} else {
return makeProxyUrl(url);
}
}, this));
require(jsResources, $.proxy(function() {
if (typeof baseSaveUrl === "undefined") {
baseSaveUrl = data.instance.baseSaveUrl;
}
var instance = this.createInstance(data, baseSaveUrl);
if (typeof callback === "function") {
callback(data, instance);
}
}, this));
return data.instance.id;
},
/**
* Creates an new instance/object of a webcomponent based on instance-id
* from persistance.
*
* @param {object} data json-ified data coming from the server
*
* @param {string} baseSaveUrl
*
* @return {object} instance Instance/object of the new/retrieved webcomponent
*/
createInstance : function(data, baseSaveUrl) {
var instance = null;
if (diysdk.webcomponents[data.instance.id]) {
instance = diysdk.webcomponents[data.instance.id];
} else {
var componentClass = null;
if (diysdk[data.instance.app.name] && diysdk[data.instance.app.name][data.instance.name]) {
componentClass = diysdk[data.instance.app.name][data.instance.name];
} else {
componentClass = diysdk.basic;
}
instance = new componentClass(data, baseSaveUrl);
diysdk.webcomponents[data.instance.id] = instance;
}
this.createViewInstance({
instance: instance,
view: data.instance.view,
data: data.instance.data,
embeddedComponents: data.embeddedComponents,
baseSaveUrl: baseSaveUrl
});
return instance;
},
/**
* Creates client instances/objects for embedded components in a
* webcomponent and wires events between
*
* @param {object} parentView parent to all components in {components}
*
* @param {array} components array of child components of {parentInstance}
*
* @param {string} baseSaveUrl
*
*/
createEmbeddedInstances : function(parentView, components, baseSaveUrl, isSitebuilder) {
var embeddedInstances = {},
eventsToWire = [],
dataBindings = [];
$.each(components, $.proxy(function(id, component) {
var instance = null;
if (parentView && parentView.childInstances[id]) {
instance = parentView.childInstances[id];
} else {
instance = this.createOneEmbeddedInstance(component, parentView, baseSaveUrl, id, isSitebuilder);
// aggregate wiring events
if (component.events && component.events.length > 0) {
$.each(component.events, function(i, eventInfo) {
eventsToWire.push($.extend(eventInfo, {
instance : instance
}));
});
}
// aggregate data bindings
if (component.dataSource) {
dataBindings.push($.extend(component.dataSource, {
instance : instance
}));
}
}
embeddedInstances[id] = instance;
// init view
var mainJQ = $('#' + diysdk.fixJQueryIdSelector(component.id));
this.createViewInstance({
instance: instance,
view: component.view,
mainJQ: mainJQ,
data: component.data,
embeddedComponents: component.embeddedComponents,
parentView: parentView
});
}, this));
this.wireEmbeddedInstances(eventsToWire, embeddedInstances);
this.wireDataBindings(dataBindings, embeddedInstances);
},
/**
* Create and initialize a view instance
* @param {object} options = {
* view: {string} - the name of the view
* mainJQ: {jQuery DOM node} - the main div of the view (optional)
* data: {object} - data to pass to the view
* embeddedComponents: {array} - the embedded components
* baseSaveUrl: {string} - the base url of the proxy
* parentView: {object} - the parent view object
* }
*/
createViewInstance : function(options) {
var view = options.instance.initView(options.view, options.mainJQ, options.data, options.parentView);
// go into recursion for embedded components
if (options.embeddedComponents) {
this.createEmbeddedInstances(
view,
options.embeddedComponents,
options.baseSaveUrl,
options.instance.isSitebuilderMode()
);
}
if (view.name == 'web' && options.instance.isSitebuilderMode() == true) {
view.getMainJQ().webOverlay();
}
view.bindEvents();
if (typeof view.initChildInstances === "function") {
view.initChildInstances();
}
},
/**
* Creates an instance/object of a component based on configuration coming
* from server.
*
* @param {object} component json-ified configuration from server
*
* @param {object} parentView of the here new created instance
*
* @param {string} baseSaveUrl
*
* @param {string} internalId Id of the component given by the developer, visible
* only within the embedding component
*
* @return {object} instance The created instance
*/
createOneEmbeddedInstance : function(component, parentView, baseSaveUrl, internalId) {
var componentClass = null;
if (diysdk[component.app] && diysdk[component.app][component.component]) {
componentClass = diysdk[component.app][component.component];
} else {
componentClass = diysdk.basic;
}
// create new instance of {componentClass}
var instance = new componentClass(component.data, baseSaveUrl);
instance.internalId = internalId;
parentView.childInstances[internalId] = instance;
return instance;
},
/**
* Wires events of embedded components based on the configuration initially
* coming from markup
*
* @param {array} eventsToWire event configuration including callbacks
*
* @param {object} instances instances of embedded components
*
*/
wireEmbeddedInstances : function(eventsToWire, instances) {
$.each(eventsToWire, $.proxy(function(i, eventInfo) {
if (!instances[eventInfo.source]) {
console.warn("error wiring events: component not found: " + eventInfo.source);
return;
}
var sourceInstance = instances[eventInfo.source];
if (eventInfo.handler) {
var error = false;
if (!eventInfo.instance[eventInfo.handler]) {
console.warn("error wiring events: method not found: " + eventInfo.handler);
error = true;
}
if (!eventInfo.name) {
console.warn("error wiring events: event name not specified");
error = true;
}
if (!error) {
var handler = $.proxy(eventInfo.instance[eventInfo.handler], eventInfo.instance);
sourceInstance.on(eventInfo.name, handler);
}
}
}, this));
},
/**
* Wires events for data bindings
*
* @param {array} dataBindings The data bindings
* @param {array} instances The embedded instances
*/
wireDataBindings : function(dataBindings, instances) {
var paramValues = {};
$.each(dataBindings, $.proxy(function(i, dataBinding) {
if (!instances[dataBinding.source]) {
console.warn("error wiring events: component not found: " + dataBinding.source);
return;
}
var sourceInstance = instances[dataBinding.source];
var handler = $.proxy(function(value) {
var oldValue = paramValues[dataBinding.param];
paramValues[dataBinding.param] = value;
this.dataSourceUpdated({
oldValue : oldValue,
newValue : value,
param : dataBinding.param,
params : paramValues
});
}, dataBinding.instance);
sourceInstance.on('valueChange', handler);
}, this));
},
/**
* Checks if resource was already requested through any static proxy and returns the requested url
*
* @param {string} url - absolute/relative resource url, also handles !order prefix
*
* @return {string}
*/
resourceUrl : function(url) {
var resourceUrl = /.*\/proxy\/apps\/.*\/s\/(.*)/;
if (resourceUrl.test(url)) {
var urlPattern = url.replace(resourceUrl,'$1');
if (typeof this.loadedResources[urlPattern] === "undefined") {
this.loadedResources[urlPattern] = url;
}
return this.loadedResources[urlPattern];
} else {
return url;
}
}
});
diysdk.webcomponentIntegrator.myStaticProperties = {};
})(window.jQuery);(function($, window) {
/**
* get the absolute version of a URL
*/
var getAbsoluteUrl = function(url) {
if (/^[^:\/]+:\/\//.exec(url) || url.indexOf('//') === 0) {
// absolute URL
return url;
} else if (url.substring(0, 1) === '/') {
// domain-relative URL
return window.location.protocol + '//' + window.location.host + url;
}
// path-relative URL
return window.location.protocol + '//' + window.location.host + window.location.pathname.replace(/[^\/]*$/, '') + url;
};
window.diysdk.cssloader = {
// object with already loaded css files
loadedcss: [],
initialized : false,
init : function() {
$('head link[rel="stylesheet"], head link[type="text/css"]').each($.proxy(function(index, link) {
var url = getAbsoluteUrl(link.href);
if ($.inArray(url, this.loadedcss) === -1) {
this.loadedcss.push(url);
}
}, this));
this.initialized = true;
},
// load the given css if not already loaded
load: function(url) {
if (!this.initialized) {
this.init();
}
if(typeof url === 'object') {
var parent = this;
$.each(url, function(key, value) {
parent._loadaction(value);
});
} else if (typeof url === 'string') {
this._loadaction(url);
}
},
_loadaction: function(url) {
url = getAbsoluteUrl(url);
if ($.inArray(url, this.loadedcss) === -1) {
var sheet = $('');
sheet.appendTo('head');
if($.inArray(sheet[0].href, this.loadedcss) !== -1) {
// to prevent double loaded css files we remove it if our filter hasn't noticed it before
$('body').remove(sheet);
} else {
this.loadedcss[this.loadedcss.length] = sheet[0].href;
}
this.loadedcss.push(url);
}
}
};
})(window.jQuery, window);/*
Pure Javascript implementation of Uniforum message translation.
Copyright (C) 2008 Joshua I. Miller , all rights reserved
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published
by the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
USA.
=head1 NAME
Javascript Gettext - Javascript implemenation of GNU Gettext API.
=head1 SYNOPSIS
// //////////////////////////////////////////////////////////
// Optimum caching way
var gt = new Gettext({ "domain" : "myDomain" });
// rest is the same
// //////////////////////////////////////////////////////////
// The reson the shortcuts aren't exported by default is because they'd be
// glued to the single domain you created. So, if you're adding i18n support
// to some js library, you should use it as so:
if (typeof(MyNamespace) == 'undefined') MyNamespace = {};
MyNamespace.MyClass = function () {
var gtParms = { "domain" : 'MyNamespace_MyClass' };
this.gt = new Gettext(gtParams);
return this;
};
MyNamespace.MyClass.prototype._ = function (msgid) {
return this.gt.gettext(msgid);
};
MyNamespace.MyClass.prototype.something = function () {
var myString = this._("this will get translated");
};
// //////////////////////////////////////////////////////////
// Adding the shortcuts to a global scope is easier. If that's
// ok in your app, this is certainly easier.
var myGettext = new Gettext({ 'domain' : 'myDomain' });
function _ (msgid) {
return myGettext.gettext(msgid);
}
alert( _("text") );
// //////////////////////////////////////////////////////////
// Data structure of the json data
// NOTE: if you're loading via the
// in domain.json
json_locale_data = {
"mydomain" : {
// po header fields
"" : {
"plural-forms" : "...",
"lang" : "en",
},
// all the msgid strings and translations
"msgid" : [ "msgid_plural", "translation", "plural_translation" ],
},
};
// please see the included bin/po2json script for the details on this format
This method also allows you to use unsupported file formats, so long as you can parse them into the above format.
=item 2. Use AJAX to load language file.
Use XMLHttpRequest (actually, SJAX - syncronous) to load an external resource.
Supported external formats are:
=over
=item * Javascript Object Notation (.json)
(see bin/po2json)
type=application/json
=item * Uniforum Portable Object (.po)
(see GNU Gettext's xgettext)
type=application/x-po
=item * Machine Object (compiled .po) (.mo)
NOTE: .mo format isn't actually supported just yet, but support is planned.
(see GNU Gettext's msgfmt)
type=application/x-mo
=back
=back
=head1 METHODS
The following methods are implemented:
new Gettext(args)
textdomain (domain)
gettext (msgid)
dgettext (domainname, msgid)
dcgettext (domainname, msgid, LC_MESSAGES)
ngettext (msgid, msgid_plural, count)
dngettext (domainname, msgid, msgid_plural, count)
dcngettext (domainname, msgid, msgid_plural, count, LC_MESSAGES)
pgettext (msgctxt, msgid)
dpgettext (domainname, msgctxt, msgid)
dcpgettext (domainname, msgctxt, msgid, LC_MESSAGES)
npgettext (msgctxt, msgid, msgid_plural, count)
dnpgettext (domainname, msgctxt, msgid, msgid_plural, count)
dcnpgettext (domainname, msgctxt, msgid, msgid_plural, count, LC_MESSAGES)
strargs (string, args_array)
=head2 new Gettext (args)
Several methods of loading locale data are included. You may specify a plugin or alternative method of loading data by passing the data in as the "locale_data" option. For example:
var get_locale_data = function () {
// plugin does whatever to populate locale_data
return locale_data;
};
var gt = new Gettext( 'domain' : 'messages',
'locale_data' : get_locale_data() );
The above can also be used if locale data is specified in a statically included