[ Index ] |
|
Code source de Zen Cart E-Commerce Shopping Cart 1.3.7.1 |
1 // combined config.js and cssjsmenu.js for performance reasons 2 // to save a cache check and an inline script 3 4 // config.js 5 6 7 checkForUpgrade(); 8 9 function hide_dropdowns(what){ 10 if (window.navigator.userAgent.indexOf('MSIE 6.0') != -1) 11 if (what=="in") { 12 var anchors = document.getElementsByTagName("select"); 13 for (var i=0; i<anchors.length; i++) { 14 var anchor = anchors[i]; 15 if (anchor.getAttribute("rel")=="dropdown") { 16 anchor.style.position="relative"; 17 anchor.style.top="0px"; 18 anchor.style.left="-2000px"; 19 } 20 } 21 } else { 22 var anchors = document.getElementsByTagName("select"); 23 for (var i=0; i<anchors.length; i++) { 24 var anchor = anchors[i]; 25 if (anchor.getAttribute("rel")=="dropdown") { 26 anchor.style.position="relative"; 27 anchor.style.top="0px"; 28 anchor.style.left="0px"; 29 } 30 } 31 } 32 } 33 34 function ndeSetStyleSheet(newtitle) 35 { 36 ndeCreateCookie('nde-style', newtitle, 365, false); 37 if (ndeReadCookie('nde-style') == newtitle) 38 { 39 window.location.reload(true); 40 } 41 else 42 { 43 alert('You must enable Cookies in order for theme selection to work'); 44 } 45 } 46 47 function ndeSetTextSize(chgsize,rs) 48 { 49 if (!document.documentElement || !document.body) 50 { 51 return; 52 } 53 54 var newSize; 55 var startSize = parseInt(ndeGetDocTextSize()); 56 57 if (!startSize) 58 { 59 startSize = 12; 60 } 61 62 switch (chgsize) 63 { 64 case 'incr': 65 newSize = startSize + 2; 66 break; 67 68 case 'decr': 69 newSize = startSize - 2; 70 break; 71 72 case 'reset': 73 if (rs) 74 { 75 newSize = rs; 76 } 77 else 78 { 79 newSize = 12; 80 } 81 break; 82 83 default: 84 newSize = parseInt(ndeReadCookie('nde-textsize', true)); 85 if (!newSize) 86 { 87 newSize = startSize; 88 } 89 break; 90 91 } 92 93 if (newSize < 10) 94 { 95 newSize = 10; 96 } 97 98 newSize += 'px'; 99 100 document.documentElement.style.fontSize = newSize; 101 document.body.style.fontSize = newSize; 102 103 ndeCreateCookie('nde-textsize', newSize, 365, true); 104 } 105 106 function ndeGetDocTextSize() 107 { 108 if (!document.body) 109 { 110 return 0; 111 } 112 113 var size = 0; 114 var body = document.body; 115 116 if (body.style && body.style.fontSize) 117 { 118 size = body.style.fontSize; 119 } 120 else if (typeof(getComputedStyle) != 'undefined') 121 { 122 size = getComputedStyle(body,'').getPropertyValue('font-size'); 123 } 124 else if (body.currentStyle) 125 { 126 size = body.currentStyle.fontSize; 127 } 128 return size; 129 } 130 131 function ndeCreateCookie(name,value,days,useLang) 132 { 133 var langString = useLang ? ndeGetLang() : ''; 134 135 var cookie = name + langString + '=' + value + ';'; 136 137 if (days) 138 { 139 var date = new Date(); 140 var ndeMilliSecondsInDay = 86400000; // 24*60*60*1000 141 date.setTime(date.getTime()+(days*ndeMilliSecondsInDay)); 142 cookie += ' expires=' + date.toGMTString() + ';'; 143 } 144 cookie += ' path=/'; 145 146 document.cookie = cookie; 147 } 148 149 function ndeReadCookie(name, useLang) 150 { 151 var langString = useLang ? ndeGetLang() : ''; 152 153 var nameEQ = name + langString + '='; 154 var ca = document.cookie.split(';'); 155 156 for(var i = 0; i < ca.length; i++) 157 { 158 var c = ca[i]; 159 while (c.charAt(0) == ' ') 160 { 161 c = c.substring(1, c.length); 162 } 163 164 if (c.indexOf(nameEQ) == 0) 165 { 166 return c.substring(nameEQ.length,c.length); 167 } 168 } 169 return null; 170 } 171 172 function ndeSetTheme() 173 { 174 ndeSetTextSize(); 175 return true; 176 } 177 178 function ndeGetLang() 179 { 180 var langString = ''; 181 182 if (document.documentElement){ 183 langString = document.documentElement.lang; 184 if (langString != ''){ 185 langString = '-' + langString; 186 } 187 } 188 return langString; 189 } 190 191 function checkForUpgrade() 192 { 193 var rvValue = -1; 194 195 if (navigator.product == 'Gecko') 196 { 197 rvValue = 0; 198 var ua = navigator.userAgent.toLowerCase(); 199 var rvStart = ua.indexOf('rv:'); 200 var rvEnd = ua.indexOf(')', rvStart); 201 var rv = ua.substring(rvStart+3, rvEnd); 202 var rvParts = rv.split('.'); 203 var exp = 1; 204 205 for (var i = 0; i < rvParts.length; i++) 206 { 207 var val = parseInt(rvParts[i]); 208 rvValue += val / exp; 209 exp *= 100; 210 } 211 } 212 213 if (!document.getElementById || ( rvValue >= 0 && rvValue < 1.0)) 214 { 215 var updateMessageShown = ndeReadCookie('upgrade'); 216 if (!updateMessageShown) 217 { 218 ndeCreateCookie('upgrade','1', 90); 219 // check if cookie written. If not, don't redirect 220 if (ndeReadCookie('upgrade')) 221 { 222 document.location = '/upgrade.html'; 223 } 224 } 225 } 226 } 227 228 function printAlert() 229 { 230 alert('Thanks to the use of a print-media stylesheet, this page is already printer-friendly! Just print the article from a CSS-capable browser to get the print styles on paper.'); 231 } 232 233 function init() 234 { 235 cssjsmenu('navbar'); 236 cssjsmenu('nde-config'); 237 if (document.getElementById) 238 { 239 var kill = document.getElementById('hoverJS'); 240 kill.disabled = true; 241 } 242 } 243 244 // csjsmenu.js 245 246 function elementContains(elmOuter, elmInner) 247 { 248 while (elmInner && elmInner != elmOuter) 249 { 250 elmInner = elmInner.parentNode; 251 } 252 if (elmInner == elmOuter) 253 { 254 return true; 255 } 256 return false; 257 } 258 259 function getPageXY(elm) 260 { 261 var point = { x: 0, y: 0 }; 262 while (elm) 263 { 264 point.x += elm.offsetLeft; 265 point.y += elm.offsetTop; 266 elm = elm.offsetParent; 267 } 268 return point; 269 } 270 271 function setPageXY(elm, x, y) 272 { 273 var parentXY = {x: 0, y: 0 }; 274 275 if (elm.offsetParent) 276 { 277 parentXY = getPageXY(elm.offsetParent); 278 } 279 280 elm.style.left = (x - parentXY.x) + 'px'; 281 elm.style.top = (y - parentXY.y) + 'px'; 282 } 283 284 /* ------------------------------------------------------------ */ 285 /* file boundary */ 286 287 function cssjsmenu(menuid) 288 { 289 var i; 290 var j; 291 var node; 292 var child; 293 var parent; 294 295 // if the browser doesn't even support 296 // document.getElementById, give up now. 297 if (!document.getElementById) 298 { 299 return true; 300 } 301 302 // check for downlevel browsers 303 // Opera 6, IE 5/Mac are not supported 304 305 var version; 306 var offset; 307 308 offset = navigator.userAgent.indexOf('Opera'); 309 if (offset != -1) 310 { 311 version = parseInt('0' + navigator.userAgent.substr(offset + 6), 10); 312 if (version < 7) 313 { 314 return true; 315 } 316 } 317 318 offset = navigator.userAgent.indexOf('MSIE'); 319 if (offset != -1) 320 { 321 if (navigator.userAgent.indexOf('Mac') != -1) 322 { 323 return true; 324 } 325 } 326 327 var menudiv = document.getElementById(menuid); 328 329 // ul 330 var ul = new Array(); 331 332 for (i = 0; i < menudiv.childNodes.length; i++) 333 { 334 node = menudiv.childNodes[i]; 335 if (node.nodeName.toUpperCase() == 'UL') 336 { 337 ul[ul.length] = node; 338 } 339 } 340 341 // ul > li 342 var ul_gt_li = new Array(); 343 344 for (i = 0; i < ul.length; i++) 345 { 346 node = ul[i]; 347 for (j = 0; j < node.childNodes.length; j++) 348 { 349 child = node.childNodes[j]; 350 if (child.nodeName.toUpperCase() == 'LI') 351 { 352 ul_gt_li[ul_gt_li.length] = child; 353 child.style.display = 'inline'; 354 child.style.listStyle = 'none'; 355 child.style.position = 'static'; 356 } 357 } 358 } 359 360 // ul > li > ul 361 var ul_gt_li_gt_ul = new Array(); 362 363 for (i = 0; i < ul_gt_li.length; i++) 364 { 365 node = ul_gt_li[i]; 366 for (j = 0; j < node.childNodes.length; j++) 367 { 368 child = node.childNodes[j]; 369 if (child.nodeName.toUpperCase() == 'UL') 370 { 371 ul_gt_li_gt_ul[ul_gt_li_gt_ul.length] = child; 372 child.style.position = 'absolute'; 373 child.style.left = '-13em'; 374 child.style.visibility = 'hidden'; 375 376 // attach hover to parent li 377 parent = child.parentNode; 378 parent.onmouseover = function (e) 379 { 380 var i; 381 var child; 382 var point; 383 384 // stop the pure css hover effect 385 this.style.paddingBottom = '0'; 386 387 for (i = 0; i < this.childNodes.length; i++) 388 { 389 child = this.childNodes[i]; 390 if (child.nodeName.toUpperCase() == 'UL') 391 { 392 point = getPageXY(this); 393 setPageXY(child, point.x, point.y + this.offsetHeight); 394 child.style.visibility = 'visible'; 395 } 396 } 397 return false; 398 }; 399 parent.onmouseout = function (e) 400 { 401 var relatedTarget = null; 402 if (e) 403 { 404 relatedTarget = e.relatedTarget; 405 // work around Gecko Linux only bug where related target is null 406 // when clicking on menu links or when right clicking and moving 407 // into a context menu. 408 if (navigator.product == 'Gecko' && navigator.platform.indexOf('Linux') != -1 && !relatedTarget) 409 { 410 relatedTarget = e.originalTarget; 411 } 412 } 413 else if (window.event) 414 { 415 relatedTarget = window.event.toElement; 416 } 417 418 if (elementContains(this, relatedTarget)) 419 { 420 return false; 421 } 422 423 var i; 424 var child; 425 for (i = 0; i < this.childNodes.length; i++) 426 { 427 child = this.childNodes[i]; 428 if (child.nodeName.toUpperCase() == 'UL') 429 { 430 child.style.visibility = 'hidden'; 431 } 432 } 433 return false; 434 }; 435 } 436 } 437 } 438 return true; 439 } 440
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 16:45:43 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |