Main.js 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648
  1. MWF.xApplication.Profile.options.multitask = false;
  2. MWF.xApplication.Profile.Main = new Class({
  3. Extends: MWF.xApplication.Common.Main,
  4. Implements: [Options, Events],
  5. options: {
  6. "style": "default",
  7. "name": "Profile",
  8. "icon": "icon.png",
  9. "width": "800",
  10. "height": "600",
  11. "isResize": false,
  12. "isMax": false,
  13. "title": MWF.xApplication.Profile.LP.title
  14. },
  15. onQueryLoad: function(){
  16. this.lp = MWF.xApplication.Profile.LP;
  17. },
  18. loadApplication: function(callback){
  19. this.loadTitle();
  20. this.loadContent();
  21. },
  22. loadTitle: function(){
  23. this.loadTitleBar();
  24. this.loadTitleUserNode();
  25. this.loadTitleTextNode();
  26. },
  27. loadTitleBar: function(){
  28. this.titleBar = new Element("div", {
  29. "styles": this.css.titleBar
  30. }).inject(this.content);
  31. },
  32. loadTitleUserNode: function(){
  33. this.titleUserNode = new Element("div", {
  34. "styles": this.css.titleUserNode
  35. }).inject(this.titleBar);
  36. this.titleUserIconNode = new Element("div", {
  37. "styles": this.css.titleUserIconNode
  38. }).inject(this.titleUserNode);
  39. this.titleUserTextNode = new Element("div", {
  40. "styles": this.css.titleUserTextNode,
  41. "text": this.desktop.session.user.name
  42. }).inject(this.titleUserNode);
  43. },
  44. loadTitleTextNode: function(){
  45. this.taskTitleTextNode = new Element("div", {
  46. "styles": this.css.titleTextNode,
  47. "text": this.lp.title
  48. }).inject(this.titleBar);
  49. },
  50. loadContent: function(){
  51. this.contentNode = new Element("div", {"styles": this.css.contentNode}).inject(this.content);
  52. MWF.require("MWF.widget.Tab", function(){
  53. this.tab = new MWF.widget.Tab(this.contentNode, {"style": "profile"});
  54. this.tab.load();
  55. this.loadInforConfigNode();
  56. this.loadLayoutConfigNode();
  57. this.loadIdeaConfigNode();
  58. this.loadPasswordConfigNode();
  59. this.inforConfigPage = this.tab.addTab(this.inforConfigNode, this.lp.inforConfig);
  60. this.layoutConfigPage = this.tab.addTab(this.layoutConfigNode, this.lp.layoutConfig);
  61. this.ideaConfigPage = this.tab.addTab(this.ideaConfigNode, this.lp.ideaConfig);
  62. this.passwordConfigPage = this.tab.addTab(this.passwordConfigNode, this.lp.passwordConfig);
  63. if (this.options.tab){
  64. this[this.options.tab].showIm();
  65. }else{
  66. this.inforConfigPage.showIm();
  67. }
  68. }.bind(this));
  69. },
  70. loadInforConfigNode: function(){
  71. this.inforConfigNode = new Element("div", {"styles": this.css.configNode}).inject(this.content);
  72. this.inforConfigAreaNode = new Element("div", {"styles": this.css.inforConfigAreaNode}).inject(this.inforConfigNode);
  73. this.getAction(function(){
  74. this.action.getPerson(function(json){
  75. this.personData = json.data;
  76. // var icon = json.data.icon;
  77. // if (!icon){
  78. // if (json.data.genderType=="f"){
  79. // icon = "/x_component_Profile/$Main/"+this.options.style+"/female.png";
  80. // }else{
  81. // icon = "/x_component_Profile/$Main/"+this.options.style+"/man.png";
  82. // }
  83. // }else{
  84. // icon = "data:image/png;base64,"+icon;
  85. // }
  86. //var html = "<table width='100%' border='0' cellpadding='5px'>" +
  87. // "<tr><td>头像:</td><td><img src='"+icon+"' style='width:72px; height: 72px; border:0px; float:left'/>" +
  88. // "<div style='margin: 20px 10px; cursor: pointer; float: left; border: 1px solid #999; padding: 3px 5px'>更换头像</div></td></tr>" +
  89. // "<tr><td>姓名:</td><td>"+json.data.name+"</td></tr>" +
  90. // "<tr><td>工号:</td><td>"+json.data.employee+"</td></tr>" +
  91. // "<tr><td>邮件:</td><td></td></tr>" +
  92. // "<tr><td>微信:</td><td>"+json.data.employee+"</td></tr>" +
  93. // "<tr><td>手机:</td><td>"+json.data.employee+"</td></tr>" +
  94. // "<tr><td>QQ:</td><td>"+json.data.employee+"</td></tr>" +
  95. // "</table>"
  96. //this.inforConfigAreaNode.set("html", html);
  97. var _self = this;
  98. var lineNode = new Element("div", {"styles": this.css.inforLineNode}).inject(this.inforConfigAreaNode);
  99. var titleNode = new Element("div", {"styles": this.css.inforIconTitleNode, "text": this.lp.icon}).inject(lineNode);
  100. var contentNode = new Element("div", {"styles": this.css.inforIconContentNode}).inject(lineNode);
  101. this.contentImgNode = new Element("img", {"styles": this.css.inforIconContentImgNode, "src": this.action.getPersonIcon()}).inject(contentNode);
  102. var actionNode = new Element("div", {"styles": this.css.inforChangeIconNode, "text": this.lp.changeIcon, "events": {
  103. "click": function(){this.changeIcon();}.bind(this)
  104. }}).inject(lineNode);
  105. var lineNode = new Element("div", {"styles": this.css.inforLineNode}).inject(this.inforConfigAreaNode);
  106. var titleNode = new Element("div", {"styles": this.css.inforTitleNode, "text": this.lp.name}).inject(lineNode);
  107. var contentNode = new Element("div", {"styles": this.css.inforContentNode, "text": json.data.name}).inject(lineNode);
  108. var lineNode = new Element("div", {"styles": this.css.inforLineNode}).inject(this.inforConfigAreaNode);
  109. var titleNode = new Element("div", {"styles": this.css.inforTitleNode, "text": this.lp.employee}).inject(lineNode);
  110. var contentNode = new Element("div", {"styles": this.css.inforContentNode, "text": json.data.employee}).inject(lineNode);
  111. var lineNode = new Element("div", {"styles": this.css.inforLineNode}).inject(this.inforConfigAreaNode);
  112. var titleNode = new Element("div", {"styles": this.css.inforTitleNode, "text": this.lp.mail}).inject(lineNode);
  113. var contentNode = new Element("div", {"styles": this.css.inforContentNode}).inject(lineNode);
  114. this.mailInputNode = new Element("input", {"styles": this.css.inforContentInputNode, "value": json.data.mail, "events": {
  115. "blur": function(){this.setStyles(_self.css.inforContentInputNode);},
  116. "focus": function(){this.setStyles(_self.css.inforContentInputNode_focus);}
  117. }}).inject(contentNode);
  118. var lineNode = new Element("div", {"styles": this.css.inforLineNode}).inject(this.inforConfigAreaNode);
  119. var titleNode = new Element("div", {"styles": this.css.inforTitleNode, "text": this.lp.mobile}).inject(lineNode);
  120. var contentNode = new Element("div", {"styles": this.css.inforContentNode}).inject(lineNode);
  121. this.mobileInputNode = new Element("input", {"styles": this.css.inforContentInputNode, "value": json.data.mobile, "events": {
  122. "blur": function(){this.setStyles(_self.css.inforContentInputNode);},
  123. "focus": function(){this.setStyles(_self.css.inforContentInputNode_focus);}
  124. }}).inject(contentNode);
  125. var lineNode = new Element("div", {"styles": this.css.inforLineNode}).inject(this.inforConfigAreaNode);
  126. var titleNode = new Element("div", {"styles": this.css.inforTitleNode, "text": this.lp.officePhone}).inject(lineNode);
  127. var contentNode = new Element("div", {"styles": this.css.inforContentNode}).inject(lineNode);
  128. this.officePhoneInputNode = new Element("input", {"styles": this.css.inforContentInputNode, "value": json.data.officePhone, "events": {
  129. "blur": function(){this.setStyles(_self.css.inforContentInputNode);},
  130. "focus": function(){this.setStyles(_self.css.inforContentInputNode_focus);}
  131. }}).inject(contentNode);
  132. var lineNode = new Element("div", {"styles": this.css.inforLineNode}).inject(this.inforConfigAreaNode);
  133. var titleNode = new Element("div", {"styles": this.css.inforTitleNode, "text": this.lp.weixin}).inject(lineNode);
  134. var contentNode = new Element("div", {"styles": this.css.inforContentNode}).inject(lineNode);
  135. this.weixinInputNode = new Element("input", {"styles": this.css.inforContentInputNode, "value": json.data.weixin, "events": {
  136. "blur": function(){this.setStyles(_self.css.inforContentInputNode);},
  137. "focus": function(){this.setStyles(_self.css.inforContentInputNode_focus);}
  138. }}).inject(contentNode);
  139. var lineNode = new Element("div", {"styles": this.css.inforLineNode}).inject(this.inforConfigAreaNode);
  140. var titleNode = new Element("div", {"styles": this.css.inforTitleNode, "text": this.lp.QQ}).inject(lineNode);
  141. var contentNode = new Element("div", {"styles": this.css.inforContentNode}).inject(lineNode);
  142. this.qqInputNode = new Element("input", {"styles": this.css.inforContentInputNode, "value": json.data.qq, "events": {
  143. "blur": function(){this.setStyles(_self.css.inforContentInputNode);},
  144. "focus": function(){this.setStyles(_self.css.inforContentInputNode_focus);}
  145. }}).inject(contentNode);
  146. var lineNode = new Element("div", {"styles": this.css.inforLineNode}).inject(this.inforConfigAreaNode);
  147. var titleNode = new Element("div", {"styles": this.css.inforTitleNode, "text": this.lp.signature}).inject(lineNode);
  148. var contentNode = new Element("div", {"styles": this.css.inforContentNode}).inject(lineNode);
  149. this.signatureInputNode = new Element("input", {"styles": this.css.inforContentInputNode, "value": json.data.signature, "events": {
  150. "blur": function(){this.setStyles(_self.css.inforContentInputNode);},
  151. "focus": function(){this.setStyles(_self.css.inforContentInputNode_focus);}
  152. }}).inject(contentNode);
  153. var lineNode = new Element("div", {"styles": this.css.inforLineNode}).inject(this.inforConfigAreaNode);
  154. this.saveAction = new Element("div", {"styles": this.css.saveAction, "text": this.lp.saveInfor}).inject(lineNode);
  155. this.saveAction.addEvent("click", function(){
  156. this.savePersonInfor();
  157. }.bind(this));
  158. }.bind(this), null, this.desktop.session.user.name)
  159. }.bind(this));
  160. },
  161. changeIcon: function(){
  162. var options = {};
  163. var width = "668";
  164. var height = "510";
  165. width = width.toInt();
  166. height = height.toInt();
  167. var size = this.content.getSize();
  168. var x = (size.x-width)/2;
  169. var y = (size.y-height)/2;
  170. if (x<0) x = 0;
  171. if (y<0) y = 0;
  172. if (layout.mobile){
  173. x = 20;
  174. y = 0;
  175. }
  176. var _self = this;
  177. MWF.require("MWF.xDesktop.Dialog", function() {
  178. MWF.require("MWF.widget.ImageClipper", function(){
  179. var dlg = new MWF.xDesktop.Dialog({
  180. "title": this.lp.changePersonIcon,
  181. "style": "image",
  182. "top": y,
  183. "left": x - 20,
  184. "fromTop": y,
  185. "fromLeft": x - 20,
  186. "width": width,
  187. "height": height,
  188. "html": "<div></div>",
  189. "maskNode": this.content,
  190. "container": this.content,
  191. "buttonList": [
  192. {
  193. "text": MWF.LP.process.button.ok,
  194. "action": function () {
  195. //_self.uploadPersonIcon();
  196. _self.image.uploadImage( function( json ){
  197. _self.action.getPerson(function(json){
  198. if (json.data){
  199. this.personData = json.data;
  200. _self.contentImgNode.set("src", _self.action.getPersonIcon());
  201. }
  202. this.close();
  203. }.bind(this));
  204. }.bind(this), null );
  205. }
  206. },
  207. {
  208. "text": MWF.LP.process.button.cancel,
  209. "action": function () {
  210. _self.image = null;
  211. this.close();
  212. }
  213. }
  214. ]
  215. });
  216. dlg.show();
  217. this.image = new MWF.widget.ImageClipper(dlg.content.getFirst(), {
  218. "aspectRatio": 1,
  219. "description" : "",
  220. "imageUrl" : this.action.getPersonIcon(),
  221. "resetEnable" : false,
  222. "data": null,
  223. "parameter": null,
  224. "action": this.action.action,
  225. "method": "changeIcon"
  226. });
  227. this.image.load();
  228. }.bind(this));
  229. }.bind(this))
  230. },
  231. uploadPersonIcon: function(){
  232. if (this.image){
  233. if( this.image.getResizedImage() ){
  234. this.action.changeIcon(function(){
  235. this.action.getPerson(function(json){
  236. if (json.data){
  237. this.personData = json.data;
  238. //if (this.personData.icon){
  239. this.contentImgNode.set("src", this.action.getPersonIcon());
  240. //}
  241. }
  242. }.bind(this))
  243. }.bind(this), null, this.image.getFormData(), this.image.resizedImage);
  244. // this.explorer.actions.changePersonIcon(this.data.id ,function(){
  245. // this.iconNode.set("src", "");
  246. // if (this.item.iconNode) this.item.iconNode.getElement("img").set("src", "");
  247. // window.setTimeout(function(){
  248. // this.iconNode.set("src", this._getIcon(true));
  249. // if (this.item.iconNode) this.item.iconNode.getElement("img").set("src", this.item._getIcon(true));
  250. // }.bind(this), 100);
  251. // }.bind(this), null, this.image.getFormData(), this.image.resizedImage);
  252. }
  253. }
  254. },
  255. // changeIcon: function(){
  256. // if (!this.uploadFileAreaNode){
  257. // this.uploadFileAreaNode = new Element("div");
  258. // var html = "<input name=\"file\" type=\"file\"/>";
  259. // this.uploadFileAreaNode.set("html", html);
  260. //
  261. // this.fileUploadNode = this.uploadFileAreaNode.getFirst();
  262. // this.fileUploadNode.addEvent("change", function(){
  263. //
  264. // var files = fileNode.files;
  265. // if (files.length){
  266. // for (var i = 0; i < files.length; i++) {
  267. // var file = files.item(i);
  268. //
  269. // var formData = new FormData();
  270. // formData.append('file', file);
  271. // //formData.append('name', file.name);
  272. // //formData.append('folder', folderId);
  273. // this.action.changeIcon(function(){
  274. // this.action.getPerson(function(json){
  275. // if (json.data){
  276. // this.personData = json.data;
  277. // //if (this.personData.icon){
  278. // this.contentImgNode.set("src", this.action.getPersonIcon());
  279. // //}
  280. // }
  281. // }.bind(this))
  282. // }.bind(this), null, formData, file);
  283. // }
  284. // }
  285. //
  286. // }.bind(this));
  287. // }
  288. // var fileNode = this.uploadFileAreaNode.getFirst();
  289. // fileNode.click();
  290. // },
  291. savePersonInfor: function(){
  292. this.personData.officePhone = this.officePhoneInputNode.get("value");
  293. this.personData.mail = this.mailInputNode.get("value");
  294. this.personData.mobile = this.mobileInputNode.get("value");
  295. this.personData.weixin = this.weixinInputNode.get("value");
  296. this.personData.qq = this.qqInputNode.get("value");
  297. this.personData.signature = this.signatureInputNode.get("value");
  298. this.action.updatePerson(this.personData, function(){
  299. this.notice(this.lp.saveInforOk, "success");
  300. }.bind(this));
  301. },
  302. loadLayoutConfigNode: function(){
  303. this.layoutConfigNode = new Element("div", {"styles": this.css.configNode}).inject(this.content);
  304. new Element("div", {"styles": this.css.layoutTitleNode, "text": this.lp.layoutAction}).inject(this.layoutConfigNode);
  305. var buttonNode = new Element("div", {"styles": this.css.buttonNodeArea}).inject(this.layoutConfigNode);
  306. this.clearDataAction = new Element("div", {"styles": this.css.clearDataAction, "text": this.lp.clear}).inject(buttonNode);
  307. this.clearDataAction.addEvent("click", function(){
  308. MWF.require("MWF.widget.UUID", function(){
  309. //MWF.UD.putData("layout", {}, function(){
  310. // this.notice(this.lp.clearok, "success");
  311. // this.desktop.notRecordStatus = true;
  312. //}.bind(this));
  313. debugger;
  314. MWF.UD.deleteData("layout", function(){
  315. this.notice(this.lp.clearok, "success");
  316. this.desktop.notRecordStatus = true;
  317. }.bind(this));
  318. }.bind(this));
  319. }.bind(this));
  320. if (MWF.AC.isAdministrator()){
  321. var defaultNode = new Element("div", {"styles": {"overflow":"hidden", "clear": "left"}}).inject(buttonNode);
  322. this.defaultDataAction = new Element("div", {"styles": this.css.setDefaultDataAction, "text": this.lp.setDefault}).inject(defaultNode);
  323. this.defaultDataAction.addEvent("click", function(){
  324. MWF.require("MWF.widget.UUID", function(){
  325. var text = this.lp.setDefaultOk;
  326. this.close();
  327. var status = layout.desktop.getLayoutStatusData();
  328. MWF.UD.putPublicData("defaultLayout", status, function(){
  329. MWF.xDesktop.notice("success", {"x": "right", "y": "top"}, text, layout.desktop.desktopNode);
  330. }.bind(this));
  331. }.bind(this));
  332. }.bind(this));
  333. this.clearDefaultDataAction = new Element("div", {"styles": this.css.setDefaultDataAction, "text": this.lp.clearDefault}).inject(defaultNode);
  334. this.clearDefaultDataAction.addEvent("click", function(){
  335. MWF.require("MWF.widget.UUID", function(){
  336. MWF.UD.deletePublicData("defaultLayout", function(){
  337. this.notice(this.lp.clearok, "success");
  338. this.desktop.notRecordStatus = true;
  339. }.bind(this));
  340. //
  341. // var text = this.lp.setDefaultOk;
  342. // this.close();
  343. // var status = layout.desktop.getLayoutStatusData();
  344. // MWF.UD.putPublicData("defaultLayout", status, function(){
  345. // MWF.xDesktop.notice("success", {"x": "right", "y": "top"}, text, layout.desktop.desktopNode);
  346. // }.bind(this));
  347. }.bind(this));
  348. }.bind(this));
  349. //var tmpNode = new Element("div", {"styles": {
  350. // "width": "300px",
  351. // "margin": "-20px auto"
  352. //}}).inject(this.layoutConfigNode);
  353. this.forceDataAction = new Element("div", {"styles": this.css.setDefaultDataAction, "text": this.lp.setForce}).inject(buttonNode);
  354. this.forceDataAction.setStyle("float", "left");
  355. this.forceDataAction.addEvent("click", function(){
  356. MWF.require("MWF.widget.UUID", function(){
  357. var text = this.lp.setForceOk;
  358. this.close();
  359. var status = layout.desktop.getLayoutStatusData();
  360. MWF.UD.putPublicData("forceLayout", status, function(){
  361. MWF.xDesktop.notice("success", {"x": "right", "y": "top"}, text, layout.desktop.desktopNode);
  362. }.bind(this));
  363. }.bind(this));
  364. }.bind(this));
  365. this.deleteForceDataAction = new Element("div", {"styles": this.css.setDefaultDataAction, "text": this.lp.clearForce}).inject(buttonNode);
  366. this.deleteForceDataAction.addEvent("click", function(){
  367. MWF.require("MWF.widget.UUID", function(){
  368. MWF.UD.deletePublicData("forceLayout", function(){
  369. this.notice(this.lp.clearok, "success");
  370. this.desktop.notRecordStatus = true;
  371. }.bind(this));
  372. }.bind(this));
  373. }.bind(this));
  374. }
  375. new Element("div", {"styles": this.css.layoutTitleNode, "text": this.lp.desktopBackground}).inject(this.layoutConfigNode);
  376. var UINode = new Element("div", {"styles": this.css.buttonNodeArea}).inject(this.layoutConfigNode);
  377. this.loadDesktopBackground(UINode);
  378. },
  379. loadDesktopBackground: function(UINode){
  380. var currentSrc = layout.desktop.options.style;
  381. MWF.UD.getDataJson("layoutDesktop", function(json){
  382. if (json) currentSrc = json.src;
  383. }.bind(this), false);
  384. MWF.getJSON(layout.desktop.path+"styles.json", function(json){
  385. json.each(function(style){
  386. var img = MWF.defaultPath+"/xDesktop/$Layout/"+style.style+"/preview.jpg";
  387. //var dskImg = MWF.defaultPath+"/xDesktop/$Layout/"+style.style+"/desktop.jpg";
  388. var imgArea = new Element("div", {"styles": this.css.previewBackground}).inject(UINode);
  389. if (currentSrc==style.style){
  390. imgArea.setStyles({"border": "4px solid #ffea00"});
  391. }
  392. new Element("img", {"src": img}).inject(imgArea);
  393. imgArea.store("dskimg", style.style);
  394. var _self = this;
  395. imgArea.addEvent("click", function(){ _self.selectDesktopImg(this, UINode); });
  396. }.bind(this));
  397. }.bind(this));
  398. //MWF.UD.getPublicData("layoutDesktopImgs", function(json){
  399. // if (json) currentSrc = json.src;
  400. //}.bind(this), false);
  401. //
  402. if (MWF.AC.isAdministrator()){
  403. }
  404. },
  405. selectDesktopImg: function(item, UINode){
  406. var desktopImg = item.retrieve("dskimg");
  407. MWF.UD.putData("layoutDesktop", {"src": desktopImg}, function(){
  408. UINode.getChildren().each(function(node){
  409. node.setStyles({"border": "4px solid #eeeeee"});
  410. }.bind(this));
  411. item.setStyles({"border": "4px solid #ffea00"});
  412. var dskImg = MWF.defaultPath+"/xDesktop/$Layout/"+desktopImg+"/desktop.jpg";
  413. layout.desktop.node.setStyle("background-image", "url("+dskImg+")");
  414. }.bind(this));
  415. },
  416. loadIdeaConfigNode: function(){
  417. this.ideaConfigNode = new Element("div", {"styles": this.css.configNode}).inject(this.content);
  418. this.ideasArea = new Element("textarea", {"styles": this.css.ideasArea}).inject(this.ideaConfigNode);
  419. this.ideasSaveAction = new Element("div", {"styles": this.css.ideasSaveAction, "text": this.lp.saveIdea}).inject(this.ideaConfigNode);
  420. if (MWF.AC.isAdministrator()){
  421. this.ideasSaveDefaultAction = new Element("div", {"styles": this.css.ideasSaveAction, "text": this.lp.saveIdeaDefault}).inject(this.ideaConfigNode);
  422. this.ideasSaveDefaultAction.addEvent("click", function(){
  423. MWF.require("MWF.widget.UUID", function(){
  424. var data = {};
  425. data.ideas = this.ideasArea.get("value").split("\n");
  426. MWF.UD.putPublicData("idea", data, function(){
  427. this.notice(this.lp.ideaSaveOk, "success");
  428. }.bind(this));
  429. }.bind(this));
  430. }.bind(this))
  431. }
  432. MWF.require("MWF.widget.UUID", function(){
  433. MWF.UD.getDataJson("idea", function(json){
  434. if (json){
  435. if (json.ideas) this.ideasArea.set("value", json.ideas.join("\n"));
  436. }
  437. }.bind(this));
  438. }.bind(this));
  439. this.ideasSaveAction.addEvent("click", function(){
  440. MWF.require("MWF.widget.UUID", function(){
  441. var data = {};
  442. data.ideas = this.ideasArea.get("value").split("\n");
  443. MWF.UD.putData("idea", data, function(){
  444. this.notice(this.lp.ideaSaveOk, "success");
  445. }.bind(this));
  446. }.bind(this));
  447. }.bind(this))
  448. },
  449. loadPasswordConfigNode: function(){
  450. this.passwordConfigNode = new Element("div", {"styles": this.css.configNode});
  451. this.passwordConfigAreaNode = new Element("div", {"styles": this.css.inforConfigAreaNode}).inject(this.passwordConfigNode);
  452. var _self = this;
  453. var lineNode = new Element("div", {"styles": this.css.inforLineNode}).inject(this.passwordConfigAreaNode);
  454. var titleNode = new Element("div", {"styles": this.css.inforTitleNode, "text": this.lp.oldPassword}).inject(lineNode);
  455. var contentNode = new Element("div", {"styles": this.css.inforContentNode}).inject(lineNode);
  456. this.oldPasswordInputNode = new Element("input", {"type": "password", "styles": this.css.inforContentInputNode, "events": {
  457. "blur": function(){this.setStyles(_self.css.inforContentInputNode);},
  458. "focus": function(){this.setStyles(_self.css.inforContentInputNode_focus);}
  459. }}).inject(contentNode);
  460. var lineNode = new Element("div", {"styles": this.css.inforLineNode}).inject(this.passwordConfigAreaNode);
  461. var titleNode = new Element("div", {"styles": this.css.inforTitleNode, "text": this.lp.password}).inject(lineNode);
  462. var contentNode = new Element("div", {"styles": this.css.inforContentNode}).inject(lineNode);
  463. this.passwordInputNode = new Element("input", {"type": "password", "styles": this.css.inforContentInputNode, "events": {
  464. "blur": function(){
  465. this.setStyles(_self.css.inforContentInputNode);
  466. },
  467. "focus": function(){this.setStyles(_self.css.inforContentInputNode_focus);},
  468. "keyup" : function(){ this.checkPassowrdStrength( this.passwordInputNode.get("value") ) }.bind(this)
  469. }}).inject(contentNode);
  470. var lineNode = new Element("div", {"styles": this.css.inforLineNode}).inject(this.passwordConfigAreaNode);
  471. var titleNode = new Element("div", {"styles": this.css.inforTitleNode}).inject(lineNode);
  472. this.passwordRemindContainer = new Element("div", {"styles": this.css.inforContentNode}).inject(lineNode);
  473. var lineNode = new Element("div", {"styles": this.css.inforLineNode}).inject(this.passwordConfigAreaNode);
  474. var titleNode = new Element("div", {"styles": this.css.inforTitleNode, "text": this.lp.morePassword}).inject(lineNode);
  475. var contentNode = new Element("div", {"styles": this.css.inforContentNode}).inject(lineNode);
  476. this.morePasswordInputNode = new Element("input", {"type": "password", "styles": this.css.inforContentInputNode, "events": {
  477. "blur": function(){this.setStyles(_self.css.inforContentInputNode);},
  478. "focus": function(){this.setStyles(_self.css.inforContentInputNode_focus);}
  479. }}).inject(contentNode);
  480. var lineNode = new Element("div", {"styles": this.css.inforLineNode}).inject(this.passwordConfigAreaNode);
  481. this.saveAction = new Element("div", {"styles": this.css.saveAction, "text": this.lp.passwordConfig}).inject(lineNode);
  482. this.saveAction.addEvent("click", function(){
  483. this.changePassword();
  484. }.bind(this));
  485. this.createPasswordStrengthNode();
  486. this.passworRemindNode = new Element("div",{"styles": this.css.passwordRemindNode, "text": this.lp.paswordRule }).inject( this.passwordRemindContainer );
  487. },
  488. changePassword: function(){
  489. var oldPassword = this.oldPasswordInputNode.get("value");
  490. var password = this.passwordInputNode.get("value");
  491. var morePassword = this.morePasswordInputNode.get("value");
  492. if (password!=morePassword){
  493. this.notice(this.lp.passwordNotMatch, "error");
  494. this.passwordInputNode.setStyles(this.css.inforContentInputNode_error);
  495. this.morePasswordInputNode.setStyles(this.css.inforContentInputNode_error);
  496. }else{
  497. this.action.changePassword(oldPassword, password, morePassword, function(){
  498. this.oldPasswordInputNode.set("value", "");
  499. this.passwordInputNode.set("value", "");
  500. this.morePasswordInputNode.set("value", "");
  501. this.notice(this.lp.changePasswordOk, "success");
  502. }.bind(this));
  503. if (layout.config.mail){
  504. var url = "http://"+layout.config.mail+"//names.nsf?changepassword&password="+encodeURIComponent(oldPassword)+"&passwordnew="+encodeURIComponent(password)+"&passwordconfirm="+encodeURIComponent(password);
  505. var iframe = new Element("iframe", {"styles": {"display": "none"}}).inject(this.desktop.desktopNode);
  506. iframe.set("src", url);
  507. window.setTimeout(function(){
  508. iframe.destroy();
  509. }.bind(this), 2000);
  510. }
  511. }
  512. },
  513. getAction: function(callback){
  514. if (!this.acrion){
  515. this.action = MWF.Actions.get("x_organization_assemble_personal");
  516. if (callback) callback();
  517. // MWF.xDesktop.requireApp("Profile", "Actions.RestActions", function(){
  518. // this.action = new MWF.xApplication.Profile.Actions.RestActions();
  519. // if (callback) callback();
  520. // }.bind(this));
  521. }else{
  522. if (callback) callback();
  523. }
  524. },
  525. createPasswordStrengthNode : function(){
  526. var passwordStrengthArea = this.passwordRemindContainer;
  527. var lowNode = new Element( "div", {styles : this.css.passwordStrengthNode }).inject( passwordStrengthArea );
  528. this.lowColorNode = new Element( "div", {styles : this.css.passwordStrengthColor }).inject( lowNode );
  529. this.lowTextNode = new Element( "div", {styles : this.css.passwordStrengthText, text : this.lp.weak }).inject( lowNode );
  530. var middleNode = new Element( "div" , {styles : this.css.passwordStrengthNode }).inject( passwordStrengthArea );
  531. this.middleColorNode = new Element( "div", {styles : this.css.passwordStrengthColor }).inject( middleNode );
  532. this.middleTextNode = new Element( "div", {styles : this.css.passwordStrengthText, text : this.lp.middle }).inject( middleNode );
  533. var highNode = new Element("div", {styles : this.css.passwordStrengthNode }).inject( passwordStrengthArea );
  534. this.highColorNode = new Element( "div", {styles : this.css.passwordStrengthColor }).inject( highNode );
  535. this.highTextNode = new Element( "div", {styles : this.css.passwordStrengthText, text : this.lp.high }).inject( highNode );
  536. },
  537. getPasswordLevel: function( password, callback ){
  538. /*Level(级别)
  539. •0-3 : [easy]
  540. •4-6 : [midium]
  541. •7-9 : [strong]
  542. •10-12 : [very strong]
  543. •>12 : [extremely strong]
  544. */
  545. this.getAction( function( ){
  546. this.action.checkPassword( password, function( json ){
  547. debugger;
  548. if(callback)callback( json.data.value );
  549. }.bind(this), null, false );
  550. }.bind(this) );
  551. },
  552. checkPassowrdStrength: function(pwd){
  553. this.lowColorNode.setStyles( this.css.passwordStrengthColor );
  554. this.lowTextNode.setStyles( this.css.passwordStrengthText );
  555. this.middleColorNode.setStyles( this.css.passwordStrengthColor );
  556. this.middleTextNode.setStyles( this.css.passwordStrengthText );
  557. this.highColorNode.setStyles( this.css.passwordStrengthColor );
  558. this.highTextNode.setStyles( this.css.passwordStrengthText );
  559. if (pwd==null||pwd==''){
  560. }else{
  561. this.getPasswordLevel( pwd, function( level ){
  562. switch(level) {
  563. case 0:
  564. case 1:
  565. case 2:
  566. case 3:
  567. this.lowColorNode.setStyles( this.css.passwordStrengthColor_low );
  568. this.lowTextNode.setStyles( this.css.passwordStrengthText_current );
  569. break;
  570. case 4:
  571. case 5:
  572. case 6:
  573. this.middleColorNode.setStyles( this.css.passwordStrengthColor_middle );
  574. this.middleTextNode.setStyles( this.css.passwordStrengthText_current );
  575. break;
  576. default:
  577. this.highColorNode.setStyles( this.css.passwordStrengthColor_high );
  578. this.highTextNode.setStyles( this.css.passwordStrengthText_current );
  579. }
  580. }.bind(this) )
  581. }
  582. }
  583. });