1 |
601
|
doc
|
// Copyright 2006 Stepan Riha
|
2 |
|
|
// www.nonplus.net
|
3 |
|
|
// $Id: jsadmin.js 2 2006-04-18 03:04:39Z stepan $
|
4 |
|
|
|
5 |
|
|
// Initialize JsAdmin when page loads
|
6 |
|
|
JsAdmin.loadHandler = function(ev, self) {
|
7 |
|
|
if(self.init_tool) {
|
8 |
|
|
self.init_tool();
|
9 |
|
|
}
|
10 |
|
|
if(self.restore_toggled) {
|
11 |
|
|
self.restore_toggled();
|
12 |
|
|
YAHOO.util.Event.addListener(window, 'unload', JsAdmin.unloadHandler, self, false);
|
13 |
|
|
}
|
14 |
|
|
if(self.init_drag_drop) {
|
15 |
|
|
self.init_drag_drop();
|
16 |
|
|
}
|
17 |
|
|
};
|
18 |
|
|
|
19 |
|
|
// Store JsAdmin cookies when page unloads
|
20 |
|
|
JsAdmin.unloadHandler = function(ev, self) {
|
21 |
|
|
self.save_toggled();
|
22 |
|
|
};
|
23 |
|
|
|
24 |
|
|
JsAdmin.rowMouseOverHandler = function(ev, tr) {
|
25 |
|
|
YAHOO.util.Dom.setStyle(tr, 'background' ,'#fea');
|
26 |
|
|
};
|
27 |
|
|
|
28 |
|
|
JsAdmin.rowMouseOutHandler = function(ev, tr) {
|
29 |
|
|
YAHOO.util.Dom.setStyle(tr, 'background' ,'');
|
30 |
|
|
};
|
31 |
|
|
|
32 |
|
|
YAHOO.util.Event.addListener(window, 'load', JsAdmin.loadHandler, JsAdmin, false);
|
33 |
|
|
|
34 |
|
|
JsAdmin.util = {
|
35 |
|
|
createCookie : function(name,value,days)
|
36 |
|
|
{
|
37 |
|
|
if (days)
|
38 |
|
|
{
|
39 |
|
|
var date = new Date();
|
40 |
|
|
date.setTime(date.getTime()+(days*24*60*60*1000));
|
41 |
|
|
var expires = "; expires="+date.toGMTString();
|
42 |
|
|
}
|
43 |
|
|
else var expires = "";
|
44 |
|
|
document.cookie = name+"="+value+expires+"; path=/";
|
45 |
|
|
},
|
46 |
|
|
|
47 |
|
|
readCookie : function(name)
|
48 |
|
|
{
|
49 |
|
|
var nameEQ = name + "=";
|
50 |
|
|
var ca = document.cookie.split(';');
|
51 |
|
|
for(var i=0;i < ca.length;i++)
|
52 |
|
|
{
|
53 |
|
|
var c = ca[i];
|
54 |
|
|
while (c.charAt(0)==' ') c = c.substring(1,c.length);
|
55 |
|
|
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
|
56 |
|
|
}
|
57 |
|
|
return null;
|
58 |
|
|
},
|
59 |
|
|
|
60 |
|
|
eraseCookie : function(name)
|
61 |
|
|
{
|
62 |
|
|
this.createCookie(name,"",-1);
|
63 |
|
|
},
|
64 |
|
|
|
65 |
|
|
next_id : 1,
|
66 |
|
|
getUniqueId : function () {
|
67 |
|
|
var id;
|
68 |
|
|
do {
|
69 |
|
|
id = 'jsadmin_id_' + this.next_id++;
|
70 |
|
|
} while(YAHOO.util.Dom.get(id));
|
71 |
|
|
return id;
|
72 |
|
|
},
|
73 |
|
|
|
74 |
|
|
isNodeType : function(elt, type) {
|
75 |
|
|
if(elt) {
|
76 |
|
|
return elt.nodeName.toUpperCase() == type.toUpperCase();
|
77 |
|
|
}
|
78 |
|
|
return false;
|
79 |
|
|
},
|
80 |
|
|
|
81 |
|
|
getItemIndex : function (elt) {
|
82 |
|
|
var type = elt.nodeName;
|
83 |
|
|
var index = 0;
|
84 |
|
|
for(var sib = elt.previousSibling; sib; sib = sib.previousSibling) {
|
85 |
|
|
if(sib.nodeName == type) {
|
86 |
|
|
index++;
|
87 |
|
|
}
|
88 |
|
|
}
|
89 |
|
|
return index;
|
90 |
|
|
},
|
91 |
|
|
|
92 |
|
|
getAncestorNode : function(elt, type) {
|
93 |
|
|
if(elt) {
|
94 |
|
|
if(type) {
|
95 |
|
|
type = type.toUpperCase();
|
96 |
|
|
} else {
|
97 |
|
|
type = elt.nodeName.toUpperCase();
|
98 |
|
|
}
|
99 |
|
|
elt = elt.parentNode;
|
100 |
|
|
while(elt && elt.nodeName.toUpperCase() != type) {
|
101 |
|
|
elt = elt.parentNode;
|
102 |
|
|
}
|
103 |
|
|
}
|
104 |
|
|
return elt;
|
105 |
|
|
},
|
106 |
|
|
|
107 |
|
|
getNextSiblingNode : function (elt, type) {
|
108 |
|
|
if(elt) {
|
109 |
|
|
if(type) {
|
110 |
|
|
type = type.toUpperCase();
|
111 |
|
|
} else {
|
112 |
|
|
type = elt.nodeName.toUpperCase();
|
113 |
|
|
}
|
114 |
|
|
elt = elt.nextSibling;
|
115 |
|
|
while(elt && elt.nodeName.toUpperCase() != type) {
|
116 |
|
|
elt = elt.nextSibling;
|
117 |
|
|
}
|
118 |
|
|
}
|
119 |
|
|
return elt;
|
120 |
|
|
},
|
121 |
|
|
|
122 |
|
|
matchNextSibling : function (elt, re) {
|
123 |
|
|
if(elt) {
|
124 |
|
|
elt = elt.nextSibling;
|
125 |
|
|
while(elt && !elt.nodeName.match(re)) {
|
126 |
|
|
elt = elt.nextSibling;
|
127 |
|
|
}
|
128 |
|
|
}
|
129 |
|
|
return elt;
|
130 |
|
|
},
|
131 |
|
|
|
132 |
|
|
getPreviousSiblingNode : function (elt, type) {
|
133 |
|
|
if(elt) {
|
134 |
|
|
if(type) {
|
135 |
|
|
type = type.toUpperCase();
|
136 |
|
|
} else {
|
137 |
|
|
type = elt.nodeName.toUpperCase();
|
138 |
|
|
}
|
139 |
|
|
elt = elt.previousSibling;
|
140 |
|
|
while(elt && elt.nodeName.toUpperCase() != type) {
|
141 |
|
|
elt = elt.previousSibling;
|
142 |
|
|
}
|
143 |
|
|
}
|
144 |
|
|
return elt;
|
145 |
|
|
},
|
146 |
|
|
|
147 |
|
|
insertBefore : function(parent, newChild, beforeChild) {
|
148 |
|
|
if(beforeChild) {
|
149 |
|
|
parent.insertBefore(newChild, beforeChild);
|
150 |
|
|
} else {
|
151 |
|
|
parent.appendChild(newChild);
|
152 |
|
|
}
|
153 |
|
|
},
|
154 |
|
|
|
155 |
|
|
insertAfter : function(parent, newChild, afterChild) {
|
156 |
|
|
if(afterChild) {
|
157 |
|
|
this.insertBefore(parent, newChild, afterChild.nextSibling);
|
158 |
|
|
} else {
|
159 |
|
|
this.insertBefore(parent, newChild, parent.firstChild);
|
160 |
|
|
}
|
161 |
|
|
}
|
162 |
|
|
};
|