· 8 years ago · Jan 24, 2017, 04:38 PM
1/*! jQuery v1.10.2 | (c) 2005, 2013 jQuery Foundation, Inc. | jquery.org/license
2//@ sourceMappingURL=jquery-1.10.2.min.map
3*/
4(function(e,t){var n,r,i=typeof t,o=e.location,a=e.document,s=a.documentElement,l=e.jQuery,u=e.$,c={},p=[],f="1.10.2",d=p.concat,h=p.push,g=p.slice,m=p.indexOf,y=c.toString,v=c.hasOwnProperty,b=f.trim,x=function(e,t){return new x.fn.init(e,t,r)},w=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,T=/\S+/g,C=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,N=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,k=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,E=/^[\],:{}\s]*$/,S=/(?:^|:|,)(?:\s*\[)+/g,A=/\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,j=/"[^"\\\r\n]*"|true|false|null|-?(?:\d+\.|)\d+(?:[eE][+-]?\d+|)/g,D=/^-ms-/,L=/-([\da-z])/gi,H=function(e,t){return t.toUpperCase()},q=function(e){(a.addEventListener||"load"===e.type||"complete"===a.readyState)&&(_(),x.ready())},_=function(){a.addEventListener?(a.removeEventListener("DOMContentLoaded",q,!1),e.removeEventListener("load",q,!1)):(a.detachEvent("onreadystatechange",q),e.detachEvent("onload",q))};x.fn=x.prototype={jquery:f,constructor:x,init:function(e,n,r){var i,o;if(!e)return this;if("string"==typeof e){if(i="<"===e.charAt(0)&&">"===e.charAt(e.length-1)&&e.length>=3?[null,e,null]:N.exec(e),!i||!i[1]&&n)return!n||n.jquery?(n||r).find(e):this.constructor(n).find(e);if(i[1]){if(n=n instanceof x?n[0]:n,x.merge(this,x.parseHTML(i[1],n&&n.nodeType?n.ownerDocument||n:a,!0)),k.test(i[1])&&x.isPlainObject(n))for(i in n)x.isFunction(this[i])?this[i](n[i]):this.attr(i,n[i]);return this}if(o=a.getElementById(i[2]),o&&o.parentNode){if(o.id!==i[2])return r.find(e);this.length=1,this[0]=o}return this.context=a,this.selector=e,this}return e.nodeType?(this.context=this[0]=e,this.length=1,this):x.isFunction(e)?r.ready(e):(e.selector!==t&&(this.selector=e.selector,this.context=e.context),x.makeArray(e,this))},selector:"",length:0,toArray:function(){return g.call(this)},get:function(e){return null==e?this.toArray():0>e?this[this.length+e]:this[e]},pushStack:function(e){var t=x.merge(this.constructor(),e);return t.prevObject=this,t.context=this.context,t},each:function(e,t){return x.each(this,e,t)},ready:function(e){return x.ready.promise().done(e),this},slice:function(){return this.pushStack(g.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(e){var t=this.length,n=+e+(0>e?t:0);return this.pushStack(n>=0&&t>n?[this[n]]:[])},map:function(e){return this.pushStack(x.map(this,function(t,n){return e.call(t,n,t)}))},end:function(){return this.prevObject||this.constructor(null)},push:h,sort:[].sort,splice:[].splice},x.fn.init.prototype=x.fn,x.extend=x.fn.extend=function(){var e,n,r,i,o,a,s=arguments[0]||{},l=1,u=arguments.length,c=!1;for("boolean"==typeof s&&(c=s,s=arguments[1]||{},l=2),"object"==typeof s||x.isFunction(s)||(s={}),u===l&&(s=this,--l);u>l;l++)if(null!=(o=arguments[l]))for(i in o)e=s[i],r=o[i],s!==r&&(c&&r&&(x.isPlainObject(r)||(n=x.isArray(r)))?(n?(n=!1,a=e&&x.isArray(e)?e:[]):a=e&&x.isPlainObject(e)?e:{},s[i]=x.extend(c,a,r)):r!==t&&(s[i]=r));return s},x.extend({expando:"jQuery"+(f+Math.random()).replace(/\D/g,""),noConflict:function(t){return e.$===x&&(e.$=u),t&&e.jQuery===x&&(e.jQuery=l),x},isReady:!1,readyWait:1,holdReady:function(e){e?x.readyWait++:x.ready(!0)},ready:function(e){if(e===!0?!--x.readyWait:!x.isReady){if(!a.body)return setTimeout(x.ready);x.isReady=!0,e!==!0&&--x.readyWait>0||(n.resolveWith(a,[x]),x.fn.trigger&&x(a).trigger("ready").off("ready"))}},isFunction:function(e){return"function"===x.type(e)},isArray:Array.isArray||function(e){return"array"===x.type(e)},isWindow:function(e){return null!=e&&e==e.window},isNumeric:function(e){return!isNaN(parseFloat(e))&&isFinite(e)},type:function(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?c[y.call(e)]||"object":typeof e},isPlainObject:function(e){var n;if(!e||"object"!==x.type(e)||e.nodeType||x.isWindow(e))return!1;try{if(e.constructor&&!v.call(e,"constructor")&&!v.call(e.constructor.prototype,"isPrototypeOf"))return!1}catch(r){return!1}if(x.support.ownLast)for(n in e)return v.call(e,n);for(n in e);return n===t||v.call(e,n)},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},error:function(e){throw Error(e)},parseHTML:function(e,t,n){if(!e||"string"!=typeof e)return null;"boolean"==typeof t&&(n=t,t=!1),t=t||a;var r=k.exec(e),i=!n&&[];return r?[t.createElement(r[1])]:(r=x.buildFragment([e],t,i),i&&x(i).remove(),x.merge([],r.childNodes))},parseJSON:function(n){return e.JSON&&e.JSON.parse?e.JSON.parse(n):null===n?n:"string"==typeof n&&(n=x.trim(n),n&&E.test(n.replace(A,"@").replace(j,"]").replace(S,"")))?Function("return "+n)():(x.error("Invalid JSON: "+n),t)},parseXML:function(n){var r,i;if(!n||"string"!=typeof n)return null;try{e.DOMParser?(i=new DOMParser,r=i.parseFromString(n,"text/xml")):(r=new ActiveXObject("Microsoft.XMLDOM"),r.async="false",r.loadXML(n))}catch(o){r=t}return r&&r.documentElement&&!r.getElementsByTagName("parsererror").length||x.error("Invalid XML: "+n),r},noop:function(){},globalEval:function(t){t&&x.trim(t)&&(e.execScript||function(t){e.eval.call(e,t)})(t)},camelCase:function(e){return e.replace(D,"ms-").replace(L,H)},nodeName:function(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()},each:function(e,t,n){var r,i=0,o=e.length,a=M(e);if(n){if(a){for(;o>i;i++)if(r=t.apply(e[i],n),r===!1)break}else for(i in e)if(r=t.apply(e[i],n),r===!1)break}else if(a){for(;o>i;i++)if(r=t.call(e[i],i,e[i]),r===!1)break}else for(i in e)if(r=t.call(e[i],i,e[i]),r===!1)break;return e},trim:b&&!b.call("\ufeff\u00a0")?function(e){return null==e?"":b.call(e)}:function(e){return null==e?"":(e+"").replace(C,"")},makeArray:function(e,t){var n=t||[];return null!=e&&(M(Object(e))?x.merge(n,"string"==typeof e?[e]:e):h.call(n,e)),n},inArray:function(e,t,n){var r;if(t){if(m)return m.call(t,e,n);for(r=t.length,n=n?0>n?Math.max(0,r+n):n:0;r>n;n++)if(n in t&&t[n]===e)return n}return-1},merge:function(e,n){var r=n.length,i=e.length,o=0;if("number"==typeof r)for(;r>o;o++)e[i++]=n[o];else while(n[o]!==t)e[i++]=n[o++];return e.length=i,e},grep:function(e,t,n){var r,i=[],o=0,a=e.length;for(n=!!n;a>o;o++)r=!!t(e[o],o),n!==r&&i.push(e[o]);return i},map:function(e,t,n){var r,i=0,o=e.length,a=M(e),s=[];if(a)for(;o>i;i++)r=t(e[i],i,n),null!=r&&(s[s.length]=r);else for(i in e)r=t(e[i],i,n),null!=r&&(s[s.length]=r);return d.apply([],s)},guid:1,proxy:function(e,n){var r,i,o;return"string"==typeof n&&(o=e[n],n=e,e=o),x.isFunction(e)?(r=g.call(arguments,2),i=function(){return e.apply(n||this,r.concat(g.call(arguments)))},i.guid=e.guid=e.guid||x.guid++,i):t},access:function(e,n,r,i,o,a,s){var l=0,u=e.length,c=null==r;if("object"===x.type(r)){o=!0;for(l in r)x.access(e,n,l,r[l],!0,a,s)}else if(i!==t&&(o=!0,x.isFunction(i)||(s=!0),c&&(s?(n.call(e,i),n=null):(c=n,n=function(e,t,n){return c.call(x(e),n)})),n))for(;u>l;l++)n(e[l],r,s?i:i.call(e[l],l,n(e[l],r)));return o?e:c?n.call(e):u?n(e[0],r):a},now:function(){return(new Date).getTime()},swap:function(e,t,n,r){var i,o,a={};for(o in t)a[o]=e.style[o],e.style[o]=t[o];i=n.apply(e,r||[]);for(o in t)e.style[o]=a[o];return i}}),x.ready.promise=function(t){if(!n)if(n=x.Deferred(),"complete"===a.readyState)setTimeout(x.ready);else if(a.addEventListener)a.addEventListener("DOMContentLoaded",q,!1),e.addEventListener("load",q,!1);else{a.attachEvent("onreadystatechange",q),e.attachEvent("onload",q);var r=!1;try{r=null==e.frameElement&&a.documentElement}catch(i){}r&&r.doScroll&&function o(){if(!x.isReady){try{r.doScroll("left")}catch(e){return setTimeout(o,50)}_(),x.ready()}}()}return n.promise(t)},x.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(e,t){c["[object "+t+"]"]=t.toLowerCase()});function M(e){var t=e.length,n=x.type(e);return x.isWindow(e)?!1:1===e.nodeType&&t?!0:"array"===n||"function"!==n&&(0===t||"number"==typeof t&&t>0&&t-1 in e)}r=x(a),function(e,t){var n,r,i,o,a,s,l,u,c,p,f,d,h,g,m,y,v,b="sizzle"+-new Date,w=e.document,T=0,C=0,N=st(),k=st(),E=st(),S=!1,A=function(e,t){return e===t?(S=!0,0):0},j=typeof t,D=1<<31,L={}.hasOwnProperty,H=[],q=H.pop,_=H.push,M=H.push,O=H.slice,F=H.indexOf||function(e){var t=0,n=this.length;for(;n>t;t++)if(this[t]===e)return t;return-1},B="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",P="[\\x20\\t\\r\\n\\f]",R="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",W=R.replace("w","w#"),$="\\["+P+"*("+R+")"+P+"*(?:([*^$|!~]?=)"+P+"*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|("+W+")|)|)"+P+"*\\]",I=":("+R+")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|"+$.replace(3,8)+")*)|.*)\\)|)",z=RegExp("^"+P+"+|((?:^|[^\\\\])(?:\\\\.)*)"+P+"+$","g"),X=RegExp("^"+P+"*,"+P+"*"),U=RegExp("^"+P+"*([>+~]|"+P+")"+P+"*"),V=RegExp(P+"*[+~]"),Y=RegExp("="+P+"*([^\\]'\"]*)"+P+"*\\]","g"),J=RegExp(I),G=RegExp("^"+W+"$"),Q={ID:RegExp("^#("+R+")"),CLASS:RegExp("^\\.("+R+")"),TAG:RegExp("^("+R.replace("w","w*")+")"),ATTR:RegExp("^"+$),PSEUDO:RegExp("^"+I),CHILD:RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+P+"*(even|odd|(([+-]|)(\\d*)n|)"+P+"*(?:([+-]|)"+P+"*(\\d+)|))"+P+"*\\)|)","i"),bool:RegExp("^(?:"+B+")$","i"),needsContext:RegExp("^"+P+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+P+"*((?:-\\d)?\\d*)"+P+"*\\)|)(?=[^-]|$)","i")},K=/^[^{]+\{\s*\[native \w/,Z=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,et=/^(?:input|select|textarea|button)$/i,tt=/^h\d$/i,nt=/'|\\/g,rt=RegExp("\\\\([\\da-f]{1,6}"+P+"?|("+P+")|.)","ig"),it=function(e,t,n){var r="0x"+t-65536;return r!==r||n?t:0>r?String.fromCharCode(r+65536):String.fromCharCode(55296|r>>10,56320|1023&r)};try{M.apply(H=O.call(w.childNodes),w.childNodes),H[w.childNodes.length].nodeType}catch(ot){M={apply:H.length?function(e,t){_.apply(e,O.call(t))}:function(e,t){var n=e.length,r=0;while(e[n++]=t[r++]);e.length=n-1}}}function at(e,t,n,i){var o,a,s,l,u,c,d,m,y,x;if((t?t.ownerDocument||t:w)!==f&&p(t),t=t||f,n=n||[],!e||"string"!=typeof e)return n;if(1!==(l=t.nodeType)&&9!==l)return[];if(h&&!i){if(o=Z.exec(e))if(s=o[1]){if(9===l){if(a=t.getElementById(s),!a||!a.parentNode)return n;if(a.id===s)return n.push(a),n}else if(t.ownerDocument&&(a=t.ownerDocument.getElementById(s))&&v(t,a)&&a.id===s)return n.push(a),n}else{if(o[2])return M.apply(n,t.getElementsByTagName(e)),n;if((s=o[3])&&r.getElementsByClassName&&t.getElementsByClassName)return M.apply(n,t.getElementsByClassName(s)),n}if(r.qsa&&(!g||!g.test(e))){if(m=d=b,y=t,x=9===l&&e,1===l&&"object"!==t.nodeName.toLowerCase()){c=mt(e),(d=t.getAttribute("id"))?m=d.replace(nt,"\\$&"):t.setAttribute("id",m),m="[id='"+m+"'] ",u=c.length;while(u--)c[u]=m+yt(c[u]);y=V.test(e)&&t.parentNode||t,x=c.join(",")}if(x)try{return M.apply(n,y.querySelectorAll(x)),n}catch(T){}finally{d||t.removeAttribute("id")}}}return kt(e.replace(z,"$1"),t,n,i)}function st(){var e=[];function t(n,r){return e.push(n+=" ")>o.cacheLength&&delete t[e.shift()],t[n]=r}return t}function lt(e){return e[b]=!0,e}function ut(e){var t=f.createElement("div");try{return!!e(t)}catch(n){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function ct(e,t){var n=e.split("|"),r=e.length;while(r--)o.attrHandle[n[r]]=t}function pt(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&(~t.sourceIndex||D)-(~e.sourceIndex||D);if(r)return r;if(n)while(n=n.nextSibling)if(n===t)return-1;return e?1:-1}function ft(e){return function(t){var n=t.nodeName.toLowerCase();return"input"===n&&t.type===e}}function dt(e){return function(t){var n=t.nodeName.toLowerCase();return("input"===n||"button"===n)&&t.type===e}}function ht(e){return lt(function(t){return t=+t,lt(function(n,r){var i,o=e([],n.length,t),a=o.length;while(a--)n[i=o[a]]&&(n[i]=!(r[i]=n[i]))})})}s=at.isXML=function(e){var t=e&&(e.ownerDocument||e).documentElement;return t?"HTML"!==t.nodeName:!1},r=at.support={},p=at.setDocument=function(e){var n=e?e.ownerDocument||e:w,i=n.defaultView;return n!==f&&9===n.nodeType&&n.documentElement?(f=n,d=n.documentElement,h=!s(n),i&&i.attachEvent&&i!==i.top&&i.attachEvent("onbeforeunload",function(){p()}),r.attributes=ut(function(e){return e.className="i",!e.getAttribute("className")}),r.getElementsByTagName=ut(function(e){return e.appendChild(n.createComment("")),!e.getElementsByTagName("*").length}),r.getElementsByClassName=ut(function(e){return e.innerHTML="<div class='a'></div><div class='a i'></div>",e.firstChild.className="i",2===e.getElementsByClassName("i").length}),r.getById=ut(function(e){return d.appendChild(e).id=b,!n.getElementsByName||!n.getElementsByName(b).length}),r.getById?(o.find.ID=function(e,t){if(typeof t.getElementById!==j&&h){var n=t.getElementById(e);return n&&n.parentNode?[n]:[]}},o.filter.ID=function(e){var t=e.replace(rt,it);return function(e){return e.getAttribute("id")===t}}):(delete o.find.ID,o.filter.ID=function(e){var t=e.replace(rt,it);return function(e){var n=typeof e.getAttributeNode!==j&&e.getAttributeNode("id");return n&&n.value===t}}),o.find.TAG=r.getElementsByTagName?function(e,n){return typeof n.getElementsByTagName!==j?n.getElementsByTagName(e):t}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){while(n=o[i++])1===n.nodeType&&r.push(n);return r}return o},o.find.CLASS=r.getElementsByClassName&&function(e,n){return typeof n.getElementsByClassName!==j&&h?n.getElementsByClassName(e):t},m=[],g=[],(r.qsa=K.test(n.querySelectorAll))&&(ut(function(e){e.innerHTML="<select><option selected=''></option></select>",e.querySelectorAll("[selected]").length||g.push("\\["+P+"*(?:value|"+B+")"),e.querySelectorAll(":checked").length||g.push(":checked")}),ut(function(e){var t=n.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("t",""),e.querySelectorAll("[t^='']").length&&g.push("[*^$]="+P+"*(?:''|\"\")"),e.querySelectorAll(":enabled").length||g.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),g.push(",.*:")})),(r.matchesSelector=K.test(y=d.webkitMatchesSelector||d.mozMatchesSelector||d.oMatchesSelector||d.msMatchesSelector))&&ut(function(e){r.disconnectedMatch=y.call(e,"div"),y.call(e,"[s!='']:x"),m.push("!=",I)}),g=g.length&&RegExp(g.join("|")),m=m.length&&RegExp(m.join("|")),v=K.test(d.contains)||d.compareDocumentPosition?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)while(t=t.parentNode)if(t===e)return!0;return!1},A=d.compareDocumentPosition?function(e,t){if(e===t)return S=!0,0;var i=t.compareDocumentPosition&&e.compareDocumentPosition&&e.compareDocumentPosition(t);return i?1&i||!r.sortDetached&&t.compareDocumentPosition(e)===i?e===n||v(w,e)?-1:t===n||v(w,t)?1:c?F.call(c,e)-F.call(c,t):0:4&i?-1:1:e.compareDocumentPosition?-1:1}:function(e,t){var r,i=0,o=e.parentNode,a=t.parentNode,s=[e],l=[t];if(e===t)return S=!0,0;if(!o||!a)return e===n?-1:t===n?1:o?-1:a?1:c?F.call(c,e)-F.call(c,t):0;if(o===a)return pt(e,t);r=e;while(r=r.parentNode)s.unshift(r);r=t;while(r=r.parentNode)l.unshift(r);while(s[i]===l[i])i++;return i?pt(s[i],l[i]):s[i]===w?-1:l[i]===w?1:0},n):f},at.matches=function(e,t){return at(e,null,null,t)},at.matchesSelector=function(e,t){if((e.ownerDocument||e)!==f&&p(e),t=t.replace(Y,"='$1']"),!(!r.matchesSelector||!h||m&&m.test(t)||g&&g.test(t)))try{var n=y.call(e,t);if(n||r.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(i){}return at(t,f,null,[e]).length>0},at.contains=function(e,t){return(e.ownerDocument||e)!==f&&p(e),v(e,t)},at.attr=function(e,n){(e.ownerDocument||e)!==f&&p(e);var i=o.attrHandle[n.toLowerCase()],a=i&&L.call(o.attrHandle,n.toLowerCase())?i(e,n,!h):t;return a===t?r.attributes||!h?e.getAttribute(n):(a=e.getAttributeNode(n))&&a.specified?a.value:null:a},at.error=function(e){throw Error("Syntax error, unrecognized expression: "+e)},at.uniqueSort=function(e){var t,n=[],i=0,o=0;if(S=!r.detectDuplicates,c=!r.sortStable&&e.slice(0),e.sort(A),S){while(t=e[o++])t===e[o]&&(i=n.push(o));while(i--)e.splice(n[i],1)}return e},a=at.getText=function(e){var t,n="",r=0,i=e.nodeType;if(i){if(1===i||9===i||11===i){if("string"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)n+=a(e)}else if(3===i||4===i)return e.nodeValue}else for(;t=e[r];r++)n+=a(t);return n},o=at.selectors={cacheLength:50,createPseudo:lt,match:Q,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(rt,it),e[3]=(e[4]||e[5]||"").replace(rt,it),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||at.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&at.error(e[0]),e},PSEUDO:function(e){var n,r=!e[5]&&e[2];return Q.CHILD.test(e[0])?null:(e[3]&&e[4]!==t?e[2]=e[4]:r&&J.test(r)&&(n=mt(r,!0))&&(n=r.indexOf(")",r.length-n)-r.length)&&(e[0]=e[0].slice(0,n),e[2]=r.slice(0,n)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(rt,it).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=N[e+" "];return t||(t=RegExp("(^|"+P+")"+e+"("+P+"|$)"))&&N(e,function(e){return t.test("string"==typeof e.className&&e.className||typeof e.getAttribute!==j&&e.getAttribute("class")||"")})},ATTR:function(e,t,n){return function(r){var i=at.attr(r,e);return null==i?"!="===t:t?(i+="","="===t?i===n:"!="===t?i!==n:"^="===t?n&&0===i.indexOf(n):"*="===t?n&&i.indexOf(n)>-1:"$="===t?n&&i.slice(-n.length)===n:"~="===t?(" "+i+" ").indexOf(n)>-1:"|="===t?i===n||i.slice(0,n.length+1)===n+"-":!1):!0}},CHILD:function(e,t,n,r,i){var o="nth"!==e.slice(0,3),a="last"!==e.slice(-4),s="of-type"===t;return 1===r&&0===i?function(e){return!!e.parentNode}:function(t,n,l){var u,c,p,f,d,h,g=o!==a?"nextSibling":"previousSibling",m=t.parentNode,y=s&&t.nodeName.toLowerCase(),v=!l&&!s;if(m){if(o){while(g){p=t;while(p=p[g])if(s?p.nodeName.toLowerCase()===y:1===p.nodeType)return!1;h=g="only"===e&&!h&&"nextSibling"}return!0}if(h=[a?m.firstChild:m.lastChild],a&&v){c=m[b]||(m[b]={}),u=c[e]||[],d=u[0]===T&&u[1],f=u[0]===T&&u[2],p=d&&m.childNodes[d];while(p=++d&&p&&p[g]||(f=d=0)||h.pop())if(1===p.nodeType&&++f&&p===t){c[e]=[T,d,f];break}}else if(v&&(u=(t[b]||(t[b]={}))[e])&&u[0]===T)f=u[1];else while(p=++d&&p&&p[g]||(f=d=0)||h.pop())if((s?p.nodeName.toLowerCase()===y:1===p.nodeType)&&++f&&(v&&((p[b]||(p[b]={}))[e]=[T,f]),p===t))break;return f-=i,f===r||0===f%r&&f/r>=0}}},PSEUDO:function(e,t){var n,r=o.pseudos[e]||o.setFilters[e.toLowerCase()]||at.error("unsupported pseudo: "+e);return r[b]?r(t):r.length>1?(n=[e,e,"",t],o.setFilters.hasOwnProperty(e.toLowerCase())?lt(function(e,n){var i,o=r(e,t),a=o.length;while(a--)i=F.call(e,o[a]),e[i]=!(n[i]=o[a])}):function(e){return r(e,0,n)}):r}},pseudos:{not:lt(function(e){var t=[],n=[],r=l(e.replace(z,"$1"));return r[b]?lt(function(e,t,n,i){var o,a=r(e,null,i,[]),s=e.length;while(s--)(o=a[s])&&(e[s]=!(t[s]=o))}):function(e,i,o){return t[0]=e,r(t,null,o,n),!n.pop()}}),has:lt(function(e){return function(t){return at(e,t).length>0}}),contains:lt(function(e){return function(t){return(t.textContent||t.innerText||a(t)).indexOf(e)>-1}}),lang:lt(function(e){return G.test(e||"")||at.error("unsupported lang: "+e),e=e.replace(rt,it).toLowerCase(),function(t){var n;do if(n=h?t.lang:t.getAttribute("xml:lang")||t.getAttribute("lang"))return n=n.toLowerCase(),n===e||0===n.indexOf(e+"-");while((t=t.parentNode)&&1===t.nodeType);return!1}}),target:function(t){var n=e.location&&e.location.hash;return n&&n.slice(1)===t.id},root:function(e){return e===d},focus:function(e){return e===f.activeElement&&(!f.hasFocus||f.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:function(e){return e.disabled===!1},disabled:function(e){return e.disabled===!0},checked:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&!!e.checked||"option"===t&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,e.selected===!0},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeName>"@"||3===e.nodeType||4===e.nodeType)return!1;return!0},parent:function(e){return!o.pseudos.empty(e)},header:function(e){return tt.test(e.nodeName)},input:function(e){return et.test(e.nodeName)},button:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&"button"===e.type||"button"===t},text:function(e){var t;return"input"===e.nodeName.toLowerCase()&&"text"===e.type&&(null==(t=e.getAttribute("type"))||t.toLowerCase()===e.type)},first:ht(function(){return[0]}),last:ht(function(e,t){return[t-1]}),eq:ht(function(e,t,n){return[0>n?n+t:n]}),even:ht(function(e,t){var n=0;for(;t>n;n+=2)e.push(n);return e}),odd:ht(function(e,t){var n=1;for(;t>n;n+=2)e.push(n);return e}),lt:ht(function(e,t,n){var r=0>n?n+t:n;for(;--r>=0;)e.push(r);return e}),gt:ht(function(e,t,n){var r=0>n?n+t:n;for(;t>++r;)e.push(r);return e})}},o.pseudos.nth=o.pseudos.eq;for(n in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})o.pseudos[n]=ft(n);for(n in{submit:!0,reset:!0})o.pseudos[n]=dt(n);function gt(){}gt.prototype=o.filters=o.pseudos,o.setFilters=new gt;function mt(e,t){var n,r,i,a,s,l,u,c=k[e+" "];if(c)return t?0:c.slice(0);s=e,l=[],u=o.preFilter;while(s){(!n||(r=X.exec(s)))&&(r&&(s=s.slice(r[0].length)||s),l.push(i=[])),n=!1,(r=U.exec(s))&&(n=r.shift(),i.push({value:n,type:r[0].replace(z," ")}),s=s.slice(n.length));for(a in o.filter)!(r=Q[a].exec(s))||u[a]&&!(r=u[a](r))||(n=r.shift(),i.push({value:n,type:a,matches:r}),s=s.slice(n.length));if(!n)break}return t?s.length:s?at.error(e):k(e,l).slice(0)}function yt(e){var t=0,n=e.length,r="";for(;n>t;t++)r+=e[t].value;return r}function vt(e,t,n){var r=t.dir,o=n&&"parentNode"===r,a=C++;return t.first?function(t,n,i){while(t=t[r])if(1===t.nodeType||o)return e(t,n,i)}:function(t,n,s){var l,u,c,p=T+" "+a;if(s){while(t=t[r])if((1===t.nodeType||o)&&e(t,n,s))return!0}else while(t=t[r])if(1===t.nodeType||o)if(c=t[b]||(t[b]={}),(u=c[r])&&u[0]===p){if((l=u[1])===!0||l===i)return l===!0}else if(u=c[r]=[p],u[1]=e(t,n,s)||i,u[1]===!0)return!0}}function bt(e){return e.length>1?function(t,n,r){var i=e.length;while(i--)if(!e[i](t,n,r))return!1;return!0}:e[0]}function xt(e,t,n,r,i){var o,a=[],s=0,l=e.length,u=null!=t;for(;l>s;s++)(o=e[s])&&(!n||n(o,r,i))&&(a.push(o),u&&t.push(s));return a}function wt(e,t,n,r,i,o){return r&&!r[b]&&(r=wt(r)),i&&!i[b]&&(i=wt(i,o)),lt(function(o,a,s,l){var u,c,p,f=[],d=[],h=a.length,g=o||Nt(t||"*",s.nodeType?[s]:s,[]),m=!e||!o&&t?g:xt(g,f,e,s,l),y=n?i||(o?e:h||r)?[]:a:m;if(n&&n(m,y,s,l),r){u=xt(y,d),r(u,[],s,l),c=u.length;while(c--)(p=u[c])&&(y[d[c]]=!(m[d[c]]=p))}if(o){if(i||e){if(i){u=[],c=y.length;while(c--)(p=y[c])&&u.push(m[c]=p);i(null,y=[],u,l)}c=y.length;while(c--)(p=y[c])&&(u=i?F.call(o,p):f[c])>-1&&(o[u]=!(a[u]=p))}}else y=xt(y===a?y.splice(h,y.length):y),i?i(null,a,y,l):M.apply(a,y)})}function Tt(e){var t,n,r,i=e.length,a=o.relative[e[0].type],s=a||o.relative[" "],l=a?1:0,c=vt(function(e){return e===t},s,!0),p=vt(function(e){return F.call(t,e)>-1},s,!0),f=[function(e,n,r){return!a&&(r||n!==u)||((t=n).nodeType?c(e,n,r):p(e,n,r))}];for(;i>l;l++)if(n=o.relative[e[l].type])f=[vt(bt(f),n)];else{if(n=o.filter[e[l].type].apply(null,e[l].matches),n[b]){for(r=++l;i>r;r++)if(o.relative[e[r].type])break;return wt(l>1&&bt(f),l>1&&yt(e.slice(0,l-1).concat({value:" "===e[l-2].type?"*":""})).replace(z,"$1"),n,r>l&&Tt(e.slice(l,r)),i>r&&Tt(e=e.slice(r)),i>r&&yt(e))}f.push(n)}return bt(f)}function Ct(e,t){var n=0,r=t.length>0,a=e.length>0,s=function(s,l,c,p,d){var h,g,m,y=[],v=0,b="0",x=s&&[],w=null!=d,C=u,N=s||a&&o.find.TAG("*",d&&l.parentNode||l),k=T+=null==C?1:Math.random()||.1;for(w&&(u=l!==f&&l,i=n);null!=(h=N[b]);b++){if(a&&h){g=0;while(m=e[g++])if(m(h,l,c)){p.push(h);break}w&&(T=k,i=++n)}r&&((h=!m&&h)&&v--,s&&x.push(h))}if(v+=b,r&&b!==v){g=0;while(m=t[g++])m(x,y,l,c);if(s){if(v>0)while(b--)x[b]||y[b]||(y[b]=q.call(p));y=xt(y)}M.apply(p,y),w&&!s&&y.length>0&&v+t.length>1&&at.uniqueSort(p)}return w&&(T=k,u=C),x};return r?lt(s):s}l=at.compile=function(e,t){var n,r=[],i=[],o=E[e+" "];if(!o){t||(t=mt(e)),n=t.length;while(n--)o=Tt(t[n]),o[b]?r.push(o):i.push(o);o=E(e,Ct(i,r))}return o};function Nt(e,t,n){var r=0,i=t.length;for(;i>r;r++)at(e,t[r],n);return n}function kt(e,t,n,i){var a,s,u,c,p,f=mt(e);if(!i&&1===f.length){if(s=f[0]=f[0].slice(0),s.length>2&&"ID"===(u=s[0]).type&&r.getById&&9===t.nodeType&&h&&o.relative[s[1].type]){if(t=(o.find.ID(u.matches[0].replace(rt,it),t)||[])[0],!t)return n;e=e.slice(s.shift().value.length)}a=Q.needsContext.test(e)?0:s.length;while(a--){if(u=s[a],o.relative[c=u.type])break;if((p=o.find[c])&&(i=p(u.matches[0].replace(rt,it),V.test(s[0].type)&&t.parentNode||t))){if(s.splice(a,1),e=i.length&&yt(s),!e)return M.apply(n,i),n;break}}}return l(e,f)(i,t,!h,n,V.test(e)),n}r.sortStable=b.split("").sort(A).join("")===b,r.detectDuplicates=S,p(),r.sortDetached=ut(function(e){return 1&e.compareDocumentPosition(f.createElement("div"))}),ut(function(e){return e.innerHTML="<a href='#'></a>","#"===e.firstChild.getAttribute("href")})||ct("type|href|height|width",function(e,n,r){return r?t:e.getAttribute(n,"type"===n.toLowerCase()?1:2)}),r.attributes&&ut(function(e){return e.innerHTML="<input/>",e.firstChild.setAttribute("value",""),""===e.firstChild.getAttribute("value")})||ct("value",function(e,n,r){return r||"input"!==e.nodeName.toLowerCase()?t:e.defaultValue}),ut(function(e){return null==e.getAttribute("disabled")})||ct(B,function(e,n,r){var i;return r?t:(i=e.getAttributeNode(n))&&i.specified?i.value:e[n]===!0?n.toLowerCase():null}),x.find=at,x.expr=at.selectors,x.expr[":"]=x.expr.pseudos,x.unique=at.uniqueSort,x.text=at.getText,x.isXMLDoc=at.isXML,x.contains=at.contains}(e);var O={};function F(e){var t=O[e]={};return x.each(e.match(T)||[],function(e,n){t[n]=!0}),t}x.Callbacks=function(e){e="string"==typeof e?O[e]||F(e):x.extend({},e);var n,r,i,o,a,s,l=[],u=!e.once&&[],c=function(t){for(r=e.memory&&t,i=!0,a=s||0,s=0,o=l.length,n=!0;l&&o>a;a++)if(l[a].apply(t[0],t[1])===!1&&e.stopOnFalse){r=!1;break}n=!1,l&&(u?u.length&&c(u.shift()):r?l=[]:p.disable())},p={add:function(){if(l){var t=l.length;(function i(t){x.each(t,function(t,n){var r=x.type(n);"function"===r?e.unique&&p.has(n)||l.push(n):n&&n.length&&"string"!==r&&i(n)})})(arguments),n?o=l.length:r&&(s=t,c(r))}return this},remove:function(){return l&&x.each(arguments,function(e,t){var r;while((r=x.inArray(t,l,r))>-1)l.splice(r,1),n&&(o>=r&&o--,a>=r&&a--)}),this},has:function(e){return e?x.inArray(e,l)>-1:!(!l||!l.length)},empty:function(){return l=[],o=0,this},disable:function(){return l=u=r=t,this},disabled:function(){return!l},lock:function(){return u=t,r||p.disable(),this},locked:function(){return!u},fireWith:function(e,t){return!l||i&&!u||(t=t||[],t=[e,t.slice?t.slice():t],n?u.push(t):c(t)),this},fire:function(){return p.fireWith(this,arguments),this},fired:function(){return!!i}};return p},x.extend({Deferred:function(e){var t=[["resolve","done",x.Callbacks("once memory"),"resolved"],["reject","fail",x.Callbacks("once memory"),"rejected"],["notify","progress",x.Callbacks("memory")]],n="pending",r={state:function(){return n},always:function(){return i.done(arguments).fail(arguments),this},then:function(){var e=arguments;return x.Deferred(function(n){x.each(t,function(t,o){var a=o[0],s=x.isFunction(e[t])&&e[t];i[o[1]](function(){var e=s&&s.apply(this,arguments);e&&x.isFunction(e.promise)?e.promise().done(n.resolve).fail(n.reject).progress(n.notify):n[a+"With"](this===r?n.promise():this,s?[e]:arguments)})}),e=null}).promise()},promise:function(e){return null!=e?x.extend(e,r):r}},i={};return r.pipe=r.then,x.each(t,function(e,o){var a=o[2],s=o[3];r[o[1]]=a.add,s&&a.add(function(){n=s},t[1^e][2].disable,t[2][2].lock),i[o[0]]=function(){return i[o[0]+"With"](this===i?r:this,arguments),this},i[o[0]+"With"]=a.fireWith}),r.promise(i),e&&e.call(i,i),i},when:function(e){var t=0,n=g.call(arguments),r=n.length,i=1!==r||e&&x.isFunction(e.promise)?r:0,o=1===i?e:x.Deferred(),a=function(e,t,n){return function(r){t[e]=this,n[e]=arguments.length>1?g.call(arguments):r,n===s?o.notifyWith(t,n):--i||o.resolveWith(t,n)}},s,l,u;if(r>1)for(s=Array(r),l=Array(r),u=Array(r);r>t;t++)n[t]&&x.isFunction(n[t].promise)?n[t].promise().done(a(t,u,n)).fail(o.reject).progress(a(t,l,s)):--i;return i||o.resolveWith(u,n),o.promise()}}),x.support=function(t){var n,r,o,s,l,u,c,p,f,d=a.createElement("div");if(d.setAttribute("className","t"),d.innerHTML=" <link/><table></table><a href='/a'>a</a><input type='checkbox'/>",n=d.getElementsByTagName("*")||[],r=d.getElementsByTagName("a")[0],!r||!r.style||!n.length)return t;s=a.createElement("select"),u=s.appendChild(a.createElement("option")),o=d.getElementsByTagName("input")[0],r.style.cssText="top:1px;float:left;opacity:.5",t.getSetAttribute="t"!==d.className,t.leadingWhitespace=3===d.firstChild.nodeType,t.tbody=!d.getElementsByTagName("tbody").length,t.htmlSerialize=!!d.getElementsByTagName("link").length,t.style=/top/.test(r.getAttribute("style")),t.hrefNormalized="/a"===r.getAttribute("href"),t.opacity=/^0.5/.test(r.style.opacity),t.cssFloat=!!r.style.cssFloat,t.checkOn=!!o.value,t.optSelected=u.selected,t.enctype=!!a.createElement("form").enctype,t.html5Clone="<:nav></:nav>"!==a.createElement("nav").cloneNode(!0).outerHTML,t.inlineBlockNeedsLayout=!1,t.shrinkWrapBlocks=!1,t.pixelPosition=!1,t.deleteExpando=!0,t.noCloneEvent=!0,t.reliableMarginRight=!0,t.boxSizingReliable=!0,o.checked=!0,t.noCloneChecked=o.cloneNode(!0).checked,s.disabled=!0,t.optDisabled=!u.disabled;try{delete d.test}catch(h){t.deleteExpando=!1}o=a.createElement("input"),o.setAttribute("value",""),t.input=""===o.getAttribute("value"),o.value="t",o.setAttribute("type","radio"),t.radioValue="t"===o.value,o.setAttribute("checked","t"),o.setAttribute("name","t"),l=a.createDocumentFragment(),l.appendChild(o),t.appendChecked=o.checked,t.checkClone=l.cloneNode(!0).cloneNode(!0).lastChild.checked,d.attachEvent&&(d.attachEvent("onclick",function(){t.noCloneEvent=!1}),d.cloneNode(!0).click());for(f in{submit:!0,change:!0,focusin:!0})d.setAttribute(c="on"+f,"t"),t[f+"Bubbles"]=c in e||d.attributes[c].expando===!1;d.style.backgroundClip="content-box",d.cloneNode(!0).style.backgroundClip="",t.clearCloneStyle="content-box"===d.style.backgroundClip;for(f in x(t))break;return t.ownLast="0"!==f,x(function(){var n,r,o,s="padding:0;margin:0;border:0;display:block;box-sizing:content-box;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;",l=a.getElementsByTagName("body")[0];l&&(n=a.createElement("div"),n.style.cssText="border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px",l.appendChild(n).appendChild(d),d.innerHTML="<table><tr><td></td><td>t</td></tr></table>",o=d.getElementsByTagName("td"),o[0].style.cssText="padding:0;margin:0;border:0;display:none",p=0===o[0].offsetHeight,o[0].style.display="",o[1].style.display="none",t.reliableHiddenOffsets=p&&0===o[0].offsetHeight,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%;",x.swap(l,null!=l.style.zoom?{zoom:1}:{},function(){t.boxSizing=4===d.offsetWidth}),e.getComputedStyle&&(t.pixelPosition="1%"!==(e.getComputedStyle(d,null)||{}).top,t.boxSizingReliable="4px"===(e.getComputedStyle(d,null)||{width:"4px"}).width,r=d.appendChild(a.createElement("div")),r.style.cssText=d.style.cssText=s,r.style.marginRight=r.style.width="0",d.style.width="1px",t.reliableMarginRight=!parseFloat((e.getComputedStyle(r,null)||{}).marginRight)),typeof d.style.zoom!==i&&(d.innerHTML="",d.style.cssText=s+"width:1px;padding:1px;display:inline;zoom:1",t.inlineBlockNeedsLayout=3===d.offsetWidth,d.style.display="block",d.innerHTML="<div></div>",d.firstChild.style.width="5px",t.shrinkWrapBlocks=3!==d.offsetWidth,t.inlineBlockNeedsLayout&&(l.style.zoom=1)),l.removeChild(n),n=d=o=r=null)}),n=s=l=u=r=o=null,t
5}({});var B=/(?:\{[\s\S]*\}|\[[\s\S]*\])$/,P=/([A-Z])/g;function R(e,n,r,i){if(x.acceptData(e)){var o,a,s=x.expando,l=e.nodeType,u=l?x.cache:e,c=l?e[s]:e[s]&&s;if(c&&u[c]&&(i||u[c].data)||r!==t||"string"!=typeof n)return c||(c=l?e[s]=p.pop()||x.guid++:s),u[c]||(u[c]=l?{}:{toJSON:x.noop}),("object"==typeof n||"function"==typeof n)&&(i?u[c]=x.extend(u[c],n):u[c].data=x.extend(u[c].data,n)),a=u[c],i||(a.data||(a.data={}),a=a.data),r!==t&&(a[x.camelCase(n)]=r),"string"==typeof n?(o=a[n],null==o&&(o=a[x.camelCase(n)])):o=a,o}}function W(e,t,n){if(x.acceptData(e)){var r,i,o=e.nodeType,a=o?x.cache:e,s=o?e[x.expando]:x.expando;if(a[s]){if(t&&(r=n?a[s]:a[s].data)){x.isArray(t)?t=t.concat(x.map(t,x.camelCase)):t in r?t=[t]:(t=x.camelCase(t),t=t in r?[t]:t.split(" ")),i=t.length;while(i--)delete r[t[i]];if(n?!I(r):!x.isEmptyObject(r))return}(n||(delete a[s].data,I(a[s])))&&(o?x.cleanData([e],!0):x.support.deleteExpando||a!=a.window?delete a[s]:a[s]=null)}}}x.extend({cache:{},noData:{applet:!0,embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"},hasData:function(e){return e=e.nodeType?x.cache[e[x.expando]]:e[x.expando],!!e&&!I(e)},data:function(e,t,n){return R(e,t,n)},removeData:function(e,t){return W(e,t)},_data:function(e,t,n){return R(e,t,n,!0)},_removeData:function(e,t){return W(e,t,!0)},acceptData:function(e){if(e.nodeType&&1!==e.nodeType&&9!==e.nodeType)return!1;var t=e.nodeName&&x.noData[e.nodeName.toLowerCase()];return!t||t!==!0&&e.getAttribute("classid")===t}}),x.fn.extend({data:function(e,n){var r,i,o=null,a=0,s=this[0];if(e===t){if(this.length&&(o=x.data(s),1===s.nodeType&&!x._data(s,"parsedAttrs"))){for(r=s.attributes;r.length>a;a++)i=r[a].name,0===i.indexOf("data-")&&(i=x.camelCase(i.slice(5)),$(s,i,o[i]));x._data(s,"parsedAttrs",!0)}return o}return"object"==typeof e?this.each(function(){x.data(this,e)}):arguments.length>1?this.each(function(){x.data(this,e,n)}):s?$(s,e,x.data(s,e)):null},removeData:function(e){return this.each(function(){x.removeData(this,e)})}});function $(e,n,r){if(r===t&&1===e.nodeType){var i="data-"+n.replace(P,"-$1").toLowerCase();if(r=e.getAttribute(i),"string"==typeof r){try{r="true"===r?!0:"false"===r?!1:"null"===r?null:+r+""===r?+r:B.test(r)?x.parseJSON(r):r}catch(o){}x.data(e,n,r)}else r=t}return r}function I(e){var t;for(t in e)if(("data"!==t||!x.isEmptyObject(e[t]))&&"toJSON"!==t)return!1;return!0}x.extend({queue:function(e,n,r){var i;return e?(n=(n||"fx")+"queue",i=x._data(e,n),r&&(!i||x.isArray(r)?i=x._data(e,n,x.makeArray(r)):i.push(r)),i||[]):t},dequeue:function(e,t){t=t||"fx";var n=x.queue(e,t),r=n.length,i=n.shift(),o=x._queueHooks(e,t),a=function(){x.dequeue(e,t)};"inprogress"===i&&(i=n.shift(),r--),i&&("fx"===t&&n.unshift("inprogress"),delete o.stop,i.call(e,a,o)),!r&&o&&o.empty.fire()},_queueHooks:function(e,t){var n=t+"queueHooks";return x._data(e,n)||x._data(e,n,{empty:x.Callbacks("once memory").add(function(){x._removeData(e,t+"queue"),x._removeData(e,n)})})}}),x.fn.extend({queue:function(e,n){var r=2;return"string"!=typeof e&&(n=e,e="fx",r--),r>arguments.length?x.queue(this[0],e):n===t?this:this.each(function(){var t=x.queue(this,e,n);x._queueHooks(this,e),"fx"===e&&"inprogress"!==t[0]&&x.dequeue(this,e)})},dequeue:function(e){return this.each(function(){x.dequeue(this,e)})},delay:function(e,t){return e=x.fx?x.fx.speeds[e]||e:e,t=t||"fx",this.queue(t,function(t,n){var r=setTimeout(t,e);n.stop=function(){clearTimeout(r)}})},clearQueue:function(e){return this.queue(e||"fx",[])},promise:function(e,n){var r,i=1,o=x.Deferred(),a=this,s=this.length,l=function(){--i||o.resolveWith(a,[a])};"string"!=typeof e&&(n=e,e=t),e=e||"fx";while(s--)r=x._data(a[s],e+"queueHooks"),r&&r.empty&&(i++,r.empty.add(l));return l(),o.promise(n)}});var z,X,U=/[\t\r\n\f]/g,V=/\r/g,Y=/^(?:input|select|textarea|button|object)$/i,J=/^(?:a|area)$/i,G=/^(?:checked|selected)$/i,Q=x.support.getSetAttribute,K=x.support.input;x.fn.extend({attr:function(e,t){return x.access(this,x.attr,e,t,arguments.length>1)},removeAttr:function(e){return this.each(function(){x.removeAttr(this,e)})},prop:function(e,t){return x.access(this,x.prop,e,t,arguments.length>1)},removeProp:function(e){return e=x.propFix[e]||e,this.each(function(){try{this[e]=t,delete this[e]}catch(n){}})},addClass:function(e){var t,n,r,i,o,a=0,s=this.length,l="string"==typeof e&&e;if(x.isFunction(e))return this.each(function(t){x(this).addClass(e.call(this,t,this.className))});if(l)for(t=(e||"").match(T)||[];s>a;a++)if(n=this[a],r=1===n.nodeType&&(n.className?(" "+n.className+" ").replace(U," "):" ")){o=0;while(i=t[o++])0>r.indexOf(" "+i+" ")&&(r+=i+" ");n.className=x.trim(r)}return this},removeClass:function(e){var t,n,r,i,o,a=0,s=this.length,l=0===arguments.length||"string"==typeof e&&e;if(x.isFunction(e))return this.each(function(t){x(this).removeClass(e.call(this,t,this.className))});if(l)for(t=(e||"").match(T)||[];s>a;a++)if(n=this[a],r=1===n.nodeType&&(n.className?(" "+n.className+" ").replace(U," "):"")){o=0;while(i=t[o++])while(r.indexOf(" "+i+" ")>=0)r=r.replace(" "+i+" "," ");n.className=e?x.trim(r):""}return this},toggleClass:function(e,t){var n=typeof e;return"boolean"==typeof t&&"string"===n?t?this.addClass(e):this.removeClass(e):x.isFunction(e)?this.each(function(n){x(this).toggleClass(e.call(this,n,this.className,t),t)}):this.each(function(){if("string"===n){var t,r=0,o=x(this),a=e.match(T)||[];while(t=a[r++])o.hasClass(t)?o.removeClass(t):o.addClass(t)}else(n===i||"boolean"===n)&&(this.className&&x._data(this,"__className__",this.className),this.className=this.className||e===!1?"":x._data(this,"__className__")||"")})},hasClass:function(e){var t=" "+e+" ",n=0,r=this.length;for(;r>n;n++)if(1===this[n].nodeType&&(" "+this[n].className+" ").replace(U," ").indexOf(t)>=0)return!0;return!1},val:function(e){var n,r,i,o=this[0];{if(arguments.length)return i=x.isFunction(e),this.each(function(n){var o;1===this.nodeType&&(o=i?e.call(this,n,x(this).val()):e,null==o?o="":"number"==typeof o?o+="":x.isArray(o)&&(o=x.map(o,function(e){return null==e?"":e+""})),r=x.valHooks[this.type]||x.valHooks[this.nodeName.toLowerCase()],r&&"set"in r&&r.set(this,o,"value")!==t||(this.value=o))});if(o)return r=x.valHooks[o.type]||x.valHooks[o.nodeName.toLowerCase()],r&&"get"in r&&(n=r.get(o,"value"))!==t?n:(n=o.value,"string"==typeof n?n.replace(V,""):null==n?"":n)}}}),x.extend({valHooks:{option:{get:function(e){var t=x.find.attr(e,"value");return null!=t?t:e.text}},select:{get:function(e){var t,n,r=e.options,i=e.selectedIndex,o="select-one"===e.type||0>i,a=o?null:[],s=o?i+1:r.length,l=0>i?s:o?i:0;for(;s>l;l++)if(n=r[l],!(!n.selected&&l!==i||(x.support.optDisabled?n.disabled:null!==n.getAttribute("disabled"))||n.parentNode.disabled&&x.nodeName(n.parentNode,"optgroup"))){if(t=x(n).val(),o)return t;a.push(t)}return a},set:function(e,t){var n,r,i=e.options,o=x.makeArray(t),a=i.length;while(a--)r=i[a],(r.selected=x.inArray(x(r).val(),o)>=0)&&(n=!0);return n||(e.selectedIndex=-1),o}}},attr:function(e,n,r){var o,a,s=e.nodeType;if(e&&3!==s&&8!==s&&2!==s)return typeof e.getAttribute===i?x.prop(e,n,r):(1===s&&x.isXMLDoc(e)||(n=n.toLowerCase(),o=x.attrHooks[n]||(x.expr.match.bool.test(n)?X:z)),r===t?o&&"get"in o&&null!==(a=o.get(e,n))?a:(a=x.find.attr(e,n),null==a?t:a):null!==r?o&&"set"in o&&(a=o.set(e,r,n))!==t?a:(e.setAttribute(n,r+""),r):(x.removeAttr(e,n),t))},removeAttr:function(e,t){var n,r,i=0,o=t&&t.match(T);if(o&&1===e.nodeType)while(n=o[i++])r=x.propFix[n]||n,x.expr.match.bool.test(n)?K&&Q||!G.test(n)?e[r]=!1:e[x.camelCase("default-"+n)]=e[r]=!1:x.attr(e,n,""),e.removeAttribute(Q?n:r)},attrHooks:{type:{set:function(e,t){if(!x.support.radioValue&&"radio"===t&&x.nodeName(e,"input")){var n=e.value;return e.setAttribute("type",t),n&&(e.value=n),t}}}},propFix:{"for":"htmlFor","class":"className"},prop:function(e,n,r){var i,o,a,s=e.nodeType;if(e&&3!==s&&8!==s&&2!==s)return a=1!==s||!x.isXMLDoc(e),a&&(n=x.propFix[n]||n,o=x.propHooks[n]),r!==t?o&&"set"in o&&(i=o.set(e,r,n))!==t?i:e[n]=r:o&&"get"in o&&null!==(i=o.get(e,n))?i:e[n]},propHooks:{tabIndex:{get:function(e){var t=x.find.attr(e,"tabindex");return t?parseInt(t,10):Y.test(e.nodeName)||J.test(e.nodeName)&&e.href?0:-1}}}}),X={set:function(e,t,n){return t===!1?x.removeAttr(e,n):K&&Q||!G.test(n)?e.setAttribute(!Q&&x.propFix[n]||n,n):e[x.camelCase("default-"+n)]=e[n]=!0,n}},x.each(x.expr.match.bool.source.match(/\w+/g),function(e,n){var r=x.expr.attrHandle[n]||x.find.attr;x.expr.attrHandle[n]=K&&Q||!G.test(n)?function(e,n,i){var o=x.expr.attrHandle[n],a=i?t:(x.expr.attrHandle[n]=t)!=r(e,n,i)?n.toLowerCase():null;return x.expr.attrHandle[n]=o,a}:function(e,n,r){return r?t:e[x.camelCase("default-"+n)]?n.toLowerCase():null}}),K&&Q||(x.attrHooks.value={set:function(e,n,r){return x.nodeName(e,"input")?(e.defaultValue=n,t):z&&z.set(e,n,r)}}),Q||(z={set:function(e,n,r){var i=e.getAttributeNode(r);return i||e.setAttributeNode(i=e.ownerDocument.createAttribute(r)),i.value=n+="","value"===r||n===e.getAttribute(r)?n:t}},x.expr.attrHandle.id=x.expr.attrHandle.name=x.expr.attrHandle.coords=function(e,n,r){var i;return r?t:(i=e.getAttributeNode(n))&&""!==i.value?i.value:null},x.valHooks.button={get:function(e,n){var r=e.getAttributeNode(n);return r&&r.specified?r.value:t},set:z.set},x.attrHooks.contenteditable={set:function(e,t,n){z.set(e,""===t?!1:t,n)}},x.each(["width","height"],function(e,n){x.attrHooks[n]={set:function(e,r){return""===r?(e.setAttribute(n,"auto"),r):t}}})),x.support.hrefNormalized||x.each(["href","src"],function(e,t){x.propHooks[t]={get:function(e){return e.getAttribute(t,4)}}}),x.support.style||(x.attrHooks.style={get:function(e){return e.style.cssText||t},set:function(e,t){return e.style.cssText=t+""}}),x.support.optSelected||(x.propHooks.selected={get:function(e){var t=e.parentNode;return t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex),null}}),x.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){x.propFix[this.toLowerCase()]=this}),x.support.enctype||(x.propFix.enctype="encoding"),x.each(["radio","checkbox"],function(){x.valHooks[this]={set:function(e,n){return x.isArray(n)?e.checked=x.inArray(x(e).val(),n)>=0:t}},x.support.checkOn||(x.valHooks[this].get=function(e){return null===e.getAttribute("value")?"on":e.value})});var Z=/^(?:input|select|textarea)$/i,et=/^key/,tt=/^(?:mouse|contextmenu)|click/,nt=/^(?:focusinfocus|focusoutblur)$/,rt=/^([^.]*)(?:\.(.+)|)$/;function it(){return!0}function ot(){return!1}function at(){try{return a.activeElement}catch(e){}}x.event={global:{},add:function(e,n,r,o,a){var s,l,u,c,p,f,d,h,g,m,y,v=x._data(e);if(v){r.handler&&(c=r,r=c.handler,a=c.selector),r.guid||(r.guid=x.guid++),(l=v.events)||(l=v.events={}),(f=v.handle)||(f=v.handle=function(e){return typeof x===i||e&&x.event.triggered===e.type?t:x.event.dispatch.apply(f.elem,arguments)},f.elem=e),n=(n||"").match(T)||[""],u=n.length;while(u--)s=rt.exec(n[u])||[],g=y=s[1],m=(s[2]||"").split(".").sort(),g&&(p=x.event.special[g]||{},g=(a?p.delegateType:p.bindType)||g,p=x.event.special[g]||{},d=x.extend({type:g,origType:y,data:o,handler:r,guid:r.guid,selector:a,needsContext:a&&x.expr.match.needsContext.test(a),namespace:m.join(".")},c),(h=l[g])||(h=l[g]=[],h.delegateCount=0,p.setup&&p.setup.call(e,o,m,f)!==!1||(e.addEventListener?e.addEventListener(g,f,!1):e.attachEvent&&e.attachEvent("on"+g,f))),p.add&&(p.add.call(e,d),d.handler.guid||(d.handler.guid=r.guid)),a?h.splice(h.delegateCount++,0,d):h.push(d),x.event.global[g]=!0);e=null}},remove:function(e,t,n,r,i){var o,a,s,l,u,c,p,f,d,h,g,m=x.hasData(e)&&x._data(e);if(m&&(c=m.events)){t=(t||"").match(T)||[""],u=t.length;while(u--)if(s=rt.exec(t[u])||[],d=g=s[1],h=(s[2]||"").split(".").sort(),d){p=x.event.special[d]||{},d=(r?p.delegateType:p.bindType)||d,f=c[d]||[],s=s[2]&&RegExp("(^|\\.)"+h.join("\\.(?:.*\\.|)")+"(\\.|$)"),l=o=f.length;while(o--)a=f[o],!i&&g!==a.origType||n&&n.guid!==a.guid||s&&!s.test(a.namespace)||r&&r!==a.selector&&("**"!==r||!a.selector)||(f.splice(o,1),a.selector&&f.delegateCount--,p.remove&&p.remove.call(e,a));l&&!f.length&&(p.teardown&&p.teardown.call(e,h,m.handle)!==!1||x.removeEvent(e,d,m.handle),delete c[d])}else for(d in c)x.event.remove(e,d+t[u],n,r,!0);x.isEmptyObject(c)&&(delete m.handle,x._removeData(e,"events"))}},trigger:function(n,r,i,o){var s,l,u,c,p,f,d,h=[i||a],g=v.call(n,"type")?n.type:n,m=v.call(n,"namespace")?n.namespace.split("."):[];if(u=f=i=i||a,3!==i.nodeType&&8!==i.nodeType&&!nt.test(g+x.event.triggered)&&(g.indexOf(".")>=0&&(m=g.split("."),g=m.shift(),m.sort()),l=0>g.indexOf(":")&&"on"+g,n=n[x.expando]?n:new x.Event(g,"object"==typeof n&&n),n.isTrigger=o?2:3,n.namespace=m.join("."),n.namespace_re=n.namespace?RegExp("(^|\\.)"+m.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,n.result=t,n.target||(n.target=i),r=null==r?[n]:x.makeArray(r,[n]),p=x.event.special[g]||{},o||!p.trigger||p.trigger.apply(i,r)!==!1)){if(!o&&!p.noBubble&&!x.isWindow(i)){for(c=p.delegateType||g,nt.test(c+g)||(u=u.parentNode);u;u=u.parentNode)h.push(u),f=u;f===(i.ownerDocument||a)&&h.push(f.defaultView||f.parentWindow||e)}d=0;while((u=h[d++])&&!n.isPropagationStopped())n.type=d>1?c:p.bindType||g,s=(x._data(u,"events")||{})[n.type]&&x._data(u,"handle"),s&&s.apply(u,r),s=l&&u[l],s&&x.acceptData(u)&&s.apply&&s.apply(u,r)===!1&&n.preventDefault();if(n.type=g,!o&&!n.isDefaultPrevented()&&(!p._default||p._default.apply(h.pop(),r)===!1)&&x.acceptData(i)&&l&&i[g]&&!x.isWindow(i)){f=i[l],f&&(i[l]=null),x.event.triggered=g;try{i[g]()}catch(y){}x.event.triggered=t,f&&(i[l]=f)}return n.result}},dispatch:function(e){e=x.event.fix(e);var n,r,i,o,a,s=[],l=g.call(arguments),u=(x._data(this,"events")||{})[e.type]||[],c=x.event.special[e.type]||{};if(l[0]=e,e.delegateTarget=this,!c.preDispatch||c.preDispatch.call(this,e)!==!1){s=x.event.handlers.call(this,e,u),n=0;while((o=s[n++])&&!e.isPropagationStopped()){e.currentTarget=o.elem,a=0;while((i=o.handlers[a++])&&!e.isImmediatePropagationStopped())(!e.namespace_re||e.namespace_re.test(i.namespace))&&(e.handleObj=i,e.data=i.data,r=((x.event.special[i.origType]||{}).handle||i.handler).apply(o.elem,l),r!==t&&(e.result=r)===!1&&(e.preventDefault(),e.stopPropagation()))}return c.postDispatch&&c.postDispatch.call(this,e),e.result}},handlers:function(e,n){var r,i,o,a,s=[],l=n.delegateCount,u=e.target;if(l&&u.nodeType&&(!e.button||"click"!==e.type))for(;u!=this;u=u.parentNode||this)if(1===u.nodeType&&(u.disabled!==!0||"click"!==e.type)){for(o=[],a=0;l>a;a++)i=n[a],r=i.selector+" ",o[r]===t&&(o[r]=i.needsContext?x(r,this).index(u)>=0:x.find(r,this,null,[u]).length),o[r]&&o.push(i);o.length&&s.push({elem:u,handlers:o})}return n.length>l&&s.push({elem:this,handlers:n.slice(l)}),s},fix:function(e){if(e[x.expando])return e;var t,n,r,i=e.type,o=e,s=this.fixHooks[i];s||(this.fixHooks[i]=s=tt.test(i)?this.mouseHooks:et.test(i)?this.keyHooks:{}),r=s.props?this.props.concat(s.props):this.props,e=new x.Event(o),t=r.length;while(t--)n=r[t],e[n]=o[n];return e.target||(e.target=o.srcElement||a),3===e.target.nodeType&&(e.target=e.target.parentNode),e.metaKey=!!e.metaKey,s.filter?s.filter(e,o):e},props:"altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(e,t){return null==e.which&&(e.which=null!=t.charCode?t.charCode:t.keyCode),e}},mouseHooks:{props:"button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(e,n){var r,i,o,s=n.button,l=n.fromElement;return null==e.pageX&&null!=n.clientX&&(i=e.target.ownerDocument||a,o=i.documentElement,r=i.body,e.pageX=n.clientX+(o&&o.scrollLeft||r&&r.scrollLeft||0)-(o&&o.clientLeft||r&&r.clientLeft||0),e.pageY=n.clientY+(o&&o.scrollTop||r&&r.scrollTop||0)-(o&&o.clientTop||r&&r.clientTop||0)),!e.relatedTarget&&l&&(e.relatedTarget=l===e.target?n.toElement:l),e.which||s===t||(e.which=1&s?1:2&s?3:4&s?2:0),e}},special:{load:{noBubble:!0},focus:{trigger:function(){if(this!==at()&&this.focus)try{return this.focus(),!1}catch(e){}},delegateType:"focusin"},blur:{trigger:function(){return this===at()&&this.blur?(this.blur(),!1):t},delegateType:"focusout"},click:{trigger:function(){return x.nodeName(this,"input")&&"checkbox"===this.type&&this.click?(this.click(),!1):t},_default:function(e){return x.nodeName(e.target,"a")}},beforeunload:{postDispatch:function(e){e.result!==t&&(e.originalEvent.returnValue=e.result)}}},simulate:function(e,t,n,r){var i=x.extend(new x.Event,n,{type:e,isSimulated:!0,originalEvent:{}});r?x.event.trigger(i,null,t):x.event.dispatch.call(t,i),i.isDefaultPrevented()&&n.preventDefault()}},x.removeEvent=a.removeEventListener?function(e,t,n){e.removeEventListener&&e.removeEventListener(t,n,!1)}:function(e,t,n){var r="on"+t;e.detachEvent&&(typeof e[r]===i&&(e[r]=null),e.detachEvent(r,n))},x.Event=function(e,n){return this instanceof x.Event?(e&&e.type?(this.originalEvent=e,this.type=e.type,this.isDefaultPrevented=e.defaultPrevented||e.returnValue===!1||e.getPreventDefault&&e.getPreventDefault()?it:ot):this.type=e,n&&x.extend(this,n),this.timeStamp=e&&e.timeStamp||x.now(),this[x.expando]=!0,t):new x.Event(e,n)},x.Event.prototype={isDefaultPrevented:ot,isPropagationStopped:ot,isImmediatePropagationStopped:ot,preventDefault:function(){var e=this.originalEvent;this.isDefaultPrevented=it,e&&(e.preventDefault?e.preventDefault():e.returnValue=!1)},stopPropagation:function(){var e=this.originalEvent;this.isPropagationStopped=it,e&&(e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0)},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=it,this.stopPropagation()}},x.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(e,t){x.event.special[e]={delegateType:t,bindType:t,handle:function(e){var n,r=this,i=e.relatedTarget,o=e.handleObj;return(!i||i!==r&&!x.contains(r,i))&&(e.type=o.origType,n=o.handler.apply(this,arguments),e.type=t),n}}}),x.support.submitBubbles||(x.event.special.submit={setup:function(){return x.nodeName(this,"form")?!1:(x.event.add(this,"click._submit keypress._submit",function(e){var n=e.target,r=x.nodeName(n,"input")||x.nodeName(n,"button")?n.form:t;r&&!x._data(r,"submitBubbles")&&(x.event.add(r,"submit._submit",function(e){e._submit_bubble=!0}),x._data(r,"submitBubbles",!0))}),t)},postDispatch:function(e){e._submit_bubble&&(delete e._submit_bubble,this.parentNode&&!e.isTrigger&&x.event.simulate("submit",this.parentNode,e,!0))},teardown:function(){return x.nodeName(this,"form")?!1:(x.event.remove(this,"._submit"),t)}}),x.support.changeBubbles||(x.event.special.change={setup:function(){return Z.test(this.nodeName)?(("checkbox"===this.type||"radio"===this.type)&&(x.event.add(this,"propertychange._change",function(e){"checked"===e.originalEvent.propertyName&&(this._just_changed=!0)}),x.event.add(this,"click._change",function(e){this._just_changed&&!e.isTrigger&&(this._just_changed=!1),x.event.simulate("change",this,e,!0)})),!1):(x.event.add(this,"beforeactivate._change",function(e){var t=e.target;Z.test(t.nodeName)&&!x._data(t,"changeBubbles")&&(x.event.add(t,"change._change",function(e){!this.parentNode||e.isSimulated||e.isTrigger||x.event.simulate("change",this.parentNode,e,!0)}),x._data(t,"changeBubbles",!0))}),t)},handle:function(e){var n=e.target;return this!==n||e.isSimulated||e.isTrigger||"radio"!==n.type&&"checkbox"!==n.type?e.handleObj.handler.apply(this,arguments):t},teardown:function(){return x.event.remove(this,"._change"),!Z.test(this.nodeName)}}),x.support.focusinBubbles||x.each({focus:"focusin",blur:"focusout"},function(e,t){var n=0,r=function(e){x.event.simulate(t,e.target,x.event.fix(e),!0)};x.event.special[t]={setup:function(){0===n++&&a.addEventListener(e,r,!0)},teardown:function(){0===--n&&a.removeEventListener(e,r,!0)}}}),x.fn.extend({on:function(e,n,r,i,o){var a,s;if("object"==typeof e){"string"!=typeof n&&(r=r||n,n=t);for(a in e)this.on(a,n,r,e[a],o);return this}if(null==r&&null==i?(i=n,r=n=t):null==i&&("string"==typeof n?(i=r,r=t):(i=r,r=n,n=t)),i===!1)i=ot;else if(!i)return this;return 1===o&&(s=i,i=function(e){return x().off(e),s.apply(this,arguments)},i.guid=s.guid||(s.guid=x.guid++)),this.each(function(){x.event.add(this,e,i,r,n)})},one:function(e,t,n,r){return this.on(e,t,n,r,1)},off:function(e,n,r){var i,o;if(e&&e.preventDefault&&e.handleObj)return i=e.handleObj,x(e.delegateTarget).off(i.namespace?i.origType+"."+i.namespace:i.origType,i.selector,i.handler),this;if("object"==typeof e){for(o in e)this.off(o,n,e[o]);return this}return(n===!1||"function"==typeof n)&&(r=n,n=t),r===!1&&(r=ot),this.each(function(){x.event.remove(this,e,r,n)})},trigger:function(e,t){return this.each(function(){x.event.trigger(e,t,this)})},triggerHandler:function(e,n){var r=this[0];return r?x.event.trigger(e,n,r,!0):t}});var st=/^.[^:#\[\.,]*$/,lt=/^(?:parents|prev(?:Until|All))/,ut=x.expr.match.needsContext,ct={children:!0,contents:!0,next:!0,prev:!0};x.fn.extend({find:function(e){var t,n=[],r=this,i=r.length;if("string"!=typeof e)return this.pushStack(x(e).filter(function(){for(t=0;i>t;t++)if(x.contains(r[t],this))return!0}));for(t=0;i>t;t++)x.find(e,r[t],n);return n=this.pushStack(i>1?x.unique(n):n),n.selector=this.selector?this.selector+" "+e:e,n},has:function(e){var t,n=x(e,this),r=n.length;return this.filter(function(){for(t=0;r>t;t++)if(x.contains(this,n[t]))return!0})},not:function(e){return this.pushStack(ft(this,e||[],!0))},filter:function(e){return this.pushStack(ft(this,e||[],!1))},is:function(e){return!!ft(this,"string"==typeof e&&ut.test(e)?x(e):e||[],!1).length},closest:function(e,t){var n,r=0,i=this.length,o=[],a=ut.test(e)||"string"!=typeof e?x(e,t||this.context):0;for(;i>r;r++)for(n=this[r];n&&n!==t;n=n.parentNode)if(11>n.nodeType&&(a?a.index(n)>-1:1===n.nodeType&&x.find.matchesSelector(n,e))){n=o.push(n);break}return this.pushStack(o.length>1?x.unique(o):o)},index:function(e){return e?"string"==typeof e?x.inArray(this[0],x(e)):x.inArray(e.jquery?e[0]:e,this):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,t){var n="string"==typeof e?x(e,t):x.makeArray(e&&e.nodeType?[e]:e),r=x.merge(this.get(),n);return this.pushStack(x.unique(r))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}});function pt(e,t){do e=e[t];while(e&&1!==e.nodeType);return e}x.each({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},parents:function(e){return x.dir(e,"parentNode")},parentsUntil:function(e,t,n){return x.dir(e,"parentNode",n)},next:function(e){return pt(e,"nextSibling")},prev:function(e){return pt(e,"previousSibling")},nextAll:function(e){return x.dir(e,"nextSibling")},prevAll:function(e){return x.dir(e,"previousSibling")},nextUntil:function(e,t,n){return x.dir(e,"nextSibling",n)},prevUntil:function(e,t,n){return x.dir(e,"previousSibling",n)},siblings:function(e){return x.sibling((e.parentNode||{}).firstChild,e)},children:function(e){return x.sibling(e.firstChild)},contents:function(e){return x.nodeName(e,"iframe")?e.contentDocument||e.contentWindow.document:x.merge([],e.childNodes)}},function(e,t){x.fn[e]=function(n,r){var i=x.map(this,t,n);return"Until"!==e.slice(-5)&&(r=n),r&&"string"==typeof r&&(i=x.filter(r,i)),this.length>1&&(ct[e]||(i=x.unique(i)),lt.test(e)&&(i=i.reverse())),this.pushStack(i)}}),x.extend({filter:function(e,t,n){var r=t[0];return n&&(e=":not("+e+")"),1===t.length&&1===r.nodeType?x.find.matchesSelector(r,e)?[r]:[]:x.find.matches(e,x.grep(t,function(e){return 1===e.nodeType}))},dir:function(e,n,r){var i=[],o=e[n];while(o&&9!==o.nodeType&&(r===t||1!==o.nodeType||!x(o).is(r)))1===o.nodeType&&i.push(o),o=o[n];return i},sibling:function(e,t){var n=[];for(;e;e=e.nextSibling)1===e.nodeType&&e!==t&&n.push(e);return n}});function ft(e,t,n){if(x.isFunction(t))return x.grep(e,function(e,r){return!!t.call(e,r,e)!==n});if(t.nodeType)return x.grep(e,function(e){return e===t!==n});if("string"==typeof t){if(st.test(t))return x.filter(t,e,n);t=x.filter(t,e)}return x.grep(e,function(e){return x.inArray(e,t)>=0!==n})}function dt(e){var t=ht.split("|"),n=e.createDocumentFragment();if(n.createElement)while(t.length)n.createElement(t.pop());return n}var ht="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",gt=/ jQuery\d+="(?:null|\d+)"/g,mt=RegExp("<(?:"+ht+")[\\s/>]","i"),yt=/^\s+/,vt=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,bt=/<([\w:]+)/,xt=/<tbody/i,wt=/<|&#?\w+;/,Tt=/<(?:script|style|link)/i,Ct=/^(?:checkbox|radio)$/i,Nt=/checked\s*(?:[^=]|=\s*.checked.)/i,kt=/^$|\/(?:java|ecma)script/i,Et=/^true\/(.*)/,St=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,At={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],area:[1,"<map>","</map>"],param:[1,"<object>","</object>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:x.support.htmlSerialize?[0,"",""]:[1,"X<div>","</div>"]},jt=dt(a),Dt=jt.appendChild(a.createElement("div"));At.optgroup=At.option,At.tbody=At.tfoot=At.colgroup=At.caption=At.thead,At.th=At.td,x.fn.extend({text:function(e){return x.access(this,function(e){return e===t?x.text(this):this.empty().append((this[0]&&this[0].ownerDocument||a).createTextNode(e))},null,e,arguments.length)},append:function(){return this.domManip(arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=Lt(this,e);t.appendChild(e)}})},prepend:function(){return this.domManip(arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=Lt(this,e);t.insertBefore(e,t.firstChild)}})},before:function(){return this.domManip(arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this)})},after:function(){return this.domManip(arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)})},remove:function(e,t){var n,r=e?x.filter(e,this):this,i=0;for(;null!=(n=r[i]);i++)t||1!==n.nodeType||x.cleanData(Ft(n)),n.parentNode&&(t&&x.contains(n.ownerDocument,n)&&_t(Ft(n,"script")),n.parentNode.removeChild(n));return this},empty:function(){var e,t=0;for(;null!=(e=this[t]);t++){1===e.nodeType&&x.cleanData(Ft(e,!1));while(e.firstChild)e.removeChild(e.firstChild);e.options&&x.nodeName(e,"select")&&(e.options.length=0)}return this},clone:function(e,t){return e=null==e?!1:e,t=null==t?e:t,this.map(function(){return x.clone(this,e,t)})},html:function(e){return x.access(this,function(e){var n=this[0]||{},r=0,i=this.length;if(e===t)return 1===n.nodeType?n.innerHTML.replace(gt,""):t;if(!("string"!=typeof e||Tt.test(e)||!x.support.htmlSerialize&&mt.test(e)||!x.support.leadingWhitespace&&yt.test(e)||At[(bt.exec(e)||["",""])[1].toLowerCase()])){e=e.replace(vt,"<$1></$2>");try{for(;i>r;r++)n=this[r]||{},1===n.nodeType&&(x.cleanData(Ft(n,!1)),n.innerHTML=e);n=0}catch(o){}}n&&this.empty().append(e)},null,e,arguments.length)},replaceWith:function(){var e=x.map(this,function(e){return[e.nextSibling,e.parentNode]}),t=0;return this.domManip(arguments,function(n){var r=e[t++],i=e[t++];i&&(r&&r.parentNode!==i&&(r=this.nextSibling),x(this).remove(),i.insertBefore(n,r))},!0),t?this:this.remove()},detach:function(e){return this.remove(e,!0)},domManip:function(e,t,n){e=d.apply([],e);var r,i,o,a,s,l,u=0,c=this.length,p=this,f=c-1,h=e[0],g=x.isFunction(h);if(g||!(1>=c||"string"!=typeof h||x.support.checkClone)&&Nt.test(h))return this.each(function(r){var i=p.eq(r);g&&(e[0]=h.call(this,r,i.html())),i.domManip(e,t,n)});if(c&&(l=x.buildFragment(e,this[0].ownerDocument,!1,!n&&this),r=l.firstChild,1===l.childNodes.length&&(l=r),r)){for(a=x.map(Ft(l,"script"),Ht),o=a.length;c>u;u++)i=l,u!==f&&(i=x.clone(i,!0,!0),o&&x.merge(a,Ft(i,"script"))),t.call(this[u],i,u);if(o)for(s=a[a.length-1].ownerDocument,x.map(a,qt),u=0;o>u;u++)i=a[u],kt.test(i.type||"")&&!x._data(i,"globalEval")&&x.contains(s,i)&&(i.src?x._evalUrl(i.src):x.globalEval((i.text||i.textContent||i.innerHTML||"").replace(St,"")));l=r=null}return this}});function Lt(e,t){return x.nodeName(e,"table")&&x.nodeName(1===t.nodeType?t:t.firstChild,"tr")?e.getElementsByTagName("tbody")[0]||e.appendChild(e.ownerDocument.createElement("tbody")):e}function Ht(e){return e.type=(null!==x.find.attr(e,"type"))+"/"+e.type,e}function qt(e){var t=Et.exec(e.type);return t?e.type=t[1]:e.removeAttribute("type"),e}function _t(e,t){var n,r=0;for(;null!=(n=e[r]);r++)x._data(n,"globalEval",!t||x._data(t[r],"globalEval"))}function Mt(e,t){if(1===t.nodeType&&x.hasData(e)){var n,r,i,o=x._data(e),a=x._data(t,o),s=o.events;if(s){delete a.handle,a.events={};for(n in s)for(r=0,i=s[n].length;i>r;r++)x.event.add(t,n,s[n][r])}a.data&&(a.data=x.extend({},a.data))}}function Ot(e,t){var n,r,i;if(1===t.nodeType){if(n=t.nodeName.toLowerCase(),!x.support.noCloneEvent&&t[x.expando]){i=x._data(t);for(r in i.events)x.removeEvent(t,r,i.handle);t.removeAttribute(x.expando)}"script"===n&&t.text!==e.text?(Ht(t).text=e.text,qt(t)):"object"===n?(t.parentNode&&(t.outerHTML=e.outerHTML),x.support.html5Clone&&e.innerHTML&&!x.trim(t.innerHTML)&&(t.innerHTML=e.innerHTML)):"input"===n&&Ct.test(e.type)?(t.defaultChecked=t.checked=e.checked,t.value!==e.value&&(t.value=e.value)):"option"===n?t.defaultSelected=t.selected=e.defaultSelected:("input"===n||"textarea"===n)&&(t.defaultValue=e.defaultValue)}}x.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(e,t){x.fn[e]=function(e){var n,r=0,i=[],o=x(e),a=o.length-1;for(;a>=r;r++)n=r===a?this:this.clone(!0),x(o[r])[t](n),h.apply(i,n.get());return this.pushStack(i)}});function Ft(e,n){var r,o,a=0,s=typeof e.getElementsByTagName!==i?e.getElementsByTagName(n||"*"):typeof e.querySelectorAll!==i?e.querySelectorAll(n||"*"):t;if(!s)for(s=[],r=e.childNodes||e;null!=(o=r[a]);a++)!n||x.nodeName(o,n)?s.push(o):x.merge(s,Ft(o,n));return n===t||n&&x.nodeName(e,n)?x.merge([e],s):s}function Bt(e){Ct.test(e.type)&&(e.defaultChecked=e.checked)}x.extend({clone:function(e,t,n){var r,i,o,a,s,l=x.contains(e.ownerDocument,e);if(x.support.html5Clone||x.isXMLDoc(e)||!mt.test("<"+e.nodeName+">")?o=e.cloneNode(!0):(Dt.innerHTML=e.outerHTML,Dt.removeChild(o=Dt.firstChild)),!(x.support.noCloneEvent&&x.support.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||x.isXMLDoc(e)))for(r=Ft(o),s=Ft(e),a=0;null!=(i=s[a]);++a)r[a]&&Ot(i,r[a]);if(t)if(n)for(s=s||Ft(e),r=r||Ft(o),a=0;null!=(i=s[a]);a++)Mt(i,r[a]);else Mt(e,o);return r=Ft(o,"script"),r.length>0&&_t(r,!l&&Ft(e,"script")),r=s=i=null,o},buildFragment:function(e,t,n,r){var i,o,a,s,l,u,c,p=e.length,f=dt(t),d=[],h=0;for(;p>h;h++)if(o=e[h],o||0===o)if("object"===x.type(o))x.merge(d,o.nodeType?[o]:o);else if(wt.test(o)){s=s||f.appendChild(t.createElement("div")),l=(bt.exec(o)||["",""])[1].toLowerCase(),c=At[l]||At._default,s.innerHTML=c[1]+o.replace(vt,"<$1></$2>")+c[2],i=c[0];while(i--)s=s.lastChild;if(!x.support.leadingWhitespace&&yt.test(o)&&d.push(t.createTextNode(yt.exec(o)[0])),!x.support.tbody){o="table"!==l||xt.test(o)?"<table>"!==c[1]||xt.test(o)?0:s:s.firstChild,i=o&&o.childNodes.length;while(i--)x.nodeName(u=o.childNodes[i],"tbody")&&!u.childNodes.length&&o.removeChild(u)}x.merge(d,s.childNodes),s.textContent="";while(s.firstChild)s.removeChild(s.firstChild);s=f.lastChild}else d.push(t.createTextNode(o));s&&f.removeChild(s),x.support.appendChecked||x.grep(Ft(d,"input"),Bt),h=0;while(o=d[h++])if((!r||-1===x.inArray(o,r))&&(a=x.contains(o.ownerDocument,o),s=Ft(f.appendChild(o),"script"),a&&_t(s),n)){i=0;while(o=s[i++])kt.test(o.type||"")&&n.push(o)}return s=null,f},cleanData:function(e,t){var n,r,o,a,s=0,l=x.expando,u=x.cache,c=x.support.deleteExpando,f=x.event.special;for(;null!=(n=e[s]);s++)if((t||x.acceptData(n))&&(o=n[l],a=o&&u[o])){if(a.events)for(r in a.events)f[r]?x.event.remove(n,r):x.removeEvent(n,r,a.handle);
6u[o]&&(delete u[o],c?delete n[l]:typeof n.removeAttribute!==i?n.removeAttribute(l):n[l]=null,p.push(o))}},_evalUrl:function(e){return x.ajax({url:e,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0})}}),x.fn.extend({wrapAll:function(e){if(x.isFunction(e))return this.each(function(t){x(this).wrapAll(e.call(this,t))});if(this[0]){var t=x(e,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){var e=this;while(e.firstChild&&1===e.firstChild.nodeType)e=e.firstChild;return e}).append(this)}return this},wrapInner:function(e){return x.isFunction(e)?this.each(function(t){x(this).wrapInner(e.call(this,t))}):this.each(function(){var t=x(this),n=t.contents();n.length?n.wrapAll(e):t.append(e)})},wrap:function(e){var t=x.isFunction(e);return this.each(function(n){x(this).wrapAll(t?e.call(this,n):e)})},unwrap:function(){return this.parent().each(function(){x.nodeName(this,"body")||x(this).replaceWith(this.childNodes)}).end()}});var Pt,Rt,Wt,$t=/alpha\([^)]*\)/i,It=/opacity\s*=\s*([^)]*)/,zt=/^(top|right|bottom|left)$/,Xt=/^(none|table(?!-c[ea]).+)/,Ut=/^margin/,Vt=RegExp("^("+w+")(.*)$","i"),Yt=RegExp("^("+w+")(?!px)[a-z%]+$","i"),Jt=RegExp("^([+-])=("+w+")","i"),Gt={BODY:"block"},Qt={position:"absolute",visibility:"hidden",display:"block"},Kt={letterSpacing:0,fontWeight:400},Zt=["Top","Right","Bottom","Left"],en=["Webkit","O","Moz","ms"];function tn(e,t){if(t in e)return t;var n=t.charAt(0).toUpperCase()+t.slice(1),r=t,i=en.length;while(i--)if(t=en[i]+n,t in e)return t;return r}function nn(e,t){return e=t||e,"none"===x.css(e,"display")||!x.contains(e.ownerDocument,e)}function rn(e,t){var n,r,i,o=[],a=0,s=e.length;for(;s>a;a++)r=e[a],r.style&&(o[a]=x._data(r,"olddisplay"),n=r.style.display,t?(o[a]||"none"!==n||(r.style.display=""),""===r.style.display&&nn(r)&&(o[a]=x._data(r,"olddisplay",ln(r.nodeName)))):o[a]||(i=nn(r),(n&&"none"!==n||!i)&&x._data(r,"olddisplay",i?n:x.css(r,"display"))));for(a=0;s>a;a++)r=e[a],r.style&&(t&&"none"!==r.style.display&&""!==r.style.display||(r.style.display=t?o[a]||"":"none"));return e}x.fn.extend({css:function(e,n){return x.access(this,function(e,n,r){var i,o,a={},s=0;if(x.isArray(n)){for(o=Rt(e),i=n.length;i>s;s++)a[n[s]]=x.css(e,n[s],!1,o);return a}return r!==t?x.style(e,n,r):x.css(e,n)},e,n,arguments.length>1)},show:function(){return rn(this,!0)},hide:function(){return rn(this)},toggle:function(e){return"boolean"==typeof e?e?this.show():this.hide():this.each(function(){nn(this)?x(this).show():x(this).hide()})}}),x.extend({cssHooks:{opacity:{get:function(e,t){if(t){var n=Wt(e,"opacity");return""===n?"1":n}}}},cssNumber:{columnCount:!0,fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":x.support.cssFloat?"cssFloat":"styleFloat"},style:function(e,n,r,i){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var o,a,s,l=x.camelCase(n),u=e.style;if(n=x.cssProps[l]||(x.cssProps[l]=tn(u,l)),s=x.cssHooks[n]||x.cssHooks[l],r===t)return s&&"get"in s&&(o=s.get(e,!1,i))!==t?o:u[n];if(a=typeof r,"string"===a&&(o=Jt.exec(r))&&(r=(o[1]+1)*o[2]+parseFloat(x.css(e,n)),a="number"),!(null==r||"number"===a&&isNaN(r)||("number"!==a||x.cssNumber[l]||(r+="px"),x.support.clearCloneStyle||""!==r||0!==n.indexOf("background")||(u[n]="inherit"),s&&"set"in s&&(r=s.set(e,r,i))===t)))try{u[n]=r}catch(c){}}},css:function(e,n,r,i){var o,a,s,l=x.camelCase(n);return n=x.cssProps[l]||(x.cssProps[l]=tn(e.style,l)),s=x.cssHooks[n]||x.cssHooks[l],s&&"get"in s&&(a=s.get(e,!0,r)),a===t&&(a=Wt(e,n,i)),"normal"===a&&n in Kt&&(a=Kt[n]),""===r||r?(o=parseFloat(a),r===!0||x.isNumeric(o)?o||0:a):a}}),e.getComputedStyle?(Rt=function(t){return e.getComputedStyle(t,null)},Wt=function(e,n,r){var i,o,a,s=r||Rt(e),l=s?s.getPropertyValue(n)||s[n]:t,u=e.style;return s&&(""!==l||x.contains(e.ownerDocument,e)||(l=x.style(e,n)),Yt.test(l)&&Ut.test(n)&&(i=u.width,o=u.minWidth,a=u.maxWidth,u.minWidth=u.maxWidth=u.width=l,l=s.width,u.width=i,u.minWidth=o,u.maxWidth=a)),l}):a.documentElement.currentStyle&&(Rt=function(e){return e.currentStyle},Wt=function(e,n,r){var i,o,a,s=r||Rt(e),l=s?s[n]:t,u=e.style;return null==l&&u&&u[n]&&(l=u[n]),Yt.test(l)&&!zt.test(n)&&(i=u.left,o=e.runtimeStyle,a=o&&o.left,a&&(o.left=e.currentStyle.left),u.left="fontSize"===n?"1em":l,l=u.pixelLeft+"px",u.left=i,a&&(o.left=a)),""===l?"auto":l});function on(e,t,n){var r=Vt.exec(t);return r?Math.max(0,r[1]-(n||0))+(r[2]||"px"):t}function an(e,t,n,r,i){var o=n===(r?"border":"content")?4:"width"===t?1:0,a=0;for(;4>o;o+=2)"margin"===n&&(a+=x.css(e,n+Zt[o],!0,i)),r?("content"===n&&(a-=x.css(e,"padding"+Zt[o],!0,i)),"margin"!==n&&(a-=x.css(e,"border"+Zt[o]+"Width",!0,i))):(a+=x.css(e,"padding"+Zt[o],!0,i),"padding"!==n&&(a+=x.css(e,"border"+Zt[o]+"Width",!0,i)));return a}function sn(e,t,n){var r=!0,i="width"===t?e.offsetWidth:e.offsetHeight,o=Rt(e),a=x.support.boxSizing&&"border-box"===x.css(e,"boxSizing",!1,o);if(0>=i||null==i){if(i=Wt(e,t,o),(0>i||null==i)&&(i=e.style[t]),Yt.test(i))return i;r=a&&(x.support.boxSizingReliable||i===e.style[t]),i=parseFloat(i)||0}return i+an(e,t,n||(a?"border":"content"),r,o)+"px"}function ln(e){var t=a,n=Gt[e];return n||(n=un(e,t),"none"!==n&&n||(Pt=(Pt||x("<iframe frameborder='0' width='0' height='0'/>").css("cssText","display:block !important")).appendTo(t.documentElement),t=(Pt[0].contentWindow||Pt[0].contentDocument).document,t.write("<!doctype html><html><body>"),t.close(),n=un(e,t),Pt.detach()),Gt[e]=n),n}function un(e,t){var n=x(t.createElement(e)).appendTo(t.body),r=x.css(n[0],"display");return n.remove(),r}x.each(["height","width"],function(e,n){x.cssHooks[n]={get:function(e,r,i){return r?0===e.offsetWidth&&Xt.test(x.css(e,"display"))?x.swap(e,Qt,function(){return sn(e,n,i)}):sn(e,n,i):t},set:function(e,t,r){var i=r&&Rt(e);return on(e,t,r?an(e,n,r,x.support.boxSizing&&"border-box"===x.css(e,"boxSizing",!1,i),i):0)}}}),x.support.opacity||(x.cssHooks.opacity={get:function(e,t){return It.test((t&&e.currentStyle?e.currentStyle.filter:e.style.filter)||"")?.01*parseFloat(RegExp.$1)+"":t?"1":""},set:function(e,t){var n=e.style,r=e.currentStyle,i=x.isNumeric(t)?"alpha(opacity="+100*t+")":"",o=r&&r.filter||n.filter||"";n.zoom=1,(t>=1||""===t)&&""===x.trim(o.replace($t,""))&&n.removeAttribute&&(n.removeAttribute("filter"),""===t||r&&!r.filter)||(n.filter=$t.test(o)?o.replace($t,i):o+" "+i)}}),x(function(){x.support.reliableMarginRight||(x.cssHooks.marginRight={get:function(e,n){return n?x.swap(e,{display:"inline-block"},Wt,[e,"marginRight"]):t}}),!x.support.pixelPosition&&x.fn.position&&x.each(["top","left"],function(e,n){x.cssHooks[n]={get:function(e,r){return r?(r=Wt(e,n),Yt.test(r)?x(e).position()[n]+"px":r):t}}})}),x.expr&&x.expr.filters&&(x.expr.filters.hidden=function(e){return 0>=e.offsetWidth&&0>=e.offsetHeight||!x.support.reliableHiddenOffsets&&"none"===(e.style&&e.style.display||x.css(e,"display"))},x.expr.filters.visible=function(e){return!x.expr.filters.hidden(e)}),x.each({margin:"",padding:"",border:"Width"},function(e,t){x.cssHooks[e+t]={expand:function(n){var r=0,i={},o="string"==typeof n?n.split(" "):[n];for(;4>r;r++)i[e+Zt[r]+t]=o[r]||o[r-2]||o[0];return i}},Ut.test(e)||(x.cssHooks[e+t].set=on)});var cn=/%20/g,pn=/\[\]$/,fn=/\r?\n/g,dn=/^(?:submit|button|image|reset|file)$/i,hn=/^(?:input|select|textarea|keygen)/i;x.fn.extend({serialize:function(){return x.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var e=x.prop(this,"elements");return e?x.makeArray(e):this}).filter(function(){var e=this.type;return this.name&&!x(this).is(":disabled")&&hn.test(this.nodeName)&&!dn.test(e)&&(this.checked||!Ct.test(e))}).map(function(e,t){var n=x(this).val();return null==n?null:x.isArray(n)?x.map(n,function(e){return{name:t.name,value:e.replace(fn,"\r\n")}}):{name:t.name,value:n.replace(fn,"\r\n")}}).get()}}),x.param=function(e,n){var r,i=[],o=function(e,t){t=x.isFunction(t)?t():null==t?"":t,i[i.length]=encodeURIComponent(e)+"="+encodeURIComponent(t)};if(n===t&&(n=x.ajaxSettings&&x.ajaxSettings.traditional),x.isArray(e)||e.jquery&&!x.isPlainObject(e))x.each(e,function(){o(this.name,this.value)});else for(r in e)gn(r,e[r],n,o);return i.join("&").replace(cn,"+")};function gn(e,t,n,r){var i;if(x.isArray(t))x.each(t,function(t,i){n||pn.test(e)?r(e,i):gn(e+"["+("object"==typeof i?t:"")+"]",i,n,r)});else if(n||"object"!==x.type(t))r(e,t);else for(i in t)gn(e+"["+i+"]",t[i],n,r)}x.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(e,t){x.fn[t]=function(e,n){return arguments.length>0?this.on(t,null,e,n):this.trigger(t)}}),x.fn.extend({hover:function(e,t){return this.mouseenter(e).mouseleave(t||e)},bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",n)}});var mn,yn,vn=x.now(),bn=/\?/,xn=/#.*$/,wn=/([?&])_=[^&]*/,Tn=/^(.*?):[ \t]*([^\r\n]*)\r?$/gm,Cn=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Nn=/^(?:GET|HEAD)$/,kn=/^\/\//,En=/^([\w.+-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/,Sn=x.fn.load,An={},jn={},Dn="*/".concat("*");try{yn=o.href}catch(Ln){yn=a.createElement("a"),yn.href="",yn=yn.href}mn=En.exec(yn.toLowerCase())||[];function Hn(e){return function(t,n){"string"!=typeof t&&(n=t,t="*");var r,i=0,o=t.toLowerCase().match(T)||[];if(x.isFunction(n))while(r=o[i++])"+"===r[0]?(r=r.slice(1)||"*",(e[r]=e[r]||[]).unshift(n)):(e[r]=e[r]||[]).push(n)}}function qn(e,n,r,i){var o={},a=e===jn;function s(l){var u;return o[l]=!0,x.each(e[l]||[],function(e,l){var c=l(n,r,i);return"string"!=typeof c||a||o[c]?a?!(u=c):t:(n.dataTypes.unshift(c),s(c),!1)}),u}return s(n.dataTypes[0])||!o["*"]&&s("*")}function _n(e,n){var r,i,o=x.ajaxSettings.flatOptions||{};for(i in n)n[i]!==t&&((o[i]?e:r||(r={}))[i]=n[i]);return r&&x.extend(!0,e,r),e}x.fn.load=function(e,n,r){if("string"!=typeof e&&Sn)return Sn.apply(this,arguments);var i,o,a,s=this,l=e.indexOf(" ");return l>=0&&(i=e.slice(l,e.length),e=e.slice(0,l)),x.isFunction(n)?(r=n,n=t):n&&"object"==typeof n&&(a="POST"),s.length>0&&x.ajax({url:e,type:a,dataType:"html",data:n}).done(function(e){o=arguments,s.html(i?x("<div>").append(x.parseHTML(e)).find(i):e)}).complete(r&&function(e,t){s.each(r,o||[e.responseText,t,e])}),this},x.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){x.fn[t]=function(e){return this.on(t,e)}}),x.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:yn,type:"GET",isLocal:Cn.test(mn[1]),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Dn,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":x.parseJSON,"text xml":x.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,t){return t?_n(_n(e,x.ajaxSettings),t):_n(x.ajaxSettings,e)},ajaxPrefilter:Hn(An),ajaxTransport:Hn(jn),ajax:function(e,n){"object"==typeof e&&(n=e,e=t),n=n||{};var r,i,o,a,s,l,u,c,p=x.ajaxSetup({},n),f=p.context||p,d=p.context&&(f.nodeType||f.jquery)?x(f):x.event,h=x.Deferred(),g=x.Callbacks("once memory"),m=p.statusCode||{},y={},v={},b=0,w="canceled",C={readyState:0,getResponseHeader:function(e){var t;if(2===b){if(!c){c={};while(t=Tn.exec(a))c[t[1].toLowerCase()]=t[2]}t=c[e.toLowerCase()]}return null==t?null:t},getAllResponseHeaders:function(){return 2===b?a:null},setRequestHeader:function(e,t){var n=e.toLowerCase();return b||(e=v[n]=v[n]||e,y[e]=t),this},overrideMimeType:function(e){return b||(p.mimeType=e),this},statusCode:function(e){var t;if(e)if(2>b)for(t in e)m[t]=[m[t],e[t]];else C.always(e[C.status]);return this},abort:function(e){var t=e||w;return u&&u.abort(t),k(0,t),this}};if(h.promise(C).complete=g.add,C.success=C.done,C.error=C.fail,p.url=((e||p.url||yn)+"").replace(xn,"").replace(kn,mn[1]+"//"),p.type=n.method||n.type||p.method||p.type,p.dataTypes=x.trim(p.dataType||"*").toLowerCase().match(T)||[""],null==p.crossDomain&&(r=En.exec(p.url.toLowerCase()),p.crossDomain=!(!r||r[1]===mn[1]&&r[2]===mn[2]&&(r[3]||("http:"===r[1]?"80":"443"))===(mn[3]||("http:"===mn[1]?"80":"443")))),p.data&&p.processData&&"string"!=typeof p.data&&(p.data=x.param(p.data,p.traditional)),qn(An,p,n,C),2===b)return C;l=p.global,l&&0===x.active++&&x.event.trigger("ajaxStart"),p.type=p.type.toUpperCase(),p.hasContent=!Nn.test(p.type),o=p.url,p.hasContent||(p.data&&(o=p.url+=(bn.test(o)?"&":"?")+p.data,delete p.data),p.cache===!1&&(p.url=wn.test(o)?o.replace(wn,"$1_="+vn++):o+(bn.test(o)?"&":"?")+"_="+vn++)),p.ifModified&&(x.lastModified[o]&&C.setRequestHeader("If-Modified-Since",x.lastModified[o]),x.etag[o]&&C.setRequestHeader("If-None-Match",x.etag[o])),(p.data&&p.hasContent&&p.contentType!==!1||n.contentType)&&C.setRequestHeader("Content-Type",p.contentType),C.setRequestHeader("Accept",p.dataTypes[0]&&p.accepts[p.dataTypes[0]]?p.accepts[p.dataTypes[0]]+("*"!==p.dataTypes[0]?", "+Dn+"; q=0.01":""):p.accepts["*"]);for(i in p.headers)C.setRequestHeader(i,p.headers[i]);if(p.beforeSend&&(p.beforeSend.call(f,C,p)===!1||2===b))return C.abort();w="abort";for(i in{success:1,error:1,complete:1})C[i](p[i]);if(u=qn(jn,p,n,C)){C.readyState=1,l&&d.trigger("ajaxSend",[C,p]),p.async&&p.timeout>0&&(s=setTimeout(function(){C.abort("timeout")},p.timeout));try{b=1,u.send(y,k)}catch(N){if(!(2>b))throw N;k(-1,N)}}else k(-1,"No Transport");function k(e,n,r,i){var c,y,v,w,T,N=n;2!==b&&(b=2,s&&clearTimeout(s),u=t,a=i||"",C.readyState=e>0?4:0,c=e>=200&&300>e||304===e,r&&(w=Mn(p,C,r)),w=On(p,w,C,c),c?(p.ifModified&&(T=C.getResponseHeader("Last-Modified"),T&&(x.lastModified[o]=T),T=C.getResponseHeader("etag"),T&&(x.etag[o]=T)),204===e||"HEAD"===p.type?N="nocontent":304===e?N="notmodified":(N=w.state,y=w.data,v=w.error,c=!v)):(v=N,(e||!N)&&(N="error",0>e&&(e=0))),C.status=e,C.statusText=(n||N)+"",c?h.resolveWith(f,[y,N,C]):h.rejectWith(f,[C,N,v]),C.statusCode(m),m=t,l&&d.trigger(c?"ajaxSuccess":"ajaxError",[C,p,c?y:v]),g.fireWith(f,[C,N]),l&&(d.trigger("ajaxComplete",[C,p]),--x.active||x.event.trigger("ajaxStop")))}return C},getJSON:function(e,t,n){return x.get(e,t,n,"json")},getScript:function(e,n){return x.get(e,t,n,"script")}}),x.each(["get","post"],function(e,n){x[n]=function(e,r,i,o){return x.isFunction(r)&&(o=o||i,i=r,r=t),x.ajax({url:e,type:n,dataType:o,data:r,success:i})}});function Mn(e,n,r){var i,o,a,s,l=e.contents,u=e.dataTypes;while("*"===u[0])u.shift(),o===t&&(o=e.mimeType||n.getResponseHeader("Content-Type"));if(o)for(s in l)if(l[s]&&l[s].test(o)){u.unshift(s);break}if(u[0]in r)a=u[0];else{for(s in r){if(!u[0]||e.converters[s+" "+u[0]]){a=s;break}i||(i=s)}a=a||i}return a?(a!==u[0]&&u.unshift(a),r[a]):t}function On(e,t,n,r){var i,o,a,s,l,u={},c=e.dataTypes.slice();if(c[1])for(a in e.converters)u[a.toLowerCase()]=e.converters[a];o=c.shift();while(o)if(e.responseFields[o]&&(n[e.responseFields[o]]=t),!l&&r&&e.dataFilter&&(t=e.dataFilter(t,e.dataType)),l=o,o=c.shift())if("*"===o)o=l;else if("*"!==l&&l!==o){if(a=u[l+" "+o]||u["* "+o],!a)for(i in u)if(s=i.split(" "),s[1]===o&&(a=u[l+" "+s[0]]||u["* "+s[0]])){a===!0?a=u[i]:u[i]!==!0&&(o=s[0],c.unshift(s[1]));break}if(a!==!0)if(a&&e["throws"])t=a(t);else try{t=a(t)}catch(p){return{state:"parsererror",error:a?p:"No conversion from "+l+" to "+o}}}return{state:"success",data:t}}x.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/(?:java|ecma)script/},converters:{"text script":function(e){return x.globalEval(e),e}}}),x.ajaxPrefilter("script",function(e){e.cache===t&&(e.cache=!1),e.crossDomain&&(e.type="GET",e.global=!1)}),x.ajaxTransport("script",function(e){if(e.crossDomain){var n,r=a.head||x("head")[0]||a.documentElement;return{send:function(t,i){n=a.createElement("script"),n.async=!0,e.scriptCharset&&(n.charset=e.scriptCharset),n.src=e.url,n.onload=n.onreadystatechange=function(e,t){(t||!n.readyState||/loaded|complete/.test(n.readyState))&&(n.onload=n.onreadystatechange=null,n.parentNode&&n.parentNode.removeChild(n),n=null,t||i(200,"success"))},r.insertBefore(n,r.firstChild)},abort:function(){n&&n.onload(t,!0)}}}});var Fn=[],Bn=/(=)\?(?=&|$)|\?\?/;x.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=Fn.pop()||x.expando+"_"+vn++;return this[e]=!0,e}}),x.ajaxPrefilter("json jsonp",function(n,r,i){var o,a,s,l=n.jsonp!==!1&&(Bn.test(n.url)?"url":"string"==typeof n.data&&!(n.contentType||"").indexOf("application/x-www-form-urlencoded")&&Bn.test(n.data)&&"data");return l||"jsonp"===n.dataTypes[0]?(o=n.jsonpCallback=x.isFunction(n.jsonpCallback)?n.jsonpCallback():n.jsonpCallback,l?n[l]=n[l].replace(Bn,"$1"+o):n.jsonp!==!1&&(n.url+=(bn.test(n.url)?"&":"?")+n.jsonp+"="+o),n.converters["script json"]=function(){return s||x.error(o+" was not called"),s[0]},n.dataTypes[0]="json",a=e[o],e[o]=function(){s=arguments},i.always(function(){e[o]=a,n[o]&&(n.jsonpCallback=r.jsonpCallback,Fn.push(o)),s&&x.isFunction(a)&&a(s[0]),s=a=t}),"script"):t});var Pn,Rn,Wn=0,$n=e.ActiveXObject&&function(){var e;for(e in Pn)Pn[e](t,!0)};function In(){try{return new e.XMLHttpRequest}catch(t){}}function zn(){try{return new e.ActiveXObject("Microsoft.XMLHTTP")}catch(t){}}x.ajaxSettings.xhr=e.ActiveXObject?function(){return!this.isLocal&&In()||zn()}:In,Rn=x.ajaxSettings.xhr(),x.support.cors=!!Rn&&"withCredentials"in Rn,Rn=x.support.ajax=!!Rn,Rn&&x.ajaxTransport(function(n){if(!n.crossDomain||x.support.cors){var r;return{send:function(i,o){var a,s,l=n.xhr();if(n.username?l.open(n.type,n.url,n.async,n.username,n.password):l.open(n.type,n.url,n.async),n.xhrFields)for(s in n.xhrFields)l[s]=n.xhrFields[s];n.mimeType&&l.overrideMimeType&&l.overrideMimeType(n.mimeType),n.crossDomain||i["X-Requested-With"]||(i["X-Requested-With"]="XMLHttpRequest");try{for(s in i)l.setRequestHeader(s,i[s])}catch(u){}l.send(n.hasContent&&n.data||null),r=function(e,i){var s,u,c,p;try{if(r&&(i||4===l.readyState))if(r=t,a&&(l.onreadystatechange=x.noop,$n&&delete Pn[a]),i)4!==l.readyState&&l.abort();else{p={},s=l.status,u=l.getAllResponseHeaders(),"string"==typeof l.responseText&&(p.text=l.responseText);try{c=l.statusText}catch(f){c=""}s||!n.isLocal||n.crossDomain?1223===s&&(s=204):s=p.text?200:404}}catch(d){i||o(-1,d)}p&&o(s,c,p,u)},n.async?4===l.readyState?setTimeout(r):(a=++Wn,$n&&(Pn||(Pn={},x(e).unload($n)),Pn[a]=r),l.onreadystatechange=r):r()},abort:function(){r&&r(t,!0)}}}});var Xn,Un,Vn=/^(?:toggle|show|hide)$/,Yn=RegExp("^(?:([+-])=|)("+w+")([a-z%]*)$","i"),Jn=/queueHooks$/,Gn=[nr],Qn={"*":[function(e,t){var n=this.createTween(e,t),r=n.cur(),i=Yn.exec(t),o=i&&i[3]||(x.cssNumber[e]?"":"px"),a=(x.cssNumber[e]||"px"!==o&&+r)&&Yn.exec(x.css(n.elem,e)),s=1,l=20;if(a&&a[3]!==o){o=o||a[3],i=i||[],a=+r||1;do s=s||".5",a/=s,x.style(n.elem,e,a+o);while(s!==(s=n.cur()/r)&&1!==s&&--l)}return i&&(a=n.start=+a||+r||0,n.unit=o,n.end=i[1]?a+(i[1]+1)*i[2]:+i[2]),n}]};function Kn(){return setTimeout(function(){Xn=t}),Xn=x.now()}function Zn(e,t,n){var r,i=(Qn[t]||[]).concat(Qn["*"]),o=0,a=i.length;for(;a>o;o++)if(r=i[o].call(n,t,e))return r}function er(e,t,n){var r,i,o=0,a=Gn.length,s=x.Deferred().always(function(){delete l.elem}),l=function(){if(i)return!1;var t=Xn||Kn(),n=Math.max(0,u.startTime+u.duration-t),r=n/u.duration||0,o=1-r,a=0,l=u.tweens.length;for(;l>a;a++)u.tweens[a].run(o);return s.notifyWith(e,[u,o,n]),1>o&&l?n:(s.resolveWith(e,[u]),!1)},u=s.promise({elem:e,props:x.extend({},t),opts:x.extend(!0,{specialEasing:{}},n),originalProperties:t,originalOptions:n,startTime:Xn||Kn(),duration:n.duration,tweens:[],createTween:function(t,n){var r=x.Tween(e,u.opts,t,n,u.opts.specialEasing[t]||u.opts.easing);return u.tweens.push(r),r},stop:function(t){var n=0,r=t?u.tweens.length:0;if(i)return this;for(i=!0;r>n;n++)u.tweens[n].run(1);return t?s.resolveWith(e,[u,t]):s.rejectWith(e,[u,t]),this}}),c=u.props;for(tr(c,u.opts.specialEasing);a>o;o++)if(r=Gn[o].call(u,e,c,u.opts))return r;return x.map(c,Zn,u),x.isFunction(u.opts.start)&&u.opts.start.call(e,u),x.fx.timer(x.extend(l,{elem:e,anim:u,queue:u.opts.queue})),u.progress(u.opts.progress).done(u.opts.done,u.opts.complete).fail(u.opts.fail).always(u.opts.always)}function tr(e,t){var n,r,i,o,a;for(n in e)if(r=x.camelCase(n),i=t[r],o=e[n],x.isArray(o)&&(i=o[1],o=e[n]=o[0]),n!==r&&(e[r]=o,delete e[n]),a=x.cssHooks[r],a&&"expand"in a){o=a.expand(o),delete e[r];for(n in o)n in e||(e[n]=o[n],t[n]=i)}else t[r]=i}x.Animation=x.extend(er,{tweener:function(e,t){x.isFunction(e)?(t=e,e=["*"]):e=e.split(" ");var n,r=0,i=e.length;for(;i>r;r++)n=e[r],Qn[n]=Qn[n]||[],Qn[n].unshift(t)},prefilter:function(e,t){t?Gn.unshift(e):Gn.push(e)}});function nr(e,t,n){var r,i,o,a,s,l,u=this,c={},p=e.style,f=e.nodeType&&nn(e),d=x._data(e,"fxshow");n.queue||(s=x._queueHooks(e,"fx"),null==s.unqueued&&(s.unqueued=0,l=s.empty.fire,s.empty.fire=function(){s.unqueued||l()}),s.unqueued++,u.always(function(){u.always(function(){s.unqueued--,x.queue(e,"fx").length||s.empty.fire()})})),1===e.nodeType&&("height"in t||"width"in t)&&(n.overflow=[p.overflow,p.overflowX,p.overflowY],"inline"===x.css(e,"display")&&"none"===x.css(e,"float")&&(x.support.inlineBlockNeedsLayout&&"inline"!==ln(e.nodeName)?p.zoom=1:p.display="inline-block")),n.overflow&&(p.overflow="hidden",x.support.shrinkWrapBlocks||u.always(function(){p.overflow=n.overflow[0],p.overflowX=n.overflow[1],p.overflowY=n.overflow[2]}));for(r in t)if(i=t[r],Vn.exec(i)){if(delete t[r],o=o||"toggle"===i,i===(f?"hide":"show"))continue;c[r]=d&&d[r]||x.style(e,r)}if(!x.isEmptyObject(c)){d?"hidden"in d&&(f=d.hidden):d=x._data(e,"fxshow",{}),o&&(d.hidden=!f),f?x(e).show():u.done(function(){x(e).hide()}),u.done(function(){var t;x._removeData(e,"fxshow");for(t in c)x.style(e,t,c[t])});for(r in c)a=Zn(f?d[r]:0,r,u),r in d||(d[r]=a.start,f&&(a.end=a.start,a.start="width"===r||"height"===r?1:0))}}function rr(e,t,n,r,i){return new rr.prototype.init(e,t,n,r,i)}x.Tween=rr,rr.prototype={constructor:rr,init:function(e,t,n,r,i,o){this.elem=e,this.prop=n,this.easing=i||"swing",this.options=t,this.start=this.now=this.cur(),this.end=r,this.unit=o||(x.cssNumber[n]?"":"px")},cur:function(){var e=rr.propHooks[this.prop];return e&&e.get?e.get(this):rr.propHooks._default.get(this)},run:function(e){var t,n=rr.propHooks[this.prop];return this.pos=t=this.options.duration?x.easing[this.easing](e,this.options.duration*e,0,1,this.options.duration):e,this.now=(this.end-this.start)*t+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),n&&n.set?n.set(this):rr.propHooks._default.set(this),this}},rr.prototype.init.prototype=rr.prototype,rr.propHooks={_default:{get:function(e){var t;return null==e.elem[e.prop]||e.elem.style&&null!=e.elem.style[e.prop]?(t=x.css(e.elem,e.prop,""),t&&"auto"!==t?t:0):e.elem[e.prop]},set:function(e){x.fx.step[e.prop]?x.fx.step[e.prop](e):e.elem.style&&(null!=e.elem.style[x.cssProps[e.prop]]||x.cssHooks[e.prop])?x.style(e.elem,e.prop,e.now+e.unit):e.elem[e.prop]=e.now}}},rr.propHooks.scrollTop=rr.propHooks.scrollLeft={set:function(e){e.elem.nodeType&&e.elem.parentNode&&(e.elem[e.prop]=e.now)}},x.each(["toggle","show","hide"],function(e,t){var n=x.fn[t];x.fn[t]=function(e,r,i){return null==e||"boolean"==typeof e?n.apply(this,arguments):this.animate(ir(t,!0),e,r,i)}}),x.fn.extend({fadeTo:function(e,t,n,r){return this.filter(nn).css("opacity",0).show().end().animate({opacity:t},e,n,r)},animate:function(e,t,n,r){var i=x.isEmptyObject(e),o=x.speed(t,n,r),a=function(){var t=er(this,x.extend({},e),o);(i||x._data(this,"finish"))&&t.stop(!0)};return a.finish=a,i||o.queue===!1?this.each(a):this.queue(o.queue,a)},stop:function(e,n,r){var i=function(e){var t=e.stop;delete e.stop,t(r)};return"string"!=typeof e&&(r=n,n=e,e=t),n&&e!==!1&&this.queue(e||"fx",[]),this.each(function(){var t=!0,n=null!=e&&e+"queueHooks",o=x.timers,a=x._data(this);if(n)a[n]&&a[n].stop&&i(a[n]);else for(n in a)a[n]&&a[n].stop&&Jn.test(n)&&i(a[n]);for(n=o.length;n--;)o[n].elem!==this||null!=e&&o[n].queue!==e||(o[n].anim.stop(r),t=!1,o.splice(n,1));(t||!r)&&x.dequeue(this,e)})},finish:function(e){return e!==!1&&(e=e||"fx"),this.each(function(){var t,n=x._data(this),r=n[e+"queue"],i=n[e+"queueHooks"],o=x.timers,a=r?r.length:0;for(n.finish=!0,x.queue(this,e,[]),i&&i.stop&&i.stop.call(this,!0),t=o.length;t--;)o[t].elem===this&&o[t].queue===e&&(o[t].anim.stop(!0),o.splice(t,1));for(t=0;a>t;t++)r[t]&&r[t].finish&&r[t].finish.call(this);delete n.finish})}});function ir(e,t){var n,r={height:e},i=0;for(t=t?1:0;4>i;i+=2-t)n=Zt[i],r["margin"+n]=r["padding"+n]=e;return t&&(r.opacity=r.width=e),r}x.each({slideDown:ir("show"),slideUp:ir("hide"),slideToggle:ir("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(e,t){x.fn[e]=function(e,n,r){return this.animate(t,e,n,r)}}),x.speed=function(e,t,n){var r=e&&"object"==typeof e?x.extend({},e):{complete:n||!n&&t||x.isFunction(e)&&e,duration:e,easing:n&&t||t&&!x.isFunction(t)&&t};return r.duration=x.fx.off?0:"number"==typeof r.duration?r.duration:r.duration in x.fx.speeds?x.fx.speeds[r.duration]:x.fx.speeds._default,(null==r.queue||r.queue===!0)&&(r.queue="fx"),r.old=r.complete,r.complete=function(){x.isFunction(r.old)&&r.old.call(this),r.queue&&x.dequeue(this,r.queue)},r},x.easing={linear:function(e){return e},swing:function(e){return.5-Math.cos(e*Math.PI)/2}},x.timers=[],x.fx=rr.prototype.init,x.fx.tick=function(){var e,n=x.timers,r=0;for(Xn=x.now();n.length>r;r++)e=n[r],e()||n[r]!==e||n.splice(r--,1);n.length||x.fx.stop(),Xn=t},x.fx.timer=function(e){e()&&x.timers.push(e)&&x.fx.start()},x.fx.interval=13,x.fx.start=function(){Un||(Un=setInterval(x.fx.tick,x.fx.interval))},x.fx.stop=function(){clearInterval(Un),Un=null},x.fx.speeds={slow:600,fast:200,_default:400},x.fx.step={},x.expr&&x.expr.filters&&(x.expr.filters.animated=function(e){return x.grep(x.timers,function(t){return e===t.elem}).length}),x.fn.offset=function(e){if(arguments.length)return e===t?this:this.each(function(t){x.offset.setOffset(this,e,t)});var n,r,o={top:0,left:0},a=this[0],s=a&&a.ownerDocument;if(s)return n=s.documentElement,x.contains(n,a)?(typeof a.getBoundingClientRect!==i&&(o=a.getBoundingClientRect()),r=or(s),{top:o.top+(r.pageYOffset||n.scrollTop)-(n.clientTop||0),left:o.left+(r.pageXOffset||n.scrollLeft)-(n.clientLeft||0)}):o},x.offset={setOffset:function(e,t,n){var r=x.css(e,"position");"static"===r&&(e.style.position="relative");var i=x(e),o=i.offset(),a=x.css(e,"top"),s=x.css(e,"left"),l=("absolute"===r||"fixed"===r)&&x.inArray("auto",[a,s])>-1,u={},c={},p,f;l?(c=i.position(),p=c.top,f=c.left):(p=parseFloat(a)||0,f=parseFloat(s)||0),x.isFunction(t)&&(t=t.call(e,n,o)),null!=t.top&&(u.top=t.top-o.top+p),null!=t.left&&(u.left=t.left-o.left+f),"using"in t?t.using.call(e,u):i.css(u)}},x.fn.extend({position:function(){if(this[0]){var e,t,n={top:0,left:0},r=this[0];return"fixed"===x.css(r,"position")?t=r.getBoundingClientRect():(e=this.offsetParent(),t=this.offset(),x.nodeName(e[0],"html")||(n=e.offset()),n.top+=x.css(e[0],"borderTopWidth",!0),n.left+=x.css(e[0],"borderLeftWidth",!0)),{top:t.top-n.top-x.css(r,"marginTop",!0),left:t.left-n.left-x.css(r,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var e=this.offsetParent||s;while(e&&!x.nodeName(e,"html")&&"static"===x.css(e,"position"))e=e.offsetParent;return e||s})}}),x.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(e,n){var r=/Y/.test(n);x.fn[e]=function(i){return x.access(this,function(e,i,o){var a=or(e);return o===t?a?n in a?a[n]:a.document.documentElement[i]:e[i]:(a?a.scrollTo(r?x(a).scrollLeft():o,r?o:x(a).scrollTop()):e[i]=o,t)},e,i,arguments.length,null)}});function or(e){return x.isWindow(e)?e:9===e.nodeType?e.defaultView||e.parentWindow:!1}x.each({Height:"height",Width:"width"},function(e,n){x.each({padding:"inner"+e,content:n,"":"outer"+e},function(r,i){x.fn[i]=function(i,o){var a=arguments.length&&(r||"boolean"!=typeof i),s=r||(i===!0||o===!0?"margin":"border");return x.access(this,function(n,r,i){var o;return x.isWindow(n)?n.document.documentElement["client"+e]:9===n.nodeType?(o=n.documentElement,Math.max(n.body["scroll"+e],o["scroll"+e],n.body["offset"+e],o["offset"+e],o["client"+e])):i===t?x.css(n,r,s):x.style(n,r,i,s)},n,a?i:t,a,null)}})}),x.fn.size=function(){return this.length},x.fn.andSelf=x.fn.addBack,"object"==typeof module&&module&&"object"==typeof module.exports?module.exports=x:(e.jQuery=e.$=x,"function"==typeof define&&define.amd&&define("jquery",[],function(){return x}))})(window);
7// Underscore.js 1.4.4
8// ===================
9
10// > http://underscorejs.org
11// > (c) 2009-2013 Jeremy Ashkenas, DocumentCloud Inc.
12// > Underscore may be freely distributed under the MIT license.
13
14// Baseline setup
15// --------------
16(function() {
17
18 // Establish the root object, `window` in the browser, or `global` on the server.
19 var root = this;
20
21 // Save the previous value of the `_` variable.
22 var previousUnderscore = root._;
23
24 // Establish the object that gets returned to break out of a loop iteration.
25 var breaker = {};
26
27 // Save bytes in the minified (but not gzipped) version:
28 var ArrayProto = Array.prototype, ObjProto = Object.prototype, FuncProto = Function.prototype;
29
30 // Create quick reference variables for speed access to core prototypes.
31 var push = ArrayProto.push,
32 slice = ArrayProto.slice,
33 concat = ArrayProto.concat,
34 toString = ObjProto.toString,
35 hasOwnProperty = ObjProto.hasOwnProperty;
36
37 // All **ECMAScript 5** native function implementations that we hope to use
38 // are declared here.
39 var
40 nativeForEach = ArrayProto.forEach,
41 nativeMap = ArrayProto.map,
42 nativeReduce = ArrayProto.reduce,
43 nativeReduceRight = ArrayProto.reduceRight,
44 nativeFilter = ArrayProto.filter,
45 nativeEvery = ArrayProto.every,
46 nativeSome = ArrayProto.some,
47 nativeIndexOf = ArrayProto.indexOf,
48 nativeLastIndexOf = ArrayProto.lastIndexOf,
49 nativeIsArray = Array.isArray,
50 nativeKeys = Object.keys,
51 nativeBind = FuncProto.bind;
52
53 // Create a safe reference to the Underscore object for use below.
54 var _ = function(obj) {
55 if (obj instanceof _) return obj;
56 if (!(this instanceof _)) return new _(obj);
57 this._wrapped = obj;
58 };
59
60 // Export the Underscore object for **Node.js**, with
61 // backwards-compatibility for the old `require()` API. If we're in
62 // the browser, add `_` as a global object via a string identifier,
63 // for Closure Compiler "advanced" mode.
64 if (typeof exports !== 'undefined') {
65 if (typeof module !== 'undefined' && module.exports) {
66 exports = module.exports = _;
67 }
68 exports._ = _;
69 } else {
70 root._ = _;
71 }
72
73 // Current version.
74 _.VERSION = '1.4.4';
75
76 // Collection Functions
77 // --------------------
78
79 // The cornerstone, an `each` implementation, aka `forEach`.
80 // Handles objects with the built-in `forEach`, arrays, and raw objects.
81 // Delegates to **ECMAScript 5**'s native `forEach` if available.
82 var each = _.each = _.forEach = function(obj, iterator, context) {
83 if (obj == null) return;
84 if (nativeForEach && obj.forEach === nativeForEach) {
85 obj.forEach(iterator, context);
86 } else if (obj.length === +obj.length) {
87 for (var i = 0, l = obj.length; i < l; i++) {
88 if (iterator.call(context, obj[i], i, obj) === breaker) return;
89 }
90 } else {
91 for (var key in obj) {
92 if (_.has(obj, key)) {
93 if (iterator.call(context, obj[key], key, obj) === breaker) return;
94 }
95 }
96 }
97 };
98
99 // Return the results of applying the iterator to each element.
100 // Delegates to **ECMAScript 5**'s native `map` if available.
101 _.map = _.collect = function(obj, iterator, context) {
102 var results = [];
103 if (obj == null) return results;
104 if (nativeMap && obj.map === nativeMap) return obj.map(iterator, context);
105 each(obj, function(value, index, list) {
106 results[results.length] = iterator.call(context, value, index, list);
107 });
108 return results;
109 };
110
111 var reduceError = 'Reduce of empty array with no initial value';
112
113 // **Reduce** builds up a single result from a list of values, aka `inject`,
114 // or `foldl`. Delegates to **ECMAScript 5**'s native `reduce` if available.
115 _.reduce = _.foldl = _.inject = function(obj, iterator, memo, context) {
116 var initial = arguments.length > 2;
117 if (obj == null) obj = [];
118 if (nativeReduce && obj.reduce === nativeReduce) {
119 if (context) iterator = _.bind(iterator, context);
120 return initial ? obj.reduce(iterator, memo) : obj.reduce(iterator);
121 }
122 each(obj, function(value, index, list) {
123 if (!initial) {
124 memo = value;
125 initial = true;
126 } else {
127 memo = iterator.call(context, memo, value, index, list);
128 }
129 });
130 if (!initial) throw new TypeError(reduceError);
131 return memo;
132 };
133
134 // The right-associative version of reduce, also known as `foldr`.
135 // Delegates to **ECMAScript 5**'s native `reduceRight` if available.
136 _.reduceRight = _.foldr = function(obj, iterator, memo, context) {
137 var initial = arguments.length > 2;
138 if (obj == null) obj = [];
139 if (nativeReduceRight && obj.reduceRight === nativeReduceRight) {
140 if (context) iterator = _.bind(iterator, context);
141 return initial ? obj.reduceRight(iterator, memo) : obj.reduceRight(iterator);
142 }
143 var length = obj.length;
144 if (length !== +length) {
145 var keys = _.keys(obj);
146 length = keys.length;
147 }
148 each(obj, function(value, index, list) {
149 index = keys ? keys[--length] : --length;
150 if (!initial) {
151 memo = obj[index];
152 initial = true;
153 } else {
154 memo = iterator.call(context, memo, obj[index], index, list);
155 }
156 });
157 if (!initial) throw new TypeError(reduceError);
158 return memo;
159 };
160
161 // Return the first value which passes a truth test. Aliased as `detect`.
162 _.find = _.detect = function(obj, iterator, context) {
163 var result;
164 any(obj, function(value, index, list) {
165 if (iterator.call(context, value, index, list)) {
166 result = value;
167 return true;
168 }
169 });
170 return result;
171 };
172
173 // Return all the elements that pass a truth test.
174 // Delegates to **ECMAScript 5**'s native `filter` if available.
175 // Aliased as `select`.
176 _.filter = _.select = function(obj, iterator, context) {
177 var results = [];
178 if (obj == null) return results;
179 if (nativeFilter && obj.filter === nativeFilter) return obj.filter(iterator, context);
180 each(obj, function(value, index, list) {
181 if (iterator.call(context, value, index, list)) results[results.length] = value;
182 });
183 return results;
184 };
185
186 // Return all the elements for which a truth test fails.
187 _.reject = function(obj, iterator, context) {
188 return _.filter(obj, function(value, index, list) {
189 return !iterator.call(context, value, index, list);
190 }, context);
191 };
192
193 // Determine whether all of the elements match a truth test.
194 // Delegates to **ECMAScript 5**'s native `every` if available.
195 // Aliased as `all`.
196 _.every = _.all = function(obj, iterator, context) {
197 iterator || (iterator = _.identity);
198 var result = true;
199 if (obj == null) return result;
200 if (nativeEvery && obj.every === nativeEvery) return obj.every(iterator, context);
201 each(obj, function(value, index, list) {
202 if (!(result = result && iterator.call(context, value, index, list))) return breaker;
203 });
204 return !!result;
205 };
206
207 // Determine if at least one element in the object matches a truth test.
208 // Delegates to **ECMAScript 5**'s native `some` if available.
209 // Aliased as `any`.
210 var any = _.some = _.any = function(obj, iterator, context) {
211 iterator || (iterator = _.identity);
212 var result = false;
213 if (obj == null) return result;
214 if (nativeSome && obj.some === nativeSome) return obj.some(iterator, context);
215 each(obj, function(value, index, list) {
216 if (result || (result = iterator.call(context, value, index, list))) return breaker;
217 });
218 return !!result;
219 };
220
221 // Determine if the array or object contains a given value (using `===`).
222 // Aliased as `include`.
223 _.contains = _.include = function(obj, target) {
224 if (obj == null) return false;
225 if (nativeIndexOf && obj.indexOf === nativeIndexOf) return obj.indexOf(target) != -1;
226 return any(obj, function(value) {
227 return value === target;
228 });
229 };
230
231 // Invoke a method (with arguments) on every item in a collection.
232 _.invoke = function(obj, method) {
233 var args = slice.call(arguments, 2);
234 var isFunc = _.isFunction(method);
235 return _.map(obj, function(value) {
236 return (isFunc ? 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 // containing specific `key:value` pairs.
247 _.where = function(obj, attrs, first) {
248 if (_.isEmpty(attrs)) return first ? null : [];
249 return _[first ? 'find' : '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 // Convenience version of a common use case of `find`: getting the first object
258 // containing specific `key:value` pairs.
259 _.findWhere = function(obj, attrs) {
260 return _.where(obj, attrs, true);
261 };
262
263 // Return the maximum element or (element-based computation).
264 // Can't optimize arrays of integers longer than 65,535 elements.
265 // See: https://bugs.webkit.org/show_bug.cgi?id=80797
266 _.max = function(obj, iterator, context) {
267 if (!iterator && _.isArray(obj) && obj[0] === +obj[0] && obj.length < 65535) {
268 return Math.max.apply(Math, obj);
269 }
270 if (!iterator && _.isEmpty(obj)) return -Infinity;
271 var result = {computed : -Infinity, value: -Infinity};
272 each(obj, function(value, index, list) {
273 var computed = iterator ? iterator.call(context, value, index, list) : value;
274 computed >= result.computed && (result = {value : value, computed : computed});
275 });
276 return result.value;
277 };
278
279 // Return the minimum element (or element-based computation).
280 _.min = function(obj, iterator, context) {
281 if (!iterator && _.isArray(obj) && obj[0] === +obj[0] && obj.length < 65535) {
282 return Math.min.apply(Math, obj);
283 }
284 if (!iterator && _.isEmpty(obj)) return Infinity;
285 var result = {computed : Infinity, value: Infinity};
286 each(obj, function(value, index, list) {
287 var computed = iterator ? iterator.call(context, value, index, list) : value;
288 computed < result.computed && (result = {value : value, computed : computed});
289 });
290 return result.value;
291 };
292
293 // Shuffle an array.
294 _.shuffle = function(obj) {
295 var rand;
296 var index = 0;
297 var shuffled = [];
298 each(obj, function(value) {
299 rand = _.random(index++);
300 shuffled[index - 1] = shuffled[rand];
301 shuffled[rand] = value;
302 });
303 return shuffled;
304 };
305
306 // An internal function to generate lookup iterators.
307 var lookupIterator = function(value) {
308 return _.isFunction(value) ? value : function(obj){ return obj[value]; };
309 };
310
311 // Sort the object's values by a criterion produced by an iterator.
312 _.sortBy = function(obj, value, context) {
313 var iterator = lookupIterator(value);
314 return _.pluck(_.map(obj, function(value, index, list) {
315 return {
316 value : value,
317 index : index,
318 criteria : iterator.call(context, value, index, list)
319 };
320 }).sort(function(left, right) {
321 var a = left.criteria;
322 var b = right.criteria;
323 if (a !== b) {
324 if (a > b || a === void 0) return 1;
325 if (a < b || b === void 0) return -1;
326 }
327 return left.index < right.index ? -1 : 1;
328 }), 'value');
329 };
330
331 // An internal function used for aggregate "group by" operations.
332 var group = function(obj, value, context, behavior) {
333 var result = {};
334 var iterator = lookupIterator(value || _.identity);
335 each(obj, function(value, index) {
336 var key = iterator.call(context, value, index, obj);
337 behavior(result, key, value);
338 });
339 return result;
340 };
341
342 // Groups the object's values by a criterion. Pass either a string attribute
343 // to group by, or a function that returns the criterion.
344 _.groupBy = function(obj, value, context) {
345 return group(obj, value, context, function(result, key, value) {
346 (_.has(result, key) ? result[key] : (result[key] = [])).push(value);
347 });
348 };
349
350 // Counts instances of an object that group by a certain criterion. Pass
351 // either a string attribute to count by, or a function that returns the
352 // criterion.
353 _.countBy = function(obj, value, context) {
354 return group(obj, value, context, function(result, key) {
355 if (!_.has(result, key)) result[key] = 0;
356 result[key]++;
357 });
358 };
359
360 // Use a comparator function to figure out the smallest index at which
361 // an object should be inserted so as to maintain order. Uses binary search.
362 _.sortedIndex = function(array, obj, iterator, context) {
363 iterator = iterator == null ? _.identity : lookupIterator(iterator);
364 var value = iterator.call(context, obj);
365 var low = 0, high = array.length;
366 while (low < high) {
367 var mid = (low + high) >>> 1;
368 iterator.call(context, array[mid]) < value ? low = mid + 1 : high = mid;
369 }
370 return low;
371 };
372
373 // Safely convert anything iterable into a real, live array.
374 _.toArray = function(obj) {
375 if (!obj) return [];
376 if (_.isArray(obj)) return slice.call(obj);
377 if (obj.length === +obj.length) return _.map(obj, _.identity);
378 return _.values(obj);
379 };
380
381 // Return the number of elements in an object.
382 _.size = function(obj) {
383 if (obj == null) return 0;
384 return (obj.length === +obj.length) ? obj.length : _.keys(obj).length;
385 };
386
387 // Array Functions
388 // ---------------
389
390 // Get the first element of an array. Passing **n** will return the first N
391 // values in the array. Aliased as `head` and `take`. The **guard** check
392 // allows it to work with `_.map`.
393 _.first = _.head = _.take = function(array, n, guard) {
394 if (array == null) return void 0;
395 return (n != null) && !guard ? slice.call(array, 0, n) : array[0];
396 };
397
398 // Returns everything but the last entry of the array. Especially useful on
399 // the arguments object. Passing **n** will return all the values in
400 // the array, excluding the last N. The **guard** check allows it to work with
401 // `_.map`.
402 _.initial = function(array, n, guard) {
403 return slice.call(array, 0, array.length - ((n == null) || guard ? 1 : n));
404 };
405
406 // Get the last element of an array. Passing **n** will return the last N
407 // values in the array. The **guard** check allows it to work with `_.map`.
408 _.last = function(array, n, guard) {
409 if (array == null) return void 0;
410 if ((n != null) && !guard) {
411 return slice.call(array, Math.max(array.length - n, 0));
412 } else {
413 return array[array.length - 1];
414 }
415 };
416
417 // Returns everything but the first entry of the array. Aliased as `tail` and `drop`.
418 // Especially useful on the arguments object. Passing an **n** will return
419 // the rest N values in the array. The **guard**
420 // check allows it to work with `_.map`.
421 _.rest = _.tail = _.drop = function(array, n, guard) {
422 return slice.call(array, (n == null) || guard ? 1 : n);
423 };
424
425 // Trim out all falsy values from an array.
426 _.compact = function(array) {
427 return _.filter(array, _.identity);
428 };
429
430 // Internal implementation of a recursive `flatten` function.
431 var flatten = function(input, shallow, output) {
432 each(input, function(value) {
433 if (_.isArray(value)) {
434 shallow ? push.apply(output, value) : flatten(value, shallow, output);
435 } else {
436 output.push(value);
437 }
438 });
439 return output;
440 };
441
442 // Return a completely flattened version of an array.
443 _.flatten = function(array, shallow) {
444 return flatten(array, shallow, []);
445 };
446
447 // Return a version of the array that does not contain the specified value(s).
448 _.without = function(array) {
449 return _.difference(array, slice.call(arguments, 1));
450 };
451
452 // Produce a duplicate-free version of the array. If the array has already
453 // been sorted, you have the option of using a faster algorithm.
454 // Aliased as `unique`.
455 _.uniq = _.unique = function(array, isSorted, iterator, context) {
456 if (_.isFunction(isSorted)) {
457 context = iterator;
458 iterator = isSorted;
459 isSorted = false;
460 }
461 var initial = iterator ? _.map(array, iterator, context) : array;
462 var results = [];
463 var seen = [];
464 each(initial, function(value, index) {
465 if (isSorted ? (!index || seen[seen.length - 1] !== value) : !_.contains(seen, value)) {
466 seen.push(value);
467 results.push(array[index]);
468 }
469 });
470 return results;
471 };
472
473 // Produce an array that contains the union: each distinct element from all of
474 // the passed-in arrays.
475 _.union = function() {
476 return _.uniq(concat.apply(ArrayProto, arguments));
477 };
478
479 // Produce an array that contains every item shared between all the
480 // passed-in arrays.
481 _.intersection = function(array) {
482 var rest = slice.call(arguments, 1);
483 return _.filter(_.uniq(array), function(item) {
484 return _.every(rest, function(other) {
485 return _.indexOf(other, item) >= 0;
486 });
487 });
488 };
489
490 // Take the difference between one array and a number of other arrays.
491 // Only the elements present in just the first array will remain.
492 _.difference = function(array) {
493 var rest = concat.apply(ArrayProto, slice.call(arguments, 1));
494 return _.filter(array, function(value){ return !_.contains(rest, value); });
495 };
496
497 // Zip together multiple lists into a single array -- elements that share
498 // an index go together.
499 _.zip = function() {
500 var args = slice.call(arguments);
501 var length = _.max(_.pluck(args, 'length'));
502 var results = new Array(length);
503 for (var i = 0; i < length; i++) {
504 results[i] = _.pluck(args, "" + i);
505 }
506 return results;
507 };
508
509 // Converts lists into objects. Pass either a single array of `[key, value]`
510 // pairs, or two parallel arrays of the same length -- one of keys, and one of
511 // the corresponding values.
512 _.object = function(list, values) {
513 if (list == null) return {};
514 var result = {};
515 for (var i = 0, l = list.length; i < l; i++) {
516 if (values) {
517 result[list[i]] = values[i];
518 } else {
519 result[list[i][0]] = list[i][1];
520 }
521 }
522 return result;
523 };
524
525 // If the browser doesn't supply us with indexOf (I'm looking at you, **MSIE**),
526 // we need this function. Return the position of the first occurrence of an
527 // item in an array, or -1 if the item is not included in the array.
528 // Delegates to **ECMAScript 5**'s native `indexOf` if available.
529 // If the array is large and already in sort order, pass `true`
530 // for **isSorted** to use binary search.
531 _.indexOf = function(array, item, isSorted) {
532 if (array == null) return -1;
533 var i = 0, l = array.length;
534 if (isSorted) {
535 if (typeof isSorted == 'number') {
536 i = (isSorted < 0 ? Math.max(0, l + isSorted) : isSorted);
537 } else {
538 i = _.sortedIndex(array, item);
539 return array[i] === item ? i : -1;
540 }
541 }
542 if (nativeIndexOf && array.indexOf === nativeIndexOf) return array.indexOf(item, isSorted);
543 for (; i < l; i++) if (array[i] === item) return i;
544 return -1;
545 };
546
547 // Delegates to **ECMAScript 5**'s native `lastIndexOf` if available.
548 _.lastIndexOf = function(array, item, from) {
549 if (array == null) return -1;
550 var hasIndex = from != null;
551 if (nativeLastIndexOf && array.lastIndexOf === nativeLastIndexOf) {
552 return hasIndex ? array.lastIndexOf(item, from) : array.lastIndexOf(item);
553 }
554 var i = (hasIndex ? from : array.length);
555 while (i--) if (array[i] === item) return i;
556 return -1;
557 };
558
559 // Generate an integer Array containing an arithmetic progression. A port of
560 // the native Python `range()` function. See
561 // [the Python documentation](http://docs.python.org/library/functions.html#range).
562 _.range = function(start, stop, step) {
563 if (arguments.length <= 1) {
564 stop = start || 0;
565 start = 0;
566 }
567 step = arguments[2] || 1;
568
569 var len = Math.max(Math.ceil((stop - start) / step), 0);
570 var idx = 0;
571 var range = new Array(len);
572
573 while(idx < len) {
574 range[idx++] = start;
575 start += step;
576 }
577
578 return range;
579 };
580
581 // Function (ahem) Functions
582 // ------------------
583
584 // Create a function bound to a given object (assigning `this`, and arguments,
585 // optionally). Delegates to **ECMAScript 5**'s native `Function.bind` if
586 // available.
587 _.bind = function(func, context) {
588 if (func.bind === nativeBind && nativeBind) return nativeBind.apply(func, slice.call(arguments, 1));
589 var args = slice.call(arguments, 2);
590 return function() {
591 return func.apply(context, args.concat(slice.call(arguments)));
592 };
593 };
594
595 // Partially apply a function by creating a version that has had some of its
596 // arguments pre-filled, without changing its dynamic `this` context.
597 _.partial = function(func) {
598 var args = slice.call(arguments, 1);
599 return function() {
600 return func.apply(this, args.concat(slice.call(arguments)));
601 };
602 };
603
604 // Bind all of an object's methods to that object. Useful for ensuring that
605 // all callbacks defined on an object belong to it.
606 _.bindAll = function(obj) {
607 var funcs = slice.call(arguments, 1);
608 if (funcs.length === 0) funcs = _.functions(obj);
609 each(funcs, function(f) { obj[f] = _.bind(obj[f], obj); });
610 return obj;
611 };
612
613 // Memoize an expensive function by storing its results.
614 _.memoize = function(func, hasher) {
615 var memo = {};
616 hasher || (hasher = _.identity);
617 return function() {
618 var key = hasher.apply(this, arguments);
619 return _.has(memo, key) ? memo[key] : (memo[key] = func.apply(this, arguments));
620 };
621 };
622
623 // Delays a function for the given number of milliseconds, and then calls
624 // it with the arguments supplied.
625 _.delay = function(func, wait) {
626 var args = slice.call(arguments, 2);
627 return setTimeout(function(){ return func.apply(null, args); }, wait);
628 };
629
630 // Defers a function, scheduling it to run after the current call stack has
631 // cleared.
632 _.defer = function(func) {
633 return _.delay.apply(_, [func, 1].concat(slice.call(arguments, 1)));
634 };
635
636 // Returns a function, that, when invoked, will only be triggered at most once
637 // during a given window of time.
638 _.throttle = function(func, wait) {
639 var context, args, timeout, result;
640 var previous = 0;
641 var later = function() {
642 previous = new Date;
643 timeout = null;
644 result = func.apply(context, args);
645 };
646 return function() {
647 var now = new Date;
648 var remaining = wait - (now - previous);
649 context = this;
650 args = arguments;
651 if (remaining <= 0) {
652 clearTimeout(timeout);
653 timeout = null;
654 previous = now;
655 result = func.apply(context, args);
656 } else if (!timeout) {
657 timeout = setTimeout(later, remaining);
658 }
659 return result;
660 };
661 };
662
663 // Returns a function, that, as long as it continues to be invoked, will not
664 // be triggered. The function will be called after it stops being called for
665 // N milliseconds. If `immediate` is passed, trigger the function on the
666 // leading edge, instead of the trailing.
667 _.debounce = function(func, wait, immediate) {
668 var timeout, result;
669 return function() {
670 var context = this, args = arguments;
671 var later = function() {
672 timeout = null;
673 if (!immediate) result = func.apply(context, args);
674 };
675 var callNow = immediate && !timeout;
676 clearTimeout(timeout);
677 timeout = setTimeout(later, wait);
678 if (callNow) result = func.apply(context, args);
679 return result;
680 };
681 };
682
683 // Returns a function that will be executed at most one time, no matter how
684 // often you call it. Useful for lazy initialization.
685 _.once = function(func) {
686 var ran = false, memo;
687 return function() {
688 if (ran) return memo;
689 ran = true;
690 memo = func.apply(this, arguments);
691 func = null;
692 return memo;
693 };
694 };
695
696 // Returns the first function passed as an argument to the second,
697 // allowing you to adjust arguments, run code before and after, and
698 // conditionally execute the original function.
699 _.wrap = function(func, wrapper) {
700 return function() {
701 var args = [func];
702 push.apply(args, arguments);
703 return wrapper.apply(this, args);
704 };
705 };
706
707 // Returns a function that is the composition of a list of functions, each
708 // consuming the return value of the function that follows.
709 _.compose = function() {
710 var funcs = arguments;
711 return function() {
712 var args = arguments;
713 for (var i = funcs.length - 1; i >= 0; i--) {
714 args = [funcs[i].apply(this, args)];
715 }
716 return args[0];
717 };
718 };
719
720 // Returns a function that will only be executed after being called N times.
721 _.after = function(times, func) {
722 if (times <= 0) return func();
723 return function() {
724 if (--times < 1) {
725 return func.apply(this, arguments);
726 }
727 };
728 };
729
730 // Object Functions
731 // ----------------
732
733 // Retrieve the names of an object's properties.
734 // Delegates to **ECMAScript 5**'s native `Object.keys`
735 _.keys = nativeKeys || function(obj) {
736 if (obj !== Object(obj)) throw new TypeError('Invalid object');
737 var keys = [];
738 for (var key in obj) if (_.has(obj, key)) keys[keys.length] = key;
739 return keys;
740 };
741
742 // Retrieve the values of an object's properties.
743 _.values = function(obj) {
744 var values = [];
745 for (var key in obj) if (_.has(obj, key)) values.push(obj[key]);
746 return values;
747 };
748
749 // Convert an object into a list of `[key, value]` pairs.
750 _.pairs = function(obj) {
751 var pairs = [];
752 for (var key in obj) if (_.has(obj, key)) pairs.push([key, obj[key]]);
753 return pairs;
754 };
755
756 // Invert the keys and values of an object. The values must be serializable.
757 _.invert = function(obj) {
758 var result = {};
759 for (var key in obj) if (_.has(obj, key)) result[obj[key]] = key;
760 return result;
761 };
762
763 // Return a sorted list of the function names available on the object.
764 // Aliased as `methods`
765 _.functions = _.methods = function(obj) {
766 var names = [];
767 for (var key in obj) {
768 if (_.isFunction(obj[key])) names.push(key);
769 }
770 return names.sort();
771 };
772
773 // Extend a given object with all the properties in passed-in object(s).
774 _.extend = function(obj) {
775 each(slice.call(arguments, 1), function(source) {
776 if (source) {
777 for (var prop in source) {
778 obj[prop] = source[prop];
779 }
780 }
781 });
782 return obj;
783 };
784
785 // Return a copy of the object only containing the whitelisted properties.
786 _.pick = function(obj) {
787 var copy = {};
788 var keys = concat.apply(ArrayProto, slice.call(arguments, 1));
789 each(keys, function(key) {
790 if (key in obj) copy[key] = obj[key];
791 });
792 return copy;
793 };
794
795 // Return a copy of the object without the blacklisted properties.
796 _.omit = function(obj) {
797 var copy = {};
798 var keys = concat.apply(ArrayProto, slice.call(arguments, 1));
799 for (var key in obj) {
800 if (!_.contains(keys, key)) copy[key] = obj[key];
801 }
802 return copy;
803 };
804
805 // Fill in a given object with default properties.
806 _.defaults = function(obj) {
807 each(slice.call(arguments, 1), function(source) {
808 if (source) {
809 for (var prop in source) {
810 if (obj[prop] == null) obj[prop] = source[prop];
811 }
812 }
813 });
814 return obj;
815 };
816
817 // Create a (shallow-cloned) duplicate of an object.
818 _.clone = function(obj) {
819 if (!_.isObject(obj)) return obj;
820 return _.isArray(obj) ? obj.slice() : _.extend({}, obj);
821 };
822
823 // Invokes interceptor with the obj, and then returns obj.
824 // The primary purpose of this method is to "tap into" a method chain, in
825 // order to perform operations on intermediate results within the chain.
826 _.tap = function(obj, interceptor) {
827 interceptor(obj);
828 return obj;
829 };
830
831 // Internal recursive comparison function for `isEqual`.
832 var eq = function(a, b, aStack, bStack) {
833 // Identical objects are equal. `0 === -0`, but they aren't identical.
834 // See the Harmony `egal` proposal: http://wiki.ecmascript.org/doku.php?id=harmony:egal.
835 if (a === b) return a !== 0 || 1 / a == 1 / b;
836 // A strict comparison is necessary because `null == undefined`.
837 if (a == null || b == null) return a === b;
838 // Unwrap any wrapped objects.
839 if (a instanceof _) a = a._wrapped;
840 if (b instanceof _) b = b._wrapped;
841 // Compare `[[Class]]` names.
842 var className = toString.call(a);
843 if (className != toString.call(b)) return false;
844 switch (className) {
845 // Strings, numbers, dates, and booleans are compared by value.
846 case '[object String]':
847 // Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is
848 // equivalent to `new String("5")`.
849 return a == String(b);
850 case '[object Number]':
851 // `NaN`s are equivalent, but non-reflexive. An `egal` comparison is performed for
852 // other numeric values.
853 return a != +a ? b != +b : (a == 0 ? 1 / a == 1 / b : a == +b);
854 case '[object Date]':
855 case '[object Boolean]':
856 // Coerce dates and booleans to numeric primitive values. Dates are compared by their
857 // millisecond representations. Note that invalid dates with millisecond representations
858 // of `NaN` are not equivalent.
859 return +a == +b;
860 // RegExps are compared by their source patterns and flags.
861 case '[object RegExp]':
862 return a.source == b.source &&
863 a.global == b.global &&
864 a.multiline == b.multiline &&
865 a.ignoreCase == b.ignoreCase;
866 }
867 if (typeof a != 'object' || typeof b != 'object') return false;
868 // Assume equality for cyclic structures. The algorithm for detecting cyclic
869 // structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`.
870 var length = aStack.length;
871 while (length--) {
872 // Linear search. Performance is inversely proportional to the number of
873 // unique nested structures.
874 if (aStack[length] == a) return bStack[length] == b;
875 }
876 // Add the first object to the stack of traversed objects.
877 aStack.push(a);
878 bStack.push(b);
879 var size = 0, result = true;
880 // Recursively compare objects and arrays.
881 if (className == '[object Array]') {
882 // Compare array lengths to determine if a deep comparison is necessary.
883 size = a.length;
884 result = size == b.length;
885 if (result) {
886 // Deep compare the contents, ignoring non-numeric properties.
887 while (size--) {
888 if (!(result = eq(a[size], b[size], aStack, bStack))) break;
889 }
890 }
891 } else {
892 // Objects with different constructors are not equivalent, but `Object`s
893 // from different frames are.
894 var aCtor = a.constructor, bCtor = b.constructor;
895 if (aCtor !== bCtor && !(_.isFunction(aCtor) && (aCtor instanceof aCtor) &&
896 _.isFunction(bCtor) && (bCtor instanceof bCtor))) {
897 return false;
898 }
899 // Deep compare objects.
900 for (var key in a) {
901 if (_.has(a, key)) {
902 // Count the expected number of properties.
903 size++;
904 // Deep compare each member.
905 if (!(result = _.has(b, key) && eq(a[key], b[key], aStack, bStack))) break;
906 }
907 }
908 // Ensure that both objects contain the same number of properties.
909 if (result) {
910 for (key in b) {
911 if (_.has(b, key) && !(size--)) break;
912 }
913 result = !size;
914 }
915 }
916 // Remove the first object from the stack of traversed objects.
917 aStack.pop();
918 bStack.pop();
919 return result;
920 };
921
922 // Perform a deep comparison to check if two objects are equal.
923 _.isEqual = function(a, b) {
924 return eq(a, b, [], []);
925 };
926
927 // Is a given array, string, or object empty?
928 // An "empty" object has no enumerable own-properties.
929 _.isEmpty = function(obj) {
930 if (obj == null) return true;
931 if (_.isArray(obj) || _.isString(obj)) return obj.length === 0;
932 for (var key in obj) if (_.has(obj, key)) return false;
933 return true;
934 };
935
936 // Is a given value a DOM element?
937 _.isElement = function(obj) {
938 return !!(obj && obj.nodeType === 1);
939 };
940
941 // Is a given value an array?
942 // Delegates to ECMA5's native Array.isArray
943 _.isArray = nativeIsArray || function(obj) {
944 return toString.call(obj) == '[object Array]';
945 };
946
947 // Is a given variable an object?
948 _.isObject = function(obj) {
949 return obj === Object(obj);
950 };
951
952 // Add some isType methods: isArguments, isFunction, isString, isNumber, isDate, isRegExp.
953 each(['Arguments', 'Function', 'String', 'Number', 'Date', 'RegExp'], function(name) {
954 _['is' + name] = function(obj) {
955 return toString.call(obj) == '[object ' + name + ']';
956 };
957 });
958
959 // Define a fallback version of the method in browsers (ahem, IE), where
960 // there isn't any inspectable "Arguments" type.
961 if (!_.isArguments(arguments)) {
962 _.isArguments = function(obj) {
963 return !!(obj && _.has(obj, 'callee'));
964 };
965 }
966
967 // Optimize `isFunction` if appropriate.
968 if (typeof (/./) !== 'function') {
969 _.isFunction = function(obj) {
970 return typeof obj === 'function';
971 };
972 }
973
974 // Is a given object a finite number?
975 _.isFinite = function(obj) {
976 return isFinite(obj) && !isNaN(parseFloat(obj));
977 };
978
979 // Is the given value `NaN`? (NaN is the only number which does not equal itself).
980 _.isNaN = function(obj) {
981 return _.isNumber(obj) && obj != +obj;
982 };
983
984 // Is a given value a boolean?
985 _.isBoolean = function(obj) {
986 return obj === true || obj === false || toString.call(obj) == '[object Boolean]';
987 };
988
989 // Is a given value equal to null?
990 _.isNull = function(obj) {
991 return obj === null;
992 };
993
994 // Is a given variable undefined?
995 _.isUndefined = function(obj) {
996 return obj === void 0;
997 };
998
999 // Shortcut function for checking if an object has a given property directly
1000 // on itself (in other words, not on a prototype).
1001 _.has = function(obj, key) {
1002 return hasOwnProperty.call(obj, key);
1003 };
1004
1005 // Utility Functions
1006 // -----------------
1007
1008 // Run Underscore.js in *noConflict* mode, returning the `_` variable to its
1009 // previous owner. Returns a reference to the Underscore object.
1010 _.noConflict = function() {
1011 root._ = previousUnderscore;
1012 return this;
1013 };
1014
1015 // Keep the identity function around for default iterators.
1016 _.identity = function(value) {
1017 return value;
1018 };
1019
1020 // Run a function **n** times.
1021 _.times = function(n, iterator, context) {
1022 var accum = Array(n);
1023 for (var i = 0; i < n; i++) accum[i] = iterator.call(context, i);
1024 return accum;
1025 };
1026
1027 // Return a random integer between min and max (inclusive).
1028 _.random = function(min, max) {
1029 if (max == null) {
1030 max = min;
1031 min = 0;
1032 }
1033 return min + Math.floor(Math.random() * (max - min + 1));
1034 };
1035
1036 // List of HTML entities for escaping.
1037 var entityMap = {
1038 escape: {
1039 '&': '&',
1040 '<': '<',
1041 '>': '>',
1042 '"': '"',
1043 "'": ''',
1044 '/': '/'
1045 }
1046 };
1047 entityMap.unescape = _.invert(entityMap.escape);
1048
1049 // Regexes containing the keys and values listed immediately above.
1050 var entityRegexes = {
1051 escape: new RegExp('[' + _.keys(entityMap.escape).join('') + ']', 'g'),
1052 unescape: new RegExp('(' + _.keys(entityMap.unescape).join('|') + ')', 'g')
1053 };
1054
1055 // Functions for escaping and unescaping strings to/from HTML interpolation.
1056 _.each(['escape', 'unescape'], function(method) {
1057 _[method] = function(string) {
1058 if (string == null) return '';
1059 return ('' + string).replace(entityRegexes[method], function(match) {
1060 return entityMap[method][match];
1061 });
1062 };
1063 });
1064
1065 // If the value of the named property is a function then invoke it;
1066 // otherwise, return it.
1067 _.result = function(object, property) {
1068 if (object == null) return null;
1069 var value = object[property];
1070 return _.isFunction(value) ? value.call(object) : value;
1071 };
1072
1073 // Add your own custom functions to the Underscore object.
1074 _.mixin = function(obj) {
1075 each(_.functions(obj), function(name){
1076 var func = _[name] = obj[name];
1077 _.prototype[name] = function() {
1078 var args = [this._wrapped];
1079 push.apply(args, arguments);
1080 return result.call(this, func.apply(_, args));
1081 };
1082 });
1083 };
1084
1085 // Generate a unique integer id (unique within the entire client session).
1086 // Useful for temporary DOM ids.
1087 var idCounter = 0;
1088 _.uniqueId = function(prefix) {
1089 var id = ++idCounter + '';
1090 return prefix ? prefix + id : id;
1091 };
1092
1093 // By default, Underscore uses ERB-style template delimiters, change the
1094 // following template settings to use alternative delimiters.
1095 _.templateSettings = {
1096 evaluate : /<%([\s\S]+?)%>/g,
1097 interpolate : /<%=([\s\S]+?)%>/g,
1098 escape : /<%-([\s\S]+?)%>/g
1099 };
1100
1101 // When customizing `templateSettings`, if you don't want to define an
1102 // interpolation, evaluation or escaping regex, we need one that is
1103 // guaranteed not to match.
1104 var noMatch = /(.)^/;
1105
1106 // Certain characters need to be escaped so that they can be put into a
1107 // string literal.
1108 var escapes = {
1109 "'": "'",
1110 '\\': '\\',
1111 '\r': 'r',
1112 '\n': 'n',
1113 '\t': 't',
1114 '\u2028': 'u2028',
1115 '\u2029': 'u2029'
1116 };
1117
1118 var escaper = /\\|'|\r|\n|\t|\u2028|\u2029/g;
1119
1120 // JavaScript micro-templating, similar to John Resig's implementation.
1121 // Underscore templating handles arbitrary delimiters, preserves whitespace,
1122 // and correctly escapes quotes within interpolated code.
1123 _.template = function(text, data, settings) {
1124 var render;
1125 settings = _.defaults({}, settings, _.templateSettings);
1126
1127 // Combine delimiters into one regular expression via alternation.
1128 var matcher = new RegExp([
1129 (settings.escape || noMatch).source,
1130 (settings.interpolate || noMatch).source,
1131 (settings.evaluate || noMatch).source
1132 ].join('|') + '|$', 'g');
1133
1134 // Compile the template source, escaping string literals appropriately.
1135 var index = 0;
1136 var source = "__p+='";
1137 text.replace(matcher, function(match, escape, interpolate, evaluate, offset) {
1138 source += text.slice(index, offset)
1139 .replace(escaper, function(match) { return '\\' + escapes[match]; });
1140
1141 if (escape) {
1142 source += "'+\n((__t=(" + escape + "))==null?'':_.escape(__t))+\n'";
1143 }
1144 if (interpolate) {
1145 source += "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'";
1146 }
1147 if (evaluate) {
1148 source += "';\n" + evaluate + "\n__p+='";
1149 }
1150 index = offset + match.length;
1151 return match;
1152 });
1153 source += "';\n";
1154
1155 // If a variable is not specified, place data values in local scope.
1156 if (!settings.variable) source = 'with(obj||{}){\n' + source + '}\n';
1157
1158 source = "var __t,__p='',__j=Array.prototype.join," +
1159 "print=function(){__p+=__j.call(arguments,'');};\n" +
1160 source + "return __p;\n";
1161
1162 try {
1163 render = new Function(settings.variable || 'obj', '_', source);
1164 } catch (e) {
1165 e.source = source;
1166 throw e;
1167 }
1168
1169 if (data) return render(data, _);
1170 var template = function(data) {
1171 return render.call(this, data, _);
1172 };
1173
1174 // Provide the compiled function source as a convenience for precompilation.
1175 template.source = 'function(' + (settings.variable || 'obj') + '){\n' + source + '}';
1176
1177 return template;
1178 };
1179
1180 // Add a "chain" function, which will delegate to the wrapper.
1181 _.chain = function(obj) {
1182 return _(obj).chain();
1183 };
1184
1185 // OOP
1186 // ---------------
1187 // If Underscore is called as a function, it returns a wrapped object that
1188 // can be used OO-style. This wrapper holds altered versions of all the
1189 // underscore functions. Wrapped objects may be chained.
1190
1191 // Helper function to continue chaining intermediate results.
1192 var result = function(obj) {
1193 return this._chain ? _(obj).chain() : obj;
1194 };
1195
1196 // Add all of the Underscore functions to the wrapper object.
1197 _.mixin(_);
1198
1199 // Add all mutator Array functions to the wrapper.
1200 each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) {
1201 var method = ArrayProto[name];
1202 _.prototype[name] = function() {
1203 var obj = this._wrapped;
1204 method.apply(obj, arguments);
1205 if ((name == 'shift' || name == 'splice') && obj.length === 0) delete obj[0];
1206 return result.call(this, obj);
1207 };
1208 });
1209
1210 // Add all accessor Array functions to the wrapper.
1211 each(['concat', 'join', 'slice'], function(name) {
1212 var method = ArrayProto[name];
1213 _.prototype[name] = function() {
1214 return result.call(this, method.apply(this._wrapped, arguments));
1215 };
1216 });
1217
1218 _.extend(_.prototype, {
1219
1220 // Start chaining a wrapped Underscore object.
1221 chain: function() {
1222 this._chain = true;
1223 return this;
1224 },
1225
1226 // Extracts the result from a wrapped and chained object.
1227 value: function() {
1228 return this._wrapped;
1229 }
1230
1231 });
1232
1233}).call(this);
1234// Backbone.js
1235// ===========
1236
1237// > (c) 2010-2012 Jeremy Ashkenas, DocumentCloud Inc.
1238// > Backbone may be freely distributed under the MIT license.
1239// > For all details and documentation: http://backbonejs.org
1240
1241// Initial Setup
1242// -------------
1243
1244(function(){
1245
1246 // Save a reference to the global object (`window` in the browser, `exports`
1247 // on the server).
1248 var root = this;
1249
1250 // Save the previous value of the `Backbone` variable, so that it can be
1251 // restored later on, if `noConflict` is used.
1252 var previousBackbone = root.Backbone;
1253
1254 // Create a local reference to array methods.
1255 var array = [];
1256 var push = array.push;
1257 var slice = array.slice;
1258 var splice = array.splice;
1259
1260 // The top-level namespace. All public Backbone classes and modules will
1261 // be attached to this. Exported for both CommonJS and the browser.
1262 var Backbone;
1263 if (typeof exports !== 'undefined') {
1264 Backbone = exports;
1265 } else {
1266 Backbone = root.Backbone = {};
1267 }
1268
1269 // Current version of the library. Keep in sync with `package.json`.
1270 Backbone.VERSION = '0.9.10';
1271
1272 // Require Underscore, if we're on the server, and it's not already present.
1273 var _ = root._;
1274 if (!_ && (typeof require !== 'undefined')) _ = require('underscore');
1275
1276 // For Backbone's purposes, jQuery, Zepto, or Ender owns the `$` variable.
1277 Backbone.$ = root.jQuery || root.Zepto || root.ender;
1278
1279 // Runs Backbone.js in *noConflict* mode, returning the `Backbone` variable
1280 // to its previous owner. Returns a reference to this Backbone object.
1281 Backbone.noConflict = function() {
1282 root.Backbone = previousBackbone;
1283 return this;
1284 };
1285
1286 // Turn on `emulateHTTP` to support legacy HTTP servers. Setting this option
1287 // will fake `"PUT"` and `"DELETE"` requests via the `_method` parameter and
1288 // set a `X-Http-Method-Override` header.
1289 Backbone.emulateHTTP = false;
1290
1291 // Turn on `emulateJSON` to support legacy servers that can't deal with direct
1292 // `application/json` requests ... will encode the body as
1293 // `application/x-www-form-urlencoded` instead and will send the model in a
1294 // form param named `model`.
1295 Backbone.emulateJSON = false;
1296
1297 // Backbone.Events
1298 // ---------------
1299
1300 // Regular expression used to split event strings.
1301 var eventSplitter = /\s+/;
1302
1303 // Implement fancy features of the Events API such as multiple event
1304 // names `"change blur"` and jQuery-style event maps `{change: action}`
1305 // in terms of the existing API.
1306 var eventsApi = function(obj, action, name, rest) {
1307 if (!name) return true;
1308 if (typeof name === 'object') {
1309 for (var key in name) {
1310 obj[action].apply(obj, [key, name[key]].concat(rest));
1311 }
1312 } else if (eventSplitter.test(name)) {
1313 var names = name.split(eventSplitter);
1314 for (var i = 0, l = names.length; i < l; i++) {
1315 obj[action].apply(obj, [names[i]].concat(rest));
1316 }
1317 } else {
1318 return true;
1319 }
1320 };
1321
1322 // Optimized internal dispatch function for triggering events. Tries to
1323 // keep the usual cases speedy (most Backbone events have 3 arguments).
1324 var triggerEvents = function(events, args) {
1325 var ev, i = -1, l = events.length;
1326 switch (args.length) {
1327 case 0: while (++i < l) (ev = events[i]).callback.call(ev.ctx);
1328 return;
1329 case 1: while (++i < l) (ev = events[i]).callback.call(ev.ctx, args[0]);
1330 return;
1331 case 2: while (++i < l) (ev = events[i]).callback.call(ev.ctx, args[0], args[1]);
1332 return;
1333 case 3: while (++i < l) (ev = events[i]).callback.call(ev.ctx, args[0], args[1], args[2]);
1334 return;
1335 default: while (++i < l) (ev = events[i]).callback.apply(ev.ctx, args);
1336 }
1337 };
1338
1339 // A module that can be mixed in to *any object* in order to provide it with
1340 // custom events. You may bind with `on` or remove with `off` callback
1341 // functions to an event; `trigger`-ing an event fires all callbacks in
1342 // succession.
1343 var Events = Backbone.Events = {
1344
1345 // Bind one or more space separated events, or an events map,
1346 // to a `callback` function. Passing `"all"` will bind the callback to
1347 // all events fired.
1348 on: function(name, callback, context) {
1349 if (!(eventsApi(this, 'on', name, [callback, context]) && callback)) return this;
1350 this._events || (this._events = {});
1351 var list = this._events[name] || (this._events[name] = []);
1352 list.push({callback: callback, context: context, ctx: context || this});
1353 return this;
1354 },
1355
1356 // Bind events to only be triggered a single time. After the first time
1357 // the callback is invoked, it will be removed.
1358 once: function(name, callback, context) {
1359 if (!(eventsApi(this, 'once', name, [callback, context]) && callback)) return this;
1360 var self = this;
1361 var once = _.once(function() {
1362 self.off(name, once);
1363 callback.apply(this, arguments);
1364 });
1365 once._callback = callback;
1366 this.on(name, once, context);
1367 return this;
1368 },
1369
1370 // Remove one or many callbacks. If `context` is null, removes all
1371 // callbacks with that function. If `callback` is null, removes all
1372 // callbacks for the event. If `name` is null, removes all bound
1373 // callbacks for all events.
1374 off: function(name, callback, context) {
1375 var list, ev, events, names, i, l, j, k;
1376 if (!this._events || !eventsApi(this, 'off', name, [callback, context])) return this;
1377 if (!name && !callback && !context) {
1378 this._events = {};
1379 return this;
1380 }
1381
1382 names = name ? [name] : _.keys(this._events);
1383 for (i = 0, l = names.length; i < l; i++) {
1384 name = names[i];
1385 if (list = this._events[name]) {
1386 events = [];
1387 if (callback || context) {
1388 for (j = 0, k = list.length; j < k; j++) {
1389 ev = list[j];
1390 if ((callback && callback !== ev.callback &&
1391 callback !== ev.callback._callback) ||
1392 (context && context !== ev.context)) {
1393 events.push(ev);
1394 }
1395 }
1396 }
1397 this._events[name] = events;
1398 }
1399 }
1400
1401 return this;
1402 },
1403
1404 // Trigger one or many events, firing all bound callbacks. Callbacks are
1405 // passed the same arguments as `trigger` is, apart from the event name
1406 // (unless you're listening on `"all"`, which will cause your callback to
1407 // receive the true name of the event as the first argument).
1408 trigger: function(name) {
1409 if (!this._events) return this;
1410 var args = slice.call(arguments, 1);
1411 if (!eventsApi(this, 'trigger', name, args)) return this;
1412 var events = this._events[name];
1413 var allEvents = this._events.all;
1414 if (events) triggerEvents(events, args);
1415 if (allEvents) triggerEvents(allEvents, arguments);
1416 return this;
1417 },
1418
1419 // An inversion-of-control version of `on`. Tell *this* object to listen to
1420 // an event in another object ... keeping track of what it's listening to.
1421 listenTo: function(obj, name, callback) {
1422 var listeners = this._listeners || (this._listeners = {});
1423 var id = obj._listenerId || (obj._listenerId = _.uniqueId('l'));
1424 listeners[id] = obj;
1425 obj.on(name, typeof name === 'object' ? this : callback, this);
1426 return this;
1427 },
1428
1429 // Tell this object to stop listening to either specific events ... or
1430 // to every object it's currently listening to.
1431 stopListening: function(obj, name, callback) {
1432 var listeners = this._listeners;
1433 if (!listeners) return;
1434 if (obj) {
1435 obj.off(name, typeof name === 'object' ? this : callback, this);
1436 if (!name && !callback) delete listeners[obj._listenerId];
1437 } else {
1438 if (typeof name === 'object') callback = this;
1439 for (var id in listeners) {
1440 listeners[id].off(name, callback, this);
1441 }
1442 this._listeners = {};
1443 }
1444 return this;
1445 }
1446 };
1447
1448 // Aliases for backwards compatibility.
1449 Events.bind = Events.on;
1450 Events.unbind = Events.off;
1451
1452 // Allow the `Backbone` object to serve as a global event bus, for folks who
1453 // want global "pubsub" in a convenient place.
1454 _.extend(Backbone, Events);
1455
1456 // Backbone.Model
1457 // --------------
1458
1459 // Create a new model, with defined attributes. A client id (`cid`)
1460 // is automatically generated and assigned for you.
1461 var Model = Backbone.Model = function(attributes, options) {
1462 var defaults;
1463 var attrs = attributes || {};
1464 this.cid = _.uniqueId('c');
1465 this.attributes = {};
1466 if (options && options.collection) this.collection = options.collection;
1467 if (options && options.parse) attrs = this.parse(attrs, options) || {};
1468 if (defaults = _.result(this, 'defaults')) {
1469 attrs = _.defaults({}, attrs, defaults);
1470 }
1471 this.set(attrs, options);
1472 this.changed = {};
1473 this.initialize.apply(this, arguments);
1474 };
1475
1476 // Attach all inheritable methods to the Model prototype.
1477 _.extend(Model.prototype, Events, {
1478
1479 // A hash of attributes whose current and previous value differ.
1480 changed: null,
1481
1482 // The default name for the JSON `id` attribute is `"id"`. MongoDB and
1483 // CouchDB users may want to set this to `"_id"`.
1484 idAttribute: 'id',
1485
1486 // Initialize is an empty function by default. Override it with your own
1487 // initialization logic.
1488 initialize: function(){},
1489
1490 // Return a copy of the model's `attributes` object.
1491 toJSON: function(options) {
1492 return _.clone(this.attributes);
1493 },
1494
1495 // Proxy `Backbone.sync` by default.
1496 sync: function() {
1497 return Backbone.sync.apply(this, arguments);
1498 },
1499
1500 // Get the value of an attribute.
1501 get: function(attr) {
1502 return this.attributes[attr];
1503 },
1504
1505 // Get the HTML-escaped value of an attribute.
1506 escape: function(attr) {
1507 return _.escape(this.get(attr));
1508 },
1509
1510 // Returns `true` if the attribute contains a value that is not null
1511 // or undefined.
1512 has: function(attr) {
1513 return this.get(attr) != null;
1514 },
1515
1516 // ----------------------------------------------------------------------
1517
1518 // Set a hash of model attributes on the object, firing `"change"` unless
1519 // you choose to silence it.
1520 set: function(key, val, options) {
1521 var attr, attrs, unset, changes, silent, changing, prev, current;
1522 if (key == null) return this;
1523
1524 // Handle both `"key", value` and `{key: value}` -style arguments.
1525 if (typeof key === 'object') {
1526 attrs = key;
1527 options = val;
1528 } else {
1529 (attrs = {})[key] = val;
1530 }
1531
1532 options || (options = {});
1533
1534 // Run validation.
1535 if (!this._validate(attrs, options)) return false;
1536
1537 // Extract attributes and options.
1538 unset = options.unset;
1539 silent = options.silent;
1540 changes = [];
1541 changing = this._changing;
1542 this._changing = true;
1543
1544 if (!changing) {
1545 this._previousAttributes = _.clone(this.attributes);
1546 this.changed = {};
1547 }
1548 current = this.attributes, prev = this._previousAttributes;
1549
1550 // Check for changes of `id`.
1551 if (this.idAttribute in attrs) this.id = attrs[this.idAttribute];
1552
1553 // For each `set` attribute, update or delete the current value.
1554 for (attr in attrs) {
1555 val = attrs[attr];
1556 if (!_.isEqual(current[attr], val)) changes.push(attr);
1557 if (!_.isEqual(prev[attr], val)) {
1558 this.changed[attr] = val;
1559 } else {
1560 delete this.changed[attr];
1561 }
1562 unset ? delete current[attr] : current[attr] = val;
1563 }
1564
1565 // Trigger all relevant attribute changes.
1566 if (!silent) {
1567 if (changes.length) this._pending = true;
1568 for (var i = 0, l = changes.length; i < l; i++) {
1569 this.trigger('change:' + changes[i], this, current[changes[i]], options);
1570 }
1571 }
1572
1573 if (changing) return this;
1574 if (!silent) {
1575 while (this._pending) {
1576 this._pending = false;
1577 this.trigger('change', this, options);
1578 }
1579 }
1580 this._pending = false;
1581 this._changing = false;
1582 return this;
1583 },
1584
1585 // Remove an attribute from the model, firing `"change"` unless you choose
1586 // to silence it. `unset` is a noop if the attribute doesn't exist.
1587 unset: function(attr, options) {
1588 return this.set(attr, void 0, _.extend({}, options, {unset: true}));
1589 },
1590
1591 // Clear all attributes on the model, firing `"change"` unless you choose
1592 // to silence it.
1593 clear: function(options) {
1594 var attrs = {};
1595 for (var key in this.attributes) attrs[key] = void 0;
1596 return this.set(attrs, _.extend({}, options, {unset: true}));
1597 },
1598
1599 // Determine if the model has changed since the last `"change"` event.
1600 // If you specify an attribute name, determine if that attribute has changed.
1601 hasChanged: function(attr) {
1602 if (attr == null) return !_.isEmpty(this.changed);
1603 return _.has(this.changed, attr);
1604 },
1605
1606 // Return an object containing all the attributes that have changed, or
1607 // false if there are no changed attributes. Useful for determining what
1608 // parts of a view need to be updated and/or what attributes need to be
1609 // persisted to the server. Unset attributes will be set to undefined.
1610 // You can also pass an attributes object to diff against the model,
1611 // determining if there *would be* a change.
1612 changedAttributes: function(diff) {
1613 if (!diff) return this.hasChanged() ? _.clone(this.changed) : false;
1614 var val, changed = false;
1615 var old = this._changing ? this._previousAttributes : this.attributes;
1616 for (var attr in diff) {
1617 if (_.isEqual(old[attr], (val = diff[attr]))) continue;
1618 (changed || (changed = {}))[attr] = val;
1619 }
1620 return changed;
1621 },
1622
1623 // Get the previous value of an attribute, recorded at the time the last
1624 // `"change"` event was fired.
1625 previous: function(attr) {
1626 if (attr == null || !this._previousAttributes) return null;
1627 return this._previousAttributes[attr];
1628 },
1629
1630 // Get all of the attributes of the model at the time of the previous
1631 // `"change"` event.
1632 previousAttributes: function() {
1633 return _.clone(this._previousAttributes);
1634 },
1635
1636 // ---------------------------------------------------------------------
1637
1638 // Fetch the model from the server. If the server's representation of the
1639 // model differs from its current attributes, they will be overriden,
1640 // triggering a `"change"` event.
1641 fetch: function(options) {
1642 options = options ? _.clone(options) : {};
1643 if (options.parse === void 0) options.parse = true;
1644 var success = options.success;
1645 options.success = function(model, resp, options) {
1646 if (!model.set(model.parse(resp, options), options)) return false;
1647 if (success) success(model, resp, options);
1648 };
1649 return this.sync('read', this, options);
1650 },
1651
1652 // Set a hash of model attributes, and sync the model to the server.
1653 // If the server returns an attributes hash that differs, the model's
1654 // state will be `set` again.
1655 save: function(key, val, options) {
1656 var attrs, success, method, xhr, attributes = this.attributes;
1657
1658 // Handle both `"key", value` and `{key: value}` -style arguments.
1659 if (key == null || typeof key === 'object') {
1660 attrs = key;
1661 options = val;
1662 } else {
1663 (attrs = {})[key] = val;
1664 }
1665
1666 // If we're not waiting and attributes exist, save acts as `set(attr).save(null, opts)`.
1667 if (attrs && (!options || !options.wait) && !this.set(attrs, options)) return false;
1668
1669 options = _.extend({validate: true}, options);
1670
1671 // Do not persist invalid models.
1672 if (!this._validate(attrs, options)) return false;
1673
1674 // Set temporary attributes if `{wait: true}`.
1675 if (attrs && options.wait) {
1676 this.attributes = _.extend({}, attributes, attrs);
1677 }
1678
1679 // After a successful server-side save, the client is (optionally)
1680 // updated with the server-side state.
1681 if (options.parse === void 0) options.parse = true;
1682 success = options.success;
1683 options.success = function(model, resp, options) {
1684 // Ensure attributes are restored during synchronous saves.
1685 model.attributes = attributes;
1686 var serverAttrs = model.parse(resp, options);
1687 if (options.wait) serverAttrs = _.extend(attrs || {}, serverAttrs);
1688 if (_.isObject(serverAttrs) && !model.set(serverAttrs, options)) {
1689 return false;
1690 }
1691 if (success) success(model, resp, options);
1692 };
1693
1694 // Finish configuring and sending the Ajax request.
1695 method = this.isNew() ? 'create' : (options.patch ? 'patch' : 'update');
1696 if (method === 'patch') options.attrs = attrs;
1697 xhr = this.sync(method, this, options);
1698
1699 // Restore attributes.
1700 if (attrs && options.wait) this.attributes = attributes;
1701
1702 return xhr;
1703 },
1704
1705 // Destroy this model on the server if it was already persisted.
1706 // Optimistically removes the model from its collection, if it has one.
1707 // If `wait: true` is passed, waits for the server to respond before removal.
1708 destroy: function(options) {
1709 options = options ? _.clone(options) : {};
1710 var model = this;
1711 var success = options.success;
1712
1713 var destroy = function() {
1714 model.trigger('destroy', model, model.collection, options);
1715 };
1716
1717 options.success = function(model, resp, options) {
1718 if (options.wait || model.isNew()) destroy();
1719 if (success) success(model, resp, options);
1720 };
1721
1722 if (this.isNew()) {
1723 options.success(this, null, options);
1724 return false;
1725 }
1726
1727 var xhr = this.sync('delete', this, options);
1728 if (!options.wait) destroy();
1729 return xhr;
1730 },
1731
1732 // Default URL for the model's representation on the server -- if you're
1733 // using Backbone's restful methods, override this to change the endpoint
1734 // that will be called.
1735 url: function() {
1736 var base = _.result(this, 'urlRoot') || _.result(this.collection, 'url') || urlError();
1737 if (this.isNew()) return base;
1738 return base + (base.charAt(base.length - 1) === '/' ? '' : '/') + encodeURIComponent(this.id);
1739 },
1740
1741 // **parse** converts a response into the hash of attributes to be `set` on
1742 // the model. The default implementation is just to pass the response along.
1743 parse: function(resp, options) {
1744 return resp;
1745 },
1746
1747 // Create a new model with identical attributes to this one.
1748 clone: function() {
1749 return new this.constructor(this.attributes);
1750 },
1751
1752 // A model is new if it has never been saved to the server, and lacks an id.
1753 isNew: function() {
1754 return this.id == null;
1755 },
1756
1757 // Check if the model is currently in a valid state.
1758 isValid: function(options) {
1759 return !this.validate || !this.validate(this.attributes, options);
1760 },
1761
1762 // Run validation against the next complete set of model attributes,
1763 // returning `true` if all is well. Otherwise, fire a general
1764 // `"error"` event and call the error callback, if specified.
1765 _validate: function(attrs, options) {
1766 if (!options.validate || !this.validate) return true;
1767 attrs = _.extend({}, this.attributes, attrs);
1768 var error = this.validationError = this.validate(attrs, options) || null;
1769 if (!error) return true;
1770 this.trigger('invalid', this, error, options || {});
1771 return false;
1772 }
1773
1774 });
1775
1776 // Backbone.Collection
1777 // -------------------
1778
1779 // Provides a standard collection class for our sets of models, ordered
1780 // or unordered. If a `comparator` is specified, the Collection will maintain
1781 // its models in sort order, as they're added and removed.
1782 var Collection = Backbone.Collection = function(models, options) {
1783 options || (options = {});
1784 if (options.model) this.model = options.model;
1785 if (options.comparator !== void 0) this.comparator = options.comparator;
1786 this.models = [];
1787 this._reset();
1788 this.initialize.apply(this, arguments);
1789 if (models) this.reset(models, _.extend({silent: true}, options));
1790 };
1791
1792 // Define the Collection's inheritable methods.
1793 _.extend(Collection.prototype, Events, {
1794
1795 // The default model for a collection is just a **Backbone.Model**.
1796 // This should be overridden in most cases.
1797 model: Model,
1798
1799 // Initialize is an empty function by default. Override it with your own
1800 // initialization logic.
1801 initialize: function(){},
1802
1803 // The JSON representation of a Collection is an array of the
1804 // models' attributes.
1805 toJSON: function(options) {
1806 return this.map(function(model){ return model.toJSON(options); });
1807 },
1808
1809 // Proxy `Backbone.sync` by default.
1810 sync: function() {
1811 return Backbone.sync.apply(this, arguments);
1812 },
1813
1814 // Add a model, or list of models to the set.
1815 add: function(models, options) {
1816 models = _.isArray(models) ? models.slice() : [models];
1817 options || (options = {});
1818 var i, l, model, attrs, existing, doSort, add, at, sort, sortAttr;
1819 add = [];
1820 at = options.at;
1821 sort = this.comparator && (at == null) && options.sort != false;
1822 sortAttr = _.isString(this.comparator) ? this.comparator : null;
1823
1824 // Turn bare objects into model references, and prevent invalid models
1825 // from being added.
1826 for (i = 0, l = models.length; i < l; i++) {
1827 if (!(model = this._prepareModel(attrs = models[i], options))) {
1828 this.trigger('invalid', this, attrs, options);
1829 continue;
1830 }
1831
1832 // If a duplicate is found, prevent it from being added and
1833 // optionally merge it into the existing model.
1834 if (existing = this.get(model)) {
1835 if (options.merge) {
1836 existing.set(attrs === model ? model.attributes : attrs, options);
1837 if (sort && !doSort && existing.hasChanged(sortAttr)) doSort = true;
1838 }
1839 continue;
1840 }
1841
1842 // This is a new model, push it to the `add` list.
1843 add.push(model);
1844
1845 // Listen to added models' events, and index models for lookup by
1846 // `id` and by `cid`.
1847 model.on('all', this._onModelEvent, this);
1848 this._byId[model.cid] = model;
1849 if (model.id != null) this._byId[model.id] = model;
1850 }
1851
1852 // See if sorting is needed, update `length` and splice in new models.
1853 if (add.length) {
1854 if (sort) doSort = true;
1855 this.length += add.length;
1856 if (at != null) {
1857 splice.apply(this.models, [at, 0].concat(add));
1858 } else {
1859 push.apply(this.models, add);
1860 }
1861 }
1862
1863 // Silently sort the collection if appropriate.
1864 if (doSort) this.sort({silent: true});
1865
1866 if (options.silent) return this;
1867
1868 // Trigger `add` events.
1869 for (i = 0, l = add.length; i < l; i++) {
1870 (model = add[i]).trigger('add', model, this, options);
1871 }
1872
1873 // Trigger `sort` if the collection was sorted.
1874 if (doSort) this.trigger('sort', this, options);
1875
1876 return this;
1877 },
1878
1879 // Remove a model, or a list of models from the set.
1880 remove: function(models, options) {
1881 models = _.isArray(models) ? models.slice() : [models];
1882 options || (options = {});
1883 var i, l, index, model;
1884 for (i = 0, l = models.length; i < l; i++) {
1885 model = this.get(models[i]);
1886 if (!model) continue;
1887 delete this._byId[model.id];
1888 delete this._byId[model.cid];
1889 index = this.indexOf(model);
1890 this.models.splice(index, 1);
1891 this.length--;
1892 if (!options.silent) {
1893 options.index = index;
1894 model.trigger('remove', model, this, options);
1895 }
1896 this._removeReference(model);
1897 }
1898 return this;
1899 },
1900
1901 // Add a model to the end of the collection.
1902 push: function(model, options) {
1903 model = this._prepareModel(model, options);
1904 this.add(model, _.extend({at: this.length}, options));
1905 return model;
1906 },
1907
1908 // Remove a model from the end of the collection.
1909 pop: function(options) {
1910 var model = this.at(this.length - 1);
1911 this.remove(model, options);
1912 return model;
1913 },
1914
1915 // Add a model to the beginning of the collection.
1916 unshift: function(model, options) {
1917 model = this._prepareModel(model, options);
1918 this.add(model, _.extend({at: 0}, options));
1919 return model;
1920 },
1921
1922 // Remove a model from the beginning of the collection.
1923 shift: function(options) {
1924 var model = this.at(0);
1925 this.remove(model, options);
1926 return model;
1927 },
1928
1929 // Slice out a sub-array of models from the collection.
1930 slice: function(begin, end) {
1931 return this.models.slice(begin, end);
1932 },
1933
1934 // Get a model from the set by id.
1935 get: function(obj) {
1936 if (obj == null) return void 0;
1937 this._idAttr || (this._idAttr = this.model.prototype.idAttribute);
1938 return this._byId[obj.id || obj.cid || obj[this._idAttr] || obj];
1939 },
1940
1941 // Get the model at the given index.
1942 at: function(index) {
1943 return this.models[index];
1944 },
1945
1946 // Return models with matching attributes. Useful for simple cases of `filter`.
1947 where: function(attrs) {
1948 if (_.isEmpty(attrs)) return [];
1949 return this.filter(function(model) {
1950 for (var key in attrs) {
1951 if (attrs[key] !== model.get(key)) return false;
1952 }
1953 return true;
1954 });
1955 },
1956
1957 // Force the collection to re-sort itself. You don't need to call this under
1958 // normal circumstances, as the set will maintain sort order as each item
1959 // is added.
1960 sort: function(options) {
1961 if (!this.comparator) {
1962 throw new Error('Cannot sort a set without a comparator');
1963 }
1964 options || (options = {});
1965
1966 // Run sort based on type of `comparator`.
1967 if (_.isString(this.comparator) || this.comparator.length === 1) {
1968 this.models = this.sortBy(this.comparator, this);
1969 } else {
1970 this.models.sort(_.bind(this.comparator, this));
1971 }
1972
1973 if (!options.silent) this.trigger('sort', this, options);
1974 return this;
1975 },
1976
1977 // Pluck an attribute from each model in the collection.
1978 pluck: function(attr) {
1979 return _.invoke(this.models, 'get', attr);
1980 },
1981
1982 // Smartly update a collection with a change set of models, adding,
1983 // removing, and merging as necessary.
1984 update: function(models, options) {
1985 options = _.extend({add: true, merge: true, remove: true}, options);
1986 if (options.parse) models = this.parse(models, options);
1987 var model, i, l, existing;
1988 var add = [], remove = [], modelMap = {};
1989
1990 // Allow a single model (or no argument) to be passed.
1991 if (!_.isArray(models)) models = models ? [models] : [];
1992
1993 // Proxy to `add` for this case, no need to iterate...
1994 if (options.add && !options.remove) return this.add(models, options);
1995
1996 // Determine which models to add and merge, and which to remove.
1997 for (i = 0, l = models.length; i < l; i++) {
1998 model = models[i];
1999 existing = this.get(model);
2000 if (options.remove && existing) modelMap[existing.cid] = true;
2001 if ((options.add && !existing) || (options.merge && existing)) {
2002 add.push(model);
2003 }
2004 }
2005 if (options.remove) {
2006 for (i = 0, l = this.models.length; i < l; i++) {
2007 model = this.models[i];
2008 if (!modelMap[model.cid]) remove.push(model);
2009 }
2010 }
2011
2012 // Remove models (if applicable) before we add and merge the rest.
2013 if (remove.length) this.remove(remove, options);
2014 if (add.length) this.add(add, options);
2015 return this;
2016 },
2017
2018 // When you have more items than you want to add or remove individually,
2019 // you can reset the entire set with a new list of models, without firing
2020 // any `add` or `remove` events. Fires `reset` when finished.
2021 reset: function(models, options) {
2022 options || (options = {});
2023 if (options.parse) models = this.parse(models, options);
2024 for (var i = 0, l = this.models.length; i < l; i++) {
2025 this._removeReference(this.models[i]);
2026 }
2027 options.previousModels = this.models.slice();
2028 this._reset();
2029 if (models) this.add(models, _.extend({silent: true}, options));
2030 if (!options.silent) this.trigger('reset', this, options);
2031 return this;
2032 },
2033
2034 // Fetch the default set of models for this collection, resetting the
2035 // collection when they arrive. If `update: true` is passed, the response
2036 // data will be passed through the `update` method instead of `reset`.
2037 fetch: function(options) {
2038 options = options ? _.clone(options) : {};
2039 if (options.parse === void 0) options.parse = true;
2040 var success = options.success;
2041 options.success = function(collection, resp, options) {
2042 var method = options.update ? 'update' : 'reset';
2043 collection[method](resp, options);
2044 if (success) success(collection, resp, options);
2045 };
2046 return this.sync('read', this, options);
2047 },
2048
2049 // Create a new instance of a model in this collection. Add the model to the
2050 // collection immediately, unless `wait: true` is passed, in which case we
2051 // wait for the server to agree.
2052 create: function(model, options) {
2053 options = options ? _.clone(options) : {};
2054 if (!(model = this._prepareModel(model, options))) return false;
2055 if (!options.wait) this.add(model, options);
2056 var collection = this;
2057 var success = options.success;
2058 options.success = function(model, resp, options) {
2059 if (options.wait) collection.add(model, options);
2060 if (success) success(model, resp, options);
2061 };
2062 model.save(null, options);
2063 return model;
2064 },
2065
2066 // **parse** converts a response into a list of models to be added to the
2067 // collection. The default implementation is just to pass it through.
2068 parse: function(resp, options) {
2069 return resp;
2070 },
2071
2072 // Create a new collection with an identical list of models as this one.
2073 clone: function() {
2074 return new this.constructor(this.models);
2075 },
2076
2077 // Reset all internal state. Called when the collection is reset.
2078 _reset: function() {
2079 this.length = 0;
2080 this.models.length = 0;
2081 this._byId = {};
2082 },
2083
2084 // Prepare a model or hash of attributes to be added to this collection.
2085 _prepareModel: function(attrs, options) {
2086 if (attrs instanceof Model) {
2087 if (!attrs.collection) attrs.collection = this;
2088 return attrs;
2089 }
2090 options || (options = {});
2091 options.collection = this;
2092 var model = new this.model(attrs, options);
2093 if (!model._validate(attrs, options)) return false;
2094 return model;
2095 },
2096
2097 // Internal method to remove a model's ties to a collection.
2098 _removeReference: function(model) {
2099 if (this === model.collection) delete model.collection;
2100 model.off('all', this._onModelEvent, this);
2101 },
2102
2103 // Internal method called every time a model in the set fires an event.
2104 // Sets need to update their indexes when models change ids. All other
2105 // events simply proxy through. "add" and "remove" events that originate
2106 // in other collections are ignored.
2107 _onModelEvent: function(event, model, collection, options) {
2108 if ((event === 'add' || event === 'remove') && collection !== this) return;
2109 if (event === 'destroy') this.remove(model, options);
2110 if (model && event === 'change:' + model.idAttribute) {
2111 delete this._byId[model.previous(model.idAttribute)];
2112 if (model.id != null) this._byId[model.id] = model;
2113 }
2114 this.trigger.apply(this, arguments);
2115 },
2116
2117 sortedIndex: function (model, value, context) {
2118 value || (value = this.comparator);
2119 var iterator = _.isFunction(value) ? value : function(model) {
2120 return model.get(value);
2121 };
2122 return _.sortedIndex(this.models, model, iterator, context);
2123 }
2124
2125 });
2126
2127 // Underscore methods that we want to implement on the Collection.
2128 var methods = ['forEach', 'each', 'map', 'collect', 'reduce', 'foldl',
2129 'inject', 'reduceRight', 'foldr', 'find', 'detect', 'filter', 'select',
2130 'reject', 'every', 'all', 'some', 'any', 'include', 'contains', 'invoke',
2131 'max', 'min', 'toArray', 'size', 'first', 'head', 'take', 'initial', 'rest',
2132 'tail', 'drop', 'last', 'without', 'indexOf', 'shuffle', 'lastIndexOf',
2133 'isEmpty', 'chain'];
2134
2135 // Mix in each Underscore method as a proxy to `Collection#models`.
2136 _.each(methods, function(method) {
2137 Collection.prototype[method] = function() {
2138 var args = slice.call(arguments);
2139 args.unshift(this.models);
2140 return _[method].apply(_, args);
2141 };
2142 });
2143
2144 // Underscore methods that take a property name as an argument.
2145 var attributeMethods = ['groupBy', 'countBy', 'sortBy'];
2146
2147 // Use attributes instead of properties.
2148 _.each(attributeMethods, function(method) {
2149 Collection.prototype[method] = function(value, context) {
2150 var iterator = _.isFunction(value) ? value : function(model) {
2151 return model.get(value);
2152 };
2153 return _[method](this.models, iterator, context);
2154 };
2155 });
2156
2157 // Backbone.Router
2158 // ---------------
2159
2160 // Routers map faux-URLs to actions, and fire events when routes are
2161 // matched. Creating a new one sets its `routes` hash, if not set statically.
2162 var Router = Backbone.Router = function(options) {
2163 options || (options = {});
2164 if (options.routes) this.routes = options.routes;
2165 this._bindRoutes();
2166 this.initialize.apply(this, arguments);
2167 };
2168
2169 // Cached regular expressions for matching named param parts and splatted
2170 // parts of route strings.
2171 var optionalParam = /\((.*?)\)/g;
2172 var namedParam = /(\(\?)?:\w+/g;
2173 var splatParam = /\*\w+/g;
2174 var escapeRegExp = /[\-{}\[\]+?.,\\\^$|#\s]/g;
2175
2176 // Set up all inheritable **Backbone.Router** properties and methods.
2177 _.extend(Router.prototype, Events, {
2178
2179 // Initialize is an empty function by default. Override it with your own
2180 // initialization logic.
2181 initialize: function(){},
2182
2183 // Manually bind a single named route to a callback function.
2184 route: function(route, name, callback) {
2185 if (!_.isRegExp(route)) route = this._routeToRegExp(route);
2186 if (!callback) callback = this[name];
2187 Backbone.history.route(route, _.bind(function(fragment) {
2188 var args = this._extractParameters(route, fragment);
2189 callback && callback.apply(this, args);
2190 this.trigger.apply(this, ['route:' + name].concat(args));
2191 this.trigger('route', name, args);
2192 Backbone.history.trigger('route', this, name, args);
2193 }, this));
2194 return this;
2195 },
2196
2197 // Simple proxy to `Backbone.history` to save a fragment into the history.
2198 navigate: function(fragment, options) {
2199 Backbone.history.navigate(fragment, options);
2200 return this;
2201 },
2202
2203 // Bind all defined routes to `Backbone.history`. We have to reverse the
2204 // order of the routes here to support behavior where the most general
2205 // routes can be defined at the bottom of the route map.
2206 _bindRoutes: function() {
2207 if (!this.routes) return;
2208 var route, routes = _.keys(this.routes);
2209 while ((route = routes.pop()) != null) {
2210 this.route(route, this.routes[route]);
2211 }
2212 },
2213
2214 // Convert a route string into a regular expression, suitable for matching
2215 // against the current location hash.
2216 _routeToRegExp: function(route) {
2217 route = route.replace(escapeRegExp, '\\$&')
2218 .replace(optionalParam, '(?:$1)?')
2219 .replace(namedParam, function(match, optional){
2220 return optional ? match : '([^\/]+)';
2221 })
2222 .replace(splatParam, '(.*?)');
2223 return new RegExp('^' + route + '$');
2224 },
2225
2226 // Given a route, and a URL fragment that it matches, return the array of
2227 // extracted parameters.
2228 _extractParameters: function(route, fragment) {
2229 return route.exec(fragment).slice(1);
2230 }
2231
2232 });
2233
2234 // Backbone.History
2235 // ----------------
2236
2237 // Handles cross-browser history management, based on URL fragments. If the
2238 // browser does not support `onhashchange`, falls back to polling.
2239 var History = Backbone.History = function() {
2240 this.handlers = [];
2241 _.bindAll(this, 'checkUrl');
2242
2243 // Ensure that `History` can be used outside of the browser.
2244 if (typeof window !== 'undefined') {
2245 this.location = window.location;
2246 this.history = window.history;
2247 }
2248 };
2249
2250 // Cached regex for stripping a leading hash/slash and trailing space.
2251 var routeStripper = /^[#\/]|\s+$/g;
2252
2253 // Cached regex for stripping leading and trailing slashes.
2254 var rootStripper = /^\/+|\/+$/g;
2255
2256 // Cached regex for detecting MSIE.
2257 var isExplorer = /msie [\w.]+/;
2258
2259 // Cached regex for removing a trailing slash.
2260 var trailingSlash = /\/$/;
2261
2262 // Has the history handling already been started?
2263 History.started = false;
2264
2265 // Set up all inheritable **Backbone.History** properties and methods.
2266 _.extend(History.prototype, Events, {
2267
2268 // The default interval to poll for hash changes, if necessary, is
2269 // twenty times a second.
2270 interval: 50,
2271
2272 // Gets the true hash value. Cannot use location.hash directly due to bug
2273 // in Firefox where location.hash will always be decoded.
2274 getHash: function(window) {
2275 var match = (window || this).location.href.match(/#(.*)$/);
2276 return match ? match[1] : '';
2277 },
2278
2279 // Get the cross-browser normalized URL fragment, either from the URL,
2280 // the hash, or the override.
2281 getFragment: function(fragment, forcePushState) {
2282 if (fragment == null) {
2283 if (this._hasPushState || !this._wantsHashChange || forcePushState) {
2284 fragment = this.location.pathname;
2285 var root = this.root.replace(trailingSlash, '');
2286 if (!fragment.indexOf(root)) fragment = fragment.substr(root.length);
2287 } else {
2288 fragment = this.getHash();
2289 }
2290 }
2291 return fragment.replace(routeStripper, '');
2292 },
2293
2294 // Start the hash change handling, returning `true` if the current URL matches
2295 // an existing route, and `false` otherwise.
2296 start: function(options) {
2297 if (History.started) throw new Error("Backbone.history has already been started");
2298 History.started = true;
2299
2300 // Figure out the initial configuration. Do we need an iframe?
2301 // Is pushState desired ... is it available?
2302 this.options = _.extend({}, {root: '/'}, this.options, options);
2303 this.root = this.options.root;
2304 this._wantsHashChange = this.options.hashChange !== false;
2305 this._wantsPushState = !!this.options.pushState;
2306 this._hasPushState = !!(this.options.pushState && this.history && this.history.pushState);
2307 var fragment = this.getFragment();
2308 var docMode = document.documentMode;
2309 var oldIE = (isExplorer.exec(navigator.userAgent.toLowerCase()) && (!docMode || docMode <= 7));
2310
2311 // Normalize root to always include a leading and trailing slash.
2312 this.root = ('/' + this.root + '/').replace(rootStripper, '/');
2313
2314 if (oldIE && this._wantsHashChange) {
2315 this.iframe = Backbone.$('<iframe src="javascript:0" tabindex="-1" />').hide().appendTo('body')[0].contentWindow;
2316 this.navigate(fragment);
2317 }
2318
2319 // Depending on whether we're using pushState or hashes, and whether
2320 // 'onhashchange' is supported, determine how we check the URL state.
2321 if (this._hasPushState) {
2322 Backbone.$(window).on('popstate', this.checkUrl);
2323 } else if (this._wantsHashChange && ('onhashchange' in window) && !oldIE) {
2324 Backbone.$(window).on('hashchange', this.checkUrl);
2325 } else if (this._wantsHashChange) {
2326 this._checkUrlInterval = setInterval(this.checkUrl, this.interval);
2327 }
2328
2329 // Determine if we need to change the base url, for a pushState link
2330 // opened by a non-pushState browser.
2331 this.fragment = fragment;
2332 var loc = this.location;
2333 var atRoot = loc.pathname.replace(/[^\/]$/, '$&/') === this.root;
2334
2335 // If we've started off with a route from a `pushState`-enabled browser,
2336 // but we're currently in a browser that doesn't support it...
2337 if (this._wantsHashChange && this._wantsPushState && !this._hasPushState && !atRoot) {
2338 this.fragment = this.getFragment(null, true);
2339 this.location.replace(this.root + this.location.search + '#' + this.fragment);
2340 // Return immediately as browser will do redirect to new url
2341 return true;
2342
2343 // Or if we've started out with a hash-based route, but we're currently
2344 // in a browser where it could be `pushState`-based instead...
2345 } else if (this._wantsPushState && this._hasPushState && atRoot && loc.hash) {
2346 this.fragment = this.getHash().replace(routeStripper, '');
2347 this.history.replaceState({}, document.title, this.root + this.fragment + loc.search);
2348 }
2349
2350 if (!this.options.silent) return this.loadUrl();
2351 },
2352
2353 // Disable Backbone.history, perhaps temporarily. Not useful in a real app,
2354 // but possibly useful for unit testing Routers.
2355 stop: function() {
2356 Backbone.$(window).off('popstate', this.checkUrl).off('hashchange', this.checkUrl);
2357 clearInterval(this._checkUrlInterval);
2358 History.started = false;
2359 },
2360
2361 // Add a route to be tested when the fragment changes. Routes added later
2362 // may override previous routes.
2363 route: function(route, callback) {
2364 this.handlers.unshift({route: route, callback: callback});
2365 },
2366
2367 // Checks the current URL to see if it has changed, and if it has,
2368 // calls `loadUrl`, normalizing across the hidden iframe.
2369 checkUrl: function(e) {
2370 var current = this.getFragment();
2371 if (current === this.fragment && this.iframe) {
2372 current = this.getFragment(this.getHash(this.iframe));
2373 }
2374 if (current === this.fragment) return false;
2375 if (this.iframe) this.navigate(current);
2376 this.loadUrl() || this.loadUrl(this.getHash());
2377 },
2378
2379 // Attempt to load the current URL fragment. If a route succeeds with a
2380 // match, returns `true`. If no defined routes matches the fragment,
2381 // returns `false`.
2382 loadUrl: function(fragmentOverride) {
2383 var fragment = this.fragment = this.getFragment(fragmentOverride);
2384 var matched = _.any(this.handlers, function(handler) {
2385 if (handler.route.test(fragment)) {
2386 handler.callback(fragment);
2387 return true;
2388 }
2389 });
2390 return matched;
2391 },
2392
2393 // Save a fragment into the hash history, or replace the URL state if the
2394 // 'replace' option is passed. You are responsible for properly URL-encoding
2395 // the fragment in advance.
2396 //
2397 // The options object can contain `trigger: true` if you wish to have the
2398 // route callback be fired (not usually desirable), or `replace: true`, if
2399 // you wish to modify the current URL without adding an entry to the history.
2400 navigate: function(fragment, options) {
2401 if (!History.started) return false;
2402 if (!options || options === true) options = {trigger: options};
2403 fragment = this.getFragment(fragment || '');
2404 if (this.fragment === fragment) return;
2405 this.fragment = fragment;
2406 var url = this.root + fragment;
2407
2408 // If pushState is available, we use it to set the fragment as a real URL.
2409 if (this._hasPushState) {
2410 this.history[options.replace ? 'replaceState' : 'pushState']({}, document.title, url);
2411
2412 // If hash changes haven't been explicitly disabled, update the hash
2413 // fragment to store history.
2414 } else if (this._wantsHashChange) {
2415 this._updateHash(this.location, fragment, options.replace);
2416 if (this.iframe && (fragment !== this.getFragment(this.getHash(this.iframe)))) {
2417 // Opening and closing the iframe tricks IE7 and earlier to push a
2418 // history entry on hash-tag change. When replace is true, we don't
2419 // want this.
2420 if(!options.replace) this.iframe.document.open().close();
2421 this._updateHash(this.iframe.location, fragment, options.replace);
2422 }
2423
2424 // If you've told us that you explicitly don't want fallback hashchange-
2425 // based history, then `navigate` becomes a page refresh.
2426 } else {
2427 return this.location.assign(url);
2428 }
2429 if (options.trigger) this.loadUrl(fragment);
2430 },
2431
2432 // Update the hash location, either replacing the current entry, or adding
2433 // a new one to the browser history.
2434 _updateHash: function(location, fragment, replace) {
2435 if (replace) {
2436 var href = location.href.replace(/(javascript:|#).*$/, '');
2437 location.replace(href + '#' + fragment);
2438 } else {
2439 // Some browsers require that `hash` contains a leading #.
2440 location.hash = '#' + fragment;
2441 }
2442 }
2443
2444 });
2445
2446 // Create the default Backbone.history.
2447 Backbone.history = new History;
2448
2449 // Backbone.View
2450 // -------------
2451
2452 // Creating a Backbone.View creates its initial element outside of the DOM,
2453 // if an existing element is not provided...
2454 var View = Backbone.View = function(options) {
2455 this.cid = _.uniqueId('view');
2456 this._configure(options || {});
2457 this._ensureElement();
2458 this.initialize.apply(this, arguments);
2459 this.delegateEvents();
2460 };
2461
2462 // Cached regex to split keys for `delegate`.
2463 var delegateEventSplitter = /^(\S+)\s*(.*)$/;
2464
2465 // List of view options to be merged as properties.
2466 var viewOptions = ['model', 'collection', 'el', 'id', 'attributes', 'className', 'tagName', 'events'];
2467
2468 // Set up all inheritable **Backbone.View** properties and methods.
2469 _.extend(View.prototype, Events, {
2470
2471 // The default `tagName` of a View's element is `"div"`.
2472 tagName: 'div',
2473
2474 // jQuery delegate for element lookup, scoped to DOM elements within the
2475 // current view. This should be prefered to global lookups where possible.
2476 $: function(selector) {
2477 return this.$el.find(selector);
2478 },
2479
2480 // Initialize is an empty function by default. Override it with your own
2481 // initialization logic.
2482 initialize: function(){},
2483
2484 // **render** is the core function that your view should override, in order
2485 // to populate its element (`this.el`), with the appropriate HTML. The
2486 // convention is for **render** to always return `this`.
2487 render: function() {
2488 return this;
2489 },
2490
2491 // Remove this view by taking the element out of the DOM, and removing any
2492 // applicable Backbone.Events listeners.
2493 remove: function() {
2494 this.$el.remove();
2495 this.stopListening();
2496 return this;
2497 },
2498
2499 // Change the view's element (`this.el` property), including event
2500 // re-delegation.
2501 setElement: function(element, delegate) {
2502 if (this.$el) this.undelegateEvents();
2503 this.$el = element instanceof Backbone.$ ? element : Backbone.$(element);
2504 this.el = this.$el[0];
2505 if (delegate !== false) this.delegateEvents();
2506 return this;
2507 },
2508
2509 // Set callbacks, where `this.events` is a hash of
2510 //
2511 // *{"event selector": "callback"}*
2512 //
2513 // {
2514 // 'mousedown .title': 'edit',
2515 // 'click .button': 'save'
2516 // 'click .open': function(e) { ... }
2517 // }
2518 //
2519 // pairs. Callbacks will be bound to the view, with `this` set properly.
2520 // Uses event delegation for efficiency.
2521 // Omitting the selector binds the event to `this.el`.
2522 // This only works for delegate-able events: not `focus`, `blur`, and
2523 // not `change`, `submit`, and `reset` in Internet Explorer.
2524 delegateEvents: function(events) {
2525 if (!(events || (events = _.result(this, 'events')))) return;
2526 this.undelegateEvents();
2527 for (var key in events) {
2528 var method = events[key];
2529 if (!_.isFunction(method)) method = this[events[key]];
2530 if (!method) throw new Error('Method "' + events[key] + '" does not exist');
2531 var match = key.match(delegateEventSplitter);
2532 var eventName = match[1], selector = match[2];
2533 method = _.bind(method, this);
2534 eventName += '.delegateEvents' + this.cid;
2535 if (selector === '') {
2536 this.$el.on(eventName, method);
2537 } else {
2538 this.$el.on(eventName, selector, method);
2539 }
2540 }
2541 },
2542
2543 // Clears all callbacks previously bound to the view with `delegateEvents`.
2544 // You usually don't need to use this, but may wish to if you have multiple
2545 // Backbone views attached to the same DOM element.
2546 undelegateEvents: function() {
2547 this.$el.off('.delegateEvents' + this.cid);
2548 },
2549
2550 // Performs the initial configuration of a View with a set of options.
2551 // Keys with special meaning *(model, collection, id, className)*, are
2552 // attached directly to the view.
2553 _configure: function(options) {
2554 if (this.options) options = _.extend({}, _.result(this, 'options'), options);
2555 _.extend(this, _.pick(options, viewOptions));
2556 this.options = options;
2557 },
2558
2559 // Ensure that the View has a DOM element to render into.
2560 // If `this.el` is a string, pass it through `$()`, take the first
2561 // matching element, and re-assign it to `el`. Otherwise, create
2562 // an element from the `id`, `className` and `tagName` properties.
2563 _ensureElement: function() {
2564 if (!this.el) {
2565 var attrs = _.extend({}, _.result(this, 'attributes'));
2566 if (this.id) attrs.id = _.result(this, 'id');
2567 if (this.className) attrs['class'] = _.result(this, 'className');
2568 var $el = Backbone.$('<' + _.result(this, 'tagName') + '>').attr(attrs);
2569 this.setElement($el, false);
2570 } else {
2571 this.setElement(_.result(this, 'el'), false);
2572 }
2573 }
2574
2575 });
2576
2577 // Backbone.sync
2578 // -------------
2579
2580 // Map from CRUD to HTTP for our default `Backbone.sync` implementation.
2581 var methodMap = {
2582 'create': 'POST',
2583 'update': 'PUT',
2584 'patch': 'PATCH',
2585 'delete': 'DELETE',
2586 'read': 'GET'
2587 };
2588
2589 // Override this function to change the manner in which Backbone persists
2590 // models to the server. You will be passed the type of request, and the
2591 // model in question. By default, makes a RESTful Ajax request
2592 // to the model's `url()`. Some possible customizations could be:
2593 //
2594 // * Use `setTimeout` to batch rapid-fire updates into a single request.
2595 // * Send up the models as XML instead of JSON.
2596 // * Persist models via WebSockets instead of Ajax.
2597 //
2598 // Turn on `Backbone.emulateHTTP` in order to send `PUT` and `DELETE` requests
2599 // as `POST`, with a `_method` parameter containing the true HTTP method,
2600 // as well as all requests with the body as `application/x-www-form-urlencoded`
2601 // instead of `application/json` with the model in a param named `model`.
2602 // Useful when interfacing with server-side languages like **PHP** that make
2603 // it difficult to read the body of `PUT` requests.
2604 Backbone.sync = function(method, model, options) {
2605 var type = methodMap[method];
2606
2607 // Default options, unless specified.
2608 _.defaults(options || (options = {}), {
2609 emulateHTTP: Backbone.emulateHTTP,
2610 emulateJSON: Backbone.emulateJSON
2611 });
2612
2613 // Default JSON-request options.
2614 var params = {type: type, dataType: 'json'};
2615
2616 // Ensure that we have a URL.
2617 if (!options.url) {
2618 params.url = _.result(model, 'url') || urlError();
2619 }
2620
2621 // Ensure that we have the appropriate request data.
2622 if (options.data == null && model && (method === 'create' || method === 'update' || method === 'patch')) {
2623 params.contentType = 'application/json';
2624 params.data = JSON.stringify(options.attrs || model.toJSON(options));
2625 }
2626
2627 // For older servers, emulate JSON by encoding the request into an HTML-form.
2628 if (options.emulateJSON) {
2629 params.contentType = 'application/x-www-form-urlencoded';
2630 params.data = params.data ? {model: params.data} : {};
2631 }
2632
2633 // For older servers, emulate HTTP by mimicking the HTTP method with `_method`
2634 // And an `X-HTTP-Method-Override` header.
2635 if (options.emulateHTTP && (type === 'PUT' || type === 'DELETE' || type === 'PATCH')) {
2636 params.type = 'POST';
2637 if (options.emulateJSON) params.data._method = type;
2638 var beforeSend = options.beforeSend;
2639 options.beforeSend = function(xhr) {
2640 xhr.setRequestHeader('X-HTTP-Method-Override', type);
2641 if (beforeSend) return beforeSend.apply(this, arguments);
2642 };
2643 }
2644
2645 // Don't process data on a non-GET request.
2646 if (params.type !== 'GET' && !options.emulateJSON) {
2647 params.processData = false;
2648 }
2649
2650 var success = options.success;
2651 options.success = function(resp) {
2652 if (success) success(model, resp, options);
2653 model.trigger('sync', model, resp, options);
2654 };
2655
2656 var error = options.error;
2657 options.error = function(xhr) {
2658 if (error) error(model, xhr, options);
2659 model.trigger('error', model, xhr, options);
2660 };
2661
2662 // Make the request, allowing the user to override any Ajax options.
2663 var xhr = options.xhr = Backbone.ajax(_.extend(params, options));
2664 model.trigger('request', model, xhr, options);
2665 return xhr;
2666 };
2667
2668 // Set the default implementation of `Backbone.ajax` to proxy through to `$`.
2669 Backbone.ajax = function() {
2670 return Backbone.$.ajax.apply(Backbone.$, arguments);
2671 };
2672
2673 // Helpers
2674 // -------
2675
2676 // Helper function to correctly set up the prototype chain, for subclasses.
2677 // Similar to `goog.inherits`, but uses a hash of prototype properties and
2678 // class properties to be extended.
2679 var extend = function(protoProps, staticProps) {
2680 var parent = this;
2681 var child;
2682
2683 // The constructor function for the new subclass is either defined by you
2684 // (the "constructor" property in your `extend` definition), or defaulted
2685 // by us to simply call the parent's constructor.
2686 if (protoProps && _.has(protoProps, 'constructor')) {
2687 child = protoProps.constructor;
2688 } else {
2689 child = function(){ return parent.apply(this, arguments); };
2690 }
2691
2692 // Add static properties to the constructor function, if supplied.
2693 _.extend(child, parent, staticProps);
2694
2695 // Set the prototype chain to inherit from `parent`, without calling
2696 // `parent`'s constructor function.
2697 var Surrogate = function(){ this.constructor = child; };
2698 Surrogate.prototype = parent.prototype;
2699 child.prototype = new Surrogate;
2700
2701 // Add prototype properties (instance properties) to the subclass,
2702 // if supplied.
2703 if (protoProps) _.extend(child.prototype, protoProps);
2704
2705 // Set a convenience property in case the parent's prototype is needed
2706 // later.
2707 child.__super__ = parent.prototype;
2708
2709 return child;
2710 };
2711
2712 // Set up inheritance for the model, collection, router, view and history.
2713 Model.extend = Collection.extend = Router.extend = View.extend = History.extend = extend;
2714
2715 // Throw an error when a URL is needed, and none is supplied.
2716 var urlError = function() {
2717 throw new Error('A "url" property or function must be specified');
2718 };
2719
2720}).call(this);
2721/*
2722UriTemplates Template Processor - Version: @VERSION - Dated: @DATE
2723(c) marc.portier@gmail.com - 2011-2012
2724Licensed under ALPv2
2725*/
2726
2727;
2728var uritemplate = (function() {
2729
2730// Below are the functions we originally used from jQuery.
2731// The implementations below are often more naive then what is inside jquery, but they suffice for our needs.
2732
2733function isFunction(fn) {
2734 return typeof fn == 'function';
2735}
2736
2737function isEmptyObject (obj) {
2738 for(var name in obj){
2739 return false;
2740 }
2741 return true;
2742}
2743
2744function extend(base, newprops) {
2745 for (var name in newprops) {
2746 base[name] = newprops[name];
2747 }
2748 return base;
2749}
2750
2751/**
2752 * Create a runtime cache around retrieved values from the context.
2753 * This allows for dynamic (function) results to be kept the same for multiple
2754 * occuring expansions within one template.
2755 * Note: Uses key-value tupples to be able to cache null values as well.
2756 */
2757 //TODO move this into prep-processing
2758function CachingContext(context) {
2759 this.raw = context;
2760 this.cache = {};
2761}
2762CachingContext.prototype.get = function(key) {
2763 var val = this.lookupRaw(key);
2764 var result = val;
2765
2766 if (isFunction(val)) { // check function-result-cache
2767 var tupple = this.cache[key];
2768 if (tupple !== null && tupple !== undefined) {
2769 result = tupple.val;
2770 } else {
2771 result = val(this.raw);
2772 this.cache[key] = {key: key, val: result};
2773 // NOTE: by storing tupples we make sure a null return is validly consistent too in expansions
2774 }
2775 }
2776 return result;
2777};
2778
2779CachingContext.prototype.lookupRaw = function(key) {
2780 return CachingContext.lookup(this, this.raw, key);
2781};
2782
2783CachingContext.lookup = function(me, context, key) {
2784 var result = context[key];
2785 if (result !== undefined) {
2786 return result;
2787 } else {
2788 var keyparts = key.split('.');
2789 var i = 0, keysplits = keyparts.length - 1;
2790 for (i = 0; i<keysplits; i++) {
2791 var leadKey = keyparts.slice(0, keysplits - i).join('.');
2792 var trailKey = keyparts.slice(-i-1).join('.');
2793 var leadContext = context[leadKey];
2794 if (leadContext !== undefined) {
2795 return CachingContext.lookup(me, leadContext, trailKey);
2796 }
2797 }
2798 return undefined;
2799 }
2800};
2801
2802
2803function UriTemplate(set) {
2804 this.set = set;
2805}
2806
2807UriTemplate.prototype.expand = function(context) {
2808 var cache = new CachingContext(context);
2809 var res = "";
2810 var i = 0, cnt = this.set.length;
2811 for (i = 0; i<cnt; i++ ) {
2812 res += this.set[i].expand(cache);
2813 }
2814 return res;
2815};
2816
2817//TODO: change since draft-0.6 about characters in literals
2818/* extract:
2819The characters outside of expressions in a URI Template string are intended to be copied literally to the URI-reference if the character is allowed in a URI (reserved / unreserved / pct-encoded) or, if not allowed, copied to the URI-reference in its UTF-8 pct-encoded form.
2820*/
2821function Literal(txt ) {
2822 this.txt = txt;
2823}
2824
2825Literal.prototype.expand = function() {
2826 return this.txt;
2827};
2828
2829
2830
2831var RESERVEDCHARS_RE = new RegExp("[:/?#\\[\\]@!$&()*+,;=']","g");
2832function encodeNormal(val) {
2833 return encodeURIComponent(val).replace(RESERVEDCHARS_RE, function(s) {return escape(s);} );
2834}
2835
2836//var SELECTEDCHARS_RE = new RegExp("[]","g");
2837function encodeReserved(val) {
2838 //return encodeURI(val).replace(SELECTEDCHARS_RE, function(s) {return escape(s)} );
2839 return encodeURI(val); // no need for additional replace if selected-chars is empty
2840}
2841
2842
2843function addUnNamed(name, key, val) {
2844 return key + (key.length > 0 ? "=" : "") + val;
2845}
2846
2847function addNamed(name, key, val, noName) {
2848 noName = noName || false;
2849 if (noName) { name = ""; }
2850
2851 if (!key || key.length === 0) {
2852 key = name;
2853 }
2854 return key + (key.length > 0 ? "=" : "") + val;
2855}
2856
2857function addLabeled(name, key, val, noName) {
2858 noName = noName || false;
2859 if (noName) { name = ""; }
2860
2861 if (!key || key.length === 0) {
2862 key = name;
2863 }
2864 return key + (key.length > 0 && val ? "=" : "") + val;
2865}
2866
2867
2868var simpleConf = {
2869 prefix : "", joiner : ",", encode : encodeNormal, builder : addUnNamed
2870};
2871var reservedConf = {
2872 prefix : "", joiner : ",", encode : encodeReserved, builder : addUnNamed
2873};
2874var fragmentConf = {
2875 prefix : "#", joiner : ",", encode : encodeReserved, builder : addUnNamed
2876};
2877var pathParamConf = {
2878 prefix : ";", joiner : ";", encode : encodeNormal, builder : addLabeled
2879};
2880var formParamConf = {
2881 prefix : "?", joiner : "&", encode : encodeNormal, builder : addNamed
2882};
2883var formContinueConf = {
2884 prefix : "&", joiner : "&", encode : encodeNormal, builder : addNamed
2885};
2886var pathHierarchyConf = {
2887 prefix : "/", joiner : "/", encode : encodeNormal, builder : addUnNamed
2888};
2889var labelConf = {
2890 prefix : ".", joiner : ".", encode : encodeNormal, builder : addUnNamed
2891};
2892
2893
2894function Expression(conf, vars ) {
2895 extend(this, conf);
2896 this.vars = vars;
2897}
2898
2899Expression.build = function(ops, vars) {
2900 var conf;
2901 switch(ops) {
2902 case '' : conf = simpleConf; break;
2903 case '+' : conf = reservedConf; break;
2904 case '#' : conf = fragmentConf; break;
2905 case ';' : conf = pathParamConf; break;
2906 case '?' : conf = formParamConf; break;
2907 case '&' : conf = formContinueConf; break;
2908 case '/' : conf = pathHierarchyConf; break;
2909 case '.' : conf = labelConf; break;
2910 default : throw "Unexpected operator: '"+ops+"'";
2911 }
2912 return new Expression(conf, vars);
2913};
2914
2915Expression.prototype.expand = function(context) {
2916 var joiner = this.prefix;
2917 var nextjoiner = this.joiner;
2918 var buildSegment = this.builder;
2919 var res = "";
2920 var i = 0, cnt = this.vars.length;
2921
2922 for (i = 0 ; i< cnt; i++) {
2923 var varspec = this.vars[i];
2924 varspec.addValues(context, this.encode, function(key, val, noName) {
2925 var segm = buildSegment(varspec.name, key, val, noName);
2926 if (segm !== null && segm !== undefined) {
2927 res += joiner + segm;
2928 joiner = nextjoiner;
2929 }
2930 });
2931 }
2932 return res;
2933};
2934
2935
2936
2937var UNBOUND = {};
2938
2939/**
2940 * Helper class to help grow a string of (possibly encoded) parts until limit is reached
2941 */
2942function Buffer(limit) {
2943 this.str = "";
2944 if (limit === UNBOUND) {
2945 this.appender = Buffer.UnboundAppend;
2946 } else {
2947 this.len = 0;
2948 this.limit = limit;
2949 this.appender = Buffer.BoundAppend;
2950 }
2951}
2952
2953Buffer.prototype.append = function(part, encoder) {
2954 return this.appender(this, part, encoder);
2955};
2956
2957Buffer.UnboundAppend = function(me, part, encoder) {
2958 part = encoder ? encoder(part) : part;
2959 me.str += part;
2960 return me;
2961};
2962
2963Buffer.BoundAppend = function(me, part, encoder) {
2964 part = part.substring(0, me.limit - me.len);
2965 me.len += part.length;
2966
2967 part = encoder ? encoder(part) : part;
2968 me.str += part;
2969 return me;
2970};
2971
2972
2973function arrayToString(arr, encoder, maxLength) {
2974 var buffer = new Buffer(maxLength);
2975 var joiner = "";
2976
2977 var i = 0, cnt = arr.length;
2978 for (i=0; i<cnt; i++) {
2979 if (arr[i] !== null && arr[i] !== undefined) {
2980 buffer.append(joiner).append(arr[i], encoder);
2981 joiner = ",";
2982 }
2983 }
2984 return buffer.str;
2985}
2986
2987function objectToString(obj, encoder, maxLength) {
2988 var buffer = new Buffer(maxLength);
2989 var joiner = "";
2990 var k;
2991
2992 for (k in obj) {
2993 if (obj.hasOwnProperty(k) ) {
2994 if (obj[k] !== null && obj[k] !== undefined) {
2995 buffer.append(joiner + k + ',').append(obj[k], encoder);
2996 joiner = ",";
2997 }
2998 }
2999 }
3000 return buffer.str;
3001}
3002
3003
3004function simpleValueHandler(me, val, valprops, encoder, adder) {
3005 var result;
3006
3007 if (valprops.isArr) {
3008 result = arrayToString(val, encoder, me.maxLength);
3009 } else if (valprops.isObj) {
3010 result = objectToString(val, encoder, me.maxLength);
3011 } else {
3012 var buffer = new Buffer(me.maxLength);
3013 result = buffer.append(val, encoder).str;
3014 }
3015
3016 adder("", result);
3017}
3018
3019function explodeValueHandler(me, val, valprops, encoder, adder) {
3020 if (valprops.isArr) {
3021 var i = 0, cnt = val.length;
3022 for (i = 0; i<cnt; i++) {
3023 adder("", encoder(val[i]) );
3024 }
3025 } else if (valprops.isObj) {
3026 var k;
3027 for (k in val) {
3028 if (val.hasOwnProperty(k)) {
3029 adder(k, encoder(val[k]) );
3030 }
3031 }
3032 } else { // explode-requested, but single value
3033 adder("", encoder(val));
3034 }
3035}
3036
3037function valueProperties(val) {
3038 var isArr = false;
3039 var isObj = false;
3040 var isUndef = true; //note: "" is empty but not undef
3041
3042 if (val !== null && val !== undefined) {
3043 isArr = (val.constructor === Array);
3044 isObj = (val.constructor === Object);
3045 isUndef = (isArr && val.length === 0) || (isObj && isEmptyObject(val));
3046 }
3047
3048 return {isArr: isArr, isObj: isObj, isUndef: isUndef};
3049}
3050
3051
3052function VarSpec (name, vhfn, nums) {
3053 this.name = unescape(name);
3054 this.valueHandler = vhfn;
3055 this.maxLength = nums;
3056}
3057
3058
3059VarSpec.build = function(name, expl, part, nums) {
3060 var valueHandler, valueModifier;
3061
3062 if (!!expl) { //interprete as boolean
3063 valueHandler = explodeValueHandler;
3064 } else {
3065 valueHandler = simpleValueHandler;
3066 }
3067
3068 if (!part) {
3069 nums = UNBOUND;
3070 }
3071
3072 return new VarSpec(name, valueHandler, nums);
3073};
3074
3075
3076VarSpec.prototype.addValues = function(context, encoder, adder) {
3077 var val = context.get(this.name);
3078 var valprops = valueProperties(val);
3079 if (valprops.isUndef) { return; } // ignore empty values
3080 this.valueHandler(this, val, valprops, encoder, adder);
3081};
3082
3083
3084
3085//----------------------------------------------parsing logic
3086// How each varspec should look like
3087var VARSPEC_RE=/([^*:]*)((\*)|(:)([0-9]+))?/;
3088
3089var match2varspec = function(m) {
3090 var name = m[1];
3091 var expl = m[3];
3092 var part = m[4];
3093 var nums = parseInt(m[5], 10);
3094
3095 return VarSpec.build(name, expl, part, nums);
3096};
3097
3098
3099// Splitting varspecs in list with:
3100var LISTSEP=",";
3101
3102// How each template should look like
3103var TEMPL_RE=/(\{([+#.;?&\/])?(([^.*:,{}|@!=$()][^*:,{}$()]*)(\*|:([0-9]+))?(,([^.*:,{}][^*:,{}]*)(\*|:([0-9]+))?)*)\})/g;
3104// Note: reserved operators: |!@ are left out of the regexp in order to make those templates degrade into literals
3105// (as expected by the spec - see tests.html "reserved operators")
3106
3107
3108var match2expression = function(m) {
3109 var expr = m[0];
3110 var ops = m[2] || '';
3111 var vars = m[3].split(LISTSEP);
3112 var i = 0, len = vars.length;
3113 for (i = 0; i<len; i++) {
3114 var match;
3115 if ( (match = vars[i].match(VARSPEC_RE)) === null) {
3116 throw "unexpected parse error in varspec: " + vars[i];
3117 }
3118 vars[i] = match2varspec(match);
3119 }
3120
3121 return Expression.build(ops, vars);
3122};
3123
3124
3125var pushLiteralSubstr = function(set, src, from, to) {
3126 if (from < to) {
3127 var literal = src.substr(from, to - from);
3128 set.push(new Literal(literal));
3129 }
3130};
3131
3132var parse = function(str) {
3133 var lastpos = 0;
3134 var comp = [];
3135
3136 var match;
3137 var pattern = TEMPL_RE;
3138 pattern.lastIndex = 0; // just to be sure
3139 while ((match = pattern.exec(str)) !== null) {
3140 var newpos = match.index;
3141 pushLiteralSubstr(comp, str, lastpos, newpos);
3142
3143 comp.push(match2expression(match));
3144 lastpos = pattern.lastIndex;
3145 }
3146 pushLiteralSubstr(comp, str, lastpos, str.length);
3147
3148 return new UriTemplate(comp);
3149};
3150
3151
3152//-------------------------------------------comments and ideas
3153
3154//TODO: consider building cache of previously parsed uris or even parsed expressions?
3155
3156return parse;
3157
3158}());
3159/*! URI.js v1.14.1 http://medialize.github.io/URI.js/ */
3160/* build contains: IPv6.js, punycode.js, SecondLevelDomains.js, URI.js, URITemplate.js */
3161(function(f,l){"object"===typeof exports?module.exports=l():"function"===typeof define&&define.amd?define(l):f.IPv6=l(f)})(this,function(f){var l=f&&f.IPv6;return{best:function(g){g=g.toLowerCase().split(":");var m=g.length,b=8;""===g[0]&&""===g[1]&&""===g[2]?(g.shift(),g.shift()):""===g[0]&&""===g[1]?g.shift():""===g[m-1]&&""===g[m-2]&&g.pop();m=g.length;-1!==g[m-1].indexOf(".")&&(b=7);var k;for(k=0;k<m&&""!==g[k];k++);if(k<b)for(g.splice(k,1,"0000");g.length<b;)g.splice(k,0,"0000");for(k=0;k<b;k++){for(var m=
3162g[k].split(""),f=0;3>f;f++)if("0"===m[0]&&1<m.length)m.splice(0,1);else break;g[k]=m.join("")}var m=-1,l=f=0,h=-1,r=!1;for(k=0;k<b;k++)r?"0"===g[k]?l+=1:(r=!1,l>f&&(m=h,f=l)):"0"===g[k]&&(r=!0,h=k,l=1);l>f&&(m=h,f=l);1<f&&g.splice(m,f,"");m=g.length;b="";""===g[0]&&(b=":");for(k=0;k<m;k++){b+=g[k];if(k===m-1)break;b+=":"}""===g[m-1]&&(b+=":");return b},noConflict:function(){f.IPv6===this&&(f.IPv6=l);return this}}});
3163(function(f){function l(b){throw RangeError(v[b]);}function g(b,e){for(var h=b.length;h--;)b[h]=e(b[h]);return b}function m(b,e){return g(b.split(u),e).join(".")}function b(b){for(var e=[],h=0,a=b.length,c,d;h<a;)c=b.charCodeAt(h++),55296<=c&&56319>=c&&h<a?(d=b.charCodeAt(h++),56320==(d&64512)?e.push(((c&1023)<<10)+(d&1023)+65536):(e.push(c),h--)):e.push(c);return e}function k(b){return g(b,function(b){var e="";65535<b&&(b-=65536,e+=A(b>>>10&1023|55296),b=56320|b&1023);return e+=A(b)}).join("")}function y(b,
3164e){return b+22+75*(26>b)-((0!=e)<<5)}function p(b,e,h){var a=0;b=h?q(b/700):b>>1;for(b+=q(b/e);455<b;a+=36)b=q(b/35);return q(a+36*b/(b+38))}function h(b){var e=[],h=b.length,a,c=0,d=128,t=72,w,x,g,f,m;w=b.lastIndexOf("-");0>w&&(w=0);for(x=0;x<w;++x)128<=b.charCodeAt(x)&&l("not-basic"),e.push(b.charCodeAt(x));for(w=0<w?w+1:0;w<h;){x=c;a=1;for(g=36;;g+=36){w>=h&&l("invalid-input");f=b.charCodeAt(w++);f=10>f-48?f-22:26>f-65?f-65:26>f-97?f-97:36;(36<=f||f>q((2147483647-c)/a))&&l("overflow");c+=f*a;m=
3165g<=t?1:g>=t+26?26:g-t;if(f<m)break;f=36-m;a>q(2147483647/f)&&l("overflow");a*=f}a=e.length+1;t=p(c-x,a,0==x);q(c/a)>2147483647-d&&l("overflow");d+=q(c/a);c%=a;e.splice(c++,0,d)}return k(e)}function r(e){var h,g,a,c,d,t,w,x,f,m=[],r,k,n;e=b(e);r=e.length;h=128;g=0;d=72;for(t=0;t<r;++t)f=e[t],128>f&&m.push(A(f));for((a=c=m.length)&&m.push("-");a<r;){w=2147483647;for(t=0;t<r;++t)f=e[t],f>=h&&f<w&&(w=f);k=a+1;w-h>q((2147483647-g)/k)&&l("overflow");g+=(w-h)*k;h=w;for(t=0;t<r;++t)if(f=e[t],f<h&&2147483647<
3166++g&&l("overflow"),f==h){x=g;for(w=36;;w+=36){f=w<=d?1:w>=d+26?26:w-d;if(x<f)break;n=x-f;x=36-f;m.push(A(y(f+n%x,0)));x=q(n/x)}m.push(A(y(x,0)));d=p(g,k,a==c);g=0;++a}++g;++h}return m.join("")}var B="object"==typeof exports&&exports,C="object"==typeof module&&module&&module.exports==B&&module,z="object"==typeof global&&global;if(z.global===z||z.window===z)f=z;var s,n=/^xn--/,e=/[^ -~]/,u=/\x2E|\u3002|\uFF0E|\uFF61/g,v={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)",
3167"invalid-input":"Invalid input"},q=Math.floor,A=String.fromCharCode,D;s={version:"1.2.3",ucs2:{decode:b,encode:k},decode:h,encode:r,toASCII:function(b){return m(b,function(b){return e.test(b)?"xn--"+r(b):b})},toUnicode:function(b){return m(b,function(b){return n.test(b)?h(b.slice(4).toLowerCase()):b})}};if("function"==typeof define&&"object"==typeof define.amd&&define.amd)define(function(){return s});else if(B&&!B.nodeType)if(C)C.exports=s;else for(D in s)s.hasOwnProperty(D)&&(B[D]=s[D]);else f.punycode=
3168s})(this);
3169(function(f,l){"object"===typeof exports?module.exports=l():"function"===typeof define&&define.amd?define(l):f.SecondLevelDomains=l(f)})(this,function(f){var l=f&&f.SecondLevelDomains,g={list:{ac:" com gov mil net org ",ae:" ac co gov mil name net org pro sch ",af:" com edu gov net org ",al:" com edu gov mil net org ",ao:" co ed gv it og pb ",ar:" com edu gob gov int mil net org tur ",at:" ac co gv or ",au:" asn com csiro edu gov id net org ",ba:" co com edu gov mil net org rs unbi unmo unsa untz unze ",bb:" biz co com edu gov info net org store tv ",
3170bh:" biz cc com edu gov info net org ",bn:" com edu gov net org ",bo:" com edu gob gov int mil net org tv ",br:" adm adv agr am arq art ato b bio blog bmd cim cng cnt com coop ecn edu eng esp etc eti far flog fm fnd fot fst g12 ggf gov imb ind inf jor jus lel mat med mil mus net nom not ntr odo org ppg pro psc psi qsl rec slg srv tmp trd tur tv vet vlog wiki zlg ",bs:" com edu gov net org ",bz:" du et om ov rg ",ca:" ab bc mb nb nf nl ns nt nu on pe qc sk yk ",ck:" biz co edu gen gov info net org ",
3171cn:" ac ah bj com cq edu fj gd gov gs gx gz ha hb he hi hl hn jl js jx ln mil net nm nx org qh sc sd sh sn sx tj tw xj xz yn zj ",co:" com edu gov mil net nom org ",cr:" ac c co ed fi go or sa ",cy:" ac biz com ekloges gov ltd name net org parliament press pro tm ","do":" art com edu gob gov mil net org sld web ",dz:" art asso com edu gov net org pol ",ec:" com edu fin gov info med mil net org pro ",eg:" com edu eun gov mil name net org sci ",er:" com edu gov ind mil net org rochest w ",es:" com edu gob nom org ",
3172et:" biz com edu gov info name net org ",fj:" ac biz com info mil name net org pro ",fk:" ac co gov net nom org ",fr:" asso com f gouv nom prd presse tm ",gg:" co net org ",gh:" com edu gov mil org ",gn:" ac com gov net org ",gr:" com edu gov mil net org ",gt:" com edu gob ind mil net org ",gu:" com edu gov net org ",hk:" com edu gov idv net org ",hu:" 2000 agrar bolt casino city co erotica erotika film forum games hotel info ingatlan jogasz konyvelo lakas media news org priv reklam sex shop sport suli szex tm tozsde utazas video ",
3173id:" ac co go mil net or sch web ",il:" ac co gov idf k12 muni net org ","in":" ac co edu ernet firm gen gov i ind mil net nic org res ",iq:" com edu gov i mil net org ",ir:" ac co dnssec gov i id net org sch ",it:" edu gov ",je:" co net org ",jo:" com edu gov mil name net org sch ",jp:" ac ad co ed go gr lg ne or ",ke:" ac co go info me mobi ne or sc ",kh:" com edu gov mil net org per ",ki:" biz com de edu gov info mob net org tel ",km:" asso com coop edu gouv k medecin mil nom notaires pharmaciens presse tm veterinaire ",
3174kn:" edu gov net org ",kr:" ac busan chungbuk chungnam co daegu daejeon es gangwon go gwangju gyeongbuk gyeonggi gyeongnam hs incheon jeju jeonbuk jeonnam k kg mil ms ne or pe re sc seoul ulsan ",kw:" com edu gov net org ",ky:" com edu gov net org ",kz:" com edu gov mil net org ",lb:" com edu gov net org ",lk:" assn com edu gov grp hotel int ltd net ngo org sch soc web ",lr:" com edu gov net org ",lv:" asn com conf edu gov id mil net org ",ly:" com edu gov id med net org plc sch ",ma:" ac co gov m net org press ",
3175mc:" asso tm ",me:" ac co edu gov its net org priv ",mg:" com edu gov mil nom org prd tm ",mk:" com edu gov inf name net org pro ",ml:" com edu gov net org presse ",mn:" edu gov org ",mo:" com edu gov net org ",mt:" com edu gov net org ",mv:" aero biz com coop edu gov info int mil museum name net org pro ",mw:" ac co com coop edu gov int museum net org ",mx:" com edu gob net org ",my:" com edu gov mil name net org sch ",nf:" arts com firm info net other per rec store web ",ng:" biz com edu gov mil mobi name net org sch ",
3176ni:" ac co com edu gob mil net nom org ",np:" com edu gov mil net org ",nr:" biz com edu gov info net org ",om:" ac biz co com edu gov med mil museum net org pro sch ",pe:" com edu gob mil net nom org sld ",ph:" com edu gov i mil net ngo org ",pk:" biz com edu fam gob gok gon gop gos gov net org web ",pl:" art bialystok biz com edu gda gdansk gorzow gov info katowice krakow lodz lublin mil net ngo olsztyn org poznan pwr radom slupsk szczecin torun warszawa waw wroc wroclaw zgora ",pr:" ac biz com edu est gov info isla name net org pro prof ",
3177ps:" com edu gov net org plo sec ",pw:" belau co ed go ne or ",ro:" arts com firm info nom nt org rec store tm www ",rs:" ac co edu gov in org ",sb:" com edu gov net org ",sc:" com edu gov net org ",sh:" co com edu gov net nom org ",sl:" com edu gov net org ",st:" co com consulado edu embaixada gov mil net org principe saotome store ",sv:" com edu gob org red ",sz:" ac co org ",tr:" av bbs bel biz com dr edu gen gov info k12 name net org pol tel tsk tv web ",tt:" aero biz cat co com coop edu gov info int jobs mil mobi museum name net org pro tel travel ",
3178tw:" club com ebiz edu game gov idv mil net org ",mu:" ac co com gov net or org ",mz:" ac co edu gov org ",na:" co com ",nz:" ac co cri geek gen govt health iwi maori mil net org parliament school ",pa:" abo ac com edu gob ing med net nom org sld ",pt:" com edu gov int net nome org publ ",py:" com edu gov mil net org ",qa:" com edu gov mil net org ",re:" asso com nom ",ru:" ac adygeya altai amur arkhangelsk astrakhan bashkiria belgorod bir bryansk buryatia cbg chel chelyabinsk chita chukotka chuvashia com dagestan e-burg edu gov grozny int irkutsk ivanovo izhevsk jar joshkar-ola kalmykia kaluga kamchatka karelia kazan kchr kemerovo khabarovsk khakassia khv kirov koenig komi kostroma kranoyarsk kuban kurgan kursk lipetsk magadan mari mari-el marine mil mordovia mosreg msk murmansk nalchik net nnov nov novosibirsk nsk omsk orenburg org oryol penza perm pp pskov ptz rnd ryazan sakhalin samara saratov simbirsk smolensk spb stavropol stv surgut tambov tatarstan tom tomsk tsaritsyn tsk tula tuva tver tyumen udm udmurtia ulan-ude vladikavkaz vladimir vladivostok volgograd vologda voronezh vrn vyatka yakutia yamal yekaterinburg yuzhno-sakhalinsk ",
3179rw:" ac co com edu gouv gov int mil net ",sa:" com edu gov med net org pub sch ",sd:" com edu gov info med net org tv ",se:" a ac b bd c d e f g h i k l m n o org p parti pp press r s t tm u w x y z ",sg:" com edu gov idn net org per ",sn:" art com edu gouv org perso univ ",sy:" com edu gov mil net news org ",th:" ac co go in mi net or ",tj:" ac biz co com edu go gov info int mil name net nic org test web ",tn:" agrinet com defense edunet ens fin gov ind info intl mincom nat net org perso rnrt rns rnu tourism ",
3180tz:" ac co go ne or ",ua:" biz cherkassy chernigov chernovtsy ck cn co com crimea cv dn dnepropetrovsk donetsk dp edu gov if in ivano-frankivsk kh kharkov kherson khmelnitskiy kiev kirovograd km kr ks kv lg lugansk lutsk lviv me mk net nikolaev od odessa org pl poltava pp rovno rv sebastopol sumy te ternopil uzhgorod vinnica vn zaporizhzhe zhitomir zp zt ",ug:" ac co go ne or org sc ",uk:" ac bl british-library co cym gov govt icnet jet lea ltd me mil mod national-library-scotland nel net nhs nic nls org orgn parliament plc police sch scot soc ",
3181us:" dni fed isa kids nsn ",uy:" com edu gub mil net org ",ve:" co com edu gob info mil net org web ",vi:" co com k12 net org ",vn:" ac biz com edu gov health info int name net org pro ",ye:" co com gov ltd me net org plc ",yu:" ac co edu gov org ",za:" ac agric alt bourse city co cybernet db edu gov grondar iaccess imt inca landesign law mil net ngo nis nom olivetti org pix school tm web ",zm:" ac co com edu gov net org sch "},has:function(f){var b=f.lastIndexOf(".");if(0>=b||b>=f.length-1)return!1;
3182var k=f.lastIndexOf(".",b-1);if(0>=k||k>=b-1)return!1;var l=g.list[f.slice(b+1)];return l?0<=l.indexOf(" "+f.slice(k+1,b)+" "):!1},is:function(f){var b=f.lastIndexOf(".");if(0>=b||b>=f.length-1||0<=f.lastIndexOf(".",b-1))return!1;var k=g.list[f.slice(b+1)];return k?0<=k.indexOf(" "+f.slice(0,b)+" "):!1},get:function(f){var b=f.lastIndexOf(".");if(0>=b||b>=f.length-1)return null;var k=f.lastIndexOf(".",b-1);if(0>=k||k>=b-1)return null;var l=g.list[f.slice(b+1)];return!l||0>l.indexOf(" "+f.slice(k+
31831,b)+" ")?null:f.slice(k+1)},noConflict:function(){f.SecondLevelDomains===this&&(f.SecondLevelDomains=l);return this}};return g});
3184(function(f,l){"object"===typeof exports?module.exports=l(require("./punycode"),require("./IPv6"),require("./SecondLevelDomains")):"function"===typeof define&&define.amd?define(["./punycode","./IPv6","./SecondLevelDomains"],l):f.URI=l(f.punycode,f.IPv6,f.SecondLevelDomains,f)})(this,function(f,l,g,m){function b(a,c){if(!(this instanceof b))return new b(a,c);void 0===a&&(a="undefined"!==typeof location?location.href+"":"");this.href(a);return void 0!==c?this.absoluteTo(c):this}function k(a){return a.replace(/([.*+?^=!:${}()|[\]\/\\])/g,
3185"\\$1")}function y(a){return void 0===a?"Undefined":String(Object.prototype.toString.call(a)).slice(8,-1)}function p(a){return"Array"===y(a)}function h(a,c){var d,b;if(p(c)){d=0;for(b=c.length;d<b;d++)if(!h(a,c[d]))return!1;return!0}var e=y(c);d=0;for(b=a.length;d<b;d++)if("RegExp"===e){if("string"===typeof a[d]&&a[d].match(c))return!0}else if(a[d]===c)return!0;return!1}function r(a,c){if(!p(a)||!p(c)||a.length!==c.length)return!1;a.sort();c.sort();for(var d=0,b=a.length;d<b;d++)if(a[d]!==c[d])return!1;
3186return!0}function B(a){return escape(a)}function C(a){return encodeURIComponent(a).replace(/[!'()*]/g,B).replace(/\*/g,"%2A")}function z(a){return function(c,d){if(void 0===c)return this._parts[a]||"";this._parts[a]=c||null;this.build(!d);return this}}function s(a,c){return function(d,b){if(void 0===d)return this._parts[a]||"";null!==d&&(d+="",d.charAt(0)===c&&(d=d.substring(1)));this._parts[a]=d;this.build(!b);return this}}var n=m&&m.URI;b.version="1.14.1";var e=b.prototype,u=Object.prototype.hasOwnProperty;
3187b._parts=function(){return{protocol:null,username:null,password:null,hostname:null,urn:null,port:null,path:null,query:null,fragment:null,duplicateQueryParameters:b.duplicateQueryParameters,escapeQuerySpace:b.escapeQuerySpace}};b.duplicateQueryParameters=!1;b.escapeQuerySpace=!0;b.protocol_expression=/^[a-z][a-z0-9.+-]*$/i;b.idn_expression=/[^a-z0-9\.-]/i;b.punycode_expression=/(xn--)/i;b.ip4_expression=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;b.ip6_expression=/^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/;
3188b.find_uri_expression=/\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?\u00ab\u00bb\u201c\u201d\u2018\u2019]))/ig;b.findUri={start:/\b(?:([a-z][a-z0-9.+-]*:\/\/)|www\.)/gi,end:/[\s\r\n]|$/,trim:/[`!()\[\]{};:'".,<>?\u00ab\u00bb\u201c\u201d\u201e\u2018\u2019]+$/};b.defaultPorts={http:"80",https:"443",ftp:"21",gopher:"70",ws:"80",wss:"443"};b.invalid_hostname_characters=
3189/[^a-zA-Z0-9\.-]/;b.domAttributes={a:"href",blockquote:"cite",link:"href",base:"href",script:"src",form:"action",img:"src",area:"href",iframe:"src",embed:"src",source:"src",track:"src",input:"src",audio:"src",video:"src"};b.getDomAttribute=function(a){if(a&&a.nodeName){var c=a.nodeName.toLowerCase();return"input"===c&&"image"!==a.type?void 0:b.domAttributes[c]}};b.encode=C;b.decode=decodeURIComponent;b.iso8859=function(){b.encode=escape;b.decode=unescape};b.unicode=function(){b.encode=C;b.decode=
3190decodeURIComponent};b.characters={pathname:{encode:{expression:/%(24|26|2B|2C|3B|3D|3A|40)/ig,map:{"%24":"$","%26":"&","%2B":"+","%2C":",","%3B":";","%3D":"=","%3A":":","%40":"@"}},decode:{expression:/[\/\?#]/g,map:{"/":"%2F","?":"%3F","#":"%23"}}},reserved:{encode:{expression:/%(21|23|24|26|27|28|29|2A|2B|2C|2F|3A|3B|3D|3F|40|5B|5D)/ig,map:{"%3A":":","%2F":"/","%3F":"?","%23":"#","%5B":"[","%5D":"]","%40":"@","%21":"!","%24":"$","%26":"&","%27":"'","%28":"(","%29":")","%2A":"*","%2B":"+","%2C":",",
3191"%3B":";","%3D":"="}}}};b.encodeQuery=function(a,c){var d=b.encode(a+"");void 0===c&&(c=b.escapeQuerySpace);return c?d.replace(/%20/g,"+"):d};b.decodeQuery=function(a,c){a+="";void 0===c&&(c=b.escapeQuerySpace);try{return b.decode(c?a.replace(/\+/g,"%20"):a)}catch(d){return a}};b.recodePath=function(a){a=(a+"").split("/");for(var c=0,d=a.length;c<d;c++)a[c]=b.encodePathSegment(b.decode(a[c]));return a.join("/")};b.decodePath=function(a){a=(a+"").split("/");for(var c=0,d=a.length;c<d;c++)a[c]=b.decodePathSegment(a[c]);
3192return a.join("/")};var v={encode:"encode",decode:"decode"},q,A=function(a,c){return function(d){try{return b[c](d+"").replace(b.characters[a][c].expression,function(d){return b.characters[a][c].map[d]})}catch(t){return d}}};for(q in v)b[q+"PathSegment"]=A("pathname",v[q]);b.encodeReserved=A("reserved","encode");b.parse=function(a,c){var d;c||(c={});d=a.indexOf("#");-1<d&&(c.fragment=a.substring(d+1)||null,a=a.substring(0,d));d=a.indexOf("?");-1<d&&(c.query=a.substring(d+1)||null,a=a.substring(0,
3193d));"//"===a.substring(0,2)?(c.protocol=null,a=a.substring(2),a=b.parseAuthority(a,c)):(d=a.indexOf(":"),-1<d&&(c.protocol=a.substring(0,d)||null,c.protocol&&!c.protocol.match(b.protocol_expression)?c.protocol=void 0:"//"===a.substring(d+1,d+3)?(a=a.substring(d+3),a=b.parseAuthority(a,c)):(a=a.substring(d+1),c.urn=!0)));c.path=a;return c};b.parseHost=function(a,c){var d=a.indexOf("/"),b;-1===d&&(d=a.length);"["===a.charAt(0)?(b=a.indexOf("]"),c.hostname=a.substring(1,b)||null,c.port=a.substring(b+
31942,d)||null,"/"===c.port&&(c.port=null)):a.indexOf(":")!==a.lastIndexOf(":")?(c.hostname=a.substring(0,d)||null,c.port=null):(b=a.substring(0,d).split(":"),c.hostname=b[0]||null,c.port=b[1]||null);c.hostname&&"/"!==a.substring(d).charAt(0)&&(d++,a="/"+a);return a.substring(d)||"/"};b.parseAuthority=function(a,c){a=b.parseUserinfo(a,c);return b.parseHost(a,c)};b.parseUserinfo=function(a,c){var d=a.indexOf("/"),t=a.lastIndexOf("@",-1<d?d:a.length-1);-1<t&&(-1===d||t<d)?(d=a.substring(0,t).split(":"),
3195c.username=d[0]?b.decode(d[0]):null,d.shift(),c.password=d[0]?b.decode(d.join(":")):null,a=a.substring(t+1)):(c.username=null,c.password=null);return a};b.parseQuery=function(a,c){if(!a)return{};a=a.replace(/&+/g,"&").replace(/^\?*&*|&+$/g,"");if(!a)return{};for(var d={},t=a.split("&"),e=t.length,f,h,g=0;g<e;g++)f=t[g].split("="),h=b.decodeQuery(f.shift(),c),f=f.length?b.decodeQuery(f.join("="),c):null,u.call(d,h)?("string"===typeof d[h]&&(d[h]=[d[h]]),d[h].push(f)):d[h]=f;return d};b.build=function(a){var c=
3196"";a.protocol&&(c+=a.protocol+":");a.urn||!c&&!a.hostname||(c+="//");c+=b.buildAuthority(a)||"";"string"===typeof a.path&&("/"!==a.path.charAt(0)&&"string"===typeof a.hostname&&(c+="/"),c+=a.path);"string"===typeof a.query&&a.query&&(c+="?"+a.query);"string"===typeof a.fragment&&a.fragment&&(c+="#"+a.fragment);return c};b.buildHost=function(a){var c="";if(a.hostname)c=b.ip6_expression.test(a.hostname)?c+("["+a.hostname+"]"):c+a.hostname;else return"";a.port&&(c+=":"+a.port);return c};b.buildAuthority=
3197function(a){return b.buildUserinfo(a)+b.buildHost(a)};b.buildUserinfo=function(a){var c="";a.username&&(c+=b.encode(a.username),a.password&&(c+=":"+b.encode(a.password)),c+="@");return c};b.buildQuery=function(a,c,d){var t="",e,f,h,g;for(f in a)if(u.call(a,f)&&f)if(p(a[f]))for(e={},h=0,g=a[f].length;h<g;h++)void 0!==a[f][h]&&void 0===e[a[f][h]+""]&&(t+="&"+b.buildQueryParameter(f,a[f][h],d),!0!==c&&(e[a[f][h]+""]=!0));else void 0!==a[f]&&(t+="&"+b.buildQueryParameter(f,a[f],d));return t.substring(1)};
3198b.buildQueryParameter=function(a,c,d){return b.encodeQuery(a,d)+(null!==c?"="+b.encodeQuery(c,d):"")};b.addQuery=function(a,c,d){if("object"===typeof c)for(var e in c)u.call(c,e)&&b.addQuery(a,e,c[e]);else if("string"===typeof c)void 0===a[c]?a[c]=d:("string"===typeof a[c]&&(a[c]=[a[c]]),p(d)||(d=[d]),a[c]=(a[c]||[]).concat(d));else throw new TypeError("URI.addQuery() accepts an object, string as the name parameter");};b.removeQuery=function(a,c,d){var e;if(p(c))for(d=0,e=c.length;d<e;d++)a[c[d]]=
3199void 0;else if("object"===typeof c)for(e in c)u.call(c,e)&&b.removeQuery(a,e,c[e]);else if("string"===typeof c)if(void 0!==d)if(a[c]===d)a[c]=void 0;else{if(p(a[c])){e=a[c];var f={},h,g;if(p(d))for(h=0,g=d.length;h<g;h++)f[d[h]]=!0;else f[d]=!0;h=0;for(g=e.length;h<g;h++)void 0!==f[e[h]]&&(e.splice(h,1),g--,h--);a[c]=e}}else a[c]=void 0;else throw new TypeError("URI.addQuery() accepts an object, string as the first parameter");};b.hasQuery=function(a,c,d,e){if("object"===typeof c){for(var f in c)if(u.call(c,
3200f)&&!b.hasQuery(a,f,c[f]))return!1;return!0}if("string"!==typeof c)throw new TypeError("URI.hasQuery() accepts an object, string as the name parameter");switch(y(d)){case "Undefined":return c in a;case "Boolean":return a=Boolean(p(a[c])?a[c].length:a[c]),d===a;case "Function":return!!d(a[c],c,a);case "Array":return p(a[c])?(e?h:r)(a[c],d):!1;case "RegExp":return p(a[c])?e?h(a[c],d):!1:Boolean(a[c]&&a[c].match(d));case "Number":d=String(d);case "String":return p(a[c])?e?h(a[c],d):!1:a[c]===d;default:throw new TypeError("URI.hasQuery() accepts undefined, boolean, string, number, RegExp, Function as the value parameter");
3201}};b.commonPath=function(a,c){var d=Math.min(a.length,c.length),b;for(b=0;b<d;b++)if(a.charAt(b)!==c.charAt(b)){b--;break}if(1>b)return a.charAt(0)===c.charAt(0)&&"/"===a.charAt(0)?"/":"";if("/"!==a.charAt(b)||"/"!==c.charAt(b))b=a.substring(0,b).lastIndexOf("/");return a.substring(0,b+1)};b.withinString=function(a,c,d){d||(d={});var e=d.start||b.findUri.start,f=d.end||b.findUri.end,h=d.trim||b.findUri.trim,g=/[a-z0-9-]=["']?$/i;for(e.lastIndex=0;;){var r=e.exec(a);if(!r)break;r=r.index;if(d.ignoreHtml){var k=
3202a.slice(Math.max(r-3,0),r);if(k&&g.test(k))continue}var k=r+a.slice(r).search(f),m=a.slice(r,k).replace(h,"");d.ignore&&d.ignore.test(m)||(k=r+m.length,m=c(m,r,k,a),a=a.slice(0,r)+m+a.slice(k),e.lastIndex=r+m.length)}e.lastIndex=0;return a};b.ensureValidHostname=function(a){if(a.match(b.invalid_hostname_characters)){if(!f)throw new TypeError('Hostname "'+a+'" contains characters other than [A-Z0-9.-] and Punycode.js is not available');if(f.toASCII(a).match(b.invalid_hostname_characters))throw new TypeError('Hostname "'+
3203a+'" contains characters other than [A-Z0-9.-]');}};b.noConflict=function(a){if(a)return a={URI:this.noConflict()},m.URITemplate&&"function"===typeof m.URITemplate.noConflict&&(a.URITemplate=m.URITemplate.noConflict()),m.IPv6&&"function"===typeof m.IPv6.noConflict&&(a.IPv6=m.IPv6.noConflict()),m.SecondLevelDomains&&"function"===typeof m.SecondLevelDomains.noConflict&&(a.SecondLevelDomains=m.SecondLevelDomains.noConflict()),a;m.URI===this&&(m.URI=n);return this};e.build=function(a){if(!0===a)this._deferred_build=
3204!0;else if(void 0===a||this._deferred_build)this._string=b.build(this._parts),this._deferred_build=!1;return this};e.clone=function(){return new b(this)};e.valueOf=e.toString=function(){return this.build(!1)._string};e.protocol=z("protocol");e.username=z("username");e.password=z("password");e.hostname=z("hostname");e.port=z("port");e.query=s("query","?");e.fragment=s("fragment","#");e.search=function(a,c){var d=this.query(a,c);return"string"===typeof d&&d.length?"?"+d:d};e.hash=function(a,c){var d=
3205this.fragment(a,c);return"string"===typeof d&&d.length?"#"+d:d};e.pathname=function(a,c){if(void 0===a||!0===a){var d=this._parts.path||(this._parts.hostname?"/":"");return a?b.decodePath(d):d}this._parts.path=a?b.recodePath(a):"/";this.build(!c);return this};e.path=e.pathname;e.href=function(a,c){var d;if(void 0===a)return this.toString();this._string="";this._parts=b._parts();var e=a instanceof b,f="object"===typeof a&&(a.hostname||a.path||a.pathname);a.nodeName&&(f=b.getDomAttribute(a),a=a[f]||
3206"",f=!1);!e&&f&&void 0!==a.pathname&&(a=a.toString());if("string"===typeof a||a instanceof String)this._parts=b.parse(String(a),this._parts);else if(e||f)for(d in e=e?a._parts:a,e)u.call(this._parts,d)&&(this._parts[d]=e[d]);else throw new TypeError("invalid input");this.build(!c);return this};e.is=function(a){var c=!1,d=!1,e=!1,f=!1,h=!1,r=!1,k=!1,m=!this._parts.urn;this._parts.hostname&&(m=!1,d=b.ip4_expression.test(this._parts.hostname),e=b.ip6_expression.test(this._parts.hostname),c=d||e,h=(f=
3207!c)&&g&&g.has(this._parts.hostname),r=f&&b.idn_expression.test(this._parts.hostname),k=f&&b.punycode_expression.test(this._parts.hostname));switch(a.toLowerCase()){case "relative":return m;case "absolute":return!m;case "domain":case "name":return f;case "sld":return h;case "ip":return c;case "ip4":case "ipv4":case "inet4":return d;case "ip6":case "ipv6":case "inet6":return e;case "idn":return r;case "url":return!this._parts.urn;case "urn":return!!this._parts.urn;case "punycode":return k}return null};
3208var D=e.protocol,E=e.port,F=e.hostname;e.protocol=function(a,c){if(void 0!==a&&a&&(a=a.replace(/:(\/\/)?$/,""),!a.match(b.protocol_expression)))throw new TypeError('Protocol "'+a+"\" contains characters other than [A-Z0-9.+-] or doesn't start with [A-Z]");return D.call(this,a,c)};e.scheme=e.protocol;e.port=function(a,c){if(this._parts.urn)return void 0===a?"":this;if(void 0!==a&&(0===a&&(a=null),a&&(a+="",":"===a.charAt(0)&&(a=a.substring(1)),a.match(/[^0-9]/))))throw new TypeError('Port "'+a+'" contains characters other than [0-9]');
3209return E.call(this,a,c)};e.hostname=function(a,c){if(this._parts.urn)return void 0===a?"":this;if(void 0!==a){var d={};b.parseHost(a,d);a=d.hostname}return F.call(this,a,c)};e.host=function(a,c){if(this._parts.urn)return void 0===a?"":this;if(void 0===a)return this._parts.hostname?b.buildHost(this._parts):"";b.parseHost(a,this._parts);this.build(!c);return this};e.authority=function(a,c){if(this._parts.urn)return void 0===a?"":this;if(void 0===a)return this._parts.hostname?b.buildAuthority(this._parts):
3210"";b.parseAuthority(a,this._parts);this.build(!c);return this};e.userinfo=function(a,c){if(this._parts.urn)return void 0===a?"":this;if(void 0===a){if(!this._parts.username)return"";var d=b.buildUserinfo(this._parts);return d.substring(0,d.length-1)}"@"!==a[a.length-1]&&(a+="@");b.parseUserinfo(a,this._parts);this.build(!c);return this};e.resource=function(a,c){var d;if(void 0===a)return this.path()+this.search()+this.hash();d=b.parse(a);this._parts.path=d.path;this._parts.query=d.query;this._parts.fragment=
3211d.fragment;this.build(!c);return this};e.subdomain=function(a,c){if(this._parts.urn)return void 0===a?"":this;if(void 0===a){if(!this._parts.hostname||this.is("IP"))return"";var d=this._parts.hostname.length-this.domain().length-1;return this._parts.hostname.substring(0,d)||""}d=this._parts.hostname.length-this.domain().length;d=this._parts.hostname.substring(0,d);d=new RegExp("^"+k(d));a&&"."!==a.charAt(a.length-1)&&(a+=".");a&&b.ensureValidHostname(a);this._parts.hostname=this._parts.hostname.replace(d,
3212a);this.build(!c);return this};e.domain=function(a,c){if(this._parts.urn)return void 0===a?"":this;"boolean"===typeof a&&(c=a,a=void 0);if(void 0===a){if(!this._parts.hostname||this.is("IP"))return"";var d=this._parts.hostname.match(/\./g);if(d&&2>d.length)return this._parts.hostname;d=this._parts.hostname.length-this.tld(c).length-1;d=this._parts.hostname.lastIndexOf(".",d-1)+1;return this._parts.hostname.substring(d)||""}if(!a)throw new TypeError("cannot set domain empty");b.ensureValidHostname(a);
3213!this._parts.hostname||this.is("IP")?this._parts.hostname=a:(d=new RegExp(k(this.domain())+"$"),this._parts.hostname=this._parts.hostname.replace(d,a));this.build(!c);return this};e.tld=function(a,c){if(this._parts.urn)return void 0===a?"":this;"boolean"===typeof a&&(c=a,a=void 0);if(void 0===a){if(!this._parts.hostname||this.is("IP"))return"";var d=this._parts.hostname.lastIndexOf("."),d=this._parts.hostname.substring(d+1);return!0!==c&&g&&g.list[d.toLowerCase()]?g.get(this._parts.hostname)||d:d}if(a)if(a.match(/[^a-zA-Z0-9-]/))if(g&&
3214g.is(a))d=new RegExp(k(this.tld())+"$"),this._parts.hostname=this._parts.hostname.replace(d,a);else throw new TypeError('TLD "'+a+'" contains characters other than [A-Z0-9]');else{if(!this._parts.hostname||this.is("IP"))throw new ReferenceError("cannot set TLD on non-domain host");d=new RegExp(k(this.tld())+"$");this._parts.hostname=this._parts.hostname.replace(d,a)}else throw new TypeError("cannot set TLD empty");this.build(!c);return this};e.directory=function(a,c){if(this._parts.urn)return void 0===
3215a?"":this;if(void 0===a||!0===a){if(!this._parts.path&&!this._parts.hostname)return"";if("/"===this._parts.path)return"/";var d=this._parts.path.length-this.filename().length-1,d=this._parts.path.substring(0,d)||(this._parts.hostname?"/":"");return a?b.decodePath(d):d}d=this._parts.path.length-this.filename().length;d=this._parts.path.substring(0,d);d=new RegExp("^"+k(d));this.is("relative")||(a||(a="/"),"/"!==a.charAt(0)&&(a="/"+a));a&&"/"!==a.charAt(a.length-1)&&(a+="/");a=b.recodePath(a);this._parts.path=
3216this._parts.path.replace(d,a);this.build(!c);return this};e.filename=function(a,c){if(this._parts.urn)return void 0===a?"":this;if(void 0===a||!0===a){if(!this._parts.path||"/"===this._parts.path)return"";var d=this._parts.path.lastIndexOf("/"),d=this._parts.path.substring(d+1);return a?b.decodePathSegment(d):d}d=!1;"/"===a.charAt(0)&&(a=a.substring(1));a.match(/\.?\//)&&(d=!0);var e=new RegExp(k(this.filename())+"$");a=b.recodePath(a);this._parts.path=this._parts.path.replace(e,a);d?this.normalizePath(c):
3217this.build(!c);return this};e.suffix=function(a,c){if(this._parts.urn)return void 0===a?"":this;if(void 0===a||!0===a){if(!this._parts.path||"/"===this._parts.path)return"";var d=this.filename(),e=d.lastIndexOf(".");if(-1===e)return"";d=d.substring(e+1);d=/^[a-z0-9%]+$/i.test(d)?d:"";return a?b.decodePathSegment(d):d}"."===a.charAt(0)&&(a=a.substring(1));if(d=this.suffix())e=a?new RegExp(k(d)+"$"):new RegExp(k("."+d)+"$");else{if(!a)return this;this._parts.path+="."+b.recodePath(a)}e&&(a=b.recodePath(a),
3218this._parts.path=this._parts.path.replace(e,a));this.build(!c);return this};e.segment=function(a,c,d){var b=this._parts.urn?":":"/",e=this.path(),f="/"===e.substring(0,1),e=e.split(b);void 0!==a&&"number"!==typeof a&&(d=c,c=a,a=void 0);if(void 0!==a&&"number"!==typeof a)throw Error('Bad segment "'+a+'", must be 0-based integer');f&&e.shift();0>a&&(a=Math.max(e.length+a,0));if(void 0===c)return void 0===a?e:e[a];if(null===a||void 0===e[a])if(p(c)){e=[];a=0;for(var h=c.length;a<h;a++)if(c[a].length||
3219e.length&&e[e.length-1].length)e.length&&!e[e.length-1].length&&e.pop(),e.push(c[a])}else{if(c||"string"===typeof c)""===e[e.length-1]?e[e.length-1]=c:e.push(c)}else c?e[a]=c:e.splice(a,1);f&&e.unshift("");return this.path(e.join(b),d)};e.segmentCoded=function(a,c,d){var e,f;"number"!==typeof a&&(d=c,c=a,a=void 0);if(void 0===c){a=this.segment(a,c,d);if(p(a))for(e=0,f=a.length;e<f;e++)a[e]=b.decode(a[e]);else a=void 0!==a?b.decode(a):void 0;return a}if(p(c))for(e=0,f=c.length;e<f;e++)c[e]=b.decode(c[e]);
3220else c="string"===typeof c||c instanceof String?b.encode(c):c;return this.segment(a,c,d)};var G=e.query;e.query=function(a,c){if(!0===a)return b.parseQuery(this._parts.query,this._parts.escapeQuerySpace);if("function"===typeof a){var d=b.parseQuery(this._parts.query,this._parts.escapeQuerySpace),e=a.call(this,d);this._parts.query=b.buildQuery(e||d,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace);this.build(!c);return this}return void 0!==a&&"string"!==typeof a?(this._parts.query=
3221b.buildQuery(a,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace),this.build(!c),this):G.call(this,a,c)};e.setQuery=function(a,c,d){var e=b.parseQuery(this._parts.query,this._parts.escapeQuerySpace);if("string"===typeof a||a instanceof String)e[a]=void 0!==c?c:null;else if("object"===typeof a)for(var f in a)u.call(a,f)&&(e[f]=a[f]);else throw new TypeError("URI.addQuery() accepts an object, string as the name parameter");this._parts.query=b.buildQuery(e,this._parts.duplicateQueryParameters,
3222this._parts.escapeQuerySpace);"string"!==typeof a&&(d=c);this.build(!d);return this};e.addQuery=function(a,c,d){var e=b.parseQuery(this._parts.query,this._parts.escapeQuerySpace);b.addQuery(e,a,void 0===c?null:c);this._parts.query=b.buildQuery(e,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace);"string"!==typeof a&&(d=c);this.build(!d);return this};e.removeQuery=function(a,c,d){var e=b.parseQuery(this._parts.query,this._parts.escapeQuerySpace);b.removeQuery(e,a,c);this._parts.query=
3223b.buildQuery(e,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace);"string"!==typeof a&&(d=c);this.build(!d);return this};e.hasQuery=function(a,c,d){var e=b.parseQuery(this._parts.query,this._parts.escapeQuerySpace);return b.hasQuery(e,a,c,d)};e.setSearch=e.setQuery;e.addSearch=e.addQuery;e.removeSearch=e.removeQuery;e.hasSearch=e.hasQuery;e.normalize=function(){return this._parts.urn?this.normalizeProtocol(!1).normalizeQuery(!1).normalizeFragment(!1).build():this.normalizeProtocol(!1).normalizeHostname(!1).normalizePort(!1).normalizePath(!1).normalizeQuery(!1).normalizeFragment(!1).build()};
3224e.normalizeProtocol=function(a){"string"===typeof this._parts.protocol&&(this._parts.protocol=this._parts.protocol.toLowerCase(),this.build(!a));return this};e.normalizeHostname=function(a){this._parts.hostname&&(this.is("IDN")&&f?this._parts.hostname=f.toASCII(this._parts.hostname):this.is("IPv6")&&l&&(this._parts.hostname=l.best(this._parts.hostname)),this._parts.hostname=this._parts.hostname.toLowerCase(),this.build(!a));return this};e.normalizePort=function(a){"string"===typeof this._parts.protocol&&
3225this._parts.port===b.defaultPorts[this._parts.protocol]&&(this._parts.port=null,this.build(!a));return this};e.normalizePath=function(a){if(this._parts.urn||!this._parts.path||"/"===this._parts.path)return this;var c,d=this._parts.path,e="",f,h;"/"!==d.charAt(0)&&(c=!0,d="/"+d);d=d.replace(/(\/(\.\/)+)|(\/\.$)/g,"/").replace(/\/{2,}/g,"/");c&&(e=d.substring(1).match(/^(\.\.\/)+/)||"")&&(e=e[0]);for(;;){f=d.indexOf("/..");if(-1===f)break;else if(0===f){d=d.substring(3);continue}h=d.substring(0,f).lastIndexOf("/");
3226-1===h&&(h=f);d=d.substring(0,h)+d.substring(f+3)}c&&this.is("relative")&&(d=e+d.substring(1));d=b.recodePath(d);this._parts.path=d;this.build(!a);return this};e.normalizePathname=e.normalizePath;e.normalizeQuery=function(a){"string"===typeof this._parts.query&&(this._parts.query.length?this.query(b.parseQuery(this._parts.query,this._parts.escapeQuerySpace)):this._parts.query=null,this.build(!a));return this};e.normalizeFragment=function(a){this._parts.fragment||(this._parts.fragment=null,this.build(!a));
3227return this};e.normalizeSearch=e.normalizeQuery;e.normalizeHash=e.normalizeFragment;e.iso8859=function(){var a=b.encode,c=b.decode;b.encode=escape;b.decode=decodeURIComponent;this.normalize();b.encode=a;b.decode=c;return this};e.unicode=function(){var a=b.encode,c=b.decode;b.encode=C;b.decode=unescape;this.normalize();b.encode=a;b.decode=c;return this};e.readable=function(){var a=this.clone();a.username("").password("").normalize();var c="";a._parts.protocol&&(c+=a._parts.protocol+"://");a._parts.hostname&&
3228(a.is("punycode")&&f?(c+=f.toUnicode(a._parts.hostname),a._parts.port&&(c+=":"+a._parts.port)):c+=a.host());a._parts.hostname&&a._parts.path&&"/"!==a._parts.path.charAt(0)&&(c+="/");c+=a.path(!0);if(a._parts.query){for(var d="",e=0,h=a._parts.query.split("&"),g=h.length;e<g;e++){var r=(h[e]||"").split("="),d=d+("&"+b.decodeQuery(r[0],this._parts.escapeQuerySpace).replace(/&/g,"%26"));void 0!==r[1]&&(d+="="+b.decodeQuery(r[1],this._parts.escapeQuerySpace).replace(/&/g,"%26"))}c+="?"+d.substring(1)}return c+=
3229b.decodeQuery(a.hash(),!0)};e.absoluteTo=function(a){var c=this.clone(),d=["protocol","username","password","hostname","port"],e,f;if(this._parts.urn)throw Error("URNs do not have any generally defined hierarchical components");a instanceof b||(a=new b(a));c._parts.protocol||(c._parts.protocol=a._parts.protocol);if(this._parts.hostname)return c;for(e=0;f=d[e];e++)c._parts[f]=a._parts[f];c._parts.path?".."===c._parts.path.substring(-2)&&(c._parts.path+="/"):(c._parts.path=a._parts.path,c._parts.query||
3230(c._parts.query=a._parts.query));"/"!==c.path().charAt(0)&&(a=a.directory(),c._parts.path=(a?a+"/":"")+c._parts.path,c.normalizePath());c.build();return c};e.relativeTo=function(a){var c=this.clone().normalize(),d,e,f,h;if(c._parts.urn)throw Error("URNs do not have any generally defined hierarchical components");a=(new b(a)).normalize();d=c._parts;e=a._parts;f=c.path();h=a.path();if("/"!==f.charAt(0))throw Error("URI is already relative");if("/"!==h.charAt(0))throw Error("Cannot calculate a URI relative to another relative URI");
3231d.protocol===e.protocol&&(d.protocol=null);if(d.username===e.username&&d.password===e.password&&null===d.protocol&&null===d.username&&null===d.password&&d.hostname===e.hostname&&d.port===e.port)d.hostname=null,d.port=null;else return c.build();if(f===h)return d.path="",c.build();a=b.commonPath(c.path(),a.path());if(!a)return c.build();e=e.path.substring(a.length).replace(/[^\/]*$/,"").replace(/.*?\//g,"../");d.path=e+d.path.substring(a.length);return c.build()};e.equals=function(a){var c=this.clone();
3232a=new b(a);var d={},e={},f={},h;c.normalize();a.normalize();if(c.toString()===a.toString())return!0;d=c.query();e=a.query();c.query("");a.query("");if(c.toString()!==a.toString()||d.length!==e.length)return!1;d=b.parseQuery(d,this._parts.escapeQuerySpace);e=b.parseQuery(e,this._parts.escapeQuerySpace);for(h in d)if(u.call(d,h)){if(!p(d[h])){if(d[h]!==e[h])return!1}else if(!r(d[h],e[h]))return!1;f[h]=!0}for(h in e)if(u.call(e,h)&&!f[h])return!1;return!0};e.duplicateQueryParameters=function(a){this._parts.duplicateQueryParameters=
3233!!a;return this};e.escapeQuerySpace=function(a){this._parts.escapeQuerySpace=!!a;return this};return b});
3234(function(f,l){"object"===typeof exports?module.exports=l(require("./URI")):"function"===typeof define&&define.amd?define(["./URI"],l):f.URITemplate=l(f.URI,f)})(this,function(f,l){function g(b){if(g._cache[b])return g._cache[b];if(!(this instanceof g))return new g(b);this.expression=b;g._cache[b]=this;return this}function m(b){this.data=b;this.cache={}}var b=l&&l.URITemplate,k=Object.prototype.hasOwnProperty,y=g.prototype,p={"":{prefix:"",separator:",",named:!1,empty_name_separator:!1,encode:"encode"},
3235"+":{prefix:"",separator:",",named:!1,empty_name_separator:!1,encode:"encodeReserved"},"#":{prefix:"#",separator:",",named:!1,empty_name_separator:!1,encode:"encodeReserved"},".":{prefix:".",separator:".",named:!1,empty_name_separator:!1,encode:"encode"},"/":{prefix:"/",separator:"/",named:!1,empty_name_separator:!1,encode:"encode"},";":{prefix:";",separator:";",named:!0,empty_name_separator:!1,encode:"encode"},"?":{prefix:"?",separator:"&",named:!0,empty_name_separator:!0,encode:"encode"},"&":{prefix:"&",
3236separator:"&",named:!0,empty_name_separator:!0,encode:"encode"}};g._cache={};g.EXPRESSION_PATTERN=/\{([^a-zA-Z0-9%_]?)([^\}]+)(\}|$)/g;g.VARIABLE_PATTERN=/^([^*:]+)((\*)|:(\d+))?$/;g.VARIABLE_NAME_PATTERN=/[^a-zA-Z0-9%_]/;g.expand=function(b,f){var k=p[b.operator],m=k.named?"Named":"Unnamed",l=b.variables,s=[],n,e,u;for(u=0;e=l[u];u++)n=f.get(e.name),n.val.length?s.push(g["expand"+m](n,k,e.explode,e.explode&&k.separator||",",e.maxlength,e.name)):n.type&&s.push("");return s.length?k.prefix+s.join(k.separator):
3237""};g.expandNamed=function(b,g,k,m,l,s){var n="",e=g.encode;g=g.empty_name_separator;var u=!b[e].length,v=2===b.type?"":f[e](s),q,p,y;p=0;for(y=b.val.length;p<y;p++)l?(q=f[e](b.val[p][1].substring(0,l)),2===b.type&&(v=f[e](b.val[p][0].substring(0,l)))):u?(q=f[e](b.val[p][1]),2===b.type?(v=f[e](b.val[p][0]),b[e].push([v,q])):b[e].push([void 0,q])):(q=b[e][p][1],2===b.type&&(v=b[e][p][0])),n&&(n+=m),k?n+=v+(g||q?"=":"")+q:(p||(n+=f[e](s)+(g||q?"=":"")),2===b.type&&(n+=v+","),n+=q);return n};g.expandUnnamed=
3238function(b,g,k,m,l){var s="",n=g.encode;g=g.empty_name_separator;var e=!b[n].length,p,v,q,y;q=0;for(y=b.val.length;q<y;q++)l?v=f[n](b.val[q][1].substring(0,l)):e?(v=f[n](b.val[q][1]),b[n].push([2===b.type?f[n](b.val[q][0]):void 0,v])):v=b[n][q][1],s&&(s+=m),2===b.type&&(p=l?f[n](b.val[q][0].substring(0,l)):b[n][q][0],s+=p,s=k?s+(g||v?"=":""):s+","),s+=v;return s};g.noConflict=function(){l.URITemplate===g&&(l.URITemplate=b);return g};y.expand=function(b){var f="";this.parts&&this.parts.length||this.parse();
3239b instanceof m||(b=new m(b));for(var k=0,l=this.parts.length;k<l;k++)f+="string"===typeof this.parts[k]?this.parts[k]:g.expand(this.parts[k],b);return f};y.parse=function(){var b=this.expression,f=g.EXPRESSION_PATTERN,k=g.VARIABLE_PATTERN,m=g.VARIABLE_NAME_PATTERN,l=[],s=0,n,e,u;for(f.lastIndex=0;;){e=f.exec(b);if(null===e){l.push(b.substring(s));break}else l.push(b.substring(s,e.index)),s=e.index+e[0].length;if(!p[e[1]])throw Error('Unknown Operator "'+e[1]+'" in "'+e[0]+'"');if(!e[3])throw Error('Unclosed Expression "'+
3240e[0]+'"');n=e[2].split(",");for(var v=0,q=n.length;v<q;v++){u=n[v].match(k);if(null===u)throw Error('Invalid Variable "'+n[v]+'" in "'+e[0]+'"');if(u[1].match(m))throw Error('Invalid Variable Name "'+u[1]+'" in "'+e[0]+'"');n[v]={name:u[1],explode:!!u[3],maxlength:u[4]&&parseInt(u[4],10)}}if(!n.length)throw Error('Expression Missing Variable(s) "'+e[0]+'"');l.push({expression:e[0],operator:e[1],variables:n})}l.length||l.push(b);this.parts=l;return this};m.prototype.get=function(b){var f=this.data,
3241g={type:0,val:[],encode:[],encodeReserved:[]},l;if(void 0!==this.cache[b])return this.cache[b];this.cache[b]=g;f="[object Function]"===String(Object.prototype.toString.call(f))?f(b):"[object Function]"===String(Object.prototype.toString.call(f[b]))?f[b](b):f[b];if(void 0!==f&&null!==f)if("[object Array]"===String(Object.prototype.toString.call(f))){l=0;for(b=f.length;l<b;l++)void 0!==f[l]&&null!==f[l]&&g.val.push([void 0,String(f[l])]);g.val.length&&(g.type=3)}else if("[object Object]"===String(Object.prototype.toString.call(f))){for(l in f)k.call(f,
3242l)&&void 0!==f[l]&&null!==f[l]&&g.val.push([l,String(f[l])]);g.val.length&&(g.type=2)}else g.type=1,g.val.push([void 0,String(f)]);return g};f.expand=function(b,k){var l=(new g(b)).expand(k);return new f(l)};return g});
3243/* ===================================================
3244 * bootstrap-transition.js v2.3.1
3245 * http://twitter.github.com/bootstrap/javascript.html#transitions
3246 * ===================================================
3247 * Copyright 2012 Twitter, Inc.
3248 *
3249 * Licensed under the Apache License, Version 2.0 (the "License");
3250 * you may not use this file except in compliance with the License.
3251 * You may obtain a copy of the License at
3252 *
3253 * http://www.apache.org/licenses/LICENSE-2.0
3254 *
3255 * Unless required by applicable law or agreed to in writing, software
3256 * distributed under the License is distributed on an "AS IS" BASIS,
3257 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3258 * See the License for the specific language governing permissions and
3259 * limitations under the License.
3260 * ========================================================== */
3261
3262
3263!function ($) {
3264
3265 "use strict"; // jshint ;_;
3266
3267
3268 /* CSS TRANSITION SUPPORT (http://www.modernizr.com/)
3269 * ======================================================= */
3270
3271 $(function () {
3272
3273 $.support.transition = (function () {
3274
3275 var transitionEnd = (function () {
3276
3277 var el = document.createElement('bootstrap')
3278 , transEndEventNames = {
3279 'WebkitTransition' : 'webkitTransitionEnd'
3280 , 'MozTransition' : 'transitionend'
3281 , 'OTransition' : 'oTransitionEnd otransitionend'
3282 , 'transition' : 'transitionend'
3283 }
3284 , name
3285
3286 for (name in transEndEventNames){
3287 if (el.style[name] !== undefined) {
3288 return transEndEventNames[name]
3289 }
3290 }
3291
3292 }())
3293
3294 return transitionEnd && {
3295 end: transitionEnd
3296 }
3297
3298 })()
3299
3300 })
3301
3302}(window.jQuery);/* ==========================================================
3303 * bootstrap-alert.js v2.3.1
3304 * http://twitter.github.com/bootstrap/javascript.html#alerts
3305 * ==========================================================
3306 * Copyright 2012 Twitter, Inc.
3307 *
3308 * Licensed under the Apache License, Version 2.0 (the "License");
3309 * you may not use this file except in compliance with the License.
3310 * You may obtain a copy of the License at
3311 *
3312 * http://www.apache.org/licenses/LICENSE-2.0
3313 *
3314 * Unless required by applicable law or agreed to in writing, software
3315 * distributed under the License is distributed on an "AS IS" BASIS,
3316 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3317 * See the License for the specific language governing permissions and
3318 * limitations under the License.
3319 * ========================================================== */
3320
3321
3322!function ($) {
3323
3324 "use strict"; // jshint ;_;
3325
3326
3327 /* ALERT CLASS DEFINITION
3328 * ====================== */
3329
3330 var dismiss = '[data-dismiss="alert"]'
3331 , Alert = function (el) {
3332 $(el).on('click', dismiss, this.close)
3333 }
3334
3335 Alert.prototype.close = function (e) {
3336 var $this = $(this)
3337 , selector = $this.attr('data-target')
3338 , $parent
3339
3340 if (!selector) {
3341 selector = $this.attr('href')
3342 selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
3343 }
3344
3345 $parent = $(selector)
3346
3347 e && e.preventDefault()
3348
3349 $parent.length || ($parent = $this.hasClass('alert') ? $this : $this.parent())
3350
3351 $parent.trigger(e = $.Event('close'))
3352
3353 if (e.isDefaultPrevented()) return
3354
3355 $parent.removeClass('in')
3356
3357 function removeElement() {
3358 $parent
3359 .trigger('closed')
3360 .remove()
3361 }
3362
3363 $.support.transition && $parent.hasClass('fade') ?
3364 $parent.on($.support.transition.end, removeElement) :
3365 removeElement()
3366 }
3367
3368
3369 /* ALERT PLUGIN DEFINITION
3370 * ======================= */
3371
3372 var old = $.fn.alert
3373
3374 $.fn.alert = function (option) {
3375 return this.each(function () {
3376 var $this = $(this)
3377 , data = $this.data('alert')
3378 if (!data) $this.data('alert', (data = new Alert(this)))
3379 if (typeof option == 'string') data[option].call($this)
3380 })
3381 }
3382
3383 $.fn.alert.Constructor = Alert
3384
3385
3386 /* ALERT NO CONFLICT
3387 * ================= */
3388
3389 $.fn.alert.noConflict = function () {
3390 $.fn.alert = old
3391 return this
3392 }
3393
3394
3395 /* ALERT DATA-API
3396 * ============== */
3397
3398 $(document).on('click.alert.data-api', dismiss, Alert.prototype.close)
3399
3400}(window.jQuery);/* ============================================================
3401 * bootstrap-button.js v2.3.1
3402 * http://twitter.github.com/bootstrap/javascript.html#buttons
3403 * ============================================================
3404 * Copyright 2012 Twitter, Inc.
3405 *
3406 * Licensed under the Apache License, Version 2.0 (the "License");
3407 * you may not use this file except in compliance with the License.
3408 * You may obtain a copy of the License at
3409 *
3410 * http://www.apache.org/licenses/LICENSE-2.0
3411 *
3412 * Unless required by applicable law or agreed to in writing, software
3413 * distributed under the License is distributed on an "AS IS" BASIS,
3414 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3415 * See the License for the specific language governing permissions and
3416 * limitations under the License.
3417 * ============================================================ */
3418
3419
3420!function ($) {
3421
3422 "use strict"; // jshint ;_;
3423
3424
3425 /* BUTTON PUBLIC CLASS DEFINITION
3426 * ============================== */
3427
3428 var Button = function (element, options) {
3429 this.$element = $(element)
3430 this.options = $.extend({}, $.fn.button.defaults, options)
3431 }
3432
3433 Button.prototype.setState = function (state) {
3434 var d = 'disabled'
3435 , $el = this.$element
3436 , data = $el.data()
3437 , val = $el.is('input') ? 'val' : 'html'
3438
3439 state = state + 'Text'
3440 data.resetText || $el.data('resetText', $el[val]())
3441
3442 $el[val](data[state] || this.options[state])
3443
3444 // push to event loop to allow forms to submit
3445 setTimeout(function () {
3446 state == 'loadingText' ?
3447 $el.addClass(d).attr(d, d) :
3448 $el.removeClass(d).removeAttr(d)
3449 }, 0)
3450 }
3451
3452 Button.prototype.toggle = function () {
3453 var $parent = this.$element.closest('[data-toggle="buttons-radio"]')
3454
3455 $parent && $parent
3456 .find('.active')
3457 .removeClass('active')
3458
3459 this.$element.toggleClass('active')
3460 }
3461
3462
3463 /* BUTTON PLUGIN DEFINITION
3464 * ======================== */
3465
3466 var old = $.fn.button
3467
3468 $.fn.button = function (option) {
3469 return this.each(function () {
3470 var $this = $(this)
3471 , data = $this.data('button')
3472 , options = typeof option == 'object' && option
3473 if (!data) $this.data('button', (data = new Button(this, options)))
3474 if (option == 'toggle') data.toggle()
3475 else if (option) data.setState(option)
3476 })
3477 }
3478
3479 $.fn.button.defaults = {
3480 loadingText: 'loading...'
3481 }
3482
3483 $.fn.button.Constructor = Button
3484
3485
3486 /* BUTTON NO CONFLICT
3487 * ================== */
3488
3489 $.fn.button.noConflict = function () {
3490 $.fn.button = old
3491 return this
3492 }
3493
3494
3495 /* BUTTON DATA-API
3496 * =============== */
3497
3498 $(document).on('click.button.data-api', '[data-toggle^=button]', function (e) {
3499 var $btn = $(e.target)
3500 if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
3501 $btn.button('toggle')
3502 })
3503
3504}(window.jQuery);/* ==========================================================
3505 * bootstrap-carousel.js v2.3.1
3506 * http://twitter.github.com/bootstrap/javascript.html#carousel
3507 * ==========================================================
3508 * Copyright 2012 Twitter, Inc.
3509 *
3510 * Licensed under the Apache License, Version 2.0 (the "License");
3511 * you may not use this file except in compliance with the License.
3512 * You may obtain a copy of the License at
3513 *
3514 * http://www.apache.org/licenses/LICENSE-2.0
3515 *
3516 * Unless required by applicable law or agreed to in writing, software
3517 * distributed under the License is distributed on an "AS IS" BASIS,
3518 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3519 * See the License for the specific language governing permissions and
3520 * limitations under the License.
3521 * ========================================================== */
3522
3523
3524!function ($) {
3525
3526 "use strict"; // jshint ;_;
3527
3528
3529 /* CAROUSEL CLASS DEFINITION
3530 * ========================= */
3531
3532 var Carousel = function (element, options) {
3533 this.$element = $(element)
3534 this.$indicators = this.$element.find('.carousel-indicators')
3535 this.options = options
3536 this.options.pause == 'hover' && this.$element
3537 .on('mouseenter', $.proxy(this.pause, this))
3538 .on('mouseleave', $.proxy(this.cycle, this))
3539 }
3540
3541 Carousel.prototype = {
3542
3543 cycle: function (e) {
3544 if (!e) this.paused = false
3545 if (this.interval) clearInterval(this.interval);
3546 this.options.interval
3547 && !this.paused
3548 && (this.interval = setInterval($.proxy(this.next, this), this.options.interval))
3549 return this
3550 }
3551
3552 , getActiveIndex: function () {
3553 this.$active = this.$element.find('.item.active')
3554 this.$items = this.$active.parent().children()
3555 return this.$items.index(this.$active)
3556 }
3557
3558 , to: function (pos) {
3559 var activeIndex = this.getActiveIndex()
3560 , that = this
3561
3562 if (pos > (this.$items.length - 1) || pos < 0) return
3563
3564 if (this.sliding) {
3565 return this.$element.one('slid', function () {
3566 that.to(pos)
3567 })
3568 }
3569
3570 if (activeIndex == pos) {
3571 return this.pause().cycle()
3572 }
3573
3574 return this.slide(pos > activeIndex ? 'next' : 'prev', $(this.$items[pos]))
3575 }
3576
3577 , pause: function (e) {
3578 if (!e) this.paused = true
3579 if (this.$element.find('.next, .prev').length && $.support.transition.end) {
3580 this.$element.trigger($.support.transition.end)
3581 this.cycle(true)
3582 }
3583 clearInterval(this.interval)
3584 this.interval = null
3585 return this
3586 }
3587
3588 , next: function () {
3589 if (this.sliding) return
3590 return this.slide('next')
3591 }
3592
3593 , prev: function () {
3594 if (this.sliding) return
3595 return this.slide('prev')
3596 }
3597
3598 , slide: function (type, next) {
3599 var $active = this.$element.find('.item.active')
3600 , $next = next || $active[type]()
3601 , isCycling = this.interval
3602 , direction = type == 'next' ? 'left' : 'right'
3603 , fallback = type == 'next' ? 'first' : 'last'
3604 , that = this
3605 , e
3606
3607 this.sliding = true
3608
3609 isCycling && this.pause()
3610
3611 $next = $next.length ? $next : this.$element.find('.item')[fallback]()
3612
3613 e = $.Event('slide', {
3614 relatedTarget: $next[0]
3615 , direction: direction
3616 })
3617
3618 if ($next.hasClass('active')) return
3619
3620 if (this.$indicators.length) {
3621 this.$indicators.find('.active').removeClass('active')
3622 this.$element.one('slid', function () {
3623 var $nextIndicator = $(that.$indicators.children()[that.getActiveIndex()])
3624 $nextIndicator && $nextIndicator.addClass('active')
3625 })
3626 }
3627
3628 if ($.support.transition && this.$element.hasClass('slide')) {
3629 this.$element.trigger(e)
3630 if (e.isDefaultPrevented()) return
3631 $next.addClass(type)
3632 $next[0].offsetWidth // force reflow
3633 $active.addClass(direction)
3634 $next.addClass(direction)
3635 this.$element.one($.support.transition.end, function () {
3636 $next.removeClass([type, direction].join(' ')).addClass('active')
3637 $active.removeClass(['active', direction].join(' '))
3638 that.sliding = false
3639 setTimeout(function () { that.$element.trigger('slid') }, 0)
3640 })
3641 } else {
3642 this.$element.trigger(e)
3643 if (e.isDefaultPrevented()) return
3644 $active.removeClass('active')
3645 $next.addClass('active')
3646 this.sliding = false
3647 this.$element.trigger('slid')
3648 }
3649
3650 isCycling && this.cycle()
3651
3652 return this
3653 }
3654
3655 }
3656
3657
3658 /* CAROUSEL PLUGIN DEFINITION
3659 * ========================== */
3660
3661 var old = $.fn.carousel
3662
3663 $.fn.carousel = function (option) {
3664 return this.each(function () {
3665 var $this = $(this)
3666 , data = $this.data('carousel')
3667 , options = $.extend({}, $.fn.carousel.defaults, typeof option == 'object' && option)
3668 , action = typeof option == 'string' ? option : options.slide
3669 if (!data) $this.data('carousel', (data = new Carousel(this, options)))
3670 if (typeof option == 'number') data.to(option)
3671 else if (action) data[action]()
3672 else if (options.interval) data.pause().cycle()
3673 })
3674 }
3675
3676 $.fn.carousel.defaults = {
3677 interval: 5000
3678 , pause: 'hover'
3679 }
3680
3681 $.fn.carousel.Constructor = Carousel
3682
3683
3684 /* CAROUSEL NO CONFLICT
3685 * ==================== */
3686
3687 $.fn.carousel.noConflict = function () {
3688 $.fn.carousel = old
3689 return this
3690 }
3691
3692 /* CAROUSEL DATA-API
3693 * ================= */
3694
3695 $(document).on('click.carousel.data-api', '[data-slide], [data-slide-to]', function (e) {
3696 var $this = $(this), href
3697 , $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
3698 , options = $.extend({}, $target.data(), $this.data())
3699 , slideIndex
3700
3701 $target.carousel(options)
3702
3703 if (slideIndex = $this.attr('data-slide-to')) {
3704 $target.data('carousel').pause().to(slideIndex).cycle()
3705 }
3706
3707 e.preventDefault()
3708 })
3709
3710}(window.jQuery);/* =============================================================
3711 * bootstrap-collapse.js v2.3.1
3712 * http://twitter.github.com/bootstrap/javascript.html#collapse
3713 * =============================================================
3714 * Copyright 2012 Twitter, Inc.
3715 *
3716 * Licensed under the Apache License, Version 2.0 (the "License");
3717 * you may not use this file except in compliance with the License.
3718 * You may obtain a copy of the License at
3719 *
3720 * http://www.apache.org/licenses/LICENSE-2.0
3721 *
3722 * Unless required by applicable law or agreed to in writing, software
3723 * distributed under the License is distributed on an "AS IS" BASIS,
3724 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3725 * See the License for the specific language governing permissions and
3726 * limitations under the License.
3727 * ============================================================ */
3728
3729
3730!function ($) {
3731
3732 "use strict"; // jshint ;_;
3733
3734
3735 /* COLLAPSE PUBLIC CLASS DEFINITION
3736 * ================================ */
3737
3738 var Collapse = function (element, options) {
3739 this.$element = $(element)
3740 this.options = $.extend({}, $.fn.collapse.defaults, options)
3741
3742 if (this.options.parent) {
3743 this.$parent = $(this.options.parent)
3744 }
3745
3746 this.options.toggle && this.toggle()
3747 }
3748
3749 Collapse.prototype = {
3750
3751 constructor: Collapse
3752
3753 , dimension: function () {
3754 var hasWidth = this.$element.hasClass('width')
3755 return hasWidth ? 'width' : 'height'
3756 }
3757
3758 , show: function () {
3759 var dimension
3760 , scroll
3761 , actives
3762 , hasData
3763
3764 if (this.transitioning || this.$element.hasClass('in')) return
3765
3766 dimension = this.dimension()
3767 scroll = $.camelCase(['scroll', dimension].join('-'))
3768 actives = this.$parent && this.$parent.find('> .accordion-group > .in')
3769
3770 if (actives && actives.length) {
3771 hasData = actives.data('collapse')
3772 if (hasData && hasData.transitioning) return
3773 actives.collapse('hide')
3774 hasData || actives.data('collapse', null)
3775 }
3776
3777 this.$element[dimension](0)
3778 this.transition('addClass', $.Event('show'), 'shown')
3779 $.support.transition && this.$element[dimension](this.$element[0][scroll])
3780 }
3781
3782 , hide: function () {
3783 var dimension
3784 if (this.transitioning || !this.$element.hasClass('in')) return
3785 dimension = this.dimension()
3786 this.reset(this.$element[dimension]())
3787 this.transition('removeClass', $.Event('hide'), 'hidden')
3788 this.$element[dimension](0)
3789 }
3790
3791 , reset: function (size) {
3792 var dimension = this.dimension()
3793
3794 this.$element
3795 .removeClass('collapse')
3796 [dimension](size || 'auto')
3797 [0].offsetWidth
3798
3799 this.$element[size !== null ? 'addClass' : 'removeClass']('collapse')
3800
3801 return this
3802 }
3803
3804 , transition: function (method, startEvent, completeEvent) {
3805 var that = this
3806 , complete = function () {
3807 if (startEvent.type == 'show') that.reset()
3808 that.transitioning = 0
3809 that.$element.trigger(completeEvent)
3810 }
3811
3812 this.$element.trigger(startEvent)
3813
3814 if (startEvent.isDefaultPrevented()) return
3815
3816 this.transitioning = 1
3817
3818 this.$element[method]('in')
3819
3820 $.support.transition && this.$element.hasClass('collapse') ?
3821 this.$element.one($.support.transition.end, complete) :
3822 complete()
3823 }
3824
3825 , toggle: function () {
3826 this[this.$element.hasClass('in') ? 'hide' : 'show']()
3827 }
3828
3829 }
3830
3831
3832 /* COLLAPSE PLUGIN DEFINITION
3833 * ========================== */
3834
3835 var old = $.fn.collapse
3836
3837 $.fn.collapse = function (option) {
3838 return this.each(function () {
3839 var $this = $(this)
3840 , data = $this.data('collapse')
3841 , options = $.extend({}, $.fn.collapse.defaults, $this.data(), typeof option == 'object' && option)
3842 if (!data) $this.data('collapse', (data = new Collapse(this, options)))
3843 if (typeof option == 'string') data[option]()
3844 })
3845 }
3846
3847 $.fn.collapse.defaults = {
3848 toggle: true
3849 }
3850
3851 $.fn.collapse.Constructor = Collapse
3852
3853
3854 /* COLLAPSE NO CONFLICT
3855 * ==================== */
3856
3857 $.fn.collapse.noConflict = function () {
3858 $.fn.collapse = old
3859 return this
3860 }
3861
3862
3863 /* COLLAPSE DATA-API
3864 * ================= */
3865
3866 $(document).on('click.collapse.data-api', '[data-toggle=collapse]', function (e) {
3867 var $this = $(this), href
3868 , target = $this.attr('data-target')
3869 || e.preventDefault()
3870 || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7
3871 , option = $(target).data('collapse') ? 'toggle' : $this.data()
3872 $this[$(target).hasClass('in') ? 'addClass' : 'removeClass']('collapsed')
3873 $(target).collapse(option)
3874 })
3875
3876}(window.jQuery);/* ============================================================
3877 * bootstrap-dropdown.js v2.3.1
3878 * http://twitter.github.com/bootstrap/javascript.html#dropdowns
3879 * ============================================================
3880 * Copyright 2012 Twitter, Inc.
3881 *
3882 * Licensed under the Apache License, Version 2.0 (the "License");
3883 * you may not use this file except in compliance with the License.
3884 * You may obtain a copy of the License at
3885 *
3886 * http://www.apache.org/licenses/LICENSE-2.0
3887 *
3888 * Unless required by applicable law or agreed to in writing, software
3889 * distributed under the License is distributed on an "AS IS" BASIS,
3890 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3891 * See the License for the specific language governing permissions and
3892 * limitations under the License.
3893 * ============================================================ */
3894
3895
3896!function ($) {
3897
3898 "use strict"; // jshint ;_;
3899
3900
3901 /* DROPDOWN CLASS DEFINITION
3902 * ========================= */
3903
3904 var toggle = '[data-toggle=dropdown]'
3905 , Dropdown = function (element) {
3906 var $el = $(element).on('click.dropdown.data-api', this.toggle)
3907 $('html').on('click.dropdown.data-api', function () {
3908 $el.parent().removeClass('open')
3909 })
3910 }
3911
3912 Dropdown.prototype = {
3913
3914 constructor: Dropdown
3915
3916 , toggle: function (e) {
3917 var $this = $(this)
3918 , $parent
3919 , isActive
3920
3921 if ($this.is('.disabled, :disabled')) return
3922
3923 $parent = getParent($this)
3924
3925 isActive = $parent.hasClass('open')
3926
3927 clearMenus()
3928
3929 if (!isActive) {
3930 $parent.toggleClass('open')
3931 }
3932
3933 $this.focus()
3934
3935 return false
3936 }
3937
3938 , keydown: function (e) {
3939 var $this
3940 , $items
3941 , $active
3942 , $parent
3943 , isActive
3944 , index
3945
3946 if (!/(38|40|27)/.test(e.keyCode)) return
3947
3948 $this = $(this)
3949
3950 e.preventDefault()
3951 e.stopPropagation()
3952
3953 if ($this.is('.disabled, :disabled')) return
3954
3955 $parent = getParent($this)
3956
3957 isActive = $parent.hasClass('open')
3958
3959 if (!isActive || (isActive && e.keyCode == 27)) {
3960 if (e.which == 27) $parent.find(toggle).focus()
3961 return $this.click()
3962 }
3963
3964 $items = $('[role=menu] li:not(.divider):visible a', $parent)
3965
3966 if (!$items.length) return
3967
3968 index = $items.index($items.filter(':focus'))
3969
3970 if (e.keyCode == 38 && index > 0) index-- // up
3971 if (e.keyCode == 40 && index < $items.length - 1) index++ // down
3972 if (!~index) index = 0
3973
3974 $items
3975 .eq(index)
3976 .focus()
3977 }
3978
3979 }
3980
3981 function clearMenus() {
3982 $(toggle).each(function () {
3983 getParent($(this)).removeClass('open')
3984 })
3985 }
3986
3987 function getParent($this) {
3988 var selector = $this.attr('data-target')
3989 , $parent
3990
3991 if (!selector) {
3992 selector = $this.attr('href')
3993 selector = selector && /#/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
3994 }
3995
3996 $parent = selector && $(selector)
3997
3998 if (!$parent || !$parent.length) $parent = $this.parent()
3999
4000 return $parent
4001 }
4002
4003
4004 /* DROPDOWN PLUGIN DEFINITION
4005 * ========================== */
4006
4007 var old = $.fn.dropdown
4008
4009 $.fn.dropdown = function (option) {
4010 return this.each(function () {
4011 var $this = $(this)
4012 , data = $this.data('dropdown')
4013 if (!data) $this.data('dropdown', (data = new Dropdown(this)))
4014 if (typeof option == 'string') data[option].call($this)
4015 })
4016 }
4017
4018 $.fn.dropdown.Constructor = Dropdown
4019
4020
4021 /* DROPDOWN NO CONFLICT
4022 * ==================== */
4023
4024 $.fn.dropdown.noConflict = function () {
4025 $.fn.dropdown = old
4026 return this
4027 }
4028
4029
4030 /* APPLY TO STANDARD DROPDOWN ELEMENTS
4031 * =================================== */
4032
4033 $(document)
4034 .on('click.dropdown.data-api', clearMenus)
4035 .on('click.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
4036 .on('click.dropdown-menu', function (e) { e.stopPropagation() })
4037 .on('click.dropdown.data-api' , toggle, Dropdown.prototype.toggle)
4038 .on('keydown.dropdown.data-api', toggle + ', [role=menu]' , Dropdown.prototype.keydown)
4039
4040}(window.jQuery);
4041/* =========================================================
4042 * bootstrap-modal.js v2.3.1
4043 * http://twitter.github.com/bootstrap/javascript.html#modals
4044 * =========================================================
4045 * Copyright 2012 Twitter, Inc.
4046 *
4047 * Licensed under the Apache License, Version 2.0 (the "License");
4048 * you may not use this file except in compliance with the License.
4049 * You may obtain a copy of the License at
4050 *
4051 * http://www.apache.org/licenses/LICENSE-2.0
4052 *
4053 * Unless required by applicable law or agreed to in writing, software
4054 * distributed under the License is distributed on an "AS IS" BASIS,
4055 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4056 * See the License for the specific language governing permissions and
4057 * limitations under the License.
4058 * ========================================================= */
4059
4060
4061!function ($) {
4062
4063 "use strict"; // jshint ;_;
4064
4065
4066 /* MODAL CLASS DEFINITION
4067 * ====================== */
4068
4069 var Modal = function (element, options) {
4070 this.options = options
4071 this.$element = $(element)
4072 .delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this))
4073 this.options.remote && this.$element.find('.modal-body').load(this.options.remote)
4074 }
4075
4076 Modal.prototype = {
4077
4078 constructor: Modal
4079
4080 , toggle: function () {
4081 return this[!this.isShown ? 'show' : 'hide']()
4082 }
4083
4084 , show: function () {
4085 var that = this
4086 , e = $.Event('show')
4087
4088 this.$element.trigger(e)
4089
4090 if (this.isShown || e.isDefaultPrevented()) return
4091
4092 this.isShown = true
4093
4094 this.escape()
4095
4096 this.backdrop(function () {
4097 var transition = $.support.transition && that.$element.hasClass('fade')
4098
4099 if (!that.$element.parent().length) {
4100 that.$element.appendTo(document.body) //don't move modals dom position
4101 }
4102
4103 that.$element.show()
4104
4105 if (transition) {
4106 that.$element[0].offsetWidth // force reflow
4107 }
4108
4109 that.$element
4110 .addClass('in')
4111 .attr('aria-hidden', false)
4112
4113 that.enforceFocus()
4114
4115 transition ?
4116 that.$element.one($.support.transition.end, function () { that.$element.focus().trigger('shown') }) :
4117 that.$element.focus().trigger('shown')
4118
4119 })
4120 }
4121
4122 , hide: function (e) {
4123 e && e.preventDefault()
4124
4125 var that = this
4126
4127 e = $.Event('hide')
4128
4129 this.$element.trigger(e)
4130
4131 if (!this.isShown || e.isDefaultPrevented()) return
4132
4133 this.isShown = false
4134
4135 this.escape()
4136
4137 $(document).off('focusin.modal')
4138
4139 this.$element
4140 .removeClass('in')
4141 .attr('aria-hidden', true)
4142
4143 $.support.transition && this.$element.hasClass('fade') ?
4144 this.hideWithTransition() :
4145 this.hideModal()
4146 }
4147
4148 , enforceFocus: function () {
4149 var that = this
4150 $(document).on('focusin.modal', function (e) {
4151 if (that.$element[0] !== e.target && !that.$element.has(e.target).length) {
4152 that.$element.focus()
4153 }
4154 })
4155 }
4156
4157 , escape: function () {
4158 var that = this
4159 if (this.isShown && this.options.keyboard) {
4160 this.$element.on('keyup.dismiss.modal', function ( e ) {
4161 e.which == 27 && that.hide()
4162 })
4163 } else if (!this.isShown) {
4164 this.$element.off('keyup.dismiss.modal')
4165 }
4166 }
4167
4168 , hideWithTransition: function () {
4169 var that = this
4170 , timeout = setTimeout(function () {
4171 that.$element.off($.support.transition.end)
4172 that.hideModal()
4173 }, 500)
4174
4175 this.$element.one($.support.transition.end, function () {
4176 clearTimeout(timeout)
4177 that.hideModal()
4178 })
4179 }
4180
4181 , hideModal: function () {
4182 var that = this
4183 this.$element.hide()
4184 this.backdrop(function () {
4185 that.removeBackdrop()
4186 that.$element.trigger('hidden')
4187 })
4188 }
4189
4190 , removeBackdrop: function () {
4191 this.$backdrop && this.$backdrop.remove()
4192 this.$backdrop = null
4193 }
4194
4195 , backdrop: function (callback) {
4196 var that = this
4197 , animate = this.$element.hasClass('fade') ? 'fade' : ''
4198
4199 if (this.isShown && this.options.backdrop) {
4200 var doAnimate = $.support.transition && animate
4201
4202 this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
4203 .appendTo(document.body)
4204
4205 this.$backdrop.click(
4206 this.options.backdrop == 'static' ?
4207 $.proxy(this.$element[0].focus, this.$element[0])
4208 : $.proxy(this.hide, this)
4209 )
4210
4211 if (doAnimate) this.$backdrop[0].offsetWidth // force reflow
4212
4213 this.$backdrop.addClass('in')
4214
4215 if (!callback) return
4216
4217 doAnimate ?
4218 this.$backdrop.one($.support.transition.end, callback) :
4219 callback()
4220
4221 } else if (!this.isShown && this.$backdrop) {
4222 this.$backdrop.removeClass('in')
4223
4224 $.support.transition && this.$element.hasClass('fade')?
4225 this.$backdrop.one($.support.transition.end, callback) :
4226 callback()
4227
4228 } else if (callback) {
4229 callback()
4230 }
4231 }
4232 }
4233
4234
4235 /* MODAL PLUGIN DEFINITION
4236 * ======================= */
4237
4238 var old = $.fn.modal
4239
4240 $.fn.modal = function (option) {
4241 return this.each(function () {
4242 var $this = $(this)
4243 , data = $this.data('modal')
4244 , options = $.extend({}, $.fn.modal.defaults, $this.data(), typeof option == 'object' && option)
4245 if (!data) $this.data('modal', (data = new Modal(this, options)))
4246 if (typeof option == 'string') data[option]()
4247 else if (options.show) data.show()
4248 })
4249 }
4250
4251 $.fn.modal.defaults = {
4252 backdrop: true
4253 , keyboard: true
4254 , show: true
4255 }
4256
4257 $.fn.modal.Constructor = Modal
4258
4259
4260 /* MODAL NO CONFLICT
4261 * ================= */
4262
4263 $.fn.modal.noConflict = function () {
4264 $.fn.modal = old
4265 return this
4266 }
4267
4268
4269 /* MODAL DATA-API
4270 * ============== */
4271
4272 $(document).on('click.modal.data-api', '[data-toggle="modal"]', function (e) {
4273 var $this = $(this)
4274 , href = $this.attr('href')
4275 , $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) //strip for ie7
4276 , option = $target.data('modal') ? 'toggle' : $.extend({ remote:!/#/.test(href) && href }, $target.data(), $this.data())
4277
4278 e.preventDefault()
4279
4280 $target
4281 .modal(option)
4282 .one('hide', function () {
4283 $this.focus()
4284 })
4285 })
4286
4287}(window.jQuery);
4288/* ===========================================================
4289 * bootstrap-tooltip.js v2.3.1
4290 * http://twitter.github.com/bootstrap/javascript.html#tooltips
4291 * Inspired by the original jQuery.tipsy by Jason Frame
4292 * ===========================================================
4293 * Copyright 2012 Twitter, Inc.
4294 *
4295 * Licensed under the Apache License, Version 2.0 (the "License");
4296 * you may not use this file except in compliance with the License.
4297 * You may obtain a copy of the License at
4298 *
4299 * http://www.apache.org/licenses/LICENSE-2.0
4300 *
4301 * Unless required by applicable law or agreed to in writing, software
4302 * distributed under the License is distributed on an "AS IS" BASIS,
4303 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4304 * See the License for the specific language governing permissions and
4305 * limitations under the License.
4306 * ========================================================== */
4307
4308
4309!function ($) {
4310
4311 "use strict"; // jshint ;_;
4312
4313
4314 /* TOOLTIP PUBLIC CLASS DEFINITION
4315 * =============================== */
4316
4317 var Tooltip = function (element, options) {
4318 this.init('tooltip', element, options)
4319 }
4320
4321 Tooltip.prototype = {
4322
4323 constructor: Tooltip
4324
4325 , init: function (type, element, options) {
4326 var eventIn
4327 , eventOut
4328 , triggers
4329 , trigger
4330 , i
4331
4332 this.type = type
4333 this.$element = $(element)
4334 this.options = this.getOptions(options)
4335 this.enabled = true
4336
4337 triggers = this.options.trigger.split(' ')
4338
4339 for (i = triggers.length; i--;) {
4340 trigger = triggers[i]
4341 if (trigger == 'click') {
4342 this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
4343 } else if (trigger != 'manual') {
4344 eventIn = trigger == 'hover' ? 'mouseenter' : 'focus'
4345 eventOut = trigger == 'hover' ? 'mouseleave' : 'blur'
4346 this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
4347 this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
4348 }
4349 }
4350
4351 this.options.selector ?
4352 (this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :
4353 this.fixTitle()
4354 }
4355
4356 , getOptions: function (options) {
4357 options = $.extend({}, $.fn[this.type].defaults, this.$element.data(), options)
4358
4359 if (options.delay && typeof options.delay == 'number') {
4360 options.delay = {
4361 show: options.delay
4362 , hide: options.delay
4363 }
4364 }
4365
4366 return options
4367 }
4368
4369 , enter: function (e) {
4370 var defaults = $.fn[this.type].defaults
4371 , options = {}
4372 , self
4373
4374 this._options && $.each(this._options, function (key, value) {
4375 if (defaults[key] != value) options[key] = value
4376 }, this)
4377
4378 self = $(e.currentTarget)[this.type](options).data(this.type)
4379
4380 if (!self.options.delay || !self.options.delay.show) return self.show()
4381
4382 clearTimeout(this.timeout)
4383 self.hoverState = 'in'
4384 this.timeout = setTimeout(function() {
4385 if (self.hoverState == 'in') self.show()
4386 }, self.options.delay.show)
4387 }
4388
4389 , leave: function (e) {
4390 var self = $(e.currentTarget)[this.type](this._options).data(this.type)
4391
4392 if (this.timeout) clearTimeout(this.timeout)
4393 if (!self.options.delay || !self.options.delay.hide) return self.hide()
4394
4395 self.hoverState = 'out'
4396 this.timeout = setTimeout(function() {
4397 if (self.hoverState == 'out') self.hide()
4398 }, self.options.delay.hide)
4399 }
4400
4401 , show: function () {
4402 var $tip
4403 , pos
4404 , actualWidth
4405 , actualHeight
4406 , placement
4407 , tp
4408 , e = $.Event('show')
4409
4410 if (this.hasContent() && this.enabled) {
4411 this.$element.trigger(e)
4412 if (e.isDefaultPrevented()) return
4413 $tip = this.tip()
4414 this.setContent()
4415
4416 if (this.options.animation) {
4417 $tip.addClass('fade')
4418 }
4419
4420 placement = typeof this.options.placement == 'function' ?
4421 this.options.placement.call(this, $tip[0], this.$element[0]) :
4422 this.options.placement
4423
4424 $tip
4425 .detach()
4426 .css({ top: 0, left: 0, display: 'block' })
4427
4428 this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element)
4429
4430 pos = this.getPosition()
4431
4432 actualWidth = $tip[0].offsetWidth
4433 actualHeight = $tip[0].offsetHeight
4434
4435 switch (placement) {
4436 case 'bottom':
4437 tp = {top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2}
4438 break
4439 case 'top':
4440 tp = {top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2}
4441 break
4442 case 'left':
4443 tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth}
4444 break
4445 case 'right':
4446 tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width}
4447 break
4448 }
4449
4450 this.applyPlacement(tp, placement)
4451 this.$element.trigger('shown')
4452 }
4453 }
4454
4455 , applyPlacement: function(offset, placement){
4456 var $tip = this.tip()
4457 , width = $tip[0].offsetWidth
4458 , height = $tip[0].offsetHeight
4459 , actualWidth
4460 , actualHeight
4461 , delta
4462 , replace
4463
4464 $tip
4465 .offset(offset)
4466 .addClass(placement)
4467 .addClass('in')
4468
4469 actualWidth = $tip[0].offsetWidth
4470 actualHeight = $tip[0].offsetHeight
4471
4472 if (placement == 'top' && actualHeight != height) {
4473 offset.top = offset.top + height - actualHeight
4474 replace = true
4475 }
4476
4477 if (placement == 'bottom' || placement == 'top') {
4478 delta = 0
4479
4480 if (offset.left < 0){
4481 delta = offset.left * -2
4482 offset.left = 0
4483 $tip.offset(offset)
4484 actualWidth = $tip[0].offsetWidth
4485 actualHeight = $tip[0].offsetHeight
4486 }
4487
4488 this.replaceArrow(delta - width + actualWidth, actualWidth, 'left')
4489 } else {
4490 this.replaceArrow(actualHeight - height, actualHeight, 'top')
4491 }
4492
4493 if (replace) $tip.offset(offset)
4494 }
4495
4496 , replaceArrow: function(delta, dimension, position){
4497 this
4498 .arrow()
4499 .css(position, delta ? (50 * (1 - delta / dimension) + "%") : '')
4500 }
4501
4502 , setContent: function () {
4503 var $tip = this.tip()
4504 , title = this.getTitle()
4505
4506 $tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title)
4507 $tip.removeClass('fade in top bottom left right')
4508 }
4509
4510 , hide: function () {
4511 var that = this
4512 , $tip = this.tip()
4513 , e = $.Event('hide')
4514
4515 this.$element.trigger(e)
4516 if (e.isDefaultPrevented()) return
4517
4518 $tip.removeClass('in')
4519
4520 function removeWithAnimation() {
4521 var timeout = setTimeout(function () {
4522 $tip.off($.support.transition.end).detach()
4523 }, 500)
4524
4525 $tip.one($.support.transition.end, function () {
4526 clearTimeout(timeout)
4527 $tip.detach()
4528 })
4529 }
4530
4531 $.support.transition && this.$tip.hasClass('fade') ?
4532 removeWithAnimation() :
4533 $tip.detach()
4534
4535 this.$element.trigger('hidden')
4536
4537 return this
4538 }
4539
4540 , fixTitle: function () {
4541 var $e = this.$element
4542 if ($e.attr('title') || typeof($e.attr('data-original-title')) != 'string') {
4543 $e.attr('data-original-title', $e.attr('title') || '').attr('title', '')
4544 }
4545 }
4546
4547 , hasContent: function () {
4548 return this.getTitle()
4549 }
4550
4551 , getPosition: function () {
4552 var el = this.$element[0]
4553 return $.extend({}, (typeof el.getBoundingClientRect == 'function') ? el.getBoundingClientRect() : {
4554 width: el.offsetWidth
4555 , height: el.offsetHeight
4556 }, this.$element.offset())
4557 }
4558
4559 , getTitle: function () {
4560 var title
4561 , $e = this.$element
4562 , o = this.options
4563
4564 title = $e.attr('data-original-title')
4565 || (typeof o.title == 'function' ? o.title.call($e[0]) : o.title)
4566
4567 return title
4568 }
4569
4570 , tip: function () {
4571 return this.$tip = this.$tip || $(this.options.template)
4572 }
4573
4574 , arrow: function(){
4575 return this.$arrow = this.$arrow || this.tip().find(".tooltip-arrow")
4576 }
4577
4578 , validate: function () {
4579 if (!this.$element[0].parentNode) {
4580 this.hide()
4581 this.$element = null
4582 this.options = null
4583 }
4584 }
4585
4586 , enable: function () {
4587 this.enabled = true
4588 }
4589
4590 , disable: function () {
4591 this.enabled = false
4592 }
4593
4594 , toggleEnabled: function () {
4595 this.enabled = !this.enabled
4596 }
4597
4598 , toggle: function (e) {
4599 var self = e ? $(e.currentTarget)[this.type](this._options).data(this.type) : this
4600 self.tip().hasClass('in') ? self.hide() : self.show()
4601 }
4602
4603 , destroy: function () {
4604 this.hide().$element.off('.' + this.type).removeData(this.type)
4605 }
4606
4607 }
4608
4609
4610 /* TOOLTIP PLUGIN DEFINITION
4611 * ========================= */
4612
4613 var old = $.fn.tooltip
4614
4615 $.fn.tooltip = function ( option ) {
4616 return this.each(function () {
4617 var $this = $(this)
4618 , data = $this.data('tooltip')
4619 , options = typeof option == 'object' && option
4620 if (!data) $this.data('tooltip', (data = new Tooltip(this, options)))
4621 if (typeof option == 'string') data[option]()
4622 })
4623 }
4624
4625 $.fn.tooltip.Constructor = Tooltip
4626
4627 $.fn.tooltip.defaults = {
4628 animation: true
4629 , placement: 'top'
4630 , selector: false
4631 , template: '<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'
4632 , trigger: 'hover focus'
4633 , title: ''
4634 , delay: 0
4635 , html: false
4636 , container: false
4637 }
4638
4639
4640 /* TOOLTIP NO CONFLICT
4641 * =================== */
4642
4643 $.fn.tooltip.noConflict = function () {
4644 $.fn.tooltip = old
4645 return this
4646 }
4647
4648}(window.jQuery);
4649/* ===========================================================
4650 * bootstrap-popover.js v2.3.1
4651 * http://twitter.github.com/bootstrap/javascript.html#popovers
4652 * ===========================================================
4653 * Copyright 2012 Twitter, Inc.
4654 *
4655 * Licensed under the Apache License, Version 2.0 (the "License");
4656 * you may not use this file except in compliance with the License.
4657 * You may obtain a copy of the License at
4658 *
4659 * http://www.apache.org/licenses/LICENSE-2.0
4660 *
4661 * Unless required by applicable law or agreed to in writing, software
4662 * distributed under the License is distributed on an "AS IS" BASIS,
4663 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4664 * See the License for the specific language governing permissions and
4665 * limitations under the License.
4666 * =========================================================== */
4667
4668
4669!function ($) {
4670
4671 "use strict"; // jshint ;_;
4672
4673
4674 /* POPOVER PUBLIC CLASS DEFINITION
4675 * =============================== */
4676
4677 var Popover = function (element, options) {
4678 this.init('popover', element, options)
4679 }
4680
4681
4682 /* NOTE: POPOVER EXTENDS BOOTSTRAP-TOOLTIP.js
4683 ========================================== */
4684
4685 Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype, {
4686
4687 constructor: Popover
4688
4689 , setContent: function () {
4690 var $tip = this.tip()
4691 , title = this.getTitle()
4692 , content = this.getContent()
4693
4694 $tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title)
4695 $tip.find('.popover-content')[this.options.html ? 'html' : 'text'](content)
4696
4697 $tip.removeClass('fade top bottom left right in')
4698 }
4699
4700 , hasContent: function () {
4701 return this.getTitle() || this.getContent()
4702 }
4703
4704 , getContent: function () {
4705 var content
4706 , $e = this.$element
4707 , o = this.options
4708
4709 content = (typeof o.content == 'function' ? o.content.call($e[0]) : o.content)
4710 || $e.attr('data-content')
4711
4712 return content
4713 }
4714
4715 , tip: function () {
4716 if (!this.$tip) {
4717 this.$tip = $(this.options.template)
4718 }
4719 return this.$tip
4720 }
4721
4722 , destroy: function () {
4723 this.hide().$element.off('.' + this.type).removeData(this.type)
4724 }
4725
4726 })
4727
4728
4729 /* POPOVER PLUGIN DEFINITION
4730 * ======================= */
4731
4732 var old = $.fn.popover
4733
4734 $.fn.popover = function (option) {
4735 return this.each(function () {
4736 var $this = $(this)
4737 , data = $this.data('popover')
4738 , options = typeof option == 'object' && option
4739 if (!data) $this.data('popover', (data = new Popover(this, options)))
4740 if (typeof option == 'string') data[option]()
4741 })
4742 }
4743
4744 $.fn.popover.Constructor = Popover
4745
4746 $.fn.popover.defaults = $.extend({} , $.fn.tooltip.defaults, {
4747 placement: 'right'
4748 , trigger: 'click'
4749 , content: ''
4750 , template: '<div class="popover"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'
4751 })
4752
4753
4754 /* POPOVER NO CONFLICT
4755 * =================== */
4756
4757 $.fn.popover.noConflict = function () {
4758 $.fn.popover = old
4759 return this
4760 }
4761
4762}(window.jQuery);
4763/* =============================================================
4764 * bootstrap-scrollspy.js v2.3.1
4765 * http://twitter.github.com/bootstrap/javascript.html#scrollspy
4766 * =============================================================
4767 * Copyright 2012 Twitter, Inc.
4768 *
4769 * Licensed under the Apache License, Version 2.0 (the "License");
4770 * you may not use this file except in compliance with the License.
4771 * You may obtain a copy of the License at
4772 *
4773 * http://www.apache.org/licenses/LICENSE-2.0
4774 *
4775 * Unless required by applicable law or agreed to in writing, software
4776 * distributed under the License is distributed on an "AS IS" BASIS,
4777 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4778 * See the License for the specific language governing permissions and
4779 * limitations under the License.
4780 * ============================================================== */
4781
4782
4783!function ($) {
4784
4785 "use strict"; // jshint ;_;
4786
4787
4788 /* SCROLLSPY CLASS DEFINITION
4789 * ========================== */
4790
4791 function ScrollSpy(element, options) {
4792 var process = $.proxy(this.process, this)
4793 , $element = $(element).is('body') ? $(window) : $(element)
4794 , href
4795 this.options = $.extend({}, $.fn.scrollspy.defaults, options)
4796 this.$scrollElement = $element.on('scroll.scroll-spy.data-api', process)
4797 this.selector = (this.options.target
4798 || ((href = $(element).attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
4799 || '') + ' .nav li > a'
4800 this.$body = $('body')
4801 this.refresh()
4802 this.process()
4803 }
4804
4805 ScrollSpy.prototype = {
4806
4807 constructor: ScrollSpy
4808
4809 , refresh: function () {
4810 var self = this
4811 , $targets
4812
4813 this.offsets = $([])
4814 this.targets = $([])
4815
4816 $targets = this.$body
4817 .find(this.selector)
4818 .map(function () {
4819 var $el = $(this)
4820 , href = $el.data('target') || $el.attr('href')
4821 , $href = /^#\w/.test(href) && $(href)
4822 return ( $href
4823 && $href.length
4824 && [[ $href.position().top + (!$.isWindow(self.$scrollElement.get(0)) && self.$scrollElement.scrollTop()), href ]] ) || null
4825 })
4826 .sort(function (a, b) { return a[0] - b[0] })
4827 .each(function () {
4828 self.offsets.push(this[0])
4829 self.targets.push(this[1])
4830 })
4831 }
4832
4833 , process: function () {
4834 var scrollTop = this.$scrollElement.scrollTop() + this.options.offset
4835 , scrollHeight = this.$scrollElement[0].scrollHeight || this.$body[0].scrollHeight
4836 , maxScroll = scrollHeight - this.$scrollElement.height()
4837 , offsets = this.offsets
4838 , targets = this.targets
4839 , activeTarget = this.activeTarget
4840 , i
4841
4842 if (scrollTop >= maxScroll) {
4843 return activeTarget != (i = targets.last()[0])
4844 && this.activate ( i )
4845 }
4846
4847 for (i = offsets.length; i--;) {
4848 activeTarget != targets[i]
4849 && scrollTop >= offsets[i]
4850 && (!offsets[i + 1] || scrollTop <= offsets[i + 1])
4851 && this.activate( targets[i] )
4852 }
4853 }
4854
4855 , activate: function (target) {
4856 var active
4857 , selector
4858
4859 this.activeTarget = target
4860
4861 $(this.selector)
4862 .parent('.active')
4863 .removeClass('active')
4864
4865 selector = this.selector
4866 + '[data-target="' + target + '"],'
4867 + this.selector + '[href="' + target + '"]'
4868
4869 active = $(selector)
4870 .parent('li')
4871 .addClass('active')
4872
4873 if (active.parent('.dropdown-menu').length) {
4874 active = active.closest('li.dropdown').addClass('active')
4875 }
4876
4877 active.trigger('activate')
4878 }
4879
4880 }
4881
4882
4883 /* SCROLLSPY PLUGIN DEFINITION
4884 * =========================== */
4885
4886 var old = $.fn.scrollspy
4887
4888 $.fn.scrollspy = function (option) {
4889 return this.each(function () {
4890 var $this = $(this)
4891 , data = $this.data('scrollspy')
4892 , options = typeof option == 'object' && option
4893 if (!data) $this.data('scrollspy', (data = new ScrollSpy(this, options)))
4894 if (typeof option == 'string') data[option]()
4895 })
4896 }
4897
4898 $.fn.scrollspy.Constructor = ScrollSpy
4899
4900 $.fn.scrollspy.defaults = {
4901 offset: 10
4902 }
4903
4904
4905 /* SCROLLSPY NO CONFLICT
4906 * ===================== */
4907
4908 $.fn.scrollspy.noConflict = function () {
4909 $.fn.scrollspy = old
4910 return this
4911 }
4912
4913
4914 /* SCROLLSPY DATA-API
4915 * ================== */
4916
4917 $(window).on('load', function () {
4918 $('[data-spy="scroll"]').each(function () {
4919 var $spy = $(this)
4920 $spy.scrollspy($spy.data())
4921 })
4922 })
4923
4924}(window.jQuery);/* ========================================================
4925 * bootstrap-tab.js v2.3.1
4926 * http://twitter.github.com/bootstrap/javascript.html#tabs
4927 * ========================================================
4928 * Copyright 2012 Twitter, Inc.
4929 *
4930 * Licensed under the Apache License, Version 2.0 (the "License");
4931 * you may not use this file except in compliance with the License.
4932 * You may obtain a copy of the License at
4933 *
4934 * http://www.apache.org/licenses/LICENSE-2.0
4935 *
4936 * Unless required by applicable law or agreed to in writing, software
4937 * distributed under the License is distributed on an "AS IS" BASIS,
4938 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4939 * See the License for the specific language governing permissions and
4940 * limitations under the License.
4941 * ======================================================== */
4942
4943
4944!function ($) {
4945
4946 "use strict"; // jshint ;_;
4947
4948
4949 /* TAB CLASS DEFINITION
4950 * ==================== */
4951
4952 var Tab = function (element) {
4953 this.element = $(element)
4954 }
4955
4956 Tab.prototype = {
4957
4958 constructor: Tab
4959
4960 , show: function () {
4961 var $this = this.element
4962 , $ul = $this.closest('ul:not(.dropdown-menu)')
4963 , selector = $this.attr('data-target')
4964 , previous
4965 , $target
4966 , e
4967
4968 if (!selector) {
4969 selector = $this.attr('href')
4970 selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
4971 }
4972
4973 if ( $this.parent('li').hasClass('active') ) return
4974
4975 previous = $ul.find('.active:last a')[0]
4976
4977 e = $.Event('show', {
4978 relatedTarget: previous
4979 })
4980
4981 $this.trigger(e)
4982
4983 if (e.isDefaultPrevented()) return
4984
4985 $target = $(selector)
4986
4987 this.activate($this.parent('li'), $ul)
4988 this.activate($target, $target.parent(), function () {
4989 $this.trigger({
4990 type: 'shown'
4991 , relatedTarget: previous
4992 })
4993 })
4994 }
4995
4996 , activate: function ( element, container, callback) {
4997 var $active = container.find('> .active')
4998 , transition = callback
4999 && $.support.transition
5000 && $active.hasClass('fade')
5001
5002 function next() {
5003 $active
5004 .removeClass('active')
5005 .find('> .dropdown-menu > .active')
5006 .removeClass('active')
5007
5008 element.addClass('active')
5009
5010 if (transition) {
5011 element[0].offsetWidth // reflow for transition
5012 element.addClass('in')
5013 } else {
5014 element.removeClass('fade')
5015 }
5016
5017 if ( element.parent('.dropdown-menu') ) {
5018 element.closest('li.dropdown').addClass('active')
5019 }
5020
5021 callback && callback()
5022 }
5023
5024 transition ?
5025 $active.one($.support.transition.end, next) :
5026 next()
5027
5028 $active.removeClass('in')
5029 }
5030 }
5031
5032
5033 /* TAB PLUGIN DEFINITION
5034 * ===================== */
5035
5036 var old = $.fn.tab
5037
5038 $.fn.tab = function ( option ) {
5039 return this.each(function () {
5040 var $this = $(this)
5041 , data = $this.data('tab')
5042 if (!data) $this.data('tab', (data = new Tab(this)))
5043 if (typeof option == 'string') data[option]()
5044 })
5045 }
5046
5047 $.fn.tab.Constructor = Tab
5048
5049
5050 /* TAB NO CONFLICT
5051 * =============== */
5052
5053 $.fn.tab.noConflict = function () {
5054 $.fn.tab = old
5055 return this
5056 }
5057
5058
5059 /* TAB DATA-API
5060 * ============ */
5061
5062 $(document).on('click.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
5063 e.preventDefault()
5064 $(this).tab('show')
5065 })
5066
5067}(window.jQuery);/* =============================================================
5068 * bootstrap-typeahead.js v2.3.1
5069 * http://twitter.github.com/bootstrap/javascript.html#typeahead
5070 * =============================================================
5071 * Copyright 2012 Twitter, Inc.
5072 *
5073 * Licensed under the Apache License, Version 2.0 (the "License");
5074 * you may not use this file except in compliance with the License.
5075 * You may obtain a copy of the License at
5076 *
5077 * http://www.apache.org/licenses/LICENSE-2.0
5078 *
5079 * Unless required by applicable law or agreed to in writing, software
5080 * distributed under the License is distributed on an "AS IS" BASIS,
5081 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5082 * See the License for the specific language governing permissions and
5083 * limitations under the License.
5084 * ============================================================ */
5085
5086
5087!function($){
5088
5089 "use strict"; // jshint ;_;
5090
5091
5092 /* TYPEAHEAD PUBLIC CLASS DEFINITION
5093 * ================================= */
5094
5095 var Typeahead = function (element, options) {
5096 this.$element = $(element)
5097 this.options = $.extend({}, $.fn.typeahead.defaults, options)
5098 this.matcher = this.options.matcher || this.matcher
5099 this.sorter = this.options.sorter || this.sorter
5100 this.highlighter = this.options.highlighter || this.highlighter
5101 this.updater = this.options.updater || this.updater
5102 this.source = this.options.source
5103 this.$menu = $(this.options.menu)
5104 this.shown = false
5105 this.listen()
5106 }
5107
5108 Typeahead.prototype = {
5109
5110 constructor: Typeahead
5111
5112 , select: function () {
5113 var val = this.$menu.find('.active').attr('data-value')
5114 this.$element
5115 .val(this.updater(val))
5116 .change()
5117 return this.hide()
5118 }
5119
5120 , updater: function (item) {
5121 return item
5122 }
5123
5124 , show: function () {
5125 var pos = $.extend({}, this.$element.position(), {
5126 height: this.$element[0].offsetHeight
5127 })
5128
5129 this.$menu
5130 .insertAfter(this.$element)
5131 .css({
5132 top: pos.top + pos.height
5133 , left: pos.left
5134 })
5135 .show()
5136
5137 this.shown = true
5138 return this
5139 }
5140
5141 , hide: function () {
5142 this.$menu.hide()
5143 this.shown = false
5144 return this
5145 }
5146
5147 , lookup: function (event) {
5148 var items
5149
5150 this.query = this.$element.val()
5151
5152 if (!this.query || this.query.length < this.options.minLength) {
5153 return this.shown ? this.hide() : this
5154 }
5155
5156 items = $.isFunction(this.source) ? this.source(this.query, $.proxy(this.process, this)) : this.source
5157
5158 return items ? this.process(items) : this
5159 }
5160
5161 , process: function (items) {
5162 var that = this
5163
5164 items = $.grep(items, function (item) {
5165 return that.matcher(item)
5166 })
5167
5168 items = this.sorter(items)
5169
5170 if (!items.length) {
5171 return this.shown ? this.hide() : this
5172 }
5173
5174 return this.render(items.slice(0, this.options.items)).show()
5175 }
5176
5177 , matcher: function (item) {
5178 return ~item.toLowerCase().indexOf(this.query.toLowerCase())
5179 }
5180
5181 , sorter: function (items) {
5182 var beginswith = []
5183 , caseSensitive = []
5184 , caseInsensitive = []
5185 , item
5186
5187 while (item = items.shift()) {
5188 if (!item.toLowerCase().indexOf(this.query.toLowerCase())) beginswith.push(item)
5189 else if (~item.indexOf(this.query)) caseSensitive.push(item)
5190 else caseInsensitive.push(item)
5191 }
5192
5193 return beginswith.concat(caseSensitive, caseInsensitive)
5194 }
5195
5196 , highlighter: function (item) {
5197 var query = this.query.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, '\\$&')
5198 return item.replace(new RegExp('(' + query + ')', 'ig'), function ($1, match) {
5199 return '<strong>' + match + '</strong>'
5200 })
5201 }
5202
5203 , render: function (items) {
5204 var that = this
5205
5206 items = $(items).map(function (i, item) {
5207 i = $(that.options.item).attr('data-value', item)
5208 i.find('a').html(that.highlighter(item))
5209 return i[0]
5210 })
5211
5212 items.first().addClass('active')
5213 this.$menu.html(items)
5214 return this
5215 }
5216
5217 , next: function (event) {
5218 var active = this.$menu.find('.active').removeClass('active')
5219 , next = active.next()
5220
5221 if (!next.length) {
5222 next = $(this.$menu.find('li')[0])
5223 }
5224
5225 next.addClass('active')
5226 }
5227
5228 , prev: function (event) {
5229 var active = this.$menu.find('.active').removeClass('active')
5230 , prev = active.prev()
5231
5232 if (!prev.length) {
5233 prev = this.$menu.find('li').last()
5234 }
5235
5236 prev.addClass('active')
5237 }
5238
5239 , listen: function () {
5240 this.$element
5241 .on('focus', $.proxy(this.focus, this))
5242 .on('blur', $.proxy(this.blur, this))
5243 .on('keypress', $.proxy(this.keypress, this))
5244 .on('keyup', $.proxy(this.keyup, this))
5245
5246 if (this.eventSupported('keydown')) {
5247 this.$element.on('keydown', $.proxy(this.keydown, this))
5248 }
5249
5250 this.$menu
5251 .on('click', $.proxy(this.click, this))
5252 .on('mouseenter', 'li', $.proxy(this.mouseenter, this))
5253 .on('mouseleave', 'li', $.proxy(this.mouseleave, this))
5254 }
5255
5256 , eventSupported: function(eventName) {
5257 var isSupported = eventName in this.$element
5258 if (!isSupported) {
5259 this.$element.setAttribute(eventName, 'return;')
5260 isSupported = typeof this.$element[eventName] === 'function'
5261 }
5262 return isSupported
5263 }
5264
5265 , move: function (e) {
5266 if (!this.shown) return
5267
5268 switch(e.keyCode) {
5269 case 9: // tab
5270 case 13: // enter
5271 case 27: // escape
5272 e.preventDefault()
5273 break
5274
5275 case 38: // up arrow
5276 e.preventDefault()
5277 this.prev()
5278 break
5279
5280 case 40: // down arrow
5281 e.preventDefault()
5282 this.next()
5283 break
5284 }
5285
5286 e.stopPropagation()
5287 }
5288
5289 , keydown: function (e) {
5290 this.suppressKeyPressRepeat = ~$.inArray(e.keyCode, [40,38,9,13,27])
5291 this.move(e)
5292 }
5293
5294 , keypress: function (e) {
5295 if (this.suppressKeyPressRepeat) return
5296 this.move(e)
5297 }
5298
5299 , keyup: function (e) {
5300 switch(e.keyCode) {
5301 case 40: // down arrow
5302 case 38: // up arrow
5303 case 16: // shift
5304 case 17: // ctrl
5305 case 18: // alt
5306 break
5307
5308 case 9: // tab
5309 case 13: // enter
5310 if (!this.shown) return
5311 this.select()
5312 break
5313
5314 case 27: // escape
5315 if (!this.shown) return
5316 this.hide()
5317 break
5318
5319 default:
5320 this.lookup()
5321 }
5322
5323 e.stopPropagation()
5324 e.preventDefault()
5325 }
5326
5327 , focus: function (e) {
5328 this.focused = true
5329 }
5330
5331 , blur: function (e) {
5332 this.focused = false
5333 if (!this.mousedover && this.shown) this.hide()
5334 }
5335
5336 , click: function (e) {
5337 e.stopPropagation()
5338 e.preventDefault()
5339 this.select()
5340 this.$element.focus()
5341 }
5342
5343 , mouseenter: function (e) {
5344 this.mousedover = true
5345 this.$menu.find('.active').removeClass('active')
5346 $(e.currentTarget).addClass('active')
5347 }
5348
5349 , mouseleave: function (e) {
5350 this.mousedover = false
5351 if (!this.focused && this.shown) this.hide()
5352 }
5353
5354 }
5355
5356
5357 /* TYPEAHEAD PLUGIN DEFINITION
5358 * =========================== */
5359
5360 var old = $.fn.typeahead
5361
5362 $.fn.typeahead = function (option) {
5363 return this.each(function () {
5364 var $this = $(this)
5365 , data = $this.data('typeahead')
5366 , options = typeof option == 'object' && option
5367 if (!data) $this.data('typeahead', (data = new Typeahead(this, options)))
5368 if (typeof option == 'string') data[option]()
5369 })
5370 }
5371
5372 $.fn.typeahead.defaults = {
5373 source: []
5374 , items: 8
5375 , menu: '<ul class="typeahead dropdown-menu"></ul>'
5376 , item: '<li><a href="#"></a></li>'
5377 , minLength: 1
5378 }
5379
5380 $.fn.typeahead.Constructor = Typeahead
5381
5382
5383 /* TYPEAHEAD NO CONFLICT
5384 * =================== */
5385
5386 $.fn.typeahead.noConflict = function () {
5387 $.fn.typeahead = old
5388 return this
5389 }
5390
5391
5392 /* TYPEAHEAD DATA-API
5393 * ================== */
5394
5395 $(document).on('focus.typeahead.data-api', '[data-provide="typeahead"]', function (e) {
5396 var $this = $(this)
5397 if ($this.data('typeahead')) return
5398 $this.typeahead($this.data())
5399 })
5400
5401}(window.jQuery);
5402/* ==========================================================
5403 * bootstrap-affix.js v2.3.1
5404 * http://twitter.github.com/bootstrap/javascript.html#affix
5405 * ==========================================================
5406 * Copyright 2012 Twitter, Inc.
5407 *
5408 * Licensed under the Apache License, Version 2.0 (the "License");
5409 * you may not use this file except in compliance with the License.
5410 * You may obtain a copy of the License at
5411 *
5412 * http://www.apache.org/licenses/LICENSE-2.0
5413 *
5414 * Unless required by applicable law or agreed to in writing, software
5415 * distributed under the License is distributed on an "AS IS" BASIS,
5416 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5417 * See the License for the specific language governing permissions and
5418 * limitations under the License.
5419 * ========================================================== */
5420
5421
5422!function ($) {
5423
5424 "use strict"; // jshint ;_;
5425
5426
5427 /* AFFIX CLASS DEFINITION
5428 * ====================== */
5429
5430 var Affix = function (element, options) {
5431 this.options = $.extend({}, $.fn.affix.defaults, options)
5432 this.$window = $(window)
5433 .on('scroll.affix.data-api', $.proxy(this.checkPosition, this))
5434 .on('click.affix.data-api', $.proxy(function () { setTimeout($.proxy(this.checkPosition, this), 1) }, this))
5435 this.$element = $(element)
5436 this.checkPosition()
5437 }
5438
5439 Affix.prototype.checkPosition = function () {
5440 if (!this.$element.is(':visible')) return
5441
5442 var scrollHeight = $(document).height()
5443 , scrollTop = this.$window.scrollTop()
5444 , position = this.$element.offset()
5445 , offset = this.options.offset
5446 , offsetBottom = offset.bottom
5447 , offsetTop = offset.top
5448 , reset = 'affix affix-top affix-bottom'
5449 , affix
5450
5451 if (typeof offset != 'object') offsetBottom = offsetTop = offset
5452 if (typeof offsetTop == 'function') offsetTop = offset.top()
5453 if (typeof offsetBottom == 'function') offsetBottom = offset.bottom()
5454
5455 affix = this.unpin != null && (scrollTop + this.unpin <= position.top) ?
5456 false : offsetBottom != null && (position.top + this.$element.height() >= scrollHeight - offsetBottom) ?
5457 'bottom' : offsetTop != null && scrollTop <= offsetTop ?
5458 'top' : false
5459
5460 if (this.affixed === affix) return
5461
5462 this.affixed = affix
5463 this.unpin = affix == 'bottom' ? position.top - scrollTop : null
5464
5465 this.$element.removeClass(reset).addClass('affix' + (affix ? '-' + affix : ''))
5466 }
5467
5468
5469 /* AFFIX PLUGIN DEFINITION
5470 * ======================= */
5471
5472 var old = $.fn.affix
5473
5474 $.fn.affix = function (option) {
5475 return this.each(function () {
5476 var $this = $(this)
5477 , data = $this.data('affix')
5478 , options = typeof option == 'object' && option
5479 if (!data) $this.data('affix', (data = new Affix(this, options)))
5480 if (typeof option == 'string') data[option]()
5481 })
5482 }
5483
5484 $.fn.affix.Constructor = Affix
5485
5486 $.fn.affix.defaults = {
5487 offset: 0
5488 }
5489
5490
5491 /* AFFIX NO CONFLICT
5492 * ================= */
5493
5494 $.fn.affix.noConflict = function () {
5495 $.fn.affix = old
5496 return this
5497 }
5498
5499
5500 /* AFFIX DATA-API
5501 * ============== */
5502
5503 $(window).on('load', function () {
5504 $('[data-spy="affix"]').each(function () {
5505 var $spy = $(this)
5506 , data = $spy.data()
5507
5508 data.offset = data.offset || {}
5509
5510 data.offsetBottom && (data.offset.bottom = data.offsetBottom)
5511 data.offsetTop && (data.offset.top = data.offsetTop)
5512
5513 $spy.affix(data)
5514 })
5515 })
5516
5517
5518}(window.jQuery);(function() {
5519 var urlRegex = /(http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
5520
5521 function isCurie(string) {
5522 return string.split(':').length > 1;
5523 };
5524
5525 var HAL = {
5526 Models: {},
5527 Views: {},
5528 Http: {},
5529 currentDocument: {},
5530 jsonIndent: 2,
5531 isUrl: function(str) {
5532 return str.match(urlRegex) || isCurie(str);
5533 },
5534 isFollowableHeader: function(headerName) {
5535 return headerName === 'Location' || headerName === 'Content-Location';
5536 },
5537 truncateIfUrl: function(str) {
5538 var replaceRegex = /(http|https):\/\/([^\/]*)\//;
5539 return str.replace(replaceRegex, '.../');
5540 },
5541 normalizeUrl: function(rel) {
5542 var cur = location.hash.slice(1);
5543 var uri = new URI(rel)
5544 var norm = uri.absoluteTo(cur);
5545
5546 return norm
5547 },
5548 buildUrl: function(rel) {
5549 if (!HAL.currentDocument._links) {
5550 return rel;
5551 }
5552 if (!rel.match(urlRegex) && isCurie(rel) && HAL.currentDocument._links.curies) {
5553 var parts = rel.split(':');
5554 var curies = HAL.currentDocument._links.curies;
5555 for (var i=0; i<curies.length; i++) {
5556 if (curies[i].name == parts[0]) {
5557 var tmpl = uritemplate(curies[i].href);
5558 return tmpl.expand({ rel: parts[1] });
5559 }
5560 }
5561 }
5562 else if (!rel.match(urlRegex) && isCurie(rel) && HAL.currentDocument._links.curie) {
5563 // Backward compatibility with <04 version of spec.
5564 var tmpl = uritemplate(HAL.currentDocument._links.curie.href);
5565 return tmpl.expand({ rel: rel.split(':')[1] });
5566 }
5567 else {
5568 return rel;
5569 }
5570 },
5571 parseHeaders: function(string) {
5572 var header_lines = string.split("\n");
5573 var headers = {};
5574 _.each(header_lines, function(line) {
5575 var parts = line.split(':');
5576 if (parts.length > 1) {
5577 var name = parts.shift().trim();
5578 var value = parts.join(':').trim();
5579 headers[name] = value;
5580 }
5581 });
5582 return headers;
5583 },
5584 customPostForm: undefined
5585 };
5586
5587 window.HAL = HAL;
5588})();
5589HAL.Browser = Backbone.Router.extend({
5590 initialize: function(opts) {
5591 opts = opts || {};
5592
5593 var vent = _.extend({}, Backbone.Events),
5594 $container = opts.container || $('#browser');
5595
5596 this.entryPoint = opts.entryPoint || '/';
5597
5598 // TODO: don't hang currentDoc off namespace
5599 vent.bind('response', function(e) {
5600 window.HAL.currentDocument = e.resource || {};
5601 });
5602
5603 vent.bind('location-go', _.bind(this.loadUrl, this));
5604
5605 HAL.client = new HAL.Http.Client({ vent: vent });
5606
5607 var browser = new HAL.Views.Browser({ vent: vent, entryPoint: this.entryPoint });
5608 browser.render()
5609
5610 $container.html(browser.el);
5611 vent.trigger('app:loaded');
5612
5613 if (window.location.hash === '') {
5614 window.location.hash = this.entryPoint;
5615 }
5616
5617 if(location.hash.slice(1,9) === 'NON-GET:') {
5618 new HAL.Views.NonSafeRequestDialog({
5619 href: location.hash.slice(9),
5620 vent: vent
5621 }).render({});
5622 }
5623 },
5624
5625 routes: {
5626 '*url': 'resourceRoute'
5627 },
5628
5629 loadUrl: function(url) {
5630 if (this.getHash() === url) {
5631 HAL.client.get(url);
5632 } else {
5633 window.location.hash = url;
5634 }
5635 },
5636
5637 getHash: function() {
5638 return window.location.hash.slice(1);
5639 },
5640
5641 resourceRoute: function() {
5642 url = location.hash.slice(1);
5643 console.log('target url changed to: ' + url);
5644 if (url.slice(0,8) !== 'NON-GET:') {
5645 HAL.client.get(url);
5646 }
5647 }
5648});
5649HAL.Http.Client = function(opts) {
5650 this.vent = opts.vent;
5651 this.defaultHeaders = { 'Accept': 'application/hal+json, application/json, */*; q=0.01' };
5652 this.headers = this.defaultHeaders;
5653};
5654
5655HAL.Http.Client.prototype.get = function(url) {
5656 var self = this;
5657 this.vent.trigger('location-change', { url: url });
5658 var jqxhr = $.ajax({
5659 url: url,
5660 dataType: 'json',
5661 xhrFields: {
5662 withCredentials: true
5663 },
5664 headers: this.headers,
5665 success: function(resource, textStatus, jqXHR) {
5666 self.vent.trigger('response', {
5667 resource: resource,
5668 jqxhr: jqXHR,
5669 headers: jqXHR.getAllResponseHeaders()
5670 });
5671 }
5672 }).error(function() {
5673 self.vent.trigger('fail-response', { jqxhr: jqxhr });
5674 });
5675};
5676
5677HAL.Http.Client.prototype.request = function(opts) {
5678 var self = this;
5679 opts.dataType = 'json';
5680 opts.xhrFields = opts.xhrFields || {};
5681 opts.xhrFields.withCredentials = opts.xhrFields.withCredentials || true;
5682
5683 var jwt;
5684 if (localStorage.token) {
5685 jwt = JSON.parse(localStorage.token);
5686 } else if (sessionStorage.token) {
5687 jwt = JSON.parse(sessionStorage.token);
5688 }
5689 if (jwt)Â {
5690 opts.headers = {
5691 Authorization: jwt.token_type + ' ' + jwt.access_token
5692 }
5693 }
5694
5695 self.vent.trigger('location-change', { url: opts.url });
5696 return jqxhr = $.ajax(opts);
5697};
5698
5699HAL.Http.Client.prototype.updateHeaders = function(headers) {
5700 this.headers = headers;
5701};
5702
5703HAL.Http.Client.prototype.getHeaders = function() {
5704 return this.headers;
5705};
5706HAL.Models.Resource = Backbone.Model.extend({
5707 initialize: function(representation) {
5708 representation = representation || {};
5709 this.links = representation._links;
5710 this.title = representation.title;
5711 if(representation._embedded !== undefined) {
5712 this.embeddedResources = this.buildEmbeddedResources(representation._embedded);
5713 }
5714 this.set(representation);
5715 this.unset('_embedded', { silent: true });
5716 this.unset('_links', { silent: true });
5717 },
5718
5719 buildEmbeddedResources: function(embeddedResources) {
5720 var result = {};
5721 _.each(embeddedResources, function(obj, rel) {
5722 if($.isArray(obj)) {
5723 var arr = [];
5724 _.each(obj, function(resource, i) {
5725 var newResource = new HAL.Models.Resource(resource);
5726 newResource.identifier = rel + '[' + i + ']';
5727 newResource.embed_rel = rel;
5728 arr.push(newResource);
5729 });
5730 result[rel] = arr;
5731 } else {
5732 var newResource = new HAL.Models.Resource(obj);
5733 newResource.identifier = rel;
5734 newResource.embed_rel = rel;
5735 result[rel] = newResource;
5736 }
5737 });
5738 return result;
5739 }
5740});
5741HAL.Views.Browser = Backbone.View.extend({
5742 initialize: function(opts) {
5743 var self = this;
5744 this.vent = opts.vent;
5745 this.entryPoint = opts.entryPoint;
5746 this.explorerView = new HAL.Views.Explorer({ vent: this.vent });
5747 this.inspectorView = new HAL.Views.Inspector({ vent: this.vent });
5748 },
5749
5750 className: 'hal-browser row-fluid',
5751
5752 render: function() {
5753 this.$el.empty();
5754
5755 this.inspectorView.render();
5756 this.explorerView.render();
5757
5758 this.$el.html(this.explorerView.el);
5759 this.$el.append(this.inspectorView.el);
5760
5761 var entryPoint = this.entryPoint;
5762
5763 $("#entryPointLink").click(function(event) {
5764 event.preventDefault();
5765 window.location.hash = entryPoint;
5766 });
5767 return this;
5768 }
5769});
5770HAL.Views.Explorer = Backbone.View.extend({
5771 initialize: function(opts) {
5772 var self = this;
5773 this.vent = opts.vent;
5774 this.navigationView = new HAL.Views.Navigation({ vent: this.vent });
5775 this.resourceView = new HAL.Views.Resource({ vent: this.vent });
5776 },
5777
5778 className: 'explorer span6',
5779
5780 render: function() {
5781 this.navigationView.render();
5782
5783 this.$el.html(this.template());
5784
5785 this.$el.append(this.navigationView.el);
5786 this.$el.append(this.resourceView.el);
5787 },
5788
5789 template: function() {
5790 return '<h1>Explorer</h1>';
5791 }
5792});
5793HAL.Views.Inspector = Backbone.View.extend({
5794 initialize: function(opts) {
5795 this.vent = opts.vent;
5796
5797 _.bindAll(this, 'renderDocumentation');
5798 _.bindAll(this, 'renderResponse');
5799
5800 this.vent.bind('show-docs', this.renderDocumentation);
5801 this.vent.bind('response', this.renderResponse);
5802 },
5803
5804 className: 'inspector span6',
5805
5806 render: function() {
5807 this.$el.html(this.template());
5808 },
5809
5810 renderResponse: function(response) {
5811 var responseView = new HAL.Views.Response({ vent: this.vent });
5812
5813 this.render();
5814 responseView.render(response);
5815
5816 this.$el.append(responseView.el);
5817 },
5818
5819 renderDocumentation: function(e) {
5820 var docView = new HAL.Views.Documenation({ vent: this.vent });
5821
5822 this.render();
5823 docView.render(e.url);
5824
5825 this.$el.append(docView.el);
5826 },
5827
5828 template: function() {
5829 return '<h1>Inspector</h1>';
5830 }
5831});
5832HAL.Views.Navigation = Backbone.View.extend({
5833 initialize: function(opts) {
5834 this.vent = opts.vent;
5835 this.locationBar = new HAL.Views.LocationBar({ vent: this.vent });
5836 this.requestHeadersView = new HAL.Views.RequestHeaders({ vent: this.vent });
5837 },
5838
5839 className: 'navigation',
5840
5841 render: function() {
5842 this.$el.empty();
5843
5844 this.locationBar.render();
5845 this.requestHeadersView.render();
5846
5847 this.$el.append(this.locationBar.el);
5848 this.$el.append(this.requestHeadersView.el);
5849 }
5850});
5851HAL.Views.LocationBar = Backbone.View.extend({
5852 initialize: function(opts) {
5853 this.vent = opts.vent;
5854 _.bindAll(this, 'render');
5855 _.bindAll(this, 'onButtonClick');
5856 this.vent.bind('location-change', this.render);
5857 this.vent.bind('location-change', _.bind(this.showSpinner, this));
5858 this.vent.bind('response', _.bind(this.hideSpinner, this));
5859 },
5860
5861 events: {
5862 'submit form': 'onButtonClick'
5863 },
5864
5865 className: 'address',
5866
5867 render: function(e) {
5868 e = e || { url: '' };
5869 this.$el.html(this.template(e));
5870 },
5871
5872 onButtonClick: function(e) {
5873 e.preventDefault();
5874 this.vent.trigger('location-go', this.getLocation());
5875 },
5876
5877 getLocation: function() {
5878 return this.$el.find('input').val();
5879 },
5880
5881 showSpinner: function() {
5882 this.$el.find('.ajax-loader').addClass('visible');
5883 },
5884
5885 hideSpinner: function() {
5886 this.$el.find('.ajax-loader').removeClass('visible');
5887 },
5888
5889 template: _.template($('#location-bar-template').html())
5890});
5891HAL.Views.RequestHeaders = Backbone.View.extend({
5892 initialize: function(opts) {
5893 var self = this;
5894 this.vent = opts.vent;
5895
5896 _.bindAll(this, 'updateRequestHeaders');
5897
5898 this.vent.bind('app:loaded', function() {
5899 self.updateRequestHeaders();
5900 });
5901 },
5902
5903 className: 'request-headers',
5904
5905 events: {
5906 'blur textarea': 'updateRequestHeaders'
5907 },
5908
5909 updateRequestHeaders: function(e) {
5910 var inputText = this.$('textarea').val() || '';
5911 headers = HAL.parseHeaders(inputText);
5912 HAL.client.updateHeaders(_.defaults(headers, HAL.client.defaultHeaders))
5913 },
5914
5915 render: function() {
5916 this.$el.html(this.template());
5917 },
5918
5919 template: _.template($('#request-headers-template').html())
5920});
5921HAL.Views.Resource = Backbone.View.extend({
5922 initialize: function(opts) {
5923 var self = this;
5924
5925 this.vent = opts.vent;
5926
5927 this.vent.bind('response', function(e) {
5928 self.render(new HAL.Models.Resource(e.resource));
5929 });
5930
5931 this.vent.bind('fail-response', function(e) {
5932 try {
5933 resource = JSON.parse(e.jqxhr.responseText);
5934 } catch(err) {
5935 resource = null;
5936 }
5937 self.vent.trigger('response', { resource: resource, jqxhr: e.jqxhr });
5938 });
5939 },
5940
5941 className: 'resource',
5942
5943 render: function(resource) {
5944 var linksView = new HAL.Views.Links({ vent: this.vent }),
5945 propertiesView = new HAL.Views.Properties({ vent: this.vent }),
5946 embeddedResourcesView
5947
5948 propertiesView.render(resource.toJSON());
5949 linksView.render(resource.links);
5950
5951 this.$el.empty();
5952 this.$el.append(propertiesView.el);
5953 this.$el.append(linksView.el);
5954
5955 if (resource.embeddedResources) {
5956 embeddedResourcesView = new HAL.Views.EmbeddedResources({ vent: this.vent });
5957 embeddedResourcesView.render(resource.embeddedResources);
5958 this.$el.append(embeddedResourcesView.el);
5959 }
5960
5961 return this;
5962 }
5963});
5964HAL.Views.Properties = Backbone.View.extend({
5965 initialize: function(opts) {
5966 this.vent = opts.vent;
5967 _.bindAll(this, 'render');
5968 },
5969
5970 className: 'properties',
5971
5972 render: function(props) {
5973 this.$el.html(this.template({ properties: props }));
5974 },
5975
5976 template: _.template($('#properties-template').html())
5977});
5978HAL.Views.Links = Backbone.View.extend({
5979 initialize: function(opts) {
5980 this.vent = opts.vent;
5981 },
5982
5983 events: {
5984 'click .follow': 'followLink',
5985 'click .non-get': 'showNonSafeRequestDialog',
5986 'click .query': 'showUriQueryDialog',
5987 'click .dox': 'showDocs'
5988 },
5989
5990 className: 'links',
5991
5992 followLink: function(e) {
5993 e.preventDefault();
5994 var $target = $(e.currentTarget);
5995 var uri = $target.attr('href');
5996 window.location.hash = uri;
5997 },
5998
5999 showUriQueryDialog: function(e) {
6000 e.preventDefault();
6001
6002 var $target = $(e.currentTarget);
6003 var uri = $target.attr('href');
6004
6005 new HAL.Views.QueryUriDialog({
6006 href: uri
6007 }).render({});
6008 },
6009
6010 showNonSafeRequestDialog: function(e) {
6011 e.preventDefault();
6012
6013 var postForm = (HAL.customPostForm !== undefined) ? HAL.customPostForm : HAL.Views.NonSafeRequestDialog;
6014 var d = new postForm({
6015 href: $(e.currentTarget).attr('href'),
6016 vent: this.vent
6017 }).render({})
6018 },
6019
6020 showDocs: function(e) {
6021 e.preventDefault();
6022 var $target = $(e.target);
6023 var uri = $target.attr('href') || $target.parent().attr('href');
6024 this.vent.trigger('show-docs', { url: uri });
6025 },
6026
6027 template: _.template($('#links-template').html()),
6028
6029 render: function(links) {
6030 this.$el.html(this.template({ links: links }));
6031 }
6032});
6033HAL.Views.EmbeddedResources = Backbone.View.extend({
6034 initialize: function(opts) {
6035 this.vent = opts.vent;
6036 _.bindAll(this, 'render');
6037 },
6038
6039 className: 'embedded-resources accordion',
6040
6041 render: function(resources) {
6042 var self = this,
6043 resourceViews = [],
6044 buildView = function(resource) {
6045 return new HAL.Views.EmbeddedResource({
6046 resource: resource,
6047 vent: self.vent
6048 });
6049 };
6050
6051 _.each(resources, function(prop) {
6052 if ($.isArray(prop)) {
6053 _.each(prop, function(resource) {
6054 resourceViews.push(buildView(resource));
6055 });
6056 } else {
6057 resourceViews.push(buildView(prop));
6058 }
6059 });
6060
6061 this.$el.html(this.template());
6062
6063 _.each(resourceViews, function(view) {
6064 view.render();
6065 self.$el.append(view.el);
6066 });
6067
6068
6069 return this;
6070 },
6071
6072 template: _.template($('#embedded-resources-template').html())
6073});
6074HAL.Views.EmbeddedResource = Backbone.View.extend({
6075 initialize: function(opts) {
6076 this.vent = opts.vent;
6077 this.resource = opts.resource;
6078
6079 this.propertiesView = new HAL.Views.Properties({});
6080 this.linksView = new HAL.Views.Links({
6081 vent: this.vent
6082 });
6083
6084 _.bindAll(this, 'onToggleClick');
6085 _.bindAll(this, 'onDoxClick');
6086 },
6087
6088 events: {
6089 'click a.accordion-toggle': 'onToggleClick',
6090 'click span.dox': 'onDoxClick'
6091 },
6092
6093 className: 'embedded-resource accordion-group',
6094
6095 onToggleClick: function(e) {
6096 e.preventDefault();
6097 this.$accordionBody.collapse('toggle');
6098 },
6099
6100 onDoxClick: function(e) {
6101 e.preventDefault();
6102 this.vent.trigger('show-docs', {
6103 url: $(e.currentTarget).data('href')
6104 });
6105 return false;
6106 },
6107
6108 render: function() {
6109 this.$el.empty();
6110
6111 this.propertiesView.render(this.resource.toJSON());
6112 this.linksView.render(this.resource.links);
6113
6114 this.$el.append(this.template({
6115 resource: this.resource
6116 }));
6117
6118 var $inner = $('<div class="accordion-inner"></div>');
6119 $inner.append(this.propertiesView.el);
6120 $inner.append(this.linksView.el);
6121
6122 this.$accordionBody = $('<div class="accordion-body collapse"></div>');
6123 this.$accordionBody.append($inner)
6124
6125 this.$el.append(this.$accordionBody);
6126 },
6127
6128 template: _.template($('#embedded-resource-template').html())
6129});
6130HAL.Views.NonSafeRequestDialog = Backbone.View.extend({
6131 initialize: function(opts) {
6132 this.href = opts.href;
6133 this.vent = opts.vent;
6134 this.uriTemplate = uritemplate(this.href);
6135 _.bindAll(this, 'submitQuery');
6136 },
6137
6138 events: {
6139 'submit form': 'submitQuery'
6140 },
6141
6142 className: 'modal fade',
6143
6144 submitQuery: function(e) {
6145 e.preventDefault();
6146
6147 var self = this,
6148 opts = {
6149 url: this.$('.url').val(),
6150 headers: HAL.parseHeaders(this.$('.headers').val()),
6151 method: this.$('.method').val(),
6152 data: this.$('.body').val()
6153 };
6154
6155 var request = HAL.client.request(opts);
6156 request.done(function(response) {
6157 self.vent.trigger('response', { resource: response, jqxhr: jqxhr });
6158 }).fail(function(response) {
6159 self.vent.trigger('fail-response', { jqxhr: jqxhr });
6160 }).always(function() {
6161 self.vent.trigger('response-headers', { jqxhr: jqxhr });
6162 window.location.hash = 'NON-GET:' + opts.url;
6163 });
6164
6165 this.$el.modal('hide');
6166 },
6167
6168 render: function(opts) {
6169 var headers = HAL.client.getHeaders(),
6170 headersString = '';
6171
6172 _.each(headers, function(value, name) {
6173 headersString += name + ': ' + value + '\n';
6174 });
6175
6176 this.$el.html(this.template({ href: this.href, user_defined_headers: headersString }));
6177 this.$el.modal();
6178 return this;
6179 },
6180
6181 template: _.template($('#non-safe-request-template').html())
6182});
6183HAL.Views.QueryUriDialog = Backbone.View.extend({
6184 initialize: function(opts) {
6185 this.href = opts.href;
6186 this.uriTemplate = uritemplate(this.href);
6187 _.bindAll(this, 'submitQuery');
6188 _.bindAll(this, 'renderPreview');
6189 },
6190
6191 className: 'modal fade',
6192
6193 events: {
6194 'submit form': 'submitQuery',
6195 'keyup textarea': 'renderPreview',
6196 'change textarea': 'renderPreview'
6197 },
6198
6199 submitQuery: function(e) {
6200 e.preventDefault();
6201 var input;
6202 try {
6203 input = JSON.parse(this.$('textarea').val());
6204 } catch(err) {
6205 input = {};
6206 }
6207 this.$el.modal('hide');
6208 window.location.hash = this.uriTemplate.expand(this.cleanInput(input));
6209 },
6210
6211 renderPreview: function(e) {
6212 var input, result;
6213 try {
6214 input = JSON.parse($(e.target).val());
6215 result = this.uriTemplate.expand(this.cleanInput(input));
6216 } catch (err) {
6217 result = 'Invalid json input';
6218 }
6219 this.$('.preview').text(result);
6220 },
6221
6222 extractExpressionNames: function (template) {
6223 var names = [];
6224 for (var i=0; i<template.set.length; i++) {
6225 if (template.set[i].vars) {
6226 for (var j=0; j<template.set[i].vars.length; j++) {
6227 names.push(template.set[i].vars[j].name);
6228 }
6229 }
6230 }
6231 return names;
6232 },
6233
6234 createDefaultInput: function (expressionNames) {
6235 var defaultInput = {};
6236 for (var i=0; i<expressionNames.length; i++) {
6237 defaultInput[expressionNames[i]] = '';
6238 }
6239 return JSON.stringify(defaultInput, null, HAL.jsonIndent);
6240 },
6241
6242 render: function(opts) {
6243 var input = this.createDefaultInput(this.extractExpressionNames(this.uriTemplate));
6244 this.$el.html(this.template({ href: this.href, input: input }));
6245 this.$('textarea').trigger('keyup');
6246 this.$el.modal(opts);
6247 return this;
6248 },
6249
6250 cleanInput: function(inputObj) {
6251 var obj = {}
6252 for(var k in inputObj) {
6253 if(inputObj.hasOwnProperty(k) && inputObj[k] != null && String(inputObj[k]).trim() != '') {
6254 obj[k] = inputObj[k]
6255 }
6256 }
6257 return obj
6258 },
6259
6260 template: _.template($('#query-uri-template').html())
6261});
6262HAL.Views.Response = Backbone.View.extend({
6263 initialize: function(opts) {
6264 this.vent = opts.vent;
6265
6266 this.headersView = new HAL.Views.ResponseHeaders({ vent: this.vent });
6267 this.bodyView = new HAL.Views.ResponseBody({ vent: this.vent });
6268
6269 _.bindAll(this, 'render');
6270
6271 this.vent.bind('response', this.render);
6272 },
6273
6274 className: 'response',
6275
6276 render: function(e) {
6277 this.$el.html();
6278
6279 this.headersView.render(e);
6280 this.bodyView.render(e);
6281
6282 this.$el.append(this.headersView.el);
6283 this.$el.append(this.bodyView.el);
6284 }
6285});
6286HAL.Views.ResponseHeaders = Backbone.View.extend({
6287 initialize: function(opts) {
6288 this.vent = opts.vent;
6289 },
6290
6291 events: {
6292 'click .follow': 'followLink'
6293 },
6294
6295 className: 'response-headers',
6296
6297 followLink: function(e) {
6298 e.preventDefault();
6299 var $target = $(e.currentTarget);
6300 var uri = $target.attr('href');
6301 window.location.hash = uri;
6302 },
6303
6304 render: function(e) {
6305 this.$el.html(this.template({
6306 status: {
6307 code: e.jqxhr.status,
6308 text: e.jqxhr.statusText
6309 },
6310 headers: HAL.parseHeaders(e.jqxhr.getAllResponseHeaders())
6311 }));
6312 },
6313
6314 template: _.template($('#response-headers-template').html())
6315});
6316HAL.Views.ResponseBody = Backbone.View.extend({
6317 initialize: function(opts) {
6318 this.vent = opts.vent;
6319 },
6320
6321 className: 'response-headers',
6322
6323 render: function(e) {
6324 this.$el.html(this.template({
6325 body: this._bodyAsStringFromEvent(e)
6326 }));
6327 },
6328
6329 template: _.template($('#response-body-template').html()),
6330
6331 _bodyAsStringFromEvent: function(e) {
6332 var output = 'n/a';
6333 if(e.resource !== null) {
6334 output = JSON.stringify(e.resource, null, HAL.jsonIndent);
6335 } else {
6336 // The Ajax request "failed", but there may still be an
6337 // interesting response body (possibly JSON) to show.
6338 var content_type = e.jqxhr.getResponseHeader('content-type');
6339 var responseText = e.jqxhr.responseText;
6340 if(content_type == null || content_type.indexOf('text/') == 0) {
6341 output = responseText;
6342 } else if(content_type.indexOf('json') != -1) {
6343 // Looks like json... try to parse it.
6344 try {
6345 var obj = JSON.parse(responseText);
6346 output = JSON.stringify(obj, null, HAL.jsonIndent);
6347 } catch (err) {
6348 // JSON parse failed. Just show the raw text.
6349 output = responseText;
6350 }
6351 }
6352 }
6353 return output
6354 }
6355});
6356HAL.Views.Documenation = Backbone.View.extend({
6357 className: 'documentation',
6358
6359 render: function(url) {
6360 this.$el.html('<iframe src=' + url + '></iframe>');
6361 }
6362});