Skip to content
Browse files

Funnyface.js: Indentation

  • Loading branch information...
1 parent 158848f commit 1abb3cc2229ca3e145795210e20e693c98eff7ca @sindresorhus sindresorhus committed May 4, 2012
Showing with 99 additions and 100 deletions.
  1. +99 −100 labs/architecture-examples/o_O/js/app.js
View
199 labs/architecture-examples/o_O/js/app.js
@@ -2,68 +2,68 @@
(function( window ) {
'use strict';
-// represents a single todo item
-var Todo = o_O.model.extend({
- title: '',
- completed: false
- },
- {
- initialize: function() {
- this.editing = o_O( false );
- },
-
- startEditing: function() {
- this.editing( true );
- var self = this;
- setTimeout(function() {
- $( self.el ).parent().find('input.edit').select();
- }, 0);
+ // represents a single todo item
+ var Todo = o_O.model.extend({
+ title: '',
+ completed: false
},
+ {
+ initialize: function() {
+ this.editing = o_O( false );
+ },
+
+ startEditing: function() {
+ this.editing( true );
+ var self = this;
+ setTimeout(function() {
+ $( self.el ).parent().find('input.edit').select();
+ }, 0);
+ },
+
+ stopEditing: function() {
+ var text = $.trim( this.title() );
+
+ if ( text ) {
+ this.title( text );
+ } else {
+ this.remove();
+ }
- stopEditing: function() {
- var text = $.trim( this.title() );
-
- if ( text ) {
- this.title( text );
- } else {
- this.remove();
- }
-
- this.editing( false );
- },
+ this.editing( false );
+ },
- remove: function() {
- todoapp.todos.remove( this );
- },
+ remove: function() {
+ todoapp.todos.remove( this );
+ },
- visible: function() {
- var filter = todoapp.filter(),
- completed = this.completed();
+ visible: function() {
+ var filter = todoapp.filter(),
+ completed = this.completed();
- return filter === '' ||
- ( filter === 'completed' && completed ) ||
- ( filter === 'active' && !completed );
- },
+ return filter === '' ||
+ ( filter === 'completed' && completed ) ||
+ ( filter === 'active' && !completed );
+ },
- klass: function() {
- if ( this.editing() ) {
- return 'editing';
- }
- if ( this.completed() ) {
- return 'completed';
- } else {
- return '';
+ klass: function() {
+ if ( this.editing() ) {
+ return 'editing';
+ }
+ if ( this.completed() ) {
+ return 'completed';
+ } else {
+ return '';
+ }
}
}
- }
-);
-
-// main application
-var TodoApp = o_O.model.extend({
- current: '',
- completedCount: 0,
- filter: ''
- }, {
+ );
+
+ // main application
+ var TodoApp = o_O.model.extend({
+ current: '',
+ completedCount: 0,
+ filter: ''
+ }, {
initialize: function() {
var self = this;
@@ -123,59 +123,58 @@ var TodoApp = o_O.model.extend({
pluralize: function( word, count ) {
return word + ( count === 1 ? '' : 's' );
}
- }
-);
+ });
-function main() {
- // load todos
- var i, l,
- todos = [];
+ function main() {
+ // load todos
+ var i, l,
+ todos = [];
- try {
- todos = JSON.parse( localStorage['todos-o_O'] );
- } catch( e ) {}
+ try {
+ todos = JSON.parse( localStorage['todos-o_O'] );
+ } catch( e ) {}
- // create models
- for( i = 0, l = todos.length; i < l; i++ ) {
- todos[ i ] = Todo.create( todos[ i ] );
+ // create models
+ for( i = 0, l = todos.length; i < l; i++ ) {
+ todos[ i ] = Todo.create( todos[ i ] );
+ }
+
+ // create app
+ window.todoapp = TodoApp({
+ todos: todos
+ });
+
+ // bind to DOM element
+ todoapp.bind('#todoapp');
+
+ // setup Routing
+ o_O.router()
+ .add('*filter', function( filter ) {
+ todoapp.filter( filter );
+
+ $('#filters a')
+ .removeClass('selected')
+ .filter( '[href="#/' + filter + '"]' )
+ .addClass('selected');
+ })
+ .start();
}
- // create app
- window.todoapp = TodoApp({
- todos: todos
- });
+ // a custom binding to handle the enter key
+ o_O.bindings.enterKey = function( func, $el ) {
+ var ENTER_KEY = 13,
+ context = this;
- // bind to DOM element
- todoapp.bind('#todoapp');
-
- // setup Routing
- o_O.router()
- .add('*filter', function( filter ) {
- todoapp.filter( filter );
-
- $('#filters a')
- .removeClass('selected')
- .filter( '[href="#/' + filter + '"]' )
- .addClass('selected');
- })
- .start();
-}
-
-// a custom binding to handle the enter key
-o_O.bindings.enterKey = function( func, $el ) {
- var ENTER_KEY = 13,
- context = this;
-
- $el.keyup(function( e ) {
- if ( e.which === ENTER_KEY ) {
- func.call( context );
- }
- });
-};
+ $el.keyup(function( e ) {
+ if ( e.which === ENTER_KEY ) {
+ func.call( context );
+ }
+ });
+ };
-o_O.bindingTypes.enterKey = 'outbound';
+ o_O.bindingTypes.enterKey = 'outbound';
-// kick it off
-main();
+ // kick it off
+ main();
})( window );

0 comments on commit 1abb3cc

Please sign in to comment.
Something went wrong with that request. Please try again.