active_frontend 13.3.0 → 14.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (221) hide show
  1. checksums.yaml +4 -4
  2. data/.DS_Store +0 -0
  3. data/.fasterer.yml +19 -0
  4. data/.reek +27 -0
  5. data/.rubocop.yml +38 -0
  6. data/.scss-lint.yml +27 -0
  7. data/Rakefile +1 -1
  8. data/active_frontend.gemspec +21 -18
  9. data/app/.DS_Store +0 -0
  10. data/app/assets/.DS_Store +0 -0
  11. data/app/assets/fonts/.DS_Store +0 -0
  12. data/app/assets/fonts/dripicons/.DS_Store +0 -0
  13. data/app/assets/fonts/dripicons/dripicons.woff +0 -0
  14. data/app/assets/fonts/fakt-pro/.DS_Store +0 -0
  15. data/app/assets/fonts/fakt-pro/fakt-pro-bold.woff +0 -0
  16. data/app/assets/fonts/fakt-pro/fakt-pro-normal.woff +0 -0
  17. data/app/assets/fonts/fakt-pro/fakt-pro-semibold.woff +0 -0
  18. data/app/assets/fonts/fakt-pro/fakt-pro-semilight.woff +0 -0
  19. data/app/assets/fonts/fakt-soft-pro/.DS_Store +0 -0
  20. data/app/assets/fonts/fakt-soft-pro/fakt-soft-pro-bold.woff +0 -0
  21. data/app/assets/fonts/fakt-soft-pro/fakt-soft-pro-normal.woff +0 -0
  22. data/app/assets/fonts/fakt-soft-pro/fakt-soft-pro-semibold.woff +0 -0
  23. data/app/assets/fonts/fakt-soft-pro/fakt-soft-pro-semilight.woff +0 -0
  24. data/app/assets/images/.DS_Store +0 -0
  25. data/app/assets/images/.keep +0 -0
  26. data/app/assets/images/placeholders/.DS_Store +0 -0
  27. data/app/assets/images/placeholders/camera-large.png +0 -0
  28. data/app/assets/images/placeholders/camera-small.png +0 -0
  29. data/app/assets/images/placeholders/camera.png +0 -0
  30. data/app/assets/images/placeholders/document-large.png +0 -0
  31. data/app/assets/images/placeholders/document-small.png +0 -0
  32. data/app/assets/images/placeholders/document.png +0 -0
  33. data/app/assets/images/placeholders/photo-large.png +0 -0
  34. data/app/assets/images/placeholders/{picture-small.png → photo-small.png} +0 -0
  35. data/app/assets/images/placeholders/photo.png +0 -0
  36. data/app/assets/images/placeholders/store-large.png +0 -0
  37. data/app/assets/images/placeholders/store-small.png +0 -0
  38. data/app/assets/images/placeholders/store.png +0 -0
  39. data/app/assets/images/placeholders/user-large.png +0 -0
  40. data/app/assets/images/placeholders/user-small.png +0 -0
  41. data/app/assets/images/placeholders/user.png +0 -0
  42. data/app/helpers/active_frontend_helper.rb +22 -37
  43. data/lib/.DS_Store +0 -0
  44. data/lib/active_frontend.rb +3 -4
  45. data/lib/active_frontend/.DS_Store +0 -0
  46. data/lib/active_frontend/version.rb +1 -1
  47. data/lib/generators/active_frontend/install_generator.rb +3 -3
  48. data/lib/generators/active_frontend/templates/install.js +35 -30
  49. data/lib/generators/active_frontend/templates/install.scss +55 -58
  50. data/vendor/.DS_Store +0 -0
  51. data/vendor/assets/.DS_Store +0 -0
  52. data/vendor/assets/javascripts/.DS_Store +0 -0
  53. data/vendor/assets/javascripts/active_frontend.js +35 -30
  54. data/vendor/assets/javascripts/base/_affix.js +170 -0
  55. data/vendor/assets/javascripts/base/_alert.js +80 -0
  56. data/vendor/assets/javascripts/base/_animation.js +106 -0
  57. data/vendor/assets/javascripts/base/_button.js +123 -0
  58. data/vendor/assets/javascripts/base/_carousel.js +237 -0
  59. data/vendor/assets/javascripts/base/_collapse.js +200 -0
  60. data/vendor/assets/javascripts/base/_colorpicker.js +147 -0
  61. data/vendor/assets/javascripts/base/_datepicker.js +1411 -0
  62. data/vendor/assets/javascripts/base/_dropdown.js +154 -0
  63. data/vendor/assets/javascripts/base/_filepicker.js +235 -0
  64. data/vendor/assets/javascripts/base/_hoverdown.js +116 -0
  65. data/vendor/assets/javascripts/base/_layout.js +126 -0
  66. data/vendor/assets/javascripts/base/_list.js +103 -0
  67. data/vendor/assets/javascripts/{_modal.js → base/_modal.js} +170 -167
  68. data/vendor/assets/javascripts/base/_popover.js +101 -0
  69. data/vendor/assets/javascripts/base/_scrollspy.js +161 -0
  70. data/vendor/assets/javascripts/base/_switch.js +160 -0
  71. data/vendor/assets/javascripts/base/_tab.js +139 -0
  72. data/vendor/assets/javascripts/base/_table.js +224 -0
  73. data/vendor/assets/javascripts/base/_timeago.js +270 -0
  74. data/vendor/assets/javascripts/base/_timepicker.js +541 -0
  75. data/vendor/assets/javascripts/base/_tooltip.js +525 -0
  76. data/vendor/assets/javascripts/base/_tour.js +268 -0
  77. data/vendor/assets/javascripts/base/_transition.js +52 -0
  78. data/vendor/assets/javascripts/base/_typeahead.js +362 -0
  79. data/vendor/assets/javascripts/extensions/_calendar.js +4709 -0
  80. data/vendor/assets/javascripts/extensions/_chart.js +9371 -0
  81. data/vendor/assets/javascripts/extensions/_map.js +2153 -0
  82. data/vendor/assets/stylesheets/.DS_Store +0 -0
  83. data/vendor/assets/stylesheets/{_mixin.scss → _utility.scss} +96 -10
  84. data/vendor/assets/stylesheets/_variable.scss +201 -19
  85. data/vendor/assets/stylesheets/active_frontend.scss +55 -58
  86. data/vendor/assets/stylesheets/blocks/_anchor.scss +15 -0
  87. data/vendor/assets/stylesheets/blocks/_button.scss +278 -0
  88. data/vendor/assets/stylesheets/blocks/_code.scss +144 -0
  89. data/vendor/assets/stylesheets/blocks/_common.scss +127 -0
  90. data/vendor/assets/stylesheets/blocks/_form.scss +508 -0
  91. data/vendor/assets/stylesheets/blocks/_icon.scss +359 -0
  92. data/vendor/assets/stylesheets/blocks/_list.scss +76 -0
  93. data/vendor/assets/stylesheets/blocks/_multimedia.scss +62 -0
  94. data/vendor/assets/stylesheets/blocks/_reset.scss +179 -0
  95. data/vendor/assets/stylesheets/blocks/_table.scss +211 -0
  96. data/vendor/assets/stylesheets/blocks/_typography.scss +204 -0
  97. data/vendor/assets/stylesheets/components/_ad.scss +78 -0
  98. data/vendor/assets/stylesheets/components/_affix.scss +14 -0
  99. data/vendor/assets/stylesheets/components/_alert.scss +50 -0
  100. data/vendor/assets/stylesheets/components/_animation.scss +1670 -0
  101. data/vendor/assets/stylesheets/components/_breadcrumb.scss +17 -0
  102. data/vendor/assets/stylesheets/components/_calendar.scss +213 -0
  103. data/vendor/assets/stylesheets/components/_card.scss +30 -0
  104. data/vendor/assets/stylesheets/components/_carousel.scss +135 -0
  105. data/vendor/assets/stylesheets/components/_chart.scss +10 -0
  106. data/vendor/assets/stylesheets/components/_collapse.scss +17 -0
  107. data/vendor/assets/stylesheets/components/_colorpicker.scss +38 -0
  108. data/vendor/assets/stylesheets/components/_datepicker.scss +80 -0
  109. data/vendor/assets/stylesheets/components/_dropmenu.scss +151 -0
  110. data/vendor/assets/stylesheets/components/_footer.scss +11 -0
  111. data/vendor/assets/stylesheets/components/_grid.scss +144 -0
  112. data/vendor/assets/stylesheets/components/_header.scss +99 -0
  113. data/vendor/assets/stylesheets/components/_label_and_badge.scss +57 -0
  114. data/vendor/assets/stylesheets/components/_layout.scss +63 -0
  115. data/vendor/assets/stylesheets/components/_map.scss +14 -0
  116. data/vendor/assets/stylesheets/components/_milestone.scss +49 -0
  117. data/vendor/assets/stylesheets/components/_missive.scss +40 -0
  118. data/vendor/assets/stylesheets/components/_modal.scss +126 -0
  119. data/vendor/assets/stylesheets/components/_nav_and_tab.scss +202 -0
  120. data/vendor/assets/stylesheets/components/_navbar.scss +66 -0
  121. data/vendor/assets/stylesheets/components/_pagination.scss +79 -0
  122. data/vendor/assets/stylesheets/components/_placeholder.scss +23 -0
  123. data/vendor/assets/stylesheets/components/_popover.scss +167 -0
  124. data/vendor/assets/stylesheets/components/_progress.scss +62 -0
  125. data/vendor/assets/stylesheets/components/_sidebar.scss +74 -0
  126. data/vendor/assets/stylesheets/components/_spinner.scss +83 -0
  127. data/vendor/assets/stylesheets/components/_switch.scss +150 -0
  128. data/vendor/assets/stylesheets/components/_timepicker.scss +30 -0
  129. data/vendor/assets/stylesheets/components/_tooltip.scss +93 -0
  130. data/vendor/assets/stylesheets/components/_transition.scss +12 -0
  131. data/vendor/assets/stylesheets/components/_typeahead.scss +18 -0
  132. metadata +150 -94
  133. data/app/assets/fonts/gotham/gotham-bold.woff +0 -0
  134. data/app/assets/fonts/gotham/gotham-book.woff +0 -0
  135. data/app/assets/fonts/gotham/gotham-light.woff +0 -0
  136. data/app/assets/fonts/gotham/gotham-medium.woff +0 -0
  137. data/app/assets/fonts/gotham/gotham-rounded-bold.woff +0 -0
  138. data/app/assets/fonts/gotham/gotham-rounded-book.woff +0 -0
  139. data/app/assets/fonts/gotham/gotham-rounded-light.woff +0 -0
  140. data/app/assets/fonts/gotham/gotham-rounded-medium.woff +0 -0
  141. data/app/assets/images/placeholders/archive-large.png +0 -0
  142. data/app/assets/images/placeholders/archive-small.png +0 -0
  143. data/app/assets/images/placeholders/archive.png +0 -0
  144. data/app/assets/images/placeholders/picture-large.png +0 -0
  145. data/app/assets/images/placeholders/picture.png +0 -0
  146. data/vendor/assets/javascripts/_affix.js +0 -153
  147. data/vendor/assets/javascripts/_alert.js +0 -85
  148. data/vendor/assets/javascripts/_animation.js +0 -103
  149. data/vendor/assets/javascripts/_button.js +0 -107
  150. data/vendor/assets/javascripts/_carousel.js +0 -228
  151. data/vendor/assets/javascripts/_chart.js +0 -3742
  152. data/vendor/assets/javascripts/_collapse.js +0 -202
  153. data/vendor/assets/javascripts/_color_picker.js +0 -108
  154. data/vendor/assets/javascripts/_date_picker.js +0 -1650
  155. data/vendor/assets/javascripts/_dropdown.js +0 -156
  156. data/vendor/assets/javascripts/_file_input.js +0 -71
  157. data/vendor/assets/javascripts/_hoverdown.js +0 -109
  158. data/vendor/assets/javascripts/_inputmask.js +0 -341
  159. data/vendor/assets/javascripts/_loader.js +0 -361
  160. data/vendor/assets/javascripts/_map.js +0 -2401
  161. data/vendor/assets/javascripts/_popover.js +0 -99
  162. data/vendor/assets/javascripts/_scrollspy.js +0 -163
  163. data/vendor/assets/javascripts/_slider.js +0 -1572
  164. data/vendor/assets/javascripts/_sort.js +0 -1432
  165. data/vendor/assets/javascripts/_swoggle.js +0 -415
  166. data/vendor/assets/javascripts/_tab.js +0 -146
  167. data/vendor/assets/javascripts/_tablespy.js +0 -1883
  168. data/vendor/assets/javascripts/_time_ago.js +0 -206
  169. data/vendor/assets/javascripts/_time_picker.js +0 -1088
  170. data/vendor/assets/javascripts/_tooltip.js +0 -504
  171. data/vendor/assets/javascripts/_transition.js +0 -50
  172. data/vendor/assets/javascripts/_typeahead.js +0 -366
  173. data/vendor/assets/stylesheets/_ad.scss +0 -63
  174. data/vendor/assets/stylesheets/_affix.scss +0 -14
  175. data/vendor/assets/stylesheets/_alert.scss +0 -114
  176. data/vendor/assets/stylesheets/_animation.scss +0 -1370
  177. data/vendor/assets/stylesheets/_breadcrumb.scss +0 -100
  178. data/vendor/assets/stylesheets/_button.scss +0 -386
  179. data/vendor/assets/stylesheets/_canvas.scss +0 -182
  180. data/vendor/assets/stylesheets/_carousel.scss +0 -158
  181. data/vendor/assets/stylesheets/_chart.scss +0 -15
  182. data/vendor/assets/stylesheets/_code.scss +0 -150
  183. data/vendor/assets/stylesheets/_collapse.scss +0 -14
  184. data/vendor/assets/stylesheets/_color.scss +0 -55
  185. data/vendor/assets/stylesheets/_colorpicker.scss +0 -63
  186. data/vendor/assets/stylesheets/_datepicker.scss +0 -122
  187. data/vendor/assets/stylesheets/_dropdown.scss +0 -248
  188. data/vendor/assets/stylesheets/_footer.scss +0 -71
  189. data/vendor/assets/stylesheets/_form.scss +0 -661
  190. data/vendor/assets/stylesheets/_grid.scss +0 -184
  191. data/vendor/assets/stylesheets/_header.scss +0 -156
  192. data/vendor/assets/stylesheets/_icon.scss +0 -362
  193. data/vendor/assets/stylesheets/_image.scss +0 -33
  194. data/vendor/assets/stylesheets/_label_and_badge.scss +0 -104
  195. data/vendor/assets/stylesheets/_link.scss +0 -55
  196. data/vendor/assets/stylesheets/_list.scss +0 -122
  197. data/vendor/assets/stylesheets/_loader.scss +0 -71
  198. data/vendor/assets/stylesheets/_map.scss +0 -44
  199. data/vendor/assets/stylesheets/_missive.scss +0 -74
  200. data/vendor/assets/stylesheets/_modal.scss +0 -204
  201. data/vendor/assets/stylesheets/_nav_and_tab.scss +0 -230
  202. data/vendor/assets/stylesheets/_navbar.scss +0 -73
  203. data/vendor/assets/stylesheets/_pagination.scss +0 -79
  204. data/vendor/assets/stylesheets/_panel.scss +0 -80
  205. data/vendor/assets/stylesheets/_placeholder.scss +0 -63
  206. data/vendor/assets/stylesheets/_popover.scss +0 -128
  207. data/vendor/assets/stylesheets/_progress.scss +0 -86
  208. data/vendor/assets/stylesheets/_reset.scss +0 -140
  209. data/vendor/assets/stylesheets/_sidebar.scss +0 -148
  210. data/vendor/assets/stylesheets/_slider.scss +0 -151
  211. data/vendor/assets/stylesheets/_spinner.scss +0 -572
  212. data/vendor/assets/stylesheets/_subheader.scss +0 -112
  213. data/vendor/assets/stylesheets/_swoggle.scss +0 -120
  214. data/vendor/assets/stylesheets/_table.scss +0 -210
  215. data/vendor/assets/stylesheets/_timepicker.scss +0 -77
  216. data/vendor/assets/stylesheets/_toolbar.scss +0 -130
  217. data/vendor/assets/stylesheets/_tooltip.scss +0 -105
  218. data/vendor/assets/stylesheets/_transition.scss +0 -11
  219. data/vendor/assets/stylesheets/_trunk.scss +0 -147
  220. data/vendor/assets/stylesheets/_typeahead.scss +0 -18
  221. data/vendor/assets/stylesheets/_typography.scss +0 -233
