tui-calendar-rails 1.12.13.1
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.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +45 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/tui/calendar/rails.rb +10 -0
- data/lib/tui/calendar/rails/version.rb +7 -0
- data/tui-calendar-rails.gemspec +25 -0
- data/vendor/assets/javascripts/tui-calendar.js +4 -0
- data/vendor/assets/javascripts/tui-calendar/tui-calendar.js +26440 -0
- data/vendor/assets/javascripts/tui-code-snippet/tui-code-snippet.js +4358 -0
- data/vendor/assets/javascripts/tui-date-picker/tui-date-picker.js +7417 -0
- data/vendor/assets/javascripts/tui-time-picker/tui-time-picker.js +4057 -0
- data/vendor/assets/stylesheets/tui-calendar.css +5 -0
- data/vendor/assets/stylesheets/tui-calendar/tui-calendar.css +1177 -0
- data/vendor/assets/stylesheets/tui-date-picker/tui-date-picker.css +556 -0
- data/vendor/assets/stylesheets/tui-time-picker/tui-time-picker.css +286 -0
- metadata +90 -0
@@ -0,0 +1,4057 @@
|
|
1
|
+
/*!
|
2
|
+
* TOAST UI Time Picker
|
3
|
+
* @version 2.0.3
|
4
|
+
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
5
|
+
* @license MIT
|
6
|
+
*/
|
7
|
+
(function webpackUniversalModuleDefinition(root, factory) {
|
8
|
+
if(typeof exports === 'object' && typeof module === 'object')
|
9
|
+
module.exports = factory();
|
10
|
+
else if(typeof define === 'function' && define.amd)
|
11
|
+
define([], factory);
|
12
|
+
else if(typeof exports === 'object')
|
13
|
+
exports["TimePicker"] = factory();
|
14
|
+
else
|
15
|
+
root["tui"] = root["tui"] || {}, root["tui"]["TimePicker"] = factory();
|
16
|
+
})(window, function() {
|
17
|
+
return /******/ (function(modules) { // webpackBootstrap
|
18
|
+
/******/ // The module cache
|
19
|
+
/******/ var installedModules = {};
|
20
|
+
/******/
|
21
|
+
/******/ // The require function
|
22
|
+
/******/ function __webpack_require__(moduleId) {
|
23
|
+
/******/
|
24
|
+
/******/ // Check if module is in cache
|
25
|
+
/******/ if(installedModules[moduleId]) {
|
26
|
+
/******/ return installedModules[moduleId].exports;
|
27
|
+
/******/ }
|
28
|
+
/******/ // Create a new module (and put it into the cache)
|
29
|
+
/******/ var module = installedModules[moduleId] = {
|
30
|
+
/******/ i: moduleId,
|
31
|
+
/******/ l: false,
|
32
|
+
/******/ exports: {}
|
33
|
+
/******/ };
|
34
|
+
/******/
|
35
|
+
/******/ // Execute the module function
|
36
|
+
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
37
|
+
/******/
|
38
|
+
/******/ // Flag the module as loaded
|
39
|
+
/******/ module.l = true;
|
40
|
+
/******/
|
41
|
+
/******/ // Return the exports of the module
|
42
|
+
/******/ return module.exports;
|
43
|
+
/******/ }
|
44
|
+
/******/
|
45
|
+
/******/
|
46
|
+
/******/ // expose the modules object (__webpack_modules__)
|
47
|
+
/******/ __webpack_require__.m = modules;
|
48
|
+
/******/
|
49
|
+
/******/ // expose the module cache
|
50
|
+
/******/ __webpack_require__.c = installedModules;
|
51
|
+
/******/
|
52
|
+
/******/ // define getter function for harmony exports
|
53
|
+
/******/ __webpack_require__.d = function(exports, name, getter) {
|
54
|
+
/******/ if(!__webpack_require__.o(exports, name)) {
|
55
|
+
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
|
56
|
+
/******/ }
|
57
|
+
/******/ };
|
58
|
+
/******/
|
59
|
+
/******/ // define __esModule on exports
|
60
|
+
/******/ __webpack_require__.r = function(exports) {
|
61
|
+
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
62
|
+
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
63
|
+
/******/ }
|
64
|
+
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
65
|
+
/******/ };
|
66
|
+
/******/
|
67
|
+
/******/ // create a fake namespace object
|
68
|
+
/******/ // mode & 1: value is a module id, require it
|
69
|
+
/******/ // mode & 2: merge all properties of value into the ns
|
70
|
+
/******/ // mode & 4: return value when already ns object
|
71
|
+
/******/ // mode & 8|1: behave like require
|
72
|
+
/******/ __webpack_require__.t = function(value, mode) {
|
73
|
+
/******/ if(mode & 1) value = __webpack_require__(value);
|
74
|
+
/******/ if(mode & 8) return value;
|
75
|
+
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
|
76
|
+
/******/ var ns = Object.create(null);
|
77
|
+
/******/ __webpack_require__.r(ns);
|
78
|
+
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
|
79
|
+
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
|
80
|
+
/******/ return ns;
|
81
|
+
/******/ };
|
82
|
+
/******/
|
83
|
+
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
84
|
+
/******/ __webpack_require__.n = function(module) {
|
85
|
+
/******/ var getter = module && module.__esModule ?
|
86
|
+
/******/ function getDefault() { return module['default']; } :
|
87
|
+
/******/ function getModuleExports() { return module; };
|
88
|
+
/******/ __webpack_require__.d(getter, 'a', getter);
|
89
|
+
/******/ return getter;
|
90
|
+
/******/ };
|
91
|
+
/******/
|
92
|
+
/******/ // Object.prototype.hasOwnProperty.call
|
93
|
+
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
94
|
+
/******/
|
95
|
+
/******/ // __webpack_public_path__
|
96
|
+
/******/ __webpack_require__.p = "dist";
|
97
|
+
/******/
|
98
|
+
/******/
|
99
|
+
/******/ // Load entry module and return exports
|
100
|
+
/******/ return __webpack_require__(__webpack_require__.s = 20);
|
101
|
+
/******/ })
|
102
|
+
/************************************************************************/
|
103
|
+
/******/ ([
|
104
|
+
/* 0 */
|
105
|
+
/***/ (function(module, exports, __webpack_require__) {
|
106
|
+
|
107
|
+
"use strict";
|
108
|
+
/* eslint-disable complexity */
|
109
|
+
/**
|
110
|
+
* @fileoverview Returns the first index at which a given element can be found in the array.
|
111
|
+
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
112
|
+
*/
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
var isArray = __webpack_require__(2);
|
117
|
+
|
118
|
+
/**
|
119
|
+
* @module array
|
120
|
+
*/
|
121
|
+
|
122
|
+
/**
|
123
|
+
* Returns the first index at which a given element can be found in the array
|
124
|
+
* from start index(default 0), or -1 if it is not present.
|
125
|
+
* It compares searchElement to elements of the Array using strict equality
|
126
|
+
* (the same method used by the ===, or triple-equals, operator).
|
127
|
+
* @param {*} searchElement Element to locate in the array
|
128
|
+
* @param {Array} array Array that will be traversed.
|
129
|
+
* @param {number} startIndex Start index in array for searching (default 0)
|
130
|
+
* @returns {number} the First index at which a given element, or -1 if it is not present
|
131
|
+
* @memberof module:array
|
132
|
+
* @example
|
133
|
+
* var inArray = require('tui-code-snippet/array/inArray'); // node, commonjs
|
134
|
+
*
|
135
|
+
* var arr = ['one', 'two', 'three', 'four'];
|
136
|
+
* var idx1 = inArray('one', arr, 3); // -1
|
137
|
+
* var idx2 = inArray('one', arr); // 0
|
138
|
+
*/
|
139
|
+
function inArray(searchElement, array, startIndex) {
|
140
|
+
var i;
|
141
|
+
var length;
|
142
|
+
startIndex = startIndex || 0;
|
143
|
+
|
144
|
+
if (!isArray(array)) {
|
145
|
+
return -1;
|
146
|
+
}
|
147
|
+
|
148
|
+
if (Array.prototype.indexOf) {
|
149
|
+
return Array.prototype.indexOf.call(array, searchElement, startIndex);
|
150
|
+
}
|
151
|
+
|
152
|
+
length = array.length;
|
153
|
+
for (i = startIndex; startIndex >= 0 && i < length; i += 1) {
|
154
|
+
if (array[i] === searchElement) {
|
155
|
+
return i;
|
156
|
+
}
|
157
|
+
}
|
158
|
+
|
159
|
+
return -1;
|
160
|
+
}
|
161
|
+
|
162
|
+
module.exports = inArray;
|
163
|
+
|
164
|
+
|
165
|
+
/***/ }),
|
166
|
+
/* 1 */
|
167
|
+
/***/ (function(module, exports, __webpack_require__) {
|
168
|
+
|
169
|
+
"use strict";
|
170
|
+
/**
|
171
|
+
* @fileoverview Extend the target object from other objects.
|
172
|
+
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
173
|
+
*/
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
/**
|
178
|
+
* @module object
|
179
|
+
*/
|
180
|
+
|
181
|
+
/**
|
182
|
+
* Extend the target object from other objects.
|
183
|
+
* @param {object} target - Object that will be extended
|
184
|
+
* @param {...object} objects - Objects as sources
|
185
|
+
* @returns {object} Extended object
|
186
|
+
* @memberof module:object
|
187
|
+
*/
|
188
|
+
function extend(target, objects) { // eslint-disable-line no-unused-vars
|
189
|
+
var hasOwnProp = Object.prototype.hasOwnProperty;
|
190
|
+
var source, prop, i, len;
|
191
|
+
|
192
|
+
for (i = 1, len = arguments.length; i < len; i += 1) {
|
193
|
+
source = arguments[i];
|
194
|
+
for (prop in source) {
|
195
|
+
if (hasOwnProp.call(source, prop)) {
|
196
|
+
target[prop] = source[prop];
|
197
|
+
}
|
198
|
+
}
|
199
|
+
}
|
200
|
+
|
201
|
+
return target;
|
202
|
+
}
|
203
|
+
|
204
|
+
module.exports = extend;
|
205
|
+
|
206
|
+
|
207
|
+
/***/ }),
|
208
|
+
/* 2 */
|
209
|
+
/***/ (function(module, exports, __webpack_require__) {
|
210
|
+
|
211
|
+
"use strict";
|
212
|
+
/**
|
213
|
+
* @fileoverview Check whether the given variable is an instance of Array or not.
|
214
|
+
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
215
|
+
*/
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
/**
|
220
|
+
* Check whether the given variable is an instance of Array or not.
|
221
|
+
* If the given variable is an instance of Array, return true.
|
222
|
+
* @param {*} obj - Target for checking
|
223
|
+
* @returns {boolean} Is array instance?
|
224
|
+
* @memberof module:type
|
225
|
+
*/
|
226
|
+
function isArray(obj) {
|
227
|
+
return obj instanceof Array;
|
228
|
+
}
|
229
|
+
|
230
|
+
module.exports = isArray;
|
231
|
+
|
232
|
+
|
233
|
+
/***/ }),
|
234
|
+
/* 3 */
|
235
|
+
/***/ (function(module, exports, __webpack_require__) {
|
236
|
+
|
237
|
+
"use strict";
|
238
|
+
/**
|
239
|
+
* @fileoverview Execute the provided callback once for each element present in the array(or Array-like object) in ascending order.
|
240
|
+
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
241
|
+
*/
|
242
|
+
|
243
|
+
|
244
|
+
|
245
|
+
/**
|
246
|
+
* Execute the provided callback once for each element present
|
247
|
+
* in the array(or Array-like object) in ascending order.
|
248
|
+
* If the callback function returns false, the loop will be stopped.
|
249
|
+
* Callback function(iteratee) is invoked with three arguments:
|
250
|
+
* 1) The value of the element
|
251
|
+
* 2) The index of the element
|
252
|
+
* 3) The array(or Array-like object) being traversed
|
253
|
+
* @param {Array|Arguments|NodeList} arr The array(or Array-like object) that will be traversed
|
254
|
+
* @param {function} iteratee Callback function
|
255
|
+
* @param {Object} [context] Context(this) of callback function
|
256
|
+
* @memberof module:collection
|
257
|
+
* @example
|
258
|
+
* var forEachArray = require('tui-code-snippet/collection/forEachArray'); // node, commonjs
|
259
|
+
*
|
260
|
+
* var sum = 0;
|
261
|
+
*
|
262
|
+
* forEachArray([1,2,3], function(value){
|
263
|
+
* sum += value;
|
264
|
+
* });
|
265
|
+
* alert(sum); // 6
|
266
|
+
*/
|
267
|
+
function forEachArray(arr, iteratee, context) {
|
268
|
+
var index = 0;
|
269
|
+
var len = arr.length;
|
270
|
+
|
271
|
+
context = context || null;
|
272
|
+
|
273
|
+
for (; index < len; index += 1) {
|
274
|
+
if (iteratee.call(context, arr[index], index, arr) === false) {
|
275
|
+
break;
|
276
|
+
}
|
277
|
+
}
|
278
|
+
}
|
279
|
+
|
280
|
+
module.exports = forEachArray;
|
281
|
+
|
282
|
+
|
283
|
+
/***/ }),
|
284
|
+
/* 4 */
|
285
|
+
/***/ (function(module, exports, __webpack_require__) {
|
286
|
+
|
287
|
+
"use strict";
|
288
|
+
/**
|
289
|
+
* @fileoverview Execute the provided callback once for each property of object(or element of array) which actually exist.
|
290
|
+
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
291
|
+
*/
|
292
|
+
|
293
|
+
|
294
|
+
|
295
|
+
var isArray = __webpack_require__(2);
|
296
|
+
var forEachArray = __webpack_require__(3);
|
297
|
+
var forEachOwnProperties = __webpack_require__(16);
|
298
|
+
|
299
|
+
/**
|
300
|
+
* @module collection
|
301
|
+
*/
|
302
|
+
|
303
|
+
/**
|
304
|
+
* Execute the provided callback once for each property of object(or element of array) which actually exist.
|
305
|
+
* If the object is Array-like object(ex-arguments object), It needs to transform to Array.(see 'ex2' of example).
|
306
|
+
* If the callback function returns false, the loop will be stopped.
|
307
|
+
* Callback function(iteratee) is invoked with three arguments:
|
308
|
+
* 1) The value of the property(or The value of the element)
|
309
|
+
* 2) The name of the property(or The index of the element)
|
310
|
+
* 3) The object being traversed
|
311
|
+
* @param {Object} obj The object that will be traversed
|
312
|
+
* @param {function} iteratee Callback function
|
313
|
+
* @param {Object} [context] Context(this) of callback function
|
314
|
+
* @memberof module:collection
|
315
|
+
* @example
|
316
|
+
* var forEach = require('tui-code-snippet/collection/forEach'); // node, commonjs
|
317
|
+
*
|
318
|
+
* var sum = 0;
|
319
|
+
*
|
320
|
+
* forEach([1,2,3], function(value){
|
321
|
+
* sum += value;
|
322
|
+
* });
|
323
|
+
* alert(sum); // 6
|
324
|
+
*
|
325
|
+
* // In case of Array-like object
|
326
|
+
* var array = Array.prototype.slice.call(arrayLike); // change to array
|
327
|
+
* forEach(array, function(value){
|
328
|
+
* sum += value;
|
329
|
+
* });
|
330
|
+
*/
|
331
|
+
function forEach(obj, iteratee, context) {
|
332
|
+
if (isArray(obj)) {
|
333
|
+
forEachArray(obj, iteratee, context);
|
334
|
+
} else {
|
335
|
+
forEachOwnProperties(obj, iteratee, context);
|
336
|
+
}
|
337
|
+
}
|
338
|
+
|
339
|
+
module.exports = forEach;
|
340
|
+
|
341
|
+
|
342
|
+
/***/ }),
|
343
|
+
/* 5 */
|
344
|
+
/***/ (function(module, exports, __webpack_require__) {
|
345
|
+
|
346
|
+
"use strict";
|
347
|
+
/**
|
348
|
+
* @fileoverview Check whether the given variable is undefined or not.
|
349
|
+
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
350
|
+
*/
|
351
|
+
|
352
|
+
|
353
|
+
|
354
|
+
/**
|
355
|
+
* Check whether the given variable is undefined or not.
|
356
|
+
* If the given variable is undefined, returns true.
|
357
|
+
* @param {*} obj - Target for checking
|
358
|
+
* @returns {boolean} Is undefined?
|
359
|
+
* @memberof module:type
|
360
|
+
*/
|
361
|
+
function isUndefined(obj) {
|
362
|
+
return obj === undefined; // eslint-disable-line no-undefined
|
363
|
+
}
|
364
|
+
|
365
|
+
module.exports = isUndefined;
|
366
|
+
|
367
|
+
|
368
|
+
/***/ }),
|
369
|
+
/* 6 */
|
370
|
+
/***/ (function(module, exports, __webpack_require__) {
|
371
|
+
|
372
|
+
"use strict";
|
373
|
+
/**
|
374
|
+
* @fileoverview Check whether the given variable is a string or not.
|
375
|
+
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
376
|
+
*/
|
377
|
+
|
378
|
+
|
379
|
+
|
380
|
+
/**
|
381
|
+
* Check whether the given variable is a string or not.
|
382
|
+
* If the given variable is a string, return true.
|
383
|
+
* @param {*} obj - Target for checking
|
384
|
+
* @returns {boolean} Is string?
|
385
|
+
* @memberof module:type
|
386
|
+
*/
|
387
|
+
function isString(obj) {
|
388
|
+
return typeof obj === 'string' || obj instanceof String;
|
389
|
+
}
|
390
|
+
|
391
|
+
module.exports = isString;
|
392
|
+
|
393
|
+
|
394
|
+
/***/ }),
|
395
|
+
/* 7 */
|
396
|
+
/***/ (function(module, exports, __webpack_require__) {
|
397
|
+
|
398
|
+
"use strict";
|
399
|
+
/**
|
400
|
+
* @fileoverview Convert text by binding expressions with context.
|
401
|
+
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
402
|
+
*/
|
403
|
+
|
404
|
+
|
405
|
+
|
406
|
+
var inArray = __webpack_require__(0);
|
407
|
+
var forEach = __webpack_require__(4);
|
408
|
+
var isArray = __webpack_require__(2);
|
409
|
+
var isString = __webpack_require__(6);
|
410
|
+
var extend = __webpack_require__(1);
|
411
|
+
|
412
|
+
// IE8 does not support capture groups.
|
413
|
+
var EXPRESSION_REGEXP = /{{\s?|\s?}}/g;
|
414
|
+
var BRACKET_NOTATION_REGEXP = /^[a-zA-Z0-9_@]+\[[a-zA-Z0-9_@"']+\]$/;
|
415
|
+
var BRACKET_REGEXP = /\[\s?|\s?\]/;
|
416
|
+
var DOT_NOTATION_REGEXP = /^[a-zA-Z_]+\.[a-zA-Z_]+$/;
|
417
|
+
var DOT_REGEXP = /\./;
|
418
|
+
var STRING_NOTATION_REGEXP = /^["']\w+["']$/;
|
419
|
+
var STRING_REGEXP = /"|'/g;
|
420
|
+
var NUMBER_REGEXP = /^-?\d+\.?\d*$/;
|
421
|
+
|
422
|
+
var EXPRESSION_INTERVAL = 2;
|
423
|
+
|
424
|
+
var BLOCK_HELPERS = {
|
425
|
+
'if': handleIf,
|
426
|
+
'each': handleEach,
|
427
|
+
'with': handleWith
|
428
|
+
};
|
429
|
+
|
430
|
+
var isValidSplit = 'a'.split(/a/).length === 3;
|
431
|
+
|
432
|
+
/**
|
433
|
+
* Split by RegExp. (Polyfill for IE8)
|
434
|
+
* @param {string} text - text to be splitted\
|
435
|
+
* @param {RegExp} regexp - regular expression
|
436
|
+
* @returns {Array.<string>}
|
437
|
+
*/
|
438
|
+
var splitByRegExp = (function() {
|
439
|
+
if (isValidSplit) {
|
440
|
+
return function(text, regexp) {
|
441
|
+
return text.split(regexp);
|
442
|
+
};
|
443
|
+
}
|
444
|
+
|
445
|
+
return function(text, regexp) {
|
446
|
+
var result = [];
|
447
|
+
var prevIndex = 0;
|
448
|
+
var match, index;
|
449
|
+
|
450
|
+
if (!regexp.global) {
|
451
|
+
regexp = new RegExp(regexp, 'g');
|
452
|
+
}
|
453
|
+
|
454
|
+
match = regexp.exec(text);
|
455
|
+
while (match !== null) {
|
456
|
+
index = match.index;
|
457
|
+
result.push(text.slice(prevIndex, index));
|
458
|
+
|
459
|
+
prevIndex = index + match[0].length;
|
460
|
+
match = regexp.exec(text);
|
461
|
+
}
|
462
|
+
result.push(text.slice(prevIndex));
|
463
|
+
|
464
|
+
return result;
|
465
|
+
};
|
466
|
+
})();
|
467
|
+
|
468
|
+
/**
|
469
|
+
* Find value in the context by an expression.
|
470
|
+
* @param {string} exp - an expression
|
471
|
+
* @param {object} context - context
|
472
|
+
* @returns {*}
|
473
|
+
* @private
|
474
|
+
*/
|
475
|
+
// eslint-disable-next-line complexity
|
476
|
+
function getValueFromContext(exp, context) {
|
477
|
+
var splitedExps;
|
478
|
+
var value = context[exp];
|
479
|
+
|
480
|
+
if (exp === 'true') {
|
481
|
+
value = true;
|
482
|
+
} else if (exp === 'false') {
|
483
|
+
value = false;
|
484
|
+
} else if (STRING_NOTATION_REGEXP.test(exp)) {
|
485
|
+
value = exp.replace(STRING_REGEXP, '');
|
486
|
+
} else if (BRACKET_NOTATION_REGEXP.test(exp)) {
|
487
|
+
splitedExps = exp.split(BRACKET_REGEXP);
|
488
|
+
value = getValueFromContext(splitedExps[0], context)[getValueFromContext(splitedExps[1], context)];
|
489
|
+
} else if (DOT_NOTATION_REGEXP.test(exp)) {
|
490
|
+
splitedExps = exp.split(DOT_REGEXP);
|
491
|
+
value = getValueFromContext(splitedExps[0], context)[splitedExps[1]];
|
492
|
+
} else if (NUMBER_REGEXP.test(exp)) {
|
493
|
+
value = parseFloat(exp);
|
494
|
+
}
|
495
|
+
|
496
|
+
return value;
|
497
|
+
}
|
498
|
+
|
499
|
+
/**
|
500
|
+
* Extract elseif and else expressions.
|
501
|
+
* @param {Array.<string>} ifExps - args of if expression
|
502
|
+
* @param {Array.<string>} sourcesInsideBlock - sources inside if block
|
503
|
+
* @returns {object} - exps: expressions of if, elseif, and else / sourcesInsideIf: sources inside if, elseif, and else block.
|
504
|
+
* @private
|
505
|
+
*/
|
506
|
+
function extractElseif(ifExps, sourcesInsideBlock) {
|
507
|
+
var exps = [ifExps];
|
508
|
+
var sourcesInsideIf = [];
|
509
|
+
var otherIfCount = 0;
|
510
|
+
var start = 0;
|
511
|
+
|
512
|
+
// eslint-disable-next-line complexity
|
513
|
+
forEach(sourcesInsideBlock, function(source, index) {
|
514
|
+
if (source.indexOf('if') === 0) {
|
515
|
+
otherIfCount += 1;
|
516
|
+
} else if (source === '/if') {
|
517
|
+
otherIfCount -= 1;
|
518
|
+
} else if (!otherIfCount && (source.indexOf('elseif') === 0 || source === 'else')) {
|
519
|
+
exps.push(source === 'else' ? ['true'] : source.split(' ').slice(1));
|
520
|
+
sourcesInsideIf.push(sourcesInsideBlock.slice(start, index));
|
521
|
+
start = index + 1;
|
522
|
+
}
|
523
|
+
});
|
524
|
+
|
525
|
+
sourcesInsideIf.push(sourcesInsideBlock.slice(start));
|
526
|
+
|
527
|
+
return {
|
528
|
+
exps: exps,
|
529
|
+
sourcesInsideIf: sourcesInsideIf
|
530
|
+
};
|
531
|
+
}
|
532
|
+
|
533
|
+
/**
|
534
|
+
* Helper function for "if".
|
535
|
+
* @param {Array.<string>} exps - array of expressions split by spaces
|
536
|
+
* @param {Array.<string>} sourcesInsideBlock - array of sources inside the if block
|
537
|
+
* @param {object} context - context
|
538
|
+
* @returns {string}
|
539
|
+
* @private
|
540
|
+
*/
|
541
|
+
function handleIf(exps, sourcesInsideBlock, context) {
|
542
|
+
var analyzed = extractElseif(exps, sourcesInsideBlock);
|
543
|
+
var result = false;
|
544
|
+
var compiledSource = '';
|
545
|
+
|
546
|
+
forEach(analyzed.exps, function(exp, index) {
|
547
|
+
result = handleExpression(exp, context);
|
548
|
+
if (result) {
|
549
|
+
compiledSource = compile(analyzed.sourcesInsideIf[index], context);
|
550
|
+
}
|
551
|
+
|
552
|
+
return !result;
|
553
|
+
});
|
554
|
+
|
555
|
+
return compiledSource;
|
556
|
+
}
|
557
|
+
|
558
|
+
/**
|
559
|
+
* Helper function for "each".
|
560
|
+
* @param {Array.<string>} exps - array of expressions split by spaces
|
561
|
+
* @param {Array.<string>} sourcesInsideBlock - array of sources inside the each block
|
562
|
+
* @param {object} context - context
|
563
|
+
* @returns {string}
|
564
|
+
* @private
|
565
|
+
*/
|
566
|
+
function handleEach(exps, sourcesInsideBlock, context) {
|
567
|
+
var collection = handleExpression(exps, context);
|
568
|
+
var additionalKey = isArray(collection) ? '@index' : '@key';
|
569
|
+
var additionalContext = {};
|
570
|
+
var result = '';
|
571
|
+
|
572
|
+
forEach(collection, function(item, key) {
|
573
|
+
additionalContext[additionalKey] = key;
|
574
|
+
additionalContext['@this'] = item;
|
575
|
+
extend(context, additionalContext);
|
576
|
+
|
577
|
+
result += compile(sourcesInsideBlock.slice(), context);
|
578
|
+
});
|
579
|
+
|
580
|
+
return result;
|
581
|
+
}
|
582
|
+
|
583
|
+
/**
|
584
|
+
* Helper function for "with ... as"
|
585
|
+
* @param {Array.<string>} exps - array of expressions split by spaces
|
586
|
+
* @param {Array.<string>} sourcesInsideBlock - array of sources inside the with block
|
587
|
+
* @param {object} context - context
|
588
|
+
* @returns {string}
|
589
|
+
* @private
|
590
|
+
*/
|
591
|
+
function handleWith(exps, sourcesInsideBlock, context) {
|
592
|
+
var asIndex = inArray('as', exps);
|
593
|
+
var alias = exps[asIndex + 1];
|
594
|
+
var result = handleExpression(exps.slice(0, asIndex), context);
|
595
|
+
|
596
|
+
var additionalContext = {};
|
597
|
+
additionalContext[alias] = result;
|
598
|
+
|
599
|
+
return compile(sourcesInsideBlock, extend(context, additionalContext)) || '';
|
600
|
+
}
|
601
|
+
|
602
|
+
/**
|
603
|
+
* Extract sources inside block in place.
|
604
|
+
* @param {Array.<string>} sources - array of sources
|
605
|
+
* @param {number} start - index of start block
|
606
|
+
* @param {number} end - index of end block
|
607
|
+
* @returns {Array.<string>}
|
608
|
+
* @private
|
609
|
+
*/
|
610
|
+
function extractSourcesInsideBlock(sources, start, end) {
|
611
|
+
var sourcesInsideBlock = sources.splice(start + 1, end - start);
|
612
|
+
sourcesInsideBlock.pop();
|
613
|
+
|
614
|
+
return sourcesInsideBlock;
|
615
|
+
}
|
616
|
+
|
617
|
+
/**
|
618
|
+
* Handle block helper function
|
619
|
+
* @param {string} helperKeyword - helper keyword (ex. if, each, with)
|
620
|
+
* @param {Array.<string>} sourcesToEnd - array of sources after the starting block
|
621
|
+
* @param {object} context - context
|
622
|
+
* @returns {Array.<string>}
|
623
|
+
* @private
|
624
|
+
*/
|
625
|
+
function handleBlockHelper(helperKeyword, sourcesToEnd, context) {
|
626
|
+
var executeBlockHelper = BLOCK_HELPERS[helperKeyword];
|
627
|
+
var helperCount = 1;
|
628
|
+
var startBlockIndex = 0;
|
629
|
+
var endBlockIndex;
|
630
|
+
var index = startBlockIndex + EXPRESSION_INTERVAL;
|
631
|
+
var expression = sourcesToEnd[index];
|
632
|
+
|
633
|
+
while (helperCount && isString(expression)) {
|
634
|
+
if (expression.indexOf(helperKeyword) === 0) {
|
635
|
+
helperCount += 1;
|
636
|
+
} else if (expression.indexOf('/' + helperKeyword) === 0) {
|
637
|
+
helperCount -= 1;
|
638
|
+
endBlockIndex = index;
|
639
|
+
}
|
640
|
+
|
641
|
+
index += EXPRESSION_INTERVAL;
|
642
|
+
expression = sourcesToEnd[index];
|
643
|
+
}
|
644
|
+
|
645
|
+
if (helperCount) {
|
646
|
+
throw Error(helperKeyword + ' needs {{/' + helperKeyword + '}} expression.');
|
647
|
+
}
|
648
|
+
|
649
|
+
sourcesToEnd[startBlockIndex] = executeBlockHelper(
|
650
|
+
sourcesToEnd[startBlockIndex].split(' ').slice(1),
|
651
|
+
extractSourcesInsideBlock(sourcesToEnd, startBlockIndex, endBlockIndex),
|
652
|
+
context
|
653
|
+
);
|
654
|
+
|
655
|
+
return sourcesToEnd;
|
656
|
+
}
|
657
|
+
|
658
|
+
/**
|
659
|
+
* Helper function for "custom helper".
|
660
|
+
* If helper is not a function, return helper itself.
|
661
|
+
* @param {Array.<string>} exps - array of expressions split by spaces (first element: helper)
|
662
|
+
* @param {object} context - context
|
663
|
+
* @returns {string}
|
664
|
+
* @private
|
665
|
+
*/
|
666
|
+
function handleExpression(exps, context) {
|
667
|
+
var result = getValueFromContext(exps[0], context);
|
668
|
+
|
669
|
+
if (result instanceof Function) {
|
670
|
+
return executeFunction(result, exps.slice(1), context);
|
671
|
+
}
|
672
|
+
|
673
|
+
return result;
|
674
|
+
}
|
675
|
+
|
676
|
+
/**
|
677
|
+
* Execute a helper function.
|
678
|
+
* @param {Function} helper - helper function
|
679
|
+
* @param {Array.<string>} argExps - expressions of arguments
|
680
|
+
* @param {object} context - context
|
681
|
+
* @returns {string} - result of executing the function with arguments
|
682
|
+
* @private
|
683
|
+
*/
|
684
|
+
function executeFunction(helper, argExps, context) {
|
685
|
+
var args = [];
|
686
|
+
forEach(argExps, function(exp) {
|
687
|
+
args.push(getValueFromContext(exp, context));
|
688
|
+
});
|
689
|
+
|
690
|
+
return helper.apply(null, args);
|
691
|
+
}
|
692
|
+
|
693
|
+
/**
|
694
|
+
* Get a result of compiling an expression with the context.
|
695
|
+
* @param {Array.<string>} sources - array of sources split by regexp of expression.
|
696
|
+
* @param {object} context - context
|
697
|
+
* @returns {Array.<string>} - array of sources that bind with its context
|
698
|
+
* @private
|
699
|
+
*/
|
700
|
+
function compile(sources, context) {
|
701
|
+
var index = 1;
|
702
|
+
var expression = sources[index];
|
703
|
+
var exps, firstExp, result;
|
704
|
+
|
705
|
+
while (isString(expression)) {
|
706
|
+
exps = expression.split(' ');
|
707
|
+
firstExp = exps[0];
|
708
|
+
|
709
|
+
if (BLOCK_HELPERS[firstExp]) {
|
710
|
+
result = handleBlockHelper(firstExp, sources.splice(index, sources.length - index), context);
|
711
|
+
sources = sources.concat(result);
|
712
|
+
} else {
|
713
|
+
sources[index] = handleExpression(exps, context);
|
714
|
+
}
|
715
|
+
|
716
|
+
index += EXPRESSION_INTERVAL;
|
717
|
+
expression = sources[index];
|
718
|
+
}
|
719
|
+
|
720
|
+
return sources.join('');
|
721
|
+
}
|
722
|
+
|
723
|
+
/**
|
724
|
+
* Convert text by binding expressions with context.
|
725
|
+
* <br>
|
726
|
+
* If expression exists in the context, it will be replaced.
|
727
|
+
* ex) '{{title}}' with context {title: 'Hello!'} is converted to 'Hello!'.
|
728
|
+
* An array or object can be accessed using bracket and dot notation.
|
729
|
+
* ex) '{{odds\[2\]}}' with context {odds: \[1, 3, 5\]} is converted to '5'.
|
730
|
+
* ex) '{{evens\[first\]}}' with context {evens: \[2, 4\], first: 0} is converted to '2'.
|
731
|
+
* ex) '{{project\["name"\]}}' and '{{project.name}}' with context {project: {name: 'CodeSnippet'}} is converted to 'CodeSnippet'.
|
732
|
+
* <br>
|
733
|
+
* If replaced expression is a function, next expressions will be arguments of the function.
|
734
|
+
* ex) '{{add 1 2}}' with context {add: function(a, b) {return a + b;}} is converted to '3'.
|
735
|
+
* <br>
|
736
|
+
* It has 3 predefined block helpers '{{helper ...}} ... {{/helper}}': 'if', 'each', 'with ... as ...'.
|
737
|
+
* 1) 'if' evaluates conditional statements. It can use with 'elseif' and 'else'.
|
738
|
+
* 2) 'each' iterates an array or object. It provides '@index'(array), '@key'(object), and '@this'(current element).
|
739
|
+
* 3) 'with ... as ...' provides an alias.
|
740
|
+
* @param {string} text - text with expressions
|
741
|
+
* @param {object} context - context
|
742
|
+
* @returns {string} - text that bind with its context
|
743
|
+
* @memberof module:domUtil
|
744
|
+
* @example
|
745
|
+
* var template = require('tui-code-snippet/domUtil/template');
|
746
|
+
*
|
747
|
+
* var source =
|
748
|
+
* '<h1>'
|
749
|
+
* + '{{if isValidNumber title}}'
|
750
|
+
* + '{{title}}th'
|
751
|
+
* + '{{elseif isValidDate title}}'
|
752
|
+
* + 'Date: {{title}}'
|
753
|
+
* + '{{/if}}'
|
754
|
+
* + '</h1>'
|
755
|
+
* + '{{each list}}'
|
756
|
+
* + '{{with addOne @index as idx}}'
|
757
|
+
* + '<p>{{idx}}: {{@this}}</p>'
|
758
|
+
* + '{{/with}}'
|
759
|
+
* + '{{/each}}';
|
760
|
+
*
|
761
|
+
* var context = {
|
762
|
+
* isValidDate: function(text) {
|
763
|
+
* return /^\d{4}-(0|1)\d-(0|1|2|3)\d$/.test(text);
|
764
|
+
* },
|
765
|
+
* isValidNumber: function(text) {
|
766
|
+
* return /^\d+$/.test(text);
|
767
|
+
* }
|
768
|
+
* title: '2019-11-25',
|
769
|
+
* list: ['Clean the room', 'Wash the dishes'],
|
770
|
+
* addOne: function(num) {
|
771
|
+
* return num + 1;
|
772
|
+
* }
|
773
|
+
* };
|
774
|
+
*
|
775
|
+
* var result = template(source, context);
|
776
|
+
* console.log(result); // <h1>Date: 2019-11-25</h1><p>1: Clean the room</p><p>2: Wash the dishes</p>
|
777
|
+
*/
|
778
|
+
function template(text, context) {
|
779
|
+
return compile(splitByRegExp(text, EXPRESSION_REGEXP), context);
|
780
|
+
}
|
781
|
+
|
782
|
+
module.exports = template;
|
783
|
+
|
784
|
+
|
785
|
+
/***/ }),
|
786
|
+
/* 8 */
|
787
|
+
/***/ (function(module, exports, __webpack_require__) {
|
788
|
+
|
789
|
+
"use strict";
|
790
|
+
/**
|
791
|
+
* @fileoverview This module provides some functions for custom events. And it is implemented in the observer design pattern.
|
792
|
+
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
793
|
+
*/
|
794
|
+
|
795
|
+
|
796
|
+
|
797
|
+
var extend = __webpack_require__(1);
|
798
|
+
var isExisty = __webpack_require__(23);
|
799
|
+
var isString = __webpack_require__(6);
|
800
|
+
var isObject = __webpack_require__(25);
|
801
|
+
var isArray = __webpack_require__(2);
|
802
|
+
var isFunction = __webpack_require__(26);
|
803
|
+
var forEach = __webpack_require__(4);
|
804
|
+
|
805
|
+
var R_EVENTNAME_SPLIT = /\s+/g;
|
806
|
+
|
807
|
+
/**
|
808
|
+
* @class
|
809
|
+
* @example
|
810
|
+
* // node, commonjs
|
811
|
+
* var CustomEvents = require('tui-code-snippet/customEvents/customEvents');
|
812
|
+
*/
|
813
|
+
function CustomEvents() {
|
814
|
+
/**
|
815
|
+
* @type {HandlerItem[]}
|
816
|
+
*/
|
817
|
+
this.events = null;
|
818
|
+
|
819
|
+
/**
|
820
|
+
* only for checking specific context event was binded
|
821
|
+
* @type {object[]}
|
822
|
+
*/
|
823
|
+
this.contexts = null;
|
824
|
+
}
|
825
|
+
|
826
|
+
/**
|
827
|
+
* Mixin custom events feature to specific constructor
|
828
|
+
* @param {function} func - constructor
|
829
|
+
* @example
|
830
|
+
* var CustomEvents = require('tui-code-snippet/customEvents/customEvents'); // node, commonjs
|
831
|
+
*
|
832
|
+
* var model;
|
833
|
+
* function Model() {
|
834
|
+
* this.name = '';
|
835
|
+
* }
|
836
|
+
* CustomEvents.mixin(Model);
|
837
|
+
*
|
838
|
+
* model = new Model();
|
839
|
+
* model.on('change', function() { this.name = 'model'; }, this);
|
840
|
+
* model.fire('change');
|
841
|
+
* alert(model.name); // 'model';
|
842
|
+
*/
|
843
|
+
CustomEvents.mixin = function(func) {
|
844
|
+
extend(func.prototype, CustomEvents.prototype);
|
845
|
+
};
|
846
|
+
|
847
|
+
/**
|
848
|
+
* Get HandlerItem object
|
849
|
+
* @param {function} handler - handler function
|
850
|
+
* @param {object} [context] - context for handler
|
851
|
+
* @returns {HandlerItem} HandlerItem object
|
852
|
+
* @private
|
853
|
+
*/
|
854
|
+
CustomEvents.prototype._getHandlerItem = function(handler, context) {
|
855
|
+
var item = {handler: handler};
|
856
|
+
|
857
|
+
if (context) {
|
858
|
+
item.context = context;
|
859
|
+
}
|
860
|
+
|
861
|
+
return item;
|
862
|
+
};
|
863
|
+
|
864
|
+
/**
|
865
|
+
* Get event object safely
|
866
|
+
* @param {string} [eventName] - create sub event map if not exist.
|
867
|
+
* @returns {(object|array)} event object. if you supplied `eventName`
|
868
|
+
* parameter then make new array and return it
|
869
|
+
* @private
|
870
|
+
*/
|
871
|
+
CustomEvents.prototype._safeEvent = function(eventName) {
|
872
|
+
var events = this.events;
|
873
|
+
var byName;
|
874
|
+
|
875
|
+
if (!events) {
|
876
|
+
events = this.events = {};
|
877
|
+
}
|
878
|
+
|
879
|
+
if (eventName) {
|
880
|
+
byName = events[eventName];
|
881
|
+
|
882
|
+
if (!byName) {
|
883
|
+
byName = [];
|
884
|
+
events[eventName] = byName;
|
885
|
+
}
|
886
|
+
|
887
|
+
events = byName;
|
888
|
+
}
|
889
|
+
|
890
|
+
return events;
|
891
|
+
};
|
892
|
+
|
893
|
+
/**
|
894
|
+
* Get context array safely
|
895
|
+
* @returns {array} context array
|
896
|
+
* @private
|
897
|
+
*/
|
898
|
+
CustomEvents.prototype._safeContext = function() {
|
899
|
+
var context = this.contexts;
|
900
|
+
|
901
|
+
if (!context) {
|
902
|
+
context = this.contexts = [];
|
903
|
+
}
|
904
|
+
|
905
|
+
return context;
|
906
|
+
};
|
907
|
+
|
908
|
+
/**
|
909
|
+
* Get index of context
|
910
|
+
* @param {object} ctx - context that used for bind custom event
|
911
|
+
* @returns {number} index of context
|
912
|
+
* @private
|
913
|
+
*/
|
914
|
+
CustomEvents.prototype._indexOfContext = function(ctx) {
|
915
|
+
var context = this._safeContext();
|
916
|
+
var index = 0;
|
917
|
+
|
918
|
+
while (context[index]) {
|
919
|
+
if (ctx === context[index][0]) {
|
920
|
+
return index;
|
921
|
+
}
|
922
|
+
|
923
|
+
index += 1;
|
924
|
+
}
|
925
|
+
|
926
|
+
return -1;
|
927
|
+
};
|
928
|
+
|
929
|
+
/**
|
930
|
+
* Memorize supplied context for recognize supplied object is context or
|
931
|
+
* name: handler pair object when off()
|
932
|
+
* @param {object} ctx - context object to memorize
|
933
|
+
* @private
|
934
|
+
*/
|
935
|
+
CustomEvents.prototype._memorizeContext = function(ctx) {
|
936
|
+
var context, index;
|
937
|
+
|
938
|
+
if (!isExisty(ctx)) {
|
939
|
+
return;
|
940
|
+
}
|
941
|
+
|
942
|
+
context = this._safeContext();
|
943
|
+
index = this._indexOfContext(ctx);
|
944
|
+
|
945
|
+
if (index > -1) {
|
946
|
+
context[index][1] += 1;
|
947
|
+
} else {
|
948
|
+
context.push([ctx, 1]);
|
949
|
+
}
|
950
|
+
};
|
951
|
+
|
952
|
+
/**
|
953
|
+
* Forget supplied context object
|
954
|
+
* @param {object} ctx - context object to forget
|
955
|
+
* @private
|
956
|
+
*/
|
957
|
+
CustomEvents.prototype._forgetContext = function(ctx) {
|
958
|
+
var context, contextIndex;
|
959
|
+
|
960
|
+
if (!isExisty(ctx)) {
|
961
|
+
return;
|
962
|
+
}
|
963
|
+
|
964
|
+
context = this._safeContext();
|
965
|
+
contextIndex = this._indexOfContext(ctx);
|
966
|
+
|
967
|
+
if (contextIndex > -1) {
|
968
|
+
context[contextIndex][1] -= 1;
|
969
|
+
|
970
|
+
if (context[contextIndex][1] <= 0) {
|
971
|
+
context.splice(contextIndex, 1);
|
972
|
+
}
|
973
|
+
}
|
974
|
+
};
|
975
|
+
|
976
|
+
/**
|
977
|
+
* Bind event handler
|
978
|
+
* @param {(string|{name:string, handler:function})} eventName - custom
|
979
|
+
* event name or an object {eventName: handler}
|
980
|
+
* @param {(function|object)} [handler] - handler function or context
|
981
|
+
* @param {object} [context] - context for binding
|
982
|
+
* @private
|
983
|
+
*/
|
984
|
+
CustomEvents.prototype._bindEvent = function(eventName, handler, context) {
|
985
|
+
var events = this._safeEvent(eventName);
|
986
|
+
this._memorizeContext(context);
|
987
|
+
events.push(this._getHandlerItem(handler, context));
|
988
|
+
};
|
989
|
+
|
990
|
+
/**
|
991
|
+
* Bind event handlers
|
992
|
+
* @param {(string|{name:string, handler:function})} eventName - custom
|
993
|
+
* event name or an object {eventName: handler}
|
994
|
+
* @param {(function|object)} [handler] - handler function or context
|
995
|
+
* @param {object} [context] - context for binding
|
996
|
+
* //-- #1. Get Module --//
|
997
|
+
* var CustomEvents = require('tui-code-snippet/customEvents/customEvents'); // node, commonjs
|
998
|
+
*
|
999
|
+
* //-- #2. Use method --//
|
1000
|
+
* // # 2.1 Basic Usage
|
1001
|
+
* CustomEvents.on('onload', handler);
|
1002
|
+
*
|
1003
|
+
* // # 2.2 With context
|
1004
|
+
* CustomEvents.on('onload', handler, myObj);
|
1005
|
+
*
|
1006
|
+
* // # 2.3 Bind by object that name, handler pairs
|
1007
|
+
* CustomEvents.on({
|
1008
|
+
* 'play': handler,
|
1009
|
+
* 'pause': handler2
|
1010
|
+
* });
|
1011
|
+
*
|
1012
|
+
* // # 2.4 Bind by object that name, handler pairs with context object
|
1013
|
+
* CustomEvents.on({
|
1014
|
+
* 'play': handler
|
1015
|
+
* }, myObj);
|
1016
|
+
*/
|
1017
|
+
CustomEvents.prototype.on = function(eventName, handler, context) {
|
1018
|
+
var self = this;
|
1019
|
+
|
1020
|
+
if (isString(eventName)) {
|
1021
|
+
// [syntax 1, 2]
|
1022
|
+
eventName = eventName.split(R_EVENTNAME_SPLIT);
|
1023
|
+
forEach(eventName, function(name) {
|
1024
|
+
self._bindEvent(name, handler, context);
|
1025
|
+
});
|
1026
|
+
} else if (isObject(eventName)) {
|
1027
|
+
// [syntax 3, 4]
|
1028
|
+
context = handler;
|
1029
|
+
forEach(eventName, function(func, name) {
|
1030
|
+
self.on(name, func, context);
|
1031
|
+
});
|
1032
|
+
}
|
1033
|
+
};
|
1034
|
+
|
1035
|
+
/**
|
1036
|
+
* Bind one-shot event handlers
|
1037
|
+
* @param {(string|{name:string,handler:function})} eventName - custom
|
1038
|
+
* event name or an object {eventName: handler}
|
1039
|
+
* @param {function|object} [handler] - handler function or context
|
1040
|
+
* @param {object} [context] - context for binding
|
1041
|
+
*/
|
1042
|
+
CustomEvents.prototype.once = function(eventName, handler, context) {
|
1043
|
+
var self = this;
|
1044
|
+
|
1045
|
+
if (isObject(eventName)) {
|
1046
|
+
context = handler;
|
1047
|
+
forEach(eventName, function(func, name) {
|
1048
|
+
self.once(name, func, context);
|
1049
|
+
});
|
1050
|
+
|
1051
|
+
return;
|
1052
|
+
}
|
1053
|
+
|
1054
|
+
function onceHandler() { // eslint-disable-line require-jsdoc
|
1055
|
+
handler.apply(context, arguments);
|
1056
|
+
self.off(eventName, onceHandler, context);
|
1057
|
+
}
|
1058
|
+
|
1059
|
+
this.on(eventName, onceHandler, context);
|
1060
|
+
};
|
1061
|
+
|
1062
|
+
/**
|
1063
|
+
* Splice supplied array by callback result
|
1064
|
+
* @param {array} arr - array to splice
|
1065
|
+
* @param {function} predicate - function return boolean
|
1066
|
+
* @private
|
1067
|
+
*/
|
1068
|
+
CustomEvents.prototype._spliceMatches = function(arr, predicate) {
|
1069
|
+
var i = 0;
|
1070
|
+
var len;
|
1071
|
+
|
1072
|
+
if (!isArray(arr)) {
|
1073
|
+
return;
|
1074
|
+
}
|
1075
|
+
|
1076
|
+
for (len = arr.length; i < len; i += 1) {
|
1077
|
+
if (predicate(arr[i]) === true) {
|
1078
|
+
arr.splice(i, 1);
|
1079
|
+
len -= 1;
|
1080
|
+
i -= 1;
|
1081
|
+
}
|
1082
|
+
}
|
1083
|
+
};
|
1084
|
+
|
1085
|
+
/**
|
1086
|
+
* Get matcher for unbind specific handler events
|
1087
|
+
* @param {function} handler - handler function
|
1088
|
+
* @returns {function} handler matcher
|
1089
|
+
* @private
|
1090
|
+
*/
|
1091
|
+
CustomEvents.prototype._matchHandler = function(handler) {
|
1092
|
+
var self = this;
|
1093
|
+
|
1094
|
+
return function(item) {
|
1095
|
+
var needRemove = handler === item.handler;
|
1096
|
+
|
1097
|
+
if (needRemove) {
|
1098
|
+
self._forgetContext(item.context);
|
1099
|
+
}
|
1100
|
+
|
1101
|
+
return needRemove;
|
1102
|
+
};
|
1103
|
+
};
|
1104
|
+
|
1105
|
+
/**
|
1106
|
+
* Get matcher for unbind specific context events
|
1107
|
+
* @param {object} context - context
|
1108
|
+
* @returns {function} object matcher
|
1109
|
+
* @private
|
1110
|
+
*/
|
1111
|
+
CustomEvents.prototype._matchContext = function(context) {
|
1112
|
+
var self = this;
|
1113
|
+
|
1114
|
+
return function(item) {
|
1115
|
+
var needRemove = context === item.context;
|
1116
|
+
|
1117
|
+
if (needRemove) {
|
1118
|
+
self._forgetContext(item.context);
|
1119
|
+
}
|
1120
|
+
|
1121
|
+
return needRemove;
|
1122
|
+
};
|
1123
|
+
};
|
1124
|
+
|
1125
|
+
/**
|
1126
|
+
* Get matcher for unbind specific hander, context pair events
|
1127
|
+
* @param {function} handler - handler function
|
1128
|
+
* @param {object} context - context
|
1129
|
+
* @returns {function} handler, context matcher
|
1130
|
+
* @private
|
1131
|
+
*/
|
1132
|
+
CustomEvents.prototype._matchHandlerAndContext = function(handler, context) {
|
1133
|
+
var self = this;
|
1134
|
+
|
1135
|
+
return function(item) {
|
1136
|
+
var matchHandler = (handler === item.handler);
|
1137
|
+
var matchContext = (context === item.context);
|
1138
|
+
var needRemove = (matchHandler && matchContext);
|
1139
|
+
|
1140
|
+
if (needRemove) {
|
1141
|
+
self._forgetContext(item.context);
|
1142
|
+
}
|
1143
|
+
|
1144
|
+
return needRemove;
|
1145
|
+
};
|
1146
|
+
};
|
1147
|
+
|
1148
|
+
/**
|
1149
|
+
* Unbind event by event name
|
1150
|
+
* @param {string} eventName - custom event name to unbind
|
1151
|
+
* @param {function} [handler] - handler function
|
1152
|
+
* @private
|
1153
|
+
*/
|
1154
|
+
CustomEvents.prototype._offByEventName = function(eventName, handler) {
|
1155
|
+
var self = this;
|
1156
|
+
var andByHandler = isFunction(handler);
|
1157
|
+
var matchHandler = self._matchHandler(handler);
|
1158
|
+
|
1159
|
+
eventName = eventName.split(R_EVENTNAME_SPLIT);
|
1160
|
+
|
1161
|
+
forEach(eventName, function(name) {
|
1162
|
+
var handlerItems = self._safeEvent(name);
|
1163
|
+
|
1164
|
+
if (andByHandler) {
|
1165
|
+
self._spliceMatches(handlerItems, matchHandler);
|
1166
|
+
} else {
|
1167
|
+
forEach(handlerItems, function(item) {
|
1168
|
+
self._forgetContext(item.context);
|
1169
|
+
});
|
1170
|
+
|
1171
|
+
self.events[name] = [];
|
1172
|
+
}
|
1173
|
+
});
|
1174
|
+
};
|
1175
|
+
|
1176
|
+
/**
|
1177
|
+
* Unbind event by handler function
|
1178
|
+
* @param {function} handler - handler function
|
1179
|
+
* @private
|
1180
|
+
*/
|
1181
|
+
CustomEvents.prototype._offByHandler = function(handler) {
|
1182
|
+
var self = this;
|
1183
|
+
var matchHandler = this._matchHandler(handler);
|
1184
|
+
|
1185
|
+
forEach(this._safeEvent(), function(handlerItems) {
|
1186
|
+
self._spliceMatches(handlerItems, matchHandler);
|
1187
|
+
});
|
1188
|
+
};
|
1189
|
+
|
1190
|
+
/**
|
1191
|
+
* Unbind event by object(name: handler pair object or context object)
|
1192
|
+
* @param {object} obj - context or {name: handler} pair object
|
1193
|
+
* @param {function} handler - handler function
|
1194
|
+
* @private
|
1195
|
+
*/
|
1196
|
+
CustomEvents.prototype._offByObject = function(obj, handler) {
|
1197
|
+
var self = this;
|
1198
|
+
var matchFunc;
|
1199
|
+
|
1200
|
+
if (this._indexOfContext(obj) < 0) {
|
1201
|
+
forEach(obj, function(func, name) {
|
1202
|
+
self.off(name, func);
|
1203
|
+
});
|
1204
|
+
} else if (isString(handler)) {
|
1205
|
+
matchFunc = this._matchContext(obj);
|
1206
|
+
|
1207
|
+
self._spliceMatches(this._safeEvent(handler), matchFunc);
|
1208
|
+
} else if (isFunction(handler)) {
|
1209
|
+
matchFunc = this._matchHandlerAndContext(handler, obj);
|
1210
|
+
|
1211
|
+
forEach(this._safeEvent(), function(handlerItems) {
|
1212
|
+
self._spliceMatches(handlerItems, matchFunc);
|
1213
|
+
});
|
1214
|
+
} else {
|
1215
|
+
matchFunc = this._matchContext(obj);
|
1216
|
+
|
1217
|
+
forEach(this._safeEvent(), function(handlerItems) {
|
1218
|
+
self._spliceMatches(handlerItems, matchFunc);
|
1219
|
+
});
|
1220
|
+
}
|
1221
|
+
};
|
1222
|
+
|
1223
|
+
/**
|
1224
|
+
* Unbind custom events
|
1225
|
+
* @param {(string|object|function)} eventName - event name or context or
|
1226
|
+
* {name: handler} pair object or handler function
|
1227
|
+
* @param {(function)} handler - handler function
|
1228
|
+
* @example
|
1229
|
+
* //-- #1. Get Module --//
|
1230
|
+
* var CustomEvents = require('tui-code-snippet/customEvents/customEvents'); // node, commonjs
|
1231
|
+
*
|
1232
|
+
* //-- #2. Use method --//
|
1233
|
+
* // # 2.1 off by event name
|
1234
|
+
* CustomEvents.off('onload');
|
1235
|
+
*
|
1236
|
+
* // # 2.2 off by event name and handler
|
1237
|
+
* CustomEvents.off('play', handler);
|
1238
|
+
*
|
1239
|
+
* // # 2.3 off by handler
|
1240
|
+
* CustomEvents.off(handler);
|
1241
|
+
*
|
1242
|
+
* // # 2.4 off by context
|
1243
|
+
* CustomEvents.off(myObj);
|
1244
|
+
*
|
1245
|
+
* // # 2.5 off by context and handler
|
1246
|
+
* CustomEvents.off(myObj, handler);
|
1247
|
+
*
|
1248
|
+
* // # 2.6 off by context and event name
|
1249
|
+
* CustomEvents.off(myObj, 'onload');
|
1250
|
+
*
|
1251
|
+
* // # 2.7 off by an Object.<string, function> that is {eventName: handler}
|
1252
|
+
* CustomEvents.off({
|
1253
|
+
* 'play': handler,
|
1254
|
+
* 'pause': handler2
|
1255
|
+
* });
|
1256
|
+
*
|
1257
|
+
* // # 2.8 off the all events
|
1258
|
+
* CustomEvents.off();
|
1259
|
+
*/
|
1260
|
+
CustomEvents.prototype.off = function(eventName, handler) {
|
1261
|
+
if (isString(eventName)) {
|
1262
|
+
// [syntax 1, 2]
|
1263
|
+
this._offByEventName(eventName, handler);
|
1264
|
+
} else if (!arguments.length) {
|
1265
|
+
// [syntax 8]
|
1266
|
+
this.events = {};
|
1267
|
+
this.contexts = [];
|
1268
|
+
} else if (isFunction(eventName)) {
|
1269
|
+
// [syntax 3]
|
1270
|
+
this._offByHandler(eventName);
|
1271
|
+
} else if (isObject(eventName)) {
|
1272
|
+
// [syntax 4, 5, 6]
|
1273
|
+
this._offByObject(eventName, handler);
|
1274
|
+
}
|
1275
|
+
};
|
1276
|
+
|
1277
|
+
/**
|
1278
|
+
* Fire custom event
|
1279
|
+
* @param {string} eventName - name of custom event
|
1280
|
+
*/
|
1281
|
+
CustomEvents.prototype.fire = function(eventName) { // eslint-disable-line
|
1282
|
+
this.invoke.apply(this, arguments);
|
1283
|
+
};
|
1284
|
+
|
1285
|
+
/**
|
1286
|
+
* Fire a event and returns the result of operation 'boolean AND' with all
|
1287
|
+
* listener's results.
|
1288
|
+
*
|
1289
|
+
* So, It is different from {@link CustomEvents#fire}.
|
1290
|
+
*
|
1291
|
+
* In service code, use this as a before event in component level usually
|
1292
|
+
* for notifying that the event is cancelable.
|
1293
|
+
* @param {string} eventName - Custom event name
|
1294
|
+
* @param {...*} data - Data for event
|
1295
|
+
* @returns {boolean} The result of operation 'boolean AND'
|
1296
|
+
* @example
|
1297
|
+
* var map = new Map();
|
1298
|
+
* map.on({
|
1299
|
+
* 'beforeZoom': function() {
|
1300
|
+
* // It should cancel the 'zoom' event by some conditions.
|
1301
|
+
* if (that.disabled && this.getState()) {
|
1302
|
+
* return false;
|
1303
|
+
* }
|
1304
|
+
* return true;
|
1305
|
+
* }
|
1306
|
+
* });
|
1307
|
+
*
|
1308
|
+
* if (this.invoke('beforeZoom')) { // check the result of 'beforeZoom'
|
1309
|
+
* // if true,
|
1310
|
+
* // doSomething
|
1311
|
+
* }
|
1312
|
+
*/
|
1313
|
+
CustomEvents.prototype.invoke = function(eventName) {
|
1314
|
+
var events, args, index, item;
|
1315
|
+
|
1316
|
+
if (!this.hasListener(eventName)) {
|
1317
|
+
return true;
|
1318
|
+
}
|
1319
|
+
|
1320
|
+
events = this._safeEvent(eventName);
|
1321
|
+
args = Array.prototype.slice.call(arguments, 1);
|
1322
|
+
index = 0;
|
1323
|
+
|
1324
|
+
while (events[index]) {
|
1325
|
+
item = events[index];
|
1326
|
+
|
1327
|
+
if (item.handler.apply(item.context, args) === false) {
|
1328
|
+
return false;
|
1329
|
+
}
|
1330
|
+
|
1331
|
+
index += 1;
|
1332
|
+
}
|
1333
|
+
|
1334
|
+
return true;
|
1335
|
+
};
|
1336
|
+
|
1337
|
+
/**
|
1338
|
+
* Return whether at least one of the handlers is registered in the given
|
1339
|
+
* event name.
|
1340
|
+
* @param {string} eventName - Custom event name
|
1341
|
+
* @returns {boolean} Is there at least one handler in event name?
|
1342
|
+
*/
|
1343
|
+
CustomEvents.prototype.hasListener = function(eventName) {
|
1344
|
+
return this.getListenerLength(eventName) > 0;
|
1345
|
+
};
|
1346
|
+
|
1347
|
+
/**
|
1348
|
+
* Return a count of events registered.
|
1349
|
+
* @param {string} eventName - Custom event name
|
1350
|
+
* @returns {number} number of event
|
1351
|
+
*/
|
1352
|
+
CustomEvents.prototype.getListenerLength = function(eventName) {
|
1353
|
+
var events = this._safeEvent(eventName);
|
1354
|
+
|
1355
|
+
return events.length;
|
1356
|
+
};
|
1357
|
+
|
1358
|
+
module.exports = CustomEvents;
|
1359
|
+
|
1360
|
+
|
1361
|
+
/***/ }),
|
1362
|
+
/* 9 */
|
1363
|
+
/***/ (function(module, exports, __webpack_require__) {
|
1364
|
+
|
1365
|
+
"use strict";
|
1366
|
+
/**
|
1367
|
+
* @fileoverview
|
1368
|
+
* This module provides a function to make a constructor
|
1369
|
+
* that can inherit from the other constructors like the CLASS easily.
|
1370
|
+
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
1371
|
+
*/
|
1372
|
+
|
1373
|
+
|
1374
|
+
|
1375
|
+
var inherit = __webpack_require__(27);
|
1376
|
+
var extend = __webpack_require__(1);
|
1377
|
+
|
1378
|
+
/**
|
1379
|
+
* @module defineClass
|
1380
|
+
*/
|
1381
|
+
|
1382
|
+
/**
|
1383
|
+
* Help a constructor to be defined and to inherit from the other constructors
|
1384
|
+
* @param {*} [parent] Parent constructor
|
1385
|
+
* @param {Object} props Members of constructor
|
1386
|
+
* @param {Function} props.init Initialization method
|
1387
|
+
* @param {Object} [props.static] Static members of constructor
|
1388
|
+
* @returns {*} Constructor
|
1389
|
+
* @memberof module:defineClass
|
1390
|
+
* @example
|
1391
|
+
* var defineClass = require('tui-code-snippet/defineClass/defineClass'); // node, commonjs
|
1392
|
+
*
|
1393
|
+
* //-- #2. Use property --//
|
1394
|
+
* var Parent = defineClass({
|
1395
|
+
* init: function() { // constuructor
|
1396
|
+
* this.name = 'made by def';
|
1397
|
+
* },
|
1398
|
+
* method: function() {
|
1399
|
+
* // ...
|
1400
|
+
* },
|
1401
|
+
* static: {
|
1402
|
+
* staticMethod: function() {
|
1403
|
+
* // ...
|
1404
|
+
* }
|
1405
|
+
* }
|
1406
|
+
* });
|
1407
|
+
*
|
1408
|
+
* var Child = defineClass(Parent, {
|
1409
|
+
* childMethod: function() {}
|
1410
|
+
* });
|
1411
|
+
*
|
1412
|
+
* Parent.staticMethod();
|
1413
|
+
*
|
1414
|
+
* var parentInstance = new Parent();
|
1415
|
+
* console.log(parentInstance.name); //made by def
|
1416
|
+
* parentInstance.staticMethod(); // Error
|
1417
|
+
*
|
1418
|
+
* var childInstance = new Child();
|
1419
|
+
* childInstance.method();
|
1420
|
+
* childInstance.childMethod();
|
1421
|
+
*/
|
1422
|
+
function defineClass(parent, props) {
|
1423
|
+
var obj;
|
1424
|
+
|
1425
|
+
if (!props) {
|
1426
|
+
props = parent;
|
1427
|
+
parent = null;
|
1428
|
+
}
|
1429
|
+
|
1430
|
+
obj = props.init || function() {};
|
1431
|
+
|
1432
|
+
if (parent) {
|
1433
|
+
inherit(obj, parent);
|
1434
|
+
}
|
1435
|
+
|
1436
|
+
if (props.hasOwnProperty('static')) {
|
1437
|
+
extend(obj, props['static']);
|
1438
|
+
delete props['static'];
|
1439
|
+
}
|
1440
|
+
|
1441
|
+
extend(obj.prototype, props);
|
1442
|
+
|
1443
|
+
return obj;
|
1444
|
+
}
|
1445
|
+
|
1446
|
+
module.exports = defineClass;
|
1447
|
+
|
1448
|
+
|
1449
|
+
/***/ }),
|
1450
|
+
/* 10 */
|
1451
|
+
/***/ (function(module, exports, __webpack_require__) {
|
1452
|
+
|
1453
|
+
"use strict";
|
1454
|
+
/**
|
1455
|
+
* @fileoverview Bind DOM events
|
1456
|
+
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
1457
|
+
*/
|
1458
|
+
|
1459
|
+
|
1460
|
+
|
1461
|
+
var isString = __webpack_require__(6);
|
1462
|
+
var forEach = __webpack_require__(4);
|
1463
|
+
|
1464
|
+
var safeEvent = __webpack_require__(17);
|
1465
|
+
|
1466
|
+
/**
|
1467
|
+
* Bind DOM events.
|
1468
|
+
* @param {HTMLElement} element - element to bind events
|
1469
|
+
* @param {(string|object)} types - Space splitted events names or eventName:handler object
|
1470
|
+
* @param {(function|object)} handler - handler function or context for handler method
|
1471
|
+
* @param {object} [context] context - context for handler method.
|
1472
|
+
* @memberof module:domEvent
|
1473
|
+
* @example
|
1474
|
+
* var div = document.querySelector('div');
|
1475
|
+
*
|
1476
|
+
* // Bind one event to an element.
|
1477
|
+
* on(div, 'click', toggle);
|
1478
|
+
*
|
1479
|
+
* // Bind multiple events with a same handler to multiple elements at once.
|
1480
|
+
* // Use event names splitted by a space.
|
1481
|
+
* on(div, 'mouseenter mouseleave', changeColor);
|
1482
|
+
*
|
1483
|
+
* // Bind multiple events with different handlers to an element at once.
|
1484
|
+
* // Use an object which of key is an event name and value is a handler function.
|
1485
|
+
* on(div, {
|
1486
|
+
* keydown: highlight,
|
1487
|
+
* keyup: dehighlight
|
1488
|
+
* });
|
1489
|
+
*
|
1490
|
+
* // Set a context for handler method.
|
1491
|
+
* var name = 'global';
|
1492
|
+
* var repository = {name: 'CodeSnippet'};
|
1493
|
+
* on(div, 'drag', function() {
|
1494
|
+
* console.log(this.name);
|
1495
|
+
* }, repository);
|
1496
|
+
* // Result when you drag a div: "CodeSnippet"
|
1497
|
+
*/
|
1498
|
+
function on(element, types, handler, context) {
|
1499
|
+
if (isString(types)) {
|
1500
|
+
forEach(types.split(/\s+/g), function(type) {
|
1501
|
+
bindEvent(element, type, handler, context);
|
1502
|
+
});
|
1503
|
+
|
1504
|
+
return;
|
1505
|
+
}
|
1506
|
+
|
1507
|
+
forEach(types, function(func, type) {
|
1508
|
+
bindEvent(element, type, func, handler);
|
1509
|
+
});
|
1510
|
+
}
|
1511
|
+
|
1512
|
+
/**
|
1513
|
+
* Bind DOM events
|
1514
|
+
* @param {HTMLElement} element - element to bind events
|
1515
|
+
* @param {string} type - events name
|
1516
|
+
* @param {function} handler - handler function or context for handler method
|
1517
|
+
* @param {object} [context] context - context for handler method.
|
1518
|
+
* @private
|
1519
|
+
*/
|
1520
|
+
function bindEvent(element, type, handler, context) {
|
1521
|
+
/**
|
1522
|
+
* Event handler
|
1523
|
+
* @param {Event} e - event object
|
1524
|
+
*/
|
1525
|
+
function eventHandler(e) {
|
1526
|
+
handler.call(context || element, e || window.event);
|
1527
|
+
}
|
1528
|
+
|
1529
|
+
if ('addEventListener' in element) {
|
1530
|
+
element.addEventListener(type, eventHandler);
|
1531
|
+
} else if ('attachEvent' in element) {
|
1532
|
+
element.attachEvent('on' + type, eventHandler);
|
1533
|
+
}
|
1534
|
+
memorizeHandler(element, type, handler, eventHandler);
|
1535
|
+
}
|
1536
|
+
|
1537
|
+
/**
|
1538
|
+
* Memorize DOM event handler for unbinding.
|
1539
|
+
* @param {HTMLElement} element - element to bind events
|
1540
|
+
* @param {string} type - events name
|
1541
|
+
* @param {function} handler - handler function that user passed at on() use
|
1542
|
+
* @param {function} wrappedHandler - handler function that wrapped by domevent for implementing some features
|
1543
|
+
* @private
|
1544
|
+
*/
|
1545
|
+
function memorizeHandler(element, type, handler, wrappedHandler) {
|
1546
|
+
var events = safeEvent(element, type);
|
1547
|
+
var existInEvents = false;
|
1548
|
+
|
1549
|
+
forEach(events, function(obj) {
|
1550
|
+
if (obj.handler === handler) {
|
1551
|
+
existInEvents = true;
|
1552
|
+
|
1553
|
+
return false;
|
1554
|
+
}
|
1555
|
+
|
1556
|
+
return true;
|
1557
|
+
});
|
1558
|
+
|
1559
|
+
if (!existInEvents) {
|
1560
|
+
events.push({
|
1561
|
+
handler: handler,
|
1562
|
+
wrappedHandler: wrappedHandler
|
1563
|
+
});
|
1564
|
+
}
|
1565
|
+
}
|
1566
|
+
|
1567
|
+
module.exports = on;
|
1568
|
+
|
1569
|
+
|
1570
|
+
/***/ }),
|
1571
|
+
/* 11 */
|
1572
|
+
/***/ (function(module, exports, __webpack_require__) {
|
1573
|
+
|
1574
|
+
"use strict";
|
1575
|
+
/**
|
1576
|
+
* @fileoverview Unbind DOM events
|
1577
|
+
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
1578
|
+
*/
|
1579
|
+
|
1580
|
+
|
1581
|
+
|
1582
|
+
var isString = __webpack_require__(6);
|
1583
|
+
var forEach = __webpack_require__(4);
|
1584
|
+
|
1585
|
+
var safeEvent = __webpack_require__(17);
|
1586
|
+
|
1587
|
+
/**
|
1588
|
+
* Unbind DOM events
|
1589
|
+
* If a handler function is not passed, remove all events of that type.
|
1590
|
+
* @param {HTMLElement} element - element to unbind events
|
1591
|
+
* @param {(string|object)} types - Space splitted events names or eventName:handler object
|
1592
|
+
* @param {function} [handler] - handler function
|
1593
|
+
* @memberof module:domEvent
|
1594
|
+
* @example
|
1595
|
+
* // Following the example of domEvent#on
|
1596
|
+
*
|
1597
|
+
* // Unbind one event from an element.
|
1598
|
+
* off(div, 'click', toggle);
|
1599
|
+
*
|
1600
|
+
* // Unbind multiple events with a same handler from multiple elements at once.
|
1601
|
+
* // Use event names splitted by a space.
|
1602
|
+
* off(element, 'mouseenter mouseleave', changeColor);
|
1603
|
+
*
|
1604
|
+
* // Unbind multiple events with different handlers from an element at once.
|
1605
|
+
* // Use an object which of key is an event name and value is a handler function.
|
1606
|
+
* off(div, {
|
1607
|
+
* keydown: highlight,
|
1608
|
+
* keyup: dehighlight
|
1609
|
+
* });
|
1610
|
+
*
|
1611
|
+
* // Unbind events without handlers.
|
1612
|
+
* off(div, 'drag');
|
1613
|
+
*/
|
1614
|
+
function off(element, types, handler) {
|
1615
|
+
if (isString(types)) {
|
1616
|
+
forEach(types.split(/\s+/g), function(type) {
|
1617
|
+
unbindEvent(element, type, handler);
|
1618
|
+
});
|
1619
|
+
|
1620
|
+
return;
|
1621
|
+
}
|
1622
|
+
|
1623
|
+
forEach(types, function(func, type) {
|
1624
|
+
unbindEvent(element, type, func);
|
1625
|
+
});
|
1626
|
+
}
|
1627
|
+
|
1628
|
+
/**
|
1629
|
+
* Unbind DOM events
|
1630
|
+
* If a handler function is not passed, remove all events of that type.
|
1631
|
+
* @param {HTMLElement} element - element to unbind events
|
1632
|
+
* @param {string} type - events name
|
1633
|
+
* @param {function} [handler] - handler function
|
1634
|
+
* @private
|
1635
|
+
*/
|
1636
|
+
function unbindEvent(element, type, handler) {
|
1637
|
+
var events = safeEvent(element, type);
|
1638
|
+
var index;
|
1639
|
+
|
1640
|
+
if (!handler) {
|
1641
|
+
forEach(events, function(item) {
|
1642
|
+
removeHandler(element, type, item.wrappedHandler);
|
1643
|
+
});
|
1644
|
+
events.splice(0, events.length);
|
1645
|
+
} else {
|
1646
|
+
forEach(events, function(item, idx) {
|
1647
|
+
if (handler === item.handler) {
|
1648
|
+
removeHandler(element, type, item.wrappedHandler);
|
1649
|
+
index = idx;
|
1650
|
+
|
1651
|
+
return false;
|
1652
|
+
}
|
1653
|
+
|
1654
|
+
return true;
|
1655
|
+
});
|
1656
|
+
events.splice(index, 1);
|
1657
|
+
}
|
1658
|
+
}
|
1659
|
+
|
1660
|
+
/**
|
1661
|
+
* Remove an event handler
|
1662
|
+
* @param {HTMLElement} element - An element to remove an event
|
1663
|
+
* @param {string} type - event type
|
1664
|
+
* @param {function} handler - event handler
|
1665
|
+
* @private
|
1666
|
+
*/
|
1667
|
+
function removeHandler(element, type, handler) {
|
1668
|
+
if ('removeEventListener' in element) {
|
1669
|
+
element.removeEventListener(type, handler);
|
1670
|
+
} else if ('detachEvent' in element) {
|
1671
|
+
element.detachEvent('on' + type, handler);
|
1672
|
+
}
|
1673
|
+
}
|
1674
|
+
|
1675
|
+
module.exports = off;
|
1676
|
+
|
1677
|
+
|
1678
|
+
/***/ }),
|
1679
|
+
/* 12 */
|
1680
|
+
/***/ (function(module, exports, __webpack_require__) {
|
1681
|
+
|
1682
|
+
"use strict";
|
1683
|
+
/**
|
1684
|
+
* @fileoverview Find parent element recursively
|
1685
|
+
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
1686
|
+
*/
|
1687
|
+
|
1688
|
+
|
1689
|
+
|
1690
|
+
var matches = __webpack_require__(30);
|
1691
|
+
|
1692
|
+
/**
|
1693
|
+
* Find parent element recursively
|
1694
|
+
* @param {HTMLElement} element - base element to start find
|
1695
|
+
* @param {string} selector - selector string for find
|
1696
|
+
* @returns {HTMLElement} - element finded or null
|
1697
|
+
* @memberof module:domUtil
|
1698
|
+
*/
|
1699
|
+
function closest(element, selector) {
|
1700
|
+
var parent = element.parentNode;
|
1701
|
+
|
1702
|
+
if (matches(element, selector)) {
|
1703
|
+
return element;
|
1704
|
+
}
|
1705
|
+
|
1706
|
+
while (parent && parent !== document) {
|
1707
|
+
if (matches(parent, selector)) {
|
1708
|
+
return parent;
|
1709
|
+
}
|
1710
|
+
|
1711
|
+
parent = parent.parentNode;
|
1712
|
+
}
|
1713
|
+
|
1714
|
+
return null;
|
1715
|
+
}
|
1716
|
+
|
1717
|
+
module.exports = closest;
|
1718
|
+
|
1719
|
+
|
1720
|
+
/***/ }),
|
1721
|
+
/* 13 */
|
1722
|
+
/***/ (function(module, exports, __webpack_require__) {
|
1723
|
+
|
1724
|
+
"use strict";
|
1725
|
+
/**
|
1726
|
+
* @fileoverview Remove element from parent node.
|
1727
|
+
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
1728
|
+
*/
|
1729
|
+
|
1730
|
+
|
1731
|
+
|
1732
|
+
/**
|
1733
|
+
* Remove element from parent node.
|
1734
|
+
* @param {HTMLElement} element - element to remove.
|
1735
|
+
* @memberof module:domUtil
|
1736
|
+
*/
|
1737
|
+
function removeElement(element) {
|
1738
|
+
if (element && element.parentNode) {
|
1739
|
+
element.parentNode.removeChild(element);
|
1740
|
+
}
|
1741
|
+
}
|
1742
|
+
|
1743
|
+
module.exports = removeElement;
|
1744
|
+
|
1745
|
+
|
1746
|
+
/***/ }),
|
1747
|
+
/* 14 */
|
1748
|
+
/***/ (function(module, exports, __webpack_require__) {
|
1749
|
+
|
1750
|
+
"use strict";
|
1751
|
+
/**
|
1752
|
+
* @fileoverview Check whether the given variable is a instance of HTMLNode or not.
|
1753
|
+
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
1754
|
+
*/
|
1755
|
+
|
1756
|
+
|
1757
|
+
|
1758
|
+
/**
|
1759
|
+
* Check whether the given variable is a instance of HTMLNode or not.
|
1760
|
+
* If the given variables is a instance of HTMLNode, return true.
|
1761
|
+
* @param {*} html - Target for checking
|
1762
|
+
* @returns {boolean} Is HTMLNode ?
|
1763
|
+
* @memberof module:type
|
1764
|
+
*/
|
1765
|
+
function isHTMLNode(html) {
|
1766
|
+
if (typeof HTMLElement === 'object') {
|
1767
|
+
return (html && (html instanceof HTMLElement || !!html.nodeType));
|
1768
|
+
}
|
1769
|
+
|
1770
|
+
return !!(html && html.nodeType);
|
1771
|
+
}
|
1772
|
+
|
1773
|
+
module.exports = isHTMLNode;
|
1774
|
+
|
1775
|
+
|
1776
|
+
/***/ }),
|
1777
|
+
/* 15 */
|
1778
|
+
/***/ (function(module, exports, __webpack_require__) {
|
1779
|
+
|
1780
|
+
"use strict";
|
1781
|
+
/**
|
1782
|
+
* @fileoverview Utils for Timepicker component
|
1783
|
+
* @author NHN. FE dev Lab. <dl_javascript@nhn.com>
|
1784
|
+
*/
|
1785
|
+
|
1786
|
+
|
1787
|
+
|
1788
|
+
var inArray = __webpack_require__(0);
|
1789
|
+
var sendHostname = __webpack_require__(35);
|
1790
|
+
|
1791
|
+
var uniqueId = 0;
|
1792
|
+
|
1793
|
+
/**
|
1794
|
+
* Utils
|
1795
|
+
* @namespace util
|
1796
|
+
* @ignore
|
1797
|
+
*/
|
1798
|
+
var utils = {
|
1799
|
+
/**
|
1800
|
+
* Returns unique id
|
1801
|
+
* @returns {number}
|
1802
|
+
*/
|
1803
|
+
getUniqueId: function() {
|
1804
|
+
uniqueId += 1;
|
1805
|
+
|
1806
|
+
return uniqueId;
|
1807
|
+
},
|
1808
|
+
|
1809
|
+
/**
|
1810
|
+
* Convert a value to meet the format
|
1811
|
+
* @param {number|string} value
|
1812
|
+
* @param {string} format - ex) hh, h, mm, m
|
1813
|
+
* @returns {string}
|
1814
|
+
*/
|
1815
|
+
formatTime: function(value, format) {
|
1816
|
+
var PADDING_ZERO_TYPES = ['hh', 'mm'];
|
1817
|
+
value = String(value);
|
1818
|
+
|
1819
|
+
return inArray(format, PADDING_ZERO_TYPES) >= 0
|
1820
|
+
&& value.length === 1
|
1821
|
+
? '0' + value
|
1822
|
+
: value;
|
1823
|
+
},
|
1824
|
+
|
1825
|
+
/**
|
1826
|
+
* Get meridiem hour
|
1827
|
+
* @param {number} hour - Original hour
|
1828
|
+
* @returns {number} Converted meridiem hour
|
1829
|
+
*/
|
1830
|
+
getMeridiemHour: function(hour) {
|
1831
|
+
hour %= 12;
|
1832
|
+
|
1833
|
+
if (hour === 0) {
|
1834
|
+
hour = 12;
|
1835
|
+
}
|
1836
|
+
|
1837
|
+
return hour;
|
1838
|
+
},
|
1839
|
+
|
1840
|
+
/**
|
1841
|
+
* Returns range arr
|
1842
|
+
* @param {number} start - Start value
|
1843
|
+
* @param {number} end - End value
|
1844
|
+
* @param {number} [step] - Step value
|
1845
|
+
* @returns {Array}
|
1846
|
+
*/
|
1847
|
+
getRangeArr: function(start, end, step) {
|
1848
|
+
var arr = [];
|
1849
|
+
var i;
|
1850
|
+
|
1851
|
+
step = step || 1;
|
1852
|
+
|
1853
|
+
if (start > end) {
|
1854
|
+
for (i = end; i >= start; i -= step) {
|
1855
|
+
arr.push(i);
|
1856
|
+
}
|
1857
|
+
} else {
|
1858
|
+
for (i = start; i <= end; i += step) {
|
1859
|
+
arr.push(i);
|
1860
|
+
}
|
1861
|
+
}
|
1862
|
+
|
1863
|
+
return arr;
|
1864
|
+
},
|
1865
|
+
|
1866
|
+
/**
|
1867
|
+
* Get a target element
|
1868
|
+
* @param {Event} ev Event object
|
1869
|
+
* @returns {HTMLElement} An event target element
|
1870
|
+
*/
|
1871
|
+
getTarget: function(ev) {
|
1872
|
+
return ev.target || ev.srcElement;
|
1873
|
+
},
|
1874
|
+
|
1875
|
+
/**
|
1876
|
+
* send host name
|
1877
|
+
* @ignore
|
1878
|
+
*/
|
1879
|
+
sendHostName: function() {
|
1880
|
+
sendHostname('time-picker', 'UA-129987462-1');
|
1881
|
+
}
|
1882
|
+
};
|
1883
|
+
|
1884
|
+
module.exports = utils;
|
1885
|
+
|
1886
|
+
|
1887
|
+
/***/ }),
|
1888
|
+
/* 16 */
|
1889
|
+
/***/ (function(module, exports, __webpack_require__) {
|
1890
|
+
|
1891
|
+
"use strict";
|
1892
|
+
/**
|
1893
|
+
* @fileoverview Execute the provided callback once for each property of object which actually exist.
|
1894
|
+
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
1895
|
+
*/
|
1896
|
+
|
1897
|
+
|
1898
|
+
|
1899
|
+
/**
|
1900
|
+
* Execute the provided callback once for each property of object which actually exist.
|
1901
|
+
* If the callback function returns false, the loop will be stopped.
|
1902
|
+
* Callback function(iteratee) is invoked with three arguments:
|
1903
|
+
* 1) The value of the property
|
1904
|
+
* 2) The name of the property
|
1905
|
+
* 3) The object being traversed
|
1906
|
+
* @param {Object} obj The object that will be traversed
|
1907
|
+
* @param {function} iteratee Callback function
|
1908
|
+
* @param {Object} [context] Context(this) of callback function
|
1909
|
+
* @memberof module:collection
|
1910
|
+
* @example
|
1911
|
+
* var forEachOwnProperties = require('tui-code-snippet/collection/forEachOwnProperties'); // node, commonjs
|
1912
|
+
*
|
1913
|
+
* var sum = 0;
|
1914
|
+
*
|
1915
|
+
* forEachOwnProperties({a:1,b:2,c:3}, function(value){
|
1916
|
+
* sum += value;
|
1917
|
+
* });
|
1918
|
+
* alert(sum); // 6
|
1919
|
+
*/
|
1920
|
+
function forEachOwnProperties(obj, iteratee, context) {
|
1921
|
+
var key;
|
1922
|
+
|
1923
|
+
context = context || null;
|
1924
|
+
|
1925
|
+
for (key in obj) {
|
1926
|
+
if (obj.hasOwnProperty(key)) {
|
1927
|
+
if (iteratee.call(context, obj[key], key, obj) === false) {
|
1928
|
+
break;
|
1929
|
+
}
|
1930
|
+
}
|
1931
|
+
}
|
1932
|
+
}
|
1933
|
+
|
1934
|
+
module.exports = forEachOwnProperties;
|
1935
|
+
|
1936
|
+
|
1937
|
+
/***/ }),
|
1938
|
+
/* 17 */
|
1939
|
+
/***/ (function(module, exports, __webpack_require__) {
|
1940
|
+
|
1941
|
+
"use strict";
|
1942
|
+
/**
|
1943
|
+
* @fileoverview Get event collection for specific HTML element
|
1944
|
+
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
1945
|
+
*/
|
1946
|
+
|
1947
|
+
|
1948
|
+
|
1949
|
+
var EVENT_KEY = '_feEventKey';
|
1950
|
+
|
1951
|
+
/**
|
1952
|
+
* Get event collection for specific HTML element
|
1953
|
+
* @param {HTMLElement} element - HTML element
|
1954
|
+
* @param {string} type - event type
|
1955
|
+
* @returns {array}
|
1956
|
+
* @private
|
1957
|
+
*/
|
1958
|
+
function safeEvent(element, type) {
|
1959
|
+
var events = element[EVENT_KEY];
|
1960
|
+
var handlers;
|
1961
|
+
|
1962
|
+
if (!events) {
|
1963
|
+
events = element[EVENT_KEY] = {};
|
1964
|
+
}
|
1965
|
+
|
1966
|
+
handlers = events[type];
|
1967
|
+
if (!handlers) {
|
1968
|
+
handlers = events[type] = [];
|
1969
|
+
}
|
1970
|
+
|
1971
|
+
return handlers;
|
1972
|
+
}
|
1973
|
+
|
1974
|
+
module.exports = safeEvent;
|
1975
|
+
|
1976
|
+
|
1977
|
+
/***/ }),
|
1978
|
+
/* 18 */
|
1979
|
+
/***/ (function(module, exports, __webpack_require__) {
|
1980
|
+
|
1981
|
+
"use strict";
|
1982
|
+
/**
|
1983
|
+
* @fileoverview Get HTML element's design classes.
|
1984
|
+
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
1985
|
+
*/
|
1986
|
+
|
1987
|
+
|
1988
|
+
|
1989
|
+
var isUndefined = __webpack_require__(5);
|
1990
|
+
|
1991
|
+
/**
|
1992
|
+
* Get HTML element's design classes.
|
1993
|
+
* @param {(HTMLElement|SVGElement)} element target element
|
1994
|
+
* @returns {string} element css class name
|
1995
|
+
* @memberof module:domUtil
|
1996
|
+
*/
|
1997
|
+
function getClass(element) {
|
1998
|
+
if (!element || !element.className) {
|
1999
|
+
return '';
|
2000
|
+
}
|
2001
|
+
|
2002
|
+
if (isUndefined(element.className.baseVal)) {
|
2003
|
+
return element.className;
|
2004
|
+
}
|
2005
|
+
|
2006
|
+
return element.className.baseVal;
|
2007
|
+
}
|
2008
|
+
|
2009
|
+
module.exports = getClass;
|
2010
|
+
|
2011
|
+
|
2012
|
+
/***/ }),
|
2013
|
+
/* 19 */
|
2014
|
+
/***/ (function(module, exports, __webpack_require__) {
|
2015
|
+
|
2016
|
+
"use strict";
|
2017
|
+
/**
|
2018
|
+
* @fileoverview Set className value
|
2019
|
+
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
2020
|
+
*/
|
2021
|
+
|
2022
|
+
|
2023
|
+
|
2024
|
+
var isArray = __webpack_require__(2);
|
2025
|
+
var isUndefined = __webpack_require__(5);
|
2026
|
+
|
2027
|
+
/**
|
2028
|
+
* Set className value
|
2029
|
+
* @param {(HTMLElement|SVGElement)} element - target element
|
2030
|
+
* @param {(string|string[])} cssClass - class names
|
2031
|
+
* @private
|
2032
|
+
*/
|
2033
|
+
function setClassName(element, cssClass) {
|
2034
|
+
cssClass = isArray(cssClass) ? cssClass.join(' ') : cssClass;
|
2035
|
+
|
2036
|
+
cssClass = cssClass.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
|
2037
|
+
|
2038
|
+
if (isUndefined(element.className.baseVal)) {
|
2039
|
+
element.className = cssClass;
|
2040
|
+
|
2041
|
+
return;
|
2042
|
+
}
|
2043
|
+
|
2044
|
+
element.className.baseVal = cssClass;
|
2045
|
+
}
|
2046
|
+
|
2047
|
+
module.exports = setClassName;
|
2048
|
+
|
2049
|
+
|
2050
|
+
/***/ }),
|
2051
|
+
/* 20 */
|
2052
|
+
/***/ (function(module, exports, __webpack_require__) {
|
2053
|
+
|
2054
|
+
"use strict";
|
2055
|
+
/**
|
2056
|
+
* @fileoverview The entry file of TimePicker components
|
2057
|
+
* @author NHN. FE Development Lab <dl_javascript@nhn.com>
|
2058
|
+
*/
|
2059
|
+
|
2060
|
+
|
2061
|
+
|
2062
|
+
__webpack_require__(21);
|
2063
|
+
|
2064
|
+
module.exports = __webpack_require__(22);
|
2065
|
+
|
2066
|
+
|
2067
|
+
/***/ }),
|
2068
|
+
/* 21 */
|
2069
|
+
/***/ (function(module, exports, __webpack_require__) {
|
2070
|
+
|
2071
|
+
// extracted by mini-css-extract-plugin
|
2072
|
+
|
2073
|
+
/***/ }),
|
2074
|
+
/* 22 */
|
2075
|
+
/***/ (function(module, exports, __webpack_require__) {
|
2076
|
+
|
2077
|
+
"use strict";
|
2078
|
+
/**
|
2079
|
+
* @fileoverview TimePicker component
|
2080
|
+
* @author NHN. FE Development Lab <dl_javascript@nhn.com>
|
2081
|
+
*/
|
2082
|
+
|
2083
|
+
|
2084
|
+
|
2085
|
+
var inArray = __webpack_require__(0);
|
2086
|
+
var forEachArray = __webpack_require__(3);
|
2087
|
+
var CustomEvents = __webpack_require__(8);
|
2088
|
+
var defineClass = __webpack_require__(9);
|
2089
|
+
var extend = __webpack_require__(1);
|
2090
|
+
var on = __webpack_require__(10);
|
2091
|
+
var off = __webpack_require__(11);
|
2092
|
+
var addClass = __webpack_require__(29);
|
2093
|
+
var closest = __webpack_require__(12);
|
2094
|
+
var removeElement = __webpack_require__(13);
|
2095
|
+
var removeClass = __webpack_require__(32);
|
2096
|
+
var isHTMLNode = __webpack_require__(14);
|
2097
|
+
var isNumber = __webpack_require__(33);
|
2098
|
+
|
2099
|
+
var Spinbox = __webpack_require__(34);
|
2100
|
+
var Selectbox = __webpack_require__(38);
|
2101
|
+
var util = __webpack_require__(15);
|
2102
|
+
var localeTexts = __webpack_require__(40);
|
2103
|
+
var tmpl = __webpack_require__(41);
|
2104
|
+
var meridiemTmpl = __webpack_require__(42);
|
2105
|
+
|
2106
|
+
var SELECTOR_HOUR_ELEMENT = '.tui-timepicker-hour';
|
2107
|
+
var SELECTOR_MINUTE_ELEMENT = '.tui-timepicker-minute';
|
2108
|
+
var SELECTOR_MERIDIEM_ELEMENT = '.tui-timepicker-meridiem';
|
2109
|
+
var CLASS_NAME_LEFT_MERIDIEM = 'tui-has-left';
|
2110
|
+
var CLASS_NAME_HIDDEN = 'tui-hidden';
|
2111
|
+
var CLASS_NAME_CHECKED = 'tui-timepicker-meridiem-checked';
|
2112
|
+
var INPUT_TYPE_SPINBOX = 'spinbox';
|
2113
|
+
var INPUT_TYPE_SELECTBOX = 'selectbox';
|
2114
|
+
|
2115
|
+
/**
|
2116
|
+
* Merge default options
|
2117
|
+
* @ignore
|
2118
|
+
* @param {object} options - options
|
2119
|
+
* @returns {object} Merged options
|
2120
|
+
*/
|
2121
|
+
var mergeDefaultOptions = function(options) {
|
2122
|
+
return extend(
|
2123
|
+
{
|
2124
|
+
language: 'en',
|
2125
|
+
initialHour: 0,
|
2126
|
+
initialMinute: 0,
|
2127
|
+
showMeridiem: true,
|
2128
|
+
inputType: 'selectbox',
|
2129
|
+
hourStep: 1,
|
2130
|
+
minuteStep: 1,
|
2131
|
+
meridiemPosition: 'right',
|
2132
|
+
format: 'h:m',
|
2133
|
+
disabledHours: [],
|
2134
|
+
usageStatistics: true
|
2135
|
+
},
|
2136
|
+
options
|
2137
|
+
);
|
2138
|
+
};
|
2139
|
+
|
2140
|
+
/**
|
2141
|
+
* @class
|
2142
|
+
* @param {string|HTMLElement} container - Container element or selector
|
2143
|
+
* @param {Object} [options] - Options for initialization
|
2144
|
+
* @param {number} [options.initialHour = 0] - Initial setting value of hour
|
2145
|
+
* @param {number} [options.initialMinute = 0] - Initial setting value of minute
|
2146
|
+
* @param {number} [options.hourStep = 1] - Step value of hour
|
2147
|
+
* @param {number} [options.minuteStep = 1] - Step value of minute
|
2148
|
+
* @param {string} [options.inputType = 'selectbox'] - 'selectbox' or 'spinbox'
|
2149
|
+
* @param {string} [options.format = 'h:m'] - hour, minute format for display
|
2150
|
+
* @param {boolean} [options.showMeridiem = true] - Show meridiem expression?
|
2151
|
+
* @param {Array} [options.disabledHours = []] - Registered Hours is disabled.
|
2152
|
+
* @param {string} [options.meridiemPosition = 'right'] - Set location of the meridiem element.
|
2153
|
+
* If this option set 'left', the meridiem element is created in front of the hour element.
|
2154
|
+
* @param {string} [options.language = 'en'] Set locale texts
|
2155
|
+
* @param {Boolean} [options.usageStatistics=true|false] send hostname to google analytics [default value is true]
|
2156
|
+
* @example
|
2157
|
+
* var timepicker = new tui.TimePicker('#timepicker-container', {
|
2158
|
+
* initialHour: 15,
|
2159
|
+
* initialMinute: 13,
|
2160
|
+
* inputType: 'selectbox',
|
2161
|
+
* showMeridiem: false
|
2162
|
+
* });
|
2163
|
+
*/
|
2164
|
+
var TimePicker = defineClass(
|
2165
|
+
/** @lends TimePicker.prototype */ {
|
2166
|
+
static: {
|
2167
|
+
/**
|
2168
|
+
* Locale text data
|
2169
|
+
* @type {object}
|
2170
|
+
* @memberof TimePicker
|
2171
|
+
* @static
|
2172
|
+
* @example
|
2173
|
+
* var TimePicker = tui.TimePicker; // or require('tui-time-picker');
|
2174
|
+
*
|
2175
|
+
* TimePicker.localeTexts['customKey'] = {
|
2176
|
+
* am: 'a.m.',
|
2177
|
+
* pm: 'p.m.'
|
2178
|
+
* };
|
2179
|
+
*
|
2180
|
+
* var instance = new tui.TimePicker('#timepicker-container', {
|
2181
|
+
* language: 'customKey',
|
2182
|
+
* });
|
2183
|
+
*/
|
2184
|
+
localeTexts: localeTexts
|
2185
|
+
},
|
2186
|
+
init: function(container, options) {
|
2187
|
+
options = mergeDefaultOptions(options);
|
2188
|
+
|
2189
|
+
/**
|
2190
|
+
* @type {number}
|
2191
|
+
* @private
|
2192
|
+
*/
|
2193
|
+
this._id = util.getUniqueId();
|
2194
|
+
|
2195
|
+
/**
|
2196
|
+
* @type {HTMLElement}
|
2197
|
+
* @private
|
2198
|
+
*/
|
2199
|
+
this._container = isHTMLNode(container)
|
2200
|
+
? container
|
2201
|
+
: document.querySelector(container);
|
2202
|
+
|
2203
|
+
/**
|
2204
|
+
* @type {HTMLElement}
|
2205
|
+
* @private
|
2206
|
+
*/
|
2207
|
+
this._element = null;
|
2208
|
+
|
2209
|
+
/**
|
2210
|
+
* @type {HTMLElement}
|
2211
|
+
* @private
|
2212
|
+
*/
|
2213
|
+
this._meridiemElement = null;
|
2214
|
+
|
2215
|
+
/**
|
2216
|
+
* @type {HTMLElement}
|
2217
|
+
* @private
|
2218
|
+
*/
|
2219
|
+
this._amEl = null;
|
2220
|
+
|
2221
|
+
/**
|
2222
|
+
* @type {HTMLElement}
|
2223
|
+
* @private
|
2224
|
+
*/
|
2225
|
+
this._pmEl = null;
|
2226
|
+
|
2227
|
+
/**
|
2228
|
+
* @type {boolean}
|
2229
|
+
* @private
|
2230
|
+
*/
|
2231
|
+
this._showMeridiem = options.showMeridiem;
|
2232
|
+
|
2233
|
+
/**
|
2234
|
+
* Meridiem postion
|
2235
|
+
* @type {'left'|'right'}
|
2236
|
+
* @private
|
2237
|
+
*/
|
2238
|
+
this._meridiemPosition = options.meridiemPosition;
|
2239
|
+
|
2240
|
+
/**
|
2241
|
+
* @type {Spinbox|Selectbox}
|
2242
|
+
* @private
|
2243
|
+
*/
|
2244
|
+
this._hourInput = null;
|
2245
|
+
|
2246
|
+
/**
|
2247
|
+
* @type {Spinbox|Selectbox}
|
2248
|
+
* @private
|
2249
|
+
*/
|
2250
|
+
this._minuteInput = null;
|
2251
|
+
|
2252
|
+
/**
|
2253
|
+
* @type {number}
|
2254
|
+
* @private
|
2255
|
+
*/
|
2256
|
+
this._hour = options.initialHour;
|
2257
|
+
|
2258
|
+
/**
|
2259
|
+
* @type {number}
|
2260
|
+
* @private
|
2261
|
+
*/
|
2262
|
+
this._minute = options.initialMinute;
|
2263
|
+
|
2264
|
+
/**
|
2265
|
+
* @type {number}
|
2266
|
+
* @private
|
2267
|
+
*/
|
2268
|
+
this._hourStep = options.hourStep;
|
2269
|
+
|
2270
|
+
/**
|
2271
|
+
* @type {number}
|
2272
|
+
* @private
|
2273
|
+
*/
|
2274
|
+
this._minuteStep = options.minuteStep;
|
2275
|
+
|
2276
|
+
/**
|
2277
|
+
* @type {Array}
|
2278
|
+
* @private
|
2279
|
+
*/
|
2280
|
+
this._disabledHours = options.disabledHours;
|
2281
|
+
|
2282
|
+
/**
|
2283
|
+
* TimePicker inputType
|
2284
|
+
* @type {'spinbox'|'selectbox'}
|
2285
|
+
* @private
|
2286
|
+
*/
|
2287
|
+
this._inputType = options.inputType;
|
2288
|
+
|
2289
|
+
/**
|
2290
|
+
* Locale text for meridiem
|
2291
|
+
* @type {string}
|
2292
|
+
* @private
|
2293
|
+
*/
|
2294
|
+
this._localeText = localeTexts[options.language];
|
2295
|
+
|
2296
|
+
/**
|
2297
|
+
* Time format for output
|
2298
|
+
* @type {string}
|
2299
|
+
* @private
|
2300
|
+
*/
|
2301
|
+
this._format = this._getValidTimeFormat(options.format);
|
2302
|
+
|
2303
|
+
this._render();
|
2304
|
+
this._setEvents();
|
2305
|
+
|
2306
|
+
if (options.usageStatistics) {
|
2307
|
+
util.sendHostName();
|
2308
|
+
}
|
2309
|
+
},
|
2310
|
+
|
2311
|
+
/**
|
2312
|
+
* Set event handlers to selectors, container
|
2313
|
+
* @private
|
2314
|
+
*/
|
2315
|
+
_setEvents: function() {
|
2316
|
+
this._hourInput.on('change', this._onChangeTimeInput, this);
|
2317
|
+
this._minuteInput.on('change', this._onChangeTimeInput, this);
|
2318
|
+
|
2319
|
+
if (this._showMeridiem) {
|
2320
|
+
if (this._inputType === INPUT_TYPE_SELECTBOX) {
|
2321
|
+
on(
|
2322
|
+
this._meridiemElement.querySelector('select'),
|
2323
|
+
'change',
|
2324
|
+
this._onChangeMeridiem,
|
2325
|
+
this
|
2326
|
+
);
|
2327
|
+
} else if (this._inputType === INPUT_TYPE_SPINBOX) {
|
2328
|
+
on(this._meridiemElement, 'click', this._onChangeMeridiem, this);
|
2329
|
+
}
|
2330
|
+
}
|
2331
|
+
},
|
2332
|
+
|
2333
|
+
/**
|
2334
|
+
* Remove events
|
2335
|
+
* @private
|
2336
|
+
*/
|
2337
|
+
_removeEvents: function() {
|
2338
|
+
this.off();
|
2339
|
+
|
2340
|
+
this._hourInput.destroy();
|
2341
|
+
this._minuteInput.destroy();
|
2342
|
+
|
2343
|
+
if (this._showMeridiem) {
|
2344
|
+
if (this._inputType === INPUT_TYPE_SELECTBOX) {
|
2345
|
+
off(
|
2346
|
+
this._meridiemElement.querySelector('select'),
|
2347
|
+
'change',
|
2348
|
+
this._onChangeMeridiem,
|
2349
|
+
this
|
2350
|
+
);
|
2351
|
+
} else if (this._inputType === INPUT_TYPE_SPINBOX) {
|
2352
|
+
off(this._meridiemElement, 'click', this._onChangeMeridiem, this);
|
2353
|
+
}
|
2354
|
+
}
|
2355
|
+
},
|
2356
|
+
|
2357
|
+
/**
|
2358
|
+
* Render element
|
2359
|
+
* @private
|
2360
|
+
*/
|
2361
|
+
_render: function() {
|
2362
|
+
var context = {
|
2363
|
+
showMeridiem: this._showMeridiem,
|
2364
|
+
isSpinbox: this._inputType === 'spinbox'
|
2365
|
+
};
|
2366
|
+
|
2367
|
+
if (this._showMeridiem) {
|
2368
|
+
extend(context, {
|
2369
|
+
meridiemElement: this._makeMeridiemHTML()
|
2370
|
+
});
|
2371
|
+
}
|
2372
|
+
|
2373
|
+
if (this._element) {
|
2374
|
+
removeElement(this._element);
|
2375
|
+
}
|
2376
|
+
this._container.innerHTML = tmpl(context);
|
2377
|
+
this._element = this._container.firstChild;
|
2378
|
+
|
2379
|
+
this._renderTimeInputs();
|
2380
|
+
|
2381
|
+
if (this._showMeridiem) {
|
2382
|
+
this._setMeridiemElement();
|
2383
|
+
}
|
2384
|
+
},
|
2385
|
+
|
2386
|
+
/**
|
2387
|
+
* Set meridiem element on timepicker
|
2388
|
+
* @private
|
2389
|
+
*/
|
2390
|
+
_setMeridiemElement: function() {
|
2391
|
+
if (this._meridiemPosition === 'left') {
|
2392
|
+
addClass(this._element, CLASS_NAME_LEFT_MERIDIEM);
|
2393
|
+
}
|
2394
|
+
this._meridiemElement = this._element.querySelector(SELECTOR_MERIDIEM_ELEMENT);
|
2395
|
+
this._amEl = this._meridiemElement.querySelector('[value="AM"]');
|
2396
|
+
this._pmEl = this._meridiemElement.querySelector('[value="PM"]');
|
2397
|
+
this._syncToMeridiemElements();
|
2398
|
+
},
|
2399
|
+
|
2400
|
+
/**
|
2401
|
+
* Make html for meridiem element
|
2402
|
+
* @returns {HTMLElement} Meridiem element
|
2403
|
+
* @private
|
2404
|
+
*/
|
2405
|
+
_makeMeridiemHTML: function() {
|
2406
|
+
var localeText = this._localeText;
|
2407
|
+
|
2408
|
+
return meridiemTmpl({
|
2409
|
+
am: localeText.am,
|
2410
|
+
pm: localeText.pm,
|
2411
|
+
radioId: this._id,
|
2412
|
+
isSpinbox: this._inputType === 'spinbox'
|
2413
|
+
});
|
2414
|
+
},
|
2415
|
+
|
2416
|
+
/**
|
2417
|
+
* Render time selectors
|
2418
|
+
* @private
|
2419
|
+
*/
|
2420
|
+
_renderTimeInputs: function() {
|
2421
|
+
var hour = this._hour;
|
2422
|
+
var showMeridiem = this._showMeridiem;
|
2423
|
+
var hourElement = this._element.querySelector(SELECTOR_HOUR_ELEMENT);
|
2424
|
+
var minuteElement = this._element.querySelector(SELECTOR_MINUTE_ELEMENT);
|
2425
|
+
var BoxComponent = this._inputType.toLowerCase() === 'selectbox' ? Selectbox : Spinbox;
|
2426
|
+
var formatExplode = this._format.split(':');
|
2427
|
+
var hourItems = this._getHourItems();
|
2428
|
+
|
2429
|
+
if (showMeridiem) {
|
2430
|
+
hour = util.getMeridiemHour(hour);
|
2431
|
+
}
|
2432
|
+
|
2433
|
+
this._hourInput = new BoxComponent(hourElement, {
|
2434
|
+
initialValue: hour,
|
2435
|
+
items: hourItems,
|
2436
|
+
format: formatExplode[0],
|
2437
|
+
disabledItems: this._makeDisabledStatItems(hourItems)
|
2438
|
+
});
|
2439
|
+
|
2440
|
+
this._minuteInput = new BoxComponent(minuteElement, {
|
2441
|
+
initialValue: this._minute,
|
2442
|
+
items: this._getMinuteItems(),
|
2443
|
+
format: formatExplode[1]
|
2444
|
+
});
|
2445
|
+
},
|
2446
|
+
|
2447
|
+
_makeDisabledStatItems: function(hourItems) {
|
2448
|
+
var result = [];
|
2449
|
+
var disabledHours = this._disabledHours.concat();
|
2450
|
+
|
2451
|
+
if (this._showMeridiem) {
|
2452
|
+
disabledHours = this._meridiemableTime(disabledHours);
|
2453
|
+
}
|
2454
|
+
|
2455
|
+
forEachArray(hourItems, function(hour) {
|
2456
|
+
result.push(inArray(hour, disabledHours) >= 0);
|
2457
|
+
});
|
2458
|
+
|
2459
|
+
return result;
|
2460
|
+
},
|
2461
|
+
|
2462
|
+
_meridiemableTime: function(disabledHours) {
|
2463
|
+
var diffHour = 0;
|
2464
|
+
var startHour = 0;
|
2465
|
+
var endHour = 11;
|
2466
|
+
var result = [];
|
2467
|
+
|
2468
|
+
if (this._hour >= 12) {
|
2469
|
+
diffHour = 12;
|
2470
|
+
startHour = 12;
|
2471
|
+
endHour = 23;
|
2472
|
+
}
|
2473
|
+
|
2474
|
+
forEachArray(disabledHours, function(hour) {
|
2475
|
+
if (hour >= startHour && hour <= endHour) {
|
2476
|
+
result.push(hour - diffHour === 0 ? 12 : hour - diffHour);
|
2477
|
+
}
|
2478
|
+
});
|
2479
|
+
|
2480
|
+
return result;
|
2481
|
+
},
|
2482
|
+
|
2483
|
+
/**
|
2484
|
+
* Return formatted format.
|
2485
|
+
* @param {string} format - format option
|
2486
|
+
* @returns {string}
|
2487
|
+
* @private
|
2488
|
+
*/
|
2489
|
+
_getValidTimeFormat: function(format) {
|
2490
|
+
if (!format.match(/^[h]{1,2}:[m]{1,2}$/i)) {
|
2491
|
+
return 'h:m';
|
2492
|
+
}
|
2493
|
+
|
2494
|
+
return format.toLowerCase();
|
2495
|
+
},
|
2496
|
+
|
2497
|
+
/**
|
2498
|
+
* Initialize meridiem elements
|
2499
|
+
* @private
|
2500
|
+
*/
|
2501
|
+
_syncToMeridiemElements: function() {
|
2502
|
+
var selectedEl = this._hour >= 12 ? this._pmEl : this._amEl;
|
2503
|
+
var notSelectedEl = selectedEl === this._pmEl ? this._amEl : this._pmEl;
|
2504
|
+
|
2505
|
+
selectedEl.setAttribute('selected', true);
|
2506
|
+
selectedEl.setAttribute('checked', true);
|
2507
|
+
addClass(selectedEl, CLASS_NAME_CHECKED);
|
2508
|
+
notSelectedEl.removeAttribute('selected');
|
2509
|
+
notSelectedEl.removeAttribute('checked');
|
2510
|
+
removeClass(notSelectedEl, CLASS_NAME_CHECKED);
|
2511
|
+
},
|
2512
|
+
|
2513
|
+
/**
|
2514
|
+
* Set values in spinboxes from time
|
2515
|
+
* @private
|
2516
|
+
*/
|
2517
|
+
_syncToInputs: function() {
|
2518
|
+
var hour = this._hour;
|
2519
|
+
var minute = this._minute;
|
2520
|
+
|
2521
|
+
if (this._showMeridiem) {
|
2522
|
+
hour = util.getMeridiemHour(hour);
|
2523
|
+
}
|
2524
|
+
|
2525
|
+
this._hourInput.setValue(hour);
|
2526
|
+
this._minuteInput.setValue(minute);
|
2527
|
+
},
|
2528
|
+
|
2529
|
+
/**
|
2530
|
+
* DOM event handler
|
2531
|
+
* @param {Event} ev - Change event on meridiem element
|
2532
|
+
* @private
|
2533
|
+
*/
|
2534
|
+
_onChangeMeridiem: function(ev) {
|
2535
|
+
var hour = this._hour;
|
2536
|
+
var target = util.getTarget(ev);
|
2537
|
+
|
2538
|
+
if (target.value && closest(target, SELECTOR_MERIDIEM_ELEMENT)) {
|
2539
|
+
hour = this._to24Hour(target.value === 'PM', hour);
|
2540
|
+
this.setTime(hour, this._minute);
|
2541
|
+
this._setDisabledHours();
|
2542
|
+
}
|
2543
|
+
},
|
2544
|
+
|
2545
|
+
/**
|
2546
|
+
* Time change event handler
|
2547
|
+
* @private
|
2548
|
+
*/
|
2549
|
+
_onChangeTimeInput: function() {
|
2550
|
+
var hour = this._hourInput.getValue();
|
2551
|
+
var minute = this._minuteInput.getValue();
|
2552
|
+
var isPM = this._hour >= 12;
|
2553
|
+
|
2554
|
+
if (this._showMeridiem) {
|
2555
|
+
hour = this._to24Hour(isPM, hour);
|
2556
|
+
}
|
2557
|
+
this.setTime(hour, minute);
|
2558
|
+
},
|
2559
|
+
|
2560
|
+
/**
|
2561
|
+
* 12Hour-expression to 24Hour-expression
|
2562
|
+
* @param {boolean} isPM - Is pm?
|
2563
|
+
* @param {number} hour - Hour
|
2564
|
+
* @returns {number}
|
2565
|
+
* @private
|
2566
|
+
*/
|
2567
|
+
_to24Hour: function(isPM, hour) {
|
2568
|
+
hour %= 12;
|
2569
|
+
if (isPM) {
|
2570
|
+
hour += 12;
|
2571
|
+
}
|
2572
|
+
|
2573
|
+
return hour;
|
2574
|
+
},
|
2575
|
+
|
2576
|
+
_setDisabledHours: function() {
|
2577
|
+
var hourItems = this._getHourItems();
|
2578
|
+
var disabledItems = this._makeDisabledStatItems(hourItems);
|
2579
|
+
|
2580
|
+
this._hourInput.setDisabledItems(disabledItems);
|
2581
|
+
},
|
2582
|
+
|
2583
|
+
/**
|
2584
|
+
* Get items of hour
|
2585
|
+
* @returns {array} Hour item list
|
2586
|
+
* @private
|
2587
|
+
*/
|
2588
|
+
_getHourItems: function() {
|
2589
|
+
var step = this._hourStep;
|
2590
|
+
|
2591
|
+
return this._showMeridiem ? util.getRangeArr(1, 12, step) : util.getRangeArr(0, 23, step);
|
2592
|
+
},
|
2593
|
+
|
2594
|
+
/**
|
2595
|
+
* Get items of minute
|
2596
|
+
* @returns {array} Minute item list
|
2597
|
+
* @private
|
2598
|
+
*/
|
2599
|
+
_getMinuteItems: function() {
|
2600
|
+
return util.getRangeArr(0, 59, this._minuteStep);
|
2601
|
+
},
|
2602
|
+
|
2603
|
+
/**
|
2604
|
+
* Whether the hour and minute are in valid items or not
|
2605
|
+
* @param {number} hour - Hour value
|
2606
|
+
* @param {number} minute - Minute value
|
2607
|
+
* @returns {boolean} State
|
2608
|
+
* @private
|
2609
|
+
*/
|
2610
|
+
_validItems: function(hour, minute) {
|
2611
|
+
if (!isNumber(hour) || !isNumber(minute)) {
|
2612
|
+
return false;
|
2613
|
+
}
|
2614
|
+
|
2615
|
+
if (this._showMeridiem) {
|
2616
|
+
hour = util.getMeridiemHour(hour);
|
2617
|
+
}
|
2618
|
+
|
2619
|
+
return (
|
2620
|
+
inArray(hour, this._getHourItems()) > -1 &&
|
2621
|
+
inArray(minute, this._getMinuteItems()) > -1
|
2622
|
+
);
|
2623
|
+
},
|
2624
|
+
|
2625
|
+
/**
|
2626
|
+
* Set step of hour
|
2627
|
+
* @param {array} step - Step to create items of hour
|
2628
|
+
*/
|
2629
|
+
setHourStep: function(step) {
|
2630
|
+
this._hourStep = step;
|
2631
|
+
this._hourInput.fire('changeItems', this._getHourItems());
|
2632
|
+
},
|
2633
|
+
|
2634
|
+
/**
|
2635
|
+
* Get step of hour
|
2636
|
+
* @returns {number} Step of hour
|
2637
|
+
*/
|
2638
|
+
getHourStep: function() {
|
2639
|
+
return this._hourStep;
|
2640
|
+
},
|
2641
|
+
|
2642
|
+
/**
|
2643
|
+
* Set step of minute
|
2644
|
+
* @param {array} step - Step to create items of minute
|
2645
|
+
*/
|
2646
|
+
setMinuteStep: function(step) {
|
2647
|
+
this._minuteStep = step;
|
2648
|
+
this._minuteInput.fire('changeItems', this._getMinuteItems());
|
2649
|
+
},
|
2650
|
+
|
2651
|
+
/**
|
2652
|
+
* Get step of minute
|
2653
|
+
* @returns {number} Step of minute
|
2654
|
+
*/
|
2655
|
+
getMinuteStep: function() {
|
2656
|
+
return this._minuteStep;
|
2657
|
+
},
|
2658
|
+
|
2659
|
+
/**
|
2660
|
+
* Show time picker element
|
2661
|
+
*/
|
2662
|
+
show: function() {
|
2663
|
+
removeClass(this._element, CLASS_NAME_HIDDEN);
|
2664
|
+
},
|
2665
|
+
|
2666
|
+
/**
|
2667
|
+
* Hide time picker element
|
2668
|
+
*/
|
2669
|
+
hide: function() {
|
2670
|
+
addClass(this._element, CLASS_NAME_HIDDEN);
|
2671
|
+
},
|
2672
|
+
|
2673
|
+
/**
|
2674
|
+
* Set hour
|
2675
|
+
* @param {number} hour for time picker - (0~23)
|
2676
|
+
* @returns {boolean} result of set time
|
2677
|
+
*/
|
2678
|
+
setHour: function(hour) {
|
2679
|
+
return this.setTime(hour, this._minute);
|
2680
|
+
},
|
2681
|
+
|
2682
|
+
/**
|
2683
|
+
* Set minute
|
2684
|
+
* @param {number} minute for time picker
|
2685
|
+
* @returns {boolean} result of set time
|
2686
|
+
*/
|
2687
|
+
setMinute: function(minute) {
|
2688
|
+
return this.setTime(this._hour, minute);
|
2689
|
+
},
|
2690
|
+
|
2691
|
+
/**
|
2692
|
+
* Set time
|
2693
|
+
* @param {number} hour for time picker - (0~23)
|
2694
|
+
* @param {number} minute for time picker
|
2695
|
+
*/
|
2696
|
+
setTime: function(hour, minute) {
|
2697
|
+
if (!this._validItems(hour, minute)) {
|
2698
|
+
return;
|
2699
|
+
}
|
2700
|
+
|
2701
|
+
this._hour = hour;
|
2702
|
+
this._minute = minute;
|
2703
|
+
|
2704
|
+
this._syncToInputs();
|
2705
|
+
if (this._showMeridiem) {
|
2706
|
+
this._syncToMeridiemElements();
|
2707
|
+
}
|
2708
|
+
|
2709
|
+
/**
|
2710
|
+
* Change event - TimePicker
|
2711
|
+
* @event TimePicker#change
|
2712
|
+
*/
|
2713
|
+
this.fire('change', {
|
2714
|
+
hour: this._hour,
|
2715
|
+
minute: this._minute
|
2716
|
+
});
|
2717
|
+
},
|
2718
|
+
|
2719
|
+
/**
|
2720
|
+
* Get hour
|
2721
|
+
* @returns {number} hour - (0~23)
|
2722
|
+
*/
|
2723
|
+
getHour: function() {
|
2724
|
+
return this._hour;
|
2725
|
+
},
|
2726
|
+
|
2727
|
+
/**
|
2728
|
+
* Get minute
|
2729
|
+
* @returns {number} minute
|
2730
|
+
*/
|
2731
|
+
getMinute: function() {
|
2732
|
+
return this._minute;
|
2733
|
+
},
|
2734
|
+
|
2735
|
+
/**
|
2736
|
+
* Change locale text of meridiem by language code
|
2737
|
+
* @param {string} language - Language code
|
2738
|
+
*/
|
2739
|
+
changeLanguage: function(language) {
|
2740
|
+
this._localeText = localeTexts[language];
|
2741
|
+
this._render();
|
2742
|
+
},
|
2743
|
+
|
2744
|
+
/**
|
2745
|
+
* Destroy
|
2746
|
+
*/
|
2747
|
+
destroy: function() {
|
2748
|
+
this._removeEvents();
|
2749
|
+
removeElement(this._element);
|
2750
|
+
|
2751
|
+
this._container
|
2752
|
+
= this._showMeridiem
|
2753
|
+
= this._hourInput
|
2754
|
+
= this._minuteInput
|
2755
|
+
= this._hour
|
2756
|
+
= this._minute
|
2757
|
+
= this._inputType
|
2758
|
+
= this._element
|
2759
|
+
= this._meridiemElement
|
2760
|
+
= this._amEl
|
2761
|
+
= this._pmEl
|
2762
|
+
= null;
|
2763
|
+
}
|
2764
|
+
}
|
2765
|
+
);
|
2766
|
+
|
2767
|
+
CustomEvents.mixin(TimePicker);
|
2768
|
+
module.exports = TimePicker;
|
2769
|
+
|
2770
|
+
|
2771
|
+
/***/ }),
|
2772
|
+
/* 23 */
|
2773
|
+
/***/ (function(module, exports, __webpack_require__) {
|
2774
|
+
|
2775
|
+
"use strict";
|
2776
|
+
/**
|
2777
|
+
* @fileoverview Check whether the given variable is existing or not.
|
2778
|
+
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
2779
|
+
*/
|
2780
|
+
|
2781
|
+
|
2782
|
+
|
2783
|
+
var isUndefined = __webpack_require__(5);
|
2784
|
+
var isNull = __webpack_require__(24);
|
2785
|
+
|
2786
|
+
/**
|
2787
|
+
* Check whether the given variable is existing or not.
|
2788
|
+
* If the given variable is not null and not undefined, returns true.
|
2789
|
+
* @param {*} param - Target for checking
|
2790
|
+
* @returns {boolean} Is existy?
|
2791
|
+
* @memberof module:type
|
2792
|
+
* @example
|
2793
|
+
* var isExisty = require('tui-code-snippet/type/isExisty'); // node, commonjs
|
2794
|
+
*
|
2795
|
+
* isExisty(''); //true
|
2796
|
+
* isExisty(0); //true
|
2797
|
+
* isExisty([]); //true
|
2798
|
+
* isExisty({}); //true
|
2799
|
+
* isExisty(null); //false
|
2800
|
+
* isExisty(undefined); //false
|
2801
|
+
*/
|
2802
|
+
function isExisty(param) {
|
2803
|
+
return !isUndefined(param) && !isNull(param);
|
2804
|
+
}
|
2805
|
+
|
2806
|
+
module.exports = isExisty;
|
2807
|
+
|
2808
|
+
|
2809
|
+
/***/ }),
|
2810
|
+
/* 24 */
|
2811
|
+
/***/ (function(module, exports, __webpack_require__) {
|
2812
|
+
|
2813
|
+
"use strict";
|
2814
|
+
/**
|
2815
|
+
* @fileoverview Check whether the given variable is null or not.
|
2816
|
+
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
2817
|
+
*/
|
2818
|
+
|
2819
|
+
|
2820
|
+
|
2821
|
+
/**
|
2822
|
+
* Check whether the given variable is null or not.
|
2823
|
+
* If the given variable(arguments[0]) is null, returns true.
|
2824
|
+
* @param {*} obj - Target for checking
|
2825
|
+
* @returns {boolean} Is null?
|
2826
|
+
* @memberof module:type
|
2827
|
+
*/
|
2828
|
+
function isNull(obj) {
|
2829
|
+
return obj === null;
|
2830
|
+
}
|
2831
|
+
|
2832
|
+
module.exports = isNull;
|
2833
|
+
|
2834
|
+
|
2835
|
+
/***/ }),
|
2836
|
+
/* 25 */
|
2837
|
+
/***/ (function(module, exports, __webpack_require__) {
|
2838
|
+
|
2839
|
+
"use strict";
|
2840
|
+
/**
|
2841
|
+
* @fileoverview Check whether the given variable is an object or not.
|
2842
|
+
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
2843
|
+
*/
|
2844
|
+
|
2845
|
+
|
2846
|
+
|
2847
|
+
/**
|
2848
|
+
* Check whether the given variable is an object or not.
|
2849
|
+
* If the given variable is an object, return true.
|
2850
|
+
* @param {*} obj - Target for checking
|
2851
|
+
* @returns {boolean} Is object?
|
2852
|
+
* @memberof module:type
|
2853
|
+
*/
|
2854
|
+
function isObject(obj) {
|
2855
|
+
return obj === Object(obj);
|
2856
|
+
}
|
2857
|
+
|
2858
|
+
module.exports = isObject;
|
2859
|
+
|
2860
|
+
|
2861
|
+
/***/ }),
|
2862
|
+
/* 26 */
|
2863
|
+
/***/ (function(module, exports, __webpack_require__) {
|
2864
|
+
|
2865
|
+
"use strict";
|
2866
|
+
/**
|
2867
|
+
* @fileoverview Check whether the given variable is a function or not.
|
2868
|
+
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
2869
|
+
*/
|
2870
|
+
|
2871
|
+
|
2872
|
+
|
2873
|
+
/**
|
2874
|
+
* Check whether the given variable is a function or not.
|
2875
|
+
* If the given variable is a function, return true.
|
2876
|
+
* @param {*} obj - Target for checking
|
2877
|
+
* @returns {boolean} Is function?
|
2878
|
+
* @memberof module:type
|
2879
|
+
*/
|
2880
|
+
function isFunction(obj) {
|
2881
|
+
return obj instanceof Function;
|
2882
|
+
}
|
2883
|
+
|
2884
|
+
module.exports = isFunction;
|
2885
|
+
|
2886
|
+
|
2887
|
+
/***/ }),
|
2888
|
+
/* 27 */
|
2889
|
+
/***/ (function(module, exports, __webpack_require__) {
|
2890
|
+
|
2891
|
+
"use strict";
|
2892
|
+
/**
|
2893
|
+
* @fileoverview Provide a simple inheritance in prototype-oriented.
|
2894
|
+
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
2895
|
+
*/
|
2896
|
+
|
2897
|
+
|
2898
|
+
|
2899
|
+
var createObject = __webpack_require__(28);
|
2900
|
+
|
2901
|
+
/**
|
2902
|
+
* Provide a simple inheritance in prototype-oriented.
|
2903
|
+
* Caution :
|
2904
|
+
* Don't overwrite the prototype of child constructor.
|
2905
|
+
*
|
2906
|
+
* @param {function} subType Child constructor
|
2907
|
+
* @param {function} superType Parent constructor
|
2908
|
+
* @memberof module:inheritance
|
2909
|
+
* @example
|
2910
|
+
* var inherit = require('tui-code-snippet/inheritance/inherit'); // node, commonjs
|
2911
|
+
*
|
2912
|
+
* // Parent constructor
|
2913
|
+
* function Animal(leg) {
|
2914
|
+
* this.leg = leg;
|
2915
|
+
* }
|
2916
|
+
* Animal.prototype.growl = function() {
|
2917
|
+
* // ...
|
2918
|
+
* };
|
2919
|
+
*
|
2920
|
+
* // Child constructor
|
2921
|
+
* function Person(name) {
|
2922
|
+
* this.name = name;
|
2923
|
+
* }
|
2924
|
+
*
|
2925
|
+
* // Inheritance
|
2926
|
+
* inherit(Person, Animal);
|
2927
|
+
*
|
2928
|
+
* // After this inheritance, please use only the extending of property.
|
2929
|
+
* // Do not overwrite prototype.
|
2930
|
+
* Person.prototype.walk = function(direction) {
|
2931
|
+
* // ...
|
2932
|
+
* };
|
2933
|
+
*/
|
2934
|
+
function inherit(subType, superType) {
|
2935
|
+
var prototype = createObject(superType.prototype);
|
2936
|
+
prototype.constructor = subType;
|
2937
|
+
subType.prototype = prototype;
|
2938
|
+
}
|
2939
|
+
|
2940
|
+
module.exports = inherit;
|
2941
|
+
|
2942
|
+
|
2943
|
+
/***/ }),
|
2944
|
+
/* 28 */
|
2945
|
+
/***/ (function(module, exports, __webpack_require__) {
|
2946
|
+
|
2947
|
+
"use strict";
|
2948
|
+
/**
|
2949
|
+
* @fileoverview Create a new object with the specified prototype object and properties.
|
2950
|
+
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
2951
|
+
*/
|
2952
|
+
|
2953
|
+
|
2954
|
+
|
2955
|
+
/**
|
2956
|
+
* @module inheritance
|
2957
|
+
*/
|
2958
|
+
|
2959
|
+
/**
|
2960
|
+
* Create a new object with the specified prototype object and properties.
|
2961
|
+
* @param {Object} obj This object will be a prototype of the newly-created object.
|
2962
|
+
* @returns {Object}
|
2963
|
+
* @memberof module:inheritance
|
2964
|
+
*/
|
2965
|
+
function createObject(obj) {
|
2966
|
+
function F() {} // eslint-disable-line require-jsdoc
|
2967
|
+
F.prototype = obj;
|
2968
|
+
|
2969
|
+
return new F();
|
2970
|
+
}
|
2971
|
+
|
2972
|
+
module.exports = createObject;
|
2973
|
+
|
2974
|
+
|
2975
|
+
/***/ }),
|
2976
|
+
/* 29 */
|
2977
|
+
/***/ (function(module, exports, __webpack_require__) {
|
2978
|
+
|
2979
|
+
"use strict";
|
2980
|
+
/**
|
2981
|
+
* @fileoverview Add css class to element
|
2982
|
+
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
2983
|
+
*/
|
2984
|
+
|
2985
|
+
|
2986
|
+
|
2987
|
+
var forEach = __webpack_require__(4);
|
2988
|
+
var inArray = __webpack_require__(0);
|
2989
|
+
var getClass = __webpack_require__(18);
|
2990
|
+
var setClassName = __webpack_require__(19);
|
2991
|
+
|
2992
|
+
/**
|
2993
|
+
* domUtil module
|
2994
|
+
* @module domUtil
|
2995
|
+
*/
|
2996
|
+
|
2997
|
+
/**
|
2998
|
+
* Add css class to element
|
2999
|
+
* @param {(HTMLElement|SVGElement)} element - target element
|
3000
|
+
* @param {...string} cssClass - css classes to add
|
3001
|
+
* @memberof module:domUtil
|
3002
|
+
*/
|
3003
|
+
function addClass(element) {
|
3004
|
+
var cssClass = Array.prototype.slice.call(arguments, 1);
|
3005
|
+
var classList = element.classList;
|
3006
|
+
var newClass = [];
|
3007
|
+
var origin;
|
3008
|
+
|
3009
|
+
if (classList) {
|
3010
|
+
forEach(cssClass, function(name) {
|
3011
|
+
element.classList.add(name);
|
3012
|
+
});
|
3013
|
+
|
3014
|
+
return;
|
3015
|
+
}
|
3016
|
+
|
3017
|
+
origin = getClass(element);
|
3018
|
+
|
3019
|
+
if (origin) {
|
3020
|
+
cssClass = [].concat(origin.split(/\s+/), cssClass);
|
3021
|
+
}
|
3022
|
+
|
3023
|
+
forEach(cssClass, function(cls) {
|
3024
|
+
if (inArray(cls, newClass) < 0) {
|
3025
|
+
newClass.push(cls);
|
3026
|
+
}
|
3027
|
+
});
|
3028
|
+
|
3029
|
+
setClassName(element, newClass);
|
3030
|
+
}
|
3031
|
+
|
3032
|
+
module.exports = addClass;
|
3033
|
+
|
3034
|
+
|
3035
|
+
/***/ }),
|
3036
|
+
/* 30 */
|
3037
|
+
/***/ (function(module, exports, __webpack_require__) {
|
3038
|
+
|
3039
|
+
"use strict";
|
3040
|
+
/**
|
3041
|
+
* @fileoverview Check element match selector
|
3042
|
+
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
3043
|
+
*/
|
3044
|
+
|
3045
|
+
|
3046
|
+
|
3047
|
+
var inArray = __webpack_require__(0);
|
3048
|
+
var toArray = __webpack_require__(31);
|
3049
|
+
|
3050
|
+
var elProto = Element.prototype;
|
3051
|
+
var matchSelector = elProto.matches ||
|
3052
|
+
elProto.webkitMatchesSelector ||
|
3053
|
+
elProto.mozMatchesSelector ||
|
3054
|
+
elProto.msMatchesSelector ||
|
3055
|
+
function(selector) {
|
3056
|
+
var doc = this.document || this.ownerDocument;
|
3057
|
+
|
3058
|
+
return inArray(this, toArray(doc.querySelectorAll(selector))) > -1;
|
3059
|
+
};
|
3060
|
+
|
3061
|
+
/**
|
3062
|
+
* Check element match selector
|
3063
|
+
* @param {HTMLElement} element - element to check
|
3064
|
+
* @param {string} selector - selector to check
|
3065
|
+
* @returns {boolean} is selector matched to element?
|
3066
|
+
* @memberof module:domUtil
|
3067
|
+
*/
|
3068
|
+
function matches(element, selector) {
|
3069
|
+
return matchSelector.call(element, selector);
|
3070
|
+
}
|
3071
|
+
|
3072
|
+
module.exports = matches;
|
3073
|
+
|
3074
|
+
|
3075
|
+
/***/ }),
|
3076
|
+
/* 31 */
|
3077
|
+
/***/ (function(module, exports, __webpack_require__) {
|
3078
|
+
|
3079
|
+
"use strict";
|
3080
|
+
/**
|
3081
|
+
* @fileoverview Transform the Array-like object to Array.
|
3082
|
+
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
3083
|
+
*/
|
3084
|
+
|
3085
|
+
|
3086
|
+
|
3087
|
+
var forEachArray = __webpack_require__(3);
|
3088
|
+
|
3089
|
+
/**
|
3090
|
+
* Transform the Array-like object to Array.
|
3091
|
+
* In low IE (below 8), Array.prototype.slice.call is not perfect. So, try-catch statement is used.
|
3092
|
+
* @param {*} arrayLike Array-like object
|
3093
|
+
* @returns {Array} Array
|
3094
|
+
* @memberof module:collection
|
3095
|
+
* @example
|
3096
|
+
* var toArray = require('tui-code-snippet/collection/toArray'); // node, commonjs
|
3097
|
+
*
|
3098
|
+
* var arrayLike = {
|
3099
|
+
* 0: 'one',
|
3100
|
+
* 1: 'two',
|
3101
|
+
* 2: 'three',
|
3102
|
+
* 3: 'four',
|
3103
|
+
* length: 4
|
3104
|
+
* };
|
3105
|
+
* var result = toArray(arrayLike);
|
3106
|
+
*
|
3107
|
+
* alert(result instanceof Array); // true
|
3108
|
+
* alert(result); // one,two,three,four
|
3109
|
+
*/
|
3110
|
+
function toArray(arrayLike) {
|
3111
|
+
var arr;
|
3112
|
+
try {
|
3113
|
+
arr = Array.prototype.slice.call(arrayLike);
|
3114
|
+
} catch (e) {
|
3115
|
+
arr = [];
|
3116
|
+
forEachArray(arrayLike, function(value) {
|
3117
|
+
arr.push(value);
|
3118
|
+
});
|
3119
|
+
}
|
3120
|
+
|
3121
|
+
return arr;
|
3122
|
+
}
|
3123
|
+
|
3124
|
+
module.exports = toArray;
|
3125
|
+
|
3126
|
+
|
3127
|
+
/***/ }),
|
3128
|
+
/* 32 */
|
3129
|
+
/***/ (function(module, exports, __webpack_require__) {
|
3130
|
+
|
3131
|
+
"use strict";
|
3132
|
+
/**
|
3133
|
+
* @fileoverview Remove css class from element
|
3134
|
+
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
3135
|
+
*/
|
3136
|
+
|
3137
|
+
|
3138
|
+
|
3139
|
+
var forEachArray = __webpack_require__(3);
|
3140
|
+
var inArray = __webpack_require__(0);
|
3141
|
+
var getClass = __webpack_require__(18);
|
3142
|
+
var setClassName = __webpack_require__(19);
|
3143
|
+
|
3144
|
+
/**
|
3145
|
+
* Remove css class from element
|
3146
|
+
* @param {(HTMLElement|SVGElement)} element - target element
|
3147
|
+
* @param {...string} cssClass - css classes to remove
|
3148
|
+
* @memberof module:domUtil
|
3149
|
+
*/
|
3150
|
+
function removeClass(element) {
|
3151
|
+
var cssClass = Array.prototype.slice.call(arguments, 1);
|
3152
|
+
var classList = element.classList;
|
3153
|
+
var origin, newClass;
|
3154
|
+
|
3155
|
+
if (classList) {
|
3156
|
+
forEachArray(cssClass, function(name) {
|
3157
|
+
classList.remove(name);
|
3158
|
+
});
|
3159
|
+
|
3160
|
+
return;
|
3161
|
+
}
|
3162
|
+
|
3163
|
+
origin = getClass(element).split(/\s+/);
|
3164
|
+
newClass = [];
|
3165
|
+
forEachArray(origin, function(name) {
|
3166
|
+
if (inArray(name, cssClass) < 0) {
|
3167
|
+
newClass.push(name);
|
3168
|
+
}
|
3169
|
+
});
|
3170
|
+
|
3171
|
+
setClassName(element, newClass);
|
3172
|
+
}
|
3173
|
+
|
3174
|
+
module.exports = removeClass;
|
3175
|
+
|
3176
|
+
|
3177
|
+
/***/ }),
|
3178
|
+
/* 33 */
|
3179
|
+
/***/ (function(module, exports, __webpack_require__) {
|
3180
|
+
|
3181
|
+
"use strict";
|
3182
|
+
/**
|
3183
|
+
* @fileoverview Check whether the given variable is a number or not.
|
3184
|
+
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
3185
|
+
*/
|
3186
|
+
|
3187
|
+
|
3188
|
+
|
3189
|
+
/**
|
3190
|
+
* Check whether the given variable is a number or not.
|
3191
|
+
* If the given variable is a number, return true.
|
3192
|
+
* @param {*} obj - Target for checking
|
3193
|
+
* @returns {boolean} Is number?
|
3194
|
+
* @memberof module:type
|
3195
|
+
*/
|
3196
|
+
function isNumber(obj) {
|
3197
|
+
return typeof obj === 'number' || obj instanceof Number;
|
3198
|
+
}
|
3199
|
+
|
3200
|
+
module.exports = isNumber;
|
3201
|
+
|
3202
|
+
|
3203
|
+
/***/ }),
|
3204
|
+
/* 34 */
|
3205
|
+
/***/ (function(module, exports, __webpack_require__) {
|
3206
|
+
|
3207
|
+
"use strict";
|
3208
|
+
/**
|
3209
|
+
* @fileoverview Spinbox (in TimePicker)
|
3210
|
+
* @author NHN. FE Development Lab <dl_javascript@nhn.com>
|
3211
|
+
*/
|
3212
|
+
|
3213
|
+
|
3214
|
+
|
3215
|
+
var inArray = __webpack_require__(0);
|
3216
|
+
var forEachArray = __webpack_require__(3);
|
3217
|
+
var CustomEvents = __webpack_require__(8);
|
3218
|
+
var defineClass = __webpack_require__(9);
|
3219
|
+
var extend = __webpack_require__(1);
|
3220
|
+
var on = __webpack_require__(10);
|
3221
|
+
var off = __webpack_require__(11);
|
3222
|
+
var closest = __webpack_require__(12);
|
3223
|
+
var removeElement = __webpack_require__(13);
|
3224
|
+
var isHTMLNode = __webpack_require__(14);
|
3225
|
+
|
3226
|
+
var util = __webpack_require__(15);
|
3227
|
+
var tmpl = __webpack_require__(37);
|
3228
|
+
|
3229
|
+
var SELECTOR_UP_BUTTON = '.tui-timepicker-btn-up';
|
3230
|
+
var SELECTOR_DOWN_BUTTON = '.tui-timepicker-btn-down';
|
3231
|
+
|
3232
|
+
/**
|
3233
|
+
* @class
|
3234
|
+
* @ignore
|
3235
|
+
* @param {String|HTMLElement} container - Container of spinbox or selector
|
3236
|
+
* @param {Object} [options] - Options for initialization
|
3237
|
+
* @param {number} [options.initialValue] - initial setting value
|
3238
|
+
* @param {Array.<number>} items - Items
|
3239
|
+
*/
|
3240
|
+
var Spinbox = defineClass(
|
3241
|
+
/** @lends Spinbox.prototype */ {
|
3242
|
+
init: function(container, options) {
|
3243
|
+
options = extend(
|
3244
|
+
{
|
3245
|
+
items: []
|
3246
|
+
},
|
3247
|
+
options
|
3248
|
+
);
|
3249
|
+
|
3250
|
+
/**
|
3251
|
+
* @type {HTMLElement}
|
3252
|
+
* @private
|
3253
|
+
*/
|
3254
|
+
this._container = isHTMLNode(container)
|
3255
|
+
? container
|
3256
|
+
: document.querySelector(container);
|
3257
|
+
|
3258
|
+
/**
|
3259
|
+
* Spinbox element
|
3260
|
+
* @type {HTMLElement}
|
3261
|
+
* @private
|
3262
|
+
*/
|
3263
|
+
this._element = null;
|
3264
|
+
|
3265
|
+
/**
|
3266
|
+
* @type {HTMLElement}
|
3267
|
+
* @private
|
3268
|
+
*/
|
3269
|
+
this._inputElement = null;
|
3270
|
+
|
3271
|
+
/**
|
3272
|
+
* Spinbox value items
|
3273
|
+
* @type {Array.<number>}
|
3274
|
+
* @private
|
3275
|
+
*/
|
3276
|
+
this._items = options.items;
|
3277
|
+
|
3278
|
+
/**
|
3279
|
+
* Selectbox disabled items info
|
3280
|
+
* @type {Array.<number>}
|
3281
|
+
* @private
|
3282
|
+
*/
|
3283
|
+
this._disabledItems = options.disabledItems || [];
|
3284
|
+
|
3285
|
+
/**
|
3286
|
+
* @type {number}
|
3287
|
+
* @private
|
3288
|
+
*/
|
3289
|
+
this._selectedIndex = Math.max(0, inArray(options.initialValue, this._items));
|
3290
|
+
|
3291
|
+
/**
|
3292
|
+
* Time format for output
|
3293
|
+
* @type {string}
|
3294
|
+
* @private
|
3295
|
+
*/
|
3296
|
+
this._format = options.format;
|
3297
|
+
|
3298
|
+
this._render();
|
3299
|
+
this._setEvents();
|
3300
|
+
},
|
3301
|
+
|
3302
|
+
/**
|
3303
|
+
* Render spinbox
|
3304
|
+
* @private
|
3305
|
+
*/
|
3306
|
+
_render: function() {
|
3307
|
+
var index = inArray(this.getValue(), this._items);
|
3308
|
+
var context;
|
3309
|
+
|
3310
|
+
if (this._disabledItems[index]) {
|
3311
|
+
this._selectedIndex = this._findEnabledIndex();
|
3312
|
+
}
|
3313
|
+
context = {
|
3314
|
+
maxLength: this._getMaxLength(),
|
3315
|
+
initialValue: this.getValue(),
|
3316
|
+
format: this._format,
|
3317
|
+
formatTime: util.formatTime
|
3318
|
+
};
|
3319
|
+
|
3320
|
+
this._container.innerHTML = tmpl(context);
|
3321
|
+
this._element = this._container.firstChild;
|
3322
|
+
this._inputElement = this._element.querySelector('input');
|
3323
|
+
},
|
3324
|
+
|
3325
|
+
/**
|
3326
|
+
* Find the index of the enabled item
|
3327
|
+
* @returns {number} - find selected index
|
3328
|
+
* @private
|
3329
|
+
*/
|
3330
|
+
_findEnabledIndex: function() {
|
3331
|
+
return inArray(false, this._disabledItems);
|
3332
|
+
},
|
3333
|
+
|
3334
|
+
/**
|
3335
|
+
* Returns maxlength of value
|
3336
|
+
* @returns {number}
|
3337
|
+
* @private
|
3338
|
+
*/
|
3339
|
+
_getMaxLength: function() {
|
3340
|
+
var lengths = [];
|
3341
|
+
|
3342
|
+
forEachArray(this._items, function(item) {
|
3343
|
+
lengths.push(String(item).length);
|
3344
|
+
});
|
3345
|
+
|
3346
|
+
return Math.max.apply(null, lengths);
|
3347
|
+
},
|
3348
|
+
|
3349
|
+
/**
|
3350
|
+
* Set disabledItems
|
3351
|
+
* @param {object} disabledItems - disabled status of items
|
3352
|
+
*/
|
3353
|
+
setDisabledItems: function(disabledItems) {
|
3354
|
+
this._disabledItems = disabledItems;
|
3355
|
+
this._changeToInputValue();
|
3356
|
+
},
|
3357
|
+
|
3358
|
+
/**
|
3359
|
+
* Assign default events to up/down button
|
3360
|
+
* @private
|
3361
|
+
*/
|
3362
|
+
_setEvents: function() {
|
3363
|
+
on(this._container, 'click', this._onClickHandler, this);
|
3364
|
+
on(this._inputElement, 'keydown', this._onKeydownInputElement, this);
|
3365
|
+
on(this._inputElement, 'change', this._onChangeHandler, this);
|
3366
|
+
|
3367
|
+
this.on(
|
3368
|
+
'changeItems',
|
3369
|
+
function(items) {
|
3370
|
+
this._items = items;
|
3371
|
+
this._render();
|
3372
|
+
},
|
3373
|
+
this
|
3374
|
+
);
|
3375
|
+
},
|
3376
|
+
|
3377
|
+
/**
|
3378
|
+
* Remove events to up/down button
|
3379
|
+
* @private
|
3380
|
+
*/
|
3381
|
+
_removeEvents: function() {
|
3382
|
+
this.off();
|
3383
|
+
|
3384
|
+
off(this._container, 'click', this._onClickHandler, this);
|
3385
|
+
off(this._inputElement, 'keydown', this._onKeydownInputElement, this);
|
3386
|
+
off(this._inputElement, 'change', this._onChangeHandler, this);
|
3387
|
+
},
|
3388
|
+
|
3389
|
+
/**
|
3390
|
+
* Click event handler
|
3391
|
+
* @param {Event} ev - Change event on up/down buttons.
|
3392
|
+
*/
|
3393
|
+
_onClickHandler: function(ev) {
|
3394
|
+
var target = util.getTarget(ev);
|
3395
|
+
|
3396
|
+
if (closest(target, SELECTOR_DOWN_BUTTON)) {
|
3397
|
+
this._setNextValue(true);
|
3398
|
+
} else if (closest(target, SELECTOR_UP_BUTTON)) {
|
3399
|
+
this._setNextValue(false);
|
3400
|
+
}
|
3401
|
+
},
|
3402
|
+
|
3403
|
+
/**
|
3404
|
+
* Set input value
|
3405
|
+
* @param {boolean} isDown - From down-action?
|
3406
|
+
* @private
|
3407
|
+
*/
|
3408
|
+
_setNextValue: function(isDown) {
|
3409
|
+
var index = this._selectedIndex;
|
3410
|
+
|
3411
|
+
if (isDown) {
|
3412
|
+
index = index ? index - 1 : this._items.length - 1;
|
3413
|
+
} else {
|
3414
|
+
index = index < this._items.length - 1 ? index + 1 : 0;
|
3415
|
+
}
|
3416
|
+
|
3417
|
+
if (this._disabledItems[index]) {
|
3418
|
+
this._selectedIndex = index;
|
3419
|
+
this._setNextValue(isDown);
|
3420
|
+
} else {
|
3421
|
+
this.setValue(this._items[index]);
|
3422
|
+
}
|
3423
|
+
},
|
3424
|
+
|
3425
|
+
/**
|
3426
|
+
* DOM(Input element) Keydown Event handler
|
3427
|
+
* @param {Event} ev event-object
|
3428
|
+
* @private
|
3429
|
+
*/
|
3430
|
+
_onKeydownInputElement: function(ev) {
|
3431
|
+
var keyCode = ev.which || ev.keyCode;
|
3432
|
+
var isDown;
|
3433
|
+
|
3434
|
+
if (closest(util.getTarget(ev), 'input')) {
|
3435
|
+
switch (keyCode) {
|
3436
|
+
case 38:
|
3437
|
+
isDown = false;
|
3438
|
+
break;
|
3439
|
+
case 40:
|
3440
|
+
isDown = true;
|
3441
|
+
break;
|
3442
|
+
default:
|
3443
|
+
return;
|
3444
|
+
}
|
3445
|
+
|
3446
|
+
this._setNextValue(isDown);
|
3447
|
+
}
|
3448
|
+
},
|
3449
|
+
|
3450
|
+
/**
|
3451
|
+
* DOM(Input element) Change Event handler
|
3452
|
+
* @param {Event} ev Change event on an input element.
|
3453
|
+
* @private
|
3454
|
+
*/
|
3455
|
+
_onChangeHandler: function(ev) {
|
3456
|
+
if (closest(util.getTarget(ev), 'input')) {
|
3457
|
+
this._changeToInputValue();
|
3458
|
+
}
|
3459
|
+
},
|
3460
|
+
|
3461
|
+
/**
|
3462
|
+
* Change value to input-box if it is valid.
|
3463
|
+
* @private
|
3464
|
+
*/
|
3465
|
+
_changeToInputValue: function() {
|
3466
|
+
var newValue = Number(this._inputElement.value);
|
3467
|
+
var newIndex = inArray(newValue, this._items);
|
3468
|
+
|
3469
|
+
if (this._disabledItems[newIndex]) {
|
3470
|
+
newIndex = this._findEnabledIndex();
|
3471
|
+
newValue = this._items[newIndex];
|
3472
|
+
} else if (newIndex === this._selectedIndex) {
|
3473
|
+
return;
|
3474
|
+
}
|
3475
|
+
|
3476
|
+
if (newIndex === -1) {
|
3477
|
+
this.setValue(this._items[this._selectedIndex]);
|
3478
|
+
} else {
|
3479
|
+
this._selectedIndex = newIndex;
|
3480
|
+
this.fire('change', {
|
3481
|
+
value: newValue
|
3482
|
+
});
|
3483
|
+
}
|
3484
|
+
},
|
3485
|
+
|
3486
|
+
/**
|
3487
|
+
* Set value to input-box.
|
3488
|
+
* @param {number} value - Value
|
3489
|
+
*/
|
3490
|
+
setValue: function(value) {
|
3491
|
+
this._inputElement.value = util.formatTime(value, this._format);
|
3492
|
+
this._changeToInputValue();
|
3493
|
+
},
|
3494
|
+
|
3495
|
+
/**
|
3496
|
+
* Returns current value
|
3497
|
+
* @returns {number}
|
3498
|
+
*/
|
3499
|
+
getValue: function() {
|
3500
|
+
return this._items[this._selectedIndex];
|
3501
|
+
},
|
3502
|
+
|
3503
|
+
/**
|
3504
|
+
* Destory
|
3505
|
+
*/
|
3506
|
+
destroy: function() {
|
3507
|
+
this._removeEvents();
|
3508
|
+
removeElement(this._element);
|
3509
|
+
this._container = this._element = this._inputElement = this._items = this._selectedIndex = null;
|
3510
|
+
}
|
3511
|
+
}
|
3512
|
+
);
|
3513
|
+
|
3514
|
+
CustomEvents.mixin(Spinbox);
|
3515
|
+
module.exports = Spinbox;
|
3516
|
+
|
3517
|
+
|
3518
|
+
/***/ }),
|
3519
|
+
/* 35 */
|
3520
|
+
/***/ (function(module, exports, __webpack_require__) {
|
3521
|
+
|
3522
|
+
"use strict";
|
3523
|
+
/**
|
3524
|
+
* @fileoverview Send hostname on DOMContentLoaded.
|
3525
|
+
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
3526
|
+
*/
|
3527
|
+
|
3528
|
+
|
3529
|
+
|
3530
|
+
var isUndefined = __webpack_require__(5);
|
3531
|
+
var imagePing = __webpack_require__(36);
|
3532
|
+
|
3533
|
+
var ms7days = 7 * 24 * 60 * 60 * 1000;
|
3534
|
+
|
3535
|
+
/**
|
3536
|
+
* Check if the date has passed 7 days
|
3537
|
+
* @param {number} date - milliseconds
|
3538
|
+
* @returns {boolean}
|
3539
|
+
* @private
|
3540
|
+
*/
|
3541
|
+
function isExpired(date) {
|
3542
|
+
var now = new Date().getTime();
|
3543
|
+
|
3544
|
+
return now - date > ms7days;
|
3545
|
+
}
|
3546
|
+
|
3547
|
+
/**
|
3548
|
+
* Send hostname on DOMContentLoaded.
|
3549
|
+
* To prevent hostname set tui.usageStatistics to false.
|
3550
|
+
* @param {string} appName - application name
|
3551
|
+
* @param {string} trackingId - GA tracking ID
|
3552
|
+
* @ignore
|
3553
|
+
*/
|
3554
|
+
function sendHostname(appName, trackingId) {
|
3555
|
+
var url = 'https://www.google-analytics.com/collect';
|
3556
|
+
var hostname = location.hostname;
|
3557
|
+
var hitType = 'event';
|
3558
|
+
var eventCategory = 'use';
|
3559
|
+
var applicationKeyForStorage = 'TOAST UI ' + appName + ' for ' + hostname + ': Statistics';
|
3560
|
+
var date = window.localStorage.getItem(applicationKeyForStorage);
|
3561
|
+
|
3562
|
+
// skip if the flag is defined and is set to false explicitly
|
3563
|
+
if (!isUndefined(window.tui) && window.tui.usageStatistics === false) {
|
3564
|
+
return;
|
3565
|
+
}
|
3566
|
+
|
3567
|
+
// skip if not pass seven days old
|
3568
|
+
if (date && !isExpired(date)) {
|
3569
|
+
return;
|
3570
|
+
}
|
3571
|
+
|
3572
|
+
window.localStorage.setItem(applicationKeyForStorage, new Date().getTime());
|
3573
|
+
|
3574
|
+
setTimeout(function() {
|
3575
|
+
if (document.readyState === 'interactive' || document.readyState === 'complete') {
|
3576
|
+
imagePing(url, {
|
3577
|
+
v: 1,
|
3578
|
+
t: hitType,
|
3579
|
+
tid: trackingId,
|
3580
|
+
cid: hostname,
|
3581
|
+
dp: hostname,
|
3582
|
+
dh: appName,
|
3583
|
+
el: appName,
|
3584
|
+
ec: eventCategory
|
3585
|
+
});
|
3586
|
+
}
|
3587
|
+
}, 1000);
|
3588
|
+
}
|
3589
|
+
|
3590
|
+
module.exports = sendHostname;
|
3591
|
+
|
3592
|
+
|
3593
|
+
/***/ }),
|
3594
|
+
/* 36 */
|
3595
|
+
/***/ (function(module, exports, __webpack_require__) {
|
3596
|
+
|
3597
|
+
"use strict";
|
3598
|
+
/**
|
3599
|
+
* @fileoverview Request image ping.
|
3600
|
+
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
3601
|
+
*/
|
3602
|
+
|
3603
|
+
|
3604
|
+
|
3605
|
+
var forEachOwnProperties = __webpack_require__(16);
|
3606
|
+
|
3607
|
+
/**
|
3608
|
+
* @module request
|
3609
|
+
*/
|
3610
|
+
|
3611
|
+
/**
|
3612
|
+
* Request image ping.
|
3613
|
+
* @param {String} url url for ping request
|
3614
|
+
* @param {Object} trackingInfo infos for make query string
|
3615
|
+
* @returns {HTMLElement}
|
3616
|
+
* @memberof module:request
|
3617
|
+
* @example
|
3618
|
+
* var imagePing = require('tui-code-snippet/request/imagePing'); // node, commonjs
|
3619
|
+
*
|
3620
|
+
* imagePing('https://www.google-analytics.com/collect', {
|
3621
|
+
* v: 1,
|
3622
|
+
* t: 'event',
|
3623
|
+
* tid: 'trackingid',
|
3624
|
+
* cid: 'cid',
|
3625
|
+
* dp: 'dp',
|
3626
|
+
* dh: 'dh'
|
3627
|
+
* });
|
3628
|
+
*/
|
3629
|
+
function imagePing(url, trackingInfo) {
|
3630
|
+
var trackingElement = document.createElement('img');
|
3631
|
+
var queryString = '';
|
3632
|
+
forEachOwnProperties(trackingInfo, function(value, key) {
|
3633
|
+
queryString += '&' + key + '=' + value;
|
3634
|
+
});
|
3635
|
+
queryString = queryString.substring(1);
|
3636
|
+
|
3637
|
+
trackingElement.src = url + '?' + queryString;
|
3638
|
+
|
3639
|
+
trackingElement.style.display = 'none';
|
3640
|
+
document.body.appendChild(trackingElement);
|
3641
|
+
document.body.removeChild(trackingElement);
|
3642
|
+
|
3643
|
+
return trackingElement;
|
3644
|
+
}
|
3645
|
+
|
3646
|
+
module.exports = imagePing;
|
3647
|
+
|
3648
|
+
|
3649
|
+
/***/ }),
|
3650
|
+
/* 37 */
|
3651
|
+
/***/ (function(module, exports, __webpack_require__) {
|
3652
|
+
|
3653
|
+
"use strict";
|
3654
|
+
|
3655
|
+
|
3656
|
+
var template = __webpack_require__(7);
|
3657
|
+
|
3658
|
+
module.exports = function(context) {
|
3659
|
+
var source =
|
3660
|
+
'<div class="tui-timepicker-btn-area">'
|
3661
|
+
+ ' <input type="text" class="tui-timepicker-spinbox-input"'
|
3662
|
+
+ ' maxlength="{{maxLength}}"'
|
3663
|
+
+ ' size="{{maxLength}}"'
|
3664
|
+
+ ' value="{{formatTime initialValue format}}"'
|
3665
|
+
+ ' aria-label="TimePicker spinbox value">'
|
3666
|
+
+ ' <button type="button" class="tui-timepicker-btn tui-timepicker-btn-up">'
|
3667
|
+
+ ' <span class="tui-ico-t-btn">Increase</span>'
|
3668
|
+
+ ' </button>'
|
3669
|
+
+ ' <button type="button" class="tui-timepicker-btn tui-timepicker-btn-down">'
|
3670
|
+
+ ' <span class="tui-ico-t-btn">Decrease</span>'
|
3671
|
+
+ ' </button>'
|
3672
|
+
+ '</div>';
|
3673
|
+
|
3674
|
+
return template(source, context);
|
3675
|
+
};
|
3676
|
+
|
3677
|
+
|
3678
|
+
|
3679
|
+
/***/ }),
|
3680
|
+
/* 38 */
|
3681
|
+
/***/ (function(module, exports, __webpack_require__) {
|
3682
|
+
|
3683
|
+
"use strict";
|
3684
|
+
/**
|
3685
|
+
* @fileoverview Selectbox (in TimePicker)
|
3686
|
+
* @author NHN. FE Development Lab <dl_javascript@nhn.com>
|
3687
|
+
*/
|
3688
|
+
|
3689
|
+
|
3690
|
+
|
3691
|
+
var inArray = __webpack_require__(0);
|
3692
|
+
var CustomEvents = __webpack_require__(8);
|
3693
|
+
var defineClass = __webpack_require__(9);
|
3694
|
+
var extend = __webpack_require__(1);
|
3695
|
+
var on = __webpack_require__(10);
|
3696
|
+
var off = __webpack_require__(11);
|
3697
|
+
var closest = __webpack_require__(12);
|
3698
|
+
var removeElement = __webpack_require__(13);
|
3699
|
+
var isHTMLNode = __webpack_require__(14);
|
3700
|
+
|
3701
|
+
var util = __webpack_require__(15);
|
3702
|
+
var tmpl = __webpack_require__(39);
|
3703
|
+
|
3704
|
+
/**
|
3705
|
+
* @class
|
3706
|
+
* @ignore
|
3707
|
+
* @param {string|HTMLElement} container - Container element or selector
|
3708
|
+
* @param {object} options - Options
|
3709
|
+
* @param {Array.<number>} options.items - Items
|
3710
|
+
* @param {number} options.initialValue - Initial value
|
3711
|
+
*/
|
3712
|
+
var Selectbox = defineClass(
|
3713
|
+
/** @lends Selectbox.prototype */ {
|
3714
|
+
init: function(container, options) {
|
3715
|
+
options = extend(
|
3716
|
+
{
|
3717
|
+
items: []
|
3718
|
+
},
|
3719
|
+
options
|
3720
|
+
);
|
3721
|
+
|
3722
|
+
/**
|
3723
|
+
* Container element
|
3724
|
+
* @type {HTMLElement}
|
3725
|
+
* @private
|
3726
|
+
*/
|
3727
|
+
this._container = isHTMLNode(container)
|
3728
|
+
? container
|
3729
|
+
: document.querySelector(container);
|
3730
|
+
|
3731
|
+
/**
|
3732
|
+
* Selectbox items
|
3733
|
+
* @type {Array.<number>}
|
3734
|
+
* @private
|
3735
|
+
*/
|
3736
|
+
this._items = options.items || [];
|
3737
|
+
|
3738
|
+
/**
|
3739
|
+
* Selectbox disabled items info
|
3740
|
+
* @type {Array.<number>}
|
3741
|
+
* @private
|
3742
|
+
*/
|
3743
|
+
this._disabledItems = options.disabledItems || [];
|
3744
|
+
|
3745
|
+
/**
|
3746
|
+
* Selected index
|
3747
|
+
* @type {number}
|
3748
|
+
* @private
|
3749
|
+
*/
|
3750
|
+
this._selectedIndex = Math.max(0, inArray(options.initialValue, this._items));
|
3751
|
+
|
3752
|
+
/**
|
3753
|
+
* Time format for output
|
3754
|
+
* @type {string}
|
3755
|
+
* @private
|
3756
|
+
*/
|
3757
|
+
this._format = options.format;
|
3758
|
+
|
3759
|
+
/**
|
3760
|
+
* Select element
|
3761
|
+
* @type {HTMLElement}
|
3762
|
+
* @private
|
3763
|
+
*/
|
3764
|
+
this._element = null;
|
3765
|
+
|
3766
|
+
this._render();
|
3767
|
+
this._setEvents();
|
3768
|
+
},
|
3769
|
+
|
3770
|
+
/**
|
3771
|
+
* Render selectbox
|
3772
|
+
* @private
|
3773
|
+
*/
|
3774
|
+
_render: function() {
|
3775
|
+
var context;
|
3776
|
+
|
3777
|
+
this._changeEnabledIndex();
|
3778
|
+
context = {
|
3779
|
+
items: this._items,
|
3780
|
+
format: this._format,
|
3781
|
+
initialValue: this.getValue(),
|
3782
|
+
disabledItems: this._disabledItems,
|
3783
|
+
formatTime: util.formatTime,
|
3784
|
+
equals: function(a, b) {
|
3785
|
+
return a === b;
|
3786
|
+
}
|
3787
|
+
};
|
3788
|
+
|
3789
|
+
if (this._element) {
|
3790
|
+
this._removeElement();
|
3791
|
+
}
|
3792
|
+
|
3793
|
+
this._container.innerHTML = tmpl(context);
|
3794
|
+
this._element = this._container.firstChild;
|
3795
|
+
on(this._element, 'change', this._onChangeHandler, this);
|
3796
|
+
},
|
3797
|
+
|
3798
|
+
/**
|
3799
|
+
* Change the index of the enabled item
|
3800
|
+
* @private
|
3801
|
+
*/
|
3802
|
+
_changeEnabledIndex: function() {
|
3803
|
+
var index = inArray(this.getValue(), this._items);
|
3804
|
+
if (this._disabledItems[index]) {
|
3805
|
+
this._selectedIndex = inArray(false, this._disabledItems);
|
3806
|
+
}
|
3807
|
+
},
|
3808
|
+
|
3809
|
+
/**
|
3810
|
+
* Set disabledItems
|
3811
|
+
* @param {object} disabledItems - disabled status of items
|
3812
|
+
* @private
|
3813
|
+
*/
|
3814
|
+
setDisabledItems: function(disabledItems) {
|
3815
|
+
this._disabledItems = disabledItems;
|
3816
|
+
this._render();
|
3817
|
+
},
|
3818
|
+
|
3819
|
+
/**
|
3820
|
+
* Set events
|
3821
|
+
* @private
|
3822
|
+
*/
|
3823
|
+
_setEvents: function() {
|
3824
|
+
this.on(
|
3825
|
+
'changeItems',
|
3826
|
+
function(items) {
|
3827
|
+
this._items = items;
|
3828
|
+
this._render();
|
3829
|
+
},
|
3830
|
+
this
|
3831
|
+
);
|
3832
|
+
},
|
3833
|
+
|
3834
|
+
/**
|
3835
|
+
* Remove events
|
3836
|
+
* @private
|
3837
|
+
*/
|
3838
|
+
_removeEvents: function() {
|
3839
|
+
this.off();
|
3840
|
+
},
|
3841
|
+
|
3842
|
+
/**
|
3843
|
+
* Remove element
|
3844
|
+
* @private
|
3845
|
+
*/
|
3846
|
+
_removeElement: function() {
|
3847
|
+
off(this._element, 'change', this._onChangeHandler, this);
|
3848
|
+
removeElement(this._element);
|
3849
|
+
},
|
3850
|
+
|
3851
|
+
/**
|
3852
|
+
* Change event handler
|
3853
|
+
* @param {Event} ev Change event on a select element.
|
3854
|
+
* @private
|
3855
|
+
*/
|
3856
|
+
_onChangeHandler: function(ev) {
|
3857
|
+
if (closest(util.getTarget(ev), 'select')) {
|
3858
|
+
this._setNewValue();
|
3859
|
+
}
|
3860
|
+
},
|
3861
|
+
|
3862
|
+
/**
|
3863
|
+
* Set new value
|
3864
|
+
* @private
|
3865
|
+
*/
|
3866
|
+
_setNewValue: function() {
|
3867
|
+
var newValue = Number(this._element.value);
|
3868
|
+
this._selectedIndex = inArray(newValue, this._items);
|
3869
|
+
this.fire('change', {
|
3870
|
+
value: newValue
|
3871
|
+
});
|
3872
|
+
},
|
3873
|
+
|
3874
|
+
/**
|
3875
|
+
* Returns current value
|
3876
|
+
* @returns {number}
|
3877
|
+
*/
|
3878
|
+
getValue: function() {
|
3879
|
+
return this._items[this._selectedIndex];
|
3880
|
+
},
|
3881
|
+
|
3882
|
+
/**
|
3883
|
+
* Set value
|
3884
|
+
* @param {number} value - New value
|
3885
|
+
*/
|
3886
|
+
setValue: function(value) {
|
3887
|
+
var newIndex = inArray(value, this._items);
|
3888
|
+
|
3889
|
+
if (newIndex > -1 && newIndex !== this._selectedIndex) {
|
3890
|
+
this._selectedIndex = newIndex;
|
3891
|
+
this._element.value = value;
|
3892
|
+
this._setNewValue();
|
3893
|
+
}
|
3894
|
+
},
|
3895
|
+
|
3896
|
+
/**
|
3897
|
+
* Destory
|
3898
|
+
*/
|
3899
|
+
destroy: function() {
|
3900
|
+
this._removeEvents();
|
3901
|
+
this._removeElement();
|
3902
|
+
this._container = this._items = this._selectedIndex = this._element = null;
|
3903
|
+
}
|
3904
|
+
}
|
3905
|
+
);
|
3906
|
+
|
3907
|
+
CustomEvents.mixin(Selectbox);
|
3908
|
+
module.exports = Selectbox;
|
3909
|
+
|
3910
|
+
|
3911
|
+
/***/ }),
|
3912
|
+
/* 39 */
|
3913
|
+
/***/ (function(module, exports, __webpack_require__) {
|
3914
|
+
|
3915
|
+
"use strict";
|
3916
|
+
|
3917
|
+
|
3918
|
+
var template = __webpack_require__(7);
|
3919
|
+
|
3920
|
+
module.exports = function(context) {
|
3921
|
+
var source =
|
3922
|
+
'<select class="tui-timepicker-select" aria-label="Time">'
|
3923
|
+
+ ' {{each items}}'
|
3924
|
+
+ ' {{if equals initialValue @this}}'
|
3925
|
+
+ ' <option value="{{@this}}" selected {{if disabledItems[@index]}}disabled{{/if}}>{{formatTime @this format}}</option>'
|
3926
|
+
+ ' {{else}}'
|
3927
|
+
+ ' <option value="{{@this}}" {{if disabledItems[@index]}}disabled{{/if}}>{{formatTime @this format}}</option>'
|
3928
|
+
+ ' {{/if}}'
|
3929
|
+
+ ' {{/each}}'
|
3930
|
+
+ '</select>';
|
3931
|
+
|
3932
|
+
return template(source, context);
|
3933
|
+
};
|
3934
|
+
|
3935
|
+
|
3936
|
+
|
3937
|
+
/***/ }),
|
3938
|
+
/* 40 */
|
3939
|
+
/***/ (function(module, exports, __webpack_require__) {
|
3940
|
+
|
3941
|
+
"use strict";
|
3942
|
+
/**
|
3943
|
+
* @fileoverview Default locale texts
|
3944
|
+
* @author NHN. FE Development Lab <dl_javascript@nhn.com>
|
3945
|
+
*/
|
3946
|
+
|
3947
|
+
|
3948
|
+
|
3949
|
+
module.exports = {
|
3950
|
+
en: {
|
3951
|
+
am: 'AM',
|
3952
|
+
pm: 'PM'
|
3953
|
+
},
|
3954
|
+
ko: {
|
3955
|
+
am: '오전',
|
3956
|
+
pm: '오후'
|
3957
|
+
}
|
3958
|
+
};
|
3959
|
+
|
3960
|
+
|
3961
|
+
/***/ }),
|
3962
|
+
/* 41 */
|
3963
|
+
/***/ (function(module, exports, __webpack_require__) {
|
3964
|
+
|
3965
|
+
"use strict";
|
3966
|
+
|
3967
|
+
|
3968
|
+
var template = __webpack_require__(7);
|
3969
|
+
|
3970
|
+
module.exports = function(context) {
|
3971
|
+
var source =
|
3972
|
+
'<div class="tui-timepicker">'
|
3973
|
+
+ ' <div class="tui-timepicker-body">'
|
3974
|
+
+ ' <div class="tui-timepicker-row">'
|
3975
|
+
+ ' {{if isSpinbox}}'
|
3976
|
+
+ ' <div class="tui-timepicker-column tui-timepicker-spinbox tui-timepicker-hour"></div>'
|
3977
|
+
+ ' <span class="tui-timepicker-column tui-timepicker-colon"><span class="tui-ico-colon">:</span></span>'
|
3978
|
+
+ ' <div class="tui-timepicker-column tui-timepicker-spinbox tui-timepicker-minute"></div>'
|
3979
|
+
+ ' {{if showMeridiem}}'
|
3980
|
+
+ ' {{meridiemElement}}'
|
3981
|
+
+ ' {{/if}}'
|
3982
|
+
+ ' {{else}}'
|
3983
|
+
+ ' <div class="tui-timepicker-column tui-timepicker-selectbox tui-timepicker-hour"></div>'
|
3984
|
+
+ ' <span class="tui-timepicker-column tui-timepicker-colon"><span class="tui-ico-colon">:</span></span>'
|
3985
|
+
+ ' <div class="tui-timepicker-column tui-timepicker-selectbox tui-timepicker-minute"></div>'
|
3986
|
+
+ ' {{if showMeridiem}}'
|
3987
|
+
+ ' {{meridiemElement}}'
|
3988
|
+
+ ' {{/if}}'
|
3989
|
+
+ ' {{/if}}'
|
3990
|
+
+ ' </div>'
|
3991
|
+
+ ' </div>'
|
3992
|
+
+ '</div>';
|
3993
|
+
|
3994
|
+
return template(source, context);
|
3995
|
+
};
|
3996
|
+
|
3997
|
+
|
3998
|
+
|
3999
|
+
/***/ }),
|
4000
|
+
/* 42 */
|
4001
|
+
/***/ (function(module, exports, __webpack_require__) {
|
4002
|
+
|
4003
|
+
"use strict";
|
4004
|
+
|
4005
|
+
|
4006
|
+
var template = __webpack_require__(7);
|
4007
|
+
|
4008
|
+
module.exports = function(context) {
|
4009
|
+
var source =
|
4010
|
+
'{{if isSpinbox}}'
|
4011
|
+
+ ' <div class="tui-timepicker-column tui-timepicker-checkbox tui-timepicker-meridiem">'
|
4012
|
+
+ ' <div class="tui-timepicker-check-area">'
|
4013
|
+
+ ' <ul class="tui-timepicker-check-lst">'
|
4014
|
+
+ ' <li class="tui-timepicker-check">'
|
4015
|
+
+ ' <div class="tui-timepicker-radio">'
|
4016
|
+
+ ' <input type="radio"'
|
4017
|
+
+ ' name="optionsRadios-{{radioId}}"'
|
4018
|
+
+ ' value="AM"'
|
4019
|
+
+ ' class="tui-timepicker-radio-am"'
|
4020
|
+
+ ' id="tui-timepicker-radio-am-{{radioId}}">'
|
4021
|
+
+ ' <label for="tui-timepicker-radio-am-{{radioId}}" class="tui-timepicker-radio-label">'
|
4022
|
+
+ ' <span class="tui-timepicker-input-radio"></span>{{am}}'
|
4023
|
+
+ ' </label>'
|
4024
|
+
+ ' </div>'
|
4025
|
+
+ ' </li>'
|
4026
|
+
+ ' <li class="tui-timepicker-check">'
|
4027
|
+
+ ' <div class="tui-timepicker-radio">'
|
4028
|
+
+ ' <input type="radio"'
|
4029
|
+
+ ' name="optionsRadios-{{radioId}}"'
|
4030
|
+
+ ' value="PM"'
|
4031
|
+
+ ' class="tui-timepicker-radio-pm"'
|
4032
|
+
+ ' id="tui-timepicker-radio-pm-{{radioId}}">'
|
4033
|
+
+ ' <label for="tui-timepicker-radio-pm-{{radioId}}" class="tui-timepicker-radio-label">'
|
4034
|
+
+ ' <span class="tui-timepicker-input-radio"></span>{{pm}}'
|
4035
|
+
+ ' </label>'
|
4036
|
+
+ ' </div>'
|
4037
|
+
+ ' </li>'
|
4038
|
+
+ ' </ul>'
|
4039
|
+
+ ' </div>'
|
4040
|
+
+ ' </div>'
|
4041
|
+
+ '{{else}}'
|
4042
|
+
+ ' <div class="tui-timepicker-column tui-timepicker-selectbox tui-is-add-picker tui-timepicker-meridiem">'
|
4043
|
+
+ ' <select class="tui-timepicker-select" aria-label="AM/PM">'
|
4044
|
+
+ ' <option value="AM">{{am}}</option>'
|
4045
|
+
+ ' <option value="PM">{{pm}}</option>'
|
4046
|
+
+ ' </select>'
|
4047
|
+
+ ' </div>'
|
4048
|
+
+ '{{/if}}';
|
4049
|
+
|
4050
|
+
return template(source, context);
|
4051
|
+
};
|
4052
|
+
|
4053
|
+
|
4054
|
+
|
4055
|
+
/***/ })
|
4056
|
+
/******/ ]);
|
4057
|
+
});
|