mindapp 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (195) hide show
  1. data/.gitignore +17 -0
  2. data/Gemfile +4 -0
  3. data/LICENSE.txt +22 -0
  4. data/README.md +29 -0
  5. data/Rakefile +1 -0
  6. data/lib/generators/mindapp/USAGE +8 -0
  7. data/lib/generators/mindapp/install_generator.rb +134 -0
  8. data/lib/generators/mindapp/templates/app/assets/images/account.png +0 -0
  9. data/lib/generators/mindapp/templates/app/assets/images/add.png +0 -0
  10. data/lib/generators/mindapp/templates/app/assets/images/ajax-loader-circle.gif +0 -0
  11. data/lib/generators/mindapp/templates/app/assets/images/ajax-loader.gif +0 -0
  12. data/lib/generators/mindapp/templates/app/assets/images/anchor.png +0 -0
  13. data/lib/generators/mindapp/templates/app/assets/images/application_double.png +0 -0
  14. data/lib/generators/mindapp/templates/app/assets/images/application_form_edit.png +0 -0
  15. data/lib/generators/mindapp/templates/app/assets/images/arrow_left.png +0 -0
  16. data/lib/generators/mindapp/templates/app/assets/images/arrow_right.png +0 -0
  17. data/lib/generators/mindapp/templates/app/assets/images/arrow_turn_left.png +0 -0
  18. data/lib/generators/mindapp/templates/app/assets/images/arrow_turn_right.png +0 -0
  19. data/lib/generators/mindapp/templates/app/assets/images/calendar.png +0 -0
  20. data/lib/generators/mindapp/templates/app/assets/images/cancel.png +0 -0
  21. data/lib/generators/mindapp/templates/app/assets/images/chart_bar.png +0 -0
  22. data/lib/generators/mindapp/templates/app/assets/images/clock.png +0 -0
  23. data/lib/generators/mindapp/templates/app/assets/images/cog.png +0 -0
  24. data/lib/generators/mindapp/templates/app/assets/images/control_fastforward.png +0 -0
  25. data/lib/generators/mindapp/templates/app/assets/images/control_play.png +0 -0
  26. data/lib/generators/mindapp/templates/app/assets/images/cross.png +0 -0
  27. data/lib/generators/mindapp/templates/app/assets/images/delete.png +0 -0
  28. data/lib/generators/mindapp/templates/app/assets/images/external-link.png +0 -0
  29. data/lib/generators/mindapp/templates/app/assets/images/help.png +0 -0
  30. data/lib/generators/mindapp/templates/app/assets/images/house.png +0 -0
  31. data/lib/generators/mindapp/templates/app/assets/images/logo_mindapp.png +0 -0
  32. data/lib/generators/mindapp/templates/app/assets/images/logout.png +0 -0
  33. data/lib/generators/mindapp/templates/app/assets/images/new.gif +0 -0
  34. data/lib/generators/mindapp/templates/app/assets/images/new.png +0 -0
  35. data/lib/generators/mindapp/templates/app/assets/images/page.png +0 -0
  36. data/lib/generators/mindapp/templates/app/assets/images/page_attach.png +0 -0
  37. data/lib/generators/mindapp/templates/app/assets/images/page_green.png +0 -0
  38. data/lib/generators/mindapp/templates/app/assets/images/page_output.png +0 -0
  39. data/lib/generators/mindapp/templates/app/assets/images/page_pdf.png +0 -0
  40. data/lib/generators/mindapp/templates/app/assets/images/pencil.png +0 -0
  41. data/lib/generators/mindapp/templates/app/assets/images/printer.png +0 -0
  42. data/lib/generators/mindapp/templates/app/assets/images/refresh.png +0 -0
  43. data/lib/generators/mindapp/templates/app/assets/images/report.png +0 -0
  44. data/lib/generators/mindapp/templates/app/assets/images/rssmall.png +0 -0
  45. data/lib/generators/mindapp/templates/app/assets/images/tick.png +0 -0
  46. data/lib/generators/mindapp/templates/app/assets/images/user.png +0 -0
  47. data/lib/generators/mindapp/templates/app/assets/images/view_code.png +0 -0
  48. data/lib/generators/mindapp/templates/app/assets/javascripts/application.js +19 -0
  49. data/lib/generators/mindapp/templates/app/assets/javascripts/disable_enter_key.js +10 -0
  50. data/lib/generators/mindapp/templates/app/assets/javascripts/iscroll-wrapper.js +32 -0
  51. data/lib/generators/mindapp/templates/app/assets/javascripts/iscroll.js +1084 -0
  52. data/lib/generators/mindapp/templates/app/assets/javascripts/jquery-1.7.1.js +9266 -0
  53. data/lib/generators/mindapp/templates/app/assets/javascripts/jquery.mobile.datebox.js +1772 -0
  54. data/lib/generators/mindapp/templates/app/assets/javascripts/jquery.mobile.js +7007 -0
  55. data/lib/generators/mindapp/templates/app/assets/javascripts/jquery.mobile.splitview.js +624 -0
  56. data/lib/generators/mindapp/templates/app/assets/javascripts/mindapp.js +14 -0
  57. data/lib/generators/mindapp/templates/app/assets/stylesheets/application.css.scss +18 -0
  58. data/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/sarabun.eot +0 -0
  59. data/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/sarabun.ttf +0 -0
  60. data/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/sarabun.woff +0 -0
  61. data/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/sarabun_bold.ttf +0 -0
  62. data/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/sarabun_bolditalic.ttf +0 -0
  63. data/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/sarabun_italic.ttf +0 -0
  64. data/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/thsarabunnew-webfont.eot +0 -0
  65. data/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/thsarabunnew-webfont.ttf +0 -0
  66. data/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/thsarabunnew-webfont.woff +0 -0
  67. data/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/thsarabunnew.css +47 -0
  68. data/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/thsarabunnew_bold-webfont.eot +0 -0
  69. data/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/thsarabunnew_bold-webfont.ttf +0 -0
  70. data/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/thsarabunnew_bold-webfont.woff +0 -0
  71. data/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/thsarabunnew_bolditalic-webfont.eot +0 -0
  72. data/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/thsarabunnew_bolditalic-webfont.ttf +0 -0
  73. data/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/thsarabunnew_bolditalic-webfont.woff +0 -0
  74. data/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/thsarabunnew_italic-webfont.eot +0 -0
  75. data/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/thsarabunnew_italic-webfont.ttf +0 -0
  76. data/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/thsarabunnew_italic-webfont.woff +0 -0
  77. data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ajax-loader.png +0 -0
  78. data/lib/generators/mindapp/templates/app/assets/stylesheets/images/bg.png +0 -0
  79. data/lib/generators/mindapp/templates/app/assets/stylesheets/images/button_black.png +0 -0
  80. data/lib/generators/mindapp/templates/app/assets/stylesheets/images/button_blue.png +0 -0
  81. data/lib/generators/mindapp/templates/app/assets/stylesheets/images/button_red.png +0 -0
  82. data/lib/generators/mindapp/templates/app/assets/stylesheets/images/cancel.png +0 -0
  83. data/lib/generators/mindapp/templates/app/assets/stylesheets/images/close.png +0 -0
  84. data/lib/generators/mindapp/templates/app/assets/stylesheets/images/del2.png +0 -0
  85. data/lib/generators/mindapp/templates/app/assets/stylesheets/images/deli4.png +0 -0
  86. data/lib/generators/mindapp/templates/app/assets/stylesheets/images/down-left.png +0 -0
  87. data/lib/generators/mindapp/templates/app/assets/stylesheets/images/down-right.png +0 -0
  88. data/lib/generators/mindapp/templates/app/assets/stylesheets/images/fbook.png +0 -0
  89. data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ff.png +0 -0
  90. data/lib/generators/mindapp/templates/app/assets/stylesheets/images/icon-search-black.png +0 -0
  91. data/lib/generators/mindapp/templates/app/assets/stylesheets/images/icons-18-black.png +0 -0
  92. data/lib/generators/mindapp/templates/app/assets/stylesheets/images/icons-18-white.png +0 -0
  93. data/lib/generators/mindapp/templates/app/assets/stylesheets/images/icons-36-black.png +0 -0
  94. data/lib/generators/mindapp/templates/app/assets/stylesheets/images/icons-36-white.png +0 -0
  95. data/lib/generators/mindapp/templates/app/assets/stylesheets/images/overlay.png +0 -0
  96. data/lib/generators/mindapp/templates/app/assets/stylesheets/images/rss3.png +0 -0
  97. data/lib/generators/mindapp/templates/app/assets/stylesheets/images/rss4.png +0 -0
  98. data/lib/generators/mindapp/templates/app/assets/stylesheets/images/search_bg.png +0 -0
  99. data/lib/generators/mindapp/templates/app/assets/stylesheets/images/stumble2.png +0 -0
  100. data/lib/generators/mindapp/templates/app/assets/stylesheets/images/stumble4.png +0 -0
  101. data/lib/generators/mindapp/templates/app/assets/stylesheets/images/tab-left.png +0 -0
  102. data/lib/generators/mindapp/templates/app/assets/stylesheets/images/tab-right.png +0 -0
  103. data/lib/generators/mindapp/templates/app/assets/stylesheets/images/tech3.png +0 -0
  104. data/lib/generators/mindapp/templates/app/assets/stylesheets/images/tech4.png +0 -0
  105. data/lib/generators/mindapp/templates/app/assets/stylesheets/images/twitter3.png +0 -0
  106. data/lib/generators/mindapp/templates/app/assets/stylesheets/images/twitter4.png +0 -0
  107. data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-anim_basic_16x16.gif +0 -0
  108. data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  109. data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_flat_55_fbec88_40x100.png +0 -0
  110. data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  111. data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  112. data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  113. data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_glass_75_d0e5f5_1x400.png +0 -0
  114. data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  115. data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  116. data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_glass_85_dfeffc_1x400.png +0 -0
  117. data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  118. data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_gloss-wave_55_5c9ccc_500x100.png +0 -0
  119. data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  120. data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_inset-hard_100_f5f8f9_1x100.png +0 -0
  121. data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_inset-hard_100_fcfdfd_1x100.png +0 -0
  122. data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-icons_217bc0_256x240.png +0 -0
  123. data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-icons_222222_256x240.png +0 -0
  124. data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-icons_2e83ff_256x240.png +0 -0
  125. data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-icons_454545_256x240.png +0 -0
  126. data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-icons_469bdd_256x240.png +0 -0
  127. data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-icons_6da8d5_256x240.png +0 -0
  128. data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-icons_888888_256x240.png +0 -0
  129. data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-icons_cd0a0a_256x240.png +0 -0
  130. data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-icons_d8e7f3_256x240.png +0 -0
  131. data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-icons_f9bd01_256x240.png +0 -0
  132. data/lib/generators/mindapp/templates/app/assets/stylesheets/indicator.gif +0 -0
  133. data/lib/generators/mindapp/templates/app/assets/stylesheets/jquery.mobile.css +1855 -0
  134. data/lib/generators/mindapp/templates/app/assets/stylesheets/jquery.mobile.datebox.css +65 -0
  135. data/lib/generators/mindapp/templates/app/assets/stylesheets/jquery.mobile.grids.collapsible.css +122 -0
  136. data/lib/generators/mindapp/templates/app/assets/stylesheets/jquery.mobile.splitview.css +130 -0
  137. data/lib/generators/mindapp/templates/app/assets/stylesheets/mindapp.css +134 -0
  138. data/lib/generators/mindapp/templates/app/assets/stylesheets/sarabun.css +37 -0
  139. data/lib/generators/mindapp/templates/app/controllers/identities_controller.rb +5 -0
  140. data/lib/generators/mindapp/templates/app/controllers/mindapp_controller.rb +464 -0
  141. data/lib/generators/mindapp/templates/app/controllers/sessions_controller.rb +28 -0
  142. data/lib/generators/mindapp/templates/app/mailers/.gitkeep +0 -0
  143. data/lib/generators/mindapp/templates/app/mailers/mindapp_mailer.rb +7 -0
  144. data/lib/generators/mindapp/templates/app/mindapp/index.mm +85 -0
  145. data/lib/generators/mindapp/templates/app/mindapp/template/view.html.erb +21 -0
  146. data/lib/generators/mindapp/templates/app/models/.gitkeep +0 -0
  147. data/lib/generators/mindapp/templates/app/models/identity.rb +14 -0
  148. data/lib/generators/mindapp/templates/app/models/mindapp/doc.rb +30 -0
  149. data/lib/generators/mindapp/templates/app/models/mindapp/module.rb +10 -0
  150. data/lib/generators/mindapp/templates/app/models/mindapp/notice.rb +11 -0
  151. data/lib/generators/mindapp/templates/app/models/mindapp/role.rb +7 -0
  152. data/lib/generators/mindapp/templates/app/models/mindapp/runseq.rb +24 -0
  153. data/lib/generators/mindapp/templates/app/models/mindapp/service.rb +16 -0
  154. data/lib/generators/mindapp/templates/app/models/mindapp/xmain.rb +38 -0
  155. data/lib/generators/mindapp/templates/app/models/param.rb +41 -0
  156. data/lib/generators/mindapp/templates/app/models/user.rb +30 -0
  157. data/lib/generators/mindapp/templates/app/views/identities/new.html.erb +30 -0
  158. data/lib/generators/mindapp/templates/app/views/layouts/_full.haml +39 -0
  159. data/lib/generators/mindapp/templates/app/views/layouts/_head.html.erb +14 -0
  160. data/lib/generators/mindapp/templates/app/views/layouts/_page.haml +16 -0
  161. data/lib/generators/mindapp/templates/app/views/layouts/_top.html.erb +10 -0
  162. data/lib/generators/mindapp/templates/app/views/layouts/application.haml +4 -0
  163. data/lib/generators/mindapp/templates/app/views/layouts/gmail.html.erb +9 -0
  164. data/lib/generators/mindapp/templates/app/views/layouts/mobile.html.erb +13 -0
  165. data/lib/generators/mindapp/templates/app/views/layouts/mobilejq.html.erb +31 -0
  166. data/lib/generators/mindapp/templates/app/views/layouts/print.html.erb +22 -0
  167. data/lib/generators/mindapp/templates/app/views/layouts/utf8.html.erb +21 -0
  168. data/lib/generators/mindapp/templates/app/views/mindapp/_activity.md +10 -0
  169. data/lib/generators/mindapp/templates/app/views/mindapp/_menu.haml +22 -0
  170. data/lib/generators/mindapp/templates/app/views/mindapp/_menu_mm.haml +30 -0
  171. data/lib/generators/mindapp/templates/app/views/mindapp/_model.md +5 -0
  172. data/lib/generators/mindapp/templates/app/views/mindapp/_modul.md +9 -0
  173. data/lib/generators/mindapp/templates/app/views/mindapp/_pending_home.haml +5 -0
  174. data/lib/generators/mindapp/templates/app/views/mindapp/_pending_page.haml +26 -0
  175. data/lib/generators/mindapp/templates/app/views/mindapp/_service.md +24 -0
  176. data/lib/generators/mindapp/templates/app/views/mindapp/_static.haml +23 -0
  177. data/lib/generators/mindapp/templates/app/views/mindapp/doc.md +37 -0
  178. data/lib/generators/mindapp/templates/app/views/mindapp/feed.rss.builder +27 -0
  179. data/lib/generators/mindapp/templates/app/views/mindapp/help.haml +20 -0
  180. data/lib/generators/mindapp/templates/app/views/mindapp/index.html.haml +34 -0
  181. data/lib/generators/mindapp/templates/app/views/mindapp/pending.haml +1 -0
  182. data/lib/generators/mindapp/templates/app/views/mindapp/run_form.haml +37 -0
  183. data/lib/generators/mindapp/templates/app/views/mindapp/search.haml +20 -0
  184. data/lib/generators/mindapp/templates/app/views/mindapp/status.haml +61 -0
  185. data/lib/generators/mindapp/templates/app/views/mindapp_mailer/gmail.html.erb +9 -0
  186. data/lib/generators/mindapp/templates/app/views/sessions/new.html.erb +11 -0
  187. data/lib/generators/mindapp/templates/mindapp.yml +10 -0
  188. data/lib/generators/mindapp/templates/seeds.rb +6 -0
  189. data/lib/mindapp.rb +6 -0
  190. data/lib/mindapp/helpers.rb +475 -0
  191. data/lib/mindapp/railtie.rb +18 -0
  192. data/lib/mindapp/version.rb +3 -0
  193. data/lib/tasks/mindapp.rake +191 -0
  194. data/mindapp.gemspec +19 -0
  195. metadata +239 -0
