Commit 8e97e4bd authored by Kevin Malakoff's avatar Kevin Malakoff Committed by Sindre Sorhus

Close #1159 PR: Knockback: upgrade to node_modules and latest library.

parent 42cae948
node_modules/backbone/* node_modules/knockback/*
!node_modules/backbone/backbone.js !node_modules/knockback/knockback.js
!node_modules/knockback/node_modules
node_modules/backbone.localstorage/* node_modules/knockback/node_modules/backbone/*
!node_modules/backbone.localstorage/backbone.localStorage.js !node_modules/knockback/node_modules/backbone/backbone.js
node_modules/knockback/node_modules/underscore/*
!node_modules/knockback/node_modules/underscore/underscore.js
node_modules/knockback/node_modules/knockout/*
!node_modules/knockback/node_modules/knockout/build
node_modules/knockback/node_modules/knockout/build/*
!node_modules/knockback/node_modules/knockout/build/output
node_modules/knockback/node_modules/knockout/build/output/*
!node_modules/knockback/node_modules/knockout/build/output/knockout-latest.debug.js
node_modules/jquery/* node_modules/jquery/*
!node_modules/jquery/dist !node_modules/jquery/dist
......
...@@ -54,7 +54,10 @@ ...@@ -54,7 +54,10 @@
<!-- App Dependencies --> <!-- App Dependencies -->
<script src="node_modules/todomvc-common/base.js"></script> <script src="node_modules/todomvc-common/base.js"></script>
<script src="node_modules/jquery/dist/jquery.js"></script> <script src="node_modules/jquery/dist/jquery.js"></script>
<script src="js/lib/knockback-full-stack-0.16.9.min.js"></script> <script src="node_modules/knockback/node_modules/underscore/underscore.js"></script>
<script src="node_modules/knockback/node_modules/backbone/backbone.js"></script>
<script src="node_modules/knockback/node_modules/knockout/build/output/knockout-latest.debug.js"></script>
<script src="node_modules/knockback/knockback.js"></script>
<script src="node_modules/backbone.localStorage/backbone.localStorage.js"></script> <script src="node_modules/backbone.localStorage/backbone.localStorage.js"></script>
<!-- App and Components --> <!-- App and Components -->
......
/**
* Backbone localStorage Adapter
* Version 1.1.0
*
* https://github.com/jeromegn/Backbone.localStorage
*/(function(a,b){typeof define=="function"&&define.amd?define(["underscore","backbone"],function(c,d){return b(c||a._,d||a.Backbone)}):b(_,Backbone)})(this,function(a,b){function c(){return((1+Math.random())*65536|0).toString(16).substring(1)}function d(){return c()+c()+"-"+c()+"-"+c()+"-"+c()+"-"+c()+c()+c()}return b.LocalStorage=window.Store=function(a){this.name=a;var b=this.localStorage().getItem(this.name);this.records=b&&b.split(",")||[]},a.extend(b.LocalStorage.prototype,{save:function(){this.localStorage().setItem(this.name,this.records.join(","))},create:function(a){return a.id||(a.id=d(),a.set(a.idAttribute,a.id)),this.localStorage().setItem(this.name+"-"+a.id,JSON.stringify(a)),this.records.push(a.id.toString()),this.save(),this.find(a)},update:function(b){return this.localStorage().setItem(this.name+"-"+b.id,JSON.stringify(b)),a.include(this.records,b.id.toString())||this.records.push(b.id.toString()),this.save(),this.find(b)},find:function(a){return this.jsonData(this.localStorage().getItem(this.name+"-"+a.id))},findAll:function(){return a(this.records).chain().map(function(a){return this.jsonData(this.localStorage().getItem(this.name+"-"+a))},this).compact().value()},destroy:function(b){return b.isNew()?!1:(this.localStorage().removeItem(this.name+"-"+b.id),this.records=a.reject(this.records,function(a){return a===b.id.toString()}),this.save(),b)},localStorage:function(){return localStorage},jsonData:function(a){return a&&JSON.parse(a)}}),b.LocalStorage.sync=window.Store.sync=b.localSync=function(a,c,d){var e=c.localStorage||c.collection.localStorage,f,g,h=$.Deferred&&$.Deferred();try{switch(a){case"read":f=c.id!=undefined?e.find(c):e.findAll();break;case"create":f=e.create(c);break;case"update":f=e.update(c);break;case"delete":f=e.destroy(c)}}catch(i){i.code===DOMException.QUOTA_EXCEEDED_ERR&&window.localStorage.length===0?g="Private browsing is unsupported":g=i.message}return f?(c.trigger("sync",c,f,d),d&&d.success&&(b.VERSION==="0.9.10"?d.success(c,f,d):d.success(f)),h&&h.resolve(f)):(g=g?g:"Record Not Found",c.trigger("error",c,g,d),d&&d.error&&(b.VERSION==="0.9.10"?d.error(c,g,d):d.error(g)),h&&h.reject(g)),d&&d.complete&&d.complete(f),h&&h.promise()},b.ajaxSync=b.sync,b.getSyncMethod=function(a){return a.localStorage||a.collection&&a.collection.localStorage?b.localSync:b.ajaxSync},b.sync=function(a,c,d){return b.getSyncMethod(c).apply(this,[a,c,d])},b.LocalStorage});
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
// Generated by CoffeeScript 1.7.1 // Generated by CoffeeScript 1.8.0
(function() { (function() {
ko.bindingHandlers.dblclick = { ko.bindingHandlers.dblclick = {
init: function(element, value_accessor) { init: function(element, value_accessor) {
......
// Generated by CoffeeScript 1.7.1 // Generated by CoffeeScript 1.8.0
(function() { (function() {
var __hasProp = {}.hasOwnProperty, var __hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
......
// Generated by CoffeeScript 1.7.1 // Generated by CoffeeScript 1.8.0
(function() { (function() {
var __hasProp = {}.hasOwnProperty, var __hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
......
// Generated by CoffeeScript 1.7.1 // Generated by CoffeeScript 1.8.0
(function() { (function() {
var ENTER_KEY; var ENTER_KEY;
...@@ -16,15 +16,15 @@ ...@@ -16,15 +16,15 @@
switch (_this.list_filter_mode()) { switch (_this.list_filter_mode()) {
case 'active': case 'active':
return function(model) { return function(model) {
return model.completed(); return !model.completed();
}; };
case 'completed': case 'completed':
return function(model) { return function(model) {
return !model.completed(); return model.completed();
}; };
default: default:
return function() { return function() {
return false; return true;
}; };
} }
}; };
......
// Generated by CoffeeScript 1.7.1 // Generated by CoffeeScript 1.8.0
(function() { (function() {
window.TodoViewModel = function(model) { window.TodoViewModel = function(model) {
var ENTER_KEY, ESCAPE_KEY; var ENTER_KEY, ESCAPE_KEY;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
"dependencies": { "dependencies": {
"backbone.localStorage": "^1.1.3", "backbone.localStorage": "^1.1.3",
"jquery": "^2.0.0", "jquery": "^2.0.0",
"knockback": "^0.20.5",
"todomvc-app-css": "^1.0.0", "todomvc-app-css": "^1.0.0",
"todomvc-common": "^1.0.1" "todomvc-common": "^1.0.1"
} }
......
...@@ -30,10 +30,10 @@ To install CoffeeScript globally: ...@@ -30,10 +30,10 @@ To install CoffeeScript globally:
To compile once: To compile once:
# from architecture-examples/knockback # from examples/knockback
cake build cake build
To compile on save To compile on save
# from architecture-examples/knockback # from examples/knockback
cake watch cake watch
...@@ -12,4 +12,4 @@ ko.bindingHandlers.selectAndFocus = ...@@ -12,4 +12,4 @@ ko.bindingHandlers.selectAndFocus =
update: (element, value_accessor) -> update: (element, value_accessor) ->
ko.utils.unwrapObservable(value_accessor()) # create dependency ko.utils.unwrapObservable(value_accessor()) # create dependency
_.defer(->ko.bindingHandlers.hasfocus.update(element, value_accessor)) _.defer -> ko.bindingHandlers.hasfocus.update(element, value_accessor)
\ No newline at end of file \ No newline at end of file
...@@ -11,12 +11,12 @@ window.AppViewModel = -> ...@@ -11,12 +11,12 @@ window.AppViewModel = ->
# shared observables # shared observables
@list_filter_mode = ko.observable('') @list_filter_mode = ko.observable('')
filter_fn = ko.computed(=> filter_fn = ko.computed =>
switch @list_filter_mode() switch @list_filter_mode()
when 'active' then return (model) -> return model.completed() when 'active' then return (model) -> return not model.completed()
when 'completed' then return (model) -> return not model.completed() when 'completed' then return (model) -> return model.completed()
else return -> return false else return -> return true
)
@todos = kb.collectionObservable(@collections.todos, {view_model: TodoViewModel, filters: filter_fn}) @todos = kb.collectionObservable(@collections.todos, {view_model: TodoViewModel, filters: filter_fn})
@todos_changed = kb.triggeredObservable(@collections.todos, 'change add remove') @todos_changed = kb.triggeredObservable(@collections.todos, 'change add remove')
@tasks_exist = ko.computed(=> @todos_changed(); return !!@collections.todos.length) @tasks_exist = ko.computed(=> @todos_changed(); return !!@collections.todos.length)
...@@ -35,18 +35,16 @@ window.AppViewModel = -> ...@@ -35,18 +35,16 @@ window.AppViewModel = ->
############################# #############################
# Main Section # Main Section
############################# #############################
@remaining_count = ko.computed(=> @todos_changed(); return @collections.todos.remainingCount()) @remaining_count = ko.computed => @todos_changed(); return @collections.todos.remainingCount()
@completed_count = ko.computed(=> @todos_changed(); return @collections.todos.completedCount()) @completed_count = ko.computed => @todos_changed(); return @collections.todos.completedCount()
@all_completed = ko.computed( @all_completed = ko.computed
read: => return not @remaining_count() read: => return not @remaining_count()
write: (completed) => @collections.todos.completeAll(completed) write: (completed) => @collections.todos.completeAll(completed)
)
############################# #############################
# Footer Section # Footer Section
############################# #############################
@onDestroyCompleted = => @onDestroyCompleted = => @collections.todos.destroyCompleted()
@collections.todos.destroyCompleted()
############################# #############################
# Localization # Localization
......
...@@ -27,4 +27,4 @@ window.TodoViewModel = (model) -> ...@@ -27,4 +27,4 @@ window.TodoViewModel = (model) ->
$('.todo-input').blur() $('.todo-input').blur()
@editing(false) @editing(false)
return return
\ 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