/[drupal]/contributions/themes/MyTree/script.js
ViewVC logotype

Contents of /contributions/themes/MyTree/script.js

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.2 - (show annotations) (download) (as text)
Mon Jun 22 23:25:48 2009 UTC (5 months, 1 week ago) by vigilianty
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +1 -1 lines
File MIME type: text/javascript
Validation: added a title to footer link.
1 /* begin Page */
2
3 /* Generated version 2.1.0.16090, file checksum is 0287F487. */
4
5 var artEventHelper = {
6 'bind' : function (obj, evt, fn) {
7 if (obj.addEventListener)
8 obj.addEventListener(evt, fn, false);
9 else if (obj.attachEvent)
10 obj.attachEvent('on' + evt, fn);
11 else
12 obj['on' + evt] = fn;
13 }
14 };
15
16 var artLoadEvent = (function() {
17 var userAgent = navigator.userAgent.toLowerCase();
18 var browser = {
19 version: (userAgent.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/) || [])[1],
20 safari: /webkit/.test(userAgent),
21 opera: /opera/.test(userAgent),
22 msie: /msie/.test(userAgent) && !/opera/.test(userAgent),
23 mozilla: /mozilla/.test(userAgent) && !/(compatible|webkit)/.test(userAgent)
24 };
25
26 var list = [];
27
28 var done = false;
29 var ready = function () {
30 if (done) return;
31 done = true;
32 for (var i = 0; i < list.length; i++)
33 list[i]();
34 };
35
36 if (document.addEventListener && !browser.opera)
37 document.addEventListener('DOMContentLoaded', ready, false);
38
39 if (browser.msie && window == top) {
40 (function () {
41 try {
42 document.documentElement.doScroll('left');
43 } catch (e) {
44 setTimeout(arguments.callee, 10);
45 return;
46 }
47 ready();
48 })();
49 }
50
51 if (browser.opera) {
52 document.addEventListener('DOMContentLoaded', function () {
53 for (var i = 0; i < document.styleSheets.length; i++) {
54 if (document.styleSheets[i].disabled) {
55 setTimeout(arguments.callee, 10);
56 return;
57 }
58 }
59 ready();
60 }, false);
61 }
62
63 if (browser.safari) {
64 var numStyles;
65 (function(){
66 if (document.readyState != 'loaded' && document.readyState != 'complete') {
67 setTimeout(arguments.callee, 10);
68 return;
69 }
70 if ('undefined' == typeof numStyles) {
71 numStyles = document.getElementsByTagName('style').length;
72 var links = document.getElementsByTagName('link');
73 for (var i = 0; i < links.length; i++) {
74 numStyles += (links[i].getAttribute('rel') == 'stylesheet') ? 1 : 0;
75 }
76 if (document.styleSheets.length != numStyles) {
77 setTimeout(arguments.callee, 0);
78 return;
79 }
80 }
81 ready();
82 })();
83 }
84
85 artEventHelper.bind(window, 'load', ready);
86
87 return ({
88 add: function(f) {
89 list.push(f);
90 }
91 })
92 })();
93
94 (function () {
95 // fix ie blinking
96 var m = document.uniqueID && document.compatMode && !window.XMLHttpRequest && document.execCommand;
97 try{ if(!!m) { m("BackgroundImageCache", false, true); } }
98 catch(oh){};
99 })();
100
101 function xGetElementsByClassName(clsName, parentEle, tagName) {
102 var elements = null;
103 var found = [];
104 var slash = String.fromCharCode(92);
105 var re = new RegExp(slash + "b" + clsName + slash + "b");
106 if (!parentEle) parentEle = document;
107 if (!tagName) tagName = '*';
108 elements = parentEle.getElementsByTagName(tagName);
109 if (elements) {
110 for (var i = 0; i < elements.length; ++i) {
111 if (elements[i].className.search(re) != -1) {
112 found[found.length] = elements[i];
113 }
114 }
115 }
116 return found;
117 }
118
119 var styleUrlCached = null;
120 function GetStyleUrl() {
121 if (null == styleUrlCached) {
122 var ns;
123 styleUrlCached = '';
124 ns = document.getElementsByTagName('link');
125 for (var i = 0; i < ns.length; i++) {
126 var l = ns[i];
127 if (l.href && /style\.css(\?.*)?$/.test(l.href)){
128 return styleUrlCached = l.href.replace(/style\.css(\?.*)?$/,'');
129 }
130 }
131
132 ns = document.getElementsByTagName('style');
133 for (var i = 0; i < ns.length; i++) {
134 var matches = new RegExp('import\\s+"([^"]+\\/)style\\.css"').exec(ns[i].innerHTML);
135 if (null != matches && matches.length > 0)
136 return styleUrlCached = matches[1];
137 }
138 }
139 return styleUrlCached;
140 }
141
142
143 function artButtonSetupJsHover(btn)
144 {
145 artEventHelper.bind(btn, 'mouseover', function() {
146 var spans = btn.getElementsByTagName("span");
147 if (spans.length > 0)
148 spans[0].className += " hover";
149 });
150 artEventHelper.bind(btn, 'mouseout', function() {
151 var spans = btn.getElementsByTagName("span");
152 if (spans.length > 0)
153 spans[0].className = spans[0].className.replace(/hover/, "").replace(/active/, "");
154 });
155 artEventHelper.bind(btn, 'mousedown', function() {
156 var spans = btn.getElementsByTagName("span");
157 if (spans.length > 0)
158 spans[0].className += " active";
159 });
160 artEventHelper.bind(btn, 'mouseup', function() {
161 var spans = btn.getElementsByTagName("span");
162 if (spans.length > 0)
163 spans[0].className = spans[0].className.replace(/active/, "");
164 });
165 }
166
167 function artButtonsSetupJsHover() {
168 var elements = xGetElementsByClassName("btn", document, "span");
169 for (var i = 0; i < elements.length; i++) {
170 if (!elements[i].tagName) continue;
171 artButtonSetupJsHover(elements[i].parentNode);
172 }
173 }
174 artLoadEvent.add(artButtonsSetupJsHover);
175
176 /* end Page */
177
178 /* begin Menu */
179 function Insert_Separators()
180 {
181 var menus = xGetElementsByClassName("artmenu", document);
182 for (var i = 0; i < menus.length; i++) {
183 var menu = menus[i];
184 var childs = menu.childNodes;
185 var listItems = [];
186 for (var j = 0; j < childs.length; j++){
187 var el = childs[j];
188 if (String(el.tagName).toLowerCase() == "li")listItems.push(el);
189 }
190 for (var j = 0; j < listItems.length - 1; j++){
191 var span = document.createElement('span');
192 span.className = 'separator';
193 var li = document.createElement('li');
194 li.appendChild(span);
195 listItems[j].parentNode.insertBefore(li, listItems[j].nextSibling);
196 }
197 }
198 }
199 artLoadEvent.add(Insert_Separators);
200
201 function Menu_IE6Setup() {
202 var isIE6 = navigator.userAgent.toLowerCase().indexOf("msie") != -1
203 && navigator.userAgent.toLowerCase().indexOf("msie 7") == -1;
204 if (!isIE6) return;
205 var aTmp2, i, j, oLI, aUL, aA;
206 var aTmp = xGetElementsByClassName("artmenu", document, "ul");
207 for (i=0;i<aTmp.length;i++) {
208 aTmp2 = aTmp[i].getElementsByTagName("li");
209 for (j=0;j<aTmp2.length;j++) {
210 oLI = aTmp2[j];
211 aUL = oLI.getElementsByTagName("ul");
212 if (aUL && aUL.length) {
213 oLI.UL = aUL[0];
214 aA = oLI.getElementsByTagName("a");
215 if (aA && aA.length)
216 oLI.A = aA[0];
217 oLI.onmouseenter = function() {
218 this.className += " artmenuhover";
219 this.UL.className += " artmenuhoverUL";
220 if (this.A) this.A.className += " artmenuhoverA";
221 };
222 oLI.onmouseleave = function() {
223 this.className = this.className.replace(/artmenuhover/,"");
224 this.UL.className = this.UL.className.replace(/artmenuhoverUL/,"");
225 if (this.A) this.A.className = this.A.className.replace(/artmenuhoverA/, "");
226 };
227 }
228 }
229 }
230 }
231 artLoadEvent.add(Menu_IE6Setup);
232 /* end Menu */
233
234
235
236 artLoadEvent.add(function() {
237 // select all tables with table class
238 var formButtons = document.getElementsByTagName('button');
239 for (var i = 0; i < formButtons.length; i++) {
240 var button = formButtons[i];
241
242 button.buttonName = button.getAttribute('name');
243 button.buttonValue = button.getAttribute('value');
244 button.prevOnClick = button.onclick;
245
246 if (button.outerHTML) {
247 var re = /\bvalue="([^"]+)"/i;
248 button.buttonValue = re.test(button.outerHTML) ? re.exec(button.outerHTML)[1] : button.buttonValue;
249 }
250
251 button.setAttribute("name", "_" + button.buttonName);
252
253 button.onclick = function() {
254 if (this.prevOnClick) this.prevOnClick.apply(this);
255 var f = this;
256 while (f.tagName.toLowerCase() != "body") {
257 if (f.tagName.toLowerCase() == "form") {
258 var subButton = document.createElement("input");
259 subButton.setAttribute("type", "hidden");
260 subButton.setAttribute("name", this.buttonName);
261 subButton.setAttribute("value", this.buttonValue);
262 f.appendChild(subButton);
263 return true;
264 }
265 f = f.parentNode;
266 }
267 return false;
268 };
269 }
270 });

  ViewVC Help
Powered by ViewVC 1.1.2