Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Agilityjs pull request for fixing issue #257 #275

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion architecture-examples/agilityjs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Agility.js • TodoMVC</title>
<link rel="stylesheet" href="../../assets/base.css">
<!--[if IE]>
Expand All @@ -16,7 +17,7 @@ <h1>todos</h1>
</header>
<section id="main" data-bind="class = mainStyle">
<input id="toggle-all" type="checkbox">
<label for="toggle-all">Mark all as completed</label>
<label for="toggle-all">Mark all as complete</label>
<ul id="todo-list">
<li>
<div class="view">
Expand Down
42 changes: 27 additions & 15 deletions architecture-examples/agilityjs/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
this.view.$().toggleClass( 'completed', this.model.get('completed') );
app.updateStatus();
},
'dblclick label': function() {
'dblclick &': function() {
this.view.$().addClass('editing');
this.view.$('.edit').focus();
},
Expand All @@ -42,17 +42,25 @@
'destroy': function() {
this.erase();
},
'change:title': function() {
this.view.$().removeClass('editing');
var title = this.model.get('title').trim();
if ( title ) {
this.model.set({
title: title
});
} else {
this.destroy();
'blur input': function() {
this.updateTitle();
},
'keyup input': function() {
if ( event.which === ENTER_KEY ) {
this.updateTitle();
}
}
},
updateTitle: function() {
this.view.$().removeClass('editing');
var title = this.model.get('title').trim();
if ( title ) {
this.model.set({
title: title
});
} else {
this.destroy();
}
}
}).persist( $$.adapter.localStorage, {
collection: 'todos-agilityjs'
Expand Down Expand Up @@ -117,13 +125,15 @@
});
this.model.set({
todoCount: count - completedCount + '',
pluralizer: (count > 1 ? 's' : ''),
pluralizer: (count - completedCount === 1 ? '' : 's'),
completedCount: completedCount + '',
mainStyle: (count === 0 ? 'hidden' : ''),
clearBtnStyle: (completedCount === 0 ? 'hidden' : '')
});
// update toggle-all checked status
$('#toggle-all').prop( 'checked', completedCount === count );
// update the view according to the current filter.
this.applyFilter();
},
// filter handler
filters: {
Expand All @@ -138,10 +148,12 @@
}
},
applyFilter: function( hash ) {
var isVisible = this.filters[hash];
this.each(function( id, item ) {
item.view.$().toggleClass( 'hidden', !isVisible( item ) );
});
var isVisible = this.filters[hash || location.hash];
if ( isVisible ) {
this.each(function( id, item ) {
item.view.$().toggleClass( 'hidden', !isVisible( item ) );
});
}
}
}).persist();
$$.document.prepend( app );
Expand Down