jekyll-theme-paperwiki 0.1.0 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/assets/js/list.js DELETED
@@ -1,2020 +0,0 @@
1
- var List;List =
2
- /******/ (function() { // webpackBootstrap
3
- /******/ var __webpack_modules__ = ({
4
-
5
- /***/ "./src/add-async.js":
6
- /*!**************************!*\
7
- !*** ./src/add-async.js ***!
8
- \**************************/
9
- /*! unknown exports (runtime-defined) */
10
- /*! runtime requirements: module */
11
- /*! CommonJS bailout: module.exports is used directly at 1:0-14 */
12
- /***/ (function(module) {
13
-
14
- module.exports = function (list) {
15
- var addAsync = function addAsync(values, callback, items) {
16
- var valuesToAdd = values.splice(0, 50);
17
- items = items || [];
18
- items = items.concat(list.add(valuesToAdd));
19
-
20
- if (values.length > 0) {
21
- setTimeout(function () {
22
- addAsync(values, callback, items);
23
- }, 1);
24
- } else {
25
- list.update();
26
- callback(items);
27
- }
28
- };
29
-
30
- return addAsync;
31
- };
32
-
33
- /***/ }),
34
-
35
- /***/ "./src/filter.js":
36
- /*!***********************!*\
37
- !*** ./src/filter.js ***!
38
- \***********************/
39
- /*! unknown exports (runtime-defined) */
40
- /*! runtime requirements: module */
41
- /*! CommonJS bailout: module.exports is used directly at 1:0-14 */
42
- /***/ (function(module) {
43
-
44
- module.exports = function (list) {
45
- // Add handlers
46
- list.handlers.filterStart = list.handlers.filterStart || [];
47
- list.handlers.filterComplete = list.handlers.filterComplete || [];
48
- return function (filterFunction) {
49
- list.trigger('filterStart');
50
- list.i = 1; // Reset paging
51
-
52
- list.reset.filter();
53
-
54
- if (filterFunction === undefined) {
55
- list.filtered = false;
56
- } else {
57
- list.filtered = true;
58
- var is = list.items;
59
-
60
- for (var i = 0, il = is.length; i < il; i++) {
61
- var item = is[i];
62
-
63
- if (filterFunction(item)) {
64
- item.filtered = true;
65
- } else {
66
- item.filtered = false;
67
- }
68
- }
69
- }
70
-
71
- list.update();
72
- list.trigger('filterComplete');
73
- return list.visibleItems;
74
- };
75
- };
76
-
77
- /***/ }),
78
-
79
- /***/ "./src/fuzzy-search.js":
80
- /*!*****************************!*\
81
- !*** ./src/fuzzy-search.js ***!
82
- \*****************************/
83
- /*! unknown exports (runtime-defined) */
84
- /*! runtime requirements: module, __webpack_require__ */
85
- /*! CommonJS bailout: module.exports is used directly at 8:0-14 */
86
- /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
87
-
88
- var classes = __webpack_require__(/*! ./utils/classes */ "./src/utils/classes.js"),
89
- events = __webpack_require__(/*! ./utils/events */ "./src/utils/events.js"),
90
- extend = __webpack_require__(/*! ./utils/extend */ "./src/utils/extend.js"),
91
- toString = __webpack_require__(/*! ./utils/to-string */ "./src/utils/to-string.js"),
92
- getByClass = __webpack_require__(/*! ./utils/get-by-class */ "./src/utils/get-by-class.js"),
93
- fuzzy = __webpack_require__(/*! ./utils/fuzzy */ "./src/utils/fuzzy.js");
94
-
95
- module.exports = function (list, options) {
96
- options = options || {};
97
- options = extend({
98
- location: 0,
99
- distance: 100,
100
- threshold: 0.4,
101
- multiSearch: true,
102
- searchClass: 'fuzzy-search'
103
- }, options);
104
- var fuzzySearch = {
105
- search: function search(searchString, columns) {
106
- // Substract arguments from the searchString or put searchString as only argument
107
- var searchArguments = options.multiSearch ? searchString.replace(/ +$/, '').split(/ +/) : [searchString];
108
-
109
- for (var k = 0, kl = list.items.length; k < kl; k++) {
110
- fuzzySearch.item(list.items[k], columns, searchArguments);
111
- }
112
- },
113
- item: function item(_item, columns, searchArguments) {
114
- var found = true;
115
-
116
- for (var i = 0; i < searchArguments.length; i++) {
117
- var foundArgument = false;
118
-
119
- for (var j = 0, jl = columns.length; j < jl; j++) {
120
- if (fuzzySearch.values(_item.values(), columns[j], searchArguments[i])) {
121
- foundArgument = true;
122
- }
123
- }
124
-
125
- if (!foundArgument) {
126
- found = false;
127
- }
128
- }
129
-
130
- _item.found = found;
131
- },
132
- values: function values(_values, value, searchArgument) {
133
- if (_values.hasOwnProperty(value)) {
134
- var text = toString(_values[value]).toLowerCase();
135
-
136
- if (fuzzy(text, searchArgument, options)) {
137
- return true;
138
- }
139
- }
140
-
141
- return false;
142
- }
143
- };
144
- events.bind(getByClass(list.listContainer, options.searchClass), 'keyup', list.utils.events.debounce(function (e) {
145
- var target = e.target || e.srcElement; // IE have srcElement
146
-
147
- list.search(target.value, fuzzySearch.search);
148
- }, list.searchDelay));
149
- return function (str, columns) {
150
- list.search(str, columns, fuzzySearch.search);
151
- };
152
- };
153
-
154
- /***/ }),
155
-
156
- /***/ "./src/index.js":
157
- /*!**********************!*\
158
- !*** ./src/index.js ***!
159
- \**********************/
160
- /*! unknown exports (runtime-defined) */
161
- /*! runtime requirements: module, __webpack_require__ */
162
- /*! CommonJS bailout: module.exports is used directly at 11:0-14 */
163
- /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
164
-
165
- var naturalSort = __webpack_require__(/*! string-natural-compare */ "./node_modules/string-natural-compare/natural-compare.js"),
166
- getByClass = __webpack_require__(/*! ./utils/get-by-class */ "./src/utils/get-by-class.js"),
167
- extend = __webpack_require__(/*! ./utils/extend */ "./src/utils/extend.js"),
168
- indexOf = __webpack_require__(/*! ./utils/index-of */ "./src/utils/index-of.js"),
169
- events = __webpack_require__(/*! ./utils/events */ "./src/utils/events.js"),
170
- toString = __webpack_require__(/*! ./utils/to-string */ "./src/utils/to-string.js"),
171
- classes = __webpack_require__(/*! ./utils/classes */ "./src/utils/classes.js"),
172
- getAttribute = __webpack_require__(/*! ./utils/get-attribute */ "./src/utils/get-attribute.js"),
173
- toArray = __webpack_require__(/*! ./utils/to-array */ "./src/utils/to-array.js");
174
-
175
- module.exports = function (id, options, values) {
176
- var self = this,
177
- init,
178
- Item = __webpack_require__(/*! ./item */ "./src/item.js")(self),
179
- addAsync = __webpack_require__(/*! ./add-async */ "./src/add-async.js")(self),
180
- initPagination = __webpack_require__(/*! ./pagination */ "./src/pagination.js")(self);
181
-
182
- init = {
183
- start: function start() {
184
- self.listClass = 'list';
185
- self.searchClass = 'search';
186
- self.sortClass = 'sort';
187
- self.page = 10000;
188
- self.i = 1;
189
- self.items = [];
190
- self.visibleItems = [];
191
- self.matchingItems = [];
192
- self.searched = false;
193
- self.filtered = false;
194
- self.searchColumns = undefined;
195
- self.searchDelay = 0;
196
- self.handlers = {
197
- updated: []
198
- };
199
- self.valueNames = [];
200
- self.utils = {
201
- getByClass: getByClass,
202
- extend: extend,
203
- indexOf: indexOf,
204
- events: events,
205
- toString: toString,
206
- naturalSort: naturalSort,
207
- classes: classes,
208
- getAttribute: getAttribute,
209
- toArray: toArray
210
- };
211
- self.utils.extend(self, options);
212
- self.listContainer = typeof id === 'string' ? document.getElementById(id) : id;
213
-
214
- if (!self.listContainer) {
215
- return;
216
- }
217
-
218
- self.list = getByClass(self.listContainer, self.listClass, true);
219
- self.parse = __webpack_require__(/*! ./parse */ "./src/parse.js")(self);
220
- self.templater = __webpack_require__(/*! ./templater */ "./src/templater.js")(self);
221
- self.search = __webpack_require__(/*! ./search */ "./src/search.js")(self);
222
- self.filter = __webpack_require__(/*! ./filter */ "./src/filter.js")(self);
223
- self.sort = __webpack_require__(/*! ./sort */ "./src/sort.js")(self);
224
- self.fuzzySearch = __webpack_require__(/*! ./fuzzy-search */ "./src/fuzzy-search.js")(self, options.fuzzySearch);
225
- this.handlers();
226
- this.items();
227
- this.pagination();
228
- self.update();
229
- },
230
- handlers: function handlers() {
231
- for (var handler in self.handlers) {
232
- if (self[handler] && self.handlers.hasOwnProperty(handler)) {
233
- self.on(handler, self[handler]);
234
- }
235
- }
236
- },
237
- items: function items() {
238
- self.parse(self.list);
239
-
240
- if (values !== undefined) {
241
- self.add(values);
242
- }
243
- },
244
- pagination: function pagination() {
245
- if (options.pagination !== undefined) {
246
- if (options.pagination === true) {
247
- options.pagination = [{}];
248
- }
249
-
250
- if (options.pagination[0] === undefined) {
251
- options.pagination = [options.pagination];
252
- }
253
-
254
- for (var i = 0, il = options.pagination.length; i < il; i++) {
255
- initPagination(options.pagination[i]);
256
- }
257
- }
258
- }
259
- };
260
- /*
261
- * Re-parse the List, use if html have changed
262
- */
263
-
264
- this.reIndex = function () {
265
- self.items = [];
266
- self.visibleItems = [];
267
- self.matchingItems = [];
268
- self.searched = false;
269
- self.filtered = false;
270
- self.parse(self.list);
271
- };
272
-
273
- this.toJSON = function () {
274
- var json = [];
275
-
276
- for (var i = 0, il = self.items.length; i < il; i++) {
277
- json.push(self.items[i].values());
278
- }
279
-
280
- return json;
281
- };
282
- /*
283
- * Add object to list
284
- */
285
-
286
-
287
- this.add = function (values, callback) {
288
- if (values.length === 0) {
289
- return;
290
- }
291
-
292
- if (callback) {
293
- addAsync(values.slice(0), callback);
294
- return;
295
- }
296
-
297
- var added = [],
298
- notCreate = false;
299
-
300
- if (values[0] === undefined) {
301
- values = [values];
302
- }
303
-
304
- for (var i = 0, il = values.length; i < il; i++) {
305
- var item = null;
306
- notCreate = self.items.length > self.page ? true : false;
307
- item = new Item(values[i], undefined, notCreate);
308
- self.items.push(item);
309
- added.push(item);
310
- }
311
-
312
- self.update();
313
- return added;
314
- };
315
-
316
- this.show = function (i, page) {
317
- this.i = i;
318
- this.page = page;
319
- self.update();
320
- return self;
321
- };
322
- /* Removes object from list.
323
- * Loops through the list and removes objects where
324
- * property "valuename" === value
325
- */
326
-
327
-
328
- this.remove = function (valueName, value, options) {
329
- var found = 0;
330
-
331
- for (var i = 0, il = self.items.length; i < il; i++) {
332
- if (self.items[i].values()[valueName] == value) {
333
- self.templater.remove(self.items[i], options);
334
- self.items.splice(i, 1);
335
- il--;
336
- i--;
337
- found++;
338
- }
339
- }
340
-
341
- self.update();
342
- return found;
343
- };
344
- /* Gets the objects in the list which
345
- * property "valueName" === value
346
- */
347
-
348
-
349
- this.get = function (valueName, value) {
350
- var matchedItems = [];
351
-
352
- for (var i = 0, il = self.items.length; i < il; i++) {
353
- var item = self.items[i];
354
-
355
- if (item.values()[valueName] == value) {
356
- matchedItems.push(item);
357
- }
358
- }
359
-
360
- return matchedItems;
361
- };
362
- /*
363
- * Get size of the list
364
- */
365
-
366
-
367
- this.size = function () {
368
- return self.items.length;
369
- };
370
- /*
371
- * Removes all items from the list
372
- */
373
-
374
-
375
- this.clear = function () {
376
- self.templater.clear();
377
- self.items = [];
378
- return self;
379
- };
380
-
381
- this.on = function (event, callback) {
382
- self.handlers[event].push(callback);
383
- return self;
384
- };
385
-
386
- this.off = function (event, callback) {
387
- var e = self.handlers[event];
388
- var index = indexOf(e, callback);
389
-
390
- if (index > -1) {
391
- e.splice(index, 1);
392
- }
393
-
394
- return self;
395
- };
396
-
397
- this.trigger = function (event) {
398
- var i = self.handlers[event].length;
399
-
400
- while (i--) {
401
- self.handlers[event][i](self);
402
- }
403
-
404
- return self;
405
- };
406
-
407
- this.reset = {
408
- filter: function filter() {
409
- var is = self.items,
410
- il = is.length;
411
-
412
- while (il--) {
413
- is[il].filtered = false;
414
- }
415
-
416
- return self;
417
- },
418
- search: function search() {
419
- var is = self.items,
420
- il = is.length;
421
-
422
- while (il--) {
423
- is[il].found = false;
424
- }
425
-
426
- return self;
427
- }
428
- };
429
-
430
- this.update = function () {
431
- var is = self.items,
432
- il = is.length;
433
- self.visibleItems = [];
434
- self.matchingItems = [];
435
- self.templater.clear();
436
-
437
- for (var i = 0; i < il; i++) {
438
- if (is[i].matching() && self.matchingItems.length + 1 >= self.i && self.visibleItems.length < self.page) {
439
- is[i].show();
440
- self.visibleItems.push(is[i]);
441
- self.matchingItems.push(is[i]);
442
- } else if (is[i].matching()) {
443
- self.matchingItems.push(is[i]);
444
- is[i].hide();
445
- } else {
446
- is[i].hide();
447
- }
448
- }
449
-
450
- self.trigger('updated');
451
- return self;
452
- };
453
-
454
- init.start();
455
- };
456
-
457
- /***/ }),
458
-
459
- /***/ "./src/item.js":
460
- /*!*********************!*\
461
- !*** ./src/item.js ***!
462
- \*********************/
463
- /*! unknown exports (runtime-defined) */
464
- /*! runtime requirements: module */
465
- /*! CommonJS bailout: module.exports is used directly at 1:0-14 */
466
- /***/ (function(module) {
467
-
468
- module.exports = function (list) {
469
- return function (initValues, element, notCreate) {
470
- var item = this;
471
- this._values = {};
472
- this.found = false; // Show if list.searched == true and this.found == true
473
-
474
- this.filtered = false; // Show if list.filtered == true and this.filtered == true
475
-
476
- var init = function init(initValues, element, notCreate) {
477
- if (element === undefined) {
478
- if (notCreate) {
479
- item.values(initValues, notCreate);
480
- } else {
481
- item.values(initValues);
482
- }
483
- } else {
484
- item.elm = element;
485
- var values = list.templater.get(item, initValues);
486
- item.values(values);
487
- }
488
- };
489
-
490
- this.values = function (newValues, notCreate) {
491
- if (newValues !== undefined) {
492
- for (var name in newValues) {
493
- item._values[name] = newValues[name];
494
- }
495
-
496
- if (notCreate !== true) {
497
- list.templater.set(item, item.values());
498
- }
499
- } else {
500
- return item._values;
501
- }
502
- };
503
-
504
- this.show = function () {
505
- list.templater.show(item);
506
- };
507
-
508
- this.hide = function () {
509
- list.templater.hide(item);
510
- };
511
-
512
- this.matching = function () {
513
- return list.filtered && list.searched && item.found && item.filtered || list.filtered && !list.searched && item.filtered || !list.filtered && list.searched && item.found || !list.filtered && !list.searched;
514
- };
515
-
516
- this.visible = function () {
517
- return item.elm && item.elm.parentNode == list.list ? true : false;
518
- };
519
-
520
- init(initValues, element, notCreate);
521
- };
522
- };
523
-
524
- /***/ }),
525
-
526
- /***/ "./src/pagination.js":
527
- /*!***************************!*\
528
- !*** ./src/pagination.js ***!
529
- \***************************/
530
- /*! unknown exports (runtime-defined) */
531
- /*! runtime requirements: module, __webpack_require__ */
532
- /*! CommonJS bailout: module.exports is used directly at 5:0-14 */
533
- /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
534
-
535
- var classes = __webpack_require__(/*! ./utils/classes */ "./src/utils/classes.js"),
536
- events = __webpack_require__(/*! ./utils/events */ "./src/utils/events.js"),
537
- List = __webpack_require__(/*! ./index */ "./src/index.js");
538
-
539
- module.exports = function (list) {
540
- var isHidden = false;
541
-
542
- var refresh = function refresh(pagingList, options) {
543
- if (list.page < 1) {
544
- list.listContainer.style.display = 'none';
545
- isHidden = true;
546
- return;
547
- } else if (isHidden) {
548
- list.listContainer.style.display = 'block';
549
- }
550
-
551
- var item,
552
- l = list.matchingItems.length,
553
- index = list.i,
554
- page = list.page,
555
- pages = Math.ceil(l / page),
556
- currentPage = Math.ceil(index / page),
557
- innerWindow = options.innerWindow || 2,
558
- left = options.left || options.outerWindow || 0,
559
- right = options.right || options.outerWindow || 0;
560
- right = pages - right;
561
- pagingList.clear();
562
-
563
- for (var i = 1; i <= pages; i++) {
564
- var className = currentPage === i ? 'active' : ''; //console.log(i, left, right, currentPage, (currentPage - innerWindow), (currentPage + innerWindow), className);
565
-
566
- if (is.number(i, left, right, currentPage, innerWindow)) {
567
- item = pagingList.add({
568
- page: i,
569
- dotted: false
570
- })[0];
571
-
572
- if (className) {
573
- classes(item.elm).add(className);
574
- }
575
-
576
- item.elm.firstChild.setAttribute('data-i', i);
577
- item.elm.firstChild.setAttribute('data-page', page);
578
- } else if (is.dotted(pagingList, i, left, right, currentPage, innerWindow, pagingList.size())) {
579
- item = pagingList.add({
580
- page: '...',
581
- dotted: true
582
- })[0];
583
- classes(item.elm).add('disabled');
584
- }
585
- }
586
- };
587
-
588
- var is = {
589
- number: function number(i, left, right, currentPage, innerWindow) {
590
- return this.left(i, left) || this.right(i, right) || this.innerWindow(i, currentPage, innerWindow);
591
- },
592
- left: function left(i, _left) {
593
- return i <= _left;
594
- },
595
- right: function right(i, _right) {
596
- return i > _right;
597
- },
598
- innerWindow: function innerWindow(i, currentPage, _innerWindow) {
599
- return i >= currentPage - _innerWindow && i <= currentPage + _innerWindow;
600
- },
601
- dotted: function dotted(pagingList, i, left, right, currentPage, innerWindow, currentPageItem) {
602
- return this.dottedLeft(pagingList, i, left, right, currentPage, innerWindow) || this.dottedRight(pagingList, i, left, right, currentPage, innerWindow, currentPageItem);
603
- },
604
- dottedLeft: function dottedLeft(pagingList, i, left, right, currentPage, innerWindow) {
605
- return i == left + 1 && !this.innerWindow(i, currentPage, innerWindow) && !this.right(i, right);
606
- },
607
- dottedRight: function dottedRight(pagingList, i, left, right, currentPage, innerWindow, currentPageItem) {
608
- if (pagingList.items[currentPageItem - 1].values().dotted) {
609
- return false;
610
- } else {
611
- return i == right && !this.innerWindow(i, currentPage, innerWindow) && !this.right(i, right);
612
- }
613
- }
614
- };
615
- return function (options) {
616
- var pagingList = new List(list.listContainer.id, {
617
- listClass: options.paginationClass || 'pagination',
618
- item: options.item || "<li><a class='page' href='#'></a></li>",
619
- valueNames: ['page', 'dotted'],
620
- searchClass: 'pagination-search-that-is-not-supposed-to-exist',
621
- sortClass: 'pagination-sort-that-is-not-supposed-to-exist'
622
- });
623
- events.bind(pagingList.listContainer, 'click', function (e) {
624
- var target = e.target || e.srcElement,
625
- page = list.utils.getAttribute(target, 'data-page'),
626
- i = list.utils.getAttribute(target, 'data-i');
627
-
628
- if (i) {
629
- list.show((i - 1) * page + 1, page);
630
- }
631
- });
632
- list.on('updated', function () {
633
- refresh(pagingList, options);
634
- });
635
- refresh(pagingList, options);
636
- };
637
- };
638
-
639
- /***/ }),
640
-
641
- /***/ "./src/parse.js":
642
- /*!**********************!*\
643
- !*** ./src/parse.js ***!
644
- \**********************/
645
- /*! unknown exports (runtime-defined) */
646
- /*! runtime requirements: module, __webpack_require__ */
647
- /*! CommonJS bailout: module.exports is used directly at 1:0-14 */
648
- /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
649
-
650
- module.exports = function (list) {
651
- var Item = __webpack_require__(/*! ./item */ "./src/item.js")(list);
652
-
653
- var getChildren = function getChildren(parent) {
654
- var nodes = parent.childNodes,
655
- items = [];
656
-
657
- for (var i = 0, il = nodes.length; i < il; i++) {
658
- // Only textnodes have a data attribute
659
- if (nodes[i].data === undefined) {
660
- items.push(nodes[i]);
661
- }
662
- }
663
-
664
- return items;
665
- };
666
-
667
- var parse = function parse(itemElements, valueNames) {
668
- for (var i = 0, il = itemElements.length; i < il; i++) {
669
- list.items.push(new Item(valueNames, itemElements[i]));
670
- }
671
- };
672
-
673
- var parseAsync = function parseAsync(itemElements, valueNames) {
674
- var itemsToIndex = itemElements.splice(0, 50); // TODO: If < 100 items, what happens in IE etc?
675
-
676
- parse(itemsToIndex, valueNames);
677
-
678
- if (itemElements.length > 0) {
679
- setTimeout(function () {
680
- parseAsync(itemElements, valueNames);
681
- }, 1);
682
- } else {
683
- list.update();
684
- list.trigger('parseComplete');
685
- }
686
- };
687
-
688
- list.handlers.parseComplete = list.handlers.parseComplete || [];
689
- return function () {
690
- var itemsToIndex = getChildren(list.list),
691
- valueNames = list.valueNames;
692
-
693
- if (list.indexAsync) {
694
- parseAsync(itemsToIndex, valueNames);
695
- } else {
696
- parse(itemsToIndex, valueNames);
697
- }
698
- };
699
- };
700
-
701
- /***/ }),
702
-
703
- /***/ "./src/search.js":
704
- /*!***********************!*\
705
- !*** ./src/search.js ***!
706
- \***********************/
707
- /*! unknown exports (runtime-defined) */
708
- /*! runtime requirements: module */
709
- /*! CommonJS bailout: module.exports is used directly at 1:0-14 */
710
- /***/ (function(module) {
711
-
712
- module.exports = function (_list) {
713
- var item, text, columns, searchString, customSearch;
714
- var prepare = {
715
- resetList: function resetList() {
716
- _list.i = 1;
717
-
718
- _list.templater.clear();
719
-
720
- customSearch = undefined;
721
- },
722
- setOptions: function setOptions(args) {
723
- if (args.length == 2 && args[1] instanceof Array) {
724
- columns = args[1];
725
- } else if (args.length == 2 && typeof args[1] == 'function') {
726
- columns = undefined;
727
- customSearch = args[1];
728
- } else if (args.length == 3) {
729
- columns = args[1];
730
- customSearch = args[2];
731
- } else {
732
- columns = undefined;
733
- }
734
- },
735
- setColumns: function setColumns() {
736
- if (_list.items.length === 0) return;
737
-
738
- if (columns === undefined) {
739
- columns = _list.searchColumns === undefined ? prepare.toArray(_list.items[0].values()) : _list.searchColumns;
740
- }
741
- },
742
- setSearchString: function setSearchString(s) {
743
- s = _list.utils.toString(s).toLowerCase();
744
- s = s.replace(/[-[\]{}()*+?.,\\^$|#]/g, '\\$&'); // Escape regular expression characters
745
-
746
- searchString = s;
747
- },
748
- toArray: function toArray(values) {
749
- var tmpColumn = [];
750
-
751
- for (var name in values) {
752
- tmpColumn.push(name);
753
- }
754
-
755
- return tmpColumn;
756
- }
757
- };
758
- var search = {
759
- list: function list() {
760
- // Extract quoted phrases "word1 word2" from original searchString
761
- // searchString is converted to lowercase by List.js
762
- var words = [],
763
- phrase,
764
- ss = searchString;
765
-
766
- while ((phrase = ss.match(/"([^"]+)"/)) !== null) {
767
- words.push(phrase[1]);
768
- ss = ss.substring(0, phrase.index) + ss.substring(phrase.index + phrase[0].length);
769
- } // Get remaining space-separated words (if any)
770
-
771
-
772
- ss = ss.trim();
773
- if (ss.length) words = words.concat(ss.split(/\s+/));
774
-
775
- for (var k = 0, kl = _list.items.length; k < kl; k++) {
776
- var item = _list.items[k];
777
- item.found = false;
778
- if (!words.length) continue;
779
-
780
- for (var i = 0, il = words.length; i < il; i++) {
781
- var word_found = false;
782
-
783
- for (var j = 0, jl = columns.length; j < jl; j++) {
784
- var values = item.values(),
785
- column = columns[j];
786
-
787
- if (values.hasOwnProperty(column) && values[column] !== undefined && values[column] !== null) {
788
- var text = typeof values[column] !== 'string' ? values[column].toString() : values[column];
789
-
790
- if (text.toLowerCase().indexOf(words[i]) !== -1) {
791
- // word found, so no need to check it against any other columns
792
- word_found = true;
793
- break;
794
- }
795
- }
796
- } // this word not found? no need to check any other words, the item cannot match
797
-
798
-
799
- if (!word_found) break;
800
- }
801
-
802
- item.found = word_found;
803
- }
804
- },
805
- // Removed search.item() and search.values()
806
- reset: function reset() {
807
- _list.reset.search();
808
-
809
- _list.searched = false;
810
- }
811
- };
812
-
813
- var searchMethod = function searchMethod(str) {
814
- _list.trigger('searchStart');
815
-
816
- prepare.resetList();
817
- prepare.setSearchString(str);
818
- prepare.setOptions(arguments); // str, cols|searchFunction, searchFunction
819
-
820
- prepare.setColumns();
821
-
822
- if (searchString === '') {
823
- search.reset();
824
- } else {
825
- _list.searched = true;
826
-
827
- if (customSearch) {
828
- customSearch(searchString, columns);
829
- } else {
830
- search.list();
831
- }
832
- }
833
-
834
- _list.update();
835
-
836
- _list.trigger('searchComplete');
837
-
838
- return _list.visibleItems;
839
- };
840
-
841
- _list.handlers.searchStart = _list.handlers.searchStart || [];
842
- _list.handlers.searchComplete = _list.handlers.searchComplete || [];
843
-
844
- _list.utils.events.bind(_list.utils.getByClass(_list.listContainer, _list.searchClass), 'keyup', _list.utils.events.debounce(function (e) {
845
- var target = e.target || e.srcElement,
846
- // IE have srcElement
847
- alreadyCleared = target.value === '' && !_list.searched;
848
-
849
- if (!alreadyCleared) {
850
- // If oninput already have resetted the list, do nothing
851
- searchMethod(target.value);
852
- }
853
- }, _list.searchDelay)); // Used to detect click on HTML5 clear button
854
-
855
-
856
- _list.utils.events.bind(_list.utils.getByClass(_list.listContainer, _list.searchClass), 'input', function (e) {
857
- var target = e.target || e.srcElement;
858
-
859
- if (target.value === '') {
860
- searchMethod('');
861
- }
862
- });
863
-
864
- return searchMethod;
865
- };
866
-
867
- /***/ }),
868
-
869
- /***/ "./src/sort.js":
870
- /*!*********************!*\
871
- !*** ./src/sort.js ***!
872
- \*********************/
873
- /*! unknown exports (runtime-defined) */
874
- /*! runtime requirements: module */
875
- /*! CommonJS bailout: module.exports is used directly at 1:0-14 */
876
- /***/ (function(module) {
877
-
878
- module.exports = function (list) {
879
- var buttons = {
880
- els: undefined,
881
- clear: function clear() {
882
- for (var i = 0, il = buttons.els.length; i < il; i++) {
883
- list.utils.classes(buttons.els[i]).remove('asc');
884
- list.utils.classes(buttons.els[i]).remove('desc');
885
- }
886
- },
887
- getOrder: function getOrder(btn) {
888
- var predefinedOrder = list.utils.getAttribute(btn, 'data-order');
889
-
890
- if (predefinedOrder == 'asc' || predefinedOrder == 'desc') {
891
- return predefinedOrder;
892
- } else if (list.utils.classes(btn).has('desc')) {
893
- return 'asc';
894
- } else if (list.utils.classes(btn).has('asc')) {
895
- return 'desc';
896
- } else {
897
- return 'asc';
898
- }
899
- },
900
- getInSensitive: function getInSensitive(btn, options) {
901
- var insensitive = list.utils.getAttribute(btn, 'data-insensitive');
902
-
903
- if (insensitive === 'false') {
904
- options.insensitive = false;
905
- } else {
906
- options.insensitive = true;
907
- }
908
- },
909
- setOrder: function setOrder(options) {
910
- for (var i = 0, il = buttons.els.length; i < il; i++) {
911
- var btn = buttons.els[i];
912
-
913
- if (list.utils.getAttribute(btn, 'data-sort') !== options.valueName) {
914
- continue;
915
- }
916
-
917
- var predefinedOrder = list.utils.getAttribute(btn, 'data-order');
918
-
919
- if (predefinedOrder == 'asc' || predefinedOrder == 'desc') {
920
- if (predefinedOrder == options.order) {
921
- list.utils.classes(btn).add(options.order);
922
- }
923
- } else {
924
- list.utils.classes(btn).add(options.order);
925
- }
926
- }
927
- }
928
- };
929
-
930
- var sort = function sort() {
931
- list.trigger('sortStart');
932
- var options = {};
933
- var target = arguments[0].currentTarget || arguments[0].srcElement || undefined;
934
-
935
- if (target) {
936
- options.valueName = list.utils.getAttribute(target, 'data-sort');
937
- buttons.getInSensitive(target, options);
938
- options.order = buttons.getOrder(target);
939
- } else {
940
- options = arguments[1] || options;
941
- options.valueName = arguments[0];
942
- options.order = options.order || 'asc';
943
- options.insensitive = typeof options.insensitive == 'undefined' ? true : options.insensitive;
944
- }
945
-
946
- buttons.clear();
947
- buttons.setOrder(options); // caseInsensitive
948
- // alphabet
949
-
950
- var customSortFunction = options.sortFunction || list.sortFunction || null,
951
- multi = options.order === 'desc' ? -1 : 1,
952
- sortFunction;
953
-
954
- if (customSortFunction) {
955
- sortFunction = function sortFunction(itemA, itemB) {
956
- return customSortFunction(itemA, itemB, options) * multi;
957
- };
958
- } else {
959
- sortFunction = function sortFunction(itemA, itemB) {
960
- var sort = list.utils.naturalSort;
961
- sort.alphabet = list.alphabet || options.alphabet || undefined;
962
-
963
- if (!sort.alphabet && options.insensitive) {
964
- sort = list.utils.naturalSort.caseInsensitive;
965
- }
966
-
967
- return sort(itemA.values()[options.valueName], itemB.values()[options.valueName]) * multi;
968
- };
969
- }
970
-
971
- list.items.sort(sortFunction);
972
- list.update();
973
- list.trigger('sortComplete');
974
- }; // Add handlers
975
-
976
-
977
- list.handlers.sortStart = list.handlers.sortStart || [];
978
- list.handlers.sortComplete = list.handlers.sortComplete || [];
979
- buttons.els = list.utils.getByClass(list.listContainer, list.sortClass);
980
- list.utils.events.bind(buttons.els, 'click', sort);
981
- list.on('searchStart', buttons.clear);
982
- list.on('filterStart', buttons.clear);
983
- return sort;
984
- };
985
-
986
- /***/ }),
987
-
988
- /***/ "./src/templater.js":
989
- /*!**************************!*\
990
- !*** ./src/templater.js ***!
991
- \**************************/
992
- /*! unknown exports (runtime-defined) */
993
- /*! runtime requirements: module */
994
- /*! CommonJS bailout: module.exports is used directly at 216:0-14 */
995
- /***/ (function(module) {
996
-
997
- var Templater = function Templater(list) {
998
- var createItem,
999
- templater = this;
1000
-
1001
- var init = function init() {
1002
- var itemSource;
1003
-
1004
- if (typeof list.item === 'function') {
1005
- createItem = function createItem(values) {
1006
- var item = list.item(values);
1007
- return getItemSource(item);
1008
- };
1009
-
1010
- return;
1011
- }
1012
-
1013
- if (typeof list.item === 'string') {
1014
- if (list.item.indexOf('<') === -1) {
1015
- itemSource = document.getElementById(list.item);
1016
- } else {
1017
- itemSource = getItemSource(list.item);
1018
- }
1019
- } else {
1020
- /* If item source does not exists, use the first item in list as
1021
- source for new items */
1022
- itemSource = getFirstListItem();
1023
- }
1024
-
1025
- if (!itemSource) {
1026
- throw new Error("The list needs to have at least one item on init otherwise you'll have to add a template.");
1027
- }
1028
-
1029
- itemSource = createCleanTemplateItem(itemSource, list.valueNames);
1030
-
1031
- createItem = function createItem() {
1032
- return itemSource.cloneNode(true);
1033
- };
1034
- };
1035
-
1036
- var createCleanTemplateItem = function createCleanTemplateItem(templateNode, valueNames) {
1037
- var el = templateNode.cloneNode(true);
1038
- el.removeAttribute('id');
1039
-
1040
- for (var i = 0, il = valueNames.length; i < il; i++) {
1041
- var elm = undefined,
1042
- valueName = valueNames[i];
1043
-
1044
- if (valueName.data) {
1045
- for (var j = 0, jl = valueName.data.length; j < jl; j++) {
1046
- el.setAttribute('data-' + valueName.data[j], '');
1047
- }
1048
- } else if (valueName.attr && valueName.name) {
1049
- elm = list.utils.getByClass(el, valueName.name, true);
1050
-
1051
- if (elm) {
1052
- elm.setAttribute(valueName.attr, '');
1053
- }
1054
- } else {
1055
- elm = list.utils.getByClass(el, valueName, true);
1056
-
1057
- if (elm) {
1058
- elm.innerHTML = '';
1059
- }
1060
- }
1061
- }
1062
-
1063
- return el;
1064
- };
1065
-
1066
- var getFirstListItem = function getFirstListItem() {
1067
- var nodes = list.list.childNodes;
1068
-
1069
- for (var i = 0, il = nodes.length; i < il; i++) {
1070
- // Only textnodes have a data attribute
1071
- if (nodes[i].data === undefined) {
1072
- return nodes[i].cloneNode(true);
1073
- }
1074
- }
1075
-
1076
- return undefined;
1077
- };
1078
-
1079
- var getItemSource = function getItemSource(itemHTML) {
1080
- if (typeof itemHTML !== 'string') return undefined;
1081
-
1082
- if (/<tr[\s>]/g.exec(itemHTML)) {
1083
- var tbody = document.createElement('tbody');
1084
- tbody.innerHTML = itemHTML;
1085
- return tbody.firstElementChild;
1086
- } else if (itemHTML.indexOf('<') !== -1) {
1087
- var div = document.createElement('div');
1088
- div.innerHTML = itemHTML;
1089
- return div.firstElementChild;
1090
- }
1091
-
1092
- return undefined;
1093
- };
1094
-
1095
- var getValueName = function getValueName(name) {
1096
- for (var i = 0, il = list.valueNames.length; i < il; i++) {
1097
- var valueName = list.valueNames[i];
1098
-
1099
- if (valueName.data) {
1100
- var data = valueName.data;
1101
-
1102
- for (var j = 0, jl = data.length; j < jl; j++) {
1103
- if (data[j] === name) {
1104
- return {
1105
- data: name
1106
- };
1107
- }
1108
- }
1109
- } else if (valueName.attr && valueName.name && valueName.name == name) {
1110
- return valueName;
1111
- } else if (valueName === name) {
1112
- return name;
1113
- }
1114
- }
1115
- };
1116
-
1117
- var setValue = function setValue(item, name, value) {
1118
- var elm = undefined,
1119
- valueName = getValueName(name);
1120
- if (!valueName) return;
1121
-
1122
- if (valueName.data) {
1123
- item.elm.setAttribute('data-' + valueName.data, value);
1124
- } else if (valueName.attr && valueName.name) {
1125
- elm = list.utils.getByClass(item.elm, valueName.name, true);
1126
-
1127
- if (elm) {
1128
- elm.setAttribute(valueName.attr, value);
1129
- }
1130
- } else {
1131
- elm = list.utils.getByClass(item.elm, valueName, true);
1132
-
1133
- if (elm) {
1134
- elm.innerHTML = value;
1135
- }
1136
- }
1137
- };
1138
-
1139
- this.get = function (item, valueNames) {
1140
- templater.create(item);
1141
- var values = {};
1142
-
1143
- for (var i = 0, il = valueNames.length; i < il; i++) {
1144
- var elm = undefined,
1145
- valueName = valueNames[i];
1146
-
1147
- if (valueName.data) {
1148
- for (var j = 0, jl = valueName.data.length; j < jl; j++) {
1149
- values[valueName.data[j]] = list.utils.getAttribute(item.elm, 'data-' + valueName.data[j]);
1150
- }
1151
- } else if (valueName.attr && valueName.name) {
1152
- elm = list.utils.getByClass(item.elm, valueName.name, true);
1153
- values[valueName.name] = elm ? list.utils.getAttribute(elm, valueName.attr) : '';
1154
- } else {
1155
- elm = list.utils.getByClass(item.elm, valueName, true);
1156
- values[valueName] = elm ? elm.innerHTML : '';
1157
- }
1158
- }
1159
-
1160
- return values;
1161
- };
1162
-
1163
- this.set = function (item, values) {
1164
- if (!templater.create(item)) {
1165
- for (var v in values) {
1166
- if (values.hasOwnProperty(v)) {
1167
- setValue(item, v, values[v]);
1168
- }
1169
- }
1170
- }
1171
- };
1172
-
1173
- this.create = function (item) {
1174
- if (item.elm !== undefined) {
1175
- return false;
1176
- }
1177
-
1178
- item.elm = createItem(item.values());
1179
- templater.set(item, item.values());
1180
- return true;
1181
- };
1182
-
1183
- this.remove = function (item) {
1184
- if (item.elm.parentNode === list.list) {
1185
- list.list.removeChild(item.elm);
1186
- }
1187
- };
1188
-
1189
- this.show = function (item) {
1190
- templater.create(item);
1191
- list.list.appendChild(item.elm);
1192
- };
1193
-
1194
- this.hide = function (item) {
1195
- if (item.elm !== undefined && item.elm.parentNode === list.list) {
1196
- list.list.removeChild(item.elm);
1197
- }
1198
- };
1199
-
1200
- this.clear = function () {
1201
- /* .innerHTML = ''; fucks up IE */
1202
- if (list.list.hasChildNodes()) {
1203
- while (list.list.childNodes.length >= 1) {
1204
- list.list.removeChild(list.list.firstChild);
1205
- }
1206
- }
1207
- };
1208
-
1209
- init();
1210
- };
1211
-
1212
- module.exports = function (list) {
1213
- return new Templater(list);
1214
- };
1215
-
1216
- /***/ }),
1217
-
1218
- /***/ "./src/utils/classes.js":
1219
- /*!******************************!*\
1220
- !*** ./src/utils/classes.js ***!
1221
- \******************************/
1222
- /*! unknown exports (runtime-defined) */
1223
- /*! runtime requirements: module, __webpack_require__ */
1224
- /*! CommonJS bailout: module.exports is used directly at 24:0-14 */
1225
- /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
1226
-
1227
- /**
1228
- * Module dependencies.
1229
- */
1230
- var index = __webpack_require__(/*! ./index-of */ "./src/utils/index-of.js");
1231
- /**
1232
- * Whitespace regexp.
1233
- */
1234
-
1235
-
1236
- var re = /\s+/;
1237
- /**
1238
- * toString reference.
1239
- */
1240
-
1241
- var toString = Object.prototype.toString;
1242
- /**
1243
- * Wrap `el` in a `ClassList`.
1244
- *
1245
- * @param {Element} el
1246
- * @return {ClassList}
1247
- * @api public
1248
- */
1249
-
1250
- module.exports = function (el) {
1251
- return new ClassList(el);
1252
- };
1253
- /**
1254
- * Initialize a new ClassList for `el`.
1255
- *
1256
- * @param {Element} el
1257
- * @api private
1258
- */
1259
-
1260
-
1261
- function ClassList(el) {
1262
- if (!el || !el.nodeType) {
1263
- throw new Error('A DOM element reference is required');
1264
- }
1265
-
1266
- this.el = el;
1267
- this.list = el.classList;
1268
- }
1269
- /**
1270
- * Add class `name` if not already present.
1271
- *
1272
- * @param {String} name
1273
- * @return {ClassList}
1274
- * @api public
1275
- */
1276
-
1277
-
1278
- ClassList.prototype.add = function (name) {
1279
- // classList
1280
- if (this.list) {
1281
- this.list.add(name);
1282
- return this;
1283
- } // fallback
1284
-
1285
-
1286
- var arr = this.array();
1287
- var i = index(arr, name);
1288
- if (!~i) arr.push(name);
1289
- this.el.className = arr.join(' ');
1290
- return this;
1291
- };
1292
- /**
1293
- * Remove class `name` when present, or
1294
- * pass a regular expression to remove
1295
- * any which match.
1296
- *
1297
- * @param {String|RegExp} name
1298
- * @return {ClassList}
1299
- * @api public
1300
- */
1301
-
1302
-
1303
- ClassList.prototype.remove = function (name) {
1304
- // classList
1305
- if (this.list) {
1306
- this.list.remove(name);
1307
- return this;
1308
- } // fallback
1309
-
1310
-
1311
- var arr = this.array();
1312
- var i = index(arr, name);
1313
- if (~i) arr.splice(i, 1);
1314
- this.el.className = arr.join(' ');
1315
- return this;
1316
- };
1317
- /**
1318
- * Toggle class `name`, can force state via `force`.
1319
- *
1320
- * For browsers that support classList, but do not support `force` yet,
1321
- * the mistake will be detected and corrected.
1322
- *
1323
- * @param {String} name
1324
- * @param {Boolean} force
1325
- * @return {ClassList}
1326
- * @api public
1327
- */
1328
-
1329
-
1330
- ClassList.prototype.toggle = function (name, force) {
1331
- // classList
1332
- if (this.list) {
1333
- if ('undefined' !== typeof force) {
1334
- if (force !== this.list.toggle(name, force)) {
1335
- this.list.toggle(name); // toggle again to correct
1336
- }
1337
- } else {
1338
- this.list.toggle(name);
1339
- }
1340
-
1341
- return this;
1342
- } // fallback
1343
-
1344
-
1345
- if ('undefined' !== typeof force) {
1346
- if (!force) {
1347
- this.remove(name);
1348
- } else {
1349
- this.add(name);
1350
- }
1351
- } else {
1352
- if (this.has(name)) {
1353
- this.remove(name);
1354
- } else {
1355
- this.add(name);
1356
- }
1357
- }
1358
-
1359
- return this;
1360
- };
1361
- /**
1362
- * Return an array of classes.
1363
- *
1364
- * @return {Array}
1365
- * @api public
1366
- */
1367
-
1368
-
1369
- ClassList.prototype.array = function () {
1370
- var className = this.el.getAttribute('class') || '';
1371
- var str = className.replace(/^\s+|\s+$/g, '');
1372
- var arr = str.split(re);
1373
- if ('' === arr[0]) arr.shift();
1374
- return arr;
1375
- };
1376
- /**
1377
- * Check if class `name` is present.
1378
- *
1379
- * @param {String} name
1380
- * @return {ClassList}
1381
- * @api public
1382
- */
1383
-
1384
-
1385
- ClassList.prototype.has = ClassList.prototype.contains = function (name) {
1386
- return this.list ? this.list.contains(name) : !!~index(this.array(), name);
1387
- };
1388
-
1389
- /***/ }),
1390
-
1391
- /***/ "./src/utils/events.js":
1392
- /*!*****************************!*\
1393
- !*** ./src/utils/events.js ***!
1394
- \*****************************/
1395
- /*! default exports */
1396
- /*! export bind [provided] [no usage info] [missing usage info prevents renaming] */
1397
- /*! export debounce [provided] [no usage info] [missing usage info prevents renaming] */
1398
- /*! export unbind [provided] [no usage info] [missing usage info prevents renaming] */
1399
- /*! other exports [not provided] [no usage info] */
1400
- /*! runtime requirements: __webpack_exports__, __webpack_require__ */
1401
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
1402
-
1403
- var bind = window.addEventListener ? 'addEventListener' : 'attachEvent',
1404
- unbind = window.removeEventListener ? 'removeEventListener' : 'detachEvent',
1405
- prefix = bind !== 'addEventListener' ? 'on' : '',
1406
- toArray = __webpack_require__(/*! ./to-array */ "./src/utils/to-array.js");
1407
- /**
1408
- * Bind `el` event `type` to `fn`.
1409
- *
1410
- * @param {Element} el, NodeList, HTMLCollection or Array
1411
- * @param {String} type
1412
- * @param {Function} fn
1413
- * @param {Boolean} capture
1414
- * @api public
1415
- */
1416
-
1417
-
1418
- exports.bind = function (el, type, fn, capture) {
1419
- el = toArray(el);
1420
-
1421
- for (var i = 0, il = el.length; i < il; i++) {
1422
- el[i][bind](prefix + type, fn, capture || false);
1423
- }
1424
- };
1425
- /**
1426
- * Unbind `el` event `type`'s callback `fn`.
1427
- *
1428
- * @param {Element} el, NodeList, HTMLCollection or Array
1429
- * @param {String} type
1430
- * @param {Function} fn
1431
- * @param {Boolean} capture
1432
- * @api public
1433
- */
1434
-
1435
-
1436
- exports.unbind = function (el, type, fn, capture) {
1437
- el = toArray(el);
1438
-
1439
- for (var i = 0, il = el.length; i < il; i++) {
1440
- el[i][unbind](prefix + type, fn, capture || false);
1441
- }
1442
- };
1443
- /**
1444
- * Returns a function, that, as long as it continues to be invoked, will not
1445
- * be triggered. The function will be called after it stops being called for
1446
- * `wait` milliseconds. If `immediate` is true, trigger the function on the
1447
- * leading edge, instead of the trailing.
1448
- *
1449
- * @param {Function} fn
1450
- * @param {Integer} wait
1451
- * @param {Boolean} immediate
1452
- * @api public
1453
- */
1454
-
1455
-
1456
- exports.debounce = function (fn, wait, immediate) {
1457
- var timeout;
1458
- return wait ? function () {
1459
- var context = this,
1460
- args = arguments;
1461
-
1462
- var later = function later() {
1463
- timeout = null;
1464
- if (!immediate) fn.apply(context, args);
1465
- };
1466
-
1467
- var callNow = immediate && !timeout;
1468
- clearTimeout(timeout);
1469
- timeout = setTimeout(later, wait);
1470
- if (callNow) fn.apply(context, args);
1471
- } : fn;
1472
- };
1473
-
1474
- /***/ }),
1475
-
1476
- /***/ "./src/utils/extend.js":
1477
- /*!*****************************!*\
1478
- !*** ./src/utils/extend.js ***!
1479
- \*****************************/
1480
- /*! unknown exports (runtime-defined) */
1481
- /*! runtime requirements: module */
1482
- /*! CommonJS bailout: module.exports is used directly at 4:0-14 */
1483
- /***/ (function(module) {
1484
-
1485
- /*
1486
- * Source: https://github.com/segmentio/extend
1487
- */
1488
- module.exports = function extend(object) {
1489
- // Takes an unlimited number of extenders.
1490
- var args = Array.prototype.slice.call(arguments, 1); // For each extender, copy their properties on our object.
1491
-
1492
- for (var i = 0, source; source = args[i]; i++) {
1493
- if (!source) continue;
1494
-
1495
- for (var property in source) {
1496
- object[property] = source[property];
1497
- }
1498
- }
1499
-
1500
- return object;
1501
- };
1502
-
1503
- /***/ }),
1504
-
1505
- /***/ "./src/utils/fuzzy.js":
1506
- /*!****************************!*\
1507
- !*** ./src/utils/fuzzy.js ***!
1508
- \****************************/
1509
- /*! unknown exports (runtime-defined) */
1510
- /*! runtime requirements: module */
1511
- /*! CommonJS bailout: module.exports is used directly at 1:0-14 */
1512
- /***/ (function(module) {
1513
-
1514
- module.exports = function (text, pattern, options) {
1515
- // Aproximately where in the text is the pattern expected to be found?
1516
- var Match_Location = options.location || 0; //Determines how close the match must be to the fuzzy location (specified above). An exact letter match which is 'distance' characters away from the fuzzy location would score as a complete mismatch. A distance of '0' requires the match be at the exact location specified, a threshold of '1000' would require a perfect match to be within 800 characters of the fuzzy location to be found using a 0.8 threshold.
1517
-
1518
- var Match_Distance = options.distance || 100; // At what point does the match algorithm give up. A threshold of '0.0' requires a perfect match (of both letters and location), a threshold of '1.0' would match anything.
1519
-
1520
- var Match_Threshold = options.threshold || 0.4;
1521
- if (pattern === text) return true; // Exact match
1522
-
1523
- if (pattern.length > 32) return false; // This algorithm cannot be used
1524
- // Set starting location at beginning text and initialise the alphabet.
1525
-
1526
- var loc = Match_Location,
1527
- s = function () {
1528
- var q = {},
1529
- i;
1530
-
1531
- for (i = 0; i < pattern.length; i++) {
1532
- q[pattern.charAt(i)] = 0;
1533
- }
1534
-
1535
- for (i = 0; i < pattern.length; i++) {
1536
- q[pattern.charAt(i)] |= 1 << pattern.length - i - 1;
1537
- }
1538
-
1539
- return q;
1540
- }(); // Compute and return the score for a match with e errors and x location.
1541
- // Accesses loc and pattern through being a closure.
1542
-
1543
-
1544
- function match_bitapScore_(e, x) {
1545
- var accuracy = e / pattern.length,
1546
- proximity = Math.abs(loc - x);
1547
-
1548
- if (!Match_Distance) {
1549
- // Dodge divide by zero error.
1550
- return proximity ? 1.0 : accuracy;
1551
- }
1552
-
1553
- return accuracy + proximity / Match_Distance;
1554
- }
1555
-
1556
- var score_threshold = Match_Threshold,
1557
- // Highest score beyond which we give up.
1558
- best_loc = text.indexOf(pattern, loc); // Is there a nearby exact match? (speedup)
1559
-
1560
- if (best_loc != -1) {
1561
- score_threshold = Math.min(match_bitapScore_(0, best_loc), score_threshold); // What about in the other direction? (speedup)
1562
-
1563
- best_loc = text.lastIndexOf(pattern, loc + pattern.length);
1564
-
1565
- if (best_loc != -1) {
1566
- score_threshold = Math.min(match_bitapScore_(0, best_loc), score_threshold);
1567
- }
1568
- } // Initialise the bit arrays.
1569
-
1570
-
1571
- var matchmask = 1 << pattern.length - 1;
1572
- best_loc = -1;
1573
- var bin_min, bin_mid;
1574
- var bin_max = pattern.length + text.length;
1575
- var last_rd;
1576
-
1577
- for (var d = 0; d < pattern.length; d++) {
1578
- // Scan for the best match; each iteration allows for one more error.
1579
- // Run a binary search to determine how far from 'loc' we can stray at this
1580
- // error level.
1581
- bin_min = 0;
1582
- bin_mid = bin_max;
1583
-
1584
- while (bin_min < bin_mid) {
1585
- if (match_bitapScore_(d, loc + bin_mid) <= score_threshold) {
1586
- bin_min = bin_mid;
1587
- } else {
1588
- bin_max = bin_mid;
1589
- }
1590
-
1591
- bin_mid = Math.floor((bin_max - bin_min) / 2 + bin_min);
1592
- } // Use the result from this iteration as the maximum for the next.
1593
-
1594
-
1595
- bin_max = bin_mid;
1596
- var start = Math.max(1, loc - bin_mid + 1);
1597
- var finish = Math.min(loc + bin_mid, text.length) + pattern.length;
1598
- var rd = Array(finish + 2);
1599
- rd[finish + 1] = (1 << d) - 1;
1600
-
1601
- for (var j = finish; j >= start; j--) {
1602
- // The alphabet (s) is a sparse hash, so the following line generates
1603
- // warnings.
1604
- var charMatch = s[text.charAt(j - 1)];
1605
-
1606
- if (d === 0) {
1607
- // First pass: exact match.
1608
- rd[j] = (rd[j + 1] << 1 | 1) & charMatch;
1609
- } else {
1610
- // Subsequent passes: fuzzy match.
1611
- rd[j] = (rd[j + 1] << 1 | 1) & charMatch | ((last_rd[j + 1] | last_rd[j]) << 1 | 1) | last_rd[j + 1];
1612
- }
1613
-
1614
- if (rd[j] & matchmask) {
1615
- var score = match_bitapScore_(d, j - 1); // This match will almost certainly be better than any existing match.
1616
- // But check anyway.
1617
-
1618
- if (score <= score_threshold) {
1619
- // Told you so.
1620
- score_threshold = score;
1621
- best_loc = j - 1;
1622
-
1623
- if (best_loc > loc) {
1624
- // When passing loc, don't exceed our current distance from loc.
1625
- start = Math.max(1, 2 * loc - best_loc);
1626
- } else {
1627
- // Already passed loc, downhill from here on in.
1628
- break;
1629
- }
1630
- }
1631
- }
1632
- } // No hope for a (better) match at greater error levels.
1633
-
1634
-
1635
- if (match_bitapScore_(d + 1, loc) > score_threshold) {
1636
- break;
1637
- }
1638
-
1639
- last_rd = rd;
1640
- }
1641
-
1642
- return best_loc < 0 ? false : true;
1643
- };
1644
-
1645
- /***/ }),
1646
-
1647
- /***/ "./src/utils/get-attribute.js":
1648
- /*!************************************!*\
1649
- !*** ./src/utils/get-attribute.js ***!
1650
- \************************************/
1651
- /*! unknown exports (runtime-defined) */
1652
- /*! runtime requirements: module */
1653
- /*! CommonJS bailout: module.exports is used directly at 11:0-14 */
1654
- /***/ (function(module) {
1655
-
1656
- /**
1657
- * A cross-browser implementation of getAttribute.
1658
- * Source found here: http://stackoverflow.com/a/3755343/361337 written by Vivin Paliath
1659
- *
1660
- * Return the value for `attr` at `element`.
1661
- *
1662
- * @param {Element} el
1663
- * @param {String} attr
1664
- * @api public
1665
- */
1666
- module.exports = function (el, attr) {
1667
- var result = el.getAttribute && el.getAttribute(attr) || null;
1668
-
1669
- if (!result) {
1670
- var attrs = el.attributes;
1671
- var length = attrs.length;
1672
-
1673
- for (var i = 0; i < length; i++) {
1674
- if (attrs[i] !== undefined) {
1675
- if (attrs[i].nodeName === attr) {
1676
- result = attrs[i].nodeValue;
1677
- }
1678
- }
1679
- }
1680
- }
1681
-
1682
- return result;
1683
- };
1684
-
1685
- /***/ }),
1686
-
1687
- /***/ "./src/utils/get-by-class.js":
1688
- /*!***********************************!*\
1689
- !*** ./src/utils/get-by-class.js ***!
1690
- \***********************************/
1691
- /*! unknown exports (runtime-defined) */
1692
- /*! runtime requirements: module */
1693
- /*! CommonJS bailout: module.exports is used directly at 53:0-14 */
1694
- /***/ (function(module) {
1695
-
1696
- /**
1697
- * A cross-browser implementation of getElementsByClass.
1698
- * Heavily based on Dustin Diaz's function: http://dustindiaz.com/getelementsbyclass.
1699
- *
1700
- * Find all elements with class `className` inside `container`.
1701
- * Use `single = true` to increase performance in older browsers
1702
- * when only one element is needed.
1703
- *
1704
- * @param {String} className
1705
- * @param {Element} container
1706
- * @param {Boolean} single
1707
- * @api public
1708
- */
1709
- var getElementsByClassName = function getElementsByClassName(container, className, single) {
1710
- if (single) {
1711
- return container.getElementsByClassName(className)[0];
1712
- } else {
1713
- return container.getElementsByClassName(className);
1714
- }
1715
- };
1716
-
1717
- var querySelector = function querySelector(container, className, single) {
1718
- className = '.' + className;
1719
-
1720
- if (single) {
1721
- return container.querySelector(className);
1722
- } else {
1723
- return container.querySelectorAll(className);
1724
- }
1725
- };
1726
-
1727
- var polyfill = function polyfill(container, className, single) {
1728
- var classElements = [],
1729
- tag = '*';
1730
- var els = container.getElementsByTagName(tag);
1731
- var elsLen = els.length;
1732
- var pattern = new RegExp('(^|\\s)' + className + '(\\s|$)');
1733
-
1734
- for (var i = 0, j = 0; i < elsLen; i++) {
1735
- if (pattern.test(els[i].className)) {
1736
- if (single) {
1737
- return els[i];
1738
- } else {
1739
- classElements[j] = els[i];
1740
- j++;
1741
- }
1742
- }
1743
- }
1744
-
1745
- return classElements;
1746
- };
1747
-
1748
- module.exports = function () {
1749
- return function (container, className, single, options) {
1750
- options = options || {};
1751
-
1752
- if (options.test && options.getElementsByClassName || !options.test && document.getElementsByClassName) {
1753
- return getElementsByClassName(container, className, single);
1754
- } else if (options.test && options.querySelector || !options.test && document.querySelector) {
1755
- return querySelector(container, className, single);
1756
- } else {
1757
- return polyfill(container, className, single);
1758
- }
1759
- };
1760
- }();
1761
-
1762
- /***/ }),
1763
-
1764
- /***/ "./src/utils/index-of.js":
1765
- /*!*******************************!*\
1766
- !*** ./src/utils/index-of.js ***!
1767
- \*******************************/
1768
- /*! unknown exports (runtime-defined) */
1769
- /*! runtime requirements: module */
1770
- /*! CommonJS bailout: module.exports is used directly at 3:0-14 */
1771
- /***/ (function(module) {
1772
-
1773
- var indexOf = [].indexOf;
1774
-
1775
- module.exports = function (arr, obj) {
1776
- if (indexOf) return arr.indexOf(obj);
1777
-
1778
- for (var i = 0, il = arr.length; i < il; ++i) {
1779
- if (arr[i] === obj) return i;
1780
- }
1781
-
1782
- return -1;
1783
- };
1784
-
1785
- /***/ }),
1786
-
1787
- /***/ "./src/utils/to-array.js":
1788
- /*!*******************************!*\
1789
- !*** ./src/utils/to-array.js ***!
1790
- \*******************************/
1791
- /*! unknown exports (runtime-defined) */
1792
- /*! runtime requirements: module */
1793
- /*! CommonJS bailout: module.exports is used directly at 11:0-14 */
1794
- /***/ (function(module) {
1795
-
1796
- /**
1797
- * Source: https://github.com/timoxley/to-array
1798
- *
1799
- * Convert an array-like object into an `Array`.
1800
- * If `collection` is already an `Array`, then will return a clone of `collection`.
1801
- *
1802
- * @param {Array | Mixed} collection An `Array` or array-like object to convert e.g. `arguments` or `NodeList`
1803
- * @return {Array} Naive conversion of `collection` to a new `Array`.
1804
- * @api public
1805
- */
1806
- module.exports = function toArray(collection) {
1807
- if (typeof collection === 'undefined') return [];
1808
- if (collection === null) return [null];
1809
- if (collection === window) return [window];
1810
- if (typeof collection === 'string') return [collection];
1811
- if (isArray(collection)) return collection;
1812
- if (typeof collection.length != 'number') return [collection];
1813
- if (typeof collection === 'function' && collection instanceof Function) return [collection];
1814
- var arr = [];
1815
-
1816
- for (var i = 0, il = collection.length; i < il; i++) {
1817
- if (Object.prototype.hasOwnProperty.call(collection, i) || i in collection) {
1818
- arr.push(collection[i]);
1819
- }
1820
- }
1821
-
1822
- if (!arr.length) return [];
1823
- return arr;
1824
- };
1825
-
1826
- function isArray(arr) {
1827
- return Object.prototype.toString.call(arr) === '[object Array]';
1828
- }
1829
-
1830
- /***/ }),
1831
-
1832
- /***/ "./src/utils/to-string.js":
1833
- /*!********************************!*\
1834
- !*** ./src/utils/to-string.js ***!
1835
- \********************************/
1836
- /*! unknown exports (runtime-defined) */
1837
- /*! runtime requirements: module */
1838
- /*! CommonJS bailout: module.exports is used directly at 1:0-14 */
1839
- /***/ (function(module) {
1840
-
1841
- module.exports = function (s) {
1842
- s = s === undefined ? '' : s;
1843
- s = s === null ? '' : s;
1844
- s = s.toString();
1845
- return s;
1846
- };
1847
-
1848
- /***/ }),
1849
-
1850
- /***/ "./node_modules/string-natural-compare/natural-compare.js":
1851
- /*!****************************************************************!*\
1852
- !*** ./node_modules/string-natural-compare/natural-compare.js ***!
1853
- \****************************************************************/
1854
- /*! unknown exports (runtime-defined) */
1855
- /*! runtime requirements: module */
1856
- /*! CommonJS bailout: module.exports is used directly at 124:0-14 */
1857
- /***/ (function(module) {
1858
-
1859
- "use strict";
1860
-
1861
-
1862
- var alphabet;
1863
- var alphabetIndexMap;
1864
- var alphabetIndexMapLength = 0;
1865
-
1866
- function isNumberCode(code) {
1867
- return code >= 48 && code <= 57;
1868
- }
1869
-
1870
- function naturalCompare(a, b) {
1871
- var lengthA = (a += '').length;
1872
- var lengthB = (b += '').length;
1873
- var aIndex = 0;
1874
- var bIndex = 0;
1875
-
1876
- while (aIndex < lengthA && bIndex < lengthB) {
1877
- var charCodeA = a.charCodeAt(aIndex);
1878
- var charCodeB = b.charCodeAt(bIndex);
1879
-
1880
- if (isNumberCode(charCodeA)) {
1881
- if (!isNumberCode(charCodeB)) {
1882
- return charCodeA - charCodeB;
1883
- }
1884
-
1885
- var numStartA = aIndex;
1886
- var numStartB = bIndex;
1887
-
1888
- while (charCodeA === 48 && ++numStartA < lengthA) {
1889
- charCodeA = a.charCodeAt(numStartA);
1890
- }
1891
- while (charCodeB === 48 && ++numStartB < lengthB) {
1892
- charCodeB = b.charCodeAt(numStartB);
1893
- }
1894
-
1895
- var numEndA = numStartA;
1896
- var numEndB = numStartB;
1897
-
1898
- while (numEndA < lengthA && isNumberCode(a.charCodeAt(numEndA))) {
1899
- ++numEndA;
1900
- }
1901
- while (numEndB < lengthB && isNumberCode(b.charCodeAt(numEndB))) {
1902
- ++numEndB;
1903
- }
1904
-
1905
- var difference = numEndA - numStartA - numEndB + numStartB; // numA length - numB length
1906
- if (difference) {
1907
- return difference;
1908
- }
1909
-
1910
- while (numStartA < numEndA) {
1911
- difference = a.charCodeAt(numStartA++) - b.charCodeAt(numStartB++);
1912
- if (difference) {
1913
- return difference;
1914
- }
1915
- }
1916
-
1917
- aIndex = numEndA;
1918
- bIndex = numEndB;
1919
- continue;
1920
- }
1921
-
1922
- if (charCodeA !== charCodeB) {
1923
- if (
1924
- charCodeA < alphabetIndexMapLength &&
1925
- charCodeB < alphabetIndexMapLength &&
1926
- alphabetIndexMap[charCodeA] !== -1 &&
1927
- alphabetIndexMap[charCodeB] !== -1
1928
- ) {
1929
- return alphabetIndexMap[charCodeA] - alphabetIndexMap[charCodeB];
1930
- }
1931
-
1932
- return charCodeA - charCodeB;
1933
- }
1934
-
1935
- ++aIndex;
1936
- ++bIndex;
1937
- }
1938
-
1939
- if (aIndex >= lengthA && bIndex < lengthB && lengthA >= lengthB) {
1940
- return -1;
1941
- }
1942
-
1943
- if (bIndex >= lengthB && aIndex < lengthA && lengthB >= lengthA) {
1944
- return 1;
1945
- }
1946
-
1947
- return lengthA - lengthB;
1948
- }
1949
-
1950
- naturalCompare.caseInsensitive = naturalCompare.i = function(a, b) {
1951
- return naturalCompare(('' + a).toLowerCase(), ('' + b).toLowerCase());
1952
- };
1953
-
1954
- Object.defineProperties(naturalCompare, {
1955
- alphabet: {
1956
- get: function() {
1957
- return alphabet;
1958
- },
1959
-
1960
- set: function(value) {
1961
- alphabet = value;
1962
- alphabetIndexMap = [];
1963
-
1964
- var i = 0;
1965
-
1966
- if (alphabet) {
1967
- for (; i < alphabet.length; i++) {
1968
- alphabetIndexMap[alphabet.charCodeAt(i)] = i;
1969
- }
1970
- }
1971
-
1972
- alphabetIndexMapLength = alphabetIndexMap.length;
1973
-
1974
- for (i = 0; i < alphabetIndexMapLength; i++) {
1975
- if (alphabetIndexMap[i] === undefined) {
1976
- alphabetIndexMap[i] = -1;
1977
- }
1978
- }
1979
- },
1980
- },
1981
- });
1982
-
1983
- module.exports = naturalCompare;
1984
-
1985
-
1986
- /***/ })
1987
-
1988
- /******/ });
1989
- /************************************************************************/
1990
- /******/ // The module cache
1991
- /******/ var __webpack_module_cache__ = {};
1992
- /******/
1993
- /******/ // The require function
1994
- /******/ function __webpack_require__(moduleId) {
1995
- /******/ // Check if module is in cache
1996
- /******/ if(__webpack_module_cache__[moduleId]) {
1997
- /******/ return __webpack_module_cache__[moduleId].exports;
1998
- /******/ }
1999
- /******/ // Create a new module (and put it into the cache)
2000
- /******/ var module = __webpack_module_cache__[moduleId] = {
2001
- /******/ // no module.id needed
2002
- /******/ // no module.loaded needed
2003
- /******/ exports: {}
2004
- /******/ };
2005
- /******/
2006
- /******/ // Execute the module function
2007
- /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
2008
- /******/
2009
- /******/ // Return the exports of the module
2010
- /******/ return module.exports;
2011
- /******/ }
2012
- /******/
2013
- /************************************************************************/
2014
- /******/ // module exports must be returned from runtime so entry inlining is disabled
2015
- /******/ // startup
2016
- /******/ // Load entry module and return exports
2017
- /******/ return __webpack_require__("./src/index.js");
2018
- /******/ })()
2019
- ;
2020
- //# sourceMappingURL=list.js.map