From: pablozg Date: Fri, 21 Sep 2018 19:34:28 +0000 (+0200) Subject: webui: Add Previous button to epg and dvr, fix minor issues (If you select the first... X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cf073b3a2f4e23d24ebd7606e9e3c4918d33aec8;p=thirdparty%2Ftvheadend.git webui: Add Previous button to epg and dvr, fix minor issues (If you select the first/last row the previous/next are active when the popup window is opened first time) --- diff --git a/src/webui/static/app/dvr.js b/src/webui/static/app/dvr.js index 4a642a193..3863e7762 100644 --- a/src/webui/static/app/dvr.js +++ b/src/webui/static/app/dvr.js @@ -26,6 +26,7 @@ tvheadend.dvrDetails = function(grid, index) { var win; // We need a unique DOM id in case user opens two dialogs. var nextButtonId = Ext.id(); + var previousButtonId = Ext.id(); // Our title is passed to search functions (such as imdb) // So always ensure this does not contain channel info. function getTitle(d) { @@ -44,6 +45,7 @@ tvheadend.dvrDetails = function(grid, index) { if (channelname && channelname.length) fields.push(channelname); return fields.join(' - '); } + function getDialogContent(d) { var params = d[0].params; var chicon = params[0].value; @@ -173,6 +175,13 @@ tvheadend.dvrDetails = function(grid, index) { if (title) buttons.push(comboGetInfo); + buttons.push(new Ext.Button({ + id: previousButtonId, + handler: previousEvent, + iconCls: 'previous', + tooltip: _('Go to previous event'), + text: _("Previous"), + })); buttons.push(new Ext.Button({ id: nextButtonId, handler: nextEvent, @@ -201,11 +210,11 @@ tvheadend.dvrDetails = function(grid, index) { buttons: buttons, html: content }); + win.show(); + checkButtonAvailability(win.fbar) + } - win.show(); - } - - function load(store, index, cb) { + function load(store, index, cb) { var uuid = store.getAt(index).id; tvheadend.loading(1); Ext.Ajax.request({ @@ -226,15 +235,27 @@ tvheadend.dvrDetails = function(grid, index) { tvheadend.loading(0); } }); - } // load - - function nextEvent() { - var store = grid.getStore(); - ++current_index; - load(store,current_index,updateit); - } + } // load + + function previousEvent() { + --current_index; + load(store,current_index,updateit); + } + function nextEvent() { + ++current_index; + load(store,current_index,updateit); + } + + function checkButtonAvailability(toolBar){ + // If we're at the end of the store then disable the next + // or previous button. (getTotalCount is one-based). + if (current_index == store.getTotalCount() - 1) + toolBar.getComponent(nextButtonId).disable(); + if (current_index == 0) + toolBar.getComponent(previousButtonId).disable(); + } - function updateit(d) { + function updateit(d) { var dialogTitle = getDialogTitle(d); var content = getDialogContent(d); var buttons = getDialogButtons(getTitle(d)); @@ -246,15 +267,12 @@ tvheadend.dvrDetails = function(grid, index) { var tbar = win.fbar; tbar.removeAll(); Ext.each(buttons, function(btn) { - tbar.addButton(btn); - }); - // If we're at the end of the store then disable the next - // button. (getTotalCount is one-based). - if (current_index == store.getTotalCount() - 1) - tbar.getComponent(nextButtonId).disable(); + tbar.addButton(btn); + }); + checkButtonAvailability(tbar); // Finally, relayout. win.doLayout(); - } + } var store = grid.getStore(); load(store,index,showit); diff --git a/src/webui/static/app/epg.js b/src/webui/static/app/epg.js index 28f373885..9a9743567 100644 --- a/src/webui/static/app/epg.js +++ b/src/webui/static/app/epg.js @@ -110,6 +110,7 @@ tvheadend.filmAffinityLanguage = function() { tvheadend.epgDetails = function(grid, index) { // We need a unique DOM id in case user opens two dialogs. var nextButtonId = Ext.id(); + var previousButtonId = Ext.id(); var confcomboButtonId = Ext.id(); function getDialogTitle(event) { @@ -334,6 +335,13 @@ tvheadend.epgDetails = function(grid, index) { tooltip: _('Create an automatic recording rule to record all future programs that match the current query.'), text: event.serieslinkUri ? _("Record series") : _("Autorec") })); + buttons.push(new Ext.Button({ + id: previousButtonId, + handler: previousEvent, + iconCls: 'previous', + tooltip: _('Go to previous event'), + text: _("Previous"), + })); buttons.push(new Ext.Button({ id: nextButtonId, handler: nextEvent, @@ -355,6 +363,7 @@ tvheadend.epgDetails = function(grid, index) { var current_index = index; var event = grid.getStore().getAt(index).data; + var store = grid.getStore(); var content = getDialogContent(event); var buttons = getDialogButtons(); var windowHeight = Ext.getBody().getViewSize().height - 150; @@ -363,7 +372,7 @@ tvheadend.epgDetails = function(grid, index) { title: title, iconCls: 'broadcast_details', layout: 'fit', - width: 800, + width: 850, height: windowHeight, constrainHeader: true, buttons: buttons, @@ -372,6 +381,7 @@ tvheadend.epgDetails = function(grid, index) { html: content }); win.show(); + checkButtonAvailability(win.fbar); function playProgram() { var title = event.title; @@ -381,10 +391,26 @@ tvheadend.epgDetails = function(grid, index) { '?title=' + encodeURIComponent(title), '_blank'); } + function previousEvent() { + --current_index; + event = store.getAt(current_index).data; + updateit(); + } function nextEvent() { - var store = grid.getStore(); - ++current_index; - event = store.getAt(current_index).data; + ++current_index; + event = store.getAt(current_index).data; + updateit(); + } + function checkButtonAvailability(toolBar){ + // If we're at the end of the store then disable the next + // or previous button. (getTotalCount is one-based). + if (current_index == store.getTotalCount() - 1) + toolBar.getComponent(nextButtonId).disable(); + if (current_index == 0) + toolBar.getComponent(previousButtonId).disable(); + } + + function updateit() { var title = getDialogTitle(event); var content = getDialogContent(event); var buttons = getDialogButtons(event); @@ -399,10 +425,7 @@ tvheadend.epgDetails = function(grid, index) { Ext.each(buttons, function(btn) { tbar.addButton(btn); }); - // If we're at the end of the store then disable the next - // button. (getTotalCount is one-based). - if (current_index == store.getTotalCount() - 1) - tbar.getComponent(nextButtonId).disable(); + checkButtonAvailability(tbar); // Finally, relayout. win.doLayout(); }