You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
2.6 KiB

2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. This file is part of Ext JS 3.4
  3. Copyright (c) 2011-2013 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
  7. published by the Free Software Foundation and appearing in the file LICENSE included in the
  8. packaging of this file.
  9. Please review the following information to ensure the GNU General Public License version 3.0
  10. requirements will be met: http://www.gnu.org/copyleft/gpl.html.
  11. If you are unsure which license is appropriate for your use, please contact the sales department
  12. at http://www.sencha.com/contact.
  13. Build date: 2013-04-03 15:07:25
  14. */
  15. // We are adding these custom layouts to a namespace that does not
  16. // exist by default in Ext, so we have to add the namespace first:
  17. Ext.ns('Ext.ux.layout');
  18. /**
  19. * @class Ext.ux.layout.CenterLayout
  20. * @extends Ext.layout.FitLayout
  21. * <p>This is a very simple layout style used to center contents within a container. This layout works within
  22. * nested containers and can also be used as expected as a Viewport layout to center the page layout.</p>
  23. * <p>As a subclass of FitLayout, CenterLayout expects to have a single child panel of the container that uses
  24. * the layout. The layout does not require any config options, although the child panel contained within the
  25. * layout must provide a fixed or percentage width. The child panel's height will fit to the container by
  26. * default, but you can specify <tt>autoHeight:true</tt> to allow it to autosize based on its content height.
  27. * Example usage:</p>
  28. * <pre><code>
  29. // The content panel is centered in the container
  30. var p = new Ext.Panel({
  31. title: 'Center Layout',
  32. layout: 'ux.center',
  33. items: [{
  34. title: 'Centered Content',
  35. width: '75%',
  36. html: 'Some content'
  37. }]
  38. });
  39. // If you leave the title blank and specify no border
  40. // you'll create a non-visual, structural panel just
  41. // for centering the contents in the main container.
  42. var p = new Ext.Panel({
  43. layout: 'ux.center',
  44. border: false,
  45. items: [{
  46. title: 'Centered Content',
  47. width: 300,
  48. autoHeight: true,
  49. html: 'Some content'
  50. }]
  51. });
  52. </code></pre>
  53. */
  54. Ext.ux.layout.CenterLayout = Ext.extend(Ext.layout.FitLayout, {
  55. // private
  56. setItemSize : function(item, size){
  57. this.container.addClass('ux-layout-center');
  58. item.addClass('ux-layout-center-item');
  59. if(item && size.height > 0){
  60. if(item.width){
  61. size.width = item.width;
  62. }
  63. item.setSize(size);
  64. }
  65. }
  66. });
  67. Ext.Container.LAYOUTS['ux.center'] = Ext.ux.layout.CenterLayout;