mizugumo 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -0
- data/Gemfile.lock +15 -0
- data/README.rdoc +47 -8
- data/Rakefile +12 -3
- data/lib/generators/mizugumo/install/install_generator.rb +55 -18
- data/lib/generators/mizugumo/install/templates/disabled-javascripts/ns.min.js +109 -0
- data/lib/generators/mizugumo/install/templates/disabled-javascripts/rails.js +332 -0
- data/lib/generators/mizugumo/install/templates/javascripts/jquery-1.6.4.min.js +4 -0
- data/lib/generators/mizugumo/install/templates/javascripts/mizugumo.js +9 -0
- data/lib/generators/mizugumo/install/templates/javascripts/ninja_go.js +3 -0
- data/lib/generators/mizugumo/install/templates/javascripts/ninjascript.js +4566 -0
- data/lib/generators/rails/mizugumo/js_assets_generator.rb +26 -0
- data/lib/generators/rails/mizugumo/scaffold_controller_generator.rb +3 -0
- data/lib/generators/rails/mizugumo/view_generator.rb +15 -11
- data/lib/mizugumo.rb +5 -2
- data/lib/mizugumo_link_helper.rb +1 -1
- metadata +81 -91
- data/lib/generators/mizugumo/install/templates/javascripts/jquery-1.4.2.js +0 -6240
- data/lib/generators/mizugumo/install/templates/javascripts/jquery.ninja_script.js +0 -1172
- data/lib/generators/mizugumo/install/templates/javascripts/rails.js +0 -132
@@ -0,0 +1,4 @@
|
|
1
|
+
/*! jQuery v1.6.4 http://jquery.com/ | http://jquery.org/license */
|
2
|
+
(function(a,b){function cu(a){return f.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}function cr(a){if(!cg[a]){var b=c.body,d=f("<"+a+">").appendTo(b),e=d.css("display");d.remove();if(e==="none"||e===""){ch||(ch=c.createElement("iframe"),ch.frameBorder=ch.width=ch.height=0),b.appendChild(ch);if(!ci||!ch.createElement)ci=(ch.contentWindow||ch.contentDocument).document,ci.write((c.compatMode==="CSS1Compat"?"<!doctype html>":"")+"<html><body>"),ci.close();d=ci.createElement(a),ci.body.appendChild(d),e=f.css(d,"display"),b.removeChild(ch)}cg[a]=e}return cg[a]}function cq(a,b){var c={};f.each(cm.concat.apply([],cm.slice(0,b)),function(){c[this]=a});return c}function cp(){cn=b}function co(){setTimeout(cp,0);return cn=f.now()}function cf(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}function ce(){try{return new a.XMLHttpRequest}catch(b){}}function b$(a,c){a.dataFilter&&(c=a.dataFilter(c,a.dataType));var d=a.dataTypes,e={},g,h,i=d.length,j,k=d[0],l,m,n,o,p;for(g=1;g<i;g++){if(g===1)for(h in a.converters)typeof h=="string"&&(e[h.toLowerCase()]=a.converters[h]);l=k,k=d[g];if(k==="*")k=l;else if(l!=="*"&&l!==k){m=l+" "+k,n=e[m]||e["* "+k];if(!n){p=b;for(o in e){j=o.split(" ");if(j[0]===l||j[0]==="*"){p=e[j[1]+" "+k];if(p){o=e[o],o===!0?n=p:p===!0&&(n=o);break}}}}!n&&!p&&f.error("No conversion from "+m.replace(" "," to ")),n!==!0&&(c=n?n(c):p(o(c)))}}return c}function bZ(a,c,d){var e=a.contents,f=a.dataTypes,g=a.responseFields,h,i,j,k;for(i in g)i in d&&(c[g[i]]=d[i]);while(f[0]==="*")f.shift(),h===b&&(h=a.mimeType||c.getResponseHeader("content-type"));if(h)for(i in e)if(e[i]&&e[i].test(h)){f.unshift(i);break}if(f[0]in d)j=f[0];else{for(i in d){if(!f[0]||a.converters[i+" "+f[0]]){j=i;break}k||(k=i)}j=j||k}if(j){j!==f[0]&&f.unshift(j);return d[j]}}function bY(a,b,c,d){if(f.isArray(b))f.each(b,function(b,e){c||bA.test(a)?d(a,e):bY(a+"["+(typeof e=="object"||f.isArray(e)?b:"")+"]",e,c,d)});else if(!c&&b!=null&&typeof b=="object")for(var e in b)bY(a+"["+e+"]",b[e],c,d);else d(a,b)}function bX(a,c){var d,e,g=f.ajaxSettings.flatOptions||{};for(d in c)c[d]!==b&&((g[d]?a:e||(e={}))[d]=c[d]);e&&f.extend(!0,a,e)}function bW(a,c,d,e,f,g){f=f||c.dataTypes[0],g=g||{},g[f]=!0;var h=a[f],i=0,j=h?h.length:0,k=a===bP,l;for(;i<j&&(k||!l);i++)l=h[i](c,d,e),typeof l=="string"&&(!k||g[l]?l=b:(c.dataTypes.unshift(l),l=bW(a,c,d,e,l,g)));(k||!l)&&!g["*"]&&(l=bW(a,c,d,e,"*",g));return l}function bV(a){return function(b,c){typeof b!="string"&&(c=b,b="*");if(f.isFunction(c)){var d=b.toLowerCase().split(bL),e=0,g=d.length,h,i,j;for(;e<g;e++)h=d[e],j=/^\+/.test(h),j&&(h=h.substr(1)||"*"),i=a[h]=a[h]||[],i[j?"unshift":"push"](c)}}}function by(a,b,c){var d=b==="width"?a.offsetWidth:a.offsetHeight,e=b==="width"?bt:bu;if(d>0){c!=="border"&&f.each(e,function(){c||(d-=parseFloat(f.css(a,"padding"+this))||0),c==="margin"?d+=parseFloat(f.css(a,c+this))||0:d-=parseFloat(f.css(a,"border"+this+"Width"))||0});return d+"px"}d=bv(a,b,b);if(d<0||d==null)d=a.style[b]||0;d=parseFloat(d)||0,c&&f.each(e,function(){d+=parseFloat(f.css(a,"padding"+this))||0,c!=="padding"&&(d+=parseFloat(f.css(a,"border"+this+"Width"))||0),c==="margin"&&(d+=parseFloat(f.css(a,c+this))||0)});return d+"px"}function bl(a,b){b.src?f.ajax({url:b.src,async:!1,dataType:"script"}):f.globalEval((b.text||b.textContent||b.innerHTML||"").replace(bd,"/*$0*/")),b.parentNode&&b.parentNode.removeChild(b)}function bk(a){f.nodeName(a,"input")?bj(a):"getElementsByTagName"in a&&f.grep(a.getElementsByTagName("input"),bj)}function bj(a){if(a.type==="checkbox"||a.type==="radio")a.defaultChecked=a.checked}function bi(a){return"getElementsByTagName"in a?a.getElementsByTagName("*"):"querySelectorAll"in a?a.querySelectorAll("*"):[]}function bh(a,b){var c;if(b.nodeType===1){b.clearAttributes&&b.clearAttributes(),b.mergeAttributes&&b.mergeAttributes(a),c=b.nodeName.toLowerCase();if(c==="object")b.outerHTML=a.outerHTML;else if(c!=="input"||a.type!=="checkbox"&&a.type!=="radio"){if(c==="option")b.selected=a.defaultSelected;else if(c==="input"||c==="textarea")b.defaultValue=a.defaultValue}else a.checked&&(b.defaultChecked=b.checked=a.checked),b.value!==a.value&&(b.value=a.value);b.removeAttribute(f.expando)}}function bg(a,b){if(b.nodeType===1&&!!f.hasData(a)){var c=f.expando,d=f.data(a),e=f.data(b,d);if(d=d[c]){var g=d.events;e=e[c]=f.extend({},d);if(g){delete e.handle,e.events={};for(var h in g)for(var i=0,j=g[h].length;i<j;i++)f.event.add(b,h+(g[h][i].namespace?".":"")+g[h][i].namespace,g[h][i],g[h][i].data)}}}}function bf(a,b){return f.nodeName(a,"table")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function V(a,b,c){b=b||0;if(f.isFunction(b))return f.grep(a,function(a,d){var e=!!b.call(a,d,a);return e===c});if(b.nodeType)return f.grep(a,function(a,d){return a===b===c});if(typeof b=="string"){var d=f.grep(a,function(a){return a.nodeType===1});if(Q.test(b))return f.filter(b,d,!c);b=f.filter(b,d)}return f.grep(a,function(a,d){return f.inArray(a,b)>=0===c})}function U(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function M(a,b){return(a&&a!=="*"?a+".":"")+b.replace(y,"`").replace(z,"&")}function L(a){var b,c,d,e,g,h,i,j,k,l,m,n,o,p=[],q=[],r=f._data(this,"events");if(!(a.liveFired===this||!r||!r.live||a.target.disabled||a.button&&a.type==="click")){a.namespace&&(n=new RegExp("(^|\\.)"+a.namespace.split(".").join("\\.(?:.*\\.)?")+"(\\.|$)")),a.liveFired=this;var s=r.live.slice(0);for(i=0;i<s.length;i++)g=s[i],g.origType.replace(w,"")===a.type?q.push(g.selector):s.splice(i--,1);e=f(a.target).closest(q,a.currentTarget);for(j=0,k=e.length;j<k;j++){m=e[j];for(i=0;i<s.length;i++){g=s[i];if(m.selector===g.selector&&(!n||n.test(g.namespace))&&!m.elem.disabled){h=m.elem,d=null;if(g.preType==="mouseenter"||g.preType==="mouseleave")a.type=g.preType,d=f(a.relatedTarget).closest(g.selector)[0],d&&f.contains(h,d)&&(d=h);(!d||d!==h)&&p.push({elem:h,handleObj:g,level:m.level})}}}for(j=0,k=p.length;j<k;j++){e=p[j];if(c&&e.level>c)break;a.currentTarget=e.elem,a.data=e.handleObj.data,a.handleObj=e.handleObj,o=e.handleObj.origHandler.apply(e.elem,arguments);if(o===!1||a.isPropagationStopped()){c=e.level,o===!1&&(b=!1);if(a.isImmediatePropagationStopped())break}}return b}}function J(a,c,d){var e=f.extend({},d[0]);e.type=a,e.originalEvent={},e.liveFired=b,f.event.handle.call(c,e),e.isDefaultPrevented()&&d[0].preventDefault()}function D(){return!0}function C(){return!1}function m(a,c,d){var e=c+"defer",g=c+"queue",h=c+"mark",i=f.data(a,e,b,!0);i&&(d==="queue"||!f.data(a,g,b,!0))&&(d==="mark"||!f.data(a,h,b,!0))&&setTimeout(function(){!f.data(a,g,b,!0)&&!f.data(a,h,b,!0)&&(f.removeData(a,e,!0),i.resolve())},0)}function l(a){for(var b in a)if(b!=="toJSON")return!1;return!0}function k(a,c,d){if(d===b&&a.nodeType===1){var e="data-"+c.replace(j,"-$1").toLowerCase();d=a.getAttribute(e);if(typeof d=="string"){try{d=d==="true"?!0:d==="false"?!1:d==="null"?null:f.isNaN(d)?i.test(d)?f.parseJSON(d):d:parseFloat(d)}catch(g){}f.data(a,c,d)}else d=b}return d}var c=a.document,d=a.navigator,e=a.location,f=function(){function K(){if(!e.isReady){try{c.documentElement.doScroll("left")}catch(a){setTimeout(K,1);return}e.ready()}}var e=function(a,b){return new e.fn.init(a,b,h)},f=a.jQuery,g=a.$,h,i=/^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,j=/\S/,k=/^\s+/,l=/\s+$/,m=/\d/,n=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,o=/^[\],:{}\s]*$/,p=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,q=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,r=/(?:^|:|,)(?:\s*\[)+/g,s=/(webkit)[ \/]([\w.]+)/,t=/(opera)(?:.*version)?[ \/]([\w.]+)/,u=/(msie) ([\w.]+)/,v=/(mozilla)(?:.*? rv:([\w.]+))?/,w=/-([a-z]|[0-9])/ig,x=/^-ms-/,y=function(a,b){return(b+"").toUpperCase()},z=d.userAgent,A,B,C,D=Object.prototype.toString,E=Object.prototype.hasOwnProperty,F=Array.prototype.push,G=Array.prototype.slice,H=String.prototype.trim,I=Array.prototype.indexOf,J={};e.fn=e.prototype={constructor:e,init:function(a,d,f){var g,h,j,k;if(!a)return this;if(a.nodeType){this.context=this[0]=a,this.length=1;return this}if(a==="body"&&!d&&c.body){this.context=c,this[0]=c.body,this.selector=a,this.length=1;return this}if(typeof a=="string"){a.charAt(0)!=="<"||a.charAt(a.length-1)!==">"||a.length<3?g=i.exec(a):g=[null,a,null];if(g&&(g[1]||!d)){if(g[1]){d=d instanceof e?d[0]:d,k=d?d.ownerDocument||d:c,j=n.exec(a),j?e.isPlainObject(d)?(a=[c.createElement(j[1])],e.fn.attr.call(a,d,!0)):a=[k.createElement(j[1])]:(j=e.buildFragment([g[1]],[k]),a=(j.cacheable?e.clone(j.fragment):j.fragment).childNodes);return e.merge(this,a)}h=c.getElementById(g[2]);if(h&&h.parentNode){if(h.id!==g[2])return f.find(a);this.length=1,this[0]=h}this.context=c,this.selector=a;return this}return!d||d.jquery?(d||f).find(a):this.constructor(d).find(a)}if(e.isFunction(a))return f.ready(a);a.selector!==b&&(this.selector=a.selector,this.context=a.context);return e.makeArray(a,this)},selector:"",jquery:"1.6.4",length:0,size:function(){return this.length},toArray:function(){return G.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this[this.length+a]:this[a]},pushStack:function(a,b,c){var d=this.constructor();e.isArray(a)?F.apply(d,a):e.merge(d,a),d.prevObject=this,d.context=this.context,b==="find"?d.selector=this.selector+(this.selector?" ":"")+c:b&&(d.selector=this.selector+"."+b+"("+c+")");return d},each:function(a,b){return e.each(this,a,b)},ready:function(a){e.bindReady(),B.done(a);return this},eq:function(a){return a===-1?this.slice(a):this.slice(a,+a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(G.apply(this,arguments),"slice",G.call(arguments).join(","))},map:function(a){return this.pushStack(e.map(this,function(b,c){return a.call(b,c,b)}))},end:function(){return this.prevObject||this.constructor(null)},push:F,sort:[].sort,splice:[].splice},e.fn.init.prototype=e.fn,e.extend=e.fn.extend=function(){var a,c,d,f,g,h,i=arguments[0]||{},j=1,k=arguments.length,l=!1;typeof i=="boolean"&&(l=i,i=arguments[1]||{},j=2),typeof i!="object"&&!e.isFunction(i)&&(i={}),k===j&&(i=this,--j);for(;j<k;j++)if((a=arguments[j])!=null)for(c in a){d=i[c],f=a[c];if(i===f)continue;l&&f&&(e.isPlainObject(f)||(g=e.isArray(f)))?(g?(g=!1,h=d&&e.isArray(d)?d:[]):h=d&&e.isPlainObject(d)?d:{},i[c]=e.extend(l,h,f)):f!==b&&(i[c]=f)}return i},e.extend({noConflict:function(b){a.$===e&&(a.$=g),b&&a.jQuery===e&&(a.jQuery=f);return e},isReady:!1,readyWait:1,holdReady:function(a){a?e.readyWait++:e.ready(!0)},ready:function(a){if(a===!0&&!--e.readyWait||a!==!0&&!e.isReady){if(!c.body)return setTimeout(e.ready,1);e.isReady=!0;if(a!==!0&&--e.readyWait>0)return;B.resolveWith(c,[e]),e.fn.trigger&&e(c).trigger("ready").unbind("ready")}},bindReady:function(){if(!B){B=e._Deferred();if(c.readyState==="complete")return setTimeout(e.ready,1);if(c.addEventListener)c.addEventListener("DOMContentLoaded",C,!1),a.addEventListener("load",e.ready,!1);else if(c.attachEvent){c.attachEvent("onreadystatechange",C),a.attachEvent("onload",e.ready);var b=!1;try{b=a.frameElement==null}catch(d){}c.documentElement.doScroll&&b&&K()}}},isFunction:function(a){return e.type(a)==="function"},isArray:Array.isArray||function(a){return e.type(a)==="array"},isWindow:function(a){return a&&typeof a=="object"&&"setInterval"in a},isNaN:function(a){return a==null||!m.test(a)||isNaN(a)},type:function(a){return a==null?String(a):J[D.call(a)]||"object"},isPlainObject:function(a){if(!a||e.type(a)!=="object"||a.nodeType||e.isWindow(a))return!1;try{if(a.constructor&&!E.call(a,"constructor")&&!E.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}var d;for(d in a);return d===b||E.call(a,d)},isEmptyObject:function(a){for(var b in a)return!1;return!0},error:function(a){throw a},parseJSON:function(b){if(typeof b!="string"||!b)return null;b=e.trim(b);if(a.JSON&&a.JSON.parse)return a.JSON.parse(b);if(o.test(b.replace(p,"@").replace(q,"]").replace(r,"")))return(new Function("return "+b))();e.error("Invalid JSON: "+b)},parseXML:function(c){var d,f;try{a.DOMParser?(f=new DOMParser,d=f.parseFromString(c,"text/xml")):(d=new ActiveXObject("Microsoft.XMLDOM"),d.async="false",d.loadXML(c))}catch(g){d=b}(!d||!d.documentElement||d.getElementsByTagName("parsererror").length)&&e.error("Invalid XML: "+c);return d},noop:function(){},globalEval:function(b){b&&j.test(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(x,"ms-").replace(w,y)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,c,d){var f,g=0,h=a.length,i=h===b||e.isFunction(a);if(d){if(i){for(f in a)if(c.apply(a[f],d)===!1)break}else for(;g<h;)if(c.apply(a[g++],d)===!1)break}else if(i){for(f in a)if(c.call(a[f],f,a[f])===!1)break}else for(;g<h;)if(c.call(a[g],g,a[g++])===!1)break;return a},trim:H?function(a){return a==null?"":H.call(a)}:function(a){return a==null?"":(a+"").replace(k,"").replace(l,"")},makeArray:function(a,b){var c=b||[];if(a!=null){var d=e.type(a);a.length==null||d==="string"||d==="function"||d==="regexp"||e.isWindow(a)?F.call(c,a):e.merge(c,a)}return c},inArray:function(a,b){if(!b)return-1;if(I)return I.call(b,a);for(var c=0,d=b.length;c<d;c++)if(b[c]===a)return c;return-1},merge:function(a,c){var d=a.length,e=0;if(typeof c.length=="number")for(var f=c.length;e<f;e++)a[d++]=c[e];else while(c[e]!==b)a[d++]=c[e++];a.length=d;return a},grep:function(a,b,c){var d=[],e;c=!!c;for(var f=0,g=a.length;f<g;f++)e=!!b(a[f],f),c!==e&&d.push(a[f]);return d},map:function(a,c,d){var f,g,h=[],i=0,j=a.length,k=a instanceof e||j!==b&&typeof j=="number"&&(j>0&&a[0]&&a[j-1]||j===0||e.isArray(a));if(k)for(;i<j;i++)f=c(a[i],i,d),f!=null&&(h[h.length]=f);else for(g in a)f=c(a[g],g,d),f!=null&&(h[h.length]=f);return h.concat.apply([],h)},guid:1,proxy:function(a,c){if(typeof c=="string"){var d=a[c];c=a,a=d}if(!e.isFunction(a))return b;var f=G.call(arguments,2),g=function(){return a.apply(c,f.concat(G.call(arguments)))};g.guid=a.guid=a.guid||g.guid||e.guid++;return g},access:function(a,c,d,f,g,h){var i=a.length;if(typeof c=="object"){for(var j in c)e.access(a,j,c[j],f,g,d);return a}if(d!==b){f=!h&&f&&e.isFunction(d);for(var k=0;k<i;k++)g(a[k],c,f?d.call(a[k],k,g(a[k],c)):d,h);return a}return i?g(a[0],c):b},now:function(){return(new Date).getTime()},uaMatch:function(a){a=a.toLowerCase();var b=s.exec(a)||t.exec(a)||u.exec(a)||a.indexOf("compatible")<0&&v.exec(a)||[];return{browser:b[1]||"",version:b[2]||"0"}},sub:function(){function a(b,c){return new a.fn.init(b,c)}e.extend(!0,a,this),a.superclass=this,a.fn=a.prototype=this(),a.fn.constructor=a,a.sub=this.sub,a.fn.init=function(d,f){f&&f instanceof e&&!(f instanceof a)&&(f=a(f));return e.fn.init.call(this,d,f,b)},a.fn.init.prototype=a.fn;var b=a(c);return a},browser:{}}),e.each("Boolean Number String Function Array Date RegExp Object".split(" "),function(a,b){J["[object "+b+"]"]=b.toLowerCase()}),A=e.uaMatch(z),A.browser&&(e.browser[A.browser]=!0,e.browser.version=A.version),e.browser.webkit&&(e.browser.safari=!0),j.test(" ")&&(k=/^[\s\xA0]+/,l=/[\s\xA0]+$/),h=e(c),c.addEventListener?C=function(){c.removeEventListener("DOMContentLoaded",C,!1),e.ready()}:c.attachEvent&&(C=function(){c.readyState==="complete"&&(c.detachEvent("onreadystatechange",C),e.ready())});return e}(),g="done fail isResolved isRejected promise then always pipe".split(" "),h=[].slice;f.extend({_Deferred:function(){var a=[],b,c,d,e={done:function(){if(!d){var c=arguments,g,h,i,j,k;b&&(k=b,b=0);for(g=0,h=c.length;g<h;g++)i=c[g],j=f.type(i),j==="array"?e.done.apply(e,i):j==="function"&&a.push(i);k&&e.resolveWith(k[0],k[1])}return this},resolveWith:function(e,f){if(!d&&!b&&!c){f=f||[],c=1;try{while(a[0])a.shift().apply(e,f)}finally{b=[e,f],c=0}}return this},resolve:function(){e.resolveWith(this,arguments);return this},isResolved:function(){return!!c||!!b},cancel:function(){d=1,a=[];return this}};return e},Deferred:function(a){var b=f._Deferred(),c=f._Deferred(),d;f.extend(b,{then:function(a,c){b.done(a).fail(c);return this},always:function(){return b.done.apply(b,arguments).fail.apply(this,arguments)},fail:c.done,rejectWith:c.resolveWith,reject:c.resolve,isRejected:c.isResolved,pipe:function(a,c){return f.Deferred(function(d){f.each({done:[a,"resolve"],fail:[c,"reject"]},function(a,c){var e=c[0],g=c[1],h;f.isFunction(e)?b[a](function(){h=e.apply(this,arguments),h&&f.isFunction(h.promise)?h.promise().then(d.resolve,d.reject):d[g+"With"](this===b?d:this,[h])}):b[a](d[g])})}).promise()},promise:function(a){if(a==null){if(d)return d;d=a={}}var c=g.length;while(c--)a[g[c]]=b[g[c]];return a}}),b.done(c.cancel).fail(b.cancel),delete b.cancel,a&&a.call(b,b);return b},when:function(a){function i(a){return function(c){b[a]=arguments.length>1?h.call(arguments,0):c,--e||g.resolveWith(g,h.call(b,0))}}var b=arguments,c=0,d=b.length,e=d,g=d<=1&&a&&f.isFunction(a.promise)?a:f.Deferred();if(d>1){for(;c<d;c++)b[c]&&f.isFunction(b[c].promise)?b[c].promise().then(i(c),g.reject):--e;e||g.resolveWith(g,b)}else g!==a&&g.resolveWith(g,d?[a]:[]);return g.promise()}}),f.support=function(){var a=c.createElement("div"),b=c.documentElement,d,e,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u;a.setAttribute("className","t"),a.innerHTML=" <link/><table></table><a href='/a' style='top:1px;float:left;opacity:.55;'>a</a><input type='checkbox'/>",d=a.getElementsByTagName("*"),e=a.getElementsByTagName("a")[0];if(!d||!d.length||!e)return{};g=c.createElement("select"),h=g.appendChild(c.createElement("option")),i=a.getElementsByTagName("input")[0],k={leadingWhitespace:a.firstChild.nodeType===3,tbody:!a.getElementsByTagName("tbody").length,htmlSerialize:!!a.getElementsByTagName("link").length,style:/top/.test(e.getAttribute("style")),hrefNormalized:e.getAttribute("href")==="/a",opacity:/^0.55$/.test(e.style.opacity),cssFloat:!!e.style.cssFloat,checkOn:i.value==="on",optSelected:h.selected,getSetAttribute:a.className!=="t",submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0},i.checked=!0,k.noCloneChecked=i.cloneNode(!0).checked,g.disabled=!0,k.optDisabled=!h.disabled;try{delete a.test}catch(v){k.deleteExpando=!1}!a.addEventListener&&a.attachEvent&&a.fireEvent&&(a.attachEvent("onclick",function(){k.noCloneEvent=!1}),a.cloneNode(!0).fireEvent("onclick")),i=c.createElement("input"),i.value="t",i.setAttribute("type","radio"),k.radioValue=i.value==="t",i.setAttribute("checked","checked"),a.appendChild(i),l=c.createDocumentFragment(),l.appendChild(a.firstChild),k.checkClone=l.cloneNode(!0).cloneNode(!0).lastChild.checked,a.innerHTML="",a.style.width=a.style.paddingLeft="1px",m=c.getElementsByTagName("body")[0],o=c.createElement(m?"div":"body"),p={visibility:"hidden",width:0,height:0,border:0,margin:0,background:"none"},m&&f.extend(p,{position:"absolute",left:"-1000px",top:"-1000px"});for(t in p)o.style[t]=p[t];o.appendChild(a),n=m||b,n.insertBefore(o,n.firstChild),k.appendChecked=i.checked,k.boxModel=a.offsetWidth===2,"zoom"in a.style&&(a.style.display="inline",a.style.zoom=1,k.inlineBlockNeedsLayout=a.offsetWidth===2,a.style.display="",a.innerHTML="<div style='width:4px;'></div>",k.shrinkWrapBlocks=a.offsetWidth!==2),a.innerHTML="<table><tr><td style='padding:0;border:0;display:none'></td><td>t</td></tr></table>",q=a.getElementsByTagName("td"),u=q[0].offsetHeight===0,q[0].style.display="",q[1].style.display="none",k.reliableHiddenOffsets=u&&q[0].offsetHeight===0,a.innerHTML="",c.defaultView&&c.defaultView.getComputedStyle&&(j=c.createElement("div"),j.style.width="0",j.style.marginRight="0",a.appendChild(j),k.reliableMarginRight=(parseInt((c.defaultView.getComputedStyle(j,null)||{marginRight:0}).marginRight,10)||0)===0),o.innerHTML="",n.removeChild(o);if(a.attachEvent)for(t in{submit:1,change:1,focusin:1})s="on"+t,u=s in a,u||(a.setAttribute(s,"return;"),u=typeof a[s]=="function"),k[t+"Bubbles"]=u;o=l=g=h=m=j=a=i=null;return k}(),f.boxModel=f.support.boxModel;var i=/^(?:\{.*\}|\[.*\])$/,j=/([A-Z])/g;f.extend({cache:{},uuid:0,expando:"jQuery"+(f.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(a){a=a.nodeType?f.cache[a[f.expando]]:a[f.expando];return!!a&&!l(a)},data:function(a,c,d,e){if(!!f.acceptData(a)){var g,h,i=f.expando,j=typeof c=="string",k=a.nodeType,l=k?f.cache:a,m=k?a[f.expando]:a[f.expando]&&f.expando;if((!m||e&&m&&l[m]&&!l[m][i])&&j&&d===b)return;m||(k?a[f.expando]=m=++f.uuid:m=f.expando),l[m]||(l[m]={},k||(l[m].toJSON=f.noop));if(typeof c=="object"||typeof c=="function")e?l[m][i]=f.extend(l[m][i],c):l[m]=f.extend(l[m],c);g=l[m],e&&(g[i]||(g[i]={}),g=g[i]),d!==b&&(g[f.camelCase(c)]=d);if(c==="events"&&!g[c])return g[i]&&g[i].events;j?(h=g[c],h==null&&(h=g[f.camelCase(c)])):h=g;return h}},removeData:function(a,b,c){if(!!f.acceptData(a)){var d,e=f.expando,g=a.nodeType,h=g?f.cache:a,i=g?a[f.expando]:f.expando;if(!h[i])return;if(b){d=c?h[i][e]:h[i];if(d){d[b]||(b=f.camelCase(b)),delete d[b];if(!l(d))return}}if(c){delete h[i][e];if(!l(h[i]))return}var j=h[i][e];f.support.deleteExpando||!h.setInterval?delete h[i]:h[i]=null,j?(h[i]={},g||(h[i].toJSON=f.noop),h[i][e]=j):g&&(f.support.deleteExpando?delete a[f.expando]:a.removeAttribute?a.removeAttribute(f.expando):a[f.expando]=null)}},_data:function(a,b,c){return f.data(a,b,c,!0)},acceptData:function(a){if(a.nodeName){var b=f.noData[a.nodeName.toLowerCase()];if(b)return b!==!0&&a.getAttribute("classid")===b}return!0}}),f.fn.extend({data:function(a,c){var d=null;if(typeof a=="undefined"){if(this.length){d=f.data(this[0]);if(this[0].nodeType===1){var e=this[0].attributes,g;for(var h=0,i=e.length;h<i;h++)g=e[h].name,g.indexOf("data-")===0&&(g=f.camelCase(g.substring(5)),k(this[0],g,d[g]))}}return d}if(typeof a=="object")return this.each(function(){f.data(this,a)});var j=a.split(".");j[1]=j[1]?"."+j[1]:"";if(c===b){d=this.triggerHandler("getData"+j[1]+"!",[j[0]]),d===b&&this.length&&(d=f.data(this[0],a),d=k(this[0],a,d));return d===b&&j[1]?this.data(j[0]):d}return this.each(function(){var b=f(this),d=[j[0],c];b.triggerHandler("setData"+j[1]+"!",d),f.data(this,a,c),b.triggerHandler("changeData"+j[1]+"!",d)})},removeData:function(a){return this.each(function(){f.removeData(this,a)})}}),f.extend({_mark:function(a,c){a&&(c=(c||"fx")+"mark",f.data(a,c,(f.data(a,c,b,!0)||0)+1,!0))},_unmark:function(a,c,d){a!==!0&&(d=c,c=a,a=!1);if(c){d=d||"fx";var e=d+"mark",g=a?0:(f.data(c,e,b,!0)||1)-1;g?f.data(c,e,g,!0):(f.removeData(c,e,!0),m(c,d,"mark"))}},queue:function(a,c,d){if(a){c=(c||"fx")+"queue";var e=f.data(a,c,b,!0);d&&(!e||f.isArray(d)?e=f.data(a,c,f.makeArray(d),!0):e.push(d));return e||[]}},dequeue:function(a,b){b=b||"fx";var c=f.queue(a,b),d=c.shift(),e;d==="inprogress"&&(d=c.shift()),d&&(b==="fx"&&c.unshift("inprogress"),d.call(a,function(){f.dequeue(a,b)})),c.length||(f.removeData(a,b+"queue",!0),m(a,b,"queue"))}}),f.fn.extend({queue:function(a,c){typeof a!="string"&&(c=a,a="fx");if(c===b)return f.queue(this[0],a);return this.each(function(){var b=f.queue(this,a,c);a==="fx"&&b[0]!=="inprogress"&&f.dequeue(this,a)})},dequeue:function(a){return this.each(function(){f.dequeue(this,a)})},delay:function(a,b){a=f.fx?f.fx.speeds[a]||a:a,b=b||"fx";return this.queue(b,function(){var c=this;setTimeout(function(){f.dequeue(c,b)},a)})},clearQueue:function(a){return this.queue(a||"fx",[])},promise:function(a,c){function m(){--h||d.resolveWith(e,[e])}typeof a!="string"&&(c=a,a=b),a=a||"fx";var d=f.Deferred(),e=this,g=e.length,h=1,i=a+"defer",j=a+"queue",k=a+"mark",l;while(g--)if(l=f.data(e[g],i,b,!0)||(f.data(e[g],j,b,!0)||f.data(e[g],k,b,!0))&&f.data(e[g],i,f._Deferred(),!0))h++,l.done(m);m();return d.promise()}});var n=/[\n\t\r]/g,o=/\s+/,p=/\r/g,q=/^(?:button|input)$/i,r=/^(?:button|input|object|select|textarea)$/i,s=/^a(?:rea)?$/i,t=/^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,u,v;f.fn.extend({attr:function(a,b){return f.access(this,a,b,!0,f.attr)},removeAttr:function(a){return this.each(function(){f.removeAttr(this,a)})},prop:function(a,b){return f.access(this,a,b,!0,f.prop)},removeProp:function(a){a=f.propFix[a]||a;return this.each(function(){try{this[a]=b,delete this[a]}catch(c){}})},addClass:function(a){var b,c,d,e,g,h,i;if(f.isFunction(a))return this.each(function(b){f(this).addClass(a.call(this,b,this.className))});if(a&&typeof a=="string"){b=a.split(o);for(c=0,d=this.length;c<d;c++){e=this[c];if(e.nodeType===1)if(!e.className&&b.length===1)e.className=a;else{g=" "+e.className+" ";for(h=0,i=b.length;h<i;h++)~g.indexOf(" "+b[h]+" ")||(g+=b[h]+" ");e.className=f.trim(g)}}}return this},removeClass:function(a){var c,d,e,g,h,i,j;if(f.isFunction(a))return this.each(function(b){f(this).removeClass(a.call(this,b,this.className))});if(a&&typeof a=="string"||a===b){c=(a||"").split(o);for(d=0,e=this.length;d<e;d++){g=this[d];if(g.nodeType===1&&g.className)if(a){h=(" "+g.className+" ").replace(n," ");for(i=0,j=c.length;i<j;i++)h=h.replace(" "+c[i]+" "," ");g.className=f.trim(h)}else g.className=""}}return this},toggleClass:function(a,b){var c=typeof a,d=typeof b=="boolean";if(f.isFunction(a))return this.each(function(c){f(this).toggleClass(a.call(this,c,this.className,b),b)});return this.each(function(){if(c==="string"){var e,g=0,h=f(this),i=b,j=a.split(o);while(e=j[g++])i=d?i:!h.hasClass(e),h[i?"addClass":"removeClass"](e)}else if(c==="undefined"||c==="boolean")this.className&&f._data(this,"__className__",this.className),this.className=this.className||a===!1?"":f._data(this,"__className__")||""})},hasClass:function(a){var b=" "+a+" ";for(var c=0,d=this.length;c<d;c++)if(this[c].nodeType===1&&(" "+this[c].className+" ").replace(n," ").indexOf(b)>-1)return!0;return!1},val:function(a){var c,d,e=this[0];if(!arguments.length){if(e){c=f.valHooks[e.nodeName.toLowerCase()]||f.valHooks[e.type];if(c&&"get"in c&&(d=c.get(e,"value"))!==b)return d;d=e.value;return typeof d=="string"?d.replace(p,""):d==null?"":d}return b}var g=f.isFunction(a);return this.each(function(d){var e=f(this),h;if(this.nodeType===1){g?h=a.call(this,d,e.val()):h=a,h==null?h="":typeof h=="number"?h+="":f.isArray(h)&&(h=f.map(h,function(a){return a==null?"":a+""})),c=f.valHooks[this.nodeName.toLowerCase()]||f.valHooks[this.type];if(!c||!("set"in c)||c.set(this,h,"value")===b)this.value=h}})}}),f.extend({valHooks:{option:{get:function(a){var b=a.attributes.value;return!b||b.specified?a.value:a.text}},select:{get:function(a){var b,c=a.selectedIndex,d=[],e=a.options,g=a.type==="select-one";if(c<0)return null;for(var h=g?c:0,i=g?c+1:e.length;h<i;h++){var j=e[h];if(j.selected&&(f.support.optDisabled?!j.disabled:j.getAttribute("disabled")===null)&&(!j.parentNode.disabled||!f.nodeName(j.parentNode,"optgroup"))){b=f(j).val();if(g)return b;d.push(b)}}if(g&&!d.length&&e.length)return f(e[c]).val();return d},set:function(a,b){var c=f.makeArray(b);f(a).find("option").each(function(){this.selected=f.inArray(f(this).val(),c)>=0}),c.length||(a.selectedIndex=-1);return c}}},attrFn:{val:!0,css:!0,html:!0,text:!0,data:!0,width:!0,height:!0,offset:!0},attrFix:{tabindex:"tabIndex"},attr:function(a,c,d,e){var g=a.nodeType;if(!a||g===3||g===8||g===2)return b;if(e&&c in f.attrFn)return f(a)[c](d);if(!("getAttribute"in a))return f.prop(a,c,d);var h,i,j=g!==1||!f.isXMLDoc(a);j&&(c=f.attrFix[c]||c,i=f.attrHooks[c],i||(t.test(c)?i=v:u&&(i=u)));if(d!==b){if(d===null){f.removeAttr(a,c);return b}if(i&&"set"in i&&j&&(h=i.set(a,d,c))!==b)return h;a.setAttribute(c,""+d);return d}if(i&&"get"in i&&j&&(h=i.get(a,c))!==null)return h;h=a.getAttribute(c);return h===null?b:h},removeAttr:function(a,b){var c;a.nodeType===1&&(b=f.attrFix[b]||b,f.attr(a,b,""),a.removeAttribute(b),t.test(b)&&(c=f.propFix[b]||b)in a&&(a[c]=!1))},attrHooks:{type:{set:function(a,b){if(q.test(a.nodeName)&&a.parentNode)f.error("type property can't be changed");else if(!f.support.radioValue&&b==="radio"&&f.nodeName(a,"input")){var c=a.value;a.setAttribute("type",b),c&&(a.value=c);return b}}},value:{get:function(a,b){if(u&&f.nodeName(a,"button"))return u.get(a,b);return b in a?a.value:null},set:function(a,b,c){if(u&&f.nodeName(a,"button"))return u.set(a,b,c);a.value=b}}},propFix:{tabindex:"tabIndex",readonly:"readOnly","for":"htmlFor","class":"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},prop:function(a,c,d){var e=a.nodeType;if(!a||e===3||e===8||e===2)return b;var g,h,i=e!==1||!f.isXMLDoc(a);i&&(c=f.propFix[c]||c,h=f.propHooks[c]);return d!==b?h&&"set"in h&&(g=h.set(a,d,c))!==b?g:a[c]=d:h&&"get"in h&&(g=h.get(a,c))!==null?g:a[c]},propHooks:{tabIndex:{get:function(a){var c=a.getAttributeNode("tabindex");return c&&c.specified?parseInt(c.value,10):r.test(a.nodeName)||s.test(a.nodeName)&&a.href?0:b}}}}),f.attrHooks.tabIndex=f.propHooks.tabIndex,v={get:function(a,c){var d;return f.prop(a,c)===!0||(d=a.getAttributeNode(c))&&d.nodeValue!==!1?c.toLowerCase():b},set:function(a,b,c){var d;b===!1?f.removeAttr(a,c):(d=f.propFix[c]||c,d in a&&(a[d]=!0),a.setAttribute(c,c.toLowerCase()));return c}},f.support.getSetAttribute||(u=f.valHooks.button={get:function(a,c){var d;d=a.getAttributeNode(c);return d&&d.nodeValue!==""?d.nodeValue:b},set:function(a,b,d){var e=a.getAttributeNode(d);e||(e=c.createAttribute(d),a.setAttributeNode(e));return e.nodeValue=b+""}},f.each(["width","height"],function(a,b){f.attrHooks[b]=f.extend(f.attrHooks[b],{set:function(a,c){if(c===""){a.setAttribute(b,"auto");return c}}})})),f.support.hrefNormalized||f.each(["href","src","width","height"],function(a,c){f.attrHooks[c]=f.extend(f.attrHooks[c],{get:function(a){var d=a.getAttribute(c,2);return d===null?b:d}})}),f.support.style||(f.attrHooks.style={get:function(a){return a.style.cssText.toLowerCase()||b},set:function(a,b){return a.style.cssText=""+b}}),f.support.optSelected||(f.propHooks.selected=f.extend(f.propHooks.selected,{get:function(a){var b=a.parentNode;b&&(b.selectedIndex,b.parentNode&&b.parentNode.selectedIndex);return null}})),f.support.checkOn||f.each(["radio","checkbox"],function(){f.valHooks[this]={get:function(a){return a.getAttribute("value")===null?"on":a.value}}}),f.each(["radio","checkbox"],function(){f.valHooks[this]=f.extend(f.valHooks[this],{set:function(a,b){if(f.isArray(b))return a.checked=f.inArray(f(a).val(),b)>=0}})});var w=/\.(.*)$/,x=/^(?:textarea|input|select)$/i,y=/\./g,z=/ /g,A=/[^\w\s.|`]/g,B=function(a){return a.replace(A,"\\$&")};f.event={add:function(a,c,d,e){if(a.nodeType!==3&&a.nodeType!==8){if(d===!1)d=C;else if(!d)return;var g,h;d.handler&&(g=d,d=g.handler),d.guid||(d.guid=f.guid++);var i=f._data(a);if(!i)return;var j=i.events,k=i.handle;j||(i.events=j={}),k||(i.handle=k=function(a){return typeof f!="undefined"&&(!a||f.event.triggered!==a.type)?f.event.handle.apply(k.elem,arguments):b}),k.elem=a,c=c.split(" ");var l,m=0,n;while(l=c[m++]){h=g?f.extend({},g):{handler:d,data:e},l.indexOf(".")>-1?(n=l.split("."),l=n.shift(),h.namespace=n.slice(0).sort().join(".")):(n=[],h.namespace=""),h.type=l,h.guid||(h.guid=d.guid);var o=j[l],p=f.event.special[l]||{};if(!o){o=j[l]=[];if(!p.setup||p.setup.call(a,e,n,k)===!1)a.addEventListener?a.addEventListener(l,k,!1):a.attachEvent&&a.attachEvent("on"+l,k)}p.add&&(p.add.call(a,h),h.handler.guid||(h.handler.guid=d.guid)),o.push(h),f.event.global[l]=!0}a=null}},global:{},remove:function(a,c,d,e){if(a.nodeType!==3&&a.nodeType!==8){d===!1&&(d=C);var g,h,i,j,k=0,l,m,n,o,p,q,r,s=f.hasData(a)&&f._data(a),t=s&&s.events;if(!s||!t)return;c&&c.type&&(d=c.handler,c=c.type);if(!c||typeof c=="string"&&c.charAt(0)==="."){c=c||"";for(h in t)f.event.remove(a,h+c);return}c=c.split(" ");while(h=c[k++]){r=h,q=null,l=h.indexOf(".")<0,m=[],l||(m=h.split("."),h=m.shift(),n=new RegExp("(^|\\.)"+f.map(m.slice(0).sort(),B).join("\\.(?:.*\\.)?")+"(\\.|$)")),p=t[h];if(!p)continue;if(!d){for(j=0;j<p.length;j++){q=p[j];if(l||n.test(q.namespace))f.event.remove(a,r,q.handler,j),p.splice(j--,1)}continue}o=f.event.special[h]||{};for(j=e||0;j<p.length;j++){q=p[j];if(d.guid===q.guid){if(l||n.test(q.namespace))e==null&&p.splice(j--,1),o.remove&&o.remove.call(a,q);if(e!=null)break}}if(p.length===0||e!=null&&p.length===1)(!o.teardown||o.teardown.call(a,m)===!1)&&f.removeEvent(a,h,s.handle),g=null,delete
|
3
|
+
t[h]}if(f.isEmptyObject(t)){var u=s.handle;u&&(u.elem=null),delete s.events,delete s.handle,f.isEmptyObject(s)&&f.removeData(a,b,!0)}}},customEvent:{getData:!0,setData:!0,changeData:!0},trigger:function(c,d,e,g){var h=c.type||c,i=[],j;h.indexOf("!")>=0&&(h=h.slice(0,-1),j=!0),h.indexOf(".")>=0&&(i=h.split("."),h=i.shift(),i.sort());if(!!e&&!f.event.customEvent[h]||!!f.event.global[h]){c=typeof c=="object"?c[f.expando]?c:new f.Event(h,c):new f.Event(h),c.type=h,c.exclusive=j,c.namespace=i.join("."),c.namespace_re=new RegExp("(^|\\.)"+i.join("\\.(?:.*\\.)?")+"(\\.|$)");if(g||!e)c.preventDefault(),c.stopPropagation();if(!e){f.each(f.cache,function(){var a=f.expando,b=this[a];b&&b.events&&b.events[h]&&f.event.trigger(c,d,b.handle.elem)});return}if(e.nodeType===3||e.nodeType===8)return;c.result=b,c.target=e,d=d!=null?f.makeArray(d):[],d.unshift(c);var k=e,l=h.indexOf(":")<0?"on"+h:"";do{var m=f._data(k,"handle");c.currentTarget=k,m&&m.apply(k,d),l&&f.acceptData(k)&&k[l]&&k[l].apply(k,d)===!1&&(c.result=!1,c.preventDefault()),k=k.parentNode||k.ownerDocument||k===c.target.ownerDocument&&a}while(k&&!c.isPropagationStopped());if(!c.isDefaultPrevented()){var n,o=f.event.special[h]||{};if((!o._default||o._default.call(e.ownerDocument,c)===!1)&&(h!=="click"||!f.nodeName(e,"a"))&&f.acceptData(e)){try{l&&e[h]&&(n=e[l],n&&(e[l]=null),f.event.triggered=h,e[h]())}catch(p){}n&&(e[l]=n),f.event.triggered=b}}return c.result}},handle:function(c){c=f.event.fix(c||a.event);var d=((f._data(this,"events")||{})[c.type]||[]).slice(0),e=!c.exclusive&&!c.namespace,g=Array.prototype.slice.call(arguments,0);g[0]=c,c.currentTarget=this;for(var h=0,i=d.length;h<i;h++){var j=d[h];if(e||c.namespace_re.test(j.namespace)){c.handler=j.handler,c.data=j.data,c.handleObj=j;var k=j.handler.apply(this,g);k!==b&&(c.result=k,k===!1&&(c.preventDefault(),c.stopPropagation()));if(c.isImmediatePropagationStopped())break}}return c.result},props:"altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),fix:function(a){if(a[f.expando])return a;var d=a;a=f.Event(d);for(var e=this.props.length,g;e;)g=this.props[--e],a[g]=d[g];a.target||(a.target=a.srcElement||c),a.target.nodeType===3&&(a.target=a.target.parentNode),!a.relatedTarget&&a.fromElement&&(a.relatedTarget=a.fromElement===a.target?a.toElement:a.fromElement);if(a.pageX==null&&a.clientX!=null){var h=a.target.ownerDocument||c,i=h.documentElement,j=h.body;a.pageX=a.clientX+(i&&i.scrollLeft||j&&j.scrollLeft||0)-(i&&i.clientLeft||j&&j.clientLeft||0),a.pageY=a.clientY+(i&&i.scrollTop||j&&j.scrollTop||0)-(i&&i.clientTop||j&&j.clientTop||0)}a.which==null&&(a.charCode!=null||a.keyCode!=null)&&(a.which=a.charCode!=null?a.charCode:a.keyCode),!a.metaKey&&a.ctrlKey&&(a.metaKey=a.ctrlKey),!a.which&&a.button!==b&&(a.which=a.button&1?1:a.button&2?3:a.button&4?2:0);return a},guid:1e8,proxy:f.proxy,special:{ready:{setup:f.bindReady,teardown:f.noop},live:{add:function(a){f.event.add(this,M(a.origType,a.selector),f.extend({},a,{handler:L,guid:a.handler.guid}))},remove:function(a){f.event.remove(this,M(a.origType,a.selector),a)}},beforeunload:{setup:function(a,b,c){f.isWindow(this)&&(this.onbeforeunload=c)},teardown:function(a,b){this.onbeforeunload===b&&(this.onbeforeunload=null)}}}},f.removeEvent=c.removeEventListener?function(a,b,c){a.removeEventListener&&a.removeEventListener(b,c,!1)}:function(a,b,c){a.detachEvent&&a.detachEvent("on"+b,c)},f.Event=function(a,b){if(!this.preventDefault)return new f.Event(a,b);a&&a.type?(this.originalEvent=a,this.type=a.type,this.isDefaultPrevented=a.defaultPrevented||a.returnValue===!1||a.getPreventDefault&&a.getPreventDefault()?D:C):this.type=a,b&&f.extend(this,b),this.timeStamp=f.now(),this[f.expando]=!0},f.Event.prototype={preventDefault:function(){this.isDefaultPrevented=D;var a=this.originalEvent;!a||(a.preventDefault?a.preventDefault():a.returnValue=!1)},stopPropagation:function(){this.isPropagationStopped=D;var a=this.originalEvent;!a||(a.stopPropagation&&a.stopPropagation(),a.cancelBubble=!0)},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=D,this.stopPropagation()},isDefaultPrevented:C,isPropagationStopped:C,isImmediatePropagationStopped:C};var E=function(a){var b=a.relatedTarget,c=!1,d=a.type;a.type=a.data,b!==this&&(b&&(c=f.contains(this,b)),c||(f.event.handle.apply(this,arguments),a.type=d))},F=function(a){a.type=a.data,f.event.handle.apply(this,arguments)};f.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(a,b){f.event.special[a]={setup:function(c){f.event.add(this,b,c&&c.selector?F:E,a)},teardown:function(a){f.event.remove(this,b,a&&a.selector?F:E)}}}),f.support.submitBubbles||(f.event.special.submit={setup:function(a,b){if(!f.nodeName(this,"form"))f.event.add(this,"click.specialSubmit",function(a){var b=a.target,c=f.nodeName(b,"input")||f.nodeName(b,"button")?b.type:"";(c==="submit"||c==="image")&&f(b).closest("form").length&&J("submit",this,arguments)}),f.event.add(this,"keypress.specialSubmit",function(a){var b=a.target,c=f.nodeName(b,"input")||f.nodeName(b,"button")?b.type:"";(c==="text"||c==="password")&&f(b).closest("form").length&&a.keyCode===13&&J("submit",this,arguments)});else return!1},teardown:function(a){f.event.remove(this,".specialSubmit")}});if(!f.support.changeBubbles){var G,H=function(a){var b=f.nodeName(a,"input")?a.type:"",c=a.value;b==="radio"||b==="checkbox"?c=a.checked:b==="select-multiple"?c=a.selectedIndex>-1?f.map(a.options,function(a){return a.selected}).join("-"):"":f.nodeName(a,"select")&&(c=a.selectedIndex);return c},I=function(c){var d=c.target,e,g;if(!!x.test(d.nodeName)&&!d.readOnly){e=f._data(d,"_change_data"),g=H(d),(c.type!=="focusout"||d.type!=="radio")&&f._data(d,"_change_data",g);if(e===b||g===e)return;if(e!=null||g)c.type="change",c.liveFired=b,f.event.trigger(c,arguments[1],d)}};f.event.special.change={filters:{focusout:I,beforedeactivate:I,click:function(a){var b=a.target,c=f.nodeName(b,"input")?b.type:"";(c==="radio"||c==="checkbox"||f.nodeName(b,"select"))&&I.call(this,a)},keydown:function(a){var b=a.target,c=f.nodeName(b,"input")?b.type:"";(a.keyCode===13&&!f.nodeName(b,"textarea")||a.keyCode===32&&(c==="checkbox"||c==="radio")||c==="select-multiple")&&I.call(this,a)},beforeactivate:function(a){var b=a.target;f._data(b,"_change_data",H(b))}},setup:function(a,b){if(this.type==="file")return!1;for(var c in G)f.event.add(this,c+".specialChange",G[c]);return x.test(this.nodeName)},teardown:function(a){f.event.remove(this,".specialChange");return x.test(this.nodeName)}},G=f.event.special.change.filters,G.focus=G.beforeactivate}f.support.focusinBubbles||f.each({focus:"focusin",blur:"focusout"},function(a,b){function e(a){var c=f.event.fix(a);c.type=b,c.originalEvent={},f.event.trigger(c,null,c.target),c.isDefaultPrevented()&&a.preventDefault()}var d=0;f.event.special[b]={setup:function(){d++===0&&c.addEventListener(a,e,!0)},teardown:function(){--d===0&&c.removeEventListener(a,e,!0)}}}),f.each(["bind","one"],function(a,c){f.fn[c]=function(a,d,e){var g;if(typeof a=="object"){for(var h in a)this[c](h,d,a[h],e);return this}if(arguments.length===2||d===!1)e=d,d=b;c==="one"?(g=function(a){f(this).unbind(a,g);return e.apply(this,arguments)},g.guid=e.guid||f.guid++):g=e;if(a==="unload"&&c!=="one")this.one(a,d,e);else for(var i=0,j=this.length;i<j;i++)f.event.add(this[i],a,g,d);return this}}),f.fn.extend({unbind:function(a,b){if(typeof a=="object"&&!a.preventDefault)for(var c in a)this.unbind(c,a[c]);else for(var d=0,e=this.length;d<e;d++)f.event.remove(this[d],a,b);return this},delegate:function(a,b,c,d){return this.live(b,c,d,a)},undelegate:function(a,b,c){return arguments.length===0?this.unbind("live"):this.die(b,null,c,a)},trigger:function(a,b){return this.each(function(){f.event.trigger(a,b,this)})},triggerHandler:function(a,b){if(this[0])return f.event.trigger(a,b,this[0],!0)},toggle:function(a){var b=arguments,c=a.guid||f.guid++,d=0,e=function(c){var e=(f.data(this,"lastToggle"+a.guid)||0)%d;f.data(this,"lastToggle"+a.guid,e+1),c.preventDefault();return b[e].apply(this,arguments)||!1};e.guid=c;while(d<b.length)b[d++].guid=c;return this.click(e)},hover:function(a,b){return this.mouseenter(a).mouseleave(b||a)}});var K={focus:"focusin",blur:"focusout",mouseenter:"mouseover",mouseleave:"mouseout"};f.each(["live","die"],function(a,c){f.fn[c]=function(a,d,e,g){var h,i=0,j,k,l,m=g||this.selector,n=g?this:f(this.context);if(typeof a=="object"&&!a.preventDefault){for(var o in a)n[c](o,d,a[o],m);return this}if(c==="die"&&!a&&g&&g.charAt(0)==="."){n.unbind(g);return this}if(d===!1||f.isFunction(d))e=d||C,d=b;a=(a||"").split(" ");while((h=a[i++])!=null){j=w.exec(h),k="",j&&(k=j[0],h=h.replace(w,""));if(h==="hover"){a.push("mouseenter"+k,"mouseleave"+k);continue}l=h,K[h]?(a.push(K[h]+k),h=h+k):h=(K[h]||h)+k;if(c==="live")for(var p=0,q=n.length;p<q;p++)f.event.add(n[p],"live."+M(h,m),{data:d,selector:m,handler:e,origType:h,origHandler:e,preType:l});else n.unbind("live."+M(h,m),e)}return this}}),f.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error".split(" "),function(a,b){f.fn[b]=function(a,c){c==null&&(c=a,a=null);return arguments.length>0?this.bind(b,a,c):this.trigger(b)},f.attrFn&&(f.attrFn[b]=!0)}),function(){function u(a,b,c,d,e,f){for(var g=0,h=d.length;g<h;g++){var i=d[g];if(i){var j=!1;i=i[a];while(i){if(i.sizcache===c){j=d[i.sizset];break}if(i.nodeType===1){f||(i.sizcache=c,i.sizset=g);if(typeof b!="string"){if(i===b){j=!0;break}}else if(k.filter(b,[i]).length>0){j=i;break}}i=i[a]}d[g]=j}}}function t(a,b,c,d,e,f){for(var g=0,h=d.length;g<h;g++){var i=d[g];if(i){var j=!1;i=i[a];while(i){if(i.sizcache===c){j=d[i.sizset];break}i.nodeType===1&&!f&&(i.sizcache=c,i.sizset=g);if(i.nodeName.toLowerCase()===b){j=i;break}i=i[a]}d[g]=j}}}var a=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,d=0,e=Object.prototype.toString,g=!1,h=!0,i=/\\/g,j=/\W/;[0,0].sort(function(){h=!1;return 0});var k=function(b,d,f,g){f=f||[],d=d||c;var h=d;if(d.nodeType!==1&&d.nodeType!==9)return[];if(!b||typeof b!="string")return f;var i,j,n,o,q,r,s,t,u=!0,w=k.isXML(d),x=[],y=b;do{a.exec(""),i=a.exec(y);if(i){y=i[3],x.push(i[1]);if(i[2]){o=i[3];break}}}while(i);if(x.length>1&&m.exec(b))if(x.length===2&&l.relative[x[0]])j=v(x[0]+x[1],d);else{j=l.relative[x[0]]?[d]:k(x.shift(),d);while(x.length)b=x.shift(),l.relative[b]&&(b+=x.shift()),j=v(b,j)}else{!g&&x.length>1&&d.nodeType===9&&!w&&l.match.ID.test(x[0])&&!l.match.ID.test(x[x.length-1])&&(q=k.find(x.shift(),d,w),d=q.expr?k.filter(q.expr,q.set)[0]:q.set[0]);if(d){q=g?{expr:x.pop(),set:p(g)}:k.find(x.pop(),x.length===1&&(x[0]==="~"||x[0]==="+")&&d.parentNode?d.parentNode:d,w),j=q.expr?k.filter(q.expr,q.set):q.set,x.length>0?n=p(j):u=!1;while(x.length)r=x.pop(),s=r,l.relative[r]?s=x.pop():r="",s==null&&(s=d),l.relative[r](n,s,w)}else n=x=[]}n||(n=j),n||k.error(r||b);if(e.call(n)==="[object Array]")if(!u)f.push.apply(f,n);else if(d&&d.nodeType===1)for(t=0;n[t]!=null;t++)n[t]&&(n[t]===!0||n[t].nodeType===1&&k.contains(d,n[t]))&&f.push(j[t]);else for(t=0;n[t]!=null;t++)n[t]&&n[t].nodeType===1&&f.push(j[t]);else p(n,f);o&&(k(o,h,f,g),k.uniqueSort(f));return f};k.uniqueSort=function(a){if(r){g=h,a.sort(r);if(g)for(var b=1;b<a.length;b++)a[b]===a[b-1]&&a.splice(b--,1)}return a},k.matches=function(a,b){return k(a,null,null,b)},k.matchesSelector=function(a,b){return k(b,null,null,[a]).length>0},k.find=function(a,b,c){var d;if(!a)return[];for(var e=0,f=l.order.length;e<f;e++){var g,h=l.order[e];if(g=l.leftMatch[h].exec(a)){var j=g[1];g.splice(1,1);if(j.substr(j.length-1)!=="\\"){g[1]=(g[1]||"").replace(i,""),d=l.find[h](g,b,c);if(d!=null){a=a.replace(l.match[h],"");break}}}}d||(d=typeof b.getElementsByTagName!="undefined"?b.getElementsByTagName("*"):[]);return{set:d,expr:a}},k.filter=function(a,c,d,e){var f,g,h=a,i=[],j=c,m=c&&c[0]&&k.isXML(c[0]);while(a&&c.length){for(var n in l.filter)if((f=l.leftMatch[n].exec(a))!=null&&f[2]){var o,p,q=l.filter[n],r=f[1];g=!1,f.splice(1,1);if(r.substr(r.length-1)==="\\")continue;j===i&&(i=[]);if(l.preFilter[n]){f=l.preFilter[n](f,j,d,i,e,m);if(!f)g=o=!0;else if(f===!0)continue}if(f)for(var s=0;(p=j[s])!=null;s++)if(p){o=q(p,f,s,j);var t=e^!!o;d&&o!=null?t?g=!0:j[s]=!1:t&&(i.push(p),g=!0)}if(o!==b){d||(j=i),a=a.replace(l.match[n],"");if(!g)return[];break}}if(a===h)if(g==null)k.error(a);else break;h=a}return j},k.error=function(a){throw"Syntax error, unrecognized expression: "+a};var l=k.selectors={order:["ID","NAME","TAG"],match:{ID:/#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,CLASS:/\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,NAME:/\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/,ATTR:/\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/,TAG:/^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/,CHILD:/:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/,POS:/:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/,PSEUDO:/:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/},leftMatch:{},attrMap:{"class":"className","for":"htmlFor"},attrHandle:{href:function(a){return a.getAttribute("href")},type:function(a){return a.getAttribute("type")}},relative:{"+":function(a,b){var c=typeof b=="string",d=c&&!j.test(b),e=c&&!d;d&&(b=b.toLowerCase());for(var f=0,g=a.length,h;f<g;f++)if(h=a[f]){while((h=h.previousSibling)&&h.nodeType!==1);a[f]=e||h&&h.nodeName.toLowerCase()===b?h||!1:h===b}e&&k.filter(b,a,!0)},">":function(a,b){var c,d=typeof b=="string",e=0,f=a.length;if(d&&!j.test(b)){b=b.toLowerCase();for(;e<f;e++){c=a[e];if(c){var g=c.parentNode;a[e]=g.nodeName.toLowerCase()===b?g:!1}}}else{for(;e<f;e++)c=a[e],c&&(a[e]=d?c.parentNode:c.parentNode===b);d&&k.filter(b,a,!0)}},"":function(a,b,c){var e,f=d++,g=u;typeof b=="string"&&!j.test(b)&&(b=b.toLowerCase(),e=b,g=t),g("parentNode",b,f,a,e,c)},"~":function(a,b,c){var e,f=d++,g=u;typeof b=="string"&&!j.test(b)&&(b=b.toLowerCase(),e=b,g=t),g("previousSibling",b,f,a,e,c)}},find:{ID:function(a,b,c){if(typeof b.getElementById!="undefined"&&!c){var d=b.getElementById(a[1]);return d&&d.parentNode?[d]:[]}},NAME:function(a,b){if(typeof b.getElementsByName!="undefined"){var c=[],d=b.getElementsByName(a[1]);for(var e=0,f=d.length;e<f;e++)d[e].getAttribute("name")===a[1]&&c.push(d[e]);return c.length===0?null:c}},TAG:function(a,b){if(typeof b.getElementsByTagName!="undefined")return b.getElementsByTagName(a[1])}},preFilter:{CLASS:function(a,b,c,d,e,f){a=" "+a[1].replace(i,"")+" ";if(f)return a;for(var g=0,h;(h=b[g])!=null;g++)h&&(e^(h.className&&(" "+h.className+" ").replace(/[\t\n\r]/g," ").indexOf(a)>=0)?c||d.push(h):c&&(b[g]=!1));return!1},ID:function(a){return a[1].replace(i,"")},TAG:function(a,b){return a[1].replace(i,"").toLowerCase()},CHILD:function(a){if(a[1]==="nth"){a[2]||k.error(a[0]),a[2]=a[2].replace(/^\+|\s*/g,"");var b=/(-?)(\d*)(?:n([+\-]?\d*))?/.exec(a[2]==="even"&&"2n"||a[2]==="odd"&&"2n+1"||!/\D/.test(a[2])&&"0n+"+a[2]||a[2]);a[2]=b[1]+(b[2]||1)-0,a[3]=b[3]-0}else a[2]&&k.error(a[0]);a[0]=d++;return a},ATTR:function(a,b,c,d,e,f){var g=a[1]=a[1].replace(i,"");!f&&l.attrMap[g]&&(a[1]=l.attrMap[g]),a[4]=(a[4]||a[5]||"").replace(i,""),a[2]==="~="&&(a[4]=" "+a[4]+" ");return a},PSEUDO:function(b,c,d,e,f){if(b[1]==="not")if((a.exec(b[3])||"").length>1||/^\w/.test(b[3]))b[3]=k(b[3],null,null,c);else{var g=k.filter(b[3],c,d,!0^f);d||e.push.apply(e,g);return!1}else if(l.match.POS.test(b[0])||l.match.CHILD.test(b[0]))return!0;return b},POS:function(a){a.unshift(!0);return a}},filters:{enabled:function(a){return a.disabled===!1&&a.type!=="hidden"},disabled:function(a){return a.disabled===!0},checked:function(a){return a.checked===!0},selected:function(a){a.parentNode&&a.parentNode.selectedIndex;return a.selected===!0},parent:function(a){return!!a.firstChild},empty:function(a){return!a.firstChild},has:function(a,b,c){return!!k(c[3],a).length},header:function(a){return/h\d/i.test(a.nodeName)},text:function(a){var b=a.getAttribute("type"),c=a.type;return a.nodeName.toLowerCase()==="input"&&"text"===c&&(b===c||b===null)},radio:function(a){return a.nodeName.toLowerCase()==="input"&&"radio"===a.type},checkbox:function(a){return a.nodeName.toLowerCase()==="input"&&"checkbox"===a.type},file:function(a){return a.nodeName.toLowerCase()==="input"&&"file"===a.type},password:function(a){return a.nodeName.toLowerCase()==="input"&&"password"===a.type},submit:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"submit"===a.type},image:function(a){return a.nodeName.toLowerCase()==="input"&&"image"===a.type},reset:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"reset"===a.type},button:function(a){var b=a.nodeName.toLowerCase();return b==="input"&&"button"===a.type||b==="button"},input:function(a){return/input|select|textarea|button/i.test(a.nodeName)},focus:function(a){return a===a.ownerDocument.activeElement}},setFilters:{first:function(a,b){return b===0},last:function(a,b,c,d){return b===d.length-1},even:function(a,b){return b%2===0},odd:function(a,b){return b%2===1},lt:function(a,b,c){return b<c[3]-0},gt:function(a,b,c){return b>c[3]-0},nth:function(a,b,c){return c[3]-0===b},eq:function(a,b,c){return c[3]-0===b}},filter:{PSEUDO:function(a,b,c,d){var e=b[1],f=l.filters[e];if(f)return f(a,c,b,d);if(e==="contains")return(a.textContent||a.innerText||k.getText([a])||"").indexOf(b[3])>=0;if(e==="not"){var g=b[3];for(var h=0,i=g.length;h<i;h++)if(g[h]===a)return!1;return!0}k.error(e)},CHILD:function(a,b){var c=b[1],d=a;switch(c){case"only":case"first":while(d=d.previousSibling)if(d.nodeType===1)return!1;if(c==="first")return!0;d=a;case"last":while(d=d.nextSibling)if(d.nodeType===1)return!1;return!0;case"nth":var e=b[2],f=b[3];if(e===1&&f===0)return!0;var g=b[0],h=a.parentNode;if(h&&(h.sizcache!==g||!a.nodeIndex)){var i=0;for(d=h.firstChild;d;d=d.nextSibling)d.nodeType===1&&(d.nodeIndex=++i);h.sizcache=g}var j=a.nodeIndex-f;return e===0?j===0:j%e===0&&j/e>=0}},ID:function(a,b){return a.nodeType===1&&a.getAttribute("id")===b},TAG:function(a,b){return b==="*"&&a.nodeType===1||a.nodeName.toLowerCase()===b},CLASS:function(a,b){return(" "+(a.className||a.getAttribute("class"))+" ").indexOf(b)>-1},ATTR:function(a,b){var c=b[1],d=l.attrHandle[c]?l.attrHandle[c](a):a[c]!=null?a[c]:a.getAttribute(c),e=d+"",f=b[2],g=b[4];return d==null?f==="!=":f==="="?e===g:f==="*="?e.indexOf(g)>=0:f==="~="?(" "+e+" ").indexOf(g)>=0:g?f==="!="?e!==g:f==="^="?e.indexOf(g)===0:f==="$="?e.substr(e.length-g.length)===g:f==="|="?e===g||e.substr(0,g.length+1)===g+"-":!1:e&&d!==!1},POS:function(a,b,c,d){var e=b[2],f=l.setFilters[e];if(f)return f(a,c,b,d)}}},m=l.match.POS,n=function(a,b){return"\\"+(b-0+1)};for(var o in l.match)l.match[o]=new RegExp(l.match[o].source+/(?![^\[]*\])(?![^\(]*\))/.source),l.leftMatch[o]=new RegExp(/(^(?:.|\r|\n)*?)/.source+l.match[o].source.replace(/\\(\d+)/g,n));var p=function(a,b){a=Array.prototype.slice.call(a,0);if(b){b.push.apply(b,a);return b}return a};try{Array.prototype.slice.call(c.documentElement.childNodes,0)[0].nodeType}catch(q){p=function(a,b){var c=0,d=b||[];if(e.call(a)==="[object Array]")Array.prototype.push.apply(d,a);else if(typeof a.length=="number")for(var f=a.length;c<f;c++)d.push(a[c]);else for(;a[c];c++)d.push(a[c]);return d}}var r,s;c.documentElement.compareDocumentPosition?r=function(a,b){if(a===b){g=!0;return 0}if(!a.compareDocumentPosition||!b.compareDocumentPosition)return a.compareDocumentPosition?-1:1;return a.compareDocumentPosition(b)&4?-1:1}:(r=function(a,b){if(a===b){g=!0;return 0}if(a.sourceIndex&&b.sourceIndex)return a.sourceIndex-b.sourceIndex;var c,d,e=[],f=[],h=a.parentNode,i=b.parentNode,j=h;if(h===i)return s(a,b);if(!h)return-1;if(!i)return 1;while(j)e.unshift(j),j=j.parentNode;j=i;while(j)f.unshift(j),j=j.parentNode;c=e.length,d=f.length;for(var k=0;k<c&&k<d;k++)if(e[k]!==f[k])return s(e[k],f[k]);return k===c?s(a,f[k],-1):s(e[k],b,1)},s=function(a,b,c){if(a===b)return c;var d=a.nextSibling;while(d){if(d===b)return-1;d=d.nextSibling}return 1}),k.getText=function(a){var b="",c;for(var d=0;a[d];d++)c=a[d],c.nodeType===3||c.nodeType===4?b+=c.nodeValue:c.nodeType!==8&&(b+=k.getText(c.childNodes));return b},function(){var a=c.createElement("div"),d="script"+(new Date).getTime(),e=c.documentElement;a.innerHTML="<a name='"+d+"'/>",e.insertBefore(a,e.firstChild),c.getElementById(d)&&(l.find.ID=function(a,c,d){if(typeof c.getElementById!="undefined"&&!d){var e=c.getElementById(a[1]);return e?e.id===a[1]||typeof e.getAttributeNode!="undefined"&&e.getAttributeNode("id").nodeValue===a[1]?[e]:b:[]}},l.filter.ID=function(a,b){var c=typeof a.getAttributeNode!="undefined"&&a.getAttributeNode("id");return a.nodeType===1&&c&&c.nodeValue===b}),e.removeChild(a),e=a=null}(),function(){var a=c.createElement("div");a.appendChild(c.createComment("")),a.getElementsByTagName("*").length>0&&(l.find.TAG=function(a,b){var c=b.getElementsByTagName(a[1]);if(a[1]==="*"){var d=[];for(var e=0;c[e];e++)c[e].nodeType===1&&d.push(c[e]);c=d}return c}),a.innerHTML="<a href='#'></a>",a.firstChild&&typeof a.firstChild.getAttribute!="undefined"&&a.firstChild.getAttribute("href")!=="#"&&(l.attrHandle.href=function(a){return a.getAttribute("href",2)}),a=null}(),c.querySelectorAll&&function(){var a=k,b=c.createElement("div"),d="__sizzle__";b.innerHTML="<p class='TEST'></p>";if(!b.querySelectorAll||b.querySelectorAll(".TEST").length!==0){k=function(b,e,f,g){e=e||c;if(!g&&!k.isXML(e)){var h=/^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec(b);if(h&&(e.nodeType===1||e.nodeType===9)){if(h[1])return p(e.getElementsByTagName(b),f);if(h[2]&&l.find.CLASS&&e.getElementsByClassName)return p(e.getElementsByClassName(h[2]),f)}if(e.nodeType===9){if(b==="body"&&e.body)return p([e.body],f);if(h&&h[3]){var i=e.getElementById(h[3]);if(!i||!i.parentNode)return p([],f);if(i.id===h[3])return p([i],f)}try{return p(e.querySelectorAll(b),f)}catch(j){}}else if(e.nodeType===1&&e.nodeName.toLowerCase()!=="object"){var m=e,n=e.getAttribute("id"),o=n||d,q=e.parentNode,r=/^\s*[+~]/.test(b);n?o=o.replace(/'/g,"\\$&"):e.setAttribute("id",o),r&&q&&(e=e.parentNode);try{if(!r||q)return p(e.querySelectorAll("[id='"+o+"'] "+b),f)}catch(s){}finally{n||m.removeAttribute("id")}}}return a(b,e,f,g)};for(var e in a)k[e]=a[e];b=null}}(),function(){var a=c.documentElement,b=a.matchesSelector||a.mozMatchesSelector||a.webkitMatchesSelector||a.msMatchesSelector;if(b){var d=!b.call(c.createElement("div"),"div"),e=!1;try{b.call(c.documentElement,"[test!='']:sizzle")}catch(f){e=!0}k.matchesSelector=function(a,c){c=c.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!k.isXML(a))try{if(e||!l.match.PSEUDO.test(c)&&!/!=/.test(c)){var f=b.call(a,c);if(f||!d||a.document&&a.document.nodeType!==11)return f}}catch(g){}return k(c,null,null,[a]).length>0}}}(),function(){var a=c.createElement("div");a.innerHTML="<div class='test e'></div><div class='test'></div>";if(!!a.getElementsByClassName&&a.getElementsByClassName("e").length!==0){a.lastChild.className="e";if(a.getElementsByClassName("e").length===1)return;l.order.splice(1,0,"CLASS"),l.find.CLASS=function(a,b,c){if(typeof b.getElementsByClassName!="undefined"&&!c)return b.getElementsByClassName(a[1])},a=null}}(),c.documentElement.contains?k.contains=function(a,b){return a!==b&&(a.contains?a.contains(b):!0)}:c.documentElement.compareDocumentPosition?k.contains=function(a,b){return!!(a.compareDocumentPosition(b)&16)}:k.contains=function(){return!1},k.isXML=function(a){var b=(a?a.ownerDocument||a:0).documentElement;return b?b.nodeName!=="HTML":!1};var v=function(a,b){var c,d=[],e="",f=b.nodeType?[b]:b;while(c=l.match.PSEUDO.exec(a))e+=c[0],a=a.replace(l.match.PSEUDO,"");a=l.relative[a]?a+"*":a;for(var g=0,h=f.length;g<h;g++)k(a,f[g],d);return k.filter(e,d)};f.find=k,f.expr=k.selectors,f.expr[":"]=f.expr.filters,f.unique=k.uniqueSort,f.text=k.getText,f.isXMLDoc=k.isXML,f.contains=k.contains}();var N=/Until$/,O=/^(?:parents|prevUntil|prevAll)/,P=/,/,Q=/^.[^:#\[\.,]*$/,R=Array.prototype.slice,S=f.expr.match.POS,T={children:!0,contents:!0,next:!0,prev:!0};f.fn.extend({find:function(a){var b=this,c,d;if(typeof a!="string")return f(a).filter(function(){for(c=0,d=b.length;c<d;c++)if(f.contains(b[c],this))return!0});var e=this.pushStack("","find",a),g,h,i;for(c=0,d=this.length;c<d;c++){g=e.length,f.find(a,this[c],e);if(c>0)for(h=g;h<e.length;h++)for(i=0;i<g;i++)if(e[i]===e[h]){e.splice(h--,1);break}}return e},has:function(a){var b=f(a);return this.filter(function(){for(var a=0,c=b.length;a<c;a++)if(f.contains(this,b[a]))return!0})},not:function(a){return this.pushStack(V(this,a,!1),"not",a)},filter:function(a){return this.pushStack(V(this,a,!0),"filter",a)},is:function(a){return!!a&&(typeof a=="string"?f.filter(a,this).length>0:this.filter(a).length>0)},closest:function(a,b){var c=[],d,e,g=this[0];if(f.isArray(a)){var h,i,j={},k=1;if(g&&a.length){for(d=0,e=a.length;d<e;d++)i=a[d],j[i]||(j[i]=S.test(i)?f(i,b||this.context):i);while(g&&g.ownerDocument&&g!==b){for(i in j)h=j[i],(h.jquery?h.index(g)>-1:f(g).is(h))&&c.push({selector:i,elem:g,level:k});g=g.parentNode,k++}}return c}var l=S.test(a)||typeof a!="string"?f(a,b||this.context):0;for(d=0,e=this.length;d<e;d++){g=this[d];while(g){if(l?l.index(g)>-1:f.find.matchesSelector(g,a)){c.push(g);break}g=g.parentNode;if(!g||!g.ownerDocument||g===b||g.nodeType===11)break}}c=c.length>1?f.unique(c):c;return this.pushStack(c,"closest",a)},index:function(a){if(!a)return this[0]&&this[0].parentNode?this.prevAll().length:-1;if(typeof a=="string")return f.inArray(this[0],f(a));return f.inArray(a.jquery?a[0]:a,this)},add:function(a,b){var c=typeof a=="string"?f(a,b):f.makeArray(a&&a.nodeType?[a]:a),d=f.merge(this.get(),c);return this.pushStack(U(c[0])||U(d[0])?d:f.unique(d))},andSelf:function(){return this.add(this.prevObject)}}),f.each({parent:function(a){var b=a.parentNode;return b&&b.nodeType!==11?b:null},parents:function(a){return f.dir(a,"parentNode")},parentsUntil:function(a,b,c){return f.dir(a,"parentNode",c)},next:function(a){return f.nth(a,2,"nextSibling")},prev:function(a){return f.nth(a,2,"previousSibling")},nextAll:function(a){return f.dir(a,"nextSibling")},prevAll:function(a){return f.dir(a,"previousSibling")},nextUntil:function(a,b,c){return f.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return f.dir(a,"previousSibling",c)},siblings:function(a){return f.sibling(a.parentNode.firstChild,a)},children:function(a){return f.sibling(a.firstChild)},contents:function(a){return f.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:f.makeArray(a.childNodes)}},function(a,b){f.fn[a]=function(c,d){var e=f.map(this,b,c),g=R.call(arguments);N.test(a)||(d=c),d&&typeof d=="string"&&(e=f.filter(d,e)),e=this.length>1&&!T[a]?f.unique(e):e,(this.length>1||P.test(d))&&O.test(a)&&(e=e.reverse());return this.pushStack(e,a,g.join(","))}}),f.extend({filter:function(a,b,c){c&&(a=":not("+a+")");return b.length===1?f.find.matchesSelector(b[0],a)?[b[0]]:[]:f.find.matches(a,b)},dir:function(a,c,d){var e=[],g=a[c];while(g&&g.nodeType!==9&&(d===b||g.nodeType!==1||!f(g).is(d)))g.nodeType===1&&e.push(g),g=g[c];return e},nth:function(a,b,c,d){b=b||1;var e=0;for(;a;a=a[c])if(a.nodeType===1&&++e===b)break;return a},sibling:function(a,b){var c=[];for(;a;a=a.nextSibling)a.nodeType===1&&a!==b&&c.push(a);return c}});var W=/ jQuery\d+="(?:\d+|null)"/g,X=/^\s+/,Y=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,Z=/<([\w:]+)/,$=/<tbody/i,_=/<|&#?\w+;/,ba=/<(?:script|object|embed|option|style)/i,bb=/checked\s*(?:[^=]|=\s*.checked.)/i,bc=/\/(java|ecma)script/i,bd=/^\s*<!(?:\[CDATA\[|\-\-)/,be={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],area:[1,"<map>","</map>"],_default:[0,"",""]};be.optgroup=be.option,be.tbody=be.tfoot=be.colgroup=be.caption=be.thead,be.th=be.td,f.support.htmlSerialize||(be._default=[1,"div<div>","</div>"]),f.fn.extend({text:function(a){if(f.isFunction(a))return this.each(function(b){var c=f(this);c.text(a.call(this,b,c.text()))});if(typeof a!="object"&&a!==b)return this.empty().append((this[0]&&this[0].ownerDocument||c).createTextNode(a));return f.text(this)},wrapAll:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapAll(a.call(this,b))});if(this[0]){var b=f(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstChild&&a.firstChild.nodeType===1)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapInner(a.call(this,b))});return this.each(function(){var b=f(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){return this.each(function(){f(this).wrapAll(a)})},unwrap:function(){return this.parent().each(function(){f.nodeName(this,"body")||f(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this)});if(arguments.length){var a=f(arguments[0]);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this.nextSibling)});if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,f(arguments[0]).toArray());return a}},remove:function(a,b){for(var c=0,d;(d=this[c])!=null;c++)if(!a||f.filter(a,[d]).length)!b&&d.nodeType===1&&(f.cleanData(d.getElementsByTagName("*")),f.cleanData([d])),d.parentNode&&d.parentNode.removeChild(d);return this},empty:function(){for(var a=0,b;(b=this[a])!=null;a++){b.nodeType===1&&f.cleanData(b.getElementsByTagName("*"));while(b.firstChild)b.removeChild(b.firstChild)}return this},clone:function(a,b){a=a==null?!1:a,b=b==null?a:b;return this.map(function(){return f.clone(this,a,b)})},html:function(a){if(a===b)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(W,""):null;if(typeof a=="string"&&!ba.test(a)&&(f.support.leadingWhitespace||!X.test(a))&&!be[(Z.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Y,"<$1></$2>");try{for(var c=0,d=this.length;c<d;c++)this[c].nodeType===1&&(f.cleanData(this[c].getElementsByTagName("*")),this[c].innerHTML=a)}catch(e){this.empty().append(a)}}else f.isFunction(a)?this.each(function(b){var c=f(this);c.html(a.call(this,b,c.html()))}):this.empty().append(a);return this},replaceWith:function(a){if(this[0]&&this[0].parentNode){if(f.isFunction(a))return this.each(function(b){var c=f(this),d=c.html();c.replaceWith(a.call(this,b,d))});typeof a!="string"&&(a=f(a).detach());return this.each(function(){var b=this.nextSibling,c=this.parentNode;f(this).remove(),b?f(b).before(a):f(c).append(a)})}return this.length?this.pushStack(f(f.isFunction(a)?a():a),"replaceWith",a):this},detach:function(a){return this.remove(a,!0)},domManip:function(a,c,d){var e,g,h,i,j=a[0],k=[];if(!f.support.checkClone&&arguments.length===3&&typeof j=="string"&&bb.test(j))return this.each(function(){f(this).domManip(a,c,d,!0)});if(f.isFunction(j))return this.each(function(e){var g=f(this);a[0]=j.call(this,e,c?g.html():b),g.domManip(a,c,d)});if(this[0]){i=j&&j.parentNode,f.support.parentNode&&i&&i.nodeType===11&&i.childNodes.length===this.length?e={fragment:i}:e=f.buildFragment(a,this,k),h=e.fragment,h.childNodes.length===1?g=h=h.firstChild:g=h.firstChild;if(g){c=c&&f.nodeName(g,"tr");for(var l=0,m=this.length,n=m-1;l<m;l++)d.call(c?bf(this[l],g):this[l],e.cacheable||m>1&&l<n?f.clone(h,!0,!0):h)}k.length&&f.each(k,bl)}return this}}),f.buildFragment=function(a,b,d){var e,g,h,i;b&&b[0]&&(i=b[0].ownerDocument||b[0]),i.createDocumentFragment||(i=c),a.length===1&&typeof a[0]=="string"&&a[0].length<512&&i===c&&a[0].charAt(0)==="<"&&!ba.test(a[0])&&(f.support.checkClone||!bb.test(a[0]))&&(g=!0,h=f.fragments[a[0]],h&&h!==1&&(e=h)),e||(e=i.createDocumentFragment(),f.clean
|
4
|
+
(a,i,e,d)),g&&(f.fragments[a[0]]=h?e:1);return{fragment:e,cacheable:g}},f.fragments={},f.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){f.fn[a]=function(c){var d=[],e=f(c),g=this.length===1&&this[0].parentNode;if(g&&g.nodeType===11&&g.childNodes.length===1&&e.length===1){e[b](this[0]);return this}for(var h=0,i=e.length;h<i;h++){var j=(h>0?this.clone(!0):this).get();f(e[h])[b](j),d=d.concat(j)}return this.pushStack(d,a,e.selector)}}),f.extend({clone:function(a,b,c){var d=a.cloneNode(!0),e,g,h;if((!f.support.noCloneEvent||!f.support.noCloneChecked)&&(a.nodeType===1||a.nodeType===11)&&!f.isXMLDoc(a)){bh(a,d),e=bi(a),g=bi(d);for(h=0;e[h];++h)g[h]&&bh(e[h],g[h])}if(b){bg(a,d);if(c){e=bi(a),g=bi(d);for(h=0;e[h];++h)bg(e[h],g[h])}}e=g=null;return d},clean:function(a,b,d,e){var g;b=b||c,typeof b.createElement=="undefined"&&(b=b.ownerDocument||b[0]&&b[0].ownerDocument||c);var h=[],i;for(var j=0,k;(k=a[j])!=null;j++){typeof k=="number"&&(k+="");if(!k)continue;if(typeof k=="string")if(!_.test(k))k=b.createTextNode(k);else{k=k.replace(Y,"<$1></$2>");var l=(Z.exec(k)||["",""])[1].toLowerCase(),m=be[l]||be._default,n=m[0],o=b.createElement("div");o.innerHTML=m[1]+k+m[2];while(n--)o=o.lastChild;if(!f.support.tbody){var p=$.test(k),q=l==="table"&&!p?o.firstChild&&o.firstChild.childNodes:m[1]==="<table>"&&!p?o.childNodes:[];for(i=q.length-1;i>=0;--i)f.nodeName(q[i],"tbody")&&!q[i].childNodes.length&&q[i].parentNode.removeChild(q[i])}!f.support.leadingWhitespace&&X.test(k)&&o.insertBefore(b.createTextNode(X.exec(k)[0]),o.firstChild),k=o.childNodes}var r;if(!f.support.appendChecked)if(k[0]&&typeof (r=k.length)=="number")for(i=0;i<r;i++)bk(k[i]);else bk(k);k.nodeType?h.push(k):h=f.merge(h,k)}if(d){g=function(a){return!a.type||bc.test(a.type)};for(j=0;h[j];j++)if(e&&f.nodeName(h[j],"script")&&(!h[j].type||h[j].type.toLowerCase()==="text/javascript"))e.push(h[j].parentNode?h[j].parentNode.removeChild(h[j]):h[j]);else{if(h[j].nodeType===1){var s=f.grep(h[j].getElementsByTagName("script"),g);h.splice.apply(h,[j+1,0].concat(s))}d.appendChild(h[j])}}return h},cleanData:function(a){var b,c,d=f.cache,e=f.expando,g=f.event.special,h=f.support.deleteExpando;for(var i=0,j;(j=a[i])!=null;i++){if(j.nodeName&&f.noData[j.nodeName.toLowerCase()])continue;c=j[f.expando];if(c){b=d[c]&&d[c][e];if(b&&b.events){for(var k in b.events)g[k]?f.event.remove(j,k):f.removeEvent(j,k,b.handle);b.handle&&(b.handle.elem=null)}h?delete j[f.expando]:j.removeAttribute&&j.removeAttribute(f.expando),delete d[c]}}}});var bm=/alpha\([^)]*\)/i,bn=/opacity=([^)]*)/,bo=/([A-Z]|^ms)/g,bp=/^-?\d+(?:px)?$/i,bq=/^-?\d/,br=/^([\-+])=([\-+.\de]+)/,bs={position:"absolute",visibility:"hidden",display:"block"},bt=["Left","Right"],bu=["Top","Bottom"],bv,bw,bx;f.fn.css=function(a,c){if(arguments.length===2&&c===b)return this;return f.access(this,a,c,!0,function(a,c,d){return d!==b?f.style(a,c,d):f.css(a,c)})},f.extend({cssHooks:{opacity:{get:function(a,b){if(b){var c=bv(a,"opacity","opacity");return c===""?"1":c}return a.style.opacity}}},cssNumber:{fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":f.support.cssFloat?"cssFloat":"styleFloat"},style:function(a,c,d,e){if(!!a&&a.nodeType!==3&&a.nodeType!==8&&!!a.style){var g,h,i=f.camelCase(c),j=a.style,k=f.cssHooks[i];c=f.cssProps[i]||i;if(d===b){if(k&&"get"in k&&(g=k.get(a,!1,e))!==b)return g;return j[c]}h=typeof d,h==="string"&&(g=br.exec(d))&&(d=+(g[1]+1)*+g[2]+parseFloat(f.css(a,c)),h="number");if(d==null||h==="number"&&isNaN(d))return;h==="number"&&!f.cssNumber[i]&&(d+="px");if(!k||!("set"in k)||(d=k.set(a,d))!==b)try{j[c]=d}catch(l){}}},css:function(a,c,d){var e,g;c=f.camelCase(c),g=f.cssHooks[c],c=f.cssProps[c]||c,c==="cssFloat"&&(c="float");if(g&&"get"in g&&(e=g.get(a,!0,d))!==b)return e;if(bv)return bv(a,c)},swap:function(a,b,c){var d={};for(var e in b)d[e]=a.style[e],a.style[e]=b[e];c.call(a);for(e in b)a.style[e]=d[e]}}),f.curCSS=f.css,f.each(["height","width"],function(a,b){f.cssHooks[b]={get:function(a,c,d){var e;if(c){if(a.offsetWidth!==0)return by(a,b,d);f.swap(a,bs,function(){e=by(a,b,d)});return e}},set:function(a,b){if(!bp.test(b))return b;b=parseFloat(b);if(b>=0)return b+"px"}}}),f.support.opacity||(f.cssHooks.opacity={get:function(a,b){return bn.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?parseFloat(RegExp.$1)/100+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle,e=f.isNaN(b)?"":"alpha(opacity="+b*100+")",g=d&&d.filter||c.filter||"";c.zoom=1;if(b>=1&&f.trim(g.replace(bm,""))===""){c.removeAttribute("filter");if(d&&!d.filter)return}c.filter=bm.test(g)?g.replace(bm,e):g+" "+e}}),f(function(){f.support.reliableMarginRight||(f.cssHooks.marginRight={get:function(a,b){var c;f.swap(a,{display:"inline-block"},function(){b?c=bv(a,"margin-right","marginRight"):c=a.style.marginRight});return c}})}),c.defaultView&&c.defaultView.getComputedStyle&&(bw=function(a,c){var d,e,g;c=c.replace(bo,"-$1").toLowerCase();if(!(e=a.ownerDocument.defaultView))return b;if(g=e.getComputedStyle(a,null))d=g.getPropertyValue(c),d===""&&!f.contains(a.ownerDocument.documentElement,a)&&(d=f.style(a,c));return d}),c.documentElement.currentStyle&&(bx=function(a,b){var c,d=a.currentStyle&&a.currentStyle[b],e=a.runtimeStyle&&a.runtimeStyle[b],f=a.style;!bp.test(d)&&bq.test(d)&&(c=f.left,e&&(a.runtimeStyle.left=a.currentStyle.left),f.left=b==="fontSize"?"1em":d||0,d=f.pixelLeft+"px",f.left=c,e&&(a.runtimeStyle.left=e));return d===""?"auto":d}),bv=bw||bx,f.expr&&f.expr.filters&&(f.expr.filters.hidden=function(a){var b=a.offsetWidth,c=a.offsetHeight;return b===0&&c===0||!f.support.reliableHiddenOffsets&&(a.style.display||f.css(a,"display"))==="none"},f.expr.filters.visible=function(a){return!f.expr.filters.hidden(a)});var bz=/%20/g,bA=/\[\]$/,bB=/\r?\n/g,bC=/#.*$/,bD=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,bE=/^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,bF=/^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,bG=/^(?:GET|HEAD)$/,bH=/^\/\//,bI=/\?/,bJ=/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,bK=/^(?:select|textarea)/i,bL=/\s+/,bM=/([?&])_=[^&]*/,bN=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,bO=f.fn.load,bP={},bQ={},bR,bS,bT=["*/"]+["*"];try{bR=e.href}catch(bU){bR=c.createElement("a"),bR.href="",bR=bR.href}bS=bN.exec(bR.toLowerCase())||[],f.fn.extend({load:function(a,c,d){if(typeof a!="string"&&bO)return bO.apply(this,arguments);if(!this.length)return this;var e=a.indexOf(" ");if(e>=0){var g=a.slice(e,a.length);a=a.slice(0,e)}var h="GET";c&&(f.isFunction(c)?(d=c,c=b):typeof c=="object"&&(c=f.param(c,f.ajaxSettings.traditional),h="POST"));var i=this;f.ajax({url:a,type:h,dataType:"html",data:c,complete:function(a,b,c){c=a.responseText,a.isResolved()&&(a.done(function(a){c=a}),i.html(g?f("<div>").append(c.replace(bJ,"")).find(g):c)),d&&i.each(d,[c,b,a])}});return this},serialize:function(){return f.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?f.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||bK.test(this.nodeName)||bE.test(this.type))}).map(function(a,b){var c=f(this).val();return c==null?null:f.isArray(c)?f.map(c,function(a,c){return{name:b.name,value:a.replace(bB,"\r\n")}}):{name:b.name,value:c.replace(bB,"\r\n")}}).get()}}),f.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){f.fn[b]=function(a){return this.bind(b,a)}}),f.each(["get","post"],function(a,c){f[c]=function(a,d,e,g){f.isFunction(d)&&(g=g||e,e=d,d=b);return f.ajax({type:c,url:a,data:d,success:e,dataType:g})}}),f.extend({getScript:function(a,c){return f.get(a,b,c,"script")},getJSON:function(a,b,c){return f.get(a,b,c,"json")},ajaxSetup:function(a,b){b?bX(a,f.ajaxSettings):(b=a,a=f.ajaxSettings),bX(a,b);return a},ajaxSettings:{url:bR,isLocal:bF.test(bS[1]),global:!0,type:"GET",contentType:"application/x-www-form-urlencoded",processData:!0,async:!0,accepts:{xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":bT},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":a.String,"text html":!0,"text json":f.parseJSON,"text xml":f.parseXML},flatOptions:{context:!0,url:!0}},ajaxPrefilter:bV(bP),ajaxTransport:bV(bQ),ajax:function(a,c){function w(a,c,l,m){if(s!==2){s=2,q&&clearTimeout(q),p=b,n=m||"",v.readyState=a>0?4:0;var o,r,u,w=c,x=l?bZ(d,v,l):b,y,z;if(a>=200&&a<300||a===304){if(d.ifModified){if(y=v.getResponseHeader("Last-Modified"))f.lastModified[k]=y;if(z=v.getResponseHeader("Etag"))f.etag[k]=z}if(a===304)w="notmodified",o=!0;else try{r=b$(d,x),w="success",o=!0}catch(A){w="parsererror",u=A}}else{u=w;if(!w||a)w="error",a<0&&(a=0)}v.status=a,v.statusText=""+(c||w),o?h.resolveWith(e,[r,w,v]):h.rejectWith(e,[v,w,u]),v.statusCode(j),j=b,t&&g.trigger("ajax"+(o?"Success":"Error"),[v,d,o?r:u]),i.resolveWith(e,[v,w]),t&&(g.trigger("ajaxComplete",[v,d]),--f.active||f.event.trigger("ajaxStop"))}}typeof a=="object"&&(c=a,a=b),c=c||{};var d=f.ajaxSetup({},c),e=d.context||d,g=e!==d&&(e.nodeType||e instanceof f)?f(e):f.event,h=f.Deferred(),i=f._Deferred(),j=d.statusCode||{},k,l={},m={},n,o,p,q,r,s=0,t,u,v={readyState:0,setRequestHeader:function(a,b){if(!s){var c=a.toLowerCase();a=m[c]=m[c]||a,l[a]=b}return this},getAllResponseHeaders:function(){return s===2?n:null},getResponseHeader:function(a){var c;if(s===2){if(!o){o={};while(c=bD.exec(n))o[c[1].toLowerCase()]=c[2]}c=o[a.toLowerCase()]}return c===b?null:c},overrideMimeType:function(a){s||(d.mimeType=a);return this},abort:function(a){a=a||"abort",p&&p.abort(a),w(0,a);return this}};h.promise(v),v.success=v.done,v.error=v.fail,v.complete=i.done,v.statusCode=function(a){if(a){var b;if(s<2)for(b in a)j[b]=[j[b],a[b]];else b=a[v.status],v.then(b,b)}return this},d.url=((a||d.url)+"").replace(bC,"").replace(bH,bS[1]+"//"),d.dataTypes=f.trim(d.dataType||"*").toLowerCase().split(bL),d.crossDomain==null&&(r=bN.exec(d.url.toLowerCase()),d.crossDomain=!(!r||r[1]==bS[1]&&r[2]==bS[2]&&(r[3]||(r[1]==="http:"?80:443))==(bS[3]||(bS[1]==="http:"?80:443)))),d.data&&d.processData&&typeof d.data!="string"&&(d.data=f.param(d.data,d.traditional)),bW(bP,d,c,v);if(s===2)return!1;t=d.global,d.type=d.type.toUpperCase(),d.hasContent=!bG.test(d.type),t&&f.active++===0&&f.event.trigger("ajaxStart");if(!d.hasContent){d.data&&(d.url+=(bI.test(d.url)?"&":"?")+d.data,delete d.data),k=d.url;if(d.cache===!1){var x=f.now(),y=d.url.replace(bM,"$1_="+x);d.url=y+(y===d.url?(bI.test(d.url)?"&":"?")+"_="+x:"")}}(d.data&&d.hasContent&&d.contentType!==!1||c.contentType)&&v.setRequestHeader("Content-Type",d.contentType),d.ifModified&&(k=k||d.url,f.lastModified[k]&&v.setRequestHeader("If-Modified-Since",f.lastModified[k]),f.etag[k]&&v.setRequestHeader("If-None-Match",f.etag[k])),v.setRequestHeader("Accept",d.dataTypes[0]&&d.accepts[d.dataTypes[0]]?d.accepts[d.dataTypes[0]]+(d.dataTypes[0]!=="*"?", "+bT+"; q=0.01":""):d.accepts["*"]);for(u in d.headers)v.setRequestHeader(u,d.headers[u]);if(d.beforeSend&&(d.beforeSend.call(e,v,d)===!1||s===2)){v.abort();return!1}for(u in{success:1,error:1,complete:1})v[u](d[u]);p=bW(bQ,d,c,v);if(!p)w(-1,"No Transport");else{v.readyState=1,t&&g.trigger("ajaxSend",[v,d]),d.async&&d.timeout>0&&(q=setTimeout(function(){v.abort("timeout")},d.timeout));try{s=1,p.send(l,w)}catch(z){s<2?w(-1,z):f.error(z)}}return v},param:function(a,c){var d=[],e=function(a,b){b=f.isFunction(b)?b():b,d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};c===b&&(c=f.ajaxSettings.traditional);if(f.isArray(a)||a.jquery&&!f.isPlainObject(a))f.each(a,function(){e(this.name,this.value)});else for(var g in a)bY(g,a[g],c,e);return d.join("&").replace(bz,"+")}}),f.extend({active:0,lastModified:{},etag:{}});var b_=f.now(),ca=/(\=)\?(&|$)|\?\?/i;f.ajaxSetup({jsonp:"callback",jsonpCallback:function(){return f.expando+"_"+b_++}}),f.ajaxPrefilter("json jsonp",function(b,c,d){var e=b.contentType==="application/x-www-form-urlencoded"&&typeof b.data=="string";if(b.dataTypes[0]==="jsonp"||b.jsonp!==!1&&(ca.test(b.url)||e&&ca.test(b.data))){var g,h=b.jsonpCallback=f.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,i=a[h],j=b.url,k=b.data,l="$1"+h+"$2";b.jsonp!==!1&&(j=j.replace(ca,l),b.url===j&&(e&&(k=k.replace(ca,l)),b.data===k&&(j+=(/\?/.test(j)?"&":"?")+b.jsonp+"="+h))),b.url=j,b.data=k,a[h]=function(a){g=[a]},d.always(function(){a[h]=i,g&&f.isFunction(i)&&a[h](g[0])}),b.converters["script json"]=function(){g||f.error(h+" was not called");return g[0]},b.dataTypes[0]="json";return"script"}}),f.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/javascript|ecmascript/},converters:{"text script":function(a){f.globalEval(a);return a}}}),f.ajaxPrefilter("script",function(a){a.cache===b&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),f.ajaxTransport("script",function(a){if(a.crossDomain){var d,e=c.head||c.getElementsByTagName("head")[0]||c.documentElement;return{send:function(f,g){d=c.createElement("script"),d.async="async",a.scriptCharset&&(d.charset=a.scriptCharset),d.src=a.url,d.onload=d.onreadystatechange=function(a,c){if(c||!d.readyState||/loaded|complete/.test(d.readyState))d.onload=d.onreadystatechange=null,e&&d.parentNode&&e.removeChild(d),d=b,c||g(200,"success")},e.insertBefore(d,e.firstChild)},abort:function(){d&&d.onload(0,1)}}}});var cb=a.ActiveXObject?function(){for(var a in cd)cd[a](0,1)}:!1,cc=0,cd;f.ajaxSettings.xhr=a.ActiveXObject?function(){return!this.isLocal&&ce()||cf()}:ce,function(a){f.extend(f.support,{ajax:!!a,cors:!!a&&"withCredentials"in a})}(f.ajaxSettings.xhr()),f.support.ajax&&f.ajaxTransport(function(c){if(!c.crossDomain||f.support.cors){var d;return{send:function(e,g){var h=c.xhr(),i,j;c.username?h.open(c.type,c.url,c.async,c.username,c.password):h.open(c.type,c.url,c.async);if(c.xhrFields)for(j in c.xhrFields)h[j]=c.xhrFields[j];c.mimeType&&h.overrideMimeType&&h.overrideMimeType(c.mimeType),!c.crossDomain&&!e["X-Requested-With"]&&(e["X-Requested-With"]="XMLHttpRequest");try{for(j in e)h.setRequestHeader(j,e[j])}catch(k){}h.send(c.hasContent&&c.data||null),d=function(a,e){var j,k,l,m,n;try{if(d&&(e||h.readyState===4)){d=b,i&&(h.onreadystatechange=f.noop,cb&&delete cd[i]);if(e)h.readyState!==4&&h.abort();else{j=h.status,l=h.getAllResponseHeaders(),m={},n=h.responseXML,n&&n.documentElement&&(m.xml=n),m.text=h.responseText;try{k=h.statusText}catch(o){k=""}!j&&c.isLocal&&!c.crossDomain?j=m.text?200:404:j===1223&&(j=204)}}}catch(p){e||g(-1,p)}m&&g(j,k,m,l)},!c.async||h.readyState===4?d():(i=++cc,cb&&(cd||(cd={},f(a).unload(cb)),cd[i]=d),h.onreadystatechange=d)},abort:function(){d&&d(0,1)}}}});var cg={},ch,ci,cj=/^(?:toggle|show|hide)$/,ck=/^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,cl,cm=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]],cn;f.fn.extend({show:function(a,b,c){var d,e;if(a||a===0)return this.animate(cq("show",3),a,b,c);for(var g=0,h=this.length;g<h;g++)d=this[g],d.style&&(e=d.style.display,!f._data(d,"olddisplay")&&e==="none"&&(e=d.style.display=""),e===""&&f.css(d,"display")==="none"&&f._data(d,"olddisplay",cr(d.nodeName)));for(g=0;g<h;g++){d=this[g];if(d.style){e=d.style.display;if(e===""||e==="none")d.style.display=f._data(d,"olddisplay")||""}}return this},hide:function(a,b,c){if(a||a===0)return this.animate(cq("hide",3),a,b,c);for(var d=0,e=this.length;d<e;d++)if(this[d].style){var g=f.css(this[d],"display");g!=="none"&&!f._data(this[d],"olddisplay")&&f._data(this[d],"olddisplay",g)}for(d=0;d<e;d++)this[d].style&&(this[d].style.display="none");return this},_toggle:f.fn.toggle,toggle:function(a,b,c){var d=typeof a=="boolean";f.isFunction(a)&&f.isFunction(b)?this._toggle.apply(this,arguments):a==null||d?this.each(function(){var b=d?a:f(this).is(":hidden");f(this)[b?"show":"hide"]()}):this.animate(cq("toggle",3),a,b,c);return this},fadeTo:function(a,b,c,d){return this.filter(":hidden").css("opacity",0).show().end().animate({opacity:b},a,c,d)},animate:function(a,b,c,d){var e=f.speed(b,c,d);if(f.isEmptyObject(a))return this.each(e.complete,[!1]);a=f.extend({},a);return this[e.queue===!1?"each":"queue"](function(){e.queue===!1&&f._mark(this);var b=f.extend({},e),c=this.nodeType===1,d=c&&f(this).is(":hidden"),g,h,i,j,k,l,m,n,o;b.animatedProperties={};for(i in a){g=f.camelCase(i),i!==g&&(a[g]=a[i],delete a[i]),h=a[g],f.isArray(h)?(b.animatedProperties[g]=h[1],h=a[g]=h[0]):b.animatedProperties[g]=b.specialEasing&&b.specialEasing[g]||b.easing||"swing";if(h==="hide"&&d||h==="show"&&!d)return b.complete.call(this);c&&(g==="height"||g==="width")&&(b.overflow=[this.style.overflow,this.style.overflowX,this.style.overflowY],f.css(this,"display")==="inline"&&f.css(this,"float")==="none"&&(f.support.inlineBlockNeedsLayout?(j=cr(this.nodeName),j==="inline"?this.style.display="inline-block":(this.style.display="inline",this.style.zoom=1)):this.style.display="inline-block"))}b.overflow!=null&&(this.style.overflow="hidden");for(i in a)k=new f.fx(this,b,i),h=a[i],cj.test(h)?k[h==="toggle"?d?"show":"hide":h]():(l=ck.exec(h),m=k.cur(),l?(n=parseFloat(l[2]),o=l[3]||(f.cssNumber[i]?"":"px"),o!=="px"&&(f.style(this,i,(n||1)+o),m=(n||1)/k.cur()*m,f.style(this,i,m+o)),l[1]&&(n=(l[1]==="-="?-1:1)*n+m),k.custom(m,n,o)):k.custom(m,h,""));return!0})},stop:function(a,b){a&&this.queue([]),this.each(function(){var a=f.timers,c=a.length;b||f._unmark(!0,this);while(c--)a[c].elem===this&&(b&&a[c](!0),a.splice(c,1))}),b||this.dequeue();return this}}),f.each({slideDown:cq("show",1),slideUp:cq("hide",1),slideToggle:cq("toggle",1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(a,b){f.fn[a]=function(a,c,d){return this.animate(b,a,c,d)}}),f.extend({speed:function(a,b,c){var d=a&&typeof a=="object"?f.extend({},a):{complete:c||!c&&b||f.isFunction(a)&&a,duration:a,easing:c&&b||b&&!f.isFunction(b)&&b};d.duration=f.fx.off?0:typeof d.duration=="number"?d.duration:d.duration in f.fx.speeds?f.fx.speeds[d.duration]:f.fx.speeds._default,d.old=d.complete,d.complete=function(a){f.isFunction(d.old)&&d.old.call(this),d.queue!==!1?f.dequeue(this):a!==!1&&f._unmark(this)};return d},easing:{linear:function(a,b,c,d){return c+d*a},swing:function(a,b,c,d){return(-Math.cos(a*Math.PI)/2+.5)*d+c}},timers:[],fx:function(a,b,c){this.options=b,this.elem=a,this.prop=c,b.orig=b.orig||{}}}),f.fx.prototype={update:function(){this.options.step&&this.options.step.call(this.elem,this.now,this),(f.fx.step[this.prop]||f.fx.step._default)(this)},cur:function(){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==null))return this.elem[this.prop];var a,b=f.css(this.elem,this.prop);return isNaN(a=parseFloat(b))?!b||b==="auto"?0:b:a},custom:function(a,b,c){function g(a){return d.step(a)}var d=this,e=f.fx;this.startTime=cn||co(),this.start=a,this.end=b,this.unit=c||this.unit||(f.cssNumber[this.prop]?"":"px"),this.now=this.start,this.pos=this.state=0,g.elem=this.elem,g()&&f.timers.push(g)&&!cl&&(cl=setInterval(e.tick,e.interval))},show:function(){this.options.orig[this.prop]=f.style(this.elem,this.prop),this.options.show=!0,this.custom(this.prop==="width"||this.prop==="height"?1:0,this.cur()),f(this.elem).show()},hide:function(){this.options.orig[this.prop]=f.style(this.elem,this.prop),this.options.hide=!0,this.custom(this.cur(),0)},step:function(a){var b=cn||co(),c=!0,d=this.elem,e=this.options,g,h;if(a||b>=e.duration+this.startTime){this.now=this.end,this.pos=this.state=1,this.update(),e.animatedProperties[this.prop]=!0;for(g in e.animatedProperties)e.animatedProperties[g]!==!0&&(c=!1);if(c){e.overflow!=null&&!f.support.shrinkWrapBlocks&&f.each(["","X","Y"],function(a,b){d.style["overflow"+b]=e.overflow[a]}),e.hide&&f(d).hide();if(e.hide||e.show)for(var i in e.animatedProperties)f.style(d,i,e.orig[i]);e.complete.call(d)}return!1}e.duration==Infinity?this.now=b:(h=b-this.startTime,this.state=h/e.duration,this.pos=f.easing[e.animatedProperties[this.prop]](this.state,h,0,1,e.duration),this.now=this.start+(this.end-this.start)*this.pos),this.update();return!0}},f.extend(f.fx,{tick:function(){for(var a=f.timers,b=0;b<a.length;++b)a[b]()||a.splice(b--,1);a.length||f.fx.stop()},interval:13,stop:function(){clearInterval(cl),cl=null},speeds:{slow:600,fast:200,_default:400},step:{opacity:function(a){f.style(a.elem,"opacity",a.now)},_default:function(a){a.elem.style&&a.elem.style[a.prop]!=null?a.elem.style[a.prop]=(a.prop==="width"||a.prop==="height"?Math.max(0,a.now):a.now)+a.unit:a.elem[a.prop]=a.now}}}),f.expr&&f.expr.filters&&(f.expr.filters.animated=function(a){return f.grep(f.timers,function(b){return a===b.elem}).length});var cs=/^t(?:able|d|h)$/i,ct=/^(?:body|html)$/i;"getBoundingClientRect"in c.documentElement?f.fn.offset=function(a){var b=this[0],c;if(a)return this.each(function(b){f.offset.setOffset(this,a,b)});if(!b||!b.ownerDocument)return null;if(b===b.ownerDocument.body)return f.offset.bodyOffset(b);try{c=b.getBoundingClientRect()}catch(d){}var e=b.ownerDocument,g=e.documentElement;if(!c||!f.contains(g,b))return c?{top:c.top,left:c.left}:{top:0,left:0};var h=e.body,i=cu(e),j=g.clientTop||h.clientTop||0,k=g.clientLeft||h.clientLeft||0,l=i.pageYOffset||f.support.boxModel&&g.scrollTop||h.scrollTop,m=i.pageXOffset||f.support.boxModel&&g.scrollLeft||h.scrollLeft,n=c.top+l-j,o=c.left+m-k;return{top:n,left:o}}:f.fn.offset=function(a){var b=this[0];if(a)return this.each(function(b){f.offset.setOffset(this,a,b)});if(!b||!b.ownerDocument)return null;if(b===b.ownerDocument.body)return f.offset.bodyOffset(b);f.offset.initialize();var c,d=b.offsetParent,e=b,g=b.ownerDocument,h=g.documentElement,i=g.body,j=g.defaultView,k=j?j.getComputedStyle(b,null):b.currentStyle,l=b.offsetTop,m=b.offsetLeft;while((b=b.parentNode)&&b!==i&&b!==h){if(f.offset.supportsFixedPosition&&k.position==="fixed")break;c=j?j.getComputedStyle(b,null):b.currentStyle,l-=b.scrollTop,m-=b.scrollLeft,b===d&&(l+=b.offsetTop,m+=b.offsetLeft,f.offset.doesNotAddBorder&&(!f.offset.doesAddBorderForTableAndCells||!cs.test(b.nodeName))&&(l+=parseFloat(c.borderTopWidth)||0,m+=parseFloat(c.borderLeftWidth)||0),e=d,d=b.offsetParent),f.offset.subtractsBorderForOverflowNotVisible&&c.overflow!=="visible"&&(l+=parseFloat(c.borderTopWidth)||0,m+=parseFloat(c.borderLeftWidth)||0),k=c}if(k.position==="relative"||k.position==="static")l+=i.offsetTop,m+=i.offsetLeft;f.offset.supportsFixedPosition&&k.position==="fixed"&&(l+=Math.max(h.scrollTop,i.scrollTop),m+=Math.max(h.scrollLeft,i.scrollLeft));return{top:l,left:m}},f.offset={initialize:function(){var a=c.body,b=c.createElement("div"),d,e,g,h,i=parseFloat(f.css(a,"marginTop"))||0,j="<div style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;'><div></div></div><table style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;' cellpadding='0' cellspacing='0'><tr><td></td></tr></table>";f.extend(b.style,{position:"absolute",top:0,left:0,margin:0,border:0,width:"1px",height:"1px",visibility:"hidden"}),b.innerHTML=j,a.insertBefore(b,a.firstChild),d=b.firstChild,e=d.firstChild,h=d.nextSibling.firstChild.firstChild,this.doesNotAddBorder=e.offsetTop!==5,this.doesAddBorderForTableAndCells=h.offsetTop===5,e.style.position="fixed",e.style.top="20px",this.supportsFixedPosition=e.offsetTop===20||e.offsetTop===15,e.style.position=e.style.top="",d.style.overflow="hidden",d.style.position="relative",this.subtractsBorderForOverflowNotVisible=e.offsetTop===-5,this.doesNotIncludeMarginInBodyOffset=a.offsetTop!==i,a.removeChild(b),f.offset.initialize=f.noop},bodyOffset:function(a){var b=a.offsetTop,c=a.offsetLeft;f.offset.initialize(),f.offset.doesNotIncludeMarginInBodyOffset&&(b+=parseFloat(f.css(a,"marginTop"))||0,c+=parseFloat(f.css(a,"marginLeft"))||0);return{top:b,left:c}},setOffset:function(a,b,c){var d=f.css(a,"position");d==="static"&&(a.style.position="relative");var e=f(a),g=e.offset(),h=f.css(a,"top"),i=f.css(a,"left"),j=(d==="absolute"||d==="fixed")&&f.inArray("auto",[h,i])>-1,k={},l={},m,n;j?(l=e.position(),m=l.top,n=l.left):(m=parseFloat(h)||0,n=parseFloat(i)||0),f.isFunction(b)&&(b=b.call(a,c,g)),b.top!=null&&(k.top=b.top-g.top+m),b.left!=null&&(k.left=b.left-g.left+n),"using"in b?b.using.call(a,k):e.css(k)}},f.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),c=this.offset(),d=ct.test(b[0].nodeName)?{top:0,left:0}:b.offset();c.top-=parseFloat(f.css(a,"marginTop"))||0,c.left-=parseFloat(f.css(a,"marginLeft"))||0,d.top+=parseFloat(f.css(b[0],"borderTopWidth"))||0,d.left+=parseFloat(f.css(b[0],"borderLeftWidth"))||0;return{top:c.top-d.top,left:c.left-d.left}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||c.body;while(a&&!ct.test(a.nodeName)&&f.css(a,"position")==="static")a=a.offsetParent;return a})}}),f.each(["Left","Top"],function(a,c){var d="scroll"+c;f.fn[d]=function(c){var e,g;if(c===b){e=this[0];if(!e)return null;g=cu(e);return g?"pageXOffset"in g?g[a?"pageYOffset":"pageXOffset"]:f.support.boxModel&&g.document.documentElement[d]||g.document.body[d]:e[d]}return this.each(function(){g=cu(this),g?g.scrollTo(a?f(g).scrollLeft():c,a?c:f(g).scrollTop()):this[d]=c})}}),f.each(["Height","Width"],function(a,c){var d=c.toLowerCase();f.fn["inner"+c]=function(){var a=this[0];return a&&a.style?parseFloat(f.css(a,d,"padding")):null},f.fn["outer"+c]=function(a){var b=this[0];return b&&b.style?parseFloat(f.css(b,d,a?"margin":"border")):null},f.fn[d]=function(a){var e=this[0];if(!e)return a==null?null:this;if(f.isFunction(a))return this.each(function(b){var c=f(this);c[d](a.call(this,b,c[d]()))});if(f.isWindow(e)){var g=e.document.documentElement["client"+c],h=e.document.body;return e.document.compatMode==="CSS1Compat"&&g||h&&h["client"+c]||g}if(e.nodeType===9)return Math.max(e.documentElement["client"+c],e.body["scroll"+c],e.documentElement["scroll"+c],e.body["offset"+c],e.documentElement["offset"+c]);if(a===b){var i=f.css(e,d),j=parseFloat(i);return f.isNaN(j)?i:j}return this.css(d,typeof a=="string"?a:a+"px")}}),a.jQuery=a.$=f})(window);
|
@@ -0,0 +1,4566 @@
|
|
1
|
+
/*
|
2
|
+
* NinjaScript - 0.9
|
3
|
+
* written by and copyright 2010-2011 Judson Lester and Logical Reality Design
|
4
|
+
* Licensed under the MIT license
|
5
|
+
*
|
6
|
+
* 06-29-2011
|
7
|
+
*/
|
8
|
+
/** vim: et:ts=4:sw=4:sts=4
|
9
|
+
* @license RequireJS 0.24.0 Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
|
10
|
+
* Available via the MIT or new BSD license.
|
11
|
+
* see: http://github.com/jrburke/requirejs for details
|
12
|
+
*/
|
13
|
+
/*jslint strict: false, plusplus: false */
|
14
|
+
/*global window: false, navigator: false, document: false, importScripts: false,
|
15
|
+
jQuery: false, clearInterval: false, setInterval: false, self: false,
|
16
|
+
setTimeout: false, opera: false */
|
17
|
+
|
18
|
+
var require, define;
|
19
|
+
(function () {
|
20
|
+
//Change this version number for each release.
|
21
|
+
var version = "0.24.0",
|
22
|
+
commentRegExp = /(\/\*([\s\S]*?)\*\/|\/\/(.*)$)/mg,
|
23
|
+
cjsRequireRegExp = /require\(["']([^'"\s]+)["']\)/g,
|
24
|
+
currDirRegExp = /^\.\//,
|
25
|
+
jsSuffixRegExp = /\.js$/,
|
26
|
+
ostring = Object.prototype.toString,
|
27
|
+
ap = Array.prototype,
|
28
|
+
aps = ap.slice,
|
29
|
+
apsp = ap.splice,
|
30
|
+
isBrowser = !!(typeof window !== "undefined" && navigator && document),
|
31
|
+
isWebWorker = !isBrowser && typeof importScripts !== "undefined",
|
32
|
+
//PS3 indicates loaded and complete, but need to wait for complete
|
33
|
+
//specifically. Sequence is "loading", "loaded", execution,
|
34
|
+
// then "complete". The UA check is unfortunate, but not sure how
|
35
|
+
//to feature test w/o causing perf issues.
|
36
|
+
readyRegExp = isBrowser && navigator.platform === 'PLAYSTATION 3' ?
|
37
|
+
/^complete$/ : /^(complete|loaded)$/,
|
38
|
+
defContextName = "_",
|
39
|
+
//Oh the tragedy, detecting opera. See the usage of isOpera for reason.
|
40
|
+
isOpera = typeof opera !== "undefined" && opera.toString() === "[object Opera]",
|
41
|
+
reqWaitIdPrefix = "_r@@",
|
42
|
+
empty = {},
|
43
|
+
contexts = {},
|
44
|
+
globalDefQueue = [],
|
45
|
+
interactiveScript = null,
|
46
|
+
isDone = false,
|
47
|
+
useInteractive = false,
|
48
|
+
req, cfg = {}, currentlyAddingScript, s, head, baseElement, scripts, script,
|
49
|
+
src, subPath, mainScript, dataMain, i, scrollIntervalId, setReadyState, ctx;
|
50
|
+
|
51
|
+
function isFunction(it) {
|
52
|
+
return ostring.call(it) === "[object Function]";
|
53
|
+
}
|
54
|
+
|
55
|
+
function isArray(it) {
|
56
|
+
return ostring.call(it) === "[object Array]";
|
57
|
+
}
|
58
|
+
|
59
|
+
/**
|
60
|
+
* Simple function to mix in properties from source into target,
|
61
|
+
* but only if target does not already have a property of the same name.
|
62
|
+
* This is not robust in IE for transferring methods that match
|
63
|
+
* Object.prototype names, but the uses of mixin here seem unlikely to
|
64
|
+
* trigger a problem related to that.
|
65
|
+
*/
|
66
|
+
function mixin(target, source, force) {
|
67
|
+
for (var prop in source) {
|
68
|
+
if (!(prop in empty) && (!(prop in target) || force)) {
|
69
|
+
target[prop] = source[prop];
|
70
|
+
}
|
71
|
+
}
|
72
|
+
return req;
|
73
|
+
}
|
74
|
+
|
75
|
+
/**
|
76
|
+
* Used to set up package paths from a packagePaths or packages config object.
|
77
|
+
* @param {Object} pkgs the object to store the new package config
|
78
|
+
* @param {Array} currentPackages an array of packages to configure
|
79
|
+
* @param {String} [dir] a prefix dir to use.
|
80
|
+
*/
|
81
|
+
function configurePackageDir(pkgs, currentPackages, dir) {
|
82
|
+
var i, location, pkgObj;
|
83
|
+
|
84
|
+
for (i = 0; (pkgObj = currentPackages[i]); i++) {
|
85
|
+
pkgObj = typeof pkgObj === "string" ? { name: pkgObj } : pkgObj;
|
86
|
+
location = pkgObj.location;
|
87
|
+
|
88
|
+
//Add dir to the path, but avoid paths that start with a slash
|
89
|
+
//or have a colon (indicates a protocol)
|
90
|
+
if (dir && (!location || (location.indexOf("/") !== 0 && location.indexOf(":") === -1))) {
|
91
|
+
location = dir + "/" + (location || pkgObj.name);
|
92
|
+
}
|
93
|
+
|
94
|
+
//Create a brand new object on pkgs, since currentPackages can
|
95
|
+
//be passed in again, and config.pkgs is the internal transformed
|
96
|
+
//state for all package configs.
|
97
|
+
pkgs[pkgObj.name] = {
|
98
|
+
name: pkgObj.name,
|
99
|
+
location: location || pkgObj.name,
|
100
|
+
lib: pkgObj.lib || "lib",
|
101
|
+
//Remove leading dot in main, so main paths are normalized,
|
102
|
+
//and remove any trailing .js, since different package
|
103
|
+
//envs have different conventions: some use a module name,
|
104
|
+
//some use a file name.
|
105
|
+
main: (pkgObj.main || "lib/main")
|
106
|
+
.replace(currDirRegExp, '')
|
107
|
+
.replace(jsSuffixRegExp, '')
|
108
|
+
};
|
109
|
+
}
|
110
|
+
}
|
111
|
+
|
112
|
+
//Check for an existing version of require. If so, then exit out. Only allow
|
113
|
+
//one version of require to be active in a page. However, allow for a require
|
114
|
+
//config object, just exit quickly if require is an actual function.
|
115
|
+
if (typeof require !== "undefined") {
|
116
|
+
if (isFunction(require)) {
|
117
|
+
return;
|
118
|
+
} else {
|
119
|
+
//assume it is a config object.
|
120
|
+
cfg = require;
|
121
|
+
}
|
122
|
+
}
|
123
|
+
|
124
|
+
/**
|
125
|
+
* Creates a new context for use in require and define calls.
|
126
|
+
* Handle most of the heavy lifting. Do not want to use an object
|
127
|
+
* with prototype here to avoid using "this" in require, in case it
|
128
|
+
* needs to be used in more super secure envs that do not want this.
|
129
|
+
* Also there should not be that many contexts in the page. Usually just
|
130
|
+
* one for the default context, but could be extra for multiversion cases
|
131
|
+
* or if a package needs a special context for a dependency that conflicts
|
132
|
+
* with the standard context.
|
133
|
+
*/
|
134
|
+
function newContext(contextName) {
|
135
|
+
var context, resume,
|
136
|
+
config = {
|
137
|
+
waitSeconds: 7,
|
138
|
+
baseUrl: s.baseUrl || "./",
|
139
|
+
paths: {},
|
140
|
+
pkgs: {}
|
141
|
+
},
|
142
|
+
defQueue = [],
|
143
|
+
specified = {
|
144
|
+
"require": true,
|
145
|
+
"exports": true,
|
146
|
+
"module": true
|
147
|
+
},
|
148
|
+
urlMap = {},
|
149
|
+
defined = {},
|
150
|
+
loaded = {},
|
151
|
+
waiting = {},
|
152
|
+
waitAry = [],
|
153
|
+
waitIdCounter = 0,
|
154
|
+
managerCallbacks = {},
|
155
|
+
plugins = {},
|
156
|
+
pluginsQueue = {},
|
157
|
+
resumeDepth = 0,
|
158
|
+
normalizedWaiting = {};
|
159
|
+
|
160
|
+
/**
|
161
|
+
* Trims the . and .. from an array of path segments.
|
162
|
+
* It will keep a leading path segment if a .. will become
|
163
|
+
* the first path segment, to help with module name lookups,
|
164
|
+
* which act like paths, but can be remapped. But the end result,
|
165
|
+
* all paths that use this function should look normalized.
|
166
|
+
* NOTE: this method MODIFIES the input array.
|
167
|
+
* @param {Array} ary the array of path segments.
|
168
|
+
*/
|
169
|
+
function trimDots(ary) {
|
170
|
+
var i, part;
|
171
|
+
for (i = 0; (part = ary[i]); i++) {
|
172
|
+
if (part === ".") {
|
173
|
+
ary.splice(i, 1);
|
174
|
+
i -= 1;
|
175
|
+
} else if (part === "..") {
|
176
|
+
if (i === 1 && (ary[2] === '..' || ary[0] === '..')) {
|
177
|
+
//End of the line. Keep at least one non-dot
|
178
|
+
//path segment at the front so it can be mapped
|
179
|
+
//correctly to disk. Otherwise, there is likely
|
180
|
+
//no path mapping for a path starting with '..'.
|
181
|
+
//This can still fail, but catches the most reasonable
|
182
|
+
//uses of ..
|
183
|
+
break;
|
184
|
+
} else if (i > 0) {
|
185
|
+
ary.splice(i - 1, 2);
|
186
|
+
i -= 2;
|
187
|
+
}
|
188
|
+
}
|
189
|
+
}
|
190
|
+
}
|
191
|
+
|
192
|
+
/**
|
193
|
+
* Given a relative module name, like ./something, normalize it to
|
194
|
+
* a real name that can be mapped to a path.
|
195
|
+
* @param {String} name the relative name
|
196
|
+
* @param {String} baseName a real name that the name arg is relative
|
197
|
+
* to.
|
198
|
+
* @returns {String} normalized name
|
199
|
+
*/
|
200
|
+
function normalize(name, baseName) {
|
201
|
+
var pkgName, pkgConfig;
|
202
|
+
|
203
|
+
//Adjust any relative paths.
|
204
|
+
if (name.charAt(0) === ".") {
|
205
|
+
//If have a base name, try to normalize against it,
|
206
|
+
//otherwise, assume it is a top-level require that will
|
207
|
+
//be relative to baseUrl in the end.
|
208
|
+
if (baseName) {
|
209
|
+
if (config.pkgs[baseName]) {
|
210
|
+
//If the baseName is a package name, then just treat it as one
|
211
|
+
//name to concat the name with.
|
212
|
+
baseName = [baseName];
|
213
|
+
} else {
|
214
|
+
//Convert baseName to array, and lop off the last part,
|
215
|
+
//so that . matches that "directory" and not name of the baseName's
|
216
|
+
//module. For instance, baseName of "one/two/three", maps to
|
217
|
+
//"one/two/three.js", but we want the directory, "one/two" for
|
218
|
+
//this normalization.
|
219
|
+
baseName = baseName.split("/");
|
220
|
+
baseName = baseName.slice(0, baseName.length - 1);
|
221
|
+
}
|
222
|
+
|
223
|
+
name = baseName.concat(name.split("/"));
|
224
|
+
trimDots(name);
|
225
|
+
|
226
|
+
//Some use of packages may use a . path to reference the
|
227
|
+
//"main" module name, so normalize for that.
|
228
|
+
pkgConfig = config.pkgs[(pkgName = name[0])];
|
229
|
+
name = name.join("/");
|
230
|
+
if (pkgConfig && name === pkgName + '/' + pkgConfig.main) {
|
231
|
+
name = pkgName;
|
232
|
+
}
|
233
|
+
}
|
234
|
+
}
|
235
|
+
return name;
|
236
|
+
}
|
237
|
+
|
238
|
+
/**
|
239
|
+
* Creates a module mapping that includes plugin prefix, module
|
240
|
+
* name, and path. If parentModuleMap is provided it will
|
241
|
+
* also normalize the name via require.normalize()
|
242
|
+
*
|
243
|
+
* @param {String} name the module name
|
244
|
+
* @param {String} [parentModuleMap] parent module map
|
245
|
+
* for the module name, used to resolve relative names.
|
246
|
+
*
|
247
|
+
* @returns {Object}
|
248
|
+
*/
|
249
|
+
function makeModuleMap(name, parentModuleMap) {
|
250
|
+
var index = name ? name.indexOf("!") : -1,
|
251
|
+
prefix = null,
|
252
|
+
parentName = parentModuleMap ? parentModuleMap.name : null,
|
253
|
+
originalName = name,
|
254
|
+
normalizedName, url, pluginModule;
|
255
|
+
|
256
|
+
if (index !== -1) {
|
257
|
+
prefix = name.substring(0, index);
|
258
|
+
name = name.substring(index + 1, name.length);
|
259
|
+
}
|
260
|
+
|
261
|
+
if (prefix) {
|
262
|
+
prefix = normalize(prefix, parentName);
|
263
|
+
}
|
264
|
+
|
265
|
+
//Account for relative paths if there is a base name.
|
266
|
+
if (name) {
|
267
|
+
if (prefix) {
|
268
|
+
pluginModule = defined[prefix];
|
269
|
+
if (pluginModule) {
|
270
|
+
//Plugin is loaded, use its normalize method, otherwise,
|
271
|
+
//normalize name as usual.
|
272
|
+
if (pluginModule.normalize) {
|
273
|
+
normalizedName = pluginModule.normalize(name, function (name) {
|
274
|
+
return normalize(name, parentName);
|
275
|
+
});
|
276
|
+
} else {
|
277
|
+
normalizedName = normalize(name, parentName);
|
278
|
+
}
|
279
|
+
} else {
|
280
|
+
//Plugin is not loaded yet, so do not normalize
|
281
|
+
//the name, wait for plugin to load to see if
|
282
|
+
//it has a normalize method. To avoid possible
|
283
|
+
//ambiguity with relative names loaded from another
|
284
|
+
//plugin, use the parent's name as part of this name.
|
285
|
+
normalizedName = '__$p' + parentName + '@' + name;
|
286
|
+
}
|
287
|
+
} else {
|
288
|
+
normalizedName = normalize(name, parentName);
|
289
|
+
}
|
290
|
+
|
291
|
+
url = urlMap[normalizedName];
|
292
|
+
if (!url) {
|
293
|
+
//Calculate url for the module, if it has a name.
|
294
|
+
if (req.toModuleUrl) {
|
295
|
+
//Special logic required for a particular engine,
|
296
|
+
//like Node.
|
297
|
+
url = req.toModuleUrl(context, name, parentModuleMap);
|
298
|
+
} else {
|
299
|
+
url = context.nameToUrl(name, null, parentModuleMap);
|
300
|
+
}
|
301
|
+
|
302
|
+
//Store the URL mapping for later.
|
303
|
+
urlMap[normalizedName] = url;
|
304
|
+
}
|
305
|
+
}
|
306
|
+
|
307
|
+
return {
|
308
|
+
prefix: prefix,
|
309
|
+
name: normalizedName,
|
310
|
+
parentMap: parentModuleMap,
|
311
|
+
url: url,
|
312
|
+
originalName: originalName,
|
313
|
+
fullName: prefix ? prefix + "!" + normalizedName : normalizedName
|
314
|
+
};
|
315
|
+
}
|
316
|
+
|
317
|
+
/**
|
318
|
+
* Determine if priority loading is done. If so clear the priorityWait
|
319
|
+
*/
|
320
|
+
function isPriorityDone() {
|
321
|
+
var priorityDone = true,
|
322
|
+
priorityWait = config.priorityWait,
|
323
|
+
priorityName, i;
|
324
|
+
if (priorityWait) {
|
325
|
+
for (i = 0; (priorityName = priorityWait[i]); i++) {
|
326
|
+
if (!loaded[priorityName]) {
|
327
|
+
priorityDone = false;
|
328
|
+
break;
|
329
|
+
}
|
330
|
+
}
|
331
|
+
if (priorityDone) {
|
332
|
+
delete config.priorityWait;
|
333
|
+
}
|
334
|
+
}
|
335
|
+
return priorityDone;
|
336
|
+
}
|
337
|
+
|
338
|
+
/**
|
339
|
+
* Helper function that creates a setExports function for a "module"
|
340
|
+
* CommonJS dependency. Do this here to avoid creating a closure that
|
341
|
+
* is part of a loop.
|
342
|
+
*/
|
343
|
+
function makeSetExports(moduleObj) {
|
344
|
+
return function (exports) {
|
345
|
+
moduleObj.exports = exports;
|
346
|
+
};
|
347
|
+
}
|
348
|
+
|
349
|
+
function makeContextModuleFunc(func, relModuleMap, enableBuildCallback) {
|
350
|
+
return function () {
|
351
|
+
//A version of a require function that passes a moduleName
|
352
|
+
//value for items that may need to
|
353
|
+
//look up paths relative to the moduleName
|
354
|
+
var args = [].concat(aps.call(arguments, 0)), lastArg;
|
355
|
+
if (enableBuildCallback &&
|
356
|
+
isFunction((lastArg = args[args.length - 1]))) {
|
357
|
+
lastArg.__requireJsBuild = true;
|
358
|
+
}
|
359
|
+
args.push(relModuleMap);
|
360
|
+
return func.apply(null, args);
|
361
|
+
};
|
362
|
+
}
|
363
|
+
|
364
|
+
/**
|
365
|
+
* Helper function that creates a require function object to give to
|
366
|
+
* modules that ask for it as a dependency. It needs to be specific
|
367
|
+
* per module because of the implication of path mappings that may
|
368
|
+
* need to be relative to the module name.
|
369
|
+
*/
|
370
|
+
function makeRequire(relModuleMap, enableBuildCallback) {
|
371
|
+
var modRequire = makeContextModuleFunc(context.require, relModuleMap, enableBuildCallback);
|
372
|
+
|
373
|
+
mixin(modRequire, {
|
374
|
+
nameToUrl: makeContextModuleFunc(context.nameToUrl, relModuleMap),
|
375
|
+
toUrl: makeContextModuleFunc(context.toUrl, relModuleMap),
|
376
|
+
isDefined: makeContextModuleFunc(context.isDefined, relModuleMap),
|
377
|
+
ready: req.ready,
|
378
|
+
isBrowser: req.isBrowser
|
379
|
+
});
|
380
|
+
//Something used by node.
|
381
|
+
if (req.paths) {
|
382
|
+
modRequire.paths = req.paths;
|
383
|
+
}
|
384
|
+
return modRequire;
|
385
|
+
}
|
386
|
+
|
387
|
+
/**
|
388
|
+
* Used to update the normalized name for plugin-based dependencies
|
389
|
+
* after a plugin loads, since it can have its own normalization structure.
|
390
|
+
* @param {String} pluginName the normalized plugin module name.
|
391
|
+
*/
|
392
|
+
function updateNormalizedNames(pluginName) {
|
393
|
+
|
394
|
+
var oldFullName, oldModuleMap, moduleMap, fullName, callbacks,
|
395
|
+
i, j, k, depArray, existingCallbacks,
|
396
|
+
maps = normalizedWaiting[pluginName];
|
397
|
+
|
398
|
+
if (maps) {
|
399
|
+
for (i = 0; (oldModuleMap = maps[i]); i++) {
|
400
|
+
oldFullName = oldModuleMap.fullName;
|
401
|
+
moduleMap = makeModuleMap(oldModuleMap.originalName, oldModuleMap.parentMap);
|
402
|
+
fullName = moduleMap.fullName;
|
403
|
+
//Callbacks could be undefined if the same plugin!name was
|
404
|
+
//required twice in a row, so use empty array in that case.
|
405
|
+
callbacks = managerCallbacks[oldFullName] || [];
|
406
|
+
existingCallbacks = managerCallbacks[fullName];
|
407
|
+
|
408
|
+
if (fullName !== oldFullName) {
|
409
|
+
//Update the specified object, but only if it is already
|
410
|
+
//in there. In sync environments, it may not be yet.
|
411
|
+
if (oldFullName in specified) {
|
412
|
+
delete specified[oldFullName];
|
413
|
+
specified[fullName] = true;
|
414
|
+
}
|
415
|
+
|
416
|
+
//Update managerCallbacks to use the correct normalized name.
|
417
|
+
//If there are already callbacks for the normalized name,
|
418
|
+
//just add to them.
|
419
|
+
if (existingCallbacks) {
|
420
|
+
managerCallbacks[fullName] = existingCallbacks.concat(callbacks);
|
421
|
+
} else {
|
422
|
+
managerCallbacks[fullName] = callbacks;
|
423
|
+
}
|
424
|
+
delete managerCallbacks[oldFullName];
|
425
|
+
|
426
|
+
//In each manager callback, update the normalized name in the depArray.
|
427
|
+
for (j = 0; j < callbacks.length; j++) {
|
428
|
+
depArray = callbacks[j].depArray;
|
429
|
+
for (k = 0; k < depArray.length; k++) {
|
430
|
+
if (depArray[k] === oldFullName) {
|
431
|
+
depArray[k] = fullName;
|
432
|
+
}
|
433
|
+
}
|
434
|
+
}
|
435
|
+
}
|
436
|
+
}
|
437
|
+
}
|
438
|
+
|
439
|
+
delete normalizedWaiting[pluginName];
|
440
|
+
}
|
441
|
+
|
442
|
+
/*
|
443
|
+
* Queues a dependency for checking after the loader is out of a
|
444
|
+
* "paused" state, for example while a script file is being loaded
|
445
|
+
* in the browser, where it may have many modules defined in it.
|
446
|
+
*
|
447
|
+
* depName will be fully qualified, no relative . or .. path.
|
448
|
+
*/
|
449
|
+
function queueDependency(dep) {
|
450
|
+
//Make sure to load any plugin and associate the dependency
|
451
|
+
//with that plugin.
|
452
|
+
var prefix = dep.prefix,
|
453
|
+
fullName = dep.fullName;
|
454
|
+
|
455
|
+
//Do not bother if the depName is already in transit
|
456
|
+
if (specified[fullName] || fullName in defined) {
|
457
|
+
return;
|
458
|
+
}
|
459
|
+
|
460
|
+
if (prefix && !plugins[prefix]) {
|
461
|
+
//Queue up loading of the dependency, track it
|
462
|
+
//via context.plugins. Mark it as a plugin so
|
463
|
+
//that the build system will know to treat it
|
464
|
+
//special.
|
465
|
+
plugins[prefix] = undefined;
|
466
|
+
|
467
|
+
//Remember this dep that needs to have normaliztion done
|
468
|
+
//after the plugin loads.
|
469
|
+
(normalizedWaiting[prefix] || (normalizedWaiting[prefix] = []))
|
470
|
+
.push(dep);
|
471
|
+
|
472
|
+
//Register an action to do once the plugin loads, to update
|
473
|
+
//all managerCallbacks to use a properly normalized module
|
474
|
+
//name.
|
475
|
+
(managerCallbacks[prefix] ||
|
476
|
+
(managerCallbacks[prefix] = [])).push({
|
477
|
+
onDep: function (name, value) {
|
478
|
+
if (name === prefix) {
|
479
|
+
updateNormalizedNames(prefix);
|
480
|
+
}
|
481
|
+
}
|
482
|
+
});
|
483
|
+
|
484
|
+
queueDependency(makeModuleMap(prefix));
|
485
|
+
}
|
486
|
+
|
487
|
+
context.paused.push(dep);
|
488
|
+
}
|
489
|
+
|
490
|
+
function execManager(manager) {
|
491
|
+
var i, ret, waitingCallbacks,
|
492
|
+
cb = manager.callback,
|
493
|
+
fullName = manager.fullName,
|
494
|
+
args = [],
|
495
|
+
ary = manager.depArray;
|
496
|
+
|
497
|
+
//Call the callback to define the module, if necessary.
|
498
|
+
if (cb && isFunction(cb)) {
|
499
|
+
//Pull out the defined dependencies and pass the ordered
|
500
|
+
//values to the callback.
|
501
|
+
if (ary) {
|
502
|
+
for (i = 0; i < ary.length; i++) {
|
503
|
+
args.push(manager.deps[ary[i]]);
|
504
|
+
}
|
505
|
+
}
|
506
|
+
|
507
|
+
ret = req.execCb(fullName, manager.callback, args);
|
508
|
+
|
509
|
+
if (fullName) {
|
510
|
+
//If using exports and the function did not return a value,
|
511
|
+
//and the "module" object for this definition function did not
|
512
|
+
//define an exported value, then use the exports object.
|
513
|
+
if (manager.usingExports && ret === undefined && (!manager.cjsModule || !("exports" in manager.cjsModule))) {
|
514
|
+
ret = defined[fullName];
|
515
|
+
} else {
|
516
|
+
if (manager.cjsModule && "exports" in manager.cjsModule) {
|
517
|
+
ret = defined[fullName] = manager.cjsModule.exports;
|
518
|
+
} else {
|
519
|
+
if (fullName in defined && !manager.usingExports) {
|
520
|
+
return req.onError(new Error(fullName + " has already been defined"));
|
521
|
+
}
|
522
|
+
defined[fullName] = ret;
|
523
|
+
}
|
524
|
+
}
|
525
|
+
}
|
526
|
+
} else if (fullName) {
|
527
|
+
//May just be an object definition for the module. Only
|
528
|
+
//worry about defining if have a module name.
|
529
|
+
ret = defined[fullName] = cb;
|
530
|
+
}
|
531
|
+
|
532
|
+
if (fullName) {
|
533
|
+
//If anything was waiting for this module to be defined,
|
534
|
+
//notify them now.
|
535
|
+
waitingCallbacks = managerCallbacks[fullName];
|
536
|
+
if (waitingCallbacks) {
|
537
|
+
for (i = 0; i < waitingCallbacks.length; i++) {
|
538
|
+
waitingCallbacks[i].onDep(fullName, ret);
|
539
|
+
}
|
540
|
+
delete managerCallbacks[fullName];
|
541
|
+
}
|
542
|
+
}
|
543
|
+
|
544
|
+
//Clean up waiting.
|
545
|
+
if (waiting[manager.waitId]) {
|
546
|
+
delete waiting[manager.waitId];
|
547
|
+
manager.isDone = true;
|
548
|
+
context.waitCount -= 1;
|
549
|
+
if (context.waitCount === 0) {
|
550
|
+
//Clear the wait array used for cycles.
|
551
|
+
waitAry = [];
|
552
|
+
}
|
553
|
+
}
|
554
|
+
|
555
|
+
return undefined;
|
556
|
+
}
|
557
|
+
|
558
|
+
function main(inName, depArray, callback, relModuleMap) {
|
559
|
+
var moduleMap = makeModuleMap(inName, relModuleMap),
|
560
|
+
name = moduleMap.name,
|
561
|
+
fullName = moduleMap.fullName,
|
562
|
+
uniques = {},
|
563
|
+
manager = {
|
564
|
+
//Use a wait ID because some entries are anon
|
565
|
+
//async require calls.
|
566
|
+
waitId: name || reqWaitIdPrefix + (waitIdCounter++),
|
567
|
+
depCount: 0,
|
568
|
+
depMax: 0,
|
569
|
+
prefix: moduleMap.prefix,
|
570
|
+
name: name,
|
571
|
+
fullName: fullName,
|
572
|
+
deps: {},
|
573
|
+
depArray: depArray,
|
574
|
+
callback: callback,
|
575
|
+
onDep: function (depName, value) {
|
576
|
+
if (!(depName in manager.deps)) {
|
577
|
+
manager.deps[depName] = value;
|
578
|
+
manager.depCount += 1;
|
579
|
+
if (manager.depCount === manager.depMax) {
|
580
|
+
//All done, execute!
|
581
|
+
execManager(manager);
|
582
|
+
}
|
583
|
+
}
|
584
|
+
}
|
585
|
+
},
|
586
|
+
i, depArg, depName, cjsMod;
|
587
|
+
|
588
|
+
if (fullName) {
|
589
|
+
//If module already defined for context, or already loaded,
|
590
|
+
//then leave.
|
591
|
+
if (fullName in defined || loaded[fullName] === true) {
|
592
|
+
return;
|
593
|
+
}
|
594
|
+
|
595
|
+
//Set specified/loaded here for modules that are also loaded
|
596
|
+
//as part of a layer, where onScriptLoad is not fired
|
597
|
+
//for those cases. Do this after the inline define and
|
598
|
+
//dependency tracing is done.
|
599
|
+
//Also check if auto-registry of jQuery needs to be skipped.
|
600
|
+
specified[fullName] = true;
|
601
|
+
loaded[fullName] = true;
|
602
|
+
context.jQueryDef = (fullName === "jquery");
|
603
|
+
}
|
604
|
+
|
605
|
+
//Add the dependencies to the deps field, and register for callbacks
|
606
|
+
//on the dependencies.
|
607
|
+
for (i = 0; i < depArray.length; i++) {
|
608
|
+
depArg = depArray[i];
|
609
|
+
//There could be cases like in IE, where a trailing comma will
|
610
|
+
//introduce a null dependency, so only treat a real dependency
|
611
|
+
//value as a dependency.
|
612
|
+
if (depArg) {
|
613
|
+
//Split the dependency name into plugin and name parts
|
614
|
+
depArg = makeModuleMap(depArg, (name ? moduleMap : relModuleMap));
|
615
|
+
depName = depArg.fullName;
|
616
|
+
|
617
|
+
//Fix the name in depArray to be just the name, since
|
618
|
+
//that is how it will be called back later.
|
619
|
+
depArray[i] = depName;
|
620
|
+
|
621
|
+
//Fast path CommonJS standard dependencies.
|
622
|
+
if (depName === "require") {
|
623
|
+
manager.deps[depName] = makeRequire(moduleMap);
|
624
|
+
} else if (depName === "exports") {
|
625
|
+
//CommonJS module spec 1.1
|
626
|
+
manager.deps[depName] = defined[fullName] = {};
|
627
|
+
manager.usingExports = true;
|
628
|
+
} else if (depName === "module") {
|
629
|
+
//CommonJS module spec 1.1
|
630
|
+
manager.cjsModule = cjsMod = manager.deps[depName] = {
|
631
|
+
id: name,
|
632
|
+
uri: name ? context.nameToUrl(name, null, relModuleMap) : undefined
|
633
|
+
};
|
634
|
+
cjsMod.setExports = makeSetExports(cjsMod);
|
635
|
+
} else if (depName in defined && !(depName in waiting)) {
|
636
|
+
//Module already defined, no need to wait for it.
|
637
|
+
manager.deps[depName] = defined[depName];
|
638
|
+
} else if (!uniques[depName]) {
|
639
|
+
|
640
|
+
//A dynamic dependency.
|
641
|
+
manager.depMax += 1;
|
642
|
+
|
643
|
+
queueDependency(depArg);
|
644
|
+
|
645
|
+
//Register to get notification when dependency loads.
|
646
|
+
(managerCallbacks[depName] ||
|
647
|
+
(managerCallbacks[depName] = [])).push(manager);
|
648
|
+
|
649
|
+
uniques[depName] = true;
|
650
|
+
}
|
651
|
+
}
|
652
|
+
}
|
653
|
+
|
654
|
+
//Do not bother tracking the manager if it is all done.
|
655
|
+
if (manager.depCount === manager.depMax) {
|
656
|
+
//All done, execute!
|
657
|
+
execManager(manager);
|
658
|
+
} else {
|
659
|
+
waiting[manager.waitId] = manager;
|
660
|
+
waitAry.push(manager);
|
661
|
+
context.waitCount += 1;
|
662
|
+
}
|
663
|
+
}
|
664
|
+
|
665
|
+
/**
|
666
|
+
* Convenience method to call main for a require.def call that was put on
|
667
|
+
* hold in the defQueue.
|
668
|
+
*/
|
669
|
+
function callDefMain(args) {
|
670
|
+
main.apply(null, args);
|
671
|
+
//Mark the module loaded. Must do it here in addition
|
672
|
+
//to doing it in require.def in case a script does
|
673
|
+
//not call require.def
|
674
|
+
loaded[args[0]] = true;
|
675
|
+
}
|
676
|
+
|
677
|
+
/**
|
678
|
+
* As of jQuery 1.4.3, it supports a readyWait property that will hold off
|
679
|
+
* calling jQuery ready callbacks until all scripts are loaded. Be sure
|
680
|
+
* to track it if readyWait is available. Also, since jQuery 1.4.3 does
|
681
|
+
* not register as a module, need to do some global inference checking.
|
682
|
+
* Even if it does register as a module, not guaranteed to be the precise
|
683
|
+
* name of the global. If a jQuery is tracked for this context, then go
|
684
|
+
* ahead and register it as a module too, if not already in process.
|
685
|
+
*/
|
686
|
+
function jQueryCheck(jqCandidate) {
|
687
|
+
if (!context.jQuery) {
|
688
|
+
var $ = jqCandidate || (typeof jQuery !== "undefined" ? jQuery : null);
|
689
|
+
if ($ && "readyWait" in $) {
|
690
|
+
context.jQuery = $;
|
691
|
+
|
692
|
+
//Manually create a "jquery" module entry if not one already
|
693
|
+
//or in process.
|
694
|
+
callDefMain(["jquery", [], function () {
|
695
|
+
return jQuery;
|
696
|
+
}]);
|
697
|
+
|
698
|
+
//Increment jQuery readyWait if ncecessary.
|
699
|
+
if (context.scriptCount) {
|
700
|
+
$.readyWait += 1;
|
701
|
+
context.jQueryIncremented = true;
|
702
|
+
}
|
703
|
+
}
|
704
|
+
}
|
705
|
+
}
|
706
|
+
|
707
|
+
function forceExec(manager, traced) {
|
708
|
+
if (manager.isDone) {
|
709
|
+
return undefined;
|
710
|
+
}
|
711
|
+
|
712
|
+
var fullName = manager.fullName,
|
713
|
+
depArray = manager.depArray,
|
714
|
+
depName, i;
|
715
|
+
if (fullName) {
|
716
|
+
if (traced[fullName]) {
|
717
|
+
return defined[fullName];
|
718
|
+
}
|
719
|
+
|
720
|
+
traced[fullName] = true;
|
721
|
+
}
|
722
|
+
|
723
|
+
//forceExec all of its dependencies.
|
724
|
+
for (i = 0; i < depArray.length; i++) {
|
725
|
+
//Some array members may be null, like if a trailing comma
|
726
|
+
//IE, so do the explicit [i] access and check if it has a value.
|
727
|
+
depName = depArray[i];
|
728
|
+
if (depName) {
|
729
|
+
if (!manager.deps[depName] && waiting[depName]) {
|
730
|
+
manager.onDep(depName, forceExec(waiting[depName], traced));
|
731
|
+
}
|
732
|
+
}
|
733
|
+
}
|
734
|
+
|
735
|
+
return fullName ? defined[fullName] : undefined;
|
736
|
+
}
|
737
|
+
|
738
|
+
/**
|
739
|
+
* Checks if all modules for a context are loaded, and if so, evaluates the
|
740
|
+
* new ones in right dependency order.
|
741
|
+
*
|
742
|
+
* @private
|
743
|
+
*/
|
744
|
+
function checkLoaded() {
|
745
|
+
var waitInterval = config.waitSeconds * 1000,
|
746
|
+
//It is possible to disable the wait interval by using waitSeconds of 0.
|
747
|
+
expired = waitInterval && (context.startTime + waitInterval) < new Date().getTime(),
|
748
|
+
noLoads = "", hasLoadedProp = false, stillLoading = false, prop,
|
749
|
+
err, manager;
|
750
|
+
|
751
|
+
//If there are items still in the paused queue processing wait.
|
752
|
+
//This is particularly important in the sync case where each paused
|
753
|
+
//item is processed right away but there may be more waiting.
|
754
|
+
if (context.pausedCount > 0) {
|
755
|
+
return undefined;
|
756
|
+
}
|
757
|
+
|
758
|
+
//Determine if priority loading is done. If so clear the priority. If
|
759
|
+
//not, then do not check
|
760
|
+
if (config.priorityWait) {
|
761
|
+
if (isPriorityDone()) {
|
762
|
+
//Call resume, since it could have
|
763
|
+
//some waiting dependencies to trace.
|
764
|
+
resume();
|
765
|
+
} else {
|
766
|
+
return undefined;
|
767
|
+
}
|
768
|
+
}
|
769
|
+
|
770
|
+
//See if anything is still in flight.
|
771
|
+
for (prop in loaded) {
|
772
|
+
if (!(prop in empty)) {
|
773
|
+
hasLoadedProp = true;
|
774
|
+
if (!loaded[prop]) {
|
775
|
+
if (expired) {
|
776
|
+
noLoads += prop + " ";
|
777
|
+
} else {
|
778
|
+
stillLoading = true;
|
779
|
+
break;
|
780
|
+
}
|
781
|
+
}
|
782
|
+
}
|
783
|
+
}
|
784
|
+
|
785
|
+
//Check for exit conditions.
|
786
|
+
if (!hasLoadedProp && !context.waitCount) {
|
787
|
+
//If the loaded object had no items, then the rest of
|
788
|
+
//the work below does not need to be done.
|
789
|
+
return undefined;
|
790
|
+
}
|
791
|
+
if (expired && noLoads) {
|
792
|
+
//If wait time expired, throw error of unloaded modules.
|
793
|
+
err = new Error("require.js load timeout for modules: " + noLoads);
|
794
|
+
err.requireType = "timeout";
|
795
|
+
err.requireModules = noLoads;
|
796
|
+
return req.onError(err);
|
797
|
+
}
|
798
|
+
if (stillLoading || context.scriptCount) {
|
799
|
+
//Something is still waiting to load. Wait for it.
|
800
|
+
if (isBrowser || isWebWorker) {
|
801
|
+
setTimeout(checkLoaded, 50);
|
802
|
+
}
|
803
|
+
return undefined;
|
804
|
+
}
|
805
|
+
|
806
|
+
//If still have items in the waiting cue, but all modules have
|
807
|
+
//been loaded, then it means there are some circular dependencies
|
808
|
+
//that need to be broken.
|
809
|
+
//However, as a waiting thing is fired, then it can add items to
|
810
|
+
//the waiting cue, and those items should not be fired yet, so
|
811
|
+
//make sure to redo the checkLoaded call after breaking a single
|
812
|
+
//cycle, if nothing else loaded then this logic will pick it up
|
813
|
+
//again.
|
814
|
+
if (context.waitCount) {
|
815
|
+
//Cycle through the waitAry, and call items in sequence.
|
816
|
+
for (i = 0; (manager = waitAry[i]); i++) {
|
817
|
+
forceExec(manager, {});
|
818
|
+
}
|
819
|
+
|
820
|
+
checkLoaded();
|
821
|
+
return undefined;
|
822
|
+
}
|
823
|
+
|
824
|
+
//Check for DOM ready, and nothing is waiting across contexts.
|
825
|
+
req.checkReadyState();
|
826
|
+
|
827
|
+
return undefined;
|
828
|
+
}
|
829
|
+
|
830
|
+
function callPlugin(pluginName, dep) {
|
831
|
+
var name = dep.name,
|
832
|
+
fullName = dep.fullName,
|
833
|
+
load;
|
834
|
+
|
835
|
+
//Do not bother if plugin is already defined or being loaded.
|
836
|
+
if (fullName in defined || fullName in loaded) {
|
837
|
+
return;
|
838
|
+
}
|
839
|
+
|
840
|
+
if (!plugins[pluginName]) {
|
841
|
+
plugins[pluginName] = defined[pluginName];
|
842
|
+
}
|
843
|
+
|
844
|
+
//Only set loaded to false for tracking if it has not already been set.
|
845
|
+
if (!loaded[fullName]) {
|
846
|
+
loaded[fullName] = false;
|
847
|
+
}
|
848
|
+
|
849
|
+
load = function (ret) {
|
850
|
+
//Allow the build process to register plugin-loaded dependencies.
|
851
|
+
if (require.onPluginLoad) {
|
852
|
+
require.onPluginLoad(context, pluginName, name, ret);
|
853
|
+
}
|
854
|
+
|
855
|
+
execManager({
|
856
|
+
prefix: dep.prefix,
|
857
|
+
name: dep.name,
|
858
|
+
fullName: dep.fullName,
|
859
|
+
callback: function () {
|
860
|
+
return ret;
|
861
|
+
}
|
862
|
+
});
|
863
|
+
loaded[fullName] = true;
|
864
|
+
};
|
865
|
+
|
866
|
+
//Allow plugins to load other code without having to know the
|
867
|
+
//context or how to "complete" the load.
|
868
|
+
load.fromText = function (moduleName, text) {
|
869
|
+
/*jslint evil: true */
|
870
|
+
var hasInteractive = useInteractive;
|
871
|
+
|
872
|
+
//Indicate a the module is in process of loading.
|
873
|
+
context.loaded[moduleName] = false;
|
874
|
+
context.scriptCount += 1;
|
875
|
+
|
876
|
+
//Turn off interactive script matching for IE for any define
|
877
|
+
//calls in the text, then turn it back on at the end.
|
878
|
+
if (hasInteractive) {
|
879
|
+
useInteractive = false;
|
880
|
+
}
|
881
|
+
eval(text);
|
882
|
+
if (hasInteractive) {
|
883
|
+
useInteractive = true;
|
884
|
+
}
|
885
|
+
|
886
|
+
//Support anonymous modules.
|
887
|
+
context.completeLoad(moduleName);
|
888
|
+
};
|
889
|
+
|
890
|
+
//Use parentName here since the plugin's name is not reliable,
|
891
|
+
//could be some weird string with no path that actually wants to
|
892
|
+
//reference the parentName's path.
|
893
|
+
plugins[pluginName].load(name, makeRequire(dep.parentMap, true), load, config);
|
894
|
+
}
|
895
|
+
|
896
|
+
function loadPaused(dep) {
|
897
|
+
//Renormalize dependency if its name was waiting on a plugin
|
898
|
+
//to load, which as since loaded.
|
899
|
+
if (dep.prefix && dep.name.indexOf('__$p') === 0 && defined[dep.prefix]) {
|
900
|
+
dep = makeModuleMap(dep.originalName, dep.parentMap);
|
901
|
+
}
|
902
|
+
|
903
|
+
var pluginName = dep.prefix,
|
904
|
+
fullName = dep.fullName;
|
905
|
+
|
906
|
+
//Do not bother if the dependency has already been specified.
|
907
|
+
if (specified[fullName] || loaded[fullName]) {
|
908
|
+
return;
|
909
|
+
} else {
|
910
|
+
specified[fullName] = true;
|
911
|
+
}
|
912
|
+
|
913
|
+
if (pluginName) {
|
914
|
+
//If plugin not loaded, wait for it.
|
915
|
+
//set up callback list. if no list, then register
|
916
|
+
//managerCallback for that plugin.
|
917
|
+
if (defined[pluginName]) {
|
918
|
+
callPlugin(pluginName, dep);
|
919
|
+
} else {
|
920
|
+
if (!pluginsQueue[pluginName]) {
|
921
|
+
pluginsQueue[pluginName] = [];
|
922
|
+
(managerCallbacks[pluginName] ||
|
923
|
+
(managerCallbacks[pluginName] = [])).push({
|
924
|
+
onDep: function (name, value) {
|
925
|
+
if (name === pluginName) {
|
926
|
+
var i, oldModuleMap, ary = pluginsQueue[pluginName];
|
927
|
+
|
928
|
+
//Now update all queued plugin actions.
|
929
|
+
for (i = 0; i < ary.length; i++) {
|
930
|
+
oldModuleMap = ary[i];
|
931
|
+
//Update the moduleMap since the
|
932
|
+
//module name may be normalized
|
933
|
+
//differently now.
|
934
|
+
callPlugin(pluginName,
|
935
|
+
makeModuleMap(oldModuleMap.originalName, oldModuleMap.parentMap));
|
936
|
+
}
|
937
|
+
delete pluginsQueue[pluginName];
|
938
|
+
}
|
939
|
+
}
|
940
|
+
});
|
941
|
+
}
|
942
|
+
pluginsQueue[pluginName].push(dep);
|
943
|
+
}
|
944
|
+
} else {
|
945
|
+
req.load(context, fullName, dep.url);
|
946
|
+
}
|
947
|
+
}
|
948
|
+
|
949
|
+
/**
|
950
|
+
* Resumes tracing of dependencies and then checks if everything is loaded.
|
951
|
+
*/
|
952
|
+
resume = function () {
|
953
|
+
var args, i, p;
|
954
|
+
|
955
|
+
resumeDepth += 1;
|
956
|
+
|
957
|
+
if (context.scriptCount <= 0) {
|
958
|
+
//Synchronous envs will push the number below zero with the
|
959
|
+
//decrement above, be sure to set it back to zero for good measure.
|
960
|
+
//require() calls that also do not end up loading scripts could
|
961
|
+
//push the number negative too.
|
962
|
+
context.scriptCount = 0;
|
963
|
+
}
|
964
|
+
|
965
|
+
//Make sure any remaining defQueue items get properly processed.
|
966
|
+
while (defQueue.length) {
|
967
|
+
args = defQueue.shift();
|
968
|
+
if (args[0] === null) {
|
969
|
+
return req.onError(new Error('Mismatched anonymous require.def modules'));
|
970
|
+
} else {
|
971
|
+
callDefMain(args);
|
972
|
+
}
|
973
|
+
}
|
974
|
+
|
975
|
+
//Skip the resume of paused dependencies
|
976
|
+
//if current context is in priority wait.
|
977
|
+
if (!config.priorityWait || isPriorityDone()) {
|
978
|
+
while (context.paused.length) {
|
979
|
+
p = context.paused;
|
980
|
+
context.pausedCount += p.length;
|
981
|
+
//Reset paused list
|
982
|
+
context.paused = [];
|
983
|
+
|
984
|
+
for (i = 0; (args = p[i]); i++) {
|
985
|
+
loadPaused(args);
|
986
|
+
}
|
987
|
+
//Move the start time for timeout forward.
|
988
|
+
context.startTime = (new Date()).getTime();
|
989
|
+
context.pausedCount -= p.length;
|
990
|
+
}
|
991
|
+
}
|
992
|
+
|
993
|
+
//Only check if loaded when resume depth is 1. It is likely that
|
994
|
+
//it is only greater than 1 in sync environments where a factory
|
995
|
+
//function also then calls the callback-style require. In those
|
996
|
+
//cases, the checkLoaded should not occur until the resume
|
997
|
+
//depth is back at the top level.
|
998
|
+
if (resumeDepth === 1) {
|
999
|
+
checkLoaded();
|
1000
|
+
}
|
1001
|
+
|
1002
|
+
resumeDepth -= 1;
|
1003
|
+
|
1004
|
+
return undefined;
|
1005
|
+
};
|
1006
|
+
|
1007
|
+
//Define the context object. Many of these fields are on here
|
1008
|
+
//just to make debugging easier.
|
1009
|
+
context = {
|
1010
|
+
contextName: contextName,
|
1011
|
+
config: config,
|
1012
|
+
defQueue: defQueue,
|
1013
|
+
waiting: waiting,
|
1014
|
+
waitCount: 0,
|
1015
|
+
specified: specified,
|
1016
|
+
loaded: loaded,
|
1017
|
+
urlMap: urlMap,
|
1018
|
+
scriptCount: 0,
|
1019
|
+
urlFetched: {},
|
1020
|
+
defined: defined,
|
1021
|
+
paused: [],
|
1022
|
+
pausedCount: 0,
|
1023
|
+
plugins: plugins,
|
1024
|
+
managerCallbacks: managerCallbacks,
|
1025
|
+
makeModuleMap: makeModuleMap,
|
1026
|
+
normalize: normalize,
|
1027
|
+
/**
|
1028
|
+
* Set a configuration for the context.
|
1029
|
+
* @param {Object} cfg config object to integrate.
|
1030
|
+
*/
|
1031
|
+
configure: function (cfg) {
|
1032
|
+
var paths, prop, packages, pkgs, packagePaths, requireWait;
|
1033
|
+
|
1034
|
+
//Make sure the baseUrl ends in a slash.
|
1035
|
+
if (cfg.baseUrl) {
|
1036
|
+
if (cfg.baseUrl.charAt(cfg.baseUrl.length - 1) !== "/") {
|
1037
|
+
cfg.baseUrl += "/";
|
1038
|
+
}
|
1039
|
+
}
|
1040
|
+
|
1041
|
+
//Save off the paths and packages since they require special processing,
|
1042
|
+
//they are additive.
|
1043
|
+
paths = config.paths;
|
1044
|
+
packages = config.packages;
|
1045
|
+
pkgs = config.pkgs;
|
1046
|
+
|
1047
|
+
//Mix in the config values, favoring the new values over
|
1048
|
+
//existing ones in context.config.
|
1049
|
+
mixin(config, cfg, true);
|
1050
|
+
|
1051
|
+
//Adjust paths if necessary.
|
1052
|
+
if (cfg.paths) {
|
1053
|
+
for (prop in cfg.paths) {
|
1054
|
+
if (!(prop in empty)) {
|
1055
|
+
paths[prop] = cfg.paths[prop];
|
1056
|
+
}
|
1057
|
+
}
|
1058
|
+
config.paths = paths;
|
1059
|
+
}
|
1060
|
+
|
1061
|
+
packagePaths = cfg.packagePaths;
|
1062
|
+
if (packagePaths || cfg.packages) {
|
1063
|
+
//Convert packagePaths into a packages config.
|
1064
|
+
if (packagePaths) {
|
1065
|
+
for (prop in packagePaths) {
|
1066
|
+
if (!(prop in empty)) {
|
1067
|
+
configurePackageDir(pkgs, packagePaths[prop], prop);
|
1068
|
+
}
|
1069
|
+
}
|
1070
|
+
}
|
1071
|
+
|
1072
|
+
//Adjust packages if necessary.
|
1073
|
+
if (cfg.packages) {
|
1074
|
+
configurePackageDir(pkgs, cfg.packages);
|
1075
|
+
}
|
1076
|
+
|
1077
|
+
//Done with modifications, assing packages back to context config
|
1078
|
+
config.pkgs = pkgs;
|
1079
|
+
}
|
1080
|
+
|
1081
|
+
//If priority loading is in effect, trigger the loads now
|
1082
|
+
if (cfg.priority) {
|
1083
|
+
//Hold on to requireWait value, and reset it after done
|
1084
|
+
requireWait = context.requireWait;
|
1085
|
+
|
1086
|
+
//Allow tracing some require calls to allow the fetching
|
1087
|
+
//of the priority config.
|
1088
|
+
context.requireWait = false;
|
1089
|
+
|
1090
|
+
//But first, call resume to register any defined modules that may
|
1091
|
+
//be in a data-main built file before the priority config
|
1092
|
+
//call. Also grab any waiting define calls for this context.
|
1093
|
+
context.takeGlobalQueue();
|
1094
|
+
resume();
|
1095
|
+
|
1096
|
+
context.require(cfg.priority);
|
1097
|
+
|
1098
|
+
//Trigger a resume right away, for the case when
|
1099
|
+
//the script with the priority load is done as part
|
1100
|
+
//of a data-main call. In that case the normal resume
|
1101
|
+
//call will not happen because the scriptCount will be
|
1102
|
+
//at 1, since the script for data-main is being processed.
|
1103
|
+
resume();
|
1104
|
+
|
1105
|
+
//Restore previous state.
|
1106
|
+
context.requireWait = requireWait;
|
1107
|
+
config.priorityWait = cfg.priority;
|
1108
|
+
}
|
1109
|
+
|
1110
|
+
//If a deps array or a config callback is specified, then call
|
1111
|
+
//require with those args. This is useful when require is defined as a
|
1112
|
+
//config object before require.js is loaded.
|
1113
|
+
if (cfg.deps || cfg.callback) {
|
1114
|
+
context.require(cfg.deps || [], cfg.callback);
|
1115
|
+
}
|
1116
|
+
|
1117
|
+
//Set up ready callback, if asked. Useful when require is defined as a
|
1118
|
+
//config object before require.js is loaded.
|
1119
|
+
if (cfg.ready) {
|
1120
|
+
req.ready(cfg.ready);
|
1121
|
+
}
|
1122
|
+
},
|
1123
|
+
|
1124
|
+
isDefined: function (moduleName, relModuleMap) {
|
1125
|
+
return makeModuleMap(moduleName, relModuleMap).fullName in defined;
|
1126
|
+
},
|
1127
|
+
|
1128
|
+
require: function (deps, callback, relModuleMap) {
|
1129
|
+
var moduleName, ret, moduleMap;
|
1130
|
+
if (typeof deps === "string") {
|
1131
|
+
//Synchronous access to one module. If require.get is
|
1132
|
+
//available (as in the Node adapter), prefer that.
|
1133
|
+
//In this case deps is the moduleName and callback is
|
1134
|
+
//the relModuleMap
|
1135
|
+
if (req.get) {
|
1136
|
+
return req.get(context, deps, callback);
|
1137
|
+
}
|
1138
|
+
|
1139
|
+
//Just return the module wanted. In this scenario, the
|
1140
|
+
//second arg (if passed) is just the relModuleMap.
|
1141
|
+
moduleName = deps;
|
1142
|
+
relModuleMap = callback;
|
1143
|
+
|
1144
|
+
//Normalize module name, if it contains . or ..
|
1145
|
+
moduleMap = makeModuleMap(moduleName, relModuleMap);
|
1146
|
+
|
1147
|
+
ret = defined[moduleMap.fullName];
|
1148
|
+
if (ret === undefined) {
|
1149
|
+
return req.onError(new Error("require: module name '" +
|
1150
|
+
moduleMap.fullName +
|
1151
|
+
"' has not been loaded yet for context: " +
|
1152
|
+
contextName));
|
1153
|
+
}
|
1154
|
+
return ret;
|
1155
|
+
}
|
1156
|
+
|
1157
|
+
main(null, deps, callback, relModuleMap);
|
1158
|
+
|
1159
|
+
//If the require call does not trigger anything new to load,
|
1160
|
+
//then resume the dependency processing.
|
1161
|
+
if (!context.requireWait) {
|
1162
|
+
while (!context.scriptCount && context.paused.length) {
|
1163
|
+
resume();
|
1164
|
+
}
|
1165
|
+
}
|
1166
|
+
return undefined;
|
1167
|
+
},
|
1168
|
+
|
1169
|
+
/**
|
1170
|
+
* Internal method to transfer globalQueue items to this context's
|
1171
|
+
* defQueue.
|
1172
|
+
*/
|
1173
|
+
takeGlobalQueue: function () {
|
1174
|
+
//Push all the globalDefQueue items into the context's defQueue
|
1175
|
+
if (globalDefQueue.length) {
|
1176
|
+
//Array splice in the values since the context code has a
|
1177
|
+
//local var ref to defQueue, so cannot just reassign the one
|
1178
|
+
//on context.
|
1179
|
+
apsp.apply(context.defQueue,
|
1180
|
+
[context.defQueue.length - 1, 0].concat(globalDefQueue));
|
1181
|
+
globalDefQueue = [];
|
1182
|
+
}
|
1183
|
+
},
|
1184
|
+
|
1185
|
+
/**
|
1186
|
+
* Internal method used by environment adapters to complete a load event.
|
1187
|
+
* A load event could be a script load or just a load pass from a synchronous
|
1188
|
+
* load call.
|
1189
|
+
* @param {String} moduleName the name of the module to potentially complete.
|
1190
|
+
*/
|
1191
|
+
completeLoad: function (moduleName) {
|
1192
|
+
var args;
|
1193
|
+
|
1194
|
+
context.takeGlobalQueue();
|
1195
|
+
|
1196
|
+
while (defQueue.length) {
|
1197
|
+
args = defQueue.shift();
|
1198
|
+
|
1199
|
+
if (args[0] === null) {
|
1200
|
+
args[0] = moduleName;
|
1201
|
+
break;
|
1202
|
+
} else if (args[0] === moduleName) {
|
1203
|
+
//Found matching require.def call for this script!
|
1204
|
+
break;
|
1205
|
+
} else {
|
1206
|
+
//Some other named require.def call, most likely the result
|
1207
|
+
//of a build layer that included many require.def calls.
|
1208
|
+
callDefMain(args);
|
1209
|
+
args = null;
|
1210
|
+
}
|
1211
|
+
}
|
1212
|
+
if (args) {
|
1213
|
+
callDefMain(args);
|
1214
|
+
} else {
|
1215
|
+
//A script that does not call define(), so just simulate
|
1216
|
+
//the call for it. Special exception for jQuery dynamic load.
|
1217
|
+
callDefMain([moduleName, [],
|
1218
|
+
moduleName === "jquery" && typeof jQuery !== "undefined" ?
|
1219
|
+
function () {
|
1220
|
+
return jQuery;
|
1221
|
+
} : null]);
|
1222
|
+
}
|
1223
|
+
|
1224
|
+
//Mark the script as loaded. Note that this can be different from a
|
1225
|
+
//moduleName that maps to a require.def call. This line is important
|
1226
|
+
//for traditional browser scripts.
|
1227
|
+
loaded[moduleName] = true;
|
1228
|
+
|
1229
|
+
//If a global jQuery is defined, check for it. Need to do it here
|
1230
|
+
//instead of main() since stock jQuery does not register as
|
1231
|
+
//a module via define.
|
1232
|
+
jQueryCheck();
|
1233
|
+
|
1234
|
+
//Doing this scriptCount decrement branching because sync envs
|
1235
|
+
//need to decrement after resume, otherwise it looks like
|
1236
|
+
//loading is complete after the first dependency is fetched.
|
1237
|
+
//For browsers, it works fine to decrement after, but it means
|
1238
|
+
//the checkLoaded setTimeout 50 ms cost is taken. To avoid
|
1239
|
+
//that cost, decrement beforehand.
|
1240
|
+
if (req.isAsync) {
|
1241
|
+
context.scriptCount -= 1;
|
1242
|
+
}
|
1243
|
+
resume();
|
1244
|
+
if (!req.isAsync) {
|
1245
|
+
context.scriptCount -= 1;
|
1246
|
+
}
|
1247
|
+
},
|
1248
|
+
|
1249
|
+
/**
|
1250
|
+
* Converts a module name + .extension into an URL path.
|
1251
|
+
* *Requires* the use of a module name. It does not support using
|
1252
|
+
* plain URLs like nameToUrl.
|
1253
|
+
*/
|
1254
|
+
toUrl: function (moduleNamePlusExt, relModuleMap) {
|
1255
|
+
var index = moduleNamePlusExt.lastIndexOf("."),
|
1256
|
+
ext = null;
|
1257
|
+
|
1258
|
+
if (index !== -1) {
|
1259
|
+
ext = moduleNamePlusExt.substring(index, moduleNamePlusExt.length);
|
1260
|
+
moduleNamePlusExt = moduleNamePlusExt.substring(0, index);
|
1261
|
+
}
|
1262
|
+
|
1263
|
+
return context.nameToUrl(moduleNamePlusExt, ext, relModuleMap);
|
1264
|
+
},
|
1265
|
+
|
1266
|
+
/**
|
1267
|
+
* Converts a module name to a file path. Supports cases where
|
1268
|
+
* moduleName may actually be just an URL.
|
1269
|
+
*/
|
1270
|
+
nameToUrl: function (moduleName, ext, relModuleMap) {
|
1271
|
+
var paths, pkgs, pkg, pkgPath, syms, i, parentModule, url,
|
1272
|
+
config = context.config;
|
1273
|
+
|
1274
|
+
if (moduleName.indexOf("./") === 0 || moduleName.indexOf("../") === 0) {
|
1275
|
+
//A relative ID, just map it relative to relModuleMap's url
|
1276
|
+
syms = relModuleMap && relModuleMap.url ? relModuleMap.url.split('/') : [];
|
1277
|
+
//Pop off the file name.
|
1278
|
+
if (syms.length) {
|
1279
|
+
syms.pop();
|
1280
|
+
}
|
1281
|
+
syms = syms.concat(moduleName.split('/'));
|
1282
|
+
trimDots(syms);
|
1283
|
+
url = syms.join('/') +
|
1284
|
+
(ext ? ext :
|
1285
|
+
(req.jsExtRegExp.test(moduleName) ? "" : ".js"));
|
1286
|
+
} else {
|
1287
|
+
|
1288
|
+
//Normalize module name if have a base relative module name to work from.
|
1289
|
+
moduleName = normalize(moduleName, relModuleMap);
|
1290
|
+
|
1291
|
+
//If a colon is in the URL, it indicates a protocol is used and it is just
|
1292
|
+
//an URL to a file, or if it starts with a slash or ends with .js, it is just a plain file.
|
1293
|
+
//The slash is important for protocol-less URLs as well as full paths.
|
1294
|
+
if (req.jsExtRegExp.test(moduleName)) {
|
1295
|
+
//Just a plain path, not module name lookup, so just return it.
|
1296
|
+
//Add extension if it is included. This is a bit wonky, only non-.js things pass
|
1297
|
+
//an extension, this method probably needs to be reworked.
|
1298
|
+
url = moduleName + (ext ? ext : "");
|
1299
|
+
} else {
|
1300
|
+
//A module that needs to be converted to a path.
|
1301
|
+
paths = config.paths;
|
1302
|
+
pkgs = config.pkgs;
|
1303
|
+
|
1304
|
+
syms = moduleName.split("/");
|
1305
|
+
//For each module name segment, see if there is a path
|
1306
|
+
//registered for it. Start with most specific name
|
1307
|
+
//and work up from it.
|
1308
|
+
for (i = syms.length; i > 0; i--) {
|
1309
|
+
parentModule = syms.slice(0, i).join("/");
|
1310
|
+
if (paths[parentModule]) {
|
1311
|
+
syms.splice(0, i, paths[parentModule]);
|
1312
|
+
break;
|
1313
|
+
} else if ((pkg = pkgs[parentModule])) {
|
1314
|
+
//If module name is just the package name, then looking
|
1315
|
+
//for the main module.
|
1316
|
+
if (moduleName === pkg.name) {
|
1317
|
+
pkgPath = pkg.location + '/' + pkg.main;
|
1318
|
+
} else {
|
1319
|
+
pkgPath = pkg.location + '/' + pkg.lib;
|
1320
|
+
}
|
1321
|
+
syms.splice(0, i, pkgPath);
|
1322
|
+
break;
|
1323
|
+
}
|
1324
|
+
}
|
1325
|
+
|
1326
|
+
//Join the path parts together, then figure out if baseUrl is needed.
|
1327
|
+
url = syms.join("/") + (ext || ".js");
|
1328
|
+
url = (url.charAt(0) === '/' || url.match(/^\w+:/) ? "" : config.baseUrl) + url;
|
1329
|
+
}
|
1330
|
+
}
|
1331
|
+
|
1332
|
+
return config.urlArgs ? url +
|
1333
|
+
((url.indexOf('?') === -1 ? '?' : '&') +
|
1334
|
+
config.urlArgs) : url;
|
1335
|
+
}
|
1336
|
+
};
|
1337
|
+
|
1338
|
+
//Make these visible on the context so can be called at the very
|
1339
|
+
//end of the file to bootstrap
|
1340
|
+
context.jQueryCheck = jQueryCheck;
|
1341
|
+
context.resume = resume;
|
1342
|
+
|
1343
|
+
return context;
|
1344
|
+
}
|
1345
|
+
|
1346
|
+
/**
|
1347
|
+
* Main entry point.
|
1348
|
+
*
|
1349
|
+
* If the only argument to require is a string, then the module that
|
1350
|
+
* is represented by that string is fetched for the appropriate context.
|
1351
|
+
*
|
1352
|
+
* If the first argument is an array, then it will be treated as an array
|
1353
|
+
* of dependency string names to fetch. An optional function callback can
|
1354
|
+
* be specified to execute when all of those dependencies are available.
|
1355
|
+
*
|
1356
|
+
* Make a local req variable to help Caja compliance (it assumes things
|
1357
|
+
* on a require that are not standardized), and to give a short
|
1358
|
+
* name for minification/local scope use.
|
1359
|
+
*/
|
1360
|
+
req = require = function (deps, callback) {
|
1361
|
+
|
1362
|
+
//Find the right context, use default
|
1363
|
+
var contextName = defContextName,
|
1364
|
+
context, config;
|
1365
|
+
|
1366
|
+
// Determine if have config object in the call.
|
1367
|
+
if (!isArray(deps) && typeof deps !== "string") {
|
1368
|
+
// deps is a config object
|
1369
|
+
config = deps;
|
1370
|
+
if (isArray(callback)) {
|
1371
|
+
// Adjust args if there are dependencies
|
1372
|
+
deps = callback;
|
1373
|
+
callback = arguments[2];
|
1374
|
+
} else {
|
1375
|
+
deps = [];
|
1376
|
+
}
|
1377
|
+
}
|
1378
|
+
|
1379
|
+
if (config && config.context) {
|
1380
|
+
contextName = config.context;
|
1381
|
+
}
|
1382
|
+
|
1383
|
+
context = contexts[contextName] ||
|
1384
|
+
(contexts[contextName] = newContext(contextName));
|
1385
|
+
|
1386
|
+
if (config) {
|
1387
|
+
context.configure(config);
|
1388
|
+
}
|
1389
|
+
|
1390
|
+
return context.require(deps, callback);
|
1391
|
+
};
|
1392
|
+
|
1393
|
+
req.version = version;
|
1394
|
+
req.isArray = isArray;
|
1395
|
+
req.isFunction = isFunction;
|
1396
|
+
req.mixin = mixin;
|
1397
|
+
//Used to filter out dependencies that are already paths.
|
1398
|
+
req.jsExtRegExp = /^\/|:|\?|\.js$/;
|
1399
|
+
s = req.s = {
|
1400
|
+
contexts: contexts,
|
1401
|
+
//Stores a list of URLs that should not get async script tag treatment.
|
1402
|
+
skipAsync: {},
|
1403
|
+
isPageLoaded: !isBrowser,
|
1404
|
+
readyCalls: []
|
1405
|
+
};
|
1406
|
+
|
1407
|
+
req.isAsync = req.isBrowser = isBrowser;
|
1408
|
+
if (isBrowser) {
|
1409
|
+
head = s.head = document.getElementsByTagName("head")[0];
|
1410
|
+
//If BASE tag is in play, using appendChild is a problem for IE6.
|
1411
|
+
//When that browser dies, this can be removed. Details in this jQuery bug:
|
1412
|
+
//http://dev.jquery.com/ticket/2709
|
1413
|
+
baseElement = document.getElementsByTagName("base")[0];
|
1414
|
+
if (baseElement) {
|
1415
|
+
head = s.head = baseElement.parentNode;
|
1416
|
+
}
|
1417
|
+
}
|
1418
|
+
|
1419
|
+
/**
|
1420
|
+
* Any errors that require explicitly generates will be passed to this
|
1421
|
+
* function. Intercept/override it if you want custom error handling.
|
1422
|
+
* @param {Error} err the error object.
|
1423
|
+
*/
|
1424
|
+
req.onError = function (err) {
|
1425
|
+
throw err;
|
1426
|
+
};
|
1427
|
+
|
1428
|
+
/**
|
1429
|
+
* Does the request to load a module for the browser case.
|
1430
|
+
* Make this a separate function to allow other environments
|
1431
|
+
* to override it.
|
1432
|
+
*
|
1433
|
+
* @param {Object} context the require context to find state.
|
1434
|
+
* @param {String} moduleName the name of the module.
|
1435
|
+
* @param {Object} url the URL to the module.
|
1436
|
+
*/
|
1437
|
+
req.load = function (context, moduleName, url) {
|
1438
|
+
var contextName = context.contextName,
|
1439
|
+
urlFetched = context.urlFetched,
|
1440
|
+
loaded = context.loaded;
|
1441
|
+
isDone = false;
|
1442
|
+
|
1443
|
+
//Only set loaded to false for tracking if it has not already been set.
|
1444
|
+
if (!loaded[moduleName]) {
|
1445
|
+
loaded[moduleName] = false;
|
1446
|
+
}
|
1447
|
+
|
1448
|
+
if (!urlFetched[url]) {
|
1449
|
+
context.scriptCount += 1;
|
1450
|
+
req.attach(url, contextName, moduleName);
|
1451
|
+
urlFetched[url] = true;
|
1452
|
+
|
1453
|
+
//If tracking a jQuery, then make sure its readyWait
|
1454
|
+
//is incremented to prevent its ready callbacks from
|
1455
|
+
//triggering too soon.
|
1456
|
+
if (context.jQuery && !context.jQueryIncremented) {
|
1457
|
+
context.jQuery.readyWait += 1;
|
1458
|
+
context.jQueryIncremented = true;
|
1459
|
+
}
|
1460
|
+
}
|
1461
|
+
};
|
1462
|
+
|
1463
|
+
function getInteractiveScript() {
|
1464
|
+
var scripts, i, script;
|
1465
|
+
if (interactiveScript && interactiveScript.readyState === 'interactive') {
|
1466
|
+
return interactiveScript;
|
1467
|
+
}
|
1468
|
+
|
1469
|
+
scripts = document.getElementsByTagName('script');
|
1470
|
+
for (i = scripts.length - 1; i > -1 && (script = scripts[i]); i--) {
|
1471
|
+
if (script.readyState === 'interactive') {
|
1472
|
+
return (interactiveScript = script);
|
1473
|
+
}
|
1474
|
+
}
|
1475
|
+
|
1476
|
+
return null;
|
1477
|
+
}
|
1478
|
+
|
1479
|
+
/**
|
1480
|
+
* The function that handles definitions of modules. Differs from
|
1481
|
+
* require() in that a string for the module should be the first argument,
|
1482
|
+
* and the function to execute after dependencies are loaded should
|
1483
|
+
* return a value to define the module corresponding to the first argument's
|
1484
|
+
* name.
|
1485
|
+
*/
|
1486
|
+
define = req.def = function (name, deps, callback) {
|
1487
|
+
var node, context;
|
1488
|
+
|
1489
|
+
//Allow for anonymous functions
|
1490
|
+
if (typeof name !== 'string') {
|
1491
|
+
//Adjust args appropriately
|
1492
|
+
callback = deps;
|
1493
|
+
deps = name;
|
1494
|
+
name = null;
|
1495
|
+
}
|
1496
|
+
|
1497
|
+
//This module may not have dependencies
|
1498
|
+
if (!req.isArray(deps)) {
|
1499
|
+
callback = deps;
|
1500
|
+
deps = [];
|
1501
|
+
}
|
1502
|
+
|
1503
|
+
//If no name, and callback is a function, then figure out if it a
|
1504
|
+
//CommonJS thing with dependencies.
|
1505
|
+
if (!name && !deps.length && req.isFunction(callback)) {
|
1506
|
+
//Remove comments from the callback string,
|
1507
|
+
//look for require calls, and pull them into the dependencies,
|
1508
|
+
//but only if there are function args.
|
1509
|
+
if (callback.length) {
|
1510
|
+
callback
|
1511
|
+
.toString()
|
1512
|
+
.replace(commentRegExp, "")
|
1513
|
+
.replace(cjsRequireRegExp, function (match, dep) {
|
1514
|
+
deps.push(dep);
|
1515
|
+
});
|
1516
|
+
|
1517
|
+
//May be a CommonJS thing even without require calls, but still
|
1518
|
+
//could use exports, and such, so always add those as dependencies.
|
1519
|
+
//This is a bit wasteful for RequireJS modules that do not need
|
1520
|
+
//an exports or module object, but erring on side of safety.
|
1521
|
+
//REQUIRES the function to expect the CommonJS variables in the
|
1522
|
+
//order listed below.
|
1523
|
+
deps = ["require", "exports", "module"].concat(deps);
|
1524
|
+
}
|
1525
|
+
}
|
1526
|
+
|
1527
|
+
//If in IE 6-8 and hit an anonymous define() call, do the interactive
|
1528
|
+
//work.
|
1529
|
+
if (useInteractive) {
|
1530
|
+
node = currentlyAddingScript || getInteractiveScript();
|
1531
|
+
if (!node) {
|
1532
|
+
return req.onError(new Error("ERROR: No matching script interactive for " + callback));
|
1533
|
+
}
|
1534
|
+
if (!name) {
|
1535
|
+
name = node.getAttribute("data-requiremodule");
|
1536
|
+
}
|
1537
|
+
context = contexts[node.getAttribute("data-requirecontext")];
|
1538
|
+
}
|
1539
|
+
|
1540
|
+
//Always save off evaluating the def call until the script onload handler.
|
1541
|
+
//This allows multiple modules to be in a file without prematurely
|
1542
|
+
//tracing dependencies, and allows for anonymous module support,
|
1543
|
+
//where the module name is not known until the script onload event
|
1544
|
+
//occurs. If no context, use the global queue, and get it processed
|
1545
|
+
//in the onscript load callback.
|
1546
|
+
(context ? context.defQueue : globalDefQueue).push([name, deps, callback]);
|
1547
|
+
|
1548
|
+
return undefined;
|
1549
|
+
};
|
1550
|
+
|
1551
|
+
define.amd = {
|
1552
|
+
multiversion: true,
|
1553
|
+
plugins: true
|
1554
|
+
};
|
1555
|
+
|
1556
|
+
/**
|
1557
|
+
* Executes a module callack function. Broken out as a separate function
|
1558
|
+
* solely to allow the build system to sequence the files in the built
|
1559
|
+
* layer in the right sequence.
|
1560
|
+
*
|
1561
|
+
* @private
|
1562
|
+
*/
|
1563
|
+
req.execCb = function (name, callback, args) {
|
1564
|
+
return callback.apply(null, args);
|
1565
|
+
};
|
1566
|
+
|
1567
|
+
/**
|
1568
|
+
* callback for script loads, used to check status of loading.
|
1569
|
+
*
|
1570
|
+
* @param {Event} evt the event from the browser for the script
|
1571
|
+
* that was loaded.
|
1572
|
+
*
|
1573
|
+
* @private
|
1574
|
+
*/
|
1575
|
+
req.onScriptLoad = function (evt) {
|
1576
|
+
//Using currentTarget instead of target for Firefox 2.0's sake. Not
|
1577
|
+
//all old browsers will be supported, but this one was easy enough
|
1578
|
+
//to support and still makes sense.
|
1579
|
+
var node = evt.currentTarget || evt.srcElement, contextName, moduleName,
|
1580
|
+
context;
|
1581
|
+
|
1582
|
+
if (evt.type === "load" || readyRegExp.test(node.readyState)) {
|
1583
|
+
//Reset interactive script so a script node is not held onto for
|
1584
|
+
//to long.
|
1585
|
+
interactiveScript = null;
|
1586
|
+
|
1587
|
+
//Pull out the name of the module and the context.
|
1588
|
+
contextName = node.getAttribute("data-requirecontext");
|
1589
|
+
moduleName = node.getAttribute("data-requiremodule");
|
1590
|
+
context = contexts[contextName];
|
1591
|
+
|
1592
|
+
contexts[contextName].completeLoad(moduleName);
|
1593
|
+
|
1594
|
+
//Clean up script binding. Favor detachEvent because of IE9
|
1595
|
+
//issue, see attachEvent/addEventListener comment elsewhere
|
1596
|
+
//in this file.
|
1597
|
+
if (node.detachEvent && !isOpera) {
|
1598
|
+
//Probably IE. If not it will throw an error, which will be
|
1599
|
+
//useful to know.
|
1600
|
+
node.detachEvent("onreadystatechange", req.onScriptLoad);
|
1601
|
+
} else {
|
1602
|
+
node.removeEventListener("load", req.onScriptLoad, false);
|
1603
|
+
}
|
1604
|
+
}
|
1605
|
+
};
|
1606
|
+
|
1607
|
+
/**
|
1608
|
+
* Attaches the script represented by the URL to the current
|
1609
|
+
* environment. Right now only supports browser loading,
|
1610
|
+
* but can be redefined in other environments to do the right thing.
|
1611
|
+
* @param {String} url the url of the script to attach.
|
1612
|
+
* @param {String} contextName the name of the context that wants the script.
|
1613
|
+
* @param {moduleName} the name of the module that is associated with the script.
|
1614
|
+
* @param {Function} [callback] optional callback, defaults to require.onScriptLoad
|
1615
|
+
* @param {String} [type] optional type, defaults to text/javascript
|
1616
|
+
*/
|
1617
|
+
req.attach = function (url, contextName, moduleName, callback, type) {
|
1618
|
+
var node, loaded, context;
|
1619
|
+
if (isBrowser) {
|
1620
|
+
//In the browser so use a script tag
|
1621
|
+
callback = callback || req.onScriptLoad;
|
1622
|
+
node = document.createElement("script");
|
1623
|
+
node.type = type || "text/javascript";
|
1624
|
+
node.charset = "utf-8";
|
1625
|
+
//Use async so Gecko does not block on executing the script if something
|
1626
|
+
//like a long-polling comet tag is being run first. Gecko likes
|
1627
|
+
//to evaluate scripts in DOM order, even for dynamic scripts.
|
1628
|
+
//It will fetch them async, but only evaluate the contents in DOM
|
1629
|
+
//order, so a long-polling script tag can delay execution of scripts
|
1630
|
+
//after it. But telling Gecko we expect async gets us the behavior
|
1631
|
+
//we want -- execute it whenever it is finished downloading. Only
|
1632
|
+
//Helps Firefox 3.6+
|
1633
|
+
//Allow some URLs to not be fetched async. Mostly helps the order!
|
1634
|
+
//plugin
|
1635
|
+
node.async = !s.skipAsync[url];
|
1636
|
+
|
1637
|
+
node.setAttribute("data-requirecontext", contextName);
|
1638
|
+
node.setAttribute("data-requiremodule", moduleName);
|
1639
|
+
|
1640
|
+
//Set up load listener. Test attachEvent first because IE9 has
|
1641
|
+
//a subtle issue in its addEventListener and script onload firings
|
1642
|
+
//that do not match the behavior of all other browsers with
|
1643
|
+
//addEventListener support, which fire the onload event for a
|
1644
|
+
//script right after the script execution. See:
|
1645
|
+
//https://connect.microsoft.com/IE/feedback/details/648057/script-onload-event-is-not-fired-immediately-after-script-execution
|
1646
|
+
//UNFORTUNATELY Opera implements attachEvent but does not follow the script
|
1647
|
+
//script execution mode.
|
1648
|
+
if (node.attachEvent && !isOpera) {
|
1649
|
+
//Probably IE. IE (at least 6-8) do not fire
|
1650
|
+
//script onload right after executing the script, so
|
1651
|
+
//we cannot tie the anonymous require.def call to a name.
|
1652
|
+
//However, IE reports the script as being in "interactive"
|
1653
|
+
//readyState at the time of the require.def call.
|
1654
|
+
useInteractive = true;
|
1655
|
+
node.attachEvent("onreadystatechange", callback);
|
1656
|
+
} else {
|
1657
|
+
node.addEventListener("load", callback, false);
|
1658
|
+
}
|
1659
|
+
node.src = url;
|
1660
|
+
|
1661
|
+
//For some cache cases in IE 6-8, the script executes before the end
|
1662
|
+
//of the appendChild execution, so to tie an anonymous require.def
|
1663
|
+
//call to the module name (which is stored on the node), hold on
|
1664
|
+
//to a reference to this node, but clear after the DOM insertion.
|
1665
|
+
currentlyAddingScript = node;
|
1666
|
+
if (baseElement) {
|
1667
|
+
head.insertBefore(node, baseElement);
|
1668
|
+
} else {
|
1669
|
+
head.appendChild(node);
|
1670
|
+
}
|
1671
|
+
currentlyAddingScript = null;
|
1672
|
+
return node;
|
1673
|
+
} else if (isWebWorker) {
|
1674
|
+
//In a web worker, use importScripts. This is not a very
|
1675
|
+
//efficient use of importScripts, importScripts will block until
|
1676
|
+
//its script is downloaded and evaluated. However, if web workers
|
1677
|
+
//are in play, the expectation that a build has been done so that
|
1678
|
+
//only one script needs to be loaded anyway. This may need to be
|
1679
|
+
//reevaluated if other use cases become common.
|
1680
|
+
context = contexts[contextName];
|
1681
|
+
loaded = context.loaded;
|
1682
|
+
loaded[moduleName] = false;
|
1683
|
+
|
1684
|
+
importScripts(url);
|
1685
|
+
|
1686
|
+
//Account for anonymous modules
|
1687
|
+
context.completeLoad(moduleName);
|
1688
|
+
}
|
1689
|
+
return null;
|
1690
|
+
};
|
1691
|
+
|
1692
|
+
//Look for a data-main script attribute, which could also adjust the baseUrl.
|
1693
|
+
if (isBrowser) {
|
1694
|
+
//Figure out baseUrl. Get it from the script tag with require.js in it.
|
1695
|
+
scripts = document.getElementsByTagName("script");
|
1696
|
+
|
1697
|
+
for (i = scripts.length - 1; i > -1 && (script = scripts[i]); i--) {
|
1698
|
+
//Set the "head" where we can append children by
|
1699
|
+
//using the script's parent.
|
1700
|
+
if (!head) {
|
1701
|
+
head = script.parentNode;
|
1702
|
+
}
|
1703
|
+
|
1704
|
+
//Look for a data-main attribute to set main script for the page
|
1705
|
+
//to load. If it is there, the path to data main becomes the
|
1706
|
+
//baseUrl, if it is not already set.
|
1707
|
+
if ((dataMain = script.getAttribute('data-main'))) {
|
1708
|
+
if (!cfg.baseUrl) {
|
1709
|
+
//Pull off the directory of data-main for use as the
|
1710
|
+
//baseUrl.
|
1711
|
+
src = dataMain.split('/');
|
1712
|
+
mainScript = src.pop();
|
1713
|
+
subPath = src.length ? src.join('/') + '/' : './';
|
1714
|
+
|
1715
|
+
//Set final config.
|
1716
|
+
cfg.baseUrl = subPath;
|
1717
|
+
//Strip off any trailing .js since dataMain is now
|
1718
|
+
//like a module name.
|
1719
|
+
dataMain = mainScript.replace(jsSuffixRegExp, '');
|
1720
|
+
}
|
1721
|
+
|
1722
|
+
//Put the data-main script in the files to load.
|
1723
|
+
cfg.deps = cfg.deps ? cfg.deps.concat(dataMain) : [dataMain];
|
1724
|
+
|
1725
|
+
break;
|
1726
|
+
}
|
1727
|
+
}
|
1728
|
+
}
|
1729
|
+
|
1730
|
+
//Set baseUrl based on config.
|
1731
|
+
s.baseUrl = cfg.baseUrl;
|
1732
|
+
|
1733
|
+
//****** START page load functionality ****************
|
1734
|
+
/**
|
1735
|
+
* Sets the page as loaded and triggers check for all modules loaded.
|
1736
|
+
*/
|
1737
|
+
req.pageLoaded = function () {
|
1738
|
+
if (!s.isPageLoaded) {
|
1739
|
+
s.isPageLoaded = true;
|
1740
|
+
if (scrollIntervalId) {
|
1741
|
+
clearInterval(scrollIntervalId);
|
1742
|
+
}
|
1743
|
+
|
1744
|
+
//Part of a fix for FF < 3.6 where readyState was not set to
|
1745
|
+
//complete so libraries like jQuery that check for readyState
|
1746
|
+
//after page load where not getting initialized correctly.
|
1747
|
+
//Original approach suggested by Andrea Giammarchi:
|
1748
|
+
//http://webreflection.blogspot.com/2009/11/195-chars-to-help-lazy-loading.html
|
1749
|
+
//see other setReadyState reference for the rest of the fix.
|
1750
|
+
if (setReadyState) {
|
1751
|
+
document.readyState = "complete";
|
1752
|
+
}
|
1753
|
+
|
1754
|
+
req.callReady();
|
1755
|
+
}
|
1756
|
+
};
|
1757
|
+
|
1758
|
+
//See if there is nothing waiting across contexts, and if not, trigger
|
1759
|
+
//callReady.
|
1760
|
+
req.checkReadyState = function () {
|
1761
|
+
var contexts = s.contexts, prop;
|
1762
|
+
for (prop in contexts) {
|
1763
|
+
if (!(prop in empty)) {
|
1764
|
+
if (contexts[prop].waitCount) {
|
1765
|
+
return;
|
1766
|
+
}
|
1767
|
+
}
|
1768
|
+
}
|
1769
|
+
s.isDone = true;
|
1770
|
+
req.callReady();
|
1771
|
+
};
|
1772
|
+
|
1773
|
+
/**
|
1774
|
+
* Internal function that calls back any ready functions. If you are
|
1775
|
+
* integrating RequireJS with another library without require.ready support,
|
1776
|
+
* you can define this method to call your page ready code instead.
|
1777
|
+
*/
|
1778
|
+
req.callReady = function () {
|
1779
|
+
var callbacks = s.readyCalls, i, callback, contexts, context, prop;
|
1780
|
+
|
1781
|
+
if (s.isPageLoaded && s.isDone) {
|
1782
|
+
if (callbacks.length) {
|
1783
|
+
s.readyCalls = [];
|
1784
|
+
for (i = 0; (callback = callbacks[i]); i++) {
|
1785
|
+
callback();
|
1786
|
+
}
|
1787
|
+
}
|
1788
|
+
|
1789
|
+
//If jQuery with readyWait is being tracked, updated its
|
1790
|
+
//readyWait count.
|
1791
|
+
contexts = s.contexts;
|
1792
|
+
for (prop in contexts) {
|
1793
|
+
if (!(prop in empty)) {
|
1794
|
+
context = contexts[prop];
|
1795
|
+
if (context.jQueryIncremented) {
|
1796
|
+
context.jQuery.ready(true);
|
1797
|
+
context.jQueryIncremented = false;
|
1798
|
+
}
|
1799
|
+
}
|
1800
|
+
}
|
1801
|
+
}
|
1802
|
+
};
|
1803
|
+
|
1804
|
+
/**
|
1805
|
+
* Registers functions to call when the page is loaded
|
1806
|
+
*/
|
1807
|
+
req.ready = function (callback) {
|
1808
|
+
if (s.isPageLoaded && s.isDone) {
|
1809
|
+
callback();
|
1810
|
+
} else {
|
1811
|
+
s.readyCalls.push(callback);
|
1812
|
+
}
|
1813
|
+
return req;
|
1814
|
+
};
|
1815
|
+
|
1816
|
+
if (isBrowser) {
|
1817
|
+
if (document.addEventListener) {
|
1818
|
+
//Standards. Hooray! Assumption here that if standards based,
|
1819
|
+
//it knows about DOMContentLoaded.
|
1820
|
+
document.addEventListener("DOMContentLoaded", req.pageLoaded, false);
|
1821
|
+
window.addEventListener("load", req.pageLoaded, false);
|
1822
|
+
//Part of FF < 3.6 readystate fix (see setReadyState refs for more info)
|
1823
|
+
if (!document.readyState) {
|
1824
|
+
setReadyState = true;
|
1825
|
+
document.readyState = "loading";
|
1826
|
+
}
|
1827
|
+
} else if (window.attachEvent) {
|
1828
|
+
window.attachEvent("onload", req.pageLoaded);
|
1829
|
+
|
1830
|
+
//DOMContentLoaded approximation, as found by Diego Perini:
|
1831
|
+
//http://javascript.nwbox.com/IEContentLoaded/
|
1832
|
+
if (self === self.top) {
|
1833
|
+
scrollIntervalId = setInterval(function () {
|
1834
|
+
try {
|
1835
|
+
//From this ticket:
|
1836
|
+
//http://bugs.dojotoolkit.org/ticket/11106,
|
1837
|
+
//In IE HTML Application (HTA), such as in a selenium test,
|
1838
|
+
//javascript in the iframe can't see anything outside
|
1839
|
+
//of it, so self===self.top is true, but the iframe is
|
1840
|
+
//not the top window and doScroll will be available
|
1841
|
+
//before document.body is set. Test document.body
|
1842
|
+
//before trying the doScroll trick.
|
1843
|
+
if (document.body) {
|
1844
|
+
document.documentElement.doScroll("left");
|
1845
|
+
req.pageLoaded();
|
1846
|
+
}
|
1847
|
+
} catch (e) {}
|
1848
|
+
}, 30);
|
1849
|
+
}
|
1850
|
+
}
|
1851
|
+
|
1852
|
+
//Check if document already complete, and if so, just trigger page load
|
1853
|
+
//listeners. NOTE: does not work with Firefox before 3.6. To support
|
1854
|
+
//those browsers, manually call require.pageLoaded().
|
1855
|
+
if (document.readyState === "complete") {
|
1856
|
+
req.pageLoaded();
|
1857
|
+
}
|
1858
|
+
}
|
1859
|
+
//****** END page load functionality ****************
|
1860
|
+
|
1861
|
+
//Set up default context. If require was a configuration object, use that as base config.
|
1862
|
+
req(cfg);
|
1863
|
+
|
1864
|
+
//If modules are built into require.js, then need to make sure dependencies are
|
1865
|
+
//traced. Use a setTimeout in the browser world, to allow all the modules to register
|
1866
|
+
//themselves. In a non-browser env, assume that modules are not built into require.js,
|
1867
|
+
//which seems odd to do on the server.
|
1868
|
+
if (req.isAsync && typeof setTimeout !== "undefined") {
|
1869
|
+
ctx = s.contexts[(cfg.context || defContextName)];
|
1870
|
+
//Indicate that the script that includes require() is still loading,
|
1871
|
+
//so that require()'d dependencies are not traced until the end of the
|
1872
|
+
//file is parsed (approximated via the setTimeout call).
|
1873
|
+
ctx.requireWait = true;
|
1874
|
+
setTimeout(function () {
|
1875
|
+
ctx.requireWait = false;
|
1876
|
+
|
1877
|
+
//Any modules included with the require.js file will be in the
|
1878
|
+
//global queue, assign them to this context.
|
1879
|
+
ctx.takeGlobalQueue();
|
1880
|
+
|
1881
|
+
//Allow for jQuery to be loaded/already in the page, and if jQuery 1.4.3,
|
1882
|
+
//make sure to hold onto it for readyWait triggering.
|
1883
|
+
ctx.jQueryCheck();
|
1884
|
+
|
1885
|
+
if (!ctx.scriptCount) {
|
1886
|
+
ctx.resume();
|
1887
|
+
}
|
1888
|
+
req.checkReadyState();
|
1889
|
+
}, 0);
|
1890
|
+
}
|
1891
|
+
}());
|
1892
|
+
|
1893
|
+
define('utils',['require','exports','module'],function(){
|
1894
|
+
return {
|
1895
|
+
log: function(message) {
|
1896
|
+
if(false) { //LOGGING TURNED OFF IS 100% faster!
|
1897
|
+
try {
|
1898
|
+
console.log(message)
|
1899
|
+
}
|
1900
|
+
catch(e) {} //we're in IE or FF w/o Firebug or something
|
1901
|
+
}
|
1902
|
+
},
|
1903
|
+
|
1904
|
+
isArray: function(candidate) {
|
1905
|
+
return (candidate.constructor == Array)
|
1906
|
+
},
|
1907
|
+
|
1908
|
+
forEach: function(list, callback, thisArg) {
|
1909
|
+
if(typeof list.forEach == "function") {
|
1910
|
+
return list.forEach(callback, thisArg)
|
1911
|
+
}
|
1912
|
+
else if(typeof Array.prototype.forEach == "function") {
|
1913
|
+
return Array.prototype.forEach.call(list, callback, thisArg)
|
1914
|
+
}
|
1915
|
+
else {
|
1916
|
+
var len = Number(list.length)
|
1917
|
+
for(var k = 0; k < len; k+=1) {
|
1918
|
+
if(typeof list[k] != "undefined") {
|
1919
|
+
callback.call(thisArg, list[k], k, list)
|
1920
|
+
}
|
1921
|
+
}
|
1922
|
+
return
|
1923
|
+
}
|
1924
|
+
}
|
1925
|
+
}
|
1926
|
+
})
|
1927
|
+
|
1928
|
+
define('ninja/exceptions',['require','exports','module'],function () {
|
1929
|
+
return {
|
1930
|
+
CouldntChoose: function(){},
|
1931
|
+
TransformFailed: function(){}
|
1932
|
+
}
|
1933
|
+
})
|
1934
|
+
define('ninja/behaviors',["ninja/exceptions"], function(Exceptions) {
|
1935
|
+
var CouldntChooseException = Exceptions.CouldntChoose
|
1936
|
+
|
1937
|
+
var behaviors = {
|
1938
|
+
}
|
1939
|
+
|
1940
|
+
behaviors.meta = function(setup, callback) {
|
1941
|
+
setup(this)
|
1942
|
+
this.chooser = callback
|
1943
|
+
}
|
1944
|
+
|
1945
|
+
behaviors.meta.prototype = {
|
1946
|
+
choose: function(element) {
|
1947
|
+
var chosen = this.chooser(element)
|
1948
|
+
if(chosen !== undefined) {
|
1949
|
+
return chosen.choose(element)
|
1950
|
+
}
|
1951
|
+
else {
|
1952
|
+
throw new CouldntChooseException
|
1953
|
+
}
|
1954
|
+
}
|
1955
|
+
}
|
1956
|
+
|
1957
|
+
//For these to be acceptable, I need to fit them into the pattern that
|
1958
|
+
//Ninja.behavior accepts...
|
1959
|
+
behaviors.select = function(menu) {
|
1960
|
+
this.menu = menu
|
1961
|
+
}
|
1962
|
+
|
1963
|
+
behaviors.select.prototype = {
|
1964
|
+
choose: function(element) {
|
1965
|
+
for(var selector in this.menu) {
|
1966
|
+
if(jQuery(element).is(selector)) {
|
1967
|
+
return this.menu[selector].choose(element)
|
1968
|
+
}
|
1969
|
+
}
|
1970
|
+
return null //XXX Should raise exception
|
1971
|
+
}
|
1972
|
+
}
|
1973
|
+
|
1974
|
+
behaviors.base = function(handlers) {
|
1975
|
+
this.helpers = {}
|
1976
|
+
this.eventHandlers = []
|
1977
|
+
this.lexicalOrder = 0
|
1978
|
+
this.priority = 0
|
1979
|
+
|
1980
|
+
if (typeof handlers.transform == "function") {
|
1981
|
+
this.transform = handlers.transform
|
1982
|
+
delete handlers.transform
|
1983
|
+
}
|
1984
|
+
if (typeof handlers.helpers != "undefined"){
|
1985
|
+
this.helpers = handlers.helpers
|
1986
|
+
delete handlers.helpers
|
1987
|
+
}
|
1988
|
+
if (typeof handlers.priority != "undefined"){
|
1989
|
+
this.priority = handlers.priority
|
1990
|
+
}
|
1991
|
+
delete handlers.priority
|
1992
|
+
if (typeof handlers.events != "undefined") {
|
1993
|
+
this.eventHandlers = handlers.events
|
1994
|
+
}
|
1995
|
+
else {
|
1996
|
+
this.eventHandlers = handlers
|
1997
|
+
}
|
1998
|
+
|
1999
|
+
return this
|
2000
|
+
}
|
2001
|
+
|
2002
|
+
behaviors.base.prototype = {
|
2003
|
+
//XXX applyTo?
|
2004
|
+
apply: function(elem) {
|
2005
|
+
var context = this.inContext({})
|
2006
|
+
|
2007
|
+
elem = this.applyTransform(context, elem)
|
2008
|
+
jQuery(elem).data("ninja-visited", context)
|
2009
|
+
|
2010
|
+
this.applyEventHandlers(context, elem)
|
2011
|
+
|
2012
|
+
return elem
|
2013
|
+
},
|
2014
|
+
priority: function(value) {
|
2015
|
+
this.priority = value
|
2016
|
+
return this
|
2017
|
+
},
|
2018
|
+
choose: function(element) {
|
2019
|
+
return this
|
2020
|
+
},
|
2021
|
+
inContext: function(basedOn) {
|
2022
|
+
function Context() {}
|
2023
|
+
Context.prototype = basedOn
|
2024
|
+
return Ninja.tools.enrich(new Context, this.helpers)
|
2025
|
+
},
|
2026
|
+
applyTransform: function(context, elem) {
|
2027
|
+
var previousElem = elem
|
2028
|
+
var newElem = this.transform.call(context, elem)
|
2029
|
+
if(newElem === undefined) {
|
2030
|
+
return previousElem
|
2031
|
+
}
|
2032
|
+
else {
|
2033
|
+
return newElem
|
2034
|
+
}
|
2035
|
+
},
|
2036
|
+
applyEventHandlers: function(context, elem) {
|
2037
|
+
for(var eventName in this.eventHandlers) {
|
2038
|
+
var handler = this.eventHandlers[eventName]
|
2039
|
+
jQuery(elem).bind(eventName, this.makeHandler.call(context, handler))
|
2040
|
+
}
|
2041
|
+
return elem
|
2042
|
+
},
|
2043
|
+
recordEventHandlers: function(scribe, context) {
|
2044
|
+
for(var eventName in this.eventHandlers) {
|
2045
|
+
scribe.recordHandler(this, eventName, function(oldHandler){
|
2046
|
+
return this.makeHandler.call(context, this.eventHandlers[eventName], oldHandler)
|
2047
|
+
}
|
2048
|
+
)
|
2049
|
+
}
|
2050
|
+
},
|
2051
|
+
buildHandler: function(context, eventName, previousHandler) {
|
2052
|
+
var handle
|
2053
|
+
var fallThrough = true
|
2054
|
+
var stopDefault = true
|
2055
|
+
var stopPropagate = true
|
2056
|
+
var stopImmediate = false
|
2057
|
+
var fireMutation = false
|
2058
|
+
var config = this.eventHandlers[eventName]
|
2059
|
+
|
2060
|
+
if (typeof config == "function") {
|
2061
|
+
handle = config
|
2062
|
+
}
|
2063
|
+
else {
|
2064
|
+
handle = config[0]
|
2065
|
+
config = config.slice(1,config.length)
|
2066
|
+
var len = config.length
|
2067
|
+
for(var i = 0; i < len; i++) {
|
2068
|
+
var found = true
|
2069
|
+
if (config[i] == "dontContinue" ||
|
2070
|
+
config[i] == "overridesOthers") {
|
2071
|
+
fallThrough = false
|
2072
|
+
}
|
2073
|
+
if (config[i] == "andDoDefault" ||
|
2074
|
+
config[i] == "continues" ||
|
2075
|
+
config[i] == "allowDefault") {
|
2076
|
+
stopDefault = false
|
2077
|
+
}
|
2078
|
+
if (config[i] == "allowPropagate" || config[i] == "dontStopPropagation") {
|
2079
|
+
stopPropagate = false
|
2080
|
+
}
|
2081
|
+
//stopImmediatePropagation is a jQuery thing
|
2082
|
+
if (config[i] == "andDoOthers") {
|
2083
|
+
stopImmediate = false
|
2084
|
+
}
|
2085
|
+
if (config[i] == "changesDOM") {
|
2086
|
+
fireMutation = true
|
2087
|
+
}
|
2088
|
+
if (!found) {
|
2089
|
+
console.log("Event handler modifier unrecognized: " + config[i])
|
2090
|
+
}
|
2091
|
+
}
|
2092
|
+
}
|
2093
|
+
var handler = function(eventRecord) {
|
2094
|
+
handle.call(context, eventRecord, this)
|
2095
|
+
if(!eventRecord.isFallthroughPrevented()) {
|
2096
|
+
previousHandler.call(context, eventRecord)
|
2097
|
+
}
|
2098
|
+
if(stopDefault){
|
2099
|
+
return false
|
2100
|
+
} else {
|
2101
|
+
return !eventRecord.isDefaultPrevented()
|
2102
|
+
}
|
2103
|
+
}
|
2104
|
+
if(!fallThrough) {
|
2105
|
+
handler = this.prependAction(handler, function(eventRecord) {
|
2106
|
+
eventRecord.preventFallthrough()
|
2107
|
+
})
|
2108
|
+
}
|
2109
|
+
if(stopDefault) {
|
2110
|
+
handler = this.prependAction(handler, function(eventRecord) {
|
2111
|
+
eventRecord.preventDefault()
|
2112
|
+
})
|
2113
|
+
}
|
2114
|
+
if(stopPropagate) {
|
2115
|
+
handler = this.prependAction(handler, function(eventRecord) {
|
2116
|
+
eventRecord.stopPropagation()
|
2117
|
+
})
|
2118
|
+
}
|
2119
|
+
if (stopImmediate) {
|
2120
|
+
handler = this.prependAction(handler, function(eventRecord) {
|
2121
|
+
eventRecord.stopImmediatePropagation()
|
2122
|
+
})
|
2123
|
+
}
|
2124
|
+
if (fireMutation) {
|
2125
|
+
handler = this.appendAction(handler, function(eventRecord) {
|
2126
|
+
Ninja.tools.fireMutationEvent()
|
2127
|
+
})
|
2128
|
+
}
|
2129
|
+
handler = this.prependAction(handler, function(eventRecord) {
|
2130
|
+
eventRecord.isFallthroughPrevented = function(){ return false };
|
2131
|
+
eventRecord.preventFallthrough = function(){
|
2132
|
+
eventRecord.isFallthroughPrevented =function(){ return true };
|
2133
|
+
}
|
2134
|
+
})
|
2135
|
+
|
2136
|
+
return handler
|
2137
|
+
},
|
2138
|
+
prependAction: function(handler, doWhat) {
|
2139
|
+
return function(eventRecord) {
|
2140
|
+
doWhat.call(this, eventRecord)
|
2141
|
+
return handler.call(this, eventRecord)
|
2142
|
+
}
|
2143
|
+
},
|
2144
|
+
appendAction: function(handler, doWhat) {
|
2145
|
+
return function(eventRecord) {
|
2146
|
+
var result = handler.call(this, eventRecord)
|
2147
|
+
doWhat.call(this, eventRecord)
|
2148
|
+
return result
|
2149
|
+
}
|
2150
|
+
},
|
2151
|
+
transform: function(elem){
|
2152
|
+
return elem
|
2153
|
+
}
|
2154
|
+
}
|
2155
|
+
|
2156
|
+
return behaviors
|
2157
|
+
})
|
2158
|
+
define('sizzle-1.0',['require','exports','module'],function() {
|
2159
|
+
/*
|
2160
|
+
* Sizzle CSS engine
|
2161
|
+
* Copyright 2009 The Dojo Foundation
|
2162
|
+
* Released under the MIT, BSD, and GPL Licenses.
|
2163
|
+
*
|
2164
|
+
* This version of the Sizzle engine taken from jQuery 1.4.2
|
2165
|
+
* Doesn't conflict with Mutation events.
|
2166
|
+
*/
|
2167
|
+
|
2168
|
+
var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,
|
2169
|
+
done = 0,
|
2170
|
+
toString = Object.prototype.toString,
|
2171
|
+
hasDuplicate = false,
|
2172
|
+
baseHasDuplicate = true;
|
2173
|
+
|
2174
|
+
// Here we check if the JavaScript engine is using some sort of
|
2175
|
+
// optimization where it does not always call our comparision
|
2176
|
+
// function. If that is the case, discard the hasDuplicate value.
|
2177
|
+
// Thus far that includes Google Chrome.
|
2178
|
+
[0, 0].sort(function(){
|
2179
|
+
baseHasDuplicate = false;
|
2180
|
+
return 0;
|
2181
|
+
});
|
2182
|
+
|
2183
|
+
var Sizzle = function(selector, context, results, seed) {
|
2184
|
+
results = results || [];
|
2185
|
+
var origContext = context = context || document;
|
2186
|
+
|
2187
|
+
if ( context.nodeType !== 1 && context.nodeType !== 9 ) {
|
2188
|
+
return [];
|
2189
|
+
}
|
2190
|
+
|
2191
|
+
if ( !selector || typeof selector !== "string" ) {
|
2192
|
+
return results;
|
2193
|
+
}
|
2194
|
+
|
2195
|
+
var parts = [], m, set, checkSet, extra, prune = true, contextXML = isXML(context),
|
2196
|
+
soFar = selector;
|
2197
|
+
|
2198
|
+
// Reset the position of the chunker regexp (start from head)
|
2199
|
+
while ( (chunker.exec(""), m = chunker.exec(soFar)) !== null ) {
|
2200
|
+
soFar = m[3];
|
2201
|
+
|
2202
|
+
parts.push( m[1] );
|
2203
|
+
|
2204
|
+
if ( m[2] ) {
|
2205
|
+
extra = m[3];
|
2206
|
+
break;
|
2207
|
+
}
|
2208
|
+
}
|
2209
|
+
|
2210
|
+
if ( parts.length > 1 && origPOS.exec( selector ) ) {
|
2211
|
+
if ( parts.length === 2 && Expr.relative[ parts[0] ] ) {
|
2212
|
+
set = posProcess( parts[0] + parts[1], context );
|
2213
|
+
} else {
|
2214
|
+
set = Expr.relative[ parts[0] ] ?
|
2215
|
+
[ context ] :
|
2216
|
+
Sizzle( parts.shift(), context );
|
2217
|
+
|
2218
|
+
while ( parts.length ) {
|
2219
|
+
selector = parts.shift();
|
2220
|
+
|
2221
|
+
if ( Expr.relative[ selector ] ) {
|
2222
|
+
selector += parts.shift();
|
2223
|
+
}
|
2224
|
+
|
2225
|
+
set = posProcess( selector, set );
|
2226
|
+
}
|
2227
|
+
}
|
2228
|
+
} else {
|
2229
|
+
// Take a shortcut and set the context if the root selector is an ID
|
2230
|
+
// (but not if it'll be faster if the inner selector is an ID)
|
2231
|
+
if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML &&
|
2232
|
+
Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) {
|
2233
|
+
var ret = Sizzle.find( parts.shift(), context, contextXML );
|
2234
|
+
context = ret.expr ? Sizzle.filter( ret.expr, ret.set )[0] : ret.set[0];
|
2235
|
+
}
|
2236
|
+
|
2237
|
+
if ( context ) {
|
2238
|
+
var ret = seed ?
|
2239
|
+
{ expr: parts.pop(), set: makeArray(seed) } :
|
2240
|
+
Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML );
|
2241
|
+
set = ret.expr ? Sizzle.filter( ret.expr, ret.set ) : ret.set;
|
2242
|
+
|
2243
|
+
if ( parts.length > 0 ) {
|
2244
|
+
checkSet = makeArray(set);
|
2245
|
+
} else {
|
2246
|
+
prune = false;
|
2247
|
+
}
|
2248
|
+
|
2249
|
+
while ( parts.length ) {
|
2250
|
+
var cur = parts.pop(), pop = cur;
|
2251
|
+
|
2252
|
+
if ( !Expr.relative[ cur ] ) {
|
2253
|
+
cur = "";
|
2254
|
+
} else {
|
2255
|
+
pop = parts.pop();
|
2256
|
+
}
|
2257
|
+
|
2258
|
+
if ( pop == null ) {
|
2259
|
+
pop = context;
|
2260
|
+
}
|
2261
|
+
|
2262
|
+
Expr.relative[ cur ]( checkSet, pop, contextXML );
|
2263
|
+
}
|
2264
|
+
} else {
|
2265
|
+
checkSet = parts = [];
|
2266
|
+
}
|
2267
|
+
}
|
2268
|
+
|
2269
|
+
if ( !checkSet ) {
|
2270
|
+
checkSet = set;
|
2271
|
+
}
|
2272
|
+
|
2273
|
+
if ( !checkSet ) {
|
2274
|
+
Sizzle.error( cur || selector );
|
2275
|
+
}
|
2276
|
+
|
2277
|
+
if ( toString.call(checkSet) === "[object Array]" ) {
|
2278
|
+
if ( !prune ) {
|
2279
|
+
results.push.apply( results, checkSet );
|
2280
|
+
} else if ( context && context.nodeType === 1 ) {
|
2281
|
+
for ( var i = 0; checkSet[i] != null; i++ ) {
|
2282
|
+
if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && contains(context, checkSet[i])) ) {
|
2283
|
+
results.push( set[i] );
|
2284
|
+
}
|
2285
|
+
}
|
2286
|
+
} else {
|
2287
|
+
for ( var i = 0; checkSet[i] != null; i++ ) {
|
2288
|
+
if ( checkSet[i] && checkSet[i].nodeType === 1 ) {
|
2289
|
+
results.push( set[i] );
|
2290
|
+
}
|
2291
|
+
}
|
2292
|
+
}
|
2293
|
+
} else {
|
2294
|
+
makeArray( checkSet, results );
|
2295
|
+
}
|
2296
|
+
|
2297
|
+
if ( extra ) {
|
2298
|
+
Sizzle( extra, origContext, results, seed );
|
2299
|
+
Sizzle.uniqueSort( results );
|
2300
|
+
}
|
2301
|
+
|
2302
|
+
return results;
|
2303
|
+
};
|
2304
|
+
|
2305
|
+
Sizzle.uniqueSort = function(results){
|
2306
|
+
if ( sortOrder ) {
|
2307
|
+
hasDuplicate = baseHasDuplicate;
|
2308
|
+
results.sort(sortOrder);
|
2309
|
+
|
2310
|
+
if ( hasDuplicate ) {
|
2311
|
+
for ( var i = 1; i < results.length; i++ ) {
|
2312
|
+
if ( results[i] === results[i-1] ) {
|
2313
|
+
results.splice(i--, 1);
|
2314
|
+
}
|
2315
|
+
}
|
2316
|
+
}
|
2317
|
+
}
|
2318
|
+
|
2319
|
+
return results;
|
2320
|
+
};
|
2321
|
+
|
2322
|
+
Sizzle.matches = function(expr, set){
|
2323
|
+
return Sizzle(expr, null, null, set);
|
2324
|
+
};
|
2325
|
+
|
2326
|
+
Sizzle.find = function(expr, context, isXML){
|
2327
|
+
var set, match;
|
2328
|
+
|
2329
|
+
if ( !expr ) {
|
2330
|
+
return [];
|
2331
|
+
}
|
2332
|
+
|
2333
|
+
for ( var i = 0, l = Expr.order.length; i < l; i++ ) {
|
2334
|
+
var type = Expr.order[i], match;
|
2335
|
+
|
2336
|
+
if ( (match = Expr.leftMatch[ type ].exec( expr )) ) {
|
2337
|
+
var left = match[1];
|
2338
|
+
match.splice(1,1);
|
2339
|
+
|
2340
|
+
if ( left.substr( left.length - 1 ) !== "\\" ) {
|
2341
|
+
match[1] = (match[1] || "").replace(/\\/g, "");
|
2342
|
+
set = Expr.find[ type ]( match, context, isXML );
|
2343
|
+
if ( set != null ) {
|
2344
|
+
expr = expr.replace( Expr.match[ type ], "" );
|
2345
|
+
break;
|
2346
|
+
}
|
2347
|
+
}
|
2348
|
+
}
|
2349
|
+
}
|
2350
|
+
|
2351
|
+
if ( !set ) {
|
2352
|
+
set = context.getElementsByTagName("*");
|
2353
|
+
}
|
2354
|
+
|
2355
|
+
return {set: set, expr: expr};
|
2356
|
+
};
|
2357
|
+
|
2358
|
+
Sizzle.filter = function(expr, set, inplace, not){
|
2359
|
+
var old = expr, result = [], curLoop = set, match, anyFound,
|
2360
|
+
isXMLFilter = set && set[0] && isXML(set[0]);
|
2361
|
+
|
2362
|
+
while ( expr && set.length ) {
|
2363
|
+
for ( var type in Expr.filter ) {
|
2364
|
+
if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) {
|
2365
|
+
var filter = Expr.filter[ type ], found, item, left = match[1];
|
2366
|
+
anyFound = false;
|
2367
|
+
|
2368
|
+
match.splice(1,1);
|
2369
|
+
|
2370
|
+
if ( left.substr( left.length - 1 ) === "\\" ) {
|
2371
|
+
continue;
|
2372
|
+
}
|
2373
|
+
|
2374
|
+
if ( curLoop === result ) {
|
2375
|
+
result = [];
|
2376
|
+
}
|
2377
|
+
|
2378
|
+
if ( Expr.preFilter[ type ] ) {
|
2379
|
+
match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter );
|
2380
|
+
|
2381
|
+
if ( !match ) {
|
2382
|
+
anyFound = found = true;
|
2383
|
+
} else if ( match === true ) {
|
2384
|
+
continue;
|
2385
|
+
}
|
2386
|
+
}
|
2387
|
+
|
2388
|
+
if ( match ) {
|
2389
|
+
for ( var i = 0; (item = curLoop[i]) != null; i++ ) {
|
2390
|
+
if ( item ) {
|
2391
|
+
found = filter( item, match, i, curLoop );
|
2392
|
+
var pass = not ^ !!found;
|
2393
|
+
|
2394
|
+
if ( inplace && found != null ) {
|
2395
|
+
if ( pass ) {
|
2396
|
+
anyFound = true;
|
2397
|
+
} else {
|
2398
|
+
curLoop[i] = false;
|
2399
|
+
}
|
2400
|
+
} else if ( pass ) {
|
2401
|
+
result.push( item );
|
2402
|
+
anyFound = true;
|
2403
|
+
}
|
2404
|
+
}
|
2405
|
+
}
|
2406
|
+
}
|
2407
|
+
|
2408
|
+
if ( found !== undefined ) {
|
2409
|
+
if ( !inplace ) {
|
2410
|
+
curLoop = result;
|
2411
|
+
}
|
2412
|
+
|
2413
|
+
expr = expr.replace( Expr.match[ type ], "" );
|
2414
|
+
|
2415
|
+
if ( !anyFound ) {
|
2416
|
+
return [];
|
2417
|
+
}
|
2418
|
+
|
2419
|
+
break;
|
2420
|
+
}
|
2421
|
+
}
|
2422
|
+
}
|
2423
|
+
|
2424
|
+
// Improper expression
|
2425
|
+
if ( expr === old ) {
|
2426
|
+
if ( anyFound == null ) {
|
2427
|
+
Sizzle.error( expr );
|
2428
|
+
} else {
|
2429
|
+
break;
|
2430
|
+
}
|
2431
|
+
}
|
2432
|
+
|
2433
|
+
old = expr;
|
2434
|
+
}
|
2435
|
+
|
2436
|
+
return curLoop;
|
2437
|
+
};
|
2438
|
+
|
2439
|
+
Sizzle.error = function( msg ) {
|
2440
|
+
throw "Syntax error, unrecognized expression: " + msg;
|
2441
|
+
};
|
2442
|
+
|
2443
|
+
var Expr = Sizzle.selectors = {
|
2444
|
+
order: [ "ID", "NAME", "TAG" ],
|
2445
|
+
match: {
|
2446
|
+
ID: /#((?:[\w\u00c0-\uFFFF-]|\\.)+)/,
|
2447
|
+
CLASS: /\.((?:[\w\u00c0-\uFFFF-]|\\.)+)/,
|
2448
|
+
NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF-]|\\.)+)['"]*\]/,
|
2449
|
+
ATTR: /\[\s*((?:[\w\u00c0-\uFFFF-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/,
|
2450
|
+
TAG: /^((?:[\w\u00c0-\uFFFF\*-]|\\.)+)/,
|
2451
|
+
CHILD: /:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/,
|
2452
|
+
POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/,
|
2453
|
+
PSEUDO: /:((?:[\w\u00c0-\uFFFF-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/
|
2454
|
+
},
|
2455
|
+
leftMatch: {},
|
2456
|
+
attrMap: {
|
2457
|
+
"class": "className",
|
2458
|
+
"for": "htmlFor"
|
2459
|
+
},
|
2460
|
+
attrHandle: {
|
2461
|
+
href: function(elem){
|
2462
|
+
return elem.getAttribute("href");
|
2463
|
+
}
|
2464
|
+
},
|
2465
|
+
relative: {
|
2466
|
+
"+": function(checkSet, part){
|
2467
|
+
var isPartStr = typeof part === "string",
|
2468
|
+
isTag = isPartStr && !/\W/.test(part),
|
2469
|
+
isPartStrNotTag = isPartStr && !isTag;
|
2470
|
+
|
2471
|
+
if ( isTag ) {
|
2472
|
+
part = part.toLowerCase();
|
2473
|
+
}
|
2474
|
+
|
2475
|
+
for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) {
|
2476
|
+
if ( (elem = checkSet[i]) ) {
|
2477
|
+
while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {}
|
2478
|
+
|
2479
|
+
checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ?
|
2480
|
+
elem || false :
|
2481
|
+
elem === part;
|
2482
|
+
}
|
2483
|
+
}
|
2484
|
+
|
2485
|
+
if ( isPartStrNotTag ) {
|
2486
|
+
Sizzle.filter( part, checkSet, true );
|
2487
|
+
}
|
2488
|
+
},
|
2489
|
+
">": function(checkSet, part){
|
2490
|
+
var isPartStr = typeof part === "string";
|
2491
|
+
|
2492
|
+
if ( isPartStr && !/\W/.test(part) ) {
|
2493
|
+
part = part.toLowerCase();
|
2494
|
+
|
2495
|
+
for ( var i = 0, l = checkSet.length; i < l; i++ ) {
|
2496
|
+
var elem = checkSet[i];
|
2497
|
+
if ( elem ) {
|
2498
|
+
var parent = elem.parentNode;
|
2499
|
+
checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false;
|
2500
|
+
}
|
2501
|
+
}
|
2502
|
+
} else {
|
2503
|
+
for ( var i = 0, l = checkSet.length; i < l; i++ ) {
|
2504
|
+
var elem = checkSet[i];
|
2505
|
+
if ( elem ) {
|
2506
|
+
checkSet[i] = isPartStr ?
|
2507
|
+
elem.parentNode :
|
2508
|
+
elem.parentNode === part;
|
2509
|
+
}
|
2510
|
+
}
|
2511
|
+
|
2512
|
+
if ( isPartStr ) {
|
2513
|
+
Sizzle.filter( part, checkSet, true );
|
2514
|
+
}
|
2515
|
+
}
|
2516
|
+
},
|
2517
|
+
"": function(checkSet, part, isXML){
|
2518
|
+
var doneName = done++, checkFn = dirCheck;
|
2519
|
+
|
2520
|
+
if ( typeof part === "string" && !/\W/.test(part) ) {
|
2521
|
+
var nodeCheck = part = part.toLowerCase();
|
2522
|
+
checkFn = dirNodeCheck;
|
2523
|
+
}
|
2524
|
+
|
2525
|
+
checkFn("parentNode", part, doneName, checkSet, nodeCheck, isXML);
|
2526
|
+
},
|
2527
|
+
"~": function(checkSet, part, isXML){
|
2528
|
+
var doneName = done++, checkFn = dirCheck;
|
2529
|
+
|
2530
|
+
if ( typeof part === "string" && !/\W/.test(part) ) {
|
2531
|
+
var nodeCheck = part = part.toLowerCase();
|
2532
|
+
checkFn = dirNodeCheck;
|
2533
|
+
}
|
2534
|
+
|
2535
|
+
checkFn("previousSibling", part, doneName, checkSet, nodeCheck, isXML);
|
2536
|
+
}
|
2537
|
+
},
|
2538
|
+
find: {
|
2539
|
+
ID: function(match, context, isXML){
|
2540
|
+
if ( typeof context.getElementById !== "undefined" && !isXML ) {
|
2541
|
+
var m = context.getElementById(match[1]);
|
2542
|
+
return m ? [m] : [];
|
2543
|
+
}
|
2544
|
+
},
|
2545
|
+
NAME: function(match, context){
|
2546
|
+
if ( typeof context.getElementsByName !== "undefined" ) {
|
2547
|
+
var ret = [], results = context.getElementsByName(match[1]);
|
2548
|
+
|
2549
|
+
for ( var i = 0, l = results.length; i < l; i++ ) {
|
2550
|
+
if ( results[i].getAttribute("name") === match[1] ) {
|
2551
|
+
ret.push( results[i] );
|
2552
|
+
}
|
2553
|
+
}
|
2554
|
+
|
2555
|
+
return ret.length === 0 ? null : ret;
|
2556
|
+
}
|
2557
|
+
},
|
2558
|
+
TAG: function(match, context){
|
2559
|
+
return context.getElementsByTagName(match[1]);
|
2560
|
+
}
|
2561
|
+
},
|
2562
|
+
preFilter: {
|
2563
|
+
CLASS: function(match, curLoop, inplace, result, not, isXML){
|
2564
|
+
match = " " + match[1].replace(/\\/g, "") + " ";
|
2565
|
+
|
2566
|
+
if ( isXML ) {
|
2567
|
+
return match;
|
2568
|
+
}
|
2569
|
+
|
2570
|
+
for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) {
|
2571
|
+
if ( elem ) {
|
2572
|
+
if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n]/g, " ").indexOf(match) >= 0) ) {
|
2573
|
+
if ( !inplace ) {
|
2574
|
+
result.push( elem );
|
2575
|
+
}
|
2576
|
+
} else if ( inplace ) {
|
2577
|
+
curLoop[i] = false;
|
2578
|
+
}
|
2579
|
+
}
|
2580
|
+
}
|
2581
|
+
|
2582
|
+
return false;
|
2583
|
+
},
|
2584
|
+
ID: function(match){
|
2585
|
+
return match[1].replace(/\\/g, "");
|
2586
|
+
},
|
2587
|
+
TAG: function(match, curLoop){
|
2588
|
+
return match[1].toLowerCase();
|
2589
|
+
},
|
2590
|
+
CHILD: function(match){
|
2591
|
+
if ( match[1] === "nth" ) {
|
2592
|
+
// parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
|
2593
|
+
var test = /(-?)(\d*)n((?:\+|-)?\d*)/.exec(
|
2594
|
+
match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" ||
|
2595
|
+
!/\D/.test( match[2] ) && "0n+" + match[2] || match[2]);
|
2596
|
+
|
2597
|
+
// calculate the numbers (first)n+(last) including if they are negative
|
2598
|
+
match[2] = (test[1] + (test[2] || 1)) - 0;
|
2599
|
+
match[3] = test[3] - 0;
|
2600
|
+
}
|
2601
|
+
|
2602
|
+
// TODO: Move to normal caching system
|
2603
|
+
match[0] = done++;
|
2604
|
+
|
2605
|
+
return match;
|
2606
|
+
},
|
2607
|
+
ATTR: function(match, curLoop, inplace, result, not, isXML){
|
2608
|
+
var name = match[1].replace(/\\/g, "");
|
2609
|
+
|
2610
|
+
if ( !isXML && Expr.attrMap[name] ) {
|
2611
|
+
match[1] = Expr.attrMap[name];
|
2612
|
+
}
|
2613
|
+
|
2614
|
+
if ( match[2] === "~=" ) {
|
2615
|
+
match[4] = " " + match[4] + " ";
|
2616
|
+
}
|
2617
|
+
|
2618
|
+
return match;
|
2619
|
+
},
|
2620
|
+
PSEUDO: function(match, curLoop, inplace, result, not){
|
2621
|
+
if ( match[1] === "not" ) {
|
2622
|
+
// If we're dealing with a complex expression, or a simple one
|
2623
|
+
if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) {
|
2624
|
+
match[3] = Sizzle(match[3], null, null, curLoop);
|
2625
|
+
} else {
|
2626
|
+
var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not);
|
2627
|
+
if ( !inplace ) {
|
2628
|
+
result.push.apply( result, ret );
|
2629
|
+
}
|
2630
|
+
return false;
|
2631
|
+
}
|
2632
|
+
} else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) {
|
2633
|
+
return true;
|
2634
|
+
}
|
2635
|
+
|
2636
|
+
return match;
|
2637
|
+
},
|
2638
|
+
POS: function(match){
|
2639
|
+
match.unshift( true );
|
2640
|
+
return match;
|
2641
|
+
}
|
2642
|
+
},
|
2643
|
+
filters: {
|
2644
|
+
enabled: function(elem){
|
2645
|
+
return elem.disabled === false && elem.type !== "hidden";
|
2646
|
+
},
|
2647
|
+
disabled: function(elem){
|
2648
|
+
return elem.disabled === true;
|
2649
|
+
},
|
2650
|
+
checked: function(elem){
|
2651
|
+
return elem.checked === true;
|
2652
|
+
},
|
2653
|
+
selected: function(elem){
|
2654
|
+
// Accessing this property makes selected-by-default
|
2655
|
+
// options in Safari work properly
|
2656
|
+
elem.parentNode.selectedIndex;
|
2657
|
+
return elem.selected === true;
|
2658
|
+
},
|
2659
|
+
parent: function(elem){
|
2660
|
+
return !!elem.firstChild;
|
2661
|
+
},
|
2662
|
+
empty: function(elem){
|
2663
|
+
return !elem.firstChild;
|
2664
|
+
},
|
2665
|
+
has: function(elem, i, match){
|
2666
|
+
return !!Sizzle( match[3], elem ).length;
|
2667
|
+
},
|
2668
|
+
header: function(elem){
|
2669
|
+
return /h\d/i.test( elem.nodeName );
|
2670
|
+
},
|
2671
|
+
text: function(elem){
|
2672
|
+
return "text" === elem.type;
|
2673
|
+
},
|
2674
|
+
radio: function(elem){
|
2675
|
+
return "radio" === elem.type;
|
2676
|
+
},
|
2677
|
+
checkbox: function(elem){
|
2678
|
+
return "checkbox" === elem.type;
|
2679
|
+
},
|
2680
|
+
file: function(elem){
|
2681
|
+
return "file" === elem.type;
|
2682
|
+
},
|
2683
|
+
password: function(elem){
|
2684
|
+
return "password" === elem.type;
|
2685
|
+
},
|
2686
|
+
submit: function(elem){
|
2687
|
+
return "submit" === elem.type;
|
2688
|
+
},
|
2689
|
+
image: function(elem){
|
2690
|
+
return "image" === elem.type;
|
2691
|
+
},
|
2692
|
+
reset: function(elem){
|
2693
|
+
return "reset" === elem.type;
|
2694
|
+
},
|
2695
|
+
button: function(elem){
|
2696
|
+
return "button" === elem.type || elem.nodeName.toLowerCase() === "button";
|
2697
|
+
},
|
2698
|
+
input: function(elem){
|
2699
|
+
return /input|select|textarea|button/i.test(elem.nodeName);
|
2700
|
+
}
|
2701
|
+
},
|
2702
|
+
setFilters: {
|
2703
|
+
first: function(elem, i){
|
2704
|
+
return i === 0;
|
2705
|
+
},
|
2706
|
+
last: function(elem, i, match, array){
|
2707
|
+
return i === array.length - 1;
|
2708
|
+
},
|
2709
|
+
even: function(elem, i){
|
2710
|
+
return i % 2 === 0;
|
2711
|
+
},
|
2712
|
+
odd: function(elem, i){
|
2713
|
+
return i % 2 === 1;
|
2714
|
+
},
|
2715
|
+
lt: function(elem, i, match){
|
2716
|
+
return i < match[3] - 0;
|
2717
|
+
},
|
2718
|
+
gt: function(elem, i, match){
|
2719
|
+
return i > match[3] - 0;
|
2720
|
+
},
|
2721
|
+
nth: function(elem, i, match){
|
2722
|
+
return match[3] - 0 === i;
|
2723
|
+
},
|
2724
|
+
eq: function(elem, i, match){
|
2725
|
+
return match[3] - 0 === i;
|
2726
|
+
}
|
2727
|
+
},
|
2728
|
+
filter: {
|
2729
|
+
PSEUDO: function(elem, match, i, array){
|
2730
|
+
var name = match[1], filter = Expr.filters[ name ];
|
2731
|
+
|
2732
|
+
if ( filter ) {
|
2733
|
+
return filter( elem, i, match, array );
|
2734
|
+
} else if ( name === "contains" ) {
|
2735
|
+
return (elem.textContent || elem.innerText || getText([ elem ]) || "").indexOf(match[3]) >= 0;
|
2736
|
+
} else if ( name === "not" ) {
|
2737
|
+
var not = match[3];
|
2738
|
+
|
2739
|
+
for ( var i = 0, l = not.length; i < l; i++ ) {
|
2740
|
+
if ( not[i] === elem ) {
|
2741
|
+
return false;
|
2742
|
+
}
|
2743
|
+
}
|
2744
|
+
|
2745
|
+
return true;
|
2746
|
+
} else {
|
2747
|
+
Sizzle.error( "Syntax error, unrecognized expression: " + name );
|
2748
|
+
}
|
2749
|
+
},
|
2750
|
+
CHILD: function(elem, match){
|
2751
|
+
var type = match[1], node = elem;
|
2752
|
+
switch (type) {
|
2753
|
+
case 'only':
|
2754
|
+
case 'first':
|
2755
|
+
while ( (node = node.previousSibling) ) {
|
2756
|
+
if ( node.nodeType === 1 ) {
|
2757
|
+
return false;
|
2758
|
+
}
|
2759
|
+
}
|
2760
|
+
if ( type === "first" ) {
|
2761
|
+
return true;
|
2762
|
+
}
|
2763
|
+
node = elem;
|
2764
|
+
case 'last':
|
2765
|
+
while ( (node = node.nextSibling) ) {
|
2766
|
+
if ( node.nodeType === 1 ) {
|
2767
|
+
return false;
|
2768
|
+
}
|
2769
|
+
}
|
2770
|
+
return true;
|
2771
|
+
case 'nth':
|
2772
|
+
var first = match[2], last = match[3];
|
2773
|
+
|
2774
|
+
if ( first === 1 && last === 0 ) {
|
2775
|
+
return true;
|
2776
|
+
}
|
2777
|
+
|
2778
|
+
var doneName = match[0],
|
2779
|
+
parent = elem.parentNode;
|
2780
|
+
|
2781
|
+
if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) {
|
2782
|
+
var count = 0;
|
2783
|
+
for ( node = parent.firstChild; node; node = node.nextSibling ) {
|
2784
|
+
if ( node.nodeType === 1 ) {
|
2785
|
+
node.nodeIndex = ++count;
|
2786
|
+
}
|
2787
|
+
}
|
2788
|
+
parent.sizcache = doneName;
|
2789
|
+
}
|
2790
|
+
|
2791
|
+
var diff = elem.nodeIndex - last;
|
2792
|
+
if ( first === 0 ) {
|
2793
|
+
return diff === 0;
|
2794
|
+
} else {
|
2795
|
+
return ( diff % first === 0 && diff / first >= 0 );
|
2796
|
+
}
|
2797
|
+
}
|
2798
|
+
},
|
2799
|
+
ID: function(elem, match){
|
2800
|
+
return elem.nodeType === 1 && elem.getAttribute("id") === match;
|
2801
|
+
},
|
2802
|
+
TAG: function(elem, match){
|
2803
|
+
return (match === "*" && elem.nodeType === 1) || elem.nodeName.toLowerCase() === match;
|
2804
|
+
},
|
2805
|
+
CLASS: function(elem, match){
|
2806
|
+
return (" " + (elem.className || elem.getAttribute("class")) + " ")
|
2807
|
+
.indexOf( match ) > -1;
|
2808
|
+
},
|
2809
|
+
ATTR: function(elem, match){
|
2810
|
+
var name = match[1],
|
2811
|
+
result = Expr.attrHandle[ name ] ?
|
2812
|
+
Expr.attrHandle[ name ]( elem ) :
|
2813
|
+
elem[ name ] != null ?
|
2814
|
+
elem[ name ] :
|
2815
|
+
elem.getAttribute( name ),
|
2816
|
+
value = result + "",
|
2817
|
+
type = match[2],
|
2818
|
+
check = match[4];
|
2819
|
+
|
2820
|
+
return result == null ?
|
2821
|
+
type === "!=" :
|
2822
|
+
type === "=" ?
|
2823
|
+
value === check :
|
2824
|
+
type === "*=" ?
|
2825
|
+
value.indexOf(check) >= 0 :
|
2826
|
+
type === "~=" ?
|
2827
|
+
(" " + value + " ").indexOf(check) >= 0 :
|
2828
|
+
!check ?
|
2829
|
+
value && result !== false :
|
2830
|
+
type === "!=" ?
|
2831
|
+
value !== check :
|
2832
|
+
type === "^=" ?
|
2833
|
+
value.indexOf(check) === 0 :
|
2834
|
+
type === "$=" ?
|
2835
|
+
value.substr(value.length - check.length) === check :
|
2836
|
+
type === "|=" ?
|
2837
|
+
value === check || value.substr(0, check.length + 1) === check + "-" :
|
2838
|
+
false;
|
2839
|
+
},
|
2840
|
+
POS: function(elem, match, i, array){
|
2841
|
+
var name = match[2], filter = Expr.setFilters[ name ];
|
2842
|
+
|
2843
|
+
if ( filter ) {
|
2844
|
+
return filter( elem, i, match, array );
|
2845
|
+
}
|
2846
|
+
}
|
2847
|
+
}
|
2848
|
+
};
|
2849
|
+
|
2850
|
+
var origPOS = Expr.match.POS;
|
2851
|
+
|
2852
|
+
for ( var type in Expr.match ) {
|
2853
|
+
Expr.match[ type ] = new RegExp( Expr.match[ type ].source + /(?![^\[]*\])(?![^\(]*\))/.source );
|
2854
|
+
Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, function(all, num){
|
2855
|
+
return "\\" + (num - 0 + 1);
|
2856
|
+
}));
|
2857
|
+
}
|
2858
|
+
|
2859
|
+
var makeArray = function(array, results) {
|
2860
|
+
array = Array.prototype.slice.call( array, 0 );
|
2861
|
+
|
2862
|
+
if ( results ) {
|
2863
|
+
results.push.apply( results, array );
|
2864
|
+
return results;
|
2865
|
+
}
|
2866
|
+
|
2867
|
+
return array;
|
2868
|
+
};
|
2869
|
+
|
2870
|
+
// Perform a simple check to determine if the browser is capable of
|
2871
|
+
// converting a NodeList to an array using builtin methods.
|
2872
|
+
// Also verifies that the returned array holds DOM nodes
|
2873
|
+
// (which is not the case in the Blackberry browser)
|
2874
|
+
try {
|
2875
|
+
Array.prototype.slice.call( document.documentElement.childNodes, 0 )[0].nodeType;
|
2876
|
+
|
2877
|
+
// Provide a fallback method if it does not work
|
2878
|
+
} catch(e){
|
2879
|
+
makeArray = function(array, results) {
|
2880
|
+
var ret = results || [];
|
2881
|
+
|
2882
|
+
if ( toString.call(array) === "[object Array]" ) {
|
2883
|
+
Array.prototype.push.apply( ret, array );
|
2884
|
+
} else {
|
2885
|
+
if ( typeof array.length === "number" ) {
|
2886
|
+
for ( var i = 0, l = array.length; i < l; i++ ) {
|
2887
|
+
ret.push( array[i] );
|
2888
|
+
}
|
2889
|
+
} else {
|
2890
|
+
for ( var i = 0; array[i]; i++ ) {
|
2891
|
+
ret.push( array[i] );
|
2892
|
+
}
|
2893
|
+
}
|
2894
|
+
}
|
2895
|
+
|
2896
|
+
return ret;
|
2897
|
+
};
|
2898
|
+
}
|
2899
|
+
|
2900
|
+
var sortOrder;
|
2901
|
+
|
2902
|
+
if ( document.documentElement.compareDocumentPosition ) {
|
2903
|
+
sortOrder = function( a, b ) {
|
2904
|
+
if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) {
|
2905
|
+
if ( a == b ) {
|
2906
|
+
hasDuplicate = true;
|
2907
|
+
}
|
2908
|
+
return a.compareDocumentPosition ? -1 : 1;
|
2909
|
+
}
|
2910
|
+
|
2911
|
+
var ret = a.compareDocumentPosition(b) & 4 ? -1 : a === b ? 0 : 1;
|
2912
|
+
if ( ret === 0 ) {
|
2913
|
+
hasDuplicate = true;
|
2914
|
+
}
|
2915
|
+
return ret;
|
2916
|
+
};
|
2917
|
+
} else if ( "sourceIndex" in document.documentElement ) {
|
2918
|
+
sortOrder = function( a, b ) {
|
2919
|
+
if ( !a.sourceIndex || !b.sourceIndex ) {
|
2920
|
+
if ( a == b ) {
|
2921
|
+
hasDuplicate = true;
|
2922
|
+
}
|
2923
|
+
return a.sourceIndex ? -1 : 1;
|
2924
|
+
}
|
2925
|
+
|
2926
|
+
var ret = a.sourceIndex - b.sourceIndex;
|
2927
|
+
if ( ret === 0 ) {
|
2928
|
+
hasDuplicate = true;
|
2929
|
+
}
|
2930
|
+
return ret;
|
2931
|
+
};
|
2932
|
+
} else if ( document.createRange ) {
|
2933
|
+
sortOrder = function( a, b ) {
|
2934
|
+
if ( !a.ownerDocument || !b.ownerDocument ) {
|
2935
|
+
if ( a == b ) {
|
2936
|
+
hasDuplicate = true;
|
2937
|
+
}
|
2938
|
+
return a.ownerDocument ? -1 : 1;
|
2939
|
+
}
|
2940
|
+
|
2941
|
+
var aRange = a.ownerDocument.createRange(), bRange = b.ownerDocument.createRange();
|
2942
|
+
aRange.setStart(a, 0);
|
2943
|
+
aRange.setEnd(a, 0);
|
2944
|
+
bRange.setStart(b, 0);
|
2945
|
+
bRange.setEnd(b, 0);
|
2946
|
+
var ret = aRange.compareBoundaryPoints(Range.START_TO_END, bRange);
|
2947
|
+
if ( ret === 0 ) {
|
2948
|
+
hasDuplicate = true;
|
2949
|
+
}
|
2950
|
+
return ret;
|
2951
|
+
};
|
2952
|
+
}
|
2953
|
+
|
2954
|
+
// Utility function for retreiving the text value of an array of DOM nodes
|
2955
|
+
function getText( elems ) {
|
2956
|
+
var ret = "", elem;
|
2957
|
+
|
2958
|
+
for ( var i = 0; elems[i]; i++ ) {
|
2959
|
+
elem = elems[i];
|
2960
|
+
|
2961
|
+
// Get the text from text nodes and CDATA nodes
|
2962
|
+
if ( elem.nodeType === 3 || elem.nodeType === 4 ) {
|
2963
|
+
ret += elem.nodeValue;
|
2964
|
+
|
2965
|
+
// Traverse everything else, except comment nodes
|
2966
|
+
} else if ( elem.nodeType !== 8 ) {
|
2967
|
+
ret += getText( elem.childNodes );
|
2968
|
+
}
|
2969
|
+
}
|
2970
|
+
|
2971
|
+
return ret;
|
2972
|
+
}
|
2973
|
+
|
2974
|
+
// Check to see if the browser returns elements by name when
|
2975
|
+
// querying by getElementById (and provide a workaround)
|
2976
|
+
(function(){
|
2977
|
+
// We're going to inject a fake input element with a specified name
|
2978
|
+
var form = document.createElement("div"),
|
2979
|
+
id = "script" + (new Date).getTime();
|
2980
|
+
form.innerHTML = "<a name='" + id + "'/>";
|
2981
|
+
|
2982
|
+
// Inject it into the root element, check its status, and remove it quickly
|
2983
|
+
var root = document.documentElement;
|
2984
|
+
root.insertBefore( form, root.firstChild );
|
2985
|
+
|
2986
|
+
// The workaround has to do additional checks after a getElementById
|
2987
|
+
// Which slows things down for other browsers (hence the branching)
|
2988
|
+
if ( document.getElementById( id ) ) {
|
2989
|
+
Expr.find.ID = function(match, context, isXML){
|
2990
|
+
if ( typeof context.getElementById !== "undefined" && !isXML ) {
|
2991
|
+
var m = context.getElementById(match[1]);
|
2992
|
+
return m ? m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ? [m] : undefined : [];
|
2993
|
+
}
|
2994
|
+
};
|
2995
|
+
|
2996
|
+
Expr.filter.ID = function(elem, match){
|
2997
|
+
var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id");
|
2998
|
+
return elem.nodeType === 1 && node && node.nodeValue === match;
|
2999
|
+
};
|
3000
|
+
}
|
3001
|
+
|
3002
|
+
root.removeChild( form );
|
3003
|
+
root = form = null; // release memory in IE
|
3004
|
+
})();
|
3005
|
+
|
3006
|
+
(function(){
|
3007
|
+
// Check to see if the browser returns only elements
|
3008
|
+
// when doing getElementsByTagName("*")
|
3009
|
+
|
3010
|
+
// Create a fake element
|
3011
|
+
var div = document.createElement("div");
|
3012
|
+
div.appendChild( document.createComment("") );
|
3013
|
+
|
3014
|
+
// Make sure no comments are found
|
3015
|
+
if ( div.getElementsByTagName("*").length > 0 ) {
|
3016
|
+
Expr.find.TAG = function(match, context){
|
3017
|
+
var results = context.getElementsByTagName(match[1]);
|
3018
|
+
|
3019
|
+
// Filter out possible comments
|
3020
|
+
if ( match[1] === "*" ) {
|
3021
|
+
var tmp = [];
|
3022
|
+
|
3023
|
+
for ( var i = 0; results[i]; i++ ) {
|
3024
|
+
if ( results[i].nodeType === 1 ) {
|
3025
|
+
tmp.push( results[i] );
|
3026
|
+
}
|
3027
|
+
}
|
3028
|
+
|
3029
|
+
results = tmp;
|
3030
|
+
}
|
3031
|
+
|
3032
|
+
return results;
|
3033
|
+
};
|
3034
|
+
}
|
3035
|
+
|
3036
|
+
// Check to see if an attribute returns normalized href attributes
|
3037
|
+
div.innerHTML = "<a href='#'></a>";
|
3038
|
+
if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" &&
|
3039
|
+
div.firstChild.getAttribute("href") !== "#" ) {
|
3040
|
+
Expr.attrHandle.href = function(elem){
|
3041
|
+
return elem.getAttribute("href", 2);
|
3042
|
+
};
|
3043
|
+
}
|
3044
|
+
|
3045
|
+
div = null; // release memory in IE
|
3046
|
+
})();
|
3047
|
+
|
3048
|
+
if ( document.querySelectorAll ) {
|
3049
|
+
(function(){
|
3050
|
+
var oldSizzle = Sizzle, div = document.createElement("div");
|
3051
|
+
div.innerHTML = "<p class='TEST'></p>";
|
3052
|
+
|
3053
|
+
// Safari can't handle uppercase or unicode characters when
|
3054
|
+
// in quirks mode.
|
3055
|
+
if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {
|
3056
|
+
return;
|
3057
|
+
}
|
3058
|
+
|
3059
|
+
Sizzle = function(query, context, extra, seed){
|
3060
|
+
context = context || document;
|
3061
|
+
|
3062
|
+
// Only use querySelectorAll on non-XML documents
|
3063
|
+
// (ID selectors don't work in non-HTML documents)
|
3064
|
+
if ( !seed && context.nodeType === 9 && !isXML(context) ) {
|
3065
|
+
try {
|
3066
|
+
return makeArray( context.querySelectorAll(query), extra );
|
3067
|
+
} catch(e){}
|
3068
|
+
}
|
3069
|
+
|
3070
|
+
return oldSizzle(query, context, extra, seed);
|
3071
|
+
};
|
3072
|
+
|
3073
|
+
for ( var prop in oldSizzle ) {
|
3074
|
+
Sizzle[ prop ] = oldSizzle[ prop ];
|
3075
|
+
}
|
3076
|
+
|
3077
|
+
div = null; // release memory in IE
|
3078
|
+
})();
|
3079
|
+
}
|
3080
|
+
|
3081
|
+
(function(){
|
3082
|
+
var div = document.createElement("div");
|
3083
|
+
|
3084
|
+
div.innerHTML = "<div class='test e'></div><div class='test'></div>";
|
3085
|
+
|
3086
|
+
// Opera can't find a second classname (in 9.6)
|
3087
|
+
// Also, make sure that getElementsByClassName actually exists
|
3088
|
+
if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) {
|
3089
|
+
return;
|
3090
|
+
}
|
3091
|
+
|
3092
|
+
// Safari caches class attributes, doesn't catch changes (in 3.2)
|
3093
|
+
div.lastChild.className = "e";
|
3094
|
+
|
3095
|
+
if ( div.getElementsByClassName("e").length === 1 ) {
|
3096
|
+
return;
|
3097
|
+
}
|
3098
|
+
|
3099
|
+
Expr.order.splice(1, 0, "CLASS");
|
3100
|
+
Expr.find.CLASS = function(match, context, isXML) {
|
3101
|
+
if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) {
|
3102
|
+
return context.getElementsByClassName(match[1]);
|
3103
|
+
}
|
3104
|
+
};
|
3105
|
+
|
3106
|
+
div = null; // release memory in IE
|
3107
|
+
})();
|
3108
|
+
|
3109
|
+
function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
|
3110
|
+
for ( var i = 0, l = checkSet.length; i < l; i++ ) {
|
3111
|
+
var elem = checkSet[i];
|
3112
|
+
if ( elem ) {
|
3113
|
+
elem = elem[dir];
|
3114
|
+
var match = false;
|
3115
|
+
|
3116
|
+
while ( elem ) {
|
3117
|
+
if ( elem.sizcache === doneName ) {
|
3118
|
+
match = checkSet[elem.sizset];
|
3119
|
+
break;
|
3120
|
+
}
|
3121
|
+
|
3122
|
+
if ( elem.nodeType === 1 && !isXML ){
|
3123
|
+
elem.sizcache = doneName;
|
3124
|
+
elem.sizset = i;
|
3125
|
+
}
|
3126
|
+
|
3127
|
+
if ( elem.nodeName.toLowerCase() === cur ) {
|
3128
|
+
match = elem;
|
3129
|
+
break;
|
3130
|
+
}
|
3131
|
+
|
3132
|
+
elem = elem[dir];
|
3133
|
+
}
|
3134
|
+
|
3135
|
+
checkSet[i] = match;
|
3136
|
+
}
|
3137
|
+
}
|
3138
|
+
}
|
3139
|
+
|
3140
|
+
function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
|
3141
|
+
for ( var i = 0, l = checkSet.length; i < l; i++ ) {
|
3142
|
+
var elem = checkSet[i];
|
3143
|
+
if ( elem ) {
|
3144
|
+
elem = elem[dir];
|
3145
|
+
var match = false;
|
3146
|
+
|
3147
|
+
while ( elem ) {
|
3148
|
+
if ( elem.sizcache === doneName ) {
|
3149
|
+
match = checkSet[elem.sizset];
|
3150
|
+
break;
|
3151
|
+
}
|
3152
|
+
|
3153
|
+
if ( elem.nodeType === 1 ) {
|
3154
|
+
if ( !isXML ) {
|
3155
|
+
elem.sizcache = doneName;
|
3156
|
+
elem.sizset = i;
|
3157
|
+
}
|
3158
|
+
if ( typeof cur !== "string" ) {
|
3159
|
+
if ( elem === cur ) {
|
3160
|
+
match = true;
|
3161
|
+
break;
|
3162
|
+
}
|
3163
|
+
|
3164
|
+
} else if ( Sizzle.filter( cur, [elem] ).length > 0 ) {
|
3165
|
+
match = elem;
|
3166
|
+
break;
|
3167
|
+
}
|
3168
|
+
}
|
3169
|
+
|
3170
|
+
elem = elem[dir];
|
3171
|
+
}
|
3172
|
+
|
3173
|
+
checkSet[i] = match;
|
3174
|
+
}
|
3175
|
+
}
|
3176
|
+
}
|
3177
|
+
|
3178
|
+
var contains = document.compareDocumentPosition ? function(a, b){
|
3179
|
+
return !!(a.compareDocumentPosition(b) & 16);
|
3180
|
+
} : function(a, b){
|
3181
|
+
return a !== b && (a.contains ? a.contains(b) : true);
|
3182
|
+
};
|
3183
|
+
|
3184
|
+
var isXML = function(elem){
|
3185
|
+
// documentElement is verified for cases where it doesn't yet exist
|
3186
|
+
// (such as loading iframes in IE - #4833)
|
3187
|
+
var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement;
|
3188
|
+
return documentElement ? documentElement.nodeName !== "HTML" : false;
|
3189
|
+
};
|
3190
|
+
|
3191
|
+
var posProcess = function(selector, context){
|
3192
|
+
var tmpSet = [], later = "", match,
|
3193
|
+
root = context.nodeType ? [context] : context;
|
3194
|
+
|
3195
|
+
// Position selectors must be done after the filter
|
3196
|
+
// And so must :not(positional) so we move all PSEUDOs to the end
|
3197
|
+
while ( (match = Expr.match.PSEUDO.exec( selector )) ) {
|
3198
|
+
later += match[0];
|
3199
|
+
selector = selector.replace( Expr.match.PSEUDO, "" );
|
3200
|
+
}
|
3201
|
+
|
3202
|
+
selector = Expr.relative[selector] ? selector + "*" : selector;
|
3203
|
+
|
3204
|
+
for ( var i = 0, l = root.length; i < l; i++ ) {
|
3205
|
+
Sizzle( selector, root[i], tmpSet );
|
3206
|
+
}
|
3207
|
+
|
3208
|
+
return Sizzle.filter( later, tmpSet );
|
3209
|
+
};
|
3210
|
+
|
3211
|
+
return Sizzle;
|
3212
|
+
})
|
3213
|
+
define('ninja/event-scribe',['require','exports','module'],function() {
|
3214
|
+
function EventScribe() {
|
3215
|
+
this.handlers = {}
|
3216
|
+
this.currentElement = null
|
3217
|
+
}
|
3218
|
+
|
3219
|
+
EventScribe.prototype = {
|
3220
|
+
//I'll be frank: I don't remember what this method is for,
|
3221
|
+
//so I'm not comfortable keeping it in play.
|
3222
|
+
// makeHandlersRemove: function(element) {
|
3223
|
+
// for(var eventName in this.handlers) {
|
3224
|
+
// var handler = this.handlers[eventName]
|
3225
|
+
// this.handlers[eventName] = function(eventRecord) {
|
3226
|
+
// var res = handler.call(eventRecord)
|
3227
|
+
// //jQuery(element).remove()
|
3228
|
+
// return res
|
3229
|
+
// }
|
3230
|
+
// }
|
3231
|
+
// },
|
3232
|
+
recordEventHandlers: function (context, behavior) {
|
3233
|
+
if(this.currentElement !== context.element) {
|
3234
|
+
if(this.currentElement !== null) {
|
3235
|
+
//this.makeHandlersRemove(this.currentElement)
|
3236
|
+
this.applyEventHandlers(this.currentElement)
|
3237
|
+
this.handlers = {}
|
3238
|
+
}
|
3239
|
+
this.currentElement = context.element
|
3240
|
+
}
|
3241
|
+
for(var eventName in behavior.eventHandlers) {
|
3242
|
+
var oldHandler = this.handlers[eventName]
|
3243
|
+
if(typeof oldHandler == "undefined") {
|
3244
|
+
oldHandler = function(){return true}
|
3245
|
+
}
|
3246
|
+
this.handlers[eventName] = behavior.buildHandler(context, eventName, oldHandler)
|
3247
|
+
}
|
3248
|
+
},
|
3249
|
+
applyEventHandlers: function(element) {
|
3250
|
+
for(var eventName in this.handlers) {
|
3251
|
+
jQuery(element).bind(eventName, this.handlers[eventName])
|
3252
|
+
}
|
3253
|
+
}
|
3254
|
+
}
|
3255
|
+
return EventScribe
|
3256
|
+
})
|
3257
|
+
define('ninja/behavior-collection',["sizzle-1.0", "ninja/behaviors", "utils", "ninja/event-scribe", "ninja/exceptions"],
|
3258
|
+
function(Sizzle, Behaviors, Utils, EventScribe, Exceptions) {
|
3259
|
+
|
3260
|
+
var forEach = Utils.forEach
|
3261
|
+
var log = Utils.log
|
3262
|
+
|
3263
|
+
var TransformFailedException = Exceptions.TransformFailed
|
3264
|
+
var CouldntChooseException = Exceptions.CouldntChoose
|
3265
|
+
|
3266
|
+
function BehaviorCollection(tools) {
|
3267
|
+
this.lexicalCount = 0
|
3268
|
+
this.eventQueue = []
|
3269
|
+
this.behaviors = {}
|
3270
|
+
this.selectors = []
|
3271
|
+
this.mutationTargets = []
|
3272
|
+
this.tools = tools
|
3273
|
+
return this
|
3274
|
+
}
|
3275
|
+
|
3276
|
+
BehaviorCollection.prototype = {
|
3277
|
+
addBehavior: function(selector, behavior) {
|
3278
|
+
if(Utils.isArray(behavior)) {
|
3279
|
+
forEach(behavior, function(behaves){
|
3280
|
+
this.addBehavior(selector, behaves)
|
3281
|
+
}, this)
|
3282
|
+
}
|
3283
|
+
else if(behavior instanceof Behaviors.base) {
|
3284
|
+
this.insertBehavior(selector, behavior)
|
3285
|
+
}
|
3286
|
+
else if(behavior instanceof Behaviors.select) {
|
3287
|
+
this.insertBehavior(selector, behavior)
|
3288
|
+
}
|
3289
|
+
else if(behavior instanceof Behaviors.meta) {
|
3290
|
+
this.insertBehavior(selector, behavior)
|
3291
|
+
}
|
3292
|
+
else if(typeof behavior == "function"){
|
3293
|
+
this.addBehavior(selector, behavior())
|
3294
|
+
}
|
3295
|
+
else {
|
3296
|
+
var behavior = new Behaviors.base(behavior)
|
3297
|
+
this.addBehavior(selector, behavior)
|
3298
|
+
}
|
3299
|
+
},
|
3300
|
+
insertBehavior: function(selector, behavior) {
|
3301
|
+
behavior.lexicalOrder = this.lexicalCount
|
3302
|
+
this.lexicalCount += 1
|
3303
|
+
if(this.behaviors[selector] === undefined) {
|
3304
|
+
this.selectors.push(selector)
|
3305
|
+
this.behaviors[selector] = [behavior]
|
3306
|
+
}
|
3307
|
+
else {
|
3308
|
+
this.behaviors[selector].push(behavior)
|
3309
|
+
}
|
3310
|
+
},
|
3311
|
+
addMutationTargets: function(targets) {
|
3312
|
+
this.mutationTargets = this.mutationTargets.concat(targets)
|
3313
|
+
},
|
3314
|
+
//Move to Tools
|
3315
|
+
fireMutationEvent: function() {
|
3316
|
+
var targets = this.mutationTargets
|
3317
|
+
if (targets.length > 0 ) {
|
3318
|
+
for(var target = targets[0];
|
3319
|
+
targets.length > 0;
|
3320
|
+
target = targets.shift()) {
|
3321
|
+
jQuery(target).trigger("thisChangedDOM")
|
3322
|
+
}
|
3323
|
+
}
|
3324
|
+
else {
|
3325
|
+
this.tools.getRootOfDocument().trigger("thisChangedDOM")
|
3326
|
+
}
|
3327
|
+
},
|
3328
|
+
mutationEventTriggered: function(evnt){
|
3329
|
+
if(this.eventQueue.length == 0){
|
3330
|
+
log("mutation event - first")
|
3331
|
+
this.enqueueEvent(evnt)
|
3332
|
+
this.handleQueue()
|
3333
|
+
}
|
3334
|
+
else {
|
3335
|
+
log("mutation event - queueing")
|
3336
|
+
this.enqueueEvent(evnt)
|
3337
|
+
}
|
3338
|
+
},
|
3339
|
+
enqueueEvent: function(evnt) {
|
3340
|
+
var eventCovered = false
|
3341
|
+
var uncovered = []
|
3342
|
+
forEach(this.eventQueue, function(val) {
|
3343
|
+
eventCovered = eventCovered || jQuery.contains(val.target, evnt.target)
|
3344
|
+
if (!(jQuery.contains(evnt.target, val.target))) {
|
3345
|
+
uncovered.push(val)
|
3346
|
+
}
|
3347
|
+
})
|
3348
|
+
if(!eventCovered) {
|
3349
|
+
uncovered.unshift(evnt)
|
3350
|
+
this.eventQueue = uncovered
|
3351
|
+
}
|
3352
|
+
},
|
3353
|
+
handleQueue: function(){
|
3354
|
+
while (this.eventQueue.length != 0){
|
3355
|
+
this.applyAll(this.eventQueue[0].target)
|
3356
|
+
this.eventQueue.shift()
|
3357
|
+
}
|
3358
|
+
},
|
3359
|
+
applyBehaviorsTo: function(element, behaviors) {
|
3360
|
+
return this.applyBehaviorsInContext(new this.tools.behaviorContext, element, behaviors)
|
3361
|
+
},
|
3362
|
+
applyBehaviorsInContext: function(context, element, behaviors) {
|
3363
|
+
var curContext,
|
3364
|
+
applyList = [],
|
3365
|
+
scribe = new EventScribe
|
3366
|
+
|
3367
|
+
//Move enrich to Utils
|
3368
|
+
this.tools.enrich(scribe.handlers, context.eventHandlerSet)
|
3369
|
+
|
3370
|
+
behaviors = behaviors.sort(function(left, right) {
|
3371
|
+
if(left.priority != right.priority) {
|
3372
|
+
if(left.priority === undefined) {
|
3373
|
+
return -1
|
3374
|
+
}
|
3375
|
+
else if(right.priority === undefined) {
|
3376
|
+
return 1
|
3377
|
+
}
|
3378
|
+
else {
|
3379
|
+
return left.priority - right.priority
|
3380
|
+
}
|
3381
|
+
}
|
3382
|
+
else {
|
3383
|
+
return left.lexicalOrder - right.lexicalOrder
|
3384
|
+
}
|
3385
|
+
}
|
3386
|
+
)
|
3387
|
+
|
3388
|
+
forEach(behaviors,
|
3389
|
+
function(behavior){
|
3390
|
+
//XXX This needs to have exception handling back
|
3391
|
+
try {
|
3392
|
+
curContext = behavior.inContext(context)
|
3393
|
+
element = behavior.applyTransform(curContext, element)
|
3394
|
+
|
3395
|
+
context = curContext
|
3396
|
+
context.element = element
|
3397
|
+
|
3398
|
+
scribe.recordEventHandlers(context, behavior)
|
3399
|
+
}
|
3400
|
+
catch(ex) {
|
3401
|
+
if(ex instanceof TransformFailedException) {
|
3402
|
+
log("!!! Transform failed")
|
3403
|
+
}
|
3404
|
+
else {
|
3405
|
+
log(ex)
|
3406
|
+
throw ex
|
3407
|
+
}
|
3408
|
+
}
|
3409
|
+
}
|
3410
|
+
)
|
3411
|
+
jQuery(element).data("ninja-visited", context)
|
3412
|
+
|
3413
|
+
scribe.applyEventHandlers(element)
|
3414
|
+
//Move enrich to utils
|
3415
|
+
this.tools.enrich(context.eventHandlerSet, scribe.handlers)
|
3416
|
+
|
3417
|
+
this.fireMutationEvent()
|
3418
|
+
|
3419
|
+
return element
|
3420
|
+
},
|
3421
|
+
collectBehaviors: function(element, collection, behaviors) {
|
3422
|
+
forEach(behaviors, function(val) {
|
3423
|
+
try {
|
3424
|
+
collection.push(val.choose(element))
|
3425
|
+
}
|
3426
|
+
catch(ex) {
|
3427
|
+
if(ex instanceof CouldntChooseException) {
|
3428
|
+
log("!!! couldn't choose")
|
3429
|
+
}
|
3430
|
+
else {
|
3431
|
+
log(ex)
|
3432
|
+
throw(ex)
|
3433
|
+
}
|
3434
|
+
}
|
3435
|
+
})
|
3436
|
+
},
|
3437
|
+
//XXX Still doesn't quite handle the sub-behavior case - order of application
|
3438
|
+
apply: function(element, startBehaviors, selectorIndex) {
|
3439
|
+
var applicableBehaviors = [], len = this.selectors.length
|
3440
|
+
this.collectBehaviors(element, applicableBehaviors, startBehaviors)
|
3441
|
+
var context = jQuery(element).data('ninja-visited')
|
3442
|
+
if (!context) {
|
3443
|
+
if(typeof selectorIndex == "undefined") {
|
3444
|
+
selectorIndex = 0
|
3445
|
+
}
|
3446
|
+
for(var j = selectorIndex; j < len; j++) {
|
3447
|
+
if(jQuery(element).is(this.selectors[j])) {
|
3448
|
+
this.collectBehaviors(element, applicableBehaviors, this.behaviors[this.selectors[j]])
|
3449
|
+
}
|
3450
|
+
}
|
3451
|
+
this.applyBehaviorsTo(element, applicableBehaviors)
|
3452
|
+
}
|
3453
|
+
else {
|
3454
|
+
context.unbindHandlers()
|
3455
|
+
this.applyBehaviorsInContext(context, element, applicableBehaviors)
|
3456
|
+
}
|
3457
|
+
},
|
3458
|
+
applyAll: function(root){
|
3459
|
+
var len = this.selectors.length
|
3460
|
+
for(var i = 0; i < len; i++) {
|
3461
|
+
var collection = this
|
3462
|
+
|
3463
|
+
//Sizzle?
|
3464
|
+
|
3465
|
+
forEach(Sizzle( this.selectors[i], root), //an array, not a jQuery
|
3466
|
+
function(elem){
|
3467
|
+
if (!jQuery(elem).data("ninja-visited")) { //Pure optimization
|
3468
|
+
collection.apply(elem, [], i)
|
3469
|
+
}
|
3470
|
+
})
|
3471
|
+
|
3472
|
+
|
3473
|
+
// jQuery(root).find(this.selectors[i]).each(
|
3474
|
+
// function(index, elem){
|
3475
|
+
// if (!jQuery(elem).data("ninja-visited")) { //Pure optimization
|
3476
|
+
// collection.apply(elem, [], i)
|
3477
|
+
// }
|
3478
|
+
// }
|
3479
|
+
// )
|
3480
|
+
}
|
3481
|
+
}
|
3482
|
+
}
|
3483
|
+
return BehaviorCollection
|
3484
|
+
})
|
3485
|
+
define('ninja/root-context',["utils"], function(Utils) {
|
3486
|
+
var forEach = Utils.forEach
|
3487
|
+
|
3488
|
+
return function(tools) {
|
3489
|
+
|
3490
|
+
function RootContext() {
|
3491
|
+
this.stashedElements = []
|
3492
|
+
this.eventHandlerSet = {}
|
3493
|
+
}
|
3494
|
+
|
3495
|
+
RootContext.prototype = tools.enrich(
|
3496
|
+
tools,
|
3497
|
+
{
|
3498
|
+
stash: function(element) {
|
3499
|
+
this.stashedElements.unshift(element)
|
3500
|
+
},
|
3501
|
+
unstash: function() {
|
3502
|
+
return this.stashedElements.shift()
|
3503
|
+
},
|
3504
|
+
clearStash: function() {
|
3505
|
+
this.stashedElements = []
|
3506
|
+
},
|
3507
|
+
//XXX Of concern: how do cascading events work out?
|
3508
|
+
//Should there be a first catch? Or a "doesn't cascade" or something?
|
3509
|
+
cascadeEvent: function(event) {
|
3510
|
+
var formDiv = Ninja.tools.hiddenDiv()
|
3511
|
+
forEach(this.stashedElements, function(element) {
|
3512
|
+
var elem = jQuery(element)
|
3513
|
+
elem.data("ninja-visited", this)
|
3514
|
+
jQuery(formDiv).append(elem)
|
3515
|
+
elem.trigger(event)
|
3516
|
+
})
|
3517
|
+
},
|
3518
|
+
unbindHandlers: function() {
|
3519
|
+
var el = jQuery(this.element)
|
3520
|
+
for(eventName in this.eventHandlerSet) {
|
3521
|
+
el.unbind(eventName, this.eventHandlerSet[eventName])
|
3522
|
+
}
|
3523
|
+
}
|
3524
|
+
})
|
3525
|
+
|
3526
|
+
return RootContext
|
3527
|
+
}
|
3528
|
+
})
|
3529
|
+
|
3530
|
+
define('ninja/tools',[ "ninja/behaviors", "ninja/behavior-collection", "ninja/exceptions",
|
3531
|
+
"utils", "ninja/root-context"
|
3532
|
+
], function(
|
3533
|
+
Behaviors, BehaviorCollection, Exceptions,
|
3534
|
+
Utils, rootContext
|
3535
|
+
) {
|
3536
|
+
var CantTransformException = Exceptions.CantTransform
|
3537
|
+
var log = Utils.log
|
3538
|
+
|
3539
|
+
function Tools(ninja) {
|
3540
|
+
this.ninja = ninja
|
3541
|
+
this.behaviorContext = rootContext(this)
|
3542
|
+
}
|
3543
|
+
|
3544
|
+
Tools.prototype = {
|
3545
|
+
//Handy JS things
|
3546
|
+
forEach: Utils.forEach,
|
3547
|
+
enrich: function(left, right) {
|
3548
|
+
return jQuery.extend(left, right)
|
3549
|
+
},
|
3550
|
+
|
3551
|
+
ensureDefaults: function(config, defaults) {
|
3552
|
+
if(!(config instanceof Object)) {
|
3553
|
+
config = {}
|
3554
|
+
}
|
3555
|
+
for(var key in defaults) {
|
3556
|
+
if(typeof config[key] == "undefined") {
|
3557
|
+
if(typeof this.ninja.config[key] != "undefined") {
|
3558
|
+
config[key] = this.ninja.config[key]
|
3559
|
+
} else if(typeof defaults[key] != "undefined") {
|
3560
|
+
config[key] = defaults[key]
|
3561
|
+
}
|
3562
|
+
}
|
3563
|
+
}
|
3564
|
+
return config
|
3565
|
+
},
|
3566
|
+
|
3567
|
+
//DOM and Events
|
3568
|
+
getRootOfDocument: function() {
|
3569
|
+
return jQuery("html") //document.firstChild)
|
3570
|
+
},
|
3571
|
+
clearRootCollection: function() {
|
3572
|
+
this.ninja.behavior = this.ninja.goodBehavior
|
3573
|
+
this.getRootOfDocument().data("ninja-behavior", null)
|
3574
|
+
},
|
3575
|
+
getRootCollection: function() {
|
3576
|
+
var rootOfDocument = this.getRootOfDocument()
|
3577
|
+
if(rootOfDocument.data("ninja-behavior") instanceof BehaviorCollection) {
|
3578
|
+
return rootOfDocument.data("ninja-behavior")
|
3579
|
+
}
|
3580
|
+
|
3581
|
+
var collection = new BehaviorCollection(this)
|
3582
|
+
rootOfDocument.data("ninja-behavior", collection);
|
3583
|
+
return collection
|
3584
|
+
},
|
3585
|
+
addMutationTargets: function(targets) {
|
3586
|
+
this.getRootCollection().addMutationTargets(targets)
|
3587
|
+
},
|
3588
|
+
fireMutationEvent: function() {
|
3589
|
+
this.getRootCollection().fireMutationEvent()
|
3590
|
+
},
|
3591
|
+
detachSyntheticMutationEvents: function() {
|
3592
|
+
this.getRootCollection().fireMutationEvent = function(){}
|
3593
|
+
this.getRootCollection().addMutationTargets = function(t){}
|
3594
|
+
},
|
3595
|
+
//HTML Utils
|
3596
|
+
copyAttributes: function(from, to, which) {
|
3597
|
+
var attributeList = []
|
3598
|
+
var attrs = []
|
3599
|
+
var match = new RegExp("^" + which.join("$|^") + "$")
|
3600
|
+
to = jQuery(to)
|
3601
|
+
this.forEach(from.attributes, function(att) {
|
3602
|
+
if(match.test(att.nodeName)) {
|
3603
|
+
to.attr(att.nodeName, att.nodeValue)
|
3604
|
+
}
|
3605
|
+
})
|
3606
|
+
},
|
3607
|
+
deriveElementsFrom: function(element, means){
|
3608
|
+
switch(typeof means){
|
3609
|
+
case 'undefined': return element
|
3610
|
+
case 'string': return jQuery(means)
|
3611
|
+
case 'function': return means(element)
|
3612
|
+
}
|
3613
|
+
},
|
3614
|
+
extractMethod: function(element, formData) {
|
3615
|
+
if(element.dataset !== undefined &&
|
3616
|
+
element.dataset["method"] !== undefined &&
|
3617
|
+
element.dataset["method"].length > 0) {
|
3618
|
+
log("Override via dataset: " + element.dataset["method"])
|
3619
|
+
return element.dataset["method"]
|
3620
|
+
}
|
3621
|
+
if(element.dataset === undefined &&
|
3622
|
+
jQuery(element).attr("data-method") !== undefined) {
|
3623
|
+
log("Override via data-method: " + jQuery(element).attr("data-method"))
|
3624
|
+
return jQuery(element).attr("data-method")
|
3625
|
+
}
|
3626
|
+
if(typeof formData !== "undefined") {
|
3627
|
+
for(var i=0, len = formData.length; i<len; i++) {
|
3628
|
+
if(formData[i].name == "Method") {
|
3629
|
+
log("Override via Method: " + formData[i].value)
|
3630
|
+
return formData[i].value
|
3631
|
+
}
|
3632
|
+
}
|
3633
|
+
}
|
3634
|
+
if(typeof element.method !== "undefined") {
|
3635
|
+
return element.method
|
3636
|
+
}
|
3637
|
+
return "GET"
|
3638
|
+
},
|
3639
|
+
//Ninjascript utils
|
3640
|
+
cantTransform: function() {
|
3641
|
+
throw new TransformFailedException
|
3642
|
+
},
|
3643
|
+
applyBehaviors: function(element, behaviors) {
|
3644
|
+
this.getRootCollection().apply(element, behaviors)
|
3645
|
+
},
|
3646
|
+
message: function(text, classes) {
|
3647
|
+
var addingMessage = this.ninja.config.messageWrapping(text, classes)
|
3648
|
+
jQuery(this.ninja.config.messageList).append(addingMessage)
|
3649
|
+
},
|
3650
|
+
hiddenDiv: function() {
|
3651
|
+
var existing = jQuery("div#ninja-hide")
|
3652
|
+
if(existing.length > 0) {
|
3653
|
+
return existing[0]
|
3654
|
+
}
|
3655
|
+
|
3656
|
+
var hide = jQuery("<div id='ninja-hide'></div>").css("display", "none")
|
3657
|
+
jQuery("body").append(hide)
|
3658
|
+
this.getRootCollection().applyBehaviorsTo(hide, [this.ninja.suppressChangeEvents()])
|
3659
|
+
return hide
|
3660
|
+
}
|
3661
|
+
}
|
3662
|
+
|
3663
|
+
return Tools;
|
3664
|
+
})
|
3665
|
+
define('ninja/configuration',['require','exports','module'],function() {
|
3666
|
+
return {
|
3667
|
+
//This is the half-assed: it should be template of some sort
|
3668
|
+
messageWrapping: function(text, classes) {
|
3669
|
+
return "<div class='flash " + classes +"'><p>" + text + "</p></div>"
|
3670
|
+
},
|
3671
|
+
messageList: "#messages",
|
3672
|
+
busyLaziness: 200
|
3673
|
+
}
|
3674
|
+
})
|
3675
|
+
define('ninja/tools/json-dispatcher',["utils"], function(Utils) {
|
3676
|
+
function JSONDispatcher() {
|
3677
|
+
this.handlers = []
|
3678
|
+
}
|
3679
|
+
|
3680
|
+
JSONDispatcher.prototype = {
|
3681
|
+
addHandler: function(handler) {
|
3682
|
+
this.handlers.push({ handler: new JSONHandler(handler) })
|
3683
|
+
},
|
3684
|
+
dispatch: function(json) {
|
3685
|
+
var len = this.handlers.length
|
3686
|
+
for(var i = 0; i < len; i++) {
|
3687
|
+
try {
|
3688
|
+
this.handlers[i].handler.receive(json)
|
3689
|
+
}
|
3690
|
+
catch(problem) {
|
3691
|
+
Utils.log("Caught: " + problem + " while handling JSON response.")
|
3692
|
+
}
|
3693
|
+
}
|
3694
|
+
}
|
3695
|
+
}
|
3696
|
+
|
3697
|
+
function JSONHandler(desc) {
|
3698
|
+
this.desc = desc
|
3699
|
+
}
|
3700
|
+
|
3701
|
+
/**
|
3702
|
+
* Intention is to use JSONHandler like this:
|
3703
|
+
*
|
3704
|
+
* this.ajaxToJson({
|
3705
|
+
* item: function(html) {
|
3706
|
+
* $('#items').append($(html))
|
3707
|
+
* },
|
3708
|
+
* item_count: function(html) {
|
3709
|
+
* $('#item_count').replace($(html))
|
3710
|
+
* }
|
3711
|
+
* })
|
3712
|
+
*
|
3713
|
+
* And the server sends back something like:
|
3714
|
+
*
|
3715
|
+
* { "item": "<li>A list item<\li>", "item_count": 17 }
|
3716
|
+
**/
|
3717
|
+
|
3718
|
+
JSONHandler.prototype = {
|
3719
|
+
receive: function (data) {
|
3720
|
+
this.compose([], data, this.desc)
|
3721
|
+
return null
|
3722
|
+
},
|
3723
|
+
compose: function(path, data, desc) {
|
3724
|
+
if(typeof desc == "function") {
|
3725
|
+
try {
|
3726
|
+
desc.call(this, data) //Individual functions can share data through handler
|
3727
|
+
}
|
3728
|
+
catch(problem) {
|
3729
|
+
Utils.log("Caught: " + problem + " while handling JSON at " + path.join("/"))
|
3730
|
+
}
|
3731
|
+
}
|
3732
|
+
|
3733
|
+
else {
|
3734
|
+
for(var key in data) {
|
3735
|
+
if(data.hasOwnProperty(key)) {
|
3736
|
+
if( key in desc) {
|
3737
|
+
this.compose(path.concat([key]), data[key], desc[key])
|
3738
|
+
}
|
3739
|
+
}
|
3740
|
+
}
|
3741
|
+
}
|
3742
|
+
return null
|
3743
|
+
}
|
3744
|
+
}
|
3745
|
+
|
3746
|
+
return JSONDispatcher
|
3747
|
+
})
|
3748
|
+
define('ninja',["utils", "ninja/tools", "ninja/behaviors", "ninja/configuration", 'ninja/tools/json-dispatcher'],
|
3749
|
+
function(Utils, Tools, Behaviors, Configs, JSONDispatcher) {
|
3750
|
+
var log = Utils.log
|
3751
|
+
|
3752
|
+
function NinjaScript() {
|
3753
|
+
//NinjaScript-wide configurations. Currently, not very many
|
3754
|
+
this.config = Configs
|
3755
|
+
|
3756
|
+
this.behavior = this.goodBehavior
|
3757
|
+
this.jsonDispatcher = new JSONDispatcher()
|
3758
|
+
this.tools = new Tools(this)
|
3759
|
+
}
|
3760
|
+
|
3761
|
+
NinjaScript.prototype = {
|
3762
|
+
|
3763
|
+
packageBehaviors: function(callback) {
|
3764
|
+
var types = {
|
3765
|
+
does: Behaviors.base,
|
3766
|
+
chooses: Behaviors.meta,
|
3767
|
+
selects: Behaviors.select
|
3768
|
+
}
|
3769
|
+
result = callback(types)
|
3770
|
+
this.tools.enrich(this, result)
|
3771
|
+
},
|
3772
|
+
|
3773
|
+
packageTools: function(object) {
|
3774
|
+
this.tools.enrich(Tools.prototype, object)
|
3775
|
+
},
|
3776
|
+
|
3777
|
+
configure: function(opts) {
|
3778
|
+
this.tools.enrich(this.config, opts)
|
3779
|
+
},
|
3780
|
+
|
3781
|
+
goodBehavior: function(dispatching) {
|
3782
|
+
var collection = this.tools.getRootCollection()
|
3783
|
+
for(var selector in dispatching)
|
3784
|
+
{
|
3785
|
+
if(typeof dispatching[selector] == "undefined") {
|
3786
|
+
log("Selector " + selector + " not properly defined - ignoring")
|
3787
|
+
}
|
3788
|
+
else {
|
3789
|
+
collection.addBehavior(selector, dispatching[selector])
|
3790
|
+
}
|
3791
|
+
}
|
3792
|
+
jQuery(window).load( function(){ Ninja.go() } )
|
3793
|
+
},
|
3794
|
+
|
3795
|
+
badBehavior: function(nonsense) {
|
3796
|
+
throw new Error("Called Ninja.behavior() after Ninja.go() - don't do that. 'Go' means 'I'm done, please proceed'")
|
3797
|
+
},
|
3798
|
+
|
3799
|
+
respondToJson: function(handlerConfig) {
|
3800
|
+
this.jsonDispatcher.addHandler(handlerConfig)
|
3801
|
+
},
|
3802
|
+
|
3803
|
+
go: function() {
|
3804
|
+
var Ninja = this
|
3805
|
+
|
3806
|
+
function handleMutation(evnt) {
|
3807
|
+
Ninja.tools.getRootCollection().mutationEventTriggered(evnt);
|
3808
|
+
}
|
3809
|
+
|
3810
|
+
if(this.behavior != this.misbehavior) {
|
3811
|
+
var rootOfDocument = this.tools.getRootOfDocument()
|
3812
|
+
rootOfDocument.bind("DOMSubtreeModified DOMNodeInserted thisChangedDOM", handleMutation);
|
3813
|
+
//If we ever receive either of the W3C DOMMutation events, we don't need our IE based
|
3814
|
+
//hack, so nerf it
|
3815
|
+
rootOfDocument.one("DOMSubtreeModified DOMNodeInserted", function(){
|
3816
|
+
Ninja.tools.detachSyntheticMutationEvents()
|
3817
|
+
})
|
3818
|
+
this.behavior = this.badBehavior
|
3819
|
+
this.tools.fireMutationEvent()
|
3820
|
+
}
|
3821
|
+
}
|
3822
|
+
}
|
3823
|
+
|
3824
|
+
return new NinjaScript()
|
3825
|
+
})
|
3826
|
+
define('ninja/behaviors/utility',["ninja"], function(Ninja) {
|
3827
|
+
Ninja.packageBehaviors(function(ninja) {
|
3828
|
+
return {
|
3829
|
+
suppressChangeEvents: function() {
|
3830
|
+
return new ninja.does({
|
3831
|
+
events: {
|
3832
|
+
DOMSubtreeModified: function(e){},
|
3833
|
+
DOMNodeInserted: function(e){}
|
3834
|
+
}
|
3835
|
+
})
|
3836
|
+
}
|
3837
|
+
}
|
3838
|
+
})
|
3839
|
+
})
|
3840
|
+
define('ninja/behaviors/standard',["ninja", "utils"],
|
3841
|
+
function(Ninja, Utils) {
|
3842
|
+
var log = Utils.log
|
3843
|
+
Ninja.packageBehaviors( function(ninja){
|
3844
|
+
return {
|
3845
|
+
/**
|
3846
|
+
* Ninja.submitsAsAjax(configs) -> null
|
3847
|
+
* - configs(Object): configuration for the behavior, passed directly
|
3848
|
+
* to either submitsAsAjaxLink or submitsAsAjaxForm
|
3849
|
+
*
|
3850
|
+
* Converts either a link or a form to send its requests via AJAX - we
|
3851
|
+
* eval the Javascript we get back. We get an busy overlay if
|
3852
|
+
* configured to do so.
|
3853
|
+
*
|
3854
|
+
* This farms out the actual behavior to submitsAsAjaxLink and
|
3855
|
+
* submitsAsAjaxForm, c.f.
|
3856
|
+
**/
|
3857
|
+
submitsAsAjax: function(configs) {
|
3858
|
+
return new ninja.chooses(function(meta) {
|
3859
|
+
meta.asLink = Ninja.submitsAsAjaxLink(configs),
|
3860
|
+
meta.asForm = Ninja.submitsAsAjaxForm(configs)
|
3861
|
+
},
|
3862
|
+
function(elem) {
|
3863
|
+
switch(elem.tagName.toLowerCase()) {
|
3864
|
+
case "a": return this.asLink
|
3865
|
+
case "form": return this.asForm
|
3866
|
+
}
|
3867
|
+
})
|
3868
|
+
},
|
3869
|
+
|
3870
|
+
|
3871
|
+
/**
|
3872
|
+
* Ninja.submitAsAjaxLink( configs ) -> null
|
3873
|
+
*
|
3874
|
+
* Converts a link to send its GET request via Ajax - we assume that we
|
3875
|
+
* get Javascript back, which is eval'd. While we're waiting, we'll
|
3876
|
+
* throw up a busy overlay if configured to do so. By default, we don't
|
3877
|
+
* use a busy overlay.
|
3878
|
+
*
|
3879
|
+
**/
|
3880
|
+
submitsAsAjaxLink: function(configs) {
|
3881
|
+
configs = Ninja.tools.ensureDefaults(configs,
|
3882
|
+
{ busyElement: function(elem) {
|
3883
|
+
return $(elem).parents('address,blockquote,body,dd,div,p,dl,dt,table,form,ol,ul,tr')[0]
|
3884
|
+
}})
|
3885
|
+
|
3886
|
+
return new ninja.does({
|
3887
|
+
priority: 10,
|
3888
|
+
helpers: {
|
3889
|
+
findOverlay: function(elem) {
|
3890
|
+
return this.deriveElementsFrom(elem, configs.busyElement)
|
3891
|
+
}
|
3892
|
+
},
|
3893
|
+
events: {
|
3894
|
+
click: function(evnt) {
|
3895
|
+
this.overlayAndSubmit(evnt.target, evnt.target.href, configs.actions)
|
3896
|
+
}
|
3897
|
+
}
|
3898
|
+
})
|
3899
|
+
},
|
3900
|
+
|
3901
|
+
/**
|
3902
|
+
* Ninja.submitAsAjaxForm(configs) -> null
|
3903
|
+
*
|
3904
|
+
* Converts a form to send its request via Ajax - we assume that we get
|
3905
|
+
* Javascript back, which is eval'd. We pull the method from the form:
|
3906
|
+
* either from the method attribute itself, a data-method attribute or a
|
3907
|
+
* Method input. While we're waiting, we'll throw up a busy overlay if
|
3908
|
+
* configured to do so. By default, we use the form itself as the busy
|
3909
|
+
* element.
|
3910
|
+
*
|
3911
|
+
**/
|
3912
|
+
submitsAsAjaxForm: function(configs) {
|
3913
|
+
configs = Ninja.tools.ensureDefaults(configs,
|
3914
|
+
{ busyElement: undefined })
|
3915
|
+
|
3916
|
+
return new ninja.does({
|
3917
|
+
priority: 10,
|
3918
|
+
helpers: {
|
3919
|
+
findOverlay: function(elem) {
|
3920
|
+
return this.deriveElementsFrom(elem, configs.busyElement)
|
3921
|
+
}
|
3922
|
+
},
|
3923
|
+
events: {
|
3924
|
+
submit: function(evnt) {
|
3925
|
+
this.overlayAndSubmit(evnt.target, evnt.target.action, configs.actions)
|
3926
|
+
}
|
3927
|
+
}
|
3928
|
+
})
|
3929
|
+
},
|
3930
|
+
|
3931
|
+
|
3932
|
+
/**
|
3933
|
+
* Ninja.becomesAjaxLink( configs ) -> null
|
3934
|
+
*
|
3935
|
+
* Converts a whole form into a link that submits via AJAX. The
|
3936
|
+
* intention is that you create a <form> elements with hidden inputs and
|
3937
|
+
* a single submit button - then when we transform it, you don't lose
|
3938
|
+
* anything in terms of user interface. Like submitsAsAjaxForm, it will
|
3939
|
+
* put up a busy overlay - by default we overlay the element itself
|
3940
|
+
**/
|
3941
|
+
becomesAjaxLink: function(configs) {
|
3942
|
+
configs = Ninja.tools.ensureDefaults(configs, {
|
3943
|
+
busyElement: undefined,
|
3944
|
+
retainedFormAttributes: ["id", "class", "lang", "dir", "title", "data-.*"]
|
3945
|
+
})
|
3946
|
+
|
3947
|
+
return [ Ninja.submitsAsAjax(configs), Ninja.becomesLink(configs) ]
|
3948
|
+
},
|
3949
|
+
|
3950
|
+
/**
|
3951
|
+
* Ninja.becomesLink( configs ) -> null
|
3952
|
+
*
|
3953
|
+
* Replaces a form with a link - the text of the link is based on the
|
3954
|
+
* Submit input of the form. The form itself is pulled out of the
|
3955
|
+
* document until the link is clicked, at which point, it gets stuffed
|
3956
|
+
* back into the document and submitted, so the link behaves exactly
|
3957
|
+
* link submitting the form with its default inputs. The motivation is
|
3958
|
+
* to use hidden-input-only forms for POST interactions, which
|
3959
|
+
* Javascript can convert into links if you want.
|
3960
|
+
*
|
3961
|
+
**/
|
3962
|
+
becomesLink: function(configs) {
|
3963
|
+
configs = Ninja.tools.ensureDefaults(configs, {
|
3964
|
+
retainedFormAttributes: ["id", "class", "lang", "dir", "title", "rel", "data-.*"]
|
3965
|
+
})
|
3966
|
+
|
3967
|
+
return new ninja.does({
|
3968
|
+
priority: 30,
|
3969
|
+
transform: function(form){
|
3970
|
+
var linkText
|
3971
|
+
if ((images = jQuery('input[type=image]', form)).size() > 0){
|
3972
|
+
image = images[0]
|
3973
|
+
linkText = "<img src='" + image.src + "' alt='" + image.alt +"'";
|
3974
|
+
}
|
3975
|
+
else if((submits = jQuery('input[type=submit]', form)).size() > 0) {
|
3976
|
+
submit = submits[0]
|
3977
|
+
if(submits.size() > 1) {
|
3978
|
+
log("Multiple submits. Using: " + submit)
|
3979
|
+
}
|
3980
|
+
linkText = submit.value
|
3981
|
+
}
|
3982
|
+
else {
|
3983
|
+
log("Couldn't find a submit input in form");
|
3984
|
+
this.cantTransform()
|
3985
|
+
}
|
3986
|
+
|
3987
|
+
var link = jQuery("<a rel='nofollow' href='#'>" + linkText + "</a>")
|
3988
|
+
this.copyAttributes(form, link, configs.retainedFormAttributes)
|
3989
|
+
this.stash(jQuery(form).replaceWith(link))
|
3990
|
+
|
3991
|
+
return link
|
3992
|
+
},
|
3993
|
+
events: {
|
3994
|
+
click: function(evnt, elem){
|
3995
|
+
this.cascadeEvent("submit")
|
3996
|
+
}
|
3997
|
+
}
|
3998
|
+
})
|
3999
|
+
|
4000
|
+
},
|
4001
|
+
|
4002
|
+
/**
|
4003
|
+
* Ninja.decay( configs ) -> null
|
4004
|
+
*
|
4005
|
+
* Use for elements that should be transient. For instance, the
|
4006
|
+
* default behavior of failed AJAX calls is to insert a message into a
|
4007
|
+
* div#messages with a "flash" class. You can use this behavior to
|
4008
|
+
* have those disappear after a few seconds.
|
4009
|
+
*
|
4010
|
+
* Configs: { lifetime: 10000, diesFor: 600 }
|
4011
|
+
**/
|
4012
|
+
|
4013
|
+
decays: function(configs) {
|
4014
|
+
configs = Ninja.tools.ensureDefaults(configs, {
|
4015
|
+
lifetime: 10000,
|
4016
|
+
diesFor: 600
|
4017
|
+
})
|
4018
|
+
|
4019
|
+
return new ninja.does({
|
4020
|
+
priority: 100,
|
4021
|
+
transform: function(elem) {
|
4022
|
+
jQuery(elem).delay(configs.lifetime).slideUp(configs.diesFor, function(){
|
4023
|
+
jQuery(elem).remove()
|
4024
|
+
Ninja.tools.fireMutationEvent()
|
4025
|
+
})
|
4026
|
+
},
|
4027
|
+
events: {
|
4028
|
+
click: [function(event) {
|
4029
|
+
jQuery(this.element).remove();
|
4030
|
+
}, "changesDOM"]
|
4031
|
+
}
|
4032
|
+
})
|
4033
|
+
}
|
4034
|
+
};
|
4035
|
+
})
|
4036
|
+
})
|
4037
|
+
define('ninja/behaviors/placeholder',["ninja"],
|
4038
|
+
function(Ninja) {
|
4039
|
+
Ninja.packageBehaviors( function(ninja){
|
4040
|
+
function placeholderSubmitter(inputBehavior) {
|
4041
|
+
return new ninja.does({
|
4042
|
+
priority: 1000,
|
4043
|
+
submit: [function(event, el, oldHandler) {
|
4044
|
+
inputBehavior.prepareForSubmit()
|
4045
|
+
oldHandler(event)
|
4046
|
+
}, "andDoDefault"]
|
4047
|
+
})
|
4048
|
+
}
|
4049
|
+
|
4050
|
+
function grabsPlaceholderText(configs) {
|
4051
|
+
configs = Ninja.tools.ensureDefaults(configs, {
|
4052
|
+
textElementSelector: function(elem) {
|
4053
|
+
return "*[data-for=" + elem.id + "]"
|
4054
|
+
},
|
4055
|
+
findTextElement: function(elem) {
|
4056
|
+
var textHolder = $(configs.textElementSelector(elem))
|
4057
|
+
if(textHolder.length == 0) {
|
4058
|
+
return null
|
4059
|
+
}
|
4060
|
+
return textHolder[0]
|
4061
|
+
}
|
4062
|
+
})
|
4063
|
+
|
4064
|
+
return new ninja.does({
|
4065
|
+
priority: -10,
|
4066
|
+
transform: function(element) {
|
4067
|
+
var label = $(configs.findTextElement(element))
|
4068
|
+
if( label === null ) {
|
4069
|
+
this.cantTransform()
|
4070
|
+
}
|
4071
|
+
this.placeholderText = label.text()
|
4072
|
+
$(element).attr("placeholder", label.text())
|
4073
|
+
this.stash(label.detach())
|
4074
|
+
}
|
4075
|
+
})
|
4076
|
+
}
|
4077
|
+
|
4078
|
+
//Gratefully borrowed from Modernizr
|
4079
|
+
|
4080
|
+
var input_placeholder = !!('placeholder' in document.createElement('input'))
|
4081
|
+
var textarea_placeholder = !!('placeholder' in document.createElement('textarea'))
|
4082
|
+
|
4083
|
+
if(! input_placeholder) {
|
4084
|
+
function alternateInput(passwordField, parentForm) {
|
4085
|
+
return new ninja.does({
|
4086
|
+
helpers: {
|
4087
|
+
prepareForSubmit: function() {
|
4088
|
+
$(this.element).val('')
|
4089
|
+
}
|
4090
|
+
},
|
4091
|
+
transform: function() {
|
4092
|
+
this.applyBehaviors(parentForm, [placeholderSubmitter(this)])
|
4093
|
+
},
|
4094
|
+
events: {
|
4095
|
+
focus: function(event) {
|
4096
|
+
var el = $(this.element)
|
4097
|
+
var id = el.attr("id")
|
4098
|
+
el.attr("id", '')
|
4099
|
+
el.replaceWith(passwordField)
|
4100
|
+
passwordField.attr("id", id)
|
4101
|
+
passwordField.focus()
|
4102
|
+
}
|
4103
|
+
}
|
4104
|
+
})
|
4105
|
+
}
|
4106
|
+
|
4107
|
+
function hasPlaceholderPassword(configs) {
|
4108
|
+
configs = Ninja.tools.ensureDefaults(configs, {
|
4109
|
+
findParentForm: function(elem) {
|
4110
|
+
return elem.parents('form')[0]
|
4111
|
+
},
|
4112
|
+
retainedInputAttributes: [
|
4113
|
+
"name", "class", "style", "title", "lang", "dir",
|
4114
|
+
"size", "maxlength", "alt", "tabindex", "accesskey",
|
4115
|
+
"data-.*"
|
4116
|
+
]
|
4117
|
+
})
|
4118
|
+
return new ninja.does({
|
4119
|
+
priority: 1000,
|
4120
|
+
helpers: {
|
4121
|
+
swapInAlternate: function() {
|
4122
|
+
var el = $(this.element)
|
4123
|
+
var id = el.attr("id")
|
4124
|
+
if(el.val() == '') {
|
4125
|
+
el.attr("id", '')
|
4126
|
+
el.replaceWith(this.placeholderTextInput)
|
4127
|
+
this.placeholderTextInput.attr('id', id)
|
4128
|
+
}
|
4129
|
+
}
|
4130
|
+
},
|
4131
|
+
transform: function(element) {
|
4132
|
+
var replacement
|
4133
|
+
var el = $(element)
|
4134
|
+
|
4135
|
+
replacement = $('<input type="text">')
|
4136
|
+
this.copyAttributes(element, replacement, configs.retainedInputAttributes)
|
4137
|
+
replacement.addClass("ninja_placeholder")
|
4138
|
+
replacement.val(this.placeholderText)
|
4139
|
+
|
4140
|
+
var alternate = alternateInput(el, configs.findParentForm(el))
|
4141
|
+
this.applyBehaviors(replacement, [alternate])
|
4142
|
+
|
4143
|
+
this.placeholderTextInput = replacement
|
4144
|
+
this.swapInAlternate()
|
4145
|
+
|
4146
|
+
return element
|
4147
|
+
},
|
4148
|
+
events: {
|
4149
|
+
blur: function(event) {
|
4150
|
+
this.swapInAlternate()
|
4151
|
+
}
|
4152
|
+
}
|
4153
|
+
})
|
4154
|
+
}
|
4155
|
+
}
|
4156
|
+
|
4157
|
+
if((!input_placeholder) || (!textarea_placeholder)) {
|
4158
|
+
function hasPlaceholderText(configs) {
|
4159
|
+
configs = Ninja.tools.ensureDefaults(configs, {
|
4160
|
+
findParentForm: function(elem) {
|
4161
|
+
return elem.parents('form')[0]
|
4162
|
+
}
|
4163
|
+
})
|
4164
|
+
return new ninja.does({
|
4165
|
+
priority: 1000,
|
4166
|
+
helpers: {
|
4167
|
+
prepareForSubmit: function() {
|
4168
|
+
if($(this.element).hasClass('ninja_placeholder')) {
|
4169
|
+
$(this.element).val('')
|
4170
|
+
}
|
4171
|
+
}
|
4172
|
+
},
|
4173
|
+
transform: function(element) {
|
4174
|
+
var el = $(element)
|
4175
|
+
el.addClass('ninja_placeholder')
|
4176
|
+
el.val(this.placeholderText)
|
4177
|
+
|
4178
|
+
this.applyBehaviors(configs.findParentForm(el), [placeholderSubmitter(this)])
|
4179
|
+
|
4180
|
+
return element
|
4181
|
+
},
|
4182
|
+
events: {
|
4183
|
+
focus: function(event) {
|
4184
|
+
if($(this.element).hasClass('ninja_placeholder')) {
|
4185
|
+
$(this.element).removeClass('ninja_placeholder').val('')
|
4186
|
+
}
|
4187
|
+
},
|
4188
|
+
blur: function(event) {
|
4189
|
+
if($(this.element).val() == '') {
|
4190
|
+
$(this.element).addClass('ninja_placeholder').val(this.placeholderText)
|
4191
|
+
}
|
4192
|
+
}
|
4193
|
+
}
|
4194
|
+
})
|
4195
|
+
}
|
4196
|
+
}
|
4197
|
+
|
4198
|
+
return {
|
4199
|
+
hasPlaceholder: function(configs) {
|
4200
|
+
var behaviors = [grabsPlaceholderText(configs)]
|
4201
|
+
if(!input_placeholder || !textarea_placeholder) {
|
4202
|
+
behaviors.push(
|
4203
|
+
new ninja.chooses(function(meta) {
|
4204
|
+
if(input_placeholder) {
|
4205
|
+
meta.asTextInput = null
|
4206
|
+
meta.asPassword = null
|
4207
|
+
} else {
|
4208
|
+
meta.asTextInput = hasPlaceholderText(configs)
|
4209
|
+
meta.asPassword = hasPlaceholderPassword(configs)
|
4210
|
+
}
|
4211
|
+
|
4212
|
+
if( textarea_placeholder) {
|
4213
|
+
meta.asTextArea = null
|
4214
|
+
} else {
|
4215
|
+
meta.asTextArea = hasPlaceholderText(configs)
|
4216
|
+
}
|
4217
|
+
},
|
4218
|
+
function(elem) {
|
4219
|
+
elem = $(elem)
|
4220
|
+
if(elem.is("input[type=text]")) {
|
4221
|
+
return this.asTextInput
|
4222
|
+
}
|
4223
|
+
else if(elem.is("textarea")) {
|
4224
|
+
return this.asTextArea
|
4225
|
+
}
|
4226
|
+
else if(elem.is("input[type=password]")) {
|
4227
|
+
return this.asPassword
|
4228
|
+
}
|
4229
|
+
}))
|
4230
|
+
}
|
4231
|
+
return behaviors
|
4232
|
+
}
|
4233
|
+
}
|
4234
|
+
})
|
4235
|
+
})
|
4236
|
+
define('ninja/behaviors/trigger-on',["ninja"],
|
4237
|
+
function(Ninja) {
|
4238
|
+
Ninja.packageBehaviors( function(ninja) {
|
4239
|
+
return {
|
4240
|
+
triggersOnSelect: function(configs) {
|
4241
|
+
configs = Ninja.tools.ensureDefaults(configs,
|
4242
|
+
{
|
4243
|
+
busyElement: undefined,
|
4244
|
+
placeholderText: "Select to go",
|
4245
|
+
placeholderValue: "instructions"
|
4246
|
+
})
|
4247
|
+
var jsonActions = configs
|
4248
|
+
if (typeof(configs.actions) === "object") {
|
4249
|
+
jsonActions = configs.actions
|
4250
|
+
}
|
4251
|
+
|
4252
|
+
return new ninja.does({
|
4253
|
+
priority: 20,
|
4254
|
+
helpers: {
|
4255
|
+
findOverlay: function(elem) {
|
4256
|
+
return this.deriveElementsFrom(elem, configs.busyElement)
|
4257
|
+
}
|
4258
|
+
},
|
4259
|
+
transform: function(form) {
|
4260
|
+
var select = $(form).find("select").first()
|
4261
|
+
if( typeof select == "undefined" ) {
|
4262
|
+
this.cantTransform()
|
4263
|
+
}
|
4264
|
+
select.prepend("<option value='"+ configs.placeholderValue +"'> " + configs.placeholderText + "</option>")
|
4265
|
+
select.val(configs.placeholderValue)
|
4266
|
+
$(form).find("input[type='submit']").remove()
|
4267
|
+
return form
|
4268
|
+
},
|
4269
|
+
events: {
|
4270
|
+
change: [
|
4271
|
+
function(evnt, elem) {
|
4272
|
+
this.overlayAndSubmit(elem, elem.action, jsonActions)
|
4273
|
+
|
4274
|
+
}, "andDoDefault" ]
|
4275
|
+
}
|
4276
|
+
|
4277
|
+
})
|
4278
|
+
}
|
4279
|
+
};
|
4280
|
+
})
|
4281
|
+
})
|
4282
|
+
define('ninja/behaviors/confirm',["ninja"],
|
4283
|
+
function(Ninja){
|
4284
|
+
Ninja.packageBehaviors( function(ninja) {
|
4285
|
+
return {
|
4286
|
+
confirms: function(configs) {
|
4287
|
+
|
4288
|
+
configs = Ninja.tools.ensureDefaults(configs,
|
4289
|
+
{ confirmMessage: function(elem){
|
4290
|
+
return $(elem).attr('data-confirm')
|
4291
|
+
}})
|
4292
|
+
if(typeof configs.confirmMessage == "string"){
|
4293
|
+
message = configs.confirmMessage
|
4294
|
+
configs.confirmMessage = function(elem){
|
4295
|
+
return message
|
4296
|
+
}
|
4297
|
+
}
|
4298
|
+
|
4299
|
+
function confirmDefault(event,elem) {
|
4300
|
+
if(!confirm(configs.confirmMessage(elem))) {
|
4301
|
+
event.preventDefault()
|
4302
|
+
event.preventFallthrough()
|
4303
|
+
}
|
4304
|
+
}
|
4305
|
+
|
4306
|
+
return new ninja.selects({
|
4307
|
+
"form": new ninja.does({
|
4308
|
+
priority: 20,
|
4309
|
+
events: { submit: [confirmDefault, "andDoDefault"] }
|
4310
|
+
}),
|
4311
|
+
"a,input": new ninja.does({
|
4312
|
+
priority: 20,
|
4313
|
+
events: { click: [confirmDefault, "andDoDefault"] }
|
4314
|
+
})
|
4315
|
+
})
|
4316
|
+
}
|
4317
|
+
}
|
4318
|
+
})
|
4319
|
+
})
|
4320
|
+
define('ninja/behaviors/all',[
|
4321
|
+
"./utility",
|
4322
|
+
"./standard",
|
4323
|
+
"./placeholder",
|
4324
|
+
"./trigger-on",
|
4325
|
+
"./confirm"
|
4326
|
+
],
|
4327
|
+
function(){})
|
4328
|
+
define('ninja/tools/overlay',["utils", "ninja"],
|
4329
|
+
function(Utils, Ninja) {
|
4330
|
+
var forEach = Utils.forEach
|
4331
|
+
|
4332
|
+
function Overlay(list) {
|
4333
|
+
var elements = this.convertToElementArray(list)
|
4334
|
+
this.laziness = 0
|
4335
|
+
var ov = this
|
4336
|
+
this.set = jQuery(jQuery.map(elements, function(element, idx) {
|
4337
|
+
return ov.buildOverlayFor(element)
|
4338
|
+
}))
|
4339
|
+
}
|
4340
|
+
|
4341
|
+
Overlay.prototype = {
|
4342
|
+
convertToElementArray: function(list) {
|
4343
|
+
var h = this
|
4344
|
+
switch(typeof list) {
|
4345
|
+
case 'undefined': return []
|
4346
|
+
case 'boolean': return []
|
4347
|
+
case 'string': return h.convertToElementArray(jQuery(list))
|
4348
|
+
case 'function': return h.convertToElementArray(list())
|
4349
|
+
case 'object': {
|
4350
|
+
//IE8 barfs on 'list instanceof Element'
|
4351
|
+
if("focus" in list && "blur" in list && !("jquery" in list)) {
|
4352
|
+
return [list]
|
4353
|
+
}
|
4354
|
+
else if("length" in list && "0" in list) {
|
4355
|
+
var result = []
|
4356
|
+
forEach(list, function(element) {
|
4357
|
+
result = result.concat(h.convertToElementArray(element))
|
4358
|
+
})
|
4359
|
+
return result
|
4360
|
+
}
|
4361
|
+
else {
|
4362
|
+
return []
|
4363
|
+
}
|
4364
|
+
}
|
4365
|
+
}
|
4366
|
+
},
|
4367
|
+
|
4368
|
+
buildOverlayFor: function(elem) {
|
4369
|
+
var overlay = jQuery(document.createElement("div"))
|
4370
|
+
var hideMe = jQuery(elem)
|
4371
|
+
var offset = hideMe.offset()
|
4372
|
+
overlay.css("position", "absolute")
|
4373
|
+
overlay.css("top", offset.top)
|
4374
|
+
overlay.css("left", offset.left)
|
4375
|
+
overlay.width(hideMe.outerWidth())
|
4376
|
+
overlay.height(hideMe.outerHeight())
|
4377
|
+
overlay.css("zIndex", "2")
|
4378
|
+
overlay.css("display", "none")
|
4379
|
+
return overlay[0]
|
4380
|
+
},
|
4381
|
+
affix: function() {
|
4382
|
+
this.set.appendTo(jQuery("body"))
|
4383
|
+
overlaySet = this.set
|
4384
|
+
window.setTimeout(function() {
|
4385
|
+
overlaySet.css("display", "block")
|
4386
|
+
}, this.laziness)
|
4387
|
+
},
|
4388
|
+
remove: function() {
|
4389
|
+
this.set.remove()
|
4390
|
+
}
|
4391
|
+
}
|
4392
|
+
|
4393
|
+
|
4394
|
+
Ninja.packageTools({
|
4395
|
+
overlay: function() {
|
4396
|
+
// I really liked using
|
4397
|
+
//return new Overlay([].map.apply(arguments,[function(i) {return i}]))
|
4398
|
+
//but IE8 doesn't implement ECMA 2.6.2 5th ed.
|
4399
|
+
|
4400
|
+
return new Overlay(jQuery.makeArray(arguments))
|
4401
|
+
},
|
4402
|
+
busyOverlay: function(elem) {
|
4403
|
+
var overlay = this.overlay(elem)
|
4404
|
+
overlay.set.addClass("ninja_busy")
|
4405
|
+
overlay.laziness = this.ninja.config.busyLaziness
|
4406
|
+
return overlay
|
4407
|
+
},
|
4408
|
+
//Currently, this doesn't respect changes to the original block...
|
4409
|
+
//There should be an "Overlay behavior" that gets applied
|
4410
|
+
buildOverlayFor: function(elem) {
|
4411
|
+
var overlay = jQuery(document.createElement("div"))
|
4412
|
+
var hideMe = jQuery(elem)
|
4413
|
+
var offset = hideMe.offset()
|
4414
|
+
overlay.css("position", "absolute")
|
4415
|
+
overlay.css("top", offset.top)
|
4416
|
+
overlay.css("left", offset.left)
|
4417
|
+
overlay.width(hideMe.outerWidth())
|
4418
|
+
overlay.height(hideMe.outerHeight())
|
4419
|
+
overlay.css("zIndex", "2")
|
4420
|
+
return overlay
|
4421
|
+
}
|
4422
|
+
})
|
4423
|
+
|
4424
|
+
return Overlay
|
4425
|
+
})
|
4426
|
+
|
4427
|
+
define('ninja/tools/ajax-submitter',["ninja", "utils", "./json-dispatcher", "./overlay"], function(Ninja, Utils, jH, O) {
|
4428
|
+
var log = Utils.log
|
4429
|
+
|
4430
|
+
function AjaxSubmitter() {
|
4431
|
+
this.formData = []
|
4432
|
+
this.action = "/"
|
4433
|
+
this.method = "GET"
|
4434
|
+
this.dataType = 'script'
|
4435
|
+
|
4436
|
+
return this
|
4437
|
+
}
|
4438
|
+
|
4439
|
+
AjaxSubmitter.prototype = {
|
4440
|
+
submit: function() {
|
4441
|
+
log("Computed method: " + this.method)
|
4442
|
+
jQuery.ajax(this.ajaxData())
|
4443
|
+
},
|
4444
|
+
|
4445
|
+
sourceForm: function(form) {
|
4446
|
+
this.formData = jQuery(form).serializeArray()
|
4447
|
+
},
|
4448
|
+
|
4449
|
+
ajaxData: function() {
|
4450
|
+
return {
|
4451
|
+
data: this.formData,
|
4452
|
+
dataType: this.dataType,
|
4453
|
+
url: this.action,
|
4454
|
+
type: this.method,
|
4455
|
+
complete: this.responseHandler(),
|
4456
|
+
success: this.successHandler(),
|
4457
|
+
error: this.onError
|
4458
|
+
}
|
4459
|
+
},
|
4460
|
+
|
4461
|
+
successHandler: function() {
|
4462
|
+
var submitter = this
|
4463
|
+
return function(data, statusTxt, xhr) {
|
4464
|
+
submitter.onSuccess(xhr, statusTxt, data)
|
4465
|
+
}
|
4466
|
+
},
|
4467
|
+
|
4468
|
+
responseHandler: function() {
|
4469
|
+
var submitter = this
|
4470
|
+
return function(xhr, statusTxt) {
|
4471
|
+
submitter.onResponse(xhr, statusTxt)
|
4472
|
+
Ninja.tools.fireMutationEvent()
|
4473
|
+
}
|
4474
|
+
},
|
4475
|
+
|
4476
|
+
onResponse: function(xhr, statusTxt) {
|
4477
|
+
},
|
4478
|
+
onSuccess: function(xhr, statusTxt, data) {
|
4479
|
+
},
|
4480
|
+
onError: function(xhr, statusTxt, errorThrown) {
|
4481
|
+
log(xhr.responseText)
|
4482
|
+
Ninja.tools.message("Server error: " + xhr.statusText, "error")
|
4483
|
+
}
|
4484
|
+
}
|
4485
|
+
|
4486
|
+
|
4487
|
+
Ninja.packageTools({
|
4488
|
+
ajaxSubmitter: function() {
|
4489
|
+
return new AjaxSubmitter()
|
4490
|
+
},
|
4491
|
+
|
4492
|
+
ajaxToJson: function(desc) {
|
4493
|
+
var submitter = this.ajaxSubmitter()
|
4494
|
+
submitter.dataType = 'json'
|
4495
|
+
submitter.onSuccess = function(xhr, statusText, data) {
|
4496
|
+
Ninja.jsonDispatcher.dispatch(data)
|
4497
|
+
}
|
4498
|
+
return submitter
|
4499
|
+
},
|
4500
|
+
|
4501
|
+
overlayAndSubmit: function(target, action, jsonHandling) {
|
4502
|
+
var overlay = this.busyOverlay(this.findOverlay(target))
|
4503
|
+
|
4504
|
+
var submitter
|
4505
|
+
if( typeof jsonHandling == "undefined" ) {
|
4506
|
+
submitter = this.ajaxSubmitter()
|
4507
|
+
}
|
4508
|
+
else {
|
4509
|
+
submitter = this.ajaxToJson(jsonHandling)
|
4510
|
+
}
|
4511
|
+
|
4512
|
+
submitter.sourceForm(target)
|
4513
|
+
|
4514
|
+
submitter.action = action
|
4515
|
+
submitter.method = this.extractMethod(target, submitter.formData)
|
4516
|
+
|
4517
|
+
submitter.onResponse = function(xhr, statusTxt) {
|
4518
|
+
overlay.remove()
|
4519
|
+
}
|
4520
|
+
overlay.affix()
|
4521
|
+
submitter.submit()
|
4522
|
+
}
|
4523
|
+
})
|
4524
|
+
|
4525
|
+
|
4526
|
+
return AjaxSubmitter
|
4527
|
+
})
|
4528
|
+
define('ninja/tools/all',[
|
4529
|
+
"./overlay",
|
4530
|
+
"./ajax-submitter",
|
4531
|
+
"./json-dispatcher"
|
4532
|
+
],
|
4533
|
+
function() { })
|
4534
|
+
define('ninja/jquery',["ninja"], function(Ninja) {
|
4535
|
+
jQuery.extend(
|
4536
|
+
{
|
4537
|
+
ninja: Ninja,
|
4538
|
+
behavior: Ninja.behavior
|
4539
|
+
}
|
4540
|
+
);
|
4541
|
+
})
|
4542
|
+
window["Ninja"] = {
|
4543
|
+
orderList: [],
|
4544
|
+
orders: function(order_func){
|
4545
|
+
this.orderList.push(order_func)
|
4546
|
+
}
|
4547
|
+
}
|
4548
|
+
require([
|
4549
|
+
"ninja",
|
4550
|
+
"ninja/behaviors/all",
|
4551
|
+
"ninja/tools/all",
|
4552
|
+
"ninja/jquery"
|
4553
|
+
], function(Ninja, stdBehaviors, placeholder, triggerOn, allTools, jquery) {
|
4554
|
+
var ninjaOrders = window["Ninja"].orderList
|
4555
|
+
var ordersLength = ninjaOrders.length
|
4556
|
+
|
4557
|
+
window["Ninja"] = Ninja
|
4558
|
+
Ninja['behavior'] = Ninja.behavior
|
4559
|
+
for(var i = 0; i < ordersLength; i++) {
|
4560
|
+
ninjaOrders[i](Ninja)
|
4561
|
+
}
|
4562
|
+
Ninja.orders = function(funk) {
|
4563
|
+
funk(this) //because it amuses JDL, that's why.
|
4564
|
+
}
|
4565
|
+
})
|
4566
|
+
define("main", function(){});
|