forked from thedjpetersen/subway
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds button for joining a channel without writing /join
Fixes issue thedjpetersen#123 and adds a button under the channel list for easily inputing a channel name and pressing enter. This should make it more easy for new users to IRC, joining channels. Someone with a better feel for UI may want to look at how to make this prettier and even simpler.
- Loading branch information
Showing
4 changed files
with
63 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,42 @@ | |||
var AddChannelView = Backbone.View.extend({ | |||
el: '#add-channel-button', | |||
|
|||
inputOn: false, | |||
|
|||
events: { | |||
'click': 'enableButtonInput', | |||
'keyup :input': 'processKey', | |||
'blur :input': 'disableButtonInput', | |||
}, | |||
|
|||
initialize: function() { | |||
this.render(); | |||
}, | |||
|
|||
enableButtonInput: function() { | |||
if (!this.inputOn) { | |||
$(this.el).html(ich.add_new_channel_form()); | |||
this.inputOn = true; | |||
} | |||
}, | |||
|
|||
disableButtonInput: function() { | |||
if (this.inputOn) { | |||
this.render(); | |||
this.inputOn = false; | |||
} | |||
}, | |||
|
|||
processKey: function (event) { | |||
if (event.which == 13) { // enter key | |||
irc.socket.emit('join', event.target.value); | |||
} | |||
return false; | |||
}, | |||
|
|||
render: function(){ | |||
$(this.el).html(ich.add_new_channel()); | |||
return this; | |||
} | |||
|
|||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters