dlegr250_material_design 0.5.56 → 0.5.57

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/lib/dlegr250_material_design/version.rb +1 -1
  3. data/vendor/assets/javascripts/components/clockpicker.coffee +31 -0
  4. data/vendor/assets/javascripts/components/combobox.coffee +28 -0
  5. data/vendor/assets/javascripts/components/datepicker.coffee +29 -0
  6. data/vendor/assets/javascripts/components/expansion_panels.coffee +14 -0
  7. data/vendor/assets/javascripts/components/form_submit_buttons.coffee +4 -0
  8. data/vendor/assets/javascripts/components/html_editor.coffee +94 -0
  9. data/vendor/assets/javascripts/dlegr250_material_design.js +2 -6
  10. data/vendor/assets/javascripts/extensions/jquery/binary_insert.coffee +61 -0
  11. data/vendor/assets/javascripts/extensions/jquery/increment_and_decrement.coffee +19 -0
  12. data/vendor/assets/javascripts/extensions/jquery/positioning.coffee +22 -0
  13. data/vendor/assets/javascripts/extensions/jquery/spinner.coffee +13 -0
  14. data/vendor/assets/javascripts/third_party/autosize.min.3.0.20.js +6 -0
  15. data/vendor/assets/javascripts/third_party/jquery.clockpicker.js +737 -0
  16. data/vendor/assets/javascripts/third_party/moment.min.2.17.1.js +551 -0
  17. data/vendor/assets/javascripts/third_party/mousetrap.min.1.6.0.js +11 -0
  18. data/vendor/assets/javascripts/third_party/pikaday.base.js +1201 -0
  19. data/vendor/assets/javascripts/third_party/pikaday.jquery.js +56 -0
  20. data/vendor/assets/javascripts/third_party/scroll_scope.min.js +4 -0
  21. data/vendor/assets/javascripts/third_party/select2.min.4.0.3.js +3 -0
  22. data/vendor/assets/javascripts/third_party/sortable.js +1481 -0
  23. data/vendor/assets/stylesheets/base/global_classes.scss +0 -6
  24. data/vendor/assets/stylesheets/components/comments.scss +43 -4
  25. data/vendor/assets/stylesheets/components/cursors.scss +6 -0
  26. data/vendor/assets/stylesheets/components/dialogs.scss +5 -2
  27. data/vendor/assets/stylesheets/components/expansion_panels.scss +19 -0
  28. data/vendor/assets/stylesheets/components/lists.scss +48 -4
  29. data/vendor/assets/stylesheets/dlegr250_material_design.scss +2 -0
  30. data/vendor/assets/stylesheets/layouts/application/appbar.scss +4 -4
  31. metadata +23 -3
  32. data/vendor/assets/javascripts/extensions/jquery.js.coffee +0 -65
