Commit 757d0fca authored by Stephen Sawchuk's avatar Stephen Sawchuk

(flight) code style changes.

parent c488f564
/*global define */ /*global define */
'use strict'; 'use strict';
define( define([
[
'./data/todos', './data/todos',
'./data/stats', './data/stats',
'./ui/new_item', './ui/new_item',
...@@ -10,17 +9,7 @@ define( ...@@ -10,17 +9,7 @@ define(
'./ui/stats', './ui/stats',
'./ui/main_selector', './ui/main_selector',
'./ui/toggle_all' './ui/toggle_all'
], ], function (TodosData, StatsData, NewItemUI, TodoListUI, StatsUI, MainSelectorUI, ToggleAllUI) {
function (
TodosData,
StatsData,
NewItemUI,
TodoListUI,
StatsUI,
MainSelectorUI,
ToggleAllUI) {
var initialize = function () { var initialize = function () {
StatsData.attachTo(document); StatsData.attachTo(document);
TodosData.attachTo(document); TodosData.attachTo(document);
...@@ -34,5 +23,4 @@ define( ...@@ -34,5 +23,4 @@ define(
return { return {
initialize: initialize initialize: initialize
}; };
} });
);
/*global define */ /*global define */
'use strict'; 'use strict';
define( define([
[
'flight/component', 'flight/component',
'../store' '../store'
], ], function (defineComponent, dataStore) {
function (defineComponent, dataStore) {
return defineComponent(stats);
function stats() { function stats() {
this.recount = function () { this.recount = function () {
var todos = dataStore.all(); var todos = dataStore.all();
...@@ -35,5 +30,6 @@ define( ...@@ -35,5 +30,6 @@ define(
this.on(document, 'dataTodoToggledAll', this.recount); this.on(document, 'dataTodoToggledAll', this.recount);
}); });
} }
}
); return defineComponent(stats);
});
/*global define */ /*global define */
'use strict'; 'use strict';
define( define([
[
'flight/component', 'flight/component',
'../store' '../store'
], ], function (defineComponent, dataStore) {
function (defineComponent, dataStore) {
return defineComponent(todos);
function todos() { function todos() {
var filter; var filter;
...@@ -28,7 +23,7 @@ define( ...@@ -28,7 +23,7 @@ define(
this.trigger('dataTodoRemoved', todo); this.trigger('dataTodoRemoved', todo);
}; };
this.load = function (e, data) { this.load = function () {
var todos; var todos;
filter = localStorage.getItem('filter'); filter = localStorage.getItem('filter');
...@@ -74,8 +69,7 @@ define( ...@@ -74,8 +69,7 @@ define(
todos = dataStore.find(function (each) { todos = dataStore.find(function (each) {
return (typeof each[filter] !== 'undefined') ? each.completed : !each.completed; return (typeof each[filter] !== 'undefined') ? each.completed : !each.completed;
}); });
} } else {
else {
todos = dataStore.all(); todos = dataStore.all();
} }
...@@ -101,5 +95,6 @@ define( ...@@ -101,5 +95,6 @@ define(
this.on(document, 'uiFilterRequested', this.filter); this.on(document, 'uiFilterRequested', this.filter);
}); });
} }
}
); return defineComponent(todos);
});
/*global define */
'use strict'; 'use strict';
define( define([
[
'depot' 'depot'
], ], function (depot) {
function (depot) {
return depot('todos', { idAttribute: 'id' }); return depot('todos', { idAttribute: 'id' });
} });
);
/*global define */ /*global define */
'use strict'; 'use strict';
define( define([
[
'flight/component' 'flight/component'
], ], function (defineComponent) {
function (defineComponent) {
return defineComponent(mainSelector);
function mainSelector() { function mainSelector() {
this.toggle = function (e, data) { this.toggle = function (e, data) {
var toggle = data.all > 0; var toggle = data.all > 0;
...@@ -20,5 +15,6 @@ define( ...@@ -20,5 +15,6 @@ define(
this.on(document, 'dataStatsCounted', this.toggle); this.on(document, 'dataStatsCounted', this.toggle);
}); });
} }
}
); return defineComponent(mainSelector);
});
/*global define */ /*global define */
'use strict'; 'use strict';
define( define([
[
'flight/component' 'flight/component'
], ], function (defineComponent) {
function (defineComponent) {
return defineComponent(newItem);
function newItem() { function newItem() {
var ENTER_KEY = 13; var ENTER_KEY = 13;
...@@ -29,5 +24,6 @@ define( ...@@ -29,5 +24,6 @@ define(
this.on('keydown', this.createOnEnter); this.on('keydown', this.createOnEnter);
}); });
} }
}
); return defineComponent(newItem);
});
/*global define */ /*global define */
'use strict'; 'use strict';
define( define([
[
'flight/component', 'flight/component',
'./with_filters', './with_filters',
'text!app/templates/stats.html', 'text!app/templates/stats.html',
'../utils' '../utils'
], ], function (defineComponent, withFilters, statsTmpl, utils) {
function (defineComponent, withFilters, statsTmpl, utils) {
return defineComponent(stats, withFilters);
function stats() { function stats() {
var template = utils.tmpl(statsTmpl); var template = utils.tmpl(statsTmpl);
...@@ -27,7 +22,7 @@ define( ...@@ -27,7 +22,7 @@ define(
this.markSelected(data.filter); this.markSelected(data.filter);
}; };
this.clearCompleted = function (e, data) { this.clearCompleted = function () {
this.trigger('uiClearRequested'); this.trigger('uiClearRequested');
}; };
...@@ -37,5 +32,6 @@ define( ...@@ -37,5 +32,6 @@ define(
this.on('click', { 'clearCompletedSelector': this.clearCompleted }); this.on('click', { 'clearCompletedSelector': this.clearCompleted });
}); });
} }
}
); return defineComponent(stats, withFilters);
});
/*global define $ */ /*global define, $ */
'use strict'; 'use strict';
define( define([
[
'flight/component', 'flight/component',
'text!app/templates/todo.html', 'text!app/templates/todo.html',
'../utils' '../utils'
], ], function (defineComponent, todoTmpl, utils) {
function (defineComponent, todoTmpl, utils) {
return defineComponent(todoList);
function todoList() { function todoList() {
var ENTER_KEY = 13; var ENTER_KEY = 13;
var template = utils.tmpl(todoTmpl); var template = utils.tmpl(todoTmpl);
...@@ -44,7 +39,7 @@ define( ...@@ -44,7 +39,7 @@ define(
this.select('editSelector').focus(); this.select('editSelector').focus();
}; };
this.requestUpdate = function (e, data) { this.requestUpdate = function (e) {
var $inputEl = $(e.currentTarget); var $inputEl = $(e.currentTarget);
var $todoEl = $inputEl.parents('li'); var $todoEl = $inputEl.parents('li');
var value = $inputEl.val().trim(); var value = $inputEl.val().trim();
...@@ -54,7 +49,7 @@ define( ...@@ -54,7 +49,7 @@ define(
return; return;
} }
!$todoEl.removeClass('editing'); $todoEl.removeClass('editing');
if (value) { if (value) {
$todoEl.find('label').html(value); $todoEl.find('label').html(value);
...@@ -109,5 +104,6 @@ define( ...@@ -109,5 +104,6 @@ define(
this.trigger('uiLoadRequested'); this.trigger('uiLoadRequested');
}); });
} }
}
); return defineComponent(todoList);
});
/*global define */ /*global define */
'use strict'; 'use strict';
define( define([
[
'flight/component' 'flight/component'
], ], function (defineComponent) {
function (defineComponent) {
return defineComponent(toggleAll);
function toggleAll() { function toggleAll() {
this.toggleAllComplete = function () { this.toggleAllComplete = function () {
this.trigger('uiToggleAllRequested', { this.trigger('uiToggleAllRequested', {
...@@ -25,5 +20,6 @@ define( ...@@ -25,5 +20,6 @@ define(
this.on(document, 'dataStatsCounted', this.toggleCheckbox); this.on(document, 'dataStatsCounted', this.toggleCheckbox);
}); });
} }
}
); return defineComponent(toggleAll);
});
/*global define $ */ /*global define, $ */
'use strict'; 'use strict';
define( define(function () {
function () {
return function withFilters() { return function withFilters() {
this.defaultAttrs({ this.defaultAttrs({
filterSelector: '#filters a' filterSelector: '#filters a'
...@@ -24,5 +23,4 @@ define( ...@@ -24,5 +23,4 @@ define(
this.on('click', { filterSelector: this.chooseFilter }); this.on('click', { filterSelector: this.chooseFilter });
}); });
}; };
} });
);
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
// tmpl function scooped from underscore. // tmpl function scooped from underscore.
// http://documentcloud.github.com/underscore/#template // http://documentcloud.github.com/underscore/#template
define(function () { define(function () {
var _ = {}; var _ = {};
// List of HTML entities for escaping. // List of HTML entities for escaping.
...@@ -128,5 +127,7 @@ define(function () { ...@@ -128,5 +127,7 @@ define(function () {
return template; return template;
}; };
return { tmpl: template }; return {
tmpl: template
};
}); });
<span id="todo-count"><strong><%= remaining %></strong> <%= remaining == 1 ? 'item' : 'items' %> left</span> <span id="todo-count">
<strong><%= remaining %></strong> <%= remaining == 1 ? 'item' : 'items' %> left
</span>
<ul id="filters"> <ul id="filters">
<li> <li>
<a href="#/">All</a> <a href="#/">All</a>
...@@ -11,5 +13,5 @@ ...@@ -11,5 +13,5 @@
</li> </li>
</ul> </ul>
<% if (completed) { %> <% if (completed) { %>
<button id="clear-completed">Clear completed (<%= completed %>)</button> <button id="clear-completed">Clear completed (<%= completed %>)</button>
<% } %> <% } %>
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