1;(function(){ 2 3/** 4 * Require the given path. 5 * 6 * @param {String} path 7 * @return {Object} exports 8 * @api public 9 */ 10 11function 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 47require.modules = {}; 48 49/** 50 * Registered aliases. 51 */ 52 53require.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 69require.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 96require.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 123require.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 135require.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 150require.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}; 203require.register("component-classes/index.js", function(exports, require, module){ 204/** 205 * Module dependencies. 206 */ 207 208var index = require('indexof'); 209 210/** 211 * Whitespace regexp. 212 */ 213 214var re = /\s+/; 215 216/** 217 * toString reference. 218 */ 219 220var toString = Object.prototype.toString; 221 222/** 223 * Wrap `el` in a `ClassList`. 224 * 225 * @param {Element} el 226 * @return {ClassList} 227 * @api public 228 */ 229 230module.exports = function(el){ 231 return new ClassList(el); 232}; 233 234/** 235 * Initialize a new ClassList for `el`. 236 * 237 * @param {Element} el 238 * @api private 239 */ 240 241function ClassList(el) { 242 if (!el) throw new Error('A DOM element reference is required'); 243 this.el = el; 244 this.list = el.classList; 245} 246 247/** 248 * Add class `name` if not already present. 249 * 250 * @param {String} name 251 * @return {ClassList} 252 * @api public 253 */ 254 255ClassList.prototype.add = function(name){ 256 // classList 257 if (this.list) { 258 this.list.add(name); 259 return this; 260 } 261 262 // fallback 263 var arr = this.array(); 264 var i = index(arr, name); 265 if (!~i) arr.push(name); 266 this.el.className = arr.join(' '); 267 return this; 268}; 269 270/** 271 * Remove class `name` when present, or 272 * pass a regular expression to remove 273 * any which match. 274 * 275 * @param {String|RegExp} name 276 * @return {ClassList} 277 * @api public 278 */ 279 280ClassList.prototype.remove = function(name){ 281 if ('[object RegExp]' == toString.call(name)) { 282 return this.removeMatching(name); 283 } 284 285 // classList 286 if (this.list) { 287 this.list.remove(name); 288 return this; 289 } 290 291 // fallback 292 var arr = this.array(); 293 var i = index(arr, name); 294 if (~i) arr.splice(i, 1); 295 this.el.className = arr.join(' '); 296 return this; 297}; 298 299/** 300 * Remove all classes matching `re`. 301 * 302 * @param {RegExp} re 303 * @return {ClassList} 304 * @api private 305 */ 306 307ClassList.prototype.removeMatching = function(re){ 308 var arr = this.array(); 309 for (var i = 0; i < arr.length; i++) { 310 if (re.test(arr[i])) { 311 this.remove(arr[i]); 312 } 313 } 314 return this; 315}; 316 317/** 318 * Toggle class `name`, can force state via `force`. 319 * 320 * For browsers that support classList, but do not support `force` yet, 321 * the mistake will be detected and corrected. 322 * 323 * @param {String} name 324 * @param {Boolean} force 325 * @return {ClassList} 326 * @api public 327 */ 328 329ClassList.prototype.toggle = function(name, force){ 330 // classList 331 if (this.list) { 332 if ("undefined" !== typeof force) { 333 if (force !== this.list.toggle(name, force)) { 334 this.list.toggle(name); // toggle again to correct 335 } 336 } else { 337 this.list.toggle(name); 338 } 339 return this; 340 } 341 342 // fallback 343 if ("undefined" !== typeof force) { 344 if (!force) { 345 this.remove(name); 346 } else { 347 this.add(name); 348 } 349 } else { 350 if (this.has(name)) { 351 this.remove(name); 352 } else { 353 this.add(name); 354 } 355 } 356 357 return this; 358}; 359 360/** 361 * Return an array of classes. 362 * 363 * @return {Array} 364 * @api public 365 */ 366 367ClassList.prototype.array = function(){ 368 var str = this.el.className.replace(/^\s+|\s+$/g, ''); 369 var arr = str.split(re); 370 if ('' === arr[0]) arr.shift(); 371 return arr; 372}; 373 374/** 375 * Check if class `name` is present. 376 * 377 * @param {String} name 378 * @return {ClassList} 379 * @api public 380 */ 381 382ClassList.prototype.has = 383ClassList.prototype.contains = function(name){ 384 return this.list 385 ? this.list.contains(name) 386 : !! ~index(this.array(), name); 387}; 388 389}); 390require.register("segmentio-extend/index.js", function(exports, require, module){ 391 392module.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}); 407require.register("component-indexof/index.js", function(exports, require, module){ 408module.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}); 416require.register("component-event/index.js", function(exports, require, module){ 417var bind = window.addEventListener ? 'addEventListener' : 'attachEvent', 418 unbind = window.removeEventListener ? 'removeEventListener' : 'detachEvent', 419 prefix = bind !== 'addEventListener' ? 'on' : ''; 420 421/** 422 * Bind `el` event `type` to `fn`. 423 * 424 * @param {Element} el 425 * @param {String} type 426 * @param {Function} fn 427 * @param {Boolean} capture 428 * @return {Function} 429 * @api public 430 */ 431 432exports.bind = function(el, type, fn, capture){ 433 el[bind](prefix + type, fn, capture || false); 434 return fn; 435}; 436 437/** 438 * Unbind `el` event `type`'s callback `fn`. 439 * 440 * @param {Element} el 441 * @param {String} type 442 * @param {Function} fn 443 * @param {Boolean} capture 444 * @return {Function} 445 * @api public 446 */ 447 448exports.unbind = function(el, type, fn, capture){ 449 el[unbind](prefix + type, fn, capture || false); 450 return fn; 451}; 452}); 453require.register("javve-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 463module.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 (collection instanceof Array) return collection 469 if (typeof collection.length != 'number') return [collection] 470 if (typeof collection === '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 } 477 } 478 if (!arr.length) return [] 479 return arr 480} 481 482}); 483require.register("javve-events/index.js", function(exports, require, module){ 484var events = require('event'), 485 toArray = require('to-array'); 486 487/** 488 * Bind `el` event `type` to `fn`. 489 * 490 * @param {Element} el, NodeList, HTMLCollection or Array 491 * @param {String} type 492 * @param {Function} fn 493 * @param {Boolean} capture 494 * @api public 495 */ 496 497exports.bind = function(el, type, fn, capture){ 498 el = toArray(el); 499 for ( var i = 0; i < el.length; i++ ) { 500 events.bind(el[i], type, fn, capture); 501 } 502}; 503 504/** 505 * Unbind `el` event `type`'s callback `fn`. 506 * 507 * @param {Element} el, NodeList, HTMLCollection or Array 508 * @param {String} type 509 * @param {Function} fn 510 * @param {Boolean} capture 511 * @api public 512 */ 513 514exports.unbind = function(el, type, fn, capture){ 515 el = toArray(el); 516 for ( var i = 0; i < el.length; i++ ) { 517 events.unbind(el[i], type, fn, capture); 518 } 519}; 520 521}); 522require.register("javve-get-by-class/index.js", function(exports, require, module){ 523/** 524 * Find all elements with class `className` inside `container`. 525 * Use `single = true` to increase performance in older browsers 526 * when only one element is needed. 527 * 528 * @param {String} className 529 * @param {Element} container 530 * @param {Boolean} single 531 * @api public 532 */ 533 534module.exports = (function() { 535 if (document.getElementsByClassName) { 536 return function(container, className, single) { 537 if (single) { 538 return container.getElementsByClassName(className)[0]; 539 } else { 540 return container.getElementsByClassName(className); 541 } 542 }; 543 } else if (document.querySelector) { 544 return function(container, className, single) { 545 className = '.' + className; 546 if (single) { 547 return container.querySelector(className); 548 } else { 549 return container.querySelectorAll(className); 550 } 551 }; 552 } else { 553 return function(container, className, single) { 554 var classElements = [], 555 tag = '*'; 556 if (container == null) { 557 container = document; 558 } 559 var els = container.getElementsByTagName(tag); 560 var elsLen = els.length; 561 var pattern = new RegExp("(^|\\s)"+className+"(\\s|$)"); 562 for (var i = 0, j = 0; i < elsLen; i++) { 563 if ( pattern.test(els[i].className) ) { 564 if (single) { 565 return els[i]; 566 } else { 567 classElements[j] = els[i]; 568 j++; 569 } 570 } 571 } 572 return classElements; 573 }; 574 } 575})(); 576 577}); 578require.register("javve-get-attribute/index.js", function(exports, require, module){ 579/** 580 * Return the value for `attr` at `element`. 581 * 582 * @param {Element} el 583 * @param {String} attr 584 * @api public 585 */ 586 587module.exports = function(el, attr) { 588 var result = (el.getAttribute && el.getAttribute(attr)) || null; 589 if( !result ) { 590 var attrs = el.attributes; 591 var length = attrs.length; 592 for(var i = 0; i < length; i++) { 593 if (attr[i] !== undefined) { 594 if(attr[i].nodeName === attr) { 595 result = attr[i].nodeValue; 596 } 597 } 598 } 599 } 600 return result; 601} 602}); 603require.register("javve-natural-sort/index.js", function(exports, require, module){ 604/* 605 * Natural Sort algorithm for Javascript - Version 0.7 - Released under MIT license 606 * Author: Jim Palmer (based on chunking idea from Dave Koelle) 607 */ 608 609module.exports = function(a, b, options) { 610 var re = /(^-?[0-9]+(\.?[0-9]*)[df]?e?[0-9]?$|^0x[0-9a-f]+$|[0-9]+)/gi, 611 sre = /(^[ ]*|[ ]*$)/g, 612 dre = /(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/, 613 hre = /^0x[0-9a-f]+$/i, 614 ore = /^0/, 615 options = options || {}, 616 i = function(s) { return options.insensitive && (''+s).toLowerCase() || ''+s }, 617 // convert all to strings strip whitespace 618 x = i(a).replace(sre, '') || '', 619 y = i(b).replace(sre, '') || '', 620 // chunk/tokenize 621 xN = x.replace(re, '\0$1\0').replace(/\0$/,'').replace(/^\0/,'').split('\0'), 622 yN = y.replace(re, '\0$1\0').replace(/\0$/,'').replace(/^\0/,'').split('\0'), 623 // numeric, hex or date detection 624 xD = parseInt(x.match(hre)) || (xN.length != 1 && x.match(dre) && Date.parse(x)), 625 yD = parseInt(y.match(hre)) || xD && y.match(dre) && Date.parse(y) || null, 626 oFxNcL, oFyNcL, 627 mult = options.desc ? -1 : 1; 628 // first try and sort Hex codes or Dates 629 if (yD) 630 if ( xD < yD ) return -1 * mult; 631 else if ( xD > yD ) return 1 * mult; 632 // natural sorting through split numeric strings and default strings 633 for(var cLoc=0, numS=Math.max(xN.length, yN.length); cLoc < numS; cLoc++) { 634 // find floats not starting with '0', string or 0 if not defined (Clint Priest) 635 oFxNcL = !(xN[cLoc] || '').match(ore) && parseFloat(xN[cLoc]) || xN[cLoc] || 0; 636 oFyNcL = !(yN[cLoc] || '').match(ore) && parseFloat(yN[cLoc]) || yN[cLoc] || 0; 637 // handle numeric vs string comparison - number < string - (Kyle Adams) 638 if (isNaN(oFxNcL) !== isNaN(oFyNcL)) { return (isNaN(oFxNcL)) ? 1 : -1; } 639 // rely on string comparison if different types - i.e. '02' < 2 != '02' < '2' 640 else if (typeof oFxNcL !== typeof oFyNcL) { 641 oFxNcL += ''; 642 oFyNcL += ''; 643 }
644 if (oFxNcL < oFyNcL) return -1 * mult; 645 if (oFxNcL > oFyNcL) return 1 * mult; 646 } 647 return 0; 648}; 649 650/* 651var defaultSort = getSortFunction(); 652 653module.exports = function(a, b, options) { 654 if (arguments.length == 1) { 655 options = a; 656 return getSortFunction(options); 657 } else { 658 return defaultSort(a,b); 659 } 660} 661*/ 662}); 663require.register("javve-to-string/index.js", function(exports, require, module){ 664module.exports = function(s) { 665 s = (s === undefined) ? "" : s; 666 s = (s === null) ? "" : s; 667 s = s.toString(); 668 return s; 669}; 670 671}); 672require.register("component-type/index.js", function(exports, require, module){ 673/** 674 * toString ref. 675 */ 676 677var toString = Object.prototype.toString; 678 679/** 680 * Return the type of `val`. 681 * 682 * @param {Mixed} val 683 * @return {String} 684 * @api public 685 */ 686 687module.exports = function(val){ 688 switch (toString.call(val)) { 689 case '[object Date]': return 'date'; 690 case '[object RegExp]': return 'regexp'; 691 case '[object Arguments]': return 'arguments'; 692 case '[object Array]': return 'array'; 693 case '[object Error]': return 'error'; 694 } 695 696 if (val === null) return 'null'; 697 if (val === undefined) return 'undefined'; 698 if (val !== val) return 'nan'; 699 if (val && val.nodeType === 1) return 'element'; 700 701 return typeof val.valueOf(); 702}; 703 704}); 705require.register("list.js/index.js", function(exports, require, module){ 706/* 707ListJS with beta 1.0.0 708By Jonny Strömberg (www.jonnystromberg.com, www.listjs.com) 709*/ 710(function( window, undefined ) { 711"use strict"; 712 713var document = window.document, 714 getByClass = require('get-by-class'), 715 extend = require('extend'), 716 indexOf = require('indexof'); 717 718var List = function(id, options, values) { 719 720 var self = this, 721 init, 722 Item = require('./src/item')(self), 723 addAsync = require('./src/add-async')(self), 724 parse = require('./src/parse')(self); 725 726 init = { 727 start: function() { 728 self.listClass = "list"; 729 self.searchClass = "search"; 730 self.sortClass = "sort"; 731 self.page = 200; 732 self.i = 1; 733 self.items = []; 734 self.visibleItems = []; 735 self.matchingItems = []; 736 self.searched = false; 737 self.filtered = false; 738 self.handlers = { 'updated': [] }; 739 self.plugins = {}; 740 self.helpers = { 741 getByClass: getByClass, 742 extend: extend, 743 indexOf: indexOf 744 }; 745 746 extend(self, options); 747 748 self.listContainer = (typeof(id) === 'string') ? document.getElementById(id) : id; 749 if (!self.listContainer) { return; } 750 self.list = getByClass(self.listContainer, self.listClass, true); 751 752 self.templater = require('./src/templater')(self); 753 self.search = require('./src/search')(self); 754 self.filter = require('./src/filter')(self); 755 self.sort = require('./src/sort')(self); 756 757 this.items(); 758 self.update(); 759 this.plugins(); 760 }, 761 items: function() { 762 parse(self.list); 763 if (values !== undefined) { 764 self.add(values); 765 } 766 }, 767 plugins: function() { 768 for (var i = 0; i < self.plugins.length; i++) { 769 var plugin = self.plugins[i]; 770 self[plugin.name] = plugin; 771 plugin.init(self); 772 } 773 } 774 }; 775 776 777 /* 778 * Add object to list 779 */ 780 this.add = function(values, callback) { 781 if (callback) { 782 addAsync(values, callback); 783 return; 784 } 785 var added = [], 786 notCreate = false; 787 if (values[0] === undefined){ 788 values = [values]; 789 } 790 for (var i = 0, il = values.length; i < il; i++) { 791 var item = null; 792 if (values[i] instanceof Item) { 793 item = values[i]; 794 item.reload(); 795 } else { 796 notCreate = (self.items.length > self.page) ? true : false;
797 item = new Item(values[i], undefined, notCreate); 798 } 799 self.items.push(item); 800 added.push(item); 801 } 802 self.update(); 803 return added; 804 }; 805 806 this.show = function(i, page) { 807 this.i = i; 808 this.page = page; 809 self.update(); 810 return self; 811 }; 812 813 /* Removes object from list. 814 * Loops through the list and removes objects where 815 * property "valuename" === value 816 */ 817 this.remove = function(valueName, value, options) { 818 var found = 0; 819 for (var i = 0, il = self.items.length; i < il; i++) { 820 if (self.items[i].values()[valueName] == value) { 821 self.templater.remove(self.items[i], options); 822 self.items.splice(i,1); 823 il--; 824 i--; 825 found++; 826 } 827 } 828 self.update(); 829 return found; 830 }; 831 832 /* Gets the objects in the list which 833 * property "valueName" === value 834 */ 835 this.get = function(valueName, value) { 836 var matchedItems = []; 837 for (var i = 0, il = self.items.length; i < il; i++) { 838 var item = self.items[i]; 839 if (item.values()[valueName] == value) { 840 matchedItems.push(item); 841 } 842 } 843 return matchedItems; 844 }; 845 846 /* 847 * Get size of the list 848 */ 849 this.size = function() { 850 return self.items.length; 851 }; 852 853 /* 854 * Removes all items from the list 855 */ 856 this.clear = function() { 857 self.templater.clear(); 858 self.items = []; 859 return self; 860 }; 861 862 this.on = function(event, callback) { 863 self.handlers[event].push(callback); 864 return self; 865 }; 866 867 this.off = function(event, callback) { 868 var e = self.handlers[event]; 869 var index = indexOf(e, callback); 870 if (index > -1) { 871 e.splice(index, 1); 872 } 873 return self; 874 }; 875 876 this.trigger = function(event) { 877 var i = self.handlers[event].length; 878 while(i--) { 879 self.handlers[event][i](self); 880 } 881 return self; 882 }; 883 884 this.reset = { 885 filter: function() { 886 var is = self.items, 887 il = is.length; 888 while (il--) { 889 is[il].filtered = false; 890 } 891 return self; 892 }, 893 search: function() { 894 var is = self.items, 895 il = is.length; 896 while (il--) { 897 is[il].found = false; 898 } 899 return self; 900 } 901 }; 902 903 this.update = function() { 904 var is = self.items, 905 il = is.length; 906 907 self.visibleItems = []; 908 self.matchingItems = []; 909 self.templater.clear(); 910 for (var i = 0; i < il; i++) { 911 if (is[i].matching() && ((self.matchingItems.length+1) >= self.i && self.visibleItems.length < self.page)) { 912 is[i].show(); 913 self.visibleItems.push(is[i]); 914 self.matchingItems.push(is[i]); 915 } else if (is[i].matching()) { 916 self.matchingItems.push(is[i]); 917 is[i].hide(); 918 } else { 919 is[i].hide(); 920 } 921 } 922 923 // If no results are found, append a no results message to the list. 924 if (self.visibleItems.length === 0) { 925 var noResultsElement = document.createElement('div'); 926 noResultsElement.className = 'search-list-none-found'; 927 noResultsElement.innerHTML = an_javascript_translation.no_results_found; 928 929 self.list.appendChild(noResultsElement); 930 } 931 932 self.trigger('updated'); 933 return self; 934 }; 935 936 init.start(); 937}; 938 939module.exports = List; 940 941})(window); 942 943}); 944require.register("list.js/src/search.js", function(exports, require, module){ 945var events = require('events'), 946 getByClass = require('get-by-class'), 947 toString = require('to-string'); 948 949module.exports = function(list) { 950 var item, 951 text, 952 columns, 953 searchString, 954 customSearch; 955 956 var prepare = { 957 resetList: function() { 958 list.i = 1; 959 list.templater.clear(); 960 customSearch = undefined; 961 }, 962 setOptions: function(args) { 963 if (args.length == 2 && args[1] instanceof Array) { 964 columns = args[1]; 965 } else if (args.length == 2 && typeof(args[1]) == "function") { 966 customSearch = args[1]; 967 } else if (args.length == 3) { 968 columns = args[1]; 969 customSearch = args[2]; 970 } 971 }, 972 setColumns: function() { 973 columns = (columns === undefined) ? prepare.toArray(list.items[0].values()) : columns; 974 }, 975 setSearchString: function(s) { 976 s = toString(s).toLowerCase(); 977 //console.log(s); 978 //s = s.replace(/[[\]{}(),\\^|]/g, "\\$&"); // Escape regular expression characters 979 //console.log(s); 980 searchString = s; 981 }, 982 toArray: function(values) { 983 var tmpColumn = []; 984 for (var name in values) { 985 tmpColumn.push(name); 986 } 987 return tmpColumn; 988 } 989 }; 990 var search = { 991 list: function() { 992 for (var k = 0, kl = list.items.length; k < kl; k++) { 993 search.item(list.items[k]); 994 } 995 }, 996 item: function(item) { 997 item.found = false;
998 999 var text = []; 1000 for (var j = 0, jl = columns.length; j < jl; j++) { 1001 //console.log(item.values()); 1002 //console.log(columns[j]); 1003 if (columns[j] != "listjs_id") { 1004 text.push(item.values()[columns[j]]); 1005 } 1006 1007 1008 //console.log('false'); 1009 } 1010 1011 //console.log(text); 1012 if (search.values(text.toString())) { 1013 //console.log('true'); 1014 item.found = true; 1015 return; 1016 } 1017 }, 1018 values: function(text) { 1019 // console.log(values); 1020 // console.log(column); 1021 //if (values.hasOwnProperty(column)) { 1022 //text = toString(values[column]).toLowerCase(); 1023/* 1024 if ((searchString !== "") && (text.search(searchString) > -1)) { 1025 return true; 1026 } 1027*/ 1028 1029 if (searchString !== "") { 1030 keywords = (searchString).split(/ |,|\[|\]|\(|\)/); 1031 1032 for (var i = 0; i < keywords.length; i++) { 1033 1034 if (((text).toUpperCase()).indexOf((keywords[i]).toUpperCase()) == -1) { 1035 //console.log(false); 1036 // Return `null` if the term should not be displayed 1037 return false; 1038 1039 } 1040 //console.log(true); 1041 } 1042 1043 return true; 1044 } 1045 1046 1047 1048 // `data.text` is the text that is displayed for the data object 1049 // check if data.text contains all of keywords, if some is missing, return null 1050 1051 //} 1052 return false; 1053 }, 1054 reset: function() { 1055 list.reset.search(); 1056 list.searched = false; 1057 } 1058 }; 1059 1060 var searchMethod = function(str) { 1061 list.trigger('searchStart'); 1062 1063 prepare.resetList(); 1064 prepare.setSearchString(str); 1065 prepare.setOptions(arguments); // str, cols|searchFunction, searchFunction 1066 prepare.setColumns(); 1067 1068 if (searchString === "" ) { 1069 search.reset(); 1070 } else { 1071 list.searched = true; 1072 if (customSearch) { 1073 customSearch(searchString, columns); 1074 } else { 1075 search.list(); 1076 } 1077 } 1078 1079 list.update(); 1080 list.trigger('searchComplete'); 1081 return list.visibleItems; 1082 }; 1083 1084 list.handlers.searchStart = list.handlers.searchStart || []; 1085 list.handlers.searchComplete = list.handlers.searchComplete || []; 1086 1087 events.bind(getByClass(list.listContainer, list.searchClass), 'keyup', function(e) { 1088 var target = e.target || e.srcElement; // IE have srcElement 1089 searchMethod(target.value); 1090 }); 1091 1092 list.helpers.toString = toString; 1093 return searchMethod; 1094}; 1095 1096}); 1097require.register("list.js/src/sort.js", function(exports, require, module){ 1098var naturalSort = require('natural-sort'), 1099 classes = require('classes'), 1100 events = require('events'), 1101 getByClass = require('get-by-class'), 1102 getAttribute = require('get-attribute'); 1103 1104module.exports = function(list) { 1105 list.sortFunction = list.sortFunction || function(itemA, itemB, options) { 1106 options.desc = options.order == "desc" ? true : false; // Natural sort uses this format 1107 return naturalSort(itemA.values()[options.valueName], itemB.values()[options.valueName], options); 1108 }; 1109 1110 var buttons = { 1111 els: undefined, 1112 clear: function() { 1113 for (var i = 0, il = buttons.els.length; i < il; i++) { 1114 classes(buttons.els[i]).remove('asc'); 1115 classes(buttons.els[i]).remove('desc'); 1116 } 1117 }, 1118 getOrder: function(btn) { 1119 var predefinedOrder = getAttribute(btn, 'data-order'); 1120 if (predefinedOrder == "asc" || predefinedOrder == "desc") { 1121 return predefinedOrder; 1122 } else if (classes(btn).has('desc')) { 1123 return "asc"; 1124 } else if (classes(btn).has('asc')) { 1125 return "desc"; 1126 } else { 1127 return "asc"; 1128 } 1129 }, 1130 getInSensitive: function(btn, options) { 1131 var insensitive = getAttribute(btn, 'data-insensitive'); 1132 if (insensitive === "true") { 1133 options.insensitive = true; 1134 } else { 1135 options.insensitive = false;
1136 } 1137 }, 1138 setOrder: function(options) { 1139 for (var i = 0, il = buttons.els.length; i < il; i++) { 1140 var btn = buttons.els[i]; 1141 if (getAttribute(btn, 'data-sort') !== options.valueName) { 1142 continue; 1143 } 1144 var predefinedOrder = getAttribute(btn, 'data-order'); 1145 if (predefinedOrder == "asc" || predefinedOrder == "desc") { 1146 if (predefinedOrder == options.order) { 1147 classes(btn).add(options.order); 1148 } 1149 } else { 1150 classes(btn).add(options.order); 1151 } 1152 } 1153 } 1154 }; 1155 var sort = function() { 1156 list.trigger('sortStart'); 1157 options = {}; 1158 1159 var target = arguments[0].currentTarget || arguments[0].srcElement || undefined; 1160 1161 if (target) { 1162 options.valueName = getAttribute(target, 'data-sort'); 1163 buttons.getInSensitive(target, options); 1164 options.order = buttons.getOrder(target); 1165 } else { 1166 options = arguments[1] || options; 1167 options.valueName = arguments[0]; 1168 options.order = options.order || "asc"; 1169 options.insensitive = (typeof options.insensitive == "undefined") ? true : options.insensitive; 1170 } 1171 buttons.clear(); 1172 buttons.setOrder(options); 1173 1174 options.sortFunction = options.sortFunction || list.sortFunction; 1175 list.items.sort(function(a, b) { 1176 return options.sortFunction(a, b, options); 1177 }); 1178 list.update(); 1179 list.trigger('sortComplete'); 1180 }; 1181 1182 // Add handlers 1183 list.handlers.sortStart = list.handlers.sortStart || []; 1184 list.handlers.sortComplete = list.handlers.sortComplete || []; 1185 1186 buttons.els = getByClass(list.listContainer, list.sortClass); 1187 events.bind(buttons.els, 'click', sort); 1188 list.on('searchStart', buttons.clear); 1189 list.on('filterStart', buttons.clear); 1190 1191 // Helpers 1192 list.helpers.classes = classes; 1193 list.helpers.naturalSort = naturalSort; 1194 list.helpers.events = events; 1195 list.helpers.getAttribute = getAttribute; 1196 1197 return sort; 1198}; 1199 1200}); 1201require.register("list.js/src/item.js", function(exports, require, module){ 1202module.exports = function(list) { 1203 return function(initValues, element, notCreate) { 1204 var item = this; 1205 1206 this._values = {}; 1207 1208 this.found = false; // Show if list.searched == true and this.found == true 1209 this.filtered = false;// Show if list.filtered == true and this.filtered == true 1210 1211 var init = function(initValues, element, notCreate) { 1212 if (element === undefined) { 1213 if (notCreate) { 1214 item.values(initValues, notCreate); 1215 } else { 1216 item.values(initValues); 1217 } 1218 } else { 1219 item.elm = element; 1220 var values = list.templater.get(item, initValues); 1221 item.values(values); 1222 } 1223 }; 1224 this.values = function(newValues, notCreate) { 1225 if (newValues !== undefined) { 1226 for(var name in newValues) { 1227 item._values[name] = newValues[name]; 1228 } 1229 if (notCreate !== true) { 1230 list.templater.set(item, item.values()); 1231 } 1232 } else { 1233 return item._values; 1234 } 1235 }; 1236 this.show = function() { 1237 list.templater.show(item); 1238 }; 1239 this.hide = function() { 1240 list.templater.hide(item); 1241 }; 1242 this.matching = function() { 1243 return ( 1244 (list.filtered && list.searched && item.found && item.filtered) || 1245 (list.filtered && !list.searched && item.filtered) || 1246 (!list.filtered && list.searched && item.found) || 1247 (!list.filtered && !list.searched) 1248 ); 1249 }; 1250 this.visible = function() { 1251 return (item.elm.parentNode == list.list) ? true : false;
1252 }; 1253 init(initValues, element, notCreate); 1254 }; 1255}; 1256 1257}); 1258require.register("list.js/src/templater.js", function(exports, require, module){ 1259var getByClass = require('get-by-class'); 1260 1261var Templater = function(list) { 1262 var itemSource = getItemSource(list.item), 1263 templater = this; 1264 1265 function getItemSource(item) { 1266 if (item === undefined) { 1267 var nodes = list.list.childNodes, 1268 items = []; 1269 1270 for (var i = 0, il = nodes.length; i < il; i++) { 1271 // Only textnodes have a data attribute 1272 if (nodes[i].data === undefined) { 1273 return nodes[i]; 1274 } 1275 } 1276 return null; 1277 } else if (item.indexOf("<") !== -1) { // Try create html element of list, do not work for tables!! 1278 var div = document.createElement('div'); 1279 div.innerHTML = item; 1280 return div.firstChild; 1281 } else { 1282 return document.getElementById(list.item); 1283 } 1284 } 1285 1286 /* Get values from element */ 1287 this.get = function(item, valueNames) { 1288 templater.create(item); 1289 var values = {}; 1290 for(var i = 0, il = valueNames.length; i < il; i++) { 1291 var elm = getByClass(item.elm, valueNames[i], true); 1292 values[valueNames[i]] = elm ? elm.innerHTML : ""; 1293 } 1294 return values; 1295 }; 1296 1297 /* Sets values at element */ 1298 this.set = function(item, values) { 1299 if (!templater.create(item)) { 1300 for(var v in values) { 1301 if (values.hasOwnProperty(v)) { 1302 // TODO speed up if possible 1303 var elm = getByClass(item.elm, v, true); 1304 if (elm) { 1305 /* src attribute for image tag & text for other tags */ 1306 if (elm.tagName === "IMG" && values[v] !== "") { 1307 elm.src = values[v]; 1308 } else { 1309 elm.innerHTML = values[v]; 1310 } 1311 } 1312 } 1313 } 1314 } 1315 }; 1316 1317 this.create = function(item) { 1318 if (item.elm !== undefined) { 1319 return false; 1320 } 1321 /* If item source does not exists, use the first item in list as 1322 source for new items */ 1323 var newItem = itemSource.cloneNode(true); 1324 newItem.removeAttribute('id'); 1325 item.elm = newItem; 1326 templater.set(item, item.values()); 1327 return true; 1328 }; 1329 this.remove = function(item) { 1330 list.list.removeChild(item.elm); 1331 }; 1332 this.show = function(item) { 1333 templater.create(item); 1334 list.list.appendChild(item.elm); 1335 }; 1336 this.hide = function(item) { 1337 if (item.elm !== undefined && item.elm.parentNode === list.list) { 1338 list.list.removeChild(item.elm); 1339 } 1340 }; 1341 this.clear = function() { 1342 /* .innerHTML = ''; fucks up IE */ 1343 if (list.list.hasChildNodes()) { 1344 while (list.list.childNodes.length >= 1) 1345 { 1346 list.list.removeChild(list.list.firstChild); 1347 } 1348 } 1349 }; 1350}; 1351 1352module.exports = function(list) { 1353 return new Templater(list); 1354}; 1355 1356}); 1357require.register("list.js/src/filter.js", function(exports, require, module){ 1358module.exports = function(list) { 1359 1360 // Add handlers 1361 list.handlers.filterStart = list.handlers.filterStart || []; 1362 list.handlers.filterComplete = list.handlers.filterComplete || []; 1363 1364 return function(filterFunction) { 1365 list.trigger('filterStart'); 1366 list.i = 1; // Reset paging 1367 list.reset.filter(); 1368 if (filterFunction === undefined) { 1369 list.filtered = false; 1370 } else { 1371 list.filtered = true; 1372 var is = list.items; 1373 for (var i = 0, il = is.length; i < il; i++) { 1374 var item = is[i]; 1375 if (filterFunction(item)) { 1376 item.filtered = true; 1377 } else { 1378 item.filtered = false; 1379 } 1380 } 1381 }
1382 list.update(); 1383 list.trigger('filterComplete'); 1384 return list.visibleItems; 1385 }; 1386}; 1387 1388}); 1389require.register("list.js/src/add-async.js", function(exports, require, module){ 1390module.exports = function(list) { 1391 return function(values, callback, items) { 1392 var valuesToAdd = values.splice(0, 100); 1393 items = items || []; 1394 items = items.concat(list.add(valuesToAdd)); 1395 if (values.length > 0) { 1396 setTimeout(function() { 1397 addAsync(values, callback, items); 1398 }, 10); 1399 } else { 1400 list.update(); 1401 callback(items); 1402 } 1403 }; 1404}; 1405}); 1406require.register("list.js/src/parse.js", function(exports, require, module){ 1407module.exports = function(list) { 1408 1409 var Item = require('./item')(list); 1410 1411 var getChildren = function(parent) { 1412 var nodes = parent.childNodes, 1413 items = []; 1414 for (var i = 0, il = nodes.length; i < il; i++) { 1415 // Only textnodes have a data attribute 1416 if (nodes[i].data === undefined) { 1417 items.push(nodes[i]); 1418 } 1419 } 1420 return items; 1421 }; 1422 1423 var parse = function(itemElements, valueNames) { 1424 for (var i = 0, il = itemElements.length; i < il; i++) { 1425 list.items.push(new Item(valueNames, itemElements[i])); 1426 } 1427 }; 1428 var parseAsync = function(itemElements, valueNames) { 1429 var itemsToIndex = itemElements.splice(0, 100); // TODO: If < 100 items, what happens in IE etc? 1430 parse(itemsToIndex, valueNames); 1431 if (itemElements.length > 0) { 1432 setTimeout(function() { 1433 init.items.indexAsync(itemElements, valueNames); 1434 }, 10); 1435 } else { 1436 list.update(); 1437 // TODO: Add indexed callback 1438 } 1439 }; 1440 1441 return function() { 1442 var itemsToIndex = getChildren(list.list), 1443 valueNames = list.valueNames; 1444 1445 if (list.indexAsync) { 1446 parseAsync(itemsToIndex, valueNames); 1447 } else { 1448 parse(itemsToIndex, valueNames); 1449 } 1450 }; 1451}; 1452 1453}); 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474require.alias("component-classes/index.js", "list.js/deps/classes/index.js"); 1475require.alias("component-classes/index.js", "classes/index.js"); 1476require.alias("component-indexof/index.js", "component-classes/deps/indexof/index.js"); 1477 1478require.alias("segmentio-extend/index.js", "list.js/deps/extend/index.js"); 1479require.alias("segmentio-extend/index.js", "extend/index.js"); 1480 1481require.alias("component-indexof/index.js", "list.js/deps/indexof/index.js"); 1482require.alias("component-indexof/index.js", "indexof/index.js"); 1483 1484require.alias("javve-events/index.js", "list.js/deps/events/index.js"); 1485require.alias("javve-events/index.js", "events/index.js"); 1486require.alias("component-event/index.js", "javve-events/deps/event/index.js"); 1487 1488require.alias("javve-to-array/index.js", "javve-events/deps/to-array/index.js"); 1489 1490require.alias("javve-get-by-class/index.js", "list.js/deps/get-by-class/index.js"); 1491require.alias("javve-get-by-class/index.js", "get-by-class/index.js"); 1492 1493require.alias("javve-get-attribute/index.js", "list.js/deps/get-attribute/index.js"); 1494require.alias("javve-get-attribute/index.js", "get-attribute/index.js"); 1495 1496require.alias("javve-natural-sort/index.js", "list.js/deps/natural-sort/index.js"); 1497require.alias("javve-natural-sort/index.js", "natural-sort/index.js"); 1498 1499require.alias("javve-to-string/index.js", "list.js/deps/to-string/index.js"); 1500require.alias("javve-to-string/index.js", "list.js/deps/to-string/index.js"); 1501require.alias("javve-to-string/index.js", "to-string/index.js"); 1502require.alias("javve-to-string/index.js", "javve-to-string/index.js"); 1503require.alias("component-type/index.js", "list.js/deps/type/index.js"); 1504require.alias("component-type/index.js", "type/index.js"); 1505if (typeof exports == "object") { 1506 module.exports = require("list.js"); 1507} else if (typeof define == "function" && define.amd) { 1508 define(function(){ return require("list.js"); }); 1509} else { 1510 this["List"] = require("list.js"); 1511}})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.