(function() {
var Konstruktor = function(test) {
return Konstruktor.redirect[typeof test](arguments);
}
Konstruktor.version = '0.3.2a';
Konstruktor.doc = document;
Konstruktor.win = window;
Konstruktor.fragment = Konstruktor.doc.createDocumentFragment();
Konstruktor.method = function(name, fn) {
domKonstruktor.prototype[name] = fn;
}
Konstruktor._cacheTPL = {
queue: [],
query: {},
event: {},
elems: {}
}
Konstruktor._cache = Konstruktor._cacheTPL;
Konstruktor.cache = function(dir, name, val, noCache) {
return ! val ? Konstruktor._cache[dir][name] || null: (noCache ? val: (Konstruktor._cache[dir][name] = val));
}
Konstruktor.cacheClear = function(dir, name) {
return (!dir ? (Konstruktor._cache = Konstruktor._cacheTPL) : !name ? (Konstruktor._cache[dir] = Konstruktor._cacheTPL[dir]) : (Konstruktor._cache[dir][name] = null));
}
Konstruktor.info = function(ie) {
var d = Konstruktor.doc,
w = Konstruktor.win,
ua = navigator.userAgent.toLowerCase(),
qsel = !!d.querySelectorAll,
csel = !!d.getElementsByClassName,
ff = !!window.Iterator && !!d.addEventListener,
ff3 = csel && ff,
ie5 = ie == 5,
ie6 = (ie == 6 && d.compatMode && d.all && !!d.readyState),
ie7 = (ie == 7 && d.documentElement && typeof d.documentElement.style.maxHeight != "undefined"),
ie8 = (ie == 8 && qsel),
wk = /webkit\/(\d+)/i.test(ua),
opera = (!ie && !!w.opera && w.opera.toString() === "[object Opera]"),
opVer = !!opera ? ua.substr(ua.indexOf('opera') + 6, 1) : null,
opera9 = (opVer == 9);
return {
ff: ff,
ff3: ff3,
ie: ie,
ie6: ie6,
ie7: ie7,
ie8: ie8,
ie5: ie5,
opera: opera,
opera9: opera9,
wk: wk,
querySelector: qsel,
getByClass: csel
};
} (
/*@cc_on @_jscript_version * 10 % 10 @*/
);
Konstruktor.redirect = {
'function': function(fn) {
var doc = Konstruktor.doc;
if (!Konstruktor.info.ie && doc.addEventListener) return doc.addEventListener('DOMContentLoaded', fn, false);
if (Konstruktor._cache.queue.push(fn).length > 1) return;
var fns = Konstruktor._cache.queue,
i = fns.length;
if (Konstruktor.info.ie)(function() {
try {
doc.documentElement.doScroll('left');
while (i) fns[--i]();
Konstruktor.cacheClear('queue');
} catch(e) {
setTimeout(arguments.callee, 0);
}
})();
else if (Konstruktor.info.wk) var t = setInterval(function() {
if (/^(loaded|complete)$/.test(doc.readyState)) {
clearInterval(t);
while (i) fns[--i]();
Konstruktor.cacheClear('queue');
}
},
0);
else $(window).bind('load', fn);
},
string: function(expr, root, cache) {
return expr.charAt(0) == '<' ? domKonstruktor.create(expr, root) : new domKonstruktor(expr, root, cache);
},
object: function(o) {
return o.nodeType ? new domKonstruktor(o, null, null, true) : o.konstruktor ? o: null;
},
undefined: function() { // Че нить пиздатое придумать
}
}
function log(s) {
console.log(s)
}
function getAttribute(el, name) {
if (!name || !el) return null;
var r = el[name] || el['attributes'][name];
if (r.nodeType) return r.nodeValue;
return r;
}
function getAttribute2(e, a) {
if (a === "class" || a === "className") return e.className;
return e[a] || e.getAttribute(a);
}
var domKonstruktor = function(selector, root, noCache, justNode) {
this.konstruktor = 1;
if (justNode) return this.sync([selector]);
if (typeof selector == 'string') {
root = root ? root.nodeType ? [root] : root.konstruktor ? root.elements: root: [Konstruktor.doc];
selector = selector.replace(/\s+/g, ' ').replace(/\s?([>+~])\s?/g, ' $1').replace(/\s?(\+\d+\))/g, '$1');
this.elements = domKonstruktor.find(selector, root, noCache);
this.length = this.elements.length;
this.selector = selector;
return this;
} else {
return this.sync(selector);
}
}
domKonstruktor.Expr = {
single: /^((\*|\w+)?([.%#])?([a-z0-9\-_]+)?(.*))$/,
///(?:^((\*|\w+)?([:.#]+)?(\w+|[\-])?(\[(\w+)=([a-z0-9*^.$]+)\])?(([<:*>~])(.+))?$)?)/,
// For min ver;
tag: /^(\*|\w+)$/,
cl: /^\.([a-z0-9\-_]+)$/,
id: /^\#([a-z0-9\-_]+)$/,
attrs: /^(\[(\w+)=([a-z0-9*^.$]+)\])*$/,
mod: /([\|\^\$\~\*\=\!]+)/,
prefix: /^([>:+~=!])$/,
modificator: /^([a-z_-]+)?\s*(\(\s*['"]*\s*(.*)\)$)?/
}
domKonstruktor.exceptions = {
'class': 'className',
'float': 'styleFloat'
}
domKonstruktor.normalizeToken = function(token) {
return token;
}
domKonstruktor.parseToken = function(expr) {
var match, r = {},
pre = expr.charAt(0);
if (/^([>:+~=!])$/.test(pre)) {
r.prefix = pre;
expr = expr.substr(1);
} else r.prefix = '_';
if ((match = domKonstruktor.Expr.single.exec(expr))) {
var aCount = 0;
r.tag = match[2] ? match[2].toUpperCase() : null; // tag
var jor = match[3]; // # || .
r.id = (jor && jor == '#') ? match[4] : null;
r.cl = (jor && jor == '.') ? match[4] : null;
r.name = (jor && jor == '%') ? match[4] : null;
r.jor = jor || '_'; //var _cl = !!domKonstruktor.info.Class;
if (match[5]) { // params etc
match = match[5].replace(':', "_:_").split('_');
if (match[0]) {
var attrs = match[0].split(']'),
_attrs = [],
k = attrs.length;
while (--k) {
if (attrs[k]) {
var g = attrs[k].split('[')[1],
mod = domKonstruktor.Expr['mod'].test(g) ? RegExp.$1: '!';
g = g.split(mod);
var key = g[0],
value = /^['"]?([a-z0-9_-]+)['"]?$/.test(g[1]) ? RegExp.$1: null,
isClass = (key === 'class' || key == 'className');
if (isClass && value && mod == '=') {
r.cl = value;
continue;
}
key = isClass ? 'className': key;
_attrs.push([mod, key, value]); ++aCount;
}
}
r.attrs = aCount > 0 ? _attrs: null;
}
if (match[1] && match[2] && match[2].match(/^([a-z_-]+)?\s*(\(\s*['"]*\s*(.*)\)$)?/)) {
r.mod = match[1];
r.modParam = RegExp.$3 // || null;
r.modificator = RegExp.$1 || r.modParam;
} else r.modificator = null;
}
r.parsed = 1;
}
return r;
}
domKonstruktor.checkAttrs = function(el, attrs) {
var k = -1,
a;
if (attrs.length == 1 && (a = attrs[0])) return domKonstruktor.attr[a[0]](el, a[1], a[2]);
while (a = attrs[++k]) {
if (!domKonstruktor.attr[a[0]](el, a[1], a[2])) return false;
}
return true;
}
domKonstruktor.attr = {
'!': function(n, a) {
return !! n[a];
},
'!=': function(n, a, v) {
return ! n[a] || n[a] !== v;
},
'=': function(n, a, v) {
return n[a] == v
},
'^=': function(n, a, v) {
return n[a].indexOf(v) == 0;
},
'$=': function(n, a, v) {
var at = n[a];
return at && at.indexOf(v) == (at.length - v.length);
},
'*=': function(n, a, v) {
return n[a].indexOf(v) > -1;
}
}
domKonstruktor.quickFilter = function(node, tag, id, cl, attrs, mod, modParam, index) {
return ((!mod || domKonstruktor.modificators[mod](node, modParam, index)) && (!id || id == node.id) && (!cl || node.className == cl) // @todo ��������....
&& (!tag || (tag == '*' || (tag == node.tagName))) && (!attrs || domKonstruktor.checkAttrs(node, attrs)));
}
domKonstruktor.quickNotFilter = function(node, tag, id, cl, attrs, mod) {
return ((!id || (!node.id || id != node.id)) && (!cl || node.className != cl) // @todo ��������....
&& (!tag || (tag != '*' || (tag != node.tagName))) && (!attrs || !domKonstruktor.checkAttrs(node, attrs)) && (!mod || !domKonstruktor.modificators[mod](node, modParam, index)));
}
domKonstruktor.quickRet = function(token, root) {
/*if (document.querySelectorAll) {
token = domKonstruktor.normalizeToken(token);
return document.querySelectorAll(token);
}*/
var exprs = ['tag', 'id', 'cl'],
k = -1,
expr;
while (expr = exprs[++k]) {
if (domKonstruktor.Expr[expr].test(token)) return domKonstruktor.quickRet[expr](RegExp.$1, root);
}
return null;
}
domKonstruktor.quickRet['id'] = function(id, root) {
if (!root || (root.length == 1 && root[0] == document)) return [document.getElementById(id)];
var node, k = -1,
a = [];
while (node = root[++k]) {
var els = node.getElementsByName('*'),
i = -1,
el;
while (el = els[++i]) {
if (el.id == id) a.push(el);
}
}
return a;
}
domKonstruktor.quickRet['cl'] = !!Konstruktor.info.getByClass ?
function(cl, root) {
if (!root) return document.getElementsByClassName(cl);
if (root.nodeType) return root.getElementsByClassName(cl);
if (root && root.length == 1) return root[0].getElementsByClassName(cl);
var str = cl + 'len',
n = -1,
a = [],
node,
c = 0,
len = Konstruktor.cache('query', str) || Konstruktor.cache('query', str, Konstruktor.doc.getElementsByClassName(cl).length);
while (node = root[++n]) {
if (!node._) {
var children = node.getElementsByClassName(cl);
if (len == children.length) return children;
var j = -1,
child;
while ((child = children[++j]) && !child._) {
child._ = 1;
a[c++] = child;
}
if (len == a.length) break;
}
}
while (c) a[--c]._ = null;
return a;
}: function(cl, root) {
var n = -1,
a = [],
node,
c = 0;
if (!root) root = [document.body];
while (node = root[++n]) {
if (!node._) {
var children = node.getElementsByTagName('*'),
j = -1,
child;
while ((child = children[++j]) && !child._) { // @todo ��������..
if (child['className'] && child['className'].split(cl).length > 1) {
child._ = 1;
a[c++] = child;
}
}
}
}
while (c) a[--c]._ = null;
return a;
}
domKonstruktor.quickRet['tag'] = function(tag, root) {
if (!root) return Konstruktor.doc.getElementsByTagName(tag);
if (root.nodeType) return root.getElementsByTagName(tag);
if (root && root.length == 1) return root[0].getElementsByTagName(tag);
var n = -1,
a = [],
node,
c = 0,
test = Konstruktor.doc.getElementsByTagName(tag).length;
while (node = root[++n]) {
if (!node._) {
var j = -1,
child, children = node.getElementsByTagName(tag);
if (test == children.length) return children;
while ((child = children[++j]) && !child._) {
child._ = 1;
a[c++] = child;
}
if (test == a.length) break;
}
}
while (c) a[--c]._ = null;
return a;
}
domKonstruktor.find = function(Selector, Root, noCache) {
var try_cache = Konstruktor.cache('query', Selector); // Quick return cached elems
if (try_cache) return try_cache;
var quickRet = domKonstruktor.quickRet(Selector, Root); // Or just tag, id or class if we can
if (quickRet) return Konstruktor.cache('query', Selector, quickRet, noCache);
var tokens = Selector.split(' '),
cacheToken = [],
n = 0,
token,
elements = Root;
while (token = tokens[n++]) {
cacheToken.push(token);
var _token = cacheToken.join(' '); // Try to find cached token
if ((try_cache = Konstruktor.cache('query', _token)) && (elements = try_cache)) continue; // It can be a simple selector such as tag, class or id
if ((quickRet = domKonstruktor.quickRet(token, elements)) && (elements = Konstruktor.cache('query', _token, quickRet, noCache))) continue; // If it is not simple and not cached, try to parse it
var el = domKonstruktor.parseToken(token);
if (el && el.parsed) { // Init links
var tag = el['tag'] || '*',
modParam = el['modParam'],
cl = el['cl'],
id = el['id'],
a,
name = el['name'],
prefix = el['prefix'],
attrs = el['attrs'] || null,
modificator = el['modificator'];
if ((!cl || !Konstruktor.info.getByClass) && !id && !name) a = domKonstruktor.seekAndDestroy[prefix](elements, tag, id, cl, attrs, modificator, modParam, domKonstruktor.children['tag'], tag);
else if (id && !cl && (!name || !Konstruktor.info.ie)) {
var e = document.getElementById(id);
a = (e && domKonstruktor.quickFilter(e, tag, id, cl, attrs, modificator, modParam)) ? [e] : [];
} else if (cl && !id && !name) a = domKonstruktor.seekAndDestroy[prefix](elements, tag, id, cl, attrs, modificator, modParam, domKonstruktor.children['cl'], cl);
else if (name) a = domKonstruktor.seekAndDestroy[prefix](elements, tag, id, cl, attrs, modificator, modParam, domKonstruktor.children['name'], name);
elements = Konstruktor.cache('query', _token, a, noCache);
}
}
return elements || [];
}
domKonstruktor.children = {
'tag': function(node, tag) {
return node.getElementsByTagName(tag);
},
'cl': function(node, cl) {
return node.getElementsByClassName(cl);
},
'name': function(node, name) {
return node.getElementsByName(name);
},
'id': function(node, set) {
var els = node.getElementsByName(set[0] || '*'),
i = -1,
el,
id = set[1],
a = [];
while (el = els[++i]) {
if (el.id == id) a.push(el);
}
return a;
}
}
domKonstruktor.seekAndDestroy = {
'_': function(elements, tag, id, cl, attrs, modificator, modParam, fn, p) {
var j = -1,
node, c = 0,
a = [],
gt = (modificator == 'gt' || modificator == 'gte'),
lt = (modificator == 'lt' || modificator == 'lte'),
single = (modificator == 'eq' || modificator == 'first'),
childMod = modificator == 'nth-child',
dIndex = gt ? (modParam - 1) : ( - 1);
while (node = elements[++j]) {
if (!node._) {
var children = fn(node, p),
i = dIndex,
child;
while ((child = children[++i]) && !child._ && (!lt || i <= modParam)) {
if (domKonstruktor.quickFilter(child, tag, id, cl, attrs, modificator, modParam, i)) {
if (single) return [child];
child._ = 1;
a[c++] = child;
}
}
}
}
while (c) a[--c]._ = null;
return a;
},
'>': function(elements, tag, id, cl, attrs, modificator, modParam, fn, p) {
var j = -1,
node, c = 0,
a = [],
gt = (modificator == 'gt' || modificator == 'gte'),
lt = (modificator == 'lt' || modificator == 'lte'),
single = (modificator == 'eq' || modificator == 'first' || modificator == 'last'),
dIndex = gt ? (modParam - 1) : ( - 1);
while (node = elements[++j]) { //for ( var child = node.firstChild, i = dIndex; child; child = child.nextSibling ) {
var child = node.firstChild,
i = dIndex;
while (child = domKonstruktor.dir['next'](child)) {
if (!child._
/* && child.nodeType == 1*/
/*@cc_on && child.parentNode === node @*/
&& (!lt || i <= modParam) && domKonstruktor.quickFilter(child, tag, id, cl, attrs, modificator, modParam, ++i)) {
if (single) return [child];
child._ = 1;
a[c++] = child;
}
}
}
while (c) a[--c]._ = null;
return a;
},
'~': function(elements, tag, id, cl, attrs, modificator, modParam) {
var j = -1,
node, c = 0,
a = [],
gt = (modificator == 'gt' || modificator == 'gte'),
lt = (modificator == 'lt' || modificator == 'lte'),
single = (modificator == 'eq' || modificator == 'first' || modificator == 'last'),
dIndex = gt ? (modParam - 1) : ( - 1);
while (node = elements[++j]) {
if (!node._) {
var i = dIndex;
while ((node = domKonstruktor.dir['next'](node)) && !node._) {
if (domKonstruktor.quickFilter(node, tag, id, cl, attrs, modificator, modParam, ++i) && (!lt || i <= modParam)) {
if (single) return [child];
node._ = 1;
a[c++] = node;
}
}
}
}
while (c) a[--c]._ = null;
return a;
},
'+': function(elements, tag, id, cl, attrs, modificator, modParam) {
var j = -1,
node, c = 0,
a = [],
gt = (modificator == 'gt' || modificator == 'gte'),
lt = (modificator == 'lt' || modificator == 'lte'),
single = (modificator == 'eq' || modificator == 'first' || modificator == 'last'),
dIndex = gt ? (modParam - 1) : ( - 1);
while (node = elements[++j]) {
var i = dIndex;
node = domKonstruktor.dir['next'](node);
if (node && !node._ && domKonstruktor.quickFilter(node, tag, id, cl, attrs, modificator, modParam, ++i) && (!lt || i <= modParam)) {
if (single) return [child];
node._ = 1;
a[c++] = node;
}
}
while (c) a[--c]._ = null;
return a;
}
}
domKonstruktor.dir = {
'next': function(e) {
while (e && (e = e.nextSibling) && e.nodeType != 1) {}
return e || 0;
},
'prev': function(e) {
while (e && (e = e.previousSibling) && e.nodeType != 1) {}
return e || 0;
}
}
domKonstruktor.modificators = {
'first-child': function(node) {
return domKonstruktor.dir['prev'](node) ? false: true;
},
'last-child': function(node) {
return domKonstruktor.dir['next'](node) ? false: true;
},
'only-child': function(node) {
return (!domKonstruktor.dir['next'](node) && !domKonstruktor.dir['prev'](node));
},
'nth-child': function(node, expr) {
var mod = expr,
j = 0,
el = node.parentNode.firstChild;
if (!el) return 0;
if (el.nodeType != 1 && !(el = domKonstruktor.dir['next'](el))) return 0;
var p, a, b, o, fn;
if (expr != 'even' && expr != 'odd') {
p = /^(\d+)(n[+]?)?(\d+)?$/.exec(expr);
a = p[1];
o = p[2];
b = p[3];
mod = 'pos';
}
fn = domKonstruktor['nth-child'][mod];
while ((el = domKonstruktor.dir['next'](el)) && !fn(++j, a, o, b)) {
if (el == node) return 1;
}
return 0;
},
'not': function(node, n) {
var c = domKonstruktor.parseToken(n);
return c ? domKonstruktor.quickNotFilter(node, c.tag, c.id, c.cl, c.attrs, c.modificator, c.modParam) : 0;
},
'has': function(node, selector) {
return domKonstruktor.find(selector, [node], true).length > 0;
},
'empty': function(node) {
return node.firstChild ? 0 : 1;
},
'parent': function(node) {
return !! node.firstChild;
},
'contains': function(node, n) {
return ((node.innerText || node.textContent || "").indexOf(n) > -1);
},
'eq': function(undefined, n, i) {
return n == i;
},
'nth': function(undefined, n, i) {
return n == i;
},
'lt': function(undefined, n, i) {
return n > i;
},
'lte': function(undefined, n, i) {
return n >= i;
},
'gt': function(undefined, n, i) {
return n < i;
},
'gte': function(undefined, n, i) {
return n <= i;
},
'even': function(undefined, n, i) {
return i % 2 === 0;
},
'odd': function(undefined, n, i) {
return i % 2 === 1;
},
'first': function(undefined, n, i) {
return i == 0;
},
'checked': function(node) {
return !! node['checked'];
},
'submit': function(node) {
return node['type'] === 'submit';
},
'text': function(node) {
return node['type'] === 'text';
},
'password': function(node) {
return node['type'] === 'password';
},
'disabled': function(node) {
return !! node['disabled'];
},
'enabled': function(node) {
return !! node['enabled'];
}
}
domKonstruktor['nth-child'] = {
'pos': function(i, a, o, b) {
return ! a ? 0 : (!o ? i == a: !b ? i % a == 0 : (i + b) % a == 0);
},
'even': function(i) {
return i % 2 == 1;
},
'odd': function(i) {
return i % 2 == 0;
}
}
/**
* End of search engine ;)
**/
domKonstruktor.create = function(html, convert) {
var cached;
if (!convert && (cached = Konstruktor.cache('elems', html))) return cached;
var div = document.createElement('div');
div.innerHTML = html; //return div.childNodes;
var els = div.childNodes,
i = -1,
e, f = Konstruktor.fragment;
while (e = els[++i]) f.appendChild(e);
return ! convert ? Konstruktor.cache('elems', html, new domKonstruktor(f)) : f; //return Konstruktor.cache('elems', html, ret);
}
Konstruktor.method = domKonstruktor.prototype = { // Core prototype fn
each: function(fn) {
var m = this.length,
i = -1;
while (++i < m) fn.call(this.elements[i], i, this.elements[i]);
return this;
},
get: function(i) {
return i ? this.elements[i] : this.elements;
},
sync: function(o, i) {
if (i) while (i) o[--i]._ = null;
this.elements = o;
this.length = o ? o.length: 0;
return this;
},
/**
* nodewalkers && filters
**/
sibling: function(expr, dir, all) {
var _this = this,
c = expr ? domKonstruktor.parseToken(expr) : null,
a = [],
k = 0,
fn = domKonstruktor.dir[dir],
check = null;
return _this.each(function(i) {
while (el = fn(this) && !check) {
if (!c || domKonstruktor.quickFilter(el, c.tag, c.id, c.cl, c.attrs, c.modificator, c.modParam)) {
el._ = 1;
a[k++] = el;
if (!all) check = 1;
}
}
}).sync(a, k);
},
next: function(expr) {
return this.sibling(expr, 'next');
},
prev: function(expr) {
return this.sibling(expr, 'prev');
},
nextAll: function(expr) {
return this.sibling(expr, 'next', true);
},
prevAll: function(expr) {
return this.sibling(expr, 'prev', true);
},
pos: function(n, gt, lt, s) {
if (!gt && !lt && n > -1) return this.sync([this.elements[n]]);
var a = [],
c = 0;
return this.each(function(i, el) {
if (!lt || (!s ? i <= lt: i < lt) && (!lt || (!s ? i >= gt: i > gt))) a[c++] = el;
}).sync(a);
},
eq: function(n) {
return this.pos(n);
},
last: function(n) {
return this.pos(this.length - 1);
},
first: function(n) {
return this.pos(0);
},
gt: function(n) {
return this.pos(null, n, null, true);
},
gte: function(n) {
return this.pos(null, n, null);
},
lt: function(n) {
return this.pos(null, null, n, true);
},
lte: function(n) {
return this.pos(null, null, n);
},
find: function(expr) {
var a = domKonstruktor.find(expr, this.elements, true);
return this.sync(a);
},
children: function(expr) {
var c = expr ? domKonstruktor.parseToken(expr) : null,
a = !c ? domKonstruktor.seekAndDestroy['>'](this.elements) : domKonstruktor.seekAndDestroy['>'](this.elements, c.tag, c.id, c.cl, c.attrs, c.modificator, c.modParam);
return this.sync(a);
},
getParents: function(expr, all) {
var c = expr ? domKonstruktor.parseToken(expr) : null,
a = [],
k = 0,
check = null;
return this.each(function() {
var el;
while (!check && (el = this.parentNode) && el != doc) {
if (!el._ && (!c || domKonstruktor.quickFilter(el, c.tag, c.id, c.cl, c.attrs, c.modificator, c.modParam))) {
el._ = 1;
a[k++] = el;
if (!all) check = 1;
}
}
}).sync(a, k);
},
parent: function() {
return this.getParents();
},
parents: function(expr) {
return this.getParents(expr, true);
},
not: function(old) {
if (typeof old == 'object') {
old = old.elements || old,
cur = this.elements;
var temp = [],
a = [],
k = -1,
el,
key,
c = 0;
while (el = old[++k]) {
key = el.tagName + el.id + el.className + el.name + el.style;
if (temp[key]) {
temp[key]++;
} else {
temp[key] = 1;
}
}
k = -1;
while (el = cur[++k]) {
key = el.tagName + el.id + el.className + el.name + el.style;
if (temp[key]) {
if (temp[key] == 0) {
return false;
} else {
temp[key]--;
}
} else a[c++] = el;
}
}
return this.sync(a);
},
unique: function() {
var temp = [],
a = [],
c = 0;
return this.each(function() {
var key = this.tagName + this.id + this.className + this.name + this.style;
if (!temp[key]) {
a[c++] = this;
temp[key] = 1;
}
}).sync(a);
},
DOM: function(html, callback) {
var isStr = typeof html === 'string';
Konstruktor.cacheClear('query', this.selector);
var el = isStr ? domKonstruktor.create(html, true) : this.elements[0];
return this.each(function() {
callback.call(this, el);
});
},
append: function(elem) {
return this.DOM(elem,
function(child) {
this.appendChild(child)
});
},
prepend: function(elem) {
return this.DOM(elem,
function(el) {
this.insertBefore(el, this.firstChild);
});
},
before: function(elem) {
return this.DOM(elem,
function(el) {
this.parentNode.insertBefore(el, this);
});
},
after: function(elem) {
return this.DOM(elem,
function(el) {
this.parentNode.insertBefore(el, domKonstruktor.dir['next'](this));
});
}
}
window[!window.$ ? '$': !window._$ ? '_$': !window.$$ ? '$$': 'Konstruktor'] = Konstruktor;
if (!window.Konstruktor) window.Konstruktor = Konstruktor;
})();
//------------------------------------------------------------------------------
function tf(name, fn, loops) {
var s = new Date().getTime(),
undefined;
loops = loops || 1000;
while (--loops) fn.call(null, loops, undefined);
var e = new Date().getTime() - s,
r = name + ': ' + e + 'мс';
if (window.console) console.info(r);
else alert(r);
}