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) {
if (channelname && channelname.length) fields.push(channelname);
return fields.join(' - ');
}
+
function getDialogContent(d) {
var params = d[0].params;
var chicon = params[0].value;
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,
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({
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));
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);
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) {
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,
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;
title: title,
iconCls: 'broadcast_details',
layout: 'fit',
- width: 800,
+ width: 850,
height: windowHeight,
constrainHeader: true,
buttons: buttons,
html: content
});
win.show();
+ checkButtonAvailability(win.fbar);
function playProgram() {
var title = event.title;
'?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);
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();
}