listjs-rails 1.1.0 → 1.1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5b1aa4cc10a0b9a5783f561f7f485e76edef308b
4
- data.tar.gz: b9a579e520c632916b8d3a01901c49480eb7ad7c
3
+ metadata.gz: 1cc24eac52a9e06779f0ad6055a3981f5682159d
4
+ data.tar.gz: 109fd090f017c048139afb80ed2a2edc60b56212
5
5
  SHA512:
6
- metadata.gz: 581d62a49e8fa57eecb7b62e5eb1b4bd19019008753750f3e10589ca713476cac26baa729c0778cdf881a9e491ce9f89d2c14d72beaa926f952f3550420d7ffa
7
- data.tar.gz: 84de0263e295e12a0919fc21f7fd358c73a813ef69c5b8f3f5eb7e79db3412ba72d880c9b5ce22617d02b94f0cda5e13f8c2b3af77f28d7ed4be5a6eb2b69ea4
6
+ metadata.gz: 2e728299ef57cbae89f361230407923e51e3012d8878aba58f6046cfd7df683458fd13bb5d33bbd50bca1688e17bde0fd3d79b816cbb90e061c42ef1832953ac
7
+ data.tar.gz: c938c8702ed383531a4745a04f6970e9814f0da8bc7f23fc9cdc35ab80f35a0b838194e8e938a6607785a5fb999755a670a77d9123b07205e38aaf48b18301d4
data/README.md CHANGED
@@ -24,6 +24,20 @@ Make sure List.js is preset in `app/assets/javascripts/application.js`
24
24
  ...
25
25
  ```
26
26
 
27
+ If you require any plugins you may add them to `application.js` also
28
+
29
+ ```
30
+ ...
31
+ //= require list
32
+ //= require list.pagination
33
+ //= require list.fuzzysearch
34
+ ...
35
+ ```
36
+
37
+ ## Usage
38
+
39
+ Please refer to the [List.js Documentation](http://listjs.com) for further implementation instructions.
40
+
27
41
  ## Contributing
28
42
 
29
43
  Feel free to open an issue ticket if you find something that could be improved.
@@ -0,0 +1,869 @@
1
+ ;(function(){
2
+
3
+ /**
4
+ * Require the given path.
5
+ *
6
+ * @param {String} path
7
+ * @return {Object} exports
8
+ * @api public
9
+ */
10
+
11
+ function require(path, parent, orig) {
12
+ var resolved = require.resolve(path);
13
+
14
+ // lookup failed
15
+ if (null == resolved) {
16
+ orig = orig || path;
17
+ parent = parent || 'root';
18
+ var err = new Error('Failed to require "' + orig + '" from "' + parent + '"');
19
+ err.path = orig;
20
+ err.parent = parent;
21
+ err.require = true;
22
+ throw err;
23
+ }
24
+
25
+ var module = require.modules[resolved];
26
+
27
+ // perform real require()
28
+ // by invoking the module's
29
+ // registered function
30
+ if (!module._resolving && !module.exports) {
31
+ var mod = {};
32
+ mod.exports = {};
33
+ mod.client = mod.component = true;
34
+ module._resolving = true;
35
+ module.call(this, mod.exports, require.relative(resolved), mod);
36
+ delete module._resolving;
37
+ module.exports = mod.exports;
38
+ }
39
+
40
+ return module.exports;
41
+ }
42
+
43
+ /**
44
+ * Registered modules.
45
+ */
46
+
47
+ require.modules = {};
48
+
49
+ /**
50
+ * Registered aliases.
51
+ */
52
+
53
+ require.aliases = {};
54
+
55
+ /**
56
+ * Resolve `path`.
57
+ *
58
+ * Lookup:
59
+ *
60
+ * - PATH/index.js
61
+ * - PATH.js
62
+ * - PATH
63
+ *
64
+ * @param {String} path
65
+ * @return {String} path or null
66
+ * @api private
67
+ */
68
+
69
+ require.resolve = function(path) {
70
+ if (path.charAt(0) === '/') path = path.slice(1);
71
+
72
+ var paths = [
73
+ path,
74
+ path + '.js',
75
+ path + '.json',
76
+ path + '/index.js',
77
+ path + '/index.json'
78
+ ];
79
+
80
+ for (var i = 0; i < paths.length; i++) {
81
+ var path = paths[i];
82
+ if (require.modules.hasOwnProperty(path)) return path;
83
+ if (require.aliases.hasOwnProperty(path)) return require.aliases[path];
84
+ }
85
+ };
86
+
87
+ /**
88
+ * Normalize `path` relative to the current path.
89
+ *
90
+ * @param {String} curr
91
+ * @param {String} path
92
+ * @return {String}
93
+ * @api private
94
+ */
95
+
96
+ require.normalize = function(curr, path) {
97
+ var segs = [];
98
+
99
+ if ('.' != path.charAt(0)) return path;
100
+
101
+ curr = curr.split('/');
102
+ path = path.split('/');
103
+
104
+ for (var i = 0; i < path.length; ++i) {
105
+ if ('..' == path[i]) {
106
+ curr.pop();
107
+ } else if ('.' != path[i] && '' != path[i]) {
108
+ segs.push(path[i]);
109
+ }
110
+ }
111
+
112
+ return curr.concat(segs).join('/');
113
+ };
114
+
115
+ /**
116
+ * Register module at `path` with callback `definition`.
117
+ *
118
+ * @param {String} path
119
+ * @param {Function} definition
120
+ * @api private
121
+ */
122
+
123
+ require.register = function(path, definition) {
124
+ require.modules[path] = definition;
125
+ };
126
+
127
+ /**
128
+ * Alias a module definition.
129
+ *
130
+ * @param {String} from
131
+ * @param {String} to
132
+ * @api private
133
+ */
134
+
135
+ require.alias = function(from, to) {
136
+ if (!require.modules.hasOwnProperty(from)) {
137
+ throw new Error('Failed to alias "' + from + '", it does not exist');
138
+ }
139
+ require.aliases[to] = from;
140
+ };
141
+
142
+ /**
143
+ * Return a require function relative to the `parent` path.
144
+ *
145
+ * @param {String} parent
146
+ * @return {Function}
147
+ * @api private
148
+ */
149
+
150
+ require.relative = function(parent) {
151
+ var p = require.normalize(parent, '..');
152
+
153
+ /**
154
+ * lastIndexOf helper.
155
+ */
156
+
157
+ function lastIndexOf(arr, obj) {
158
+ var i = arr.length;
159
+ while (i--) {
160
+ if (arr[i] === obj) return i;
161
+ }
162
+ return -1;
163
+ }
164
+
165
+ /**
166
+ * The relative require() itself.
167
+ */
168
+
169
+ function localRequire(path) {
170
+ var resolved = localRequire.resolve(path);
171
+ return require(resolved, parent, path);
172
+ }
173
+
174
+ /**
175
+ * Resolve relative to the parent.
176
+ */
177
+
178
+ localRequire.resolve = function(path) {
179
+ var c = path.charAt(0);
180
+ if ('/' == c) return path.slice(1);
181
+ if ('.' == c) return require.normalize(p, path);
182
+
183
+ // resolve deps by returning
184
+ // the dep in the nearest "deps"
185
+ // directory
186
+ var segs = parent.split('/');
187
+ var i = lastIndexOf(segs, 'deps') + 1;
188
+ if (!i) i = 0;
189
+ path = segs.slice(0, i + 1).join('/') + '/deps/' + path;
190
+ return path;
191
+ };
192
+
193
+ /**
194
+ * Check if module is defined at `path`.
195
+ */
196
+
197
+ localRequire.exists = function(path) {
198
+ return require.modules.hasOwnProperty(localRequire.resolve(path));
199
+ };
200
+
201
+ return localRequire;
202
+ };
203
+ require.register("component-indexof/index.js", function(exports, require, module){
204
+ module.exports = function(arr, obj){
205
+ if (arr.indexOf) return arr.indexOf(obj);
206
+ for (var i = 0; i < arr.length; ++i) {
207
+ if (arr[i] === obj) return i;
208
+ }
209
+ return -1;
210
+ };
211
+ });
212
+ require.register("component-classes/index.js", function(exports, require, module){
213
+ /**
214
+ * Module dependencies.
215
+ */
216
+
217
+ var index = require('indexof');
218
+
219
+ /**
220
+ * Whitespace regexp.
221
+ */
222
+
223
+ var re = /\s+/;
224
+
225
+ /**
226
+ * toString reference.
227
+ */
228
+
229
+ var toString = Object.prototype.toString;
230
+
231
+ /**
232
+ * Wrap `el` in a `ClassList`.
233
+ *
234
+ * @param {Element} el
235
+ * @return {ClassList}
236
+ * @api public
237
+ */
238
+
239
+ module.exports = function(el){
240
+ return new ClassList(el);
241
+ };
242
+
243
+ /**
244
+ * Initialize a new ClassList for `el`.
245
+ *
246
+ * @param {Element} el
247
+ * @api private
248
+ */
249
+
250
+ function ClassList(el) {
251
+ if (!el) throw new Error('A DOM element reference is required');
252
+ this.el = el;
253
+ this.list = el.classList;
254
+ }
255
+
256
+ /**
257
+ * Add class `name` if not already present.
258
+ *
259
+ * @param {String} name
260
+ * @return {ClassList}
261
+ * @api public
262
+ */
263
+
264
+ ClassList.prototype.add = function(name){
265
+ // classList
266
+ if (this.list) {
267
+ this.list.add(name);
268
+ return this;
269
+ }
270
+
271
+ // fallback
272
+ var arr = this.array();
273
+ var i = index(arr, name);
274
+ if (!~i) arr.push(name);
275
+ this.el.className = arr.join(' ');
276
+ return this;
277
+ };
278
+
279
+ /**
280
+ * Remove class `name` when present, or
281
+ * pass a regular expression to remove
282
+ * any which match.
283
+ *
284
+ * @param {String|RegExp} name
285
+ * @return {ClassList}
286
+ * @api public
287
+ */
288
+
289
+ ClassList.prototype.remove = function(name){
290
+ if ('[object RegExp]' == toString.call(name)) {
291
+ return this.removeMatching(name);
292
+ }
293
+
294
+ // classList
295
+ if (this.list) {
296
+ this.list.remove(name);
297
+ return this;
298
+ }
299
+
300
+ // fallback
301
+ var arr = this.array();
302
+ var i = index(arr, name);
303
+ if (~i) arr.splice(i, 1);
304
+ this.el.className = arr.join(' ');
305
+ return this;
306
+ };
307
+
308
+ /**
309
+ * Remove all classes matching `re`.
310
+ *
311
+ * @param {RegExp} re
312
+ * @return {ClassList}
313
+ * @api private
314
+ */
315
+
316
+ ClassList.prototype.removeMatching = function(re){
317
+ var arr = this.array();
318
+ for (var i = 0; i < arr.length; i++) {
319
+ if (re.test(arr[i])) {
320
+ this.remove(arr[i]);
321
+ }
322
+ }
323
+ return this;
324
+ };
325
+
326
+ /**
327
+ * Toggle class `name`.
328
+ *
329
+ * @param {String} name
330
+ * @return {ClassList}
331
+ * @api public
332
+ */
333
+
334
+ ClassList.prototype.toggle = function(name){
335
+ // classList
336
+ if (this.list) {
337
+ this.list.toggle(name);
338
+ return this;
339
+ }
340
+
341
+ // fallback
342
+ if (this.has(name)) {
343
+ this.remove(name);
344
+ } else {
345
+ this.add(name);
346
+ }
347
+ return this;
348
+ };
349
+
350
+ /**
351
+ * Return an array of classes.
352
+ *
353
+ * @return {Array}
354
+ * @api public
355
+ */
356
+
357
+ ClassList.prototype.array = function(){
358
+ var str = this.el.className.replace(/^\s+|\s+$/g, '');
359
+ var arr = str.split(re);
360
+ if ('' === arr[0]) arr.shift();
361
+ return arr;
362
+ };
363
+
364
+ /**
365
+ * Check if class `name` is present.
366
+ *
367
+ * @param {String} name
368
+ * @return {ClassList}
369
+ * @api public
370
+ */
371
+
372
+ ClassList.prototype.has =
373
+ ClassList.prototype.contains = function(name){
374
+ return this.list
375
+ ? this.list.contains(name)
376
+ : !! ~index(this.array(), name);
377
+ };
378
+
379
+ });
380
+ require.register("segmentio-extend/index.js", function(exports, require, module){
381
+
382
+ module.exports = function extend (object) {
383
+ // Takes an unlimited number of extenders.
384
+ var args = Array.prototype.slice.call(arguments, 1);
385
+
386
+ // For each extender, copy their properties on our object.
387
+ for (var i = 0, source; source = args[i]; i++) {
388
+ if (!source) continue;
389
+ for (var property in source) {
390
+ object[property] = source[property];
391
+ }
392
+ }
393
+
394
+ return object;
395
+ };
396
+ });
397
+ require.register("component-event/index.js", function(exports, require, module){
398
+ var bind = (window.addEventListener !== undefined) ? 'addEventListener' : 'attachEvent',
399
+ unbind = (window.removeEventListener !== undefined) ? 'removeEventListener' : 'detachEvent',
400
+ prefix = (bind !== 'addEventListener') ? 'on' : '';
401
+
402
+ /**
403
+ * Bind `el` event `type` to `fn`.
404
+ *
405
+ * @param {Element} el
406
+ * @param {String} type
407
+ * @param {Function} fn
408
+ * @param {Boolean} capture
409
+ * @return {Function}
410
+ * @api public
411
+ */
412
+
413
+ exports.bind = function(el, type, fn, capture){
414
+ el[bind](prefix + type, fn, capture || false);
415
+
416
+ return fn;
417
+ };
418
+
419
+ /**
420
+ * Unbind `el` event `type`'s callback `fn`.
421
+ *
422
+ * @param {Element} el
423
+ * @param {String} type
424
+ * @param {Function} fn
425
+ * @param {Boolean} capture
426
+ * @return {Function}
427
+ * @api public
428
+ */
429
+
430
+ exports.unbind = function(el, type, fn, capture){
431
+ el[unbind](prefix + type, fn, capture || false);
432
+
433
+ return fn;
434
+ };
435
+ });
436
+ require.register("component-type/index.js", function(exports, require, module){
437
+
438
+ /**
439
+ * toString ref.
440
+ */
441
+
442
+ var toString = Object.prototype.toString;
443
+
444
+ /**
445
+ * Return the type of `val`.
446
+ *
447
+ * @param {Mixed} val
448
+ * @return {String}
449
+ * @api public
450
+ */
451
+
452
+ module.exports = function(val){
453
+ switch (toString.call(val)) {
454
+ case '[object Function]': return 'function';
455
+ case '[object Date]': return 'date';
456
+ case '[object RegExp]': return 'regexp';
457
+ case '[object Arguments]': return 'arguments';
458
+ case '[object Array]': return 'array';
459
+ case '[object String]': return 'string';
460
+ }
461
+
462
+ if (val === null) return 'null';
463
+ if (val === undefined) return 'undefined';
464
+ if (val && val.nodeType === 1) return 'element';
465
+ if (val === Object(val)) return 'object';
466
+
467
+ return typeof val;
468
+ };
469
+
470
+ });
471
+ require.register("timoxley-is-collection/index.js", function(exports, require, module){
472
+ var typeOf = require('type')
473
+
474
+ /**
475
+ * Evaluates _obj_ to determine if it's an array, an array-like collection, or
476
+ * something else. This is useful when working with the function `arguments`
477
+ * collection and `HTMLElement` collections.
478
+ * Note: This implementation doesn't consider elements that are also
479
+ *
480
+ *
481
+
482
+ collections, such as `<form>` and `<select>`, to be array-like.
483
+
484
+ @method test
485
+ @param {Object} obj Object to test.
486
+ @return {Number} A number indicating the results of the test:
487
+
488
+ * 0: Neither an array nor an array-like collection.
489
+ * 1: Real array.
490
+ * 2: Array-like collection.
491
+
492
+ @api private
493
+ **/
494
+ module.exports = function isCollection(obj) {
495
+ var type = typeOf(obj)
496
+ if (type === 'array') return 1
497
+ switch (type) {
498
+ case 'arguments': return 2
499
+ case 'object':
500
+ if (isNodeList(obj)) return 2
501
+ try {
502
+ // indexed, but no tagName (element) or scrollTo/document (window. From DOM.isWindow test which we can't use here),
503
+ // or functions without apply/call (Safari
504
+ // HTMLElementCollection bug).
505
+ if ('length' in obj
506
+ && !obj.tagName
507
+ && !(obj.scrollTo && obj.document)
508
+ && !obj.apply) {
509
+ return 2
510
+ }
511
+ } catch (ex) {}
512
+ default:
513
+ return 0
514
+ }
515
+ }
516
+
517
+ function isNodeList(nodes) {
518
+ return typeof nodes === 'object'
519
+ && /^\[object (NodeList)\]$/.test(Object.prototype.toString.call(nodes))
520
+ && nodes.hasOwnProperty('length')
521
+ && (nodes.length == 0 || (typeof nodes[0] === "object" && nodes[0].nodeType > 0))
522
+ }
523
+
524
+
525
+ });
526
+ require.register("javve-events/index.js", function(exports, require, module){
527
+ var events = require('event'),
528
+ isCollection = require('is-collection');
529
+
530
+ /**
531
+ * Bind `el` event `type` to `fn`.
532
+ *
533
+ * @param {Element} el, NodeList, HTMLCollection or Array
534
+ * @param {String} type
535
+ * @param {Function} fn
536
+ * @param {Boolean} capture
537
+ * @api public
538
+ */
539
+
540
+ exports.bind = function(el, type, fn, capture){
541
+ if (!isCollection(el)) {
542
+ events.bind(el, type, fn, capture);
543
+ } else if ( el && el[0] !== undefined ) {
544
+ for ( var i = 0; i < el.length; i++ ) {
545
+ events.bind(el[i], type, fn, capture);
546
+ }
547
+ }
548
+ };
549
+
550
+ /**
551
+ * Unbind `el` event `type`'s callback `fn`.
552
+ *
553
+ * @param {Element} el, NodeList, HTMLCollection or Array
554
+ * @param {String} type
555
+ * @param {Function} fn
556
+ * @param {Boolean} capture
557
+ * @api public
558
+ */
559
+
560
+ exports.unbind = function(el, type, fn, capture){
561
+ if (!isCollection(el)) {
562
+ events.unbind(el, type, fn, capture);
563
+ } else if ( el && el[0] !== undefined ) {
564
+ for ( var i = 0; i < el.length; i++ ) {
565
+ events.unbind(el[i], type, fn, capture);
566
+ }
567
+ }
568
+ };
569
+ });
570
+ require.register("javve-get-by-class/index.js", function(exports, require, module){
571
+ /**
572
+ * Find all elements with class `className` inside `container`.
573
+ * Use `single = true` to increase performance in older browsers
574
+ * when only one element is needed.
575
+ *
576
+ * @param {String} className
577
+ * @param {Element} container
578
+ * @param {Boolean} single
579
+ * @api public
580
+ */
581
+
582
+ module.exports = (function() {
583
+ if (document.getElementsByClassName) {
584
+ return function(container, className, single) {
585
+ if (single) {
586
+ return container.getElementsByClassName(className)[0];
587
+ } else {
588
+ return container.getElementsByClassName(className);
589
+ }
590
+ };
591
+ } else if (document.querySelector) {
592
+ return function(container, className, single) {
593
+ if (single) {
594
+ return container.querySelector(className);
595
+ } else {
596
+ return container.querySelectorAll(className);
597
+ }
598
+ };
599
+ } else {
600
+ return function(container, className, single) {
601
+ var classElements = [],
602
+ tag = '*';
603
+ if (container == null) {
604
+ container = document;
605
+ }
606
+ var els = container.getElementsByTagName(tag);
607
+ var elsLen = els.length;
608
+ var pattern = new RegExp("(^|\\s)"+className+"(\\s|$)");
609
+ for (var i = 0, j = 0; i < elsLen; i++) {
610
+ if ( pattern.test(els[i].className) ) {
611
+ if (single) {
612
+ return els[i];
613
+ } else {
614
+ classElements[j] = els[i];
615
+ j++;
616
+ }
617
+ }
618
+ }
619
+ return classElements;
620
+ };
621
+ }
622
+ })();
623
+
624
+ });
625
+ require.register("javve-to-string/index.js", function(exports, require, module){
626
+ module.exports = function(s) {
627
+ s = (s === undefined) ? "" : s;
628
+ s = (s === null) ? "" : s;
629
+ s = s.toString();
630
+ return s;
631
+ };
632
+
633
+ });
634
+ require.register("list.fuzzysearch.js/index.js", function(exports, require, module){
635
+ var classes = require('classes'),
636
+ events = require('events'),
637
+ extend = require('extend'),
638
+ toString = require('to-string'),
639
+ getByClass = require('get-by-class');
640
+
641
+ module.exports = function(options) {
642
+ options = options || {};
643
+
644
+ extend(options, {
645
+ location: 0,
646
+ distance: 100,
647
+ threshold: 0.4,
648
+ multiSearch: true,
649
+ searchClass: 'fuzzy-search'
650
+ });
651
+
652
+ var fuzzy = require('./src/fuzzy'),
653
+ list;
654
+
655
+ var fuzzySearch = {
656
+ search: function(searchString, columns) {
657
+ // Substract arguments from the searchString or put searchString as only argument
658
+ var searchArguments = options.multiSearch ? searchString.replace(/ +$/, '').split(/ +/) : [searchString];
659
+
660
+ for (var k = 0, kl = list.items.length; k < kl; k++) {
661
+ fuzzySearch.item(list.items[k], columns, searchArguments);
662
+ }
663
+ },
664
+ item: function(item, columns, searchArguments) {
665
+ var found = true;
666
+ for(var i = 0; i < searchArguments.length; i++) {
667
+ var foundArgument = false;
668
+ for (var j = 0, jl = columns.length; j < jl; j++) {
669
+ if (fuzzySearch.values(item.values(), columns[j], searchArguments[i])) {
670
+ foundArgument = true;
671
+ }
672
+ }
673
+ if(!foundArgument) {
674
+ found = false;
675
+ }
676
+ }
677
+ item.found = found;
678
+ },
679
+ values: function(values, value, searchArgument) {
680
+ if (values.hasOwnProperty(value)) {
681
+ var text = toString(values[value]).toLowerCase();
682
+
683
+ if (fuzzy(text, searchArgument, options)) {
684
+ return true;
685
+ }
686
+ }
687
+ return false;
688
+ }
689
+ };
690
+
691
+ return {
692
+ init: function(parentList) {
693
+ list = parentList;
694
+
695
+ events.bind(getByClass(list.listContainer, options.searchClass), 'keyup', function(e) {
696
+ var target = e.target || e.srcElement; // IE have srcElement
697
+ list.search(target.value, fuzzySearch.search);
698
+ });
699
+
700
+ return;
701
+ },
702
+ search: function(str, columns) {
703
+ list.search(str, columns, fuzzySearch.search);
704
+ },
705
+ name: options.name || "fuzzySearch"
706
+ };
707
+ };
708
+
709
+ });
710
+ require.register("list.fuzzysearch.js/src/fuzzy.js", function(exports, require, module){
711
+ module.exports = function(text, pattern, options) {
712
+ // Aproximately where in the text is the pattern expected to be found?
713
+ var Match_Location = options.location || 0;
714
+
715
+ //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.
716
+ var Match_Distance = options.distance || 100;
717
+
718
+ // 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.
719
+ var Match_Threshold = options.threshold || 0.4;
720
+
721
+ if (pattern === text) return true; // Exact match
722
+ if (pattern.length > 32) return false; // This algorithm cannot be used
723
+
724
+ // Set starting location at beginning text and initialise the alphabet.
725
+ var loc = Match_Location,
726
+ s = (function() {
727
+ var q = {},
728
+ i;
729
+
730
+ for (i = 0; i < pattern.length; i++) {
731
+ q[pattern.charAt(i)] = 0;
732
+ }
733
+
734
+ for (i = 0; i < pattern.length; i++) {
735
+ q[pattern.charAt(i)] |= 1 << (pattern.length - i - 1);
736
+ }
737
+
738
+ return q;
739
+ }());
740
+
741
+ // Compute and return the score for a match with e errors and x location.
742
+ // Accesses loc and pattern through being a closure.
743
+
744
+ function match_bitapScore_(e, x) {
745
+ var accuracy = e / pattern.length,
746
+ proximity = Math.abs(loc - x);
747
+
748
+ if (!Match_Distance) {
749
+ // Dodge divide by zero error.
750
+ return proximity ? 1.0 : accuracy;
751
+ }
752
+ return accuracy + (proximity / Match_Distance);
753
+ }
754
+
755
+ var score_threshold = Match_Threshold, // Highest score beyond which we give up.
756
+ best_loc = text.indexOf(pattern, loc); // Is there a nearby exact match? (speedup)
757
+
758
+ if (best_loc != -1) {
759
+ score_threshold = Math.min(match_bitapScore_(0, best_loc), score_threshold);
760
+ // What about in the other direction? (speedup)
761
+ best_loc = text.lastIndexOf(pattern, loc + pattern.length);
762
+
763
+ if (best_loc != -1) {
764
+ score_threshold = Math.min(match_bitapScore_(0, best_loc), score_threshold);
765
+ }
766
+ }
767
+
768
+ // Initialise the bit arrays.
769
+ var matchmask = 1 << (pattern.length - 1);
770
+ best_loc = -1;
771
+
772
+ var bin_min, bin_mid;
773
+ var bin_max = pattern.length + text.length;
774
+ var last_rd;
775
+ for (var d = 0; d < pattern.length; d++) {
776
+ // Scan for the best match; each iteration allows for one more error.
777
+ // Run a binary search to determine how far from 'loc' we can stray at this
778
+ // error level.
779
+ bin_min = 0;
780
+ bin_mid = bin_max;
781
+ while (bin_min < bin_mid) {
782
+ if (match_bitapScore_(d, loc + bin_mid) <= score_threshold) {
783
+ bin_min = bin_mid;
784
+ } else {
785
+ bin_max = bin_mid;
786
+ }
787
+ bin_mid = Math.floor((bin_max - bin_min) / 2 + bin_min);
788
+ }
789
+ // Use the result from this iteration as the maximum for the next.
790
+ bin_max = bin_mid;
791
+ var start = Math.max(1, loc - bin_mid + 1);
792
+ var finish = Math.min(loc + bin_mid, text.length) + pattern.length;
793
+
794
+ var rd = Array(finish + 2);
795
+ rd[finish + 1] = (1 << d) - 1;
796
+ for (var j = finish; j >= start; j--) {
797
+ // The alphabet (s) is a sparse hash, so the following line generates
798
+ // warnings.
799
+ var charMatch = s[text.charAt(j - 1)];
800
+ if (d === 0) { // First pass: exact match.
801
+ rd[j] = ((rd[j + 1] << 1) | 1) & charMatch;
802
+ } else { // Subsequent passes: fuzzy match.
803
+ rd[j] = (((rd[j + 1] << 1) | 1) & charMatch) |
804
+ (((last_rd[j + 1] | last_rd[j]) << 1) | 1) |
805
+ last_rd[j + 1];
806
+ }
807
+ if (rd[j] & matchmask) {
808
+ var score = match_bitapScore_(d, j - 1);
809
+ // This match will almost certainly be better than any existing match.
810
+ // But check anyway.
811
+ if (score <= score_threshold) {
812
+ // Told you so.
813
+ score_threshold = score;
814
+ best_loc = j - 1;
815
+ if (best_loc > loc) {
816
+ // When passing loc, don't exceed our current distance from loc.
817
+ start = Math.max(1, 2 * loc - best_loc);
818
+ } else {
819
+ // Already passed loc, downhill from here on in.
820
+ break;
821
+ }
822
+ }
823
+ }
824
+ }
825
+ // No hope for a (better) match at greater error levels.
826
+ if (match_bitapScore_(d + 1, loc) > score_threshold) {
827
+ break;
828
+ }
829
+ last_rd = rd;
830
+ }
831
+
832
+ return (best_loc < 0) ? false : true;
833
+ };
834
+
835
+ });
836
+
837
+
838
+
839
+
840
+
841
+
842
+ require.alias("component-classes/index.js", "list.fuzzysearch.js/deps/classes/index.js");
843
+ require.alias("component-classes/index.js", "classes/index.js");
844
+ require.alias("component-indexof/index.js", "component-classes/deps/indexof/index.js");
845
+
846
+ require.alias("segmentio-extend/index.js", "list.fuzzysearch.js/deps/extend/index.js");
847
+ require.alias("segmentio-extend/index.js", "extend/index.js");
848
+
849
+ require.alias("javve-events/index.js", "list.fuzzysearch.js/deps/events/index.js");
850
+ require.alias("javve-events/index.js", "events/index.js");
851
+ require.alias("component-event/index.js", "javve-events/deps/event/index.js");
852
+
853
+ require.alias("timoxley-is-collection/index.js", "javve-events/deps/is-collection/index.js");
854
+ require.alias("component-type/index.js", "timoxley-is-collection/deps/type/index.js");
855
+
856
+ require.alias("javve-get-by-class/index.js", "list.fuzzysearch.js/deps/get-by-class/index.js");
857
+ require.alias("javve-get-by-class/index.js", "get-by-class/index.js");
858
+
859
+ require.alias("javve-to-string/index.js", "list.fuzzysearch.js/deps/to-string/index.js");
860
+ require.alias("javve-to-string/index.js", "list.fuzzysearch.js/deps/to-string/index.js");
861
+ require.alias("javve-to-string/index.js", "to-string/index.js");
862
+ require.alias("javve-to-string/index.js", "javve-to-string/index.js");
863
+ require.alias("list.fuzzysearch.js/index.js", "list.fuzzysearch.js/index.js");if (typeof exports == "object") {
864
+ module.exports = require("list.fuzzysearch.js");
865
+ } else if (typeof define == "function" && define.amd) {
866
+ define(function(){ return require("list.fuzzysearch.js"); });
867
+ } else {
868
+ this["ListFuzzySearch"] = require("list.fuzzysearch.js");
869
+ }})();