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

📄 statefulcanvas.js

📁 javascript 很酷的类库
💻 JS
📖 第 1 页 / 共 4 页
字号:
    if (this.overflow != isc.Canvas.VISIBLE || !isc.isA.Canvas(this.label))         return this.invokeSuper(isc.StatefulCanvas, "getScrollHeight", calcNewValue,B,C,D);    if (this._deferredOverflow) {        this._deferredOverflow = null;        this.adjustOverflow("heightCheckWhileDeferred");    }    if (!calcNewValue && this._scrollHeight != null) return this._scrollHeight;    // _getAutoInnerWidth() will give us back the greater of our specified size / the    // label's visible size + our end caps.    // This is basically our "scroll size" if overflow is visible    var scrollHeight = this._getAutoInnerHeight()    return (this._scrollHeight = scrollHeight);},// Update the label's overflow when our overflow gets updated.setOverflow : function (newOverflow, a, b, c, d) {    // If we're autoFit:true, and overflow is getting set to hidden revert the autoFit property    // to false    if (this.autoFit && this._autoFitInitialized && !this._settingAutoFit &&        newOverflow != isc.Canvas.VISIBLE) {                this._explicitOverflow = newOverflow;        this.setAutoFit(false);        return;    }        this.invokeSuper(isc.StatefulCanvas, "setOverflow", newOverflow, a, b, c, d);    if (isc.isA.Canvas(this.label)) this.label.setOverflow(newOverflow, a, b, c, d);    },// if the SIB is resized, resize the label// This covers both:// - the SIB is resized by application code and the label must grow/shrink// - the SIB resizes itself as a result of the label changing size, in which case the call to//   resize the label should no-op, since the sizes already agreeresized : function (deltaX, deltaY, a,b,c) {    this.invokeSuper(isc.StatefulCanvas, this._$resized, deltaX,deltaY,a,b,c);    //if (!this.label || this.overflow != isc.Canvas.VISIBLE) return;    if (this.label) this.label.resizeTo(this._getLabelSpecifiedWidth(),                                         this._getLabelSpecifiedHeight());},draw : function (a,b,c) {    if (isc._traceMarkers) arguments.__this = this;        var returnVal = isc.Canvas._instancePrototype.draw.call(this, a,b,c);        //var returnVal = this.Super("draw", arguments);        if (this.position != isc.Canvas.ABSOLUTE && isc.isA.Canvas(this.label)) {                if (isc.Page.isLoaded()) this._positionLabel();        else isc.Page.setEvent("load", this.getID() + "._positionLabel()");    }    return returnVal;        },_positionLabel : function () {    if (!this.isDrawn()) return;    this.label.moveTo(this._getLabelLeft(), this._getLabelTop());},// setAlign() / setVAlign() to set content alignment// JSDoc'd in subclassessetAlign : function (align) {    this.align = align;    if (this.isDrawn()) this.markForRedraw();},setVAlign : function (valign) {    this.valign = valign;    if (this.isDrawn()) this.markForRedraw();},// Title handling// ---------------------------------------------------------------------------------------//> @method statefulCanvas.shouldHiliteAccessKey()// Should the accessKey be underlined if present in the title for this button.// Default implementation returns +link{StatefulCanvas.hiliteAccessKey}//<shouldHiliteAccessKey : function () {    return this.hiliteAccessKey;},// If this widget has an accessKey, it will underline the first occurance of the accessKey// in the title (preferring Uppercase to Lowercase)getTitleHTML : function () {    var title = this.getTitle();    if (!this.shouldHiliteAccessKey() || !isc.isA.String(title) || this.accessKey == null)         return title;        return isc.Canvas.hiliteCharacter(title, this.accessKey);    },//>	@method	statefulCanvas.getTitle()	(A)// Return the title - text/HTML drawn inside the component.// <p>// Default is to simply return this.title.// @return	(string)	HTML for the title// @visibility external//<getTitle : function () {    return this.title;},//>	@method	statefulCanvas.setTitle()// Set the title.// @group	appearance// @param	newTitle	(string)	new title// @visibility external//<setTitle : function (newTitle) {	// remember the contents	this.title = newTitle;    if (this.label) {	    this.label.setContents(newTitle);    	this.label.setState(this.getState());	    this.label.setSelected(this.isSelected());    // if we didn't have a label before, lazily create it.    } else if (this.title != null && this.shouldShowLabel()) {        this.makeLabel()    }},// other Label management// ---------------------------------------------------------------------------------------// override setZIndex to ensure that this.label is always visible.setZIndex : function (index,b,c) {        isc.Canvas._instancePrototype.setZIndex.call(this, index,b,c);        //this.Super("setZIndex", arguments);    if (isc.isA.Canvas(this.label)) this.label.moveAbove(this);},// Override _updateCanFocus() update the focusability of the label too_updateCanFocus : function () {    this.Super("_updateCanFocus", arguments);    if (this.label != null) this.label._updateCanFocus();},//> @method statefulCanvas.setIcon()// Change the icon being shown next to the title text.// @param icon (URL) URL of new icon// @group buttonIcon// @visibility external//<// NOTE: subclasses that show a Label use the label to show an icon.  Other subclasses (like// Button) must override setIcon()setIcon : function (icon) {     this.icon = icon;    if (this.label) this.label.setIcon(icon);     // lazily create a label if necessary    else if (icon && this.shouldShowLabel()) this.makeLabel();},// Mouse Event Handlers// --------------------------------------------------------------------------------------------// various mouse events will set the state of this object.//>	@method	statefulCanvas.mouseOver()	(A)//			mouseMove event handler -- hilite the current button if showRollOver is true//			may redraw the button//		@group	events//<mouseOver : function () {	if (this.showDown && this.ns.EH.mouseIsDown()) {        // XXX we should only show down if the mouse went down on us originally		this.setState(isc.StatefulCanvas.STATE_DOWN);    } else {        if (this.showRollOver) {            this.setState(isc.StatefulCanvas.STATE_OVER);        }        if (this.showOverCanvas) {            if (!this.overCanvas) {                this.addAutoChild("overCanvas", {                    autoDraw:false                })            }             if (!this.overCanvas.isDrawn()) this.overCanvas.draw();        }	}},//>	@method	statefulCanvas.mouseOut()	(A)//			mouseOut event handler -- clear the button hilite, if appropriate//			may redraw the button//		@group	events//<mouseOut : function () {	if (this.showRollOver) {		this.setState(isc.StatefulCanvas.STATE_UP);	} else if (this.showDown && this.ns.EH.mouseIsDown()) {        // FIXME we should only pop up if the mouse went down on us originally		this.setState(isc.StatefulCanvas.STATE_UP);	}        if (this.showOverCanvas && this.overCanvas && this.overCanvas.isVisible() &&         (isc.EH.getTarget() != this.overCanvas))    {        this.overCanvas.clear();    }},// override the internal _focusChanged() method to set the state of the canvas to "over" on// focus.  (Note - overriding this rather than the public 'focusChanged()' method so developers// can still put functionality into that method without worrying about calling 'super')._focusChanged : function (hasFocus,b,c,d) {    var returnVal = this.invokeSuper(isc.StatefulCanvas, "_focusChanged", hasFocus,b,c,d);    // don't show the over state if we don't actually have focus anymore (because onFocus    // is delayed in IE and focus may be elsewhere by the time it fires)     if (!(hasFocus && isc.Browser.isIE &&          (this.getFocusHandle() != this.getDocument().activeElement)) )     {        this.updateStateForFocus(hasFocus);    }        return returnVal;},updateStateForFocus : function (hasFocus) {        if (!this.showFocused) return;        if (this.showFocusedAsOver) {             // NOTE: don't show the over state if showRollOver is false, because this is typically set        // because there is no over state media (eg for an ImgButton)        if (!this.showRollOver) return;            var state = this.getState();        if (hasFocus) {            // on focus, if our state is currently 'up' set state to 'over' to indicate            // we have focus            if (state == isc.StatefulCanvas.STATE_UP) this.setState(isc.StatefulCanvas.STATE_OVER);        } else {            // on blur - clear out the 'over' state (if appropriate)            if (state == isc.StatefulCanvas.STATE_OVER) this.setState(isc.StatefulCanvas.STATE_UP);        }    } else {        // just call stateChanged - it will check this.hasFocus        this.stateChanged();        // Note: normally label styling etc will be updated by stateChanged() - but in this case        // the other states are all unchanged so the label would not necessarily refresh to reflect        // the focused state.        if (this.label) this.label.stateChanged();    }},// getFocusedState() - returns a boolean value for whether we should show the "Focused" stategetFocusedState : function () {    if (!this.showFocused || this.showFocusedAsOver) return false;    return this.hasFocus;},//>	@method	statefulCanvas.handleMouseDown()	(A)// MouseDown event handler -- show the button as down if appropriate// calls this.mouseDown() if assigned//	may redraw the button//		@group	event//<handleMouseDown : function (event, eventInfo) {    if (event.target == this && this.useEventParts) {        if (this.firePartEvent(event, isc.EH.MOUSE_DOWN) == false) return false;    }	if (this.showDown) this.setState(isc.StatefulCanvas.STATE_DOWN);        if (this.mouseDown) return this.mouseDown(event, eventInfo);    },//>	@method	statefulCanvas.handleMouseUp()	(A)//		@group	event//			mouseUp event handler -- if showing the button as down, reset to the 'up' state//          calls this.mouseUp() if assigned//<handleMouseUp : function (event, eventInfo) {    if (event.target == this && this.useEventParts) {        if (this.firePartEvent(event, isc.EH.MOUSE_UP) == false) return false;    }	// set the state of the button to change it's appearance	if (this.showDown) {		this.setState(this.showRollOver ? isc.StatefulCanvas.STATE_OVER :                       isc.StatefulCanvas.STATE_UP);	}    if (this.mouseUp) return this.mouseUp(event, eventInfo);    },//>	@method	statefulCanvas.handleActivate() (A)//      "Activate" this widget - fired from click or Space / Enter keypress.//      Sets selection state of this widget if appropriate.//      Calls this.activate stringMethod if defined//      Otherwise calls this.click stringMethod if defined.//      @group  event//<handleActivate : function (event, eventInfo) {    var actionType = this.getActionType();	if (actionType == isc.StatefulCanvas.RADIO) {		// if a radio button, select this button		this.select();			} else if (actionType == isc.StatefulCanvas.CHECKBOX) {		// if a checkbox, toggle the selected state		this.setSelected(!this.isSelected());	}    if (this.activate) return this.activate(event, eventInfo);        if (this.action) return this.action();    if (this.click) return this.click(event, eventInfo);},//>	@method	statefulCanvas.handleClick()	(A)//			click event handler -- falls through to handleActivate.//          Note: Does not call 'this.click' directly - this is handled by handleActivate//		@group	event//<handleClick : function (event, eventInfo) {    // This is required to handle icon clicks on buttons, etc    if (event.target == this && this.useEventParts) {        if (this.firePartEvent(event, isc.EH.CLICK) == false) return false;    }    return this.handleActivate(event,eventInfo);    },//>	@method	statefulCanvas.handleKeyPress()	(A)//			keyPress event handler.//          Will call this.keyPress if defined on Space or Enter keypress, falls through //          to this.handleActivate().//		@group	event//<handleKeyPress : function (event, eventInfo) {    if (this.keyPress && (this.keyPress(event, eventInfo) == false)) return false;        if (event.keyName == "Space" || event.keyName == "Enter") {        if (this.handleActivate(event, eventInfo) == false) return false;    }        return true;    }, // ---------------------------------------------------------------------------------------// override destroy to removeFromRadioGroup - cleans up a class level pointer to this widget.destroy : function () {    this.removeFromRadioGroup();        return this.Super("destroy", arguments);}});// Add 'activate' as a stringMethod to statefulCanvii, with the same signature as 'click'isc.StatefulCanvas.registerStringMethods({    activate:isc.EH._eventHandlerArgString,  //"event, eventInfo"    //> @method statefulCanvas.action()    // This property contains the default 'action' for the Button to fire when activated.    //<    // exposed on the Button / ImgButton / StretchImgButton subclasses    action:""});

⌨️ 快捷键说明

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