Main.js 4.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. setCategorySelect: function(categorySelect){
  43. if (categorySelect){
  44. new Element("option", {"value": "$newCategory","text": this.lp.newCategory}).inject(categorySelect);
  45. this.actions.listWidgetTemplateCategory(function(json){
  46. json.data.each(function(category){
  47. new Element("option", {"value": category.name,"text": category.name}).inject(categorySelect);
  48. }.bind(this));
  49. }.bind(this));
  50. }
  51. },
  52. _savePage : function(pcData, mobileData, fieldList, success, failure ){
  53. this.actions.saveWidget(pcData, mobileData, fieldList, function(responseJSON){
  54. success(responseJSON)
  55. }.bind(this), function(xhr, text, error){
  56. failure(xhr, text, error)
  57. }.bind(this));
  58. },
  59. addPageTemplate : function(pcData, mobileData, data, success, failure){
  60. this.actions.addWidgetTemplate( pcData, mobileData, data, function(json){
  61. if(success)success(json);
  62. }.bind(this), function(xhr, text, error){
  63. if(failure)failure(xhr, text, error);
  64. }.bind(this))
  65. },
  66. loadNewPageData: function(callback){
  67. var url = "../x_component_portal_PageDesigner/Module/Page/template/"+this.options.template;
  68. MWF.getJSON(url, {
  69. "onSuccess": function(obj){
  70. this.pageData = obj.pcData;
  71. this.pageData.id="";
  72. this.pageData.isNewPage = true;
  73. this.pageData.json.name = MWF.APPWD.LP.newPage;
  74. this.pageMobileData = obj.mobileData;
  75. this.pageMobileData.id="";
  76. this.pageMobileData.isNewPage = true;
  77. if (callback) callback();
  78. }.bind(this),
  79. "onerror": function(text){
  80. this.notice(text, "error");
  81. }.bind(this),
  82. "onRequestFailure": function(xhr){
  83. this.notice(xhr.responseText, "error");
  84. }.bind(this)
  85. });
  86. },
  87. previewPage: function(){
  88. this.savePage();
  89. //this.page.preview();
  90. var url = "../x_desktop/portal.html?id="+this.application.id+"&widget="+this.page.json.id;
  91. window.open(o2.filterUrl(url));
  92. }
  93. });