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.
@@ -0,0 +1,4358 @@
1
+ /*!
2
+ * tui-code-snippet.js
3
+ * @version 1.5.2
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["util"] = factory();
14
+ else
15
+ root["tui"] = root["tui"] || {}, root["tui"]["util"] = factory();
16
+ })(this, 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
+ /******/ exports: {},
31
+ /******/ id: moduleId,
32
+ /******/ loaded: false
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.loaded = 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
+ /******/ // __webpack_public_path__
53
+ /******/ __webpack_require__.p = "dist";
54
+
55
+ /******/ // Load entry module and return exports
56
+ /******/ return __webpack_require__(0);
57
+ /******/ })
58
+ /************************************************************************/
59
+ /******/ ([
60
+ /* 0 */
61
+ /***/ (function(module, exports, __webpack_require__) {
62
+
63
+ 'use strict';
64
+
65
+ /**
66
+ * @fileoverview
67
+ * @author NHN.
68
+ * FE Development Lab <dl_javascript@nhn.com>
69
+ * @namespace tui.util
70
+ * @example
71
+ * // node, commonjs
72
+ * var util = require('tui-code-snippet');
73
+ * @example
74
+ * // distribution file, script
75
+ * <script src='path-to/tui-code-snippt.js'></script>
76
+ * <script>
77
+ * var util = tui.util;
78
+ * <script>
79
+ */
80
+ var util = {};
81
+ var object = __webpack_require__(1);
82
+ var extend = object.extend;
83
+
84
+ extend(util, object);
85
+ extend(util, __webpack_require__(3));
86
+ extend(util, __webpack_require__(2));
87
+ extend(util, __webpack_require__(4));
88
+ extend(util, __webpack_require__(5));
89
+ extend(util, __webpack_require__(6));
90
+ extend(util, __webpack_require__(7));
91
+ extend(util, __webpack_require__(8));
92
+ extend(util, __webpack_require__(9));
93
+
94
+ util.browser = __webpack_require__(10);
95
+ util.popup = __webpack_require__(11);
96
+ util.formatDate = __webpack_require__(12);
97
+ util.defineClass = __webpack_require__(13);
98
+ util.defineModule = __webpack_require__(14);
99
+ util.defineNamespace = __webpack_require__(15);
100
+ util.CustomEvents = __webpack_require__(16);
101
+ util.Enum = __webpack_require__(17);
102
+ util.ExMap = __webpack_require__(18);
103
+ util.HashMap = __webpack_require__(20);
104
+ util.Map = __webpack_require__(19);
105
+
106
+ module.exports = util;
107
+
108
+
109
+ /***/ }),
110
+ /* 1 */
111
+ /***/ (function(module, exports, __webpack_require__) {
112
+
113
+ /**
114
+ * @fileoverview This module has some functions for handling a plain object, json.
115
+ * @author NHN.
116
+ * FE Development Lab <dl_javascript@nhn.com>
117
+ */
118
+
119
+ 'use strict';
120
+
121
+ var type = __webpack_require__(2);
122
+ var array = __webpack_require__(3);
123
+
124
+ /**
125
+ * The last id of stamp
126
+ * @type {number}
127
+ * @private
128
+ */
129
+ var lastId = 0;
130
+
131
+ /**
132
+ * Extend the target object from other objects.
133
+ * @param {object} target - Object that will be extended
134
+ * @param {...object} objects - Objects as sources
135
+ * @returns {object} Extended object
136
+ * @memberof tui.util
137
+ */
138
+ function extend(target, objects) { // eslint-disable-line no-unused-vars
139
+ var hasOwnProp = Object.prototype.hasOwnProperty;
140
+ var source, prop, i, len;
141
+
142
+ for (i = 1, len = arguments.length; i < len; i += 1) {
143
+ source = arguments[i];
144
+ for (prop in source) {
145
+ if (hasOwnProp.call(source, prop)) {
146
+ target[prop] = source[prop];
147
+ }
148
+ }
149
+ }
150
+
151
+ return target;
152
+ }
153
+
154
+ /**
155
+ * Assign a unique id to an object
156
+ * @param {object} obj - Object that will be assigned id.
157
+ * @returns {number} Stamped id
158
+ * @memberof tui.util
159
+ */
160
+ function stamp(obj) {
161
+ if (!obj.__fe_id) {
162
+ lastId += 1;
163
+ obj.__fe_id = lastId; // eslint-disable-line camelcase
164
+ }
165
+
166
+ return obj.__fe_id;
167
+ }
168
+
169
+ /**
170
+ * Verify whether an object has a stamped id or not.
171
+ * @param {object} obj - adjusted object
172
+ * @returns {boolean}
173
+ * @memberof tui.util
174
+ */
175
+ function hasStamp(obj) {
176
+ return type.isExisty(pick(obj, '__fe_id'));
177
+ }
178
+
179
+ /**
180
+ * Reset the last id of stamp
181
+ * @private
182
+ */
183
+ function resetLastId() {
184
+ lastId = 0;
185
+ }
186
+
187
+ /**
188
+ * Return a key-list(array) of a given object
189
+ * @param {object} obj - Object from which a key-list will be extracted
190
+ * @returns {Array} A key-list(array)
191
+ * @memberof tui.util
192
+ */
193
+ function keys(obj) {
194
+ var keyArray = [];
195
+ var key;
196
+
197
+ for (key in obj) {
198
+ if (obj.hasOwnProperty(key)) {
199
+ keyArray.push(key);
200
+ }
201
+ }
202
+
203
+ return keyArray;
204
+ }
205
+
206
+ /**
207
+ * Return the equality for multiple objects(jsonObjects).<br>
208
+ * See {@link http://stackoverflow.com/questions/1068834/object-comparison-in-javascript}
209
+ * @param {...object} object - Multiple objects for comparing.
210
+ * @returns {boolean} Equality
211
+ * @memberof tui.util
212
+ * @example
213
+ * //-- #1. Get Module --//
214
+ * var util = require('tui-code-snippet'); // node, commonjs
215
+ * var util = tui.util; // distribution file
216
+ *
217
+ * //-- #2. Use property --//
218
+ * var jsonObj1 = {name:'milk', price: 1000};
219
+ * var jsonObj2 = {name:'milk', price: 1000};
220
+ * var jsonObj3 = {name:'milk', price: 1000};
221
+ * util.compareJSON(jsonObj1, jsonObj2, jsonObj3); // true
222
+ *
223
+ * var jsonObj4 = {name:'milk', price: 1000};
224
+ * var jsonObj5 = {name:'beer', price: 3000};
225
+ * util.compareJSON(jsonObj4, jsonObj5); // false
226
+ */
227
+ function compareJSON(object) {
228
+ var argsLen = arguments.length;
229
+ var i = 1;
230
+
231
+ if (argsLen < 1) {
232
+ return true;
233
+ }
234
+
235
+ for (; i < argsLen; i += 1) {
236
+ if (!isSameObject(object, arguments[i])) {
237
+ return false;
238
+ }
239
+ }
240
+
241
+ return true;
242
+ }
243
+
244
+ /**
245
+ * @param {*} x - object to compare
246
+ * @param {*} y - object to compare
247
+ * @returns {boolean} - whether object x and y is same or not
248
+ * @private
249
+ */
250
+ function isSameObject(x, y) { // eslint-disable-line complexity
251
+ var leftChain = [];
252
+ var rightChain = [];
253
+ var p;
254
+
255
+ // remember that NaN === NaN returns false
256
+ // and isNaN(undefined) returns true
257
+ if (isNaN(x) &&
258
+ isNaN(y) &&
259
+ type.isNumber(x) &&
260
+ type.isNumber(y)) {
261
+ return true;
262
+ }
263
+
264
+ // Compare primitives and functions.
265
+ // Check if both arguments link to the same object.
266
+ // Especially useful on step when comparing prototypes
267
+ if (x === y) {
268
+ return true;
269
+ }
270
+
271
+ // Works in case when functions are created in constructor.
272
+ // Comparing dates is a common scenario. Another built-ins?
273
+ // We can even handle functions passed across iframes
274
+ if ((type.isFunction(x) && type.isFunction(y)) ||
275
+ (x instanceof Date && y instanceof Date) ||
276
+ (x instanceof RegExp && y instanceof RegExp) ||
277
+ (x instanceof String && y instanceof String) ||
278
+ (x instanceof Number && y instanceof Number)) {
279
+ return x.toString() === y.toString();
280
+ }
281
+
282
+ // At last checking prototypes as good a we can
283
+ if (!(x instanceof Object && y instanceof Object)) {
284
+ return false;
285
+ }
286
+
287
+ if (x.isPrototypeOf(y) ||
288
+ y.isPrototypeOf(x) ||
289
+ x.constructor !== y.constructor ||
290
+ x.prototype !== y.prototype) {
291
+ return false;
292
+ }
293
+
294
+ // check for infinitive linking loops
295
+ if (array.inArray(x, leftChain) > -1 ||
296
+ array.inArray(y, rightChain) > -1) {
297
+ return false;
298
+ }
299
+
300
+ // Quick checking of one object beeing a subset of another.
301
+ for (p in y) {
302
+ if (y.hasOwnProperty(p) !== x.hasOwnProperty(p)) {
303
+ return false;
304
+ } else if (typeof y[p] !== typeof x[p]) {
305
+ return false;
306
+ }
307
+ }
308
+
309
+ // This for loop executes comparing with hasOwnProperty() and typeof for each property in 'x' object,
310
+ // and verifying equality for x[property] and y[property].
311
+ for (p in x) {
312
+ if (y.hasOwnProperty(p) !== x.hasOwnProperty(p)) {
313
+ return false;
314
+ } else if (typeof y[p] !== typeof x[p]) {
315
+ return false;
316
+ }
317
+
318
+ if (typeof (x[p]) === 'object' || typeof (x[p]) === 'function') {
319
+ leftChain.push(x);
320
+ rightChain.push(y);
321
+
322
+ if (!isSameObject(x[p], y[p])) {
323
+ return false;
324
+ }
325
+
326
+ leftChain.pop();
327
+ rightChain.pop();
328
+ } else if (x[p] !== y[p]) {
329
+ return false;
330
+ }
331
+ }
332
+
333
+ return true;
334
+ }
335
+ /* eslint-enable complexity */
336
+
337
+ /**
338
+ * Retrieve a nested item from the given object/array
339
+ * @param {object|Array} obj - Object for retrieving
340
+ * @param {...string|number} paths - Paths of property
341
+ * @returns {*} Value
342
+ * @memberof tui.util
343
+ * @example
344
+ * //-- #1. Get Module --//
345
+ * var util = require('tui-code-snippet'); // node, commonjs
346
+ * var util = tui.util; // distribution file
347
+ *
348
+ * //-- #2. Use property --//
349
+ * var obj = {
350
+ * 'key1': 1,
351
+ * 'nested' : {
352
+ * 'key1': 11,
353
+ * 'nested': {
354
+ * 'key1': 21
355
+ * }
356
+ * }
357
+ * };
358
+ * util.pick(obj, 'nested', 'nested', 'key1'); // 21
359
+ * util.pick(obj, 'nested', 'nested', 'key2'); // undefined
360
+ *
361
+ * var arr = ['a', 'b', 'c'];
362
+ * util.pick(arr, 1); // 'b'
363
+ */
364
+ function pick(obj, paths) { // eslint-disable-line no-unused-vars
365
+ var args = arguments;
366
+ var target = args[0];
367
+ var i = 1;
368
+ var length = args.length;
369
+
370
+ for (; i < length; i += 1) {
371
+ if (type.isUndefined(target) ||
372
+ type.isNull(target)) {
373
+ return;
374
+ }
375
+
376
+ target = target[args[i]];
377
+ }
378
+
379
+ return target; // eslint-disable-line consistent-return
380
+ }
381
+
382
+ module.exports = {
383
+ extend: extend,
384
+ stamp: stamp,
385
+ hasStamp: hasStamp,
386
+ resetLastId: resetLastId,
387
+ keys: Object.prototype.keys || keys,
388
+ compareJSON: compareJSON,
389
+ pick: pick
390
+ };
391
+
392
+
393
+ /***/ }),
394
+ /* 2 */
395
+ /***/ (function(module, exports) {
396
+
397
+ /**
398
+ * @fileoverview This module provides some functions to check the type of variable
399
+ * @author NHN.
400
+ * FE Development Lab <dl_javascript@nhn.com>
401
+ */
402
+
403
+ 'use strict';
404
+
405
+ var toString = Object.prototype.toString;
406
+
407
+ /**
408
+ * Check whether the given variable is existing or not.<br>
409
+ * If the given variable is not null and not undefined, returns true.
410
+ * @param {*} param - Target for checking
411
+ * @returns {boolean} Is existy?
412
+ * @memberof tui.util
413
+ * @example
414
+ * //-- #1. Get Module --//
415
+ * var util = require('tui-code-snippet'); // node, commonjs
416
+ * var util = tui.util; // distribution file
417
+ *
418
+ * //-- #2. Use property --//
419
+ * util.isExisty(''); //true
420
+ * util.isExisty(0); //true
421
+ * util.isExisty([]); //true
422
+ * util.isExisty({}); //true
423
+ * util.isExisty(null); //false
424
+ * util.isExisty(undefined); //false
425
+ */
426
+ function isExisty(param) {
427
+ return !isUndefined(param) && !isNull(param);
428
+ }
429
+
430
+ /**
431
+ * Check whether the given variable is undefined or not.<br>
432
+ * If the given variable is undefined, returns true.
433
+ * @param {*} obj - Target for checking
434
+ * @returns {boolean} Is undefined?
435
+ * @memberof tui.util
436
+ */
437
+ function isUndefined(obj) {
438
+ return obj === undefined; // eslint-disable-line no-undefined
439
+ }
440
+
441
+ /**
442
+ * Check whether the given variable is null or not.<br>
443
+ * If the given variable(arguments[0]) is null, returns true.
444
+ * @param {*} obj - Target for checking
445
+ * @returns {boolean} Is null?
446
+ * @memberof tui.util
447
+ */
448
+ function isNull(obj) {
449
+ return obj === null;
450
+ }
451
+
452
+ /**
453
+ * Check whether the given variable is truthy or not.<br>
454
+ * If the given variable is not null or not undefined or not false, returns true.<br>
455
+ * (It regards 0 as true)
456
+ * @param {*} obj - Target for checking
457
+ * @returns {boolean} Is truthy?
458
+ * @memberof tui.util
459
+ */
460
+ function isTruthy(obj) {
461
+ return isExisty(obj) && obj !== false;
462
+ }
463
+
464
+ /**
465
+ * Check whether the given variable is falsy or not.<br>
466
+ * If the given variable is null or undefined or false, returns true.
467
+ * @param {*} obj - Target for checking
468
+ * @returns {boolean} Is falsy?
469
+ * @memberof tui.util
470
+ */
471
+ function isFalsy(obj) {
472
+ return !isTruthy(obj);
473
+ }
474
+
475
+ /**
476
+ * Check whether the given variable is an arguments object or not.<br>
477
+ * If the given variable is an arguments object, return true.
478
+ * @param {*} obj - Target for checking
479
+ * @returns {boolean} Is arguments?
480
+ * @memberof tui.util
481
+ */
482
+ function isArguments(obj) {
483
+ var result = isExisty(obj) &&
484
+ ((toString.call(obj) === '[object Arguments]') || !!obj.callee);
485
+
486
+ return result;
487
+ }
488
+
489
+ /**
490
+ * Check whether the given variable is an instance of Array or not.<br>
491
+ * If the given variable is an instance of Array, return true.
492
+ * @param {*} obj - Target for checking
493
+ * @returns {boolean} Is array instance?
494
+ * @memberof tui.util
495
+ */
496
+ function isArray(obj) {
497
+ return obj instanceof Array;
498
+ }
499
+
500
+ /**
501
+ * Check whether the given variable is an object or not.<br>
502
+ * If the given variable is an object, return true.
503
+ * @param {*} obj - Target for checking
504
+ * @returns {boolean} Is object?
505
+ * @memberof tui.util
506
+ */
507
+ function isObject(obj) {
508
+ return obj === Object(obj);
509
+ }
510
+
511
+ /**
512
+ * Check whether the given variable is a function or not.<br>
513
+ * If the given variable is a function, return true.
514
+ * @param {*} obj - Target for checking
515
+ * @returns {boolean} Is function?
516
+ * @memberof tui.util
517
+ */
518
+ function isFunction(obj) {
519
+ return obj instanceof Function;
520
+ }
521
+
522
+ /**
523
+ * Check whether the given variable is a number or not.<br>
524
+ * If the given variable is a number, return true.
525
+ * @param {*} obj - Target for checking
526
+ * @returns {boolean} Is number?
527
+ * @memberof tui.util
528
+ */
529
+ function isNumber(obj) {
530
+ return typeof obj === 'number' || obj instanceof Number;
531
+ }
532
+
533
+ /**
534
+ * Check whether the given variable is a string or not.<br>
535
+ * If the given variable is a string, return true.
536
+ * @param {*} obj - Target for checking
537
+ * @returns {boolean} Is string?
538
+ * @memberof tui.util
539
+ */
540
+ function isString(obj) {
541
+ return typeof obj === 'string' || obj instanceof String;
542
+ }
543
+
544
+ /**
545
+ * Check whether the given variable is a boolean or not.<br>
546
+ * If the given variable is a boolean, return true.
547
+ * @param {*} obj - Target for checking
548
+ * @returns {boolean} Is boolean?
549
+ * @memberof tui.util
550
+ */
551
+ function isBoolean(obj) {
552
+ return typeof obj === 'boolean' || obj instanceof Boolean;
553
+ }
554
+
555
+ /**
556
+ * Check whether the given variable is an instance of Array or not.<br>
557
+ * If the given variable is an instance of Array, return true.<br>
558
+ * (It is used for multiple frame environments)
559
+ * @param {*} obj - Target for checking
560
+ * @returns {boolean} Is an instance of array?
561
+ * @memberof tui.util
562
+ */
563
+ function isArraySafe(obj) {
564
+ return toString.call(obj) === '[object Array]';
565
+ }
566
+
567
+ /**
568
+ * Check whether the given variable is a function or not.<br>
569
+ * If the given variable is a function, return true.<br>
570
+ * (It is used for multiple frame environments)
571
+ * @param {*} obj - Target for checking
572
+ * @returns {boolean} Is a function?
573
+ * @memberof tui.util
574
+ */
575
+ function isFunctionSafe(obj) {
576
+ return toString.call(obj) === '[object Function]';
577
+ }
578
+
579
+ /**
580
+ * Check whether the given variable is a number or not.<br>
581
+ * If the given variable is a number, return true.<br>
582
+ * (It is used for multiple frame environments)
583
+ * @param {*} obj - Target for checking
584
+ * @returns {boolean} Is a number?
585
+ * @memberof tui.util
586
+ */
587
+ function isNumberSafe(obj) {
588
+ return toString.call(obj) === '[object Number]';
589
+ }
590
+
591
+ /**
592
+ * Check whether the given variable is a string or not.<br>
593
+ * If the given variable is a string, return true.<br>
594
+ * (It is used for multiple frame environments)
595
+ * @param {*} obj - Target for checking
596
+ * @returns {boolean} Is a string?
597
+ * @memberof tui.util
598
+ */
599
+ function isStringSafe(obj) {
600
+ return toString.call(obj) === '[object String]';
601
+ }
602
+
603
+ /**
604
+ * Check whether the given variable is a boolean or not.<br>
605
+ * If the given variable is a boolean, return true.<br>
606
+ * (It is used for multiple frame environments)
607
+ * @param {*} obj - Target for checking
608
+ * @returns {boolean} Is a boolean?
609
+ * @memberof tui.util
610
+ */
611
+ function isBooleanSafe(obj) {
612
+ return toString.call(obj) === '[object Boolean]';
613
+ }
614
+
615
+ /**
616
+ * Check whether the given variable is a instance of HTMLNode or not.<br>
617
+ * If the given variables is a instance of HTMLNode, return true.
618
+ * @param {*} html - Target for checking
619
+ * @returns {boolean} Is HTMLNode ?
620
+ * @memberof tui.util
621
+ */
622
+ function isHTMLNode(html) {
623
+ if (typeof HTMLElement === 'object') {
624
+ return (html && (html instanceof HTMLElement || !!html.nodeType));
625
+ }
626
+
627
+ return !!(html && html.nodeType);
628
+ }
629
+
630
+ /**
631
+ * Check whether the given variable is a HTML tag or not.<br>
632
+ * If the given variables is a HTML tag, return true.
633
+ * @param {*} html - Target for checking
634
+ * @returns {Boolean} Is HTML tag?
635
+ * @memberof tui.util
636
+ */
637
+ function isHTMLTag(html) {
638
+ if (typeof HTMLElement === 'object') {
639
+ return (html && (html instanceof HTMLElement));
640
+ }
641
+
642
+ return !!(html && html.nodeType && html.nodeType === 1);
643
+ }
644
+
645
+ /**
646
+ * Check whether the given variable is empty(null, undefined, or empty array, empty object) or not.<br>
647
+ * If the given variables is empty, return true.
648
+ * @param {*} obj - Target for checking
649
+ * @returns {boolean} Is empty?
650
+ * @memberof tui.util
651
+ */
652
+ function isEmpty(obj) {
653
+ if (!isExisty(obj) || _isEmptyString(obj)) {
654
+ return true;
655
+ }
656
+
657
+ if (isArray(obj) || isArguments(obj)) {
658
+ return obj.length === 0;
659
+ }
660
+
661
+ if (isObject(obj) && !isFunction(obj)) {
662
+ return !_hasOwnProperty(obj);
663
+ }
664
+
665
+ return true;
666
+ }
667
+
668
+ /**
669
+ * Check whether given argument is empty string
670
+ * @param {*} obj - Target for checking
671
+ * @returns {boolean} whether given argument is empty string
672
+ * @memberof tui.util
673
+ * @private
674
+ */
675
+ function _isEmptyString(obj) {
676
+ return isString(obj) && obj === '';
677
+ }
678
+
679
+ /**
680
+ * Check whether given argument has own property
681
+ * @param {Object} obj - Target for checking
682
+ * @returns {boolean} - whether given argument has own property
683
+ * @memberof tui.util
684
+ * @private
685
+ */
686
+ function _hasOwnProperty(obj) {
687
+ var key;
688
+ for (key in obj) {
689
+ if (obj.hasOwnProperty(key)) {
690
+ return true;
691
+ }
692
+ }
693
+
694
+ return false;
695
+ }
696
+
697
+ /**
698
+ * Check whether the given variable is not empty
699
+ * (not null, not undefined, or not empty array, not empty object) or not.<br>
700
+ * If the given variables is not empty, return true.
701
+ * @param {*} obj - Target for checking
702
+ * @returns {boolean} Is not empty?
703
+ * @memberof tui.util
704
+ */
705
+ function isNotEmpty(obj) {
706
+ return !isEmpty(obj);
707
+ }
708
+
709
+ /**
710
+ * Check whether the given variable is an instance of Date or not.<br>
711
+ * If the given variables is an instance of Date, return true.
712
+ * @param {*} obj - Target for checking
713
+ * @returns {boolean} Is an instance of Date?
714
+ * @memberof tui.util
715
+ */
716
+ function isDate(obj) {
717
+ return obj instanceof Date;
718
+ }
719
+
720
+ /**
721
+ * Check whether the given variable is an instance of Date or not.<br>
722
+ * If the given variables is an instance of Date, return true.<br>
723
+ * (It is used for multiple frame environments)
724
+ * @param {*} obj - Target for checking
725
+ * @returns {boolean} Is an instance of Date?
726
+ * @memberof tui.util
727
+ */
728
+ function isDateSafe(obj) {
729
+ return toString.call(obj) === '[object Date]';
730
+ }
731
+
732
+ module.exports = {
733
+ isExisty: isExisty,
734
+ isUndefined: isUndefined,
735
+ isNull: isNull,
736
+ isTruthy: isTruthy,
737
+ isFalsy: isFalsy,
738
+ isArguments: isArguments,
739
+ isArray: isArray,
740
+ isArraySafe: isArraySafe,
741
+ isObject: isObject,
742
+ isFunction: isFunction,
743
+ isFunctionSafe: isFunctionSafe,
744
+ isNumber: isNumber,
745
+ isNumberSafe: isNumberSafe,
746
+ isDate: isDate,
747
+ isDateSafe: isDateSafe,
748
+ isString: isString,
749
+ isStringSafe: isStringSafe,
750
+ isBoolean: isBoolean,
751
+ isBooleanSafe: isBooleanSafe,
752
+ isHTMLNode: isHTMLNode,
753
+ isHTMLTag: isHTMLTag,
754
+ isEmpty: isEmpty,
755
+ isNotEmpty: isNotEmpty
756
+ };
757
+
758
+
759
+ /***/ }),
760
+ /* 3 */
761
+ /***/ (function(module, exports, __webpack_require__) {
762
+
763
+ /**
764
+ * @fileoverview This module has some functions for handling array.
765
+ * @author NHN.
766
+ * FE Development Lab <dl_javascript@nhn.com>
767
+ */
768
+
769
+ 'use strict';
770
+
771
+ var collection = __webpack_require__(4);
772
+ var type = __webpack_require__(2);
773
+
774
+ var aps = Array.prototype.slice;
775
+ var util;
776
+
777
+ /**
778
+ * Generate an integer Array containing an arithmetic progression.
779
+ * @param {number} start - start index
780
+ * @param {number} stop - stop index
781
+ * @param {number} step - next visit index = current index + step
782
+ * @returns {Array}
783
+ * @memberof tui.util
784
+ * @example
785
+ * //-- #1. Get Module --//
786
+ * var util = require('tui-code-snippet'); // node, commonjs
787
+ * var util = tui.util; // distribution file
788
+ *
789
+ * //-- #2. Use property --//
790
+ * util.range(5); // [0, 1, 2, 3, 4]
791
+ * util.range(1, 5); // [1,2,3,4]
792
+ * util.range(2, 10, 2); // [2,4,6,8]
793
+ * util.range(10, 2, -2); // [10,8,6,4]
794
+ */
795
+ var range = function(start, stop, step) {
796
+ var arr = [];
797
+ var flag;
798
+
799
+ if (type.isUndefined(stop)) {
800
+ stop = start || 0;
801
+ start = 0;
802
+ }
803
+
804
+ step = step || 1;
805
+ flag = step < 0 ? -1 : 1;
806
+ stop *= flag;
807
+
808
+ for (; start * flag < stop; start += step) {
809
+ arr.push(start);
810
+ }
811
+
812
+ return arr;
813
+ };
814
+
815
+ /* eslint-disable valid-jsdoc */
816
+ /**
817
+ * Zip together multiple lists into a single array
818
+ * @param {...Array}
819
+ * @returns {Array}
820
+ * @memberof tui.util
821
+ * @example
822
+ * //-- #1. Get Module --//
823
+ * var util = require('tui-code-snippet'); // node, commonjs
824
+ * var util = tui.util; // distribution file
825
+ *
826
+ * //-- #2. Use property --//
827
+ * var result = util.zip([1, 2, 3], ['a', 'b','c'], [true, false, true]);
828
+ * console.log(result[0]); // [1, 'a', true]
829
+ * console.log(result[1]); // [2, 'b', false]
830
+ * console.log(result[2]); // [3, 'c', true]
831
+ */
832
+ var zip = function() {/* eslint-enable valid-jsdoc */
833
+ var arr2d = aps.call(arguments);
834
+ var result = [];
835
+
836
+ collection.forEach(arr2d, function(arr) {
837
+ collection.forEach(arr, function(value, index) {
838
+ if (!result[index]) {
839
+ result[index] = [];
840
+ }
841
+ result[index].push(value);
842
+ });
843
+ });
844
+
845
+ return result;
846
+ };
847
+
848
+ /**
849
+ * Returns the first index at which a given element can be found in the array
850
+ * from start index(default 0), or -1 if it is not present.<br>
851
+ * It compares searchElement to elements of the Array using strict equality
852
+ * (the same method used by the ===, or triple-equals, operator).
853
+ * @param {*} searchElement Element to locate in the array
854
+ * @param {Array} array Array that will be traversed.
855
+ * @param {number} startIndex Start index in array for searching (default 0)
856
+ * @returns {number} the First index at which a given element, or -1 if it is not present
857
+ * @memberof tui.util
858
+ * @example
859
+ * //-- #1. Get Module --//
860
+ * var util = require('tui-code-snippet'); // node, commonjs
861
+ * var util = tui.util; // distribution file
862
+ *
863
+ * //-- #2. Use property --//
864
+ * var arr = ['one', 'two', 'three', 'four'];
865
+ * var idx1 = util.inArray('one', arr, 3); // -1
866
+ * var idx2 = util.inArray('one', arr); // 0
867
+ */
868
+ var inArray = function(searchElement, array, startIndex) {
869
+ var i;
870
+ var length;
871
+ startIndex = startIndex || 0;
872
+
873
+ if (!type.isArray(array)) {
874
+ return -1;
875
+ }
876
+
877
+ if (Array.prototype.indexOf) {
878
+ return Array.prototype.indexOf.call(array, searchElement, startIndex);
879
+ }
880
+
881
+ length = array.length;
882
+ for (i = startIndex; startIndex >= 0 && i < length; i += 1) {
883
+ if (array[i] === searchElement) {
884
+ return i;
885
+ }
886
+ }
887
+
888
+ return -1;
889
+ };
890
+
891
+ util = {
892
+ inArray: inArray,
893
+ range: range,
894
+ zip: zip
895
+ };
896
+
897
+ module.exports = util;
898
+
899
+
900
+ /***/ }),
901
+ /* 4 */
902
+ /***/ (function(module, exports, __webpack_require__) {
903
+
904
+ /**
905
+ * @fileoverview This module has some functions for handling object as collection.
906
+ * @author NHN.
907
+ * FE Development Lab <dl_javascript@nhn.com>
908
+ */
909
+
910
+ 'use strict';
911
+
912
+ var type = __webpack_require__(2);
913
+ var object = __webpack_require__(1);
914
+
915
+ /**
916
+ * Execute the provided callback once for each element present
917
+ * in the array(or Array-like object) in ascending order.<br>
918
+ * If the callback function returns false, the loop will be stopped.<br>
919
+ * Callback function(iteratee) is invoked with three arguments:
920
+ * - The value of the element
921
+ * - The index of the element
922
+ * - The array(or Array-like object) being traversed
923
+ * @param {Array} arr The array(or Array-like object) that will be traversed
924
+ * @param {function} iteratee Callback function
925
+ * @param {Object} [context] Context(this) of callback function
926
+ * @memberof tui.util
927
+ * @example
928
+ * //-- #1. Get Module --//
929
+ * var util = require('tui-code-snippet'); // node, commonjs
930
+ * var util = tui.util; // distribution file
931
+ *
932
+ * //-- #2. Use property --//
933
+ * var sum = 0;
934
+ *
935
+ * util.forEachArray([1,2,3], function(value){
936
+ * sum += value;
937
+ * });
938
+ * alert(sum); // 6
939
+ */
940
+ function forEachArray(arr, iteratee, context) {
941
+ var index = 0;
942
+ var len = arr.length;
943
+
944
+ context = context || null;
945
+
946
+ for (; index < len; index += 1) {
947
+ if (iteratee.call(context, arr[index], index, arr) === false) {
948
+ break;
949
+ }
950
+ }
951
+ }
952
+
953
+ /**
954
+ * Execute the provided callback once for each property of object which actually exist.<br>
955
+ * If the callback function returns false, the loop will be stopped.<br>
956
+ * Callback function(iteratee) is invoked with three arguments:
957
+ * - The value of the property
958
+ * - The name of the property
959
+ * - The object being traversed
960
+ * @param {Object} obj The object that will be traversed
961
+ * @param {function} iteratee Callback function
962
+ * @param {Object} [context] Context(this) of callback function
963
+ * @memberof tui.util
964
+ * @example
965
+ * //-- #1. Get Module --//
966
+ * var util = require('tui-code-snippet'); // node, commonjs
967
+ * var util = tui.util; // distribution file
968
+ *
969
+ * //-- #2. Use property --//
970
+ * var sum = 0;
971
+ *
972
+ * util.forEachOwnProperties({a:1,b:2,c:3}, function(value){
973
+ * sum += value;
974
+ * });
975
+ * alert(sum); // 6
976
+ **/
977
+ function forEachOwnProperties(obj, iteratee, context) {
978
+ var key;
979
+
980
+ context = context || null;
981
+
982
+ for (key in obj) {
983
+ if (obj.hasOwnProperty(key)) {
984
+ if (iteratee.call(context, obj[key], key, obj) === false) {
985
+ break;
986
+ }
987
+ }
988
+ }
989
+ }
990
+
991
+ /**
992
+ * Execute the provided callback once for each property of object(or element of array) which actually exist.<br>
993
+ * If the object is Array-like object(ex-arguments object), It needs to transform to Array.(see 'ex2' of example).<br>
994
+ * If the callback function returns false, the loop will be stopped.<br>
995
+ * Callback function(iteratee) is invoked with three arguments:
996
+ * - The value of the property(or The value of the element)
997
+ * - The name of the property(or The index of the element)
998
+ * - The object being traversed
999
+ * @param {Object} obj The object that will be traversed
1000
+ * @param {function} iteratee Callback function
1001
+ * @param {Object} [context] Context(this) of callback function
1002
+ * @memberof tui.util
1003
+ * @example
1004
+ * //-- #1. Get Module --//
1005
+ * var util = require('tui-code-snippet'); // node, commonjs
1006
+ * var util = tui.util; // distribution file
1007
+ *
1008
+ * //-- #2. Use property --//
1009
+ * var sum = 0;
1010
+ *
1011
+ * util.forEach([1,2,3], function(value){
1012
+ * sum += value;
1013
+ * });
1014
+ * alert(sum); // 6
1015
+ *
1016
+ * // In case of Array-like object
1017
+ * var array = Array.prototype.slice.call(arrayLike); // change to array
1018
+ * util.forEach(array, function(value){
1019
+ * sum += value;
1020
+ * });
1021
+ */
1022
+ function forEach(obj, iteratee, context) {
1023
+ if (type.isArray(obj)) {
1024
+ forEachArray(obj, iteratee, context);
1025
+ } else {
1026
+ forEachOwnProperties(obj, iteratee, context);
1027
+ }
1028
+ }
1029
+
1030
+ /**
1031
+ * Execute the provided callback function once for each element in an array, in order,
1032
+ * and constructs a new array from the results.<br>
1033
+ * If the object is Array-like object(ex-arguments object),
1034
+ * It needs to transform to Array.(see 'ex2' of forEach example)<br>
1035
+ * Callback function(iteratee) is invoked with three arguments:
1036
+ * - The value of the property(or The value of the element)
1037
+ * - The name of the property(or The index of the element)
1038
+ * - The object being traversed
1039
+ * @param {Object} obj The object that will be traversed
1040
+ * @param {function} iteratee Callback function
1041
+ * @param {Object} [context] Context(this) of callback function
1042
+ * @returns {Array} A new array composed of returned values from callback function
1043
+ * @memberof tui.util
1044
+ * @example
1045
+ * //-- #1. Get Module --//
1046
+ * var util = require('tui-code-snippet'); // node, commonjs
1047
+ * var util = tui.util; // distribution file
1048
+ *
1049
+ * //-- #2. Use property --//
1050
+ * var result = util.map([0,1,2,3], function(value) {
1051
+ * return value + 1;
1052
+ * });
1053
+ *
1054
+ * alert(result); // 1,2,3,4
1055
+ */
1056
+ function map(obj, iteratee, context) {
1057
+ var resultArray = [];
1058
+
1059
+ context = context || null;
1060
+
1061
+ forEach(obj, function() {
1062
+ resultArray.push(iteratee.apply(context, arguments));
1063
+ });
1064
+
1065
+ return resultArray;
1066
+ }
1067
+
1068
+ /**
1069
+ * Execute the callback function once for each element present in the array(or Array-like object or plain object).<br>
1070
+ * If the object is Array-like object(ex-arguments object),
1071
+ * It needs to transform to Array.(see 'ex2' of forEach example)<br>
1072
+ * Callback function(iteratee) is invoked with four arguments:
1073
+ * - The previousValue
1074
+ * - The currentValue
1075
+ * - The index
1076
+ * - The object being traversed
1077
+ * @param {Object} obj The object that will be traversed
1078
+ * @param {function} iteratee Callback function
1079
+ * @param {Object} [context] Context(this) of callback function
1080
+ * @returns {*} The result value
1081
+ * @memberof tui.util
1082
+ * @example
1083
+ * //-- #1. Get Module --//
1084
+ * var util = require('tui-code-snippet'); // node, commonjs
1085
+ * var util = tui.util; // distribution file
1086
+ *
1087
+ * //-- #2. Use property --//
1088
+ * var result = util.reduce([0,1,2,3], function(stored, value) {
1089
+ * return stored + value;
1090
+ * });
1091
+ *
1092
+ * alert(result); // 6
1093
+ */
1094
+ function reduce(obj, iteratee, context) {
1095
+ var index = 0;
1096
+ var keys, length, store;
1097
+
1098
+ context = context || null;
1099
+
1100
+ if (!type.isArray(obj)) {
1101
+ keys = object.keys(obj);
1102
+ length = keys.length;
1103
+ store = obj[keys[index += 1]];
1104
+ } else {
1105
+ length = obj.length;
1106
+ store = obj[index];
1107
+ }
1108
+
1109
+ index += 1;
1110
+ for (; index < length; index += 1) {
1111
+ store = iteratee.call(context, store, obj[keys ? keys[index] : index]);
1112
+ }
1113
+
1114
+ return store;
1115
+ }
1116
+
1117
+ /**
1118
+ * Transform the Array-like object to Array.<br>
1119
+ * In low IE (below 8), Array.prototype.slice.call is not perfect. So, try-catch statement is used.
1120
+ * @param {*} arrayLike Array-like object
1121
+ * @returns {Array} Array
1122
+ * @memberof tui.util
1123
+ * @example
1124
+ * //-- #1. Get Module --//
1125
+ * var util = require('tui-code-snippet'); // node, commonjs
1126
+ * var util = tui.util; // distribution file
1127
+ *
1128
+ * //-- #2. Use property --//
1129
+ * var arrayLike = {
1130
+ * 0: 'one',
1131
+ * 1: 'two',
1132
+ * 2: 'three',
1133
+ * 3: 'four',
1134
+ * length: 4
1135
+ * };
1136
+ * var result = util.toArray(arrayLike);
1137
+ *
1138
+ * alert(result instanceof Array); // true
1139
+ * alert(result); // one,two,three,four
1140
+ */
1141
+ function toArray(arrayLike) {
1142
+ var arr;
1143
+ try {
1144
+ arr = Array.prototype.slice.call(arrayLike);
1145
+ } catch (e) {
1146
+ arr = [];
1147
+ forEachArray(arrayLike, function(value) {
1148
+ arr.push(value);
1149
+ });
1150
+ }
1151
+
1152
+ return arr;
1153
+ }
1154
+
1155
+ /**
1156
+ * Create a new array or plain object with all elements(or properties)
1157
+ * that pass the test implemented by the provided function.<br>
1158
+ * Callback function(iteratee) is invoked with three arguments:
1159
+ * - The value of the property(or The value of the element)
1160
+ * - The name of the property(or The index of the element)
1161
+ * - The object being traversed
1162
+ * @param {Object} obj Object(plain object or Array) that will be traversed
1163
+ * @param {function} iteratee Callback function
1164
+ * @param {Object} [context] Context(this) of callback function
1165
+ * @returns {Object} plain object or Array
1166
+ * @memberof tui.util
1167
+ * @example
1168
+ * //-- #1. Get Module --//
1169
+ * var util = require('tui-code-snippet'); // node, commonjs
1170
+ * var util = tui.util; // distribution file
1171
+ *
1172
+ * //-- #2. Use property --//
1173
+ * var result1 = util.filter([0,1,2,3], function(value) {
1174
+ * return (value % 2 === 0);
1175
+ * });
1176
+ * alert(result1); // [0, 2]
1177
+ *
1178
+ * var result2 = util.filter({a : 1, b: 2, c: 3}, function(value) {
1179
+ * return (value % 2 !== 0);
1180
+ * });
1181
+ * alert(result2.a); // 1
1182
+ * alert(result2.b); // undefined
1183
+ * alert(result2.c); // 3
1184
+ */
1185
+ function filter(obj, iteratee, context) {
1186
+ var result, add;
1187
+
1188
+ context = context || null;
1189
+
1190
+ if (!type.isObject(obj) || !type.isFunction(iteratee)) {
1191
+ throw new Error('wrong parameter');
1192
+ }
1193
+
1194
+ if (type.isArray(obj)) {
1195
+ result = [];
1196
+ add = function(subResult, args) {
1197
+ subResult.push(args[0]);
1198
+ };
1199
+ } else {
1200
+ result = {};
1201
+ add = function(subResult, args) {
1202
+ subResult[args[1]] = args[0];
1203
+ };
1204
+ }
1205
+
1206
+ forEach(obj, function() {
1207
+ if (iteratee.apply(context, arguments)) {
1208
+ add(result, arguments);
1209
+ }
1210
+ }, context);
1211
+
1212
+ return result;
1213
+ }
1214
+
1215
+ /**
1216
+ * fetching a property
1217
+ * @param {Array} arr target collection
1218
+ * @param {String|Number} property property name
1219
+ * @returns {Array}
1220
+ * @memberof tui.util
1221
+ * @example
1222
+ * //-- #1. Get Module --//
1223
+ * var util = require('tui-code-snippet'); // node, commonjs
1224
+ * var util = tui.util; // distribution file
1225
+ *
1226
+ * //-- #2. Use property --//
1227
+ * var objArr = [
1228
+ * {'abc': 1, 'def': 2, 'ghi': 3},
1229
+ * {'abc': 4, 'def': 5, 'ghi': 6},
1230
+ * {'abc': 7, 'def': 8, 'ghi': 9}
1231
+ * ];
1232
+ * var arr2d = [
1233
+ * [1, 2, 3],
1234
+ * [4, 5, 6],
1235
+ * [7, 8, 9]
1236
+ * ];
1237
+ * util.pluck(objArr, 'abc'); // [1, 4, 7]
1238
+ * util.pluck(arr2d, 2); // [3, 6, 9]
1239
+ */
1240
+ function pluck(arr, property) {
1241
+ var result = map(arr, function(item) {
1242
+ return item[property];
1243
+ });
1244
+
1245
+ return result;
1246
+ }
1247
+
1248
+ module.exports = {
1249
+ forEachOwnProperties: forEachOwnProperties,
1250
+ forEachArray: forEachArray,
1251
+ forEach: forEach,
1252
+ toArray: toArray,
1253
+ map: map,
1254
+ reduce: reduce,
1255
+ filter: filter,
1256
+ pluck: pluck
1257
+ };
1258
+
1259
+
1260
+ /***/ }),
1261
+ /* 5 */
1262
+ /***/ (function(module, exports) {
1263
+
1264
+ /**
1265
+ * @fileoverview This module provides a bind() function for context binding.
1266
+ * @author NHN.
1267
+ * FE Development Lab <dl_javascript@nhn.com>
1268
+ */
1269
+
1270
+ 'use strict';
1271
+
1272
+ /**
1273
+ * Create a new function that, when called, has its this keyword set to the provided value.
1274
+ * @param {function} fn A original function before binding
1275
+ * @param {*} obj context of function in arguments[0]
1276
+ * @returns {function()} A new bound function with context that is in arguments[1]
1277
+ * @memberof tui.util
1278
+ */
1279
+ function bind(fn, obj) {
1280
+ var slice = Array.prototype.slice;
1281
+ var args;
1282
+
1283
+ if (fn.bind) {
1284
+ return fn.bind.apply(fn, slice.call(arguments, 1));
1285
+ }
1286
+
1287
+ /* istanbul ignore next */
1288
+ args = slice.call(arguments, 2);
1289
+
1290
+ /* istanbul ignore next */
1291
+ return function() {
1292
+ /* istanbul ignore next */
1293
+ return fn.apply(obj, args.length ? args.concat(slice.call(arguments)) : arguments);
1294
+ };
1295
+ }
1296
+
1297
+ module.exports = {
1298
+ bind: bind
1299
+ };
1300
+
1301
+
1302
+ /***/ }),
1303
+ /* 6 */
1304
+ /***/ (function(module, exports) {
1305
+
1306
+ /**
1307
+ * @fileoverview This module provides some simple function for inheritance.
1308
+ * @author NHN.
1309
+ * FE Development Lab <dl_javascript@nhn.com>
1310
+ */
1311
+
1312
+ 'use strict';
1313
+
1314
+ /**
1315
+ * Create a new object with the specified prototype object and properties.
1316
+ * @param {Object} obj This object will be a prototype of the newly-created object.
1317
+ * @returns {Object}
1318
+ * @memberof tui.util
1319
+ */
1320
+ function createObject(obj) {
1321
+ function F() {} // eslint-disable-line require-jsdoc
1322
+ F.prototype = obj;
1323
+
1324
+ return new F();
1325
+ }
1326
+
1327
+ /**
1328
+ * Provide a simple inheritance in prototype-oriented.<br>
1329
+ * Caution :
1330
+ * Don't overwrite the prototype of child constructor.
1331
+ *
1332
+ * @param {function} subType Child constructor
1333
+ * @param {function} superType Parent constructor
1334
+ * @memberof tui.util
1335
+ * @example
1336
+ * //-- #1. Get Module --//
1337
+ * var util = require('tui-code-snippet'); // node, commonjs
1338
+ * var util = tui.util; // distribution file
1339
+ *
1340
+ * //-- #2. Use property --//
1341
+ * // Parent constructor
1342
+ * function Animal(leg) {
1343
+ * this.leg = leg;
1344
+ * }
1345
+ * Animal.prototype.growl = function() {
1346
+ * // ...
1347
+ * };
1348
+ *
1349
+ * // Child constructor
1350
+ * function Person(name) {
1351
+ * this.name = name;
1352
+ * }
1353
+ *
1354
+ * // Inheritance
1355
+ * util.inherit(Person, Animal);
1356
+ *
1357
+ * // After this inheritance, please use only the extending of property.
1358
+ * // Do not overwrite prototype.
1359
+ * Person.prototype.walk = function(direction) {
1360
+ * // ...
1361
+ * };
1362
+ */
1363
+ function inherit(subType, superType) {
1364
+ var prototype = createObject(superType.prototype);
1365
+ prototype.constructor = subType;
1366
+ subType.prototype = prototype;
1367
+ }
1368
+
1369
+ module.exports = {
1370
+ createObject: createObject,
1371
+ inherit: inherit
1372
+ };
1373
+
1374
+
1375
+ /***/ }),
1376
+ /* 7 */
1377
+ /***/ (function(module, exports, __webpack_require__) {
1378
+
1379
+ /**
1380
+ * @fileoverview This module has some functions for handling the string.
1381
+ * @author NHN.
1382
+ * FE Development Lab <dl_javascript@nhn.com>
1383
+ */
1384
+
1385
+ 'use strict';
1386
+
1387
+ var collection = __webpack_require__(4);
1388
+ var object = __webpack_require__(1);
1389
+ /**
1390
+ * Transform the given HTML Entity string into plain string
1391
+ * @param {String} htmlEntity - HTML Entity type string
1392
+ * @returns {String} Plain string
1393
+ * @memberof tui.util
1394
+ * @example
1395
+ * //-- #1. Get Module --//
1396
+ * var util = require('tui-code-snippet'); // node, commonjs
1397
+ * var util = tui.util; // distribution file
1398
+ *
1399
+ * //-- #2. Use property --//
1400
+ * var htmlEntityString = "A &#39;quote&#39; is &lt;b&gt;bold&lt;/b&gt;"
1401
+ * var result = util.decodeHTMLEntity(htmlEntityString); //"A 'quote' is <b>bold</b>"
1402
+ */
1403
+ function decodeHTMLEntity(htmlEntity) {
1404
+ var entities = {
1405
+ '&quot;': '"',
1406
+ '&amp;': '&',
1407
+ '&lt;': '<',
1408
+ '&gt;': '>',
1409
+ '&#39;': '\'',
1410
+ '&nbsp;': ' '
1411
+ };
1412
+
1413
+ return htmlEntity.replace(/&amp;|&lt;|&gt;|&quot;|&#39;|&nbsp;/g, function(m0) {
1414
+ return entities[m0] ? entities[m0] : m0;
1415
+ });
1416
+ }
1417
+
1418
+ /**
1419
+ * Transform the given string into HTML Entity string
1420
+ * @param {String} html - String for encoding
1421
+ * @returns {String} HTML Entity
1422
+ * @memberof tui.util
1423
+ * @example
1424
+ * //-- #1. Get Module --//
1425
+ * var util = require('tui-code-snippet'); // node, commonjs
1426
+ * var util = tui.util; // distribution file
1427
+ *
1428
+ * //-- #2. Use property --//
1429
+ * var htmlEntityString = "<script> alert('test');</script><a href='test'>";
1430
+ * var result = util.encodeHTMLEntity(htmlEntityString);
1431
+ * //"&lt;script&gt; alert(&#39;test&#39;);&lt;/script&gt;&lt;a href=&#39;test&#39;&gt;"
1432
+ */
1433
+ function encodeHTMLEntity(html) {
1434
+ var entities = {
1435
+ '"': 'quot',
1436
+ '&': 'amp',
1437
+ '<': 'lt',
1438
+ '>': 'gt',
1439
+ '\'': '#39'
1440
+ };
1441
+
1442
+ return html.replace(/[<>&"']/g, function(m0) {
1443
+ return entities[m0] ? '&' + entities[m0] + ';' : m0;
1444
+ });
1445
+ }
1446
+
1447
+ /**
1448
+ * Return whether the string capable to transform into plain string is in the given string or not.
1449
+ * @param {String} string - test string
1450
+ * @memberof tui.util
1451
+ * @returns {boolean}
1452
+ */
1453
+ function hasEncodableString(string) {
1454
+ return (/[<>&"']/).test(string);
1455
+ }
1456
+
1457
+ /**
1458
+ * Return duplicate charters
1459
+ * @param {string} operandStr1 The operand string
1460
+ * @param {string} operandStr2 The operand string
1461
+ * @private
1462
+ * @memberof tui.util
1463
+ * @returns {string}
1464
+ * @example
1465
+ * //-- #1. Get Module --//
1466
+ * var util = require('tui-code-snippet'); // node, commonjs
1467
+ * var util = tui.util; // distribution file
1468
+ *
1469
+ * //-- #2. Use property --//
1470
+ * util.getDuplicatedChar('fe dev', 'nhn entertainment'); // 'e'
1471
+ * util.getDuplicatedChar('fdsa', 'asdf'); // 'asdf'
1472
+ */
1473
+ function getDuplicatedChar(operandStr1, operandStr2) {
1474
+ var i = 0;
1475
+ var len = operandStr1.length;
1476
+ var pool = {};
1477
+ var dupl, key;
1478
+
1479
+ for (; i < len; i += 1) {
1480
+ key = operandStr1.charAt(i);
1481
+ pool[key] = 1;
1482
+ }
1483
+
1484
+ for (i = 0, len = operandStr2.length; i < len; i += 1) {
1485
+ key = operandStr2.charAt(i);
1486
+ if (pool[key]) {
1487
+ pool[key] += 1;
1488
+ }
1489
+ }
1490
+
1491
+ pool = collection.filter(pool, function(item) {
1492
+ return item > 1;
1493
+ });
1494
+
1495
+ pool = object.keys(pool).sort();
1496
+ dupl = pool.join('');
1497
+
1498
+ return dupl;
1499
+ }
1500
+
1501
+ module.exports = {
1502
+ decodeHTMLEntity: decodeHTMLEntity,
1503
+ encodeHTMLEntity: encodeHTMLEntity,
1504
+ hasEncodableString: hasEncodableString,
1505
+ getDuplicatedChar: getDuplicatedChar
1506
+ };
1507
+
1508
+
1509
+ /***/ }),
1510
+ /* 8 */
1511
+ /***/ (function(module, exports) {
1512
+
1513
+ /**
1514
+ * @fileoverview collections of some technic methods.
1515
+ * @author NHN.
1516
+ * FE Development Lab <dl_javascript.nhn.com>
1517
+ */
1518
+
1519
+ 'use strict';
1520
+
1521
+ var tricks = {};
1522
+ var aps = Array.prototype.slice;
1523
+
1524
+ /**
1525
+ * Creates a debounced function that delays invoking fn until after delay milliseconds has elapsed
1526
+ * since the last time the debouced function was invoked.
1527
+ * @param {function} fn The function to debounce.
1528
+ * @param {number} [delay=0] The number of milliseconds to delay
1529
+ * @memberof tui.util
1530
+ * @returns {function} debounced function.
1531
+ * @example
1532
+ * //-- #1. Get Module --//
1533
+ * var util = require('tui-code-snippet'); // node, commonjs
1534
+ * var util = tui.util; // distribution file
1535
+ *
1536
+ * //-- #2. Use property --//
1537
+ * function someMethodToInvokeDebounced() {}
1538
+ *
1539
+ * var debounced = util.debounce(someMethodToInvokeDebounced, 300);
1540
+ *
1541
+ * // invoke repeatedly
1542
+ * debounced();
1543
+ * debounced();
1544
+ * debounced();
1545
+ * debounced();
1546
+ * debounced();
1547
+ * debounced(); // last invoke of debounced()
1548
+ *
1549
+ * // invoke someMethodToInvokeDebounced() after 300 milliseconds.
1550
+ */
1551
+ function debounce(fn, delay) {
1552
+ var timer, args;
1553
+
1554
+ /* istanbul ignore next */
1555
+ delay = delay || 0;
1556
+
1557
+ function debounced() { // eslint-disable-line require-jsdoc
1558
+ args = aps.call(arguments);
1559
+
1560
+ window.clearTimeout(timer);
1561
+ timer = window.setTimeout(function() {
1562
+ fn.apply(null, args);
1563
+ }, delay);
1564
+ }
1565
+
1566
+ return debounced;
1567
+ }
1568
+
1569
+ /**
1570
+ * return timestamp
1571
+ * @memberof tui.util
1572
+ * @returns {number} The number of milliseconds from Jan. 1970 00:00:00 (GMT)
1573
+ */
1574
+ function timestamp() {
1575
+ return Number(new Date());
1576
+ }
1577
+
1578
+ /**
1579
+ * Creates a throttled function that only invokes fn at most once per every interval milliseconds.
1580
+ *
1581
+ * You can use this throttle short time repeatedly invoking functions. (e.g MouseMove, Resize ...)
1582
+ *
1583
+ * if you need reuse throttled method. you must remove slugs (e.g. flag variable) related with throttling.
1584
+ * @param {function} fn function to throttle
1585
+ * @param {number} [interval=0] the number of milliseconds to throttle invocations to.
1586
+ * @memberof tui.util
1587
+ * @returns {function} throttled function
1588
+ * @example
1589
+ * //-- #1. Get Module --//
1590
+ * var util = require('tui-code-snippet'); // node, commonjs
1591
+ * var util = tui.util; // distribution file
1592
+ *
1593
+ * //-- #2. Use property --//
1594
+ * function someMethodToInvokeThrottled() {}
1595
+ *
1596
+ * var throttled = util.throttle(someMethodToInvokeThrottled, 300);
1597
+ *
1598
+ * // invoke repeatedly
1599
+ * throttled(); // invoke (leading)
1600
+ * throttled();
1601
+ * throttled(); // invoke (near 300 milliseconds)
1602
+ * throttled();
1603
+ * throttled();
1604
+ * throttled(); // invoke (near 600 milliseconds)
1605
+ * // ...
1606
+ * // invoke (trailing)
1607
+ *
1608
+ * // if you need reuse throttled method. then invoke reset()
1609
+ * throttled.reset();
1610
+ */
1611
+ function throttle(fn, interval) {
1612
+ var base;
1613
+ var isLeading = true;
1614
+ var tick = function(_args) {
1615
+ fn.apply(null, _args);
1616
+ base = null;
1617
+ };
1618
+ var debounced, stamp, args;
1619
+
1620
+ /* istanbul ignore next */
1621
+ interval = interval || 0;
1622
+
1623
+ debounced = tricks.debounce(tick, interval);
1624
+
1625
+ function throttled() { // eslint-disable-line require-jsdoc
1626
+ args = aps.call(arguments);
1627
+
1628
+ if (isLeading) {
1629
+ tick(args);
1630
+ isLeading = false;
1631
+
1632
+ return;
1633
+ }
1634
+
1635
+ stamp = tricks.timestamp();
1636
+
1637
+ base = base || stamp;
1638
+
1639
+ // pass array directly because `debounce()`, `tick()` are already use
1640
+ // `apply()` method to invoke developer's `fn` handler.
1641
+ //
1642
+ // also, this `debounced` line invoked every time for implements
1643
+ // `trailing` features.
1644
+ debounced(args);
1645
+
1646
+ if ((stamp - base) >= interval) {
1647
+ tick(args);
1648
+ }
1649
+ }
1650
+
1651
+ function reset() { // eslint-disable-line require-jsdoc
1652
+ isLeading = true;
1653
+ base = null;
1654
+ }
1655
+
1656
+ throttled.reset = reset;
1657
+
1658
+ return throttled;
1659
+ }
1660
+
1661
+ tricks.timestamp = timestamp;
1662
+ tricks.debounce = debounce;
1663
+ tricks.throttle = throttle;
1664
+
1665
+ module.exports = tricks;
1666
+
1667
+
1668
+ /***/ }),
1669
+ /* 9 */
1670
+ /***/ (function(module, exports, __webpack_require__) {
1671
+
1672
+ /**
1673
+ * @fileoverview This module has some functions for handling object as collection.
1674
+ * @author NHN.
1675
+ * FE Development Lab <dl_javascript@nhn.com>
1676
+ */
1677
+ 'use strict';
1678
+
1679
+ var object = __webpack_require__(1);
1680
+ var collection = __webpack_require__(4);
1681
+ var type = __webpack_require__(2);
1682
+ var ms7days = 7 * 24 * 60 * 60 * 1000;
1683
+
1684
+ /**
1685
+ * Check if the date has passed 7 days
1686
+ * @param {number} date - milliseconds
1687
+ * @returns {boolean}
1688
+ * @ignore
1689
+ */
1690
+ function isExpired(date) {
1691
+ var now = new Date().getTime();
1692
+
1693
+ return now - date > ms7days;
1694
+ }
1695
+
1696
+ /**
1697
+ * Send hostname on DOMContentLoaded.
1698
+ * To prevent hostname set tui.usageStatistics to false.
1699
+ * @param {string} appName - application name
1700
+ * @param {string} trackingId - GA tracking ID
1701
+ * @ignore
1702
+ */
1703
+ function sendHostname(appName, trackingId) {
1704
+ var url = 'https://www.google-analytics.com/collect';
1705
+ var hostname = location.hostname;
1706
+ var hitType = 'event';
1707
+ var eventCategory = 'use';
1708
+ var applicationKeyForStorage = 'TOAST UI ' + appName + ' for ' + hostname + ': Statistics';
1709
+ var date = window.localStorage.getItem(applicationKeyForStorage);
1710
+
1711
+ // skip if the flag is defined and is set to false explicitly
1712
+ if (!type.isUndefined(window.tui) && window.tui.usageStatistics === false) {
1713
+ return;
1714
+ }
1715
+
1716
+ // skip if not pass seven days old
1717
+ if (date && !isExpired(date)) {
1718
+ return;
1719
+ }
1720
+
1721
+ window.localStorage.setItem(applicationKeyForStorage, new Date().getTime());
1722
+
1723
+ setTimeout(function() {
1724
+ if (document.readyState === 'interactive' || document.readyState === 'complete') {
1725
+ imagePing(url, {
1726
+ v: 1,
1727
+ t: hitType,
1728
+ tid: trackingId,
1729
+ cid: hostname,
1730
+ dp: hostname,
1731
+ dh: appName,
1732
+ el: appName,
1733
+ ec: eventCategory
1734
+ });
1735
+ }
1736
+ }, 1000);
1737
+ }
1738
+
1739
+ /**
1740
+ * Request image ping.
1741
+ * @param {String} url url for ping request
1742
+ * @param {Object} trackingInfo infos for make query string
1743
+ * @returns {HTMLElement}
1744
+ * @memberof tui.util
1745
+ * @example
1746
+ * //-- #1. Get Module --//
1747
+ * var util = require('tui-code-snippet'); // node, commonjs
1748
+ * var util = tui.util; // distribution file
1749
+ *
1750
+ * //-- #2. Use property --//
1751
+ * util.imagePing('https://www.google-analytics.com/collect', {
1752
+ * v: 1,
1753
+ * t: 'event',
1754
+ * tid: 'trackingid',
1755
+ * cid: 'cid',
1756
+ * dp: 'dp',
1757
+ * dh: 'dh'
1758
+ * });
1759
+ */
1760
+ function imagePing(url, trackingInfo) {
1761
+ var queryString = collection.map(object.keys(trackingInfo), function(key, index) {
1762
+ var startWith = index === 0 ? '' : '&';
1763
+
1764
+ return startWith + key + '=' + trackingInfo[key];
1765
+ }).join('');
1766
+ var trackingElement = document.createElement('img');
1767
+
1768
+ trackingElement.src = url + '?' + queryString;
1769
+
1770
+ trackingElement.style.display = 'none';
1771
+ document.body.appendChild(trackingElement);
1772
+ document.body.removeChild(trackingElement);
1773
+
1774
+ return trackingElement;
1775
+ }
1776
+
1777
+ module.exports = {
1778
+ imagePing: imagePing,
1779
+ sendHostname: sendHostname
1780
+ };
1781
+
1782
+
1783
+ /***/ }),
1784
+ /* 10 */
1785
+ /***/ (function(module, exports) {
1786
+
1787
+ /**
1788
+ * @fileoverview This module detects the kind of well-known browser and version.
1789
+ * @author NHN.
1790
+ * FE Development Lab <dl_javascript@nhn.com>
1791
+ */
1792
+
1793
+ 'use strict';
1794
+
1795
+ /**
1796
+ * This object has an information that indicate the kind of browser.<br>
1797
+ * The list below is a detectable browser list.
1798
+ * - ie8 ~ ie11
1799
+ * - chrome
1800
+ * - firefox
1801
+ * - safari
1802
+ * - edge
1803
+ * @memberof tui.util
1804
+ * @example
1805
+ * //-- #1. Get Module --//
1806
+ * var util = require('tui-code-snippet'); // node, commonjs
1807
+ * var util = tui.util; // distribution file
1808
+ *
1809
+ * //-- #2. Use property --//
1810
+ * util.browser.chrome === true; // chrome
1811
+ * util.browser.firefox === true; // firefox
1812
+ * util.browser.safari === true; // safari
1813
+ * util.browser.msie === true; // IE
1814
+ * util.browser.edge === true; // edge
1815
+ * util.browser.others === true; // other browser
1816
+ * util.browser.version; // browser version
1817
+ */
1818
+ var browser = {
1819
+ chrome: false,
1820
+ firefox: false,
1821
+ safari: false,
1822
+ msie: false,
1823
+ edge: false,
1824
+ others: false,
1825
+ version: 0
1826
+ };
1827
+
1828
+ if (window && window.navigator) {
1829
+ detectBrowser();
1830
+ }
1831
+
1832
+ /**
1833
+ * Detect the browser.
1834
+ * @private
1835
+ */
1836
+ function detectBrowser() {
1837
+ var nav = window.navigator;
1838
+ var appName = nav.appName.replace(/\s/g, '_');
1839
+ var userAgent = nav.userAgent;
1840
+
1841
+ var rIE = /MSIE\s([0-9]+[.0-9]*)/;
1842
+ var rIE11 = /Trident.*rv:11\./;
1843
+ var rEdge = /Edge\/(\d+)\./;
1844
+ var versionRegex = {
1845
+ firefox: /Firefox\/(\d+)\./,
1846
+ chrome: /Chrome\/(\d+)\./,
1847
+ safari: /Version\/([\d.]+).*Safari\/(\d+)/
1848
+ };
1849
+
1850
+ var key, tmp;
1851
+
1852
+ var detector = {
1853
+ Microsoft_Internet_Explorer: function() { // eslint-disable-line camelcase
1854
+ var detectedVersion = userAgent.match(rIE);
1855
+
1856
+ if (detectedVersion) { // ie8 ~ ie10
1857
+ browser.msie = true;
1858
+ browser.version = parseFloat(detectedVersion[1]);
1859
+ } else { // no version information
1860
+ browser.others = true;
1861
+ }
1862
+ },
1863
+ Netscape: function() { // eslint-disable-line complexity
1864
+ var detected = false;
1865
+
1866
+ if (rIE11.exec(userAgent)) {
1867
+ browser.msie = true;
1868
+ browser.version = 11;
1869
+ detected = true;
1870
+ } else if (rEdge.exec(userAgent)) {
1871
+ browser.edge = true;
1872
+ browser.version = userAgent.match(rEdge)[1];
1873
+ detected = true;
1874
+ } else {
1875
+ for (key in versionRegex) {
1876
+ if (versionRegex.hasOwnProperty(key)) {
1877
+ tmp = userAgent.match(versionRegex[key]);
1878
+ if (tmp && tmp.length > 1) { // eslint-disable-line max-depth
1879
+ browser[key] = detected = true;
1880
+ browser.version = parseFloat(tmp[1] || 0);
1881
+ break;
1882
+ }
1883
+ }
1884
+ }
1885
+ }
1886
+ if (!detected) {
1887
+ browser.others = true;
1888
+ }
1889
+ }
1890
+ };
1891
+
1892
+ var fn = detector[appName];
1893
+
1894
+ if (fn) {
1895
+ detector[appName]();
1896
+ }
1897
+ }
1898
+
1899
+ module.exports = browser;
1900
+
1901
+
1902
+ /***/ }),
1903
+ /* 11 */
1904
+ /***/ (function(module, exports, __webpack_require__) {
1905
+
1906
+ /**
1907
+ * @fileoverview This module has some methods for handling popup-window
1908
+ * @author NHN.
1909
+ * FE Development Lab <dl_javascript@nhn.com>
1910
+ */
1911
+
1912
+ 'use strict';
1913
+
1914
+ var collection = __webpack_require__(4);
1915
+ var type = __webpack_require__(2);
1916
+ var func = __webpack_require__(5);
1917
+ var browser = __webpack_require__(10);
1918
+ var object = __webpack_require__(1);
1919
+
1920
+ var popupId = 0;
1921
+
1922
+ /**
1923
+ * Popup management class
1924
+ * @constructor
1925
+ * @memberof tui.util
1926
+ * @example
1927
+ * // node, commonjs
1928
+ * var popup = require('tui-code-snippet').popup;
1929
+ * @example
1930
+ * // distribution file, script
1931
+ * <script src='path-to/tui-code-snippt.js'></script>
1932
+ * <script>
1933
+ * var popup = tui.util.popup;
1934
+ * <script>
1935
+ */
1936
+ function Popup() {
1937
+ /**
1938
+ * Caching the window-contexts of opened popups
1939
+ * @type {Object}
1940
+ */
1941
+ this.openedPopup = {};
1942
+
1943
+ /**
1944
+ * In IE7, an error occurs when the closeWithParent property attaches to window object.<br>
1945
+ * So, It is for saving the value of closeWithParent instead of attaching to window object.
1946
+ * @type {Object}
1947
+ */
1948
+ this.closeWithParentPopup = {};
1949
+
1950
+ /**
1951
+ * Post data bridge for IE11 popup
1952
+ * @type {string}
1953
+ */
1954
+ this.postBridgeUrl = '';
1955
+ }
1956
+
1957
+ /**********
1958
+ * public methods
1959
+ **********/
1960
+
1961
+ /**
1962
+ * Returns a popup-list administered by current window.
1963
+ * @param {string} [key] The key of popup.
1964
+ * @returns {Object} popup window list object
1965
+ */
1966
+ Popup.prototype.getPopupList = function(key) {
1967
+ var target;
1968
+ if (type.isExisty(key)) {
1969
+ target = this.openedPopup[key];
1970
+ } else {
1971
+ target = this.openedPopup;
1972
+ }
1973
+
1974
+ return target;
1975
+ };
1976
+
1977
+ /**
1978
+ * Open popup
1979
+ * Caution:
1980
+ * In IE11, when transfer data to popup by POST, must set the postBridgeUrl.
1981
+ *
1982
+ * @param {string} url - popup url
1983
+ * @param {Object} options - popup options
1984
+ * @param {string} [options.popupName] - Key of popup window.<br>
1985
+ * If the key is set, when you try to open by this key, the popup of this key is focused.<br>
1986
+ * Or else a new popup window having this key is opened.
1987
+ *
1988
+ * @param {string} [options.popupOptionStr=""] - Option string of popup window<br>
1989
+ * It is same with the third parameter of window.open() method.<br>
1990
+ * See {@link http://www.w3schools.com/jsref/met_win_open.asp}
1991
+ *
1992
+ * @param {boolean} [options.closeWithParent=true] - Is closed when parent window closed?
1993
+ *
1994
+ * @param {boolean} [options.useReload=false] - This property indicates whether reload the popup or not.<br>
1995
+ * If true, the popup will be reloaded when you try to re-open the popup that has been opened.<br>
1996
+ * When transmit the POST-data, some browsers alert a message for confirming whether retransmit or not.
1997
+ *
1998
+ * @param {string} [options.postBridgeUrl='']
1999
+ * Use this url to avoid a certain bug occuring when transmitting POST data to the popup in IE11.<br>
2000
+ * This specific buggy situation is known to happen because IE11 tries to open the requested url<br>
2001
+ * not in a new popup window as intended, but in a new tab.<br>
2002
+ * See {@link http://wiki.nhnent.com/pages/viewpage.action?pageId=240562844}
2003
+ *
2004
+ * @param {string} [options.method=get]
2005
+ * The method of transmission when the form-data is transmitted to popup-window.
2006
+ *
2007
+ * @param {Object} [options.param=null]
2008
+ * Using as parameters for transmission when the form-data is transmitted to popup-window.
2009
+ */
2010
+ Popup.prototype.openPopup = function(url, options) { // eslint-disable-line complexity
2011
+ var popup, formElement, useIEPostBridge;
2012
+
2013
+ options = object.extend({
2014
+ popupName: 'popup_' + popupId + '_' + Number(new Date()),
2015
+ popupOptionStr: '',
2016
+ useReload: true,
2017
+ closeWithParent: true,
2018
+ method: 'get',
2019
+ param: {}
2020
+ }, options || {});
2021
+
2022
+ options.method = options.method.toUpperCase();
2023
+
2024
+ this.postBridgeUrl = options.postBridgeUrl || this.postBridgeUrl;
2025
+
2026
+ useIEPostBridge = options.method === 'POST' && options.param &&
2027
+ browser.msie && browser.version === 11;
2028
+
2029
+ if (!type.isExisty(url)) {
2030
+ throw new Error('Popup#open() need popup url.');
2031
+ }
2032
+
2033
+ popupId += 1;
2034
+
2035
+ /*
2036
+ * In form-data transmission
2037
+ * 1. Create a form before opening a popup.
2038
+ * 2. Transmit the form-data.
2039
+ * 3. Remove the form after transmission.
2040
+ */
2041
+ if (options.param) {
2042
+ if (options.method === 'GET') {
2043
+ url = url + (/\?/.test(url) ? '&' : '?') + this._parameterize(options.param);
2044
+ } else if (options.method === 'POST') {
2045
+ if (!useIEPostBridge) {
2046
+ formElement = this.createForm(url, options.param, options.method, options.popupName);
2047
+ url = 'about:blank';
2048
+ }
2049
+ }
2050
+ }
2051
+
2052
+ popup = this.openedPopup[options.popupName];
2053
+
2054
+ if (!type.isExisty(popup)) {
2055
+ this.openedPopup[options.popupName] = popup = this._open(useIEPostBridge, options.param,
2056
+ url, options.popupName, options.popupOptionStr);
2057
+ } else if (popup.closed) {
2058
+ this.openedPopup[options.popupName] = popup = this._open(useIEPostBridge, options.param,
2059
+ url, options.popupName, options.popupOptionStr);
2060
+ } else {
2061
+ if (options.useReload) {
2062
+ popup.location.replace(url);
2063
+ }
2064
+ popup.focus();
2065
+ }
2066
+
2067
+ this.closeWithParentPopup[options.popupName] = options.closeWithParent;
2068
+
2069
+ if (!popup || popup.closed || type.isUndefined(popup.closed)) {
2070
+ alert('please enable popup windows for this website');
2071
+ }
2072
+
2073
+ if (options.param && options.method === 'POST' && !useIEPostBridge) {
2074
+ if (popup) {
2075
+ formElement.submit();
2076
+ }
2077
+ if (formElement.parentNode) {
2078
+ formElement.parentNode.removeChild(formElement);
2079
+ }
2080
+ }
2081
+
2082
+ window.onunload = func.bind(this.closeAllPopup, this);
2083
+ };
2084
+
2085
+ /**
2086
+ * Close the popup
2087
+ * @param {boolean} [skipBeforeUnload] - If true, the 'window.onunload' will be null and skip unload event.
2088
+ * @param {Window} [popup] - Window-context of popup for closing. If omit this, current window-context will be closed.
2089
+ */
2090
+ Popup.prototype.close = function(skipBeforeUnload, popup) {
2091
+ var target = popup || window;
2092
+ skipBeforeUnload = type.isExisty(skipBeforeUnload) ? skipBeforeUnload : false;
2093
+
2094
+ if (skipBeforeUnload) {
2095
+ window.onunload = null;
2096
+ }
2097
+
2098
+ if (!target.closed) {
2099
+ target.opener = window.location.href;
2100
+ target.close();
2101
+ }
2102
+ };
2103
+
2104
+ /**
2105
+ * Close all the popups in current window.
2106
+ * @param {boolean} closeWithParent - If true, popups having the closeWithParentPopup property as true will be closed.
2107
+ */
2108
+ Popup.prototype.closeAllPopup = function(closeWithParent) {
2109
+ var hasArg = type.isExisty(closeWithParent);
2110
+
2111
+ collection.forEachOwnProperties(this.openedPopup, function(popup, key) {
2112
+ if ((hasArg && this.closeWithParentPopup[key]) || !hasArg) {
2113
+ this.close(false, popup);
2114
+ }
2115
+ }, this);
2116
+ };
2117
+
2118
+ /**
2119
+ * Activate(or focus) the popup of the given name.
2120
+ * @param {string} popupName - Name of popup for activation
2121
+ */
2122
+ Popup.prototype.focus = function(popupName) {
2123
+ this.getPopupList(popupName).focus();
2124
+ };
2125
+
2126
+ /**
2127
+ * Return an object made of parsing the query string.
2128
+ * @returns {Object} An object having some information of the query string.
2129
+ * @private
2130
+ */
2131
+ Popup.prototype.parseQuery = function() {
2132
+ var param = {};
2133
+ var search, pair;
2134
+
2135
+ search = window.location.search.substr(1);
2136
+ collection.forEachArray(search.split('&'), function(part) {
2137
+ pair = part.split('=');
2138
+ param[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
2139
+ });
2140
+
2141
+ return param;
2142
+ };
2143
+
2144
+ /**
2145
+ * Create a hidden form from the given arguments and return this form.
2146
+ * @param {string} action - URL for form transmission
2147
+ * @param {Object} [data] - Data for form transmission
2148
+ * @param {string} [method] - Method of transmission
2149
+ * @param {string} [target] - Target of transmission
2150
+ * @param {HTMLElement} [container] - Container element of form.
2151
+ * @returns {HTMLElement} Form element
2152
+ */
2153
+ Popup.prototype.createForm = function(action, data, method, target, container) {
2154
+ var form = document.createElement('form'),
2155
+ input;
2156
+
2157
+ container = container || document.body;
2158
+
2159
+ form.method = method || 'POST';
2160
+ form.action = action || '';
2161
+ form.target = target || '';
2162
+ form.style.display = 'none';
2163
+
2164
+ collection.forEachOwnProperties(data, function(value, key) {
2165
+ input = document.createElement('input');
2166
+ input.name = key;
2167
+ input.type = 'hidden';
2168
+ input.value = value;
2169
+ form.appendChild(input);
2170
+ });
2171
+
2172
+ container.appendChild(form);
2173
+
2174
+ return form;
2175
+ };
2176
+
2177
+ /**********
2178
+ * private methods
2179
+ **********/
2180
+
2181
+ /**
2182
+ * Return an query string made by parsing the given object
2183
+ * @param {Object} obj - An object that has information for query string
2184
+ * @returns {string} - Query string
2185
+ * @private
2186
+ */
2187
+ Popup.prototype._parameterize = function(obj) {
2188
+ var query = [];
2189
+
2190
+ collection.forEachOwnProperties(obj, function(value, key) {
2191
+ query.push(encodeURIComponent(key) + '=' + encodeURIComponent(value));
2192
+ });
2193
+
2194
+ return query.join('&');
2195
+ };
2196
+
2197
+ /**
2198
+ * Open popup
2199
+ * @param {boolean} useIEPostBridge - A switch option whether to use alternative
2200
+ * of tossing POST data to the popup window in IE11
2201
+ * @param {Object} param - A data for tossing to popup
2202
+ * @param {string} url - Popup url
2203
+ * @param {string} popupName - Popup name
2204
+ * @param {string} optionStr - Setting for popup, ex) 'width=640,height=320,scrollbars=yes'
2205
+ * @returns {Window} Window context of popup
2206
+ * @private
2207
+ */
2208
+ Popup.prototype._open = function(useIEPostBridge, param, url, popupName, optionStr) {
2209
+ var popup;
2210
+
2211
+ if (useIEPostBridge) {
2212
+ popup = window.open(this.postBridgeUrl, popupName, optionStr);
2213
+ setTimeout(function() {
2214
+ popup.redirect(url, param);
2215
+ }, 100);
2216
+ } else {
2217
+ popup = window.open(url, popupName, optionStr);
2218
+ }
2219
+
2220
+ return popup;
2221
+ };
2222
+
2223
+ module.exports = new Popup();
2224
+
2225
+
2226
+ /***/ }),
2227
+ /* 12 */
2228
+ /***/ (function(module, exports, __webpack_require__) {
2229
+
2230
+ /**
2231
+ * @fileoverview This module has a function for date format.
2232
+ * @author NHN.
2233
+ * FE Development Lab <dl_javascript@nhn.com>
2234
+ */
2235
+
2236
+ 'use strict';
2237
+
2238
+ var type = __webpack_require__(2);
2239
+ var object = __webpack_require__(1);
2240
+
2241
+ var tokens = /[\\]*YYYY|[\\]*YY|[\\]*MMMM|[\\]*MMM|[\\]*MM|[\\]*M|[\\]*DD|[\\]*D|[\\]*HH|[\\]*H|[\\]*A/gi;
2242
+ var MONTH_STR = [
2243
+ 'Invalid month', 'January', 'February', 'March', 'April', 'May',
2244
+ 'June', 'July', 'August', 'September', 'October', 'November', 'December'
2245
+ ];
2246
+ var MONTH_DAYS = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
2247
+ var replaceMap = {
2248
+ M: function(date) {
2249
+ return Number(date.month);
2250
+ },
2251
+ MM: function(date) {
2252
+ var month = date.month;
2253
+
2254
+ return (Number(month) < 10) ? '0' + month : month;
2255
+ },
2256
+ MMM: function(date) {
2257
+ return MONTH_STR[Number(date.month)].substr(0, 3);
2258
+ },
2259
+ MMMM: function(date) {
2260
+ return MONTH_STR[Number(date.month)];
2261
+ },
2262
+ D: function(date) {
2263
+ return Number(date.date);
2264
+ },
2265
+ d: function(date) {
2266
+ return replaceMap.D(date); // eslint-disable-line new-cap
2267
+ },
2268
+ DD: function(date) {
2269
+ var dayInMonth = date.date;
2270
+
2271
+ return (Number(dayInMonth) < 10) ? '0' + dayInMonth : dayInMonth;
2272
+ },
2273
+ dd: function(date) {
2274
+ return replaceMap.DD(date); // eslint-disable-line new-cap
2275
+ },
2276
+ YY: function(date) {
2277
+ return Number(date.year) % 100;
2278
+ },
2279
+ yy: function(date) {
2280
+ return replaceMap.YY(date); // eslint-disable-line new-cap
2281
+ },
2282
+ YYYY: function(date) {
2283
+ var prefix = '20',
2284
+ year = date.year;
2285
+ if (year > 69 && year < 100) {
2286
+ prefix = '19';
2287
+ }
2288
+
2289
+ return (Number(year) < 100) ? prefix + String(year) : year;
2290
+ },
2291
+ yyyy: function(date) {
2292
+ return replaceMap.YYYY(date); // eslint-disable-line new-cap
2293
+ },
2294
+ A: function(date) {
2295
+ return date.meridiem;
2296
+ },
2297
+ a: function(date) {
2298
+ return date.meridiem;
2299
+ },
2300
+ hh: function(date) {
2301
+ var hour = date.hour;
2302
+
2303
+ return (Number(hour) < 10) ? '0' + hour : hour;
2304
+ },
2305
+ HH: function(date) {
2306
+ return replaceMap.hh(date);
2307
+ },
2308
+ h: function(date) {
2309
+ return String(Number(date.hour));
2310
+ },
2311
+ H: function(date) {
2312
+ return replaceMap.h(date);
2313
+ },
2314
+ m: function(date) {
2315
+ return String(Number(date.minute));
2316
+ },
2317
+ mm: function(date) {
2318
+ var minute = date.minute;
2319
+
2320
+ return (Number(minute) < 10) ? '0' + minute : minute;
2321
+ }
2322
+ };
2323
+
2324
+ /**
2325
+ * Check whether the given variables are valid date or not.
2326
+ * @param {number} year - Year
2327
+ * @param {number} month - Month
2328
+ * @param {number} date - Day in month.
2329
+ * @returns {boolean} Is valid?
2330
+ * @private
2331
+ */
2332
+ function isValidDate(year, month, date) { // eslint-disable-line complexity
2333
+ var isValidYear, isValidMonth, isValid, lastDayInMonth;
2334
+
2335
+ year = Number(year);
2336
+ month = Number(month);
2337
+ date = Number(date);
2338
+
2339
+ isValidYear = (year > -1 && year < 100) || ((year > 1969) && (year < 2070));
2340
+ isValidMonth = (month > 0) && (month < 13);
2341
+
2342
+ if (!isValidYear || !isValidMonth) {
2343
+ return false;
2344
+ }
2345
+
2346
+ lastDayInMonth = MONTH_DAYS[month];
2347
+ if (month === 2 && year % 4 === 0) {
2348
+ if (year % 100 !== 0 || year % 400 === 0) {
2349
+ lastDayInMonth = 29;
2350
+ }
2351
+ }
2352
+
2353
+ isValid = (date > 0) && (date <= lastDayInMonth);
2354
+
2355
+ return isValid;
2356
+ }
2357
+
2358
+ /**
2359
+ * Return a string that transformed from the given form and date.
2360
+ * @param {string} form - Date form
2361
+ * @param {Date|Object} date - Date object
2362
+ * @param {{meridiemSet: {AM: string, PM: string}}} option - Option
2363
+ * @returns {boolean|string} A transformed string or false.
2364
+ * @memberof tui.util
2365
+ * @example
2366
+ * // key | Shorthand
2367
+ * // --------------- |-----------------------
2368
+ * // years | YY / YYYY / yy / yyyy
2369
+ * // months(n) | M / MM
2370
+ * // months(str) | MMM / MMMM
2371
+ * // days | D / DD / d / dd
2372
+ * // hours | H / HH / h / hh
2373
+ * // minutes | m / mm
2374
+ * // meridiem(AM,PM) | A / a
2375
+ *
2376
+ * //-- #1. Get Module --//
2377
+ * var util = require('tui-code-snippet'); // node, commonjs
2378
+ * var util = tui.util; // distribution file
2379
+ *
2380
+ * //-- #2. Use property --//
2381
+ * var dateStr1 = util.formatDate('yyyy-MM-dd', {
2382
+ * year: 2014,
2383
+ * month: 12,
2384
+ * date: 12
2385
+ * });
2386
+ * alert(dateStr1); // '2014-12-12'
2387
+ *
2388
+ * var dateStr2 = util.formatDate('MMM DD YYYY HH:mm', {
2389
+ * year: 1999,
2390
+ * month: 9,
2391
+ * date: 9,
2392
+ * hour: 0,
2393
+ * minute: 2
2394
+ * });
2395
+ * alert(dateStr2); // 'Sep 09 1999 00:02'
2396
+ *
2397
+ * var dt = new Date(2010, 2, 13),
2398
+ * dateStr3 = util.formatDate('yyyy년 M월 dd일', dt);
2399
+ * alert(dateStr3); // '2010년 3월 13일'
2400
+ *
2401
+ * var option4 = {
2402
+ * meridiemSet: {
2403
+ * AM: '오전',
2404
+ * PM: '오후'
2405
+ * }
2406
+ * };
2407
+ * var date4 = {year: 1999, month: 9, date: 9, hour: 13, minute: 2};
2408
+ * var dateStr4 = util.formatDate('yyyy-MM-dd A hh:mm', date4, option4));
2409
+ * alert(dateStr4); // '1999-09-09 오후 01:02'
2410
+ */
2411
+ function formatDate(form, date, option) { // eslint-disable-line complexity
2412
+ var am = object.pick(option, 'meridiemSet', 'AM') || 'AM';
2413
+ var pm = object.pick(option, 'meridiemSet', 'PM') || 'PM';
2414
+ var meridiem, nDate, resultStr;
2415
+
2416
+ if (type.isDate(date)) {
2417
+ nDate = {
2418
+ year: date.getFullYear(),
2419
+ month: date.getMonth() + 1,
2420
+ date: date.getDate(),
2421
+ hour: date.getHours(),
2422
+ minute: date.getMinutes()
2423
+ };
2424
+ } else {
2425
+ nDate = {
2426
+ year: date.year,
2427
+ month: date.month,
2428
+ date: date.date,
2429
+ hour: date.hour,
2430
+ minute: date.minute
2431
+ };
2432
+ }
2433
+
2434
+ if (!isValidDate(nDate.year, nDate.month, nDate.date)) {
2435
+ return false;
2436
+ }
2437
+
2438
+ nDate.meridiem = '';
2439
+ if (/([^\\]|^)[aA]\b/.test(form)) {
2440
+ meridiem = (nDate.hour > 11) ? pm : am;
2441
+ if (nDate.hour > 12) { // See the clock system: https://en.wikipedia.org/wiki/12-hour_clock
2442
+ nDate.hour %= 12;
2443
+ }
2444
+ if (nDate.hour === 0) {
2445
+ nDate.hour = 12;
2446
+ }
2447
+ nDate.meridiem = meridiem;
2448
+ }
2449
+
2450
+ resultStr = form.replace(tokens, function(key) {
2451
+ if (key.indexOf('\\') > -1) { // escape character
2452
+ return key.replace(/\\/, '');
2453
+ }
2454
+
2455
+ return replaceMap[key](nDate) || '';
2456
+ });
2457
+
2458
+ return resultStr;
2459
+ }
2460
+
2461
+ module.exports = formatDate;
2462
+
2463
+
2464
+ /***/ }),
2465
+ /* 13 */
2466
+ /***/ (function(module, exports, __webpack_require__) {
2467
+
2468
+ /**
2469
+ * @fileoverview
2470
+ * This module provides a function to make a constructor
2471
+ * that can inherit from the other constructors like the CLASS easily.
2472
+ * @author NHN.
2473
+ * FE Development Lab <dl_javascript@nhn.com>
2474
+ */
2475
+
2476
+ 'use strict';
2477
+
2478
+ var inherit = __webpack_require__(6).inherit;
2479
+ var extend = __webpack_require__(1).extend;
2480
+
2481
+ /**
2482
+ * Help a constructor to be defined and to inherit from the other constructors
2483
+ * @param {*} [parent] Parent constructor
2484
+ * @param {Object} props Members of constructor
2485
+ * @param {Function} props.init Initialization method
2486
+ * @param {Object} [props.static] Static members of constructor
2487
+ * @returns {*} Constructor
2488
+ * @memberof tui.util
2489
+ * @example
2490
+ * //-- #1. Get Module --//
2491
+ * var util = require('tui-code-snippet'); // node, commonjs
2492
+ * var util = tui.util; // distribution file
2493
+ *
2494
+ * //-- #2. Use property --//
2495
+ * var Parent = util.defineClass({
2496
+ * init: function() { // constuructor
2497
+ * this.name = 'made by def';
2498
+ * },
2499
+ * method: function() {
2500
+ * // ...
2501
+ * },
2502
+ * static: {
2503
+ * staticMethod: function() {
2504
+ * // ...
2505
+ * }
2506
+ * }
2507
+ * });
2508
+ *
2509
+ * var Child = util.defineClass(Parent, {
2510
+ * childMethod: function() {}
2511
+ * });
2512
+ *
2513
+ * Parent.staticMethod();
2514
+ *
2515
+ * var parentInstance = new Parent();
2516
+ * console.log(parentInstance.name); //made by def
2517
+ * parentInstance.staticMethod(); // Error
2518
+ *
2519
+ * var childInstance = new Child();
2520
+ * childInstance.method();
2521
+ * childInstance.childMethod();
2522
+ */
2523
+ function defineClass(parent, props) {
2524
+ var obj;
2525
+
2526
+ if (!props) {
2527
+ props = parent;
2528
+ parent = null;
2529
+ }
2530
+
2531
+ obj = props.init || function() {};
2532
+
2533
+ if (parent) {
2534
+ inherit(obj, parent);
2535
+ }
2536
+
2537
+ if (props.hasOwnProperty('static')) {
2538
+ extend(obj, props['static']);
2539
+ delete props['static'];
2540
+ }
2541
+
2542
+ extend(obj.prototype, props);
2543
+
2544
+ return obj;
2545
+ }
2546
+
2547
+ module.exports = defineClass;
2548
+
2549
+
2550
+ /***/ }),
2551
+ /* 14 */
2552
+ /***/ (function(module, exports, __webpack_require__) {
2553
+
2554
+ /**
2555
+ * @fileoverview Define module
2556
+ * @author NHN.
2557
+ * FE Development Lab <dl_javscript@nhn.com>
2558
+ * @dependency type.js, defineNamespace.js
2559
+ */
2560
+
2561
+ 'use strict';
2562
+
2563
+ var defineNamespace = __webpack_require__(15);
2564
+ var type = __webpack_require__(2);
2565
+
2566
+ var INITIALIZATION_METHOD_NAME = 'initialize';
2567
+
2568
+ /**
2569
+ * Define module
2570
+ * @param {string} namespace - Namespace of module
2571
+ * @param {Object} moduleDefinition - Object literal for module
2572
+ * @returns {Object} Defined module
2573
+ * @memberof tui.util
2574
+ * @example
2575
+ * //-- #1. Get Module --//
2576
+ * var util = require('tui-code-snippet'); // node, commonjs
2577
+ * var util = tui.util; // distribution file
2578
+ *
2579
+ * //-- #2. Use property --//
2580
+ * var myModule = util.defineModule('modules.myModule', {
2581
+ * name: 'john',
2582
+ * message: '',
2583
+ * initialize: function() {
2584
+ * this.message = 'hello world';
2585
+ * },
2586
+ * getMessage: function() {
2587
+ * return this.name + ': ' + this.message
2588
+ * }
2589
+ * });
2590
+ *
2591
+ * console.log(myModule.getMessage()); // 'john: hello world';
2592
+ */
2593
+ function defineModule(namespace, moduleDefinition) {
2594
+ var base = moduleDefinition || {};
2595
+
2596
+ if (type.isFunction(base[INITIALIZATION_METHOD_NAME])) {
2597
+ base[INITIALIZATION_METHOD_NAME]();
2598
+ }
2599
+
2600
+ return defineNamespace(namespace, base);
2601
+ }
2602
+
2603
+ module.exports = defineModule;
2604
+
2605
+
2606
+ /***/ }),
2607
+ /* 15 */
2608
+ /***/ (function(module, exports, __webpack_require__) {
2609
+
2610
+ /**
2611
+ * @fileoverview Define namespace
2612
+ * @author NHN.
2613
+ * FE Development Lab <dl_javascript@nhn.com>
2614
+ * @dependency object.js, collection.js
2615
+ */
2616
+
2617
+ 'use strict';
2618
+
2619
+ var collection = __webpack_require__(4);
2620
+ var object = __webpack_require__(1);
2621
+
2622
+ /**
2623
+ * Define namespace
2624
+ * @param {string} namespace - Namespace (ex- 'foo.bar.baz')
2625
+ * @param {(object|function)} props - A set of modules or one module
2626
+ * @param {boolean} [isOverride] - Override the props to the namespace.<br>
2627
+ * (It removes previous properties of this namespace)
2628
+ * @returns {(object|function)} Defined namespace
2629
+ * @memberof tui.util
2630
+ * @example
2631
+ * //-- #1. Get Module --//
2632
+ * var util = require('tui-code-snippet'); // node, commonjs
2633
+ * var util = tui.util; // distribution file
2634
+ *
2635
+ * //-- #2. Use property --//
2636
+ * var neComp = util.defineNamespace;
2637
+ * neComp.listMenu = defineClass({
2638
+ * init: function() {
2639
+ * // ...
2640
+ * }
2641
+ * });
2642
+ */
2643
+ function defineNamespace(namespace, props, isOverride) {
2644
+ var names, result, prevLast, last;
2645
+
2646
+ names = namespace.split('.');
2647
+ names.unshift(window);
2648
+
2649
+ result = collection.reduce(names, function(obj, name) {
2650
+ obj[name] = obj[name] || {};
2651
+
2652
+ return obj[name];
2653
+ });
2654
+
2655
+ if (isOverride) {
2656
+ last = names.pop();
2657
+ prevLast = object.pick.apply(null, names);
2658
+ result = prevLast[last] = props;
2659
+ } else {
2660
+ object.extend(result, props);
2661
+ }
2662
+
2663
+ return result;
2664
+ }
2665
+
2666
+ module.exports = defineNamespace;
2667
+
2668
+
2669
+ /***/ }),
2670
+ /* 16 */
2671
+ /***/ (function(module, exports, __webpack_require__) {
2672
+
2673
+ /**
2674
+ * @fileoverview
2675
+ * This module provides some functions for custom events.<br>
2676
+ * And it is implemented in the observer design pattern.
2677
+ * @author NHN.
2678
+ * FE Development Lab <dl_javascript@nhn.com>
2679
+ */
2680
+
2681
+ 'use strict';
2682
+
2683
+ var collection = __webpack_require__(4);
2684
+ var type = __webpack_require__(2);
2685
+ var object = __webpack_require__(1);
2686
+
2687
+ var R_EVENTNAME_SPLIT = /\s+/g;
2688
+
2689
+ /**
2690
+ * A unit of event handler item.
2691
+ * @ignore
2692
+ * @typedef {object} HandlerItem
2693
+ * @property {function} fn - event handler
2694
+ * @property {object} ctx - context of event handler
2695
+ */
2696
+
2697
+ /**
2698
+ * @class
2699
+ * @memberof tui.util
2700
+ * @example
2701
+ * // node, commonjs
2702
+ * var CustomEvents = require('tui-code-snippet').CustomEvents;
2703
+ * @example
2704
+ * // distribution file, script
2705
+ * <script src='path-to/tui-code-snippt.js'></script>
2706
+ * <script>
2707
+ * var CustomEvents = tui.util.CustomEvents;
2708
+ * </script>
2709
+ */
2710
+ function CustomEvents() {
2711
+ /**
2712
+ * @type {HandlerItem[]}
2713
+ */
2714
+ this.events = null;
2715
+
2716
+ /**
2717
+ * only for checking specific context event was binded
2718
+ * @type {object[]}
2719
+ */
2720
+ this.contexts = null;
2721
+ }
2722
+
2723
+ /**
2724
+ * Mixin custom events feature to specific constructor
2725
+ * @param {function} func - constructor
2726
+ * @example
2727
+ * //-- #1. Get Module --//
2728
+ * var CustomEvents = require('tui-code-snippet').CustomEvents; // node, commonjs
2729
+ * var CustomEvents = tui.util.CustomEvents; // distribution file
2730
+ *
2731
+ * //-- #2. Use property --//
2732
+ * var model;
2733
+ * function Model() {
2734
+ * this.name = '';
2735
+ * }
2736
+ * CustomEvents.mixin(Model);
2737
+ *
2738
+ * model = new Model();
2739
+ * model.on('change', function() { this.name = 'model'; }, this);
2740
+ * model.fire('change');
2741
+ * alert(model.name); // 'model';
2742
+ */
2743
+ CustomEvents.mixin = function(func) {
2744
+ object.extend(func.prototype, CustomEvents.prototype);
2745
+ };
2746
+
2747
+ /**
2748
+ * Get HandlerItem object
2749
+ * @param {function} handler - handler function
2750
+ * @param {object} [context] - context for handler
2751
+ * @returns {HandlerItem} HandlerItem object
2752
+ * @private
2753
+ */
2754
+ CustomEvents.prototype._getHandlerItem = function(handler, context) {
2755
+ var item = {handler: handler};
2756
+
2757
+ if (context) {
2758
+ item.context = context;
2759
+ }
2760
+
2761
+ return item;
2762
+ };
2763
+
2764
+ /**
2765
+ * Get event object safely
2766
+ * @param {string} [eventName] - create sub event map if not exist.
2767
+ * @returns {(object|array)} event object. if you supplied `eventName`
2768
+ * parameter then make new array and return it
2769
+ * @private
2770
+ */
2771
+ CustomEvents.prototype._safeEvent = function(eventName) {
2772
+ var events = this.events;
2773
+ var byName;
2774
+
2775
+ if (!events) {
2776
+ events = this.events = {};
2777
+ }
2778
+
2779
+ if (eventName) {
2780
+ byName = events[eventName];
2781
+
2782
+ if (!byName) {
2783
+ byName = [];
2784
+ events[eventName] = byName;
2785
+ }
2786
+
2787
+ events = byName;
2788
+ }
2789
+
2790
+ return events;
2791
+ };
2792
+
2793
+ /**
2794
+ * Get context array safely
2795
+ * @returns {array} context array
2796
+ * @private
2797
+ */
2798
+ CustomEvents.prototype._safeContext = function() {
2799
+ var context = this.contexts;
2800
+
2801
+ if (!context) {
2802
+ context = this.contexts = [];
2803
+ }
2804
+
2805
+ return context;
2806
+ };
2807
+
2808
+ /**
2809
+ * Get index of context
2810
+ * @param {object} ctx - context that used for bind custom event
2811
+ * @returns {number} index of context
2812
+ * @private
2813
+ */
2814
+ CustomEvents.prototype._indexOfContext = function(ctx) {
2815
+ var context = this._safeContext();
2816
+ var index = 0;
2817
+
2818
+ while (context[index]) {
2819
+ if (ctx === context[index][0]) {
2820
+ return index;
2821
+ }
2822
+
2823
+ index += 1;
2824
+ }
2825
+
2826
+ return -1;
2827
+ };
2828
+
2829
+ /**
2830
+ * Memorize supplied context for recognize supplied object is context or
2831
+ * name: handler pair object when off()
2832
+ * @param {object} ctx - context object to memorize
2833
+ * @private
2834
+ */
2835
+ CustomEvents.prototype._memorizeContext = function(ctx) {
2836
+ var context, index;
2837
+
2838
+ if (!type.isExisty(ctx)) {
2839
+ return;
2840
+ }
2841
+
2842
+ context = this._safeContext();
2843
+ index = this._indexOfContext(ctx);
2844
+
2845
+ if (index > -1) {
2846
+ context[index][1] += 1;
2847
+ } else {
2848
+ context.push([ctx, 1]);
2849
+ }
2850
+ };
2851
+
2852
+ /**
2853
+ * Forget supplied context object
2854
+ * @param {object} ctx - context object to forget
2855
+ * @private
2856
+ */
2857
+ CustomEvents.prototype._forgetContext = function(ctx) {
2858
+ var context, contextIndex;
2859
+
2860
+ if (!type.isExisty(ctx)) {
2861
+ return;
2862
+ }
2863
+
2864
+ context = this._safeContext();
2865
+ contextIndex = this._indexOfContext(ctx);
2866
+
2867
+ if (contextIndex > -1) {
2868
+ context[contextIndex][1] -= 1;
2869
+
2870
+ if (context[contextIndex][1] <= 0) {
2871
+ context.splice(contextIndex, 1);
2872
+ }
2873
+ }
2874
+ };
2875
+
2876
+ /**
2877
+ * Bind event handler
2878
+ * @param {(string|{name:string, handler:function})} eventName - custom
2879
+ * event name or an object {eventName: handler}
2880
+ * @param {(function|object)} [handler] - handler function or context
2881
+ * @param {object} [context] - context for binding
2882
+ * @private
2883
+ */
2884
+ CustomEvents.prototype._bindEvent = function(eventName, handler, context) {
2885
+ var events = this._safeEvent(eventName);
2886
+ this._memorizeContext(context);
2887
+ events.push(this._getHandlerItem(handler, context));
2888
+ };
2889
+
2890
+ /**
2891
+ * Bind event handlers
2892
+ * @param {(string|{name:string, handler:function})} eventName - custom
2893
+ * event name or an object {eventName: handler}
2894
+ * @param {(function|object)} [handler] - handler function or context
2895
+ * @param {object} [context] - context for binding
2896
+ * //-- #1. Get Module --//
2897
+ * var CustomEvents = require('tui-code-snippet').CustomEvents; // node, commonjs
2898
+ * var CustomEvents = tui.util.CustomEvents; // distribution file
2899
+ *
2900
+ * //-- #2. Use property --//
2901
+ * // # 2.1 Basic Usage
2902
+ * CustomEvents.on('onload', handler);
2903
+ *
2904
+ * // # 2.2 With context
2905
+ * CustomEvents.on('onload', handler, myObj);
2906
+ *
2907
+ * // # 2.3 Bind by object that name, handler pairs
2908
+ * CustomEvents.on({
2909
+ * 'play': handler,
2910
+ * 'pause': handler2
2911
+ * });
2912
+ *
2913
+ * // # 2.4 Bind by object that name, handler pairs with context object
2914
+ * CustomEvents.on({
2915
+ * 'play': handler
2916
+ * }, myObj);
2917
+ */
2918
+ CustomEvents.prototype.on = function(eventName, handler, context) {
2919
+ var self = this;
2920
+
2921
+ if (type.isString(eventName)) {
2922
+ // [syntax 1, 2]
2923
+ eventName = eventName.split(R_EVENTNAME_SPLIT);
2924
+ collection.forEach(eventName, function(name) {
2925
+ self._bindEvent(name, handler, context);
2926
+ });
2927
+ } else if (type.isObject(eventName)) {
2928
+ // [syntax 3, 4]
2929
+ context = handler;
2930
+ collection.forEach(eventName, function(func, name) {
2931
+ self.on(name, func, context);
2932
+ });
2933
+ }
2934
+ };
2935
+
2936
+ /**
2937
+ * Bind one-shot event handlers
2938
+ * @param {(string|{name:string,handler:function})} eventName - custom
2939
+ * event name or an object {eventName: handler}
2940
+ * @param {function|object} [handler] - handler function or context
2941
+ * @param {object} [context] - context for binding
2942
+ */
2943
+ CustomEvents.prototype.once = function(eventName, handler, context) {
2944
+ var self = this;
2945
+
2946
+ if (type.isObject(eventName)) {
2947
+ context = handler;
2948
+ collection.forEach(eventName, function(func, name) {
2949
+ self.once(name, func, context);
2950
+ });
2951
+
2952
+ return;
2953
+ }
2954
+
2955
+ function onceHandler() { // eslint-disable-line require-jsdoc
2956
+ handler.apply(context, arguments);
2957
+ self.off(eventName, onceHandler, context);
2958
+ }
2959
+
2960
+ this.on(eventName, onceHandler, context);
2961
+ };
2962
+
2963
+ /**
2964
+ * Splice supplied array by callback result
2965
+ * @param {array} arr - array to splice
2966
+ * @param {function} predicate - function return boolean
2967
+ * @private
2968
+ */
2969
+ CustomEvents.prototype._spliceMatches = function(arr, predicate) {
2970
+ var i = 0;
2971
+ var len;
2972
+
2973
+ if (!type.isArray(arr)) {
2974
+ return;
2975
+ }
2976
+
2977
+ for (len = arr.length; i < len; i += 1) {
2978
+ if (predicate(arr[i]) === true) {
2979
+ arr.splice(i, 1);
2980
+ len -= 1;
2981
+ i -= 1;
2982
+ }
2983
+ }
2984
+ };
2985
+
2986
+ /**
2987
+ * Get matcher for unbind specific handler events
2988
+ * @param {function} handler - handler function
2989
+ * @returns {function} handler matcher
2990
+ * @private
2991
+ */
2992
+ CustomEvents.prototype._matchHandler = function(handler) {
2993
+ var self = this;
2994
+
2995
+ return function(item) {
2996
+ var needRemove = handler === item.handler;
2997
+
2998
+ if (needRemove) {
2999
+ self._forgetContext(item.context);
3000
+ }
3001
+
3002
+ return needRemove;
3003
+ };
3004
+ };
3005
+
3006
+ /**
3007
+ * Get matcher for unbind specific context events
3008
+ * @param {object} context - context
3009
+ * @returns {function} object matcher
3010
+ * @private
3011
+ */
3012
+ CustomEvents.prototype._matchContext = function(context) {
3013
+ var self = this;
3014
+
3015
+ return function(item) {
3016
+ var needRemove = context === item.context;
3017
+
3018
+ if (needRemove) {
3019
+ self._forgetContext(item.context);
3020
+ }
3021
+
3022
+ return needRemove;
3023
+ };
3024
+ };
3025
+
3026
+ /**
3027
+ * Get matcher for unbind specific hander, context pair events
3028
+ * @param {function} handler - handler function
3029
+ * @param {object} context - context
3030
+ * @returns {function} handler, context matcher
3031
+ * @private
3032
+ */
3033
+ CustomEvents.prototype._matchHandlerAndContext = function(handler, context) {
3034
+ var self = this;
3035
+
3036
+ return function(item) {
3037
+ var matchHandler = (handler === item.handler);
3038
+ var matchContext = (context === item.context);
3039
+ var needRemove = (matchHandler && matchContext);
3040
+
3041
+ if (needRemove) {
3042
+ self._forgetContext(item.context);
3043
+ }
3044
+
3045
+ return needRemove;
3046
+ };
3047
+ };
3048
+
3049
+ /**
3050
+ * Unbind event by event name
3051
+ * @param {string} eventName - custom event name to unbind
3052
+ * @param {function} [handler] - handler function
3053
+ * @private
3054
+ */
3055
+ CustomEvents.prototype._offByEventName = function(eventName, handler) {
3056
+ var self = this;
3057
+ var forEach = collection.forEachArray;
3058
+ var andByHandler = type.isFunction(handler);
3059
+ var matchHandler = self._matchHandler(handler);
3060
+
3061
+ eventName = eventName.split(R_EVENTNAME_SPLIT);
3062
+
3063
+ forEach(eventName, function(name) {
3064
+ var handlerItems = self._safeEvent(name);
3065
+
3066
+ if (andByHandler) {
3067
+ self._spliceMatches(handlerItems, matchHandler);
3068
+ } else {
3069
+ forEach(handlerItems, function(item) {
3070
+ self._forgetContext(item.context);
3071
+ });
3072
+
3073
+ self.events[name] = [];
3074
+ }
3075
+ });
3076
+ };
3077
+
3078
+ /**
3079
+ * Unbind event by handler function
3080
+ * @param {function} handler - handler function
3081
+ * @private
3082
+ */
3083
+ CustomEvents.prototype._offByHandler = function(handler) {
3084
+ var self = this;
3085
+ var matchHandler = this._matchHandler(handler);
3086
+
3087
+ collection.forEach(this._safeEvent(), function(handlerItems) {
3088
+ self._spliceMatches(handlerItems, matchHandler);
3089
+ });
3090
+ };
3091
+
3092
+ /**
3093
+ * Unbind event by object(name: handler pair object or context object)
3094
+ * @param {object} obj - context or {name: handler} pair object
3095
+ * @param {function} handler - handler function
3096
+ * @private
3097
+ */
3098
+ CustomEvents.prototype._offByObject = function(obj, handler) {
3099
+ var self = this;
3100
+ var matchFunc;
3101
+
3102
+ if (this._indexOfContext(obj) < 0) {
3103
+ collection.forEach(obj, function(func, name) {
3104
+ self.off(name, func);
3105
+ });
3106
+ } else if (type.isString(handler)) {
3107
+ matchFunc = this._matchContext(obj);
3108
+
3109
+ self._spliceMatches(this._safeEvent(handler), matchFunc);
3110
+ } else if (type.isFunction(handler)) {
3111
+ matchFunc = this._matchHandlerAndContext(handler, obj);
3112
+
3113
+ collection.forEach(this._safeEvent(), function(handlerItems) {
3114
+ self._spliceMatches(handlerItems, matchFunc);
3115
+ });
3116
+ } else {
3117
+ matchFunc = this._matchContext(obj);
3118
+
3119
+ collection.forEach(this._safeEvent(), function(handlerItems) {
3120
+ self._spliceMatches(handlerItems, matchFunc);
3121
+ });
3122
+ }
3123
+ };
3124
+
3125
+ /**
3126
+ * Unbind custom events
3127
+ * @param {(string|object|function)} eventName - event name or context or
3128
+ * {name: handler} pair object or handler function
3129
+ * @param {(function)} handler - handler function
3130
+ * @example
3131
+ * //-- #1. Get Module --//
3132
+ * var CustomEvents = require('tui-code-snippet').CustomEvents; // node, commonjs
3133
+ * var CustomEvents = tui.util.CustomEvents; // distribution file
3134
+ *
3135
+ * //-- #2. Use property --//
3136
+ * // # 2.1 off by event name
3137
+ * CustomEvents.off('onload');
3138
+ *
3139
+ * // # 2.2 off by event name and handler
3140
+ * CustomEvents.off('play', handler);
3141
+ *
3142
+ * // # 2.3 off by handler
3143
+ * CustomEvents.off(handler);
3144
+ *
3145
+ * // # 2.4 off by context
3146
+ * CustomEvents.off(myObj);
3147
+ *
3148
+ * // # 2.5 off by context and handler
3149
+ * CustomEvents.off(myObj, handler);
3150
+ *
3151
+ * // # 2.6 off by context and event name
3152
+ * CustomEvents.off(myObj, 'onload');
3153
+ *
3154
+ * // # 2.7 off by an Object.<string, function> that is {eventName: handler}
3155
+ * CustomEvents.off({
3156
+ * 'play': handler,
3157
+ * 'pause': handler2
3158
+ * });
3159
+ *
3160
+ * // # 2.8 off the all events
3161
+ * CustomEvents.off();
3162
+ */
3163
+ CustomEvents.prototype.off = function(eventName, handler) {
3164
+ if (type.isString(eventName)) {
3165
+ // [syntax 1, 2]
3166
+ this._offByEventName(eventName, handler);
3167
+ } else if (!arguments.length) {
3168
+ // [syntax 8]
3169
+ this.events = {};
3170
+ this.contexts = [];
3171
+ } else if (type.isFunction(eventName)) {
3172
+ // [syntax 3]
3173
+ this._offByHandler(eventName);
3174
+ } else if (type.isObject(eventName)) {
3175
+ // [syntax 4, 5, 6]
3176
+ this._offByObject(eventName, handler);
3177
+ }
3178
+ };
3179
+
3180
+ /**
3181
+ * Fire custom event
3182
+ * @param {string} eventName - name of custom event
3183
+ */
3184
+ CustomEvents.prototype.fire = function(eventName) { // eslint-disable-line
3185
+ this.invoke.apply(this, arguments);
3186
+ };
3187
+
3188
+ /**
3189
+ * Fire a event and returns the result of operation 'boolean AND' with all
3190
+ * listener's results.
3191
+ *
3192
+ * So, It is different from {@link CustomEvents#fire}.
3193
+ *
3194
+ * In service code, use this as a before event in component level usually
3195
+ * for notifying that the event is cancelable.
3196
+ * @param {string} eventName - Custom event name
3197
+ * @param {...*} data - Data for event
3198
+ * @returns {boolean} The result of operation 'boolean AND'
3199
+ * @example
3200
+ * var map = new Map();
3201
+ * map.on({
3202
+ * 'beforeZoom': function() {
3203
+ * // It should cancel the 'zoom' event by some conditions.
3204
+ * if (that.disabled && this.getState()) {
3205
+ * return false;
3206
+ * }
3207
+ * return true;
3208
+ * }
3209
+ * });
3210
+ *
3211
+ * if (this.invoke('beforeZoom')) { // check the result of 'beforeZoom'
3212
+ * // if true,
3213
+ * // doSomething
3214
+ * }
3215
+ */
3216
+ CustomEvents.prototype.invoke = function(eventName) {
3217
+ var events, args, index, item;
3218
+
3219
+ if (!this.hasListener(eventName)) {
3220
+ return true;
3221
+ }
3222
+
3223
+ events = this._safeEvent(eventName);
3224
+ args = Array.prototype.slice.call(arguments, 1);
3225
+ index = 0;
3226
+
3227
+ while (events[index]) {
3228
+ item = events[index];
3229
+
3230
+ if (item.handler.apply(item.context, args) === false) {
3231
+ return false;
3232
+ }
3233
+
3234
+ index += 1;
3235
+ }
3236
+
3237
+ return true;
3238
+ };
3239
+
3240
+ /**
3241
+ * Return whether at least one of the handlers is registered in the given
3242
+ * event name.
3243
+ * @param {string} eventName - Custom event name
3244
+ * @returns {boolean} Is there at least one handler in event name?
3245
+ */
3246
+ CustomEvents.prototype.hasListener = function(eventName) {
3247
+ return this.getListenerLength(eventName) > 0;
3248
+ };
3249
+
3250
+ /**
3251
+ * Return a count of events registered.
3252
+ * @param {string} eventName - Custom event name
3253
+ * @returns {number} number of event
3254
+ */
3255
+ CustomEvents.prototype.getListenerLength = function(eventName) {
3256
+ var events = this._safeEvent(eventName);
3257
+
3258
+ return events.length;
3259
+ };
3260
+
3261
+ module.exports = CustomEvents;
3262
+
3263
+
3264
+ /***/ }),
3265
+ /* 17 */
3266
+ /***/ (function(module, exports, __webpack_require__) {
3267
+
3268
+ /**
3269
+ * @fileoverview This module provides a Enum Constructor.
3270
+ * @author NHN.
3271
+ * FE Development Lab <dl_javascript@nhn.com>
3272
+ * @example
3273
+ * // node, commonjs
3274
+ * var Enum = require('tui-code-snippet').Enum;
3275
+ * @example
3276
+ * // distribution file, script
3277
+ * <script src='path-to/tui-code-snippt.js'></script>
3278
+ * <script>
3279
+ * var Enum = tui.util.Enum;
3280
+ * <script>
3281
+ */
3282
+
3283
+ 'use strict';
3284
+
3285
+ var collection = __webpack_require__(4);
3286
+ var type = __webpack_require__(2);
3287
+
3288
+ /**
3289
+ * Check whether the defineProperty() method is supported.
3290
+ * @type {boolean}
3291
+ * @ignore
3292
+ */
3293
+ var isSupportDefinedProperty = (function() {
3294
+ try {
3295
+ Object.defineProperty({}, 'x', {});
3296
+
3297
+ return true;
3298
+ } catch (e) {
3299
+ return false;
3300
+ }
3301
+ })();
3302
+
3303
+ /**
3304
+ * A unique value of a constant.
3305
+ * @type {number}
3306
+ * @ignore
3307
+ */
3308
+ var enumValue = 0;
3309
+
3310
+ /**
3311
+ * Make a constant-list that has unique values.<br>
3312
+ * In modern browsers (except IE8 and lower),<br>
3313
+ * a value defined once can not be changed.
3314
+ *
3315
+ * @param {...string|string[]} itemList Constant-list (An array of string is available)
3316
+ * @class
3317
+ * @memberof tui.util
3318
+ * @example
3319
+ * //-- #1. Get Module --//
3320
+ * var Enum = require('tui-code-snippet').Enum; // node, commonjs
3321
+ * var Enum = tui.util.Enum; // distribution file
3322
+ *
3323
+ * //-- #2. Use property --//
3324
+ * var MYENUM = new Enum('TYPE1', 'TYPE2');
3325
+ * var MYENUM2 = new Enum(['TYPE1', 'TYPE2']);
3326
+ *
3327
+ * //usage
3328
+ * if (value === MYENUM.TYPE1) {
3329
+ * ....
3330
+ * }
3331
+ *
3332
+ * //add (If a duplicate name is inputted, will be disregarded.)
3333
+ * MYENUM.set('TYPE3', 'TYPE4');
3334
+ *
3335
+ * //get name of a constant by a value
3336
+ * MYENUM.getName(MYENUM.TYPE1); // 'TYPE1'
3337
+ *
3338
+ * // In modern browsers (except IE8 and lower), a value can not be changed in constants.
3339
+ * var originalValue = MYENUM.TYPE1;
3340
+ * MYENUM.TYPE1 = 1234; // maybe TypeError
3341
+ * MYENUM.TYPE1 === originalValue; // true
3342
+ **/
3343
+ function Enum(itemList) {
3344
+ if (itemList) {
3345
+ this.set.apply(this, arguments);
3346
+ }
3347
+ }
3348
+
3349
+ /**
3350
+ * Define a constants-list
3351
+ * @param {...string|string[]} itemList Constant-list (An array of string is available)
3352
+ */
3353
+ Enum.prototype.set = function(itemList) {
3354
+ var self = this;
3355
+
3356
+ if (!type.isArray(itemList)) {
3357
+ itemList = collection.toArray(arguments);
3358
+ }
3359
+
3360
+ collection.forEach(itemList, function itemListIteratee(item) {
3361
+ self._addItem(item);
3362
+ });
3363
+ };
3364
+
3365
+ /**
3366
+ * Return a key of the constant.
3367
+ * @param {number} value A value of the constant.
3368
+ * @returns {string|undefined} Key of the constant.
3369
+ */
3370
+ Enum.prototype.getName = function(value) {
3371
+ var self = this;
3372
+ var foundedKey;
3373
+
3374
+ collection.forEach(this, function(itemValue, key) { // eslint-disable-line consistent-return
3375
+ if (self._isEnumItem(key) && value === itemValue) {
3376
+ foundedKey = key;
3377
+
3378
+ return false;
3379
+ }
3380
+ });
3381
+
3382
+ return foundedKey;
3383
+ };
3384
+
3385
+ /**
3386
+ * Create a constant.
3387
+ * @private
3388
+ * @param {string} name Constant name. (It will be a key of a constant)
3389
+ */
3390
+ Enum.prototype._addItem = function(name) {
3391
+ var value;
3392
+
3393
+ if (!this.hasOwnProperty(name)) {
3394
+ value = this._makeEnumValue();
3395
+
3396
+ if (isSupportDefinedProperty) {
3397
+ Object.defineProperty(this, name, {
3398
+ enumerable: true,
3399
+ configurable: false,
3400
+ writable: false,
3401
+ value: value
3402
+ });
3403
+ } else {
3404
+ this[name] = value;
3405
+ }
3406
+ }
3407
+ };
3408
+
3409
+ /**
3410
+ * Return a unique value for assigning to a constant.
3411
+ * @private
3412
+ * @returns {number} A unique value
3413
+ */
3414
+ Enum.prototype._makeEnumValue = function() {
3415
+ var value;
3416
+
3417
+ value = enumValue;
3418
+ enumValue += 1;
3419
+
3420
+ return value;
3421
+ };
3422
+
3423
+ /**
3424
+ * Return whether a constant from the given key is in instance or not.
3425
+ * @param {string} key - A constant key
3426
+ * @returns {boolean} Result
3427
+ * @private
3428
+ */
3429
+ Enum.prototype._isEnumItem = function(key) {
3430
+ return type.isNumber(this[key]);
3431
+ };
3432
+
3433
+ module.exports = Enum;
3434
+
3435
+
3436
+ /***/ }),
3437
+ /* 18 */
3438
+ /***/ (function(module, exports, __webpack_require__) {
3439
+
3440
+ /**
3441
+ * @fileoverview
3442
+ * Implements the ExMap (Extended Map) object.
3443
+ * @author NHN.
3444
+ * FE Development Lab <dl_javascript@nhn.com>
3445
+ */
3446
+
3447
+ 'use strict';
3448
+
3449
+ var collection = __webpack_require__(4);
3450
+ var Map = __webpack_require__(19);
3451
+
3452
+ // Caching tui.util for performance enhancing
3453
+ var mapAPIsForRead = ['get', 'has', 'forEach', 'keys', 'values', 'entries'];
3454
+ var mapAPIsForDelete = ['delete', 'clear'];
3455
+
3456
+ /**
3457
+ * The ExMap object is Extended Version of the tui.util.Map object.<br>
3458
+ * and added some useful feature to make it easy to manage the Map object.
3459
+ * @constructor
3460
+ * @param {Array} initData - Array of key-value pairs (2-element Arrays).
3461
+ * Each key-value pair will be added to the new Map
3462
+ * @memberof tui.util
3463
+ * @example
3464
+ * // node, commonjs
3465
+ * var ExMap = require('tui-code-snippet').ExMap;
3466
+ * @example
3467
+ * // distribution file, script
3468
+ * <script src='path-to/tui-code-snippt.js'></script>
3469
+ * <script>
3470
+ * var ExMap = tui.util.ExMap;
3471
+ * <script>
3472
+ */
3473
+ function ExMap(initData) {
3474
+ this._map = new Map(initData);
3475
+ this.size = this._map.size;
3476
+ }
3477
+
3478
+ collection.forEachArray(mapAPIsForRead, function(name) {
3479
+ ExMap.prototype[name] = function() {
3480
+ return this._map[name].apply(this._map, arguments);
3481
+ };
3482
+ });
3483
+
3484
+ collection.forEachArray(mapAPIsForDelete, function(name) {
3485
+ ExMap.prototype[name] = function() {
3486
+ var result = this._map[name].apply(this._map, arguments);
3487
+ this.size = this._map.size;
3488
+
3489
+ return result;
3490
+ };
3491
+ });
3492
+
3493
+ ExMap.prototype.set = function() {
3494
+ this._map.set.apply(this._map, arguments);
3495
+ this.size = this._map.size;
3496
+
3497
+ return this;
3498
+ };
3499
+
3500
+ /**
3501
+ * Sets all of the key-value pairs in the specified object to the Map object.
3502
+ * @param {Object} object - Plain object that has a key-value pair
3503
+ */
3504
+ ExMap.prototype.setObject = function(object) {
3505
+ collection.forEachOwnProperties(object, function(value, key) {
3506
+ this.set(key, value);
3507
+ }, this);
3508
+ };
3509
+
3510
+ /**
3511
+ * Removes the elements associated with keys in the specified array.
3512
+ * @param {Array} keys - Array that contains keys of the element to remove
3513
+ */
3514
+ ExMap.prototype.deleteByKeys = function(keys) {
3515
+ collection.forEachArray(keys, function(key) {
3516
+ this['delete'](key);
3517
+ }, this);
3518
+ };
3519
+
3520
+ /**
3521
+ * Sets all of the key-value pairs in the specified Map object to this Map object.
3522
+ * @param {Map} map - Map object to be merged into this Map object
3523
+ */
3524
+ ExMap.prototype.merge = function(map) {
3525
+ map.forEach(function(value, key) {
3526
+ this.set(key, value);
3527
+ }, this);
3528
+ };
3529
+
3530
+ /**
3531
+ * Looks through each key-value pair in the map and returns the new ExMap object of
3532
+ * all key-value pairs that pass a truth test implemented by the provided function.
3533
+ * @param {function} predicate - Function to test each key-value pair of the Map object.<br>
3534
+ * Invoked with arguments (value, key). Return true to keep the element, false otherwise.
3535
+ * @returns {ExMap} A new ExMap object
3536
+ */
3537
+ ExMap.prototype.filter = function(predicate) {
3538
+ var filtered = new ExMap();
3539
+
3540
+ this.forEach(function(value, key) {
3541
+ if (predicate(value, key)) {
3542
+ filtered.set(key, value);
3543
+ }
3544
+ });
3545
+
3546
+ return filtered;
3547
+ };
3548
+
3549
+ module.exports = ExMap;
3550
+
3551
+
3552
+ /***/ }),
3553
+ /* 19 */
3554
+ /***/ (function(module, exports, __webpack_require__) {
3555
+
3556
+
3557
+ /**
3558
+ * @fileoverview
3559
+ * Implements the Map object.
3560
+ * @author NHN.
3561
+ * FE Development Lab <dl_javascript@nhn.com>
3562
+ */
3563
+
3564
+ 'use strict';
3565
+
3566
+ var collection = __webpack_require__(4);
3567
+ var type = __webpack_require__(2);
3568
+ var array = __webpack_require__(3);
3569
+ var browser = __webpack_require__(10);
3570
+ var func = __webpack_require__(5);
3571
+
3572
+ /**
3573
+ * Using undefined for a key can be ambiguous if there's deleted item in the array,<br>
3574
+ * which is also undefined when accessed by index.<br>
3575
+ * So use this unique object as an undefined key to distinguish it from deleted keys.
3576
+ * @private
3577
+ * @constant
3578
+ */
3579
+ var _KEY_FOR_UNDEFINED = {};
3580
+
3581
+ /**
3582
+ * For using NaN as a key, use this unique object as a NaN key.<br>
3583
+ * This makes it easier and faster to compare an object with each keys in the array<br>
3584
+ * through no exceptional comapring for NaN.
3585
+ * @private
3586
+ * @constant
3587
+ */
3588
+ var _KEY_FOR_NAN = {};
3589
+
3590
+ /**
3591
+ * Constructor of MapIterator<br>
3592
+ * Creates iterator object with new keyword.
3593
+ * @constructor
3594
+ * @param {Array} keys - The array of keys in the map
3595
+ * @param {function} valueGetter - Function that returns certain value,
3596
+ * taking key and keyIndex as arguments.
3597
+ * @ignore
3598
+ */
3599
+ function MapIterator(keys, valueGetter) {
3600
+ this._keys = keys;
3601
+ this._valueGetter = valueGetter;
3602
+ this._length = this._keys.length;
3603
+ this._index = -1;
3604
+ this._done = false;
3605
+ }
3606
+
3607
+ /**
3608
+ * Implementation of Iterator protocol.
3609
+ * @returns {{done: boolean, value: *}} Object that contains done(boolean) and value.
3610
+ */
3611
+ MapIterator.prototype.next = function() {
3612
+ var data = {};
3613
+ do {
3614
+ this._index += 1;
3615
+ } while (type.isUndefined(this._keys[this._index]) && this._index < this._length);
3616
+
3617
+ if (this._index >= this._length) {
3618
+ data.done = true;
3619
+ } else {
3620
+ data.done = false;
3621
+ data.value = this._valueGetter(this._keys[this._index], this._index);
3622
+ }
3623
+
3624
+ return data;
3625
+ };
3626
+
3627
+ /**
3628
+ * The Map object implements the ES6 Map specification as closely as possible.<br>
3629
+ * For using objects and primitive values as keys, this object uses array internally.<br>
3630
+ * So if the key is not a string, get(), set(), has(), delete() will operates in O(n),<br>
3631
+ * and it can cause performance issues with a large dataset.
3632
+ *
3633
+ * Features listed below are not supported. (can't be implented without native support)
3634
+ * - Map object is iterable<br>
3635
+ * - Iterable object can be used as an argument of constructor
3636
+ *
3637
+ * If the browser supports full implementation of ES6 Map specification, native Map obejct
3638
+ * will be used internally.
3639
+ * @class
3640
+ * @param {Array} initData - Array of key-value pairs (2-element Arrays).
3641
+ * Each key-value pair will be added to the new Map
3642
+ * @memberof tui.util
3643
+ * @example
3644
+ * // node, commonjs
3645
+ * var Map = require('tui-code-snippet').Map;
3646
+ * @example
3647
+ * // distribution file, script
3648
+ * <script src='path-to/tui-code-snippt.js'></script>
3649
+ * <script>
3650
+ * var Map = tui.util.Map;
3651
+ * <script>
3652
+ */
3653
+ function Map(initData) {
3654
+ this._valuesForString = {};
3655
+ this._valuesForIndex = {};
3656
+ this._keys = [];
3657
+
3658
+ if (initData) {
3659
+ this._setInitData(initData);
3660
+ }
3661
+
3662
+ this.size = 0;
3663
+ }
3664
+
3665
+ /* eslint-disable no-extend-native */
3666
+ /**
3667
+ * Add all elements in the initData to the Map object.
3668
+ * @private
3669
+ * @param {Array} initData - Array of key-value pairs to add to the Map object
3670
+ */
3671
+ Map.prototype._setInitData = function(initData) {
3672
+ if (!type.isArray(initData)) {
3673
+ throw new Error('Only Array is supported.');
3674
+ }
3675
+ collection.forEachArray(initData, function(pair) {
3676
+ this.set(pair[0], pair[1]);
3677
+ }, this);
3678
+ };
3679
+
3680
+ /**
3681
+ * Returns true if the specified value is NaN.<br>
3682
+ * For unsing NaN as a key, use this method to test equality of NaN<br>
3683
+ * because === operator doesn't work for NaN.
3684
+ * @private
3685
+ * @param {*} value - Any object to be tested
3686
+ * @returns {boolean} True if value is NaN, false otherwise.
3687
+ */
3688
+ Map.prototype._isNaN = function(value) {
3689
+ return typeof value === 'number' && value !== value; // eslint-disable-line no-self-compare
3690
+ };
3691
+
3692
+ /**
3693
+ * Returns the index of the specified key.
3694
+ * @private
3695
+ * @param {*} key - The key object to search for.
3696
+ * @returns {number} The index of the specified key
3697
+ */
3698
+ Map.prototype._getKeyIndex = function(key) {
3699
+ var result = -1;
3700
+ var value;
3701
+
3702
+ if (type.isString(key)) {
3703
+ value = this._valuesForString[key];
3704
+ if (value) {
3705
+ result = value.keyIndex;
3706
+ }
3707
+ } else {
3708
+ result = array.inArray(key, this._keys);
3709
+ }
3710
+
3711
+ return result;
3712
+ };
3713
+
3714
+ /**
3715
+ * Returns the original key of the specified key.
3716
+ * @private
3717
+ * @param {*} key - key
3718
+ * @returns {*} Original key
3719
+ */
3720
+ Map.prototype._getOriginKey = function(key) {
3721
+ var originKey = key;
3722
+ if (key === _KEY_FOR_UNDEFINED) {
3723
+ originKey = undefined; // eslint-disable-line no-undefined
3724
+ } else if (key === _KEY_FOR_NAN) {
3725
+ originKey = NaN;
3726
+ }
3727
+
3728
+ return originKey;
3729
+ };
3730
+
3731
+ /**
3732
+ * Returns the unique key of the specified key.
3733
+ * @private
3734
+ * @param {*} key - key
3735
+ * @returns {*} Unique key
3736
+ */
3737
+ Map.prototype._getUniqueKey = function(key) {
3738
+ var uniqueKey = key;
3739
+ if (type.isUndefined(key)) {
3740
+ uniqueKey = _KEY_FOR_UNDEFINED;
3741
+ } else if (this._isNaN(key)) {
3742
+ uniqueKey = _KEY_FOR_NAN;
3743
+ }
3744
+
3745
+ return uniqueKey;
3746
+ };
3747
+
3748
+ /**
3749
+ * Returns the value object of the specified key.
3750
+ * @private
3751
+ * @param {*} key - The key of the value object to be returned
3752
+ * @param {number} keyIndex - The index of the key
3753
+ * @returns {{keyIndex: number, origin: *}} Value object
3754
+ */
3755
+ Map.prototype._getValueObject = function(key, keyIndex) { // eslint-disable-line consistent-return
3756
+ if (type.isString(key)) {
3757
+ return this._valuesForString[key];
3758
+ }
3759
+
3760
+ if (type.isUndefined(keyIndex)) {
3761
+ keyIndex = this._getKeyIndex(key);
3762
+ }
3763
+ if (keyIndex >= 0) {
3764
+ return this._valuesForIndex[keyIndex];
3765
+ }
3766
+ };
3767
+
3768
+ /**
3769
+ * Returns the original value of the specified key.
3770
+ * @private
3771
+ * @param {*} key - The key of the value object to be returned
3772
+ * @param {number} keyIndex - The index of the key
3773
+ * @returns {*} Original value
3774
+ */
3775
+ Map.prototype._getOriginValue = function(key, keyIndex) {
3776
+ return this._getValueObject(key, keyIndex).origin;
3777
+ };
3778
+
3779
+ /**
3780
+ * Returns key-value pair of the specified key.
3781
+ * @private
3782
+ * @param {*} key - The key of the value object to be returned
3783
+ * @param {number} keyIndex - The index of the key
3784
+ * @returns {Array} Key-value Pair
3785
+ */
3786
+ Map.prototype._getKeyValuePair = function(key, keyIndex) {
3787
+ return [this._getOriginKey(key), this._getOriginValue(key, keyIndex)];
3788
+ };
3789
+
3790
+ /**
3791
+ * Creates the wrapper object of original value that contains a key index
3792
+ * and returns it.
3793
+ * @private
3794
+ * @param {type} origin - Original value
3795
+ * @param {type} keyIndex - Index of the key
3796
+ * @returns {{keyIndex: number, origin: *}} Value object
3797
+ */
3798
+ Map.prototype._createValueObject = function(origin, keyIndex) {
3799
+ return {
3800
+ keyIndex: keyIndex,
3801
+ origin: origin
3802
+ };
3803
+ };
3804
+
3805
+ /**
3806
+ * Sets the value for the key in the Map object.
3807
+ * @param {*} key - The key of the element to add to the Map object
3808
+ * @param {*} value - The value of the element to add to the Map object
3809
+ * @returns {Map} The Map object
3810
+ */
3811
+ Map.prototype.set = function(key, value) {
3812
+ var uniqueKey = this._getUniqueKey(key);
3813
+ var keyIndex = this._getKeyIndex(uniqueKey);
3814
+ var valueObject;
3815
+
3816
+ if (keyIndex < 0) {
3817
+ keyIndex = this._keys.push(uniqueKey) - 1;
3818
+ this.size += 1;
3819
+ }
3820
+ valueObject = this._createValueObject(value, keyIndex);
3821
+
3822
+ if (type.isString(key)) {
3823
+ this._valuesForString[key] = valueObject;
3824
+ } else {
3825
+ this._valuesForIndex[keyIndex] = valueObject;
3826
+ }
3827
+
3828
+ return this;
3829
+ };
3830
+
3831
+ /**
3832
+ * Returns the value associated to the key, or undefined if there is none.
3833
+ * @param {*} key - The key of the element to return
3834
+ * @returns {*} Element associated with the specified key
3835
+ */
3836
+ Map.prototype.get = function(key) {
3837
+ var uniqueKey = this._getUniqueKey(key);
3838
+ var value = this._getValueObject(uniqueKey);
3839
+
3840
+ return value && value.origin;
3841
+ };
3842
+
3843
+ /**
3844
+ * Returns a new Iterator object that contains the keys for each element
3845
+ * in the Map object in insertion order.
3846
+ * @returns {Iterator} A new Iterator object
3847
+ */
3848
+ Map.prototype.keys = function() {
3849
+ return new MapIterator(this._keys, func.bind(this._getOriginKey, this));
3850
+ };
3851
+
3852
+ /**
3853
+ * Returns a new Iterator object that contains the values for each element
3854
+ * in the Map object in insertion order.
3855
+ * @returns {Iterator} A new Iterator object
3856
+ */
3857
+ Map.prototype.values = function() {
3858
+ return new MapIterator(this._keys, func.bind(this._getOriginValue, this));
3859
+ };
3860
+
3861
+ /**
3862
+ * Returns a new Iterator object that contains the [key, value] pairs
3863
+ * for each element in the Map object in insertion order.
3864
+ * @returns {Iterator} A new Iterator object
3865
+ */
3866
+ Map.prototype.entries = function() {
3867
+ return new MapIterator(this._keys, func.bind(this._getKeyValuePair, this));
3868
+ };
3869
+
3870
+ /**
3871
+ * Returns a boolean asserting whether a value has been associated to the key
3872
+ * in the Map object or not.
3873
+ * @param {*} key - The key of the element to test for presence
3874
+ * @returns {boolean} True if an element with the specified key exists;
3875
+ * Otherwise false
3876
+ */
3877
+ Map.prototype.has = function(key) {
3878
+ return !!this._getValueObject(key);
3879
+ };
3880
+
3881
+ /**
3882
+ * Removes the specified element from a Map object.
3883
+ * @param {*} key - The key of the element to remove
3884
+ * @function delete
3885
+ * @memberof tui.util.Map.prototype
3886
+ */
3887
+ // cannot use reserved keyword as a property name in IE8 and under.
3888
+ Map.prototype['delete'] = function(key) {
3889
+ var keyIndex;
3890
+
3891
+ if (type.isString(key)) {
3892
+ if (this._valuesForString[key]) {
3893
+ keyIndex = this._valuesForString[key].keyIndex;
3894
+ delete this._valuesForString[key];
3895
+ }
3896
+ } else {
3897
+ keyIndex = this._getKeyIndex(key);
3898
+ if (keyIndex >= 0) {
3899
+ delete this._valuesForIndex[keyIndex];
3900
+ }
3901
+ }
3902
+
3903
+ if (keyIndex >= 0) {
3904
+ delete this._keys[keyIndex];
3905
+ this.size -= 1;
3906
+ }
3907
+ };
3908
+
3909
+ /**
3910
+ * Executes a provided function once per each key/value pair in the Map object,
3911
+ * in insertion order.
3912
+ * @param {function} callback - Function to execute for each element
3913
+ * @param {thisArg} thisArg - Value to use as this when executing callback
3914
+ */
3915
+ Map.prototype.forEach = function(callback, thisArg) {
3916
+ thisArg = thisArg || this;
3917
+ collection.forEachArray(this._keys, function(key) {
3918
+ if (!type.isUndefined(key)) {
3919
+ callback.call(thisArg, this._getValueObject(key).origin, key, this);
3920
+ }
3921
+ }, this);
3922
+ };
3923
+
3924
+ /**
3925
+ * Removes all elements from a Map object.
3926
+ */
3927
+ Map.prototype.clear = function() {
3928
+ Map.call(this);
3929
+ };
3930
+ /* eslint-enable no-extend-native */
3931
+
3932
+ // Use native Map object if exists.
3933
+ // But only latest versions of Chrome and Firefox support full implementation.
3934
+ (function() {
3935
+ if (window.Map && (
3936
+ (browser.firefox && browser.version >= 37) ||
3937
+ (browser.chrome && browser.version >= 42)
3938
+ )
3939
+ ) {
3940
+ Map = window.Map; // eslint-disable-line no-func-assign
3941
+ }
3942
+ })();
3943
+
3944
+ module.exports = Map;
3945
+
3946
+
3947
+ /***/ }),
3948
+ /* 20 */
3949
+ /***/ (function(module, exports, __webpack_require__) {
3950
+
3951
+ /**
3952
+ * @fileoverview This module provides the HashMap constructor.
3953
+ * @author NHN.
3954
+ * FE Development Lab <dl_javascript@nhn.com>
3955
+ */
3956
+
3957
+ 'use strict';
3958
+
3959
+ var collection = __webpack_require__(4);
3960
+ var type = __webpack_require__(2);
3961
+ /**
3962
+ * All the data in hashMap begin with _MAPDATAPREFIX;
3963
+ * @type {string}
3964
+ * @private
3965
+ */
3966
+ var _MAPDATAPREFIX = 'å';
3967
+
3968
+ /**
3969
+ * HashMap can handle the key-value pairs.<br>
3970
+ * Caution:<br>
3971
+ * HashMap instance has a length property but is not an instance of Array.
3972
+ * @param {Object} [obj] A initial data for creation.
3973
+ * @constructor
3974
+ * @memberof tui.util
3975
+ * @deprecated since version 1.3.0
3976
+ * @example
3977
+ * // node, commonjs
3978
+ * var HashMap = require('tui-code-snippet').HashMap;
3979
+ * var hm = new tui.util.HashMap({
3980
+ 'mydata': {
3981
+ 'hello': 'imfine'
3982
+ },
3983
+ 'what': 'time'
3984
+ });
3985
+ * @example
3986
+ * // distribution file, script
3987
+ * <script src='path-to/tui-code-snippt.js'></script>
3988
+ * <script>
3989
+ * var HashMap = tui.util.HashMap;
3990
+ * <script>
3991
+ * var hm = new tui.util.HashMap({
3992
+ 'mydata': {
3993
+ 'hello': 'imfine'
3994
+ },
3995
+ 'what': 'time'
3996
+ });
3997
+ */
3998
+ function HashMap(obj) {
3999
+ /**
4000
+ * size
4001
+ * @type {number}
4002
+ */
4003
+ this.length = 0;
4004
+
4005
+ if (obj) {
4006
+ this.setObject(obj);
4007
+ }
4008
+ }
4009
+
4010
+ /**
4011
+ * Set a data from the given key with value or the given object.
4012
+ * @param {string|Object} key A string or object for key
4013
+ * @param {*} [value] A data
4014
+ * @example
4015
+ * //-- #1. Get Module --//
4016
+ * var HashMap = require('tui-code-snippet').HashMap; // node, commonjs
4017
+ * var HashMap = tui.util.HashMap; // distribution file
4018
+ *
4019
+ * //-- #2. Use property --//
4020
+ * var hm = new HashMap();
4021
+ * hm.set('key', 'value');
4022
+ * hm.set({
4023
+ * 'key1': 'data1',
4024
+ * 'key2': 'data2'
4025
+ * });
4026
+ */
4027
+ HashMap.prototype.set = function(key, value) {
4028
+ if (arguments.length === 2) {
4029
+ this.setKeyValue(key, value);
4030
+ } else {
4031
+ this.setObject(key);
4032
+ }
4033
+ };
4034
+
4035
+ /**
4036
+ * Set a data from the given key with value.
4037
+ * @param {string} key A string for key
4038
+ * @param {*} value A data
4039
+ * @example
4040
+ * //-- #1. Get Module --//
4041
+ * var HashMap = require('tui-code-snippet').HashMap; // node, commonjs
4042
+ * var HashMap = tui.util.HashMap; // distribution file
4043
+ *
4044
+ * //-- #2. Use property --//
4045
+ * var hm = new HashMap();
4046
+ * hm.setKeyValue('key', 'value');
4047
+ */
4048
+ HashMap.prototype.setKeyValue = function(key, value) {
4049
+ if (!this.has(key)) {
4050
+ this.length += 1;
4051
+ }
4052
+ this[this.encodeKey(key)] = value;
4053
+ };
4054
+
4055
+ /**
4056
+ * Set a data from the given object.
4057
+ * @param {Object} obj A object for data
4058
+ * @example
4059
+ * //-- #1. Get Module --//
4060
+ * var HashMap = require('tui-code-snippet').HashMap; // node, commonjs
4061
+ * var HashMap = tui.util.HashMap; // distribution file
4062
+ *
4063
+ * //-- #2. Use property --//
4064
+ * var hm = new HashMap();
4065
+ * hm.setObject({
4066
+ * 'key1': 'data1',
4067
+ * 'key2': 'data2'
4068
+ * });
4069
+ */
4070
+ HashMap.prototype.setObject = function(obj) {
4071
+ var self = this;
4072
+
4073
+ collection.forEachOwnProperties(obj, function(value, key) {
4074
+ self.setKeyValue(key, value);
4075
+ });
4076
+ };
4077
+
4078
+ /**
4079
+ * Merge with the given another hashMap.
4080
+ * @param {HashMap} hashMap Another hashMap instance
4081
+ */
4082
+ HashMap.prototype.merge = function(hashMap) {
4083
+ var self = this;
4084
+
4085
+ hashMap.each(function(value, key) {
4086
+ self.setKeyValue(key, value);
4087
+ });
4088
+ };
4089
+
4090
+ /**
4091
+ * Encode the given key for hashMap.
4092
+ * @param {string} key A string for key
4093
+ * @returns {string} A encoded key
4094
+ * @private
4095
+ */
4096
+ HashMap.prototype.encodeKey = function(key) {
4097
+ return _MAPDATAPREFIX + key;
4098
+ };
4099
+
4100
+ /**
4101
+ * Decode the given key in hashMap.
4102
+ * @param {string} key A string for key
4103
+ * @returns {string} A decoded key
4104
+ * @private
4105
+ */
4106
+ HashMap.prototype.decodeKey = function(key) {
4107
+ var decodedKey = key.split(_MAPDATAPREFIX);
4108
+
4109
+ return decodedKey[decodedKey.length - 1];
4110
+ };
4111
+
4112
+ /**
4113
+ * Return the value from the given key.
4114
+ * @param {string} key A string for key
4115
+ * @returns {*} The value from a key
4116
+ * @example
4117
+ * //-- #1. Get Module --//
4118
+ * var HashMap = require('tui-code-snippet').HashMap; // node, commonjs
4119
+ * var HashMap = tui.util.HashMap; // distribution file
4120
+ *
4121
+ * //-- #2. Use property --//
4122
+ * var hm = new HashMap();
4123
+ * hm.set('key', 'value');
4124
+ * hm.get('key') // value
4125
+ */
4126
+ HashMap.prototype.get = function(key) {
4127
+ return this[this.encodeKey(key)];
4128
+ };
4129
+
4130
+ /**
4131
+ * Check the existence of a value from the key.
4132
+ * @param {string} key A string for key
4133
+ * @returns {boolean} Indicating whether a value exists or not.
4134
+ * @example
4135
+ * //-- #1. Get Module --//
4136
+ * var HashMap = require('tui-code-snippet').HashMap; // node, commonjs
4137
+ * var HashMap = tui.util.HashMap; // distribution file
4138
+ *
4139
+ * //-- #2. Use property --//
4140
+ * var hm = new HashMap();
4141
+ * hm.set('key', 'value');
4142
+ * hm.has('key') // true
4143
+ */
4144
+ HashMap.prototype.has = function(key) {
4145
+ return this.hasOwnProperty(this.encodeKey(key));
4146
+ };
4147
+
4148
+ /**
4149
+ * Remove a data(key-value pairs) from the given key or the given key-list.
4150
+ * @param {...string|string[]} key A string for key
4151
+ * @returns {string|string[]} A removed data
4152
+ * @example
4153
+ * //-- #1. Get Module --//
4154
+ * var HashMap = require('tui-code-snippet').HashMap; // node, commonjs
4155
+ * var HashMap = tui.util.HashMap; // distribution file
4156
+ *
4157
+ * //-- #2. Use property --//
4158
+ * var hm = new HashMap();
4159
+ * hm.set('key', 'value');
4160
+ * hm.set('key2', 'value');
4161
+ *
4162
+ * hm.remove('key');
4163
+ * hm.remove('key', 'key2');
4164
+ * hm.remove(['key', 'key2']);
4165
+ */
4166
+ HashMap.prototype.remove = function(key) {
4167
+ if (arguments.length > 1) {
4168
+ key = collection.toArray(arguments);
4169
+ }
4170
+
4171
+ return type.isArray(key) ? this.removeByKeyArray(key) : this.removeByKey(key);
4172
+ };
4173
+
4174
+ /**
4175
+ * Remove data(key-value pair) from the given key.
4176
+ * @param {string} key A string for key
4177
+ * @returns {*|null} A removed data
4178
+ * @example
4179
+ * //-- #1. Get Module --//
4180
+ * var HashMap = require('tui-code-snippet').HashMap; // node, commonjs
4181
+ * var HashMap = tui.util.HashMap; // distribution file
4182
+ *
4183
+ * //-- #2. Use property --//
4184
+ * var hm = new HashMap();
4185
+ * hm.set('key', 'value');
4186
+ * hm.removeByKey('key')
4187
+ */
4188
+ HashMap.prototype.removeByKey = function(key) {
4189
+ var data = this.has(key) ? this.get(key) : null;
4190
+
4191
+ if (data !== null) {
4192
+ delete this[this.encodeKey(key)];
4193
+ this.length -= 1;
4194
+ }
4195
+
4196
+ return data;
4197
+ };
4198
+
4199
+ /**
4200
+ * Remove a data(key-value pairs) from the given key-list.
4201
+ * @param {string[]} keyArray An array of keys
4202
+ * @returns {string[]} A removed data
4203
+ * @example
4204
+ * //-- #1. Get Module --//
4205
+ * var HashMap = require('tui-code-snippet').HashMap; // node, commonjs
4206
+ * var HashMap = tui.util.HashMap; // distribution file
4207
+ *
4208
+ * //-- #2. Use property --//
4209
+ * var hm = new HashMap();
4210
+ * hm.set('key', 'value');
4211
+ * hm.set('key2', 'value');
4212
+ * hm.removeByKeyArray(['key', 'key2']);
4213
+ */
4214
+ HashMap.prototype.removeByKeyArray = function(keyArray) {
4215
+ var data = [];
4216
+ var self = this;
4217
+
4218
+ collection.forEach(keyArray, function(key) {
4219
+ data.push(self.removeByKey(key));
4220
+ });
4221
+
4222
+ return data;
4223
+ };
4224
+
4225
+ /**
4226
+ * Remove all the data
4227
+ */
4228
+ HashMap.prototype.removeAll = function() {
4229
+ var self = this;
4230
+
4231
+ this.each(function(value, key) {
4232
+ self.remove(key);
4233
+ });
4234
+ };
4235
+
4236
+ /**
4237
+ * Execute the provided callback once for each all the data.
4238
+ * @param {Function} iteratee Callback function
4239
+ * @example
4240
+ * //-- #1. Get Module --//
4241
+ * var HashMap = require('tui-code-snippet').HashMap; // node, commonjs
4242
+ * var HashMap = tui.util.HashMap; // distribution file
4243
+ *
4244
+ * //-- #2. Use property --//
4245
+ * var hm = new HashMap();
4246
+ * hm.set('key', 'value');
4247
+ * hm.set('key2', 'value');
4248
+ *
4249
+ * hm.each(function(value, key) {
4250
+ * //do something...
4251
+ * });
4252
+ */
4253
+ HashMap.prototype.each = function(iteratee) {
4254
+ var self = this;
4255
+ var flag;
4256
+
4257
+ collection.forEachOwnProperties(this, function(value, key) { // eslint-disable-line consistent-return
4258
+ if (key.charAt(0) === _MAPDATAPREFIX) {
4259
+ flag = iteratee(value, self.decodeKey(key));
4260
+ }
4261
+
4262
+ if (flag === false) {
4263
+ return flag;
4264
+ }
4265
+ });
4266
+ };
4267
+
4268
+ /**
4269
+ * Return the key-list stored.
4270
+ * @returns {Array} A key-list
4271
+ * @example
4272
+ * //-- #1. Get Module --//
4273
+ * var HashMap = require('tui-code-snippet').HashMap; // node, commonjs
4274
+ * var HashMap = tui.util.HashMap; // distribution file
4275
+ *
4276
+ * //-- #2. Use property --//
4277
+ * var hm = new HashMap();
4278
+ * hm.set('key', 'value');
4279
+ * hm.set('key2', 'value');
4280
+ * hm.keys(); //['key', 'key2');
4281
+ */
4282
+ HashMap.prototype.keys = function() {
4283
+ var keys = [];
4284
+ var self = this;
4285
+
4286
+ this.each(function(value, key) {
4287
+ keys.push(self.decodeKey(key));
4288
+ });
4289
+
4290
+ return keys;
4291
+ };
4292
+
4293
+ /**
4294
+ * Work similarly to Array.prototype.map().<br>
4295
+ * It executes the provided callback that checks conditions once for each element of hashMap,<br>
4296
+ * and returns a new array having elements satisfying the conditions
4297
+ * @param {Function} condition A function that checks conditions
4298
+ * @returns {Array} A new array having elements satisfying the conditions
4299
+ * @example
4300
+ * //-- #1. Get Module --//
4301
+ * var HashMap = require('tui-code-snippet').HashMap; // node, commonjs
4302
+ * var HashMap = tui.util.HashMap; // distribution file
4303
+ *
4304
+ * //-- #2. Use property --//
4305
+ * var hm1 = new HashMap();
4306
+ * hm1.set('key', 'value');
4307
+ * hm1.set('key2', 'value');
4308
+ *
4309
+ * hm1.find(function(value, key) {
4310
+ * return key === 'key2';
4311
+ * }); // ['value']
4312
+ *
4313
+ * var hm2 = new HashMap({
4314
+ * 'myobj1': {
4315
+ * visible: true
4316
+ * },
4317
+ * 'mybobj2': {
4318
+ * visible: false
4319
+ * }
4320
+ * });
4321
+ *
4322
+ * hm2.find(function(obj, key) {
4323
+ * return obj.visible === true;
4324
+ * }); // [{visible: true}];
4325
+ */
4326
+ HashMap.prototype.find = function(condition) {
4327
+ var founds = [];
4328
+
4329
+ this.each(function(value, key) {
4330
+ if (condition(value, key)) {
4331
+ founds.push(value);
4332
+ }
4333
+ });
4334
+
4335
+ return founds;
4336
+ };
4337
+
4338
+ /**
4339
+ * Return a new Array having all values.
4340
+ * @returns {Array} A new array having all values
4341
+ */
4342
+ HashMap.prototype.toArray = function() {
4343
+ var result = [];
4344
+
4345
+ this.each(function(v) {
4346
+ result.push(v);
4347
+ });
4348
+
4349
+ return result;
4350
+ };
4351
+
4352
+ module.exports = HashMap;
4353
+
4354
+
4355
+ /***/ })
4356
+ /******/ ])
4357
+ });
4358
+ ;