From 2d4bddcbf7b816f86db6f308a4d11bc9787c1f99 Mon Sep 17 00:00:00 2001 From: Tristan Zur Date: Sat, 28 Apr 2012 13:42:41 +0200 Subject: =?UTF-8?q?-=20Veranstaltungen=20CRUD=20Basisimplementierung=20-?= =?UTF-8?q?=20Extension=20"CJuiDateTimePicker"=20hinzugef=C3=BCgt=20-=20Mo?= =?UTF-8?q?dul=20"AuditTrail"=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 8 + protected/components/Html.php | 2 - protected/config/console.php | 8 +- protected/config/maincfg.php | 14 +- protected/controllers/VeranstaltungController.php | 167 ++++ protected/data/testdrive.db | Bin 0 -> 14336 bytes .../CJuiDateTimePicker/CJuiDateTimePicker.php | 62 ++ .../assets/jquery-ui-timepicker-addon.css | 5 + .../assets/jquery-ui-timepicker-addon.js | 981 +++++++++++++++++++++ protected/models/Angebot.php | 6 + protected/models/AngebotVerein.php | 6 + protected/models/Kategorie.php | 6 + protected/models/Standort.php | 6 + protected/models/Veranstaltung.php | 118 +++ protected/models/Verein.php | 6 + protected/modules/auditTrail/.DS_Store | Bin 0 -> 12292 bytes protected/modules/auditTrail/AuditTrailModule.php | 74 ++ protected/modules/auditTrail/README.txt | 19 + .../auditTrail/behaviors/LoggableBehavior.php | 133 +++ .../auditTrail/controllers/AdminController.php | 19 + .../auditTrail/controllers/DefaultController.php | 9 + .../m110517_155003_create_tables_audit_trail.php | 66 ++ protected/modules/auditTrail/models/.DS_Store | Bin 0 -> 6148 bytes protected/modules/auditTrail/models/AuditTrail.php | 125 +++ protected/modules/auditTrail/views/.DS_Store | Bin 0 -> 6148 bytes .../modules/auditTrail/views/admin/_search.php | 59 ++ protected/modules/auditTrail/views/admin/admin.php | 58 ++ .../modules/auditTrail/views/default/.DS_Store | Bin 0 -> 6148 bytes .../modules/auditTrail/views/default/index.php | 95 ++ protected/modules/auditTrail/widgets/.DS_Store | Bin 0 -> 6148 bytes .../modules/auditTrail/widgets/portlets/.DS_Store | Bin 0 -> 6148 bytes .../auditTrail/widgets/portlets/ShowAuditTrail.php | 157 ++++ protected/runtime/application.log | 226 +++++ protected/tests/functional/SiteTest.php | 6 +- protected/views/veranstaltung/_form.php | 98 ++ protected/views/veranstaltung/_search.php | 54 ++ protected/views/veranstaltung/_view.php | 38 + protected/views/veranstaltung/create.php | 16 + protected/views/veranstaltung/index.php | 35 + protected/views/veranstaltung/update.php | 18 + protected/views/veranstaltung/view.php | 28 + 41 files changed, 2715 insertions(+), 13 deletions(-) create mode 100644 .gitignore create mode 100644 protected/controllers/VeranstaltungController.php create mode 100644 protected/data/testdrive.db create mode 100644 protected/extensions/CJuiDateTimePicker/CJuiDateTimePicker.php create mode 100644 protected/extensions/CJuiDateTimePicker/assets/jquery-ui-timepicker-addon.css create mode 100644 protected/extensions/CJuiDateTimePicker/assets/jquery-ui-timepicker-addon.js create mode 100644 protected/models/Veranstaltung.php create mode 100644 protected/modules/auditTrail/.DS_Store create mode 100644 protected/modules/auditTrail/AuditTrailModule.php create mode 100644 protected/modules/auditTrail/README.txt create mode 100644 protected/modules/auditTrail/behaviors/LoggableBehavior.php create mode 100644 protected/modules/auditTrail/controllers/AdminController.php create mode 100644 protected/modules/auditTrail/controllers/DefaultController.php create mode 100644 protected/modules/auditTrail/migrations/m110517_155003_create_tables_audit_trail.php create mode 100644 protected/modules/auditTrail/models/.DS_Store create mode 100644 protected/modules/auditTrail/models/AuditTrail.php create mode 100644 protected/modules/auditTrail/views/.DS_Store create mode 100644 protected/modules/auditTrail/views/admin/_search.php create mode 100644 protected/modules/auditTrail/views/admin/admin.php create mode 100644 protected/modules/auditTrail/views/default/.DS_Store create mode 100644 protected/modules/auditTrail/views/default/index.php create mode 100644 protected/modules/auditTrail/widgets/.DS_Store create mode 100644 protected/modules/auditTrail/widgets/portlets/.DS_Store create mode 100644 protected/modules/auditTrail/widgets/portlets/ShowAuditTrail.php create mode 100644 protected/views/veranstaltung/_form.php create mode 100644 protected/views/veranstaltung/_search.php create mode 100644 protected/views/veranstaltung/_view.php create mode 100644 protected/views/veranstaltung/create.php create mode 100644 protected/views/veranstaltung/index.php create mode 100644 protected/views/veranstaltung/update.php create mode 100644 protected/views/veranstaltung/view.php diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fddbf02 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ + +/assets/17a1de59 +/assets/3940d2b +/assets/505bb103 +/assets/b6d35603 +/assets/e5f37766 +/assets/e7e1ddad +/assets/fc6ef99b \ No newline at end of file diff --git a/protected/components/Html.php b/protected/components/Html.php index 08fc6d9..6c7df3c 100644 --- a/protected/components/Html.php +++ b/protected/components/Html.php @@ -34,7 +34,5 @@ class Html extends CHtml { public static function enumDropDownList($model, $attribute, $htmlOptions = array()) { return CHtml::activeDropDownList($model, $attribute, Html::enumItem($model, $attribute), $htmlOptions); } - - } ?> \ No newline at end of file diff --git a/protected/config/console.php b/protected/config/console.php index 15c9353..2df2b24 100644 --- a/protected/config/console.php +++ b/protected/config/console.php @@ -7,18 +7,16 @@ return array( 'name'=>'My Console Application', // application components 'components'=>array( - 'db'=>array( + /*'db'=>array( 'connectionString' => 'sqlite:'.dirname(__FILE__).'/../data/testdrive.db', - ), + ),*/ // uncomment the following to use a MySQL database - /* 'db'=>array( - 'connectionString' => 'mysql:host=localhost;dbname=testdrive', + 'connectionString' => 'mysql:host=localhost;dbname=astaf', 'emulatePrepare' => true, 'username' => 'root', 'password' => '', 'charset' => 'utf8', ), - */ ), ); \ No newline at end of file diff --git a/protected/config/maincfg.php b/protected/config/maincfg.php index 78c3c6a..c1443ba 100644 --- a/protected/config/maincfg.php +++ b/protected/config/maincfg.php @@ -16,7 +16,8 @@ return array( 'import'=>array( 'application.models.*', 'application.components.*', - 'application.extensions.egmap.*' + 'application.extensions.egmap.*', + 'application.modules.auditTrail.models.AuditTrail', ), 'modules'=>array( @@ -27,6 +28,11 @@ return array( // If removed, Gii defaults to localhost only. Edit carefully to taste. 'ipFilters'=>array('127.0.0.1','::1'), ), + 'auditTrail'=>array( + 'userClass' => 'User', // the class name for the user object + 'userIdColumn' => 'id', // the column name of the primary key for the user + 'userNameColumn' => 'username', // the column name of the primary key for the user + ), ), // application components @@ -86,6 +92,10 @@ return array( 'pos_lat'=>48.8323934983, 'pos_long'=>9.31750059128, 'map_api_key'=>'ABQIAAAAzwMJRVnIOel5nqTjdUcPrRTSNOUR83EeIVShY4aBvXxHJx0DexSUFNGH3KQhtFhfSNHxkECqL5rQBA', - 'map_api_domain'=>'www.astaf.de' + 'map_api_domain'=>'www.astaf.de', + 'start_date'=>'01.07.2012', + 'end_date'=>'03.07.2012', + 'start_time'=>'19:00', + 'end_time'=>'23:00', ), ); \ No newline at end of file diff --git a/protected/controllers/VeranstaltungController.php b/protected/controllers/VeranstaltungController.php new file mode 100644 index 0000000..d4471b7 --- /dev/null +++ b/protected/controllers/VeranstaltungController.php @@ -0,0 +1,167 @@ +array('create','update','index','view','delete'), + 'users'=>array('admin'), + ), + array('deny', // deny all users + 'users'=>array('*'), + ), + ); + } + + /** + * Displays a particular model. + * @param integer $id the ID of the model to be displayed + */ + public function actionView($id) + { + $this->render('view',array( + 'model'=>$this->loadModel($id), + )); + } + + /** + * Creates a new model. + * If creation is successful, the browser will be redirected to the 'view' page. + */ + public function actionCreate() + { + $model=new Veranstaltung; + + // Uncomment the following line if AJAX validation is needed + // $this->performAjaxValidation($model); + + if(isset($_POST['Veranstaltung'])) + { + $model->attributes=$_POST['Veranstaltung']; + if($model->save()) + $this->redirect(array('view','id'=>$model->id)); + } + + $standorte = Standort::model()->findAll(array("condition"=>"published=1 and type='Bühne'")); + $vereine = Verein::model()->findAll(array("condition"=>"published=1")); + + $this->render('create',array( + 'model'=>$model, + 'vereine'=>$vereine, + 'standorte'=>$standorte + )); + } + + /** + * Updates a particular model. + * If update is successful, the browser will be redirected to the 'view' page. + * @param integer $id the ID of the model to be updated + */ + public function actionUpdate($id) + { + $model=$this->loadModel($id); + + // Uncomment the following line if AJAX validation is needed + // $this->performAjaxValidation($model); + + if(isset($_POST['Veranstaltung'])) + { + $model->attributes=$_POST['Veranstaltung']; + if($model->save()) + $this->redirect(array('view','id'=>$model->id)); + } + + $standorte = Standort::model()->findAll(array("condition"=>"published=1 and type='Bühne'")); + $vereine = Verein::model()->findAll(array("condition"=>"published=1")); + + $this->render('update',array( + 'model'=>$model, + 'vereine'=>$vereine, + 'standorte'=>$standorte + )); + } + + /** + * Deletes a particular model. + * If deletion is successful, the browser will be redirected to the 'admin' page. + * @param integer $id the ID of the model to be deleted + */ + public function actionDelete($id) + { + if(Yii::app()->request->isPostRequest) + { + // we only allow deletion via POST request + $this->loadModel($id)->delete(); + + // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser + if(!isset($_GET['ajax'])) + $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin')); + } + else + throw new CHttpException(400,'Invalid request. Please do not repeat this request again.'); + } + + /** + * Lists all models. + */ + public function actionIndex() + { + $model=new Veranstaltung('search'); + $model->unsetAttributes(); // clear any default values + if(isset($_GET['Veranstaltung'])) + $model->attributes=$_GET['Veranstaltung']; + + $this->render('index',array( + 'model'=>$model, + )); + } + + /** + * Returns the data model based on the primary key given in the GET variable. + * If the data model is not found, an HTTP exception will be raised. + * @param integer the ID of the model to be loaded + */ + public function loadModel($id) + { + $model=Veranstaltung::model()->findByPk($id); + if($model===null) + throw new CHttpException(404,'The requested page does not exist.'); + return $model; + } + + /** + * Performs the AJAX validation. + * @param CModel the model to be validated + */ + protected function performAjaxValidation($model) + { + if(isset($_POST['ajax']) && $_POST['ajax']==='veranstaltung-form') + { + echo CActiveForm::validate($model); + Yii::app()->end(); + } + } +} diff --git a/protected/data/testdrive.db b/protected/data/testdrive.db new file mode 100644 index 0000000..e335767 Binary files /dev/null and b/protected/data/testdrive.db differ diff --git a/protected/extensions/CJuiDateTimePicker/CJuiDateTimePicker.php b/protected/extensions/CJuiDateTimePicker/CJuiDateTimePicker.php new file mode 100644 index 0000000..3a73cb6 --- /dev/null +++ b/protected/extensions/CJuiDateTimePicker/CJuiDateTimePicker.php @@ -0,0 +1,62 @@ + + */ + +Yii::import('zii.widgets.jui.CJuiDatePicker'); +class CJuiDateTimePicker extends CJuiDatePicker +{ + const ASSETS_NAME='/jquery-ui-timepicker-addon'; + + public $mode='datetime'; + + public function init() + { + if(!in_array($this->mode, array('date','time','datetime'))) + throw new CException('unknow mode "'.$this->mode.'"'); + if(!isset($this->language)) + $this->language=Yii::app()->getLanguage(); + return parent::init(); + } + + public function run() + { + list($name,$id)=$this->resolveNameID(); + + if(isset($this->htmlOptions['id'])) + $id=$this->htmlOptions['id']; + else + $this->htmlOptions['id']=$id; + if(isset($this->htmlOptions['name'])) + $name=$this->htmlOptions['name']; + else + $this->htmlOptions['name']=$name; + + if($this->hasModel()) + echo CHtml::activeTextField($this->model,$this->attribute,$this->htmlOptions); + else + echo CHtml::textField($name,$this->value,$this->htmlOptions); + + + $options=CJavaScript::encode($this->options); + + $js = "jQuery('#{$id}').{$this->mode}picker($options);"; + + if (isset($this->language)){ + $this->registerScriptFile($this->i18nScriptFile); + $js = "jQuery('#{$id}').{$this->mode}picker(jQuery.extend({showMonthAfterYear:false}, jQuery.datepicker.regional['{$this->language}'], {$options}));"; + } + + $cs = Yii::app()->getClientScript(); + + $assets = Yii::app()->getAssetManager()->publish(dirname(__FILE__).DIRECTORY_SEPARATOR.'assets'); + $cs->registerCssFile($assets.self::ASSETS_NAME.'.css'); + $cs->registerScriptFile($assets.self::ASSETS_NAME.'.js',CClientScript::POS_END); + + $cs->registerScript(__CLASS__, $this->defaultOptions?'jQuery.{$this->mode}picker.setDefaults('.CJavaScript::encode($this->defaultOptions).');':''); + $cs->registerScript(__CLASS__.'#'.$id, $js); + + } +} \ No newline at end of file diff --git a/protected/extensions/CJuiDateTimePicker/assets/jquery-ui-timepicker-addon.css b/protected/extensions/CJuiDateTimePicker/assets/jquery-ui-timepicker-addon.css new file mode 100644 index 0000000..2cdb20f --- /dev/null +++ b/protected/extensions/CJuiDateTimePicker/assets/jquery-ui-timepicker-addon.css @@ -0,0 +1,5 @@ +.ui-timepicker-div .ui-widget-header{ margin-bottom: 8px; } +.ui-timepicker-div dl{ text-align: left; } +.ui-timepicker-div dl dt{ height: 25px; } +.ui-timepicker-div dl dd{ margin: -25px 0 10px 65px; } +.ui-timepicker-div td { font-size: 90%; } \ No newline at end of file diff --git a/protected/extensions/CJuiDateTimePicker/assets/jquery-ui-timepicker-addon.js b/protected/extensions/CJuiDateTimePicker/assets/jquery-ui-timepicker-addon.js new file mode 100644 index 0000000..215e43a --- /dev/null +++ b/protected/extensions/CJuiDateTimePicker/assets/jquery-ui-timepicker-addon.js @@ -0,0 +1,981 @@ +/* +* jQuery timepicker addon +* By: Trent Richardson [http://trentrichardson.com] +* Version 0.9.4-dev +* Last Modified: 03/02/2011 +* +* Copyright 2011 Trent Richardson +* Dual licensed under the MIT and GPL licenses. +* http://trentrichardson.com/Impromptu/GPL-LICENSE.txt +* http://trentrichardson.com/Impromptu/MIT-LICENSE.txt +* +* HERES THE CSS: +* .ui-timepicker-div .ui-widget-header{ margin-bottom: 8px; } +* .ui-timepicker-div dl{ text-align: left; } +* .ui-timepicker-div dl dt{ height: 25px; } +* .ui-timepicker-div dl dd{ margin: -25px 0 10px 65px; } +* .ui-timepicker-div td { font-size: 90%; } +*/ + +(function($) { + +$.extend($.ui, { timepicker: { version: "0.9.4" } }); + +/* 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.regional = []; // Available regional settings, indexed by language code + this.regional[''] = { // Default regional settings + currentText: 'Now', + closeText: 'Done', + ampm: false, + timeFormat: 'hh:mm tt', + timeOnlyTitle: 'Choose Time', + timeText: 'Time', + hourText: 'Hour', + minuteText: 'Minute', + secondText: 'Second', + timezoneText: 'Time Zone' + }; + this._defaults = { // Global defaults for all the datetime picker instances + showButtonPanel: true, + timeOnly: false, + showHour: true, + showMinute: true, + showSecond: false, + showTimezone: false, + showTime: true, + stepHour: 0.05, + stepMinute: 0.05, + stepSecond: 0.05, + hour: 0, + minute: 0, + second: 0, + timezone: '+0000', + hourMin: 0, + minuteMin: 0, + secondMin: 0, + hourMax: 23, + minuteMax: 59, + secondMax: 59, + minDateTime: null, + maxDateTime: null, + hourGrid: 0, + minuteGrid: 0, + secondGrid: 0, + alwaysSetTime: true, + separator: ' ', + altFieldTimeOnly: true, + showTimepicker: true, + timezoneList: ["-1100", "-1000", "-0900", "-0800", "-0700", "-0600", + "-0500", "-0400", "-0300", "-0200", "-0100", "+0000", + "+0100", "+0200", "+0300", "+0400", "+0500", "+0600", + "+0700", "+0800", "+0900", "+1000", "+1100", "+1200"] + }; + $.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, + timezone_select: null, + hour: 0, + minute: 0, + second: 0, + timezone: '+0000', + hourMinOriginal: null, + minuteMinOriginal: null, + secondMinOriginal: null, + hourMaxOriginal: null, + minuteMaxOriginal: null, + secondMaxOriginal: null, + ampm: '', + formattedDate: '', + formattedTime: '', + formattedDateTime: '', + timezoneList: ["-1100", "-1000", "-0900", "-0800", "-0700", "-0600", + "-0500", "-0400", "-0300", "-0200", "-0100", "+0000", + "+0100", "+0200", "+0300", "+0400", "+0500", "+0600", + "+0700", "+0800", "+0900", "+1000", "+1100", "+1200"], + + /* 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, o) { + var tp_inst = new Timepicker(), + inlineSettings = {}; + + for (var attrName in this._defaults) { + var attrValue = $input.attr('time:' + attrName); + if (attrValue) { + try { + inlineSettings[attrName] = eval(attrValue); + } catch (err) { + inlineSettings[attrName] = attrValue; + } + } + } + tp_inst._defaults = $.extend({}, this._defaults, inlineSettings, o, { + beforeShow: function(input, dp_inst) { + if ($.isFunction(o.beforeShow)) + o.beforeShow(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(o.onChangeMonthYear)) + o.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(o.onClose)) + o.onClose.call($input[0], dateText, dp_inst, tp_inst); + }, + timepicker: tp_inst // add timepicker as a property of datepicker: $.datepicker._get(dp_inst, 'timepicker'); + }); + + tp_inst.hour = tp_inst._defaults.hour; + tp_inst.minute = tp_inst._defaults.minute; + tp_inst.second = tp_inst._defaults.second; + tp_inst.ampm = ''; + tp_inst.$input = $input; + + if (o.altField) + tp_inst.$altInput = $(o.altField) + .css({ cursor: 'pointer' }) + .focus(function(){ $input.trigger("focus"); }); + + // 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()); + + 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) { + var regstr = this._defaults.timeFormat.toString() + .replace(/h{1,2}/ig, '(\\d?\\d)') + .replace(/m{1,2}/ig, '(\\d?\\d)') + .replace(/s{1,2}/ig, '(\\d?\\d)') + .replace(/t{1,2}/ig, '(am|pm|a|p)?') + .replace(/z{1}/ig, '((\\+|-)\\d\\d\\d\\d)?') + .replace(/\s/g, '\\s?') + '$', + order = this._getFormatPositions(), + treg; + + if (!this.inst) this.inst = $.datepicker._getInst(this.$input[0]); + + if (withDate || !this._defaults.timeOnly) { + // the time should come after x number of characters and a space. + // x = at least the length of text specified by the date format + var dp_dateFormat = $.datepicker._get(this.inst, 'dateFormat'); + // escape special regex characters in the seperator + var specials = new RegExp("[.*+?|()\\[\\]{}\\\\]", "g"); + regstr = '.{' + dp_dateFormat.length + ',}' + this._defaults.separator.replace(specials, "\\$&") + regstr; + } + + treg = timeString.match(new RegExp(regstr, 'i')); + + if (treg) { + if (order.t !== -1) + this.ampm = ((treg[order.t] === undefined || treg[order.t].length === 0) ? + '' : + (treg[order.t].charAt(0).toUpperCase() == 'A') ? 'AM' : 'PM').toUpperCase(); + + if (order.h !== -1) { + if (this.ampm == 'AM' && treg[order.h] == '12') + this.hour = 0; // 12am = 0 hour + else if (this.ampm == 'PM' && treg[order.h] != '12') + this.hour = (parseFloat(treg[order.h]) + 12).toFixed(0); // 12pm = 12 hour, any other pm = hour + 12 + else this.hour = Number(treg[order.h]); + } + + if (order.m !== -1) this.minute = Number(treg[order.m]); + if (order.s !== -1) this.second = Number(treg[order.s]); + if (order.z !== -1) this.timezone = treg[order.z]; + + return true; + + } + return false; + }, + + //######################################################################## + // figure out position of time elements.. cause js cant do named captures + //######################################################################## + _getFormatPositions: function() { + var finds = this._defaults.timeFormat.toLowerCase().match(/(h{1,2}|m{1,2}|s{1,2}|t{1,2}|z)/g), + orders = { h: -1, m: -1, s: -1, t: -1, z: -1 }; + + if (finds) + for (var i = 0; i < finds.length; i++) + if (orders[finds[i].toString().charAt(0)] == -1) + orders[finds[i].toString().charAt(0)] = i + 1; + + return orders; + }, + + //######################################################################## + // generate and inject html for timepicker into ui datepicker + //######################################################################## + _injectTimePicker: function() { + var $dp = this.inst.dpDiv, + o = this._defaults, + tp_inst = this, + // Added by Peter Medeiros: + // - Figure out what the hour/minute/second max should be based on the step values. + // - Example: if stepMinute is 15, then minMax is 45. + hourMax = (o.hourMax - (o.hourMax % o.stepHour)).toFixed(0), + minMax = (o.minuteMax - (o.minuteMax % o.stepMinute)).toFixed(0), + secMax = (o.secondMax - (o.secondMax % o.stepSecond)).toFixed(0), + dp_id = this.inst.id.toString().replace(/([^A-Za-z0-9_])/g, ''); + + // Prevent displaying twice + //if ($dp.find("div#ui-timepicker-div-"+ dp_id).length === 0) { + if ($dp.find("div#ui-timepicker-div-"+ dp_id).length === 0 && o.showTimepicker) { + var noDisplay = ' style="display:none;"', + html = '
' + + '
' + o.timeText + '
' + + '
' + + '
' + o.hourText + '
', + hourGridSize = 0, + minuteGridSize = 0, + secondGridSize = 0, + size; + + if (o.showHour && o.hourGrid > 0) { + html += '
' + + '
' + + '
'; + + for (var h = o.hourMin; h < hourMax; h += o.hourGrid) { + hourGridSize++; + var tmph = (o.ampm && h > 12) ? h-12 : h; + if (tmph < 10) tmph = '0' + tmph; + if (o.ampm) { + if (h == 0) tmph = 12 +'a'; + else if (h < 12) tmph += 'a'; + else tmph += 'p'; + } + html += ''; + } + + html += '
' + tmph + '
' + + '
'; + } else html += '
'; + + html += '
' + o.minuteText + '
'; + + if (o.showMinute && o.minuteGrid > 0) { + html += '
' + + '
' + + '
'; + + for (var m = o.minuteMin; m < minMax; m += o.minuteGrid) { + minuteGridSize++; + html += ''; + } + + html += '
' + ((m < 10) ? '0' : '') + m + '
' + + '
'; + } else html += '
'; + + html += '
' + o.secondText + '
'; + + if (o.showSecond && o.secondGrid > 0) { + html += '
' + + '
' + + '
'; + + for (var s = o.secondMin; s < secMax; s += o.secondGrid) { + secondGridSize++; + html += ''; + } + + html += '
' + ((s < 10) ? '0' : '') + s + '
' + + '
'; + } else html += '
'; + + html += '
' + o.timezoneText + '
'; + html += '
'; + + html += '
'; + $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(); + } + + this.hour_slider = $tp.find('#ui_tpicker_hour_'+ dp_id).slider({ + orientation: "horizontal", + value: this.hour, + min: o.hourMin, + max: hourMax, + step: o.stepHour, + slide: function(event, ui) { + tp_inst.hour_slider.slider( "option", "value", ui.value); + tp_inst._onTimeChange(); + } + }); + + // Updated by Peter Medeiros: + // - Pass in Event and UI instance into slide function + this.minute_slider = $tp.find('#ui_tpicker_minute_'+ dp_id).slider({ + orientation: "horizontal", + value: this.minute, + min: o.minuteMin, + max: minMax, + step: o.stepMinute, + slide: function(event, ui) { + // update the global minute slider instance value with the current slider value + tp_inst.minute_slider.slider( "option", "value", ui.value); + tp_inst._onTimeChange(); + } + }); + + this.second_slider = $tp.find('#ui_tpicker_second_'+ dp_id).slider({ + orientation: "horizontal", + value: this.second, + min: o.secondMin, + max: secMax, + step: o.stepSecond, + slide: function(event, ui) { + tp_inst.second_slider.slider( "option", "value", ui.value); + tp_inst._onTimeChange(); + } + }); + + + this.timezone_select = $tp.find('#ui_tpicker_timezone_'+ dp_id).append('').find("select"); + $.fn.append.apply(this.timezone_select, + $.map(o.timezoneList, function(val, idx) { + return $("