From d4bcebc3e05be0c14b10c8ee01b5879196597652 Mon Sep 17 00:00:00 2001 From: Darren Date: Mon, 6 Jan 2014 15:32:27 +0000 Subject: [PATCH] Capping ui_menubox height --- client/src/views/channelinfo.js | 4 +--- client/src/views/menubox.js | 30 ++++++++++++++++++++++-------- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/client/src/views/channelinfo.js b/client/src/views/channelinfo.js index c9928c3..d26e2b5 100644 --- a/client/src/views/channelinfo.js +++ b/client/src/views/channelinfo.js @@ -19,7 +19,7 @@ _kiwi.view.ChannelInfo = Backbone.View.extend({ this.$el = $(_.template($('#tmpl_channel_info').html().trim(), text)); // Create the menu box this view will sit inside - this.menu = new _kiwi.view.MenuBox(); + this.menu = new _kiwi.view.MenuBox(channel.get('name')); this.menu.addItem('channel_info', this.$el); this.menu.$el.appendTo(channel.view.$container); this.menu.show(); @@ -90,8 +90,6 @@ _kiwi.view.ChannelInfo = Backbone.View.extend({ var that = this, title, modes, url, banlist; - this.menu.setTitle(channel.get('name')); - modes = channel.get('info_modes'); if (modes) { _.each(modes, function(mode, idx) { diff --git a/client/src/views/menubox.js b/client/src/views/menubox.js index 4249bb3..dd2debc 100644 --- a/client/src/views/menubox.js +++ b/client/src/views/menubox.js @@ -6,7 +6,7 @@ _kiwi.view.MenuBox = Backbone.View.extend({ initialize: function(title) { var that = this; - this.$el = $('
'); + this.$el = $('
'); this._title = title || ''; this._items = {}; @@ -16,26 +16,29 @@ _kiwi.view.MenuBox = Backbone.View.extend({ render: function() { - var that = this; + var that = this, + $title, + $items = that.$el.find('.items'); - this.$el.find('*').remove(); + $items.find('*').remove(); - $('
').appendTo(this.$el); if (this._title) { - this.$el.find('.ui_menu_title') + $title = $('
') .text(this._title); - } + this.$el.prepend($title); + } _.each(this._items, function(item) { var $item = $('
') .append(item); - that.$el.append($item); + $items.append($item); }); if (this._display_footer) this.$el.append('
Close
'); + }, @@ -97,11 +100,22 @@ _kiwi.view.MenuBox = Backbone.View.extend({ show: function() { - var that = this; + var that = this, + $controlbox, menu_height; this.render(); this.$el.appendTo(_kiwi.app.view.$el); + // Ensure the menu doesn't get too tall to overlap the input bar at the bottom + $controlbox = _kiwi.app.view.$el.find('.controlbox'); + $items = this.$el.find('.items'); + menu_height = this.$el.outerHeight() - $items.outerHeight(); + + $items.css({ + 'overflow-y': 'auto', + 'max-height': $controlbox.offset().top - this.$el.offset().top - menu_height + }); + // We add this document click listener on the next javascript tick. // If the current tick is handling an existing click event (such as the nicklist click handler), // the click event bubbles up and hits the document therefore calling this callback to -- 2.25.1