From e6761b54da5d94feb6b67d861b651a1034708b51 Mon Sep 17 00:00:00 2001 From: Duncan Sommerville Date: Mon, 24 Aug 2015 12:05:57 -0400 Subject: [PATCH] CC-6066 - more work on add/remove content screen --- .../controllers/ScheduleController.php | 1 + .../controllers/ShowbuilderController.php | 10 +++ airtime_mvc/public/css/_showbuilder.css | 6 +- .../css/redmond/jquery-ui-1.8.8.custom.css | 2 +- .../public/js/airtime/common/common.js | 30 +++++++++ .../public/js/airtime/schedule/schedule.js | 52 ++++++++++++++- .../js/airtime/showbuilder/main_builder.js | 63 ++++++------------- 7 files changed, 113 insertions(+), 51 deletions(-) diff --git a/airtime_mvc/application/controllers/ScheduleController.php b/airtime_mvc/application/controllers/ScheduleController.php index 2d26d1b9d..3993364da 100644 --- a/airtime_mvc/application/controllers/ScheduleController.php +++ b/airtime_mvc/application/controllers/ScheduleController.php @@ -100,6 +100,7 @@ class ScheduleController extends Zend_Controller_Action $this->view->headScript()->appendFile($baseUrl.'js/libs/moment.min.js?'.$CC_CONFIG['airtime_version'], 'text/javascript'); $this->view->headScript()->appendFile($baseUrl.'js/libs/moment-timezone-with-data-2010-2020.min.js?'.$CC_CONFIG['airtime_version'], 'text/javascript'); + $this->view->headScript()->appendFile($baseUrl.'js/airtime/utilities/utilities.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $this->view->headScript()->appendFile($baseUrl.'js/airtime/buttons/buttons.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $this->view->headScript()->appendFile($baseUrl.'js/airtime/library/events/library_showbuilder.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); diff --git a/airtime_mvc/application/controllers/ShowbuilderController.php b/airtime_mvc/application/controllers/ShowbuilderController.php index 029dc0595..5e28d37bf 100644 --- a/airtime_mvc/application/controllers/ShowbuilderController.php +++ b/airtime_mvc/application/controllers/ShowbuilderController.php @@ -175,6 +175,16 @@ class ShowbuilderController extends Zend_Controller_Action $this->view->start = $start_time; $this->view->end = $end_time; + $form = new Application_Form_ShowBuilder(); + $form->populate(array( + 'sb_date_start' => $start->format("Y-m-d"), + 'sb_time_start' => $start->format("H:i"), + 'sb_date_end' => $end->format("Y-m-d"), + 'sb_time_end' => $end->format("H:i") + )); + + $this->view->sb_form = $form; + $this->view->dialog = $this->view->render('showbuilder/builderDialog.phtml'); } diff --git a/airtime_mvc/public/css/_showbuilder.css b/airtime_mvc/public/css/_showbuilder.css index 5e2ff290e..ddff8d84d 100644 --- a/airtime_mvc/public/css/_showbuilder.css +++ b/airtime_mvc/public/css/_showbuilder.css @@ -616,9 +616,9 @@ th.library_checkbox { } /* Since the z-index gets applied dynamically */ -#ui-datepicker-div { - z-index: 1000 !important; -} +/*#ui-datepicker-div {*/ + /*z-index: 1000 !important;*/ +/*}*/ .datatable .ui-state-highlight, .spl_sortable .ui-state-highlight { background: rgba(255, 93, 26, .6); diff --git a/airtime_mvc/public/css/redmond/jquery-ui-1.8.8.custom.css b/airtime_mvc/public/css/redmond/jquery-ui-1.8.8.custom.css index e48449b1e..06709e695 100644 --- a/airtime_mvc/public/css/redmond/jquery-ui-1.8.8.custom.css +++ b/airtime_mvc/public/css/redmond/jquery-ui-1.8.8.custom.css @@ -1399,7 +1399,7 @@ button.ui-button.::-moz-focus-inner { .ui-datepicker th { padding: .7em .3em; text-align: center; - font-weight: bold; + font-weight: normal; border: 0; } .ui-datepicker td { diff --git a/airtime_mvc/public/js/airtime/common/common.js b/airtime_mvc/public/js/airtime/common/common.js index a423b5be7..76331d754 100644 --- a/airtime_mvc/public/js/airtime/common/common.js +++ b/airtime_mvc/public/js/airtime/common/common.js @@ -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); } diff --git a/airtime_mvc/public/js/airtime/schedule/schedule.js b/airtime_mvc/public/js/airtime/schedule/schedule.js index 6e0be7bbd..7769fbd61 100644 --- a/airtime_mvc/public/js/airtime/schedule/schedule.js +++ b/airtime_mvc/public/js/airtime/schedule/schedule.js @@ -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){ diff --git a/airtime_mvc/public/js/airtime/showbuilder/main_builder.js b/airtime_mvc/public/js/airtime/showbuilder/main_builder.js index c94274555..c633bc637 100644 --- a/airtime_mvc/public/js/airtime/showbuilder/main_builder.js +++ b/airtime_mvc/public/js/airtime/showbuilder/main_builder.js @@ -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(); } }