⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dtree.js

📁 尚洋仓库管理系统,对仓库
💻 JS
📖 第 1 页 / 共 4 页
字号:
//******************************************************************************
//
//    Deluxe Tree 1.x
//    Additional module for floatable & movable Tree Menu
//    http://deluxe-tree.com
//    (c) 2006, by deluxe-tree.com
//
//******************************************************************************
//
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//                              COMMENTS
//                            ------------
// 1. do not erase double brackets in while statement (NS6 issue).
//    For example: while ((it=funcname()))
//
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//
// 1. menu loads .js modules automatically. Problem: dtree_ss.js must be loaded BEFORE dtree.js!
// 2. dtree_ss.js is deleted, code moved into dtree.js
// 3.
// 4.
//


String.prototype.sb=function(s,e) {return this.substring(s,e)}
String.prototype.io=function(s)   {return this.indexOf(s)}
String.prototype.ln=function()    {return this.length}
 Array.prototype.ln=function()    {return this.length}


var isIE  = 0;
var isIE5 = 0;
var isNS  = 0;
var isNS4 = 0;
var isOP  = 0;
var isOP7 = 0;
var isMZ  = 0;
var isVER = 0;
var isDOM = 0;
var isMAC = 0;
var isIEPC =0;
var isIEComp = 0;                               // IE compatible (such as all IE and Opera 7+)
var dtdo = document;

dt_getBrowser();

var tdynamicTree = !(isNS4 || (isOP && isVER<7));
var tuf = 'undefined';
var docElement;                                 // Document object variable depending on <!DOCTYPE> tag. Used as document.body object.
var tuserLoadFunc = null;                       // var to remember user's onLoad event
var tcTimers      = [];

var dt_menu = [];                               // menu object
var tisLoaded  = 0;                             // is treemenu loaded

var tcurMenu = {
  ind  : 0,    	        // index of current processed menu
  mVar : null,
  itInd: -1,   		      // index of current processed item
  itVar: null,
  pitVar: null
}


var tmoveRec = {
  isMoving   : 0,       // if menu is in a moving process
  cX   : 0,             // capturing X coord
  cY   : 0,             // capturing Y coord
  mObj : 0,             // current movable menu object
  mVar : null           // current movable menu variable
}


var tcurBtn = 0;
var goffX = 0,
    goffY = 0;          // global page offset after page was loaded (non-zero in MAC IE only).


//##############################################################################
var taddedScripts = [];
if (typeof(tWorkPath)==tuf) var tWorkPath = '';

function dt_addScript(fname)
// Includes additional script files
{
  for (var i=0; i<taddedScripts.ln(); i++) if (taddedScripts[i]==fname) return;
  taddedScripts.push(fname);
  dtdo.write('<SCR'+'IPT SRC="'+tWorkPath+fname+'.js" type="text/javascript"></SCR'+'IPT>');
}
//##############################################################################


function dt_setDocElement()
{
  // Detect the document object according to <!DOCTYPE> specification
  docElement = (dtdo.compatMode=="CSS1Compat" && !isMZ) ? dtdo.documentElement : dtdo.body;
}


