142
St
startsInvasion / files
startsInvasion / libs / node_modules / qwery / integration / ender.js
19.7 KB
1/*! 2 * Ender: open module JavaScript framework 3 * copyright Dustin Diaz & Jacob Thornton 2011 (@ded @fat) 4 * https://ender.no.de 5 * License MIT 6 * Build: ender build domready bonzo 7 */ 8!function (context) { 9 10 function aug(o, o2) { 11 for (var k in o2) { 12 k != 'noConflict' && k != '_VERSION' && (o[k] = o2[k]); 13 } 14 return o; 15 } 16 17 function boosh(s, r) { 18 var els; 19 if (ender._select && typeof s == 'string' || s.nodeName || s.length && 'item' in s) { //string || node || nodelist 20 els = ender._select(s, r); 21 els.selector = s; 22 } else { 23 els = isFinite(s.length) ? s : [s]; 24 } 25 return aug(els, boosh); 26 } 27 28 function ender(s, r) { 29 return boosh(s, r); 30 } 31 32 aug(ender, { 33 _VERSION: '0.1.8', 34 ender: function (o, chain) { 35 aug(chain ? boosh : ender, o); 36 } 37 }); 38 39 var old = context.$; 40 ender.noConflict = function () { 41 context.$ = old; 42 return this; 43 }; 44 45 (typeof module !== 'undefined') && module.exports && (module.exports = ender); 46 context['ender'] = context['$'] = ender; 47 48}(this); 49!function () { var exports = {}, module = { exports: exports }; !function (doc) { 50 var loaded = 0, fns = [], ol, f = false, 51 testEl = doc.createElement('a'), 52 domContentLoaded = 'DOMContentLoaded', 53 addEventListener = 'addEventListener', 54 onreadystatechange = 'onreadystatechange'; 55 56 /^loade|c/.test(doc.readyState) && (loaded = 1); 57 58 function flush() { 59 loaded = 1; 60 for (var i = 0, l = fns.length; i < l; i++) { 61 fns[i](); 62 } 63 } 64 doc[addEventListener] && doc[addEventListener](domContentLoaded, function fn() { 65 doc.removeEventListener(domContentLoaded, fn, f); 66 flush(); 67 }, f); 68 69 70 testEl.doScroll && doc.attachEvent(onreadystatechange, (ol = function ol() { 71 if (/^c/.test(doc.readyState)) { 72 doc.detachEvent(onreadystatechange, ol); 73 flush(); 74 } 75 })); 76 77 var domReady = testEl.doScroll ? 78 function (fn) { 79 self != top ? 80 !loaded ? 81 fns.push(fn) : 82 fn() : 83 !function () { 84 try { 85 testEl.doScroll('left'); 86 } catch (e) { 87 return setTimeout(function() { 88 domReady(fn); 89 }, 50); 90 } 91 fn(); 92 }(); 93 } : 94 function (fn) { 95 loaded ? fn() : fns.push(fn); 96 }; 97 98 (typeof module !== 'undefined') && module.exports ? 99 (module.exports = {domReady: domReady}) : 100 (window.domReady = domReady); 101 102}(document); $.ender(module.exports); }.call($); 103/*! 104 * bonzo.js - copyright @dedfat 2011 105 * https://github.com/ded/bonzo 106 * Follow our software http://twitter.com/dedfat 107 * MIT License 108 */ 109!function (context) { 110 111 var doc = context.document, 112 html = doc.documentElement, 113 query = null, 114 byTag = 'getElementsByTagName', 115 specialAttributes = /^checked|value|selected$/, 116 specialTags = /select|map|fieldset|table|tbody|tr|colgroup/i, 117 tagMap = { select: 'option', table: 'tbody', tr: 'td' }, 118 stateAttributes = /^checked|selected$/, 119 ie = /msie/i.test(navigator.userAgent), 120 uidList = [], 121 uuids = 0, 122 digit = /^-?\d+$/, 123 px = 'px', 124 // commonly used methods 125 setAttribute = 'setAttribute', 126 getAttribute = 'getAttribute', 127 trimReplace = /(^\s*|\s*$)/g, 128 unitless = { lineHeight: 1, zoom: 1, zIndex: 1, opacity: 1 }; 129 130 function classReg(c) { 131 return new RegExp("(^|\\s+)" + c + "(\\s+|$)"); 132 } 133 134 function each(ar, fn, scope) { 135 for (var i = 0, l = ar.length; i < l; i++) { 136 fn.call(scope || ar[i], ar[i], i, ar); 137 } 138 return ar; 139 } 140 141 var trim = String.prototype.trim ? 142 function (s) { 143 return s.trim(); 144 } : 145 function (s) { 146 return s.replace(trimReplace, ''); 147 }; 148 149 function camelize(s) { 150 return s.replace(/-(.)/g, function (m, m1) { 151 return m1.toUpperCase(); 152 }); 153 } 154 155 function is(node) { 156 return node && node.nodeName && node.nodeType == 1; 157 } 158 159 function some(ar, fn, scope) { 160 for (var i = 0, j = ar.length; i < j; ++i) { 161 if (fn.call(scope, ar[i], i, ar)) { 162 return true; 163 } 164 } 165 return false; 166 } 167 168 var getStyle = doc.defaultView && doc.defaultView.getComputedStyle ? 169 function (el, property) { 170 var value = null; 171 if (property == 'float') { 172 property = 'cssFloat'; 173 } 174 var computed = doc.defaultView.getComputedStyle(el, ''); 175 computed && (value = computed[camelize(property)]); 176 return el.style[property] || value; 177 178 } : (ie && html.currentStyle) ? 179 180 function (el, property) { 181 property = camelize(property); 182 property = property == 'float' ? 'styleFloat' : property; 183 184 if (property == 'opacity') { 185 var val = 100; 186 try { 187 val = el.filters['DXImageTransform.Microsoft.Alpha'].opacity; 188 } catch (e1) { 189 try { 190 val = el.filters('alpha').opacity; 191 } catch (e2) {} 192 } 193 return val / 100; 194 } 195 var value = el.currentStyle ? el.currentStyle[property] : null; 196 return el.style[property] || value; 197 } : 198 199 function (el, property) { 200 return el.style[camelize(property)]; 201 }; 202 203 function insert(target, host, fn) { 204 var i = 0, self = host || this, r = []; 205 each(normalize(query ? query(target) : target), function (t) { 206 each(self, function (el) { 207 var n = el.cloneNode(true); 208 fn(t, n); 209 r[i] = n; 210 i++; 211 }); 212 }, this); 213 each(r, function (e, i) { 214 self[i] = e; 215 }); 216 self.length = i; 217 return self; 218 } 219 220 function xy(el, x, y) { 221 var $el = bonzo(el), 222 style = $el.css('position'), 223 offset = $el.offset(), 224 rel = 'relative', 225 isRel = style == rel, 226 delta = [parseInt($el.css('left'), 10), parseInt($el.css('top'), 10)]; 227 228 if (style == 'static') { 229 $el.css('position', rel); 230 style = rel; 231 } 232 233 isNaN(delta[0]) && (delta[0] = isRel ? 0 : el.offsetLeft); 234 isNaN(delta[1]) && (delta[1] = isRel ? 0 : el.offsetTop); 235 236 x !== null && (el.style.left = x - offset.left + delta[0] + 'px'); 237 y !== null && (el.style.top = y - offset.top + delta[1] + 'px'); 238 239 } 240 241 function _bonzo(elements) { 242 this.length = 0; 243 this.original = elements; 244 if (elements) { 245 elements = typeof elements !== 'string' && 246 !elements.nodeType && 247 typeof elements.length !== 'undefined' ? 248 elements : 249 [elements]; 250 this.length = elements.length; 251 for (var i = 0; i < elements.length; i++) { 252 this[i] = elements[i]; 253 } 254 } 255 } 256 257 _bonzo.prototype = { 258 259 each: function (fn, scope) { 260 return each(this, fn, scope); 261 }, 262 263 map: function (fn, reject) { 264 var m = [], n; 265 for (var i = 0; i < this.length; i++) { 266 n = fn.call(this, this[i]); 267 reject ? (reject(n) && m.push(n)) : m.push(n); 268 } 269 return m; 270 }, 271 272 first: function () { 273 return bonzo(this[0]); 274 }, 275 276 last: function () { 277 return bonzo(this[this.length - 1]); 278 }, 279 280 html: function (h, text) { 281 var method = text ? 282 html.textContent == null ? 283 'innerText' : 284 'textContent' : 285 'innerHTML', m; 286 function append(el, tag) { 287 while (el.firstChild) { 288 el.removeChild(el.firstChild); 289 } 290 each(normalize(h, tag), function (node) { 291 el.appendChild(node); 292 }); 293 } 294 return typeof h !== 'undefined' ? 295 this.each(function (el) { 296 (m = el.tagName.match(specialTags)) ? 297 append(el, m[0]) : 298 (el[method] = h); 299 }) : 300 this[0] ? this[0][method] : ''; 301 }, 302 303 text: function (text) { 304 return this.html(text, 1); 305 }, 306 307 addClass: function (c) { 308 return this.each(function (el) { 309 this.hasClass(el, c) || (el.className = trim(el.className + ' ' + c)); 310 }, this); 311 }, 312 313 removeClass: function (c) { 314 return this.each(function (el) { 315 this.hasClass(el, c) && (el.className = trim(el.className.replace(classReg(c), ' '))); 316 }, this); 317 }, 318 319 hasClass: function (el, c) { 320 return typeof c == 'undefined' ? 321 some(this, function (i) { 322 return classReg(el).test(i.className); 323 }) : 324 classReg(c).test(el.className); 325 }, 326 327 toggleClass: function (c, condition) { 328 if (typeof condition !== 'undefined' && !condition) { 329 return this; 330 } 331 return this.each(function (el) { 332 this.hasClass(el, c) ? 333 (el.className = trim(el.className.replace(classReg(c), ' '))) : 334 (el.className = trim(el.className + ' ' + c)); 335 }, this); 336 }, 337 338 show: function (type) { 339 return this.each(function (el) { 340 el.style.display = type || ''; 341 }); 342 }, 343 344 hide: function (elements) { 345 return this.each(function (el) { 346 el.style.display = 'none'; 347 }); 348 }, 349 350 append: function (node) { 351 return this.each(function (el) { 352 each(normalize(node), function (i) { 353 el.appendChild(i); 354 }); 355 }); 356 }, 357 358 prepend: function (node) { 359 return this.each(function (el) { 360 var first = el.firstChild; 361 each(normalize(node), function (i) { 362 el.insertBefore(i, first); 363 }); 364 }); 365 }, 366 367 appendTo: function (target, host) { 368 return insert.call(this, target, host, function (t, el) { 369 t.appendChild(el); 370 }); 371 }, 372 373 prependTo: function (target, host) { 374 return insert.call(this, target, host, function (t, el) { 375 t.insertBefore(el, t.firstChild); 376 }); 377 }, 378 379 next: function () { 380 return this.related('nextSibling'); 381 }, 382 383 previous: function () { 384 return this.related('previousSibling'); 385 }, 386 387 related: function (method) { 388 return this.map( 389 function (el) { 390 el = el[method]; 391 while (el && el.nodeType !== 1) { 392 el = el[method]; 393 } 394 return el || 0; 395 }, 396 function (el) { 397 return el; 398 } 399 ); 400 }, 401 402 before: function (node) { 403 return this.each(function (el) { 404 each(bonzo.create(node), function (i) { 405 el.parentNode.insertBefore(i, el); 406 }); 407 }); 408 }, 409 410 after: function (node) { 411 return this.each(function (el) { 412 each(bonzo.create(node), function (i) { 413 el.parentNode.insertBefore(i, el.nextSibling); 414 }); 415 }); 416 }, 417 418 insertBefore: function (target, host) { 419 return insert.call(this, target, host, function (t, el) { 420 t.parentNode.insertBefore(el, t); 421 }); 422 }, 423 424 insertAfter: function (target, host) { 425 return insert.call(this, target, host, function (t, el) { 426 var sibling = t.nextSibling; 427 if (sibling) { 428 t.parentNode.insertBefore(el, sibling); 429 } 430 else { 431 t.parentNode.appendChild(el); 432 } 433 }); 434 }, 435 436 css: function (o, v) { 437 // is this a request for just getting a style? 438 if (v === undefined && typeof o == 'string') { 439 return getStyle(this[0], o); 440 } 441 var iter = o; 442 if (typeof o == 'string') { 443 iter = {}; 444 iter[o] = v; 445 } 446 447 if (ie && iter.opacity) { 448 // oh this 'ol gamut 449 iter.filter = 'alpha(opacity=' + (iter.opacity * 100) + ')'; 450 // give it layout 451 iter.zoom = o.zoom || 1; 452 delete iter.opacity; 453 } 454 455 if (v = iter['float']) { 456 // float is a reserved style word. w3 uses cssFloat, ie uses styleFloat 457 ie ? (iter.styleFloat = v) : (iter.cssFloat = v); 458 delete iter['float']; 459 } 460 461 var fn = function (el, p, v) { 462 for (var k in iter) { 463 if (iter.hasOwnProperty(k)) { 464 v = iter[k]; 465 // change "5" to "5px" - unless you're line-height, which is allowed 466 (p = camelize(k)) && digit.test(v) && !(p in unitless) && (v += px); 467 el.style[p] = v; 468 } 469 } 470 }; 471 return this.each(fn); 472 }, 473 474 offset: function (x, y) { 475 if (x || y) { 476 return this.each(function (el) { 477 xy(el, x, y); 478 }); 479 } 480 var el = this[0]; 481 var width = el.offsetWidth; 482 var height = el.offsetHeight; 483 var top = el.offsetTop; 484 var left = el.offsetLeft; 485 while (el = el.offsetParent) { 486 top = top + el.offsetTop; 487 left = left + el.offsetLeft; 488 } 489 490 return { 491 top: top, 492 left: left, 493 height: height, 494 width: width 495 }; 496 }, 497 498 attr: function (k, v) { 499 var el = this[0]; 500 return typeof v == 'undefined' ? 501 specialAttributes.test(k) ? 502 stateAttributes.test(k) && typeof el[k] == 'string' ? 503 true : el[k] : el[getAttribute](k) : 504 this.each(function (el) { 505 k == 'value' ? (el.value = v) : el[setAttribute](k, v); 506 }); 507 }, 508 509 val: function (s) { 510 return (typeof s == 'string') ? this.attr('value', s) : this[0].value; 511 }, 512 513 removeAttr: function (k) { 514 return this.each(function (el) { 515 el.removeAttribute(k); 516 }); 517 }, 518 519 data: function (k, v) { 520 var el = this[0]; 521 if (typeof v === 'undefined') { 522 el[getAttribute]('data-node-uid') || el[setAttribute]('data-node-uid', ++uuids); 523 var uid = el[getAttribute]('data-node-uid'); 524 uidList[uid] || (uidList[uid] = {}); 525 return uidList[uid][k]; 526 } else { 527 return this.each(function (el) { 528 el[getAttribute]('data-node-uid') || el[setAttribute]('data-node-uid', ++uuids); 529 var uid = el[getAttribute]('data-node-uid'); 530 var o = {}; 531 o[k] = v; 532 uidList[uid] = o; 533 }); 534 } 535 }, 536 537 remove: function () { 538 return this.each(function (el) { 539 el.parentNode && el.parentNode.removeChild(el); 540 }); 541 }, 542 543 empty: function () { 544 return this.each(function (el) { 545 while (el.firstChild) { 546 el.removeChild(el.firstChild); 547 } 548 }); 549 }, 550 551 detach: function () { 552 return this.map(function (el) { 553 return el.parentNode.removeChild(el); 554 }); 555 }, 556 557 scrollTop: function (y) { 558 return scroll.call(this, null, y, 'y'); 559 }, 560 561 scrollLeft: function (x) { 562 return scroll.call(this, x, null, 'x'); 563 } 564 }; 565 566 function normalize(node, tag) { 567 return typeof node == 'string' ? bonzo.create(node, tag) : is(node) ? [node] : node; 568 } 569 570 function scroll(x, y, type) { 571 var el = this[0]; 572 if (x == null && y == null) { 573 return (isBody(el) ? getWindowScroll() : { x: el.scrollLeft, y: el.scrollTop })[type]; 574 } 575 if (isBody(el)) { 576 window.scrollTo(x, y); 577 } else { 578 x != null && (el.scrollLeft = x); 579 y != null && (el.scrollTop = y); 580 } 581 return this; 582 } 583 584 function isBody(element) { 585 return element === window || (/^(?:body|html)$/i).test(element.tagName); 586 } 587 588 function getWindowScroll() { 589 return { x: window.pageXOffset || html.scrollLeft, y: window.pageYOffset || html.scrollTop }; 590 } 591 592 function bonzo(els, host) { 593 return new _bonzo(els, host); 594 } 595 596 bonzo.setQueryEngine = function (q) { 597 query = q; 598 delete bonzo.setQueryEngine; 599 }; 600 601 bonzo.aug = function (o, target) { 602 for (var k in o) { 603 o.hasOwnProperty(k) && ((target || _bonzo.prototype)[k] = o[k]); 604 } 605 }; 606 607 bonzo.create = function (node, tag) { 608 return typeof node == 'string' ? 609 function () { 610 var t = tag ? tagMap[tag.toLowerCase()] : null; 611 var el = doc.createElement(t || 'div'), els = []; 612 if (tag) { 613 var bitches = node.match(new RegExp("<" + t + ">.+?<\\/" + t + ">", "g")); 614 each(bitches, function (m) { 615 m = m.replace(/<(.+)>(.+?)<\/\1>/, '$2'); 616 var bah = doc.createElement(t); 617 bah.appendChild(doc.createDocumentFragment(m)); 618 el.appendChild(bah); 619 }); 620 } else { 621 el.innerHTML = node; 622 } 623 var nodes = el.childNodes; 624 el = el.firstChild; 625 els.push(el); 626 while (el = el.nextSibling) { 627 (el.nodeType == 1) && els.push(el); 628 } 629 return els; 630 631 }() : is(node) ? [node.cloneNode(true)] : []; 632 }; 633 634 bonzo.doc = function () { 635 var w = html.scrollWidth, 636 h = html.scrollHeight, 637 vp = this.viewport(); 638 return { 639 width: Math.max(w, vp.width), 640 height: Math.max(h, vp.height) 641 }; 642 }; 643 644 bonzo.firstChild = function (el) { 645 for (var c = el.childNodes, i = 0, j = (c && c.length) || 0, e; i < j; i++) { 646 if (c[i].nodeType === 1) { 647 e = c[j = i]; 648 } 649 } 650 return e; 651 }; 652 653 bonzo.viewport = function () { 654 var h = self.innerHeight, 655 w = self.innerWidth; 656 ie && (h = html.clientHeight) && (w = html.clientWidth); 657 return { 658 width: w, 659 height: h 660 }; 661 }; 662 663 bonzo.isAncestor = 'compareDocumentPosition' in html ? 664 function (container, element) { 665 return (container.compareDocumentPosition(element) & 16) == 16; 666 } : 'contains' in html ? 667 function (container, element) { 668 return container !== element && container.contains(element); 669 } : 670 function (container, element) { 671 while (element = element.parentNode) { 672 if (element === container) { 673 return true; 674 } 675 } 676 return false; 677 }; 678 679 var old = context.bonzo; 680 bonzo.noConflict = function () { 681 context.bonzo = old; 682 return this; 683 }; 684 context['bonzo'] = bonzo; 685 686}(this);!function ($) { 687 688 var b = bonzo; 689 b.setQueryEngine($); 690 $.ender(b); 691 $.ender(b(), true); 692 $.ender({ 693 create: function (node) { 694 return $(b.create(node)); 695 } 696 }); 697 698 function indexOf(ar, val) { 699 for (var i = 0; i < ar.length; i++) { 700 if (ar[i] === val) { 701 return i; 702 } 703 } 704 return -1; 705 } 706 707 function uniq(ar) { 708 var a = [], i, j; 709 label: 710 for (i = 0; i < ar.length; i++) { 711 for (j = 0; j < a.length; j++) { 712 if (a[j] == ar[i]) { 713 continue label; 714 } 715 } 716 a[a.length] = ar[i]; 717 } 718 return a; 719 } 720 $.ender({ 721 parents: function (selector, closest) { 722 var collection = $(selector), j, k, p, r = []; 723 for (j = 0, k = this.length; j < k; j++) { 724 p = this[j]; 725 while (p = p.parentNode) { 726 if (indexOf(collection, p) !== -1) { 727 r.push(p); 728 if (closest) break; 729 } 730 } 731 } 732 return $(uniq(r)); 733 }, 734 735 closest: function (selector) { 736 return this.parents(selector, true); 737 }, 738 739 first: function () { 740 return $(this[0]); 741 }, 742 743 last: function () { 744 return $(this[this.length - 1]); 745 }, 746 747 next: function () { 748 return $(b(this).next()); 749 }, 750 751 previous: function () { 752 return $(b(this).previous()); 753 }, 754 755 appendTo: function (t) { 756 return b(this.selector).appendTo(t, this); 757 }, 758 759 prependTo: function (t) { 760 return b(this.selector).prependTo(t, this); 761 }, 762 763 insertAfter: function (t) { 764 return b(this.selector).insertAfter(t, this); 765 }, 766 767 insertBefore: function (t) { 768 return b(this.selector).insertBefore(t, this); 769 }, 770 771 siblings: function () { 772 var i, l, p, r = []; 773 for (i = 0, l = this.length; i < l; i++) { 774 p = this[i]; 775 while (p = p.previousSibling) { 776 p.nodeType == 1 && r.push(p); 777 } 778 p = this[i]; 779 while (p = p.nextSibling) { 780 p.nodeType == 1 && r.push(p); 781 } 782 } 783 return $(r); 784 }, 785 786 children: function () { 787 var el, r = []; 788 for (i = 0, l = this.length; i < l; i++) { 789 if (!(el = b.firstChild(this[i]))) { 790 continue; 791 } 792 r.push(el); 793 while (el = el.nextSibling) { 794 el.nodeType == 1 && r.push(el); 795 } 796 } 797 return $(uniq(r)); 798 }, 799 800 height: function (v) { 801 return v ? this.css('height', v) : parseInt(this.css('height'), 10); 802 }, 803 804 width: function (v) { 805 return v ? this.css('width', v) : parseInt(this.css('width'), 10); 806 } 807 }, true); 808 809}(ender || $);