Main.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. MWF.APPWD = MWF.xApplication.portal.WidgetDesigner;
  2. MWF.APPWD.options = {
  3. "multitask": true,
  4. "executable": false
  5. };
  6. MWF.xDesktop.requireApp("portal.PageDesigner", "lp." + MWF.language, null, false);
  7. MWF.xDesktop.requireApp("portal.PageDesigner", "", null, false);
  8. MWF.xApplication.portal.WidgetDesigner.Main = new Class({
  9. Extends: MWF.xApplication.portal.PageDesigner.Main,
  10. Implements: [Options, Events],
  11. options: {
  12. "style": "default",
  13. "template": "page.json",
  14. "templateId": "",
  15. "name": "portal.WidgetDesigner",
  16. "icon": "icon.png",
  17. "title": MWF.APPWD.LP.title,
  18. "appTitle": MWF.APPWD.LP.title,
  19. "id": "",
  20. "actions": null,
  21. "category": null,
  22. "processData": null
  23. },
  24. //loadPage: function(){
  25. // this.getPageData(function(){
  26. // this.pcPage = new MWF.PCWidget(this, this.designNode);
  27. // this.pcPage.load(this.pageData);
  28. //
  29. // this.page = this.pcPage;
  30. // }.bind(this));
  31. //},
  32. getPageTemplate: function (templateId, callback) {
  33. this.actions.getWidgetTemplate(templateId, function (page) {
  34. if (callback) callback(page);
  35. }.bind(this));
  36. },
  37. getPage: function (id, callback) {
  38. this.actions.getWidget(id, function (page) {
  39. if (callback) callback(page);
  40. }.bind(this));
  41. },
  42. loadPage: function () {
  43. this.getPageData(function () {
  44. this.pcPage = new MWF.PCPage(this, this.designNode, {
  45. "propertyPath": "../x_component_portal_WidgetDesigner/Module/Page/page.html",
  46. "onPostLoad": function(){
  47. this.fireEvent("postWidgetLoad");
  48. }.bind(this)
  49. });
  50. this.pcPage.load(this.pageData);
  51. this.page = this.pcPage;
  52. }.bind(this));
  53. },
  54. setCategorySelect: function (categorySelect) {
  55. if (categorySelect) {
  56. new Element("option", {"value": "$newCategory", "text": this.lp.newCategory}).inject(categorySelect);
  57. this.actions.listWidgetTemplateCategory(function (json) {
  58. json.data.each(function (category) {
  59. new Element("option", {"value": category.name, "text": category.name}).inject(categorySelect);
  60. }.bind(this));
  61. }.bind(this));
  62. }
  63. },
  64. _savePage: function (pcData, mobileData, fieldList, success, failure) {
  65. this.actions.saveWidget(pcData, mobileData, fieldList, function (responseJSON) {
  66. success(responseJSON)
  67. }.bind(this), function (xhr, text, error) {
  68. failure(xhr, text, error)
  69. }.bind(this));
  70. },
  71. addPageTemplate: function (pcData, mobileData, data, success, failure) {
  72. this.actions.addWidgetTemplate(pcData, mobileData, data, function (json) {
  73. if (success) success(json);
  74. }.bind(this), function (xhr, text, error) {
  75. if (failure) failure(xhr, text, error);
  76. }.bind(this))
  77. },
  78. loadNewPageData: function (callback) {
  79. var url = "../x_component_portal_PageDesigner/Module/Page/template/" + this.options.template;
  80. MWF.getJSON(url, {
  81. "onSuccess": function (obj) {
  82. this.pageData = obj.pcData;
  83. this.pageData.id = "";
  84. this.pageData.isNewPage = true;
  85. this.pageData.json.name = MWF.APPWD.LP.newPage;
  86. this.pageMobileData = obj.mobileData;
  87. this.pageMobileData.id = "";
  88. this.pageMobileData.isNewPage = true;
  89. if (callback) callback();
  90. }.bind(this),
  91. "onerror": function (text) {
  92. this.notice(text, "error");
  93. }.bind(this),
  94. "onRequestFailure": function (xhr) {
  95. this.notice(xhr.responseText, "error");
  96. }.bind(this)
  97. });
  98. },
  99. previewPage: function () {
  100. this.savePage();
  101. //this.page.preview();
  102. var url = "../x_desktop/portal.html?id=" + this.application.id + "&widget=" + this.page.json.id;
  103. window.open(o2.filterUrl(url));
  104. }
  105. });