/hippo/src/main/webapp/ext/src/widgets/layout/AbsoluteLayout.js

http://hdbc.googlecode.com/ · JavaScript · 82 lines · 16 code · 5 blank · 61 comment · 0 complexity · 90503ba7049c23bdbe01836043fc8e72 MD5 · raw file

  1. /*!
  2. * Ext JS Library 3.0.0
  3. * Copyright(c) 2006-2009 Ext JS, LLC
  4. * licensing@extjs.com
  5. * http://www.extjs.com/license
  6. */
  7. /**
  8. * @class Ext.layout.AbsoluteLayout
  9. * @extends Ext.layout.AnchorLayout
  10. * <p>This is a layout that inherits the anchoring of <b>{@link Ext.layout.AnchorLayout}</b> and adds the
  11. * ability for x/y positioning using the standard x and y component config options.</p>
  12. * <p>This class is intended to be extended or created via the <tt><b>{@link Ext.Container#layout layout}</b></tt>
  13. * configuration property. See <tt><b>{@link Ext.Container#layout}</b></tt> for additional details.</p>
  14. * <p>Example usage:</p>
  15. * <pre><code>
  16. var form = new Ext.form.FormPanel({
  17. title: 'Absolute Layout',
  18. layout:'absolute',
  19. layoutConfig: {
  20. // layout-specific configs go here
  21. extraCls: 'x-abs-layout-item',
  22. },
  23. baseCls: 'x-plain',
  24. url:'save-form.php',
  25. defaultType: 'textfield',
  26. items: [{
  27. x: 0,
  28. y: 5,
  29. xtype:'label',
  30. text: 'Send To:'
  31. },{
  32. x: 60,
  33. y: 0,
  34. name: 'to',
  35. anchor:'100%' // anchor width by percentage
  36. },{
  37. x: 0,
  38. y: 35,
  39. xtype:'label',
  40. text: 'Subject:'
  41. },{
  42. x: 60,
  43. y: 30,
  44. name: 'subject',
  45. anchor: '100%' // anchor width by percentage
  46. },{
  47. x:0,
  48. y: 60,
  49. xtype: 'textarea',
  50. name: 'msg',
  51. anchor: '100% 100%' // anchor width and height
  52. }]
  53. });
  54. </code></pre>
  55. */
  56. Ext.layout.AbsoluteLayout = Ext.extend(Ext.layout.AnchorLayout, {
  57. extraCls: 'x-abs-layout-item',
  58. onLayout : function(ct, target){
  59. target.position();
  60. this.paddingLeft = target.getPadding('l');
  61. this.paddingTop = target.getPadding('t');
  62. Ext.layout.AbsoluteLayout.superclass.onLayout.call(this, ct, target);
  63. },
  64. // private
  65. adjustWidthAnchor : function(value, comp){
  66. return value ? value - comp.getPosition(true)[0] + this.paddingLeft : value;
  67. },
  68. // private
  69. adjustHeightAnchor : function(value, comp){
  70. return value ? value - comp.getPosition(true)[1] + this.paddingTop : value;
  71. }
  72. /**
  73. * @property activeItem
  74. * @hide
  75. */
  76. });
  77. Ext.Container.LAYOUTS['absolute'] = Ext.layout.AbsoluteLayout;