Common.js 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265
  1. MWF.xApplication.Minder = MWF.xApplication.Minder || {};
  2. //MWF.xDesktop.requireApp("Minder", "Actions.RestActions", null, false);
  3. MWF.xDesktop.requireApp("Template", "Explorer", null, false);
  4. MWF.xDesktop.requireApp("Template", "MPopupForm", null, false);
  5. MWF.xDesktop.requireApp("Template", "MTooltips", null, false);
  6. MWF.require("MWF.widget.O2Identity", null, false);
  7. MWF.xApplication.Minder.FolderSelector = new Class({
  8. Extends: MTooltips,
  9. options : {
  10. style : "", //如果有style,就加载 style/css.wcss
  11. axis: "y", //箭头在x轴还是y轴上展现
  12. position : { //node 固定的位置
  13. x : "right", //x轴上left center right, auto 系统自动计算
  14. y : "auto" //y 轴上top middle bottom, auto 系统自动计算
  15. },
  16. event : "click", //事件类型,有target 时有效, mouseenter对应mouseleave,click 对应 container 的 click
  17. hiddenDelay : 200, //ms , 有target 且 事件类型为 mouseenter 时有效
  18. displayDelay : 0, //ms , 有target 且事件类型为 mouseenter 时有效
  19. hasArrow : false,
  20. overflow : "scroll", //弹出框高宽超过container的时候怎么处理,hidden 表示超过的隐藏,scroll 表示超过的时候显示滚动条
  21. nodeStyles : {
  22. "font-size" : "12px",
  23. "position" : "absolute",
  24. "max-width" : "500px",
  25. "min-width" : "260px",
  26. "z-index" : "11",
  27. "background-color" : "#fff",
  28. "padding" : "5px",
  29. "border-radius" : "4px",
  30. "box-shadow": "0 0 4px 0 #999999",
  31. "-webkit-user-select": "text",
  32. "-moz-user-select": "text"
  33. }
  34. },
  35. _loadCustom : function( callback ){
  36. var _self = this;
  37. this.treeNode = new Element("div.treeNode",{
  38. "styles" : {
  39. "position": "relative",
  40. "overflow": "hidden",
  41. "min-width" : "395px",
  42. "box-shadow": "0 1px 3px 0 rgba(0,0,0,0.25)",
  43. "float" : "left",
  44. "background-color" : "#F8F8F8"
  45. }
  46. }).inject(this.contentNode);
  47. this.tree = new MWF.xApplication.Minder.Tree( { app : this.app }, this.treeNode, {
  48. style : "default",
  49. defaultNode : this.options.defaultNode || "root",
  50. onPostLoad : function(){
  51. if(callback)callback();
  52. }.bind(this),
  53. onSelect : function( treeNode ){
  54. this.fireEvent( "select", treeNode.data );
  55. this.hide();
  56. }.bind(this),
  57. "minWidth" : 425,
  58. "maxWidth" : 425
  59. } );
  60. }
  61. });
  62. MWF.xApplication.Minder.Tree = new Class({
  63. Extends: MWF.widget.Common,
  64. Implements: [Options, Events],
  65. options : {
  66. "style" :"default",
  67. "defaultNode" : "root",
  68. "minWidth" : null,
  69. "maxWidth" : null
  70. },
  71. initialize: function(explorer, node, options){
  72. this.setOptions(options);
  73. this.explorer = explorer;
  74. this.app = explorer.app;
  75. this.node = $(node);
  76. this.cssPath = "../x_component_Minder/$Common/"+this.options.style+"/css.wcss";
  77. this.load();
  78. },
  79. load: function(){
  80. this._loadCss();
  81. var _self = this;
  82. this.treeContentNode = new Element("div",{
  83. "styles" : this.css.treeContentNode
  84. }).inject(this.node);
  85. var rootData = {
  86. id : "root",
  87. name : "根目录",
  88. orderNumber : "1",
  89. description : ""
  90. };
  91. this.app.restActions.listMyFolder( function( json ){
  92. rootData.children = json.data;
  93. this.loadTreeNode( rootData );
  94. this.fireEvent("postLoad");
  95. }.bind(this),function(){
  96. this.fireEvent("postLoad");
  97. }.bind(this), true)
  98. },
  99. loadTreeNode : function( rootData ){
  100. this.treeNode = new MWF.xApplication.Minder.Tree.Node( this, this.treeContentNode, rootData, {
  101. "style" : this.options.style,
  102. "isCurrent" : this.options.defaultNode == rootData.id,
  103. "minWidth" : this.options.minWidth,
  104. "maxWidth" : this.options.maxWidth
  105. });
  106. },
  107. reload : function(){
  108. this.node.empty();
  109. this.load();
  110. },
  111. getCurrentNode : function(){
  112. return this.currentItem;
  113. },
  114. getCurrentFolderData : function(){
  115. var item = this.getCurrentNode();
  116. if( item ){
  117. return item.data;
  118. }else{
  119. return {};
  120. }
  121. },
  122. getCurrentFolderId : function(){
  123. var item = this.getCurrentNode();
  124. if( item ){
  125. return item.data.id;
  126. }else{
  127. return "";
  128. }
  129. }
  130. });
  131. MWF.xApplication.Minder.Tree.Node = new Class({
  132. Implements: [Options, Events],
  133. options : {
  134. "style" :"default",
  135. "isCurrent" : false,
  136. "isExpanded" : true,
  137. "level" : 0,
  138. "minWidth" : null,
  139. "maxWidth" : null
  140. },
  141. initialize: function( tree, node, data, options){
  142. this.setOptions(options);
  143. this.tree = tree;
  144. this.explorer = tree.explorer;
  145. this.app = tree.app;
  146. this.css = this.tree.css;
  147. this.data = data;
  148. this.node = $(node);
  149. this.load();
  150. },
  151. load : function() {
  152. var _self = this;
  153. this.itemNode = new Element("div.treeItemNode", {
  154. "styles": this.css.treeItemNode
  155. }).inject(this.node);
  156. this.itemNode.setStyle("padding-left", (this.options.level * 12 + 10 ) +"px");
  157. this.itemExpendNode = new Element("div.treeItemExpendNode", {
  158. "styles": this.css.emptyExpendNode
  159. }).inject(this.itemNode);
  160. if( this.data.children && this.data.children.length ){
  161. this.itemExpendNode.addEvent("click", function( ev ){
  162. if( _self.options.isExpanded ){
  163. _self.collapse();
  164. }else{
  165. _self.expand();
  166. }
  167. ev.stopPropagation();
  168. })
  169. }
  170. this.itemIconNode = new Element("div.treeItemIconNode", {
  171. "styles": this.css.treeItemIconNode
  172. }).inject(this.itemNode);
  173. this.itemTextNode = new Element("div.treeItemTextNode", {
  174. "styles": this.css.treeItemTextNode,
  175. "text": this.data.name
  176. }).inject(this.itemNode);
  177. this.setTextNodeWidth();
  178. this.itemNode.addEvents({
  179. "mouseover": function () {
  180. if ( !_self.options.isCurrent ){
  181. this.setStyles(_self.css.treeItemNode_over);
  182. _self.itemIconNode.setStyles( _self.css.treeItemIconNode_over );
  183. }
  184. },
  185. "mouseout": function () {
  186. if ( !_self.options.isCurrent ){
  187. this.setStyles(_self.css.treeItemNode);
  188. _self.itemIconNode.setStyles( _self.css.treeItemIconNode );
  189. }
  190. },
  191. click: function () {
  192. _self.tree.fireEvent("select", _self );
  193. _self.setCurrent();
  194. }
  195. });
  196. if (this.data.children) {
  197. this.treeContentNode = new Element("div.treeContentNode", {
  198. "styles": this.css.treeContentNode
  199. }).inject(this.node);
  200. this.children = [];
  201. this.data.children.each( function( d ){
  202. _self.children.push( _self.getTreeNode( d ) )
  203. })
  204. }
  205. if( this.options.isCurrent ){
  206. this.setCurrent();
  207. }
  208. if( this.data.children && this.data.children.length ){
  209. if( this.options.isExpanded ){
  210. this.expand();
  211. }else{
  212. this.collapse();
  213. }
  214. }
  215. },
  216. setTextNodeWidth : function(){
  217. if( this.options.minWidth ){
  218. this.itemTextNode.setStyle( "min-width" , ( this.options.minWidth - this.options.level * 12 - 10 - 80 ) +"px");
  219. }
  220. if( this.options.maxWidth ){
  221. this.itemTextNode.setStyle( "max-width" , ( this.options.maxWidth - this.options.level * 12 - 10 - 80 ) +"px");
  222. }
  223. },
  224. getTreeNode: function( data ){
  225. return new MWF.xApplication.Minder.Tree.Node(this.tree, this.treeContentNode, data, {
  226. style :this.options.style,
  227. level : this.options.level + 1,
  228. isCurrent : this.tree.options.defaultNode == data.id,
  229. "minWidth" : this.options.minWidth,
  230. "maxWidth" : this.options.maxWidth
  231. })
  232. },
  233. cancelCurrent : function(){
  234. this.itemNode.setStyles( this.css.treeItemNode );
  235. this.itemIconNode.setStyles( this.css.treeItemIconNode );
  236. if( this.data.children && this.data.children.length > 0 ){
  237. if( this.options.isExpanded ){
  238. this.itemExpendNode.setStyles( this.css.treeItemExpendNode );
  239. }else{
  240. this.itemExpendNode.setStyles( this.css.treeItemCollapseNode );
  241. }
  242. }
  243. this._cancelCurrent();
  244. this.options.isCurrent = false;
  245. this.tree.currentItem = null;
  246. },
  247. _cancelCurrent : function(){
  248. //if( this.toolbar )this.toolbar.setStyle("display","none");
  249. },
  250. setCurrent : function(){
  251. if(this.tree.currentItem ){
  252. this.tree.currentItem.cancelCurrent();
  253. }
  254. this.itemNode.setStyles( this.css.treeItemNode_selected );
  255. this.itemIconNode.setStyles( this.css.treeItemIconNode_selected );
  256. if( this.data.children && this.data.children.length > 0 ){
  257. if( this.options.isExpanded ){
  258. this.itemExpendNode.setStyles( this.css.treeItemExpendNode_selected );
  259. }else{
  260. this.itemExpendNode.setStyles( this.css.treeItemCollapseNode_selected );
  261. }
  262. }
  263. this.options.isCurrent = true;
  264. this.tree.currentItem = this;
  265. this._setCurrent()
  266. },
  267. _setCurrent: function(){
  268. //this.explorer.loadList({
  269. // folderId : this.data.id
  270. //});
  271. //if( !this.toolbar ){
  272. // this.createToolbar()
  273. //}else{
  274. // this.toolbar.setStyle("display","");
  275. //}
  276. },
  277. expand: function(){
  278. if( this.options.isCurrent ){
  279. this.itemExpendNode.setStyles( this.css.treeItemExpendNode_selected );
  280. }else{
  281. this.itemExpendNode.setStyles( this.css.treeItemExpendNode );
  282. }
  283. if( this.treeContentNode )this.treeContentNode.setStyle("display","");
  284. this.options.isExpanded = true;
  285. },
  286. collapse: function(){
  287. if( this.options.isCurrent ){
  288. this.itemExpendNode.setStyles( this.css.treeItemCollapseNode_selected );
  289. }else{
  290. this.itemExpendNode.setStyles( this.css.treeItemCollapseNode );
  291. }
  292. if( this.treeContentNode )this.treeContentNode.setStyle("display","none");
  293. this.options.isExpanded = false;
  294. }
  295. });
  296. MWF.xApplication.Minder.ShareForm = new Class({
  297. Extends: MPopupForm,
  298. Implements: [Options, Events],
  299. options: {
  300. "style": "minder",
  301. "width": 700,
  302. //"height": 300,
  303. "height": "400",
  304. "hasTop": true,
  305. "hasIcon": false,
  306. "draggable": true,
  307. "title" : "脑图分享"
  308. },
  309. _createTableContent: function () {
  310. var html = "<table width='100%' bordr='0' cellpadding='7' cellspacing='0' styles='formTable' style='margin-top: 20px; '>" +
  311. "<tr><td styles='formTableTitle' lable='fileName' width='18%'></td>" +
  312. " <td styles='formTableValue14' item='fileName'></td></tr>" +
  313. "<tr><td styles='formTableTitle' lable='shareTo' width='18%'></td>" +
  314. " <td styles='formTableValue14' item='shareTo'></td></tr>" +
  315. "<tr><td styles='formTableTitle' width='18%'></td>" +
  316. " <td styles='formTableValue14'>邀请其他人查看此文档</td></tr>" +
  317. "</table>";
  318. this.formTableArea.set("html", html);
  319. this.form = new MForm(this.formTableArea, this.data || {}, {
  320. isEdited: true,
  321. style : "minder",
  322. hasColon : true,
  323. itemTemplate: {
  324. fileName : { text : "脑图名称", type : "innerHTML", value : function(){
  325. var name = [];
  326. this.checkedItemData.each( function(d){
  327. name.push(d.name );
  328. });
  329. return name.join("<br>");
  330. }.bind(this)},
  331. shareTo: { type : "org", orgType:["person","unit","group"],text : "分享对象", notEmpty : true, count : 0, style : {
  332. "min-height" : "100px"
  333. } }
  334. }
  335. }, this.app);
  336. this.form.load();
  337. },
  338. _createBottomContent: function () {
  339. if (this.isNew || this.isEdited) {
  340. this.okActionNode = new Element("button.inputOkButton", {
  341. "styles": this.css.inputOkButton,
  342. "text": "确定"
  343. }).inject(this.formBottomNode);
  344. this.okActionNode.addEvent("click", function (e) {
  345. this.share(e);
  346. }.bind(this));
  347. }
  348. this.cancelActionNode = new Element("button.inputCancelButton", {
  349. "styles": (this.isEdited || this.isNew || this.getEditPermission() ) ? this.css.inputCancelButton : this.css.inputCancelButton_long,
  350. "text": "关闭"
  351. }).inject(this.formBottomNode);
  352. this.cancelActionNode.addEvent("click", function (e) {
  353. this.close(e);
  354. }.bind(this));
  355. },
  356. share: function(){
  357. var data = this.form.getResult(true,null,true,false,true);
  358. if( data ){
  359. var json = {
  360. sharePersons : [],
  361. shareUnits : [],
  362. shareGroups : []
  363. };
  364. data.shareTo.each( function( s ){
  365. var flag = s.substr(s.length-1, 1);
  366. switch (flag.toLowerCase()){
  367. case "p":
  368. json.sharePersons.push( s );
  369. break;
  370. case "u":
  371. json.shareUnits.push( s );
  372. break;
  373. case "g":
  374. json.shareGroups.push( s );
  375. break;
  376. default :
  377. break;
  378. }
  379. }.bind(this));
  380. var count = 0;
  381. this.checkedItemData.each( function(d){
  382. this.app.restActions.shareMind( d.id, json, function(){
  383. count++;
  384. if( count == this.checkedItemData.length){
  385. this.app.notice( "分享成功!" );
  386. this.close();
  387. }
  388. }.bind(this));
  389. }.bind(this));
  390. }
  391. }
  392. });
  393. MWF.xApplication.Minder.NewNameForm = new Class({
  394. Extends: MPopupForm,
  395. Implements: [Options, Events],
  396. options: {
  397. "style": "minder",
  398. "width": 700,
  399. //"height": 300,
  400. "height": "300",
  401. "hasTop": true,
  402. "hasIcon": false,
  403. "draggable": true,
  404. "title" : "新建脑图"
  405. },
  406. _createTableContent: function () {
  407. var html = "<table width='100%' bordr='0' cellpadding='7' cellspacing='0' styles='formTable' style='margin-top: 20px; '>" +
  408. "<tr><td styles='formTableTitle' lable='folder' width='25%'></td>" +
  409. " <td styles='formTableValue14' item='folder' colspan='3'></td></tr>" +
  410. "<tr><td styles='formTableTitle' lable='name' width='25%'></td>" +
  411. " <td styles='formTableValue14' item='name' colspan='3'></td></tr>" +
  412. "</table>";
  413. this.formTableArea.set("html", html);
  414. var currentFolderData = this.explorer.getCurrentFolderData ? this.explorer.getCurrentFolderData() : {};
  415. this.folderId = currentFolderData.id || "root";
  416. this.form = new MForm(this.formTableArea, this.data || {}, {
  417. isEdited: true,
  418. style : "minder",
  419. hasColon : true,
  420. itemTemplate: {
  421. folder: { text : "选择文件夹", notEmpty : true, attr : { readonly : true }, defaultValue : currentFolderData.name || "根目录" },
  422. name: { text : "脑图名称", notEmpty : true }
  423. }
  424. }, this.app);
  425. this.form.load();
  426. this.loadFolderSelect();
  427. },
  428. _createBottomContent: function () {
  429. if (this.isNew || this.isEdited) {
  430. this.okActionNode = new Element("button.inputOkButton", {
  431. "styles": this.css.inputOkButton,
  432. "text": "确定"
  433. }).inject(this.formBottomNode);
  434. this.okActionNode.addEvent("click", function (e) {
  435. this.save(e);
  436. }.bind(this));
  437. }
  438. this.cancelActionNode = new Element("button.inputCancelButton", {
  439. "styles": (this.isEdited || this.isNew || this.getEditPermission() ) ? this.css.inputCancelButton : this.css.inputCancelButton_long,
  440. "text": "关闭"
  441. }).inject(this.formBottomNode);
  442. this.cancelActionNode.addEvent("click", function (e) {
  443. this.close(e);
  444. }.bind(this));
  445. },
  446. save: function(){
  447. var data = this.form.getResult(true,null,true,false,true);
  448. if( data ){
  449. data.content = "{\"root\":{\"data\":{\"text\":\""+ data.name +"\"},\"children\":[]}}";
  450. data.folderId = this.folderId; //this.explorer.getCurrentFolderId();
  451. this.app.restActions.saveMind( data, function( json ){
  452. this.app.desktop.openApplication(null, "MinderEditor", {
  453. "folderId" : data.folderId,
  454. "minderName" : data.name,
  455. "id" : json.data.id,
  456. "isEdited" : true,
  457. "isNew" : false
  458. });
  459. if(this.explorer.currentView)this.explorer.currentView.reload();
  460. this.close();
  461. }.bind(this));
  462. }
  463. },
  464. loadFolderSelect: function() {
  465. this.folderSelect = new MWF.xApplication.Minder.FolderSelector( this.app.content, this.form.getItem("folder").getElements()[0], this.app, {}, {
  466. defaultNode : this.folderId,
  467. onSelect : function( folderData ){
  468. this.form.getItem("folder").setValue( folderData.name );
  469. this.folderId = folderData.id;
  470. }.bind(this)
  471. } );
  472. }
  473. });
  474. MWF.xApplication.Minder.FolderForm = new Class({
  475. Extends: MPopupForm,
  476. Implements: [Options, Events],
  477. options: {
  478. "style": "minder",
  479. "width": 700,
  480. //"height": 300,
  481. "height": "200",
  482. "hasTop": true,
  483. "hasIcon": false,
  484. "draggable": true,
  485. "title" : "新建目录"
  486. },
  487. _createTableContent: function () {
  488. var html = "<table width='100%' bordr='0' cellpadding='7' cellspacing='0' styles='formTable' style='margin-top: 20px; '>" +
  489. "<tr><td styles='formTableTitle' lable='name' width='25%'></td>" +
  490. " <td styles='formTableValue14' item='name' colspan='3'></td></tr>" +
  491. "</table>";
  492. this.formTableArea.set("html", html);
  493. this.form = new MForm(this.formTableArea, this.data || {}, {
  494. isEdited: true,
  495. style : "minder",
  496. hasColon : true,
  497. itemTemplate: {
  498. name: { text : "名称", notEmpty : true }
  499. }
  500. }, this.app);
  501. this.form.load();
  502. },
  503. _createBottomContent: function () {
  504. if (this.isNew || this.isEdited) {
  505. this.okActionNode = new Element("button.inputOkButton", {
  506. "styles": this.css.inputOkButton,
  507. "text": "确定"
  508. }).inject(this.formBottomNode);
  509. this.okActionNode.addEvent("click", function (e) {
  510. this.save(e);
  511. }.bind(this));
  512. }
  513. this.cancelActionNode = new Element("button.inputCancelButton", {
  514. "styles": (this.isEdited || this.isNew || this.getEditPermission() ) ? this.css.inputCancelButton : this.css.inputCancelButton_long,
  515. "text": "关闭"
  516. }).inject(this.formBottomNode);
  517. this.cancelActionNode.addEvent("click", function (e) {
  518. this.close(e);
  519. }.bind(this));
  520. },
  521. save: function(){
  522. var data = this.form.getResult(true,null,true,false,true);
  523. if( data ){
  524. if( this.isNew )data.parentId = this.explorer.getCurrentFolderId();
  525. this.app.restActions.saveFolder( data, function( json ){
  526. this.explorer.tree.reload();
  527. this.close();
  528. }.bind(this));
  529. }
  530. }
  531. });
  532. MWF.xApplication.Minder.ReNameForm = new Class({
  533. Extends: MPopupForm,
  534. Implements: [Options, Events],
  535. options: {
  536. "style": "minder",
  537. "width": 700,
  538. //"height": 300,
  539. "height": "200",
  540. "hasTop": true,
  541. "hasIcon": false,
  542. "draggable": true,
  543. "title" : "重命名脑图",
  544. "id" : ""
  545. },
  546. _createTableContent: function () {
  547. var html = "<table width='100%' bordr='0' cellpadding='7' cellspacing='0' styles='formTable' style='margin-top: 20px; '>" +
  548. "<tr><td styles='formTableTitle' lable='name' width='25%'></td>" +
  549. " <td styles='formTableValue14' item='name' colspan='3'></td></tr>" +
  550. "</table>";
  551. this.formTableArea.set("html", html);
  552. this.form = new MForm(this.formTableArea, this.data || {}, {
  553. isEdited: true,
  554. style : "minder",
  555. hasColon : true,
  556. itemTemplate: {
  557. name: { text : "名称", notEmpty : true }
  558. }
  559. }, this.app);
  560. this.form.load();
  561. },
  562. _createBottomContent: function () {
  563. if (this.isNew || this.isEdited) {
  564. this.okActionNode = new Element("button.inputOkButton", {
  565. "styles": this.css.inputOkButton,
  566. "text": "确定"
  567. }).inject(this.formBottomNode);
  568. this.okActionNode.addEvent("click", function (e) {
  569. this.save(e);
  570. }.bind(this));
  571. }
  572. this.cancelActionNode = new Element("button.inputCancelButton", {
  573. "styles": (this.isEdited || this.isNew || this.getEditPermission() ) ? this.css.inputCancelButton : this.css.inputCancelButton_long,
  574. "text": "关闭"
  575. }).inject(this.formBottomNode);
  576. this.cancelActionNode.addEvent("click", function (e) {
  577. this.close(e);
  578. }.bind(this));
  579. },
  580. save: function(){
  581. var data = this.form.getResult(true,null,true,false,true);
  582. if( data ){
  583. this.app.restActions.getMind( this.options.id, function( json ){
  584. var d = json.data;
  585. d.name = data.name;
  586. this.app.restActions.saveMind( d, function( json ){
  587. this.app.notice("重命名成功");
  588. this.explorer.currentView.reload();
  589. this.close();
  590. }.bind(this));
  591. }.bind(this))
  592. }
  593. }
  594. });
  595. MWF.xApplication.Minder.Toolbar = new Class({
  596. Extends: MWF.widget.Common,
  597. Implements: [Options, Events],
  598. options: {
  599. "style": "default",
  600. "availableTool" : [
  601. ["createMinder", "createFolder"],
  602. ["rename", "recycle"],
  603. //["import", "export"],
  604. ["share"]
  605. ],
  606. "viewType" : "list"
  607. },
  608. initialize : function( container, explorer, options ) {
  609. this.container = container;
  610. this.explorer = explorer;
  611. this.app = explorer.app;
  612. this.lp = explorer.app.lp;
  613. //this.css = explorer.app.css;
  614. this.iconPath = "../x_component_Minder/$Common/"+this.options.style+"/icon_tool/";
  615. this.cssPath = "../x_component_Minder/$Common/"+this.options.style+"/css.wcss";
  616. this.setOptions(options);
  617. this.tools = {
  618. createMinder : {
  619. action : "createMinder",
  620. text : "新建脑图",
  621. icon : "createminder"
  622. },
  623. createFolder : {
  624. action : "createFolder",
  625. text : "新建目录",
  626. icon : "createfolder"
  627. },
  628. rename : {
  629. action : "rename",
  630. text : "重命名",
  631. icon : "rename"
  632. },
  633. //import : {
  634. // action : "import",
  635. // text : "导入",
  636. // icon : "import"
  637. //},
  638. //export : {
  639. // action : "export",
  640. // text : "导出",
  641. // icon : "export"
  642. //},
  643. recycle : {
  644. action : "recycle",
  645. text : "删除",
  646. icon : "recycle"
  647. },
  648. destroyFromRecycle : {
  649. action : "destroyFromRecycle",
  650. text : "彻底删除",
  651. icon : "delete"
  652. },
  653. delete : {
  654. action : "delete",
  655. text : "彻底删除",
  656. icon : "delete"
  657. },
  658. share : {
  659. action : "share",
  660. text : "分享",
  661. icon : "share"
  662. },
  663. restore : {
  664. action : "restore",
  665. text : "恢复",
  666. icon : "restore"
  667. }
  668. }
  669. },
  670. load : function(){
  671. this._loadCss();
  672. this.node = new Element("div",{ styles : this.css.toolbarNode }).inject( this.container );
  673. this.options.availableTool.each( function( group ){
  674. var toolgroupNode = new Element("div",{
  675. styles : this.css.toolgroupNode
  676. }).inject( this.node );
  677. var length = group.length;
  678. group.each( function( t, i ){
  679. var className;
  680. if( length == 1 ){
  681. className = "toolItemNode_single";
  682. }else{
  683. if( i == 0 ){
  684. className = "toolItemNode_left";
  685. }else if( i + 1 == length ){
  686. className = "toolItemNode_right";
  687. }else{
  688. className = "toolItemNode_center";
  689. }
  690. }
  691. var tool = this.tools[ t ];
  692. var toolNode = new Element( "div", {
  693. styles : this.css[className],
  694. text : tool.text,
  695. events : {
  696. click : function( ev ){ this[tool.action]( ev ) }.bind(this),
  697. mouseover : function( ev ){
  698. ev.target.setStyles( this.css.toolItemNode_over );
  699. ev.target.setStyle("background-image","url("+this.iconPath+ tool.icon +"_active.png)")
  700. }.bind(this),
  701. mouseout : function( ev ){
  702. ev.target.setStyles( this.css.toolItemNode_normal );
  703. ev.target.setStyle("background-image","url("+this.iconPath+ tool.icon +".png)")
  704. }.bind(this)
  705. }
  706. }).inject( toolgroupNode );
  707. toolNode.setStyle("background-image", "url("+this.iconPath+ tool.icon +".png)")
  708. }.bind(this))
  709. }.bind(this));
  710. this.loadRightNode()
  711. },
  712. createMinder : function(){
  713. var form = new MWF.xApplication.Minder.NewNameForm(this.explorer, {
  714. }, {}, {
  715. app: this.app
  716. });
  717. form.edit()
  718. },
  719. createFolder : function(){
  720. var form = new MWF.xApplication.Minder.FolderForm(this.explorer, {
  721. }, {}, {
  722. app: this.app
  723. });
  724. form.create()
  725. },
  726. rename : function(){
  727. var data = this.explorer.currentView.getCheckedItemData();
  728. if( data.length == 0 ){
  729. this.app.notice("请先选择文件","error");
  730. return;
  731. }
  732. var form = new MWF.xApplication.Minder.ReNameForm(this.explorer, {
  733. name : data[0].name
  734. }, {
  735. id : data[0].id
  736. }, {
  737. app: this.app
  738. });
  739. form.edit()
  740. },
  741. recycle : function( e ){
  742. var _self = this;
  743. var ids = this.explorer.currentView.getCheckedItemIds();
  744. if( ids.length == 0 ){
  745. this.app.notice("请先选择文件","error");
  746. return;
  747. }
  748. this.app.confirm("warn", e, "删除文件确认", "是否删除选中的"+ids.length+"个文件?删除的文件会放到回收站。", 350, 120, function () {
  749. var count = 0;
  750. ids.each( function(id){
  751. _self.app.restActions.recycleMind( id , function(){
  752. count++;
  753. if( ids.length == count ){
  754. _self.app.notice("成功删除"+count+"个文件,您可以从回收站找到文件。");
  755. _self.explorer.currentView.reload();
  756. }
  757. });
  758. }.bind(this));
  759. this.close();
  760. }, function () {
  761. this.close();
  762. });
  763. },
  764. delete : function( e ){
  765. var _self = this;
  766. var ids = this.explorer.currentView.getCheckedItemIds();
  767. if( ids.length == 0 ){
  768. this.app.notice("请先选择文件","error");
  769. return;
  770. }
  771. this.app.confirm("warn", e, "彻底删除文件确认", "删除的文件无法恢复!是否彻底删除选中的"+ids.length+"个文件?", 350, 120, function () {
  772. var count = 0;
  773. ids.each( function(id){
  774. _self.app.restActions.deleteMind( id , function(){
  775. count++;
  776. if( ids.length == count ){
  777. _self.app.notice("成功删除"+count+"个文件");
  778. _self.explorer.currentView.reload();
  779. }
  780. });
  781. }.bind(this));
  782. this.close();
  783. }, function () {
  784. this.close();
  785. });
  786. },
  787. destroyFromRecycle : function( e ){
  788. var _self = this;
  789. var ids = this.explorer.currentView.getCheckedItemIds();
  790. if( ids.length == 0 ){
  791. this.app.notice("请先选择文件","error");
  792. return;
  793. }
  794. this.app.confirm("warn", e, "彻底删除文件确认", "删除的文件无法恢复!是否彻底删除选中的"+ids.length+"个文件?", 350, 120, function () {
  795. var count = 0;
  796. ids.each( function(id){
  797. _self.app.restActions.destroyFromRecycle( id , function(){
  798. count++;
  799. if( ids.length == count ){
  800. _self.app.notice("成功删除"+count+"个文件");
  801. _self.explorer.currentView.reload();
  802. }
  803. });
  804. }.bind(this));
  805. this.close();
  806. }, function () {
  807. this.close();
  808. });
  809. },
  810. restore : function(){
  811. var _self = this;
  812. var ids = this.explorer.currentView.getCheckedItemIds();
  813. if( ids.length == 0 ){
  814. this.app.notice("请先选择文件","error");
  815. return;
  816. }
  817. var count = 0;
  818. ids.each( function(id){
  819. _self.app.restActions.restoreMind( id , function(){
  820. count++;
  821. if( ids.length == count ){
  822. _self.app.notice("成功恢复"+count+"个文件");
  823. _self.explorer.currentView.reload();
  824. }
  825. });
  826. }.bind(this));
  827. },
  828. loadRightNode : function(){
  829. this.toolabrRightNode = new Element("div",{
  830. "styles": this.css.toolabrRightNode
  831. }).inject(this.node);
  832. this.loadSearch();
  833. this.loadListType();
  834. },
  835. loadSearch : function(){
  836. this.searchBarAreaNode = new Element("div", {
  837. "styles": this.css.searchBarAreaNode
  838. }).inject(this.toolabrRightNode);
  839. this.searchBarNode = new Element("div", {
  840. "styles": this.css.searchBarNode
  841. }).inject(this.searchBarAreaNode);
  842. this.searchBarInputBoxNode = new Element("div", {
  843. "styles": this.css.searchBarInputBoxNode
  844. }).inject(this.searchBarNode);
  845. this.searchBarInputNode = new Element("input", {
  846. "type": "text",
  847. "placeHolder": this.lp.searchKey,
  848. "styles": this.css.searchBarInputNode
  849. }).inject(this.searchBarInputBoxNode);
  850. this.searchBarResetActionNode = new Element("div", {
  851. "styles": this.css.searchBarResetActionNode
  852. }).inject(this.searchBarInputBoxNode);
  853. this.searchBarResetActionNode.setStyle("display","none");
  854. this.searchBarActionNode = new Element("div", {
  855. "styles": this.css.searchBarActionNode
  856. }).inject(this.searchBarNode);
  857. var _self = this;
  858. this.searchBarActionNode.addEvent("click", function(){
  859. this.search();
  860. }.bind(this));
  861. this.searchBarResetActionNode.addEvent("click", function(){
  862. this.reset();
  863. }.bind(this));
  864. this.searchBarInputNode.addEvents({
  865. "keydown": function(e){
  866. if (e.code==13){
  867. this.search();
  868. e.preventDefault();
  869. }
  870. }.bind(this)
  871. });
  872. },
  873. getListType : function(){
  874. return this.viewType || this.options.viewType
  875. },
  876. loadListType : function(){
  877. this.listViewTypeNode = new Element("div", {
  878. "styles": this.css[ this.options.viewType == "list" ? "listViewTypeNode_active" : "listViewTypeNode"],
  879. events : {
  880. click : function(){
  881. this.viewType = "list";
  882. this.listViewTypeNode.setStyles( this.css.listViewTypeNode_active );
  883. this.tileViewTypeNode.setStyles( this.css.tileViewTypeNode );
  884. this.explorer.loadList( this.explorer.currentView.filterData );
  885. }.bind(this)
  886. }
  887. }).inject(this.toolabrRightNode);
  888. this.tileViewTypeNode = new Element("div", {
  889. "styles": this.css[ this.options.viewType != "list" ? "tileViewTypeNode_active" : "tileViewTypeNode"],
  890. events : {
  891. click : function(){
  892. this.viewType = "tile";
  893. this.listViewTypeNode.setStyles( this.css.listViewTypeNode );
  894. this.tileViewTypeNode.setStyles( this.css.tileViewTypeNode_active );
  895. this.explorer.loadList( this.explorer.currentView.filterData );
  896. }.bind(this)
  897. }
  898. }).inject(this.toolabrRightNode);
  899. },
  900. search : function(){
  901. var value = this.searchBarInputNode.get("value");
  902. var filterData = Object.clone(this.explorer.currentView.filterData);
  903. if(value){
  904. filterData.name = value;
  905. }else if( filterData.name ){
  906. delete filterData.name;
  907. }
  908. this.explorer.loadList( filterData );
  909. },
  910. share : function(){
  911. var data = this.explorer.currentView.getCheckedItemData();
  912. if( data.length == 0 ){
  913. this.app.notice("请先选择文件","error");
  914. return;
  915. }
  916. var form = new MWF.xApplication.Minder.ShareForm(this.explorer, {}, {
  917. }, {
  918. app: this.app
  919. });
  920. form.checkedItemData = data;
  921. form.edit()
  922. }
  923. });
  924. MWF.xApplication.Minder.List = new Class({
  925. Extends: MWF.xApplication.Template.Explorer.ComplexView,
  926. options : {
  927. "scrollEnable" : true,
  928. "scrollType" : "window"
  929. },
  930. _createDocument: function(data, index){
  931. return new MWF.xApplication.Minder.Document(this.viewNode, data, this.explorer, this, null, index);
  932. },
  933. _getCurrentPageData: function(callback, count){
  934. if(!count)count=30;
  935. var id = (this.items.length) ? this.items[this.items.length - 1].data.id : "(0)";
  936. var filter = this.filterData || {};
  937. if( this.sortType && this.sortField ){
  938. filter.orderField = this.sortField;
  939. filter.orderType = this.sortType;
  940. }
  941. //{"name":"","folderId":"root","description":"","creator":"","creatorUnit":"","shared":"","orderField":"","orderType":""}//
  942. this.actions.listNextMindWithFilter(id, count, filter, function(json){
  943. if( !json.data )json.data = [];
  944. if (callback)callback(json);
  945. });
  946. },
  947. _removeDocument: function(documentData, all){
  948. this.actions.deleteSubject(documentData.id, function(json){
  949. this.reload();
  950. this.app.notice(this.app.lp.deleteDocumentOK, "success");
  951. }.bind(this));
  952. },
  953. _create: function(){},
  954. _openDocument: function( documentData,index ){
  955. //var appId = "ReportDocument"+documentData.id;
  956. //if (this.app.desktop.apps[appId]){
  957. // this.app.desktop.apps[appId].setCurrent();
  958. //}else {
  959. // this.app.desktop.openApplication(null, "ReportDocument", {
  960. // "id" : documentData.id,
  961. // "isEdited" : false,
  962. // "isNew" : false
  963. // });
  964. //}
  965. var appId = "MinderEditor"+documentData.id;
  966. if (this.app.desktop.apps[appId]){
  967. this.app.desktop.apps[appId].setCurrent();
  968. }else {
  969. this.app.desktop.openApplication(null, "MinderEditor", {
  970. "appId" : appId,
  971. "folderId" : documentData.folderId,
  972. "id" : documentData.id,
  973. "isEdited" : true,
  974. "isNew" : false
  975. });
  976. }
  977. },
  978. _queryCreateViewNode: function(){
  979. },
  980. _postCreateViewNode: function( viewNode ){
  981. },
  982. _queryCreateViewHead:function(){},
  983. _postCreateViewHead: function( headNode ){
  984. var selectAll = headNode.getElement("[item='selectAll']");
  985. if( selectAll ){
  986. selectAll.addEvent("click", function(){
  987. if( this.selectedAll ){
  988. this.selectAllCheckbox_custom( false );
  989. this.selectedAll = false;
  990. selectAll.setStyles( this.css.tileSelectAllNode );
  991. }else{
  992. this.selectAllCheckbox_custom( true );
  993. this.selectedAll = true;
  994. selectAll.setStyles( this.css.tileSelectAllNode_selected );
  995. }
  996. }.bind(this))
  997. }
  998. },
  999. getCheckedItemData : function(){
  1000. if( this.viewType == "tile" ){
  1001. var items = this.getCheckedItems_custom();
  1002. }else{
  1003. var items = this.getCheckedItems();
  1004. }
  1005. var array = [];
  1006. items.each( function( item ){
  1007. array.push( item.data )
  1008. });
  1009. return array;
  1010. },
  1011. getCheckedItemIds : function(){
  1012. if( this.viewType == "tile" ){
  1013. var items = this.getCheckedItems_custom();
  1014. }else{
  1015. var items = this.getCheckedItems();
  1016. }
  1017. var ids = [];
  1018. items.each( function( item ){
  1019. ids.push( item.data.id )
  1020. });
  1021. return ids;
  1022. },
  1023. selectAllCheckbox_custom: function ( flag ) {
  1024. this.items.each(function (it) {
  1025. it.setSelect( flag )
  1026. }.bind(this))
  1027. },
  1028. getCheckedItems_custom : function(){
  1029. var checkedItems = [];
  1030. this.items.each(function (it) {
  1031. if (it.selected) {
  1032. checkedItems.push( it )
  1033. }
  1034. }.bind(this));
  1035. return checkedItems;
  1036. }
  1037. });
  1038. MWF.xApplication.Minder.Document = new Class({
  1039. Extends: MWF.xApplication.Template.Explorer.ComplexDocument,
  1040. mouseoverDocument : function(){
  1041. this.node.setStyles( this.css.tileNode_over );
  1042. if( !this.selected ) {
  1043. var select = this.node.getElement("[item=select]");
  1044. select.setStyle("display", "");
  1045. }
  1046. },
  1047. mouseoutDocument : function(){
  1048. this.node.setStyles( this.css.tileNode );
  1049. if( !this.selected ){
  1050. var select = this.node.getElement("[item=select]");
  1051. select.setStyle("display","none");
  1052. }
  1053. },
  1054. _queryCreateDocumentNode:function( itemData ){
  1055. },
  1056. _postCreateDocumentNode: function( itemNode, itemData ){
  1057. var select = itemNode.getElement("[item=select]");
  1058. if( select ){
  1059. select.addEvent("click", function( ev ){
  1060. this.setSelect( !this.selected );
  1061. ev.stopPropagation()
  1062. }.bind(this))
  1063. }
  1064. //this.app.restActions.getMindIcon( itemData.id, function( json ){
  1065. // var thumbnailNode = itemNode.getElement("[item=thumbnail]");
  1066. // thumbnailNode.set("src", "data:image/png;base64,"+ json.data.value );
  1067. //}, function(){
  1068. // var thumbnailNode = itemNode.getElement("[item=thumbnail]");
  1069. // thumbnailNode.set("src", this.app.path + this.view.options.style + "/icon/default_thumbnail.png" );
  1070. //}.bind(this))
  1071. if( itemData.icon ){
  1072. var thumbnailNode = itemNode.getElement("[item=thumbnail]");
  1073. thumbnailNode.set("src", MWF.xDesktop.getImageSrc(itemData.icon) );
  1074. }else{
  1075. var thumbnailNode = itemNode.getElement("[item=thumbnail]");
  1076. thumbnailNode.set("src", this.app.path + this.view.options.style + "/icon/default_thumbnail.png" );
  1077. }
  1078. },
  1079. setSelect : function( flag ){
  1080. var select = this.node.getElement("[item=select]");
  1081. if( !flag ){
  1082. this.selected = false;
  1083. select.setStyles( this.css.tileItemSelectNode )
  1084. }else{
  1085. this.selected = true;
  1086. select.setStyles( this.css.tileItemSelectNode_selected )
  1087. }
  1088. },
  1089. open: function (e) {
  1090. this.view._openDocument(this.data, this.index);
  1091. },
  1092. edit : function( menuAction ){
  1093. var appId = "MinderEditor"+this.data.id;
  1094. var app = this.app.desktop.apps[appId];
  1095. if (app){
  1096. app.setCurrent();
  1097. if( menuAction ){
  1098. app.openMainMenu(menuAction)
  1099. }
  1100. }else {
  1101. this.app.desktop.openApplication(null, "MinderEditor", {
  1102. "appId" : appId,
  1103. "folderId" : this.data.folderId,
  1104. "id" : this.data.id,
  1105. "isEdited" : true,
  1106. "isNew" : false,
  1107. "menuAction" : menuAction
  1108. });
  1109. }
  1110. },
  1111. remove : function(){
  1112. },
  1113. showFileVersion : function(ev){
  1114. this.edit( "openFileVersion" );
  1115. ev.stopPropagation()
  1116. },
  1117. showShareRecord : function(ev){
  1118. this.edit( "openShare" );
  1119. ev.stopPropagation()
  1120. }
  1121. });
  1122. MWF.xApplication.Minder.ShareTooltip = new Class({
  1123. Extends: MTooltips,
  1124. options : {
  1125. style : "", //如果有style,就加载 style/css.wcss
  1126. axis: "y", //箭头在x轴还是y轴上展现
  1127. position : { //node 固定的位置
  1128. x : "auto", //x轴上left center right, auto 系统自动计算
  1129. y : "auto" //y 轴上top middle bottom, auto 系统自动计算
  1130. },
  1131. event : "mouseenter", //事件类型,有target 时有效, mouseenter对应mouseleave,click 对应 container 的 click
  1132. hiddenDelay : 200, //ms , 有target 且 事件类型为 mouseenter 时有效
  1133. displayDelay : 0, //ms , 有target 且事件类型为 mouseenter 时有效
  1134. overflow : "scroll" //弹出框高宽超过container的时候怎么处理,hidden 表示超过的隐藏,scroll 表示超过的时候显示滚动条
  1135. },
  1136. _getHtml : function( ){
  1137. var data = this.data;
  1138. var titleStyle = "font-size:14px;color:#333";
  1139. var valueStyle = "font-size:14px;color:#666;padding-right:20px";
  1140. var html =
  1141. "<div style='overflow: hidden;padding:15px 20px 20px 10px;height:16px;line-height:16px;'>" +
  1142. //" <div style='font-size: 12px;color:#666; float: right'>"+ this.lp.applyPerson +":" + data.applicant.split("@")[0] +"</div>" +
  1143. " <div style='font-size: 16px;color:#333;float: left;'>分享细节</div>"+
  1144. "</div>"+
  1145. "<div style='font-size: 14px;color:#333;padding:0px 10px 15px 20px;'>"+ data.name +"</div>"+
  1146. "<div style='height:1px;margin:0px 20px;border-bottom:1px solid #ccc;'></div>"+
  1147. "<table width='100%' bordr='0' cellpadding='7' cellspacing='0' style='margin:13px 13px 13px 13px;'>" +
  1148. "<tr><td style='"+titleStyle+"' width='70'>个人:</td>" +
  1149. " <td style='"+valueStyle+"'>" + this.getCn( data.sharePersonList ) + "</td></tr>" +
  1150. "<tr><td style='"+titleStyle+"'>组织:</td>" +
  1151. " <td style='"+valueStyle+"'>" + this.getCn( data.shareUnitList ) + "</td></tr>" +
  1152. "<tr><td style='"+titleStyle+"'>群组:</td>" +
  1153. " <td style='"+valueStyle+"'>" + this.getCn( data.shareGroupList ) + "</td></tr>" +
  1154. "</table>";
  1155. return "";
  1156. }
  1157. });
  1158. MWF.xApplication.Minder.ShareRecordForm = new Class({
  1159. Extends: MPopupForm,
  1160. Implements: [Options, Events],
  1161. options: {
  1162. "style": "minder",
  1163. "width": "80%",
  1164. //"height": 300,
  1165. "height": "80%",
  1166. "hasTop": true,
  1167. "hasIcon": false,
  1168. "draggable": true,
  1169. "title" : "分享记录"
  1170. },
  1171. _createTableContent: function () {
  1172. },
  1173. _createBottomContent: function () {
  1174. this.cancelActionNode = new Element("button.inputCancelButton", {
  1175. "styles": this.css.inputCancelButton_long,
  1176. "text": "关闭"
  1177. }).inject(this.formBottomNode);
  1178. this.cancelActionNode.addEvent("click", function (e) {
  1179. this.close(e);
  1180. }.bind(this));
  1181. }
  1182. });