.data('member', member);\r
});\r
},\r
- nickClick: function (x) {\r
- var $target = $(x.currentTarget).parent('li'),\r
+ nickClick: function (event) {\r
+ var $target = $(event.currentTarget).parent('li'),\r
member = $target.data('member'),\r
userbox;\r
\r
+ event.stopPropagation();\r
+\r
// If the userbox already exists here, hide it\r
if ($target.find('.userbox').length > 0) {\r
$('.userbox', this.$el).remove();\r
\r
userbox = new _kiwi.view.UserBox();\r
userbox.member = member;\r
+ userbox.channel = this.model.channel;\r
+\r
+ if (!this.model.getByNick(_kiwi.gateway.get('nick')).get('is_op')) {\r
+ userbox.$el.children('.if_op').remove();\r
+ }\r
+\r
+ var menu = new _kiwi.view.MenuBox(member.get('nick') || 'User');\r
+ menu.addItem('userbox', userbox.$el);\r
+ menu.show();\r
\r
- // Remove any existing userboxes\r
- $('.userbox', this.$el).remove();\r
+ // Position the userbox + menubox\r
+ (function() {\r
+ var t = event.pageY,\r
+ m_bottom = t + menu.$el.outerHeight(), // Where the bottom of menu will be\r
+ memberlist_bottom = this.$el.parent().offset().top + this.$el.parent().outerHeight();\r
\r
- $target.append(userbox.$el);\r
+ // If the bottom of the userbox is going to be too low.. raise it\r
+ if (m_bottom > memberlist_bottom){\r
+ t = memberlist_bottom - menu.$el.outerHeight();\r
+ }\r
+\r
+ // Set the new positon\r
+ menu.$el.offset({\r
+ left: _kiwi.app.view.$el.width() - menu.$el.outerWidth() - 20,\r
+ top: t\r
+ });\r
+ }).call(this);\r
},\r
show: function () {\r
$('#memberlists').children().removeClass('active');\r
events: {\r
'click .query': 'queryClick',\r
'click .info': 'infoClick',\r
- 'click .slap': 'slapClick'\r
+ 'click .slap': 'slapClick',\r
+ 'click .op': 'opClick',\r
+ 'click .deop': 'deopClick',\r
+ 'click .voice': 'voiceClick',\r
+ 'click .devoice': 'devoiceClick',\r
+ 'click .kick': 'kickClick',\r
+ 'click .ban': 'banClick'\r
},\r
\r
initialize: function () {\r
\r
slapClick: function (event) {\r
_kiwi.app.controlbox.processInput('/slap ' + this.member.get('nick'));\r
+ },\r
+\r
+ opClick: function (event) {\r
+ _kiwi.app.controlbox.processInput('/mode ' + this.channel.get('name') + ' +o ' + this.member.get('nick'));\r
+ },\r
+\r
+ deopClick: function (event) {\r
+ _kiwi.app.controlbox.processInput('/mode ' + this.channel.get('name') + ' -o ' + this.member.get('nick'));\r
+ },\r
+\r
+ voiceClick: function (event) {\r
+ _kiwi.app.controlbox.processInput('/mode ' + this.channel.get('name') + ' +v ' + this.member.get('nick'));\r
+ },\r
+\r
+ devoiceClick: function (event) {\r
+ _kiwi.app.controlbox.processInput('/mode ' + this.channel.get('name') + ' -v ' + this.member.get('nick'));\r
+ },\r
+\r
+ kickClick: function (event) {\r
+ // TODO: Enable the use of a custom kick message\r
+ _kiwi.app.controlbox.processInput('/kick ' + this.member.get('nick') + ' Bye!');\r
+ },\r
+\r
+ banClick: function (event) {\r
+ // TODO: Set ban on host, not just on nick\r
+ _kiwi.app.controlbox.processInput('/mode ' + this.channel.get('name') + ' +b ' + this.member.get('nick') + '!*');\r
}\r
});\r
\r
events: {\r
'submit form': 'submitForm',\r
'click .show_more': 'showMore',\r
- 'change .have_pass input': 'showPass'\r
+ 'change .have_pass input': 'showPass',\r
+ 'change .have_key input': 'showKey'\r
},\r
\r
initialize: function () {\r
}\r
},\r
\r
+ showKey: function (event) {\r
+ if (this.$el.find('tr.have_key input').is(':checked')) {\r
+ this.$el.find('tr.key').show().find('input').focus();\r
+ } else {\r
+ this.$el.find('tr.key').hide().find('input').val('');\r
+ }\r
+ },\r
+\r
showMore: function (event) {\r
$('.more', this.$el).slideDown('fast');\r
$('input.server', this.$el).select();\r
$('input.server', this.$el).val(server);\r
$('input.port', this.$el).val(port);\r
$('input.ssl', this.$el).prop('checked', ssl);\r
+ $('input#server_select_show_pass', this.$el).prop('checked', !(!password));\r
$('input.password', this.$el).val(password);\r
+ if (!(!password)) {\r
+ $('tr.pass', this.$el).show();\r
+ }\r
$('input.channel', this.$el).val(channel);\r
+ $('input#server_select_show_channel_key', this.$el).prop('checked', !(!channel_key));\r
$('input.channel_key', this.$el).val(channel_key);\r
+ if (!(!channel_key)) {\r
+ $('tr.key', this.$el).show();\r
+ }\r
},\r
\r
hide: function () {\r
\r
} else if (is_highlight) {\r
_kiwi.app.view.alertWindow('* People are talking!');\r
+ _kiwi.app.view.playSound('highlight');\r
this.alert('highlight');\r
\r
} else {\r
this.alert('activity');\r
}\r
\r
+ if (this.model.isQuery() && !this.model.isActive()) {\r
+ _kiwi.app.view.alertWindow('* People are talking!');\r
+ _kiwi.app.view.playSound('highlight');\r
+ }\r
+\r
// Update the activity counters\r
(function () {\r
// Only inrement the counters if we're not the active panel\r
\r
if (panel.isServer()) {\r
panel.tab.addClass('server');\r
+ panel.tab.addClass('icon-nonexistant');\r
}\r
\r
panel.tab.data('panel_id', panel.cid)\r
\r
// Only show the part image on non-server tabs\r
if (!panel.isServer()) {\r
- panel.tab.append('<span class="part"></span>');\r
+ panel.tab.append('<span class="part icon-nonexistant"></span>');\r
}\r
},\r
\r
if (!this._callbacks['command:' + command]) {\r
this.trigger('unknown_command', {command: command, params: params});\r
}\r
+ },\r
+\r
+\r
+ addPluginIcon: function ($icon) {\r
+ var $tool = $('<div class="tool"></div>').append($icon);\r
+ this.$el.find('.input_tools').append($tool);\r
+ _kiwi.app.view.doLayout();\r
}\r
});\r
\r
return 'This will close all KiwiIRC conversations. Are you sure you want to close this window?';\r
}\r
};\r
+\r
+ this.initSound();\r
},\r
\r
\r
// And move the handle just out of sight to the right\r
el_resize_handle.css('left', el_panels.outerWidth(true));\r
}\r
+\r
+ var input_wrap_width = parseInt($('#kiwi #controlbox .input_tools').outerWidth());\r
+ el_controlbox.find('.input_wrap').css('right', input_wrap_width + 7);\r
},\r
\r
\r
$('#controlbox').slideDown(0);\r
this.doLayout();\r
}\r
+ },\r
+\r
+\r
+ initSound: function () {\r
+ var that = this,\r
+ base_path = this.model.get('base_path');\r
+\r
+ $script(base_path + '/assets/libs/soundmanager2/soundmanager2-nodebug-jsmin.js', function() {\r
+ if (typeof soundManager === 'undefined')\r
+ return;\r
+\r
+ soundManager.setup({\r
+ url: base_path + '/assets/libs/soundmanager2/',\r
+ flashVersion: 9, // optional: shiny features (default = 8)// optional: ignore Flash where possible, use 100% HTML5 mode\r
+ preferFlash: true,\r
+\r
+ onready: function() {\r
+ that.sound_object = soundManager.createSound({\r
+ id: 'highlight',\r
+ url: base_path + '/assets/sound/highlight.mp3'\r
+ });\r
+ }\r
+ });\r
+ });\r
+ },\r
+\r
+\r
+ playSound: function (sound_id) {\r
+ if (!this.sound_object) return;\r
+\r
+ if (_kiwi.global.settings.get('mute_sounds'))\r
+ return;\r
+ \r
+ soundManager.play(sound_id);\r
}\r
});\r
\r
\r
return html;\r
}\r
-});
\ No newline at end of file
+});\r
+\r
+\r
+\r
+_kiwi.view.MenuBox = Backbone.View.extend({\r
+ events: {\r
+ 'click .ui_menu_foot .close': 'dispose'\r
+ },\r
+\r
+ initialize: function(title) {\r
+ var that = this;\r
+\r
+ this.$el = $('<div class="ui_menu"></div>');\r
+\r
+ this._title = title || '';\r
+ this._items = {};\r
+ this._display_footer = true;\r
+\r
+ this._close_proxy = function(event) {\r
+ that.onDocumentClick(event);\r
+ };\r
+ $(document).on('click', this._close_proxy);\r
+ },\r
+\r
+\r
+ render: function() {\r
+ var that = this;\r
+\r
+ this.$el.find('*').remove();\r
+\r
+ if (this._title) {\r
+ $('<div class="ui_menu_title"></div>')\r
+ .text(this._title)\r
+ .appendTo(this.$el);\r
+ }\r
+\r
+\r
+ _.each(this._items, function(item) {\r
+ var $item = $('<div class="ui_menu_content hover"></div>')\r
+ .append(item);\r
+\r
+ that.$el.append($item);\r
+ });\r
+\r
+ if (this._display_footer)\r
+ this.$el.append('<div class="ui_menu_foot"><a class="close" onclick="">Close <i class="icon-remove"></i></a></div>');\r
+ },\r
+\r
+\r
+ onDocumentClick: function(event) {\r
+ var $target = $(event.target);\r
+\r
+ // If this is not itself AND we don't contain this element, dispose $el\r
+ if ($target[0] != this.$el[0] && this.$el.has($target).length === 0)\r
+ this.dispose();\r
+ },\r
+\r
+\r
+ dispose: function() {\r
+ _.each(this._items, function(item) {\r
+ item.dispose && item.dispose();\r
+ item.remove && item.remove();\r
+ });\r
+\r
+ this._items = null;\r
+ this.remove();\r
+\r
+ $(document).off('click', this._close_proxy);\r
+ },\r
+\r
+\r
+ addItem: function(item_name, $item) {\r
+ $item = $($item);\r
+ if ($item.is('a')) $item.addClass('icon-chevron-right');\r
+ this._items[item_name] = $item;\r
+ },\r
+\r
+\r
+ removeItem: function(item_name) {\r
+ delete this._items[item_name];\r
+ },\r
+\r
+\r
+ showFooter: function(show) {\r
+ this._show_footer = show;\r
+ },\r
+\r
+\r
+ show: function() {\r
+ this.render();\r
+ this.$el.appendTo(_kiwi.app.view.$el);\r
+ }\r
+});\r