CC-6066 - more work on add/remove content screen

This commit is contained in:
Duncan Sommerville 2015-08-24 12:05:57 -04:00
parent b15160d0fb
commit e6761b54da
7 changed files with 113 additions and 51 deletions

View file

@ -58,6 +58,11 @@ var i18n_days_short = [
$.i18n._("Sa")
];
var dateStartId = "#sb_date_start",
timeStartId = "#sb_time_start",
dateEndId = "#sb_date_end",
timeEndId = "#sb_time_end";
function getDatatablesStrings(overrideDict) {
var dict = {
@ -181,6 +186,31 @@ function openPreviewWindow(url, w, h) {
return false;
}
function validateTimeRange() {
var oRange,
inputs = $('.sb-timerange > input'),
start, end;
oRange = AIRTIME.utilities.fnGetScheduleRange(dateStartId, timeStartId, dateEndId, timeEndId);
start = oRange.start;
end = oRange.end;
if (end >= start) {
inputs.removeClass('error');
} else {
if (!inputs.hasClass('error')) {
inputs.addClass('error');
}
}
return {
start: start,
end: end,
isValid: end >= start
};
}
function pad(number, length) {
return sprintf("%'0"+length+"d", number);
}

View file

@ -120,8 +120,7 @@ function findViewportDimensions() {
};
}
function highlightMediaTypeSelector(dialog)
{
function highlightMediaTypeSelector(dialog) {
if (location.hash === "") {
dialog.find("a[href$='#files']").parent().addClass("selected");
}
@ -143,6 +142,54 @@ function highlightMediaTypeSelector(dialog)
});
}
function buildTimerange(dialog) {
var builder = dialog.find("#show_builder"),
oBaseDatePickerSettings = {
dateFormat: 'yy-mm-dd',
//i18n_months, i18n_days_short are in common.js
monthNames: i18n_months,
dayNamesMin: i18n_days_short,
onClick: function(sDate, oDatePicker) {
$(this).datepicker("setDate", sDate);
},
onClose: validateTimeRange
},
oBaseTimePickerSettings = {
showPeriodLabels: false,
showCloseButton: true,
closeButtonText: $.i18n._("Done"),
showLeadingZero: false,
defaultTime: '0:00',
hourText: $.i18n._("Hour"),
minuteText: $.i18n._("Minute"),
onClose: validateTimeRange
};
/*
* Icon hover states for search.
*/
builder.on("mouseenter", ".sb-timerange .ui-button", function(ev) {
$(this).addClass("ui-state-hover");
});
builder.on("mouseleave", ".sb-timerange .ui-button", function(ev) {
$(this).removeClass("ui-state-hover");
});
builder.find(dateStartId)
.datepicker(oBaseDatePickerSettings);
builder.find(timeStartId)
.timepicker(oBaseTimePickerSettings);
builder.find(dateEndId)
.datepicker(oBaseDatePickerSettings);
builder.find(timeEndId)
.timepicker(oBaseTimePickerSettings);
var oRange = AIRTIME.utilities.fnGetScheduleRange(dateStartId, timeStartId,
dateEndId, timeEndId);
AIRTIME.showbuilder.fnServerData.start = oRange.start;
AIRTIME.showbuilder.fnServerData.end = oRange.end;
}
function buildScheduleDialog (json, instance_id) {
var dialog = $(json.dialog),
viewport = findViewportDimensions(),
@ -184,6 +231,7 @@ function buildScheduleDialog (json, instance_id) {
dialog.dialog('open');
highlightMediaTypeSelector(dialog);
buildTimerange(dialog);
}
function buildContentDialog (json){

View file

@ -86,32 +86,6 @@ AIRTIME = (function(AIRTIME) {
}
}
function validateTimeRange() {
var oRange,
inputs = $('.sb-timerange > input'),
start, end;
oRange = AIRTIME.utilities.fnGetScheduleRange(dateStartId, timeStartId, dateEndId, timeEndId);
start = oRange.start;
end = oRange.end;
if (end >= start) {
inputs.removeClass('error');
}
else {
if (!inputs.hasClass('error')) {
inputs.addClass('error');
}
}
return {
start: start,
end: end,
isValid: end >= start
};
}
function showSearchSubmit() {
var fn,
op,
@ -121,25 +95,24 @@ AIRTIME = (function(AIRTIME) {
check = validateTimeRange();
if (check.isValid) {
//reset timestamp value since input values could have changed.
AIRTIME.showbuilder.resetTimestamp();
fn = oTable.fnSettings().fnServerData;
fn.start = check.start;
fn.end = check.end;
op = $("div.sb-advanced-options");
if (op.is(":visible")) {
if (fn.ops === undefined) {
fn.ops = {};
}
fn.ops.showFilter = op.find("#sb_show_filter").val();
fn.ops.myShows = op.find("#sb_my_shows").is(":checked") ? 1 : 0;
}
oTable.fnDraw();
//reset timestamp value since input values could have changed.
AIRTIME.showbuilder.resetTimestamp();
fn = oTable.fnSettings().fnServerData;
fn.start = check.start;
fn.end = check.end;
op = $("div.sb-advanced-options");
if (op.is(":visible")) {
if (fn.ops === undefined) {
fn.ops = {};
}
fn.ops.showFilter = op.find("#sb_show_filter").val();
fn.ops.myShows = op.find("#sb_my_shows").is(":checked") ? 1 : 0;
}
oTable.fnDraw();
}
}