active_scaffold 3.2.17 → 3.2.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (246) hide show
  1. data/CHANGELOG +5 -1
  2. metadata +17 -261
  3. data/app/assets/images/active_scaffold/add.png +0 -0
  4. data/app/assets/images/active_scaffold/arrow_down.png +0 -0
  5. data/app/assets/images/active_scaffold/arrow_up.png +0 -0
  6. data/app/assets/images/active_scaffold/close.png +0 -0
  7. data/app/assets/images/active_scaffold/close_touch.png +0 -0
  8. data/app/assets/images/active_scaffold/config.png +0 -0
  9. data/app/assets/images/active_scaffold/cross.png +0 -0
  10. data/app/assets/images/active_scaffold/gears.png +0 -0
  11. data/app/assets/images/active_scaffold/indicator-small.gif +0 -0
  12. data/app/assets/images/active_scaffold/indicator.gif +0 -0
  13. data/app/assets/images/active_scaffold/magnifier.png +0 -0
  14. data/app/assets/javascripts/active_scaffold.js.erb +0 -19
  15. data/app/assets/javascripts/jquery/active_scaffold.js +0 -1113
  16. data/app/assets/javascripts/jquery/date_picker_bridge.js.erb +0 -24
  17. data/app/assets/javascripts/jquery/draggable_lists.js +0 -27
  18. data/app/assets/javascripts/jquery/jquery.editinplace.js +0 -743
  19. data/app/assets/javascripts/jquery/tiny_mce_bridge.js +0 -7
  20. data/app/assets/javascripts/prototype/active_scaffold.js +0 -1107
  21. data/app/assets/javascripts/prototype/dhtml_history.js +0 -870
  22. data/app/assets/javascripts/prototype/form_enhancements.js +0 -117
  23. data/app/assets/javascripts/prototype/rico_corner.js +0 -370
  24. data/app/assets/javascripts/prototype/tiny_mce_bridge.js +0 -7
  25. data/app/assets/stylesheets/active_scaffold-ie.css.scss +0 -54
  26. data/app/assets/stylesheets/active_scaffold.css.scss +0 -14
  27. data/app/assets/stylesheets/active_scaffold_colors.css.scss +0 -395
  28. data/app/assets/stylesheets/active_scaffold_extensions.css.erb +0 -2
  29. data/app/assets/stylesheets/active_scaffold_images.css.scss +0 -40
  30. data/app/assets/stylesheets/active_scaffold_layout.css +0 -936
  31. data/app/assets/stylesheets/blue-theme.css +0 -74
  32. data/config/locales/de.yml +0 -125
  33. data/config/locales/en.yml +0 -127
  34. data/config/locales/es.yml +0 -128
  35. data/config/locales/fr.yml +0 -131
  36. data/config/locales/hu.yml +0 -126
  37. data/config/locales/ja.yml +0 -126
  38. data/config/locales/ru.yml +0 -135
  39. data/frontends/default/views/_action_group.html.erb +0 -24
  40. data/frontends/default/views/_add_existing_form.html.erb +0 -30
  41. data/frontends/default/views/_base_form.html.erb +0 -53
  42. data/frontends/default/views/_create_form.html.erb +0 -8
  43. data/frontends/default/views/_create_form_on_list.html.erb +0 -6
  44. data/frontends/default/views/_field_search.html.erb +0 -32
  45. data/frontends/default/views/_form.html.erb +0 -28
  46. data/frontends/default/views/_form_association.html.erb +0 -17
  47. data/frontends/default/views/_form_association_footer.html.erb +0 -47
  48. data/frontends/default/views/_form_attribute.html.erb +0 -23
  49. data/frontends/default/views/_form_hidden_attribute.html.erb +0 -7
  50. data/frontends/default/views/_form_messages.html.erb +0 -5
  51. data/frontends/default/views/_horizontal_subform.html.erb +0 -22
  52. data/frontends/default/views/_horizontal_subform_footer.html.erb +0 -0
  53. data/frontends/default/views/_horizontal_subform_header.html.erb +0 -11
  54. data/frontends/default/views/_horizontal_subform_record.html.erb +0 -43
  55. data/frontends/default/views/_human_conditions.html.erb +0 -1
  56. data/frontends/default/views/_list.html.erb +0 -18
  57. data/frontends/default/views/_list_actions.html.erb +0 -15
  58. data/frontends/default/views/_list_calculations.html.erb +0 -16
  59. data/frontends/default/views/_list_column_headings.html.erb +0 -12
  60. data/frontends/default/views/_list_header.html.erb +0 -10
  61. data/frontends/default/views/_list_inline_adapter.html.erb +0 -21
  62. data/frontends/default/views/_list_messages.html.erb +0 -28
  63. data/frontends/default/views/_list_pagination.html.erb +0 -11
  64. data/frontends/default/views/_list_pagination_links.html.erb +0 -9
  65. data/frontends/default/views/_list_record.html.erb +0 -13
  66. data/frontends/default/views/_list_record_columns.html.erb +0 -8
  67. data/frontends/default/views/_list_with_header.html.erb +0 -36
  68. data/frontends/default/views/_messages.html.erb +0 -10
  69. data/frontends/default/views/_refresh_list.js.erb +0 -1
  70. data/frontends/default/views/_render_field.js.erb +0 -20
  71. data/frontends/default/views/_row.html.erb +0 -1
  72. data/frontends/default/views/_search.html.erb +0 -34
  73. data/frontends/default/views/_search_attribute.html.erb +0 -10
  74. data/frontends/default/views/_show.html.erb +0 -8
  75. data/frontends/default/views/_show_columns.html.erb +0 -15
  76. data/frontends/default/views/_update_actions.html.erb +0 -9
  77. data/frontends/default/views/_update_calculations.js.erb +0 -4
  78. data/frontends/default/views/_update_form.html.erb +0 -6
  79. data/frontends/default/views/_update_messages.js.erb +0 -2
  80. data/frontends/default/views/_vertical_subform.html.erb +0 -12
  81. data/frontends/default/views/_vertical_subform_record.html.erb +0 -43
  82. data/frontends/default/views/action_confirmation.html.erb +0 -13
  83. data/frontends/default/views/add_existing.js.erb +0 -14
  84. data/frontends/default/views/add_existing_form.html.erb +0 -5
  85. data/frontends/default/views/create.html.erb +0 -5
  86. data/frontends/default/views/delete.html.erb +0 -13
  87. data/frontends/default/views/destroy.js.erb +0 -26
  88. data/frontends/default/views/edit_associated.js.erb +0 -12
  89. data/frontends/default/views/field_search.html.erb +0 -5
  90. data/frontends/default/views/form_messages.js.erb +0 -1
  91. data/frontends/default/views/list.html.erb +0 -1
  92. data/frontends/default/views/on_action_update.js.erb +0 -22
  93. data/frontends/default/views/on_create.js.erb +0 -38
  94. data/frontends/default/views/on_mark.js.erb +0 -6
  95. data/frontends/default/views/on_update.js.erb +0 -29
  96. data/frontends/default/views/refresh_list.js.erb +0 -2
  97. data/frontends/default/views/render_field.js.erb +0 -1
  98. data/frontends/default/views/row.js.erb +0 -2
  99. data/frontends/default/views/search.html.erb +0 -5
  100. data/frontends/default/views/show.html.erb +0 -5
  101. data/frontends/default/views/update.html.erb +0 -8
  102. data/frontends/default/views/update_column.js.erb +0 -15
  103. data/frontends/default/views/update_row.js.erb +0 -1
  104. data/lib/active_scaffold.rb +0 -373
  105. data/lib/active_scaffold/actions/common_search.rb +0 -22
  106. data/lib/active_scaffold/actions/core.rb +0 -203
  107. data/lib/active_scaffold/actions/create.rb +0 -139
  108. data/lib/active_scaffold/actions/delete.rb +0 -74
  109. data/lib/active_scaffold/actions/field_search.rb +0 -78
  110. data/lib/active_scaffold/actions/list.rb +0 -208
  111. data/lib/active_scaffold/actions/mark.rb +0 -89
  112. data/lib/active_scaffold/actions/nested.rb +0 -244
  113. data/lib/active_scaffold/actions/search.rb +0 -48
  114. data/lib/active_scaffold/actions/show.rb +0 -61
  115. data/lib/active_scaffold/actions/subform.rb +0 -23
  116. data/lib/active_scaffold/actions/update.rb +0 -156
  117. data/lib/active_scaffold/active_record_permissions.rb +0 -135
  118. data/lib/active_scaffold/attribute_params.rb +0 -200
  119. data/lib/active_scaffold/bridges.rb +0 -61
  120. data/lib/active_scaffold/bridges/ancestry.rb +0 -5
  121. data/lib/active_scaffold/bridges/ancestry/ancestry_bridge.rb +0 -39
  122. data/lib/active_scaffold/bridges/bitfields.rb +0 -6
  123. data/lib/active_scaffold/bridges/bitfields/bitfields_bridge.rb +0 -37
  124. data/lib/active_scaffold/bridges/calendar_date_select.rb +0 -24
  125. data/lib/active_scaffold/bridges/calendar_date_select/as_cds_bridge.rb +0 -66
  126. data/lib/active_scaffold/bridges/cancan.rb +0 -15
  127. data/lib/active_scaffold/bridges/cancan/cancan_bridge.rb +0 -127
  128. data/lib/active_scaffold/bridges/carrierwave.rb +0 -12
  129. data/lib/active_scaffold/bridges/carrierwave/carrierwave_bridge.rb +0 -31
  130. data/lib/active_scaffold/bridges/carrierwave/carrierwave_bridge_helpers.rb +0 -10
  131. data/lib/active_scaffold/bridges/carrierwave/form_ui.rb +0 -45
  132. data/lib/active_scaffold/bridges/carrierwave/list_ui.rb +0 -17
  133. data/lib/active_scaffold/bridges/country_helper.rb +0 -9
  134. data/lib/active_scaffold/bridges/country_helper/country_helper_bridge.rb +0 -358
  135. data/lib/active_scaffold/bridges/date_picker.rb +0 -23
  136. data/lib/active_scaffold/bridges/date_picker/ext.rb +0 -63
  137. data/lib/active_scaffold/bridges/date_picker/helper.rb +0 -180
  138. data/lib/active_scaffold/bridges/dragonfly.rb +0 -9
  139. data/lib/active_scaffold/bridges/dragonfly/dragonfly_bridge.rb +0 -34
  140. data/lib/active_scaffold/bridges/dragonfly/dragonfly_bridge_helpers.rb +0 -10
  141. data/lib/active_scaffold/bridges/dragonfly/form_ui.rb +0 -27
  142. data/lib/active_scaffold/bridges/dragonfly/list_ui.rb +0 -16
  143. data/lib/active_scaffold/bridges/file_column.rb +0 -11
  144. data/lib/active_scaffold/bridges/file_column/as_file_column_bridge.rb +0 -46
  145. data/lib/active_scaffold/bridges/file_column/file_column_helpers.rb +0 -57
  146. data/lib/active_scaffold/bridges/file_column/form_ui.rb +0 -34
  147. data/lib/active_scaffold/bridges/file_column/list_ui.rb +0 -26
  148. data/lib/active_scaffold/bridges/file_column/test/functional/file_column_keep_test.rb +0 -43
  149. data/lib/active_scaffold/bridges/file_column/test/mock_model.rb +0 -9
  150. data/lib/active_scaffold/bridges/file_column/test/test_helper.rb +0 -15
  151. data/lib/active_scaffold/bridges/paperclip.rb +0 -12
  152. data/lib/active_scaffold/bridges/paperclip/form_ui.rb +0 -27
  153. data/lib/active_scaffold/bridges/paperclip/list_ui.rb +0 -16
  154. data/lib/active_scaffold/bridges/paperclip/paperclip_bridge.rb +0 -36
  155. data/lib/active_scaffold/bridges/paperclip/paperclip_bridge_helpers.rb +0 -24
  156. data/lib/active_scaffold/bridges/record_select.rb +0 -11
  157. data/lib/active_scaffold/bridges/record_select/helpers.rb +0 -92
  158. data/lib/active_scaffold/bridges/semantic_attributes.rb +0 -5
  159. data/lib/active_scaffold/bridges/semantic_attributes/column.rb +0 -20
  160. data/lib/active_scaffold/bridges/shared/date_bridge.rb +0 -209
  161. data/lib/active_scaffold/bridges/tiny_mce.rb +0 -17
  162. data/lib/active_scaffold/bridges/tiny_mce/helpers.rb +0 -46
  163. data/lib/active_scaffold/config/base.rb +0 -75
  164. data/lib/active_scaffold/config/core.rb +0 -236
  165. data/lib/active_scaffold/config/create.rb +0 -32
  166. data/lib/active_scaffold/config/delete.rb +0 -32
  167. data/lib/active_scaffold/config/field_search.rb +0 -79
  168. data/lib/active_scaffold/config/form.rb +0 -64
  169. data/lib/active_scaffold/config/list.rb +0 -247
  170. data/lib/active_scaffold/config/mark.rb +0 -30
  171. data/lib/active_scaffold/config/nested.rb +0 -42
  172. data/lib/active_scaffold/config/search.rb +0 -73
  173. data/lib/active_scaffold/config/show.rb +0 -31
  174. data/lib/active_scaffold/config/subform.rb +0 -35
  175. data/lib/active_scaffold/config/update.rb +0 -33
  176. data/lib/active_scaffold/configurable.rb +0 -29
  177. data/lib/active_scaffold/constraints.rb +0 -171
  178. data/lib/active_scaffold/data_structures/action_columns.rb +0 -142
  179. data/lib/active_scaffold/data_structures/action_link.rb +0 -185
  180. data/lib/active_scaffold/data_structures/action_links.rb +0 -191
  181. data/lib/active_scaffold/data_structures/actions.rb +0 -45
  182. data/lib/active_scaffold/data_structures/bridge.rb +0 -22
  183. data/lib/active_scaffold/data_structures/column.rb +0 -401
  184. data/lib/active_scaffold/data_structures/columns.rb +0 -75
  185. data/lib/active_scaffold/data_structures/error_message.rb +0 -24
  186. data/lib/active_scaffold/data_structures/nested_info.rb +0 -171
  187. data/lib/active_scaffold/data_structures/set.rb +0 -61
  188. data/lib/active_scaffold/data_structures/sorting.rb +0 -167
  189. data/lib/active_scaffold/engine.rb +0 -4
  190. data/lib/active_scaffold/extensions/action_controller_rendering.rb +0 -20
  191. data/lib/active_scaffold/extensions/action_controller_rescueing.rb +0 -7
  192. data/lib/active_scaffold/extensions/action_view_rendering.rb +0 -115
  193. data/lib/active_scaffold/extensions/active_record_offset.rb +0 -12
  194. data/lib/active_scaffold/extensions/array.rb +0 -7
  195. data/lib/active_scaffold/extensions/cache_association.rb +0 -16
  196. data/lib/active_scaffold/extensions/localize.rb +0 -10
  197. data/lib/active_scaffold/extensions/name_option_for_datetime.rb +0 -12
  198. data/lib/active_scaffold/extensions/nil_id_in_url_params.rb +0 -7
  199. data/lib/active_scaffold/extensions/paginator_extensions.rb +0 -26
  200. data/lib/active_scaffold/extensions/reverse_associations.rb +0 -64
  201. data/lib/active_scaffold/extensions/routing_mapper.rb +0 -48
  202. data/lib/active_scaffold/extensions/to_label.rb +0 -8
  203. data/lib/active_scaffold/extensions/unsaved_associated.rb +0 -61
  204. data/lib/active_scaffold/extensions/unsaved_record.rb +0 -20
  205. data/lib/active_scaffold/extensions/usa_state.rb +0 -46
  206. data/lib/active_scaffold/finder.rb +0 -399
  207. data/lib/active_scaffold/helpers/association_helpers.rb +0 -42
  208. data/lib/active_scaffold/helpers/controller_helpers.rb +0 -94
  209. data/lib/active_scaffold/helpers/form_column_helpers.rb +0 -322
  210. data/lib/active_scaffold/helpers/human_condition_helpers.rb +0 -64
  211. data/lib/active_scaffold/helpers/id_helpers.rb +0 -131
  212. data/lib/active_scaffold/helpers/list_column_helpers.rb +0 -374
  213. data/lib/active_scaffold/helpers/pagination_helpers.rb +0 -62
  214. data/lib/active_scaffold/helpers/search_column_helpers.rb +0 -257
  215. data/lib/active_scaffold/helpers/show_column_helpers.rb +0 -44
  216. data/lib/active_scaffold/helpers/view_helpers.rb +0 -398
  217. data/lib/active_scaffold/marked_model.rb +0 -38
  218. data/lib/active_scaffold/paginator.rb +0 -136
  219. data/lib/active_scaffold/responds_to_parent.rb +0 -70
  220. data/lib/active_scaffold/tableless.rb +0 -83
  221. data/lib/active_scaffold/version.rb +0 -9
  222. data/lib/active_scaffold_env.rb +0 -13
  223. data/lib/generators/active_scaffold/USAGE +0 -29
  224. data/lib/generators/active_scaffold/active_scaffold_generator.rb +0 -21
  225. data/lib/generators/active_scaffold_controller/USAGE +0 -19
  226. data/lib/generators/active_scaffold_controller/active_scaffold_controller_generator.rb +0 -29
  227. data/lib/generators/active_scaffold_controller/templates/controller.rb +0 -4
  228. data/lib/generators/active_scaffold_controller/templates/helper.rb +0 -2
  229. data/public/blank.html +0 -33
  230. data/shoulda_macros/macros.rb +0 -136
  231. data/vendor/assets/images/ui-bg_diagonals-thick_18_b81900_40x40.png +0 -0
  232. data/vendor/assets/images/ui-bg_diagonals-thick_20_666666_40x40.png +0 -0
  233. data/vendor/assets/images/ui-bg_flat_10_000000_40x100.png +0 -0
  234. data/vendor/assets/images/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
  235. data/vendor/assets/images/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
  236. data/vendor/assets/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  237. data/vendor/assets/images/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
  238. data/vendor/assets/images/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
  239. data/vendor/assets/images/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
  240. data/vendor/assets/images/ui-icons_222222_256x240.png +0 -0
  241. data/vendor/assets/images/ui-icons_228ef1_256x240.png +0 -0
  242. data/vendor/assets/images/ui-icons_ef8c08_256x240.png +0 -0
  243. data/vendor/assets/images/ui-icons_ffd27a_256x240.png +0 -0
  244. data/vendor/assets/images/ui-icons_ffffff_256x240.png +0 -0
  245. data/vendor/assets/javascripts/jquery-ui-timepicker-addon.js +0 -1276
  246. data/vendor/assets/stylesheets/jquery-ui.css +0 -568
@@ -1,4 +0,0 @@
1
- class <%= controller_class_name %>Controller < ApplicationController
2
- active_scaffold :<%= class_name.demodulize.underscore %> do |conf|
3
- end
4
- end
@@ -1,2 +0,0 @@
1
- module <%= controller_class_name %>Helper
2
- end
data/public/blank.html DELETED
@@ -1,33 +0,0 @@
1
- <!--
2
- Copyright (c) 2005, Brad Neuberg, bkn3@columbia.edu
3
- http://codinginparadise.org
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the "Software"),
7
- to deal in the Software without restriction, including without limitation
8
- the rights to use, copy, modify, merge, publish, distribute, sublicense,
9
- and/or sell copies of the Software, and to permit persons to whom the
10
- Software is furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be
13
- included in all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
- OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
20
- OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
21
- THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
- -->
23
-
24
- <html>
25
- <script language="JavaScript">
26
- function pageLoaded() {
27
- window.parent.dhtmlHistory.iframeLoaded(window.location);
28
- }
29
- </script>
30
- <body onload="pageLoaded()">
31
- <h1>blank.html - Needed for Internet Explorer's hidden IFrame</h1>
32
- </body>
33
- </html>
@@ -1,136 +0,0 @@
1
- class ActiveSupport::TestCase
2
- def self.should_have_columns_in(action, *columns)
3
- should "have #{columns.to_sentence} columns in #{action}" do
4
- assert_equal columns, column_names(action)
5
- end
6
- end
7
-
8
- def self.should_include_columns_in(action, *columns)
9
- should "include #{columns.to_sentence} columns in #{action}" do
10
- action_columns = column_names(action)
11
- columns.each do |column|
12
- assert action_columns.include?(column.to_sym), "#{column} is not included in #{action}"
13
- end
14
- end
15
- end
16
-
17
- def self.should_not_include_columns_in(action, *columns)
18
- should "not include #{columns.to_sentence} columns in #{action}" do
19
- action_columns = column_names(action)
20
- columns.each do |column|
21
- assert !action_columns.include?(column.to_sym), "#{column} is included in #{action}"
22
- end
23
- end
24
- end
25
-
26
- def self.should_render_as_form_ui(column_name, form_ui)
27
- should "render column #{column_name} as #{form_ui} form_ui", :before => lambda{
28
- @rendered_columns = []
29
- @controller.view_context_class.any_instance.expects(:"active_scaffold_input_#{form_ui}").at_least_once.with {|column, options|
30
- @rendered_columns << column.name
31
- true
32
- }
33
- } do
34
- assert_equal form_ui, @controller.active_scaffold_config.columns[column_name].form_ui
35
- assert @rendered_columns.include?(column_name)
36
- end
37
- end
38
-
39
- def self.should_render_with_options_for_select(column_name, *options)
40
- should "render column #{column_name} with options for select" do
41
- converting_sort = lambda{|a,b| a.to_s <=> b.to_s}
42
- assert_equal options.sort(&converting_sort), @controller.active_scaffold_config.columns[column_name].options[:options].sort(&converting_sort)
43
- end
44
- end
45
-
46
- def self.should_render_as_form_override(column_name)
47
- should "render column #{column_name} as form override" do
48
- column = @controller.active_scaffold_config.columns[column_name]
49
- assert @response.template.override_form_field?(column)
50
- assert_template :partial => "_#{column_name}_form_column", :count => 0
51
- end
52
- end
53
-
54
- def self.should_render_as_form_partial_override(column_name)
55
- should "render column #{column_name} as form partial override" do
56
- assert_template :partial => "_#{column_name}_form_column"
57
- end
58
- end
59
-
60
- def self.should_render_as_form_hidden(column_name)
61
- should "render column #{column_name} as form hidden", :before => lambda{
62
- @rendered_columns = []
63
- @controller.view_context_class.any_instance.expects(:"hidden_field").at_least_once.with {|object, method, options|
64
- @rendered_columns << method
65
- true
66
- }
67
- } do
68
- assert_template :partial => "_form_hidden_attribute"
69
- assert @rendered_columns.include?(column_name)
70
- end
71
- end
72
-
73
- def self.should_render_as_list_ui(column_name, list_ui)
74
- should "render column #{column_name} as #{list_ui} list_ui", :before => lambda{
75
- @rendered_columns = []
76
- @controller.view_context_class.any_instance.expects(:"active_scaffold_column_#{list_ui}").at_least_once.with {|column, options|
77
- @rendered_columns << column.name
78
- true
79
- }
80
- } do
81
- assert_equal list_ui, @controller.active_scaffold_config.columns[column_name].list_ui
82
- assert @rendered_columns.include?(column_name)
83
- end
84
- end
85
-
86
- def self.should_render_as_field_override(column_name)
87
- should "render column #{column_name} as field override" do
88
- column = @controller.active_scaffold_config.columns[column_name]
89
- assert @response.template.override_form_field?(column)
90
- assert_template :partial => "_#{column_name}_column", :count => 0
91
- end
92
- end
93
-
94
- def self.should_render_as_field_partial_override(column_name)
95
- should "render column #{column_name} as field partial override" do
96
- assert_template :partial => "_#{column_name}_column"
97
- end
98
- end
99
-
100
- def self.should_render_as_inplace_edit(column_name)
101
- should "render column #{column_name} as inplace edit", :before => lambda{
102
- @column = @controller.active_scaffold_config.columns[column_name]
103
- @rendered_columns = []
104
- method = @column.list_ui == :checkbox ? :format_column_checkbox : :active_scaffold_inplace_edit
105
- @controller.view_context_class.any_instance.expects(method).at_least_once.with {|model, column, options|
106
- @rendered_columns << column.name
107
- true
108
- }
109
- } do
110
- assert @column.inplace_edit
111
- assert @rendered_columns.include?(column_name)
112
- end
113
- end
114
-
115
- def self.should_respond_to_parent_redirecting_to(description, &block)
116
- should_respond_to_parent("redirecting to #{description}") { "document.location.href = \"#{instance_eval(&block)}\"" }
117
- end
118
-
119
- def self.should_respond_to_parent(description = nil, &block)
120
- should "respond to parent #{description}" do
121
- script = block ? instance_eval(&block) : /.*/
122
- script = script.is_a?(Regexp) ? script.source : Regexp.quote(script)
123
- script = script.gsub('\n', '\\\\\\n').
124
- gsub(/['"]/, '\\\\\\\\\&').
125
- gsub('</script>','</scr"+"ipt>')
126
- assert_select 'script[type=text/javascript]', Regexp.new('.*' + Regexp.quote("with(window.parent) { setTimeout(function() { window.eval('") + script + Regexp.quote("'); if (typeof(loc) !== 'undefined') loc.replace('about:blank'); }, 1) };") + '.*')
127
- end
128
- end
129
-
130
- private
131
- def column_names(action)
132
- columns = []
133
- @controller.active_scaffold_config.send(action).columns.each(:flatten => true) {|col| columns << col.name}
134
- columns
135
- end
136
- end
@@ -1,1276 +0,0 @@
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
- };
1064
-
1065
- //#######################################################################################
1066
- // Disable & enable the Time in the datetimepicker
1067
- //#######################################################################################
1068
- $.datepicker._disableTimepickerDatepicker = function(target, date, withDate) {
1069
- var inst = this._getInst(target),
1070
- tp_inst = this._get(inst, 'timepicker');
1071
- $(target).datepicker('getDate'); // Init selected[Year|Month|Day]
1072
- if (tp_inst) {
1073
- tp_inst._defaults.showTimepicker = false;
1074
- tp_inst._updateDateTime(inst);
1075
- }
1076
- };
1077
-
1078
- $.datepicker._enableTimepickerDatepicker = function(target, date, withDate) {
1079
- var inst = this._getInst(target),
1080
- tp_inst = this._get(inst, 'timepicker');
1081
- $(target).datepicker('getDate'); // Init selected[Year|Month|Day]
1082
- if (tp_inst) {
1083
- tp_inst._defaults.showTimepicker = true;
1084
- tp_inst._addTimePicker(inst); // Could be disabled on page load
1085
- tp_inst._updateDateTime(inst);
1086
- }
1087
- };
1088
-
1089
- //#######################################################################################
1090
- // Create our own set time function
1091
- //#######################################################################################
1092
- $.datepicker._setTime = function(inst, date) {
1093
- var tp_inst = this._get(inst, 'timepicker');
1094
- if (tp_inst) {
1095
- var defaults = tp_inst._defaults,
1096
- // calling _setTime with no date sets time to defaults
1097
- hour = date ? date.getHours() : defaults.hour,
1098
- minute = date ? date.getMinutes() : defaults.minute,
1099
- second = date ? date.getSeconds() : defaults.second,
1100
- millisec = date ? date.getMilliseconds() : defaults.millisec;
1101
-
1102
- //check if within min/max times..
1103
- 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)) {
1104
- hour = defaults.hourMin;
1105
- minute = defaults.minuteMin;
1106
- second = defaults.secondMin;
1107
- millisec = defaults.millisecMin;
1108
- }
1109
-
1110
- tp_inst.hour = hour;
1111
- tp_inst.minute = minute;
1112
- tp_inst.second = second;
1113
- tp_inst.millisec = millisec;
1114
-
1115
- if (tp_inst.hour_slider) tp_inst.hour_slider.slider('value', hour);
1116
- if (tp_inst.minute_slider) tp_inst.minute_slider.slider('value', minute);
1117
- if (tp_inst.second_slider) tp_inst.second_slider.slider('value', second);
1118
- if (tp_inst.millisec_slider) tp_inst.millisec_slider.slider('value', millisec);
1119
-
1120
- tp_inst._onTimeChange();
1121
- tp_inst._updateDateTime(inst);
1122
- }
1123
- };
1124
-
1125
- //#######################################################################################
1126
- // Create new public method to set only time, callable as $().datepicker('setTime', date)
1127
- //#######################################################################################
1128
- $.datepicker._setTimeDatepicker = function(target, date, withDate) {
1129
- var inst = this._getInst(target),
1130
- tp_inst = this._get(inst, 'timepicker');
1131
-
1132
- if (tp_inst) {
1133
- this._setDateFromField(inst);
1134
- var tp_date;
1135
- if (date) {
1136
- if (typeof date == "string") {
1137
- tp_inst._parseTime(date, withDate);
1138
- tp_date = new Date();
1139
- tp_date.setHours(tp_inst.hour, tp_inst.minute, tp_inst.second, tp_inst.millisec);
1140
- }
1141
- else tp_date = new Date(date.getTime());
1142
- if (tp_date.toString() == 'Invalid Date') tp_date = undefined;
1143
- this._setTime(inst, tp_date);
1144
- }
1145
- }
1146
-
1147
- };
1148
-
1149
- //#######################################################################################
1150
- // override setDate() to allow setting time too within Date object
1151
- //#######################################################################################
1152
- $.datepicker._base_setDateDatepicker = $.datepicker._setDateDatepicker;
1153
- $.datepicker._setDateDatepicker = function(target, date) {
1154
- var inst = this._getInst(target),
1155
- tp_date = (date instanceof Date) ? new Date(date.getTime()) : date;
1156
-
1157
- this._updateDatepicker(inst);
1158
- this._base_setDateDatepicker.apply(this, arguments);
1159
- this._setTimeDatepicker(target, tp_date, true);
1160
- };
1161
-
1162
- //#######################################################################################
1163
- // override getDate() to allow getting time too within Date object
1164
- //#######################################################################################
1165
- $.datepicker._base_getDateDatepicker = $.datepicker._getDateDatepicker;
1166
- $.datepicker._getDateDatepicker = function(target, noDefault) {
1167
- var inst = this._getInst(target),
1168
- tp_inst = this._get(inst, 'timepicker');
1169
-
1170
- if (tp_inst) {
1171
- this._setDateFromField(inst, noDefault);
1172
- var date = this._getDate(inst);
1173
- if (date && tp_inst._parseTime($(target).val(), tp_inst.timeOnly)) date.setHours(tp_inst.hour, tp_inst.minute, tp_inst.second, tp_inst.millisec);
1174
- return date;
1175
- }
1176
- return this._base_getDateDatepicker(target, noDefault);
1177
- };
1178
-
1179
- //#######################################################################################
1180
- // override parseDate() because UI 1.8.14 throws an error about "Extra characters"
1181
- // An option in datapicker to ignore extra format characters would be nicer.
1182
- //#######################################################################################
1183
- $.datepicker._base_parseDate = $.datepicker.parseDate;
1184
- $.datepicker.parseDate = function(format, value, settings) {
1185
- var date;
1186
- try {
1187
- date = this._base_parseDate(format, value, settings);
1188
- } catch (err) {
1189
- // Hack! The error message ends with a colon, a space, and
1190
- // the "extra" characters. We rely on that instead of
1191
- // attempting to perfectly reproduce the parsing algorithm.
1192
- date = this._base_parseDate(format, value.substring(0,value.length-(err.length-err.indexOf(':')-2)), settings);
1193
- }
1194
- return date;
1195
- };
1196
-
1197
- //#######################################################################################
1198
- // override formatDate to set date with time to the input
1199
- //#######################################################################################
1200
- $.datepicker._base_formatDate=$.datepicker._formatDate;
1201
- $.datepicker._formatDate = function(inst, day, month, year){
1202
- var tp_inst = this._get(inst, 'timepicker');
1203
- if(tp_inst)
1204
- {
1205
- if(day)
1206
- var b = this._base_formatDate(inst, day, month, year);
1207
- tp_inst._updateDateTime();
1208
- return tp_inst.$input.val();
1209
- }
1210
- return this._base_formatDate(inst);
1211
- }
1212
-
1213
- //#######################################################################################
1214
- // override options setter to add time to maxDate(Time) and minDate(Time). MaxDate
1215
- //#######################################################################################
1216
- $.datepicker._base_optionDatepicker = $.datepicker._optionDatepicker;
1217
- $.datepicker._optionDatepicker = function(target, name, value) {
1218
- var inst = this._getInst(target),
1219
- tp_inst = this._get(inst, 'timepicker');
1220
- if (tp_inst) {
1221
- var min,max,onselect;
1222
- if (typeof name == 'string') { // if min/max was set with the string
1223
- if (name==='minDate' || name==='minDateTime' )
1224
- min = value;
1225
- else if (name==='maxDate' || name==='maxDateTime')
1226
- max = value;
1227
- else if (name==='onSelect')
1228
- onselect=value;
1229
- } else if (typeof name == 'object') { //if min/max was set with the JSON
1230
- if(name.minDate)
1231
- min = name.minDate;
1232
- else if (name.minDateTime)
1233
- min = name.minDateTime;
1234
- else if (name.maxDate)
1235
- max = name.maxDate;
1236
- else if (name.maxDateTime)
1237
- max = name.maxDateTime;
1238
- }
1239
- if(min){ //if min was set
1240
- if(min==0)
1241
- min=new Date();
1242
- else
1243
- min= new Date(min);
1244
-
1245
- tp_inst._defaults.minDate = min;
1246
- tp_inst._defaults.minDateTime = min;
1247
- } else if (max){ //if max was set
1248
- if(max==0)
1249
- max=new Date();
1250
- else
1251
- max= new Date(max);
1252
- tp_inst._defaults.maxDate = max;
1253
- tp_inst._defaults.maxDateTime = max;
1254
- }
1255
- else if (onselect)
1256
- tp_inst._defaults.onSelect=onselect;
1257
- }
1258
- this._base_optionDatepicker(target, name, value);
1259
- };
1260
-
1261
- //#######################################################################################
1262
- // jQuery extend now ignores nulls!
1263
- //#######################################################################################
1264
- function extendRemove(target, props) {
1265
- $.extend(target, props);
1266
- for (var name in props)
1267
- if (props[name] === null || props[name] === undefined)
1268
- target[name] = props[name];
1269
- return target;
1270
- }
1271
-
1272
- $.timepicker = new Timepicker(); // singleton instance
1273
- $.timepicker.version = "0.9.7";
1274
-
1275
- })(jQuery);
1276
-