使用Popup視窗建立無限級Web頁菜單(4) function Menu()
使用Popup視窗建立無限級Web頁菜單(4) {
使用Popup視窗建立無限級Web頁菜單(4) this.m_Items = []; // 菜單條目集合
使用Popup視窗建立無限級Web頁菜單(4) this.m_Popup = null; // 顯示菜單的popup視窗
使用Popup視窗建立無限級Web頁菜單(4) this.m_Invalidate = false; // 是否失效标志
使用Popup視窗建立無限級Web頁菜單(4) this.m_Drawn = false; // 菜單是否已輸出
使用Popup視窗建立無限級Web頁菜單(4) this.m_Opener = null; // 菜單的父視窗window對象
使用Popup視窗建立無限級Web頁菜單(4) this.m_ParentMenu = null; // 菜單的父菜單MenuItem對象
使用Popup視窗建立無限級Web頁菜單(4) this.m_ActiveItem = null; // 被激活(highlighting)的MenuItem
使用Popup視窗建立無限級Web頁菜單(4) this.m_ShowTimer = null; // 滑鼠停留在有子菜單的條目上,子菜單顯示延遲計時器
使用Popup視窗建立無限級Web頁菜單(4) this.m_Bounds = null; // 菜單的bounds
使用Popup視窗建立無限級Web頁菜單(4) this.m_ShowHeaderBlank = true; // 是否顯示MenuItem前的空白區域
使用Popup視窗建立無限級Web頁菜單(4) this.m_IsEventAttached = false; // 事件是否attached
使用Popup視窗建立無限級Web頁菜單(4) this.m_Id = __MenuCache__.NewId(); // 或取菜單對象的唯一辨別
使用Popup視窗建立無限級Web頁菜單(4) __MenuCache__[this.m_Id] = this; // 把菜單放入__MenuCache__
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4) this.toString = function()
使用Popup視窗建立無限級Web頁菜單(4) {
使用Popup視窗建立無限級Web頁菜單(4) return '[class Menu]';
使用Popup視窗建立無限級Web頁菜單(4) };
使用Popup視窗建立無限級Web頁菜單(4) }
菜單類的方法有:
使用Popup視窗建立無限級Web頁菜單(4) Menu.prototype.Add = function(mi)
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4) // 添加菜單條目到菜單中
使用Popup視窗建立無限級Web頁菜單(4) };
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4) Menu.prototype.AddAt = function(mi, index)
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4) // 把菜單條目添加到指定的數組索引上
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4) Menu.prototype.AddSeparator = function()
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4) // 添加一個Separator Item,就是我們在window菜單裡的"-"
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4) Menu.prototype.Remove = function(mi)
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4) // 删除菜單中的一個菜單條目
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4) Menu.prototype.Contains = function(menu)
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4) // 判斷已建構的菜單中是否已包含了menu
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4) Menu.prototype.Render = function()
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4) // 生成菜單UI顯示需要的DHTML
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4) Menu.prototype.__generatePaddingTR = function(doc)
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4) // 為了美化菜單UI生成的一個TR element
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4) Menu.prototype.AttachEvents = function(menu)
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4) // attach事件處理函數到菜單事件上
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4) Menu.prototype.ActiveItem = function(evt)
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4) // 處理菜單itme被Active後的UI和動作等
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4) Menu.prototype.Hide = function()
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4) // 隐藏菜單
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4) Menu.prototype.Keydown = function(evt)
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4) // 處理鍵盤按鍵
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4) Menu.prototype.Click = function()
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4) // 執行菜單被click
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4) Menu.prototype.ResumeItem = function(evt)
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4) // 恢複菜單,取消active和恢複UI
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4) Menu.prototype.__resumeItem = function()
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4) // 執行UI恢複
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4) Menu.prototype.__resumeAll = function()
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4) // 執行批量UI恢複
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4) Menu.prototype.__activeItem = function()
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4) // 執行UI激活
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4) Menu.prototype.HasSubMenuExpanded = function()
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4) // 判斷菜單是否有展開的submenu
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4) Menu.prototype.__isEllipsis = function(menuObj, menuHtml)
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4) // 在菜單item的text過長時将截斷并顯示"
使用Popup視窗建立無限級Web頁菜單(4) "
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4) Menu.prototype.Show = function(evt)
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4) // 顯示菜單
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4) Menu.prototype.InnerShow = function()
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4) // 顯示submenu,用于菜單内部觸發的菜單顯示
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4) Menu.prototype.__show = function(miObj)
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4) // 執行菜單顯示
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4) Menu.prototype.FadeinEffect = function(effect)
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4) // 菜單顯示式的特效,是用filter來實作,隻在Show菜的時候調用
使用Popup視窗建立無限級Web頁菜單(4) 類MenuItem比Menu類簡單很多,定義如下:
使用Popup視窗建立無限級Web頁菜單(4) function MenuItem(text, action, icon, shortcut, menu)
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4) this.m_Text = text; // 菜單文本
使用Popup視窗建立無限級Web頁菜單(4) this.m_Action = action; // 菜單條目被觸發時執行的函數
使用Popup視窗建立無限級Web頁菜單(4) this.m_Icon = icon; // 菜單條目前的圖示路徑
使用Popup視窗建立無限級Web頁菜單(4) this.m_ChildMenu = menu; // 子菜單,類型為Menu對象
使用Popup視窗建立無限級Web頁菜單(4) this.m_Menu = null; // 本菜單條目所在的菜單對象執行個體
使用Popup視窗建立無限級Web頁菜單(4) this.m_ShortCut = shortcut; // 快捷方式(保留,未實作)
使用Popup視窗建立無限級Web頁菜單(4) this.m_Disabled = false;
使用Popup視窗建立無限級Web頁菜單(4) this.m_Mnemonic = null;
使用Popup視窗建立無限級Web頁菜單(4) this.m_Tooltip = null;
使用Popup視窗建立無限級Web頁菜單(4) this.m_Attributes = []; // 附加屬性集合,由SetAttribute設定
使用Popup視窗建立無限級Web頁菜單(4) this.m_Id = __MenuCache__.NewId();
使用Popup視窗建立無限級Web頁菜單(4) __MenuCache__[this.m_Id] = this;
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4) return '[class MenuItem]';
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4) MenuItem類的方法如下:
使用Popup視窗建立無限級Web頁菜單(4) MenuItem.prototype.Contains = function(menu)
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4) // 子菜單中是否已添加menu
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4) MenuItem.prototype.SetAttribute = function(key, value)
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4) // 設定使用者定義的屬性
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4) MenuItem.prototype.GetAttribute = function(key)
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4) // 或取使用者定義的屬性
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4) MenuItem.prototype.Invalidate = function()
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4) // 失效
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4) MenuItem.prototype.IsSeparator = function()
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4) // 判斷MenuItem是否為Separator,就是其m_Text == '-'
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4) MenuItem.prototype.Render = function()
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4) // 生成菜單UI的DHTML
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4) MenuItem.prototype.SetBorderColor = function(miHtml, width, borderColor)
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4) // 設定菜單條目的邊框顔色
使用Popup視窗建立無限級Web頁菜單(4) "__"開頭的方法是内部方法,不提供給類外使用。變量命名規則m_開頭的是類屬性變量,Obj結尾的是菜單類對象,和它相對的是Html結尾的,使菜單的HTML元素對象,常見的是menuObj、menuHtml、miObj和miHTML。
Menu類中最重要的方法是:
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4)
使用Popup視窗建立無限級Web頁菜單(4) MenuItem主要是處理UI顯示,沒有太重要的方法。
本文轉自部落格園鳥食軒的部落格,原文連結:http://www.cnblogs.com/birdshome/,如需轉載請自行聯系原部落客。