Commit 0bd96e8d authored by Pascal Hartig's avatar Pascal Hartig

Partially revert ffff5854

Unquoting attributes causes issues with the closure compiler.
parent d29ad7ee
...@@ -10,67 +10,67 @@ goog.require('todomvc.todomodel'); ...@@ -10,67 +10,67 @@ goog.require('todomvc.todomodel');
* @constructor * @constructor
* @extends {mvc.Collection} * @extends {mvc.Collection}
*/ */
todomvc.listmodel = function() { todomvc.listmodel = function () {
var todosSchema = { var todosSchema = {
// number of completed // number of completed
completed: { 'completed': {
get: function() { get: function () {
return this.getModels('completed').length; return this.getModels('completed').length;
}, },
models: true models: true
}, },
allDone: { 'allDone': {
get: function() { get: function () {
return this.getLength() === this.getModels( 'completed' ).length; return this.getLength() === this.getModels('completed').length;
}, },
set: function( done ) { set: function (done) {
goog.array.forEach( this.getModels('none'), function( model ) { goog.array.forEach(this.getModels('none'), function (model) {
model.set( 'completed', done ); model.set('completed', done);
}); });
}, },
models: true models: true
}, },
// number of active models // number of active models
active: { 'active': {
get: function() { get: function () {
return this.getLength() - this.getModels( 'completed' ).length; return this.getLength() - this.getModels('completed').length;
}, },
models: true models: true
}, },
// the total // the total
total: { 'total': {
get: function() { get: function () {
return this.getLength(); return this.getLength();
}, },
models: true models: true
} }
}; };
goog.base( this, { goog.base(this, {
id: 'todos-plastronjs', 'id': 'todos-plastronjs',
sync: new todomvc.listsync(), 'sync': new todomvc.listsync(),
schema: todosSchema, 'schema': todosSchema,
modelType: todomvc.todomodel 'modelType': todomvc.todomodel
}); });
// fetch from localstorage // fetch from localstorage
this.fetch(); this.fetch();
// save on any changes // save on any changes
this.anyModelChange( this.save ); this.anyModelChange(this.save);
}; };
goog.inherits( todomvc.listmodel, mvc.Collection ); goog.inherits(todomvc.listmodel, mvc.Collection);
todomvc.listmodel.Filter = { todomvc.listmodel.Filter = {
none: function() { 'none': function () {
return true; return true;
}, },
active: function( model ) { 'active': function (model) {
return !model.get('completed'); return !model.get('completed');
}, },
completed: function( model ) { 'completed': function (model) {
return model.get('completed'); return model.get('completed');
} }
}; };
...@@ -81,17 +81,17 @@ todomvc.listmodel.Filter = { ...@@ -81,17 +81,17 @@ todomvc.listmodel.Filter = {
* *
* @inheritDoc * @inheritDoc
*/ */
todomvc.listmodel.prototype.getModels = function( optFilter ) { todomvc.listmodel.prototype.getModels = function (opt_filter) {
return goog.base(this, 'getModels', return goog.base(this, 'getModels',
todomvc.listmodel.Filter[ optFilter || this.get('filter') ] ); todomvc.listmodel.Filter[opt_filter || this.get('filter')]);
}; };
/** /**
* @return {Object} todos as json. * @return {Object} todos as json.
*/ */
todomvc.listmodel.prototype.toJson = function() { todomvc.listmodel.prototype.toJson = function () {
return goog.array.map( this.getModels('none'), function( mod ) { return goog.array.map(this.getModels('none'), function (mod) {
return mod.toJson(); return mod.toJson();
}); });
}; };
...@@ -10,14 +10,14 @@ goog.require('mvc.Model.ValidateError'); ...@@ -10,14 +10,14 @@ goog.require('mvc.Model.ValidateError');
* @param {Object=} opt_options to be put on the model. * @param {Object=} opt_options to be put on the model.
* @extends {mvc.Model} * @extends {mvc.Model}
*/ */
todomvc.todomodel = function( opt_options ) { todomvc.todomodel = function (opt_options) {
goog.base( this, opt_options ); goog.base(this, opt_options);
// title must have a length, also format to remove spaces // title must have a length, also format to remove spaces
this.setter( 'title', function( title ) { this.setter('title', function (title) {
var updated = goog.string.trim( title ); var updated = goog.string.trim(title);
if ( !updated.length ) { if (!updated.length) {
throw new mvc.Model.ValidateError('null string'); throw new mvc.Model.ValidateError('null string');
} }
...@@ -25,8 +25,8 @@ todomvc.todomodel = function( opt_options ) { ...@@ -25,8 +25,8 @@ todomvc.todomodel = function( opt_options ) {
}); });
// when a note title is no longer valid then remove it // when a note title is no longer valid then remove it
this.errorHandler(function() { this.errorHandler(function () {
this.dispose(); this.dispose();
}); });
}; };
goog.inherits( todomvc.todomodel, mvc.Model ); goog.inherits(todomvc.todomodel, mvc.Model);
...@@ -17,7 +17,7 @@ goog.inherits( todomvc.listsync, mvc.LocalSync ); ...@@ -17,7 +17,7 @@ goog.inherits( todomvc.listsync, mvc.LocalSync );
/** /**
* @inheritDoc * @inheritDoc
*/ */
todomvc.listsync.prototype.read = function( model ) { todomvc.listsync.prototype.read = function( model, opt_callback ) {
var id = /** @type {string} */(model.get('id')); var id = /** @type {string} */(model.get('id'));
var todos = this.store_.get(id) || []; var todos = this.store_.get(id) || [];
goog.array.forEach(/** @type {Array} */(todos), goog.array.forEach(/** @type {Array} */(todos),
......
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