surveyor 0.21.0 → 0.22.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. data/.gitignore +1 -0
  2. data/Gemfile +0 -6
  3. data/README.md +40 -14
  4. data/app/helpers/surveyor_helper.rb +1 -85
  5. data/app/views/partials/_answer.html.haml +5 -4
  6. data/app/views/partials/_question.html.haml +7 -5
  7. data/app/views/partials/_question_group.html.haml +2 -2
  8. data/app/views/surveyor/export.json.rabl +75 -0
  9. data/app/views/surveyor/show.html.haml +75 -13
  10. data/app/views/surveyor/show.json.rabl +14 -0
  11. data/config/routes.rb +2 -3
  12. data/doc/surveyor reject or delete decision matrix.png +0 -0
  13. data/features/export_to_json.feature +96 -0
  14. data/features/show_survey.feature +42 -0
  15. data/features/step_definitions/{common_setps.rb → common_steps.rb} +0 -0
  16. data/features/step_definitions/surveyor_steps.rb +46 -12
  17. data/features/step_definitions/web_steps.rb +15 -5
  18. data/features/support/paths.rb +2 -1
  19. data/features/surveyor.feature +192 -41
  20. data/features/surveyor_parser.feature +10 -10
  21. data/features/{redcap_parser.feature → z_redcap_parser.feature} +9 -6
  22. data/lib/formtastic/surveyor_builder.rb +1 -4
  23. data/lib/generators/surveyor/install_generator.rb +6 -5
  24. data/lib/generators/surveyor/templates/db/migrate/add_api_id_to_question_groups.rb +9 -0
  25. data/lib/generators/surveyor/templates/db/migrate/add_api_ids_to_response_sets_and_responses.rb +11 -0
  26. data/lib/generators/surveyor/templates/public/javascripts/surveyor/jquery-ui-timepicker-addon.js +1277 -0
  27. data/lib/generators/surveyor/templates/public/javascripts/surveyor/jquery-ui.js +11729 -0
  28. data/lib/generators/surveyor/templates/public/javascripts/surveyor/jquery.surveyor.js +54 -10
  29. data/lib/generators/surveyor/templates/public/stylesheets/sass/surveyor.sass +1 -1
  30. data/lib/generators/surveyor/templates/public/stylesheets/surveyor/jquery-ui-timepicker-addon.css +6 -0
  31. data/lib/generators/surveyor/templates/public/stylesheets/surveyor/jquery-ui.custom.css +572 -0
  32. data/lib/generators/surveyor/templates/public/stylesheets/surveyor/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
  33. data/lib/generators/surveyor/templates/public/stylesheets/surveyor/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
  34. data/lib/generators/surveyor/templates/public/stylesheets/surveyor/ui-bg_glass_65_ffffff_1x400.png +0 -0
  35. data/lib/generators/surveyor/templates/public/stylesheets/surveyor/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
  36. data/lib/generators/surveyor/templates/public/stylesheets/surveyor/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
  37. data/lib/generators/surveyor/templates/public/stylesheets/surveyor/ui-icons_ef8c08_256x240.png +0 -0
  38. data/lib/generators/surveyor/templates/public/stylesheets/surveyor/ui-icons_ffffff_256x240.png +0 -0
  39. data/lib/generators/surveyor/templates/surveys/EXTENDING_SURVEYOR.md +14 -0
  40. data/lib/generators/surveyor/templates/surveys/MODIFYING_SURVEYOR.md +91 -0
  41. data/lib/generators/surveyor/templates/surveys/date_survey.rb +15 -0
  42. data/lib/generators/surveyor/templates/surveys/kitchen_sink_survey.rb +2 -2
  43. data/lib/surveyor/common.rb +31 -4
  44. data/lib/surveyor/helpers/surveyor_helper_methods.rb +99 -0
  45. data/lib/surveyor/models/answer_methods.rb +6 -5
  46. data/lib/surveyor/models/dependency_condition_methods.rb +0 -1
  47. data/lib/surveyor/models/dependency_methods.rb +1 -1
  48. data/lib/surveyor/models/question_group_methods.rb +5 -0
  49. data/lib/surveyor/models/question_methods.rb +5 -2
  50. data/lib/surveyor/models/response_methods.rb +44 -3
  51. data/lib/surveyor/models/response_set_methods.rb +14 -4
  52. data/lib/surveyor/models/survey_methods.rb +8 -2
  53. data/lib/surveyor/models/survey_section_methods.rb +13 -1
  54. data/lib/surveyor/parser.rb +18 -11
  55. data/lib/surveyor/render_text.rb +19 -0
  56. data/lib/surveyor/surveyor_controller_methods.rb +19 -1
  57. data/lib/surveyor/unparser.rb +1 -1
  58. data/lib/surveyor/version.rb +1 -1
  59. data/lib/tasks/surveyor_tasks.rake +1 -1
  60. data/spec/controllers/surveyor_controller_spec.rb +7 -3
  61. data/spec/helpers/surveyor_helper_spec.rb +104 -9
  62. data/spec/lib/chinese_survey.rb +14 -0
  63. data/spec/lib/common_spec.rb +52 -1
  64. data/spec/lib/rake_kitchen_sink.rb +40 -0
  65. data/spec/models/answer_spec.rb +11 -0
  66. data/spec/models/question_spec.rb +15 -0
  67. data/spec/models/response_set_spec.rb +45 -1
  68. data/spec/models/response_spec.rb +7 -4
  69. data/surveyor.gemspec +4 -2
  70. metadata +99 -40
  71. data/app/controllers/results_controller.rb +0 -13
  72. data/app/views/results/index.html.erb +0 -17
  73. data/app/views/results/show.html.erb +0 -25
@@ -1,9 +1,9 @@
1
- Feature: Survey creation
2
- As a
1
+ Feature: Survey parser
2
+ As a developer
3
3
  I want to write out the survey in the DSL
4
4
  So that I can give it to survey participants
5
5
 
6
- Scenario: Basic questions
6
+ Scenario: Parsing basic questions
7
7
  Given I parse
8
8
  """
9
9
  survey "Simple survey" do
@@ -52,7 +52,7 @@ Feature: Survey creation
52
52
  | 3 | brown | answer | 0 |
53
53
  | nil | Omit | answer | 3 |
54
54
 
55
- Scenario: More complex questions
55
+ Scenario: Parsing more complex questions
56
56
  Given I parse
57
57
  """
58
58
  survey "Complex survey" do
@@ -106,7 +106,7 @@ Feature: Survey creation
106
106
  | -2 | answer |
107
107
  | Other | string |
108
108
 
109
- Scenario: Dependencies and validations
109
+ Scenario: Parsing dependencies and validations
110
110
  Given I parse
111
111
  """
112
112
  survey "Dependency and validation survey" do
@@ -165,7 +165,7 @@ Feature: Survey creation
165
165
  | rule_key | integer_value |
166
166
  | A | 0 |
167
167
 
168
- Scenario: Dependencies and validations
168
+ Scenario: Parsing other dependencies and validations
169
169
  Given I parse
170
170
  """
171
171
  survey "dependency test" do
@@ -209,7 +209,7 @@ Feature: Survey creation
209
209
  And question "copd_sh_1a" should have a dependency with rule "A"
210
210
  And question "copd_sh_1ba" should have a dependency with rule "E"
211
211
 
212
- Scenario: Dependencies on questions inside of a group
212
+ Scenario: Parsing dependencies on questions inside of a group
213
213
  Given the survey
214
214
  """
215
215
  survey "Phone Screen Questions" do
@@ -248,8 +248,8 @@ Feature: Survey creation
248
248
  Then there should be 4 dependencies
249
249
  And 2 dependencies should depend on questions
250
250
  And 2 dependencies should depend on question groups
251
-
252
- Scenario: Dependencies with "a"
251
+
252
+ Scenario: Parsing dependencies with "a"
253
253
  Given the survey
254
254
  """
255
255
  survey "Dependencies with 'a'" do
@@ -273,7 +273,7 @@ Feature: Survey creation
273
273
  | rule_key |
274
274
  | A |
275
275
 
276
- Scenario: Dependencies with "q"
276
+ Scenario: Parsing dependencies with "q"
277
277
  Given the survey