@@ -0,0 +1,1772 @@
1
+ /*
2
+ * jQuery Mobile Framework : plugin to provide a date and time picker.
3
+ * Copyright (c) JTSage
4
+ * CC 3.0 Attribution. May be relicensed without permission/notifcation.
5
+ * https://github.com/jtsage/jquery-mobile-datebox
6
+ */
7
+ (function($, undefined ) {
8
+ $.widget( "mobile.datebox", $.mobile.widget, {
9
+ options: {
10
+ // All widget options, including some internal runtime details
11
+ theme: 'c',
12
+ pickPageTheme: 'b',
13
+ pickPageInputTheme: 'e',
14
+ pickPageButtonTheme: 'a',
15
+ pickPageHighButtonTheme: 'e',
16
+ pickPageOHighButtonTheme: 'e',
17
+ pickPageODHighButtonTheme: 'e',
18
+ pickPageTodayButtonTheme: 'e',
19
+ pickPageSlideButtonTheme: 'd',
20
+ pickPageFlipButtonTheme: 'b',
21
+ centerWindow: true,
22
+ calHighToday: true,
23
+ calHighPicked: true,
24
+ noAnimation: false,
25
+ disableManualInput: false,
26
+
27
+ disabled: false,
28
+ wheelExists: false,
29
+ swipeEnabled: true,
30
+ zindex: '500',
31
+ debug: false,
32
+
33
+ setDateButtonLabel: 'Set Date',
34
+ setTimeButtonLabel: 'Set Time',
35
+ setDurationButtonLabel: 'Set Duration',
36
+ calTodayButtonLabel: 'Jump to Today',
37
+ titleDateDialogLabel: 'Set Date',
38
+ titleTimeDialogLabel: 'Set Time',
39
+ titleDialogLabel: false,
40
+ meridiemLetters: ['AM', 'PM'],
41
+ daysOfWeek: ['อาทิตย์', 'จันทร์', 'อังคาร', 'พุธ', 'พฤหัสบดี', 'ศุกร์', 'เสาร์'],
42
+ daysOfWeekShort: ['อา', 'จ', 'อ', 'พ', 'พฤ', 'ศ', 'ส'],
43
+ monthsOfYear: ['มกราคม', 'กุมภาพันธ์', 'มีนาคม', 'เมษษยน', 'พฤษภาคม', 'มิถุนายน', 'กรกฏาคม', 'สิงหาคม', 'กันยายน', 'ตุลาคม', 'พฤศจิกายน', 'ธันวาคม'],
44
+ monthsOfYearShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
45
+ durationLabel: ['Days', 'Hours', 'Minutes', 'Seconds'],
46
+ durationDays: ['Day', 'Days'],
47
+ durationFormat: 'DD ddd, hh:ii:ss',
48
+ timeFormat: 24,
49
+ timeFormats: { '12': 'gg:ii AA', '24': 'HH:ii' },
50
+ timeOutput: false,
51
+ rolloverMode: { 'm': true, 'd': true, 'h': true, 'i': true, 's': true },
52
+
53
+ mode: 'datebox',
54
+ calShowDays: true,
55
+ calShowOnlyMonth: false,
56
+ useDialogForceTrue: false,
57
+ useDialogForceFalse: false,
58
+ useDialog: false,
59
+ useModal: false,
60
+ useInline: false,
61
+ noButtonFocusMode: false,
62
+ noButton: false,
63
+ noSetButton: false,
64
+ closeCallback: false,
65
+ open: false,
66
+ nestedBox: false,
67
+
68
+ fieldsOrder: false,
69
+ dateFieldOrder: ['m', 'd', 'y'],
70
+ timeFieldOrder: ['h', 'i', 'a'],
71
+ slideFieldOrder: ['y', 'm', 'd'],
72
+ durationOrder: ['d', 'h', 'i', 's'],
73
+ headerFormat: 'ddd, mmm dd, YYYY',
74
+ dateFormat: 'YYYY-MM-DD',
75
+ minuteStep: 1,
76
+ calTodayButton: false,
77
+ calWeekMode: false,
78
+ calWeekModeFirstDay: 1,
79
+ calWeekModeHighlight: true,
80
+ calStartDay: 0,
81
+ defaultPickerValue: false,
82
+ defaultDate : false, //this is deprecated and will be removed in the future versions (ok, may be not)
83
+ minYear: false,
84
+ maxYear: false,
85
+ afterToday: false,
86
+ beforeToday: false,
87
+ maxDays: false,
88
+ minDays: false,
89
+ highDays: false,
90
+ highDates: false,
91
+ blackDays: false,
92
+ blackDates: false,
93
+ durationSteppers: {'d': 1, 'h': 1, 'i': 1, 's': 1},
94
+ disabledDayColor: '#888'
95
+ },
96
+ _dateboxHandler: function(event, payload) {
97
+ // Handle all event triggers that have an internal effect
98
+ if ( ! event.isPropagationStopped() ) {
99
+ switch (payload.method) {
100
+ case 'close':
101
+ $(this).data('datebox').close();
102
+ break;
103
+ case 'open':
104
+ $(this).data('datebox').open();
105
+ break;
106
+ case 'set':
107
+ $(this).val(payload.value);
108
+ $(this).trigger('change');
109
+ break;
110
+ case 'doset':
111
+ if ( $(this).data('datebox').options.mode === 'timebox' || $(this).data('datebox').options.mode === 'durationbox' ) {
112
+ $(this).trigger('datebox', {'method':'set', 'value':$(this).data('datebox')._formatTime($(this).data('datebox').theDate)});
113
+ } else {
114
+ $(this).trigger('datebox', {'method':'set', 'value':$(this).data('datebox')._formatDate($(this).data('datebox').theDate)});
115
+ }
116
+ case 'dooffset':
117
+ $(this).data('datebox')._offset(payload.type, payload.amount, true);
118
+ break;
119
+ case 'dorefresh':
120
+ $(this).data('datebox')._update();
121
+ break;
122
+ }
123
+ }
124
+ },
125
+ _zeroPad: function(number) {
126
+ // Pad a number with a zero, to make it 2 digits
127
+ return ( ( number < 10 ) ? "0" : "" ) + String(number);
128
+ },
129
+ _makeOrd: function (num) {
130
+ // Return an ordinal suffix (1st, 2nd, 3rd, etc)
131
+ var ending = num % 10;
132
+ if ( num > 9 && num < 21 ) { return 'th'; }
133
+ if ( ending > 3 ) { return 'th'; }
134
+ return ['th','st','nd','rd'][ending];
135
+ },
136
+ _isInt: function (s) {
137
+ // Bool, return is a number is an integer
138
+ return (s.toString().search(/^[0-9]+$/) === 0);
139
+ },
140
+ _dstAdjust: function(date) {
141
+ // Make sure not to run into daylight savings time.
142
+ if (!date) { return null; }
143
+ date.setHours(date.getHours() > 12 ? date.getHours() + 2 : 0);
144
+ return date;
145
+ },
146
+ _getFirstDay: function(date) {
147
+ // Get the first DAY of the month (0-6)
148
+ return new Date(date.getFullYear(), date.getMonth(), 1).getDay();
149
+ },
150
+ _getLastDate: function(date) {
151
+ // Get the last DATE of the month (28,29,30,31)
152
+ return 32 - this._dstAdjust(new Date(date.getFullYear(), date.getMonth(), 32)).getDate();
153
+ },
154
+ _getLastDateBefore: function(date) {
155
+ // Get the last DATE of the PREVIOUS month (28,29,30,31)
156
+ return 32 - this._dstAdjust(new Date(date.getFullYear(), date.getMonth()-1, 32)).getDate();
157
+ },
158
+ _formatter: function(format, date) {
159
+ // Format the output date or time (not duration)
160
+ format = format.replace('SS', this._makeOrd(date.getDate()));
161
+ format = format.replace('YYYY', date.getFullYear());
162
+ format = format.replace('mmmm', this.options.monthsOfYearShort[date.getMonth()] );
163
+ format = format.replace('mmm', this.options.monthsOfYear[date.getMonth()] );
164
+ format = format.replace('MM', this._zeroPad(date.getMonth() + 1));
165
+ format = format.replace('mm', date.getMonth() + 1);
166
+ format = format.replace('dddd', this.options.daysOfWeekShort[date.getDay()] );
167
+ format = format.replace('ddd', this.options.daysOfWeek[date.getDay()] );
168
+ format = format.replace('DD', this._zeroPad(date.getDate()));
169
+ format = format.replace('dd', date.getDate());
170
+
171
+ format = format.replace('HH', this._zeroPad(date.getHours()));
172
+ format = format.replace('GG', date.getHours());
173
+
174
+ format = format.replace('hh', this._zeroPad(((date.getHours() === 0 || date.getHours() === 12)?12:((date.getHours()<12)?date.getHours():date.getHours()-12))));
175
+ format = format.replace('gg', ((date.getHours() === 0 || date.getHours() === 12)?12:((date.getHours()<12)?date.getHours():(date.getHours()-12))));
176
+
177
+ format = format.replace('ii', this._zeroPad(date.getMinutes()));
178
+ format = format.replace('ss', this._zeroPad(date.getSeconds()));
179
+ format = format.replace('AA', ((date.getHours() < 12)?this.options.meridiemLetters[0].toUpperCase():this.options.meridiemLetters[1].toUpperCase()));
180
+ format = format.replace('aa', ((date.getHours() < 12)?this.options.meridiemLetters[0].toLowerCase():this.options.meridiemLetters[1].toLowerCase()));
181
+ return format;
182
+ },
183
+ _formatHeader: function(date) {
184
+ // Shortcut function to return headerFormat date/time format
185
+ return this._formatter(this.options.headerFormat, date);
186
+ },
187
+ _formatDate: function(date) {
188
+ // Shortcut function to return dateFormat date/time format
189
+ return this._formatter(this.options.dateFormat, date);
190
+ },
191
+ _isoDate: function(y,m,d) {
192
+ // Return an ISO 8601 date (yyyy-mm-dd)
193
+ return String(y) + '-' + (( m < 10 ) ? "0" : "") + String(m) + '-' + ((d < 10 ) ? "0" : "") + String(d);
194
+ },
195
+ _formatTime: function(date) {
196
+ // Shortcut to return formatted time, also handles duration
197
+ var self = this,
198
+ dur_collapse = [false,false,false], adv, exp_format, i, j,
199
+ format = this.options.durationFormat,
200
+ dur_comps = [0,0,0,0];
201
+
202
+ if ( this.options.mode === 'durationbox' ) {
203
+ adv = this.options.durationFormat;
204
+ adv = adv.replace(/ddd/g, '.+?');
205
+ adv = adv.replace(/DD|ss|hh|ii/g, '([0-9Dhis]+)');
206
+ adv = RegExp('^' + adv + '$');
207
+ exp_format = adv.exec(this.options.durationFormat);
208
+
209
+ i = ((self.theDate.getTime() - self.theDate.getMilliseconds()) / 1000) - ((self.initDate.getTime() - self.initDate.getMilliseconds()) / 1000); j = i;
210
+
211
+ dur_comps[0] = parseInt( i / (60*60*24),10); i = i - (dur_comps[0]*60*60*24); // Days
212
+ dur_comps[1] = parseInt( i / (60*60),10); i = i - (dur_comps[1]*60*60); // Hours
213
+ dur_comps[2] = parseInt( i / (60),10); i = i - (dur_comps[2]*60); // Minutes
214
+ dur_comps[3] = i; // Seconds
215
+
216
+ if ( ! exp_format[0].match(/DD/) ) { dur_collapse[0] = true; dur_comps[1] = dur_comps[1] + (dur_comps[0]*24);}
217
+ if ( ! exp_format[0].match(/hh/) ) { dur_collapse[1] = true; dur_comps[2] = dur_comps[2] + (dur_comps[1]*60);}
218
+ if ( ! exp_format[0].match(/ii/) ) { dur_collapse[2] = true; dur_comps[3] = dur_comps[3] + (dur_comps[2]*60);}
219
+
220
+ if ( this.options.debug ) {
221
+ console.log({'format': exp_format, 'collapse': dur_collapse, 'seconds': j, 'parts': dur_comps});
222
+ }
223
+
224
+ format = format.replace('DD', dur_comps[0]);
225
+ format = format.replace('ddd', ((dur_comps[0] > 1)?this.options.durationDays[1]:this.options.durationDays[0]));
226
+ format = format.replace('hh', self._zeroPad(dur_comps[1]));
227
+ format = format.replace('ii', self._zeroPad(dur_comps[2]));
228
+ format = format.replace('ss', self._zeroPad(dur_comps[3]));
229
+ return format;
230
+ } else {
231
+ return this._formatter(self.options.timeOutput, date);
232
+ }
233
+ },
234
+ _makeDate: function (str) {
235
+ // Date Parser
236
+ str = $.trim(str);
237
+ var o = this.options,
238
+ self = this,
239
+ adv = null,
240
+ exp_input = null,
241
+ exp_format = null,
242
+ exp_temp = null,
243
+ date = new Date(),
244
+ dur_collapse = [false,false,false],
245
+ found_date = [date.getFullYear(),date.getMonth(),date.getDate(),date.getHours(),date.getMinutes(),date.getSeconds()],
246
+ i;
247
+
248
+ if ( o.mode === 'durationbox' ) {
249
+ adv = o.durationFormat;
250
+ adv = adv.replace(/ddd/g, '.+?');
251
+ adv = adv.replace(/DD|ss|hh|ii/g, '([0-9Dhis]+)');
252
+ adv = RegExp('^' + adv + '$');
253
+ exp_input = adv.exec(str);
254
+ exp_format = adv.exec(o.durationFormat);
255
+
256
+ if ( o.debug ) { // Legacy debug code - you probably never need this.
257
+ console.log({'info': 'EXPERIMENTAL REGEX MODE ENABLED', 'string': str, 'regex':adv, 'input':exp_input, 'format':exp_format});
258
+ }
259
+
260
+ if ( exp_input === null || exp_input.length !== exp_format.length ) {
261
+ if ( typeof o.defaultPickerValue === "number" && o.defaultPickerValue > 0 ) {
262
+ return new Date(self.initDate.getTime() + (parseInt(o.defaultPickerValue,10) * 1000));
263
+ } else {
264
+ return new Date(self.initDate.getTime());
265
+ }
266
+ } else {
267
+ exp_temp = ((self.initDate.getTime() - self.initDate.getMilliseconds()) / 1000);
268
+ for ( i=0; i<exp_input.length; i++ ) { //0y 1m 2d 3h 4i 5s
269
+ if ( exp_format[i].match(/^DD$/i) ) { exp_temp = exp_temp + (parseInt(exp_input[i],10)*60*60*24); }
270
+ if ( exp_format[i].match(/^hh$/i) ) { exp_temp = exp_temp + (parseInt(exp_input[i],10)*60*60); }
271
+ if ( exp_format[i].match(/^ii$/i) ) { exp_temp = exp_temp + (parseInt(exp_input[i],10)*60); }
272
+ if ( exp_format[i].match(/^ss$/i) ) { exp_temp = exp_temp + (parseInt(exp_input[i],10)); }
273
+ }
274
+ return new Date((exp_temp*1000));
275
+ }
276
+ } else {
277
+ if ( o.mode === 'timebox' || o.mode === 'timeflipbox' ) { adv = o.timeOutput; } else { adv = o.dateFormat; }
278
+
279
+ adv = adv.replace(/dddd|mmmm/g, '(.+?)');
280
+ adv = adv.replace(/ddd|SS/g, '.+?');
281
+ adv = adv.replace(/mmm/g, '(.+?)');
282
+ adv = adv.replace(/ *AA/ig, ' *(.*?)');
283
+ adv = adv.replace(/yyyy|dd|mm|gg|hh|ii/ig, '([0-9yYdDmMgGhHi]+)');
284
+ adv = adv.replace(/ss/g, '([0-9s]+)');
285
+ adv = RegExp('^' + adv + '$');
286
+ exp_input = adv.exec(str);
287
+ if ( o.mode === 'timebox' || o.mode === 'timeflipbox' ) {
288
+ exp_format = adv.exec(o.timeOutput); // If time, use timeOutput as expected format
289
+ } else {
290
+ exp_format = adv.exec(o.dateFormat); // If date, use dateFormat as expected format
291
+ }
292
+
293
+ if ( o.debug ) { // Legacy debug code - you probably never need this.
294
+ console.log({'info': 'EXPERIMENTAL REGEX MODE ENABLED', 'string': str, 'regex':adv, 'input':exp_input, 'format':exp_format});
295
+ }
296
+
297
+ if ( exp_input === null || exp_input.length !== exp_format.length ) {
298
+ if ( o.defaultPickerValue !== false ) {
299
+ if ( $.isArray(o.defaultPickerValue) && o.defaultPickerValue.length === 3 ) {
300
+ if ( o.mode === 'timebox' || o.mode === 'timeflipbox' ) {
301
+ return new Date(found_date[0], found_date[1], found_date[2], o.defaultPickerValue[0], o.defaultPickerValue[1], o.defaultPickerValue[2], 0);
302
+ }
303
+ else {
304
+ return new Date(o.defaultPickerValue[0], o.defaultPickerValue[1], o.defaultPickerValue[2], 0, 0, 0, 0);
305
+ }
306
+ }
307
+ else {
308
+ if ( o.mode === 'timebox' || o.mode === 'timeflipbox' ) {
309
+ exp_temp = o.defaultPickerValue.split(':');
310
+ if ( exp_temp.length === 3 ) {
311
+ date = new Date(found_date[0], found_date[1], found_date[2], parseInt(exp_temp[0],10),parseInt(exp_temp[1],10),parseInt(exp_temp[2],10),0);
312
+ if ( isNaN(date.getDate()) ) { date = new Date(); }
313
+ }
314
+ }
315
+ else {
316
+ exp_temp = o.defaultPickerValue.split('-');
317
+ if ( exp_temp.length === 3 ) {
318
+ date = new Date(parseInt(exp_temp[0],10),parseInt(exp_temp[1],10)-1,parseInt(exp_temp[2],10),0,0,0,0);
319
+ if ( isNaN(date.getDate()) ) { date = new Date(); }
320
+ }
321
+ }
322
+ }
323
+ }
324
+ } else {
325
+ for ( i=0; i<exp_input.length; i++ ) { //0y 1m 2d 3h 4i 5s
326
+ if ( exp_format[i].match(/^gg$/i) ) { found_date[3] = parseInt(exp_input[i],10); }
327
+ if ( exp_format[i].match(/^hh$/i) ) { found_date[3] = parseInt(exp_input[i],10); }
328
+ if ( exp_format[i].match(/^ii$/i) ) { found_date[4] = parseInt(exp_input[i],10); }
329
+ if ( exp_format[i].match(/^ss$/ ) ) { found_date[5] = parseInt(exp_input[i],10); }
330
+ if ( exp_format[i].match(/^dd$/i) ) { found_date[2] = parseInt(exp_input[i],10); }
331
+ if ( exp_format[i].match(/^mm$/i) ) { found_date[1] = parseInt(exp_input[i],10)-1; }
332
+ if ( exp_format[i].match(/^yyyy$/i) ) { found_date[0] = parseInt(exp_input[i],10); }
333
+ if ( exp_format[i].match(/^AA$/i) ) {
334
+ if ( exp_input[i].toLowerCase().charAt(0) === 'a' && found_date[3] === 12 ) {
335
+ found_date[3] = 0;
336
+ } else if ( exp_input[i].toLowerCase().charAt(0) === 'p' && found_date[3] !== 12 ) {
337
+ found_date[3] = found_date[3] + 12;
338
+ }
339
+ }
340
+ if ( exp_format[i].match(/^mmm$/i) ) {
341
+ exp_temp = $.inArray(exp_input[i], o.monthsOfYear);
342
+ if ( exp_temp > -1 ) { found_date[1] = exp_temp; }
343
+ }
344
+ if ( exp_format[i].match(/^mmmm$/i) ) {
345
+ exp_temp = $.inArray(exp_input[i], o.monthsOfYearShort);
346
+ if ( exp_temp > -1 ) { found_date[1] = exp_temp; }
347
+ }
348
+ }
349
+ }
350
+ if ( exp_format[0].match(/G|g|i|s|H|h|A/) ) {
351
+ return new Date(found_date[0], found_date[1], found_date[2], found_date[3], found_date[4], found_date[5], 0);
352
+ } else {
353
+ return new Date(found_date[0], found_date[1], found_date[2], 0, 0, 0, 0); // Normalize time for raw dates
354
+ }
355
+ }
356
+ },
357
+ _checker: function(date) {
358
+ // Return a ISO 8601 BASIC format date (YYYYMMDD) for simple comparisons
359
+ return parseInt(String(date.getFullYear()) + this._zeroPad(date.getMonth()+1) + this._zeroPad(date.getDate()),10);
360
+ },
361
+ _hoover: function(item) {
362
+ // Hover toggle class, for calendar
363
+ $(item).toggleClass('ui-btn-up-'+$(item).attr('data-theme')+' ui-btn-down-'+$(item).attr('data-theme'));
364
+ },
365
+ _offset: function(mode, amount, update) {
366
+ // Compute a date/time offset.
367
+ // update = false to prevent controls refresh
368
+ var self = this,
369
+ o = this.options;
370
+
371
+ if ( typeof(update) === "undefined" ) { update = true; }
372
+ self.input.trigger('datebox', {'method':'offset', 'type':mode, 'amount':amount});
373
+ switch(mode) {
374
+ case 'y':
375
+ self.theDate.setYear(self.theDate.getFullYear() + amount);
376
+ break;
377
+ case 'm':
378
+ console.log(o.rolloverMode);
379
+ if ( o.rolloverMode['m'] || ( self.theDate.getMonth() + amount < 12 && self.theDate.getMonth() + amount > -1 ) ) {
380
+ self.theDate.setMonth(self.theDate.getMonth() + amount);
381
+ }
382
+ break;
383
+ case 'd':
384
+ if ( o.rolloverMode['d'] || (
385
+ self.theDate.getDate() + amount > 0 &&
386
+ self.theDate.getDate() + amount < (self._getLastDate(self.theDate) + 1) ) ) {
387
+ self.theDate.setDate(self.theDate.getDate() + amount);
388
+ }
389
+ break;
390
+ case 'h':
391
+ if ( o.rolloverMode['h'] || (
392
+ self.theDate.getHours() + amount > -1 &&
393
+ self.theDate.getHours() + amount < 24 ) ) {
394
+ self.theDate.setHours(self.theDate.getHours() + amount);
395
+ }
396
+ break;
397
+ case 'i':
398
+ if ( o.rolloverMode['i'] || (
399
+ self.theDate.getMinutes() + amount > -1 &&
400
+ self.theDate.getMinutes() + amount < 60 ) ) {
401
+ self.theDate.setMinutes(self.theDate.getMinutes() + amount);
402
+ }
403
+ break;
404
+ case 's':
405
+ if ( o.rolloverMode['i'] || (
406
+ self.theDate.getSeconds() + amount > -1 &&
407
+ self.theDate.getSeconds() + amount < 60 ) ) {
408
+ self.theDate.setSeconds(self.theDate.getSeconds() + amount);
409
+ }
410
+ break;
411
+ case 'a':
412
+ if ( self.pickerMeri.val() === o.meridiemLetters[0] ) {
413
+ self._offset('h',12,false);
414
+ } else {
415
+ self._offset('h',-12,false);
416
+ }
417
+ break;
418
+ }
419
+ if ( update === true ) { self._update(); }
420
+ },
421
+ _updateduration: function() {
422
+ // Update the duration contols when inputs are directly edited.
423
+ var self = this,
424
+ secs = (self.initDate.getTime() - self.initDate.getMilliseconds()) / 1000;
425
+
426
+ if ( !self._isInt(self.pickerDay.val()) ) { self.pickerDay.val(0); }
427
+ if ( !self._isInt(self.pickerHour.val()) ) { self.pickerHour.val(0); }
428
+ if ( !self._isInt(self.pickerMins.val()) ) { self.pickerMins.val(0); }
429
+ if ( !self._isInt(self.pickerSecs.val()) ) { self.pickerSecs.val(0); }
430
+
431
+ secs = secs + (parseInt(self.pickerDay.val(),10) * 60 * 60 * 24);
432
+ secs = secs + (parseInt(self.pickerHour.val(),10) * 60 * 60);
433
+ secs = secs + (parseInt(self.pickerMins.val(),10) * 60);
434
+ secs = secs + (parseInt(self.pickerSecs.val(),10));
435
+ self.theDate.setTime( secs * 1000 );
436
+ self._update();
437
+ },
438
+ _update: function() {
439
+ // Update the display on date change
440
+ var self = this,
441
+ o = self.options,
442
+ testDate = null,
443
+ i, gridWeek, gridDay, skipThis, thisRow, y, cTheme, inheritDate, thisPRow, tmpVal,
444
+ interval = {'d': 60*60*24, 'h': 60*60, 'i': 60, 's':1},
445
+ calmode = {};
446
+
447
+ self.input.trigger('datebox', {'method':'refresh'});
448
+ /* BEGIN:DURATIONBOX */
449
+ if ( o.mode === 'durationbox' ) {
450
+ i = ((self.theDate.getTime() - self.theDate.getMilliseconds()) / 1000) - ((self.initDate.getTime() - self.initDate.getMilliseconds()) / 1000);
451
+ if ( i<0 ) { i = 0; self.theDate.setTime(self.initDate.getTime()); }
452
+
453
+ /* DAYS */
454
+ y = parseInt( i / interval['d'],10);
455
+ i = i - ( y * interval['d'] );
456
+ self.pickerDay.val(y);
457
+
458
+ /* HOURS */
459
+ y = parseInt( i / interval['h'], 10);
460
+ i = i - ( y * interval['h'] );
461
+ self.pickerHour.val(y);
462
+
463
+ /* MINS AND SECS */
464
+ y = parseInt( i / interval['i'], 10);
465
+ i = i - ( y * interval['i']);
466
+ self.pickerMins.val(y);
467
+ self.pickerSecs.val(parseInt(i,10));
468
+ }
469
+ /* END:DURATIONBOX */
470
+ /* BEGIN:TIMEBOX */
471
+ if ( o.mode === 'timebox' ) {
472
+ if ( o.minuteStep !== 1 ) {
473
+ i = self.theDate.getMinutes() % o.minuteStep;
474
+ if ( i !== 0 ) { self.theDate.setMinutes(self.theDate.getMinutes() - i); }
475
+ }
476
+ self.pickerMins.val(self._zeroPad(self.theDate.getMinutes()));
477
+ if ( o.timeFormat === 12 ) { // Handle meridiems
478
+ if ( self.theDate.getHours() > 11 ) {
479
+ self.pickerMeri.val(o.meridiemLetters[1]);
480
+ if ( self.theDate.getHours() === 12 ) {
481
+ self.pickerHour.val(12);
482
+ } else {
483
+ self.pickerHour.val(self.theDate.getHours() - 12);
484
+ }
485
+ } else {
486
+ self.pickerMeri.val(o.meridiemLetters[0]);
487
+ if ( self.theDate.getHours() === 0 ) {
488
+ self.pickerHour.val(12);
489
+ } else {
490
+ self.pickerHour.val(self.theDate.getHours());
491
+ }
492
+ }
493
+ } else {
494
+ self.pickerHour.val(self.theDate.getHours());
495
+ }
496
+ }
497
+ /* END:TIMEBOX */
498
+ /* BEGIN:FLIPBOX */
499
+ if ( o.mode === 'flipbox' || o.mode === 'timeflipbox' ) {
500
+ if ( o.afterToday !== false ) {
501
+ testDate = new Date();
502
+ if ( self.theDate < testDate ) { self.theDate = testDate; }
503
+ }
504
+ if ( o.maxDays !== false ) {
505
+ testDate = new Date();
506
+ testDate.setDate(testDate.getDate() + o.maxDays);
507
+ if ( self.theDate > testDate ) { self.theDate = testDate; }
508
+ }
509
+ if ( o.minDays !== false ) {
510
+ testDate = new Date();
511
+ testDate.setDate(testDate.getDate() - o.minDays);
512
+ if ( self.theDate < testDate ) { self.theDate = testDate; }
513
+ }
514
+ if ( o.maxYear !== false ) {
515
+ testDate = new Date(o.maxYear, 0, 1);
516
+ testDate.setDate(testDate.getDate() - 1);
517
+ if ( self.theDate > testDate ) { self.theDate = testDate; }
518
+ }
519
+ if ( o.minYear !== false ) {
520
+ testDate = new Date(o.minYear, 0, 1);
521
+ if ( self.theDate < testDate ) { self.theDate = testDate; }
522
+ }
523
+
524
+ inheritDate = self._makeDate(self.input.val());
525
+
526
+ self.controlsHeader.html( self._formatHeader(self.theDate) );
527
+
528
+ for ( y=0; y<o.fieldsOrder.length; y++ ) {
529
+ tmpVal = true;
530
+ switch (o.fieldsOrder[y]) {
531
+ case 'y':
532
+ thisRow = self.pickerYar.find('ul');
533
+ thisRow.html('');
534
+ for ( i=-15; i<16; i++ ) {
535
+ cTheme = ((inheritDate.getFullYear()===(self.theDate.getFullYear() + i))?o.pickPageHighButtonTheme:o.pickPageFlipButtonTheme);
536
+ if ( i === 0 ) { cTheme = o.pickPageButtonTheme; }
537
+ $("<li>", { 'class' : 'ui-body-'+cTheme, 'style':''+((tmpVal===true)?'margin-top: -453px':'') })
538
+ .html("<span>"+(self.theDate.getFullYear() + i)+"</span>")
539
+ .attr('data-offset', i)
540
+ .attr('data-theme', cTheme)
541
+ .appendTo(thisRow);
542
+ if ( tmpVal === true ) { tmpVal = false; }
543
+ }
544
+ break;
545
+ case 'm':
546
+ thisRow = self.pickerMon.find('ul');
547
+ thisRow.html('');
548
+ for ( i=-12; i<13; i++ ) {
549
+ testDate = new Date(self.theDate.getFullYear(), self.theDate.getMonth(), 1);
550
+ testDate.setMonth(testDate.getMonth()+i);
551
+ cTheme = ( inheritDate.getMonth() === testDate.getMonth() && inheritDate.getYear() === testDate.getYear() ) ? o.pickPageHighButtonTheme : o.pickPageFlipButtonTheme;
552
+ if ( i === 0 ) { cTheme = o.pickPageButtonTheme; }
553
+ $("<li>", { 'class' : 'ui-body-'+cTheme, 'style':''+((tmpVal===true)?'margin-top: -357px':'') })
554
+ .attr('data-offset',i)
555
+ .attr('data-theme', cTheme)
556
+ .html("<span>"+o.monthsOfYearShort[testDate.getMonth()]+"</span>")
557
+ .appendTo(thisRow);
558
+ if ( tmpVal === true ) { tmpVal = false; }
559
+ }
560
+ break;
561
+ case 'd':
562
+ thisRow = self.pickerDay.find('ul');
563
+ thisRow.html('');
564
+ for ( i=-15; i<16; i++ ) {
565
+ testDate = new Date(self.theDate.getFullYear(), self.theDate.getMonth(), self.theDate.getDate());
566
+ testDate.setDate(testDate.getDate()+i);
567
+ cTheme = ( inheritDate.getDate() === testDate.getDate() && inheritDate.getMonth() === testDate.getMonth() && inheritDate.getYear() === testDate.getYear() ) ? o.pickPageHighButtonTheme : o.pickPageFlipButtonTheme;
568
+ if ( i === 0 ) { cTheme = o.pickPageButtonTheme; }
569
+ $("<li>", { 'class' : 'ui-body-'+cTheme, 'style':''+((tmpVal===true)?'margin-top: -453px':'') })
570
+ .attr('data-offset', i)
571
+ .attr('data-theme', cTheme)
572
+ .html("<span>"+testDate.getDate()+"</span>")
573
+ .appendTo(thisRow);
574
+ if ( tmpVal === true ) { tmpVal = false; }
575
+ }
576
+ break;
577
+ case 'h':
578
+ thisRow = self.pickerHour.find('ul');
579
+ thisRow.html('');
580
+ for ( i=-12; i<13; i++ ) {
581
+ testDate = new Date(self.theDate.getFullYear(), self.theDate.getMonth(), self.theDate.getDate(), self.theDate.getHours());
582
+ testDate.setHours(testDate.getHours()+i);
583
+ cTheme = ( i === 0 ) ? o.pickPageButtonTheme : o.pickPageFlipButtonTheme;
584
+ $("<li>", { 'class' : 'ui-body-'+cTheme, 'style':''+((tmpVal===true)?'margin-top: -357px':'') })
585
+ .attr('data-offset',i)
586
+ .attr('data-theme', cTheme)
587
+ .html("<span>"+( ( o.timeFormat === 12 ) ? ( ( testDate.getHours() === 0 ) ? '12' : ( ( testDate.getHours() < 12 ) ? testDate.getHours() : ( ( testDate.getHours() === 12 ) ? '12' : (testDate.getHours()-12) ) ) ) : testDate.getHours() )+"</span>")
588
+ .appendTo(thisRow);
589
+ if ( tmpVal === true ) { tmpVal = false; }
590
+ }
591
+ break;
592
+ case 'i':
593
+ thisRow = self.pickerMins.find('ul');
594
+ thisRow.html('');
595
+ for ( i=-30; i<31; i++ ) {
596
+ if ( o.minuteStep > 1 ) { self.theDate.setMinutes(self.theDate.getMinutes() - (self.theDate.getMinutes() % o.minuteStep)); }
597
+ testDate = new Date(self.theDate.getFullYear(), self.theDate.getMonth(), self.theDate.getDate(), self.theDate.getHours(), self.theDate.getMinutes());
598
+ testDate.setMinutes(testDate.getMinutes()+(i*o.minuteStep));
599
+ cTheme = ( i === 0 ) ? o.pickPageButtonTheme : o.pickPageFlipButtonTheme;
600
+ $("<li>", { 'class' : 'ui-body-'+cTheme, 'style':''+((tmpVal===true)?'margin-top: -933px':'') })
601
+ .attr('data-offset',(i*o.minuteStep))
602
+ .attr('data-theme', cTheme)
603
+ .html("<span>"+self._zeroPad(testDate.getMinutes())+"</span>")
604
+ .appendTo(thisRow);
605
+ if ( tmpVal === true ) { tmpVal = false; }
606
+ }
607
+ break;
608
+ case 'a':
609
+ thisRow = self.pickerMeri.find('ul');
610
+ thisRow.html('');
611
+ if ( self.theDate.getHours() > 11 ) {
612
+ tmpVal = '-65';
613
+ cTheme = [o.pickPageFlipButtonTheme, o.pickPageButtonTheme]
614
+ } else {
615
+ tmpVal = '-33';
616
+ cTheme = [o.pickPageButtonTheme, o.pickPageFlipButtonTheme]
617
+ }
618
+ $("<li>").appendTo(thisRow).clone().appendTo(thisRow);
619
+ $("<li>", { 'class' : 'ui-body-'+cTheme[0], 'style':'margin-top: '+tmpVal+'px' })
620
+ .attr('data-offset',1)
621
+ .attr('data-theme', cTheme[0])
622
+ .html("<span>"+o.meridiemLetters[0]+"</span>")
623
+ .appendTo(thisRow);
624
+ $("<li>", { 'class' : 'ui-body-'+cTheme[1] })
625
+ .attr('data-offset',1)
626
+ .attr('data-theme', cTheme[1])
627
+ .html("<span>"+o.meridiemLetters[1]+"</span>")
628
+ .appendTo(thisRow);
629
+ $("<li>").appendTo(thisRow).clone().appendTo(thisRow);
630
+ break;
631
+ }
632
+ }
633
+ }
634
+ /* END:FLIPBOX */
635
+ /* BEGIN:SLIDEBOX */
636
+ if ( o.mode === 'slidebox' ) {
637
+ if ( o.afterToday !== false ) {
638
+ testDate = new Date();
639
+ if ( self.theDate < testDate ) { self.theDate = testDate; }
640
+ }
641
+ if ( o.maxDays !== false ) {
642
+ testDate = new Date();
643
+ testDate.setDate(testDate.getDate() + o.maxDays);
644
+ if ( self.theDate > testDate ) { self.theDate = testDate; }
645
+ }
646
+ if ( o.minDays !== false ) {
647
+ testDate = new Date();
648
+ testDate.setDate(testDate.getDate() - o.minDays);
649
+ if ( self.theDate < testDate ) { self.theDate = testDate; }
650
+ }
651
+ if ( o.maxYear !== false ) {
652
+ testDate = new Date(o.maxYear, 0, 1);
653
+ testDate.setDate(testDate.getDate() - 1);
654
+ if ( self.theDate > testDate ) { self.theDate = testDate; }
655
+ }
656
+ if ( o.minYear !== false ) {
657
+ testDate = new Date(o.minYear, 0, 1);
658
+ if ( self.theDate < testDate ) { self.theDate = testDate; }
659
+ }
660
+
661
+ inheritDate = self._makeDate(self.input.val());
662
+
663
+ self.controlsHeader.html( self._formatHeader(self.theDate) );
664
+ self.controlsInput.html('');
665
+
666
+ for ( y=0; y<o.fieldsOrder.length; y++ ) {
667
+ thisPRow = $("<div>", {'data-rowtype': o.fieldsOrder[y]});
668
+
669
+ if ( o.wheelExists ) {
670
+ thisPRow.bind('mousewheel', function(e,d) {
671
+ e.preventDefault();
672
+ self._offset($(this).attr('data-rowtype'), ((d>0)?1:-1));
673
+ });
674
+ }
675
+
676
+ thisRow = $("<div>", {'class': 'ui-datebox-sliderow-int', 'data-rowtype': o.fieldsOrder[y]}).appendTo(thisPRow);
677
+
678
+ if ( o.swipeEnabled ) {
679
+ thisRow
680
+ .bind(self.START_DRAG, function(e) {
681
+ if ( !self.dragMove ) {
682
+ self.dragMove = true;
683
+ self.dragTarget = $(this);
684
+ self.dragPos = parseInt(self.dragTarget.css('marginLeft').replace(/px/i, ''),10);
685
+ self.dragStart = self.touch ? e.originalEvent.changedTouches[0].pageX : e.pageX;
686
+ self.dragEnd = false;
687
+ e.stopPropagation();
688
+ e.preventDefault();
689
+ }
690
+ });
691
+ }
692
+ switch (o.fieldsOrder[y]) {
693
+ case 'y':
694
+ thisPRow.addClass('ui-datebox-sliderow-ym');
695
+ thisRow.css('marginLeft', '-333px');
696
+ for ( i=-5; i<6; i++ ) {
697
+ cTheme = ((inheritDate.getFullYear()===(self.theDate.getFullYear() + i))?o.pickPageHighButtonTheme:o.pickPageSlideButtonTheme);
698
+ if ( i === 0 ) { cTheme = o.pickPageButtonTheme; }
699
+ $("<div>", { 'class' : 'ui-datebox-slideyear ui-corner-all ui-btn-up-'+cTheme })
700
+ .text(self.theDate.getFullYear() + i)
701
+ .attr('data-offset', i)
702
+ .attr('data-theme', cTheme)
703
+ .bind('vmouseover vmouseout', function() { self._hoover(this); })
704
+ .bind('vclick', function(e) { e.preventDefault(); self._offset('y', parseInt($(this).attr('data-offset'),10)); })
705
+ .appendTo(thisRow);
706
+ }
707
+ break;
708
+ case 'm':
709
+ thisPRow.addClass('ui-datebox-sliderow-ym');
710
+ thisRow.css('marginLeft', '-204px');
711
+ for ( i=-6; i<7; i++ ) {
712
+ testDate = new Date(self.theDate.getFullYear(), self.theDate.getMonth(), 1);
713
+ testDate.setMonth(testDate.getMonth()+i);
714
+ cTheme = ( inheritDate.getMonth() === testDate.getMonth() && inheritDate.getYear() === testDate.getYear() ) ? o.pickPageHighButtonTheme : o.pickPageSlideButtonTheme;
715
+ if ( i === 0 ) { cTheme = o.pickPageButtonTheme; }
716
+ $("<div>", { 'class' : 'ui-datebox-slidemonth ui-corner-all ui-btn-up-'+cTheme })
717
+ .attr('data-offset',i)
718
+ .attr('data-theme', cTheme)
719
+ .text(o.monthsOfYearShort[testDate.getMonth()])
720
+ .bind('vmouseover vmouseout', function() { self._hoover(this); })
721
+ .bind('vclick', function(e) { e.preventDefault(); self._offset('m', parseInt($(this).attr('data-offset'),10)); })
722
+ .appendTo(thisRow);
723
+ }
724
+ break;
725
+ case 'd':
726
+ thisPRow.addClass('ui-datebox-sliderow-d');
727
+ thisRow.css('marginLeft', '-386px');
728
+ for ( i=-15; i<16; i++ ) {
729
+ testDate = new Date(self.theDate.getFullYear(), self.theDate.getMonth(), self.theDate.getDate());
730
+ testDate.setDate(testDate.getDate()+i);
731
+ cTheme = ( inheritDate.getDate() === testDate.getDate() && inheritDate.getMonth() === testDate.getMonth() && inheritDate.getYear() === testDate.getYear() ) ? o.pickPageHighButtonTheme : o.pickPageSlideButtonTheme;
732
+ if ( i === 0 ) { cTheme = o.pickPageButtonTheme; }
733
+
734
+ $("<div>", { 'class' : 'ui-datebox-slideday ui-corner-all ui-btn-up-'+cTheme })
735
+ .attr('data-offset', i)
736
+ .attr('data-theme', cTheme)
737
+ .html(testDate.getDate() + '<br /><span class="ui-datebox-slidewday">' + o.daysOfWeekShort[testDate.getDay()] + '</span>')
738
+ .bind('vmouseover vmouseout', function() { self._hoover(this); })
739
+ .bind('vclick', function(e) { e.preventDefault(); self._offset('d', parseInt($(this).attr('data-offset'),10)); })
740
+ .appendTo(thisRow);
741
+ }
742
+ break;
743
+ case 'h':
744
+ thisPRow.addClass('ui-datebox-sliderow-hi');
745
+ thisRow.css('marginLeft', '-284px');
746
+ for ( i=-12; i<13; i++ ) {
747
+ testDate = new Date(self.theDate.getFullYear(), self.theDate.getMonth(), self.theDate.getDate(), self.theDate.getHours());
748
+ testDate.setHours(testDate.getHours()+i);
749
+ cTheme = ( i === 0 ) ? o.pickPageButtonTheme : o.pickPageSlideButtonTheme;
750
+ $("<div>", { 'class' : 'ui-datebox-slidehour ui-corner-all ui-btn-up-'+cTheme })
751
+ .attr('data-offset',i)
752
+ .attr('data-theme', cTheme)
753
+ .html(( ( o.timeFormat === 12 ) ? ( ( testDate.getHours() === 0 ) ? '12<span class="ui-datebox-slidewday">AM</span>' : ( ( testDate.getHours() < 12 ) ? testDate.getHours() + '<span class="ui-datebox-slidewday">AM</span>' : ( ( testDate.getHours() === 12 ) ? '12<span class="ui-datebox-slidewday">PM</span>' : (testDate.getHours()-12) + '<span class="ui-datebox-slidewday">PM</span>') ) ) : testDate.getHours() ))
754
+ .bind('vmouseover vmouseout', function() { self._hoover(this); })
755
+ .bind('vclick', function(e) { e.preventDefault(); self._offset('h', parseInt($(this).attr('data-offset'),10)); })
756
+ .appendTo(thisRow);
757
+ }
758
+ break;
759
+ case 'i':
760
+ thisPRow.addClass('ui-datebox-sliderow-hi');
761
+ thisRow.css('marginLeft', '-896px');
762
+ for ( i=-30; i<31; i++ ) {
763
+ testDate = new Date(self.theDate.getFullYear(), self.theDate.getMonth(), self.theDate.getDate(), self.theDate.getHours(), self.theDate.getMinutes());
764
+ testDate.setMinutes(testDate.getMinutes()+i);
765
+ cTheme = ( i === 0 ) ? o.pickPageButtonTheme : o.pickPageSlideButtonTheme;
766
+ $("<div>", { 'class' : 'ui-datebox-slidemins ui-corner-all ui-btn-up-'+cTheme })
767
+ .attr('data-offset',i)
768
+ .attr('data-theme', cTheme)
769
+ .text(self._zeroPad(testDate.getMinutes()))
770
+ .bind('vmouseover vmouseout', function() { self._hoover(this); })
771
+ .bind('vclick', function(e) { e.preventDefault(); self._offset('i', parseInt($(this).attr('data-offset'),10)); })
772
+ .appendTo(thisRow);
773
+ }
774
+ break;
775
+ }
776
+ thisPRow.appendTo(self.controlsInput);
777
+ }
778
+ }
779
+ /* END:SLIDEBOX */
780
+ /* BEGIN:DATEBOX */
781
+ if ( o.mode === 'datebox' ) {
782
+ if ( o.afterToday !== false ) {
783
+ testDate = new Date();
784
+ if ( self.theDate < testDate ) { self.theDate = testDate; }
785
+ }
786
+ if ( o.beforeToday !== false ) {
787
+ testDate = new Date();
788
+ if ( self.theDate > testDate ) { self.theDate = testDate; }
789
+ }
790
+ if ( o.maxDays !== false ) {
791
+ testDate = new Date();
792
+ testDate.setDate(testDate.getDate() + o.maxDays);
793
+ if ( self.theDate > testDate ) { self.theDate = testDate; }
794
+ }
795
+ if ( o.minDays !== false ) {
796
+ testDate = new Date();
797
+ testDate.setDate(testDate.getDate() - o.minDays);
798
+ if ( self.theDate < testDate ) { self.theDate = testDate; }
799
+ }
800
+ if ( o.maxYear !== false ) {
801
+ testDate = new Date(o.maxYear, 0, 1);
802
+ testDate.setDate(testDate.getDate() - 1);
803
+ if ( self.theDate > testDate ) { self.theDate = testDate; }
804
+ }
805
+ if ( o.minYear !== false ) {
806
+ testDate = new Date(o.minYear, 0, 1);
807
+ if ( self.theDate < testDate ) { self.theDate = testDate; }
808
+ }
809
+
810
+ self.controlsHeader.html( self._formatHeader(self.theDate) );
811
+ self.pickerMon.val(self.theDate.getMonth() + 1);
812
+ self.pickerDay.val(self.theDate.getDate());
813
+ self.pickerYar.val(self.theDate.getFullYear());
814
+ }
815
+ /* END:DATEBOX */
816
+ /* BEGIN:CALBOX */
817
+ if ( o.mode === 'calbox' ) { // Meat and potatos - make the calendar grid.
818
+ self.controlsInput.text( o.monthsOfYear[self.theDate.getMonth()] + " " + self.theDate.getFullYear() );
819
+ self.controlsSet.html('');
820
+
821
+ calmode = {'today': -1, 'highlightDay': -1, 'presetDay': -1, 'nexttoday': 1,
822
+ 'thisDate': new Date(), 'maxDate': new Date(), 'minDate': new Date(),
823
+ 'currentMonth': false, 'weekMode': 0, 'weekDays': null, 'thisTheme': o.pickPageButtonTheme };
824
+ calmode.start = self._getFirstDay(self.theDate);
825
+ calmode.end = self._getLastDate(self.theDate);
826
+ calmode.lastend = self._getLastDateBefore(self.theDate);
827
+ calmode.presetDate = self._makeDate(self.input.val());
828
+
829
+ if ( o.calStartDay > 0 ) {
830
+ calmode.start = calmode.start - o.calStartDay;
831
+ if ( calmode.start < 0 ) { calmode.start = calmode.start + 7; }
832
+ }
833
+
834
+ calmode.prevtoday = calmode.lastend - (calmode.start - 1);
835
+ calmode.checkDates = ( o.afterToday !== false || o.beforeToday !== false || o.notToday !== false || o.maxDays !== false || o.minDays !== false || o.blackDates !== false || o.blackDays !== false );
836
+
837
+ if ( calmode.thisDate.getMonth() === self.theDate.getMonth() && calmode.thisDate.getFullYear() === self.theDate.getFullYear() ) { calmode.currentMonth = true; calmode.highlightDay = calmode.thisDate.getDate(); }
838
+ if ( self._checker(calmode.presetDate) === self._checker(self.theDate) ) { calmode.presetDay = calmode.presetDate.getDate(); }
839
+
840
+ self.calNoPrev = false; self.calNoNext = false;
841
+
842
+ if ( o.afterToday === true &&
843
+ ( calmode.currentMonth === true || ( calmode.thisDate.getMonth() >= self.theDate.getMonth() && self.theDate.getFullYear() === calmode.thisDate.getFullYear() ) ) ) {
844
+ self.calNoPrev = true; }
845
+ if ( o.beforeToday === true &&
846
+ ( calmode.currentMonth === true || ( calmode.thisDate.getMonth() <= self.theDate.getMonth() && self.theDate.getFullYear() === calmode.thisDate.getFullYear() ) ) ) {
847
+ self.calNoNext = true; }
848
+
849
+ if ( o.minDays !== false ) {
850
+ calmode.minDate.setDate(calmode.minDate.getDate() - o.minDays);
851
+ if ( self.theDate.getFullYear() === calmode.minDate.getFullYear() && self.theDate.getMonth() <= calmode.minDate.getMonth() ) { self.calNoPrev = true;}
852
+ }
853
+ if ( o.maxDays !== false ) {
854
+ calmode.maxDate.setDate(calmode.maxDate.getDate() + o.maxDays);
855
+ if ( self.theDate.getFullYear() === calmode.maxDate.getFullYear() && self.theDate.getMonth() >= calmode.maxDate.getMonth() ) { self.calNoNext = true;}
856
+ }
857
+
858
+ if ( o.calShowDays ) {
859
+ if ( o.daysOfWeekShort.length < 8 ) { o.daysOfWeekShort = o.daysOfWeekShort.concat(o.daysOfWeekShort); }
860
+ calmode.weekDays = $("<div>", {'class':'ui-datebox-gridrow'}).appendTo(self.controlsSet);
861
+ for ( i=0; i<=6;i++ ) {
862
+ $("<div>"+o.daysOfWeekShort[i+o.calStartDay]+"</div>").addClass('ui-datebox-griddate ui-datebox-griddate-empty ui-datebox-griddate-label').appendTo(calmode.weekDays);
863
+ }
864
+ }
865
+
866
+ for ( gridWeek=0; gridWeek<=5; gridWeek++ ) {
867
+ if ( gridWeek === 0 || ( gridWeek > 0 && (calmode.today > 0 && calmode.today <= calmode.end) ) ) {
868
+ thisRow = $("<div>", {'class': 'ui-datebox-gridrow'}).appendTo(self.controlsSet);
869
+ for ( gridDay=0; gridDay<=6; gridDay++) {
870
+ if ( gridDay === 0 ) { calmode.weekMode = ( calmode.today < 1 ) ? (calmode.prevtoday - calmode.lastend + o.calWeekModeFirstDay) : (calmode.today + o.calWeekModeFirstDay); }
871
+ if ( gridDay === calmode.start && gridWeek === 0 ) { calmode.today = 1; }
872
+ if ( calmode.today > calmode.end ) { calmode.today = -1; }
873
+ if ( calmode.today < 1 ) {
874
+ if ( o.calShowOnlyMonth ) {
875
+ $("<div>", {'class': 'ui-datebox-griddate ui-datebox-griddate-empty'}).appendTo(thisRow);
876
+ } else {
877
+ if (
878
+ ( o.blackDays !== false && $.inArray(gridDay, o.blackDays) > -1 ) ||
879
+ ( o.blackDates !== false && $.inArray(self._isoDate(self.theDate.getFullYear(), (self.theDate.getMonth()), calmode.prevtoday), o.blackDates) > -1 ) ||
880
+ ( o.blackDates !== false && $.inArray(self._isoDate(self.theDate.getFullYear(), (self.theDate.getMonth()+2), calmode.nexttoday), o.blackDates) > -1 ) ) {
881
+ skipThis = true;
882
+ } else { skipThis = false; }
883
+
884
+ if ( gridWeek === 0 ) {
885
+ $("<div>"+String(calmode.prevtoday)+"</div>")
886
+ .addClass('ui-datebox-griddate ui-datebox-griddate-empty').appendTo(thisRow)
887
+ .attr('data-date', ((o.calWeekMode)?(calmode.weekMode+calmode.lastend):calmode.prevtoday))
888
+ .bind((!skipThis)?'vclick':'error', function(e) {
889
+ e.preventDefault();
890
+ if ( !self.calNoPrev ) {
891
+ self.theDate.setMonth(self.theDate.getMonth() - 1);
892
+ self.theDate.setDate($(this).attr('data-date'));
893
+ self.input.trigger('datebox', {'method':'set', 'value':self._formatDate(self.theDate)});
894
+ self.input.trigger('datebox', {'method':'close'});
895
+ }
896
+ });
897
+ calmode.prevtoday++;
898
+ } else {
899
+ $("<div>"+String(calmode.nexttoday)+"</div>")
900
+ .addClass('ui-datebox-griddate ui-datebox-griddate-empty').appendTo(thisRow)
901
+ .attr('data-date', ((o.calWeekMode)?calmode.weekMode:calmode.nexttoday))
902
+ .bind((!skipThis)?'vclick':'error', function(e) {
903
+ e.preventDefault();
904
+ if ( !self.calNoNext ) {
905
+ self.theDate.setDate($(this).attr('data-date'));
906
+ if ( !o.calWeekMode ) { self.theDate.setMonth(self.theDate.getMonth() + 1); }
907
+ self.input.trigger('datebox', {'method':'set', 'value':self._formatDate(self.theDate)});
908
+ self.input.trigger('datebox', {'method':'close'});
909
+ }
910
+ });
911
+ calmode.nexttoday++;
912
+ }
913
+ }
914
+ } else {
915
+ skipThis = false;
916
+ if ( calmode.checkDates ) {
917
+ if ( o.afterToday && self._checker(calmode.thisDate) > (self._checker(self.theDate)+calmode.today-self.theDate.getDate()) ) {
918
+ skipThis = true;
919
+ }
920
+ if ( !skipThis && o.beforeToday && self._checker(calmode.thisDate) < (self._checker(self.theDate)+calmode.today-self.theDate.getDate()) ) {
921
+ skipThis = true;
922
+ }
923
+ if ( !skipThis && o.notToday && calmode.today === calmode.highlightDay ) {
924
+ skipThis = true;
925
+ }
926
+ if ( !skipThis && o.maxDays !== false && self._checker(calmode.maxDate) < (self._checker(self.theDate)+calmode.today-self.theDate.getDate()) ) {
927
+ skipThis = true;
928
+ }
929
+ if ( !skipThis && o.minDays !== false && self._checker(calmode.minDate) > (self._checker(self.theDate)+calmode.today-self.theDate.getDate()) ) {
930
+ skipThis = true;
931
+ }
932
+ if ( !skipThis && ( o.blackDays !== false || o.blackDates !== false ) ) { // Blacklists
933
+ if (
934
+ ( $.inArray(gridDay, o.blackDays) > -1 ) ||
935
+ ( $.inArray(self._isoDate(self.theDate.getFullYear(), self.theDate.getMonth()+1, calmode.today), o.blackDates) > -1 ) ) {
936
+ skipThis = true;
937
+ }
938
+ }
939
+ }
940
+
941
+ if ( o.calHighPicked && calmode.today === calmode.presetDay ) {
942
+ calmode.thisTheme = o.pickPageHighButtonTheme;
943
+ } else if ( o.calHighToday && calmode.today === calmode.highlightDay ) {
944
+ calmode.thisTheme = o.pickPageTodayButtonTheme;
945
+ } else if ( $.isArray(o.highDates) && ($.inArray(self._isoDate(self.theDate.getFullYear(), self.theDate.getMonth()+1, calmode.today), o.highDates) > -1 ) ) {
946
+ calmode.thisTheme = o.pickPageOHighButtonTheme;
947
+ } else if ( $.isArray(o.highDays) && $.inArray(gridDay, o.highDays) > -1 ) {
948
+ calmode.thisTheme = o.pickPageODHighButtonTheme;
949
+ } else {
950
+ calmode.thisTheme = o.pickPageButtonTheme;
951
+ }
952
+
953
+ $("<div>"+String(calmode.today)+"</div>")
954
+ .addClass('ui-datebox-griddate ui-corner-all')
955
+ .attr('data-date', ((o.calWeekMode)?calmode.weekMode:calmode.today))
956
+ .attr('data-theme', calmode.thisTheme)
957
+ .appendTo(thisRow)
958
+ .addClass('ui-btn-up-'+calmode.thisTheme)
959
+ .bind('vmouseover vmouseout', function() {
960
+ if ( o.calWeekMode !== false && o.calWeekModeHighlight === true ) {
961
+ $(this).parent().find('div').each(function() { self._hoover(this); });
962
+ } else { self._hoover(this); }
963
+ })
964
+ .bind((!skipThis)?'vclick':'error', function(e) {
965
+ e.preventDefault();
966
+ self.theDate.setDate($(this).attr('data-date'));
967
+ self.input.trigger('datebox', {'method':'set', 'value':self._formatDate(self.theDate)});
968
+ self.input.trigger('datebox', {'method':'close'});
969
+ })
970
+ .css((skipThis)?'color':'nocolor', o.disabledDayColor);
971
+
972
+ calmode.today++;
973
+ }
974
+ }
975
+ }
976
+ }
977
+ }
978
+ /* END:CALBOX */
979
+ },
980
+ _create: function() {
981
+ // Create the widget, called automatically by widget system
982
+ var self = this,
983
+ o = $.extend(this.options, this.element.data('options')),
984
+ input = this.element,
985
+ focusedEl = input.wrap('<div class="ui-input-datebox ui-shadow-inset ui-corner-all ui-body-'+ o.theme +'"></div>').parent(),
986
+ theDate = new Date(), // Internal date object, used for all operations
987
+ initDate = new Date(theDate.getTime()), // Initilization time - used for duration
988
+ dialogTitle = ((o.titleDialogLabel === false)?((o.mode==='timebox')?o.titleTimeDialogLabel:o.titleDateDialogLabel):o.titleDialogLabel),
989
+
990
+ // This is the button that is added to the original input
991
+ openbutton = $('<a href="#" class="ui-input-clear" title="date picker">date picker</a>')
992
+ .bind('vclick', function (e) {
993
+ e.preventDefault();
994
+ if ( !o.disabled ) { self.input.trigger('datebox', {'method': 'open'}); }
995
+ setTimeout( function() { $(e.target).closest("a").removeClass($.mobile.activeBtnClass); }, 300);
996
+ })
997
+ .appendTo(focusedEl).buttonMarkup({icon: 'grid', iconpos: 'notext', corners:true, shadow:true})
998
+ .css({'vertical-align': 'middle', 'float': 'right'}),
999
+ thisPage = input.closest('.ui-page'),
1000
+ pickPage = $("<div data-role='dialog' class='ui-dialog-datebox' data-theme='" + o.pickPageTheme + "' >" +
1001
+ "<div data-role='header' data-backbtn='false' data-theme='a'>" +
1002
+ "<div class='ui-title'>" + dialogTitle + "</div>"+
1003
+ "</div>"+
1004
+ "<div data-role='content'></div>"+
1005
+ "</div>")
1006
+ .appendTo( $.mobile.pageContainer )
1007
+ .page().css('minHeight', '0px').css('zIndex', o.zindex).addClass('pop'),
1008
+ pickPageContent = pickPage.find( ".ui-content" ),
1009
+ touch = ('ontouchstart' in window),
1010
+ START_EVENT = touch ? 'touchstart' : 'mousedown',
1011
+ MOVE_EVENT = touch ? 'touchmove' : 'mousemove',
1012
+ END_EVENT = touch ? 'touchend' : 'mouseup',
1013
+ dragMove = false,
1014
+ dragStart = false,
1015
+ dragEnd = false,
1016
+ dragPos = false,
1017
+ dragTarget = false,
1018
+ dragThisDelta = 0;
1019
+
1020
+ if(o.defaultPickerValue===false && o.defaultDate!==false){
1021
+ o.defaultPickerValue = o.defaultDate;
1022
+ }
1023
+
1024
+ $('label[for='+input.attr('id')+']').addClass('ui-input-text').css('verticalAlign', 'middle');
1025
+
1026
+ /* BUILD:MODE */
1027
+
1028
+ if ( o.mode === "timeflipbox" ) { // No header in time flipbox.
1029
+ o.headerFormat = ' ';
1030
+ }
1031
+
1032
+ // Select the appropriate output format if not otherwise specified
1033
+ if ( o.timeOutput === false ) {
1034
+ o.timeOutput = o.timeFormats[o.timeFormat];
1035
+ }
1036
+ if ( o.fieldsOrder === false ) {
1037
+ switch (o.mode) {
1038
+ case 'timebox':
1039
+ case 'timeflipbox':
1040
+ o.fieldsOrder = o.timeFieldOrder;
1041
+ break;
1042
+ case 'slidebox':
1043
+ o.fieldsOrder = o.slideFieldOrder;
1044
+ break;
1045
+ default:
1046
+ o.fieldsOrder = o.dateFieldOrder;
1047
+ }
1048
+ }
1049
+
1050
+ // For focus mode, disable button, and bind click of input element and it's parent
1051
+ if ( o.noButtonFocusMode || o.useInline || o.noButton ) { openbutton.hide(); }
1052
+
1053
+ focusedEl.bind('vclick', function() {
1054
+ if ( !o.disabled && o.noButtonFocusMode ) { input.trigger('datebox', {'method': 'open'}); }
1055
+ });
1056
+
1057
+
1058
+ input
1059
+ .removeClass('ui-corner-all ui-shadow-inset')
1060
+ .focus(function(){
1061
+ if ( ! o.disabled ) {
1062
+ focusedEl.addClass('ui-focus');
1063
+ if ( o.noButtonFocusMode ) { focusedEl.addClass('ui-focus'); input.trigger('datebox', {'method': 'open'}); }
1064
+ }
1065
+ input.removeClass('ui-focus');
1066
+ })
1067
+ .blur(function(){
1068
+ focusedEl.removeClass('ui-focus');
1069
+ input.removeClass('ui-focus');
1070
+ })
1071
+ .change(function() {
1072
+ self.theDate = self._makeDate(self.input.val());
1073
+ self._update();
1074
+ });
1075
+
1076
+ // Bind the master handler.
1077
+ input.bind('datebox', self._dateboxHandler);
1078
+
1079
+ // Bind the close button on the DIALOG mode.
1080
+ pickPage.find( ".ui-header a").bind('vclick', function(e) {
1081
+ e.preventDefault();
1082
+ e.stopImmediatePropagation();
1083
+ self.input.trigger('datebox', {'method':'close'});
1084
+ });
1085
+
1086
+ $.extend(self, {
1087
+ pickPage: pickPage,
1088
+ thisPage: thisPage,
1089
+ pickPageContent: pickPageContent,
1090
+ input: input,
1091
+ theDate: theDate,
1092
+ initDate: initDate,
1093
+ focusedEl: focusedEl,
1094
+ touch: touch,
1095
+ START_DRAG: START_EVENT,
1096
+ MOVE_DRAG: MOVE_EVENT,
1097
+ END_DRAG: END_EVENT,
1098
+ dragMove: dragMove,
1099
+ dragStart: dragStart,
1100
+ dragEnd: dragEnd,
1101
+ dragPos: dragPos
1102
+ });
1103
+
1104
+ // Check if mousewheel plugin is loaded
1105
+ if ( typeof $.event.special.mousewheel !== 'undefined' ) { o.wheelExists = true; }
1106
+
1107
+ self._buildPage();
1108
+
1109
+ // drag and drop support, all ending and moving events are defined here, start events are handled in _buildPage or update
1110
+ if ( o.swipeEnabled ) {
1111
+ $(document).bind(self.MOVE_DRAG, function(e) {
1112
+ if ( self.dragMove ) {
1113
+ if ( o.mode === 'slidebox' ) {
1114
+ self.dragEnd = self.touch ? e.originalEvent.changedTouches[0].pageX : e.pageX;
1115
+ self.dragTarget.css('marginLeft', (self.dragPos + self.dragEnd - self.dragStart) + 'px');
1116
+ e.preventDefault();
1117
+ e.stopPropagation();
1118
+ return false;
1119
+ } else if ( o.mode === 'flipbox' || o.mode === 'timeflipbox' ) {
1120
+ self.dragEnd = self.touch ? e.originalEvent.changedTouches[0].pageY : e.pageY;
1121
+ self.dragTarget.css('marginTop', (self.dragPos + self.dragEnd - self.dragStart) + 'px');
1122
+ e.preventDefault();
1123
+ e.stopPropagation();
1124
+ return false;
1125
+ } else if ( o.mode === 'durationbox' || o.mode === 'timebox' || o.mode === 'datebox' ) {
1126
+ self.dragEnd = self.touch ? e.originalEvent.changedTouches[0].pageY : e.pageY;
1127
+ if ( (self.dragEnd - self.dragStart) % 2 === 0 ) {
1128
+ dragThisDelta = (self.dragEnd - self.dragStart) / -2;
1129
+ if ( dragThisDelta < self.dragPos ) {
1130
+ self._offset(self.dragTarget, -1*(self.dragTarget==='i'?o.minuteStep:1));
1131
+ } else if ( dragThisDelta > self.dragPos ) {
1132
+ self._offset(self.dragTarget, 1*(self.dragTarget==='i'?o.minuteStep:1));
1133
+ }
1134
+ self.dragPos = dragThisDelta;
1135
+ }
1136
+ e.preventDefault();
1137
+ e.stopPropagation();
1138
+ return false;
1139
+ }
1140
+ }
1141
+ });
1142
+ $(document).bind(self.END_DRAG, function(e) {
1143
+ if ( self.dragMove ) {
1144
+ self.dragMove = false;
1145
+ if ( o.mode === 'slidebox' ) {
1146
+ if ( self.dragEnd !== false && Math.abs(self.dragStart - self.dragEnd) > 25 ) {
1147
+ e.preventDefault();
1148
+ e.stopPropagation();
1149
+ switch(self.dragTarget.parent().data('rowtype')) {
1150
+ case 'y':
1151
+ self._offset('y', parseInt(( self.dragStart - self.dragEnd ) / 84, 10));
1152
+ break;
1153
+ case 'm':
1154
+ self._offset('m', parseInt(( self.dragStart - self.dragEnd ) / 51, 10));
1155
+ break;
1156
+ case 'd':
1157
+ self._offset('d', parseInt(( self.dragStart - self.dragEnd ) / 32, 10));
1158
+ break;
1159
+ case 'h':
1160
+ self._offset('h', parseInt(( self.dragStart - self.dragEnd ) / 32, 10));
1161
+ break;
1162
+ case 'i':
1163
+ self._offset('i', parseInt(( self.dragStart - self.dragEnd ) / 32, 10));
1164
+ break;
1165
+ }
1166
+ }
1167
+ } else if ( o.mode === 'flipbox' || o.mode === 'timeflipbox' ) {
1168
+ if ( self.dragEnd !== false ) {
1169
+ e.preventDefault();
1170
+ e.stopPropagation();
1171
+ self._offset(self.dragTarget.parent().parent().data('field'), parseInt(( self.dragStart - self.dragEnd ) / 30, 10));
1172
+ }
1173
+ }
1174
+ self.dragStart = false;
1175
+ self.dragEnd = false;
1176
+ }
1177
+ });
1178
+ }
1179
+
1180
+ // Disable when done if element attribute disabled is true.
1181
+ if ( input.is(':disabled') ) {
1182
+ self.disable();
1183
+ }
1184
+ // Turn input readonly if requested (on by default)
1185
+ if ( o.disableManualInput === true ) {
1186
+ input.attr("readonly", true);
1187
+ }
1188
+ },
1189
+ _buildPage: function () {
1190
+ // Build the controls
1191
+ var self = this,
1192
+ o = self.options, x, newHour, fld,
1193
+ linkdiv =$("<div><a href='#'></a></div>"),
1194
+ pickerContent = $("<div>", { "class": 'ui-datebox-container ui-overlay-shadow ui-corner-all ui-datebox-hidden pop ui-body-'+o.pickPageTheme} ).css('zIndex', o.zindex),
1195
+ templInput = $("<input type='text' />").addClass('ui-input-text ui-corner-all ui-shadow-inset ui-datebox-input ui-body-'+o.pickPageInputTheme),
1196
+ templControls = $("<div>", { "class":'ui-datebox-controls' }),
1197
+ templFlip = $("<div class='ui-overlay-shadow'><ul></ul></div>"),
1198
+ controlsPlus, controlsInput, controlsMinus, controlsSet, controlsHeader,
1199
+ pickerHour, pickerMins, pickerMeri, pickerMon, pickerDay, pickerYar, pickerSecs,
1200
+ calNoNext = false,
1201
+ calNoPrev = false,
1202
+ screen = $("<div>", {'class':'ui-datebox-screen ui-datebox-hidden'+((o.useModal)?' ui-datebox-screen-modal':'')})
1203
+ .css({'z-index': o.zindex-1})
1204
+ .appendTo(self.thisPage)
1205
+ .bind("vclick", function(event) {
1206
+ event.preventDefault();
1207
+ self.input.trigger('datebox', {'method':'close'});
1208
+ });
1209
+
1210
+ if ( o.noAnimation ) { pickerContent.removeClass('pop'); }
1211
+
1212
+ /* BEGIN:FLIPBOX */
1213
+ if ( o.mode === 'flipbox' || o.mode === 'timeflipbox' ) {
1214
+ controlsHeader = $("<div class='ui-datebox-header'><h4>Unitialized</h4></div>").appendTo(pickerContent).find("h4");
1215
+ controlsInput = $("<div>", {"class":'ui-datebox-flipcontent'}).appendTo(pickerContent);
1216
+ controlsPlus = $("<div>", {"class":'ui-datebox-flipcenter ui-overlay-shadow'}).appendTo(pickerContent);
1217
+ controlsSet = templControls.clone().appendTo(pickerContent);
1218
+
1219
+ pickerDay = templFlip.clone().attr('data-field', 'd');
1220
+ pickerMon = templFlip.clone().attr('data-field', 'm');
1221
+ pickerYar = templFlip.clone().attr('data-field', 'y');
1222
+ pickerHour = templFlip.clone().attr('data-field', 'h');
1223
+ pickerMins = templFlip.clone().attr('data-field', 'i');
1224
+ pickerMeri = templFlip.clone().attr('data-field', 'a');
1225
+
1226
+ if ( o.wheelExists ) { // Mousewheel operation, if the plugin is loaded.
1227
+ pickerYar.bind('mousewheel', function(e,d) { e.preventDefault(); self._offset('y', (d<0)?-1:1); });
1228
+ pickerMon.bind('mousewheel', function(e,d) { e.preventDefault(); self._offset('m', (d<0)?-1:1); });
1229
+ pickerDay.bind('mousewheel', function(e,d) { e.preventDefault(); self._offset('d', (d<0)?-1:1); });
1230
+ pickerHour.bind('mousewheel', function(e,d) { e.preventDefault(); self._offset('h', (d<0)?-1:1); });
1231
+ pickerMins.bind('mousewheel', function(e,d) { e.preventDefault(); self._offset('i', ((d<0)?-1:1)*o.minuteStep); });
1232
+ pickerMeri.bind('mousewheel', function(e,d) { e.preventDefault(); self._offset('a', d); });
1233
+ controlsPlus.bind('mousewheel', function(e,d) {
1234
+ e.preventDefault();
1235
+ if ( o.fieldsOrder.length === 3 ) {
1236
+ fld = o.fieldsOrder[parseInt((e.pageX - $(e.currentTarget).offset().left) / 87, 10)];
1237
+ } else if ( o.fieldsOrder.length === 2 ) {
1238
+ fld = o.fieldsOrder[parseInt((e.pageX - $(e.currentTarget).offset().left) / 130, 10)];
1239
+ }
1240
+ self._offset(fld, ((d<0)?-1:1) * ((fld==="i")?o.minuteStep:1));
1241
+ });
1242
+ }
1243
+
1244
+ for(x=0; x<=o.fieldsOrder.length; x++) { // Use fieldsOrder to decide which to show.
1245
+ if (o.fieldsOrder[x] === 'y') { pickerYar.appendTo(controlsInput); }
1246
+ if (o.fieldsOrder[x] === 'm') { pickerMon.appendTo(controlsInput); }
1247
+ if (o.fieldsOrder[x] === 'd') { pickerDay.appendTo(controlsInput); }
1248
+ if (o.fieldsOrder[x] === 'h') { pickerHour.appendTo(controlsInput); }
1249
+ if (o.fieldsOrder[x] === 'i') { pickerMins.appendTo(controlsInput); }
1250
+ if (o.fieldsOrder[x] === 'a' && o.timeFormat === 12 ) { pickerMeri.appendTo(controlsInput); }
1251
+ }
1252
+
1253
+ if ( o.swipeEnabled ) { // Drag and drop support
1254
+ controlsInput.find('ul').bind(self.START_DRAG, function(e,f) {
1255
+ if ( !self.dragMove ) {
1256
+ if ( typeof f !== "undefined" ) { e = f; }
1257
+ self.dragMove = true;
1258
+ self.dragTarget = $(this).find('li').first();
1259
+ self.dragPos = parseInt(self.dragTarget.css('marginTop').replace(/px/i, ''),10);
1260
+ self.dragStart = self.touch ? e.originalEvent.changedTouches[0].pageY : e.pageY;
1261
+ self.dragEnd = false;
1262
+ e.stopPropagation();
1263
+ e.preventDefault();
1264
+ }
1265
+ });
1266
+ controlsPlus.bind(self.START_DRAG, function(e) {
1267
+ if ( !self.dragMove ) {
1268
+ self.dragTarget = self.touch ? e.originalEvent.changedTouches[0].pageX - $(e.currentTarget).offset().left : e.pageX - $(e.currentTarget).offset().left;
1269
+ if ( o.fieldsOrder.length === 3 ) {
1270
+ $(self.controlsInput.find('ul').get(parseInt(self.dragTarget / 87, 10))).trigger(self.START_DRAG, e);
1271
+ } else if ( o.fieldsOrder.length === 2 ) {
1272
+ $(self.controlsInput.find('ul').get(parseInt(self.dragTarget / 130, 10))).trigger(self.START_DRAG, e);
1273
+ }
1274
+ }
1275
+ });
1276
+ }
1277
+
1278
+ if ( o.noSetButton === false ) { // Set button at bottom
1279
+ $("<a href='#'>" + ((o.mode==='timeflipbox')?o.setTimeButtonLabel:o.setDateButtonLabel) + "</a>")
1280
+ .appendTo(controlsSet).buttonMarkup({theme: o.pickPageTheme, icon: 'check', iconpos: 'left', corners:true, shadow:true})
1281
+ .bind('vclick', function(e) {
1282
+ e.preventDefault();
1283
+ if ( o.mode === 'timeflipbox' ) { self.input.trigger('datebox', {'method':'set', 'value':self._formatTime(self.theDate)}); }
1284
+ else { self.input.trigger('datebox', {'method':'set', 'value':self._formatDate(self.theDate)}); }
1285
+ self.input.trigger('datebox', {'method':'close'});
1286
+ });
1287
+ }
1288
+
1289
+ $.extend(self, {
1290
+ controlsHeader: controlsHeader,
1291
+ controlsInput: controlsInput,
1292
+ pickerDay: pickerDay,
1293
+ pickerMon: pickerMon,
1294
+ pickerYar: pickerYar,
1295
+ pickerHour: pickerHour,
1296
+ pickerMins: pickerMins,
1297
+ pickerMeri: pickerMeri
1298
+ });
1299
+
1300
+ pickerContent.appendTo(self.thisPage);
1301
+
1302
+ }
1303
+ /* END:FLIPBOX */
1304
+ /* BEGIN:DURATIONBOX */
1305
+ if ( o.mode === 'durationbox' ) {
1306
+ controlsPlus = templControls.clone().removeClass('ui-datebox-controls').addClass('ui-datebox-scontrols').appendTo(pickerContent);
1307
+ controlsInput = controlsPlus.clone().appendTo(pickerContent);
1308
+ controlsMinus = controlsPlus.clone().appendTo(pickerContent);
1309
+ controlsSet = templControls.clone().appendTo(pickerContent);
1310
+
1311
+ pickerDay = templInput.removeClass('ui-datebox-input').clone()
1312
+ .keyup(function() { if ( $(this).val() !== '' ) { self._updateduration(); } });
1313
+
1314
+ pickerHour = pickerDay.clone().keyup(function() { if ( $(this).val() !== '' ) { self._updateduration(); } });
1315
+ pickerMins = pickerDay.clone().keyup(function() { if ( $(this).val() !== '' ) { self._updateduration(); } });
1316
+ pickerSecs = pickerDay.clone().keyup(function() { if ( $(this).val() !== '' ) { self._updateduration(); } });
1317
+
1318
+ if ( o.wheelExists ) { // Mousewheel operation, if the plgin is loaded
1319
+ pickerDay.bind('mousewheel', function(e,d) { e.preventDefault(); self._offset('d', ((d<0)?-1:1)*o.durationSteppers['d']); });
1320
+ pickerHour.bind('mousewheel', function(e,d) { e.preventDefault(); self._offset('h', ((d<0)?-1:1)*o.durationSteppers['h']); });
1321
+ pickerMins.bind('mousewheel', function(e,d) { e.preventDefault(); self._offset('i', ((d<0)?-1:1)*o.durationSteppers['i']); });
1322
+ pickerSecs.bind('mousewheel', function(e,d) { e.preventDefault(); self._offset('s', ((d<0)?-1:1)*o.durationSteppers['s']); });
1323
+ }
1324
+
1325
+ for ( x=0; x<o.durationOrder.length; x++ ) { // Use durationOrder to decide what goes where
1326
+ switch ( o.durationOrder[x] ) {
1327
+ case 'd':
1328
+ $('<div>', {'class': 'ui-datebox-sinput', 'data-field': 'd'}).append(pickerDay).appendTo(controlsInput).prepend('<label>'+o.durationLabel[0]+'</label>');
1329
+ break;
1330
+ case 'h':
1331
+ $('<div>', {'class': 'ui-datebox-sinput', 'data-field': 'h'}).append(pickerHour).appendTo(controlsInput).prepend('<label>'+o.durationLabel[1]+'</label>');
1332
+ break;
1333
+ case 'i':
1334
+ $('<div>', {'class': 'ui-datebox-sinput', 'data-field': 'i'}).append(pickerMins).appendTo(controlsInput).prepend('<label>'+o.durationLabel[2]+'</label>');
1335
+ break;
1336
+ case 's':
1337
+ $('<div>', {'class': 'ui-datebox-sinput', 'data-field': 's'}).append(pickerSecs).appendTo(controlsInput).prepend('<label>'+o.durationLabel[3]+'</label>');
1338
+ break;
1339
+ }
1340
+ }
1341
+
1342
+ if ( o.swipeEnabled ) { // Drag and drop operation
1343
+ controlsInput.find('input').bind(self.START_DRAG, function(e) {
1344
+ if ( !self.dragMove ) {
1345
+ self.dragMove = true;
1346
+ self.dragTarget = $(this).parent().data('field');
1347
+ self.dragPos = 0;
1348
+ self.dragStart = self.touch ? e.originalEvent.changedTouches[0].pageY : e.pageY;
1349
+ self.dragEnd = false;
1350
+ e.stopPropagation();
1351
+ }
1352
+ });
1353
+ }
1354
+
1355
+ if ( o.noSetButton === false ) { // Bottom set button
1356
+ $("<a href='#'>" + o.setDurationButtonLabel + "</a>")
1357
+ .appendTo(controlsSet).buttonMarkup({theme: o.pickPageTheme, icon: 'check', iconpos: 'left', corners:true, shadow:true})
1358
+ .bind('vclick', function(e) {
1359
+ e.preventDefault();
1360
+ self.input.trigger('datebox', {'method':'set', 'value':self._formatTime(self.theDate)});
1361
+ self.input.trigger('datebox', {'method':'close'});
1362
+ });
1363
+ }
1364
+
1365
+ for ( x=0; x<o.durationOrder.length; x++ ) {
1366
+ linkdiv.clone()
1367
+ .appendTo(controlsPlus).buttonMarkup({theme: o.pickPageButtonTheme, icon: 'plus', iconpos: 'bottom', corners:true, shadow:true})
1368
+ .attr('data-field', o.durationOrder[x])
1369
+ .bind('vclick', function(e) {
1370
+ e.preventDefault();
1371
+ self._offset($(this).attr('data-field'),o.durationSteppers[$(this).attr('data-field')]);
1372
+ });
1373
+
1374
+ linkdiv.clone()
1375
+ .appendTo(controlsMinus).buttonMarkup({theme: o.pickPageButtonTheme, icon: 'minus', iconpos: 'top', corners:true, shadow:true})
1376
+ .attr('data-field', o.durationOrder[x])
1377
+ .bind('vclick', function(e) {
1378
+ e.preventDefault();
1379
+ self._offset($(this).attr('data-field'),-1*o.durationSteppers[$(this).attr('data-field')]);
1380
+ });
1381
+ }
1382
+
1383
+ $.extend(self, {
1384
+ pickerHour: pickerHour,
1385
+ pickerMins: pickerMins,
1386
+ pickerDay: pickerDay,
1387
+ pickerSecs: pickerSecs
1388
+ });
1389
+
1390
+ pickerContent.appendTo(self.thisPage);
1391
+ }
1392
+ /* END:DURATIONBOX */
1393
+ /* BEGIN:DATETIME */
1394
+ if ( o.mode === 'datebox' || o.mode === 'timebox' ) {
1395
+ controlsHeader = $("<div class='ui-datebox-header'><h4>Unitialized</h4></div>").appendTo(pickerContent).find("h4");
1396
+ controlsPlus = templControls.clone().appendTo(pickerContent);
1397
+ controlsInput = templControls.clone().appendTo(pickerContent);
1398
+ controlsMinus = templControls.clone().appendTo(pickerContent);
1399
+ controlsSet = templControls.clone().appendTo(pickerContent);
1400
+
1401
+ if ( o.mode === 'timebox' ) { controlsHeader.parent().html(''); } // Time mode has no header
1402
+
1403
+ pickerMon = templInput.clone()
1404
+ .attr('data-field', 'm')
1405
+ .keyup(function() {
1406
+ if ( $(this).val() !== '' && self._isInt($(this).val()) ) {
1407
+ self.theDate.setMonth(parseInt($(this).val(),10)-1);
1408
+ self._update();
1409
+ }
1410
+ });
1411
+
1412
+ pickerDay = pickerMon.clone()
1413
+ .attr('data-field', 'd')
1414
+ .keyup(function() {
1415
+ if ( $(this).val() !== '' && self._isInt($(this).val()) ) {
1416
+ self.theDate.setDate(parseInt($(this).val(),10));
1417
+ self._update();
1418
+ }
1419
+ });
1420
+
1421
+ pickerYar = pickerMon.clone()
1422
+ .attr('data-field', 'y')
1423
+ .keyup(function() {
1424
+ if ( $(this).val() !== '' && self._isInt($(this).val()) ) {
1425
+ self.theDate.setFullYear(parseInt($(this).val(),10));
1426
+ self._update();
1427
+ }
1428
+ });
1429
+
1430
+ pickerHour = templInput.clone()
1431
+ .attr('data-field', 'h')
1432
+ .keyup(function() {
1433
+ if ( $(this).val() !== '' && self._isInt($(this).val()) ) {
1434
+ newHour = parseInt($(this).val(),10);
1435
+ if ( newHour === 12 ) {
1436
+ if ( o.timeFormat === 12 && pickerMeri.val() === o.meridiemLetters[0] ) { newHour = 0; }
1437
+ }
1438
+ self.theDate.setHours(newHour);
1439
+ self._update();
1440
+ }
1441
+ });
1442
+
1443
+ pickerMins = templInput.clone()
1444
+ .attr('data-field', 'i')
1445
+ .keyup(function() {
1446
+ if ( $(this).val() !== '' && self._isInt($(this).val()) ) {
1447
+ self.theDate.setMinutes(parseInt($(this).val(),10));
1448
+ self._update();
1449
+ }
1450
+ });
1451
+
1452
+ pickerMeri = templInput.clone()
1453
+ .attr('data-field', 'a')
1454
+ .keyup(function() {
1455
+ if ( $(this).val() !== '' ) {
1456
+ self._update();
1457
+ }
1458
+ });
1459
+
1460
+ if ( o.wheelExists ) { // Mousewheel operation, if plugin is loaded
1461
+ pickerYar.bind('mousewheel', function(e,d) { e.preventDefault(); self._offset('y', (d<0)?-1:1); });
1462
+ pickerMon.bind('mousewheel', function(e,d) { e.preventDefault(); self._offset('m', (d<0)?-1:1); });
1463
+ pickerDay.bind('mousewheel', function(e,d) { e.preventDefault(); self._offset('d', (d<0)?-1:1); });
1464
+ pickerHour.bind('mousewheel', function(e,d) { e.preventDefault(); self._offset('h', (d<0)?-1:1); });
1465
+ pickerMins.bind('mousewheel', function(e,d) { e.preventDefault(); self._offset('i', ((d<0)?-1:1)*o.minuteStep); });
1466
+ pickerMeri.bind('mousewheel', function(e,d) { e.preventDefault(); self._offset('a', d); });
1467
+ }
1468
+
1469
+ for(x=0; x<=o.fieldsOrder.length; x++) { // Use fieldsOrder to decide what goes where
1470
+ if (o.fieldsOrder[x] === 'y') { pickerYar.appendTo(controlsInput); }
1471
+ if (o.fieldsOrder[x] === 'm') { pickerMon.appendTo(controlsInput); }
1472
+ if (o.fieldsOrder[x] === 'd') { pickerDay.appendTo(controlsInput); }
1473
+ if (o.fieldsOrder[x] === 'h') { pickerHour.appendTo(controlsInput); }
1474
+ if (o.fieldsOrder[x] === 'i') { pickerMins.appendTo(controlsInput); }
1475
+ if (o.fieldsOrder[x] === 'a' && o.timeFormat === 12 ) { pickerMeri.appendTo(controlsInput); }
1476
+ }
1477
+
1478
+ if ( o.swipeEnabled ) { // Drag and drop support
1479
+ controlsInput.find('input').bind(self.START_DRAG, function(e) {
1480
+ if ( !self.dragMove ) {
1481
+ self.dragMove = true;
1482
+ self.dragTarget = $(this).data('field');
1483
+ self.dragPos = 0;
1484
+ self.dragStart = self.touch ? e.originalEvent.changedTouches[0].pageY : e.pageY;
1485
+ self.dragEnd = false;
1486
+ e.stopPropagation();
1487
+ }
1488
+ });
1489
+ }
1490
+
1491
+ if ( o.noSetButton === false ) { // Set button at bottom
1492
+ $("<a href='#'>" + ((o.mode==='timebox')?o.setTimeButtonLabel:o.setDateButtonLabel) + "</a>")
1493
+ .appendTo(controlsSet).buttonMarkup({theme: o.pickPageTheme, icon: 'check', iconpos: 'left', corners:true, shadow:true})
1494
+ .bind('vclick', function(e) {
1495
+ e.preventDefault();
1496
+ if ( o.mode === 'timebox' ) { self.input.trigger('datebox', {'method':'set', 'value':self._formatTime(self.theDate)}); }
1497
+ else { self.input.trigger('datebox', {'method':'set', 'value':self._formatDate(self.theDate)}); }
1498
+ self.input.trigger('datebox', {'method':'close'});
1499
+ });
1500
+ }
1501
+
1502
+ for( x=0; x<self.options.fieldsOrder.length; x++ ) { // Generate the plus and minus buttons, use fieldsOrder again
1503
+ if ( o.fieldsOrder[x] !== 'a' || o.timeFormat === 12 ) {
1504
+ linkdiv.clone()
1505
+ .appendTo(controlsPlus).buttonMarkup({theme: o.pickPageButtonTheme, icon: 'plus', iconpos: 'bottom', corners:true, shadow:true})
1506
+ .attr('data-field', o.fieldsOrder[x])
1507
+ .bind('vclick', function(e) {
1508
+ e.preventDefault();
1509
+ self._offset($(this).attr('data-field'),1*($(this).attr('data-field')==='i'?o.minuteStep:1));
1510
+ });
1511
+ linkdiv.clone()
1512
+ .appendTo(controlsMinus).buttonMarkup({theme: o.pickPageButtonTheme, icon: 'minus', iconpos: 'top', corners:true, shadow:true})
1513
+ .attr('data-field', o.fieldsOrder[x])
1514
+ .bind('vclick', function(e) {
1515
+ e.preventDefault();
1516
+ self._offset($(this).attr('data-field'),-1*($(this).attr('data-field')==='i'?o.minuteStep:1));
1517
+ });
1518
+ }
1519
+ }
1520
+
1521
+ $.extend(self, {
1522
+ controlsHeader: controlsHeader,
1523
+ pickerDay: pickerDay,
1524
+ pickerMon: pickerMon,
1525
+ pickerYar: pickerYar,
1526
+ pickerHour: pickerHour,
1527
+ pickerMins: pickerMins,
1528
+ pickerMeri: pickerMeri
1529
+ });
1530
+
1531
+ pickerContent.appendTo(self.thisPage);
1532
+ }
1533
+ /* END:DATETIME */
1534
+ /* BEGIN:CALBOX */
1535
+ if ( o.mode === 'calbox' ) {
1536
+ controlsHeader = $("<div>", {"class": 'ui-datebox-gridheader'}).appendTo(pickerContent);
1537
+ controlsSet = $("<div>", {"class": 'ui-datebox-grid'}).appendTo(pickerContent);
1538
+ controlsInput = $("<div class='ui-datebox-gridlabel'><h4>Uninitialized</h4></div>").appendTo(controlsHeader).find('h4');
1539
+
1540
+ if ( o.swipeEnabled ) { // Calendar swipe left and right
1541
+ pickerContent
1542
+ .bind('swipeleft', function() { if ( !self.calNoNext ) { self._offset('m', 1); } })
1543
+ .bind('swiperight', function() { if ( !self.calNoPrev ) { self._offset('m', -1); } });
1544
+ }
1545
+
1546
+ if ( o.wheelExists) { // Mousewheel operations, if plugin is loaded
1547
+ pickerContent.bind('mousewheel', function(e,d) {
1548
+ e.preventDefault();
1549
+ if ( d > 0 && !self.calNoNext ) {
1550
+ if ( self.theDate.getDate() > 28 ) { self.theDate.setDate(1); }
1551
+ self._offset('m', 1);
1552
+ }
1553
+ if ( d < 0 && !self.calNoPrev ) {
1554
+ if ( self.theDate.getDate() > 28 ) { self.theDate.setDate(1); }
1555
+ self._offset('m', -1);
1556
+ }
1557
+ });
1558
+ }
1559
+
1560
+ // Previous and next month buttons, define booleans to decide if they should do anything
1561
+ $("<div class='ui-datebox-gridplus'><a href='#'>Next Month</a></div>")
1562
+ .prependTo(controlsHeader).buttonMarkup({theme: o.pickPageButtonTheme, icon: 'plus', inline: true, iconpos: 'notext', corners:true, shadow:true})
1563
+ .bind('vclick', function(e) {
1564
+ e.preventDefault();
1565
+ if ( ! self.calNoNext ) {
1566
+ if ( self.theDate.getDate() > 28 ) { self.theDate.setDate(1); }
1567
+ self._offset('m',1);
1568
+ }
1569
+ });
1570
+ $("<div class='ui-datebox-gridminus'><a href='#'>Prev Month</a></div>")
1571
+ .prependTo(controlsHeader).buttonMarkup({theme: o.pickPageButtonTheme, icon: 'minus', inline: true, iconpos: 'notext', corners:true, shadow:true})
1572
+ .bind('vclick', function(e) {
1573
+ e.preventDefault();
1574
+ if ( ! self.calNoPrev ) {
1575
+ if ( self.theDate.getDate() > 28 ) { self.theDate.setDate(1); }
1576
+ self._offset('m',-1);
1577
+ }
1578
+ });
1579
+
1580
+ if ( o.calTodayButton === true ) { // Show today button at bottom
1581
+ $("<a href='#'>" + o.calTodayButtonLabel + "</a>")
1582
+ .appendTo(pickerContent).buttonMarkup({theme: o.pickPageTheme, icon: 'check', iconpos: 'left', corners:true, shadow:true})
1583
+ .bind('vclick', function(e) {
1584
+ e.preventDefault();
1585
+ self.theDate = new Date();
1586
+ self.theDate = new Date(self.theDate.getFullYear(), self.theDate.getMonth(), self.theDate.getDate(), 0,0,0,0);
1587
+ self.input.trigger('datebox', {'method':'doset'});
1588
+ });
1589
+ }
1590
+
1591
+ $.extend(self, {
1592
+ controlsInput: controlsInput,
1593
+ controlsSet: controlsSet,
1594
+ calNoNext: calNoNext,
1595
+ calNoPrev: calNoPrev
1596
+ });
1597
+
1598
+ pickerContent.appendTo(self.thisPage);
1599
+ }
1600
+ /* END:CALBOX */
1601
+ /* BEGIN:SLIDEBOX */
1602
+ if ( o.mode === 'slidebox' ) {
1603
+ controlsHeader = $("<div class='ui-datebox-header'><h4>Unitialized</h4></div>").appendTo(pickerContent).find("h4");
1604
+ controlsInput = $('<div>').addClass('ui-datebox-slide').appendTo(pickerContent);
1605
+ controlsSet = $("<div>", { "class":'ui-datebox-controls'}).appendTo(pickerContent);
1606
+
1607
+ if ( o.noSetButton === false ) { // Show set button at bottom
1608
+ $("<a href='#'>" + o.setDateButtonLabel + "</a>")
1609
+ .appendTo(controlsSet).buttonMarkup({theme: o.pickPageTheme, icon: 'check', iconpos: 'left', corners:true, shadow:true})
1610
+ .bind('vclick', function(e) {
1611
+ e.preventDefault();
1612
+ self.input.trigger('datebox', {'method':'set', 'value':self._formatDate(self.theDate)});
1613
+ self.input.trigger('datebox', {'method':'close'});
1614
+ });
1615
+ }
1616
+
1617
+ $.extend(self, {
1618
+ controlsHeader: controlsHeader,
1619
+ controlsInput: controlsInput
1620
+ });
1621
+
1622
+ pickerContent.appendTo(self.thisPage);
1623
+ }
1624
+ /* END:SLIDEBOX */
1625
+
1626
+ $.extend(self, {
1627
+ pickerContent: pickerContent,
1628
+ screen: screen
1629
+ });
1630
+
1631
+ // If useInline mode, drop it into the document, and stop a few events from working (or just hide the trigger)
1632
+ if ( o.useInline ) {
1633
+ self.input.parent().parent().append(self.pickerContent);
1634
+ if ( o.useInlineHideInput ) { self.input.parent().hide(); }
1635
+ self.input.trigger('change');
1636
+ self.pickerContent.removeClass('ui-datebox-hidden');
1637
+ }
1638
+
1639
+ },
1640
+ refresh: function() {
1641
+ // Pulic shortcut to _update, with an extra hook for inline mode.
1642
+ if ( this.options.useInline === true ) {
1643
+ this.input.trigger('change');
1644
+ }
1645
+ this._update();
1646
+ },
1647
+ open: function() {
1648
+ // Open the controls
1649
+ if ( this.options.useInline ) { return false; } // Ignore if inline
1650
+ if ( this.pickPage.is(':visible') ) { return false; } // Ignore if already open
1651
+
1652
+ this.input.trigger('change').blur(); // Grab latest value of input, in case it changed
1653
+
1654
+ var self = this,
1655
+ o = this.options,
1656
+ inputOffset = self.focusedEl.offset(),
1657
+ pickWinHeight = self.pickerContent.outerHeight(),
1658
+ pickWinWidth = self.pickerContent.innerWidth(),
1659
+ pickWinTop = inputOffset.top + ( self.focusedEl.outerHeight() / 2 )- ( pickWinHeight / 2),
1660
+ pickWinLeft = inputOffset.left + ( self.focusedEl.outerWidth() / 2) - ( pickWinWidth / 2),
1661
+ transition = o.noAnimation ? 'none' : 'pop',
1662
+ activePage;
1663
+
1664
+ // TOO FAR RIGHT TRAP
1665
+ if ( (pickWinLeft + pickWinWidth) > $(document).width() ) {
1666
+ pickWinLeft = $(document).width() - pickWinWidth - 1;
1667
+ }
1668
+ // TOO FAR LEFT TRAP
1669
+ if ( pickWinLeft < 0 ) {
1670
+ pickWinLeft = 0;
1671
+ }
1672
+ // Center popup on request - centered in document, not any containing div.
1673
+ if ( o.centerWindow ) {
1674
+ pickWinLeft = ( $(document).width() / 2 ) - ( pickWinWidth / 2 );
1675
+ }
1676
+
1677
+ if ( (pickWinHeight + pickWinTop) > $(document).height() ) {
1678
+ pickWinTop = $(document).height() - (pickWinHeight + 2);
1679
+ }
1680
+ if ( pickWinTop < 45 ) { pickWinTop = 45; }
1681
+
1682
+ // If the window is less than 400px wide, use the jQM dialog method unless otherwise forced
1683
+ if ( ( $(document).width() > 400 && !o.useDialogForceTrue ) || o.useDialogForceFalse ) {
1684
+ o.useDialog = false;
1685
+ if ( o.nestedBox ) {
1686
+ if ( pickWinHeight === 0 ) { // The box may have no height since it dosen't exist yet. working on it.
1687
+ pickWinHeight = 250;
1688
+ pickWinTop = inputOffset.top + ( self.focusedEl.outerHeight() / 2 )- ( pickWinHeight / 2);
1689
+ }
1690
+ activePage = $('.ui-page-active').first();
1691
+ $(activePage).append(self.pickerContent);
1692
+ $(activePage).append(self.screen);
1693
+ }
1694
+ if ( o.useModal ) { // If model, fade the background screen
1695
+ self.screen.fadeIn('slow');
1696
+ } else { // Else just unhide it since it's transparent
1697
+ self.screen.removeClass('ui-datebox-hidden');
1698
+ }
1699
+ self.pickerContent.addClass('ui-overlay-shadow in').css({'position': 'absolute', 'top': pickWinTop, 'left': pickWinLeft}).removeClass('ui-datebox-hidden');
1700
+ } else {
1701
+ // prevent the parent page from being removed from the DOM,
1702
+ self.thisPage.unbind( "pagehide.remove" );
1703
+ o.useDialog = true;
1704
+ self.pickPageContent.append(self.pickerContent);
1705
+ self.pickerContent.css({'top': 'auto', 'left': 'auto', 'marginLeft': 'auto', 'marginRight': 'auto'}).removeClass('ui-overlay-shadow ui-datebox-hidden');
1706
+ $.mobile.changePage(self.pickPage, {'transition': transition});
1707
+ }
1708
+ },
1709
+ close: function() {
1710
+ // Close the controls
1711
+ var self = this,
1712
+ callback;
1713
+
1714
+ if ( self.options.useInline ) {
1715
+ return true;
1716
+ }
1717
+
1718
+ // Check options to see if we are closing a dialog, or removing a popup
1719
+ if ( self.options.useDialog ) {
1720
+ $(self.pickPage).dialog('close');
1721
+ if( !self.thisPage.data("page").options.domCache ){
1722
+ self.thisPage.bind( "pagehide.remove", function() {
1723
+ $(self).remove();
1724
+ });
1725
+ }
1726
+ self.pickerContent.addClass('ui-datebox-hidden').removeAttr('style').css('zIndex', self.options.zindex);
1727
+ self.thisPage.append(self.pickerContent);
1728
+ } else {
1729
+ if ( self.options.useModal ) {
1730
+ self.screen.fadeOut('slow');
1731
+ } else {
1732
+ self.screen.addClass('ui-datebox-hidden');
1733
+ }
1734
+ self.pickerContent.addClass('ui-datebox-hidden').removeAttr('style').css('zIndex', self.options.zindex).removeClass('in');
1735
+ }
1736
+ self.focusedEl.removeClass('ui-focus');
1737
+
1738
+ if ( self.options.closeCallback !== false ) { callback = new Function(self.options.closeCallback); callback(); }
1739
+ },
1740
+ disable: function(){
1741
+ // Disable the element
1742
+ this.element.attr("disabled",true);
1743
+ this.element.parent().addClass("ui-disabled");
1744
+ this.options.disabled = true;
1745
+ this.element.blur();
1746
+ this.input.trigger('datebox', {'method':'disable'});
1747
+ },
1748
+ enable: function(){
1749
+ // Enable the element
1750
+ this.element.attr("disabled", false);
1751
+ this.element.parent().removeClass("ui-disabled");
1752
+ this.options.disabled = false;
1753
+ this.input.trigger('datebox', {'method':'enable'});
1754
+ }
1755
+
1756
+ });
1757
+
1758
+ // Degrade date inputs to text inputs, suppress standard UI functions.
1759
+ $( document ).bind( "pagebeforecreate", function( e ) {
1760
+ $( ":jqmData(role='datebox')", e.target ).each(function() {
1761
+ $(this).replaceWith(
1762
+ $( "<div>" ).html( $(this).clone() ).html()
1763
+ .replace( /\s+type=["']date['"]?/, " type=\"text\" " )
1764
+ );
1765
+ });
1766
+ });
1767
+ // Automatically bind to data-role='datebox' items.
1768
+ $( document ).bind( "pagecreate", function( e ){
1769
+ $( ":jqmData(role='datebox')", e.target ).datebox();
1770
+ });
1771
+
1772
+ })( jQuery );