Cascading Style Sheets Tutorial

My Ajax download code

  <! – 
  String.prototype.getParam = function (name) 
  ( 
  Var reg = new RegExp ("(^|;| \ \ s) "+ name +" \ \ s *: \ \ s *([^;]*)( \ \ s |; | $) "," i " ); 
  Var str = this.replace (/(;[^:]+)(;|$)/ g, function (a, b, c) (return b.replace (/; / g, "\ x0f") + c ;)); 
  Var r = str.match (reg); 
  If (r! = Null) 
  Return unescape (r [2]. Replace (/ [\ x0f] / g, ";")); 
  Return ""; 
  ) 

  Function getObjectById (id) 
  ( 
  If (typeof (id)! = "String" | | id == "") return null; 
  If (document.all) return document.all (id); 
  If (document.getElementById) return document.getElementById (id); 
  Try (return eval (id);) catch (e) (return null;) 
  ) 

  Function MzTreeView (Tname) 
  ( 
  If (typeof (Tname)! = "String" | | Tname == "") 
  Throw (new Error (-1, 'no Class Name')); 

  This.divider = "_"; 
  This.url = "#"; 
  This.target = "_self"; 
  This.name = Tname; 
  This.index = 0; 
  This.nodes = (); 
  This.nodeFilePath = ""; 
  This.currentNode = null; 

  Var highLight = "# 0A246A"; 
  Var highLightText = "# FFFFFF"; 
  Var mouseOverBgColor = "# D4D0C8"; 

  This.createHTML = function (node, AtEnd) 
  ( 
  Var data = node.data; 
  Var id = node.id; 
  Var url = node.url; 
  If (! Url) url = this.url; 
  If (data) url + = (url.indexOf ( "\ ?")==- 1?" \ ?":"&") + Data; 
  Var HCN = node.hasChild, isRoot node.parentId == = "0"; 
  If (isRoot & node.icon =="") node.icon = "root"; 
  If (HCN node.icon =="") node.icon =? "Folder": "file"; 
  Node.iconExpand = HCN? AtEnd? "PM2": "PM1": AtEnd? "L2": "L1"; 
  If (node.id! = "0" & &! IsRoot) node.childAppend + = node.parentNode.childAppend 
  "<IMG Border='0' align='absmiddle' src='"+this.icons[(AtEnd?"empty":"L4")].src+"'>"; 

  Var nodeHTML = "<DIV noWrap> <SPAN onmouseover = 'this.style.backgroundColor = \" "+ 
  MouseOverBgColor + "\" 'onmouseout =' this.style.backgroundColor = \ "\" '> <NOBR> "+ 
  (IsRoot? "": Node.parentNode.childAppend + 
  "<IMG border ='0 'align =' absmiddle 'id ='" + + Tname "_expand_" + id + " '" + 
  (HCN? "Onclick = \" "+ + Tname." Expand ( ' "+ id +"') \ "": "") + 
  "Src = '" + this.icons [node.iconExpand]. Src + "' style = 'cursor: hand'>")+ 
  "<SPAN oncontextmenu = 'return" Tname + +. "Popupmenu (\" "+ id +" \ ")'" 
  / / + "Onclick = \" "+ + Tname." Focus ( ' "+ id +"', true) \ "" + (HCN? "Ondblclick = \" "+ + Tname." Expand ( ' "+ id + " ') \" ":" ") 
  + (HCN? "Onclick = \" "+ + Tname." Expand ( ' "+ id +"', true); "Tname + +." Focus ( ' "+ id +"', true); \ "" : "onclick = \" "+ + Tname." focus ( ' "+ id +"', true); \ "") 
+">"+
  "<IMG border ='0 'align =' absmiddle 'id ='" + + Tname "_icon_" + id + " '" + 
  "Src = '" + this.icons [node.icon]. Src +"'>"+ 
  "<A class = 'MzTreeview' id = '" + + Tname "_link_" + id + "'"; 
  NodeHTML + = "target = '" + this.target + "'"; 
  NodeHTML + = "href = '" + url + "'"; 
  NodeHTML + = "title = '" + node.hint + "' onclick = '" + 
  "Return" Tname + +. "Click (\" "+ id +" \ ");'>"+ node.text + "</ A> </ NOBR>" + 
  "</ SPAN> </ SPAN> </ DIV> \ r \ n"; if (isRoot & node.text =="") nodeHTML = ""; 
  NodeHTML + = "<SPAN id='"+ Tname +"_tree_"+ id +"' style='DISPLAY: none'> </ SPAN>"; 
  Return nodeHTML; 
  ); 

  Var _d = "\ x0f"; 
  This.node = (); 
  This.node [ "0"] = 
  ( 
  "Id": "0", 
  "Path": "0", 
  "IsLoad": false, 
  "ChildNodes": new Array (), 
  "ChildAppend": "" 
  "SourceIndex": "0", 
  "ChildNodesFileName": "" 
  ); 

  This.XMLHttpLoadFile = function (url, id) 
  ( 
  Var httpRequest; 
  If (typeof XMLHttpRequest! = 'Undefined') ( 
  HttpRequest = new XMLHttpRequest (); 
  ) 
  Else if (typeof ActiveXObject! = 'Undefined') ( 
  HttpRequest = new ActiveXObject ( 'Microsoft.XMLHTTP'); 
  ) 
  If (httpRequest) ( 
  HttpRequest.open ( 'GET', url, false); 
  HttpRequest.send (null); 
  If (httpRequest.status == 200) 
  ( 
  Var textInfo = httpRequest.responseText; 
  Eval (textInfo); 
  ) 
  ) 
  ) 

  This.load = function (id, and sign) 
  ( 
  = Var me this, node = this.node [id]; 
  If (sign & & (id> 0)) 
  ( 
  SetTimeout (me.name +. "Load ( '" + id + "', false)," 1); 
  GetObjectById (me.name + "_tree_" + id). InnerHTML = node.childAppend + 
  "<IMG Border='0' align='absmiddle' src='"+this.icons["L2"].src+"'>" + 
  "<IMG Border='0' align='absmiddle' src='"+this.icons["file"].src+"'>" + 
  "<Span style = 'background-Color:" + + highLight "color:" + + highLightText 
  "Font-size: 9pt '>" + unescape ( "% u52A0% u8F7D% u4E2D") +"…</ span> "; 
  Return; 
  ) 

  If (! Node.isLoad) 
  ( 
  If ((node.childNodesFileName) & & (node.childNodesFileName! = "Undefined ")&&( node.childNodesFileName.length> 0)) 
  ( 
  This.XMLHttpLoadFile (node.childNodesFileName, id); 
  Node.isLoad = true; 
  ) 
  ) 

  Var sid = node.sourceIndex.substr (node.sourceIndex.indexOf (this.divider) + this.divider.length); 
  Var str = "(^|"+ _d +")"+ sid + + this.divider +"[^"+ _d this.divider +"]+("+ _d +"|$)"; 
  Var reg = new RegExp (str, "g"), cns = this.names.match (reg), tcn = this.node [id]. ChildNodes; 
  If (cns) ( 
  Reg = new RegExp (_d, "g"); 
  For (var i = 0; i <cns.length; i + +) 
  ( 
  Var tmp [i] = cns. Replace (reg, ""); 
  Tcn [tcn.length] = this.nodeInit (tmp, id); 
  ) 
  ) 
  Node.isLoad = true; if (node.id == "0") return; 
  This.drawNode (id); 
  ); 

  This.nodeInit = function (sourceIndex, parentId) 
  ( 
  This.index + +; 
  Var param = this.nodes [sourceIndex]; 
  Var hint = param.getParam ( "hint"); 
  Var text = param.getParam ( "text"); 
  Var childNodesFileNameValue = param.getParam ( "childNodesFileName"); 
  Var sid = sourceIndex.substr (sourceIndex.indexOf (this.divider) + this.divider.length); 

  This.node [this.index] = ( 
  "Id": this.index, 
  "Text": text, 
  "Hint": hint? Hint: text, 
  "Icon": param.getParam ( "icon") 
  "Path": this.node [parentId]. Path + + this.index this.divider, 
  "IsLoad": false, 
  "IsExpand": false, 
  "ParentId": parentId, 
  "ParentNode": this.node [parentId] 
  "SourceIndex": sourceIndex, 
  "ChildAppend": "" 
  "ChildNodesFileName": childNodesFileNameValue (childNodesFileNameValue this.nodeFilePath +): "" 
  "Url": param.getParam ( "url") 
  "Data": param.getParam ( "data") 

  ); 
  If (childNodesFileNameValue) 
  ( 
  This.node [this.index]. HasChild = true; 
  ) 
  Else 
  ( 
  This.node [this.index]. HasChild = this.names.indexOf (sid _d + + this.divider)> -1; 
  ) 
  If (this.node [this.index]. HasChild) this.node [this.index]. ChildNodes = new Array (); 
  This.nodes [sourceIndex] = this.index; 
  Return this.node [this.index]; 
  ); 

  This.drawNode = function (id) 
  ( 
  Var tcn = this.node [id]. ChildNodes, str = ""; 
  For (var i = 0; i <tcn.length; i + +) str + = this.createHTML (tcn [i], i == tcn.length-1); 
  GetObjectById (Tname + "_tree_" + id). InnerHTML = str; 
  ); 

  This.getPath = function (id) 
  ( 
  Var A = new Array (); A [0] = id, pid = id; 
  While (id! = "0" & id !="") 
  ( 
  "(^|"+_ Var str = d + d +")([^"+_ this.divider +"]+"+ this.divider + id +")("+_ d +"|$)"; 
  Var ids = this.names.match (new RegExp (str, "g")); 
  If (ids) 
  ( 
  Id = ids [0]. Replace (_d, ""). Split (this.divider) [0]; 
  A [A.length] = id; 
  ) Else break; 
  ) 
  Return A.reverse (); 
  ); 

  This.focus = function (id, onlySimpleFocus) 
  ( 
  If (! This.currentNode) this.node this.currentNode = [ "0"]; if (! OnlySimpleFocus) ( 
  If (typeof (this.node [id ])==" undefined ") = var apid this.getPath (id); 
  This.node else var apid = [id]. Path.split (this.divider); 
  For (var i = 0; i <apid.length-1; i + +) this.expand (apid [i], true);) 

  Var a = getObjectById (Tname + "_link_" + id); if (a) (a.focus ();// alert ( "focus" + id); 
  Var link = getObjectById (Tname + "_link_" + this.currentNode.id); 
  If (link) with (link.style) (color = ""; backgroundColor ="";} 
  With (a.style) (color = highLightText; backgroundColor = highLight;) 
  This.node this.currentNode = [id];) 
  ); 

  This.expand = function (id, sureExpand) 
  ( 
  Var node = this.node [id]; 
  If (sureExpand & node.isExpand) return; 
  Var area = getObjectById (Tname + "_tree_" + id); 
  If (area) 
  ( 
  Var icon = this.icons [node.icon]; 
  Var iconE = this.iconsExpand [node.icon]; 
  Var exp = this.icons [node.iconExpand]; 
  Var expE = this.iconsExpand [node.iconExpand]; 
  = = Var Bool node.isExpand sureExpand | | area.style.display == "none"; 

  Var img = getObjectById (Tname + "_icon_" + id); 
  If (img) img.src =! Bool? Icon.src: typeof (iconE) == "undefined"? Icon.src: iconE.src; 

  Var img = getObjectById (Tname + "_expand_" + id); 
  If (img) img.src =! Bool? Exp.src: typeof (expE) == "undefined"? Exp.src: expE.src; 

  If (! Bool & this.currentNode.path.indexOf (node.path) == 0) 
  ( 
  This.focus (id, true); 
  This.click (id); 
  ) 
  Area.style.display = Bool? "Block": "none"; 
  If (! Node.isLoad) 
  ( 
  This.load (id, true); 
  ) 
  ) 
  ); 

  This.toString = function () 
  ( 
  Var a = new Array (); for (id in this.nodes) a [a.length] = id; 
  This.names = a.join (_d _d +); this.load ( "0", true); 
  Var rootCN this.node = [ "0"]. ChildNodes; 
  Var str = "<A id='"+ Tname +"_RootLink' href='#' style='DISPLAY: none'> </ A>"; 
  If (rootCN.length> 0) 
  ( 
  For (var i = 0; i <rootCN.length; i + +) str + = this.createHTML (rootCN [i], i == rootCN.length-1); 
  SetTimeout (Tname +. "Expand ( '" + rootCN [0]. Id + "', true);" + 
  Tname +. "Focus ( '" + rootCN [0]. Id +"'); "Tname + +." AtRootIsEmpty () ", 10); 
  ) 
  Return str; 
  ); 
  ) 

  MzTreeView.prototype.setIconPath = function (path) 
  ( 
  This.icons = ( 
  L0: 'L0.gif', / / ³ 
  L1: 'L1.gif', / / Ç 
  L2: 'L2.gif', / / » 
  L3: 'L3.gif', / / ¥ 
  L4: 'L4.gif', / / § 
  PM0: 'P0.gif', / / ³ 
  PM1: 'P1.gif', / / Ç 
  PM2: 'P2.gif', / / » 
  PM3: 'P3.gif', / / ¥ 
  Empty: 'L5.gif', / / blank 
  Root: 'root.gif', / / root 
  Folder: 'folder.gif', / / folder 
  File: 'file.gif', / / file 

  Event: 'event.gif' 
  Object: 'object.gif' 
  Behavior: 'behavior.gif' 
  Property: 'property.gif' 
  Method: 'method.gif' 
  Collection: 'collection.gif' 

  Exit: 'exit.gif' 
  ); 

  This.iconsExpand = ( 
  PM0: 'M0.gif', / / ³ 
  PM1: 'M1.gif', / / Ç 
  PM2: 'M2.gif', / / » 
  PM3: 'M3.gif', / / ¥ 
  Folder: 'folderopen.gif' 

  Exit: 'exit.gif' 
  ); 
  For (var i in this.icons) 
  ( 
  Var tmp = this.icons [i]; 
  This.icons [i] = new Image (); 
  This.icons [i]. Path + src = tmp; 
  ) 
  For (var i in this.iconsExpand) 
  ( 
  Var tmp = this.iconsExpand [i]; 
  This.iconsExpand [i] = new Image (); 
  This.iconsExpand [i]. Path + src = tmp; 
  ) 
  ) 

  MzTreeView.prototype.atRootIsEmpty = function () 
  ( 
  Var RCN this.node = [ "0"]. ChildNodes; 
  For (var i = 0; i <RCN.length; i + +) 
  ( 
  If (RCN [i]. Text =="") 
  ( 
  Var node = RCN [i]. ChildNodes [0] = node.hasChild HCN; 
  Node.iconExpand [i] = RCN. ChildNodes.length> 1? HCN? "PM0": "L0": HCN? "PM3": "L3" 
  GetObjectById (this.name + "_expand_" + node.id). Src = this.icons [node.iconExpand]. Src; 
  ) 
  ) 
  ); 

  MzTreeView.prototype.popupmenu = function (id) 
  ( 
  Try 
  ( 
  If (this.popupMenu) 
  ( 
  If (id) 
  ( 
  This.node this.popupMenu.data = [id]. Data; 
  This.node this.popupMenu.treeviewitem = [id]; 
  ) 
  For (var i = 0; i <this.popupMenu.items.length; i + +) 
  ( 
  If (this.popupMenu.items [i]. Bind! = "") 
  This.popupMenu.items [i]. Bind Tname + = "_tree_" + Tname; 
  ) 
  This.popupMenu.show (window.event, window.event.srcElement); 
  Return false; 
  ) 
  Else return true; 
  ) Catch (e) () 
  ); 

  MzTreeView.prototype.click = function (id) 
  ( 
  If ((this.node [id]. Url == this.url) | | ((this.node [id]. Url == "")&&( this.node [id]. Data == "")) ) return false; 
  Return true; 
  ); 
  / / -> 

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Facebook
  • Google
  • DotNetKicks
  • DZone

Tags: css code, css code generator, css color code, css download, css map download div, tutorial download css

Releated Posts

  • Ajax achieve WebForm in drag controls, and immediately preserved in the service-state data (Asp.net 2.0) (sample code download)
  • Click advertising appears to download the code addresses
  • Summary: A CSS code reference map
  • Domestic famous picture Station ~! Guide Web site _ _ _ Web Design Guide website effects _ _ _ free domain name space to download code
  • Diy easily with the CSS code to your web page scroll

This entry was posted on Thursday, November 29th, 2007 at 12:00 am and is filed under CSS Tutorial By Examples. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

« Ajax jumped out of the mindset
Web2.0 features List »

Leave a Reply

  • Categories

    • CSS Properties (491)
    • CSS Tutorial (1154)
    • CSS Tutorial By Examples (1201)
    • Css+Div Web Design (3274)
    • Xhtml and Web Design (1797)
  • Archives

    • February 2008
    • January 2008
    • December 2007
    • November 2007
    • October 2007
    • September 2007
    • August 2007
    • July 2007
    • June 2007
    • May 2007
    • April 2007
    • March 2007
    • February 2007
    • January 2007
  • Pages

    • About us

Cascading Style Sheets Tutorial