PageRenderTime 40ms CodeModel.GetById 30ms RepoModel.GetById 1ms app.codeStats 0ms

/ext-4.0.7/src/layout/container/Container.js

https://bitbucket.org/srogerf/javascript
JavaScript | 111 lines | 61 code | 15 blank | 35 comment | 15 complexity | db7a2250ee3d4d38ebf33f7d49fe322a MD5 | raw file
  1. /*
  2. This file is part of Ext JS 4
  3. Copyright (c) 2011 Sencha Inc
  4. Contact: http://www.sencha.com/contact
  5. GNU General Public License Usage
  6. 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.
  7. If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
  8. */
  9. /**
  10. * @class Ext.layout.container.Container
  11. * @extends Ext.layout.container.AbstractContainer
  12. * <p>This class is intended to be extended or created via the {@link Ext.container.Container#layout layout}
  13. * configuration property. See {@link Ext.container.Container#layout} for additional details.</p>
  14. */
  15. Ext.define('Ext.layout.container.Container', {
  16. /* Begin Definitions */
  17. extend: 'Ext.layout.container.AbstractContainer',
  18. alternateClassName: 'Ext.layout.ContainerLayout',
  19. /* End Definitions */
  20. layoutItem: function(item, box) {
  21. if (box) {
  22. item.doComponentLayout(box.width, box.height);
  23. } else {
  24. item.doComponentLayout();
  25. }
  26. },
  27. getLayoutTargetSize : function() {
  28. var target = this.getTarget(),
  29. ret;
  30. if (target) {
  31. ret = target.getViewSize();
  32. // IE in will sometimes return a width of 0 on the 1st pass of getViewSize.
  33. // Use getStyleSize to verify the 0 width, the adjustment pass will then work properly
  34. // with getViewSize
  35. if (Ext.isIE && ret.width == 0){
  36. ret = target.getStyleSize();
  37. }
  38. ret.width -= target.getPadding('lr');
  39. ret.height -= target.getPadding('tb');
  40. }
  41. return ret;
  42. },
  43. beforeLayout: function() {
  44. if (this.owner.beforeLayout(arguments) !== false) {
  45. return this.callParent(arguments);
  46. }
  47. else {
  48. return false;
  49. }
  50. },
  51. /**
  52. * @protected
  53. * Returns all items that are rendered
  54. * @return {Array} All matching items
  55. */
  56. getRenderedItems: function() {
  57. var me = this,
  58. target = me.getTarget(),
  59. items = me.getLayoutItems(),
  60. ln = items.length,
  61. renderedItems = [],
  62. i, item;
  63. for (i = 0; i < ln; i++) {
  64. item = items[i];
  65. if (item.rendered && me.isValidParent(item, target, i)) {
  66. renderedItems.push(item);
  67. }
  68. }
  69. return renderedItems;
  70. },
  71. /**
  72. * @protected
  73. * Returns all items that are both rendered and visible
  74. * @return {Array} All matching items
  75. */
  76. getVisibleItems: function() {
  77. var target = this.getTarget(),
  78. items = this.getLayoutItems(),
  79. ln = items.length,
  80. visibleItems = [],
  81. i, item;
  82. for (i = 0; i < ln; i++) {
  83. item = items[i];
  84. if (item.rendered && this.isValidParent(item, target, i) && item.hidden !== true) {
  85. visibleItems.push(item);
  86. }
  87. }
  88. return visibleItems;
  89. }
  90. });