rails_admin 0.4.6 → 0.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of rails_admin might be problematic. Click here for more details.
- data.tar.gz.sig +0 -0
- data/app/assets/javascripts/rails_admin/jquery.ui.timepicker.js +222 -218
- data/app/assets/javascripts/rails_admin/ui.coffee +7 -0
- data/app/assets/stylesheets/rails_admin/base/theming.scss +2 -1
- data/app/controllers/rails_admin/main_controller.rb +1 -1
- data/app/helpers/rails_admin/application_helper.rb +2 -1
- data/app/views/rails_admin/main/_form_filtering_multiselect.html.haml +1 -1
- data/app/views/rails_admin/main/_form_filtering_select.html.haml +2 -2
- data/app/views/rails_admin/main/_form_nested_many.html.haml +1 -1
- data/app/views/rails_admin/main/export.html.haml +6 -1
- data/lib/rails_admin/adapters/active_record.rb +4 -0
- data/lib/rails_admin/adapters/mongoid.rb +14 -6
- data/lib/rails_admin/config.rb +1 -1
- data/lib/rails_admin/config/fields/base.rb +20 -2
- data/lib/rails_admin/config/fields/types/belongs_to_association.rb +8 -0
- data/lib/rails_admin/config/fields/types/has_many_association.rb +4 -0
- data/lib/rails_admin/config/fields/types/has_one_association.rb +9 -0
- data/lib/rails_admin/config/fields/types/serialized.rb +3 -1
- data/lib/rails_admin/config/model.rb +4 -0
- data/lib/rails_admin/version.rb +1 -1
- data/spec/controllers/rails_admin/main_controller_spec.rb +18 -0
- data/spec/dummy_app/app/mongoid/field_test.rb +2 -1
- data/spec/integration/config/edit/rails_admin_config_edit_spec.rb +74 -0
- data/spec/rails_admin/adapters/mongoid_spec.rb +16 -4
- data/spec/rails_admin/config/fields/base_spec.rb +12 -0
- data/spec/rails_admin/config_spec.rb +15 -0
- metadata +6 -4
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
Binary file
|
@@ -1,54 +1,54 @@
|
|
1
1
|
/*
|
2
|
-
* jQuery UI Timepicker
|
3
|
-
*
|
4
|
-
* Copyright 2010-
|
5
|
-
* Dual licensed under the MIT or GPL Version 2 licenses.
|
6
|
-
* http://jquery.org/license
|
7
|
-
*
|
8
|
-
* http://fgelinas.com/code/timepicker
|
9
|
-
*
|
10
|
-
* Depends:
|
11
|
-
*
|
12
|
-
*
|
13
|
-
*
|
14
|
-
* Change version 0.1.0 - moved the t-rex up here
|
15
|
-
*
|
16
|
-
____
|
17
|
-
___
|
18
|
-
`-._~-.
|
19
|
-
\
|
20
|
-
]
|
21
|
-
/
|
22
|
-
/
|
23
|
-
/
|
24
|
-
/
|
25
|
-
/
|
26
|
-
Y
|
27
|
-
|
|
28
|
-
|
|
29
|
-
l
|
30
|
-
\
|
31
|
-
\
|
32
|
-
"-.,_____.,_
|
33
|
-
~~
|
34
|
-
`. ~(
|
35
|
-
)
|
36
|
-
/,`--'~\--'~\
|
37
|
-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
38
|
-
->T-Rex<-
|
2
|
+
* jQuery UI Timepicker
|
3
|
+
*
|
4
|
+
* Copyright 2010-2013, Francois Gelinas
|
5
|
+
* Dual licensed under the MIT or GPL Version 2 licenses.
|
6
|
+
* http://jquery.org/license
|
7
|
+
*
|
8
|
+
* http://fgelinas.com/code/timepicker
|
9
|
+
*
|
10
|
+
* Depends:
|
11
|
+
* jquery.ui.core.js
|
12
|
+
* jquery.ui.position.js (only if position settngs are used)
|
13
|
+
*
|
14
|
+
* Change version 0.1.0 - moved the t-rex up here
|
15
|
+
*
|
16
|
+
____
|
17
|
+
___ .-~. /_"-._
|
18
|
+
`-._~-. / /_ "~o\ :Y
|
19
|
+
\ \ / : \~x. ` ')
|
20
|
+
] Y / | Y< ~-.__j
|
21
|
+
/ ! _.--~T : l l< /.-~
|
22
|
+
/ / ____.--~ . ` l /~\ \<|Y
|
23
|
+
/ / .-~~" /| . ',-~\ \L|
|
24
|
+
/ / / .^ \ Y~Y \.^>/l_ "--'
|
25
|
+
/ Y .-"( . l__ j_j l_/ /~_.-~ .
|
26
|
+
Y l / \ ) ~~~." / `/"~ / \.__/l_
|
27
|
+
| \ _.-" ~-{__ l : l._Z~-.___.--~
|
28
|
+
| ~---~ / ~~"---\_ ' __[>
|
29
|
+
l . _.^ ___ _>-y~
|
30
|
+
\ \ . .-~ .-~ ~>--" /
|
31
|
+
\ ~---" / ./ _.-'
|
32
|
+
"-.,_____.,_ _.--~\ _.-~
|
33
|
+
~~ ( _} -Row
|
34
|
+
`. ~(
|
35
|
+
) \
|
36
|
+
/,`--'~\--'~\
|
37
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
38
|
+
->T-Rex<-
|
39
39
|
*/
|
40
40
|
|
41
41
|
(function ($) {
|
42
42
|
|
43
|
-
$.extend($.ui, { timepicker: { version: "0.3.
|
43
|
+
$.extend($.ui, { timepicker: { version: "0.3.2"} });
|
44
44
|
|
45
45
|
var PROP_NAME = 'timepicker',
|
46
46
|
tpuuid = new Date().getTime();
|
47
47
|
|
48
48
|
/* Time picker manager.
|
49
|
-
Use the singleton instance of this class, $.timepicker, to interact with the time picker.
|
50
|
-
Settings for (groups of) time pickers are maintained in an instance object,
|
51
|
-
allowing multiple different settings on the same page. */
|
49
|
+
Use the singleton instance of this class, $.timepicker, to interact with the time picker.
|
50
|
+
Settings for (groups of) time pickers are maintained in an instance object,
|
51
|
+
allowing multiple different settings on the same page. */
|
52
52
|
|
53
53
|
function Timepicker() {
|
54
54
|
this.debug = true; // Change this to true to start debugging
|
@@ -64,61 +64,61 @@ allowing multiple different settings on the same page. */
|
|
64
64
|
|
65
65
|
this.regional = []; // Available regional settings, indexed by language code
|
66
66
|
this.regional[''] = { // Default regional settings
|
67
|
-
hourText: 'Hour',
|
68
|
-
minuteText: 'Minute',
|
69
|
-
amPmText: ['AM', 'PM'],
|
70
|
-
closeButtonText: 'Done',
|
71
|
-
nowButtonText: 'Now',
|
72
|
-
deselectButtonText: 'Deselect'
|
67
|
+
hourText: 'Hour', // Display text for hours section
|
68
|
+
minuteText: 'Minute', // Display text for minutes link
|
69
|
+
amPmText: ['AM', 'PM'], // Display text for AM PM
|
70
|
+
closeButtonText: 'Done', // Text for the confirmation button (ok button)
|
71
|
+
nowButtonText: 'Now', // Text for the now button
|
72
|
+
deselectButtonText: 'Deselect' // Text for the deselect button
|
73
73
|
};
|
74
74
|
this._defaults = { // Global defaults for all the time picker instances
|
75
|
-
showOn: 'focus',
|
75
|
+
showOn: 'focus', // 'focus' for popup on focus,
|
76
76
|
// 'button' for trigger button, or 'both' for either (not yet implemented)
|
77
|
-
button: null,
|
78
|
-
showAnim: 'fadeIn',
|
79
|
-
showOptions: {},
|
80
|
-
appendText: '',
|
81
|
-
|
82
|
-
beforeShow: null,
|
83
|
-
onSelect: null,
|
84
|
-
onClose: null,
|
85
|
-
|
86
|
-
timeSeparator: ':',
|
87
|
-
periodSeparator: ' ',
|
88
|
-
showPeriod: false,
|
89
|
-
showPeriodLabels: true,
|
90
|
-
showLeadingZero: true,
|
91
|
-
showMinutesLeadingZero: true,
|
92
|
-
altField: '',
|
93
|
-
defaultTime: 'now',
|
77
|
+
button: null, // 'button' element that will trigger the timepicker
|
78
|
+
showAnim: 'fadeIn', // Name of jQuery animation for popup
|
79
|
+
showOptions: {}, // Options for enhanced animations
|
80
|
+
appendText: '', // Display text following the input box, e.g. showing the format
|
81
|
+
|
82
|
+
beforeShow: null, // Define a callback function executed before the timepicker is shown
|
83
|
+
onSelect: null, // Define a callback function when a hour / minutes is selected
|
84
|
+
onClose: null, // Define a callback function when the timepicker is closed
|
85
|
+
|
86
|
+
timeSeparator: ':', // The character to use to separate hours and minutes.
|
87
|
+
periodSeparator: ' ', // The character to use to separate the time from the time period.
|
88
|
+
showPeriod: false, // Define whether or not to show AM/PM with selected time
|
89
|
+
showPeriodLabels: true, // Show the AM/PM labels on the left of the time picker
|
90
|
+
showLeadingZero: true, // Define whether or not to show a leading zero for hours < 10. [true/false]
|
91
|
+
showMinutesLeadingZero: true, // Define whether or not to show a leading zero for minutes < 10.
|
92
|
+
altField: '', // Selector for an alternate field to store selected time into
|
93
|
+
defaultTime: 'now', // Used as default time when input field is empty or for inline timePicker
|
94
94
|
// (set to 'now' for the current time, '' for no highlighted time)
|
95
|
-
myPosition: 'left top',
|
95
|
+
myPosition: 'left top', // Position of the dialog relative to the input.
|
96
96
|
// see the position utility for more info : http://jqueryui.com/demos/position/
|
97
|
-
atPosition: 'left bottom',
|
97
|
+
atPosition: 'left bottom', // Position of the input element to match
|
98
98
|
// Note : if the position utility is not loaded, the timepicker will attach left top to left bottom
|
99
99
|
//NEW: 2011-02-03
|
100
|
-
onHourShow: null,
|
101
|
-
onMinuteShow: null,
|
100
|
+
onHourShow: null, // callback for enabling / disabling on selectable hours ex : function(hour) { return true; }
|
101
|
+
onMinuteShow: null, // callback for enabling / disabling on time selection ex : function(hour,minute) { return true; }
|
102
102
|
|
103
103
|
hours: {
|
104
|
-
starts: 0,
|
105
|
-
ends: 23
|
104
|
+
starts: 0, // first displayed hour
|
105
|
+
ends: 23 // last displayed hour
|
106
106
|
},
|
107
107
|
minutes: {
|
108
|
-
starts: 0,
|
109
|
-
ends: 55,
|
110
|
-
interval: 5
|
108
|
+
starts: 0, // first displayed minute
|
109
|
+
ends: 55, // last displayed minute
|
110
|
+
interval: 5 // interval of displayed minutes
|
111
111
|
},
|
112
|
-
rows: 4,
|
112
|
+
rows: 4, // number of rows for the input tables, minimum 2, makes more sense if you use multiple of 2
|
113
113
|
// 2011-08-05 0.2.4
|
114
|
-
showHours: true,
|
115
|
-
showMinutes: true,
|
116
|
-
optionalMinutes: false,
|
117
|
-
|
114
|
+
showHours: true, // display the hours section of the dialog
|
115
|
+
showMinutes: true, // display the minute section of the dialog
|
116
|
+
optionalMinutes: false, // optionally parse inputs of whole hours with minutes omitted
|
117
|
+
|
118
118
|
// buttons
|
119
|
-
showCloseButton: false,
|
120
|
-
showNowButton: false,
|
121
|
-
showDeselectButton: false
|
119
|
+
showCloseButton: false, // shows an OK button to confirm the edit
|
120
|
+
showNowButton: false, // Shows the 'now' button
|
121
|
+
showDeselectButton: false // Shows the deselect time button
|
122
122
|
|
123
123
|
};
|
124
124
|
$.extend(this._defaults, this.regional['']);
|
@@ -141,16 +141,16 @@ allowing multiple different settings on the same page. */
|
|
141
141
|
},
|
142
142
|
|
143
143
|
/* Override the default settings for all instances of the time picker.
|
144
|
-
@param
|
145
|
-
@return the manager object */
|
144
|
+
@param settings object - the new settings to use as defaults (anonymous object)
|
145
|
+
@return the manager object */
|
146
146
|
setDefaults: function (settings) {
|
147
147
|
extendRemove(this._defaults, settings || {});
|
148
148
|
return this;
|
149
149
|
},
|
150
150
|
|
151
151
|
/* Attach the time picker to a jQuery selection.
|
152
|
-
@param
|
153
|
-
@param
|
152
|
+
@param target element - the target input field or division or span
|
153
|
+
@param settings object - the new settings to use for this time picker instance (anonymous) */
|
154
154
|
_attachTimepicker: function (target, settings) {
|
155
155
|
// check for settings on the control itself - in namespace 'time:'
|
156
156
|
var inlineSettings = null;
|
@@ -192,7 +192,7 @@ allowing multiple different settings on the same page. */
|
|
192
192
|
id: id, input: target, // associated target
|
193
193
|
inline: inline, // is timepicker inline or not :
|
194
194
|
tpDiv: (!inline ? this.tpDiv : // presentation div
|
195
|
-
$('<div class="' + this._inlineClass + ' ui-timepicker ui-widget
|
195
|
+
$('<div class="' + this._inlineClass + ' ui-timepicker ui-widget ui-helper-clearfix"></div>'))
|
196
196
|
};
|
197
197
|
},
|
198
198
|
|
@@ -229,8 +229,8 @@ allowing multiple different settings on the same page. */
|
|
229
229
|
$.timepicker._updateSelectedValue(inst);
|
230
230
|
$.timepicker._hideTimepicker();
|
231
231
|
|
232
|
-
return false; // don't submit the form
|
233
|
-
break; // select the value on enter
|
232
|
+
return false; // don't submit the form
|
233
|
+
break; // select the value on enter
|
234
234
|
case 27: $.timepicker._hideTimepicker();
|
235
235
|
break; // hide on escape
|
236
236
|
default: handled = false;
|
@@ -315,8 +315,8 @@ break; // select the value on enter
|
|
315
315
|
},
|
316
316
|
|
317
317
|
/* Pop-up the time picker for a given input field.
|
318
|
-
@param
|
319
|
-
event - if triggered by focus */
|
318
|
+
@param input element - the input field attached to the time picker or
|
319
|
+
event - if triggered by focus */
|
320
320
|
_showTimepicker: function (input) {
|
321
321
|
input = input.target || input;
|
322
322
|
if (input.nodeName.toLowerCase() != 'input') { input = $('input', input.parentNode)[0]; } // find from button/image trigger
|
@@ -348,10 +348,6 @@ event - if triggered by focus */
|
|
348
348
|
isFixed |= $(this).css('position') == 'fixed';
|
349
349
|
return !isFixed;
|
350
350
|
});
|
351
|
-
if (isFixed && $.browser.opera) { // correction for Opera when fixed and scrolled
|
352
|
-
$.timepicker._pos[0] -= document.documentElement.scrollLeft;
|
353
|
-
$.timepicker._pos[1] -= document.documentElement.scrollTop;
|
354
|
-
}
|
355
351
|
|
356
352
|
var offset = { left: $.timepicker._pos[0], top: $.timepicker._pos[1] };
|
357
353
|
|
@@ -362,7 +358,7 @@ event - if triggered by focus */
|
|
362
358
|
|
363
359
|
|
364
360
|
// position with the ui position utility, if loaded
|
365
|
-
if ( ( ! inst.inline )
|
361
|
+
if ( ( ! inst.inline ) && ( typeof $.ui.position == 'object' ) ) {
|
366
362
|
inst.tpDiv.position({
|
367
363
|
of: inst.input,
|
368
364
|
my: $.timepicker._get( inst, 'myPosition' ),
|
@@ -384,7 +380,7 @@ event - if triggered by focus */
|
|
384
380
|
// and adjust position before showing
|
385
381
|
offset = $.timepicker._checkOffset(inst, offset, isFixed);
|
386
382
|
inst.tpDiv.css({ position: ($.timepicker._inDialog && $.blockUI ?
|
387
|
-
'static' : (isFixed ? 'fixed' : 'absolute')), display: 'none',
|
383
|
+
'static' : (isFixed ? 'fixed' : 'absolute')), display: 'none',
|
388
384
|
left: offset.left + 'px', top: offset.top + 'px'
|
389
385
|
});
|
390
386
|
if ( ! inst.inline ) {
|
@@ -395,9 +391,9 @@ event - if triggered by focus */
|
|
395
391
|
$.timepicker._timepickerShowing = true;
|
396
392
|
var borders = $.timepicker._getBorders(inst.tpDiv);
|
397
393
|
inst.tpDiv.find('iframe.ui-timepicker-cover'). // IE6- only
|
398
|
-
css({ left: -borders[0], top: -borders[1],
|
399
|
-
width: inst.tpDiv.outerWidth(), height: inst.tpDiv.outerHeight()
|
400
|
-
});
|
394
|
+
css({ left: -borders[0], top: -borders[1],
|
395
|
+
width: inst.tpDiv.outerWidth(), height: inst.tpDiv.outerHeight()
|
396
|
+
});
|
401
397
|
};
|
402
398
|
|
403
399
|
// Fixed the zIndex problem for real (I hope) - FG - v 0.2.9
|
@@ -416,24 +412,31 @@ width: inst.tpDiv.outerWidth(), height: inst.tpDiv.outerHeight()
|
|
416
412
|
}
|
417
413
|
},
|
418
414
|
|
419
|
-
// This is
|
420
|
-
//
|
415
|
+
// This is an enhanced copy of the zIndex function of UI core 1.8.?? For backward compatibility.
|
416
|
+
// Enhancement returns maximum zindex value discovered while traversing parent elements,
|
417
|
+
// rather than the first zindex value found. Ensures the timepicker popup will be in front,
|
418
|
+
// even in funky scenarios like non-jq dialog containers with large fixed zindex values and
|
419
|
+
// nested zindex-influenced elements of their own.
|
421
420
|
_getZIndex: function (target) {
|
422
|
-
var elem = $(
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
421
|
+
var elem = $(target);
|
422
|
+
var maxValue = 0;
|
423
|
+
var position, value;
|
424
|
+
while (elem.length && elem[0] !== document) {
|
425
|
+
position = elem.css("position");
|
426
|
+
if (position === "absolute" || position === "relative" || position === "fixed") {
|
427
|
+
value = parseInt(elem.css("zIndex"), 10);
|
428
|
+
if (!isNaN(value) && value !== 0) {
|
429
|
+
if (value > maxValue) { maxValue = value; }
|
429
430
|
}
|
430
431
|
}
|
431
432
|
elem = elem.parent();
|
432
433
|
}
|
434
|
+
|
435
|
+
return maxValue;
|
433
436
|
},
|
434
437
|
|
435
438
|
/* Refresh the time picker
|
436
|
-
@param
|
439
|
+
@param target element - The target input field or inline container element. */
|
437
440
|
_refreshTimepicker: function(target) {
|
438
441
|
var inst = this._getInst(target);
|
439
442
|
if (inst) {
|
@@ -453,11 +456,11 @@ width: inst.tpDiv.outerWidth(), height: inst.tpDiv.outerHeight()
|
|
453
456
|
var borders = $.timepicker._getBorders(inst.tpDiv),
|
454
457
|
self = this;
|
455
458
|
inst.tpDiv
|
456
|
-
.find('iframe.ui-timepicker-cover') // IE6- only
|
457
|
-
.css({ left: -borders[0], top: -borders[1],
|
458
|
-
width: inst.tpDiv.outerWidth(), height: inst.tpDiv.outerHeight()
|
459
|
-
})
|
460
|
-
.end()
|
459
|
+
.find('iframe.ui-timepicker-cover') // IE6- only
|
460
|
+
.css({ left: -borders[0], top: -borders[1],
|
461
|
+
width: inst.tpDiv.outerWidth(), height: inst.tpDiv.outerHeight()
|
462
|
+
})
|
463
|
+
.end()
|
461
464
|
// after the picker html is appended bind the click & double click events (faster in IE this way
|
462
465
|
// then letting the browser interpret the inline events)
|
463
466
|
// the binding for the minute cells also exists in _updateMinuteDisplay
|
@@ -471,25 +474,25 @@ width: inst.tpDiv.outerWidth(), height: inst.tpDiv.outerHeight()
|
|
471
474
|
.bind("click", { fromDoubleClick:false }, $.proxy($.timepicker.selectHours, this))
|
472
475
|
.bind("dblclick", { fromDoubleClick:true }, $.proxy($.timepicker.selectHours, this))
|
473
476
|
.end()
|
474
|
-
.find('.ui-timepicker td a')
|
477
|
+
.find('.ui-timepicker td a')
|
475
478
|
.unbind()
|
476
|
-
.bind('mouseout', function () {
|
477
|
-
$(this).removeClass('ui-state-hover');
|
478
|
-
if (this.className.indexOf('ui-timepicker-prev') != -1) $(this).removeClass('ui-timepicker-prev-hover');
|
479
|
-
if (this.className.indexOf('ui-timepicker-next') != -1) $(this).removeClass('ui-timepicker-next-hover');
|
480
|
-
})
|
481
|
-
.bind('mouseover', function () {
|
482
|
-
if ( ! self._isDisabledTimepicker(inst.inline ? inst.tpDiv.parent()[0] : inst.input[0])) {
|
483
|
-
$(this).parents('.ui-timepicker-calendar').find('a').removeClass('ui-state-hover');
|
484
|
-
$(this).addClass('ui-state-hover');
|
485
|
-
if (this.className.indexOf('ui-timepicker-prev') != -1) $(this).addClass('ui-timepicker-prev-hover');
|
486
|
-
if (this.className.indexOf('ui-timepicker-next') != -1) $(this).addClass('ui-timepicker-next-hover');
|
487
|
-
}
|
488
|
-
})
|
489
|
-
.end()
|
490
|
-
.find('.' + this._dayOverClass + ' a')
|
491
|
-
.trigger('mouseover')
|
492
|
-
.end()
|
479
|
+
.bind('mouseout', function () {
|
480
|
+
$(this).removeClass('ui-state-hover');
|
481
|
+
if (this.className.indexOf('ui-timepicker-prev') != -1) $(this).removeClass('ui-timepicker-prev-hover');
|
482
|
+
if (this.className.indexOf('ui-timepicker-next') != -1) $(this).removeClass('ui-timepicker-next-hover');
|
483
|
+
})
|
484
|
+
.bind('mouseover', function () {
|
485
|
+
if ( ! self._isDisabledTimepicker(inst.inline ? inst.tpDiv.parent()[0] : inst.input[0])) {
|
486
|
+
$(this).parents('.ui-timepicker-calendar').find('a').removeClass('ui-state-hover');
|
487
|
+
$(this).addClass('ui-state-hover');
|
488
|
+
if (this.className.indexOf('ui-timepicker-prev') != -1) $(this).addClass('ui-timepicker-prev-hover');
|
489
|
+
if (this.className.indexOf('ui-timepicker-next') != -1) $(this).addClass('ui-timepicker-next-hover');
|
490
|
+
}
|
491
|
+
})
|
492
|
+
.end()
|
493
|
+
.find('.' + this._dayOverClass + ' a')
|
494
|
+
.trigger('mouseover')
|
495
|
+
.end()
|
493
496
|
.find('.ui-timepicker-now').bind("click", function(e) {
|
494
497
|
$.timepicker.selectNow(e);
|
495
498
|
}).end()
|
@@ -548,7 +551,7 @@ if (this.className.indexOf('ui-timepicker-next') != -1) $(this).addClass('ui-tim
|
|
548
551
|
pmItems++;
|
549
552
|
}
|
550
553
|
}
|
551
|
-
hourCounter = 0;
|
554
|
+
hourCounter = 0;
|
552
555
|
|
553
556
|
amRows = Math.floor(amItems / hours.length * rows);
|
554
557
|
pmRows = Math.floor(pmItems / hours.length * rows);
|
@@ -639,11 +642,12 @@ if (this.className.indexOf('ui-timepicker-next') != -1) $(this).addClass('ui-tim
|
|
639
642
|
html += buttonPanel + '</div></td></tr>';
|
640
643
|
}
|
641
644
|
html += '</table>';
|
645
|
+
|
642
646
|
return html;
|
643
647
|
},
|
644
648
|
|
645
649
|
/* Special function that update the minutes selection in currently visible timepicker
|
646
|
-
* called on hour selection when onMinuteShow is defined
|
650
|
+
* called on hour selection when onMinuteShow is defined */
|
647
651
|
_updateMinuteDisplay: function (inst) {
|
648
652
|
var newHtml = this._generateHTMLMinutes(inst);
|
649
653
|
inst.tpDiv.find('td.ui-timepicker-minutes').html(newHtml);
|
@@ -651,17 +655,17 @@ if (this.className.indexOf('ui-timepicker-next') != -1) $(this).addClass('ui-tim
|
|
651
655
|
// after the picker html is appended bind the click & double click events (faster in IE this way
|
652
656
|
// then letting the browser interpret the inline events)
|
653
657
|
// yes I know, duplicate code, sorry
|
654
|
-
/*
|
655
|
-
.bind("click", { fromDoubleClick:false }, $.proxy($.timepicker.selectMinutes, this))
|
656
|
-
.bind("dblclick", { fromDoubleClick:true }, $.proxy($.timepicker.selectMinutes, this));
|
658
|
+
/* .find('.ui-timepicker-minute-cell')
|
659
|
+
.bind("click", { fromDoubleClick:false }, $.proxy($.timepicker.selectMinutes, this))
|
660
|
+
.bind("dblclick", { fromDoubleClick:true }, $.proxy($.timepicker.selectMinutes, this));
|
657
661
|
*/
|
658
662
|
|
659
663
|
},
|
660
664
|
|
661
665
|
/*
|
662
|
-
* Generate the minutes table
|
663
|
-
* This is separated from the _generateHTML function because is can be called separately (when hours changes)
|
664
|
-
*/
|
666
|
+
* Generate the minutes table
|
667
|
+
* This is separated from the _generateHTML function because is can be called separately (when hours changes)
|
668
|
+
*/
|
665
669
|
_generateHTMLMinutes: function (inst) {
|
666
670
|
|
667
671
|
var m, row, html = '',
|
@@ -686,8 +690,8 @@ if (this.className.indexOf('ui-timepicker-next') != -1) $(this).addClass('ui-tim
|
|
686
690
|
minutesPerRow = Math.round(minutes.length / rows + 0.49); // always round up
|
687
691
|
|
688
692
|
/*
|
689
|
-
* The minutes table
|
690
|
-
*/
|
693
|
+
* The minutes table
|
694
|
+
*/
|
691
695
|
// if currently selected minute is not enabled, we have a problem and need to select a new minute.
|
692
696
|
if (onMinuteShow &&
|
693
697
|
(onMinuteShow.apply((inst.input ? inst.input[0] : null), [inst.hours , inst.minutes]) == false) ) {
|
@@ -744,7 +748,7 @@ if (this.className.indexOf('ui-timepicker-next') != -1) $(this).addClass('ui-tim
|
|
744
748
|
|
745
749
|
var html = "";
|
746
750
|
var enabled = true;
|
747
|
-
var onHourShow = this._get(inst, 'onHourShow');
|
751
|
+
var onHourShow = this._get(inst, 'onHourShow'); //custom callback
|
748
752
|
|
749
753
|
if (hour == undefined) {
|
750
754
|
html = '<td><span class="ui-state-default ui-state-disabled"> </span></td>';
|
@@ -752,7 +756,7 @@ if (this.className.indexOf('ui-timepicker-next') != -1) $(this).addClass('ui-tim
|
|
752
756
|
}
|
753
757
|
|
754
758
|
if (onHourShow) {
|
755
|
-
|
759
|
+
enabled = onHourShow.apply((inst.input ? inst.input[0] : null), [hour]);
|
756
760
|
}
|
757
761
|
|
758
762
|
if (enabled) {
|
@@ -764,26 +768,26 @@ if (this.className.indexOf('ui-timepicker-next') != -1) $(this).addClass('ui-tim
|
|
764
768
|
'</a></td>';
|
765
769
|
}
|
766
770
|
else {
|
767
|
-
|
768
|
-
|
769
|
-
'<span class="ui-state-default ui-state-disabled ' +
|
770
|
-
(hour == inst.hours ? ' ui-state-active ' : ' ') +
|
771
|
-
'">' +
|
772
|
-
displayHour.toString() +
|
773
|
-
'</span>' +
|
774
|
-
'</td>';
|
771
|
+
html =
|
772
|
+
'<td>' +
|
773
|
+
'<span class="ui-state-default ui-state-disabled ' +
|
774
|
+
(hour == inst.hours ? ' ui-state-active ' : ' ') +
|
775
|
+
'">' +
|
776
|
+
displayHour.toString() +
|
777
|
+
'</span>' +
|
778
|
+
'</td>';
|
775
779
|
}
|
776
780
|
return html;
|
777
781
|
},
|
778
782
|
|
779
783
|
/* Generate the content of a "Hour" cell */
|
780
784
|
_generateHTMLMinuteCell: function (inst, minute, displayText) {
|
781
|
-
|
785
|
+
var html = "";
|
782
786
|
var enabled = true;
|
783
|
-
var onMinuteShow = this._get(inst, 'onMinuteShow');
|
787
|
+
var onMinuteShow = this._get(inst, 'onMinuteShow'); //custom callback
|
784
788
|
if (onMinuteShow) {
|
785
|
-
|
786
|
-
|
789
|
+
//NEW: 2011-02-03 we should give the hour as a parameter as well!
|
790
|
+
enabled = onMinuteShow.apply((inst.input ? inst.input[0] : null), [inst.hours,minute]); //trigger callback
|
787
791
|
}
|
788
792
|
|
789
793
|
if (minute == undefined) {
|
@@ -792,19 +796,19 @@ displayHour.toString() +
|
|
792
796
|
}
|
793
797
|
|
794
798
|
if (enabled) {
|
795
|
-
html = '<td class="ui-timepicker-minute-cell" data-timepicker-instance-id="#' + inst.id.replace(/\\\\/g,"\\") + '" data-minute="' + minute.toString() + '" >' +
|
796
|
-
'<a class="ui-state-default ' +
|
797
|
-
(minute == inst.minutes ? 'ui-state-active' : '') +
|
798
|
-
'" >' +
|
799
|
-
displayText +
|
800
|
-
'</a></td>';
|
799
|
+
html = '<td class="ui-timepicker-minute-cell" data-timepicker-instance-id="#' + inst.id.replace(/\\\\/g,"\\") + '" data-minute="' + minute.toString() + '" >' +
|
800
|
+
'<a class="ui-state-default ' +
|
801
|
+
(minute == inst.minutes ? 'ui-state-active' : '') +
|
802
|
+
'" >' +
|
803
|
+
displayText +
|
804
|
+
'</a></td>';
|
801
805
|
}
|
802
806
|
else {
|
803
807
|
|
804
|
-
|
805
|
-
'<span class="ui-state-default ui-state-disabled" >' +
|
806
|
-
displayText +
|
807
|
-
'</span>' +
|
808
|
+
html = '<td>' +
|
809
|
+
'<span class="ui-state-default ui-state-disabled" >' +
|
810
|
+
displayText +
|
811
|
+
'</span>' +
|
808
812
|
'</td>';
|
809
813
|
}
|
810
814
|
return html;
|
@@ -812,7 +816,7 @@ displayText +
|
|
812
816
|
|
813
817
|
|
814
818
|
/* Detach a timepicker from its control.
|
815
|
-
@param
|
819
|
+
@param target element - the target input field or division or span */
|
816
820
|
_destroyTimepicker: function(target) {
|
817
821
|
var $target = $(target);
|
818
822
|
var inst = $.data(target, PROP_NAME);
|
@@ -832,7 +836,7 @@ displayText +
|
|
832
836
|
},
|
833
837
|
|
834
838
|
/* Enable the date picker to a jQuery selection.
|
835
|
-
@param
|
839
|
+
@param target element - the target input field or division or span */
|
836
840
|
_enableTimepicker: function(target) {
|
837
841
|
var $target = $(target),
|
838
842
|
target_id = $target.attr('id'),
|
@@ -861,7 +865,7 @@ displayText +
|
|
861
865
|
},
|
862
866
|
|
863
867
|
/* Disable the time picker to a jQuery selection.
|
864
|
-
@param
|
868
|
+
@param target element - the target input field or division or span */
|
865
869
|
_disableTimepicker: function(target) {
|
866
870
|
var $target = $(target);
|
867
871
|
var inst = $.data(target, PROP_NAME);
|
@@ -893,8 +897,8 @@ displayText +
|
|
893
897
|
},
|
894
898
|
|
895
899
|
/* Is the first field in a jQuery collection disabled as a timepicker?
|
896
|
-
@param
|
897
|
-
@return boolean - true if disabled, false if enabled */
|
900
|
+
@param target_id element - the target input field or division or span
|
901
|
+
@return boolean - true if disabled, false if enabled */
|
898
902
|
_isDisabledTimepicker: function (target_id) {
|
899
903
|
if ( ! target_id) { return false; }
|
900
904
|
for (var i = 0; i < this._disabledInputs.length; i++) {
|
@@ -918,9 +922,9 @@ displayText +
|
|
918
922
|
|
919
923
|
// now check if datepicker is showing outside window viewport - move to a better place if so.
|
920
924
|
offset.left -= Math.min(offset.left, (offset.left + tpWidth > viewWidth && viewWidth > tpWidth) ?
|
921
|
-
Math.abs(offset.left + tpWidth - viewWidth) : 0);
|
925
|
+
Math.abs(offset.left + tpWidth - viewWidth) : 0);
|
922
926
|
offset.top -= Math.min(offset.top, (offset.top + tpHeight > viewHeight && viewHeight > tpHeight) ?
|
923
|
-
Math.abs(tpHeight + inputHeight) : 0);
|
927
|
+
Math.abs(tpHeight + inputHeight) : 0);
|
924
928
|
|
925
929
|
return offset;
|
926
930
|
},
|
@@ -937,14 +941,14 @@ Math.abs(tpHeight + inputHeight) : 0);
|
|
937
941
|
},
|
938
942
|
|
939
943
|
/* Retrieve the size of left and top borders for an element.
|
940
|
-
@param
|
941
|
-
@return
|
944
|
+
@param elem (jQuery object) the element of interest
|
945
|
+
@return (number[2]) the left and top borders */
|
942
946
|
_getBorders: function (elem) {
|
943
947
|
var convert = function (value) {
|
944
948
|
return { thin: 1, medium: 2, thick: 3}[value] || value;
|
945
949
|
};
|
946
950
|
return [parseFloat(convert(elem.css('border-left-width'))),
|
947
|
-
parseFloat(convert(elem.css('border-top-width')))];
|
951
|
+
parseFloat(convert(elem.css('border-top-width')))];
|
948
952
|
},
|
949
953
|
|
950
954
|
|
@@ -953,15 +957,15 @@ parseFloat(convert(elem.css('border-top-width')))];
|
|
953
957
|
if (!$.timepicker._curInst) { return; }
|
954
958
|
var $target = $(event.target);
|
955
959
|
if ($target[0].id != $.timepicker._mainDivId &&
|
956
|
-
$target.parents('#' + $.timepicker._mainDivId).length == 0 &&
|
957
|
-
!$target.hasClass($.timepicker.markerClassName) &&
|
958
|
-
!$target.hasClass($.timepicker._triggerClass) &&
|
959
|
-
$.timepicker._timepickerShowing && !($.timepicker._inDialog && $.blockUI))
|
960
|
+
$target.parents('#' + $.timepicker._mainDivId).length == 0 &&
|
961
|
+
!$target.hasClass($.timepicker.markerClassName) &&
|
962
|
+
!$target.hasClass($.timepicker._triggerClass) &&
|
963
|
+
$.timepicker._timepickerShowing && !($.timepicker._inDialog && $.blockUI))
|
960
964
|
$.timepicker._hideTimepicker();
|
961
965
|
},
|
962
966
|
|
963
967
|
/* Hide the time picker from view.
|
964
|
-
@param
|
968
|
+
@param input element - the input field attached to the time picker */
|
965
969
|
_hideTimepicker: function (input) {
|
966
970
|
var inst = this._curInst;
|
967
971
|
if (!inst || (input && inst != $.data(input, PROP_NAME))) { return; }
|
@@ -977,7 +981,7 @@ $.timepicker._timepickerShowing && !($.timepicker._inDialog && $.blockUI))
|
|
977
981
|
}
|
978
982
|
else {
|
979
983
|
inst.tpDiv[(showAnim == 'slideDown' ? 'slideUp' :
|
980
|
-
(showAnim == 'fadeIn' ? 'fadeOut' : 'hide'))]((showAnim ? duration : null), postProcess);
|
984
|
+
(showAnim == 'fadeIn' ? 'fadeOut' : 'hide'))]((showAnim ? duration : null), postProcess);
|
981
985
|
}
|
982
986
|
if (!showAnim) { postProcess(); }
|
983
987
|
|
@@ -997,7 +1001,7 @@ $.timepicker._timepickerShowing && !($.timepicker._inDialog && $.blockUI))
|
|
997
1001
|
if (onClose) {
|
998
1002
|
onClose.apply(
|
999
1003
|
(inst.input ? inst.input[0] : null),
|
1000
|
-
|
1004
|
+
[(inst.input ? inst.input.val() : ''), inst]); // trigger custom callback
|
1001
1005
|
}
|
1002
1006
|
|
1003
1007
|
}
|
@@ -1011,9 +1015,9 @@ $.timepicker._timepickerShowing && !($.timepicker._inDialog && $.blockUI))
|
|
1011
1015
|
},
|
1012
1016
|
|
1013
1017
|
/* Retrieve the instance data for the target control.
|
1014
|
-
@param
|
1015
|
-
@return
|
1016
|
-
@throws
|
1018
|
+
@param target element - the target input field or division or span
|
1019
|
+
@return object - the associated instance data
|
1020
|
+
@throws error if a jQuery problem getting data */
|
1017
1021
|
_getInst: function (target) {
|
1018
1022
|
try {
|
1019
1023
|
return $.data(target, PROP_NAME);
|
@@ -1026,7 +1030,7 @@ $.timepicker._timepickerShowing && !($.timepicker._inDialog && $.blockUI))
|
|
1026
1030
|
/* Get a setting value, defaulting if necessary. */
|
1027
1031
|
_get: function (inst, name) {
|
1028
1032
|
return inst.settings[name] !== undefined ?
|
1029
|
-
inst.settings[name] : this._defaults[name];
|
1033
|
+
inst.settings[name] : this._defaults[name];
|
1030
1034
|
},
|
1031
1035
|
|
1032
1036
|
/* Parse existing time and initialise time picker. */
|
@@ -1057,13 +1061,13 @@ inst.settings[name] : this._defaults[name];
|
|
1057
1061
|
},
|
1058
1062
|
|
1059
1063
|
/* Update or retrieve the settings for an existing time picker.
|
1060
|
-
@param
|
1061
|
-
@param
|
1062
|
-
string - the name of the setting to change or retrieve,
|
1063
|
-
when retrieving also 'all' for all instance settings or
|
1064
|
-
'defaults' for all global defaults
|
1065
|
-
@param
|
1066
|
-
(omit if above is an object or to retrieve a value) */
|
1064
|
+
@param target element - the target input field or division or span
|
1065
|
+
@param name object - the new settings to update or
|
1066
|
+
string - the name of the setting to change or retrieve,
|
1067
|
+
when retrieving also 'all' for all instance settings or
|
1068
|
+
'defaults' for all global defaults
|
1069
|
+
@param value any - the new value for the setting
|
1070
|
+
(omit if above is an object or to retrieve a value) */
|
1067
1071
|
_optionTimepicker: function(target, name, value) {
|
1068
1072
|
var inst = this._getInst(target);
|
1069
1073
|
if (arguments.length == 2 && typeof name == 'string') {
|
@@ -1087,16 +1091,16 @@ when retrieving also 'all' for all instance settings or
|
|
1087
1091
|
|
1088
1092
|
|
1089
1093
|
/* Set the time for a jQuery selection.
|
1090
|
-
@param
|
1091
|
-
@param
|
1092
|
-
_setTimeTimepicker: function(target, time) {
|
1093
|
-
var inst = this._getInst(target);
|
1094
|
-
if (inst) {
|
1095
|
-
this._setTime(inst, time);
|
1096
|
-
|
1097
|
-
this._updateAlternate(inst, time);
|
1098
|
-
}
|
1099
|
-
},
|
1094
|
+
@param target element - the target input field or division or span
|
1095
|
+
@param time String - the new time */
|
1096
|
+
_setTimeTimepicker: function(target, time) {
|
1097
|
+
var inst = this._getInst(target);
|
1098
|
+
if (inst) {
|
1099
|
+
this._setTime(inst, time);
|
1100
|
+
this._updateTimepicker(inst);
|
1101
|
+
this._updateAlternate(inst, time);
|
1102
|
+
}
|
1103
|
+
},
|
1100
1104
|
|
1101
1105
|
/* Set the time directly. */
|
1102
1106
|
_setTime: function(inst, time, noChange) {
|
@@ -1129,8 +1133,8 @@ this._updateAlternate(inst, time);
|
|
1129
1133
|
},
|
1130
1134
|
|
1131
1135
|
/*
|
1132
|
-
* Parse a time string into hours and minutes
|
1133
|
-
*/
|
1136
|
+
* Parse a time string into hours and minutes
|
1137
|
+
*/
|
1134
1138
|
parseTime: function (inst, timeVal) {
|
1135
1139
|
var retVal = new Object();
|
1136
1140
|
retVal.hours = -1;
|
@@ -1218,7 +1222,7 @@ this._updateAlternate(inst, time);
|
|
1218
1222
|
// added for onMinuteShow callback
|
1219
1223
|
var onMinuteShow = this._get(inst, 'onMinuteShow');
|
1220
1224
|
if (onMinuteShow) {
|
1221
|
-
// this will trigger a callback on selected hour to make sure selected minute is allowed.
|
1225
|
+
// this will trigger a callback on selected hour to make sure selected minute is allowed.
|
1222
1226
|
this._updateMinuteDisplay(inst);
|
1223
1227
|
}
|
1224
1228
|
|
@@ -1301,7 +1305,7 @@ this._updateAlternate(inst, time);
|
|
1301
1305
|
if (displayHours == -1) { displayHours = 0 }
|
1302
1306
|
if (selectedMinutes == -1) { selectedMinutes = 0 }
|
1303
1307
|
|
1304
|
-
if (showPeriod) {
|
1308
|
+
if (showPeriod) {
|
1305
1309
|
if (inst.hours == 0) {
|
1306
1310
|
displayHours = 12;
|
1307
1311
|
}
|
@@ -1383,15 +1387,15 @@ this._updateAlternate(inst, time);
|
|
1383
1387
|
|
1384
1388
|
|
1385
1389
|
/* Invoke the timepicker functionality.
|
1386
|
-
@param
|
1387
|
-
Object - settings for attaching new timepicker functionality
|
1388
|
-
@return
|
1390
|
+
@param options string - a command, optionally followed by additional parameters or
|
1391
|
+
Object - settings for attaching new timepicker functionality
|
1392
|
+
@return jQuery object */
|
1389
1393
|
$.fn.timepicker = function (options) {
|
1390
1394
|
|
1391
1395
|
/* Initialise the time picker. */
|
1392
1396
|
if (!$.timepicker.initialized) {
|
1393
1397
|
$(document).mousedown($.timepicker._checkExternalClick).
|
1394
|
-
find('body').append($.timepicker.tpDiv);
|
1398
|
+
find('body').append($.timepicker.tpDiv);
|
1395
1399
|
$.timepicker.initialized = true;
|
1396
1400
|
}
|
1397
1401
|
|
@@ -1400,15 +1404,15 @@ find('body').append($.timepicker.tpDiv);
|
|
1400
1404
|
var otherArgs = Array.prototype.slice.call(arguments, 1);
|
1401
1405
|
if (typeof options == 'string' && (options == 'getTime' || options == 'getTimeAsDate' || options == 'getHour' || options == 'getMinute' ))
|
1402
1406
|
return $.timepicker['_' + options + 'Timepicker'].
|
1403
|
-
apply($.timepicker, [this[0]].concat(otherArgs));
|
1407
|
+
apply($.timepicker, [this[0]].concat(otherArgs));
|
1404
1408
|
if (options == 'option' && arguments.length == 2 && typeof arguments[1] == 'string')
|
1405
1409
|
return $.timepicker['_' + options + 'Timepicker'].
|
1406
1410
|
apply($.timepicker, [this[0]].concat(otherArgs));
|
1407
1411
|
return this.each(function () {
|
1408
1412
|
typeof options == 'string' ?
|
1409
|
-
$.timepicker['_' + options + 'Timepicker'].
|
1410
|
-
apply($.timepicker, [this].concat(otherArgs)) :
|
1411
|
-
$.timepicker._attachTimepicker(this, options);
|
1413
|
+
$.timepicker['_' + options + 'Timepicker'].
|
1414
|
+
apply($.timepicker, [this].concat(otherArgs)) :
|
1415
|
+
$.timepicker._attachTimepicker(this, options);
|
1412
1416
|
});
|
1413
1417
|
};
|
1414
1418
|
|
@@ -1424,7 +1428,7 @@ $.timepicker._attachTimepicker(this, options);
|
|
1424
1428
|
$.timepicker = new Timepicker(); // singleton instance
|
1425
1429
|
$.timepicker.initialized = false;
|
1426
1430
|
$.timepicker.uuid = new Date().getTime();
|
1427
|
-
$.timepicker.version = "0.3.
|
1431
|
+
$.timepicker.version = "0.3.2";
|
1428
1432
|
|
1429
1433
|
// Workaround for #4055
|
1430
1434
|
// Add another global to avoid noConflict issues with inline event handlers
|