www-thermferm/js/jquery-ui-timepicker-addon.js

Tue, 08 Jul 2014 23:53:04 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Tue, 08 Jul 2014 23:53:04 +0200
changeset 97
4a9dbee41a6c
permissions
-rw-r--r--

Added initial set for the thermferm web interface

97
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 /*
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2 * jQuery timepicker addon
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3 * By: Trent Richardson [http://trentrichardson.com]
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4 * Version 1.3.1
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5 * Last Modified: 07/07/2013
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6 *
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7 * Copyright 2013 Trent Richardson
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8 * You may use this project under MIT or GPL licenses.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9 * http://trentrichardson.com/Impromptu/GPL-LICENSE.txt
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10 * http://trentrichardson.com/Impromptu/MIT-LICENSE.txt
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13 /*jslint evil: true, white: false, undef: false, nomen: false */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
15 (function($) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
16
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
17 /*
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
18 * Lets not redefine timepicker, Prevent "Uncaught RangeError: Maximum call stack size exceeded"
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
19 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
20 $.ui.timepicker = $.ui.timepicker || {};
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
21 if ($.ui.timepicker.version) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
22 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
23 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
24
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
25 /*
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
26 * Extend jQueryUI, get it started with our version number
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
27 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
28 $.extend($.ui, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
29 timepicker: {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
30 version: "1.3.1"
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
31 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
32 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
33
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
34 /*
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
35 * Timepicker manager.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
36 * Use the singleton instance of this class, $.timepicker, to interact with the time picker.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
37 * Settings for (groups of) time pickers are maintained in an instance object,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
38 * allowing multiple different settings on the same page.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
39 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
40 var Timepicker = function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
41 this.regional = []; // Available regional settings, indexed by language code
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
42 this.regional[''] = { // Default regional settings
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
43 currentText: 'Now',
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
44 closeText: 'Done',
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
45 amNames: ['AM', 'A'],
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
46 pmNames: ['PM', 'P'],
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
47 timeFormat: 'HH:mm',
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
48 timeSuffix: '',
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
49 timeOnlyTitle: 'Choose Time',
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
50 timeText: 'Time',
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
51 hourText: 'Hour',
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
52 minuteText: 'Minute',
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
53 secondText: 'Second',
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
54 millisecText: 'Millisecond',
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
55 microsecText: 'Microsecond',
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
56 timezoneText: 'Time Zone',
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
57 isRTL: false
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
58 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
59 this._defaults = { // Global defaults for all the datetime picker instances
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
60 showButtonPanel: true,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
61 timeOnly: false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
62 showHour: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
63 showMinute: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
64 showSecond: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
65 showMillisec: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
66 showMicrosec: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
67 showTimezone: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
68 showTime: true,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
69 stepHour: 1,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
70 stepMinute: 1,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
71 stepSecond: 1,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
72 stepMillisec: 1,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
73 stepMicrosec: 1,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
74 hour: 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
75 minute: 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
76 second: 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
77 millisec: 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
78 microsec: 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
79 timezone: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
80 hourMin: 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
81 minuteMin: 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
82 secondMin: 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
83 millisecMin: 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
84 microsecMin: 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
85 hourMax: 23,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
86 minuteMax: 59,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
87 secondMax: 59,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
88 millisecMax: 999,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
89 microsecMax: 999,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
90 minDateTime: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
91 maxDateTime: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
92 onSelect: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
93 hourGrid: 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
94 minuteGrid: 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
95 secondGrid: 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
96 millisecGrid: 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
97 microsecGrid: 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
98 alwaysSetTime: true,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
99 separator: ' ',
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
100 altFieldTimeOnly: true,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
101 altTimeFormat: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
102 altSeparator: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
103 altTimeSuffix: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
104 pickerTimeFormat: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
105 pickerTimeSuffix: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
106 showTimepicker: true,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
107 timezoneList: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
108 addSliderAccess: false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
109 sliderAccessArgs: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
110 controlType: 'slider',
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
111 defaultValue: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
112 parse: 'strict'
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
113 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
114 $.extend(this._defaults, this.regional['']);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
115 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
116
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
117 $.extend(Timepicker.prototype, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
118 $input: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
119 $altInput: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
120 $timeObj: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
121 inst: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
122 hour_slider: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
123 minute_slider: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
124 second_slider: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
125 millisec_slider: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
126 microsec_slider: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
127 timezone_select: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
128 hour: 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
129 minute: 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
130 second: 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
131 millisec: 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
132 microsec: 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
133 timezone: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
134 hourMinOriginal: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
135 minuteMinOriginal: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
136 secondMinOriginal: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
137 millisecMinOriginal: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
138 microsecMinOriginal: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
139 hourMaxOriginal: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
140 minuteMaxOriginal: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
141 secondMaxOriginal: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
142 millisecMaxOriginal: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
143 microsecMaxOriginal: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
144 ampm: '',
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
145 formattedDate: '',
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
146 formattedTime: '',
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
147 formattedDateTime: '',
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
148 timezoneList: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
149 units: ['hour','minute','second','millisec', 'microsec'],
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
150 support: {},
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
151 control: null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
152
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
153 /*
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
154 * Override the default settings for all instances of the time picker.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
155 * @param settings object - the new settings to use as defaults (anonymous object)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
156 * @return the manager object
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
157 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
158 setDefaults: function(settings) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
159 extendRemove(this._defaults, settings || {});
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
160 return this;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
161 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
162
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
163 /*
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
164 * Create a new Timepicker instance
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
165 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
166 _newInst: function($input, opts) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
167 var tp_inst = new Timepicker(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
168 inlineSettings = {},
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
169 fns = {},
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
170 overrides, i;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
171
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
172 for (var attrName in this._defaults) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
173 if(this._defaults.hasOwnProperty(attrName)){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
174 var attrValue = $input.attr('time:' + attrName);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
175 if (attrValue) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
176 try {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
177 inlineSettings[attrName] = eval(attrValue);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
178 } catch (err) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
179 inlineSettings[attrName] = attrValue;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
180 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
181 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
182 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
183 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
184
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
185 overrides = {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
186 beforeShow: function (input, dp_inst) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
187 if ($.isFunction(tp_inst._defaults.evnts.beforeShow)) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
188 return tp_inst._defaults.evnts.beforeShow.call($input[0], input, dp_inst, tp_inst);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
189 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
190 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
191 onChangeMonthYear: function (year, month, dp_inst) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
192 // Update the time as well : this prevents the time from disappearing from the $input field.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
193 tp_inst._updateDateTime(dp_inst);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
194 if ($.isFunction(tp_inst._defaults.evnts.onChangeMonthYear)) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
195 tp_inst._defaults.evnts.onChangeMonthYear.call($input[0], year, month, dp_inst, tp_inst);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
196 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
197 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
198 onClose: function (dateText, dp_inst) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
199 if (tp_inst.timeDefined === true && $input.val() !== '') {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
200 tp_inst._updateDateTime(dp_inst);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
201 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
202 if ($.isFunction(tp_inst._defaults.evnts.onClose)) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
203 tp_inst._defaults.evnts.onClose.call($input[0], dateText, dp_inst, tp_inst);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
204 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
205 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
206 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
207 for (i in overrides) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
208 if (overrides.hasOwnProperty(i)) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
209 fns[i] = opts[i] || null;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
210 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
211 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
212
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
213 tp_inst._defaults = $.extend({}, this._defaults, inlineSettings, opts, overrides, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
214 evnts:fns,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
215 timepicker: tp_inst // add timepicker as a property of datepicker: $.datepicker._get(dp_inst, 'timepicker');
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
216 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
217 tp_inst.amNames = $.map(tp_inst._defaults.amNames, function(val) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
218 return val.toUpperCase();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
219 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
220 tp_inst.pmNames = $.map(tp_inst._defaults.pmNames, function(val) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
221 return val.toUpperCase();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
222 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
223
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
224 // detect which units are supported
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
225 tp_inst.support = detectSupport(
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
226 tp_inst._defaults.timeFormat +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
227 (tp_inst._defaults.pickerTimeFormat? tp_inst._defaults.pickerTimeFormat:'') +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
228 (tp_inst._defaults.altTimeFormat? tp_inst._defaults.altTimeFormat:''));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
229
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
230 // controlType is string - key to our this._controls
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
231 if(typeof(tp_inst._defaults.controlType) === 'string'){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
232 if(tp_inst._defaults.controlType == 'slider' && typeof(jQuery.ui.slider) === 'undefined'){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
233 tp_inst._defaults.controlType = 'select';
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
234 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
235 tp_inst.control = tp_inst._controls[tp_inst._defaults.controlType];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
236 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
237 // controlType is an object and must implement create, options, value methods
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
238 else{
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
239 tp_inst.control = tp_inst._defaults.controlType;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
240 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
241
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
242 // prep the timezone options
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
243 var timezoneList = [-720,-660,-600,-570,-540,-480,-420,-360,-300,-270,-240,-210,-180,-120,-60,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
244 0,60,120,180,210,240,270,300,330,345,360,390,420,480,525,540,570,600,630,660,690,720,765,780,840];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
245 if (tp_inst._defaults.timezoneList !== null) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
246 timezoneList = tp_inst._defaults.timezoneList;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
247 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
248 var tzl=timezoneList.length,tzi=0,tzv=null;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
249 if (tzl > 0 && typeof timezoneList[0] !== 'object') {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
250 for(; tzi<tzl; tzi++){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
251 tzv = timezoneList[tzi];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
252 timezoneList[tzi] = { value: tzv, label: $.timepicker.timezoneOffsetString(tzv, tp_inst.support.iso8601) };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
253 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
254 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
255 tp_inst._defaults.timezoneList = timezoneList;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
256
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
257 // set the default units
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
258 tp_inst.timezone = tp_inst._defaults.timezone !== null? $.timepicker.timezoneOffsetNumber(tp_inst._defaults.timezone) :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
259 ((new Date()).getTimezoneOffset()*-1);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
260 tp_inst.hour = tp_inst._defaults.hour < tp_inst._defaults.hourMin? tp_inst._defaults.hourMin :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
261 tp_inst._defaults.hour > tp_inst._defaults.hourMax? tp_inst._defaults.hourMax : tp_inst._defaults.hour;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
262 tp_inst.minute = tp_inst._defaults.minute < tp_inst._defaults.minuteMin? tp_inst._defaults.minuteMin :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
263 tp_inst._defaults.minute > tp_inst._defaults.minuteMax? tp_inst._defaults.minuteMax : tp_inst._defaults.minute;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
264 tp_inst.second = tp_inst._defaults.second < tp_inst._defaults.secondMin? tp_inst._defaults.secondMin :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
265 tp_inst._defaults.second > tp_inst._defaults.secondMax? tp_inst._defaults.secondMax : tp_inst._defaults.second;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
266 tp_inst.millisec = tp_inst._defaults.millisec < tp_inst._defaults.millisecMin? tp_inst._defaults.millisecMin :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
267 tp_inst._defaults.millisec > tp_inst._defaults.millisecMax? tp_inst._defaults.millisecMax : tp_inst._defaults.millisec;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
268 tp_inst.microsec = tp_inst._defaults.microsec < tp_inst._defaults.microsecMin? tp_inst._defaults.microsecMin :
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
269 tp_inst._defaults.microsec > tp_inst._defaults.microsecMax? tp_inst._defaults.microsecMax : tp_inst._defaults.microsec;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
270 tp_inst.ampm = '';
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
271 tp_inst.$input = $input;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
272
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
273 if (tp_inst._defaults.altField) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
274 tp_inst.$altInput = $(tp_inst._defaults.altField).css({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
275 cursor: 'pointer'
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
276 }).focus(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
277 $input.trigger("focus");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
278 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
279 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
280
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
281 if (tp_inst._defaults.minDate === 0 || tp_inst._defaults.minDateTime === 0) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
282 tp_inst._defaults.minDate = new Date();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
283 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
284 if (tp_inst._defaults.maxDate === 0 || tp_inst._defaults.maxDateTime === 0) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
285 tp_inst._defaults.maxDate = new Date();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
286 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
287
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
288 // datepicker needs minDate/maxDate, timepicker needs minDateTime/maxDateTime..
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
289 if (tp_inst._defaults.minDate !== undefined && tp_inst._defaults.minDate instanceof Date) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
290 tp_inst._defaults.minDateTime = new Date(tp_inst._defaults.minDate.getTime());
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
291 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
292 if (tp_inst._defaults.minDateTime !== undefined && tp_inst._defaults.minDateTime instanceof Date) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
293 tp_inst._defaults.minDate = new Date(tp_inst._defaults.minDateTime.getTime());
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
294 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
295 if (tp_inst._defaults.maxDate !== undefined && tp_inst._defaults.maxDate instanceof Date) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
296 tp_inst._defaults.maxDateTime = new Date(tp_inst._defaults.maxDate.getTime());
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
297 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
298 if (tp_inst._defaults.maxDateTime !== undefined && tp_inst._defaults.maxDateTime instanceof Date) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
299 tp_inst._defaults.maxDate = new Date(tp_inst._defaults.maxDateTime.getTime());
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
300 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
301 tp_inst.$input.bind('focus', function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
302 tp_inst._onFocus();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
303 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
304
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
305 return tp_inst;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
306 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
307
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
308 /*
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
309 * add our sliders to the calendar
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
310 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
311 _addTimePicker: function(dp_inst) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
312 var currDT = (this.$altInput && this._defaults.altFieldTimeOnly) ? this.$input.val() + ' ' + this.$altInput.val() : this.$input.val();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
313
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
314 this.timeDefined = this._parseTime(currDT);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
315 this._limitMinMaxDateTime(dp_inst, false);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
316 this._injectTimePicker();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
317 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
318
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
319 /*
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
320 * parse the time string from input value or _setTime
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
321 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
322 _parseTime: function(timeString, withDate) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
323 if (!this.inst) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
324 this.inst = $.datepicker._getInst(this.$input[0]);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
325 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
326
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
327 if (withDate || !this._defaults.timeOnly) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
328 var dp_dateFormat = $.datepicker._get(this.inst, 'dateFormat');
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
329 try {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
330 var parseRes = parseDateTimeInternal(dp_dateFormat, this._defaults.timeFormat, timeString, $.datepicker._getFormatConfig(this.inst), this._defaults);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
331 if (!parseRes.timeObj) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
332 return false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
333 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
334 $.extend(this, parseRes.timeObj);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
335 } catch (err) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
336 $.timepicker.log("Error parsing the date/time string: " + err +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
337 "\ndate/time string = " + timeString +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
338 "\ntimeFormat = " + this._defaults.timeFormat +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
339 "\ndateFormat = " + dp_dateFormat);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
340 return false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
341 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
342 return true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
343 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
344 var timeObj = $.datepicker.parseTime(this._defaults.timeFormat, timeString, this._defaults);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
345 if (!timeObj) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
346 return false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
347 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
348 $.extend(this, timeObj);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
349 return true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
350 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
351 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
352
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
353 /*
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
354 * generate and inject html for timepicker into ui datepicker
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
355 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
356 _injectTimePicker: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
357 var $dp = this.inst.dpDiv,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
358 o = this.inst.settings,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
359 tp_inst = this,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
360 litem = '',
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
361 uitem = '',
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
362 show = null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
363 max = {},
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
364 gridSize = {},
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
365 size = null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
366 i=0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
367 l=0;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
368
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
369 // Prevent displaying twice
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
370 if ($dp.find("div.ui-timepicker-div").length === 0 && o.showTimepicker) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
371 var noDisplay = ' style="display:none;"',
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
372 html = '<div class="ui-timepicker-div'+ (o.isRTL? ' ui-timepicker-rtl' : '') +'"><dl>' + '<dt class="ui_tpicker_time_label"' + ((o.showTime) ? '' : noDisplay) + '>' + o.timeText + '</dt>' +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
373 '<dd class="ui_tpicker_time"' + ((o.showTime) ? '' : noDisplay) + '></dd>';
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
374
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
375 // Create the markup
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
376 for(i=0,l=this.units.length; i<l; i++){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
377 litem = this.units[i];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
378 uitem = litem.substr(0,1).toUpperCase() + litem.substr(1);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
379 show = o['show'+uitem] !== null? o['show'+uitem] : this.support[litem];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
380
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
381 // Added by Peter Medeiros:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
382 // - Figure out what the hour/minute/second max should be based on the step values.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
383 // - Example: if stepMinute is 15, then minMax is 45.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
384 max[litem] = parseInt((o[litem+'Max'] - ((o[litem+'Max'] - o[litem+'Min']) % o['step'+uitem])), 10);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
385 gridSize[litem] = 0;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
386
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
387 html += '<dt class="ui_tpicker_'+ litem +'_label"' + (show ? '' : noDisplay) + '>' + o[litem +'Text'] + '</dt>' +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
388 '<dd class="ui_tpicker_'+ litem +'"><div class="ui_tpicker_'+ litem +'_slider"' + (show ? '' : noDisplay) + '></div>';
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
389
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
390 if (show && o[litem+'Grid'] > 0) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
391 html += '<div style="padding-left: 1px"><table class="ui-tpicker-grid-label"><tr>';
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
392
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
393 if(litem == 'hour'){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
394 for (var h = o[litem+'Min']; h <= max[litem]; h += parseInt(o[litem+'Grid'], 10)) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
395 gridSize[litem]++;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
396 var tmph = $.datepicker.formatTime(this.support.ampm? 'hht':'HH', {hour:h}, o);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
397 html += '<td data-for="'+litem+'">' + tmph + '</td>';
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
398 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
399 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
400 else{
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
401 for (var m = o[litem+'Min']; m <= max[litem]; m += parseInt(o[litem+'Grid'], 10)) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
402 gridSize[litem]++;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
403 html += '<td data-for="'+litem+'">' + ((m < 10) ? '0' : '') + m + '</td>';
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
404 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
405 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
406
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
407 html += '</tr></table></div>';
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
408 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
409 html += '</dd>';
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
410 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
411
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
412 // Timezone
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
413 var showTz = o.showTimezone !== null? o.showTimezone : this.support.timezone;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
414 html += '<dt class="ui_tpicker_timezone_label"' + (showTz ? '' : noDisplay) + '>' + o.timezoneText + '</dt>';
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
415 html += '<dd class="ui_tpicker_timezone" ' + (showTz ? '' : noDisplay) + '></dd>';
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
416
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
417 // Create the elements from string
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
418 html += '</dl></div>';
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
419 var $tp = $(html);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
420
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
421 // if we only want time picker...
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
422 if (o.timeOnly === true) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
423 $tp.prepend('<div class="ui-widget-header ui-helper-clearfix ui-corner-all">' + '<div class="ui-datepicker-title">' + o.timeOnlyTitle + '</div>' + '</div>');
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
424 $dp.find('.ui-datepicker-header, .ui-datepicker-calendar').hide();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
425 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
426
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
427 // add sliders, adjust grids, add events
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
428 for(i=0,l=tp_inst.units.length; i<l; i++){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
429 litem = tp_inst.units[i];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
430 uitem = litem.substr(0,1).toUpperCase() + litem.substr(1);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
431 show = o['show'+uitem] !== null? o['show'+uitem] : this.support[litem];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
432
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
433 // add the slider
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
434 tp_inst[litem+'_slider'] = tp_inst.control.create(tp_inst, $tp.find('.ui_tpicker_'+litem+'_slider'), litem, tp_inst[litem], o[litem+'Min'], max[litem], o['step'+uitem]);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
435
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
436 // adjust the grid and add click event
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
437 if (show && o[litem+'Grid'] > 0) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
438 size = 100 * gridSize[litem] * o[litem+'Grid'] / (max[litem] - o[litem+'Min']);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
439 $tp.find('.ui_tpicker_'+litem+' table').css({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
440 width: size + "%",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
441 marginLeft: o.isRTL? '0' : ((size / (-2 * gridSize[litem])) + "%"),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
442 marginRight: o.isRTL? ((size / (-2 * gridSize[litem])) + "%") : '0',
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
443 borderCollapse: 'collapse'
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
444 }).find("td").click(function(e){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
445 var $t = $(this),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
446 h = $t.html(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
447 n = parseInt(h.replace(/[^0-9]/g),10),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
448 ap = h.replace(/[^apm]/ig),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
449 f = $t.data('for'); // loses scope, so we use data-for
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
450
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
451 if(f == 'hour'){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
452 if(ap.indexOf('p') !== -1 && n < 12){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
453 n += 12;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
454 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
455 else{
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
456 if(ap.indexOf('a') !== -1 && n === 12){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
457 n = 0;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
458 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
459 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
460 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
461
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
462 tp_inst.control.value(tp_inst, tp_inst[f+'_slider'], litem, n);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
463
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
464 tp_inst._onTimeChange();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
465 tp_inst._onSelectHandler();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
466 }).css({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
467 cursor: 'pointer',
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
468 width: (100 / gridSize[litem]) + '%',
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
469 textAlign: 'center',
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
470 overflow: 'hidden'
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
471 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
472 } // end if grid > 0
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
473 } // end for loop
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
474
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
475 // Add timezone options
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
476 this.timezone_select = $tp.find('.ui_tpicker_timezone').append('<select></select>').find("select");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
477 $.fn.append.apply(this.timezone_select,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
478 $.map(o.timezoneList, function(val, idx) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
479 return $("<option />").val(typeof val == "object" ? val.value : val).text(typeof val == "object" ? val.label : val);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
480 }));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
481 if (typeof(this.timezone) != "undefined" && this.timezone !== null && this.timezone !== "") {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
482 var local_timezone = (new Date(this.inst.selectedYear, this.inst.selectedMonth, this.inst.selectedDay, 12)).getTimezoneOffset()*-1;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
483 if (local_timezone == this.timezone) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
484 selectLocalTimezone(tp_inst);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
485 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
486 this.timezone_select.val(this.timezone);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
487 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
488 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
489 if (typeof(this.hour) != "undefined" && this.hour !== null && this.hour !== "") {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
490 this.timezone_select.val(o.timezone);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
491 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
492 selectLocalTimezone(tp_inst);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
493 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
494 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
495 this.timezone_select.change(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
496 tp_inst._onTimeChange();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
497 tp_inst._onSelectHandler();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
498 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
499 // End timezone options
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
500
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
501 // inject timepicker into datepicker
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
502 var $buttonPanel = $dp.find('.ui-datepicker-buttonpane');
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
503 if ($buttonPanel.length) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
504 $buttonPanel.before($tp);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
505 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
506 $dp.append($tp);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
507 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
508
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
509 this.$timeObj = $tp.find('.ui_tpicker_time');
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
510
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
511 if (this.inst !== null) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
512 var timeDefined = this.timeDefined;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
513 this._onTimeChange();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
514 this.timeDefined = timeDefined;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
515 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
516
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
517 // slideAccess integration: http://trentrichardson.com/2011/11/11/jquery-ui-sliders-and-touch-accessibility/
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
518 if (this._defaults.addSliderAccess) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
519 var sliderAccessArgs = this._defaults.sliderAccessArgs,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
520 rtl = this._defaults.isRTL;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
521 sliderAccessArgs.isRTL = rtl;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
522
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
523 setTimeout(function() { // fix for inline mode
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
524 if ($tp.find('.ui-slider-access').length === 0) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
525 $tp.find('.ui-slider:visible').sliderAccess(sliderAccessArgs);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
526
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
527 // fix any grids since sliders are shorter
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
528 var sliderAccessWidth = $tp.find('.ui-slider-access:eq(0)').outerWidth(true);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
529 if (sliderAccessWidth) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
530 $tp.find('table:visible').each(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
531 var $g = $(this),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
532 oldWidth = $g.outerWidth(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
533 oldMarginLeft = $g.css(rtl? 'marginRight':'marginLeft').toString().replace('%', ''),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
534 newWidth = oldWidth - sliderAccessWidth,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
535 newMarginLeft = ((oldMarginLeft * newWidth) / oldWidth) + '%',
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
536 css = { width: newWidth, marginRight: 0, marginLeft: 0 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
537 css[rtl? 'marginRight':'marginLeft'] = newMarginLeft;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
538 $g.css(css);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
539 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
540 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
541 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
542 }, 10);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
543 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
544 // end slideAccess integration
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
545
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
546 tp_inst._limitMinMaxDateTime(this.inst, true);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
547 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
548 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
549
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
550 /*
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
551 * This function tries to limit the ability to go outside the
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
552 * min/max date range
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
553 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
554 _limitMinMaxDateTime: function(dp_inst, adjustSliders) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
555 var o = this._defaults,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
556 dp_date = new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
557
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
558 if (!this._defaults.showTimepicker) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
559 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
560 } // No time so nothing to check here
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
561
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
562 if ($.datepicker._get(dp_inst, 'minDateTime') !== null && $.datepicker._get(dp_inst, 'minDateTime') !== undefined && dp_date) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
563 var minDateTime = $.datepicker._get(dp_inst, 'minDateTime'),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
564 minDateTimeDate = new Date(minDateTime.getFullYear(), minDateTime.getMonth(), minDateTime.getDate(), 0, 0, 0, 0);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
565
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
566 if (this.hourMinOriginal === null || this.minuteMinOriginal === null || this.secondMinOriginal === null || this.millisecMinOriginal === null || this.microsecMinOriginal === null) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
567 this.hourMinOriginal = o.hourMin;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
568 this.minuteMinOriginal = o.minuteMin;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
569 this.secondMinOriginal = o.secondMin;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
570 this.millisecMinOriginal = o.millisecMin;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
571 this.microsecMinOriginal = o.microsecMin;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
572 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
573
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
574 if (dp_inst.settings.timeOnly || minDateTimeDate.getTime() == dp_date.getTime()) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
575 this._defaults.hourMin = minDateTime.getHours();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
576 if (this.hour <= this._defaults.hourMin) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
577 this.hour = this._defaults.hourMin;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
578 this._defaults.minuteMin = minDateTime.getMinutes();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
579 if (this.minute <= this._defaults.minuteMin) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
580 this.minute = this._defaults.minuteMin;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
581 this._defaults.secondMin = minDateTime.getSeconds();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
582 if (this.second <= this._defaults.secondMin) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
583 this.second = this._defaults.secondMin;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
584 this._defaults.millisecMin = minDateTime.getMilliseconds();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
585 if(this.millisec <= this._defaults.millisecMin) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
586 this.millisec = this._defaults.millisecMin;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
587 this._defaults.microsecMin = minDateTime.getMicroseconds();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
588 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
589 if (this.microsec < this._defaults.microsecMin) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
590 this.microsec = this._defaults.microsecMin;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
591 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
592 this._defaults.microsecMin = this.microsecMinOriginal;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
593 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
594 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
595 this._defaults.millisecMin = this.millisecMinOriginal;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
596 this._defaults.microsecMin = this.microsecMinOriginal;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
597 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
598 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
599 this._defaults.secondMin = this.secondMinOriginal;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
600 this._defaults.millisecMin = this.millisecMinOriginal;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
601 this._defaults.microsecMin = this.microsecMinOriginal;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
602 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
603 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
604 this._defaults.minuteMin = this.minuteMinOriginal;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
605 this._defaults.secondMin = this.secondMinOriginal;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
606 this._defaults.millisecMin = this.millisecMinOriginal;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
607 this._defaults.microsecMin = this.microsecMinOriginal;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
608 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
609 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
610 this._defaults.hourMin = this.hourMinOriginal;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
611 this._defaults.minuteMin = this.minuteMinOriginal;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
612 this._defaults.secondMin = this.secondMinOriginal;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
613 this._defaults.millisecMin = this.millisecMinOriginal;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
614 this._defaults.microsecMin = this.microsecMinOriginal;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
615 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
616 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
617
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
618 if ($.datepicker._get(dp_inst, 'maxDateTime') !== null && $.datepicker._get(dp_inst, 'maxDateTime') !== undefined && dp_date) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
619 var maxDateTime = $.datepicker._get(dp_inst, 'maxDateTime'),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
620 maxDateTimeDate = new Date(maxDateTime.getFullYear(), maxDateTime.getMonth(), maxDateTime.getDate(), 0, 0, 0, 0);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
621
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
622 if (this.hourMaxOriginal === null || this.minuteMaxOriginal === null || this.secondMaxOriginal === null || this.millisecMaxOriginal === null) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
623 this.hourMaxOriginal = o.hourMax;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
624 this.minuteMaxOriginal = o.minuteMax;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
625 this.secondMaxOriginal = o.secondMax;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
626 this.millisecMaxOriginal = o.millisecMax;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
627 this.microsecMaxOriginal = o.microsecMax;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
628 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
629
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
630 if (dp_inst.settings.timeOnly || maxDateTimeDate.getTime() == dp_date.getTime()) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
631 this._defaults.hourMax = maxDateTime.getHours();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
632 if (this.hour >= this._defaults.hourMax) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
633 this.hour = this._defaults.hourMax;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
634 this._defaults.minuteMax = maxDateTime.getMinutes();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
635 if (this.minute >= this._defaults.minuteMax) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
636 this.minute = this._defaults.minuteMax;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
637 this._defaults.secondMax = maxDateTime.getSeconds();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
638 if (this.second >= this._defaults.secondMax) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
639 this.second = this._defaults.secondMax;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
640 this._defaults.millisecMax = maxDateTime.getMilliseconds();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
641 if (this.millisec >= this._defaults.millisecMax) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
642 this.millisec = this._defaults.millisecMax;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
643 this._defaults.microsecMax = maxDateTime.getMicroseconds();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
644 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
645 if (this.microsec > this._defaults.microsecMax) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
646 this.microsec = this._defaults.microsecMax;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
647 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
648 this._defaults.microsecMax = this.microsecMaxOriginal;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
649 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
650 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
651 this._defaults.millisecMax = this.millisecMaxOriginal;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
652 this._defaults.microsecMax = this.microsecMaxOriginal;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
653 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
654 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
655 this._defaults.secondMax = this.secondMaxOriginal;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
656 this._defaults.millisecMax = this.millisecMaxOriginal;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
657 this._defaults.microsecMax = this.microsecMaxOriginal;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
658 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
659 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
660 this._defaults.minuteMax = this.minuteMaxOriginal;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
661 this._defaults.secondMax = this.secondMaxOriginal;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
662 this._defaults.millisecMax = this.millisecMaxOriginal;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
663 this._defaults.microsecMax = this.microsecMaxOriginal;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
664 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
665 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
666 this._defaults.hourMax = this.hourMaxOriginal;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
667 this._defaults.minuteMax = this.minuteMaxOriginal;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
668 this._defaults.secondMax = this.secondMaxOriginal;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
669 this._defaults.millisecMax = this.millisecMaxOriginal;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
670 this._defaults.microsecMax = this.microsecMaxOriginal;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
671 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
672 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
673
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
674 if (adjustSliders !== undefined && adjustSliders === true) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
675 var hourMax = parseInt((this._defaults.hourMax - ((this._defaults.hourMax - this._defaults.hourMin) % this._defaults.stepHour)), 10),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
676 minMax = parseInt((this._defaults.minuteMax - ((this._defaults.minuteMax - this._defaults.minuteMin) % this._defaults.stepMinute)), 10),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
677 secMax = parseInt((this._defaults.secondMax - ((this._defaults.secondMax - this._defaults.secondMin) % this._defaults.stepSecond)), 10),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
678 millisecMax = parseInt((this._defaults.millisecMax - ((this._defaults.millisecMax - this._defaults.millisecMin) % this._defaults.stepMillisec)), 10);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
679 microsecMax = parseInt((this._defaults.microsecMax - ((this._defaults.microsecMax - this._defaults.microsecMin) % this._defaults.stepMicrosec)), 10);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
680
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
681 if (this.hour_slider) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
682 this.control.options(this, this.hour_slider, 'hour', { min: this._defaults.hourMin, max: hourMax });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
683 this.control.value(this, this.hour_slider, 'hour', this.hour - (this.hour % this._defaults.stepHour));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
684 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
685 if (this.minute_slider) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
686 this.control.options(this, this.minute_slider, 'minute', { min: this._defaults.minuteMin, max: minMax });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
687 this.control.value(this, this.minute_slider, 'minute', this.minute - (this.minute % this._defaults.stepMinute));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
688 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
689 if (this.second_slider) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
690 this.control.options(this, this.second_slider, 'second', { min: this._defaults.secondMin, max: secMax });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
691 this.control.value(this, this.second_slider, 'second', this.second - (this.second % this._defaults.stepSecond));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
692 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
693 if (this.millisec_slider) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
694 this.control.options(this, this.millisec_slider, 'millisec', { min: this._defaults.millisecMin, max: millisecMax });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
695 this.control.value(this, this.millisec_slider, 'millisec', this.millisec - (this.millisec % this._defaults.stepMillisec));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
696 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
697 if (this.microsec_slider) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
698 this.control.options(this, this.microsec_slider, 'microsec', { min: this._defaults.microsecMin, max: microsecMax });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
699 this.control.value(this, this.microsec_slider, 'microsec', this.microsec - (this.microsec % this._defaults.stepMicrosec));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
700 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
701 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
702
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
703 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
704
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
705 /*
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
706 * when a slider moves, set the internal time...
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
707 * on time change is also called when the time is updated in the text field
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
708 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
709 _onTimeChange: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
710 var hour = (this.hour_slider) ? this.control.value(this, this.hour_slider, 'hour') : false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
711 minute = (this.minute_slider) ? this.control.value(this, this.minute_slider, 'minute') : false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
712 second = (this.second_slider) ? this.control.value(this, this.second_slider, 'second') : false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
713 millisec = (this.millisec_slider) ? this.control.value(this, this.millisec_slider, 'millisec') : false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
714 microsec = (this.microsec_slider) ? this.control.value(this, this.microsec_slider, 'microsec') : false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
715 timezone = (this.timezone_select) ? this.timezone_select.val() : false,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
716 o = this._defaults,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
717 pickerTimeFormat = o.pickerTimeFormat || o.timeFormat,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
718 pickerTimeSuffix = o.pickerTimeSuffix || o.timeSuffix;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
719
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
720 if (typeof(hour) == 'object') {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
721 hour = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
722 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
723 if (typeof(minute) == 'object') {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
724 minute = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
725 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
726 if (typeof(second) == 'object') {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
727 second = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
728 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
729 if (typeof(millisec) == 'object') {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
730 millisec = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
731 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
732 if (typeof(microsec) == 'object') {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
733 microsec = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
734 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
735 if (typeof(timezone) == 'object') {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
736 timezone = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
737 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
738
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
739 if (hour !== false) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
740 hour = parseInt(hour, 10);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
741 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
742 if (minute !== false) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
743 minute = parseInt(minute, 10);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
744 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
745 if (second !== false) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
746 second = parseInt(second, 10);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
747 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
748 if (millisec !== false) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
749 millisec = parseInt(millisec, 10);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
750 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
751 if (microsec !== false) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
752 microsec = parseInt(microsec, 10);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
753 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
754
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
755 var ampm = o[hour < 12 ? 'amNames' : 'pmNames'][0];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
756
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
757 // If the update was done in the input field, the input field should not be updated.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
758 // If the update was done using the sliders, update the input field.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
759 var hasChanged = (hour != this.hour || minute != this.minute || second != this.second || millisec != this.millisec || microsec != this.microsec
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
760 || (this.ampm.length > 0 && (hour < 12) != ($.inArray(this.ampm.toUpperCase(), this.amNames) !== -1))
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
761 || (this.timezone !== null && timezone != this.timezone));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
762
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
763 if (hasChanged) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
764
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
765 if (hour !== false) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
766 this.hour = hour;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
767 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
768 if (minute !== false) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
769 this.minute = minute;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
770 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
771 if (second !== false) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
772 this.second = second;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
773 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
774 if (millisec !== false) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
775 this.millisec = millisec;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
776 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
777 if (microsec !== false) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
778 this.microsec = microsec;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
779 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
780 if (timezone !== false) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
781 this.timezone = timezone;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
782 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
783
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
784 if (!this.inst) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
785 this.inst = $.datepicker._getInst(this.$input[0]);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
786 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
787
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
788 this._limitMinMaxDateTime(this.inst, true);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
789 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
790 if (this.support.ampm) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
791 this.ampm = ampm;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
792 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
793
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
794 // Updates the time within the timepicker
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
795 this.formattedTime = $.datepicker.formatTime(o.timeFormat, this, o);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
796 if (this.$timeObj) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
797 if(pickerTimeFormat === o.timeFormat){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
798 this.$timeObj.text(this.formattedTime + pickerTimeSuffix);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
799 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
800 else{
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
801 this.$timeObj.text($.datepicker.formatTime(pickerTimeFormat, this, o) + pickerTimeSuffix);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
802 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
803 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
804
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
805 this.timeDefined = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
806 if (hasChanged) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
807 this._updateDateTime();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
808 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
809 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
810
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
811 /*
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
812 * call custom onSelect.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
813 * bind to sliders slidestop, and grid click.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
814 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
815 _onSelectHandler: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
816 var onSelect = this._defaults.onSelect || this.inst.settings.onSelect;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
817 var inputEl = this.$input ? this.$input[0] : null;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
818 if (onSelect && inputEl) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
819 onSelect.apply(inputEl, [this.formattedDateTime, this]);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
820 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
821 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
822
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
823 /*
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
824 * update our input with the new date time..
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
825 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
826 _updateDateTime: function(dp_inst) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
827 dp_inst = this.inst || dp_inst;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
828 //var dt = $.datepicker._daylightSavingAdjust(new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay)),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
829 var dt = $.datepicker._daylightSavingAdjust(new Date(dp_inst.currentYear, dp_inst.currentMonth, dp_inst.currentDay)),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
830 dateFmt = $.datepicker._get(dp_inst, 'dateFormat'),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
831 formatCfg = $.datepicker._getFormatConfig(dp_inst),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
832 timeAvailable = dt !== null && this.timeDefined;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
833 this.formattedDate = $.datepicker.formatDate(dateFmt, (dt === null ? new Date() : dt), formatCfg);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
834 var formattedDateTime = this.formattedDate;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
835
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
836 // if a slider was changed but datepicker doesn't have a value yet, set it
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
837 if(dp_inst.lastVal===""){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
838 dp_inst.currentYear=dp_inst.selectedYear;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
839 dp_inst.currentMonth=dp_inst.selectedMonth;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
840 dp_inst.currentDay=dp_inst.selectedDay;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
841 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
842
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
843 /*
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
844 * remove following lines to force every changes in date picker to change the input value
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
845 * Bug descriptions: when an input field has a default value, and click on the field to pop up the date picker.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
846 * If the user manually empty the value in the input field, the date picker will never change selected value.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
847 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
848 //if (dp_inst.lastVal !== undefined && (dp_inst.lastVal.length > 0 && this.$input.val().length === 0)) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
849 // return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
850 //}
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
851
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
852 if (this._defaults.timeOnly === true) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
853 formattedDateTime = this.formattedTime;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
854 } else if (this._defaults.timeOnly !== true && (this._defaults.alwaysSetTime || timeAvailable)) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
855 formattedDateTime += this._defaults.separator + this.formattedTime + this._defaults.timeSuffix;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
856 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
857
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
858 this.formattedDateTime = formattedDateTime;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
859
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
860 if (!this._defaults.showTimepicker) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
861 this.$input.val(this.formattedDate);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
862 } else if (this.$altInput && this._defaults.timeOnly === false && this._defaults.altFieldTimeOnly === true) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
863 this.$altInput.val(this.formattedTime);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
864 this.$input.val(this.formattedDate);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
865 } else if (this.$altInput) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
866 this.$input.val(formattedDateTime);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
867 var altFormattedDateTime = '',
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
868 altSeparator = this._defaults.altSeparator ? this._defaults.altSeparator : this._defaults.separator,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
869 altTimeSuffix = this._defaults.altTimeSuffix ? this._defaults.altTimeSuffix : this._defaults.timeSuffix;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
870
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
871 if(!this._defaults.timeOnly){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
872 if (this._defaults.altFormat){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
873 altFormattedDateTime = $.datepicker.formatDate(this._defaults.altFormat, (dt === null ? new Date() : dt), formatCfg);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
874 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
875 else{
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
876 altFormattedDateTime = this.formattedDate;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
877 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
878
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
879 if (altFormattedDateTime){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
880 altFormattedDateTime += altSeparator;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
881 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
882 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
883
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
884 if(this._defaults.altTimeFormat){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
885 altFormattedDateTime += $.datepicker.formatTime(this._defaults.altTimeFormat, this, this._defaults) + altTimeSuffix;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
886 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
887 else{
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
888 altFormattedDateTime += this.formattedTime + altTimeSuffix;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
889 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
890 this.$altInput.val(altFormattedDateTime);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
891 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
892 this.$input.val(formattedDateTime);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
893 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
894
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
895 this.$input.trigger("change");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
896 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
897
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
898 _onFocus: function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
899 if (!this.$input.val() && this._defaults.defaultValue) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
900 this.$input.val(this._defaults.defaultValue);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
901 var inst = $.datepicker._getInst(this.$input.get(0)),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
902 tp_inst = $.datepicker._get(inst, 'timepicker');
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
903 if (tp_inst) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
904 if (tp_inst._defaults.timeOnly && (inst.input.val() != inst.lastVal)) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
905 try {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
906 $.datepicker._updateDatepicker(inst);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
907 } catch (err) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
908 $.timepicker.log(err);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
909 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
910 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
911 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
912 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
913 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
914
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
915 /*
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
916 * Small abstraction to control types
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
917 * We can add more, just be sure to follow the pattern: create, options, value
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
918 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
919 _controls: {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
920 // slider methods
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
921 slider: {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
922 create: function(tp_inst, obj, unit, val, min, max, step){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
923 var rtl = tp_inst._defaults.isRTL; // if rtl go -60->0 instead of 0->60
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
924 return obj.prop('slide', null).slider({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
925 orientation: "horizontal",
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
926 value: rtl? val*-1 : val,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
927 min: rtl? max*-1 : min,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
928 max: rtl? min*-1 : max,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
929 step: step,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
930 slide: function(event, ui) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
931 tp_inst.control.value(tp_inst, $(this), unit, rtl? ui.value*-1:ui.value);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
932 tp_inst._onTimeChange();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
933 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
934 stop: function(event, ui) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
935 tp_inst._onSelectHandler();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
936 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
937 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
938 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
939 options: function(tp_inst, obj, unit, opts, val){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
940 if(tp_inst._defaults.isRTL){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
941 if(typeof(opts) == 'string'){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
942 if(opts == 'min' || opts == 'max'){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
943 if(val !== undefined){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
944 return obj.slider(opts, val*-1);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
945 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
946 return Math.abs(obj.slider(opts));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
947 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
948 return obj.slider(opts);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
949 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
950 var min = opts.min,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
951 max = opts.max;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
952 opts.min = opts.max = null;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
953 if(min !== undefined){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
954 opts.max = min * -1;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
955 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
956 if(max !== undefined){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
957 opts.min = max * -1;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
958 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
959 return obj.slider(opts);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
960 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
961 if(typeof(opts) == 'string' && val !== undefined){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
962 return obj.slider(opts, val);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
963 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
964 return obj.slider(opts);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
965 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
966 value: function(tp_inst, obj, unit, val){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
967 if(tp_inst._defaults.isRTL){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
968 if(val !== undefined){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
969 return obj.slider('value', val*-1);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
970 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
971 return Math.abs(obj.slider('value'));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
972 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
973 if(val !== undefined){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
974 return obj.slider('value', val);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
975 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
976 return obj.slider('value');
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
977 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
978 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
979 // select methods
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
980 select: {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
981 create: function(tp_inst, obj, unit, val, min, max, step){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
982 var sel = '<select class="ui-timepicker-select" data-unit="'+ unit +'" data-min="'+ min +'" data-max="'+ max +'" data-step="'+ step +'">',
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
983 format = tp_inst._defaults.pickerTimeFormat || tp_inst._defaults.timeFormat;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
984
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
985 for(var i=min; i<=max; i+=step){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
986 sel += '<option value="'+ i +'"'+ (i==val? ' selected':'') +'>';
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
987 if(unit == 'hour'){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
988 sel += $.datepicker.formatTime($.trim(format.replace(/[^ht ]/ig,'')), {hour:i}, tp_inst._defaults);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
989 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
990 else if(unit == 'millisec' || unit == 'microsec' || i >= 10){ sel += i; }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
991 else {sel += '0'+ i.toString(); }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
992 sel += '</option>';
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
993 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
994 sel += '</select>';
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
995
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
996 obj.children('select').remove();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
997
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
998 $(sel).appendTo(obj).change(function(e){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
999 tp_inst._onTimeChange();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1000 tp_inst._onSelectHandler();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1001 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1002
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1003 return obj;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1004 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1005 options: function(tp_inst, obj, unit, opts, val){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1006 var o = {},
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1007 $t = obj.children('select');
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1008 if(typeof(opts) == 'string'){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1009 if(val === undefined){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1010 return $t.data(opts);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1011 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1012 o[opts] = val;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1013 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1014 else{ o = opts; }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1015 return tp_inst.control.create(tp_inst, obj, $t.data('unit'), $t.val(), o.min || $t.data('min'), o.max || $t.data('max'), o.step || $t.data('step'));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1016 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1017 value: function(tp_inst, obj, unit, val){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1018 var $t = obj.children('select');
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1019 if(val !== undefined){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1020 return $t.val(val);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1021 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1022 return $t.val();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1023 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1024 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1025 } // end _controls
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1026
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1027 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1028
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1029 $.fn.extend({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1030 /*
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1031 * shorthand just to use timepicker..
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1032 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1033 timepicker: function(o) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1034 o = o || {};
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1035 var tmp_args = Array.prototype.slice.call(arguments);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1036
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1037 if (typeof o == 'object') {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1038 tmp_args[0] = $.extend(o, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1039 timeOnly: true
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1040 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1041 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1042
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1043 return $(this).each(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1044 $.fn.datetimepicker.apply($(this), tmp_args);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1045 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1046 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1047
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1048 /*
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1049 * extend timepicker to datepicker
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1050 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1051 datetimepicker: function(o) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1052 o = o || {};
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1053 var tmp_args = arguments;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1054
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1055 if (typeof(o) == 'string') {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1056 if (o == 'getDate') {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1057 return $.fn.datepicker.apply($(this[0]), tmp_args);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1058 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1059 return this.each(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1060 var $t = $(this);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1061 $t.datepicker.apply($t, tmp_args);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1062 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1063 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1064 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1065 return this.each(function() {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1066 var $t = $(this);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1067 $t.datepicker($.timepicker._newInst($t, o)._defaults);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1068 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1069 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1070 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1071 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1072
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1073 /*
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1074 * Public Utility to parse date and time
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1075 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1076 $.datepicker.parseDateTime = function(dateFormat, timeFormat, dateTimeString, dateSettings, timeSettings) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1077 var parseRes = parseDateTimeInternal(dateFormat, timeFormat, dateTimeString, dateSettings, timeSettings);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1078 if (parseRes.timeObj) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1079 var t = parseRes.timeObj;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1080 parseRes.date.setHours(t.hour, t.minute, t.second, t.millisec);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1081 parseRes.date.setMicroseconds(t.microsec);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1082 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1083
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1084 return parseRes.date;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1085 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1086
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1087 /*
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1088 * Public utility to parse time
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1089 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1090 $.datepicker.parseTime = function(timeFormat, timeString, options) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1091 var o = extendRemove(extendRemove({}, $.timepicker._defaults), options || {}),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1092 iso8601 = (timeFormat.replace(/\'.*?\'/g,'').indexOf('Z') !== -1);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1093
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1094 // Strict parse requires the timeString to match the timeFormat exactly
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1095 var strictParse = function(f, s, o){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1096
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1097 // pattern for standard and localized AM/PM markers
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1098 var getPatternAmpm = function(amNames, pmNames) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1099 var markers = [];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1100 if (amNames) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1101 $.merge(markers, amNames);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1102 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1103 if (pmNames) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1104 $.merge(markers, pmNames);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1105 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1106 markers = $.map(markers, function(val) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1107 return val.replace(/[.*+?|()\[\]{}\\]/g, '\\$&');
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1108 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1109 return '(' + markers.join('|') + ')?';
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1110 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1111
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1112 // figure out position of time elements.. cause js cant do named captures
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1113 var getFormatPositions = function(timeFormat) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1114 var finds = timeFormat.toLowerCase().match(/(h{1,2}|m{1,2}|s{1,2}|l{1}|c{1}|t{1,2}|z|'.*?')/g),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1115 orders = {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1116 h: -1,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1117 m: -1,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1118 s: -1,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1119 l: -1,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1120 c: -1,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1121 t: -1,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1122 z: -1
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1123 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1124
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1125 if (finds) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1126 for (var i = 0; i < finds.length; i++) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1127 if (orders[finds[i].toString().charAt(0)] == -1) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1128 orders[finds[i].toString().charAt(0)] = i + 1;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1129 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1130 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1131 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1132 return orders;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1133 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1134
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1135 var regstr = '^' + f.toString()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1136 .replace(/([hH]{1,2}|mm?|ss?|[tT]{1,2}|[zZ]|[lc]|'.*?')/g, function (match) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1137 var ml = match.length;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1138 switch (match.charAt(0).toLowerCase()) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1139 case 'h': return ml === 1? '(\\d?\\d)':'(\\d{'+ml+'})';
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1140 case 'm': return ml === 1? '(\\d?\\d)':'(\\d{'+ml+'})';
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1141 case 's': return ml === 1? '(\\d?\\d)':'(\\d{'+ml+'})';
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1142 case 'l': return '(\\d?\\d?\\d)';
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1143 case 'c': return '(\\d?\\d?\\d)';
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1144 case 'z': return '(z|[-+]\\d\\d:?\\d\\d|\\S+)?';
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1145 case 't': return getPatternAmpm(o.amNames, o.pmNames);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1146 default: // literal escaped in quotes
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1147 return '(' + match.replace(/\'/g, "").replace(/(\.|\$|\^|\\|\/|\(|\)|\[|\]|\?|\+|\*)/g, function (m) { return "\\" + m; }) + ')?';
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1148 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1149 })
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1150 .replace(/\s/g, '\\s?') +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1151 o.timeSuffix + '$',
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1152 order = getFormatPositions(f),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1153 ampm = '',
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1154 treg;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1155
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1156 treg = s.match(new RegExp(regstr, 'i'));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1157
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1158 var resTime = {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1159 hour: 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1160 minute: 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1161 second: 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1162 millisec: 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1163 microsec: 0
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1164 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1165
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1166 if (treg) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1167 if (order.t !== -1) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1168 if (treg[order.t] === undefined || treg[order.t].length === 0) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1169 ampm = '';
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1170 resTime.ampm = '';
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1171 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1172 ampm = $.inArray(treg[order.t].toUpperCase(), o.amNames) !== -1 ? 'AM' : 'PM';
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1173 resTime.ampm = o[ampm == 'AM' ? 'amNames' : 'pmNames'][0];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1174 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1175 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1176
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1177 if (order.h !== -1) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1178 if (ampm == 'AM' && treg[order.h] == '12') {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1179 resTime.hour = 0; // 12am = 0 hour
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1180 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1181 if (ampm == 'PM' && treg[order.h] != '12') {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1182 resTime.hour = parseInt(treg[order.h], 10) + 12; // 12pm = 12 hour, any other pm = hour + 12
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1183 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1184 resTime.hour = Number(treg[order.h]);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1185 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1186 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1187 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1188
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1189 if (order.m !== -1) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1190 resTime.minute = Number(treg[order.m]);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1191 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1192 if (order.s !== -1) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1193 resTime.second = Number(treg[order.s]);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1194 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1195 if (order.l !== -1) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1196 resTime.millisec = Number(treg[order.l]);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1197 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1198 if (order.c !== -1) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1199 resTime.microsec = Number(treg[order.c]);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1200 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1201 if (order.z !== -1 && treg[order.z] !== undefined) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1202 resTime.timezone = $.timepicker.timezoneOffsetNumber(treg[order.z]);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1203 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1204
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1205
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1206 return resTime;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1207 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1208 return false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1209 };// end strictParse
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1210
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1211 // First try JS Date, if that fails, use strictParse
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1212 var looseParse = function(f,s,o){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1213 try{
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1214 var d = new Date('2012-01-01 '+ s);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1215 if(isNaN(d.getTime())){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1216 d = new Date('2012-01-01T'+ s);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1217 if(isNaN(d.getTime())){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1218 d = new Date('01/01/2012 '+ s);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1219 if(isNaN(d.getTime())){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1220 throw "Unable to parse time with native Date: "+ s;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1221 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1222 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1223 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1224
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1225 return {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1226 hour: d.getHours(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1227 minute: d.getMinutes(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1228 second: d.getSeconds(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1229 millisec: d.getMilliseconds(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1230 microsec: d.getMicroseconds(),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1231 timezone: d.getTimezoneOffset()*-1
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1232 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1233 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1234 catch(err){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1235 try{
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1236 return strictParse(f,s,o);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1237 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1238 catch(err2){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1239 $.timepicker.log("Unable to parse \ntimeString: "+ s +"\ntimeFormat: "+ f);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1240 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1241 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1242 return false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1243 }; // end looseParse
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1244
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1245 if(typeof o.parse === "function"){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1246 return o.parse(timeFormat, timeString, o);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1247 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1248 if(o.parse === 'loose'){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1249 return looseParse(timeFormat, timeString, o);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1250 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1251 return strictParse(timeFormat, timeString, o);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1252 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1253
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1254 /*
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1255 * Public utility to format the time
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1256 * format = string format of the time
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1257 * time = a {}, not a Date() for timezones
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1258 * options = essentially the regional[].. amNames, pmNames, ampm
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1259 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1260 $.datepicker.formatTime = function(format, time, options) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1261 options = options || {};
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1262 options = $.extend({}, $.timepicker._defaults, options);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1263 time = $.extend({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1264 hour: 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1265 minute: 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1266 second: 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1267 millisec: 0,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1268 timezone: 0
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1269 }, time);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1270
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1271 var tmptime = format,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1272 ampmName = options.amNames[0],
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1273 hour = parseInt(time.hour, 10);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1274
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1275 if (hour > 11) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1276 ampmName = options.pmNames[0];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1277 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1278
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1279 tmptime = tmptime.replace(/(?:HH?|hh?|mm?|ss?|[tT]{1,2}|[zZ]|[lc]|('.*?'|".*?"))/g, function(match) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1280 switch (match) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1281 case 'HH':
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1282 return ('0' + hour).slice(-2);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1283 case 'H':
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1284 return hour;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1285 case 'hh':
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1286 return ('0' + convert24to12(hour)).slice(-2);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1287 case 'h':
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1288 return convert24to12(hour);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1289 case 'mm':
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1290 return ('0' + time.minute).slice(-2);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1291 case 'm':
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1292 return time.minute;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1293 case 'ss':
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1294 return ('0' + time.second).slice(-2);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1295 case 's':
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1296 return time.second;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1297 case 'l':
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1298 return ('00' + time.millisec).slice(-3);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1299 case 'c':
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1300 return ('00' + time.microsec).slice(-3);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1301 case 'z':
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1302 return $.timepicker.timezoneOffsetString(time.timezone === null? options.timezone : time.timezone, false);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1303 case 'Z':
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1304 return $.timepicker.timezoneOffsetString(time.timezone === null? options.timezone : time.timezone, true);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1305 case 'T':
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1306 return ampmName.charAt(0).toUpperCase();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1307 case 'TT':
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1308 return ampmName.toUpperCase();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1309 case 't':
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1310 return ampmName.charAt(0).toLowerCase();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1311 case 'tt':
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1312 return ampmName.toLowerCase();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1313 default:
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1314 return match.replace(/\'/g, "") || "'";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1315 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1316 });
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1317
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1318 tmptime = $.trim(tmptime);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1319 return tmptime;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1320 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1321
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1322 /*
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1323 * the bad hack :/ override datepicker so it doesnt close on select
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1324 // inspired: http://stackoverflow.com/questions/1252512/jquery-datepicker-prevent-closing-picker-when-clicking-a-date/1762378#1762378
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1325 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1326 $.datepicker._base_selectDate = $.datepicker._selectDate;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1327 $.datepicker._selectDate = function(id, dateStr) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1328 var inst = this._getInst($(id)[0]),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1329 tp_inst = this._get(inst, 'timepicker');
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1330
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1331 if (tp_inst) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1332 tp_inst._limitMinMaxDateTime(inst, true);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1333 inst.inline = inst.stay_open = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1334 //This way the onSelect handler called from calendarpicker get the full dateTime
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1335 this._base_selectDate(id, dateStr);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1336 inst.inline = inst.stay_open = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1337 this._notifyChange(inst);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1338 this._updateDatepicker(inst);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1339 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1340 this._base_selectDate(id, dateStr);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1341 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1342 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1343
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1344 /*
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1345 * second bad hack :/ override datepicker so it triggers an event when changing the input field
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1346 * and does not redraw the datepicker on every selectDate event
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1347 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1348 $.datepicker._base_updateDatepicker = $.datepicker._updateDatepicker;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1349 $.datepicker._updateDatepicker = function(inst) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1350
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1351 // don't popup the datepicker if there is another instance already opened
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1352 var input = inst.input[0];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1353 if ($.datepicker._curInst && $.datepicker._curInst != inst && $.datepicker._datepickerShowing && $.datepicker._lastInput != input) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1354 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1355 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1356
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1357 if (typeof(inst.stay_open) !== 'boolean' || inst.stay_open === false) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1358
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1359 this._base_updateDatepicker(inst);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1360
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1361 // Reload the time control when changing something in the input text field.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1362 var tp_inst = this._get(inst, 'timepicker');
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1363 if (tp_inst) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1364 tp_inst._addTimePicker(inst);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1365 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1366 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1367 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1368
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1369 /*
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1370 * third bad hack :/ override datepicker so it allows spaces and colon in the input field
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1371 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1372 $.datepicker._base_doKeyPress = $.datepicker._doKeyPress;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1373 $.datepicker._doKeyPress = function(event) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1374 var inst = $.datepicker._getInst(event.target),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1375 tp_inst = $.datepicker._get(inst, 'timepicker');
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1376
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1377 if (tp_inst) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1378 if ($.datepicker._get(inst, 'constrainInput')) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1379 var ampm = tp_inst.support.ampm,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1380 tz = tp_inst._defaults.showTimezone !== null? tp_inst._defaults.showTimezone : tp_inst.support.timezone,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1381 dateChars = $.datepicker._possibleChars($.datepicker._get(inst, 'dateFormat')),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1382 datetimeChars = tp_inst._defaults.timeFormat.toString()
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1383 .replace(/[hms]/g, '')
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1384 .replace(/TT/g, ampm ? 'APM' : '')
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1385 .replace(/Tt/g, ampm ? 'AaPpMm' : '')
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1386 .replace(/tT/g, ampm ? 'AaPpMm' : '')
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1387 .replace(/T/g, ampm ? 'AP' : '')
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1388 .replace(/tt/g, ampm ? 'apm' : '')
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1389 .replace(/t/g, ampm ? 'ap' : '') +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1390 " " + tp_inst._defaults.separator +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1391 tp_inst._defaults.timeSuffix +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1392 (tz ? tp_inst._defaults.timezoneList.join('') : '') +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1393 (tp_inst._defaults.amNames.join('')) + (tp_inst._defaults.pmNames.join('')) +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1394 dateChars,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1395 chr = String.fromCharCode(event.charCode === undefined ? event.keyCode : event.charCode);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1396 return event.ctrlKey || (chr < ' ' || !dateChars || datetimeChars.indexOf(chr) > -1);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1397 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1398 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1399
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1400 return $.datepicker._base_doKeyPress(event);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1401 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1402
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1403 /*
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1404 * Fourth bad hack :/ override _updateAlternate function used in inline mode to init altField
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1405 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1406 $.datepicker._base_updateAlternate = $.datepicker._updateAlternate;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1407 /* Update any alternate field to synchronise with the main field. */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1408 $.datepicker._updateAlternate = function(inst) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1409 var tp_inst = this._get(inst, 'timepicker');
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1410 if(tp_inst){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1411 var altField = tp_inst._defaults.altField;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1412 if (altField) { // update alternate field too
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1413 var altFormat = tp_inst._defaults.altFormat || tp_inst._defaults.dateFormat,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1414 date = this._getDate(inst),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1415 formatCfg = $.datepicker._getFormatConfig(inst),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1416 altFormattedDateTime = '',
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1417 altSeparator = tp_inst._defaults.altSeparator ? tp_inst._defaults.altSeparator : tp_inst._defaults.separator,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1418 altTimeSuffix = tp_inst._defaults.altTimeSuffix ? tp_inst._defaults.altTimeSuffix : tp_inst._defaults.timeSuffix,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1419 altTimeFormat = tp_inst._defaults.altTimeFormat !== null ? tp_inst._defaults.altTimeFormat : tp_inst._defaults.timeFormat;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1420
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1421 altFormattedDateTime += $.datepicker.formatTime(altTimeFormat, tp_inst, tp_inst._defaults) + altTimeSuffix;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1422 if(!tp_inst._defaults.timeOnly && !tp_inst._defaults.altFieldTimeOnly && date !== null){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1423 if(tp_inst._defaults.altFormat){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1424 altFormattedDateTime = $.datepicker.formatDate(tp_inst._defaults.altFormat, date, formatCfg) + altSeparator + altFormattedDateTime;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1425 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1426 else{
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1427 altFormattedDateTime = tp_inst.formattedDate + altSeparator + altFormattedDateTime;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1428 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1429 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1430 $(altField).val(altFormattedDateTime);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1431 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1432 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1433 else{
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1434 $.datepicker._base_updateAlternate(inst);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1435 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1436 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1437
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1438 /*
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1439 * Override key up event to sync manual input changes.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1440 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1441 $.datepicker._base_doKeyUp = $.datepicker._doKeyUp;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1442 $.datepicker._doKeyUp = function(event) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1443 var inst = $.datepicker._getInst(event.target),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1444 tp_inst = $.datepicker._get(inst, 'timepicker');
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1445
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1446 if (tp_inst) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1447 if (tp_inst._defaults.timeOnly && (inst.input.val() != inst.lastVal)) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1448 try {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1449 $.datepicker._updateDatepicker(inst);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1450 } catch (err) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1451 $.timepicker.log(err);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1452 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1453 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1454 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1455
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1456 return $.datepicker._base_doKeyUp(event);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1457 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1458
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1459 /*
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1460 * override "Today" button to also grab the time.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1461 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1462 $.datepicker._base_gotoToday = $.datepicker._gotoToday;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1463 $.datepicker._gotoToday = function(id) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1464 var inst = this._getInst($(id)[0]),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1465 $dp = inst.dpDiv;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1466 this._base_gotoToday(id);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1467 var tp_inst = this._get(inst, 'timepicker');
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1468 selectLocalTimezone(tp_inst);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1469 var now = new Date();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1470 this._setTime(inst, now);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1471 $('.ui-datepicker-today', $dp).click();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1472 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1473
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1474 /*
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1475 * Disable & enable the Time in the datetimepicker
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1476 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1477 $.datepicker._disableTimepickerDatepicker = function(target) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1478 var inst = this._getInst(target);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1479 if (!inst) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1480 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1481 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1482
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1483 var tp_inst = this._get(inst, 'timepicker');
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1484 $(target).datepicker('getDate'); // Init selected[Year|Month|Day]
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1485 if (tp_inst) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1486 tp_inst._defaults.showTimepicker = false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1487 tp_inst._updateDateTime(inst);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1488 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1489 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1490
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1491 $.datepicker._enableTimepickerDatepicker = function(target) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1492 var inst = this._getInst(target);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1493 if (!inst) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1494 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1495 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1496
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1497 var tp_inst = this._get(inst, 'timepicker');
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1498 $(target).datepicker('getDate'); // Init selected[Year|Month|Day]
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1499 if (tp_inst) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1500 tp_inst._defaults.showTimepicker = true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1501 tp_inst._addTimePicker(inst); // Could be disabled on page load
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1502 tp_inst._updateDateTime(inst);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1503 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1504 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1505
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1506 /*
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1507 * Create our own set time function
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1508 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1509 $.datepicker._setTime = function(inst, date) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1510 var tp_inst = this._get(inst, 'timepicker');
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1511 if (tp_inst) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1512 var defaults = tp_inst._defaults;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1513
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1514 // calling _setTime with no date sets time to defaults
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1515 tp_inst.hour = date ? date.getHours() : defaults.hour;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1516 tp_inst.minute = date ? date.getMinutes() : defaults.minute;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1517 tp_inst.second = date ? date.getSeconds() : defaults.second;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1518 tp_inst.millisec = date ? date.getMilliseconds() : defaults.millisec;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1519 tp_inst.microsec = date ? date.getMicroseconds() : defaults.microsec;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1520
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1521 //check if within min/max times..
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1522 tp_inst._limitMinMaxDateTime(inst, true);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1523
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1524 tp_inst._onTimeChange();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1525 tp_inst._updateDateTime(inst);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1526 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1527 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1528
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1529 /*
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1530 * Create new public method to set only time, callable as $().datepicker('setTime', date)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1531 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1532 $.datepicker._setTimeDatepicker = function(target, date, withDate) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1533 var inst = this._getInst(target);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1534 if (!inst) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1535 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1536 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1537
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1538 var tp_inst = this._get(inst, 'timepicker');
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1539
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1540 if (tp_inst) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1541 this._setDateFromField(inst);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1542 var tp_date;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1543 if (date) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1544 if (typeof date == "string") {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1545 tp_inst._parseTime(date, withDate);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1546 tp_date = new Date();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1547 tp_date.setHours(tp_inst.hour, tp_inst.minute, tp_inst.second, tp_inst.millisec);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1548 tp_date.setMicroseconds(tp_inst.microsec);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1549 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1550 tp_date = new Date(date.getTime());
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1551 tp_date.setMicroseconds(date.getMicroseconds());
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1552 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1553 if (tp_date.toString() == 'Invalid Date') {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1554 tp_date = undefined;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1555 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1556 this._setTime(inst, tp_date);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1557 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1558 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1559
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1560 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1561
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1562 /*
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1563 * override setDate() to allow setting time too within Date object
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1564 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1565 $.datepicker._base_setDateDatepicker = $.datepicker._setDateDatepicker;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1566 $.datepicker._setDateDatepicker = function(target, date) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1567 var inst = this._getInst(target);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1568 if (!inst) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1569 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1570 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1571
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1572 if(typeof(date) === 'string'){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1573 date = new Date(date);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1574 if(!date.getTime()){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1575 $.timepicker.log("Error creating Date object from string.");
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1576 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1577 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1578
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1579 var tp_inst = this._get(inst, 'timepicker');
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1580 var tp_date;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1581 if (date instanceof Date) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1582 tp_date = new Date(date.getTime());
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1583 tp_date.setMicroseconds(date.getMicroseconds());
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1584 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1585 tp_date = date;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1586 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1587
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1588 // This is important if you are using the timezone option, javascript's Date
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1589 // object will only return the timezone offset for the current locale, so we
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1590 // adjust it accordingly. If not using timezone option this won't matter..
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1591 // If a timezone is different in tp, keep the timezone as is
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1592 if(tp_inst){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1593 // look out for DST if tz wasn't specified
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1594 if(!tp_inst.support.timezone && tp_inst._defaults.timezone === null){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1595 tp_inst.timezone = tp_date.getTimezoneOffset()*-1;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1596 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1597 date = $.timepicker.timezoneAdjust(date, tp_inst.timezone);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1598 tp_date = $.timepicker.timezoneAdjust(tp_date, tp_inst.timezone);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1599 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1600
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1601 this._updateDatepicker(inst);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1602 this._base_setDateDatepicker.apply(this, arguments);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1603 this._setTimeDatepicker(target, tp_date, true);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1604 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1605
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1606 /*
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1607 * override getDate() to allow getting time too within Date object
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1608 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1609 $.datepicker._base_getDateDatepicker = $.datepicker._getDateDatepicker;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1610 $.datepicker._getDateDatepicker = function(target, noDefault) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1611 var inst = this._getInst(target);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1612 if (!inst) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1613 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1614 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1615
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1616 var tp_inst = this._get(inst, 'timepicker');
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1617
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1618 if (tp_inst) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1619 // if it hasn't yet been defined, grab from field
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1620 if(inst.lastVal === undefined){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1621 this._setDateFromField(inst, noDefault);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1622 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1623
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1624 var date = this._getDate(inst);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1625 if (date && tp_inst._parseTime($(target).val(), tp_inst.timeOnly)) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1626 date.setHours(tp_inst.hour, tp_inst.minute, tp_inst.second, tp_inst.millisec);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1627 date.setMicroseconds(tp_inst.microsec);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1628
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1629 // This is important if you are using the timezone option, javascript's Date
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1630 // object will only return the timezone offset for the current locale, so we
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1631 // adjust it accordingly. If not using timezone option this won't matter..
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1632 if(tp_inst.timezone != null){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1633 // look out for DST if tz wasn't specified
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1634 if(!tp_inst.support.timezone && tp_inst._defaults.timezone === null){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1635 tp_inst.timezone = date.getTimezoneOffset()*-1;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1636 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1637 date = $.timepicker.timezoneAdjust(date, tp_inst.timezone);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1638 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1639 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1640 return date;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1641 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1642 return this._base_getDateDatepicker(target, noDefault);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1643 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1644
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1645 /*
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1646 * override parseDate() because UI 1.8.14 throws an error about "Extra characters"
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1647 * An option in datapicker to ignore extra format characters would be nicer.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1648 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1649 $.datepicker._base_parseDate = $.datepicker.parseDate;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1650 $.datepicker.parseDate = function(format, value, settings) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1651 var date;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1652 try {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1653 date = this._base_parseDate(format, value, settings);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1654 } catch (err) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1655 // Hack! The error message ends with a colon, a space, and
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1656 // the "extra" characters. We rely on that instead of
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1657 // attempting to perfectly reproduce the parsing algorithm.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1658 if (err.indexOf(":") >= 0) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1659 date = this._base_parseDate(format, value.substring(0,value.length-(err.length-err.indexOf(':')-2)), settings);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1660 $.timepicker.log("Error parsing the date string: " + err + "\ndate string = " + value + "\ndate format = " + format);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1661 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1662 throw err;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1663 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1664 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1665 return date;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1666 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1667
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1668 /*
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1669 * override formatDate to set date with time to the input
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1670 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1671 $.datepicker._base_formatDate = $.datepicker._formatDate;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1672 $.datepicker._formatDate = function(inst, day, month, year) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1673 var tp_inst = this._get(inst, 'timepicker');
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1674 if (tp_inst) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1675 tp_inst._updateDateTime(inst);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1676 return tp_inst.$input.val();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1677 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1678 return this._base_formatDate(inst);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1679 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1680
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1681 /*
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1682 * override options setter to add time to maxDate(Time) and minDate(Time). MaxDate
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1683 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1684 $.datepicker._base_optionDatepicker = $.datepicker._optionDatepicker;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1685 $.datepicker._optionDatepicker = function(target, name, value) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1686 var inst = this._getInst(target),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1687 name_clone;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1688 if (!inst) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1689 return null;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1690 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1691
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1692 var tp_inst = this._get(inst, 'timepicker');
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1693 if (tp_inst) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1694 var min = null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1695 max = null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1696 onselect = null,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1697 overrides = tp_inst._defaults.evnts,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1698 fns = {},
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1699 prop;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1700 if (typeof name == 'string') { // if min/max was set with the string
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1701 if (name === 'minDate' || name === 'minDateTime') {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1702 min = value;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1703 } else if (name === 'maxDate' || name === 'maxDateTime') {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1704 max = value;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1705 } else if (name === 'onSelect') {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1706 onselect = value;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1707 } else if (overrides.hasOwnProperty(name)) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1708 if (typeof (value) === 'undefined') {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1709 return overrides[name];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1710 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1711 fns[name] = value;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1712 name_clone = {}; //empty results in exiting function after overrides updated
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1713 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1714 } else if (typeof name == 'object') { //if min/max was set with the JSON
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1715 if (name.minDate) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1716 min = name.minDate;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1717 } else if (name.minDateTime) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1718 min = name.minDateTime;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1719 } else if (name.maxDate) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1720 max = name.maxDate;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1721 } else if (name.maxDateTime) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1722 max = name.maxDateTime;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1723 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1724 for (prop in overrides) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1725 if (overrides.hasOwnProperty(prop) && name[prop]) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1726 fns[prop] = name[prop];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1727 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1728 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1729 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1730 for (prop in fns) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1731 if (fns.hasOwnProperty(prop)) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1732 overrides[prop] = fns[prop];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1733 if (!name_clone) { name_clone = $.extend({}, name);}
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1734 delete name_clone[prop];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1735 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1736 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1737 if (name_clone && isEmptyObject(name_clone)) { return; }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1738 if (min) { //if min was set
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1739 if (min === 0) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1740 min = new Date();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1741 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1742 min = new Date(min);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1743 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1744 tp_inst._defaults.minDate = min;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1745 tp_inst._defaults.minDateTime = min;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1746 } else if (max) { //if max was set
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1747 if (max === 0) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1748 max = new Date();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1749 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1750 max = new Date(max);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1751 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1752 tp_inst._defaults.maxDate = max;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1753 tp_inst._defaults.maxDateTime = max;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1754 } else if (onselect) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1755 tp_inst._defaults.onSelect = onselect;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1756 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1757 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1758 if (value === undefined) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1759 return this._base_optionDatepicker.call($.datepicker, target, name);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1760 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1761 return this._base_optionDatepicker.call($.datepicker, target, name_clone || name, value);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1762 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1763
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1764 /*
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1765 * jQuery isEmptyObject does not check hasOwnProperty - if someone has added to the object prototype,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1766 * it will return false for all objects
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1767 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1768 var isEmptyObject = function(obj) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1769 var prop;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1770 for (prop in obj) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1771 if (obj.hasOwnProperty(obj)) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1772 return false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1773 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1774 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1775 return true;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1776 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1777
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1778 /*
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1779 * jQuery extend now ignores nulls!
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1780 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1781 var extendRemove = function(target, props) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1782 $.extend(target, props);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1783 for (var name in props) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1784 if (props[name] === null || props[name] === undefined) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1785 target[name] = props[name];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1786 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1787 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1788 return target;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1789 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1790
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1791 /*
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1792 * Determine by the time format which units are supported
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1793 * Returns an object of booleans for each unit
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1794 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1795 var detectSupport = function(timeFormat){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1796 var tf = timeFormat.replace(/\'.*?\'/g,'').toLowerCase(), // removes literals
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1797 isIn = function(f, t){ // does the format contain the token?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1798 return f.indexOf(t) !== -1? true:false;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1799 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1800 return {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1801 hour: isIn(tf,'h'),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1802 minute: isIn(tf,'m'),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1803 second: isIn(tf,'s'),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1804 millisec: isIn(tf,'l'),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1805 microsec: isIn(tf,'c'),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1806 timezone: isIn(tf,'z'),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1807 ampm: isIn(tf,'t') && isIn(timeFormat,'h'),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1808 iso8601: isIn(timeFormat, 'Z')
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1809 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1810 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1811
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1812 /*
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1813 * Converts 24 hour format into 12 hour
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1814 * Returns 12 hour without leading 0
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1815 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1816 var convert24to12 = function(hour) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1817 if (hour > 12) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1818 hour = hour - 12;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1819 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1820
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1821 if (hour === 0) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1822 hour = 12;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1823 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1824
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1825 return String(hour);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1826 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1827
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1828 /*
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1829 * Splits datetime string into date ans time substrings.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1830 * Throws exception when date can't be parsed
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1831 * Returns [dateString, timeString]
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1832 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1833 var splitDateTime = function(dateFormat, dateTimeString, dateSettings, timeSettings) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1834 try {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1835 // The idea is to get the number separator occurances in datetime and the time format requested (since time has
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1836 // fewer unknowns, mostly numbers and am/pm). We will use the time pattern to split.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1837 var separator = timeSettings && timeSettings.separator ? timeSettings.separator : $.timepicker._defaults.separator,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1838 format = timeSettings && timeSettings.timeFormat ? timeSettings.timeFormat : $.timepicker._defaults.timeFormat,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1839 timeParts = format.split(separator), // how many occurances of separator may be in our format?
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1840 timePartsLen = timeParts.length,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1841 allParts = dateTimeString.split(separator),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1842 allPartsLen = allParts.length;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1843
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1844 if (allPartsLen > 1) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1845 return [
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1846 allParts.splice(0,allPartsLen-timePartsLen).join(separator),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1847 allParts.splice(0,timePartsLen).join(separator)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1848 ];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1849 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1850
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1851 } catch (err) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1852 $.timepicker.log('Could not split the date from the time. Please check the following datetimepicker options' +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1853 "\nthrown error: " + err +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1854 "\ndateTimeString" + dateTimeString +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1855 "\ndateFormat = " + dateFormat +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1856 "\nseparator = " + timeSettings.separator +
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1857 "\ntimeFormat = " + timeSettings.timeFormat);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1858
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1859 if (err.indexOf(":") >= 0) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1860 // Hack! The error message ends with a colon, a space, and
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1861 // the "extra" characters. We rely on that instead of
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1862 // attempting to perfectly reproduce the parsing algorithm.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1863 var dateStringLength = dateTimeString.length - (err.length - err.indexOf(':') - 2),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1864 timeString = dateTimeString.substring(dateStringLength);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1865
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1866 return [$.trim(dateTimeString.substring(0, dateStringLength)), $.trim(dateTimeString.substring(dateStringLength))];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1867
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1868 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1869 throw err;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1870 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1871 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1872 return [dateTimeString, ''];
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1873 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1874
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1875 /*
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1876 * Internal function to parse datetime interval
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1877 * Returns: {date: Date, timeObj: Object}, where
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1878 * date - parsed date without time (type Date)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1879 * timeObj = {hour: , minute: , second: , millisec: , microsec: } - parsed time. Optional
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1880 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1881 var parseDateTimeInternal = function(dateFormat, timeFormat, dateTimeString, dateSettings, timeSettings) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1882 var date;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1883 var splitRes = splitDateTime(dateFormat, dateTimeString, dateSettings, timeSettings);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1884 date = $.datepicker._base_parseDate(dateFormat, splitRes[0], dateSettings);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1885 if (splitRes[1] !== '') {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1886 var timeString = splitRes[1],
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1887 parsedTime = $.datepicker.parseTime(timeFormat, timeString, timeSettings);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1888
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1889 if (parsedTime === null) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1890 throw 'Wrong time format';
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1891 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1892 return {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1893 date: date,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1894 timeObj: parsedTime
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1895 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1896 } else {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1897 return {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1898 date: date
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1899 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1900 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1901 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1902
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1903 /*
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1904 * Internal function to set timezone_select to the local timezone
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1905 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1906 var selectLocalTimezone = function(tp_inst, date) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1907 if (tp_inst && tp_inst.timezone_select) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1908 var now = typeof date !== 'undefined' ? date : new Date();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1909 tp_inst.timezone_select.val(now.getTimezoneOffset()*-1);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1910 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1911 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1912
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1913 /*
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1914 * Create a Singleton Insance
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1915 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1916 $.timepicker = new Timepicker();
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1917
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1918 /**
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1919 * Get the timezone offset as string from a date object (eg '+0530' for UTC+5.5)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1920 * @param number if not a number this value is returned
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1921 * @param boolean if true formats in accordance to iso8601 "+12:45"
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1922 * @return string
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1923 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1924 $.timepicker.timezoneOffsetString = function(tzMinutes, iso8601) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1925 if(isNaN(tzMinutes) || tzMinutes > 840){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1926 return tzMinutes;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1927 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1928
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1929 var off = tzMinutes,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1930 minutes = off % 60,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1931 hours = (off - minutes) / 60,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1932 iso = iso8601? ':':'',
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1933 tz = (off >= 0 ? '+' : '-') + ('0' + (hours * 101).toString()).slice(-2) + iso + ('0' + (minutes * 101).toString()).slice(-2);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1934
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1935 if(tz == '+00:00'){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1936 return 'Z';
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1937 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1938 return tz;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1939 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1940
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1941 /**
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1942 * Get the number in minutes that represents a timezone string
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1943 * @param string formated like "+0500", "-1245"
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1944 * @return number
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1945 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1946 $.timepicker.timezoneOffsetNumber = function(tzString) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1947 tzString = tzString.toString().replace(':',''); // excuse any iso8601, end up with "+1245"
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1948
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1949 if(tzString.toUpperCase() === 'Z'){ // if iso8601 with Z, its 0 minute offset
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1950 return 0;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1951 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1952
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1953 if(!/^(\-|\+)\d{4}$/.test(tzString)){ // possibly a user defined tz, so just give it back
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1954 return tzString;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1955 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1956
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1957 return ((tzString.substr(0,1) =='-'? -1 : 1) * // plus or minus
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1958 ((parseInt(tzString.substr(1,2),10)*60) + // hours (converted to minutes)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1959 parseInt(tzString.substr(3,2),10))); // minutes
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1960 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1961
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1962 /**
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1963 * No way to set timezone in js Date, so we must adjust the minutes to compensate. (think setDate, getDate)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1964 * @param date
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1965 * @param string formated like "+0500", "-1245"
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1966 * @return date
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1967 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1968 $.timepicker.timezoneAdjust = function(date, toTimezone) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1969 var toTz = $.timepicker.timezoneOffsetNumber(toTimezone);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1970 if(!isNaN(toTz)){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1971 date.setMinutes(date.getMinutes()*1 + (date.getTimezoneOffset()*-1 - toTz*1) );
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1972 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1973 return date;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1974 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1975
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1976 /**
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1977 * Calls `timepicker()` on the `startTime` and `endTime` elements, and configures them to
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1978 * enforce date range limits.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1979 * n.b. The input value must be correctly formatted (reformatting is not supported)
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1980 * @param Element startTime
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1981 * @param Element endTime
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1982 * @param obj options Options for the timepicker() call
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1983 * @return jQuery
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1984 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1985 $.timepicker.timeRange = function(startTime, endTime, options) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1986 return $.timepicker.handleRange('timepicker', startTime, endTime, options);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1987 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1988
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1989 /**
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1990 * Calls `datetimepicker` on the `startTime` and `endTime` elements, and configures them to
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1991 * enforce date range limits.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1992 * @param Element startTime
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1993 * @param Element endTime
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1994 * @param obj options Options for the `timepicker()` call. Also supports `reformat`,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1995 * a boolean value that can be used to reformat the input values to the `dateFormat`.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1996 * @param string method Can be used to specify the type of picker to be added
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1997 * @return jQuery
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1998 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1999 $.timepicker.datetimeRange = function(startTime, endTime, options) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2000 $.timepicker.handleRange('datetimepicker', startTime, endTime, options);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2001 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2002
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2003 /**
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2004 * Calls `method` on the `startTime` and `endTime` elements, and configures them to
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2005 * enforce date range limits.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2006 * @param Element startTime
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2007 * @param Element endTime
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2008 * @param obj options Options for the `timepicker()` call. Also supports `reformat`,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2009 * a boolean value that can be used to reformat the input values to the `dateFormat`.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2010 * @return jQuery
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2011 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2012 $.timepicker.dateRange = function(startTime, endTime, options) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2013 $.timepicker.handleRange('datepicker', startTime, endTime, options);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2014 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2015
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2016 /**
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2017 * Calls `method` on the `startTime` and `endTime` elements, and configures them to
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2018 * enforce date range limits.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2019 * @param string method Can be used to specify the type of picker to be added
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2020 * @param Element startTime
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2021 * @param Element endTime
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2022 * @param obj options Options for the `timepicker()` call. Also supports `reformat`,
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2023 * a boolean value that can be used to reformat the input values to the `dateFormat`.
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2024 * @return jQuery
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2025 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2026 $.timepicker.handleRange = function(method, startTime, endTime, options) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2027 options = $.extend({}, {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2028 minInterval: 0, // min allowed interval in milliseconds
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2029 maxInterval: 0, // max allowed interval in milliseconds
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2030 start: {}, // options for start picker
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2031 end: {} // options for end picker
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2032 }, options);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2033
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2034 $.fn[method].call(startTime, $.extend({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2035 onClose: function(dateText, inst) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2036 checkDates($(this), endTime);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2037 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2038 onSelect: function(selectedDateTime) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2039 selected($(this), endTime, 'minDate');
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2040 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2041 }, options, options.start));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2042 $.fn[method].call(endTime, $.extend({
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2043 onClose: function(dateText, inst) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2044 checkDates($(this), startTime);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2045 },
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2046 onSelect: function(selectedDateTime) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2047 selected($(this), startTime, 'maxDate');
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2048 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2049 }, options, options.end));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2050
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2051 checkDates(startTime, endTime);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2052 selected(startTime, endTime, 'minDate');
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2053 selected(endTime, startTime, 'maxDate');
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2054
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2055 function checkDates(changed, other) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2056 var startdt = startTime[method]('getDate'),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2057 enddt = endTime[method]('getDate'),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2058 changeddt = changed[method]('getDate');
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2059
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2060 if(startdt !== null){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2061 var minDate = new Date(startdt.getTime()),
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2062 maxDate = new Date(startdt.getTime());
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2063
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2064 minDate.setMilliseconds(minDate.getMilliseconds() + options.minInterval);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2065 maxDate.setMilliseconds(maxDate.getMilliseconds() + options.maxInterval);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2066
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2067 if(options.minInterval > 0 && minDate > enddt){ // minInterval check
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2068 endTime[method]('setDate',minDate);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2069 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2070 else if(options.maxInterval > 0 && maxDate < enddt){ // max interval check
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2071 endTime[method]('setDate',maxDate);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2072 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2073 else if (startdt > enddt) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2074 other[method]('setDate',changeddt);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2075 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2076 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2077 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2078
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2079 function selected(changed, other, option) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2080 if (!changed.val()) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2081 return;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2082 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2083 var date = changed[method].call(changed, 'getDate');
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2084 if(date !== null && options.minInterval > 0){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2085 if(option == 'minDate'){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2086 date.setMilliseconds(date.getMilliseconds() + options.minInterval);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2087 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2088 if(option == 'maxDate'){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2089 date.setMilliseconds(date.getMilliseconds() - options.minInterval);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2090 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2091 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2092 if (date.getTime) {
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2093 other[method].call(other, 'option', option, date);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2094 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2095 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2096 return $([startTime.get(0), endTime.get(0)]);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2097 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2098
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2099 /**
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2100 * Log error or data to the console during error or debugging
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2101 * @param Object err pass any type object to log to the console during error or debugging
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2102 * @return void
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2103 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2104 $.timepicker.log = function(err){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2105 if(window.console){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2106 console.log(err);
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2107 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2108 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2109
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2110 /*
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2111 * Microsecond support
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2112 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2113 if(!Date.prototype.getMicroseconds){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2114 Date.prototype.microseconds = 0;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2115 Date.prototype.getMicroseconds = function(){ return this.microseconds; };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2116 Date.prototype.setMicroseconds = function(m){
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2117 this.setMilliseconds(this.getMilliseconds() + Math.floor(m/1000));
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2118 this.microseconds = m%1000;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2119 return this;
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2120 };
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2121 }
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2122
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2123 /*
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2124 * Keep up with the version
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2125 */
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2126 $.timepicker.version = "1.3.1";
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2127
4a9dbee41a6c Added initial set for the thermferm web interface
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2128 })(jQuery);

mercurial