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