Commit 7a773a09 authored by Addy Osmani's avatar Addy Osmani

Merge pull request #41 from boushley/separateStorage

Separate storage fix
parents d3047151 95624f6e
angular.service('persistencejs', function() {
persistence.store.websql.config(persistence, 'todo', 'todo database', 5*1024*1024);
persistence.store.websql.config(persistence, 'todo-angular-persistence', 'todo database', 5*1024*1024);
var Todo = persistence.define('todo', {
content: 'TEXT',
done: 'BOOL'
......@@ -54,4 +54,4 @@ angular.service('persistencejs', function() {
});
},
};
});
\ No newline at end of file
});
......@@ -11,7 +11,7 @@ define([
model: Todo,
// Save all of the todo items under the `"todos"` namespace.
localStorage: new Store("todos"),
localStorage: new Store("todos-backbone-require"),
// Filter down the list of all todo items that are finished.
done: function() {
......
......@@ -48,7 +48,7 @@ $(function(){
model: Todo,
// Save all of the todo items under the `"todos"` namespace.
localStorage: new Store("todos"),
localStorage: new Store("todos-backbone"),
// Filter down the list of all todo items that are finished.
done: function() {
......
......@@ -3,6 +3,6 @@ Ext.define('Todo.model.Task', {
fields: ['id', 'label', {name: 'checked', type: 'boolean'}],
proxy: {
type: 'localstorage',
id: 'todo'
id: 'todos-extjs'
}
});
var localStoreName = 'todos-fidel';
var todoStore = (function() {
return {
get: function() {
var d = localStorage.getItem('fidel.todos');
var d = localStorage.getItem(localStoreName);
var todos = {};
if (d) {
d = JSON.parse(d);
......@@ -12,7 +13,7 @@ var todoStore = (function() {
return todos;
},
save: function(todos) {
localStorage.setItem('fidel.todos', JSON.stringify(todos));
localStorage.setItem(localStoreName, JSON.stringify(todos));
}
};
})();
......
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p,
blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em,
font, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var,
dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption,
tbody, tfoot, thead, tr, th, td {
margin:0;
padding:0;
}
body {
font-family: "Helvetica Neue", helvetica, arial, sans-serif;
font-size: 14px;
line-height: 1.4em;
background: #eeeeee;
color: #333333;
padding: 0px;
margin: 0px;
}
#todos {
-moz-box-shadow: rgba(0, 0, 0, 0.2) 0 2px 6px 0;
-webkit-box-shadow: rgba(0, 0, 0, 0.2) 0 2px 6px 0;
-o-box-shadow: rgba(0, 0, 0, 0.2) 0 2px 6px 0;
box-shadow: rgba(0, 0, 0, 0.2) 0 2px 6px 0;
-moz-border-radius: 0 0 5px 5px;
-o-border-radius: 0 0 5px 5px;
-webkit-border-radius: 0 0 5px 5px;
border-radius: 0 0 5px 5px;
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;
background-attachment: scroll;
margin: 0 auto 40px;
width: 520px;
background-color: white;
}
h1{
font-size: 36px;
font-weight: bold;
line-height: 1;
padding: 30px 0 10px;
text-align: center;
}
#todos .create {
border: 1px solid #999999;
-moz-box-shadow: rgba(0, 0, 0, 0.2) 0 1px 2px 0 inset;
-webkit-box-shadow: rgba(0, 0, 0, 0.2) 0 1px 2px 0 inset;
-o-box-shadow: rgba(0, 0, 0, 0.2) 0 1px 2px 0 inset;
box-shadow: rgba(0, 0, 0, 0.2) 0 1px 2px 0 inset; font-family: inherit;
font-size: 24px;
line-height: 1.4em;
outline: medium none;
padding: 6px;
width: 466px;
}
.content{
padding: 20px 20px 0;
}
#instructions {
color: #777777;
margin: 10px auto;
text-align: center;
text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
width: 520px;
}
#instructions li{
list-style-type:none;
}
.create, input.text {
font-size: 1.4em;
width: 100%;
}
ul {
margin: 0px;padding: 0px;
}
.todo {
list-style: none;
border-bottom: 1px solid #CCCCCC;
font-size: 24px;
padding: 15px 20px 15px 0;
position: relative;
margin-left: 15px;
}
.todo:hover .todestroy{
display:block;
}
#todo-stats {
background: none repeat scroll 0 0 #F4FCE8;
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;
border-top: 1px solid #EDEDED;
color: #555555;
line-height: 36px;
margin-top: 20px;
padding: 0 20px;
}
.todo-count .number {
color: #555555;
font-weight: bold;
}
#list {
margin-top: 20px;
}
.todestroy {
background: url("destroy.png") no-repeat scroll center center transparent;
cursor: pointer;
height: 20px;
position: absolute;
right: 0;
top: 16px;
width: 20px;
display:none;
margin-right: 20px;
}
.todo-clear {
float: right;
}
.todo-clear a {
display: block;
line-height: 20px;
text-decoration: none;
-moz-border-radius: 12px;
-webkit-border-radius: 12px;
-o-border-radius: 12px;
-ms-border-radius: 12px;
-khtml-border-radius: 12px;
border-radius: 12px;
background: rgba(0, 0, 0, 0.1);
color: #555555;
font-size: 11px;
margin-top: 8px;
padding: 0 10px 1px;
-moz-box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 0 0;
-webkit-box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 0 0;
-o-box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 0 0;
box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 0 0;
}
.todo-clear a:hover, .todo-clear a:focus {
background: rgba(0, 0, 0, 0.15);
}
#todoapp #todo-stats .todo-clear a:active {
position: relative;
top: 1px;
}
#credits {
color: #999999;
margin: 30px auto;
text-align: center;
text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
width: 520px;
}
#credits a {
color: #888888;
}
html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,font,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td{margin:0;padding:0}body{font-family:"Helvetica Neue",helvetica,arial,sans-serif;font-size:14px;line-height:1.4em;background:#eee;color:#333;padding:0;margin:0}#todos{-moz-box-shadow:rgba(0,0,0,0.2) 0 2px 6px 0;-webkit-box-shadow:rgba(0,0,0,0.2) 0 2px 6px 0;-o-box-shadow:rgba(0,0,0,0.2) 0 2px 6px 0;box-shadow:rgba(0,0,0,0.2) 0 2px 6px 0;-moz-border-radius:0 0 5px 5px;-o-border-radius:0 0 5px 5px;-webkit-border-radius:0 0 5px 5px;border-radius:0 0 5px 5px;border-bottom-left-radius:5px;border-bottom-right-radius:5px;background-attachment:scroll;margin:0 auto 40px;width:520px;background-color:white}h1{font-size:36px;font-weight:bold;line-height:1;padding:30px 0 10px;text-align:center}#todos .create{border:1px solid #999;-moz-box-shadow:rgba(0,0,0,0.2) 0 1px 2px 0 inset;-webkit-box-shadow:rgba(0,0,0,0.2) 0 1px 2px 0 inset;-o-box-shadow:rgba(0,0,0,0.2) 0 1px 2px 0 inset;box-shadow:rgba(0,0,0,0.2) 0 1px 2px 0 inset;font-family:inherit;font-size:24px;line-height:1.4em;outline:medium none;padding:6px;width:466px}.content{padding:20px 20px 0}#instructions{color:#777;margin:10px auto;text-align:center;text-shadow:0 1px 0 rgba(255,255,255,0.8);width:520px}#instructions li{list-style-type:none}.create,input.text{font-size:1.4em;width:100%}ul{margin:0;padding:0}.todo{list-style:none;border-bottom:1px solid #ccc;font-size:24px;padding:15px 20px 15px 0;position:relative;margin-left:15px}.todo:hover .todestroy{display:block}#todo-stats{background:none repeat scroll 0 0 #f4fce8;border-bottom-left-radius:5px;border-bottom-right-radius:5px;border-top:1px solid #ededed;color:#555;line-height:36px;margin-top:20px;padding:0 20px}.todo-count .number{color:#555;font-weight:bold}#list{margin-top:20px}.todestroy{background:url(destroy.png) no-repeat scroll center center transparent;cursor:pointer;height:20px;position:absolute;right:0;top:16px;width:20px;display:none;margin-right:20px}.todo-clear{float:right}.todo-clear a{display:block;line-height:20px;text-decoration:none;-moz-border-radius:12px;-webkit-border-radius:12px;-o-border-radius:12px;-ms-border-radius:12px;-khtml-border-radius:12px;border-radius:12px;background:rgba(0,0,0,0.1);color:#555;font-size:11px;margin-top:8px;padding:0 10px 1px;-moz-box-shadow:rgba(0,0,0,0.2) 0 -1px 0 0;-webkit-box-shadow:rgba(0,0,0,0.2) 0 -1px 0 0;-o-box-shadow:rgba(0,0,0,0.2) 0 -1px 0 0;box-shadow:rgba(0,0,0,0.2) 0 -1px 0 0}#credits{color:#999;margin:30px auto;text-align:center;text-shadow:0 1px 0 rgba(255,255,255,0.8);width:520px}#credits a{color:#888}
\ No newline at end of file
steal.css("todo").plugins("jquery/model/list","jquery/controller","jquery/view/ejs","jquery/lang/json").then(function(d){d.Model("Todo",{localStore:function(a){var b=this.shortName,c=d.evalJSON(window.localStorage[b]||(window.localStorage[b]="{}"));if(a.call(this,c)!==false)window.localStorage[b]=d.toJSON(c)},findAll:function(a,b){this.localStore(function(c){instances=[];for(var e in c)instances.push(new this(c[e]));b&&b(instances)})},destroyAll:function(a,b){this.localStore(function(c){d.each(a,
function(){delete c[this]})});b()},destroy:function(a,b){this.destroyAll(a,b);this.localStore(function(c){delete c[a]})},create:function(a,b){this.localStore(function(c){a.id=a.id||parseInt(1E5*Math.random());c[a.id]=a});b({id:a.id})},update:function(a,b,c){this.localStore(function(e){d.extend(e[a],b)});c({})}},{});d.Model.List("Todo.List",{completed:function(){return this.grep(function(a){return a.complete===true})}});d.Controller("Todos",{init:function(){this.find(".create").val("")[0].focus();
steal.css("todo").plugins("jquery/model/list","jquery/controller","jquery/view/ejs","jquery/lang/json").then(function(d){d.Model("Todo",{localStore:function(a){var b=d.evalJSON(window.localStorage["todo-javascriptmvc"]||(window.localStorage["todo-javascriptmvc"]="{}"));if(a.call(this,b)!==false)window.localStorage["todo-javascriptmvc"]=d.toJSON(b)},findAll:function(a,b){this.localStore(function(c){instances=[];for(var e in c)instances.push(new this(c[e]));b&&b(instances)})},destroyAll:function(a,
b){this.localStore(function(c){d.each(a,function(){delete c[this]})});b()},destroy:function(a,b){this.destroyAll(a,b);this.localStore(function(c){delete c[a]})},create:function(a,b){this.localStore(function(c){a.id=a.id||parseInt(1E5*Math.random());c[a.id]=a});b({id:a.id})},update:function(a,b,c){this.localStore(function(e){d.extend(e[a],b)});c({})}},{});d.Model.List("Todo.List",{completed:function(){return this.grep(function(a){return a.complete===true})}});d.Controller("Todos",{init:function(){this.find(".create").val("")[0].focus();
this.options.list.findAll()},"{list} add":function(a,b,c){this.find("#list").append("todosEJS",c);this.updateStats()},".create keyup":function(a,b){if(b.keyCode==13){(new Todo({text:a.val(),complete:false})).save(this.callback("created"));a.val("")}},created:function(a){this.options.list.push(a)},".todo-clear click":function(){this.options.list.completed().destroyAll()},".todo .todestroy click":function(a){a.closest(".todo").model().destroy()},"{list} remove":function(a,b,c){c.elements(this.element).slideUp(function(){d(this).remove()});
this.updateStats()},".todo [name=complete] change":function(a){a.closest(".todo").model().update({complete:a.is(":checked")})},".todo dblclick":function(a){var b=d("<input name='text' class='text'/>").val(a.model().text);a.html(b);b[0].focus()},".todo [name=text] focusout":function(a){a.closest(".todo").model().update({text:a.val()})},"{list} update":function(a,b,c){c.elements().html("todoEJS",c);this.updateStats()},updateStats:function(){var a=this.options.list,b=a.completed().length;d("#todo-stats").html("statsEJS",
{completed:b,total:a.length,remaining:a.length-b})}});d(function(){d("#todos").todos({list:new Todo.List})})});
{completed:b,total:a.length,remaining:a.length-b})}});d(function(){d("#todos").todos({list:new Todo.List})})});
;
steal.end();
steal.plugins("jquery/model").then(function(c){var k=function(a){return a[0]&&c.isArray(a[0])?a[0]:a[0]instanceof c.Model.List?c.makeArray(a[0]):c.makeArray(a)},m=0,j=jQuery.expando;c.Class.extend("jQuery.Model.List",{init:function(a){this.length=0;this._data={};this._namespace=".list"+ ++m;this.push.apply(this,c.makeArray(a||[]))},slice:function(){return new this.Class(Array.prototype.slice.apply(this,arguments))},match:function(a,b){return this.grep(function(d){return d[a]==b})},grep:function(a,
......@@ -10,7 +10,7 @@ b){return new this.Class(c.grep(this,a,b))},_makeData:function(){var a=this._dat
remove:function(a){if(!this.length)return[];var b=[],d=this[0].Class.id,g=new RegExp(this[0].Class._fullName+"_([^ ]+)"),i;a=k(arguments);for(var e=0;e<this.length;){for(var f=this[e],l=false,h=0;h<a.length;h++){var n=a[h].nodeName&&(i=a[h].className.match(g))&&i[1]||(typeof a[h]=="string"||typeof a[h]=="number"?a[h]:a[h][d]);if(f[d]==n){b.push.apply(b,this.splice(e,1));a.splice(h,1);l=true;break}}l||e++}b=new this.Class(b);b.length&&c([this]).trigger("remove",[b]);return b},publish:function(a,b){OpenAjax.hub.publish(this.Class.shortName+
"."+a,b)},elements:function(a){return c(this.map(function(b){return"."+b.identity()}).join(","),a)},model:function(){return this.Class.namespace},findAll:function(a,b,d){var g=this;this.model().findAll(a,function(i){g.push(i);b&&b(g)},d)},destroyAll:function(){var a=function(b){return b[b.Class.id]};ids=this.map(a);model=this.model();self=this;items=this.slice(0,this.length);destroy=function(){this.destroyed()};model.destroyAll?model.destroyAll(ids,function(){c.each(items,destroy)}):this.each(function(b,
d){model.destroy(a(d),function(){d.destroyed()})})},bind:function(){this[j]===undefined&&this.bindings(this);c.fn.bind.apply(c([this]),arguments);return this},unbind:function(){c.fn.unbind.apply(c([this]),arguments);this[j]===undefined&&c(this).unbind(this._namespace);return this},bindings:function(a){var b=this;c(a).bind("destroyed"+this._namespace,function(){b.remove(this)}).bind("updated"+this._namespace,function(){c([b]).trigger("update",this)})},push:function(){var a=k(arguments);this[j]!==undefined&&
this.bindings(a);this._changed=true;var b=o.apply(this,a);this[j]&&a.length&&c([this]).trigger("add",[a]);return b}});var o=[].push;c.each({pop:[].pop,shift:[].shift,unshift:[].unshift,splice:[].splice,sort:[].sort},function(a,b){c.Model.List.prototype[a]=function(){this._changed=true;return b.apply(this,arguments)}});c.each(["each","map"],function(a,b){c.Model.List.prototype[b]=function(d,g){return c[b](this,d,g)}})});
this.bindings(a);this._changed=true;var b=o.apply(this,a);this[j]&&a.length&&c([this]).trigger("add",[a]);return b}});var o=[].push;c.each({pop:[].pop,shift:[].shift,unshift:[].unshift,splice:[].splice,sort:[].sort},function(a,b){c.Model.List.prototype[a]=function(){this._changed=true;return b.apply(this,arguments)}});c.each(["each","map"],function(a,b){c.Model.List.prototype[b]=function(d,g){return c[b](this,d,g)}})});
;
steal.end();
steal.plugins("jquery/class","jquery/lang").then(function(){var m=$.String.underscore,w=$.String.classize,q=$.isArray,r=$.makeArray,o=$.extend,j=$.each,x=/GET|POST|PUT|DELETE/i,k=function(a,b,c,e,f,d,g){g=g||"json";var h="";if(typeof a=="string"){var i=a.indexOf(" ");if(i>2&&i<7){h=a.substr(0,i);if(x.test(h))d=h;else g=h;h=a.substr(i+1)}else h=a}b=o({},b);a=$.String.sub(h,b,true);return $.ajax({url:a,data:b,success:c,error:e,type:d||"post",dataType:g,fixture:f})},s=function(a,b){var c=m(this.shortName),
......@@ -25,13 +25,13 @@ var d=this[a],g=this,h=function(i){e&&e.call(g,i);$(g).triggerHandler("error."+a
b,c])}e&&e(this)}if(a===d.id&&b!==null&&d.list)if(c){if(c!=b){d.list.remove(c);d.list.push(this)}}else d.list.push(this)},attrs:function(a){var b;if(a){var c=this.Class.id;for(b in a)b!=c&&this.attr(b,a[b]);c in a&&this.attr(c,a[c])}else{a={};for(b in this.Class.attributes)if(this.Class.attributes.hasOwnProperty(b))a[b]=this.attr(b)}return a},isNew:function(){var a=n(this);return a===undefined||a===null},save:function(a,b){return u(this,this.isNew()?"create":"update",a,b)},destroy:function(a,b){return u(this,
"destroy",a,b,"destroyed")},identity:function(){var a=n(this);return this.Class._fullName+"_"+(this.Class.escapeIdentity?encodeURIComponent(a):a)},elements:function(a){return $("."+this.identity(),a)},publish:function(a,b){this.Class.publish(a,b||this)},hookup:function(a){var b=this.Class._shortName,c=$.data(a,"models")||$.data(a,"models",{});$(a).addClass(b+" "+this.identity());c[b]=this}});$.Model.wrapMany=$.Model.models;$.Model.wrap=$.Model.model;j(["created","updated","destroyed"],function(a,
b){$.Model.prototype[b]=function(c){b==="destroyed"&&this.Class.list&&this.Class.list.remove(n(this));c&&typeof c=="object"&&this.attrs(c.attrs?c.attrs():c);$(this).triggerHandler(b);this.publish(b,this);$([this.Class]).triggerHandler(b,this);return[this].concat(r(arguments))}});$.fn.models=function(){var a=[],b,c;this.each(function(){j($.data(this,"models")||{},function(e,f){b=b===undefined?f.Class.List||null:f.Class.List===b?b:null;a.push(f)})});c=t(b);c.push.apply(c,z(a));return c};$.fn.model=
function(a){if(a&&a instanceof $.Model){a.hookup(this[0]);return this}else return this.models.apply(this,arguments)[0]}});
function(a){if(a&&a instanceof $.Model){a.hookup(this[0]);return this}else return this.models.apply(this,arguments)[0]}});
;
steal.end();
steal.plugins("jquery","jquery/lang").then(function(i){var k=false,p=i.makeArray,q=i.isFunction,m=i.isArray,n=i.extend,r=function(a,c){return a.concat(p(c))},t=/xyz/.test(function(){})?/\b_super\b/:/.*/,s=function(a,c,d){d=d||a;for(var b in a)d[b]=q(a[b])&&q(c[b])&&t.test(a[b])?function(g,h){return function(){var f=this._super,e;this._super=c[g];e=h.apply(this,arguments);this._super=f;return e}}(b,a[b]):a[b]},j=i.Class=function(){arguments.length&&j.extend.apply(j,arguments)};n(j,{callback:function(a){var c=
p(arguments),d;a=c.shift();m(a)||(a=[a]);d=this;return function(){for(var b=r(c,arguments),g,h=a.length,f=0,e;f<h;f++)if(e=a[f]){if((g=typeof e=="string")&&d._set_called)d.called=e;b=(g?d[e]:e).apply(d,b||[]);if(f<h-1)b=!m(b)||b._use_call?[b]:b}return b}},getObject:i.String.getObject,newInstance:function(){var a=this.rawInstance(),c;if(a.setup)c=a.setup.apply(a,arguments);if(a.init)a.init.apply(a,m(c)?c:arguments);return a},setup:function(a){this.defaults=n(true,{},a.defaults,this.defaults);return arguments},
rawInstance:function(){k=true;var a=new this;k=false;return a},extend:function(a,c,d){function b(){if(!k)return this.constructor!==b&&arguments.length?arguments.callee.extend.apply(arguments.callee,arguments):this.Class.newInstance.apply(this.Class,arguments)}if(typeof a!="string"){d=c;c=a;a=null}if(!d){d=c;c=null}d=d||{};var g=this,h=this.prototype,f,e,l,o;k=true;o=new this;k=false;s(d,h,o);for(f in this)if(this.hasOwnProperty(f))b[f]=this[f];s(c,this,b);if(a){l=a.split(/\./);e=l.pop();l=h=j.getObject(l.join("."),
window,true);h[e]=b}n(b,{prototype:o,namespace:l,shortName:e,constructor:b,fullName:a});b.prototype.Class=b.prototype.constructor=b;g=b.setup.apply(b,r([g],arguments));if(b.init)b.init.apply(b,g||[]);return b}});j.prototype.callback=j.callback})();
window,true);h[e]=b}n(b,{prototype:o,namespace:l,shortName:e,constructor:b,fullName:a});b.prototype.Class=b.prototype.constructor=b;g=b.setup.apply(b,r([g],arguments));if(b.init)b.init.apply(b,g||[]);return b}});j.prototype.callback=j.callback})();
;
steal.end();
(function(E,v){function wa(a,b,d){if(d===v&&a.nodeType===1){d="data-"+b.replace(gb,"$1-$2").toLowerCase();d=a.getAttribute(d);if(typeof d==="string"){try{d=d==="true"?true:d==="false"?false:d==="null"?null:!c.isNaN(d)?parseFloat(d):hb.test(d)?c.parseJSON(d):d}catch(e){}c.data(a,b,d)}else d=v}return d}function ia(a){for(var b in a)if(b!=="toJSON")return false;return true}function xa(a,b,d){var e=b+"defer",f=b+"queue",g=b+"mark",i=c.data(a,e,v,true);if(i&&(d==="queue"||!c.data(a,f,v,true))&&(d==="mark"||
......@@ -212,12 +212,12 @@ c.offset.initialize=c.noop},bodyOffset:function(a){var b=a.offsetTop,d=a.offsetL
l=n.left}else{e=parseFloat(i)||0;l=parseFloat(l)||0}if(c.isFunction(b))b=b.call(a,d,g);if(b.top!=null)m.top=b.top-g.top+e;if(b.left!=null)m.left=b.left-g.left+l;"using"in b?b.using.call(a,m):f.css(m)}};c.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),d=this.offset(),e=fb.test(b[0].nodeName)?{top:0,left:0}:b.offset();d.top-=parseFloat(c.css(a,"marginTop"))||0;d.left-=parseFloat(c.css(a,"marginLeft"))||0;e.top+=parseFloat(c.css(b[0],"borderTopWidth"))||0;
e.left+=parseFloat(c.css(b[0],"borderLeftWidth"))||0;return{top:d.top-e.top,left:d.left-e.left}},offsetParent:function(){return this.map(function(){for(var a=this.offsetParent||x.body;a&&!fb.test(a.nodeName)&&c.css(a,"position")==="static";)a=a.offsetParent;return a})}});c.each(["Left","Top"],function(a,b){var d="scroll"+b;c.fn[d]=function(e){var f,g;if(e===v){f=this[0];if(!f)return null;return(g=na(f))?"pageXOffset"in g?g[a?"pageYOffset":"pageXOffset"]:c.support.boxModel&&g.document.documentElement[d]||
g.document.body[d]:f[d]}return this.each(function(){if(g=na(this))g.scrollTo(!a?e:c(g).scrollLeft(),a?e:c(g).scrollTop());else this[d]=e})}});c.each(["Height","Width"],function(a,b){var d=b.toLowerCase();c.fn["inner"+b]=function(){return this[0]?parseFloat(c.css(this[0],d,"padding")):null};c.fn["outer"+b]=function(e){return this[0]?parseFloat(c.css(this[0],d,e?"margin":"border")):null};c.fn[d]=function(e){var f=this[0];if(!f)return e==null?null:this;if(c.isFunction(e))return this.each(function(i){var l=
c(this);l[d](e.call(this,i,l[d]()))});if(c.isWindow(f)){var g=f.document.documentElement["client"+b];return f.document.compatMode==="CSS1Compat"&&g||f.document.body["client"+b]||g}else if(f.nodeType===9)return Math.max(f.documentElement["client"+b],f.body["scroll"+b],f.documentElement["scroll"+b],f.body["offset"+b],f.documentElement["offset"+b]);else if(e===v){f=c.css(f,d);g=parseFloat(f);return c.isNaN(g)?f:g}else return this.css(d,typeof e==="string"?e:e+"px")}});E.jQuery=E.$=c})(window);
c(this);l[d](e.call(this,i,l[d]()))});if(c.isWindow(f)){var g=f.document.documentElement["client"+b];return f.document.compatMode==="CSS1Compat"&&g||f.document.body["client"+b]||g}else if(f.nodeType===9)return Math.max(f.documentElement["client"+b],f.body["scroll"+b],f.documentElement["scroll"+b],f.body["offset"+b],f.documentElement["offset"+b]);else if(e===v){f=c.css(f,d);g=parseFloat(f);return c.isNaN(g)?f:g}else return this.css(d,typeof e==="string"?e:e+"px")}});E.jQuery=E.$=c})(window);
;
steal.end();
steal.plugins("jquery").then(function(j){var g={undHash:/_|-/,colons:/::/,words:/([A-Z]+)([A-Z][a-z])/g,lowUp:/([a-z\d])([A-Z])/g,dash:/([a-z\d])([A-Z])/g,replacer:/\{([^\}]+)\}/g,dot:/\./},l=function(a,c,b){return a[c]||b&&(a[c]={})},m=function(a){return(a=typeof a)&&(a=="function"||a=="object")},n=function(a,c,b){a=a?a.split(g.dot):[];var f=a.length;c=j.isArray(c)?c:[c||window];var d,e,h,o=0;if(f==0)return c[0];for(;d=c[o++];){for(h=0;h<f-1&&m(d);h++)d=l(d,a[h],b);if(m(d)){e=l(d,a[h],b);if(e!==
undefined){b===false&&delete d[a[h]];return e}}}},k=j.String=j.extend(j.String||{},{getObject:n,capitalize:function(a){return a.charAt(0).toUpperCase()+a.substr(1)},camelize:function(a){a=k.classize(a);return a.charAt(0).toLowerCase()+a.substr(1)},classize:function(a,c){a=a.split(g.undHash);for(var b=0;b<a.length;b++)a[b]=k.capitalize(a[b]);return a.join(c||"")},niceName:function(){k.classize(parts[i]," ")},underscore:function(a){return a.replace(g.colons,"/").replace(g.words,"$1_$2").replace(g.lowUp,
"$1_$2").replace(g.dash,"_").toLowerCase()},sub:function(a,c,b){var f=[];f.push(a.replace(g.replacer,function(d,e){d=n(e,c,typeof b=="boolean"?!b:b);e=typeof d;if((e==="object"||e==="function")&&e!==null){f.push(d);return""}else return""+d}));return f.length<=1?f[0]:f}})});
"$1_$2").replace(g.dash,"_").toLowerCase()},sub:function(a,c,b){var f=[];f.push(a.replace(g.replacer,function(d,e){d=n(e,c,typeof b=="boolean"?!b:b);e=typeof d;if((e==="object"||e==="function")&&e!==null){f.push(d);return""}else return""+d}));return f.length<=1?f[0]:f}})});
;
steal.end();
steal.plugins("jquery/class","jquery/lang","jquery/event/destroyed").then(function(e){var u=function(a,b,c){var d,f=a.bind&&a.unbind?a:e(j(a)?[a]:a);if(b.indexOf(">")===0){b=b.substr(1);d=function(g){g.target===a&&c.apply(this,arguments)}}f.bind(b,d||c);return function(){f.unbind(b,d||c);a=b=c=d=null}},p=e.makeArray,v=e.isArray,j=e.isFunction,k=e.extend,q=e.String,w=function(a,b,c,d){e(a).delegate(b,c,d);return function(){e(a).undelegate(b,c,d);a=c=d=b=null}},r=function(a,b,c,d){return d?w(a,d,b,
......@@ -227,13 +227,13 @@ hookup:function(a){return new this(a)},_isAction:function(a){return z.test(a)?tr
this._bindings=[];this.options=k(k(true,{},d.defaults),b);for(c in d.actions)if(d.actions.hasOwnProperty(c)){b=d.actions[c]||d._action(c,this.options);this._bindings.push(b.processor(b.delegate||a,b.parts[2],b.parts[1],this.callback(c),this))}this.called="init";var f=l(this.callback("destroy"));this.element.bind("destroyed",f);this._bindings.push(function(){e(a).unbind("destroyed",f)});return this.element},bind:function(a,b,c){if(typeof a=="string"){c=b;b=a;a=this.element}return this._binder(a,b,
c)},_binder:function(a,b,c,d){if(typeof c=="string")c=l(this.callback(c));this._bindings.push(r(a,b,c,d));return this._bindings.length},delegate:function(a,b,c,d){if(typeof a=="string"){d=c;c=b;b=a;a=this.element}return this._binder(a,c,d,b)},update:function(a){k(this.options,a)},destroy:function(){if(this._destroyed)throw this.Class.shortName+" controller instance has been deleted";var a=this,b=this.Class._fullName;this._destroyed=true;this.element.removeClass(b);e.each(this._bindings,function(c,
d){d(a.element[0])});delete this._actions;delete this.element.data("controllers")[b];e(this).triggerHandler("destroyed");this.element=null},find:function(a){return this.element.find(a)},_set_called:true});var o=e.Controller.processors;m=function(a,b,c,d,f){var g=f.Class;if(g.onDocument&&!/^Main(Controller)?$/.test(g.shortName)&&a===f.element[0])c=c?"#"+g._shortName+" "+c:"#"+g._shortName;return r(a,b,l(d),c)};e.each("change click contextmenu dblclick keydown keyup keypress mousedown mousemove mouseout mouseover mouseup reset resize scroll select submit focusin focusout mouseenter mouseleave".split(" "),
function(a,b){o[b]=m});var i,C=function(a,b){for(i=0;i<b.length;i++)if(typeof b[i]=="string"?a.Class._shortName==b[i]:a instanceof b[i])return true;return false};e.fn.controllers=function(){var a=p(arguments),b=[],c,d,f;this.each(function(){c=e.data(this,"controllers");for(f in c)if(c.hasOwnProperty(f)){d=c[f];if(!a.length||C(d,a))b.push(d)}});return b};e.fn.controller=function(){return this.controllers.apply(this,arguments)[0]}});
function(a,b){o[b]=m});var i,C=function(a,b){for(i=0;i<b.length;i++)if(typeof b[i]=="string"?a.Class._shortName==b[i]:a instanceof b[i])return true;return false};e.fn.controllers=function(){var a=p(arguments),b=[],c,d,f;this.each(function(){c=e.data(this,"controllers");for(f in c)if(c.hasOwnProperty(f)){d=c[f];if(!a.length||C(d,a))b.push(d)}});return b};e.fn.controller=function(){return this.controllers.apply(this,arguments)[0]}});
;
steal.end();
steal.plugins("jquery/event").then(function(a){var e=jQuery.cleanData;a.cleanData=function(b){for(var c=0,d;(d=b[c])!==undefined;c++)a(d).triggerHandler("destroyed");e(b)}});
steal.plugins("jquery/event").then(function(a){var e=jQuery.cleanData;a.cleanData=function(b){for(var c=0,d;(d=b[c])!==undefined;c++)a(d).triggerHandler("destroyed");e(b)}});
;
steal.end();
steal.plugins("jquery");
steal.plugins("jquery");
;
steal.end();
steal.plugins("jquery/view","jquery/lang/rsplit").then(function(g){var p=function(a){eval(a)},q=function(a){return a.substr(0,a.length-1)},l=g.String.rsplit,j=g.extend,r=g.isArray,m=function(a){return a.replace(/\\/g,"\\\\").replace(/\n/g,"\\n").replace(/"/g,'\\"')};escapeHTML=function(a){return a.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&#34;").replace(/'/g,"&#39;")};EJS=function(a){if(this.constructor!=EJS){var b=new EJS(a);return function(c,e){return b.render(c,
......@@ -243,7 +243,7 @@ cleanLeft:a+"%~",scan:n,lines:0});c.splitter=new RegExp("("+[c.dLeft,c.dRight,c.
o(d);e.cr();k();break;case f.left:case f.eLeft:case f.eeLeft:case f.cleanLeft:case f.cmnt:i=h;d.length>0&&o(d);k();break;case f.dLeft:d+=f.left;break;default:d+=h;break}else switch(h){case f.right:switch(i){case f.left:if(d[d.length-1]=="\n"){d=q(d);e.push(d,";");e.cr()}else e.push(d,";");break;case f.cleanLeft:e.push("___v1ew.push(","(jQuery.EJS.clean(",d,")));");break;case f.eLeft:e.push("___v1ew.push(","(jQuery.EJS.text(",d,")));");break;case f.eeLeft:e.push("___v1ew.push(","(jQuery.EJS.text(",
d,")));");break}i=null;k();break;case f.dRight:d+=f.right;break;default:d+=h;break}});d.length>0&&e.push("___v1ew.push(",'"',m(d)+'");');a={out:"try { with(_VIEW) { with (_CONTEXT) {"+e.close()+" return ___v1ew.join('');}}}catch(e){e.lineNumber=null;throw e;}"};p.call(a,"this.process = (function(_CONTEXT,_VIEW){"+a.out+"});\r\n//@ sourceURL="+c+".js");return a};EJS.Buffer=function(a,b){this.line=[];this.script=[];this.post=b;this.push.apply(this,a)};EJS.Buffer.prototype={push:function(){this.line.push.apply(this.line,
arguments)},cr:function(){this.script.push(this.line.join(""),"\n");this.line=[]},close:function(){if(this.line.length>0){this.script.push(this.line.join(""));this.line=[]}this.post.length&&this.push.apply(this,this.post);this.script.push(";");return this.script.join("")}};EJS.options={type:"<",ext:".ejs"};EJS.Helpers=function(a,b){this._data=a;this._extras=b;j(this,b)};EJS.Helpers.prototype={plugin:function(){var a=g.makeArray(arguments),b=a.shift();return function(c){c=g(c);c[b].apply(c,a)}},view:function(a,
b,c){c=c||this._extras;b=b||this._data;return g.View(a,b,c)}};g.View.register({suffix:"ejs",script:function(a,b){return"jQuery.EJS(function(_CONTEXT,_VIEW) { "+(new EJS({text:b})).template.out+" })"},renderer:function(a,b){var c=new EJS({text:b,name:a});return function(e,d){return c.render.call(c,e,d)}}})});
b,c){c=c||this._extras;b=b||this._data;return g.View(a,b,c)}};g.View.register({suffix:"ejs",script:function(a,b){return"jQuery.EJS(function(_CONTEXT,_VIEW) { "+(new EJS({text:b})).template.out+" })"},renderer:function(a,b){var c=new EJS({text:b,name:a});return function(e,d){return c.render.call(c,e,d)}}})});
;
steal.end();
steal.plugins("jquery").then(function(i){var x=function(a){return a.replace(/^\/\//,"").replace(/[\/\.]/g,"_")},y=1,e,o,p;isDeferred=function(a){return a&&i.isFunction(a.always)};getDeferreds=function(a){var b=[];if(isDeferred(a))return[a];else for(var c in a)isDeferred(a[c])&&b.push(a[c]);return b};usefulPart=function(a){return i.isArray(a)&&a.length===3&&a[1]==="success"?a[0]:a};e=i.View=function(a,b,c,d){if(typeof c==="function"){d=c;c=undefined}var f=getDeferreds(b);if(f.length){var g=i.Deferred();
......@@ -252,16 +252,16 @@ dataType:"view",async:b})};i.ajaxTransport("view",function(a,b){a=b.url;var c=a.
"success",k(f.innerHTML));else j=i.ajax({async:b.async,url:h,dataType:"text",error:function(){o("",h);m(404)},success:function(s){o(s,h);m(200,"success",k(s))}})},abort:function(){j&&j.abort()}}});i.extend(e,{hookups:{},hookup:function(a){var b=++y;e.hookups[b]=a;return b},cached:{},cache:true,register:function(a){this.types["."+a.suffix]=a},types:{},ext:".ejs",registerScript:function(a,b,c){return"$.View.preload('"+b+"',"+e.types["."+a].script(b,c)+");"},preload:function(a,b){e.cached[a]=function(c,
d){return b.call(c,c,d)}}});var t,n,u,v,w,q;t=function(a){var b=i.fn[a];i.fn[a]=function(){var c=i.makeArray(arguments),d,f,g=this;if(u(c)){if(d=v(c)){f=c[d];c[d]=function(h){n.call(g,[h],b);f.call(g,h)};e.apply(e,c);return this}c=e.apply(e,c);if(isDeferred(c)){c.done(function(h){n.call(g,[h],b)});return this}else c=[c]}return n.call(this,c,b)}};n=function(a,b){var c;for(var d in e.hookups)break;if(d){c=e.hookups;e.hookups={};a[0]=i(a[0])}b=b.apply(this,a);d&&w(a[0],c);return b};u=function(a){var b=
typeof a[1];return typeof a[0]=="string"&&(b=="object"||b=="function")&&!a[1].nodeType&&!a[1].jquery};v=function(a){return typeof a[3]==="function"?3:typeof a[2]==="function"&&2};w=function(a,b){var c,d=0,f,g;a=a.filter(function(){return this.nodeType!=3});a=a.add("[data-view-id]",a);for(c=a.length;d<c;d++)if(a[d].getAttribute&&(f=a[d].getAttribute("data-view-id"))&&(g=b[f])){g(a[d],f);delete b[f];a[d].removeAttribute("data-view-id")}i.extend(e.hookups,b)};q=["prepend","append","after","before","text",
"html","replaceWith","val"];for(var r=0;r<q.length;r++)t(q[r])});
"html","replaceWith","val"];for(var r=0;r<q.length;r++)t(q[r])});
;
steal.end();
steal.plugins("jquery/lang").then(function(f){f.String.rsplit=function(a,e){for(var b=e.exec(a),c=[],d;b!==null;){d=b.index;if(d!==0){c.push(a.substring(0,d));a=a.slice(d)}c.push(b[0]);a=a.slice(b[0].length);b=e.exec(a)}a!==""&&c.push(a);return c}});
steal.plugins("jquery/lang").then(function(f){f.String.rsplit=function(a,e){for(var b=e.exec(a),c=[],d;b!==null;){d=b.index;if(d!==0){c.push(a.substring(0,d));a=a.slice(d)}c.push(b[0]);a=a.slice(b[0].length);b=e.exec(a)}a!==""&&c.push(a);return c}});
;
steal.end();
steal.plugins("jquery").then(function(){(function(e){e.toJSON=function(a,c,b,h){if(typeof JSON=="object"&&JSON.stringify)return JSON.stringify(a,c,b);if(!h&&e.isFunction(c))a=c("",a);if(typeof b=="number")b=" ".substring(0,b);b=typeof b=="string"?b.substring(0,10):"";var f=typeof a;if(a===null)return"null";if(!(f=="undefined"||f=="function")){if(f=="number"||f=="boolean")return a+"";if(f=="string")return e.quoteString(a);if(f=="object"){if(typeof a.toJSON=="function")return e.toJSON(a.toJSON(),
c,b,true);if(a.constructor===Date){b=a.getUTCMonth()+1;if(b<10)b="0"+b;h=a.getUTCDate();if(h<10)h="0"+h;var i=a.getUTCFullYear(),g=a.getUTCHours();if(g<10)g="0"+g;var d=a.getUTCMinutes();if(d<10)d="0"+d;var j=a.getUTCSeconds();if(j<10)j="0"+j;a=a.getUTCMilliseconds();if(a<100)a="0"+a;if(a<10)a="0"+a;return'"'+i+"-"+b+"-"+h+"T"+g+":"+d+":"+j+"."+a+'Z"'}h=e.isFunction(c)?function(k,l){return c(k,l)}:function(k,l){return l};i=b?"\n":"";j=b?" ":"";if(a.constructor===Array){g=[];for(d=0;d<a.length;d++)g.push((e.toJSON(h(d,
a[d]),c,b,true)||"null").replace(/^/gm,b));return"["+i+g.join(","+i)+i+"]"}var n=[];if(e.isArray(c))g=e.map(c,function(k){return typeof k=="string"||typeof k=="number"?k+"":null});for(d in a){var m;f=typeof d;if(!(g&&e.inArray(d+"",g)==-1)){if(f=="number")f='"'+d+'"';else if(f=="string")f=e.quoteString(d);else continue;m=e.toJSON(h(d,a[d]),c,b,true);typeof m!="undefined"&&n.push((f+":"+j+m).replace(/^/gm,b))}}return"{"+i+n.join(","+i)+i+"}"}}};e.evalJSON=function(a){if(typeof JSON=="object"&&JSON.parse)return JSON.parse(a);
return eval("("+a+")")};e.secureEvalJSON=function(a){if(typeof JSON=="object"&&JSON.parse)return JSON.parse(a);var c=a;c=c.replace(/\\["\\\/bfnrtu]/g,"@");c=c.replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]");c=c.replace(/(?:^|:|,)(?:\s*\[)+/g,"");if(/^[\],:{}\s]*$/.test(c))return eval("("+a+")");else throw new SyntaxError("Error parsing JSON, source is not valid.");};e.quoteString=function(a){if(a.match(o))return'"'+a.replace(o,function(c){var b=p[c];if(typeof b==="string")return b;
b=c.charCodeAt();return"\\u00"+Math.floor(b/16).toString(16)+(b%16).toString(16)})+'"';return'"'+a+'"'};var o=/["\\\x00-\x1f\x7f-\x9f]/g,p={"\u0008":"\\b","\t":"\\t","\n":"\\n","\u000c":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"}})(jQuery)});
b=c.charCodeAt();return"\\u00"+Math.floor(b/16).toString(16)+(b%16).toString(16)})+'"';return'"'+a+'"'};var o=/["\\\x00-\x1f\x7f-\x9f]/g,p={"\u0008":"\\b","\t":"\\t","\n":"\\n","\u000c":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"}})(jQuery)});
;
steal.end()
\ No newline at end of file
......@@ -17,7 +17,7 @@ $.Model('Todo',{
* This is unimportant for understanding JavaScriptMVC!
*/
localStore: function(cb){
var name = this.shortName,
var name = 'todo-javascriptmvc',
data = $.evalJSON( window.localStorage[name] || (window.localStorage[name] = "{}") ),
res = cb.call(this, data);
if(res !== false){
......@@ -251,4 +251,4 @@ $(function(){
})
});
\ No newline at end of file
});
......@@ -40,7 +40,7 @@ jQuery(function($){
this.$count = this.$footer.find('.count');
this.$clearBtn = this.$footer.find('.clear');
// localStorage support
this.store = new Store('todoapp');
this.store = new Store('todo-jquery');
this.todos = this.store.get('todos') || [];
this.bindEvents();
this.render();
......@@ -149,4 +149,4 @@ jQuery(function($){
window.TodoApp = App.init();
});
\ No newline at end of file
});
......@@ -186,14 +186,14 @@
// lists model
Lists = Object.create(Model);
Lists.name = 'lists';
Lists.name = 'lists-sammyjs';
Lists.init();
// todos model
Todos = Object.create(Model);
Todos.name = 'todos';
Todos.name = 'todos-sammyjs';
Todos.init();
$(function() { app.run(); });
})(jQuery);
\ No newline at end of file
})(jQuery);
(function() {
var storageName = 'todos-spine';
if (typeof Spine === "undefined" || Spine === null) {
Spine = require('spine');
}
......@@ -10,11 +12,11 @@
saveLocal: function() {
var result;
result = JSON.stringify(this);
return localStorage[this.className] = result;
return localStorage[storageName] = result;
},
loadLocal: function() {
var result;
result = localStorage[this.className];
result = localStorage[storageName];
return this.refresh(result || [], {
clear: true
});
......
YUI().use('event-focus', 'json', 'model', 'model-list', 'view', function (Y) {
var TodoAppView, TodoList, TodoModel, TodoView;
var TodoAppView, TodoList, TodoModel, TodoView, localStorageName = 'todos-yuilibrary';
// -- Model --------------------------------------------------------------------
......@@ -12,7 +12,7 @@ var TodoAppView, TodoList, TodoModel, TodoView;
TodoModel = Y.TodoModel = Y.Base.create('todoModel', Y.Model, [], {
// This tells the Model to use a localStorage sync provider (which we'll
// create below) to save and load information about a todo item.
sync: LocalStorageSync('todo'),
sync: LocalStorageSync(localStorageName),
// This method will toggle the `done` attribute from `true` to `false`, or
// vice versa.
......@@ -41,7 +41,7 @@ TodoList = Y.TodoList = Y.Base.create('todoList', Y.ModelList, [], {
// This tells the list to use a localStorage sync provider (which we'll
// create below) to load the list of todo items.
sync : LocalStorageSync('todo'),
sync : LocalStorageSync(localStorageName),
// Returns an array of all models in this list with the `done` attribute
// set to `true`.
......@@ -444,4 +444,4 @@ function LocalStorageSync(key) {
// in motion and bring our todo list into existence.
new TodoAppView();
});
\ No newline at end of file
});
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment