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

📄 sectionstack.js

📁 javascript 很酷的类库
💻 JS
📖 第 1 页 / 共 4 页
字号:
            // whatever member actually gets chosen as the resize target.            // NOTE: if we pass a section header, don't resize if the preceding member is            // another section header, detected via the isSectionHeader flag rather than            // isc.isA.SectionHeader since section header implementation is pluggable            if (member.isSectionHeader || (!member.resizeable && member.isVisible()))                this._resizeIgnore += member.getVisibleHeight();        }        // if there are no preceeding resizeable members, never allow resize (eg, no         // resize is possible if you are grabbing the first section header, or a section header        // after a series of collapsed or fixed-size sections)        if (!resizeTarget) return null;                // Read as:         // - if canResizeStack is true (default), always allow resize if there is a preceeding,        //   resizeable member, even though this *may* change the overall stack size if there        //   isn't also a resizeable member after this section header        // - if canResizeStack is false, only allow a resize if there is *also* a member        //   after us that can resize, because only then will all available space still be        //   filled.        if (this.canResizeStack) return resizeTarget;        // look for a member after us that can resize        var numMembers = this.getMembers().length;        for (var i = myIndex+1; i < numMembers; i++) {            var member = this.getMember(i);            // some member after the sectionHeader is resizeable, so go ahead and return the            // resizeTarget we previously determined            if (this.memberIsDragResizeable(member)) return resizeTarget;        }                return null;    },            memberIsDragResizeable : function (member) {        if (!member.isSectionHeader             && member.resizeable !== false             && member.isVisible()            && (!this.memberHasInherentLength(member) || member.resizeable)            ) return true;    },    memberHasAutoResizeableHeight : function (member) {        var uh = member._userHeight;        return uh == null || (isc.isA.String(uh) && (uh == "*" || isc.endsWith(uh, "%")));    },    getMemberDefaultBreadth : function (member, defaultBreadth) {        var breadth = defaultBreadth;        if (!member.isSectionHeader) {            if (this.itemStartIndent != null || this.itemEndIndent != null)                breadth -= this.itemStartIndent + this.itemEndIndent;            else breadth -= this.itemIndent;        }        return breadth;    },        getMemberOffset : function (member, defaultOffset, alignment) {        var offset = this.itemIndent;        if (member.isSectionHeader) return defaultOffset;        if (this.itemStartIndent != null) offset = this.itemStartIndent;        if (alignment == isc.Canvas.RIGHT || alignment == isc.Canvas.BOTTOM)            offset *= -1;        return defaultOffset + offset;    }});// SectionHeader classes// ---------------------------------------------------------------------------------------isc._commonMediaProps = {    icon:"[SKIN]SectionHeader/opener.gif",    overflow:"hidden",    baseStyle:"sectionHeader",     // Show the disabled style in both image based headers and label-based headers    showDisabled:true,    // expanded/collapsed styling    // ---------------------------------------------------------------------------------------    expanded: false,    setExpanded : function (expanded) {        this.expanded = expanded;        this.stateChanged();    },    //>!BackCompat 2005.12.22    setOpen : function (isOpen) {         this.setExpanded(isOpen);    },    //<!BackCompat    getCustomState : function () { return this.expanded ? "opened" : "closed"; }};isc._commonHeaderProps = {    overflow:"hidden",    wrap:false, // actually only needed for the Label-based "SectionHeader" class    height:20,    expanded: false,    canCollapse: true,    // Collapse behavior    // ---------------------------------------------------------------------------------------    getLayout : function () {        var layout = this.layout;        return isc.isA.String(layout) ? window[layout] : layout;    },    // Snap open/closed on  "space" / "enter" keypress    // Allow resizing via ctrl+arrow keys    keyPress : function () {        var keyName = isc.EH.getKey();        if (keyName == "Enter" || keyName == "Space") {            if (this.canCollapse) this.getLayout().sectionHeaderClick(this);        } else if (keyName == "Arrow_Up" || keyName == "Arrow_Down") {            var target = this.getLayout().getDragResizeTarget(this);            // NOTE: don't resize if the preceding member is another section header, detected            // via marker rather than class since section header is pluggable            if (target == null) return false;            var resizeStep = (keyName == "Arrow_Up" ? -5 : 5);            this.bringToFront(); // so we aren't occluded by what we will resize            this.resizeTarget(target, true, this.resizeInRealTime, 0, 0,                                (this.getPageTop() + resizeStep))            // set a flag so we know to kill the when the user releases the ctrl key            this._keyResizeTarget = target;        }	},        keyUp : function () {        if (this._keyResizeTarget) {            var keyName = isc.EH.getKey();            if (keyName == "Arrow_Up" || keyName == "Arrow_Down") {                this.finishTargetResize(this._keyResizeTarget, true, this.resizeInRealTime);                this._keyResizeTarget = null;            }        }    },        _canFocus : function () {        return this.getLayout().canTabToHeaders == true;    },    // Editing    // ---------------------------------------------------------------------------------------    //>EditMode    schemaName : "SectionStackSection", // schema to use when editing and serializing    addItem : function (item, index) {         this.getLayout().addItem(this, item, index);        // Visual Builder expects addItem to also expand this section        this.getLayout().expandSection(this);    },    removeItem : function (item) {        this.getLayout().removeItem(this, item);    },    //<EditMode    // Resize interaction    // ---------------------------------------------------------------------------------------    canDrag:true,    dragAppearance:"none",    isSectionHeader:true,    dragStart : function () {        var target = this.getLayout().getDragResizeTarget(this);        this._sectionDragTarget = target;        if (target == null) return false;        this.bringToFront(); // so we aren't occluded by what we will drag resize    },	dragMove : function () {        // resizeIgnore is calculated in getDragResizeTarget(), called from dragStart();        var resizeIgnore = this.getLayout()._resizeIgnore;        var offset = 0 - isc.EH.dragOffsetY;        this.resizeTarget(this._sectionDragTarget, true, this.resizeInRealTime, offset, resizeIgnore);	},	dragStop : function () {        this.finishTargetResize(this._sectionDragTarget, true, this.resizeInRealTime);	},        // When a section gets destroyed, ensure all items (including those that have never been    // added as a member to the layout) also get cleared out.    destroy : function () {        if (!this.expanded && this.items) {            var items = this.items;            for (var i = 0; i< items.length; i++) {                if (isc.isA.Canvas(items[i]) && items[i].parentElement != this.parentElement) {                    items[i].destroy();                }            }        }        return this.Super("destroy", arguments);    }};//> @class SectionHeader// Simple SectionHeader class based on a Label with an icon, skinnable via CSS.//// @treeLocation Client Reference/Layout/SectionStack// @visibility external//<isc.defineClass("SectionHeader", "Label").addMethods(isc._commonHeaderProps,                                                      isc._commonMediaProps, {        // We use this.title, not this.contents for the section header title    useContents:false,        //> @attr sectionHeader.icon   (SCImgURL : "[SKIN]SectionHeader/opener.gif" : [IRA])    // Base filename of the icon that represents open and closed states. The default settings    // also change the icon for disabled sections, so a total of four images are required    // (opened, closed, Disabled_opened, Disabled_closed).    //    // @visibility external    //<    //> @attr sectionHeader.baseStyle    (CSSStyleName : "sectionHeader" : [IRA])    // CSS class for the section header.    // @visibility external    //<    // call our layout on click    click : function () {        if (this.canCollapse) this.getLayout().sectionHeaderClick(this);    },    draw : function (a,b,c,d) {            if (isc._traceMarkers) arguments.__this = this;        if (!this.readyToDraw()) return;                    this.align = this.isRTL() ? "right" : "left";        this.invokeSuper(isc.ImgSectionHeader, "draw", a,b,c,d);        // allow extra controls to be floated over the header in an HLayout        if (this.headerControls != null) {            this.headerLayout = isc.HLayout.create({                autoDraw:false, width:this.getInnerWidth(), height:this.getInnerHeight(),                members:this.headerControls            });            // Has to be a child, not a peer, so it will bubble clicks etc through if appropriate            this.addChild(this.headerLayout);            this.allowContentAndChildren = true;        }    }});//> @class ImgSectionHeader// SectionHeader class based on an HLayout with +link{StretchImg} background.// @treeLocation Client Reference/Layout/SectionStack// @visibility external//<isc.defineClass("ImgSectionHeader", "HLayout").addMethods({    //> @attr ImgSectionHeader.background (AutoChild : null : R)    // Background of the section header, based on a StretchImg.    // @visibility external    //<    backgroundDefaults : isc.addProperties({        titleStyle:"sectionHeaderTitle",                // These images now live in SectionHeader/ in the provided skins, but SectionStack/        // is left as the default for backcompat with customer skins.        src:"[SKIN]SectionStack/header.gif",                backgroundColor:"#a0a0a0",        // call our layout on click.  Note this function is placed on the background element so        // that clicks on headerControls floating above the background do not trigger        // expand/collapse        click : function () {            if (this.parentElement.canCollapse) {                this.parentElement.getLayout().sectionHeaderClick(this.parentElement);            }        },        width:"100%", height:"100%", addAsChild:true    }, isc._commonMediaProps),    setExpanded : function (expanded) {        this.expanded = expanded;        if (this.background) this.background.setExpanded(expanded);    },    //>!BackCompat 2005.12.22    setOpen : function (isOpen) {        this.setExpanded(isOpen);    },    //<!BackCompat    setTitle : function (title) {        this.title = title;        if (this.background) this.background.setTitle(title);    },    draw : function (a,b,c,d) {            if (isc._traceMarkers) arguments.__this = this;        if (!this.readyToDraw()) return;        var props = {            title : this.title,            expanded: this.expanded,            // handle focus on the header itself rather than this button.            canFocus:false        };        if (this.icon) props.icon = this.icon;        if (!this.canCollapse) {            props.icon = isc.Page.getImgURL("[SKIN]/blank.gif");            props.showIconState = false;        }        props.align = this.isRTL() ? "right" : "left";        this.addAutoChild("background", props, isc.StretchImgButton);        // allow extra controls to be floated over the background, as layout members.        this.addAutoChildren(this.headerControls);        this.background.sendToBack();        this.invokeSuper(isc.ImgSectionHeader, "draw", a,b,c,d);    }});isc.ImgSectionHeader.addMethods(isc._commonHeaderProps);

⌨️ 快捷键说明

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