@@ -1,202 +0,0 @@
1
- +function ($) {
2
- 'use strict';
3
-
4
- // COLLAPSE PUBLIC CLASS DEFINITION
5
- // ================================
6
-
7
- var Collapse = function (element, options) {
8
- this.$element = $(element)
9
- this.options = $.extend({}, Collapse.DEFAULTS, options)
10
- this.$trigger = $('[data-toggle="collapse"][href="#' + element.id + '"],' +
11
- '[data-toggle="collapse"][data-target="#' + element.id + '"]')
12
- this.transitioning = null
13
-
14
- if (this.options.parent) {
15
- this.$parent = this.getParent()
16
- } else {
17
- this.addAriaAndCollapsedClass(this.$element, this.$trigger)
18
- }
19
-
20
- if (this.options.toggle) this.toggle()
21
- }
22
-
23
- Collapse.VERSION = '3.3.6'
24
-
25
- Collapse.TRANSITION_DURATION = 350
26
-
27
- Collapse.DEFAULTS = {
28
- toggle: true
29
- }
30
-
31
- Collapse.prototype.dimension = function () {
32
- var hasWidth = this.$element.hasClass('width')
33
- return hasWidth ? 'width' : 'height'
34
- }
35
-
36
- Collapse.prototype.show = function () {
37
- if (this.transitioning || this.$element.hasClass('in')) return
38
-
39
- var activesData
40
- var actives = this.$parent && this.$parent.children('.panel').children('.in, .collapsing')
41
-
42
- if (actives && actives.length) {
43
- activesData = actives.data('bs.collapse')
44
- if (activesData && activesData.transitioning) return
45
- }
46
-
47
- var startEvent = $.Event('show.bs.collapse')
48
- this.$element.trigger(startEvent)
49
- if (startEvent.isDefaultPrevented()) return
50
-
51
- if (actives && actives.length) {
52
- Plugin.call(actives, 'hide')
53
- activesData || actives.data('bs.collapse', null)
54
- }
55
-
56
- var dimension = this.dimension()
57
-
58
- this.$element
59
- .removeClass('collapse')
60
- .addClass('collapsing')[dimension](0)
61
- .attr('aria-expanded', true)
62
-
63
- this.$trigger
64
- .removeClass('collapsed')
65
- .attr('aria-expanded', true)
66
-
67
- this.transitioning = 1
68
-
69
- var complete = function () {
70
- this.$element
71
- .removeClass('collapsing')
72
- .addClass('collapse in')[dimension]('')
73
- this.transitioning = 0
74
- this.$element
75
- .trigger('shown.bs.collapse')
76
- }
77
-
78
- if (!$.support.transition) return complete.call(this)
79
-
80
- var scrollSize = $.camelCase(['scroll', dimension].join('-'))
81
-
82
- this.$element
83
- .one('bsTransitionEnd', $.proxy(complete, this))
84
- .emulateTransitionEnd(Collapse.TRANSITION_DURATION)[dimension](this.$element[0][scrollSize])
85
- }
86
-
87
- Collapse.prototype.hide = function () {
88
- if (this.transitioning || !this.$element.hasClass('in')) return
89
-
90
- var startEvent = $.Event('hide.bs.collapse')
91
- this.$element.trigger(startEvent)
92
- if (startEvent.isDefaultPrevented()) return
93
-
94
- var dimension = this.dimension()
95
-
96
- this.$element[dimension](this.$element[dimension]())[0].offsetHeight
97
-
98
- this.$element
99
- .addClass('collapsing')
100
- .removeClass('collapse in')
101
- .attr('aria-expanded', false)
102
-
103
- this.$trigger
104
- .addClass('collapsed')
105
- .attr('aria-expanded', false)
106
-
107
- this.transitioning = 1
108
-
109
- var complete = function () {
110
- this.transitioning = 0
111
- this.$element
112
- .removeClass('collapsing')
113
- .addClass('collapse')
114
- .trigger('hidden.bs.collapse')
115
- }
116
-
117
- if (!$.support.transition) return complete.call(this)
118
-
119
- this.$element
120
- [dimension](0)
121
- .one('bsTransitionEnd', $.proxy(complete, this))
122
- .emulateTransitionEnd(Collapse.TRANSITION_DURATION)
123
- }
124
-
125
- Collapse.prototype.toggle = function () {
126
- this[this.$element.hasClass('in') ? 'hide' : 'show']()
127
- }
128
-
129
- Collapse.prototype.getParent = function () {
130
- return $(this.options.parent)
131
- .find('[data-toggle="collapse"][data-parent="' + this.options.parent + '"]')
132
- .each($.proxy(function (i, element) {
133
- var $element = $(element)
134
- this.addAriaAndCollapsedClass(getTargetFromTrigger($element), $element)
135
- }, this))
136
- .end()
137
- }
138
-
139
- Collapse.prototype.addAriaAndCollapsedClass = function ($element, $trigger) {
140
- var isOpen = $element.hasClass('in')
141
-
142
- $element.attr('aria-expanded', isOpen)
143
- $trigger
144
- .toggleClass('collapsed', !isOpen)
145
- .attr('aria-expanded', isOpen)
146
- }
147
-
148
- function getTargetFromTrigger($trigger) {
149
- var href
150
- var target = $trigger.attr('data-target')
151
- || (href = $trigger.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') // strip for ie7
152
-
153
- return $(target)
154
- }
155
-
156
-
157
- // COLLAPSE PLUGIN DEFINITION
158
- // ==========================
159
-
160
- function Plugin(option) {
161
- return this.each(function () {
162
- var $this = $(this)
163
- var data = $this.data('bs.collapse')
164
- var options = $.extend({}, Collapse.DEFAULTS, $this.data(), typeof option == 'object' && option)
165
-
166
- if (!data && options.toggle && /show|hide/.test(option)) options.toggle = false
167
- if (!data) $this.data('bs.collapse', (data = new Collapse(this, options)))
168
- if (typeof option == 'string') data[option]()
169
- })
170
- }
171
-
172
- var old = $.fn.collapse
173
-
174
- $.fn.collapse = Plugin
175
- $.fn.collapse.Constructor = Collapse
176
-
177
-
178
- // COLLAPSE NO CONFLICT
179
- // ====================
180
-
181
- $.fn.collapse.noConflict = function () {
182
- $.fn.collapse = old
183
- return this
184
- }
185
-
186
-
187
- // COLLAPSE DATA-API
188
- // =================
189
-
190
- $(document).on('click.bs.collapse.data-api', '[data-toggle="collapse"]', function (e) {
191
- var $this = $(this)
192
-
193
- if (!$this.attr('data-target')) e.preventDefault()
194
-
195
- var $target = getTargetFromTrigger($this)
196
- var data = $target.data('bs.collapse')
197
- var option = data ? 'toggle' : $this.data()
198
-
199
- Plugin.call($target, option)
200
- })
201
-
202
- }(jQuery);
@@ -1,108 +0,0 @@
1
- (function($) {"use strict";
2
- var ColorPicker = function(select, options) {
3
- this.options = options;
4
- this.$select = $(select);
5
- this._init();
6
- };
7
-
8
- ColorPicker.prototype = {
9
- constructor : ColorPicker,
10
-
11
- _init : function() {
12
- var callback = this.options.callback;
13
- var dropdown = this.options.dropdown;
14
- var tooltip = this.options.tooltip;
15
- var selectValue = this.$select.val();
16
- var selectColor = this.$select.find("option:selected").data("color");
17
-
18
- var $markupUl = $("<ul>").addClass(dropdown);
19
- var $markupDiv = $("<div>").addClass("dropdown dropdown-colorpicker");
20
- var $markupSpan = $("<span>").addClass("dropdown-swatch").css("background", selectColor);
21
- var $markupA = $("<a>").attr("data-toggle", "dropdown").attr("href", "#").addClass("dropdown-toggle").append($markupSpan);
22
-
23
- $("option", this.$select).each(function() {
24
- var option = $(this);
25
- var value = option.attr("value");
26
- var color = option.data("color");
27
- var title = option.text();
28
-
29
- var $markupA = $("<a>").addClass("colorpicker-swatch ").addClass(tooltip);
30
- if (option.prop("selected") === true || selectValue === color) {
31
- $markupA.addClass("selected");
32
- }
33
- $markupA.css("background", color);
34
- $markupA.attr("href", "#").attr("data-color", color).attr("data-value", value).attr("title", title);
35
-
36
- $markupUl.append($("<li>").append($markupA));
37
- });
38
-
39
- $markupDiv.append($markupA);
40
- $markupDiv.append($markupUl);
41
-
42
- this.$select.hide();
43
- this.$selector = $($markupDiv).insertAfter(this.$select);
44
- this.$select.on("change", function() {
45
- var value = $(this).val();
46
- var color = $(this).find("option[value='" + value + "']").data("color");
47
- var title = $(this).find("option[value='" + value + "']").text();
48
-
49
- $(this).next().find("ul").find("li").find(".selected").removeClass("selected");
50
- $(this).next().find("ul").find("li").find("a[data-color='" + color + "']").addClass("selected");
51
- $(this).next().find(".dropdown-swatch").css("background", color);
52
-
53
- callback(value, color, title);
54
- });
55
-
56
- $markupUl.on('click.colorpicker', $.proxy(this._clickColor, this));
57
- },
58
-
59
- _clickColor : function(e) {
60
- var a = $(e.target);
61
-
62
- if (!a.is(".colorpicker-swatch")) {
63
- return false;
64
- }
65
-
66
- this.$select.val(a.data("value")).change();
67
-
68
- e.preventDefault();
69
- return true;
70
- },
71
-
72
- setColor : function(color) {
73
- var value = $(this.$selector).find("li").find("a[data-color='" + color + "']").data("value");
74
- this.setValue(value);
75
- },
76
-
77
- setValue : function(value) {
78
- this.$select.val(value).change();
79
- },
80
-
81
- };
82
-
83
- $.fn.colorpicker = function(option) {
84
- var args = Array.apply(null, arguments);
85
- args.shift();
86
-
87
- return this.each(function() {
88
- var $this = $(this), data = $this.data("colorpicker"), options = $.extend({}, $.fn.colorpicker.defaults, $this.data(), typeof option == "object" && option);
89
-
90
- if (!data) {
91
- $this.data("colorpicker", (data = new ColorPicker(this, options)));
92
- }
93
-
94
- if (typeof option == "string") {
95
- data[option].apply(data, args);
96
- }
97
- });
98
- };
99
-
100
- $.fn.colorpicker.defaults = {
101
- callback : function(value, color, title) {},
102
- dropdown: "dropdown-menu dropdown-caret",
103
- tooltip: null
104
- };
105
-
106
- $.fn.colorpicker.Constructor = ColorPicker;
107
-
108
- })(jQuery, window, document);
@@ -1,1650 +0,0 @@
1
- (function($, undefined){
2
-
3
- var $window = $(window);
4
-
5
- function UTCDate(){
6
- return new Date(Date.UTC.apply(Date, arguments));
7
- }
8
- function UTCToday(){
9
- var today = new Date();
10
- return UTCDate(today.getFullYear(), today.getMonth(), today.getDate());
11
- }
12
- function alias(method){
13
- return function(){
14
- return this[method].apply(this, arguments);
15
- };
16
- }
17
-
18
- var DateArray = (function(){
19
- var extras = {
20
- get: function(i){
21
- return this.slice(i)[0];
22
- },
23
- contains: function(d){
24
- // Array.indexOf is not cross-browser;
25
- // $.inArray doesn't work with Dates
26
- var val = d && d.valueOf();
27
- for (var i=0, l=this.length; i < l; i++)
28
- if (this[i].valueOf() === val)
29
- return i;
30
- return -1;
31
- },
32
- remove: function(i){
33
- this.splice(i,1);
34
- },
35
- replace: function(new_array){
36
- if (!new_array)
37
- return;
38
- if (!$.isArray(new_array))
39
- new_array = [new_array];
40
- this.clear();
41
- this.push.apply(this, new_array);
42
- },
43
- clear: function(){
44
- this.length = 0;
45
- },
46
- copy: function(){
47
- var a = new DateArray();
48
- a.replace(this);
49
- return a;
50
- }
51
- };
52
-
53
- return function(){
54
- var a = [];
55
- a.push.apply(a, arguments);
56
- $.extend(a, extras);
57
- return a;
58
- };
59
- })();
60
-
61
-
62
- // Picker object
63
-
64
- var Datepicker = function(element, options){
65
- this.dates = new DateArray();
66
- this.viewDate = UTCToday();
67
- this.focusDate = null;
68
-
69
- this._process_options(options);
70
-
71
- this.element = $(element);
72
- this.isInline = false;
73
- this.isInput = this.element.is('input');
74
- this.component = this.element.is('.date') ? this.element.find('.add-on, .input-group-addon, .btn') : false;
75
- this.hasInput = this.component && this.element.find('input').length;
76
- if (this.component && this.component.length === 0)
77
- this.component = false;
78
-
79
- this.picker = $(DPGlobal.template);
80
- this._buildEvents();
81
- this._attachEvents();
82
-
83
- if (this.isInline){
84
- this.picker.addClass('datepicker-inline').appendTo(this.element);
85
- }
86
- else {
87
- this.picker.addClass(this.o.dropdown);
88
- }
89
-
90
- if (this.o.rtl){
91
- this.picker.addClass('datepicker-rtl');
92
- }
93
-
94
- this.viewMode = this.o.startView;
95
-
96
- if (this.o.calendarWeeks)
97
- this.picker.find('tfoot th.today')
98
- .attr('colspan', function(i, val){
99
- return parseInt(val) + 1;
100
- });
101
-
102
- this._allow_update = false;
103
-
104
- this.setStartDate(this._o.startDate);
105
- this.setEndDate(this._o.endDate);
106
- this.setDaysOfWeekDisabled(this.o.daysOfWeekDisabled);
107
-
108
- this.fillDow();
109
- this.fillMonths();
110
-
111
- this._allow_update = true;
112
-
113
- this.update();
114
- this.showMode();
115
-
116
- if (this.isInline){
117
- this.show();
118
- }
119
- };
120
-
121
- Datepicker.prototype = {
122
- constructor: Datepicker,
123
-
124
- _process_options: function(opts){
125
- // Store raw options for reference
126
- this._o = $.extend({}, this._o, opts);
127
- // Processed options
128
- var o = this.o = $.extend({}, this._o);
129
-
130
- // Check if "de-DE" style date is available, if not language should
131
- // fallback to 2 letter code eg "de"
132
- var lang = o.language;
133
- if (!dates[lang]){
134
- lang = lang.split('-')[0];
135
- if (!dates[lang])
136
- lang = defaults.language;
137
- }
138
- o.language = lang;
139
-
140
- switch (o.startView){
141
- case 2:
142
- case 'decade':
143
- o.startView = 2;
144
- break;
145
- case 1:
146
- case 'year':
147
- o.startView = 1;
148
- break;
149
- default:
150
- o.startView = 0;
151
- }
152
-
153
- switch (o.minViewMode){
154
- case 1:
155
- case 'months':
156
- o.minViewMode = 1;
157
- break;
158
- case 2:
159
- case 'years':
160
- o.minViewMode = 2;
161
- break;
162
- default:
163
- o.minViewMode = 0;
164
- }
165
-
166
- o.startView = Math.max(o.startView, o.minViewMode);
167
-
168
- // true, false, or Number > 0
169
- if (o.multidate !== true){
170
- o.multidate = Number(o.multidate) || false;
171
- if (o.multidate !== false)
172
- o.multidate = Math.max(0, o.multidate);
173
- else
174
- o.multidate = 1;
175
- }
176
- o.multidateSeparator = String(o.multidateSeparator);
177
-
178
- o.weekStart %= 7;
179
- o.weekEnd = ((o.weekStart + 6) % 7);
180
-
181
- var format = DPGlobal.parseFormat(o.format);
182
- if (o.startDate !== -Infinity){
183
- if (!!o.startDate){
184
- if (o.startDate instanceof Date)
185
- o.startDate = this._local_to_utc(this._zero_time(o.startDate));
186
- else
187
- o.startDate = DPGlobal.parseDate(o.startDate, format, o.language);
188
- }
189
- else {
190
- o.startDate = -Infinity;
191
- }
192
- }
193
- if (o.endDate !== Infinity){
194
- if (!!o.endDate){
195
- if (o.endDate instanceof Date)
196
- o.endDate = this._local_to_utc(this._zero_time(o.endDate));
197
- else
198
- o.endDate = DPGlobal.parseDate(o.endDate, format, o.language);
199
- }
200
- else {
201
- o.endDate = Infinity;
202
- }
203
- }
204
-
205
- o.daysOfWeekDisabled = o.daysOfWeekDisabled||[];
206
- if (!$.isArray(o.daysOfWeekDisabled))
207
- o.daysOfWeekDisabled = o.daysOfWeekDisabled.split(/[,\s]*/);
208
- o.daysOfWeekDisabled = $.map(o.daysOfWeekDisabled, function(d){
209
- return parseInt(d, 10);
210
- });
211
-
212
- var plc = String(o.orientation).toLowerCase().split(/\s+/g),
213
- _plc = o.orientation.toLowerCase();
214
- plc = $.grep(plc, function(word){
215
- return (/^auto|left|right|top|bottom$/).test(word);
216
- });
217
- o.orientation = {x: 'auto', y: 'auto'};
218
- if (!_plc || _plc === 'auto')
219
- ; // no action
220
- else if (plc.length === 1){
221
- switch (plc[0]){
222
- case 'top':
223
- case 'bottom':
224
- o.orientation.y = plc[0];
225
- break;
226
- case 'left':
227
- case 'right':
228
- o.orientation.x = plc[0];
229
- break;
230
- }
231
- }
232
- else {
233
- _plc = $.grep(plc, function(word){
234
- return (/^left|right$/).test(word);
235
- });
236
- o.orientation.x = _plc[0] || 'auto';
237
-
238
- _plc = $.grep(plc, function(word){
239
- return (/^top|bottom$/).test(word);
240
- });
241
- o.orientation.y = _plc[0] || 'auto';
242
- }
243
- },
244
- _events: [],
245
- _secondaryEvents: [],
246
- _applyEvents: function(evs){
247
- for (var i=0, el, ch, ev; i < evs.length; i++){
248
- el = evs[i][0];
249
- if (evs[i].length === 2){
250
- ch = undefined;
251
- ev = evs[i][1];
252
- }
253
- else if (evs[i].length === 3){
254
- ch = evs[i][1];
255
- ev = evs[i][2];
256
- }
257
- el.on(ev, ch);
258
- }
259
- },
260
- _unapplyEvents: function(evs){
261
- for (var i=0, el, ev, ch; i < evs.length; i++){
262
- el = evs[i][0];
263
- if (evs[i].length === 2){
264
- ch = undefined;
265
- ev = evs[i][1];
266
- }
267
- else if (evs[i].length === 3){
268
- ch = evs[i][1];
269
- ev = evs[i][2];
270
- }
271
- el.off(ev, ch);
272
- }
273
- },
274
- _buildEvents: function(){
275
- if (this.isInput){ // single input
276
- this._events = [
277
- [this.element, {
278
- focus: $.proxy(this.show, this),
279
- keyup: $.proxy(function(e){
280
- if ($.inArray(e.keyCode, [27,37,39,38,40,32,13,9]) === -1)
281
- this.update();
282
- }, this),
283
- keydown: $.proxy(this.keydown, this)
284
- }]
285
- ];
286
- }
287
- else if (this.component && this.hasInput){ // component: input + button
288
- this._events = [
289
- // For components that are not readonly, allow keyboard nav
290
- [this.element.find('input'), {
291
- focus: $.proxy(this.show, this),
292
- keyup: $.proxy(function(e){
293
- if ($.inArray(e.keyCode, [27,37,39,38,40,32,13,9]) === -1)
294
- this.update();
295
- }, this),
296
- keydown: $.proxy(this.keydown, this)
297
- }],
298
- [this.component, {
299
- click: $.proxy(this.show, this)
300
- }]
301
- ];
302
- }
303
- else if (this.element.is('div')){ // inline datepicker
304
- this.isInline = true;
305
- }
306
- else {
307
- this._events = [
308
- [this.element, {
309
- click: $.proxy(this.show, this)
310
- }]
311
- ];
312
- }
313
- this._events.push(
314
- // Component: listen for blur on element descendants
315
- [this.element, '*', {
316
- blur: $.proxy(function(e){
317
- this._focused_from = e.target;
318
- }, this)
319
- }],
320
- // Input: listen for blur on element
321
- [this.element, {
322
- blur: $.proxy(function(e){
323
- this._focused_from = e.target;
324
- }, this)
325
- }]
326
- );
327
-
328
- this._secondaryEvents = [
329
- [this.picker, {
330
- click: $.proxy(this.click, this)
331
- }],
332
- [$(window), {
333
- resize: $.proxy(this.place, this)
334
- }],
335
- [$(document), {
336
- 'mousedown touchstart': $.proxy(function(e){
337
- // Clicked outside the datepicker, hide it
338
- if (!(
339
- this.element.is(e.target) ||
340
- this.element.find(e.target).length ||
341
- this.picker.is(e.target) ||
342
- this.picker.find(e.target).length
343
- )){
344
- this.hide();
345
- }
346
- }, this)
347
- }]
348
- ];
349
- },
350
- _attachEvents: function(){
351
- this._detachEvents();
352
- this._applyEvents(this._events);
353
- },
354
- _detachEvents: function(){
355
- this._unapplyEvents(this._events);
356
- },
357
- _attachSecondaryEvents: function(){
358
- this._detachSecondaryEvents();
359
- this._applyEvents(this._secondaryEvents);
360
- },
361
- _detachSecondaryEvents: function(){
362
- this._unapplyEvents(this._secondaryEvents);
363
- },
364
- _trigger: function(event, altdate){
365
- var date = altdate || this.dates.get(-1),
366
- local_date = this._utc_to_local(date);
367
-
368
- this.element.trigger({
369
- type: event,
370
- date: local_date,
371
- dates: $.map(this.dates, this._utc_to_local),
372
- format: $.proxy(function(ix, format){
373
- if (arguments.length === 0){
374
- ix = this.dates.length - 1;
375
- format = this.o.format;
376
- }
377
- else if (typeof ix === 'string'){
378
- format = ix;
379
- ix = this.dates.length - 1;
380
- }
381
- format = format || this.o.format;
382
- var date = this.dates.get(ix);
383
- return DPGlobal.formatDate(date, format, this.o.language);
384
- }, this)
385
- });
386
- },
387
-
388
- show: function(){
389
- if (!this.isInline)
390
- this.picker.appendTo('body');
391
- this.picker.show();
392
- this.place();
393
- this._attachSecondaryEvents();
394
- this._trigger('show');
395
- },
396
-
397
- hide: function(){
398
- if (this.isInline)
399
- return;
400
- if (!this.picker.is(':visible'))
401
- return;
402
- this.focusDate = null;
403
- this.picker.hide().detach();
404
- this._detachSecondaryEvents();
405
- this.viewMode = this.o.startView;
406
- this.showMode();
407
-
408
- if (
409
- this.o.forceParse &&
410
- (
411
- this.isInput && this.element.val() ||
412
- this.hasInput && this.element.find('input').val()
413
- )
414
- )
415
- this.setValue();
416
- this._trigger('hide');
417
- },
418
-
419
- remove: function(){
420
- this.hide();
421
- this._detachEvents();
422
- this._detachSecondaryEvents();
423
- this.picker.remove();
424
- delete this.element.data().datepicker;
425
- if (!this.isInput){
426
- delete this.element.data().date;
427
- }
428
- },
429
-
430
- _utc_to_local: function(utc){
431
- return utc && new Date(utc.getTime() + (utc.getTimezoneOffset()*60000));
432
- },
433
- _local_to_utc: function(local){
434
- return local && new Date(local.getTime() - (local.getTimezoneOffset()*60000));
435
- },
436
- _zero_time: function(local){
437
- return local && new Date(local.getFullYear(), local.getMonth(), local.getDate());
438
- },
439
- _zero_utc_time: function(utc){
440
- return utc && new Date(Date.UTC(utc.getUTCFullYear(), utc.getUTCMonth(), utc.getUTCDate()));
441
- },
442
-
443
- getDates: function(){
444
- return $.map(this.dates, this._utc_to_local);
445
- },
446
-
447
- getUTCDates: function(){
448
- return $.map(this.dates, function(d){
449
- return new Date(d);
450
- });
451
- },
452
-
453
- getDate: function(){
454
- return this._utc_to_local(this.getUTCDate());
455
- },
456
-
457
- getUTCDate: function(){
458
- return new Date(this.dates.get(-1));
459
- },
460
-
461
- setDates: function(){
462
- var args = $.isArray(arguments[0]) ? arguments[0] : arguments;
463
- this.update.apply(this, args);
464
- this._trigger('changeDate');
465
- this.setValue();
466
- },
467
-
468
- setUTCDates: function(){
469
- var args = $.isArray(arguments[0]) ? arguments[0] : arguments;
470
- this.update.apply(this, $.map(args, this._utc_to_local));
471
- this._trigger('changeDate');
472
- this.setValue();
473
- },
474
-
475
- setDate: alias('setDates'),
476
- setUTCDate: alias('setUTCDates'),
477
-
478
- setValue: function(){
479
- var formatted = this.getFormattedDate();
480
- if (!this.isInput){
481
- if (this.component){
482
- this.element.find('input').val(formatted).change();
483
- }
484
- }
485
- else {
486
- this.element.val(formatted).change();
487
- }
488
- },
489
-
490
- getFormattedDate: function(format){
491
- if (format === undefined)
492
- format = this.o.format;
493
-
494
- var lang = this.o.language;
495
- return $.map(this.dates, function(d){
496
- return DPGlobal.formatDate(d, format, lang);
497
- }).join(this.o.multidateSeparator);
498
- },
499
-
500
- setStartDate: function(startDate){
501
- this._process_options({startDate: startDate});
502
- this.update();
503
- this.updateNavArrows();
504
- },
505
-
506
- setEndDate: function(endDate){
507
- this._process_options({endDate: endDate});
508
- this.update();
509
- this.updateNavArrows();
510
- },
511
-
512
- setDaysOfWeekDisabled: function(daysOfWeekDisabled){
513
- this._process_options({daysOfWeekDisabled: daysOfWeekDisabled});
514
- this.update();
515
- this.updateNavArrows();
516
- },
517
-
518
- place: function(){
519
- if (this.isInline)
520
- return;
521
- var calendarWidth = this.picker.outerWidth(),
522
- calendarHeight = this.picker.outerHeight(),
523
- visualPadding = 10,
524
- windowWidth = $window.width(),
525
- windowHeight = $window.height(),
526
- scrollTop = $window.scrollTop();
527
-
528
- var zIndex = parseInt(this.element.parents().filter(function(){
529
- return $(this).css('z-index') !== 'auto';
530
- }).first().css('z-index'))+10;
531
- var offset = this.component ? this.component.parent().offset() : this.element.offset();
532
- var height = this.component ? this.component.outerHeight(true) : this.element.outerHeight(false);
533
- var width = this.component ? this.component.outerWidth(true) : this.element.outerWidth(false);
534
- var left = offset.left,
535
- top = offset.top;
536
-
537
- this.picker.removeClass(
538
- 'datepicker-orient-top datepicker-orient-bottom '+
539
- 'datepicker-orient-right datepicker-orient-left'
540
- );
541
-
542
- if (this.o.orientation.x !== 'auto'){
543
- this.picker.addClass('datepicker-orient-' + this.o.orientation.x);
544
- if (this.o.orientation.x === 'right')
545
- left -= calendarWidth - width;
546
- }
547
- // auto x orientation is best-placement: if it crosses a window
548
- // edge, fudge it sideways
549
- else {
550
- // Default to left
551
- this.picker.addClass('datepicker-orient-left');
552
- if (offset.left < 0)
553
- left -= offset.left - visualPadding;
554
- else if (offset.left + calendarWidth > windowWidth)
555
- left = windowWidth - calendarWidth - visualPadding;
556
- }
557
-
558
- // auto y orientation is best-situation: top or bottom, no fudging,
559
- // decision based on which shows more of the calendar
560
- var yorient = this.o.orientation.y,
561
- top_overflow, bottom_overflow;
562
- if (yorient === 'auto'){
563
- top_overflow = -scrollTop + offset.top - calendarHeight;
564
- bottom_overflow = scrollTop + windowHeight - (offset.top + height + calendarHeight);
565
- if (Math.max(top_overflow, bottom_overflow) === bottom_overflow)
566
- yorient = 'top';
567
- else
568
- yorient = 'bottom';
569
- }
570
- this.picker.addClass('datepicker-orient-' + yorient);
571
- if (yorient === 'top')
572
- top += height;
573
- else
574
- top -= calendarHeight + parseInt(this.picker.css('padding-top'));
575
-
576
- this.picker.css({
577
- top: top,
578
- left: left,
579
- zIndex: zIndex
580
- });
581
- },
582
-
583
- _allow_update: true,
584
- update: function(){
585
- if (!this._allow_update)
586
- return;
587
-
588
- var oldDates = this.dates.copy(),
589
- dates = [],
590
- fromArgs = false;
591
- if (arguments.length){
592
- $.each(arguments, $.proxy(function(i, date){
593
- if (date instanceof Date)
594
- date = this._local_to_utc(date);
595
- dates.push(date);
596
- }, this));
597
- fromArgs = true;
598
- }
599
- else {
600
- dates = this.isInput
601
- ? this.element.val()
602
- : this.element.data('date') || this.element.find('input').val();
603
- if (dates && this.o.multidate)
604
- dates = dates.split(this.o.multidateSeparator);
605
- else
606
- dates = [dates];
607
- delete this.element.data().date;
608
- }
609
-
610
- dates = $.map(dates, $.proxy(function(date){
611
- return DPGlobal.parseDate(date, this.o.format, this.o.language);
612
- }, this));
613
- dates = $.grep(dates, $.proxy(function(date){
614
- return (
615
- date < this.o.startDate ||
616
- date > this.o.endDate ||
617
- !date
618
- );
619
- }, this), true);
620
- this.dates.replace(dates);
621
-
622
- if (this.dates.length)
623
- this.viewDate = new Date(this.dates.get(-1));
624
- else if (this.viewDate < this.o.startDate)
625
- this.viewDate = new Date(this.o.startDate);
626
- else if (this.viewDate > this.o.endDate)
627
- this.viewDate = new Date(this.o.endDate);
628
-
629
- if (fromArgs){
630
- // setting date by clicking
631
- this.setValue();
632
- }
633
- else if (dates.length){
634
- // setting date by typing
635
- if (String(oldDates) !== String(this.dates))
636
- this._trigger('changeDate');
637
- }
638
- if (!this.dates.length && oldDates.length)
639
- this._trigger('clearDate');
640
-
641
- this.fill();
642
- },
643
-
644
- fillDow: function(){
645
- var dowCnt = this.o.weekStart,
646
- html = '<tr>';
647
- if (this.o.calendarWeeks){
648
- var cell = '<th class="cw">&nbsp;</th>';
649
- html += cell;
650
- this.picker.find('.datepicker-days thead tr:first-child').prepend(cell);
651
- }
652
- while (dowCnt < this.o.weekStart + 7){
653
- html += '<th class="dow">'+dates[this.o.language].daysMin[(dowCnt++)%7]+'</th>';
654
- }
655
- html += '</tr>';
656
- this.picker.find('.datepicker-days thead').append(html);
657
- },
658
-
659
- fillMonths: function(){
660
- var html = '',
661
- i = 0;
662
- while (i < 12){
663
- html += '<span class="month">'+dates[this.o.language].monthsShort[i++]+'</span>';
664
- }
665
- this.picker.find('.datepicker-months td').html(html);
666
- },
667
-
668
- setRange: function(range){
669
- if (!range || !range.length)
670
- delete this.range;
671
- else
672
- this.range = $.map(range, function(d){
673
- return d.valueOf();
674
- });
675
- this.fill();
676
- },
677
-
678
- getClassNames: function(date){
679
- var cls = [],
680
- year = this.viewDate.getUTCFullYear(),
681
- month = this.viewDate.getUTCMonth(),
682
- today = new Date();
683
- if (date.getUTCFullYear() < year || (date.getUTCFullYear() === year && date.getUTCMonth() < month)){
684
- cls.push('old');
685
- }
686
- else if (date.getUTCFullYear() > year || (date.getUTCFullYear() === year && date.getUTCMonth() > month)){
687
- cls.push('new');
688
- }
689
- if (this.focusDate && date.valueOf() === this.focusDate.valueOf())
690
- cls.push('focused');
691
- // Compare internal UTC date with local today, not UTC today
692
- if (this.o.todayHighlight &&
693
- date.getUTCFullYear() === today.getFullYear() &&
694
- date.getUTCMonth() === today.getMonth() &&
695
- date.getUTCDate() === today.getDate()){
696
- cls.push('today');
697
- }
698
- if (this.dates.contains(date) !== -1)
699
- cls.push('active');
700
- if (date.valueOf() < this.o.startDate || date.valueOf() > this.o.endDate ||
701
- $.inArray(date.getUTCDay(), this.o.daysOfWeekDisabled) !== -1){
702
- cls.push('disabled');
703
- }
704
- if (this.range){
705
- if (date > this.range[0] && date < this.range[this.range.length-1]){
706
- cls.push('range');
707
- }
708
- if ($.inArray(date.valueOf(), this.range) !== -1){
709
- cls.push('selected');
710
- }
711
- }
712
- return cls;
713
- },
714
-
715
- fill: function(){
716
- var d = new Date(this.viewDate),
717
- year = d.getUTCFullYear(),
718
- month = d.getUTCMonth(),
719
- startYear = this.o.startDate !== -Infinity ? this.o.startDate.getUTCFullYear() : -Infinity,
720
- startMonth = this.o.startDate !== -Infinity ? this.o.startDate.getUTCMonth() : -Infinity,
721
- endYear = this.o.endDate !== Infinity ? this.o.endDate.getUTCFullYear() : Infinity,
722
- endMonth = this.o.endDate !== Infinity ? this.o.endDate.getUTCMonth() : Infinity,
723
- todaytxt = dates[this.o.language].today || dates['en'].today || '',
724
- cleartxt = dates[this.o.language].clear || dates['en'].clear || '',
725
- tooltip;
726
- this.picker.find('.datepicker-days thead th.datepicker-switch')
727
- .text(dates[this.o.language].months[month]+' '+year);
728
- this.picker.find('tfoot th.today')
729
- .text(todaytxt)
730
- .toggle(this.o.todayBtn !== false);
731
- this.picker.find('tfoot th.clear')
732
- .text(cleartxt)
733
- .toggle(this.o.clearBtn !== false);
734
- this.updateNavArrows();
735
- this.fillMonths();
736
- var prevMonth = UTCDate(year, month-1, 28),
737
- day = DPGlobal.getDaysInMonth(prevMonth.getUTCFullYear(), prevMonth.getUTCMonth());
738
- prevMonth.setUTCDate(day);
739
- prevMonth.setUTCDate(day - (prevMonth.getUTCDay() - this.o.weekStart + 7)%7);
740
- var nextMonth = new Date(prevMonth);
741
- nextMonth.setUTCDate(nextMonth.getUTCDate() + 42);
742
- nextMonth = nextMonth.valueOf();
743
- var html = [];
744
- var clsName;
745
- while (prevMonth.valueOf() < nextMonth){
746
- if (prevMonth.getUTCDay() === this.o.weekStart){
747
- html.push('<tr>');
748
- if (this.o.calendarWeeks){
749
- // ISO 8601: First week contains first thursday.
750
- // ISO also states week starts on Monday, but we can be more abstract here.
751
- var
752
- // Start of current week: based on weekstart/current date
753
- ws = new Date(+prevMonth + (this.o.weekStart - prevMonth.getUTCDay() - 7) % 7 * 864e5),
754
- // Thursday of this week
755
- th = new Date(Number(ws) + (7 + 4 - ws.getUTCDay()) % 7 * 864e5),
756
- // First Thursday of year, year from thursday
757
- yth = new Date(Number(yth = UTCDate(th.getUTCFullYear(), 0, 1)) + (7 + 4 - yth.getUTCDay())%7*864e5),
758
- // Calendar week: ms between thursdays, div ms per day, div 7 days
759
- calWeek = (th - yth) / 864e5 / 7 + 1;
760
- html.push('<td class="cw">'+ calWeek +'</td>');
761
-
762
- }
763
- }
764
- clsName = this.getClassNames(prevMonth);
765
- clsName.push('day');
766
-
767
- if (this.o.beforeShowDay !== $.noop){
768
- var before = this.o.beforeShowDay(this._utc_to_local(prevMonth));
769
- if (before === undefined)
770
- before = {};
771
- else if (typeof(before) === 'boolean')
772
- before = {enabled: before};
773
- else if (typeof(before) === 'string')
774
- before = {classes: before};
775
- if (before.enabled === false)
776
- clsName.push('disabled');
777
- if (before.classes)
778
- clsName = clsName.concat(before.classes.split(/\s+/));
779
- if (before.tooltip)
780
- tooltip = before.tooltip;
781
- }
782
-
783
- clsName = $.unique(clsName);
784
- html.push('<td class="'+clsName.join(' ')+'"' + (tooltip ? ' title="'+tooltip+'"' : '') + '>'+prevMonth.getUTCDate() + '</td>');
785
- if (prevMonth.getUTCDay() === this.o.weekEnd){
786
- html.push('</tr>');
787
- }
788
- prevMonth.setUTCDate(prevMonth.getUTCDate()+1);
789
- }
790
- this.picker.find('.datepicker-days tbody').empty().append(html.join(''));
791
-
792
- var months = this.picker.find('.datepicker-months')
793
- .find('th:eq(1)')
794
- .text(year)
795
- .end()
796
- .find('span').removeClass('active');
797
-
798
- $.each(this.dates, function(i, d){
799
- if (d.getUTCFullYear() === year)
800
- months.eq(d.getUTCMonth()).addClass('active');
801
- });
802
-
803
- if (year < startYear || year > endYear){
804
- months.addClass('disabled');
805
- }
806
- if (year === startYear){
807
- months.slice(0, startMonth).addClass('disabled');
808
- }
809
- if (year === endYear){
810
- months.slice(endMonth+1).addClass('disabled');
811
- }
812
-
813
- html = '';
814
- year = parseInt(year/10, 10) * 10;
815
- var yearCont = this.picker.find('.datepicker-years')
816
- .find('th:eq(1)')
817
- .text(year + '-' + (year + 9))
818
- .end()
819
- .find('td');
820
- year -= 1;
821
- var years = $.map(this.dates, function(d){
822
- return d.getUTCFullYear();
823
- }),
824
- classes;
825
- for (var i = -1; i < 11; i++){
826
- classes = ['year'];
827
- if (i === -1)
828
- classes.push('old');
829
- else if (i === 10)
830
- classes.push('new');
831
- if ($.inArray(year, years) !== -1)
832
- classes.push('active');
833
- if (year < startYear || year > endYear)
834
- classes.push('disabled');
835
- html += '<span class="' + classes.join(' ') + '">'+year+'</span>';
836
- year += 1;
837
- }
838
- yearCont.html(html);
839
- },
840
-
841
- updateNavArrows: function(){
842
- if (!this._allow_update)
843
- return;
844
-
845
- var d = new Date(this.viewDate),
846
- year = d.getUTCFullYear(),
847
- month = d.getUTCMonth();
848
- switch (this.viewMode){
849
- case 0:
850
- if (this.o.startDate !== -Infinity && year <= this.o.startDate.getUTCFullYear() && month <= this.o.startDate.getUTCMonth()){
851
- this.picker.find('.prev').css({visibility: 'hidden'});
852
- }
853
- else {
854
- this.picker.find('.prev').css({visibility: 'visible'});
855
- }
856
- if (this.o.endDate !== Infinity && year >= this.o.endDate.getUTCFullYear() && month >= this.o.endDate.getUTCMonth()){
857
- this.picker.find('.next').css({visibility: 'hidden'});
858
- }
859
- else {
860
- this.picker.find('.next').css({visibility: 'visible'});
861
- }
862
- break;
863
- case 1:
864
- case 2:
865
- if (this.o.startDate !== -Infinity && year <= this.o.startDate.getUTCFullYear()){
866
- this.picker.find('.prev').css({visibility: 'hidden'});
867
- }
868
- else {
869
- this.picker.find('.prev').css({visibility: 'visible'});
870
- }
871
- if (this.o.endDate !== Infinity && year >= this.o.endDate.getUTCFullYear()){
872
- this.picker.find('.next').css({visibility: 'hidden'});
873
- }
874
- else {
875
- this.picker.find('.next').css({visibility: 'visible'});
876
- }
877
- break;
878
- }
879
- },
880
-
881
- click: function(e){
882
- e.preventDefault();
883
- var target = $(e.target).closest('span, td, th'),
884
- year, month, day;
885
- if (target.length === 1){
886
- switch (target[0].nodeName.toLowerCase()){
887
- case 'th':
888
- switch (target[0].className){
889
- case 'datepicker-switch':
890
- this.showMode(1);
891
- break;
892
- case 'prev':
893
- case 'next':
894
- var dir = DPGlobal.modes[this.viewMode].navStep * (target[0].className === 'prev' ? -1 : 1);
895
- switch (this.viewMode){
896
- case 0:
897
- this.viewDate = this.moveMonth(this.viewDate, dir);
898
- this._trigger('changeMonth', this.viewDate);
899
- break;
900
- case 1:
901
- case 2:
902
- this.viewDate = this.moveYear(this.viewDate, dir);
903
- if (this.viewMode === 1)
904
- this._trigger('changeYear', this.viewDate);
905
- break;
906
- }
907
- this.fill();
908
- break;
909
- case 'today':
910
- var date = new Date();
911
- date = UTCDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
912
-
913
- this.showMode(-2);
914
- var which = this.o.todayBtn === 'linked' ? null : 'view';
915
- this._setDate(date, which);
916
- break;
917
- case 'clear':
918
- var element;
919
- if (this.isInput)
920
- element = this.element;
921
- else if (this.component)
922
- element = this.element.find('input');
923
- if (element)
924
- element.val("").change();
925
- this.update();
926
- this._trigger('changeDate');
927
- if (this.o.autoclose)
928
- this.hide();
929
- break;
930
- }
931
- break;
932
- case 'span':
933
- if (!target.is('.disabled')){
934
- this.viewDate.setUTCDate(1);
935
- if (target.is('.month')){
936
- day = 1;
937
- month = target.parent().find('span').index(target);
938
- year = this.viewDate.getUTCFullYear();
939
- this.viewDate.setUTCMonth(month);
940
- this._trigger('changeMonth', this.viewDate);
941
- if (this.o.minViewMode === 1){
942
- this._setDate(UTCDate(year, month, day));
943
- }
944
- }
945
- else {
946
- day = 1;
947
- month = 0;
948
- year = parseInt(target.text(), 10)||0;
949
- this.viewDate.setUTCFullYear(year);
950
- this._trigger('changeYear', this.viewDate);
951
- if (this.o.minViewMode === 2){
952
- this._setDate(UTCDate(year, month, day));
953
- }
954
- }
955
- this.showMode(-1);
956
- this.fill();
957
- }
958
- break;
959
- case 'td':
960
- if (target.is('.day') && !target.is('.disabled')){
961
- day = parseInt(target.text(), 10)||1;
962
- year = this.viewDate.getUTCFullYear();
963
- month = this.viewDate.getUTCMonth();
964
- if (target.is('.old')){
965
- if (month === 0){
966
- month = 11;
967
- year -= 1;
968
- }
969
- else {
970
- month -= 1;
971
- }
972
- }
973
- else if (target.is('.new')){
974
- if (month === 11){
975
- month = 0;
976
- year += 1;
977
- }
978
- else {
979
- month += 1;
980
- }
981
- }
982
- this._setDate(UTCDate(year, month, day));
983
- }
984
- break;
985
- }
986
- }
987
- if (this.picker.is(':visible') && this._focused_from){
988
- $(this._focused_from).focus();
989
- }
990
- delete this._focused_from;
991
- },
992
-
993
- _toggle_multidate: function(date){
994
- var ix = this.dates.contains(date);
995
- if (!date){
996
- this.dates.clear();
997
- }
998
- else if (ix !== -1){
999
- this.dates.remove(ix);
1000
- }
1001
- else {
1002
- this.dates.push(date);
1003
- }
1004
- if (typeof this.o.multidate === 'number')
1005
- while (this.dates.length > this.o.multidate)
1006
- this.dates.remove(0);
1007
- },
1008
-
1009
- _setDate: function(date, which){
1010
- if (!which || which === 'date')
1011
- this._toggle_multidate(date && new Date(date));
1012
- if (!which || which === 'view')
1013
- this.viewDate = date && new Date(date);
1014
-
1015
- this.fill();
1016
- this.setValue();
1017
- this._trigger('changeDate');
1018
- var element;
1019
- if (this.isInput){
1020
- element = this.element;
1021
- }
1022
- else if (this.component){
1023
- element = this.element.find('input');
1024
- }
1025
- if (element){
1026
- element.change();
1027
- }
1028
- if (this.o.autoclose && (!which || which === 'date')){
1029
- this.hide();
1030
- }
1031
- },
1032
-
1033
- moveMonth: function(date, dir){
1034
- if (!date)
1035
- return undefined;
1036
- if (!dir)
1037
- return date;
1038
- var new_date = new Date(date.valueOf()),
1039
- day = new_date.getUTCDate(),
1040
- month = new_date.getUTCMonth(),
1041
- mag = Math.abs(dir),
1042
- new_month, test;
1043
- dir = dir > 0 ? 1 : -1;
1044
- if (mag === 1){
1045
- test = dir === -1
1046
- // If going back one month, make sure month is not current month
1047
- // (eg, Mar 31 -> Feb 31 == Feb 28, not Mar 02)
1048
- ? function(){
1049
- return new_date.getUTCMonth() === month;
1050
- }
1051
- // If going forward one month, make sure month is as expected
1052
- // (eg, Jan 31 -> Feb 31 == Feb 28, not Mar 02)
1053
- : function(){
1054
- return new_date.getUTCMonth() !== new_month;
1055
- };
1056
- new_month = month + dir;
1057
- new_date.setUTCMonth(new_month);
1058
- // Dec -> Jan (12) or Jan -> Dec (-1) -- limit expected date to 0-11
1059
- if (new_month < 0 || new_month > 11)
1060
- new_month = (new_month + 12) % 12;
1061
- }
1062
- else {
1063
- // For magnitudes >1, move one month at a time...
1064
- for (var i=0; i < mag; i++)
1065
- // ...which might decrease the day (eg, Jan 31 to Feb 28, etc)...
1066
- new_date = this.moveMonth(new_date, dir);
1067
- // ...then reset the day, keeping it in the new month
1068
- new_month = new_date.getUTCMonth();
1069
- new_date.setUTCDate(day);
1070
- test = function(){
1071
- return new_month !== new_date.getUTCMonth();
1072
- };
1073
- }
1074
- // Common date-resetting loop -- if date is beyond end of month, make it
1075
- // end of month
1076
- while (test()){
1077
- new_date.setUTCDate(--day);
1078
- new_date.setUTCMonth(new_month);
1079
- }
1080
- return new_date;
1081
- },
1082
-
1083
- moveYear: function(date, dir){
1084
- return this.moveMonth(date, dir*12);
1085
- },
1086
-
1087
- dateWithinRange: function(date){
1088
- return date >= this.o.startDate && date <= this.o.endDate;
1089
- },
1090
-
1091
- keydown: function(e){
1092
- if (this.picker.is(':not(:visible)')){
1093
- if (e.keyCode === 27) // allow escape to hide and re-show picker
1094
- this.show();
1095
- return;
1096
- }
1097
- var dateChanged = false,
1098
- dir, newDate, newViewDate,
1099
- focusDate = this.focusDate || this.viewDate;
1100
- switch (e.keyCode){
1101
- case 27: // escape
1102
- if (this.focusDate){
1103
- this.focusDate = null;
1104
- this.viewDate = this.dates.get(-1) || this.viewDate;
1105
- this.fill();
1106
- }
1107
- else
1108
- this.hide();
1109
- e.preventDefault();
1110
- break;
1111
- case 37: // left
1112
- case 39: // right
1113
- if (!this.o.keyboardNavigation)
1114
- break;
1115
- dir = e.keyCode === 37 ? -1 : 1;
1116
- if (e.ctrlKey){
1117
- newDate = this.moveYear(this.dates.get(-1) || UTCToday(), dir);
1118
- newViewDate = this.moveYear(focusDate, dir);
1119
- this._trigger('changeYear', this.viewDate);
1120
- }
1121
- else if (e.shiftKey){
1122
- newDate = this.moveMonth(this.dates.get(-1) || UTCToday(), dir);
1123
- newViewDate = this.moveMonth(focusDate, dir);
1124
- this._trigger('changeMonth', this.viewDate);
1125
- }
1126
- else {
1127
- newDate = new Date(this.dates.get(-1) || UTCToday());
1128
- newDate.setUTCDate(newDate.getUTCDate() + dir);
1129
- newViewDate = new Date(focusDate);
1130
- newViewDate.setUTCDate(focusDate.getUTCDate() + dir);
1131
- }
1132
- if (this.dateWithinRange(newDate)){
1133
- this.focusDate = this.viewDate = newViewDate;
1134
- this.setValue();
1135
- this.fill();
1136
- e.preventDefault();
1137
- }
1138
- break;
1139
- case 38: // up
1140
- case 40: // down
1141
- if (!this.o.keyboardNavigation)
1142
- break;
1143
- dir = e.keyCode === 38 ? -1 : 1;
1144
- if (e.ctrlKey){
1145
- newDate = this.moveYear(this.dates.get(-1) || UTCToday(), dir);
1146
- newViewDate = this.moveYear(focusDate, dir);
1147
- this._trigger('changeYear', this.viewDate);
1148
- }
1149
- else if (e.shiftKey){
1150
- newDate = this.moveMonth(this.dates.get(-1) || UTCToday(), dir);
1151
- newViewDate = this.moveMonth(focusDate, dir);
1152
- this._trigger('changeMonth', this.viewDate);
1153
- }
1154
- else {
1155
- newDate = new Date(this.dates.get(-1) || UTCToday());
1156
- newDate.setUTCDate(newDate.getUTCDate() + dir * 7);
1157
- newViewDate = new Date(focusDate);
1158
- newViewDate.setUTCDate(focusDate.getUTCDate() + dir * 7);
1159
- }
1160
- if (this.dateWithinRange(newDate)){
1161
- this.focusDate = this.viewDate = newViewDate;
1162
- this.setValue();
1163
- this.fill();
1164
- e.preventDefault();
1165
- }
1166
- break;
1167
- case 32: // spacebar
1168
- // Spacebar is used in manually typing dates in some formats.
1169
- // As such, its behavior should not be hijacked.
1170
- break;
1171
- case 13: // enter
1172
- focusDate = this.focusDate || this.dates.get(-1) || this.viewDate;
1173
- this._toggle_multidate(focusDate);
1174
- dateChanged = true;
1175
- this.focusDate = null;
1176
- this.viewDate = this.dates.get(-1) || this.viewDate;
1177
- this.setValue();
1178
- this.fill();
1179
- if (this.picker.is(':visible')){
1180
- e.preventDefault();
1181
- if (this.o.autoclose)
1182
- this.hide();
1183
- }
1184
- break;
1185
- case 9: // tab
1186
- this.focusDate = null;
1187
- this.viewDate = this.dates.get(-1) || this.viewDate;
1188
- this.fill();
1189
- this.hide();
1190
- break;
1191
- }
1192
- if (dateChanged){
1193
- if (this.dates.length)
1194
- this._trigger('changeDate');
1195
- else
1196
- this._trigger('clearDate');
1197
- var element;
1198
- if (this.isInput){
1199
- element = this.element;
1200
- }
1201
- else if (this.component){
1202
- element = this.element.find('input');
1203
- }
1204
- if (element){
1205
- element.change();
1206
- }
1207
- }
1208
- },
1209
-
1210
- showMode: function(dir){
1211
- if (dir){
1212
- this.viewMode = Math.max(this.o.minViewMode, Math.min(2, this.viewMode + dir));
1213
- }
1214
- this.picker
1215
- .find('>div')
1216
- .hide()
1217
- .filter('.datepicker-'+DPGlobal.modes[this.viewMode].clsName)
1218
- .css('display', 'block');
1219
- this.updateNavArrows();
1220
- }
1221
- };
1222
-
1223
- var DateRangePicker = function(element, options){
1224
- this.element = $(element);
1225
- this.inputs = $.map(options.inputs, function(i){
1226
- return i.jquery ? i[0] : i;
1227
- });
1228
- delete options.inputs;
1229
-
1230
- $(this.inputs)
1231
- .datepicker(options)
1232
- .bind('changeDate', $.proxy(this.dateUpdated, this));
1233
-
1234
- this.pickers = $.map(this.inputs, function(i){
1235
- return $(i).data('datepicker');
1236
- });
1237
- this.updateDates();
1238
- };
1239
- DateRangePicker.prototype = {
1240
- updateDates: function(){
1241
- this.dates = $.map(this.pickers, function(i){
1242
- return i.getUTCDate();
1243
- });
1244
- this.updateRanges();
1245
- },
1246
- updateRanges: function(){
1247
- var range = $.map(this.dates, function(d){
1248
- return d.valueOf();
1249
- });
1250
- $.each(this.pickers, function(i, p){
1251
- p.setRange(range);
1252
- });
1253
- },
1254
- dateUpdated: function(e){
1255
- // `this.updating` is a workaround for preventing infinite recursion
1256
- // between `changeDate` triggering and `setUTCDate` calling. Until
1257
- // there is a better mechanism.
1258
- if (this.updating)
1259
- return;
1260
- this.updating = true;
1261
-
1262
- var dp = $(e.target).data('datepicker'),
1263
- new_date = dp.getUTCDate(),
1264
- i = $.inArray(e.target, this.inputs),
1265
- l = this.inputs.length;
1266
- if (i === -1)
1267
- return;
1268
-
1269
- $.each(this.pickers, function(i, p){
1270
- if (!p.getUTCDate())
1271
- p.setUTCDate(new_date);
1272
- });
1273
-
1274
- if (new_date < this.dates[i]){
1275
- // Date being moved earlier/left
1276
- while (i >= 0 && new_date < this.dates[i]){
1277
- this.pickers[i--].setUTCDate(new_date);
1278
- }
1279
- }
1280
- else if (new_date > this.dates[i]){
1281
- // Date being moved later/right
1282
- while (i < l && new_date > this.dates[i]){
1283
- this.pickers[i++].setUTCDate(new_date);
1284
- }
1285
- }
1286
- this.updateDates();
1287
-
1288
- delete this.updating;
1289
- },
1290
- remove: function(){
1291
- $.map(this.pickers, function(p){ p.remove(); });
1292
- delete this.element.data().datepicker;
1293
- }
1294
- };
1295
-
1296
- function opts_from_el(el, prefix){
1297
- // Derive options from element data-attrs
1298
- var data = $(el).data(),
1299
- out = {}, inkey,
1300
- replace = new RegExp('^' + prefix.toLowerCase() + '([A-Z])');
1301
- prefix = new RegExp('^' + prefix.toLowerCase());
1302
- function re_lower(_,a){
1303
- return a.toLowerCase();
1304
- }
1305
- for (var key in data)
1306
- if (prefix.test(key)){
1307
- inkey = key.replace(replace, re_lower);
1308
- out[inkey] = data[key];
1309
- }
1310
- return out;
1311
- }
1312
-
1313
- function opts_from_locale(lang){
1314
- // Derive options from locale plugins
1315
- var out = {};
1316
- // Check if "de-DE" style date is available, if not language should
1317
- // fallback to 2 letter code eg "de"
1318
- if (!dates[lang]){
1319
- lang = lang.split('-')[0];
1320
- if (!dates[lang])
1321
- return;
1322
- }
1323
- var d = dates[lang];
1324
- $.each(locale_opts, function(i,k){
1325
- if (k in d)
1326
- out[k] = d[k];
1327
- });
1328
- return out;
1329
- }
1330
-
1331
- var old = $.fn.datepicker;
1332
- $.fn.datepicker = function(option){
1333
- var args = Array.apply(null, arguments);
1334
- args.shift();
1335
- var internal_return;
1336
- this.each(function(){
1337
- var $this = $(this),
1338
- data = $this.data('datepicker'),
1339
- options = typeof option === 'object' && option;
1340
- if (!data){
1341
- var elopts = opts_from_el(this, 'date'),
1342
- // Preliminary otions
1343
- xopts = $.extend({}, defaults, elopts, options),
1344
- locopts = opts_from_locale(xopts.language),
1345
- // Options priority: js args, data-attrs, locales, defaults
1346
- opts = $.extend({}, defaults, locopts, elopts, options);
1347
- if ($this.is('.input-daterange') || opts.inputs){
1348
- var ropts = {
1349
- inputs: opts.inputs || $this.find('input').toArray()
1350
- };
1351
- $this.data('datepicker', (data = new DateRangePicker(this, $.extend(opts, ropts))));
1352
- }
1353
- else {
1354
- $this.data('datepicker', (data = new Datepicker(this, opts)));
1355
- }
1356
- }
1357
- if (typeof option === 'string' && typeof data[option] === 'function'){
1358
- internal_return = data[option].apply(data, args);
1359
- if (internal_return !== undefined)
1360
- return false;
1361
- }
1362
- });
1363
- if (internal_return !== undefined)
1364
- return internal_return;
1365
- else
1366
- return this;
1367
- };
1368
-
1369
- var defaults = $.fn.datepicker.defaults = {
1370
- autoclose: false,
1371
- beforeShowDay: $.noop,
1372
- calendarWeeks: false,
1373
- clearBtn: false,
1374
- daysOfWeekDisabled: [],
1375
- dropdown: 'datepicker-dropdown dropdown-menu',
1376
- endDate: Infinity,
1377
- forceParse: true,
1378
- format: 'mm/dd/yyyy',
1379
- keyboardNavigation: true,
1380
- language: 'en',
1381
- minViewMode: 0,
1382
- multidate: false,
1383
- multidateSeparator: ',',
1384
- orientation: "auto",
1385
- rtl: false,
1386
- startDate: -Infinity,
1387
- startView: 0,
1388
- todayBtn: false,
1389
- todayHighlight: false,
1390
- weekStart: 0
1391
- };
1392
- var locale_opts = $.fn.datepicker.locale_opts = [
1393
- 'format',
1394
- 'rtl',
1395
- 'weekStart'
1396
- ];
1397
- $.fn.datepicker.Constructor = Datepicker;
1398
- var dates = $.fn.datepicker.dates = {
1399
- en: {
1400
- days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
1401
- daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
1402
- daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
1403
- months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
1404
- monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
1405
- today: "Today",
1406
- clear: "Clear"
1407
- }
1408
- };
1409
-
1410
- var DPGlobal = {
1411
- modes: [
1412
- {
1413
- clsName: 'days',
1414
- navFnc: 'Month',
1415
- navStep: 1
1416
- },
1417
- {
1418
- clsName: 'months',
1419
- navFnc: 'FullYear',
1420
- navStep: 1
1421
- },
1422
- {
1423
- clsName: 'years',
1424
- navFnc: 'FullYear',
1425
- navStep: 10
1426
- }],
1427
- isLeapYear: function(year){
1428
- return (((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0));
1429
- },
1430
- getDaysInMonth: function(year, month){
1431
- return [31, (DPGlobal.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month];
1432
- },
1433
- validParts: /dd?|DD?|mm?|MM?|yy(?:yy)?/g,
1434
- nonpunctuation: /[^ -\/:-@\[\u3400-\u9fff-`{-~\t\n\r]+/g,
1435
- parseFormat: function(format){
1436
- // IE treats \0 as a string end in inputs (truncating the value),
1437
- // so it's a bad format delimiter, anyway
1438
- var separators = format.replace(this.validParts, '\0').split('\0'),
1439
- parts = format.match(this.validParts);
1440
- if (!separators || !separators.length || !parts || parts.length === 0){
1441
- throw new Error("Invalid date format.");
1442
- }
1443
- return {separators: separators, parts: parts};
1444
- },
1445
- parseDate: function(date, format, language){
1446
- if (!date)
1447
- return undefined;
1448
- if (date instanceof Date)
1449
- return date;
1450
- if (typeof format === 'string')
1451
- format = DPGlobal.parseFormat(format);
1452
- var part_re = /([\-+]\d+)([dmwy])/,
1453
- parts = date.match(/([\-+]\d+)([dmwy])/g),
1454
- part, dir, i;
1455
- if (/^[\-+]\d+[dmwy]([\s,]+[\-+]\d+[dmwy])*$/.test(date)){
1456
- date = new Date();
1457
- for (i=0; i < parts.length; i++){
1458
- part = part_re.exec(parts[i]);
1459
- dir = parseInt(part[1]);
1460
- switch (part[2]){
1461
- case 'd':
1462
- date.setUTCDate(date.getUTCDate() + dir);
1463
- break;
1464
- case 'm':
1465
- date = Datepicker.prototype.moveMonth.call(Datepicker.prototype, date, dir);
1466
- break;
1467
- case 'w':
1468
- date.setUTCDate(date.getUTCDate() + dir * 7);
1469
- break;
1470
- case 'y':
1471
- date = Datepicker.prototype.moveYear.call(Datepicker.prototype, date, dir);
1472
- break;
1473
- }
1474
- }
1475
- return UTCDate(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(), 0, 0, 0);
1476
- }
1477
- parts = date && date.match(this.nonpunctuation) || [];
1478
- date = new Date();
1479
- var parsed = {},
1480
- setters_order = ['yyyy', 'yy', 'M', 'MM', 'm', 'mm', 'd', 'dd'],
1481
- setters_map = {
1482
- yyyy: function(d,v){
1483
- return d.setUTCFullYear(v);
1484
- },
1485
- yy: function(d,v){
1486
- return d.setUTCFullYear(2000+v);
1487
- },
1488
- m: function(d,v){
1489
- if (isNaN(d))
1490
- return d;
1491
- v -= 1;
1492
- while (v < 0) v += 12;
1493
- v %= 12;
1494
- d.setUTCMonth(v);
1495
- while (d.getUTCMonth() !== v)
1496
- d.setUTCDate(d.getUTCDate()-1);
1497
- return d;
1498
- },
1499
- d: function(d,v){
1500
- return d.setUTCDate(v);
1501
- }
1502
- },
1503
- val, filtered;
1504
- setters_map['M'] = setters_map['MM'] = setters_map['mm'] = setters_map['m'];
1505
- setters_map['dd'] = setters_map['d'];
1506
- date = UTCDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
1507
- var fparts = format.parts.slice();
1508
- // Remove noop parts
1509
- if (parts.length !== fparts.length){
1510
- fparts = $(fparts).filter(function(i,p){
1511
- return $.inArray(p, setters_order) !== -1;
1512
- }).toArray();
1513
- }
1514
- // Process remainder
1515
- function match_part(){
1516
- var m = this.slice(0, parts[i].length),
1517
- p = parts[i].slice(0, m.length);
1518
- return m === p;
1519
- }
1520
- if (parts.length === fparts.length){
1521
- var cnt;
1522
- for (i=0, cnt = fparts.length; i < cnt; i++){
1523
- val = parseInt(parts[i], 10);
1524
- part = fparts[i];
1525
- if (isNaN(val)){
1526
- switch (part){
1527
- case 'MM':
1528
- filtered = $(dates[language].months).filter(match_part);
1529
- val = $.inArray(filtered[0], dates[language].months) + 1;
1530
- break;
1531
- case 'M':
1532
- filtered = $(dates[language].monthsShort).filter(match_part);
1533
- val = $.inArray(filtered[0], dates[language].monthsShort) + 1;
1534
- break;
1535
- }
1536
- }
1537
- parsed[part] = val;
1538
- }
1539
- var _date, s;
1540
- for (i=0; i < setters_order.length; i++){
1541
- s = setters_order[i];
1542
- if (s in parsed && !isNaN(parsed[s])){
1543
- _date = new Date(date);
1544
- setters_map[s](_date, parsed[s]);
1545
- if (!isNaN(_date))
1546
- date = _date;
1547
- }
1548
- }
1549
- }
1550
- return date;
1551
- },
1552
- formatDate: function(date, format, language){
1553
- if (!date)
1554
- return '';
1555
- if (typeof format === 'string')
1556
- format = DPGlobal.parseFormat(format);
1557
- var val = {
1558
- d: date.getUTCDate(),
1559
- D: dates[language].daysShort[date.getUTCDay()],
1560
- DD: dates[language].days[date.getUTCDay()],
1561
- m: date.getUTCMonth() + 1,
1562
- M: dates[language].monthsShort[date.getUTCMonth()],
1563
- MM: dates[language].months[date.getUTCMonth()],
1564
- yy: date.getUTCFullYear().toString().substring(2),
1565
- yyyy: date.getUTCFullYear()
1566
- };
1567
- val.dd = (val.d < 10 ? '0' : '') + val.d;
1568
- val.mm = (val.m < 10 ? '0' : '') + val.m;
1569
- date = [];
1570
- var seps = $.extend([], format.separators);
1571
- for (var i=0, cnt = format.parts.length; i <= cnt; i++){
1572
- if (seps.length)
1573
- date.push(seps.shift());
1574
- date.push(val[format.parts[i]]);
1575
- }
1576
- return date.join('');
1577
- },
1578
- headTemplate: '<thead>'+
1579
- '<tr>'+
1580
- '<th class="prev">&laquo;</th>'+
1581
- '<th colspan="5" class="datepicker-switch"></th>'+
1582
- '<th class="next">&raquo;</th>'+
1583
- '</tr>'+
1584
- '</thead>',
1585
- contTemplate: '<tbody><tr><td colspan="7"></td></tr></tbody>',
1586
- footTemplate: '<tfoot>'+
1587
- '<tr>'+
1588
- '<th colspan="7" class="today"></th>'+
1589
- '</tr>'+
1590
- '<tr>'+
1591
- '<th colspan="7" class="clear"></th>'+
1592
- '</tr>'+
1593
- '</tfoot>'
1594
- };
1595
- DPGlobal.template = '<div class="datepicker">'+
1596
- '<div class="datepicker-days">'+
1597
- '<table class=" table-condensed">'+
1598
- DPGlobal.headTemplate+
1599
- '<tbody></tbody>'+
1600
- DPGlobal.footTemplate+
1601
- '</table>'+
1602
- '</div>'+
1603
- '<div class="datepicker-months">'+
1604
- '<table class="table-condensed">'+
1605
- DPGlobal.headTemplate+
1606
- DPGlobal.contTemplate+
1607
- DPGlobal.footTemplate+
1608
- '</table>'+
1609
- '</div>'+
1610
- '<div class="datepicker-years">'+
1611
- '<table class="table-condensed">'+
1612
- DPGlobal.headTemplate+
1613
- DPGlobal.contTemplate+
1614
- DPGlobal.footTemplate+
1615
- '</table>'+
1616
- '</div>'+
1617
- '</div>';
1618
-
1619
- $.fn.datepicker.DPGlobal = DPGlobal;
1620
-
1621
-
1622
- /* DATEPICKER NO CONFLICT
1623
- * =================== */
1624
-
1625
- $.fn.datepicker.noConflict = function(){
1626
- $.fn.datepicker = old;
1627
- return this;
1628
- };
1629
-
1630
-
1631
- /* DATEPICKER DATA-API
1632
- * ================== */
1633
-
1634
- $(document).on(
1635
- 'focus.datepicker.data-api click.datepicker.data-api',
1636
- '[data-provide="datepicker"]',
1637
- function(e){
1638
- var $this = $(this);
1639
- if ($this.data('datepicker'))
1640
- return;
1641
- e.preventDefault();
1642
- // component click requires us to explicitly show it
1643
- $this.datepicker('show');
1644
- }
1645
- );
1646
- $(function(){
1647
- $('[data-provide="datepicker-inline"]').datepicker();
1648
- });
1649
-
1650
- }(window.jQuery));