alchemy-chimera 0.5.4 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/CHANGELOG.md +39 -4
  2. package/assets/scripts/chimera/chimera.js +13 -288
  3. package/assets/stylesheets/chimera/chimera.scss +451 -0
  4. package/bootstrap.js +6 -302
  5. package/config/routes.js +53 -5
  6. package/controller/00-chimera_controller.js +16 -0
  7. package/controller/chimera_editor_controller.js +159 -614
  8. package/controller/chimera_static_controller.js +102 -9
  9. package/lib/chimera_config.js +138 -163
  10. package/model/model.js +1 -1
  11. package/package.json +8 -12
  12. package/view/chimera/dashboard.hwk +8 -0
  13. package/view/chimera/editor/index.hwk +20 -0
  14. package/view/chimera/sidebar.hwk +4 -0
  15. package/view/chimera/widgets.hwk +8 -0
  16. package/view/layouts/chimera_base.hwk +15 -0
  17. package/view/layouts/chimera_basics.hwk +15 -0
  18. package/view/layouts/chimera_body.hwk +24 -0
  19. package/assets/scripts/chimera/assoc_field.js +0 -311
  20. package/assets/scripts/chimera/boolean_field.js +0 -53
  21. package/assets/scripts/chimera/chimera_field.js +0 -622
  22. package/assets/scripts/chimera/chimera_field_wrapper.js +0 -558
  23. package/assets/scripts/chimera/date_field.js +0 -170
  24. package/assets/scripts/chimera/geopoint_field.js +0 -147
  25. package/assets/scripts/chimera/medium-button.js +0 -6
  26. package/assets/scripts/chimera/object_field.js +0 -51
  27. package/assets/scripts/chimera/page-editor.js +0 -3
  28. package/assets/scripts/chimera/password_field.js +0 -73
  29. package/assets/scripts/chimera/schema_field.js +0 -300
  30. package/assets/scripts/chimera/text_field.js +0 -119
  31. package/assets/scripts/rome/rome.js +0 -4978
  32. package/assets/scripts/vex/vex.dialog.js +0 -151
  33. package/assets/scripts/vex/vex.js +0 -193
  34. package/assets/stylesheets/chimera/chimera.less +0 -1075
  35. package/assets/stylesheets/chimera_old/chimera.less +0 -351
  36. package/assets/stylesheets/chimera_old/core.less +0 -315
  37. package/assets/stylesheets/chimera_old/font.less +0 -38
  38. package/assets/stylesheets/chimera_old/mixins.less +0 -35
  39. package/assets/stylesheets/chimera_old/page-editor.less +0 -23
  40. package/assets/stylesheets/rome/rome.less +0 -130
  41. package/assets/stylesheets/vex/vex-theme-bottom-right-corner.less +0 -613
  42. package/assets/stylesheets/vex/vex.default.less +0 -501
  43. package/assets/stylesheets/vex/vex.flat.less +0 -443
  44. package/assets/stylesheets/vex/vex.less +0 -320
  45. package/controller/chimera_page_controller.js +0 -14
  46. package/controller/chimera_settings_controller.js +0 -129
  47. package/controller/tasks_chimera_controller.js +0 -106
  48. package/helper/chimera_helper.js +0 -202
  49. package/lib/chimera_action_fields.js +0 -292
  50. package/lib/chimera_field/belongsto_chimera_field.js +0 -160
  51. package/lib/chimera_field/boolean_chimera_field.js +0 -19
  52. package/lib/chimera_field/date_chimera_field.js +0 -20
  53. package/lib/chimera_field/datetime_chimera_field.js +0 -20
  54. package/lib/chimera_field/enum_chimera_field.js +0 -131
  55. package/lib/chimera_field/geopoint_chimera_field.js +0 -20
  56. package/lib/chimera_field/habtm_chimera_field.js +0 -55
  57. package/lib/chimera_field/hasoneparent_chimera_field.js +0 -18
  58. package/lib/chimera_field/html_chimera_field.js +0 -20
  59. package/lib/chimera_field/object_chimera_field.js +0 -18
  60. package/lib/chimera_field/password_chimera_field.js +0 -18
  61. package/lib/chimera_field/schema_chimera_field.js +0 -149
  62. package/lib/chimera_field/text_chimera_field.js +0 -20
  63. package/lib/chimera_field/time_chimera_field.js +0 -18
  64. package/lib/chimera_field.js +0 -208
  65. package/model/setting_model.js +0 -51
  66. package/public/chimera/codedor.svg +0 -28
  67. package/view/chimera/dashboard.ejs +0 -5
  68. package/view/chimera/editor/add.ejs +0 -32
  69. package/view/chimera/editor/edit.ejs +0 -33
  70. package/view/chimera/editor/index.ejs +0 -87
  71. package/view/chimera/editor/remove.ejs +0 -23
  72. package/view/chimera/editor/view.ejs +0 -54
  73. package/view/chimera/elements/editor_actions.ejs +0 -4
  74. package/view/chimera/elements/empty +0 -0
  75. package/view/chimera/field_wrappers/_entries.ejs +0 -91
  76. package/view/chimera/field_wrappers/_wrapper.ejs +0 -82
  77. package/view/chimera/field_wrappers/date_edit.ejs +0 -23
  78. package/view/chimera/field_wrappers/date_list.ejs +0 -3
  79. package/view/chimera/field_wrappers/date_view.ejs +0 -16
  80. package/view/chimera/field_wrappers/default_edit.ejs +0 -22
  81. package/view/chimera/field_wrappers/default_list.ejs +0 -3
  82. package/view/chimera/field_wrappers/default_peek.ejs +0 -3
  83. package/view/chimera/field_wrappers/default_view.ejs +0 -14
  84. package/view/chimera/field_wrappers/geopoint_edit.ejs +0 -25
  85. package/view/chimera/field_wrappers/geopoint_list.ejs +0 -5
  86. package/view/chimera/field_wrappers/geopoint_view.ejs +0 -18
  87. package/view/chimera/field_wrappers/schema_edit.ejs +0 -19
  88. package/view/chimera/field_wrappers/text_edit.ejs +0 -22
  89. package/view/chimera/field_wrappers/text_list.ejs +0 -1
  90. package/view/chimera/fields/belongsto_edit.ejs +0 -4
  91. package/view/chimera/fields/belongsto_list.ejs +0 -1
  92. package/view/chimera/fields/belongsto_peek.ejs +0 -1
  93. package/view/chimera/fields/boolean_edit.ejs +0 -17
  94. package/view/chimera/fields/boolean_list.ejs +0 -3
  95. package/view/chimera/fields/boolean_view.ejs +0 -3
  96. package/view/chimera/fields/date_edit.ejs +0 -14
  97. package/view/chimera/fields/date_list.ejs +0 -9
  98. package/view/chimera/fields/date_peek.ejs +0 -9
  99. package/view/chimera/fields/date_view.ejs +0 -9
  100. package/view/chimera/fields/datetime_edit.ejs +0 -24
  101. package/view/chimera/fields/datetime_list.ejs +0 -9
  102. package/view/chimera/fields/datetime_view.ejs +0 -10
  103. package/view/chimera/fields/default_edit.ejs +0 -10
  104. package/view/chimera/fields/default_list.ejs +0 -15
  105. package/view/chimera/fields/default_view.ejs +0 -1
  106. package/view/chimera/fields/enum_edit.ejs +0 -10
  107. package/view/chimera/fields/geopoint_edit.ejs +0 -10
  108. package/view/chimera/fields/geopoint_list.ejs +0 -9
  109. package/view/chimera/fields/geopoint_view.ejs +0 -9
  110. package/view/chimera/fields/habtm_edit.ejs +0 -5
  111. package/view/chimera/fields/hasoneparent_edit.ejs +0 -6
  112. package/view/chimera/fields/hasoneparent_list.ejs +0 -1
  113. package/view/chimera/fields/object_edit.ejs +0 -8
  114. package/view/chimera/fields/password_edit.ejs +0 -12
  115. package/view/chimera/fields/schema_edit.ejs +0 -14
  116. package/view/chimera/fields/text_edit.ejs +0 -5
  117. package/view/chimera/fields/text_list.ejs +0 -9
  118. package/view/chimera/fields/text_view.ejs +0 -3
  119. package/view/chimera/fields/time_edit.ejs +0 -15
  120. package/view/chimera/fields/time_list.ejs +0 -9
  121. package/view/chimera/fields/time_view.ejs +0 -9
  122. package/view/chimera/page/edit.ejs +0 -18
  123. package/view/chimera/page_editor.ejs +0 -5
  124. package/view/chimera/sidebar.ejs +0 -40
  125. package/view/chimera/tasks/index.ejs +0 -114
  126. package/view/layouts/chimera.ejs +0 -12
  127. package/view/layouts/chimera_base.ejs +0 -11
  128. package/view/layouts/chimera_body.ejs +0 -43
