-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjs-core.min.js
6 lines (6 loc) · 17.7 KB
/
js-core.min.js
1
2
3
4
5
6
/* js-core JavaScript framework, version 2.8.1 (minified)
Copyright (c) 2009 Dmitry Korobkin
Released under the MIT License.
More information: http://www.js-core.ru/
*/
(function(g,h,l,m,o,p){m.forEach=function(a,b,c){var d=a.length,i=-1;if(d!==p){while(++i<d)if(b.call(c,a[i],i,a,d)===false)break}else for(var e in a)if(a.hasOwnProperty(e))if(b.call(c,e,a[e],a)===false)break;return a};m.extend=function(c,d){this.forEach(d,function(a,b){c[a]=b});return c};m.extend(m,{ie:o,cache:{},id:function(a){return typeof a=='string'?this.cache[a]||(this.cache[a]=h.getElementById(a)):a},create:function(a){return typeof a=='string'?h.createElement(a):a},insert:function(a,b,c){return a.insertBefore(this.create(b),c)},bind:g.addEventListener?function(a,b,c){a.addEventListener(b,c,false)}:function(a,b,c){a.attachEvent('on'+b,c)},unbind:g.removeEventListener?function(a,b,c){a.removeEventListener(b,c,false)}:function(a,b,c){a.detachEvent('on'+b,c)},isEmpty:function(a){var b=true;m.forEach(a,function(){return b=false});return b},isNumber:function(a){return!isNaN(a*1)},handlers:{guid:1,fid:1,createListener:function(d){return function(c){m.forEach(m.handlers[d].events[(c||(c=g.event)).type],function(a,b){if(b.call(this,c)===false)m.preventDefault(c)},m.handlers[d].link)}}},attrs:{htmlFor:'for',className:'class'},toArray:function(a){if(typeof a=='string'){var i=-1,j=0,array=a.split(' '),length=array.length;a=[];while(++i<length)if(array[i])a[j++]=array[i]}return a},ready:function(){var c,list=[],i=-1;return function(a){if(a)c?a():list.push(a);else if(!c){c=true;var b=list.length;while(++i<b)list[i]();list=null}}}(),context:function(b,c){return function _func(a){return b.call(c,a)}},parse:function(a){var b=h.createElement('div');b.innerHTML=a;return new this(b.firstChild)},n:function(a){return new this(h.createElement(a))},tag:function(a){return new m(h).child(a,true)},find:function(a,b){return new m(h).find(a,b)},findAttr:function(a,b,c){return new m(h).findAttr(a,b,c)},findClass:function(a,b){return new m(h).findClass(a,b)},makeArray:o?function(a){var i=-1,length=a.length,array=[];while(++i<length)array[i]=a[i];return array}:function(a){return Array.prototype.slice.call(a)},list:function(a,b){if(this.list)return new this.list(a,b);if(b===false)this.items=a||[];else{var i=-1,j=0,k=0,length=a.length;this.items=[];while(++i<length)if(a[i].nodeType==1&&(b?b.call(a[i],j++):true))this.items[k++]=a[i]}},timer:function(a,b,c){if(this.timer)return new this.timer(a,b,c);m.extend(this,{time:a,func:b,context:c,enabled:false})},preventDefault:o?function(a){a.returnValue=false}:function(a){a.preventDefault()},stopPropagation:o?function(a){a.cancelBubble=true}:function(a){a.stopPropagation()},stop:function(a){m.preventDefault(a);m.stopPropagation(a)},target:function(b){return function(a){return a[b]}}(o?'srcElement':'target'),relatedTarget:o?function(a){return a.fromElement===a.srcElement?a.toElement:a.fromElement}:function(a){return a.relatedTarget},mouseButton:function(b,c){return function(a){return a[b]<2?1:a[b]==c?3:2}}(o?'button':'which',o?4:2),trim:String.prototype.trim?function(a){return a.trim()}:function(a){return a.replace(/^\s+|\s+$/g,'')},trimLeft:String.prototype.trimLeft?function(a){return a.trimLeft()}:function(a){return a.replace(/^\s+/,'')},trimRight:String.prototype.trimRight?function(a){return a.trimRight()}:function(a){return a.replace(/\s+$/,'')},computedStyle:o?function(a){return a.currentStyle}:function(a){return h.defaultView.getComputedStyle(a,null)}});(function(b){if(o){m.pageX=function(a){return a.clientX+b('Left')};m.pageY=function(a){return a.clientY+b('Top')}}else{m.pageX=function(a){return a.pageX};m.pageY=function(a){return a.pageY}}})(function(a){return(l['scroll'+a]||0)-(l['client'+a]||0)});m.prototype={parent:function(a){var b=this.node.parentNode;if(a){a=a.toUpperCase();do if(b.tagName==a)break;while(b=b.parentNode)}return new m(b)},append:function(a){return new m(this.node.appendChild(m.create(a)))},prepend:function(a){return new m(m.insert(this.node,a,this.node.firstChild))},after:function(a){return new m(m.insert(this.node.parentNode,a,this.node.nextSibling))},before:function(a){return new m(m.insert(this.node.parentNode,a,this.node))},appendTo:function(a){(a=new m(a)).node.appendChild(this.node);return a},prependTo:function(a){m.insert((a=new m(a)).node,this.node,a.node.firstChild);return a},insertAfter:function(a){var b=m.id(a);return new m(m.insert(b.parentNode,this.node,b.nextSibling))},insertBefore:function(a){var b=m.id(a);return new m(m.insert(b.parentNode,this.node,b))},clone:function(d,e){d=d!==false;e=e!==false;var f=d?this.child(true).add(this.node):new m.list([this.node]),clone,guid,handler,data={};f.each(function(b){guid=this.guid;this.guid=null;if(guid&&m.handlers[guid]){m.forEach(m.handlers[guid].events,function(a){m.unbind(this,a,m.handlers[guid].listener)},this);data[guid]=b}});clone=new m(this.node.cloneNode(d));f=d?clone.child(true).add(clone.node):new m.list([clone.node]);m.forEach(data,function(b,c){(handler=m.handlers[b]).link.guid=b;m.forEach(handler.events,function(a){m.bind(this.link,a,this.listener)},handler);if(e)f.get(c).copyHandlers(handler.link)});return clone},replace:function(a){a=this.before(a);this.remove();return a},wrap:o?function(a,b){return new m(this.node.applyElement(m.create(a),b))}:function(b,c){if(c==='inside'){var d=h.createDocumentFragment();m.forEach(m.makeArray(this.node.childNodes),function(a){d.appendChild(a)});return new m(d).appendTo(this.append(b).node)}else return this.appendTo(this.before(b).node)},el:function(a){return a?this.replace(m.id(a)):this.node},empty:function(){this.child(true).each('remove',false);while(this.node.firstChild)this.node.removeChild(this.node.firstChild);return this},remove:function(a){if(a!==false)this.empty();m.clear(this.unbind().node).parentNode.removeChild(this.node);return this},html:function(a){if(a!==p){this.empty().node.innerHTML=a;return this}else return this.node.innerHTML},text:function(a){if(a!==p){this.empty().node.appendChild(h.createTextNode(a));return this}else return this.node.innerText||this.node.textContent},bind:function(a,b){var c=this.node.guid||(this.node.guid=m.handlers.guid++);if(!m.handlers[c])m.handlers[c]={link:this.node,listener:m.handlers.createListener(c),events:{}};if(a&&!m.handlers[c].events[a]){m.handlers[c].events[a]={};m.bind(this.node,a,m.handlers[c].listener)}if(b){if(!b.fid)b.fid=m.handlers.fid++;m.handlers[c].events[a][b.fid]=b}else return m.handlers[c];return this},unbind:function(b,c){var d=m.handlers[this.node.guid],events;if(d){events=d.events;if(c){if(events[b])delete events[b][c.fid];if(m.isEmpty(events[b]))return this.unbind(b)}else if(b){delete events[b];m.unbind(this.node,b,d.listener);if(m.isEmpty(d.events))delete m.handlers[this.node.guid]}else{m.forEach(events,function(a){m.unbind(this,a,d.listener)},this.node);delete m.handlers[this.node.guid]}}return this},copyHandlers:function(c,d){var e=m.handlers[m.id(c).guid],current,node;if(e){current=this.bind(d);node=this.node;if(d)m.extend(current.events[d],e.events[d]);else m.forEach(e.events,function(a,b){if(!this.events[a]){this.events[a]=b;m.bind(node,a,this.listener)}else m.extend(this.events[a],b)},current)}return this},exist:function(a,b){if(a&&this.node)a.call(this.node);else if(b&&!this.node)b();return!!this.node},hasClass:function(b){if(b){var c=' '+this.node.className+' ',exist=true;m.forEach(m.toArray(b),function(a){if(c.indexOf(' '+a+' ')==-1)return exist=false});return exist}else return!!this.node.className},addClass:function(b){var c=this.node.className,modified=false;if(c){c=' '+c+' ';m.forEach(m.toArray(b),function(a){if(c.indexOf(' '+a+' ')==-1){c+=a+' ';modified=true}});if(modified)this.node.className=m.toArray(c).join(' ')}else this.node.className=b;return this},removeClass:function(b){if(b){var b=' '+(b.join?b.join(' '):b)+' ',modified=false,i=0,className=[];m.forEach(m.toArray(this.node.className),function(a){if(b.indexOf(' '+a+' ')==-1)className[i++]=a;else modified=true});if(modified)this.node.className=className.join(' ')}else this.node.className='';return this},toggleClass:function(b,c){var d=this.node.className;if(c){if(d){var i=0;c=m.toArray(c);d=' '+d+' ';m.forEach(m.toArray(b),function(a){d=d.replace(' '+a+' ',' '+c[i++]+' ')});this.node.className=m.toArray(d).join(' ')}}else{if(d){var e=m.prototype.removeClass.call({node:{className:b}},d).node.className;this.removeClass(b);if(e)this.addClass(e)}else this.addClass(b)}return this},attr:function(a,b){if(b!==p){var c=a;a={};a[c]=b}else if(a.join||a.split){var d=m.toArray(a),length=d.length,i=-1,j=0,result=[];while(++i<length)result[j++]=this.node[d[i]];return result.length==1?result[0]:result}m.extend(this.node,a);return this},removeAttr:function(a){var i=(a=m.toArray(a)).length;while(i--)this.node[a[i]]=null;return this},val:function(a){var b='value'in this.node;return a!==p?(b?this.attr({value:a}):this.text(a)):(b?this.node.value:((b=this.node.firstChild)?b.nodeValue:''))},is:function(c,d){if(c){if(typeof c=='string')return this.node.tagName==c.toUpperCase();var e=true;if(d)c.tagName=d.toUpperCase();m.forEach(c,function(a,b){if(this[a]!=b)return e=false},this.node);return e}else return this.exist()},css:function(e,f){return function(a,b){if(b!==p){var c=a;a={};a[c]=b}else if(a.split||a.join){var d=m.toArray(a),length=d.length,i=-1,j=0,result=[];while(++i<length)result[j++]=f(this.node,d[i]);return result.length==1?result[0]:result}e(this.node,a);return this}}(o?function(){return function(a,b){if(b.opacity!=p){var c=a.filters['DXImageTransform.Microsoft.alpha']||a.filters.alpha;c?c.opacity=b.opacity*100:a.style.filter+=' progid:DXImageTransform.Microsoft.Alpha(opacity='+b.opacity*100+')';delete b.opacity}if(b.cssFloat){b.styleFloat=b.cssFloat;delete b.cssFloat}m.extend(a.style,b)}}():function(a,b){m.extend(a.style,b)},o?function(c){return function(a,b){return c[b]?c[b](a):a.currentStyle[b]}}({cssFloat:function(a){return a.currentStyle.styleFloat},backgroundPosition:function(a){return a.currentStyle.backgroundPositionX+' '+a.currentStyle.backgroundPositionY},opacity:function(a){if(a.filters.length){var b=a.filters['DXImageTransform.Microsoft.alpha']||a.filters.alpha;return b?b.opacity/100:1}else return 1}}):function(a,b){return h.defaultView.getComputedStyle(a,null)[b]}),hide:function(){this.node.style.display='none';return this},show:function(a){this.node.style.display=a||'block';return this},visible:function(){return this.node.offsetWidth>0||this.node.offsetHeight>0},toggle:function(a){this.node.style.display=this.css(['display'])=='none'?a||'block':'none';return this},enabled:function(a){return typeof a=='boolean'?(a?this.removeAttr(['disabled']):this.attr({disabled:'disabled'})):!this.attr(['disabled'])},id:function(a){if(a!==p){delete m.cache[this.node.id];this.node.id=a;return this}else return this.node.id},serialize:function(){return this.node.outerHTML||new XMLSerializer().serializeToString(this.node)},position:l.getBoundingClientRect?function(){var a=this.node.getBoundingClientRect();return{top:Math.round(a.top+(g.pageYOffset||l.scrollTop)-(l.clientTop||0)),left:Math.round(a.left+(g.pageXOffset||l.scrollLeft)-(l.clientLeft||0))}}:function(){var a=0,left=0,node=this.node;while(node){a+=parseInt(node.offsetTop)||0;left+=parseInt(node.offsetLeft)||0;node=node.offsetParent}return{top:a,left:left}},find:h.querySelectorAll?function(c,d){var e=[],i,j=0;if(c.split||c.join){i=(c=m.toArray(c)).length;while(i--)e[j++]=m.attrs[c[i]]||c[i].toLowerCase()}else m.forEach(c,function(a,b){e[j++]=(m.attrs[a]||a.toLowerCase())+'="'+b+'"'});e='['+e.join('][')+']';if(d){var f=[];i=(d=m.toArray(d)).length;j=0;while(i--)f[j++]=d[i]+e;e=f.join(',')}return new m.list(this.node.querySelectorAll(e),false)}:function(c,d){var i=-1,n=0,list=this.child(d,true).items,length=list.length,key,array=[];if(c.split||c.join){var j,k=(c=m.toArray(c)).length;while(++i<length){j=k;key=true;while(j--)if(!list[i][c[j]]){key=false;break}if(key)array[n++]=list[i]}}else while(++i<length){key=true;m.forEach(c,function(a,b){if(list[i][a]!=b)return key=false});if(key)array[n++]=list[i]}return new m.list(array,false)},findAttr:h.querySelectorAll?function(a,b,c){var d=[],i=(b=m.toArray(b)).length,j=0,k=(c=c?m.toArray(c):['']).length,n=i;a=m.attrs[a]||a.toLowerCase();while(k--){while(i--)d[j++]=c[k]+'['+a+'~="'+b[i]+'"]';i=n}return new m.list(this.node.querySelectorAll(d.join(',')),false)}:function(a,b,c){var i=-1,j,n=0,k=(b=m.toArray(b)).length,list=this.child(c,true).items,length=list.length,key,value,array=[];while(++i<length){j=k;key=false;value=' '+list[i][a]+' ';while(j--)if(value.indexOf(' '+b[j]+' ')!=-1){key=true;break}if(key)array[n++]=list[i]}return new m.list(array,false)},child:function(d,e,f){if('children'in l){e='children';f=false}else e='childNodes';return function(a,b){if(a||b){var i=-1,list=[];if(a===true||(!a&&b))list=this.node.getElementsByTagName('*');else if(a){if(b)list=(i=(a=m.toArray(a)).length)==1?this.node.getElementsByTagName(a[0]):d(this.node,a,i);else{var c=this.node[e],length=c.length,j=0;a=' '+(a.join?a.join(' '):a).toUpperCase()+' ';while(++i<length)if(a.indexOf(' '+c[i].tagName+' ')!=-1)list[j++]=c[i]}}return new m.list(list,false)}else return new m.list(this.node[e],f)}}(h.querySelectorAll?function(a,b){return a.querySelectorAll(b.join(','))}:function(a,b,i){var c=[];while(i--)c=c.concat(m.makeArray(a.getElementsByTagName(b[i])));return c}),children:function(a){return this.child(a,true)},findClass:h.querySelectorAll?function(a,b){var c=[];a=m.toArray(a);if(b){var i,length=a.length,j,k=0;i=(b=m.toArray(b)).length;while(i--){j=length;while(j--)c[k++]=b[i]+'.'+a[j]}c=c.join(',')}else c='.'+a.join(',.');return new m.list(this.node.querySelectorAll(c),false)}:h.getElementsByClassName?function(a,b){return!b&&(a=m.toArray(a)).length==1?new m.list(this.node.getElementsByClassName(a[0]),false):this.findAttr('className',a,b)}:function(a,b){return this.findAttr('className',a,b)}};m.extend(m.prototype,function(d,e,f){if('childElementCount'in l){d={next:'nextElementSibling',prev:'previousElementSibling',first:'firstElementChild',last:'lastElementChild'};e=function(a,b,c){if(c){c=c.toUpperCase();while(a=a[b])if(a.nodeName==c)break;return a}return a[b]};f=function(a,b,c){return a?(c&&a.tagName!=c.toUpperCase()?e(a,d[b],c):a):null};m.clear=function(a){a.childElementCount?this.cache={}:delete this.cache[a.id];return a}}else{d={next:'nextSibling',prev:'previousSibling',first:'firstChild',last:'lastChild'};e=function(a,b,c){if(c)c=c.toUpperCase();while(a=a[b])if(a.nodeType==1&&(c?a.tagName==c:true))break;return a};f=function(a,b,c){return a?(a.nodeType==1&&(c?c.toUpperCase()==a.tagName:true)?a:e(a,d[b],c)):null};m.clear=function(a){a.hasChildNodes()?this.cache={}:delete this.cache[a.id];return a}}return{next:function(a){return new m(e(this.node,d.next,a))},prev:function(a){return new m(e(this.node,d.prev,a))},first:function(a){return new m(f(this.node[d.first],'next',a))},last:function(a){return new m(f(this.node[d.last],'prev',a))},nth:function(a,b){return this.child(b).get(a)}}}());m.list.prototype={get:function(a){return a===p?this.items:new m(this.items[a])},getLast:function(){return new m(this.items[this.items.length-1])},size:function(){return this.items.length},add:function(a){if(!this.items.join)this.items=m.makeArray(this.items);if(!a.join&&a.length!==p)a=m.makeArray(a);this.items=this.items.concat(a);return this}};m.extend(m.list.prototype,function(d){function check(a){var b=(a=d.call(a,1)).length<2;return b?{method:'call',args:a[0]}:{method:'apply',args:a}}m.forEach('resize,scroll,blur,focus,error,abort,onload,unload,click,dblclick,mousedown,mouseup,mousemove,mouseover,mouseout,keydown,keypress,keyup,change,select,submit,reset'.split(','),function(c){return function(b){m.prototype[b]=function(a){return a?this.bind(b,a.call?a:c(a,arguments)):this.node[b]()}}}(function(b,c){return function(){var a,exec=check(c);(a=$(this))[b][exec.method](a,exec.args)}}));return{filter:function(a){if(a.call)return new m.list(this.items,a);else{var b=new m(this.items[0]),exec=check(arguments);return new m.list(this.items,exec.method=='call'?function(){b.node=this;return b[a](exec.args)}:function(){b.node=this;return m.prototype[a].apply(b,exec.args)})}},each:function(a){var i=this.items.length;if(a.call){while(i--)if(a.call(this.items[i],i,this.items)===false)break}else{var b=new m(this.items[0]),exec=check(arguments);if(exec.method=='call')while(i--){b.node=this.items[i];b[a](exec.args)}else while(i--){b.node=this.items[i];m.prototype[a].apply(b,exec.args)}}return this}}}(Array.prototype.slice));m.prototype.store=m.list.prototype.store=function(){return m.storage=this};m.restore=m.prototype.restore=m.list.prototype.restore=function(){var a=m.storage;delete m.storage;return a};m.timer.prototype={start:function(){if(!this.enabled){var a=this;a.enabled=true;(function(){a.func.call(a.context,a);if(a.enabled)setTimeout(arguments.callee,a.time)})()}return this},stop:function(){this.enabled=false;return this},repeat:function(a,b,c){if(!this.enabled){var d=this;d.enabled=true;(function(){d.func.call(d.context,d);if(d.enabled&&--a)setTimeout(arguments.callee,d.time);else{d.enabled=false;if(b)b.call(c||d.context,d)}})()}return this}};g.core=g.$?m:(g.$=m);(function(a){m.bind(g,'load',a);if(!o)return h.addEventListener('DOMContentLoaded',a,false);try{l.doScroll('left')}catch(error){h.write(unescape('%3CSCRIPT onreadystatechange="if(this.readyState==\'complete\') core.ready()" defer="defer" src="\/\/:"%3E%3C/SCRIPT%3E'))}})(function(){m.unbind(h,'DOMContentLoaded',arguments.callee);m.unbind(g,'load',arguments.callee);m.ready()});m.bind(g,'unload',function(){delete m.cache;delete m.storage;delete m.handlers.guid;delete m.handlers.fid;delete m.handlers.createListener;m.forEach(m.handlers,function(b,c){m.forEach(c.events,function(a){m.unbind(c.link,a,c.listener)},c)});delete m.handlers;m.unbind(g,'unload',arguments.callee)})})(window,document,document.documentElement||document.body,function(a){if(this.core)return new core(a);this.node=core.id(a)}/*@cc_on,ScriptEngineMinorVersion()@*/);