f381fe1dec7ac63171971273856ed7b45b9e40d9.svn-base 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * Ext JS Library 2.0 Copyright(c) 2006-2007, Ext JS, LLC. licensing@extjs.com
  3. *
  4. * http://extjs.com/license
  5. */
  6. Ext.Tip = Ext.extend(Ext.Panel, {
  7. minWidth : 40,
  8. maxWidth : 300,
  9. shadow : "sides",
  10. defaultAlign : "tl-bl?",
  11. autoRender : true,
  12. quickShowInterval : 250,
  13. frame : true,
  14. hidden : true,
  15. baseCls : "x-tip",
  16. floating : {
  17. shadow : true,
  18. shim : true,
  19. useDisplay : true,
  20. constrain : false
  21. },
  22. autoHeight : true,
  23. initComponent : function() {
  24. Ext.Tip.superclass.initComponent.call(this);
  25. if (this.closable && !this.title) {
  26. this.elements += ",header"
  27. }
  28. },
  29. afterRender : function() {
  30. Ext.Tip.superclass.afterRender.call(this);
  31. if (this.closable) {
  32. this.addTool({
  33. id : "close",
  34. handler : this.hide,
  35. scope : this
  36. })
  37. }
  38. },
  39. showAt : function(A) {
  40. Ext.Tip.superclass.show.call(this);
  41. if (this.measureWidth !== false
  42. && (!this.initialConfig || typeof this.initialConfig.width != "number")) {
  43. var B = this.body.getTextWidth();
  44. if (this.title) {
  45. B = Math.max(B, this.header.child("span")
  46. .getTextWidth(this.title))
  47. }
  48. B += this.getFrameWidth() + (this.closable ? 20 : 0)
  49. + this.body.getPadding("lr");
  50. this.setWidth(B.constrain(this.minWidth, this.maxWidth))
  51. }
  52. if (this.constrainPosition) {
  53. A = this.el.adjustForConstraints(A)
  54. }
  55. this.setPagePosition(A[0], A[1])
  56. },
  57. showBy : function(A, B) {
  58. if (!this.rendered) {
  59. this.render(Ext.getBody())
  60. }
  61. this.showAt(this.el.getAlignToXY(A, B || this.defaultAlign))
  62. },
  63. initDraggable : function() {
  64. this.dd = new Ext.Tip.DD(this, typeof this.draggable == "boolean"
  65. ? null
  66. : this.draggable);
  67. this.header.addClass("x-tip-draggable")
  68. }
  69. });
  70. Ext.Tip.DD = function(B, A) {
  71. Ext.apply(this, A);
  72. this.tip = B;
  73. Ext.Tip.DD.superclass.constructor.call(this, B.el.id, "WindowDD-" + B.id);
  74. this.setHandleElId(B.header.id);
  75. this.scroll = false
  76. };
  77. Ext.extend(Ext.Tip.DD, Ext.dd.DD, {
  78. moveOnly : true,
  79. scroll : false,
  80. headerOffsets : [100, 25],
  81. startDrag : function() {
  82. this.tip.el.disableShadow()
  83. },
  84. endDrag : function(A) {
  85. this.tip.el.enableShadow(true)
  86. }
  87. });