Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

backbone examples: minor style updates. #395

Merged
merged 1 commit into from

2 participants

ssarj Sindre Sorhus
ssarj
  • Hopefully not off the mark here, but it I tidied up what I thought was inconsistent use of the '$' prefix.
  • A few other minor style fixes.
  • Fixed up script reference from backbone.xmpp.

Nothing earth shattering, but thought may as well just do it :)

Thanks for the repo!

Steve Sarjeant backbone: Consistent use of '$' prefix, other minor style changes.
backbone.xmpp: Fixed up backbone script reference.
8b95665
Sindre Sorhus sindresorhus merged commit e624af7 into from
Sindre Sorhus

Thanks! I :heart: style and consistency improvements :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 12, 2013
  1. backbone: Consistent use of '$' prefix, other minor style changes.

    Steve Sarjeant authored
    backbone.xmpp: Fixed up backbone script reference.
This page is out of date. Refresh to see the latest.
12 architecture-examples/backbone/js/views/app.js
View
@@ -27,8 +27,8 @@ $(function( $ ) {
// collection, when items are added or changed. Kick things off by
// loading any preexisting todos that might be saved in *localStorage*.
initialize: function() {
- this.input = this.$('#new-todo');
this.allCheckbox = this.$('#toggle-all')[0];
+ this.$input = this.$('#new-todo');
this.$footer = this.$('#footer');
this.$main = this.$('#main');
@@ -81,18 +81,18 @@ $(function( $ ) {
app.Todos.each(this.addOne, this);
},
- filterOne : function (todo) {
+ filterOne: function( todo ) {
todo.trigger('visible');
},
- filterAll : function () {
+ filterAll: function() {
app.Todos.each(this.filterOne, this);
},
// Generate the attributes for a new Todo item.
newAttributes: function() {
return {
- title: this.input.val().trim(),
+ title: this.$input.val().trim(),
order: app.Todos.nextOrder(),
completed: false
};
@@ -101,12 +101,12 @@ $(function( $ ) {
// If you hit return in the main input field, create new **Todo** model,
// persisting it to *localStorage*.
createOnEnter: function( e ) {
- if ( e.which !== ENTER_KEY || !this.input.val().trim() ) {
+ if ( e.which !== ENTER_KEY || !this.$input.val().trim() ) {
return;
}
app.Todos.create( this.newAttributes() );
- this.input.val('');
+ this.$input.val('');
},
// Clear all completed todo items, destroying their models.
14 architecture-examples/backbone/js/views/todos.js
View
@@ -17,7 +17,7 @@ $(function() {
// The DOM events specific to an item.
events: {
- 'click .toggle': 'togglecompleted',
+ 'click .toggle': 'toggleCompleted',
'dblclick label': 'edit',
'click .destroy': 'clear',
'keypress .edit': 'updateOnEnter',
@@ -39,15 +39,15 @@ $(function() {
this.$el.toggleClass( 'completed', this.model.get('completed') );
this.toggleVisible();
- this.input = this.$('.edit');
+ this.$input = this.$('.edit');
return this;
},
- toggleVisible : function () {
+ toggleVisible: function() {
this.$el.toggleClass( 'hidden', this.isHidden());
},
- isHidden : function () {
+ isHidden: function() {
var isCompleted = this.model.get('completed');
return ( // hidden cases only
(!isCompleted && app.TodoFilter === 'completed')
@@ -56,19 +56,19 @@ $(function() {
},
// Toggle the `"completed"` state of the model.
- togglecompleted: function() {
+ toggleCompleted: function() {
this.model.toggle();
},
// Switch this view into `"editing"` mode, displaying the input field.
edit: function() {
this.$el.addClass('editing');
- this.input.focus();
+ this.$input.focus();
},
// Close the `"editing"` mode, saving changes to the todo.
close: function() {
- var value = this.input.val().trim();
+ var value = this.$input.val().trim();
if ( value ) {
this.model.save({ title: value });
12 dependency-examples/backbone_require/js/views/app.js
View
@@ -28,8 +28,8 @@ define([
// collection, when items are added or changed. Kick things off by
// loading any preexisting todos that might be saved in *localStorage*.
initialize: function() {
- this.input = this.$('#new-todo');
this.allCheckbox = this.$('#toggle-all')[0];
+ this.$input = this.$('#new-todo');
this.$footer = this.$('#footer');
this.$main = this.$('#main');
@@ -82,18 +82,18 @@ define([
Todos.each(this.addOne, this);
},
- filterOne : function (todo) {
+ filterOne: function( todo ) {
todo.trigger("visible");
},
- filterAll : function () {
+ filterAll: function() {
Todos.each(this.filterOne, this);
},
// Generate the attributes for a new Todo item.
newAttributes: function() {
return {
- title: this.input.val().trim(),
+ title: this.$input.val().trim(),
order: Todos.nextOrder(),
completed: false
};
@@ -102,12 +102,12 @@ define([
// If you hit return in the main input field, create new **Todo** model,
// persisting it to *localStorage*.
createOnEnter: function( e ) {
- if ( e.which !== Common.ENTER_KEY || !this.input.val().trim() ) {
+ if ( e.which !== Common.ENTER_KEY || !this.$input.val().trim() ) {
return;
}
Todos.create( this.newAttributes() );
- this.input.val('');
+ this.$input.val('');
},
// Clear all completed todo items, destroying their models.
14 dependency-examples/backbone_require/js/views/todos.js
View
@@ -14,7 +14,7 @@ define([
// The DOM events specific to an item.
events: {
- 'click .toggle': 'togglecompleted',
+ 'click .toggle': 'toggleCompleted',
'dblclick label': 'edit',
'click .destroy': 'clear',
'keypress .edit': 'updateOnEnter',
@@ -36,15 +36,15 @@ define([
this.$el.toggleClass( 'completed', this.model.get('completed') );
this.toggleVisible();
- this.input = this.$('.edit');
+ this.$input = this.$('.edit');
return this;
},
- toggleVisible : function () {
+ toggleVisible: function() {
this.$el.toggleClass( 'hidden', this.isHidden());
},
- isHidden : function () {
+ isHidden: function() {
var isCompleted = this.model.get('completed');
return ( // hidden cases only
(!isCompleted && Common.TodoFilter === 'completed')
@@ -53,19 +53,19 @@ define([
},
// Toggle the `"completed"` state of the model.
- togglecompleted: function() {
+ toggleCompleted: function() {
this.model.toggle();
},
// Switch this view into `"editing"` mode, displaying the input field.
edit: function() {
this.$el.addClass('editing');
- this.input.focus();
+ this.$input.focus();
},
// Close the `"editing"` mode, saving changes to the todo.
close: function() {
- var value = this.input.val().trim();
+ var value = this.$input.val().trim();
if ( value ){
this.model.save({ title: value });
2  labs/architecture-examples/backbone.xmpp/index.html
View
@@ -58,7 +58,7 @@
<script src="../../../assets/base.js"></script>
<script src="../../../assets/jquery.min.js"></script>
<script src="../../../assets/lodash.min.js"></script>
- <script src="../../../architecture-examples/backbone/js/lib/backbone-min.js"></script>
+ <script src="../../../architecture-examples/backbone/js/lib/backbone.js"></script>
<script src="js/lib/strophe.js"></script>
<script src="js/lib/strophe.forms.js"></script>
<script src="js/lib/strophe.pubsub.js"></script>
8 labs/architecture-examples/backbone.xmpp/js/views/app.js
View
@@ -27,7 +27,6 @@ $(function( $ ) {
// collection, when items are added or changed. Kick things off by
// loading any preexisting todos that might be saved in *localStorage*.
initialize: function() {
- this.input = this.$('#new-todo');
this.allCheckbox = this.$('#toggle-all')[0];
window.app.Todos.on( 'add', this.addAll, this );
@@ -35,6 +34,7 @@ $(function( $ ) {
window.app.Todos.on( 'change:completed', this.addAll, this );
window.app.Todos.on( 'all', this.render, this );
+ this.$input = this.$('#new-todo');
this.$footer = this.$('#footer');
this.$main = this.$('#main');
@@ -95,7 +95,7 @@ $(function( $ ) {
// Generate the attributes for a new Todo item.
newAttributes: function() {
return {
- title: this.input.val().trim(),
+ title: this.$input.val().trim(),
order: app.Todos.nextOrder(),
completed: false
};
@@ -104,12 +104,12 @@ $(function( $ ) {
// If you hit return in the main input field, create new **Todo** model,
// persisting it to *localStorage*.
createOnEnter: function( e ) {
- if ( e.which !== ENTER_KEY || !this.input.val().trim() ) {
+ if ( e.which !== ENTER_KEY || !this.$input.val().trim() ) {
return;
}
app.Todos.create( this.newAttributes(), {wait: true} );
- this.input.val('');
+ this.$input.val('');
},
// Clear all completed todo items, destroying their models.
12 labs/architecture-examples/backbone.xmpp/js/views/todos.js
View
@@ -17,7 +17,7 @@ $(function() {
// The DOM events specific to an item.
events: {
- 'click .toggle': 'togglecompleted',
+ 'click .toggle': 'toggleCompleted',
'dblclick label': 'edit',
'click .destroy': 'clear',
'keypress .edit': 'updateOnEnter',
@@ -33,7 +33,7 @@ $(function() {
this.model.collection.on( 'remove', this.remoteRemove, this);
},
- remoteRemove: function (model) {
+ remoteRemove: function( model ) {
if (model.id === this.model.id) {
this.remove();
}
@@ -44,24 +44,24 @@ $(function() {
this.$el.html( this.template( this.model.toJSON() ) );
this.$el.toggleClass( 'completed', this.model.get('completed') );
- this.input = this.$('.edit');
+ this.$input = this.$('.edit');
return this;
},
// Toggle the `"completed"` state of the model.
- togglecompleted: function() {
+ toggleCompleted: function() {
this.model.toggle();
},
// Switch this view into `"editing"` mode, displaying the input field.
edit: function() {
this.$el.addClass('editing');
- this.input.focus();
+ this.$input.focus();
},
// Close the `"editing"` mode, saving changes to the todo.
close: function() {
- var value = this.input.val().trim();
+ var value = this.$input.val().trim();
if ( value ) {
this.model.save({ title: value });
Something went wrong with that request. Please try again.