Upgrade to ExtJS 4.0.2 - Released 06/09/2011
[extjs.git] / src / ShadowPool.js
1 /*
2
3 This file is part of Ext JS 4
4
5 Copyright (c) 2011 Sencha Inc
6
7 Contact:  http://www.sencha.com/contact
8
9 GNU General Public License Usage
10 This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file.  Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
11
12 If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
13
14 */
15 /**
16  * @class Ext.ShadowPool
17  * @extends Object
18  * Private utility class that manages the internal Shadow cache
19  * @private
20  */
21 Ext.define('Ext.ShadowPool', {
22     singleton: true,
23     requires: ['Ext.core.DomHelper'],
24
25     markup: function() {
26         if (Ext.supports.CSS3BoxShadow) {
27             return '<div class="' + Ext.baseCSSPrefix + 'css-shadow" role="presentation"></div>';
28         } else if (Ext.isIE) {
29             return '<div class="' + Ext.baseCSSPrefix + 'ie-shadow" role="presentation"></div>';
30         } else {
31             return '<div class="' + Ext.baseCSSPrefix + 'frame-shadow" role="presentation">' +
32                 '<div class="xst" role="presentation">' +
33                     '<div class="xstl" role="presentation"></div>' +
34                     '<div class="xstc" role="presentation"></div>' +
35                     '<div class="xstr" role="presentation"></div>' +
36                 '</div>' +
37                 '<div class="xsc" role="presentation">' +
38                     '<div class="xsml" role="presentation"></div>' +
39                     '<div class="xsmc" role="presentation"></div>' +
40                     '<div class="xsmr" role="presentation"></div>' +
41                 '</div>' +
42                 '<div class="xsb" role="presentation">' +
43                     '<div class="xsbl" role="presentation"></div>' +
44                     '<div class="xsbc" role="presentation"></div>' +
45                     '<div class="xsbr" role="presentation"></div>' +
46                 '</div>' +
47             '</div>';
48         }
49     }(),
50
51     shadows: [],
52
53     pull: function() {
54         var sh = this.shadows.shift();
55         if (!sh) {
56             sh = Ext.get(Ext.core.DomHelper.insertHtml("beforeBegin", document.body.firstChild, this.markup));
57             sh.autoBoxAdjust = false;
58         }
59         return sh;
60     },
61
62     push: function(sh) {
63         this.shadows.push(sh);
64     },
65     
66     reset: function() {
67         Ext.Array.each(this.shadows, function(shadow) {
68             shadow.remove();
69         });
70         this.shadows = [];
71     }
72 });