]>
Commit | Line | Data |
---|---|---|
6527f429 DM |
1 | /**\r |
2 | * This plugin defers the execution cost of the instantiation and initialization of child components of un-rendered items.\r | |
3 | *\r | |
4 | * For example, in a {@link Ext.tab.Panel#deferredRender deferredRender} {@link Ext.tab.Panel TabPanel}, the un-rendered tabs\r | |
5 | * do not have to incur the cost of instantiating and initializing their descendant components until render.\r | |
6 | *\r | |
7 | * This plugin allows that.\r | |
8 | *\r | |
9 | * Add the items to the plugin:\r | |
10 | *\r | |
11 | * {\r | |
12 | * xtype: 'tabpanel',\r | |
13 | * items: [{\r | |
14 | * title: 'Tab One',\r | |
15 | * plugins: {\r | |
16 | * ptype: 'lazyitems',\r | |
17 | * items: [... tab child items...]\r | |
18 | * }\r | |
19 | * }, {\r | |
20 | * title: 'Tab One',\r | |
21 | * plugins: {\r | |
22 | * ptype: 'lazyitems',\r | |
23 | * items: [... tab child items...]\r | |
24 | * }\r | |
25 | * }]\r | |
26 | * }\r | |
27 | *\r | |
28 | */\r | |
29 | Ext.define('Ext.plugin.LazyItems', {\r | |
30 | extend: 'Ext.plugin.Abstract',\r | |
31 | \r | |
32 | alias: 'plugin.lazyitems',\r | |
33 | \r | |
34 | init: function(comp) {\r | |
35 | this.callParent(arguments);\r | |
36 | \r | |
37 | if (this.items) {\r | |
38 | // Eager instantiation means create the child items now\r | |
39 | if (this.eagerInstantiation) {\r | |
40 | this.items = comp.prepareItems(this.items);\r | |
41 | }\r | |
42 | }\r | |
43 | \r | |
44 | // We need to jump in right before the beforeRender call\r | |
45 | comp.beforeRender = Ext.Function.createInterceptor(comp.beforeRender, this.beforeComponentRender, this);\r | |
46 | },\r | |
47 | \r | |
48 | // Add the child items at the last possible moment.\r | |
49 | beforeComponentRender: function() {\r | |
50 | this.cmp.add(this.items);\r | |
51 | \r | |
52 | // Remove the interceptor\r | |
53 | this.cmp.beforeComponentRender = null;\r | |
54 | }\r | |
55 | });\r |