ShadowPool.js 1010 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /**
  2. * Private utility class that manages the internal Shadow cache.
  3. * @private
  4. */
  5. Ext.define('Ext.ShadowPool', {
  6. singleton: true,
  7. requires: ['Ext.DomHelper'],
  8. markup: (function() {
  9. return Ext.String.format(
  10. '<div class="{0}{1}-shadow" role="presentation"></div>',
  11. Ext.baseCSSPrefix,
  12. Ext.isIE && !Ext.supports.CSS3BoxShadow ? 'ie' : 'css'
  13. );
  14. }()),
  15. shadows: [],
  16. pull: function() {
  17. var sh = this.shadows.shift();
  18. if (!sh) {
  19. sh = Ext.get(Ext.DomHelper.insertHtml("beforeBegin", document.body.firstChild, this.markup));
  20. sh.autoBoxAdjust = false;
  21. }
  22. return sh;
  23. },
  24. push: function(sh) {
  25. this.shadows.push(sh);
  26. },
  27. reset: function() {
  28. var shadows = [].concat(this.shadows),
  29. s,
  30. sLen = shadows.length;
  31. for (s = 0; s < sLen; s++) {
  32. shadows[s].remove();
  33. }
  34. this.shadows = [];
  35. }
  36. });