278
278
  """
279
279
  survey "Dependencies with 'q'" do
@@ -1,9 +1,12 @@
1
- Feature: Survey creation
2
- As a
1
+ # The redcap parser feature should run last. If it runs in between other features that use the surveyor parser,
2
+ # it causes the DependencyCondition before_save :resolve_references hook to stop running, causing hard to trace failures.
3
+
4
+ Feature: Survey import from REDCap
5
+ As a developer
3
6
  I want to write out the survey in the DSL
4
7
  So that I can give it to survey participants
5
8
 
6
- Scenario: Basic questions
9
+ Scenario: Basic questions from REDCap
7
10
  Given I parse redcap file "REDCapDemoDatabase_DataDictionary.csv"
8
11
  Then there should be 1 survey with:
9
12
  ||
@@ -17,7 +20,7 @@ Feature: Survey creation
17
20
  | rule |
18
21
  | A |
19
22
  | A and B |
20
- Scenario: question level dependencies
23
+ Scenario: Question level dependencies from REDCap
21
24
  Given I parse redcap file "redcap_siblings.csv"
22
25
  Then there should be 1 survey with:
23
26
  ||
@@ -31,7 +34,7 @@ Feature: Survey creation
31
34
  And there should be 1 dependencies with:
32
35
  | rule |
33
36
  | A |
34
- Scenario: with different headers
37
+ Scenario: with different headers from REDCap
35
38
  Given I parse redcap file "redcap_new_headers.csv"
36
39
  Then there should be 1 survey with:
37
40
  ||
@@ -40,7 +43,7 @@ Feature: Survey creation
40
43
  And there should be 2 answers with:
41
44
  ||
42
45
 
43
- Scenario: with different whitespace
46
+ Scenario: with different whitespace from REDCap
44
47
  Given I parse redcap file "redcap_whitespace.csv"
45
48
  Then there should be 1 survey with:
46
49
  ||
@@ -50,7 +50,7 @@ module Formtastic
50
50
  end
51
51
  def surveyor_radio_input(method, options)
52
52
  collection = find_collection_for_column(method, options)
53
- html_options = strip_formtastic_options(options).merge(options.delete(:input_html) || {})
53
+ html_options = strip_formtastic_options(options).merge(options[:input_html] || {})
54
54
 
55
55
  input_name = generate_association_input_name(method)
56
56
  value_as_class = options.delete(:value_as_class)
@@ -78,8 +78,5 @@ module Formtastic
78
78
 
79
79
  Formtastic::Util.html_safe(list_item_content.join)
80
80
  end
81
- def date_input(method, options)
82
- string_input(method, options)
83
- end
84
81
  end
85
82
  end
@@ -4,15 +4,15 @@ module Surveyor
4
4
  source_root File.expand_path("../templates", __FILE__)
5
5
  desc "Generate surveyor README, migrations, assets and sample survey"
6
6
  class_option :skip_migrations, :type => :boolean, :desc => "skip migrations, but generate everything else"
7
-
7
+
8
8
  def readme
9
9
  copy_file "../../../../README.md", "surveys/README.md"
10
10
  end
11
- def migrations
11
+ def migrations
12
12
  unless options[:skip_migrations]
13
13
  # because all migration timestamps end up the same, causing a collision when running rake db:migrate
14
14
  # copied functionality from RAILS_GEM_PATH/lib/rails_generator/commands.rb
15
- %w(create_surveys create_survey_sections create_questions create_question_groups create_answers create_response_sets create_responses create_dependencies create_dependency_conditions create_validations create_validation_conditions add_display_order_to_surveys add_correct_answer_id_to_questions add_index_to_response_sets add_index_to_surveys add_unique_indicies add_section_id_to_responses add_default_value_to_answers add_api_ids add_display_type_to_answers).each_with_index do |model, i|
15
+ %w(create_surveys create_survey_sections create_questions create_question_groups create_answers create_response_sets create_responses create_dependencies create_dependency_conditions create_validations create_validation_conditions add_display_order_to_surveys add_correct_answer_id_to_questions add_index_to_response_sets add_index_to_surveys add_unique_indicies add_section_id_to_responses add_default_value_to_answers add_api_ids add_display_type_to_answers add_api_id_to_question_groups add_api_ids_to_response_sets_and_responses).each_with_index do |model, i|
16
16
  unless (prev_migrations = Dir.glob("db/migrate/[0-9]*_*.rb").grep(/[0-9]+_#{model}.rb$/)).empty?
17
17
  prev_migration_timestamp = prev_migrations[0].match(/([0-9]+)_#{model}.rb$/)[1]
18
18
  end
@@ -29,18 +29,19 @@ module Surveyor
29
29
  asset_path = File.expand_path("../#{path}", __FILE__)
30
30
  Dir.foreach(asset_path) do |f|
31
31
  next if File.directory?(f)
32
-
32
+
33
33
  from_path = "#{path.gsub('templates/public', 'public')}/#{f}"
34
34
  to_path = "#{path.gsub('templates/public', asset_directory)}/#{f}"
35
35
  to_path = to_path.gsub("/sass", "") if asset_directory == "vendor/assets"
36
36
  copy_file(from_path, to_path)
37
37
  end
38
38
  end
39
-
39
+
40
40
  end
41
41
  def surveys
42
42
  copy_file "surveys/kitchen_sink_survey.rb"
43
43
  copy_file "surveys/quiz.rb"
44
+ copy_file "surveys/date_survey.rb"
44
45
  end
45
46
  def locales
46
47
  directory "config/locales"
@@ -0,0 +1,9 @@
1
+ class AddApiIdToQuestionGroups < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :question_groups, :api_id, :string
4
+ end
5
+
6
+ def self.down
7
+ remove_column :question_groups, :api_id
8
+ end
9
+ end
@@ -0,0 +1,11 @@
1
+ class AddApiIdsToResponseSetsAndResponses < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :response_sets, :api_id, :string
4
+ add_column :responses, :api_id, :string
5
+ end
6
+
7
+ def self.down
8
+ remove_column :response_sets, :api_id
9
+ remove_column :responses, :api_id
10
+ end
11
+ end
@@ -0,0 +1,1277 @@
1
+ /*
2
+ * jQuery timepicker addon
3
+ * By: Trent Richardson [http://trentrichardson.com]
4
+ * Version 0.9.7
5
+ * Last Modified: 10/02/2011
6
+ *
7
+ * Copyright 2011 Trent Richardson
8
+ * Dual licensed under the MIT and GPL licenses.
9
+ * http://trentrichardson.com/Impromptu/GPL-LICENSE.txt
10
+ * http://trentrichardson.com/Impromptu/MIT-LICENSE.txt
11
+ *
12
+ * HERES THE CSS:
13
+ * .ui-timepicker-div .ui-widget-header { margin-bottom: 8px; }
14
+ * .ui-timepicker-div dl { text-align: left; }
15
+ * .ui-timepicker-div dl dt { height: 25px; }
16
+ * .ui-timepicker-div dl dd { margin: -25px 10px 10px 65px; }
17
+ * .ui-timepicker-div td { font-size: 90%; }
18
+ * .ui-tpicker-grid-label { background: none; border: none; margin: 0; padding: 0; }
19
+ */
20
+
21
+ (function($) {
22
+
23
+ $.extend($.ui, { timepicker: { version: "0.9.7" } });
24
+
25
+ /* Time picker manager.
26
+ Use the singleton instance of this class, $.timepicker, to interact with the time picker.
27
+ Settings for (groups of) time pickers are maintained in an instance object,
28
+ allowing multiple different settings on the same page. */
29
+
30
+ function Timepicker() {
31
+ this.regional = []; // Available regional settings, indexed by language code
32
+ this.regional[''] = { // Default regional settings
33
+ currentText: 'Now',
34
+ closeText: 'Done',
35
+ ampm: false,
36
+ amNames: ['AM', 'A'],
37
+ pmNames: ['PM', 'P'],
38
+ timeFormat: 'hh:mm tt',
39
+ timeSuffix: '',
40
+ timeOnlyTitle: 'Choose Time',
41
+ timeText: 'Time',
42
+ hourText: 'Hour',
43
+ minuteText: 'Minute',
44
+ secondText: 'Second',
45
+ millisecText: 'Millisecond',
46
+ timezoneText: 'Time Zone'
47
+ };
48
+ this._defaults = { // Global defaults for all the datetime picker instances
49
+ showButtonPanel: true,
50
+ timeOnly: false,
51
+ showHour: true,
52
+ showMinute: true,
53
+ showSecond: false,
54
+ showMillisec: false,
55
+ showTimezone: false,
56
+ showTime: true,
57
+ stepHour: 0.05,
58
+ stepMinute: 0.05,
59
+ stepSecond: 0.05,
60
+ stepMillisec: 0.5,
61
+ hour: 0,
62
+ minute: 0,
63
+ second: 0,
64
+ millisec: 0,
65
+ timezone: '+0000',
66
+ hourMin: 0,
67
+ minuteMin: 0,
68
+ secondMin: 0,
69
+ millisecMin: 0,
70
+ hourMax: 23,
71
+ minuteMax: 59,
72
+ secondMax: 59,
73
+ millisecMax: 999,
74
+ minDateTime: null,
75
+ maxDateTime: null,
76
+ onSelect: null,
77
+ hourGrid: 0,
78
+ minuteGrid: 0,
79
+ secondGrid: 0,
80
+ millisecGrid: 0,
81
+ alwaysSetTime: true,
82
+ separator: ' ',
83
+ altFieldTimeOnly: true,
84
+ showTimepicker: true,
85
+ timezoneIso8609: false,
86
+ timezoneList: null
87
+ };
88
+ $.extend(this._defaults, this.regional['']);
89
+ }
90
+
91
+ $.extend(Timepicker.prototype, {
92
+ $input: null,
93
+ $altInput: null,
94
+ $timeObj: null,
95
+ inst: null,
96
+ hour_slider: null,
97
+ minute_slider: null,
98
+ second_slider: null,
99
+ millisec_slider: null,
100
+ timezone_select: null,
101
+ hour: 0,
102
+ minute: 0,
103
+ second: 0,
104
+ millisec: 0,
105
+ timezone: '+0000',
106
+ hourMinOriginal: null,
107
+ minuteMinOriginal: null,
108
+ secondMinOriginal: null,
109
+ millisecMinOriginal: null,
110
+ hourMaxOriginal: null,
111
+ minuteMaxOriginal: null,
112
+ secondMaxOriginal: null,
113
+ millisecMaxOriginal: null,
114
+ ampm: '',
115
+ formattedDate: '',
116
+ formattedTime: '',
117
+ formattedDateTime: '',
118
+ timezoneList: null,
119
+
120
+ /* Override the default settings for all instances of the time picker.
121
+ @param settings object - the new settings to use as defaults (anonymous object)
122
+ @return the manager object */
123
+ setDefaults: function(settings) {
124
+ extendRemove(this._defaults, settings || {});
125
+ return this;
126
+ },
127
+
128
+ //########################################################################
129
+ // Create a new Timepicker instance
130
+ //########################################################################
131
+ _newInst: function($input, o) {
132
+ var tp_inst = new Timepicker(),
133
+ inlineSettings = {};
134
+
135
+ for (var attrName in this._defaults) {
136
+ var attrValue = $input.attr('time:' + attrName);
137
+ if (attrValue) {
138
+ try {
139
+ inlineSettings[attrName] = eval(attrValue);
140
+ } catch (err) {
141
+ inlineSettings[attrName] = attrValue;
142
+ }
143
+ }
144
+ }
145
+ tp_inst._defaults = $.extend({}, this._defaults, inlineSettings, o, {
146
+ beforeShow: function(input, dp_inst) {
147
+ if ($.isFunction(o.beforeShow))
148
+ o.beforeShow(input, dp_inst, tp_inst);
149
+ },
150
+ onChangeMonthYear: function(year, month, dp_inst) {
151
+ // Update the time as well : this prevents the time from disappearing from the $input field.
152
+ tp_inst._updateDateTime(dp_inst);
153
+ if ($.isFunction(o.onChangeMonthYear))
154
+ o.onChangeMonthYear.call($input[0], year, month, dp_inst, tp_inst);
155
+ },
156
+ onClose: function(dateText, dp_inst) {
157
+ if (tp_inst.timeDefined === true && $input.val() != '')
158
+ tp_inst._updateDateTime(dp_inst);
159
+ if ($.isFunction(o.onClose))
160
+ o.onClose.call($input[0], dateText, dp_inst, tp_inst);
161
+ },
162
+ timepicker: tp_inst // add timepicker as a property of datepicker: $.datepicker._get(dp_inst, 'timepicker');
163
+ });
164
+ tp_inst.amNames = $.map(tp_inst._defaults.amNames, function(val) { return val.toUpperCase() });
165
+ tp_inst.pmNames = $.map(tp_inst._defaults.pmNames, function(val) { return val.toUpperCase() });
166
+
167
+ if (tp_inst._defaults.timezoneList === null) {
168
+ var timezoneList = [];
169
+ for (var i = -11; i <= 12; i++)
170
+ timezoneList.push((i >= 0 ? '+' : '-') + ('0' + Math.abs(i).toString()).slice(-2) + '00');
171
+ if (tp_inst._defaults.timezoneIso8609)
172
+ timezoneList = $.map(timezoneList, function(val) {
173
+ return val == '+0000' ? 'Z' : (val.substring(0, 3) + ':' + val.substring(3));
174
+ });
175
+ tp_inst._defaults.timezoneList = timezoneList;
176
+ }
177
+
178
+ tp_inst.hour = tp_inst._defaults.hour;
179
+ tp_inst.minute = tp_inst._defaults.minute;
180
+ tp_inst.second = tp_inst._defaults.second;
181
+ tp_inst.millisec = tp_inst._defaults.millisec;
182
+ tp_inst.ampm = '';
183
+ tp_inst.$input = $input;
184
+
185
+ if (o.altField)
186
+ tp_inst.$altInput = $(o.altField)
187
+ .css({ cursor: 'pointer' })
188
+ .focus(function(){ $input.trigger("focus"); });
189
+
190
+ if(tp_inst._defaults.minDate==0 || tp_inst._defaults.minDateTime==0)
191
+ {
192
+ tp_inst._defaults.minDate=new Date();
193
+ }
194
+ if(tp_inst._defaults.maxDate==0 || tp_inst._defaults.maxDateTime==0)
195
+ {
196
+ tp_inst._defaults.maxDate=new Date();
197
+ }
198
+
199
+ // datepicker needs minDate/maxDate, timepicker needs minDateTime/maxDateTime..
200
+ if(tp_inst._defaults.minDate !== undefined && tp_inst._defaults.minDate instanceof Date)
201
+ tp_inst._defaults.minDateTime = new Date(tp_inst._defaults.minDate.getTime());
202
+ if(tp_inst._defaults.minDateTime !== undefined && tp_inst._defaults.minDateTime instanceof Date)
203
+ tp_inst._defaults.minDate = new Date(tp_inst._defaults.minDateTime.getTime());
204
+ if(tp_inst._defaults.maxDate !== undefined && tp_inst._defaults.maxDate instanceof Date)
205
+ tp_inst._defaults.maxDateTime = new Date(tp_inst._defaults.maxDate.getTime());
206
+ if(tp_inst._defaults.maxDateTime !== undefined && tp_inst._defaults.maxDateTime instanceof Date)
207
+ tp_inst._defaults.maxDate = new Date(tp_inst._defaults.maxDateTime.getTime());
208
+ return tp_inst;
209
+ },
210
+
211
+ //########################################################################
212
+ // add our sliders to the calendar
213
+ //########################################################################
214
+ _addTimePicker: function(dp_inst) {
215
+ var currDT = (this.$altInput && this._defaults.altFieldTimeOnly) ?
216
+ this.$input.val() + ' ' + this.$altInput.val() :
217
+ this.$input.val();
218
+
219
+ this.timeDefined = this._parseTime(currDT);
220
+ this._limitMinMaxDateTime(dp_inst, false);
221
+ this._injectTimePicker();
222
+ },
223
+
224
+ //########################################################################
225
+ // parse the time string from input value or _setTime
226
+ //########################################################################
227
+ _parseTime: function(timeString, withDate) {
228
+ var regstr = this._defaults.timeFormat.toString()
229
+ .replace(/h{1,2}/ig, '(\\d?\\d)')
230
+ .replace(/m{1,2}/ig, '(\\d?\\d)')
231
+ .replace(/s{1,2}/ig, '(\\d?\\d)')
232
+ .replace(/l{1}/ig, '(\\d?\\d?\\d)')
233
+ .replace(/t{1,2}/ig, this._getPatternAmpm())
234
+ .replace(/z{1}/ig, '(z|[-+]\\d\\d:?\\d\\d)?')
235
+ .replace(/\s/g, '\\s?') + this._defaults.timeSuffix + '$',
236
+ order = this._getFormatPositions(),
237
+ ampm = '',
238
+ treg;
239
+
240
+ if (!this.inst) this.inst = $.datepicker._getInst(this.$input[0]);
241
+
242
+ if (withDate || !this._defaults.timeOnly) {
243
+ // the time should come after x number of characters and a space.
244
+ // x = at least the length of text specified by the date format
245
+ var dp_dateFormat = $.datepicker._get(this.inst, 'dateFormat');
246
+ // escape special regex characters in the seperator
247
+ var specials = new RegExp("[.*+?|()\\[\\]{}\\\\]", "g");
248
+ regstr = '.{' + dp_dateFormat.length + ',}' + this._defaults.separator.replace(specials, "\\$&") + regstr;
249
+ }
250
+
251
+ treg = timeString.match(new RegExp(regstr, 'i'));
252
+
253
+ if (treg) {
254
+ if (order.t !== -1) {
255
+ if (treg[order.t] === undefined || treg[order.t].length === 0) {
256
+ ampm = '';
257
+ this.ampm = '';
258
+ } else {
259
+ ampm = $.inArray(treg[order.t].toUpperCase(), this.amNames) !== -1 ? 'AM' : 'PM';
260
+ this.ampm = this._defaults[ampm == 'AM' ? 'amNames' : 'pmNames'][0];
261
+ }
262
+ }
263
+
264
+ if (order.h !== -1) {
265
+ if (ampm == 'AM' && treg[order.h] == '12')
266
+ this.hour = 0; // 12am = 0 hour
267
+ else if (ampm == 'PM' && treg[order.h] != '12')
268
+ this.hour = (parseFloat(treg[order.h]) + 12).toFixed(0); // 12pm = 12 hour, any other pm = hour + 12
269
+ else this.hour = Number(treg[order.h]);
270
+ }
271
+
272
+ if (order.m !== -1) this.minute = Number(treg[order.m]);
273
+ if (order.s !== -1) this.second = Number(treg[order.s]);
274
+ if (order.l !== -1) this.millisec = Number(treg[order.l]);
275
+ if (order.z !== -1 && treg[order.z] !== undefined) {
276
+ var tz = treg[order.z].toUpperCase();
277
+ switch (tz.length) {
278
+ case 1: // Z
279
+ tz = this._defaults.timezoneIso8609 ? 'Z' : '+0000';
280
+ break;
281
+ case 5: // +hhmm
282
+ if (this._defaults.timezoneIso8609)
283
+ tz = tz.substring(1) == '0000'
284
+ ? 'Z'
285
+ : tz.substring(0, 3) + ':' + tz.substring(3);
286
+ break;
287
+ case 6: // +hh:mm
288
+ if (!this._defaults.timezoneIso8609)
289
+ tz = tz == 'Z' || tz.substring(1) == '00:00'
290
+ ? '+0000'
291
+ : tz.replace(/:/, '');
292
+ else if (tz.substring(1) == '00:00')
293
+ tz = 'Z';
294
+ break;
295
+ }
296
+ this.timezone = tz;
297
+ }
298
+
299
+ return true;
300
+
301
+ }
302
+ return false;
303
+ },
304
+
305
+ //########################################################################
306
+ // pattern for standard and localized AM/PM markers
307
+ //########################################################################
308
+ _getPatternAmpm: function() {
309
+ var markers = [];
310
+ o = this._defaults;
311
+ if (o.amNames)
312
+ $.merge(markers, o.amNames);
313
+ if (o.pmNames)
314
+ $.merge(markers, o.pmNames);
315
+ markers = $.map(markers, function(val) { return val.replace(/[.*+?|()\[\]{}\\]/g, '\\$&') });
316
+ return '(' + markers.join('|') + ')?';
317
+ },
318
+
319
+ //########################################################################
320
+ // figure out position of time elements.. cause js cant do named captures
321
+ //########################################################################
322
+ _getFormatPositions: function() {
323
+ var finds = this._defaults.timeFormat.toLowerCase().match(/(h{1,2}|m{1,2}|s{1,2}|l{1}|t{1,2}|z)/g),
324
+ orders = { h: -1, m: -1, s: -1, l: -1, t: -1, z: -1 };
325
+
326
+ if (finds)
327
+ for (var i = 0; i < finds.length; i++)
328
+ if (orders[finds[i].toString().charAt(0)] == -1)
329
+ orders[finds[i].toString().charAt(0)] = i + 1;
330
+
331
+ return orders;
332
+ },
333
+
334
+ //########################################################################
335
+ // generate and inject html for timepicker into ui datepicker
336
+ //########################################################################
337
+ _injectTimePicker: function() {
338
+ var $dp = this.inst.dpDiv,
339
+ o = this._defaults,
340
+ tp_inst = this,
341
+ // Added by Peter Medeiros:
342
+ // - Figure out what the hour/minute/second max should be based on the step values.
343
+ // - Example: if stepMinute is 15, then minMax is 45.
344
+ hourMax = (o.hourMax - ((o.hourMax - o.hourMin) % o.stepHour)).toFixed(0),
345
+ minMax = (o.minuteMax - ((o.minuteMax - o.minuteMin) % o.stepMinute)).toFixed(0),
346
+ secMax = (o.secondMax - ((o.secondMax - o.secondMin) % o.stepSecond)).toFixed(0),
347
+ millisecMax = (o.millisecMax - ((o.millisecMax - o.millisecMin) % o.stepMillisec)).toFixed(0),
348
+ dp_id = this.inst.id.toString().replace(/([^A-Za-z0-9_])/g, '');
349
+
350
+ // Prevent displaying twice
351
+ //if ($dp.find("div#ui-timepicker-div-"+ dp_id).length === 0) {
352
+ if ($dp.find("div#ui-timepicker-div-"+ dp_id).length === 0 && o.showTimepicker) {
353
+ var noDisplay = ' style="display:none;"',
354
+ html = '<div class="ui-timepicker-div" id="ui-timepicker-div-' + dp_id + '"><dl>' +
355
+ '<dt class="ui_tpicker_time_label" id="ui_tpicker_time_label_' + dp_id + '"' +
356
+ ((o.showTime) ? '' : noDisplay) + '>' + o.timeText + '</dt>' +
357
+ '<dd class="ui_tpicker_time" id="ui_tpicker_time_' + dp_id + '"' +
358
+ ((o.showTime) ? '' : noDisplay) + '></dd>' +
359
+ '<dt class="ui_tpicker_hour_label" id="ui_tpicker_hour_label_' + dp_id + '"' +
360
+ ((o.showHour) ? '' : noDisplay) + '>' + o.hourText + '</dt>',
361
+ hourGridSize = 0,
362
+ minuteGridSize = 0,
363
+ secondGridSize = 0,
364
+ millisecGridSize = 0,
365
+ size;
366
+
367
+ // Hours
368
+ if (o.showHour && o.hourGrid > 0) {
369
+ html += '<dd class="ui_tpicker_hour">' +
370
+ '<div id="ui_tpicker_hour_' + dp_id + '"' + ((o.showHour) ? '' : noDisplay) + '></div>' +
371
+ '<div style="padding-left: 1px"><table class="ui-tpicker-grid-label"><tr>';
372
+
373
+ for (var h = o.hourMin; h <= hourMax; h += parseInt(o.hourGrid,10)) {
374
+ hourGridSize++;
375
+ var tmph = (o.ampm && h > 12) ? h-12 : h;
376
+ if (tmph < 10) tmph = '0' + tmph;
377
+ if (o.ampm) {
378
+ if (h == 0) tmph = 12 +'a';
379
+ else if (h < 12) tmph += 'a';
380
+ else tmph += 'p';
381
+ }
382
+ html += '<td>' + tmph + '</td>';
383
+ }
384
+
385
+ html += '</tr></table></div>' +
386
+ '</dd>';
387
+ } else html += '<dd class="ui_tpicker_hour" id="ui_tpicker_hour_' + dp_id + '"' +
388
+ ((o.showHour) ? '' : noDisplay) + '></dd>';
389
+
390
+ html += '<dt class="ui_tpicker_minute_label" id="ui_tpicker_minute_label_' + dp_id + '"' +
391
+ ((o.showMinute) ? '' : noDisplay) + '>' + o.minuteText + '</dt>';
392
+
393
+ // Minutes
394
+ if (o.showMinute && o.minuteGrid > 0) {
395
+ html += '<dd class="ui_tpicker_minute ui_tpicker_minute_' + o.minuteGrid + '">' +
396
+ '<div id="ui_tpicker_minute_' + dp_id + '"' +
397
+ ((o.showMinute) ? '' : noDisplay) + '></div>' +
398
+ '<div style="padding-left: 1px"><table class="ui-tpicker-grid-label"><tr>';
399
+
400
+ for (var m = o.minuteMin; m <= minMax; m += parseInt(o.minuteGrid,10)) {
401
+ minuteGridSize++;
402
+ html += '<td>' + ((m < 10) ? '0' : '') + m + '</td>';
403
+ }
404
+
405
+ html += '</tr></table></div>' +
406
+ '</dd>';
407
+ } else html += '<dd class="ui_tpicker_minute" id="ui_tpicker_minute_' + dp_id + '"' +
408
+ ((o.showMinute) ? '' : noDisplay) + '></dd>';
409
+
410
+ // Seconds
411
+ html += '<dt class="ui_tpicker_second_label" id="ui_tpicker_second_label_' + dp_id + '"' +
412
+ ((o.showSecond) ? '' : noDisplay) + '>' + o.secondText + '</dt>';
413
+
414
+ if (o.showSecond && o.secondGrid > 0) {
415
+ html += '<dd class="ui_tpicker_second ui_tpicker_second_' + o.secondGrid + '">' +
416
+ '<div id="ui_tpicker_second_' + dp_id + '"' +
417
+ ((o.showSecond) ? '' : noDisplay) + '></div>' +
418
+ '<div style="padding-left: 1px"><table><tr>';
419
+
420
+ for (var s = o.secondMin; s <= secMax; s += parseInt(o.secondGrid,10)) {
421
+ secondGridSize++;
422
+ html += '<td>' + ((s < 10) ? '0' : '') + s + '</td>';
423
+ }
424
+
425
+ html += '</tr></table></div>' +
426
+ '</dd>';
427
+ } else html += '<dd class="ui_tpicker_second" id="ui_tpicker_second_' + dp_id + '"' +
428
+ ((o.showSecond) ? '' : noDisplay) + '></dd>';
429
+
430
+ // Milliseconds
431
+ html += '<dt class="ui_tpicker_millisec_label" id="ui_tpicker_millisec_label_' + dp_id + '"' +
432
+ ((o.showMillisec) ? '' : noDisplay) + '>' + o.millisecText + '</dt>';
433
+
434
+ if (o.showMillisec && o.millisecGrid > 0) {
435
+ html += '<dd class="ui_tpicker_millisec ui_tpicker_millisec_' + o.millisecGrid + '">' +
436
+ '<div id="ui_tpicker_millisec_' + dp_id + '"' +
437
+ ((o.showMillisec) ? '' : noDisplay) + '></div>' +
438
+ '<div style="padding-left: 1px"><table><tr>';
439
+
440
+ for (var l = o.millisecMin; l <= millisecMax; l += parseInt(o.millisecGrid,10)) {
441
+ millisecGridSize++;
442
+ html += '<td>' + ((l < 10) ? '0' : '') + s + '</td>';
443
+ }
444
+
445
+ html += '</tr></table></div>' +
446
+ '</dd>';
447
+ } else html += '<dd class="ui_tpicker_millisec" id="ui_tpicker_millisec_' + dp_id + '"' +
448
+ ((o.showMillisec) ? '' : noDisplay) + '></dd>';
449
+
450
+ // Timezone
451
+ html += '<dt class="ui_tpicker_timezone_label" id="ui_tpicker_timezone_label_' + dp_id + '"' +
452
+ ((o.showTimezone) ? '' : noDisplay) + '>' + o.timezoneText + '</dt>';
453
+ html += '<dd class="ui_tpicker_timezone" id="ui_tpicker_timezone_' + dp_id + '"' +
454
+ ((o.showTimezone) ? '' : noDisplay) + '></dd>';
455
+
456
+ html += '</dl></div>';
457
+ $tp = $(html);
458
+
459
+ // if we only want time picker...
460
+ if (o.timeOnly === true) {
461
+ $tp.prepend(
462
+ '<div class="ui-widget-header ui-helper-clearfix ui-corner-all">' +
463
+ '<div class="ui-datepicker-title">' + o.timeOnlyTitle + '</div>' +
464
+ '</div>');
465
+ $dp.find('.ui-datepicker-header, .ui-datepicker-calendar').hide();
466
+ }
467
+
468
+ this.hour_slider = $tp.find('#ui_tpicker_hour_'+ dp_id).slider({
469
+ orientation: "horizontal",
470
+ value: this.hour,
471
+ min: o.hourMin,
472
+ max: hourMax,
473
+ step: o.stepHour,
474
+ slide: function(event, ui) {
475
+ tp_inst.hour_slider.slider( "option", "value", ui.value);
476
+ tp_inst._onTimeChange();
477
+ }
478
+ });
479
+
480
+ // Updated by Peter Medeiros:
481
+ // - Pass in Event and UI instance into slide function
482
+ this.minute_slider = $tp.find('#ui_tpicker_minute_'+ dp_id).slider({
483
+ orientation: "horizontal",
484
+ value: this.minute,
485
+ min: o.minuteMin,
486
+ max: minMax,
487
+ step: o.stepMinute,
488
+ slide: function(event, ui) {
489
+ // update the global minute slider instance value with the current slider value
490
+ tp_inst.minute_slider.slider( "option", "value", ui.value);
491
+ tp_inst._onTimeChange();
492
+ }
493
+ });
494
+
495
+ this.second_slider = $tp.find('#ui_tpicker_second_'+ dp_id).slider({
496
+ orientation: "horizontal",
497
+ value: this.second,
498
+ min: o.secondMin,
499
+ max: secMax,
500
+ step: o.stepSecond,
501
+ slide: function(event, ui) {
502
+ tp_inst.second_slider.slider( "option", "value", ui.value);
503
+ tp_inst._onTimeChange();
504
+ }
505
+ });
506
+
507
+ this.millisec_slider = $tp.find('#ui_tpicker_millisec_'+ dp_id).slider({
508
+ orientation: "horizontal",
509
+ value: this.millisec,
510
+ min: o.millisecMin,
511
+ max: millisecMax,
512
+ step: o.stepMillisec,
513
+ slide: function(event, ui) {
514
+ tp_inst.millisec_slider.slider( "option", "value", ui.value);
515
+ tp_inst._onTimeChange();
516
+ }
517
+ });
518
+
519
+ this.timezone_select = $tp.find('#ui_tpicker_timezone_'+ dp_id).append('<select></select>').find("select");
520
+ $.fn.append.apply(this.timezone_select,
521
+ $.map(o.timezoneList, function(val, idx) {
522
+ return $("<option />")
523
+ .val(typeof val == "object" ? val.value : val)
524
+ .text(typeof val == "object" ? val.label : val);
525
+ })
526
+ );
527
+ this.timezone_select.val((typeof this.timezone != "undefined" && this.timezone != null && this.timezone != "") ? this.timezone : o.timezone);
528
+ this.timezone_select.change(function() {
529
+ tp_inst._onTimeChange();
530
+ });
531
+
532
+ // Add grid functionality
533
+ if (o.showHour && o.hourGrid > 0) {
534
+ size = 100 * hourGridSize * o.hourGrid / (hourMax - o.hourMin);
535
+
536
+ $tp.find(".ui_tpicker_hour table").css({
537
+ width: size + "%",
538
+ marginLeft: (size / (-2 * hourGridSize)) + "%",
539
+ borderCollapse: 'collapse'
540
+ }).find("td").each( function(index) {
541
+ $(this).click(function() {
542
+ var h = $(this).html();
543
+ if(o.ampm) {
544
+ var ap = h.substring(2).toLowerCase(),
545
+ aph = parseInt(h.substring(0,2), 10);
546
+ if (ap == 'a') {
547
+ if (aph == 12) h = 0;
548
+ else h = aph;
549
+ } else if (aph == 12) h = 12;
550
+ else h = aph + 12;
551
+ }
552
+ tp_inst.hour_slider.slider("option", "value", h);
553
+ tp_inst._onTimeChange();
554
+ tp_inst._onSelectHandler();
555
+ }).css({
556
+ cursor: 'pointer',
557
+ width: (100 / hourGridSize) + '%',
558
+ textAlign: 'center',
559
+ overflow: 'hidden'
560
+ });
561
+ });
562
+ }
563
+
564
+ if (o.showMinute && o.minuteGrid > 0) {
565
+ size = 100 * minuteGridSize * o.minuteGrid / (minMax - o.minuteMin);
566
+ $tp.find(".ui_tpicker_minute table").css({
567
+ width: size + "%",
568
+ marginLeft: (size / (-2 * minuteGridSize)) + "%",
569
+ borderCollapse: 'collapse'
570
+ }).find("td").each(function(index) {
571
+ $(this).click(function() {
572
+ tp_inst.minute_slider.slider("option", "value", $(this).html());
573
+ tp_inst._onTimeChange();
574
+ tp_inst._onSelectHandler();
575
+ }).css({
576
+ cursor: 'pointer',
577
+ width: (100 / minuteGridSize) + '%',
578
+ textAlign: 'center',
579
+ overflow: 'hidden'
580
+ });
581
+ });
582
+ }
583
+
584
+ if (o.showSecond && o.secondGrid > 0) {
585
+ $tp.find(".ui_tpicker_second table").css({
586
+ width: size + "%",
587
+ marginLeft: (size / (-2 * secondGridSize)) + "%",
588
+ borderCollapse: 'collapse'
589
+ }).find("td").each(function(index) {
590
+ $(this).click(function() {
591
+ tp_inst.second_slider.slider("option", "value", $(this).html());
592
+ tp_inst._onTimeChange();
593
+ tp_inst._onSelectHandler();
594
+ }).css({
595
+ cursor: 'pointer',
596
+ width: (100 / secondGridSize) + '%',
597
+ textAlign: 'center',
598
+ overflow: 'hidden'
599
+ });
600
+ });
601
+ }
602
+
603
+ if (o.showMillisec && o.millisecGrid > 0) {
604
+ $tp.find(".ui_tpicker_millisec table").css({
605
+ width: size + "%",
606
+ marginLeft: (size / (-2 * millisecGridSize)) + "%",
607
+ borderCollapse: 'collapse'
608
+ }).find("td").each(function(index) {
609
+ $(this).click(function() {
610
+ tp_inst.millisec_slider.slider("option", "value", $(this).html());
611
+ tp_inst._onTimeChange();
612
+ tp_inst._onSelectHandler();
613
+ }).css({
614
+ cursor: 'pointer',
615
+ width: (100 / millisecGridSize) + '%',
616
+ textAlign: 'center',
617
+ overflow: 'hidden'
618
+ });
619
+ });
620
+ }
621
+
622
+ var $buttonPanel = $dp.find('.ui-datepicker-buttonpane');
623
+ if ($buttonPanel.length) $buttonPanel.before($tp);
624
+ else $dp.append($tp);
625
+
626
+ this.$timeObj = $tp.find('#ui_tpicker_time_'+ dp_id);
627
+
628
+ if (this.inst !== null) {
629
+ var timeDefined = this.timeDefined;
630
+ this._onTimeChange();
631
+ this.timeDefined = timeDefined;
632
+ }
633
+
634
+ //Emulate datepicker onSelect behavior. Call on slidestop.
635
+ var onSelectDelegate = function() {
636
+ tp_inst._onSelectHandler();
637
+ };
638
+ this.hour_slider.bind('slidestop',onSelectDelegate);
639
+ this.minute_slider.bind('slidestop',onSelectDelegate);
640
+ this.second_slider.bind('slidestop',onSelectDelegate);
641
+ this.millisec_slider.bind('slidestop',onSelectDelegate);
642
+ }
643
+ },
644
+
645
+ //########################################################################
646
+ // This function tries to limit the ability to go outside the
647
+ // min/max date range
648
+ //########################################################################
649
+ _limitMinMaxDateTime: function(dp_inst, adjustSliders){
650
+ var o = this._defaults,
651
+ dp_date = new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay);
652
+
653
+ if(!this._defaults.showTimepicker) return; // No time so nothing to check here
654
+
655
+ if($.datepicker._get(dp_inst, 'minDateTime') !== null && $.datepicker._get(dp_inst, 'minDateTime') !== undefined && dp_date){
656
+ var minDateTime = $.datepicker._get(dp_inst, 'minDateTime'),
657
+ minDateTimeDate = new Date(minDateTime.getFullYear(), minDateTime.getMonth(), minDateTime.getDate(), 0, 0, 0, 0);
658
+
659
+ if(this.hourMinOriginal === null || this.minuteMinOriginal === null || this.secondMinOriginal === null || this.millisecMinOriginal === null){
660
+ this.hourMinOriginal = o.hourMin;
661
+ this.minuteMinOriginal = o.minuteMin;
662
+ this.secondMinOriginal = o.secondMin;
663
+ this.millisecMinOriginal = o.millisecMin;
664
+ }
665
+
666
+ if(dp_inst.settings.timeOnly || minDateTimeDate.getTime() == dp_date.getTime()) {
667
+ this._defaults.hourMin = minDateTime.getHours();
668
+ if (this.hour <= this._defaults.hourMin) {
669
+ this.hour = this._defaults.hourMin;
670
+ this._defaults.minuteMin = minDateTime.getMinutes();
671
+ if (this.minute <= this._defaults.minuteMin) {
672
+ this.minute = this._defaults.minuteMin;
673
+ this._defaults.secondMin = minDateTime.getSeconds();
674
+ } else if (this.second <= this._defaults.secondMin){
675
+ this.second = this._defaults.secondMin;
676
+ this._defaults.millisecMin = minDateTime.getMilliseconds();
677
+ } else {
678
+ if(this.millisec < this._defaults.millisecMin)
679
+ this.millisec = this._defaults.millisecMin;
680
+ this._defaults.millisecMin = this.millisecMinOriginal;
681
+ }
682
+ } else {
683
+ this._defaults.minuteMin = this.minuteMinOriginal;
684
+ this._defaults.secondMin = this.secondMinOriginal;
685
+ this._defaults.millisecMin = this.millisecMinOriginal;
686
+ }
687
+ }else{
688
+ this._defaults.hourMin = this.hourMinOriginal;
689
+ this._defaults.minuteMin = this.minuteMinOriginal;
690
+ this._defaults.secondMin = this.secondMinOriginal;
691
+ this._defaults.millisecMin = this.millisecMinOriginal;
692
+ }
693
+ }
694
+
695
+ if($.datepicker._get(dp_inst, 'maxDateTime') !== null && $.datepicker._get(dp_inst, 'maxDateTime') !== undefined && dp_date){
696
+ var maxDateTime = $.datepicker._get(dp_inst, 'maxDateTime'),
697
+ maxDateTimeDate = new Date(maxDateTime.getFullYear(), maxDateTime.getMonth(), maxDateTime.getDate(), 0, 0, 0, 0);
698
+
699
+ if(this.hourMaxOriginal === null || this.minuteMaxOriginal === null || this.secondMaxOriginal === null){
700
+ this.hourMaxOriginal = o.hourMax;
701
+ this.minuteMaxOriginal = o.minuteMax;
702
+ this.secondMaxOriginal = o.secondMax;
703
+ this.millisecMaxOriginal = o.millisecMax;
704
+ }
705
+
706
+ if(dp_inst.settings.timeOnly || maxDateTimeDate.getTime() == dp_date.getTime()){
707
+ this._defaults.hourMax = maxDateTime.getHours();
708
+ if (this.hour >= this._defaults.hourMax) {
709
+ this.hour = this._defaults.hourMax;
710
+ this._defaults.minuteMax = maxDateTime.getMinutes();
711
+ if (this.minute >= this._defaults.minuteMax) {
712
+ this.minute = this._defaults.minuteMax;
713
+ this._defaults.secondMax = maxDateTime.getSeconds();
714
+ } else if (this.second >= this._defaults.secondMax) {
715
+ this.second = this._defaults.secondMax;
716
+ this._defaults.millisecMax = maxDateTime.getMilliseconds();
717
+ } else {
718
+ if(this.millisec > this._defaults.millisecMax) this.millisec = this._defaults.millisecMax;
719
+ this._defaults.millisecMax = this.millisecMaxOriginal;
720
+ }
721
+ } else {
722
+ this._defaults.minuteMax = this.minuteMaxOriginal;
723
+ this._defaults.secondMax = this.secondMaxOriginal;
724
+ this._defaults.millisecMax = this.millisecMaxOriginal;
725
+ }
726
+ }else{
727
+ this._defaults.hourMax = this.hourMaxOriginal;
728
+ this._defaults.minuteMax = this.minuteMaxOriginal;
729
+ this._defaults.secondMax = this.secondMaxOriginal;
730
+ this._defaults.millisecMax = this.millisecMaxOriginal;
731
+ }
732
+ }
733
+
734
+ if(adjustSliders !== undefined && adjustSliders === true){
735
+ var hourMax = (this._defaults.hourMax - ((this._defaults.hourMax - this._defaults.hourMin) % this._defaults.stepHour)).toFixed(0),
736
+ minMax = (this._defaults.minuteMax - ((this._defaults.minuteMax - this._defaults.minuteMin) % this._defaults.stepMinute)).toFixed(0),
737
+ secMax = (this._defaults.secondMax - ((this._defaults.secondMax - this._defaults.secondMin) % this._defaults.stepSecond)).toFixed(0),
738
+ millisecMax = (this._defaults.millisecMax - ((this._defaults.millisecMax - this._defaults.millisecMin) % this._defaults.stepMillisec)).toFixed(0);
739
+
740
+ if(this.hour_slider)
741
+ this.hour_slider.slider("option", { min: this._defaults.hourMin, max: hourMax }).slider('value', this.hour);
742
+ if(this.minute_slider)
743
+ this.minute_slider.slider("option", { min: this._defaults.minuteMin, max: minMax }).slider('value', this.minute);
744
+ if(this.second_slider)
745
+ this.second_slider.slider("option", { min: this._defaults.secondMin, max: secMax }).slider('value', this.second);
746
+ if(this.millisec_slider)
747
+ this.millisec_slider.slider("option", { min: this._defaults.millisecMin, max: millisecMax }).slider('value', this.millisec);
748
+ }
749
+
750
+ },
751
+
752
+
753
+ //########################################################################
754
+ // when a slider moves, set the internal time...
755
+ // on time change is also called when the time is updated in the text field
756
+ //########################################################################
757
+ _onTimeChange: function() {
758
+ var hour = (this.hour_slider) ? this.hour_slider.slider('value') : false,
759
+ minute = (this.minute_slider) ? this.minute_slider.slider('value') : false,
760
+ second = (this.second_slider) ? this.second_slider.slider('value') : false,
761
+ millisec = (this.millisec_slider) ? this.millisec_slider.slider('value') : false,
762
+ timezone = (this.timezone_select) ? this.timezone_select.val() : false,
763
+ o = this._defaults;
764
+
765
+ if (typeof(hour) == 'object') hour = false;
766
+ if (typeof(minute) == 'object') minute = false;
767
+ if (typeof(second) == 'object') second = false;
768
+ if (typeof(millisec) == 'object') millisec = false;
769
+ if (typeof(timezone) == 'object') timezone = false;
770
+
771
+ if (hour !== false) hour = parseInt(hour,10);
772
+ if (minute !== false) minute = parseInt(minute,10);
773
+ if (second !== false) second = parseInt(second,10);
774
+ if (millisec !== false) millisec = parseInt(millisec,10);
775
+
776
+ var ampm = o[hour < 12 ? 'amNames' : 'pmNames'][0];
777
+
778
+ // If the update was done in the input field, the input field should not be updated.
779
+ // If the update was done using the sliders, update the input field.
780
+ var hasChanged = (hour != this.hour || minute != this.minute
781
+ || second != this.second || millisec != this.millisec
782
+ || (this.ampm.length > 0
783
+ && (hour < 12) != ($.inArray(this.ampm.toUpperCase(), this.amNames) !== -1))
784
+ || timezone != this.timezone);
785
+
786
+ if (hasChanged) {
787
+
788
+ if (hour !== false)this.hour = hour;
789
+ if (minute !== false) this.minute = minute;
790
+ if (second !== false) this.second = second;
791
+ if (millisec !== false) this.millisec = millisec;
792
+ if (timezone !== false) this.timezone = timezone;
793
+
794
+ if (!this.inst) this.inst = $.datepicker._getInst(this.$input[0]);
795
+
796
+ this._limitMinMaxDateTime(this.inst, true);
797
+ }
798
+ if (o.ampm) this.ampm = ampm;
799
+
800
+ this._formatTime();
801
+ if (this.$timeObj) this.$timeObj.text(this.formattedTime + o.timeSuffix);
802
+ this.timeDefined = true;
803
+ if (hasChanged) this._updateDateTime();
804
+ },
805
+
806
+ //########################################################################
807
+ // call custom onSelect.
808
+ // bind to sliders slidestop, and grid click.
809
+ //########################################################################
810
+ _onSelectHandler: function() {
811
+ var onSelect = this._defaults.onSelect;
812
+ var inputEl = this.$input ? this.$input[0] : null;
813
+ if (onSelect && inputEl) {
814
+ onSelect.apply(inputEl, [this.formattedDateTime, this]);
815
+ }
816
+ },
817
+
818
+ //########################################################################
819
+ // format the time all pretty...
820
+ //########################################################################
821
+ _formatTime: function(time, format, ampm) {
822
+ if (ampm == undefined) ampm = this._defaults.ampm;
823
+ time = time || { hour: this.hour, minute: this.minute, second: this.second, millisec: this.millisec, ampm: this.ampm, timezone: this.timezone };
824
+ var tmptime = (format || this._defaults.timeFormat).toString();
825
+
826
+ var hour = parseInt(time.hour, 10);
827
+ if (ampm) {
828
+ if (!$.inArray(time.ampm.toUpperCase(), this.amNames) !== -1)
829
+ hour = hour % 12;
830
+ if (hour === 0)
831
+ hour = 12;
832
+ }
833
+ tmptime = tmptime.replace(/(?:hh?|mm?|ss?|[tT]{1,2}|[lz])/g, function(match) {
834
+ switch (match.toLowerCase()) {
835
+ case 'hh': return ('0' + hour).slice(-2);
836
+ case 'h': return hour;
837
+ case 'mm': return ('0' + time.minute).slice(-2);
838
+ case 'm': return time.minute;
839
+ case 'ss': return ('0' + time.second).slice(-2);
840
+ case 's': return time.second;
841
+ case 'l': return ('00' + time.millisec).slice(-3);
842
+ case 'z': return time.timezone;
843
+ case 't': case 'tt':
844
+ if (ampm) {
845
+ var _ampm = time.ampm;
846
+ if (match.length == 1)
847
+ _ampm = _ampm.charAt(0);
848
+ return match.charAt(0) == 'T' ? _ampm.toUpperCase() : _ampm.toLowerCase();
849
+ }
850
+ return '';
851
+ }
852
+ });
853
+
854
+ if (arguments.length) return tmptime;
855
+ else this.formattedTime = tmptime;
856
+ },
857
+
858
+ //########################################################################
859
+ // update our input with the new date time..
860
+ //########################################################################
861
+ _updateDateTime: function(dp_inst) {
862
+ dp_inst = this.inst || dp_inst,
863
+ dt = new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay),
864
+ dateFmt = $.datepicker._get(dp_inst, 'dateFormat'),
865
+ formatCfg = $.datepicker._getFormatConfig(dp_inst),
866
+ timeAvailable = dt !== null && this.timeDefined;
867
+ this.formattedDate = $.datepicker.formatDate(dateFmt, (dt === null ? new Date() : dt), formatCfg);
868
+ var formattedDateTime = this.formattedDate;
869
+ if (dp_inst.lastVal !== undefined && (dp_inst.lastVal.length > 0 && this.$input.val().length === 0))
870
+ return;
871
+
872
+ if (this._defaults.timeOnly === true) {
873
+ formattedDateTime = this.formattedTime;
874
+ } else if (this._defaults.timeOnly !== true && (this._defaults.alwaysSetTime || timeAvailable)) {
875
+ formattedDateTime += this._defaults.separator + this.formattedTime + this._defaults.timeSuffix;
876
+ }
877
+
878
+ this.formattedDateTime = formattedDateTime;
879
+
880
+ if(!this._defaults.showTimepicker) {
881
+ this.$input.val(this.formattedDate);
882
+ } else if (this.$altInput && this._defaults.altFieldTimeOnly === true) {
883
+ this.$altInput.val(this.formattedTime);
884
+ this.$input.val(this.formattedDate);
885
+ } else if(this.$altInput) {
886
+ this.$altInput.val(formattedDateTime);
887
+ this.$input.val(formattedDateTime);
888
+ } else {
889
+ this.$input.val(formattedDateTime);
890
+ }
891
+
892
+ this.$input.trigger("change");
893
+ }
894
+
895
+ });
896
+
897
+ $.fn.extend({
898
+ //########################################################################
899
+ // shorthand just to use timepicker..
900
+ //########################################################################
901
+ timepicker: function(o) {
902
+ o = o || {};
903
+ var tmp_args = arguments;
904
+
905
+ if (typeof o == 'object') tmp_args[0] = $.extend(o, { timeOnly: true });
906
+
907
+ return $(this).each(function() {
908
+ $.fn.datetimepicker.apply($(this), tmp_args);
909
+ });
910
+ },
911
+
912
+ //########################################################################
913
+ // extend timepicker to datepicker
914
+ //########################################################################
915
+ datetimepicker: function(o) {
916
+ o = o || {};
917
+ var $input = this,
918
+ tmp_args = arguments;
919
+
920
+ if (typeof(o) == 'string'){
921
+ if(o == 'getDate')
922
+ return $.fn.datepicker.apply($(this[0]), tmp_args);
923
+ else
924
+ return this.each(function() {
925
+ var $t = $(this);
926
+ $t.datepicker.apply($t, tmp_args);
927
+ });
928
+ }
929
+ else
930
+ return this.each(function() {
931
+ var $t = $(this);
932
+ $t.datepicker($.timepicker._newInst($t, o)._defaults);
933
+ });
934
+ }
935
+ });
936
+
937
+ //########################################################################
938
+ // the bad hack :/ override datepicker so it doesnt close on select
939
+ // inspired: http://stackoverflow.com/questions/1252512/jquery-datepicker-prevent-closing-picker-when-clicking-a-date/1762378#1762378
940
+ //########################################################################
941
+ $.datepicker._base_selectDate = $.datepicker._selectDate;
942
+ $.datepicker._selectDate = function (id, dateStr) {
943
+ var inst = this._getInst($(id)[0]),
944
+ tp_inst = this._get(inst, 'timepicker');
945
+
946
+ if (tp_inst) {
947
+ tp_inst._limitMinMaxDateTime(inst, true);
948
+ inst.inline = inst.stay_open = true;
949
+ //This way the onSelect handler called from calendarpicker get the full dateTime
950
+ this._base_selectDate(id, dateStr);
951
+ inst.inline = inst.stay_open = false;
952
+ this._notifyChange(inst);
953
+ this._updateDatepicker(inst);
954
+ }
955
+ else this._base_selectDate(id, dateStr);
956
+ };
957
+
958
+ //#############################################################################################
959
+ // second bad hack :/ override datepicker so it triggers an event when changing the input field
960
+ // and does not redraw the datepicker on every selectDate event
961
+ //#############################################################################################
962
+ $.datepicker._base_updateDatepicker = $.datepicker._updateDatepicker;
963
+ $.datepicker._updateDatepicker = function(inst) {
964
+
965
+ // don't popup the datepicker if there is another instance already opened
966
+ var input = inst.input[0];
967
+ if($.datepicker._curInst &&
968
+ $.datepicker._curInst != inst &&
969
+ $.datepicker._datepickerShowing &&
970
+ $.datepicker._lastInput != input) {
971
+ return;
972
+ }
973
+
974
+ if (typeof(inst.stay_open) !== 'boolean' || inst.stay_open === false) {
975
+
976
+ this._base_updateDatepicker(inst);
977
+
978
+ // Reload the time control when changing something in the input text field.
979
+ var tp_inst = this._get(inst, 'timepicker');
980
+ if(tp_inst) tp_inst._addTimePicker(inst);
981
+ }
982
+ };
983
+
984
+ //#######################################################################################
985
+ // third bad hack :/ override datepicker so it allows spaces and colon in the input field
986
+ //#######################################################################################
987
+ $.datepicker._base_doKeyPress = $.datepicker._doKeyPress;
988
+ $.datepicker._doKeyPress = function(event) {
989
+ var inst = $.datepicker._getInst(event.target),
990
+ tp_inst = $.datepicker._get(inst, 'timepicker');
991
+
992
+ if (tp_inst) {
993
+ if ($.datepicker._get(inst, 'constrainInput')) {
994
+ var ampm = tp_inst._defaults.ampm,
995
+ dateChars = $.datepicker._possibleChars($.datepicker._get(inst, 'dateFormat')),
996
+ datetimeChars = tp_inst._defaults.timeFormat.toString()
997
+ .replace(/[hms]/g, '')
998
+ .replace(/TT/g, ampm ? 'APM' : '')
999
+ .replace(/Tt/g, ampm ? 'AaPpMm' : '')
1000
+ .replace(/tT/g, ampm ? 'AaPpMm' : '')
1001
+ .replace(/T/g, ampm ? 'AP' : '')
1002
+ .replace(/tt/g, ampm ? 'apm' : '')
1003
+ .replace(/t/g, ampm ? 'ap' : '') +
1004
+ " " +
1005
+ tp_inst._defaults.separator +
1006
+ tp_inst._defaults.timeSuffix +
1007
+ (tp_inst._defaults.showTimezone ? tp_inst._defaults.timezoneList.join('') : '') +
1008
+ (tp_inst._defaults.amNames.join('')) +
1009
+ (tp_inst._defaults.pmNames.join('')) +
1010
+ dateChars,
1011
+ chr = String.fromCharCode(event.charCode === undefined ? event.keyCode : event.charCode);
1012
+ return event.ctrlKey || (chr < ' ' || !dateChars || datetimeChars.indexOf(chr) > -1);
1013
+ }
1014
+ }
1015
+
1016
+ return $.datepicker._base_doKeyPress(event);
1017
+ };
1018
+
1019
+ //#######################################################################################
1020
+ // Override key up event to sync manual input changes.
1021
+ //#######################################################################################
1022
+ $.datepicker._base_doKeyUp = $.datepicker._doKeyUp;
1023
+ $.datepicker._doKeyUp = function (event) {
1024
+ var inst = $.datepicker._getInst(event.target),
1025
+ tp_inst = $.datepicker._get(inst, 'timepicker');
1026
+
1027
+ if (tp_inst) {
1028
+ if (tp_inst._defaults.timeOnly && (inst.input.val() != inst.lastVal)) {
1029
+ try {
1030
+ $.datepicker._updateDatepicker(inst);
1031
+ }
1032
+ catch (err) {
1033
+ $.datepicker.log(err);
1034
+ }
1035
+ }
1036
+ }
1037
+
1038
+ return $.datepicker._base_doKeyUp(event);
1039
+ };
1040
+
1041
+ //#######################################################################################
1042
+ // override "Today" button to also grab the time.
1043
+ //#######################################################################################
1044
+ $.datepicker._base_gotoToday = $.datepicker._gotoToday;
1045
+ $.datepicker._gotoToday = function(id) {
1046
+ var inst = this._getInst($(id)[0]),
1047
+ $dp = inst.dpDiv;
1048
+ this._base_gotoToday(id);
1049
+ var now = new Date();
1050
+ var tp_inst = this._get(inst, 'timepicker');
1051
+ if (tp_inst._defaults.showTimezone && tp_inst.timezone_select) {
1052
+ var tzoffset = now.getTimezoneOffset(); // If +0100, returns -60
1053
+ var tzsign = tzoffset > 0 ? '-' : '+';
1054
+ tzoffset = Math.abs(tzoffset);
1055
+ var tzmin = tzoffset % 60
1056
+ tzoffset = tzsign + ('0' + (tzoffset - tzmin) / 60).slice(-2) + ('0' + tzmin).slice(-2);
1057
+ if (tp_inst._defaults.timezoneIso8609)
1058
+ tzoffset = tzoffset.substring(0, 3) + ':' + tzoffset.substring(3);
1059
+ tp_inst.timezone_select.val(tzoffset);
1060
+ }
1061
+ this._setTime(inst, now);
1062
+ $( '.ui-datepicker-today', $dp).click();
1063
+ this._hideDatepicker();
1064
+ };
1065
+
1066
+ //#######################################################################################
1067
+ // Disable & enable the Time in the datetimepicker
1068
+ //#######################################################################################
1069
+ $.datepicker._disableTimepickerDatepicker = function(target, date, withDate) {
1070
+ var inst = this._getInst(target),
1071
+ tp_inst = this._get(inst, 'timepicker');
1072
+ $(target).datepicker('getDate'); // Init selected[Year|Month|Day]
1073
+ if (tp_inst) {
1074
+ tp_inst._defaults.showTimepicker = false;
1075
+ tp_inst._updateDateTime(inst);
1076
+ }
1077
+ };
1078
+
1079
+ $.datepicker._enableTimepickerDatepicker = function(target, date, withDate) {
1080
+ var inst = this._getInst(target),
1081
+ tp_inst = this._get(inst, 'timepicker');
1082
+ $(target).datepicker('getDate'); // Init selected[Year|Month|Day]
1083
+ if (tp_inst) {
1084
+ tp_inst._defaults.showTimepicker = true;
1085
+ tp_inst._addTimePicker(inst); // Could be disabled on page load
1086
+ tp_inst._updateDateTime(inst);
1087
+ }
1088
+ };
1089
+
1090
+ //#######################################################################################
1091
+ // Create our own set time function
1092
+ //#######################################################################################
1093
+ $.datepicker._setTime = function(inst, date) {
1094
+ var tp_inst = this._get(inst, 'timepicker');
1095
+ if (tp_inst) {
1096
+ var defaults = tp_inst._defaults,
1097
+ // calling _setTime with no date sets time to defaults
1098
+ hour = date ? date.getHours() : defaults.hour,
1099
+ minute = date ? date.getMinutes() : defaults.minute,
1100
+ second = date ? date.getSeconds() : defaults.second,
1101
+ millisec = date ? date.getMilliseconds() : defaults.millisec;
1102
+
1103
+ //check if within min/max times..
1104
+ if ((hour < defaults.hourMin || hour > defaults.hourMax) || (minute < defaults.minuteMin || minute > defaults.minuteMax) || (second < defaults.secondMin || second > defaults.secondMax) || (millisec < defaults.millisecMin || millisec > defaults.millisecMax)) {
1105
+ hour = defaults.hourMin;
1106
+ minute = defaults.minuteMin;
1107
+ second = defaults.secondMin;
1108
+ millisec = defaults.millisecMin;
1109
+ }
1110
+
1111
+ tp_inst.hour = hour;
1112
+ tp_inst.minute = minute;
1113
+ tp_inst.second = second;
1114
+ tp_inst.millisec = millisec;
1115
+
1116
+ if (tp_inst.hour_slider) tp_inst.hour_slider.slider('value', hour);
1117
+ if (tp_inst.minute_slider) tp_inst.minute_slider.slider('value', minute);
1118
+ if (tp_inst.second_slider) tp_inst.second_slider.slider('value', second);
1119
+ if (tp_inst.millisec_slider) tp_inst.millisec_slider.slider('value', millisec);
1120
+
1121
+ tp_inst._onTimeChange();
1122
+ tp_inst._updateDateTime(inst);
1123
+ }
1124
+ };
1125
+
1126
+ //#######################################################################################
1127
+ // Create new public method to set only time, callable as $().datepicker('setTime', date)
1128
+ //#######################################################################################
1129
+ $.datepicker._setTimeDatepicker = function(target, date, withDate) {
1130
+ var inst = this._getInst(target),
1131
+ tp_inst = this._get(inst, 'timepicker');
1132
+
1133
+ if (tp_inst) {
1134
+ this._setDateFromField(inst);
1135
+ var tp_date;
1136
+ if (date) {
1137
+ if (typeof date == "string") {
1138
+ tp_inst._parseTime(date, withDate);
1139
+ tp_date = new Date();
1140
+ tp_date.setHours(tp_inst.hour, tp_inst.minute, tp_inst.second, tp_inst.millisec);
1141
+ }
1142
+ else tp_date = new Date(date.getTime());
1143
+ if (tp_date.toString() == 'Invalid Date') tp_date = undefined;
1144
+ this._setTime(inst, tp_date);
1145
+ }
1146
+ }
1147
+
1148
+ };
1149
+
1150
+ //#######################################################################################
1151
+ // override setDate() to allow setting time too within Date object
1152
+ //#######################################################################################
1153
+ $.datepicker._base_setDateDatepicker = $.datepicker._setDateDatepicker;
1154
+ $.datepicker._setDateDatepicker = function(target, date) {
1155
+ var inst = this._getInst(target),
1156
+ tp_date = (date instanceof Date) ? new Date(date.getTime()) : date;
1157
+
1158
+ this._updateDatepicker(inst);
1159
+ this._base_setDateDatepicker.apply(this, arguments);
1160
+ this._setTimeDatepicker(target, tp_date, true);
1161
+ };
1162
+
1163
+ //#######################################################################################
1164
+ // override getDate() to allow getting time too within Date object
1165
+ //#######################################################################################
1166
+ $.datepicker._base_getDateDatepicker = $.datepicker._getDateDatepicker;
1167
+ $.datepicker._getDateDatepicker = function(target, noDefault) {
1168
+ var inst = this._getInst(target),
1169
+ tp_inst = this._get(inst, 'timepicker');
1170
+
1171
+ if (tp_inst) {
1172
+ this._setDateFromField(inst, noDefault);
1173
+ var date = this._getDate(inst);
1174
+ if (date && tp_inst._parseTime($(target).val(), tp_inst.timeOnly)) date.setHours(tp_inst.hour, tp_inst.minute, tp_inst.second, tp_inst.millisec);
1175
+ return date;
1176
+ }
1177
+ return this._base_getDateDatepicker(target, noDefault);
1178
+ };
1179
+
1180
+ //#######################################################################################
1181
+ // override parseDate() because UI 1.8.14 throws an error about "Extra characters"
1182
+ // An option in datapicker to ignore extra format characters would be nicer.
1183
+ //#######################################################################################
1184
+ $.datepicker._base_parseDate = $.datepicker.parseDate;
1185
+ $.datepicker.parseDate = function(format, value, settings) {
1186
+ var date;
1187
+ try {
1188
+ date = this._base_parseDate(format, value, settings);
1189
+ } catch (err) {
1190
+ // Hack! The error message ends with a colon, a space, and
1191
+ // the "extra" characters. We rely on that instead of
1192
+ // attempting to perfectly reproduce the parsing algorithm.
1193
+ date = this._base_parseDate(format, value.substring(0,value.length-(err.length-err.indexOf(':')-2)), settings);
1194
+ }
1195
+ return date;
1196
+ };
1197
+
1198
+ //#######################################################################################
1199
+ // override formatDate to set date with time to the input
1200
+ //#######################################################################################
1201
+ $.datepicker._base_formatDate=$.datepicker._formatDate;
1202
+ $.datepicker._formatDate = function(inst, day, month, year){
1203
+ var tp_inst = this._get(inst, 'timepicker');
1204
+ if(tp_inst)
1205
+ {
1206
+ if(day)
1207
+ var b = this._base_formatDate(inst, day, month, year);
1208
+ tp_inst._updateDateTime();
1209
+ return tp_inst.$input.val();
1210
+ }
1211
+ return this._base_formatDate(inst);
1212
+ }
1213
+
1214
+ //#######################################################################################
1215
+ // override options setter to add time to maxDate(Time) and minDate(Time). MaxDate
1216
+ //#######################################################################################
1217
+ $.datepicker._base_optionDatepicker = $.datepicker._optionDatepicker;
1218
+ $.datepicker._optionDatepicker = function(target, name, value) {
1219
+ var inst = this._getInst(target),
1220
+ tp_inst = this._get(inst, 'timepicker');
1221
+ if (tp_inst) {
1222
+ var min,max,onselect;
1223
+ if (typeof name == 'string') { // if min/max was set with the string
1224
+ if (name==='minDate' || name==='minDateTime' )
1225
+ min = value;
1226
+ else if (name==='maxDate' || name==='maxDateTime')
1227
+ max = value;
1228
+ else if (name==='onSelect')
1229
+ onselect=value;
1230
+ } else if (typeof name == 'object') { //if min/max was set with the JSON
1231
+ if(name.minDate)
1232
+ min = name.minDate;
1233
+ else if (name.minDateTime)
1234
+ min = name.minDateTime;
1235
+ else if (name.maxDate)
1236
+ max = name.maxDate;
1237
+ else if (name.maxDateTime)
1238
+ max = name.maxDateTime;
1239
+ }
1240
+ if(min){ //if min was set
1241
+ if(min==0)
1242
+ min=new Date();
1243
+ else
1244
+ min= new Date(min);
1245
+
1246
+ tp_inst._defaults.minDate = min;
1247
+ tp_inst._defaults.minDateTime = min;
1248
+ } else if (max){ //if max was set
1249
+ if(max==0)
1250
+ max=new Date();
1251
+ else
1252
+ max= new Date(max);
1253
+ tp_inst._defaults.maxDate = max;
1254
+ tp_inst._defaults.maxDateTime = max;
1255
+ }
1256
+ else if (onselect)
1257
+ tp_inst._defaults.onSelect=onselect;
1258
+ }
1259
+ this._base_optionDatepicker(target, name, value);
1260
+ };
1261
+
1262
+ //#######################################################################################
1263
+ // jQuery extend now ignores nulls!
1264
+ //#######################################################################################
1265
+ function extendRemove(target, props) {
1266
+ $.extend(target, props);
1267
+ for (var name in props)
1268
+ if (props[name] === null || props[name] === undefined)
1269
+ target[name] = props[name];
1270
+ return target;
1271
+ }
1272
+
1273
+ $.timepicker = new Timepicker(); // singleton instance
1274
+ $.timepicker.version = "0.9.7";
1275
+
1276
+ })(jQuery);
1277
+