ViewSelector.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. MWF.xDesktop.requireApp("process.Xform", "ViewSelector", null, false);
  2. MWF.xApplication.cms.Xform.ViewSelector = MWF.CMSViewSelector = new Class({
  3. Extends: MWF.APPViewSelector,
  4. selectView: function(callback){
  5. if (this.json.viewName){
  6. var viewJson = {
  7. "application": this.json.application || this.form.json.application,
  8. "viewName": this.json.viewName || "",
  9. "isTitle": this.json.isTitle || "yes",
  10. "select": this.json.select || "single"
  11. };
  12. var options = {};
  13. var width = options.width || "700";
  14. var height = options.height || "400";
  15. if (layout.mobile){
  16. var size = document.body.getSize();
  17. width = size.x;
  18. height = size.y;
  19. options.style = "viewmobile";
  20. }
  21. width = width.toInt();
  22. height = height.toInt();
  23. var size = this.form.app.content.getSize();
  24. var x = (size.x-width)/2;
  25. var y = (size.y-height)/2;
  26. if (x<0) x = 0;
  27. if (y<0) y = 0;
  28. if (layout.mobile){
  29. x = 20;
  30. y = 0;
  31. }
  32. var _self = this;
  33. MWF.require("MWF.xDesktop.Dialog", function(){
  34. var dlg = new MWF.xDesktop.Dialog({
  35. "title": this.json.title || "select view",
  36. "style": options.style || "view",
  37. "top": y,
  38. "left": x-20,
  39. "fromTop":y,
  40. "fromLeft": x-20,
  41. "width": width,
  42. "height": height,
  43. "html": "<div></div>",
  44. "maskNode": this.form.app.content,
  45. "container": this.form.app.content,
  46. "buttonList": [
  47. {
  48. "text": MWF.LP.process.button.ok,
  49. "action": function(){
  50. //if (callback) callback(_self.view.selectedItems);
  51. if (callback) callback(_self.view.getData());
  52. this.close();
  53. }
  54. },
  55. {
  56. "text": MWF.LP.process.button.cancel,
  57. "action": function(){this.close();}
  58. }
  59. ]
  60. });
  61. dlg.show();
  62. if (layout.mobile){
  63. var backAction = dlg.node.getElement(".MWF_dialod_Action_back");
  64. var okAction = dlg.node.getElement(".MWF_dialod_Action_ok");
  65. if (backAction) backAction.addEvent("click", function(e){
  66. dlg.close();
  67. }.bind(this));
  68. if (okAction) okAction.addEvent("click", function(e){
  69. //if (callback) callback(this.view.selectedItems);
  70. if (callback) callback(this.view.getData());
  71. dlg.close();
  72. }.bind(this));
  73. }
  74. MWF.xDesktop.requireApp("cms.Xform", "widget.View", function(){
  75. this.view = new MWF.xApplication.cms.Xform.widget.View(dlg.content.getFirst(), viewJson, {"style": "select"});
  76. }.bind(this));
  77. }.bind(this));
  78. }
  79. }
  80. });