1 |
07e0a90c
|
Scott Ullrich
|
function NiftyCheck(){
|
2 |
|
|
if(!document.getElementById || !document.createElement)
|
3 |
|
|
return(false);
|
4 |
|
|
isXHTML=/html\:/.test(document.getElementsByTagName('body')[0].nodeName);
|
5 |
|
|
if(Array.prototype.push==null){Array.prototype.push=function(){
|
6 |
|
|
this[this.length]=arguments[0]; return(this.length);}}
|
7 |
|
|
return(true);
|
8 |
|
|
}
|
9 |
|
|
|
10 |
|
|
function Rounded(selector,wich,bk,color,opt){
|
11 |
|
|
var i,prefixt,prefixb,cn="r",ecolor="",edges=false,eclass="",b=false,t=false;
|
12 |
|
|
|
13 |
|
|
if(color=="transparent"){
|
14 |
|
|
cn=cn+"x";
|
15 |
|
|
ecolor=bk;
|
16 |
|
|
bk="transparent";
|
17 |
|
|
}
|
18 |
|
|
else if(opt && opt.indexOf("border")>=0){
|
19 |
|
|
var optar=opt.split(" ");
|
20 |
|
|
for(i=0;i<optar.length;i++)
|
21 |
|
|
if(optar[i].indexOf("#")>=0) ecolor=optar[i];
|
22 |
|
|
if(ecolor=="") ecolor="#666";
|
23 |
|
|
cn+="e";
|
24 |
|
|
edges=true;
|
25 |
|
|
}
|
26 |
|
|
else if(opt && opt.indexOf("smooth")>=0){
|
27 |
|
|
cn+="a";
|
28 |
|
|
ecolor=Mix(bk,color);
|
29 |
|
|
}
|
30 |
|
|
if(opt && opt.indexOf("small")>=0) cn+="s";
|
31 |
|
|
prefixt=cn;
|
32 |
|
|
prefixb=cn;
|
33 |
|
|
if(wich.indexOf("all")>=0){t=true;b=true}
|
34 |
|
|
else if(wich.indexOf("top")>=0) t="true";
|
35 |
|
|
else if(wich.indexOf("tl")>=0){
|
36 |
|
|
t="true";
|
37 |
|
|
if(wich.indexOf("tr")<0) prefixt+="l";
|
38 |
|
|
}
|
39 |
|
|
else if(wich.indexOf("tr")>=0){
|
40 |
|
|
t="true";
|
41 |
|
|
prefixt+="r";
|
42 |
|
|
}
|
43 |
|
|
if(wich.indexOf("bottom")>=0) b=true;
|
44 |
|
|
else if(wich.indexOf("bl")>=0){
|
45 |
|
|
b="true";
|
46 |
|
|
if(wich.indexOf("br")<0) prefixb+="l";
|
47 |
|
|
}
|
48 |
|
|
else if(wich.indexOf("br")>=0){
|
49 |
|
|
b="true";
|
50 |
|
|
prefixb+="r";
|
51 |
|
|
}
|
52 |
|
|
var v=getElementsBySelector(selector);
|
53 |
|
|
var l=v.length;
|
54 |
|
|
for(i=0;i<l;i++){
|
55 |
|
|
if(edges) AddBorder(v[i],ecolor);
|
56 |
|
|
if(t) AddTop(v[i],bk,color,ecolor,prefixt);
|
57 |
|
|
if(b) AddBottom(v[i],bk,color,ecolor,prefixb);
|
58 |
|
|
}
|
59 |
|
|
}
|
60 |
|
|
|
61 |
|
|
function AddBorder(el,bc){
|
62 |
|
|
var i;
|
63 |
|
|
if(!el.passed){
|
64 |
|
|
if(el.childNodes.length==1 && el.childNodes[0].nodeType==3){
|
65 |
|
|
var t=el.firstChild.nodeValue;
|
66 |
|
|
el.removeChild(el.lastChild);
|
67 |
|
|
var d=CreateEl("span");
|
68 |
|
|
d.style.display="block";
|
69 |
|
|
d.appendChild(document.createTextNode(t));
|
70 |
|
|
el.appendChild(d);
|
71 |
|
|
}
|
72 |
|
|
for(i=0;i<el.childNodes.length;i++){
|
73 |
|
|
if(el.childNodes[i].nodeType==1){
|
74 |
|
|
el.childNodes[i].style.borderLeft="1px solid "+bc;
|
75 |
|
|
el.childNodes[i].style.borderRight="1px solid "+bc;
|
76 |
|
|
}
|
77 |
|
|
}
|
78 |
|
|
}
|
79 |
|
|
el.passed=true;
|
80 |
|
|
}
|
81 |
|
|
|
82 |
|
|
function AddTop(el,bk,color,bc,cn){
|
83 |
|
|
var i,lim=4,d=CreateEl("b");
|
84 |
|
|
|
85 |
|
|
if(cn.indexOf("s")>=0) lim=2;
|
86 |
|
|
if(bc) d.className="artop";
|
87 |
|
|
else d.className="rtop";
|
88 |
|
|
d.style.backgroundColor=bk;
|
89 |
|
|
for(i=1;i<=lim;i++){
|
90 |
|
|
var x=CreateEl("b");
|
91 |
|
|
x.className=cn + i;
|
92 |
|
|
x.style.backgroundColor=color;
|
93 |
|
|
if(bc) x.style.borderColor=bc;
|
94 |
|
|
d.appendChild(x);
|
95 |
|
|
}
|
96 |
|
|
el.style.paddingTop=0;
|
97 |
|
|
el.insertBefore(d,el.firstChild);
|
98 |
|
|
}
|
99 |
|
|
|
100 |
|
|
function AddBottom(el,bk,color,bc,cn){
|
101 |
|
|
var i,lim=4,d=CreateEl("b");
|
102 |
|
|
|
103 |
|
|
if(cn.indexOf("s")>=0) lim=2;
|
104 |
|
|
if(bc) d.className="artop";
|
105 |
|
|
else d.className="rtop";
|
106 |
|
|
d.style.backgroundColor=bk;
|
107 |
|
|
for(i=lim;i>0;i--){
|
108 |
|
|
var x=CreateEl("b");
|
109 |
|
|
x.className=cn + i;
|
110 |
|
|
x.style.backgroundColor=color;
|
111 |
|
|
if(bc) x.style.borderColor=bc;
|
112 |
|
|
d.appendChild(x);
|
113 |
|
|
}
|
114 |
|
|
el.style.paddingBottom=0;
|
115 |
|
|
el.appendChild(d);
|
116 |
|
|
}
|
117 |
|
|
|
118 |
|
|
function CreateEl(x){
|
119 |
|
|
if(isXHTML) return(document.createElementNS('http://www.w3.org/1999/xhtml',x));
|
120 |
|
|
else return(document.createElement(x));
|
121 |
|
|
}
|
122 |
|
|
|
123 |
|
|
function getElementsBySelector(selector){
|
124 |
|
|
var i,selid="",selclass="",tag=selector,f,s=[],objlist=[];
|
125 |
|
|
|
126 |
|
|
if(selector.indexOf(" ")>0){ //descendant selector like "tag#id tag"
|
127 |
|
|
s=selector.split(" ");
|
128 |
|
|
var fs=s[0].split("#");
|
129 |
|
|
if(fs.length==1) return(objlist);
|
130 |
|
|
f=document.getElementById(fs[1]);
|
131 |
|
|
if(f) return(f.getElementsByTagName(s[1]));
|
132 |
|
|
return(objlist);
|
133 |
|
|
}
|
134 |
|
|
if(selector.indexOf("#")>0){ //id selector like "tag#id"
|
135 |
|
|
s=selector.split("#");
|
136 |
|
|
tag=s[0];
|
137 |
|
|
selid=s[1];
|
138 |
|
|
}
|
139 |
|
|
if(selid!=""){
|
140 |
|
|
f=document.getElementById(selid);
|
141 |
|
|
if(f) objlist.push(f);
|
142 |
|
|
return(objlist);
|
143 |
|
|
}
|
144 |
|
|
if(selector.indexOf(".")>0){ //class selector like "tag.class"
|
145 |
|
|
s=selector.split(".");
|
146 |
|
|
tag=s[0];
|
147 |
|
|
selclass=s[1];
|
148 |
|
|
}
|
149 |
|
|
var v=document.getElementsByTagName(tag); // tag selector like "tag"
|
150 |
|
|
if(selclass=="")
|
151 |
|
|
return(v);
|
152 |
|
|
for(i=0;i<v.length;i++){
|
153 |
|
|
if(v[i].className.indexOf(selclass)>=0){
|
154 |
|
|
objlist.push(v[i]);
|
155 |
|
|
}
|
156 |
|
|
}
|
157 |
|
|
return(objlist);
|
158 |
|
|
}
|
159 |
|
|
|
160 |
|
|
function Mix(c1,c2){
|
161 |
|
|
var i,step1,step2,x,y,r=new Array(3);
|
162 |
|
|
if(c1.length==4)step1=1;
|
163 |
|
|
else step1=2;
|
164 |
|
|
if(c2.length==4) step2=1;
|
165 |
|
|
else step2=2;
|
166 |
|
|
for(i=0;i<3;i++){
|
167 |
|
|
x=parseInt(c1.substr(1+step1*i,step1),16);
|
168 |
|
|
if(step1==1) x=16*x+x;
|
169 |
|
|
y=parseInt(c2.substr(1+step2*i,step2),16);
|
170 |
|
|
if(step2==1) y=16*y+y;
|
171 |
|
|
r[i]=Math.floor((x*50+y*50)/100);
|
172 |
|
|
}
|
173 |
|
|
return("#"+r[0].toString(16)+r[1].toString(16)+r[2].toString(16));
|
174 |
|
|
}
|