[phpBB Debug] PHP Warning: in file [ROOT]/includes/crs/crs_misc_functions.php on line 37: mime_content_type(): Empty filename or path
[phpBB Debug] PHP Warning: in file [ROOT]/includes/crs/crs_misc_functions.php on line 37: mime_content_type(): Empty filename or path
Zen Cart 源代码 menu.js

Zen Cart 源代码 menu.js




下载文件

文件名: menu.js
文件类型: Javascript文件
文件大小: 9.73 KiB
MD5: f9c100be7e672c43c8f9d1f6fe26f342

menu.js - 关闭高亮
  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.     offset = navigator.userAgent.indexOf('Version/');
  317.     version = parseInt('0' + navigator.userAgent.substr(offset + 8), 10);
  318.     if (version >= 12 && navigator.userAgent.indexOf('Windows') != -1) version = 'Opera12win';
  319.   }
  320.  
  321.   offset = navigator.userAgent.indexOf('MSIE');
  322.   if (offset != -1)
  323.   {
  324.     if (navigator.userAgent.indexOf('Mac') != -1)
  325.     {
  326.       return true;
  327.     }
  328.   }
  329.  
  330.   var menudiv = document.getElementById(menuid);
  331.  
  332.   // ul
  333.   var ul = new Array();
  334.  
  335.   for (i = 0; i < menudiv.childNodes.length; i++)
  336.   {
  337.     node = menudiv.childNodes[i];
  338.     if (node.nodeName.toUpperCase() == 'UL')
  339.     {
  340.       ul[ul.length] = node;
  341.     }
  342.   }
  343.  
  344.   // ul > li
  345.   var ul_gt_li = new Array();
  346.  
  347.   for (i = 0; i < ul.length; i++)
  348.   {
  349.     node = ul[i];
  350.     for (j = 0; j < node.childNodes.length; j++)
  351.     {
  352.       child = node.childNodes[j];
  353.       if (child.nodeName.toUpperCase() == 'LI')
  354.       {
  355.         ul_gt_li[ul_gt_li.length] = child;
  356.         child.style.display = 'inline';
  357.         child.style.listStyle = 'none';
  358.         if (version != 'Opera12win') child.style.position = 'static';
  359.       }
  360.     }
  361.   }
  362.  
  363.   // ul > li > ul
  364.   var ul_gt_li_gt_ul = new Array();
  365.  
  366.   for (i = 0; i < ul_gt_li.length; i++)
  367.   {
  368.     node = ul_gt_li[i];
  369.     for (j = 0; j < node.childNodes.length; j++)
  370.     {
  371.       child = node.childNodes[j];
  372.       if (child.nodeName.toUpperCase() == 'UL')
  373.       {
  374.         ul_gt_li_gt_ul[ul_gt_li_gt_ul.length] = child;
  375.         child.style.position = 'absolute';
  376.         if (version != 'Opera12win') child.style.left = '-13em';
  377.         child.style.visibility = 'hidden';
  378.  
  379.         // attach hover to parent li
  380.         parent = child.parentNode;
  381.         parent.onmouseover = function (e)
  382.         {
  383.           var i;
  384.           var child;
  385.           var point;
  386.  
  387.           // stop the pure css hover effect
  388.           this.style.paddingBottom = '0';
  389.  
  390.           for (i = 0; i < this.childNodes.length; i++)
  391.           {
  392.             child = this.childNodes[i];
  393.             if (child.nodeName.toUpperCase() == 'UL')
  394.             {
  395.               point = getPageXY(this);
  396.               if (version != 'Opera12win') setPageXY(child, point.x, point.y + this.offsetHeight);
  397.               child.style.visibility = 'visible';
  398.             }
  399.           }
  400.           return false;
  401.         };
  402.         parent.onmouseout = function (e)
  403.         {
  404.           var relatedTarget = null;
  405.           if (e)
  406.           {
  407.             relatedTarget = e.relatedTarget;
  408.             // work around Gecko Linux only bug where related target is null
  409.             // when clicking on menu links or when right clicking and moving
  410.             // into a context menu.
  411.         if (navigator.product == 'Gecko' && navigator.platform.indexOf('Linux') != -1 && !relatedTarget)
  412.         {
  413.           relatedTarget = e.originalTarget;
  414.         }
  415.           }
  416.           else if (window.event)
  417.           {
  418.             relatedTarget = window.event.toElement;
  419.           }
  420.  
  421.           if (elementContains(this, relatedTarget))
  422.           {
  423.             return false;
  424.           }
  425.  
  426.           var i;
  427.           var child;
  428.           for (i = 0; i < this.childNodes.length; i++)
  429.           {
  430.             child = this.childNodes[i];
  431.             if (child.nodeName.toUpperCase() == 'UL')
  432.             {
  433.                 child.style.visibility = 'hidden';
  434.             }
  435.           }
  436.           return false;
  437.         };
  438.       }
  439.     }
  440.   }
  441.   return true;
  442. }
  443.  
  444.