3
3
* By: Trent Richardson [http://trentrichardson.com]
4
4
* Version 0.9.6
5
5
* Last Modified: 07/20/2011
6
- *
6
+ *
7
7
* Copyright 2011 Trent Richardson
8
8
* Dual licensed under the MIT and GPL licenses.
9
9
* http://trentrichardson.com/Impromptu/GPL-LICENSE.txt
10
10
* http://trentrichardson.com/Impromptu/MIT-LICENSE.txt
11
- *
11
+ *
12
12
* HERES THE CSS:
13
13
* .ui-timepicker-div .ui-widget-header{ margin-bottom: 8px; }
14
14
* .ui-timepicker-div dl{ text-align: left; }
@@ -121,7 +121,7 @@ $.extend(Timepicker.prototype, {
121
121
_newInst : function ( $input , o ) {
122
122
var tp_inst = new Timepicker ( ) ,
123
123
inlineSettings = { } ;
124
-
124
+
125
125
for ( var attrName in this . _defaults ) {
126
126
var attrValue = $input . attr ( 'time:' + attrName ) ;
127
127
if ( attrValue ) {
@@ -162,7 +162,7 @@ $.extend(Timepicker.prototype, {
162
162
tp_inst . $altInput = $ ( o . altField )
163
163
. css ( { cursor : 'pointer' } )
164
164
. focus ( function ( ) { $input . trigger ( "focus" ) ; } ) ;
165
-
165
+
166
166
// datepicker needs minDate/maxDate, timepicker needs minDateTime/maxDateTime..
167
167
if ( tp_inst . _defaults . minDate !== undefined && tp_inst . _defaults . minDate instanceof Date )
168
168
tp_inst . _defaults . minDateTime = new Date ( tp_inst . _defaults . minDate . getTime ( ) ) ;
@@ -172,7 +172,7 @@ $.extend(Timepicker.prototype, {
172
172
tp_inst . _defaults . maxDateTime = new Date ( tp_inst . _defaults . maxDate . getTime ( ) ) ;
173
173
if ( tp_inst . _defaults . maxDateTime !== undefined && tp_inst . _defaults . maxDateTime instanceof Date )
174
174
tp_inst . _defaults . maxDate = new Date ( tp_inst . _defaults . maxDateTime . getTime ( ) ) ;
175
-
175
+
176
176
return tp_inst ;
177
177
} ,
178
178
@@ -181,7 +181,7 @@ $.extend(Timepicker.prototype, {
181
181
//########################################################################
182
182
_addTimePicker : function ( dp_inst ) {
183
183
var currDT = ( this . $altInput && this . _defaults . altFieldTimeOnly ) ?
184
- this . $input . val ( ) + ' ' + this . $altInput . val ( ) :
184
+ this . $input . val ( ) + ' ' + this . $altInput . val ( ) :
185
185
this . $input . val ( ) ;
186
186
187
187
this . timeDefined = this . _parseTime ( currDT ) ;
@@ -213,7 +213,7 @@ $.extend(Timepicker.prototype, {
213
213
var specials = new RegExp ( "[.*+?|()\\[\\]{}\\\\]" , "g" ) ;
214
214
regstr = '.{' + dp_dateFormat . length + ',}' + this . _defaults . separator . replace ( specials , "\\$&" ) + regstr ;
215
215
}
216
-
216
+
217
217
treg = timeString . match ( new RegExp ( regstr , 'i' ) ) ;
218
218
219
219
if ( treg ) {
@@ -223,17 +223,17 @@ $.extend(Timepicker.prototype, {
223
223
( treg [ order . t ] . charAt ( 0 ) . toUpperCase ( ) == 'A' ) ? 'AM' : 'PM' ) . toUpperCase ( ) ;
224
224
225
225
if ( order . h !== - 1 ) {
226
- if ( this . ampm == 'AM' && treg [ order . h ] == '12' )
226
+ if ( this . ampm == 'AM' && treg [ order . h ] == '12' )
227
227
this . hour = 0 ; // 12am = 0 hour
228
- else if ( this . ampm == 'PM' && treg [ order . h ] != '12' )
228
+ else if ( this . ampm == 'PM' && treg [ order . h ] != '12' )
229
229
this . hour = ( parseFloat ( treg [ order . h ] ) + 12 ) . toFixed ( 0 ) ; // 12pm = 12 hour, any other pm = hour + 12
230
230
else this . hour = Number ( treg [ order . h ] ) ;
231
231
}
232
232
233
233
if ( order . m !== - 1 ) this . minute = Number ( treg [ order . m ] ) ;
234
234
if ( order . s !== - 1 ) this . second = Number ( treg [ order . s ] ) ;
235
235
if ( order . z !== - 1 ) this . timezone = treg [ order . z ] ;
236
-
236
+
237
237
return true ;
238
238
239
239
}
@@ -285,7 +285,7 @@ $.extend(Timepicker.prototype, {
285
285
minuteGridSize = 0 ,
286
286
secondGridSize = 0 ,
287
287
size ;
288
-
288
+
289
289
if ( o . showHour && o . hourGrid > 0 ) {
290
290
html += '<dd class="ui_tpicker_hour">' +
291
291
'<div id="ui_tpicker_hour_' + dp_id + '"' + ( ( o . showHour ) ? '' : noDisplay ) + '></div>' +
@@ -345,7 +345,7 @@ $.extend(Timepicker.prototype, {
345
345
'</dd>' ;
346
346
} else html += '<dd class="ui_tpicker_second" id="ui_tpicker_second_' + dp_id + '"' +
347
347
( ( o . showSecond ) ? '' : noDisplay ) + '></dd>' ;
348
-
348
+
349
349
html += '<dt class="ui_tpicker_timezone_label" id="ui_tpicker_timezone_label_' + dp_id + '"' +
350
350
( ( o . showTimezone ) ? '' : noDisplay ) + '>' + o . timezoneText + '</dt>' ;
351
351
html += '<dd class="ui_tpicker_timezone" id="ui_tpicker_timezone_' + dp_id + '"' +
@@ -401,8 +401,8 @@ $.extend(Timepicker.prototype, {
401
401
tp_inst . _onTimeChange ( ) ;
402
402
}
403
403
} ) ;
404
-
405
-
404
+
405
+
406
406
this . timezone_select = $tp . find ( '#ui_tpicker_timezone_' + dp_id ) . append ( '<select></select>' ) . find ( "select" ) ;
407
407
$ . fn . append . apply ( this . timezone_select ,
408
408
$ . map ( o . timezoneList , function ( val , idx ) {
@@ -510,7 +510,7 @@ $.extend(Timepicker.prototype, {
510
510
} ,
511
511
512
512
//########################################################################
513
- // This function tries to limit the ability to go outside the
513
+ // This function tries to limit the ability to go outside the
514
514
// min/max date range
515
515
//########################################################################
516
516
_limitMinMaxDateTime : function ( dp_inst , adjustSliders ) {
@@ -555,7 +555,7 @@ $.extend(Timepicker.prototype, {
555
555
if ( $ . datepicker . _get ( dp_inst , 'maxDateTime' ) !== null && dp_date ) {
556
556
var maxDateTime = $ . datepicker . _get ( dp_inst , 'maxDateTime' ) ,
557
557
maxDateTimeDate = new Date ( maxDateTime . getFullYear ( ) , maxDateTime . getMonth ( ) , maxDateTime . getDate ( ) , 0 , 0 , 0 , 0 ) ;
558
-
558
+
559
559
if ( this . hourMaxOriginal === null || this . minuteMaxOriginal === null || this . secondMaxOriginal === null ) {
560
560
this . hourMaxOriginal = o . hourMax ;
561
561
this . minuteMaxOriginal = o . minuteMax ;
@@ -600,7 +600,7 @@ $.extend(Timepicker.prototype, {
600
600
601
601
} ,
602
602
603
-
603
+
604
604
//########################################################################
605
605
// when a slider moves, set the internal time...
606
606
// on time change is also called when the time is updated in the text field
@@ -625,28 +625,28 @@ $.extend(Timepicker.prototype, {
625
625
// If the update was done in the input field, the input field should not be updated.
626
626
// If the update was done using the sliders, update the input field.
627
627
var hasChanged = ( hour != this . hour || minute != this . minute || second != this . second || ( this . ampm . length > 0 && this . ampm != ampm ) || timezone != this . timezone ) ;
628
-
628
+
629
629
if ( hasChanged ) {
630
630
631
631
if ( hour !== false ) this . hour = hour ;
632
632
if ( minute !== false ) this . minute = minute ;
633
633
if ( second !== false ) this . second = second ;
634
634
if ( timezone !== false ) this . timezone = timezone ;
635
-
635
+
636
636
if ( ! this . inst ) this . inst = $ . datepicker . _getInst ( this . $input [ 0 ] ) ;
637
-
637
+
638
638
this . _limitMinMaxDateTime ( this . inst , true ) ;
639
639
}
640
640
if ( this . _defaults . ampm ) this . ampm = ampm ;
641
-
641
+
642
642
this . _formatTime ( ) ;
643
643
if ( this . $timeObj ) this . $timeObj . text ( this . formattedTime + this . _defaults . timeSuffix ) ;
644
644
this . timeDefined = true ;
645
645
if ( hasChanged ) this . _updateDateTime ( ) ;
646
646
} ,
647
-
647
+
648
648
//########################################################################
649
- // call custom onSelect.
649
+ // call custom onSelect.
650
650
// bind to sliders slidestop, and grid click.
651
651
//########################################################################
652
652
_onSelectHandler : function ( ) {
@@ -731,7 +731,7 @@ $.extend(Timepicker.prototype, {
731
731
} else {
732
732
this . $input . val ( formattedDateTime ) ;
733
733
}
734
-
734
+
735
735
this . $input . trigger ( "change" ) ;
736
736
}
737
737
@@ -761,9 +761,9 @@ $.fn.extend({
761
761
tmp_args = arguments ;
762
762
763
763
if ( typeof ( o ) == 'string' ) {
764
- if ( o == 'getDate' )
764
+ if ( o == 'getDate' )
765
765
return $ . fn . datepicker . apply ( $ ( this [ 0 ] ) , tmp_args ) ;
766
- else
766
+ else
767
767
return this . each ( function ( ) {
768
768
var $t = $ ( this ) ;
769
769
$t . datepicker . apply ( $t , tmp_args ) ;
@@ -815,9 +815,9 @@ $.datepicker._updateDatepicker = function(inst) {
815
815
}
816
816
817
817
if ( typeof ( inst . stay_open ) !== 'boolean' || inst . stay_open === false ) {
818
-
818
+
819
819
this . _base_updateDatepicker ( inst ) ;
820
-
820
+
821
821
// Reload the time control when changing something in the input text field.
822
822
var tp_inst = this . _get ( inst , 'timepicker' ) ;
823
823
if ( tp_inst ) tp_inst . _addTimePicker ( inst ) ;
@@ -853,7 +853,7 @@ $.datepicker._doKeyPress = function(event) {
853
853
return event . ctrlKey || ( chr < ' ' || ! dateChars || datetimeChars . indexOf ( chr ) > - 1 ) ;
854
854
}
855
855
}
856
-
856
+
857
857
return $ . datepicker . _base_doKeyPress ( event ) ;
858
858
} ;
859
859
@@ -1027,7 +1027,7 @@ $.datepicker._optionDatepicker = function(target, name, value) {
1027
1027
if ( tp_inst ) {
1028
1028
//Set minimum and maximum date values if we have timepicker
1029
1029
if ( name === 'minDate' ) {
1030
- if ( tp_inst . _defaults . minDate !== undefined && tp_inst . _defaults . minDate instanceof Date )
1030
+ if ( tp_inst . _defaults . minDate !== undefined && tp_inst . _defaults . minDate instanceof Date )
1031
1031
tp_inst . _defaults . minDateTime = new Date ( value ) ;
1032
1032
if ( tp_inst . _defaults . minDateTime !== undefined && tp_inst . _defaults . minDateTime instanceof Date )
1033
1033
tp_inst . _defaults . minDate = new Date ( tp_inst . _defaults . minDateTime . getTime ( ) ) ;
0 commit comments