@@ -0,0 +1,11 @@
1
+ /* mousetrap v1.6.0 craig.is/killing/mice */
2
+ (function(r,t,g){function u(a,b,h){a.addEventListener?a.addEventListener(b,h,!1):a.attachEvent("on"+b,h)}function y(a){if("keypress"==a.type){var b=String.fromCharCode(a.which);a.shiftKey||(b=b.toLowerCase());return b}return k[a.which]?k[a.which]:p[a.which]?p[a.which]:String.fromCharCode(a.which).toLowerCase()}function D(a){var b=[];a.shiftKey&&b.push("shift");a.altKey&&b.push("alt");a.ctrlKey&&b.push("ctrl");a.metaKey&&b.push("meta");return b}function v(a){return"shift"==a||"ctrl"==a||"alt"==a||
3
+ "meta"==a}function z(a,b){var h,c,e,g=[];h=a;"+"===h?h=["+"]:(h=h.replace(/\+{2}/g,"+plus"),h=h.split("+"));for(e=0;e<h.length;++e)c=h[e],A[c]&&(c=A[c]),b&&"keypress"!=b&&B[c]&&(c=B[c],g.push("shift")),v(c)&&g.push(c);h=c;e=b;if(!e){if(!n){n={};for(var l in k)95<l&&112>l||k.hasOwnProperty(l)&&(n[k[l]]=l)}e=n[h]?"keydown":"keypress"}"keypress"==e&&g.length&&(e="keydown");return{key:c,modifiers:g,action:e}}function C(a,b){return null===a||a===t?!1:a===b?!0:C(a.parentNode,b)}function c(a){function b(a){a=
4
+ a||{};var b=!1,m;for(m in n)a[m]?b=!0:n[m]=0;b||(w=!1)}function h(a,b,m,f,c,h){var g,e,k=[],l=m.type;if(!d._callbacks[a])return[];"keyup"==l&&v(a)&&(b=[a]);for(g=0;g<d._callbacks[a].length;++g)if(e=d._callbacks[a][g],(f||!e.seq||n[e.seq]==e.level)&&l==e.action){var q;(q="keypress"==l&&!m.metaKey&&!m.ctrlKey)||(q=e.modifiers,q=b.sort().join(",")===q.sort().join(","));q&&(q=f&&e.seq==f&&e.level==h,(!f&&e.combo==c||q)&&d._callbacks[a].splice(g,1),k.push(e))}return k}function g(a,b,m,f){d.stopCallback(b,
5
+ b.target||b.srcElement,m,f)||!1!==a(b,m)||(b.preventDefault?b.preventDefault():b.returnValue=!1,b.stopPropagation?b.stopPropagation():b.cancelBubble=!0)}function e(a){"number"!==typeof a.which&&(a.which=a.keyCode);var b=y(a);b&&("keyup"==a.type&&x===b?x=!1:d.handleKey(b,D(a),a))}function k(a,c,m,f){function e(c){return function(){w=c;++n[a];clearTimeout(r);r=setTimeout(b,1E3)}}function h(c){g(m,c,a);"keyup"!==f&&(x=y(c));setTimeout(b,10)}for(var d=n[a]=0;d<c.length;++d){var p=d+1===c.length?h:e(f||
6
+ z(c[d+1]).action);l(c[d],p,f,a,d)}}function l(a,b,c,f,e){d._directMap[a+":"+c]=b;a=a.replace(/\s+/g," ");var g=a.split(" ");1<g.length?k(a,g,b,c):(c=z(a,c),d._callbacks[c.key]=d._callbacks[c.key]||[],h(c.key,c.modifiers,{type:c.action},f,a,e),d._callbacks[c.key][f?"unshift":"push"]({callback:b,modifiers:c.modifiers,action:c.action,seq:f,level:e,combo:a}))}var d=this;a=a||t;if(!(d instanceof c))return new c(a);d.target=a;d._callbacks={};d._directMap={};var n={},r,x=!1,p=!1,w=!1;d._handleKey=function(a,
7
+ c,e){var f=h(a,c,e),d;c={};var k=0,l=!1;for(d=0;d<f.length;++d)f[d].seq&&(k=Math.max(k,f[d].level));for(d=0;d<f.length;++d)f[d].seq?f[d].level==k&&(l=!0,c[f[d].seq]=1,g(f[d].callback,e,f[d].combo,f[d].seq)):l||g(f[d].callback,e,f[d].combo);f="keypress"==e.type&&p;e.type!=w||v(a)||f||b(c);p=l&&"keydown"==e.type};d._bindMultiple=function(a,b,c){for(var d=0;d<a.length;++d)l(a[d],b,c)};u(a,"keypress",e);u(a,"keydown",e);u(a,"keyup",e)}if(r){var k={8:"backspace",9:"tab",13:"enter",16:"shift",17:"ctrl",
8
+ 18:"alt",20:"capslock",27:"esc",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"ins",46:"del",91:"meta",93:"meta",224:"meta"},p={106:"*",107:"+",109:"-",110:".",111:"/",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},B={"~":"`","!":"1","@":"2","#":"3",$:"4","%":"5","^":"6","&":"7","*":"8","(":"9",")":"0",_:"-","+":"=",":":";",'"':"'","<":",",">":".","?":"/","|":"\\"},A={option:"alt",command:"meta","return":"enter",
9
+ escape:"esc",plus:"+",mod:/Mac|iPod|iPhone|iPad/.test(navigator.platform)?"meta":"ctrl"},n;for(g=1;20>g;++g)k[111+g]="f"+g;for(g=0;9>=g;++g)k[g+96]=g;c.prototype.bind=function(a,b,c){a=a instanceof Array?a:[a];this._bindMultiple.call(this,a,b,c);return this};c.prototype.unbind=function(a,b){return this.bind.call(this,a,function(){},b)};c.prototype.trigger=function(a,b){if(this._directMap[a+":"+b])this._directMap[a+":"+b]({},a);return this};c.prototype.reset=function(){this._callbacks={};this._directMap=
10
+ {};return this};c.prototype.stopCallback=function(a,b){return-1<(" "+b.className+" ").indexOf(" mousetrap ")||C(b,this.target)?!1:"INPUT"==b.tagName||"SELECT"==b.tagName||"TEXTAREA"==b.tagName||b.isContentEditable};c.prototype.handleKey=function(){return this._handleKey.apply(this,arguments)};c.addKeycodes=function(a){for(var b in a)a.hasOwnProperty(b)&&(k[b]=a[b]);n=null};c.init=function(){var a=c(t),b;for(b in a)"_"!==b.charAt(0)&&(c[b]=function(b){return function(){return a[b].apply(a,arguments)}}(b))};
11
+ c.init();r.Mousetrap=c;"undefined"!==typeof module&&module.exports&&(module.exports=c);"function"===typeof define&&define.amd&&define(function(){return c})}})("undefined"!==typeof window?window:null,"undefined"!==typeof window?document:null);
@@ -0,0 +1,1201 @@
1
+ /*!
2
+ * Pikaday
3
+ *
4
+ * Copyright © 2014 David Bushell | BSD & MIT license | https://github.com/dbushell/Pikaday
5
+ */
6
+
7
+ (function (root, factory)
8
+ {
9
+ 'use strict';
10
+
11
+ var moment;
12
+ if (typeof exports === 'object') {
13
+ // CommonJS module
14
+ // Load moment.js as an optional dependency
15
+ try { moment = require('moment'); } catch (e) {}
16
+ module.exports = factory(moment);
17
+ } else if (typeof define === 'function' && define.amd) {
18
+ // AMD. Register as an anonymous module.
19
+ define(function (req)
20
+ {
21
+ // Load moment.js as an optional dependency
22
+ var id = 'moment';
23
+ try { moment = req(id); } catch (e) {}
24
+ return factory(moment);
25
+ });
26
+ } else {
27
+ root.Pikaday = factory(root.moment);
28
+ }
29
+ }(this, function (moment)
30
+ {
31
+ 'use strict';
32
+
33
+ /**
34
+ * feature detection and helper functions
35
+ */
36
+ var hasMoment = typeof moment === 'function',
37
+
38
+ hasEventListeners = !!window.addEventListener,
39
+
40
+ document = window.document,
41
+
42
+ sto = window.setTimeout,
43
+
44
+ addEvent = function(el, e, callback, capture)
45
+ {
46
+ if (hasEventListeners) {
47
+ el.addEventListener(e, callback, !!capture);
48
+ } else {
49
+ el.attachEvent('on' + e, callback);
50
+ }
51
+ },
52
+
53
+ removeEvent = function(el, e, callback, capture)
54
+ {
55
+ if (hasEventListeners) {
56
+ el.removeEventListener(e, callback, !!capture);
57
+ } else {
58
+ el.detachEvent('on' + e, callback);
59
+ }
60
+ },
61
+
62
+ fireEvent = function(el, eventName, data)
63
+ {
64
+ var ev;
65
+
66
+ if (document.createEvent) {
67
+ ev = document.createEvent('HTMLEvents');
68
+ ev.initEvent(eventName, true, false);
69
+ ev = extend(ev, data);
70
+ el.dispatchEvent(ev);
71
+ } else if (document.createEventObject) {
72
+ ev = document.createEventObject();
73
+ ev = extend(ev, data);
74
+ el.fireEvent('on' + eventName, ev);
75
+ }
76
+ },
77
+
78
+ trim = function(str)
79
+ {
80
+ return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g,'');
81
+ },
82
+
83
+ hasClass = function(el, cn)
84
+ {
85
+ return (' ' + el.className + ' ').indexOf(' ' + cn + ' ') !== -1;
86
+ },
87
+
88
+ addClass = function(el, cn)
89
+ {
90
+ if (!hasClass(el, cn)) {
91
+ el.className = (el.className === '') ? cn : el.className + ' ' + cn;
92
+ }
93
+ },
94
+
95
+ removeClass = function(el, cn)
96
+ {
97
+ el.className = trim((' ' + el.className + ' ').replace(' ' + cn + ' ', ' '));
98
+ },
99
+
100
+ isArray = function(obj)
101
+ {
102
+ return (/Array/).test(Object.prototype.toString.call(obj));
103
+ },
104
+
105
+ isDate = function(obj)
106
+ {
107
+ return (/Date/).test(Object.prototype.toString.call(obj)) && !isNaN(obj.getTime());
108
+ },
109
+
110
+ isWeekend = function(date)
111
+ {
112
+ var day = date.getDay();
113
+ return day === 0 || day === 6;
114
+ },
115
+
116
+ isLeapYear = function(year)
117
+ {
118
+ // solution by Matti Virkkunen: http://stackoverflow.com/a/4881951
119
+ return year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
120
+ },
121
+
122
+ getDaysInMonth = function(year, month)
123
+ {
124
+ return [31, isLeapYear(year) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month];
125
+ },
126
+
127
+ setToStartOfDay = function(date)
128
+ {
129
+ if (isDate(date)) date.setHours(0,0,0,0);
130
+ },
131
+
132
+ compareDates = function(a,b)
133
+ {
134
+ // weak date comparison (use setToStartOfDay(date) to ensure correct result)
135
+ return a.getTime() === b.getTime();
136
+ },
137
+
138
+ extend = function(to, from, overwrite)
139
+ {
140
+ var prop, hasProp;
141
+ for (prop in from) {
142
+ hasProp = to[prop] !== undefined;
143
+ if (hasProp && typeof from[prop] === 'object' && from[prop] !== null && from[prop].nodeName === undefined) {
144
+ if (isDate(from[prop])) {
145
+ if (overwrite) {
146
+ to[prop] = new Date(from[prop].getTime());
147
+ }
148
+ }
149
+ else if (isArray(from[prop])) {
150
+ if (overwrite) {
151
+ to[prop] = from[prop].slice(0);
152
+ }
153
+ } else {
154
+ to[prop] = extend({}, from[prop], overwrite);
155
+ }
156
+ } else if (overwrite || !hasProp) {
157
+ to[prop] = from[prop];
158
+ }
159
+ }
160
+ return to;
161
+ },
162
+
163
+ adjustCalendar = function(calendar) {
164
+ if (calendar.month < 0) {
165
+ calendar.year -= Math.ceil(Math.abs(calendar.month)/12);
166
+ calendar.month += 12;
167
+ }
168
+ if (calendar.month > 11) {
169
+ calendar.year += Math.floor(Math.abs(calendar.month)/12);
170
+ calendar.month -= 12;
171
+ }
172
+ return calendar;
173
+ },
174
+
175
+ /**
176
+ * defaults and localisation
177
+ */
178
+ defaults = {
179
+
180
+ // bind the picker to a form field
181
+ field: null,
182
+
183
+ // automatically show/hide the picker on `field` focus (default `true` if `field` is set)
184
+ bound: undefined,
185
+
186
+ // position of the datepicker, relative to the field (default to bottom & left)
187
+ // ('bottom' & 'left' keywords are not used, 'top' & 'right' are modifier on the bottom/left position)
188
+ position: 'bottom left',
189
+
190
+ // automatically fit in the viewport even if it means repositioning from the position option
191
+ reposition: true,
192
+
193
+ // the default output format for `.toString()` and `field` value
194
+ format: 'YYYY-MM-DD',
195
+
196
+ // the initial date to view when first opened
197
+ defaultDate: null,
198
+
199
+ // make the `defaultDate` the initial selected value
200
+ setDefaultDate: false,
201
+
202
+ // first day of week (0: Sunday, 1: Monday etc)
203
+ firstDay: 0,
204
+
205
+ // the default flag for moment's strict date parsing
206
+ formatStrict: false,
207
+
208
+ // the minimum/earliest date that can be selected
209
+ minDate: null,
210
+ // the maximum/latest date that can be selected
211
+ maxDate: null,
212
+
213
+ // number of years either side, or array of upper/lower range
214
+ yearRange: 10,
215
+
216
+ // show week numbers at head of row
217
+ showWeekNumber: false,
218
+
219
+ // used internally (don't config outside)
220
+ minYear: 0,
221
+ maxYear: 9999,
222
+ minMonth: undefined,
223
+ maxMonth: undefined,
224
+
225
+ startRange: null,
226
+ endRange: null,
227
+
228
+ isRTL: false,
229
+
230
+ // Additional text to append to the year in the calendar title
231
+ yearSuffix: '',
232
+
233
+ // Render the month after year in the calendar title
234
+ showMonthAfterYear: false,
235
+
236
+ // Render days of the calendar grid that fall in the next or previous month
237
+ showDaysInNextAndPreviousMonths: false,
238
+
239
+ // how many months are visible
240
+ numberOfMonths: 1,
241
+
242
+ // when numberOfMonths is used, this will help you to choose where the main calendar will be (default `left`, can be set to `right`)
243
+ // only used for the first display or when a selected date is not visible
244
+ mainCalendar: 'left',
245
+
246
+ // Specify a DOM element to render the calendar in
247
+ container: undefined,
248
+
249
+ // internationalization
250
+ i18n: {
251
+ previousMonth : 'Previous Month',
252
+ nextMonth : 'Next Month',
253
+ months : ['January','February','March','April','May','June','July','August','September','October','November','December'],
254
+ weekdays : ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],
255
+ weekdaysShort : ['Sun','Mon','Tue','Wed','Thu','Fri','Sat']
256
+ },
257
+
258
+ // Theme Classname
259
+ theme: null,
260
+
261
+ // callback function
262
+ onSelect: null,
263
+ onOpen: null,
264
+ onClose: null,
265
+ onDraw: null,
266
+
267
+ // 2017-02-11 / dan.legrand@gmail.com
268
+ // Allow option for keyboard events; PR awaiting merge.
269
+ keyboardInput: true
270
+ },
271
+
272
+
273
+ /**
274
+ * templating functions to abstract HTML rendering
275
+ */
276
+ renderDayName = function(opts, day, abbr)
277
+ {
278
+ day += opts.firstDay;
279
+ while (day >= 7) {
280
+ day -= 7;
281
+ }
282
+ return abbr ? opts.i18n.weekdaysShort[day] : opts.i18n.weekdays[day];
283
+ },
284
+
285
+ renderDay = function(opts)
286
+ {
287
+ var arr = [];
288
+ var ariaSelected = 'false';
289
+ if (opts.isEmpty) {
290
+ if (opts.showDaysInNextAndPreviousMonths) {
291
+ arr.push('is-outside-current-month');
292
+ } else {
293
+ return '<td class="is-empty"></td>';
294
+ }
295
+ }
296
+ if (opts.isDisabled) {
297
+ arr.push('is-disabled');
298
+ }
299
+ if (opts.isToday) {
300
+ arr.push('is-today');
301
+ }
302
+ if (opts.isSelected) {
303
+ arr.push('is-selected');
304
+ ariaSelected = 'true';
305
+ }
306
+ if (opts.isInRange) {
307
+ arr.push('is-inrange');
308
+ }
309
+ if (opts.isStartRange) {
310
+ arr.push('is-startrange');
311
+ }
312
+ if (opts.isEndRange) {
313
+ arr.push('is-endrange');
314
+ }
315
+ return '<td data-day="' + opts.day + '" class="' + arr.join(' ') + '" aria-selected="' + ariaSelected + '">' +
316
+ '<button class="pika-button pika-day" type="button" ' +
317
+ 'data-pika-year="' + opts.year + '" data-pika-month="' + opts.month + '" data-pika-day="' + opts.day + '">' +
318
+ opts.day +
319
+ '</button>' +
320
+ '</td>';
321
+ },
322
+
323
+ renderWeek = function (d, m, y) {
324
+ // Lifted from http://javascript.about.com/library/blweekyear.htm, lightly modified.
325
+ var onejan = new Date(y, 0, 1),
326
+ weekNum = Math.ceil((((new Date(y, m, d) - onejan) / 86400000) + onejan.getDay()+1)/7);
327
+ return '<td class="pika-week">' + weekNum + '</td>';
328
+ },
329
+
330
+ renderRow = function(days, isRTL)
331
+ {
332
+ return '<tr>' + (isRTL ? days.reverse() : days).join('') + '</tr>';
333
+ },
334
+
335
+ renderBody = function(rows)
336
+ {
337
+ return '<tbody>' + rows.join('') + '</tbody>';
338
+ },
339
+
340
+ renderHead = function(opts)
341
+ {
342
+ var i, arr = [];
343
+ if (opts.showWeekNumber) {
344
+ arr.push('<th></th>');
345
+ }
346
+ for (i = 0; i < 7; i++) {
347
+ arr.push('<th scope="col"><abbr title="' + renderDayName(opts, i) + '">' + renderDayName(opts, i, true) + '</abbr></th>');
348
+ }
349
+ return '<thead><tr>' + (opts.isRTL ? arr.reverse() : arr).join('') + '</tr></thead>';
350
+ },
351
+
352
+ renderTitle = function(instance, c, year, month, refYear, randId)
353
+ {
354
+ var i, j, arr,
355
+ opts = instance._o,
356
+ isMinYear = year === opts.minYear,
357
+ isMaxYear = year === opts.maxYear,
358
+ html = '<div id="' + randId + '" class="pika-title" role="heading" aria-live="assertive">',
359
+ monthHtml,
360
+ yearHtml,
361
+ prev = true,
362
+ next = true;
363
+
364
+ for (arr = [], i = 0; i < 12; i++) {
365
+ arr.push('<option value="' + (year === refYear ? i - c : 12 + i - c) + '"' +
366
+ (i === month ? ' selected="selected"': '') +
367
+ ((isMinYear && i < opts.minMonth) || (isMaxYear && i > opts.maxMonth) ? 'disabled="disabled"' : '') + '>' +
368
+ opts.i18n.months[i] + '</option>');
369
+ }
370
+
371
+ monthHtml = '<div class="pika-label">' + opts.i18n.months[month] + '<select class="pika-select pika-select-month" tabindex="-1">' + arr.join('') + '</select></div>';
372
+
373
+ if (isArray(opts.yearRange)) {
374
+ i = opts.yearRange[0];
375
+ j = opts.yearRange[1] + 1;
376
+ } else {
377
+ i = year - opts.yearRange;
378
+ j = 1 + year + opts.yearRange;
379
+ }
380
+
381
+ for (arr = []; i < j && i <= opts.maxYear; i++) {
382
+ if (i >= opts.minYear) {
383
+ arr.push('<option value="' + i + '"' + (i === year ? ' selected="selected"': '') + '>' + (i) + '</option>');
384
+ }
385
+ }
386
+ yearHtml = '<div class="pika-label">' + year + opts.yearSuffix + '<select class="pika-select pika-select-year" tabindex="-1">' + arr.join('') + '</select></div>';
387
+
388
+ if (opts.showMonthAfterYear) {
389
+ html += yearHtml + monthHtml;
390
+ } else {
391
+ html += monthHtml + yearHtml;
392
+ }
393
+
394
+ if (isMinYear && (month === 0 || opts.minMonth >= month)) {
395
+ prev = false;
396
+ }
397
+
398
+ if (isMaxYear && (month === 11 || opts.maxMonth <= month)) {
399
+ next = false;
400
+ }
401
+
402
+ if (c === 0) {
403
+ html += '<button class="pika-prev' + (prev ? '' : ' is-disabled') + '" type="button">' + opts.i18n.previousMonth + '</button>';
404
+ }
405
+ if (c === (instance._o.numberOfMonths - 1) ) {
406
+ html += '<button class="pika-next' + (next ? '' : ' is-disabled') + '" type="button">' + opts.i18n.nextMonth + '</button>';
407
+ }
408
+
409
+ return html += '</div>';
410
+ },
411
+
412
+ renderTable = function(opts, data, randId)
413
+ {
414
+ return '<table cellpadding="0" cellspacing="0" class="pika-table" role="grid" aria-labelledby="' + randId + '">' + renderHead(opts) + renderBody(data) + '</table>';
415
+ },
416
+
417
+
418
+ /**
419
+ * Pikaday constructor
420
+ */
421
+ Pikaday = function(options)
422
+ {
423
+ var self = this,
424
+ opts = self.config(options);
425
+
426
+ self._onMouseDown = function(e)
427
+ {
428
+ if (!self._v) {
429
+ return;
430
+ }
431
+ e = e || window.event;
432
+ var target = e.target || e.srcElement;
433
+ if (!target) {
434
+ return;
435
+ }
436
+
437
+ if (!hasClass(target, 'is-disabled')) {
438
+ if (hasClass(target, 'pika-button') && !hasClass(target, 'is-empty') && !hasClass(target.parentNode, 'is-disabled')) {
439
+ self.setDate(new Date(target.getAttribute('data-pika-year'), target.getAttribute('data-pika-month'), target.getAttribute('data-pika-day')));
440
+ if (opts.bound) {
441
+ sto(function() {
442
+ self.hide();
443
+ if (opts.field) {
444
+ opts.field.blur();
445
+ }
446
+ }, 100);
447
+ }
448
+ }
449
+ else if (hasClass(target, 'pika-prev')) {
450
+ self.prevMonth();
451
+ }
452
+ else if (hasClass(target, 'pika-next')) {
453
+ self.nextMonth();
454
+ }
455
+ }
456
+ if (!hasClass(target, 'pika-select')) {
457
+ // if this is touch event prevent mouse events emulation
458
+ if (e.preventDefault) {
459
+ e.preventDefault();
460
+ } else {
461
+ e.returnValue = false;
462
+ return false;
463
+ }
464
+ } else {
465
+ self._c = true;
466
+ }
467
+ };
468
+
469
+ self._onChange = function(e)
470
+ {
471
+ e = e || window.event;
472
+ var target = e.target || e.srcElement;
473
+ if (!target) {
474
+ return;
475
+ }
476
+ if (hasClass(target, 'pika-select-month')) {
477
+ self.gotoMonth(target.value);
478
+ }
479
+ else if (hasClass(target, 'pika-select-year')) {
480
+ self.gotoYear(target.value);
481
+ }
482
+ };
483
+
484
+ self._onKeyChange = function(e)
485
+ {
486
+ e = e || window.event;
487
+
488
+ if (self.isVisible()) {
489
+
490
+ switch(e.keyCode){
491
+ case 13:
492
+ case 27:
493
+ opts.field.blur();
494
+ break;
495
+ case 37:
496
+ e.preventDefault();
497
+ self.adjustDate('subtract', 1);
498
+ break;
499
+ case 38:
500
+ self.adjustDate('subtract', 7);
501
+ break;
502
+ case 39:
503
+ self.adjustDate('add', 1);
504
+ break;
505
+ case 40:
506
+ self.adjustDate('add', 7);
507
+ break;
508
+ }
509
+ }
510
+ };
511
+
512
+ self._onInputChange = function(e)
513
+ {
514
+ var date;
515
+
516
+ if (e.firedBy === self) {
517
+ return;
518
+ }
519
+ if (hasMoment) {
520
+ date = moment(opts.field.value, opts.format, opts.formatStrict);
521
+ date = (date && date.isValid()) ? date.toDate() : null;
522
+ }
523
+ else {
524
+ date = new Date(Date.parse(opts.field.value));
525
+ }
526
+ if (isDate(date)) {
527
+ self.setDate(date);
528
+ }
529
+ if (!self._v) {
530
+ self.show();
531
+ }
532
+ };
533
+
534
+ self._onInputFocus = function()
535
+ {
536
+ self.show();
537
+ };
538
+
539
+ self._onInputClick = function()
540
+ {
541
+ self.show();
542
+ };
543
+
544
+ self._onInputBlur = function()
545
+ {
546
+ // IE allows pika div to gain focus; catch blur the input field
547
+ var pEl = document.activeElement;
548
+ do {
549
+ if (hasClass(pEl, 'pika-single')) {
550
+ return;
551
+ }
552
+ }
553
+ while ((pEl = pEl.parentNode));
554
+
555
+ if (!self._c) {
556
+ self._b = sto(function() {
557
+ self.hide();
558
+ }, 50);
559
+ }
560
+ self._c = false;
561
+ };
562
+
563
+ self._onClick = function(e)
564
+ {
565
+ e = e || window.event;
566
+ var target = e.target || e.srcElement,
567
+ pEl = target;
568
+ if (!target) {
569
+ return;
570
+ }
571
+ if (!hasEventListeners && hasClass(target, 'pika-select')) {
572
+ if (!target.onchange) {
573
+ target.setAttribute('onchange', 'return;');
574
+ addEvent(target, 'change', self._onChange);
575
+ }
576
+ }
577
+ do {
578
+ if (hasClass(pEl, 'pika-single') || pEl === opts.trigger) {
579
+ return;
580
+ }
581
+ }
582
+ while ((pEl = pEl.parentNode));
583
+ if (self._v && target !== opts.trigger && pEl !== opts.trigger) {
584
+ self.hide();
585
+ }
586
+ };
587
+
588
+ self.el = document.createElement('div');
589
+ self.el.className = 'pika-single' + (opts.isRTL ? ' is-rtl' : '') + (opts.theme ? ' ' + opts.theme : '');
590
+
591
+ addEvent(self.el, 'mousedown', self._onMouseDown, true);
592
+ addEvent(self.el, 'touchend', self._onMouseDown, true);
593
+ addEvent(self.el, 'change', self._onChange);
594
+ // 2017-02-11 / dan.legrand@gmail.com
595
+ // PR awaiting to merge for optional keyboard events
596
+ if (opts.keyboardInput) {
597
+ addEvent(document, 'keydown', self._onKeyChange);
598
+ }
599
+
600
+ if (opts.field) {
601
+ if (opts.container) {
602
+ opts.container.appendChild(self.el);
603
+ } else if (opts.bound) {
604
+ document.body.appendChild(self.el);
605
+ } else {
606
+ opts.field.parentNode.insertBefore(self.el, opts.field.nextSibling);
607
+ }
608
+ addEvent(opts.field, 'change', self._onInputChange);
609
+
610
+ if (!opts.defaultDate) {
611
+ if (hasMoment && opts.field.value) {
612
+ opts.defaultDate = moment(opts.field.value, opts.format).toDate();
613
+ } else {
614
+ opts.defaultDate = new Date(Date.parse(opts.field.value));
615
+ }
616
+ opts.setDefaultDate = true;
617
+ }
618
+ }
619
+
620
+ var defDate = opts.defaultDate;
621
+
622
+ if (isDate(defDate)) {
623
+ if (opts.setDefaultDate) {
624
+ self.setDate(defDate, true);
625
+ } else {
626
+ self.gotoDate(defDate);
627
+ }
628
+ } else {
629
+ self.gotoDate(new Date());
630
+ }
631
+
632
+ if (opts.bound) {
633
+ this.hide();
634
+ self.el.className += ' is-bound';
635
+ addEvent(opts.trigger, 'click', self._onInputClick);
636
+ addEvent(opts.trigger, 'focus', self._onInputFocus);
637
+ addEvent(opts.trigger, 'blur', self._onInputBlur);
638
+ } else {
639
+ this.show();
640
+ }
641
+ };
642
+
643
+
644
+ /**
645
+ * public Pikaday API
646
+ */
647
+ Pikaday.prototype = {
648
+
649
+
650
+ /**
651
+ * configure functionality
652
+ */
653
+ config: function(options)
654
+ {
655
+ if (!this._o) {
656
+ this._o = extend({}, defaults, true);
657
+ }
658
+
659
+ var opts = extend(this._o, options, true);
660
+
661
+ opts.isRTL = !!opts.isRTL;
662
+
663
+ opts.field = (opts.field && opts.field.nodeName) ? opts.field : null;
664
+
665
+ opts.theme = (typeof opts.theme) === 'string' && opts.theme ? opts.theme : null;
666
+
667
+ opts.bound = !!(opts.bound !== undefined ? opts.field && opts.bound : opts.field);
668
+
669
+ opts.trigger = (opts.trigger && opts.trigger.nodeName) ? opts.trigger : opts.field;
670
+
671
+ opts.disableWeekends = !!opts.disableWeekends;
672
+
673
+ opts.disableDayFn = (typeof opts.disableDayFn) === 'function' ? opts.disableDayFn : null;
674
+
675
+ var nom = parseInt(opts.numberOfMonths, 10) || 1;
676
+ opts.numberOfMonths = nom > 4 ? 4 : nom;
677
+
678
+ if (!isDate(opts.minDate)) {
679
+ opts.minDate = false;
680
+ }
681
+ if (!isDate(opts.maxDate)) {
682
+ opts.maxDate = false;
683
+ }
684
+ if ((opts.minDate && opts.maxDate) && opts.maxDate < opts.minDate) {
685
+ opts.maxDate = opts.minDate = false;
686
+ }
687
+ if (opts.minDate) {
688
+ this.setMinDate(opts.minDate);
689
+ }
690
+ if (opts.maxDate) {
691
+ this.setMaxDate(opts.maxDate);
692
+ }
693
+
694
+ if (isArray(opts.yearRange)) {
695
+ var fallback = new Date().getFullYear() - 10;
696
+ opts.yearRange[0] = parseInt(opts.yearRange[0], 10) || fallback;
697
+ opts.yearRange[1] = parseInt(opts.yearRange[1], 10) || fallback;
698
+ } else {
699
+ opts.yearRange = Math.abs(parseInt(opts.yearRange, 10)) || defaults.yearRange;
700
+ if (opts.yearRange > 100) {
701
+ opts.yearRange = 100;
702
+ }
703
+ }
704
+
705
+ return opts;
706
+ },
707
+
708
+ /**
709
+ * return a formatted string of the current selection (using Moment.js if available)
710
+ */
711
+ toString: function(format)
712
+ {
713
+ return !isDate(this._d) ? '' : hasMoment ? moment(this._d).format(format || this._o.format) : this._d.toDateString();
714
+ },
715
+
716
+ /**
717
+ * return a Moment.js object of the current selection (if available)
718
+ */
719
+ getMoment: function()
720
+ {
721
+ return hasMoment ? moment(this._d) : null;
722
+ },
723
+
724
+ /**
725
+ * set the current selection from a Moment.js object (if available)
726
+ */
727
+ setMoment: function(date, preventOnSelect)
728
+ {
729
+ if (hasMoment && moment.isMoment(date)) {
730
+ this.setDate(date.toDate(), preventOnSelect);
731
+ }
732
+ },
733
+
734
+ /**
735
+ * return a Date object of the current selection with fallback for the current date
736
+ */
737
+ getDate: function()
738
+ {
739
+ return isDate(this._d) ? new Date(this._d.getTime()) : new Date();
740
+ },
741
+
742
+ /**
743
+ * set the current selection
744
+ */
745
+ setDate: function(date, preventOnSelect)
746
+ {
747
+ if (!date) {
748
+ this._d = null;
749
+
750
+ if (this._o.field) {
751
+ this._o.field.value = '';
752
+ fireEvent(this._o.field, 'change', { firedBy: this });
753
+ }
754
+
755
+ return this.draw();
756
+ }
757
+ if (typeof date === 'string') {
758
+ date = new Date(Date.parse(date));
759
+ }
760
+ if (!isDate(date)) {
761
+ return;
762
+ }
763
+
764
+ var min = this._o.minDate,
765
+ max = this._o.maxDate;
766
+
767
+ if (isDate(min) && date < min) {
768
+ date = min;
769
+ } else if (isDate(max) && date > max) {
770
+ date = max;
771
+ }
772
+
773
+ this._d = new Date(date.getTime());
774
+ setToStartOfDay(this._d);
775
+ this.gotoDate(this._d);
776
+
777
+ if (this._o.field) {
778
+ this._o.field.value = this.toString();
779
+ fireEvent(this._o.field, 'change', { firedBy: this });
780
+ }
781
+ if (!preventOnSelect && typeof this._o.onSelect === 'function') {
782
+ this._o.onSelect.call(this, this.getDate());
783
+ }
784
+ },
785
+
786
+ /**
787
+ * change view to a specific date
788
+ */
789
+ gotoDate: function(date)
790
+ {
791
+ var newCalendar = true;
792
+
793
+ if (!isDate(date)) {
794
+ return;
795
+ }
796
+
797
+ if (this.calendars) {
798
+ var firstVisibleDate = new Date(this.calendars[0].year, this.calendars[0].month, 1),
799
+ lastVisibleDate = new Date(this.calendars[this.calendars.length-1].year, this.calendars[this.calendars.length-1].month, 1),
800
+ visibleDate = date.getTime();
801
+ // get the end of the month
802
+ lastVisibleDate.setMonth(lastVisibleDate.getMonth()+1);
803
+ lastVisibleDate.setDate(lastVisibleDate.getDate()-1);
804
+ newCalendar = (visibleDate < firstVisibleDate.getTime() || lastVisibleDate.getTime() < visibleDate);
805
+ }
806
+
807
+ if (newCalendar) {
808
+ this.calendars = [{
809
+ month: date.getMonth(),
810
+ year: date.getFullYear()
811
+ }];
812
+ if (this._o.mainCalendar === 'right') {
813
+ this.calendars[0].month += 1 - this._o.numberOfMonths;
814
+ }
815
+ }
816
+
817
+ this.adjustCalendars();
818
+ },
819
+
820
+ adjustDate: function(sign, days) {
821
+
822
+ var day = this.getDate();
823
+ var difference = parseInt(days)*24*60*60*1000;
824
+
825
+ var newDay;
826
+
827
+ if (sign === 'add') {
828
+ newDay = new Date(day.valueOf() + difference);
829
+ } else if (sign === 'subtract') {
830
+ newDay = new Date(day.valueOf() - difference);
831
+ }
832
+
833
+ if (hasMoment) {
834
+ if (sign === 'add') {
835
+ newDay = moment(day).add(days, "days").toDate();
836
+ } else if (sign === 'subtract') {
837
+ newDay = moment(day).subtract(days, "days").toDate();
838
+ }
839
+ }
840
+
841
+ this.setDate(newDay);
842
+ },
843
+
844
+ adjustCalendars: function() {
845
+ this.calendars[0] = adjustCalendar(this.calendars[0]);
846
+ for (var c = 1; c < this._o.numberOfMonths; c++) {
847
+ this.calendars[c] = adjustCalendar({
848
+ month: this.calendars[0].month + c,
849
+ year: this.calendars[0].year
850
+ });
851
+ }
852
+ this.draw();
853
+ },
854
+
855
+ gotoToday: function()
856
+ {
857
+ this.gotoDate(new Date());
858
+ },
859
+
860
+ /**
861
+ * change view to a specific month (zero-index, e.g. 0: January)
862
+ */
863
+ gotoMonth: function(month)
864
+ {
865
+ if (!isNaN(month)) {
866
+ this.calendars[0].month = parseInt(month, 10);
867
+ this.adjustCalendars();
868
+ }
869
+ },
870
+
871
+ nextMonth: function()
872
+ {
873
+ this.calendars[0].month++;
874
+ this.adjustCalendars();
875
+ },
876
+
877
+ prevMonth: function()
878
+ {
879
+ this.calendars[0].month--;
880
+ this.adjustCalendars();
881
+ },
882
+
883
+ /**
884
+ * change view to a specific full year (e.g. "2012")
885
+ */
886
+ gotoYear: function(year)
887
+ {
888
+ if (!isNaN(year)) {
889
+ this.calendars[0].year = parseInt(year, 10);
890
+ this.adjustCalendars();
891
+ }
892
+ },
893
+
894
+ /**
895
+ * change the minDate
896
+ */
897
+ setMinDate: function(value)
898
+ {
899
+ if(value instanceof Date) {
900
+ setToStartOfDay(value);
901
+ this._o.minDate = value;
902
+ this._o.minYear = value.getFullYear();
903
+ this._o.minMonth = value.getMonth();
904
+ } else {
905
+ this._o.minDate = defaults.minDate;
906
+ this._o.minYear = defaults.minYear;
907
+ this._o.minMonth = defaults.minMonth;
908
+ this._o.startRange = defaults.startRange;
909
+ }
910
+
911
+ this.draw();
912
+ },
913
+
914
+ /**
915
+ * change the maxDate
916
+ */
917
+ setMaxDate: function(value)
918
+ {
919
+ if(value instanceof Date) {
920
+ setToStartOfDay(value);
921
+ this._o.maxDate = value;
922
+ this._o.maxYear = value.getFullYear();
923
+ this._o.maxMonth = value.getMonth();
924
+ } else {
925
+ this._o.maxDate = defaults.maxDate;
926
+ this._o.maxYear = defaults.maxYear;
927
+ this._o.maxMonth = defaults.maxMonth;
928
+ this._o.endRange = defaults.endRange;
929
+ }
930
+
931
+ this.draw();
932
+ },
933
+
934
+ setStartRange: function(value)
935
+ {
936
+ this._o.startRange = value;
937
+ },
938
+
939
+ setEndRange: function(value)
940
+ {
941
+ this._o.endRange = value;
942
+ },
943
+
944
+ /**
945
+ * refresh the HTML
946
+ */
947
+ draw: function(force)
948
+ {
949
+ if (!this._v && !force) {
950
+ return;
951
+ }
952
+ var opts = this._o,
953
+ minYear = opts.minYear,
954
+ maxYear = opts.maxYear,
955
+ minMonth = opts.minMonth,
956
+ maxMonth = opts.maxMonth,
957
+ html = '',
958
+ randId;
959
+
960
+ if (this._y <= minYear) {
961
+ this._y = minYear;
962
+ if (!isNaN(minMonth) && this._m < minMonth) {
963
+ this._m = minMonth;
964
+ }
965
+ }
966
+ if (this._y >= maxYear) {
967
+ this._y = maxYear;
968
+ if (!isNaN(maxMonth) && this._m > maxMonth) {
969
+ this._m = maxMonth;
970
+ }
971
+ }
972
+
973
+ randId = 'pika-title-' + Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 2);
974
+
975
+ for (var c = 0; c < opts.numberOfMonths; c++) {
976
+ html += '<div class="pika-lendar">' + renderTitle(this, c, this.calendars[c].year, this.calendars[c].month, this.calendars[0].year, randId) + this.render(this.calendars[c].year, this.calendars[c].month, randId) + '</div>';
977
+ }
978
+
979
+ this.el.innerHTML = html;
980
+
981
+ if (opts.bound) {
982
+ if(opts.field.type !== 'hidden') {
983
+ sto(function() {
984
+ opts.trigger.focus();
985
+ }, 1);
986
+ }
987
+ }
988
+
989
+ if (typeof this._o.onDraw === 'function') {
990
+ this._o.onDraw(this);
991
+ }
992
+
993
+ if (opts.bound) {
994
+ // let the screen reader user know to use arrow keys
995
+ opts.field.setAttribute('aria-label', 'Use the arrow keys to pick a date');
996
+ }
997
+ },
998
+
999
+ adjustPosition: function()
1000
+ {
1001
+ var field, pEl, width, height, viewportWidth, viewportHeight, scrollTop, left, top, clientRect;
1002
+
1003
+ if (this._o.container) return;
1004
+
1005
+ this.el.style.position = 'absolute';
1006
+
1007
+ field = this._o.trigger;
1008
+ pEl = field;
1009
+ width = this.el.offsetWidth;
1010
+ height = this.el.offsetHeight;
1011
+ viewportWidth = window.innerWidth || document.documentElement.clientWidth;
1012
+ viewportHeight = window.innerHeight || document.documentElement.clientHeight;
1013
+ scrollTop = window.pageYOffset || document.body.scrollTop || document.documentElement.scrollTop;
1014
+
1015
+ if (typeof field.getBoundingClientRect === 'function') {
1016
+ clientRect = field.getBoundingClientRect();
1017
+ left = clientRect.left + window.pageXOffset;
1018
+ top = clientRect.bottom + window.pageYOffset;
1019
+ } else {
1020
+ left = pEl.offsetLeft;
1021
+ top = pEl.offsetTop + pEl.offsetHeight;
1022
+ while((pEl = pEl.offsetParent)) {
1023
+ left += pEl.offsetLeft;
1024
+ top += pEl.offsetTop;
1025
+ }
1026
+ }
1027
+
1028
+ // default position is bottom & left
1029
+ if ((this._o.reposition && left + width > viewportWidth) ||
1030
+ (
1031
+ this._o.position.indexOf('right') > -1 &&
1032
+ left - width + field.offsetWidth > 0
1033
+ )
1034
+ ) {
1035
+ left = left - width + field.offsetWidth;
1036
+ }
1037
+ if ((this._o.reposition && top + height > viewportHeight + scrollTop) ||
1038
+ (
1039
+ this._o.position.indexOf('top') > -1 &&
1040
+ top - height - field.offsetHeight > 0
1041
+ )
1042
+ ) {
1043
+ top = top - height - field.offsetHeight;
1044
+ }
1045
+
1046
+ this.el.style.left = left + 'px';
1047
+ this.el.style.top = top + 'px';
1048
+ },
1049
+
1050
+ /**
1051
+ * render HTML for a particular month
1052
+ */
1053
+ render: function(year, month, randId)
1054
+ {
1055
+ var opts = this._o,
1056
+ now = new Date(),
1057
+ days = getDaysInMonth(year, month),
1058
+ before = new Date(year, month, 1).getDay(),
1059
+ data = [],
1060
+ row = [];
1061
+ setToStartOfDay(now);
1062
+ if (opts.firstDay > 0) {
1063
+ before -= opts.firstDay;
1064
+ if (before < 0) {
1065
+ before += 7;
1066
+ }
1067
+ }
1068
+ var previousMonth = month === 0 ? 11 : month - 1,
1069
+ nextMonth = month === 11 ? 0 : month + 1,
1070
+ yearOfPreviousMonth = month === 0 ? year - 1 : year,
1071
+ yearOfNextMonth = month === 11 ? year + 1 : year,
1072
+ daysInPreviousMonth = getDaysInMonth(yearOfPreviousMonth, previousMonth);
1073
+ var cells = days + before,
1074
+ after = cells;
1075
+ while(after > 7) {
1076
+ after -= 7;
1077
+ }
1078
+ cells += 7 - after;
1079
+ for (var i = 0, r = 0; i < cells; i++)
1080
+ {
1081
+ var day = new Date(year, month, 1 + (i - before)),
1082
+ isSelected = isDate(this._d) ? compareDates(day, this._d) : false,
1083
+ isToday = compareDates(day, now),
1084
+ isEmpty = i < before || i >= (days + before),
1085
+ dayNumber = 1 + (i - before),
1086
+ monthNumber = month,
1087
+ yearNumber = year,
1088
+ isStartRange = opts.startRange && compareDates(opts.startRange, day),
1089
+ isEndRange = opts.endRange && compareDates(opts.endRange, day),
1090
+ isInRange = opts.startRange && opts.endRange && opts.startRange < day && day < opts.endRange,
1091
+ isDisabled = (opts.minDate && day < opts.minDate) ||
1092
+ (opts.maxDate && day > opts.maxDate) ||
1093
+ (opts.disableWeekends && isWeekend(day)) ||
1094
+ (opts.disableDayFn && opts.disableDayFn(day));
1095
+
1096
+ if (isEmpty) {
1097
+ if (i < before) {
1098
+ dayNumber = daysInPreviousMonth + dayNumber;
1099
+ monthNumber = previousMonth;
1100
+ yearNumber = yearOfPreviousMonth;
1101
+ } else {
1102
+ dayNumber = dayNumber - days;
1103
+ monthNumber = nextMonth;
1104
+ yearNumber = yearOfNextMonth;
1105
+ }
1106
+ }
1107
+
1108
+ var dayConfig = {
1109
+ day: dayNumber,
1110
+ month: monthNumber,
1111
+ year: yearNumber,
1112
+ isSelected: isSelected,
1113
+ isToday: isToday,
1114
+ isDisabled: isDisabled,
1115
+ isEmpty: isEmpty,
1116
+ isStartRange: isStartRange,
1117
+ isEndRange: isEndRange,
1118
+ isInRange: isInRange,
1119
+ showDaysInNextAndPreviousMonths: opts.showDaysInNextAndPreviousMonths
1120
+ };
1121
+
1122
+ row.push(renderDay(dayConfig));
1123
+
1124
+ if (++r === 7) {
1125
+ if (opts.showWeekNumber) {
1126
+ row.unshift(renderWeek(i - before, month, year));
1127
+ }
1128
+ data.push(renderRow(row, opts.isRTL));
1129
+ row = [];
1130
+ r = 0;
1131
+ }
1132
+ }
1133
+ return renderTable(opts, data, randId);
1134
+ },
1135
+
1136
+ isVisible: function()
1137
+ {
1138
+ return this._v;
1139
+ },
1140
+
1141
+ show: function()
1142
+ {
1143
+ if (!this.isVisible()) {
1144
+ removeClass(this.el, 'is-hidden');
1145
+ this._v = true;
1146
+ this.draw();
1147
+ if (this._o.bound) {
1148
+ addEvent(document, 'click', this._onClick);
1149
+ this.adjustPosition();
1150
+ }
1151
+ if (typeof this._o.onOpen === 'function') {
1152
+ this._o.onOpen.call(this);
1153
+ }
1154
+ }
1155
+ },
1156
+
1157
+ hide: function()
1158
+ {
1159
+ var v = this._v;
1160
+ if (v !== false) {
1161
+ if (this._o.bound) {
1162
+ removeEvent(document, 'click', this._onClick);
1163
+ }
1164
+ this.el.style.position = 'static'; // reset
1165
+ this.el.style.left = 'auto';
1166
+ this.el.style.top = 'auto';
1167
+ addClass(this.el, 'is-hidden');
1168
+ this._v = false;
1169
+ if (v !== undefined && typeof this._o.onClose === 'function') {
1170
+ this._o.onClose.call(this);
1171
+ }
1172
+ }
1173
+ },
1174
+
1175
+ /**
1176
+ * GAME OVER
1177
+ */
1178
+ destroy: function()
1179
+ {
1180
+ this.hide();
1181
+ removeEvent(this.el, 'mousedown', this._onMouseDown, true);
1182
+ removeEvent(this.el, 'touchend', this._onMouseDown, true);
1183
+ removeEvent(this.el, 'change', this._onChange);
1184
+ if (this._o.field) {
1185
+ removeEvent(this._o.field, 'change', this._onInputChange);
1186
+ if (this._o.bound) {
1187
+ removeEvent(this._o.trigger, 'click', this._onInputClick);
1188
+ removeEvent(this._o.trigger, 'focus', this._onInputFocus);
1189
+ removeEvent(this._o.trigger, 'blur', this._onInputBlur);
1190
+ }
1191
+ }
1192
+ if (this.el.parentNode) {
1193
+ this.el.parentNode.removeChild(this.el);
1194
+ }
1195
+ }
1196
+
1197
+ };
1198
+
1199
+ return Pikaday;
1200
+
1201
+ }));