function dt_getBrowser()
// Detects browser
{
  var nv = navigator;
  var a = nv.userAgent;
  var n = nv.appName;
  var v = nv.appVersion;
  var ns = 'Netscape';
  var gk = 'Gecko';
  var pf = function(r) {return parseFloat(r)}
  isMAC = v.io("Mac")>=0;
  isDOM = dtdo.getElementById?1:0;

  // Safari detect
  if ((parseInt(nv.productSub)>=20020000) && (nv.vendor.io("Apple Computer") != -1) && (nv.product==gk))
  {
      isNS  = 1;
      isVER = 6;
      isSAF = 1;
      return;
  }

  // Konqueror detect
  if (n.toLowerCase()=='konqueror')
  {
      isMZ  = 1;
      isVER = 1.6;
      return;
  }

  // Opera detect
  if (a.io('Opera')>=0)
  {
      isOP     = 1;
      isVER    = pf(a.sb(a.io('Opera')+6, a.ln()));
      isIEComp = (isVER>=7);
		  return;
  }
  if (n.toLowerCase()=='netscape')
  {
      if (a.io('rv:')!=-1 && a.io(gk)!=-1 && a.io(ns)==-1)
      {
          isMZ  = 1;
          isVER = pf(a.sb(a.io('rv:')+3, a.ln()));
      }
      else
      {
          isNS = 1;
          if (a.io(gk) != -1 && a.io(ns)>a.io(gk))
          {
    	        if (a.io(ns+'6')>-1) isVER = pf(a.sb(a.io(ns)+10, a.ln()));
	            else
                  if (a.io(ns)>-1) isVER = pf(a.sb(a.io(ns)+9, a.ln()));
          }
          else
              isVER = pf(v);
      }
      isNS4 = isNS && isVER<6;
      return;
  }

  if (dtdo.all?1:0)
  {
      isIE     = 1;
      isVER    = pf(a.sb(a.io('MSIE ')+5, a.ln()));
      isIE5    = (isVER>=5);
      isIE6    = (isVER>=6);
      isIEComp = 1;
      isIEPC   = (isMAC?0:1);
      isIEMAC  = isMAC;
  }
  //alert("isIE = "+isIE+"\n"+"isOP = "+isOP+"\n"+"isMZ = "+isMZ+"\n"+"isNS = "+isNS+"\n"+"isDOM = "+isDOM+"\n"+"isMAC = "+isMAC+"\n"+"isVER = "+isVER);	
}


//##############################################################################
// GLOBAL PARAMS FUNCTIONS
//##############################################################################

dt_preDefineGlobalParams();

function dt_preDefineGlobalParams()
// Pre-defines global variables
{
  tpressedFontColor = '#AA0000',

  tcloseExpanded   = 0;
  tcloseExpandedXP = 0;

  tXPFilter         = 1;
  tXPTitleLeftWidth = 4;
  tXPBtnWidth    = 25;
  tXPBtnHeight   = 25;
  tXPIconWidth   = 31;
  tXPIconHeight  = 32;
  tXPBorderWidth = 1;
  tXPBorderColor = '#FFFFFF';

  titemBorderWidth = 0;
  titemBorderStyle = 0;
  titemBorderColor = 0;

  tfontColorDisabled = '#AAAAAA';

  tfloatableX=1;
  tfloatableY=1;

  tmenuHeight = '';
  tnoWrap = 1;

  ttoggleMode      = 0;
  tpathPrefix_link = '';
  tpathPrefix_img  = '';

  tmoveColor  = '#ECECEC';
  tmoveImageHeight = 12;
  
  titemHeight = 19;
  texpanded   = 0;
  
  tsaveState  = 0;
  tsavePrefix = 'pre';
  
  tlevelDX = 20;
  texpandItemClick = 0;
  tdynamic = 0;
}


function dt_checkGlobalParams()
{
  if (isNS4)
  {
      tfloatable = 0;
      tmovable   = 0;
  }

  with (tcurMenu)
  {
      itInd  = 0;
      itVar  = null;
      pitVar = null;
  }

  if (tfloatIterations<=0) tfloatIterations = 6;
  if (!tmenuWidth) tmenuWidth = '200';

  tpoints = tdynamicTree ? tpoints : 0;                                           // draw tree lines if browser support dynamic tree
  if (titemCursor=='pointer' && isIE) titemCursor = 'hand';


  // XP-style parameters
  if (tXPStyle)
      if (tXPIterations<=0) tXPIterations=1;
}


function dt_getObjectStyleXY(obj)
{
  with (obj) return [parseInt(style.left), parseInt(style.top)];
}


function dt_load()
{
  dt_setDocElement();                                                            // Detect document object according to <DOCTYPE> specification

  var mObj = dt_getObjectByID("dt_0div");
  var xy = dt_getObjectStyleXY(mObj);                                           // get current coords from object.style
  goffX = dt_menu[0].left - xy[0];
  goffY = dt_menu[0].top  - xy[1];
 
  tisLoaded = 1;	                                                                // all data were loaded


  // Initialize floatable and movable menu
  if (!(isOP && isVER<6))                                                         // cancel floatable mode for Opera 5: links don't work if enabled
  {
      var f=0, j=0;
      while (j<dt_menu.ln() && !(f=(dt_menu[j].floating && dt_menu[j].absPos))) j++;
      if (f) window.setInterval('dt_ScrollWindow()', 20);

      var f=0, j=0;
      while (j<dt_menu.ln() && !(f=(dt_menu[j].moving && dt_menu[j].absPos))) j++;
      if (f) dt_assignMoveEvent();                                              // assign mousemove event for the moveable menu
  }


  if (tuserLoadFunc) tuserLoadFunc();                                             // execute user's onLoad event
}


