Skip to content

Commit

Permalink
Simplifies logic for adding a channel. Changes having global state to…
Browse files Browse the repository at this point in the history
… using the DOM.
  • Loading branch information
hermansc committed Feb 18, 2014
1 parent b63829d commit 9125abb
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions assets/js/views/add_channel_button.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,21 @@
var AddChannelView = Backbone.View.extend({
el: '#add-channel-button',

inputOn: false,
inputId: '#channelname',

events: {
'click': 'enableButtonInput',
'keyup :input': 'processKey',
'blur :input': 'disableButtonInput',
'blur :input': 'render',
},

initialize: function() {
this.render();
},

enableButtonInput: function() {
if (!this.inputOn) {
if (!$(this.inputId).is(":focus")){
$(this.el).html(ich.add_new_channel_form());
this.inputOn = true;
}
},

disableButtonInput: function() {
if (this.inputOn) {
this.render();
this.inputOn = false;
}
}
},

processKey: function (event) {
Expand Down

0 comments on commit 9125abb

Please sign in to comment.