"&&!n?m.childNodes:[];for(g=o.length-1;g>=0;--g)J.nodeName(o[g],"tbody")&&!o[g].childNodes.length&&o[g].parentNode.removeChild(o[g])}!J.support.leadingWhitespace&&br.test(i)&&m.insertBefore(b.createTextNode(br.exec(i)[0]),m.firstChild),i=m.childNodes}var p;if(!J.support.appendChecked)if(i[0]&&typeof (p=i.length)=="number")for(g=0;g=0)return b+"px"}}}),J.support.opacity||(J.cssHooks.opacity={get:function(a,b){return bC.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?parseFloat(RegExp.$1)/100+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle;c.zoom=1;var e=J.isNaN(b)?"":"alpha(opacity="+b*100+")",f=d&&d.filter||c.filter||"";c.filter=bB.test(f)?f.replace(bB,e):f+" "+e}}),J(function(){J.support.reliableMarginRight||(J.cssHooks.marginRight={get:function(a,b){var c;return J.swap(a,{display:"inline-block"},function(){b?c=bM(a,"margin-right","marginRight"):c=a.style.marginRight}),c}})}),G.defaultView&&G.defaultView.getComputedStyle&&(bN=function(a,c){var d,e,f;c=c.replace(bE,"-$1").toLowerCase();if(!(e=a.ownerDocument.defaultView))return b;if(f=e.getComputedStyle(a,null))d=f.getPropertyValue(c),d===""&&!J.contains(a.ownerDocument.documentElement,a)&&(d=J.style(a,c));return d}),G.documentElement.currentStyle&&(bO=function(a,b){var c,d=a.currentStyle&&a.currentStyle[b],e=a.runtimeStyle&&a.runtimeStyle[b],f=a.style;return!bF.test(d)&&bG.test(d)&&(c=f.left,e&&(a.runtimeStyle.left=a.currentStyle.left),f.left=b==="fontSize"?"1em":d||0,d=f.pixelLeft+"px",f.left=c,e&&(a.runtimeStyle.left=e)),d===""?"auto":d}),bM=bN||bO,J.expr&&J.expr.filters&&(J.expr.filters.hidden=function(a){var b=a.offsetWidth,c=a.offsetHeight;return b===0&&c===0||!J.support.reliableHiddenOffsets&&(a.style.display||J.css(a,"display"))==="none"},J.expr.filters.visible=function(a){return!J.expr.filters.hidden(a)});var bQ=/%20/g,bR=/\[\]$/,bS=/\r?\n/g,bT=/#.*$/,bU=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,bV=/^(?:color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,bW=/^(?:about|app|app\-storage|.+\-extension|file|widget):$/,bX=/^(?:GET|HEAD)$/,bY=/^\/\//,bZ=/\?/,b$=/
+
+
+
+
+
+
+
diff --git a/test/model.test.js b/test/model.test.js
index 9db2517d..4e3e3c2e 100644
--- a/test/model.test.js
+++ b/test/model.test.js
@@ -164,6 +164,104 @@ test('Webstore Backend', function() {
equal("2009-01-01", docList.models[0].get('date'));
});
});
+ $.ajax.restore();
+});
+
+
+var dataProxyData = {
+ "data": [
+ [
+ "1",
+ "1950-01",
+ "34.73"
+ ],
+ [
+ "2",
+ "1950-02",
+ "34.73"
+ ],
+ [
+ "3",
+ "1950-03",
+ "34.73"
+ ],
+ [
+ "4",
+ "1950-04",
+ "34.73"
+ ],
+ [
+ "5",
+ "1950-05",
+ "34.73"
+ ],
+ [
+ "6",
+ "1950-06",
+ "34.73"
+ ],
+ [
+ "7",
+ "1950-07",
+ "34.73"
+ ],
+ [
+ "8",
+ "1950-08",
+ "34.73"
+ ],
+ [
+ "9",
+ "1950-09",
+ "34.73"
+ ],
+ [
+ "10",
+ "1950-10",
+ "34.73"
+ ]
+ ],
+ "fields": [
+ "__id__",
+ "date",
+ "price"
+ ],
+ "length": null,
+ "max_results": 10,
+ "url": "http://webstore.thedatahub.org/rufuspollock/gold_prices/data.csv"
+};
+
+test('DataProxy Backend', function() {
+ // needed only if not stubbing
+ // stop();
+ var backend = new recline.Model.BackendDataProxy({
+ url: 'http://webstore.thedatahub.org/rufuspollock/gold_prices/data.csv'
+ });
+ recline.Model.setBackend(backend);
+ dataset = backend.getDataset();
+
+ var stub = sinon.stub($, 'ajax', function(options) {
+ var partialUrl = 'jsonpdataproxy.appspot.com';
+ if (options.url.indexOf(partialUrl) != -1) {
+ return {
+ then: function(callback) {
+ callback(dataProxyData);
+ }
+ }
+ }
+ });
+
+ dataset.fetch().then(function(dataset) {
+ deepEqual(['__id__', 'date', 'price'], dataset.get('headers'));
+ equal(null, dataset.docCount)
+ dataset.getDocuments().then(function(docList) {
+ equal(10, docList.length)
+ equal("1950-01", docList.models[0].get('date'));
+ // needed only if not stubbing
+ start();
+ });
+ });
+ $.ajax.restore();
});
})(this.jQuery);
diff --git a/vendor/jquery.couch2.js b/vendor/jquery.couch2.js
deleted file mode 100755
index cd1fa8ca..00000000
--- a/vendor/jquery.couch2.js
+++ /dev/null
@@ -1,85 +0,0 @@
-(function($) {
-
- window.couch = {};
-
- var defaults = {
- headers: {"Accept":"application/json"},
- dataType:"json",
- contentType: "application/json",
- type: "GET",
- url: "/"
- };
-
- couch.errors = {
- forbidden: "You aren't allowed to do that."
- }
-
- couch.responseError = function(response) {
- if(_.isArray(response) && (response.length > 0) ) response = response[0];
- if (response.error) return couch.errors[response.error];
- }
-
- couch.request = function(opts) {
- var ajaxOpts = $.extend({}, defaults, opts)
- , dfd = $.Deferred()
- ;
-
- $.ajax(ajaxOpts).then(
- function(successResponse) {
- var error = couch.responseError(successResponse);
- if (error) app.emitter.emit(error, 'error');
- dfd.resolve(successResponse);
- },
- function(errorResponse) {
- app.emitter.emit("Fatal XHR Error", 'error');
- }
- )
-
- return dfd.promise();
- }
-
- couch.get = function(url) {
- return couch.request({url:url, type:'GET'});
- };
-
- couch.login = function(credentials) {
- return couch.request({
- url: "/_session",
- type: 'POST',
- data: JSON.stringify({name: credentials.username, password: credentials.password})
- })
- }
-
- couch.logout = function() {
- return couch.request({url: "/_session", type: 'DELETE'});
- }
-
- couch.session = function() {
- return couch.request({url: "/_session"});
- }
-
- couch.db = function(name, couchRoot) {
- if(!couchRoot) couchRoot = "";
- return {
- name: name,
- uri: couchRoot + "/" + encodeURIComponent(name) + "/",
-
- get: function(id) {
- return couch.request({url:this.uri + id, type:"GET"});
- },
-
- put: function(id, data) {
- return couch.request({url:this.uri + id, type:"PUT", data:data});
- },
-
- designDocs: function(opts) {
- return couch.request($.extend(defaults, {
- url: this.uri + "_all_docs",
- data: {startkey:'"_design/"', endkey:'"_design0"', include_docs:true}
- }));
- }
-
- };
- };
-
-})(jQuery);
\ No newline at end of file
diff --git a/vendor/microevent.js b/vendor/microevent.js
deleted file mode 100755
index 3e74d026..00000000
--- a/vendor/microevent.js
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * MicroEvent - to make any js object an event emitter (server or browser)
- *
- * - pure javascript - server compatible, browser compatible
- * - dont rely on the browser doms
- * - super simple - you get it immediatly, no mistery, no magic involved
- *
- * - create a MicroEventDebug with goodies to debug
- * - make it safer to use
-*/
-
-var MicroEvent = function(){}
-MicroEvent.prototype = {
- on : function(event, fct){
- this._events = this._events || {};
- this._events[event] = this._events[event] || [];
- this._events[event].push(fct);
- },
- clear : function(event, fct){
- this._events = this._events || {};
- if( event in this._events === false ) return;
- this._events[event].splice(this._events[event].indexOf(fct), 1);
- },
- trigger : function(event /* , args... */){
- this._events = this._events || {};
- if( event in this._events === false ) return;
- for(var i = 0; i < this._events[event].length; i++){
- this._events[event][i].apply(this, Array.prototype.slice.call(arguments, 1))
- }
- }
-};
-
-/**
- * mixin will delegate all MicroEvent.js function in the destination object
- *
- * - require('MicroEvent').mixin(Foobar) will make Foobar able to use MicroEvent
- *
- * @param {Object} the object which will support MicroEvent
-*/
-MicroEvent.mixin = function(destObject){
- var props = ['on', 'clear', 'trigger'];
- for(var i = 0; i < props.length; i ++){
- destObject.prototype[props[i]] = MicroEvent.prototype[props[i]];
- }
-}
-
-// export in common js
-if( typeof module !== "undefined" && ('exports' in module)){
- module.exports = MicroEvent
-}
\ No newline at end of file
diff --git a/vendor/sammy-0.6.3.min.js b/vendor/sammy-0.6.3.min.js
deleted file mode 100755
index b1970f45..00000000
--- a/vendor/sammy-0.6.3.min.js
+++ /dev/null
@@ -1,5 +0,0 @@
-// -- Sammy.js -- /sammy.js
-// http://sammyjs.org
-// Version: 0.6.3
-// Built: 2011-01-27 10:31:14 -0800
-(function(h,j){var o,g="([^/]+)",k=/:([\w\d]+)/g,l=/\?([^#]*)$/,c=function(p){return Array.prototype.slice.call(p)},d=function(p){return Object.prototype.toString.call(p)==="[object Function]"},m=function(p){return Object.prototype.toString.call(p)==="[object Array]"},i=function(p){return decodeURIComponent(p.replace(/\+/g," "))},b=encodeURIComponent,f=function(p){return String(p).replace(/&(?!\w+;)/g,"&").replace(//g,">").replace(/"/g,""")},n=function(p){return function(q,r){return this.route.apply(this,[p,q,r])}},a={},e=[];o=function(){var q=c(arguments),r,p;o.apps=o.apps||{};if(q.length===0||q[0]&&d(q[0])){return o.apply(o,["body"].concat(q))}else{if(typeof(p=q.shift())=="string"){r=o.apps[p]||new o.Application();r.element_selector=p;if(q.length>0){h.each(q,function(s,t){r.use(t)})}if(r.element_selector!=p){delete o.apps[p]}o.apps[r.element_selector]=r;return r}}};o.VERSION="0.6.3";o.addLogger=function(p){e.push(p)};o.log=function(){var p=c(arguments);p.unshift("["+Date()+"]");h.each(e,function(r,q){q.apply(o,p)})};if(typeof j.console!="undefined"){if(d(j.console.log.apply)){o.addLogger(function(){j.console.log.apply(j.console,arguments)})}else{o.addLogger(function(){j.console.log(arguments)})}}else{if(typeof console!="undefined"){o.addLogger(function(){console.log.apply(console,arguments)})}}h.extend(o,{makeArray:c,isFunction:d,isArray:m});o.Object=function(p){return h.extend(this,p||{})};h.extend(o.Object.prototype,{escapeHTML:f,h:f,toHash:function(){var p={};h.each(this,function(r,q){if(!d(q)){p[r]=q}});return p},toHTML:function(){var p="";h.each(this,function(r,q){if(!d(q)){p+=""+r+" "+q+"
"}});return p},keys:function(p){var q=[];for(var r in this){if(!d(this[r])||!p){q.push(r)}}return q},has:function(p){return this[p]&&h.trim(this[p].toString())!=""},join:function(){var q=c(arguments);var p=q.shift();return q.join(p)},log:function(){o.log.apply(o,arguments)},toString:function(p){var q=[];h.each(this,function(s,r){if(!d(r)||p){q.push('"'+s+'": '+r.toString())}});return"Sammy.Object: {"+q.join(",")+"}"}});o.HashLocationProxy=function(q,p){this.app=q;this.is_native=false;this._startPolling(p)};o.HashLocationProxy.prototype={bind:function(){var p=this,q=this.app;h(j).bind("hashchange."+this.app.eventNamespace(),function(s,r){if(p.is_native===false&&!r){o.log("native hash change exists, using");p.is_native=true;j.clearInterval(o.HashLocationProxy._interval)}q.trigger("location-changed")});if(!o.HashLocationProxy._bindings){o.HashLocationProxy._bindings=0}o.HashLocationProxy._bindings++},unbind:function(){h(j).unbind("hashchange."+this.app.eventNamespace());o.HashLocationProxy._bindings--;if(o.HashLocationProxy._bindings<=0){j.clearInterval(o.HashLocationProxy._interval)}},getLocation:function(){var p=j.location.toString().match(/^[^#]*(#.+)$/);return p?p[1]:""},setLocation:function(p){return(j.location=p)},_startPolling:function(r){var q=this;if(!o.HashLocationProxy._interval){if(!r){r=10}var p=function(){var s=q.getLocation();if(!o.HashLocationProxy._last_location||s!=o.HashLocationProxy._last_location){j.setTimeout(function(){h(j).trigger("hashchange",[true])},13)}o.HashLocationProxy._last_location=s};p();o.HashLocationProxy._interval=j.setInterval(p,r)}}};o.Application=function(p){var q=this;this.routes={};this.listeners=new o.Object({});this.arounds=[];this.befores=[];this.namespace=(new Date()).getTime()+"-"+parseInt(Math.random()*1000,10);this.context_prototype=function(){o.EventContext.apply(this,arguments)};this.context_prototype.prototype=new o.EventContext();if(d(p)){p.apply(this,[this])}if(!this._location_proxy){this.setLocationProxy(new o.HashLocationProxy(this,this.run_interval_every))}if(this.debug){this.bindToAllEvents(function(s,r){q.log(q.toString(),s.cleaned_type,r||{})})}};o.Application.prototype=h.extend({},o.Object.prototype,{ROUTE_VERBS:["get","post","put","delete"],APP_EVENTS:["run","unload","lookup-route","run-route","route-found","event-context-before","event-context-after","changed","error","check-form-submission","redirect","location-changed"],_last_route:null,_location_proxy:null,_running:false,element_selector:"body",debug:false,raise_errors:false,run_interval_every:50,template_engine:null,toString:function(){return"Sammy.Application:"+this.element_selector},$element:function(p){return p?h(this.element_selector).find(p):h(this.element_selector)},use:function(){var p=c(arguments),r=p.shift(),q=r||"";try{p.unshift(this);if(typeof r=="string"){q="Sammy."+r;r=o[r]}r.apply(this,p)}catch(s){if(typeof r==="undefined"){this.error("Plugin Error: called use() but plugin ("+q.toString()+") is not defined",s)}else{if(!d(r)){this.error("Plugin Error: called use() but '"+q.toString()+"' is not a function",s)}else{this.error("Plugin Error",s)}}}return this},setLocationProxy:function(p){var q=this._location_proxy;this._location_proxy=p;if(this.isRunning()){if(q){q.unbind()}this._location_proxy.bind()}},route:function(t,q,v){var s=this,u=[],p,r;if(!v&&d(q)){q=t;v=q;t="any"}t=t.toLowerCase();if(q.constructor==String){k.lastIndex=0;while((r=k.exec(q))!==null){u.push(r[1])}q=new RegExp("^"+q.replace(k,g)+"$")}if(typeof v=="string"){v=s[v]}p=function(w){var x={verb:w,path:q,callback:v,param_names:u};s.routes[w]=s.routes[w]||[];s.routes[w].push(x)};if(t==="any"){h.each(this.ROUTE_VERBS,function(x,w){p(w)})}else{p(t)}return this},get:n("get"),post:n("post"),put:n("put"),del:n("delete"),any:n("any"),mapRoutes:function(q){var p=this;h.each(q,function(r,s){p.route.apply(p,s)});return this},eventNamespace:function(){return["sammy-app",this.namespace].join("-")},bind:function(p,r,t){var s=this;if(typeof t=="undefined"){t=r}var q=function(){var w,u,v;w=arguments[0];v=arguments[1];if(v&&v.context){u=v.context;delete v.context}else{u=new s.context_prototype(s,"bind",w.type,v,w.target)}w.cleaned_type=w.type.replace(s.eventNamespace(),"");t.apply(u,[w,v])};if(!this.listeners[p]){this.listeners[p]=[]}this.listeners[p].push(q);if(this.isRunning()){this._listen(p,q)}return this},trigger:function(p,q){this.$element().trigger([p,this.eventNamespace()].join("."),[q]);return this},refresh:function(){this.last_location=null;this.trigger("location-changed");return this},before:function(p,q){if(d(p)){q=p;p={}}this.befores.push([p,q]);return this},after:function(p){return this.bind("event-context-after",p)},around:function(p){this.arounds.push(p);return this},isRunning:function(){return this._running},helpers:function(p){h.extend(this.context_prototype.prototype,p);return this},helper:function(p,q){this.context_prototype.prototype[p]=q;return this},run:function(p){if(this.isRunning()){return false}var q=this;h.each(this.listeners.toHash(),function(r,s){h.each(s,function(u,t){q._listen(r,t)})});this.trigger("run",{start_url:p});this._running=true;this.last_location=null;if(this.getLocation()==""&&typeof p!="undefined"){this.setLocation(p)}this._checkLocation();this._location_proxy.bind();this.bind("location-changed",function(){q._checkLocation()});this.bind("submit",function(s){var r=q._checkFormSubmission(h(s.target).closest("form"));return(r===false)?s.preventDefault():false});h(j).bind("beforeunload",function(){q.unload()});return this.trigger("changed")},unload:function(){if(!this.isRunning()){return false}var p=this;this.trigger("unload");this._location_proxy.unbind();this.$element().unbind("submit").removeClass(p.eventNamespace());h.each(this.listeners.toHash(),function(q,r){h.each(r,function(t,s){p._unlisten(q,s)})});this._running=false;return this},bindToAllEvents:function(q){var p=this;h.each(this.APP_EVENTS,function(r,s){p.bind(s,q)});h.each(this.listeners.keys(true),function(s,r){if(p.APP_EVENTS.indexOf(r)==-1){p.bind(r,q)}});return this},routablePath:function(p){return p.replace(l,"")},lookupRoute:function(s,q){var r=this,p=false;this.trigger("lookup-route",{verb:s,path:q});if(typeof this.routes[s]!="undefined"){h.each(this.routes[s],function(u,t){if(r.routablePath(q).match(t.path)){p=t;return false}})}return p},runRoute:function(r,E,t,w){var s=this,C=this.lookupRoute(r,E),q,z,u,y,D,A,x,B,p;this.log("runRoute",[r,E].join(" "));this.trigger("run-route",{verb:r,path:E,params:t});if(typeof t=="undefined"){t={}}h.extend(t,this._parseQueryString(E));if(C){this.trigger("route-found",{route:C});if((B=C.path.exec(this.routablePath(E)))!==null){B.shift();h.each(B,function(F,G){if(C.param_names[F]){t[C.param_names[F]]=i(G)}else{if(!t.splat){t.splat=[]}t.splat.push(i(G))}})}q=new this.context_prototype(this,r,E,t,w);u=this.arounds.slice(0);D=this.befores.slice(0);x=[q].concat(t.splat);z=function(){var F;while(D.length>0){A=D.shift();if(s.contextMatchesOptions(q,A[0])){F=A[1].apply(q,[q]);if(F===false){return false}}}s.last_route=C;q.trigger("event-context-before",{context:q});F=C.callback.apply(q,x);q.trigger("event-context-after",{context:q});return F};h.each(u.reverse(),function(F,G){var H=z;z=function(){return G.apply(q,[H])}});try{p=z()}catch(v){this.error(["500 Error",r,E].join(" "),v)}return p}else{return this.notFound(r,E)}},contextMatchesOptions:function(s,u,q){var r=u;if(typeof r==="undefined"||r=={}){return true}if(typeof q==="undefined"){q=true}if(typeof r==="string"||d(r.test)){r={path:r}}if(r.only){return this.contextMatchesOptions(s,r.only,true)}else{if(r.except){return this.contextMatchesOptions(s,r.except,false)}}var p=true,t=true;if(r.path){if(d(r.path.test)){p=r.path.test(s.path)}else{p=(r.path.toString()===s.path)}}if(r.verb){t=r.verb===s.verb}return q?(t&&p):!(t&&p)},getLocation:function(){return this._location_proxy.getLocation()},setLocation:function(p){return this._location_proxy.setLocation(p)},swap:function(p){return this.$element().html(p)},templateCache:function(p,q){if(typeof q!="undefined"){return a[p]=q}else{return a[p]}},clearTemplateCache:function(){return a={}},notFound:function(r,q){var p=this.error(["404 Not Found",r,q].join(" "));return(r==="get")?p:true},error:function(q,p){if(!p){p=new Error()}p.message=[q,p.message].join(" ");this.trigger("error",{message:p.message,error:p});if(this.raise_errors){throw (p)}else{this.log(p.message,p)}},_checkLocation:function(){var p,q;p=this.getLocation();if(!this.last_location||this.last_location[0]!="get"||this.last_location[1]!=p){this.last_location=["get",p];q=this.runRoute("get",p)}return q},_getFormVerb:function(r){var q=h(r),s,p;p=q.find('input[name="_method"]');if(p.length>0){s=p.val()}if(!s){s=q[0].getAttribute("method")}if(!s||s==""){s="get"}return h.trim(s.toString().toLowerCase())},_checkFormSubmission:function(r){var p,s,u,t,q;this.trigger("check-form-submission",{form:r});p=h(r);s=p.attr("action");u=this._getFormVerb(p);this.log("_checkFormSubmission",p,s,u);if(u==="get"){this.setLocation(s+"?"+this._serializeFormParams(p));q=false}else{t=h.extend({},this._parseFormParams(p));q=this.runRoute(u,s,t,r.get(0))}return(typeof q=="undefined")?false:q},_serializeFormParams:function(q){var s="",p=q.serializeArray(),r;if(p.length>0){s=this._encodeFormPair(p[0].name,p[0].value);for(r=1;r
0){this.then(this.callbacks.shift())}},load:function(p,q,s){var r=this;return this.then(function(){var t,u,w,v;if(d(q)){s=q;q={}}else{q=h.extend({},q)}if(s){this.then(s)}if(typeof p==="string"){w=(p.match(/\.json$/)||q.json);t=((w&&q.cache===true)||q.cache!==false);r.next_engine=r.event_context.engineFor(p);delete q.cache;delete q.json;if(q.engine){r.next_engine=q.engine;delete q.engine}if(t&&(u=this.event_context.app.templateCache(p))){return u}this.wait();h.ajax(h.extend({url:p,data:{},dataType:w?"json":null,type:"get",success:function(x){if(t){r.event_context.app.templateCache(p,x)}r.next(x)}},q));return false}else{if(p.nodeType){return p.innerHTML}if(p.selector){r.next_engine=p.attr("data-engine");if(q.clone===false){return p.remove()[0].innerHTML.toString()}else{return p[0].innerHTML.toString()}}}})},render:function(p,q,r){if(d(p)&&!q){return this.then(p)}else{if(!q&&this.content){q=this.content}return this.load(p).interpolate(q,p).then(r)}},partial:function(p,q){return this.render(p,q).swap()},send:function(){var r=this,q=c(arguments),p=q.shift();if(m(q[0])){q=q[0]}return this.then(function(s){q.push(function(t){r.next(t)});r.wait();p.apply(p,q);return false})},collect:function(t,s,p){var r=this;var q=function(){if(d(t)){s=t;t=this.content}var u=[],v=false;h.each(t,function(w,y){var x=s.apply(r,[w,y]);if(x.jquery&&x.length==1){x=x[0];v=true}u.push(x);return x});return v?u:u.join("")};return p?q():this.then(q)},renderEach:function(p,q,r,s){if(m(q)){s=r;r=q;q=null}return this.load(p).then(function(u){var t=this;if(!r){r=m(this.previous_content)?this.previous_content:[]}if(s){h.each(r,function(v,x){var y={},w=this.next_engine||p;q?(y[q]=x):(y=x);s(x,t.event_context.interpolate(u,y,w))})}else{return this.collect(r,function(v,x){var y={},w=this.next_engine||p;q?(y[q]=x):(y=x);return this.event_context.interpolate(u,y,w)},true)}})},interpolate:function(s,r,p){var q=this;return this.then(function(u,t){if(!s&&t){s=t}if(this.next_engine){r=this.next_engine;this.next_engine=false}var v=q.event_context.interpolate(u,s,r);return p?t+v:v})},swap:function(){return this.then(function(p){this.event_context.swap(p)}).trigger("changed",{})},appendTo:function(p){return this.then(function(q){h(p).append(q)}).trigger("changed",{})},prependTo:function(p){return this.then(function(q){h(p).prepend(q)}).trigger("changed",{})},replace:function(p){return this.then(function(q){h(p).html(q)}).trigger("changed",{})},trigger:function(p,q){return this.then(function(r){if(typeof q=="undefined"){q={content:r}}this.event_context.trigger(p,q)})}});o.EventContext=function(t,s,q,r,p){this.app=t;this.verb=s;this.path=q;this.params=new o.Object(r);this.target=p};o.EventContext.prototype=h.extend({},o.Object.prototype,{$element:function(){return this.app.$element(c(arguments).shift())},engineFor:function(r){var q=this,p;if(d(r)){return r}r=(r||q.app.template_engine).toString();if((p=r.match(/\.([^\.]+)$/))){r=p[1]}if(r&&d(q[r])){return q[r]}if(q.app.template_engine){return this.engineFor(q.app.template_engine)}return function(s,t){return s}},interpolate:function(q,r,p){return this.engineFor(p).apply(this,[q,r])},render:function(p,q,r){return new o.RenderContext(this).render(p,q,r)},renderEach:function(p,q,r,s){return new o.RenderContext(this).renderEach(p,q,r,s)},load:function(p,q,r){return new o.RenderContext(this).load(p,q,r)},partial:function(p,q){return new o.RenderContext(this).partial(p,q)},send:function(){var p=new o.RenderContext(this);return p.send.apply(p,arguments)},redirect:function(){var r,q=c(arguments),p=this.app.getLocation();if(q.length>1){q.unshift("/");r=this.join.apply(this,q)}else{r=q[0]}this.trigger("redirect",{to:r});this.app.last_location=[this.verb,this.path];this.app.setLocation(r);if(p==r){this.app.trigger("location-changed")}},trigger:function(p,q){if(typeof q=="undefined"){q={}}if(!q.context){q.context=this}return this.app.trigger(p,q)},eventNamespace:function(){return this.app.eventNamespace()},swap:function(p){return this.app.swap(p)},notFound:function(){return this.app.notFound(this.verb,this.path)},json:function(p){return h.parseJSON(p)},toString:function(){return"Sammy.EventContext: "+[this.verb,this.path,this.params].join(" ")}});h.sammy=j.Sammy=o})(jQuery,window);