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

📄 menubar.js

📁 javascript 很酷的类库
💻 JS
📖 第 1 页 / 共 2 页
字号:
/*
 * Isomorphic SmartClient
 * Version 6.5 (2008-04-30)
 * Copyright(c) 1998-2007 Isomorphic Software, Inc. All rights reserved.
 * "SmartClient" is a trademark of Isomorphic Software, Inc.
 *
 * licensing@smartclient.com
 *
 * http://smartclient.com/license
 */
 //>	@class	MenuBar//      A MenuBar is a bar of buttons used to show a set of menus.//  @treeLocation Client Reference/Control//  @visibility external//<// declare the class itselfisc.ClassFactory.defineClass("MenuBar", "Toolbar");// synonym: used to be named with lowercase "b"isc.addGlobal("Menubar", isc.MenuBar);// add default properties to the classisc.MenuBar.addProperties( {    //>	@attr	menuBar.menus		(Array of Menu : null : [IRW])    // An array of menu object initializers or instantiated menu objects. Buttons for each    // menu item will automatically be created. See the Menu Widget Class for fundamental    // menu properties and other properties.  Titles for the buttons are derived from the     // <code>title</code> property of each menu.    //  @visibility external    //  @see class:Menu    //<	//menus:null,			overflow:isc.Canvas.VISIBLE,    //>	@attr	menuBar.defaultHeight		(number : 22 : IRW)	// Default to height for menu bars	//		@group	sizing	//<	defaultHeight:22,							menuConstructor:"Menu",		//	menuDefaults:{},	    //>	@attr	menuBar.buttonConstructor		(Class : MenuBarButton : IRWA)	// Default constructor for menuBar buttons.  Change to a more exotic class if you dare!    // (untested)	//		@group	appearance	//<	buttonConstructor:"MenuBarButton",	    //> @attr menuBar.tabIndex  (number : -1 : IRWA)    // By default exclude menubars from the page's tab order. To include a menubar in the page's    // tab order, set tabIndex to an explicit tab index, or <code>null</code> for automatically     // assigned tabIndex    // @visibility external    //<    tabIndex:-1,        // We want arrow keys to move us around the toolbar, not tabs.    tabWithinToolbar:false,	//>	@attr	menuBar.buttonDefaults		(object : (see below) : IRWA)	//	The following are defaults for all menuBar buttons.  	//	To add properties to all buttons of ALL menuBars, change the below.	//	To add properties to all buttons of a particular menuBar you're creating,	//		add a "button" property to the menuBar constructor with the defaults	//		you want applied to the buttons.  This will automatically be added to each button.	//		@group	appearance	//<	buttonDefaults: {		showDown:false,		showRollOver:true,                showFocused:true,        showFocusedAsOver:true	}});isc.MenuBar.addMethods({//>	@method	menuBar.initWidget()	(A)// Initialize the menuBar object// <p>// Instantiates each Menu with automatically-generated IDs, using menuBar.menuConstructor and// menuBar.menuDefaults//<initWidget : function () {	// call the superclass function	this.Super("initWidget",arguments);		//Note: we don't instantiate menus until they are displayed -- reduces init time.},//>	@method	menuBar.setButtons()// Set up the menuBar buttons. Should not be called directly - use 'setMenus' instead.//		@group	drawing////		@param	[newButtons]	(object[])	//          list of button objects (object literal with 'title', 'width', etc)//<// Overridden to derive buttons from this.menus.// Called to initialize the menuBar on draw, and from setMenus only.setButtons : function (newButtons) {	newButtons = [];    // create a button for each menu	for (var i = 0; i < this.menus.length; i++) {        var menu = this.menus[i];        newButtons[i] = this._getButtonProperties(menu,i);    }    return this.Super("setButtons",[newButtons]);},// Helper method to get the properties for a menu button._getButtonProperties : function (menu, index) {    return {                   title:menu.title,                 width:(menu.menuButtonWidth ? menu.menuButtonWidth : menu.width),                 menuNum:index,                                focusChanged:function (hasFocus) {                    if (isc.Browser.isMoz && hasFocus) this.bringToFront();                }            };},//>	@method	menuBar.setMenus()// Dynamically reset the set of menus displayed by this menu bar. // @param menus (array) array of new menus for this menubar// @visibility external//<setMenus : function (menus) {    if (!isc.isAn.Array(menus)) menus = [menus];        for (var i = 0; i < this.members.length; i++) {        var member = this.members[i],            menu = this.menus[member.menuNum];        if (member.isObserving(menu, "hide")) {            member.ignore(menu, "hide");        }    }    this.menus = menus;    this.setButtons(menus);},// Helper method fired to update buttons in response to the menus shifting order// - clears out old observations (for buttons that may be removed from the menubar) //   and remaps menu numbers_remapButton : function (button, index) {    if (!button) return;    // in most cases we're still going to point at the same menu, but the position of that    // menu in the menus array will have changed.    // If index == -1 though, the menu is being removed, so clean up the observation    if (index == -1) {        var menuNum = button.menuNum,            oldMenu = this.menus[button.menuNum];        if (button.isObserving(oldMenu, "hide")) {            button.ignore(oldMenu, "hide");        }    }    // Update the menuNum so the members match the menus    button.menuNum = index;},//>	@method	menuBar.addMenus()// Dynamically update the menuBar to include additional menus. Will update the visible set// of buttons as appropriate// @param newMenus (array) Array of new menus to add// @param position (number) desired starting position of the new menus in the existing menus //  array// @visibility external//<addMenus : function (newMenus, position) {    if (!newMenus) return;    if (!isc.isAn.Array(newMenus)) newMenus = [newMenus];    if (!this.menus) this.menus = [];    if (position == null) position = this.menus.length;    // If we have not yet initialized the buttons, we simply need to add the menus    // the new buttons will be init'd along with the ones for pre-existant menus    if (!this._buttonsInitialized) {        this.menus.addListAt(newMenus, position);    } else {                // Every button AFTER the new buttons' position will need to be remapped        for (var i = position; i < this.members.length; i++) {            this._remapButton(this.members[i], (i + newMenus.length));        }                this.menus.addListAt(newMenus, position);                var newButtons = [];        for (var i = 0; i < newMenus.length; i++) {            var index = this.menus.indexOf(newMenus[i]);            newButtons[i] = this._getButtonProperties(newMenus[i], index);        }        this.addButtons(newButtons, position);    }},//>	@method	menuBar.removeMenus()// Dynamically remove menus from the menuBar. Will update the visible set of buttons as // appropriate.// @param menus (array) Array of menus to remove (will accept actual Menu components, //                      or numbers representing the index of the menus in the current menus array)// @visibility external//<removeMenus : function (menus) {    if (menus == null) return;    if (!isc.isAn.Array(menus)) menus = [menus];        var membersToRemove = [],        // make a new Array so existing Menu indices are stable while we form the new array        newMenusArray = this.menus.duplicate();            for (var i = 0; i < menus.length; i++) {        var menu = menus[i];        if (isc.isA.Number(menu)) menu = this.menus[menu];

⌨️ 快捷键说明

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