@@ -1,4978 +0,0 @@
1
- /**
2
- * rome - Customizable date (and time) picker. Opt-in UI, no jQuery!
3
- * @version v1.1.6
4
- * @link https://github.com/bevacqua/rome
5
- * @license MIT
6
- */
7
- !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.rome=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
8
- // shim for using process in browser
9
-
10
- var process = module.exports = {};
11
-
12
- process.nextTick = (function () {
13
- var canSetImmediate = typeof window !== 'undefined'
14
- && window.setImmediate;
15
- var canPost = typeof window !== 'undefined'
16
- && window.postMessage && window.addEventListener
17
- ;
18
-
19
- if (canSetImmediate) {
20
- return function (f) { return window.setImmediate(f) };
21
- }
22
-
23
- if (canPost) {
24
- var queue = [];
25
- window.addEventListener('message', function (ev) {
26
- var source = ev.source;
27
- if ((source === window || source === null) && ev.data === 'process-tick') {
28
- ev.stopPropagation();
29
- if (queue.length > 0) {
30
- var fn = queue.shift();
31
- fn();
32
- }
33
- }
34
- }, true);
35
-
36
- return function nextTick(fn) {
37
- queue.push(fn);
38
- window.postMessage('process-tick', '*');
39
- };
40
- }
41
-
42
- return function nextTick(fn) {
43
- setTimeout(fn, 0);
44
- };
45
- })();
46
-
47
- process.title = 'browser';
48
- process.browser = true;
49
- process.env = {};
50
- process.argv = [];
51
-
52
- function noop() {}
53
-
54
- process.on = noop;
55
- process.addListener = noop;
56
- process.once = noop;
57
- process.off = noop;
58
- process.removeListener = noop;
59
- process.removeAllListeners = noop;
60
- process.emit = noop;
61
-
62
- process.binding = function (name) {
63
- throw new Error('process.binding is not supported');
64
- }
65
-
66
- // TODO(shtylman)
67
- process.cwd = function () { return '/' };
68
- process.chdir = function (dir) {
69
- throw new Error('process.chdir is not supported');
70
- };
71
-
72
- },{}],2:[function(_dereq_,module,exports){
73
- module.exports = _dereq_('./src/contra.emitter.js');
74
-
75
- },{"./src/contra.emitter.js":3}],3:[function(_dereq_,module,exports){
76
- (function (process){
77
- (function (root, undefined) {
78
- 'use strict';
79
-
80
- var undef = '' + undefined;
81
- function atoa (a, n) { return Array.prototype.slice.call(a, n); }
82
- function debounce (fn, args, ctx) { if (!fn) { return; } tick(function run () { fn.apply(ctx || null, args || []); }); }
83
-
84
- // cross-platform ticker
85
- var si = typeof setImmediate === 'function', tick;
86
- if (si) {
87
- tick = function (fn) { setImmediate(fn); };
88
- } else if (typeof process !== undef && process.nextTick) {
89
- tick = process.nextTick;
90
- } else {
91
- tick = function (fn) { setTimeout(fn, 0); };
92
- }
93
-
94
- function _emitter (thing, options) {
95
- var opts = options || {};
96
- var evt = {};
97
- if (thing === undefined) { thing = {}; }
98
- thing.on = function (type, fn) {
99
- if (!evt[type]) {
100
- evt[type] = [fn];
101
- } else {
102
- evt[type].push(fn);
103
- }
104
- return thing;
105
- };
106
- thing.once = function (type, fn) {
107
- fn._once = true; // thing.off(fn) still works!
108
- thing.on(type, fn);
109
- return thing;
110
- };
111
- thing.off = function (type, fn) {
112
- var c = arguments.length;
113
- if (c === 1) {
114
- delete evt[type];
115
- } else if (c === 0) {
116
- evt = {};
117
- } else {
118
- var et = evt[type];
119
- if (!et) { return thing; }
120
- et.splice(et.indexOf(fn), 1);
121
- }
122
- return thing;
123
- };
124
- thing.emit = function () {
125
- var args = atoa(arguments);
126
- var type = args.shift();
127
- var et = evt[type];
128
- if (type === 'error' && opts.throws !== false && !et) { throw args.length === 1 ? args[0] : args; }
129
- if (!et) { return thing; }
130
- evt[type] = et.filter(function emitter (listen) {
131
- if (opts.async) { debounce(listen, args, thing); } else { listen.apply(thing, args); }
132
- return !listen._once;
133
- });
134
- return thing;
135
- };
136
- return thing;
137
- }
138
-
139
- // cross-platform export
140
- if (typeof module !== undef && module.exports) {
141
- module.exports = _emitter;
142
- } else {
143
- root.contra = root.contra || {};
144
- root.contra.emitter = _emitter;
145
- }
146
- })(this);
147
-
148
- }).call(this,_dereq_("FWaASH"))
149
- },{"FWaASH":1}],4:[function(_dereq_,module,exports){
150
- /**
151
- * Lo-Dash 2.4.1 (Custom Build) <http://lodash.com/>
152
- * Build: `lodash modularize modern exports="npm" -o ./npm/`
153
- * Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/>
154
- * Based on Underscore.js 1.5.2 <http://underscorejs.org/LICENSE>
155
- * Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
156
- * Available under MIT license <http://lodash.com/license>
157
- */
158
- var debounce = _dereq_('lodash.debounce'),
159
- isFunction = _dereq_('lodash.isfunction'),
160
- isObject = _dereq_('lodash.isobject');
161
-
162
- /** Used as an internal `_.debounce` options object */
163
- var debounceOptions = {
164
- 'leading': false,
165
- 'maxWait': 0,
166
- 'trailing': false
167
- };
168
-
169
- /**
170
- * Creates a function that, when executed, will only call the `func` function
171
- * at most once per every `wait` milliseconds. Provide an options object to
172
- * indicate that `func` should be invoked on the leading and/or trailing edge
173
- * of the `wait` timeout. Subsequent calls to the throttled function will
174
- * return the result of the last `func` call.
175
- *
176
- * Note: If `leading` and `trailing` options are `true` `func` will be called
177
- * on the trailing edge of the timeout only if the the throttled function is
178
- * invoked more than once during the `wait` timeout.
179
- *
180
- * @static
181
- * @memberOf _
182
- * @category Functions
183
- * @param {Function} func The function to throttle.
184
- * @param {number} wait The number of milliseconds to throttle executions to.
185
- * @param {Object} [options] The options object.
186
- * @param {boolean} [options.leading=true] Specify execution on the leading edge of the timeout.
187
- * @param {boolean} [options.trailing=true] Specify execution on the trailing edge of the timeout.
188
- * @returns {Function} Returns the new throttled function.
189
- * @example
190
- *
191
- * // avoid excessively updating the position while scrolling
192
- * var throttled = _.throttle(updatePosition, 100);
193
- * jQuery(window).on('scroll', throttled);
194
- *
195
- * // execute `renewToken` when the click event is fired, but not more than once every 5 minutes
196
- * jQuery('.interactive').on('click', _.throttle(renewToken, 300000, {
197
- * 'trailing': false
198
- * }));
199
- */
200
- function throttle(func, wait, options) {
201
- var leading = true,
202
- trailing = true;
203
-
204
- if (!isFunction(func)) {
205
- throw new TypeError;
206
- }
207
- if (options === false) {
208
- leading = false;
209
- } else if (isObject(options)) {
210
- leading = 'leading' in options ? options.leading : leading;
211
- trailing = 'trailing' in options ? options.trailing : trailing;
212
- }
213
- debounceOptions.leading = leading;
214
- debounceOptions.maxWait = wait;
215
- debounceOptions.trailing = trailing;
216
-
217
- return debounce(func, wait, debounceOptions);
218
- }
219
-
220
- module.exports = throttle;
221
-
222
- },{"lodash.debounce":5,"lodash.isfunction":8,"lodash.isobject":9}],5:[function(_dereq_,module,exports){
223
- /**
224
- * Lo-Dash 2.4.1 (Custom Build) <http://lodash.com/>
225
- * Build: `lodash modularize modern exports="npm" -o ./npm/`
226
- * Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/>
227
- * Based on Underscore.js 1.5.2 <http://underscorejs.org/LICENSE>
228
- * Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
229
- * Available under MIT license <http://lodash.com/license>
230
- */
231
- var isFunction = _dereq_('lodash.isfunction'),
232
- isObject = _dereq_('lodash.isobject'),
233
- now = _dereq_('lodash.now');
234
-
235
- /* Native method shortcuts for methods with the same name as other `lodash` methods */
236
- var nativeMax = Math.max;
237
-
238
- /**
239
- * Creates a function that will delay the execution of `func` until after
240
- * `wait` milliseconds have elapsed since the last time it was invoked.
241
- * Provide an options object to indicate that `func` should be invoked on
242
- * the leading and/or trailing edge of the `wait` timeout. Subsequent calls
243
- * to the debounced function will return the result of the last `func` call.
244
- *
245
- * Note: If `leading` and `trailing` options are `true` `func` will be called
246
- * on the trailing edge of the timeout only if the the debounced function is
247
- * invoked more than once during the `wait` timeout.
248
- *
249
- * @static
250
- * @memberOf _
251
- * @category Functions
252
- * @param {Function} func The function to debounce.
253
- * @param {number} wait The number of milliseconds to delay.
254
- * @param {Object} [options] The options object.
255
- * @param {boolean} [options.leading=false] Specify execution on the leading edge of the timeout.
256
- * @param {number} [options.maxWait] The maximum time `func` is allowed to be delayed before it's called.
257
- * @param {boolean} [options.trailing=true] Specify execution on the trailing edge of the timeout.
258
- * @returns {Function} Returns the new debounced function.
259
- * @example
260
- *
261
- * // avoid costly calculations while the window size is in flux
262
- * var lazyLayout = _.debounce(calculateLayout, 150);
263
- * jQuery(window).on('resize', lazyLayout);
264
- *
265
- * // execute `sendMail` when the click event is fired, debouncing subsequent calls
266
- * jQuery('#postbox').on('click', _.debounce(sendMail, 300, {
267
- * 'leading': true,
268
- * 'trailing': false
269
- * });
270
- *
271
- * // ensure `batchLog` is executed once after 1 second of debounced calls
272
- * var source = new EventSource('/stream');
273
- * source.addEventListener('message', _.debounce(batchLog, 250, {
274
- * 'maxWait': 1000
275
- * }, false);
276
- */
277
- function debounce(func, wait, options) {
278
- var args,
279
- maxTimeoutId,
280
- result,
281
- stamp,
282
- thisArg,
283
- timeoutId,
284
- trailingCall,
285
- lastCalled = 0,
286
- maxWait = false,
287
- trailing = true;
288
-
289
- if (!isFunction(func)) {
290
- throw new TypeError;
291
- }
292
- wait = nativeMax(0, wait) || 0;
293
- if (options === true) {
294
- var leading = true;
295
- trailing = false;
296
- } else if (isObject(options)) {
297
- leading = options.leading;
298
- maxWait = 'maxWait' in options && (nativeMax(wait, options.maxWait) || 0);
299
- trailing = 'trailing' in options ? options.trailing : trailing;
300
- }
301
- var delayed = function() {
302
- var remaining = wait - (now() - stamp);
303
- if (remaining <= 0) {
304
- if (maxTimeoutId) {
305
- clearTimeout(maxTimeoutId);
306
- }
307
- var isCalled = trailingCall;
308
- maxTimeoutId = timeoutId = trailingCall = undefined;
309
- if (isCalled) {
310
- lastCalled = now();
311
- result = func.apply(thisArg, args);
312
- if (!timeoutId && !maxTimeoutId) {
313
- args = thisArg = null;
314
- }
315
- }
316
- } else {
317
- timeoutId = setTimeout(delayed, remaining);
318
- }
319
- };
320
-
321
- var maxDelayed = function() {
322
- if (timeoutId) {
323
- clearTimeout(timeoutId);
324
- }
325
- maxTimeoutId = timeoutId = trailingCall = undefined;
326
- if (trailing || (maxWait !== wait)) {
327
- lastCalled = now();
328
- result = func.apply(thisArg, args);
329
- if (!timeoutId && !maxTimeoutId) {
330
- args = thisArg = null;
331
- }
332
- }
333
- };
334
-
335
- return function() {
336
- args = arguments;
337
- stamp = now();
338
- thisArg = this;
339
- trailingCall = trailing && (timeoutId || !leading);
340
-
341
- if (maxWait === false) {
342
- var leadingCall = leading && !timeoutId;
343
- } else {
344
- if (!maxTimeoutId && !leading) {
345
- lastCalled = stamp;
346
- }
347
- var remaining = maxWait - (stamp - lastCalled),
348
- isCalled = remaining <= 0;
349
-
350
- if (isCalled) {
351
- if (maxTimeoutId) {
352
- maxTimeoutId = clearTimeout(maxTimeoutId);
353
- }
354
- lastCalled = stamp;
355
- result = func.apply(thisArg, args);
356
- }
357
- else if (!maxTimeoutId) {
358
- maxTimeoutId = setTimeout(maxDelayed, remaining);
359
- }
360
- }
361
- if (isCalled && timeoutId) {
362
- timeoutId = clearTimeout(timeoutId);
363
- }
364
- else if (!timeoutId && wait !== maxWait) {
365
- timeoutId = setTimeout(delayed, wait);
366
- }
367
- if (leadingCall) {
368
- isCalled = true;
369
- result = func.apply(thisArg, args);
370
- }
371
- if (isCalled && !timeoutId && !maxTimeoutId) {
372
- args = thisArg = null;
373
- }
374
- return result;
375
- };
376
- }
377
-
378
- module.exports = debounce;
379
-
380
- },{"lodash.isfunction":8,"lodash.isobject":9,"lodash.now":6}],6:[function(_dereq_,module,exports){
381
- /**
382
- * Lo-Dash 2.4.1 (Custom Build) <http://lodash.com/>
383
- * Build: `lodash modularize modern exports="npm" -o ./npm/`
384
- * Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/>
385
- * Based on Underscore.js 1.5.2 <http://underscorejs.org/LICENSE>
386
- * Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
387
- * Available under MIT license <http://lodash.com/license>
388
- */
389
- var isNative = _dereq_('lodash._isnative');
390
-
391
- /**
392
- * Gets the number of milliseconds that have elapsed since the Unix epoch
393
- * (1 January 1970 00:00:00 UTC).
394
- *
395
- * @static
396
- * @memberOf _
397
- * @category Utilities
398
- * @example
399
- *
400
- * var stamp = _.now();
401
- * _.defer(function() { console.log(_.now() - stamp); });
402
- * // => logs the number of milliseconds it took for the deferred function to be called
403
- */
404
- var now = isNative(now = Date.now) && now || function() {
405
- return new Date().getTime();
406
- };
407
-
408
- module.exports = now;
409
-
410
- },{"lodash._isnative":7}],7:[function(_dereq_,module,exports){
411
- /**
412
- * Lo-Dash 2.4.1 (Custom Build) <http://lodash.com/>
413
- * Build: `lodash modularize modern exports="npm" -o ./npm/`
414
- * Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/>
415
- * Based on Underscore.js 1.5.2 <http://underscorejs.org/LICENSE>
416
- * Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
417
- * Available under MIT license <http://lodash.com/license>
418
- */
419
-
420
- /** Used for native method references */
421
- var objectProto = Object.prototype;
422
-
423
- /** Used to resolve the internal [[Class]] of values */
424
- var toString = objectProto.toString;
425
-
426
- /** Used to detect if a method is native */
427
- var reNative = RegExp('^' +
428
- String(toString)
429
- .replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
430
- .replace(/toString| for [^\]]+/g, '.*?') + '$'
431
- );
432
-
433
- /**
434
- * Checks if `value` is a native function.
435
- *
436
- * @private
437
- * @param {*} value The value to check.
438
- * @returns {boolean} Returns `true` if the `value` is a native function, else `false`.
439
- */
440
- function isNative(value) {
441
- return typeof value == 'function' && reNative.test(value);
442
- }
443
-
444
- module.exports = isNative;
445
-
446
- },{}],8:[function(_dereq_,module,exports){
447
- /**
448
- * Lo-Dash 2.4.1 (Custom Build) <http://lodash.com/>
449
- * Build: `lodash modularize modern exports="npm" -o ./npm/`
450
- * Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/>
451
- * Based on Underscore.js 1.5.2 <http://underscorejs.org/LICENSE>
452
- * Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
453
- * Available under MIT license <http://lodash.com/license>
454
- */
455
-
456
- /**
457
- * Checks if `value` is a function.
458
- *
459
- * @static
460
- * @memberOf _
461
- * @category Objects
462
- * @param {*} value The value to check.
463
- * @returns {boolean} Returns `true` if the `value` is a function, else `false`.
464
- * @example
465
- *
466
- * _.isFunction(_);
467
- * // => true
468
- */
469
- function isFunction(value) {
470
- return typeof value == 'function';
471
- }
472
-
473
- module.exports = isFunction;
474
-
475
- },{}],9:[function(_dereq_,module,exports){
476
- /**
477
- * Lo-Dash 2.4.1 (Custom Build) <http://lodash.com/>
478
- * Build: `lodash modularize modern exports="npm" -o ./npm/`
479
- * Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/>
480
- * Based on Underscore.js 1.5.2 <http://underscorejs.org/LICENSE>
481
- * Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
482
- * Available under MIT license <http://lodash.com/license>
483
- */
484
- var objectTypes = _dereq_('lodash._objecttypes');
485
-
486
- /**
487
- * Checks if `value` is the language type of Object.
488
- * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
489
- *
490
- * @static
491
- * @memberOf _
492
- * @category Objects
493
- * @param {*} value The value to check.
494
- * @returns {boolean} Returns `true` if the `value` is an object, else `false`.
495
- * @example
496
- *
497
- * _.isObject({});
498
- * // => true
499
- *
500
- * _.isObject([1, 2, 3]);
501
- * // => true
502
- *
503
- * _.isObject(1);
504
- * // => false
505
- */
506
- function isObject(value) {
507
- // check if the value is the ECMAScript language type of Object
508
- // http://es5.github.io/#x8
509
- // and avoid a V8 bug
510
- // http://code.google.com/p/v8/issues/detail?id=2291
511
- return !!(value && objectTypes[typeof value]);
512
- }
513
-
514
- module.exports = isObject;
515
-
516
- },{"lodash._objecttypes":10}],10:[function(_dereq_,module,exports){
517
- /**
518
- * Lo-Dash 2.4.1 (Custom Build) <http://lodash.com/>
519
- * Build: `lodash modularize modern exports="npm" -o ./npm/`
520
- * Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/>
521
- * Based on Underscore.js 1.5.2 <http://underscorejs.org/LICENSE>
522
- * Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
523
- * Available under MIT license <http://lodash.com/license>
524
- */
525
-
526
- /** Used to determine if values are of the language type Object */
527
- var objectTypes = {
528
- 'boolean': false,
529
- 'function': true,
530
- 'object': true,
531
- 'number': false,
532
- 'string': false,
533
- 'undefined': false
534
- };
535
-
536
- module.exports = objectTypes;
537
-
538
- },{}],11:[function(_dereq_,module,exports){
539
- (function (global){
540
- //! moment.js
541
- //! version : 2.8.2
542
- //! authors : Tim Wood, Iskren Chernev, Moment.js contributors
543
- //! license : MIT
544
- //! momentjs.com
545
-
546
- (function (undefined) {
547
- /************************************
548
- Constants
549
- ************************************/
550
-
551
- var moment,
552
- VERSION = '2.8.2',
553
- // the global-scope this is NOT the global object in Node.js
554
- globalScope = typeof global !== 'undefined' ? global : this,
555
- oldGlobalMoment,
556
- round = Math.round,
557
- hasOwnProperty = Object.prototype.hasOwnProperty,
558
- i,
559
-
560
- YEAR = 0,
561
- MONTH = 1,
562
- DATE = 2,
563
- HOUR = 3,
564
- MINUTE = 4,
565
- SECOND = 5,
566
- MILLISECOND = 6,
567
-
568
- // internal storage for locale config files
569
- locales = {},
570
-
571
- // extra moment internal properties (plugins register props here)
572
- momentProperties = [],
573
-
574
- // check for nodeJS
575
- hasModule = (typeof module !== 'undefined' && module.exports),
576
-
577
- // ASP.NET json date format regex
578
- aspNetJsonRegex = /^\/?Date\((\-?\d+)/i,
579
- aspNetTimeSpanJsonRegex = /(\-)?(?:(\d*)\.)?(\d+)\:(\d+)(?:\:(\d+)\.?(\d{3})?)?/,
580
-
581
- // from http://docs.closure-library.googlecode.com/git/closure_goog_date_date.js.source.html
582
- // somewhat more in line with 4.4.3.2 2004 spec, but allows decimal anywhere
583
- isoDurationRegex = /^(-)?P(?:(?:([0-9,.]*)Y)?(?:([0-9,.]*)M)?(?:([0-9,.]*)D)?(?:T(?:([0-9,.]*)H)?(?:([0-9,.]*)M)?(?:([0-9,.]*)S)?)?|([0-9,.]*)W)$/,
584
-
585
- // format tokens
586
- formattingTokens = /(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Q|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|S{1,4}|X|zz?|ZZ?|.)/g,
587
- localFormattingTokens = /(\[[^\[]*\])|(\\)?(LT|LL?L?L?|l{1,4})/g,
588
-
589
- // parsing token regexes
590
- parseTokenOneOrTwoDigits = /\d\d?/, // 0 - 99
591
- parseTokenOneToThreeDigits = /\d{1,3}/, // 0 - 999
592
- parseTokenOneToFourDigits = /\d{1,4}/, // 0 - 9999
593
- parseTokenOneToSixDigits = /[+\-]?\d{1,6}/, // -999,999 - 999,999
594
- parseTokenDigits = /\d+/, // nonzero number of digits
595
- parseTokenWord = /[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i, // any word (or two) characters or numbers including two/three word month in arabic.
596
- parseTokenTimezone = /Z|[\+\-]\d\d:?\d\d/gi, // +00:00 -00:00 +0000 -0000 or Z
597
- parseTokenT = /T/i, // T (ISO separator)
598
- parseTokenTimestampMs = /[\+\-]?\d+(\.\d{1,3})?/, // 123456789 123456789.123
599
- parseTokenOrdinal = /\d{1,2}/,
600
-
601
- //strict parsing regexes
602
- parseTokenOneDigit = /\d/, // 0 - 9
603
- parseTokenTwoDigits = /\d\d/, // 00 - 99
604
- parseTokenThreeDigits = /\d{3}/, // 000 - 999
605
- parseTokenFourDigits = /\d{4}/, // 0000 - 9999
606
- parseTokenSixDigits = /[+-]?\d{6}/, // -999,999 - 999,999
607
- parseTokenSignedNumber = /[+-]?\d+/, // -inf - inf
608
-
609
- // iso 8601 regex
610
- // 0000-00-00 0000-W00 or 0000-W00-0 + T + 00 or 00:00 or 00:00:00 or 00:00:00.000 + +00:00 or +0000 or +00)
611
- isoRegex = /^\s*(?:[+-]\d{6}|\d{4})-(?:(\d\d-\d\d)|(W\d\d$)|(W\d\d-\d)|(\d\d\d))((T| )(\d\d(:\d\d(:\d\d(\.\d+)?)?)?)?([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/,
612
-
613
- isoFormat = 'YYYY-MM-DDTHH:mm:ssZ',
614
-
615
- isoDates = [
616
- ['YYYYYY-MM-DD', /[+-]\d{6}-\d{2}-\d{2}/],
617
- ['YYYY-MM-DD', /\d{4}-\d{2}-\d{2}/],
618
- ['GGGG-[W]WW-E', /\d{4}-W\d{2}-\d/],
619
- ['GGGG-[W]WW', /\d{4}-W\d{2}/],
620
- ['YYYY-DDD', /\d{4}-\d{3}/]
621
- ],
622
-
623
- // iso time formats and regexes
624
- isoTimes = [
625
- ['HH:mm:ss.SSSS', /(T| )\d\d:\d\d:\d\d\.\d+/],
626
- ['HH:mm:ss', /(T| )\d\d:\d\d:\d\d/],
627
- ['HH:mm', /(T| )\d\d:\d\d/],
628
- ['HH', /(T| )\d\d/]
629
- ],
630
-
631
- // timezone chunker '+10:00' > ['10', '00'] or '-1530' > ['-15', '30']
632
- parseTimezoneChunker = /([\+\-]|\d\d)/gi,
633
-
634
- // getter and setter names
635
- proxyGettersAndSetters = 'Date|Hours|Minutes|Seconds|Milliseconds'.split('|'),
636
- unitMillisecondFactors = {
637
- 'Milliseconds' : 1,
638
- 'Seconds' : 1e3,
639
- 'Minutes' : 6e4,
640
- 'Hours' : 36e5,
641
- 'Days' : 864e5,
642
- 'Months' : 2592e6,
643
- 'Years' : 31536e6
644
- },
645
-
646
- unitAliases = {
647
- ms : 'millisecond',
648
- s : 'second',
649
- m : 'minute',
650
- h : 'hour',
651
- d : 'day',
652
- D : 'date',
653
- w : 'week',
654
- W : 'isoWeek',
655
- M : 'month',
656
- Q : 'quarter',
657
- y : 'year',
658
- DDD : 'dayOfYear',
659
- e : 'weekday',
660
- E : 'isoWeekday',
661
- gg: 'weekYear',
662
- GG: 'isoWeekYear'
663
- },
664
-
665
- camelFunctions = {
666
- dayofyear : 'dayOfYear',
667
- isoweekday : 'isoWeekday',
668
- isoweek : 'isoWeek',
669
- weekyear : 'weekYear',
670
- isoweekyear : 'isoWeekYear'
671
- },
672
-
673
- // format function strings
674
- formatFunctions = {},
675
-
676
- // default relative time thresholds
677
- relativeTimeThresholds = {
678
- s: 45, // seconds to minute
679
- m: 45, // minutes to hour
680
- h: 22, // hours to day
681
- d: 26, // days to month
682
- M: 11 // months to year
683
- },
684
-
685
- // tokens to ordinalize and pad
686
- ordinalizeTokens = 'DDD w W M D d'.split(' '),
687
- paddedTokens = 'M D H h m s w W'.split(' '),
688
-
689
- formatTokenFunctions = {
690
- M : function () {
691
- return this.month() + 1;
692
- },
693
- MMM : function (format) {
694
- return this.localeData().monthsShort(this, format);
695
- },
696
- MMMM : function (format) {
697
- return this.localeData().months(this, format);
698
- },
699
- D : function () {
700
- return this.date();
701
- },
702
- DDD : function () {
703
- return this.dayOfYear();
704
- },
705
- d : function () {
706
- return this.day();
707
- },
708
- dd : function (format) {
709
- return this.localeData().weekdaysMin(this, format);
710
- },
711
- ddd : function (format) {
712
- return this.localeData().weekdaysShort(this, format);
713
- },
714
- dddd : function (format) {
715
- return this.localeData().weekdays(this, format);
716
- },
717
- w : function () {
718
- return this.week();
719
- },
720
- W : function () {
721
- return this.isoWeek();
722
- },
723
- YY : function () {
724
- return leftZeroFill(this.year() % 100, 2);
725
- },
726
- YYYY : function () {
727
- return leftZeroFill(this.year(), 4);
728
- },
729
- YYYYY : function () {
730
- return leftZeroFill(this.year(), 5);
731
- },
732
- YYYYYY : function () {
733
- var y = this.year(), sign = y >= 0 ? '+' : '-';
734
- return sign + leftZeroFill(Math.abs(y), 6);
735
- },
736
- gg : function () {
737
- return leftZeroFill(this.weekYear() % 100, 2);
738
- },
739
- gggg : function () {
740
- return leftZeroFill(this.weekYear(), 4);
741
- },
742
- ggggg : function () {
743
- return leftZeroFill(this.weekYear(), 5);
744
- },
745
- GG : function () {
746
- return leftZeroFill(this.isoWeekYear() % 100, 2);
747
- },
748
- GGGG : function () {
749
- return leftZeroFill(this.isoWeekYear(), 4);
750
- },
751
- GGGGG : function () {
752
- return leftZeroFill(this.isoWeekYear(), 5);
753
- },
754
- e : function () {
755
- return this.weekday();
756
- },
757
- E : function () {
758
- return this.isoWeekday();
759
- },
760
- a : function () {
761
- return this.localeData().meridiem(this.hours(), this.minutes(), true);
762
- },
763
- A : function () {
764
- return this.localeData().meridiem(this.hours(), this.minutes(), false);
765
- },
766
- H : function () {
767
- return this.hours();
768
- },
769
- h : function () {
770
- return this.hours() % 12 || 12;
771
- },
772
- m : function () {
773
- return this.minutes();
774
- },
775
- s : function () {
776
- return this.seconds();
777
- },
778
- S : function () {
779
- return toInt(this.milliseconds() / 100);
780
- },
781
- SS : function () {
782
- return leftZeroFill(toInt(this.milliseconds() / 10), 2);
783
- },
784
- SSS : function () {
785
- return leftZeroFill(this.milliseconds(), 3);
786
- },
787
- SSSS : function () {
788
- return leftZeroFill(this.milliseconds(), 3);
789
- },
790
- Z : function () {
791
- var a = -this.zone(),
792
- b = '+';
793
- if (a < 0) {
794
- a = -a;
795
- b = '-';
796
- }
797
- return b + leftZeroFill(toInt(a / 60), 2) + ':' + leftZeroFill(toInt(a) % 60, 2);
798
- },
799
- ZZ : function () {
800
- var a = -this.zone(),
801
- b = '+';
802
- if (a < 0) {
803
- a = -a;
804
- b = '-';
805
- }
806
- return b + leftZeroFill(toInt(a / 60), 2) + leftZeroFill(toInt(a) % 60, 2);
807
- },
808
- z : function () {
809
- return this.zoneAbbr();
810
- },
811
- zz : function () {
812
- return this.zoneName();
813
- },
814
- X : function () {
815
- return this.unix();
816
- },
817
- Q : function () {
818
- return this.quarter();
819
- }
820
- },
821
-
822
- deprecations = {},
823
-
824
- lists = ['months', 'monthsShort', 'weekdays', 'weekdaysShort', 'weekdaysMin'];
825
-
826
- // Pick the first defined of two or three arguments. dfl comes from
827
- // default.
828
- function dfl(a, b, c) {
829
- switch (arguments.length) {
830
- case 2: return a != null ? a : b;
831
- case 3: return a != null ? a : b != null ? b : c;
832
- default: throw new Error('Implement me');
833
- }
834
- }
835
-
836
- function hasOwnProp(a, b) {
837
- return hasOwnProperty.call(a, b);
838
- }
839
-
840
- function defaultParsingFlags() {
841
- // We need to deep clone this object, and es5 standard is not very
842
- // helpful.
843
- return {
844
- empty : false,
845
- unusedTokens : [],
846
- unusedInput : [],
847
- overflow : -2,
848
- charsLeftOver : 0,
849
- nullInput : false,
850
- invalidMonth : null,
851
- invalidFormat : false,
852
- userInvalidated : false,
853
- iso: false
854
- };
855
- }
856
-
857
- function printMsg(msg) {
858
- if (moment.suppressDeprecationWarnings === false &&
859
- typeof console !== 'undefined' && console.warn) {
860
- console.warn('Deprecation warning: ' + msg);
861
- }
862
- }
863
-
864
- function deprecate(msg, fn) {
865
- var firstTime = true;
866
- return extend(function () {
867
- if (firstTime) {
868
- printMsg(msg);
869
- firstTime = false;
870
- }
871
- return fn.apply(this, arguments);
872
- }, fn);
873
- }
874
-
875
- function deprecateSimple(name, msg) {
876
- if (!deprecations[name]) {
877
- printMsg(msg);
878
- deprecations[name] = true;
879
- }
880
- }
881
-
882
- function padToken(func, count) {
883
- return function (a) {
884
- return leftZeroFill(func.call(this, a), count);
885
- };
886
- }
887
- function ordinalizeToken(func, period) {
888
- return function (a) {
889
- return this.localeData().ordinal(func.call(this, a), period);
890
- };
891
- }
892
-
893
- while (ordinalizeTokens.length) {
894
- i = ordinalizeTokens.pop();
895
- formatTokenFunctions[i + 'o'] = ordinalizeToken(formatTokenFunctions[i], i);
896
- }
897
- while (paddedTokens.length) {
898
- i = paddedTokens.pop();
899
- formatTokenFunctions[i + i] = padToken(formatTokenFunctions[i], 2);
900
- }
901
- formatTokenFunctions.DDDD = padToken(formatTokenFunctions.DDD, 3);
902
-
903
-
904
- /************************************
905
- Constructors
906
- ************************************/
907
-
908
- function Locale() {
909
- }
910
-
911
- // Moment prototype object
912
- function Moment(config, skipOverflow) {
913
- if (skipOverflow !== false) {
914
- checkOverflow(config);
915
- }
916
- copyConfig(this, config);
917
- this._d = new Date(+config._d);
918
- }
919
-
920
- // Duration Constructor
921
- function Duration(duration) {
922
- var normalizedInput = normalizeObjectUnits(duration),
923
- years = normalizedInput.year || 0,
924
- quarters = normalizedInput.quarter || 0,
925
- months = normalizedInput.month || 0,
926
- weeks = normalizedInput.week || 0,
927
- days = normalizedInput.day || 0,
928
- hours = normalizedInput.hour || 0,
929
- minutes = normalizedInput.minute || 0,
930
- seconds = normalizedInput.second || 0,
931
- milliseconds = normalizedInput.millisecond || 0;
932
-
933
- // representation for dateAddRemove
934
- this._milliseconds = +milliseconds +
935
- seconds * 1e3 + // 1000
936
- minutes * 6e4 + // 1000 * 60
937
- hours * 36e5; // 1000 * 60 * 60
938
- // Because of dateAddRemove treats 24 hours as different from a
939
- // day when working around DST, we need to store them separately
940
- this._days = +days +
941
- weeks * 7;
942
- // It is impossible translate months into days without knowing
943
- // which months you are are talking about, so we have to store
944
- // it separately.
945
- this._months = +months +
946
- quarters * 3 +
947
- years * 12;
948
-
949
- this._data = {};
950
-
951
- this._locale = moment.localeData();
952
-
953
- this._bubble();
954
- }
955
-
956
- /************************************
957
- Helpers
958
- ************************************/
959
-
960
-
961
- function extend(a, b) {
962
- for (var i in b) {
963
- if (hasOwnProp(b, i)) {
964
- a[i] = b[i];
965
- }
966
- }
967
-
968
- if (hasOwnProp(b, 'toString')) {
969
- a.toString = b.toString;
970
- }
971
-
972
- if (hasOwnProp(b, 'valueOf')) {
973
- a.valueOf = b.valueOf;
974
- }
975
-
976
- return a;
977
- }
978
-
979
- function copyConfig(to, from) {
980
- var i, prop, val;
981
-
982
- if (typeof from._isAMomentObject !== 'undefined') {
983
- to._isAMomentObject = from._isAMomentObject;
984
- }
985
- if (typeof from._i !== 'undefined') {
986
- to._i = from._i;
987
- }
988
- if (typeof from._f !== 'undefined') {
989
- to._f = from._f;
990
- }
991
- if (typeof from._l !== 'undefined') {
992
- to._l = from._l;
993
- }
994
- if (typeof from._strict !== 'undefined') {
995
- to._strict = from._strict;
996
- }
997
- if (typeof from._tzm !== 'undefined') {
998
- to._tzm = from._tzm;
999
- }
1000
- if (typeof from._isUTC !== 'undefined') {
1001
- to._isUTC = from._isUTC;
1002
- }
1003
- if (typeof from._offset !== 'undefined') {
1004
- to._offset = from._offset;
1005
- }
1006
- if (typeof from._pf !== 'undefined') {
1007
- to._pf = from._pf;
1008
- }
1009
- if (typeof from._locale !== 'undefined') {
1010
- to._locale = from._locale;
1011
- }
1012
-
1013
- if (momentProperties.length > 0) {
1014
- for (i in momentProperties) {
1015
- prop = momentProperties[i];
1016
- val = from[prop];
1017
- if (typeof val !== 'undefined') {
1018
- to[prop] = val;
1019
- }
1020
- }
1021
- }
1022
-
1023
- return to;
1024
- }
1025
-
1026
- function absRound(number) {
1027
- if (number < 0) {
1028
- return Math.ceil(number);
1029
- } else {
1030
- return Math.floor(number);
1031
- }
1032
- }
1033
-
1034
- // left zero fill a number
1035
- // see http://jsperf.com/left-zero-filling for performance comparison
1036
- function leftZeroFill(number, targetLength, forceSign) {
1037
- var output = '' + Math.abs(number),
1038
- sign = number >= 0;
1039
-
1040
- while (output.length < targetLength) {
1041
- output = '0' + output;
1042
- }
1043
- return (sign ? (forceSign ? '+' : '') : '-') + output;
1044
- }
1045
-
1046
- function positiveMomentsDifference(base, other) {
1047
- var res = {milliseconds: 0, months: 0};
1048
-
1049
- res.months = other.month() - base.month() +
1050
- (other.year() - base.year()) * 12;
1051
- if (base.clone().add(res.months, 'M').isAfter(other)) {
1052
- --res.months;
1053
- }
1054
-
1055
- res.milliseconds = +other - +(base.clone().add(res.months, 'M'));
1056
-
1057
- return res;
1058
- }
1059
-
1060
- function momentsDifference(base, other) {
1061
- var res;
1062
- other = makeAs(other, base);
1063
- if (base.isBefore(other)) {
1064
- res = positiveMomentsDifference(base, other);
1065
- } else {
1066
- res = positiveMomentsDifference(other, base);
1067
- res.milliseconds = -res.milliseconds;
1068
- res.months = -res.months;
1069
- }
1070
-
1071
- return res;
1072
- }
1073
-
1074
- // TODO: remove 'name' arg after deprecation is removed
1075
- function createAdder(direction, name) {
1076
- return function (val, period) {
1077
- var dur, tmp;
1078
- //invert the arguments, but complain about it
1079
- if (period !== null && !isNaN(+period)) {
1080
- deprecateSimple(name, 'moment().' + name + '(period, number) is deprecated. Please use moment().' + name + '(number, period).');
1081
- tmp = val; val = period; period = tmp;
1082
- }
1083
-
1084
- val = typeof val === 'string' ? +val : val;
1085
- dur = moment.duration(val, period);
1086
- addOrSubtractDurationFromMoment(this, dur, direction);
1087
- return this;
1088
- };
1089
- }
1090
-
1091
- function addOrSubtractDurationFromMoment(mom, duration, isAdding, updateOffset) {
1092
- var milliseconds = duration._milliseconds,
1093
- days = duration._days,
1094
- months = duration._months;
1095
- updateOffset = updateOffset == null ? true : updateOffset;
1096
-
1097
- if (milliseconds) {
1098
- mom._d.setTime(+mom._d + milliseconds * isAdding);
1099
- }
1100
- if (days) {
1101
- rawSetter(mom, 'Date', rawGetter(mom, 'Date') + days * isAdding);
1102
- }
1103
- if (months) {
1104
- rawMonthSetter(mom, rawGetter(mom, 'Month') + months * isAdding);
1105
- }
1106
- if (updateOffset) {
1107
- moment.updateOffset(mom, days || months);
1108
- }
1109
- }
1110
-
1111
- // check if is an array
1112
- function isArray(input) {
1113
- return Object.prototype.toString.call(input) === '[object Array]';
1114
- }
1115
-
1116
- function isDate(input) {
1117
- return Object.prototype.toString.call(input) === '[object Date]' ||
1118
- input instanceof Date;
1119
- }
1120
-
1121
- // compare two arrays, return the number of differences
1122
- function compareArrays(array1, array2, dontConvert) {
1123
- var len = Math.min(array1.length, array2.length),
1124
- lengthDiff = Math.abs(array1.length - array2.length),
1125
- diffs = 0,
1126
- i;
1127
- for (i = 0; i < len; i++) {
1128
- if ((dontConvert && array1[i] !== array2[i]) ||
1129
- (!dontConvert && toInt(array1[i]) !== toInt(array2[i]))) {
1130
- diffs++;
1131
- }
1132
- }
1133
- return diffs + lengthDiff;
1134
- }
1135
-
1136
- function normalizeUnits(units) {
1137
- if (units) {
1138
- var lowered = units.toLowerCase().replace(/(.)s$/, '$1');
1139
- units = unitAliases[units] || camelFunctions[lowered] || lowered;
1140
- }
1141
- return units;
1142
- }
1143
-
1144
- function normalizeObjectUnits(inputObject) {
1145
- var normalizedInput = {},
1146
- normalizedProp,
1147
- prop;
1148
-
1149
- for (prop in inputObject) {
1150
- if (hasOwnProp(inputObject, prop)) {
1151
- normalizedProp = normalizeUnits(prop);
1152
- if (normalizedProp) {
1153
- normalizedInput[normalizedProp] = inputObject[prop];
1154
- }
1155
- }
1156
- }
1157
-
1158
- return normalizedInput;
1159
- }
1160
-
1161
- function makeList(field) {
1162
- var count, setter;
1163
-
1164
- if (field.indexOf('week') === 0) {
1165
- count = 7;
1166
- setter = 'day';
1167
- }
1168
- else if (field.indexOf('month') === 0) {
1169
- count = 12;
1170
- setter = 'month';
1171
- }
1172
- else {
1173
- return;
1174
- }
1175
-
1176
- moment[field] = function (format, index) {
1177
- var i, getter,
1178
- method = moment._locale[field],
1179
- results = [];
1180
-
1181
- if (typeof format === 'number') {
1182
- index = format;
1183
- format = undefined;
1184
- }
1185
-
1186
- getter = function (i) {
1187
- var m = moment().utc().set(setter, i);
1188
- return method.call(moment._locale, m, format || '');
1189
- };
1190
-
1191
- if (index != null) {
1192
- return getter(index);
1193
- }
1194
- else {
1195
- for (i = 0; i < count; i++) {
1196
- results.push(getter(i));
1197
- }
1198
- return results;
1199
- }
1200
- };
1201
- }
1202
-
1203
- function toInt(argumentForCoercion) {
1204
- var coercedNumber = +argumentForCoercion,
1205
- value = 0;
1206
-
1207
- if (coercedNumber !== 0 && isFinite(coercedNumber)) {
1208
- if (coercedNumber >= 0) {
1209
- value = Math.floor(coercedNumber);
1210
- } else {
1211
- value = Math.ceil(coercedNumber);
1212
- }
1213
- }
1214
-
1215
- return value;
1216
- }
1217
-
1218
- function daysInMonth(year, month) {
1219
- return new Date(Date.UTC(year, month + 1, 0)).getUTCDate();
1220
- }
1221
-
1222
- function weeksInYear(year, dow, doy) {
1223
- return weekOfYear(moment([year, 11, 31 + dow - doy]), dow, doy).week;
1224
- }
1225
-
1226
- function daysInYear(year) {
1227
- return isLeapYear(year) ? 366 : 365;
1228
- }
1229
-
1230
- function isLeapYear(year) {
1231
- return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
1232
- }
1233
-
1234
- function checkOverflow(m) {
1235
- var overflow;
1236
- if (m._a && m._pf.overflow === -2) {
1237
- overflow =
1238
- m._a[MONTH] < 0 || m._a[MONTH] > 11 ? MONTH :
1239
- m._a[DATE] < 1 || m._a[DATE] > daysInMonth(m._a[YEAR], m._a[MONTH]) ? DATE :
1240
- m._a[HOUR] < 0 || m._a[HOUR] > 23 ? HOUR :
1241
- m._a[MINUTE] < 0 || m._a[MINUTE] > 59 ? MINUTE :
1242
- m._a[SECOND] < 0 || m._a[SECOND] > 59 ? SECOND :
1243
- m._a[MILLISECOND] < 0 || m._a[MILLISECOND] > 999 ? MILLISECOND :
1244
- -1;
1245
-
1246
- if (m._pf._overflowDayOfYear && (overflow < YEAR || overflow > DATE)) {
1247
- overflow = DATE;
1248
- }
1249
-
1250
- m._pf.overflow = overflow;
1251
- }
1252
- }
1253
-
1254
- function isValid(m) {
1255
- if (m._isValid == null) {
1256
- m._isValid = !isNaN(m._d.getTime()) &&
1257
- m._pf.overflow < 0 &&
1258
- !m._pf.empty &&
1259
- !m._pf.invalidMonth &&
1260
- !m._pf.nullInput &&
1261
- !m._pf.invalidFormat &&
1262
- !m._pf.userInvalidated;
1263
-
1264
- if (m._strict) {
1265
- m._isValid = m._isValid &&
1266
- m._pf.charsLeftOver === 0 &&
1267
- m._pf.unusedTokens.length === 0;
1268
- }
1269
- }
1270
- return m._isValid;
1271
- }
1272
-
1273
- function normalizeLocale(key) {
1274
- return key ? key.toLowerCase().replace('_', '-') : key;
1275
- }
1276
-
1277
- // pick the locale from the array
1278
- // try ['en-au', 'en-gb'] as 'en-au', 'en-gb', 'en', as in move through the list trying each
1279
- // substring from most specific to least, but move to the next array item if it's a more specific variant than the current root
1280
- function chooseLocale(names) {
1281
- var i = 0, j, next, locale, split;
1282
-
1283
- while (i < names.length) {
1284
- split = normalizeLocale(names[i]).split('-');
1285
- j = split.length;
1286
- next = normalizeLocale(names[i + 1]);
1287
- next = next ? next.split('-') : null;
1288
- while (j > 0) {
1289
- locale = loadLocale(split.slice(0, j).join('-'));
1290
- if (locale) {
1291
- return locale;
1292
- }
1293
- if (next && next.length >= j && compareArrays(split, next, true) >= j - 1) {
1294
- //the next array item is better than a shallower substring of this one
1295
- break;
1296
- }
1297
- j--;
1298
- }
1299
- i++;
1300
- }
1301
- return null;
1302
- }
1303
-
1304
- function loadLocale(name) {
1305
- var oldLocale = null;
1306
- if (!locales[name] && hasModule) {
1307
- try {
1308
- oldLocale = moment.locale();
1309
- _dereq_('./locale/' + name);
1310
- // because defineLocale currently also sets the global locale, we want to undo that for lazy loaded locales
1311
- moment.locale(oldLocale);
1312
- } catch (e) { }
1313
- }
1314
- return locales[name];
1315
- }
1316
-
1317
- // Return a moment from input, that is local/utc/zone equivalent to model.
1318
- function makeAs(input, model) {
1319
- return model._isUTC ? moment(input).zone(model._offset || 0) :
1320
- moment(input).local();
1321
- }
1322
-
1323
- /************************************
1324
- Locale
1325
- ************************************/
1326
-
1327
-
1328
- extend(Locale.prototype, {
1329
-
1330
- set : function (config) {
1331
- var prop, i;
1332
- for (i in config) {
1333
- prop = config[i];
1334
- if (typeof prop === 'function') {
1335
- this[i] = prop;
1336
- } else {
1337
- this['_' + i] = prop;
1338
- }
1339
- }
1340
- },
1341
-
1342
- _months : 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'),
1343
- months : function (m) {
1344
- return this._months[m.month()];
1345
- },
1346
-
1347
- _monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'),
1348
- monthsShort : function (m) {
1349
- return this._monthsShort[m.month()];
1350
- },
1351
-
1352
- monthsParse : function (monthName) {
1353
- var i, mom, regex;
1354
-
1355
- if (!this._monthsParse) {
1356
- this._monthsParse = [];
1357
- }
1358
-
1359
- for (i = 0; i < 12; i++) {
1360
- // make the regex if we don't have it already
1361
- if (!this._monthsParse[i]) {
1362
- mom = moment.utc([2000, i]);
1363
- regex = '^' + this.months(mom, '') + '|^' + this.monthsShort(mom, '');
1364
- this._monthsParse[i] = new RegExp(regex.replace('.', ''), 'i');
1365
- }
1366
- // test the regex
1367
- if (this._monthsParse[i].test(monthName)) {
1368
- return i;
1369
- }
1370
- }
1371
- },
1372
-
1373
- _weekdays : 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'),
1374
- weekdays : function (m) {
1375
- return this._weekdays[m.day()];
1376
- },
1377
-
1378
- _weekdaysShort : 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'),
1379
- weekdaysShort : function (m) {
1380
- return this._weekdaysShort[m.day()];
1381
- },
1382
-
1383
- _weekdaysMin : 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'),
1384
- weekdaysMin : function (m) {
1385
- return this._weekdaysMin[m.day()];
1386
- },
1387
-
1388
- weekdaysParse : function (weekdayName) {
1389
- var i, mom, regex;
1390
-
1391
- if (!this._weekdaysParse) {
1392
- this._weekdaysParse = [];
1393
- }
1394
-
1395
- for (i = 0; i < 7; i++) {
1396
- // make the regex if we don't have it already
1397
- if (!this._weekdaysParse[i]) {
1398
- mom = moment([2000, 1]).day(i);
1399
- regex = '^' + this.weekdays(mom, '') + '|^' + this.weekdaysShort(mom, '') + '|^' + this.weekdaysMin(mom, '');
1400
- this._weekdaysParse[i] = new RegExp(regex.replace('.', ''), 'i');
1401
- }
1402
- // test the regex
1403
- if (this._weekdaysParse[i].test(weekdayName)) {
1404
- return i;
1405
- }
1406
- }
1407
- },
1408
-
1409
- _longDateFormat : {
1410
- LT : 'h:mm A',
1411
- L : 'MM/DD/YYYY',
1412
- LL : 'MMMM D, YYYY',
1413
- LLL : 'MMMM D, YYYY LT',
1414
- LLLL : 'dddd, MMMM D, YYYY LT'
1415
- },
1416
- longDateFormat : function (key) {
1417
- var output = this._longDateFormat[key];
1418
- if (!output && this._longDateFormat[key.toUpperCase()]) {
1419
- output = this._longDateFormat[key.toUpperCase()].replace(/MMMM|MM|DD|dddd/g, function (val) {
1420
- return val.slice(1);
1421
- });
1422
- this._longDateFormat[key] = output;
1423
- }
1424
- return output;
1425
- },
1426
-
1427
- isPM : function (input) {
1428
- // IE8 Quirks Mode & IE7 Standards Mode do not allow accessing strings like arrays
1429
- // Using charAt should be more compatible.
1430
- return ((input + '').toLowerCase().charAt(0) === 'p');
1431
- },
1432
-
1433
- _meridiemParse : /[ap]\.?m?\.?/i,
1434
- meridiem : function (hours, minutes, isLower) {
1435
- if (hours > 11) {
1436
- return isLower ? 'pm' : 'PM';
1437
- } else {
1438
- return isLower ? 'am' : 'AM';
1439
- }
1440
- },
1441
-
1442
- _calendar : {
1443
- sameDay : '[Today at] LT',
1444
- nextDay : '[Tomorrow at] LT',
1445
- nextWeek : 'dddd [at] LT',
1446
- lastDay : '[Yesterday at] LT',
1447
- lastWeek : '[Last] dddd [at] LT',
1448
- sameElse : 'L'
1449
- },
1450
- calendar : function (key, mom) {
1451
- var output = this._calendar[key];
1452
- return typeof output === 'function' ? output.apply(mom) : output;
1453
- },
1454
-
1455
- _relativeTime : {
1456
- future : 'in %s',
1457
- past : '%s ago',
1458
- s : 'a few seconds',
1459
- m : 'a minute',
1460
- mm : '%d minutes',
1461
- h : 'an hour',
1462
- hh : '%d hours',
1463
- d : 'a day',
1464
- dd : '%d days',
1465
- M : 'a month',
1466
- MM : '%d months',
1467
- y : 'a year',
1468
- yy : '%d years'
1469
- },
1470
-
1471
- relativeTime : function (number, withoutSuffix, string, isFuture) {
1472
- var output = this._relativeTime[string];
1473
- return (typeof output === 'function') ?
1474
- output(number, withoutSuffix, string, isFuture) :
1475
- output.replace(/%d/i, number);
1476
- },
1477
-
1478
- pastFuture : function (diff, output) {
1479
- var format = this._relativeTime[diff > 0 ? 'future' : 'past'];
1480
- return typeof format === 'function' ? format(output) : format.replace(/%s/i, output);
1481
- },
1482
-
1483
- ordinal : function (number) {
1484
- return this._ordinal.replace('%d', number);
1485
- },
1486
- _ordinal : '%d',
1487
-
1488
- preparse : function (string) {
1489
- return string;
1490
- },
1491
-
1492
- postformat : function (string) {
1493
- return string;
1494
- },
1495
-
1496
- week : function (mom) {
1497
- return weekOfYear(mom, this._week.dow, this._week.doy).week;
1498
- },
1499
-
1500
- _week : {
1501
- dow : 0, // Sunday is the first day of the week.
1502
- doy : 6 // The week that contains Jan 1st is the first week of the year.
1503
- },
1504
-
1505
- _invalidDate: 'Invalid date',
1506
- invalidDate: function () {
1507
- return this._invalidDate;
1508
- }
1509
- });
1510
-
1511
- /************************************
1512
- Formatting
1513
- ************************************/
1514
-
1515
-
1516
- function removeFormattingTokens(input) {
1517
- if (input.match(/\[[\s\S]/)) {
1518
- return input.replace(/^\[|\]$/g, '');
1519
- }
1520
- return input.replace(/\\/g, '');
1521
- }
1522
-
1523
- function makeFormatFunction(format) {
1524
- var array = format.match(formattingTokens), i, length;
1525
-
1526
- for (i = 0, length = array.length; i < length; i++) {
1527
- if (formatTokenFunctions[array[i]]) {
1528
- array[i] = formatTokenFunctions[array[i]];
1529
- } else {
1530
- array[i] = removeFormattingTokens(array[i]);
1531
- }
1532
- }
1533
-
1534
- return function (mom) {
1535
- var output = '';
1536
- for (i = 0; i < length; i++) {
1537
- output += array[i] instanceof Function ? array[i].call(mom, format) : array[i];
1538
- }
1539
- return output;
1540
- };
1541
- }
1542
-
1543
- // format date using native date object
1544
- function formatMoment(m, format) {
1545
- if (!m.isValid()) {
1546
- return m.localeData().invalidDate();
1547
- }
1548
-
1549
- format = expandFormat(format, m.localeData());
1550
-
1551
- if (!formatFunctions[format]) {
1552
- formatFunctions[format] = makeFormatFunction(format);
1553
- }
1554
-
1555
- return formatFunctions[format](m);
1556
- }
1557
-
1558
- function expandFormat(format, locale) {
1559
- var i = 5;
1560
-
1561
- function replaceLongDateFormatTokens(input) {
1562
- return locale.longDateFormat(input) || input;
1563
- }
1564
-
1565
- localFormattingTokens.lastIndex = 0;
1566
- while (i >= 0 && localFormattingTokens.test(format)) {
1567
- format = format.replace(localFormattingTokens, replaceLongDateFormatTokens);
1568
- localFormattingTokens.lastIndex = 0;
1569
- i -= 1;
1570
- }
1571
-
1572
- return format;
1573
- }
1574
-
1575
-
1576
- /************************************
1577
- Parsing
1578
- ************************************/
1579
-
1580
-
1581
- // get the regex to find the next token
1582
- function getParseRegexForToken(token, config) {
1583
- var a, strict = config._strict;
1584
- switch (token) {
1585
- case 'Q':
1586
- return parseTokenOneDigit;
1587
- case 'DDDD':
1588
- return parseTokenThreeDigits;
1589
- case 'YYYY':
1590
- case 'GGGG':
1591
- case 'gggg':
1592
- return strict ? parseTokenFourDigits : parseTokenOneToFourDigits;
1593
- case 'Y':
1594
- case 'G':
1595
- case 'g':
1596
- return parseTokenSignedNumber;
1597
- case 'YYYYYY':
1598
- case 'YYYYY':
1599
- case 'GGGGG':
1600
- case 'ggggg':
1601
- return strict ? parseTokenSixDigits : parseTokenOneToSixDigits;
1602
- case 'S':
1603
- if (strict) {
1604
- return parseTokenOneDigit;
1605
- }
1606
- /* falls through */
1607
- case 'SS':
1608
- if (strict) {
1609
- return parseTokenTwoDigits;
1610
- }
1611
- /* falls through */
1612
- case 'SSS':
1613
- if (strict) {
1614
- return parseTokenThreeDigits;
1615
- }
1616
- /* falls through */
1617
- case 'DDD':
1618
- return parseTokenOneToThreeDigits;
1619
- case 'MMM':
1620
- case 'MMMM':
1621
- case 'dd':
1622
- case 'ddd':
1623
- case 'dddd':
1624
- return parseTokenWord;
1625
- case 'a':
1626
- case 'A':
1627
- return config._locale._meridiemParse;
1628
- case 'X':
1629
- return parseTokenTimestampMs;
1630
- case 'Z':
1631
- case 'ZZ':
1632
- return parseTokenTimezone;
1633
- case 'T':
1634
- return parseTokenT;
1635
- case 'SSSS':
1636
- return parseTokenDigits;
1637
- case 'MM':
1638
- case 'DD':
1639
- case 'YY':
1640
- case 'GG':
1641
- case 'gg':
1642
- case 'HH':
1643
- case 'hh':
1644
- case 'mm':
1645
- case 'ss':
1646
- case 'ww':
1647
- case 'WW':
1648
- return strict ? parseTokenTwoDigits : parseTokenOneOrTwoDigits;
1649
- case 'M':
1650
- case 'D':
1651
- case 'd':
1652
- case 'H':
1653
- case 'h':
1654
- case 'm':
1655
- case 's':
1656
- case 'w':
1657
- case 'W':
1658
- case 'e':
1659
- case 'E':
1660
- return parseTokenOneOrTwoDigits;
1661
- case 'Do':
1662
- return parseTokenOrdinal;
1663
- default :
1664
- a = new RegExp(regexpEscape(unescapeFormat(token.replace('\\', '')), 'i'));
1665
- return a;
1666
- }
1667
- }
1668
-
1669
- function timezoneMinutesFromString(string) {
1670
- string = string || '';
1671
- var possibleTzMatches = (string.match(parseTokenTimezone) || []),
1672
- tzChunk = possibleTzMatches[possibleTzMatches.length - 1] || [],
1673
- parts = (tzChunk + '').match(parseTimezoneChunker) || ['-', 0, 0],
1674
- minutes = +(parts[1] * 60) + toInt(parts[2]);
1675
-
1676
- return parts[0] === '+' ? -minutes : minutes;
1677
- }
1678
-
1679
- // function to convert string input to date
1680
- function addTimeToArrayFromToken(token, input, config) {
1681
- var a, datePartArray = config._a;
1682
-
1683
- switch (token) {
1684
- // QUARTER
1685
- case 'Q':
1686
- if (input != null) {
1687
- datePartArray[MONTH] = (toInt(input) - 1) * 3;
1688
- }
1689
- break;
1690
- // MONTH
1691
- case 'M' : // fall through to MM
1692
- case 'MM' :
1693
- if (input != null) {
1694
- datePartArray[MONTH] = toInt(input) - 1;
1695
- }
1696
- break;
1697
- case 'MMM' : // fall through to MMMM
1698
- case 'MMMM' :
1699
- a = config._locale.monthsParse(input);
1700
- // if we didn't find a month name, mark the date as invalid.
1701
- if (a != null) {
1702
- datePartArray[MONTH] = a;
1703
- } else {
1704
- config._pf.invalidMonth = input;
1705
- }
1706
- break;
1707
- // DAY OF MONTH
1708
- case 'D' : // fall through to DD
1709
- case 'DD' :
1710
- if (input != null) {
1711
- datePartArray[DATE] = toInt(input);
1712
- }
1713
- break;
1714
- case 'Do' :
1715
- if (input != null) {
1716
- datePartArray[DATE] = toInt(parseInt(input, 10));
1717
- }
1718
- break;
1719
- // DAY OF YEAR
1720
- case 'DDD' : // fall through to DDDD
1721
- case 'DDDD' :
1722
- if (input != null) {
1723
- config._dayOfYear = toInt(input);
1724
- }
1725
-
1726
- break;
1727
- // YEAR
1728
- case 'YY' :
1729
- datePartArray[YEAR] = moment.parseTwoDigitYear(input);
1730
- break;
1731
- case 'YYYY' :
1732
- case 'YYYYY' :
1733
- case 'YYYYYY' :
1734
- datePartArray[YEAR] = toInt(input);
1735
- break;
1736
- // AM / PM
1737
- case 'a' : // fall through to A
1738
- case 'A' :
1739
- config._isPm = config._locale.isPM(input);
1740
- break;
1741
- // 24 HOUR
1742
- case 'H' : // fall through to hh
1743
- case 'HH' : // fall through to hh
1744
- case 'h' : // fall through to hh
1745
- case 'hh' :
1746
- datePartArray[HOUR] = toInt(input);
1747
- break;
1748
- // MINUTE
1749
- case 'm' : // fall through to mm
1750
- case 'mm' :
1751
- datePartArray[MINUTE] = toInt(input);
1752
- break;
1753
- // SECOND
1754
- case 's' : // fall through to ss
1755
- case 'ss' :
1756
- datePartArray[SECOND] = toInt(input);
1757
- break;
1758
- // MILLISECOND
1759
- case 'S' :
1760
- case 'SS' :
1761
- case 'SSS' :
1762
- case 'SSSS' :
1763
- datePartArray[MILLISECOND] = toInt(('0.' + input) * 1000);
1764
- break;
1765
- // UNIX TIMESTAMP WITH MS
1766
- case 'X':
1767
- config._d = new Date(parseFloat(input) * 1000);
1768
- break;
1769
- // TIMEZONE
1770
- case 'Z' : // fall through to ZZ
1771
- case 'ZZ' :
1772
- config._useUTC = true;
1773
- config._tzm = timezoneMinutesFromString(input);
1774
- break;
1775
- // WEEKDAY - human
1776
- case 'dd':
1777
- case 'ddd':
1778
- case 'dddd':
1779
- a = config._locale.weekdaysParse(input);
1780
- // if we didn't get a weekday name, mark the date as invalid
1781
- if (a != null) {
1782
- config._w = config._w || {};
1783
- config._w['d'] = a;
1784
- } else {
1785
- config._pf.invalidWeekday = input;
1786
- }
1787
- break;
1788
- // WEEK, WEEK DAY - numeric
1789
- case 'w':
1790
- case 'ww':
1791
- case 'W':
1792
- case 'WW':
1793
- case 'd':
1794
- case 'e':
1795
- case 'E':
1796
- token = token.substr(0, 1);
1797
- /* falls through */
1798
- case 'gggg':
1799
- case 'GGGG':
1800
- case 'GGGGG':
1801
- token = token.substr(0, 2);
1802
- if (input) {
1803
- config._w = config._w || {};
1804
- config._w[token] = toInt(input);
1805
- }
1806
- break;
1807
- case 'gg':
1808
- case 'GG':
1809
- config._w = config._w || {};
1810
- config._w[token] = moment.parseTwoDigitYear(input);
1811
- }
1812
- }
1813
-
1814
- function dayOfYearFromWeekInfo(config) {
1815
- var w, weekYear, week, weekday, dow, doy, temp;
1816
-
1817
- w = config._w;
1818
- if (w.GG != null || w.W != null || w.E != null) {
1819
- dow = 1;
1820
- doy = 4;
1821
-
1822
- // TODO: We need to take the current isoWeekYear, but that depends on
1823
- // how we interpret now (local, utc, fixed offset). So create
1824
- // a now version of current config (take local/utc/offset flags, and
1825
- // create now).
1826
- weekYear = dfl(w.GG, config._a[YEAR], weekOfYear(moment(), 1, 4).year);
1827
- week = dfl(w.W, 1);
1828
- weekday = dfl(w.E, 1);
1829
- } else {
1830
- dow = config._locale._week.dow;
1831
- doy = config._locale._week.doy;
1832
-
1833
- weekYear = dfl(w.gg, config._a[YEAR], weekOfYear(moment(), dow, doy).year);
1834
- week = dfl(w.w, 1);
1835
-
1836
- if (w.d != null) {
1837
- // weekday -- low day numbers are considered next week
1838
- weekday = w.d;
1839
- if (weekday < dow) {
1840
- ++week;
1841
- }
1842
- } else if (w.e != null) {
1843
- // local weekday -- counting starts from begining of week
1844
- weekday = w.e + dow;
1845
- } else {
1846
- // default to begining of week
1847
- weekday = dow;
1848
- }
1849
- }
1850
- temp = dayOfYearFromWeeks(weekYear, week, weekday, doy, dow);
1851
-
1852
- config._a[YEAR] = temp.year;
1853
- config._dayOfYear = temp.dayOfYear;
1854
- }
1855
-
1856
- // convert an array to a date.
1857
- // the array should mirror the parameters below
1858
- // note: all values past the year are optional and will default to the lowest possible value.
1859
- // [year, month, day , hour, minute, second, millisecond]
1860
- function dateFromConfig(config) {
1861
- var i, date, input = [], currentDate, yearToUse;
1862
-
1863
- if (config._d) {
1864
- return;
1865
- }
1866
-
1867
- currentDate = currentDateArray(config);
1868
-
1869
- //compute day of the year from weeks and weekdays
1870
- if (config._w && config._a[DATE] == null && config._a[MONTH] == null) {
1871
- dayOfYearFromWeekInfo(config);
1872
- }
1873
-
1874
- //if the day of the year is set, figure out what it is
1875
- if (config._dayOfYear) {
1876
- yearToUse = dfl(config._a[YEAR], currentDate[YEAR]);
1877
-
1878
- if (config._dayOfYear > daysInYear(yearToUse)) {
1879
- config._pf._overflowDayOfYear = true;
1880
- }
1881
-
1882
- date = makeUTCDate(yearToUse, 0, config._dayOfYear);
1883
- config._a[MONTH] = date.getUTCMonth();
1884
- config._a[DATE] = date.getUTCDate();
1885
- }
1886
-
1887
- // Default to current date.
1888
- // * if no year, month, day of month are given, default to today
1889
- // * if day of month is given, default month and year
1890
- // * if month is given, default only year
1891
- // * if year is given, don't default anything
1892
- for (i = 0; i < 3 && config._a[i] == null; ++i) {
1893
- config._a[i] = input[i] = currentDate[i];
1894
- }
1895
-
1896
- // Zero out whatever was not defaulted, including time
1897
- for (; i < 7; i++) {
1898
- config._a[i] = input[i] = (config._a[i] == null) ? (i === 2 ? 1 : 0) : config._a[i];
1899
- }
1900
-
1901
- config._d = (config._useUTC ? makeUTCDate : makeDate).apply(null, input);
1902
- // Apply timezone offset from input. The actual zone can be changed
1903
- // with parseZone.
1904
- if (config._tzm != null) {
1905
- config._d.setUTCMinutes(config._d.getUTCMinutes() + config._tzm);
1906
- }
1907
- }
1908
-
1909
- function dateFromObject(config) {
1910
- var normalizedInput;
1911
-
1912
- if (config._d) {
1913
- return;
1914
- }
1915
-
1916
- normalizedInput = normalizeObjectUnits(config._i);
1917
- config._a = [
1918
- normalizedInput.year,
1919
- normalizedInput.month,
1920
- normalizedInput.day,
1921
- normalizedInput.hour,
1922
- normalizedInput.minute,
1923
- normalizedInput.second,
1924
- normalizedInput.millisecond
1925
- ];
1926
-
1927
- dateFromConfig(config);
1928
- }
1929
-
1930
- function currentDateArray(config) {
1931
- var now = new Date();
1932
- if (config._useUTC) {
1933
- return [
1934
- now.getUTCFullYear(),
1935
- now.getUTCMonth(),
1936
- now.getUTCDate()
1937
- ];
1938
- } else {
1939
- return [now.getFullYear(), now.getMonth(), now.getDate()];
1940
- }
1941
- }
1942
-
1943
- // date from string and format string
1944
- function makeDateFromStringAndFormat(config) {
1945
- if (config._f === moment.ISO_8601) {
1946
- parseISO(config);
1947
- return;
1948
- }
1949
-
1950
- config._a = [];
1951
- config._pf.empty = true;
1952
-
1953
- // This array is used to make a Date, either with `new Date` or `Date.UTC`
1954
- var string = '' + config._i,
1955
- i, parsedInput, tokens, token, skipped,
1956
- stringLength = string.length,
1957
- totalParsedInputLength = 0;
1958
-
1959
- tokens = expandFormat(config._f, config._locale).match(formattingTokens) || [];
1960
-
1961
- for (i = 0; i < tokens.length; i++) {
1962
- token = tokens[i];
1963
- parsedInput = (string.match(getParseRegexForToken(token, config)) || [])[0];
1964
- if (parsedInput) {
1965
- skipped = string.substr(0, string.indexOf(parsedInput));
1966
- if (skipped.length > 0) {
1967
- config._pf.unusedInput.push(skipped);
1968
- }
1969
- string = string.slice(string.indexOf(parsedInput) + parsedInput.length);
1970
- totalParsedInputLength += parsedInput.length;
1971
- }
1972
- // don't parse if it's not a known token
1973
- if (formatTokenFunctions[token]) {
1974
- if (parsedInput) {
1975
- config._pf.empty = false;
1976
- }
1977
- else {
1978
- config._pf.unusedTokens.push(token);
1979
- }
1980
- addTimeToArrayFromToken(token, parsedInput, config);
1981
- }
1982
- else if (config._strict && !parsedInput) {
1983
- config._pf.unusedTokens.push(token);
1984
- }
1985
- }
1986
-
1987
- // add remaining unparsed input length to the string
1988
- config._pf.charsLeftOver = stringLength - totalParsedInputLength;
1989
- if (string.length > 0) {
1990
- config._pf.unusedInput.push(string);
1991
- }
1992
-
1993
- // handle am pm
1994
- if (config._isPm && config._a[HOUR] < 12) {
1995
- config._a[HOUR] += 12;
1996
- }
1997
- // if is 12 am, change hours to 0
1998
- if (config._isPm === false && config._a[HOUR] === 12) {
1999
- config._a[HOUR] = 0;
2000
- }
2001
-
2002
- dateFromConfig(config);
2003
- checkOverflow(config);
2004
- }
2005
-
2006
- function unescapeFormat(s) {
2007
- return s.replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g, function (matched, p1, p2, p3, p4) {
2008
- return p1 || p2 || p3 || p4;
2009
- });
2010
- }
2011
-
2012
- // Code from http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript
2013
- function regexpEscape(s) {
2014
- return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
2015
- }
2016
-
2017
- // date from string and array of format strings
2018
- function makeDateFromStringAndArray(config) {
2019
- var tempConfig,
2020
- bestMoment,
2021
-
2022
- scoreToBeat,
2023
- i,
2024
- currentScore;
2025
-
2026
- if (config._f.length === 0) {
2027
- config._pf.invalidFormat = true;
2028
- config._d = new Date(NaN);
2029
- return;
2030
- }
2031
-
2032
- for (i = 0; i < config._f.length; i++) {
2033
- currentScore = 0;
2034
- tempConfig = copyConfig({}, config);
2035
- tempConfig._pf = defaultParsingFlags();
2036
- tempConfig._f = config._f[i];
2037
- makeDateFromStringAndFormat(tempConfig);
2038
-
2039
- if (!isValid(tempConfig)) {
2040
- continue;
2041
- }
2042
-
2043
- // if there is any input that was not parsed add a penalty for that format
2044
- currentScore += tempConfig._pf.charsLeftOver;
2045
-
2046
- //or tokens
2047
- currentScore += tempConfig._pf.unusedTokens.length * 10;
2048
-
2049
- tempConfig._pf.score = currentScore;
2050
-
2051
- if (scoreToBeat == null || currentScore < scoreToBeat) {
2052
- scoreToBeat = currentScore;
2053
- bestMoment = tempConfig;
2054
- }
2055
- }
2056
-
2057
- extend(config, bestMoment || tempConfig);
2058
- }
2059
-
2060
- // date from iso format
2061
- function parseISO(config) {
2062
- var i, l,
2063
- string = config._i,
2064
- match = isoRegex.exec(string);
2065
-
2066
- if (match) {
2067
- config._pf.iso = true;
2068
- for (i = 0, l = isoDates.length; i < l; i++) {
2069
- if (isoDates[i][1].exec(string)) {
2070
- // match[5] should be 'T' or undefined
2071
- config._f = isoDates[i][0] + (match[6] || ' ');
2072
- break;
2073
- }
2074
- }
2075
- for (i = 0, l = isoTimes.length; i < l; i++) {
2076
- if (isoTimes[i][1].exec(string)) {
2077
- config._f += isoTimes[i][0];
2078
- break;
2079
- }
2080
- }
2081
- if (string.match(parseTokenTimezone)) {
2082
- config._f += 'Z';
2083
- }
2084
- makeDateFromStringAndFormat(config);
2085
- } else {
2086
- config._isValid = false;
2087
- }
2088
- }
2089
-
2090
- // date from iso format or fallback
2091
- function makeDateFromString(config) {
2092
- parseISO(config);
2093
- if (config._isValid === false) {
2094
- delete config._isValid;
2095
- moment.createFromInputFallback(config);
2096
- }
2097
- }
2098
-
2099
- function makeDateFromInput(config) {
2100
- var input = config._i, matched;
2101
- if (input === undefined) {
2102
- config._d = new Date();
2103
- } else if (isDate(input)) {
2104
- config._d = new Date(+input);
2105
- } else if ((matched = aspNetJsonRegex.exec(input)) !== null) {
2106
- config._d = new Date(+matched[1]);
2107
- } else if (typeof input === 'string') {
2108
- makeDateFromString(config);
2109
- } else if (isArray(input)) {
2110
- config._a = input.slice(0);
2111
- dateFromConfig(config);
2112
- } else if (typeof(input) === 'object') {
2113
- dateFromObject(config);
2114
- } else if (typeof(input) === 'number') {
2115
- // from milliseconds
2116
- config._d = new Date(input);
2117
- } else {
2118
- moment.createFromInputFallback(config);
2119
- }
2120
- }
2121
-
2122
- function makeDate(y, m, d, h, M, s, ms) {
2123
- //can't just apply() to create a date:
2124
- //http://stackoverflow.com/questions/181348/instantiating-a-javascript-object-by-calling-prototype-constructor-apply
2125
- var date = new Date(y, m, d, h, M, s, ms);
2126
-
2127
- //the date constructor doesn't accept years < 1970
2128
- if (y < 1970) {
2129
- date.setFullYear(y);
2130
- }
2131
- return date;
2132
- }
2133
-
2134
- function makeUTCDate(y) {
2135
- var date = new Date(Date.UTC.apply(null, arguments));
2136
- if (y < 1970) {
2137
- date.setUTCFullYear(y);
2138
- }
2139
- return date;
2140
- }
2141
-
2142
- function parseWeekday(input, locale) {
2143
- if (typeof input === 'string') {
2144
- if (!isNaN(input)) {
2145
- input = parseInt(input, 10);
2146
- }
2147
- else {
2148
- input = locale.weekdaysParse(input);
2149
- if (typeof input !== 'number') {
2150
- return null;
2151
- }
2152
- }
2153
- }
2154
- return input;
2155
- }
2156
-
2157
- /************************************
2158
- Relative Time
2159
- ************************************/
2160
-
2161
-
2162
- // helper function for moment.fn.from, moment.fn.fromNow, and moment.duration.fn.humanize
2163
- function substituteTimeAgo(string, number, withoutSuffix, isFuture, locale) {
2164
- return locale.relativeTime(number || 1, !!withoutSuffix, string, isFuture);
2165
- }
2166
-
2167
- function relativeTime(posNegDuration, withoutSuffix, locale) {
2168
- var duration = moment.duration(posNegDuration).abs(),
2169
- seconds = round(duration.as('s')),
2170
- minutes = round(duration.as('m')),
2171
- hours = round(duration.as('h')),
2172
- days = round(duration.as('d')),
2173
- months = round(duration.as('M')),
2174
- years = round(duration.as('y')),
2175
-
2176
- args = seconds < relativeTimeThresholds.s && ['s', seconds] ||
2177
- minutes === 1 && ['m'] ||
2178
- minutes < relativeTimeThresholds.m && ['mm', minutes] ||
2179
- hours === 1 && ['h'] ||
2180
- hours < relativeTimeThresholds.h && ['hh', hours] ||
2181
- days === 1 && ['d'] ||
2182
- days < relativeTimeThresholds.d && ['dd', days] ||
2183
- months === 1 && ['M'] ||
2184
- months < relativeTimeThresholds.M && ['MM', months] ||
2185
- years === 1 && ['y'] || ['yy', years];
2186
-
2187
- args[2] = withoutSuffix;
2188
- args[3] = +posNegDuration > 0;
2189
- args[4] = locale;
2190
- return substituteTimeAgo.apply({}, args);
2191
- }
2192
-
2193
-
2194
- /************************************
2195
- Week of Year
2196
- ************************************/
2197
-
2198
-
2199
- // firstDayOfWeek 0 = sun, 6 = sat
2200
- // the day of the week that starts the week
2201
- // (usually sunday or monday)
2202
- // firstDayOfWeekOfYear 0 = sun, 6 = sat
2203
- // the first week is the week that contains the first
2204
- // of this day of the week
2205
- // (eg. ISO weeks use thursday (4))
2206
- function weekOfYear(mom, firstDayOfWeek, firstDayOfWeekOfYear) {
2207
- var end = firstDayOfWeekOfYear - firstDayOfWeek,
2208
- daysToDayOfWeek = firstDayOfWeekOfYear - mom.day(),
2209
- adjustedMoment;
2210
-
2211
-
2212
- if (daysToDayOfWeek > end) {
2213
- daysToDayOfWeek -= 7;
2214
- }
2215
-
2216
- if (daysToDayOfWeek < end - 7) {
2217
- daysToDayOfWeek += 7;
2218
- }
2219
-
2220
- adjustedMoment = moment(mom).add(daysToDayOfWeek, 'd');
2221
- return {
2222
- week: Math.ceil(adjustedMoment.dayOfYear() / 7),
2223
- year: adjustedMoment.year()
2224
- };
2225
- }
2226
-
2227
- //http://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday
2228
- function dayOfYearFromWeeks(year, week, weekday, firstDayOfWeekOfYear, firstDayOfWeek) {
2229
- var d = makeUTCDate(year, 0, 1).getUTCDay(), daysToAdd, dayOfYear;
2230
-
2231
- d = d === 0 ? 7 : d;
2232
- weekday = weekday != null ? weekday : firstDayOfWeek;
2233
- daysToAdd = firstDayOfWeek - d + (d > firstDayOfWeekOfYear ? 7 : 0) - (d < firstDayOfWeek ? 7 : 0);
2234
- dayOfYear = 7 * (week - 1) + (weekday - firstDayOfWeek) + daysToAdd + 1;
2235
-
2236
- return {
2237
- year: dayOfYear > 0 ? year : year - 1,
2238
- dayOfYear: dayOfYear > 0 ? dayOfYear : daysInYear(year - 1) + dayOfYear
2239
- };
2240
- }
2241
-
2242
- /************************************
2243
- Top Level Functions
2244
- ************************************/
2245
-
2246
- function makeMoment(config) {
2247
- var input = config._i,
2248
- format = config._f;
2249
-
2250
- config._locale = config._locale || moment.localeData(config._l);
2251
-
2252
- if (input === null || (format === undefined && input === '')) {
2253
- return moment.invalid({nullInput: true});
2254
- }
2255
-
2256
- if (typeof input === 'string') {
2257
- config._i = input = config._locale.preparse(input);
2258
- }
2259
-
2260
- if (moment.isMoment(input)) {
2261
- return new Moment(input, true);
2262
- } else if (format) {
2263
- if (isArray(format)) {
2264
- makeDateFromStringAndArray(config);
2265
- } else {
2266
- makeDateFromStringAndFormat(config);
2267
- }
2268
- } else {
2269
- makeDateFromInput(config);
2270
- }
2271
-
2272
- return new Moment(config);
2273
- }
2274
-
2275
- moment = function (input, format, locale, strict) {
2276
- var c;
2277
-
2278
- if (typeof(locale) === 'boolean') {
2279
- strict = locale;
2280
- locale = undefined;
2281
- }
2282
- // object construction must be done this way.
2283
- // https://github.com/moment/moment/issues/1423
2284
- c = {};
2285
- c._isAMomentObject = true;
2286
- c._i = input;
2287
- c._f = format;
2288
- c._l = locale;
2289
- c._strict = strict;
2290
- c._isUTC = false;
2291
- c._pf = defaultParsingFlags();
2292
-
2293
- return makeMoment(c);
2294
- };
2295
-
2296
- moment.suppressDeprecationWarnings = false;
2297
-
2298
- moment.createFromInputFallback = deprecate(
2299
- 'moment construction falls back to js Date. This is ' +
2300
- 'discouraged and will be removed in upcoming major ' +
2301
- 'release. Please refer to ' +
2302
- 'https://github.com/moment/moment/issues/1407 for more info.',
2303
- function (config) {
2304
- config._d = new Date(config._i);
2305
- }
2306
- );
2307
-
2308
- // Pick a moment m from moments so that m[fn](other) is true for all
2309
- // other. This relies on the function fn to be transitive.
2310
- //
2311
- // moments should either be an array of moment objects or an array, whose
2312
- // first element is an array of moment objects.
2313
- function pickBy(fn, moments) {
2314
- var res, i;
2315
- if (moments.length === 1 && isArray(moments[0])) {
2316
- moments = moments[0];
2317
- }
2318
- if (!moments.length) {
2319
- return moment();
2320
- }
2321
- res = moments[0];
2322
- for (i = 1; i < moments.length; ++i) {
2323
- if (moments[i][fn](res)) {
2324
- res = moments[i];
2325
- }
2326
- }
2327
- return res;
2328
- }
2329
-
2330
- moment.min = function () {
2331
- var args = [].slice.call(arguments, 0);
2332
-
2333
- return pickBy('isBefore', args);
2334
- };
2335
-
2336
- moment.max = function () {
2337
- var args = [].slice.call(arguments, 0);
2338
-
2339
- return pickBy('isAfter', args);
2340
- };
2341
-
2342
- // creating with utc
2343
- moment.utc = function (input, format, locale, strict) {
2344
- var c;
2345
-
2346
- if (typeof(locale) === 'boolean') {
2347
- strict = locale;
2348
- locale = undefined;
2349
- }
2350
- // object construction must be done this way.
2351
- // https://github.com/moment/moment/issues/1423
2352
- c = {};
2353
- c._isAMomentObject = true;
2354
- c._useUTC = true;
2355
- c._isUTC = true;
2356
- c._l = locale;
2357
- c._i = input;
2358
- c._f = format;
2359
- c._strict = strict;
2360
- c._pf = defaultParsingFlags();
2361
-
2362
- return makeMoment(c).utc();
2363
- };
2364
-
2365
- // creating with unix timestamp (in seconds)
2366
- moment.unix = function (input) {
2367
- return moment(input * 1000);
2368
- };
2369
-
2370
- // duration
2371
- moment.duration = function (input, key) {
2372
- var duration = input,
2373
- // matching against regexp is expensive, do it on demand
2374
- match = null,
2375
- sign,
2376
- ret,
2377
- parseIso,
2378
- diffRes;
2379
-
2380
- if (moment.isDuration(input)) {
2381
- duration = {
2382
- ms: input._milliseconds,
2383
- d: input._days,
2384
- M: input._months
2385
- };
2386
- } else if (typeof input === 'number') {
2387
- duration = {};
2388
- if (key) {
2389
- duration[key] = input;
2390
- } else {
2391
- duration.milliseconds = input;
2392
- }
2393
- } else if (!!(match = aspNetTimeSpanJsonRegex.exec(input))) {
2394
- sign = (match[1] === '-') ? -1 : 1;
2395
- duration = {
2396
- y: 0,
2397
- d: toInt(match[DATE]) * sign,
2398
- h: toInt(match[HOUR]) * sign,
2399
- m: toInt(match[MINUTE]) * sign,
2400
- s: toInt(match[SECOND]) * sign,
2401
- ms: toInt(match[MILLISECOND]) * sign
2402
- };
2403
- } else if (!!(match = isoDurationRegex.exec(input))) {
2404
- sign = (match[1] === '-') ? -1 : 1;
2405
- parseIso = function (inp) {
2406
- // We'd normally use ~~inp for this, but unfortunately it also
2407
- // converts floats to ints.
2408
- // inp may be undefined, so careful calling replace on it.
2409
- var res = inp && parseFloat(inp.replace(',', '.'));
2410
- // apply sign while we're at it
2411
- return (isNaN(res) ? 0 : res) * sign;
2412
- };
2413
- duration = {
2414
- y: parseIso(match[2]),
2415
- M: parseIso(match[3]),
2416
- d: parseIso(match[4]),
2417
- h: parseIso(match[5]),
2418
- m: parseIso(match[6]),
2419
- s: parseIso(match[7]),
2420
- w: parseIso(match[8])
2421
- };
2422
- } else if (typeof duration === 'object' &&
2423
- ('from' in duration || 'to' in duration)) {
2424
- diffRes = momentsDifference(moment(duration.from), moment(duration.to));
2425
-
2426
- duration = {};
2427
- duration.ms = diffRes.milliseconds;
2428
- duration.M = diffRes.months;
2429
- }
2430
-
2431
- ret = new Duration(duration);
2432
-
2433
- if (moment.isDuration(input) && hasOwnProp(input, '_locale')) {
2434
- ret._locale = input._locale;
2435
- }
2436
-
2437
- return ret;
2438
- };
2439
-
2440
- // version number
2441
- moment.version = VERSION;
2442
-
2443
- // default format
2444
- moment.defaultFormat = isoFormat;
2445
-
2446
- // constant that refers to the ISO standard
2447
- moment.ISO_8601 = function () {};
2448
-
2449
- // Plugins that add properties should also add the key here (null value),
2450
- // so we can properly clone ourselves.
2451
- moment.momentProperties = momentProperties;
2452
-
2453
- // This function will be called whenever a moment is mutated.
2454
- // It is intended to keep the offset in sync with the timezone.
2455
- moment.updateOffset = function () {};
2456
-
2457
- // This function allows you to set a threshold for relative time strings
2458
- moment.relativeTimeThreshold = function (threshold, limit) {
2459
- if (relativeTimeThresholds[threshold] === undefined) {
2460
- return false;
2461
- }
2462
- if (limit === undefined) {
2463
- return relativeTimeThresholds[threshold];
2464
- }
2465
- relativeTimeThresholds[threshold] = limit;
2466
- return true;
2467
- };
2468
-
2469
- moment.lang = deprecate(
2470
- 'moment.lang is deprecated. Use moment.locale instead.',
2471
- function (key, value) {
2472
- return moment.locale(key, value);
2473
- }
2474
- );
2475
-
2476
- // This function will load locale and then set the global locale. If
2477
- // no arguments are passed in, it will simply return the current global
2478
- // locale key.
2479
- moment.locale = function (key, values) {
2480
- var data;
2481
- if (key) {
2482
- if (typeof(values) !== 'undefined') {
2483
- data = moment.defineLocale(key, values);
2484
- }
2485
- else {
2486
- data = moment.localeData(key);
2487
- }
2488
-
2489
- if (data) {
2490
- moment.duration._locale = moment._locale = data;
2491
- }
2492
- }
2493
-
2494
- return moment._locale._abbr;
2495
- };
2496
-
2497
- moment.defineLocale = function (name, values) {
2498
- if (values !== null) {
2499
- values.abbr = name;
2500
- if (!locales[name]) {
2501
- locales[name] = new Locale();
2502
- }
2503
- locales[name].set(values);
2504
-
2505
- // backwards compat for now: also set the locale
2506
- moment.locale(name);
2507
-
2508
- return locales[name];
2509
- } else {
2510
- // useful for testing
2511
- delete locales[name];
2512
- return null;
2513
- }
2514
- };
2515
-
2516
- moment.langData = deprecate(
2517
- 'moment.langData is deprecated. Use moment.localeData instead.',
2518
- function (key) {
2519
- return moment.localeData(key);
2520
- }
2521
- );
2522
-
2523
- // returns locale data
2524
- moment.localeData = function (key) {
2525
- var locale;
2526
-
2527
- if (key && key._locale && key._locale._abbr) {
2528
- key = key._locale._abbr;
2529
- }
2530
-
2531
- if (!key) {
2532
- return moment._locale;
2533
- }
2534
-
2535
- if (!isArray(key)) {
2536
- //short-circuit everything else
2537
- locale = loadLocale(key);
2538
- if (locale) {
2539
- return locale;
2540
- }
2541
- key = [key];
2542
- }
2543
-
2544
- return chooseLocale(key);
2545
- };
2546
-
2547
- // compare moment object
2548
- moment.isMoment = function (obj) {
2549
- return obj instanceof Moment ||
2550
- (obj != null && hasOwnProp(obj, '_isAMomentObject'));
2551
- };
2552
-
2553
- // for typechecking Duration objects
2554
- moment.isDuration = function (obj) {
2555
- return obj instanceof Duration;
2556
- };
2557
-
2558
- for (i = lists.length - 1; i >= 0; --i) {
2559
- makeList(lists[i]);
2560
- }
2561
-
2562
- moment.normalizeUnits = function (units) {
2563
- return normalizeUnits(units);
2564
- };
2565
-
2566
- moment.invalid = function (flags) {
2567
- var m = moment.utc(NaN);
2568
- if (flags != null) {
2569
- extend(m._pf, flags);
2570
- }
2571
- else {
2572
- m._pf.userInvalidated = true;
2573
- }
2574
-
2575
- return m;
2576
- };
2577
-
2578
- moment.parseZone = function () {
2579
- return moment.apply(null, arguments).parseZone();
2580
- };
2581
-
2582
- moment.parseTwoDigitYear = function (input) {
2583
- return toInt(input) + (toInt(input) > 68 ? 1900 : 2000);
2584
- };
2585
-
2586
- /************************************
2587
- Moment Prototype
2588
- ************************************/
2589
-
2590
-
2591
- extend(moment.fn = Moment.prototype, {
2592
-
2593
- clone : function () {
2594
- return moment(this);
2595
- },
2596
-
2597
- valueOf : function () {
2598
- return +this._d + ((this._offset || 0) * 60000);
2599
- },
2600
-
2601
- unix : function () {
2602
- return Math.floor(+this / 1000);
2603
- },
2604
-
2605
- toString : function () {
2606
- return this.clone().locale('en').format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ');
2607
- },
2608
-
2609
- toDate : function () {
2610
- return this._offset ? new Date(+this) : this._d;
2611
- },
2612
-
2613
- toISOString : function () {
2614
- var m = moment(this).utc();
2615
- if (0 < m.year() && m.year() <= 9999) {
2616
- return formatMoment(m, 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]');
2617
- } else {
2618
- return formatMoment(m, 'YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]');
2619
- }
2620
- },
2621
-
2622
- toArray : function () {
2623
- var m = this;
2624
- return [
2625
- m.year(),
2626
- m.month(),
2627
- m.date(),
2628
- m.hours(),
2629
- m.minutes(),
2630
- m.seconds(),
2631
- m.milliseconds()
2632
- ];
2633
- },
2634
-
2635
- isValid : function () {
2636
- return isValid(this);
2637
- },
2638
-
2639
- isDSTShifted : function () {
2640
- if (this._a) {
2641
- return this.isValid() && compareArrays(this._a, (this._isUTC ? moment.utc(this._a) : moment(this._a)).toArray()) > 0;
2642
- }
2643
-
2644
- return false;
2645
- },
2646
-
2647
- parsingFlags : function () {
2648
- return extend({}, this._pf);
2649
- },
2650
-
2651
- invalidAt: function () {
2652
- return this._pf.overflow;
2653
- },
2654
-
2655
- utc : function (keepLocalTime) {
2656
- return this.zone(0, keepLocalTime);
2657
- },
2658
-
2659
- local : function (keepLocalTime) {
2660
- if (this._isUTC) {
2661
- this.zone(0, keepLocalTime);
2662
- this._isUTC = false;
2663
-
2664
- if (keepLocalTime) {
2665
- this.add(this._d.getTimezoneOffset(), 'm');
2666
- }
2667
- }
2668
- return this;
2669
- },
2670
-
2671
- format : function (inputString) {
2672
- var output = formatMoment(this, inputString || moment.defaultFormat);
2673
- return this.localeData().postformat(output);
2674
- },
2675
-
2676
- add : createAdder(1, 'add'),
2677
-
2678
- subtract : createAdder(-1, 'subtract'),
2679
-
2680
- diff : function (input, units, asFloat) {
2681
- var that = makeAs(input, this),
2682
- zoneDiff = (this.zone() - that.zone()) * 6e4,
2683
- diff, output;
2684
-
2685
- units = normalizeUnits(units);
2686
-
2687
- if (units === 'year' || units === 'month') {
2688
- // average number of days in the months in the given dates
2689
- diff = (this.daysInMonth() + that.daysInMonth()) * 432e5; // 24 * 60 * 60 * 1000 / 2
2690
- // difference in months
2691
- output = ((this.year() - that.year()) * 12) + (this.month() - that.month());
2692
- // adjust by taking difference in days, average number of days
2693
- // and dst in the given months.
2694
- output += ((this - moment(this).startOf('month')) -
2695
- (that - moment(that).startOf('month'))) / diff;
2696
- // same as above but with zones, to negate all dst
2697
- output -= ((this.zone() - moment(this).startOf('month').zone()) -
2698
- (that.zone() - moment(that).startOf('month').zone())) * 6e4 / diff;
2699
- if (units === 'year') {
2700
- output = output / 12;
2701
- }
2702
- } else {
2703
- diff = (this - that);
2704
- output = units === 'second' ? diff / 1e3 : // 1000
2705
- units === 'minute' ? diff / 6e4 : // 1000 * 60
2706
- units === 'hour' ? diff / 36e5 : // 1000 * 60 * 60
2707
- units === 'day' ? (diff - zoneDiff) / 864e5 : // 1000 * 60 * 60 * 24, negate dst
2708
- units === 'week' ? (diff - zoneDiff) / 6048e5 : // 1000 * 60 * 60 * 24 * 7, negate dst
2709
- diff;
2710
- }
2711
- return asFloat ? output : absRound(output);
2712
- },
2713
-
2714
- from : function (time, withoutSuffix) {
2715
- return moment.duration({to: this, from: time}).locale(this.locale()).humanize(!withoutSuffix);
2716
- },
2717
-
2718
- fromNow : function (withoutSuffix) {
2719
- return this.from(moment(), withoutSuffix);
2720
- },
2721
-
2722
- calendar : function (time) {
2723
- // We want to compare the start of today, vs this.
2724
- // Getting start-of-today depends on whether we're zone'd or not.
2725
- var now = time || moment(),
2726
- sod = makeAs(now, this).startOf('day'),
2727
- diff = this.diff(sod, 'days', true),
2728
- format = diff < -6 ? 'sameElse' :
2729
- diff < -1 ? 'lastWeek' :
2730
- diff < 0 ? 'lastDay' :
2731
- diff < 1 ? 'sameDay' :
2732
- diff < 2 ? 'nextDay' :
2733
- diff < 7 ? 'nextWeek' : 'sameElse';
2734
- return this.format(this.localeData().calendar(format, this));
2735
- },
2736
-
2737
- isLeapYear : function () {
2738
- return isLeapYear(this.year());
2739
- },
2740
-
2741
- isDST : function () {
2742
- return (this.zone() < this.clone().month(0).zone() ||
2743
- this.zone() < this.clone().month(5).zone());
2744
- },
2745
-
2746
- day : function (input) {
2747
- var day = this._isUTC ? this._d.getUTCDay() : this._d.getDay();
2748
- if (input != null) {
2749
- input = parseWeekday(input, this.localeData());
2750
- return this.add(input - day, 'd');
2751
- } else {
2752
- return day;
2753
- }
2754
- },
2755
-
2756
- month : makeAccessor('Month', true),
2757
-
2758
- startOf : function (units) {
2759
- units = normalizeUnits(units);
2760
- // the following switch intentionally omits break keywords
2761
- // to utilize falling through the cases.
2762
- switch (units) {
2763
- case 'year':
2764
- this.month(0);
2765
- /* falls through */
2766
- case 'quarter':
2767
- case 'month':
2768
- this.date(1);
2769
- /* falls through */
2770
- case 'week':
2771
- case 'isoWeek':
2772
- case 'day':
2773
- this.hours(0);
2774
- /* falls through */
2775
- case 'hour':
2776
- this.minutes(0);
2777
- /* falls through */
2778
- case 'minute':
2779
- this.seconds(0);
2780
- /* falls through */
2781
- case 'second':
2782
- this.milliseconds(0);
2783
- /* falls through */
2784
- }
2785
-
2786
- // weeks are a special case
2787
- if (units === 'week') {
2788
- this.weekday(0);
2789
- } else if (units === 'isoWeek') {
2790
- this.isoWeekday(1);
2791
- }
2792
-
2793
- // quarters are also special
2794
- if (units === 'quarter') {
2795
- this.month(Math.floor(this.month() / 3) * 3);
2796
- }
2797
-
2798
- return this;
2799
- },
2800
-
2801
- endOf: function (units) {
2802
- units = normalizeUnits(units);
2803
- return this.startOf(units).add(1, (units === 'isoWeek' ? 'week' : units)).subtract(1, 'ms');
2804
- },
2805
-
2806
- isAfter: function (input, units) {
2807
- units = typeof units !== 'undefined' ? units : 'millisecond';
2808
- return +this.clone().startOf(units) > +moment(input).startOf(units);
2809
- },
2810
-
2811
- isBefore: function (input, units) {
2812
- units = typeof units !== 'undefined' ? units : 'millisecond';
2813
- return +this.clone().startOf(units) < +moment(input).startOf(units);
2814
- },
2815
-
2816
- isSame: function (input, units) {
2817
- units = units || 'ms';
2818
- return +this.clone().startOf(units) === +makeAs(input, this).startOf(units);
2819
- },
2820
-
2821
- min: deprecate(
2822
- 'moment().min is deprecated, use moment.min instead. https://github.com/moment/moment/issues/1548',
2823
- function (other) {
2824
- other = moment.apply(null, arguments);
2825
- return other < this ? this : other;
2826
- }
2827
- ),
2828
-
2829
- max: deprecate(
2830
- 'moment().max is deprecated, use moment.max instead. https://github.com/moment/moment/issues/1548',
2831
- function (other) {
2832
- other = moment.apply(null, arguments);
2833
- return other > this ? this : other;
2834
- }
2835
- ),
2836
-
2837
- // keepLocalTime = true means only change the timezone, without
2838
- // affecting the local hour. So 5:31:26 +0300 --[zone(2, true)]-->
2839
- // 5:31:26 +0200 It is possible that 5:31:26 doesn't exist int zone
2840
- // +0200, so we adjust the time as needed, to be valid.
2841
- //
2842
- // Keeping the time actually adds/subtracts (one hour)
2843
- // from the actual represented time. That is why we call updateOffset
2844
- // a second time. In case it wants us to change the offset again
2845
- // _changeInProgress == true case, then we have to adjust, because
2846
- // there is no such time in the given timezone.
2847
- zone : function (input, keepLocalTime) {
2848
- var offset = this._offset || 0,
2849
- localAdjust;
2850
- if (input != null) {
2851
- if (typeof input === 'string') {
2852
- input = timezoneMinutesFromString(input);
2853
- }
2854
- if (Math.abs(input) < 16) {
2855
- input = input * 60;
2856
- }
2857
- if (!this._isUTC && keepLocalTime) {
2858
- localAdjust = this._d.getTimezoneOffset();
2859
- }
2860
- this._offset = input;
2861
- this._isUTC = true;
2862
- if (localAdjust != null) {
2863
- this.subtract(localAdjust, 'm');
2864
- }
2865
- if (offset !== input) {
2866
- if (!keepLocalTime || this._changeInProgress) {
2867
- addOrSubtractDurationFromMoment(this,
2868
- moment.duration(offset - input, 'm'), 1, false);
2869
- } else if (!this._changeInProgress) {
2870
- this._changeInProgress = true;
2871
- moment.updateOffset(this, true);
2872
- this._changeInProgress = null;
2873
- }
2874
- }
2875
- } else {
2876
- return this._isUTC ? offset : this._d.getTimezoneOffset();
2877
- }
2878
- return this;
2879
- },
2880
-
2881
- zoneAbbr : function () {
2882
- return this._isUTC ? 'UTC' : '';
2883
- },
2884
-
2885
- zoneName : function () {
2886
- return this._isUTC ? 'Coordinated Universal Time' : '';
2887
- },
2888
-
2889
- parseZone : function () {
2890
- if (this._tzm) {
2891
- this.zone(this._tzm);
2892
- } else if (typeof this._i === 'string') {
2893
- this.zone(this._i);
2894
- }
2895
- return this;
2896
- },
2897
-
2898
- hasAlignedHourOffset : function (input) {
2899
- if (!input) {
2900
- input = 0;
2901
- }
2902
- else {
2903
- input = moment(input).zone();
2904
- }
2905
-
2906
- return (this.zone() - input) % 60 === 0;
2907
- },
2908
-
2909
- daysInMonth : function () {
2910
- return daysInMonth(this.year(), this.month());
2911
- },
2912
-
2913
- dayOfYear : function (input) {
2914
- var dayOfYear = round((moment(this).startOf('day') - moment(this).startOf('year')) / 864e5) + 1;
2915
- return input == null ? dayOfYear : this.add((input - dayOfYear), 'd');
2916
- },
2917
-
2918
- quarter : function (input) {
2919
- return input == null ? Math.ceil((this.month() + 1) / 3) : this.month((input - 1) * 3 + this.month() % 3);
2920
- },
2921
-
2922
- weekYear : function (input) {
2923
- var year = weekOfYear(this, this.localeData()._week.dow, this.localeData()._week.doy).year;
2924
- return input == null ? year : this.add((input - year), 'y');
2925
- },
2926
-
2927
- isoWeekYear : function (input) {
2928
- var year = weekOfYear(this, 1, 4).year;
2929
- return input == null ? year : this.add((input - year), 'y');
2930
- },
2931
-
2932
- week : function (input) {
2933
- var week = this.localeData().week(this);
2934
- return input == null ? week : this.add((input - week) * 7, 'd');
2935
- },
2936
-
2937
- isoWeek : function (input) {
2938
- var week = weekOfYear(this, 1, 4).week;
2939
- return input == null ? week : this.add((input - week) * 7, 'd');
2940
- },
2941
-
2942
- weekday : function (input) {
2943
- var weekday = (this.day() + 7 - this.localeData()._week.dow) % 7;
2944
- return input == null ? weekday : this.add(input - weekday, 'd');
2945
- },
2946
-
2947
- isoWeekday : function (input) {
2948
- // behaves the same as moment#day except
2949
- // as a getter, returns 7 instead of 0 (1-7 range instead of 0-6)
2950
- // as a setter, sunday should belong to the previous week.
2951
- return input == null ? this.day() || 7 : this.day(this.day() % 7 ? input : input - 7);
2952
- },
2953
-
2954
- isoWeeksInYear : function () {
2955
- return weeksInYear(this.year(), 1, 4);
2956
- },
2957
-
2958
- weeksInYear : function () {
2959
- var weekInfo = this.localeData()._week;
2960
- return weeksInYear(this.year(), weekInfo.dow, weekInfo.doy);
2961
- },
2962
-
2963
- get : function (units) {
2964
- units = normalizeUnits(units);
2965
- return this[units]();
2966
- },
2967
-
2968
- set : function (units, value) {
2969
- units = normalizeUnits(units);
2970
- if (typeof this[units] === 'function') {
2971
- this[units](value);
2972
- }
2973
- return this;
2974
- },
2975
-
2976
- // If passed a locale key, it will set the locale for this
2977
- // instance. Otherwise, it will return the locale configuration
2978
- // variables for this instance.
2979
- locale : function (key) {
2980
- if (key === undefined) {
2981
- return this._locale._abbr;
2982
- } else {
2983
- this._locale = moment.localeData(key);
2984
- return this;
2985
- }
2986
- },
2987
-
2988
- lang : deprecate(
2989
- 'moment().lang() is deprecated. Use moment().localeData() instead.',
2990
- function (key) {
2991
- if (key === undefined) {
2992
- return this.localeData();
2993
- } else {
2994
- this._locale = moment.localeData(key);
2995
- return this;
2996
- }
2997
- }
2998
- ),
2999
-
3000
- localeData : function () {
3001
- return this._locale;
3002
- }
3003
- });
3004
-
3005
- function rawMonthSetter(mom, value) {
3006
- var dayOfMonth;
3007
-
3008
- // TODO: Move this out of here!
3009
- if (typeof value === 'string') {
3010
- value = mom.localeData().monthsParse(value);
3011
- // TODO: Another silent failure?
3012
- if (typeof value !== 'number') {
3013
- return mom;
3014
- }
3015
- }
3016
-
3017
- dayOfMonth = Math.min(mom.date(),
3018
- daysInMonth(mom.year(), value));
3019
- mom._d['set' + (mom._isUTC ? 'UTC' : '') + 'Month'](value, dayOfMonth);
3020
- return mom;
3021
- }
3022
-
3023
- function rawGetter(mom, unit) {
3024
- return mom._d['get' + (mom._isUTC ? 'UTC' : '') + unit]();
3025
- }
3026
-
3027
- function rawSetter(mom, unit, value) {
3028
- if (unit === 'Month') {
3029
- return rawMonthSetter(mom, value);
3030
- } else {
3031
- return mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value);
3032
- }
3033
- }
3034
-
3035
- function makeAccessor(unit, keepTime) {
3036
- return function (value) {
3037
- if (value != null) {
3038
- rawSetter(this, unit, value);
3039
- moment.updateOffset(this, keepTime);
3040
- return this;
3041
- } else {
3042
- return rawGetter(this, unit);
3043
- }
3044
- };
3045
- }
3046
-
3047
- moment.fn.millisecond = moment.fn.milliseconds = makeAccessor('Milliseconds', false);
3048
- moment.fn.second = moment.fn.seconds = makeAccessor('Seconds', false);
3049
- moment.fn.minute = moment.fn.minutes = makeAccessor('Minutes', false);
3050
- // Setting the hour should keep the time, because the user explicitly
3051
- // specified which hour he wants. So trying to maintain the same hour (in
3052
- // a new timezone) makes sense. Adding/subtracting hours does not follow
3053
- // this rule.
3054
- moment.fn.hour = moment.fn.hours = makeAccessor('Hours', true);
3055
- // moment.fn.month is defined separately
3056
- moment.fn.date = makeAccessor('Date', true);
3057
- moment.fn.dates = deprecate('dates accessor is deprecated. Use date instead.', makeAccessor('Date', true));
3058
- moment.fn.year = makeAccessor('FullYear', true);
3059
- moment.fn.years = deprecate('years accessor is deprecated. Use year instead.', makeAccessor('FullYear', true));
3060
-
3061
- // add plural methods
3062
- moment.fn.days = moment.fn.day;
3063
- moment.fn.months = moment.fn.month;
3064
- moment.fn.weeks = moment.fn.week;
3065
- moment.fn.isoWeeks = moment.fn.isoWeek;
3066
- moment.fn.quarters = moment.fn.quarter;
3067
-
3068
- // add aliased format methods
3069
- moment.fn.toJSON = moment.fn.toISOString;
3070
-
3071
- /************************************
3072
- Duration Prototype
3073
- ************************************/
3074
-
3075
-
3076
- function daysToYears (days) {
3077
- // 400 years have 146097 days (taking into account leap year rules)
3078
- return days * 400 / 146097;
3079
- }
3080
-
3081
- function yearsToDays (years) {
3082
- // years * 365 + absRound(years / 4) -
3083
- // absRound(years / 100) + absRound(years / 400);
3084
- return years * 146097 / 400;
3085
- }
3086
-
3087
- extend(moment.duration.fn = Duration.prototype, {
3088
-
3089
- _bubble : function () {
3090
- var milliseconds = this._milliseconds,
3091
- days = this._days,
3092
- months = this._months,
3093
- data = this._data,
3094
- seconds, minutes, hours, years = 0;
3095
-
3096
- // The following code bubbles up values, see the tests for
3097
- // examples of what that means.
3098
- data.milliseconds = milliseconds % 1000;
3099
-
3100
- seconds = absRound(milliseconds / 1000);
3101
- data.seconds = seconds % 60;
3102
-
3103
- minutes = absRound(seconds / 60);
3104
- data.minutes = minutes % 60;
3105
-
3106
- hours = absRound(minutes / 60);
3107
- data.hours = hours % 24;
3108
-
3109
- days += absRound(hours / 24);
3110
-
3111
- // Accurately convert days to years, assume start from year 0.
3112
- years = absRound(daysToYears(days));
3113
- days -= absRound(yearsToDays(years));
3114
-
3115
- // 30 days to a month
3116
- // TODO (iskren): Use anchor date (like 1st Jan) to compute this.
3117
- months += absRound(days / 30);
3118
- days %= 30;
3119
-
3120
- // 12 months -> 1 year
3121
- years += absRound(months / 12);
3122
- months %= 12;
3123
-
3124
- data.days = days;
3125
- data.months = months;
3126
- data.years = years;
3127
- },
3128
-
3129
- abs : function () {
3130
- this._milliseconds = Math.abs(this._milliseconds);
3131
- this._days = Math.abs(this._days);
3132
- this._months = Math.abs(this._months);
3133
-
3134
- this._data.milliseconds = Math.abs(this._data.milliseconds);
3135
- this._data.seconds = Math.abs(this._data.seconds);
3136
- this._data.minutes = Math.abs(this._data.minutes);
3137
- this._data.hours = Math.abs(this._data.hours);
3138
- this._data.months = Math.abs(this._data.months);
3139
- this._data.years = Math.abs(this._data.years);
3140
-
3141
- return this;
3142
- },
3143
-
3144
- weeks : function () {
3145
- return absRound(this.days() / 7);
3146
- },
3147
-
3148
- valueOf : function () {
3149
- return this._milliseconds +
3150
- this._days * 864e5 +
3151
- (this._months % 12) * 2592e6 +
3152
- toInt(this._months / 12) * 31536e6;
3153
- },
3154
-
3155
- humanize : function (withSuffix) {
3156
- var output = relativeTime(this, !withSuffix, this.localeData());
3157
-
3158
- if (withSuffix) {
3159
- output = this.localeData().pastFuture(+this, output);
3160
- }
3161
-
3162
- return this.localeData().postformat(output);
3163
- },
3164
-
3165
- add : function (input, val) {
3166
- // supports only 2.0-style add(1, 's') or add(moment)
3167
- var dur = moment.duration(input, val);
3168
-
3169
- this._milliseconds += dur._milliseconds;
3170
- this._days += dur._days;
3171
- this._months += dur._months;
3172
-
3173
- this._bubble();
3174
-
3175
- return this;
3176
- },
3177
-
3178
- subtract : function (input, val) {
3179
- var dur = moment.duration(input, val);
3180
-
3181
- this._milliseconds -= dur._milliseconds;
3182
- this._days -= dur._days;
3183
- this._months -= dur._months;
3184
-
3185
- this._bubble();
3186
-
3187
- return this;
3188
- },
3189
-
3190
- get : function (units) {
3191
- units = normalizeUnits(units);
3192
- return this[units.toLowerCase() + 's']();
3193
- },
3194
-
3195
- as : function (units) {
3196
- var days, months;
3197
- units = normalizeUnits(units);
3198
-
3199
- days = this._days + this._milliseconds / 864e5;
3200
- if (units === 'month' || units === 'year') {
3201
- months = this._months + daysToYears(days) * 12;
3202
- return units === 'month' ? months : months / 12;
3203
- } else {
3204
- days += yearsToDays(this._months / 12);
3205
- switch (units) {
3206
- case 'week': return days / 7;
3207
- case 'day': return days;
3208
- case 'hour': return days * 24;
3209
- case 'minute': return days * 24 * 60;
3210
- case 'second': return days * 24 * 60 * 60;
3211
- case 'millisecond': return days * 24 * 60 * 60 * 1000;
3212
- default: throw new Error('Unknown unit ' + units);
3213
- }
3214
- }
3215
- },
3216
-
3217
- lang : moment.fn.lang,
3218
- locale : moment.fn.locale,
3219
-
3220
- toIsoString : deprecate(
3221
- 'toIsoString() is deprecated. Please use toISOString() instead ' +
3222
- '(notice the capitals)',
3223
- function () {
3224
- return this.toISOString();
3225
- }
3226
- ),
3227
-
3228
- toISOString : function () {
3229
- // inspired by https://github.com/dordille/moment-isoduration/blob/master/moment.isoduration.js
3230
- var years = Math.abs(this.years()),
3231
- months = Math.abs(this.months()),
3232
- days = Math.abs(this.days()),
3233
- hours = Math.abs(this.hours()),
3234
- minutes = Math.abs(this.minutes()),
3235
- seconds = Math.abs(this.seconds() + this.milliseconds() / 1000);
3236
-
3237
- if (!this.asSeconds()) {
3238
- // this is the same as C#'s (Noda) and python (isodate)...
3239
- // but not other JS (goog.date)
3240
- return 'P0D';
3241
- }
3242
-
3243
- return (this.asSeconds() < 0 ? '-' : '') +
3244
- 'P' +
3245
- (years ? years + 'Y' : '') +
3246
- (months ? months + 'M' : '') +
3247
- (days ? days + 'D' : '') +
3248
- ((hours || minutes || seconds) ? 'T' : '') +
3249
- (hours ? hours + 'H' : '') +
3250
- (minutes ? minutes + 'M' : '') +
3251
- (seconds ? seconds + 'S' : '');
3252
- },
3253
-
3254
- localeData : function () {
3255
- return this._locale;
3256
- }
3257
- });
3258
-
3259
- moment.duration.fn.toString = moment.duration.fn.toISOString;
3260
-
3261
- function makeDurationGetter(name) {
3262
- moment.duration.fn[name] = function () {
3263
- return this._data[name];
3264
- };
3265
- }
3266
-
3267
- for (i in unitMillisecondFactors) {
3268
- if (hasOwnProp(unitMillisecondFactors, i)) {
3269
- makeDurationGetter(i.toLowerCase());
3270
- }
3271
- }
3272
-
3273
- moment.duration.fn.asMilliseconds = function () {
3274
- return this.as('ms');
3275
- };
3276
- moment.duration.fn.asSeconds = function () {
3277
- return this.as('s');
3278
- };
3279
- moment.duration.fn.asMinutes = function () {
3280
- return this.as('m');
3281
- };
3282
- moment.duration.fn.asHours = function () {
3283
- return this.as('h');
3284
- };
3285
- moment.duration.fn.asDays = function () {
3286
- return this.as('d');
3287
- };
3288
- moment.duration.fn.asWeeks = function () {
3289
- return this.as('weeks');
3290
- };
3291
- moment.duration.fn.asMonths = function () {
3292
- return this.as('M');
3293
- };
3294
- moment.duration.fn.asYears = function () {
3295
- return this.as('y');
3296
- };
3297
-
3298
- /************************************
3299
- Default Locale
3300
- ************************************/
3301
-
3302
-
3303
- // Set default locale, other locale will inherit from English.
3304
- moment.locale('en', {
3305
- ordinal : function (number) {
3306
- var b = number % 10,
3307
- output = (toInt(number % 100 / 10) === 1) ? 'th' :
3308
- (b === 1) ? 'st' :
3309
- (b === 2) ? 'nd' :
3310
- (b === 3) ? 'rd' : 'th';
3311
- return number + output;
3312
- }
3313
- });
3314
-
3315
- /* EMBED_LOCALES */
3316
-
3317
- /************************************
3318
- Exposing Moment
3319
- ************************************/
3320
-
3321
- function makeGlobal(shouldDeprecate) {
3322
- /*global ender:false */
3323
- if (typeof ender !== 'undefined') {
3324
- return;
3325
- }
3326
- oldGlobalMoment = globalScope.moment;
3327
- if (shouldDeprecate) {
3328
- globalScope.moment = deprecate(
3329
- 'Accessing Moment through the global scope is ' +
3330
- 'deprecated, and will be removed in an upcoming ' +
3331
- 'release.',
3332
- moment);
3333
- } else {
3334
- globalScope.moment = moment;
3335
- }
3336
- }
3337
-
3338
- // CommonJS module is defined
3339
- if (hasModule) {
3340
- module.exports = moment;
3341
- } else if (typeof define === 'function' && define.amd) {
3342
- define('moment', function (_dereq_, exports, module) {
3343
- if (module.config && module.config() && module.config().noGlobal === true) {
3344
- // release the global variable
3345
- globalScope.moment = oldGlobalMoment;
3346
- }
3347
-
3348
- return moment;
3349
- });
3350
- makeGlobal(true);
3351
- } else {
3352
- makeGlobal();
3353
- }
3354
- }).call(this);
3355
-
3356
- }).call(this,typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
3357
- },{}],12:[function(_dereq_,module,exports){
3358
- var now = _dereq_('performance-now')
3359
- , global = typeof window === 'undefined' ? {} : window
3360
- , vendors = ['moz', 'webkit']
3361
- , suffix = 'AnimationFrame'
3362
- , raf = global['request' + suffix]
3363
- , caf = global['cancel' + suffix] || global['cancelRequest' + suffix]
3364
-
3365
- for(var i = 0; i < vendors.length && !raf; i++) {
3366
- raf = global[vendors[i] + 'Request' + suffix]
3367
- caf = global[vendors[i] + 'Cancel' + suffix]
3368
- || global[vendors[i] + 'CancelRequest' + suffix]
3369
- }
3370
-
3371
- // Some versions of FF have rAF but not cAF
3372
- if(!raf || !caf) {
3373
- var last = 0
3374
- , id = 0
3375
- , queue = []
3376
- , frameDuration = 1000 / 60
3377
-
3378
- raf = function(callback) {
3379
- if(queue.length === 0) {
3380
- var _now = now()
3381
- , next = Math.max(0, frameDuration - (_now - last))
3382
- last = next + _now
3383
- setTimeout(function() {
3384
- var cp = queue.slice(0)
3385
- // Clear queue here to prevent
3386
- // callbacks from appending listeners
3387
- // to the current frame's queue
3388
- queue.length = 0
3389
- for (var i = 0; i < cp.length; i++) {
3390
- if (!cp[i].cancelled) {
3391
- cp[i].callback(last)
3392
- }
3393
- }
3394
- }, next)
3395
- }
3396
- queue.push({
3397
- handle: ++id,
3398
- callback: callback,
3399
- cancelled: false
3400
- })
3401
- return id
3402
- }
3403
-
3404
- caf = function(handle) {
3405
- for(var i = 0; i < queue.length; i++) {
3406
- if(queue[i].handle === handle) {
3407
- queue[i].cancelled = true
3408
- }
3409
- }
3410
- }
3411
- }
3412
-
3413
- module.exports = function() {
3414
- // Wrap in a new function to prevent
3415
- // `cancel` potentially being assigned
3416
- // to the native rAF function
3417
- return raf.apply(global, arguments)
3418
- }
3419
- module.exports.cancel = function() {
3420
- caf.apply(global, arguments)
3421
- }
3422
-
3423
- },{"performance-now":13}],13:[function(_dereq_,module,exports){
3424
- (function (process){
3425
- // Generated by CoffeeScript 1.6.3
3426
- (function() {
3427
- var getNanoSeconds, hrtime, loadTime;
3428
-
3429
- if ((typeof performance !== "undefined" && performance !== null) && performance.now) {
3430
- module.exports = function() {
3431
- return performance.now();
3432
- };
3433
- } else if ((typeof process !== "undefined" && process !== null) && process.hrtime) {
3434
- module.exports = function() {
3435
- return (getNanoSeconds() - loadTime) / 1e6;
3436
- };
3437
- hrtime = process.hrtime;
3438
- getNanoSeconds = function() {
3439
- var hr;
3440
- hr = hrtime();
3441
- return hr[0] * 1e9 + hr[1];
3442
- };
3443
- loadTime = getNanoSeconds();
3444
- } else if (Date.now) {
3445
- module.exports = function() {
3446
- return Date.now() - loadTime;
3447
- };
3448
- loadTime = Date.now();
3449
- } else {
3450
- module.exports = function() {
3451
- return new Date().getTime() - loadTime;
3452
- };
3453
- loadTime = new Date().getTime();
3454
- }
3455
-
3456
- }).call(this);
3457
-
3458
- /*
3459
- //@ sourceMappingURL=performance-now.map
3460
- */
3461
-
3462
- }).call(this,_dereq_("FWaASH"))
3463
- },{"FWaASH":1}],14:[function(_dereq_,module,exports){
3464
- 'use strict';
3465
-
3466
- var isInput = _dereq_('./isInput');
3467
- var bindings = {};
3468
-
3469
- function has (source, target) {
3470
- var binding = bindings[source.id];
3471
- return binding && binding[target.id];
3472
- }
3473
-
3474
- function insert (source, target) {
3475
- var binding = bindings[source.id];
3476
- if (!binding) {
3477
- binding = bindings[source.id] = {};
3478
- }
3479
- var invalidate = invalidator(target);
3480
- binding[target.id] = invalidate;
3481
- source.on('data', invalidate);
3482
- source.on('destroyed', remove.bind(null, source, target));
3483
- }
3484
-
3485
- function remove (source, target) {
3486
- var binding = bindings[source.id];
3487
- if (!binding) {
3488
- return;
3489
- }
3490
- var invalidate = binding[target.id];
3491
- source.off('data', invalidate);
3492
- delete binding[target.id];
3493
- }
3494
-
3495
- function invalidator (target) {
3496
- return function invalidate () {
3497
- target.refresh();
3498
- };
3499
- }
3500
-
3501
- function add (source, target) {
3502
- if (isInput(target.associated) || has(source, target)) {
3503
- return;
3504
- }
3505
- insert(source, target);
3506
- }
3507
-
3508
- module.exports = {
3509
- add: add,
3510
- remove: remove
3511
- };
3512
-
3513
- },{"./isInput":25}],15:[function(_dereq_,module,exports){
3514
- 'use strict';
3515
-
3516
- var emitter = _dereq_('contra.emitter');
3517
- var raf = _dereq_('raf');
3518
- var dom = _dereq_('./dom');
3519
- var text = _dereq_('./text');
3520
- var parse = _dereq_('./parse');
3521
- var clone = _dereq_('./clone');
3522
- var defaults = _dereq_('./defaults');
3523
- var momentum = _dereq_('./momentum');
3524
- var classes = _dereq_('./classes');
3525
- var events = _dereq_('./events');
3526
- var noop = _dereq_('./noop');
3527
- var no;
3528
-
3529
- function calendar (calendarOptions) {
3530
- var o;
3531
- var api = emitter({});
3532
- var ref;
3533
- var refCal;
3534
- var container;
3535
- var rendered = false;
3536
-
3537
- // date variables
3538
- var monthOffsetAttribute = 'data-rome-offset';
3539
- var weekdays = momentum.moment.weekdaysMin();
3540
- var weekdayCount = weekdays.length;
3541
- var calendarMonths = [];
3542
- var lastYear;
3543
- var lastMonth;
3544
- var lastDay;
3545
- var lastDayElement;
3546
- var datewrapper;
3547
- var back;
3548
- var next;
3549
-
3550
- // time variables
3551
- var secondsInDay = 60 * 60 * 24;
3552
- var time;
3553
- var timelist;
3554
-
3555
- destroy(true);
3556
-
3557
- raf(function () {
3558
- init();
3559
- });
3560
-
3561
- function napi () { return api; }
3562
-
3563
- function init (initOptions) {
3564
- o = defaults(initOptions || calendarOptions, api);
3565
- if (!container) { container = dom({ className: o.styles.container }); }
3566
- lastMonth = no;
3567
- lastYear = no;
3568
- lastDay = no;
3569
- lastDayElement = no;
3570
- o.appendTo.appendChild(container);
3571
-
3572
- removeChildren(container);
3573
- rendered = false;
3574
- ref = o.initialValue ? o.initialValue : momentum.moment();
3575
- refCal = ref.clone();
3576
-
3577
- api.container = container;
3578
- api.destroyed = false;
3579
- api.destroy = destroy.bind(api, false);
3580
- api.emitValues = emitValues;
3581
- api.getDate = getDate;
3582
- api.getDateString = getDateString;
3583
- api.getMoment = getMoment;
3584
- api.hide = hide;
3585
- api.options = changeOptions;
3586
- api.options.reset = resetOptions;
3587
- api.refresh = refresh;
3588
- api.restore = napi;
3589
- api.setValue = setValue;
3590
- api.show = show;
3591
-
3592
- hideCalendar();
3593
- eventListening();
3594
-
3595
- api.emit('ready', clone(o));
3596
-
3597
- return api;
3598
- }
3599
-
3600
- function destroy (silent) {
3601
- if (container) {
3602
- container.parentNode.removeChild(container);
3603
- }
3604
-
3605
- if (o) {
3606
- eventListening(true);
3607
- }
3608
-
3609
- api.destroyed = true;
3610
- api.destroy = napi;
3611
- api.emitValues = napi;
3612
- api.getDate = noop;
3613
- api.getDateString = noop;
3614
- api.getMoment = noop;
3615
- api.hide = napi;
3616
- api.options = napi;
3617
- api.options.reset = napi;
3618
- api.refresh = napi;
3619
- api.restore = init;
3620
- api.setValue = napi;
3621
- api.show = napi;
3622
-
3623
- if (silent !== true) {
3624
- api.emit('destroyed');
3625
- }
3626
- api.off();
3627
-
3628
- return api;
3629
- }
3630
-
3631
- function eventListening (remove) {
3632
- var op = remove ? 'remove' : 'add';
3633
- if (o.autoHideOnBlur) { events[op](document, 'focusin', hideOnBlur); }
3634
- if (o.autoHideOnClick) { events[op](document, 'click', hideOnClick); }
3635
- }
3636
-
3637
- function changeOptions (options) {
3638
- if (arguments.length === 0) {
3639
- return clone(o);
3640
- }
3641
- destroy();
3642
- init(options);
3643
- return api;
3644
- }
3645
-
3646
- function resetOptions () {
3647
- return changeOptions({});
3648
- }
3649
-
3650
- function render () {
3651
- if (rendered) {
3652
- return;
3653
- }
3654
- rendered = true;
3655
- renderDates();
3656
- renderTime();
3657
- api.emit('render');
3658
- }
3659
-
3660
- function renderDates () {
3661
- if (!o.date) {
3662
- return;
3663
- }
3664
- var i;
3665
- calendarMonths = [];
3666
-
3667
- datewrapper = dom({ className: o.styles.date, parent: container });
3668
-
3669
- for (i = 0; i < o.monthsInCalendar; i++) {
3670
- renderMonth(i);
3671
- }
3672
-
3673
- events.add(back, 'click', subtractMonth);
3674
- events.add(next, 'click', addMonth);
3675
- events.add(datewrapper, 'click', pickDay);
3676
-
3677
- function renderMonth (i) {
3678
- var month = dom({ className: o.styles.month, parent: datewrapper });
3679
- if (i === 0) {
3680
- back = dom({ type: 'button', className: o.styles.back, parent: month });
3681
- }
3682
- if (i === o.monthsInCalendar -1) {
3683
- next = dom({ type: 'button', className: o.styles.next, parent: month });
3684
- }
3685
- var label = dom({ className: o.styles.monthLabel, parent: month });
3686
- var date = dom({ type: 'table', className: o.styles.dayTable, parent: month });
3687
- var datehead = dom({ type: 'thead', className: o.styles.dayHead, parent: date });
3688
- var dateheadrow = dom({ type: 'tr', className: o.styles.dayRow, parent: datehead });
3689
- var datebody = dom({ type: 'tbody', className: o.styles.dayBody, parent: date });
3690
- var j;
3691
-
3692
- for (j = 0; j < weekdayCount; j++) {
3693
- dom({ type: 'th', className: o.styles.dayHeadElem, parent: dateheadrow, text: weekdays[weekday(j)] });
3694
- }
3695
-
3696
- datebody.setAttribute(monthOffsetAttribute, i);
3697
- calendarMonths.push({
3698
- label: label,
3699
- body: datebody
3700
- });
3701
- }
3702
- }
3703
-
3704
- function renderTime () {
3705
- if (!o.time || !o.timeInterval) {
3706
- return;
3707
- }
3708
- var timewrapper = dom({ className: o.styles.time, parent: container });
3709
- time = dom({ className: o.styles.selectedTime, parent: timewrapper, text: ref.format(o.timeFormat) });
3710
- events.add(time, 'click', toggleTimeList);
3711
- timelist = dom({ className: o.styles.timeList, parent: timewrapper });
3712
- events.add(timelist, 'click', pickTime);
3713
- var next = momentum.moment('00:00:00', 'HH:mm:ss');
3714
- var latest = next.clone().add(1, 'days');
3715
- while (next.isBefore(latest)) {
3716
- dom({ className: o.styles.timeOption, parent: timelist, text: next.format(o.timeFormat) });
3717
- next.add(o.timeInterval, 'seconds');
3718
- }
3719
- }
3720
-
3721
- function weekday (index, backwards) {
3722
- var factor = backwards ? -1 : 1;
3723
- var offset = index + o.weekStart * factor;
3724
- if (offset >= weekdayCount || offset < 0) {
3725
- offset += weekdayCount * -factor;
3726
- }
3727
- return offset;
3728
- }
3729
-
3730
- function displayValidTimesOnly () {
3731
- if (!o.time || !rendered) {
3732
- return;
3733
- }
3734
- var times = timelist.children;
3735
- var length = times.length;
3736
- var date;
3737
- var time;
3738
- var item;
3739
- var i;
3740
- for (i = 0; i < length; i++) {
3741
- item = times[i];
3742
- time = momentum.moment(text(item), o.timeFormat);
3743
- date = setTime(ref.clone(), time);
3744
- item.style.display = isInRange(date, false, o.timeValidator) ? 'block' : 'none';
3745
- }
3746
- }
3747
-
3748
- function toggleTimeList (show) {
3749
- var display = typeof show === 'boolean' ? show : timelist.style.display === 'none';
3750
- if (display) {
3751
- showTimeList();
3752
- } else {
3753
- hideTimeList();
3754
- }
3755
- }
3756
-
3757
- function showTimeList () { if (timelist) { timelist.style.display = 'block'; } }
3758
- function hideTimeList () { if (timelist) { timelist.style.display = 'none'; } }
3759
- function showCalendar () { container.style.display = 'inline-block'; api.emit('show'); }
3760
- function hideCalendar () { container.style.display = 'none'; api.emit('hide'); }
3761
-
3762
- function show () {
3763
- render();
3764
- refresh();
3765
- toggleTimeList(!o.date);
3766
- showCalendar();
3767
- return api;
3768
- }
3769
-
3770
- function hide () {
3771
- hideTimeList();
3772
- raf(hideCalendar);
3773
- return api;
3774
- }
3775
-
3776
- function hideConditionally () {
3777
- hideTimeList();
3778
-
3779
- var pos = classes.contains(container, o.styles.positioned);
3780
- if (pos) {
3781
- raf(hideCalendar);
3782
- }
3783
- return api;
3784
- }
3785
-
3786
- function calendarEventTarget (e) {
3787
- var target = e.target;
3788
- if (target === api.associated) {
3789
- return true;
3790
- }
3791
- while (target) {
3792
- if (target === container) {
3793
- return true;
3794
- }
3795
- target = target.parentNode;
3796
- }
3797
- }
3798
-
3799
- function hideOnBlur (e) {
3800
- if (calendarEventTarget(e)) {
3801
- return;
3802
- }
3803
- hideConditionally();
3804
- }
3805
-
3806
- var last;
3807
-
3808
- function hideOnClick (e) {
3809
-
3810
- var check = e.x + '-' + e.y;
3811
-
3812
- if (last == check) {
3813
- return;
3814
- }
3815
-
3816
- if (calendarEventTarget(e)) {
3817
- last = check;
3818
- return;
3819
- }
3820
- hideConditionally();
3821
- }
3822
-
3823
- function subtractMonth () { changeMonth('subtract'); }
3824
- function addMonth () { changeMonth('add'); }
3825
- function changeMonth (op) {
3826
- var bound;
3827
- var direction = op === 'add' ? -1 : 1;
3828
- var offset = o.monthsInCalendar + direction * getMonthOffset(lastDayElement);
3829
- refCal[op]('months', offset);
3830
- bound = inRange(refCal.clone());
3831
- ref = bound || ref;
3832
- if (bound) { refCal = bound.clone(); }
3833
- update();
3834
- }
3835
-
3836
- function update (silent) {
3837
- updateCalendar();
3838
- updateTime();
3839
- if (silent !== true) { emitValues(); }
3840
- displayValidTimesOnly();
3841
- }
3842
-
3843
- function updateCalendar () {
3844
- if (!o.date || !rendered) {
3845
- return;
3846
- }
3847
- var y = refCal.year();
3848
- var m = refCal.month();
3849
- var d = refCal.date();
3850
- if (d === lastDay && m === lastMonth && y === lastYear) {
3851
- return;
3852
- }
3853
- var canStay = isDisplayed();
3854
- lastDay = refCal.date();
3855
- lastMonth = refCal.month();
3856
- lastYear = refCal.year();
3857
- if (canStay) { updateCalendarSelection(); return; }
3858
- calendarMonths.forEach(updateMonth);
3859
- renderAllDays();
3860
-
3861
- function updateMonth (month, i) {
3862
- var offsetCal = refCal.clone().add(i, 'months');
3863
- text(month.label, offsetCal.format(o.monthFormat));
3864
- removeChildren(month.body);
3865
- }
3866
- }
3867
-
3868
- function updateCalendarSelection () {
3869
- var day = refCal.date() - 1;
3870
- selectDayElement(false);
3871
- calendarMonths.forEach(function (cal) {
3872
- var days;
3873
- if (sameCalendarMonth(cal.date, refCal)) {
3874
- days = cast(cal.body.children).map(aggregate);
3875
- days = Array.prototype.concat.apply([], days).filter(inside);
3876
- selectDayElement(days[day]);
3877
- }
3878
- });
3879
-
3880
- function cast (like) {
3881
- var dest = [];
3882
- var i;
3883
- for (i = 0; i < like.length; i++) {
3884
- dest.push(like[i]);
3885
- }
3886
- return dest;
3887
- }
3888
-
3889
- function aggregate (child) {
3890
- return cast(child.children);
3891
- }
3892
-
3893
- function inside (child) {
3894
- return !classes.contains(child, o.styles.dayPrevMonth) &&
3895
- !classes.contains(child, o.styles.dayNextMonth);
3896
- }
3897
- }
3898
-
3899
- function isDisplayed () {
3900
- return calendarMonths.some(matches);
3901
-
3902
- function matches (cal) {
3903
- if (!lastYear) { return false; }
3904
- return sameCalendarMonth(cal.date, refCal);
3905
- }
3906
- }
3907
-
3908
- function sameCalendarMonth (left, right) {
3909
- return left && right && left.year() === right.year() && left.month() === right.month();
3910
- }
3911
-
3912
- function updateTime () {
3913
- if (!o.time || !rendered) {
3914
- return;
3915
- }
3916
- text(time, ref.format(o.timeFormat));
3917
- }
3918
-
3919
- function emitValues () {
3920
- api.emit('data', getDateString());
3921
- api.emit('year', ref.year());
3922
- api.emit('month', ref.month());
3923
- api.emit('day', ref.day());
3924
- api.emit('time', ref.format(o.timeFormat));
3925
- return api;
3926
- }
3927
-
3928
- function refresh () {
3929
- lastYear = false;
3930
- lastMonth = false;
3931
- lastDay = false;
3932
- update(true);
3933
- return api;
3934
- }
3935
-
3936
- function setValue (value) {
3937
- var date = parse(value, o.inputFormat);
3938
- if (date === null) {
3939
- return;
3940
- }
3941
- ref = inRange(date) || ref;
3942
- refCal = ref.clone();
3943
- update(true);
3944
-
3945
- return api;
3946
- }
3947
-
3948
- function removeChildren (elem, self) {
3949
- while (elem && elem.firstChild) {
3950
- elem.removeChild(elem.firstChild);
3951
- }
3952
- if (self === true) {
3953
- elem.parentNode.removeChild(elem);
3954
- }
3955
- }
3956
-
3957
- function renderAllDays () {
3958
- var i;
3959
- for (i = 0; i < o.monthsInCalendar; i++) {
3960
- renderDays(i);
3961
- }
3962
- }
3963
-
3964
- function renderDays (offset) {
3965
- var month = calendarMonths[offset];
3966
- var offsetCal = refCal.clone().add(offset, 'months');
3967
- var total = offsetCal.daysInMonth();
3968
- var current = offsetCal.month() !== ref.month() ? -1 : ref.date(); // -1 : 1..31
3969
- var first = offsetCal.clone().date(1);
3970
- var firstDay = weekday(first.day(), true); // 0..6
3971
- var tr = dom({ type: 'tr', className: o.styles.dayRow, parent: month.body });
3972
- var prevMonth = hiddenWhen(offset !== 0, [o.styles.dayBodyElem, o.styles.dayPrevMonth]);
3973
- var nextMonth = hiddenWhen(offset !== o.monthsInCalendar - 1, [o.styles.dayBodyElem, o.styles.dayNextMonth]);
3974
- var disabled = o.styles.dayDisabled;
3975
- var lastDay;
3976
-
3977
- part({
3978
- base: first.clone().subtract(firstDay, 'days'),
3979
- length: firstDay,
3980
- cell: prevMonth
3981
- });
3982
-
3983
- part({
3984
- base: first.clone(),
3985
- length: total,
3986
- cell: [o.styles.dayBodyElem],
3987
- selectable: true
3988
- });
3989
-
3990
- lastDay = first.clone().add(total, 'days');
3991
-
3992
- part({
3993
- base: lastDay,
3994
- length: weekdayCount - tr.children.length,
3995
- cell: nextMonth
3996
- });
3997
-
3998
- back.disabled = !isInRange(first, true);
3999
- next.disabled = !isInRange(lastDay, true);
4000
- month.date = offsetCal.clone();
4001
-
4002
- function part (data) {
4003
- var i, day, node;
4004
- for (i = 0; i < data.length; i++) {
4005
- if (tr.children.length === weekdayCount) {
4006
- tr = dom({ type: 'tr', className: o.styles.dayRow, parent: month.body });
4007
- }
4008
- day = data.base.clone().add(i, 'days');
4009
- node = dom({
4010
- type: 'td',
4011
- parent: tr,
4012
- text: day.format(o.dayFormat),
4013
- className: validationTest(day, data.cell.join(' ').split(' ')).join(' ')
4014
- });
4015
- if (data.selectable && day.date() === current) {
4016
- selectDayElement(node);
4017
- }
4018
- }
4019
- }
4020
-
4021
- function validationTest (day, cell) {
4022
- if (!isInRange(day, true, o.dateValidator)) { cell.push(disabled); }
4023
- return cell;
4024
- }
4025
-
4026
- function hiddenWhen (value, cell) {
4027
- if (value) { cell.push(o.styles.dayConcealed); }
4028
- return cell;
4029
- }
4030
- }
4031
-
4032
- function isInRange (date, allday, validator) {
4033
- var min = !o.min ? false : (allday ? o.min.clone().startOf('day') : o.min);
4034
- var max = !o.max ? false : (allday ? o.max.clone().endOf('day') : o.max);
4035
- if (min && date.isBefore(min)) {
4036
- return false;
4037
- }
4038
- if (max && date.isAfter(max)) {
4039
- return false;
4040
- }
4041
- var valid = (validator || Function.prototype).call(api, date.toDate());
4042
- return valid !== false;
4043
- }
4044
-
4045
- function inRange (date) {
4046
- if (o.min && date.isBefore(o.min)) {
4047
- return inRange(o.min.clone());
4048
- } else if (o.max && date.isAfter(o.max)) {
4049
- return inRange(o.max.clone());
4050
- }
4051
- var value = date.clone().subtract(1, 'days');
4052
- if (validateTowards(value, date, 'add')) {
4053
- return inTimeRange(value);
4054
- }
4055
- value = date.clone();
4056
- if (validateTowards(value, date, 'subtract')) {
4057
- return inTimeRange(value);
4058
- }
4059
- }
4060
-
4061
- function inTimeRange (value) {
4062
- var copy = value.clone().subtract(o.timeInterval, 'seconds');
4063
- var times = Math.ceil(secondsInDay / o.timeInterval);
4064
- var i;
4065
- for (i = 0; i < times; i++) {
4066
- copy.add(o.timeInterval, 'seconds');
4067
- if (copy.date() > value.date()) {
4068
- copy.subtract(1, 'days');
4069
- }
4070
- if (o.timeValidator.call(api, copy.toDate()) !== false) {
4071
- return copy;
4072
- }
4073
- }
4074
- }
4075
-
4076
- function validateTowards (value, date, op) {
4077
- var valid = false;
4078
- while (valid === false) {
4079
- value[op](1, 'days');
4080
- if (value.month() !== date.month()) {
4081
- break;
4082
- }
4083
- valid = o.dateValidator.call(api, value.toDate());
4084
- }
4085
- return valid !== false;
4086
- }
4087
-
4088
- function pickDay (e) {
4089
- var target = e.target;
4090
- if (classes.contains(target, o.styles.dayDisabled) || !classes.contains(target, o.styles.dayBodyElem)) {
4091
- return;
4092
- }
4093
- var day = parseInt(text(target), 10);
4094
- var prev = classes.contains(target, o.styles.dayPrevMonth);
4095
- var next = classes.contains(target, o.styles.dayNextMonth);
4096
- var offset = getMonthOffset(target) - getMonthOffset(lastDayElement);
4097
- ref.add(offset, 'months');
4098
- if (prev || next) {
4099
- ref.add(prev ? -1 : 1, 'months');
4100
- }
4101
- selectDayElement(target);
4102
- ref.date(day); // must run after setting the month
4103
- setTime(ref, inRange(ref) || ref);
4104
- refCal = ref.clone();
4105
- if (o.autoClose) { hideConditionally(); }
4106
- update();
4107
- }
4108
-
4109
- function selectDayElement (node) {
4110
- if (lastDayElement) {
4111
- classes.remove(lastDayElement, o.styles.selectedDay);
4112
- }
4113
- if (node) {
4114
- classes.add(node, o.styles.selectedDay);
4115
- }
4116
- lastDayElement = node;
4117
- }
4118
-
4119
- function getMonthOffset (elem) {
4120
- var offset;
4121
- while (elem && elem.getAttribute) {
4122
- offset = elem.getAttribute(monthOffsetAttribute);
4123
- if (typeof offset === 'string') {
4124
- return parseInt(offset, 10);
4125
- }
4126
- elem = elem.parentNode;
4127
- }
4128
- return 0;
4129
- }
4130
-
4131
- function setTime (to, from) {
4132
- to.hour(from.hour()).minute(from.minute()).second(from.second());
4133
- return to;
4134
- }
4135
-
4136
- function pickTime (e) {
4137
- var target = e.target;
4138
- if (!classes.contains(target, o.styles.timeOption)) {
4139
- return;
4140
- }
4141
- var value = momentum.moment(text(target), o.timeFormat);
4142
- setTime(ref, value);
4143
- refCal = ref.clone();
4144
- emitValues();
4145
- updateTime();
4146
- if (!o.date && o.autoClose) {
4147
- hideConditionally();
4148
- } else {
4149
- hideTimeList();
4150
- }
4151
- }
4152
-
4153
- function getDate () {
4154
- return ref.toDate();
4155
- }
4156
-
4157
- function getDateString (format) {
4158
- return ref.format(format || o.inputFormat);
4159
- }
4160
-
4161
- function getMoment () {
4162
- return ref.clone();
4163
- }
4164
-
4165
- return api;
4166
- }
4167
-
4168
- module.exports = calendar;
4169
-
4170
- },{"./classes":16,"./clone":17,"./defaults":19,"./dom":20,"./events":21,"./momentum":26,"./noop":27,"./parse":28,"./text":40,"contra.emitter":2,"raf":12}],16:[function(_dereq_,module,exports){
4171
- 'use strict';
4172
-
4173
- var trim = /^\s+|\s+$/g;
4174
- var whitespace = /\s+/;
4175
-
4176
- function classes (node) {
4177
- return node.className.replace(trim, '').split(whitespace);
4178
- }
4179
-
4180
- function set (node, value) {
4181
- node.className = value.join(' ');
4182
- }
4183
-
4184
- function add (node, value) {
4185
- var values = remove(node, value);
4186
- values.push(value);
4187
- set(node, values);
4188
- }
4189
-
4190
- function remove (node, value) {
4191
- var values = classes(node);
4192
- var i = values.indexOf(value);
4193
- if (i !== -1) {
4194
- values.splice(i, 1);
4195
- set(node, values);
4196
- }
4197
- return values;
4198
- }
4199
-
4200
- function contains (node, value) {
4201
- return classes(node).indexOf(value) !== -1;
4202
- }
4203
-
4204
- module.exports = {
4205
- add: add,
4206
- remove: remove,
4207
- contains: contains
4208
- };
4209
-
4210
- },{}],17:[function(_dereq_,module,exports){
4211
- 'use strict';
4212
-
4213
- var momentum = _dereq_('./momentum');
4214
-
4215
- // naïve implementation, specifically meant to clone `options` objects
4216
- function clone (thing) {
4217
- var copy = {};
4218
- var value;
4219
-
4220
- for (var key in thing) {
4221
- value = thing[key];
4222
-
4223
- if (!value) {
4224
- copy[key] = value;
4225
- } else if (momentum.isMoment(value)) {
4226
- copy[key] = value.clone();
4227
- } else if (value._isStylesConfiguration) {
4228
- copy[key] = clone(value);
4229
- } else {
4230
- copy[key] = value;
4231
- }
4232
- }
4233
-
4234
- return copy;
4235
- }
4236
-
4237
- module.exports = clone;
4238
-
4239
- },{"./momentum":26}],18:[function(_dereq_,module,exports){
4240
- 'use strict';
4241
-
4242
- var index = _dereq_('./index');
4243
- var input = _dereq_('./input');
4244
- var inline = _dereq_('./inline');
4245
- var isInput = _dereq_('./isInput');
4246
-
4247
- function core (elem, options) {
4248
- var cal;
4249
- var existing = index.find(elem);
4250
- if (existing) {
4251
- return existing;
4252
- }
4253
-
4254
- if (isInput(elem)) {
4255
- cal = input(elem, options);
4256
- } else {
4257
- cal = inline(elem, options);
4258
- }
4259
- cal.associated = elem;
4260
- index.assign(elem, cal);
4261
-
4262
- return cal;
4263
- }
4264
-
4265
- module.exports = core;
4266
-
4267
- },{"./index":22,"./inline":23,"./input":24,"./isInput":25}],19:[function(_dereq_,module,exports){
4268
- 'use strict';
4269
-
4270
- var parse = _dereq_('./parse');
4271
- var isInput = _dereq_('./isInput');
4272
-
4273
- function defaults (options, cal) {
4274
- var temp;
4275
- var no;
4276
- var o = options || {};
4277
- if (o.autoHideOnClick === no) { o.autoHideOnClick = true; }
4278
- if (o.autoHideOnBlur === no) { o.autoHideOnBlur = true; }
4279
- if (o.autoClose === no) { o.autoClose = true; }
4280
- if (o.appendTo === no) { o.appendTo = document.body; }
4281
- if (o.appendTo === 'parent') {
4282
- if (isInput(cal.associated)) {
4283
- o.appendTo = cal.associated.parentNode;
4284
- } else {
4285
- throw new Error('Inline calendars must be appended to a parent node explicitly.');
4286
- }
4287
- }
4288
- if (o.invalidate === no) { o.invalidate = true; }
4289
- if (o.required === no) { o.required = false; }
4290
- if (o.date === no) { o.date = true; }
4291
- if (o.time === no) { o.time = true; }
4292
- if (o.date === false && o.time === false) { throw new Error('At least one of `date` or `time` must be `true`.'); }
4293
- if (o.inputFormat === no) {
4294
- if (o.date && o.time) {
4295
- o.inputFormat = 'YYYY-MM-DD HH:mm';
4296
- } else if (o.date) {
4297
- o.inputFormat = 'YYYY-MM-DD';
4298
- } else {
4299
- o.inputFormat = 'HH:mm';
4300
- }
4301
- }
4302
- if (o.initialValue === no) {
4303
- o.initialValue = null;
4304
- } else {
4305
- o.initialValue = parse(o.initialValue, o.inputFormat);
4306
- }
4307
- if (o.min === no) { o.min = null; } else { o.min = parse(o.min, o.inputFormat); }
4308
- if (o.max === no) { o.max = null; } else { o.max = parse(o.max, o.inputFormat); }
4309
- if (o.timeInterval === no) { o.timeInterval = 60 * 30; } // 30 minutes by default
4310
- if (o.min && o.max) {
4311
- if (o.max.isBefore(o.min)) {
4312
- temp = o.max;
4313
- o.max = o.min;
4314
- o.min = temp;
4315
- }
4316
- if (o.date === true) {
4317
- if (o.max.clone().subtract(1, 'days').isBefore(o.min)) {
4318
- throw new Error('`max` must be at least one day after `min`');
4319
- }
4320
- } else if (o.timeInterval * 1000 - o.min % (o.timeInterval * 1000) > o.max - o.min) {
4321
- throw new Error('`min` to `max` range must allow for at least one time option that matches `timeInterval`');
4322
- }
4323
- }
4324
- if (o.dateValidator === no) { o.dateValidator = Function.prototype; }
4325
- if (o.timeValidator === no) { o.timeValidator = Function.prototype; }
4326
- if (o.timeFormat === no) { o.timeFormat = 'HH:mm'; }
4327
- if (o.weekStart === no) { o.weekStart = 0; }
4328
- if (o.monthsInCalendar === no) { o.monthsInCalendar = 1; }
4329
- if (o.monthFormat === no) { o.monthFormat = 'MMMM YYYY'; }
4330
- if (o.dayFormat === no) { o.dayFormat = 'DD'; }
4331
- if (o.styles === no) { o.styles = {}; }
4332
-
4333
- o.styles._isStylesConfiguration = true;
4334
-
4335
- var styl = o.styles;
4336
- if (styl.back === no) { styl.back = 'rd-back'; }
4337
- if (styl.container === no) { styl.container = 'rd-container'; }
4338
- if (styl.positioned === no) { styl.positioned = 'rd-container-attachment'; }
4339
- if (styl.date === no) { styl.date = 'rd-date'; }
4340
- if (styl.dayBody === no) { styl.dayBody = 'rd-days-body'; }
4341
- if (styl.dayBodyElem === no) { styl.dayBodyElem = 'rd-day-body'; }
4342
- if (styl.dayPrevMonth === no) { styl.dayPrevMonth = 'rd-day-prev-month'; }
4343
- if (styl.dayNextMonth === no) { styl.dayNextMonth = 'rd-day-next-month'; }
4344
- if (styl.dayDisabled === no) { styl.dayDisabled = 'rd-day-disabled'; }
4345
- if (styl.dayConcealed === no) { styl.dayConcealed = 'rd-day-concealed'; }
4346
- if (styl.dayHead === no) { styl.dayHead = 'rd-days-head'; }
4347
- if (styl.dayHeadElem === no) { styl.dayHeadElem = 'rd-day-head'; }
4348
- if (styl.dayRow === no) { styl.dayRow = 'rd-days-row'; }
4349
- if (styl.dayTable === no) { styl.dayTable = 'rd-days'; }
4350
- if (styl.month === no) { styl.month = 'rd-month'; }
4351
- if (styl.monthLabel === no) { styl.monthLabel = 'rd-month-label'; }
4352
- if (styl.next === no) { styl.next = 'rd-next'; }
4353
- if (styl.selectedDay === no) { styl.selectedDay = 'rd-day-selected'; }
4354
- if (styl.selectedTime === no) { styl.selectedTime = 'rd-time-selected'; }
4355
- if (styl.time === no) { styl.time = 'rd-time'; }
4356
- if (styl.timeList === no) { styl.timeList = 'rd-time-list'; }
4357
- if (styl.timeOption === no) { styl.timeOption = 'rd-time-option'; }
4358
-
4359
- return o;
4360
- }
4361
-
4362
- module.exports = defaults;
4363
-
4364
- },{"./isInput":25,"./parse":28}],20:[function(_dereq_,module,exports){
4365
- 'use strict';
4366
-
4367
- function dom (options) {
4368
- var o = options || {};
4369
- if (!o.type) { o.type = 'div'; }
4370
- var elem = document.createElement(o.type);
4371
- if (o.className) { elem.className = o.className; }
4372
- if (o.text) { elem.innerText = elem.textContent = o.text; }
4373
- if (o.parent) { o.parent.appendChild(elem); }
4374
- return elem;
4375
- }
4376
-
4377
- module.exports = dom;
4378
-
4379
- },{}],21:[function(_dereq_,module,exports){
4380
- 'use strict';
4381
-
4382
- var addEvent = addEventEasy;
4383
- var removeEvent = removeEventEasy;
4384
-
4385
- if (!window.addEventListener) {
4386
- addEvent = addEventHard;
4387
- }
4388
-
4389
- if (!window.removeEventListener) {
4390
- removeEvent = removeEventHard;
4391
- }
4392
-
4393
- function addEventEasy (element, evt, fn) {
4394
- return element.addEventListener(evt, fn);
4395
- }
4396
-
4397
- function addEventHard (element, evt, fn) {
4398
- return element.attachEvent('on' + evt, function (ae) {
4399
- var e = ae || window.event;
4400
- e.target = e.target || e.srcElement;
4401
- e.preventDefault = e.preventDefault || function preventDefault () { e.returnValue = false; };
4402
- e.stopPropagation = e.stopPropagation || function stopPropagation () { e.cancelBubble = true; };
4403
- fn.call(element, e);
4404
- });
4405
- }
4406
-
4407
- function removeEventEasy (element, evt, fn) {
4408
- return element.removeEventListener(evt, fn);
4409
- }
4410
-
4411
- function removeEventHard (element, evt, fn) {
4412
- return element.detachEvent('on' + evt, fn);
4413
- }
4414
-
4415
- module.exports = {
4416
- add: addEvent,
4417
- remove: removeEvent
4418
- };
4419
-
4420
- },{}],22:[function(_dereq_,module,exports){
4421
- 'use strict';
4422
- var no;
4423
- var ikey = 'data-rome-id';
4424
- var index = [];
4425
-
4426
- function find (thing) { // can be a DOM element or a number
4427
- if (typeof thing !== 'number' && thing && thing.getAttribute) {
4428
- return find(thing.getAttribute(ikey));
4429
- }
4430
- var existing = index[thing];
4431
- if (existing !== no) {
4432
- return existing;
4433
- }
4434
- return null;
4435
- }
4436
-
4437
- function assign (elem, instance) {
4438
- elem.setAttribute(ikey, instance.id = index.push(instance) - 1);
4439
- }
4440
-
4441
- module.exports = {
4442
- find: find,
4443
- assign: assign
4444
- };
4445
-
4446
- },{}],23:[function(_dereq_,module,exports){
4447
- 'use strict';
4448
-
4449
- var raf = _dereq_('raf');
4450
- var calendar = _dereq_('./calendar');
4451
-
4452
- function inline (elem, calendarOptions) {
4453
- var o = calendarOptions || {};
4454
-
4455
- o.appendTo = elem;
4456
-
4457
- var api = calendar(o)
4458
- .on('ready', ready);
4459
-
4460
- function ready () {
4461
- raf(api.show);
4462
- }
4463
-
4464
- return api;
4465
- }
4466
-
4467
- module.exports = inline;
4468
-
4469
- },{"./calendar":15,"raf":12}],24:[function(_dereq_,module,exports){
4470
- 'use strict';
4471
-
4472
- var throttle = _dereq_('lodash.throttle');
4473
- var raf = _dereq_('raf');
4474
- var clone = _dereq_('./clone');
4475
- var calendar = _dereq_('./calendar');
4476
- var momentum = _dereq_('./momentum');
4477
- var classes = _dereq_('./classes');
4478
- var events = _dereq_('./events');
4479
-
4480
- function inputCalendar (input, calendarOptions) {
4481
- var o;
4482
- var api = calendar(calendarOptions);
4483
- var throttledTakeInput = throttle(takeInput, 50);
4484
- var throttledPosition = throttle(position, 30);
4485
- var ignoreInvalidation;
4486
- var ignoreShow;
4487
-
4488
- bindEvents();
4489
-
4490
- function init (superOptions) {
4491
- o = clone(superOptions);
4492
-
4493
- classes.add(api.container, o.styles.positioned);
4494
- events.add(api.container, 'mousedown', containerMouseDown);
4495
- events.add(api.container, 'click', containerClick);
4496
-
4497
- api.getDate = unrequire(api.getDate);
4498
- api.getDateString = unrequire(api.getDateString);
4499
- api.getMoment = unrequire(api.getMoment);
4500
-
4501
- if (o.initialValue) {
4502
- input.value = o.initialValue.format(o.inputFormat);
4503
- }
4504
-
4505
- api.on('data', updateInput);
4506
- api.on('show', throttledPosition);
4507
-
4508
- eventListening();
4509
- throttledTakeInput();
4510
- }
4511
-
4512
- function destroy () {
4513
- eventListening(true);
4514
- raf(bindEvents);
4515
- }
4516
-
4517
- function bindEvents () {
4518
- api.once('ready', init);
4519
- api.once('destroyed', destroy);
4520
- }
4521
-
4522
- function eventListening (remove) {
4523
- var op = remove ? 'remove' : 'add';
4524
- events[op](input, 'click', show);
4525
- events[op](input, 'touchend', show);
4526
- events[op](input, 'focusin', show);
4527
- events[op](input, 'change', throttledTakeInput);
4528
- events[op](input, 'keypress', throttledTakeInput);
4529
- events[op](input, 'keydown', throttledTakeInput);
4530
- events[op](input, 'input', throttledTakeInput);
4531
- if (o.invalidate) { events[op](input, 'blur', invalidateInput); }
4532
- events[op](window, 'resize', throttledPosition);
4533
- }
4534
-
4535
- function containerClick () {
4536
- ignoreShow = true;
4537
- input.focus();
4538
- ignoreShow = false;
4539
- }
4540
-
4541
- function containerMouseDown () {
4542
- ignoreInvalidation = true;
4543
- raf(unignore);
4544
-
4545
- function unignore () {
4546
- ignoreInvalidation = false;
4547
- }
4548
- }
4549
-
4550
- function invalidateInput () {
4551
- if (!ignoreInvalidation && !isEmpty()) {
4552
- api.emitValues();
4553
- }
4554
- }
4555
-
4556
- function show () {
4557
- if (ignoreShow) {
4558
- return;
4559
- }
4560
- api.show();
4561
- }
4562
-
4563
- function position () {
4564
- var bounds = input.getBoundingClientRect();
4565
- var scrollTop = document.body.scrollTop || document.documentElement.scrollTop;
4566
- api.container.style.top = bounds.top + scrollTop + input.offsetHeight + 'px';
4567
- api.container.style.left = bounds.left + 'px';
4568
- }
4569
-
4570
- function takeInput () {
4571
- var value = input.value.trim();
4572
- if (isEmpty()) {
4573
- return;
4574
- }
4575
- var date = momentum.moment(value, o.inputFormat);
4576
- api.setValue(date);
4577
- }
4578
-
4579
- function updateInput (data) {
4580
- input.value = data;
4581
- }
4582
-
4583
- function isEmpty () {
4584
- return o.required === false && input.value.trim() === '';
4585
- }
4586
-
4587
- function unrequire (fn) {
4588
- return function maybe () {
4589
- return isEmpty() ? null : fn.apply(this, arguments);
4590
- };
4591
- }
4592
-
4593
- return api;
4594
- }
4595
-
4596
- module.exports = inputCalendar;
4597
-
4598
- },{"./calendar":15,"./classes":16,"./clone":17,"./events":21,"./momentum":26,"lodash.throttle":4,"raf":12}],25:[function(_dereq_,module,exports){
4599
- 'use strict';
4600
-
4601
- function isInput (elem) {
4602
- return elem && elem.nodeName && elem.nodeName.toLowerCase() === 'input';
4603
- }
4604
-
4605
- module.exports = isInput;
4606
-
4607
- },{}],26:[function(_dereq_,module,exports){
4608
- 'use strict';
4609
-
4610
- function isMoment (value) {
4611
- return value && Object.prototype.hasOwnProperty.call(value, '_isAMomentObject');
4612
- }
4613
-
4614
- var api = {
4615
- moment: null,
4616
- isMoment: isMoment
4617
- };
4618
-
4619
- module.exports = api;
4620
-
4621
- },{}],27:[function(_dereq_,module,exports){
4622
- 'use strict';
4623
-
4624
- function noop () {}
4625
-
4626
- module.exports = noop;
4627
-
4628
- },{}],28:[function(_dereq_,module,exports){
4629
- 'use strict';
4630
-
4631
- var momentum = _dereq_('./momentum');
4632
-
4633
- function raw (date, format) {
4634
- if (typeof date === 'string') {
4635
- return momentum.moment(date, format);
4636
- }
4637
- if (Object.prototype.toString.call(date) === '[object Date]') {
4638
- return momentum.moment(date);
4639
- }
4640
- if (momentum.isMoment(date)) {
4641
- return date.clone();
4642
- }
4643
- }
4644
-
4645
- function parse (date, format) {
4646
- var m = raw(date, typeof format === 'string' ? format : null);
4647
- return m && m.isValid() ? m : null;
4648
- }
4649
-
4650
- module.exports = parse;
4651
-
4652
- },{"./momentum":26}],29:[function(_dereq_,module,exports){
4653
- if (!Array.prototype.every) {
4654
- Array.prototype.every = function (fn, ctx) {
4655
- var context, i;
4656
-
4657
- if (this == null) {
4658
- throw new TypeError('this is null or not defined');
4659
- }
4660
-
4661
- var source = Object(this);
4662
- var len = source.length >>> 0;
4663
-
4664
- if (typeof fn !== 'function') {
4665
- throw new TypeError(fn + ' is not a function');
4666
- }
4667
-
4668
- if (arguments.length > 1) {
4669
- context = ctx;
4670
- }
4671
-
4672
- i = 0;
4673
-
4674
- while (i < len) {
4675
- if (i in source) {
4676
- var test = fn.call(context, source[i], i, source);
4677
- if (!test) {
4678
- return false;
4679
- }
4680
- }
4681
- i++;
4682
- }
4683
- return true;
4684
- };
4685
- }
4686
-
4687
- },{}],30:[function(_dereq_,module,exports){
4688
- if (!Array.prototype.filter) {
4689
- Array.prototype.filter = function (fn, ctx) {
4690
- var f = [];
4691
- this.forEach(function (v, i, t) {
4692
- if (fn.call(ctx, v, i, t)) { f.push(v); }
4693
- }, ctx);
4694
- return f;
4695
- };
4696
- }
4697
-
4698
- },{}],31:[function(_dereq_,module,exports){
4699
- if (!Array.prototype.forEach) {
4700
- Array.prototype.forEach = function (fn, ctx) {
4701
- if (this === void 0 || this === null || typeof fn !== 'function') {
4702
- throw new TypeError();
4703
- }
4704
- var t = this;
4705
- var len = t.length;
4706
- for (var i = 0; i < len; i++) {
4707
- if (i in t) { fn.call(ctx, t[i], i, t); }
4708
- }
4709
- };
4710
- }
4711
-
4712
- },{}],32:[function(_dereq_,module,exports){
4713
- if (!Array.prototype.indexOf) {
4714
- Array.prototype.indexOf = function (what, start) {
4715
- if (this === undefined || this === null) {
4716
- throw new TypeError();
4717
- }
4718
- var length = this.length;
4719
- start = +start || 0;
4720
- if (Math.abs(start) === Infinity) {
4721
- start = 0;
4722
- } else if (start < 0) {
4723
- start += length;
4724
- if (start < 0) { start = 0; }
4725
- }
4726
- for (; start < length; start++) {
4727
- if (this[start] === what) {
4728
- return start;
4729
- }
4730
- }
4731
- return -1;
4732
- };
4733
- }
4734
-
4735
- },{}],33:[function(_dereq_,module,exports){
4736
- Array.isArray || (Array.isArray = function (a) {
4737
- return '' + a !== a && Object.prototype.toString.call(a) === '[object Array]';
4738
- });
4739
-
4740
- },{}],34:[function(_dereq_,module,exports){
4741
- if (!Array.prototype.map) {
4742
- Array.prototype.map = function (fn, ctx) {
4743
- var context, result, i;
4744
-
4745
- if (this == null) {
4746
- throw new TypeError('this is null or not defined');
4747
- }
4748
-
4749
- var source = Object(this);
4750
- var len = source.length >>> 0;
4751
-
4752
- if (typeof fn !== 'function') {
4753
- throw new TypeError(fn + ' is not a function');
4754
- }
4755
-
4756
- if (arguments.length > 1) {
4757
- context = ctx;
4758
- }
4759
-
4760
- result = new Array(len);
4761
- i = 0;
4762
-
4763
- while (i < len) {
4764
- if (i in source) {
4765
- result[i] = fn.call(context, source[i], i, source);
4766
- }
4767
- i++;
4768
- }
4769
- return result;
4770
- };
4771
- }
4772
-
4773
- },{}],35:[function(_dereq_,module,exports){
4774
- if (!Array.prototype.some) {
4775
- Array.prototype.some = function (fn, ctx) {
4776
- var context, i;
4777
-
4778
- if (this == null) {
4779
- throw new TypeError('this is null or not defined');
4780
- }
4781
-
4782
- var source = Object(this);
4783
- var len = source.length >>> 0;
4784
-
4785
- if (typeof fn !== 'function') {
4786
- throw new TypeError(fn + ' is not a function');
4787
- }
4788
-
4789
- if (arguments.length > 1) {
4790
- context = ctx;
4791
- }
4792
-
4793
- i = 0;
4794
-
4795
- while (i < len) {
4796
- if (i in source) {
4797
- var test = fn.call(context, source[i], i, source);
4798
- if (test) {
4799
- return true;
4800
- }
4801
- }
4802
- i++;
4803
- }
4804
- return false;
4805
- };
4806
- }
4807
-
4808
- },{}],36:[function(_dereq_,module,exports){
4809
- if (!Function.prototype.bind) {
4810
- Function.prototype.bind = function (context) {
4811
- if (typeof this !== 'function') {
4812
- throw new TypeError('Function.prototype.bind - what is trying to be bound is not callable');
4813
- }
4814
- var curried = Array.prototype.slice.call(arguments, 1);
4815
- var original = this;
4816
- var NoOp = function () {};
4817
- var bound = function () {
4818
- var ctx = this instanceof NoOp && context ? this : context;
4819
- var args = curried.concat(Array.prototype.slice.call(arguments));
4820
- return original.apply(ctx, args);
4821
- };
4822
- NoOp.prototype = this.prototype;
4823
- bound.prototype = new NoOp();
4824
- return bound;
4825
- };
4826
- }
4827
-
4828
- },{}],37:[function(_dereq_,module,exports){
4829
- if (!String.prototype.trim) {
4830
- String.prototype.trim = function () {
4831
- return this.replace(/^\s+|\s+$/g, '');
4832
- };
4833
- }
4834
-
4835
- },{}],38:[function(_dereq_,module,exports){
4836
- 'use strict';
4837
-
4838
- // these are only required for IE < 9
4839
- // maybe move to IE-specific distro?
4840
- _dereq_('./polyfills/function.bind');
4841
- _dereq_('./polyfills/array.foreach');
4842
- _dereq_('./polyfills/array.map');
4843
- _dereq_('./polyfills/array.filter');
4844
- _dereq_('./polyfills/array.isarray');
4845
- _dereq_('./polyfills/array.indexof');
4846
- _dereq_('./polyfills/array.every');
4847
- _dereq_('./polyfills/array.some');
4848
- _dereq_('./polyfills/string.trim');
4849
-
4850
- var core = _dereq_('./core');
4851
- var index = _dereq_('./index');
4852
- var use = _dereq_('./use');
4853
-
4854
- core.use = use.bind(core);
4855
- core.find = index.find;
4856
- core.val = _dereq_('./validators');
4857
-
4858
- module.exports = core;
4859
-
4860
- },{"./core":18,"./index":22,"./polyfills/array.every":29,"./polyfills/array.filter":30,"./polyfills/array.foreach":31,"./polyfills/array.indexof":32,"./polyfills/array.isarray":33,"./polyfills/array.map":34,"./polyfills/array.some":35,"./polyfills/function.bind":36,"./polyfills/string.trim":37,"./use":41,"./validators":42}],39:[function(_dereq_,module,exports){
4861
- 'use strict';
4862
-
4863
- var moment = _dereq_('moment');
4864
- var rome = _dereq_('./rome');
4865
-
4866
- rome.use(moment);
4867
-
4868
- module.exports = rome;
4869
-
4870
- },{"./rome":38,"moment":11}],40:[function(_dereq_,module,exports){
4871
- 'use strict';
4872
-
4873
- function text (elem, value) {
4874
- if (arguments.length === 2) {
4875
- elem.innerText = elem.textContent = value;
4876
- }
4877
- return elem.innerText || elem.textContent;
4878
- }
4879
-
4880
- module.exports = text;
4881
-
4882
- },{}],41:[function(_dereq_,module,exports){
4883
- 'use strict';
4884
-
4885
- var momentum = _dereq_('./momentum');
4886
-
4887
- function use (moment) {
4888
- this.moment = momentum.moment = moment;
4889
- }
4890
-
4891
- module.exports = use;
4892
-
4893
- },{"./momentum":26}],42:[function(_dereq_,module,exports){
4894
- 'use strict';
4895
-
4896
- var index = _dereq_('./index');
4897
- var parse = _dereq_('./parse');
4898
- var association = _dereq_('./association');
4899
-
4900
- function compareBuilder (compare) {
4901
- return function factory (value) {
4902
- var fixed = parse(value);
4903
-
4904
- return function validate (date) {
4905
- var cal = index.find(value);
4906
- var left = parse(date);
4907
- var right = fixed || cal && cal.getMoment();
4908
- if (!right) {
4909
- return true;
4910
- }
4911
- if (cal) {
4912
- association.add(this, cal);
4913
- }
4914
- return compare(left, right);
4915
- };
4916
- };
4917
- }
4918
-
4919
- function rangeBuilder (how, compare) {
4920
- return function factory (start, end) {
4921
- var dates;
4922
- var len = arguments.length;
4923
-
4924
- if (Array.isArray(start)) {
4925
- dates = start;
4926
- } else {
4927
- if (len === 1) {
4928
- dates = [start];
4929
- } else if (len === 2) {
4930
- dates = [[start, end]];
4931
- }
4932
- }
4933
-
4934
- return function validate (date) {
4935
- return dates.map(expand.bind(this))[how](compare.bind(this, date));
4936
- };
4937
-
4938
- function expand (value) {
4939
- var start, end;
4940
- var cal = index.find(value);
4941
- if (cal) {
4942
- start = end = cal.getMoment();
4943
- } else if (Array.isArray(value)) {
4944
- start = value[0]; end = value[1];
4945
- } else {
4946
- start = end = value;
4947
- }
4948
- if (cal) {
4949
- association.add(cal, this);
4950
- }
4951
- return {
4952
- start: parse(start).startOf('day').toDate(),
4953
- end: parse(end).endOf('day').toDate()
4954
- };
4955
- }
4956
- };
4957
- }
4958
-
4959
- var afterEq = compareBuilder(function (left, right) { return left >= right; });
4960
- var after = compareBuilder(function (left, right) { return left > right; });
4961
- var beforeEq = compareBuilder(function (left, right) { return left <= right; });
4962
- var before = compareBuilder(function (left, right) { return left < right; });
4963
-
4964
- var except = rangeBuilder('every', function (left, right) { return right.start > left || right.end < left; });
4965
- var only = rangeBuilder('some', function (left, right) { return right.start <= left && right.end >= left; });
4966
-
4967
- module.exports = {
4968
- afterEq: afterEq,
4969
- after: after,
4970
- beforeEq: beforeEq,
4971
- before: before,
4972
- except: except,
4973
- only: only
4974
- };
4975
-
4976
- },{"./association":14,"./index":22,"./parse":28}]},{},[39])
4977
- (39)
4978
- });