Dialog.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. o2.require("MWF.widget.Dialog", null, false);
  2. o2.xDesktop.Dialog = o2.DDL = new Class({
  3. Extends: o2.widget.Dialog,
  4. // _markShow: function(){
  5. //
  6. // if (this.options.mark){
  7. // if (!this.markNode){
  8. //
  9. // this.markNode = new Element("div", {
  10. // styles: this.css.mark
  11. // }).inject($(document.body));
  12. //
  13. // }
  14. //// if (this.options.markNode){
  15. //// var size = this.options.markNode.getComputedSize();
  16. //// var position = this.options.markNode.getPosition();
  17. //// alert(size.totalHeight);
  18. //// this.markNode.set("styles", {
  19. //// "height": size.totalHeight+"px",
  20. //// "width": size.totalWidth+"px",
  21. //// "top": position.y,
  22. //// "height": position.x
  23. //// });
  24. ////
  25. //// }else{
  26. // var size = MWF.getMarkSize();
  27. // this.markNode.set("styles", {
  28. // "height": size.y,
  29. // "width": size.x,
  30. // "top": "0xp",
  31. // "height": "0px"
  32. // });
  33. //// }
  34. //
  35. // this.markNode.setStyle("display", "block");
  36. // }
  37. // },
  38. _markShow: function(){
  39. if (this.options.mark){
  40. if (!this.markNode){
  41. var size = MWF.getMarkSize(this.options.maskNode);
  42. var topNode = this.options.container || $(document.body);
  43. this.markNode = new Element("iframe", {
  44. styles: this.css.mark
  45. }).inject(topNode);
  46. this.markNode.set("styles", {
  47. "height": size.y,
  48. "width": size.x
  49. });
  50. }
  51. this.markNode.setStyle("display", "block");
  52. }
  53. },
  54. getDialogNode: function(){
  55. this.node.set("styles", this.css.from);
  56. var topNode = this.options.container || $(document.body);
  57. this.node.inject(topNode);
  58. // this.node.addEvent("selectstart", function(e){
  59. // // e.preventDefault();
  60. // });
  61. this.title = this.node.getElement(".MWF_dialod_title");
  62. this.titleCenter = this.node.getElement(".MWF_dialod_title_center");
  63. this.titleText = this.node.getElement(".MWF_dialod_title_text");
  64. this.titleAction = this.node.getElement(".MWF_dialod_title_action");
  65. this.content = this.node.getElement(".MWF_dialod_content");
  66. this.bottom = this.node.getElement(".MWF_dialod_bottom");
  67. this.resizeNode = this.node.getElement(".MWF_dialod_bottom_resize");
  68. this.button = this.node.getElement(".MWF_dialod_button");
  69. if (!this.options.isTitle) {
  70. this.title.destroy();
  71. this.title = null;
  72. this.titleCenter = null;
  73. this.titleRefresh = null;
  74. this.titleText = null;
  75. this.titleAction = null;
  76. }
  77. if (this.title) this.setTitleEvent();
  78. // if (this.titleText) this.getTitle();
  79. if (this.content) this.getContent();
  80. if (this.titleAction) this.getAction();
  81. if (this.resizeNode) this.setResizeNode();
  82. // if (this.button) this.getButton();
  83. if (this.content) this.setContentSize();
  84. }
  85. });
  86. o2.DL.open = function(options){
  87. if (!options) options = {};
  88. if (!options.style) options.style = "user";
  89. //if (!options.transition) options.transition = Fx.Transitions.Back.easeOut;
  90. if (!options.duration) options.duration = 200;
  91. if (options.isClose!==false) options.isClose = true;
  92. var size;
  93. if (!options.width && !options.contentWidth){
  94. if (options.content){
  95. options.content.show();
  96. size = options.content.getComputedSize();
  97. options.contentWidth = size.totalWidth.toFloat();
  98. }
  99. }
  100. if (!options.height && !options.contentHeight){
  101. if (options.content){
  102. if (!size){
  103. options.content.show();
  104. size = options.content.getComputedSize();
  105. }
  106. options.contentHeight = size.totalHeight.toFloat()+2;
  107. }
  108. }
  109. if (!options.width && !options.contentWidth) options.width = 300;
  110. if (!options.height && !options.contentHeight) options.height = 150;
  111. if (!options.container && layout){
  112. if (layout.desktop.currentApp){
  113. options.container = layout.desktop.currentApp.content;
  114. }
  115. }
  116. var container = (options.positionNode || options.container || $(document.body));
  117. if ((options.top===undefined ) && (options.left===undefined)){
  118. var p = o2.getCenter({"x":(options.width || options.contentWidth), "y": (options.height || options.contentHeight+120)}, container, container);
  119. options.top = (p.y<0) ? 0 : p.y;
  120. options.left = (p.x<0) ? 0 : p.x;
  121. }
  122. if ((options.fromTop===undefined ) && (options.fromLeft===undefined)){
  123. var p = o2.getCenter({"x":(options.width || options.contentWidth)*0, "y": (options.height || options.contentHeight+120)*0}, container, container);
  124. options.fromTop = (p.y<0) ? 0 : p.y;
  125. options.fromLeft = (p.x<0) ? 0 : p.x;
  126. }
  127. if (options.offset){
  128. if (options.offset.y){
  129. options.top = options.top+options.offset.y.toInt();
  130. options.fromTop = options.fromTop+options.offset.y.toInt();
  131. }
  132. if (options.offset.x){
  133. options.left = options.left+options.offset.x.toInt();
  134. options.fromLeft = options.fromLeft+options.offset.x.toInt();
  135. }
  136. }
  137. if (options.top<0) options.top = 0;
  138. if (options.left<0) options.left = 0;
  139. if (options.fromTop<0) options.fromTop = 0;
  140. if (options.fromLeft<0) options.fromLeft = 0;
  141. options.mark = !(options.mask===false);
  142. var dlg = new o2.DDL(options);
  143. dlg.show();
  144. return dlg;
  145. };