Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

naming changes

  • Loading branch information...
commit 645fad028b721b0e0ae87e82995525a379f0e98f 1 parent 6cd7d71
@jsoverson jsoverson authored
View
4 labs/dependency-examples/backbone_marionette_require/js/views/Header.js
@@ -9,9 +9,9 @@ define(['marionette','templates'], function (Marionette,templates) {
input : '#new-todo'
},
events : {
- 'keypress #new-todo': 'onCreateKeypress'
+ 'keypress #new-todo': 'onInputKeypress'
},
- onCreateKeypress : function(evt) {
+ onInputKeypress : function(evt) {
var ENTER_KEY = 13;
var todoText = this.ui.input.val().trim();
View
10 labs/dependency-examples/backbone_marionette_require/js/views/TodoItemView.js
@@ -13,13 +13,13 @@ define(['marionette','templates'], function (Marionette,templates) {
events : {
'click .destroy' : 'destroy',
- 'dblclick label' : 'editClick',
- 'keypress .edit' : 'updateOnEnter',
+ 'dblclick label' : 'onEditClick',
+ 'keypress .edit' : 'onEditKeypress',
'click .toggle' : 'toggle'
},
initialize : function() {
- this.model.on('change',this.render,this);
+ this.bindTo(this.model, 'change', this.render, this);
},
onRender : function() {
@@ -36,12 +36,12 @@ define(['marionette','templates'], function (Marionette,templates) {
this.model.toggle().save();
},
- editClick : function() {
+ onEditClick : function() {
this.$el.addClass('editing');
this.ui.edit.focus();
},
- updateOnEnter : function(evt) {
+ onEditKeypress : function(evt) {
var ENTER_KEY = 13;
var todoText = this.ui.edit.val().trim();
View
20 labs/dependency-examples/backbone_marionette_require/js/views/TodoListCompositeView.js
@@ -6,33 +6,41 @@ define(['marionette','templates','vent','views/TodoItemView'], function (Marione
return Marionette.CompositeView.extend({
template : templates.todosCompositeView,
itemView : ItemView,
+
ui : {
list : '#todo-list',
toggleAll : '#toggle-all'
},
+
events : {
- 'click #toggle-all' : 'toggleAllClick'
+ 'click #toggle-all' : 'onToggleAllClick'
},
+
initialize : function() {
this.bindTo(vent, 'todoList:filter', this.setFilter, this);
this.bindTo(this.collection, 'all', this.updateToggleCheckbox, this);
},
+
onRender : function() {
this.updateToggleCheckbox();
},
+
updateToggleCheckbox : function() {
- var allCompleted = this.collection.reduce(function(l, r){
- return l && r.get('completed');
- },true);
+ function reduceCompleted(left, right) { return left && right.get('completed'); }
+ var allCompleted = this.collection.reduce(reduceCompleted,true);
this.ui.toggleAll.prop('checked', allCompleted);
},
+
appendHtml : function(collectionView, itemView) {
this.ui.list.append(itemView.el);
},
+
setFilter : function(filter) {
- this.ui.list.removeClass('filter-all filter-completed filter-active').addClass('filter-' + filter);
+ this.ui.list.removeClass('filter-completed filter-active');
+ if (filter) this.ui.list.addClass('filter-' + filter );
},
- toggleAllClick : function(evt) {
+
+ onToggleAllClick : function(evt) {
var isChecked = evt.currentTarget.checked;
this.collection.each(function(todo){
todo.save({'completed': isChecked});
Please sign in to comment.
Something went wrong with that request. Please try again.