DraftExplorer.js 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. MWF.xDesktop.requireApp("cms.Explorer", "Explorer", null, false);
  2. MWF.xApplication.cms.Explorer.DraftExplorer = new Class({
  3. Extends: MWF.xApplication.cms.Explorer.Explorer,
  4. Implements: [Options, Events],
  5. options: {
  6. "style": "default",
  7. "status": "draft",
  8. "tooltip": {
  9. }
  10. },
  11. initialize: function(node, actions, options){
  12. this.setOptions(options);
  13. this.setTooltip();
  14. this.path = "/x_component_cms_Explorer/$DraftExplorer/";
  15. this.cssPath = "/x_component_cms_Explorer/$DraftExplorer/"+this.options.style+"/css.wcss";
  16. this._loadCss();
  17. this.actions = actions;
  18. this.node = $(node);
  19. this.initData();
  20. if (!this.personActions) this.personActions = new MWF.xAction.org.express.RestActions();
  21. },
  22. load: function(){
  23. this.toolbarNode = new Element("div", {"styles": this.css.toolbarNode});
  24. this.toolbarNode.inject(this.node);
  25. this.loadToolbar();
  26. this.filterConditionNode = new Element("div", {
  27. "styles": this.css.filterConditionNode
  28. }).inject(this.node );
  29. this.loadContentNode();
  30. this.setNodeScroll();
  31. this.mask = new MWF.widget.Mask({"style": "desktop"});
  32. this.mask.loadNode(this.node);
  33. this.loadElementList();
  34. },
  35. _createItem: function(data){
  36. return new MWF.xApplication.cms.Explorer.DraftExplorer.Document(data, this);
  37. },
  38. _getCurrentPageData: function(callback, count){
  39. var id = (this.items.length) ? this.items[this.items.length-1].data.id : "(0)";
  40. if (this.filter && this.filter.filter ){
  41. this.actions.listDraftNext(id, count || this.pageCount, this.filter.getFilterResult(), function(json){
  42. if (callback) callback(json);
  43. });
  44. }else{
  45. this.actions.listDraftNext(id, count || this.pageCount, {}, function(json){
  46. if (callback) callback(json);
  47. });
  48. }
  49. },
  50. createDocument: function( el ){
  51. if (!this.startDocumentAreaNode){
  52. this.createStartDocumentArea();
  53. }
  54. this.startDocumentAreaNode.fade("0.9");
  55. },
  56. closeStartDocumentArea: function(){
  57. //if (this.startDocumentAreaNode) this.startDocumentTween.start("left", "0px", "-400px");
  58. if (this.startDocumentAreaNode) this.startDocumentAreaNode.fade("out");
  59. },
  60. createStartDocumentArea: function(){
  61. this.createStartDocumentAreaNode();
  62. this.createStartDocumentCloseNode();
  63. this.createStartDocumentScrollNode();
  64. this.listColumns();
  65. this.setResizeStartDocumentAreaHeight();
  66. this.app.addEvent("resize", this.setResizeStartDocumentAreaHeight.bind(this));
  67. },
  68. createStartDocumentAreaNode: function(){
  69. this.startDocumentAreaNode = new Element("div", {"styles": this.css.startDocumentAreaNode}).inject(this.app.content);
  70. this.startDocumentAreaNode.addEvent("click", function(e){
  71. this.closeStartDocumentArea();
  72. }.bind(this));
  73. },
  74. createStartDocumentCloseNode: function(){
  75. this.startDocumentTopNode = new Element("div", {"styles": this.css.startDocumentTopNode}).inject(this.startDocumentAreaNode);
  76. this.startDocumentCloseNode = new Element("div", {"styles": this.css.startDocumentCloseNode}).inject(this.startDocumentTopNode);
  77. this.startDocumentCloseNode.addEvent("click", function(e){
  78. this.closeStartDocumentArea();
  79. }.bind(this));
  80. },
  81. createStartDocumentScrollNode: function(){
  82. this.startDocumentScrollNode = new Element("div", {"styles": this.css.startDocumentScrollNode}).inject(this.startDocumentAreaNode);
  83. MWF.require("MWF.widget.ScrollBar", function(){
  84. new MWF.widget.ScrollBar(this.startDocumentScrollNode, {
  85. "style":"xApp_taskcenter", "where": "after", "distance": 30, "friction": 4, "axis": {"x": false, "y": true}
  86. });
  87. }.bind(this));
  88. this.startDocumentContentNode = new Element("div", {"styles": this.css.startDocumentContentNode}).inject(this.startDocumentScrollNode);
  89. },
  90. listColumns: function(){
  91. this.getAction(function(){
  92. this.action.listColumn(function(json){
  93. json.data.each(function(column){
  94. if(!column.name)column.name = column.appName;
  95. new MWF.xApplication.cms.Explorer.DraftExplorer.Column(column, this.app, this, this.startDocumentContentNode);
  96. }.bind(this));
  97. }.bind(this));
  98. }.bind(this));
  99. },
  100. getAction: function(callback){
  101. if (!this.action){
  102. MWF.xDesktop.requireApp("cms.Explorer", "Actions.RestActions", function(){
  103. this.action = new MWF.xApplication.cms.Explorer.Actions.RestActions();
  104. if (callback) callback();
  105. }.bind(this));
  106. }else{
  107. if (callback) callback();
  108. }
  109. },
  110. setResizeStartDocumentAreaHeight: function(){
  111. var size = this.app.content.getSize();
  112. if (this.startDocumentAreaNode){
  113. var topSize = this.startDocumentCloseNode.getSize();
  114. var y = size.y-topSize.y-80;
  115. var x = size.x - 110;
  116. var areay = size.y-60;
  117. var areax = size.x-90;
  118. this.startDocumentScrollNode.setStyle("height", ""+y+"px");
  119. this.startDocumentScrollNode.setStyle("width", ""+x+"px");
  120. this.startDocumentAreaNode.setStyle("height", ""+areay+"px");
  121. this.startDocumentAreaNode.setStyle("width", ""+areax+"px");
  122. }
  123. }
  124. });
  125. MWF.xApplication.cms.Explorer.DraftExplorer.Document = new Class({
  126. Extends: MWF.xApplication.cms.Explorer.Explorer.Document,
  127. setActions: function(){
  128. this.openNode = new Element("div", {"styles": this.css.actionOpenNode, "title": this.explorer.app.lp.open}).inject(this.actionAreaNode);
  129. this.deleteNode = new Element("div", {"styles": this.css.actionDeleteNode, "title": this.explorer.app.lp.delete}).inject(this.actionAreaNode);
  130. }
  131. })
  132. MWF.xApplication.cms.Explorer.DraftExplorer.Column = new Class({
  133. initialize: function(data, app, explorer, container){
  134. this.bgColors = ["#30afdc", "#e9573e", "#8dc153", "#9d4a9c", "#ab8465", "#959801", "#434343", "#ffb400", "#9e7698", "#00a489"];
  135. this.data = data;
  136. this.app = app;
  137. this.explorer = explorer;
  138. this.container = container;
  139. this.css = this.explorer.css;
  140. this.load();
  141. },
  142. load: function(){
  143. this.node = new Element("div", {"styles": this.css.columnNode}).inject(this.container);
  144. this.topNode = new Element("div", {"styles": this.css.columnTopNode}).inject(this.node);
  145. // this.topNode.setStyle("background-color", this.bgColors[(Math.random()*10).toInt()]);
  146. this.iconNode = new Element("div", {"styles": this.css.columnIconNode}).inject(this.topNode);
  147. if (this.data.appIcon){
  148. this.iconNode.setStyle("background-image", "url(data:image/png;base64,"+this.data.appIcon+")");
  149. }else{
  150. this.iconNode.setStyle("background-image", "url("+"/x_component_cms_Column/$Main/"+this.app.options.style+"/icon/column.png)")
  151. }
  152. this.textNode = new Element("div", {"styles": this.css.columnTextNode}).inject(this.topNode);
  153. this.textNode.set("text", this.data.name);
  154. this.childNode = new Element("div", {"styles": this.css.columnChildNode}).inject(this.node);
  155. this.loadChild();
  156. },
  157. loadChild: function(){
  158. this.explorer.action.listCategory(this.data.id,function(json){
  159. if (json.data.length){
  160. json.data.each(function(category){
  161. new MWF.xApplication.cms.Explorer.DraftExplorer.Category(category, this, this.childNode);
  162. }.bind(this));
  163. }else{
  164. this.node.setStyle("display", "none");
  165. }
  166. }.bind(this), null, this.data.id)
  167. }
  168. });
  169. MWF.xApplication.cms.Explorer.DraftExplorer.Category = new Class({
  170. initialize: function(data, column, container){
  171. this.data = data;
  172. this.column = column;
  173. this.app = this.column.app;
  174. this.explorer = this.column.explorer;
  175. this.container = container;
  176. this.css = this.explorer.css;
  177. this.load();
  178. },
  179. load: function(){
  180. this.node = new Element("div.categoryItem", {"styles": this.css.startCategoryNode}).inject(this.container);
  181. this.iconNode = new Element("div", {"styles": this.css.categoryIconNode}).inject(this.node);
  182. this.textNode = new Element("div", {"styles": this.css.categoryTextNode}).inject(this.node);
  183. this.textNode.set({
  184. "text": this.data.name,
  185. "title": this.data.name+"-"+this.data.description
  186. });
  187. var _self = this;
  188. this.node.addEvents({
  189. "mouseover": function(e){this.node.setStyles(this.css.startCategoryNode_over);}.bind(this),
  190. "mouseout": function(e){this.node.setStyles(this.css.startCategoryNode_out);}.bind(this),
  191. "click": function(e){
  192. this.startCategory(e);
  193. }.bind(this)
  194. });
  195. },
  196. startCategory: function(e){
  197. this.explorer.closeStartDocumentArea();
  198. MWF.xDesktop.requireApp("cms.Explorer", "Starter", function(){
  199. var starter = new MWF.xApplication.cms.Explorer.Starter(this.column.data, this.data, this.app, {
  200. "onStarted": function(data, title, categoryName){
  201. this.afterStart(data, title, categoryName);
  202. }.bind(this)
  203. });
  204. starter.load();
  205. }.bind(this));
  206. },
  207. afterStart : function(data, title, categoryName){
  208. var options = {"documentId": data.id};
  209. this.app.desktop.openApplication(null, "cms.Document", options);
  210. }
  211. });