Commit 1c2abb79 authored by Arthur Verschaeve's avatar Arthur Verschaeve Committed by Sindre Sorhus

Close #1292 PR: Componentjs: Minor cleanup.

parent 9c6ae435
/* global cs, app, Router, $, _ */ /* global cs, app, Router, $ */
(function () { (function () {
'use strict'; 'use strict';
......
...@@ -50,8 +50,7 @@ ...@@ -50,8 +50,7 @@
cs(self).value('data:status-items-remaining', remaining); cs(self).value('data:status-items-remaining', remaining);
if (remaining === 0 && completed > 0) { if (remaining === 0 && completed > 0) {
cs(self).value('state:all-item-selected', true); cs(self).value('state:all-item-selected', true);
} } else if (remaining > 0) {
else if (remaining > 0) {
cs(self).value('state:all-item-selected', false); cs(self).value('state:all-item-selected', false);
} }
} }
......
...@@ -63,8 +63,7 @@ ...@@ -63,8 +63,7 @@
if (items.length === 0) { if (items.length === 0) {
$('.todo__main', ui).addClass('hidden'); $('.todo__main', ui).addClass('hidden');
$('.todo__footer', ui).addClass('hidden'); $('.todo__footer', ui).addClass('hidden');
} } else {
else {
$('.todo__main', ui).removeClass('hidden'); $('.todo__main', ui).removeClass('hidden');
$('.todo__footer', ui).removeClass('hidden'); $('.todo__footer', ui).removeClass('hidden');
} }
...@@ -79,7 +78,7 @@ ...@@ -79,7 +78,7 @@
// one-way bind key-press and field blur interactions to leave editing mode // one-way bind key-press and field blur interactions to leave editing mode
var blur = function (el, takeTitle) { var blur = function (el, takeTitle) {
var id = $(el).parent().data('id') + ''; var id = String($(el).parent().data('id'));
$(el).parent().removeClass('editing'); $(el).parent().removeClass('editing');
if (takeTitle) { if (takeTitle) {
var items = cs(self).value('data:item-list'); var items = cs(self).value('data:item-list');
...@@ -109,7 +108,7 @@ ...@@ -109,7 +108,7 @@
// one-way bind click interaction to toggle item completion // one-way bind click interaction to toggle item completion
$('.todo__toggle', ui).click(function (ev) { $('.todo__toggle', ui).click(function (ev) {
var id = $(ev.target).parent().parent().data('id') + ''; var id = String($(ev.target).parent().parent().data('id'));
var items = cs(self).value('data:item-list'); var items = cs(self).value('data:item-list');
var item = _.find(items, { id: id }); var item = _.find(items, { id: id });
item.completed = !item.completed; item.completed = !item.completed;
...@@ -119,7 +118,7 @@ ...@@ -119,7 +118,7 @@
// one-way bind click interaction to remove item // one-way bind click interaction to remove item
$('.todo__destroy', ui).click(function (ev) { $('.todo__destroy', ui).click(function (ev) {
var id = $(ev.target).parent().parent().data('id') + ''; var id = String($(ev.target).parent().parent().data('id'));
var items = cs(self).value('data:item-list'); var items = cs(self).value('data:item-list');
var item = _.find(items, { id: id }); var item = _.find(items, { id: id });
cs(self).value('data:item-list', _.without(items, item)); cs(self).value('data:item-list', _.without(items, item));
...@@ -167,8 +166,7 @@ ...@@ -167,8 +166,7 @@
if (value > 0) { if (value > 0) {
$('.todo__completed', ui).css('display', 'block'); $('.todo__completed', ui).css('display', 'block');
$('*[data-bind=\'data:status-items-completed\']', ui).text(value); $('*[data-bind=\'data:status-items-completed\']', ui).text(value);
} } else {
else {
$('.todo__completed', ui).css('display', 'none'); $('.todo__completed', ui).css('display', 'none');
} }
} }
......
<!doctype html> <!doctype html>
<html lang="en" data-framework="componentjs"> <html lang="en" data-framework="componentjs">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>ComponentJS • TodoMVC</title> <title>ComponentJS • TodoMVC</title>
<!-- load third-party libraries --> <!-- load third-party libraries -->
<script src="bower_components/lodash/dist/lodash.js"></script> <script src="bower_components/lodash/dist/lodash.js"></script>
<script src="bower_components/uuid-js/lib/uuid.js"></script> <script src="bower_components/uuid-js/lib/uuid.js"></script>
<script src="bower_components/nunjucks/browser/nunjucks.js"></script> <script src="bower_components/nunjucks/browser/nunjucks.js"></script>
<script src="bower_components/jquery/jquery.js"></script> <script src="bower_components/jquery/jquery.js"></script>
<script src="bower_components/jquery-markup/jquery.markup.js"></script> <script src="bower_components/jquery-markup/jquery.markup.js"></script>
<script src="bower_components/director/build/director.js"></script> <script src="bower_components/director/build/director.js"></script>
<script src="bower_components/componentjs/component.js"></script> <script src="bower_components/componentjs/component.js"></script>
<script src="bower_components/componentjs/component.plugin.jquery.js"></script> <script src="bower_components/componentjs/component.plugin.jquery.js"></script>
<!-- load and call application initialization code --> <!-- load and call application initialization code -->
<script src="app/app.js"></script> <script src="app/app.js"></script>
<script type="text/javascript">app.boot.init()</script> <script>app.boot.init()</script>
<!-- load the service and datamodel parts --> <!-- load the service and datamodel parts -->
<script src="app/app-dm.js"></script> <script src="app/app-dm.js"></script>
<script src="app/app-sv.js"></script> <script src="app/app-sv.js"></script>
<!-- load the root UI component --> <!-- load the root UI component -->
<script src="app/app-ui-constants.js"></script> <script src="app/app-ui-constants.js"></script>
<script src="app/app-ui-composite-root.js"></script> <script src="app/app-ui-composite-root.js"></script>
<link href="app/app-ui-composite-root-style.css" rel="stylesheet" type="text/css"> <link href="app/app-ui-composite-root-style.css" rel="stylesheet">
<!-- load the main UI component --> <!-- load the main UI component -->
<script src="app/app-ui-composite-main.js"></script> <script src="app/app-ui-composite-main.js"></script>
<link href="app/app-ui-composite-main-mask.html" rel="markup" type="text/x-markup-nunjucks"> <link href="app/app-ui-composite-main-mask.html" rel="markup" type="text/x-markup-nunjucks">
<link href="app/app-ui-composite-main-style.css" rel="stylesheet" type="text/css"> <link href="app/app-ui-composite-main-style.css" rel="stylesheet">
<!-- load the todo UI component --> <!-- load the todo UI component -->
<script src="app/app-ui-widget-todo-view.js"></script> <script src="app/app-ui-widget-todo-view.js"></script>
<script src="app/app-ui-widget-todo-model.js"></script> <script src="app/app-ui-widget-todo-model.js"></script>
<link href="app/app-ui-widget-todo-mask.html" rel="markup" type="text/x-markup-nunjucks"> <link href="app/app-ui-widget-todo-mask.html" rel="markup" type="text/x-markup-nunjucks">
<link href="app/app-ui-widget-todo-style.css" rel="stylesheet" type="text/css"> <link href="app/app-ui-widget-todo-style.css" rel="stylesheet">
<!-- load required todomvc.com integration functions --> <!-- load required todomvc.com integration functions -->
<link href="bower_components/todomvc-common/base.css" rel="stylesheet" type="text/css"> <link href="bower_components/todomvc-common/base.css" rel="stylesheet">
<script src="bower_components/todomvc-common/base.js"></script> <script src="bower_components/todomvc-common/base.js"></script>
<!-- call application main code --> <!-- call application main code -->
<script type="text/javascript">app.boot.main()</script> <script>app.boot.main()</script>
</head> </head>
<body> <body>
</body> </body>
</html> </html>
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