SharedExplorer.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. //MWF.xDesktop.requireApp("Minder", "Actions.RestActions", null, false);
  2. MWF.xDesktop.requireApp("Template", "Explorer", null, false);
  3. MWF.xDesktop.requireApp("Template", "MForm", null, false);
  4. MWF.xDesktop.requireApp("Minder", "Common", null, false);
  5. MWF.xApplication.Minder.SharedExplorer = new Class({
  6. Extends: MWF.widget.Common,
  7. Implements: [Options, Events],
  8. options: {
  9. "style": "default",
  10. "defaultTreeNode" : "root",
  11. "defaultViewType" : "list"
  12. },
  13. initialize: function(node, app, options){
  14. this.setOptions(options);
  15. this.path = "../x_component_Minder/$MineExplorer/";
  16. this.cssPath = "../x_component_Minder/$MineExplorer/"+this.options.style+"/css.wcss";
  17. this._loadCss();
  18. this.app = app;
  19. this.container = $(node);
  20. },
  21. load : function(){
  22. this.rightNode = new Element("div.rightNode",{
  23. "styles" : this.css.rightNode
  24. }).inject(this.container);
  25. //this.historyContentNode = new Element("div",{
  26. // "styles" : this.css.historyContentNode
  27. //}).inject(this.rightNode);
  28. //this.app.histroy.load( this.historyContentNode );
  29. this.toolbarNode = new Element("div",{
  30. "styles" : this.css.toolbarNode
  31. }).inject(this.rightNode);
  32. this.toolbar = new MWF.xApplication.Minder.Toolbar(this.toolbarNode, this, {
  33. "availableTool" : [
  34. ["createMinder"],
  35. ["rename", "recycle"],
  36. //["import", "export"],
  37. ["share"]
  38. ],
  39. viewType : this.options.defaultViewType
  40. });
  41. this.toolbar.load();
  42. this.listNode = new Element("div",{
  43. "styles" : this.css.listNode
  44. }).inject(this.rightNode);
  45. this.loadList({});
  46. this.resizeContent();
  47. this.resizeFun = this.resizeContent.bind(this);
  48. this.app.addEvent("resize", this.resizeFun);
  49. },
  50. destroy : function(){
  51. this.container.empty();
  52. this.app.removeEvent("resize", this.resizeFun);
  53. },
  54. resizeContent : function(){
  55. var size = this.app.content.getSize();
  56. this.rightNode.setStyle("width", size.x - 70 );
  57. this.listNode.setStyle("height", size.y - 92 );
  58. this.listNode.setStyle("width", size.x - 113 );
  59. this.toolbarNode.setStyle("width", size.x - 70 );
  60. },
  61. loadList: function( filterData ){
  62. if (this.currentView) this.currentView.destroy();
  63. this.currentView = new MWF.xApplication.Minder.SharedExplorer.List( this.listNode, this.app, this, {
  64. templateUrl : this.path + this.options.style + ( this.getViewType() == "list" ? "/listItem_shared.json" : "/tileItem.json" ),
  65. "scrollEnable" : true
  66. });
  67. this.currentView.viewType = this.getViewType();
  68. this.currentView.filterData = filterData;
  69. this.currentView.load();
  70. },
  71. getViewType : function(){
  72. return this.toolbar.getListType();
  73. },
  74. getCurrentFolderId : function(){
  75. return this.tree.getCurrentFolderId();
  76. },
  77. recordStatus : function(){
  78. return {
  79. defaultViewType : this.getViewType()
  80. }
  81. }
  82. });
  83. MWF.xApplication.Minder.SharedExplorer.List = new Class({
  84. Extends: MWF.xApplication.Minder.List,
  85. options : {
  86. "scrollEnable" : true,
  87. "scrollType" : "window"
  88. },
  89. _createDocument: function(data, index){
  90. return new MWF.xApplication.Minder.Document(this.viewNode, data, this.explorer, this, null, index);
  91. },
  92. _getCurrentPageData: function(callback, count){
  93. if(!count)count=30;
  94. var id = (this.items.length) ? this.items[this.items.length - 1].data.id : "(0)";
  95. var filter = this.filterData || {};
  96. if( this.sortType && this.sortField ){
  97. filter.orderField = this.sortField;
  98. filter.orderType = this.sortType;
  99. }
  100. //{"name":"","folderId":"root","description":"","creator":"","creatorUnit":"","shared":"","orderField":"","orderType":""}//
  101. this.actions.listMySharedMind(id, count, filter, function(json){
  102. if( !json.data )json.data = [];
  103. if (callback)callback(json);
  104. });
  105. }
  106. });