142
St
startsInvasion / files
startsInvasion / libs / node_modules / qwery / mobile / qwery-mobile.js
1.7 KB
1!function (context, doc, win) { 2 3 var classOnly = /^\.([\w\-]+)$/, 4 html = doc.documentElement, 5 isAncestor = 'compareDocumentPosition' in html ? 6 function (element, container) { 7 return (container.compareDocumentPosition(element) & 16) == 16; 8 } : 9 function (element, container) { 10 container = container == doc || container == window ? html : container; 11 return container !== element && container.contains(element); 12 }; 13 14 function array(ar) { 15 return [].slice.call(ar, 0); 16 } 17 18 function isNode(el) { 19 return (el && el.nodeType && (el.nodeType == 1 || el.nodeType == 9)) || el === window; 20 } 21 22 function uniq(ar) { 23 var a = [], i, j; 24 label: 25 for (i = 0; i < ar.length; i++) { 26 for (j = 0; j < a.length; j++) { 27 if (a[j] == ar[i]) { 28 continue label; 29 } 30 } 31 a[a.length] = ar[i]; 32 } 33 return a; 34 } 35 36 function qwery(selector, _root, m) { 37 var root = (typeof _root == 'string') ? qwery(_root)[0] : (_root || doc); 38 if (!root || !selector) { 39 return []; 40 } 41 if (doc.getElementsByClassName && selector == 'string' && (m = selector.match(classOnly))) { 42 return array((root).getElementsByClassName(m[1])); 43 } 44 if (selector == win || selector == doc) { 45 selector = selector == doc ? doc : win; 46 return !_root ? [selector] : [null]; 47 } 48 if (isNode(selector)) { 49 return !root || (isAncestor(selector, root)) ? [selector] : []; 50 } 51 return array((root).querySelectorAll(selector)); 52 } 53 54 55 qwery.uniq = uniq; 56 var oldQwery = context.qwery; 57 qwery.noConflict = function () { 58 context.qwery = oldQwery; 59 return this; 60 }; 61 62 context['qwery'] = qwery; 63 64}(this, document, window);