swagger-ui 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +7 -0
- data/Gemfile.lock +53 -0
- data/LICENSE.txt +20 -0
- data/README.md +54 -0
- data/Rakefile +25 -0
- data/VERSION +1 -0
- data/examples/index.html.haml +35 -0
- data/lib/generators/swagger/install/install_generator.rb +10 -0
- data/lib/swagger/api.rb +24 -0
- data/lib/swagger/document.rb +23 -0
- data/lib/swagger/operation.rb +61 -0
- data/lib/swagger/version.rb +3 -0
- data/lib/swagger.rb +13 -0
- data/public/javascripts/swagger.js +3943 -0
- data/public/stylesheets/swagger.css +1371 -0
- data/swagger-ui.gemspec +59 -0
- data/swagger.gemspec +57 -0
- metadata +100 -0
@@ -0,0 +1,3943 @@
|
|
1
|
+
/*
|
2
|
+
JQuery
|
3
|
+
*/
|
4
|
+
/*! jQuery v@1.8.0 jquery.com | jquery.org/license */
|
5
|
+
(function(a,b){function G(a){var b=F[a]={};return p.each(a.split(s),function(a,c){b[c]=!0}),b}function J(a,c,d){if(d===b&&a.nodeType===1){var e="data-"+c.replace(I,"-$1").toLowerCase();d=a.getAttribute(e);if(typeof d=="string"){try{d=d==="true"?!0:d==="false"?!1:d==="null"?null:+d+""===d?+d:H.test(d)?p.parseJSON(d):d}catch(f){}p.data(a,c,d)}else d=b}return d}function K(a){var b;for(b in a){if(b==="data"&&p.isEmptyObject(a[b]))continue;if(b!=="toJSON")return!1}return!0}function ba(){return!1}function bb(){return!0}function bh(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function bi(a,b){do a=a[b];while(a&&a.nodeType!==1);return a}function bj(a,b,c){b=b||0;if(p.isFunction(b))return p.grep(a,function(a,d){var e=!!b.call(a,d,a);return e===c});if(b.nodeType)return p.grep(a,function(a,d){return a===b===c});if(typeof b=="string"){var d=p.grep(a,function(a){return a.nodeType===1});if(be.test(b))return p.filter(b,d,!c);b=p.filter(b,d)}return p.grep(a,function(a,d){return p.inArray(a,b)>=0===c})}function bk(a){var b=bl.split("|"),c=a.createDocumentFragment();if(c.createElement)while(b.length)c.createElement(b.pop());return c}function bC(a,b){return a.getElementsByTagName(b)[0]||a.appendChild(a.ownerDocument.createElement(b))}function bD(a,b){if(b.nodeType!==1||!p.hasData(a))return;var c,d,e,f=p._data(a),g=p._data(b,f),h=f.events;if(h){delete g.handle,g.events={};for(c in h)for(d=0,e=h[c].length;d<e;d++)p.event.add(b,c,h[c][d])}g.data&&(g.data=p.extend({},g.data))}function bE(a,b){var c;if(b.nodeType!==1)return;b.clearAttributes&&b.clearAttributes(),b.mergeAttributes&&b.mergeAttributes(a),c=b.nodeName.toLowerCase(),c==="object"?(b.parentNode&&(b.outerHTML=a.outerHTML),p.support.html5Clone&&a.innerHTML&&!p.trim(b.innerHTML)&&(b.innerHTML=a.innerHTML)):c==="input"&&bv.test(a.type)?(b.defaultChecked=b.checked=a.checked,b.value!==a.value&&(b.value=a.value)):c==="option"?b.selected=a.defaultSelected:c==="input"||c==="textarea"?b.defaultValue=a.defaultValue:c==="script"&&b.text!==a.text&&(b.text=a.text),b.removeAttribute(p.expando)}function bF(a){return typeof a.getElementsByTagName!="undefined"?a.getElementsByTagName("*"):typeof a.querySelectorAll!="undefined"?a.querySelectorAll("*"):[]}function bG(a){bv.test(a.type)&&(a.defaultChecked=a.checked)}function bX(a,b){if(b in a)return b;var c=b.charAt(0).toUpperCase()+b.slice(1),d=b,e=bV.length;while(e--){b=bV[e]+c;if(b in a)return b}return d}function bY(a,b){return a=b||a,p.css(a,"display")==="none"||!p.contains(a.ownerDocument,a)}function bZ(a,b){var c,d,e=[],f=0,g=a.length;for(;f<g;f++){c=a[f];if(!c.style)continue;e[f]=p._data(c,"olddisplay"),b?(!e[f]&&c.style.display==="none"&&(c.style.display=""),c.style.display===""&&bY(c)&&(e[f]=p._data(c,"olddisplay",cb(c.nodeName)))):(d=bH(c,"display"),!e[f]&&d!=="none"&&p._data(c,"olddisplay",d))}for(f=0;f<g;f++){c=a[f];if(!c.style)continue;if(!b||c.style.display==="none"||c.style.display==="")c.style.display=b?e[f]||"":"none"}return a}function b$(a,b,c){var d=bO.exec(b);return d?Math.max(0,d[1]-(c||0))+(d[2]||"px"):b}function b_(a,b,c,d){var e=c===(d?"border":"content")?4:b==="width"?1:0,f=0;for(;e<4;e+=2)c==="margin"&&(f+=p.css(a,c+bU[e],!0)),d?(c==="content"&&(f-=parseFloat(bH(a,"padding"+bU[e]))||0),c!=="margin"&&(f-=parseFloat(bH(a,"border"+bU[e]+"Width"))||0)):(f+=parseFloat(bH(a,"padding"+bU[e]))||0,c!=="padding"&&(f+=parseFloat(bH(a,"border"+bU[e]+"Width"))||0));return f}function ca(a,b,c){var d=b==="width"?a.offsetWidth:a.offsetHeight,e=!0,f=p.support.boxSizing&&p.css(a,"boxSizing")==="border-box";if(d<=0){d=bH(a,b);if(d<0||d==null)d=a.style[b];if(bP.test(d))return d;e=f&&(p.support.boxSizingReliable||d===a.style[b]),d=parseFloat(d)||0}return d+b_(a,b,c||(f?"border":"content"),e)+"px"}function cb(a){if(bR[a])return bR[a];var b=p("<"+a+">").appendTo(e.body),c=b.css("display");b.remove();if(c==="none"||c===""){bI=e.body.appendChild(bI||p.extend(e.createElement("iframe"),{frameBorder:0,width:0,height:0}));if(!bJ||!bI.createElement)bJ=(bI.contentWindow||bI.contentDocument).document,bJ.write("<!doctype html><html><body>"),bJ.close();b=bJ.body.appendChild(bJ.createElement(a)),c=bH(b,"display"),e.body.removeChild(bI)}return bR[a]=c,c}function ch(a,b,c,d){var e;if(p.isArray(b))p.each(b,function(b,e){c||cd.test(a)?d(a,e):ch(a+"["+(typeof e=="object"?b:"")+"]",e,c,d)});else if(!c&&p.type(b)==="object")for(e in b)ch(a+"["+e+"]",b[e],c,d);else d(a,b)}function cy(a){return function(b,c){typeof b!="string"&&(c=b,b="*");var d,e,f,g=b.toLowerCase().split(s),h=0,i=g.length;if(p.isFunction(c))for(;h<i;h++)d=g[h],f=/^\+/.test(d),f&&(d=d.substr(1)||"*"),e=a[d]=a[d]||[],e[f?"unshift":"push"](c)}}function cz(a,c,d,e,f,g){f=f||c.dataTypes[0],g=g||{},g[f]=!0;var h,i=a[f],j=0,k=i?i.length:0,l=a===cu;for(;j<k&&(l||!h);j++)h=i[j](c,d,e),typeof h=="string"&&(!l||g[h]?h=b:(c.dataTypes.unshift(h),h=cz(a,c,d,e,h,g)));return(l||!h)&&!g["*"]&&(h=cz(a,c,d,e,"*",g)),h}function cA(a,c){var d,e,f=p.ajaxSettings.flatOptions||{};for(d in c)c[d]!==b&&((f[d]?a:e||(e={}))[d]=c[d]);e&&p.extend(!0,a,e)}function cB(a,c,d){var e,f,g,h,i=a.contents,j=a.dataTypes,k=a.responseFields;for(f in k)f in d&&(c[k[f]]=d[f]);while(j[0]==="*")j.shift(),e===b&&(e=a.mimeType||c.getResponseHeader("content-type"));if(e)for(f in i)if(i[f]&&i[f].test(e)){j.unshift(f);break}if(j[0]in d)g=j[0];else{for(f in d){if(!j[0]||a.converters[f+" "+j[0]]){g=f;break}h||(h=f)}g=g||h}if(g)return g!==j[0]&&j.unshift(g),d[g]}function cC(a,b){var c,d,e,f,g=a.dataTypes.slice(),h=g[0],i={},j=0;a.dataFilter&&(b=a.dataFilter(b,a.dataType));if(g[1])for(c in a.converters)i[c.toLowerCase()]=a.converters[c];for(;e=g[++j];)if(e!=="*"){if(h!=="*"&&h!==e){c=i[h+" "+e]||i["* "+e];if(!c)for(d in i){f=d.split(" ");if(f[1]===e){c=i[h+" "+f[0]]||i["* "+f[0]];if(c){c===!0?c=i[d]:i[d]!==!0&&(e=f[0],g.splice(j--,0,e));break}}}if(c!==!0)if(c&&a["throws"])b=c(b);else try{b=c(b)}catch(k){return{state:"parsererror",error:c?k:"No conversion from "+h+" to "+e}}}h=e}return{state:"success",data:b}}function cK(){try{return new a.XMLHttpRequest}catch(b){}}function cL(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}function cT(){return setTimeout(function(){cM=b},0),cM=p.now()}function cU(a,b){p.each(b,function(b,c){var d=(cS[b]||[]).concat(cS["*"]),e=0,f=d.length;for(;e<f;e++)if(d[e].call(a,b,c))return})}function cV(a,b,c){var d,e=0,f=0,g=cR.length,h=p.Deferred().always(function(){delete i.elem}),i=function(){var b=cM||cT(),c=Math.max(0,j.startTime+j.duration-b),d=1-(c/j.duration||0),e=0,f=j.tweens.length;for(;e<f;e++)j.tweens[e].run(d);return h.notifyWith(a,[j,d,c]),d<1&&f?c:(h.resolveWith(a,[j]),!1)},j=h.promise({elem:a,props:p.extend({},b),opts:p.extend(!0,{specialEasing:{}},c),originalProperties:b,originalOptions:c,startTime:cM||cT(),duration:c.duration,tweens:[],createTween:function(b,c,d){var e=p.Tween(a,j.opts,b,c,j.opts.specialEasing[b]||j.opts.easing);return j.tweens.push(e),e},stop:function(b){var c=0,d=b?j.tweens.length:0;for(;c<d;c++)j.tweens[c].run(1);return b?h.resolveWith(a,[j,b]):h.rejectWith(a,[j,b]),this}}),k=j.props;cW(k,j.opts.specialEasing);for(;e<g;e++){d=cR[e].call(j,a,k,j.opts);if(d)return d}return cU(j,k),p.isFunction(j.opts.start)&&j.opts.start.call(a,j),p.fx.timer(p.extend(i,{anim:j,queue:j.opts.queue,elem:a})),j.progress(j.opts.progress).done(j.opts.done,j.opts.complete).fail(j.opts.fail).always(j.opts.always)}function cW(a,b){var c,d,e,f,g;for(c in a){d=p.camelCase(c),e=b[d],f=a[c],p.isArray(f)&&(e=f[1],f=a[c]=f[0]),c!==d&&(a[d]=f,delete a[c]),g=p.cssHooks[d];if(g&&"expand"in g){f=g.expand(f),delete a[d];for(c in f)c in a||(a[c]=f[c],b[c]=e)}else b[d]=e}}function cX(a,b,c){var d,e,f,g,h,i,j,k,l=this,m=a.style,n={},o=[],q=a.nodeType&&bY(a);c.queue||(j=p._queueHooks(a,"fx"),j.unqueued==null&&(j.unqueued=0,k=j.empty.fire,j.empty.fire=function(){j.unqueued||k()}),j.unqueued++,l.always(function(){l.always(function(){j.unqueued--,p.queue(a,"fx").length||j.empty.fire()})})),a.nodeType===1&&("height"in b||"width"in b)&&(c.overflow=[m.overflow,m.overflowX,m.overflowY],p.css(a,"display")==="inline"&&p.css(a,"float")==="none"&&(!p.support.inlineBlockNeedsLayout||cb(a.nodeName)==="inline"?m.display="inline-block":m.zoom=1)),c.overflow&&(m.overflow="hidden",p.support.shrinkWrapBlocks||l.done(function(){m.overflow=c.overflow[0],m.overflowX=c.overflow[1],m.overflowY=c.overflow[2]}));for(d in b){f=b[d];if(cO.exec(f)){delete b[d];if(f===(q?"hide":"show"))continue;o.push(d)}}g=o.length;if(g){h=p._data(a,"fxshow")||p._data(a,"fxshow",{}),q?p(a).show():l.done(function(){p(a).hide()}),l.done(function(){var b;p.removeData(a,"fxshow",!0);for(b in n)p.style(a,b,n[b])});for(d=0;d<g;d++)e=o[d],i=l.createTween(e,q?h[e]:0),n[e]=h[e]||p.style(a,e),e in h||(h[e]=i.start,q&&(i.end=i.start,i.start=e==="width"||e==="height"?1:0))}}function cY(a,b,c,d,e){return new cY.prototype.init(a,b,c,d,e)}function cZ(a,b){var c,d={height:a},e=0;for(;e<4;e+=2-b)c=bU[e],d["margin"+c]=d["padding"+c]=a;return b&&(d.opacity=d.width=a),d}function c_(a){return p.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}var c,d,e=a.document,f=a.location,g=a.navigator,h=a.jQuery,i=a.$,j=Array.prototype.push,k=Array.prototype.slice,l=Array.prototype.indexOf,m=Object.prototype.toString,n=Object.prototype.hasOwnProperty,o=String.prototype.trim,p=function(a,b){return new p.fn.init(a,b,c)},q=/[\-+]?(?:\d*\.|)\d+(?:[eE][\-+]?\d+|)/.source,r=/\S/,s=/\s+/,t=r.test(" ")?/^[\s\xA0]+|[\s\xA0]+$/g:/^\s+|\s+$/g,u=/^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,v=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,w=/^[\],:{}\s]*$/,x=/(?:^|:|,)(?:\s*\[)+/g,y=/\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,z=/"[^"\\\r\n]*"|true|false|null|-?(?:\d\d*\.|)\d+(?:[eE][\-+]?\d+|)/g,A=/^-ms-/,B=/-([\da-z])/gi,C=function(a,b){return(b+"").toUpperCase()},D=function(){e.addEventListener?(e.removeEventListener("DOMContentLoaded",D,!1),p.ready()):e.readyState==="complete"&&(e.detachEvent("onreadystatechange",D),p.ready())},E={};p.fn=p.prototype={constructor:p,init:function(a,c,d){var f,g,h,i;if(!a)return this;if(a.nodeType)return this.context=this[0]=a,this.length=1,this;if(typeof a=="string"){a.charAt(0)==="<"&&a.charAt(a.length-1)===">"&&a.length>=3?f=[null,a,null]:f=u.exec(a);if(f&&(f[1]||!c)){if(f[1])return c=c instanceof p?c[0]:c,i=c&&c.nodeType?c.ownerDocument||c:e,a=p.parseHTML(f[1],i,!0),v.test(f[1])&&p.isPlainObject(c)&&this.attr.call(a,c,!0),p.merge(this,a);g=e.getElementById(f[2]);if(g&&g.parentNode){if(g.id!==f[2])return d.find(a);this.length=1,this[0]=g}return this.context=e,this.selector=a,this}return!c||c.jquery?(c||d).find(a):this.constructor(c).find(a)}return p.isFunction(a)?d.ready(a):(a.selector!==b&&(this.selector=a.selector,this.context=a.context),p.makeArray(a,this))},selector:"",jquery:"1.8.0",length:0,size:function(){return this.length},toArray:function(){return k.call(this)},get:function(a){return a==null?this.toArray():a<0?this[this.length+a]:this[a]},pushStack:function(a,b,c){var d=p.merge(this.constructor(),a);return d.prevObject=this,d.context=this.context,b==="find"?d.selector=this.selector+(this.selector?" ":"")+c:b&&(d.selector=this.selector+"."+b+"("+c+")"),d},each:function(a,b){return p.each(this,a,b)},ready:function(a){return p.ready.promise().done(a),this},eq:function(a){return a=+a,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(k.apply(this,arguments),"slice",k.call(arguments).join(","))},map:function(a){return this.pushStack(p.map(this,function(b,c){return a.call(b,c,b)}))},end:function(){return this.prevObject||this.constructor(null)},push:j,sort:[].sort,splice:[].splice},p.fn.init.prototype=p.fn,p.extend=p.fn.extend=function(){var a,c,d,e,f,g,h=arguments[0]||{},i=1,j=arguments.length,k=!1;typeof h=="boolean"&&(k=h,h=arguments[1]||{},i=2),typeof h!="object"&&!p.isFunction(h)&&(h={}),j===i&&(h=this,--i);for(;i<j;i++)if((a=arguments[i])!=null)for(c in a){d=h[c],e=a[c];if(h===e)continue;k&&e&&(p.isPlainObject(e)||(f=p.isArray(e)))?(f?(f=!1,g=d&&p.isArray(d)?d:[]):g=d&&p.isPlainObject(d)?d:{},h[c]=p.extend(k,g,e)):e!==b&&(h[c]=e)}return h},p.extend({noConflict:function(b){return a.$===p&&(a.$=i),b&&a.jQuery===p&&(a.jQuery=h),p},isReady:!1,readyWait:1,holdReady:function(a){a?p.readyWait++:p.ready(!0)},ready:function(a){if(a===!0?--p.readyWait:p.isReady)return;if(!e.body)return setTimeout(p.ready,1);p.isReady=!0;if(a!==!0&&--p.readyWait>0)return;d.resolveWith(e,[p]),p.fn.trigger&&p(e).trigger("ready").off("ready")},isFunction:function(a){return p.type(a)==="function"},isArray:Array.isArray||function(a){return p.type(a)==="array"},isWindow:function(a){return a!=null&&a==a.window},isNumeric:function(a){return!isNaN(parseFloat(a))&&isFinite(a)},type:function(a){return a==null?String(a):E[m.call(a)]||"object"},isPlainObject:function(a){if(!a||p.type(a)!=="object"||a.nodeType||p.isWindow(a))return!1;try{if(a.constructor&&!n.call(a,"constructor")&&!n.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}var d;for(d in a);return d===b||n.call(a,d)},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},error:function(a){throw new Error(a)},parseHTML:function(a,b,c){var d;return!a||typeof a!="string"?null:(typeof b=="boolean"&&(c=b,b=0),b=b||e,(d=v.exec(a))?[b.createElement(d[1])]:(d=p.buildFragment([a],b,c?null:[]),p.merge([],(d.cacheable?p.clone(d.fragment):d.fragment).childNodes)))},parseJSON:function(b){if(!b||typeof b!="string")return null;b=p.trim(b);if(a.JSON&&a.JSON.parse)return a.JSON.parse(b);if(w.test(b.replace(y,"@").replace(z,"]").replace(x,"")))return(new Function("return "+b))();p.error("Invalid JSON: "+b)},parseXML:function(c){var d,e;if(!c||typeof c!="string")return null;try{a.DOMParser?(e=new DOMParser,d=e.parseFromString(c,"text/xml")):(d=new ActiveXObject("Microsoft.XMLDOM"),d.async="false",d.loadXML(c))}catch(f){d=b}return(!d||!d.documentElement||d.getElementsByTagName("parsererror").length)&&p.error("Invalid XML: "+c),d},noop:function(){},globalEval:function(b){b&&r.test(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(A,"ms-").replace(B,C)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,c,d){var e,f=0,g=a.length,h=g===b||p.isFunction(a);if(d){if(h){for(e in a)if(c.apply(a[e],d)===!1)break}else for(;f<g;)if(c.apply(a[f++],d)===!1)break}else if(h){for(e in a)if(c.call(a[e],e,a[e])===!1)break}else for(;f<g;)if(c.call(a[f],f,a[f++])===!1)break;return a},trim:o?function(a){return a==null?"":o.call(a)}:function(a){return a==null?"":a.toString().replace(t,"")},makeArray:function(a,b){var c,d=b||[];return a!=null&&(c=p.type(a),a.length==null||c==="string"||c==="function"||c==="regexp"||p.isWindow(a)?j.call(d,a):p.merge(d,a)),d},inArray:function(a,b,c){var d;if(b){if(l)return l.call(b,a,c);d=b.length,c=c?c<0?Math.max(0,d+c):c:0;for(;c<d;c++)if(c in b&&b[c]===a)return c}return-1},merge:function(a,c){var d=c.length,e=a.length,f=0;if(typeof d=="number")for(;f<d;f++)a[e++]=c[f];else while(c[f]!==b)a[e++]=c[f++];return a.length=e,a},grep:function(a,b,c){var d,e=[],f=0,g=a.length;c=!!c;for(;f<g;f++)d=!!b(a[f],f),c!==d&&e.push(a[f]);return e},map:function(a,c,d){var e,f,g=[],h=0,i=a.length,j=a instanceof p||i!==b&&typeof i=="number"&&(i>0&&a[0]&&a[i-1]||i===0||p.isArray(a));if(j)for(;h<i;h++)e=c(a[h],h,d),e!=null&&(g[g.length]=e);else for(f in a)e=c(a[f],f,d),e!=null&&(g[g.length]=e);return g.concat.apply([],g)},guid:1,proxy:function(a,c){var d,e,f;return typeof c=="string"&&(d=a[c],c=a,a=d),p.isFunction(a)?(e=k.call(arguments,2),f=function(){return a.apply(c,e.concat(k.call(arguments)))},f.guid=a.guid=a.guid||f.guid||p.guid++,f):b},access:function(a,c,d,e,f,g,h){var i,j=d==null,k=0,l=a.length;if(d&&typeof d=="object"){for(k in d)p.access(a,c,k,d[k],1,g,e);f=1}else if(e!==b){i=h===b&&p.isFunction(e),j&&(i?(i=c,c=function(a,b,c){return i.call(p(a),c)}):(c.call(a,e),c=null));if(c)for(;k<l;k++)c(a[k],d,i?e.call(a[k],k,c(a[k],d)):e,h);f=1}return f?a:j?c.call(a):l?c(a[0],d):g},now:function(){return(new Date).getTime()}}),p.ready.promise=function(b){if(!d){d=p.Deferred();if(e.readyState==="complete"||e.readyState!=="loading"&&e.addEventListener)setTimeout(p.ready,1);else if(e.addEventListener)e.addEventListener("DOMContentLoaded",D,!1),a.addEventListener("load",p.ready,!1);else{e.attachEvent("onreadystatechange",D),a.attachEvent("onload",p.ready);var c=!1;try{c=a.frameElement==null&&e.documentElement}catch(f){}c&&c.doScroll&&function g(){if(!p.isReady){try{c.doScroll("left")}catch(a){return setTimeout(g,50)}p.ready()}}()}}return d.promise(b)},p.each("Boolean Number String Function Array Date RegExp Object".split(" "),function(a,b){E["[object "+b+"]"]=b.toLowerCase()}),c=p(e);var F={};p.Callbacks=function(a){a=typeof a=="string"?F[a]||G(a):p.extend({},a);var c,d,e,f,g,h,i=[],j=!a.once&&[],k=function(b){c=a.memory&&b,d=!0,h=f||0,f=0,g=i.length,e=!0;for(;i&&h<g;h++)if(i[h].apply(b[0],b[1])===!1&&a.stopOnFalse){c=!1;break}e=!1,i&&(j?j.length&&k(j.shift()):c?i=[]:l.disable())},l={add:function(){if(i){var b=i.length;(function d(b){p.each(b,function(b,c){p.isFunction(c)&&(!a.unique||!l.has(c))?i.push(c):c&&c.length&&d(c)})})(arguments),e?g=i.length:c&&(f=b,k(c))}return this},remove:function(){return i&&p.each(arguments,function(a,b){var c;while((c=p.inArray(b,i,c))>-1)i.splice(c,1),e&&(c<=g&&g--,c<=h&&h--)}),this},has:function(a){return p.inArray(a,i)>-1},empty:function(){return i=[],this},disable:function(){return i=j=c=b,this},disabled:function(){return!i},lock:function(){return j=b,c||l.disable(),this},locked:function(){return!j},fireWith:function(a,b){return b=b||[],b=[a,b.slice?b.slice():b],i&&(!d||j)&&(e?j.push(b):k(b)),this},fire:function(){return l.fireWith(this,arguments),this},fired:function(){return!!d}};return l},p.extend({Deferred:function(a){var b=[["resolve","done",p.Callbacks("once memory"),"resolved"],["reject","fail",p.Callbacks("once memory"),"rejected"],["notify","progress",p.Callbacks("memory")]],c="pending",d={state:function(){return c},always:function(){return e.done(arguments).fail(arguments),this},then:function(){var a=arguments;return p.Deferred(function(c){p.each(b,function(b,d){var f=d[0],g=a[b];e[d[1]](p.isFunction(g)?function(){var a=g.apply(this,arguments);a&&p.isFunction(a.promise)?a.promise().done(c.resolve).fail(c.reject).progress(c.notify):c[f+"With"](this===e?c:this,[a])}:c[f])}),a=null}).promise()},promise:function(a){return typeof a=="object"?p.extend(a,d):d}},e={};return d.pipe=d.then,p.each(b,function(a,f){var g=f[2],h=f[3];d[f[1]]=g.add,h&&g.add(function(){c=h},b[a^1][2].disable,b[2][2].lock),e[f[0]]=g.fire,e[f[0]+"With"]=g.fireWith}),d.promise(e),a&&a.call(e,e),e},when:function(a){var b=0,c=k.call(arguments),d=c.length,e=d!==1||a&&p.isFunction(a.promise)?d:0,f=e===1?a:p.Deferred(),g=function(a,b,c){return function(d){b[a]=this,c[a]=arguments.length>1?k.call(arguments):d,c===h?f.notifyWith(b,c):--e||f.resolveWith(b,c)}},h,i,j;if(d>1){h=new Array(d),i=new Array(d),j=new Array(d);for(;b<d;b++)c[b]&&p.isFunction(c[b].promise)?c[b].promise().done(g(b,j,c)).fail(f.reject).progress(g(b,i,h)):--e}return e||f.resolveWith(j,c),f.promise()}}),p.support=function(){var b,c,d,f,g,h,i,j,k,l,m,n=e.createElement("div");n.setAttribute("className","t"),n.innerHTML=" <link/><table></table><a href='/a'>a</a><input type='checkbox'/>",c=n.getElementsByTagName("*"),d=n.getElementsByTagName("a")[0],d.style.cssText="top:1px;float:left;opacity:.5";if(!c||!c.length||!d)return{};f=e.createElement("select"),g=f.appendChild(e.createElement("option")),h=n.getElementsByTagName("input")[0],b={leadingWhitespace:n.firstChild.nodeType===3,tbody:!n.getElementsByTagName("tbody").length,htmlSerialize:!!n.getElementsByTagName("link").length,style:/top/.test(d.getAttribute("style")),hrefNormalized:d.getAttribute("href")==="/a",opacity:/^0.5/.test(d.style.opacity),cssFloat:!!d.style.cssFloat,checkOn:h.value==="on",optSelected:g.selected,getSetAttribute:n.className!=="t",enctype:!!e.createElement("form").enctype,html5Clone:e.createElement("nav").cloneNode(!0).outerHTML!=="<:nav></:nav>",boxModel:e.compatMode==="CSS1Compat",submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0,boxSizingReliable:!0,pixelPosition:!1},h.checked=!0,b.noCloneChecked=h.cloneNode(!0).checked,f.disabled=!0,b.optDisabled=!g.disabled;try{delete n.test}catch(o){b.deleteExpando=!1}!n.addEventListener&&n.attachEvent&&n.fireEvent&&(n.attachEvent("onclick",m=function(){b.noCloneEvent=!1}),n.cloneNode(!0).fireEvent("onclick"),n.detachEvent("onclick",m)),h=e.createElement("input"),h.value="t",h.setAttribute("type","radio"),b.radioValue=h.value==="t",h.setAttribute("checked","checked"),h.setAttribute("name","t"),n.appendChild(h),i=e.createDocumentFragment(),i.appendChild(n.lastChild),b.checkClone=i.cloneNode(!0).cloneNode(!0).lastChild.checked,b.appendChecked=h.checked,i.removeChild(h),i.appendChild(n);if(n.attachEvent)for(k in{submit:!0,change:!0,focusin:!0})j="on"+k,l=j in n,l||(n.setAttribute(j,"return;"),l=typeof n[j]=="function"),b[k+"Bubbles"]=l;return p(function(){var c,d,f,g,h="padding:0;margin:0;border:0;display:block;overflow:hidden;",i=e.getElementsByTagName("body")[0];if(!i)return;c=e.createElement("div"),c.style.cssText="visibility:hidden;border:0;width:0;height:0;position:static;top:0;margin-top:1px",i.insertBefore(c,i.firstChild),d=e.createElement("div"),c.appendChild(d),d.innerHTML="<table><tr><td></td><td>t</td></tr></table>",f=d.getElementsByTagName("td"),f[0].style.cssText="padding:0;margin:0;border:0;display:none",l=f[0].offsetHeight===0,f[0].style.display="",f[1].style.display="none",b.reliableHiddenOffsets=l&&f[0].offsetHeight===0,d.innerHTML="",d.style.cssText="box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;",b.boxSizing=d.offsetWidth===4,b.doesNotIncludeMarginInBodyOffset=i.offsetTop!==1,a.getComputedStyle&&(b.pixelPosition=(a.getComputedStyle(d,null)||{}).top!=="1%",b.boxSizingReliable=(a.getComputedStyle(d,null)||{width:"4px"}).width==="4px",g=e.createElement("div"),g.style.cssText=d.style.cssText=h,g.style.marginRight=g.style.width="0",d.style.width="1px",d.appendChild(g),b.reliableMarginRight=!parseFloat((a.getComputedStyle(g,null)||{}).marginRight)),typeof d.style.zoom!="undefined"&&(d.innerHTML="",d.style.cssText=h+"width:1px;padding:1px;display:inline;zoom:1",b.inlineBlockNeedsLayout=d.offsetWidth===3,d.style.display="block",d.style.overflow="visible",d.innerHTML="<div></div>",d.firstChild.style.width="5px",b.shrinkWrapBlocks=d.offsetWidth!==3,c.style.zoom=1),i.removeChild(c),c=d=f=g=null}),i.removeChild(n),c=d=f=g=h=i=n=null,b}();var H=/^(?:\{.*\}|\[.*\])$/,I=/([A-Z])/g;p.extend({cache:{},deletedIds:[],uuid:0,expando:"jQuery"+(p.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(a){return a=a.nodeType?p.cache[a[p.expando]]:a[p.expando],!!a&&!K(a)},data:function(a,c,d,e){if(!p.acceptData(a))return;var f,g,h=p.expando,i=typeof c=="string",j=a.nodeType,k=j?p.cache:a,l=j?a[h]:a[h]&&h;if((!l||!k[l]||!e&&!k[l].data)&&i&&d===b)return;l||(j?a[h]=l=p.deletedIds.pop()||++p.uuid:l=h),k[l]||(k[l]={},j||(k[l].toJSON=p.noop));if(typeof c=="object"||typeof c=="function")e?k[l]=p.extend(k[l],c):k[l].data=p.extend(k[l].data,c);return f=k[l],e||(f.data||(f.data={}),f=f.data),d!==b&&(f[p.camelCase(c)]=d),i?(g=f[c],g==null&&(g=f[p.camelCase(c)])):g=f,g},removeData:function(a,b,c){if(!p.acceptData(a))return;var d,e,f,g=a.nodeType,h=g?p.cache:a,i=g?a[p.expando]:p.expando;if(!h[i])return;if(b){d=c?h[i]:h[i].data;if(d){p.isArray(b)||(b in d?b=[b]:(b=p.camelCase(b),b in d?b=[b]:b=b.split(" ")));for(e=0,f=b.length;e<f;e++)delete d[b[e]];if(!(c?K:p.isEmptyObject)(d))return}}if(!c){delete h[i].data;if(!K(h[i]))return}g?p.cleanData([a],!0):p.support.deleteExpando||h!=h.window?delete h[i]:h[i]=null},_data:function(a,b,c){return p.data(a,b,c,!0)},acceptData:function(a){var b=a.nodeName&&p.noData[a.nodeName.toLowerCase()];return!b||b!==!0&&a.getAttribute("classid")===b}}),p.fn.extend({data:function(a,c){var d,e,f,g,h,i=this[0],j=0,k=null;if(a===b){if(this.length){k=p.data(i);if(i.nodeType===1&&!p._data(i,"parsedAttrs")){f=i.attributes;for(h=f.length;j<h;j++)g=f[j].name,g.indexOf("data-")===0&&(g=p.camelCase(g.substring(5)),J(i,g,k[g]));p._data(i,"parsedAttrs",!0)}}return k}return typeof a=="object"?this.each(function(){p.data(this,a)}):(d=a.split(".",2),d[1]=d[1]?"."+d[1]:"",e=d[1]+"!",p.access(this,function(c){if(c===b)return k=this.triggerHandler("getData"+e,[d[0]]),k===b&&i&&(k=p.data(i,a),k=J(i,a,k)),k===b&&d[1]?this.data(d[0]):k;d[1]=c,this.each(function(){var b=p(this);b.triggerHandler("setData"+e,d),p.data(this,a,c),b.triggerHandler("changeData"+e,d)})},null,c,arguments.length>1,null,!1))},removeData:function(a){return this.each(function(){p.removeData(this,a)})}}),p.extend({queue:function(a,b,c){var d;if(a)return b=(b||"fx")+"queue",d=p._data(a,b),c&&(!d||p.isArray(c)?d=p._data(a,b,p.makeArray(c)):d.push(c)),d||[]},dequeue:function(a,b){b=b||"fx";var c=p.queue(a,b),d=c.shift(),e=p._queueHooks(a,b),f=function(){p.dequeue(a,b)};d==="inprogress"&&(d=c.shift()),d&&(b==="fx"&&c.unshift("inprogress"),delete e.stop,d.call(a,f,e)),!c.length&&e&&e.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return p._data(a,c)||p._data(a,c,{empty:p.Callbacks("once memory").add(function(){p.removeData(a,b+"queue",!0),p.removeData(a,c,!0)})})}}),p.fn.extend({queue:function(a,c){var d=2;return typeof a!="string"&&(c=a,a="fx",d--),arguments.length<d?p.queue(this[0],a):c===b?this:this.each(function(){var b=p.queue(this,a,c);p._queueHooks(this,a),a==="fx"&&b[0]!=="inprogress"&&p.dequeue(this,a)})},dequeue:function(a){return this.each(function(){p.dequeue(this,a)})},delay:function(a,b){return a=p.fx?p.fx.speeds[a]||a:a,b=b||"fx",this.queue(b,function(b,c){var d=setTimeout(b,a);c.stop=function(){clearTimeout(d)}})},clearQueue:function(a){return this.queue(a||"fx",[])},promise:function(a,c){var d,e=1,f=p.Deferred(),g=this,h=this.length,i=function(){--e||f.resolveWith(g,[g])};typeof a!="string"&&(c=a,a=b),a=a||"fx";while(h--)(d=p._data(g[h],a+"queueHooks"))&&d.empty&&(e++,d.empty.add(i));return i(),f.promise(c)}});var L,M,N,O=/[\t\r\n]/g,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=p.support.getSetAttribute;p.fn.extend({attr:function(a,b){return p.access(this,p.attr,a,b,arguments.length>1)},removeAttr:function(a){return this.each(function(){p.removeAttr(this,a)})},prop:function(a,b){return p.access(this,p.prop,a,b,arguments.length>1)},removeProp:function(a){return a=p.propFix[a]||a,this.each(function(){try{this[a]=b,delete this[a]}catch(c){}})},addClass:function(a){var b,c,d,e,f,g,h;if(p.isFunction(a))return this.each(function(b){p(this).addClass(a.call(this,b,this.className))});if(a&&typeof a=="string"){b=a.split(s);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{f=" "+e.className+" ";for(g=0,h=b.length;g<h;g++)~f.indexOf(" "+b[g]+" ")||(f+=b[g]+" ");e.className=p.trim(f)}}}return this},removeClass:function(a){var c,d,e,f,g,h,i;if(p.isFunction(a))return this.each(function(b){p(this).removeClass(a.call(this,b,this.className))});if(a&&typeof a=="string"||a===b){c=(a||"").split(s);for(h=0,i=this.length;h<i;h++){e=this[h];if(e.nodeType===1&&e.className){d=(" "+e.className+" ").replace(O," ");for(f=0,g=c.length;f<g;f++)while(d.indexOf(" "+c[f]+" ")>-1)d=d.replace(" "+c[f]+" "," ");e.className=a?p.trim(d):""}}}return this},toggleClass:function(a,b){var c=typeof a,d=typeof b=="boolean";return p.isFunction(a)?this.each(function(c){p(this).toggleClass(a.call(this,c,this.className,b),b)}):this.each(function(){if(c==="string"){var e,f=0,g=p(this),h=b,i=a.split(s);while(e=i[f++])h=d?h:!g.hasClass(e),g[h?"addClass":"removeClass"](e)}else if(c==="undefined"||c==="boolean")this.className&&p._data(this,"__className__",this.className),this.className=this.className||a===!1?"":p._data(this,"__className__")||""})},hasClass:function(a){var b=" "+a+" ",c=0,d=this.length;for(;c<d;c++)if(this[c].nodeType===1&&(" "+this[c].className+" ").replace(O," ").indexOf(b)>-1)return!0;return!1},val:function(a){var c,d,e,f=this[0];if(!arguments.length){if(f)return c=p.valHooks[f.type]||p.valHooks[f.nodeName.toLowerCase()],c&&"get"in c&&(d=c.get(f,"value"))!==b?d:(d=f.value,typeof d=="string"?d.replace(P,""):d==null?"":d);return}return e=p.isFunction(a),this.each(function(d){var f,g=p(this);if(this.nodeType!==1)return;e?f=a.call(this,d,g.val()):f=a,f==null?f="":typeof f=="number"?f+="":p.isArray(f)&&(f=p.map(f,function(a){return a==null?"":a+""})),c=p.valHooks[this.type]||p.valHooks[this.nodeName.toLowerCase()];if(!c||!("set"in c)||c.set(this,f,"value")===b)this.value=f})}}),p.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,d,e,f=a.selectedIndex,g=[],h=a.options,i=a.type==="select-one";if(f<0)return null;c=i?f:0,d=i?f+1:h.length;for(;c<d;c++){e=h[c];if(e.selected&&(p.support.optDisabled?!e.disabled:e.getAttribute("disabled")===null)&&(!e.parentNode.disabled||!p.nodeName(e.parentNode,"optgroup"))){b=p(e).val();if(i)return b;g.push(b)}}return i&&!g.length&&h.length?p(h[f]).val():g},set:function(a,b){var c=p.makeArray(b);return p(a).find("option").each(function(){this.selected=p.inArray(p(this).val(),c)>=0}),c.length||(a.selectedIndex=-1),c}}},attrFn:{},attr:function(a,c,d,e){var f,g,h,i=a.nodeType;if(!a||i===3||i===8||i===2)return;if(e&&p.isFunction(p.fn[c]))return p(a)[c](d);if(typeof a.getAttribute=="undefined")return p.prop(a,c,d);h=i!==1||!p.isXMLDoc(a),h&&(c=c.toLowerCase(),g=p.attrHooks[c]||(T.test(c)?M:L));if(d!==b){if(d===null){p.removeAttr(a,c);return}return g&&"set"in g&&h&&(f=g.set(a,d,c))!==b?f:(a.setAttribute(c,""+d),d)}return g&&"get"in g&&h&&(f=g.get(a,c))!==null?f:(f=a.getAttribute(c),f===null?b:f)},removeAttr:function(a,b){var c,d,e,f,g=0;if(b&&a.nodeType===1){d=b.split(s);for(;g<d.length;g++)e=d[g],e&&(c=p.propFix[e]||e,f=T.test(e),f||p.attr(a,e,""),a.removeAttribute(U?e:c),f&&c in a&&(a[c]=!1))}},attrHooks:{type:{set:function(a,b){if(Q.test(a.nodeName)&&a.parentNode)p.error("type property can't be changed");else if(!p.support.radioValue&&b==="radio"&&p.nodeName(a,"input")){var c=a.value;return a.setAttribute("type",b),c&&(a.value=c),b}}},value:{get:function(a,b){return L&&p.nodeName(a,"button")?L.get(a,b):b in a?a.value:null},set:function(a,b,c){if(L&&p.nodeName(a,"button"))return L.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,f,g,h=a.nodeType;if(!a||h===3||h===8||h===2)return;return g=h!==1||!p.isXMLDoc(a),g&&(c=p.propFix[c]||c,f=p.propHooks[c]),d!==b?f&&"set"in f&&(e=f.set(a,d,c))!==b?e:a[c]=d:f&&"get"in f&&(e=f.get(a,c))!==null?e: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}}}}),M={get:function(a,c){var d,e=p.prop(a,c);return e===!0||typeof e!="boolean"&&(d=a.getAttributeNode(c))&&d.nodeValue!==!1?c.toLowerCase():b},set:function(a,b,c){var d;return b===!1?p.removeAttr(a,c):(d=p.propFix[c]||c,d in a&&(a[d]=!0),a.setAttribute(c,c.toLowerCase())),c}},U||(N={name:!0,id:!0,coords:!0},L=p.valHooks.button={get:function(a,c){var d;return d=a.getAttributeNode(c),d&&(N[c]?d.value!=="":d.specified)?d.value:b},set:function(a,b,c){var d=a.getAttributeNode(c);return d||(d=e.createAttribute(c),a.setAttributeNode(d)),d.value=b+""}},p.each(["width","height"],function(a,b){p.attrHooks[b]=p.extend(p.attrHooks[b],{set:function(a,c){if(c==="")return a.setAttribute(b,"auto"),c}})}),p.attrHooks.contenteditable={get:L.get,set:function(a,b,c){b===""&&(b="false"),L.set(a,b,c)}}),p.support.hrefNormalized||p.each(["href","src","width","height"],function(a,c){p.attrHooks[c]=p.extend(p.attrHooks[c],{get:function(a){var d=a.getAttribute(c,2);return d===null?b:d}})}),p.support.style||(p.attrHooks.style={get:function(a){return a.style.cssText.toLowerCase()||b},set:function(a,b){return a.style.cssText=""+b}}),p.support.optSelected||(p.propHooks.selected=p.extend(p.propHooks.selected,{get:function(a){var b=a.parentNode;return b&&(b.selectedIndex,b.parentNode&&b.parentNode.selectedIndex),null}})),p.support.enctype||(p.propFix.enctype="encoding"),p.support.checkOn||p.each(["radio","checkbox"],function(){p.valHooks[this]={get:function(a){return a.getAttribute("value")===null?"on":a.value}}}),p.each(["radio","checkbox"],function(){p.valHooks[this]=p.extend(p.valHooks[this],{set:function(a,b){if(p.isArray(b))return a.checked=p.inArray(p(a).val(),b)>=0}})});var V=/^(?:textarea|input|select)$/i,W=/^([^\.]*|)(?:\.(.+)|)$/,X=/(?:^|\s)hover(\.\S+|)\b/,Y=/^key/,Z=/^(?:mouse|contextmenu)|click/,$=/^(?:focusinfocus|focusoutblur)$/,_=function(a){return p.event.special.hover?a:a.replace(X,"mouseenter$1 mouseleave$1")};p.event={add:function(a,c,d,e,f){var g,h,i,j,k,l,m,n,o,q,r;if(a.nodeType===3||a.nodeType===8||!c||!d||!(g=p._data(a)))return;d.handler&&(o=d,d=o.handler,f=o.selector),d.guid||(d.guid=p.guid++),i=g.events,i||(g.events=i={}),h=g.handle,h||(g.handle=h=function(a){return typeof p!="undefined"&&(!a||p.event.triggered!==a.type)?p.event.dispatch.apply(h.elem,arguments):b},h.elem=a),c=p.trim(_(c)).split(" ");for(j=0;j<c.length;j++){k=W.exec(c[j])||[],l=k[1],m=(k[2]||"").split(".").sort(),r=p.event.special[l]||{},l=(f?r.delegateType:r.bindType)||l,r=p.event.special[l]||{},n=p.extend({type:l,origType:k[1],data:e,handler:d,guid:d.guid,selector:f,namespace:m.join(".")},o),q=i[l];if(!q){q=i[l]=[],q.delegateCount=0;if(!r.setup||r.setup.call(a,e,m,h)===!1)a.addEventListener?a.addEventListener(l,h,!1):a.attachEvent&&a.attachEvent("on"+l,h)}r.add&&(r.add.call(a,n),n.handler.guid||(n.handler.guid=d.guid)),f?q.splice(q.delegateCount++,0,n):q.push(n),p.event.global[l]=!0}a=null},global:{},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,n,o,q,r=p.hasData(a)&&p._data(a);if(!r||!(m=r.events))return;b=p.trim(_(b||"")).split(" ");for(f=0;f<b.length;f++){g=W.exec(b[f])||[],h=i=g[1],j=g[2];if(!h){for(h in m)p.event.remove(a,h+b[f],c,d,!0);continue}n=p.event.special[h]||{},h=(d?n.delegateType:n.bindType)||h,o=m[h]||[],k=o.length,j=j?new RegExp("(^|\\.)"+j.split(".").sort().join("\\.(?:.*\\.|)")+"(\\.|$)"):null;for(l=0;l<o.length;l++)q=o[l],(e||i===q.origType)&&(!c||c.guid===q.guid)&&(!j||j.test(q.namespace))&&(!d||d===q.selector||d==="**"&&q.selector)&&(o.splice(l--,1),q.selector&&o.delegateCount--,n.remove&&n.remove.call(a,q));o.length===0&&k!==o.length&&((!n.teardown||n.teardown.call(a,j,r.handle)===!1)&&p.removeEvent(a,h,r.handle),delete m[h])}p.isEmptyObject(m)&&(delete r.handle,p.removeData(a,"events",!0))},customEvent:{getData:!0,setData:!0,changeData:!0},trigger:function(c,d,f,g){if(!f||f.nodeType!==3&&f.nodeType!==8){var h,i,j,k,l,m,n,o,q,r,s=c.type||c,t=[];if($.test(s+p.event.triggered))return;s.indexOf("!")>=0&&(s=s.slice(0,-1),i=!0),s.indexOf(".")>=0&&(t=s.split("."),s=t.shift(),t.sort());if((!f||p.event.customEvent[s])&&!p.event.global[s])return;c=typeof c=="object"?c[p.expando]?c:new p.Event(s,c):new p.Event(s),c.type=s,c.isTrigger=!0,c.exclusive=i,c.namespace=t.join("."),c.namespace_re=c.namespace?new RegExp("(^|\\.)"+t.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,m=s.indexOf(":")<0?"on"+s:"";if(!f){h=p.cache;for(j in h)h[j].events&&h[j].events[s]&&p.event.trigger(c,d,h[j].handle.elem,!0);return}c.result=b,c.target||(c.target=f),d=d!=null?p.makeArray(d):[],d.unshift(c),n=p.event.special[s]||{};if(n.trigger&&n.trigger.apply(f,d)===!1)return;q=[[f,n.bindType||s]];if(!g&&!n.noBubble&&!p.isWindow(f)){r=n.delegateType||s,k=$.test(r+s)?f:f.parentNode;for(l=f;k;k=k.parentNode)q.push([k,r]),l=k;l===(f.ownerDocument||e)&&q.push([l.defaultView||l.parentWindow||a,r])}for(j=0;j<q.length&&!c.isPropagationStopped();j++)k=q[j][0],c.type=q[j][1],o=(p._data(k,"events")||{})[c.type]&&p._data(k,"handle"),o&&o.apply(k,d),o=m&&k[m],o&&p.acceptData(k)&&o.apply(k,d)===!1&&c.preventDefault();return c.type=s,!g&&!c.isDefaultPrevented()&&(!n._default||n._default.apply(f.ownerDocument,d)===!1)&&(s!=="click"||!p.nodeName(f,"a"))&&p.acceptData(f)&&m&&f[s]&&(s!=="focus"&&s!=="blur"||c.target.offsetWidth!==0)&&!p.isWindow(f)&&(l=f[m],l&&(f[m]=null),p.event.triggered=s,f[s](),p.event.triggered=b,l&&(f[m]=l)),c.result}return},dispatch:function(c){c=p.event.fix(c||a.event);var d,e,f,g,h,i,j,k,l,m,n,o=(p._data(this,"events")||{})[c.type]||[],q=o.delegateCount,r=[].slice.call(arguments),s=!c.exclusive&&!c.namespace,t=p.event.special[c.type]||{},u=[];r[0]=c,c.delegateTarget=this;if(t.preDispatch&&t.preDispatch.call(this,c)===!1)return;if(q&&(!c.button||c.type!=="click")){g=p(this),g.context=this;for(f=c.target;f!=this;f=f.parentNode||this)if(f.disabled!==!0||c.type!=="click"){i={},k=[],g[0]=f;for(d=0;d<q;d++)l=o[d],m=l.selector,i[m]===b&&(i[m]=g.is(m)),i[m]&&k.push(l);k.length&&u.push({elem:f,matches:k})}}o.length>q&&u.push({elem:this,matches:o.slice(q)});for(d=0;d<u.length&&!c.isPropagationStopped();d++){j=u[d],c.currentTarget=j.elem;for(e=0;e<j.matches.length&&!c.isImmediatePropagationStopped();e++){l=j.matches[e];if(s||!c.namespace&&!l.namespace||c.namespace_re&&c.namespace_re.test(l.namespace))c.data=l.data,c.handleObj=l,h=((p.event.special[l.origType]||{}).handle||l.handler).apply(j.elem,r),h!==b&&(c.result=h,h===!1&&(c.preventDefault(),c.stopPropagation()))}}return t.postDispatch&&t.postDispatch.call(this,c),c.result},props:"attrChange attrName relatedNode srcElement altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(a,b){return a.which==null&&(a.which=b.charCode!=null?b.charCode:b.keyCode),a}},mouseHooks:{props:"button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(a,c){var d,f,g,h=c.button,i=c.fromElement;return a.pageX==null&&c.clientX!=null&&(d=a.target.ownerDocument||e,f=d.documentElement,g=d.body,a.pageX=c.clientX+(f&&f.scrollLeft||g&&g.scrollLeft||0)-(f&&f.clientLeft||g&&g.clientLeft||0),a.pageY=c.clientY+(f&&f.scrollTop||g&&g.scrollTop||0)-(f&&f.clientTop||g&&g.clientTop||0)),!a.relatedTarget&&i&&(a.relatedTarget=i===a.target?c.toElement:i),!a.which&&h!==b&&(a.which=h&1?1:h&2?3:h&4?2:0),a}},fix:function(a){if(a[p.expando])return a;var b,c,d=a,f=p.event.fixHooks[a.type]||{},g=f.props?this.props.concat(f.props):this.props;a=p.Event(d);for(b=g.length;b;)c=g[--b],a[c]=d[c];return a.target||(a.target=d.srcElement||e),a.target.nodeType===3&&(a.target=a.target.parentNode),a.metaKey=!!a.metaKey,f.filter?f.filter(a,d):a},special:{ready:{setup:p.bindReady},load:{noBubble:!0},focus:{delegateType:"focusin"},blur:{delegateType:"focusout"},beforeunload:{setup:function(a,b,c){p.isWindow(this)&&(this.onbeforeunload=c)},teardown:function(a,b){this.onbeforeunload===b&&(this.onbeforeunload=null)}}},simulate:function(a,b,c,d){var e=p.extend(new p.Event,c,{type:a,isSimulated:!0,originalEvent:{}});d?p.event.trigger(e,null,b):p.event.dispatch.call(b,e),e.isDefaultPrevented()&&c.preventDefault()}},p.event.handle=p.event.dispatch,p.removeEvent=e.removeEventListener?function(a,b,c){a.removeEventListener&&a.removeEventListener(b,c,!1)}:function(a,b,c){var d="on"+b;a.detachEvent&&(typeof a[d]=="undefined"&&(a[d]=null),a.detachEvent(d,c))},p.Event=function(a,b){if(this instanceof p.Event)a&&a.type?(this.originalEvent=a,this.type=a.type,this.isDefaultPrevented=a.defaultPrevented||a.returnValue===!1||a.getPreventDefault&&a.getPreventDefault()?bb:ba):this.type=a,b&&p.extend(this,b),this.timeStamp=a&&a.timeStamp||p.now(),this[p.expando]=!0;else return new p.Event(a,b)},p.Event.prototype={preventDefault:function(){this.isDefaultPrevented=bb;var a=this.originalEvent;if(!a)return;a.preventDefault?a.preventDefault():a.returnValue=!1},stopPropagation:function(){this.isPropagationStopped=bb;var a=this.originalEvent;if(!a)return;a.stopPropagation&&a.stopPropagation(),a.cancelBubble=!0},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=bb,this.stopPropagation()},isDefaultPrevented:ba,isPropagationStopped:ba,isImmediatePropagationStopped:ba},p.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(a,b){p.event.special[a]={delegateType:b,bindType:b,handle:function(a){var c,d=this,e=a.relatedTarget,f=a.handleObj,g=f.selector;if(!e||e!==d&&!p.contains(d,e))a.type=f.origType,c=f.handler.apply(this,arguments),a.type=b;return c}}}),p.support.submitBubbles||(p.event.special.submit={setup:function(){if(p.nodeName(this,"form"))return!1;p.event.add(this,"click._submit keypress._submit",function(a){var c=a.target,d=p.nodeName(c,"input")||p.nodeName(c,"button")?c.form:b;d&&!p._data(d,"_submit_attached")&&(p.event.add(d,"submit._submit",function(a){a._submit_bubble=!0}),p._data(d,"_submit_attached",!0))})},postDispatch:function(a){a._submit_bubble&&(delete a._submit_bubble,this.parentNode&&!a.isTrigger&&p.event.simulate("submit",this.parentNode,a,!0))},teardown:function(){if(p.nodeName(this,"form"))return!1;p.event.remove(this,"._submit")}}),p.support.changeBubbles||(p.event.special.change={setup:function(){if(V.test(this.nodeName)){if(this.type==="checkbox"||this.type==="radio")p.event.add(this,"propertychange._change",function(a){a.originalEvent.propertyName==="checked"&&(this._just_changed=!0)}),p.event.add(this,"click._change",function(a){this._just_changed&&!a.isTrigger&&(this._just_changed=!1),p.event.simulate("change",this,a,!0)});return!1}p.event.add(this,"beforeactivate._change",function(a){var b=a.target;V.test(b.nodeName)&&!p._data(b,"_change_attached")&&(p.event.add(b,"change._change",function(a){this.parentNode&&!a.isSimulated&&!a.isTrigger&&p.event.simulate("change",this.parentNode,a,!0)}),p._data(b,"_change_attached",!0))})},handle:function(a){var b=a.target;if(this!==b||a.isSimulated||a.isTrigger||b.type!=="radio"&&b.type!=="checkbox")return a.handleObj.handler.apply(this,arguments)},teardown:function(){return p.event.remove(this,"._change"),V.test(this.nodeName)}}),p.support.focusinBubbles||p.each({focus:"focusin",blur:"focusout"},function(a,b){var c=0,d=function(a){p.event.simulate(b,a.target,p.event.fix(a),!0)};p.event.special[b]={setup:function(){c++===0&&e.addEventListener(a,d,!0)},teardown:function(){--c===0&&e.removeEventListener(a,d,!0)}}}),p.fn.extend({on:function(a,c,d,e,f){var g,h;if(typeof a=="object"){typeof c!="string"&&(d=d||c,c=b);for(h in a)this.on(h,c,d,a[h],f);return this}d==null&&e==null?(e=c,d=c=b):e==null&&(typeof c=="string"?(e=d,d=b):(e=d,d=c,c=b));if(e===!1)e=ba;else if(!e)return this;return f===1&&(g=e,e=function(a){return p().off(a),g.apply(this,arguments)},e.guid=g.guid||(g.guid=p.guid++)),this.each(function(){p.event.add(this,a,e,d,c)})},one:function(a,b,c,d){return this.on(a,b,c,d,1)},off:function(a,c,d){var e,f;if(a&&a.preventDefault&&a.handleObj)return e=a.handleObj,p(a.delegateTarget).off(e.namespace?e.origType+"."+e.namespace:e.origType,e.selector,e.handler),this;if(typeof a=="object"){for(f in a)this.off(f,c,a[f]);return this}if(c===!1||typeof c=="function")d=c,c=b;return d===!1&&(d=ba),this.each(function(){p.event.remove(this,a,d,c)})},bind:function(a,b,c){return this.on(a,null,b,c)},unbind:function(a,b){return this.off(a,null,b)},live:function(a,b,c){return p(this.context).on(a,this.selector,b,c),this},die:function(a,b){return p(this.context).off(a,this.selector||"**",b),this},delegate:function(a,b,c,d){return this.on(b,a,c,d)},undelegate:function(a,b,c){return arguments.length==1?this.off(a,"**"):this.off(b,a||"**",c)},trigger:function(a,b){return this.each(function(){p.event.trigger(a,b,this)})},triggerHandler:function(a,b){if(this[0])return p.event.trigger(a,b,this[0],!0)},toggle:function(a){var b=arguments,c=a.guid||p.guid++,d=0,e=function(c){var e=(p._data(this,"lastToggle"+a.guid)||0)%d;return p._data(this,"lastToggle"+a.guid,e+1),c.preventDefault(),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)}}),p.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 contextmenu".split(" "),function(a,b){p.fn[b]=function(a,c){return c==null&&(c=a,a=null),arguments.length>0?this.on(b,null,a,c):this.trigger(b)},Y.test(b)&&(p.event.fixHooks[b]=p.event.keyHooks),Z.test(b)&&(p.event.fixHooks[b]=p.event.mouseHooks)}),function(a,b){function bd(a,b,c,d){var e=0,f=b.length;for(;e<f;e++)Z(a,b[e],c,d)}function be(a,b,c,d,e,f){var g,h=$.setFilters[b.toLowerCase()];return h||Z.error(b),(a||!(g=e))&&bd(a||"*",d,g=[],e),g.length>0?h(g,c,f):[]}function bf(a,c,d,e,f){var g,h,i,j,k,l,m,n,p=0,q=f.length,s=L.POS,t=new RegExp("^"+s.source+"(?!"+r+")","i"),u=function(){var a=1,c=arguments.length-2;for(;a<c;a++)arguments[a]===b&&(g[a]=b)};for(;p<q;p++){s.exec(""),a=f[p],j=[],i=0,k=e;while(g=s.exec(a)){n=s.lastIndex=g.index+g[0].length;if(n>i){m=a.slice(i,g.index),i=n,l=[c],B.test(m)&&(k&&(l=k),k=e);if(h=H.test(m))m=m.slice(0,-5).replace(B,"$&*");g.length>1&&g[0].replace(t,u),k=be(m,g[1],g[2],l,k,h)}}k?(j=j.concat(k),(m=a.slice(i))&&m!==")"?B.test(m)?bd(m,j,d,e):Z(m,c,d,e?e.concat(k):k):o.apply(d,j)):Z(a,c,d,e)}return q===1?d:Z.uniqueSort(d)}function bg(a,b,c){var d,e,f,g=[],i=0,j=D.exec(a),k=!j.pop()&&!j.pop(),l=k&&a.match(C)||[""],m=$.preFilter,n=$.filter,o=!c&&b!==h;for(;(e=l[i])!=null&&k;i++){g.push(d=[]),o&&(e=" "+e);while(e){k=!1;if(j=B.exec(e))e=e.slice(j[0].length),k=d.push({part:j.pop().replace(A," "),captures:j});for(f in n)(j=L[f].exec(e))&&(!m[f]||(j=m[f](j,b,c)))&&(e=e.slice(j.shift().length),k=d.push({part:f,captures:j}));if(!k)break}}return k||Z.error(a),g}function bh(a,b,e){var f=b.dir,g=m++;return a||(a=function(a){return a===e}),b.first?function(b,c){while(b=b[f])if(b.nodeType===1)return a(b,c)&&b}:function(b,e){var h,i=g+"."+d,j=i+"."+c;while(b=b[f])if(b.nodeType===1){if((h=b[q])===j)return b.sizset;if(typeof h=="string"&&h.indexOf(i)===0){if(b.sizset)return b}else{b[q]=j;if(a(b,e))return b.sizset=!0,b;b.sizset=!1}}}}function bi(a,b){return a?function(c,d){var e=b(c,d);return e&&a(e===!0?c:e,d)}:b}function bj(a,b,c){var d,e,f=0;for(;d=a[f];f++)$.relative[d.part]?e=bh(e,$.relative[d.part],b):(d.captures.push(b,c),e=bi(e,$.filter[d.part].apply(null,d.captures)));return e}function bk(a){return function(b,c){var d,e=0;for(;d=a[e];e++)if(d(b,c))return!0;return!1}}var c,d,e,f,g,h=a.document,i=h.documentElement,j="undefined",k=!1,l=!0,m=0,n=[].slice,o=[].push,q=("sizcache"+Math.random()).replace(".",""),r="[\\x20\\t\\r\\n\\f]",s="(?:\\\\.|[-\\w]|[^\\x00-\\xa0])+",t=s.replace("w","w#"),u="([*^$|!~]?=)",v="\\["+r+"*("+s+")"+r+"*(?:"+u+r+"*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|("+t+")|)|)"+r+"*\\]",w=":("+s+")(?:\\((?:(['\"])((?:\\\\.|[^\\\\])*?)\\2|((?:[^,]|\\\\,|(?:,(?=[^\\[]*\\]))|(?:,(?=[^\\(]*\\))))*))\\)|)",x=":(nth|eq|gt|lt|first|last|even|odd)(?:\\((\\d*)\\)|)(?=[^-]|$)",y=r+"*([\\x20\\t\\r\\n\\f>+~])"+r+"*",z="(?=[^\\x20\\t\\r\\n\\f])(?:\\\\.|"+v+"|"+w.replace(2,7)+"|[^\\\\(),])+",A=new RegExp("^"+r+"+|((?:^|[^\\\\])(?:\\\\.)*)"+r+"+$","g"),B=new RegExp("^"+y),C=new RegExp(z+"?(?="+r+"*,|$)","g"),D=new RegExp("^(?:(?!,)(?:(?:^|,)"+r+"*"+z+")*?|"+r+"*(.*?))(\\)|$)"),E=new RegExp(z.slice(19,-6)+"\\x20\\t\\r\\n\\f>+~])+|"+y,"g"),F=/^(?:#([\w\-]+)|(\w+)|\.([\w\-]+))$/,G=/[\x20\t\r\n\f]*[+~]/,H=/:not\($/,I=/h\d/i,J=/input|select|textarea|button/i,K=/\\(?!\\)/g,L={ID:new RegExp("^#("+s+")"),CLASS:new RegExp("^\\.("+s+")"),NAME:new RegExp("^\\[name=['\"]?("+s+")['\"]?\\]"),TAG:new RegExp("^("+s.replace("[-","[-\\*")+")"),ATTR:new RegExp("^"+v),PSEUDO:new RegExp("^"+w),CHILD:new RegExp("^:(only|nth|last|first)-child(?:\\("+r+"*(even|odd|(([+-]|)(\\d*)n|)"+r+"*(?:([+-]|)"+r+"*(\\d+)|))"+r+"*\\)|)","i"),POS:new RegExp(x,"ig"),needsContext:new RegExp("^"+r+"*[>+~]|"+x,"i")},M={},N=[],O={},P=[],Q=function(a){return a.sizzleFilter=!0,a},R=function(a){return function(b){return b.nodeName.toLowerCase()==="input"&&b.type===a}},S=function(a){return function(b){var c=b.nodeName.toLowerCase();return(c==="input"||c==="button")&&b.type===a}},T=function(a){var b=!1,c=h.createElement("div");try{b=a(c)}catch(d){}return c=null,b},U=T(function(a){a.innerHTML="<select></select>";var b=typeof a.lastChild.getAttribute("multiple");return b!=="boolean"&&b!=="string"}),V=T(function(a){a.id=q+0,a.innerHTML="<a name='"+q+"'></a><div name='"+q+"'></div>",i.insertBefore(a,i.firstChild);var b=h.getElementsByName&&h.getElementsByName(q).length===2+h.getElementsByName(q+0).length;return g=!h.getElementById(q),i.removeChild(a),b}),W=T(function(a){return a.appendChild(h.createComment("")),a.getElementsByTagName("*").length===0}),X=T(function(a){return a.innerHTML="<a href='#'></a>",a.firstChild&&typeof a.firstChild.getAttribute!==j&&a.firstChild.getAttribute("href")==="#"}),Y=T(function(a){return a.innerHTML="<div class='hidden e'></div><div class='hidden'></div>",!a.getElementsByClassName||a.getElementsByClassName("e").length===0?!1:(a.lastChild.className="e",a.getElementsByClassName("e").length!==1)}),Z=function(a,b,c,d){c=c||[],b=b||h;var e,f,g,i,j=b.nodeType;if(j!==1&&j!==9)return[];if(!a||typeof a!="string")return c;g=ba(b);if(!g&&!d)if(e=F.exec(a))if(i=e[1]){if(j===9){f=b.getElementById(i);if(!f||!f.parentNode)return c;if(f.id===i)return c.push(f),c}else if(b.ownerDocument&&(f=b.ownerDocument.getElementById(i))&&bb(b,f)&&f.id===i)return c.push(f),c}else{if(e[2])return o.apply(c,n.call(b.getElementsByTagName(a),0)),c;if((i=e[3])&&Y&&b.getElementsByClassName)return o.apply(c,n.call(b.getElementsByClassName(i),0)),c}return bm(a,b,c,d,g)},$=Z.selectors={cacheLength:50,match:L,order:["ID","TAG"],attrHandle:{},createPseudo:Q,find:{ID:g?function(a,b,c){if(typeof b.getElementById!==j&&!c){var d=b.getElementById(a);return d&&d.parentNode?[d]:[]}}:function(a,c,d){if(typeof c.getElementById!==j&&!d){var e=c.getElementById(a);return e?e.id===a||typeof e.getAttributeNode!==j&&e.getAttributeNode("id").value===a?[e]:b:[]}},TAG:W?function(a,b){if(typeof b.getElementsByTagName!==j)return b.getElementsByTagName(a)}:function(a,b){var c=b.getElementsByTagName(a);if(a==="*"){var d,e=[],f=0;for(;d=c[f];f++)d.nodeType===1&&e.push(d);return e}return c}},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(K,""),a[3]=(a[4]||a[5]||"").replace(K,""),a[2]==="~="&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),a[1]==="nth"?(a[2]||Z.error(a[0]),a[3]=+(a[3]?a[4]+(a[5]||1):2*(a[2]==="even"||a[2]==="odd")),a[4]=+(a[6]+a[7]||a[2]==="odd")):a[2]&&Z.error(a[0]),a},PSEUDO:function(a){var b,c=a[4];return L.CHILD.test(a[0])?null:(c&&(b=D.exec(c))&&b.pop()&&(a[0]=a[0].slice(0,b[0].length-c.length-1),c=b[0].slice(0,-1)),a.splice(2,3,c||a[3]),a)}},filter:{ID:g?function(a){return a=a.replace(K,""),function(b){return b.getAttribute("id")===a}}:function(a){return a=a.replace(K,""),function(b){var c=typeof b.getAttributeNode!==j&&b.getAttributeNode("id");return c&&c.value===a}},TAG:function(a){return a==="*"?function(){return!0}:(a=a.replace(K,"").toLowerCase(),function(b){return b.nodeName&&b.nodeName.toLowerCase()===a})},CLASS:function(a){var b=M[a];return b||(b=M[a]=new RegExp("(^|"+r+")"+a+"("+r+"|$)"),N.push(a),N.length>$.cacheLength&&delete M[N.shift()]),function(a){return b.test(a.className||typeof a.getAttribute!==j&&a.getAttribute("class")||"")}},ATTR:function(a,b,c){return b?function(d){var e=Z.attr(d,a),f=e+"";if(e==null)return b==="!=";switch(b){case"=":return f===c;case"!=":return f!==c;case"^=":return c&&f.indexOf(c)===0;case"*=":return c&&f.indexOf(c)>-1;case"$=":return c&&f.substr(f.length-c.length)===c;case"~=":return(" "+f+" ").indexOf(c)>-1;case"|=":return f===c||f.substr(0,c.length+1)===c+"-"}}:function(b){return Z.attr(b,a)!=null}},CHILD:function(a,b,c,d){if(a==="nth"){var e=m++;return function(a){var b,f,g=0,h=a;if(c===1&&d===0)return!0;b=a.parentNode;if(b&&(b[q]!==e||!a.sizset)){for(h=b.firstChild;h;h=h.nextSibling)if(h.nodeType===1){h.sizset=++g;if(h===a)break}b[q]=e}return f=a.sizset-d,c===0?f===0:f%c===0&&f/c>=0}}return function(b){var c=b;switch(a){case"only":case"first":while(c=c.previousSibling)if(c.nodeType===1)return!1;if(a==="first")return!0;c=b;case"last":while(c=c.nextSibling)if(c.nodeType===1)return!1;return!0}}},PSEUDO:function(a,b,c,d){var e=$.pseudos[a]||$.pseudos[a.toLowerCase()];return e||Z.error("unsupported pseudo: "+a),e.sizzleFilter?e(b,c,d):e}},pseudos:{not:Q(function(a,b,c){var d=bl(a.replace(A,"$1"),b,c);return function(a){return!d(a)}}),enabled:function(a){return a.disabled===!1},disabled:function(a){return a.disabled===!0},checked:function(a){var b=a.nodeName.toLowerCase();return b==="input"&&!!a.checked||b==="option"&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},parent:function(a){return!$.pseudos.empty(a)},empty:function(a){var b;a=a.firstChild;while(a){if(a.nodeName>"@"||(b=a.nodeType)===3||b===4)return!1;a=a.nextSibling}return!0},contains:Q(function(a){return function(b){return(b.textContent||b.innerText||bc(b)).indexOf(a)>-1}}),has:Q(function(a){return function(b){return Z(a,b).length>0}}),header:function(a){return I.test(a.nodeName)},text:function(a){var b,c;return a.nodeName.toLowerCase()==="input"&&(b=a.type)==="text"&&((c=a.getAttribute("type"))==null||c.toLowerCase()===b)},radio:R("radio"),checkbox:R("checkbox"),file:R("file"),password:R("password"),image:R("image"),submit:S("submit"),reset:S("reset"),button:function(a){var b=a.nodeName.toLowerCase();return b==="input"&&a.type==="button"||b==="button"},input:function(a){return J.test(a.nodeName)},focus:function(a){var b=a.ownerDocument;return a===b.activeElement&&(!b.hasFocus||b.hasFocus())&&(!!a.type||!!a.href)},active:function(a){return a===a.ownerDocument.activeElement}},setFilters:{first:function(a,b,c){return c?a.slice(1):[a[0]]},last:function(a,b,c){var d=a.pop();return c?a:[d]},even:function(a,b,c){var d=[],e=c?1:0,f=a.length;for(;e<f;e=e+2)d.push(a[e]);return d},odd:function(a,b,c){var d=[],e=c?0:1,f=a.length;for(;e<f;e=e+2)d.push(a[e]);return d},lt:function(a,b,c){return c?a.slice(+b):a.slice(0,+b)},gt:function(a,b,c){return c?a.slice(0,+b+1):a.slice(+b+1)},eq:function(a,b,c){var d=a.splice(+b,1);return c?a:d}}};$.setFilters.nth=$.setFilters.eq,$.filters=$.pseudos,X||($.attrHandle={href:function(a){return a.getAttribute("href",2)},type:function(a){return a.getAttribute("type")}}),V&&($.order.push("NAME"),$.find.NAME=function(a,b){if(typeof b.getElementsByName!==j)return b.getElementsByName(a)}),Y&&($.order.splice(1,0,"CLASS"),$.find.CLASS=function(a,b,c){if(typeof b.getElementsByClassName!==j&&!c)return b.getElementsByClassName(a)});try{n.call(i.childNodes,0)[0].nodeType}catch(_){n=function(a){var b,c=[];for(;b=this[a];a++)c.push(b);return c}}var ba=Z.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return b?b.nodeName!=="HTML":!1},bb=Z.contains=i.compareDocumentPosition?function(a,b){return!!(a.compareDocumentPosition(b)&16)}:i.contains?function(a,b){var c=a.nodeType===9?a.documentElement:a,d=b.parentNode;return a===d||!!(d&&d.nodeType===1&&c.contains&&c.contains(d))}:function(a,b){while(b=b.parentNode)if(b===a)return!0;return!1},bc=Z.getText=function(a){var b,c="",d=0,e=a.nodeType;if(e){if(e===1||e===9||e===11){if(typeof a.textContent=="string")return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=bc(a)}else if(e===3||e===4)return a.nodeValue}else for(;b=a[d];d++)c+=bc(b);return c};Z.attr=function(a,b){var c,d=ba(a);return d||(b=b.toLowerCase()),$.attrHandle[b]?$.attrHandle[b](a):U||d?a.getAttribute(b):(c=a.getAttributeNode(b),c?typeof a[b]=="boolean"?a[b]?b:null:c.specified?c.value:null:null)},Z.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},[0,0].sort(function(){return l=0}),i.compareDocumentPosition?e=function(a,b){return a===b?(k=!0,0):(!a.compareDocumentPosition||!b.compareDocumentPosition?a.compareDocumentPosition:a.compareDocumentPosition(b)&4)?-1:1}:(e=function(a,b){if(a===b)return k=!0,0;if(a.sourceIndex&&b.sourceIndex)return a.sourceIndex-b.sourceIndex;var c,d,e=[],g=[],h=a.parentNode,i=b.parentNode,j=h;if(h===i)return f(a,b);if(!h)return-1;if(!i)return 1;while(j)e.unshift(j),j=j.parentNode;j=i;while(j)g.unshift(j),j=j.parentNode;c=e.length,d=g.length;for(var l=0;l<c&&l<d;l++)if(e[l]!==g[l])return f(e[l],g[l]);return l===c?f(a,g[l],-1):f(e[l],b,1)},f=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}),Z.uniqueSort=function(a){var b,c=1;if(e){k=l,a.sort(e);if(k)for(;b=a[c];c++)b===a[c-1]&&a.splice(c--,1)}return a};var bl=Z.compile=function(a,b,c){var d,e,f,g=O[a];if(g&&g.context===b)return g;e=bg(a,b,c);for(f=0;d=e[f];f++)e[f]=bj(d,b,c);return g=O[a]=bk(e),g.context=b,g.runs=g.dirruns=0,P.push(a),P.length>$.cacheLength&&delete O[P.shift()],g};Z.matches=function(a,b){return Z(a,null,null,b)},Z.matchesSelector=function(a,b){return Z(b,null,null,[a]).length>0};var bm=function(a,b,e,f,g){a=a.replace(A,"$1");var h,i,j,k,l,m,p,q,r,s=a.match(C),t=a.match(E),u=b.nodeType;if(L.POS.test(a))return bf(a,b,e,f,s);if(f)h=n.call(f,0);else if(s&&s.length===1){if(t.length>1&&u===9&&!g&&(s=L.ID.exec(t[0]))){b=$.find.ID(s[1],b,g)[0];if(!b)return e;a=a.slice(t.shift().length)}q=(s=G.exec(t[0]))&&!s.index&&b.parentNode||b,r=t.pop(),m=r.split(":not")[0];for(j=0,k=$.order.length;j<k;j++){p=$.order[j];if(s=L[p].exec(m)){h=$.find[p]((s[1]||"").replace(K,""),q,g);if(h==null)continue;m===r&&(a=a.slice(0,a.length-r.length)+m.replace(L[p],""),a||o.apply(e,n.call(h,0)));break}}}if(a){i=bl(a,b,g),d=i.dirruns++,h==null&&(h=$.find.TAG("*",G.test(a)&&b.parentNode||b));for(j=0;l=h[j];j++)c=i.runs++,i(l,b)&&e.push(l)}return e};h.querySelectorAll&&function(){var a,b=bm,c=/'|\\/g,d=/\=[\x20\t\r\n\f]*([^'"\]]*)[\x20\t\r\n\f]*\]/g,e=[],f=[":active"],g=i.matchesSelector||i.mozMatchesSelector||i.webkitMatchesSelector||i.oMatchesSelector||i.msMatchesSelector;T(function(a){a.innerHTML="<select><option selected></option></select>",a.querySelectorAll("[selected]").length||e.push("\\["+r+"*(?:checked|disabled|ismap|multiple|readonly|selected|value)"),a.querySelectorAll(":checked").length||e.push(":checked")}),T(function(a){a.innerHTML="<p test=''></p>",a.querySelectorAll("[test^='']").length&&e.push("[*^$]="+r+"*(?:\"\"|'')"),a.innerHTML="<input type='hidden'>",a.querySelectorAll(":enabled").length||e.push(":enabled",":disabled")}),e=e.length&&new RegExp(e.join("|")),bm=function(a,d,f,g,h){if(!g&&!h&&(!e||!e.test(a)))if(d.nodeType===9)try{return o.apply(f,n.call(d.querySelectorAll(a),0)),f}catch(i){}else if(d.nodeType===1&&d.nodeName.toLowerCase()!=="object"){var j=d.getAttribute("id"),k=j||q,l=G.test(a)&&d.parentNode||d;j?k=k.replace(c,"\\$&"):d.setAttribute("id",k);try{return o.apply(f,n.call(l.querySelectorAll(a.replace(C,"[id='"+k+"'] $&")),0)),f}catch(i){}finally{j||d.removeAttribute("id")}}return b(a,d,f,g,h)},g&&(T(function(b){a=g.call(b,"div");try{g.call(b,"[test!='']:sizzle"),f.push($.match.PSEUDO)}catch(c){}}),f=new RegExp(f.join("|")),Z.matchesSelector=function(b,c){c=c.replace(d,"='$1']");if(!ba(b)&&!f.test(c)&&(!e||!e.test(c)))try{var h=g.call(b,c);if(h||a||b.document&&b.document.nodeType!==11)return h}catch(i){}return Z(c,null,null,[b]).length>0})}(),Z.attr=p.attr,p.find=Z,p.expr=Z.selectors,p.expr[":"]=p.expr.pseudos,p.unique=Z.uniqueSort,p.text=Z.getText,p.isXMLDoc=Z.isXML,p.contains=Z.contains}(a);var bc=/Until$/,bd=/^(?:parents|prev(?:Until|All))/,be=/^.[^:#\[\.,]*$/,bf=p.expr.match.needsContext,bg={children:!0,contents:!0,next:!0,prev:!0};p.fn.extend({find:function(a){var b,c,d,e,f,g,h=this;if(typeof a!="string")return p(a).filter(function(){for(b=0,c=h.length;b<c;b++)if(p.contains(h[b],this))return!0});g=this.pushStack("","find",a);for(b=0,c=this.length;b<c;b++){d=g.length,p.find(a,this[b],g);if(b>0)for(e=d;e<g.length;e++)for(f=0;f<d;f++)if(g[f]===g[e]){g.splice(e--,1);break}}return g},has:function(a){var b,c=p(a,this),d=c.length;return this.filter(function(){for(b=0;b<d;b++)if(p.contains(this,c[b]))return!0})},not:function(a){return this.pushStack(bj(this,a,!1),"not",a)},filter:function(a){return this.pushStack(bj(this,a,!0),"filter",a)},is:function(a){return!!a&&(typeof a=="string"?bf.test(a)?p(a,this.context).index(this[0])>=0:p.filter(a,this).length>0:this.filter(a).length>0)},closest:function(a,b){var c,d=0,e=this.length,f=[],g=bf.test(a)||typeof a!="string"?p(a,b||this.context):0;for(;d<e;d++){c=this[d];while(c&&c.ownerDocument&&c!==b&&c.nodeType!==11){if(g?g.index(c)>-1:p.find.matchesSelector(c,a)){f.push(c);break}c=c.parentNode}}return f=f.length>1?p.unique(f):f,this.pushStack(f,"closest",a)},index:function(a){return a?typeof a=="string"?p.inArray(this[0],p(a)):p.inArray(a.jquery?a[0]:a,this):this[0]&&this[0].parentNode?this.prevAll().length:-1},add:function(a,b){var c=typeof a=="string"?p(a,b):p.makeArray(a&&a.nodeType?[a]:a),d=p.merge(this.get(),c);return this.pushStack(bh(c[0])||bh(d[0])?d:p.unique(d))},addBack:function(a){return this.add(a==null?this.prevObject:this.prevObject.filter(a))}}),p.fn.andSelf=p.fn.addBack,p.each({parent:function(a){var b=a.parentNode;return b&&b.nodeType!==11?b:null},parents:function(a){return p.dir(a,"parentNode")},parentsUntil:function(a,b,c){return p.dir(a,"parentNode",c)},next:function(a){return bi(a,"nextSibling")},prev:function(a){return bi(a,"previousSibling")},nextAll:function(a){return p.dir(a,"nextSibling")},prevAll:function(a){return p.dir(a,"previousSibling")},nextUntil:function(a,b,c){return p.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return p.dir(a,"previousSibling",c)},siblings:function(a){return p.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return p.sibling(a.firstChild)},contents:function(a){return p.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:p.merge([],a.childNodes)}},function(a,b){p.fn[a]=function(c,d){var e=p.map(this,b,c);return bc.test(a)||(d=c),d&&typeof d=="string"&&(e=p.filter(d,e)),e=this.length>1&&!bg[a]?p.unique(e):e,this.length>1&&bd.test(a)&&(e=e.reverse()),this.pushStack(e,a,k.call(arguments).join(","))}}),p.extend({filter:function(a,b,c){return c&&(a=":not("+a+")"),b.length===1?p.find.matchesSelector(b[0],a)?[b[0]]:[]:p.find.matches(a,b)},dir:function(a,c,d){var e=[],f=a[c];while(f&&f.nodeType!==9&&(d===b||f.nodeType!==1||!p(f).is(d)))f.nodeType===1&&e.push(f),f=f[c];return e},sibling:function(a,b){var c=[];for(;a;a=a.nextSibling)a.nodeType===1&&a!==b&&c.push(a);return c}});var bl="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",bm=/ jQuery\d+="(?:null|\d+)"/g,bn=/^\s+/,bo=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,bp=/<([\w:]+)/,bq=/<tbody/i,br=/<|&#?\w+;/,bs=/<(?:script|style|link)/i,bt=/<(?:script|object|embed|option|style)/i,bu=new RegExp("<(?:"+bl+")[\\s/>]","i"),bv=/^(?:checkbox|radio)$/,bw=/checked\s*(?:[^=]|=\s*.checked.)/i,bx=/\/(java|ecma)script/i,by=/^\s*<!(?:\[CDATA\[|\-\-)|[\]\-]{2}>\s*$/g,bz={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,"",""]},bA=bk(e),bB=bA.appendChild(e.createElement("div"));bz.optgroup=bz.option,bz.tbody=bz.tfoot=bz.colgroup=bz.caption=bz.thead,bz.th=bz.td,p.support.htmlSerialize||(bz._default=[1,"X<div>","</div>"]),p.fn.extend({text:function(a){return p.access(this,function(a){return a===b?p.text(this):this.empty().append((this[0]&&this[0].ownerDocument||e).createTextNode(a))},null,a,arguments.length)},wrapAll:function(a){if(p.isFunction(a))return this.each(function(b){p(this).wrapAll(a.call(this,b))});if(this[0]){var b=p(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){return p.isFunction(a)?this.each(function(b){p(this).wrapInner(a.call(this,b))}):this.each(function(){var b=p(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=p.isFunction(a);return this.each(function(c){p(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(){return this.parent().each(function(){p.nodeName(this,"body")||p(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(a){(this.nodeType===1||this.nodeType===11)&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,!0,function(a){(this.nodeType===1||this.nodeType===11)&&this.insertBefore(a,this.firstChild)})},before:function(){if(!bh(this[0]))return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this)});if(arguments.length){var a=p.clean(arguments);return this.pushStack(p.merge(a,this),"before",this.selector)}},after:function(){if(!bh(this[0]))return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this.nextSibling)});if(arguments.length){var a=p.clean(arguments);return this.pushStack(p.merge(this,a),"after",this.selector)}},remove:function(a,b){var c,d=0;for(;(c=this[d])!=null;d++)if(!a||p.filter(a,[c]).length)!b&&c.nodeType===1&&(p.cleanData(c.getElementsByTagName("*")),p.cleanData([c])),c.parentNode&&c.parentNode.removeChild(c);return this},empty:function(){var a,b=0;for(;(a=this[b])!=null;b++){a.nodeType===1&&p.cleanData(a.getElementsByTagName("*"));while(a.firstChild)a.removeChild(a.firstChild)}return this},clone:function(a,b){return a=a==null?!1:a,b=b==null?a:b,this.map(function(){return p.clone(this,a,b)})},html:function(a){return p.access(this,function(a){var c=this[0]||{},d=0,e=this.length;if(a===b)return c.nodeType===1?c.innerHTML.replace(bm,""):b;if(typeof a=="string"&&!bs.test(a)&&(p.support.htmlSerialize||!bu.test(a))&&(p.support.leadingWhitespace||!bn.test(a))&&!bz[(bp.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(bo,"<$1></$2>");try{for(;d<e;d++)c=this[d]||{},c.nodeType===1&&(p.cleanData(c.getElementsByTagName("*")),c.innerHTML=a);c=0}catch(f){}}c&&this.empty().append(a)},null,a,arguments.length)},replaceWith:function(a){return bh(this[0])?this.length?this.pushStack(p(p.isFunction(a)?a():a),"replaceWith",a):this:p.isFunction(a)?this.each(function(b){var c=p(this),d=c.html();c.replaceWith(a.call(this,b,d))}):(typeof a!="string"&&(a=p(a).detach()),this.each(function(){var b=this.nextSibling,c=this.parentNode;p(this).remove(),b?p(b).before(a):p(c).append(a)}))},detach:function(a){return this.remove(a,!0)},domManip:function(a,c,d){a=[].concat.apply([],a);var e,f,g,h,i=0,j=a[0],k=[],l=this.length;if(!p.support.checkClone&&l>1&&typeof j=="string"&&bw.test(j))return this.each(function(){p(this).domManip(a,c,d)});if(p.isFunction(j))return this.each(function(e){var f=p(this);a[0]=j.call(this,e,c?f.html():b),f.domManip(a,c,d)});if(this[0]){e=p.buildFragment(a,this,k),g=e.fragment,f=g.firstChild,g.childNodes.length===1&&(g=f);if(f){c=c&&p.nodeName(f,"tr");for(h=e.cacheable||l-1;i<l;i++)d.call(c&&p.nodeName(this[i],"table")?bC(this[i],"tbody"):this[i],i===h?g:p.clone(g,!0,!0))}g=f=null,k.length&&p.each(k,function(a,b){b.src?p.ajax?p.ajax({url:b.src,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0}):p.error("no ajax"):p.globalEval((b.text||b.textContent||b.innerHTML||"").replace(by,"")),b.parentNode&&b.parentNode.removeChild(b)})}return this}}),p.buildFragment=function(a,c,d){var f,g,h,i=a[0];return c=c||e,c=(c[0]||c).ownerDocument||c[0]||c,typeof c.createDocumentFragment=="undefined"&&(c=e),a.length===1&&typeof i=="string"&&i.length<512&&c===e&&i.charAt(0)==="<"&&!bt.test(i)&&(p.support.checkClone||!bw.test(i))&&(p.support.html5Clone||!bu.test(i))&&(g=!0,f=p.fragments[i],h=f!==b),f||(f=c.createDocumentFragment(),p.clean(a,c,f,d),g&&(p.fragments[i]=h&&f)),{fragment:f,cacheable:g}},p.fragments={},p.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){p.fn[a]=function(c){var d,e=0,f=[],g=p(c),h=g.length,i=this.length===1&&this[0].parentNode;if((i==null||i&&i.nodeType===11&&i.childNodes.length===1)&&h===1)return g[b](this[0]),this;for(;e<h;e++)d=(e>0?this.clone(!0):this).get(),p(g[e])[b](d),f=f.concat(d);return this.pushStack(f,a,g.selector)}}),p.extend({clone:function(a,b,c){var d,e,f,g;p.support.html5Clone||p.isXMLDoc(a)||!bu.test("<"+a.nodeName+">")?g=a.cloneNode(!0):(bB.innerHTML=a.outerHTML,bB.removeChild(g=bB.firstChild));if((!p.support.noCloneEvent||!p.support.noCloneChecked)&&(a.nodeType===1||a.nodeType===11)&&!p.isXMLDoc(a)){bE(a,g),d=bF(a),e=bF(g);for(f=0;d[f];++f)e[f]&&bE(d[f],e[f])}if(b){bD(a,g);if(c){d=bF(a),e=bF(g);for(f=0;d[f];++f)bD(d[f],e[f])}}return d=e=null,g},clean:function(a,b,c,d){var f,g,h,i,j,k,l,m,n,o,q,r,s=0,t=[];if(!b||typeof b.createDocumentFragment=="undefined")b=e;for(g=b===e&&bA;(h=a[s])!=null;s++){typeof h=="number"&&(h+="");if(!h)continue;if(typeof h=="string")if(!br.test(h))h=b.createTextNode(h);else{g=g||bk(b),l=l||g.appendChild(b.createElement("div")),h=h.replace(bo,"<$1></$2>"),i=(bp.exec(h)||["",""])[1].toLowerCase(),j=bz[i]||bz._default,k=j[0],l.innerHTML=j[1]+h+j[2];while(k--)l=l.lastChild;if(!p.support.tbody){m=bq.test(h),n=i==="table"&&!m?l.firstChild&&l.firstChild.childNodes:j[1]==="<table>"&&!m?l.childNodes:[];for(f=n.length-1;f>=0;--f)p.nodeName(n[f],"tbody")&&!n[f].childNodes.length&&n[f].parentNode.removeChild(n[f])}!p.support.leadingWhitespace&&bn.test(h)&&l.insertBefore(b.createTextNode(bn.exec(h)[0]),l.firstChild),h=l.childNodes,l=g.lastChild}h.nodeType?t.push(h):t=p.merge(t,h)}l&&(g.removeChild(l),h=l=g=null);if(!p.support.appendChecked)for(s=0;(h=t[s])!=null;s++)p.nodeName(h,"input")?bG(h):typeof h.getElementsByTagName!="undefined"&&p.grep(h.getElementsByTagName("input"),bG);if(c){q=function(a){if(!a.type||bx.test(a.type))return d?d.push(a.parentNode?a.parentNode.removeChild(a):a):c.appendChild(a)};for(s=0;(h=t[s])!=null;s++)if(!p.nodeName(h,"script")||!q(h))c.appendChild(h),typeof h.getElementsByTagName!="undefined"&&(r=p.grep(p.merge([],h.getElementsByTagName("script")),q),t.splice.apply(t,[s+1,0].concat(r)),s+=r.length)}return t},cleanData:function(a,b){var c,d,e,f,g=0,h=p.expando,i=p.cache,j=p.support.deleteExpando,k=p.event.special;for(;(e=a[g])!=null;g++)if(b||p.acceptData(e)){d=e[h],c=d&&i[d];if(c){if(c.events)for(f in c.events)k[f]?p.event.remove(e,f):p.removeEvent(e,f,c.handle);i[d]&&(delete i[d],j?delete e[h]:e.removeAttribute?e.removeAttribute(h):e[h]=null,p.deletedIds.push(d))}}}}),function(){var a,b;p.uaMatch=function(a){a=a.toLowerCase();var b=/(chrome)[ \/]([\w.]+)/.exec(a)||/(webkit)[ \/]([\w.]+)/.exec(a)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(a)||/(msie) ([\w.]+)/.exec(a)||a.indexOf("compatible")<0&&/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(a)||[];return{browser:b[1]||"",version:b[2]||"0"}},a=p.uaMatch(g.userAgent),b={},a.browser&&(b[a.browser]=!0,b.version=a.version),b.webkit&&(b.safari=!0),p.browser=b,p.sub=function(){function a(b,c){return new a.fn.init(b,c)}p.extend(!0,a,this),a.superclass=this,a.fn=a.prototype=this(),a.fn.constructor=a,a.sub=this.sub,a.fn.init=function c(c,d){return d&&d instanceof p&&!(d instanceof a)&&(d=a(d)),p.fn.init.call(this,c,d,b)},a.fn.init.prototype=a.fn;var b=a(e);return a}}();var bH,bI,bJ,bK=/alpha\([^)]*\)/i,bL=/opacity=([^)]*)/,bM=/^(top|right|bottom|left)$/,bN=/^margin/,bO=new RegExp("^("+q+")(.*)$","i"),bP=new RegExp("^("+q+")(?!px)[a-z%]+$","i"),bQ=new RegExp("^([-+])=("+q+")","i"),bR={},bS={position:"absolute",visibility:"hidden",display:"block"},bT={letterSpacing:0,fontWeight:400,lineHeight:1},bU=["Top","Right","Bottom","Left"],bV=["Webkit","O","Moz","ms"],bW=p.fn.toggle;p.fn.extend({css:function(a,c){return p.access(this,function(a,c,d){return d!==b?p.style(a,c,d):p.css(a,c)},a,c,arguments.length>1)},show:function(){return bZ(this,!0)},hide:function(){return bZ(this)},toggle:function(a,b){var c=typeof a=="boolean";return p.isFunction(a)&&p.isFunction(b)?bW.apply(this,arguments):this.each(function(){(c?a:bY(this))?p(this).show():p(this).hide()})}}),p.extend({cssHooks:{opacity:{get:function(a,b){if(b){var c=bH(a,"opacity");return c===""?"1":c}}}},cssNumber:{fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":p.support.cssFloat?"cssFloat":"styleFloat"},style:function(a,c,d,e){if(!a||a.nodeType===3||a.nodeType===8||!a.style)return;var f,g,h,i=p.camelCase(c),j=a.style;c=p.cssProps[i]||(p.cssProps[i]=bX(j,i)),h=p.cssHooks[c]||p.cssHooks[i];if(d===b)return h&&"get"in h&&(f=h.get(a,!1,e))!==b?f:j[c];g=typeof d,g==="string"&&(f=bQ.exec(d))&&(d=(f[1]+1)*f[2]+parseFloat(p.css(a,c)),g="number");if(d==null||g==="number"&&isNaN(d))return;g==="number"&&!p.cssNumber[i]&&(d+="px");if(!h||!("set"in h)||(d=h.set(a,d,e))!==b)try{j[c]=d}catch(k){}},css:function(a,c,d,e){var f,g,h,i=p.camelCase(c);return c=p.cssProps[i]||(p.cssProps[i]=bX(a.style,i)),h=p.cssHooks[c]||p.cssHooks[i],h&&"get"in h&&(f=h.get(a,!0,e)),f===b&&(f=bH(a,c)),f==="normal"&&c in bT&&(f=bT[c]),d||e!==b?(g=parseFloat(f),d||p.isNumeric(g)?g||0:f):f},swap:function(a,b,c){var d,e,f={};for(e in b)f[e]=a.style[e],a.style[e]=b[e];d=c.call(a);for(e in b)a.style[e]=f[e];return d}}),a.getComputedStyle?bH=function(a,b){var c,d,e,f,g=getComputedStyle(a,null),h=a.style;return g&&(c=g[b],c===""&&!p.contains(a.ownerDocument.documentElement,a)&&(c=p.style(a,b)),bP.test(c)&&bN.test(b)&&(d=h.width,e=h.minWidth,f=h.maxWidth,h.minWidth=h.maxWidth=h.width=c,c=g.width,h.width=d,h.minWidth=e,h.maxWidth=f)),c}:e.documentElement.currentStyle&&(bH=function(a,b){var c,d,e=a.currentStyle&&a.currentStyle[b],f=a.style;return e==null&&f&&f[b]&&(e=f[b]),bP.test(e)&&!bM.test(b)&&(c=f.left,d=a.runtimeStyle&&a.runtimeStyle.left,d&&(a.runtimeStyle.left=a.currentStyle.left),f.left=b==="fontSize"?"1em":e,e=f.pixelLeft+"px",f.left=c,d&&(a.runtimeStyle.left=d)),e===""?"auto":e}),p.each(["height","width"],function(a,b){p.cssHooks[b]={get:function(a,c,d){if(c)return a.offsetWidth!==0||bH(a,"display")!=="none"?ca(a,b,d):p.swap(a,bS,function(){return ca(a,b,d)})},set:function(a,c,d){return b$(a,c,d?b_(a,b,d,p.support.boxSizing&&p.css(a,"boxSizing")==="border-box"):0)}}}),p.support.opacity||(p.cssHooks.opacity={get:function(a,b){return bL.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?.01*parseFloat(RegExp.$1)+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle,e=p.isNumeric(b)?"alpha(opacity="+b*100+")":"",f=d&&d.filter||c.filter||"";c.zoom=1;if(b>=1&&p.trim(f.replace(bK,""))===""&&c.removeAttribute){c.removeAttribute("filter");if(d&&!d.filter)return}c.filter=bK.test(f)?f.replace(bK,e):f+" "+e}}),p(function(){p.support.reliableMarginRight||(p.cssHooks.marginRight={get:function(a,b){return p.swap(a,{display:"inline-block"},function(){if(b)return bH(a,"marginRight")})}}),!p.support.pixelPosition&&p.fn.position&&p.each(["top","left"],function(a,b){p.cssHooks[b]={get:function(a,c){if(c){var d=bH(a,b);return bP.test(d)?p(a).position()[b]+"px":d}}}})}),p.expr&&p.expr.filters&&(p.expr.filters.hidden=function(a){return a.offsetWidth===0&&a.offsetHeight===0||!p.support.reliableHiddenOffsets&&(a.style&&a.style.display||bH(a,"display"))==="none"},p.expr.filters.visible=function(a){return!p.expr.filters.hidden(a)}),p.each({margin:"",padding:"",border:"Width"},function(a,b){p.cssHooks[a+b]={expand:function(c){var d,e=typeof c=="string"?c.split(" "):[c],f={};for(d=0;d<4;d++)f[a+bU[d]+b]=e[d]||e[d-2]||e[0];return f}},bN.test(a)||(p.cssHooks[a+b].set=b$)});var cc=/%20/g,cd=/\[\]$/,ce=/\r?\n/g,cf=/^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,cg=/^(?:select|textarea)/i;p.fn.extend({serialize:function(){return p.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?p.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||cg.test(this.nodeName)||cf.test(this.type))}).map(function(a,b){var c=p(this).val();return c==null?null:p.isArray(c)?p.map(c,function(a,c){return{name:b.name,value:a.replace(ce,"\r\n")}}):{name:b.name,value:c.replace(ce,"\r\n")}}).get()}}),p.param=function(a,c){var d,e=[],f=function(a,b){b=p.isFunction(b)?b():b==null?"":b,e[e.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};c===b&&(c=p.ajaxSettings&&p.ajaxSettings.traditional);if(p.isArray(a)||a.jquery&&!p.isPlainObject(a))p.each(a,function(){f(this.name,this.value)});else for(d in a)ch(d,a[d],c,f);return e.join("&").replace(cc,"+")};var ci,cj,ck=/#.*$/,cl=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,cm=/^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,cn=/^(?:GET|HEAD)$/,co=/^\/\//,cp=/\?/,cq=/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,cr=/([?&])_=[^&]*/,cs=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/,ct=p.fn.load,cu={},cv={},cw=["*/"]+["*"];try{ci=f.href}catch(cx){ci=e.createElement("a"),ci.href="",ci=ci.href}cj=cs.exec(ci.toLowerCase())||[],p.fn.load=function(a,c,d){if(typeof a!="string"&&ct)return ct.apply(this,arguments);if(!this.length)return this;var e,f,g,h=this,i=a.indexOf(" ");return i>=0&&(e=a.slice(i,a.length),a=a.slice(0,i)),p.isFunction(c)?(d=c,c=b):typeof c=="object"&&(f="POST"),p.ajax({url:a,type:f,dataType:"html",data:c,complete:function(a,b){d&&h.each(d,g||[a.responseText,b,a])}}).done(function(a){g=arguments,h.html(e?p("<div>").append(a.replace(cq,"")).find(e):a)}),this},p.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){p.fn[b]=function(a){return this.on(b,a)}}),p.each(["get","post"],function(a,c){p[c]=function(a,d,e,f){return p.isFunction(d)&&(f=f||e,e=d,d=b),p.ajax({type:c,url:a,data:d,success:e,dataType:f})}}),p.extend({getScript:function(a,c){return p.get(a,b,c,"script")},getJSON:function(a,b,c){return p.get(a,b,c,"json")},ajaxSetup:function(a,b){return b?cA(a,p.ajaxSettings):(b=a,a=p.ajaxSettings),cA(a,b),a},ajaxSettings:{url:ci,isLocal:cm.test(cj[1]),global:!0,type:"GET",contentType:"application/x-www-form-urlencoded; charset=UTF-8",processData:!0,async:!0,accepts:{xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":cw},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":a.String,"text html":!0,"text json":p.parseJSON,"text xml":p.parseXML},flatOptions:{context:!0,url:!0}},ajaxPrefilter:cy(cu),ajaxTransport:cy(cv),ajax:function(a,c){function y(a,c,f,i){var k,s,t,u,w,y=c;if(v===2)return;v=2,h&&clearTimeout(h),g=b,e=i||"",x.readyState=a>0?4:0,f&&(u=cB(l,x,f));if(a>=200&&a<300||a===304)l.ifModified&&(w=x.getResponseHeader("Last-Modified"),w&&(p.lastModified[d]=w),w=x.getResponseHeader("Etag"),w&&(p.etag[d]=w)),a===304?(y="notmodified",k=!0):(k=cC(l,u),y=k.state,s=k.data,t=k.error,k=!t);else{t=y;if(!y||a)y="error",a<0&&(a=0)}x.status=a,x.statusText=""+(c||y),k?o.resolveWith(m,[s,y,x]):o.rejectWith(m,[x,y,t]),x.statusCode(r),r=b,j&&n.trigger("ajax"+(k?"Success":"Error"),[x,l,k?s:t]),q.fireWith(m,[x,y]),j&&(n.trigger("ajaxComplete",[x,l]),--p.active||p.event.trigger("ajaxStop"))}typeof a=="object"&&(c=a,a=b),c=c||{};var d,e,f,g,h,i,j,k,l=p.ajaxSetup({},c),m=l.context||l,n=m!==l&&(m.nodeType||m instanceof p)?p(m):p.event,o=p.Deferred(),q=p.Callbacks("once memory"),r=l.statusCode||{},t={},u={},v=0,w="canceled",x={readyState:0,setRequestHeader:function(a,b){if(!v){var c=a.toLowerCase();a=u[c]=u[c]||a,t[a]=b}return this},getAllResponseHeaders:function(){return v===2?e:null},getResponseHeader:function(a){var c;if(v===2){if(!f){f={};while(c=cl.exec(e))f[c[1].toLowerCase()]=c[2]}c=f[a.toLowerCase()]}return c===b?null:c},overrideMimeType:function(a){return v||(l.mimeType=a),this},abort:function(a){return a=a||w,g&&g.abort(a),y(0,a),this}};o.promise(x),x.success=x.done,x.error=x.fail,x.complete=q.add,x.statusCode=function(a){if(a){var b;if(v<2)for(b in a)r[b]=[r[b],a[b]];else b=a[x.status],x.always(b)}return this},l.url=((a||l.url)+"").replace(ck,"").replace(co,cj[1]+"//"),l.dataTypes=p.trim(l.dataType||"*").toLowerCase().split(s),l.crossDomain==null&&(i=cs.exec(l.url.toLowerCase()),l.crossDomain=!(!i||i[1]==cj[1]&&i[2]==cj[2]&&(i[3]||(i[1]==="http:"?80:443))==(cj[3]||(cj[1]==="http:"?80:443)))),l.data&&l.processData&&typeof l.data!="string"&&(l.data=p.param(l.data,l.traditional)),cz(cu,l,c,x);if(v===2)return x;j=l.global,l.type=l.type.toUpperCase(),l.hasContent=!cn.test(l.type),j&&p.active++===0&&p.event.trigger("ajaxStart");if(!l.hasContent){l.data&&(l.url+=(cp.test(l.url)?"&":"?")+l.data,delete l.data),d=l.url;if(l.cache===!1){var z=p.now(),A=l.url.replace(cr,"$1_="+z);l.url=A+(A===l.url?(cp.test(l.url)?"&":"?")+"_="+z:"")}}(l.data&&l.hasContent&&l.contentType!==!1||c.contentType)&&x.setRequestHeader("Content-Type",l.contentType),l.ifModified&&(d=d||l.url,p.lastModified[d]&&x.setRequestHeader("If-Modified-Since",p.lastModified[d]),p.etag[d]&&x.setRequestHeader("If-None-Match",p.etag[d])),x.setRequestHeader("Accept",l.dataTypes[0]&&l.accepts[l.dataTypes[0]]?l.accepts[l.dataTypes[0]]+(l.dataTypes[0]!=="*"?", "+cw+"; q=0.01":""):l.accepts["*"]);for(k in l.headers)x.setRequestHeader(k,l.headers[k]);if(!l.beforeSend||l.beforeSend.call(m,x,l)!==!1&&v!==2){w="abort";for(k in{success:1,error:1,complete:1})x[k](l[k]);g=cz(cv,l,c,x);if(!g)y(-1,"No Transport");else{x.readyState=1,j&&n.trigger("ajaxSend",[x,l]),l.async&&l.timeout>0&&(h=setTimeout(function(){x.abort("timeout")},l.timeout));try{v=1,g.send(t,y)}catch(B){if(v<2)y(-1,B);else throw B}}return x}return x.abort()},active:0,lastModified:{},etag:{}});var cD=[],cE=/\?/,cF=/(=)\?(?=&|$)|\?\?/,cG=p.now();p.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var a=cD.pop()||p.expando+"_"+cG++;return this[a]=!0,a}}),p.ajaxPrefilter("json jsonp",function(c,d,e){var f,g,h,i=c.data,j=c.url,k=c.jsonp!==!1,l=k&&cF.test(j),m=k&&!l&&typeof i=="string"&&!(c.contentType||"").indexOf("application/x-www-form-urlencoded")&&cF.test(i);if(c.dataTypes[0]==="jsonp"||l||m)return f=c.jsonpCallback=p.isFunction(c.jsonpCallback)?c.jsonpCallback():c.jsonpCallback,g=a[f],l?c.url=j.replace(cF,"$1"+f):m?c.data=i.replace(cF,"$1"+f):k&&(c.url+=(cE.test(j)?"&":"?")+c.jsonp+"="+f),c.converters["script json"]=function(){return h||p.error(f+" was not called"),h[0]},c.dataTypes[0]="json",a[f]=function(){h=arguments},e.always(function(){a[f]=g,c[f]&&(c.jsonpCallback=d.jsonpCallback,cD.push(f)),h&&p.isFunction(g)&&g(h[0]),h=g=b}),"script"}),p.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/javascript|ecmascript/},converters:{"text script":function(a){return p.globalEval(a),a}}}),p.ajaxPrefilter("script",function(a){a.cache===b&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),p.ajaxTransport("script",function(a){if(a.crossDomain){var c,d=e.head||e.getElementsByTagName("head")[0]||e.documentElement;return{send:function(f,g){c=e.createElement("script"),c.async="async",a.scriptCharset&&(c.charset=a.scriptCharset),c.src=a.url,c.onload=c.onreadystatechange=function(a,e){if(e||!c.readyState||/loaded|complete/.test(c.readyState))c.onload=c.onreadystatechange=null,d&&c.parentNode&&d.removeChild(c),c=b,e||g(200,"success")},d.insertBefore(c,d.firstChild)},abort:function(){c&&c.onload(0,1)}}}});var cH,cI=a.ActiveXObject?function(){for(var a in cH)cH[a](0,1)}:!1,cJ=0;p.ajaxSettings.xhr=a.ActiveXObject?function(){return!this.isLocal&&cK()||cL()}:cK,function(a){p.extend(p.support,{ajax:!!a,cors:!!a&&"withCredentials"in a})}(p.ajaxSettings.xhr()),p.support.ajax&&p.ajaxTransport(function(c){if(!c.crossDomain||p.support.cors){var d;return{send:function(e,f){var g,h,i=c.xhr();c.username?i.open(c.type,c.url,c.async,c.username,c.password):i.open(c.type,c.url,c.async);if(c.xhrFields)for(h in c.xhrFields)i[h]=c.xhrFields[h];c.mimeType&&i.overrideMimeType&&i.overrideMimeType(c.mimeType),!c.crossDomain&&!e["X-Requested-With"]&&(e["X-Requested-With"]="XMLHttpRequest");try{for(h in e)i.setRequestHeader(h,e[h])}catch(j){}i.send(c.hasContent&&c.data||null),d=function(a,e){var h,j,k,l,m;try{if(d&&(e||i.readyState===4)){d=b,g&&(i.onreadystatechange=p.noop,cI&&delete cH[g]);if(e)i.readyState!==4&&i.abort();else{h=i.status,k=i.getAllResponseHeaders(),l={},m=i.responseXML,m&&m.documentElement&&(l.xml=m);try{l.text=i.responseText}catch(a){}try{j=i.statusText}catch(n){j=""}!h&&c.isLocal&&!c.crossDomain?h=l.text?200:404:h===1223&&(h=204)}}}catch(o){e||f(-1,o)}l&&f(h,j,l,k)},c.async?i.readyState===4?setTimeout(d,0):(g=++cJ,cI&&(cH||(cH={},p(a).unload(cI)),cH[g]=d),i.onreadystatechange=d):d()},abort:function(){d&&d(0,1)}}}});var cM,cN,cO=/^(?:toggle|show|hide)$/,cP=new RegExp("^(?:([-+])=|)("+q+")([a-z%]*)$","i"),cQ=/queueHooks$/,cR=[cX],cS={"*":[function(a,b){var c,d,e,f=this.createTween(a,b),g=cP.exec(b),h=f.cur(),i=+h||0,j=1;if(g){c=+g[2],d=g[3]||(p.cssNumber[a]?"":"px");if(d!=="px"&&i){i=p.css(f.elem,a,!0)||c||1;do e=j=j||".5",i=i/j,p.style(f.elem,a,i+d),j=f.cur()/h;while(j!==1&&j!==e)}f.unit=d,f.start=i,f.end=g[1]?i+(g[1]+1)*c:c}return f}]};p.Animation=p.extend(cV,{tweener:function(a,b){p.isFunction(a)?(b=a,a=["*"]):a=a.split(" ");var c,d=0,e=a.length;for(;d<e;d++)c=a[d],cS[c]=cS[c]||[],cS[c].unshift(b)},prefilter:function(a,b){b?cR.unshift(a):cR.push(a)}}),p.Tween=cY,cY.prototype={constructor:cY,init:function(a,b,c,d,e,f){this.elem=a,this.prop=c,this.easing=e||"swing",this.options=b,this.start=this.now=this.cur(),this.end=d,this.unit=f||(p.cssNumber[c]?"":"px")},cur:function(){var a=cY.propHooks[this.prop];return a&&a.get?a.get(this):cY.propHooks._default.get(this)},run:function(a){var b,c=cY.propHooks[this.prop];return this.pos=b=p.easing[this.easing](a,this.options.duration*a,0,1,this.options.duration),this.now=(this.end-this.start)*b+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),c&&c.set?c.set(this):cY.propHooks._default.set(this),this}},cY.prototype.init.prototype=cY.prototype,cY.propHooks={_default:{get:function(a){var b;return a.elem[a.prop]==null||!!a.elem.style&&a.elem.style[a.prop]!=null?(b=p.css(a.elem,a.prop,!1,""),!b||b==="auto"?0:b):a.elem[a.prop]},set:function(a){p.fx.step[a.prop]?p.fx.step[a.prop](a):a.elem.style&&(a.elem.style[p.cssProps[a.prop]]!=null||p.cssHooks[a.prop])?p.style(a.elem,a.prop,a.now+a.unit):a.elem[a.prop]=a.now}}},cY.propHooks.scrollTop=cY.propHooks.scrollLeft={set:function(a){a.elem.nodeType&&a.elem.parentNode&&(a.elem[a.prop]=a.now)}},p.each(["toggle","show","hide"],function(a,b){var c=p.fn[b];p.fn[b]=function(d,e,f){return d==null||typeof d=="boolean"||!a&&p.isFunction(d)&&p.isFunction(e)?c.apply(this,arguments):this.animate(cZ(b,!0),d,e,f)}}),p.fn.extend({fadeTo:function(a,b,c,d){return this.filter(bY).css("opacity",0).show().end().animate({opacity:b},a,c,d)},animate:function(a,b,c,d){var e=p.isEmptyObject(a),f=p.speed(b,c,d),g=function(){var b=cV(this,p.extend({},a),f);e&&b.stop(!0)};return e||f.queue===!1?this.each(g):this.queue(f.queue,g)},stop:function(a,c,d){var e=function(a){var b=a.stop;delete a.stop,b(d)};return typeof a!="string"&&(d=c,c=a,a=b),c&&a!==!1&&this.queue(a||"fx",[]),this.each(function(){var b=!0,c=a!=null&&a+"queueHooks",f=p.timers,g=p._data(this);if(c)g[c]&&g[c].stop&&e(g[c]);else for(c in g)g[c]&&g[c].stop&&cQ.test(c)&&e(g[c]);for(c=f.length;c--;)f[c].elem===this&&(a==null||f[c].queue===a)&&(f[c].anim.stop(d),b=!1,f.splice(c,1));(b||!d)&&p.dequeue(this,a)})}}),p.each({slideDown:cZ("show"),slideUp:cZ("hide"),slideToggle:cZ("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(a,b){p.fn[a]=function(a,c,d){return this.animate(b,a,c,d)}}),p.speed=function(a,b,c){var d=a&&typeof a=="object"?p.extend({},a):{complete:c||!c&&b||p.isFunction(a)&&a,duration:a,easing:c&&b||b&&!p.isFunction(b)&&b};d.duration=p.fx.off?0:typeof d.duration=="number"?d.duration:d.duration in p.fx.speeds?p.fx.speeds[d.duration]:p.fx.speeds._default;if(d.queue==null||d.queue===!0)d.queue="fx";return d.old=d.complete,d.complete=function(){p.isFunction(d.old)&&d.old.call(this),d.queue&&p.dequeue(this,d.queue)},d},p.easing={linear:function(a){return a},swing:function(a){return.5-Math.cos(a*Math.PI)/2}},p.timers=[],p.fx=cY.prototype.init,p.fx.tick=function(){var a,b=p.timers,c=0;for(;c<b.length;c++)a=b[c],!a()&&b[c]===a&&b.splice(c--,1);b.length||p.fx.stop()},p.fx.timer=function(a){a()&&p.timers.push(a)&&!cN&&(cN=setInterval(p.fx.tick,p.fx.interval))},p.fx.interval=13,p.fx.stop=function(){clearInterval(cN),cN=null},p.fx.speeds={slow:600,fast:200,_default:400},p.fx.step={},p.expr&&p.expr.filters&&(p.expr.filters.animated=function(a){return p.grep(p.timers,function(b){return a===b.elem}).length});var c$=/^(?:body|html)$/i;p.fn.offset=function(a){if(arguments.length)return a===b?this:this.each(function(b){p.offset.setOffset(this,a,b)});var c,d,e,f,g,h,i,j,k,l,m=this[0],n=m&&m.ownerDocument;if(!n)return;return(e=n.body)===m?p.offset.bodyOffset(m):(d=n.documentElement,p.contains(d,m)?(c=m.getBoundingClientRect(),f=c_(n),g=d.clientTop||e.clientTop||0,h=d.clientLeft||e.clientLeft||0,i=f.pageYOffset||d.scrollTop,j=f.pageXOffset||d.scrollLeft,k=c.top+i-g,l=c.left+j-h,{top:k,left:l}):{top:0,left:0})},p.offset={bodyOffset:function(a){var b=a.offsetTop,c=a.offsetLeft;return p.support.doesNotIncludeMarginInBodyOffset&&(b+=parseFloat(p.css(a,"marginTop"))||0,c+=parseFloat(p.css(a,"marginLeft"))||0),{top:b,left:c}},setOffset:function(a,b,c){var d=p.css(a,"position");d==="static"&&(a.style.position="relative");var e=p(a),f=e.offset(),g=p.css(a,"top"),h=p.css(a,"left"),i=(d==="absolute"||d==="fixed")&&p.inArray("auto",[g,h])>-1,j={},k={},l,m;i?(k=e.position(),l=k.top,m=k.left):(l=parseFloat(g)||0,m=parseFloat(h)||0),p.isFunction(b)&&(b=b.call(a,c,f)),b.top!=null&&(j.top=b.top-f.top+l),b.left!=null&&(j.left=b.left-f.left+m),"using"in b?b.using.call(a,j):e.css(j)}},p.fn.extend({position:function(){if(!this[0])return;var a=this[0],b=this.offsetParent(),c=this.offset(),d=c$.test(b[0].nodeName)?{top:0,left:0}:b.offset();return c.top-=parseFloat(p.css(a,"marginTop"))||0,c.left-=parseFloat(p.css(a,"marginLeft"))||0,d.top+=parseFloat(p.css(b[0],"borderTopWidth"))||0,d.left+=parseFloat(p.css(b[0],"borderLeftWidth"))||0,{top:c.top-d.top,left:c.left-d.left}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||e.body;while(a&&!c$.test(a.nodeName)&&p.css(a,"position")==="static")a=a.offsetParent;return a||e.body})}}),p.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(a,c){var d=/Y/.test(c);p.fn[a]=function(e){return p.access(this,function(a,e,f){var g=c_(a);if(f===b)return g?c in g?g[c]:g.document.documentElement[e]:a[e];g?g.scrollTo(d?p(g).scrollLeft():f,d?f:p(g).scrollTop()):a[e]=f},a,e,arguments.length,null)}}),p.each({Height:"height",Width:"width"},function(a,c){p.each({padding:"inner"+a,content:c,"":"outer"+a},function(d,e){p.fn[e]=function(e,f){var g=arguments.length&&(d||typeof e!="boolean"),h=d||(e===!0||f===!0?"margin":"border");return p.access(this,function(c,d,e){var f;return p.isWindow(c)?c.document.documentElement["client"+a]:c.nodeType===9?(f=c.documentElement,Math.max(c.body["scroll"+a],f["scroll"+a],c.body["offset"+a],f["offset"+a],f["client"+a])):e===b?p.css(c,d,e,h):p.style(c,d,e,h)},c,g?e:b,g)}})}),a.jQuery=a.$=p,typeof define=="function"&&define.amd&&define.amd.jQuery&&define("jquery",[],function(){return p})})(window);
|
6
|
+
/*
|
7
|
+
Underscore
|
8
|
+
*/
|
9
|
+
// Underscore.js 1.4.3
|
10
|
+
// http://underscorejs.org
|
11
|
+
// (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc.
|
12
|
+
// Underscore may be freely distributed under the MIT license.
|
13
|
+
|
14
|
+
(function() {
|
15
|
+
|
16
|
+
// Baseline setup
|
17
|
+
// --------------
|
18
|
+
|
19
|
+
// Establish the root object, `window` in the browser, or `global` on the server.
|
20
|
+
var root = this;
|
21
|
+
|
22
|
+
// Save the previous value of the `_` variable.
|
23
|
+
var previousUnderscore = root._;
|
24
|
+
|
25
|
+
// Establish the object that gets returned to break out of a loop iteration.
|
26
|
+
var breaker = {};
|
27
|
+
|
28
|
+
// Save bytes in the minified (but not gzipped) version:
|
29
|
+
var ArrayProto = Array.prototype, ObjProto = Object.prototype, FuncProto = Function.prototype;
|
30
|
+
|
31
|
+
// Create quick reference variables for speed access to core prototypes.
|
32
|
+
var push = ArrayProto.push,
|
33
|
+
slice = ArrayProto.slice,
|
34
|
+
concat = ArrayProto.concat,
|
35
|
+
toString = ObjProto.toString,
|
36
|
+
hasOwnProperty = ObjProto.hasOwnProperty;
|
37
|
+
|
38
|
+
// All **ECMAScript 5** native function implementations that we hope to use
|
39
|
+
// are declared here.
|
40
|
+
var
|
41
|
+
nativeForEach = ArrayProto.forEach,
|
42
|
+
nativeMap = ArrayProto.map,
|
43
|
+
nativeReduce = ArrayProto.reduce,
|
44
|
+
nativeReduceRight = ArrayProto.reduceRight,
|
45
|
+
nativeFilter = ArrayProto.filter,
|
46
|
+
nativeEvery = ArrayProto.every,
|
47
|
+
nativeSome = ArrayProto.some,
|
48
|
+
nativeIndexOf = ArrayProto.indexOf,
|
49
|
+
nativeLastIndexOf = ArrayProto.lastIndexOf,
|
50
|
+
nativeIsArray = Array.isArray,
|
51
|
+
nativeKeys = Object.keys,
|
52
|
+
nativeBind = FuncProto.bind;
|
53
|
+
|
54
|
+
// Create a safe reference to the Underscore object for use below.
|
55
|
+
var _ = function(obj) {
|
56
|
+
if (obj instanceof _) return obj;
|
57
|
+
if (!(this instanceof _)) return new _(obj);
|
58
|
+
this._wrapped = obj;
|
59
|
+
};
|
60
|
+
|
61
|
+
// Export the Underscore object for **Node.js**, with
|
62
|
+
// backwards-compatibility for the old `require()` API. If we're in
|
63
|
+
// the browser, add `_` as a global object via a string identifier,
|
64
|
+
// for Closure Compiler "advanced" mode.
|
65
|
+
if (typeof exports !== 'undefined') {
|
66
|
+
if (typeof module !== 'undefined' && module.exports) {
|
67
|
+
exports = module.exports = _;
|
68
|
+
}
|
69
|
+
exports._ = _;
|
70
|
+
} else {
|
71
|
+
root._ = _;
|
72
|
+
}
|
73
|
+
|
74
|
+
// Current version.
|
75
|
+
_.VERSION = '1.4.3';
|
76
|
+
|
77
|
+
// Collection Functions
|
78
|
+
// --------------------
|
79
|
+
|
80
|
+
// The cornerstone, an `each` implementation, aka `forEach`.
|
81
|
+
// Handles objects with the built-in `forEach`, arrays, and raw objects.
|
82
|
+
// Delegates to **ECMAScript 5**'s native `forEach` if available.
|
83
|
+
var each = _.each = _.forEach = function(obj, iterator, context) {
|
84
|
+
if (obj == null) return;
|
85
|
+
if (nativeForEach && obj.forEach === nativeForEach) {
|
86
|
+
obj.forEach(iterator, context);
|
87
|
+
} else if (obj.length === +obj.length) {
|
88
|
+
for (var i = 0, l = obj.length; i < l; i++) {
|
89
|
+
if (iterator.call(context, obj[i], i, obj) === breaker) return;
|
90
|
+
}
|
91
|
+
} else {
|
92
|
+
for (var key in obj) {
|
93
|
+
if (_.has(obj, key)) {
|
94
|
+
if (iterator.call(context, obj[key], key, obj) === breaker) return;
|
95
|
+
}
|
96
|
+
}
|
97
|
+
}
|
98
|
+
};
|
99
|
+
|
100
|
+
// Return the results of applying the iterator to each element.
|
101
|
+
// Delegates to **ECMAScript 5**'s native `map` if available.
|
102
|
+
_.map = _.collect = function(obj, iterator, context) {
|
103
|
+
var results = [];
|
104
|
+
if (obj == null) return results;
|
105
|
+
if (nativeMap && obj.map === nativeMap) return obj.map(iterator, context);
|
106
|
+
each(obj, function(value, index, list) {
|
107
|
+
results[results.length] = iterator.call(context, value, index, list);
|
108
|
+
});
|
109
|
+
return results;
|
110
|
+
};
|
111
|
+
|
112
|
+
var reduceError = 'Reduce of empty array with no initial value';
|
113
|
+
|
114
|
+
// **Reduce** builds up a single result from a list of values, aka `inject`,
|
115
|
+
// or `foldl`. Delegates to **ECMAScript 5**'s native `reduce` if available.
|
116
|
+
_.reduce = _.foldl = _.inject = function(obj, iterator, memo, context) {
|
117
|
+
var initial = arguments.length > 2;
|
118
|
+
if (obj == null) obj = [];
|
119
|
+
if (nativeReduce && obj.reduce === nativeReduce) {
|
120
|
+
if (context) iterator = _.bind(iterator, context);
|
121
|
+
return initial ? obj.reduce(iterator, memo) : obj.reduce(iterator);
|
122
|
+
}
|
123
|
+
each(obj, function(value, index, list) {
|
124
|
+
if (!initial) {
|
125
|
+
memo = value;
|
126
|
+
initial = true;
|
127
|
+
} else {
|
128
|
+
memo = iterator.call(context, memo, value, index, list);
|
129
|
+
}
|
130
|
+
});
|
131
|
+
if (!initial) throw new TypeError(reduceError);
|
132
|
+
return memo;
|
133
|
+
};
|
134
|
+
|
135
|
+
// The right-associative version of reduce, also known as `foldr`.
|
136
|
+
// Delegates to **ECMAScript 5**'s native `reduceRight` if available.
|
137
|
+
_.reduceRight = _.foldr = function(obj, iterator, memo, context) {
|
138
|
+
var initial = arguments.length > 2;
|
139
|
+
if (obj == null) obj = [];
|
140
|
+
if (nativeReduceRight && obj.reduceRight === nativeReduceRight) {
|
141
|
+
if (context) iterator = _.bind(iterator, context);
|
142
|
+
return initial ? obj.reduceRight(iterator, memo) : obj.reduceRight(iterator);
|
143
|
+
}
|
144
|
+
var length = obj.length;
|
145
|
+
if (length !== +length) {
|
146
|
+
var keys = _.keys(obj);
|
147
|
+
length = keys.length;
|
148
|
+
}
|
149
|
+
each(obj, function(value, index, list) {
|
150
|
+
index = keys ? keys[--length] : --length;
|
151
|
+
if (!initial) {
|
152
|
+
memo = obj[index];
|
153
|
+
initial = true;
|
154
|
+
} else {
|
155
|
+
memo = iterator.call(context, memo, obj[index], index, list);
|
156
|
+
}
|
157
|
+
});
|
158
|
+
if (!initial) throw new TypeError(reduceError);
|
159
|
+
return memo;
|
160
|
+
};
|
161
|
+
|
162
|
+
// Return the first value which passes a truth test. Aliased as `detect`.
|
163
|
+
_.find = _.detect = function(obj, iterator, context) {
|
164
|
+
var result;
|
165
|
+
any(obj, function(value, index, list) {
|
166
|
+
if (iterator.call(context, value, index, list)) {
|
167
|
+
result = value;
|
168
|
+
return true;
|
169
|
+
}
|
170
|
+
});
|
171
|
+
return result;
|
172
|
+
};
|
173
|
+
|
174
|
+
// Return all the elements that pass a truth test.
|
175
|
+
// Delegates to **ECMAScript 5**'s native `filter` if available.
|
176
|
+
// Aliased as `select`.
|
177
|
+
_.filter = _.select = function(obj, iterator, context) {
|
178
|
+
var results = [];
|
179
|
+
if (obj == null) return results;
|
180
|
+
if (nativeFilter && obj.filter === nativeFilter) return obj.filter(iterator, context);
|
181
|
+
each(obj, function(value, index, list) {
|
182
|
+
if (iterator.call(context, value, index, list)) results[results.length] = value;
|
183
|
+
});
|
184
|
+
return results;
|
185
|
+
};
|
186
|
+
|
187
|
+
// Return all the elements for which a truth test fails.
|
188
|
+
_.reject = function(obj, iterator, context) {
|
189
|
+
return _.filter(obj, function(value, index, list) {
|
190
|
+
return !iterator.call(context, value, index, list);
|
191
|
+
}, context);
|
192
|
+
};
|
193
|
+
|
194
|
+
// Determine whether all of the elements match a truth test.
|
195
|
+
// Delegates to **ECMAScript 5**'s native `every` if available.
|
196
|
+
// Aliased as `all`.
|
197
|
+
_.every = _.all = function(obj, iterator, context) {
|
198
|
+
iterator || (iterator = _.identity);
|
199
|
+
var result = true;
|
200
|
+
if (obj == null) return result;
|
201
|
+
if (nativeEvery && obj.every === nativeEvery) return obj.every(iterator, context);
|
202
|
+
each(obj, function(value, index, list) {
|
203
|
+
if (!(result = result && iterator.call(context, value, index, list))) return breaker;
|
204
|
+
});
|
205
|
+
return !!result;
|
206
|
+
};
|
207
|
+
|
208
|
+
// Determine if at least one element in the object matches a truth test.
|
209
|
+
// Delegates to **ECMAScript 5**'s native `some` if available.
|
210
|
+
// Aliased as `any`.
|
211
|
+
var any = _.some = _.any = function(obj, iterator, context) {
|
212
|
+
iterator || (iterator = _.identity);
|
213
|
+
var result = false;
|
214
|
+
if (obj == null) return result;
|
215
|
+
if (nativeSome && obj.some === nativeSome) return obj.some(iterator, context);
|
216
|
+
each(obj, function(value, index, list) {
|
217
|
+
if (result || (result = iterator.call(context, value, index, list))) return breaker;
|
218
|
+
});
|
219
|
+
return !!result;
|
220
|
+
};
|
221
|
+
|
222
|
+
// Determine if the array or object contains a given value (using `===`).
|
223
|
+
// Aliased as `include`.
|
224
|
+
_.contains = _.include = function(obj, target) {
|
225
|
+
if (obj == null) return false;
|
226
|
+
if (nativeIndexOf && obj.indexOf === nativeIndexOf) return obj.indexOf(target) != -1;
|
227
|
+
return any(obj, function(value) {
|
228
|
+
return value === target;
|
229
|
+
});
|
230
|
+
};
|
231
|
+
|
232
|
+
// Invoke a method (with arguments) on every item in a collection.
|
233
|
+
_.invoke = function(obj, method) {
|
234
|
+
var args = slice.call(arguments, 2);
|
235
|
+
return _.map(obj, function(value) {
|
236
|
+
return (_.isFunction(method) ? method : value[method]).apply(value, args);
|
237
|
+
});
|
238
|
+
};
|
239
|
+
|
240
|
+
// Convenience version of a common use case of `map`: fetching a property.
|
241
|
+
_.pluck = function(obj, key) {
|
242
|
+
return _.map(obj, function(value){ return value[key]; });
|
243
|
+
};
|
244
|
+
|
245
|
+
// Convenience version of a common use case of `filter`: selecting only objects
|
246
|
+
// with specific `key:value` pairs.
|
247
|
+
_.where = function(obj, attrs) {
|
248
|
+
if (_.isEmpty(attrs)) return [];
|
249
|
+
return _.filter(obj, function(value) {
|
250
|
+
for (var key in attrs) {
|
251
|
+
if (attrs[key] !== value[key]) return false;
|
252
|
+
}
|
253
|
+
return true;
|
254
|
+
});
|
255
|
+
};
|
256
|
+
|
257
|
+
// Return the maximum element or (element-based computation).
|
258
|
+
// Can't optimize arrays of integers longer than 65,535 elements.
|
259
|
+
// See: https://bugs.webkit.org/show_bug.cgi?id=80797
|
260
|
+
_.max = function(obj, iterator, context) {
|
261
|
+
if (!iterator && _.isArray(obj) && obj[0] === +obj[0] && obj.length < 65535) {
|
262
|
+
return Math.max.apply(Math, obj);
|
263
|
+
}
|
264
|
+
if (!iterator && _.isEmpty(obj)) return -Infinity;
|
265
|
+
var result = {computed : -Infinity, value: -Infinity};
|
266
|
+
each(obj, function(value, index, list) {
|
267
|
+
var computed = iterator ? iterator.call(context, value, index, list) : value;
|
268
|
+
computed >= result.computed && (result = {value : value, computed : computed});
|
269
|
+
});
|
270
|
+
return result.value;
|
271
|
+
};
|
272
|
+
|
273
|
+
// Return the minimum element (or element-based computation).
|
274
|
+
_.min = function(obj, iterator, context) {
|
275
|
+
if (!iterator && _.isArray(obj) && obj[0] === +obj[0] && obj.length < 65535) {
|
276
|
+
return Math.min.apply(Math, obj);
|
277
|
+
}
|
278
|
+
if (!iterator && _.isEmpty(obj)) return Infinity;
|
279
|
+
var result = {computed : Infinity, value: Infinity};
|
280
|
+
each(obj, function(value, index, list) {
|
281
|
+
var computed = iterator ? iterator.call(context, value, index, list) : value;
|
282
|
+
computed < result.computed && (result = {value : value, computed : computed});
|
283
|
+
});
|
284
|
+
return result.value;
|
285
|
+
};
|
286
|
+
|
287
|
+
// Shuffle an array.
|
288
|
+
_.shuffle = function(obj) {
|
289
|
+
var rand;
|
290
|
+
var index = 0;
|
291
|
+
var shuffled = [];
|
292
|
+
each(obj, function(value) {
|
293
|
+
rand = _.random(index++);
|
294
|
+
shuffled[index - 1] = shuffled[rand];
|
295
|
+
shuffled[rand] = value;
|
296
|
+
});
|
297
|
+
return shuffled;
|
298
|
+
};
|
299
|
+
|
300
|
+
// An internal function to generate lookup iterators.
|
301
|
+
var lookupIterator = function(value) {
|
302
|
+
return _.isFunction(value) ? value : function(obj){ return obj[value]; };
|
303
|
+
};
|
304
|
+
|
305
|
+
// Sort the object's values by a criterion produced by an iterator.
|
306
|
+
_.sortBy = function(obj, value, context) {
|
307
|
+
var iterator = lookupIterator(value);
|
308
|
+
return _.pluck(_.map(obj, function(value, index, list) {
|
309
|
+
return {
|
310
|
+
value : value,
|
311
|
+
index : index,
|
312
|
+
criteria : iterator.call(context, value, index, list)
|
313
|
+
};
|
314
|
+
}).sort(function(left, right) {
|
315
|
+
var a = left.criteria;
|
316
|
+
var b = right.criteria;
|
317
|
+
if (a !== b) {
|
318
|
+
if (a > b || a === void 0) return 1;
|
319
|
+
if (a < b || b === void 0) return -1;
|
320
|
+
}
|
321
|
+
return left.index < right.index ? -1 : 1;
|
322
|
+
}), 'value');
|
323
|
+
};
|
324
|
+
|
325
|
+
// An internal function used for aggregate "group by" operations.
|
326
|
+
var group = function(obj, value, context, behavior) {
|
327
|
+
var result = {};
|
328
|
+
var iterator = lookupIterator(value || _.identity);
|
329
|
+
each(obj, function(value, index) {
|
330
|
+
var key = iterator.call(context, value, index, obj);
|
331
|
+
behavior(result, key, value);
|
332
|
+
});
|
333
|
+
return result;
|
334
|
+
};
|
335
|
+
|
336
|
+
// Groups the object's values by a criterion. Pass either a string attribute
|
337
|
+
// to group by, or a function that returns the criterion.
|
338
|
+
_.groupBy = function(obj, value, context) {
|
339
|
+
return group(obj, value, context, function(result, key, value) {
|
340
|
+
(_.has(result, key) ? result[key] : (result[key] = [])).push(value);
|
341
|
+
});
|
342
|
+
};
|
343
|
+
|
344
|
+
// Counts instances of an object that group by a certain criterion. Pass
|
345
|
+
// either a string attribute to count by, or a function that returns the
|
346
|
+
// criterion.
|
347
|
+
_.countBy = function(obj, value, context) {
|
348
|
+
return group(obj, value, context, function(result, key) {
|
349
|
+
if (!_.has(result, key)) result[key] = 0;
|
350
|
+
result[key]++;
|
351
|
+
});
|
352
|
+
};
|
353
|
+
|
354
|
+
// Use a comparator function to figure out the smallest index at which
|
355
|
+
// an object should be inserted so as to maintain order. Uses binary search.
|
356
|
+
_.sortedIndex = function(array, obj, iterator, context) {
|
357
|
+
iterator = iterator == null ? _.identity : lookupIterator(iterator);
|
358
|
+
var value = iterator.call(context, obj);
|
359
|
+
var low = 0, high = array.length;
|
360
|
+
while (low < high) {
|
361
|
+
var mid = (low + high) >>> 1;
|
362
|
+
iterator.call(context, array[mid]) < value ? low = mid + 1 : high = mid;
|
363
|
+
}
|
364
|
+
return low;
|
365
|
+
};
|
366
|
+
|
367
|
+
// Safely convert anything iterable into a real, live array.
|
368
|
+
_.toArray = function(obj) {
|
369
|
+
if (!obj) return [];
|
370
|
+
if (_.isArray(obj)) return slice.call(obj);
|
371
|
+
if (obj.length === +obj.length) return _.map(obj, _.identity);
|
372
|
+
return _.values(obj);
|
373
|
+
};
|
374
|
+
|
375
|
+
// Return the number of elements in an object.
|
376
|
+
_.size = function(obj) {
|
377
|
+
if (obj == null) return 0;
|
378
|
+
return (obj.length === +obj.length) ? obj.length : _.keys(obj).length;
|
379
|
+
};
|
380
|
+
|
381
|
+
// Array Functions
|
382
|
+
// ---------------
|
383
|
+
|
384
|
+
// Get the first element of an array. Passing **n** will return the first N
|
385
|
+
// values in the array. Aliased as `head` and `take`. The **guard** check
|
386
|
+
// allows it to work with `_.map`.
|
387
|
+
_.first = _.head = _.take = function(array, n, guard) {
|
388
|
+
if (array == null) return void 0;
|
389
|
+
return (n != null) && !guard ? slice.call(array, 0, n) : array[0];
|
390
|
+
};
|
391
|
+
|
392
|
+
// Returns everything but the last entry of the array. Especially useful on
|
393
|
+
// the arguments object. Passing **n** will return all the values in
|
394
|
+
// the array, excluding the last N. The **guard** check allows it to work with
|
395
|
+
// `_.map`.
|
396
|
+
_.initial = function(array, n, guard) {
|
397
|
+
return slice.call(array, 0, array.length - ((n == null) || guard ? 1 : n));
|
398
|
+
};
|
399
|
+
|
400
|
+
// Get the last element of an array. Passing **n** will return the last N
|
401
|
+
// values in the array. The **guard** check allows it to work with `_.map`.
|
402
|
+
_.last = function(array, n, guard) {
|
403
|
+
if (array == null) return void 0;
|
404
|
+
if ((n != null) && !guard) {
|
405
|
+
return slice.call(array, Math.max(array.length - n, 0));
|
406
|
+
} else {
|
407
|
+
return array[array.length - 1];
|
408
|
+
}
|
409
|
+
};
|
410
|
+
|
411
|
+
// Returns everything but the first entry of the array. Aliased as `tail` and `drop`.
|
412
|
+
// Especially useful on the arguments object. Passing an **n** will return
|
413
|
+
// the rest N values in the array. The **guard**
|
414
|
+
// check allows it to work with `_.map`.
|
415
|
+
_.rest = _.tail = _.drop = function(array, n, guard) {
|
416
|
+
return slice.call(array, (n == null) || guard ? 1 : n);
|
417
|
+
};
|
418
|
+
|
419
|
+
// Trim out all falsy values from an array.
|
420
|
+
_.compact = function(array) {
|
421
|
+
return _.filter(array, _.identity);
|
422
|
+
};
|
423
|
+
|
424
|
+
// Internal implementation of a recursive `flatten` function.
|
425
|
+
var flatten = function(input, shallow, output) {
|
426
|
+
each(input, function(value) {
|
427
|
+
if (_.isArray(value)) {
|
428
|
+
shallow ? push.apply(output, value) : flatten(value, shallow, output);
|
429
|
+
} else {
|
430
|
+
output.push(value);
|
431
|
+
}
|
432
|
+
});
|
433
|
+
return output;
|
434
|
+
};
|
435
|
+
|
436
|
+
// Return a completely flattened version of an array.
|
437
|
+
_.flatten = function(array, shallow) {
|
438
|
+
return flatten(array, shallow, []);
|
439
|
+
};
|
440
|
+
|
441
|
+
// Return a version of the array that does not contain the specified value(s).
|
442
|
+
_.without = function(array) {
|
443
|
+
return _.difference(array, slice.call(arguments, 1));
|
444
|
+
};
|
445
|
+
|
446
|
+
// Produce a duplicate-free version of the array. If the array has already
|
447
|
+
// been sorted, you have the option of using a faster algorithm.
|
448
|
+
// Aliased as `unique`.
|
449
|
+
_.uniq = _.unique = function(array, isSorted, iterator, context) {
|
450
|
+
if (_.isFunction(isSorted)) {
|
451
|
+
context = iterator;
|
452
|
+
iterator = isSorted;
|
453
|
+
isSorted = false;
|
454
|
+
}
|
455
|
+
var initial = iterator ? _.map(array, iterator, context) : array;
|
456
|
+
var results = [];
|
457
|
+
var seen = [];
|
458
|
+
each(initial, function(value, index) {
|
459
|
+
if (isSorted ? (!index || seen[seen.length - 1] !== value) : !_.contains(seen, value)) {
|
460
|
+
seen.push(value);
|
461
|
+
results.push(array[index]);
|
462
|
+
}
|
463
|
+
});
|
464
|
+
return results;
|
465
|
+
};
|
466
|
+
|
467
|
+
// Produce an array that contains the union: each distinct element from all of
|
468
|
+
// the passed-in arrays.
|
469
|
+
_.union = function() {
|
470
|
+
return _.uniq(concat.apply(ArrayProto, arguments));
|
471
|
+
};
|
472
|
+
|
473
|
+
// Produce an array that contains every item shared between all the
|
474
|
+
// passed-in arrays.
|
475
|
+
_.intersection = function(array) {
|
476
|
+
var rest = slice.call(arguments, 1);
|
477
|
+
return _.filter(_.uniq(array), function(item) {
|
478
|
+
return _.every(rest, function(other) {
|
479
|
+
return _.indexOf(other, item) >= 0;
|
480
|
+
});
|
481
|
+
});
|
482
|
+
};
|
483
|
+
|
484
|
+
// Take the difference between one array and a number of other arrays.
|
485
|
+
// Only the elements present in just the first array will remain.
|
486
|
+
_.difference = function(array) {
|
487
|
+
var rest = concat.apply(ArrayProto, slice.call(arguments, 1));
|
488
|
+
return _.filter(array, function(value){ return !_.contains(rest, value); });
|
489
|
+
};
|
490
|
+
|
491
|
+
// Zip together multiple lists into a single array -- elements that share
|
492
|
+
// an index go together.
|
493
|
+
_.zip = function() {
|
494
|
+
var args = slice.call(arguments);
|
495
|
+
var length = _.max(_.pluck(args, 'length'));
|
496
|
+
var results = new Array(length);
|
497
|
+
for (var i = 0; i < length; i++) {
|
498
|
+
results[i] = _.pluck(args, "" + i);
|
499
|
+
}
|
500
|
+
return results;
|
501
|
+
};
|
502
|
+
|
503
|
+
// Converts lists into objects. Pass either a single array of `[key, value]`
|
504
|
+
// pairs, or two parallel arrays of the same length -- one of keys, and one of
|
505
|
+
// the corresponding values.
|
506
|
+
_.object = function(list, values) {
|
507
|
+
if (list == null) return {};
|
508
|
+
var result = {};
|
509
|
+
for (var i = 0, l = list.length; i < l; i++) {
|
510
|
+
if (values) {
|
511
|
+
result[list[i]] = values[i];
|
512
|
+
} else {
|
513
|
+
result[list[i][0]] = list[i][1];
|
514
|
+
}
|
515
|
+
}
|
516
|
+
return result;
|
517
|
+
};
|
518
|
+
|
519
|
+
// If the browser doesn't supply us with indexOf (I'm looking at you, **MSIE**),
|
520
|
+
// we need this function. Return the position of the first occurrence of an
|
521
|
+
// item in an array, or -1 if the item is not included in the array.
|
522
|
+
// Delegates to **ECMAScript 5**'s native `indexOf` if available.
|
523
|
+
// If the array is large and already in sort order, pass `true`
|
524
|
+
// for **isSorted** to use binary search.
|
525
|
+
_.indexOf = function(array, item, isSorted) {
|
526
|
+
if (array == null) return -1;
|
527
|
+
var i = 0, l = array.length;
|
528
|
+
if (isSorted) {
|
529
|
+
if (typeof isSorted == 'number') {
|
530
|
+
i = (isSorted < 0 ? Math.max(0, l + isSorted) : isSorted);
|
531
|
+
} else {
|
532
|
+
i = _.sortedIndex(array, item);
|
533
|
+
return array[i] === item ? i : -1;
|
534
|
+
}
|
535
|
+
}
|
536
|
+
if (nativeIndexOf && array.indexOf === nativeIndexOf) return array.indexOf(item, isSorted);
|
537
|
+
for (; i < l; i++) if (array[i] === item) return i;
|
538
|
+
return -1;
|
539
|
+
};
|
540
|
+
|
541
|
+
// Delegates to **ECMAScript 5**'s native `lastIndexOf` if available.
|
542
|
+
_.lastIndexOf = function(array, item, from) {
|
543
|
+
if (array == null) return -1;
|
544
|
+
var hasIndex = from != null;
|
545
|
+
if (nativeLastIndexOf && array.lastIndexOf === nativeLastIndexOf) {
|
546
|
+
return hasIndex ? array.lastIndexOf(item, from) : array.lastIndexOf(item);
|
547
|
+
}
|
548
|
+
var i = (hasIndex ? from : array.length);
|
549
|
+
while (i--) if (array[i] === item) return i;
|
550
|
+
return -1;
|
551
|
+
};
|
552
|
+
|
553
|
+
// Generate an integer Array containing an arithmetic progression. A port of
|
554
|
+
// the native Python `range()` function. See
|
555
|
+
// [the Python documentation](http://docs.python.org/library/functions.html#range).
|
556
|
+
_.range = function(start, stop, step) {
|
557
|
+
if (arguments.length <= 1) {
|
558
|
+
stop = start || 0;
|
559
|
+
start = 0;
|
560
|
+
}
|
561
|
+
step = arguments[2] || 1;
|
562
|
+
|
563
|
+
var len = Math.max(Math.ceil((stop - start) / step), 0);
|
564
|
+
var idx = 0;
|
565
|
+
var range = new Array(len);
|
566
|
+
|
567
|
+
while(idx < len) {
|
568
|
+
range[idx++] = start;
|
569
|
+
start += step;
|
570
|
+
}
|
571
|
+
|
572
|
+
return range;
|
573
|
+
};
|
574
|
+
|
575
|
+
// Function (ahem) Functions
|
576
|
+
// ------------------
|
577
|
+
|
578
|
+
// Reusable constructor function for prototype setting.
|
579
|
+
var ctor = function(){};
|
580
|
+
|
581
|
+
// Create a function bound to a given object (assigning `this`, and arguments,
|
582
|
+
// optionally). Binding with arguments is also known as `curry`.
|
583
|
+
// Delegates to **ECMAScript 5**'s native `Function.bind` if available.
|
584
|
+
// We check for `func.bind` first, to fail fast when `func` is undefined.
|
585
|
+
_.bind = function(func, context) {
|
586
|
+
var args, bound;
|
587
|
+
if (func.bind === nativeBind && nativeBind) return nativeBind.apply(func, slice.call(arguments, 1));
|
588
|
+
if (!_.isFunction(func)) throw new TypeError;
|
589
|
+
args = slice.call(arguments, 2);
|
590
|
+
return bound = function() {
|
591
|
+
if (!(this instanceof bound)) return func.apply(context, args.concat(slice.call(arguments)));
|
592
|
+
ctor.prototype = func.prototype;
|
593
|
+
var self = new ctor;
|
594
|
+
ctor.prototype = null;
|
595
|
+
var result = func.apply(self, args.concat(slice.call(arguments)));
|
596
|
+
if (Object(result) === result) return result;
|
597
|
+
return self;
|
598
|
+
};
|
599
|
+
};
|
600
|
+
|
601
|
+
// Bind all of an object's methods to that object. Useful for ensuring that
|
602
|
+
// all callbacks defined on an object belong to it.
|
603
|
+
_.bindAll = function(obj) {
|
604
|
+
var funcs = slice.call(arguments, 1);
|
605
|
+
if (funcs.length == 0) funcs = _.functions(obj);
|
606
|
+
each(funcs, function(f) { obj[f] = _.bind(obj[f], obj); });
|
607
|
+
return obj;
|
608
|
+
};
|
609
|
+
|
610
|
+
// Memoize an expensive function by storing its results.
|
611
|
+
_.memoize = function(func, hasher) {
|
612
|
+
var memo = {};
|
613
|
+
hasher || (hasher = _.identity);
|
614
|
+
return function() {
|
615
|
+
var key = hasher.apply(this, arguments);
|
616
|
+
return _.has(memo, key) ? memo[key] : (memo[key] = func.apply(this, arguments));
|
617
|
+
};
|
618
|
+
};
|
619
|
+
|
620
|
+
// Delays a function for the given number of milliseconds, and then calls
|
621
|
+
// it with the arguments supplied.
|
622
|
+
_.delay = function(func, wait) {
|
623
|
+
var args = slice.call(arguments, 2);
|
624
|
+
return setTimeout(function(){ return func.apply(null, args); }, wait);
|
625
|
+
};
|
626
|
+
|
627
|
+
// Defers a function, scheduling it to run after the current call stack has
|
628
|
+
// cleared.
|
629
|
+
_.defer = function(func) {
|
630
|
+
return _.delay.apply(_, [func, 1].concat(slice.call(arguments, 1)));
|
631
|
+
};
|
632
|
+
|
633
|
+
// Returns a function, that, when invoked, will only be triggered at most once
|
634
|
+
// during a given window of time.
|
635
|
+
_.throttle = function(func, wait) {
|
636
|
+
var context, args, timeout, result;
|
637
|
+
var previous = 0;
|
638
|
+
var later = function() {
|
639
|
+
previous = new Date;
|
640
|
+
timeout = null;
|
641
|
+
result = func.apply(context, args);
|
642
|
+
};
|
643
|
+
return function() {
|
644
|
+
var now = new Date;
|
645
|
+
var remaining = wait - (now - previous);
|
646
|
+
context = this;
|
647
|
+
args = arguments;
|
648
|
+
if (remaining <= 0) {
|
649
|
+
clearTimeout(timeout);
|
650
|
+
timeout = null;
|
651
|
+
previous = now;
|
652
|
+
result = func.apply(context, args);
|
653
|
+
} else if (!timeout) {
|
654
|
+
timeout = setTimeout(later, remaining);
|
655
|
+
}
|
656
|
+
return result;
|
657
|
+
};
|
658
|
+
};
|
659
|
+
|
660
|
+
// Returns a function, that, as long as it continues to be invoked, will not
|
661
|
+
// be triggered. The function will be called after it stops being called for
|
662
|
+
// N milliseconds. If `immediate` is passed, trigger the function on the
|
663
|
+
// leading edge, instead of the trailing.
|
664
|
+
_.debounce = function(func, wait, immediate) {
|
665
|
+
var timeout, result;
|
666
|
+
return function() {
|
667
|
+
var context = this, args = arguments;
|
668
|
+
var later = function() {
|
669
|
+
timeout = null;
|
670
|
+
if (!immediate) result = func.apply(context, args);
|
671
|
+
};
|
672
|
+
var callNow = immediate && !timeout;
|
673
|
+
clearTimeout(timeout);
|
674
|
+
timeout = setTimeout(later, wait);
|
675
|
+
if (callNow) result = func.apply(context, args);
|
676
|
+
return result;
|
677
|
+
};
|
678
|
+
};
|
679
|
+
|
680
|
+
// Returns a function that will be executed at most one time, no matter how
|
681
|
+
// often you call it. Useful for lazy initialization.
|
682
|
+
_.once = function(func) {
|
683
|
+
var ran = false, memo;
|
684
|
+
return function() {
|
685
|
+
if (ran) return memo;
|
686
|
+
ran = true;
|
687
|
+
memo = func.apply(this, arguments);
|
688
|
+
func = null;
|
689
|
+
return memo;
|
690
|
+
};
|
691
|
+
};
|
692
|
+
|
693
|
+
// Returns the first function passed as an argument to the second,
|
694
|
+
// allowing you to adjust arguments, run code before and after, and
|
695
|
+
// conditionally execute the original function.
|
696
|
+
_.wrap = function(func, wrapper) {
|
697
|
+
return function() {
|
698
|
+
var args = [func];
|
699
|
+
push.apply(args, arguments);
|
700
|
+
return wrapper.apply(this, args);
|
701
|
+
};
|
702
|
+
};
|
703
|
+
|
704
|
+
// Returns a function that is the composition of a list of functions, each
|
705
|
+
// consuming the return value of the function that follows.
|
706
|
+
_.compose = function() {
|
707
|
+
var funcs = arguments;
|
708
|
+
return function() {
|
709
|
+
var args = arguments;
|
710
|
+
for (var i = funcs.length - 1; i >= 0; i--) {
|
711
|
+
args = [funcs[i].apply(this, args)];
|
712
|
+
}
|
713
|
+
return args[0];
|
714
|
+
};
|
715
|
+
};
|
716
|
+
|
717
|
+
// Returns a function that will only be executed after being called N times.
|
718
|
+
_.after = function(times, func) {
|
719
|
+
if (times <= 0) return func();
|
720
|
+
return function() {
|
721
|
+
if (--times < 1) {
|
722
|
+
return func.apply(this, arguments);
|
723
|
+
}
|
724
|
+
};
|
725
|
+
};
|
726
|
+
|
727
|
+
// Object Functions
|
728
|
+
// ----------------
|
729
|
+
|
730
|
+
// Retrieve the names of an object's properties.
|
731
|
+
// Delegates to **ECMAScript 5**'s native `Object.keys`
|
732
|
+
_.keys = nativeKeys || function(obj) {
|
733
|
+
if (obj !== Object(obj)) throw new TypeError('Invalid object');
|
734
|
+
var keys = [];
|
735
|
+
for (var key in obj) if (_.has(obj, key)) keys[keys.length] = key;
|
736
|
+
return keys;
|
737
|
+
};
|
738
|
+
|
739
|
+
// Retrieve the values of an object's properties.
|
740
|
+
_.values = function(obj) {
|
741
|
+
var values = [];
|
742
|
+
for (var key in obj) if (_.has(obj, key)) values.push(obj[key]);
|
743
|
+
return values;
|
744
|
+
};
|
745
|
+
|
746
|
+
// Convert an object into a list of `[key, value]` pairs.
|
747
|
+
_.pairs = function(obj) {
|
748
|
+
var pairs = [];
|
749
|
+
for (var key in obj) if (_.has(obj, key)) pairs.push([key, obj[key]]);
|
750
|
+
return pairs;
|
751
|
+
};
|
752
|
+
|
753
|
+
// Invert the keys and values of an object. The values must be serializable.
|
754
|
+
_.invert = function(obj) {
|
755
|
+
var result = {};
|
756
|
+
for (var key in obj) if (_.has(obj, key)) result[obj[key]] = key;
|
757
|
+
return result;
|
758
|
+
};
|
759
|
+
|
760
|
+
// Return a sorted list of the function names available on the object.
|
761
|
+
// Aliased as `methods`
|
762
|
+
_.functions = _.methods = function(obj) {
|
763
|
+
var names = [];
|
764
|
+
for (var key in obj) {
|
765
|
+
if (_.isFunction(obj[key])) names.push(key);
|
766
|
+
}
|
767
|
+
return names.sort();
|
768
|
+
};
|
769
|
+
|
770
|
+
// Extend a given object with all the properties in passed-in object(s).
|
771
|
+
_.extend = function(obj) {
|
772
|
+
each(slice.call(arguments, 1), function(source) {
|
773
|
+
if (source) {
|
774
|
+
for (var prop in source) {
|
775
|
+
obj[prop] = source[prop];
|
776
|
+
}
|
777
|
+
}
|
778
|
+
});
|
779
|
+
return obj;
|
780
|
+
};
|
781
|
+
|
782
|
+
// Return a copy of the object only containing the whitelisted properties.
|
783
|
+
_.pick = function(obj) {
|
784
|
+
var copy = {};
|
785
|
+
var keys = concat.apply(ArrayProto, slice.call(arguments, 1));
|
786
|
+
each(keys, function(key) {
|
787
|
+
if (key in obj) copy[key] = obj[key];
|
788
|
+
});
|
789
|
+
return copy;
|
790
|
+
};
|
791
|
+
|
792
|
+
// Return a copy of the object without the blacklisted properties.
|
793
|
+
_.omit = function(obj) {
|
794
|
+
var copy = {};
|
795
|
+
var keys = concat.apply(ArrayProto, slice.call(arguments, 1));
|
796
|
+
for (var key in obj) {
|
797
|
+
if (!_.contains(keys, key)) copy[key] = obj[key];
|
798
|
+
}
|
799
|
+
return copy;
|
800
|
+
};
|
801
|
+
|
802
|
+
// Fill in a given object with default properties.
|
803
|
+
_.defaults = function(obj) {
|
804
|
+
each(slice.call(arguments, 1), function(source) {
|
805
|
+
if (source) {
|
806
|
+
for (var prop in source) {
|
807
|
+
if (obj[prop] == null) obj[prop] = source[prop];
|
808
|
+
}
|
809
|
+
}
|
810
|
+
});
|
811
|
+
return obj;
|
812
|
+
};
|
813
|
+
|
814
|
+
// Create a (shallow-cloned) duplicate of an object.
|
815
|
+
_.clone = function(obj) {
|
816
|
+
if (!_.isObject(obj)) return obj;
|
817
|
+
return _.isArray(obj) ? obj.slice() : _.extend({}, obj);
|
818
|
+
};
|
819
|
+
|
820
|
+
// Invokes interceptor with the obj, and then returns obj.
|
821
|
+
// The primary purpose of this method is to "tap into" a method chain, in
|
822
|
+
// order to perform operations on intermediate results within the chain.
|
823
|
+
_.tap = function(obj, interceptor) {
|
824
|
+
interceptor(obj);
|
825
|
+
return obj;
|
826
|
+
};
|
827
|
+
|
828
|
+
// Internal recursive comparison function for `isEqual`.
|
829
|
+
var eq = function(a, b, aStack, bStack) {
|
830
|
+
// Identical objects are equal. `0 === -0`, but they aren't identical.
|
831
|
+
// See the Harmony `egal` proposal: http://wiki.ecmascript.org/doku.php?id=harmony:egal.
|
832
|
+
if (a === b) return a !== 0 || 1 / a == 1 / b;
|
833
|
+
// A strict comparison is necessary because `null == undefined`.
|
834
|
+
if (a == null || b == null) return a === b;
|
835
|
+
// Unwrap any wrapped objects.
|
836
|
+
if (a instanceof _) a = a._wrapped;
|
837
|
+
if (b instanceof _) b = b._wrapped;
|
838
|
+
// Compare `[[Class]]` names.
|
839
|
+
var className = toString.call(a);
|
840
|
+
if (className != toString.call(b)) return false;
|
841
|
+
switch (className) {
|
842
|
+
// Strings, numbers, dates, and booleans are compared by value.
|
843
|
+
case '[object String]':
|
844
|
+
// Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is
|
845
|
+
// equivalent to `new String("5")`.
|
846
|
+
return a == String(b);
|
847
|
+
case '[object Number]':
|
848
|
+
// `NaN`s are equivalent, but non-reflexive. An `egal` comparison is performed for
|
849
|
+
// other numeric values.
|
850
|
+
return a != +a ? b != +b : (a == 0 ? 1 / a == 1 / b : a == +b);
|
851
|
+
case '[object Date]':
|
852
|
+
case '[object Boolean]':
|
853
|
+
// Coerce dates and booleans to numeric primitive values. Dates are compared by their
|
854
|
+
// millisecond representations. Note that invalid dates with millisecond representations
|
855
|
+
// of `NaN` are not equivalent.
|
856
|
+
return +a == +b;
|
857
|
+
// RegExps are compared by their source patterns and flags.
|
858
|
+
case '[object RegExp]':
|
859
|
+
return a.source == b.source &&
|
860
|
+
a.global == b.global &&
|
861
|
+
a.multiline == b.multiline &&
|
862
|
+
a.ignoreCase == b.ignoreCase;
|
863
|
+
}
|
864
|
+
if (typeof a != 'object' || typeof b != 'object') return false;
|
865
|
+
// Assume equality for cyclic structures. The algorithm for detecting cyclic
|
866
|
+
// structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`.
|
867
|
+
var length = aStack.length;
|
868
|
+
while (length--) {
|
869
|
+
// Linear search. Performance is inversely proportional to the number of
|
870
|
+
// unique nested structures.
|
871
|
+
if (aStack[length] == a) return bStack[length] == b;
|
872
|
+
}
|
873
|
+
// Add the first object to the stack of traversed objects.
|
874
|
+
aStack.push(a);
|
875
|
+
bStack.push(b);
|
876
|
+
var size = 0, result = true;
|
877
|
+
// Recursively compare objects and arrays.
|
878
|
+
if (className == '[object Array]') {
|
879
|
+
// Compare array lengths to determine if a deep comparison is necessary.
|
880
|
+
size = a.length;
|
881
|
+
result = size == b.length;
|
882
|
+
if (result) {
|
883
|
+
// Deep compare the contents, ignoring non-numeric properties.
|
884
|
+
while (size--) {
|
885
|
+
if (!(result = eq(a[size], b[size], aStack, bStack))) break;
|
886
|
+
}
|
887
|
+
}
|
888
|
+
} else {
|
889
|
+
// Objects with different constructors are not equivalent, but `Object`s
|
890
|
+
// from different frames are.
|
891
|
+
var aCtor = a.constructor, bCtor = b.constructor;
|
892
|
+
if (aCtor !== bCtor && !(_.isFunction(aCtor) && (aCtor instanceof aCtor) &&
|
893
|
+
_.isFunction(bCtor) && (bCtor instanceof bCtor))) {
|
894
|
+
return false;
|
895
|
+
}
|
896
|
+
// Deep compare objects.
|
897
|
+
for (var key in a) {
|
898
|
+
if (_.has(a, key)) {
|
899
|
+
// Count the expected number of properties.
|
900
|
+
size++;
|
901
|
+
// Deep compare each member.
|
902
|
+
if (!(result = _.has(b, key) && eq(a[key], b[key], aStack, bStack))) break;
|
903
|
+
}
|
904
|
+
}
|
905
|
+
// Ensure that both objects contain the same number of properties.
|
906
|
+
if (result) {
|
907
|
+
for (key in b) {
|
908
|
+
if (_.has(b, key) && !(size--)) break;
|
909
|
+
}
|
910
|
+
result = !size;
|
911
|
+
}
|
912
|
+
}
|
913
|
+
// Remove the first object from the stack of traversed objects.
|
914
|
+
aStack.pop();
|
915
|
+
bStack.pop();
|
916
|
+
return result;
|
917
|
+
};
|
918
|
+
|
919
|
+
// Perform a deep comparison to check if two objects are equal.
|
920
|
+
_.isEqual = function(a, b) {
|
921
|
+
return eq(a, b, [], []);
|
922
|
+
};
|
923
|
+
|
924
|
+
// Is a given array, string, or object empty?
|
925
|
+
// An "empty" object has no enumerable own-properties.
|
926
|
+
_.isEmpty = function(obj) {
|
927
|
+
if (obj == null) return true;
|
928
|
+
if (_.isArray(obj) || _.isString(obj)) return obj.length === 0;
|
929
|
+
for (var key in obj) if (_.has(obj, key)) return false;
|
930
|
+
return true;
|
931
|
+
};
|
932
|
+
|
933
|
+
// Is a given value a DOM element?
|
934
|
+
_.isElement = function(obj) {
|
935
|
+
return !!(obj && obj.nodeType === 1);
|
936
|
+
};
|
937
|
+
|
938
|
+
// Is a given value an array?
|
939
|
+
// Delegates to ECMA5's native Array.isArray
|
940
|
+
_.isArray = nativeIsArray || function(obj) {
|
941
|
+
return toString.call(obj) == '[object Array]';
|
942
|
+
};
|
943
|
+
|
944
|
+
// Is a given variable an object?
|
945
|
+
_.isObject = function(obj) {
|
946
|
+
return obj === Object(obj);
|
947
|
+
};
|
948
|
+
|
949
|
+
// Add some isType methods: isArguments, isFunction, isString, isNumber, isDate, isRegExp.
|
950
|
+
each(['Arguments', 'Function', 'String', 'Number', 'Date', 'RegExp'], function(name) {
|
951
|
+
_['is' + name] = function(obj) {
|
952
|
+
return toString.call(obj) == '[object ' + name + ']';
|
953
|
+
};
|
954
|
+
});
|
955
|
+
|
956
|
+
// Define a fallback version of the method in browsers (ahem, IE), where
|
957
|
+
// there isn't any inspectable "Arguments" type.
|
958
|
+
if (!_.isArguments(arguments)) {
|
959
|
+
_.isArguments = function(obj) {
|
960
|
+
return !!(obj && _.has(obj, 'callee'));
|
961
|
+
};
|
962
|
+
}
|
963
|
+
|
964
|
+
// Optimize `isFunction` if appropriate.
|
965
|
+
if (typeof (/./) !== 'function') {
|
966
|
+
_.isFunction = function(obj) {
|
967
|
+
return typeof obj === 'function';
|
968
|
+
};
|
969
|
+
}
|
970
|
+
|
971
|
+
// Is a given object a finite number?
|
972
|
+
_.isFinite = function(obj) {
|
973
|
+
return isFinite(obj) && !isNaN(parseFloat(obj));
|
974
|
+
};
|
975
|
+
|
976
|
+
// Is the given value `NaN`? (NaN is the only number which does not equal itself).
|
977
|
+
_.isNaN = function(obj) {
|
978
|
+
return _.isNumber(obj) && obj != +obj;
|
979
|
+
};
|
980
|
+
|
981
|
+
// Is a given value a boolean?
|
982
|
+
_.isBoolean = function(obj) {
|
983
|
+
return obj === true || obj === false || toString.call(obj) == '[object Boolean]';
|
984
|
+
};
|
985
|
+
|
986
|
+
// Is a given value equal to null?
|
987
|
+
_.isNull = function(obj) {
|
988
|
+
return obj === null;
|
989
|
+
};
|
990
|
+
|
991
|
+
// Is a given variable undefined?
|
992
|
+
_.isUndefined = function(obj) {
|
993
|
+
return obj === void 0;
|
994
|
+
};
|
995
|
+
|
996
|
+
// Shortcut function for checking if an object has a given property directly
|
997
|
+
// on itself (in other words, not on a prototype).
|
998
|
+
_.has = function(obj, key) {
|
999
|
+
return hasOwnProperty.call(obj, key);
|
1000
|
+
};
|
1001
|
+
|
1002
|
+
// Utility Functions
|
1003
|
+
// -----------------
|
1004
|
+
|
1005
|
+
// Run Underscore.js in *noConflict* mode, returning the `_` variable to its
|
1006
|
+
// previous owner. Returns a reference to the Underscore object.
|
1007
|
+
_.noConflict = function() {
|
1008
|
+
root._ = previousUnderscore;
|
1009
|
+
return this;
|
1010
|
+
};
|
1011
|
+
|
1012
|
+
// Keep the identity function around for default iterators.
|
1013
|
+
_.identity = function(value) {
|
1014
|
+
return value;
|
1015
|
+
};
|
1016
|
+
|
1017
|
+
// Run a function **n** times.
|
1018
|
+
_.times = function(n, iterator, context) {
|
1019
|
+
var accum = Array(n);
|
1020
|
+
for (var i = 0; i < n; i++) accum[i] = iterator.call(context, i);
|
1021
|
+
return accum;
|
1022
|
+
};
|
1023
|
+
|
1024
|
+
// Return a random integer between min and max (inclusive).
|
1025
|
+
_.random = function(min, max) {
|
1026
|
+
if (max == null) {
|
1027
|
+
max = min;
|
1028
|
+
min = 0;
|
1029
|
+
}
|
1030
|
+
return min + (0 | Math.random() * (max - min + 1));
|
1031
|
+
};
|
1032
|
+
|
1033
|
+
// List of HTML entities for escaping.
|
1034
|
+
var entityMap = {
|
1035
|
+
escape: {
|
1036
|
+
'&': '&',
|
1037
|
+
'<': '<',
|
1038
|
+
'>': '>',
|
1039
|
+
'"': '"',
|
1040
|
+
"'": ''',
|
1041
|
+
'/': '/'
|
1042
|
+
}
|
1043
|
+
};
|
1044
|
+
entityMap.unescape = _.invert(entityMap.escape);
|
1045
|
+
|
1046
|
+
// Regexes containing the keys and values listed immediately above.
|
1047
|
+
var entityRegexes = {
|
1048
|
+
escape: new RegExp('[' + _.keys(entityMap.escape).join('') + ']', 'g'),
|
1049
|
+
unescape: new RegExp('(' + _.keys(entityMap.unescape).join('|') + ')', 'g')
|
1050
|
+
};
|
1051
|
+
|
1052
|
+
// Functions for escaping and unescaping strings to/from HTML interpolation.
|
1053
|
+
_.each(['escape', 'unescape'], function(method) {
|
1054
|
+
_[method] = function(string) {
|
1055
|
+
if (string == null) return '';
|
1056
|
+
return ('' + string).replace(entityRegexes[method], function(match) {
|
1057
|
+
return entityMap[method][match];
|
1058
|
+
});
|
1059
|
+
};
|
1060
|
+
});
|
1061
|
+
|
1062
|
+
// If the value of the named property is a function then invoke it;
|
1063
|
+
// otherwise, return it.
|
1064
|
+
_.result = function(object, property) {
|
1065
|
+
if (object == null) return null;
|
1066
|
+
var value = object[property];
|
1067
|
+
return _.isFunction(value) ? value.call(object) : value;
|
1068
|
+
};
|
1069
|
+
|
1070
|
+
// Add your own custom functions to the Underscore object.
|
1071
|
+
_.mixin = function(obj) {
|
1072
|
+
each(_.functions(obj), function(name){
|
1073
|
+
var func = _[name] = obj[name];
|
1074
|
+
_.prototype[name] = function() {
|
1075
|
+
var args = [this._wrapped];
|
1076
|
+
push.apply(args, arguments);
|
1077
|
+
return result.call(this, func.apply(_, args));
|
1078
|
+
};
|
1079
|
+
});
|
1080
|
+
};
|
1081
|
+
|
1082
|
+
// Generate a unique integer id (unique within the entire client session).
|
1083
|
+
// Useful for temporary DOM ids.
|
1084
|
+
var idCounter = 0;
|
1085
|
+
_.uniqueId = function(prefix) {
|
1086
|
+
var id = '' + ++idCounter;
|
1087
|
+
return prefix ? prefix + id : id;
|
1088
|
+
};
|
1089
|
+
|
1090
|
+
// By default, Underscore uses ERB-style template delimiters, change the
|
1091
|
+
// following template settings to use alternative delimiters.
|
1092
|
+
|
1093
|
+
// When customizing `templateSettings`, if you don't want to define an
|
1094
|
+
// interpolation, evaluation or escaping regex, we need one that is
|
1095
|
+
// guaranteed not to match.
|
1096
|
+
var noMatch = /(.)^/;
|
1097
|
+
|
1098
|
+
// Certain characters need to be escaped so that they can be put into a
|
1099
|
+
// string literal.
|
1100
|
+
var escapes = {
|
1101
|
+
"'": "'",
|
1102
|
+
'\\': '\\',
|
1103
|
+
'\r': 'r',
|
1104
|
+
'\n': 'n',
|
1105
|
+
'\t': 't',
|
1106
|
+
'\u2028': 'u2028',
|
1107
|
+
'\u2029': 'u2029'
|
1108
|
+
};
|
1109
|
+
|
1110
|
+
var escaper = /\\|'|\r|\n|\t|\u2028|\u2029/g;
|
1111
|
+
|
1112
|
+
// JavaScript micro-templating, similar to John Resig's implementation.
|
1113
|
+
// Underscore templating handles arbitrary delimiters, preserves whitespace,
|
1114
|
+
// and correctly escapes quotes within interpolated code.
|
1115
|
+
_.template = function(text, data, settings) {
|
1116
|
+
settings = _.defaults({}, settings, _.templateSettings);
|
1117
|
+
|
1118
|
+
// Combine delimiters into one regular expression via alternation.
|
1119
|
+
var matcher = new RegExp([
|
1120
|
+
(settings.escape || noMatch).source,
|
1121
|
+
(settings.interpolate || noMatch).source,
|
1122
|
+
(settings.evaluate || noMatch).source
|
1123
|
+
].join('|') + '|$', 'g');
|
1124
|
+
|
1125
|
+
// Compile the template source, escaping string literals appropriately.
|
1126
|
+
var index = 0;
|
1127
|
+
var source = "__p+='";
|
1128
|
+
text.replace(matcher, function(match, escape, interpolate, evaluate, offset) {
|
1129
|
+
source += text.slice(index, offset)
|
1130
|
+
.replace(escaper, function(match) { return '\\' + escapes[match]; });
|
1131
|
+
|
1132
|
+
if (escape) {
|
1133
|
+
source += "'+\n((__t=(" + escape + "))==null?'':_.escape(__t))+\n'";
|
1134
|
+
}
|
1135
|
+
if (interpolate) {
|
1136
|
+
source += "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'";
|
1137
|
+
}
|
1138
|
+
if (evaluate) {
|
1139
|
+
source += "';\n" + evaluate + "\n__p+='";
|
1140
|
+
}
|
1141
|
+
index = offset + match.length;
|
1142
|
+
return match;
|
1143
|
+
});
|
1144
|
+
source += "';\n";
|
1145
|
+
|
1146
|
+
// If a variable is not specified, place data values in local scope.
|
1147
|
+
if (!settings.variable) source = 'with(obj||{}){\n' + source + '}\n';
|
1148
|
+
|
1149
|
+
source = "var __t,__p='',__j=Array.prototype.join," +
|
1150
|
+
"print=function(){__p+=__j.call(arguments,'');};\n" +
|
1151
|
+
source + "return __p;\n";
|
1152
|
+
|
1153
|
+
try {
|
1154
|
+
var render = new Function(settings.variable || 'obj', '_', source);
|
1155
|
+
} catch (e) {
|
1156
|
+
e.source = source;
|
1157
|
+
throw e;
|
1158
|
+
}
|
1159
|
+
|
1160
|
+
if (data) return render(data, _);
|
1161
|
+
var template = function(data) {
|
1162
|
+
return render.call(this, data, _);
|
1163
|
+
};
|
1164
|
+
|
1165
|
+
// Provide the compiled function source as a convenience for precompilation.
|
1166
|
+
template.source = 'function(' + (settings.variable || 'obj') + '){\n' + source + '}';
|
1167
|
+
|
1168
|
+
return template;
|
1169
|
+
};
|
1170
|
+
|
1171
|
+
// Add a "chain" function, which will delegate to the wrapper.
|
1172
|
+
_.chain = function(obj) {
|
1173
|
+
return _(obj).chain();
|
1174
|
+
};
|
1175
|
+
|
1176
|
+
// OOP
|
1177
|
+
// ---------------
|
1178
|
+
// If Underscore is called as a function, it returns a wrapped object that
|
1179
|
+
// can be used OO-style. This wrapper holds altered versions of all the
|
1180
|
+
// underscore functions. Wrapped objects may be chained.
|
1181
|
+
|
1182
|
+
// Helper function to continue chaining intermediate results.
|
1183
|
+
var result = function(obj) {
|
1184
|
+
return this._chain ? _(obj).chain() : obj;
|
1185
|
+
};
|
1186
|
+
|
1187
|
+
// Add all of the Underscore functions to the wrapper object.
|
1188
|
+
_.mixin(_);
|
1189
|
+
|
1190
|
+
// Add all mutator Array functions to the wrapper.
|
1191
|
+
each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) {
|
1192
|
+
var method = ArrayProto[name];
|
1193
|
+
_.prototype[name] = function() {
|
1194
|
+
var obj = this._wrapped;
|
1195
|
+
method.apply(obj, arguments);
|
1196
|
+
if ((name == 'shift' || name == 'splice') && obj.length === 0) delete obj[0];
|
1197
|
+
return result.call(this, obj);
|
1198
|
+
};
|
1199
|
+
});
|
1200
|
+
|
1201
|
+
// Add all accessor Array functions to the wrapper.
|
1202
|
+
each(['concat', 'join', 'slice'], function(name) {
|
1203
|
+
var method = ArrayProto[name];
|
1204
|
+
_.prototype[name] = function() {
|
1205
|
+
return result.call(this, method.apply(this._wrapped, arguments));
|
1206
|
+
};
|
1207
|
+
});
|
1208
|
+
|
1209
|
+
_.extend(_.prototype, {
|
1210
|
+
|
1211
|
+
// Start chaining a wrapped Underscore object.
|
1212
|
+
chain: function() {
|
1213
|
+
this._chain = true;
|
1214
|
+
return this;
|
1215
|
+
},
|
1216
|
+
|
1217
|
+
// Extracts the result from a wrapped and chained object.
|
1218
|
+
value: function() {
|
1219
|
+
return this._wrapped;
|
1220
|
+
}
|
1221
|
+
|
1222
|
+
});
|
1223
|
+
|
1224
|
+
}).call(this);
|
1225
|
+
/*
|
1226
|
+
Backbone
|
1227
|
+
*/
|
1228
|
+
// Backbone.js 0.9.2
|
1229
|
+
|
1230
|
+
// (c) 2010-2012 Jeremy Ashkenas, DocumentCloud Inc.
|
1231
|
+
// Backbone may be freely distributed under the MIT license.
|
1232
|
+
// For all details and documentation:
|
1233
|
+
// http://backbonejs.org
|
1234
|
+
(function(){var l=this,y=l.Backbone,z=Array.prototype.slice,A=Array.prototype.splice,g;g="undefined"!==typeof exports?exports:l.Backbone={};g.VERSION="0.9.2";var f=l._;!f&&"undefined"!==typeof require&&(f=require("underscore"));var i=l.jQuery||l.Zepto||l.ender;g.setDomLibrary=function(a){i=a};g.noConflict=function(){l.Backbone=y;return this};g.emulateHTTP=!1;g.emulateJSON=!1;var p=/\s+/,k=g.Events={on:function(a,b,c){var d,e,f,g,j;if(!b)return this;a=a.split(p);for(d=this._callbacks||(this._callbacks=
|
1235
|
+
{});e=a.shift();)f=(j=d[e])?j.tail:{},f.next=g={},f.context=c,f.callback=b,d[e]={tail:g,next:j?j.next:f};return this},off:function(a,b,c){var d,e,h,g,j,q;if(e=this._callbacks){if(!a&&!b&&!c)return delete this._callbacks,this;for(a=a?a.split(p):f.keys(e);d=a.shift();)if(h=e[d],delete e[d],h&&(b||c))for(g=h.tail;(h=h.next)!==g;)if(j=h.callback,q=h.context,b&&j!==b||c&&q!==c)this.on(d,j,q);return this}},trigger:function(a){var b,c,d,e,f,g;if(!(d=this._callbacks))return this;f=d.all;a=a.split(p);for(g=
|
1236
|
+
z.call(arguments,1);b=a.shift();){if(c=d[b])for(e=c.tail;(c=c.next)!==e;)c.callback.apply(c.context||this,g);if(c=f){e=c.tail;for(b=[b].concat(g);(c=c.next)!==e;)c.callback.apply(c.context||this,b)}}return this}};k.bind=k.on;k.unbind=k.off;var o=g.Model=function(a,b){var c;a||(a={});b&&b.parse&&(a=this.parse(a));if(c=n(this,"defaults"))a=f.extend({},c,a);b&&b.collection&&(this.collection=b.collection);this.attributes={};this._escapedAttributes={};this.cid=f.uniqueId("c");this.changed={};this._silent=
|
1237
|
+
{};this._pending={};this.set(a,{silent:!0});this.changed={};this._silent={};this._pending={};this._previousAttributes=f.clone(this.attributes);this.initialize.apply(this,arguments)};f.extend(o.prototype,k,{changed:null,_silent:null,_pending:null,idAttribute:"id",initialize:function(){},toJSON:function(){return f.clone(this.attributes)},get:function(a){return this.attributes[a]},escape:function(a){var b;if(b=this._escapedAttributes[a])return b;b=this.get(a);return this._escapedAttributes[a]=f.escape(null==
|
1238
|
+
b?"":""+b)},has:function(a){return null!=this.get(a)},set:function(a,b,c){var d,e;f.isObject(a)||null==a?(d=a,c=b):(d={},d[a]=b);c||(c={});if(!d)return this;d instanceof o&&(d=d.attributes);if(c.unset)for(e in d)d[e]=void 0;if(!this._validate(d,c))return!1;this.idAttribute in d&&(this.id=d[this.idAttribute]);var b=c.changes={},h=this.attributes,g=this._escapedAttributes,j=this._previousAttributes||{};for(e in d){a=d[e];if(!f.isEqual(h[e],a)||c.unset&&f.has(h,e))delete g[e],(c.silent?this._silent:
|
1239
|
+
b)[e]=!0;c.unset?delete h[e]:h[e]=a;!f.isEqual(j[e],a)||f.has(h,e)!=f.has(j,e)?(this.changed[e]=a,c.silent||(this._pending[e]=!0)):(delete this.changed[e],delete this._pending[e])}c.silent||this.change(c);return this},unset:function(a,b){(b||(b={})).unset=!0;return this.set(a,null,b)},clear:function(a){(a||(a={})).unset=!0;return this.set(f.clone(this.attributes),a)},fetch:function(a){var a=a?f.clone(a):{},b=this,c=a.success;a.success=function(d,e,f){if(!b.set(b.parse(d,f),a))return!1;c&&c(b,d)};
|
1240
|
+
a.error=g.wrapError(a.error,b,a);return(this.sync||g.sync).call(this,"read",this,a)},save:function(a,b,c){var d,e;f.isObject(a)||null==a?(d=a,c=b):(d={},d[a]=b);c=c?f.clone(c):{};if(c.wait){if(!this._validate(d,c))return!1;e=f.clone(this.attributes)}a=f.extend({},c,{silent:!0});if(d&&!this.set(d,c.wait?a:c))return!1;var h=this,i=c.success;c.success=function(a,b,e){b=h.parse(a,e);if(c.wait){delete c.wait;b=f.extend(d||{},b)}if(!h.set(b,c))return false;i?i(h,a):h.trigger("sync",h,a,c)};c.error=g.wrapError(c.error,
|
1241
|
+
h,c);b=this.isNew()?"create":"update";b=(this.sync||g.sync).call(this,b,this,c);c.wait&&this.set(e,a);return b},destroy:function(a){var a=a?f.clone(a):{},b=this,c=a.success,d=function(){b.trigger("destroy",b,b.collection,a)};if(this.isNew())return d(),!1;a.success=function(e){a.wait&&d();c?c(b,e):b.trigger("sync",b,e,a)};a.error=g.wrapError(a.error,b,a);var e=(this.sync||g.sync).call(this,"delete",this,a);a.wait||d();return e},url:function(){var a=n(this,"urlRoot")||n(this.collection,"url")||t();
|
1242
|
+
return this.isNew()?a:a+("/"==a.charAt(a.length-1)?"":"/")+encodeURIComponent(this.id)},parse:function(a){return a},clone:function(){return new this.constructor(this.attributes)},isNew:function(){return null==this.id},change:function(a){a||(a={});var b=this._changing;this._changing=!0;for(var c in this._silent)this._pending[c]=!0;var d=f.extend({},a.changes,this._silent);this._silent={};for(c in d)this.trigger("change:"+c,this,this.get(c),a);if(b)return this;for(;!f.isEmpty(this._pending);){this._pending=
|
1243
|
+
{};this.trigger("change",this,a);for(c in this.changed)!this._pending[c]&&!this._silent[c]&&delete this.changed[c];this._previousAttributes=f.clone(this.attributes)}this._changing=!1;return this},hasChanged:function(a){return!arguments.length?!f.isEmpty(this.changed):f.has(this.changed,a)},changedAttributes:function(a){if(!a)return this.hasChanged()?f.clone(this.changed):!1;var b,c=!1,d=this._previousAttributes,e;for(e in a)if(!f.isEqual(d[e],b=a[e]))(c||(c={}))[e]=b;return c},previous:function(a){return!arguments.length||
|
1244
|
+
!this._previousAttributes?null:this._previousAttributes[a]},previousAttributes:function(){return f.clone(this._previousAttributes)},isValid:function(){return!this.validate(this.attributes)},_validate:function(a,b){if(b.silent||!this.validate)return!0;var a=f.extend({},this.attributes,a),c=this.validate(a,b);if(!c)return!0;b&&b.error?b.error(this,c,b):this.trigger("error",this,c,b);return!1}});var r=g.Collection=function(a,b){b||(b={});b.model&&(this.model=b.model);b.comparator&&(this.comparator=b.comparator);
|
1245
|
+
this._reset();this.initialize.apply(this,arguments);a&&this.reset(a,{silent:!0,parse:b.parse})};f.extend(r.prototype,k,{model:o,initialize:function(){},toJSON:function(a){return this.map(function(b){return b.toJSON(a)})},add:function(a,b){var c,d,e,g,i,j={},k={},l=[];b||(b={});a=f.isArray(a)?a.slice():[a];c=0;for(d=a.length;c<d;c++){if(!(e=a[c]=this._prepareModel(a[c],b)))throw Error("Can't add an invalid model to a collection");g=e.cid;i=e.id;j[g]||this._byCid[g]||null!=i&&(k[i]||this._byId[i])?
|
1246
|
+
l.push(c):j[g]=k[i]=e}for(c=l.length;c--;)a.splice(l[c],1);c=0;for(d=a.length;c<d;c++)(e=a[c]).on("all",this._onModelEvent,this),this._byCid[e.cid]=e,null!=e.id&&(this._byId[e.id]=e);this.length+=d;A.apply(this.models,[null!=b.at?b.at:this.models.length,0].concat(a));this.comparator&&this.sort({silent:!0});if(b.silent)return this;c=0;for(d=this.models.length;c<d;c++)if(j[(e=this.models[c]).cid])b.index=c,e.trigger("add",e,this,b);return this},remove:function(a,b){var c,d,e,g;b||(b={});a=f.isArray(a)?
|
1247
|
+
a.slice():[a];c=0;for(d=a.length;c<d;c++)if(g=this.getByCid(a[c])||this.get(a[c]))delete this._byId[g.id],delete this._byCid[g.cid],e=this.indexOf(g),this.models.splice(e,1),this.length--,b.silent||(b.index=e,g.trigger("remove",g,this,b)),this._removeReference(g);return this},push:function(a,b){a=this._prepareModel(a,b);this.add(a,b);return a},pop:function(a){var b=this.at(this.length-1);this.remove(b,a);return b},unshift:function(a,b){a=this._prepareModel(a,b);this.add(a,f.extend({at:0},b));return a},
|
1248
|
+
shift:function(a){var b=this.at(0);this.remove(b,a);return b},get:function(a){return null==a?void 0:this._byId[null!=a.id?a.id:a]},getByCid:function(a){return a&&this._byCid[a.cid||a]},at:function(a){return this.models[a]},where:function(a){return f.isEmpty(a)?[]:this.filter(function(b){for(var c in a)if(a[c]!==b.get(c))return!1;return!0})},sort:function(a){a||(a={});if(!this.comparator)throw Error("Cannot sort a set without a comparator");var b=f.bind(this.comparator,this);1==this.comparator.length?
|
1249
|
+
this.models=this.sortBy(b):this.models.sort(b);a.silent||this.trigger("reset",this,a);return this},pluck:function(a){return f.map(this.models,function(b){return b.get(a)})},reset:function(a,b){a||(a=[]);b||(b={});for(var c=0,d=this.models.length;c<d;c++)this._removeReference(this.models[c]);this._reset();this.add(a,f.extend({silent:!0},b));b.silent||this.trigger("reset",this,b);return this},fetch:function(a){a=a?f.clone(a):{};void 0===a.parse&&(a.parse=!0);var b=this,c=a.success;a.success=function(d,
|
1250
|
+
e,f){b[a.add?"add":"reset"](b.parse(d,f),a);c&&c(b,d)};a.error=g.wrapError(a.error,b,a);return(this.sync||g.sync).call(this,"read",this,a)},create:function(a,b){var c=this,b=b?f.clone(b):{},a=this._prepareModel(a,b);if(!a)return!1;b.wait||c.add(a,b);var d=b.success;b.success=function(e,f){b.wait&&c.add(e,b);d?d(e,f):e.trigger("sync",a,f,b)};a.save(null,b);return a},parse:function(a){return a},chain:function(){return f(this.models).chain()},_reset:function(){this.length=0;this.models=[];this._byId=
|
1251
|
+
{};this._byCid={}},_prepareModel:function(a,b){b||(b={});a instanceof o?a.collection||(a.collection=this):(b.collection=this,a=new this.model(a,b),a._validate(a.attributes,b)||(a=!1));return a},_removeReference:function(a){this==a.collection&&delete a.collection;a.off("all",this._onModelEvent,this)},_onModelEvent:function(a,b,c,d){("add"==a||"remove"==a)&&c!=this||("destroy"==a&&this.remove(b,d),b&&a==="change:"+b.idAttribute&&(delete this._byId[b.previous(b.idAttribute)],this._byId[b.id]=b),this.trigger.apply(this,
|
1252
|
+
arguments))}});f.each("forEach,each,map,reduce,reduceRight,find,detect,filter,select,reject,every,all,some,any,include,contains,invoke,max,min,sortBy,sortedIndex,toArray,size,first,initial,rest,last,without,indexOf,shuffle,lastIndexOf,isEmpty,groupBy".split(","),function(a){r.prototype[a]=function(){return f[a].apply(f,[this.models].concat(f.toArray(arguments)))}});var u=g.Router=function(a){a||(a={});a.routes&&(this.routes=a.routes);this._bindRoutes();this.initialize.apply(this,arguments)},B=/:\w+/g,
|
1253
|
+
C=/\*\w+/g,D=/[-[\]{}()+?.,\\^$|#\s]/g;f.extend(u.prototype,k,{initialize:function(){},route:function(a,b,c){g.history||(g.history=new m);f.isRegExp(a)||(a=this._routeToRegExp(a));c||(c=this[b]);g.history.route(a,f.bind(function(d){d=this._extractParameters(a,d);c&&c.apply(this,d);this.trigger.apply(this,["route:"+b].concat(d));g.history.trigger("route",this,b,d)},this));return this},navigate:function(a,b){g.history.navigate(a,b)},_bindRoutes:function(){if(this.routes){var a=[],b;for(b in this.routes)a.unshift([b,
|
1254
|
+
this.routes[b]]);b=0;for(var c=a.length;b<c;b++)this.route(a[b][0],a[b][1],this[a[b][1]])}},_routeToRegExp:function(a){a=a.replace(D,"\\$&").replace(B,"([^/]+)").replace(C,"(.*?)");return RegExp("^"+a+"$")},_extractParameters:function(a,b){return a.exec(b).slice(1)}});var m=g.History=function(){this.handlers=[];f.bindAll(this,"checkUrl")},s=/^[#\/]/,E=/msie [\w.]+/;m.started=!1;f.extend(m.prototype,k,{interval:50,getHash:function(a){return(a=(a?a.location:window.location).href.match(/#(.*)$/))?a[1]:
|
1255
|
+
""},getFragment:function(a,b){if(null==a)if(this._hasPushState||b){var a=window.location.pathname,c=window.location.search;c&&(a+=c)}else a=this.getHash();a.indexOf(this.options.root)||(a=a.substr(this.options.root.length));return a.replace(s,"")},start:function(a){if(m.started)throw Error("Backbone.history has already been started");m.started=!0;this.options=f.extend({},{root:"/"},this.options,a);this._wantsHashChange=!1!==this.options.hashChange;this._wantsPushState=!!this.options.pushState;this._hasPushState=
|
1256
|
+
!(!this.options.pushState||!window.history||!window.history.pushState);var a=this.getFragment(),b=document.documentMode;if(b=E.exec(navigator.userAgent.toLowerCase())&&(!b||7>=b))this.iframe=i('<iframe src="javascript:0" tabindex="-1" />').hide().appendTo("body")[0].contentWindow,this.navigate(a);this._hasPushState?i(window).bind("popstate",this.checkUrl):this._wantsHashChange&&"onhashchange"in window&&!b?i(window).bind("hashchange",this.checkUrl):this._wantsHashChange&&(this._checkUrlInterval=setInterval(this.checkUrl,
|
1257
|
+
this.interval));this.fragment=a;a=window.location;b=a.pathname==this.options.root;if(this._wantsHashChange&&this._wantsPushState&&!this._hasPushState&&!b)return this.fragment=this.getFragment(null,!0),window.location.replace(this.options.root+"#"+this.fragment),!0;this._wantsPushState&&this._hasPushState&&b&&a.hash&&(this.fragment=this.getHash().replace(s,""),window.history.replaceState({},document.title,a.protocol+"//"+a.host+this.options.root+this.fragment));if(!this.options.silent)return this.loadUrl()},
|
1258
|
+
stop:function(){i(window).unbind("popstate",this.checkUrl).unbind("hashchange",this.checkUrl);clearInterval(this._checkUrlInterval);m.started=!1},route:function(a,b){this.handlers.unshift({route:a,callback:b})},checkUrl:function(){var a=this.getFragment();a==this.fragment&&this.iframe&&(a=this.getFragment(this.getHash(this.iframe)));if(a==this.fragment)return!1;this.iframe&&this.navigate(a);this.loadUrl()||this.loadUrl(this.getHash())},loadUrl:function(a){var b=this.fragment=this.getFragment(a);return f.any(this.handlers,
|
1259
|
+
function(a){if(a.route.test(b))return a.callback(b),!0})},navigate:function(a,b){if(!m.started)return!1;if(!b||!0===b)b={trigger:b};var c=(a||"").replace(s,"");this.fragment!=c&&(this._hasPushState?(0!=c.indexOf(this.options.root)&&(c=this.options.root+c),this.fragment=c,window.history[b.replace?"replaceState":"pushState"]({},document.title,c)):this._wantsHashChange?(this.fragment=c,this._updateHash(window.location,c,b.replace),this.iframe&&c!=this.getFragment(this.getHash(this.iframe))&&(b.replace||
|
1260
|
+
this.iframe.document.open().close(),this._updateHash(this.iframe.location,c,b.replace))):window.location.assign(this.options.root+a),b.trigger&&this.loadUrl(a))},_updateHash:function(a,b,c){c?a.replace(a.toString().replace(/(javascript:|#).*$/,"")+"#"+b):a.hash=b}});var v=g.View=function(a){this.cid=f.uniqueId("view");this._configure(a||{});this._ensureElement();this.initialize.apply(this,arguments);this.delegateEvents()},F=/^(\S+)\s*(.*)$/,w="model,collection,el,id,attributes,className,tagName".split(",");
|
1261
|
+
f.extend(v.prototype,k,{tagName:"div",$:function(a){return this.$el.find(a)},initialize:function(){},render:function(){return this},remove:function(){this.$el.remove();return this},make:function(a,b,c){a=document.createElement(a);b&&i(a).attr(b);c&&i(a).html(c);return a},setElement:function(a,b){this.$el&&this.undelegateEvents();this.$el=a instanceof i?a:i(a);this.el=this.$el[0];!1!==b&&this.delegateEvents();return this},delegateEvents:function(a){if(a||(a=n(this,"events"))){this.undelegateEvents();
|
1262
|
+
for(var b in a){var c=a[b];f.isFunction(c)||(c=this[a[b]]);if(!c)throw Error('Method "'+a[b]+'" does not exist');var d=b.match(F),e=d[1],d=d[2],c=f.bind(c,this),e=e+(".delegateEvents"+this.cid);""===d?this.$el.bind(e,c):this.$el.delegate(d,e,c)}}},undelegateEvents:function(){this.$el.unbind(".delegateEvents"+this.cid)},_configure:function(a){this.options&&(a=f.extend({},this.options,a));for(var b=0,c=w.length;b<c;b++){var d=w[b];a[d]&&(this[d]=a[d])}this.options=a},_ensureElement:function(){if(this.el)this.setElement(this.el,
|
1263
|
+
!1);else{var a=n(this,"attributes")||{};this.id&&(a.id=this.id);this.className&&(a["class"]=this.className);this.setElement(this.make(this.tagName,a),!1)}}});o.extend=r.extend=u.extend=v.extend=function(a,b){var c=G(this,a,b);c.extend=this.extend;return c};var H={create:"POST",update:"PUT","delete":"DELETE",read:"GET"};g.sync=function(a,b,c){var d=H[a];c||(c={});var e={type:d,dataType:"json"};c.url||(e.url=n(b,"url")||t());if(!c.data&&b&&("create"==a||"update"==a))e.contentType="application/json",
|
1264
|
+
e.data=JSON.stringify(b.toJSON());g.emulateJSON&&(e.contentType="application/x-www-form-urlencoded",e.data=e.data?{model:e.data}:{});if(g.emulateHTTP&&("PUT"===d||"DELETE"===d))g.emulateJSON&&(e.data._method=d),e.type="POST",e.beforeSend=function(a){a.setRequestHeader("X-HTTP-Method-Override",d)};"GET"!==e.type&&!g.emulateJSON&&(e.processData=!1);return i.ajax(f.extend(e,c))};g.wrapError=function(a,b,c){return function(d,e){e=d===b?e:d;a?a(b,e,c):b.trigger("error",b,e,c)}};var x=function(){},G=function(a,
|
1265
|
+
b,c){var d;d=b&&b.hasOwnProperty("constructor")?b.constructor:function(){a.apply(this,arguments)};f.extend(d,a);x.prototype=a.prototype;d.prototype=new x;b&&f.extend(d.prototype,b);c&&f.extend(d,c);d.prototype.constructor=d;d.__super__=a.prototype;return d},n=function(a,b){return!a||!a[b]?null:f.isFunction(a[b])?a[b]():a[b]},t=function(){throw Error('A "url" property or function must be specified');}}).call(this);
|
1266
|
+
/*
|
1267
|
+
Handlebars
|
1268
|
+
*/
|
1269
|
+
// lib/handlebars/base.js
|
1270
|
+
|
1271
|
+
/*jshint eqnull:true*/
|
1272
|
+
this.Handlebars = {};
|
1273
|
+
|
1274
|
+
(function(Handlebars) {
|
1275
|
+
|
1276
|
+
Handlebars.VERSION = "1.0.rc.1";
|
1277
|
+
|
1278
|
+
Handlebars.helpers = {};
|
1279
|
+
Handlebars.partials = {};
|
1280
|
+
|
1281
|
+
Handlebars.registerHelper = function(name, fn, inverse) {
|
1282
|
+
if(inverse) { fn.not = inverse; }
|
1283
|
+
this.helpers[name] = fn;
|
1284
|
+
};
|
1285
|
+
|
1286
|
+
Handlebars.registerPartial = function(name, str) {
|
1287
|
+
this.partials[name] = str;
|
1288
|
+
};
|
1289
|
+
|
1290
|
+
Handlebars.registerHelper('helperMissing', function(arg) {
|
1291
|
+
if(arguments.length === 2) {
|
1292
|
+
return undefined;
|
1293
|
+
} else {
|
1294
|
+
throw new Error("Could not find property '" + arg + "'");
|
1295
|
+
}
|
1296
|
+
});
|
1297
|
+
|
1298
|
+
var toString = Object.prototype.toString, functionType = "[object Function]";
|
1299
|
+
|
1300
|
+
Handlebars.registerHelper('blockHelperMissing', function(context, options) {
|
1301
|
+
var inverse = options.inverse || function() {}, fn = options.fn;
|
1302
|
+
|
1303
|
+
|
1304
|
+
var ret = "";
|
1305
|
+
var type = toString.call(context);
|
1306
|
+
|
1307
|
+
if(type === functionType) { context = context.call(this); }
|
1308
|
+
|
1309
|
+
if(context === true) {
|
1310
|
+
return fn(this);
|
1311
|
+
} else if(context === false || context == null) {
|
1312
|
+
return inverse(this);
|
1313
|
+
} else if(type === "[object Array]") {
|
1314
|
+
if(context.length > 0) {
|
1315
|
+
return Handlebars.helpers.each(context, options);
|
1316
|
+
} else {
|
1317
|
+
return inverse(this);
|
1318
|
+
}
|
1319
|
+
} else {
|
1320
|
+
return fn(context);
|
1321
|
+
}
|
1322
|
+
});
|
1323
|
+
|
1324
|
+
Handlebars.K = function() {};
|
1325
|
+
|
1326
|
+
Handlebars.createFrame = Object.create || function(object) {
|
1327
|
+
Handlebars.K.prototype = object;
|
1328
|
+
var obj = new Handlebars.K();
|
1329
|
+
Handlebars.K.prototype = null;
|
1330
|
+
return obj;
|
1331
|
+
};
|
1332
|
+
|
1333
|
+
Handlebars.registerHelper('each', function(context, options) {
|
1334
|
+
var fn = options.fn, inverse = options.inverse;
|
1335
|
+
var ret = "", data;
|
1336
|
+
|
1337
|
+
if (options.data) {
|
1338
|
+
data = Handlebars.createFrame(options.data);
|
1339
|
+
}
|
1340
|
+
|
1341
|
+
if(context && context.length > 0) {
|
1342
|
+
for(var i=0, j=context.length; i<j; i++) {
|
1343
|
+
if (data) { data.index = i; }
|
1344
|
+
ret = ret + fn(context[i], { data: data });
|
1345
|
+
}
|
1346
|
+
} else {
|
1347
|
+
ret = inverse(this);
|
1348
|
+
}
|
1349
|
+
return ret;
|
1350
|
+
});
|
1351
|
+
|
1352
|
+
Handlebars.registerHelper('if', function(context, options) {
|
1353
|
+
var type = toString.call(context);
|
1354
|
+
if(type === functionType) { context = context.call(this); }
|
1355
|
+
|
1356
|
+
if(!context || Handlebars.Utils.isEmpty(context)) {
|
1357
|
+
return options.inverse(this);
|
1358
|
+
} else {
|
1359
|
+
return options.fn(this);
|
1360
|
+
}
|
1361
|
+
});
|
1362
|
+
|
1363
|
+
Handlebars.registerHelper('unless', function(context, options) {
|
1364
|
+
var fn = options.fn, inverse = options.inverse;
|
1365
|
+
options.fn = inverse;
|
1366
|
+
options.inverse = fn;
|
1367
|
+
|
1368
|
+
return Handlebars.helpers['if'].call(this, context, options);
|
1369
|
+
});
|
1370
|
+
|
1371
|
+
Handlebars.registerHelper('with', function(context, options) {
|
1372
|
+
return options.fn(context);
|
1373
|
+
});
|
1374
|
+
|
1375
|
+
Handlebars.registerHelper('log', function(context) {
|
1376
|
+
Handlebars.log(context);
|
1377
|
+
});
|
1378
|
+
|
1379
|
+
}(this.Handlebars));
|
1380
|
+
;
|
1381
|
+
// lib/handlebars/compiler/parser.js
|
1382
|
+
/* Jison generated parser */
|
1383
|
+
var handlebars = (function(){
|
1384
|
+
var parser = {trace: function trace() { },
|
1385
|
+
yy: {},
|
1386
|
+
symbols_: {"error":2,"root":3,"program":4,"EOF":5,"statements":6,"simpleInverse":7,"statement":8,"openInverse":9,"closeBlock":10,"openBlock":11,"mustache":12,"partial":13,"CONTENT":14,"COMMENT":15,"OPEN_BLOCK":16,"inMustache":17,"CLOSE":18,"OPEN_INVERSE":19,"OPEN_ENDBLOCK":20,"path":21,"OPEN":22,"OPEN_UNESCAPED":23,"OPEN_PARTIAL":24,"params":25,"hash":26,"DATA":27,"param":28,"STRING":29,"INTEGER":30,"BOOLEAN":31,"hashSegments":32,"hashSegment":33,"ID":34,"EQUALS":35,"pathSegments":36,"SEP":37,"$accept":0,"$end":1},
|
1387
|
+
terminals_: {2:"error",5:"EOF",14:"CONTENT",15:"COMMENT",16:"OPEN_BLOCK",18:"CLOSE",19:"OPEN_INVERSE",20:"OPEN_ENDBLOCK",22:"OPEN",23:"OPEN_UNESCAPED",24:"OPEN_PARTIAL",27:"DATA",29:"STRING",30:"INTEGER",31:"BOOLEAN",34:"ID",35:"EQUALS",37:"SEP"},
|
1388
|
+
productions_: [0,[3,2],[4,3],[4,1],[4,0],[6,1],[6,2],[8,3],[8,3],[8,1],[8,1],[8,1],[8,1],[11,3],[9,3],[10,3],[12,3],[12,3],[13,3],[13,4],[7,2],[17,3],[17,2],[17,2],[17,1],[17,1],[25,2],[25,1],[28,1],[28,1],[28,1],[28,1],[28,1],[26,1],[32,2],[32,1],[33,3],[33,3],[33,3],[33,3],[33,3],[21,1],[36,3],[36,1]],
|
1389
|
+
performAction: function anonymous(yytext,yyleng,yylineno,yy,yystate,$$,_$) {
|
1390
|
+
|
1391
|
+
var $0 = $$.length - 1;
|
1392
|
+
switch (yystate) {
|
1393
|
+
case 1: return $$[$0-1];
|
1394
|
+
break;
|
1395
|
+
case 2: this.$ = new yy.ProgramNode($$[$0-2], $$[$0]);
|
1396
|
+
break;
|
1397
|
+
case 3: this.$ = new yy.ProgramNode($$[$0]);
|
1398
|
+
break;
|
1399
|
+
case 4: this.$ = new yy.ProgramNode([]);
|
1400
|
+
break;
|
1401
|
+
case 5: this.$ = [$$[$0]];
|
1402
|
+
break;
|
1403
|
+
case 6: $$[$0-1].push($$[$0]); this.$ = $$[$0-1];
|
1404
|
+
break;
|
1405
|
+
case 7: this.$ = new yy.BlockNode($$[$0-2], $$[$0-1].inverse, $$[$0-1], $$[$0]);
|
1406
|
+
break;
|
1407
|
+
case 8: this.$ = new yy.BlockNode($$[$0-2], $$[$0-1], $$[$0-1].inverse, $$[$0]);
|
1408
|
+
break;
|
1409
|
+
case 9: this.$ = $$[$0];
|
1410
|
+
break;
|
1411
|
+
case 10: this.$ = $$[$0];
|
1412
|
+
break;
|
1413
|
+
case 11: this.$ = new yy.ContentNode($$[$0]);
|
1414
|
+
break;
|
1415
|
+
case 12: this.$ = new yy.CommentNode($$[$0]);
|
1416
|
+
break;
|
1417
|
+
case 13: this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1]);
|
1418
|
+
break;
|
1419
|
+
case 14: this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1]);
|
1420
|
+
break;
|
1421
|
+
case 15: this.$ = $$[$0-1];
|
1422
|
+
break;
|
1423
|
+
case 16: this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1]);
|
1424
|
+
break;
|
1425
|
+
case 17: this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1], true);
|
1426
|
+
break;
|
1427
|
+
case 18: this.$ = new yy.PartialNode($$[$0-1]);
|
1428
|
+
break;
|
1429
|
+
case 19: this.$ = new yy.PartialNode($$[$0-2], $$[$0-1]);
|
1430
|
+
break;
|
1431
|
+
case 20:
|
1432
|
+
break;
|
1433
|
+
case 21: this.$ = [[$$[$0-2]].concat($$[$0-1]), $$[$0]];
|
1434
|
+
break;
|
1435
|
+
case 22: this.$ = [[$$[$0-1]].concat($$[$0]), null];
|
1436
|
+
break;
|
1437
|
+
case 23: this.$ = [[$$[$0-1]], $$[$0]];
|
1438
|
+
break;
|
1439
|
+
case 24: this.$ = [[$$[$0]], null];
|
1440
|
+
break;
|
1441
|
+
case 25: this.$ = [[new yy.DataNode($$[$0])], null];
|
1442
|
+
break;
|
1443
|
+
case 26: $$[$0-1].push($$[$0]); this.$ = $$[$0-1];
|
1444
|
+
break;
|
1445
|
+
case 27: this.$ = [$$[$0]];
|
1446
|
+
break;
|
1447
|
+
case 28: this.$ = $$[$0];
|
1448
|
+
break;
|
1449
|
+
case 29: this.$ = new yy.StringNode($$[$0]);
|
1450
|
+
break;
|
1451
|
+
case 30: this.$ = new yy.IntegerNode($$[$0]);
|
1452
|
+
break;
|
1453
|
+
case 31: this.$ = new yy.BooleanNode($$[$0]);
|
1454
|
+
break;
|
1455
|
+
case 32: this.$ = new yy.DataNode($$[$0]);
|
1456
|
+
break;
|
1457
|
+
case 33: this.$ = new yy.HashNode($$[$0]);
|
1458
|
+
break;
|
1459
|
+
case 34: $$[$0-1].push($$[$0]); this.$ = $$[$0-1];
|
1460
|
+
break;
|
1461
|
+
case 35: this.$ = [$$[$0]];
|
1462
|
+
break;
|
1463
|
+
case 36: this.$ = [$$[$0-2], $$[$0]];
|
1464
|
+
break;
|
1465
|
+
case 37: this.$ = [$$[$0-2], new yy.StringNode($$[$0])];
|
1466
|
+
break;
|
1467
|
+
case 38: this.$ = [$$[$0-2], new yy.IntegerNode($$[$0])];
|
1468
|
+
break;
|
1469
|
+
case 39: this.$ = [$$[$0-2], new yy.BooleanNode($$[$0])];
|
1470
|
+
break;
|
1471
|
+
case 40: this.$ = [$$[$0-2], new yy.DataNode($$[$0])];
|
1472
|
+
break;
|
1473
|
+
case 41: this.$ = new yy.IdNode($$[$0]);
|
1474
|
+
break;
|
1475
|
+
case 42: $$[$0-2].push($$[$0]); this.$ = $$[$0-2];
|
1476
|
+
break;
|
1477
|
+
case 43: this.$ = [$$[$0]];
|
1478
|
+
break;
|
1479
|
+
}
|
1480
|
+
},
|
1481
|
+
table: [{3:1,4:2,5:[2,4],6:3,8:4,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],22:[1,13],23:[1,14],24:[1,15]},{1:[3]},{5:[1,16]},{5:[2,3],7:17,8:18,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,19],20:[2,3],22:[1,13],23:[1,14],24:[1,15]},{5:[2,5],14:[2,5],15:[2,5],16:[2,5],19:[2,5],20:[2,5],22:[2,5],23:[2,5],24:[2,5]},{4:20,6:3,8:4,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],20:[2,4],22:[1,13],23:[1,14],24:[1,15]},{4:21,6:3,8:4,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],20:[2,4],22:[1,13],23:[1,14],24:[1,15]},{5:[2,9],14:[2,9],15:[2,9],16:[2,9],19:[2,9],20:[2,9],22:[2,9],23:[2,9],24:[2,9]},{5:[2,10],14:[2,10],15:[2,10],16:[2,10],19:[2,10],20:[2,10],22:[2,10],23:[2,10],24:[2,10]},{5:[2,11],14:[2,11],15:[2,11],16:[2,11],19:[2,11],20:[2,11],22:[2,11],23:[2,11],24:[2,11]},{5:[2,12],14:[2,12],15:[2,12],16:[2,12],19:[2,12],20:[2,12],22:[2,12],23:[2,12],24:[2,12]},{17:22,21:23,27:[1,24],34:[1,26],36:25},{17:27,21:23,27:[1,24],34:[1,26],36:25},{17:28,21:23,27:[1,24],34:[1,26],36:25},{17:29,21:23,27:[1,24],34:[1,26],36:25},{21:30,34:[1,26],36:25},{1:[2,1]},{6:31,8:4,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],22:[1,13],23:[1,14],24:[1,15]},{5:[2,6],14:[2,6],15:[2,6],16:[2,6],19:[2,6],20:[2,6],22:[2,6],23:[2,6],24:[2,6]},{17:22,18:[1,32],21:23,27:[1,24],34:[1,26],36:25},{10:33,20:[1,34]},{10:35,20:[1,34]},{18:[1,36]},{18:[2,24],21:41,25:37,26:38,27:[1,45],28:39,29:[1,42],30:[1,43],31:[1,44],32:40,33:46,34:[1,47],36:25},{18:[2,25]},{18:[2,41],27:[2,41],29:[2,41],30:[2,41],31:[2,41],34:[2,41],37:[1,48]},{18:[2,43],27:[2,43],29:[2,43],30:[2,43],31:[2,43],34:[2,43],37:[2,43]},{18:[1,49]},{18:[1,50]},{18:[1,51]},{18:[1,52],21:53,34:[1,26],36:25},{5:[2,2],8:18,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],20:[2,2],22:[1,13],23:[1,14],24:[1,15]},{14:[2,20],15:[2,20],16:[2,20],19:[2,20],22:[2,20],23:[2,20],24:[2,20]},{5:[2,7],14:[2,7],15:[2,7],16:[2,7],19:[2,7],20:[2,7],22:[2,7],23:[2,7],24:[2,7]},{21:54,34:[1,26],36:25},{5:[2,8],14:[2,8],15:[2,8],16:[2,8],19:[2,8],20:[2,8],22:[2,8],23:[2,8],24:[2,8]},{14:[2,14],15:[2,14],16:[2,14],19:[2,14],20:[2,14],22:[2,14],23:[2,14],24:[2,14]},{18:[2,22],21:41,26:55,27:[1,45],28:56,29:[1,42],30:[1,43],31:[1,44],32:40,33:46,34:[1,47],36:25},{18:[2,23]},{18:[2,27],27:[2,27],29:[2,27],30:[2,27],31:[2,27],34:[2,27]},{18:[2,33],33:57,34:[1,58]},{18:[2,28],27:[2,28],29:[2,28],30:[2,28],31:[2,28],34:[2,28]},{18:[2,29],27:[2,29],29:[2,29],30:[2,29],31:[2,29],34:[2,29]},{18:[2,30],27:[2,30],29:[2,30],30:[2,30],31:[2,30],34:[2,30]},{18:[2,31],27:[2,31],29:[2,31],30:[2,31],31:[2,31],34:[2,31]},{18:[2,32],27:[2,32],29:[2,32],30:[2,32],31:[2,32],34:[2,32]},{18:[2,35],34:[2,35]},{18:[2,43],27:[2,43],29:[2,43],30:[2,43],31:[2,43],34:[2,43],35:[1,59],37:[2,43]},{34:[1,60]},{14:[2,13],15:[2,13],16:[2,13],19:[2,13],20:[2,13],22:[2,13],23:[2,13],24:[2,13]},{5:[2,16],14:[2,16],15:[2,16],16:[2,16],19:[2,16],20:[2,16],22:[2,16],23:[2,16],24:[2,16]},{5:[2,17],14:[2,17],15:[2,17],16:[2,17],19:[2,17],20:[2,17],22:[2,17],23:[2,17],24:[2,17]},{5:[2,18],14:[2,18],15:[2,18],16:[2,18],19:[2,18],20:[2,18],22:[2,18],23:[2,18],24:[2,18]},{18:[1,61]},{18:[1,62]},{18:[2,21]},{18:[2,26],27:[2,26],29:[2,26],30:[2,26],31:[2,26],34:[2,26]},{18:[2,34],34:[2,34]},{35:[1,59]},{21:63,27:[1,67],29:[1,64],30:[1,65],31:[1,66],34:[1,26],36:25},{18:[2,42],27:[2,42],29:[2,42],30:[2,42],31:[2,42],34:[2,42],37:[2,42]},{5:[2,19],14:[2,19],15:[2,19],16:[2,19],19:[2,19],20:[2,19],22:[2,19],23:[2,19],24:[2,19]},{5:[2,15],14:[2,15],15:[2,15],16:[2,15],19:[2,15],20:[2,15],22:[2,15],23:[2,15],24:[2,15]},{18:[2,36],34:[2,36]},{18:[2,37],34:[2,37]},{18:[2,38],34:[2,38]},{18:[2,39],34:[2,39]},{18:[2,40],34:[2,40]}],
|
1482
|
+
defaultActions: {16:[2,1],24:[2,25],38:[2,23],55:[2,21]},
|
1483
|
+
parseError: function parseError(str, hash) {
|
1484
|
+
throw new Error(str);
|
1485
|
+
},
|
1486
|
+
parse: function parse(input) {
|
1487
|
+
var self = this, stack = [0], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1;
|
1488
|
+
this.lexer.setInput(input);
|
1489
|
+
this.lexer.yy = this.yy;
|
1490
|
+
this.yy.lexer = this.lexer;
|
1491
|
+
this.yy.parser = this;
|
1492
|
+
if (typeof this.lexer.yylloc == "undefined")
|
1493
|
+
this.lexer.yylloc = {};
|
1494
|
+
var yyloc = this.lexer.yylloc;
|
1495
|
+
lstack.push(yyloc);
|
1496
|
+
var ranges = this.lexer.options && this.lexer.options.ranges;
|
1497
|
+
if (typeof this.yy.parseError === "function")
|
1498
|
+
this.parseError = this.yy.parseError;
|
1499
|
+
function popStack(n) {
|
1500
|
+
stack.length = stack.length - 2 * n;
|
1501
|
+
vstack.length = vstack.length - n;
|
1502
|
+
lstack.length = lstack.length - n;
|
1503
|
+
}
|
1504
|
+
function lex() {
|
1505
|
+
var token;
|
1506
|
+
token = self.lexer.lex() || 1;
|
1507
|
+
if (typeof token !== "number") {
|
1508
|
+
token = self.symbols_[token] || token;
|
1509
|
+
}
|
1510
|
+
return token;
|
1511
|
+
}
|
1512
|
+
var symbol, preErrorSymbol, state, action, a, r, yyval = {}, p, len, newState, expected;
|
1513
|
+
while (true) {
|
1514
|
+
state = stack[stack.length - 1];
|
1515
|
+
if (this.defaultActions[state]) {
|
1516
|
+
action = this.defaultActions[state];
|
1517
|
+
} else {
|
1518
|
+
if (symbol === null || typeof symbol == "undefined") {
|
1519
|
+
symbol = lex();
|
1520
|
+
}
|
1521
|
+
action = table[state] && table[state][symbol];
|
1522
|
+
}
|
1523
|
+
if (typeof action === "undefined" || !action.length || !action[0]) {
|
1524
|
+
var errStr = "";
|
1525
|
+
if (!recovering) {
|
1526
|
+
expected = [];
|
1527
|
+
for (p in table[state])
|
1528
|
+
if (this.terminals_[p] && p > 2) {
|
1529
|
+
expected.push("'" + this.terminals_[p] + "'");
|
1530
|
+
}
|
1531
|
+
if (this.lexer.showPosition) {
|
1532
|
+
errStr = "Parse error on line " + (yylineno + 1) + ":\n" + this.lexer.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'";
|
1533
|
+
} else {
|
1534
|
+
errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == 1?"end of input":"'" + (this.terminals_[symbol] || symbol) + "'");
|
1535
|
+
}
|
1536
|
+
this.parseError(errStr, {text: this.lexer.match, token: this.terminals_[symbol] || symbol, line: this.lexer.yylineno, loc: yyloc, expected: expected});
|
1537
|
+
}
|
1538
|
+
}
|
1539
|
+
if (action[0] instanceof Array && action.length > 1) {
|
1540
|
+
throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol);
|
1541
|
+
}
|
1542
|
+
switch (action[0]) {
|
1543
|
+
case 1:
|
1544
|
+
stack.push(symbol);
|
1545
|
+
vstack.push(this.lexer.yytext);
|
1546
|
+
lstack.push(this.lexer.yylloc);
|
1547
|
+
stack.push(action[1]);
|
1548
|
+
symbol = null;
|
1549
|
+
if (!preErrorSymbol) {
|
1550
|
+
yyleng = this.lexer.yyleng;
|
1551
|
+
yytext = this.lexer.yytext;
|
1552
|
+
yylineno = this.lexer.yylineno;
|
1553
|
+
yyloc = this.lexer.yylloc;
|
1554
|
+
if (recovering > 0)
|
1555
|
+
recovering--;
|
1556
|
+
} else {
|
1557
|
+
symbol = preErrorSymbol;
|
1558
|
+
preErrorSymbol = null;
|
1559
|
+
}
|
1560
|
+
break;
|
1561
|
+
case 2:
|
1562
|
+
len = this.productions_[action[1]][1];
|
1563
|
+
yyval.$ = vstack[vstack.length - len];
|
1564
|
+
yyval._$ = {first_line: lstack[lstack.length - (len || 1)].first_line, last_line: lstack[lstack.length - 1].last_line, first_column: lstack[lstack.length - (len || 1)].first_column, last_column: lstack[lstack.length - 1].last_column};
|
1565
|
+
if (ranges) {
|
1566
|
+
yyval._$.range = [lstack[lstack.length - (len || 1)].range[0], lstack[lstack.length - 1].range[1]];
|
1567
|
+
}
|
1568
|
+
r = this.performAction.call(yyval, yytext, yyleng, yylineno, this.yy, action[1], vstack, lstack);
|
1569
|
+
if (typeof r !== "undefined") {
|
1570
|
+
return r;
|
1571
|
+
}
|
1572
|
+
if (len) {
|
1573
|
+
stack = stack.slice(0, -1 * len * 2);
|
1574
|
+
vstack = vstack.slice(0, -1 * len);
|
1575
|
+
lstack = lstack.slice(0, -1 * len);
|
1576
|
+
}
|
1577
|
+
stack.push(this.productions_[action[1]][0]);
|
1578
|
+
vstack.push(yyval.$);
|
1579
|
+
lstack.push(yyval._$);
|
1580
|
+
newState = table[stack[stack.length - 2]][stack[stack.length - 1]];
|
1581
|
+
stack.push(newState);
|
1582
|
+
break;
|
1583
|
+
case 3:
|
1584
|
+
return true;
|
1585
|
+
}
|
1586
|
+
}
|
1587
|
+
return true;
|
1588
|
+
}
|
1589
|
+
};
|
1590
|
+
/* Jison generated lexer */
|
1591
|
+
var lexer = (function(){
|
1592
|
+
var lexer = ({EOF:1,
|
1593
|
+
parseError:function parseError(str, hash) {
|
1594
|
+
if (this.yy.parser) {
|
1595
|
+
this.yy.parser.parseError(str, hash);
|
1596
|
+
} else {
|
1597
|
+
throw new Error(str);
|
1598
|
+
}
|
1599
|
+
},
|
1600
|
+
setInput:function (input) {
|
1601
|
+
this._input = input;
|
1602
|
+
this._more = this._less = this.done = false;
|
1603
|
+
this.yylineno = this.yyleng = 0;
|
1604
|
+
this.yytext = this.matched = this.match = '';
|
1605
|
+
this.conditionStack = ['INITIAL'];
|
1606
|
+
this.yylloc = {first_line:1,first_column:0,last_line:1,last_column:0};
|
1607
|
+
if (this.options.ranges) this.yylloc.range = [0,0];
|
1608
|
+
this.offset = 0;
|
1609
|
+
return this;
|
1610
|
+
},
|
1611
|
+
input:function () {
|
1612
|
+
var ch = this._input[0];
|
1613
|
+
this.yytext += ch;
|
1614
|
+
this.yyleng++;
|
1615
|
+
this.offset++;
|
1616
|
+
this.match += ch;
|
1617
|
+
this.matched += ch;
|
1618
|
+
var lines = ch.match(/(?:\r\n?|\n).*/g);
|
1619
|
+
if (lines) {
|
1620
|
+
this.yylineno++;
|
1621
|
+
this.yylloc.last_line++;
|
1622
|
+
} else {
|
1623
|
+
this.yylloc.last_column++;
|
1624
|
+
}
|
1625
|
+
if (this.options.ranges) this.yylloc.range[1]++;
|
1626
|
+
|
1627
|
+
this._input = this._input.slice(1);
|
1628
|
+
return ch;
|
1629
|
+
},
|
1630
|
+
unput:function (ch) {
|
1631
|
+
var len = ch.length;
|
1632
|
+
var lines = ch.split(/(?:\r\n?|\n)/g);
|
1633
|
+
|
1634
|
+
this._input = ch + this._input;
|
1635
|
+
this.yytext = this.yytext.substr(0, this.yytext.length-len-1);
|
1636
|
+
//this.yyleng -= len;
|
1637
|
+
this.offset -= len;
|
1638
|
+
var oldLines = this.match.split(/(?:\r\n?|\n)/g);
|
1639
|
+
this.match = this.match.substr(0, this.match.length-1);
|
1640
|
+
this.matched = this.matched.substr(0, this.matched.length-1);
|
1641
|
+
|
1642
|
+
if (lines.length-1) this.yylineno -= lines.length-1;
|
1643
|
+
var r = this.yylloc.range;
|
1644
|
+
|
1645
|
+
this.yylloc = {first_line: this.yylloc.first_line,
|
1646
|
+
last_line: this.yylineno+1,
|
1647
|
+
first_column: this.yylloc.first_column,
|
1648
|
+
last_column: lines ?
|
1649
|
+
(lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length:
|
1650
|
+
this.yylloc.first_column - len
|
1651
|
+
};
|
1652
|
+
|
1653
|
+
if (this.options.ranges) {
|
1654
|
+
this.yylloc.range = [r[0], r[0] + this.yyleng - len];
|
1655
|
+
}
|
1656
|
+
return this;
|
1657
|
+
},
|
1658
|
+
more:function () {
|
1659
|
+
this._more = true;
|
1660
|
+
return this;
|
1661
|
+
},
|
1662
|
+
less:function (n) {
|
1663
|
+
this.unput(this.match.slice(n));
|
1664
|
+
},
|
1665
|
+
pastInput:function () {
|
1666
|
+
var past = this.matched.substr(0, this.matched.length - this.match.length);
|
1667
|
+
return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, "");
|
1668
|
+
},
|
1669
|
+
upcomingInput:function () {
|
1670
|
+
var next = this.match;
|
1671
|
+
if (next.length < 20) {
|
1672
|
+
next += this._input.substr(0, 20-next.length);
|
1673
|
+
}
|
1674
|
+
return (next.substr(0,20)+(next.length > 20 ? '...':'')).replace(/\n/g, "");
|
1675
|
+
},
|
1676
|
+
showPosition:function () {
|
1677
|
+
var pre = this.pastInput();
|
1678
|
+
var c = new Array(pre.length + 1).join("-");
|
1679
|
+
return pre + this.upcomingInput() + "\n" + c+"^";
|
1680
|
+
},
|
1681
|
+
next:function () {
|
1682
|
+
if (this.done) {
|
1683
|
+
return this.EOF;
|
1684
|
+
}
|
1685
|
+
if (!this._input) this.done = true;
|
1686
|
+
|
1687
|
+
var token,
|
1688
|
+
match,
|
1689
|
+
tempMatch,
|
1690
|
+
index,
|
1691
|
+
col,
|
1692
|
+
lines;
|
1693
|
+
if (!this._more) {
|
1694
|
+
this.yytext = '';
|
1695
|
+
this.match = '';
|
1696
|
+
}
|
1697
|
+
var rules = this._currentRules();
|
1698
|
+
for (var i=0;i < rules.length; i++) {
|
1699
|
+
tempMatch = this._input.match(this.rules[rules[i]]);
|
1700
|
+
if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
|
1701
|
+
match = tempMatch;
|
1702
|
+
index = i;
|
1703
|
+
if (!this.options.flex) break;
|
1704
|
+
}
|
1705
|
+
}
|
1706
|
+
if (match) {
|
1707
|
+
lines = match[0].match(/(?:\r\n?|\n).*/g);
|
1708
|
+
if (lines) this.yylineno += lines.length;
|
1709
|
+
this.yylloc = {first_line: this.yylloc.last_line,
|
1710
|
+
last_line: this.yylineno+1,
|
1711
|
+
first_column: this.yylloc.last_column,
|
1712
|
+
last_column: lines ? lines[lines.length-1].length-lines[lines.length-1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length};
|
1713
|
+
this.yytext += match[0];
|
1714
|
+
this.match += match[0];
|
1715
|
+
this.matches = match;
|
1716
|
+
this.yyleng = this.yytext.length;
|
1717
|
+
if (this.options.ranges) {
|
1718
|
+
this.yylloc.range = [this.offset, this.offset += this.yyleng];
|
1719
|
+
}
|
1720
|
+
this._more = false;
|
1721
|
+
this._input = this._input.slice(match[0].length);
|
1722
|
+
this.matched += match[0];
|
1723
|
+
token = this.performAction.call(this, this.yy, this, rules[index],this.conditionStack[this.conditionStack.length-1]);
|
1724
|
+
if (this.done && this._input) this.done = false;
|
1725
|
+
if (token) return token;
|
1726
|
+
else return;
|
1727
|
+
}
|
1728
|
+
if (this._input === "") {
|
1729
|
+
return this.EOF;
|
1730
|
+
} else {
|
1731
|
+
return this.parseError('Lexical error on line '+(this.yylineno+1)+'. Unrecognized text.\n'+this.showPosition(),
|
1732
|
+
{text: "", token: null, line: this.yylineno});
|
1733
|
+
}
|
1734
|
+
},
|
1735
|
+
lex:function lex() {
|
1736
|
+
var r = this.next();
|
1737
|
+
if (typeof r !== 'undefined') {
|
1738
|
+
return r;
|
1739
|
+
} else {
|
1740
|
+
return this.lex();
|
1741
|
+
}
|
1742
|
+
},
|
1743
|
+
begin:function begin(condition) {
|
1744
|
+
this.conditionStack.push(condition);
|
1745
|
+
},
|
1746
|
+
popState:function popState() {
|
1747
|
+
return this.conditionStack.pop();
|
1748
|
+
},
|
1749
|
+
_currentRules:function _currentRules() {
|
1750
|
+
return this.conditions[this.conditionStack[this.conditionStack.length-1]].rules;
|
1751
|
+
},
|
1752
|
+
topState:function () {
|
1753
|
+
return this.conditionStack[this.conditionStack.length-2];
|
1754
|
+
},
|
1755
|
+
pushState:function begin(condition) {
|
1756
|
+
this.begin(condition);
|
1757
|
+
}});
|
1758
|
+
lexer.options = {};
|
1759
|
+
lexer.performAction = function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) {
|
1760
|
+
|
1761
|
+
var YYSTATE=YY_START
|
1762
|
+
switch($avoiding_name_collisions) {
|
1763
|
+
case 0:
|
1764
|
+
if(yy_.yytext.slice(-1) !== "\\") this.begin("mu");
|
1765
|
+
if(yy_.yytext.slice(-1) === "\\") yy_.yytext = yy_.yytext.substr(0,yy_.yyleng-1), this.begin("emu");
|
1766
|
+
if(yy_.yytext) return 14;
|
1767
|
+
|
1768
|
+
break;
|
1769
|
+
case 1: return 14;
|
1770
|
+
break;
|
1771
|
+
case 2:
|
1772
|
+
if(yy_.yytext.slice(-1) !== "\\") this.popState();
|
1773
|
+
if(yy_.yytext.slice(-1) === "\\") yy_.yytext = yy_.yytext.substr(0,yy_.yyleng-1);
|
1774
|
+
return 14;
|
1775
|
+
|
1776
|
+
break;
|
1777
|
+
case 3: return 24;
|
1778
|
+
break;
|
1779
|
+
case 4: return 16;
|
1780
|
+
break;
|
1781
|
+
case 5: return 20;
|
1782
|
+
break;
|
1783
|
+
case 6: return 19;
|
1784
|
+
break;
|
1785
|
+
case 7: return 19;
|
1786
|
+
break;
|
1787
|
+
case 8: return 23;
|
1788
|
+
break;
|
1789
|
+
case 9: return 23;
|
1790
|
+
break;
|
1791
|
+
case 10: yy_.yytext = yy_.yytext.substr(3,yy_.yyleng-5); this.popState(); return 15;
|
1792
|
+
break;
|
1793
|
+
case 11: return 22;
|
1794
|
+
break;
|
1795
|
+
case 12: return 35;
|
1796
|
+
break;
|
1797
|
+
case 13: return 34;
|
1798
|
+
break;
|
1799
|
+
case 14: return 34;
|
1800
|
+
break;
|
1801
|
+
case 15: return 37;
|
1802
|
+
break;
|
1803
|
+
case 16: /*ignore whitespace*/
|
1804
|
+
break;
|
1805
|
+
case 17: this.popState(); return 18;
|
1806
|
+
break;
|
1807
|
+
case 18: this.popState(); return 18;
|
1808
|
+
break;
|
1809
|
+
case 19: yy_.yytext = yy_.yytext.substr(1,yy_.yyleng-2).replace(/\\"/g,'"'); return 29;
|
1810
|
+
break;
|
1811
|
+
case 20: yy_.yytext = yy_.yytext.substr(1,yy_.yyleng-2).replace(/\\"/g,'"'); return 29;
|
1812
|
+
break;
|
1813
|
+
case 21: yy_.yytext = yy_.yytext.substr(1); return 27;
|
1814
|
+
break;
|
1815
|
+
case 22: return 31;
|
1816
|
+
break;
|
1817
|
+
case 23: return 31;
|
1818
|
+
break;
|
1819
|
+
case 24: return 30;
|
1820
|
+
break;
|
1821
|
+
case 25: return 34;
|
1822
|
+
break;
|
1823
|
+
case 26: yy_.yytext = yy_.yytext.substr(1, yy_.yyleng-2); return 34;
|
1824
|
+
break;
|
1825
|
+
case 27: return 'INVALID';
|
1826
|
+
break;
|
1827
|
+
case 28: return 5;
|
1828
|
+
break;
|
1829
|
+
}
|
1830
|
+
};
|
1831
|
+
lexer.rules = [/^(?:[^\x00]*?(?=(\{\{)))/,/^(?:[^\x00]+)/,/^(?:[^\x00]{2,}?(?=(\{\{|$)))/,/^(?:\{\{>)/,/^(?:\{\{#)/,/^(?:\{\{\/)/,/^(?:\{\{\^)/,/^(?:\{\{\s*else\b)/,/^(?:\{\{\{)/,/^(?:\{\{&)/,/^(?:\{\{![\s\S]*?\}\})/,/^(?:\{\{)/,/^(?:=)/,/^(?:\.(?=[} ]))/,/^(?:\.\.)/,/^(?:[\/.])/,/^(?:\s+)/,/^(?:\}\}\})/,/^(?:\}\})/,/^(?:"(\\["]|[^"])*")/,/^(?:'(\\[']|[^'])*')/,/^(?:@[a-zA-Z]+)/,/^(?:true(?=[}\s]))/,/^(?:false(?=[}\s]))/,/^(?:[0-9]+(?=[}\s]))/,/^(?:[a-zA-Z0-9_$-]+(?=[=}\s\/.]))/,/^(?:\[[^\]]*\])/,/^(?:.)/,/^(?:$)/];
|
1832
|
+
lexer.conditions = {"mu":{"rules":[3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28],"inclusive":false},"emu":{"rules":[2],"inclusive":false},"INITIAL":{"rules":[0,1,28],"inclusive":true}};
|
1833
|
+
return lexer;})()
|
1834
|
+
parser.lexer = lexer;
|
1835
|
+
function Parser () { this.yy = {}; }Parser.prototype = parser;parser.Parser = Parser;
|
1836
|
+
return new Parser;
|
1837
|
+
})();
|
1838
|
+
if (typeof require !== 'undefined' && typeof exports !== 'undefined') {
|
1839
|
+
exports.parser = handlebars;
|
1840
|
+
exports.Parser = handlebars.Parser;
|
1841
|
+
exports.parse = function () { return handlebars.parse.apply(handlebars, arguments); }
|
1842
|
+
exports.main = function commonjsMain(args) {
|
1843
|
+
if (!args[1])
|
1844
|
+
throw new Error('Usage: '+args[0]+' FILE');
|
1845
|
+
var source, cwd;
|
1846
|
+
if (typeof process !== 'undefined') {
|
1847
|
+
source = require('fs').readFileSync(require('path').resolve(args[1]), "utf8");
|
1848
|
+
} else {
|
1849
|
+
source = require("file").path(require("file").cwd()).join(args[1]).read({charset: "utf-8"});
|
1850
|
+
}
|
1851
|
+
return exports.parser.parse(source);
|
1852
|
+
}
|
1853
|
+
if (typeof module !== 'undefined' && require.main === module) {
|
1854
|
+
exports.main(typeof process !== 'undefined' ? process.argv.slice(1) : require("system").args);
|
1855
|
+
}
|
1856
|
+
};
|
1857
|
+
;
|
1858
|
+
// lib/handlebars/compiler/base.js
|
1859
|
+
Handlebars.Parser = handlebars;
|
1860
|
+
|
1861
|
+
Handlebars.parse = function(string) {
|
1862
|
+
Handlebars.Parser.yy = Handlebars.AST;
|
1863
|
+
return Handlebars.Parser.parse(string);
|
1864
|
+
};
|
1865
|
+
|
1866
|
+
Handlebars.print = function(ast) {
|
1867
|
+
return new Handlebars.PrintVisitor().accept(ast);
|
1868
|
+
};
|
1869
|
+
|
1870
|
+
Handlebars.logger = {
|
1871
|
+
DEBUG: 0, INFO: 1, WARN: 2, ERROR: 3, level: 3,
|
1872
|
+
|
1873
|
+
// override in the host environment
|
1874
|
+
log: function(level, str) {}
|
1875
|
+
};
|
1876
|
+
|
1877
|
+
Handlebars.log = function(level, str) { Handlebars.logger.log(level, str); };
|
1878
|
+
;
|
1879
|
+
// lib/handlebars/compiler/ast.js
|
1880
|
+
(function() {
|
1881
|
+
|
1882
|
+
Handlebars.AST = {};
|
1883
|
+
|
1884
|
+
Handlebars.AST.ProgramNode = function(statements, inverse) {
|
1885
|
+
this.type = "program";
|
1886
|
+
this.statements = statements;
|
1887
|
+
if(inverse) { this.inverse = new Handlebars.AST.ProgramNode(inverse); }
|
1888
|
+
};
|
1889
|
+
|
1890
|
+
Handlebars.AST.MustacheNode = function(rawParams, hash, unescaped) {
|
1891
|
+
this.type = "mustache";
|
1892
|
+
this.escaped = !unescaped;
|
1893
|
+
this.hash = hash;
|
1894
|
+
|
1895
|
+
var id = this.id = rawParams[0];
|
1896
|
+
var params = this.params = rawParams.slice(1);
|
1897
|
+
|
1898
|
+
// a mustache is an eligible helper if:
|
1899
|
+
// * its id is simple (a single part, not `this` or `..`)
|
1900
|
+
var eligibleHelper = this.eligibleHelper = id.isSimple;
|
1901
|
+
|
1902
|
+
// a mustache is definitely a helper if:
|
1903
|
+
// * it is an eligible helper, and
|
1904
|
+
// * it has at least one parameter or hash segment
|
1905
|
+
this.isHelper = eligibleHelper && (params.length || hash);
|
1906
|
+
|
1907
|
+
// if a mustache is an eligible helper but not a definite
|
1908
|
+
// helper, it is ambiguous, and will be resolved in a later
|
1909
|
+
// pass or at runtime.
|
1910
|
+
};
|
1911
|
+
|
1912
|
+
Handlebars.AST.PartialNode = function(id, context) {
|
1913
|
+
this.type = "partial";
|
1914
|
+
|
1915
|
+
// TODO: disallow complex IDs
|
1916
|
+
|
1917
|
+
this.id = id;
|
1918
|
+
this.context = context;
|
1919
|
+
};
|
1920
|
+
|
1921
|
+
var verifyMatch = function(open, close) {
|
1922
|
+
if(open.original !== close.original) {
|
1923
|
+
throw new Handlebars.Exception(open.original + " doesn't match " + close.original);
|
1924
|
+
}
|
1925
|
+
};
|
1926
|
+
|
1927
|
+
Handlebars.AST.BlockNode = function(mustache, program, inverse, close) {
|
1928
|
+
verifyMatch(mustache.id, close);
|
1929
|
+
this.type = "block";
|
1930
|
+
this.mustache = mustache;
|
1931
|
+
this.program = program;
|
1932
|
+
this.inverse = inverse;
|
1933
|
+
|
1934
|
+
if (this.inverse && !this.program) {
|
1935
|
+
this.isInverse = true;
|
1936
|
+
}
|
1937
|
+
};
|
1938
|
+
|
1939
|
+
Handlebars.AST.ContentNode = function(string) {
|
1940
|
+
this.type = "content";
|
1941
|
+
this.string = string;
|
1942
|
+
};
|
1943
|
+
|
1944
|
+
Handlebars.AST.HashNode = function(pairs) {
|
1945
|
+
this.type = "hash";
|
1946
|
+
this.pairs = pairs;
|
1947
|
+
};
|
1948
|
+
|
1949
|
+
Handlebars.AST.IdNode = function(parts) {
|
1950
|
+
this.type = "ID";
|
1951
|
+
this.original = parts.join(".");
|
1952
|
+
|
1953
|
+
var dig = [], depth = 0;
|
1954
|
+
|
1955
|
+
for(var i=0,l=parts.length; i<l; i++) {
|
1956
|
+
var part = parts[i];
|
1957
|
+
|
1958
|
+
if(part === "..") { depth++; }
|
1959
|
+
else if(part === "." || part === "this") { this.isScoped = true; }
|
1960
|
+
else { dig.push(part); }
|
1961
|
+
}
|
1962
|
+
|
1963
|
+
this.parts = dig;
|
1964
|
+
this.string = dig.join('.');
|
1965
|
+
this.depth = depth;
|
1966
|
+
|
1967
|
+
// an ID is simple if it only has one part, and that part is not
|
1968
|
+
// `..` or `this`.
|
1969
|
+
this.isSimple = parts.length === 1 && !this.isScoped && depth === 0;
|
1970
|
+
};
|
1971
|
+
|
1972
|
+
Handlebars.AST.DataNode = function(id) {
|
1973
|
+
this.type = "DATA";
|
1974
|
+
this.id = id;
|
1975
|
+
};
|
1976
|
+
|
1977
|
+
Handlebars.AST.StringNode = function(string) {
|
1978
|
+
this.type = "STRING";
|
1979
|
+
this.string = string;
|
1980
|
+
};
|
1981
|
+
|
1982
|
+
Handlebars.AST.IntegerNode = function(integer) {
|
1983
|
+
this.type = "INTEGER";
|
1984
|
+
this.integer = integer;
|
1985
|
+
};
|
1986
|
+
|
1987
|
+
Handlebars.AST.BooleanNode = function(bool) {
|
1988
|
+
this.type = "BOOLEAN";
|
1989
|
+
this.bool = bool;
|
1990
|
+
};
|
1991
|
+
|
1992
|
+
Handlebars.AST.CommentNode = function(comment) {
|
1993
|
+
this.type = "comment";
|
1994
|
+
this.comment = comment;
|
1995
|
+
};
|
1996
|
+
|
1997
|
+
})();;
|
1998
|
+
// lib/handlebars/utils.js
|
1999
|
+
Handlebars.Exception = function(message) {
|
2000
|
+
var tmp = Error.prototype.constructor.apply(this, arguments);
|
2001
|
+
|
2002
|
+
for (var p in tmp) {
|
2003
|
+
if (tmp.hasOwnProperty(p)) { this[p] = tmp[p]; }
|
2004
|
+
}
|
2005
|
+
|
2006
|
+
this.message = tmp.message;
|
2007
|
+
};
|
2008
|
+
Handlebars.Exception.prototype = new Error();
|
2009
|
+
|
2010
|
+
// Build out our basic SafeString type
|
2011
|
+
Handlebars.SafeString = function(string) {
|
2012
|
+
this.string = string;
|
2013
|
+
};
|
2014
|
+
Handlebars.SafeString.prototype.toString = function() {
|
2015
|
+
return this.string.toString();
|
2016
|
+
};
|
2017
|
+
|
2018
|
+
(function() {
|
2019
|
+
var escape = {
|
2020
|
+
"&": "&",
|
2021
|
+
"<": "<",
|
2022
|
+
">": ">",
|
2023
|
+
'"': """,
|
2024
|
+
"'": "'",
|
2025
|
+
"`": "`"
|
2026
|
+
};
|
2027
|
+
|
2028
|
+
var badChars = /[&<>"'`]/g;
|
2029
|
+
var possible = /[&<>"'`]/;
|
2030
|
+
|
2031
|
+
var escapeChar = function(chr) {
|
2032
|
+
return escape[chr] || "&";
|
2033
|
+
};
|
2034
|
+
|
2035
|
+
Handlebars.Utils = {
|
2036
|
+
escapeExpression: function(string) {
|
2037
|
+
// don't escape SafeStrings, since they're already safe
|
2038
|
+
if (string instanceof Handlebars.SafeString) {
|
2039
|
+
return string.toString();
|
2040
|
+
} else if (string == null || string === false) {
|
2041
|
+
return "";
|
2042
|
+
}
|
2043
|
+
|
2044
|
+
if(!possible.test(string)) { return string; }
|
2045
|
+
return string.replace(badChars, escapeChar);
|
2046
|
+
},
|
2047
|
+
|
2048
|
+
isEmpty: function(value) {
|
2049
|
+
if (typeof value === "undefined") {
|
2050
|
+
return true;
|
2051
|
+
} else if (value === null) {
|
2052
|
+
return true;
|
2053
|
+
} else if (value === false) {
|
2054
|
+
return true;
|
2055
|
+
} else if(Object.prototype.toString.call(value) === "[object Array]" && value.length === 0) {
|
2056
|
+
return true;
|
2057
|
+
} else {
|
2058
|
+
return false;
|
2059
|
+
}
|
2060
|
+
}
|
2061
|
+
};
|
2062
|
+
})();;
|
2063
|
+
// lib/handlebars/compiler/compiler.js
|
2064
|
+
|
2065
|
+
/*jshint eqnull:true*/
|
2066
|
+
Handlebars.Compiler = function() {};
|
2067
|
+
Handlebars.JavaScriptCompiler = function() {};
|
2068
|
+
|
2069
|
+
(function(Compiler, JavaScriptCompiler) {
|
2070
|
+
// the foundHelper register will disambiguate helper lookup from finding a
|
2071
|
+
// function in a context. This is necessary for mustache compatibility, which
|
2072
|
+
// requires that context functions in blocks are evaluated by blockHelperMissing,
|
2073
|
+
// and then proceed as if the resulting value was provided to blockHelperMissing.
|
2074
|
+
|
2075
|
+
Compiler.prototype = {
|
2076
|
+
compiler: Compiler,
|
2077
|
+
|
2078
|
+
disassemble: function() {
|
2079
|
+
var opcodes = this.opcodes, opcode, out = [], params, param;
|
2080
|
+
|
2081
|
+
for (var i=0, l=opcodes.length; i<l; i++) {
|
2082
|
+
opcode = opcodes[i];
|
2083
|
+
|
2084
|
+
if (opcode.opcode === 'DECLARE') {
|
2085
|
+
out.push("DECLARE " + opcode.name + "=" + opcode.value);
|
2086
|
+
} else {
|
2087
|
+
params = [];
|
2088
|
+
for (var j=0; j<opcode.args.length; j++) {
|
2089
|
+
param = opcode.args[j];
|
2090
|
+
if (typeof param === "string") {
|
2091
|
+
param = "\"" + param.replace("\n", "\\n") + "\"";
|
2092
|
+
}
|
2093
|
+
params.push(param);
|
2094
|
+
}
|
2095
|
+
out.push(opcode.opcode + " " + params.join(" "));
|
2096
|
+
}
|
2097
|
+
}
|
2098
|
+
|
2099
|
+
return out.join("\n");
|
2100
|
+
},
|
2101
|
+
|
2102
|
+
guid: 0,
|
2103
|
+
|
2104
|
+
compile: function(program, options) {
|
2105
|
+
this.children = [];
|
2106
|
+
this.depths = {list: []};
|
2107
|
+
this.options = options;
|
2108
|
+
|
2109
|
+
// These changes will propagate to the other compiler components
|
2110
|
+
var knownHelpers = this.options.knownHelpers;
|
2111
|
+
this.options.knownHelpers = {
|
2112
|
+
'helperMissing': true,
|
2113
|
+
'blockHelperMissing': true,
|
2114
|
+
'each': true,
|
2115
|
+
'if': true,
|
2116
|
+
'unless': true,
|
2117
|
+
'with': true,
|
2118
|
+
'log': true
|
2119
|
+
};
|
2120
|
+
if (knownHelpers) {
|
2121
|
+
for (var name in knownHelpers) {
|
2122
|
+
this.options.knownHelpers[name] = knownHelpers[name];
|
2123
|
+
}
|
2124
|
+
}
|
2125
|
+
|
2126
|
+
return this.program(program);
|
2127
|
+
},
|
2128
|
+
|
2129
|
+
accept: function(node) {
|
2130
|
+
return this[node.type](node);
|
2131
|
+
},
|
2132
|
+
|
2133
|
+
program: function(program) {
|
2134
|
+
var statements = program.statements, statement;
|
2135
|
+
this.opcodes = [];
|
2136
|
+
|
2137
|
+
for(var i=0, l=statements.length; i<l; i++) {
|
2138
|
+
statement = statements[i];
|
2139
|
+
this[statement.type](statement);
|
2140
|
+
}
|
2141
|
+
this.isSimple = l === 1;
|
2142
|
+
|
2143
|
+
this.depths.list = this.depths.list.sort(function(a, b) {
|
2144
|
+
return a - b;
|
2145
|
+
});
|
2146
|
+
|
2147
|
+
return this;
|
2148
|
+
},
|
2149
|
+
|
2150
|
+
compileProgram: function(program) {
|
2151
|
+
var result = new this.compiler().compile(program, this.options);
|
2152
|
+
var guid = this.guid++, depth;
|
2153
|
+
|
2154
|
+
this.usePartial = this.usePartial || result.usePartial;
|
2155
|
+
|
2156
|
+
this.children[guid] = result;
|
2157
|
+
|
2158
|
+
for(var i=0, l=result.depths.list.length; i<l; i++) {
|
2159
|
+
depth = result.depths.list[i];
|
2160
|
+
|
2161
|
+
if(depth < 2) { continue; }
|
2162
|
+
else { this.addDepth(depth - 1); }
|
2163
|
+
}
|
2164
|
+
|
2165
|
+
return guid;
|
2166
|
+
},
|
2167
|
+
|
2168
|
+
block: function(block) {
|
2169
|
+
var mustache = block.mustache,
|
2170
|
+
program = block.program,
|
2171
|
+
inverse = block.inverse;
|
2172
|
+
|
2173
|
+
if (program) {
|
2174
|
+
program = this.compileProgram(program);
|
2175
|
+
}
|
2176
|
+
|
2177
|
+
if (inverse) {
|
2178
|
+
inverse = this.compileProgram(inverse);
|
2179
|
+
}
|
2180
|
+
|
2181
|
+
var type = this.classifyMustache(mustache);
|
2182
|
+
|
2183
|
+
if (type === "helper") {
|
2184
|
+
this.helperMustache(mustache, program, inverse);
|
2185
|
+
} else if (type === "simple") {
|
2186
|
+
this.simpleMustache(mustache);
|
2187
|
+
|
2188
|
+
// now that the simple mustache is resolved, we need to
|
2189
|
+
// evaluate it by executing `blockHelperMissing`
|
2190
|
+
this.opcode('pushProgram', program);
|
2191
|
+
this.opcode('pushProgram', inverse);
|
2192
|
+
this.opcode('pushLiteral', '{}');
|
2193
|
+
this.opcode('blockValue');
|
2194
|
+
} else {
|
2195
|
+
this.ambiguousMustache(mustache, program, inverse);
|
2196
|
+
|
2197
|
+
// now that the simple mustache is resolved, we need to
|
2198
|
+
// evaluate it by executing `blockHelperMissing`
|
2199
|
+
this.opcode('pushProgram', program);
|
2200
|
+
this.opcode('pushProgram', inverse);
|
2201
|
+
this.opcode('pushLiteral', '{}');
|
2202
|
+
this.opcode('ambiguousBlockValue');
|
2203
|
+
}
|
2204
|
+
|
2205
|
+
this.opcode('append');
|
2206
|
+
},
|
2207
|
+
|
2208
|
+
hash: function(hash) {
|
2209
|
+
var pairs = hash.pairs, pair, val;
|
2210
|
+
|
2211
|
+
this.opcode('push', '{}');
|
2212
|
+
|
2213
|
+
for(var i=0, l=pairs.length; i<l; i++) {
|
2214
|
+
pair = pairs[i];
|
2215
|
+
val = pair[1];
|
2216
|
+
|
2217
|
+
this.accept(val);
|
2218
|
+
this.opcode('assignToHash', pair[0]);
|
2219
|
+
}
|
2220
|
+
},
|
2221
|
+
|
2222
|
+
partial: function(partial) {
|
2223
|
+
var id = partial.id;
|
2224
|
+
this.usePartial = true;
|
2225
|
+
|
2226
|
+
if(partial.context) {
|
2227
|
+
this.ID(partial.context);
|
2228
|
+
} else {
|
2229
|
+
this.opcode('push', 'depth0');
|
2230
|
+
}
|
2231
|
+
|
2232
|
+
this.opcode('invokePartial', id.original);
|
2233
|
+
this.opcode('append');
|
2234
|
+
},
|
2235
|
+
|
2236
|
+
content: function(content) {
|
2237
|
+
this.opcode('appendContent', content.string);
|
2238
|
+
},
|
2239
|
+
|
2240
|
+
mustache: function(mustache) {
|
2241
|
+
var options = this.options;
|
2242
|
+
var type = this.classifyMustache(mustache);
|
2243
|
+
|
2244
|
+
if (type === "simple") {
|
2245
|
+
this.simpleMustache(mustache);
|
2246
|
+
} else if (type === "helper") {
|
2247
|
+
this.helperMustache(mustache);
|
2248
|
+
} else {
|
2249
|
+
this.ambiguousMustache(mustache);
|
2250
|
+
}
|
2251
|
+
|
2252
|
+
if(mustache.escaped && !options.noEscape) {
|
2253
|
+
this.opcode('appendEscaped');
|
2254
|
+
} else {
|
2255
|
+
this.opcode('append');
|
2256
|
+
}
|
2257
|
+
},
|
2258
|
+
|
2259
|
+
ambiguousMustache: function(mustache, program, inverse) {
|
2260
|
+
var id = mustache.id, name = id.parts[0];
|
2261
|
+
|
2262
|
+
this.opcode('getContext', id.depth);
|
2263
|
+
|
2264
|
+
this.opcode('pushProgram', program);
|
2265
|
+
this.opcode('pushProgram', inverse);
|
2266
|
+
|
2267
|
+
this.opcode('invokeAmbiguous', name);
|
2268
|
+
},
|
2269
|
+
|
2270
|
+
simpleMustache: function(mustache, program, inverse) {
|
2271
|
+
var id = mustache.id;
|
2272
|
+
|
2273
|
+
if (id.type === 'DATA') {
|
2274
|
+
this.DATA(id);
|
2275
|
+
} else if (id.parts.length) {
|
2276
|
+
this.ID(id);
|
2277
|
+
} else {
|
2278
|
+
// Simplified ID for `this`
|
2279
|
+
this.addDepth(id.depth);
|
2280
|
+
this.opcode('getContext', id.depth);
|
2281
|
+
this.opcode('pushContext');
|
2282
|
+
}
|
2283
|
+
|
2284
|
+
this.opcode('resolvePossibleLambda');
|
2285
|
+
},
|
2286
|
+
|
2287
|
+
helperMustache: function(mustache, program, inverse) {
|
2288
|
+
var params = this.setupFullMustacheParams(mustache, program, inverse),
|
2289
|
+
name = mustache.id.parts[0];
|
2290
|
+
|
2291
|
+
if (this.options.knownHelpers[name]) {
|
2292
|
+
this.opcode('invokeKnownHelper', params.length, name);
|
2293
|
+
} else if (this.knownHelpersOnly) {
|
2294
|
+
throw new Error("You specified knownHelpersOnly, but used the unknown helper " + name);
|
2295
|
+
} else {
|
2296
|
+
this.opcode('invokeHelper', params.length, name);
|
2297
|
+
}
|
2298
|
+
},
|
2299
|
+
|
2300
|
+
ID: function(id) {
|
2301
|
+
this.addDepth(id.depth);
|
2302
|
+
this.opcode('getContext', id.depth);
|
2303
|
+
|
2304
|
+
var name = id.parts[0];
|
2305
|
+
if (!name) {
|
2306
|
+
this.opcode('pushContext');
|
2307
|
+
} else {
|
2308
|
+
this.opcode('lookupOnContext', id.parts[0]);
|
2309
|
+
}
|
2310
|
+
|
2311
|
+
for(var i=1, l=id.parts.length; i<l; i++) {
|
2312
|
+
this.opcode('lookup', id.parts[i]);
|
2313
|
+
}
|
2314
|
+
},
|
2315
|
+
|
2316
|
+
DATA: function(data) {
|
2317
|
+
this.options.data = true;
|
2318
|
+
this.opcode('lookupData', data.id);
|
2319
|
+
},
|
2320
|
+
|
2321
|
+
STRING: function(string) {
|
2322
|
+
this.opcode('pushString', string.string);
|
2323
|
+
},
|
2324
|
+
|
2325
|
+
INTEGER: function(integer) {
|
2326
|
+
this.opcode('pushLiteral', integer.integer);
|
2327
|
+
},
|
2328
|
+
|
2329
|
+
BOOLEAN: function(bool) {
|
2330
|
+
this.opcode('pushLiteral', bool.bool);
|
2331
|
+
},
|
2332
|
+
|
2333
|
+
comment: function() {},
|
2334
|
+
|
2335
|
+
// HELPERS
|
2336
|
+
opcode: function(name) {
|
2337
|
+
this.opcodes.push({ opcode: name, args: [].slice.call(arguments, 1) });
|
2338
|
+
},
|
2339
|
+
|
2340
|
+
declare: function(name, value) {
|
2341
|
+
this.opcodes.push({ opcode: 'DECLARE', name: name, value: value });
|
2342
|
+
},
|
2343
|
+
|
2344
|
+
addDepth: function(depth) {
|
2345
|
+
if(isNaN(depth)) { throw new Error("EWOT"); }
|
2346
|
+
if(depth === 0) { return; }
|
2347
|
+
|
2348
|
+
if(!this.depths[depth]) {
|
2349
|
+
this.depths[depth] = true;
|
2350
|
+
this.depths.list.push(depth);
|
2351
|
+
}
|
2352
|
+
},
|
2353
|
+
|
2354
|
+
classifyMustache: function(mustache) {
|
2355
|
+
var isHelper = mustache.isHelper;
|
2356
|
+
var isEligible = mustache.eligibleHelper;
|
2357
|
+
var options = this.options;
|
2358
|
+
|
2359
|
+
// if ambiguous, we can possibly resolve the ambiguity now
|
2360
|
+
if (isEligible && !isHelper) {
|
2361
|
+
var name = mustache.id.parts[0];
|
2362
|
+
|
2363
|
+
if (options.knownHelpers[name]) {
|
2364
|
+
isHelper = true;
|
2365
|
+
} else if (options.knownHelpersOnly) {
|
2366
|
+
isEligible = false;
|
2367
|
+
}
|
2368
|
+
}
|
2369
|
+
|
2370
|
+
if (isHelper) { return "helper"; }
|
2371
|
+
else if (isEligible) { return "ambiguous"; }
|
2372
|
+
else { return "simple"; }
|
2373
|
+
},
|
2374
|
+
|
2375
|
+
pushParams: function(params) {
|
2376
|
+
var i = params.length, param;
|
2377
|
+
|
2378
|
+
while(i--) {
|
2379
|
+
param = params[i];
|
2380
|
+
|
2381
|
+
if(this.options.stringParams) {
|
2382
|
+
if(param.depth) {
|
2383
|
+
this.addDepth(param.depth);
|
2384
|
+
}
|
2385
|
+
|
2386
|
+
this.opcode('getContext', param.depth || 0);
|
2387
|
+
this.opcode('pushStringParam', param.string);
|
2388
|
+
} else {
|
2389
|
+
this[param.type](param);
|
2390
|
+
}
|
2391
|
+
}
|
2392
|
+
},
|
2393
|
+
|
2394
|
+
setupMustacheParams: function(mustache) {
|
2395
|
+
var params = mustache.params;
|
2396
|
+
this.pushParams(params);
|
2397
|
+
|
2398
|
+
if(mustache.hash) {
|
2399
|
+
this.hash(mustache.hash);
|
2400
|
+
} else {
|
2401
|
+
this.opcode('pushLiteral', '{}');
|
2402
|
+
}
|
2403
|
+
|
2404
|
+
return params;
|
2405
|
+
},
|
2406
|
+
|
2407
|
+
// this will replace setupMustacheParams when we're done
|
2408
|
+
setupFullMustacheParams: function(mustache, program, inverse) {
|
2409
|
+
var params = mustache.params;
|
2410
|
+
this.pushParams(params);
|
2411
|
+
|
2412
|
+
this.opcode('pushProgram', program);
|
2413
|
+
this.opcode('pushProgram', inverse);
|
2414
|
+
|
2415
|
+
if(mustache.hash) {
|
2416
|
+
this.hash(mustache.hash);
|
2417
|
+
} else {
|
2418
|
+
this.opcode('pushLiteral', '{}');
|
2419
|
+
}
|
2420
|
+
|
2421
|
+
return params;
|
2422
|
+
}
|
2423
|
+
};
|
2424
|
+
|
2425
|
+
var Literal = function(value) {
|
2426
|
+
this.value = value;
|
2427
|
+
};
|
2428
|
+
|
2429
|
+
JavaScriptCompiler.prototype = {
|
2430
|
+
// PUBLIC API: You can override these methods in a subclass to provide
|
2431
|
+
// alternative compiled forms for name lookup and buffering semantics
|
2432
|
+
nameLookup: function(parent, name, type) {
|
2433
|
+
if (/^[0-9]+$/.test(name)) {
|
2434
|
+
return parent + "[" + name + "]";
|
2435
|
+
} else if (JavaScriptCompiler.isValidJavaScriptVariableName(name)) {
|
2436
|
+
return parent + "." + name;
|
2437
|
+
}
|
2438
|
+
else {
|
2439
|
+
return parent + "['" + name + "']";
|
2440
|
+
}
|
2441
|
+
},
|
2442
|
+
|
2443
|
+
appendToBuffer: function(string) {
|
2444
|
+
if (this.environment.isSimple) {
|
2445
|
+
return "return " + string + ";";
|
2446
|
+
} else {
|
2447
|
+
return "buffer += " + string + ";";
|
2448
|
+
}
|
2449
|
+
},
|
2450
|
+
|
2451
|
+
initializeBuffer: function() {
|
2452
|
+
return this.quotedString("");
|
2453
|
+
},
|
2454
|
+
|
2455
|
+
namespace: "Handlebars",
|
2456
|
+
// END PUBLIC API
|
2457
|
+
|
2458
|
+
compile: function(environment, options, context, asObject) {
|
2459
|
+
this.environment = environment;
|
2460
|
+
this.options = options || {};
|
2461
|
+
|
2462
|
+
Handlebars.log(Handlebars.logger.DEBUG, this.environment.disassemble() + "\n\n");
|
2463
|
+
|
2464
|
+
this.name = this.environment.name;
|
2465
|
+
this.isChild = !!context;
|
2466
|
+
this.context = context || {
|
2467
|
+
programs: [],
|
2468
|
+
aliases: { }
|
2469
|
+
};
|
2470
|
+
|
2471
|
+
this.preamble();
|
2472
|
+
|
2473
|
+
this.stackSlot = 0;
|
2474
|
+
this.stackVars = [];
|
2475
|
+
this.registers = { list: [] };
|
2476
|
+
this.compileStack = [];
|
2477
|
+
|
2478
|
+
this.compileChildren(environment, options);
|
2479
|
+
|
2480
|
+
var opcodes = environment.opcodes, opcode;
|
2481
|
+
|
2482
|
+
this.i = 0;
|
2483
|
+
|
2484
|
+
for(l=opcodes.length; this.i<l; this.i++) {
|
2485
|
+
opcode = opcodes[this.i];
|
2486
|
+
|
2487
|
+
if(opcode.opcode === 'DECLARE') {
|
2488
|
+
this[opcode.name] = opcode.value;
|
2489
|
+
} else {
|
2490
|
+
this[opcode.opcode].apply(this, opcode.args);
|
2491
|
+
}
|
2492
|
+
}
|
2493
|
+
|
2494
|
+
return this.createFunctionContext(asObject);
|
2495
|
+
},
|
2496
|
+
|
2497
|
+
nextOpcode: function() {
|
2498
|
+
var opcodes = this.environment.opcodes, opcode = opcodes[this.i + 1];
|
2499
|
+
return opcodes[this.i + 1];
|
2500
|
+
},
|
2501
|
+
|
2502
|
+
eat: function(opcode) {
|
2503
|
+
this.i = this.i + 1;
|
2504
|
+
},
|
2505
|
+
|
2506
|
+
preamble: function() {
|
2507
|
+
var out = [];
|
2508
|
+
|
2509
|
+
if (!this.isChild) {
|
2510
|
+
var namespace = this.namespace;
|
2511
|
+
var copies = "helpers = helpers || " + namespace + ".helpers;";
|
2512
|
+
if (this.environment.usePartial) { copies = copies + " partials = partials || " + namespace + ".partials;"; }
|
2513
|
+
if (this.options.data) { copies = copies + " data = data || {};"; }
|
2514
|
+
out.push(copies);
|
2515
|
+
} else {
|
2516
|
+
out.push('');
|
2517
|
+
}
|
2518
|
+
|
2519
|
+
if (!this.environment.isSimple) {
|
2520
|
+
out.push(", buffer = " + this.initializeBuffer());
|
2521
|
+
} else {
|
2522
|
+
out.push("");
|
2523
|
+
}
|
2524
|
+
|
2525
|
+
// track the last context pushed into place to allow skipping the
|
2526
|
+
// getContext opcode when it would be a noop
|
2527
|
+
this.lastContext = 0;
|
2528
|
+
this.source = out;
|
2529
|
+
},
|
2530
|
+
|
2531
|
+
createFunctionContext: function(asObject) {
|
2532
|
+
var locals = this.stackVars.concat(this.registers.list);
|
2533
|
+
|
2534
|
+
if(locals.length > 0) {
|
2535
|
+
this.source[1] = this.source[1] + ", " + locals.join(", ");
|
2536
|
+
}
|
2537
|
+
|
2538
|
+
// Generate minimizer alias mappings
|
2539
|
+
if (!this.isChild) {
|
2540
|
+
var aliases = [];
|
2541
|
+
for (var alias in this.context.aliases) {
|
2542
|
+
this.source[1] = this.source[1] + ', ' + alias + '=' + this.context.aliases[alias];
|
2543
|
+
}
|
2544
|
+
}
|
2545
|
+
|
2546
|
+
if (this.source[1]) {
|
2547
|
+
this.source[1] = "var " + this.source[1].substring(2) + ";";
|
2548
|
+
}
|
2549
|
+
|
2550
|
+
// Merge children
|
2551
|
+
if (!this.isChild) {
|
2552
|
+
this.source[1] += '\n' + this.context.programs.join('\n') + '\n';
|
2553
|
+
}
|
2554
|
+
|
2555
|
+
if (!this.environment.isSimple) {
|
2556
|
+
this.source.push("return buffer;");
|
2557
|
+
}
|
2558
|
+
|
2559
|
+
var params = this.isChild ? ["depth0", "data"] : ["Handlebars", "depth0", "helpers", "partials", "data"];
|
2560
|
+
|
2561
|
+
for(var i=0, l=this.environment.depths.list.length; i<l; i++) {
|
2562
|
+
params.push("depth" + this.environment.depths.list[i]);
|
2563
|
+
}
|
2564
|
+
|
2565
|
+
if (asObject) {
|
2566
|
+
params.push(this.source.join("\n "));
|
2567
|
+
|
2568
|
+
return Function.apply(this, params);
|
2569
|
+
} else {
|
2570
|
+
var functionSource = 'function ' + (this.name || '') + '(' + params.join(',') + ') {\n ' + this.source.join("\n ") + '}';
|
2571
|
+
Handlebars.log(Handlebars.logger.DEBUG, functionSource + "\n\n");
|
2572
|
+
return functionSource;
|
2573
|
+
}
|
2574
|
+
},
|
2575
|
+
|
2576
|
+
// [blockValue]
|
2577
|
+
//
|
2578
|
+
// On stack, before: hash, inverse, program, value
|
2579
|
+
// On stack, after: return value of blockHelperMissing
|
2580
|
+
//
|
2581
|
+
// The purpose of this opcode is to take a block of the form
|
2582
|
+
// `{{#foo}}...{{/foo}}`, resolve the value of `foo`, and
|
2583
|
+
// replace it on the stack with the result of properly
|
2584
|
+
// invoking blockHelperMissing.
|
2585
|
+
blockValue: function() {
|
2586
|
+
this.context.aliases.blockHelperMissing = 'helpers.blockHelperMissing';
|
2587
|
+
|
2588
|
+
var params = ["depth0"];
|
2589
|
+
this.setupParams(0, params);
|
2590
|
+
|
2591
|
+
this.replaceStack(function(current) {
|
2592
|
+
params.splice(1, 0, current);
|
2593
|
+
return current + " = blockHelperMissing.call(" + params.join(", ") + ")";
|
2594
|
+
});
|
2595
|
+
},
|
2596
|
+
|
2597
|
+
// [ambiguousBlockValue]
|
2598
|
+
//
|
2599
|
+
// On stack, before: hash, inverse, program, value
|
2600
|
+
// Compiler value, before: lastHelper=value of last found helper, if any
|
2601
|
+
// On stack, after, if no lastHelper: same as [blockValue]
|
2602
|
+
// On stack, after, if lastHelper: value
|
2603
|
+
ambiguousBlockValue: function() {
|
2604
|
+
this.context.aliases.blockHelperMissing = 'helpers.blockHelperMissing';
|
2605
|
+
|
2606
|
+
var params = ["depth0"];
|
2607
|
+
this.setupParams(0, params);
|
2608
|
+
|
2609
|
+
var current = this.topStack();
|
2610
|
+
params.splice(1, 0, current);
|
2611
|
+
|
2612
|
+
this.source.push("if (!" + this.lastHelper + ") { " + current + " = blockHelperMissing.call(" + params.join(", ") + "); }");
|
2613
|
+
},
|
2614
|
+
|
2615
|
+
// [appendContent]
|
2616
|
+
//
|
2617
|
+
// On stack, before: ...
|
2618
|
+
// On stack, after: ...
|
2619
|
+
//
|
2620
|
+
// Appends the string value of `content` to the current buffer
|
2621
|
+
appendContent: function(content) {
|
2622
|
+
this.source.push(this.appendToBuffer(this.quotedString(content)));
|
2623
|
+
},
|
2624
|
+
|
2625
|
+
// [append]
|
2626
|
+
//
|
2627
|
+
// On stack, before: value, ...
|
2628
|
+
// On stack, after: ...
|
2629
|
+
//
|
2630
|
+
// Coerces `value` to a String and appends it to the current buffer.
|
2631
|
+
//
|
2632
|
+
// If `value` is truthy, or 0, it is coerced into a string and appended
|
2633
|
+
// Otherwise, the empty string is appended
|
2634
|
+
append: function() {
|
2635
|
+
var local = this.popStack();
|
2636
|
+
this.source.push("if(" + local + " || " + local + " === 0) { " + this.appendToBuffer(local) + " }");
|
2637
|
+
if (this.environment.isSimple) {
|
2638
|
+
this.source.push("else { " + this.appendToBuffer("''") + " }");
|
2639
|
+
}
|
2640
|
+
},
|
2641
|
+
|
2642
|
+
// [appendEscaped]
|
2643
|
+
//
|
2644
|
+
// On stack, before: value, ...
|
2645
|
+
// On stack, after: ...
|
2646
|
+
//
|
2647
|
+
// Escape `value` and append it to the buffer
|
2648
|
+
appendEscaped: function() {
|
2649
|
+
var opcode = this.nextOpcode(), extra = "";
|
2650
|
+
this.context.aliases.escapeExpression = 'this.escapeExpression';
|
2651
|
+
|
2652
|
+
if(opcode && opcode.opcode === 'appendContent') {
|
2653
|
+
extra = " + " + this.quotedString(opcode.args[0]);
|
2654
|
+
this.eat(opcode);
|
2655
|
+
}
|
2656
|
+
|
2657
|
+
this.source.push(this.appendToBuffer("escapeExpression(" + this.popStack() + ")" + extra));
|
2658
|
+
},
|
2659
|
+
|
2660
|
+
// [getContext]
|
2661
|
+
//
|
2662
|
+
// On stack, before: ...
|
2663
|
+
// On stack, after: ...
|
2664
|
+
// Compiler value, after: lastContext=depth
|
2665
|
+
//
|
2666
|
+
// Set the value of the `lastContext` compiler value to the depth
|
2667
|
+
getContext: function(depth) {
|
2668
|
+
if(this.lastContext !== depth) {
|
2669
|
+
this.lastContext = depth;
|
2670
|
+
}
|
2671
|
+
},
|
2672
|
+
|
2673
|
+
// [lookupOnContext]
|
2674
|
+
//
|
2675
|
+
// On stack, before: ...
|
2676
|
+
// On stack, after: currentContext[name], ...
|
2677
|
+
//
|
2678
|
+
// Looks up the value of `name` on the current context and pushes
|
2679
|
+
// it onto the stack.
|
2680
|
+
lookupOnContext: function(name) {
|
2681
|
+
this.pushStack(this.nameLookup('depth' + this.lastContext, name, 'context'));
|
2682
|
+
},
|
2683
|
+
|
2684
|
+
// [pushContext]
|
2685
|
+
//
|
2686
|
+
// On stack, before: ...
|
2687
|
+
// On stack, after: currentContext, ...
|
2688
|
+
//
|
2689
|
+
// Pushes the value of the current context onto the stack.
|
2690
|
+
pushContext: function() {
|
2691
|
+
this.pushStackLiteral('depth' + this.lastContext);
|
2692
|
+
},
|
2693
|
+
|
2694
|
+
// [resolvePossibleLambda]
|
2695
|
+
//
|
2696
|
+
// On stack, before: value, ...
|
2697
|
+
// On stack, after: resolved value, ...
|
2698
|
+
//
|
2699
|
+
// If the `value` is a lambda, replace it on the stack by
|
2700
|
+
// the return value of the lambda
|
2701
|
+
resolvePossibleLambda: function() {
|
2702
|
+
this.context.aliases.functionType = '"function"';
|
2703
|
+
|
2704
|
+
this.replaceStack(function(current) {
|
2705
|
+
return "typeof " + current + " === functionType ? " + current + "() : " + current;
|
2706
|
+
});
|
2707
|
+
},
|
2708
|
+
|
2709
|
+
// [lookup]
|
2710
|
+
//
|
2711
|
+
// On stack, before: value, ...
|
2712
|
+
// On stack, after: value[name], ...
|
2713
|
+
//
|
2714
|
+
// Replace the value on the stack with the result of looking
|
2715
|
+
// up `name` on `value`
|
2716
|
+
lookup: function(name) {
|
2717
|
+
this.replaceStack(function(current) {
|
2718
|
+
return current + " == null || " + current + " === false ? " + current + " : " + this.nameLookup(current, name, 'context');
|
2719
|
+
});
|
2720
|
+
},
|
2721
|
+
|
2722
|
+
// [lookupData]
|
2723
|
+
//
|
2724
|
+
// On stack, before: ...
|
2725
|
+
// On stack, after: data[id], ...
|
2726
|
+
//
|
2727
|
+
// Push the result of looking up `id` on the current data
|
2728
|
+
lookupData: function(id) {
|
2729
|
+
this.pushStack(this.nameLookup('data', id, 'data'));
|
2730
|
+
},
|
2731
|
+
|
2732
|
+
// [pushStringParam]
|
2733
|
+
//
|
2734
|
+
// On stack, before: ...
|
2735
|
+
// On stack, after: string, currentContext, ...
|
2736
|
+
//
|
2737
|
+
// This opcode is designed for use in string mode, which
|
2738
|
+
// provides the string value of a parameter along with its
|
2739
|
+
// depth rather than resolving it immediately.
|
2740
|
+
pushStringParam: function(string) {
|
2741
|
+
this.pushStackLiteral('depth' + this.lastContext);
|
2742
|
+
this.pushString(string);
|
2743
|
+
},
|
2744
|
+
|
2745
|
+
// [pushString]
|
2746
|
+
//
|
2747
|
+
// On stack, before: ...
|
2748
|
+
// On stack, after: quotedString(string), ...
|
2749
|
+
//
|
2750
|
+
// Push a quoted version of `string` onto the stack
|
2751
|
+
pushString: function(string) {
|
2752
|
+
this.pushStackLiteral(this.quotedString(string));
|
2753
|
+
},
|
2754
|
+
|
2755
|
+
// [push]
|
2756
|
+
//
|
2757
|
+
// On stack, before: ...
|
2758
|
+
// On stack, after: expr, ...
|
2759
|
+
//
|
2760
|
+
// Push an expression onto the stack
|
2761
|
+
push: function(expr) {
|
2762
|
+
this.pushStack(expr);
|
2763
|
+
},
|
2764
|
+
|
2765
|
+
// [pushLiteral]
|
2766
|
+
//
|
2767
|
+
// On stack, before: ...
|
2768
|
+
// On stack, after: value, ...
|
2769
|
+
//
|
2770
|
+
// Pushes a value onto the stack. This operation prevents
|
2771
|
+
// the compiler from creating a temporary variable to hold
|
2772
|
+
// it.
|
2773
|
+
pushLiteral: function(value) {
|
2774
|
+
this.pushStackLiteral(value);
|
2775
|
+
},
|
2776
|
+
|
2777
|
+
// [pushProgram]
|
2778
|
+
//
|
2779
|
+
// On stack, before: ...
|
2780
|
+
// On stack, after: program(guid), ...
|
2781
|
+
//
|
2782
|
+
// Push a program expression onto the stack. This takes
|
2783
|
+
// a compile-time guid and converts it into a runtime-accessible
|
2784
|
+
// expression.
|
2785
|
+
pushProgram: function(guid) {
|
2786
|
+
if (guid != null) {
|
2787
|
+
this.pushStackLiteral(this.programExpression(guid));
|
2788
|
+
} else {
|
2789
|
+
this.pushStackLiteral(null);
|
2790
|
+
}
|
2791
|
+
},
|
2792
|
+
|
2793
|
+
// [invokeHelper]
|
2794
|
+
//
|
2795
|
+
// On stack, before: hash, inverse, program, params..., ...
|
2796
|
+
// On stack, after: result of helper invocation
|
2797
|
+
//
|
2798
|
+
// Pops off the helper's parameters, invokes the helper,
|
2799
|
+
// and pushes the helper's return value onto the stack.
|
2800
|
+
//
|
2801
|
+
// If the helper is not found, `helperMissing` is called.
|
2802
|
+
invokeHelper: function(paramSize, name) {
|
2803
|
+
this.context.aliases.helperMissing = 'helpers.helperMissing';
|
2804
|
+
|
2805
|
+
var helper = this.lastHelper = this.setupHelper(paramSize, name);
|
2806
|
+
this.register('foundHelper', helper.name);
|
2807
|
+
|
2808
|
+
this.pushStack("foundHelper ? foundHelper.call(" +
|
2809
|
+
helper.callParams + ") " + ": helperMissing.call(" +
|
2810
|
+
helper.helperMissingParams + ")");
|
2811
|
+
},
|
2812
|
+
|
2813
|
+
// [invokeKnownHelper]
|
2814
|
+
//
|
2815
|
+
// On stack, before: hash, inverse, program, params..., ...
|
2816
|
+
// On stack, after: result of helper invocation
|
2817
|
+
//
|
2818
|
+
// This operation is used when the helper is known to exist,
|
2819
|
+
// so a `helperMissing` fallback is not required.
|
2820
|
+
invokeKnownHelper: function(paramSize, name) {
|
2821
|
+
var helper = this.setupHelper(paramSize, name);
|
2822
|
+
this.pushStack(helper.name + ".call(" + helper.callParams + ")");
|
2823
|
+
},
|
2824
|
+
|
2825
|
+
// [invokeAmbiguous]
|
2826
|
+
//
|
2827
|
+
// On stack, before: hash, inverse, program, params..., ...
|
2828
|
+
// On stack, after: result of disambiguation
|
2829
|
+
//
|
2830
|
+
// This operation is used when an expression like `{{foo}}`
|
2831
|
+
// is provided, but we don't know at compile-time whether it
|
2832
|
+
// is a helper or a path.
|
2833
|
+
//
|
2834
|
+
// This operation emits more code than the other options,
|
2835
|
+
// and can be avoided by passing the `knownHelpers` and
|
2836
|
+
// `knownHelpersOnly` flags at compile-time.
|
2837
|
+
invokeAmbiguous: function(name) {
|
2838
|
+
this.context.aliases.functionType = '"function"';
|
2839
|
+
|
2840
|
+
this.pushStackLiteral('{}');
|
2841
|
+
var helper = this.setupHelper(0, name);
|
2842
|
+
|
2843
|
+
var helperName = this.lastHelper = this.nameLookup('helpers', name, 'helper');
|
2844
|
+
this.register('foundHelper', helperName);
|
2845
|
+
|
2846
|
+
var nonHelper = this.nameLookup('depth' + this.lastContext, name, 'context');
|
2847
|
+
var nextStack = this.nextStack();
|
2848
|
+
|
2849
|
+
this.source.push('if (foundHelper) { ' + nextStack + ' = foundHelper.call(' + helper.callParams + '); }');
|
2850
|
+
this.source.push('else { ' + nextStack + ' = ' + nonHelper + '; ' + nextStack + ' = typeof ' + nextStack + ' === functionType ? ' + nextStack + '() : ' + nextStack + '; }');
|
2851
|
+
},
|
2852
|
+
|
2853
|
+
// [invokePartial]
|
2854
|
+
//
|
2855
|
+
// On stack, before: context, ...
|
2856
|
+
// On stack after: result of partial invocation
|
2857
|
+
//
|
2858
|
+
// This operation pops off a context, invokes a partial with that context,
|
2859
|
+
// and pushes the result of the invocation back.
|
2860
|
+
invokePartial: function(name) {
|
2861
|
+
var params = [this.nameLookup('partials', name, 'partial'), "'" + name + "'", this.popStack(), "helpers", "partials"];
|
2862
|
+
|
2863
|
+
if (this.options.data) {
|
2864
|
+
params.push("data");
|
2865
|
+
}
|
2866
|
+
|
2867
|
+
this.context.aliases.self = "this";
|
2868
|
+
this.pushStack("self.invokePartial(" + params.join(", ") + ");");
|
2869
|
+
},
|
2870
|
+
|
2871
|
+
// [assignToHash]
|
2872
|
+
//
|
2873
|
+
// On stack, before: value, hash, ...
|
2874
|
+
// On stack, after: hash, ...
|
2875
|
+
//
|
2876
|
+
// Pops a value and hash off the stack, assigns `hash[key] = value`
|
2877
|
+
// and pushes the hash back onto the stack.
|
2878
|
+
assignToHash: function(key) {
|
2879
|
+
var value = this.popStack();
|
2880
|
+
var hash = this.topStack();
|
2881
|
+
|
2882
|
+
this.source.push(hash + "['" + key + "'] = " + value + ";");
|
2883
|
+
},
|
2884
|
+
|
2885
|
+
// HELPERS
|
2886
|
+
|
2887
|
+
compiler: JavaScriptCompiler,
|
2888
|
+
|
2889
|
+
compileChildren: function(environment, options) {
|
2890
|
+
var children = environment.children, child, compiler;
|
2891
|
+
|
2892
|
+
for(var i=0, l=children.length; i<l; i++) {
|
2893
|
+
child = children[i];
|
2894
|
+
compiler = new this.compiler();
|
2895
|
+
|
2896
|
+
this.context.programs.push(''); // Placeholder to prevent name conflicts for nested children
|
2897
|
+
var index = this.context.programs.length;
|
2898
|
+
child.index = index;
|
2899
|
+
child.name = 'program' + index;
|
2900
|
+
this.context.programs[index] = compiler.compile(child, options, this.context);
|
2901
|
+
}
|
2902
|
+
},
|
2903
|
+
|
2904
|
+
programExpression: function(guid) {
|
2905
|
+
this.context.aliases.self = "this";
|
2906
|
+
|
2907
|
+
if(guid == null) {
|
2908
|
+
return "self.noop";
|
2909
|
+
}
|
2910
|
+
|
2911
|
+
var child = this.environment.children[guid],
|
2912
|
+
depths = child.depths.list, depth;
|
2913
|
+
|
2914
|
+
var programParams = [child.index, child.name, "data"];
|
2915
|
+
|
2916
|
+
for(var i=0, l = depths.length; i<l; i++) {
|
2917
|
+
depth = depths[i];
|
2918
|
+
|
2919
|
+
if(depth === 1) { programParams.push("depth0"); }
|
2920
|
+
else { programParams.push("depth" + (depth - 1)); }
|
2921
|
+
}
|
2922
|
+
|
2923
|
+
if(depths.length === 0) {
|
2924
|
+
return "self.program(" + programParams.join(", ") + ")";
|
2925
|
+
} else {
|
2926
|
+
programParams.shift();
|
2927
|
+
return "self.programWithDepth(" + programParams.join(", ") + ")";
|
2928
|
+
}
|
2929
|
+
},
|
2930
|
+
|
2931
|
+
register: function(name, val) {
|
2932
|
+
this.useRegister(name);
|
2933
|
+
this.source.push(name + " = " + val + ";");
|
2934
|
+
},
|
2935
|
+
|
2936
|
+
useRegister: function(name) {
|
2937
|
+
if(!this.registers[name]) {
|
2938
|
+
this.registers[name] = true;
|
2939
|
+
this.registers.list.push(name);
|
2940
|
+
}
|
2941
|
+
},
|
2942
|
+
|
2943
|
+
pushStackLiteral: function(item) {
|
2944
|
+
this.compileStack.push(new Literal(item));
|
2945
|
+
return item;
|
2946
|
+
},
|
2947
|
+
|
2948
|
+
pushStack: function(item) {
|
2949
|
+
this.source.push(this.incrStack() + " = " + item + ";");
|
2950
|
+
this.compileStack.push("stack" + this.stackSlot);
|
2951
|
+
return "stack" + this.stackSlot;
|
2952
|
+
},
|
2953
|
+
|
2954
|
+
replaceStack: function(callback) {
|
2955
|
+
var item = callback.call(this, this.topStack());
|
2956
|
+
|
2957
|
+
this.source.push(this.topStack() + " = " + item + ";");
|
2958
|
+
return "stack" + this.stackSlot;
|
2959
|
+
},
|
2960
|
+
|
2961
|
+
nextStack: function(skipCompileStack) {
|
2962
|
+
var name = this.incrStack();
|
2963
|
+
this.compileStack.push("stack" + this.stackSlot);
|
2964
|
+
return name;
|
2965
|
+
},
|
2966
|
+
|
2967
|
+
incrStack: function() {
|
2968
|
+
this.stackSlot++;
|
2969
|
+
if(this.stackSlot > this.stackVars.length) { this.stackVars.push("stack" + this.stackSlot); }
|
2970
|
+
return "stack" + this.stackSlot;
|
2971
|
+
},
|
2972
|
+
|
2973
|
+
popStack: function() {
|
2974
|
+
var item = this.compileStack.pop();
|
2975
|
+
|
2976
|
+
if (item instanceof Literal) {
|
2977
|
+
return item.value;
|
2978
|
+
} else {
|
2979
|
+
this.stackSlot--;
|
2980
|
+
return item;
|
2981
|
+
}
|
2982
|
+
},
|
2983
|
+
|
2984
|
+
topStack: function() {
|
2985
|
+
var item = this.compileStack[this.compileStack.length - 1];
|
2986
|
+
|
2987
|
+
if (item instanceof Literal) {
|
2988
|
+
return item.value;
|
2989
|
+
} else {
|
2990
|
+
return item;
|
2991
|
+
}
|
2992
|
+
},
|
2993
|
+
|
2994
|
+
quotedString: function(str) {
|
2995
|
+
return '"' + str
|
2996
|
+
.replace(/\\/g, '\\\\')
|
2997
|
+
.replace(/"/g, '\\"')
|
2998
|
+
.replace(/\n/g, '\\n')
|
2999
|
+
.replace(/\r/g, '\\r') + '"';
|
3000
|
+
},
|
3001
|
+
|
3002
|
+
setupHelper: function(paramSize, name) {
|
3003
|
+
var params = [];
|
3004
|
+
this.setupParams(paramSize, params);
|
3005
|
+
var foundHelper = this.nameLookup('helpers', name, 'helper');
|
3006
|
+
|
3007
|
+
return {
|
3008
|
+
params: params,
|
3009
|
+
name: foundHelper,
|
3010
|
+
callParams: ["depth0"].concat(params).join(", "),
|
3011
|
+
helperMissingParams: ["depth0", this.quotedString(name)].concat(params).join(", ")
|
3012
|
+
};
|
3013
|
+
},
|
3014
|
+
|
3015
|
+
// the params and contexts arguments are passed in arrays
|
3016
|
+
// to fill in
|
3017
|
+
setupParams: function(paramSize, params) {
|
3018
|
+
var options = [], contexts = [], param, inverse, program;
|
3019
|
+
|
3020
|
+
options.push("hash:" + this.popStack());
|
3021
|
+
|
3022
|
+
inverse = this.popStack();
|
3023
|
+
program = this.popStack();
|
3024
|
+
|
3025
|
+
// Avoid setting fn and inverse if neither are set. This allows
|
3026
|
+
// helpers to do a check for `if (options.fn)`
|
3027
|
+
if (program || inverse) {
|
3028
|
+
if (!program) {
|
3029
|
+
this.context.aliases.self = "this";
|
3030
|
+
program = "self.noop";
|
3031
|
+
}
|
3032
|
+
|
3033
|
+
if (!inverse) {
|
3034
|
+
this.context.aliases.self = "this";
|
3035
|
+
inverse = "self.noop";
|
3036
|
+
}
|
3037
|
+
|
3038
|
+
options.push("inverse:" + inverse);
|
3039
|
+
options.push("fn:" + program);
|
3040
|
+
}
|
3041
|
+
|
3042
|
+
for(var i=0; i<paramSize; i++) {
|
3043
|
+
param = this.popStack();
|
3044
|
+
params.push(param);
|
3045
|
+
|
3046
|
+
if(this.options.stringParams) {
|
3047
|
+
contexts.push(this.popStack());
|
3048
|
+
}
|
3049
|
+
}
|
3050
|
+
|
3051
|
+
if (this.options.stringParams) {
|
3052
|
+
options.push("contexts:[" + contexts.join(",") + "]");
|
3053
|
+
}
|
3054
|
+
|
3055
|
+
if(this.options.data) {
|
3056
|
+
options.push("data:data");
|
3057
|
+
}
|
3058
|
+
|
3059
|
+
params.push("{" + options.join(",") + "}");
|
3060
|
+
return params.join(", ");
|
3061
|
+
}
|
3062
|
+
};
|
3063
|
+
|
3064
|
+
var reservedWords = (
|
3065
|
+
"break else new var" +
|
3066
|
+
" case finally return void" +
|
3067
|
+
" catch for switch while" +
|
3068
|
+
" continue function this with" +
|
3069
|
+
" default if throw" +
|
3070
|
+
" delete in try" +
|
3071
|
+
" do instanceof typeof" +
|
3072
|
+
" abstract enum int short" +
|
3073
|
+
" boolean export interface static" +
|
3074
|
+
" byte extends long super" +
|
3075
|
+
" char final native synchronized" +
|
3076
|
+
" class float package throws" +
|
3077
|
+
" const goto private transient" +
|
3078
|
+
" debugger implements protected volatile" +
|
3079
|
+
" double import public let yield"
|
3080
|
+
).split(" ");
|
3081
|
+
|
3082
|
+
var compilerWords = JavaScriptCompiler.RESERVED_WORDS = {};
|
3083
|
+
|
3084
|
+
for(var i=0, l=reservedWords.length; i<l; i++) {
|
3085
|
+
compilerWords[reservedWords[i]] = true;
|
3086
|
+
}
|
3087
|
+
|
3088
|
+
JavaScriptCompiler.isValidJavaScriptVariableName = function(name) {
|
3089
|
+
if(!JavaScriptCompiler.RESERVED_WORDS[name] && /^[a-zA-Z_$][0-9a-zA-Z_$]+$/.test(name)) {
|
3090
|
+
return true;
|
3091
|
+
}
|
3092
|
+
return false;
|
3093
|
+
};
|
3094
|
+
|
3095
|
+
})(Handlebars.Compiler, Handlebars.JavaScriptCompiler);
|
3096
|
+
|
3097
|
+
Handlebars.precompile = function(string, options) {
|
3098
|
+
options = options || {};
|
3099
|
+
|
3100
|
+
var ast = Handlebars.parse(string);
|
3101
|
+
var environment = new Handlebars.Compiler().compile(ast, options);
|
3102
|
+
return new Handlebars.JavaScriptCompiler().compile(environment, options);
|
3103
|
+
};
|
3104
|
+
|
3105
|
+
Handlebars.compile = function(string, options) {
|
3106
|
+
options = options || {};
|
3107
|
+
|
3108
|
+
var compiled;
|
3109
|
+
function compile() {
|
3110
|
+
var ast = Handlebars.parse(string);
|
3111
|
+
var environment = new Handlebars.Compiler().compile(ast, options);
|
3112
|
+
var templateSpec = new Handlebars.JavaScriptCompiler().compile(environment, options, undefined, true);
|
3113
|
+
return Handlebars.template(templateSpec);
|
3114
|
+
}
|
3115
|
+
|
3116
|
+
// Template is only compiled on first use and cached after that point.
|
3117
|
+
return function(context, options) {
|
3118
|
+
if (!compiled) {
|
3119
|
+
compiled = compile();
|
3120
|
+
}
|
3121
|
+
return compiled.call(this, context, options);
|
3122
|
+
};
|
3123
|
+
};
|
3124
|
+
;
|
3125
|
+
// lib/handlebars/runtime.js
|
3126
|
+
Handlebars.VM = {
|
3127
|
+
template: function(templateSpec) {
|
3128
|
+
// Just add water
|
3129
|
+
var container = {
|
3130
|
+
escapeExpression: Handlebars.Utils.escapeExpression,
|
3131
|
+
invokePartial: Handlebars.VM.invokePartial,
|
3132
|
+
programs: [],
|
3133
|
+
program: function(i, fn, data) {
|
3134
|
+
var programWrapper = this.programs[i];
|
3135
|
+
if(data) {
|
3136
|
+
return Handlebars.VM.program(fn, data);
|
3137
|
+
} else if(programWrapper) {
|
3138
|
+
return programWrapper;
|
3139
|
+
} else {
|
3140
|
+
programWrapper = this.programs[i] = Handlebars.VM.program(fn);
|
3141
|
+
return programWrapper;
|
3142
|
+
}
|
3143
|
+
},
|
3144
|
+
programWithDepth: Handlebars.VM.programWithDepth,
|
3145
|
+
noop: Handlebars.VM.noop
|
3146
|
+
};
|
3147
|
+
|
3148
|
+
return function(context, options) {
|
3149
|
+
options = options || {};
|
3150
|
+
return templateSpec.call(container, Handlebars, context, options.helpers, options.partials, options.data);
|
3151
|
+
};
|
3152
|
+
},
|
3153
|
+
|
3154
|
+
programWithDepth: function(fn, data, $depth) {
|
3155
|
+
var args = Array.prototype.slice.call(arguments, 2);
|
3156
|
+
|
3157
|
+
return function(context, options) {
|
3158
|
+
options = options || {};
|
3159
|
+
|
3160
|
+
return fn.apply(this, [context, options.data || data].concat(args));
|
3161
|
+
};
|
3162
|
+
},
|
3163
|
+
program: function(fn, data) {
|
3164
|
+
return function(context, options) {
|
3165
|
+
options = options || {};
|
3166
|
+
|
3167
|
+
return fn(context, options.data || data);
|
3168
|
+
};
|
3169
|
+
},
|
3170
|
+
noop: function() { return ""; },
|
3171
|
+
invokePartial: function(partial, name, context, helpers, partials, data) {
|
3172
|
+
var options = { helpers: helpers, partials: partials, data: data };
|
3173
|
+
|
3174
|
+
if(partial === undefined) {
|
3175
|
+
throw new Handlebars.Exception("The partial " + name + " could not be found");
|
3176
|
+
} else if(partial instanceof Function) {
|
3177
|
+
return partial(context, options);
|
3178
|
+
} else if (!Handlebars.compile) {
|
3179
|
+
throw new Handlebars.Exception("The partial " + name + " could not be compiled when running in runtime-only mode");
|
3180
|
+
} else {
|
3181
|
+
partials[name] = Handlebars.compile(partial, {data: data !== undefined});
|
3182
|
+
return partials[name](context, options);
|
3183
|
+
}
|
3184
|
+
}
|
3185
|
+
};
|
3186
|
+
|
3187
|
+
Handlebars.template = Handlebars.VM.template;
|
3188
|
+
;
|
3189
|
+
/*
|
3190
|
+
Swagger UI
|
3191
|
+
*/
|
3192
|
+
$(function(){$.fn.vAlign=function(){return this.each(function(c){var a=$(this).height();var d=$(this).parent().height();var b=(d-a)/2;$(this).css("margin-top",b)})};$.fn.stretchFormtasticInputWidthToParent=function(){return this.each(function(b){var d=$(this).closest("form").innerWidth();var c=parseInt($(this).closest("form").css("padding-left"),10)+parseInt($(this).closest("form").css("padding-right"),10);var a=parseInt($(this).css("padding-left"),10)+parseInt($(this).css("padding-right"),10);$(this).css("width",d-c-a)})};$("form.formtastic li.string input, form.formtastic textarea").stretchFormtasticInputWidthToParent();$("ul.downplayed li div.content p").vAlign();$("form.sandbox").submit(function(){var a=true;$(this).find("input.required").each(function(){$(this).removeClass("error");if($(this).val()==""){$(this).addClass("error");$(this).wiggle();a=false}});return a})});function clippyCopiedCallback(b){$("#api_key_copied").fadeIn().delay(1000).fadeOut()}function log(){if(window.console){console.log.apply(console,arguments)}}if(Function.prototype.bind&&console&&typeof console.log=="object"){["log","info","warn","error","assert","dir","clear","profile","profileEnd"].forEach(function(a){console[a]=this.bind(console[a],console)},Function.prototype.call)}var Docs={shebang:function(){var b=$.param.fragment().split("/");b.shift();switch(b.length){case 1:var d="resource_"+b[0];Docs.expandEndpointListForResource(b[0]);$("#"+d).slideto({highlight:false});break;case 2:Docs.expandEndpointListForResource(b[0]);$("#"+d).slideto({highlight:false});var c=b.join("_");var a=c+"_content";Docs.expandOperation($("#"+a));$("#"+c).slideto({highlight:false});break}},toggleEndpointListForResource:function(b){var a=$("li#resource_"+Docs.escapeResourceName(b)+" ul.endpoints");if(a.is(":visible")){Docs.collapseEndpointListForResource(b)}else{Docs.expandEndpointListForResource(b)}},expandEndpointListForResource:function(b){var b=Docs.escapeResourceName(b);if(b==""){$(".resource ul.endpoints").slideDown();return}$("li#resource_"+b).addClass("active");var a=$("li#resource_"+b+" ul.endpoints");a.slideDown()},collapseEndpointListForResource:function(b){var b=Docs.escapeResourceName(b);$("li#resource_"+b).removeClass("active");var a=$("li#resource_"+b+" ul.endpoints");a.slideUp()},expandOperationsForResource:function(a){Docs.expandEndpointListForResource(a);if(a==""){$(".resource ul.endpoints li.operation div.content").slideDown();return}$("li#resource_"+Docs.escapeResourceName(a)+" li.operation div.content").each(function(){Docs.expandOperation($(this))})},collapseOperationsForResource:function(a){Docs.expandEndpointListForResource(a);$("li#resource_"+Docs.escapeResourceName(a)+" li.operation div.content").each(function(){Docs.collapseOperation($(this))})},escapeResourceName:function(a){return a.replace(/[!"#$%&'()*+,.\/:;<=>?@\[\\\]\^`{|}~]/g,"\\$&")},expandOperation:function(a){a.slideDown()},collapseOperation:function(a){a.slideUp()}};(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.content_type=b(function(g,p,f,n,m){f=f||g.helpers;var l="",c,s,k,j,q=this,h="function",o=f.helperMissing,i=void 0;function e(x,w){var t="",v,u;t+="\n ";k=f.supportedContentTypes;v=k||x.supportedContentTypes;u=f.each;j=q.program(2,d,w);j.hash={};j.fn=j;j.inverse=q.noop;v=u.call(x,v,j);if(v||v===0){t+=v}t+="\n";return t}function d(w,v){var t="",u;t+='\n <option value="';u=w;if(typeof u===h){u=u.call(w,{hash:{}})}else{if(u===i){u=o.call(w,"this",{hash:{}})}}if(u||u===0){t+=u}t+='">';u=w;if(typeof u===h){u=u.call(w,{hash:{}})}else{if(u===i){u=o.call(w,"this",{hash:{}})}}if(u||u===0){t+=u}t+="</option>\n ";return t}function r(u,t){return'\n <option value="application/json">application/json</option>\n'}l+='<label for="contentType"></label>\n<select name="contentType">\n';k=f.supportedContentTypes;c=k||p.supportedContentTypes;s=f["if"];j=q.program(1,e,m);j.hash={};j.fn=j;j.inverse=q.program(4,r,m);c=s.call(p,c,j);if(c||c===0){l+=c}l+="\n</select>\n";return l})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.main=b(function(f,p,e,n,m){e=e||f.helpers;var k="",c,r,j,i,q=this,g="function",o=e.helperMissing,h=void 0,l=this.escapeExpression;function d(v,u){var s="",t;s+='\n , <span style="font-variant: small-caps">api version</span>: ';j=e.apiVersion;t=j||v.apiVersion;if(typeof t===g){t=t.call(v,{hash:{}})}else{if(t===h){t=o.call(v,"apiVersion",{hash:{}})}}s+=l(t)+"\n ";return s}k+="\n<div class='container' id='resources_container'>\n <ul id='resources'>\n </ul>\n\n <div class=\"footer\">\n <br>\n <br>\n <h4 style=\"color: #999\">[ <span style=\"font-variant: small-caps\">base url</span>: ";j=e.basePath;c=j||p.basePath;if(typeof c===g){c=c.call(p,{hash:{}})}else{if(c===h){c=o.call(p,"basePath",{hash:{}})}}k+=l(c)+"\n ";j=e.apiVersion;c=j||p.apiVersion;r=e["if"];i=q.program(1,d,m);i.hash={};i.fn=i;i.inverse=q.noop;c=r.call(p,c,i);if(c||c===0){k+=c}k+="]</h4>\n </div>\n</div>\n";return k})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.operation=b(function(h,u,s,m,v){s=s||h.helpers;var t="",j,g,i,q,p=this,e="function",r=s.helperMissing,c=void 0,d=this.escapeExpression;function o(z,y){var w="",x;w+="\n <h4>Implementation Notes</h4>\n <p>";i=s.notes;x=i||z.notes;if(typeof x===e){x=x.call(z,{hash:{}})}else{if(x===c){x=r.call(z,"notes",{hash:{}})}}if(x||x===0){w+=x}w+="</p>\n ";return w}function n(x,w){return'\n <h4>Response Class</h4>\n <p><span class="model-signature" /></p>\n <br/>\n <div class="content-type" />\n '}function l(x,w){return"\n <div style='margin:0;padding:0;display:inline'></div>\n <h4>Status Codes</h4>\n <table class='fullwidth'>\n <thead>\n <tr>\n <th>HTTP Status Code</th>\n <th>Reason</th>\n </tr>\n </thead>\n <tbody class=\"operation-status\">\n \n </tbody>\n </table>\n "}function k(x,w){return"\n "}function f(x,w){return"\n <div class='sandbox_header'>\n <input class='submit' name='commit' type='button' value='Try it out!' />\n <a href='#' class='response_hider' style='display:none'>Hide Response</a>\n <img alt='Throbber' class='response_throbber' src='images/throbber.gif' style='display:none' />\n </div>\n "}t+="\n <ul class='operations' >\n <li class='";i=s.httpMethod;j=i||u.httpMethod;if(typeof j===e){j=j.call(u,{hash:{}})}else{if(j===c){j=r.call(u,"httpMethod",{hash:{}})}}t+=d(j)+" operation' id='";i=s.resourceName;j=i||u.resourceName;if(typeof j===e){j=j.call(u,{hash:{}})}else{if(j===c){j=r.call(u,"resourceName",{hash:{}})}}t+=d(j)+"_";i=s.nickname;j=i||u.nickname;if(typeof j===e){j=j.call(u,{hash:{}})}else{if(j===c){j=r.call(u,"nickname",{hash:{}})}}t+=d(j)+"_";i=s.httpMethod;j=i||u.httpMethod;if(typeof j===e){j=j.call(u,{hash:{}})}else{if(j===c){j=r.call(u,"httpMethod",{hash:{}})}}t+=d(j)+"_";i=s.number;j=i||u.number;if(typeof j===e){j=j.call(u,{hash:{}})}else{if(j===c){j=r.call(u,"number",{hash:{}})}}t+=d(j)+"'>\n <div class='heading'>\n <h3>\n <span class='http_method'>\n <a href='#!/";i=s.resourceName;j=i||u.resourceName;if(typeof j===e){j=j.call(u,{hash:{}})}else{if(j===c){j=r.call(u,"resourceName",{hash:{}})}}t+=d(j)+"/";i=s.nickname;j=i||u.nickname;if(typeof j===e){j=j.call(u,{hash:{}})}else{if(j===c){j=r.call(u,"nickname",{hash:{}})}}t+=d(j)+"_";i=s.httpMethod;j=i||u.httpMethod;if(typeof j===e){j=j.call(u,{hash:{}})}else{if(j===c){j=r.call(u,"httpMethod",{hash:{}})}}t+=d(j)+"_";i=s.number;j=i||u.number;if(typeof j===e){j=j.call(u,{hash:{}})}else{if(j===c){j=r.call(u,"number",{hash:{}})}}t+=d(j)+'\' class="toggleOperation">';i=s.httpMethod;j=i||u.httpMethod;if(typeof j===e){j=j.call(u,{hash:{}})}else{if(j===c){j=r.call(u,"httpMethod",{hash:{}})}}t+=d(j)+"</a>\n </span>\n <span class='path'>\n <a href='#!/";i=s.resourceName;j=i||u.resourceName;if(typeof j===e){j=j.call(u,{hash:{}})}else{if(j===c){j=r.call(u,"resourceName",{hash:{}})}}t+=d(j)+"/";i=s.nickname;j=i||u.nickname;if(typeof j===e){j=j.call(u,{hash:{}})}else{if(j===c){j=r.call(u,"nickname",{hash:{}})}}t+=d(j)+"_";i=s.httpMethod;j=i||u.httpMethod;if(typeof j===e){j=j.call(u,{hash:{}})}else{if(j===c){j=r.call(u,"httpMethod",{hash:{}})}}t+=d(j)+"_";i=s.number;j=i||u.number;if(typeof j===e){j=j.call(u,{hash:{}})}else{if(j===c){j=r.call(u,"number",{hash:{}})}}t+=d(j)+'\' class="toggleOperation">';i=s.path;j=i||u.path;if(typeof j===e){j=j.call(u,{hash:{}})}else{if(j===c){j=r.call(u,"path",{hash:{}})}}t+=d(j)+"</a>\n </span>\n </h3>\n <ul class='options'>\n <li>\n <a href='#!/";i=s.resourceName;j=i||u.resourceName;if(typeof j===e){j=j.call(u,{hash:{}})}else{if(j===c){j=r.call(u,"resourceName",{hash:{}})}}t+=d(j)+"/";i=s.nickname;j=i||u.nickname;if(typeof j===e){j=j.call(u,{hash:{}})}else{if(j===c){j=r.call(u,"nickname",{hash:{}})}}t+=d(j)+"_";i=s.httpMethod;j=i||u.httpMethod;if(typeof j===e){j=j.call(u,{hash:{}})}else{if(j===c){j=r.call(u,"httpMethod",{hash:{}})}}t+=d(j)+"_";i=s.number;j=i||u.number;if(typeof j===e){j=j.call(u,{hash:{}})}else{if(j===c){j=r.call(u,"number",{hash:{}})}}t+=d(j)+'\' class="toggleOperation">';i=s.summary;j=i||u.summary;if(typeof j===e){j=j.call(u,{hash:{}})}else{if(j===c){j=r.call(u,"summary",{hash:{}})}}if(j||j===0){t+=j}t+="</a>\n </li>\n </ul>\n </div>\n <div class='content' id='";i=s.resourceName;j=i||u.resourceName;if(typeof j===e){j=j.call(u,{hash:{}})}else{if(j===c){j=r.call(u,"resourceName",{hash:{}})}}t+=d(j)+"_";i=s.nickname;j=i||u.nickname;if(typeof j===e){j=j.call(u,{hash:{}})}else{if(j===c){j=r.call(u,"nickname",{hash:{}})}}t+=d(j)+"_";i=s.httpMethod;j=i||u.httpMethod;if(typeof j===e){j=j.call(u,{hash:{}})}else{if(j===c){j=r.call(u,"httpMethod",{hash:{}})}}t+=d(j)+"_";i=s.number;j=i||u.number;if(typeof j===e){j=j.call(u,{hash:{}})}else{if(j===c){j=r.call(u,"number",{hash:{}})}}t+=d(j)+"_content' style='display:none'>\n ";i=s.notes;j=i||u.notes;g=s["if"];q=p.program(1,o,v);q.hash={};q.fn=q;q.inverse=p.noop;j=g.call(u,j,q);if(j||j===0){t+=j}t+="\n ";i=s.responseClass;j=i||u.responseClass;g=s["if"];q=p.program(3,n,v);q.hash={};q.fn=q;q.inverse=p.noop;j=g.call(u,j,q);if(j||j===0){t+=j}t+='\n <form accept-charset=\'UTF-8\' class=\'sandbox\'>\n <div style=\'margin:0;padding:0;display:inline\'></div>\n <h4>Parameters</h4>\n <table class=\'fullwidth\'>\n <thead>\n <tr>\n <th style="width: 100px; max-width: 100px" >Parameter</th>\n <th style="width: 310px; max-width: 310px">Value</th>\n <th style="width: 200px; max-width: 200px">Description</th>\n <th style="width: 320px; max-width: 330px">Data Type</th>\n </tr>\n </thead>\n <tbody class="operation-params">\n\n </tbody>\n </table>\n ';i=s.errorResponses;j=i||u.errorResponses;g=s["if"];q=p.program(5,l,v);q.hash={};q.fn=q;q.inverse=p.noop;j=g.call(u,j,q);if(j||j===0){t+=j}t+="\n ";i=s.isReadOnly;j=i||u.isReadOnly;g=s["if"];q=p.program(7,k,v);q.hash={};q.fn=q;q.inverse=p.program(9,f,v);j=g.call(u,j,q);if(j||j===0){t+=j}t+="\n </form>\n <div class='response' style='display:none'>\n <h4>Request URL</h4>\n <div class='block request_url'></div>\n <h4>Response Body</h4>\n <div class='block response_body'></div>\n <h4>Response Code</h4>\n <div class='block response_code'></div>\n <h4>Response Headers</h4>\n <div class='block response_headers'></div>\n </div>\n </div>\n </li>\n </ul>\n";return t})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param=b(function(h,v,t,m,y){t=t||h.helpers;var u="",j,g,i,r,q=this,e="function",s=t.helperMissing,c=void 0,d=this.escapeExpression;function p(D,C){var z="",B,A;z+="\n ";i=t.isFile;B=i||D.isFile;A=t["if"];r=q.program(2,o,C);r.hash={};r.fn=r;r.inverse=q.program(4,n,C);B=A.call(D,B,r);if(B||B===0){z+=B}z+="\n ";return z}function o(C,B){var z="",A;z+='\n <input type="file" name=\'';i=t.name;A=i||C.name;if(typeof A===e){A=A.call(C,{hash:{}})}else{if(A===c){A=s.call(C,"name",{hash:{}})}}z+=d(A)+"'/>\n ";return z}function n(D,C){var z="",B,A;z+="\n ";i=t.defaultValue;B=i||D.defaultValue;A=t["if"];r=q.program(5,l,C);r.hash={};r.fn=r;r.inverse=q.program(7,k,C);B=A.call(D,B,r);if(B||B===0){z+=B}z+="\n ";return z}function l(C,B){var z="",A;z+="\n <textarea class='body-textarea' name='";i=t.name;A=i||C.name;if(typeof A===e){A=A.call(C,{hash:{}})}else{if(A===c){A=s.call(C,"name",{hash:{}})}}z+=d(A)+"'>";i=t.defaultValue;A=i||C.defaultValue;if(typeof A===e){A=A.call(C,{hash:{}})}else{if(A===c){A=s.call(C,"defaultValue",{hash:{}})}}z+=d(A)+"</textarea>\n ";return z}function k(C,B){var z="",A;z+="\n <textarea class='body-textarea' name='";i=t.name;A=i||C.name;if(typeof A===e){A=A.call(C,{hash:{}})}else{if(A===c){A=s.call(C,"name",{hash:{}})}}z+=d(A)+'\'></textarea>\n <br />\n <div class="content-type" />\n ';return z}function f(D,C){var z="",B,A;z+="\n ";i=t.defaultValue;B=i||D.defaultValue;A=t["if"];r=q.program(10,x,C);r.hash={};r.fn=r;r.inverse=q.program(12,w,C);B=A.call(D,B,r);if(B||B===0){z+=B}z+="\n ";return z}function x(C,B){var z="",A;z+="\n <input minlength='0' name='";i=t.name;A=i||C.name;if(typeof A===e){A=A.call(C,{hash:{}})}else{if(A===c){A=s.call(C,"name",{hash:{}})}}z+=d(A)+"' placeholder='' type='text' value='";i=t.defaultValue;A=i||C.defaultValue;if(typeof A===e){A=A.call(C,{hash:{}})}else{if(A===c){A=s.call(C,"defaultValue",{hash:{}})}}z+=d(A)+"'/>\n ";return z}function w(C,B){var z="",A;z+="\n <input minlength='0' name='";i=t.name;A=i||C.name;if(typeof A===e){A=A.call(C,{hash:{}})}else{if(A===c){A=s.call(C,"name",{hash:{}})}}z+=d(A)+"' placeholder='' type='text' value=''/>\n ";return z}u+="<td class='code'>";i=t.name;j=i||v.name;if(typeof j===e){j=j.call(v,{hash:{}})}else{if(j===c){j=s.call(v,"name",{hash:{}})}}u+=d(j)+"</td>\n<td>\n\n ";i=t.isBody;j=i||v.isBody;g=t["if"];r=q.program(1,p,y);r.hash={};r.fn=r;r.inverse=q.program(9,f,y);j=g.call(v,j,r);if(j||j===0){u+=j}u+="\n\n</td>\n<td>";i=t.description;j=i||v.description;if(typeof j===e){j=j.call(v,{hash:{}})}else{if(j===c){j=s.call(v,"description",{hash:{}})}}if(j||j===0){u+=j}u+='</td>\n<td>\n <span class="model-signature"></span>\n</td>\n\n';return u})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_list=b(function(h,v,t,m,x){t=t||h.helpers;var u="",k,g,j,r,q=this,e="function",s=t.helperMissing,c=void 0,d=this.escapeExpression;function p(z,y){return"\n "}function o(C,B){var y="",A,z;y+="\n ";j=t.defaultValue;A=j||C.defaultValue;z=t["if"];r=q.program(4,n,B);r.hash={};r.fn=r;r.inverse=q.program(6,l,B);A=z.call(C,A,r);if(A||A===0){y+=A}y+="\n ";return y}function n(z,y){return"\n "}function l(z,y){return"\n <option selected=\"\" value=''></option>\n "}function i(C,B){var y="",A,z;y+="\n ";j=t.isDefault;A=j||C.isDefault;z=t["if"];r=q.program(9,f,B);r.hash={};r.fn=r;r.inverse=q.program(11,w,B);A=z.call(C,A,r);if(A||A===0){y+=A}y+="\n ";return y}function f(B,A){var y="",z;y+="\n <option value='";j=t.value;z=j||B.value;if(typeof z===e){z=z.call(B,{hash:{}})}else{if(z===c){z=s.call(B,"value",{hash:{}})}}y+=d(z)+"'>";j=t.value;z=j||B.value;if(typeof z===e){z=z.call(B,{hash:{}})}else{if(z===c){z=s.call(B,"value",{hash:{}})}}y+=d(z)+" (default)</option>\n ";return y}function w(B,A){var y="",z;y+="\n <option value='";j=t.value;z=j||B.value;if(typeof z===e){z=z.call(B,{hash:{}})}else{if(z===c){z=s.call(B,"value",{hash:{}})}}y+=d(z)+"'>";j=t.value;z=j||B.value;if(typeof z===e){z=z.call(B,{hash:{}})}else{if(z===c){z=s.call(B,"value",{hash:{}})}}y+=d(z)+"</option>\n ";return y}u+="<td class='code'>";j=t.name;k=j||v.name;if(typeof k===e){k=k.call(v,{hash:{}})}else{if(k===c){k=s.call(v,"name",{hash:{}})}}u+=d(k)+"</td>\n<td>\n <select name='";j=t.name;k=j||v.name;if(typeof k===e){k=k.call(v,{hash:{}})}else{if(k===c){k=s.call(v,"name",{hash:{}})}}u+=d(k)+"'>\n ";j=t.required;k=j||v.required;g=t["if"];r=q.program(1,p,x);r.hash={};r.fn=r;r.inverse=q.program(3,o,x);k=g.call(v,k,r);if(k||k===0){u+=k}u+="\n ";j=t.allowableValues;k=j||v.allowableValues;k=(k===null||k===undefined||k===false?k:k.descriptiveValues);g=t.each;r=q.program(8,i,x);r.hash={};r.fn=r;r.inverse=q.noop;k=g.call(v,k,r);if(k||k===0){u+=k}u+="\n </select>\n</td>\n<td>";j=t.description;k=j||v.description;if(typeof k===e){k=k.call(v,{hash:{}})}else{if(k===c){k=s.call(v,"description",{hash:{}})}}if(k||k===0){u+=k}u+='</td>\n<td><span class="model-signature"></span></td>\n';return u})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_readonly=b(function(g,q,f,o,n){f=f||g.helpers;var l="",d,s,k,j,r=this,h="function",p=f.helperMissing,i=void 0,m=this.escapeExpression;function e(w,v){var t="",u;t+="\n <textarea class='body-textarea' readonly='readonly' name='";k=f.name;u=k||w.name;if(typeof u===h){u=u.call(w,{hash:{}})}else{if(u===i){u=p.call(w,"name",{hash:{}})}}t+=m(u)+"'>";k=f.defaultValue;u=k||w.defaultValue;if(typeof u===h){u=u.call(w,{hash:{}})}else{if(u===i){u=p.call(w,"defaultValue",{hash:{}})}}t+=m(u)+"</textarea>\n ";return t}function c(w,v){var t="",u;t+="\n ";k=f.defaultValue;u=k||w.defaultValue;if(typeof u===h){u=u.call(w,{hash:{}})}else{if(u===i){u=p.call(w,"defaultValue",{hash:{}})}}t+=m(u)+"\n ";return t}l+="<td class='code'>";k=f.name;d=k||q.name;if(typeof d===h){d=d.call(q,{hash:{}})}else{if(d===i){d=p.call(q,"name",{hash:{}})}}l+=m(d)+"</td>\n<td>\n ";k=f.isBody;d=k||q.isBody;s=f["if"];j=r.program(1,e,n);j.hash={};j.fn=j;j.inverse=r.program(3,c,n);d=s.call(q,d,j);if(d||d===0){l+=d}l+="\n</td>\n<td>";k=f.description;d=k||q.description;if(typeof d===h){d=d.call(q,{hash:{}})}else{if(d===i){d=p.call(q,"description",{hash:{}})}}if(d||d===0){l+=d}l+='</td>\n<td><span class="model-signature"></span></td>\n';return l})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_readonly_required=b(function(g,q,f,o,n){f=f||g.helpers;var l="",d,s,k,j,r=this,h="function",p=f.helperMissing,i=void 0,m=this.escapeExpression;function e(w,v){var t="",u;t+="\n <textarea class='body-textarea' readonly='readonly' placeholder='(required)' name='";k=f.name;u=k||w.name;if(typeof u===h){u=u.call(w,{hash:{}})}else{if(u===i){u=p.call(w,"name",{hash:{}})}}t+=m(u)+"'>";k=f.defaultValue;u=k||w.defaultValue;if(typeof u===h){u=u.call(w,{hash:{}})}else{if(u===i){u=p.call(w,"defaultValue",{hash:{}})}}t+=m(u)+"</textarea>\n ";return t}function c(w,v){var t="",u;t+="\n ";k=f.defaultValue;u=k||w.defaultValue;if(typeof u===h){u=u.call(w,{hash:{}})}else{if(u===i){u=p.call(w,"defaultValue",{hash:{}})}}t+=m(u)+"\n ";return t}l+="<td class='code required'>";k=f.name;d=k||q.name;if(typeof d===h){d=d.call(q,{hash:{}})}else{if(d===i){d=p.call(q,"name",{hash:{}})}}l+=m(d)+"</td>\n<td>\n ";k=f.isBody;d=k||q.isBody;s=f["if"];j=r.program(1,e,n);j.hash={};j.fn=j;j.inverse=r.program(3,c,n);d=s.call(q,d,j);if(d||d===0){l+=d}l+="\n</td>\n<td>";k=f.description;d=k||q.description;if(typeof d===h){d=d.call(q,{hash:{}})}else{if(d===i){d=p.call(q,"description",{hash:{}})}}if(d||d===0){l+=d}l+='</td>\n<td><span class="model-signature"></span></td>\n';return l})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_required=b(function(h,v,t,m,A){t=t||h.helpers;var u="",j,g,i,r,q=this,e="function",s=t.helperMissing,c=void 0,d=this.escapeExpression;function p(F,E){var B="",D,C;B+="\n ";i=t.isFile;D=i||F.isFile;C=t["if"];r=q.program(2,o,E);r.hash={};r.fn=r;r.inverse=q.program(4,n,E);D=C.call(F,D,r);if(D||D===0){B+=D}B+="\n ";return B}function o(E,D){var B="",C;B+='\n <input type="file" name=\'';i=t.name;C=i||E.name;if(typeof C===e){C=C.call(E,{hash:{}})}else{if(C===c){C=s.call(E,"name",{hash:{}})}}B+=d(C)+"'/>\n ";return B}function n(F,E){var B="",D,C;B+="\n ";i=t.defaultValue;D=i||F.defaultValue;C=t["if"];r=q.program(5,l,E);r.hash={};r.fn=r;r.inverse=q.program(7,k,E);D=C.call(F,D,r);if(D||D===0){B+=D}B+="\n ";return B}function l(E,D){var B="",C;B+="\n <textarea class='body-textarea' placeholder='(required)' name='";i=t.name;C=i||E.name;if(typeof C===e){C=C.call(E,{hash:{}})}else{if(C===c){C=s.call(E,"name",{hash:{}})}}B+=d(C)+"'>";i=t.defaultValue;C=i||E.defaultValue;if(typeof C===e){C=C.call(E,{hash:{}})}else{if(C===c){C=s.call(E,"defaultValue",{hash:{}})}}B+=d(C)+"</textarea>\n ";return B}function k(E,D){var B="",C;B+="\n <textarea class='body-textarea' placeholder='(required)' name='";i=t.name;C=i||E.name;if(typeof C===e){C=C.call(E,{hash:{}})}else{if(C===c){C=s.call(E,"name",{hash:{}})}}B+=d(C)+'\'></textarea>\n <br />\n <div class="content-type" />\n ';return B}function f(F,E){var B="",D,C;B+="\n ";i=t.isFile;D=i||F.isFile;C=t["if"];r=q.program(10,z,E);r.hash={};r.fn=r;r.inverse=q.program(12,y,E);D=C.call(F,D,r);if(D||D===0){B+=D}B+="\n ";return B}function z(E,D){var B="",C;B+="\n <input class='required' type='file' name='";i=t.name;C=i||E.name;if(typeof C===e){C=C.call(E,{hash:{}})}else{if(C===c){C=s.call(E,"name",{hash:{}})}}B+=d(C)+"'/>\n ";return B}function y(F,E){var B="",D,C;B+="\n ";i=t.defaultValue;D=i||F.defaultValue;C=t["if"];r=q.program(13,x,E);r.hash={};r.fn=r;r.inverse=q.program(15,w,E);D=C.call(F,D,r);if(D||D===0){B+=D}B+="\n ";return B}function x(E,D){var B="",C;B+="\n <input class='required' minlength='1' name='";i=t.name;C=i||E.name;if(typeof C===e){C=C.call(E,{hash:{}})}else{if(C===c){C=s.call(E,"name",{hash:{}})}}B+=d(C)+"' placeholder='(required)' type='text' value='";i=t.defaultValue;C=i||E.defaultValue;if(typeof C===e){C=C.call(E,{hash:{}})}else{if(C===c){C=s.call(E,"defaultValue",{hash:{}})}}B+=d(C)+"'/>\n ";return B}function w(E,D){var B="",C;B+="\n <input class='required' minlength='1' name='";i=t.name;C=i||E.name;if(typeof C===e){C=C.call(E,{hash:{}})}else{if(C===c){C=s.call(E,"name",{hash:{}})}}B+=d(C)+"' placeholder='(required)' type='text' value=''/>\n ";return B}u+="<td class='code required'>";i=t.name;j=i||v.name;if(typeof j===e){j=j.call(v,{hash:{}})}else{if(j===c){j=s.call(v,"name",{hash:{}})}}u+=d(j)+"</td>\n<td>\n ";i=t.isBody;j=i||v.isBody;g=t["if"];r=q.program(1,p,A);r.hash={};r.fn=r;r.inverse=q.program(9,f,A);j=g.call(v,j,r);if(j||j===0){u+=j}u+="\n</td>\n<td>\n <strong>";i=t.description;j=i||v.description;if(typeof j===e){j=j.call(v,{hash:{}})}else{if(j===c){j=s.call(v,"description",{hash:{}})}}if(j||j===0){u+=j}u+='</strong>\n</td>\n<td><span class="model-signature"></span></td>\n';return u})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.resource=b(function(e,n,d,l,k){d=d||e.helpers;var i="",c,h,o=this,f="function",m=d.helperMissing,g=void 0,j=this.escapeExpression;i+="<div class='heading'>\n <h2>\n <a href='#!/";h=d.name;c=h||n.name;if(typeof c===f){c=c.call(n,{hash:{}})}else{if(c===g){c=m.call(n,"name",{hash:{}})}}i+=j(c)+"' onclick=\"Docs.toggleEndpointListForResource('";h=d.name;c=h||n.name;if(typeof c===f){c=c.call(n,{hash:{}})}else{if(c===g){c=m.call(n,"name",{hash:{}})}}i+=j(c)+"');\">/";h=d.name;c=h||n.name;if(typeof c===f){c=c.call(n,{hash:{}})}else{if(c===g){c=m.call(n,"name",{hash:{}})}}i+=j(c)+"</a>\n </h2>\n <ul class='options'>\n <li>\n <a href='#!/";h=d.name;c=h||n.name;if(typeof c===f){c=c.call(n,{hash:{}})}else{if(c===g){c=m.call(n,"name",{hash:{}})}}i+=j(c)+"' id='endpointListTogger_";h=d.name;c=h||n.name;if(typeof c===f){c=c.call(n,{hash:{}})}else{if(c===g){c=m.call(n,"name",{hash:{}})}}i+=j(c)+"'\n onclick=\"Docs.toggleEndpointListForResource('";h=d.name;c=h||n.name;if(typeof c===f){c=c.call(n,{hash:{}})}else{if(c===g){c=m.call(n,"name",{hash:{}})}}i+=j(c)+"');\">Show/Hide</a>\n </li>\n <li>\n <a href='#' onclick=\"Docs.collapseOperationsForResource('";h=d.name;c=h||n.name;if(typeof c===f){c=c.call(n,{hash:{}})}else{if(c===g){c=m.call(n,"name",{hash:{}})}}i+=j(c)+"'); return false;\">\n List Operations\n </a>\n </li>\n <li>\n <a href='#' onclick=\"Docs.expandOperationsForResource('";h=d.name;c=h||n.name;if(typeof c===f){c=c.call(n,{hash:{}})}else{if(c===g){c=m.call(n,"name",{hash:{}})}}i+=j(c)+"'); return false;\">\n Expand Operations\n </a>\n </li>\n <li>\n <a href='";h=d.url;c=h||n.url;if(typeof c===f){c=c.call(n,{hash:{}})}else{if(c===g){c=m.call(n,"url",{hash:{}})}}i+=j(c)+"'>Raw</a>\n </li>\n </ul>\n</div>\n<ul class='endpoints' id='";h=d.name;c=h||n.name;if(typeof c===f){c=c.call(n,{hash:{}})}else{if(c===g){c=m.call(n,"name",{hash:{}})}}i+=j(c)+"_endpoint_list' style='display:none'>\n\n</ul>\n";return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.signature=b(function(e,n,d,l,k){d=d||e.helpers;var i="",c,h,o=this,f="function",m=d.helperMissing,g=void 0,j=this.escapeExpression;i+='<div>\n<ul class="signature-nav">\n <li><a class="description-link" href="#">Model</a></li>\n <li><a class="snippet-link" href="#">Model Schema</a></li>\n</ul>\n<div>\n\n<div class="signature-container">\n <div class="description">\n ';h=d.signature;c=h||n.signature;if(typeof c===f){c=c.call(n,{hash:{}})}else{if(c===g){c=m.call(n,"signature",{hash:{}})}}if(c||c===0){i+=c}i+='\n </div>\n\n <div class="snippet">\n <pre><code>';h=d.sampleJSON;c=h||n.sampleJSON;if(typeof c===f){c=c.call(n,{hash:{}})}else{if(c===g){c=m.call(n,"sampleJSON",{hash:{}})}}i+=j(c)+'</code></pre>\n <small class="notice"></small>\n </div>\n</div>\n\n';return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.status_code=b(function(e,n,d,l,k){d=d||e.helpers;var i="",c,h,o=this,f="function",m=d.helperMissing,g=void 0,j=this.escapeExpression;i+="<td width='15%' class='code'>";h=d.code;c=h||n.code;if(typeof c===f){c=c.call(n,{hash:{}})}else{if(c===g){c=m.call(n,"code",{hash:{}})}}i+=j(c)+"</td>\n<td>";h=d.reason;c=h||n.reason;if(typeof c===f){c=c.call(n,{hash:{}})}else{if(c===g){c=m.call(n,"reason",{hash:{}})}}if(c||c===0){i+=c}i+="</td>\n\n";return i})})();(function(){var f,b,h,c,e,j,k,i,a,g={}.hasOwnProperty,d=function(o,m){for(var l in m){if(g.call(m,l)){o[l]=m[l]}}function n(){this.constructor=o}n.prototype=m.prototype;o.prototype=new n();o.__super__=m.prototype;return o};a=(function(m){d(l,m);function l(){return l.__super__.constructor.apply(this,arguments)}l.prototype.dom_id="swagger_ui";l.prototype.options=null;l.prototype.api=null;l.prototype.headerView=null;l.prototype.mainView=null;l.prototype.initialize=function(n){var o=this;if(n==null){n={}}if(n.dom_id!=null){this.dom_id=n.dom_id;delete n.dom_id}if(!($("#"+this.dom_id)!=null)){$("body").append('<div id="'+this.dom_id+'"></div>')}this.options=n;this.options.success=function(){return o.render()};this.options.progress=function(p){return o.showMessage(p)};this.options.failure=function(p){return o.onLoadFailure(p)};this.headerView=new b({el:$("#header")});return this.headerView.on("update-swagger-ui",function(p){return o.updateSwaggerUi(p)})};l.prototype.updateSwaggerUi=function(n){this.options.discoveryUrl=n.discoveryUrl;this.options.apiKey=n.apiKey;return this.load()};l.prototype.load=function(){var n;if((n=this.mainView)!=null){n.clear()}this.headerView.update(this.options.discoveryUrl,this.options.apiKey);return this.api=new SwaggerApi(this.options)};l.prototype.render=function(){var n=this;this.showMessage("Finished Loading Resource Information. Rendering Swagger UI...");this.mainView=new h({model:this.api,el:$("#"+this.dom_id)}).render();this.showMessage();switch(this.options.docExpansion){case"full":Docs.expandOperationsForResource("");break;case"list":Docs.collapseOperationsForResource("")}if(this.options.onComplete){this.options.onComplete(this.api,this)}return setTimeout(function(){return Docs.shebang()},400)};l.prototype.showMessage=function(n){if(n==null){n=""}$("#message-bar").removeClass("message-fail");$("#message-bar").addClass("message-success");return $("#message-bar").html(n)};l.prototype.onLoadFailure=function(n){var o;if(n==null){n=""}$("#message-bar").removeClass("message-success");$("#message-bar").addClass("message-fail");o=$("#message-bar").html(n);if(this.options.onFailure!=null){this.options.onFailure(n)}return o};return l})(Backbone.Router);window.SwaggerUi=a;b=(function(m){d(l,m);function l(){return l.__super__.constructor.apply(this,arguments)}l.prototype.events={"click #show-pet-store-icon":"showPetStore","click #show-wordnik-dev-icon":"showWordnikDev","click #explore":"showCustom","keyup #input_baseUrl":"showCustomOnKeyup","keyup #input_apiKey":"showCustomOnKeyup"};l.prototype.initialize=function(){};l.prototype.showPetStore=function(n){return this.trigger("update-swagger-ui",{discoveryUrl:"http://petstore.swagger.wordnik.com/api/api-docs.json",apiKey:"special-key"})};l.prototype.showWordnikDev=function(n){return this.trigger("update-swagger-ui",{discoveryUrl:"http://api.wordnik.com/v4/resources.json",apiKey:""})};l.prototype.showCustomOnKeyup=function(n){if(n.keyCode===13){return this.showCustom()}};l.prototype.showCustom=function(n){if(n!=null){n.preventDefault()}return this.trigger("update-swagger-ui",{discoveryUrl:$("#input_baseUrl").val(),apiKey:$("#input_apiKey").val()})};l.prototype.update=function(o,p,n){if(n==null){n=false}$("#input_baseUrl").val(o);$("#input_apiKey").val(p);if(n){return this.trigger("update-swagger-ui",{discoveryUrl:o,apiKey:p})}};return l})(Backbone.View);h=(function(l){d(m,l);function m(){return m.__super__.constructor.apply(this,arguments)}m.prototype.initialize=function(){};m.prototype.render=function(){var q,p,n,o;$(this.el).html(Handlebars.templates.main(this.model));o=this.model.resourcesArray;for(p=0,n=o.length;p<n;p++){q=o[p];this.addResource(q)}return this};m.prototype.addResource=function(o){var n;n=new j({model:o,tagName:"li",id:"resource_"+o.name,className:"resource"});return $("#resources").append(n.render().el)};m.prototype.clear=function(){return $(this.el).html("")};return m})(Backbone.View);j=(function(m){d(l,m);function l(){return l.__super__.constructor.apply(this,arguments)}l.prototype.initialize=function(){};l.prototype.render=function(){var o,q,n,p;$(this.el).html(Handlebars.templates.resource(this.model));this.number=0;p=this.model.operationsArray;for(q=0,n=p.length;q<n;q++){o=p[q];this.addOperation(o)}return this};l.prototype.addOperation=function(n){var o;n.number=this.number;o=new c({model:n,tagName:"li",className:"endpoint"});$(".endpoints",$(this.el)).append(o.render().el);return this.number++};return l})(Backbone.View);c=(function(m){d(l,m);function l(){return l.__super__.constructor.apply(this,arguments)}l.prototype.events={"submit .sandbox":"submitOperation","click .submit":"submitOperation","click .response_hider":"hideResponse","click .toggleOperation":"toggleOperationContent"};l.prototype.initialize=function(){};l.prototype.render=function(){var n,x,y,p,u,z,v,s,r,w,o,t,q;y=jQuery.inArray(this.model.httpMethod,this.model.supportedSubmitMethods())>=0;if(!y){this.model.isReadOnly=true}$(this.el).html(Handlebars.templates.operation(this.model));if(this.model.responseClassSignature&&this.model.responseClassSignature!=="string"){z={sampleJSON:this.model.responseSampleJSON,isParam:false,signature:this.model.responseClassSignature};u=new k({model:z,tagName:"div"});$(".model-signature",$(this.el)).append(u.render().el)}else{$(".model-signature",$(this.el)).html(this.model.responseClass)}n={isParam:false,supportedContentTypes:this.model.supportedContentTypes};x=new f({model:n});$(".content-type",$(this.el)).append(x.render().el);t=this.model.parameters;for(s=0,w=t.length;s<w;s++){p=t[s];this.addParameter(p)}q=this.model.errorResponses;for(r=0,o=q.length;r<o;r++){v=q[r];this.addStatusCode(v)}return this};l.prototype.addParameter=function(o){var n;n=new e({model:o,tagName:"tr",readOnly:this.model.isReadOnly});return $(".operation-params",$(this.el)).append(n.render().el)};l.prototype.addStatusCode=function(o){var n;n=new i({model:o,tagName:"tr"});return $(".operation-status",$(this.el)).append(n.render().el)};l.prototype.submitOperation=function(F){var B,A,s,n,w,H,I,D,z,x,C,p,t,r,q,G,K,J,y,v,u,E=this;if(F!=null){F.preventDefault()}s=$(".sandbox",$(this.el));A=true;s.find("input.required").each(function(){var o=this;$(this).removeClass("error");if(jQuery.trim($(this).val())===""){$(this).addClass("error");$(this).wiggle({callback:function(){return $(o).focus()}});return A=false}});if(A){I={};y=s.serializeArray();for(t=0,G=y.length;t<G;t++){D=y[t];if((D.value!=null)&&jQuery.trim(D.value).length>0){I[D.name]=D.value}}H=$('input[type~="file"]').size!==0;if(H){B=new FormData();v=this.model.parameters;for(r=0,K=v.length;r<K;r++){x=v[r];if(x.paramType==="body"&&x.name!=="file"){B.append(x.name,I[x.name])}}$.each($('input[type~="file"]'),function(o,L){return B.append($(L).attr("name"),L.files[0])});console.log(B)}else{B=null;u=this.model.parameters;for(q=0,J=u.length;q<J;q++){x=u[q];if(x.paramType==="body"){B=I[x.name]}}}log("bodyParam = "+B);n=null;w=this.model.supportHeaderParams()?(n=this.model.getHeaderParams(I),this.model.urlify(I,false)):this.model.urlify(I,true);log("submitting "+w);$(".request_url",$(this.el)).html("<pre>"+w+"</pre>");$(".response_throbber",$(this.el)).show();z={type:this.model.httpMethod,url:w,headers:n,data:B,dataType:"json",processData:false,error:function(L,M,o){return E.showErrorStatus(L,M,o)},success:function(o){return E.showResponse(o)},complete:function(o){return E.showCompleteStatus(o)}};if(z.type.toLowerCase()==="post"||z.type.toLowerCase()==="put"||z.type.toLowerCase()==="patch"){z.contentType="application/json"}if(H){z.contentType=false}C=$("td select[name=contentType]",$(this.el)).val();if(C){z.contentType=C}p=$(".content > .content-type > div > select[name=contentType]",$(this.el)).val();if(p){z.headers=z.headers!=null?z.headers:{};z.headers.accept=p}jQuery.ajax(z);return false}};l.prototype.hideResponse=function(n){if(n!=null){n.preventDefault()}$(".response",$(this.el)).slideUp();return $(".response_hider",$(this.el)).fadeOut()};l.prototype.showResponse=function(n){var o;o=JSON.stringify(n,null,"\t").replace(/\n/g,"<br>");return $(".response_body",$(this.el)).html(escape(o))};l.prototype.showErrorStatus=function(n){return this.showStatus(n)};l.prototype.showCompleteStatus=function(n){return this.showStatus(n)};l.prototype.formatXml=function(u){var q,t,o,v,A,w,p,n,y,z,s,r,x;n=/(>)(<)(\/*)/g;z=/[ ]*(.*)[ ]+\n/g;q=/(<.+>)(.+\n)/g;u=u.replace(n,"$1\n$2$3").replace(z,"$1\n").replace(q,"$1\n$2");p=0;t="";A=u.split("\n");o=0;v="other";y={"single->single":0,"single->closing":-1,"single->opening":0,"single->other":0,"closing->single":0,"closing->closing":-1,"closing->opening":0,"closing->other":0,"opening->single":1,"opening->closing":0,"opening->opening":1,"opening->other":1,"other->single":0,"other->closing":-1,"other->opening":0,"other->other":0};s=function(G){var C,B,E,I,F,D,H;D={single:Boolean(G.match(/<.+\/>/)),closing:Boolean(G.match(/<\/.+>/)),opening:Boolean(G.match(/<[^!?].*>/))};F=((function(){var J;J=[];for(E in D){H=D[E];if(H){J.push(E)}}return J})())[0];F=F===void 0?"other":F;C=v+"->"+F;v=F;I="";o+=y[C];I=((function(){var K,L,J;J=[];for(B=K=0,L=o;0<=L?K<L:K>L;B=0<=L?++K:--K){J.push(" ")}return J})()).join("");if(C==="opening->closing"){return t=t.substr(0,t.length-1)+G+"\n"}else{return t+=I+G+"\n"}};for(r=0,x=A.length;r<x;r++){w=A[r];s(w)}return t};l.prototype.showStatus=function(q){var p,r,o;try{p=$("<code />").text(JSON.stringify(JSON.parse(q.responseText),null,2));r=$('<pre class="json" />').append(p)}catch(n){p=$("<code />").text(this.formatXml(q.responseText));r=$('<pre class="xml" />').append(p)}o=r;$(".response_code",$(this.el)).html("<pre>"+q.status+"</pre>");$(".response_body",$(this.el)).html(o);$(".response_headers",$(this.el)).html("<pre>"+q.getAllResponseHeaders()+"</pre>");$(".response",$(this.el)).slideDown();$(".response_hider",$(this.el)).show();$(".response_throbber",$(this.el)).hide();return hljs.highlightBlock($(".response_body",$(this.el))[0])};l.prototype.toggleOperationContent=function(){var n;n=$("#"+this.model.resourceName+"_"+this.model.nickname+"_"+this.model.httpMethod+"_"+this.model.number+"_content");if(n.is(":visible")){return Docs.collapseOperation(n)}else{return Docs.expandOperation(n)}};return l})(Backbone.View);i=(function(m){d(l,m);function l(){return l.__super__.constructor.apply(this,arguments)}l.prototype.initialize=function(){};l.prototype.render=function(){var n;n=this.template();$(this.el).html(n(this.model));return this};l.prototype.template=function(){return Handlebars.templates.status_code};return l})(Backbone.View);e=(function(m){d(l,m);function l(){return l.__super__.constructor.apply(this,arguments)}l.prototype.initialize=function(){};l.prototype.render=function(){var q,o,n,r,p;if(this.model.paramType==="body"){this.model.isBody=true}if(this.model.dataType==="file"){this.model.isFile=true}p=this.template();$(this.el).html(p(this.model));n={sampleJSON:this.model.sampleJSON,isParam:true,signature:this.model.signature};if(this.model.sampleJSON){r=new k({model:n,tagName:"div"});$(".model-signature",$(this.el)).append(r.render().el)}else{$(".model-signature",$(this.el)).html(this.model.signature)}q={isParam:true,supportedContentTypes:this.model.supportedContentTypes};o=new f({model:q});$(".content-type",$(this.el)).append(o.render().el);return this};l.prototype.template=function(){if(this.model.isList){return Handlebars.templates.param_list}else{if(this.options.readOnly){if(this.model.required){return Handlebars.templates.param_readonly_required}else{return Handlebars.templates.param_readonly}}else{if(this.model.required){return Handlebars.templates.param_required}else{return Handlebars.templates.param}}}};return l})(Backbone.View);k=(function(m){d(l,m);function l(){return l.__super__.constructor.apply(this,arguments)}l.prototype.events={"click a.description-link":"switchToDescription","click a.snippet-link":"switchToSnippet","mousedown .snippet":"snippetToTextArea"};l.prototype.initialize=function(){};l.prototype.render=function(){var n;n=this.template();$(this.el).html(n(this.model));this.switchToDescription();this.isParam=this.model.isParam;if(this.isParam){$(".notice",$(this.el)).text("Click to set as parameter value")}return this};l.prototype.template=function(){return Handlebars.templates.signature};l.prototype.switchToDescription=function(n){if(n!=null){n.preventDefault()}$(".snippet",$(this.el)).hide();$(".description",$(this.el)).show();$(".description-link",$(this.el)).addClass("selected");return $(".snippet-link",$(this.el)).removeClass("selected")};l.prototype.switchToSnippet=function(n){if(n!=null){n.preventDefault()}$(".description",$(this.el)).hide();$(".snippet",$(this.el)).show();$(".snippet-link",$(this.el)).addClass("selected");return $(".description-link",$(this.el)).removeClass("selected")};l.prototype.snippetToTextArea=function(n){var o;if(this.isParam){if(n!=null){n.preventDefault()}o=$("textarea",$(this.el.parentNode.parentNode.parentNode));if($.trim(o.val())===""){return o.val(this.model.sampleJSON)}}};return l})(Backbone.View);f=(function(l){d(m,l);function m(){return m.__super__.constructor.apply(this,arguments)}m.prototype.initialize=function(){};m.prototype.render=function(){var n;n=this.template();$(this.el).html(n(this.model));this.isParam=this.model.isParam;if(this.isParam){$("label[for=contentType]",$(this.el)).text("Parameter content type:")}else{$("label[for=contentType]",$(this.el)).text("Response Content Type")}return this};m.prototype.template=function(){return Handlebars.templates.content_type};return m})(Backbone.View)}).call(this);
|
3193
|
+
/*
|
3194
|
+
Swagger
|
3195
|
+
*/
|
3196
|
+
// Generated by CoffeeScript 1.4.0
|
3197
|
+
(function() {
|
3198
|
+
var SwaggerApi, SwaggerModel, SwaggerModelProperty, SwaggerOperation, SwaggerRequest, SwaggerResource,
|
3199
|
+
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
|
3200
|
+
|
3201
|
+
SwaggerApi = (function() {
|
3202
|
+
|
3203
|
+
SwaggerApi.prototype.discoveryUrl = "http://api.wordnik.com/v4/resources.json";
|
3204
|
+
|
3205
|
+
SwaggerApi.prototype.debug = false;
|
3206
|
+
|
3207
|
+
SwaggerApi.prototype.api_key = null;
|
3208
|
+
|
3209
|
+
SwaggerApi.prototype.basePath = null;
|
3210
|
+
|
3211
|
+
function SwaggerApi(options) {
|
3212
|
+
if (options == null) {
|
3213
|
+
options = {};
|
3214
|
+
}
|
3215
|
+
if (options.discoveryUrl != null) {
|
3216
|
+
this.discoveryUrl = options.discoveryUrl;
|
3217
|
+
}
|
3218
|
+
if (options.debug != null) {
|
3219
|
+
this.debug = options.debug;
|
3220
|
+
}
|
3221
|
+
this.apiKeyName = options.apiKeyName != null ? options.apiKeyName : 'api_key';
|
3222
|
+
if (options.apiKey != null) {
|
3223
|
+
this.api_key = options.apiKey;
|
3224
|
+
}
|
3225
|
+
if (options.api_key != null) {
|
3226
|
+
this.api_key = options.api_key;
|
3227
|
+
}
|
3228
|
+
if (options.verbose != null) {
|
3229
|
+
this.verbose = options.verbose;
|
3230
|
+
}
|
3231
|
+
this.supportHeaderParams = options.supportHeaderParams != null ? options.supportHeaderParams : false;
|
3232
|
+
this.supportedSubmitMethods = options.supportedSubmitMethods != null ? options.supportedSubmitMethods : ['get'];
|
3233
|
+
if (options.success != null) {
|
3234
|
+
this.success = options.success;
|
3235
|
+
}
|
3236
|
+
this.failure = options.failure != null ? options.failure : function() {};
|
3237
|
+
this.progress = options.progress != null ? options.progress : function() {};
|
3238
|
+
this.headers = options.headers != null ? options.headers : {};
|
3239
|
+
this.booleanValues = options.booleanValues != null ? options.booleanValues : new Array('true', 'false');
|
3240
|
+
this.discoveryUrl = this.suffixApiKey(this.discoveryUrl);
|
3241
|
+
if (options.success != null) {
|
3242
|
+
this.build();
|
3243
|
+
}
|
3244
|
+
}
|
3245
|
+
|
3246
|
+
SwaggerApi.prototype.build = function() {
|
3247
|
+
var _this = this;
|
3248
|
+
this.progress('fetching resource list: ' + this.discoveryUrl);
|
3249
|
+
return jQuery.getJSON(this.discoveryUrl, function(response) {
|
3250
|
+
var res, resource, _i, _j, _len, _len1, _ref, _ref1;
|
3251
|
+
if (response.apiVersion != null) {
|
3252
|
+
_this.apiVersion = response.apiVersion;
|
3253
|
+
}
|
3254
|
+
if ((response.basePath != null) && jQuery.trim(response.basePath).length > 0) {
|
3255
|
+
_this.basePath = response.basePath;
|
3256
|
+
if (_this.basePath.match(/^HTTP/i) == null) {
|
3257
|
+
_this.fail("discoveryUrl basePath must be a URL.");
|
3258
|
+
}
|
3259
|
+
_this.basePath = _this.basePath.replace(/\/$/, '');
|
3260
|
+
} else {
|
3261
|
+
_this.basePath = _this.discoveryUrl.substring(0, _this.discoveryUrl.lastIndexOf('/'));
|
3262
|
+
log('derived basepath from discoveryUrl as ' + _this.basePath);
|
3263
|
+
}
|
3264
|
+
_this.resources = {};
|
3265
|
+
_this.resourcesArray = [];
|
3266
|
+
if (response.resourcePath != null) {
|
3267
|
+
_this.resourcePath = response.resourcePath;
|
3268
|
+
res = null;
|
3269
|
+
_ref = response.apis;
|
3270
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
3271
|
+
resource = _ref[_i];
|
3272
|
+
if (res === null) {
|
3273
|
+
res = new SwaggerResource(resource, _this);
|
3274
|
+
} else {
|
3275
|
+
res.addOperations(resource.path, resource.operations);
|
3276
|
+
}
|
3277
|
+
}
|
3278
|
+
if (res != null) {
|
3279
|
+
_this.resources[res.name] = res;
|
3280
|
+
_this.resourcesArray.push(res);
|
3281
|
+
res.ready = true;
|
3282
|
+
_this.selfReflect();
|
3283
|
+
}
|
3284
|
+
} else {
|
3285
|
+
_ref1 = response.apis;
|
3286
|
+
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
|
3287
|
+
resource = _ref1[_j];
|
3288
|
+
res = new SwaggerResource(resource, _this);
|
3289
|
+
_this.resources[res.name] = res;
|
3290
|
+
_this.resourcesArray.push(res);
|
3291
|
+
}
|
3292
|
+
}
|
3293
|
+
return _this;
|
3294
|
+
}).error(function(error) {
|
3295
|
+
return _this.fail(error.status + ' : ' + error.statusText + ' ' + _this.discoveryUrl);
|
3296
|
+
});
|
3297
|
+
};
|
3298
|
+
|
3299
|
+
SwaggerApi.prototype.selfReflect = function() {
|
3300
|
+
var resource, resource_name, _ref;
|
3301
|
+
if (this.resources == null) {
|
3302
|
+
return false;
|
3303
|
+
}
|
3304
|
+
_ref = this.resources;
|
3305
|
+
for (resource_name in _ref) {
|
3306
|
+
resource = _ref[resource_name];
|
3307
|
+
if (resource.ready == null) {
|
3308
|
+
return false;
|
3309
|
+
}
|
3310
|
+
}
|
3311
|
+
this.setConsolidatedModels();
|
3312
|
+
this.ready = true;
|
3313
|
+
if (this.success != null) {
|
3314
|
+
return this.success();
|
3315
|
+
}
|
3316
|
+
};
|
3317
|
+
|
3318
|
+
SwaggerApi.prototype.fail = function(message) {
|
3319
|
+
this.failure(message);
|
3320
|
+
throw message;
|
3321
|
+
};
|
3322
|
+
|
3323
|
+
SwaggerApi.prototype.setConsolidatedModels = function() {
|
3324
|
+
var model, modelName, resource, resource_name, _i, _len, _ref, _ref1, _results;
|
3325
|
+
this.modelsArray = [];
|
3326
|
+
this.models = {};
|
3327
|
+
_ref = this.resources;
|
3328
|
+
for (resource_name in _ref) {
|
3329
|
+
resource = _ref[resource_name];
|
3330
|
+
for (modelName in resource.models) {
|
3331
|
+
if (!(this.models[modelName] != null)) {
|
3332
|
+
this.models[modelName] = resource.models[modelName];
|
3333
|
+
this.modelsArray.push(resource.models[modelName]);
|
3334
|
+
}
|
3335
|
+
}
|
3336
|
+
}
|
3337
|
+
_ref1 = this.modelsArray;
|
3338
|
+
_results = [];
|
3339
|
+
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
|
3340
|
+
model = _ref1[_i];
|
3341
|
+
_results.push(model.setReferencedModels(this.models));
|
3342
|
+
}
|
3343
|
+
return _results;
|
3344
|
+
};
|
3345
|
+
|
3346
|
+
SwaggerApi.prototype.suffixApiKey = function(url) {
|
3347
|
+
var sep;
|
3348
|
+
if ((this.api_key != null) && jQuery.trim(this.api_key).length > 0 && (url != null)) {
|
3349
|
+
sep = url.indexOf('?') > 0 ? '&' : '?';
|
3350
|
+
return url + sep + this.apiKeyName + '=' + this.api_key;
|
3351
|
+
} else {
|
3352
|
+
return url;
|
3353
|
+
}
|
3354
|
+
};
|
3355
|
+
|
3356
|
+
SwaggerApi.prototype.help = function() {
|
3357
|
+
var operation, operation_name, parameter, resource, resource_name, _i, _len, _ref, _ref1, _ref2;
|
3358
|
+
_ref = this.resources;
|
3359
|
+
for (resource_name in _ref) {
|
3360
|
+
resource = _ref[resource_name];
|
3361
|
+
console.log(resource_name);
|
3362
|
+
_ref1 = resource.operations;
|
3363
|
+
for (operation_name in _ref1) {
|
3364
|
+
operation = _ref1[operation_name];
|
3365
|
+
console.log(" " + operation.nickname);
|
3366
|
+
_ref2 = operation.parameters;
|
3367
|
+
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
|
3368
|
+
parameter = _ref2[_i];
|
3369
|
+
console.log(" " + parameter.name + (parameter.required ? ' (required)' : '') + " - " + parameter.description);
|
3370
|
+
}
|
3371
|
+
}
|
3372
|
+
}
|
3373
|
+
return this;
|
3374
|
+
};
|
3375
|
+
|
3376
|
+
return SwaggerApi;
|
3377
|
+
|
3378
|
+
})();
|
3379
|
+
|
3380
|
+
SwaggerResource = (function() {
|
3381
|
+
|
3382
|
+
function SwaggerResource(resourceObj, api) {
|
3383
|
+
var parts,
|
3384
|
+
_this = this;
|
3385
|
+
this.api = api;
|
3386
|
+
this.path = this.api.resourcePath != null ? this.api.resourcePath : resourceObj.path;
|
3387
|
+
this.description = resourceObj.description;
|
3388
|
+
parts = this.path.split("/");
|
3389
|
+
this.name = parts[parts.length - 1].replace('.{format}', '');
|
3390
|
+
this.basePath = this.api.basePath;
|
3391
|
+
this.operations = {};
|
3392
|
+
this.operationsArray = [];
|
3393
|
+
this.modelsArray = [];
|
3394
|
+
this.models = {};
|
3395
|
+
if ((resourceObj.operations != null) && (this.api.resourcePath != null)) {
|
3396
|
+
this.api.progress('reading resource ' + this.name + ' models and operations');
|
3397
|
+
this.addModels(resourceObj.models);
|
3398
|
+
this.addOperations(resourceObj.path, resourceObj.operations);
|
3399
|
+
this.api[this.name] = this;
|
3400
|
+
} else {
|
3401
|
+
if (this.path == null) {
|
3402
|
+
this.api.fail("SwaggerResources must have a path.");
|
3403
|
+
}
|
3404
|
+
this.url = this.api.suffixApiKey(this.api.basePath + this.path.replace('{format}', 'json'));
|
3405
|
+
this.api.progress('fetching resource ' + this.name + ': ' + this.url);
|
3406
|
+
jQuery.getJSON(this.url, function(response) {
|
3407
|
+
var endpoint, _i, _len, _ref;
|
3408
|
+
if ((response.basePath != null) && jQuery.trim(response.basePath).length > 0) {
|
3409
|
+
_this.basePath = response.basePath;
|
3410
|
+
_this.basePath = _this.basePath.replace(/\/$/, '');
|
3411
|
+
}
|
3412
|
+
_this.addModels(response.models);
|
3413
|
+
if (response.apis) {
|
3414
|
+
_ref = response.apis;
|
3415
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
3416
|
+
endpoint = _ref[_i];
|
3417
|
+
_this.addOperations(endpoint.path, endpoint.operations);
|
3418
|
+
}
|
3419
|
+
}
|
3420
|
+
_this.api[_this.name] = _this;
|
3421
|
+
_this.ready = true;
|
3422
|
+
return _this.api.selfReflect();
|
3423
|
+
}).error(function(error) {
|
3424
|
+
return _this.api.fail(error.status + ' : ' + error.statusText + ' ' + _this.url);
|
3425
|
+
});
|
3426
|
+
}
|
3427
|
+
}
|
3428
|
+
|
3429
|
+
SwaggerResource.prototype.addModels = function(models) {
|
3430
|
+
var model, modelName, swaggerModel, _i, _len, _ref, _results;
|
3431
|
+
if (models != null) {
|
3432
|
+
for (modelName in models) {
|
3433
|
+
if (!(this.models[modelName] != null)) {
|
3434
|
+
swaggerModel = new SwaggerModel(modelName, models[modelName]);
|
3435
|
+
this.modelsArray.push(swaggerModel);
|
3436
|
+
this.models[modelName] = swaggerModel;
|
3437
|
+
}
|
3438
|
+
}
|
3439
|
+
_ref = this.modelsArray;
|
3440
|
+
_results = [];
|
3441
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
3442
|
+
model = _ref[_i];
|
3443
|
+
_results.push(model.setReferencedModels(this.models));
|
3444
|
+
}
|
3445
|
+
return _results;
|
3446
|
+
}
|
3447
|
+
};
|
3448
|
+
|
3449
|
+
SwaggerResource.prototype.addOperations = function(resource_path, ops) {
|
3450
|
+
var o, op, _i, _len, _results;
|
3451
|
+
if (ops) {
|
3452
|
+
_results = [];
|
3453
|
+
for (_i = 0, _len = ops.length; _i < _len; _i++) {
|
3454
|
+
o = ops[_i];
|
3455
|
+
op = new SwaggerOperation(o.nickname, resource_path, o.httpMethod, o.parameters, o.summary, o.notes, o.responseClass, o.errorResponses, this, o.supportedContentTypes);
|
3456
|
+
this.operations[op.nickname] = op;
|
3457
|
+
_results.push(this.operationsArray.push(op));
|
3458
|
+
}
|
3459
|
+
return _results;
|
3460
|
+
}
|
3461
|
+
};
|
3462
|
+
|
3463
|
+
SwaggerResource.prototype.help = function() {
|
3464
|
+
var operation, operation_name, parameter, _i, _len, _ref, _ref1;
|
3465
|
+
_ref = this.operations;
|
3466
|
+
for (operation_name in _ref) {
|
3467
|
+
operation = _ref[operation_name];
|
3468
|
+
console.log(" " + operation.nickname);
|
3469
|
+
_ref1 = operation.parameters;
|
3470
|
+
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
|
3471
|
+
parameter = _ref1[_i];
|
3472
|
+
console.log(" " + parameter.name + (parameter.required ? ' (required)' : '') + " - " + parameter.description);
|
3473
|
+
}
|
3474
|
+
}
|
3475
|
+
return this;
|
3476
|
+
};
|
3477
|
+
|
3478
|
+
return SwaggerResource;
|
3479
|
+
|
3480
|
+
})();
|
3481
|
+
|
3482
|
+
SwaggerModel = (function() {
|
3483
|
+
|
3484
|
+
function SwaggerModel(modelName, obj) {
|
3485
|
+
var propertyName;
|
3486
|
+
this.name = obj.id != null ? obj.id : modelName;
|
3487
|
+
this.properties = [];
|
3488
|
+
for (propertyName in obj.properties) {
|
3489
|
+
this.properties.push(new SwaggerModelProperty(propertyName, obj.properties[propertyName]));
|
3490
|
+
}
|
3491
|
+
}
|
3492
|
+
|
3493
|
+
SwaggerModel.prototype.setReferencedModels = function(allModels) {
|
3494
|
+
var prop, _i, _len, _ref, _results;
|
3495
|
+
_ref = this.properties;
|
3496
|
+
_results = [];
|
3497
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
3498
|
+
prop = _ref[_i];
|
3499
|
+
if (allModels[prop.dataType] != null) {
|
3500
|
+
_results.push(prop.refModel = allModels[prop.dataType]);
|
3501
|
+
} else if ((prop.refDataType != null) && (allModels[prop.refDataType] != null)) {
|
3502
|
+
_results.push(prop.refModel = allModels[prop.refDataType]);
|
3503
|
+
} else {
|
3504
|
+
_results.push(void 0);
|
3505
|
+
}
|
3506
|
+
}
|
3507
|
+
return _results;
|
3508
|
+
};
|
3509
|
+
|
3510
|
+
SwaggerModel.prototype.getMockSignature = function(prefix, modelToIgnore) {
|
3511
|
+
var classClose, classOpen, prop, propertiesStr, returnVal, strong, strongClose, stronger, _i, _j, _len, _len1, _ref, _ref1;
|
3512
|
+
propertiesStr = [];
|
3513
|
+
_ref = this.properties;
|
3514
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
3515
|
+
prop = _ref[_i];
|
3516
|
+
propertiesStr.push(prop.toString());
|
3517
|
+
}
|
3518
|
+
strong = '<span style="font-weight: bold; color: #000; font-size: 1.0em">';
|
3519
|
+
stronger = '<span style="font-weight: bold; color: #000; font-size: 1.1em">';
|
3520
|
+
strongClose = '</span>';
|
3521
|
+
classOpen = strong + 'class ' + this.name + '(' + strongClose;
|
3522
|
+
classClose = strong + ')' + strongClose;
|
3523
|
+
returnVal = classOpen + '<span>' + propertiesStr.join('</span>, <span>') + '</span>' + classClose;
|
3524
|
+
if (prefix != null) {
|
3525
|
+
returnVal = stronger + prefix + strongClose + '<br/>' + returnVal;
|
3526
|
+
}
|
3527
|
+
_ref1 = this.properties;
|
3528
|
+
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
|
3529
|
+
prop = _ref1[_j];
|
3530
|
+
if ((prop.refModel != null) && (!(prop.refModel === modelToIgnore))) {
|
3531
|
+
returnVal = returnVal + ('<br>' + prop.refModel.getMockSignature(void 0, this));
|
3532
|
+
}
|
3533
|
+
}
|
3534
|
+
return returnVal;
|
3535
|
+
};
|
3536
|
+
|
3537
|
+
SwaggerModel.prototype.createJSONSample = function(modelToIgnore) {
|
3538
|
+
var prop, result, _i, _len, _ref;
|
3539
|
+
result = {};
|
3540
|
+
_ref = this.properties;
|
3541
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
3542
|
+
prop = _ref[_i];
|
3543
|
+
result[prop.name] = prop.getSampleValue(modelToIgnore);
|
3544
|
+
}
|
3545
|
+
return result;
|
3546
|
+
};
|
3547
|
+
|
3548
|
+
return SwaggerModel;
|
3549
|
+
|
3550
|
+
})();
|
3551
|
+
|
3552
|
+
SwaggerModelProperty = (function() {
|
3553
|
+
|
3554
|
+
function SwaggerModelProperty(name, obj) {
|
3555
|
+
this.name = name;
|
3556
|
+
this.dataType = obj.type;
|
3557
|
+
this.isArray = this.dataType.toLowerCase() === 'array';
|
3558
|
+
this.descr = obj.description;
|
3559
|
+
if (obj.items != null) {
|
3560
|
+
if (obj.items.type != null) {
|
3561
|
+
this.refDataType = obj.items.type;
|
3562
|
+
}
|
3563
|
+
if (obj.items.$ref != null) {
|
3564
|
+
this.refDataType = obj.items.$ref;
|
3565
|
+
}
|
3566
|
+
}
|
3567
|
+
this.dataTypeWithRef = this.refDataType != null ? this.dataType + '[' + this.refDataType + ']' : this.dataType;
|
3568
|
+
if (obj.allowableValues != null) {
|
3569
|
+
this.valueType = obj.allowableValues.valueType;
|
3570
|
+
this.values = obj.allowableValues.values;
|
3571
|
+
if (this.values != null) {
|
3572
|
+
this.valuesString = "'" + this.values.join("' or '") + "'";
|
3573
|
+
}
|
3574
|
+
}
|
3575
|
+
}
|
3576
|
+
|
3577
|
+
SwaggerModelProperty.prototype.getSampleValue = function(modelToIgnore) {
|
3578
|
+
var result;
|
3579
|
+
if ((this.refModel != null) && (!(this.refModel === modelToIgnore))) {
|
3580
|
+
result = this.refModel.createJSONSample(this.refModel);
|
3581
|
+
} else {
|
3582
|
+
if (this.isArray) {
|
3583
|
+
result = this.refDataType;
|
3584
|
+
} else {
|
3585
|
+
result = this.dataType;
|
3586
|
+
}
|
3587
|
+
}
|
3588
|
+
if (this.isArray) {
|
3589
|
+
return [result];
|
3590
|
+
} else {
|
3591
|
+
return result;
|
3592
|
+
}
|
3593
|
+
};
|
3594
|
+
|
3595
|
+
SwaggerModelProperty.prototype.toString = function() {
|
3596
|
+
var str;
|
3597
|
+
str = this.name + ': ' + this.dataTypeWithRef;
|
3598
|
+
if (this.values != null) {
|
3599
|
+
str += " = ['" + this.values.join("' or '") + "']";
|
3600
|
+
}
|
3601
|
+
if (this.descr != null) {
|
3602
|
+
str += ' {' + this.descr + '}';
|
3603
|
+
}
|
3604
|
+
return str;
|
3605
|
+
};
|
3606
|
+
|
3607
|
+
return SwaggerModelProperty;
|
3608
|
+
|
3609
|
+
})();
|
3610
|
+
|
3611
|
+
SwaggerOperation = (function() {
|
3612
|
+
|
3613
|
+
function SwaggerOperation(nickname, path, httpMethod, parameters, summary, notes, responseClass, errorResponses, resource, supportedContentTypes) {
|
3614
|
+
var parameter, v, _i, _j, _len, _len1, _ref, _ref1, _ref2,
|
3615
|
+
_this = this;
|
3616
|
+
this.nickname = nickname;
|
3617
|
+
this.path = path;
|
3618
|
+
this.httpMethod = httpMethod;
|
3619
|
+
this.parameters = parameters != null ? parameters : [];
|
3620
|
+
this.summary = summary;
|
3621
|
+
this.notes = notes;
|
3622
|
+
this.responseClass = responseClass;
|
3623
|
+
this.errorResponses = errorResponses;
|
3624
|
+
this.resource = resource;
|
3625
|
+
this.supportedContentTypes = supportedContentTypes;
|
3626
|
+
this["do"] = __bind(this["do"], this);
|
3627
|
+
|
3628
|
+
if (this.nickname == null) {
|
3629
|
+
this.resource.api.fail("SwaggerOperations must have a nickname.");
|
3630
|
+
}
|
3631
|
+
if (this.path == null) {
|
3632
|
+
this.resource.api.fail("SwaggerOperation " + nickname + " is missing path.");
|
3633
|
+
}
|
3634
|
+
if (this.httpMethod == null) {
|
3635
|
+
this.resource.api.fail("SwaggerOperation " + nickname + " is missing httpMethod.");
|
3636
|
+
}
|
3637
|
+
this.path = this.path.replace('{format}', 'json');
|
3638
|
+
this.httpMethod = this.httpMethod.toLowerCase();
|
3639
|
+
this.isGetMethod = this.httpMethod === "get";
|
3640
|
+
this.resourceName = this.resource.name;
|
3641
|
+
if (((_ref = this.responseClass) != null ? _ref.toLowerCase() : void 0) === 'void') {
|
3642
|
+
this.responseClass = void 0;
|
3643
|
+
}
|
3644
|
+
if (this.responseClass != null) {
|
3645
|
+
this.responseClassSignature = this.getSignature(this.responseClass, this.resource.models);
|
3646
|
+
this.responseSampleJSON = this.getSampleJSON(this.responseClass, this.resource.models);
|
3647
|
+
}
|
3648
|
+
this.errorResponses = this.errorResponses || [];
|
3649
|
+
_ref1 = this.parameters;
|
3650
|
+
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
|
3651
|
+
parameter = _ref1[_i];
|
3652
|
+
parameter.name = parameter.name || parameter.dataType;
|
3653
|
+
if (parameter.dataType.toLowerCase() === 'boolean') {
|
3654
|
+
parameter.allowableValues = {};
|
3655
|
+
parameter.allowableValues.values = this.resource.api.booleanValues;
|
3656
|
+
}
|
3657
|
+
parameter.signature = this.getSignature(parameter.dataType, this.resource.models);
|
3658
|
+
parameter.sampleJSON = this.getSampleJSON(parameter.dataType, this.resource.models);
|
3659
|
+
if (parameter.allowableValues != null) {
|
3660
|
+
if (parameter.allowableValues.valueType === "RANGE") {
|
3661
|
+
parameter.isRange = true;
|
3662
|
+
} else {
|
3663
|
+
parameter.isList = true;
|
3664
|
+
}
|
3665
|
+
if (parameter.allowableValues.values != null) {
|
3666
|
+
parameter.allowableValues.descriptiveValues = [];
|
3667
|
+
_ref2 = parameter.allowableValues.values;
|
3668
|
+
for (_j = 0, _len1 = _ref2.length; _j < _len1; _j++) {
|
3669
|
+
v = _ref2[_j];
|
3670
|
+
if ((parameter.defaultValue != null) && parameter.defaultValue === v) {
|
3671
|
+
parameter.allowableValues.descriptiveValues.push({
|
3672
|
+
value: v,
|
3673
|
+
isDefault: true
|
3674
|
+
});
|
3675
|
+
} else {
|
3676
|
+
parameter.allowableValues.descriptiveValues.push({
|
3677
|
+
value: v,
|
3678
|
+
isDefault: false
|
3679
|
+
});
|
3680
|
+
}
|
3681
|
+
}
|
3682
|
+
}
|
3683
|
+
}
|
3684
|
+
}
|
3685
|
+
this.resource[this.nickname] = function(args, callback, error) {
|
3686
|
+
return _this["do"](args, callback, error);
|
3687
|
+
};
|
3688
|
+
}
|
3689
|
+
|
3690
|
+
SwaggerOperation.prototype.isListType = function(dataType) {
|
3691
|
+
if (dataType.indexOf('[') >= 0) {
|
3692
|
+
return dataType.substring(dataType.indexOf('[') + 1, dataType.indexOf(']'));
|
3693
|
+
} else {
|
3694
|
+
return void 0;
|
3695
|
+
}
|
3696
|
+
};
|
3697
|
+
|
3698
|
+
SwaggerOperation.prototype.getSignature = function(dataType, models) {
|
3699
|
+
var isPrimitive, listType;
|
3700
|
+
listType = this.isListType(dataType);
|
3701
|
+
isPrimitive = ((listType != null) && models[listType]) || (models[dataType] != null) ? false : true;
|
3702
|
+
if (isPrimitive) {
|
3703
|
+
return dataType;
|
3704
|
+
} else {
|
3705
|
+
if (listType != null) {
|
3706
|
+
return models[listType].getMockSignature(dataType);
|
3707
|
+
} else {
|
3708
|
+
return models[dataType].getMockSignature(dataType);
|
3709
|
+
}
|
3710
|
+
}
|
3711
|
+
};
|
3712
|
+
|
3713
|
+
SwaggerOperation.prototype.getSampleJSON = function(dataType, models) {
|
3714
|
+
var isPrimitive, listType, val;
|
3715
|
+
listType = this.isListType(dataType);
|
3716
|
+
isPrimitive = ((listType != null) && models[listType]) || (models[dataType] != null) ? false : true;
|
3717
|
+
val = isPrimitive ? void 0 : (listType != null ? models[listType].createJSONSample() : models[dataType].createJSONSample());
|
3718
|
+
if (val) {
|
3719
|
+
val = listType ? [val] : val;
|
3720
|
+
return JSON.stringify(val, null, 2);
|
3721
|
+
}
|
3722
|
+
};
|
3723
|
+
|
3724
|
+
SwaggerOperation.prototype["do"] = function(args, callback, error) {
|
3725
|
+
var body, headers;
|
3726
|
+
if (args == null) {
|
3727
|
+
args = {};
|
3728
|
+
}
|
3729
|
+
if ((typeof args) === "function") {
|
3730
|
+
error = callback;
|
3731
|
+
callback = args;
|
3732
|
+
args = {};
|
3733
|
+
}
|
3734
|
+
if (error == null) {
|
3735
|
+
error = function(xhr, textStatus, error) {
|
3736
|
+
return console.log(xhr, textStatus, error);
|
3737
|
+
};
|
3738
|
+
}
|
3739
|
+
if (callback == null) {
|
3740
|
+
callback = function(data) {
|
3741
|
+
return console.log(data);
|
3742
|
+
};
|
3743
|
+
}
|
3744
|
+
if (args.headers != null) {
|
3745
|
+
headers = args.headers;
|
3746
|
+
delete args.headers;
|
3747
|
+
}
|
3748
|
+
if (args.body != null) {
|
3749
|
+
body = args.body;
|
3750
|
+
delete args.body;
|
3751
|
+
}
|
3752
|
+
return new SwaggerRequest(this.httpMethod, this.urlify(args), headers, body, callback, error, this);
|
3753
|
+
};
|
3754
|
+
|
3755
|
+
SwaggerOperation.prototype.pathJson = function() {
|
3756
|
+
return this.path.replace("{format}", "json");
|
3757
|
+
};
|
3758
|
+
|
3759
|
+
SwaggerOperation.prototype.pathXml = function() {
|
3760
|
+
return this.path.replace("{format}", "xml");
|
3761
|
+
};
|
3762
|
+
|
3763
|
+
SwaggerOperation.prototype.urlify = function(args, includeApiKey) {
|
3764
|
+
var param, queryParams, reg, url, _i, _len, _ref;
|
3765
|
+
if (includeApiKey == null) {
|
3766
|
+
includeApiKey = true;
|
3767
|
+
}
|
3768
|
+
url = this.resource.basePath + this.pathJson();
|
3769
|
+
_ref = this.parameters;
|
3770
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
3771
|
+
param = _ref[_i];
|
3772
|
+
if (param.paramType === 'path') {
|
3773
|
+
if (args[param.name]) {
|
3774
|
+
reg = new RegExp('\{' + param.name + '[^\}]*\}', 'gi');
|
3775
|
+
url = url.replace(reg, encodeURIComponent(args[param.name]));
|
3776
|
+
delete args[param.name];
|
3777
|
+
} else {
|
3778
|
+
throw "" + param.name + " is a required path param.";
|
3779
|
+
}
|
3780
|
+
}
|
3781
|
+
}
|
3782
|
+
if (includeApiKey && (this.resource.api.api_key != null) && this.resource.api.api_key.length > 0) {
|
3783
|
+
args[this.apiKeyName] = this.resource.api.api_key;
|
3784
|
+
}
|
3785
|
+
if (this.supportHeaderParams()) {
|
3786
|
+
queryParams = jQuery.param(this.getQueryParams(args, includeApiKey));
|
3787
|
+
} else {
|
3788
|
+
queryParams = jQuery.param(this.getQueryAndHeaderParams(args, includeApiKey));
|
3789
|
+
}
|
3790
|
+
if ((queryParams != null) && queryParams.length > 0) {
|
3791
|
+
url += "?" + queryParams;
|
3792
|
+
}
|
3793
|
+
return url;
|
3794
|
+
};
|
3795
|
+
|
3796
|
+
SwaggerOperation.prototype.supportHeaderParams = function() {
|
3797
|
+
return this.resource.api.supportHeaderParams;
|
3798
|
+
};
|
3799
|
+
|
3800
|
+
SwaggerOperation.prototype.supportedSubmitMethods = function() {
|
3801
|
+
return this.resource.api.supportedSubmitMethods;
|
3802
|
+
};
|
3803
|
+
|
3804
|
+
SwaggerOperation.prototype.getQueryAndHeaderParams = function(args, includeApiKey) {
|
3805
|
+
if (includeApiKey == null) {
|
3806
|
+
includeApiKey = true;
|
3807
|
+
}
|
3808
|
+
return this.getMatchingParams(['query', 'header'], args, includeApiKey);
|
3809
|
+
};
|
3810
|
+
|
3811
|
+
SwaggerOperation.prototype.getQueryParams = function(args, includeApiKey) {
|
3812
|
+
if (includeApiKey == null) {
|
3813
|
+
includeApiKey = true;
|
3814
|
+
}
|
3815
|
+
return this.getMatchingParams(['query'], args, includeApiKey);
|
3816
|
+
};
|
3817
|
+
|
3818
|
+
SwaggerOperation.prototype.getHeaderParams = function(args, includeApiKey) {
|
3819
|
+
if (includeApiKey == null) {
|
3820
|
+
includeApiKey = true;
|
3821
|
+
}
|
3822
|
+
return this.getMatchingParams(['header'], args, includeApiKey);
|
3823
|
+
};
|
3824
|
+
|
3825
|
+
SwaggerOperation.prototype.getMatchingParams = function(paramTypes, args, includeApiKey) {
|
3826
|
+
var matchingParams, name, param, value, _i, _len, _ref, _ref1;
|
3827
|
+
matchingParams = {};
|
3828
|
+
_ref = this.parameters;
|
3829
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
3830
|
+
param = _ref[_i];
|
3831
|
+
if ((jQuery.inArray(param.paramType, paramTypes) >= 0) && args[param.name]) {
|
3832
|
+
matchingParams[param.name] = args[param.name];
|
3833
|
+
}
|
3834
|
+
}
|
3835
|
+
if (includeApiKey && (this.resource.api.api_key != null) && this.resource.api.api_key.length > 0) {
|
3836
|
+
matchingParams[this.resource.api.apiKeyName] = this.resource.api.api_key;
|
3837
|
+
}
|
3838
|
+
if (jQuery.inArray('header', paramTypes) >= 0) {
|
3839
|
+
_ref1 = this.resource.api.headers;
|
3840
|
+
for (name in _ref1) {
|
3841
|
+
value = _ref1[name];
|
3842
|
+
matchingParams[name] = value;
|
3843
|
+
}
|
3844
|
+
}
|
3845
|
+
return matchingParams;
|
3846
|
+
};
|
3847
|
+
|
3848
|
+
SwaggerOperation.prototype.help = function() {
|
3849
|
+
var parameter, _i, _len, _ref;
|
3850
|
+
_ref = this.parameters;
|
3851
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
3852
|
+
parameter = _ref[_i];
|
3853
|
+
console.log(" " + parameter.name + (parameter.required ? ' (required)' : '') + " - " + parameter.description);
|
3854
|
+
}
|
3855
|
+
return this;
|
3856
|
+
};
|
3857
|
+
|
3858
|
+
return SwaggerOperation;
|
3859
|
+
|
3860
|
+
})();
|
3861
|
+
|
3862
|
+
SwaggerRequest = (function() {
|
3863
|
+
|
3864
|
+
function SwaggerRequest(type, url, headers, body, successCallback, errorCallback, operation) {
|
3865
|
+
var obj,
|
3866
|
+
_this = this;
|
3867
|
+
this.type = type;
|
3868
|
+
this.url = url;
|
3869
|
+
this.headers = headers;
|
3870
|
+
this.body = body;
|
3871
|
+
this.successCallback = successCallback;
|
3872
|
+
this.errorCallback = errorCallback;
|
3873
|
+
this.operation = operation;
|
3874
|
+
if (this.type == null) {
|
3875
|
+
throw "SwaggerRequest type is required (get/post/put/delete).";
|
3876
|
+
}
|
3877
|
+
if (this.url == null) {
|
3878
|
+
throw "SwaggerRequest url is required.";
|
3879
|
+
}
|
3880
|
+
if (this.successCallback == null) {
|
3881
|
+
throw "SwaggerRequest successCallback is required.";
|
3882
|
+
}
|
3883
|
+
if (this.errorCallback == null) {
|
3884
|
+
throw "SwaggerRequest error callback is required.";
|
3885
|
+
}
|
3886
|
+
if (this.operation == null) {
|
3887
|
+
throw "SwaggerRequest operation is required.";
|
3888
|
+
}
|
3889
|
+
if (this.operation.resource.api.verbose) {
|
3890
|
+
console.log(this.asCurl());
|
3891
|
+
}
|
3892
|
+
this.headers || (this.headers = {});
|
3893
|
+
if (this.operation.resource.api.api_key != null) {
|
3894
|
+
this.headers[this.apiKeyName] = this.operation.resource.api.api_key;
|
3895
|
+
}
|
3896
|
+
if (this.headers.mock == null) {
|
3897
|
+
obj = {
|
3898
|
+
type: this.type,
|
3899
|
+
url: this.url,
|
3900
|
+
data: JSON.stringify(this.body),
|
3901
|
+
dataType: 'json',
|
3902
|
+
error: function(xhr, textStatus, error) {
|
3903
|
+
return _this.errorCallback(xhr, textStatus, error);
|
3904
|
+
},
|
3905
|
+
success: function(data) {
|
3906
|
+
return _this.successCallback(data);
|
3907
|
+
}
|
3908
|
+
};
|
3909
|
+
if (obj.type.toLowerCase() === "post" || obj.type.toLowerCase() === "put") {
|
3910
|
+
obj.contentType = "application/json";
|
3911
|
+
}
|
3912
|
+
jQuery.ajax(obj);
|
3913
|
+
}
|
3914
|
+
}
|
3915
|
+
|
3916
|
+
SwaggerRequest.prototype.asCurl = function() {
|
3917
|
+
var header_args, k, v;
|
3918
|
+
header_args = (function() {
|
3919
|
+
var _ref, _results;
|
3920
|
+
_ref = this.headers;
|
3921
|
+
_results = [];
|
3922
|
+
for (k in _ref) {
|
3923
|
+
v = _ref[k];
|
3924
|
+
_results.push("--header \"" + k + ": " + v + "\"");
|
3925
|
+
}
|
3926
|
+
return _results;
|
3927
|
+
}).call(this);
|
3928
|
+
return "curl " + (header_args.join(" ")) + " " + this.url;
|
3929
|
+
};
|
3930
|
+
|
3931
|
+
return SwaggerRequest;
|
3932
|
+
|
3933
|
+
})();
|
3934
|
+
|
3935
|
+
window.SwaggerApi = SwaggerApi;
|
3936
|
+
|
3937
|
+
window.SwaggerResource = SwaggerResource;
|
3938
|
+
|
3939
|
+
window.SwaggerOperation = SwaggerOperation;
|
3940
|
+
|
3941
|
+
window.SwaggerRequest = SwaggerRequest;
|
3942
|
+
|
3943
|
+
}).call(this);
|