Panel.html 80 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>The source code</title>
  6. <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  7. <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  8. <style type="text/css">
  9. .highlight { display: block; background-color: #ddd; }
  10. </style>
  11. <script type="text/javascript">
  12. function highlight() {
  13. document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
  14. }
  15. </script>
  16. </head>
  17. <body onload="prettyPrint(); highlight();">
  18. <pre class="prettyprint lang-js"><span id='Ext-panel-Panel'>/**
  19. </span> * Panel is a container that has specific functionality and structural components that make it the perfect building
  20. * block for application-oriented user interfaces.
  21. *
  22. * Panels are, by virtue of their inheritance from {@link Ext.container.Container}, capable of being configured with a
  23. * {@link Ext.container.Container#layout layout}, and containing child Components.
  24. *
  25. * When either specifying child {@link #cfg-items} of a Panel, or dynamically {@link Ext.container.Container#method-add adding}
  26. * Components to a Panel, remember to consider how you wish the Panel to arrange those child elements, and whether those
  27. * child elements need to be sized using one of Ext's built-in `{@link Ext.container.Container#layout layout}`
  28. * schemes. By default, Panels use the {@link Ext.layout.container.Auto Auto} scheme. This simply renders child
  29. * components, appending them one after the other inside the Container, and **does not apply any sizing** at all.
  30. *
  31. * {@img Ext.panel.Panel/panel.png Panel components}
  32. *
  33. * A Panel may also contain {@link #bbar bottom} and {@link #tbar top} toolbars, along with separate {@link
  34. * Ext.panel.Header header}, {@link #fbar footer} and body sections.
  35. *
  36. * Panel also provides built-in {@link #collapsible collapsible, expandable} and {@link #closable} behavior. Panels can
  37. * be easily dropped into any {@link Ext.container.Container Container} or layout, and the layout and rendering pipeline
  38. * is {@link Ext.container.Container#method-add completely managed by the framework}.
  39. *
  40. * **Note:** By default, the `{@link #closable close}` header tool _destroys_ the Panel resulting in removal of the
  41. * Panel and the destruction of any descendant Components. This makes the Panel object, and all its descendants
  42. * **unusable**. To enable the close tool to simply _hide_ a Panel for later re-use, configure the Panel with
  43. * `{@link #closeAction closeAction}: 'hide'`.
  44. *
  45. * Usually, Panels are used as constituents within an application, in which case, they would be used as child items of
  46. * Containers, and would themselves use Ext.Components as child {@link #cfg-items}. However to illustrate simply rendering a
  47. * Panel into the document, here's how to do it:
  48. *
  49. * @example
  50. * Ext.create('Ext.panel.Panel', {
  51. * title: 'Hello',
  52. * width: 200,
  53. * html: '&lt;p&gt;World!&lt;/p&gt;',
  54. * renderTo: Ext.getBody()
  55. * });
  56. *
  57. * A more realistic scenario is a Panel created to house input fields which will not be rendered, but used as a
  58. * constituent part of a Container:
  59. *
  60. * @example
  61. * var filterPanel = Ext.create('Ext.panel.Panel', {
  62. * bodyPadding: 5, // Don't want content to crunch against the borders
  63. * width: 300,
  64. * title: 'Filters',
  65. * items: [{
  66. * xtype: 'datefield',
  67. * fieldLabel: 'Start date'
  68. * }, {
  69. * xtype: 'datefield',
  70. * fieldLabel: 'End date'
  71. * }],
  72. * renderTo: Ext.getBody()
  73. * });
  74. *
  75. * Note that the Panel above is configured to render into the document and assigned a size. In a real world scenario,
  76. * the Panel will often be added inside a Container which will use a {@link #layout} to render, size and position its
  77. * child Components.
  78. *
  79. * Panels will often use specific {@link #layout}s to provide an application with shape and structure by containing and
  80. * arranging child Components:
  81. *
  82. * @example
  83. * var resultsPanel = Ext.create('Ext.panel.Panel', {
  84. * title: 'Results',
  85. * width: 600,
  86. * height: 400,
  87. * renderTo: Ext.getBody(),
  88. * layout: {
  89. * type: 'vbox', // Arrange child items vertically
  90. * align: 'stretch', // Each takes up full width
  91. * padding: 5
  92. * },
  93. * items: [{ // Results grid specified as a config object with an xtype of 'grid'
  94. * xtype: 'grid',
  95. * columns: [{header: 'Column One'}], // One header just for show. There's no data,
  96. * store: Ext.create('Ext.data.ArrayStore', {}), // A dummy empty data store
  97. * flex: 1 // Use 1/3 of Container's height (hint to Box layout)
  98. * }, {
  99. * xtype: 'splitter' // A splitter between the two child items
  100. * }, { // Details Panel specified as a config object (no xtype defaults to 'panel').
  101. * title: 'Details',
  102. * bodyPadding: 5,
  103. * items: [{
  104. * fieldLabel: 'Data item',
  105. * xtype: 'textfield'
  106. * }], // An array of form fields
  107. * flex: 2 // Use 2/3 of Container's height (hint to Box layout)
  108. * }]
  109. * });
  110. *
  111. * The example illustrates one possible method of displaying search results. The Panel contains a grid with the
  112. * resulting data arranged in rows. Each selected row may be displayed in detail in the Panel below. The {@link
  113. * Ext.layout.container.VBox vbox} layout is used to arrange the two vertically. It is configured to stretch child items
  114. * horizontally to full width. Child items may either be configured with a numeric height, or with a `flex` value to
  115. * distribute available space proportionately.
  116. *
  117. * This Panel itself may be a child item of, for exaple, a {@link Ext.tab.Panel} which will size its child items to fit
  118. * within its content area.
  119. *
  120. * Using these techniques, as long as the **layout** is chosen and configured correctly, an application may have any
  121. * level of nested containment, all dynamically sized according to configuration, the user's preference and available
  122. * browser size.
  123. */
  124. Ext.define('Ext.panel.Panel', {
  125. extend: 'Ext.panel.AbstractPanel',
  126. requires: [
  127. 'Ext.panel.Header',
  128. 'Ext.fx.Anim',
  129. 'Ext.util.KeyMap',
  130. 'Ext.panel.DD',
  131. 'Ext.XTemplate',
  132. 'Ext.layout.component.Dock',
  133. 'Ext.util.Memento'
  134. ],
  135. alias: 'widget.panel',
  136. alternateClassName: 'Ext.Panel',
  137. <span id='Ext-panel-Panel-cfg-collapsedCls'> /**
  138. </span> * @cfg {String} collapsedCls
  139. * A CSS class to add to the panel's element after it has been collapsed.
  140. */
  141. collapsedCls: 'collapsed',
  142. <span id='Ext-panel-Panel-cfg-animCollapse'> /**
  143. </span> * @cfg {Boolean} animCollapse
  144. * `true` to animate the transition when the panel is collapsed, `false` to skip the animation (defaults to `true`
  145. * if the {@link Ext.fx.Anim} class is available, otherwise `false`). May also be specified as the animation
  146. * duration in milliseconds.
  147. */
  148. animCollapse: Ext.enableFx,
  149. <span id='Ext-panel-Panel-cfg-minButtonWidth'> /**
  150. </span> * @cfg {Number} minButtonWidth
  151. * Minimum width of all footer toolbar buttons in pixels. If set, this will be used as the default
  152. * value for the {@link Ext.button.Button#minWidth} config of each Button added to the **footer toolbar** via the
  153. * {@link #fbar} or {@link #buttons} configurations. It will be ignored for buttons that have a minWidth configured
  154. * some other way, e.g. in their own config object or via the {@link Ext.container.Container#defaults defaults} of
  155. * their parent container.
  156. */
  157. minButtonWidth: 75,
  158. <span id='Ext-panel-Panel-cfg-collapsed'> /**
  159. </span> * @cfg {Boolean} collapsed
  160. * `true` to render the panel collapsed, `false` to render it expanded.
  161. */
  162. collapsed: false,
  163. <span id='Ext-panel-Panel-cfg-collapseFirst'> /**
  164. </span> * @cfg {Boolean} collapseFirst
  165. * `true` to make sure the collapse/expand toggle button always renders first (to the left of) any other tools in
  166. * the panel's title bar, `false` to render it last.
  167. */
  168. collapseFirst: true,
  169. <span id='Ext-panel-Panel-cfg-hideCollapseTool'> /**
  170. </span> * @cfg {Boolean} hideCollapseTool
  171. * `true` to hide the expand/collapse toggle button when `{@link #collapsible} == true`, `false` to display it.
  172. */
  173. hideCollapseTool: false,
  174. <span id='Ext-panel-Panel-cfg-titleCollapse'> /**
  175. </span> * @cfg {Boolean} titleCollapse
  176. * `true` to allow expanding and collapsing the panel (when `{@link #collapsible} = true`) by clicking anywhere in
  177. * the header bar, `false`) to allow it only by clicking to tool button).
  178. */
  179. titleCollapse: false,
  180. <span id='Ext-panel-Panel-cfg-collapseMode'> /**
  181. </span> * @cfg {String} collapseMode
  182. * **Important: this config is only effective for {@link #collapsible} Panels which are direct child items of a
  183. * {@link Ext.layout.container.Border border layout}.**
  184. *
  185. * When _not_ a direct child item of a {@link Ext.layout.container.Border border layout}, then the Panel's header
  186. * remains visible, and the body is collapsed to zero dimensions. If the Panel has no header, then a new header
  187. * (orientated correctly depending on the {@link #collapseDirection}) will be inserted to show a the title and a re-
  188. * expand tool.
  189. *
  190. * When a child item of a {@link Ext.layout.container.Border border layout}, this config has three possible values:
  191. *
  192. * - `undefined` - When collapsed, a placeholder {@link Ext.panel.Header Header} is injected into the layout to
  193. * represent the Panel and to provide a UI with a Tool to allow the user to re-expand the Panel.
  194. *
  195. * - `&quot;header&quot;` - The Panel collapses to leave its header visible as when not inside a
  196. * {@link Ext.layout.container.Border border layout}.
  197. *
  198. * - `&quot;mini&quot;` - The Panel collapses without a visible header.
  199. */
  200. <span id='Ext-panel-Panel-cfg-placeholder'> /**
  201. </span> * @cfg {Ext.Component/Object} placeholder
  202. * **Important: This config is only effective for {@link #collapsible} Panels which are direct child items of a
  203. * {@link Ext.layout.container.Border border layout} when not using the `'header'` {@link #collapseMode}.**
  204. *
  205. * **Optional.** A Component (or config object for a Component) to show in place of this Panel when this Panel is
  206. * collapsed by a {@link Ext.layout.container.Border border layout}. Defaults to a generated {@link Ext.panel.Header
  207. * Header} containing a {@link Ext.panel.Tool Tool} to re-expand the Panel.
  208. */
  209. <span id='Ext-panel-Panel-cfg-floatable'> /**
  210. </span> * @cfg {Boolean} floatable
  211. * **Important: This config is only effective for {@link #collapsible} Panels which are direct child items of a
  212. * {@link Ext.layout.container.Border border layout}.**
  213. *
  214. * true to allow clicking a collapsed Panel's {@link #placeholder} to display the Panel floated above the layout,
  215. * false to force the user to fully expand a collapsed region by clicking the expand button to see it again.
  216. */
  217. floatable: true,
  218. <span id='Ext-panel-Panel-cfg-overlapHeader'> /**
  219. </span> * @cfg {Boolean} overlapHeader
  220. * True to overlap the header in a panel over the framing of the panel itself. This is needed when frame:true (and
  221. * is done automatically for you). Otherwise it is undefined. If you manually add rounded corners to a panel header
  222. * which does not have frame:true, this will need to be set to true.
  223. */
  224. <span id='Ext-panel-Panel-cfg-collapsible'> /**
  225. </span> * @cfg {Boolean} collapsible
  226. * True to make the panel collapsible and have an expand/collapse toggle Tool added into the header tool button
  227. * area. False to keep the panel sized either statically, or by an owning layout manager, with no toggle Tool.
  228. *
  229. * See {@link #collapseMode} and {@link #collapseDirection}
  230. */
  231. collapsible: false,
  232. <span id='Ext-panel-Panel-cfg-collapseDirection'> /**
  233. </span> * @cfg {String} collapseDirection
  234. * The direction to collapse the Panel when the toggle button is clicked.
  235. *
  236. * Defaults to the {@link #headerPosition}
  237. *
  238. * **Important: This config is _ignored_ for {@link #collapsible} Panels which are direct child items of a {@link
  239. * Ext.layout.container.Border border layout}.**
  240. *
  241. * Specify as `'top'`, `'bottom'`, `'left'` or `'right'`.
  242. */
  243. <span id='Ext-panel-Panel-cfg-closable'> /**
  244. </span> * @cfg {Boolean} closable
  245. * True to display the 'close' tool button and allow the user to close the window, false to hide the button and
  246. * disallow closing the window.
  247. *
  248. * By default, when close is requested by clicking the close button in the header, the {@link #method-close} method will be
  249. * called. This will _{@link Ext.Component#method-destroy destroy}_ the Panel and its content meaning that it may not be
  250. * reused.
  251. *
  252. * To make closing a Panel _hide_ the Panel so that it may be reused, set {@link #closeAction} to 'hide'.
  253. */
  254. closable: false,
  255. <span id='Ext-panel-Panel-cfg-closeAction'> /**
  256. </span> * @cfg {String} closeAction
  257. * The action to take when the close header tool is clicked:
  258. *
  259. * - **`'{@link #method-destroy}'`** :
  260. *
  261. * {@link #method-remove remove} the window from the DOM and {@link Ext.Component#method-destroy destroy} it and all descendant
  262. * Components. The window will **not** be available to be redisplayed via the {@link #method-show} method.
  263. *
  264. * - **`'{@link #method-hide}'`** :
  265. *
  266. * {@link #method-hide} the window by setting visibility to hidden and applying negative offsets. The window will be
  267. * available to be redisplayed via the {@link #method-show} method.
  268. *
  269. * **Note:** This behavior has changed! setting *does* affect the {@link #method-close} method which will invoke the
  270. * approriate closeAction.
  271. */
  272. closeAction: 'destroy',
  273. <span id='Ext-panel-Panel-cfg-dockedItems'> /**
  274. </span> * @cfg {Object/Object[]} dockedItems
  275. * A component or series of components to be added as docked items to this panel. The docked items can be docked to
  276. * either the top, right, left or bottom of a panel. This is typically used for things like toolbars or tab bars:
  277. *
  278. * var panel = new Ext.panel.Panel({
  279. * dockedItems: [{
  280. * xtype: 'toolbar',
  281. * dock: 'top',
  282. * items: [{
  283. * text: 'Docked to the top'
  284. * }]
  285. * }]
  286. * });
  287. */
  288. <span id='Ext-panel-Panel-cfg-placeholderCollapseHideMode'> /**
  289. </span> * @cfg {Number} placeholderCollapseHideMode
  290. * The {@link Ext.dom.Element#setVisibilityMode mode} for hiding collapsed panels when
  291. * using {@link #collapseMode} &quot;placeholder&quot;.
  292. */
  293. placeholderCollapseHideMode: Ext.Element.VISIBILITY,
  294. <span id='Ext-panel-Panel-cfg-preventHeader'> /**
  295. </span> * @cfg {Boolean} preventHeader
  296. * @deprecated 4.1.0 Use {@link #header} instead.
  297. * Prevent a Header from being created and shown.
  298. */
  299. preventHeader: false,
  300. <span id='Ext-panel-Panel-cfg-header'> /**
  301. </span> * @cfg {Boolean/Object} header
  302. * Pass as `false` to prevent a Header from being created and shown.
  303. *
  304. * Pass as a config object (optionally containing an `xtype`) to custom-configure this Panel's header.
  305. *
  306. */
  307. header: undefined,
  308. <span id='Ext-panel-Panel-cfg-headerPosition'> /**
  309. </span> * @cfg {String} headerPosition
  310. * Specify as `'top'`, `'bottom'`, `'left'` or `'right'`.
  311. */
  312. headerPosition: 'top',
  313. <span id='Ext-panel-Panel-cfg-frame'> /**
  314. </span> * @cfg {Boolean} frame
  315. * True to apply a frame to the panel.
  316. */
  317. frame: false,
  318. <span id='Ext-panel-Panel-cfg-frameHeader'> /**
  319. </span> * @cfg {Boolean} frameHeader
  320. * True to apply a frame to the panel panels header (if 'frame' is true).
  321. */
  322. frameHeader: true,
  323. <span id='Ext-panel-Panel-cfg-tools'> /**
  324. </span> * @cfg {Object[]/Ext.panel.Tool[]} tools
  325. * An array of {@link Ext.panel.Tool} configs/instances to be added to the header tool area. The tools are stored as
  326. * child components of the header container. They can be accessed using {@link #down} and {#query}, as well as the
  327. * other component methods. The toggle tool is automatically created if {@link #collapsible} is set to true.
  328. *
  329. * Note that, apart from the toggle tool which is provided when a panel is collapsible, these tools only provide the
  330. * visual button. Any required functionality must be provided by adding handlers that implement the necessary
  331. * behavior.
  332. *
  333. * Example usage:
  334. *
  335. * tools:[{
  336. * type:'refresh',
  337. * tooltip: 'Refresh form Data',
  338. * // hidden:true,
  339. * handler: function(event, toolEl, panel){
  340. * // refresh logic
  341. * }
  342. * },
  343. * {
  344. * type:'help',
  345. * tooltip: 'Get Help',
  346. * handler: function(event, toolEl, panel){
  347. * // show help here
  348. * }
  349. * }]
  350. */
  351. <span id='Ext-panel-Panel-cfg-title'> /**
  352. </span> * @cfg {String} [title='']
  353. * The title text to be used to display in the {@link Ext.panel.Header panel header}. When a
  354. * `title` is specified the {@link Ext.panel.Header} will automatically be created and displayed unless
  355. * {@link #header} is set to `false`.
  356. */
  357. <span id='Ext-panel-Panel-cfg-titleAlign'> /**
  358. </span> * @cfg {String} [titleAlign='left']
  359. * May be `&quot;left&quot;`, `&quot;right&quot;` or `&quot;center&quot;`.
  360. *
  361. * The alignment of the title text within the available space between the icon and the tools.
  362. */
  363. titleAlign: 'left',
  364. <span id='Ext-panel-Panel-cfg-manageHeight'> /**
  365. </span> * @cfg {Boolean} [manageHeight=true]: When true, the dock component layout writes
  366. * height information to the panel's DOM elements based on its shrink wrap height
  367. * calculation. This ensures that the browser respects the calculated height.
  368. * When false, the dock component layout will not write heights on the panel or its
  369. * body element. In some simple layout cases, not writing the heights to the DOM may
  370. * be desired because this allows the browser to respond to direct DOM manipulations
  371. * (like animations).
  372. */
  373. manageHeight: true,
  374. <span id='Ext-panel-Panel-cfg-iconCls'> /**
  375. </span> * @cfg {String} iconCls
  376. * CSS class for an icon in the header. Used for displaying an icon to the left of a title.
  377. */
  378. <span id='Ext-panel-Panel-cfg-icon'> /**
  379. </span> * @cfg {String} icon
  380. * Path to image for an icon in the header. Used for displaying an icon to the left of a title.
  381. */
  382. initComponent: function() {
  383. var me = this;
  384. me.addEvents(
  385. <span id='Ext-panel-Panel-event-beforeclose'> /**
  386. </span> * @event beforeclose
  387. * Fires before the user closes the panel. Return false from any listener to stop the close event being
  388. * fired
  389. * @param {Ext.panel.Panel} panel The Panel object
  390. */
  391. 'beforeclose',
  392. <span id='Ext-panel-Panel-event-close'> /**
  393. </span> * @event close
  394. * Fires when the user closes the panel.
  395. * @param {Ext.panel.Panel} panel The Panel object
  396. */
  397. 'close',
  398. <span id='Ext-panel-Panel-event-beforeexpand'> /**
  399. </span> * @event beforeexpand
  400. * Fires before this panel is expanded. Return false to prevent the expand.
  401. * @param {Ext.panel.Panel} p The Panel being expanded.
  402. * @param {Boolean} animate True if the expand is animated, else false.
  403. */
  404. &quot;beforeexpand&quot;,
  405. <span id='Ext-panel-Panel-event-beforecollapse'> /**
  406. </span> * @event beforecollapse
  407. * Fires before this panel is collapsed. Return false to prevent the collapse.
  408. * @param {Ext.panel.Panel} p The Panel being collapsed.
  409. * @param {String} direction . The direction of the collapse. One of
  410. *
  411. * - Ext.Component.DIRECTION_TOP
  412. * - Ext.Component.DIRECTION_RIGHT
  413. * - Ext.Component.DIRECTION_BOTTOM
  414. * - Ext.Component.DIRECTION_LEFT
  415. *
  416. * @param {Boolean} animate True if the collapse is animated, else false.
  417. */
  418. &quot;beforecollapse&quot;,
  419. <span id='Ext-panel-Panel-event-expand'> /**
  420. </span> * @event expand
  421. * Fires after this Panel has expanded.
  422. * @param {Ext.panel.Panel} p The Panel that has been expanded.
  423. */
  424. &quot;expand&quot;,
  425. <span id='Ext-panel-Panel-event-collapse'> /**
  426. </span> * @event collapse
  427. * Fires after this Panel hass collapsed.
  428. * @param {Ext.panel.Panel} p The Panel that has been collapsed.
  429. */
  430. &quot;collapse&quot;,
  431. <span id='Ext-panel-Panel-event-titlechange'> /**
  432. </span> * @event titlechange
  433. * Fires after the Panel title has been set or changed.
  434. * @param {Ext.panel.Panel} p the Panel which has been resized.
  435. * @param {String} newTitle The new title.
  436. * @param {String} oldTitle The previous panel title.
  437. */
  438. 'titlechange',
  439. <span id='Ext-panel-Panel-event-iconchange'> /**
  440. </span> * @event iconchange
  441. * Fires after the Panel icon has been set or changed.
  442. * @param {Ext.panel.Panel} p The Panel which has the icon changed.
  443. * @param {String} newIcon The path to the new icon image.
  444. * @param {String} oldIcon The path to the previous panel icon image.
  445. */
  446. 'iconchange',
  447. <span id='Ext-panel-Panel-event-iconclschange'> /**
  448. </span> * @event iconclschange
  449. * Fires after the Panel iconCls has been set or changed.
  450. * @param {Ext.panel.Panel} p The Panel which has the iconCls changed.
  451. * @param {String} newIconCls The new iconCls.
  452. * @param {String} oldIconCls The previous panel iconCls.
  453. */
  454. 'iconclschange'
  455. );
  456. if (me.collapsible) {
  457. // Save state on these two events.
  458. this.addStateEvents(['expand', 'collapse']);
  459. }
  460. if (me.unstyled) {
  461. me.setUI('plain');
  462. }
  463. if (me.frame) {
  464. me.setUI(me.ui + '-framed');
  465. }
  466. // Backwards compatibility
  467. me.bridgeToolbars();
  468. me.callParent();
  469. me.collapseDirection = me.collapseDirection || me.headerPosition || Ext.Component.DIRECTION_TOP;
  470. // Used to track hidden content elements during collapsed state
  471. me.hiddenOnCollapse = new Ext.dom.CompositeElement();
  472. },
  473. beforeDestroy: function() {
  474. var me = this;
  475. Ext.destroy(
  476. me.placeholder,
  477. me.ghostPanel,
  478. me.dd
  479. );
  480. me.callParent();
  481. },
  482. initAria: function() {
  483. this.callParent();
  484. this.initHeaderAria();
  485. },
  486. getFocusEl: function() {
  487. return this.el;
  488. },
  489. initHeaderAria: function() {
  490. var me = this,
  491. el = me.el,
  492. header = me.header;
  493. if (el &amp;&amp; header) {
  494. el.dom.setAttribute('aria-labelledby', header.titleCmp.id);
  495. }
  496. },
  497. <span id='Ext-panel-Panel-method-getHeader'> /**
  498. </span> * Gets the {@link Ext.panel.Header Header} for this panel.
  499. */
  500. getHeader: function() {
  501. return this.header;
  502. },
  503. <span id='Ext-panel-Panel-method-setTitle'> /**
  504. </span> * Set a title for the panel's header. See {@link Ext.panel.Header#title}.
  505. * @param {String} newTitle
  506. */
  507. setTitle: function(newTitle) {
  508. var me = this,
  509. oldTitle = me.title,
  510. header = me.header,
  511. reExpander = me.reExpander,
  512. placeholder = me.placeholder;
  513. me.title = newTitle;
  514. if (header) {
  515. if (header.isHeader) {
  516. header.setTitle(newTitle);
  517. } else {
  518. header.title = newTitle;
  519. }
  520. } else {
  521. me.updateHeader();
  522. }
  523. if (reExpander) {
  524. reExpander.setTitle(newTitle);
  525. }
  526. if (placeholder &amp;&amp; placeholder.setTitle) {
  527. placeholder.setTitle(newTitle);
  528. }
  529. me.fireEvent('titlechange', me, newTitle, oldTitle);
  530. },
  531. <span id='Ext-panel-Panel-method-setIconCls'> /**
  532. </span> * Set the iconCls for the panel's header. See {@link Ext.panel.Header#iconCls}. It will fire the
  533. * {@link #iconclschange} event after completion.
  534. * @param {String} newIconCls The new CSS class name
  535. */
  536. setIconCls: function(newIconCls) {
  537. var me = this,
  538. oldIconCls = me.iconCls,
  539. header = me.header,
  540. placeholder = me.placeholder;
  541. me.iconCls = newIconCls;
  542. if (header) {
  543. if (header.isHeader) {
  544. header.setIconCls(newIconCls);
  545. } else {
  546. header.iconCls = newIconCls;
  547. }
  548. } else {
  549. me.updateHeader();
  550. }
  551. if (placeholder &amp;&amp; placeholder.setIconCls) {
  552. placeholder.setIconCls(newIconCls);
  553. }
  554. me.fireEvent('iconclschange', me, newIconCls, oldIconCls);
  555. },
  556. <span id='Ext-panel-Panel-method-setIcon'> /**
  557. </span> * Set the icon for the panel's header. See {@link Ext.panel.Header#icon}. It will fire the
  558. * {@link #iconchange} event after completion.
  559. * @param {String} newIcon The new icon path
  560. */
  561. setIcon: function(newIcon) {
  562. var me = this,
  563. oldIcon = me.icon,
  564. header = me.header,
  565. placeholder = me.placeholder;
  566. me.icon = newIcon;
  567. if (header) {
  568. if (header.isHeader) {
  569. header.setIcon(newIcon);
  570. } else {
  571. header.icon = newIcon;
  572. }
  573. } else {
  574. me.updateHeader();
  575. }
  576. if (placeholder &amp;&amp; placeholder.setIcon) {
  577. placeholder.setIcon(newIcon);
  578. }
  579. me.fireEvent('iconchange', me, newIcon, oldIcon);
  580. },
  581. bridgeToolbars: function() {
  582. var me = this,
  583. docked = [],
  584. fbar,
  585. fbarDefaults,
  586. minButtonWidth = me.minButtonWidth;
  587. function initToolbar (toolbar, pos, useButtonAlign) {
  588. if (Ext.isArray(toolbar)) {
  589. toolbar = {
  590. xtype: 'toolbar',
  591. items: toolbar
  592. };
  593. }
  594. else if (!toolbar.xtype) {
  595. toolbar.xtype = 'toolbar';
  596. }
  597. toolbar.dock = pos;
  598. if (pos == 'left' || pos == 'right') {
  599. toolbar.vertical = true;
  600. }
  601. // Legacy support for buttonAlign (only used by buttons/fbar)
  602. if (useButtonAlign) {
  603. toolbar.layout = Ext.applyIf(toolbar.layout || {}, {
  604. // default to 'end' (right-aligned) if me.buttonAlign is undefined or invalid
  605. pack: { left:'start', center:'center' }[me.buttonAlign] || 'end'
  606. });
  607. }
  608. return toolbar;
  609. }
  610. // Short-hand toolbars (tbar, bbar and fbar plus new lbar and rbar):
  611. <span id='Ext-panel-Panel-cfg-buttonAlign'> /**
  612. </span> * @cfg {String} buttonAlign
  613. * The alignment of any buttons added to this panel. Valid values are 'right', 'left' and 'center' (defaults to
  614. * 'right' for buttons/fbar, 'left' for other toolbar types).
  615. *
  616. * **NOTE:** The prefered way to specify toolbars is to use the dockedItems config. Instead of buttonAlign you
  617. * would add the layout: { pack: 'start' | 'center' | 'end' } option to the dockedItem config.
  618. */
  619. <span id='Ext-panel-Panel-cfg-tbar'> /**
  620. </span> * @cfg {Object/Object[]} tbar
  621. * Convenience config. Short for 'Top Bar'.
  622. *
  623. * tbar: [
  624. * { xtype: 'button', text: 'Button 1' }
  625. * ]
  626. *
  627. * is equivalent to
  628. *
  629. * dockedItems: [{
  630. * xtype: 'toolbar',
  631. * dock: 'top',
  632. * items: [
  633. * { xtype: 'button', text: 'Button 1' }
  634. * ]
  635. * }]
  636. */
  637. if (me.tbar) {
  638. docked.push(initToolbar(me.tbar, 'top'));
  639. me.tbar = null;
  640. }
  641. <span id='Ext-panel-Panel-cfg-bbar'> /**
  642. </span> * @cfg {Object/Object[]} bbar
  643. * Convenience config. Short for 'Bottom Bar'.
  644. *
  645. * bbar: [
  646. * { xtype: 'button', text: 'Button 1' }
  647. * ]
  648. *
  649. * is equivalent to
  650. *
  651. * dockedItems: [{
  652. * xtype: 'toolbar',
  653. * dock: 'bottom',
  654. * items: [
  655. * { xtype: 'button', text: 'Button 1' }
  656. * ]
  657. * }]
  658. */
  659. if (me.bbar) {
  660. docked.push(initToolbar(me.bbar, 'bottom'));
  661. me.bbar = null;
  662. }
  663. <span id='Ext-panel-Panel-cfg-buttons'> /**
  664. </span> * @cfg {Object/Object[]} buttons
  665. * Convenience config used for adding buttons docked to the bottom of the panel. This is a
  666. * synonym for the {@link #fbar} config.
  667. *
  668. * buttons: [
  669. * { text: 'Button 1' }
  670. * ]
  671. *
  672. * is equivalent to
  673. *
  674. * dockedItems: [{
  675. * xtype: 'toolbar',
  676. * dock: 'bottom',
  677. * ui: 'footer',
  678. * defaults: {minWidth: {@link #minButtonWidth}},
  679. * items: [
  680. * { xtype: 'component', flex: 1 },
  681. * { xtype: 'button', text: 'Button 1' }
  682. * ]
  683. * }]
  684. *
  685. * The {@link #minButtonWidth} is used as the default {@link Ext.button.Button#minWidth minWidth} for
  686. * each of the buttons in the buttons toolbar.
  687. */
  688. if (me.buttons) {
  689. me.fbar = me.buttons;
  690. me.buttons = null;
  691. }
  692. <span id='Ext-panel-Panel-cfg-fbar'> /**
  693. </span> * @cfg {Object/Object[]} fbar
  694. * Convenience config used for adding items to the bottom of the panel. Short for Footer Bar.
  695. *
  696. * fbar: [
  697. * { type: 'button', text: 'Button 1' }
  698. * ]
  699. *
  700. * is equivalent to
  701. *
  702. * dockedItems: [{
  703. * xtype: 'toolbar',
  704. * dock: 'bottom',
  705. * ui: 'footer',
  706. * defaults: {minWidth: {@link #minButtonWidth}},
  707. * items: [
  708. * { xtype: 'component', flex: 1 },
  709. * { xtype: 'button', text: 'Button 1' }
  710. * ]
  711. * }]
  712. *
  713. * The {@link #minButtonWidth} is used as the default {@link Ext.button.Button#minWidth minWidth} for
  714. * each of the buttons in the fbar.
  715. */
  716. if (me.fbar) {
  717. fbar = initToolbar(me.fbar, 'bottom', true); // only we useButtonAlign
  718. fbar.ui = 'footer';
  719. // Apply the minButtonWidth config to buttons in the toolbar
  720. if (minButtonWidth) {
  721. fbarDefaults = fbar.defaults;
  722. fbar.defaults = function(config) {
  723. var defaults = fbarDefaults || {};
  724. if ((!config.xtype || config.xtype === 'button' || (config.isComponent &amp;&amp; config.isXType('button'))) &amp;&amp;
  725. !('minWidth' in defaults)) {
  726. defaults = Ext.apply({minWidth: minButtonWidth}, defaults);
  727. }
  728. return defaults;
  729. };
  730. }
  731. docked.push(fbar);
  732. me.fbar = null;
  733. }
  734. <span id='Ext-panel-Panel-cfg-lbar'> /**
  735. </span> * @cfg {Object/Object[]} lbar
  736. * Convenience config. Short for 'Left Bar' (left-docked, vertical toolbar).
  737. *
  738. * lbar: [
  739. * { xtype: 'button', text: 'Button 1' }
  740. * ]
  741. *
  742. * is equivalent to
  743. *
  744. * dockedItems: [{
  745. * xtype: 'toolbar',
  746. * dock: 'left',
  747. * items: [
  748. * { xtype: 'button', text: 'Button 1' }
  749. * ]
  750. * }]
  751. */
  752. if (me.lbar) {
  753. docked.push(initToolbar(me.lbar, 'left'));
  754. me.lbar = null;
  755. }
  756. <span id='Ext-panel-Panel-cfg-rbar'> /**
  757. </span> * @cfg {Object/Object[]} rbar
  758. * Convenience config. Short for 'Right Bar' (right-docked, vertical toolbar).
  759. *
  760. * rbar: [
  761. * { xtype: 'button', text: 'Button 1' }
  762. * ]
  763. *
  764. * is equivalent to
  765. *
  766. * dockedItems: [{
  767. * xtype: 'toolbar',
  768. * dock: 'right',
  769. * items: [
  770. * { xtype: 'button', text: 'Button 1' }
  771. * ]
  772. * }]
  773. */
  774. if (me.rbar) {
  775. docked.push(initToolbar(me.rbar, 'right'));
  776. me.rbar = null;
  777. }
  778. if (me.dockedItems) {
  779. if (!Ext.isArray(me.dockedItems)) {
  780. me.dockedItems = [me.dockedItems];
  781. }
  782. me.dockedItems = me.dockedItems.concat(docked);
  783. } else {
  784. me.dockedItems = docked;
  785. }
  786. },
  787. isPlaceHolderCollapse: function(){
  788. return this.collapseMode == 'placeholder';
  789. },
  790. onBoxReady: function(){
  791. this.callParent();
  792. if (this.collapsed) {
  793. this.setHiddenDocked();
  794. }
  795. },
  796. beforeRender: function() {
  797. var me = this,
  798. wasCollapsed;
  799. me.callParent();
  800. // Add class-specific header tools.
  801. // Panel adds collapsible and closable.
  802. me.initTools();
  803. // Dock the header/title unless we are configured specifically not to create a header
  804. if (!(me.preventHeader || (me.header === false))) {
  805. me.updateHeader();
  806. }
  807. // If we are rendering collapsed, we still need to save and modify various configs
  808. if (me.collapsed) {
  809. if (me.isPlaceHolderCollapse()) {
  810. me.hidden = true;
  811. // This will insert the placeholder Component into the ownerCt's child collection
  812. // Its getRenderTree call which is calling this will then iterate again and
  813. // recreate the child items array to include the new Component.
  814. me.placeholderCollapse();
  815. wasCollapsed = me.collapsed;
  816. // Temporarily clear the flag so that the header is rendered with a collapse tool in it.
  817. // Placeholder collapse panels never really collapse, they just hide. The tool is always
  818. // a collapse tool.
  819. me.collapsed = false;
  820. } else {
  821. me.beginCollapse();
  822. me.addClsWithUI(me.collapsedCls);
  823. }
  824. }
  825. // Restore the flag if we are being rendered initially placeholder collapsed.
  826. if (wasCollapsed) {
  827. me.collapsed = wasCollapsed;
  828. }
  829. },
  830. <span id='Ext-panel-Panel-method-initTools'> /**
  831. </span> * @private
  832. * Tools are a Panel-specific capabilty.
  833. * Panel uses initTools. Subclasses may contribute tools by implementing addTools.
  834. */
  835. initTools: function() {
  836. var me = this;
  837. me.tools = me.tools ? Ext.Array.clone(me.tools) : [];
  838. // Add a collapse tool unless configured to not show a collapse tool
  839. // or to not even show a header.
  840. if (me.collapsible &amp;&amp; !(me.hideCollapseTool || me.header === false || me.preventHeader)) {
  841. me.collapseDirection = me.collapseDirection || me.headerPosition || 'top';
  842. me.collapseTool = me.expandTool = Ext.widget({
  843. xtype: 'tool',
  844. type: (me.collapsed &amp;&amp; !me.isPlaceHolderCollapse()) ? ('expand-' + me.getOppositeDirection(me.collapseDirection)) : ('collapse-' + me.collapseDirection),
  845. handler: me.toggleCollapse,
  846. scope: me
  847. });
  848. // Prepend collapse tool is configured to do so.
  849. if (me.collapseFirst) {
  850. me.tools.unshift(me.collapseTool);
  851. }
  852. }
  853. // Add subclass-specific tools.
  854. me.addTools();
  855. // Make Panel closable.
  856. if (me.closable) {
  857. me.addClsWithUI('closable');
  858. me.addTool({
  859. type: 'close',
  860. handler: Ext.Function.bind(me.close, me, [])
  861. });
  862. }
  863. // Append collapse tool if needed.
  864. if (me.collapseTool &amp;&amp; !me.collapseFirst) {
  865. me.addTool(me.collapseTool);
  866. }
  867. },
  868. <span id='Ext-panel-Panel-method-addTools'> /**
  869. </span> * @private
  870. * @template
  871. * Template method to be implemented in subclasses to add their tools after the collapsible tool.
  872. */
  873. addTools: Ext.emptyFn,
  874. <span id='Ext-panel-Panel-method-close'> /**
  875. </span> * Closes the Panel. By default, this method, removes it from the DOM, {@link Ext.Component#method-destroy destroy}s the
  876. * Panel object and all its descendant Components. The {@link #beforeclose beforeclose} event is fired before the
  877. * close happens and will cancel the close action if it returns false.
  878. *
  879. * **Note:** This method is also affected by the {@link #closeAction} setting. For more explicit control use
  880. * {@link #method-destroy} and {@link #method-hide} methods.
  881. */
  882. close: function() {
  883. if (this.fireEvent('beforeclose', this) !== false) {
  884. this.doClose();
  885. }
  886. },
  887. // private
  888. doClose: function() {
  889. this.fireEvent('close', this);
  890. this[this.closeAction]();
  891. },
  892. <span id='Ext-panel-Panel-method-updateHeader'> /**
  893. </span> * Create, hide, or show the header component as appropriate based on the current config.
  894. * @private
  895. * @param {Boolean} force True to force the header to be created
  896. */
  897. updateHeader: function(force) {
  898. var me = this,
  899. header = me.header,
  900. title = me.title,
  901. tools = me.tools,
  902. icon = me.icon || me.iconCls,
  903. vertical = me.headerPosition == 'left' || me.headerPosition == 'right';
  904. if ((header !== false) &amp;&amp; (force || (title || icon) || (tools &amp;&amp; tools.length) || (me.collapsible &amp;&amp; !me.titleCollapse))) {
  905. if (header &amp;&amp; header.isHeader) {
  906. header.show();
  907. } else {
  908. // Apply the header property to the header config
  909. header = me.header = Ext.widget(Ext.apply({
  910. xtype : 'header',
  911. title : title,
  912. titleAlign : me.titleAlign,
  913. orientation : vertical ? 'vertical' : 'horizontal',
  914. dock : me.headerPosition || 'top',
  915. textCls : me.headerTextCls,
  916. iconCls : me.iconCls,
  917. icon : me.icon,
  918. baseCls : me.baseCls + '-header',
  919. tools : tools,
  920. ui : me.ui,
  921. id : me.id + '_header',
  922. indicateDrag: me.draggable,
  923. frame : (me.frame || me.alwaysFramed) &amp;&amp; me.frameHeader,
  924. ignoreParentFrame : me.frame || me.overlapHeader,
  925. ignoreBorderManagement: me.frame || me.ignoreHeaderBorderManagement,
  926. listeners : me.collapsible &amp;&amp; me.titleCollapse ? {
  927. click: me.toggleCollapse,
  928. scope: me
  929. } : null
  930. }, me.header));
  931. me.addDocked(header, 0);
  932. // Reference the Header's tool array.
  933. // Header injects named references.
  934. me.tools = header.tools;
  935. }
  936. me.initHeaderAria();
  937. } else if (header) {
  938. header.hide();
  939. }
  940. },
  941. // inherit docs
  942. setUI: function(ui) {
  943. var me = this;
  944. me.callParent(arguments);
  945. if (me.header &amp;&amp; me.header.rendered) {
  946. me.header.setUI(ui);
  947. }
  948. },
  949. // private
  950. getContentTarget: function() {
  951. return this.body;
  952. },
  953. getTargetEl: function() {
  954. var me = this;
  955. return me.body || me.protoBody || me.frameBody || me.el;
  956. },
  957. // the overrides below allow for collapsed regions inside the border layout to be hidden
  958. // inherit docs
  959. isVisible: function(deep){
  960. var me = this;
  961. if (me.collapsed &amp;&amp; me.placeholder) {
  962. return me.placeholder.isVisible(deep);
  963. }
  964. return me.callParent(arguments);
  965. },
  966. // inherit docs
  967. onHide: function(){
  968. var me = this;
  969. if (me.collapsed &amp;&amp; me.placeholder) {
  970. me.placeholder.hide();
  971. } else {
  972. me.callParent(arguments);
  973. }
  974. },
  975. // inherit docs
  976. onShow: function(){
  977. var me = this;
  978. if (me.collapsed &amp;&amp; me.placeholder) {
  979. // force hidden back to true, since this gets set by the layout
  980. me.hidden = true;
  981. me.placeholder.show();
  982. } else {
  983. me.callParent(arguments);
  984. }
  985. },
  986. onRemoved: function(destroying) {
  987. var me = this;
  988. me.callParent(arguments);
  989. // If we are removed but not being destroyed, ensure our placeholder is also removed but not destroyed
  990. // If we are being destroyed, our destroy processing will destroy the placeholder.
  991. if (me.placeholder &amp;&amp; !destroying) {
  992. me.ownerCt.remove(me.placeholder, false);
  993. }
  994. },
  995. addTool: function(tools) {
  996. tools = [].concat(tools);
  997. var me = this,
  998. header = me.header,
  999. t,
  1000. tLen = tools.length,
  1001. tool;
  1002. for (t = 0; t &lt; tLen; t++) {
  1003. tool = tools[t];
  1004. me.tools.push(tool);
  1005. if (header &amp;&amp; header.isHeader) {
  1006. header.addTool(tool);
  1007. }
  1008. }
  1009. me.updateHeader();
  1010. },
  1011. getOppositeDirection: function(d) {
  1012. var c = Ext.Component;
  1013. switch (d) {
  1014. case c.DIRECTION_TOP:
  1015. return c.DIRECTION_BOTTOM;
  1016. case c.DIRECTION_RIGHT:
  1017. return c.DIRECTION_LEFT;
  1018. case c.DIRECTION_BOTTOM:
  1019. return c.DIRECTION_TOP;
  1020. case c.DIRECTION_LEFT:
  1021. return c.DIRECTION_RIGHT;
  1022. }
  1023. },
  1024. getWidthAuthority: function() {
  1025. if (this.collapsed &amp;&amp; this.collapsedHorizontal()) {
  1026. return 1; // the panel determine's its own width
  1027. }
  1028. return this.callParent();
  1029. },
  1030. getHeightAuthority: function() {
  1031. if (this.collapsed &amp;&amp; this.collapsedVertical()) {
  1032. return 1; // the panel determine's its own height
  1033. }
  1034. return this.callParent();
  1035. },
  1036. collapsedHorizontal: function () {
  1037. var dir = this.getCollapsed();
  1038. return dir == 'left' || dir == 'right';
  1039. },
  1040. collapsedVertical: function () {
  1041. var dir = this.getCollapsed();
  1042. return dir == 'top' || dir == 'bottom';
  1043. },
  1044. restoreDimension: function(){
  1045. var dir = this.collapseDirection;
  1046. // If we're collapsing top/bottom, we want to restore the height
  1047. // If we're collapsing left/right, we want to restore the width
  1048. return (dir === 'top' || dir === 'bottom') ? 'height' : 'width';
  1049. },
  1050. <span id='Ext-panel-Panel-method-getCollapsed'> /**
  1051. </span> * Returns the current collapsed state of the panel.
  1052. * @return {Boolean/String} False when not collapsed, otherwise the value of {@link #collapseDirection}.
  1053. */
  1054. getCollapsed: function() {
  1055. var me = this;
  1056. // The collapsed flag, when the Panel is collapsed acts as the direction in which the collapse took
  1057. // place. It can still be tested as truthy/falsy if only a truth value is required.
  1058. if (me.collapsed === true) {
  1059. return me.collapseDirection;
  1060. }
  1061. return me.collapsed;
  1062. },
  1063. getState: function() {
  1064. var me = this,
  1065. state = me.callParent(),
  1066. memento;
  1067. state = me.addPropertyToState(state, 'collapsed');
  1068. // If a collapse has taken place, use remembered values as the dimensions.
  1069. if (me.collapsed) {
  1070. memento = me.collapseMemento;
  1071. memento = memento &amp;&amp; memento.data;
  1072. if (me.collapsedVertical()) {
  1073. if (state) {
  1074. delete state.height;
  1075. }
  1076. if (memento) {
  1077. state = me.addPropertyToState(state, 'height', memento.height);
  1078. }
  1079. } else {
  1080. if (state) {
  1081. delete state.width;
  1082. }
  1083. if (memento) {
  1084. state = me.addPropertyToState(state, 'width', memento.width);
  1085. }
  1086. }
  1087. }
  1088. return state;
  1089. },
  1090. findReExpander: function (direction) {
  1091. var me = this,
  1092. c = Ext.Component,
  1093. dockedItems = me.dockedItems.items,
  1094. dockedItemCount = dockedItems.length,
  1095. comp, i;
  1096. // never use the header if we're in collapseMode mini
  1097. if (me.collapseMode == 'mini') {
  1098. return;
  1099. }
  1100. switch (direction) {
  1101. case c.DIRECTION_TOP:
  1102. case c.DIRECTION_BOTTOM:
  1103. // Attempt to find a reExpander Component (docked in a horizontal orientation)
  1104. // Also, collect all other docked items which we must hide after collapse.
  1105. for (i = 0; i &lt; dockedItemCount; i++) {
  1106. comp = dockedItems[i];
  1107. if (!comp.hidden) {
  1108. if (comp.isHeader &amp;&amp; (!comp.dock || comp.dock == 'top' || comp.dock == 'bottom')) {
  1109. return comp;
  1110. }
  1111. }
  1112. }
  1113. break;
  1114. case c.DIRECTION_LEFT:
  1115. case c.DIRECTION_RIGHT:
  1116. // Attempt to find a reExpander Component (docked in a vecrtical orientation)
  1117. // Also, collect all other docked items which we must hide after collapse.
  1118. for (i = 0; i &lt; dockedItemCount; i++) {
  1119. comp = dockedItems[i];
  1120. if (!comp.hidden) {
  1121. if (comp.isHeader &amp;&amp; (comp.dock == 'left' || comp.dock == 'right')) {
  1122. return comp;
  1123. }
  1124. }
  1125. }
  1126. break;
  1127. default:
  1128. throw('Panel#findReExpander must be passed a valid collapseDirection');
  1129. }
  1130. },
  1131. getReExpander: function (direction) {
  1132. var me = this,
  1133. collapseDir = direction || me.collapseDirection,
  1134. reExpander = me.reExpander || me.findReExpander(collapseDir);
  1135. me.expandDirection = me.getOppositeDirection(collapseDir);
  1136. if (!reExpander) {
  1137. // We did not find a Header of the required orientation: create one.
  1138. me.reExpander = reExpander = me.createReExpander(collapseDir, {
  1139. dock: collapseDir,
  1140. cls: Ext.baseCSSPrefix + 'docked ' + me.baseCls + '-' + me.ui + '-collapsed',
  1141. ownerCt: me,
  1142. ownerLayout: me.componentLayout
  1143. });
  1144. me.dockedItems.insert(0, reExpander);
  1145. }
  1146. return reExpander;
  1147. },
  1148. createReExpander: function(direction, defaults) {
  1149. var me = this,
  1150. isLeft = direction == 'left',
  1151. isRight = direction == 'right',
  1152. isVertical = isLeft || isRight,
  1153. toolAtTop,
  1154. result = Ext.apply({
  1155. hideMode: 'offsets',
  1156. title: me.title,
  1157. orientation: isVertical ? 'vertical' : 'horizontal',
  1158. textCls: me.headerTextCls,
  1159. icon: me.icon,
  1160. iconCls: me.iconCls,
  1161. baseCls: me.baseCls + '-header',
  1162. ui: me.ui,
  1163. frame: me.frame &amp;&amp; me.frameHeader,
  1164. ignoreParentFrame: me.frame || me.overlapHeader,
  1165. indicateDrag: me.draggable
  1166. }, defaults);
  1167. // If we're in mini mode, set the placeholder size to only 1px since
  1168. // we don't need it to show up.
  1169. if (me.collapseMode == 'mini') {
  1170. if (isVertical) {
  1171. result.width = 1;
  1172. } else {
  1173. result.height = 1;
  1174. }
  1175. }
  1176. // Create the re expand tool
  1177. // For UI consistency reasons, collapse:left reExpanders, and region: 'west' placeHolders
  1178. // have the re expand tool at the *top* with a bit of space.
  1179. if (!me.hideCollapseTool) {
  1180. toolAtTop = isLeft || (isRight &amp;&amp; me.isPlaceHolderCollapse());
  1181. result[toolAtTop ? 'items' : 'tools'] = [{
  1182. xtype: 'tool',
  1183. type: 'expand-' + me.getOppositeDirection(direction),
  1184. uiCls: ['top'],
  1185. handler: me.toggleCollapse,
  1186. scope: me
  1187. }];
  1188. }
  1189. result = new Ext.panel.Header(result);
  1190. result.addClsWithUI(me.getHeaderCollapsedClasses(result));
  1191. return result;
  1192. },
  1193. // private
  1194. // Create the class array to add to the Header when collpsed.
  1195. getHeaderCollapsedClasses: function(header) {
  1196. var me = this,
  1197. collapsedCls = me.collapsedCls,
  1198. collapsedClasses;
  1199. collapsedClasses = [ collapsedCls, collapsedCls + '-' + header.dock];
  1200. if (me.border &amp;&amp; (!me.frame || (me.frame &amp;&amp; Ext.supports.CSS3BorderRadius))) {
  1201. collapsedClasses.push(collapsedCls + '-border-' + header.dock);
  1202. }
  1203. return collapsedClasses;
  1204. },
  1205. <span id='Ext-panel-Panel-method-beginCollapse'> /**
  1206. </span> * @private
  1207. * Called before the change from default, configured state into the collapsed state.
  1208. * This method may be called at render time to enable rendering in an initially collapsed state,
  1209. * or at runtime when an existing, fully layed out Panel may be collapsed.
  1210. * It basically saves configs which need to be clobbered for the duration of the collapsed state.
  1211. */
  1212. beginCollapse: function() {
  1213. var me = this,
  1214. lastBox = me.lastBox,
  1215. rendered = me.rendered,
  1216. collapseMemento = me.collapseMemento || (me.collapseMemento = new Ext.util.Memento(me)),
  1217. sizeModel = me.getSizeModel(),
  1218. reExpander;
  1219. // When we collapse a panel, the panel is in control of one dimension (depending on
  1220. // collapse direction) and sets that on the component. We must restore the user's
  1221. // original value (including non-existance) when we expand. Using this technique, we
  1222. // mimic setCalculatedSize for the dimension we do not control and setSize for the
  1223. // one we do (only while collapsed).
  1224. // Additionally, the panel may have a shrink wrapped width and/or height. For shrinkWrapped
  1225. // panels this can be problematic, since a collapsed, shrink-wrapped panel has no way
  1226. // of determining its width (or height if the collapse direction is horizontal). It is
  1227. // therefore necessary to capture both the width and height regardless of collapse direction.
  1228. // This allows us to set a configured width or height on the panel when it is collapsed,
  1229. // and it will be restored to an unconfigured-width shrinkWrapped state on expand.
  1230. collapseMemento.capture(['height', 'minHeight', 'width', 'minWidth']);
  1231. if (lastBox) {
  1232. collapseMemento.capture(me.restoreDimension(), lastBox, 'last.');
  1233. }
  1234. // If the panel has a shrinkWrapped height/width and is already rendered, configure its width/height as its calculated width/height,
  1235. // so that the collapsed header will have the same width or height as the panel did before it was collapsed.
  1236. // If the shrinkWrapped panel has not yet been rendered, as will be the case when a panel is initially configured with
  1237. // collapsed:true, we attempt to use the configured width/height, and fall back to minWidth or minHeight if
  1238. // width/height has not been configured, and fall back to a value of 100 if a minWidth/minHeight has not been configured.
  1239. if (me.collapsedVertical()) {
  1240. if (sizeModel.width.shrinkWrap) {
  1241. me.width = rendered ? me.getWidth() : me.width || me.minWidth || 100;
  1242. }
  1243. delete me.height;
  1244. me.minHeight = 0;
  1245. } else if (me.collapsedHorizontal()) {
  1246. if (sizeModel.height.shrinkWrap) {
  1247. me.height = rendered ? me.getHeight() : me.height || me.minHeight || 100;
  1248. }
  1249. delete me.width;
  1250. me.minWidth = 0;
  1251. }
  1252. if (me.ownerCt) {
  1253. me.ownerCt.getLayout().beginCollapse(me);
  1254. }
  1255. // Get a reExpander header. This will return the Panel Header if the Header is in the correct orientation
  1256. // If we are using the Header as the reExpander, change its UI to collapsed state
  1257. if (!me.isPlaceHolderCollapse()) {
  1258. if (me.header === (reExpander = me.getReExpander())) {
  1259. me.header.addClsWithUI(me.getHeaderCollapsedClasses(me.header));
  1260. // Ensure that the reExpander has the correct framing applied.
  1261. if (me.header.rendered) {
  1262. me.header.updateFrame();
  1263. }
  1264. }
  1265. // We're going to use a temporary reExpander: show it.
  1266. else {
  1267. if (reExpander.el) {
  1268. reExpander.el.show();
  1269. reExpander.hidden = false;
  1270. }
  1271. }
  1272. }
  1273. if (me.resizer) {
  1274. me.resizer.disable();
  1275. }
  1276. },
  1277. beginExpand: function() {
  1278. var me = this,
  1279. lastBox = me.lastBox,
  1280. collapseMemento = me.collapseMemento,
  1281. restoreDimension = this.restoreDimension(),
  1282. reExpander;
  1283. collapseMemento.restore(['minHeight', 'minWidth', restoreDimension]);
  1284. if (lastBox) {
  1285. collapseMemento.restore(restoreDimension, true, lastBox, 'last.');
  1286. }
  1287. if (me.ownerCt) {
  1288. me.ownerCt.getLayout().beginExpand(me);
  1289. }
  1290. if (!me.isPlaceHolderCollapse()) {
  1291. // If we have been using our Header as the reExpander then restore the Header to expanded UI
  1292. if (me.header === (reExpander = me.getReExpander())) {
  1293. me.header.removeClsWithUI(me.getHeaderCollapsedClasses(me.header));
  1294. // Ensure that the reExpander has the correct framing applied.
  1295. if (me.header.rendered) {
  1296. me.header.updateFrame();
  1297. }
  1298. }
  1299. // We've been using a temporary reExpander: hide it.
  1300. else {
  1301. reExpander.hidden = true;
  1302. reExpander.el.hide();
  1303. }
  1304. }
  1305. if (me.resizer) {
  1306. me.resizer.enable();
  1307. }
  1308. },
  1309. <span id='Ext-panel-Panel-method-collapse'> /**
  1310. </span> * Collapses the panel body so that the body becomes hidden. Docked Components parallel to the border towards which
  1311. * the collapse takes place will remain visible. Fires the {@link #beforecollapse} event which will cancel the
  1312. * collapse action if it returns false.
  1313. *
  1314. * @param {String} [direction] The direction to collapse towards. Must be one of
  1315. *
  1316. * - Ext.Component.DIRECTION_TOP
  1317. * - Ext.Component.DIRECTION_RIGHT
  1318. * - Ext.Component.DIRECTION_BOTTOM
  1319. * - Ext.Component.DIRECTION_LEFT
  1320. *
  1321. * Defaults to {@link #collapseDirection}.
  1322. *
  1323. * @param {Boolean} [animate] True to animate the transition, else false (defaults to the value of the
  1324. * {@link #animCollapse} panel config)
  1325. * @return {Ext.panel.Panel} this
  1326. */
  1327. collapse: function(direction, animate) {
  1328. var me = this,
  1329. collapseDir = direction || me.collapseDirection,
  1330. ownerCt = me.ownerCt;
  1331. if (me.isCollapsingOrExpanding) {
  1332. return me;
  1333. }
  1334. if (arguments.length &lt; 2) {
  1335. animate = me.animCollapse;
  1336. }
  1337. if (me.collapsed || me.fireEvent('beforecollapse', me, direction, animate) === false) {
  1338. return me;
  1339. }
  1340. if (ownerCt &amp;&amp; me.isPlaceHolderCollapse()) {
  1341. return me.placeholderCollapse(direction, animate);
  1342. }
  1343. me.collapsed = collapseDir;
  1344. me.beginCollapse();
  1345. me.fireHierarchyEvent('collapse');
  1346. return me.doCollapseExpand(1, animate);
  1347. },
  1348. doCollapseExpand: function (flags, animate) {
  1349. var me = this,
  1350. originalAnimCollapse = me.animCollapse,
  1351. ownerLayout = me.ownerLayout;
  1352. // we need to temporarily set animCollapse to the animate value here because ContextItem
  1353. // uses the animCollapse property to determine if the collapse/expand should be animated
  1354. me.animCollapse = animate;
  1355. // Flag used by the layouy ContextItem to impose an animation policy based upon the
  1356. // collapse direction and the animCollapse setting.
  1357. me.isCollapsingOrExpanding = flags;
  1358. if (ownerLayout &amp;&amp; !animate) {
  1359. ownerLayout.onContentChange(me);
  1360. } else {
  1361. me.updateLayout({ isRoot: true });
  1362. }
  1363. // set animCollapse back to its original value
  1364. me.animCollapse = originalAnimCollapse;
  1365. return me;
  1366. },
  1367. <span id='Ext-panel-Panel-method-afterCollapse'> /**
  1368. </span> * Invoked after the Panel is Collapsed.
  1369. *
  1370. * @param {Boolean} animated
  1371. *
  1372. * @template
  1373. * @protected
  1374. */
  1375. afterCollapse: function(animated) {
  1376. var me = this,
  1377. ownerLayout = me.ownerLayout;
  1378. me.isCollapsingOrExpanding = 0;
  1379. if (me.collapseTool) {
  1380. me.collapseTool.setType('expand-' + me.getOppositeDirection(me.collapseDirection));
  1381. }
  1382. if (ownerLayout &amp;&amp; animated) {
  1383. ownerLayout.onContentChange(me);
  1384. }
  1385. me.setHiddenDocked();
  1386. me.fireEvent('collapse', me);
  1387. },
  1388. setHiddenDocked: function(){
  1389. // Hide Panel content except reExpander using visibility to prevent focusing of contained elements.
  1390. // Track what we hide to re-show on expand
  1391. var me = this,
  1392. toHide = me.hiddenOnCollapse,
  1393. reExpander = me.getReExpander(),
  1394. items = me.getDockedItems(),
  1395. len = items.length,
  1396. i = 0,
  1397. item;
  1398. toHide.add(me.body);
  1399. for (; i &lt; len; i++) {
  1400. item = items[i];
  1401. if (item &amp;&amp; item !== reExpander &amp;&amp; item.el) {
  1402. toHide.add(item.el);
  1403. }
  1404. }
  1405. toHide.setStyle('visibility', 'hidden');
  1406. },
  1407. restoreHiddenDocked: function(){
  1408. var toShow = this.hiddenOnCollapse;
  1409. // Re-show Panel content which was hidden after collapse.
  1410. toShow.setStyle('visibility', '');
  1411. toShow.clear();
  1412. },
  1413. getPlaceholder: function(direction) {
  1414. var me = this,
  1415. collapseDir = direction || me.collapseDirection,
  1416. listeners = null,
  1417. placeholder = me.placeholder;
  1418. if (!placeholder) {
  1419. if (me.floatable || (me.collapsible &amp;&amp; me.titleCollapse)) {
  1420. listeners = {
  1421. click: {
  1422. fn: me.floatable ? me.floatCollapsedPanel : me.toggleCollapse,
  1423. element: 'el',
  1424. scope: me
  1425. }
  1426. };
  1427. }
  1428. me.placeholder = placeholder = Ext.widget(me.createReExpander(collapseDir, {
  1429. id: me.id + '-placeholder',
  1430. listeners: listeners
  1431. }));
  1432. }
  1433. // User created placeholder was passed in
  1434. if (!placeholder.placeholderFor) {
  1435. // Handle the case of a placeholder config
  1436. if (!placeholder.isComponent) {
  1437. me.placeholder = placeholder = me.lookupComponent(placeholder);
  1438. }
  1439. Ext.applyIf(placeholder, {
  1440. margins: me.margins,
  1441. placeholderFor: me
  1442. });
  1443. placeholder.addCls([Ext.baseCSSPrefix + 'region-collapsed-placeholder', Ext.baseCSSPrefix + 'region-collapsed-' + collapseDir + '-placeholder', me.collapsedCls]);
  1444. }
  1445. return placeholder;
  1446. },
  1447. placeholderCollapse: function(direction, animate) {
  1448. var me = this,
  1449. ownerCt = me.ownerCt,
  1450. collapseDir = direction || me.collapseDirection,
  1451. floatCls = Ext.baseCSSPrefix + 'border-region-slide-in',
  1452. placeholder = me.getPlaceholder(direction);
  1453. me.isCollapsingOrExpanding = 1;
  1454. // Upcoming layout run will ignore this Component
  1455. me.hidden = true;
  1456. me.collapsed = collapseDir;
  1457. if (placeholder.rendered) {
  1458. // We may have been added to another Container from that in which we rendered the placeholder
  1459. if (placeholder.el.dom.parentNode !== me.el.dom.parentNode) {
  1460. me.el.dom.parentNode.insertBefore(placeholder.el.dom, me.el.dom);
  1461. }
  1462. placeholder.hidden = false;
  1463. placeholder.el.show();
  1464. ownerCt.updateLayout();
  1465. } else {
  1466. ownerCt.insert(ownerCt.items.indexOf(me), placeholder);
  1467. }
  1468. if (me.rendered) {
  1469. // We MUST NOT hide using display because that resets all scroll information.
  1470. me.el.setVisibilityMode(me.placeholderCollapseHideMode);
  1471. if (animate) {
  1472. me.el.addCls(floatCls);
  1473. placeholder.el.hide();
  1474. me.el.slideOut(collapseDir.substr(0, 1), {
  1475. preserveScroll: true,
  1476. duration: Ext.Number.from(animate, Ext.fx.Anim.prototype.duration),
  1477. listeners: {
  1478. afteranimate: function() {
  1479. me.el.removeCls(floatCls);
  1480. /* We need to show the element so that slideIn will work correctly. However, if we leave it
  1481. visible then it can be seen before the animation starts, causing a flicker. The solution,
  1482. borrowed from date picker, is to hide it using display none. The slideIn effect includes
  1483. a call to fixDisplay() that will undo the display none at the appropriate time.
  1484. */
  1485. placeholder.el.show().setStyle('display', 'none').slideIn(collapseDir.substr(0, 1), {
  1486. easing: 'linear',
  1487. duration: 100,
  1488. listeners: {
  1489. afteranimate: function() {
  1490. placeholder.focus();
  1491. me.isCollapsingOrExpanding = 0;
  1492. me.fireEvent('collapse', me);
  1493. }
  1494. }
  1495. });
  1496. }
  1497. }
  1498. });
  1499. } else {
  1500. me.el.hide();
  1501. me.isCollapsingOrExpanding = 0;
  1502. me.fireEvent('collapse', me);
  1503. }
  1504. } else {
  1505. me.isCollapsingOrExpanding = 0;
  1506. me.fireEvent('collapse', me);
  1507. }
  1508. return me;
  1509. },
  1510. floatCollapsedPanel: function() {
  1511. var me = this,
  1512. placeholder = me.placeholder,
  1513. pb = placeholder.getBox(true),
  1514. myBox,
  1515. floatCls = Ext.baseCSSPrefix + 'border-region-slide-in',
  1516. collapsed = me.collapsed,
  1517. layoutOwner = me.ownerCt || me,
  1518. slideDirection;
  1519. // Already floated
  1520. if (me.el.hasCls(floatCls)) {
  1521. me.slideOutFloatedPanel();
  1522. return;
  1523. }
  1524. if (me.isSliding) {
  1525. return;
  1526. }
  1527. me.isSliding = true;
  1528. // Function to be called when the mouse leaves the floated Panel
  1529. // Slide out when the mouse leaves the region bounded by the slid Component and its placeholder.
  1530. function onMouseLeaveFloated(e) {
  1531. if (!me.isDestroyed) {
  1532. var slideRegion = me.el.getRegion().union(placeholder.el.getRegion()).adjust(1, -1, -1, 1);
  1533. // If mouse is not within slide Region, slide it out
  1534. if (!slideRegion.contains(e.getPoint())) {
  1535. me.slideOutFloatedPanel();
  1536. }
  1537. }
  1538. }
  1539. // Lay out in fully expanded mode to ensure we are at the correct size, and collect our expanded box
  1540. me.placeholder.el.hide();
  1541. me.placeholder.hidden = true;
  1542. me.el.show();
  1543. me.hidden = false;
  1544. me.collapsed = false;
  1545. layoutOwner.updateLayout();
  1546. myBox = me.getBox(true);
  1547. // Then go back immediately to collapsed state from which to initiate the float into view.
  1548. me.placeholder.el.show();
  1549. me.placeholder.hidden = false;
  1550. me.el.hide();
  1551. me.hidden = true;
  1552. me.collapsed = collapsed;
  1553. layoutOwner.updateLayout();
  1554. // Monitor for mouseouting of the placeholder. Hide it if they exit for half a second or more
  1555. me.placeholderMouseMon = placeholder.el.monitorMouseLeave(500, onMouseLeaveFloated);
  1556. me.panelMouseMon = me.el.monitorMouseLeave(500, onMouseLeaveFloated);
  1557. me.el.addCls(floatCls);
  1558. // Hide collapse tool in header if there is one (we might be headerless)
  1559. if (me.collapseTool) {
  1560. me.collapseTool.el.hide();
  1561. }
  1562. switch (me.collapsed) {
  1563. case 'top':
  1564. me.el.setLeftTop(pb.x, pb.y + pb.height - 1);
  1565. slideDirection = 't';
  1566. break;
  1567. case 'right':
  1568. me.el.setLeftTop(pb.x - myBox.width + 1, pb.y);
  1569. slideDirection = 'r';
  1570. break;
  1571. case 'bottom':
  1572. me.el.setLeftTop(pb.x, pb.y - myBox.height + 1);
  1573. slideDirection = 'b';
  1574. break;
  1575. case 'left':
  1576. me.el.setLeftTop(pb.x + pb.width - 1, pb.y);
  1577. slideDirection = 'l';
  1578. break;
  1579. }
  1580. // Remember how we are really collapsed so we can restore it, but also so we can
  1581. // become a layoutRoot while we are floated:
  1582. me.floatedFromCollapse = me.collapsed;
  1583. me.collapsed = me.hidden = false;
  1584. me.el.slideIn(slideDirection, {
  1585. preserveScroll: true,
  1586. listeners: {
  1587. afteranimate: function() {
  1588. me.isSliding = false;
  1589. }
  1590. }
  1591. });
  1592. },
  1593. isLayoutRoot: function() {
  1594. if (this.floatedFromCollapse) {
  1595. return true;
  1596. }
  1597. return this.callParent();
  1598. },
  1599. slideOutFloatedPanel: function() {
  1600. var me = this,
  1601. compEl = this.el,
  1602. collapseDirection;
  1603. if (me.isSliding) {
  1604. return;
  1605. }
  1606. me.isSliding = true;
  1607. me.slideOutFloatedPanelBegin();
  1608. if (typeof me.collapsed == 'string') {
  1609. collapseDirection = me.collapsed.charAt(0);
  1610. }
  1611. compEl.slideOut(collapseDirection, {
  1612. preserveScroll: true,
  1613. listeners: {
  1614. afteranimate: function() {
  1615. me.slideOutFloatedPanelEnd();
  1616. // this would be in slideOutFloatedPanelEnd except that the only other
  1617. // caller removes this cls later
  1618. me.el.removeCls(Ext.baseCSSPrefix + 'border-region-slide-in');
  1619. me.isSliding = false;
  1620. }
  1621. }
  1622. });
  1623. },
  1624. <span id='Ext-panel-Panel-method-slideOutFloatedPanelBegin'> /**
  1625. </span> * This method begins the slide out of the floated panel.
  1626. * @private
  1627. */
  1628. slideOutFloatedPanelBegin: function() {
  1629. var me = this,
  1630. compEl = this.el;
  1631. me.collapsed = me.floatedFromCollapse;
  1632. me.hidden = true;
  1633. me.floatedFromCollapse = null;
  1634. // Remove mouse leave monitors
  1635. compEl.un(me.panelMouseMon);
  1636. me.placeholder.el.un(me.placeholderMouseMon);
  1637. },
  1638. <span id='Ext-panel-Panel-method-slideOutFloatedPanelEnd'> /**
  1639. </span> * This method cleans up after the slide out of the floated panel.
  1640. * @private
  1641. */
  1642. slideOutFloatedPanelEnd: function() {
  1643. if (this.collapseTool) {
  1644. this.collapseTool.el.show();
  1645. }
  1646. },
  1647. <span id='Ext-panel-Panel-method-expand'> /**
  1648. </span> * Expands the panel body so that it becomes visible. Fires the {@link #beforeexpand} event which will
  1649. * cancel the expand action if it returns false.
  1650. * @param {Boolean} [animate] True to animate the transition, else false (defaults to the value of the
  1651. * {@link #animCollapse} panel config)
  1652. * @return {Ext.panel.Panel} this
  1653. */
  1654. expand: function(animate) {
  1655. var me = this;
  1656. if (me.isCollapsingOrExpanding) {
  1657. return me;
  1658. }
  1659. if (!arguments.length) {
  1660. animate = me.animCollapse;
  1661. }
  1662. if (!me.collapsed &amp;&amp; !me.floatedFromCollapse) {
  1663. return me;
  1664. }
  1665. if (me.fireEvent('beforeexpand', me, animate) === false) {
  1666. return me;
  1667. }
  1668. if (me.isPlaceHolderCollapse()) {
  1669. return me.placeholderExpand(animate);
  1670. }
  1671. me.restoreHiddenDocked();
  1672. me.beginExpand();
  1673. me.collapsed = false;
  1674. me.fireHierarchyEvent('expand');
  1675. return me.doCollapseExpand(2, animate);
  1676. },
  1677. placeholderExpand: function(animate) {
  1678. var me = this,
  1679. collapseDir = me.collapsed,
  1680. floatCls = Ext.baseCSSPrefix + 'border-region-slide-in',
  1681. finalPos,
  1682. floatedPos,
  1683. slideInDirection;
  1684. if (me.floatedFromCollapse) {
  1685. floatedPos = me.getPosition(true);
  1686. // these are the same cleanups performed by the normal slideOut mechanism:
  1687. me.slideOutFloatedPanelBegin();
  1688. me.slideOutFloatedPanelEnd();
  1689. }
  1690. me.isCollapsingOrExpanding = 2;
  1691. // Expand me and hide the placeholder
  1692. me.placeholder.hidden = true;
  1693. me.placeholder.el.hide();
  1694. me.collapsed = false;
  1695. me.show();
  1696. if (animate) {
  1697. // Floated, move it back to the floated pos, and thence into the correct place
  1698. if (floatedPos) {
  1699. finalPos = me.el.getXY();
  1700. me.el.setLeftTop(floatedPos[0], floatedPos[1]);
  1701. me.el.moveTo(finalPos[0], finalPos[1], {
  1702. duration: Ext.Number.from(animate, Ext.fx.Anim.prototype.duration),
  1703. listeners: {
  1704. afteranimate: function() {
  1705. me.el.removeCls(floatCls);
  1706. me.isCollapsingOrExpanding = 0;
  1707. me.fireEvent('expand', me);
  1708. }
  1709. }
  1710. });
  1711. }
  1712. // Not floated, slide it in to the correct place
  1713. else {
  1714. me.hidden = true;
  1715. me.el.addCls(floatCls);
  1716. me.el.hide();
  1717. me.collapsed = collapseDir;
  1718. me.placeholder.show();
  1719. slideInDirection = collapseDir.substr(0, 1);
  1720. // Slide this Component's el back into place, after which we lay out AGAIN
  1721. me.hidden = false;
  1722. me.el.slideIn(slideInDirection, {
  1723. preserveScroll: true,
  1724. duration: Ext.Number.from(animate, Ext.fx.Anim.prototype.duration),
  1725. listeners: {
  1726. afteranimate: function() {
  1727. me.collapsed = false;
  1728. // the ordering of these two lines appears to be important in
  1729. // IE9. There is an odd expand issue in IE 9 in the border layout
  1730. // example that causes the index1 child of the south dock region
  1731. // to get 'hidden' after a collapse / expand cycle. See
  1732. // EXTJSIV-5318 for details
  1733. me.el.removeCls(floatCls);
  1734. me.placeholder.hide();
  1735. me.isCollapsingOrExpanding = 0;
  1736. me.fireEvent('expand', me);
  1737. }
  1738. }
  1739. });
  1740. }
  1741. } else {
  1742. me.isCollapsingOrExpanding = 0;
  1743. me.fireEvent('expand', me);
  1744. }
  1745. return me;
  1746. },
  1747. <span id='Ext-panel-Panel-method-afterExpand'> /**
  1748. </span> * Invoked after the Panel is Expanded.
  1749. *
  1750. * @param {Boolean} animated
  1751. *
  1752. * @template
  1753. * @protected
  1754. */
  1755. afterExpand: function(animated) {
  1756. var me = this,
  1757. ownerLayout = me.ownerLayout;
  1758. me.isCollapsingOrExpanding = 0;
  1759. if (me.collapseTool) {
  1760. me.collapseTool.setType('collapse-' + me.collapseDirection);
  1761. }
  1762. if (ownerLayout &amp;&amp; animated) {
  1763. ownerLayout.onContentChange(me);
  1764. }
  1765. me.fireEvent('expand', me);
  1766. },
  1767. // inherit docs
  1768. setBorder: function(border, targetEl) {
  1769. if (targetEl) {
  1770. // skip out here, the panel will set the border on the body/header during rendering
  1771. return;
  1772. }
  1773. var me = this,
  1774. header = me.header;
  1775. if (!border) {
  1776. border = 0;
  1777. } else {
  1778. border = Ext.Element.unitizeBox((border === true) ? 1 : border);
  1779. }
  1780. if (header) {
  1781. if (header.isHeader) {
  1782. header.setBorder(border);
  1783. } else {
  1784. header.border = border;
  1785. }
  1786. }
  1787. if (me.rendered &amp;&amp; me.bodyBorder !== false) {
  1788. me.body.setStyle('border-width', border);
  1789. }
  1790. me.updateLayout();
  1791. me.border = border;
  1792. },
  1793. <span id='Ext-panel-Panel-method-toggleCollapse'> /**
  1794. </span> * Shortcut for performing an {@link #method-expand} or {@link #method-collapse} based on the current state of the panel.
  1795. * @return {Ext.panel.Panel} this
  1796. */
  1797. toggleCollapse: function() {
  1798. return (this.collapsed || this.floatedFromCollapse) ? this.expand() : this.collapse();
  1799. },
  1800. // private
  1801. getKeyMap : function() {
  1802. return this.keyMap || (this.keyMap = new Ext.util.KeyMap(Ext.apply({
  1803. target: this.el
  1804. }, this.keys)));
  1805. },
  1806. // private
  1807. initDraggable : function(){
  1808. <span id='Ext-panel-Panel-property-dd'> /**
  1809. </span> * @property {Ext.dd.DragSource} dd
  1810. * If this Panel is configured {@link #cfg-draggable}, this property will contain an instance of {@link
  1811. * Ext.dd.DragSource} which handles dragging the Panel.
  1812. *
  1813. * The developer must provide implementations of the abstract methods of {@link Ext.dd.DragSource} in order to
  1814. * supply behaviour for each stage of the drag/drop process. See {@link #cfg-draggable}.
  1815. */
  1816. this.dd = new Ext.panel.DD(this, Ext.isBoolean(this.draggable) ? null : this.draggable);
  1817. },
  1818. // private - helper function for ghost
  1819. ghostTools : function() {
  1820. var tools = [],
  1821. header = this.header,
  1822. headerTools = header ? header.query('tool[hidden=false]') : [],
  1823. t, tLen, tool;
  1824. if (headerTools.length) {
  1825. t = 0;
  1826. tLen = headerTools.length;
  1827. for (; t &lt; tLen; t++) {
  1828. tool = headerTools[t];
  1829. // Some tools can be full components, and copying them into the ghost
  1830. // actually removes them from the owning panel. You could also potentially
  1831. // end up with duplicate DOM ids as well. To avoid any issues we just make
  1832. // a simple bare-minimum clone of each tool for ghosting purposes.
  1833. tools.push({
  1834. type: tool.type
  1835. });
  1836. }
  1837. } else {
  1838. tools = [{
  1839. type: 'placeholder'
  1840. }];
  1841. }
  1842. return tools;
  1843. },
  1844. // private - used for dragging
  1845. ghost: function(cls) {
  1846. var me = this,
  1847. ghostPanel = me.ghostPanel,
  1848. box = me.getBox(),
  1849. header;
  1850. if (!ghostPanel) {
  1851. ghostPanel = new Ext.panel.Panel({
  1852. renderTo: document.body,
  1853. floating: {
  1854. shadow: false
  1855. },
  1856. frame: me.frame &amp;&amp; !me.alwaysFramed,
  1857. alwaysFramed: me.alwaysFramed,
  1858. overlapHeader: me.overlapHeader,
  1859. headerPosition: me.headerPosition,
  1860. baseCls: me.baseCls,
  1861. cls: me.baseCls + '-ghost ' + (cls ||'')
  1862. });
  1863. me.ghostPanel = ghostPanel;
  1864. } else {
  1865. ghostPanel.el.show();
  1866. }
  1867. ghostPanel.floatParent = me.floatParent;
  1868. if (me.floating) {
  1869. ghostPanel.setZIndex(Ext.Number.from(me.el.getStyle('zIndex'), 0));
  1870. } else {
  1871. ghostPanel.toFront();
  1872. }
  1873. if (!(me.preventHeader || (me.header === false))) {
  1874. header = ghostPanel.header;
  1875. // restore options
  1876. if (header) {
  1877. header.suspendLayouts();
  1878. Ext.Array.forEach(header.query('tool'), header.remove, header);
  1879. header.resumeLayouts();
  1880. }
  1881. ghostPanel.addTool(me.ghostTools());
  1882. ghostPanel.setTitle(me.title);
  1883. ghostPanel.setIconCls(me.iconCls);
  1884. }
  1885. ghostPanel.setPagePosition(box.x, box.y);
  1886. ghostPanel.setSize(box.width, box.height);
  1887. me.el.hide();
  1888. return ghostPanel;
  1889. },
  1890. // private
  1891. unghost: function(show, matchPosition) {
  1892. var me = this;
  1893. if (!me.ghostPanel) {
  1894. return;
  1895. }
  1896. if (show !== false) {
  1897. // Show el first, so that position adjustment in setPagePosition
  1898. // will work when relative positioned elements have their XY read.
  1899. me.el.show();
  1900. if (matchPosition !== false) {
  1901. me.setPagePosition(me.ghostPanel.el.getXY());
  1902. if (me.hideMode == 'offsets') {
  1903. // clear the hidden style because we just repositioned
  1904. delete me.el.hideModeStyles;
  1905. }
  1906. }
  1907. Ext.defer(me.focus, 10, me);
  1908. }
  1909. me.ghostPanel.el.hide();
  1910. },
  1911. beginDrag: function() {
  1912. if (this.floatingDescendants) {
  1913. this.floatingDescendants.hide();
  1914. }
  1915. },
  1916. endDrag: function() {
  1917. if (this.floatingDescendants) {
  1918. this.floatingDescendants.show();
  1919. }
  1920. },
  1921. initResizable: function(resizable) {
  1922. if (this.collapsed) {
  1923. resizable.disabled = true;
  1924. }
  1925. this.callParent([resizable]);
  1926. }
  1927. }, function() {
  1928. this.prototype.animCollapse = Ext.enableFx;
  1929. });
  1930. </pre>
  1931. </body>
  1932. </html>