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

📄 sectionstack.js

📁 javascript 很酷的类库
💻 JS
📖 第 1 页 / 共 4 页
字号:
/*
 * 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 SectionStack// A container that manages a list of sections of widgets, each with a header.  Sometimes called// an "Accordion".// <P>// SectionStack can be configured so that only one section is visible at a time (similar to MS Outlook's// left-hand Nav), or to allow multiple sections to be visible and share the available space.//// @treeLocation Client Reference/Layout// @visibility external// @example sectionsExpandCollapse//<isc.defineClass("SectionStack", "VLayout");//>!BackCompat 2005.6.15 old name: "ListBar"isc.addGlobal("ListBar", isc.SectionStack);//<!BackCompatisc.SectionStack.addProperties({    //> @attr SectionStack.overflow (Overflow : "hidden" : [IR])    // Normal +link{type:Overflow} settings can be used on layouts, for example, an    // overflow:auto Layout will scroll if sections are resized to exceed the specified size,    // whereas an overflow:visible Layout will grow to accomodate the resized sections.    // @visibility external    //<    overflow:"hidden",    // Section Header Creation	// ---------------------------------------------------------------------------------------     //> @attr SectionStack.sectionHeaderClass (Classname : "SectionHeader" : [IRA])    // Name of the Canvas subclass to use as a header that labels the section and allows    // showing and hiding.  The default class be skinned, or trivial subclasses created to    // allow different appearances for headers in different SectionStacks.    // <P>    // Very advanced developers can use the following information to create custom header    // classes.    // <P>    // The SectionStack will instantiate this class, giving the following properties on init:    // <ul>    // <li><code>layout</code>: the SectionStack    // <li><code>expanded</code>: true or false    // <li><code>hidden</code>: true or false    // <li><code>title</code>: section title    // </ul>    // From then on, when the sectionHeader is clicked on, it should call    // +link{method:SectionStack.sectionHeaderClick()}.    // <br>    // Whenever the section is hidden or shown, sectionHeader.setExpanded(true|false) will be    // called if implemented.    //    // @visibility external    //<    sectionHeaderClass:"SectionHeader",       //> @attr SectionStack.headerHeight (Number : 20 : [IR])    // Height of headers for sections.    // @visibility external    //<    headerHeight:20,        // All Sections	// ---------------------------------------------------------------------------------------        //> @attr SectionStack.sections (Array of SectionStackSection Properties : null : [IR])    // List of sections of components managed by this SectionStack.    //    // @see sectionStack.getSections()    // @visibility external    // @example sectionsExpandCollapse    //<     //> @attr SectionStack.canResizeSections (boolean : true : [IRA])    // Whether sections can be drag resized by the user dragging the section header.    // <P>    // Note that, with <code>canResizeSections:true</code>, not all sections can be resized:    // sections that contain only +link{Button.autoFit,autofitting} components or that are    // marked with +link{SectionStackSection.resizeable,section.resizeable:false} will not be    // resizeable.    //    // @visibility external    //<    canResizeSections:true,        // whether to allow the user to change the overall size of the SectionStack by resizing    // sections        canResizeStack:true,       //> @attr SectionStack.canTabToHeaders (boolean : false : [IRA])    // If true, the headers for the sections (if shown) will be included in the page's tab    // order for accessibility.    // @visibility external    //<    //> @attr SectionStack.scrollSectionIntoView (boolean : true : [IR])    // If an expanded or shown section expands past the current viewport and this property is    // true, then the viewport will auto-scroll to fit as much of the section content into the    // viewport without scrolling the top of the section out of the viewport.    //    // @visibility external    //<    scrollSectionIntoView: true,    // NOTE: vertical:false (horizontal stacks) does work, however the default SectionHeader    // class has a height of 20 which needs to be wiped to allow vertical stretching.  And, you    // have to have a strategy for vertical text labels.    //     isc.defineClass("MyHeader", "SectionHeader").addProperties({height:null});    //     isc.SectionStack.create({    //         vertical:false,    //         sectionHeaderClass:"MyHeader",    //vertical:true,    // Section Header Properties    // ---------------------------------------------------------------------------------------    //> @object SectionStackSection    // Section descriptor used by a SectionStack to describe a section of items which are shown    // or hidden together, and their associated header.     //    // @treeLocation Client Reference/Layout/SectionStack    // @visibility external    //<    //> @attr SectionStackSection.ID (String : null : [IR])    // Optional ID for the section.  This can be used later in calls to +link{SectionStack} APIs such as    // +link{sectionStack.expandSection} and +link{sectionStack.collapseSection}.    // @visibility external    //<    //> @attr SectionStackSection.title (String : null : [IR])    // Title to show for the section    // @visibility external    //<    //> @attr SectionStackSection.items (Array of Canvas : null : [I])    // List of Canvases that constitute the section.  These Canvases will be shown and hidden    // together.    // @visibility external    //<    //> @attr SectionStackSection.showHeader (boolean : true : [I])    // If true, a header will be shown for this section.  If false, no header will be shown.    // @visibility external    //<    //> @attr SectionStackSection.resizeable (boolean : null : [I])    // If set to false, then the items in this section will not be resized by sectionHeader    // repositioning.  You may also set this flag directly on any of the items in any section to    // cause that item to not be resizeable.    // @visibility external    // @example resizeSections    //<    //> @attr SectionStackSection.expanded (boolean : false : [I])    // Sections default to the collapsed state unless +link{SectionStackSection.showHeader} is    // set to <code>false</code> in which case they default to the expanded state.  This    // attribute allows you to explicitly control the expand/collapse state of the    // section by overriding the above default behavior.      // @visibility external    //<    //> @attr SectionStackSection.hidden (boolean : false : [I])    // Sections default to the visible state.  This    // attribute allows you to explicitly control the visible/hidden state of the    // section by overriding the above default behavior.      // @visibility external    //<    //> @attr SectionStackSection.canCollapse (boolean : true : [I])    // This attribute controls whether or not the expand/collapse UI control is shown on the    // header of this section.  Any section can still be expanded/collapsed programmatically,    // regardless of this setting.    // @visibility external    // @example sectionsExpandCollapse    //<        //>Animation    // ---------------------------------------------------------------------------------------    //> @attr sectionStack.animateSections (boolean : null : IRW)    // If true, sections are animated during expand/collapse and addition/removal of    // SectionItems is likewise animated.    // @group animation    // @visibility animation    // @example animateSections    //<    // change layout default effect for showing/hiding members; "slide" is appropriate for    // eg Window minimize, but "wipe" is usually the best effect for SectionStacks     animateMemberEffect:"wipe",    //<Animation    // Visibility of Sections	// ---------------------------------------------------------------------------------------    //> @type VisibilityMode    // Settings for whether multiple sections can be in the expanded state simultaneously.    //    // @value "mutex"    // Only one section can be expanded at a time.    //    // @value "multiple"    // Multiple sections can be expanded at the same time, and will share space.    //    // @visibility external    //<    //> @attr SectionStack.visibilityMode (VisibilityMode : "mutex" : [IRW])    // Whether multiple sections can be visible at once    //    // @see type:VisibilityMode    // @visibility external    // @example sectionsExpandCollapse    //<    visibilityMode:"mutex",    // internal flag: if true, section stack will null out _userHeight on an eligible item when    // hiding/collapsing sections to maintain the overall height of the SectionStack.  If    // false, the SectionStack will grow/shrink instead.  This needs to be rolled up to Layout    // as a policy instead.    forceFill: true,        //> @attr itemIndent (Number : 0 : [IRW])    // Size, in pixels, of indentation of all member items. Items will be offset    // and reduced in width by this amount. Overridden by    // +link{itemStartIndent} or +link{itemEndIndent}.    // Setting itemIndent is equivalent to setting itemStartIndent to the same amount    // and itemEndIndent to 0.    // @visibility external    // @group layoutMember    //<    itemIndent: 0        //> @attr itemStartIndent (Number : undefined : [IRW])    // Size, in pixels, of indentation of all member items relative to the start of    // the alignment axis. For instance, for left-aligned members,     // itemStartIndent specifies indentation for every item from the left side of the    // section stack. Overrides +link{itemIndent}.    // @visibility external    // @group layoutMember    //<    //> @attr itemEndIndent (Number : undefined : [IRW])    // Size, in pixels, of indentation of all member items relative to the end of    // the alignment axis. For instance, for left-aligned members,     // itemStartIndent specifies indentation for every item from the right side of the    // section stack.    // @visibility external    // @group layoutMember    //<});                        isc.SectionStack.addMethods({    initWidget : function () {        this.Super(this._$initWidget);         //>Animation        if (this.animateSections != null) this.animateMembers = this.animateSections        //<Animation        //>!BackCompat 2005.6.15 old name: "ListBar" with "groups"        if (this.groups != null && this.sections == null) this.sections = this.groups;        //<!BackCompat        var initSections = this.sections;        this.sections = [];        this.addSections(initSections, null, true);        },        //> @method sectionStack.addItem    // Add a canvas as an item to a section.    // @param section (String or Number) ID or index of the section to add item to    // @param item (Canvas) Item to insert into the section    // @param index (Number) Index into section to insert item    // @visibility external    //<    addItem : function (section, item, index) {        var sectionHeader = this.getSection(section);        sectionHeader.items.addAt(item, index);    },        //> @method sectionStack.removeItem    // Remove an item from a section.    // @param section (String or Number) ID or index of the section to remove item from    // @param item (Canvas) Item to remove    // @visibility external    //<    removeItem : function (section, item) {        var sectionHeader = this.getSection(section);        sectionHeader.items.remove(item);        this.removeMember(item);    }    addSections : function (sections, position, expandOne) {        if (sections == null) return;        if (!isc.isAn.Array(sections)) sections = [sections];        if (position == null || position > this.sections.length) {            position = this.sections.length;        }        for (var i = 0; i < sections.length; i++) {            var section = sections[i];            // support sparse arrays            if (!section) continue;            if (section.showHeader == null) section.showHeader = true;            if (section.canHide == null) section.canHide = true;            // use section.expanded if explicitly set.  Otherwise default to collapsed            // unless showHeader is false or autoShow is true (backcompat).            var expanded = section.expanded != null ? section.expanded :                    // previous logic was

⌨️ 快捷键说明

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