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

📄 menu.js

📁 javascript 很酷的类库
💻 JS
📖 第 1 页 / 共 5 页
字号:
        var item = this.getItem(this.getFocusRow());        if (this.hasSubmenu(item)) {            this.changeSubmenu();            // Note: Windows handling of submenus seems to be that if you open one via keyboard            // the first item is hilighted by default, otherwise no item is hilighted.            // therefore hilight first item here, but not in changeSubmenu()            this._open_submenu._navigateToNextRecord(1);            return false;   // stop propogation        }            // hide the menu if escape is hit  	    } else if (keyName == "Escape") {		if (this._parentMenu != null) {			this._parentMenu.hideSubmenu();			this._parentMenu.focus();		} else {	        isc.Menu.hideAllMenus();		}        return false;        // override keypress on "Enter" to do a single record click rather than a double    // (which has no meaning for menus)        } else if (keyName == "Enter") {        return this._generateFocusRecordClick();		// hilite the first item?    }        return this.Super("bodyKeyPress", arguments);},// Override _navigateToNextRecord() to close the menu when the user attempts to select record// '-1'. (IE: They have pressed the Arrow Up key while the first item in the menu is hilighted)_navigateToNextRecord : function (step) {    var newSelectionIndex = this.getFocusRow();    // default to starting at zero    if (newSelectionIndex == null) newSelectionIndex = 0;    // If we're attempting to navigate to the previous item in the menu, check whether we'll    // iterate up off the top of the menu.        if (step == -1) {        do {            newSelectionIndex += step;                        // hide the list if you go off the top             // (will focus back in whatever previously had focus)                        if (newSelectionIndex < 0) {                this.hide();                return false;   // cancel event propogation            }                    } while (!this.itemIsEnabled(newSelectionIndex))    }        return this.Super("_navigateToNextRecord", arguments);},// Showing and hiding// --------------------------------------------------------------------------------------------//>	@method	menu.show()// Show the menu, hiding other visible menus as appropriate.// <p>// Sets up to dismiss on any click outside the menu.//		@group	visibility//<//>Animation// @param animationEffect (string) Allows the user to specify an animation effect for showing// the menu - valid options are <code>"fade"</code>, <code>"slide"</code> and <code>"wipe"</code>// If no value is passed for this parameter, checks <code>this.showAnimationEffect</code>//<Animationshow : function (animationEffect) {        // If the menu is currently offscreen, shift it back to last onscreen position before    // showing.    if (this._isOffscreen) {        this.moveTo(this._onscreenPosition[0], this._onscreenPosition[1]);        this._isOffscreen = null;    }    //>Animation    // Note: if an animation effect was passed in we call this.animateShow(), which will    // call this method again - that's why we need the _animating parameter    if (animationEffect == null) animationEffect = this.showAnimationEffect;    var shouldAnimate = !this._animating && (animationEffect != null) &&                                             (animationEffect != "none");    if (shouldAnimate) {        this._animating = true;         this.animateShow(animationEffect, "this._showComplete()")        return;    }     //<Animation        // reset the enabled and title of menu items if necessary    if (this.setDynamicItems) this.setDynamicItems()    // if the menu hasn't been drawn, draw it now    if (!this.isDrawn()) {        // Pass in the 'showing' parameter to avoid draw() calling show again.        this.draw(true);    }        // ensure that when we get hidden, we focus back into whatever previously had focus    this.body.focusOnHide = isc.EH.getFocusCanvas();            // if this is the first menu being opened, show the click mask    if (isc.Menu._openMenus.length == 0) {        isc.Menu._menusClickMask = isc.EH.showClickMask("isc.Menu.hideAllMenus()", true);    }        // bring this menu above everything else    this.bringToFront();        // now add this menu to the list of _openMenus so it can be hidden automatically    isc.Menu._openMenus.add(this);	this.Super("show", arguments);        if (!this._animating) this._showComplete();},_showComplete : function () {    if (this._animating) delete this._animating;        if (isc.Browser.isMoz) {        this.getClipHandle().offsetLeft;    }    // grab focus for keyboard handling    this.body.focus();},//>	@method	menu.hide()//			hide this menu.//          Overridden to clear all selections and clear open submenu pointers//		@group	visibility////<hide : function () {    // no-op if no change in visibility    if (this.visibility == isc.Canvas.HIDDEN) return;    	this.Super("hide", arguments);        // We occasionally get menus that are as taller than the page (introducing v-scrollbars).    // In this case we don't want the height of the hidden menu to continue to effect the     // page scroll height, so shift offscreen when hiding.    this._moveOffscreen();        // clear hilite, as menus should always start with no hilite	this.clearLastHilite();        this._lastRecordClicked = null;     if (this._openItem) delete this._openItem;    if (this.submenuTimer) isc.Timer.clearTimeout(this.submenuTimer);        },// Context menu handling// --------------------------------------------------------------------------------------------//>	@method	menu.showContextMenu()// Show this menu as a context menu, that is, immediately adjacent to the current mouse position.//// @visibility external////		@group	visibility//		@return	(boolean)	false == stop processing this event//<showContextMenu : function (event) {        if (event && (event.target == this || (this.body && event.target == this.body))) {        if (this.body) {                            if (isc.Browser.isSafari) {                this.body._mouseDownRow = this.getEventRow();                 this.body._mouseDownCol = this.getEventColumn();            }                 this.body.click();        }        return false;    }        var target;    // if we were explicitly passed a target canvas, use it    if (isc.isA.Canvas(event)) target = event;    // otherwise, if passed an event, use the target of the event    if (event != null && event.target != null) target = event.target;        if (target != null) this.target = target;    this.positionContextMenu();    this.show();	return false;},getMaxHeight : function () {    if (this.maxHeight != null) return this.maxHeight;    return isc.Page.getHeight() - this.getScrollbarSize();},_showOffscreen : function () {    if(!this.isDrawn()) {        // draw, but avoid the call to 'show()' since we don't want to focus on this widget        this.setVisibility(isc.Canvas.HIDDEN);        this.draw();    }        this.setVisibility(isc.Canvas.VISIBLE);    this._moveOffscreen();        if (this.isDirty() || this.body.isDirty()) this.redraw();        if (this._overflowQueued) this.adjustOverflow();        // If we're enforcing max height, handle this now - introducing scrollbars if necessary    // (Can skip if we've already calculated the height and the content / sizing of the    // menu has not changed).    if (!this._heightCalculated && this.enforceMaxHeight) {        // If we're currently showing scrollbars, reset to overflow visible and default sizing        // to ensure that they're necessary                if (this.overflow != isc.Canvas.VISIBLE) {            this.leaveScrollbarGap = false;            this.setOverflow(isc.Canvas.VISIBLE);            this.setHeight(this.defaultHeight);            this.setWidth(this._origWidth || this.defaultWidth);            this.adjustOverflow();        }        var height = this.getVisibleHeight(),            width = this.getVisibleWidth(),            maxHeight = this.getMaxHeight();        if (this.overflow == isc.Canvas.VISIBLE && height > maxHeight) {            this.leaveScrollbarGap = true;            this.setHeight(maxHeight);            this._origWidth = this.getWidth();  // remember the user-specified width so we can                                                // set back to it if we have fewer items            this.setWidth(this.getVisibleWidth() + this.getScrollbarSize())            this.setOverflow(isc.Canvas.AUTO);            this.adjustOverflow();        }        this._heightCalculated = true;    }        this.setVisibility(isc.Canvas.HIDDEN);},// If our set of items changes (due to a setData() call, or a change to our data object)// we will have to determine whether we exceed this.maxHeight (and thus need scrollbars)// or not.// For tree data, each generated submenu observes the main tree, so this // method will fire for every submenu when the tree data changes, (causing a redraw of every// visible menu to show the new data).dataChanged : function (a,b,c,d) {    // for tree submenus, if our parent node has been removed, self-destruct.    // Note: We re-use tree submenus for each folder at any level of a tree.    // This means that if our parent node has been removed from the tree, this menu is not    // necessarily obsolete - it could be re-used for other folder nodes in the parent folder.    // Rather than destroy() ing the submenu here, we could just hide it, but this would mean    // in the case where there are no other folder nodes in the parent folder we'd end up with    // orphaned menus that would never get destroyed.    if (this._treeData && this._lastNode != null) {         if (!this._treeContains(this._lastNode)) {            // Note this will also fire for any submenus of this menu            this.destroy();            return;        }    }    var rv = this.invokeSuper(isc.Menu, "dataChanged", a,b,c,d);    delete this._heightCalculated;    return rv;},_treeContains : function (node) {    while (node) {        if (this._treeData.isRoot(node)) return true;        node = this._treeData.getParent(node);    }    return false;},//> @method Menu.setData()// Change the set of items to display in this menu// @param items (array of MenuItems) new items for this menu// @group data// @visibility external//<setData : function (a,b,c,d) {    var rv = this.invokeSuper(isc.Menu, "setData", a,b,c,d);    delete this._heightCalculated;    return rv;},//> @method Menu.setItems()// Synonym for +link{Menu.setData()}.// @param items (array of MenuItems) new items for this menu// @group data// @visibility external//<setItems : function (a,b,c,d) {    return this.setData(a,b,c,d);},//>EditMode add a method to retrieve menu items by a "name" property, discoverable// by type.getMenuItem : function (name) {    return isc.Class.getArrayItem(name, this.data, "name");},//<EditMode// hang a flag on this item when we move it offscreen so we can tell if we need to reposition// on show._moveOffscreen : function () {    if (this.parentElement != null) return;    // No op if we're already offscreen    if (this._isOffscreen) return;        this._onscreenPosition = [this.getLeft(), this.getTop()];    this.moveTo(null, -9999);        this._isOffscreen = true;},// Override moveBy: If the menu has been moved offscreen, and is being moved again, clear// out the 'isOffscreen' flag, so we don't incorrectly reposition to original onscreen position// on show().moveBy : function () {    var returnVal = this.Super("moveBy", arguments);        if (this._isOffscreen) this._isOffscreen = false;    return returnVal;},// Override resizesBy: If we have calculated the drawn size of the menu // (potentially with scrollbars) and the developer changes the specified height or width// we're going to have to recalculate when we next show the menu.resizeBy : function (dX, dY, a,b,c,d) {    if ((dX != null && dX != 0) || (dY != null && dY != 0)) delete this._heightCalculated;    return this.invokeSuper(isc.Menu, "resizeBy", dX,dY, a,b,c,d);},//>	@method	menu.hideContextMenu()// Hide the context menu - alias for hide()// @group	visibility// @visibility external    //<hideContextMenu : function () {

⌨️ 快捷键说明

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