AbstractComponent.html 132 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480
  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-AbstractComponent'>/**
  19. </span> * An abstract base class which provides shared methods for Components across the Sencha product line.
  20. *
  21. * Please refer to sub class's documentation
  22. * @private
  23. */
  24. Ext.define('Ext.AbstractComponent', {
  25. /* Begin Definitions */
  26. requires: [
  27. 'Ext.ComponentQuery',
  28. 'Ext.ComponentManager',
  29. 'Ext.util.ProtoElement'
  30. ],
  31. mixins: {
  32. observable: 'Ext.util.Observable',
  33. animate: 'Ext.util.Animate',
  34. elementCt: 'Ext.util.ElementContainer',
  35. renderable: 'Ext.util.Renderable',
  36. state: 'Ext.state.Stateful'
  37. },
  38. // The &quot;uses&quot; property specifies class which are used in an instantiated AbstractComponent.
  39. // They do *not* have to be loaded before this class may be defined - that is what &quot;requires&quot; is for.
  40. uses: [
  41. 'Ext.PluginManager',
  42. 'Ext.Element',
  43. 'Ext.DomHelper',
  44. 'Ext.XTemplate',
  45. 'Ext.ComponentQuery',
  46. 'Ext.ComponentLoader',
  47. 'Ext.EventManager',
  48. 'Ext.layout.Context',
  49. 'Ext.layout.Layout',
  50. 'Ext.layout.component.Auto',
  51. 'Ext.LoadMask',
  52. 'Ext.ZIndexManager'
  53. ],
  54. statics: {
  55. AUTO_ID: 1000,
  56. pendingLayouts: null,
  57. layoutSuspendCount: 0,
  58. <span id='Ext-AbstractComponent-method-cancelLayout'> /**
  59. </span> * Cancels layout of a component.
  60. * @param {Ext.Component} comp
  61. */
  62. cancelLayout: function(comp, isDestroying) {
  63. var context = this.runningLayoutContext || this.pendingLayouts;
  64. if (context) {
  65. context.cancelComponent(comp, false, isDestroying);
  66. }
  67. },
  68. <span id='Ext-AbstractComponent-static-method-flushLayouts'> /**
  69. </span> * Performs all pending layouts that were sceduled while
  70. * {@link Ext.AbstractComponent#suspendLayouts suspendLayouts} was in effect.
  71. * @static
  72. */
  73. flushLayouts: function () {
  74. var me = this,
  75. context = me.pendingLayouts;
  76. if (context &amp;&amp; context.invalidQueue.length) {
  77. me.pendingLayouts = null;
  78. me.runningLayoutContext = context;
  79. Ext.override(context, {
  80. runComplete: function () {
  81. // we need to release the layout queue before running any of the
  82. // finishedLayout calls because they call afterComponentLayout
  83. // which can re-enter by calling doLayout/doComponentLayout.
  84. me.runningLayoutContext = null;
  85. return this.callParent(); // not &quot;me&quot; here!
  86. }
  87. });
  88. context.run();
  89. }
  90. },
  91. <span id='Ext-AbstractComponent-static-method-resumeLayouts'> /**
  92. </span> * Resumes layout activity in the whole framework.
  93. *
  94. * {@link Ext#suspendLayouts} is alias of {@link Ext.AbstractComponent#suspendLayouts}.
  95. *
  96. * @param {Boolean} [flush=false] True to perform all the pending layouts. This can also be
  97. * achieved by calling {@link Ext.AbstractComponent#flushLayouts flushLayouts} directly.
  98. * @static
  99. */
  100. resumeLayouts: function (flush) {
  101. if (this.layoutSuspendCount &amp;&amp; ! --this.layoutSuspendCount) {
  102. if (flush) {
  103. this.flushLayouts();
  104. }
  105. }
  106. },
  107. <span id='Ext-AbstractComponent-static-method-suspendLayouts'> /**
  108. </span> * Stops layouts from happening in the whole framework.
  109. *
  110. * It's useful to suspend the layout activity while updating multiple components and
  111. * containers:
  112. *
  113. * Ext.suspendLayouts();
  114. * // batch of updates...
  115. * Ext.resumeLayouts(true);
  116. *
  117. * {@link Ext#suspendLayouts} is alias of {@link Ext.AbstractComponent#suspendLayouts}.
  118. *
  119. * See also {@link Ext#batchLayouts} for more abstract way of doing this.
  120. *
  121. * @static
  122. */
  123. suspendLayouts: function () {
  124. ++this.layoutSuspendCount;
  125. },
  126. <span id='Ext-AbstractComponent-static-method-updateLayout'> /**
  127. </span> * Updates layout of a component.
  128. *
  129. * @param {Ext.Component} comp The component to update.
  130. * @param {Boolean} [defer=false] True to just queue the layout if this component.
  131. * @static
  132. */
  133. updateLayout: function (comp, defer) {
  134. var me = this,
  135. running = me.runningLayoutContext,
  136. pending;
  137. if (running) {
  138. running.queueInvalidate(comp);
  139. } else {
  140. pending = me.pendingLayouts || (me.pendingLayouts = new Ext.layout.Context());
  141. pending.queueInvalidate(comp);
  142. if (!defer &amp;&amp; !me.layoutSuspendCount &amp;&amp; !comp.isLayoutSuspended()) {
  143. me.flushLayouts();
  144. }
  145. }
  146. }
  147. },
  148. /* End Definitions */
  149. <span id='Ext-AbstractComponent-property-isComponent'> /**
  150. </span> * @property {Boolean} isComponent
  151. * `true` in this class to identify an object as an instantiated Component, or subclass thereof.
  152. */
  153. isComponent: true,
  154. <span id='Ext-AbstractComponent-method-getAutoId'> /**
  155. </span> * @private
  156. */
  157. getAutoId: function() {
  158. this.autoGenId = true;
  159. return ++Ext.AbstractComponent.AUTO_ID;
  160. },
  161. deferLayouts: false,
  162. <span id='Ext-AbstractComponent-cfg-id'> /**
  163. </span> * @cfg {String} id
  164. * The **unique id of this component instance.**
  165. *
  166. * It should not be necessary to use this configuration except for singleton objects in your application. Components
  167. * created with an id may be accessed globally using {@link Ext#getCmp Ext.getCmp}.
  168. *
  169. * Instead of using assigned ids, use the {@link #itemId} config, and {@link Ext.ComponentQuery ComponentQuery}
  170. * which provides selector-based searching for Sencha Components analogous to DOM querying. The {@link
  171. * Ext.container.Container Container} class contains {@link Ext.container.Container#down shortcut methods} to query
  172. * its descendant Components by selector.
  173. *
  174. * Note that this id will also be used as the element id for the containing HTML element that is rendered to the
  175. * page for this component. This allows you to write id-based CSS rules to style the specific instance of this
  176. * component uniquely, and also to select sub-elements using this component's id as the parent.
  177. *
  178. * **Note**: to avoid complications imposed by a unique id also see `{@link #itemId}`.
  179. *
  180. * **Note**: to access the container of a Component see `{@link #ownerCt}`.
  181. *
  182. * Defaults to an {@link #getId auto-assigned id}.
  183. */
  184. <span id='Ext-AbstractComponent-property-autoGenId'> /**
  185. </span> * @property {Boolean} autoGenId
  186. * `true` indicates an id was auto-generated rather than provided by configuration.
  187. * @private
  188. */
  189. autoGenId: false,
  190. <span id='Ext-AbstractComponent-cfg-itemId'> /**
  191. </span> * @cfg {String} itemId
  192. * An itemId can be used as an alternative way to get a reference to a component when no object reference is
  193. * available. Instead of using an `{@link #id}` with {@link Ext}.{@link Ext#getCmp getCmp}, use `itemId` with
  194. * {@link Ext.container.Container}.{@link Ext.container.Container#getComponent getComponent} which will retrieve
  195. * `itemId`'s or {@link #id}'s. Since `itemId`'s are an index to the container's internal MixedCollection, the
  196. * `itemId` is scoped locally to the container -- avoiding potential conflicts with {@link Ext.ComponentManager}
  197. * which requires a **unique** `{@link #id}`.
  198. *
  199. * var c = new Ext.panel.Panel({ //
  200. * {@link Ext.Component#height height}: 300,
  201. * {@link #renderTo}: document.body,
  202. * {@link Ext.container.Container#layout layout}: 'auto',
  203. * {@link Ext.container.Container#cfg-items items}: [
  204. * {
  205. * itemId: 'p1',
  206. * {@link Ext.panel.Panel#title title}: 'Panel 1',
  207. * {@link Ext.Component#height height}: 150
  208. * },
  209. * {
  210. * itemId: 'p2',
  211. * {@link Ext.panel.Panel#title title}: 'Panel 2',
  212. * {@link Ext.Component#height height}: 150
  213. * }
  214. * ]
  215. * })
  216. * p1 = c.{@link Ext.container.Container#getComponent getComponent}('p1'); // not the same as {@link Ext#getCmp Ext.getCmp()}
  217. * p2 = p1.{@link #ownerCt}.{@link Ext.container.Container#getComponent getComponent}('p2'); // reference via a sibling
  218. *
  219. * Also see {@link #id}, `{@link Ext.container.Container#query}`, `{@link Ext.container.Container#down}` and
  220. * `{@link Ext.container.Container#child}`.
  221. *
  222. * **Note**: to access the container of an item see {@link #ownerCt}.
  223. */
  224. <span id='Ext-AbstractComponent-property-ownerCt'> /**
  225. </span> * @property {Ext.Container} ownerCt
  226. * This Component's owner {@link Ext.container.Container Container} (is set automatically
  227. * when this Component is added to a Container).
  228. *
  229. * **Note**: to access items within the Container see {@link #itemId}.
  230. * @readonly
  231. */
  232. <span id='Ext-AbstractComponent-cfg-autoEl'> /**
  233. </span> * @cfg {String/Object} autoEl
  234. * A tag name or {@link Ext.DomHelper DomHelper} spec used to create the {@link #getEl Element} which will
  235. * encapsulate this Component.
  236. *
  237. * You do not normally need to specify this. For the base classes {@link Ext.Component} and
  238. * {@link Ext.container.Container}, this defaults to **'div'**. The more complex Sencha classes use a more
  239. * complex DOM structure specified by their own {@link #renderTpl}s.
  240. *
  241. * This is intended to allow the developer to create application-specific utility Components encapsulated by
  242. * different DOM elements. Example usage:
  243. *
  244. * {
  245. * xtype: 'component',
  246. * autoEl: {
  247. * tag: 'img',
  248. * src: 'http://www.example.com/example.jpg'
  249. * }
  250. * }, {
  251. * xtype: 'component',
  252. * autoEl: {
  253. * tag: 'blockquote',
  254. * html: 'autoEl is cool!'
  255. * }
  256. * }, {
  257. * xtype: 'container',
  258. * autoEl: 'ul',
  259. * cls: 'ux-unordered-list',
  260. * items: {
  261. * xtype: 'component',
  262. * autoEl: 'li',
  263. * html: 'First list item'
  264. * }
  265. * }
  266. */
  267. <span id='Ext-AbstractComponent-cfg-renderTpl'> /**
  268. </span> * @cfg {Ext.XTemplate/String/String[]} renderTpl
  269. * An {@link Ext.XTemplate XTemplate} used to create the internal structure inside this Component's encapsulating
  270. * {@link #getEl Element}.
  271. *
  272. * You do not normally need to specify this. For the base classes {@link Ext.Component} and
  273. * {@link Ext.container.Container}, this defaults to **`null`** which means that they will be initially rendered
  274. * with no internal structure; they render their {@link #getEl Element} empty. The more specialized ExtJS and Touch
  275. * classes which use a more complex DOM structure, provide their own template definitions.
  276. *
  277. * This is intended to allow the developer to create application-specific utility Components with customized
  278. * internal structure.
  279. *
  280. * Upon rendering, any created child elements may be automatically imported into object properties using the
  281. * {@link #renderSelectors} and {@link #cfg-childEls} options.
  282. * @protected
  283. */
  284. renderTpl: '{%this.renderContent(out,values)%}',
  285. <span id='Ext-AbstractComponent-cfg-renderData'> /**
  286. </span> * @cfg {Object} renderData
  287. *
  288. * The data used by {@link #renderTpl} in addition to the following property values of the component:
  289. *
  290. * - id
  291. * - ui
  292. * - uiCls
  293. * - baseCls
  294. * - componentCls
  295. * - frame
  296. *
  297. * See {@link #renderSelectors} and {@link #cfg-childEls} for usage examples.
  298. */
  299. <span id='Ext-AbstractComponent-cfg-renderSelectors'> /**
  300. </span> * @cfg {Object} renderSelectors
  301. * An object containing properties specifying {@link Ext.DomQuery DomQuery} selectors which identify child elements
  302. * created by the render process.
  303. *
  304. * After the Component's internal structure is rendered according to the {@link #renderTpl}, this object is iterated through,
  305. * and the found Elements are added as properties to the Component using the `renderSelector` property name.
  306. *
  307. * For example, a Component which renderes a title and description into its element:
  308. *
  309. * Ext.create('Ext.Component', {
  310. * renderTo: Ext.getBody(),
  311. * renderTpl: [
  312. * '&lt;h1 class=&quot;title&quot;&gt;{title}&lt;/h1&gt;',
  313. * '&lt;p&gt;{desc}&lt;/p&gt;'
  314. * ],
  315. * renderData: {
  316. * title: &quot;Error&quot;,
  317. * desc: &quot;Something went wrong&quot;
  318. * },
  319. * renderSelectors: {
  320. * titleEl: 'h1.title',
  321. * descEl: 'p'
  322. * },
  323. * listeners: {
  324. * afterrender: function(cmp){
  325. * // After rendering the component will have a titleEl and descEl properties
  326. * cmp.titleEl.setStyle({color: &quot;red&quot;});
  327. * }
  328. * }
  329. * });
  330. *
  331. * For a faster, but less flexible, alternative that achieves the same end result (properties for child elements on the
  332. * Component after render), see {@link #cfg-childEls} and {@link #addChildEls}.
  333. */
  334. <span id='Ext-AbstractComponent-cfg-childEls'> /**
  335. </span> * @cfg {Object[]} childEls
  336. * An array describing the child elements of the Component. Each member of the array
  337. * is an object with these properties:
  338. *
  339. * - `name` - The property name on the Component for the child element.
  340. * - `itemId` - The id to combine with the Component's id that is the id of the child element.
  341. * - `id` - The id of the child element.
  342. *
  343. * If the array member is a string, it is equivalent to `{ name: m, itemId: m }`.
  344. *
  345. * For example, a Component which renders a title and body text:
  346. *
  347. * Ext.create('Ext.Component', {
  348. * renderTo: Ext.getBody(),
  349. * renderTpl: [
  350. * '&lt;h1 id=&quot;{id}-title&quot;&gt;{title}&lt;/h1&gt;',
  351. * '&lt;p&gt;{msg}&lt;/p&gt;',
  352. * ],
  353. * renderData: {
  354. * title: &quot;Error&quot;,
  355. * msg: &quot;Something went wrong&quot;
  356. * },
  357. * childEls: [&quot;title&quot;],
  358. * listeners: {
  359. * afterrender: function(cmp){
  360. * // After rendering the component will have a title property
  361. * cmp.title.setStyle({color: &quot;red&quot;});
  362. * }
  363. * }
  364. * });
  365. *
  366. * A more flexible, but somewhat slower, approach is {@link #renderSelectors}.
  367. */
  368. <span id='Ext-AbstractComponent-cfg-renderTo'> /**
  369. </span> * @cfg {String/HTMLElement/Ext.Element} renderTo
  370. * Specify the id of the element, a DOM element or an existing Element that this component will be rendered into.
  371. *
  372. * **Notes:**
  373. *
  374. * Do *not* use this option if the Component is to be a child item of a {@link Ext.container.Container Container}.
  375. * It is the responsibility of the {@link Ext.container.Container Container}'s
  376. * {@link Ext.container.Container#layout layout manager} to render and manage its child items.
  377. *
  378. * When using this config, a call to render() is not required.
  379. *
  380. * See also: {@link #method-render}.
  381. */
  382. <span id='Ext-AbstractComponent-cfg-frame'> /**
  383. </span> * @cfg {Boolean} frame
  384. * Specify as `true` to have the Component inject framing elements within the Component at render time to provide a
  385. * graphical rounded frame around the Component content.
  386. *
  387. * This is only necessary when running on outdated, or non standard-compliant browsers such as Microsoft's Internet
  388. * Explorer prior to version 9 which do not support rounded corners natively.
  389. *
  390. * The extra space taken up by this framing is available from the read only property {@link #frameSize}.
  391. */
  392. <span id='Ext-AbstractComponent-property-frameSize'> /**
  393. </span> * @property {Object} frameSize
  394. * @readonly
  395. * Indicates the width of any framing elements which were added within the encapsulating element
  396. * to provide graphical, rounded borders. See the {@link #frame} config.
  397. *
  398. * This is an object containing the frame width in pixels for all four sides of the Component containing the
  399. * following properties:
  400. *
  401. * @property {Number} [frameSize.top=0] The width of the top framing element in pixels.
  402. * @property {Number} [frameSize.right=0] The width of the right framing element in pixels.
  403. * @property {Number} [frameSize.bottom=0] The width of the bottom framing element in pixels.
  404. * @property {Number} [frameSize.left=0] The width of the left framing element in pixels.
  405. * @property {Number} [frameSize.width=0] The total width of the left and right framing elements in pixels.
  406. * @property {Number} [frameSize.height=0] The total height of the top and right bottom elements in pixels.
  407. */
  408. frameSize: { left: 0, top: 0, right: 0, bottom: 0, width: 0, height: 0 },
  409. <span id='Ext-AbstractComponent-cfg-componentLayout'> /**
  410. </span> * @cfg {String/Object} componentLayout
  411. * The sizing and positioning of a Component's internal Elements is the responsibility of the Component's layout
  412. * manager which sizes a Component's internal structure in response to the Component being sized.
  413. *
  414. * Generally, developers will not use this configuration as all provided Components which need their internal
  415. * elements sizing (Such as {@link Ext.form.field.Base input fields}) come with their own componentLayout managers.
  416. *
  417. * The {@link Ext.layout.container.Auto default layout manager} will be used on instances of the base Ext.Component
  418. * class which simply sizes the Component's encapsulating element to the height and width specified in the
  419. * {@link #setSize} method.
  420. */
  421. <span id='Ext-AbstractComponent-cfg-tpl'> /**
  422. </span> * @cfg {Ext.XTemplate/Ext.Template/String/String[]} tpl
  423. * An {@link Ext.Template}, {@link Ext.XTemplate} or an array of strings to form an Ext.XTemplate. Used in
  424. * conjunction with the `{@link #data}` and `{@link #tplWriteMode}` configurations.
  425. */
  426. <span id='Ext-AbstractComponent-cfg-data'> /**
  427. </span> * @cfg {Object} data
  428. * The initial set of data to apply to the `{@link #tpl}` to update the content area of the Component.
  429. */
  430. <span id='Ext-AbstractComponent-cfg-xtype'> /**
  431. </span> * @cfg {String} xtype
  432. * This property provides a shorter alternative to creating objects than using a full
  433. * class name. Using `xtype` is the most common way to define component instances,
  434. * especially in a container. For example, the items in a form containing text fields
  435. * could be created explicitly like so:
  436. *
  437. * items: [
  438. * Ext.create('Ext.form.field.Text', {
  439. * fieldLabel: 'Foo'
  440. * }),
  441. * Ext.create('Ext.form.field.Text', {
  442. * fieldLabel: 'Bar'
  443. * }),
  444. * Ext.create('Ext.form.field.Number', {
  445. * fieldLabel: 'Num'
  446. * })
  447. * ]
  448. *
  449. * But by using `xtype`, the above becomes:
  450. *
  451. * items: [
  452. * {
  453. * xtype: 'textfield',
  454. * fieldLabel: 'Foo'
  455. * },
  456. * {
  457. * xtype: 'textfield',
  458. * fieldLabel: 'Bar'
  459. * },
  460. * {
  461. * xtype: 'numberfield',
  462. * fieldLabel: 'Num'
  463. * }
  464. * ]
  465. *
  466. * When the `xtype` is common to many items, {@link Ext.container.AbstractContainer#defaultType}
  467. * is another way to specify the `xtype` for all items that don't have an explicit `xtype`:
  468. *
  469. * defaultType: 'textfield',
  470. * items: [
  471. * { fieldLabel: 'Foo' },
  472. * { fieldLabel: 'Bar' },
  473. * { fieldLabel: 'Num', xtype: 'numberfield' }
  474. * ]
  475. *
  476. * Each member of the `items` array is now just a &quot;configuration object&quot;. These objects
  477. * are used to create and configure component instances. A configuration object can be
  478. * manually used to instantiate a component using {@link Ext#widget}:
  479. *
  480. * var text1 = Ext.create('Ext.form.field.Text', {
  481. * fieldLabel: 'Foo'
  482. * });
  483. *
  484. * // or alternatively:
  485. *
  486. * var text1 = Ext.widget({
  487. * xtype: 'textfield',
  488. * fieldLabel: 'Foo'
  489. * });
  490. *
  491. * This conversion of configuration objects into instantiated components is done when
  492. * a container is created as part of its {Ext.container.AbstractContainer#initComponent}
  493. * process. As part of the same process, the `items` array is converted from its raw
  494. * array form into a {@link Ext.util.MixedCollection} instance.
  495. *
  496. * You can define your own `xtype` on a custom {@link Ext.Component component} by specifying
  497. * the `xtype` property in {@link Ext#define}. For example:
  498. *
  499. * Ext.define('MyApp.PressMeButton', {
  500. * extend: 'Ext.button.Button',
  501. * xtype: 'pressmebutton',
  502. * text: 'Press Me'
  503. * });
  504. *
  505. * Care should be taken when naming an `xtype` in a custom component because there is
  506. * a single, shared scope for all xtypes. Third part components should consider using
  507. * a prefix to avoid collisions.
  508. *
  509. * Ext.define('Foo.form.CoolButton', {
  510. * extend: 'Ext.button.Button',
  511. * xtype: 'ux-coolbutton',
  512. * text: 'Cool!'
  513. * });
  514. */
  515. <span id='Ext-AbstractComponent-cfg-tplWriteMode'> /**
  516. </span> * @cfg {String} tplWriteMode
  517. * The Ext.(X)Template method to use when updating the content area of the Component.
  518. * See `{@link Ext.XTemplate#overwrite}` for information on default mode.
  519. */
  520. tplWriteMode: 'overwrite',
  521. <span id='Ext-AbstractComponent-cfg-baseCls'> /**
  522. </span> * @cfg {String} [baseCls='x-component']
  523. * The base CSS class to apply to this components's element. This will also be prepended to elements within this
  524. * component like Panel's body will get a class x-panel-body. This means that if you create a subclass of Panel, and
  525. * you want it to get all the Panels styling for the element and the body, you leave the baseCls x-panel and use
  526. * componentCls to add specific styling for this component.
  527. */
  528. baseCls: Ext.baseCSSPrefix + 'component',
  529. <span id='Ext-AbstractComponent-cfg-componentCls'> /**
  530. </span> * @cfg {String} componentCls
  531. * CSS Class to be added to a components root level element to give distinction to it via styling.
  532. */
  533. <span id='Ext-AbstractComponent-cfg-cls'> /**
  534. </span> * @cfg {String} [cls='']
  535. * An optional extra CSS class that will be added to this component's Element. This can be useful
  536. * for adding customized styles to the component or any of its children using standard CSS rules.
  537. */
  538. <span id='Ext-AbstractComponent-cfg-overCls'> /**
  539. </span> * @cfg {String} [overCls='']
  540. * An optional extra CSS class that will be added to this component's Element when the mouse moves over the Element,
  541. * and removed when the mouse moves out. This can be useful for adding customized 'active' or 'hover' styles to the
  542. * component or any of its children using standard CSS rules.
  543. */
  544. <span id='Ext-AbstractComponent-cfg-disabledCls'> /**
  545. </span> * @cfg {String} [disabledCls='x-item-disabled']
  546. * CSS class to add when the Component is disabled. Defaults to 'x-item-disabled'.
  547. */
  548. disabledCls: Ext.baseCSSPrefix + 'item-disabled',
  549. <span id='Ext-AbstractComponent-cfg-ui'> /**
  550. </span> * @cfg {String} ui
  551. * A UI style for a component.
  552. */
  553. ui: 'default',
  554. <span id='Ext-AbstractComponent-cfg-uiCls'> /**
  555. </span> * @cfg {String[]} uiCls
  556. * An array of of classNames which are currently applied to this component
  557. * @private
  558. */
  559. uiCls: [],
  560. <span id='Ext-AbstractComponent-cfg-style'> /**
  561. </span> * @cfg {String/Object} style
  562. * A custom style specification to be applied to this component's Element. Should be a valid argument to
  563. * {@link Ext.Element#applyStyles}.
  564. *
  565. * new Ext.panel.Panel({
  566. * title: 'Some Title',
  567. * renderTo: Ext.getBody(),
  568. * width: 400, height: 300,
  569. * layout: 'form',
  570. * items: [{
  571. * xtype: 'textarea',
  572. * style: {
  573. * width: '95%',
  574. * marginBottom: '10px'
  575. * }
  576. * },
  577. * new Ext.button.Button({
  578. * text: 'Send',
  579. * minWidth: '100',
  580. * style: {
  581. * marginBottom: '10px'
  582. * }
  583. * })
  584. * ]
  585. * });
  586. */
  587. <span id='Ext-AbstractComponent-cfg-width'> /**
  588. </span> * @cfg {Number} width
  589. * The width of this component in pixels.
  590. */
  591. <span id='Ext-AbstractComponent-cfg-height'> /**
  592. </span> * @cfg {Number} height
  593. * The height of this component in pixels.
  594. */
  595. <span id='Ext-AbstractComponent-cfg-border'> /**
  596. </span> * @cfg {Number/String/Boolean} border
  597. * Specifies the border size for this component. The border can be a single numeric value to apply to all sides or it can
  598. * be a CSS style specification for each style, for example: '10 5 3 10'.
  599. *
  600. * For components that have no border by default, setting this won't make the border appear by itself.
  601. * You also need to specify border color and style:
  602. *
  603. * border: 5,
  604. * style: {
  605. * borderColor: 'red',
  606. * borderStyle: 'solid'
  607. * }
  608. *
  609. * To turn off the border, use `border: false`.
  610. */
  611. <span id='Ext-AbstractComponent-cfg-padding'> /**
  612. </span> * @cfg {Number/String} padding
  613. * Specifies the padding for this component. The padding can be a single numeric value to apply to all sides or it
  614. * can be a CSS style specification for each style, for example: '10 5 3 10'.
  615. */
  616. <span id='Ext-AbstractComponent-cfg-margin'> /**
  617. </span> * @cfg {Number/String} margin
  618. * Specifies the margin for this component. The margin can be a single numeric value to apply to all sides or it can
  619. * be a CSS style specification for each style, for example: '10 5 3 10'.
  620. */
  621. <span id='Ext-AbstractComponent-cfg-hidden'> /**
  622. </span> * @cfg {Boolean} hidden
  623. * True to hide the component.
  624. */
  625. hidden: false,
  626. <span id='Ext-AbstractComponent-cfg-disabled'> /**
  627. </span> * @cfg {Boolean} disabled
  628. * True to disable the component.
  629. */
  630. disabled: false,
  631. <span id='Ext-AbstractComponent-cfg-draggable'> /**
  632. </span> * @cfg {Boolean} [draggable=false]
  633. * Allows the component to be dragged.
  634. */
  635. <span id='Ext-AbstractComponent-property-draggable'> /**
  636. </span> * @property {Boolean} draggable
  637. * Indicates whether or not the component can be dragged.
  638. * @readonly
  639. */
  640. draggable: false,
  641. <span id='Ext-AbstractComponent-cfg-floating'> /**
  642. </span> * @cfg {Boolean} floating
  643. * Create the Component as a floating and use absolute positioning.
  644. *
  645. * The z-index of floating Components is handled by a ZIndexManager. If you simply render a floating Component into the DOM, it will be managed
  646. * by the global {@link Ext.WindowManager WindowManager}.
  647. *
  648. * If you include a floating Component as a child item of a Container, then upon render, ExtJS will seek an ancestor floating Component to house a new
  649. * ZIndexManager instance to manage its descendant floaters. If no floating ancestor can be found, the global WindowManager will be used.
  650. *
  651. * When a floating Component which has a ZindexManager managing descendant floaters is destroyed, those descendant floaters will also be destroyed.
  652. */
  653. floating: false,
  654. <span id='Ext-AbstractComponent-cfg-hideMode'> /**
  655. </span> * @cfg {String} hideMode
  656. * A String which specifies how this Component's encapsulating DOM element will be hidden. Values may be:
  657. *
  658. * - `'display'` : The Component will be hidden using the `display: none` style.
  659. * - `'visibility'` : The Component will be hidden using the `visibility: hidden` style.
  660. * - `'offsets'` : The Component will be hidden by absolutely positioning it out of the visible area of the document.
  661. * This is useful when a hidden Component must maintain measurable dimensions. Hiding using `display` results in a
  662. * Component having zero dimensions.
  663. */
  664. hideMode: 'display',
  665. <span id='Ext-AbstractComponent-cfg-contentEl'> /**
  666. </span> * @cfg {String} contentEl
  667. * Specify an existing HTML element, or the `id` of an existing HTML element to use as the content for this component.
  668. *
  669. * This config option is used to take an existing HTML element and place it in the layout element of a new component
  670. * (it simply moves the specified DOM element _after the Component is rendered_ to use as the content.
  671. *
  672. * **Notes:**
  673. *
  674. * The specified HTML element is appended to the layout element of the component _after any configured
  675. * {@link #html HTML} has been inserted_, and so the document will not contain this element at the time
  676. * the {@link #event-render} event is fired.
  677. *
  678. * The specified HTML element used will not participate in any **`{@link Ext.container.Container#layout layout}`**
  679. * scheme that the Component may use. It is just HTML. Layouts operate on child
  680. * **`{@link Ext.container.Container#cfg-items items}`**.
  681. *
  682. * Add either the `x-hidden` or the `x-hide-display` CSS class to prevent a brief flicker of the content before it
  683. * is rendered to the panel.
  684. */
  685. <span id='Ext-AbstractComponent-cfg-html'> /**
  686. </span> * @cfg {String/Object} [html='']
  687. * An HTML fragment, or a {@link Ext.DomHelper DomHelper} specification to use as the layout element content.
  688. * The HTML content is added after the component is rendered, so the document will not contain this HTML at the time
  689. * the {@link #event-render} event is fired. This content is inserted into the body _before_ any configured {@link #contentEl}
  690. * is appended.
  691. */
  692. <span id='Ext-AbstractComponent-cfg-styleHtmlContent'> /**
  693. </span> * @cfg {Boolean} styleHtmlContent
  694. * True to automatically style the html inside the content target of this component (body for panels).
  695. */
  696. styleHtmlContent: false,
  697. <span id='Ext-AbstractComponent-cfg-styleHtmlCls'> /**
  698. </span> * @cfg {String} [styleHtmlCls='x-html']
  699. * The class that is added to the content target when you set styleHtmlContent to true.
  700. */
  701. styleHtmlCls: Ext.baseCSSPrefix + 'html',
  702. <span id='Ext-AbstractComponent-cfg-minHeight'> /**
  703. </span> * @cfg {Number} minHeight
  704. * The minimum value in pixels which this Component will set its height to.
  705. *
  706. * **Warning:** This will override any size management applied by layout managers.
  707. */
  708. <span id='Ext-AbstractComponent-cfg-minWidth'> /**
  709. </span> * @cfg {Number} minWidth
  710. * The minimum value in pixels which this Component will set its width to.
  711. *
  712. * **Warning:** This will override any size management applied by layout managers.
  713. */
  714. <span id='Ext-AbstractComponent-cfg-maxHeight'> /**
  715. </span> * @cfg {Number} maxHeight
  716. * The maximum value in pixels which this Component will set its height to.
  717. *
  718. * **Warning:** This will override any size management applied by layout managers.
  719. */
  720. <span id='Ext-AbstractComponent-cfg-maxWidth'> /**
  721. </span> * @cfg {Number} maxWidth
  722. * The maximum value in pixels which this Component will set its width to.
  723. *
  724. * **Warning:** This will override any size management applied by layout managers.
  725. */
  726. <span id='Ext-AbstractComponent-cfg-loader'> /**
  727. </span> * @cfg {Ext.ComponentLoader/Object} loader
  728. * A configuration object or an instance of a {@link Ext.ComponentLoader} to load remote content
  729. * for this Component.
  730. *
  731. * Ext.create('Ext.Component', {
  732. * loader: {
  733. * url: 'content.html',
  734. * autoLoad: true
  735. * },
  736. * renderTo: Ext.getBody()
  737. * });
  738. */
  739. <span id='Ext-AbstractComponent-cfg-autoLoad'> /**
  740. </span> * @cfg {Ext.ComponentLoader/Object/String/Boolean} autoLoad
  741. * An alias for {@link #loader} config which also allows to specify just a string which will be
  742. * used as the url that's automatically loaded:
  743. *
  744. * Ext.create('Ext.Component', {
  745. * autoLoad: 'content.html',
  746. * renderTo: Ext.getBody()
  747. * });
  748. *
  749. * The above is the same as:
  750. *
  751. * Ext.create('Ext.Component', {
  752. * loader: {
  753. * url: 'content.html',
  754. * autoLoad: true
  755. * },
  756. * renderTo: Ext.getBody()
  757. * });
  758. *
  759. * Don't use it together with {@link #loader} config.
  760. *
  761. * @deprecated 4.1.1 Use {@link #loader} config instead.
  762. */
  763. <span id='Ext-AbstractComponent-cfg-autoShow'> /**
  764. </span> * @cfg {Boolean} autoShow
  765. * True to automatically show the component upon creation. This config option may only be used for
  766. * {@link #floating} components or components that use {@link #autoRender}. Defaults to false.
  767. */
  768. autoShow: false,
  769. <span id='Ext-AbstractComponent-cfg-autoRender'> /**
  770. </span> * @cfg {Boolean/String/HTMLElement/Ext.Element} autoRender
  771. * This config is intended mainly for non-{@link #floating} Components which may or may not be shown. Instead of using
  772. * {@link #renderTo} in the configuration, and rendering upon construction, this allows a Component to render itself
  773. * upon first _{@link Ext.Component#method-show show}_. If {@link #floating} is true, the value of this config is omited as if it is `true`.
  774. *
  775. * Specify as `true` to have this Component render to the document body upon first show.
  776. *
  777. * Specify as an element, or the ID of an element to have this Component render to a specific element upon first
  778. * show.
  779. */
  780. autoRender: false,
  781. // @private
  782. allowDomMove: true,
  783. <span id='Ext-AbstractComponent-cfg-plugins'> /**
  784. </span> * @cfg {Object/Object[]} plugins
  785. * An object or array of objects that will provide custom functionality for this component. The only requirement for
  786. * a valid plugin is that it contain an init method that accepts a reference of type Ext.Component. When a component
  787. * is created, if any plugins are available, the component will call the init method on each plugin, passing a
  788. * reference to itself. Each plugin can then call methods or respond to events on the component as needed to provide
  789. * its functionality.
  790. */
  791. <span id='Ext-AbstractComponent-property-rendered'> /**
  792. </span> * @property {Boolean} rendered
  793. * Indicates whether or not the component has been rendered.
  794. * @readonly
  795. */
  796. rendered: false,
  797. <span id='Ext-AbstractComponent-property-componentLayoutCounter'> /**
  798. </span> * @property {Number} componentLayoutCounter
  799. * @private
  800. * The number of component layout calls made on this object.
  801. */
  802. componentLayoutCounter: 0,
  803. <span id='Ext-AbstractComponent-cfg-shrinkWrap'> /**
  804. </span> * @cfg {Boolean/Number} [shrinkWrap=2]
  805. *
  806. * If this property is a number, it is interpreted as follows:
  807. *
  808. * - 0: Neither width nor height depend on content. This is equivalent to `false`.
  809. * - 1: Width depends on content (shrink wraps), but height does not.
  810. * - 2: Height depends on content (shrink wraps), but width does not. The default.
  811. * - 3: Both width and height depend on content (shrink wrap). This is equivalent to `true`.
  812. *
  813. * In CSS terms, shrink-wrap width is analogous to an inline-block element as opposed
  814. * to a block-level element. Some container layouts always shrink-wrap their children,
  815. * effectively ignoring this property (e.g., {@link Ext.layout.container.HBox},
  816. * {@link Ext.layout.container.VBox}, {@link Ext.layout.component.Dock}).
  817. */
  818. shrinkWrap: 2,
  819. weight: 0,
  820. <span id='Ext-AbstractComponent-property-maskOnDisable'> /**
  821. </span> * @property {Boolean} maskOnDisable
  822. * This is an internal flag that you use when creating custom components. By default this is set to true which means
  823. * that every component gets a mask when it's disabled. Components like FieldContainer, FieldSet, Field, Button, Tab
  824. * override this property to false since they want to implement custom disable logic.
  825. */
  826. maskOnDisable: true,
  827. <span id='Ext-AbstractComponent-property-_isLayoutRoot'> /**
  828. </span> * @property {Boolean} [_isLayoutRoot=false]
  829. * Setting this property to `true` causes the {@link #isLayoutRoot} method to return
  830. * `true` and stop the search for the top-most component for a layout.
  831. * @protected
  832. */
  833. _isLayoutRoot: false,
  834. <span id='Ext-AbstractComponent-method-constructor'> /**
  835. </span> * Creates new Component.
  836. * @param {Object} config (optional) Config object.
  837. */
  838. constructor : function(config) {
  839. var me = this,
  840. i, len, xhooks;
  841. if (config) {
  842. Ext.apply(me, config);
  843. xhooks = me.xhooks;
  844. if (xhooks) {
  845. delete me.xhooks;
  846. Ext.override(me, xhooks);
  847. }
  848. } else {
  849. config = {};
  850. }
  851. me.initialConfig = config;
  852. me.mixins.elementCt.constructor.call(me);
  853. me.addEvents(
  854. <span id='Ext-AbstractComponent-event-beforeactivate'> /**
  855. </span> * @event beforeactivate
  856. * Fires before a Component has been visually activated. Returning false from an event listener can prevent
  857. * the activate from occurring.
  858. * @param {Ext.Component} this
  859. */
  860. 'beforeactivate',
  861. <span id='Ext-AbstractComponent-event-activate'> /**
  862. </span> * @event activate
  863. * Fires after a Component has been visually activated.
  864. * @param {Ext.Component} this
  865. */
  866. 'activate',
  867. <span id='Ext-AbstractComponent-event-beforedeactivate'> /**
  868. </span> * @event beforedeactivate
  869. * Fires before a Component has been visually deactivated. Returning false from an event listener can
  870. * prevent the deactivate from occurring.
  871. * @param {Ext.Component} this
  872. */
  873. 'beforedeactivate',
  874. <span id='Ext-AbstractComponent-event-deactivate'> /**
  875. </span> * @event deactivate
  876. * Fires after a Component has been visually deactivated.
  877. * @param {Ext.Component} this
  878. */
  879. 'deactivate',
  880. <span id='Ext-AbstractComponent-event-added'> /**
  881. </span> * @event added
  882. * Fires after a Component had been added to a Container.
  883. * @param {Ext.Component} this
  884. * @param {Ext.container.Container} container Parent Container
  885. * @param {Number} pos position of Component
  886. */
  887. 'added',
  888. <span id='Ext-AbstractComponent-event-disable'> /**
  889. </span> * @event disable
  890. * Fires after the component is disabled.
  891. * @param {Ext.Component} this
  892. */
  893. 'disable',
  894. <span id='Ext-AbstractComponent-event-enable'> /**
  895. </span> * @event enable
  896. * Fires after the component is enabled.
  897. * @param {Ext.Component} this
  898. */
  899. 'enable',
  900. <span id='Ext-AbstractComponent-event-beforeshow'> /**
  901. </span> * @event beforeshow
  902. * Fires before the component is shown when calling the {@link Ext.Component#method-show show} method. Return false from an event
  903. * handler to stop the show.
  904. * @param {Ext.Component} this
  905. */
  906. 'beforeshow',
  907. <span id='Ext-AbstractComponent-event-show'> /**
  908. </span> * @event show
  909. * Fires after the component is shown when calling the {@link Ext.Component#method-show show} method.
  910. * @param {Ext.Component} this
  911. */
  912. 'show',
  913. <span id='Ext-AbstractComponent-event-beforehide'> /**
  914. </span> * @event beforehide
  915. * Fires before the component is hidden when calling the {@link Ext.Component#method-hide hide} method. Return false from an event
  916. * handler to stop the hide.
  917. * @param {Ext.Component} this
  918. */
  919. 'beforehide',
  920. <span id='Ext-AbstractComponent-event-hide'> /**
  921. </span> * @event hide
  922. * Fires after the component is hidden. Fires after the component is hidden when calling the {@link Ext.Component#method-hide hide}
  923. * method.
  924. * @param {Ext.Component} this
  925. */
  926. 'hide',
  927. <span id='Ext-AbstractComponent-event-removed'> /**
  928. </span> * @event removed
  929. * Fires when a component is removed from an Ext.container.Container
  930. * @param {Ext.Component} this
  931. * @param {Ext.container.Container} ownerCt Container which holds the component
  932. */
  933. 'removed',
  934. <span id='Ext-AbstractComponent-event-beforerender'> /**
  935. </span> * @event beforerender
  936. * Fires before the component is {@link #rendered}. Return false from an event handler to stop the
  937. * {@link #method-render}.
  938. * @param {Ext.Component} this
  939. */
  940. 'beforerender',
  941. <span id='Ext-AbstractComponent-event-render'> /**
  942. </span> * @event render
  943. * Fires after the component markup is {@link #rendered}.
  944. * @param {Ext.Component} this
  945. */
  946. 'render',
  947. <span id='Ext-AbstractComponent-event-afterrender'> /**
  948. </span> * @event afterrender
  949. * Fires after the component rendering is finished.
  950. *
  951. * The afterrender event is fired after this Component has been {@link #rendered}, been postprocesed by any
  952. * afterRender method defined for the Component.
  953. * @param {Ext.Component} this
  954. */
  955. 'afterrender',
  956. <span id='Ext-AbstractComponent-event-boxready'> /**
  957. </span> * @event boxready
  958. * Fires *one time* - after the component has been layed out for the first time at its initial size.
  959. * @param {Ext.Component} this
  960. * @param {Number} width The initial width
  961. * @param {Number} height The initial height
  962. */
  963. 'boxready',
  964. <span id='Ext-AbstractComponent-event-beforedestroy'> /**
  965. </span> * @event beforedestroy
  966. * Fires before the component is {@link #method-destroy}ed. Return false from an event handler to stop the
  967. * {@link #method-destroy}.
  968. * @param {Ext.Component} this
  969. */
  970. 'beforedestroy',
  971. <span id='Ext-AbstractComponent-event-destroy'> /**
  972. </span> * @event destroy
  973. * Fires after the component is {@link #method-destroy}ed.
  974. * @param {Ext.Component} this
  975. */
  976. 'destroy',
  977. <span id='Ext-AbstractComponent-event-resize'> /**
  978. </span> * @event resize
  979. * Fires after the component is resized. Note that this does *not* fire when the component is first layed out at its initial
  980. * size. To hook that point in the lifecycle, use the {@link #boxready} event.
  981. * @param {Ext.Component} this
  982. * @param {Number} width The new width that was set
  983. * @param {Number} height The new height that was set
  984. * @param {Number} oldWidth The previous width
  985. * @param {Number} oldHeight The previous height
  986. */
  987. 'resize',
  988. <span id='Ext-AbstractComponent-event-move'> /**
  989. </span> * @event move
  990. * Fires after the component is moved.
  991. * @param {Ext.Component} this
  992. * @param {Number} x The new x position
  993. * @param {Number} y The new y position
  994. */
  995. 'move',
  996. <span id='Ext-AbstractComponent-event-focus'> /**
  997. </span> * @event focus
  998. * Fires when this Component receives focus.
  999. * @param {Ext.Component} this
  1000. * @param {Ext.EventObject} The focus event.
  1001. */
  1002. 'focus',
  1003. <span id='Ext-AbstractComponent-event-blur'> /**
  1004. </span> * @event blur
  1005. * Fires when this Component loses focus.
  1006. * @param {Ext.Component} this
  1007. * @param {Ext.EventObject} The blur event.
  1008. */
  1009. 'blur'
  1010. );
  1011. me.getId();
  1012. me.setupProtoEl();
  1013. // initComponent, beforeRender, or event handlers may have set the style or cls property since the protoEl was set up
  1014. // so we must apply styles and classes here too.
  1015. if (me.cls) {
  1016. me.initialCls = me.cls;
  1017. me.protoEl.addCls(me.cls);
  1018. }
  1019. if (me.style) {
  1020. me.initialStyle = me.style;
  1021. me.protoEl.setStyle(me.style);
  1022. }
  1023. me.mons = [];
  1024. me.renderData = me.renderData || {};
  1025. me.renderSelectors = me.renderSelectors || {};
  1026. if (me.plugins) {
  1027. me.plugins = me.constructPlugins();
  1028. }
  1029. // we need this before we call initComponent
  1030. if (!me.hasListeners) {
  1031. me.hasListeners = new me.HasListeners();
  1032. }
  1033. me.initComponent();
  1034. // ititComponent gets a chance to change the id property before registering
  1035. Ext.ComponentManager.register(me);
  1036. // Dont pass the config so that it is not applied to 'this' again
  1037. me.mixins.observable.constructor.call(me);
  1038. me.mixins.state.constructor.call(me, config);
  1039. // Save state on resize.
  1040. this.addStateEvents('resize');
  1041. // Move this into Observable?
  1042. if (me.plugins) {
  1043. for (i = 0, len = me.plugins.length; i &lt; len; i++) {
  1044. me.plugins[i] = me.initPlugin(me.plugins[i]);
  1045. }
  1046. }
  1047. me.loader = me.getLoader();
  1048. if (me.renderTo) {
  1049. me.render(me.renderTo);
  1050. // EXTJSIV-1935 - should be a way to do afterShow or something, but that
  1051. // won't work. Likewise, rendering hidden and then showing (w/autoShow) has
  1052. // implications to afterRender so we cannot do that.
  1053. }
  1054. // Auto show only works unilaterally on *uncontained* Components.
  1055. // If contained, then it is the Container's responsibility to do the showing at next layout time.
  1056. if (me.autoShow &amp;&amp; !me.isContained) {
  1057. me.show();
  1058. }
  1059. //&lt;debug&gt;
  1060. if (Ext.isDefined(me.disabledClass)) {
  1061. if (Ext.isDefined(Ext.global.console)) {
  1062. Ext.global.console.warn('Ext.Component: disabledClass has been deprecated. Please use disabledCls.');
  1063. }
  1064. me.disabledCls = me.disabledClass;
  1065. delete me.disabledClass;
  1066. }
  1067. //&lt;/debug&gt;
  1068. },
  1069. initComponent: function () {
  1070. // This is called again here to allow derived classes to add plugin configs to the
  1071. // plugins array before calling down to this, the base initComponent.
  1072. this.plugins = this.constructPlugins();
  1073. // this will properly (ignore or) constrain the configured width/height to their
  1074. // min/max values for consistency.
  1075. this.setSize(this.width, this.height);
  1076. },
  1077. <span id='Ext-AbstractComponent-method-getState'> /**
  1078. </span> * The supplied default state gathering method for the AbstractComponent class.
  1079. *
  1080. * This method returns dimension settings such as `flex`, `anchor`, `width` and `height` along with `collapsed`
  1081. * state.
  1082. *
  1083. * Subclasses which implement more complex state should call the superclass's implementation, and apply their state
  1084. * to the result if this basic state is to be saved.
  1085. *
  1086. * Note that Component state will only be saved if the Component has a {@link #stateId} and there as a StateProvider
  1087. * configured for the document.
  1088. *
  1089. * @return {Object}
  1090. */
  1091. getState: function() {
  1092. var me = this,
  1093. state = null,
  1094. sizeModel = me.getSizeModel();
  1095. if (sizeModel.width.configured) {
  1096. state = me.addPropertyToState(state, 'width');
  1097. }
  1098. if (sizeModel.height.configured) {
  1099. state = me.addPropertyToState(state, 'height');
  1100. }
  1101. return state;
  1102. },
  1103. <span id='Ext-AbstractComponent-method-addPropertyToState'> /**
  1104. </span> * Save a property to the given state object if it is not its default or configured
  1105. * value.
  1106. *
  1107. * @param {Object} state The state object
  1108. * @param {String} propName The name of the property on this object to save.
  1109. * @param {String} [value] The value of the state property (defaults to `this[propName]`).
  1110. * @return {Boolean} The state object or a new object if state was null and the property
  1111. * was saved.
  1112. * @protected
  1113. */
  1114. addPropertyToState: function (state, propName, value) {
  1115. var me = this,
  1116. len = arguments.length;
  1117. // If the property is inherited, it is a default and we don't want to save it to
  1118. // the state, however if we explicitly specify a value, always save it
  1119. if (len == 3 || me.hasOwnProperty(propName)) {
  1120. if (len &lt; 3) {
  1121. value = me[propName];
  1122. }
  1123. // If the property has the same value as was initially configured, again, we
  1124. // don't want to save it.
  1125. if (value !== me.initialConfig[propName]) {
  1126. (state || (state = {}))[propName] = value;
  1127. }
  1128. }
  1129. return state;
  1130. },
  1131. show: Ext.emptyFn,
  1132. animate: function(animObj) {
  1133. var me = this,
  1134. hasToWidth,
  1135. hasToHeight,
  1136. toHeight,
  1137. toWidth,
  1138. to,
  1139. clearWidth,
  1140. clearHeight,
  1141. curWidth, w, curHeight, h, needsResize;
  1142. animObj = animObj || {};
  1143. to = animObj.to || {};
  1144. if (Ext.fx.Manager.hasFxBlock(me.id)) {
  1145. return me;
  1146. }
  1147. hasToWidth = Ext.isDefined(to.width);
  1148. if (hasToWidth) {
  1149. toWidth = Ext.Number.constrain(to.width, me.minWidth, me.maxWidth);
  1150. }
  1151. hasToHeight = Ext.isDefined(to.height);
  1152. if (hasToHeight) {
  1153. toHeight = Ext.Number.constrain(to.height, me.minHeight, me.maxHeight);
  1154. }
  1155. // Special processing for animating Component dimensions.
  1156. if (!animObj.dynamic &amp;&amp; (hasToWidth || hasToHeight)) {
  1157. curWidth = (animObj.from ? animObj.from.width : undefined) || me.getWidth();
  1158. w = curWidth;
  1159. curHeight = (animObj.from ? animObj.from.height : undefined) || me.getHeight();
  1160. h = curHeight;
  1161. needsResize = false;
  1162. if (hasToHeight &amp;&amp; toHeight &gt; curHeight) {
  1163. h = toHeight;
  1164. needsResize = true;
  1165. }
  1166. if (hasToWidth &amp;&amp; toWidth &gt; curWidth) {
  1167. w = toWidth;
  1168. needsResize = true;
  1169. }
  1170. // If any dimensions are being increased, we must resize the internal structure
  1171. // of the Component, but then clip it by sizing its encapsulating element back to original dimensions.
  1172. // The animation will then progressively reveal the larger content.
  1173. if (needsResize) {
  1174. clearWidth = !Ext.isNumber(me.width);
  1175. clearHeight = !Ext.isNumber(me.height);
  1176. me.setSize(w, h);
  1177. me.el.setSize(curWidth, curHeight);
  1178. if (clearWidth) {
  1179. delete me.width;
  1180. }
  1181. if (clearHeight) {
  1182. delete me.height;
  1183. }
  1184. }
  1185. if (hasToWidth) {
  1186. to.width = toWidth;
  1187. }
  1188. if (hasToHeight) {
  1189. to.height = toHeight;
  1190. }
  1191. }
  1192. return me.mixins.animate.animate.apply(me, arguments);
  1193. },
  1194. onHide: function() {
  1195. this.updateLayout({ isRoot: false });
  1196. },
  1197. onShow : function() {
  1198. this.updateLayout({ isRoot: false });
  1199. },
  1200. constructPlugin: function(plugin) {
  1201. // If a config object with a ptype
  1202. if (plugin.ptype &amp;&amp; typeof plugin.init != 'function') {
  1203. plugin.cmp = this;
  1204. plugin = Ext.PluginManager.create(plugin);
  1205. }
  1206. // Just a ptype
  1207. else if (typeof plugin == 'string') {
  1208. plugin = Ext.PluginManager.create({
  1209. ptype: plugin,
  1210. cmp: this
  1211. });
  1212. }
  1213. return plugin;
  1214. },
  1215. <span id='Ext-AbstractComponent-method-constructPlugins'> /**
  1216. </span> * @private
  1217. * Returns an array of fully constructed plugin instances. This converts any configs into their
  1218. * appropriate instances.
  1219. *
  1220. * It does not mutate the plugins array. It creates a new array.
  1221. *
  1222. * This is borrowed by {@link Ext.grid.Lockable Lockable} which clones and distributes Plugins
  1223. * to both child grids of a locking grid, so must keep to that contract.
  1224. */
  1225. constructPlugins: function() {
  1226. var me = this,
  1227. plugins,
  1228. result = [],
  1229. i, len;
  1230. if (me.plugins) {
  1231. plugins = Ext.isArray(me.plugins) ? me.plugins : [ me.plugins ];
  1232. for (i = 0, len = plugins.length; i &lt; len; i++) {
  1233. // this just returns already-constructed plugin instances...
  1234. result[i] = me.constructPlugin(plugins[i]);
  1235. }
  1236. return result;
  1237. }
  1238. },
  1239. // @private
  1240. initPlugin : function(plugin) {
  1241. plugin.init(this);
  1242. return plugin;
  1243. },
  1244. <span id='Ext-AbstractComponent-method-updateAria'> /**
  1245. </span> * @private
  1246. * Injected as an override by Ext.Aria.initialize
  1247. */
  1248. updateAria: Ext.emptyFn,
  1249. <span id='Ext-AbstractComponent-method-registerFloatingItem'> /**
  1250. </span> * Called by Component#doAutoRender
  1251. *
  1252. * Register a Container configured `floating: true` with this Component's {@link Ext.ZIndexManager ZIndexManager}.
  1253. *
  1254. * Components added in ths way will not participate in any layout, but will be rendered
  1255. * upon first show in the way that {@link Ext.window.Window Window}s are.
  1256. */
  1257. registerFloatingItem: function(cmp) {
  1258. var me = this;
  1259. if (!me.floatingDescendants) {
  1260. me.floatingDescendants = new Ext.ZIndexManager(me);
  1261. }
  1262. me.floatingDescendants.register(cmp);
  1263. },
  1264. unregisterFloatingItem: function(cmp) {
  1265. var me = this;
  1266. if (me.floatingDescendants) {
  1267. me.floatingDescendants.unregister(cmp);
  1268. }
  1269. },
  1270. layoutSuspendCount: 0,
  1271. suspendLayouts: function () {
  1272. var me = this;
  1273. if (!me.rendered) {
  1274. return;
  1275. }
  1276. if (++me.layoutSuspendCount == 1) {
  1277. me.suspendLayout = true;
  1278. }
  1279. },
  1280. resumeLayouts: function (flushOptions) {
  1281. var me = this;
  1282. if (!me.rendered) {
  1283. return;
  1284. }
  1285. if (! --me.layoutSuspendCount) {
  1286. me.suspendLayout = false;
  1287. if (flushOptions &amp;&amp; !me.isLayoutSuspended()) {
  1288. me.updateLayout(flushOptions);
  1289. }
  1290. }
  1291. },
  1292. setupProtoEl: function() {
  1293. var me = this,
  1294. cls = [ me.baseCls, me.getComponentLayout().targetCls ];
  1295. //&lt;deprecated since=0.99&gt;
  1296. if (Ext.isDefined(me.cmpCls)) {
  1297. if (Ext.isDefined(Ext.global.console)) {
  1298. Ext.global.console.warn('Ext.Component: cmpCls has been deprecated. Please use componentCls.');
  1299. }
  1300. me.componentCls = me.cmpCls;
  1301. delete me.cmpCls;
  1302. }
  1303. //&lt;/deprecated&gt;
  1304. if (me.componentCls) {
  1305. cls.push(me.componentCls);
  1306. } else {
  1307. me.componentCls = me.baseCls;
  1308. }
  1309. me.protoEl = new Ext.util.ProtoElement({
  1310. cls: cls.join(' ') // in case any of the parts have multiple classes
  1311. });
  1312. },
  1313. <span id='Ext-AbstractComponent-method-setUI'> /**
  1314. </span> * Sets the UI for the component. This will remove any existing UIs on the component. It will also loop through any
  1315. * uiCls set on the component and rename them so they include the new UI
  1316. * @param {String} ui The new UI for the component
  1317. */
  1318. setUI: function(ui) {
  1319. var me = this,
  1320. oldUICls = Ext.Array.clone(me.uiCls),
  1321. newUICls = [],
  1322. classes = [],
  1323. cls,
  1324. i;
  1325. //loop through all existing uiCls and update the ui in them
  1326. for (i = 0; i &lt; oldUICls.length; i++) {
  1327. cls = oldUICls[i];
  1328. classes = classes.concat(me.removeClsWithUI(cls, true));
  1329. newUICls.push(cls);
  1330. }
  1331. if (classes.length) {
  1332. me.removeCls(classes);
  1333. }
  1334. //remove the UI from the element
  1335. me.removeUIFromElement();
  1336. //set the UI
  1337. me.ui = ui;
  1338. //add the new UI to the element
  1339. me.addUIToElement();
  1340. //loop through all existing uiCls and update the ui in them
  1341. classes = [];
  1342. for (i = 0; i &lt; newUICls.length; i++) {
  1343. cls = newUICls[i];
  1344. classes = classes.concat(me.addClsWithUI(cls, true));
  1345. }
  1346. if (classes.length) {
  1347. me.addCls(classes);
  1348. }
  1349. // Changing the ui can lead to significant changes to a component's appearance, so the layout needs to be
  1350. // updated. Internally most calls to setUI are pre-render. Buttons are a notable exception as setScale changes
  1351. // the ui and often requires the layout to be updated.
  1352. if (me.rendered) {
  1353. me.updateLayout();
  1354. }
  1355. },
  1356. <span id='Ext-AbstractComponent-method-addClsWithUI'> /**
  1357. </span> * Adds a cls to the uiCls array, which will also call {@link #addUIClsToElement} and adds to all elements of this
  1358. * component.
  1359. * @param {String/String[]} classes A string or an array of strings to add to the uiCls
  1360. * @param {Object} skip (Boolean) skip True to skip adding it to the class and do it later (via the return)
  1361. */
  1362. addClsWithUI: function(classes, skip) {
  1363. var me = this,
  1364. clsArray = [],
  1365. length,
  1366. i = 0,
  1367. cls;
  1368. if (typeof classes === &quot;string&quot;) {
  1369. classes = (classes.indexOf(' ') &lt; 0) ? [classes] : Ext.String.splitWords(classes);
  1370. }
  1371. length = classes.length;
  1372. me.uiCls = Ext.Array.clone(me.uiCls);
  1373. for (; i &lt; length; i++) {
  1374. cls = classes[i];
  1375. if (cls &amp;&amp; !me.hasUICls(cls)) {
  1376. me.uiCls.push(cls);
  1377. clsArray = clsArray.concat(me.addUIClsToElement(cls));
  1378. }
  1379. }
  1380. if (skip !== true) {
  1381. me.addCls(clsArray);
  1382. }
  1383. return clsArray;
  1384. },
  1385. <span id='Ext-AbstractComponent-method-removeClsWithUI'> /**
  1386. </span> * Removes a cls to the uiCls array, which will also call {@link #removeUIClsFromElement} and removes it from all
  1387. * elements of this component.
  1388. * @param {String/String[]} cls A string or an array of strings to remove to the uiCls
  1389. */
  1390. removeClsWithUI: function(classes, skip) {
  1391. var me = this,
  1392. clsArray = [],
  1393. i = 0,
  1394. length, cls;
  1395. if (typeof classes === &quot;string&quot;) {
  1396. classes = (classes.indexOf(' ') &lt; 0) ? [classes] : Ext.String.splitWords(classes);
  1397. }
  1398. length = classes.length;
  1399. for (i = 0; i &lt; length; i++) {
  1400. cls = classes[i];
  1401. if (cls &amp;&amp; me.hasUICls(cls)) {
  1402. me.uiCls = Ext.Array.remove(me.uiCls, cls);
  1403. clsArray = clsArray.concat(me.removeUIClsFromElement(cls));
  1404. }
  1405. }
  1406. if (skip !== true) {
  1407. me.removeCls(clsArray);
  1408. }
  1409. return clsArray;
  1410. },
  1411. <span id='Ext-AbstractComponent-method-hasUICls'> /**
  1412. </span> * Checks if there is currently a specified uiCls
  1413. * @param {String} cls The cls to check
  1414. */
  1415. hasUICls: function(cls) {
  1416. var me = this,
  1417. uiCls = me.uiCls || [];
  1418. return Ext.Array.contains(uiCls, cls);
  1419. },
  1420. frameElementsArray: ['tl', 'tc', 'tr', 'ml', 'mc', 'mr', 'bl', 'bc', 'br'],
  1421. <span id='Ext-AbstractComponent-method-addUIClsToElement'> /**
  1422. </span> * Method which adds a specified UI + uiCls to the components element. Can be overridden to remove the UI from more
  1423. * than just the components element.
  1424. * @param {String} ui The UI to remove from the element
  1425. */
  1426. addUIClsToElement: function(cls) {
  1427. var me = this,
  1428. baseClsUi = me.baseCls + '-' + me.ui + '-' + cls,
  1429. result = [Ext.baseCSSPrefix + cls, me.baseCls + '-' + cls, baseClsUi],
  1430. frameElementCls = me.frameElementCls,
  1431. frameElementsArray, frameElementsLength, i, el, frameElement, c;
  1432. if (me.frame &amp;&amp; !Ext.supports.CSS3BorderRadius) {
  1433. // define each element of the frame
  1434. frameElementsArray = me.frameElementsArray;
  1435. frameElementsLength = frameElementsArray.length;
  1436. i = 0;
  1437. // loop through each of them, and if they are defined add the ui
  1438. for (; i &lt; frameElementsLength; i++) {
  1439. frameElement = frameElementsArray[i];
  1440. el = me['frame' + frameElement.toUpperCase()];
  1441. c = baseClsUi + '-' + frameElement;
  1442. if (el &amp;&amp; el.dom) {
  1443. el.addCls(c);
  1444. } else if (Ext.Array.indexOf(frameElementCls[frameElement], c) == -1) {
  1445. frameElementCls[frameElement].push(c);
  1446. }
  1447. }
  1448. }
  1449. me.frameElementCls = frameElementCls;
  1450. return result;
  1451. },
  1452. <span id='Ext-AbstractComponent-method-removeUIClsFromElement'> /**
  1453. </span> * Method which removes a specified UI + uiCls from the components element. The cls which is added to the element
  1454. * will be: `this.baseCls + '-' + ui`
  1455. * @param {String} ui The UI to add to the element
  1456. */
  1457. removeUIClsFromElement: function(cls) {
  1458. var me = this,
  1459. baseClsUi = me.baseCls + '-' + me.ui + '-' + cls,
  1460. result = [Ext.baseCSSPrefix + cls, me.baseCls + '-' + cls, baseClsUi],
  1461. frameElementCls = me.frameElementCls,
  1462. frameElementsArray, frameElementsLength, i, el, frameElement, c;
  1463. if (me.frame &amp;&amp; !Ext.supports.CSS3BorderRadius) {
  1464. // define each element of the frame
  1465. frameElementsArray = me.frameElementsArray;
  1466. frameElementsLength = frameElementsArray.length;
  1467. i = 0;
  1468. // loop through each of them, and if they are defined add the ui
  1469. for (; i &lt; frameElementsLength; i++) {
  1470. frameElement = frameElementsArray[i];
  1471. el = me['frame' + frameElement.toUpperCase()];
  1472. c = baseClsUi + '-' + frameElement;
  1473. if (el &amp;&amp; el.dom) {
  1474. el.addCls(c);
  1475. } else {
  1476. Ext.Array.remove(frameElementCls[frameElement], c);
  1477. }
  1478. }
  1479. }
  1480. me.frameElementCls = frameElementCls;
  1481. return result;
  1482. },
  1483. <span id='Ext-AbstractComponent-method-addUIToElement'> /**
  1484. </span> * Method which adds a specified UI to the components element.
  1485. * @private
  1486. */
  1487. addUIToElement: function() {
  1488. var me = this,
  1489. baseClsUI = me.baseCls + '-' + me.ui,
  1490. frameElementCls = me.frameElementCls,
  1491. frameElementsArray, frameElementsLength, i, el, frameElement, c;
  1492. me.addCls(baseClsUI);
  1493. if (me.frame &amp;&amp; !Ext.supports.CSS3BorderRadius) {
  1494. // define each element of the frame
  1495. frameElementsArray = me.frameElementsArray;
  1496. frameElementsLength = frameElementsArray.length;
  1497. i = 0;
  1498. // loop through each of them, and if they are defined add the ui
  1499. for (; i &lt; frameElementsLength; i++) {
  1500. frameElement = frameElementsArray[i];
  1501. el = me['frame' + frameElement.toUpperCase()];
  1502. c = baseClsUI + '-' + frameElement;
  1503. if (el) {
  1504. el.addCls(c);
  1505. } else {
  1506. if (!Ext.Array.contains(frameElementCls[frameElement], c)) {
  1507. frameElementCls[frameElement].push(c);
  1508. }
  1509. }
  1510. }
  1511. }
  1512. },
  1513. <span id='Ext-AbstractComponent-method-removeUIFromElement'> /**
  1514. </span> * Method which removes a specified UI from the components element.
  1515. * @private
  1516. */
  1517. removeUIFromElement: function() {
  1518. var me = this,
  1519. baseClsUI = me.baseCls + '-' + me.ui,
  1520. frameElementCls = me.frameElementCls,
  1521. frameElementsArray, frameElementsLength, i, el, frameElement, c;
  1522. me.removeCls(baseClsUI);
  1523. if (me.frame &amp;&amp; !Ext.supports.CSS3BorderRadius) {
  1524. // define each element of the frame
  1525. frameElementsArray = me.frameElementsArray;
  1526. frameElementsLength = frameElementsArray.length;
  1527. i = 0;
  1528. for (; i &lt; frameElementsLength; i++) {
  1529. frameElement = frameElementsArray[i];
  1530. el = me['frame' + frameElement.toUpperCase()];
  1531. c = baseClsUI + '-' + frameElement;
  1532. if (el) {
  1533. el.removeCls(c);
  1534. } else {
  1535. Ext.Array.remove(frameElementCls[frameElement], c);
  1536. }
  1537. }
  1538. }
  1539. },
  1540. <span id='Ext-AbstractComponent-method-getTpl'> /**
  1541. </span> * @private
  1542. */
  1543. getTpl: function(name) {
  1544. return Ext.XTemplate.getTpl(this, name);
  1545. },
  1546. <span id='Ext-AbstractComponent-method-initStyles'> /**
  1547. </span> * Converts style definitions to String.
  1548. * @return {String} A CSS style string with style, padding, margin and border.
  1549. * @private
  1550. */
  1551. initStyles: function(targetEl) {
  1552. var me = this,
  1553. Element = Ext.Element,
  1554. padding = me.padding,
  1555. margin = me.margin,
  1556. x = me.x,
  1557. y = me.y,
  1558. width, height;
  1559. // Convert the padding, margin and border properties from a space separated string
  1560. // into a proper style string
  1561. if (padding !== undefined) {
  1562. targetEl.setStyle('padding', Element.unitizeBox((padding === true) ? 5 : padding));
  1563. }
  1564. if (margin !== undefined) {
  1565. targetEl.setStyle('margin', Element.unitizeBox((margin === true) ? 5 : margin));
  1566. }
  1567. if (me.border !== undefined) {
  1568. me.setBorder(me.border, targetEl);
  1569. }
  1570. // initComponent, beforeRender, or event handlers may have set the style or cls property since the protoEl was set up
  1571. // so we must apply styles and classes here too.
  1572. if (me.cls &amp;&amp; me.cls != me.initialCls) {
  1573. targetEl.addCls(me.cls);
  1574. delete me.cls;
  1575. delete me.initialCls;
  1576. }
  1577. if (me.style &amp;&amp; me.style != me.initialStyle) {
  1578. targetEl.setStyle(me.style);
  1579. delete me.style;
  1580. delete me.initialStyle;
  1581. }
  1582. if (x !== undefined) {
  1583. targetEl.setStyle('left', (typeof x == 'number') ? (x + 'px') : x);
  1584. }
  1585. if (y !== undefined) {
  1586. targetEl.setStyle('top', (typeof y == 'number') ? (y + 'px') : y);
  1587. }
  1588. // Framed components need their width/height to apply to the frame, which is
  1589. // best handled in layout at present.
  1590. if (!me.getFrameInfo()) {
  1591. width = me.width;
  1592. height = me.height;
  1593. // If we're using the content box model, we also cannot assign numeric initial sizes since we do not know the border widths to subtract
  1594. if (width !== undefined) {
  1595. if (typeof width === 'number') {
  1596. if (Ext.isBorderBox) {
  1597. targetEl.setStyle('width', width + 'px');
  1598. }
  1599. } else {
  1600. targetEl.setStyle('width', width);
  1601. }
  1602. }
  1603. if (height !== undefined) {
  1604. if (typeof height === 'number') {
  1605. if (Ext.isBorderBox) {
  1606. targetEl.setStyle('height', height + 'px');
  1607. }
  1608. } else {
  1609. targetEl.setStyle('height', height);
  1610. }
  1611. }
  1612. }
  1613. },
  1614. // @private
  1615. initEvents : function() {
  1616. var me = this,
  1617. afterRenderEvents = me.afterRenderEvents,
  1618. el,
  1619. property,
  1620. fn = function(listeners){
  1621. me.mon(el, listeners);
  1622. };
  1623. if (afterRenderEvents) {
  1624. for (property in afterRenderEvents) {
  1625. if (afterRenderEvents.hasOwnProperty(property)) {
  1626. el = me[property];
  1627. if (el &amp;&amp; el.on) {
  1628. Ext.each(afterRenderEvents[property], fn);
  1629. }
  1630. }
  1631. }
  1632. }
  1633. // This will add focus/blur listeners to the getFocusEl() element if that is naturally focusable.
  1634. // If *not* naturally focusable, then the FocusManager must be enabled to get it to listen for focus so that
  1635. // the FocusManager can track and highlight focus.
  1636. me.addFocusListener();
  1637. },
  1638. <span id='Ext-AbstractComponent-method-addFocusListener'> /**
  1639. </span> * @private
  1640. * &lt;p&gt;Sets up the focus listener on this Component's {@link #getFocusEl focusEl} if it has one.&lt;/p&gt;
  1641. * &lt;p&gt;Form Components which must implicitly participate in tabbing order usually have a naturally focusable
  1642. * element as their {@link #getFocusEl focusEl}, and it is the DOM event of that recieving focus which drives
  1643. * the Component's onFocus handling, and the DOM event of it being blurred which drives the onBlur handling.&lt;/p&gt;
  1644. * &lt;p&gt;If the {@link #getFocusEl focusEl} is &lt;b&gt;not&lt;/b&gt; naturally focusable, then the listeners are only added
  1645. * if the {@link Ext.FocusManager FocusManager} is enabled.&lt;/p&gt;
  1646. */
  1647. addFocusListener: function() {
  1648. var me = this,
  1649. focusEl = me.getFocusEl(),
  1650. needsTabIndex;
  1651. // All Containers may be focusable, not only &quot;form&quot; type elements, but also
  1652. // Panels, Toolbars, Windows etc.
  1653. // Usually, the &lt;DIV&gt; element they will return as their focusEl will not be able to recieve focus
  1654. // However, if the FocusManager is invoked, its non-default navigation handlers (invoked when
  1655. // tabbing/arrowing off of certain Components) may explicitly focus a Panel or Container or FieldSet etc.
  1656. // Add listeners to the focus and blur events on the focus element
  1657. // If this Component returns a focusEl, we might need to add a focus listener to it.
  1658. if (focusEl) {
  1659. // getFocusEl might return a Component if a Container wishes to delegate focus to a descendant.
  1660. // Window can do this via its defaultFocus configuration which can reference a Button.
  1661. if (focusEl.isComponent) {
  1662. return focusEl.addFocusListener();
  1663. }
  1664. // If the focusEl is naturally focusable, then we always need a focus listener to drive the Component's
  1665. // onFocus handling.
  1666. // If *not* naturally focusable, then we only need the focus listener if the FocusManager is enabled.
  1667. needsTabIndex = focusEl.needsTabIndex();
  1668. if (!me.focusListenerAdded &amp;&amp; (!needsTabIndex || Ext.FocusManager.enabled)) {
  1669. if (needsTabIndex) {
  1670. focusEl.dom.tabIndex = -1;
  1671. }
  1672. focusEl.on({
  1673. focus: me.onFocus,
  1674. blur: me.onBlur,
  1675. scope: me
  1676. });
  1677. me.focusListenerAdded = true;
  1678. }
  1679. }
  1680. },
  1681. <span id='Ext-AbstractComponent-method-getFocusEl'> /**
  1682. </span> * @private
  1683. * &lt;p&gt;Returns the focus holder element associated with this Component. At the Component base class level, this function returns &lt;code&gt;undefined&lt;/code&gt;.&lt;/p&gt;
  1684. * &lt;p&gt;Subclasses which use embedded focusable elements (such as Window, Field and Button) should override this for use by the {@link #focus} method.&lt;/p&gt;
  1685. * &lt;p&gt;Containers which need to participate in the {@link Ext.FocusManager FocusManager}'s navigation and Container focusing scheme also
  1686. * need to return a focusEl, although focus is only listened for in this case if the {@link Ext.FocusManager FocusManager} is {@link Ext.FocusManager#method-enable enable}d.&lt;/p&gt;
  1687. * @returns {undefined} &lt;code&gt;undefined&lt;/code&gt; because raw Components cannot by default hold focus.
  1688. */
  1689. getFocusEl: Ext.emptyFn,
  1690. isFocusable: function(c) {
  1691. var me = this,
  1692. focusEl;
  1693. if ((me.focusable !== false) &amp;&amp; (focusEl = me.getFocusEl()) &amp;&amp; me.rendered &amp;&amp; !me.destroying &amp;&amp; !me.isDestroyed &amp;&amp; !me.disabled &amp;&amp; me.isVisible(true)) {
  1694. // getFocusEl might return a Component if a Container wishes to delegate focus to a descendant.
  1695. // Window can do this via its defaultFocus configuration which can reference a Button.
  1696. if (focusEl.isComponent) {
  1697. return focusEl.isFocusable();
  1698. }
  1699. return focusEl &amp;&amp; focusEl.dom &amp;&amp; focusEl.isVisible();
  1700. }
  1701. },
  1702. // private
  1703. preFocus: Ext.emptyFn,
  1704. // private
  1705. onFocus: function(e) {
  1706. var me = this,
  1707. focusCls = me.focusCls,
  1708. focusEl = me.getFocusEl();
  1709. if (!me.disabled) {
  1710. me.preFocus(e);
  1711. if (focusCls &amp;&amp; focusEl) {
  1712. focusEl.addCls(me.addClsWithUI(focusCls, true));
  1713. }
  1714. if (!me.hasFocus) {
  1715. me.hasFocus = true;
  1716. me.fireEvent('focus', me, e);
  1717. }
  1718. }
  1719. },
  1720. // private
  1721. beforeBlur : Ext.emptyFn,
  1722. // private
  1723. onBlur : function(e) {
  1724. var me = this,
  1725. focusCls = me.focusCls,
  1726. focusEl = me.getFocusEl();
  1727. if (me.destroying) {
  1728. return;
  1729. }
  1730. me.beforeBlur(e);
  1731. if (focusCls &amp;&amp; focusEl) {
  1732. focusEl.removeCls(me.removeClsWithUI(focusCls, true));
  1733. }
  1734. if (me.validateOnBlur) {
  1735. me.validate();
  1736. }
  1737. me.hasFocus = false;
  1738. me.fireEvent('blur', me, e);
  1739. me.postBlur(e);
  1740. },
  1741. // private
  1742. postBlur : Ext.emptyFn,
  1743. <span id='Ext-AbstractComponent-method-is'> /**
  1744. </span> * Tests whether this Component matches the selector string.
  1745. * @param {String} selector The selector string to test against.
  1746. * @return {Boolean} True if this Component matches the selector.
  1747. */
  1748. is: function(selector) {
  1749. return Ext.ComponentQuery.is(this, selector);
  1750. },
  1751. <span id='Ext-AbstractComponent-method-up'> /**
  1752. </span> * Walks up the `ownerCt` axis looking for an ancestor Container which matches the passed simple selector.
  1753. *
  1754. * Example:
  1755. *
  1756. * var owningTabPanel = grid.up('tabpanel');
  1757. *
  1758. * @param {String} [selector] The simple selector to test.
  1759. * @return {Ext.container.Container} The matching ancestor Container (or `undefined` if no match was found).
  1760. */
  1761. up: function(selector) {
  1762. // Use bubble target to navigate upwards so that Components can implement their own hierarchy.
  1763. // For example Menus implement getBubbleTarget because they have a parentMenu or ownerButton as an
  1764. // upward link depending upon how they are owned and triggered.
  1765. var result = this.getBubbleTarget();
  1766. if (selector) {
  1767. for (; result; result = result.getBubbleTarget()) {
  1768. if (Ext.ComponentQuery.is(result, selector)) {
  1769. return result;
  1770. }
  1771. }
  1772. }
  1773. return result;
  1774. },
  1775. <span id='Ext-AbstractComponent-method-nextSibling'> /**
  1776. </span> * Returns the next sibling of this Component.
  1777. *
  1778. * Optionally selects the next sibling which matches the passed {@link Ext.ComponentQuery ComponentQuery} selector.
  1779. *
  1780. * May also be refered to as **`next()`**
  1781. *
  1782. * Note that this is limited to siblings, and if no siblings of the item match, `null` is returned. Contrast with
  1783. * {@link #nextNode}
  1784. * @param {String} [selector] A {@link Ext.ComponentQuery ComponentQuery} selector to filter the following items.
  1785. * @return {Ext.Component} The next sibling (or the next sibling which matches the selector).
  1786. * Returns null if there is no matching sibling.
  1787. */
  1788. nextSibling: function(selector) {
  1789. var o = this.ownerCt, it, last, idx, c;
  1790. if (o) {
  1791. it = o.items;
  1792. idx = it.indexOf(this) + 1;
  1793. if (idx) {
  1794. if (selector) {
  1795. for (last = it.getCount(); idx &lt; last; idx++) {
  1796. if ((c = it.getAt(idx)).is(selector)) {
  1797. return c;
  1798. }
  1799. }
  1800. } else {
  1801. if (idx &lt; it.getCount()) {
  1802. return it.getAt(idx);
  1803. }
  1804. }
  1805. }
  1806. }
  1807. return null;
  1808. },
  1809. <span id='Ext-AbstractComponent-method-previousSibling'> /**
  1810. </span> * Returns the previous sibling of this Component.
  1811. *
  1812. * Optionally selects the previous sibling which matches the passed {@link Ext.ComponentQuery ComponentQuery}
  1813. * selector.
  1814. *
  1815. * May also be refered to as **`prev()`**
  1816. *
  1817. * Note that this is limited to siblings, and if no siblings of the item match, `null` is returned. Contrast with
  1818. * {@link #previousNode}
  1819. * @param {String} [selector] A {@link Ext.ComponentQuery ComponentQuery} selector to filter the preceding items.
  1820. * @return {Ext.Component} The previous sibling (or the previous sibling which matches the selector).
  1821. * Returns null if there is no matching sibling.
  1822. */
  1823. previousSibling: function(selector) {
  1824. var o = this.ownerCt, it, idx, c;
  1825. if (o) {
  1826. it = o.items;
  1827. idx = it.indexOf(this);
  1828. if (idx != -1) {
  1829. if (selector) {
  1830. for (--idx; idx &gt;= 0; idx--) {
  1831. if ((c = it.getAt(idx)).is(selector)) {
  1832. return c;
  1833. }
  1834. }
  1835. } else {
  1836. if (idx) {
  1837. return it.getAt(--idx);
  1838. }
  1839. }
  1840. }
  1841. }
  1842. return null;
  1843. },
  1844. <span id='Ext-AbstractComponent-method-previousNode'> /**
  1845. </span> * Returns the previous node in the Component tree in tree traversal order.
  1846. *
  1847. * Note that this is not limited to siblings, and if invoked upon a node with no matching siblings, will walk the
  1848. * tree in reverse order to attempt to find a match. Contrast with {@link #previousSibling}.
  1849. * @param {String} [selector] A {@link Ext.ComponentQuery ComponentQuery} selector to filter the preceding nodes.
  1850. * @return {Ext.Component} The previous node (or the previous node which matches the selector).
  1851. * Returns null if there is no matching node.
  1852. */
  1853. previousNode: function(selector, /* private */ includeSelf) {
  1854. var node = this,
  1855. ownerCt = node.ownerCt,
  1856. result,
  1857. it, i, sib;
  1858. // If asked to include self, test me
  1859. if (includeSelf &amp;&amp; node.is(selector)) {
  1860. return node;
  1861. }
  1862. if (ownerCt) {
  1863. for (it = ownerCt.items.items, i = Ext.Array.indexOf(it, node) - 1; i &gt; -1; i--) {
  1864. sib = it[i];
  1865. if (sib.query) {
  1866. result = sib.query(selector);
  1867. result = result[result.length - 1];
  1868. if (result) {
  1869. return result;
  1870. }
  1871. }
  1872. if (sib.is(selector)) {
  1873. return sib;
  1874. }
  1875. }
  1876. return ownerCt.previousNode(selector, true);
  1877. }
  1878. return null;
  1879. },
  1880. <span id='Ext-AbstractComponent-method-nextNode'> /**
  1881. </span> * Returns the next node in the Component tree in tree traversal order.
  1882. *
  1883. * Note that this is not limited to siblings, and if invoked upon a node with no matching siblings, will walk the
  1884. * tree to attempt to find a match. Contrast with {@link #nextSibling}.
  1885. * @param {String} [selector] A {@link Ext.ComponentQuery ComponentQuery} selector to filter the following nodes.
  1886. * @return {Ext.Component} The next node (or the next node which matches the selector).
  1887. * Returns null if there is no matching node.
  1888. */
  1889. nextNode: function(selector, /* private */ includeSelf) {
  1890. var node = this,
  1891. ownerCt = node.ownerCt,
  1892. result,
  1893. it, len, i, sib;
  1894. // If asked to include self, test me
  1895. if (includeSelf &amp;&amp; node.is(selector)) {
  1896. return node;
  1897. }
  1898. if (ownerCt) {
  1899. for (it = ownerCt.items.items, i = Ext.Array.indexOf(it, node) + 1, len = it.length; i &lt; len; i++) {
  1900. sib = it[i];
  1901. if (sib.is(selector)) {
  1902. return sib;
  1903. }
  1904. if (sib.down) {
  1905. result = sib.down(selector);
  1906. if (result) {
  1907. return result;
  1908. }
  1909. }
  1910. }
  1911. return ownerCt.nextNode(selector);
  1912. }
  1913. return null;
  1914. },
  1915. <span id='Ext-AbstractComponent-method-getId'> /**
  1916. </span> * Retrieves the id of this component. Will autogenerate an id if one has not already been set.
  1917. * @return {String}
  1918. */
  1919. getId : function() {
  1920. return this.id || (this.id = 'ext-comp-' + (this.getAutoId()));
  1921. },
  1922. <span id='Ext-AbstractComponent-method-getItemId'> /**
  1923. </span> * Returns the value of {@link #itemId} assigned to this component, or when that
  1924. * is not set, returns the value of {@link #id}.
  1925. * @return {String}
  1926. */
  1927. getItemId : function() {
  1928. return this.itemId || this.id;
  1929. },
  1930. <span id='Ext-AbstractComponent-method-getEl'> /**
  1931. </span> * Retrieves the top level element representing this component.
  1932. * @return {Ext.dom.Element}
  1933. */
  1934. getEl : function() {
  1935. return this.el;
  1936. },
  1937. <span id='Ext-AbstractComponent-method-getTargetEl'> /**
  1938. </span> * This is used to determine where to insert the 'html', 'contentEl' and 'items' in this component.
  1939. * @private
  1940. */
  1941. getTargetEl: function() {
  1942. return this.frameBody || this.el;
  1943. },
  1944. <span id='Ext-AbstractComponent-method-getOverflowStyle'> /**
  1945. </span> * @private
  1946. * Returns the CSS style object which will set the Component's scroll styles. This must be applied
  1947. * to the {@link #getTargetEl target element}.
  1948. */
  1949. getOverflowStyle: function() {
  1950. var me = this,
  1951. result = null;
  1952. if (typeof me.autoScroll == 'boolean') {
  1953. result = {
  1954. overflow: me.autoScroll ? 'auto' : ''
  1955. };
  1956. } else if (me.overflowX !== undefined || me.overflowY !== undefined) {
  1957. result = {
  1958. 'overflow-x': (me.overflowX||''),
  1959. 'overflow-y': (me.overflowY||'')
  1960. };
  1961. }
  1962. // The scrollable container element must be non-statically positioned or IE6/7 will make
  1963. // positioned children stay in place rather than scrolling with the rest of the content
  1964. if (result &amp;&amp; (Ext.isIE6 || Ext.isIE7)) {
  1965. result.position = 'relative';
  1966. }
  1967. return result;
  1968. },
  1969. <span id='Ext-AbstractComponent-method-isXType'> /**
  1970. </span> * Tests whether or not this Component is of a specific xtype. This can test whether this Component is descended
  1971. * from the xtype (default) or whether it is directly of the xtype specified (shallow = true).
  1972. *
  1973. * **If using your own subclasses, be aware that a Component must register its own xtype to participate in
  1974. * determination of inherited xtypes.**
  1975. *
  1976. * For a list of all available xtypes, see the {@link Ext.Component} header.
  1977. *
  1978. * Example usage:
  1979. *
  1980. * var t = new Ext.form.field.Text();
  1981. * var isText = t.isXType('textfield'); // true
  1982. * var isBoxSubclass = t.isXType('field'); // true, descended from Ext.form.field.Base
  1983. * var isBoxInstance = t.isXType('field', true); // false, not a direct Ext.form.field.Base instance
  1984. *
  1985. * @param {String} xtype The xtype to check for this Component
  1986. * @param {Boolean} [shallow=false] True to check whether this Component is directly of the specified xtype, false to
  1987. * check whether this Component is descended from the xtype.
  1988. * @return {Boolean} True if this component descends from the specified xtype, false otherwise.
  1989. */
  1990. isXType: function(xtype, shallow) {
  1991. if (shallow) {
  1992. return this.xtype === xtype;
  1993. }
  1994. else {
  1995. return this.xtypesMap[xtype];
  1996. }
  1997. },
  1998. <span id='Ext-AbstractComponent-method-getXTypes'> /**
  1999. </span> * Returns this Component's xtype hierarchy as a slash-delimited string. For a list of all available xtypes, see the
  2000. * {@link Ext.Component} header.
  2001. *
  2002. * **If using your own subclasses, be aware that a Component must register its own xtype to participate in
  2003. * determination of inherited xtypes.**
  2004. *
  2005. * Example usage:
  2006. *
  2007. * var t = new Ext.form.field.Text();
  2008. * alert(t.getXTypes()); // alerts 'component/field/textfield'
  2009. *
  2010. * @return {String} The xtype hierarchy string
  2011. */
  2012. getXTypes: function() {
  2013. var self = this.self,
  2014. xtypes, parentPrototype, parentXtypes;
  2015. if (!self.xtypes) {
  2016. xtypes = [];
  2017. parentPrototype = this;
  2018. while (parentPrototype) {
  2019. parentXtypes = parentPrototype.xtypes;
  2020. if (parentXtypes !== undefined) {
  2021. xtypes.unshift.apply(xtypes, parentXtypes);
  2022. }
  2023. parentPrototype = parentPrototype.superclass;
  2024. }
  2025. self.xtypeChain = xtypes;
  2026. self.xtypes = xtypes.join('/');
  2027. }
  2028. return self.xtypes;
  2029. },
  2030. <span id='Ext-AbstractComponent-method-update'> /**
  2031. </span> * Update the content area of a component.
  2032. * @param {String/Object} htmlOrData If this component has been configured with a template via the tpl config then
  2033. * it will use this argument as data to populate the template. If this component was not configured with a template,
  2034. * the components content area will be updated via Ext.Element update
  2035. * @param {Boolean} [loadScripts=false] Only legitimate when using the html configuration.
  2036. * @param {Function} [callback] Only legitimate when using the html configuration. Callback to execute when
  2037. * scripts have finished loading
  2038. */
  2039. update : function(htmlOrData, loadScripts, cb) {
  2040. var me = this;
  2041. if (me.tpl &amp;&amp; !Ext.isString(htmlOrData)) {
  2042. me.data = htmlOrData;
  2043. if (me.rendered) {
  2044. me.tpl[me.tplWriteMode](me.getTargetEl(), htmlOrData || {});
  2045. }
  2046. } else {
  2047. me.html = Ext.isObject(htmlOrData) ? Ext.DomHelper.markup(htmlOrData) : htmlOrData;
  2048. if (me.rendered) {
  2049. me.getTargetEl().update(me.html, loadScripts, cb);
  2050. }
  2051. }
  2052. if (me.rendered) {
  2053. me.updateLayout();
  2054. }
  2055. },
  2056. <span id='Ext-AbstractComponent-method-setVisible'> /**
  2057. </span> * Convenience function to hide or show this component by boolean.
  2058. * @param {Boolean} visible True to show, false to hide
  2059. * @return {Ext.Component} this
  2060. */
  2061. setVisible : function(visible) {
  2062. return this[visible ? 'show': 'hide']();
  2063. },
  2064. <span id='Ext-AbstractComponent-method-isVisible'> /**
  2065. </span> * Returns true if this component is visible.
  2066. *
  2067. * @param {Boolean} [deep=false] Pass `true` to interrogate the visibility status of all parent Containers to
  2068. * determine whether this Component is truly visible to the user.
  2069. *
  2070. * Generally, to determine whether a Component is hidden, the no argument form is needed. For example when creating
  2071. * dynamically laid out UIs in a hidden Container before showing them.
  2072. *
  2073. * @return {Boolean} True if this component is visible, false otherwise.
  2074. */
  2075. isVisible: function(deep) {
  2076. var me = this,
  2077. child = me,
  2078. visible = me.rendered &amp;&amp; !me.hidden,
  2079. ancestor = me.ownerCt;
  2080. // Clear hiddenOwnerCt property
  2081. me.hiddenAncestor = false;
  2082. if (me.destroyed) {
  2083. return false;
  2084. }
  2085. if (deep &amp;&amp; visible &amp;&amp; ancestor) {
  2086. while (ancestor) {
  2087. // If any ancestor is hidden, then this is hidden.
  2088. // If an ancestor Panel (only Panels have a collapse method) is collapsed,
  2089. // then its layoutTarget (body) is hidden, so this is hidden unless its within a
  2090. // docked item; they are still visible when collapsed (Unless they themseves are hidden)
  2091. if (ancestor.hidden || (ancestor.collapsed &amp;&amp;
  2092. !(ancestor.getDockedItems &amp;&amp; Ext.Array.contains(ancestor.getDockedItems(), child)))) {
  2093. // Store hiddenOwnerCt property if needed
  2094. me.hiddenAncestor = ancestor;
  2095. visible = false;
  2096. break;
  2097. }
  2098. child = ancestor;
  2099. ancestor = ancestor.ownerCt;
  2100. }
  2101. }
  2102. return visible;
  2103. },
  2104. onBoxReady: function(){
  2105. var me = this;
  2106. if (me.disableOnBoxReady) {
  2107. me.onDisable();
  2108. } else if (me.enableOnBoxReady) {
  2109. me.onEnable();
  2110. }
  2111. if (me.resizable) {
  2112. me.initResizable(me.resizable);
  2113. }
  2114. // Draggability must be initialized after resizability
  2115. // Because if we have to be wrapped, the resizer wrapper must be dragged as a pseudo-Component
  2116. if (me.draggable) {
  2117. me.initDraggable();
  2118. }
  2119. },
  2120. <span id='Ext-AbstractComponent-method-enable'> /**
  2121. </span> * Enable the component
  2122. * @param {Boolean} [silent=false] Passing true will supress the 'enable' event from being fired.
  2123. */
  2124. enable: function(silent) {
  2125. var me = this;
  2126. delete me.disableOnBoxReady;
  2127. me.removeCls(me.disabledCls);
  2128. if (me.rendered) {
  2129. me.onEnable();
  2130. } else {
  2131. me.enableOnBoxReady = true;
  2132. }
  2133. me.disabled = false;
  2134. delete me.resetDisable;
  2135. if (silent !== true) {
  2136. me.fireEvent('enable', me);
  2137. }
  2138. return me;
  2139. },
  2140. <span id='Ext-AbstractComponent-method-disable'> /**
  2141. </span> * Disable the component.
  2142. * @param {Boolean} [silent=false] Passing true will supress the 'disable' event from being fired.
  2143. */
  2144. disable: function(silent) {
  2145. var me = this;
  2146. delete me.enableOnBoxReady;
  2147. me.addCls(me.disabledCls);
  2148. if (me.rendered) {
  2149. me.onDisable();
  2150. } else {
  2151. me.disableOnBoxReady = true;
  2152. }
  2153. me.disabled = true;
  2154. if (silent !== true) {
  2155. delete me.resetDisable;
  2156. me.fireEvent('disable', me);
  2157. }
  2158. return me;
  2159. },
  2160. <span id='Ext-AbstractComponent-method-onEnable'> /**
  2161. </span> * Allows addition of behavior to the enable operation.
  2162. * After calling the superclass’s onEnable, the Component will be enabled.
  2163. *
  2164. * @template
  2165. * @protected
  2166. */
  2167. onEnable: function() {
  2168. if (this.maskOnDisable) {
  2169. this.el.dom.disabled = false;
  2170. this.unmask();
  2171. }
  2172. },
  2173. <span id='Ext-AbstractComponent-method-onDisable'> /**
  2174. </span> * Allows addition of behavior to the disable operation.
  2175. * After calling the superclass’s onDisable, the Component will be disabled.
  2176. *
  2177. * @template
  2178. * @protected
  2179. */
  2180. onDisable : function() {
  2181. var me = this,
  2182. focusCls = me.focusCls,
  2183. focusEl = me.getFocusEl();
  2184. if (focusCls &amp;&amp; focusEl) {
  2185. focusEl.removeCls(me.removeClsWithUI(focusCls, true));
  2186. }
  2187. if (me.maskOnDisable) {
  2188. me.el.dom.disabled = true;
  2189. me.mask();
  2190. }
  2191. },
  2192. mask: function() {
  2193. var box = this.lastBox,
  2194. target = this.getMaskTarget(),
  2195. args = [];
  2196. // Pass it the height of our element if we know it.
  2197. if (box) {
  2198. args[2] = box.height;
  2199. }
  2200. target.mask.apply(target, args);
  2201. },
  2202. unmask: function() {
  2203. this.getMaskTarget().unmask();
  2204. },
  2205. getMaskTarget: function(){
  2206. return this.el;
  2207. },
  2208. <span id='Ext-AbstractComponent-method-isDisabled'> /**
  2209. </span> * Method to determine whether this Component is currently disabled.
  2210. * @return {Boolean} the disabled state of this Component.
  2211. */
  2212. isDisabled : function() {
  2213. return this.disabled;
  2214. },
  2215. <span id='Ext-AbstractComponent-method-setDisabled'> /**
  2216. </span> * Enable or disable the component.
  2217. * @param {Boolean} disabled True to disable.
  2218. */
  2219. setDisabled : function(disabled) {
  2220. return this[disabled ? 'disable': 'enable']();
  2221. },
  2222. <span id='Ext-AbstractComponent-method-isHidden'> /**
  2223. </span> * Method to determine whether this Component is currently set to hidden.
  2224. * @return {Boolean} the hidden state of this Component.
  2225. */
  2226. isHidden : function() {
  2227. return this.hidden;
  2228. },
  2229. <span id='Ext-AbstractComponent-method-addCls'> /**
  2230. </span> * Adds a CSS class to the top level element representing this component.
  2231. * @param {String/String[]} cls The CSS class name to add
  2232. * @return {Ext.Component} Returns the Component to allow method chaining.
  2233. */
  2234. addCls : function(cls) {
  2235. var me = this,
  2236. el = me.rendered ? me.el : me.protoEl;
  2237. el.addCls.apply(el, arguments);
  2238. return me;
  2239. },
  2240. <span id='Ext-AbstractComponent-method-addClass'> /**
  2241. </span> * @inheritdoc Ext.AbstractComponent#addCls
  2242. * @deprecated 4.1 Use {@link #addCls} instead.
  2243. */
  2244. addClass : function() {
  2245. return this.addCls.apply(this, arguments);
  2246. },
  2247. <span id='Ext-AbstractComponent-method-hasCls'> /**
  2248. </span> * Checks if the specified CSS class exists on this element's DOM node.
  2249. * @param {String} className The CSS class to check for
  2250. * @return {Boolean} True if the class exists, else false
  2251. * @method
  2252. */
  2253. hasCls: function (cls) {
  2254. var me = this,
  2255. el = me.rendered ? me.el : me.protoEl;
  2256. return el.hasCls.apply(el, arguments);
  2257. },
  2258. <span id='Ext-AbstractComponent-method-removeCls'> /**
  2259. </span> * Removes a CSS class from the top level element representing this component.
  2260. * @param {String/String[]} cls The CSS class name to remove
  2261. * @returns {Ext.Component} Returns the Component to allow method chaining.
  2262. */
  2263. removeCls : function(cls) {
  2264. var me = this,
  2265. el = me.rendered ? me.el : me.protoEl;
  2266. el.removeCls.apply(el, arguments);
  2267. return me;
  2268. },
  2269. //&lt;debug&gt;
  2270. removeClass : function() {
  2271. if (Ext.isDefined(Ext.global.console)) {
  2272. Ext.global.console.warn('Ext.Component: removeClass has been deprecated. Please use removeCls.');
  2273. }
  2274. return this.removeCls.apply(this, arguments);
  2275. },
  2276. //&lt;/debug&gt;
  2277. addOverCls: function() {
  2278. var me = this;
  2279. if (!me.disabled) {
  2280. me.el.addCls(me.overCls);
  2281. }
  2282. },
  2283. removeOverCls: function() {
  2284. this.el.removeCls(this.overCls);
  2285. },
  2286. addListener : function(element, listeners, scope, options) {
  2287. var me = this,
  2288. fn,
  2289. option;
  2290. if (Ext.isString(element) &amp;&amp; (Ext.isObject(listeners) || options &amp;&amp; options.element)) {
  2291. if (options.element) {
  2292. fn = listeners;
  2293. listeners = {};
  2294. listeners[element] = fn;
  2295. element = options.element;
  2296. if (scope) {
  2297. listeners.scope = scope;
  2298. }
  2299. for (option in options) {
  2300. if (options.hasOwnProperty(option)) {
  2301. if (me.eventOptionsRe.test(option)) {
  2302. listeners[option] = options[option];
  2303. }
  2304. }
  2305. }
  2306. }
  2307. // At this point we have a variable called element,
  2308. // and a listeners object that can be passed to on
  2309. if (me[element] &amp;&amp; me[element].on) {
  2310. me.mon(me[element], listeners);
  2311. } else {
  2312. me.afterRenderEvents = me.afterRenderEvents || {};
  2313. if (!me.afterRenderEvents[element]) {
  2314. me.afterRenderEvents[element] = [];
  2315. }
  2316. me.afterRenderEvents[element].push(listeners);
  2317. }
  2318. }
  2319. return me.mixins.observable.addListener.apply(me, arguments);
  2320. },
  2321. // inherit docs
  2322. removeManagedListenerItem: function(isClear, managedListener, item, ename, fn, scope){
  2323. var me = this,
  2324. element = managedListener.options ? managedListener.options.element : null;
  2325. if (element) {
  2326. element = me[element];
  2327. if (element &amp;&amp; element.un) {
  2328. if (isClear || (managedListener.item === item &amp;&amp; managedListener.ename === ename &amp;&amp; (!fn || managedListener.fn === fn) &amp;&amp; (!scope || managedListener.scope === scope))) {
  2329. element.un(managedListener.ename, managedListener.fn, managedListener.scope);
  2330. if (!isClear) {
  2331. Ext.Array.remove(me.managedListeners, managedListener);
  2332. }
  2333. }
  2334. }
  2335. } else {
  2336. return me.mixins.observable.removeManagedListenerItem.apply(me, arguments);
  2337. }
  2338. },
  2339. <span id='Ext-AbstractComponent-method-getBubbleTarget'> /**
  2340. </span> * Provides the link for Observable's fireEvent method to bubble up the ownership hierarchy.
  2341. * @return {Ext.container.Container} the Container which owns this Component.
  2342. */
  2343. getBubbleTarget : function() {
  2344. return this.ownerCt;
  2345. },
  2346. <span id='Ext-AbstractComponent-method-isFloating'> /**
  2347. </span> * Method to determine whether this Component is floating.
  2348. * @return {Boolean} the floating state of this component.
  2349. */
  2350. isFloating : function() {
  2351. return this.floating;
  2352. },
  2353. <span id='Ext-AbstractComponent-method-isDraggable'> /**
  2354. </span> * Method to determine whether this Component is draggable.
  2355. * @return {Boolean} the draggable state of this component.
  2356. */
  2357. isDraggable : function() {
  2358. return !!this.draggable;
  2359. },
  2360. <span id='Ext-AbstractComponent-method-isDroppable'> /**
  2361. </span> * Method to determine whether this Component is droppable.
  2362. * @return {Boolean} the droppable state of this component.
  2363. */
  2364. isDroppable : function() {
  2365. return !!this.droppable;
  2366. },
  2367. <span id='Ext-AbstractComponent-method-onAdded'> /**
  2368. </span> * Method to manage awareness of when components are added to their
  2369. * respective Container, firing an #added event. References are
  2370. * established at add time rather than at render time.
  2371. *
  2372. * Allows addition of behavior when a Component is added to a
  2373. * Container. At this stage, the Component is in the parent
  2374. * Container's collection of child items. After calling the
  2375. * superclass's onAdded, the ownerCt reference will be present,
  2376. * and if configured with a ref, the refOwner will be set.
  2377. *
  2378. * @param {Ext.container.Container} container Container which holds the component
  2379. * @param {Number} pos Position at which the component was added
  2380. *
  2381. * @template
  2382. * @protected
  2383. */
  2384. onAdded : function(container, pos) {
  2385. var me = this;
  2386. me.ownerCt = container;
  2387. if (me.hasListeners.added) {
  2388. me.fireEvent('added', me, container, pos);
  2389. }
  2390. },
  2391. <span id='Ext-AbstractComponent-method-onRemoved'> /**
  2392. </span> * Method to manage awareness of when components are removed from their
  2393. * respective Container, firing a #removed event. References are properly
  2394. * cleaned up after removing a component from its owning container.
  2395. *
  2396. * Allows addition of behavior when a Component is removed from
  2397. * its parent Container. At this stage, the Component has been
  2398. * removed from its parent Container's collection of child items,
  2399. * but has not been destroyed (It will be destroyed if the parent
  2400. * Container's autoDestroy is true, or if the remove call was
  2401. * passed a truthy second parameter). After calling the
  2402. * superclass's onRemoved, the ownerCt and the refOwner will not
  2403. * be present.
  2404. * @param {Boolean} destroying Will be passed as true if the Container performing the remove operation will delete this
  2405. * Component upon remove.
  2406. *
  2407. * @template
  2408. * @protected
  2409. */
  2410. onRemoved : function(destroying) {
  2411. var me = this;
  2412. if (me.hasListeners.removed) {
  2413. me.fireEvent('removed', me, me.ownerCt);
  2414. }
  2415. delete me.ownerCt;
  2416. delete me.ownerLayout;
  2417. },
  2418. <span id='Ext-AbstractComponent-method-beforeDestroy'> /**
  2419. </span> * Invoked before the Component is destroyed.
  2420. *
  2421. * @method
  2422. * @template
  2423. * @protected
  2424. */
  2425. beforeDestroy : Ext.emptyFn,
  2426. <span id='Ext-AbstractComponent-method-onResize'> /**
  2427. </span> * Allows addition of behavior to the resize operation.
  2428. *
  2429. * Called when Ext.resizer.Resizer#drag event is fired.
  2430. *
  2431. * @method
  2432. * @template
  2433. * @protected
  2434. */
  2435. onResize : Ext.emptyFn,
  2436. <span id='Ext-AbstractComponent-method-setSize'> /**
  2437. </span> * Sets the width and height of this Component. This method fires the {@link #resize} event. This method can accept
  2438. * either width and height as separate arguments, or you can pass a size object like `{width:10, height:20}`.
  2439. *
  2440. * @param {Number/String/Object} width The new width to set. This may be one of:
  2441. *
  2442. * - A Number specifying the new width in the {@link #getEl Element}'s {@link Ext.Element#defaultUnit}s (by default, pixels).
  2443. * - A String used to set the CSS width style.
  2444. * - A size object in the format `{width: widthValue, height: heightValue}`.
  2445. * - `undefined` to leave the width unchanged.
  2446. *
  2447. * @param {Number/String} height The new height to set (not required if a size object is passed as the first arg).
  2448. * This may be one of:
  2449. *
  2450. * - A Number specifying the new height in the {@link #getEl Element}'s {@link Ext.Element#defaultUnit}s (by default, pixels).
  2451. * - A String used to set the CSS height style. Animation may **not** be used.
  2452. * - `undefined` to leave the height unchanged.
  2453. *
  2454. * @return {Ext.Component} this
  2455. */
  2456. setSize : function(width, height) {
  2457. var me = this;
  2458. // support for standard size objects
  2459. if (width &amp;&amp; typeof width == 'object') {
  2460. height = width.height;
  2461. width = width.width;
  2462. }
  2463. // Constrain within configured maxima
  2464. if (typeof width == 'number') {
  2465. me.width = Ext.Number.constrain(width, me.minWidth, me.maxWidth);
  2466. } else if (width === null) {
  2467. delete me.width;
  2468. }
  2469. if (typeof height == 'number') {
  2470. me.height = Ext.Number.constrain(height, me.minHeight, me.maxHeight);
  2471. } else if (height === null) {
  2472. delete me.height;
  2473. }
  2474. // If not rendered, all we need to is set the properties.
  2475. // The initial layout will set the size
  2476. if (me.rendered &amp;&amp; me.isVisible()) {
  2477. // If we are changing size, then we are not the root.
  2478. me.updateLayout({
  2479. isRoot: false
  2480. });
  2481. }
  2482. return me;
  2483. },
  2484. <span id='Ext-AbstractComponent-method-isLayoutRoot'> /**
  2485. </span> * Determines whether this Component is the root of a layout. This returns `true` if
  2486. * this component can run its layout without assistance from or impact on its owner.
  2487. * If this component cannot run its layout given these restrictions, `false` is returned
  2488. * and its owner will be considered as the next candidate for the layout root.
  2489. *
  2490. * Setting the {@link #_isLayoutRoot} property to `true` causes this method to always
  2491. * return `true`. This may be useful when updating a layout of a Container which shrink
  2492. * wraps content, and you know that it will not change size, and so can safely be the
  2493. * topmost participant in the layout run.
  2494. * @protected
  2495. */
  2496. isLayoutRoot: function() {
  2497. var me = this,
  2498. ownerLayout = me.ownerLayout;
  2499. // Return true if we have been explicitly flagged as the layout root, or if we are floating.
  2500. // Sometimes floating Components get an ownerCt ref injected into them which is *not* a true ownerCt, merely
  2501. // an upward link for reference purposes. For example a grid column menu is linked to the
  2502. // owning header via an ownerCt reference.
  2503. if (!ownerLayout || me._isLayoutRoot || me.floating) {
  2504. return true;
  2505. }
  2506. return ownerLayout.isItemLayoutRoot(me);
  2507. },
  2508. <span id='Ext-AbstractComponent-method-isLayoutSuspended'> /**
  2509. </span> * Returns true if layout is suspended for this component. This can come from direct
  2510. * suspension of this component's layout activity ({@link Ext.Container#suspendLayout}) or if one
  2511. * of this component's containers is suspended.
  2512. *
  2513. * @return {Boolean} True layout of this component is suspended.
  2514. */
  2515. isLayoutSuspended: function () {
  2516. var comp = this,
  2517. ownerLayout;
  2518. while (comp) {
  2519. if (comp.layoutSuspendCount || comp.suspendLayout) {
  2520. return true;
  2521. }
  2522. ownerLayout = comp.ownerLayout;
  2523. if (!ownerLayout) {
  2524. break;
  2525. }
  2526. // TODO - what about suspending a Layout instance?
  2527. // this works better than ownerCt since ownerLayout means &quot;is managed by&quot; in
  2528. // the proper sense... some floating components have ownerCt but won't have an
  2529. // ownerLayout
  2530. comp = ownerLayout.owner;
  2531. }
  2532. return false;
  2533. },
  2534. <span id='Ext-AbstractComponent-method-updateLayout'> /**
  2535. </span> * Updates this component's layout. If this update effects this components {@link #ownerCt},
  2536. * that component's `updateLayout` method will be called to perform the layout instead.
  2537. * Otherwise, just this component (and its child items) will layout.
  2538. *
  2539. * @param {Object} options An object with layout options.
  2540. * @param {Boolean} options.defer True if this layout should be deferred.
  2541. * @param {Boolean} options.isRoot True if this layout should be the root of the layout.
  2542. */
  2543. updateLayout: function (options) {
  2544. var me = this,
  2545. defer,
  2546. isRoot = options &amp;&amp; options.isRoot;
  2547. if (!me.rendered || me.layoutSuspendCount || me.suspendLayout) {
  2548. return;
  2549. }
  2550. if (me.hidden) {
  2551. Ext.AbstractComponent.cancelLayout(me);
  2552. } else if (typeof isRoot != 'boolean') {
  2553. isRoot = me.isLayoutRoot();
  2554. }
  2555. // if we aren't the root, see if our ownerLayout will handle it...
  2556. if (isRoot || !me.ownerLayout || !me.ownerLayout.onContentChange(me)) {
  2557. // either we are the root or our ownerLayout doesn't care
  2558. if (!me.isLayoutSuspended()) {
  2559. // we aren't suspended (knew that), but neither is any of our ownerCt's...
  2560. defer = (options &amp;&amp; options.hasOwnProperty('defer')) ? options.defer : me.deferLayouts;
  2561. Ext.AbstractComponent.updateLayout(me, defer);
  2562. }
  2563. }
  2564. },
  2565. <span id='Ext-AbstractComponent-method-getSizeModel'> /**
  2566. </span> * Returns an object that describes how this component's width and height are managed.
  2567. * All of these objects are shared and should not be modified.
  2568. *
  2569. * @return {Object} The size model for this component.
  2570. * @return {Ext.layout.SizeModel} return.width The {@link Ext.layout.SizeModel size model}
  2571. * for the width.
  2572. * @return {Ext.layout.SizeModel} return.height The {@link Ext.layout.SizeModel size model}
  2573. * for the height.
  2574. */
  2575. getSizeModel: function (ownerCtSizeModel) {
  2576. var me = this,
  2577. models = Ext.layout.SizeModel,
  2578. ownerContext = me.componentLayout.ownerContext,
  2579. width = me.width,
  2580. height = me.height,
  2581. typeofWidth, typeofHeight,
  2582. hasPixelWidth, hasPixelHeight,
  2583. heightModel, ownerLayout, policy, shrinkWrap, topLevel, widthModel;
  2584. if (ownerContext) {
  2585. // If we are in the middle of a running layout, always report the current,
  2586. // dynamic size model rather than recompute it. This is not (only) a time
  2587. // saving thing, but a correctness thing since we cannot get the right answer
  2588. // otherwise.
  2589. widthModel = ownerContext.widthModel;
  2590. heightModel = ownerContext.heightModel;
  2591. }
  2592. if (!widthModel || !heightModel) {
  2593. hasPixelWidth = ((typeofWidth = typeof width) == 'number');
  2594. hasPixelHeight = ((typeofHeight = typeof height) == 'number');
  2595. topLevel = me.floating || !(ownerLayout = me.ownerLayout);
  2596. // Floating or no owner layout, e.g. rendered using renderTo
  2597. if (topLevel) {
  2598. policy = Ext.layout.Layout.prototype.autoSizePolicy;
  2599. shrinkWrap = me.floating ? 3 : me.shrinkWrap;
  2600. if (hasPixelWidth) {
  2601. widthModel = models.configured;
  2602. }
  2603. if (hasPixelHeight) {
  2604. heightModel = models.configured;
  2605. }
  2606. } else {
  2607. policy = ownerLayout.getItemSizePolicy(me, ownerCtSizeModel);
  2608. shrinkWrap = ownerLayout.isItemShrinkWrap(me);
  2609. }
  2610. shrinkWrap = (shrinkWrap === true) ? 3 : (shrinkWrap || 0); // false-&gt;0, true-&gt;3
  2611. // Now that we have shrinkWrap as a 0-3 value, we need to turn off shrinkWrap
  2612. // bits for any dimension that has a configured size not in pixels. These must
  2613. // be read from the DOM.
  2614. //
  2615. if (topLevel &amp;&amp; shrinkWrap) {
  2616. if (width &amp;&amp; typeofWidth == 'string') {
  2617. shrinkWrap &amp;= 2; // percentage, &quot;30em&quot; or whatever - not width shrinkWrap
  2618. }
  2619. if (height &amp;&amp; typeofHeight == 'string') {
  2620. shrinkWrap &amp;= 1; // percentage, &quot;30em&quot; or whatever - not height shrinkWrap
  2621. }
  2622. }
  2623. if (shrinkWrap !== 3) {
  2624. if (!ownerCtSizeModel) {
  2625. ownerCtSizeModel = me.ownerCt &amp;&amp; me.ownerCt.getSizeModel();
  2626. }
  2627. if (ownerCtSizeModel) {
  2628. shrinkWrap |= (ownerCtSizeModel.width.shrinkWrap ? 1 : 0) | (ownerCtSizeModel.height.shrinkWrap ? 2 : 0);
  2629. }
  2630. }
  2631. if (!widthModel) {
  2632. if (!policy.setsWidth) {
  2633. if (hasPixelWidth) {
  2634. widthModel = models.configured;
  2635. } else {
  2636. widthModel = (shrinkWrap &amp; 1) ? models.shrinkWrap : models.natural;
  2637. }
  2638. } else if (policy.readsWidth) {
  2639. if (hasPixelWidth) {
  2640. widthModel = models.calculatedFromConfigured;
  2641. } else {
  2642. widthModel = (shrinkWrap &amp; 1) ? models.calculatedFromShrinkWrap :
  2643. models.calculatedFromNatural;
  2644. }
  2645. } else {
  2646. widthModel = models.calculated;
  2647. }
  2648. }
  2649. if (!heightModel) {
  2650. if (!policy.setsHeight) {
  2651. if (hasPixelHeight) {
  2652. heightModel = models.configured;
  2653. } else {
  2654. heightModel = (shrinkWrap &amp; 2) ? models.shrinkWrap : models.natural;
  2655. }
  2656. } else if (policy.readsHeight) {
  2657. if (hasPixelHeight) {
  2658. heightModel = models.calculatedFromConfigured;
  2659. } else {
  2660. heightModel = (shrinkWrap &amp; 2) ? models.calculatedFromShrinkWrap :
  2661. models.calculatedFromNatural;
  2662. }
  2663. } else {
  2664. heightModel = models.calculated;
  2665. }
  2666. }
  2667. }
  2668. // We return one of the cached objects with the proper &quot;width&quot; and &quot;height&quot; as the
  2669. // sizeModels we have determined.
  2670. return widthModel.pairsByHeightOrdinal[heightModel.ordinal];
  2671. },
  2672. isDescendant: function(ancestor) {
  2673. if (ancestor.isContainer) {
  2674. for (var c = this.ownerCt; c; c = c.ownerCt) {
  2675. if (c === ancestor) {
  2676. return true;
  2677. }
  2678. }
  2679. }
  2680. return false;
  2681. },
  2682. <span id='Ext-AbstractComponent-method-doComponentLayout'> /**
  2683. </span> * This method needs to be called whenever you change something on this component that requires the Component's
  2684. * layout to be recalculated.
  2685. * @return {Ext.container.Container} this
  2686. */
  2687. doComponentLayout : function() {
  2688. this.updateLayout();
  2689. return this;
  2690. },
  2691. <span id='Ext-AbstractComponent-method-forceComponentLayout'> /**
  2692. </span> * Forces this component to redo its componentLayout.
  2693. * @deprecated 4.1.0 Use {@link #updateLayout} instead.
  2694. */
  2695. forceComponentLayout: function () {
  2696. this.updateLayout();
  2697. },
  2698. // @private
  2699. setComponentLayout : function(layout) {
  2700. var currentLayout = this.componentLayout;
  2701. if (currentLayout &amp;&amp; currentLayout.isLayout &amp;&amp; currentLayout != layout) {
  2702. currentLayout.setOwner(null);
  2703. }
  2704. this.componentLayout = layout;
  2705. layout.setOwner(this);
  2706. },
  2707. getComponentLayout : function() {
  2708. var me = this;
  2709. if (!me.componentLayout || !me.componentLayout.isLayout) {
  2710. me.setComponentLayout(Ext.layout.Layout.create(me.componentLayout, 'autocomponent'));
  2711. }
  2712. return me.componentLayout;
  2713. },
  2714. <span id='Ext-AbstractComponent-method-afterComponentLayout'> /**
  2715. </span> * Called by the layout system after the Component has been layed out.
  2716. *
  2717. * @param {Number} width The width that was set
  2718. * @param {Number} height The height that was set
  2719. * @param {Number} oldWidth The old width. &lt;code&gt;undefined&lt;/code&gt; if this was the initial layout.
  2720. * @param {Number} oldHeight The old height. &lt;code&gt;undefined&lt;/code&gt; if this was the initial layout.
  2721. *
  2722. * @template
  2723. * @protected
  2724. */
  2725. afterComponentLayout: function(width, height, oldWidth, oldHeight) {
  2726. var me = this,
  2727. floaters, len, i, floater;
  2728. if (++me.componentLayoutCounter === 1) {
  2729. me.afterFirstLayout(width, height);
  2730. }
  2731. // Contained autoShow items must be shown upon next layout of the Container
  2732. if (me.floatingItems) {
  2733. floaters = me.floatingItems.items;
  2734. len = floaters.length;
  2735. for (i = 0; i &lt; len; i++) {
  2736. floater = floaters[i];
  2737. if (!floater.rendered &amp;&amp; floater.autoShow) {
  2738. floater.show();
  2739. }
  2740. }
  2741. }
  2742. if (me.hasListeners.resize &amp;&amp; (width !== oldWidth || height !== oldHeight)) {
  2743. me.fireEvent('resize', me, width, height, oldWidth, oldHeight);
  2744. }
  2745. },
  2746. <span id='Ext-AbstractComponent-method-beforeComponentLayout'> /**
  2747. </span> * Occurs before componentLayout is run. Returning false from this method will prevent the componentLayout from
  2748. * being executed.
  2749. *
  2750. * @param {Number} adjWidth The box-adjusted width that was set
  2751. * @param {Number} adjHeight The box-adjusted height that was set
  2752. *
  2753. * @template
  2754. * @protected
  2755. */
  2756. beforeComponentLayout: function(width, height) {
  2757. return true;
  2758. },
  2759. <span id='Ext-AbstractComponent-method-setPosition'> /**
  2760. </span> * Sets the left and top of the component. To set the page XY position instead, use {@link Ext.Component#setPagePosition setPagePosition}. This
  2761. * method fires the {@link #move} event.
  2762. * @param {Number} left The new left
  2763. * @param {Number} top The new top
  2764. * @param {Boolean/Object} [animate] If true, the Component is _animated_ into its new position. You may also pass an
  2765. * animation configuration.
  2766. * @return {Ext.Component} this
  2767. */
  2768. setPosition : function(x, y, animate) {
  2769. var me = this,
  2770. pos = me.beforeSetPosition.apply(me, arguments);
  2771. if (pos &amp;&amp; me.rendered) {
  2772. // Convert position WRT RTL
  2773. pos = me.convertPosition(pos);
  2774. // Proceed only if the new position is different from the current one.
  2775. if (pos.left !== me.el.getLeft() || pos.top !== me.el.getTop()) {
  2776. if (animate) {
  2777. me.stopAnimation();
  2778. me.animate(Ext.apply({
  2779. duration: 1000,
  2780. listeners: {
  2781. afteranimate: Ext.Function.bind(me.afterSetPosition, me, [pos.left, pos.top])
  2782. },
  2783. to: pos
  2784. }, animate));
  2785. } else {
  2786. // Must use Element's methods to set element position because, if it is a Layer (floater), it may need to sync a shadow
  2787. // We must also only set the properties which are defined because Element.setLeftTop autos any undefined coordinates
  2788. if (pos.left !== undefined &amp;&amp; pos.top !== undefined) {
  2789. me.el.setLeftTop(pos.left, pos.top);
  2790. } else if (pos.left !== undefined) {
  2791. me.el.setLeft(pos.left);
  2792. } else if (pos.top !==undefined) {
  2793. me.el.setTop(pos.top);
  2794. }
  2795. me.afterSetPosition(pos.left, pos.top);
  2796. }
  2797. }
  2798. }
  2799. return me;
  2800. },
  2801. <span id='Ext-AbstractComponent-method-beforeSetPosition'> /**
  2802. </span> * @private Template method called before a Component is positioned.
  2803. */
  2804. beforeSetPosition: function (x, y, animate) {
  2805. var pos, x0;
  2806. // decode the position arguments:
  2807. if (!x || Ext.isNumber(x)) {
  2808. pos = { x: x, y : y, anim: animate };
  2809. } else if (Ext.isNumber(x0 = x[0])) { // an array of [x, y]
  2810. pos = { x : x0, y : x[1], anim: y };
  2811. } else {
  2812. pos = { x: x.x, y: x.y, anim: y }; // already an object w/ x &amp; y properties
  2813. }
  2814. pos.hasX = Ext.isNumber(pos.x);
  2815. pos.hasY = Ext.isNumber(pos.y);
  2816. // store the position as specified:
  2817. this.x = pos.x;
  2818. this.y = pos.y;
  2819. return (pos.hasX || pos.hasY) ? pos : null;
  2820. },
  2821. <span id='Ext-AbstractComponent-method-afterSetPosition'> /**
  2822. </span> * Template method called after a Component has been positioned.
  2823. *
  2824. * @param {Number} x
  2825. * @param {Number} y
  2826. *
  2827. * @template
  2828. * @protected
  2829. */
  2830. afterSetPosition: function(x, y) {
  2831. var me = this;
  2832. me.onPosition(x, y);
  2833. if (me.hasListeners.move) {
  2834. me.fireEvent('move', me, x, y);
  2835. }
  2836. },
  2837. <span id='Ext-AbstractComponent-method-convertPosition'> /**
  2838. </span> * This method converts an &quot;{x: x, y: y}&quot; object to a &quot;{left: x+'px', top: y+'px'}&quot; object.
  2839. * The returned object contains the styles to set to effect the position. This is
  2840. * overridden in RTL mode to be &quot;{right: x, top: y}&quot;.
  2841. * @private
  2842. */
  2843. convertPosition: function (pos, withUnits) {
  2844. var ret = {},
  2845. El = Ext.Element;
  2846. if (pos.hasX) {
  2847. ret.left = withUnits ? El.addUnits(pos.x) : pos.x;
  2848. }
  2849. if (pos.hasY) {
  2850. ret.top = withUnits ? El.addUnits(pos.y) : pos.y;
  2851. }
  2852. return ret;
  2853. },
  2854. <span id='Ext-AbstractComponent-method-onPosition'> /**
  2855. </span> * Called after the component is moved, this method is empty by default but can be implemented by any
  2856. * subclass that needs to perform custom logic after a move occurs.
  2857. *
  2858. * @param {Number} x The new x position
  2859. * @param {Number} y The new y position
  2860. *
  2861. * @template
  2862. * @protected
  2863. */
  2864. onPosition: Ext.emptyFn,
  2865. <span id='Ext-AbstractComponent-method-setWidth'> /**
  2866. </span> * Sets the width of the component. This method fires the {@link #resize} event.
  2867. *
  2868. * @param {Number} width The new width to setThis may be one of:
  2869. *
  2870. * - A Number specifying the new width in the {@link #getEl Element}'s {@link Ext.Element#defaultUnit}s (by default, pixels).
  2871. * - A String used to set the CSS width style.
  2872. *
  2873. * @return {Ext.Component} this
  2874. */
  2875. setWidth : function(width) {
  2876. return this.setSize(width);
  2877. },
  2878. <span id='Ext-AbstractComponent-method-setHeight'> /**
  2879. </span> * Sets the height of the component. This method fires the {@link #resize} event.
  2880. *
  2881. * @param {Number} height The new height to set. This may be one of:
  2882. *
  2883. * - A Number specifying the new height in the {@link #getEl Element}'s {@link Ext.Element#defaultUnit}s (by default, pixels).
  2884. * - A String used to set the CSS height style.
  2885. * - _undefined_ to leave the height unchanged.
  2886. *
  2887. * @return {Ext.Component} this
  2888. */
  2889. setHeight : function(height) {
  2890. return this.setSize(undefined, height);
  2891. },
  2892. <span id='Ext-AbstractComponent-method-getSize'> /**
  2893. </span> * Gets the current size of the component's underlying element.
  2894. * @return {Object} An object containing the element's size {width: (element width), height: (element height)}
  2895. */
  2896. getSize : function() {
  2897. return this.el.getSize();
  2898. },
  2899. <span id='Ext-AbstractComponent-method-getWidth'> /**
  2900. </span> * Gets the current width of the component's underlying element.
  2901. * @return {Number}
  2902. */
  2903. getWidth : function() {
  2904. return this.el.getWidth();
  2905. },
  2906. <span id='Ext-AbstractComponent-method-getHeight'> /**
  2907. </span> * Gets the current height of the component's underlying element.
  2908. * @return {Number}
  2909. */
  2910. getHeight : function() {
  2911. return this.el.getHeight();
  2912. },
  2913. <span id='Ext-AbstractComponent-method-getLoader'> /**
  2914. </span> * Gets the {@link Ext.ComponentLoader} for this Component.
  2915. * @return {Ext.ComponentLoader} The loader instance, null if it doesn't exist.
  2916. */
  2917. getLoader: function(){
  2918. var me = this,
  2919. autoLoad = me.autoLoad ? (Ext.isObject(me.autoLoad) ? me.autoLoad : {url: me.autoLoad}) : null,
  2920. loader = me.loader || autoLoad;
  2921. if (loader) {
  2922. if (!loader.isLoader) {
  2923. me.loader = new Ext.ComponentLoader(Ext.apply({
  2924. target: me,
  2925. autoLoad: autoLoad
  2926. }, loader));
  2927. } else {
  2928. loader.setTarget(me);
  2929. }
  2930. return me.loader;
  2931. }
  2932. return null;
  2933. },
  2934. <span id='Ext-AbstractComponent-method-setDocked'> /**
  2935. </span> * Sets the dock position of this component in its parent panel. Note that this only has effect if this item is part
  2936. * of the dockedItems collection of a parent that has a DockLayout (note that any Panel has a DockLayout by default)
  2937. * @param {Object} dock The dock position.
  2938. * @param {Boolean} [layoutParent=false] True to re-layout parent.
  2939. * @return {Ext.Component} this
  2940. */
  2941. setDocked : function(dock, layoutParent) {
  2942. var me = this;
  2943. me.dock = dock;
  2944. if (layoutParent &amp;&amp; me.ownerCt &amp;&amp; me.rendered) {
  2945. me.ownerCt.updateLayout();
  2946. }
  2947. return me;
  2948. },
  2949. <span id='Ext-AbstractComponent-method-setBorder'> /**
  2950. </span> *
  2951. * @param {String/Number} border The border, see {@link #border}. If a falsey value is passed
  2952. * the border will be removed.
  2953. */
  2954. setBorder: function(border, /* private */ targetEl) {
  2955. var me = this,
  2956. initial = !!targetEl;
  2957. if (me.rendered || initial) {
  2958. if (!initial) {
  2959. targetEl = me.el;
  2960. }
  2961. if (!border) {
  2962. border = 0;
  2963. } else {
  2964. border = Ext.Element.unitizeBox((border === true) ? 1 : border);
  2965. }
  2966. targetEl.setStyle('border-width', border);
  2967. if (!initial) {
  2968. me.updateLayout();
  2969. }
  2970. }
  2971. me.border = border;
  2972. },
  2973. onDestroy : function() {
  2974. var me = this;
  2975. if (me.monitorResize &amp;&amp; Ext.EventManager.resizeEvent) {
  2976. Ext.EventManager.resizeEvent.removeListener(me.setSize, me);
  2977. }
  2978. // Destroying the floatingItems ZIndexManager will also destroy descendant floating Components
  2979. Ext.destroy(
  2980. me.componentLayout,
  2981. me.loadMask,
  2982. me.floatingDescendants
  2983. );
  2984. },
  2985. <span id='Ext-AbstractComponent-method-destroy'> /**
  2986. </span> * Destroys the Component.
  2987. */
  2988. destroy : function() {
  2989. var me = this,
  2990. selectors = me.renderSelectors,
  2991. selector,
  2992. el;
  2993. if (!me.isDestroyed) {
  2994. if (!me.hasListeners.beforedestroy || me.fireEvent('beforedestroy', me) !== false) {
  2995. me.destroying = true;
  2996. me.beforeDestroy();
  2997. if (me.floating) {
  2998. delete me.floatParent;
  2999. // A zIndexManager is stamped into a *floating* Component when it is added to a Container.
  3000. // If it has no zIndexManager at render time, it is assigned to the global Ext.WindowManager instance.
  3001. if (me.zIndexManager) {
  3002. me.zIndexManager.unregister(me);
  3003. }
  3004. } else if (me.ownerCt &amp;&amp; me.ownerCt.remove) {
  3005. me.ownerCt.remove(me, false);
  3006. }
  3007. me.onDestroy();
  3008. // Attempt to destroy all plugins
  3009. Ext.destroy(me.plugins);
  3010. if (me.hasListeners.destroy) {
  3011. me.fireEvent('destroy', me);
  3012. }
  3013. Ext.ComponentManager.unregister(me);
  3014. me.mixins.state.destroy.call(me);
  3015. me.clearListeners();
  3016. // make sure we clean up the element references after removing all events
  3017. if (me.rendered) {
  3018. if (!me.preserveElOnDestroy) {
  3019. me.el.remove();
  3020. }
  3021. me.mixins.elementCt.destroy.call(me); // removes childEls
  3022. if (selectors) {
  3023. for (selector in selectors) {
  3024. if (selectors.hasOwnProperty(selector)) {
  3025. el = me[selector];
  3026. if (el) { // in case any other code may have already removed it
  3027. delete me[selector];
  3028. el.remove();
  3029. }
  3030. }
  3031. }
  3032. }
  3033. delete me.el;
  3034. delete me.frameBody;
  3035. delete me.rendered;
  3036. }
  3037. me.destroying = false;
  3038. me.isDestroyed = true;
  3039. }
  3040. }
  3041. },
  3042. <span id='Ext-AbstractComponent-method-getPlugin'> /**
  3043. </span> * Retrieves a plugin by its pluginId which has been bound to this component.
  3044. * @param {String} pluginId
  3045. * @return {Ext.AbstractPlugin} plugin instance.
  3046. */
  3047. getPlugin: function(pluginId) {
  3048. var i = 0,
  3049. plugins = this.plugins,
  3050. ln = plugins.length;
  3051. for (; i &lt; ln; i++) {
  3052. if (plugins[i].pluginId === pluginId) {
  3053. return plugins[i];
  3054. }
  3055. }
  3056. },
  3057. <span id='Ext-AbstractComponent-method-isDescendantOf'> /**
  3058. </span> * Determines whether this component is the descendant of a particular container.
  3059. * @param {Ext.Container} container
  3060. * @return {Boolean} True if it is.
  3061. */
  3062. isDescendantOf: function(container) {
  3063. return !!this.findParentBy(function(p){
  3064. return p === container;
  3065. });
  3066. }
  3067. }, function() {
  3068. var AbstractComponent = this;
  3069. AbstractComponent.createAlias({
  3070. on: 'addListener',
  3071. prev: 'previousSibling',
  3072. next: 'nextSibling'
  3073. });
  3074. <span id='Ext-method-resumeLayouts'> /**
  3075. </span> * @inheritdoc Ext.AbstractComponent#resumeLayouts
  3076. * @member Ext
  3077. */
  3078. Ext.resumeLayouts = function (flush) {
  3079. AbstractComponent.resumeLayouts(flush);
  3080. };
  3081. <span id='Ext-method-suspendLayouts'> /**
  3082. </span> * @inheritdoc Ext.AbstractComponent#suspendLayouts
  3083. * @member Ext
  3084. */
  3085. Ext.suspendLayouts = function () {
  3086. AbstractComponent.suspendLayouts();
  3087. };
  3088. <span id='Ext-method-batchLayouts'> /**
  3089. </span> * Utility wrapper that suspends layouts of all components for the duration of a given function.
  3090. * @param {Function} fn The function to execute.
  3091. * @param {Object} [scope] The scope (`this` reference) in which the specified function is executed.
  3092. * @member Ext
  3093. */
  3094. Ext.batchLayouts = function(fn, scope) {
  3095. AbstractComponent.suspendLayouts();
  3096. // Invoke the function
  3097. fn.call(scope);
  3098. AbstractComponent.resumeLayouts(true);
  3099. };
  3100. });
  3101. </pre>
  3102. </body>
  3103. </html>