Upgrade to ExtJS 4.0.0 - Released 04/26/2011
[extjs.git] / src / ShadowPool.js
1 /**
2  * @class Ext.ShadowPool
3  * @extends Object
4  * Private utility class that manages the internal Shadow cache
5  * @private
6  */
7 Ext.define('Ext.ShadowPool', {
8     singleton: true,
9     requires: ['Ext.core.DomHelper'],
10
11     markup: function() {
12         if (Ext.supports.CSS3BoxShadow) {
13             return '<div class="' + Ext.baseCSSPrefix + 'css-shadow" role="presentation"></div>';
14         } else if (Ext.isIE) {
15             return '<div class="' + Ext.baseCSSPrefix + 'ie-shadow" role="presentation"></div>';
16         } else {
17             return '<div class="' + Ext.baseCSSPrefix + 'frame-shadow" role="presentation">' +
18                 '<div class="xst" role="presentation">' +
19                     '<div class="xstl" role="presentation"></div>' +
20                     '<div class="xstc" role="presentation"></div>' +
21                     '<div class="xstr" role="presentation"></div>' +
22                 '</div>' +
23                 '<div class="xsc" role="presentation">' +
24                     '<div class="xsml" role="presentation"></div>' +
25                     '<div class="xsmc" role="presentation"></div>' +
26                     '<div class="xsmr" role="presentation"></div>' +
27                 '</div>' +
28                 '<div class="xsb" role="presentation">' +
29                     '<div class="xsbl" role="presentation"></div>' +
30                     '<div class="xsbc" role="presentation"></div>' +
31                     '<div class="xsbr" role="presentation"></div>' +
32                 '</div>' +
33             '</div>';
34         }
35     }(),
36
37     shadows: [],
38
39     pull: function() {
40         var sh = this.shadows.shift();
41         if (!sh) {
42             sh = Ext.get(Ext.core.DomHelper.insertHtml("beforeBegin", document.body.firstChild, this.markup));
43             sh.autoBoxAdjust = false;
44         }
45         return sh;
46     },
47
48     push: function(sh) {
49         this.shadows.push(sh);
50     },
51     
52     reset: function() {
53         Ext.Array.each(this.shadows, function(shadow) {
54             shadow.remove();
55         });
56         this.shadows = [];
57     }
58 });