/*! * Reqwest! A general purpose XHR connection manager * (c) Dustin Diaz 2013 * https://github.com/ded/reqwest * license MIT */ !function(e,t,n){typeof module!="undefined"&&module.exports?module.exports=n():typeof define=="function"&&define.amd?define(n):t[e]=n()}("reqwest",this,function(){function handleReadyState(e,t,n){return function(){if(e._aborted)return n(e.request);e.request&&e.request[readyState]==4&&(e.request.onreadystatechange=noop,twoHundo.test(e.request.status)?t(e.request):n(e.request))}}function setHeaders(e,t){var n=t.headers||{},r;n.Accept=n.Accept||defaultHeaders.accept[t.type]||defaultHeaders.accept["*"],!t.crossOrigin&&!n[requestedWith]&&(n[requestedWith]=defaultHeaders.requestedWith),n[contentType]||(n[contentType]=t.contentType||defaultHeaders.contentType);for(r in n)n.hasOwnProperty(r)&&e.setRequestHeader(r,n[r])}function setCredentials(e,t){typeof t.withCredentials!="undefined"&&typeof e.withCredentials!="undefined"&&(e.withCredentials=!!t.withCredentials)}function generalCallback(e){lastValue=e}function urlappend(e,t){return e+(/\?/.test(e)?"&":"?")+t}function handleJsonp(e,t,n,r){var i=uniqid++,s=e.jsonpCallback||"callback",o=e.jsonpCallbackName||reqwest.getcallbackPrefix(i),u=new RegExp("((^|\\?|&)"+s+")=([^&]+)"),a=r.match(u),f=doc.createElement("script"),l=0,c=navigator.userAgent.indexOf("MSIE 10.0")!==-1;return a?a[3]==="?"?r=r.replace(u,"$1="+o):o=a[3]:r=urlappend(r,s+"="+o),win[o]=generalCallback,f.type="text/javascript",f.src=r,f.async=!0,typeof f.onreadystatechange!="undefined"&&!c&&(f.event="onclick",f.htmlFor=f.id="_reqwest_"+i),f.onload=f.onreadystatechange=function(){if(f[readyState]&&f[readyState]!=="complete"&&f[readyState]!=="loaded"||l)return!1;f.onload=f.onreadystatechange=null,f.onclick&&f.onclick(),e.success&&e.success(lastValue),lastValue=undefined,head.removeChild(f),l=1},head.appendChild(f),{abort:function(){f.onload=f.onreadystatechange=null,e.error&&e.error({},"Request is aborted: timeout",{}),lastValue=undefined,head.removeChild(f),l=1}}}function getRequest(e,t){var n=this.o,r=(n.method||"GET").toUpperCase(),i=typeof n=="string"?n:n.url,s=n.processData!==!1&&n.data&&typeof n.data!="string"?reqwest.toQueryString(n.data):n.data||null,o;return(n.type=="jsonp"||r=="GET")&&s&&(i=urlappend(i,s),s=null),n.type=="jsonp"?handleJsonp(n,e,t,i):(o=xhr(),o.open(r,i,!0),setHeaders(o,n),setCredentials(o,n),o.onreadystatechange=handleReadyState(this,e,t),n.before&&n.before(o),o.send(s),o)}function Reqwest(e,t){this.o=e,this.fn=t,init.apply(this,arguments)}function setType(e){var t=e.match(/\.(json|jsonp|html|xml)(\?|$)/);return t?t[1]:"js"}function init(o,fn){function complete(e){o.timeout&&clearTimeout(self.timeout),self.timeout=null;while(self._completeHandlers.length>0)self._completeHandlers.shift()(e)}function success(resp){var filteredResponse=globalSetupOptions.dataFilter(resp.responseText,type),r=resp.responseText=filteredResponse;if(r)switch(type){case"json":try{resp=win.JSON?win.JSON.parse(r):eval("("+r+")")}catch(err){return error(resp,"Could not parse JSON in response",err)}break;case"js":resp=eval(r);break;case"html":resp=r;break;case"xml":resp=resp.responseXML&&resp.responseXML.parseError&&resp.responseXML.parseError.errorCode&&resp.responseXML.parseError.reason?null:resp.responseXML}self._responseArgs.resp=resp,self._fulfilled=!0,fn(resp);while(self._fulfillmentHandlers.length>0)self._fulfillmentHandlers.shift()(resp);complete(resp)}function error(e,t,n){self._responseArgs.resp=e,self._responseArgs.msg=t,self._responseArgs.t=n,self._erred=!0;while(self._errorHandlers.length>0)self._errorHandlers.shift()(e,t,n);complete(e)}this.url=typeof o=="string"?o:o.url,this.timeout=null,this._fulfilled=!1,this._fulfillmentHandlers=[],this._errorHandlers=[],this._completeHandlers=[],this._erred=!1,this._responseArgs={};var self=this,type=o.type||setType(this.url);fn=fn||function(){},o.timeout&&(this.timeout=setTimeout(function(){self.abort()},o.timeout)),o.success&&this._fulfillmentHandlers.push(function(){o.success.apply(o,arguments)}),o.error&&this._errorHandlers.push(function(){o.error.apply(o,arguments)}),o.complete&&this._completeHandlers.push(function(){o.complete.apply(o,arguments)}),this.request=getRequest.call(this,success,error)}function reqwest(e,t){return new Reqwest(e,t)}function normalize(e){return e?e.replace(/\r?\n/g,"\r\n"):""}function serial(e,t){var n=e.name,r=e.tagName.toLowerCase(),i=function(e){e&&!e.disabled&&t(n,normalize(e.attributes.value&&e.attributes.value.specified?e.value:e.text))},s,o,u,a;if(e.disabled||!n)return;switch(r){case"input":/reset|button|image|file/i.test(e.type)||(s=/checkbox/i.test(e.type),o=/radio/i.test(e.type),u=e.value,(!s&&!o||e.checked)&&t(n,normalize(s&&u===""?"on":u)));break;case"textarea":t(n,normalize(e.value));break;case"select":if(e.type.toLowerCase()==="select-one")i(e.selectedIndex>=0?e.options[e.selectedIndex]:null);else for(a=0;e.length&&a2){e(Array.prototype.slice.call(arguments,1))}else{e(n)}}}function s(e){return function(){var t=Array.prototype.slice.call(arguments),r,s;var f=new n(function(e,t){r=e;s=t});i(t).then(function(t){t.push(o(r,s));try{e.apply(this,t)}catch(n){s(n)}});return f}}r.denodeify=s});e("rsvp/promise",["rsvp/config","rsvp/events","exports"],function(e,t,r){"use strict";var n=e.config;var i=t.EventTarget;function o(e){return s(e)||typeof e==="object"&&e!==null}function s(e){return typeof e==="function"}var f=function(e){var t=this,r=false;if(typeof e!=="function"){throw new TypeError("You must pass a resolver function as the sole argument to the promise constructor")}if(!(t instanceof f)){return new f(e)}var n=function(e){if(r){return}r=true;u(t,e)};var i=function(e){if(r){return}r=true;l(t,e)};this.on("promise:resolved",function(e){this.trigger("success",{detail:e.detail})},this);this.on("promise:failed",function(e){this.trigger("error",{detail:e.detail})},this);e(n,i)};var c=function(e,t,r,n){var i=s(r),f,c,a,v;if(i){try{f=r(n.detail);a=true}catch(p){v=true;c=p}}else{f=n.detail;a=true}if(o(f)&&s(f.then)){f.then(function(e){u(t,e)},function(e){l(t,e)})}else if(i&&a){u(t,f)}else if(v){l(t,c)}else if(e==="resolve"){u(t,f)}else if(e==="reject"){l(t,f)}};f.prototype={constructor:f,then:function(e,t){var r=new f(function(){});if(this.isFulfilled){n.async(function(){c("resolve",r,e,{detail:this.fulfillmentValue})},this)}if(this.isRejected){n.async(function(){c("reject",r,t,{detail:this.rejectedReason})},this)}this.on("promise:resolved",function(t){c("resolve",r,e,t)});this.on("promise:failed",function(e){c("reject",r,t,e)});return r}};i.mixin(f.prototype);function u(e,t){if(e===t){a(e,t)}else if(o(t)&&s(t.then)){t.then(function(r){if(t!==r){u(e,r)}else{a(e,r)}},function(t){l(e,t)})}else{a(e,t)}}function a(e,t){n.async(function(){e.trigger("promise:resolved",{detail:t});e.isFulfilled=true;e.fulfillmentValue=t})}function l(e,t){n.async(function(){e.trigger("promise:failed",{detail:t});e.isRejected=true;e.rejectedReason=t})}r.Promise=f});e("rsvp/resolve",["rsvp/promise","exports"],function(e,t){"use strict";var r=e.Promise;function n(e){return typeof e==="function"||typeof e==="object"&&e!==null}function i(e){var t=new r(function(t,r){var i;try{if(n(e)){i=e.then;if(typeof i==="function"){i.call(e,t,r)}else{t(e)}}else{t(e)}}catch(o){r(o)}});return t}t.resolve=i});e("rsvp",["rsvp/events","rsvp/promise","rsvp/node","rsvp/all","rsvp/hash","rsvp/defer","rsvp/config","rsvp/resolve","exports"],function(e,t,r,n,i,o,s,f,c){"use strict";var u=e.EventTarget;var a=t.Promise;var l=r.denodeify;var v=n.all;var p=i.hash;var h=o.defer;var d=s.config;var y=f.resolve;function g(e,t){d[e]=t}c.Promise=a;c.EventTarget=u;c.all=v;c.hash=p;c.defer=h;c.denodeify=l;c.configure=g;c.resolve=y});window.RSVP=t("rsvp")})(); // Underscore.js 1.4.4 // http://underscorejs.org // (c) 2009-2013 Jeremy Ashkenas, DocumentCloud Inc. // Underscore may be freely distributed under the MIT license. (function(){var n=this,t=n._,r={},e=Array.prototype,u=Object.prototype,i=Function.prototype,a=e.push,o=e.slice,c=e.concat,l=u.toString,f=u.hasOwnProperty,s=e.forEach,p=e.map,h=e.reduce,v=e.reduceRight,d=e.filter,g=e.every,m=e.some,y=e.indexOf,b=e.lastIndexOf,x=Array.isArray,_=Object.keys,j=i.bind,w=function(n){return n instanceof w?n:this instanceof w?(this._wrapped=n,void 0):new w(n)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=w),exports._=w):n._=w,w.VERSION="1.4.4";var A=w.each=w.forEach=function(n,t,e){if(null!=n)if(s&&n.forEach===s)n.forEach(t,e);else if(n.length===+n.length){for(var u=0,i=n.length;i>u;u++)if(t.call(e,n[u],u,n)===r)return}else for(var a in n)if(w.has(n,a)&&t.call(e,n[a],a,n)===r)return};w.map=w.collect=function(n,t,r){var e=[];return null==n?e:p&&n.map===p?n.map(t,r):(A(n,function(n,u,i){e[e.length]=t.call(r,n,u,i)}),e)};var O="Reduce of empty array with no initial value";w.reduce=w.foldl=w.inject=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),h&&n.reduce===h)return e&&(t=w.bind(t,e)),u?n.reduce(t,r):n.reduce(t);if(A(n,function(n,i,a){u?r=t.call(e,r,n,i,a):(r=n,u=!0)}),!u)throw new TypeError(O);return r},w.reduceRight=w.foldr=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),v&&n.reduceRight===v)return e&&(t=w.bind(t,e)),u?n.reduceRight(t,r):n.reduceRight(t);var i=n.length;if(i!==+i){var a=w.keys(n);i=a.length}if(A(n,function(o,c,l){c=a?a[--i]:--i,u?r=t.call(e,r,n[c],c,l):(r=n[c],u=!0)}),!u)throw new TypeError(O);return r},w.find=w.detect=function(n,t,r){var e;return E(n,function(n,u,i){return t.call(r,n,u,i)?(e=n,!0):void 0}),e},w.filter=w.select=function(n,t,r){var e=[];return null==n?e:d&&n.filter===d?n.filter(t,r):(A(n,function(n,u,i){t.call(r,n,u,i)&&(e[e.length]=n)}),e)},w.reject=function(n,t,r){return w.filter(n,function(n,e,u){return!t.call(r,n,e,u)},r)},w.every=w.all=function(n,t,e){t||(t=w.identity);var u=!0;return null==n?u:g&&n.every===g?n.every(t,e):(A(n,function(n,i,a){return(u=u&&t.call(e,n,i,a))?void 0:r}),!!u)};var E=w.some=w.any=function(n,t,e){t||(t=w.identity);var u=!1;return null==n?u:m&&n.some===m?n.some(t,e):(A(n,function(n,i,a){return u||(u=t.call(e,n,i,a))?r:void 0}),!!u)};w.contains=w.include=function(n,t){return null==n?!1:y&&n.indexOf===y?n.indexOf(t)!=-1:E(n,function(n){return n===t})},w.invoke=function(n,t){var r=o.call(arguments,2),e=w.isFunction(t);return w.map(n,function(n){return(e?t:n[t]).apply(n,r)})},w.pluck=function(n,t){return w.map(n,function(n){return n[t]})},w.where=function(n,t,r){return w.isEmpty(t)?r?null:[]:w[r?"find":"filter"](n,function(n){for(var r in t)if(t[r]!==n[r])return!1;return!0})},w.findWhere=function(n,t){return w.where(n,t,!0)},w.max=function(n,t,r){if(!t&&w.isArray(n)&&n[0]===+n[0]&&65535>n.length)return Math.max.apply(Math,n);if(!t&&w.isEmpty(n))return-1/0;var e={computed:-1/0,value:-1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;a>=e.computed&&(e={value:n,computed:a})}),e.value},w.min=function(n,t,r){if(!t&&w.isArray(n)&&n[0]===+n[0]&&65535>n.length)return Math.min.apply(Math,n);if(!t&&w.isEmpty(n))return 1/0;var e={computed:1/0,value:1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;e.computed>a&&(e={value:n,computed:a})}),e.value},w.shuffle=function(n){var t,r=0,e=[];return A(n,function(n){t=w.random(r++),e[r-1]=e[t],e[t]=n}),e};var k=function(n){return w.isFunction(n)?n:function(t){return t[n]}};w.sortBy=function(n,t,r){var e=k(t);return w.pluck(w.map(n,function(n,t,u){return{value:n,index:t,criteria:e.call(r,n,t,u)}}).sort(function(n,t){var r=n.criteria,e=t.criteria;if(r!==e){if(r>e||r===void 0)return 1;if(e>r||e===void 0)return-1}return n.indexi;){var o=i+a>>>1;u>r.call(e,n[o])?i=o+1:a=o}return i},w.toArray=function(n){return n?w.isArray(n)?o.call(n):n.length===+n.length?w.map(n,w.identity):w.values(n):[]},w.size=function(n){return null==n?0:n.length===+n.length?n.length:w.keys(n).length},w.first=w.head=w.take=function(n,t,r){return null==n?void 0:null==t||r?n[0]:o.call(n,0,t)},w.initial=function(n,t,r){return o.call(n,0,n.length-(null==t||r?1:t))},w.last=function(n,t,r){return null==n?void 0:null==t||r?n[n.length-1]:o.call(n,Math.max(n.length-t,0))},w.rest=w.tail=w.drop=function(n,t,r){return o.call(n,null==t||r?1:t)},w.compact=function(n){return w.filter(n,w.identity)};var R=function(n,t,r){return A(n,function(n){w.isArray(n)?t?a.apply(r,n):R(n,t,r):r.push(n)}),r};w.flatten=function(n,t){return R(n,t,[])},w.without=function(n){return w.difference(n,o.call(arguments,1))},w.uniq=w.unique=function(n,t,r,e){w.isFunction(t)&&(e=r,r=t,t=!1);var u=r?w.map(n,r,e):n,i=[],a=[];return A(u,function(r,e){(t?e&&a[a.length-1]===r:w.contains(a,r))||(a.push(r),i.push(n[e]))}),i},w.union=function(){return w.uniq(c.apply(e,arguments))},w.intersection=function(n){var t=o.call(arguments,1);return w.filter(w.uniq(n),function(n){return w.every(t,function(t){return w.indexOf(t,n)>=0})})},w.difference=function(n){var t=c.apply(e,o.call(arguments,1));return w.filter(n,function(n){return!w.contains(t,n)})},w.zip=function(){for(var n=o.call(arguments),t=w.max(w.pluck(n,"length")),r=Array(t),e=0;t>e;e++)r[e]=w.pluck(n,""+e);return r},w.object=function(n,t){if(null==n)return{};for(var r={},e=0,u=n.length;u>e;e++)t?r[n[e]]=t[e]:r[n[e][0]]=n[e][1];return r},w.indexOf=function(n,t,r){if(null==n)return-1;var e=0,u=n.length;if(r){if("number"!=typeof r)return e=w.sortedIndex(n,t),n[e]===t?e:-1;e=0>r?Math.max(0,u+r):r}if(y&&n.indexOf===y)return n.indexOf(t,r);for(;u>e;e++)if(n[e]===t)return e;return-1},w.lastIndexOf=function(n,t,r){if(null==n)return-1;var e=null!=r;if(b&&n.lastIndexOf===b)return e?n.lastIndexOf(t,r):n.lastIndexOf(t);for(var u=e?r:n.length;u--;)if(n[u]===t)return u;return-1},w.range=function(n,t,r){1>=arguments.length&&(t=n||0,n=0),r=arguments[2]||1;for(var e=Math.max(Math.ceil((t-n)/r),0),u=0,i=Array(e);e>u;)i[u++]=n,n+=r;return i},w.bind=function(n,t){if(n.bind===j&&j)return j.apply(n,o.call(arguments,1));var r=o.call(arguments,2);return function(){return n.apply(t,r.concat(o.call(arguments)))}},w.partial=function(n){var t=o.call(arguments,1);return function(){return n.apply(this,t.concat(o.call(arguments)))}},w.bindAll=function(n){var t=o.call(arguments,1);return 0===t.length&&(t=w.functions(n)),A(t,function(t){n[t]=w.bind(n[t],n)}),n},w.memoize=function(n,t){var r={};return t||(t=w.identity),function(){var e=t.apply(this,arguments);return w.has(r,e)?r[e]:r[e]=n.apply(this,arguments)}},w.delay=function(n,t){var r=o.call(arguments,2);return setTimeout(function(){return n.apply(null,r)},t)},w.defer=function(n){return w.delay.apply(w,[n,1].concat(o.call(arguments,1)))},w.throttle=function(n,t){var r,e,u,i,a=0,o=function(){a=new Date,u=null,i=n.apply(r,e)};return function(){var c=new Date,l=t-(c-a);return r=this,e=arguments,0>=l?(clearTimeout(u),u=null,a=c,i=n.apply(r,e)):u||(u=setTimeout(o,l)),i}},w.debounce=function(n,t,r){var e,u;return function(){var i=this,a=arguments,o=function(){e=null,r||(u=n.apply(i,a))},c=r&&!e;return clearTimeout(e),e=setTimeout(o,t),c&&(u=n.apply(i,a)),u}},w.once=function(n){var t,r=!1;return function(){return r?t:(r=!0,t=n.apply(this,arguments),n=null,t)}},w.wrap=function(n,t){return function(){var r=[n];return a.apply(r,arguments),t.apply(this,r)}},w.compose=function(){var n=arguments;return function(){for(var t=arguments,r=n.length-1;r>=0;r--)t=[n[r].apply(this,t)];return t[0]}},w.after=function(n,t){return 0>=n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},w.keys=_||function(n){if(n!==Object(n))throw new TypeError("Invalid object");var t=[];for(var r in n)w.has(n,r)&&(t[t.length]=r);return t},w.values=function(n){var t=[];for(var r in n)w.has(n,r)&&t.push(n[r]);return t},w.pairs=function(n){var t=[];for(var r in n)w.has(n,r)&&t.push([r,n[r]]);return t},w.invert=function(n){var t={};for(var r in n)w.has(n,r)&&(t[n[r]]=r);return t},w.functions=w.methods=function(n){var t=[];for(var r in n)w.isFunction(n[r])&&t.push(r);return t.sort()},w.extend=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)n[r]=t[r]}),n},w.pick=function(n){var t={},r=c.apply(e,o.call(arguments,1));return A(r,function(r){r in n&&(t[r]=n[r])}),t},w.omit=function(n){var t={},r=c.apply(e,o.call(arguments,1));for(var u in n)w.contains(r,u)||(t[u]=n[u]);return t},w.defaults=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)null==n[r]&&(n[r]=t[r])}),n},w.clone=function(n){return w.isObject(n)?w.isArray(n)?n.slice():w.extend({},n):n},w.tap=function(n,t){return t(n),n};var I=function(n,t,r,e){if(n===t)return 0!==n||1/n==1/t;if(null==n||null==t)return n===t;n instanceof w&&(n=n._wrapped),t instanceof w&&(t=t._wrapped);var u=l.call(n);if(u!=l.call(t))return!1;switch(u){case"[object String]":return n==t+"";case"[object Number]":return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case"[object Date]":case"[object Boolean]":return+n==+t;case"[object RegExp]":return n.source==t.source&&n.global==t.global&&n.multiline==t.multiline&&n.ignoreCase==t.ignoreCase}if("object"!=typeof n||"object"!=typeof t)return!1;for(var i=r.length;i--;)if(r[i]==n)return e[i]==t;r.push(n),e.push(t);var a=0,o=!0;if("[object Array]"==u){if(a=n.length,o=a==t.length)for(;a--&&(o=I(n[a],t[a],r,e)););}else{var c=n.constructor,f=t.constructor;if(c!==f&&!(w.isFunction(c)&&c instanceof c&&w.isFunction(f)&&f instanceof f))return!1;for(var s in n)if(w.has(n,s)&&(a++,!(o=w.has(t,s)&&I(n[s],t[s],r,e))))break;if(o){for(s in t)if(w.has(t,s)&&!a--)break;o=!a}}return r.pop(),e.pop(),o};w.isEqual=function(n,t){return I(n,t,[],[])},w.isEmpty=function(n){if(null==n)return!0;if(w.isArray(n)||w.isString(n))return 0===n.length;for(var t in n)if(w.has(n,t))return!1;return!0},w.isElement=function(n){return!(!n||1!==n.nodeType)},w.isArray=x||function(n){return"[object Array]"==l.call(n)},w.isObject=function(n){return n===Object(n)},A(["Arguments","Function","String","Number","Date","RegExp"],function(n){w["is"+n]=function(t){return l.call(t)=="[object "+n+"]"}}),w.isArguments(arguments)||(w.isArguments=function(n){return!(!n||!w.has(n,"callee"))}),"function"!=typeof/./&&(w.isFunction=function(n){return"function"==typeof n}),w.isFinite=function(n){return isFinite(n)&&!isNaN(parseFloat(n))},w.isNaN=function(n){return w.isNumber(n)&&n!=+n},w.isBoolean=function(n){return n===!0||n===!1||"[object Boolean]"==l.call(n)},w.isNull=function(n){return null===n},w.isUndefined=function(n){return n===void 0},w.has=function(n,t){return f.call(n,t)},w.noConflict=function(){return n._=t,this},w.identity=function(n){return n},w.times=function(n,t,r){for(var e=Array(n),u=0;n>u;u++)e[u]=t.call(r,u);return e},w.random=function(n,t){return null==t&&(t=n,n=0),n+Math.floor(Math.random()*(t-n+1))};var M={escape:{"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"}};M.unescape=w.invert(M.escape);var S={escape:RegExp("["+w.keys(M.escape).join("")+"]","g"),unescape:RegExp("("+w.keys(M.unescape).join("|")+")","g")};w.each(["escape","unescape"],function(n){w[n]=function(t){return null==t?"":(""+t).replace(S[n],function(t){return M[n][t]})}}),w.result=function(n,t){if(null==n)return null;var r=n[t];return w.isFunction(r)?r.call(n):r},w.mixin=function(n){A(w.functions(n),function(t){var r=w[t]=n[t];w.prototype[t]=function(){var n=[this._wrapped];return a.apply(n,arguments),D.call(this,r.apply(w,n))}})};var N=0;w.uniqueId=function(n){var t=++N+"";return n?n+t:t},w.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var T=/(.)^/,q={"'":"'","\\":"\\","\r":"r","\n":"n"," ":"t","\u2028":"u2028","\u2029":"u2029"},B=/\\|'|\r|\n|\t|\u2028|\u2029/g;w.template=function(n,t,r){var e;r=w.defaults({},r,w.templateSettings);var u=RegExp([(r.escape||T).source,(r.interpolate||T).source,(r.evaluate||T).source].join("|")+"|$","g"),i=0,a="__p+='";n.replace(u,function(t,r,e,u,o){return a+=n.slice(i,o).replace(B,function(n){return"\\"+q[n]}),r&&(a+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'"),e&&(a+="'+\n((__t=("+e+"))==null?'':__t)+\n'"),u&&(a+="';\n"+u+"\n__p+='"),i=o+t.length,t}),a+="';\n",r.variable||(a="with(obj||{}){\n"+a+"}\n"),a="var __t,__p='',__j=Array.prototype.join,"+"print=function(){__p+=__j.call(arguments,'');};\n"+a+"return __p;\n";try{e=Function(r.variable||"obj","_",a)}catch(o){throw o.source=a,o}if(t)return e(t,w);var c=function(n){return e.call(this,n,w)};return c.source="function("+(r.variable||"obj")+"){\n"+a+"}",c},w.chain=function(n){return w(n).chain()};var D=function(n){return this._chain?w(n).chain():n};w.mixin(w),A(["pop","push","reverse","shift","sort","splice","unshift"],function(n){var t=e[n];w.prototype[n]=function(){var r=this._wrapped;return t.apply(r,arguments),"shift"!=n&&"splice"!=n||0!==r.length||delete r[0],D.call(this,r)}}),A(["concat","join","slice"],function(n){var t=e[n];w.prototype[n]=function(){return D.call(this,t.apply(this._wrapped,arguments))}}),w.extend(w.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}})}).call(this); /*! jsTimezoneDetect - v1.0.5 - 2013-04-01 */ (function(e){var t=function(){"use strict";var e="s",n=2011,r=function(e){var t=-e.getTimezoneOffset();return t!==null?t:0},i=function(e,t,n){var r=new Date;return e!==undefined&&r.setFullYear(e),r.setDate(n),r.setMonth(t),r},s=function(e){return r(i(e,0,2))},o=function(e){return r(i(e,5,2))},u=function(e){var t=e.getMonth()>7?o(e.getFullYear()):s(e.getFullYear()),n=r(e);return t-n!==0},a=function(){var t=s(n),r=o(n),i=t-r;return i<0?t+",1":i>0?r+",1,"+e:t+",0"},f=function(){var e=a();return new t.TimeZone(t.olson.timezones[e])},l=function(e){var t=new Date(2010,6,15,1,0,0,0),n={"America/Denver":new Date(2011,2,13,3,0,0,0),"America/Mazatlan":new Date(2011,3,3,3,0,0,0),"America/Chicago":new Date(2011,2,13,3,0,0,0),"America/Mexico_City":new Date(2011,3,3,3,0,0,0),"America/Asuncion":new Date(2012,9,7,3,0,0,0),"America/Santiago":new Date(2012,9,3,3,0,0,0),"America/Campo_Grande":new Date(2012,9,21,5,0,0,0),"America/Montevideo":new Date(2011,9,2,3,0,0,0),"America/Sao_Paulo":new Date(2011,9,16,5,0,0,0),"America/Los_Angeles":new Date(2011,2,13,8,0,0,0),"America/Santa_Isabel":new Date(2011,3,5,8,0,0,0),"America/Havana":new Date(2012,2,10,2,0,0,0),"America/New_York":new Date(2012,2,10,7,0,0,0),"Asia/Beirut":new Date(2011,2,27,1,0,0,0),"Europe/Helsinki":new Date(2011,2,27,4,0,0,0),"Europe/Istanbul":new Date(2011,2,28,5,0,0,0),"Asia/Damascus":new Date(2011,3,1,2,0,0,0),"Asia/Jerusalem":new Date(2011,3,1,6,0,0,0),"Asia/Gaza":new Date(2009,2,28,0,30,0,0),"Africa/Cairo":new Date(2009,3,25,0,30,0,0),"Pacific/Auckland":new Date(2011,8,26,7,0,0,0),"Pacific/Fiji":new Date(2010,10,29,23,0,0,0),"America/Halifax":new Date(2011,2,13,6,0,0,0),"America/Goose_Bay":new Date(2011,2,13,2,1,0,0),"America/Miquelon":new Date(2011,2,13,5,0,0,0),"America/Godthab":new Date(2011,2,27,1,0,0,0),"Europe/Moscow":t,"Asia/Yekaterinburg":t,"Asia/Omsk":t,"Asia/Krasnoyarsk":t,"Asia/Irkutsk":t,"Asia/Yakutsk":t,"Asia/Vladivostok":t,"Asia/Kamchatka":t,"Europe/Minsk":t,"Pacific/Apia":new Date(2010,10,1,1,0,0,0),"Australia/Perth":new Date(2008,10,1,1,0,0,0)};return n[e]};return{determine:f,date_is_dst:u,dst_start_for:l}}();t.TimeZone=function(e){"use strict";var n={"America/Denver":["America/Denver","America/Mazatlan"],"America/Chicago":["America/Chicago","America/Mexico_City"],"America/Santiago":["America/Santiago","America/Asuncion","America/Campo_Grande"],"America/Montevideo":["America/Montevideo","America/Sao_Paulo"],"Asia/Beirut":["Asia/Beirut","Europe/Helsinki","Europe/Istanbul","Asia/Damascus","Asia/Jerusalem","Asia/Gaza"],"Pacific/Auckland":["Pacific/Auckland","Pacific/Fiji"],"America/Los_Angeles":["America/Los_Angeles","America/Santa_Isabel"],"America/New_York":["America/Havana","America/New_York"],"America/Halifax":["America/Goose_Bay","America/Halifax"],"America/Godthab":["America/Miquelon","America/Godthab"],"Asia/Dubai":["Europe/Moscow"],"Asia/Dhaka":["Asia/Yekaterinburg"],"Asia/Jakarta":["Asia/Omsk"],"Asia/Shanghai":["Asia/Krasnoyarsk","Australia/Perth"],"Asia/Tokyo":["Asia/Irkutsk"],"Australia/Brisbane":["Asia/Yakutsk"],"Pacific/Noumea":["Asia/Vladivostok"],"Pacific/Tarawa":["Asia/Kamchatka"],"Pacific/Tongatapu":["Pacific/Apia"],"Africa/Johannesburg":["Asia/Gaza","Africa/Cairo"],"Asia/Baghdad":["Europe/Minsk"]},r=e,i=function(){var e=n[r],i=e.length,s=0,o=e[0];for(;s0){z.reduce(K,function(L,M){L[M.operands[0]]=M.operator===I.order?1:-1;return L},J);return J}else{return null}},_buildWhere:function(){var J=z.find(this.expr.operands,function(N,L,M){return N.operator===I.where});if(J){return this._build(new E(I.and,J.operands))}else{var K=z.find(this.expr.operands,function(N,L,M){return N.operator===I.filter});if(K){return K.operands[0]}return null}},_build:function(J){if(this._isSimple(J)){return this._simple(J)}else{if(this._isRegex(J)){return this._regex(J)}else{if(this._isGeo(J)){return this._geo(J)}else{if(this._isAnd(J)){return this._and(J)}else{if(this._isOr(J)){return this._or(J)}else{if(this._isNot(J)){return this._not(J)}}}}}}},_isSimple:function(J){return J.operator>=I.equal&&J.operator<=I.size},_simple:function(N){var M={},J={};var L=N.operands;var K=this._translateoperator(N.operator);if(K){M[K]=L[1]}else{M=L[1]}J[L[0]]=M;return J},_isRegex:function(J){return J.operator>=I.regex&&J.operator<=I.endsWith},_regex:function(N){var J={};var M=this._getRegex(N);var K=this._getRegexValue(M);var L=N.operands;J[L[0]]=K;return J},_getRegex:function(L){var K=L.operands[1];var J=L.operands[2]?L.operands[2]:"";switch(L.operator){case I.regex:return K instanceof RegExp?K:new RegExp(K,J);case I.startsWith:return new RegExp("^"+K,J);case I.endsWith:return new RegExp(K+"$",J);default:throw new Error("Unknown operator type.")}},_getRegexValue:function(K){var J="";if(K.global){J+="g"}if(K.multiline){J+="m"}if(K.ignoreCase){J+="i"}return{$regex:K.source,$options:J}},_isGeo:function(J){return J.operator>=I.nearShpere&&J.operator<=I.withinShpere},_geo:function(L){var J={};var K=L.operands;J[K[0]]=this._getGeoTerm(L);return J},_getGeoTerm:function(J){switch(J.operator){case I.nearShpere:return this._getNearSphereTerm(J);case I.withinBox:return this._getWithinBox(J);case I.withinPolygon:return this._getWithinPolygon(J);case I.withinShpere:return this._getWithinCenterSphere(J);default:throw new Error("Unknown operator type.")}},_getNearSphereTerm:function(P){var L=P.operands;var J=this._getGeoPoint(L[1]);var O=L[2];var N=L[3];var K;var M={"$nearSphere":J};if(typeof O!=="undefined"){K=C[N]||C.radians;M[K]=O}return M},_getWithinBox:function(M){var K=M.operands;var J=this._getGeoPoint(K[1]);var L=this._getGeoPoint(K[2]);return{"$within":{"$box":[J,L]}}},_getWithinPolygon:function(L){var J=L.operands;var K=this._getGeoPoints(J[1]);return{"$within":{"$polygon":K}}},_getWithinCenterSphere:function(P){var N=P.operands;var K=this._getGeoPoint(N[1]);var J=N[2];var O=N[3];var L=F[O]||F.radians;var M={center:K};M[L]=J;return{"$within":{"$centerSphere":M}}},_getGeoPoint:function(J){if(z.isArray(J)){return new l(J[0],J[1])}return J},_getGeoPoints:function(K){var J=this;return z.map(K,function(L){return J._getGeoPoint(L)})},_isAnd:function(J){return J.operator===I.and},_and:function(O){var N,K,M,J={};var L=O.operands;for(N=0,K=L.length;N3){Q=Math.round(Number(Q.substr(0,3)+"."+Q.substr(3)))}else{if(Q.length<3){Q+=Q.length===2?"0":"00"}}}var R=new Date(Date.UTC(Number(S[1]),(Number(S[3])-1)||0,Number(S[5])||0,Number(S[7])||0,Number(S[8])||0,Number(S[10])||0,Number(Q)||0));if(S[13]&&S[13]!=="Z"){var U=Number(S[16])||0,P=Number(S[17])||0;U*=3600000;P*=60000;var V=U+P;if(S[15]==="+"){V=-V}R=new Date(R.valueOf()+V)}return R}else{return null}}function K(Q,R){if(typeof R==="string"){var P=O(R);if(P){R=P}}return R}function H(T,Q){var P,R,S;for(P in T){if(T.hasOwnProperty(P)){R=T[P];S=Q(P,R);T[P]=S;if(R===S&&typeof R==="object"){H(R,Q)}}}}function C(P){H(P,K)}r._traverseAndRevive=C;function E(P){if(typeof P==="string"&&P.length>0){P=JSON.parse(P,K)}else{if(typeof P==="object"){C(P)}}if(P){return{result:P.Result,count:P.Count}}else{return P}}function F(P){if(typeof P==="string"&&P.length>0){try{P=JSON.parse(P);return{message:P.message,code:P.errorCode}}catch(Q){return P}}else{return P}}function M(P){if(typeof P==="string"&&P.length>0){P=JSON.parse(P,K)}else{if(typeof P==="object"){C(P)}}if(P){return{result:P.Result}}else{return P}}function I(P){if(typeof P==="string"&&P.length>0){P=JSON.parse(P,K)}else{if(typeof P==="object"){C(P)}}if(P){return{result:P.Result,ModifiedAt:P.ModifiedAt}}else{return P}}D.parsers={simple:{result:E,error:F},single:{result:M,error:F},update:{result:I,error:F}};r.disableRequestCache=function(P,S){if(S==="GET"){var Q=(new Date()).getTime();var R=P.indexOf("?")>-1?"&":"?";P+=R+"_el="+Q}return P};if(typeof r.sendRequest==="undefined"){r.sendRequest=function(Q){var P=Q.buildUrl(Q.setup)+Q.endpoint;P=r.disableRequestCache(P,Q.method);var R=Q.method==="GET"?Q.data:JSON.stringify(Q.data);k({url:P,method:Q.method,data:R,headers:Q.headers,type:"json",contentType:"application/json",crossOrigin:true,success:function(T,U,S){Q.success.call(Q,Q.parse.result(T))},error:function(S,U,T){Q.error.call(Q,Q.parse.error(S.responseText))}})}}return D}());r.getCallbacks=function(E,C){var D;if(typeof E!=="function"&&typeof C!=="function"){D=new i.Promise(function(G,F){E=function(H){G(H)};C=function(H){F(H)}})}return{promise:D,success:E,error:C}};function t(C,F,D){var E=r.getCallbacks(F,D);C(E.success,E.error);return E.promise}function y(C,D){return function(G,E){var F=G.result;if(z.isArray(C)||typeof C.length==="number"){z.each(C,function(I,H){z.extend(I,F[H])})}else{z.extend(C,F)}D(G,E)}}function j(C,D){return function(F){var E=F.ModifiedAt;C.ModifiedAt=E;D(F)}}function d(C,D){this.setup=C;this.collectionName=D;this.options=null}d.prototype={withHeaders:function(D){var C=this.options||{};C.headers=z.extend(C.headers||{},D);this.options=C;return this},expand:function(D){var C={"X-Everlive-Expand":JSON.stringify(D)};return this.withHeaders(C)},_createRequest:function(C){z.extend(C,this.options);this.options=null;return new u(this.setup,C)},get:function(E,F,D){var C=this;return t(function(I,G){var H=C._createRequest({method:"GET",endpoint:C.collectionName,filter:E,success:I,error:G});H.send()},F,D)},getById:function(F,E,D){var C=this;return t(function(I,G){var H=C._createRequest({method:"GET",endpoint:C.collectionName+"/"+F,parse:u.parsers.single,success:I,error:G});H.send()},E,D)},count:function(E,F,D){var C=this;return t(function(I,G){var H=C._createRequest({method:"GET",endpoint:C.collectionName+"/_count",filter:E,parse:u.parsers.single,success:I,error:G});H.send()},F,D)},create:function(E,F,D){var C=this;return t(function(I,G){var H=C._createRequest({method:"POST",endpoint:C.collectionName,data:E,parse:u.parsers.single,success:y(E,I),error:G});H.send()},F,D)},rawUpdate:function(E,F,G,D){var C=this;return t(function(L,I){var K=C.collectionName;var H=null;if(typeof F==="string"){K+="/"+F}else{if(typeof F==="object"){H=F}}var J=C._createRequest({method:"PUT",endpoint:K,data:E,filter:H,success:L,error:I});J.send()},G,D)},_update:function(E,G,I,F,H,D){var C=this;return t(function(O,J){var N=C.collectionName;var L=O;if(I){N+="/"+E[g];L=j(E,O)}var M={};M[F?"$replace":"$set"]=E;var K=C._createRequest({method:"PUT",endpoint:N,parse:u.parsers.update,data:M,filter:G,success:L,error:J});K.send()},H,D)},updateSingle:function(D,E,C){return this._update(D,null,true,false,E,C)},update:function(D,E,F,C){return this._update(D,E,false,false,F,C)},_destroy:function(E,F,H,G,D){var C=this;return t(function(L,I){var K=C.collectionName;if(H){K+="/"+E[g]}var J=C._createRequest({method:"DELETE",endpoint:K,filter:F,success:L,error:I});J.send()},G,D)},destroySingle:function(D,E,C){return this._destroy(D,null,true,E,C)},destroy:function(D,E,C){return this._destroy(null,D,false,E,C)},setAcl:function(G,E,F,D){var C=this;return t(function(L,H){var K=C.collectionName;if(typeof E==="string"){K+="/"+E}else{if(typeof E==="object"){K+="/"+E[g]}}K+="/_acl";var M,J;if(G===null){M="DELETE"}else{M="PUT";J=G}var I=C._createRequest({method:M,endpoint:K,data:J,success:L,error:H});I.send()},F,D)},setOwner:function(C,F,G,E){var D=this;return t(function(K,H){var J=D.collectionName;if(typeof F==="string"){J+="/"+F}else{if(typeof F==="object"){J+="/"+F[g]}}J+="/_owner";var I=D._createRequest({method:"PUT",endpoint:J,data:{Owner:C},success:K,error:H});I.send()},G,E)},save:function(F,G,E){var D=this;var C=this.isNew(F);return t(function(K,H){function J(L){L.type=C?"create":"update";K(L)}function I(L){L.type=C?"create":"update";H(L)}if(C){return D.create(F,J,I)}else{return D.updateSingle(F,J,I)}},G,E)},isNew:function(C){return typeof C[g]==="undefined"}};r.Data=d;function l(C,D){this.longitude=C||0;this.latitude=D||0}r.GeoPoint=l;var e={unauthenticated:"unauthenticated",masterKey:"masterKey",invalidAuthentication:"invalidAuthentication",authenticated:"authenticated"};r.AuthStatus=e;function h(C,F,H,E){if(C.masterKey){return t(function(J,I){J({status:e.masterKey})},H,E)}if(!C.token){return t(function(J,I){J({status:e.unauthenticated})},H,E)}var D;if(H){D=function(I){if(I&&I.code===601){H({status:e.invalidAuthentication})}else{E(I)}}}var G=F(H,D);if(G){G=G.then(function(I){return{status:e.authenticated,user:I.result}},function(I){if(I&&I.code===601){return{status:e.invalidAuthentication}}else{throw I}})}return G}r.prototype.authInfo=function(D,C){return h(this.setup,z.bind(this.Users.getById,this.Users,"me"),D,C)};var c=function(C){C._loginSuccess=function(F){var E=F.result;var D=this.setup;D.token=E.access_token;D.tokenType=E.token_type};C._logoutSuccess=function(){var D=this.setup;D.token=null;D.tokenType=null};C.register=function(I,G,F,H,E){a(I,"username");a(G,"password");var D={Username:I,Password:G};z.extend(D,F);return this.create(D,H,E)};C.login=function(H,F,G,E){var D=this;return t(function(K,I){var J=new u(D.setup,{method:"POST",endpoint:"oauth/token",data:{username:H,password:F,grant_type:"password"},authHeaders:false,parse:u.parsers.single,success:function(){D._loginSuccess.apply(D,arguments);K.apply(null,arguments)},error:I});J.send()},G,E)};C.currentUser=function(F,E){var D=this;return t(function(H,G){h(D.setup,z.bind(D.getById,D,"me")).then(function(I){if(typeof I.user!=="undefined"){H({result:I.user})}else{H({result:null})}},function(I){G(I)})},F,E)};C.changePassword=function(J,F,I,G,H,E){var D=this;return t(function(N,K){var M="Users/changepassword";if(G){M+="?keepTokens=true"}var L=new u(D.setup,{method:"POST",endpoint:M,data:{Username:J,Password:F,NewPassword:I},authHeaders:false,parse:u.parsers.single,success:N,error:K});L.send()},H,E)};C.logout=function(F,E){var D=this;return t(function(I,G){var H=new u(D.setup,{method:"GET",endpoint:"oauth/logout",success:function(){D._logoutSuccess.apply(D,arguments);I.apply(null,arguments)},error:G});H.send()},F,E)};C._loginWithProvider=function(F,H,G){var E={Identity:F};var D=this;return t(function(K,I){var J=new u(D.setup,{method:"POST",endpoint:"Users",data:E,authHeaders:false,parse:u.parsers.single,success:function(){D._loginSuccess.apply(D,arguments);K.apply(null,arguments)},error:I});J.send()},H,G)};C._linkWithProvider=function(E,G,H,F){var D=this;return t(function(K,I){var J=new u(D.setup,{method:"POST",endpoint:"Users/"+G+"/link",data:E,parse:u.parsers.single,success:K,error:I});J.send()},H,F)};C._unlinkFromProvider=function(H,G,I,F){var E={Provider:H};var D=this;return t(function(L,J){var K=new u(D.setup,{method:"POST",endpoint:"Users/"+G+"/unlink",data:E,parse:u.parsers.single,success:L,error:J});K.send()},I,F)};C.loginWithFacebook=function(F,G,E){var D={Provider:"Facebook",Token:F};return C._loginWithProvider(D,G,E)};C.linkWithFacebook=function(G,F,H,E){var D={Provider:"Facebook",Token:F};return C._linkWithProvider(D,G,H,E)};C.unlinkFromFacebook=function(E,F,D){return C._unlinkFromProvider("Facebook",E,F,D)};C.loginWithADFS=function(F,G,E){var D={Provider:"ADFS",Token:F};return C._loginWithProvider(D,G,E)};C.linkWithADFS=function(G,F,H,E){var D={Provider:"ADFS",Token:F};return C._linkWithProvider(D,G,H,E)};C.unlinkFromADFS=function(E,F,D){return C._unlinkFromProvider("ADFS",E,F,D)};C.loginWithLiveID=function(F,G,E){var D={Provider:"LiveID",Token:F};return C._loginWithProvider(D,G,E)};C.linkWithLiveID=function(G,F,H,E){var D={Provider:"LiveID",Token:F};return C._linkWithProvider(D,G,H,E)};C.unlinkFromLiveID=function(E,F,D){return C._unlinkFromProvider("LiveID",E,F,D)};C.loginWithGoogle=function(F,G,E){var D={Provider:"Google",Token:F};return C._loginWithProvider(D,G,E)};C.linkWithGoogle=function(G,F,H,E){var D={Provider:"Google",Token:F};return C._linkWithProvider(D,G,H,E)};C.unlinkFromGoogle=function(E,F,D){return C._unlinkFromProvider("Google",E,F,D)};C.loginWithTwitter=function(F,G,H,E){var D={Provider:"Twitter",Token:F,TokenSecret:G};return C._loginWithProvider(D,H,E)};C.linkWithTwitter=function(G,F,H,I,E){var D={Provider:"Twitter",Token:F,TokenSecret:H};return C._linkWithProvider(D,G,I,E)};C.unlinkFromTwitter=function(E,F,D){return C._unlinkFromProvider("Twitter",E,F,D)}};var n=function(C){C.getUploadUrl=function(){return r.buildUrl(this.setup)+this.collectionName};C.getDownloadUrl=function(D){return r.buildUrl(this.setup)+this.collectionName+"/"+D+"/Download"};C._getUpdateUrl=function(D){return this.collectionName+"/"+D+"/Content"};C.getUpdateUrl=function(D){return r.buildUrl(this.setup)+this._getUpdateUrl(D)};C.updateContent=function(D,G,H,F){var E=this;return t(function(L,I){var K=E._getUpdateUrl(D);var J=E._createRequest({method:"PUT",endpoint:K,data:G,success:L,error:I});J.send()},H,F)};C.getDownloadUrlById=function(D,G,F){var E=this;return t(function(J,H){var I=E._createRequest({method:"GET",endpoint:E.collectionName+"/"+D,parse:u.parsers.single,success:function(K){J(K.result.Uri)},error:H});I.send()},G,F)}};var A={WindowsPhone:1,Windows:2,Android:3,iOS:4,OSX:5,Blackberry:6,Nokia:7,Unknown:100};r.PushCallbacks={};var m=function(C){this._el=C;this._currentDevice;this.notifications=C.data("Push/Notifications");this.devices=C.data("Push/Devices")};m.prototype={currentDevice:function(C){if(!window.cordova){throw new Error("Error: currentDevice() can only be called from within a hybrid mobile app, after 'deviceready' event has been fired.")}if(!this._currentDevice){this._currentDevice=new b(this);this._currentDevice.emulatorMode=C}return this._currentDevice}};var o={iOS:{badge:true,sound:true,alert:true},android:{senderID:null},notificationCallbackAndroid:null,notificationCallbackIOS:null};var b=function(C){this._pushHandler=C;this._initSuccessCallback=null;this._initErrorCallback=null;this._globalFunctionSuffix=null;this.pushSettings=null;this.pushToken=null;this.isInitialized=false;this.isInitializing=false;this.emulatorMode=false};b.prototype={enableNotifications:function(C,E,D){this.pushSettings=C;return t(z.bind(this._initialize,this),E,D)},disableNotifications:function(E,D){var C=this;return this.unregister().then(function(){return t(function(H,G){if(C.emulatorMode){H()}else{var F=window.plugins.pushNotification;F.unregister(function(){C.isInitialized=false;H()},G)}},E,D)},D)},getRegistration:function(E,C){var D=this._getDeviceId();return this._pushHandler.devices.getById("HardwareId/"+D,E,C)},register:function(D,G,E){var C=this;var F={};if(D!==undefined){F.Parameters=D}return this._populateRegistrationObject(F).then(function(){return C._pushHandler.devices.create(F,G,E)},E)},unregister:function(E,C){var D=device.uuid;return this._pushHandler.devices.destroySingle({Id:"HardwareId/"+D},E,C)},updateRegistration:function(D,G,E){var C=this;var F={};if(D!==undefined){F.Parameters=D}return this._populateRegistrationObject(F).then(function(){F.Id="HardwareId/"+F.HardwareId;return C._pushHandler.devices.updateSingle(F,G,E)},E)},_initialize:function(N,L){var P=this;if(this.isInitializing){L(new Error("Push notifications are currently initializing."));return}if(!this.emulatorMode&&(!window.plugins||!window.plugins.pushNotification)){L(new Error("The push notifications plugin is not initialized."));return}if(!this.emulatorMode&&(!window.navigator||!window.navigator.globalization)){L(new Error("The globalization plugin is not initialized."));return}this._initSuccessCallback=N;this._initErrorCallback=L;if(this.isInitialized){this._deviceRegistrationSuccess(this.pushToken);return}if(this.emulatorMode){setTimeout(function(){P._deviceRegistrationSuccess("fake_push_token")},1000);return}this.isInitializing=true;var O=this._globalFunctionSuffix;if(!O){O=Date.now().toString();this._globalFunctionSuffix=O}var D=window.plugins.pushNotification;var G=this._getPlatformType(device.platform);if(G===A.iOS){var I="apnCallback_"+O;r.PushCallbacks[I]=z.bind(this._onNotificationAPN,this);var K=this.pushSettings.iOS;this._validateIOSSettings(K);K.ecb="Everlive.PushCallbacks."+I;D.register(z.bind(this._successfulRegistrationAPN,this),z.bind(this._failedRegistrationAPN,this),K)}else{if(G===A.Android){var C="gcmCallback_"+O;r.PushCallbacks[C]=z.bind(this._onNotificationGCM,this);var F=this.pushSettings.android;this._validateAndroidSettings(F);F.ecb="Everlive.PushCallbacks."+C;D.register(z.bind(this._successSentRegistrationGCM,this),z.bind(this._errorSentRegistrationGCM,this),F)}else{if(G===A.WindowsPhone){var H="wp8Callback_"+O;var M="wp8RegistrationSuccessCallback_"+O;var E="wp8RegistrationErrorCallback_"+O;r.PushCallbacks[H]=z.bind(this._onNotificationWP8,this);r.PushCallbacks[M]=z.bind(this._deviceRegistrationSuccessWP,this);r.PushCallbacks[E]=z.bind(this._deviceRegistrationFailed,this);var J=this.pushSettings.wp8;this._validateWP8Settings(J);J.ecb="Everlive.PushCallbacks."+H;J.uccb="Everlive.PushCallbacks."+M;J.errcb="Everlive.PushCallbacks."+E;D.register(z.bind(this._successSentRegistrationWP8,this),z.bind(this._errorSentRegistrationWP8,this),J)}else{throw new Error("The current platform is not supported: "+device.platform)}}}},_deviceRegistrationSuccessWP:function(C){this._deviceRegistrationSuccess(C.uri)},_validateAndroidSettings:function(C){if(!C.senderID){throw new Error("Sender ID (project number) is not set in the android settings.")}},_validateWP8Settings:function(C){if(!C.channelName){throw new Error("channelName is not set in the WP8 settings.")}},_validateIOSSettings:function(C){},_populateRegistrationObject:function(E,F,D){var C=this;return t(function(H,G){if(!C.pushToken){throw new Error("Push token is not available.")}C._getLocaleName(function(I){var O=C._getDeviceId();var M=device.name;var K=C._getPlatformType(device.platform);var L=f.determine().name();var J=C.pushToken;var P=I.value;var N=device.version;E.HardwareId=O;E.HardwareModel=M;E.PlatformType=K;E.PlatformVersion=N;E.TimeZone=L;E.PushToken=J;E.Locale=P;H()},G)},F,D)},_getLocaleName:function(D,C){if(this.emulatorMode){D({value:"en_US"})}else{navigator.globalization.getLocaleName(function(E){D(E)},C);navigator.globalization.getLocaleName(function(E){},C)}},_getDeviceId:function(){return device.uuid},_getPlatformType:function(D){var C=D.toLowerCase();switch(C){case"ios":case"iphone":case"ipad":return A.iOS;case"android":return A.Android;case"wince":return A.WindowsPhone;case"win32nt":return A.WindowsPhone;default:return A.Unknown}},_deviceRegistrationFailed:function(C){this.pushToken=null;this.isInitializing=false;this.isInitialized=false;if(this._initErrorCallback){this._initErrorCallback({error:C})}},_deviceRegistrationSuccess:function(C){this.pushToken=C;this.isInitializing=false;this.isInitialized=true;if(this._initSuccessCallback){this._initSuccessCallback({token:C})}},_successfulRegistrationAPN:function(C){this._deviceRegistrationSuccess(C)},_failedRegistrationAPN:function(C){this._deviceRegistrationFailed(C)},_successSentRegistrationGCM:function(C){},_successSentRegistrationWP8:function(C){},_errorSentRegistrationWP8:function(C){this._deviceRegistrationFailed(C)},_errorSentRegistrationGCM:function(C){this._deviceRegistrationFailed(C)},_onNotificationAPN:function(C){this._raiseNotificationEventIOS(C)},_onNotificationWP8:function(C){this._raiseNotificationEventWP8(C)},_onNotificationGCM:function w(C){switch(C.event){case"registered":if(C.regid.length>0){this._deviceRegistrationSuccess(C.regid)}break;case"message":this._raiseNotificationEventAndroid(C);break;case"error":if(!this.pushToken){this._deviceRegistrationFailed(C)}else{this._raiseNotificationEventAndroid(C)}break;default:this._raiseNotificationEventAndroid(C);break}},_raiseNotificationEventAndroid:function(C){if(this.pushSettings.notificationCallbackAndroid){this.pushSettings.notificationCallbackAndroid(C)}},_raiseNotificationEventIOS:function(C){if(this.pushSettings.notificationCallbackIOS){this.pushSettings.notificationCallbackIOS(C)}},_raiseNotificationEventWP8:function(C){if(this.pushSettings.notificationCallbackWP8){this.pushSettings.notificationCallbackWP8(C)}}};var x=function(){this.Users=this.data("Users");c(this.Users);this.Files=this.data("Files");n(this.Files);this.push=new m(this)};s.push({name:"default",func:x});return r})); (function(a,b){if(typeof define==="function"&&define.amd){define(["Everlive"],function(c){b(c)})}else{b(a.Everlive)}}(this,function(n){var h=window.jQuery,j=window.kendo;if(h===undefined||j===undefined){return}var i=h.extend;i(true,j.data,{schemas:{everlive:{type:"json",data:function(o){if(typeof o.ModifiedAt!=="undefined"){return{ModifiedAt:o.ModifiedAt}}else{return o.Result||o}},total:"Count",model:{id:"Id"}}},transports:{everlive:{read:{dataType:"json",type:"GET",cache:false},update:{dataType:"json",contentType:"application/json",type:"PUT",cache:false},create:{dataType:"json",contentType:"application/json",type:"POST",cache:false},destroy:{dataType:"json",type:"DELETE",cache:false},parameterMap:function(p,o){if(o==="destroy"){return{}}if(o==="create"||o==="update"){return JSON.stringify(p)}if(o==="read"){return null}}}}});function l(s){var o={};if(s){if(s.skip){o.$skip=s.skip;delete s.skip}if(s.take){o.$take=s.take;delete s.take}if(s.sort){var r=s.sort;var p={};if(!h.isArray(r)){r=[r]}h.each(r,function(t,u){p[u.field]=u.dir==="asc"?1:-1});o.$sort=p;delete s.sort}if(s.filter){var q=new k().build(s.filter);o.$where=q;delete s.filter}}return o}var m=["startswith","startsWith","endswith","endsWith","contains"];function k(){}k.prototype={build:function(o){return this._build(o)},_build:function(o){if(this._isRaw(o)){return this._raw(o)}else{if(this._isSimple(o)){return this._simple(o)}else{if(this._isRegex(o)){return this._regex(o)}else{if(this._isAnd(o)){return this._and(o)}else{if(this._isOr(o)){return this._or(o)}}}}}},_isRaw:function(o){return o.operator==="_raw"},_raw:function(p){var o={};o[p.field]=p.value;return o},_isSimple:function(o){return typeof o.logic==="undefined"&&!this._isRegex(o)},_simple:function(r){var q={},o={};var p=this._translateoperator(r.operator);if(p){q[p]=r.value}else{q=r.value}o[r.field]=q;return o},_isRegex:function(o){return h.inArray(o.operator,m)!==-1},_regex:function(q){var o={};var r=this._getRegex(q);var p=this._getRegexValue(r);o[q.field]=p;return o},_getRegex:function(p){var q=p.value;var o=p.operator;switch(o){case"contains":return new RegExp(".*"+q+".*","i");case"startsWith":case"startswith":return new RegExp("^"+q,"i");case"endsWith":case"endswith":return new RegExp(q+"$","i")}throw new Error("Unknown operator type.")},_getRegexValue:function(o){return n.QueryBuilder.prototype._getRegexValue.call(this,o)},_isAnd:function(o){return o.logic==="and"},_and:function(t){var s,p,r,o={};var q=t.filters;for(s=0,p=q.length;s=0;q--){var u={model:{hasChildren:f(r[q]),children:{type:"everlive",transport:{read:{url:e(s,r.slice(0,q+1)),headers:a(r[q])}},schema:u}}}}}var t={};t.type="everlive";t.transport={typeName:o},t.schema=u;i(true,t,p);return new j.data.HierarchicalDataSource(t)};n.createDataSource=function(p){p=p||{};var o=p.typeName;if(!o){throw new Error("You need to specify a 'typeName' in order to create a kendo DataSource.")}delete p.typeName;var q={};q.type="everlive";q.transport={typeName:o},i(true,q,p);return new j.data.DataSource(q)}}));