Permalink
Browse files

PlastronJS app: Tweaks

  • Loading branch information...
1 parent 5f8b7fa commit ffff5854400e1e348a77269a366ab153ded7e87f @sindresorhus sindresorhus committed Nov 3, 2012
@@ -4,7 +4,7 @@
<meta charset="utf-8">
<title>PlastronJS • TodoMVC</title>
<link rel="stylesheet" href="../../../assets/base.css">
- <style type="text/css">
+ <style>
#filters.none li.none,
#filters.active li.active,
#filters.completed li.completed {
@@ -44,7 +44,7 @@
</section>
<footer id="info">
<p>Double-click to edit a todo</p>
- <p>Created by <a href="http://rhysbrettbowen.com">Rhys Brett-Bowen</a> (<a href="https://twitter.com/#!/RhysBB">RhysBB</a>)</p>
+ <p>Created by <a href="http://rhysbrettbowen.com">Rhys Brett-Bowen</a> (<a href="https://twitter.com/RhysBB">RhysBB</a>)</p>
<p>Using <a href="https://github.com/rhysbrettbowen/PlastronJS">PlastronJS</a> and <a href="https://developers.google.com/closure/">Closure Tools</a></p>
<p>Part of <a href="http://todomvc.com">TodoMVC</a></p>
</footer>
@@ -24,5 +24,3 @@ router.route( '/active', function() {
router.route( '/completed', function() {
todolist.set( 'filter', 'completed' );
});
-
-
@@ -1,3 +1,4 @@
+/*global goog, mvc, todomvc */
goog.provide('todomvc.listcontrol');
goog.require('goog.events.KeyCodes');
@@ -1,3 +1,4 @@
+/*global goog, mvc, soy, todomvc */
goog.provide('todomvc.todocontrol');
goog.require('goog.dom');
@@ -44,19 +45,19 @@ todomvc.todocontrol.prototype.enterDocument = function() {
this.autobind('.toggle', '{$completed}');
// Delete the model
- this.click(function( e ) {
+ this.click(function() {
model.dispose();
- }, '.destroy' );
+ }, '.destroy');
// keep label inline with title
- this.autobind( 'label', '{$title}')
+ this.autobind( 'label', '{$title}' );
var inputEl = this.getEls('.edit')[0];
// Dblclick to edit
- this.on( goog.events.EventType.DBLCLICK, function( e ) {
+ this.on( goog.events.EventType.DBLCLICK, function() {
goog.dom.classes.add( this.getElement(), 'editing' );
inputEl.focus();
- }, '.view' );
+ }, '.view');
// blur on enter
this.on( goog.events.EventType.KEYUP, function( e ) {
@@ -66,10 +67,10 @@ todomvc.todocontrol.prototype.enterDocument = function() {
});
// finish editing on blur
- this.on( goog.events.EventType.BLUR, function( e ) {
+ this.on( goog.events.EventType.BLUR, function() {
goog.dom.classes.remove( this.getElement(), 'editing' );
});
// bind the title and the edit input
- this.autobind('.edit', '{$title}');
+ this.autobind( '.edit', '{$title}' );
};
@@ -1,3 +1,4 @@
+/*global goog, mvc, todomvc */
goog.provide('todomvc.listmodel');
goog.require('mvc.Collection');
@@ -13,32 +14,32 @@ todomvc.listmodel = function() {
var todosSchema = {
// number of completed
- 'completed': {
+ completed: {
get: function() {
- return this.getModels( 'completed' ).length;
+ return this.getModels('completed').length;
},
models: true
},
- 'allDone': {
+ allDone: {
get: function() {
- return this.getLength() == this.getModels( 'completed' ).length;
+ return this.getLength() === this.getModels( 'completed' ).length;
},
set: function( done ) {
- goog.array.forEach( this.getModels( 'none' ), function( model ) {
+ goog.array.forEach( this.getModels('none'), function( model ) {
model.set( 'completed', done );
});
},
models: true
},
// number of active models
- 'active': {
+ active: {
get: function() {
return this.getLength() - this.getModels( 'completed' ).length;
},
models: true
},
// the total
- 'total': {
+ total: {
get: function() {
return this.getLength();
},
@@ -47,10 +48,10 @@ todomvc.listmodel = function() {
};
goog.base( this, {
- 'id': 'todos-plastronjs',
- 'sync': new todomvc.listsync(),
- 'schema': todosSchema,
- 'modelType': todomvc.todomodel
+ id: 'todos-plastronjs',
+ sync: new todomvc.listsync(),
+ schema: todosSchema,
+ modelType: todomvc.todomodel
});
// fetch from localstorage
@@ -63,34 +64,34 @@ goog.inherits( todomvc.listmodel, mvc.Collection );
todomvc.listmodel.Filter = {
- 'none': function() {
- return true
+ none: function() {
+ return true;
},
- 'active': function( model ) {
- return !model.get('completed')
+ active: function( model ) {
+ return !model.get('completed');
},
- 'completed': function( model ) {
- return model.get('completed')
+ completed: function( model ) {
+ return model.get('completed');
}
};
/**
* return models based on current filter or filter given
- *
+ *
* @inheritDoc
*/
-todomvc.listmodel.prototype.getModels = function(opt_filter) {
+todomvc.listmodel.prototype.getModels = function( optFilter ) {
return goog.base(this, 'getModels',
- todomvc.listmodel.Filter[ opt_filter || this.get( 'filter' ) ] );
+ todomvc.listmodel.Filter[ optFilter || this.get('filter') ] );
};
/**
* @return {Object} todos as json.
*/
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();
});
};
@@ -1,3 +1,4 @@
+/*global goog, mvc, todomvc */
goog.provide('todomvc.listsync');
goog.require('mvc.LocalSync');
@@ -16,7 +17,7 @@ goog.inherits( todomvc.listsync, mvc.LocalSync );
/**
* @inheritDoc
*/
-todomvc.listsync.prototype.read = function( model, opt_callback ) {
+todomvc.listsync.prototype.read = function( model ) {
var id = /** @type {string} */(model.get('id'));
var todos = this.store_.get(id) || [];
goog.array.forEach(/** @type {Array} */(todos),
@@ -42,7 +42,7 @@ and view the compiled version for the page by changing the bottom script src bac
## Need help?
-Message me on [twitter](https://twitter.com/#!/RhysBB)
+Message Rhys on [twitter](https://twitter.com/RhysBB)
## Credit

0 comments on commit ffff585

Please sign in to comment.