diff --git a/airtime_mvc/application/controllers/PlayouthistoryController.php b/airtime_mvc/application/controllers/PlayouthistoryController.php index 5aa78faa9..0c399aa99 100644 --- a/airtime_mvc/application/controllers/PlayouthistoryController.php +++ b/airtime_mvc/application/controllers/PlayouthistoryController.php @@ -55,7 +55,7 @@ class PlayouthistoryController extends Zend_Controller_Action $this->view->headScript()->appendFile($baseUrl.'js/datatables/plugin/dataTables.fnSetFilteringDelay.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $this->view->headScript()->appendFile($baseUrl.'js/datatables/plugin/TableTools-2.1.5/js/ZeroClipboard.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $this->view->headScript()->appendFile($baseUrl.'js/datatables/plugin/TableTools-2.1.5/js/TableTools.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); - $this->view->headScript()->appendFile($baseUrl.'js/bootstrap-datetime/bootstrap-datetimepicker.min.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); + $this->view->headScript()->appendFile($baseUrl.'js/timepicker/jquery-ui-timepicker-addon.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $offset = date("Z") * -1; $this->view->headScript()->appendScript("var serverTimezoneOffset = {$offset}; //in seconds"); @@ -67,13 +67,14 @@ class PlayouthistoryController extends Zend_Controller_Action $this->view->headLink()->appendStylesheet($baseUrl.'js/datatables/plugin/TableTools-2.1.5/css/TableTools.css?'.$CC_CONFIG['airtime_version']); $this->view->headLink()->appendStylesheet($baseUrl.'css/jquery.ui.timepicker.css?'.$CC_CONFIG['airtime_version']); $this->view->headLink()->appendStylesheet($baseUrl.'css/playouthistory.css?'.$CC_CONFIG['airtime_version']); - $this->view->headLink()->appendStylesheet($baseUrl.'css/bootstrap-datetimepicker.min.css?'.$CC_CONFIG['airtime_version']); - + $this->view->headLink()->appendStylesheet($baseUrl.'css/jquery-ui-timepicker-addon.css?'.$CC_CONFIG['airtime_version']); + + //set datatables columns for display of data. $historyService = new Application_Service_HistoryService(); $columns = json_encode($historyService->getDatatablesLogSheetColumns()); $script = "localStorage.setItem( 'datatables-historyitem-aoColumns', JSON.stringify($columns) ); "; - + $columns = json_encode($historyService->getDatatablesFileSummaryColumns()); $script.= "localStorage.setItem( 'datatables-historyfile-aoColumns', JSON.stringify($columns) );"; $this->view->headScript()->appendScript($script); @@ -84,18 +85,18 @@ class PlayouthistoryController extends Zend_Controller_Action try { $request = $this->getRequest(); $current_time = time(); - + $params = $request->getParams(); - + $starts_epoch = $request->getParam("start", $current_time - (60*60*24)); $ends_epoch = $request->getParam("end", $current_time); - + $startsDT = DateTime::createFromFormat("U", $starts_epoch, new DateTimeZone("UTC")); $endsDT = DateTime::createFromFormat("U", $ends_epoch, new DateTimeZone("UTC")); - + $historyService = new Application_Service_HistoryService(); $r = $historyService->getFileSummaryData($startsDT, $endsDT, $params); - + $this->view->sEcho = $r["sEcho"]; $this->view->iTotalDisplayRecords = $r["iTotalDisplayRecords"]; $this->view->iTotalRecords = $r["iTotalRecords"]; @@ -112,19 +113,19 @@ class PlayouthistoryController extends Zend_Controller_Action try { $request = $this->getRequest(); $current_time = time(); - + $params = $request->getParams(); - + $starts_epoch = $request->getParam("start", $current_time - (60*60*24)); $ends_epoch = $request->getParam("end", $current_time); - + $startsDT = DateTime::createFromFormat("U", $starts_epoch, new DateTimeZone("UTC")); $endsDT = DateTime::createFromFormat("U", $ends_epoch, new DateTimeZone("UTC")); - + $historyService = new Application_Service_HistoryService(); //$r = $historyService->getListView($startsDT, $endsDT, $params); $r = $historyService->getPlayedItemData($startsDT, $endsDT, $params); - + $this->view->sEcho = $r["sEcho"]; $this->view->iTotalDisplayRecords = $r["iTotalDisplayRecords"]; $this->view->iTotalRecords = $r["iTotalRecords"]; @@ -155,10 +156,10 @@ class PlayouthistoryController extends Zend_Controller_Action $request = $this->getRequest(); $params = $request->getPost(); Logging::info($params); - + $historyService = new Application_Service_HistoryService(); $json = $historyService->createPlayedItem($params); - + $this->_helper->json->sendJson($json); } catch (Exception $e) { @@ -171,7 +172,7 @@ class PlayouthistoryController extends Zend_Controller_Action { $id = $this->_getParam('id', null); Logging::info("Id is: $id"); - + $populate = isset($id) ? true : false; $historyService = new Application_Service_HistoryService(); @@ -197,10 +198,10 @@ class PlayouthistoryController extends Zend_Controller_Action $request = $this->getRequest(); $params = $request->getPost(); Logging::info($params); - + $historyService = new Application_Service_HistoryService(); $json = $historyService->editPlayedItem($params); - + $this->_helper->json->sendJson($json); } catch (Exception $e) { @@ -225,7 +226,7 @@ class PlayouthistoryController extends Zend_Controller_Action { $CC_CONFIG = Config::getConfig(); $baseUrl = Application_Common_OsPath::getBaseDir(); - + $this->view->headScript()->appendFile($baseUrl.'js/airtime/playouthistory/template.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $historyService = new Application_Service_HistoryService(); @@ -235,29 +236,29 @@ class PlayouthistoryController extends Zend_Controller_Action } public function configureTemplateAction() { - + $CC_CONFIG = Config::getConfig(); $baseUrl = Application_Common_OsPath::getBaseDir(); - + $this->view->headScript()->appendFile($baseUrl.'js/airtime/playouthistory/configuretemplate.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); - + try { - + $templateId = $this->_getParam('id'); - - $historyService = new Application_Service_HistoryService(); + + $historyService = new Application_Service_HistoryService(); $template = $historyService->loadTemplate($templateId); - + $templateType = $template["type"]; $supportedTypes = $historyService->getSupportedTemplateTypes(); - + if (!in_array($templateType, $supportedTypes)) { throw new Exception("Error: $templateType is not supported."); } - + $getMandatoryFields = "mandatory".ucfirst($templateType)."Fields"; $mandatoryFields = $historyService->$getMandatoryFields(); - + $this->view->template_id = $templateId; $this->view->template_name = $template["name"]; $this->view->template_fields = $template["fields"]; @@ -271,7 +272,7 @@ class PlayouthistoryController extends Zend_Controller_Action Logging::info("Error?"); Logging::info($e); Logging::info($e->getMessage()); - + $this->_forward('template', 'playouthistory'); } } @@ -279,34 +280,34 @@ class PlayouthistoryController extends Zend_Controller_Action public function createTemplateAction() { $templateType = $this->_getParam('type', null); - + $request = $this->getRequest(); $params = $request->getPost(); - + try { $historyService = new Application_Service_HistoryService(); $supportedTypes = $historyService->getSupportedTemplateTypes(); - + if (!in_array($templateType, $supportedTypes)) { throw new Exception("Error: $templateType is not supported."); } - + $id = $historyService->createTemplate($params); - + $this->view->url = $this->view->baseUrl("Playouthistory/configure-template/id/{$id}"); } catch (Exception $e) { Logging::info($e); Logging::info($e->getMessage()); - + $this->view->error = $e->getMessage(); } } - + public function setTemplateDefaultAction() { $templateId = $this->_getParam('id', null); - + try { $historyService = new Application_Service_HistoryService(); $historyService->setConfiguredTemplate($templateId); @@ -318,11 +319,11 @@ class PlayouthistoryController extends Zend_Controller_Action } public function updateTemplateAction() - { + { $templateId = $this->_getParam('id', null); $name = $this->_getParam('name', null); $fields = $this->_getParam('fields', array()); - + try { $historyService = new Application_Service_HistoryService(); $historyService->updateItemTemplate($templateId, $name, $fields); @@ -336,7 +337,7 @@ class PlayouthistoryController extends Zend_Controller_Action public function deleteTemplateAction() { $templateId = $this->_getParam('id'); - + try { $historyService = new Application_Service_HistoryService(); $historyService->deleteTemplate($templateId); diff --git a/airtime_mvc/application/forms/EditHistoryItem.php b/airtime_mvc/application/forms/EditHistoryItem.php index f0389eb8a..cb9868e49 100644 --- a/airtime_mvc/application/forms/EditHistoryItem.php +++ b/airtime_mvc/application/forms/EditHistoryItem.php @@ -5,7 +5,7 @@ class Application_Form_EditHistoryItem extends Application_Form_EditHistory const ID_PREFIX = "his_item_"; public function init() { - + parent::init(); $this->setDecorators(array( @@ -17,7 +17,7 @@ class Application_Form_EditHistoryItem extends Application_Form_EditHistory $starts->setValidators(array( new Zend_Validate_Date(self::VALIDATE_DATETIME_FORMAT) )); - $starts->setAttrib('class', self::TEXT_INPUT_CLASS); + $starts->setAttrib('class', self::TEXT_INPUT_CLASS." datepicker"); $starts->setAttrib('data-format', self::TIMEPICKER_DATETIME_FORMAT); $starts->addFilter('StringTrim'); $starts->setLabel(_('Start Time')); @@ -29,7 +29,7 @@ class Application_Form_EditHistoryItem extends Application_Form_EditHistory $ends->setValidators(array( new Zend_Validate_Date(self::VALIDATE_DATETIME_FORMAT) )); - $ends->setAttrib('class', self::TEXT_INPUT_CLASS); + $ends->setAttrib('class', self::TEXT_INPUT_CLASS." datepicker"); $ends->setAttrib('data-format', self::TIMEPICKER_DATETIME_FORMAT); $ends->addFilter('StringTrim'); $ends->setLabel(_('End Time')); @@ -37,9 +37,9 @@ class Application_Form_EditHistoryItem extends Application_Form_EditHistory $ends->setRequired(true); $this->addElement($ends); } - + public function createFromTemplate($template, $required) { - + parent::createFromTemplate($template, $required); } } \ No newline at end of file diff --git a/airtime_mvc/application/views/scripts/form/edit-history-item.phtml b/airtime_mvc/application/views/scripts/form/edit-history-item.phtml index 7f87f20d6..f36660c59 100644 --- a/airtime_mvc/application/views/scripts/form/edit-history-item.phtml +++ b/airtime_mvc/application/views/scripts/form/edit-history-item.phtml @@ -13,21 +13,16 @@
-
-
- getElement($name) ?> - - - -
-
+ + getElement($name) ?> + getElement($name)->hasErrors()) : ?> - +
@@ -45,7 +40,7 @@
  • - + diff --git a/airtime_mvc/public/css/jquery-ui-timepicker-addon.css b/airtime_mvc/public/css/jquery-ui-timepicker-addon.css new file mode 100644 index 000000000..b93a85f62 --- /dev/null +++ b/airtime_mvc/public/css/jquery-ui-timepicker-addon.css @@ -0,0 +1,10 @@ +.ui-timepicker-div .ui-widget-header { margin-bottom: 8px; } +.ui-timepicker-div dl { text-align: left; } +.ui-timepicker-div dl dt { height: 25px; margin-bottom: -25px; } +.ui-timepicker-div dl dd { margin: 0 10px 10px 65px; } +.ui-timepicker-div td { font-size: 90%; } +.ui-tpicker-grid-label { background: none; border: none; margin: 0; padding: 0; } + +.ui-timepicker-rtl{ direction: rtl; } +.ui-timepicker-rtl dl { text-align: right; } +.ui-timepicker-rtl dl dd { margin: 0 65px 10px 10px; } \ No newline at end of file diff --git a/airtime_mvc/public/css/styles.css b/airtime_mvc/public/css/styles.css index 837c08d1c..318030923 100644 --- a/airtime_mvc/public/css/styles.css +++ b/airtime_mvc/public/css/styles.css @@ -1552,9 +1552,6 @@ button, input { background-image:url(redmond/images/ui-icons_ff5d1a_256x240.png); } - -#ui-datepicker-div { z-index: 10 !important } - .button-bar-top { text-align:right; height:38px; diff --git a/airtime_mvc/public/js/airtime/playouthistory/historytable.js b/airtime_mvc/public/js/airtime/playouthistory/historytable.js index f4daa185b..d988cdafb 100644 --- a/airtime_mvc/public/js/airtime/playouthistory/historytable.js +++ b/airtime_mvc/public/js/airtime/playouthistory/historytable.js @@ -220,11 +220,13 @@ var AIRTIME = (function(AIRTIME) { $hisDialogEl.dialog({ title: $.i18n._("Edit History Record"), - modal: true, + modal: false, open: function( event, ui ) { - $hisDialogEl.find('.date').datetimepicker({ - "pick12HourFormat": false - }); + $hisDialogEl.find('.datepicker').datetimepicker({ + dateFormat: 'yy-mm-dd', + timeFormat: 'HH:mm:ss' + }) + .blur(); }, close: function() { removeHistoryDialog(); diff --git a/airtime_mvc/public/js/timepicker/jquery-ui-timepicker-addon.js b/airtime_mvc/public/js/timepicker/jquery-ui-timepicker-addon.js new file mode 100644 index 000000000..6f35ee532 --- /dev/null +++ b/airtime_mvc/public/js/timepicker/jquery-ui-timepicker-addon.js @@ -0,0 +1,2128 @@ +/* + * jQuery timepicker addon + * By: Trent Richardson [http://trentrichardson.com] + * Version 1.3.1 + * Last Modified: 07/07/2013 + * + * Copyright 2013 Trent Richardson + * You may use this project under MIT or GPL licenses. + * http://trentrichardson.com/Impromptu/GPL-LICENSE.txt + * http://trentrichardson.com/Impromptu/MIT-LICENSE.txt + */ + +/*jslint evil: true, white: false, undef: false, nomen: false */ + +(function($) { + + /* + * Lets not redefine timepicker, Prevent "Uncaught RangeError: Maximum call stack size exceeded" + */ + $.ui.datetimepicker = $.ui.datetimepicker || {}; + if ($.ui.datetimepicker.version) { + return; + } + + /* + * Extend jQueryUI, get it started with our version number + */ + $.extend($.ui, { + datetimepicker: { + version: "1.3.1" + } + }); + + /* + * Timepicker manager. + * Use the singleton instance of this class, $.datetimepicker, to interact with the time picker. + * Settings for (groups of) time pickers are maintained in an instance object, + * allowing multiple different settings on the same page. + */ + var Timepicker = function() { + this.regional = []; // Available regional settings, indexed by language code + this.regional[''] = { // Default regional settings + currentText: 'Now', + closeText: 'Done', + amNames: ['AM', 'A'], + pmNames: ['PM', 'P'], + timeFormat: 'HH:mm', + timeSuffix: '', + timeOnlyTitle: 'Choose Time', + timeText: 'Time', + hourText: 'Hour', + minuteText: 'Minute', + secondText: 'Second', + millisecText: 'Millisecond', + microsecText: 'Microsecond', + timezoneText: 'Time Zone', + isRTL: false + }; + this._defaults = { // Global defaults for all the datetime picker instances + showButtonPanel: true, + timeOnly: false, + showHour: null, + showMinute: null, + showSecond: null, + showMillisec: null, + showMicrosec: null, + showTimezone: null, + showTime: true, + stepHour: 1, + stepMinute: 1, + stepSecond: 1, + stepMillisec: 1, + stepMicrosec: 1, + hour: 0, + minute: 0, + second: 0, + millisec: 0, + microsec: 0, + timezone: null, + hourMin: 0, + minuteMin: 0, + secondMin: 0, + millisecMin: 0, + microsecMin: 0, + hourMax: 23, + minuteMax: 59, + secondMax: 59, + millisecMax: 999, + microsecMax: 999, + minDateTime: null, + maxDateTime: null, + onSelect: null, + hourGrid: 0, + minuteGrid: 0, + secondGrid: 0, + millisecGrid: 0, + microsecGrid: 0, + alwaysSetTime: true, + separator: ' ', + altFieldTimeOnly: true, + altTimeFormat: null, + altSeparator: null, + altTimeSuffix: null, + pickerTimeFormat: null, + pickerTimeSuffix: null, + showTimepicker: true, + timezoneList: null, + addSliderAccess: false, + sliderAccessArgs: null, + controlType: 'slider', + defaultValue: null, + parse: 'strict' + }; + $.extend(this._defaults, this.regional['']); + }; + + $.extend(Timepicker.prototype, { + $input: null, + $altInput: null, + $timeObj: null, + inst: null, + hour_slider: null, + minute_slider: null, + second_slider: null, + millisec_slider: null, + microsec_slider: null, + timezone_select: null, + hour: 0, + minute: 0, + second: 0, + millisec: 0, + microsec: 0, + timezone: null, + hourMinOriginal: null, + minuteMinOriginal: null, + secondMinOriginal: null, + millisecMinOriginal: null, + microsecMinOriginal: null, + hourMaxOriginal: null, + minuteMaxOriginal: null, + secondMaxOriginal: null, + millisecMaxOriginal: null, + microsecMaxOriginal: null, + ampm: '', + formattedDate: '', + formattedTime: '', + formattedDateTime: '', + timezoneList: null, + units: ['hour','minute','second','millisec', 'microsec'], + support: {}, + control: null, + + /* + * Override the default settings for all instances of the time picker. + * @param settings object - the new settings to use as defaults (anonymous object) + * @return the manager object + */ + setDefaults: function(settings) { + extendRemove(this._defaults, settings || {}); + return this; + }, + + /* + * Create a new Timepicker instance + */ + _newInst: function($input, opts) { + var tp_inst = new Timepicker(), + inlineSettings = {}, + fns = {}, + overrides, i; + + for (var attrName in this._defaults) { + if(this._defaults.hasOwnProperty(attrName)){ + var attrValue = $input.attr('time:' + attrName); + if (attrValue) { + try { + inlineSettings[attrName] = eval(attrValue); + } catch (err) { + inlineSettings[attrName] = attrValue; + } + } + } + } + + overrides = { + beforeShow: function (input, dp_inst) { + if ($.isFunction(tp_inst._defaults.evnts.beforeShow)) { + return tp_inst._defaults.evnts.beforeShow.call($input[0], input, dp_inst, tp_inst); + } + }, + onChangeMonthYear: function (year, month, dp_inst) { + // Update the time as well : this prevents the time from disappearing from the $input field. + tp_inst._updateDateTime(dp_inst); + if ($.isFunction(tp_inst._defaults.evnts.onChangeMonthYear)) { + tp_inst._defaults.evnts.onChangeMonthYear.call($input[0], year, month, dp_inst, tp_inst); + } + }, + onClose: function (dateText, dp_inst) { + if (tp_inst.timeDefined === true && $input.val() !== '') { + tp_inst._updateDateTime(dp_inst); + } + if ($.isFunction(tp_inst._defaults.evnts.onClose)) { + tp_inst._defaults.evnts.onClose.call($input[0], dateText, dp_inst, tp_inst); + } + } + }; + for (i in overrides) { + if (overrides.hasOwnProperty(i)) { + fns[i] = opts[i] || null; + } + } + + tp_inst._defaults = $.extend({}, this._defaults, inlineSettings, opts, overrides, { + evnts:fns, + timepicker: tp_inst // add timepicker as a property of datepicker: $.datepicker._get(dp_inst, 'timepicker'); + }); + tp_inst.amNames = $.map(tp_inst._defaults.amNames, function(val) { + return val.toUpperCase(); + }); + tp_inst.pmNames = $.map(tp_inst._defaults.pmNames, function(val) { + return val.toUpperCase(); + }); + + // detect which units are supported + tp_inst.support = detectSupport( + tp_inst._defaults.timeFormat + + (tp_inst._defaults.pickerTimeFormat? tp_inst._defaults.pickerTimeFormat:'') + + (tp_inst._defaults.altTimeFormat? tp_inst._defaults.altTimeFormat:'')); + + // controlType is string - key to our this._controls + if(typeof(tp_inst._defaults.controlType) === 'string'){ + if(tp_inst._defaults.controlType == 'slider' && typeof(jQuery.ui.slider) === 'undefined'){ + tp_inst._defaults.controlType = 'select'; + } + tp_inst.control = tp_inst._controls[tp_inst._defaults.controlType]; + } + // controlType is an object and must implement create, options, value methods + else{ + tp_inst.control = tp_inst._defaults.controlType; + } + + // prep the timezone options + var timezoneList = [-720,-660,-600,-570,-540,-480,-420,-360,-300,-270,-240,-210,-180,-120,-60, + 0,60,120,180,210,240,270,300,330,345,360,390,420,480,525,540,570,600,630,660,690,720,765,780,840]; + if (tp_inst._defaults.timezoneList !== null) { + timezoneList = tp_inst._defaults.timezoneList; + } + var tzl=timezoneList.length,tzi=0,tzv=null; + if (tzl > 0 && typeof timezoneList[0] !== 'object') { + for(; tzi tp_inst._defaults.hourMax? tp_inst._defaults.hourMax : tp_inst._defaults.hour; + tp_inst.minute = tp_inst._defaults.minute < tp_inst._defaults.minuteMin? tp_inst._defaults.minuteMin : + tp_inst._defaults.minute > tp_inst._defaults.minuteMax? tp_inst._defaults.minuteMax : tp_inst._defaults.minute; + tp_inst.second = tp_inst._defaults.second < tp_inst._defaults.secondMin? tp_inst._defaults.secondMin : + tp_inst._defaults.second > tp_inst._defaults.secondMax? tp_inst._defaults.secondMax : tp_inst._defaults.second; + tp_inst.millisec = tp_inst._defaults.millisec < tp_inst._defaults.millisecMin? tp_inst._defaults.millisecMin : + tp_inst._defaults.millisec > tp_inst._defaults.millisecMax? tp_inst._defaults.millisecMax : tp_inst._defaults.millisec; + tp_inst.microsec = tp_inst._defaults.microsec < tp_inst._defaults.microsecMin? tp_inst._defaults.microsecMin : + tp_inst._defaults.microsec > tp_inst._defaults.microsecMax? tp_inst._defaults.microsecMax : tp_inst._defaults.microsec; + tp_inst.ampm = ''; + tp_inst.$input = $input; + + if (tp_inst._defaults.altField) { + tp_inst.$altInput = $(tp_inst._defaults.altField).css({ + cursor: 'pointer' + }).focus(function() { + $input.trigger("focus"); + }); + } + + if (tp_inst._defaults.minDate === 0 || tp_inst._defaults.minDateTime === 0) { + tp_inst._defaults.minDate = new Date(); + } + if (tp_inst._defaults.maxDate === 0 || tp_inst._defaults.maxDateTime === 0) { + tp_inst._defaults.maxDate = new Date(); + } + + // datepicker needs minDate/maxDate, timepicker needs minDateTime/maxDateTime.. + if (tp_inst._defaults.minDate !== undefined && tp_inst._defaults.minDate instanceof Date) { + tp_inst._defaults.minDateTime = new Date(tp_inst._defaults.minDate.getTime()); + } + if (tp_inst._defaults.minDateTime !== undefined && tp_inst._defaults.minDateTime instanceof Date) { + tp_inst._defaults.minDate = new Date(tp_inst._defaults.minDateTime.getTime()); + } + if (tp_inst._defaults.maxDate !== undefined && tp_inst._defaults.maxDate instanceof Date) { + tp_inst._defaults.maxDateTime = new Date(tp_inst._defaults.maxDate.getTime()); + } + if (tp_inst._defaults.maxDateTime !== undefined && tp_inst._defaults.maxDateTime instanceof Date) { + tp_inst._defaults.maxDate = new Date(tp_inst._defaults.maxDateTime.getTime()); + } + tp_inst.$input.bind('focus', function() { + tp_inst._onFocus(); + }); + + return tp_inst; + }, + + /* + * add our sliders to the calendar + */ + _addTimePicker: function(dp_inst) { + var currDT = (this.$altInput && this._defaults.altFieldTimeOnly) ? this.$input.val() + ' ' + this.$altInput.val() : this.$input.val(); + + this.timeDefined = this._parseTime(currDT); + this._limitMinMaxDateTime(dp_inst, false); + this._injectTimePicker(); + }, + + /* + * parse the time string from input value or _setTime + */ + _parseTime: function(timeString, withDate) { + if (!this.inst) { + this.inst = $.datepicker._getInst(this.$input[0]); + } + + if (withDate || !this._defaults.timeOnly) { + var dp_dateFormat = $.datepicker._get(this.inst, 'dateFormat'); + try { + var parseRes = parseDateTimeInternal(dp_dateFormat, this._defaults.timeFormat, timeString, $.datepicker._getFormatConfig(this.inst), this._defaults); + if (!parseRes.timeObj) { + return false; + } + $.extend(this, parseRes.timeObj); + } catch (err) { + $.datetimepicker.log("Error parsing the date/time string: " + err + + "\ndate/time string = " + timeString + + "\ntimeFormat = " + this._defaults.timeFormat + + "\ndateFormat = " + dp_dateFormat); + return false; + } + return true; + } else { + var timeObj = $.datepicker.parseTime(this._defaults.timeFormat, timeString, this._defaults); + if (!timeObj) { + return false; + } + $.extend(this, timeObj); + return true; + } + }, + + /* + * generate and inject html for timepicker into ui datepicker + */ + _injectTimePicker: function() { + var $dp = this.inst.dpDiv, + o = this.inst.settings, + tp_inst = this, + litem = '', + uitem = '', + show = null, + max = {}, + gridSize = {}, + size = null, + i=0, + l=0; + + // Prevent displaying twice + if ($dp.find("div.ui-timepicker-div").length === 0 && o.showTimepicker) { + var noDisplay = ' style="display:none;"', + html = '
    ' + '
    ' + o.timeText + '
    ' + + '
    '; + + // Create the markup + for(i=0,l=this.units.length; i' + o[litem +'Text'] + '' + + '
    '; + + if (show && o[litem+'Grid'] > 0) { + html += '
    '; + + if(litem == 'hour'){ + for (var h = o[litem+'Min']; h <= max[litem]; h += parseInt(o[litem+'Grid'], 10)) { + gridSize[litem]++; + var tmph = $.datepicker.formatTime(this.support.ampm? 'hht':'HH', {hour:h}, o); + html += ''; + } + } + else{ + for (var m = o[litem+'Min']; m <= max[litem]; m += parseInt(o[litem+'Grid'], 10)) { + gridSize[litem]++; + html += ''; + } + } + + html += '
    ' + tmph + '' + ((m < 10) ? '0' : '') + m + '
    '; + } + html += '
    '; + } + + // Timezone + var showTz = o.showTimezone !== null? o.showTimezone : this.support.timezone; + html += '
    ' + o.timezoneText + '
    '; + html += '
    '; + + // Create the elements from string + html += '
    '; + var $tp = $(html); + + // if we only want time picker... + if (o.timeOnly === true) { + $tp.prepend('
    ' + '
    ' + o.timeOnlyTitle + '
    ' + '
    '); + $dp.find('.ui-datepicker-header, .ui-datepicker-calendar').hide(); + } + + // add sliders, adjust grids, add events + for(i=0,l=tp_inst.units.length; i 0) { + size = 100 * gridSize[litem] * o[litem+'Grid'] / (max[litem] - o[litem+'Min']); + $tp.find('.ui_tpicker_'+litem+' table').css({ + width: size + "%", + marginLeft: o.isRTL? '0' : ((size / (-2 * gridSize[litem])) + "%"), + marginRight: o.isRTL? ((size / (-2 * gridSize[litem])) + "%") : '0', + borderCollapse: 'collapse' + }).find("td").click(function(e){ + var $t = $(this), + h = $t.html(), + n = parseInt(h.replace(/[^0-9]/g),10), + ap = h.replace(/[^apm]/ig), + f = $t.data('for'); // loses scope, so we use data-for + + if(f == 'hour'){ + if(ap.indexOf('p') !== -1 && n < 12){ + n += 12; + } + else{ + if(ap.indexOf('a') !== -1 && n === 12){ + n = 0; + } + } + } + + tp_inst.control.value(tp_inst, tp_inst[f+'_slider'], litem, n); + + tp_inst._onTimeChange(); + tp_inst._onSelectHandler(); + }).css({ + cursor: 'pointer', + width: (100 / gridSize[litem]) + '%', + textAlign: 'center', + overflow: 'hidden' + }); + } // end if grid > 0 + } // end for loop + + // Add timezone options + this.timezone_select = $tp.find('.ui_tpicker_timezone').append('').find("select"); + $.fn.append.apply(this.timezone_select, + $.map(o.timezoneList, function(val, idx) { + return $("