SAAS-744 - Updated double click and Add button functionality on Now Playing and Add/Remove content screens

This commit is contained in:
Duncan Sommerville 2015-04-30 16:23:52 -04:00
parent 4e37788d92
commit 8aea86b451
3 changed files with 65 additions and 9 deletions

View file

@ -213,3 +213,21 @@ function resizeToMaxHeight(ele, targetHeight){
img.css("width", newWidth+"px");
}
}
/* From http://stackoverflow.com/questions/123999/how-to-tell-if-a-dom-element-is-visible-in-the-current-viewport/#7557433 */
function isInView(el) {
//special bonus for those using jQuery
if (typeof jQuery === "function" && el instanceof jQuery) {
el = el[0];
}
var rect = el.getBoundingClientRect();
return (
rect.top >= 0 &&
rect.left >= 0 &&
rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && /*or $(window).height() */
rect.right <= (window.innerWidth || document.documentElement.clientWidth) /*or $(window).width() */
);
}

View file

@ -8,20 +8,31 @@ var AIRTIME = (function(AIRTIME) {
mod = AIRTIME.library;
mod.checkAddButton = function() {
var selected = mod.getChosenItemsLength(), $cursor = $('tr.sb-selected'), check = false;
var selected = mod.getChosenItemsLength(), $cursor = $('tr.sb-selected'), check = false,
shows = $('tr.sb-header'), current = $('tr.sb-current-show'),
cursorText = $.i18n._('Add to next show');
// make sure library items are selected and a cursor is selected.
if (selected !== 0 && $cursor.length !== 0) {
if (selected !== 0) {
check = true;
}
if (shows.length === 0) {
check = false;
}
if (check === true) {
AIRTIME.button.enableButton("btn-group #library-plus", false);
} else {
AIRTIME.button.disableButton("btn-group #library-plus", false);
}
AIRTIME.library.changeAddButtonText($('.btn-group #library-plus #lib-plus-text'), ' '+$.i18n._('Add to selected show'));
if ($cursor.length !== 0) {
cursorText = $.i18n._('Add before selected items');
} else if (current.length !== 0) {
cursorText = $.i18n._('Add to current show');
}
AIRTIME.library.changeAddButtonText($('.btn-group #library-plus #lib-plus-text'), ' '+ cursorText);
};
mod.fnRowCallback = function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
@ -98,7 +109,7 @@ var AIRTIME = (function(AIRTIME) {
"type" : type
});
$("#show_builder_table tr.cursor-selected-row").each(function(i, el) {
$("#show_builder_table tr.sb-selected").each(function(i, el) {
aData.push($(el).prev().data("aData"));
});
@ -113,12 +124,35 @@ var AIRTIME = (function(AIRTIME) {
}
if (aSchedIds.length == 0) {
alert($.i18n._("Please select a cursor position on timeline."));
return false;
addToCurrentOrNext(aSchedIds);
}
AIRTIME.showbuilder.fnAdd(aMediaIds, aSchedIds);
};
function addToCurrentOrNext(arr) {
var el;
// Get the show instance id of the first non-data row (id = 0)
// The second last row in the table with that instance id is the
// last schedule item for the first show. (This is important for
// the Now Playing screen if multiple shows are in view).
el = $("[si_id="+$("#0").attr("si_id")+"]");
var temp = el.eq(-2).data("aData");
arr.push({
"id" : temp.id,
"instance" : temp.instance,
"timestamp" : temp.timestamp
});
if (!isInView(el)) {
$('.dataTables_scrolling.sb-padded').animate({
scrollTop: el.offset().top
}, 0);
}
return arr;
}
mod.setupLibraryToolbar = function() {
var $toolbar = $(".lib-content .fg-toolbar:first");
@ -162,6 +196,10 @@ var AIRTIME = (function(AIRTIME) {
});
}
if (aSchedIds.length == 0) {
addToCurrentOrNext(aSchedIds);
}
AIRTIME.showbuilder.fnAdd(aMediaIds, aSchedIds);
});

View file

@ -109,7 +109,7 @@ var AIRTIME = (function(AIRTIME) {
mod.changeAddButtonText = function($button, btnText) {
$button.text(btnText);
}
};
mod.createToolbarButtons = function() {
$menu = $("<div class='btn-toolbar' />");
@ -135,7 +135,7 @@ var AIRTIME = (function(AIRTIME) {
"<i class='icon-white icon-trash'></i>" +
"</button>" +
"</div>");
}
};
mod.createToolbarDropDown = function() {
$('#sb-select-page').click(function(){mod.selectCurrentPage();});