Commit 1abd9579 authored by Arthur Verschaeve's avatar Arthur Verschaeve

Thorax-lumbar: fix JSCS errors

parent 334e9f61
...@@ -17281,9 +17281,9 @@ Thorax.templatePathPrefix = 'src/templates/'; ...@@ -17281,9 +17281,9 @@ Thorax.templatePathPrefix = 'src/templates/';
var app = window.app = module.exports; var app = window.app = module.exports;
$(function() { $(function () {
app.initBackboneLoader(); app.initBackboneLoader();
Backbone.history.start(); Backbone.history.start();
}); });
;; ;;
......
This diff is collapsed.
var ENTER_KEY = 13; var ENTER_KEY = 13;
$(function() { $(function () {
// Kick things off by creating the **App**. // Kick things off by creating the **App**.
var view = new Thorax.Views['app']({ var view = new Thorax.Views.app({
collection: window.app.Todos collection: window.app.Todos
}); });
view.appendTo('body'); view.appendTo('body');
}); });
(function() { (function () {
'use strict'; 'use strict';
// Todo Collection // Todo Collection
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
// Create our global collection of **Todos**. // Create our global collection of **Todos**.
window.app.Todos = new TodoList(); window.app.Todos = new TodoList();
// Ensure that we always have data available // Ensure that we always have data available
window.app.Todos.fetch(); window.app.Todos.fetch();
}()); }());
...@@ -3,7 +3,7 @@ Thorax.templatePathPrefix = 'src/templates/'; ...@@ -3,7 +3,7 @@ Thorax.templatePathPrefix = 'src/templates/';
var app = window.app = module.exports; var app = window.app = module.exports;
$(function() { $(function () {
app.initBackboneLoader(); app.initBackboneLoader();
Backbone.history.start(); Backbone.history.start();
}); });
(function() { (function () {
'use strict'; 'use strict';
// Todo Model // Todo Model
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
}, },
// Toggle the `completed` state of this todo item. // Toggle the `completed` state of this todo item.
toggle: function() { toggle: function () {
this.save({ this.save({
completed: !this.get('completed') completed: !this.get('completed')
}); });
......
(function() { (function () {
'use strict'; 'use strict';
// Todo Router // Todo Router
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
name: module.name, name: module.name,
routes: module.routes, routes: module.routes,
setFilter: function( param ) { setFilter: function (param) {
// Set the current filter to be used // Set the current filter to be used
window.app.TodoFilter = param ? param.trim().replace(/^\//, '') : ''; window.app.TodoFilter = param ? param.trim().replace(/^\//, '') : '';
// Thorax listens for a `filter` event which will // Thorax listens for a `filter` event which will
......
$(function( $ ) { $(function ($) {
'use strict'; 'use strict';
// The Application // The Application
...@@ -23,7 +23,7 @@ $(function( $ ) { ...@@ -23,7 +23,7 @@ $(function( $ ) {
rendered: 'toggleToggleAllButton' rendered: 'toggleToggleAllButton'
}, },
toggleToggleAllButton: function() { toggleToggleAllButton: function () {
var toggleInput = this.$('#toggle-all')[0]; var toggleInput = this.$('#toggle-all')[0];
if (toggleInput) { if (toggleInput) {
toggleInput.checked = !this.collection.remaining().length; toggleInput.checked = !this.collection.remaining().length;
...@@ -32,12 +32,12 @@ $(function( $ ) { ...@@ -32,12 +32,12 @@ $(function( $ ) {
// When this function is specified, items will only be shown // When this function is specified, items will only be shown
// when this function returns true // when this function returns true
itemFilter: function(model) { itemFilter: function (model) {
return model.isVisible(); return model.isVisible();
}, },
// Generate the attributes for a new Todo item. // Generate the attributes for a new Todo item.
newAttributes: function() { newAttributes: function () {
return { return {
title: this.$('#new-todo').val().trim(), title: this.$('#new-todo').val().trim(),
order: this.collection.nextOrder(), order: this.collection.nextOrder(),
...@@ -47,18 +47,18 @@ $(function( $ ) { ...@@ -47,18 +47,18 @@ $(function( $ ) {
// If you hit return in the main input field, create new **Todo** model, // If you hit return in the main input field, create new **Todo** model,
// persisting it to *localStorage*. // persisting it to *localStorage*.
createOnEnter: function( e ) { createOnEnter: function (e) {
if ( e.which !== ENTER_KEY || !this.$('#new-todo').val().trim() ) { if (e.which !== ENTER_KEY || !this.$('#new-todo').val().trim()) {
return; return;
} }
this.collection.create( this.newAttributes() ); this.collection.create(this.newAttributes());
this.$('#new-todo').val(''); this.$('#new-todo').val('');
}, },
toggleAllComplete: function() { toggleAllComplete: function () {
var completed = this.$('#toggle-all')[0].checked; var completed = this.$('#toggle-all')[0].checked;
this.collection.each(function( todo ) { this.collection.each(function (todo) {
todo.save({ todo.save({
completed: completed completed: completed
}); });
......
Thorax.View.extend({ Thorax.View.extend({
name: 'stats', name: 'stats',
events: { events: {
'click #clear-completed': 'clearCompleted', 'click #clear-completed': 'clearCompleted',
// The "rendered" event is triggered by Thorax each time render() // The "rendered" event is triggered by Thorax each time render()
// is called and the result of the template has been appended // is called and the result of the template has been appended
// to the View's $el // to the View's $el
rendered: 'highlightFilter' rendered: 'highlightFilter'
}, },
initialize: function() { initialize: function () {
// Whenever the Todos collection changes re-render the stats // Whenever the Todos collection changes re-render the stats
// render() needs to be called with no arguments, otherwise calling // render() needs to be called with no arguments, otherwise calling
// it with arguments will insert the arguments as content // it with arguments will insert the arguments as content
this.listenTo(window.app.Todos, 'all', _.debounce(function() { this.listenTo(window.app.Todos, 'all', _.debounce(function () {
this.render(); this.render();
})); }));
}, },
// Clear all completed todo items, destroying their models. // Clear all completed todo items, destroying their models.
clearCompleted: function() { clearCompleted: function () {
_.each( window.app.Todos.completed(), function( todo ) { _.each(window.app.Todos.completed(), function (todo) {
todo.destroy(); todo.destroy();
}); });
return false; return false;
}, },
// Each time the stats view is rendered this function will // Each time the stats view is rendered this function will
// be called to generate the context / scope that the template // be called to generate the context / scope that the template
// will be called with. "context" defaults to "return this" // will be called with. "context" defaults to "return this"
context: function() { context: function () {
var remaining = window.app.Todos.remaining().length; var remaining = window.app.Todos.remaining().length;
return { return {
itemText: remaining === 1 ? 'item' : 'items', itemText: remaining === 1 ? 'item' : 'items',
completed: window.app.Todos.completed().length, completed: window.app.Todos.completed().length,
remaining: remaining remaining: remaining
}; };
}, },
// Highlight which filter will appear to be active // Highlight which filter will appear to be active
highlightFilter: function() { highlightFilter: function () {
this.$('#filters li a') this.$('#filters li a')
.removeClass('selected') .removeClass('selected')
.filter('[href="#/' + ( window.app.TodoFilter || '' ) + '"]') .filter('[href="#/' + (window.app.TodoFilter || '') + '"]')
.addClass('selected'); .addClass('selected');
} }
}); });
$(function() { $(function () {
'use strict'; 'use strict';
// Todo Item View // Todo Item View
...@@ -23,27 +23,27 @@ $(function() { ...@@ -23,27 +23,27 @@ $(function() {
// The "rendered" event is triggered by Thorax each time render() // The "rendered" event is triggered by Thorax each time render()
// is called and the result of the template has been appended // is called and the result of the template has been appended
// to the View's $el // to the View's $el
rendered: function() { rendered: function () {
this.$el.toggleClass( 'completed', this.model.get('completed') ); this.$el.toggleClass('completed', this.model.get('completed'));
} }
}, },
// Toggle the `"completed"` state of the model. // Toggle the `"completed"` state of the model.
toggleCompleted: function() { toggleCompleted: function () {
this.model.toggle(); this.model.toggle();
}, },
// Switch this view into `"editing"` mode, displaying the input field. // Switch this view into `"editing"` mode, displaying the input field.
edit: function() { edit: function () {
this.$el.addClass('editing'); this.$el.addClass('editing');
this.$('.edit').focus(); this.$('.edit').focus();
}, },
// Close the `"editing"` mode, saving changes to the todo. // Close the `"editing"` mode, saving changes to the todo.
close: function() { close: function () {
var value = this.$('.edit').val().trim(); var value = this.$('.edit').val().trim();
if ( value ) { if (value) {
this.model.save({ title: value }); this.model.save({ title: value });
} else { } else {
this.clear(); this.clear();
...@@ -53,14 +53,14 @@ $(function() { ...@@ -53,14 +53,14 @@ $(function() {
}, },
// If you hit `enter`, we're through editing the item. // If you hit `enter`, we're through editing the item.
updateOnEnter: function( e ) { updateOnEnter: function (e) {
if ( e.which === ENTER_KEY ) { if (e.which === ENTER_KEY) {
this.close(); this.close();
} }
}, },
// Remove the item, destroy the model from *localStorage* and delete its view. // Remove the item, destroy the model from *localStorage* and delete its view.
clear: function() { clear: function () {
this.model.destroy(); this.model.destroy();
} }
}); });
......
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