blazer 1.2.1 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of blazer might be problematic. Click here for more details.

@@ -1,211 +1,825 @@
1
- ;(function(){
1
+ (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
2
+ /*
3
+ List.js 1.1.1
4
+ By Jonny Strömberg (www.jonnystromberg.com, www.listjs.com)
5
+ */
6
+ (function( window, undefined ) {
7
+ "use strict";
2
8
 
3
- /**
4
- * Require the given path.
5
- *
6
- * @param {String} path
7
- * @return {Object} exports
8
- * @api public
9
- */
9
+ var document = window.document,
10
+ getByClass = require('./src/utils/get-by-class'),
11
+ extend = require('./src/utils/extend'),
12
+ indexOf = require('./src/utils/index-of'),
13
+ events = require('./src/utils/events'),
14
+ toString = require('./src/utils/to-string'),
15
+ naturalSort = require('./src/utils/natural-sort'),
16
+ classes = require('./src/utils/classes'),
17
+ getAttribute = require('./src/utils/get-attribute'),
18
+ toArray = require('./src/utils/to-array');
10
19
 
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
- }
20
+ var List = function(id, options, values) {
24
21
 
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
- }
22
+ var self = this,
23
+ init,
24
+ Item = require('./src/item')(self),
25
+ addAsync = require('./src/add-async')(self);
26
+
27
+ init = {
28
+ start: function() {
29
+ self.listClass = "list";
30
+ self.searchClass = "search";
31
+ self.sortClass = "sort";
32
+ self.page = 10000;
33
+ self.i = 1;
34
+ self.items = [];
35
+ self.visibleItems = [];
36
+ self.matchingItems = [];
37
+ self.searched = false;
38
+ self.filtered = false;
39
+ self.searchColumns = undefined;
40
+ self.handlers = { 'updated': [] };
41
+ self.plugins = {};
42
+ self.valueNames = [];
43
+ self.utils = {
44
+ getByClass: getByClass,
45
+ extend: extend,
46
+ indexOf: indexOf,
47
+ events: events,
48
+ toString: toString,
49
+ naturalSort: naturalSort,
50
+ classes: classes,
51
+ getAttribute: getAttribute,
52
+ toArray: toArray
53
+ };
54
+
55
+ self.utils.extend(self, options);
56
+
57
+ self.listContainer = (typeof(id) === 'string') ? document.getElementById(id) : id;
58
+ if (!self.listContainer) { return; }
59
+ self.list = getByClass(self.listContainer, self.listClass, true);
60
+
61
+ self.parse = require('./src/parse')(self);
62
+ self.templater = require('./src/templater')(self);
63
+ self.search = require('./src/search')(self);
64
+ self.filter = require('./src/filter')(self);
65
+ self.sort = require('./src/sort')(self);
66
+
67
+ this.handlers();
68
+ this.items();
69
+ self.update();
70
+ this.plugins();
71
+ },
72
+ handlers: function() {
73
+ for (var handler in self.handlers) {
74
+ if (self[handler]) {
75
+ self.on(handler, self[handler]);
76
+ }
77
+ }
78
+ },
79
+ items: function() {
80
+ self.parse(self.list);
81
+ if (values !== undefined) {
82
+ self.add(values);
83
+ }
84
+ },
85
+ plugins: function() {
86
+ for (var i = 0; i < self.plugins.length; i++) {
87
+ var plugin = self.plugins[i];
88
+ self[plugin.name] = plugin;
89
+ plugin.init(self, List);
90
+ }
91
+ }
92
+ };
39
93
 
40
- return module.exports;
41
- }
94
+ /*
95
+ * Re-parse the List, use if html have changed
96
+ */
97
+ this.reIndex = function() {
98
+ self.items = [];
99
+ self.visibleItems = [];
100
+ self.matchingItems = [];
101
+ self.searched = false;
102
+ self.filtered = false;
103
+ self.parse(self.list);
104
+ };
42
105
 
43
- /**
44
- * Registered modules.
45
- */
106
+ this.toJSON = function() {
107
+ var json = [];
108
+ for (var i = 0, il = self.items.length; i < il; i++) {
109
+ json.push(self.items[i].values());
110
+ }
111
+ return json;
112
+ };
46
113
 
47
- require.modules = {};
48
114
 
49
- /**
50
- * Registered aliases.
51
- */
115
+ /*
116
+ * Add object to list
117
+ */
118
+ this.add = function(values, callback) {
119
+ if (values.length === 0) {
120
+ return;
121
+ }
122
+ if (callback) {
123
+ addAsync(values, callback);
124
+ return;
125
+ }
126
+ var added = [],
127
+ notCreate = false;
128
+ if (values[0] === undefined){
129
+ values = [values];
130
+ }
131
+ for (var i = 0, il = values.length; i < il; i++) {
132
+ var item = null;
133
+ notCreate = (self.items.length > self.page) ? true : false;
134
+ item = new Item(values[i], undefined, notCreate);
135
+ self.items.push(item);
136
+ added.push(item);
137
+ }
138
+ self.update();
139
+ return added;
140
+ };
52
141
 
53
- require.aliases = {};
142
+ this.show = function(i, page) {
143
+ this.i = i;
144
+ this.page = page;
145
+ self.update();
146
+ return self;
147
+ };
54
148
 
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
- */
149
+ /* Removes object from list.
150
+ * Loops through the list and removes objects where
151
+ * property "valuename" === value
152
+ */
153
+ this.remove = function(valueName, value, options) {
154
+ var found = 0;
155
+ for (var i = 0, il = self.items.length; i < il; i++) {
156
+ if (self.items[i].values()[valueName] == value) {
157
+ self.templater.remove(self.items[i], options);
158
+ self.items.splice(i,1);
159
+ il--;
160
+ i--;
161
+ found++;
162
+ }
163
+ }
164
+ self.update();
165
+ return found;
166
+ };
68
167
 
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
- }
168
+ /* Gets the objects in the list which
169
+ * property "valueName" === value
170
+ */
171
+ this.get = function(valueName, value) {
172
+ var matchedItems = [];
173
+ for (var i = 0, il = self.items.length; i < il; i++) {
174
+ var item = self.items[i];
175
+ if (item.values()[valueName] == value) {
176
+ matchedItems.push(item);
177
+ }
178
+ }
179
+ return matchedItems;
180
+ };
181
+
182
+ /*
183
+ * Get size of the list
184
+ */
185
+ this.size = function() {
186
+ return self.items.length;
187
+ };
188
+
189
+ /*
190
+ * Removes all items from the list
191
+ */
192
+ this.clear = function() {
193
+ self.templater.clear();
194
+ self.items = [];
195
+ return self;
196
+ };
197
+
198
+ this.on = function(event, callback) {
199
+ self.handlers[event].push(callback);
200
+ return self;
201
+ };
202
+
203
+ this.off = function(event, callback) {
204
+ var e = self.handlers[event];
205
+ var index = indexOf(e, callback);
206
+ if (index > -1) {
207
+ e.splice(index, 1);
208
+ }
209
+ return self;
210
+ };
211
+
212
+ this.trigger = function(event) {
213
+ var i = self.handlers[event].length;
214
+ while(i--) {
215
+ self.handlers[event][i](self);
216
+ }
217
+ return self;
218
+ };
219
+
220
+ this.reset = {
221
+ filter: function() {
222
+ var is = self.items,
223
+ il = is.length;
224
+ while (il--) {
225
+ is[il].filtered = false;
226
+ }
227
+ return self;
228
+ },
229
+ search: function() {
230
+ var is = self.items,
231
+ il = is.length;
232
+ while (il--) {
233
+ is[il].found = false;
234
+ }
235
+ return self;
236
+ }
237
+ };
238
+
239
+ this.update = function() {
240
+ var is = self.items,
241
+ il = is.length;
242
+
243
+ self.visibleItems = [];
244
+ self.matchingItems = [];
245
+ self.templater.clear();
246
+ for (var i = 0; i < il; i++) {
247
+ if (is[i].matching() && ((self.matchingItems.length+1) >= self.i && self.visibleItems.length < self.page)) {
248
+ is[i].show();
249
+ self.visibleItems.push(is[i]);
250
+ self.matchingItems.push(is[i]);
251
+ } else if (is[i].matching()) {
252
+ self.matchingItems.push(is[i]);
253
+ is[i].hide();
254
+ } else {
255
+ is[i].hide();
256
+ }
257
+ }
258
+ self.trigger('updated');
259
+ return self;
260
+ };
261
+
262
+ init.start();
85
263
  };
86
264
 
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
265
 
96
- require.normalize = function(curr, path) {
97
- var segs = [];
266
+ // AMD support
267
+ if (typeof define === 'function' && define.amd) {
268
+ define(function () { return List; });
269
+ }
270
+ module.exports = List;
271
+ window.List = List;
272
+
273
+ })(window);
274
+
275
+ },{"./src/add-async":2,"./src/filter":3,"./src/item":4,"./src/parse":5,"./src/search":6,"./src/sort":7,"./src/templater":8,"./src/utils/classes":9,"./src/utils/events":10,"./src/utils/extend":11,"./src/utils/get-attribute":12,"./src/utils/get-by-class":13,"./src/utils/index-of":14,"./src/utils/natural-sort":15,"./src/utils/to-array":16,"./src/utils/to-string":17}],2:[function(require,module,exports){
276
+ module.exports = function(list) {
277
+ var addAsync = function(values, callback, items) {
278
+ var valuesToAdd = values.splice(0, 50);
279
+ items = items || [];
280
+ items = items.concat(list.add(valuesToAdd));
281
+ if (values.length > 0) {
282
+ setTimeout(function() {
283
+ addAsync(values, callback, items);
284
+ }, 1);
285
+ } else {
286
+ list.update();
287
+ callback(items);
288
+ }
289
+ };
290
+ return addAsync;
291
+ };
98
292
 
99
- if ('.' != path.charAt(0)) return path;
293
+ },{}],3:[function(require,module,exports){
294
+ module.exports = function(list) {
100
295
 
101
- curr = curr.split('/');
102
- path = path.split('/');
296
+ // Add handlers
297
+ list.handlers.filterStart = list.handlers.filterStart || [];
298
+ list.handlers.filterComplete = list.handlers.filterComplete || [];
103
299
 
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]);
300
+ return function(filterFunction) {
301
+ list.trigger('filterStart');
302
+ list.i = 1; // Reset paging
303
+ list.reset.filter();
304
+ if (filterFunction === undefined) {
305
+ list.filtered = false;
306
+ } else {
307
+ list.filtered = true;
308
+ var is = list.items;
309
+ for (var i = 0, il = is.length; i < il; i++) {
310
+ var item = is[i];
311
+ if (filterFunction(item)) {
312
+ item.filtered = true;
313
+ } else {
314
+ item.filtered = false;
315
+ }
316
+ }
109
317
  }
110
- }
318
+ list.update();
319
+ list.trigger('filterComplete');
320
+ return list.visibleItems;
321
+ };
322
+ };
323
+
324
+ },{}],4:[function(require,module,exports){
325
+ module.exports = function(list) {
326
+ return function(initValues, element, notCreate) {
327
+ var item = this;
328
+
329
+ this._values = {};
330
+
331
+ this.found = false; // Show if list.searched == true and this.found == true
332
+ this.filtered = false;// Show if list.filtered == true and this.filtered == true
333
+
334
+ var init = function(initValues, element, notCreate) {
335
+ if (element === undefined) {
336
+ if (notCreate) {
337
+ item.values(initValues, notCreate);
338
+ } else {
339
+ item.values(initValues);
340
+ }
341
+ } else {
342
+ item.elm = element;
343
+ var values = list.templater.get(item, initValues);
344
+ item.values(values);
345
+ }
346
+ };
347
+
348
+ this.values = function(newValues, notCreate) {
349
+ if (newValues !== undefined) {
350
+ for(var name in newValues) {
351
+ item._values[name] = newValues[name];
352
+ }
353
+ if (notCreate !== true) {
354
+ list.templater.set(item, item.values());
355
+ }
356
+ } else {
357
+ return item._values;
358
+ }
359
+ };
360
+
361
+ this.show = function() {
362
+ list.templater.show(item);
363
+ };
364
+
365
+ this.hide = function() {
366
+ list.templater.hide(item);
367
+ };
368
+
369
+ this.matching = function() {
370
+ return (
371
+ (list.filtered && list.searched && item.found && item.filtered) ||
372
+ (list.filtered && !list.searched && item.filtered) ||
373
+ (!list.filtered && list.searched && item.found) ||
374
+ (!list.filtered && !list.searched)
375
+ );
376
+ };
377
+
378
+ this.visible = function() {
379
+ return (item.elm && (item.elm.parentNode == list.list)) ? true : false;
380
+ };
111
381
 
112
- return curr.concat(segs).join('/');
382
+ init(initValues, element, notCreate);
383
+ };
113
384
  };
114
385
 
115
- /**
116
- * Register module at `path` with callback `definition`.
117
- *
118
- * @param {String} path
119
- * @param {Function} definition
120
- * @api private
121
- */
386
+ },{}],5:[function(require,module,exports){
387
+ module.exports = function(list) {
388
+
389
+ var Item = require('./item')(list);
390
+
391
+ var getChildren = function(parent) {
392
+ var nodes = parent.childNodes,
393
+ items = [];
394
+ for (var i = 0, il = nodes.length; i < il; i++) {
395
+ // Only textnodes have a data attribute
396
+ if (nodes[i].data === undefined) {
397
+ items.push(nodes[i]);
398
+ }
399
+ }
400
+ return items;
401
+ };
402
+
403
+ var parse = function(itemElements, valueNames) {
404
+ for (var i = 0, il = itemElements.length; i < il; i++) {
405
+ list.items.push(new Item(valueNames, itemElements[i]));
406
+ }
407
+ };
408
+ var parseAsync = function(itemElements, valueNames) {
409
+ var itemsToIndex = itemElements.splice(0, 50); // TODO: If < 100 items, what happens in IE etc?
410
+ parse(itemsToIndex, valueNames);
411
+ if (itemElements.length > 0) {
412
+ setTimeout(function() {
413
+ parseAsync(itemElements, valueNames);
414
+ }, 1);
415
+ } else {
416
+ list.update();
417
+ list.trigger('parseComplete');
418
+ }
419
+ };
420
+
421
+ list.handlers.parseComplete = list.handlers.parseComplete || [];
422
+
423
+ return function() {
424
+ var itemsToIndex = getChildren(list.list),
425
+ valueNames = list.valueNames;
122
426
 
123
- require.register = function(path, definition) {
124
- require.modules[path] = definition;
427
+ if (list.indexAsync) {
428
+ parseAsync(itemsToIndex, valueNames);
429
+ } else {
430
+ parse(itemsToIndex, valueNames);
431
+ }
432
+ };
125
433
  };
126
434
 
127
- /**
128
- * Alias a module definition.
129
- *
130
- * @param {String} from
131
- * @param {String} to
132
- * @api private
133
- */
435
+ },{"./item":4}],6:[function(require,module,exports){
436
+ module.exports = function(list) {
437
+ var item,
438
+ text,
439
+ columns,
440
+ searchString,
441
+ customSearch;
442
+
443
+ var prepare = {
444
+ resetList: function() {
445
+ list.i = 1;
446
+ list.templater.clear();
447
+ customSearch = undefined;
448
+ },
449
+ setOptions: function(args) {
450
+ if (args.length == 2 && args[1] instanceof Array) {
451
+ columns = args[1];
452
+ } else if (args.length == 2 && typeof(args[1]) == "function") {
453
+ customSearch = args[1];
454
+ } else if (args.length == 3) {
455
+ columns = args[1];
456
+ customSearch = args[2];
457
+ }
458
+ },
459
+ setColumns: function() {
460
+ if (list.items.length === 0) return;
461
+ if (columns === undefined) {
462
+ columns = (list.searchColumns === undefined) ? prepare.toArray(list.items[0].values()) : list.searchColumns;
463
+ }
464
+ },
465
+ setSearchString: function(s) {
466
+ s = list.utils.toString(s).toLowerCase();
467
+ s = s.replace(/[-[\]{}()*+?.,\\^$|#]/g, "\\$&"); // Escape regular expression characters
468
+ searchString = s;
469
+ },
470
+ toArray: function(values) {
471
+ var tmpColumn = [];
472
+ for (var name in values) {
473
+ tmpColumn.push(name);
474
+ }
475
+ return tmpColumn;
476
+ }
477
+ };
478
+ var search = {
479
+ list: function() {
480
+ for (var k = 0, kl = list.items.length; k < kl; k++) {
481
+ search.item(list.items[k]);
482
+ }
483
+ },
484
+ item: function(item) {
485
+ item.found = false;
486
+ for (var j = 0, jl = columns.length; j < jl; j++) {
487
+ if (search.values(item.values(), columns[j])) {
488
+ item.found = true;
489
+ return;
490
+ }
491
+ }
492
+ },
493
+ values: function(values, column) {
494
+ if (values.hasOwnProperty(column)) {
495
+ text = list.utils.toString(values[column]).toLowerCase();
496
+ if ((searchString !== "") && (text.search(searchString) > -1)) {
497
+ return true;
498
+ }
499
+ }
500
+ return false;
501
+ },
502
+ reset: function() {
503
+ list.reset.search();
504
+ list.searched = false;
505
+ }
506
+ };
134
507
 
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;
508
+ var searchMethod = function(str) {
509
+ list.trigger('searchStart');
510
+
511
+ prepare.resetList();
512
+ prepare.setSearchString(str);
513
+ prepare.setOptions(arguments); // str, cols|searchFunction, searchFunction
514
+ prepare.setColumns();
515
+
516
+ if (searchString === "" ) {
517
+ search.reset();
518
+ } else {
519
+ list.searched = true;
520
+ if (customSearch) {
521
+ customSearch(searchString, columns);
522
+ } else {
523
+ search.list();
524
+ }
525
+ }
526
+
527
+ list.update();
528
+ list.trigger('searchComplete');
529
+ return list.visibleItems;
530
+ };
531
+
532
+ list.handlers.searchStart = list.handlers.searchStart || [];
533
+ list.handlers.searchComplete = list.handlers.searchComplete || [];
534
+
535
+ list.utils.events.bind(list.utils.getByClass(list.listContainer, list.searchClass), 'keyup', function(e) {
536
+ var target = e.target || e.srcElement, // IE have srcElement
537
+ alreadyCleared = (target.value === "" && !list.searched);
538
+ if (!alreadyCleared) { // If oninput already have resetted the list, do nothing
539
+ searchMethod(target.value);
540
+ }
541
+ });
542
+
543
+ // Used to detect click on HTML5 clear button
544
+ list.utils.events.bind(list.utils.getByClass(list.listContainer, list.searchClass), 'input', function(e) {
545
+ var target = e.target || e.srcElement;
546
+ if (target.value === "") {
547
+ searchMethod('');
548
+ }
549
+ });
550
+
551
+ return searchMethod;
140
552
  };
141
553
 
142
- /**
143
- * Return a require function relative to the `parent` path.
144
- *
145
- * @param {String} parent
146
- * @return {Function}
147
- * @api private
148
- */
554
+ },{}],7:[function(require,module,exports){
555
+ module.exports = function(list) {
556
+ list.sortFunction = list.sortFunction || function(itemA, itemB, options) {
557
+ options.desc = options.order == "desc" ? true : false; // Natural sort uses this format
558
+ return list.utils.naturalSort(itemA.values()[options.valueName], itemB.values()[options.valueName], options);
559
+ };
560
+
561
+ var buttons = {
562
+ els: undefined,
563
+ clear: function() {
564
+ for (var i = 0, il = buttons.els.length; i < il; i++) {
565
+ list.utils.classes(buttons.els[i]).remove('asc');
566
+ list.utils.classes(buttons.els[i]).remove('desc');
567
+ }
568
+ },
569
+ getOrder: function(btn) {
570
+ var predefinedOrder = list.utils.getAttribute(btn, 'data-order');
571
+ if (predefinedOrder == "asc" || predefinedOrder == "desc") {
572
+ return predefinedOrder;
573
+ } else if (list.utils.classes(btn).has('desc')) {
574
+ return "asc";
575
+ } else if (list.utils.classes(btn).has('asc')) {
576
+ return "desc";
577
+ } else {
578
+ return "asc";
579
+ }
580
+ },
581
+ getInSensitive: function(btn, options) {
582
+ var insensitive = list.utils.getAttribute(btn, 'data-insensitive');
583
+ if (insensitive === "false") {
584
+ options.insensitive = false;
585
+ } else {
586
+ options.insensitive = true;
587
+ }
588
+ },
589
+ setOrder: function(options) {
590
+ for (var i = 0, il = buttons.els.length; i < il; i++) {
591
+ var btn = buttons.els[i];
592
+ if (list.utils.getAttribute(btn, 'data-sort') !== options.valueName) {
593
+ continue;
594
+ }
595
+ var predefinedOrder = list.utils.getAttribute(btn, 'data-order');
596
+ if (predefinedOrder == "asc" || predefinedOrder == "desc") {
597
+ if (predefinedOrder == options.order) {
598
+ list.utils.classes(btn).add(options.order);
599
+ }
600
+ } else {
601
+ list.utils.classes(btn).add(options.order);
602
+ }
603
+ }
604
+ }
605
+ };
606
+ var sort = function() {
607
+ list.trigger('sortStart');
608
+ var options = {};
609
+
610
+ var target = arguments[0].currentTarget || arguments[0].srcElement || undefined;
611
+
612
+ if (target) {
613
+ options.valueName = list.utils.getAttribute(target, 'data-sort');
614
+ buttons.getInSensitive(target, options);
615
+ options.order = buttons.getOrder(target);
616
+ } else {
617
+ options = arguments[1] || options;
618
+ options.valueName = arguments[0];
619
+ options.order = options.order || "asc";
620
+ options.insensitive = (typeof options.insensitive == "undefined") ? true : options.insensitive;
621
+ }
622
+ buttons.clear();
623
+ buttons.setOrder(options);
624
+
625
+ options.sortFunction = options.sortFunction || list.sortFunction;
626
+ list.items.sort(function(a, b) {
627
+ var mult = (options.order === 'desc') ? -1 : 1;
628
+ return (options.sortFunction(a, b, options) * mult);
629
+ });
630
+ list.update();
631
+ list.trigger('sortComplete');
632
+ };
633
+
634
+ // Add handlers
635
+ list.handlers.sortStart = list.handlers.sortStart || [];
636
+ list.handlers.sortComplete = list.handlers.sortComplete || [];
637
+
638
+ buttons.els = list.utils.getByClass(list.listContainer, list.sortClass);
639
+ list.utils.events.bind(buttons.els, 'click', sort);
640
+ list.on('searchStart', buttons.clear);
641
+ list.on('filterStart', buttons.clear);
642
+
643
+ return sort;
644
+ };
149
645
 
150
- require.relative = function(parent) {
151
- var p = require.normalize(parent, '..');
646
+ },{}],8:[function(require,module,exports){
647
+ var Templater = function(list) {
648
+ var itemSource,
649
+ templater = this;
152
650
 
153
- /**
154
- * lastIndexOf helper.
155
- */
651
+ var init = function() {
652
+ itemSource = templater.getItemSource(list.item);
653
+ itemSource = templater.clearSourceItem(itemSource, list.valueNames);
654
+ };
156
655
 
157
- function lastIndexOf(arr, obj) {
158
- var i = arr.length;
159
- while (i--) {
160
- if (arr[i] === obj) return i;
656
+ this.clearSourceItem = function(el, valueNames) {
657
+ for(var i = 0, il = valueNames.length; i < il; i++) {
658
+ var elm;
659
+ if (valueNames[i].data) {
660
+ for (var j = 0, jl = valueNames[i].data.length; j < jl; j++) {
661
+ el.setAttribute('data-'+valueNames[i].data[j], '');
662
+ }
663
+ } else if (valueNames[i].attr && valueNames[i].name) {
664
+ elm = list.utils.getByClass(el, valueNames[i].name, true);
665
+ if (elm) {
666
+ elm.setAttribute(valueNames[i].attr, "");
667
+ }
668
+ } else {
669
+ elm = list.utils.getByClass(el, valueNames[i], true);
670
+ if (elm) {
671
+ elm.innerHTML = "";
672
+ }
673
+ }
674
+ elm = undefined;
161
675
  }
162
- return -1;
163
- }
676
+ return el;
677
+ };
164
678
 
165
- /**
166
- * The relative require() itself.
167
- */
679
+ this.getItemSource = function(item) {
680
+ if (item === undefined) {
681
+ var nodes = list.list.childNodes,
682
+ items = [];
168
683
 
169
- function localRequire(path) {
170
- var resolved = localRequire.resolve(path);
171
- return require(resolved, parent, path);
172
- }
684
+ for (var i = 0, il = nodes.length; i < il; i++) {
685
+ // Only textnodes have a data attribute
686
+ if (nodes[i].data === undefined) {
687
+ return nodes[i].cloneNode(true);
688
+ }
689
+ }
690
+ } else if (/^tr[\s>]/.exec(item)) {
691
+ var table = document.createElement('table');
692
+ table.innerHTML = item;
693
+ return table.firstChild;
694
+ } else if (item.indexOf("<") !== -1) {
695
+ var div = document.createElement('div');
696
+ div.innerHTML = item;
697
+ return div.firstChild;
698
+ } else {
699
+ var source = document.getElementById(list.item);
700
+ if (source) {
701
+ return source;
702
+ }
703
+ }
704
+ throw new Error("The list need to have at list one item on init otherwise you'll have to add a template.");
705
+ };
173
706
 
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;
707
+ this.get = function(item, valueNames) {
708
+ templater.create(item);
709
+ var values = {};
710
+ for(var i = 0, il = valueNames.length; i < il; i++) {
711
+ var elm;
712
+ if (valueNames[i].data) {
713
+ for (var j = 0, jl = valueNames[i].data.length; j < jl; j++) {
714
+ values[valueNames[i].data[j]] = list.utils.getAttribute(item.elm, 'data-'+valueNames[i].data[j]);
715
+ }
716
+ } else if (valueNames[i].attr && valueNames[i].name) {
717
+ elm = list.utils.getByClass(item.elm, valueNames[i].name, true);
718
+ values[valueNames[i].name] = elm ? list.utils.getAttribute(elm, valueNames[i].attr) : "";
719
+ } else {
720
+ elm = list.utils.getByClass(item.elm, valueNames[i], true);
721
+ values[valueNames[i]] = elm ? elm.innerHTML : "";
722
+ }
723
+ elm = undefined;
724
+ }
725
+ return values;
191
726
  };
192
727
 
193
- /**
194
- * Check if module is defined at `path`.
195
- */
728
+ this.set = function(item, values) {
729
+ var getValueName = function(name) {
730
+ for (var i = 0, il = list.valueNames.length; i < il; i++) {
731
+ if (list.valueNames[i].data) {
732
+ var data = list.valueNames[i].data;
733
+ for (var j = 0, jl = data.length; j < jl; j++) {
734
+ if (data[j] === name) {
735
+ return { data: name };
736
+ }
737
+ }
738
+ } else if (list.valueNames[i].attr && list.valueNames[i].name && list.valueNames[i].name == name) {
739
+ return list.valueNames[i];
740
+ } else if (list.valueNames[i] === name) {
741
+ return name;
742
+ }
743
+ }
744
+ };
745
+ var setValue = function(name, value) {
746
+ var elm;
747
+ var valueName = getValueName(name);
748
+ if (!valueName)
749
+ return;
750
+ if (valueName.data) {
751
+ item.elm.setAttribute('data-'+valueName.data, value);
752
+ } else if (valueName.attr && valueName.name) {
753
+ elm = list.utils.getByClass(item.elm, valueName.name, true);
754
+ if (elm) {
755
+ elm.setAttribute(valueName.attr, value);
756
+ }
757
+ } else {
758
+ elm = list.utils.getByClass(item.elm, valueName, true);
759
+ if (elm) {
760
+ elm.innerHTML = value;
761
+ }
762
+ }
763
+ elm = undefined;
764
+ };
765
+ if (!templater.create(item)) {
766
+ for(var v in values) {
767
+ if (values.hasOwnProperty(v)) {
768
+ setValue(v, values[v]);
769
+ }
770
+ }
771
+ }
772
+ };
196
773
 
197
- localRequire.exists = function(path) {
198
- return require.modules.hasOwnProperty(localRequire.resolve(path));
774
+ this.create = function(item) {
775
+ if (item.elm !== undefined) {
776
+ return false;
777
+ }
778
+ /* If item source does not exists, use the first item in list as
779
+ source for new items */
780
+ var newItem = itemSource.cloneNode(true);
781
+ newItem.removeAttribute('id');
782
+ item.elm = newItem;
783
+ templater.set(item, item.values());
784
+ return true;
785
+ };
786
+ this.remove = function(item) {
787
+ if (item.elm.parentNode === list.list) {
788
+ list.list.removeChild(item.elm);
789
+ }
790
+ };
791
+ this.show = function(item) {
792
+ templater.create(item);
793
+ list.list.appendChild(item.elm);
794
+ };
795
+ this.hide = function(item) {
796
+ if (item.elm !== undefined && item.elm.parentNode === list.list) {
797
+ list.list.removeChild(item.elm);
798
+ }
799
+ };
800
+ this.clear = function() {
801
+ /* .innerHTML = ''; fucks up IE */
802
+ if (list.list.hasChildNodes()) {
803
+ while (list.list.childNodes.length >= 1)
804
+ {
805
+ list.list.removeChild(list.list.firstChild);
806
+ }
807
+ }
199
808
  };
200
809
 
201
- return localRequire;
810
+ init();
202
811
  };
203
- require.register("component-classes/index.js", function(exports, require, module){
812
+
813
+ module.exports = function(list) {
814
+ return new Templater(list);
815
+ };
816
+
817
+ },{}],9:[function(require,module,exports){
204
818
  /**
205
819
  * Module dependencies.
206
820
  */
207
821
 
208
- var index = require('indexof');
822
+ var index = require('./index-of');
209
823
 
210
824
  /**
211
825
  * Whitespace regexp.
@@ -239,7 +853,9 @@ module.exports = function(el){
239
853
  */
240
854
 
241
855
  function ClassList(el) {
242
- if (!el) throw new Error('A DOM element reference is required');
856
+ if (!el || !el.nodeType) {
857
+ throw new Error('A DOM element reference is required');
858
+ }
243
859
  this.el = el;
244
860
  this.list = el.classList;
245
861
  }
@@ -365,7 +981,8 @@ ClassList.prototype.toggle = function(name, force){
365
981
  */
366
982
 
367
983
  ClassList.prototype.array = function(){
368
- var str = this.el.className.replace(/^\s+|\s+$/g, '');
984
+ var className = this.el.getAttribute('class') || '';
985
+ var str = className.replace(/^\s+|\s+$/g, '');
369
986
  var arr = str.split(re);
370
987
  if ('' === arr[0]) arr.shift();
371
988
  return arr;
@@ -381,150 +998,102 @@ ClassList.prototype.array = function(){
381
998
 
382
999
  ClassList.prototype.has =
383
1000
  ClassList.prototype.contains = function(name){
384
- return this.list
385
- ? this.list.contains(name)
386
- : !! ~index(this.array(), name);
1001
+ return this.list ? this.list.contains(name) : !! ~index(this.array(), name);
387
1002
  };
388
1003
 
389
- });
390
- require.register("segmentio-extend/index.js", function(exports, require, module){
391
-
392
- module.exports = function extend (object) {
393
- // Takes an unlimited number of extenders.
394
- var args = Array.prototype.slice.call(arguments, 1);
395
-
396
- // For each extender, copy their properties on our object.
397
- for (var i = 0, source; source = args[i]; i++) {
398
- if (!source) continue;
399
- for (var property in source) {
400
- object[property] = source[property];
401
- }
402
- }
403
-
404
- return object;
405
- };
406
- });
407
- require.register("component-indexof/index.js", function(exports, require, module){
408
- module.exports = function(arr, obj){
409
- if (arr.indexOf) return arr.indexOf(obj);
410
- for (var i = 0; i < arr.length; ++i) {
411
- if (arr[i] === obj) return i;
412
- }
413
- return -1;
414
- };
415
- });
416
- require.register("component-event/index.js", function(exports, require, module){
1004
+ },{"./index-of":14}],10:[function(require,module,exports){
417
1005
  var bind = window.addEventListener ? 'addEventListener' : 'attachEvent',
418
1006
  unbind = window.removeEventListener ? 'removeEventListener' : 'detachEvent',
419
- prefix = bind !== 'addEventListener' ? 'on' : '';
1007
+ prefix = bind !== 'addEventListener' ? 'on' : '',
1008
+ toArray = require('./to-array');
420
1009
 
421
1010
  /**
422
1011
  * Bind `el` event `type` to `fn`.
423
1012
  *
424
- * @param {Element} el
1013
+ * @param {Element} el, NodeList, HTMLCollection or Array
425
1014
  * @param {String} type
426
1015
  * @param {Function} fn
427
1016
  * @param {Boolean} capture
428
- * @return {Function}
429
1017
  * @api public
430
1018
  */
431
1019
 
432
1020
  exports.bind = function(el, type, fn, capture){
433
- el[bind](prefix + type, fn, capture || false);
434
- return fn;
1021
+ el = toArray(el);
1022
+ for ( var i = 0; i < el.length; i++ ) {
1023
+ el[i][bind](prefix + type, fn, capture || false);
1024
+ }
435
1025
  };
436
1026
 
437
1027
  /**
438
1028
  * Unbind `el` event `type`'s callback `fn`.
439
1029
  *
440
- * @param {Element} el
1030
+ * @param {Element} el, NodeList, HTMLCollection or Array
441
1031
  * @param {String} type
442
1032
  * @param {Function} fn
443
1033
  * @param {Boolean} capture
444
- * @return {Function}
445
1034
  * @api public
446
1035
  */
447
1036
 
448
1037
  exports.unbind = function(el, type, fn, capture){
449
- el[unbind](prefix + type, fn, capture || false);
450
- return fn;
451
- };
452
- });
453
- require.register("timoxley-to-array/index.js", function(exports, require, module){
454
- /**
455
- * Convert an array-like object into an `Array`.
456
- * If `collection` is already an `Array`, then will return a clone of `collection`.
457
- *
458
- * @param {Array | Mixed} collection An `Array` or array-like object to convert e.g. `arguments` or `NodeList`
459
- * @return {Array} Naive conversion of `collection` to a new `Array`.
460
- * @api public
461
- */
462
-
463
- module.exports = function toArray(collection) {
464
- if (typeof collection === 'undefined') return []
465
- if (collection === null) return [null]
466
- if (collection === window) return [window]
467
- if (typeof collection === 'string') return [collection]
468
- if (isArray(collection)) return collection
469
- if (typeof collection.length != 'number') return [collection]
470
- if (typeof collection === 'function' && collection instanceof Function) return [collection]
471
-
472
- var arr = []
473
- for (var i = 0; i < collection.length; i++) {
474
- if (Object.prototype.hasOwnProperty.call(collection, i) || i in collection) {
475
- arr.push(collection[i])
476
- }
1038
+ el = toArray(el);
1039
+ for ( var i = 0; i < el.length; i++ ) {
1040
+ el[i][unbind](prefix + type, fn, capture || false);
477
1041
  }
478
- if (!arr.length) return []
479
- return arr
480
- }
1042
+ };
481
1043
 
482
- function isArray(arr) {
483
- return Object.prototype.toString.call(arr) === "[object Array]";
484
- }
1044
+ },{"./to-array":16}],11:[function(require,module,exports){
1045
+ /*
1046
+ * Source: https://github.com/segmentio/extend
1047
+ */
485
1048
 
486
- });
487
- require.register("javve-events/index.js", function(exports, require, module){
488
- var events = require('event'),
489
- toArray = require('to-array');
1049
+ module.exports = function extend (object) {
1050
+ // Takes an unlimited number of extenders.
1051
+ var args = Array.prototype.slice.call(arguments, 1);
490
1052
 
491
- /**
492
- * Bind `el` event `type` to `fn`.
493
- *
494
- * @param {Element} el, NodeList, HTMLCollection or Array
495
- * @param {String} type
496
- * @param {Function} fn
497
- * @param {Boolean} capture
498
- * @api public
499
- */
1053
+ // For each extender, copy their properties on our object.
1054
+ for (var i = 0, source; source = args[i]; i++) {
1055
+ if (!source) continue;
1056
+ for (var property in source) {
1057
+ object[property] = source[property];
1058
+ }
1059
+ }
500
1060
 
501
- exports.bind = function(el, type, fn, capture){
502
- el = toArray(el);
503
- for ( var i = 0; i < el.length; i++ ) {
504
- events.bind(el[i], type, fn, capture);
505
- }
1061
+ return object;
506
1062
  };
507
1063
 
1064
+ },{}],12:[function(require,module,exports){
508
1065
  /**
509
- * Unbind `el` event `type`'s callback `fn`.
1066
+ * A cross-browser implementation of getAttribute.
1067
+ * Source found here: http://stackoverflow.com/a/3755343/361337 written by Vivin Paliath
510
1068
  *
511
- * @param {Element} el, NodeList, HTMLCollection or Array
512
- * @param {String} type
513
- * @param {Function} fn
514
- * @param {Boolean} capture
1069
+ * Return the value for `attr` at `element`.
1070
+ *
1071
+ * @param {Element} el
1072
+ * @param {String} attr
515
1073
  * @api public
516
1074
  */
517
1075
 
518
- exports.unbind = function(el, type, fn, capture){
519
- el = toArray(el);
520
- for ( var i = 0; i < el.length; i++ ) {
521
- events.unbind(el[i], type, fn, capture);
1076
+ module.exports = function(el, attr) {
1077
+ var result = (el.getAttribute && el.getAttribute(attr)) || null;
1078
+ if( !result ) {
1079
+ var attrs = el.attributes;
1080
+ var length = attrs.length;
1081
+ for(var i = 0; i < length; i++) {
1082
+ if (attr[i] !== undefined) {
1083
+ if(attr[i].nodeName === attr) {
1084
+ result = attr[i].nodeValue;
1085
+ }
1086
+ }
1087
+ }
522
1088
  }
1089
+ return result;
523
1090
  };
524
1091
 
525
- });
526
- require.register("javve-get-by-class/index.js", function(exports, require, module){
1092
+ },{}],13:[function(require,module,exports){
527
1093
  /**
1094
+ * A cross-browser implementation of getElementsByClass.
1095
+ * Heavily based on Dustin Diaz's function: http://dustindiaz.com/getelementsbyclass.
1096
+ *
528
1097
  * Find all elements with class `className` inside `container`.
529
1098
  * Use `single = true` to increase performance in older browsers
530
1099
  * when only one element is needed.
@@ -557,7 +1126,7 @@ module.exports = (function() {
557
1126
  return function(container, className, single) {
558
1127
  var classElements = [],
559
1128
  tag = '*';
560
- if (container == null) {
1129
+ if (container === null) {
561
1130
  container = document;
562
1131
  }
563
1132
  var els = container.getElementsByTagName(tag);
@@ -578,897 +1147,112 @@ module.exports = (function() {
578
1147
  }
579
1148
  })();
580
1149
 
581
- });
582
- require.register("javve-get-attribute/index.js", function(exports, require, module){
583
- /**
584
- * Return the value for `attr` at `element`.
585
- *
586
- * @param {Element} el
587
- * @param {String} attr
588
- * @api public
589
- */
1150
+ },{}],14:[function(require,module,exports){
1151
+ var indexOf = [].indexOf;
590
1152
 
591
- module.exports = function(el, attr) {
592
- var result = (el.getAttribute && el.getAttribute(attr)) || null;
593
- if( !result ) {
594
- var attrs = el.attributes;
595
- var length = attrs.length;
596
- for(var i = 0; i < length; i++) {
597
- if (attr[i] !== undefined) {
598
- if(attr[i].nodeName === attr) {
599
- result = attr[i].nodeValue;
600
- }
601
- }
602
- }
603
- }
604
- return result;
605
- }
606
- });
607
- require.register("javve-natural-sort/index.js", function(exports, require, module){
608
- /*
609
- * Natural Sort algorithm for Javascript - Version 0.7 - Released under MIT license
610
- * Author: Jim Palmer (based on chunking idea from Dave Koelle)
611
- */
612
-
613
- module.exports = function(a, b, options) {
614
- var re = /(^-?[0-9]+(\.?[0-9]*)[df]?e?[0-9]?$|^0x[0-9a-f]+$|[0-9]+)/gi,
615
- sre = /(^[ ]*|[ ]*$)/g,
616
- dre = /(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,
617
- hre = /^0x[0-9a-f]+$/i,
618
- ore = /^0/,
619
- options = options || {},
620
- i = function(s) { return options.insensitive && (''+s).toLowerCase() || ''+s },
621
- // convert all to strings strip whitespace
622
- x = i(a).replace(sre, '') || '',
623
- y = i(b).replace(sre, '') || '',
624
- // chunk/tokenize
625
- xN = x.replace(re, '\0$1\0').replace(/\0$/,'').replace(/^\0/,'').split('\0'),
626
- yN = y.replace(re, '\0$1\0').replace(/\0$/,'').replace(/^\0/,'').split('\0'),
627
- // numeric, hex or date detection
628
- xD = parseInt(x.match(hre)) || (xN.length != 1 && x.match(dre) && Date.parse(x)),
629
- yD = parseInt(y.match(hre)) || xD && y.match(dre) && Date.parse(y) || null,
630
- oFxNcL, oFyNcL,
631
- mult = options.desc ? -1 : 1;
632
- // first try and sort Hex codes or Dates
633
- if (yD)
634
- if ( xD < yD ) return -1 * mult;
635
- else if ( xD > yD ) return 1 * mult;
636
- // natural sorting through split numeric strings and default strings
637
- for(var cLoc=0, numS=Math.max(xN.length, yN.length); cLoc < numS; cLoc++) {
638
- // find floats not starting with '0', string or 0 if not defined (Clint Priest)
639
- oFxNcL = !(xN[cLoc] || '').match(ore) && parseFloat(xN[cLoc]) || xN[cLoc] || 0;
640
- oFyNcL = !(yN[cLoc] || '').match(ore) && parseFloat(yN[cLoc]) || yN[cLoc] || 0;
641
- // handle numeric vs string comparison - number < string - (Kyle Adams)
642
- if (isNaN(oFxNcL) !== isNaN(oFyNcL)) { return (isNaN(oFxNcL)) ? 1 : -1; }
643
- // rely on string comparison if different types - i.e. '02' < 2 != '02' < '2'
644
- else if (typeof oFxNcL !== typeof oFyNcL) {
645
- oFxNcL += '';
646
- oFyNcL += '';
647
- }
648
- if (oFxNcL < oFyNcL) return -1 * mult;
649
- if (oFxNcL > oFyNcL) return 1 * mult;
1153
+ module.exports = function(arr, obj){
1154
+ if (indexOf) return arr.indexOf(obj);
1155
+ for (var i = 0; i < arr.length; ++i) {
1156
+ if (arr[i] === obj) return i;
650
1157
  }
651
- return 0;
1158
+ return -1;
652
1159
  };
653
1160
 
1161
+ },{}],15:[function(require,module,exports){
654
1162
  /*
655
- var defaultSort = getSortFunction();
656
-
657
- module.exports = function(a, b, options) {
658
- if (arguments.length == 1) {
659
- options = a;
660
- return getSortFunction(options);
661
- } else {
662
- return defaultSort(a,b);
663
- }
664
- }
665
- */
666
- });
667
- require.register("javve-to-string/index.js", function(exports, require, module){
668
- module.exports = function(s) {
669
- s = (s === undefined) ? "" : s;
670
- s = (s === null) ? "" : s;
671
- s = s.toString();
672
- return s;
673
- };
674
-
675
- });
676
- require.register("component-type/index.js", function(exports, require, module){
677
- /**
678
- * toString ref.
1163
+ * Natural Sort algorithm for Javascript - Version 0.8.1 - Released under MIT license
1164
+ * Author: Jim Palmer (based on chunking idea from Dave Koelle)
679
1165
  */
1166
+ module.exports = function(a, b, opts) {
1167
+ var re = /(^([+\-]?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?(?=\D|\s|$))|^0x[\da-fA-F]+$|\d+)/g,
1168
+ sre = /^\s+|\s+$/g, // trim pre-post whitespace
1169
+ snre = /\s+/g, // normalize all whitespace to single ' ' character
1170
+ dre = /(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,
1171
+ hre = /^0x[0-9a-f]+$/i,
1172
+ ore = /^0/,
1173
+ options = opts || {},
1174
+ i = function(s) {
1175
+ return (options.insensitive && ('' + s).toLowerCase() || '' + s).replace(sre, '');
1176
+ },
1177
+ // convert all to strings strip whitespace
1178
+ x = i(a),
1179
+ y = i(b),
1180
+ // chunk/tokenize
1181
+ xN = x.replace(re, '\0$1\0').replace(/\0$/,'').replace(/^\0/,'').split('\0'),
1182
+ yN = y.replace(re, '\0$1\0').replace(/\0$/,'').replace(/^\0/,'').split('\0'),
1183
+ // numeric, hex or date detection
1184
+ xD = parseInt(x.match(hre), 16) || (xN.length !== 1 && Date.parse(x)),
1185
+ yD = parseInt(y.match(hre), 16) || xD && y.match(dre) && Date.parse(y) || null,
1186
+ normChunk = function(s, l) {
1187
+ // normalize spaces; find floats not starting with '0', string or 0 if not defined (Clint Priest)
1188
+ return (!s.match(ore) || l == 1) && parseFloat(s) || s.replace(snre, ' ').replace(sre, '') || 0;
1189
+ },
1190
+ oFxNcL, oFyNcL;
1191
+ // first try and sort Hex codes or Dates
1192
+ if (yD) {
1193
+ if (xD < yD) { return -1; }
1194
+ else if (xD > yD) { return 1; }
1195
+ }
1196
+ // natural sorting through split numeric strings and default strings
1197
+ for(var cLoc = 0, xNl = xN.length, yNl = yN.length, numS = Math.max(xNl, yNl); cLoc < numS; cLoc++) {
1198
+ oFxNcL = normChunk(xN[cLoc] || '', xNl);
1199
+ oFyNcL = normChunk(yN[cLoc] || '', yNl);
1200
+ // handle numeric vs string comparison - number < string - (Kyle Adams)
1201
+ if (isNaN(oFxNcL) !== isNaN(oFyNcL)) {
1202
+ return isNaN(oFxNcL) ? 1 : -1;
1203
+ }
1204
+ // if unicode use locale comparison
1205
+ if (/[^\x00-\x80]/.test(oFxNcL + oFyNcL) && oFxNcL.localeCompare) {
1206
+ var comp = oFxNcL.localeCompare(oFyNcL);
1207
+ return comp / Math.abs(comp);
1208
+ }
1209
+ if (oFxNcL < oFyNcL) { return -1; }
1210
+ else if (oFxNcL > oFyNcL) { return 1; }
1211
+ }
1212
+ return 0;
1213
+ };
680
1214
 
681
- var toString = Object.prototype.toString;
682
-
1215
+ },{}],16:[function(require,module,exports){
683
1216
  /**
684
- * Return the type of `val`.
1217
+ * Source: https://github.com/timoxley/to-array
1218
+ *
1219
+ * Convert an array-like object into an `Array`.
1220
+ * If `collection` is already an `Array`, then will return a clone of `collection`.
685
1221
  *
686
- * @param {Mixed} val
687
- * @return {String}
1222
+ * @param {Array | Mixed} collection An `Array` or array-like object to convert e.g. `arguments` or `NodeList`
1223
+ * @return {Array} Naive conversion of `collection` to a new `Array`.
688
1224
  * @api public
689
1225
  */
690
1226
 
691
- module.exports = function(val){
692
- switch (toString.call(val)) {
693
- case '[object Date]': return 'date';
694
- case '[object RegExp]': return 'regexp';
695
- case '[object Arguments]': return 'arguments';
696
- case '[object Array]': return 'array';
697
- case '[object Error]': return 'error';
698
- }
699
-
700
- if (val === null) return 'null';
701
- if (val === undefined) return 'undefined';
702
- if (val !== val) return 'nan';
703
- if (val && val.nodeType === 1) return 'element';
704
-
705
- return typeof val.valueOf();
706
- };
707
-
708
- });
709
- require.register("list.js/index.js", function(exports, require, module){
710
- /*
711
- ListJS with beta 1.0.0
712
- By Jonny Strömberg (www.jonnystromberg.com, www.listjs.com)
713
- */
714
- (function( window, undefined ) {
715
- "use strict";
716
-
717
- var document = window.document,
718
- getByClass = require('get-by-class'),
719
- extend = require('extend'),
720
- indexOf = require('indexof');
721
-
722
- var List = function(id, options, values) {
723
-
724
- var self = this,
725
- init,
726
- Item = require('./src/item')(self),
727
- addAsync = require('./src/add-async')(self),
728
- parse = require('./src/parse')(self);
729
-
730
- init = {
731
- start: function() {
732
- self.listClass = "list";
733
- self.searchClass = "search";
734
- self.sortClass = "sort";
735
- self.page = 1024;
736
- self.i = 1;
737
- self.items = [];
738
- self.visibleItems = [];
739
- self.matchingItems = [];
740
- self.searched = false;
741
- self.filtered = false;
742
- self.handlers = { 'updated': [] };
743
- self.plugins = {};
744
- self.helpers = {
745
- getByClass: getByClass,
746
- extend: extend,
747
- indexOf: indexOf
748
- };
749
-
750
- extend(self, options);
751
-
752
- self.listContainer = (typeof(id) === 'string') ? document.getElementById(id) : id;
753
- if (!self.listContainer) { return; }
754
- self.list = getByClass(self.listContainer, self.listClass, true);
755
-
756
- self.templater = require('./src/templater')(self);
757
- self.search = require('./src/search')(self);
758
- self.filter = require('./src/filter')(self);
759
- self.sort = require('./src/sort')(self);
760
-
761
- this.items();
762
- self.update();
763
- this.plugins();
764
- },
765
- items: function() {
766
- parse(self.list);
767
- if (values !== undefined) {
768
- self.add(values);
769
- }
770
- },
771
- plugins: function() {
772
- for (var i = 0; i < self.plugins.length; i++) {
773
- var plugin = self.plugins[i];
774
- self[plugin.name] = plugin;
775
- plugin.init(self);
776
- }
777
- }
778
- };
779
-
780
-
781
- /*
782
- * Add object to list
783
- */
784
- this.add = function(values, callback) {
785
- if (callback) {
786
- addAsync(values, callback);
787
- return;
788
- }
789
- var added = [],
790
- notCreate = false;
791
- if (values[0] === undefined){
792
- values = [values];
793
- }
794
- for (var i = 0, il = values.length; i < il; i++) {
795
- var item = null;
796
- if (values[i] instanceof Item) {
797
- item = values[i];
798
- item.reload();
799
- } else {
800
- notCreate = (self.items.length > self.page) ? true : false;
801
- item = new Item(values[i], undefined, notCreate);
802
- }
803
- self.items.push(item);
804
- added.push(item);
805
- }
806
- self.update();
807
- return added;
808
- };
809
-
810
- this.show = function(i, page) {
811
- this.i = i;
812
- this.page = page;
813
- self.update();
814
- return self;
815
- };
816
-
817
- /* Removes object from list.
818
- * Loops through the list and removes objects where
819
- * property "valuename" === value
820
- */
821
- this.remove = function(valueName, value, options) {
822
- var found = 0;
823
- for (var i = 0, il = self.items.length; i < il; i++) {
824
- if (self.items[i].values()[valueName] == value) {
825
- self.templater.remove(self.items[i], options);
826
- self.items.splice(i,1);
827
- il--;
828
- i--;
829
- found++;
830
- }
831
- }
832
- self.update();
833
- return found;
834
- };
835
-
836
- /* Gets the objects in the list which
837
- * property "valueName" === value
838
- */
839
- this.get = function(valueName, value) {
840
- var matchedItems = [];
841
- for (var i = 0, il = self.items.length; i < il; i++) {
842
- var item = self.items[i];
843
- if (item.values()[valueName] == value) {
844
- matchedItems.push(item);
845
- }
846
- }
847
- return matchedItems;
848
- };
849
-
850
- /*
851
- * Get size of the list
852
- */
853
- this.size = function() {
854
- return self.items.length;
855
- };
856
-
857
- /*
858
- * Removes all items from the list
859
- */
860
- this.clear = function() {
861
- self.templater.clear();
862
- self.items = [];
863
- return self;
864
- };
865
-
866
- this.on = function(event, callback) {
867
- self.handlers[event].push(callback);
868
- return self;
869
- };
870
-
871
- this.off = function(event, callback) {
872
- var e = self.handlers[event];
873
- var index = indexOf(e, callback);
874
- if (index > -1) {
875
- e.splice(index, 1);
876
- }
877
- return self;
878
- };
879
-
880
- this.trigger = function(event) {
881
- var i = self.handlers[event].length;
882
- while(i--) {
883
- self.handlers[event][i](self);
884
- }
885
- return self;
886
- };
887
-
888
- this.reset = {
889
- filter: function() {
890
- var is = self.items,
891
- il = is.length;
892
- while (il--) {
893
- is[il].filtered = false;
894
- }
895
- return self;
896
- },
897
- search: function() {
898
- var is = self.items,
899
- il = is.length;
900
- while (il--) {
901
- is[il].found = false;
902
- }
903
- return self;
904
- }
905
- };
906
-
907
- this.update = function() {
908
- var is = self.items,
909
- il = is.length;
910
-
911
- self.visibleItems = [];
912
- self.matchingItems = [];
913
- self.templater.clear();
914
- for (var i = 0; i < il; i++) {
915
- if (is[i].matching() && ((self.matchingItems.length+1) >= self.i && self.visibleItems.length < self.page)) {
916
- is[i].show();
917
- self.visibleItems.push(is[i]);
918
- self.matchingItems.push(is[i]);
919
- } else if (is[i].matching()) {
920
- self.matchingItems.push(is[i]);
921
- is[i].hide();
922
- } else {
923
- is[i].hide();
924
- }
925
- }
926
- self.trigger('updated');
927
- return self;
928
- };
929
-
930
- init.start();
931
- };
932
-
933
- module.exports = List;
934
-
935
- })(window);
936
-
937
- });
938
- require.register("list.js/src/search.js", function(exports, require, module){
939
- var events = require('events'),
940
- getByClass = require('get-by-class'),
941
- toString = require('to-string');
942
-
943
- module.exports = function(list) {
944
- var item,
945
- text,
946
- columns,
947
- searchString,
948
- customSearch;
949
-
950
- var prepare = {
951
- resetList: function() {
952
- list.i = 1;
953
- list.templater.clear();
954
- customSearch = undefined;
955
- },
956
- setOptions: function(args) {
957
- if (args.length == 2 && args[1] instanceof Array) {
958
- columns = args[1];
959
- } else if (args.length == 2 && typeof(args[1]) == "function") {
960
- customSearch = args[1];
961
- } else if (args.length == 3) {
962
- columns = args[1];
963
- customSearch = args[2];
964
- }
965
- },
966
- setColumns: function() {
967
- columns = (columns === undefined) ? prepare.toArray(list.items[0].values()) : columns;
968
- },
969
- setSearchString: function(s) {
970
- s = toString(s).toLowerCase();
971
- s = s.replace(/[-[\]{}()*+?.,\\^$|#]/g, "\\$&"); // Escape regular expression characters
972
- searchString = s;
973
- },
974
- toArray: function(values) {
975
- var tmpColumn = [];
976
- for (var name in values) {
977
- tmpColumn.push(name);
978
- }
979
- return tmpColumn;
980
- }
981
- };
982
- var search = {
983
- list: function() {
984
- for (var k = 0, kl = list.items.length; k < kl; k++) {
985
- search.item(list.items[k]);
986
- }
987
- },
988
- item: function(item) {
989
- item.found = false;
990
- for (var j = 0, jl = columns.length; j < jl; j++) {
991
- if (search.values(item.values(), columns[j])) {
992
- item.found = true;
993
- return;
994
- }
995
- }
996
- },
997
- values: function(values, column) {
998
- if (values.hasOwnProperty(column)) {
999
- text = toString(values[column]).toLowerCase();
1000
- if ((searchString !== "") && (text.search(searchString) > -1)) {
1001
- return true;
1002
- }
1003
- }
1004
- return false;
1005
- },
1006
- reset: function() {
1007
- list.reset.search();
1008
- list.searched = false;
1009
- }
1010
- };
1011
-
1012
- var searchMethod = function(str) {
1013
- list.trigger('searchStart');
1014
-
1015
- prepare.resetList();
1016
- prepare.setSearchString(str);
1017
- prepare.setOptions(arguments); // str, cols|searchFunction, searchFunction
1018
- prepare.setColumns();
1019
-
1020
- if (searchString === "" ) {
1021
- search.reset();
1022
- } else {
1023
- list.searched = true;
1024
- if (customSearch) {
1025
- customSearch(searchString, columns);
1026
- } else {
1027
- search.list();
1028
- }
1029
- }
1030
-
1031
- list.update();
1032
- list.trigger('searchComplete');
1033
- return list.visibleItems;
1034
- };
1035
-
1036
- list.handlers.searchStart = list.handlers.searchStart || [];
1037
- list.handlers.searchComplete = list.handlers.searchComplete || [];
1038
-
1039
- events.bind(getByClass(list.listContainer, list.searchClass), 'keyup', function(e) {
1040
- var target = e.target || e.srcElement, // IE have srcElement
1041
- alreadyCleared = (target.value === "" && !list.searched);
1042
- if (!alreadyCleared) { // If oninput already have resetted the list, do nothing
1043
- searchMethod(target.value);
1044
- }
1045
- });
1046
-
1047
- // Used to detect click on HTML5 clear button
1048
- events.bind(getByClass(list.listContainer, list.searchClass), 'input', function(e) {
1049
- var target = e.target || e.srcElement;
1050
- if (target.value === "") {
1051
- searchMethod('');
1052
- }
1053
- });
1054
-
1055
- list.helpers.toString = toString;
1056
- return searchMethod;
1057
- };
1058
-
1059
- });
1060
- require.register("list.js/src/sort.js", function(exports, require, module){
1061
- var naturalSort = require('natural-sort'),
1062
- classes = require('classes'),
1063
- events = require('events'),
1064
- getByClass = require('get-by-class'),
1065
- getAttribute = require('get-attribute');
1066
-
1067
- module.exports = function(list) {
1068
- list.sortFunction = list.sortFunction || function(itemA, itemB, options) {
1069
- options.desc = options.order == "desc" ? true : false; // Natural sort uses this format
1070
- return naturalSort(itemA.values()[options.valueName], itemB.values()[options.valueName], options);
1071
- };
1072
-
1073
- var buttons = {
1074
- els: undefined,
1075
- clear: function() {
1076
- for (var i = 0, il = buttons.els.length; i < il; i++) {
1077
- classes(buttons.els[i]).remove('asc');
1078
- classes(buttons.els[i]).remove('desc');
1079
- }
1080
- },
1081
- getOrder: function(btn) {
1082
- var predefinedOrder = getAttribute(btn, 'data-order');
1083
- if (predefinedOrder == "asc" || predefinedOrder == "desc") {
1084
- return predefinedOrder;
1085
- } else if (classes(btn).has('desc')) {
1086
- return "asc";
1087
- } else if (classes(btn).has('asc')) {
1088
- return "desc";
1089
- } else {
1090
- return "asc";
1091
- }
1092
- },
1093
- getInSensitive: function(btn, options) {
1094
- var insensitive = getAttribute(btn, 'data-insensitive');
1095
- if (insensitive === "true") {
1096
- options.insensitive = true;
1097
- } else {
1098
- options.insensitive = false;
1099
- }
1100
- },
1101
- setOrder: function(options) {
1102
- for (var i = 0, il = buttons.els.length; i < il; i++) {
1103
- var btn = buttons.els[i];
1104
- if (getAttribute(btn, 'data-sort') !== options.valueName) {
1105
- continue;
1106
- }
1107
- var predefinedOrder = getAttribute(btn, 'data-order');
1108
- if (predefinedOrder == "asc" || predefinedOrder == "desc") {
1109
- if (predefinedOrder == options.order) {
1110
- classes(btn).add(options.order);
1111
- }
1112
- } else {
1113
- classes(btn).add(options.order);
1114
- }
1115
- }
1116
- }
1117
- };
1118
- var sort = function() {
1119
- list.trigger('sortStart');
1120
- options = {};
1121
-
1122
- var target = arguments[0].currentTarget || arguments[0].srcElement || undefined;
1123
-
1124
- if (target) {
1125
- options.valueName = getAttribute(target, 'data-sort');
1126
- buttons.getInSensitive(target, options);
1127
- options.order = buttons.getOrder(target);
1128
- } else {
1129
- options = arguments[1] || options;
1130
- options.valueName = arguments[0];
1131
- options.order = options.order || "asc";
1132
- options.insensitive = (typeof options.insensitive == "undefined") ? true : options.insensitive;
1133
- }
1134
- buttons.clear();
1135
- buttons.setOrder(options);
1136
-
1137
- options.sortFunction = options.sortFunction || list.sortFunction;
1138
- list.items.sort(function(a, b) {
1139
- return options.sortFunction(a, b, options);
1140
- });
1141
- list.update();
1142
- list.trigger('sortComplete');
1143
- };
1144
-
1145
- // Add handlers
1146
- list.handlers.sortStart = list.handlers.sortStart || [];
1147
- list.handlers.sortComplete = list.handlers.sortComplete || [];
1148
-
1149
- buttons.els = getByClass(list.listContainer, list.sortClass);
1150
- events.bind(buttons.els, 'click', sort);
1151
- list.on('searchStart', buttons.clear);
1152
- list.on('filterStart', buttons.clear);
1153
-
1154
- // Helpers
1155
- list.helpers.classes = classes;
1156
- list.helpers.naturalSort = naturalSort;
1157
- list.helpers.events = events;
1158
- list.helpers.getAttribute = getAttribute;
1159
-
1160
- return sort;
1161
- };
1162
-
1163
- });
1164
- require.register("list.js/src/item.js", function(exports, require, module){
1165
- module.exports = function(list) {
1166
- return function(initValues, element, notCreate) {
1167
- var item = this;
1168
-
1169
- this._values = {};
1170
-
1171
- this.found = false; // Show if list.searched == true and this.found == true
1172
- this.filtered = false;// Show if list.filtered == true and this.filtered == true
1173
-
1174
- var init = function(initValues, element, notCreate) {
1175
- if (element === undefined) {
1176
- if (notCreate) {
1177
- item.values(initValues, notCreate);
1178
- } else {
1179
- item.values(initValues);
1180
- }
1181
- } else {
1182
- item.elm = element;
1183
- var values = list.templater.get(item, initValues);
1184
- item.values(values);
1185
- }
1186
- };
1187
- this.values = function(newValues, notCreate) {
1188
- if (newValues !== undefined) {
1189
- for(var name in newValues) {
1190
- item._values[name] = newValues[name];
1191
- }
1192
- if (notCreate !== true) {
1193
- list.templater.set(item, item.values());
1194
- }
1195
- } else {
1196
- return item._values;
1197
- }
1198
- };
1199
- this.show = function() {
1200
- list.templater.show(item);
1201
- };
1202
- this.hide = function() {
1203
- list.templater.hide(item);
1204
- };
1205
- this.matching = function() {
1206
- return (
1207
- (list.filtered && list.searched && item.found && item.filtered) ||
1208
- (list.filtered && !list.searched && item.filtered) ||
1209
- (!list.filtered && list.searched && item.found) ||
1210
- (!list.filtered && !list.searched)
1211
- );
1212
- };
1213
- this.visible = function() {
1214
- return (item.elm.parentNode == list.list) ? true : false;
1215
- };
1216
- init(initValues, element, notCreate);
1217
- };
1218
- };
1219
-
1220
- });
1221
- require.register("list.js/src/templater.js", function(exports, require, module){
1222
- var getByClass = require('get-by-class');
1223
-
1224
- var Templater = function(list) {
1225
- var itemSource = getItemSource(list.item),
1226
- templater = this;
1227
-
1228
- function getItemSource(item) {
1229
- if (item === undefined) {
1230
- var nodes = list.list.childNodes,
1231
- items = [];
1232
-
1233
- for (var i = 0, il = nodes.length; i < il; i++) {
1234
- // Only textnodes have a data attribute
1235
- if (nodes[i].data === undefined) {
1236
- return nodes[i];
1237
- }
1238
- }
1239
- return null;
1240
- } else if (item.indexOf("<") !== -1) { // Try create html element of list, do not work for tables!!
1241
- var div = document.createElement('div');
1242
- div.innerHTML = item;
1243
- return div.firstChild;
1244
- } else {
1245
- return document.getElementById(list.item);
1246
- }
1227
+ module.exports = function toArray(collection) {
1228
+ if (typeof collection === 'undefined') return [];
1229
+ if (collection === null) return [null];
1230
+ if (collection === window) return [window];
1231
+ if (typeof collection === 'string') return [collection];
1232
+ if (isArray(collection)) return collection;
1233
+ if (typeof collection.length != 'number') return [collection];
1234
+ if (typeof collection === 'function' && collection instanceof Function) return [collection];
1235
+
1236
+ var arr = [];
1237
+ for (var i = 0; i < collection.length; i++) {
1238
+ if (Object.prototype.hasOwnProperty.call(collection, i) || i in collection) {
1239
+ arr.push(collection[i]);
1247
1240
  }
1248
-
1249
- /* Get values from element */
1250
- this.get = function(item, valueNames) {
1251
- templater.create(item);
1252
- var values = {};
1253
- for(var i = 0, il = valueNames.length; i < il; i++) {
1254
- var elm = getByClass(item.elm, valueNames[i], true);
1255
- values[valueNames[i]] = elm ? elm.innerHTML : "";
1256
- }
1257
- return values;
1258
- };
1259
-
1260
- /* Sets values at element */
1261
- this.set = function(item, values) {
1262
- if (!templater.create(item)) {
1263
- for(var v in values) {
1264
- if (values.hasOwnProperty(v)) {
1265
- // TODO speed up if possible
1266
- var elm = getByClass(item.elm, v, true);
1267
- if (elm) {
1268
- /* src attribute for image tag & text for other tags */
1269
- if (elm.tagName === "IMG" && values[v] !== "") {
1270
- elm.src = values[v];
1271
- } else {
1272
- elm.innerHTML = values[v];
1273
- }
1274
- }
1275
- }
1276
- }
1277
- }
1278
- };
1279
-
1280
- this.create = function(item) {
1281
- if (item.elm !== undefined) {
1282
- return false;
1283
- }
1284
- /* If item source does not exists, use the first item in list as
1285
- source for new items */
1286
- var newItem = itemSource.cloneNode(true);
1287
- newItem.removeAttribute('id');
1288
- item.elm = newItem;
1289
- templater.set(item, item.values());
1290
- return true;
1291
- };
1292
- this.remove = function(item) {
1293
- list.list.removeChild(item.elm);
1294
- };
1295
- this.show = function(item) {
1296
- templater.create(item);
1297
- list.list.appendChild(item.elm);
1298
- };
1299
- this.hide = function(item) {
1300
- if (item.elm !== undefined && item.elm.parentNode === list.list) {
1301
- list.list.removeChild(item.elm);
1302
- }
1303
- };
1304
- this.clear = function() {
1305
- /* .innerHTML = ''; fucks up IE */
1306
- if (list.list.hasChildNodes()) {
1307
- while (list.list.childNodes.length >= 1)
1308
- {
1309
- list.list.removeChild(list.list.firstChild);
1310
- }
1311
- }
1312
- };
1313
- };
1314
-
1315
- module.exports = function(list) {
1316
- return new Templater(list);
1317
- };
1318
-
1319
- });
1320
- require.register("list.js/src/filter.js", function(exports, require, module){
1321
- module.exports = function(list) {
1322
-
1323
- // Add handlers
1324
- list.handlers.filterStart = list.handlers.filterStart || [];
1325
- list.handlers.filterComplete = list.handlers.filterComplete || [];
1326
-
1327
- return function(filterFunction) {
1328
- list.trigger('filterStart');
1329
- list.i = 1; // Reset paging
1330
- list.reset.filter();
1331
- if (filterFunction === undefined) {
1332
- list.filtered = false;
1333
- } else {
1334
- list.filtered = true;
1335
- var is = list.items;
1336
- for (var i = 0, il = is.length; i < il; i++) {
1337
- var item = is[i];
1338
- if (filterFunction(item)) {
1339
- item.filtered = true;
1340
- } else {
1341
- item.filtered = false;
1342
- }
1343
- }
1344
- }
1345
- list.update();
1346
- list.trigger('filterComplete');
1347
- return list.visibleItems;
1348
- };
1349
- };
1350
-
1351
- });
1352
- require.register("list.js/src/add-async.js", function(exports, require, module){
1353
- module.exports = function(list) {
1354
- return function(values, callback, items) {
1355
- var valuesToAdd = values.splice(0, 100);
1356
- items = items || [];
1357
- items = items.concat(list.add(valuesToAdd));
1358
- if (values.length > 0) {
1359
- setTimeout(function() {
1360
- addAsync(values, callback, items);
1361
- }, 10);
1362
- } else {
1363
- list.update();
1364
- callback(items);
1365
- }
1366
- };
1241
+ }
1242
+ if (!arr.length) return [];
1243
+ return arr;
1367
1244
  };
1368
- });
1369
- require.register("list.js/src/parse.js", function(exports, require, module){
1370
- module.exports = function(list) {
1371
-
1372
- var Item = require('./item')(list);
1373
-
1374
- var getChildren = function(parent) {
1375
- var nodes = parent.childNodes,
1376
- items = [];
1377
- for (var i = 0, il = nodes.length; i < il; i++) {
1378
- // Only textnodes have a data attribute
1379
- if (nodes[i].data === undefined) {
1380
- items.push(nodes[i]);
1381
- }
1382
- }
1383
- return items;
1384
- };
1385
-
1386
- var parse = function(itemElements, valueNames) {
1387
- for (var i = 0, il = itemElements.length; i < il; i++) {
1388
- list.items.push(new Item(valueNames, itemElements[i]));
1389
- }
1390
- };
1391
- var parseAsync = function(itemElements, valueNames) {
1392
- var itemsToIndex = itemElements.splice(0, 100); // TODO: If < 100 items, what happens in IE etc?
1393
- parse(itemsToIndex, valueNames);
1394
- if (itemElements.length > 0) {
1395
- setTimeout(function() {
1396
- init.items.indexAsync(itemElements, valueNames);
1397
- }, 10);
1398
- } else {
1399
- list.update();
1400
- // TODO: Add indexed callback
1401
- }
1402
- };
1403
1245
 
1404
- return function() {
1405
- var itemsToIndex = getChildren(list.list),
1406
- valueNames = list.valueNames;
1246
+ function isArray(arr) {
1247
+ return Object.prototype.toString.call(arr) === "[object Array]";
1248
+ }
1407
1249
 
1408
- if (list.indexAsync) {
1409
- parseAsync(itemsToIndex, valueNames);
1410
- } else {
1411
- parse(itemsToIndex, valueNames);
1412
- }
1413
- };
1250
+ },{}],17:[function(require,module,exports){
1251
+ module.exports = function(s) {
1252
+ s = (s === undefined) ? "" : s;
1253
+ s = (s === null) ? "" : s;
1254
+ s = s.toString();
1255
+ return s;
1414
1256
  };
1415
1257
 
1416
- });
1417
-
1418
-
1419
-
1420
-
1421
-
1422
-
1423
-
1424
-
1425
-
1426
-
1427
-
1428
-
1429
-
1430
-
1431
-
1432
-
1433
-
1434
-
1435
-
1436
-
1437
- require.alias("component-classes/index.js", "list.js/deps/classes/index.js");
1438
- require.alias("component-classes/index.js", "classes/index.js");
1439
- require.alias("component-indexof/index.js", "component-classes/deps/indexof/index.js");
1440
-
1441
- require.alias("segmentio-extend/index.js", "list.js/deps/extend/index.js");
1442
- require.alias("segmentio-extend/index.js", "extend/index.js");
1443
-
1444
- require.alias("component-indexof/index.js", "list.js/deps/indexof/index.js");
1445
- require.alias("component-indexof/index.js", "indexof/index.js");
1446
-
1447
- require.alias("javve-events/index.js", "list.js/deps/events/index.js");
1448
- require.alias("javve-events/index.js", "events/index.js");
1449
- require.alias("component-event/index.js", "javve-events/deps/event/index.js");
1450
-
1451
- require.alias("timoxley-to-array/index.js", "javve-events/deps/to-array/index.js");
1452
-
1453
- require.alias("javve-get-by-class/index.js", "list.js/deps/get-by-class/index.js");
1454
- require.alias("javve-get-by-class/index.js", "get-by-class/index.js");
1455
-
1456
- require.alias("javve-get-attribute/index.js", "list.js/deps/get-attribute/index.js");
1457
- require.alias("javve-get-attribute/index.js", "get-attribute/index.js");
1458
-
1459
- require.alias("javve-natural-sort/index.js", "list.js/deps/natural-sort/index.js");
1460
- require.alias("javve-natural-sort/index.js", "natural-sort/index.js");
1461
-
1462
- require.alias("javve-to-string/index.js", "list.js/deps/to-string/index.js");
1463
- require.alias("javve-to-string/index.js", "list.js/deps/to-string/index.js");
1464
- require.alias("javve-to-string/index.js", "to-string/index.js");
1465
- require.alias("javve-to-string/index.js", "javve-to-string/index.js");
1466
- require.alias("component-type/index.js", "list.js/deps/type/index.js");
1467
- require.alias("component-type/index.js", "type/index.js");
1468
- if (typeof exports == "object") {
1469
- module.exports = require("list.js");
1470
- } else if (typeof define == "function" && define.amd) {
1471
- define(function(){ return require("list.js"); });
1472
- } else {
1473
- this["List"] = require("list.js");
1474
- }})();
1258
+ },{}]},{},[1]);