|
| 1 | +/*! Tiny.js v0.1.0 **/ |
| 2 | +var $ = function(s){return document.querySelectorAll(s);}; |
| 3 | +$.id = function(s){return document.getElementById(s);}; |
| 4 | +$.cls = function(s){return document.getElementsByClassName(s);}; |
| 5 | +$.tag = function(s,eWrapper){return (eWrapper || document).getElementsByTagName(s);}; |
| 6 | +$.crE = function(s){return document.createElement(s);}; |
| 7 | +$.crT = function(s){return document.createTextNode(s);}; |
| 8 | +$.insBfr = function(eW,e){eW.insertBefore(e,eW.firstChild);}; |
| 9 | +$.rmv = function (e) {e.parentNode.removeChild(e);}; |
| 10 | +$.getT = function(e){return e.firstChild.data;}; |
| 11 | +$.setT = function(e,s){e.firstChild.data=s;}; |
| 12 | +$.hide = function(e){e.style.visibility='hidden';}; |
| 13 | +$.show = function(e){e.style.visibility='visible';}; |
| 14 | +$.off = function(e){e.style.display='none';}; |
| 15 | +$.on = function(e){e.style.display='';}; |
| 16 | +$.style = function(e,p,v){ |
| 17 | + if (v) { |
| 18 | + e.style[p] = v; |
| 19 | + } else { |
| 20 | + e.style.cssText = p; |
| 21 | + } |
| 22 | +}; |
| 23 | +$.addEv = function(e,sEv,fn){e.addEventListener(sEv,fn,false);}; |
| 24 | +$.rmvEv = function(e,sEv,fn){e.removeEventListener(sEv,fn,false);}; |
| 25 | +$.each = function (a,fn){for(var i=0,l=a.length;i<l;++i){fn(a[i]);}}; |
| 26 | +$.hasT = function(so,s){return so.indexOf(s)>-1;}; |
| 27 | +$.hasCls = function(so,s){return $.hasT(' '+so+' ',' '+s+' ');}; |
| 28 | +$.addCls = function(e,s){var so=e.className;if(!$.hasCls(so,s))e.className+=(' '+s);}; |
| 29 | +$.rmvCls = function(e,s){var so=e.className;if($.hasCls(so,s))e.className=(' '+so+' ').replace(' '+s+' ',' ').trim();}; |
| 30 | +$.css = function (s) { |
| 31 | + var css = $.crE('style'); |
| 32 | + css.innerHTML = s; |
| 33 | + console.log(css); |
| 34 | + $.tag('head')[0].appendChild(css); |
| 35 | +}; |
| 36 | +$.cssText = ''; |
| 37 | + |
0 commit comments