CC-3174 : Show builder, working on date choice pickers, make sure they accomodate client/server timezones.
This commit is contained in:
parent
424206b9a9
commit
ecaebbeb67
13 changed files with 1715 additions and 996 deletions
|
@ -41,33 +41,34 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
$baseUrl = $request->getBaseUrl();
|
$baseUrl = $request->getBaseUrl();
|
||||||
|
|
||||||
$this->view->headScript()->appendFile($baseUrl.'/js/contextmenu/jjmenu.js','text/javascript');
|
$this->view->headScript()->appendFile($baseUrl.'/js/contextmenu/jjmenu.js','text/javascript');
|
||||||
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/js/jquery.dataTables.js','text/javascript');
|
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/js/jquery.dataTables.js','text/javascript');
|
||||||
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.pluginAPI.js','text/javascript');
|
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.pluginAPI.js','text/javascript');
|
||||||
$this->view->headScript()->appendFile($baseUrl.'/js/fullcalendar/fullcalendar.js','text/javascript');
|
$this->view->headScript()->appendFile($baseUrl.'/js/fullcalendar/fullcalendar.js','text/javascript');
|
||||||
$this->view->headScript()->appendFile($baseUrl.'/js/timepicker/jquery.ui.timepicker-0.0.6.js','text/javascript');
|
$this->view->headScript()->appendFile($baseUrl.'/js/timepicker/jquery.ui.timepicker.js','text/javascript');
|
||||||
$this->view->headScript()->appendFile($baseUrl.'/js/colorpicker/js/colorpicker.js','text/javascript');
|
$this->view->headScript()->appendFile($baseUrl.'/js/colorpicker/js/colorpicker.js','text/javascript');
|
||||||
|
|
||||||
//full-calendar-functions.js requires this variable, so that datePicker widget can be offset to server time instead of client time
|
//full-calendar-functions.js requires this variable, so that datePicker widget can be offset to server time instead of client time
|
||||||
$this->view->headScript()->appendScript("var timezoneOffset = ".date("Z")."; //in seconds");
|
$this->view->headScript()->appendScript("var timezoneOffset = ".date("Z")."; //in seconds");
|
||||||
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/schedule/full-calendar-functions.js','text/javascript');
|
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/schedule/full-calendar-functions.js','text/javascript');
|
||||||
|
|
||||||
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/schedule/add-show.js','text/javascript');
|
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/schedule/add-show.js','text/javascript');
|
||||||
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/schedule/schedule.js','text/javascript');
|
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/schedule/schedule.js','text/javascript');
|
||||||
$this->view->headScript()->appendFile($baseUrl.'/js/meioMask/jquery.meio.mask.js','text/javascript');
|
$this->view->headScript()->appendFile($baseUrl.'/js/meioMask/jquery.meio.mask.js','text/javascript');
|
||||||
|
|
||||||
$this->view->headLink()->appendStylesheet($baseUrl.'/css/jquery-ui-timepicker.css');
|
$this->view->headLink()->appendStylesheet($baseUrl.'/css/jquery.ui.timepicker.css');
|
||||||
$this->view->headLink()->appendStylesheet($baseUrl.'/css/fullcalendar.css');
|
$this->view->headLink()->appendStylesheet($baseUrl.'/css/fullcalendar.css');
|
||||||
$this->view->headLink()->appendStylesheet($baseUrl.'/css/colorpicker/css/colorpicker.css');
|
$this->view->headLink()->appendStylesheet($baseUrl.'/css/colorpicker/css/colorpicker.css');
|
||||||
$this->view->headLink()->appendStylesheet($baseUrl.'/css/add-show.css');
|
$this->view->headLink()->appendStylesheet($baseUrl.'/css/add-show.css');
|
||||||
$this->view->headLink()->appendStylesheet($baseUrl.'/css/contextmenu.css');
|
$this->view->headLink()->appendStylesheet($baseUrl.'/css/contextmenu.css');
|
||||||
|
|
||||||
|
|
||||||
Application_Model_Schedule::createNewFormSections($this->view);
|
Application_Model_Schedule::createNewFormSections($this->view);
|
||||||
|
|
||||||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||||
$user = new Application_Model_User($userInfo->id);
|
$user = new Application_Model_User($userInfo->id);
|
||||||
$this->view->isAdmin = $user->isAdmin();
|
$this->view->isAdmin = $user->isAdmin();
|
||||||
$this->view->isProgramManager = $user->isUserType('P');
|
$this->view->isProgramManager = $user->isUserType('P');
|
||||||
|
|
||||||
$this->view->headScript()->appendScript("var weekStart = ".Application_Model_Preference::GetWeekStartDay().";");
|
$this->view->headScript()->appendScript("var weekStart = ".Application_Model_Preference::GetWeekStartDay().";");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,36 +7,22 @@ class ShowbuilderController extends Zend_Controller_Action
|
||||||
{
|
{
|
||||||
$ajaxContext = $this->_helper->getHelper('AjaxContext');
|
$ajaxContext = $this->_helper->getHelper('AjaxContext');
|
||||||
$ajaxContext->addActionContext('schedule', 'json')
|
$ajaxContext->addActionContext('schedule', 'json')
|
||||||
|
->addActionContext('builder-feed', 'json')
|
||||||
->initContext();
|
->initContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function indexAction() {
|
public function indexAction() {
|
||||||
|
|
||||||
$request = $this->getRequest();
|
$this->_helper->layout->setLayout('builder');
|
||||||
|
|
||||||
$user_id = $request->getParam("uid", 0);
|
$this->view->headScript()->appendFile($this->view->baseUrl('/js/airtime/library/events/library_showbuilder.js'),'text/javascript');
|
||||||
$show_instance_id = $request->getParam("sid", 0);
|
|
||||||
|
|
||||||
try {
|
$this->_helper->actionStack('library', 'library');
|
||||||
$user = new Application_Model_User($user_id);
|
$this->_helper->actionStack('builder', 'showbuilder');
|
||||||
$show_instance = new Application_Model_ShowInstance($show_instance_id);
|
|
||||||
}
|
|
||||||
catch(Exception $e) {
|
|
||||||
$this->_helper->redirector('denied', 'error');
|
|
||||||
}
|
|
||||||
|
|
||||||
//user is allowed to schedule this show.
|
//user is allowed to schedule this show.
|
||||||
if ($user->isAdmin() || $user->isHost($show_instance->getShowId())) {
|
//if ($user->isAdmin() || $user->isHost($show_instance->getShowId())) {
|
||||||
$this->_helper->layout->setLayout('builder');
|
//}
|
||||||
|
|
||||||
$this->view->headScript()->appendFile($this->view->baseUrl('/js/airtime/library/events/library_showbuilder.js'),'text/javascript');
|
|
||||||
|
|
||||||
$this->_helper->actionStack('library', 'library');
|
|
||||||
$this->_helper->actionStack('builder', 'showbuilder');
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$this->_helper->redirector('denied', 'error');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function builderAction() {
|
public function builderAction() {
|
||||||
|
@ -44,16 +30,39 @@ class ShowbuilderController extends Zend_Controller_Action
|
||||||
$request = $this->getRequest();
|
$request = $this->getRequest();
|
||||||
$baseUrl = $request->getBaseUrl();
|
$baseUrl = $request->getBaseUrl();
|
||||||
|
|
||||||
$this->view->headScript()->appendFile($baseUrl.'/js/fullcalendar/fullcalendar_orig.js','text/javascript');
|
$this->view->headScript()->appendFile($baseUrl.'/js/timepicker/jquery.ui.timepicker.js','text/javascript');
|
||||||
|
|
||||||
|
$this->view->headScript()->appendScript("var serverTimezoneOffset = ".date("Z")."; //in seconds");
|
||||||
|
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/js/jquery.dataTables.js','text/javascript');
|
||||||
|
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.ColVis.js','text/javascript');
|
||||||
|
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.ColReorderResize.js','text/javascript');
|
||||||
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/showbuilder/builder.js','text/javascript');
|
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/showbuilder/builder.js','text/javascript');
|
||||||
|
|
||||||
$this->view->headLink()->appendStylesheet($baseUrl.'/css/fullcalendar.css');
|
$this->view->headLink()->appendStylesheet($baseUrl.'/css/jquery.ui.timepicker.css');
|
||||||
|
|
||||||
$this->_helper->viewRenderer->setResponseSegment('builder');
|
$this->_helper->viewRenderer->setResponseSegment('builder');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function eventFeedAction() {
|
public function builderFeedAction() {
|
||||||
|
|
||||||
|
$request = $this->getRequest();
|
||||||
|
$current_time = microtime(true);
|
||||||
|
|
||||||
|
$starts_epoch = $request->getParam("start", $current_time);
|
||||||
|
//default ends is 24 hours after starts.
|
||||||
|
$ends_epoch = $request->getParam("end", $current_time + (60*60*24));
|
||||||
|
|
||||||
|
$startsDT = DateTime::createFromFormat("U.u", $starts_epoch, new DateTimeZone("UTC"));
|
||||||
|
$endsDT = DateTime::createFromFormat("U.u", $ends_epoch, new DateTimeZone("UTC"));
|
||||||
|
|
||||||
|
$scheduled_items = Application_Model_Schedule::GetItems($startsDT->format("Y-m-d H:i:s.u"), $endsDT->format("Y-m-d H:i:s.u"), false);
|
||||||
|
|
||||||
|
foreach ($scheduled_items as &$item) {
|
||||||
|
$itemStartsDT = DateTime::createFromFormat("Y-m-d H:i:s.u", $item["starts"], new DateTimeZone("UTC"));
|
||||||
|
$itemEndsDT = DateTime::createFromFormat("Y-m-d H:i:s.u", $item["ends"], new DateTimeZone("UTC"));
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->view->schedule = $scheduled_items;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function scheduleAction() {
|
public function scheduleAction() {
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
<div class="wrapper">
|
<div class="wrapper">
|
||||||
<!--Set to z-index 254 to make it lower than the top-panel and the ZFDebug info bar, but higher than the side-playlist-->
|
<!--Set to z-index 254 to make it lower than the top-panel and the ZFDebug info bar, but higher than the side-playlist-->
|
||||||
<div id="library_content" class="tabs ui-widget ui-widget-content block-shadow alpha-block padded" style="z-index:254"><?php echo $this->layout()->library ?></div>
|
<div id="library_content" class="tabs ui-widget ui-widget-content block-shadow alpha-block padded" style="z-index:254"><?php echo $this->layout()->library ?></div>
|
||||||
<div id="show_builder" class="ui-widget ui-widget-content block-shadow omega-block"><?php echo $this->layout()->builder ?></div>
|
<div id="show_builder" class="ui-widget ui-widget-content block-shadow omega-block padded"><?php echo $this->layout()->builder ?></div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -155,7 +155,7 @@ class Application_Model_Schedule {
|
||||||
"nextShow"=>Application_Model_Show::GetNextShows($utcTimeNow, 1),
|
"nextShow"=>Application_Model_Show::GetNextShows($utcTimeNow, 1),
|
||||||
"timezone"=> date("T"),
|
"timezone"=> date("T"),
|
||||||
"timezoneOffset"=> date("Z"));
|
"timezoneOffset"=> date("Z"));
|
||||||
|
|
||||||
return $range;
|
return $range;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -294,6 +294,38 @@ class Application_Model_Schedule {
|
||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* @param DateTime $p_startDateTime
|
||||||
|
*
|
||||||
|
* @param DateTime $p_endDateTime
|
||||||
|
*
|
||||||
|
* @return array $scheduledItems
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static function GetScheduleDetailItems($p_startDateTime, $p_endDateTime)
|
||||||
|
{
|
||||||
|
global $CC_CONFIG, $CC_DBC;
|
||||||
|
|
||||||
|
$sql = "SELECT DISTINCT
|
||||||
|
|
||||||
|
showt.name, showt.color, showt.background_color,
|
||||||
|
si.starts, si.ends, si.time_filled, si.record, si.rebroadcast,
|
||||||
|
sched.starts, sched.ends,
|
||||||
|
ft.track_title, ft.artist_name, ft.album_title, ft.length
|
||||||
|
|
||||||
|
FROM
|
||||||
|
((cc_schedule AS sched JOIN cc_files AS ft ON (sched.file_id = ft.id)
|
||||||
|
RIGHT OUTER JOIN cc_show_instances AS si ON (si.id = sched.instance_id))
|
||||||
|
JOIN cc_show AS showt ON (showt.id = si.show_id)
|
||||||
|
)
|
||||||
|
|
||||||
|
ORDER BY sched.starts;";
|
||||||
|
|
||||||
|
$rows = $CC_DBC->GetAll($sql);
|
||||||
|
return $rows;
|
||||||
|
}
|
||||||
|
|
||||||
public static function GetShowInstanceItems($instance_id)
|
public static function GetShowInstanceItems($instance_id)
|
||||||
{
|
{
|
||||||
global $CC_CONFIG, $CC_DBC;
|
global $CC_CONFIG, $CC_DBC;
|
||||||
|
@ -533,7 +565,7 @@ class Application_Model_Schedule {
|
||||||
|
|
||||||
public static function createNewFormSections($p_view){
|
public static function createNewFormSections($p_view){
|
||||||
$isSaas = Application_Model_Preference::GetPlanLevel() == 'disabled'?false:true;
|
$isSaas = Application_Model_Preference::GetPlanLevel() == 'disabled'?false:true;
|
||||||
|
|
||||||
$formWhat = new Application_Form_AddShowWhat();
|
$formWhat = new Application_Form_AddShowWhat();
|
||||||
$formWho = new Application_Form_AddShowWho();
|
$formWho = new Application_Form_AddShowWho();
|
||||||
$formWhen = new Application_Form_AddShowWhen();
|
$formWhen = new Application_Form_AddShowWhen();
|
||||||
|
@ -560,16 +592,16 @@ class Application_Model_Schedule {
|
||||||
'add_show_duration' => '1h'));
|
'add_show_duration' => '1h'));
|
||||||
|
|
||||||
$formRepeats->populate(array('add_show_end_date' => date("Y-m-d")));
|
$formRepeats->populate(array('add_show_end_date' => date("Y-m-d")));
|
||||||
|
|
||||||
if(!$isSaas){
|
if(!$isSaas){
|
||||||
$formRecord = new Application_Form_AddShowRR();
|
$formRecord = new Application_Form_AddShowRR();
|
||||||
$formAbsoluteRebroadcast = new Application_Form_AddShowAbsoluteRebroadcastDates();
|
$formAbsoluteRebroadcast = new Application_Form_AddShowAbsoluteRebroadcastDates();
|
||||||
$formRebroadcast = new Application_Form_AddShowRebroadcastDates();
|
$formRebroadcast = new Application_Form_AddShowRebroadcastDates();
|
||||||
|
|
||||||
$formRecord->removeDecorator('DtDdWrapper');
|
$formRecord->removeDecorator('DtDdWrapper');
|
||||||
$formAbsoluteRebroadcast->removeDecorator('DtDdWrapper');
|
$formAbsoluteRebroadcast->removeDecorator('DtDdWrapper');
|
||||||
$formRebroadcast->removeDecorator('DtDdWrapper');
|
$formRebroadcast->removeDecorator('DtDdWrapper');
|
||||||
|
|
||||||
$p_view->rr = $formRecord;
|
$p_view->rr = $formRecord;
|
||||||
$p_view->absoluteRebroadcast = $formAbsoluteRebroadcast;
|
$p_view->absoluteRebroadcast = $formAbsoluteRebroadcast;
|
||||||
$p_view->rebroadcast = $formRebroadcast;
|
$p_view->rebroadcast = $formRebroadcast;
|
||||||
|
|
|
@ -1 +1,8 @@
|
||||||
<div style="width:800px" id="show_builder"></div>
|
<div style="width:800px" id="show_builder">
|
||||||
|
<input type="text" id="show_builder_datepicker_start" class="input_text"></input>
|
||||||
|
<input type="text" id="show_builder_timepicker_start" class="input_text"></input>
|
||||||
|
<input type="text" id="show_builder_datepicker_end" class="input_text"></input>
|
||||||
|
<input type="text" id="show_builder_timepicker_end" class="input_text"></input>
|
||||||
|
<input type="button" id="show_builder_timerange_button" class="ui-button ui-state-default" value="GO"></input>
|
||||||
|
<table id="show_builder_table" cellpadding="0" cellspacing="0" class="datatable"></table>
|
||||||
|
</div>
|
|
@ -1,28 +0,0 @@
|
||||||
/*
|
|
||||||
* Timepicker stylesheet
|
|
||||||
* Highly inspired from datepicker
|
|
||||||
* FG - Nov 2010 - Web3R
|
|
||||||
*
|
|
||||||
* version 0.0.3 : Fixed some settings, more dynamic
|
|
||||||
* version 0.0.4 : Removed width:100% on tables
|
|
||||||
*/
|
|
||||||
|
|
||||||
.ui-timepicker-inline { display: inline }
|
|
||||||
|
|
||||||
#ui-timepicker-div { padding: 0.2em; z-index: 10 !important }
|
|
||||||
.ui-timepicker-table { display: inline-table }
|
|
||||||
.ui-timepicker-table table { margin:0.15em 0 0 0; border-collapse: collapse; }
|
|
||||||
|
|
||||||
.ui-timepicker-hours, .ui-timepicker-minutes { padding: 0.2em; }
|
|
||||||
|
|
||||||
.ui-timepicker-table .ui-timepicker-title { line-height: 1.8em; text-align: center; }
|
|
||||||
.ui-timepicker-table td { padding: 0.1em; width: 2.2em; }
|
|
||||||
.ui-timepicker-table th.periods { padding: 0.1em; width: 2.2em; }
|
|
||||||
.ui-timepicker-table td a {
|
|
||||||
display:block;
|
|
||||||
padding:0.2em 0.3em 0.2em 0.5em;
|
|
||||||
width: 1.2em;
|
|
||||||
|
|
||||||
text-align:right;
|
|
||||||
text-decoration:none;
|
|
||||||
}
|
|
69
airtime_mvc/public/css/jquery.ui.timepicker.css
vendored
Normal file
69
airtime_mvc/public/css/jquery.ui.timepicker.css
vendored
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
/*
|
||||||
|
* Timepicker stylesheet
|
||||||
|
* Highly inspired from datepicker
|
||||||
|
* FG - Nov 2010 - Web3R
|
||||||
|
*
|
||||||
|
* version 0.0.3 : Fixed some settings, more dynamic
|
||||||
|
* version 0.0.4 : Removed width:100% on tables
|
||||||
|
* version 0.1.1 : set width 0 on tables to fix an ie6 bug
|
||||||
|
*/
|
||||||
|
|
||||||
|
.ui-timepicker-inline { display: inline; }
|
||||||
|
|
||||||
|
#ui-timepicker-div { padding: 0.2em }
|
||||||
|
.ui-timepicker-table { display: inline-table; width: 0; }
|
||||||
|
.ui-timepicker-table table { margin:0.15em 0 0 0; border-collapse: collapse; }
|
||||||
|
|
||||||
|
.ui-timepicker-hours, .ui-timepicker-minutes { padding: 0.2em; }
|
||||||
|
|
||||||
|
.ui-timepicker-table .ui-timepicker-title { line-height: 1.8em; text-align: center; }
|
||||||
|
.ui-timepicker-table td { padding: 0.1em; width: 2.2em; }
|
||||||
|
.ui-timepicker-table th.periods { padding: 0.1em; width: 2.2em; }
|
||||||
|
|
||||||
|
/* span for disabled cells */
|
||||||
|
.ui-timepicker-table td span {
|
||||||
|
display:block;
|
||||||
|
padding:0.2em 0.3em 0.2em 0.5em;
|
||||||
|
width: 1.2em;
|
||||||
|
|
||||||
|
text-align:right;
|
||||||
|
text-decoration:none;
|
||||||
|
}
|
||||||
|
/* anchors for clickable cells */
|
||||||
|
.ui-timepicker-table td a {
|
||||||
|
display:block;
|
||||||
|
padding:0.2em 0.3em 0.2em 0.5em;
|
||||||
|
width: 1.2em;
|
||||||
|
cursor: pointer;
|
||||||
|
text-align:right;
|
||||||
|
text-decoration:none;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* buttons and button pane styling */
|
||||||
|
.ui-timepicker .ui-timepicker-buttonpane {
|
||||||
|
background-image: none; margin: .7em 0 0 0; padding:0 .2em; border-left: 0; border-right: 0; border-bottom: 0;
|
||||||
|
}
|
||||||
|
.ui-timepicker .ui-timepicker-buttonpane button { margin: .5em .2em .4em; cursor: pointer; padding: .2em .6em .3em .6em; width:auto; overflow:visible; }
|
||||||
|
/* The close button */
|
||||||
|
.ui-timepicker .ui-timepicker-close { float: right }
|
||||||
|
|
||||||
|
/* the now button */
|
||||||
|
.ui-timepicker .ui-timepicker-now { float: left; }
|
||||||
|
|
||||||
|
/* the deselect button */
|
||||||
|
.ui-timepicker .ui-timepicker-deselect { float: left; }
|
||||||
|
|
||||||
|
|
||||||
|
/* IE6 IFRAME FIX (taken from datepicker 1.5.3 */
|
||||||
|
.ui-timepicker-cover {
|
||||||
|
display: none; /*sorry for IE5*/
|
||||||
|
display/**/: block; /*sorry for IE5*/
|
||||||
|
position: absolute; /*must have*/
|
||||||
|
z-index: -1; /*must have*/
|
||||||
|
filter: mask(); /*must have*/
|
||||||
|
top: -4px; /*must have*/
|
||||||
|
left: -4px; /*must have*/
|
||||||
|
width: 200px; /*must have*/
|
||||||
|
height: 200px; /*must have*/
|
||||||
|
}
|
|
@ -12,6 +12,22 @@ function dtDrawCallback() {
|
||||||
setupGroupActions();
|
setupGroupActions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addLibraryItemEvents() {
|
||||||
|
|
||||||
|
$('#library_display tr[id ^= "au"]')
|
||||||
|
.draggable({
|
||||||
|
helper: 'clone',
|
||||||
|
cursor: 'pointer'
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#library_display tbody tr td').not('[class=library_checkbox]')
|
||||||
|
.jjmenu("click",
|
||||||
|
[{get:"/Library/context-menu/format/json/id/#id#/type/#type#"}],
|
||||||
|
{id: getId, type: getType},
|
||||||
|
{xposition: "mouse", yposition: "mouse"});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
function setupLibraryToolbar() {
|
function setupLibraryToolbar() {
|
||||||
$("div.library_toolbar").html('<span class="fg-button ui-button ui-state-default" id="library_order_reset">Reset Order</span>' +
|
$("div.library_toolbar").html('<span class="fg-button ui-button ui-state-default" id="library_order_reset">Reset Order</span>' +
|
||||||
'<span class="fg-button ui-button ui-state-default ui-state-disabled" id="library_group_delete">Delete</span>' +
|
'<span class="fg-button ui-button ui-state-default ui-state-disabled" id="library_group_delete">Delete</span>' +
|
||||||
|
|
|
@ -11,4 +11,21 @@ function dtDrawCallback() {
|
||||||
addLibraryItemEvents();
|
addLibraryItemEvents();
|
||||||
//addMetadataQtip();
|
//addMetadataQtip();
|
||||||
//setupGroupActions();
|
//setupGroupActions();
|
||||||
|
}
|
||||||
|
|
||||||
|
function addLibraryItemEvents() {
|
||||||
|
|
||||||
|
$('#library_display tr')
|
||||||
|
.draggable({
|
||||||
|
helper: 'clone',
|
||||||
|
cursor: 'pointer',
|
||||||
|
connectToSortable: '#show_builder_table'
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#library_display tbody tr td').not('[class=library_checkbox]')
|
||||||
|
.jjmenu("click",
|
||||||
|
[{get:"/Library/context-menu/format/json/id/#id#/type/#type#"}],
|
||||||
|
{id: getId, type: getType},
|
||||||
|
{xposition: "mouse", yposition: "mouse"});
|
||||||
|
|
||||||
}
|
}
|
|
@ -104,22 +104,6 @@ function deletePlaylist(json) {
|
||||||
}
|
}
|
||||||
//end callbacks called by jjmenu
|
//end callbacks called by jjmenu
|
||||||
|
|
||||||
function addLibraryItemEvents() {
|
|
||||||
|
|
||||||
$('#library_display tr[id ^= "au"]')
|
|
||||||
.draggable({
|
|
||||||
helper: 'clone',
|
|
||||||
cursor: 'pointer'
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#library_display tbody tr td').not('[class=library_checkbox]')
|
|
||||||
.jjmenu("click",
|
|
||||||
[{get:"/Library/context-menu/format/json/id/#id#/type/#type#"}],
|
|
||||||
{id: getId, type: getType},
|
|
||||||
{xposition: "mouse", yposition: "mouse"});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function addProgressIcon(id) {
|
function addProgressIcon(id) {
|
||||||
if($("#au_"+id).find("td.library_title").find("span").length > 0){
|
if($("#au_"+id).find("td.library_title").find("span").length > 0){
|
||||||
$("#au_"+id).find("td.library_title").find("span").removeClass();
|
$("#au_"+id).find("td.library_title").find("span").removeClass();
|
||||||
|
|
|
@ -1,76 +1,192 @@
|
||||||
function getFullCalendarEvents(start, end, callback) {
|
function tpStartOnHourShowCallback(hour) {
|
||||||
var url, unix_ts_start, unix_ts_end;
|
var tpEndHour = $('#show_builder_timepicker_end').timepicker('getHour');
|
||||||
|
|
||||||
|
// Check if proposed hour is prior or equal to selected end time hour
|
||||||
|
if (hour <= tpEndHour) { return true; }
|
||||||
|
// if hour did not match, it can not be selected
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
unix_ts_start = Math.round(start.getTime() / 1000),
|
function tpStartOnMinuteShowCallback(hour, minute) {
|
||||||
unix_ts_end = Math.round(end.getTime() / 1000);
|
var tpEndHour = $('#show_builder_timepicker_end').timepicker('getHour'),
|
||||||
|
tpEndMinute = $('#show_builder_timepicker_end').timepicker('getMinute');
|
||||||
|
|
||||||
|
// Check if proposed hour is prior to selected end time hour
|
||||||
|
if (hour < tpEndHour) { return true; }
|
||||||
|
// Check if proposed hour is equal to selected end time hour and minutes is prior
|
||||||
|
if ( (hour == tpEndHour) && (minute < tpEndMinute) ) { return true; }
|
||||||
|
// if minute did not match, it can not be selected
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
url = '/Schedule/event-feed';
|
function tpEndOnHourShowCallback(hour) {
|
||||||
|
var tpStartHour = $('#show_builder_timepicker_start').timepicker('getHour');
|
||||||
|
|
||||||
|
// Check if proposed hour is after or equal to selected start time hour
|
||||||
|
if (hour >= tpStartHour) { return true; }
|
||||||
|
// if hour did not match, it can not be selected
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
var d = new Date();
|
function tpEndOnMinuteShowCallback(hour, minute) {
|
||||||
|
var tpStartHour = $('#show_builder_timepicker_start').timepicker('getHour'),
|
||||||
|
tpStartMinute = $('#show_builder_timepicker_start').timepicker('getMinute');
|
||||||
|
|
||||||
|
// Check if proposed hour is after selected start time hour
|
||||||
|
if (hour > tpStartHour) { return true; }
|
||||||
|
// Check if proposed hour is equal to selected start time hour and minutes is after
|
||||||
|
if ( (hour == tpStartHour) && (minute > tpStartMinute) ) { return true; }
|
||||||
|
// if minute did not match, it can not be selected
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$.get(url, {format: "json", start: unix_ts_start, end: unix_ts_end, cachep: d.getTime()}, function(json){
|
/*
|
||||||
callback(json.events);
|
* Get the schedule range start in unix timestamp form (in seconds).
|
||||||
});
|
* defaults to NOW if nothing is selected.
|
||||||
|
*
|
||||||
|
* @param String sDatePickerId
|
||||||
|
*
|
||||||
|
* @param String sTimePickerId
|
||||||
|
*
|
||||||
|
* @return Number iTime
|
||||||
|
*/
|
||||||
|
function fnGetUIPickerUnixTimestamp(sDatePickerId, sTimePickerId) {
|
||||||
|
var oDate,
|
||||||
|
oTimePicker = $( sTimePickerId ),
|
||||||
|
iTime,
|
||||||
|
iHour,
|
||||||
|
iMin,
|
||||||
|
iClientOffset,
|
||||||
|
iServerOffset;
|
||||||
|
|
||||||
|
oDate = $( sDatePickerId ).datepicker( "getDate" );
|
||||||
|
|
||||||
|
//nothing has been selected from this datepicker.
|
||||||
|
if (oDate === null) {
|
||||||
|
oDate = new Date();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
iHour = oTimePicker.timepicker('getHour');
|
||||||
|
iMin = oTimePicker.timepicker('getMinute');
|
||||||
|
|
||||||
|
oDate.setHours(iHour, iMin);
|
||||||
|
}
|
||||||
|
|
||||||
|
iTime = oDate.getTime(); //value is in millisec.
|
||||||
|
iTime = Math.round(iTime / 1000);
|
||||||
|
iClientOffset = -(oDate.getTimezoneOffset() * 60); //offset is returned in minutes.
|
||||||
|
iServerOffset = serverTimezoneOffset;
|
||||||
|
|
||||||
|
return iTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
function fnGetScheduleRange() {
|
||||||
|
var iStart,
|
||||||
|
iEnd,
|
||||||
|
iRange;
|
||||||
|
|
||||||
|
iStart = fnGetUIPickerUnixTimestamp("#show_builder_datepicker_start", "#show_builder_timepicker_start");
|
||||||
|
iEnd = fnGetUIPickerUnixTimestamp("#show_builder_datepicker_end", "#show_builder_timepicker_end");
|
||||||
|
|
||||||
|
iRange = iEnd - iStart;
|
||||||
|
}
|
||||||
|
|
||||||
|
function fnServerData( sSource, aoData, fnCallback ) {
|
||||||
|
aoData.push( { name: "format", value: "json"} );
|
||||||
|
|
||||||
|
$.ajax( {
|
||||||
|
"dataType": "json",
|
||||||
|
"type": "GET",
|
||||||
|
"url": sSource,
|
||||||
|
"data": aoData,
|
||||||
|
"success": fnCallback
|
||||||
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$('#show_builder').fullCalendar({
|
var dTable;
|
||||||
header: {
|
|
||||||
left: '',
|
dTable = $('#show_builder_table').dataTable( {
|
||||||
center: '',
|
"aoColumns": [
|
||||||
right: ''
|
/* starts */{"mDataProp": "starts", "sTitle": "starts"},
|
||||||
},
|
/* ends */{"mDataProp": "ends", "sTitle": "ends"},
|
||||||
defaultView: 'agendaDay',
|
/* title */{"mDataProp": "file_id", "sTitle": "file_id"}
|
||||||
allDaySlot: false,
|
],
|
||||||
theme: true,
|
|
||||||
|
"asStripClasses": [ 'odd' ],
|
||||||
|
|
||||||
|
"bJQueryUI": true,
|
||||||
|
"bSort": false,
|
||||||
|
"bFilter": false,
|
||||||
|
"bProcessing": true,
|
||||||
|
"bServerSide": true,
|
||||||
|
"bInfo": false,
|
||||||
|
|
||||||
|
"fnServerData": fnServerData,
|
||||||
|
|
||||||
events: getFullCalendarEvents,
|
// R = ColReorder, C = ColVis, see datatables doc for others
|
||||||
|
"sDom": 'Rr<"H"C>t<"F">',
|
||||||
|
|
||||||
|
//options for infinite scrolling
|
||||||
|
//"bScrollInfinite": true,
|
||||||
|
//"bScrollCollapse": true,
|
||||||
|
"sScrollY": "400px",
|
||||||
|
|
||||||
|
"sAjaxDataProp": "schedule",
|
||||||
|
"sAjaxSource": "/showbuilder/builder-feed"
|
||||||
|
|
||||||
axisFormat: 'H:mm',
|
});
|
||||||
slotMinutes: 1,
|
|
||||||
timeFormat: {
|
$( "#show_builder_datepicker_start" ).datepicker({
|
||||||
agenda: 'H:mm:ss{ - H:mm:ss}'
|
dateFormat: '@',
|
||||||
},
|
onSelect: function(sDate, oDatePicker) {
|
||||||
|
var oDate;
|
||||||
minTime: '17:00',
|
|
||||||
maxTime: '18:00',
|
|
||||||
|
|
||||||
droppable: true, // this allows things to be dropped onto the calendar !!!
|
|
||||||
drop: function(date, allDay) { // this function is called when something is dropped
|
|
||||||
|
|
||||||
// retrieve the dropped element's stored Event Object
|
|
||||||
//var originalEventObject = $(this).data('eventObject');
|
|
||||||
|
|
||||||
// we need to copy it, so that multiple events don't have a reference to the same object
|
oDate = new Date(parseInt(sDate, 10));
|
||||||
//var copiedEventObject = $.extend({}, originalEventObject);
|
$(this).val(oDate.toDateString());
|
||||||
var copiedEventObject = {};
|
|
||||||
var data = $(this).data("show_builder");
|
|
||||||
|
|
||||||
$.ajax({url: "/showbuilder/schedule",
|
|
||||||
data:{format: "json", sid:"", schedule_start: date},
|
|
||||||
dataType:"json",
|
|
||||||
success:function(json){
|
|
||||||
var x;
|
|
||||||
},
|
|
||||||
error:function(jqXHR, textStatus, errorThrown){
|
|
||||||
var x;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// assign it the date that was reported
|
|
||||||
copiedEventObject.title = "test title";
|
|
||||||
copiedEventObject.start = date;
|
|
||||||
var end = new Date(date.getTime());
|
|
||||||
end.setMinutes(end.getMinutes() + 5);
|
|
||||||
end.setSeconds(end.getSeconds() + 5);
|
|
||||||
copiedEventObject.end = end;
|
|
||||||
copiedEventObject.allDay = allDay;
|
|
||||||
|
|
||||||
// render the event on the calendar
|
|
||||||
// the last `true` argument determines if the event "sticks" (http://arshaw.com/fullcalendar/docs/event_rendering/renderEvent/)
|
|
||||||
//$('#show_builder').fullCalendar('renderEvent', copiedEventObject, true);
|
|
||||||
|
|
||||||
$("#schedule_calendar").fullCalendar( 'refetchEvents' );
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$( "#show_builder_timepicker_start" ).timepicker({
|
||||||
|
showPeriodLabels: false,
|
||||||
|
showCloseButton: true,
|
||||||
|
showLeadingZero: false
|
||||||
|
});
|
||||||
|
|
||||||
|
$( "#show_builder_datepicker_end" ).datepicker({
|
||||||
|
dateFormat: '@',
|
||||||
|
onSelect: function(sDate, oDatePicker) {
|
||||||
|
var oDate;
|
||||||
|
|
||||||
|
oDate = new Date(parseInt(sDate, 10));
|
||||||
|
$(this).val(oDate.toDateString());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$( "#show_builder_timepicker_end" ).timepicker({
|
||||||
|
showPeriodLabels: false,
|
||||||
|
showCloseButton: true,
|
||||||
|
showLeadingZero: false
|
||||||
|
});
|
||||||
|
|
||||||
|
$( "#show_builder_timerange_button" ).click(function(ev){
|
||||||
|
var oTable, oSettings, iStartDate, iEndDate, iStartTime, iEndTime;
|
||||||
|
|
||||||
|
fnGetScheduleRange();
|
||||||
|
|
||||||
|
oTable = $('#show_builder_table').dataTable({"bRetrieve": true});
|
||||||
|
oSettings = oTable.fnSettings();
|
||||||
|
oSettings["_iDisplayStart"] = 1050;
|
||||||
|
|
||||||
|
oTable.fnDraw();
|
||||||
|
});
|
||||||
|
|
||||||
|
$( "#show_builder_table" ).sortable({
|
||||||
|
placeholder: "ui-state-highlight",
|
||||||
|
items: 'tr',
|
||||||
|
receive: function(event, ui) {
|
||||||
|
var x;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,849 +0,0 @@
|
||||||
/*
|
|
||||||
* jQuery UI Timepicker 0.0.5
|
|
||||||
*
|
|
||||||
* Copyright 2010-2011, Francois Gelinas
|
|
||||||
* Dual licensed under the MIT or GPL Version 2 licenses.
|
|
||||||
* http://jquery.org/license
|
|
||||||
*
|
|
||||||
* http://fgelinas.com
|
|
||||||
*
|
|
||||||
* Depends:
|
|
||||||
* jquery.ui.core.js
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* As it is a timepicker, I inspired most of the code from the datepicker
|
|
||||||
* Francois Gelinas - Nov 2010
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Release 0.0.2 - Jan 6, 2011
|
|
||||||
* Updated to include common display options for USA users
|
|
||||||
* Stephen Commisso - Jan 2011
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* release 0.0.3 - Jan 8, 2011
|
|
||||||
* Re-added a display:none on the main div (fix a small empty div visible at the bottom of the page before timepicker is called) (Thanks Gertjan van Roekel)
|
|
||||||
* Fixed a problem where the timepicker was never displayed with jquery ui 1.8.7 css,
|
|
||||||
* the problem was the class ui-helper-hidden-accessible, witch I removed.
|
|
||||||
* Thanks Alexander Fietz and StackOverflow : http://stackoverflow.com/questions/4522274/jquery-timepicker-and-jqueryui-1-8-7-conflict
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Release 0.0.4 - jan 10, 2011
|
|
||||||
* changed showLeadingZero to affect only hours, added showMinutesLeadingZero for minutes display
|
|
||||||
* Removed width:100% for tables in css
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Release 0.0.5 - Jan 18, 2011
|
|
||||||
* Now updating time picker selected value when manually typing in the text field (thanks Rasmus Schultz)
|
|
||||||
* Fixed : with showPeriod: true and showLeadingZero: true, PM hours did not show leading zeros (thanks Chandler May)
|
|
||||||
* Fixed : with showPeriod: true and showLeadingZero: true, Selecting 12 AM shows as 00 AM in the input field, also parsing 12AM did not work correctly (thanks Rasmus Schultz)
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Release 0.0.6 - Jan 19, 2011
|
|
||||||
* Added standard "change" event being triggered on the input when the content changes. (Thanks Rasmus Schultz)
|
|
||||||
* Added support for inline timePicker, attached to div or span
|
|
||||||
* Added altField that receive the parsed time value when selected time changes
|
|
||||||
* Added defaultTime value to use when input field is missing (inline) or input value is empty
|
|
||||||
* if defaultTime is missing, current time is used
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
(function ($, undefined) {
|
|
||||||
|
|
||||||
$.extend($.ui, { timepicker: { version: "0.0.1"} });
|
|
||||||
|
|
||||||
var PROP_NAME = 'timepicker';
|
|
||||||
var tpuuid = new Date().getTime();
|
|
||||||
|
|
||||||
/* Time picker manager.
|
|
||||||
Use the singleton instance of this class, $.timepicker, 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. */
|
|
||||||
|
|
||||||
function Timepicker() {
|
|
||||||
this.debug = true; // Change this to true to start debugging
|
|
||||||
this._curInst = null; // The current instance in use
|
|
||||||
this._isInline = false; // true if the instance is displayed inline
|
|
||||||
this._disabledInputs = []; // List of time picker inputs that have been disabled
|
|
||||||
this._timepickerShowing = false; // True if the popup picker is showing , false if not
|
|
||||||
this._inDialog = false; // True if showing within a "dialog", false if not
|
|
||||||
this._dialogClass = 'ui-timepicker-dialog'; // The name of the dialog marker class
|
|
||||||
this._mainDivId = 'ui-timepicker-div'; // The ID of the main timepicker division
|
|
||||||
this._inlineClass = 'ui-timepicker-inline'; // The name of the inline marker class
|
|
||||||
this._currentClass = 'ui-timepicker-current'; // The name of the current hour / minutes marker class
|
|
||||||
this._dayOverClass = 'ui-timepicker-days-cell-over'; // The name of the day hover marker class
|
|
||||||
|
|
||||||
this.regional = []; // Available regional settings, indexed by language code
|
|
||||||
this.regional[''] = { // Default regional settings
|
|
||||||
hourText: 'Hour', // Display text for hours section
|
|
||||||
minuteText: 'Minute', // Display text for minutes link
|
|
||||||
amPmText: ['AM', 'PM'] // Display text for AM PM
|
|
||||||
};
|
|
||||||
this._defaults = { // Global defaults for all the time picker instances
|
|
||||||
showOn: 'focus', // 'focus' for popup on focus,
|
|
||||||
// 'button' for trigger button, or 'both' for either (not yet implemented)
|
|
||||||
showAnim: 'fadeIn', // Name of jQuery animation for popup
|
|
||||||
showOptions: {}, // Options for enhanced animations
|
|
||||||
appendText: '', // Display text following the input box, e.g. showing the format
|
|
||||||
onSelect: null, // Define a callback function when a hour / minutes is selected
|
|
||||||
onClose: null, // Define a callback function when the timepicker is closed
|
|
||||||
timeSeparator: ':', // The caracter to use to separate hours and minutes.
|
|
||||||
showPeriod: false, // Define whether or not to show AM/PM with selected time
|
|
||||||
showLeadingZero: true, // Define whether or not to show a leading zero for hours < 10. [true/false]
|
|
||||||
showMinutesLeadingZero: true, // Define whether or not to show a leading zero for minutes < 10.
|
|
||||||
altField: '', // Selector for an alternate field to store selected time into
|
|
||||||
defaultTime: '' // Used as default time when input field is empty or for inline timePicker
|
|
||||||
};
|
|
||||||
$.extend(this._defaults, this.regional['']);
|
|
||||||
|
|
||||||
this.tpDiv = $('<div id="' + this._mainDivId + '" class="ui-timepicker ui-widget ui-helper-clearfix ui-corner-all " style="display: none"></div>');
|
|
||||||
}
|
|
||||||
|
|
||||||
$.extend(Timepicker.prototype, {
|
|
||||||
/* Class name added to elements to indicate already configured with a time picker. */
|
|
||||||
markerClassName: 'hasTimepicker',
|
|
||||||
|
|
||||||
/* Debug logging (if enabled). */
|
|
||||||
log: function () {
|
|
||||||
if (this.debug)
|
|
||||||
console.log.apply('', arguments);
|
|
||||||
},
|
|
||||||
|
|
||||||
// TODO rename to "widget" when switching to widget factory
|
|
||||||
_widgetTimepicker: function () {
|
|
||||||
return this.tpDiv;
|
|
||||||
},
|
|
||||||
|
|
||||||
/* 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;
|
|
||||||
},
|
|
||||||
|
|
||||||
/* Attach the time picker to a jQuery selection.
|
|
||||||
@param target element - the target input field or division or span
|
|
||||||
@param settings object - the new settings to use for this time picker instance (anonymous) */
|
|
||||||
_attachTimepicker: function (target, settings) {
|
|
||||||
// check for settings on the control itself - in namespace 'time:'
|
|
||||||
var inlineSettings = null;
|
|
||||||
for (var attrName in this._defaults) {
|
|
||||||
var attrValue = target.getAttribute('time:' + attrName);
|
|
||||||
if (attrValue) {
|
|
||||||
inlineSettings = inlineSettings || {};
|
|
||||||
try {
|
|
||||||
inlineSettings[attrName] = eval(attrValue);
|
|
||||||
} catch (err) {
|
|
||||||
inlineSettings[attrName] = attrValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var nodeName = target.nodeName.toLowerCase();
|
|
||||||
var inline = (nodeName == 'div' || nodeName == 'span');
|
|
||||||
|
|
||||||
if (!target.id) {
|
|
||||||
this.uuid += 1;
|
|
||||||
target.id = 'tp' + this.uuid;
|
|
||||||
}
|
|
||||||
var inst = this._newInst($(target), inline);
|
|
||||||
inst.settings = $.extend({}, settings || {}, inlineSettings || {});
|
|
||||||
if (nodeName == 'input') {
|
|
||||||
this._connectTimepicker(target, inst);
|
|
||||||
} else if (inline) {
|
|
||||||
this._inlineTimepicker(target, inst);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
/* Create a new instance object. */
|
|
||||||
_newInst: function (target, inline) {
|
|
||||||
var id = target[0].id.replace(/([^A-Za-z0-9_-])/g, '\\\\$1'); // escape jQuery meta chars
|
|
||||||
return { id: id, input: target, // associated target
|
|
||||||
selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection
|
|
||||||
drawMonth: 0, drawYear: 0, // month being drawn
|
|
||||||
inline: inline, // is timepicker inline or not :
|
|
||||||
tpDiv: (!inline ? this.tpDiv : // presentation div
|
|
||||||
$('<div class="' + this._inlineClass + ' ui-timepicker ui-widget ui-helper-clearfix"></div>'))
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
/* Attach the time picker to an input field. */
|
|
||||||
_connectTimepicker: function (target, inst) {
|
|
||||||
var input = $(target);
|
|
||||||
inst.append = $([]);
|
|
||||||
inst.trigger = $([]);
|
|
||||||
if (input.hasClass(this.markerClassName)) { return; }
|
|
||||||
this._attachments(input, inst);
|
|
||||||
input.addClass(this.markerClassName).
|
|
||||||
keydown(this._doKeyDown).
|
|
||||||
keyup(this._doKeyUp).
|
|
||||||
bind("setData.timepicker", function (event, key, value) {
|
|
||||||
inst.settings[key] = value;
|
|
||||||
}).
|
|
||||||
bind("getData.timepicker", function (event, key) {
|
|
||||||
return this._get(inst, key);
|
|
||||||
});
|
|
||||||
//this._autoSize(inst);
|
|
||||||
$.data(target, PROP_NAME, inst);
|
|
||||||
},
|
|
||||||
|
|
||||||
/* Handle keystrokes. */
|
|
||||||
_doKeyDown: function (event) {
|
|
||||||
var inst = $.timepicker._getInst(event.target);
|
|
||||||
var handled = true;
|
|
||||||
inst._keyEvent = true;
|
|
||||||
if ($.timepicker._timepickerShowing) {
|
|
||||||
switch (event.keyCode) {
|
|
||||||
case 9: $.timepicker._hideTimepicker();
|
|
||||||
handled = false;
|
|
||||||
break; // hide on tab out
|
|
||||||
case 27: $.timepicker._hideTimepicker();
|
|
||||||
break; // hide on escape
|
|
||||||
default: handled = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (event.keyCode == 36 && event.ctrlKey) { // display the time picker on ctrl+home
|
|
||||||
$.timepicker._showTimepicker(this);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
handled = false;
|
|
||||||
}
|
|
||||||
if (handled) {
|
|
||||||
event.preventDefault();
|
|
||||||
event.stopPropagation();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
/* Update selected time on keyUp */
|
|
||||||
/* Added verion 0.0.5 */
|
|
||||||
_doKeyUp: function (event) {
|
|
||||||
var inst = $.timepicker._getInst(event.target);
|
|
||||||
$.timepicker._setTimeFromField(inst);
|
|
||||||
$.timepicker._updateTimepicker(inst);
|
|
||||||
},
|
|
||||||
|
|
||||||
/* Make attachments based on settings. */
|
|
||||||
_attachments: function (input, inst) {
|
|
||||||
var appendText = this._get(inst, 'appendText');
|
|
||||||
var isRTL = this._get(inst, 'isRTL');
|
|
||||||
if (inst.append) { inst.append.remove(); }
|
|
||||||
if (appendText) {
|
|
||||||
inst.append = $('<span class="' + this._appendClass + '">' + appendText + '</span>');
|
|
||||||
input[isRTL ? 'before' : 'after'](inst.append);
|
|
||||||
}
|
|
||||||
input.unbind('focus', this._showTimepicker);
|
|
||||||
if (inst.trigger) { inst.trigger.remove(); }
|
|
||||||
var showOn = this._get(inst, 'showOn');
|
|
||||||
if (showOn == 'focus' || showOn == 'both') { // pop-up time picker when in the marked field
|
|
||||||
input.focus(this._showTimepicker);
|
|
||||||
}
|
|
||||||
if (showOn == 'button' || showOn == 'both') { // pop-up time picker when button clicked
|
|
||||||
var buttonText = this._get(inst, 'buttonText');
|
|
||||||
var buttonImage = this._get(inst, 'buttonImage');
|
|
||||||
inst.trigger = $(this._get(inst, 'buttonImageOnly') ?
|
|
||||||
$('<img/>').addClass(this._triggerClass).
|
|
||||||
attr({ src: buttonImage, alt: buttonText, title: buttonText }) :
|
|
||||||
$('<button type="button"></button>').addClass(this._triggerClass).
|
|
||||||
html(buttonImage == '' ? buttonText : $('<img/>').attr(
|
|
||||||
{ src: buttonImage, alt: buttonText, title: buttonText })));
|
|
||||||
input[isRTL ? 'before' : 'after'](inst.trigger);
|
|
||||||
inst.trigger.click(function () {
|
|
||||||
if ($.timepicker._timepickerShowing && $.timepicker._lastInput == input[0]) { $.timepicker._hideTimepicker(); }
|
|
||||||
else { $.timepicker._showTimepicker(input[0]); }
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
/* Attach an inline time picker to a div. */
|
|
||||||
_inlineTimepicker: function(target, inst) {
|
|
||||||
var divSpan = $(target);
|
|
||||||
if (divSpan.hasClass(this.markerClassName))
|
|
||||||
return;
|
|
||||||
divSpan.addClass(this.markerClassName).append(inst.tpDiv).
|
|
||||||
bind("setData.timepicker", function(event, key, value){
|
|
||||||
inst.settings[key] = value;
|
|
||||||
}).bind("getData.timepicker", function(event, key){
|
|
||||||
return this._get(inst, key);
|
|
||||||
});
|
|
||||||
$.data(target, PROP_NAME, inst);
|
|
||||||
this._setTimeFromField(inst);
|
|
||||||
this._updateTimepicker(inst);
|
|
||||||
inst.tpDiv.show();
|
|
||||||
},
|
|
||||||
|
|
||||||
/* Pop-up the time picker for a given input field.
|
|
||||||
@param input element - the input field attached to the time picker or
|
|
||||||
event - if triggered by focus */
|
|
||||||
_showTimepicker: function (input) {
|
|
||||||
input = input.target || input;
|
|
||||||
if (input.nodeName.toLowerCase() != 'input') { input = $('input', input.parentNode)[0]; } // find from button/image trigger
|
|
||||||
if ($.timepicker._isDisabledTimepicker(input) || $.timepicker._lastInput == input) { return; } // already here
|
|
||||||
|
|
||||||
var inst = $.timepicker._getInst(input);
|
|
||||||
if ($.timepicker._curInst && $.timepicker._curInst != inst) {
|
|
||||||
$.timepicker._curInst.tpDiv.stop(true, true);
|
|
||||||
}
|
|
||||||
var beforeShow = $.timepicker._get(inst, 'beforeShow');
|
|
||||||
extendRemove(inst.settings, (beforeShow ? beforeShow.apply(input, [input, inst]) : {}));
|
|
||||||
inst.lastVal = null;
|
|
||||||
$.timepicker._lastInput = input;
|
|
||||||
|
|
||||||
$.timepicker._setTimeFromField(inst);
|
|
||||||
if ($.timepicker._inDialog) { input.value = ''; } // hide cursor
|
|
||||||
if (!$.timepicker._pos) { // position below input
|
|
||||||
$.timepicker._pos = $.timepicker._findPos(input);
|
|
||||||
$.timepicker._pos[1] += input.offsetHeight; // add the height
|
|
||||||
}
|
|
||||||
var isFixed = false;
|
|
||||||
$(input).parents().each(function () {
|
|
||||||
isFixed |= $(this).css('position') == 'fixed';
|
|
||||||
return !isFixed;
|
|
||||||
});
|
|
||||||
if (isFixed && $.browser.opera) { // correction for Opera when fixed and scrolled
|
|
||||||
$.timepicker._pos[0] -= document.documentElement.scrollLeft;
|
|
||||||
$.timepicker._pos[1] -= document.documentElement.scrollTop;
|
|
||||||
}
|
|
||||||
var offset = { left: $.timepicker._pos[0], top: $.timepicker._pos[1] };
|
|
||||||
$.timepicker._pos = null;
|
|
||||||
// determine sizing offscreen
|
|
||||||
inst.tpDiv.css({ position: 'absolute', display: 'block', top: '-1000px' });
|
|
||||||
$.timepicker._updateTimepicker(inst);
|
|
||||||
|
|
||||||
// reset clicked state
|
|
||||||
inst._hoursClicked = false;
|
|
||||||
inst._minutesClicked = false;
|
|
||||||
|
|
||||||
// fix width for dynamic number of time pickers
|
|
||||||
// and adjust position before showing
|
|
||||||
offset = $.timepicker._checkOffset(inst, offset, isFixed);
|
|
||||||
inst.tpDiv.css({ position: ($.timepicker._inDialog && $.blockUI ?
|
|
||||||
'static' : (isFixed ? 'fixed' : 'absolute')), display: 'none',
|
|
||||||
left: offset.left + 'px', top: offset.top + 'px'
|
|
||||||
});
|
|
||||||
if (!inst.inline) {
|
|
||||||
var showAnim = $.timepicker._get(inst, 'showAnim');
|
|
||||||
var duration = $.timepicker._get(inst, 'duration');
|
|
||||||
var postProcess = function () {
|
|
||||||
$.timepicker._timepickerShowing = true;
|
|
||||||
var borders = $.timepicker._getBorders(inst.tpDiv);
|
|
||||||
inst.tpDiv.find('iframe.ui-timepicker-cover'). // IE6- only
|
|
||||||
css({ left: -borders[0], top: -borders[1],
|
|
||||||
width: inst.tpDiv.outerWidth(), height: inst.tpDiv.outerHeight()
|
|
||||||
});
|
|
||||||
};
|
|
||||||
inst.tpDiv.zIndex($(input).zIndex() + 1);
|
|
||||||
if ($.effects && $.effects[showAnim]) {
|
|
||||||
inst.tpDiv.show(showAnim, $.timepicker._get(inst, 'showOptions'), duration, postProcess);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
inst.tpDiv[showAnim || 'show']((showAnim ? duration : null), postProcess);
|
|
||||||
}
|
|
||||||
if (!showAnim || !duration) { postProcess(); }
|
|
||||||
if (inst.input.is(':visible') && !inst.input.is(':disabled')) { inst.input.focus(); }
|
|
||||||
$.timepicker._curInst = inst;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
/* Generate the time picker content. */
|
|
||||||
_updateTimepicker: function (inst) {
|
|
||||||
var self = this;
|
|
||||||
var borders = $.timepicker._getBorders(inst.tpDiv);
|
|
||||||
inst.tpDiv.empty().append(this._generateHTML(inst))
|
|
||||||
.find('iframe.ui-timepicker-cover') // IE6- only
|
|
||||||
.css({ left: -borders[0], top: -borders[1],
|
|
||||||
width: inst.tpDiv.outerWidth(), height: inst.tpDiv.outerHeight()
|
|
||||||
})
|
|
||||||
.end()
|
|
||||||
.find('.ui-timepicker td a')
|
|
||||||
.bind('mouseout', function () {
|
|
||||||
$(this).removeClass('ui-state-hover');
|
|
||||||
if (this.className.indexOf('ui-timepicker-prev') != -1) $(this).removeClass('ui-timepicker-prev-hover');
|
|
||||||
if (this.className.indexOf('ui-timepicker-next') != -1) $(this).removeClass('ui-timepicker-next-hover');
|
|
||||||
})
|
|
||||||
.bind('mouseover', function () {
|
|
||||||
if (!self._isDisabledTimepicker(inst.inline ? inst.tpDiv.parent()[0] : inst.input[0])) {
|
|
||||||
$(this).parents('.ui-timepicker-calendar').find('a').removeClass('ui-state-hover');
|
|
||||||
$(this).addClass('ui-state-hover');
|
|
||||||
if (this.className.indexOf('ui-timepicker-prev') != -1) $(this).addClass('ui-timepicker-prev-hover');
|
|
||||||
if (this.className.indexOf('ui-timepicker-next') != -1) $(this).addClass('ui-timepicker-next-hover');
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.end()
|
|
||||||
.find('.' + this._dayOverClass + ' a')
|
|
||||||
.trigger('mouseover')
|
|
||||||
.end();
|
|
||||||
},
|
|
||||||
|
|
||||||
/* Generate the HTML for the current state of the date picker. */
|
|
||||||
_generateHTML: function (inst) {
|
|
||||||
var h, m, html = '';
|
|
||||||
var showPeriod = (this._get(inst, 'showPeriod') == true);
|
|
||||||
var showLeadingZero = (this._get(inst, 'showLeadingZero') == true);
|
|
||||||
var showMinutesLeadingZero = (this._get(inst, 'showMinutesLeadingZero') == true);
|
|
||||||
var amPmText = this._get(inst, 'amPmText');
|
|
||||||
|
|
||||||
|
|
||||||
html = '<table class="ui-timepicker-table ui-widget-content ui-corner-all"><tr>' +
|
|
||||||
'<td class="ui-timepicker-hours">' +
|
|
||||||
'<div class="ui-timepicker-title ui-widget-header ui-helper-clearfix ui-corner-all">' +
|
|
||||||
this._get(inst, 'hourText') +
|
|
||||||
'</div>' +
|
|
||||||
'<table class="ui-timepicker">';
|
|
||||||
|
|
||||||
// AM
|
|
||||||
html += '<tr><th rowspan="2" class="periods">' + amPmText[0] + '</th>';
|
|
||||||
for (h = 0; h <= 5; h++) {
|
|
||||||
html += this._generateHTMLHourCell(inst, h, showPeriod, showLeadingZero);
|
|
||||||
}
|
|
||||||
|
|
||||||
html += '</tr><tr>';
|
|
||||||
for (h = 6; h <= 11; h++) {
|
|
||||||
html += this._generateHTMLHourCell(inst, h, showPeriod, showLeadingZero);
|
|
||||||
}
|
|
||||||
|
|
||||||
// PM
|
|
||||||
html += '</tr><tr><th rowspan="2" class="periods">' + amPmText[1] + '</th>';
|
|
||||||
for (h = 12; h <= 17; h++) {
|
|
||||||
html += this._generateHTMLHourCell(inst, h, showPeriod, showLeadingZero);
|
|
||||||
}
|
|
||||||
|
|
||||||
html += '</tr><tr>';
|
|
||||||
for (h = 18; h <= 23; h++) {
|
|
||||||
html += this._generateHTMLHourCell(inst, h, showPeriod, showLeadingZero);
|
|
||||||
}
|
|
||||||
html += '</tr></table>' + // Close the hours cells table
|
|
||||||
'</td>' + // Close the Hour td
|
|
||||||
'<td class="ui-timepicker-minutes">' + // open minutes td
|
|
||||||
/* Add the minutes */
|
|
||||||
'<div class="ui-timepicker-title ui-widget-header ui-helper-clearfix ui-corner-all">' +
|
|
||||||
this._get(inst, 'minuteText') +
|
|
||||||
'</div>' +
|
|
||||||
'<table class="ui-timepicker">' +
|
|
||||||
'<tr>';
|
|
||||||
for (m = 0; m < 15; m += 5) {
|
|
||||||
html += this._generateHTMLMinuteCell(inst, m, (m < 10) && showMinutesLeadingZero ? "0" + m.toString() : m.toString());
|
|
||||||
}
|
|
||||||
html += '</tr><tr>';
|
|
||||||
for (m = 15; m < 30; m += 5) {
|
|
||||||
html += this._generateHTMLMinuteCell(inst, m, m.toString());
|
|
||||||
}
|
|
||||||
html += '</tr><tr>';
|
|
||||||
for (m = 30; m < 45; m += 5) {
|
|
||||||
html += this._generateHTMLMinuteCell(inst, m, m.toString());
|
|
||||||
}
|
|
||||||
html += '</tr><tr>';
|
|
||||||
for (m = 45; m < 60; m += 5) {
|
|
||||||
html += this._generateHTMLMinuteCell(inst, m, m.toString());
|
|
||||||
}
|
|
||||||
html += '</tr></table>' +
|
|
||||||
'</td></tr></table>';
|
|
||||||
return html;
|
|
||||||
},
|
|
||||||
|
|
||||||
/* Generate the content of a "Hour" cell */
|
|
||||||
_generateHTMLHourCell: function (inst, hour, showPeriod, showLeadingZero) {
|
|
||||||
|
|
||||||
var displayHour = hour;
|
|
||||||
if ((hour > 12) && showPeriod) {
|
|
||||||
displayHour = hour - 12;
|
|
||||||
}
|
|
||||||
if ((displayHour == 0) && showPeriod) {
|
|
||||||
displayHour = 12;
|
|
||||||
}
|
|
||||||
if ((displayHour < 10) && showLeadingZero) {
|
|
||||||
displayHour = '0' + displayHour;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
var html = '<td ' +
|
|
||||||
'onclick="TP_jQuery_' + tpuuid + '.timepicker.selectHours(\'#' + inst.id + '\', ' + hour.toString() + ', this ); return false;" ' +
|
|
||||||
'ondblclick="TP_jQuery_' + tpuuid + '.timepicker.selectHours(\'#' + inst.id + '\', ' + hour.toString() + ', this, true ); return false;" ' +
|
|
||||||
'>' +
|
|
||||||
'<a href="#" class="ui-state-default ' +
|
|
||||||
(hour == inst.hours ? 'ui-state-active' : '') +
|
|
||||||
'">' +
|
|
||||||
displayHour.toString() +
|
|
||||||
'</a></td>';
|
|
||||||
return html;
|
|
||||||
},
|
|
||||||
/* Generate the content of a "Hour" cell */
|
|
||||||
_generateHTMLMinuteCell: function (inst, minute, displayText) {
|
|
||||||
var html = '<td ' +
|
|
||||||
'onclick="TP_jQuery_' + tpuuid + '.timepicker.selectMinutes(\'#' + inst.id + '\', ' + minute.toString() + ', this ); return false;" ' +
|
|
||||||
'ondblclick="TP_jQuery_' + tpuuid + '.timepicker.selectMinutes(\'#' + inst.id + '\', ' + minute.toString() + ', this, true ); return false;" ' +
|
|
||||||
'>' +
|
|
||||||
'<a href="#" class="ui-state-default ' +
|
|
||||||
(minute == inst.minutes ? 'ui-state-active' : '') +
|
|
||||||
'" >' +
|
|
||||||
displayText +
|
|
||||||
'</a></td>';
|
|
||||||
return html;
|
|
||||||
},
|
|
||||||
|
|
||||||
/* Is the first field in a jQuery collection disabled as a timepicker?
|
|
||||||
@param target element - the target input field or division or span
|
|
||||||
@return boolean - true if disabled, false if enabled */
|
|
||||||
_isDisabledTimepicker: function (target) {
|
|
||||||
if (!target) { return false; }
|
|
||||||
for (var i = 0; i < this._disabledInputs.length; i++) {
|
|
||||||
if (this._disabledInputs[i] == target) { return true; }
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
|
|
||||||
/* Check positioning to remain on screen. */
|
|
||||||
_checkOffset: function (inst, offset, isFixed) {
|
|
||||||
var tpWidth = inst.tpDiv.outerWidth();
|
|
||||||
var tpHeight = inst.tpDiv.outerHeight();
|
|
||||||
var inputWidth = inst.input ? inst.input.outerWidth() : 0;
|
|
||||||
var inputHeight = inst.input ? inst.input.outerHeight() : 0;
|
|
||||||
var viewWidth = document.documentElement.clientWidth + $(document).scrollLeft();
|
|
||||||
var viewHeight = document.documentElement.clientHeight + $(document).scrollTop();
|
|
||||||
|
|
||||||
offset.left -= (this._get(inst, 'isRTL') ? (tpWidth - inputWidth) : 0);
|
|
||||||
offset.left -= (isFixed && offset.left == inst.input.offset().left) ? $(document).scrollLeft() : 0;
|
|
||||||
offset.top -= (isFixed && offset.top == (inst.input.offset().top + inputHeight)) ? $(document).scrollTop() : 0;
|
|
||||||
|
|
||||||
// now check if datepicker is showing outside window viewport - move to a better place if so.
|
|
||||||
offset.left -= Math.min(offset.left, (offset.left + tpWidth > viewWidth && viewWidth > tpWidth) ?
|
|
||||||
Math.abs(offset.left + tpWidth - viewWidth) : 0);
|
|
||||||
offset.top -= Math.min(offset.top, (offset.top + tpHeight > viewHeight && viewHeight > tpHeight) ?
|
|
||||||
Math.abs(tpHeight + inputHeight) : 0);
|
|
||||||
|
|
||||||
return offset;
|
|
||||||
},
|
|
||||||
|
|
||||||
/* Find an object's position on the screen. */
|
|
||||||
_findPos: function (obj) {
|
|
||||||
var inst = this._getInst(obj);
|
|
||||||
var isRTL = this._get(inst, 'isRTL');
|
|
||||||
while (obj && (obj.type == 'hidden' || obj.nodeType != 1)) {
|
|
||||||
obj = obj[isRTL ? 'previousSibling' : 'nextSibling'];
|
|
||||||
}
|
|
||||||
var position = $(obj).offset();
|
|
||||||
return [position.left, position.top];
|
|
||||||
},
|
|
||||||
|
|
||||||
/* Retrieve the size of left and top borders for an element.
|
|
||||||
@param elem (jQuery object) the element of interest
|
|
||||||
@return (number[2]) the left and top borders */
|
|
||||||
_getBorders: function (elem) {
|
|
||||||
var convert = function (value) {
|
|
||||||
return { thin: 1, medium: 2, thick: 3}[value] || value;
|
|
||||||
};
|
|
||||||
return [parseFloat(convert(elem.css('border-left-width'))),
|
|
||||||
parseFloat(convert(elem.css('border-top-width')))];
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
/* Close time picker if clicked elsewhere. */
|
|
||||||
_checkExternalClick: function (event) {
|
|
||||||
if (!$.timepicker._curInst) { return; }
|
|
||||||
var $target = $(event.target);
|
|
||||||
if ($target[0].id != $.timepicker._mainDivId &&
|
|
||||||
$target.parents('#' + $.timepicker._mainDivId).length == 0 &&
|
|
||||||
!$target.hasClass($.timepicker.markerClassName) &&
|
|
||||||
!$target.hasClass($.timepicker._triggerClass) &&
|
|
||||||
$.timepicker._timepickerShowing && !($.timepicker._inDialog && $.blockUI))
|
|
||||||
$.timepicker._hideTimepicker();
|
|
||||||
},
|
|
||||||
|
|
||||||
/* Hide the time picker from view.
|
|
||||||
@param input element - the input field attached to the time picker */
|
|
||||||
_hideTimepicker: function (input) {
|
|
||||||
var inst = this._curInst;
|
|
||||||
if (!inst || (input && inst != $.data(input, PROP_NAME))) { return; }
|
|
||||||
if (this._timepickerShowing) {
|
|
||||||
var showAnim = this._get(inst, 'showAnim');
|
|
||||||
var duration = this._get(inst, 'duration');
|
|
||||||
var postProcess = function () {
|
|
||||||
$.timepicker._tidyDialog(inst);
|
|
||||||
this._curInst = null;
|
|
||||||
};
|
|
||||||
if ($.effects && $.effects[showAnim]) {
|
|
||||||
inst.tpDiv.hide(showAnim, $.timepicker._get(inst, 'showOptions'), duration, postProcess);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
inst.tpDiv[(showAnim == 'slideDown' ? 'slideUp' :
|
|
||||||
(showAnim == 'fadeIn' ? 'fadeOut' : 'hide'))]((showAnim ? duration : null), postProcess);
|
|
||||||
}
|
|
||||||
if (!showAnim) { postProcess(); }
|
|
||||||
var onClose = this._get(inst, 'onClose');
|
|
||||||
if (onClose) {
|
|
||||||
onClose.apply(
|
|
||||||
(inst.input ? inst.input[0] : null),
|
|
||||||
[(inst.input ? inst.input.val() : ''), inst]); // trigger custom callback
|
|
||||||
}
|
|
||||||
this._timepickerShowing = false;
|
|
||||||
this._lastInput = null;
|
|
||||||
if (this._inDialog) {
|
|
||||||
this._dialogInput.css({ position: 'absolute', left: '0', top: '-100px' });
|
|
||||||
if ($.blockUI) {
|
|
||||||
$.unblockUI();
|
|
||||||
$('body').append(this.tpDiv);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this._inDialog = false;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
/* Tidy up after a dialog display. */
|
|
||||||
_tidyDialog: function (inst) {
|
|
||||||
inst.tpDiv.removeClass(this._dialogClass).unbind('.ui-timepicker');
|
|
||||||
},
|
|
||||||
|
|
||||||
/* Retrieve the instance data for the target control.
|
|
||||||
@param target element - the target input field or division or span
|
|
||||||
@return object - the associated instance data
|
|
||||||
@throws error if a jQuery problem getting data */
|
|
||||||
_getInst: function (target) {
|
|
||||||
try {
|
|
||||||
return $.data(target, PROP_NAME);
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
throw 'Missing instance data for this timepicker';
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
/* Get a setting value, defaulting if necessary. */
|
|
||||||
_get: function (inst, name) {
|
|
||||||
return inst.settings[name] !== undefined ?
|
|
||||||
inst.settings[name] : this._defaults[name];
|
|
||||||
},
|
|
||||||
|
|
||||||
/* Parse existing time and initialise time picker. */
|
|
||||||
_setTimeFromField: function (inst) {
|
|
||||||
if (inst.input.val() == inst.lastVal) { return; }
|
|
||||||
var defaultTime = this._get(inst, 'defaultTime');
|
|
||||||
|
|
||||||
|
|
||||||
var timeToParse = this._getCurrentTimeRounded(inst);
|
|
||||||
if (defaultTime != '') { timeToParse = defaultTime }
|
|
||||||
if ((inst.inline == false) && (inst.input.val() != '')) { timeToParse = inst.input.val() }
|
|
||||||
|
|
||||||
//var timeVal = inst.lastVal = inst.inline == false ? inst.input.val() :
|
|
||||||
// defaultTime ? defaultTime :
|
|
||||||
// getHours(new Date()) + timeSeparator + getMinutes(new Date());
|
|
||||||
var timeVal = inst.lastVal = timeToParse;
|
|
||||||
//alert ('inst.input ' + inst.input.attr('id'));
|
|
||||||
var time = this.parseTime(inst, timeVal);
|
|
||||||
inst.hours = time.hours;
|
|
||||||
inst.minutes = time.minutes;
|
|
||||||
},
|
|
||||||
|
|
||||||
/* Return the current time, ready to be parsed, rounded to the closest 5 minute */
|
|
||||||
_getCurrentTimeRounded: function (inst) {
|
|
||||||
var currentTime = new Date();
|
|
||||||
var timeSeparator = this._get(inst, 'timeSeparator');
|
|
||||||
// setting selected time , least priority first
|
|
||||||
var currentMinutes = currentTime.getMinutes()
|
|
||||||
// round to closest 5
|
|
||||||
currentMinutes = Math.round( currentMinutes / 5 ) * 5;
|
|
||||||
|
|
||||||
return currentTime.getHours().toString() + timeSeparator + currentMinutes.toString();
|
|
||||||
},
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Pase a time string into hours and minutes
|
|
||||||
*/
|
|
||||||
parseTime: function (inst, timeVal) {
|
|
||||||
var retVal = new Object();
|
|
||||||
retVal.hours = -1;
|
|
||||||
retVal.minutes = -1;
|
|
||||||
|
|
||||||
var timeSeparator = this._get(inst, 'timeSeparator');
|
|
||||||
var amPmText = this._get(inst, 'amPmText');
|
|
||||||
var p = timeVal.indexOf(timeSeparator);
|
|
||||||
if (p == -1) { return retVal; }
|
|
||||||
|
|
||||||
retVal.hours = parseInt(timeVal.substr(0, p), 10);
|
|
||||||
retVal.minutes = parseInt(timeVal.substr(p + 1), 10);
|
|
||||||
|
|
||||||
var showPeriod = (this._get(inst, 'showPeriod') == true);
|
|
||||||
var timeValUpper = timeVal.toUpperCase();
|
|
||||||
if ((retVal.hours < 12) && (showPeriod) && (timeValUpper.indexOf(amPmText[1].toUpperCase()) != -1)) {
|
|
||||||
retVal.hours += 12;
|
|
||||||
}
|
|
||||||
// fix for 12 AM
|
|
||||||
if ((retVal.hours == 12) && (showPeriod) && (timeValUpper.indexOf(amPmText[0].toUpperCase()) != -1)) {
|
|
||||||
retVal.hours = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return retVal;
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
selectHours: function (id, newHours, td, fromDoubleClick) {
|
|
||||||
var target = $(id);
|
|
||||||
var inst = this._getInst(target[0]);
|
|
||||||
$(td).parents('.ui-timepicker-hours:first').find('a').removeClass('ui-state-active');
|
|
||||||
//inst.tpDiv.children('.ui-timepicker-hours a').removeClass('ui-state-active');
|
|
||||||
$(td).children('a').addClass('ui-state-active');
|
|
||||||
|
|
||||||
inst.hours = newHours;
|
|
||||||
this._updateSelectedValue(inst);
|
|
||||||
|
|
||||||
inst._hoursClicked = true;
|
|
||||||
if ((inst._minutesClicked) || (fromDoubleClick)) { $.timepicker._hideTimepicker(); }
|
|
||||||
},
|
|
||||||
|
|
||||||
selectMinutes: function (id, newMinutes, td, fromDoubleClick) {
|
|
||||||
var target = $(id);
|
|
||||||
var inst = this._getInst(target[0]);
|
|
||||||
$(td).parents('.ui-timepicker-minutes:first').find('a').removeClass('ui-state-active');
|
|
||||||
$(td).children('a').addClass('ui-state-active');
|
|
||||||
|
|
||||||
inst.minutes = newMinutes;
|
|
||||||
this._updateSelectedValue(inst);
|
|
||||||
|
|
||||||
inst._minutesClicked = true;
|
|
||||||
if ((inst._hoursClicked) || (fromDoubleClick)) { $.timepicker._hideTimepicker(); }
|
|
||||||
},
|
|
||||||
|
|
||||||
_updateSelectedValue: function (inst) {
|
|
||||||
if ((inst.hours < 0) || (inst.hours > 23)) { inst.hours = 12; }
|
|
||||||
if ((inst.minutes < 0) || (inst.minutes > 59)) { inst.minutes = 0; }
|
|
||||||
|
|
||||||
var period = "";
|
|
||||||
var showPeriod = (this._get(inst, 'showPeriod') == true);
|
|
||||||
var showLeadingZero = (this._get(inst, 'showLeadingZero') == true);
|
|
||||||
var amPmText = this._get(inst, 'amPmText');
|
|
||||||
var selectedHours = inst.hours ? inst.hours : 0;
|
|
||||||
var selectedMinutes = inst.minutes ? inst.minutes : 0;
|
|
||||||
|
|
||||||
var displayHours = selectedHours;
|
|
||||||
if ( ! displayHours) {
|
|
||||||
displayHoyrs = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (showPeriod) {
|
|
||||||
if (inst.hours == 0) {
|
|
||||||
displayHours = 12;
|
|
||||||
}
|
|
||||||
if (inst.hours < 12) {
|
|
||||||
period = amPmText[0];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
period = amPmText[1];
|
|
||||||
if (displayHours > 12) {
|
|
||||||
displayHours -= 12;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var h = displayHours.toString();
|
|
||||||
if (showLeadingZero && (displayHours < 10)) { h = '0' + h; }
|
|
||||||
|
|
||||||
|
|
||||||
var m = selectedMinutes.toString();
|
|
||||||
if (selectedMinutes < 10) { m = '0' + m; }
|
|
||||||
|
|
||||||
var newTime = h + this._get(inst, 'timeSeparator') + m;
|
|
||||||
if (period.length > 0) { newTime += " " + period; }
|
|
||||||
|
|
||||||
if (inst.input) {
|
|
||||||
inst.input.val(newTime);
|
|
||||||
inst.input.trigger('change');
|
|
||||||
}
|
|
||||||
|
|
||||||
var onSelect = this._get(inst, 'onSelect');
|
|
||||||
if (onSelect) { onSelect.apply((inst.input ? inst.input[0] : null), [newTime, inst]); } // trigger custom callback
|
|
||||||
|
|
||||||
this._updateAlternate(inst, newTime);
|
|
||||||
|
|
||||||
return newTime;
|
|
||||||
},
|
|
||||||
|
|
||||||
/* Update any alternate field to synchronise with the main field. */
|
|
||||||
_updateAlternate: function(inst, newTime) {
|
|
||||||
var altField = this._get(inst, 'altField');
|
|
||||||
if (altField) { // update alternate field too
|
|
||||||
$(altField).each(function() { $(this).val(newTime); });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Invoke the timepicker functionality.
|
|
||||||
@param options string - a command, optionally followed by additional parameters or
|
|
||||||
Object - settings for attaching new datepicker functionality
|
|
||||||
@return jQuery object */
|
|
||||||
$.fn.timepicker = function (options) {
|
|
||||||
|
|
||||||
/* Initialise the date picker. */
|
|
||||||
if (!$.timepicker.initialized) {
|
|
||||||
$(document).mousedown($.timepicker._checkExternalClick).
|
|
||||||
find('body').append($.timepicker.tpDiv);
|
|
||||||
$.timepicker.initialized = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
var otherArgs = Array.prototype.slice.call(arguments, 1);
|
|
||||||
if (typeof options == 'string' && (options == 'isDisabled' || options == 'getDate' || options == 'widget'))
|
|
||||||
return $.timepicker['_' + options + 'Datepicker'].
|
|
||||||
apply($.timepicker, [this[0]].concat(otherArgs));
|
|
||||||
if (options == 'option' && arguments.length == 2 && typeof arguments[1] == 'string')
|
|
||||||
return $.timepicker['_' + options + 'Datepicker'].
|
|
||||||
apply($.timepicker, [this[0]].concat(otherArgs));
|
|
||||||
return this.each(function () {
|
|
||||||
typeof options == 'string' ?
|
|
||||||
$.timepicker['_' + options + 'Datepicker'].
|
|
||||||
apply($.timepicker, [this].concat(otherArgs)) :
|
|
||||||
$.timepicker._attachTimepicker(this, options);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
/* jQuery extend now ignores nulls! */
|
|
||||||
function extendRemove(target, props) {
|
|
||||||
$.extend(target, props);
|
|
||||||
for (var name in props)
|
|
||||||
if (props[name] == null || props[name] == undefined)
|
|
||||||
target[name] = props[name];
|
|
||||||
return target;
|
|
||||||
};
|
|
||||||
|
|
||||||
$.timepicker = new Timepicker(); // singleton instance
|
|
||||||
$.timepicker.initialized = false;
|
|
||||||
$.timepicker.uuid = new Date().getTime();
|
|
||||||
$.timepicker.version = "1.8.6";
|
|
||||||
|
|
||||||
// Workaround for #4055
|
|
||||||
// Add another global to avoid noConflict issues with inline event handlers
|
|
||||||
window['TP_jQuery_' + tpuuid] = $;
|
|
||||||
|
|
||||||
})(jQuery);
|
|
||||||
|
|
||||||
/*
|
|
||||||
____
|
|
||||||
___ .-~. /_"-._
|
|
||||||
`-._~-. / /_ "~o\ :Y
|
|
||||||
\ \ / : \~x. ` ')
|
|
||||||
] Y / | Y< ~-.__j
|
|
||||||
/ ! _.--~T : l l< /.-~
|
|
||||||
/ / ____.--~ . ` l /~\ \<|Y
|
|
||||||
/ / .-~~" /| . ',-~\ \L|
|
|
||||||
/ / / .^ \ Y~Y \.^>/l_ "--'
|
|
||||||
/ Y .-"( . l__ j_j l_/ /~_.-~ .
|
|
||||||
Y l / \ ) ~~~." / `/"~ / \.__/l_
|
|
||||||
| \ _.-" ~-{__ l : l._Z~-.___.--~
|
|
||||||
| ~---~ / ~~"---\_ ' __[>
|
|
||||||
l . _.^ ___ _>-y~
|
|
||||||
\ \ . .-~ .-~ ~>--" /
|
|
||||||
\ ~---" / ./ _.-'
|
|
||||||
"-.,_____.,_ _.--~\ _.-~
|
|
||||||
~~ ( _} -Row
|
|
||||||
`. ~(
|
|
||||||
) \
|
|
||||||
/,`--'~\--'~\
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
->T-Rex<-
|
|
||||||
*/
|
|
1345
airtime_mvc/public/js/timepicker/jquery.ui.timepicker.js
vendored
Normal file
1345
airtime_mvc/public/js/timepicker/jquery.ui.timepicker.js
vendored
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue