sunrise-core 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (219) hide show
  1. data/Gemfile +1 -1
  2. data/README.rdoc +1 -1
  3. data/lib/generators/sunrise/templates/models/defaults/position_type.rb +2 -0
  4. data/lib/generators/sunrise/templates/models/defaults/role_type.rb +2 -0
  5. data/lib/generators/sunrise/templates/models/defaults/structure_type.rb +2 -0
  6. data/lib/sunrise/version.rb +1 -1
  7. data/spec/dummy/log/test.log +5332 -39751
  8. data/spec/dummy/script/rails +0 -0
  9. metadata +862 -1288
  10. data/spec/dummy/public/uploads/avatar/4/rails.png +0 -0
  11. data/spec/dummy/public/uploads/avatar/4/thumb_rails.png +0 -0
  12. data/spec/dummy/public/uploads/avatar/5/rails.png +0 -0
  13. data/spec/dummy/public/uploads/avatar/5/thumb_rails.png +0 -0
  14. data/spec/dummy/public/uploads/avatar/6/rails.png +0 -0
  15. data/spec/dummy/public/uploads/avatar/6/thumb_rails.png +0 -0
  16. data/spec/dummy/public/uploads/avatar/7/rails.png +0 -0
  17. data/spec/dummy/public/uploads/avatar/7/thumb_rails.png +0 -0
  18. data/spec/dummy/public/uploads/avatar/8/rails.png +0 -0
  19. data/spec/dummy/public/uploads/avatar/8/thumb_rails.png +0 -0
  20. data/spec/dummy/public/uploads/tmp/20110819-1743-19227-1016/silicon_valley.jpg +0 -0
  21. data/spec/dummy/public/uploads/tmp/20110819-1743-19227-1016/thumb_silicon_valley.jpg +0 -0
  22. data/spec/dummy/public/uploads/tmp/20110819-1744-19584-0221/silicon_valley.jpg +0 -0
  23. data/spec/dummy/public/uploads/tmp/20110819-1744-19584-0221/thumb_silicon_valley.jpg +0 -0
  24. data/spec/tmp/app/helpers/manage/assets_helper.rb +0 -2
  25. data/spec/tmp/app/helpers/manage/base_helper.rb +0 -83
  26. data/spec/tmp/app/helpers/manage/pages_helper.rb +0 -2
  27. data/spec/tmp/app/helpers/manage/settings_helper.rb +0 -2
  28. data/spec/tmp/app/helpers/manage/structures_helper.rb +0 -12
  29. data/spec/tmp/app/helpers/manage/users_helper.rb +0 -6
  30. data/spec/tmp/app/models/defaults/ability.rb +0 -39
  31. data/spec/tmp/app/models/defaults/asset.rb +0 -9
  32. data/spec/tmp/app/models/defaults/attachment_file.rb +0 -31
  33. data/spec/tmp/app/models/defaults/avatar.rb +0 -34
  34. data/spec/tmp/app/models/defaults/header.rb +0 -5
  35. data/spec/tmp/app/models/defaults/page.rb +0 -5
  36. data/spec/tmp/app/models/defaults/picture.rb +0 -31
  37. data/spec/tmp/app/models/defaults/position_type.rb +0 -7
  38. data/spec/tmp/app/models/defaults/role.rb +0 -20
  39. data/spec/tmp/app/models/defaults/role_type.rb +0 -8
  40. data/spec/tmp/app/models/defaults/structure.rb +0 -9
  41. data/spec/tmp/app/models/defaults/structure_type.rb +0 -9
  42. data/spec/tmp/app/models/defaults/user.rb +0 -47
  43. data/spec/tmp/app/uploaders/attachment_file_uploader.rb +0 -5
  44. data/spec/tmp/app/uploaders/avatar_uploader.rb +0 -13
  45. data/spec/tmp/app/uploaders/picture_uploader.rb +0 -17
  46. data/spec/tmp/app/views/layouts/application.html.erb +0 -35
  47. data/spec/tmp/app/views/pages/show.html.erb +0 -2
  48. data/spec/tmp/app/views/shared/_notice.html.erb +0 -17
  49. data/spec/tmp/config/application.rb +0 -47
  50. data/spec/tmp/config/application.yml.sample +0 -4
  51. data/spec/tmp/config/database.yml.sample +0 -34
  52. data/spec/tmp/config/initializers/sunrise.rb +0 -7
  53. data/spec/tmp/config/logrotate-config.sample +0 -9
  54. data/spec/tmp/config/nginx-config-passenger.sample +0 -60
  55. data/spec/tmp/config/routes.rb +0 -7
  56. data/spec/tmp/db/migrate/20110819144550_sunrise_create_users.rb +0 -29
  57. data/spec/tmp/db/migrate/20110819144650_sunrise_create_roles.rb +0 -16
  58. data/spec/tmp/db/migrate/20110819144750_sunrise_create_structures.rb +0 -27
  59. data/spec/tmp/db/migrate/20110819144850_sunrise_create_pages.rb +0 -17
  60. data/spec/tmp/db/migrate/20110819144950_sunrise_create_assets.rb +0 -28
  61. data/spec/tmp/db/migrate/20110819145050_sunrise_create_headers.rb +0 -20
  62. data/spec/tmp/db/seeds.rb +0 -25
  63. data/spec/tmp/public/images/alert.png +0 -0
  64. data/spec/tmp/public/images/cross_ico.png +0 -0
  65. data/spec/tmp/public/images/manage/add_post_bot.gif +0 -0
  66. data/spec/tmp/public/images/manage/add_post_top.gif +0 -0
  67. data/spec/tmp/public/images/manage/add_white_bot.gif +0 -0
  68. data/spec/tmp/public/images/manage/add_white_top.gif +0 -0
  69. data/spec/tmp/public/images/manage/arrow.png +0 -0
  70. data/spec/tmp/public/images/manage/back_but_lc.gif +0 -0
  71. data/spec/tmp/public/images/manage/back_but_rc.gif +0 -0
  72. data/spec/tmp/public/images/manage/bot_corn.gif +0 -0
  73. data/spec/tmp/public/images/manage/bot_duo_corn.gif +0 -0
  74. data/spec/tmp/public/images/manage/but_bg.png +0 -0
  75. data/spec/tmp/public/images/manage/but_block_lc.gif +0 -0
  76. data/spec/tmp/public/images/manage/but_block_rc.gif +0 -0
  77. data/spec/tmp/public/images/manage/but_freze_lc.gif +0 -0
  78. data/spec/tmp/public/images/manage/but_freze_rc.gif +0 -0
  79. data/spec/tmp/public/images/manage/but_gr.gif +0 -0
  80. data/spec/tmp/public/images/manage/but_gr_l.gif +0 -0
  81. data/spec/tmp/public/images/manage/but_gr_r.gif +0 -0
  82. data/spec/tmp/public/images/manage/but_search.gif +0 -0
  83. data/spec/tmp/public/images/manage/but_unfreze_lc.gif +0 -0
  84. data/spec/tmp/public/images/manage/but_unfreze_rc.gif +0 -0
  85. data/spec/tmp/public/images/manage/button_add_foto.gif +0 -0
  86. data/spec/tmp/public/images/manage/button_add_foto_ru.gif +0 -0
  87. data/spec/tmp/public/images/manage/button_add_foto_ua.gif +0 -0
  88. data/spec/tmp/public/images/manage/button_add_foto_uk.gif +0 -0
  89. data/spec/tmp/public/images/manage/cancelbutton.gif +0 -0
  90. data/spec/tmp/public/images/manage/dark_arr.gif +0 -0
  91. data/spec/tmp/public/images/manage/dark_arr_left.gif +0 -0
  92. data/spec/tmp/public/images/manage/dark_cross_ico.gif +0 -0
  93. data/spec/tmp/public/images/manage/dot.gif +0 -0
  94. data/spec/tmp/public/images/manage/duo_bg.gif +0 -0
  95. data/spec/tmp/public/images/manage/duo_bg_small.gif +0 -0
  96. data/spec/tmp/public/images/manage/duo_bg_small_blocked.gif +0 -0
  97. data/spec/tmp/public/images/manage/duo_bg_small_frozed.gif +0 -0
  98. data/spec/tmp/public/images/manage/duo_bg_small_notact.gif +0 -0
  99. data/spec/tmp/public/images/manage/duo_bot_small.gif +0 -0
  100. data/spec/tmp/public/images/manage/duo_bot_small_blocked.gif +0 -0
  101. data/spec/tmp/public/images/manage/duo_bot_small_frozed.gif +0 -0
  102. data/spec/tmp/public/images/manage/duo_bot_small_notact.gif +0 -0
  103. data/spec/tmp/public/images/manage/duo_top_small.gif +0 -0
  104. data/spec/tmp/public/images/manage/duo_top_small_blocked.gif +0 -0
  105. data/spec/tmp/public/images/manage/duo_top_small_frozed.gif +0 -0
  106. data/spec/tmp/public/images/manage/duo_top_small_notact.gif +0 -0
  107. data/spec/tmp/public/images/manage/edit_white_top.gif +0 -0
  108. data/spec/tmp/public/images/manage/empty.gif +0 -0
  109. data/spec/tmp/public/images/manage/filter_bot_bg.gif +0 -0
  110. data/spec/tmp/public/images/manage/filter_top_bg.gif +0 -0
  111. data/spec/tmp/public/images/manage/flag_en.gif +0 -0
  112. data/spec/tmp/public/images/manage/flag_en_nonact.gif +0 -0
  113. data/spec/tmp/public/images/manage/flag_ru.gif +0 -0
  114. data/spec/tmp/public/images/manage/flag_ru_nonact.gif +0 -0
  115. data/spec/tmp/public/images/manage/flag_ua.gif +0 -0
  116. data/spec/tmp/public/images/manage/flag_ua_nonact.gif +0 -0
  117. data/spec/tmp/public/images/manage/foto.jpg +0 -0
  118. data/spec/tmp/public/images/manage/ico_add.gif +0 -0
  119. data/spec/tmp/public/images/manage/ico_delete.gif +0 -0
  120. data/spec/tmp/public/images/manage/ico_down.gif +0 -0
  121. data/spec/tmp/public/images/manage/ico_edit.gif +0 -0
  122. data/spec/tmp/public/images/manage/ico_settings.gif +0 -0
  123. data/spec/tmp/public/images/manage/ico_up.gif +0 -0
  124. data/spec/tmp/public/images/manage/input_bg.gif +0 -0
  125. data/spec/tmp/public/images/manage/l_but_corn.gif +0 -0
  126. data/spec/tmp/public/images/manage/minimise_but.gif +0 -0
  127. data/spec/tmp/public/images/manage/mp3.png +0 -0
  128. data/spec/tmp/public/images/manage/page_arr_hover.png +0 -0
  129. data/spec/tmp/public/images/manage/page_next_arr.gif +0 -0
  130. data/spec/tmp/public/images/manage/page_num_hover.gif +0 -0
  131. data/spec/tmp/public/images/manage/page_prev_arr.gif +0 -0
  132. data/spec/tmp/public/images/manage/panel/l_but_corn.gif +0 -0
  133. data/spec/tmp/public/images/manage/panel/maximise_but.gif +0 -0
  134. data/spec/tmp/public/images/manage/panel/r_but_corn.gif +0 -0
  135. data/spec/tmp/public/images/manage/panel/top_menu_arr.gif +0 -0
  136. data/spec/tmp/public/images/manage/panel/user_pic.gif +0 -0
  137. data/spec/tmp/public/images/manage/preloader.gif +0 -0
  138. data/spec/tmp/public/images/manage/r_but_corn.gif +0 -0
  139. data/spec/tmp/public/images/manage/select_bg.gif +0 -0
  140. data/spec/tmp/public/images/manage/select_corn.gif +0 -0
  141. data/spec/tmp/public/images/manage/struct_corn_lg.gif +0 -0
  142. data/spec/tmp/public/images/manage/struct_corn_llg.gif +0 -0
  143. data/spec/tmp/public/images/manage/struct_corn_lw.gif +0 -0
  144. data/spec/tmp/public/images/manage/struct_corn_rg.gif +0 -0
  145. data/spec/tmp/public/images/manage/struct_corn_rlg.gif +0 -0
  146. data/spec/tmp/public/images/manage/struct_corn_rw.gif +0 -0
  147. data/spec/tmp/public/images/manage/tab_gl.gif +0 -0
  148. data/spec/tmp/public/images/manage/tab_gr.gif +0 -0
  149. data/spec/tmp/public/images/manage/tab_wl.gif +0 -0
  150. data/spec/tmp/public/images/manage/tab_wr.gif +0 -0
  151. data/spec/tmp/public/images/manage/top_corn.gif +0 -0
  152. data/spec/tmp/public/images/manage/top_duo_corn.gif +0 -0
  153. data/spec/tmp/public/images/manage/top_menu_arr.gif +0 -0
  154. data/spec/tmp/public/images/manage/transp_cross.png +0 -0
  155. data/spec/tmp/public/images/manage/upload_progress.gif +0 -0
  156. data/spec/tmp/public/images/manage/user_act_lc.gif +0 -0
  157. data/spec/tmp/public/images/manage/user_act_rc.gif +0 -0
  158. data/spec/tmp/public/images/manage/user_ico.gif +0 -0
  159. data/spec/tmp/public/images/manage/user_pic.gif +0 -0
  160. data/spec/tmp/public/images/manage/user_pic_small.gif +0 -0
  161. data/spec/tmp/public/images/manage/user_pic_thumb.gif +0 -0
  162. data/spec/tmp/public/javascripts/datepicker/jquery-ui-i18n.js +0 -1176
  163. data/spec/tmp/public/javascripts/datepicker/jquery.ui.datepicker-ru.js +0 -37
  164. data/spec/tmp/public/javascripts/datepicker/jquery.ui.datepicker-uk.js +0 -37
  165. data/spec/tmp/public/javascripts/jquery-ui-timepicker-addon.js +0 -911
  166. data/spec/tmp/public/javascripts/jquery.cookie.js +0 -97
  167. data/spec/tmp/public/javascripts/jquery.fancybox-1.3.4.pack.js +0 -46
  168. data/spec/tmp/public/javascripts/jquery.tmpl.min.js +0 -10
  169. data/spec/tmp/public/javascripts/manage-fileuploader.js +0 -182
  170. data/spec/tmp/public/javascripts/manage.js +0 -294
  171. data/spec/tmp/public/javascripts/preloader.js +0 -47
  172. data/spec/tmp/public/javascripts/rails.js +0 -331
  173. data/spec/tmp/public/stylesheets/alert.css +0 -26
  174. data/spec/tmp/public/stylesheets/application.css +0 -1
  175. data/spec/tmp/public/stylesheets/fancybox/images/blank.gif +0 -0
  176. data/spec/tmp/public/stylesheets/fancybox/images/fancy_close.png +0 -0
  177. data/spec/tmp/public/stylesheets/fancybox/images/fancy_loading.png +0 -0
  178. data/spec/tmp/public/stylesheets/fancybox/images/fancy_nav_left.png +0 -0
  179. data/spec/tmp/public/stylesheets/fancybox/images/fancy_nav_right.png +0 -0
  180. data/spec/tmp/public/stylesheets/fancybox/images/fancy_shadow_e.png +0 -0
  181. data/spec/tmp/public/stylesheets/fancybox/images/fancy_shadow_n.png +0 -0
  182. data/spec/tmp/public/stylesheets/fancybox/images/fancy_shadow_ne.png +0 -0
  183. data/spec/tmp/public/stylesheets/fancybox/images/fancy_shadow_nw.png +0 -0
  184. data/spec/tmp/public/stylesheets/fancybox/images/fancy_shadow_s.png +0 -0
  185. data/spec/tmp/public/stylesheets/fancybox/images/fancy_shadow_se.png +0 -0
  186. data/spec/tmp/public/stylesheets/fancybox/images/fancy_shadow_sw.png +0 -0
  187. data/spec/tmp/public/stylesheets/fancybox/images/fancy_shadow_w.png +0 -0
  188. data/spec/tmp/public/stylesheets/fancybox/images/fancy_title_left.png +0 -0
  189. data/spec/tmp/public/stylesheets/fancybox/images/fancy_title_main.png +0 -0
  190. data/spec/tmp/public/stylesheets/fancybox/images/fancy_title_over.png +0 -0
  191. data/spec/tmp/public/stylesheets/fancybox/images/fancy_title_right.png +0 -0
  192. data/spec/tmp/public/stylesheets/fancybox/images/fancybox-x.png +0 -0
  193. data/spec/tmp/public/stylesheets/fancybox/images/fancybox-y.png +0 -0
  194. data/spec/tmp/public/stylesheets/fancybox/images/fancybox.png +0 -0
  195. data/spec/tmp/public/stylesheets/fancybox/jquery.fancybox-1.3.4.css +0 -359
  196. data/spec/tmp/public/stylesheets/manage/buttons.css +0 -42
  197. data/spec/tmp/public/stylesheets/manage/ie.css +0 -16
  198. data/spec/tmp/public/stylesheets/manage/main.css +0 -1108
  199. data/spec/tmp/public/stylesheets/manage/panel.css +0 -126
  200. data/spec/tmp/public/stylesheets/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  201. data/spec/tmp/public/stylesheets/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  202. data/spec/tmp/public/stylesheets/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  203. data/spec/tmp/public/stylesheets/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  204. data/spec/tmp/public/stylesheets/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  205. data/spec/tmp/public/stylesheets/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  206. data/spec/tmp/public/stylesheets/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  207. data/spec/tmp/public/stylesheets/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  208. data/spec/tmp/public/stylesheets/smoothness/images/ui-icons_222222_256x240.png +0 -0
  209. data/spec/tmp/public/stylesheets/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
  210. data/spec/tmp/public/stylesheets/smoothness/images/ui-icons_454545_256x240.png +0 -0
  211. data/spec/tmp/public/stylesheets/smoothness/images/ui-icons_888888_256x240.png +0 -0
  212. data/spec/tmp/public/stylesheets/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
  213. data/spec/tmp/public/stylesheets/smoothness/jquery-ui-1.8.13.custom.css +0 -578
  214. data/spec/tmp/spec/controllers/pages_controller_spec.rb +0 -22
  215. data/spec/tmp/spec/controllers/welcome_controller_spec.rb +0 -18
  216. data/spec/tmp/spec/factories/structure_factory.rb +0 -22
  217. data/spec/tmp/spec/factories/user_factory.rb +0 -60
  218. data/spec/tmp/spec/spec_helper.rb +0 -37
  219. data/spec/tmp/spec/support/helpers/controller_macros.rb +0 -51
@@ -1,37 +0,0 @@
1
- /* Russian (UTF-8) initialisation for the jQuery UI date picker plugin. */
2
- /* Written by Andrew Stromnov (stromnov@gmail.com). */
3
- jQuery(function($){
4
- $.datepicker.regional['ru'] = {
5
- closeText: 'Закрыть',
6
- prevText: '<Пред',
7
- nextText: 'След>',
8
- currentText: 'Сегодня',
9
- monthNames: ['Январь','Февраль','Март','Апрель','Май','Июнь',
10
- 'Июль','Август','Сентябрь','Октябрь','Ноябрь','Декабрь'],
11
- monthNamesShort: ['Янв','Фев','Мар','Апр','Май','Июн',
12
- 'Июл','Авг','Сен','Окт','Ноя','Дек'],
13
- dayNames: ['воскресенье','понедельник','вторник','среда','четверг','пятница','суббота'],
14
- dayNamesShort: ['вск','пнд','втр','срд','чтв','птн','сбт'],
15
- dayNamesMin: ['Вс','Пн','Вт','Ср','Чт','Пт','Сб'],
16
- weekHeader: 'Не',
17
- dateFormat: 'dd.mm.yy',
18
- firstDay: 1,
19
- isRTL: false,
20
- showMonthAfterYear: false,
21
- yearSuffix: ''};
22
-
23
- if ($.timepicker) {
24
- $.timepicker.regional['ru'] = {
25
- timeOnlyTitle: 'Выберите время',
26
- timeText: 'Время',
27
- hourText: 'Часы',
28
- minuteText: 'Минуты',
29
- secondText: 'Секунды',
30
- currentText: 'Теперь',
31
- closeText: 'Закрыть',
32
- ampm: false
33
- };
34
- }
35
-
36
- $.datepicker.setDefaults($.datepicker.regional['ru']);
37
- });
@@ -1,37 +0,0 @@
1
- /* Ukrainian (UTF-8) initialisation for the jQuery UI date picker plugin. */
2
- /* Written by Maxim Drogobitskiy (maxdao@gmail.com). */
3
- jQuery(function($){
4
- $.datepicker.regional['uk'] = {
5
- closeText: 'Закрити',
6
- prevText: '<',
7
- nextText: '>',
8
- currentText: 'Сьогодні',
9
- monthNames: ['Січень','Лютий','Березень','Квітень','Травень','Червень',
10
- 'Липень','Серпень','Вересень','Жовтень','Листопад','Грудень'],
11
- monthNamesShort: ['Січ','Лют','Бер','Кві','Тра','Чер',
12
- 'Лип','Сер','Вер','Жов','Лис','Гру'],
13
- dayNames: ['неділя','понеділок','вівторок','середа','четвер','п’ятниця','субота'],
14
- dayNamesShort: ['нед','пнд','вів','срд','чтв','птн','сбт'],
15
- dayNamesMin: ['Нд','Пн','Вт','Ср','Чт','Пт','Сб'],
16
- weekHeader: 'Не',
17
- dateFormat: 'dd.mm.yy',
18
- firstDay: 1,
19
- isRTL: false,
20
- showMonthAfterYear: false,
21
- yearSuffix: ''};
22
-
23
- if ($.timepicker) {
24
- $.timepicker.regional['uk'] = {
25
- timeOnlyTitle: 'Виберіть час',
26
- timeText: 'Час',
27
- hourText: 'Години',
28
- minuteText: 'Хвилини',
29
- secondText: 'Секунди',
30
- currentText: 'Тепер',
31
- closeText: 'Закрити',
32
- ampm: false
33
- };
34
- }
35
-
36
- $.datepicker.setDefaults($.datepicker.regional['uk']);
37
- });
@@ -1,911 +0,0 @@
1
- /*
2
- * jQuery timepicker addon
3
- * By: Trent Richardson [http://trentrichardson.com]
4
- * Version 0.9.3
5
- * Last Modified: 02/05/2011
6
- *
7
- * Copyright 2010 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 0 10px 65px; }
17
- * .ui-timepicker-div td { font-size: 90%; }
18
- */
19
-
20
- (function($) {
21
-
22
- $.extend($.ui, { timepicker: { version: "0.9.3" } });
23
-
24
- /* Time picker manager.
25
- Use the singleton instance of this class, $.timepicker, to interact with the time picker.
26
- Settings for (groups of) time pickers are maintained in an instance object,
27
- allowing multiple different settings on the same page. */
28
-
29
- function Timepicker() {
30
- this.regional = []; // Available regional settings, indexed by language code
31
- this.regional[''] = { // Default regional settings
32
- currentText: 'Now',
33
- closeText: 'Done',
34
- ampm: false,
35
- timeFormat: 'hh:mm tt',
36
- timeOnlyTitle: 'Choose Time',
37
- timeText: 'Time',
38
- hourText: 'Hour',
39
- minuteText: 'Minute',
40
- secondText: 'Second'
41
- };
42
- this._defaults = { // Global defaults for all the datetime picker instances
43
- showButtonPanel: true,
44
- timeOnly: false,
45
- showHour: true,
46
- showMinute: true,
47
- showSecond: false,
48
- showTime: true,
49
- stepHour: 0.05,
50
- stepMinute: 0.05,
51
- stepSecond: 0.05,
52
- hour: 0,
53
- minute: 0,
54
- second: 0,
55
- hourMin: 0,
56
- minuteMin: 0,
57
- secondMin: 0,
58
- hourMax: 23,
59
- minuteMax: 59,
60
- secondMax: 59,
61
- minDateTime: null,
62
- maxDateTime: null,
63
- hourGrid: 0,
64
- minuteGrid: 0,
65
- secondGrid: 0,
66
- alwaysSetTime: true,
67
- separator: ' ',
68
- altFieldTimeOnly: true,
69
- showTimepicker: true
70
- };
71
- $.extend(this._defaults, this.regional['']);
72
- }
73
-
74
- $.extend(Timepicker.prototype, {
75
- $input: null,
76
- $altInput: null,
77
- $timeObj: null,
78
- inst: null,
79
- hour_slider: null,
80
- minute_slider: null,
81
- second_slider: null,
82
- hour: 0,
83
- minute: 0,
84
- second: 0,
85
- hourMinOriginal: null,
86
- minuteMinOriginal: null,
87
- secondMinOriginal: null,
88
- hourMaxOriginal: null,
89
- minuteMaxOriginal: null,
90
- secondMaxOriginal: null,
91
- ampm: '',
92
- formattedDate: '',
93
- formattedTime: '',
94
- formattedDateTime: '',
95
-
96
- /* Override the default settings for all instances of the time picker.
97
- @param settings object - the new settings to use as defaults (anonymous object)
98
- @return the manager object */
99
- setDefaults: function(settings) {
100
- extendRemove(this._defaults, settings || {});
101
- return this;
102
- },
103
-
104
- //########################################################################
105
- // Create a new Timepicker instance
106
- //########################################################################
107
- _newInst: function($input, o) {
108
- var tp_inst = new Timepicker(),
109
- inlineSettings = {};
110
-
111
- tp_inst.hour = tp_inst._defaults.hour;
112
- tp_inst.minute = tp_inst._defaults.minute;
113
- tp_inst.second = tp_inst._defaults.second;
114
- tp_inst.ampm = '';
115
- tp_inst.$input = $input;
116
-
117
-
118
- for (var attrName in this._defaults) {
119
- var attrValue = $input.attr('time:' + attrName);
120
- if (attrValue) {
121
- try {
122
- inlineSettings[attrName] = eval(attrValue);
123
- } catch (err) {
124
- inlineSettings[attrName] = attrValue;
125
- }
126
- }
127
- }
128
- tp_inst._defaults = $.extend({}, this._defaults, inlineSettings, o, {
129
- beforeShow: function(input, dp_inst) {
130
- if ($.isFunction(o.beforeShow))
131
- o.beforeShow(input, dp_inst, tp_inst);
132
- },
133
- onChangeMonthYear: function(year, month, dp_inst) {
134
- // Update the time as well : this prevents the time from disappearing from the $input field.
135
- tp_inst._updateDateTime(dp_inst);
136
- if ($.isFunction(o.onChangeMonthYear))
137
- o.onChangeMonthYear(year, month, dp_inst, tp_inst);
138
- },
139
- onClose: function(dateText, dp_inst) {
140
- if (tp_inst.timeDefined === true && $input.val() != '')
141
- tp_inst._updateDateTime(dp_inst);
142
- if ($.isFunction(o.onClose))
143
- o.onClose(dateText, dp_inst, tp_inst);
144
- },
145
- timepicker: tp_inst // add timepicker as a property of datepicker: $.datepicker._get(dp_inst, 'timepicker');
146
- });
147
-
148
- if (o.altField)
149
- tp_inst.$altInput = $(o.altField)
150
- .css({ cursor: 'pointer' })
151
- .focus(function(){ $input.trigger("focus"); });
152
-
153
- // datepicker needs minDate/maxDate, timepicker needs minDateTime/maxDateTime..
154
- if(tp_inst._defaults.minDate !== undefined && tp_inst._defaults.minDate instanceof Date)
155
- tp_inst._defaults.minDateTime = new Date(tp_inst._defaults.minDate.getTime());
156
- if(tp_inst._defaults.minDateTime !== undefined && tp_inst._defaults.minDateTime instanceof Date)
157
- tp_inst._defaults.minDate = new Date(tp_inst._defaults.minDateTime.getTime());
158
- if(tp_inst._defaults.maxDate !== undefined && tp_inst._defaults.maxDate instanceof Date)
159
- tp_inst._defaults.maxDateTime = new Date(tp_inst._defaults.maxDate.getTime());
160
- if(tp_inst._defaults.maxDateTime !== undefined && tp_inst._defaults.maxDateTime instanceof Date)
161
- tp_inst._defaults.maxDate = new Date(tp_inst._defaults.maxDateTime.getTime());
162
-
163
- return tp_inst;
164
- },
165
-
166
- //########################################################################
167
- // add our sliders to the calendar
168
- //########################################################################
169
- _addTimePicker: function(dp_inst) {
170
- var currDT = (this.$altInput && this._defaults.altFieldTimeOnly) ?
171
- this.$input.val() + ' ' + this.$altInput.val() :
172
- this.$input.val();
173
-
174
- this.timeDefined = this._parseTime(currDT);
175
- this._limitMinMaxDateTime(dp_inst, false);
176
- this._injectTimePicker();
177
- },
178
-
179
- //########################################################################
180
- // parse the time string from input value or _setTime
181
- //########################################################################
182
- _parseTime: function(timeString, withDate) {
183
- var regstr = this._defaults.timeFormat.toString()
184
- .replace(/h{1,2}/ig, '(\\d?\\d)')
185
- .replace(/m{1,2}/ig, '(\\d?\\d)')
186
- .replace(/s{1,2}/ig, '(\\d?\\d)')
187
- .replace(/t{1,2}/ig, '(am|pm|a|p)?')
188
- .replace(/\s/g, '\\s?') + '$',
189
- order = this._getFormatPositions(),
190
- treg;
191
-
192
- if (!this.inst) this.inst = $.datepicker._getInst(this.$input[0]);
193
-
194
- if (withDate || !this._defaults.timeOnly) {
195
- // the time should come after x number of characters and a space.
196
- // x = at least the length of text specified by the date format
197
- var dp_dateFormat = $.datepicker._get(this.inst, 'dateFormat');
198
- regstr = '.{' + dp_dateFormat.length + ',}' + this._defaults.separator + regstr;
199
- }
200
-
201
- treg = timeString.match(new RegExp(regstr, 'i'));
202
-
203
- if (treg) {
204
- if (order.t !== -1)
205
- this.ampm = ((treg[order.t] === undefined || treg[order.t].length === 0) ?
206
- '' :
207
- (treg[order.t].charAt(0).toUpperCase() == 'A') ? 'AM' : 'PM').toUpperCase();
208
-
209
- if (order.h !== -1) {
210
- if (this.ampm == 'AM' && treg[order.h] == '12')
211
- this.hour = 0; // 12am = 0 hour
212
- else if (this.ampm == 'PM' && treg[order.h] != '12')
213
- this.hour = (parseFloat(treg[order.h]) + 12).toFixed(0); // 12pm = 12 hour, any other pm = hour + 12
214
- else this.hour = Number(treg[order.h]);
215
- }
216
-
217
- if (order.m !== -1) this.minute = Number(treg[order.m]);
218
- if (order.s !== -1) this.second = Number(treg[order.s]);
219
-
220
- return true;
221
-
222
- }
223
- return false;
224
- },
225
-
226
- //########################################################################
227
- // figure out position of time elements.. cause js cant do named captures
228
- //########################################################################
229
- _getFormatPositions: function() {
230
- var finds = this._defaults.timeFormat.toLowerCase().match(/(h{1,2}|m{1,2}|s{1,2}|t{1,2})/g),
231
- orders = { h: -1, m: -1, s: -1, t: -1 };
232
-
233
- if (finds)
234
- for (var i = 0; i < finds.length; i++)
235
- if (orders[finds[i].toString().charAt(0)] == -1)
236
- orders[finds[i].toString().charAt(0)] = i + 1;
237
-
238
- return orders;
239
- },
240
-
241
- //########################################################################
242
- // generate and inject html for timepicker into ui datepicker
243
- //########################################################################
244
- _injectTimePicker: function() {
245
- var $dp = this.inst.dpDiv,
246
- o = this._defaults,
247
- tp_inst = this,
248
- // Added by Peter Medeiros:
249
- // - Figure out what the hour/minute/second max should be based on the step values.
250
- // - Example: if stepMinute is 15, then minMax is 45.
251
- hourMax = (o.hourMax - (o.hourMax % o.stepHour)).toFixed(0),
252
- minMax = (o.minuteMax - (o.minuteMax % o.stepMinute)).toFixed(0),
253
- secMax = (o.secondMax - (o.secondMax % o.stepSecond)).toFixed(0),
254
- dp_id = this.inst.id.toString().replace(/([^A-Za-z0-9_])/g, '');
255
-
256
- // Prevent displaying twice
257
- //if ($dp.find("div#ui-timepicker-div-"+ dp_id).length === 0) {
258
- if ($dp.find("div#ui-timepicker-div-"+ dp_id).length === 0 && o.showTimepicker) {
259
- var noDisplay = ' style="display:none;"',
260
- html = '<div class="ui-timepicker-div" id="ui-timepicker-div-' + dp_id + '"><dl>' +
261
- '<dt class="ui_tpicker_time_label" id="ui_tpicker_time_label_' + dp_id + '"' +
262
- ((o.showTime) ? '' : noDisplay) + '>' + o.timeText + '</dt>' +
263
- '<dd class="ui_tpicker_time" id="ui_tpicker_time_' + dp_id + '"' +
264
- ((o.showTime) ? '' : noDisplay) + '></dd>' +
265
- '<dt class="ui_tpicker_hour_label" id="ui_tpicker_hour_label_' + dp_id + '"' +
266
- ((o.showHour) ? '' : noDisplay) + '>' + o.hourText + '</dt>',
267
- hourGridSize = 0,
268
- minuteGridSize = 0,
269
- secondGridSize = 0,
270
- size;
271
-
272
- if (o.showHour && o.hourGrid > 0) {
273
- html += '<dd class="ui_tpicker_hour">' +
274
- '<div id="ui_tpicker_hour_' + dp_id + '"' + ((o.showHour) ? '' : noDisplay) + '></div>' +
275
- '<div style="padding-left: 1px"><table><tr>';
276
-
277
- for (var h = o.hourMin; h < hourMax; h += o.hourGrid) {
278
- hourGridSize++;
279
- var tmph = (o.ampm && h > 12) ? h-12 : h;
280
- if (tmph < 10) tmph = '0' + tmph;
281
- if (o.ampm) {
282
- if (h == 0) tmph = 12 +'a';
283
- else if (h < 12) tmph += 'a';
284
- else tmph += 'p';
285
- }
286
- html += '<td>' + tmph + '</td>';
287
- }
288
-
289
- html += '</tr></table></div>' +
290
- '</dd>';
291
- } else html += '<dd class="ui_tpicker_hour" id="ui_tpicker_hour_' + dp_id + '"' +
292
- ((o.showHour) ? '' : noDisplay) + '></dd>';
293
-
294
- html += '<dt class="ui_tpicker_minute_label" id="ui_tpicker_minute_label_' + dp_id + '"' +
295
- ((o.showMinute) ? '' : noDisplay) + '>' + o.minuteText + '</dt>';
296
-
297
- if (o.showMinute && o.minuteGrid > 0) {
298
- html += '<dd class="ui_tpicker_minute ui_tpicker_minute_' + o.minuteGrid + '">' +
299
- '<div id="ui_tpicker_minute_' + dp_id + '"' +
300
- ((o.showMinute) ? '' : noDisplay) + '></div>' +
301
- '<div style="padding-left: 1px"><table><tr>';
302
-
303
- for (var m = o.minuteMin; m < minMax; m += o.minuteGrid) {
304
- minuteGridSize++;
305
- html += '<td>' + ((m < 10) ? '0' : '') + m + '</td>';
306
- }
307
-
308
- html += '</tr></table></div>' +
309
- '</dd>';
310
- } else html += '<dd class="ui_tpicker_minute" id="ui_tpicker_minute_' + dp_id + '"' +
311
- ((o.showMinute) ? '' : noDisplay) + '></dd>';
312
-
313
- html += '<dt class="ui_tpicker_second_label" id="ui_tpicker_second_label_' + dp_id + '"' +
314
- ((o.showSecond) ? '' : noDisplay) + '>' + o.secondText + '</dt>';
315
-
316
- if (o.showSecond && o.secondGrid > 0) {
317
- html += '<dd class="ui_tpicker_second ui_tpicker_second_' + o.secondGrid + '">' +
318
- '<div id="ui_tpicker_second_' + dp_id + '"' +
319
- ((o.showSecond) ? '' : noDisplay) + '></div>' +
320
- '<div style="padding-left: 1px"><table><tr>';
321
-
322
- for (var s = o.secondMin; s < secMax; s += o.secondGrid) {
323
- secondGridSize++;
324
- html += '<td>' + ((s < 10) ? '0' : '') + s + '</td>';
325
- }
326
-
327
- html += '</tr></table></div>' +
328
- '</dd>';
329
- } else html += '<dd class="ui_tpicker_second" id="ui_tpicker_second_' + dp_id + '"' +
330
- ((o.showSecond) ? '' : noDisplay) + '></dd>';
331
-
332
- html += '</dl></div>';
333
- $tp = $(html);
334
-
335
- // if we only want time picker...
336
- if (o.timeOnly === true) {
337
- $tp.prepend(
338
- '<div class="ui-widget-header ui-helper-clearfix ui-corner-all">' +
339
- '<div class="ui-datepicker-title">' + o.timeOnlyTitle + '</div>' +
340
- '</div>');
341
- $dp.find('.ui-datepicker-header, .ui-datepicker-calendar').hide();
342
- }
343
-
344
- this.hour_slider = $tp.find('#ui_tpicker_hour_'+ dp_id).slider({
345
- orientation: "horizontal",
346
- value: this.hour,
347
- min: o.hourMin,
348
- max: hourMax,
349
- step: o.stepHour,
350
- slide: function(event, ui) {
351
- tp_inst.hour_slider.slider( "option", "value", ui.value);
352
- tp_inst._onTimeChange();
353
- }
354
- });
355
-
356
- // Updated by Peter Medeiros:
357
- // - Pass in Event and UI instance into slide function
358
- this.minute_slider = $tp.find('#ui_tpicker_minute_'+ dp_id).slider({
359
- orientation: "horizontal",
360
- value: this.minute,
361
- min: o.minuteMin,
362
- max: minMax,
363
- step: o.stepMinute,
364
- slide: function(event, ui) {
365
- // update the global minute slider instance value with the current slider value
366
- tp_inst.minute_slider.slider( "option", "value", ui.value);
367
- tp_inst._onTimeChange();
368
- }
369
- });
370
-
371
- this.second_slider = $tp.find('#ui_tpicker_second_'+ dp_id).slider({
372
- orientation: "horizontal",
373
- value: this.second,
374
- min: o.secondMin,
375
- max: secMax,
376
- step: o.stepSecond,
377
- slide: function(event, ui) {
378
- tp_inst.second_slider.slider( "option", "value", ui.value);
379
- tp_inst._onTimeChange();
380
- }
381
- });
382
-
383
- // Add grid functionality
384
- if (o.showHour && o.hourGrid > 0) {
385
- size = 100 * hourGridSize * o.hourGrid / (hourMax - o.hourMin);
386
-
387
- $tp.find(".ui_tpicker_hour table").css({
388
- width: size + "%",
389
- marginLeft: (size / (-2 * hourGridSize)) + "%",
390
- borderCollapse: 'collapse'
391
- }).find("td").each( function(index) {
392
- $(this).click(function() {
393
- var h = $(this).html();
394
- if(o.ampm) {
395
- var ap = h.substring(2).toLowerCase(),
396
- aph = parseInt(h.substring(0,2));
397
- if (ap == 'a') {
398
- if (aph == 12) h = 0;
399
- else h = aph;
400
- } else if (aph == 12) h = 12;
401
- else h = aph + 12;
402
- }
403
- tp_inst.hour_slider.slider("option", "value", h);
404
- tp_inst._onTimeChange();
405
- }).css({
406
- cursor: 'pointer',
407
- width: (100 / hourGridSize) + '%',
408
- textAlign: 'center',
409
- overflow: 'hidden'
410
- });
411
- });
412
- }
413
-
414
- if (o.showMinute && o.minuteGrid > 0) {
415
- size = 100 * minuteGridSize * o.minuteGrid / (minMax - o.minuteMin);
416
- $tp.find(".ui_tpicker_minute table").css({
417
- width: size + "%",
418
- marginLeft: (size / (-2 * minuteGridSize)) + "%",
419
- borderCollapse: 'collapse'
420
- }).find("td").each(function(index) {
421
- $(this).click(function() {
422
- tp_inst.minute_slider.slider("option", "value", $(this).html());
423
- tp_inst._onTimeChange();
424
- }).css({
425
- cursor: 'pointer',
426
- width: (100 / minuteGridSize) + '%',
427
- textAlign: 'center',
428
- overflow: 'hidden'
429
- });
430
- });
431
- }
432
-
433
- if (o.showSecond && o.secondGrid > 0) {
434
- $tp.find(".ui_tpicker_second table").css({
435
- width: size + "%",
436
- marginLeft: (size / (-2 * secondGridSize)) + "%",
437
- borderCollapse: 'collapse'
438
- }).find("td").each(function(index) {
439
- $(this).click(function() {
440
- tp_inst.second_slider.slider("option", "value", $(this).html());
441
- tp_inst._onTimeChange();
442
- }).css({
443
- cursor: 'pointer',
444
- width: (100 / secondGridSize) + '%',
445
- textAlign: 'center',
446
- overflow: 'hidden'
447
- });
448
- });
449
- }
450
-
451
- var $buttonPanel = $dp.find('.ui-datepicker-buttonpane');
452
- if ($buttonPanel.length) $buttonPanel.before($tp);
453
- else $dp.append($tp);
454
-
455
- this.$timeObj = $('#ui_tpicker_time_'+ dp_id);
456
-
457
- if (this.inst !== null) {
458
- var timeDefined = this.timeDefined;
459
- this._onTimeChange();
460
- this.timeDefined = timeDefined;
461
- }
462
-
463
- //Emulate datepicker onSelect behavior. Call on slidestop.
464
- var onSelect = tp_inst._defaults['onSelect'];
465
- if (onSelect) {
466
- var inputEl = tp_inst.$input ? tp_inst.$input[0] : null;
467
- var onSelectHandler = function() {
468
- onSelect.apply(inputEl, [tp_inst.formattedDateTime, tp_inst]); // trigger custom callback*/
469
- }
470
- this.hour_slider.bind('slidestop',onSelectHandler);
471
- this.minute_slider.bind('slidestop',onSelectHandler);
472
- this.second_slider.bind('slidestop',onSelectHandler);
473
- }
474
- }
475
- },
476
-
477
- //########################################################################
478
- // This function tries to limit the ability to go outside the
479
- // min/max date range
480
- //########################################################################
481
- _limitMinMaxDateTime: function(dp_inst, adjustSliders){
482
- var o = this._defaults,
483
- dp_date = new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay),
484
- tp_date = new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay, this.hour, this.minute, this.second, 0);
485
-
486
- if(this._defaults.minDateTime !== null && dp_date){
487
- var minDateTime = this._defaults.minDateTime,
488
- minDateTimeDate = new Date(minDateTime.getFullYear(), minDateTime.getMonth(), minDateTime.getDate(), 0, 0, 0, 0);
489
-
490
- if(this.hourMinOriginal === null || this.minuteMinOriginal === null || this.secondMinOriginal === null){
491
- this.hourMinOriginal = o.hourMin;
492
- this.minuteMinOriginal = o.minuteMin;
493
- this.secondMinOriginal = o.secondMin;
494
- }
495
-
496
- if(minDateTimeDate.getTime() == dp_date.getTime()){
497
- this._defaults.hourMin = minDateTime.getHours();
498
- this._defaults.minuteMin = minDateTime.getMinutes();
499
- this._defaults.secondMin = minDateTime.getSeconds();
500
-
501
- if(this.hour < this._defaults.hourMin) this.hour = this._defaults.hourMin;
502
- if(this.minute < this._defaults.minuteMin) this.minute = this._defaults.minuteMin;
503
- if(this.second < this._defaults.secondMin) this.second = this._defaults.secondMin;
504
- }else{
505
- this._defaults.hourMin = this.hourMinOriginal;
506
- this._defaults.minuteMin = this.minuteMinOriginal;
507
- this._defaults.secondMin = this.secondMinOriginal;
508
- }
509
- }
510
-
511
- if(this._defaults.maxDateTime !== null && dp_date){
512
- var maxDateTime = this._defaults.maxDateTime,
513
- maxDateTimeDate = new Date(maxDateTime.getFullYear(), maxDateTime.getMonth(), maxDateTime.getDate(), 0, 0, 0, 0);
514
-
515
- if(this.hourMaxOriginal === null || this.minuteMaxOriginal === null || this.secondMaxOriginal === null){
516
- this.hourMaxOriginal = o.hourMax;
517
- this.minuteMaxOriginal = o.minuteMax;
518
- this.secondMaxOriginal = o.secondMax;
519
- }
520
-
521
- if(maxDateTimeDate.getTime() == dp_date.getTime()){
522
- this._defaults.hourMax = maxDateTime.getHours();
523
- this._defaults.minuteMax = maxDateTime.getMinutes();
524
- this._defaults.secondMax = maxDateTime.getSeconds();
525
-
526
- if(this.hour > this._defaults.hourMax){ this.hour = this._defaults.hourMax; }
527
- if(this.minute > this._defaults.minuteMax) this.minute = this._defaults.minuteMax;
528
- if(this.second > this._defaults.secondMax) this.second = this._defaults.secondMax;
529
- }else{
530
- this._defaults.hourMax = this.hourMaxOriginal;
531
- this._defaults.minuteMax = this.minuteMaxOriginal;
532
- this._defaults.secondMax = this.secondMaxOriginal;
533
- }
534
- }
535
-
536
- if(adjustSliders !== undefined && adjustSliders === true){
537
- this.hour_slider.slider("option", { min: this._defaults.hourMin, max: this._defaults.hourMax }).slider('value', this.hour);
538
- this.minute_slider.slider("option", { min: this._defaults.minuteMin, max: this._defaults.minuteMax }).slider('value', this.minute);
539
- this.second_slider.slider("option", { min: this._defaults.secondMin, max: this._defaults.secondMax }).slider('value', this.second);
540
- }
541
-
542
- },
543
-
544
- //########################################################################
545
- // when a slider moves, set the internal time...
546
- // on time change is also called when the time is updated in the text field
547
- //########################################################################
548
- _onTimeChange: function() {
549
- var hour = (this.hour_slider) ? this.hour_slider.slider('value') : false,
550
- minute = (this.minute_slider) ? this.minute_slider.slider('value') : false,
551
- second = (this.second_slider) ? this.second_slider.slider('value') : false;
552
-
553
- if (hour !== false) hour = parseInt(hour,10);
554
- if (minute !== false) minute = parseInt(minute,10);
555
- if (second !== false) second = parseInt(second,10);
556
-
557
- var ampm = (hour < 12) ? 'AM' : 'PM';
558
-
559
- // If the update was done in the input field, the input field should not be updated.
560
- // If the update was done using the sliders, update the input field.
561
- var hasChanged = (hour != this.hour || minute != this.minute || second != this.second || (this.ampm.length > 0 && this.ampm != ampm));
562
-
563
- if (hasChanged) {
564
-
565
- if (hour !== false)this.hour = hour;
566
- if (minute !== false) this.minute = minute;
567
- if (second !== false) this.second = second;
568
- }
569
- if (this._defaults.ampm) this.ampm = ampm;
570
-
571
- this._formatTime();
572
- if (this.$timeObj) this.$timeObj.text(this.formattedTime);
573
- this.timeDefined = true;
574
- if (hasChanged) this._updateDateTime();
575
- },
576
-
577
- //########################################################################
578
- // format the time all pretty...
579
- //########################################################################
580
- _formatTime: function(time, format, ampm) {
581
- if (ampm == undefined) ampm = this._defaults.ampm;
582
- time = time || { hour: this.hour, minute: this.minute, second: this.second, ampm: this.ampm };
583
- var tmptime = format || this._defaults.timeFormat.toString();
584
-
585
- if (ampm) {
586
- var hour12 = ((time.ampm == 'AM') ? (time.hour) : (time.hour % 12));
587
- hour12 = (Number(hour12) === 0) ? 12 : hour12;
588
- tmptime = tmptime.toString()
589
- .replace(/hh/g, ((hour12 < 10) ? '0' : '') + hour12)
590
- .replace(/h/g, hour12)
591
- .replace(/mm/g, ((time.minute < 10) ? '0' : '') + time.minute)
592
- .replace(/m/g, time.minute)
593
- .replace(/ss/g, ((time.second < 10) ? '0' : '') + time.second)
594
- .replace(/s/g, time.second)
595
- .replace(/TT/g, time.ampm.toUpperCase())
596
- .replace(/tt/g, time.ampm.toLowerCase())
597
- .replace(/T/g, time.ampm.charAt(0).toUpperCase())
598
- .replace(/t/g, time.ampm.charAt(0).toLowerCase());
599
- } else {
600
- tmptime = tmptime.toString()
601
- .replace(/hh/g, ((time.hour < 10) ? '0' : '') + time.hour)
602
- .replace(/h/g, time.hour)
603
- .replace(/mm/g, ((time.minute < 10) ? '0' : '') + time.minute)
604
- .replace(/m/g, time.minute)
605
- .replace(/ss/g, ((time.second < 10) ? '0' : '') + time.second)
606
- .replace(/s/g, time.second);
607
- tmptime = $.trim(tmptime.replace(/t/gi, ''));
608
- }
609
-
610
- if (arguments.length) return tmptime;
611
- else this.formattedTime = tmptime;
612
- },
613
-
614
- //########################################################################
615
- // update our input with the new date time..
616
- //########################################################################
617
- _updateDateTime: function(dp_inst) {
618
- dp_inst = this.inst || dp_inst,
619
- dt = new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay),
620
- dateFmt = $.datepicker._get(dp_inst, 'dateFormat'),
621
- formatCfg = $.datepicker._getFormatConfig(dp_inst),
622
- timeAvailable = dt !== null && this.timeDefined;
623
- this.formattedDate = $.datepicker.formatDate(dateFmt, (dt === null ? new Date() : dt), formatCfg);
624
- var formattedDateTime = this.formattedDate;
625
- if (dp_inst.lastVal !== undefined && (dp_inst.lastVal.length > 0 && this.$input.val().length === 0))
626
- return;
627
-
628
- if (this._defaults.timeOnly === true) {
629
- formattedDateTime = this.formattedTime;
630
- } else if (this._defaults.timeOnly !== true && (this._defaults.alwaysSetTime || timeAvailable)) {
631
- formattedDateTime += this._defaults.separator + this.formattedTime;
632
- }
633
-
634
- this.formattedDateTime = formattedDateTime;
635
-
636
- if(!this._defaults.showTimepicker) {
637
- this.$input.val(this.formattedDate);
638
- } else if (this.$altInput && this._defaults.altFieldTimeOnly === true) {
639
- this.$altInput.val(this.formattedTime);
640
- this.$input.val(this.formattedDate);
641
- } else if(this.$altInput) {
642
- this.$altInput.val(formattedDateTime);
643
- this.$input.val(formattedDateTime);
644
- } else {
645
- this.$input.val(formattedDateTime);
646
- }
647
-
648
- this.$input.trigger("change");
649
- }
650
-
651
- });
652
-
653
- $.fn.extend({
654
- //########################################################################
655
- // shorthand just to use timepicker..
656
- //########################################################################
657
- timepicker: function(o) {
658
- o = o || {};
659
- var tmp_args = arguments;
660
-
661
- if (typeof o == 'object') tmp_args[0] = $.extend(o, { timeOnly: true });
662
-
663
- return $(this).each(function() {
664
- $.fn.datetimepicker.apply($(this), tmp_args);
665
- });
666
- },
667
-
668
- //########################################################################
669
- // extend timepicker to datepicker
670
- //########################################################################
671
- datetimepicker: function(o) {
672
- o = o || {};
673
- var $input = this,
674
- tmp_args = arguments;
675
-
676
- if (typeof(o) == 'string'){
677
- if(o == 'getDate')
678
- return $.fn.datepicker.apply($(this[0]), tmp_args);
679
- else
680
- return this.each(function() {
681
- var $t = $(this);
682
- $t.datepicker.apply($t, tmp_args);
683
- });
684
- }
685
- else
686
- return this.each(function() {
687
- var $t = $(this);
688
- $t.datepicker($.timepicker._newInst($t, o)._defaults);
689
- });
690
- }
691
- });
692
-
693
- //########################################################################
694
- // the bad hack :/ override datepicker so it doesnt close on select
695
- // inspired: http://stackoverflow.com/questions/1252512/jquery-datepicker-prevent-closing-picker-when-clicking-a-date/1762378#1762378
696
- //########################################################################
697
- $.datepicker._base_selectDate = $.datepicker._selectDate;
698
- $.datepicker._selectDate = function (id, dateStr) {
699
- var inst = this._getInst($(id)[0]),
700
- tp_inst = this._get(inst, 'timepicker');
701
-
702
- if (tp_inst) {
703
- tp_inst._limitMinMaxDateTime(inst, true);
704
- inst.inline = inst.stay_open = true;
705
- //This way the onSelect handler called from calendarpicker get the full dateTime
706
- this._base_selectDate(id, dateStr + tp_inst._defaults.separator + tp_inst.formattedTime);
707
- inst.inline = inst.stay_open = false;
708
- this._notifyChange(inst);
709
- this._updateDatepicker(inst);
710
- }
711
- else this._base_selectDate(id, dateStr);
712
- };
713
-
714
- //#############################################################################################
715
- // second bad hack :/ override datepicker so it triggers an event when changing the input field
716
- // and does not redraw the datepicker on every selectDate event
717
- //#############################################################################################
718
- $.datepicker._base_updateDatepicker = $.datepicker._updateDatepicker;
719
- $.datepicker._updateDatepicker = function(inst) {
720
- if (typeof(inst.stay_open) !== 'boolean' || inst.stay_open === false) {
721
-
722
- this._base_updateDatepicker(inst);
723
-
724
- // Reload the time control when changing something in the input text field.
725
- var tp_inst = this._get(inst, 'timepicker');
726
- if(tp_inst) tp_inst._addTimePicker(inst);
727
- }
728
- };
729
-
730
- //#######################################################################################
731
- // third bad hack :/ override datepicker so it allows spaces and colan in the input field
732
- //#######################################################################################
733
- $.datepicker._base_doKeyPress = $.datepicker._doKeyPress;
734
- $.datepicker._doKeyPress = function(event) {
735
- var inst = $.datepicker._getInst(event.target),
736
- tp_inst = $.datepicker._get(inst, 'timepicker');
737
-
738
- if (tp_inst) {
739
- if ($.datepicker._get(inst, 'constrainInput')) {
740
- var ampm = tp_inst._defaults.ampm,
741
- datetimeChars = tp_inst._defaults.timeFormat.toString()
742
- .replace(/[hms]/g, '')
743
- .replace(/TT/g, ampm ? 'APM' : '')
744
- .replace(/T/g, ampm ? 'AP' : '')
745
- .replace(/tt/g, ampm ? 'apm' : '')
746
- .replace(/t/g, ampm ? 'ap' : '') +
747
- " " +
748
- tp_inst._defaults.separator +
749
- $.datepicker._possibleChars($.datepicker._get(inst, 'dateFormat')),
750
- chr = String.fromCharCode(event.charCode === undefined ? event.keyCode : event.charCode);
751
- return event.ctrlKey || (chr < ' ' || !datetimeChars || datetimeChars.indexOf(chr) > -1);
752
- }
753
- }
754
-
755
- return $.datepicker._base_doKeyPress(event);
756
- };
757
-
758
- //#######################################################################################
759
- // Override key up event to sync manual input changes.
760
- //#######################################################################################
761
- $.datepicker._base_doKeyUp = $.datepicker._doKeyUp;
762
- $.datepicker._doKeyUp = function (event) {
763
- var inst = $.datepicker._getInst(event.target),
764
- tp_inst = $.datepicker._get(inst, 'timepicker');
765
-
766
- if (tp_inst) {
767
- if (tp_inst._defaults.timeOnly && (inst.input.val() != inst.lastVal)) {
768
- try {
769
- $.datepicker._updateDatepicker(inst);
770
- }
771
- catch (err) {
772
- $.datepicker.log(err);
773
- }
774
- }
775
- }
776
-
777
- return $.datepicker._base_doKeyUp(event);
778
- };
779
-
780
- //#######################################################################################
781
- // override "Today" button to also grab the time.
782
- //#######################################################################################
783
- $.datepicker._base_gotoToday = $.datepicker._gotoToday;
784
- $.datepicker._gotoToday = function(id) {
785
- this._base_gotoToday(id);
786
- this._setTime(this._getInst($(id)[0]), new Date());
787
- };
788
-
789
- //#######################################################################################
790
- // Disable & enable the Time in the datetimepicker
791
- //#######################################################################################
792
- $.datepicker._disableTimepickerDatepicker = function(target, date, withDate) {
793
- var inst = this._getInst(target),
794
- tp_inst = this._get(inst, 'timepicker');
795
- if (tp_inst) {
796
- tp_inst._defaults.showTimepicker = false;
797
- tp_inst._onTimeChange();
798
- tp_inst._updateDateTime(inst);
799
- }
800
- };
801
-
802
- $.datepicker._enableTimepickerDatepicker = function(target, date, withDate) {
803
- var inst = this._getInst(target),
804
- tp_inst = this._get(inst, 'timepicker');
805
- if (tp_inst) {
806
- tp_inst._defaults.showTimepicker = true;
807
- tp_inst._onTimeChange();
808
- tp_inst._updateDateTime(inst);
809
- }
810
- };
811
-
812
- //#######################################################################################
813
- // Create our own set time function
814
- //#######################################################################################
815
- $.datepicker._setTime = function(inst, date) {
816
- var tp_inst = this._get(inst, 'timepicker');
817
- if (tp_inst) {
818
- var defaults = tp_inst._defaults,
819
- // calling _setTime with no date sets time to defaults
820
- hour = date ? date.getHours() : defaults.hour,
821
- minute = date ? date.getMinutes() : defaults.minute,
822
- second = date ? date.getSeconds() : defaults.second;
823
-
824
- //check if within min/max times..
825
- if ((hour < defaults.hourMin || hour > defaults.hourMax) || (minute < defaults.minuteMin || minute > defaults.minuteMax) || (second < defaults.secondMin || second > defaults.secondMax)) {
826
- hour = defaults.hourMin;
827
- minute = defaults.minuteMin;
828
- second = defaults.secondMin;
829
- }
830
-
831
- if (tp_inst.hour_slider) tp_inst.hour_slider.slider('value', hour);
832
- else tp_inst.hour = hour;
833
- if (tp_inst.minute_slider) tp_inst.minute_slider.slider('value', minute);
834
- else tp_inst.minute = minute;
835
- if (tp_inst.second_slider) tp_inst.second_slider.slider('value', second);
836
- else tp_inst.second = second;
837
-
838
- tp_inst._onTimeChange();
839
- tp_inst._updateDateTime(inst);
840
- }
841
- };
842
-
843
- //#######################################################################################
844
- // Create new public method to set only time, callable as $().datepicker('setTime', date)
845
- //#######################################################################################
846
- $.datepicker._setTimeDatepicker = function(target, date, withDate) {
847
- var inst = this._getInst(target),
848
- tp_inst = this._get(inst, 'timepicker');
849
-
850
- if (tp_inst) {
851
- this._setDateFromField(inst);
852
- var tp_date;
853
- if (date) {
854
- if (typeof date == "string") {
855
- tp_inst._parseTime(date, withDate);
856
- tp_date = new Date();
857
- tp_date.setHours(tp_inst.hour, tp_inst.minute, tp_inst.second);
858
- }
859
- else tp_date = new Date(date.getTime());
860
- if (tp_date.toString() == 'Invalid Date') tp_date = undefined;
861
- }
862
- this._setTime(inst, tp_date);
863
- }
864
-
865
- };
866
-
867
- //#######################################################################################
868
- // override setDate() to allow setting time too within Date object
869
- //#######################################################################################
870
- $.datepicker._base_setDateDatepicker = $.datepicker._setDateDatepicker;
871
- $.datepicker._setDateDatepicker = function(target, date) {
872
- var inst = this._getInst(target),
873
- tp_date = (date instanceof Date) ? new Date(date.getTime()) : date;
874
-
875
- this._updateDatepicker(inst);
876
- this._base_setDateDatepicker.apply(this, arguments);
877
- this._setTimeDatepicker(target, tp_date, true);
878
- };
879
-
880
- //#######################################################################################
881
- // override getDate() to allow getting time too within Date object
882
- //#######################################################################################
883
- $.datepicker._base_getDateDatepicker = $.datepicker._getDateDatepicker;
884
- $.datepicker._getDateDatepicker = function(target, noDefault) {
885
- var inst = this._getInst(target),
886
- tp_inst = this._get(inst, 'timepicker');
887
-
888
- if (tp_inst) {
889
- this._setDateFromField(inst, noDefault);
890
- var date = this._getDate(inst);
891
- if (date && tp_inst._parseTime($(target).val(), true)) date.setHours(tp_inst.hour, tp_inst.minute, tp_inst.second);
892
- return date;
893
- }
894
- return this._base_getDateDatepicker(target, noDefault);
895
- };
896
-
897
- //#######################################################################################
898
- // jQuery extend now ignores nulls!
899
- //#######################################################################################
900
- function extendRemove(target, props) {
901
- $.extend(target, props);
902
- for (var name in props)
903
- if (props[name] === null || props[name] === undefined)
904
- target[name] = props[name];
905
- return target;
906
- }
907
-
908
- $.timepicker = new Timepicker(); // singleton instance
909
- $.timepicker.version = "0.9.3";
910
-
911
- })(jQuery);