.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
userbox.member = member;\r
userbox.channel = this.model.channel;\r
\r
- // Remove any existing userboxes\r
- $('.userbox', this.$el).remove();\r
-\r
if (!this.model.getByNick(_kiwi.gateway.get('nick')).get('is_op')) {\r
userbox.$el.children('.if_op').remove();\r
}\r
- $target.append(userbox.$el);\r
+\r
+ var menu = new _kiwi.view.MenuBox(member.get('nick') || 'User');\r
+ menu.addItem('userbox', userbox.$el);\r
+ menu.show();\r
+\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
+ // 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
\r
// Model for this = _kiwi.model.PanelList\r
_kiwi.view.Tabs = Backbone.View.extend({\r
+ tagName: 'ul',\r
+\r
events: {\r
'click li': 'tabClick',\r
'click li .part': 'partClick'\r
\r
this.model.on('active', this.panelActive, this);\r
\r
- this.tabs_applets = $('ul.applets', this.$el);\r
- this.tabs_msg = $('ul.channels', this.$el);\r
-\r
- _kiwi.gateway.on('change:name', function (gateway, new_val) {\r
+ this.model.network.on('change:name', function (network, new_val) {\r
$('span', this.model.server.tab).text(new_val);\r
}, this);\r
+\r
+ this.$tab_container = $('#kiwi .panellist.channels');\r
+ this.$tab_container.append(this.$el);\r
},\r
+\r
render: function () {\r
var that = this;\r
\r
- this.tabs_msg.empty();\r
+ this.$el.empty();\r
\r
// Add the server tab first\r
this.model.server.tab\r
- .data('panel_id', this.model.server.cid)\r
- .appendTo(this.tabs_msg);\r
+ .data('panel', this.model.server)\r
+ .data('connection_id', this.model.network.get('connection_id'))\r
+ .appendTo(this.$el);\r
\r
// Go through each panel adding its tab\r
this.model.forEach(function (panel) {\r
if (panel == that.model.server) return;\r
\r
panel.tab\r
- .data('panel_id', panel.cid)\r
- .appendTo(panel.isApplet() ? this.tabs_applets : this.tabs_msg);\r
+ .data('panel', panel)\r
+ .appendTo(that.$el);\r
+ //.appendTo(panel.isApplet() ? this.tabs_applets : this.tabs_msg);\r
});\r
\r
_kiwi.app.view.doLayout();\r
panel.tab.addClass('icon-nonexistant');\r
}\r
\r
- panel.tab.data('panel_id', panel.cid)\r
- .appendTo(panel.isApplet() ? this.tabs_applets : this.tabs_msg);\r
+ panel.tab.data('panel', panel)\r
+ .data('connection_id', this.model.network.get('connection_id'))\r
+ .appendTo(this.$el);\r
+ //.appendTo(panel.isApplet() ? this.tabs_applets : this.tabs_msg);\r
\r
panel.bind('change:title', this.updateTabTitle);\r
_kiwi.app.view.doLayout();\r
panelActive: function (panel, previously_active_panel) {\r
// Remove any existing tabs or part images\r
$('.part', this.$el).remove();\r
- this.tabs_applets.children().removeClass('active');\r
- this.tabs_msg.children().removeClass('active');\r
+ this.$tab_container.find('.active').removeClass('active');\r
\r
panel.tab.addClass('active');\r
\r
\r
tabClick: function (e) {\r
var tab = $(e.currentTarget);\r
-\r
- var panel = this.model.getByCid(tab.data('panel_id'));\r
+ \r
+ var panel = tab.data('panel');\r
if (!panel) {\r
// A panel wasn't found for this tab... wadda fuck\r
return;\r
\r
partClick: function (e) {\r
var tab = $(e.currentTarget).parent();\r
- var panel = this.model.getByCid(tab.data('panel_id'));\r
+ var panel = this.model.getByCid(tab.data('panel'));\r
\r
// Only need to part if it's a channel\r
// If the nicklist is empty, we haven't joined the channel as yet\r
if (panel.isChannel() && panel.get('members').models.length > 0) {\r
- _kiwi.gateway.part(panel.get('name'));\r
+ this.model.network.gateway.part(panel.get('name'));\r
} else {\r
panel.close();\r
}\r
},\r
\r
next: function () {\r
- var next = _kiwi.app.panels.active.tab.next();\r
- if (!next.length) next = $('li:first', this.tabs_msgs);\r
+ var next = this.$tab_container.find('.active').next();\r
+ if (!next.length) next = $('li:first', this.$tab_container);\r
\r
next.click();\r
},\r
prev: function () {\r
- var prev = _kiwi.app.panels.active.tab.prev();\r
- if (!prev.length) prev = $('li:last', this.tabs_msgs);\r
+ var prev = this.$tab_container.find('.active').prev();\r
+ if (!prev.length) prev = $('li:last', this.$tab_container);\r
\r
prev.click();\r
}\r
_kiwi.gateway.bind('change:nick', function () {\r
$('.nick', that.$el).text(this.get('nick'));\r
});\r
+\r
+ _kiwi.app.connections.on('active', function(panel, connection) {\r
+ $('.nick', that.$el).text(connection.get('nick'));\r
+ });\r
},\r
\r
showNickChange: function (ev) {\r
return html;\r
}\r
});\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