author | Clipperz <info@clipperz.com> | 2013-01-31 13:42:04 (UTC) |
---|---|---|
committer | Clipperz <info@clipperz.com> | 2013-01-31 13:42:04 (UTC) |
commit | 07d0357beef5d9328a2dd8d07ad7b39c87ac55e4 (patch) (side-by-side diff) | |
tree | f7a4aed8848302db153c2a211f8e58b944eb4c5b /frontend/beta/js/Clipperz/YUI/DomQuery.js | |
parent | 767a3dcf48b6ac911c088af5dd7738a728eb6b99 (diff) | |
download | clipperz-07d0357beef5d9328a2dd8d07ad7b39c87ac55e4.zip clipperz-07d0357beef5d9328a2dd8d07ad7b39c87ac55e4.tar.gz clipperz-07d0357beef5d9328a2dd8d07ad7b39c87ac55e4.tar.bz2 |
Updated Copyright claims
- updated reference dates;
- removed reference to Community Edition;
- normalized logging using Clipperz.log[Warn|Error|Debug]
Diffstat (limited to 'frontend/beta/js/Clipperz/YUI/DomQuery.js') (more/less context) (show whitespace changes)
-rw-r--r-- | frontend/beta/js/Clipperz/YUI/DomQuery.js | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/frontend/beta/js/Clipperz/YUI/DomQuery.js b/frontend/beta/js/Clipperz/YUI/DomQuery.js index 4ad4193..6e54b6c 100644 --- a/frontend/beta/js/Clipperz/YUI/DomQuery.js +++ b/frontend/beta/js/Clipperz/YUI/DomQuery.js @@ -1,406 +1,404 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the online password manager. For further information about its features and functionalities please refer to http://www.clipperz.com. -* Clipperz Community Edition is free software: you can redistribute - it and/or modify it under the terms of the GNU Affero General Public - License as published by the Free Software Foundation, either version - 3 of the License, or (at your option) any later version. +* Clipperz is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. -* Clipperz Community Edition is distributed in the hope that it will - be useful, but WITHOUT ANY WARRANTY; without even the implied - warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +* Clipperz is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. * You should have received a copy of the GNU Affero General Public - License along with Clipperz Community Edition. If not, see - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ /* * yui-ext 0.40 * Copyright(c) 2006, Jack Slocum. */ /** * @class Ext.DomQuery * Provides high performance selector/xpath processing by compiling queries into reusable functions. * New pseudo classes and matchers can be plugged. It works on HTML and XML documents (if a content node is passed in). * @singleton */ Ext.DomQuery = function(){ var cache = {}, simpleCache = {}, valueCache = {}; var nonSpace = /\S/; var trimRe = /^\s*(.*?)\s*$/; var tplRe = /\{(\d+)\}/g; var modeRe = /^(\s?[\/>]\s?|\s|$)/; var clsRes = {}; function child(p, index){ var i = 0; var n = p.firstChild; while(n){ if(n.nodeType == 1){ i++; if(i == index){ return n; } } n = n.nextSibling; } return null; }; function next(d){ var n = d.nextSibling; while(n && n.nodeType != 1){ n = n.nextSibling; } return n; }; function prev(d){ var n = d.previousSibling; while(n && n.nodeType != 1){ n = n.previousSibling; } return n; }; function clean(d){ var n = d.firstChild, ni = -1; while(n){ var nx = n.nextSibling; if(n.nodeType == 3 && !nonSpace.test(n.nodeValue)){ d.removeChild(n); }else{ n.nodeIndex = ++ni; } n = nx; } return this; }; function byClassName(c, a, v){ if(!v){ return c; } var re = clsRes[v]; if(!re){ re = new RegExp('(?:^|\\s)(?:' + v + ')(?:\\s|$)'); clsRes[v] = re; } var r = []; for(var i = 0, ci; ci = c[i]; i++){ if(re.test(ci.className)){ r[r.length] = ci; } } return r; }; function convert(c){ if(c.slice){ return c; } var r = []; for(var i = 0, l = c.length; i < l; i++){ r[r.length] = c[i]; } return r; }; function attrValue(n, attr){ if(!n.tagName && typeof n.length != 'undefined'){ n = n[0]; } if(!n){ return null; } if(attr == 'for'){ return n.htmlFor; } if(attr == 'class' || attr == 'className'){ return n.className; } return n.getAttribute(attr) || n[attr]; }; function getNodes(ns, mode, tagName){ var result = [], cs; if(!ns){ return result; } mode = mode ? mode.replace(trimRe, '$1') : ''; tagName = tagName || '*'; if(ns.tagName || ns == document){ ns = [ns]; } if(mode != '/' && mode != '>'){ for(var i = 0, ni; ni = ns[i]; i++){ cs = ni.getElementsByTagName(tagName); result = concat(result, cs); } }else{ for(var i = 0, ni; ni = ns[i]; i++){ var cn = ni.getElementsByTagName(tagName); for(var j = 0, cj; cj = cn[j]; j++){ if(cj.parentNode == ni){ result[result.length] = cj; } } } } return result; }; function concat(a, b){ if(b.slice){ return a.concat(b); } for(var i = 0, l = b.length; i < l; i++){ a[a.length] = b[i]; } return a; } function byTag(cs, tagName){ if(cs.tagName || cs == document){ cs = [cs]; } if(!tagName){ return cs; } var r = []; tagName = tagName.toLowerCase(); for(var i = 0, ci; ci = cs[i]; i++){ if(ci.nodeType == 1 && ci.tagName.toLowerCase()==tagName){ r[r.length] = ci; } } return r; }; function byId(cs, attr, id){ if(cs.tagName || cs == document){ cs = [cs]; } if(!id){ return cs; } var r = []; for(var i = 0, l = cs.length; i < l; i++){ var ci = cs[i]; if(ci && ci.id == id){ r[r.length] = ci; } } return r; }; function byAttribute(cs, attr, value, op, custom){ var r = [], st = custom=='{'; var f = Ext.DomQuery.operators[op]; for(var i = 0, l = cs.length; i < l; i++){ var a; if(st){ a = Ext.DomQuery.getStyle(cs[i], attr); } else if(attr == 'class' || attr == 'className'){ a = cs[i].className; }else if(attr == 'for'){ a = cs[i].htmlFor; }else{ a = cs[i].getAttribute(attr); } if((f && f(a, value)) || (!f && a)){ r[r.length] = cs[i]; } } return r; }; function byPseudo(cs, name, value){ return Ext.DomQuery.pseudos[name](cs, value); }; // This is for IE MSXML which does not support expandos. // IE runs the same speed using setAttribute, however FF slows way down // and Safari completely fails so they need to continue to use expandos. // Branched at load time for faster execution. var isIE = window.ActiveXObject; var addAttr = isIE ? function(n, a, v){ n.setAttribute(a, v); } : function(n, a, v){ n[a] = v; }; var getAttr = isIE ? function(n, a){ return n.getAttribute(a); } : function(n, a){ return n[a]; }; var clearAttr = isIE ? function(n, a){ n.removeAttribute(a); } : function(n, a, v){ delete n[a]; }; function nodup(cs){ if(!cs.length){ return cs; } addAttr(cs[0], '_nodup', true); var r = [cs[0]]; for(var i = 1, len = cs.length; i < len; i++){ var c = cs[i]; if(!getAttr(c, '_nodup')){ addAttr(c, '_nodup', true); r[r.length] = c; } } for(var i = 0, len = cs.length; i < len; i++){ clearAttr(cs[i], '_nodup'); } return r; } function quickDiff(c1, c2){ if(!c1.length){ return c2; } for(var i = 0, len = c1.length; i < len; i++){ addAttr(c1[i], '_qdiff', true); } var r = []; for(var i = 0, len = c2.length; i < len; i++){ if(!getAttr(c2[i], '_qdiff')){ r[r.length] = c2[i]; } } for(var i = 0, len = c1.length; i < len; i++){ clearAttr(c1[i], '_qdiff'); } return r; } function quickId(ns, mode, root, id){ if(ns == root){ var d = root.ownerDocument || root; return d.getElementById(id); } ns = getNodes(ns, mode, '*'); return byId(ns, null, id); } return { getStyle : function(el, name){ return YAHOO.util.Dom.getStyle(el, name); }, /** * Compiles a selector/xpath query into a reusable function. The returned function * takes one parameter "root" (optional), which is the context node from where the query should start. * @param {String} selector The selector/xpath query * @param {String} type (optional) Either 'select' (the default) or 'simple' for a simple selector match * @return {Function} */ compile : function(path, type){ // strip leading slashes while(path.substr(0, 1)=='/'){ path = path.substr(1); } type = type || 'select'; var fn = ['var f = function(root){\n var mode; var n = root || document;\n']; var q = path, mode, lq; var tk = Ext.DomQuery.matchers; var tklen = tk.length; var mm; while(q && lq != q){ lq = q; var tm = q.match(/^(#)?([\w-\*]+)/); if(type == 'select'){ if(tm){ if(tm[1] == '#'){ fn[fn.length] = 'n = quickId(n, mode, root, "'+tm[2]+'");'; }else{ fn[fn.length] = 'n = getNodes(n, mode, "'+tm[2]+'");'; } q = q.replace(tm[0], ''); }else{ fn[fn.length] = 'n = getNodes(n, mode, "*");'; } }else{ if(tm){ if(tm[1] == '#'){ fn[fn.length] = 'n = byId(n, null, "'+tm[2]+'");'; }else{ fn[fn.length] = 'n = byTag(n, "'+tm[2]+'");'; } q = q.replace(tm[0], ''); } } while(!(mm = q.match(modeRe))){ var matched = false; for(var j = 0; j < tklen; j++){ var t = tk[j]; var m = q.match(t.re); if(m){ fn[fn.length] = t.select.replace(tplRe, function(x, i){ return m[i]; }); q = q.replace(m[0], ''); matched = true; break; } } // prevent infinite loop on bad selector if(!matched){ throw 'Error parsing selector, parsing failed at "' + q + '"'; } } if(mm[1]){ fn[fn.length] = 'mode="'+mm[1]+'";'; q = q.replace(mm[1], ''); } } fn[fn.length] = 'return nodup(n);\n}'; eval(fn.join('')); return f; }, /** * Selects a group of elements. * @param {String} selector The selector/xpath query * @param {Node} root (optional) The start of the query (defaults to document). * @return {Array} */ select : function(path, root, type){ if(!root || root == document){ root = document; } if(typeof root == 'string'){ root = document.getElementById(root); } var paths = path.split(','); var results = []; for(var i = 0, len = paths.length; i < len; i++){ var p = paths[i].replace(trimRe, '$1'); if(!cache[p]){ cache[p] = Ext.DomQuery.compile(p); if(!cache[p]){ throw p + ' is not a valid selector'; } } |