@grafit/era-dependencies 1.0.0
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.
- package/package.json +7 -0
- package/vendor/fonts/FontAwesome.otf +0 -0
- package/vendor/fonts/fontawesome-webfont.eot +0 -0
- package/vendor/fonts/fontawesome-webfont.svg +685 -0
- package/vendor/fonts/fontawesome-webfont.ttf +0 -0
- package/vendor/fonts/fontawesome-webfont.woff +0 -0
- package/vendor/fonts/fontawesome-webfont.woff2 +0 -0
- package/vendor/fonts/glyphicons-halflings-regular.eot +0 -0
- package/vendor/fonts/glyphicons-halflings-regular.svg +288 -0
- package/vendor/fonts/glyphicons-halflings-regular.ttf +0 -0
- package/vendor/fonts/glyphicons-halflings-regular.woff +0 -0
- package/vendor/fonts/glyphicons-halflings-regular.woff2 +0 -0
- package/vendor/scripts/angular/angular-cookies.js +322 -0
- package/vendor/scripts/angular/angular-file-upload.js +2087 -0
- package/vendor/scripts/angular/angular-filter.js +2287 -0
- package/vendor/scripts/angular/angular-locale_ru-ru.js +143 -0
- package/vendor/scripts/angular/angular-route.js +1069 -0
- package/vendor/scripts/angular/angular-sanitize.js +738 -0
- package/vendor/scripts/angular/angular-ui-router-0.2.18.js +4539 -0
- package/vendor/scripts/angular/angular.js +31768 -0
- package/vendor/scripts/angular/datetimepicker.js +578 -0
- package/vendor/scripts/angular/datetimepicker.templates.js +30 -0
- package/vendor/scripts/angular/mask.min.js +7 -0
- package/vendor/scripts/angular/ng-table.js +1518 -0
- package/vendor/scripts/angular/select.js +2356 -0
- package/vendor/scripts/angular/ui-bootstrap-tpls-2.1.3.js +7536 -0
- package/vendor/scripts/angular/uploader.js +3 -0
- package/vendor/scripts/bootbox.js +985 -0
- package/vendor/scripts/bootstrap.js +2377 -0
- package/vendor/scripts/es6-shim.js +3837 -0
- package/vendor/scripts/highchart/highcharts-more.src.js +3165 -0
- package/vendor/scripts/highchart/highstock.src.js +32008 -0
- package/vendor/scripts/highchart/modules/boost.src.js +2721 -0
- package/vendor/scripts/highchart/modules/exporting.src.js +951 -0
- package/vendor/scripts/jquery/jquery.js +11008 -0
- package/vendor/scripts/jquery.datetimepicker.full.js +2911 -0
- package/vendor/scripts/keycloak.js +2382 -0
- package/vendor/scripts/lodash.js +16733 -0
- package/vendor/scripts/moment-with-locales.js +12251 -0
- package/vendor/scripts/moment.js +4234 -0
- package/vendor/scripts/old/datepicker-ru.js +38 -0
- package/vendor/scripts/old/jquery-ui-1.11.1.js +16375 -0
- package/vendor/scripts/old/jquery.form.js +1278 -0
- package/vendor/scripts/perfect-scrollbar.js +1549 -0
- package/vendor/scripts/pickmeup/pickmeup-locales.js +11 -0
- package/vendor/scripts/pickmeup/pickmeup.js +1383 -0
- package/vendor/scripts/quill.js +9676 -0
- package/vendor/scripts/socket.io.min.js +3 -0
- package/vendor/scripts/textAngular/angular-spectrum-colorpicker.min.js +2 -0
- package/vendor/scripts/textAngular/spectrum.min.js +1 -0
- package/vendor/scripts/textAngular/textAngular-dropdownToggle.js +38 -0
- package/vendor/scripts/textAngular/textAngular-rangy.min.js +478 -0
- package/vendor/scripts/textAngular/textAngular-sanitize.min.js +322 -0
- package/vendor/scripts/textAngular/textAngular.min.js +1481 -0
- package/vendor/scripts/textAngular/textAngularSetup.js +1013 -0
- package/vendor/styles/bootstrap-theme.css +587 -0
- package/vendor/styles/bootstrap-theme.css.map +1 -0
- package/vendor/styles/bootstrap-theme.min.css +6 -0
- package/vendor/styles/bootstrap-theme.min.css.map +1 -0
- package/vendor/styles/bootstrap.css +6757 -0
- package/vendor/styles/bootstrap.css.map +1 -0
- package/vendor/styles/bootstrap.min.css +6 -0
- package/vendor/styles/bootstrap.min.css.map +1 -0
- package/vendor/styles/datetimepicker.css +115 -0
- package/vendor/styles/font-awesome.css +2199 -0
- package/vendor/styles/jquery.datetimepicker.min.css +1 -0
- package/vendor/styles/ng-table.css +136 -0
- package/vendor/styles/normalize.css +424 -0
- package/vendor/styles/perfect-scrollbar.css +165 -0
- package/vendor/styles/pickmeup.css +137 -0
- package/vendor/styles/spectrum.min.css +1 -0
- package/vendor/styles/textAngular.css +193 -0
|
@@ -0,0 +1,1383 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @package PickMeUp
|
|
3
|
+
* @author Nazar Mokrynskyi <nazar@mokrynskyi.com>
|
|
4
|
+
* @author Stefan Petre <www.eyecon.ro>
|
|
5
|
+
* @license 0BSD
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
(function (root, factory) {
|
|
9
|
+
if (typeof define === 'function' && define.amd) {
|
|
10
|
+
// AMD
|
|
11
|
+
//noinspection JSUnresolvedFunction
|
|
12
|
+
define(factory);
|
|
13
|
+
} else if (typeof exports === 'object') {
|
|
14
|
+
// CommonJS
|
|
15
|
+
module.exports = factory();
|
|
16
|
+
} else {
|
|
17
|
+
// Browser globals
|
|
18
|
+
root.pickmeup = factory();
|
|
19
|
+
}
|
|
20
|
+
}(window, function () {
|
|
21
|
+
/**
|
|
22
|
+
* Functions prefixed with `dom_` are simple convenient wrappers for various operations with DOM
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @param {(Element|NodeList)} element
|
|
27
|
+
* @param {Function} callback
|
|
28
|
+
* @param {*} [args=[]]
|
|
29
|
+
*/
|
|
30
|
+
function dom_for_collection (element, callback, args) {
|
|
31
|
+
args = args || [];
|
|
32
|
+
if (element instanceof Element) {
|
|
33
|
+
callback.apply(callback, [element].concat(args));
|
|
34
|
+
} else {
|
|
35
|
+
var elements, i;
|
|
36
|
+
elements = element.length;
|
|
37
|
+
for (i = 0; i < elements; ++i) {
|
|
38
|
+
callback.apply(callback, [element[i]].concat(args));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @param {(Element|Element[]|NodeList)} element
|
|
45
|
+
*/
|
|
46
|
+
function dom_remove (element) {
|
|
47
|
+
dom_for_collection(element, function (element) {
|
|
48
|
+
element.parentElement.removeChild(element);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @param {Element} element
|
|
54
|
+
* @param {string} selector
|
|
55
|
+
*
|
|
56
|
+
* @returns {Element}
|
|
57
|
+
*/
|
|
58
|
+
function dom_closest_parent (element, selector) {
|
|
59
|
+
var parent = element;
|
|
60
|
+
do {
|
|
61
|
+
parent = parent.parentElement;
|
|
62
|
+
} while (parent && !dom_matches(parent, selector));
|
|
63
|
+
return parent;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* @param {Element} element
|
|
68
|
+
* @param {string} selector
|
|
69
|
+
*
|
|
70
|
+
* @returns {boolean}
|
|
71
|
+
*/
|
|
72
|
+
function dom_matches (element, selector) {
|
|
73
|
+
return (element.matches || element.webkitMatchesSelector || element.msMatchesSelector).call(element, selector);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* @param {Element} element
|
|
78
|
+
* @param {string} class_name
|
|
79
|
+
*
|
|
80
|
+
* @returns {boolean}
|
|
81
|
+
*/
|
|
82
|
+
function dom_has_class (element, class_name) {
|
|
83
|
+
return element && element.classList.contains(class_name);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* @param {Element} element
|
|
88
|
+
* @param {string} class_name
|
|
89
|
+
*/
|
|
90
|
+
function dom_add_class (element, class_name) {
|
|
91
|
+
element.classList.add(class_name);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* @param {Element} element
|
|
96
|
+
* @param {string} class_name
|
|
97
|
+
*/
|
|
98
|
+
function dom_remove_class (element, class_name) {
|
|
99
|
+
element.classList.remove(class_name);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* @param {Element} element
|
|
104
|
+
* @param {string} selector
|
|
105
|
+
*
|
|
106
|
+
* @returns {Element}
|
|
107
|
+
*/
|
|
108
|
+
function dom_query (element, selector) {
|
|
109
|
+
return element.querySelector(selector);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* @param {Element} element
|
|
114
|
+
* @param {string} selector
|
|
115
|
+
*
|
|
116
|
+
* @returns {Element[]}
|
|
117
|
+
*/
|
|
118
|
+
function dom_query_all (element, selector) {
|
|
119
|
+
return Array.prototype.slice.call(element.querySelectorAll(selector));
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* @param {Element} target
|
|
124
|
+
* @param {(Element|Window)} element
|
|
125
|
+
* @param {string} event
|
|
126
|
+
* @param {Function} callback
|
|
127
|
+
*/
|
|
128
|
+
function dom_on (target, element, event, callback) {
|
|
129
|
+
if (event.indexOf(' ') !== -1) {
|
|
130
|
+
var events = event.split(' '),
|
|
131
|
+
events_number = events.length,
|
|
132
|
+
i;
|
|
133
|
+
for (i = 0; i < events_number; ++i) {
|
|
134
|
+
dom_on(target, element, events[i], callback)
|
|
135
|
+
}
|
|
136
|
+
} else {
|
|
137
|
+
target.__pickmeup.events.push([element, event, callback]);
|
|
138
|
+
element.addEventListener(event, callback);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* @param {Element} target
|
|
144
|
+
* @param {(Element|Window)} [element=undefined]
|
|
145
|
+
* @param {string} [event='']
|
|
146
|
+
* @param {Function} [callback=undefined]
|
|
147
|
+
*/
|
|
148
|
+
function dom_off (target, element, event, callback) {
|
|
149
|
+
var events,
|
|
150
|
+
events_number,
|
|
151
|
+
i;
|
|
152
|
+
if (event && event.indexOf(' ') !== -1) {
|
|
153
|
+
events = event.split(' ');
|
|
154
|
+
events_number = events.length;
|
|
155
|
+
for (i = 0; i < events_number; ++i) {
|
|
156
|
+
dom_off(target, element, events[i], callback)
|
|
157
|
+
}
|
|
158
|
+
} else {
|
|
159
|
+
events = target.__pickmeup.events;
|
|
160
|
+
events_number = events.length;
|
|
161
|
+
for (i = 0; i < events_number; ++i) {
|
|
162
|
+
if (
|
|
163
|
+
(element && element != events[i][0]) ||
|
|
164
|
+
(event && event != events[i][1]) ||
|
|
165
|
+
(callback && callback != events[i][2])
|
|
166
|
+
) {
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
events[i][0].removeEventListener(events[i][1], events[i][2]);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* @param {Element} element
|
|
176
|
+
*
|
|
177
|
+
* @returns {{top: number, left: number}}
|
|
178
|
+
*/
|
|
179
|
+
function dom_offset (element) {
|
|
180
|
+
var rect = element.getBoundingClientRect();
|
|
181
|
+
return {
|
|
182
|
+
top : rect.top + window.pageYOffset - document.documentElement.clientTop,
|
|
183
|
+
left : rect.left + window.pageXOffset - document.documentElement.clientLeft
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* @param {Element} element
|
|
189
|
+
* @param {string} event
|
|
190
|
+
* @param {Object} [detail=undefined]
|
|
191
|
+
*
|
|
192
|
+
* @return {boolean}
|
|
193
|
+
*/
|
|
194
|
+
function dom_dispatch_event (element, event, detail) {
|
|
195
|
+
var e = document.createEvent('Event');
|
|
196
|
+
if (detail) {
|
|
197
|
+
e.detail = detail;
|
|
198
|
+
}
|
|
199
|
+
e.initEvent('pickmeup-' + event, false, true);
|
|
200
|
+
return element.dispatchEvent(e);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Functions prefixed with `date_` are simple convenient wrappers for various operations with dates
|
|
205
|
+
*/
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* @param {Date} date
|
|
209
|
+
*
|
|
210
|
+
* @returns {number}
|
|
211
|
+
*/
|
|
212
|
+
function date_get_max_days (date) {
|
|
213
|
+
var tmpDate = new Date(date),
|
|
214
|
+
d = 28,
|
|
215
|
+
m = tmpDate.getMonth();
|
|
216
|
+
while (tmpDate.getMonth() == m) {
|
|
217
|
+
++d;
|
|
218
|
+
tmpDate.setDate(d);
|
|
219
|
+
}
|
|
220
|
+
return d - 1;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* @param {Date} date
|
|
225
|
+
* @param {number} number_of_days
|
|
226
|
+
*/
|
|
227
|
+
function date_add_days (date, number_of_days) {
|
|
228
|
+
date.setDate(date.getDate() + number_of_days);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* @param {Date} date
|
|
233
|
+
* @param {number} number_of_months
|
|
234
|
+
*/
|
|
235
|
+
function date_add_months (date, number_of_months) {
|
|
236
|
+
var day = date.getDate();
|
|
237
|
+
date.setDate(1);
|
|
238
|
+
date.setMonth(date.getMonth() + number_of_months);
|
|
239
|
+
date.setDate(Math.min(day, date_get_max_days(date)));
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* @param {Date} date
|
|
244
|
+
* @param {number} number_of_years
|
|
245
|
+
*/
|
|
246
|
+
function date_add_years (date, number_of_years) {
|
|
247
|
+
var day = date.getDate();
|
|
248
|
+
date.setDate(1);
|
|
249
|
+
date.setFullYear(date.getFullYear() + number_of_years);
|
|
250
|
+
date.setDate(Math.min(day, date_get_max_days(date)));
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* @param {Date} date
|
|
255
|
+
*
|
|
256
|
+
* @returns {number}
|
|
257
|
+
*/
|
|
258
|
+
function date_get_day_of_the_year (date) {
|
|
259
|
+
var now = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
|
|
260
|
+
var then = new Date(date.getFullYear(), 0, 0, 0, 0, 0);
|
|
261
|
+
var time = now - then;
|
|
262
|
+
return Math.floor(time / (24 * 60 * 60 * 1000));
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* @param {Element} target
|
|
267
|
+
*/
|
|
268
|
+
function fill (target) {
|
|
269
|
+
var root_element = target.__pickmeup.element,
|
|
270
|
+
options = target.__pickmeup.options,
|
|
271
|
+
current_cal = Math.floor(options.calendars / 2),
|
|
272
|
+
actual_date = options.date,
|
|
273
|
+
current_date = options.current,
|
|
274
|
+
min_date = options.min ? new Date(options.min) : null,
|
|
275
|
+
max_date = options.max ? new Date(options.max) : null,
|
|
276
|
+
local_date,
|
|
277
|
+
header,
|
|
278
|
+
instance,
|
|
279
|
+
shown_date_from,
|
|
280
|
+
shown_date_to,
|
|
281
|
+
tmp_date;
|
|
282
|
+
if (min_date) {
|
|
283
|
+
min_date.setDate(1);
|
|
284
|
+
date_add_months(min_date, 1);
|
|
285
|
+
date_add_days(min_date, -1);
|
|
286
|
+
}
|
|
287
|
+
if (max_date) {
|
|
288
|
+
max_date.setDate(1);
|
|
289
|
+
date_add_months(max_date, 1);
|
|
290
|
+
date_add_days(max_date, -1);
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Remove old content except header navigation
|
|
294
|
+
*/
|
|
295
|
+
dom_remove(dom_query_all(root_element, '.pmu-instance > :not(nav)'));
|
|
296
|
+
/**
|
|
297
|
+
* If several calendars should be shown
|
|
298
|
+
*/
|
|
299
|
+
for (var i = 0; i < options.calendars; i++) {
|
|
300
|
+
local_date = new Date(current_date);
|
|
301
|
+
reset_time(local_date);
|
|
302
|
+
instance = dom_query_all(root_element, '.pmu-instance')[i];
|
|
303
|
+
if (dom_has_class(root_element, 'pmu-view-years')) {
|
|
304
|
+
date_add_years(local_date, (i - current_cal) * 12);
|
|
305
|
+
header = (local_date.getFullYear() - 6) + ' - ' + (local_date.getFullYear() + 5);
|
|
306
|
+
} else if (dom_has_class(root_element, 'pmu-view-months')) {
|
|
307
|
+
date_add_years(local_date, i - current_cal);
|
|
308
|
+
header = local_date.getFullYear();
|
|
309
|
+
} else if (dom_has_class(root_element, 'pmu-view-days')) {
|
|
310
|
+
date_add_months(local_date, i - current_cal);
|
|
311
|
+
header = format_date(local_date, options.title_format, options.locales[options.locale]);
|
|
312
|
+
}
|
|
313
|
+
if (!shown_date_to) {
|
|
314
|
+
if (max_date) {
|
|
315
|
+
// If all dates in this month (months in year or years in years block) are after max option - set next month as current
|
|
316
|
+
// in order not to show calendar with all disabled dates
|
|
317
|
+
tmp_date = new Date(local_date);
|
|
318
|
+
if (options.select_day) {
|
|
319
|
+
date_add_months(tmp_date, options.calendars - 1);
|
|
320
|
+
} else if (options.select_month) {
|
|
321
|
+
date_add_years(tmp_date, options.calendars - 1);
|
|
322
|
+
} else {
|
|
323
|
+
date_add_years(tmp_date, (options.calendars - 1) * 12);
|
|
324
|
+
}
|
|
325
|
+
if (tmp_date > max_date) {
|
|
326
|
+
--i;
|
|
327
|
+
date_add_months(current_date, -1);
|
|
328
|
+
shown_date_to = undefined;
|
|
329
|
+
continue;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
shown_date_to = new Date(local_date);
|
|
334
|
+
if (!shown_date_from) {
|
|
335
|
+
shown_date_from = new Date(local_date);
|
|
336
|
+
// If all dates in this month are before min option - set next month as current in order not to show calendar with all disabled dates
|
|
337
|
+
shown_date_from.setDate(1);
|
|
338
|
+
date_add_months(shown_date_from, 1);
|
|
339
|
+
date_add_days(shown_date_from, -1);
|
|
340
|
+
if (min_date && min_date > shown_date_from) {
|
|
341
|
+
--i;
|
|
342
|
+
date_add_months(current_date, 1);
|
|
343
|
+
shown_date_from = undefined;
|
|
344
|
+
continue;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
dom_query(instance, '.pmu-month').textContent = header;
|
|
348
|
+
var is_year_selected = function (year) {
|
|
349
|
+
return (
|
|
350
|
+
options.mode == 'range' &&
|
|
351
|
+
year >= new Date(actual_date[0]).getFullYear() &&
|
|
352
|
+
year <= new Date(actual_date[1]).getFullYear()
|
|
353
|
+
) ||
|
|
354
|
+
(
|
|
355
|
+
options.mode == 'multiple' &&
|
|
356
|
+
actual_date.reduce(function (prev, current) {
|
|
357
|
+
prev.push(new Date(current).getFullYear());
|
|
358
|
+
return prev;
|
|
359
|
+
}, []).indexOf(year) !== -1
|
|
360
|
+
) ||
|
|
361
|
+
new Date(actual_date).getFullYear() == year;
|
|
362
|
+
};
|
|
363
|
+
var is_months_selected = function (year, month) {
|
|
364
|
+
var first_year = new Date(actual_date[0]).getFullYear(),
|
|
365
|
+
lastyear = new Date(actual_date[1]).getFullYear(),
|
|
366
|
+
first_month = new Date(actual_date[0]).getMonth(),
|
|
367
|
+
last_month = new Date(actual_date[1]).getMonth();
|
|
368
|
+
return (
|
|
369
|
+
(
|
|
370
|
+
options.mode == 'range' &&
|
|
371
|
+
(
|
|
372
|
+
(year > first_year && year < lastyear) ||
|
|
373
|
+
(year > first_year && year == lastyear && month <= last_month) ||
|
|
374
|
+
(year == first_year && year < lastyear && month >= first_month) ||
|
|
375
|
+
(year == first_year && year == lastyear && month >= first_month && month <= last_month)
|
|
376
|
+
)
|
|
377
|
+
) ||
|
|
378
|
+
(
|
|
379
|
+
options.mode == 'multiple' &&
|
|
380
|
+
actual_date.reduce(function (prev, current) {
|
|
381
|
+
current = new Date(current);
|
|
382
|
+
prev.push(current.getFullYear() + '-' + current.getMonth());
|
|
383
|
+
return prev;
|
|
384
|
+
}, []).indexOf(year + '-' + month) !== -1
|
|
385
|
+
) ||
|
|
386
|
+
(
|
|
387
|
+
new Date(actual_date).getFullYear() == year &&
|
|
388
|
+
new Date(actual_date).getMonth() == month
|
|
389
|
+
)
|
|
390
|
+
);
|
|
391
|
+
};
|
|
392
|
+
(function () {
|
|
393
|
+
var years_elements = [],
|
|
394
|
+
start_from_year = local_date.getFullYear() - 6,
|
|
395
|
+
min_year = new Date(options.min).getFullYear(),
|
|
396
|
+
max_year = new Date(options.max).getFullYear(),
|
|
397
|
+
year,
|
|
398
|
+
year_element,
|
|
399
|
+
j;
|
|
400
|
+
for (j = 0; j < 12; ++j) {
|
|
401
|
+
year = start_from_year + j;
|
|
402
|
+
year_element = document.createElement('div');
|
|
403
|
+
year_element.textContent = year;
|
|
404
|
+
year_element.__pickmeup_year = year;
|
|
405
|
+
if (
|
|
406
|
+
(options.min && year < min_year) ||
|
|
407
|
+
(options.max && year > max_year)
|
|
408
|
+
) {
|
|
409
|
+
dom_add_class(year_element, 'pmu-disabled');
|
|
410
|
+
} else if (is_year_selected(year)) {
|
|
411
|
+
dom_add_class(year_element, 'pmu-selected');
|
|
412
|
+
}
|
|
413
|
+
years_elements.push(year_element);
|
|
414
|
+
}
|
|
415
|
+
instance.appendChild(options.instance_content_template(years_elements, 'pmu-years'));
|
|
416
|
+
})();
|
|
417
|
+
(function () {
|
|
418
|
+
var months_elements = [],
|
|
419
|
+
current_year = local_date.getFullYear(),
|
|
420
|
+
min_year = new Date(options.min).getFullYear(),
|
|
421
|
+
min_month = new Date(options.min).getMonth(),
|
|
422
|
+
max_year = new Date(options.max).getFullYear(),
|
|
423
|
+
max_month = new Date(options.max).getMonth(),
|
|
424
|
+
month,
|
|
425
|
+
month_element;
|
|
426
|
+
for (month = 0; month < 12; ++month) {
|
|
427
|
+
month_element = document.createElement('div');
|
|
428
|
+
month_element.textContent = options.locales[options.locale].monthsShort[month];
|
|
429
|
+
month_element.__pickmeup_month = month;
|
|
430
|
+
month_element.__pickmeup_year = current_year;
|
|
431
|
+
if (
|
|
432
|
+
(
|
|
433
|
+
options.min &&
|
|
434
|
+
(
|
|
435
|
+
current_year < min_year ||
|
|
436
|
+
(
|
|
437
|
+
month < min_month && current_year == min_year
|
|
438
|
+
)
|
|
439
|
+
)
|
|
440
|
+
) ||
|
|
441
|
+
(
|
|
442
|
+
options.max &&
|
|
443
|
+
(
|
|
444
|
+
current_year > max_year ||
|
|
445
|
+
(
|
|
446
|
+
month > max_month && current_year >= max_year
|
|
447
|
+
)
|
|
448
|
+
)
|
|
449
|
+
)
|
|
450
|
+
) {
|
|
451
|
+
dom_add_class(month_element, 'pmu-disabled');
|
|
452
|
+
} else if (is_months_selected(current_year, month)) {
|
|
453
|
+
dom_add_class(month_element, 'pmu-selected');
|
|
454
|
+
}
|
|
455
|
+
months_elements.push(month_element);
|
|
456
|
+
}
|
|
457
|
+
instance.appendChild(options.instance_content_template(months_elements, 'pmu-months'));
|
|
458
|
+
})();
|
|
459
|
+
(function () {
|
|
460
|
+
var days_elements = [],
|
|
461
|
+
current_month = local_date.getMonth(),
|
|
462
|
+
today = reset_time(new Date).valueOf(),
|
|
463
|
+
day,
|
|
464
|
+
day_element,
|
|
465
|
+
from_user,
|
|
466
|
+
val,
|
|
467
|
+
disabled,
|
|
468
|
+
selected;
|
|
469
|
+
// Correct first day in calendar taking into account the first day of the week (Sunday or Monday)
|
|
470
|
+
(function () {
|
|
471
|
+
local_date.setDate(1);
|
|
472
|
+
var day = (local_date.getDay() - options.first_day) % 7;
|
|
473
|
+
date_add_days(local_date, -(day + (day < 0 ? 7 : 0)));
|
|
474
|
+
})();
|
|
475
|
+
for (day = 0; day < 42; ++day) {
|
|
476
|
+
day_element = document.createElement('div');
|
|
477
|
+
day_element.textContent = local_date.getDate();
|
|
478
|
+
day_element.__pickmeup_day = local_date.getDate();
|
|
479
|
+
day_element.__pickmeup_month = local_date.getMonth();
|
|
480
|
+
day_element.__pickmeup_year = local_date.getFullYear();
|
|
481
|
+
if (current_month != local_date.getMonth()) {
|
|
482
|
+
dom_add_class(day_element, 'pmu-not-in-month');
|
|
483
|
+
}
|
|
484
|
+
if (local_date.getDay() == 0) {
|
|
485
|
+
dom_add_class(day_element, 'pmu-sunday');
|
|
486
|
+
} else if (local_date.getDay() == 6) {
|
|
487
|
+
dom_add_class(day_element, 'pmu-saturday');
|
|
488
|
+
}
|
|
489
|
+
from_user = options.render(new Date(local_date)) || {};
|
|
490
|
+
// We only reset time for this value in order to deal with Summer/Winter time, but changing `local_date` itself will break days incrementing
|
|
491
|
+
val = reset_time(new Date(local_date)).valueOf();
|
|
492
|
+
disabled =
|
|
493
|
+
(options.min && options.min > local_date) ||
|
|
494
|
+
(options.max && options.max < local_date);
|
|
495
|
+
selected =
|
|
496
|
+
options.date.valueOf() == val ||
|
|
497
|
+
(
|
|
498
|
+
options.date instanceof Array &&
|
|
499
|
+
options.date.reduce(function (prev, date) {
|
|
500
|
+
return prev || val === date.valueOf();
|
|
501
|
+
}, false)
|
|
502
|
+
) ||
|
|
503
|
+
(
|
|
504
|
+
options.mode == 'range' && val >= options.date[0] && val <= options.date[1]
|
|
505
|
+
);
|
|
506
|
+
if (from_user.disabled || (!('disabled' in from_user) && disabled)) {
|
|
507
|
+
dom_add_class(day_element, 'pmu-disabled');
|
|
508
|
+
} else if (from_user.selected || (!('selected' in from_user) && selected)) {
|
|
509
|
+
dom_add_class(day_element, 'pmu-selected');
|
|
510
|
+
}
|
|
511
|
+
if (val == today) {
|
|
512
|
+
dom_add_class(day_element, 'pmu-today');
|
|
513
|
+
}
|
|
514
|
+
if (from_user.class_name) {
|
|
515
|
+
from_user.class_name.split(' ').forEach(
|
|
516
|
+
dom_add_class.bind(day_element, day_element)
|
|
517
|
+
);
|
|
518
|
+
}
|
|
519
|
+
days_elements.push(day_element);
|
|
520
|
+
// Move to the next day
|
|
521
|
+
date_add_days(local_date, 1);
|
|
522
|
+
}
|
|
523
|
+
instance.appendChild(options.instance_content_template(days_elements, 'pmu-days'));
|
|
524
|
+
})();
|
|
525
|
+
}
|
|
526
|
+
shown_date_from.setDate(1);
|
|
527
|
+
shown_date_to.setDate(1);
|
|
528
|
+
date_add_months(shown_date_to, 1);
|
|
529
|
+
date_add_days(shown_date_to, -1);
|
|
530
|
+
var prev = dom_query(root_element, '.pmu-prev'),
|
|
531
|
+
next = dom_query(root_element, '.pmu-next');
|
|
532
|
+
if (prev) {
|
|
533
|
+
prev.style.visibility = options.min && options.min >= shown_date_from ? 'hidden' : 'visible';
|
|
534
|
+
}
|
|
535
|
+
if (next) {
|
|
536
|
+
next.style.visibility = options.max && options.max <= shown_date_to ? 'hidden' : 'visible';
|
|
537
|
+
}
|
|
538
|
+
dom_dispatch_event(target, 'fill');
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
function parse_date (date, options) {
|
|
542
|
+
var format = options.format,
|
|
543
|
+
separator = options.separator,
|
|
544
|
+
locale = options.locales[options.locale],
|
|
545
|
+
i;
|
|
546
|
+
if (date instanceof Date || date instanceof Number) {
|
|
547
|
+
return reset_time(new Date(date));
|
|
548
|
+
} else if (!date) {
|
|
549
|
+
return reset_time(new Date);
|
|
550
|
+
} else if (date instanceof Array) {
|
|
551
|
+
date = date.slice();
|
|
552
|
+
for (i = 0; i < date.length; ++i) {
|
|
553
|
+
date[i] = parse_date(date[i], options);
|
|
554
|
+
}
|
|
555
|
+
return date;
|
|
556
|
+
}
|
|
557
|
+
var splitted_date = date.split(separator);
|
|
558
|
+
if (splitted_date.length > 1) {
|
|
559
|
+
splitted_date.forEach(function (element, index, array) {
|
|
560
|
+
array[index] = parse_date(element.trim(), options);
|
|
561
|
+
});
|
|
562
|
+
return splitted_date;
|
|
563
|
+
}
|
|
564
|
+
separator = [].concat(locale.daysShort, locale.daysMin, locale.days, locale.monthsShort, locale.months);
|
|
565
|
+
separator = separator.map(function (item) {
|
|
566
|
+
return '(' + item + ')';
|
|
567
|
+
});
|
|
568
|
+
separator = new RegExp('[^0-9a-zA-Z' + separator.join('') + ']+');
|
|
569
|
+
var parts = date.split(separator),
|
|
570
|
+
against = format.split(separator),
|
|
571
|
+
d,
|
|
572
|
+
m,
|
|
573
|
+
y,
|
|
574
|
+
h,
|
|
575
|
+
min,
|
|
576
|
+
now = new Date();
|
|
577
|
+
for (i = 0; i < parts.length; i++) {
|
|
578
|
+
switch (against[i]) {
|
|
579
|
+
case 'b':
|
|
580
|
+
m = locale.monthsShort.indexOf(parts[i]);
|
|
581
|
+
break;
|
|
582
|
+
case 'B':
|
|
583
|
+
m = locale.months.indexOf(parts[i]);
|
|
584
|
+
break;
|
|
585
|
+
case 'd':
|
|
586
|
+
case 'e':
|
|
587
|
+
d = parseInt(parts[i], 10);
|
|
588
|
+
break;
|
|
589
|
+
case 'm':
|
|
590
|
+
m = parseInt(parts[i], 10) - 1;
|
|
591
|
+
break;
|
|
592
|
+
case 'Y':
|
|
593
|
+
case 'y':
|
|
594
|
+
y = parseInt(parts[i], 10);
|
|
595
|
+
y += y > 100 ? 0 : (y < 29 ? 2000 : 1900);
|
|
596
|
+
break;
|
|
597
|
+
case 'H':
|
|
598
|
+
case 'I':
|
|
599
|
+
case 'k':
|
|
600
|
+
case 'l':
|
|
601
|
+
h = parseInt(parts[i], 10);
|
|
602
|
+
break;
|
|
603
|
+
case 'P':
|
|
604
|
+
case 'p':
|
|
605
|
+
if (/pm/i.test(parts[i]) && h < 12) {
|
|
606
|
+
h += 12;
|
|
607
|
+
} else if (/am/i.test(parts[i]) && h >= 12) {
|
|
608
|
+
h -= 12;
|
|
609
|
+
}
|
|
610
|
+
break;
|
|
611
|
+
case 'M':
|
|
612
|
+
min = parseInt(parts[i], 10);
|
|
613
|
+
break;
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
var parsed_date = new Date(
|
|
617
|
+
y === undefined ? now.getFullYear() : y,
|
|
618
|
+
m === undefined ? now.getMonth() : m,
|
|
619
|
+
d === undefined ? now.getDate() : d,
|
|
620
|
+
h === undefined ? now.getHours() : h,
|
|
621
|
+
min === undefined ? now.getMinutes() : min,
|
|
622
|
+
0
|
|
623
|
+
);
|
|
624
|
+
if (isNaN(parsed_date * 1)) {
|
|
625
|
+
parsed_date = new Date;
|
|
626
|
+
}
|
|
627
|
+
return reset_time(parsed_date);
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
function reset_time (date) {
|
|
631
|
+
date.setHours(0, 0, 0, 0);
|
|
632
|
+
return date;
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
function format_date (date, format, locale) {
|
|
636
|
+
var m = date.getMonth();
|
|
637
|
+
var d = date.getDate();
|
|
638
|
+
var y = date.getFullYear();
|
|
639
|
+
var w = date.getDay();
|
|
640
|
+
var hr = date.getHours();
|
|
641
|
+
var pm = (hr >= 12);
|
|
642
|
+
var ir = (pm) ? (hr - 12) : hr;
|
|
643
|
+
var dy = date_get_day_of_the_year(date);
|
|
644
|
+
if (ir == 0) {
|
|
645
|
+
ir = 12;
|
|
646
|
+
}
|
|
647
|
+
var min = date.getMinutes();
|
|
648
|
+
var sec = date.getSeconds();
|
|
649
|
+
var parts = format.split(''), part;
|
|
650
|
+
for (var i = 0; i < parts.length; i++) {
|
|
651
|
+
part = parts[i];
|
|
652
|
+
switch (part) {
|
|
653
|
+
case 'a':
|
|
654
|
+
part = locale.daysShort[w];
|
|
655
|
+
break;
|
|
656
|
+
case 'A':
|
|
657
|
+
part = locale.days[w];
|
|
658
|
+
break;
|
|
659
|
+
case 'b':
|
|
660
|
+
part = locale.monthsShort[m];
|
|
661
|
+
break;
|
|
662
|
+
case 'B':
|
|
663
|
+
part = locale.months[m];
|
|
664
|
+
break;
|
|
665
|
+
case 'C':
|
|
666
|
+
part = 1 + Math.floor(y / 100);
|
|
667
|
+
break;
|
|
668
|
+
case 'd':
|
|
669
|
+
part = (d < 10) ? ("0" + d) : d;
|
|
670
|
+
break;
|
|
671
|
+
case 'e':
|
|
672
|
+
part = d;
|
|
673
|
+
break;
|
|
674
|
+
case 'H':
|
|
675
|
+
part = (hr < 10) ? ("0" + hr) : hr;
|
|
676
|
+
break;
|
|
677
|
+
case 'I':
|
|
678
|
+
part = (ir < 10) ? ("0" + ir) : ir;
|
|
679
|
+
break;
|
|
680
|
+
case 'j':
|
|
681
|
+
part = (dy < 100) ? ((dy < 10) ? ("00" + dy) : ("0" + dy)) : dy;
|
|
682
|
+
break;
|
|
683
|
+
case 'k':
|
|
684
|
+
part = hr;
|
|
685
|
+
break;
|
|
686
|
+
case 'l':
|
|
687
|
+
part = ir;
|
|
688
|
+
break;
|
|
689
|
+
case 'm':
|
|
690
|
+
part = (m < 9) ? ("0" + (1 + m)) : (1 + m);
|
|
691
|
+
break;
|
|
692
|
+
case 'M':
|
|
693
|
+
part = (min < 10) ? ("0" + min) : min;
|
|
694
|
+
break;
|
|
695
|
+
case 'p':
|
|
696
|
+
case 'P':
|
|
697
|
+
part = pm ? "PM" : "AM";
|
|
698
|
+
break;
|
|
699
|
+
case 's':
|
|
700
|
+
part = Math.floor(date.getTime() / 1000);
|
|
701
|
+
break;
|
|
702
|
+
case 'S':
|
|
703
|
+
part = (sec < 10) ? ("0" + sec) : sec;
|
|
704
|
+
break;
|
|
705
|
+
case 'u':
|
|
706
|
+
part = w + 1;
|
|
707
|
+
break;
|
|
708
|
+
case 'w':
|
|
709
|
+
part = w;
|
|
710
|
+
break;
|
|
711
|
+
case 'y':
|
|
712
|
+
part = ('' + y).substr(2, 2);
|
|
713
|
+
break;
|
|
714
|
+
case 'Y':
|
|
715
|
+
part = y;
|
|
716
|
+
break;
|
|
717
|
+
}
|
|
718
|
+
parts[i] = part;
|
|
719
|
+
}
|
|
720
|
+
return parts.join('');
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
/**
|
|
724
|
+
* @param {Element} target
|
|
725
|
+
* @param {Date} new_date
|
|
726
|
+
*/
|
|
727
|
+
function update_date (target, new_date) {
|
|
728
|
+
var options = target.__pickmeup.options,
|
|
729
|
+
i;
|
|
730
|
+
reset_time(new_date);
|
|
731
|
+
(function () {
|
|
732
|
+
var new_value;
|
|
733
|
+
switch (options.mode) {
|
|
734
|
+
case 'multiple':
|
|
735
|
+
new_value = new_date.valueOf();
|
|
736
|
+
for (i = 0; i < options.date.length; ++i) {
|
|
737
|
+
if (options.date[i].valueOf() === new_value) {
|
|
738
|
+
options.date.splice(i, 1);
|
|
739
|
+
return;
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
options.date.push(new_date);
|
|
743
|
+
break;
|
|
744
|
+
case 'range':
|
|
745
|
+
if (!options.lastSel) {
|
|
746
|
+
options.date[0] = new_date;
|
|
747
|
+
}
|
|
748
|
+
if (new_date <= options.date[0]) {
|
|
749
|
+
options.date[1] = options.date[0];
|
|
750
|
+
options.date[0] = new_date;
|
|
751
|
+
} else {
|
|
752
|
+
options.date[1] = new_date;
|
|
753
|
+
}
|
|
754
|
+
options.lastSel = !options.lastSel;
|
|
755
|
+
break;
|
|
756
|
+
default:
|
|
757
|
+
options.date = new_date.valueOf();
|
|
758
|
+
break;
|
|
759
|
+
}
|
|
760
|
+
})();
|
|
761
|
+
var prepared_date = prepare_date(options);
|
|
762
|
+
if (dom_matches(target, 'input')) {
|
|
763
|
+
//noinspection JSUndefinedPropertyAssignment
|
|
764
|
+
target.value = options.mode == 'single' ? prepared_date.formatted_date : prepared_date.formatted_date.join(options.separator);
|
|
765
|
+
}
|
|
766
|
+
dom_dispatch_event(target, 'change', prepared_date);
|
|
767
|
+
if (
|
|
768
|
+
!options.flat &&
|
|
769
|
+
options.hide_on_select &&
|
|
770
|
+
(
|
|
771
|
+
options.mode != 'range' || !options.lastSel
|
|
772
|
+
)
|
|
773
|
+
) {
|
|
774
|
+
options.bound.hide();
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
/**
|
|
779
|
+
* @param {Element} target
|
|
780
|
+
* @param {Event} event
|
|
781
|
+
*
|
|
782
|
+
* @returns {boolean}
|
|
783
|
+
*/
|
|
784
|
+
function click (target, event) {
|
|
785
|
+
//noinspection JSValidateTypes
|
|
786
|
+
/**
|
|
787
|
+
* @type {Element}
|
|
788
|
+
*/
|
|
789
|
+
var element = event.target;
|
|
790
|
+
if (!dom_has_class(element, 'pmu-button')) {
|
|
791
|
+
element = dom_closest_parent(element, '.pmu-button');
|
|
792
|
+
}
|
|
793
|
+
if (!dom_has_class(element, 'pmu-button') || dom_has_class(element, 'pmu-disabled')) {
|
|
794
|
+
return false;
|
|
795
|
+
}
|
|
796
|
+
event.preventDefault();
|
|
797
|
+
event.stopPropagation();
|
|
798
|
+
var options = target.__pickmeup.options,
|
|
799
|
+
instance = dom_closest_parent(element, '.pmu-instance'),
|
|
800
|
+
root = instance.parentElement,
|
|
801
|
+
instance_index = dom_query_all(root, '.pmu-instance').indexOf(instance);
|
|
802
|
+
if (dom_matches(element.parentElement, 'nav')) {
|
|
803
|
+
if (dom_has_class(element, 'pmu-month')) {
|
|
804
|
+
date_add_months(options.current, instance_index - Math.floor(options.calendars / 2));
|
|
805
|
+
if (dom_has_class(root, 'pmu-view-years')) {
|
|
806
|
+
// Shift back to current date, otherwise with min value specified may jump on few (tens) years forward
|
|
807
|
+
if (options.mode != 'single') {
|
|
808
|
+
options.current = new Date(options.date[options.date.length - 1]);
|
|
809
|
+
} else {
|
|
810
|
+
options.current = new Date(options.date);
|
|
811
|
+
}
|
|
812
|
+
if (options.select_day) {
|
|
813
|
+
dom_remove_class(root, 'pmu-view-years');
|
|
814
|
+
dom_add_class(root, 'pmu-view-days');
|
|
815
|
+
} else if (options.select_month) {
|
|
816
|
+
dom_remove_class(root, 'pmu-view-years');
|
|
817
|
+
dom_add_class(root, 'pmu-view-months');
|
|
818
|
+
}
|
|
819
|
+
} else if (dom_has_class(root, 'pmu-view-months')) {
|
|
820
|
+
if (options.select_year) {
|
|
821
|
+
dom_remove_class(root, 'pmu-view-months');
|
|
822
|
+
dom_add_class(root, 'pmu-view-years');
|
|
823
|
+
} else if (options.select_day) {
|
|
824
|
+
dom_remove_class(root, 'pmu-view-months');
|
|
825
|
+
dom_add_class(root, 'pmu-view-days');
|
|
826
|
+
}
|
|
827
|
+
} else if (dom_has_class(root, 'pmu-view-days')) {
|
|
828
|
+
if (options.select_month) {
|
|
829
|
+
dom_remove_class(root, 'pmu-view-days');
|
|
830
|
+
dom_add_class(root, 'pmu-view-months');
|
|
831
|
+
} else if (options.select_year) {
|
|
832
|
+
dom_remove_class(root, 'pmu-view-days');
|
|
833
|
+
dom_add_class(root, 'pmu-view-years');
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
} else {
|
|
837
|
+
if (dom_has_class(element, 'pmu-prev')) {
|
|
838
|
+
options.bound.prev(false);
|
|
839
|
+
} else {
|
|
840
|
+
options.bound.next(false);
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
} else {
|
|
844
|
+
if (dom_has_class(root, 'pmu-view-years')) {
|
|
845
|
+
options.current.setFullYear(element.__pickmeup_year);
|
|
846
|
+
if (options.select_month) {
|
|
847
|
+
dom_remove_class(root, 'pmu-view-years');
|
|
848
|
+
dom_add_class(root, 'pmu-view-months');
|
|
849
|
+
} else if (options.select_day) {
|
|
850
|
+
dom_remove_class(root, 'pmu-view-years');
|
|
851
|
+
dom_add_class(root, 'pmu-view-days');
|
|
852
|
+
} else {
|
|
853
|
+
options.bound.update_date(options.current);
|
|
854
|
+
}
|
|
855
|
+
} else if (dom_has_class(root, 'pmu-view-months')) {
|
|
856
|
+
options.current.setMonth(element.__pickmeup_month);
|
|
857
|
+
options.current.setFullYear(element.__pickmeup_year);
|
|
858
|
+
if (options.select_day) {
|
|
859
|
+
dom_remove_class(root, 'pmu-view-months');
|
|
860
|
+
dom_add_class(root, 'pmu-view-days');
|
|
861
|
+
} else {
|
|
862
|
+
options.bound.update_date(options.current);
|
|
863
|
+
}
|
|
864
|
+
// Move current month to the first place (needed for multiple calendars)
|
|
865
|
+
date_add_months(options.current, Math.floor(options.calendars / 2) - instance_index);
|
|
866
|
+
} else {
|
|
867
|
+
var new_date = new Date(options.current);
|
|
868
|
+
new_date.setYear(element.__pickmeup_year);
|
|
869
|
+
new_date.setMonth(element.__pickmeup_month);
|
|
870
|
+
new_date.setDate(element.__pickmeup_day);
|
|
871
|
+
options.bound.update_date(new_date);
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
options.bound.fill();
|
|
875
|
+
return true;
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
function prepare_date (options) {
|
|
879
|
+
var result;
|
|
880
|
+
if (options.mode == 'single') {
|
|
881
|
+
result = new Date(options.date);
|
|
882
|
+
return {
|
|
883
|
+
formatted_date : format_date(result, options.format, options.locales[options.locale]),
|
|
884
|
+
date : result
|
|
885
|
+
};
|
|
886
|
+
} else {
|
|
887
|
+
result = {
|
|
888
|
+
formatted_date : [],
|
|
889
|
+
date : []
|
|
890
|
+
};
|
|
891
|
+
options.date.forEach(function (val) {
|
|
892
|
+
var date = new Date(val);
|
|
893
|
+
result.formatted_date.push(format_date(date, options.format, options.locales[options.locale]));
|
|
894
|
+
result.date.push(date);
|
|
895
|
+
});
|
|
896
|
+
return result;
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
/**
|
|
901
|
+
* @param {Element} target
|
|
902
|
+
* @param {boolean} [force=false]
|
|
903
|
+
*/
|
|
904
|
+
function show (target, force) {
|
|
905
|
+
var root_element = target.__pickmeup.element,
|
|
906
|
+
value;
|
|
907
|
+
if (force || dom_has_class(root_element, 'pmu-hidden')) {
|
|
908
|
+
var options = target.__pickmeup.options,
|
|
909
|
+
position = dom_offset(target),
|
|
910
|
+
viewport = {
|
|
911
|
+
l : window.pageXOffset,
|
|
912
|
+
t : window.pageYOffset,
|
|
913
|
+
w : document.documentElement.clientWidth,
|
|
914
|
+
h : document.documentElement.clientHeight
|
|
915
|
+
},
|
|
916
|
+
top = position.top,
|
|
917
|
+
left = position.left;
|
|
918
|
+
options.bound.fill();
|
|
919
|
+
if (dom_matches(target, 'input')) {
|
|
920
|
+
value = target.value;
|
|
921
|
+
if (value) {
|
|
922
|
+
options.bound.set_date(value);
|
|
923
|
+
}
|
|
924
|
+
dom_on(
|
|
925
|
+
target,
|
|
926
|
+
target,
|
|
927
|
+
'keydown',
|
|
928
|
+
function (e) {
|
|
929
|
+
if (e.which == 9) {
|
|
930
|
+
options.bound.hide();
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
);
|
|
934
|
+
options.lastSel = false;
|
|
935
|
+
}
|
|
936
|
+
if (!dom_dispatch_event(target, 'show')) {
|
|
937
|
+
return;
|
|
938
|
+
}
|
|
939
|
+
if (!options.flat) {
|
|
940
|
+
dom_remove_class(root_element, 'pmu-hidden');
|
|
941
|
+
if (options.position instanceof Function) {
|
|
942
|
+
position = options.position.call(target);
|
|
943
|
+
left = position.left;
|
|
944
|
+
top = position.top;
|
|
945
|
+
} else {
|
|
946
|
+
switch (options.position) {
|
|
947
|
+
case 'top':
|
|
948
|
+
top -= root_element.offsetHeight;
|
|
949
|
+
break;
|
|
950
|
+
case 'left':
|
|
951
|
+
left -= root_element.offsetWidth;
|
|
952
|
+
break;
|
|
953
|
+
case 'right':
|
|
954
|
+
left += target.offsetWidth;
|
|
955
|
+
break;
|
|
956
|
+
case 'bottom':
|
|
957
|
+
top += target.offsetHeight;
|
|
958
|
+
break;
|
|
959
|
+
}
|
|
960
|
+
if (top + root_element.offsetHeight > viewport.t + viewport.h) {
|
|
961
|
+
top = position.top - root_element.offsetHeight;
|
|
962
|
+
}
|
|
963
|
+
if (top < viewport.t) {
|
|
964
|
+
top = position.top + target.offsetHeight;
|
|
965
|
+
}
|
|
966
|
+
if (left + root_element.offsetWidth > viewport.l + viewport.w) {
|
|
967
|
+
left = position.left - root_element.offsetWidth;
|
|
968
|
+
}
|
|
969
|
+
if (left < viewport.l) {
|
|
970
|
+
left = position.left + target.offsetWidth;
|
|
971
|
+
}
|
|
972
|
+
left += 'px';
|
|
973
|
+
top += 'px';
|
|
974
|
+
}
|
|
975
|
+
root_element.style.left = left;
|
|
976
|
+
root_element.style.top = top;
|
|
977
|
+
setTimeout(function () {
|
|
978
|
+
dom_on(target, document.documentElement, 'click', options.bound.hide);
|
|
979
|
+
dom_on(target, window, 'resize', options.bound.forced_show);
|
|
980
|
+
});
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
/**
|
|
986
|
+
* @param {Element} target
|
|
987
|
+
* @param {Event} event
|
|
988
|
+
*/
|
|
989
|
+
function hide (target, event) {
|
|
990
|
+
var root_element = target.__pickmeup.element,
|
|
991
|
+
options = target.__pickmeup.options;
|
|
992
|
+
//noinspection JSBitwiseOperatorUsage,JSCheckFunctionSignatures
|
|
993
|
+
if (
|
|
994
|
+
!event || !event.target || //Called directly
|
|
995
|
+
(
|
|
996
|
+
event.target != target && //Clicked not on element itself
|
|
997
|
+
!(root_element.compareDocumentPosition(event.target) & 16) //And not on its children
|
|
998
|
+
)
|
|
999
|
+
) {
|
|
1000
|
+
if (dom_dispatch_event(target, 'hide')) {
|
|
1001
|
+
dom_add_class(root_element, 'pmu-hidden');
|
|
1002
|
+
dom_off(target, document.documentElement, 'click', options.bound.hide);
|
|
1003
|
+
dom_off(target, window, 'resize', options.bound.forced_show);
|
|
1004
|
+
options.lastSel = false;
|
|
1005
|
+
}
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
/**
|
|
1010
|
+
* @param {Element} target
|
|
1011
|
+
*/
|
|
1012
|
+
function update (target) {
|
|
1013
|
+
var options = target.__pickmeup.options;
|
|
1014
|
+
dom_off(target, document.documentElement, 'click', options.bound.hide);
|
|
1015
|
+
dom_off(target, window, 'resize', options.bound.forced_show);
|
|
1016
|
+
options.bound.forced_show();
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
/**
|
|
1020
|
+
* @param {Element} target
|
|
1021
|
+
*/
|
|
1022
|
+
function clear (target) {
|
|
1023
|
+
var options = target.__pickmeup.options;
|
|
1024
|
+
if (options.mode != 'single') {
|
|
1025
|
+
options.date = [];
|
|
1026
|
+
options.lastSel = false;
|
|
1027
|
+
options.bound.fill();
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1031
|
+
/**
|
|
1032
|
+
* @param {Element} target
|
|
1033
|
+
* @param {boolean} [fill=true]
|
|
1034
|
+
*/
|
|
1035
|
+
function prev (target, fill) {
|
|
1036
|
+
if (typeof fill == 'undefined') {
|
|
1037
|
+
fill = true;
|
|
1038
|
+
}
|
|
1039
|
+
var root_element = target.__pickmeup.element;
|
|
1040
|
+
var options = target.__pickmeup.options;
|
|
1041
|
+
if (dom_has_class(root_element, 'pmu-view-years')) {
|
|
1042
|
+
date_add_years(options.current, -12);
|
|
1043
|
+
} else if (dom_has_class(root_element, 'pmu-view-months')) {
|
|
1044
|
+
date_add_years(options.current, -1);
|
|
1045
|
+
} else if (dom_has_class(root_element, 'pmu-view-days')) {
|
|
1046
|
+
date_add_months(options.current, -1);
|
|
1047
|
+
}
|
|
1048
|
+
if (fill) {
|
|
1049
|
+
options.bound.fill();
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
/**
|
|
1054
|
+
* @param {Element} target
|
|
1055
|
+
* @param {boolean} [fill=true]
|
|
1056
|
+
*/
|
|
1057
|
+
function next (target, fill) {
|
|
1058
|
+
if (typeof fill == 'undefined') {
|
|
1059
|
+
fill = true;
|
|
1060
|
+
}
|
|
1061
|
+
var root_element = target.__pickmeup.element;
|
|
1062
|
+
var options = target.__pickmeup.options;
|
|
1063
|
+
if (dom_has_class(root_element, 'pmu-view-years')) {
|
|
1064
|
+
date_add_years(options.current, 12);
|
|
1065
|
+
} else if (dom_has_class(root_element, 'pmu-view-months')) {
|
|
1066
|
+
date_add_years(options.current, 1);
|
|
1067
|
+
} else if (dom_has_class(root_element, 'pmu-view-days')) {
|
|
1068
|
+
date_add_months(options.current, 1);
|
|
1069
|
+
}
|
|
1070
|
+
if (fill) {
|
|
1071
|
+
options.bound.fill();
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
|
|
1075
|
+
/**
|
|
1076
|
+
* @param {Element} target
|
|
1077
|
+
* @param {boolean} [formatted=true]
|
|
1078
|
+
*/
|
|
1079
|
+
function get_date (target, formatted) {
|
|
1080
|
+
var options = target.__pickmeup.options,
|
|
1081
|
+
prepared_date = prepare_date(options);
|
|
1082
|
+
if (typeof formatted === 'string') {
|
|
1083
|
+
var date = prepared_date.date;
|
|
1084
|
+
if (date instanceof Date) {
|
|
1085
|
+
return format_date(date, formatted, options.locales[options.locale])
|
|
1086
|
+
} else {
|
|
1087
|
+
return date.map(function (value) {
|
|
1088
|
+
return format_date(value, formatted, options.locales[options.locale]);
|
|
1089
|
+
});
|
|
1090
|
+
}
|
|
1091
|
+
} else {
|
|
1092
|
+
return prepared_date[formatted ? 'formatted_date' : 'date'];
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
|
|
1096
|
+
/**
|
|
1097
|
+
* @param {Element} target
|
|
1098
|
+
* @param {(Date|Date[]|number|number[]|string|string[])} date
|
|
1099
|
+
* @param {Date} [current=undefined]
|
|
1100
|
+
*/
|
|
1101
|
+
function set_date (target, date, current) {
|
|
1102
|
+
var options = target.__pickmeup.options,
|
|
1103
|
+
i;
|
|
1104
|
+
if (!(date instanceof Array) || date.length > 0) {
|
|
1105
|
+
options.date = parse_date(date, options);
|
|
1106
|
+
if (options.mode != 'single') {
|
|
1107
|
+
if (options.date instanceof Array) {
|
|
1108
|
+
options.date[0] = options.date[0] || parse_date(new Date, options);
|
|
1109
|
+
if (options.mode == 'range') {
|
|
1110
|
+
options.date[1] = options.date[1] || parse_date(options.date[0], options);
|
|
1111
|
+
}
|
|
1112
|
+
} else {
|
|
1113
|
+
options.date = [options.date];
|
|
1114
|
+
if (options.mode == 'range') {
|
|
1115
|
+
options.date.push(parse_date(options.date[0], options));
|
|
1116
|
+
}
|
|
1117
|
+
}
|
|
1118
|
+
for (i = 0; i < options.date.length; ++i) {
|
|
1119
|
+
options.date[i] = correct_date_outside_of_limit(options.date[i], options.min, options.max);
|
|
1120
|
+
}
|
|
1121
|
+
} else {
|
|
1122
|
+
if (options.date instanceof Array) {
|
|
1123
|
+
options.date = options.date[0];
|
|
1124
|
+
}
|
|
1125
|
+
options.date = correct_date_outside_of_limit(options.date, options.min, options.max);
|
|
1126
|
+
}
|
|
1127
|
+
} else {
|
|
1128
|
+
options.date = [];
|
|
1129
|
+
}
|
|
1130
|
+
if (!options.select_day) {
|
|
1131
|
+
if (options.date instanceof Array) {
|
|
1132
|
+
for (i = 0; i < options.date.length; ++i) {
|
|
1133
|
+
options.date[i].setDate(1);
|
|
1134
|
+
}
|
|
1135
|
+
} else {
|
|
1136
|
+
options.date.setDate(1);
|
|
1137
|
+
}
|
|
1138
|
+
}
|
|
1139
|
+
// Remove duplicates
|
|
1140
|
+
if (options.mode == 'multiple') {
|
|
1141
|
+
for (i = 0; i < options.date.length; ++i) {
|
|
1142
|
+
if (options.date.indexOf(options.date[i]) !== i) {
|
|
1143
|
+
options.date.splice(i, 1);
|
|
1144
|
+
--i;
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
}
|
|
1148
|
+
if (current) {
|
|
1149
|
+
options.current = parse_date(current, options);
|
|
1150
|
+
} else {
|
|
1151
|
+
current = options.mode === 'single' ? options.date : options.date[options.date.length - 1];
|
|
1152
|
+
options.current = current ? new Date(current) : new Date;
|
|
1153
|
+
}
|
|
1154
|
+
options.current.setDate(1);
|
|
1155
|
+
options.bound.fill();
|
|
1156
|
+
if (dom_matches(target, 'input') && options.default_date !== false) {
|
|
1157
|
+
var prepared_date = prepare_date(options),
|
|
1158
|
+
current_value = target.value,
|
|
1159
|
+
new_value = options.mode == 'single' ? prepared_date.formatted_date : prepared_date.formatted_date.join(options.separator);
|
|
1160
|
+
if (!current_value) {
|
|
1161
|
+
dom_dispatch_event(target, 'change', prepared_date);
|
|
1162
|
+
}
|
|
1163
|
+
if (current_value != new_value) {
|
|
1164
|
+
//noinspection JSUndefinedPropertyAssignment
|
|
1165
|
+
target.value = new_value;
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
|
|
1170
|
+
/**
|
|
1171
|
+
* @param {Element} target
|
|
1172
|
+
*/
|
|
1173
|
+
function destroy (target) {
|
|
1174
|
+
var root_element = target.__pickmeup.element;
|
|
1175
|
+
dom_off(target);
|
|
1176
|
+
dom_remove(root_element);
|
|
1177
|
+
delete target.__pickmeup;
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1180
|
+
function correct_date_outside_of_limit (date, min, max) {
|
|
1181
|
+
if (min && min > date) {
|
|
1182
|
+
return new Date(min);
|
|
1183
|
+
} else if (max && max < date) {
|
|
1184
|
+
return new Date(max);
|
|
1185
|
+
}
|
|
1186
|
+
return date;
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
/**
|
|
1190
|
+
* @param {(Element|string)} target
|
|
1191
|
+
* @param {Object} [initial_options={}]
|
|
1192
|
+
*
|
|
1193
|
+
* @return {(Object|null)} Object with useful methods on success, `null` otherwise
|
|
1194
|
+
*/
|
|
1195
|
+
function pickmeup_init (target, initial_options) {
|
|
1196
|
+
if (typeof target == 'string') {
|
|
1197
|
+
target = document.querySelector(target);
|
|
1198
|
+
}
|
|
1199
|
+
if (!target) {
|
|
1200
|
+
return null;
|
|
1201
|
+
}
|
|
1202
|
+
if (!target.__pickmeup) {
|
|
1203
|
+
var i,
|
|
1204
|
+
option,
|
|
1205
|
+
options = {};
|
|
1206
|
+
initial_options = initial_options || {};
|
|
1207
|
+
for (i in pickmeup_init.defaults) {
|
|
1208
|
+
options[i] = i in initial_options ? initial_options[i] : pickmeup_init.defaults[i];
|
|
1209
|
+
}
|
|
1210
|
+
for (i in options) {
|
|
1211
|
+
option = target.getAttribute('data-pmu-' + i);
|
|
1212
|
+
if (option !== null) {
|
|
1213
|
+
options[i] = option;
|
|
1214
|
+
}
|
|
1215
|
+
}
|
|
1216
|
+
// 4 conditional statements in order to account all cases
|
|
1217
|
+
if (options.view == 'days' && !options.select_day) {
|
|
1218
|
+
options.view = 'months';
|
|
1219
|
+
}
|
|
1220
|
+
if (options.view == 'months' && !options.select_month) {
|
|
1221
|
+
options.view = 'years';
|
|
1222
|
+
}
|
|
1223
|
+
if (options.view == 'years' && !options.select_year) {
|
|
1224
|
+
options.view = 'days';
|
|
1225
|
+
}
|
|
1226
|
+
if (options.view == 'days' && !options.select_day) {
|
|
1227
|
+
options.view = 'months';
|
|
1228
|
+
}
|
|
1229
|
+
options.calendars = Math.max(1, parseInt(options.calendars, 10) || 1);
|
|
1230
|
+
options.mode = /single|multiple|range/.test(options.mode) ? options.mode : 'single';
|
|
1231
|
+
if (options.min) {
|
|
1232
|
+
options.min = parse_date(options.min, options);
|
|
1233
|
+
if (!options.select_day) {
|
|
1234
|
+
options.min.setDate(1);
|
|
1235
|
+
}
|
|
1236
|
+
}
|
|
1237
|
+
if (options.max) {
|
|
1238
|
+
options.max = parse_date(options.max, options);
|
|
1239
|
+
if (!options.select_day) {
|
|
1240
|
+
options.max.setDate(1);
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
var element = document.createElement('div');
|
|
1244
|
+
//noinspection JSUndefinedPropertyAssignment
|
|
1245
|
+
target.__pickmeup = {
|
|
1246
|
+
options : options,
|
|
1247
|
+
events : [],
|
|
1248
|
+
element : element
|
|
1249
|
+
};
|
|
1250
|
+
element.__pickmeup_target = target;
|
|
1251
|
+
dom_add_class(element, 'pickmeup');
|
|
1252
|
+
if (options.class_name) {
|
|
1253
|
+
dom_add_class(element, options.class_name);
|
|
1254
|
+
}
|
|
1255
|
+
options.bound = {
|
|
1256
|
+
fill : fill.bind(target, target),
|
|
1257
|
+
update_date : update_date.bind(target, target),
|
|
1258
|
+
click : click.bind(target, target),
|
|
1259
|
+
show : show.bind(target, target),
|
|
1260
|
+
forced_show : show.bind(target, target, true),
|
|
1261
|
+
hide : hide.bind(target, target),
|
|
1262
|
+
update : update.bind(target, target),
|
|
1263
|
+
clear : clear.bind(target, target),
|
|
1264
|
+
prev : prev.bind(target, target),
|
|
1265
|
+
next : next.bind(target, target),
|
|
1266
|
+
get_date : get_date.bind(target, target),
|
|
1267
|
+
set_date : set_date.bind(target, target),
|
|
1268
|
+
destroy : destroy.bind(target, target)
|
|
1269
|
+
};
|
|
1270
|
+
dom_add_class(element, 'pmu-view-' + options.view);
|
|
1271
|
+
var content_template = options.instance_template(options),
|
|
1272
|
+
content = '';
|
|
1273
|
+
for (i = 0; i < options.calendars; ++i) {
|
|
1274
|
+
content += content_template;
|
|
1275
|
+
}
|
|
1276
|
+
element.innerHTML = content;
|
|
1277
|
+
dom_on(target, element, 'click', options.bound.click);
|
|
1278
|
+
dom_on(
|
|
1279
|
+
target,
|
|
1280
|
+
element,
|
|
1281
|
+
'onselectstart' in Element.prototype ? 'selectstart' : 'mousedown',
|
|
1282
|
+
function (e) {
|
|
1283
|
+
e.preventDefault();
|
|
1284
|
+
});
|
|
1285
|
+
if (options.flat) {
|
|
1286
|
+
dom_add_class(element, 'pmu-flat');
|
|
1287
|
+
target.appendChild(element);
|
|
1288
|
+
} else {
|
|
1289
|
+
dom_add_class(element, 'pmu-hidden');
|
|
1290
|
+
document.body.appendChild(element);
|
|
1291
|
+
dom_on(target, target, 'click', show.bind(target, target, false));
|
|
1292
|
+
dom_on(target, target, 'input', options.bound.update);
|
|
1293
|
+
dom_on(target, target, 'change', options.bound.update);
|
|
1294
|
+
}
|
|
1295
|
+
options.bound.set_date(options.date, options.current);
|
|
1296
|
+
}
|
|
1297
|
+
options = target.__pickmeup.options;
|
|
1298
|
+
return {
|
|
1299
|
+
hide : options.bound.hide,
|
|
1300
|
+
show : options.bound.show,
|
|
1301
|
+
clear : options.bound.clear,
|
|
1302
|
+
update : options.bound.update,
|
|
1303
|
+
prev : options.bound.prev,
|
|
1304
|
+
next : options.bound.next,
|
|
1305
|
+
get_date : options.bound.get_date,
|
|
1306
|
+
set_date : options.bound.set_date,
|
|
1307
|
+
destroy : options.bound.destroy
|
|
1308
|
+
}
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
pickmeup_init.defaults = {
|
|
1312
|
+
current : null,
|
|
1313
|
+
date : new Date,
|
|
1314
|
+
default_date : new Date,
|
|
1315
|
+
flat : false,
|
|
1316
|
+
first_day : 1,
|
|
1317
|
+
prev : '◀',
|
|
1318
|
+
next : '▶',
|
|
1319
|
+
mode : 'single',
|
|
1320
|
+
select_year : true,
|
|
1321
|
+
select_month : true,
|
|
1322
|
+
select_day : true,
|
|
1323
|
+
view : 'days',
|
|
1324
|
+
calendars : 1,
|
|
1325
|
+
format : 'd-m-Y',
|
|
1326
|
+
title_format : 'B, Y',
|
|
1327
|
+
position : 'bottom',
|
|
1328
|
+
class_name : '',
|
|
1329
|
+
separator : ' - ',
|
|
1330
|
+
hide_on_select : false,
|
|
1331
|
+
min : null,
|
|
1332
|
+
max : null,
|
|
1333
|
+
render : function () {
|
|
1334
|
+
},
|
|
1335
|
+
locale : 'en',
|
|
1336
|
+
locales : {
|
|
1337
|
+
en : {
|
|
1338
|
+
days : ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
|
|
1339
|
+
daysShort : ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
|
|
1340
|
+
daysMin : ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
|
|
1341
|
+
months : ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
|
|
1342
|
+
monthsShort : ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
|
|
1343
|
+
}
|
|
1344
|
+
},
|
|
1345
|
+
/**
|
|
1346
|
+
* @param {Object} options
|
|
1347
|
+
*
|
|
1348
|
+
* @returns {string}
|
|
1349
|
+
*/
|
|
1350
|
+
instance_template : function (options) {
|
|
1351
|
+
var days_of_week = options.locales[options.locale].daysMin.slice();
|
|
1352
|
+
// If Monday is the first day of the week
|
|
1353
|
+
if (options.first_day) {
|
|
1354
|
+
days_of_week.push(days_of_week.shift());
|
|
1355
|
+
}
|
|
1356
|
+
return '<div class="pmu-instance">' +
|
|
1357
|
+
'<nav>' +
|
|
1358
|
+
'<div class="pmu-prev pmu-button">' + options.prev + '</div>' +
|
|
1359
|
+
'<div class="pmu-month pmu-button"></div>' +
|
|
1360
|
+
'<div class="pmu-next pmu-button">' + options.next + '</div>' +
|
|
1361
|
+
'</nav>' +
|
|
1362
|
+
'<nav class="pmu-day-of-week"><div>' + days_of_week.join('</div><div>') + '</div></nav>' +
|
|
1363
|
+
'</div>';
|
|
1364
|
+
},
|
|
1365
|
+
/**
|
|
1366
|
+
* @param {Element[]} elements
|
|
1367
|
+
* @param {string} container_class_name
|
|
1368
|
+
*
|
|
1369
|
+
* @returns {Element}
|
|
1370
|
+
*/
|
|
1371
|
+
instance_content_template : function (elements, container_class_name) {
|
|
1372
|
+
var root_element = document.createElement('div');
|
|
1373
|
+
dom_add_class(root_element, container_class_name);
|
|
1374
|
+
for (var i = 0; i < elements.length; ++i) {
|
|
1375
|
+
dom_add_class(elements[i], 'pmu-button');
|
|
1376
|
+
root_element.appendChild(elements[i]);
|
|
1377
|
+
}
|
|
1378
|
+
return root_element;
|
|
1379
|
+
}
|
|
1380
|
+
};
|
|
1381
|
+
|
|
1382
|
+
return pickmeup_init;
|
|
1383
|
+
}));
|