From 2d0c1418bf3fff8052a6a85a5c8da5dcd8abe76e Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Tue, 1 Dec 2015 22:16:12 +0100 Subject: [PATCH] WEBUI: channels grid - group number operations to one menu to reduce toolbar width --- src/webui/static/app/chconf.js | 64 +++++++++++++++------------------- src/webui/static/app/idnode.js | 9 ++++- 2 files changed, 36 insertions(+), 37 deletions(-) diff --git a/src/webui/static/app/chconf.js b/src/webui/static/app/chconf.js index 6c3262fa4..dd5bb8b56 100644 --- a/src/webui/static/app/chconf.js +++ b/src/webui/static/app/chconf.js @@ -135,56 +135,48 @@ tvheadend.channel_tab = function(panel, index) callback: tvheadend.service_mapper }; - var lowNoButton = { - name: 'lowno', + var chopsButton = { + name: 'chops', builder: function() { - return new Ext.Toolbar.Button({ + var m = new Ext.menu.Menu() + m.add({ + name: 'lowno', tooltip: _('Assign lowest free channel number'), iconCls: 'bullet_add', - text: _('Assign Number'), - disabled: false + text: _('Assign Number') }); - }, - callback: assign_low_number - }; - - var noUpButton = { - name: 'noup', - builder: function() { - return new Ext.Toolbar.Button({ + m.add({ + name: 'noup', tooltip: _('Move channel one number up'), iconCls: 'arrow_up', - text: _('Number Up'), - disabled: false + text: _('Number Up') }); - }, - callback: move_number_up - }; - - var noDownButton = { - name: 'nodown', - builder: function() { - return new Ext.Toolbar.Button({ + m.add({ + name: 'nodown', tooltip: _('Move channel one number down'), iconCls: 'arrow_down', - text: _('Number Down'), - disabled: false + text: _('Number Down') }); - }, - callback: move_number_down - }; - - var noSwapButton = { - name: 'swap', - builder: function() { - return new Ext.Toolbar.Button({ + m.add({ + name: 'swap', tooltip: _('Swap the numbers for the two selected channels'), iconCls: 'arrow_switch', - text: _('Swap Numbers'), + text: _('Swap Numbers') + }); + return new Ext.Toolbar.Button({ + tooltip: _('Channel number operations'), + iconCls: 'bullet_add', + text: _('Number operations'), + menu: m, disabled: false }); }, - callback: swap_numbers + callback: { + lowno: assign_low_number, + noup: move_number_up, + nodown: move_number_down, + swap: swap_numbers + } }; var iconResetButton = { @@ -216,7 +208,7 @@ tvheadend.channel_tab = function(panel, index) create: {} }, del: true, - tbar: [mapButton, lowNoButton, noUpButton, noDownButton, noSwapButton, iconResetButton], + tbar: [mapButton, chopsButton, iconResetButton], lcol: [ { width: 50, diff --git a/src/webui/static/app/idnode.js b/src/webui/static/app/idnode.js index 830024e23..ab1f70096 100644 --- a/src/webui/static/app/idnode.js +++ b/src/webui/static/app/idnode.js @@ -1768,7 +1768,14 @@ tvheadend.idnode_grid = function(panel, conf) var t = conf.tbar[i]; if (t.name && t.builder) { var b = t.builder(); - if (t.callback) { + if (b.menu) { + b.menu.items.each(function(mi) { + mi.callback = t.callback[mi.name]; + mi.setHandler(function(m, e) { + this.callback(this, e, store, select); + }); + }); + } else if (t.callback) { b.callback = t.callback; b.handler = function(b, e) { this.callback(this, e, store, select); -- 2.47.3