function dt_setOnLoad()
// Attaches onload event to user's onload event (only if user defined the event before this script)
// window.attachEvent method was removed because it's necessary that user's onload event will be executed after menu's onload event
{
    tuserLoadFunc = (typeof(onload)=='function') ? onload : null;                 // remember user's onLoad event one time
    onload = dt_load;                                                           // set own onLoad event one time
}


function dt_GetParam(param, defparam) {
  return (typeof(param)!=tuf && param)?param:defparam;
}


function dt_getNextItem(itVar)
// Returns next item in the menu
{
  if (!itVar) return null;
  if (itVar.hasChild) return itVar.i[0];                                          // item has subitems => return the first child

  var pitVar = itVar.parentIt;
  if (!pitVar) return null;

  if (itVar.ind<pitVar.i.ln()-1)  return pitVar.i[itVar.ind+1];                   // item isn't the last one in submenu => return next item
  if (itVar.ind==pitVar.i.ln()-1)
  {
      while (pitVar.parentIt)
      {
          with (pitVar) if (parentIt.i[ind+1]) return parentIt.i[ind+1];
          pitVar = pitVar.parentIt;
      }
      return null;
  }
}


function dt_getLastChild(itVar)
{
  if (itVar.i.ln()) return dt_getLastChild(itVar.i[itVar.i.ln()-1])
  else
      return itVar;
}


function dt_getPrevItem(itVar)
// Returns previous item in the menu
{
  if (!itVar) return null;

  var pitVar = itVar.parentIt;
  if (!pitVar) return null;

  if (itVar.ind==0)                                                               // item is the first one in submenu
  {
      if (!pitVar.parentIt) return null;                                          // item is the first in menu
      return pitVar;                                                              // return parent item
  }

  if (itVar.ind>0)                                                                // item isn't the first one in submenu
      return dt_getLastChild(pitVar.i[itVar.ind-1]);
}


function dt_getLastItem(mInd)
// Returns last item in the menu
{
  with (dt_menu[mInd]) var itVar=i[i.ln()-1];
  var it;
  while ((it=dt_getNextItem(itVar))) itVar = it;
  return itVar;
}


function dt_setPointsMask(lvl, len, prevLvls, prevLvl)
// Sets points mask parameter for item (e.g. 00111: 0 - no points; 1 - draw points)
{
  var lvls='';
  for (var i=0; i<=len; i++)
  {
      if (prevLvls.charAt(i)!='0' && i<=lvl)  // previous position has points and not on current level yet
          lvls += '1';
      else
          lvls += (i==lvl) ? ((lvl!=prevLvl) ? '2' : '1') : '0';
  }
  return lvls;
}


function dt_detectPointsDraw(menu, maxNesting)
{
  with (menu)
  {
        var zeroLvl = dt_setPointsMask(-1, maxNesting, '', 0);  // fill string by zeroes
        var itVar = dt_getLastItem(menu.ind);

        with (itVar) ptMask = dt_setPointsMask(level, maxNesting, zeroLvl, 99999999);     // fill level mask for the last item

        var it;
        while ((it=dt_getPrevItem(itVar)))
        {
            with (it) ptMask = dt_setPointsMask(level, maxNesting, itVar.ptMask, itVar.level);
            itVar = it;
        }

  }
}


//##############################################################################
// PREFIX FUNCTIONS
//##############################################################################

var tfixPrefixes = ['javascript:', 'mailto:', "http://", "https://", "ftp://"];

function dt_canPrefix(url)
{
  for (var i=0; i<tfixPrefixes.ln(); i++)
      if (url.io(tfixPrefixes[i])==0) return 0;
  return 1;
}


function dt_setPathPrefix(paths, prefix)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -