Main.js 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526
  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": icon}).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.display}).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.display}).inject(lineNode);
  113. var contentNode = new Element("div", {"styles": this.css.inforContentNode}).inject(lineNode);
  114. this.displayInputNode = new Element("input", {"styles": this.css.inforContentInputNode, "value": json.data.display, "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.mail}).inject(lineNode);
  120. var contentNode = new Element("div", {"styles": this.css.inforContentNode}).inject(lineNode);
  121. this.mailInputNode = new Element("input", {"styles": this.css.inforContentInputNode, "value": json.data.mail, "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.mobile}).inject(lineNode);
  127. var contentNode = new Element("div", {"styles": this.css.inforContentNode}).inject(lineNode);
  128. this.mobileInputNode = new Element("input", {"styles": this.css.inforContentInputNode, "value": json.data.mobile, "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. if (!this.uploadFileAreaNode){
  163. this.uploadFileAreaNode = new Element("div");
  164. var html = "<input name=\"file\" type=\"file\"/>";
  165. this.uploadFileAreaNode.set("html", html);
  166. this.fileUploadNode = this.uploadFileAreaNode.getFirst();
  167. this.fileUploadNode.addEvent("change", function(){
  168. var files = fileNode.files;
  169. if (files.length){
  170. for (var i = 0; i < files.length; i++) {
  171. var file = files.item(i);
  172. var formData = new FormData();
  173. formData.append('file', file);
  174. //formData.append('name', file.name);
  175. //formData.append('folder', folderId);
  176. this.action.changeIcon(function(){
  177. this.action.getPerson(function(json){
  178. if (json.data){
  179. this.personData = json.data;
  180. if (this.personData.icon){
  181. this.contentImgNode.set("src", "data:image/png;base64,"+this.personData.icon);
  182. }
  183. }
  184. }.bind(this))
  185. }.bind(this), null, formData, file);
  186. }
  187. }
  188. }.bind(this));
  189. }
  190. var fileNode = this.uploadFileAreaNode.getFirst();
  191. fileNode.click();
  192. },
  193. savePersonInfor: function(){
  194. this.personData.display = this.displayInputNode.get("value");
  195. this.personData.mail = this.mailInputNode.get("value");
  196. this.personData.mobile = this.mobileInputNode.get("value");
  197. this.personData.weixin = this.weixinInputNode.get("value");
  198. this.personData.qq = this.qqInputNode.get("value");
  199. this.personData.signature = this.signatureInputNode.get("value");
  200. this.action.updatePerson(this.personData, function(){
  201. this.notice(this.lp.saveInforOk, "success");
  202. }.bind(this));
  203. },
  204. loadLayoutConfigNode: function(){
  205. this.layoutConfigNode = new Element("div", {"styles": this.css.configNode}).inject(this.content);
  206. new Element("div", {"styles": this.css.layoutTitleNode, "text": this.lp.layoutAction}).inject(this.layoutConfigNode);
  207. var buttonNode = new Element("div", {"styles": this.css.buttonNodeArea}).inject(this.layoutConfigNode);
  208. this.clearDataAction = new Element("div", {"styles": this.css.clearDataAction, "text": this.lp.clear}).inject(buttonNode);
  209. this.clearDataAction.addEvent("click", function(){
  210. MWF.require("MWF.widget.UUID", function(){
  211. //MWF.UD.putData("layout", {}, function(){
  212. // this.notice(this.lp.clearok, "success");
  213. // this.desktop.notRecordStatus = true;
  214. //}.bind(this));
  215. MWF.UD.deleteData("layout", function(){
  216. this.notice(this.lp.clearok, "success");
  217. this.desktop.notRecordStatus = true;
  218. }.bind(this));
  219. }.bind(this));
  220. }.bind(this));
  221. if (MWF.AC.isAdministrator()){
  222. this.defaultDataAction = new Element("div", {"styles": this.css.setDefaultDataAction, "text": this.lp.setDefault}).inject(buttonNode);
  223. this.defaultDataAction.addEvent("click", function(){
  224. MWF.require("MWF.widget.UUID", function(){
  225. var text = this.lp.setDefaultOk;
  226. this.close();
  227. var status = layout.desktop.getLayoutStatusData();
  228. MWF.UD.putPublicData("defaultLayout", status, function(){
  229. MWF.xDesktop.notice("success", {"x": "right", "y": "top"}, text, layout.desktop.desktopNode);
  230. }.bind(this));
  231. }.bind(this));
  232. }.bind(this));
  233. //var tmpNode = new Element("div", {"styles": {
  234. // "width": "300px",
  235. // "margin": "-20px auto"
  236. //}}).inject(this.layoutConfigNode);
  237. this.forceDataAction = new Element("div", {"styles": this.css.setDefaultDataAction, "text": this.lp.setForce}).inject(buttonNode);
  238. this.forceDataAction.setStyle("float", "left");
  239. this.forceDataAction.addEvent("click", function(){
  240. MWF.require("MWF.widget.UUID", function(){
  241. var text = this.lp.setForceOk;
  242. this.close();
  243. var status = layout.desktop.getLayoutStatusData();
  244. MWF.UD.putPublicData("forceLayout", status, function(){
  245. MWF.xDesktop.notice("success", {"x": "right", "y": "top"}, text, layout.desktop.desktopNode);
  246. }.bind(this));
  247. }.bind(this));
  248. }.bind(this));
  249. this.deleteForceDataAction = new Element("div", {"styles": this.css.setDefaultDataAction, "text": this.lp.clearForce}).inject(buttonNode);
  250. this.deleteForceDataAction.addEvent("click", function(){
  251. MWF.require("MWF.widget.UUID", function(){
  252. MWF.UD.deletePublicData("forceLayout", function(){
  253. this.notice(this.lp.clearok, "success");
  254. this.desktop.notRecordStatus = true;
  255. }.bind(this));
  256. }.bind(this));
  257. }.bind(this));
  258. }
  259. new Element("div", {"styles": this.css.layoutTitleNode, "text": this.lp.desktopBackground}).inject(this.layoutConfigNode);
  260. var UINode = new Element("div", {"styles": this.css.buttonNodeArea}).inject(this.layoutConfigNode);
  261. this.loadDesktopBackground(UINode);
  262. },
  263. loadDesktopBackground: function(UINode){
  264. var currentSrc = layout.desktop.options.style;
  265. MWF.UD.getDataJson("layoutDesktop", function(json){
  266. if (json) currentSrc = json.src;
  267. }.bind(this), false);
  268. MWF.getJSON(layout.desktop.path+"styles.json", function(json){
  269. json.each(function(style){
  270. var img = MWF.defaultPath+"/xDesktop/$Layout/"+style.style+"/preview.jpg";
  271. //var dskImg = MWF.defaultPath+"/xDesktop/$Layout/"+style.style+"/desktop.jpg";
  272. var imgArea = new Element("div", {"styles": this.css.previewBackground}).inject(UINode);
  273. if (currentSrc==style.style){
  274. imgArea.setStyles({"border": "4px solid #ffea00"});
  275. }
  276. new Element("img", {"src": img}).inject(imgArea);
  277. imgArea.store("dskimg", style.style);
  278. var _self = this;
  279. imgArea.addEvent("click", function(){ _self.selectDesktopImg(this, UINode); });
  280. }.bind(this));
  281. }.bind(this));
  282. //MWF.UD.getPublicData("layoutDesktopImgs", function(json){
  283. // if (json) currentSrc = json.src;
  284. //}.bind(this), false);
  285. //
  286. if (MWF.AC.isAdministrator()){
  287. }
  288. },
  289. selectDesktopImg: function(item, UINode){
  290. var desktopImg = item.retrieve("dskimg");
  291. MWF.UD.putData("layoutDesktop", {"src": desktopImg}, function(){
  292. UINode.getChildren().each(function(node){
  293. node.setStyles({"border": "4px solid #eeeeee"});
  294. }.bind(this));
  295. item.setStyles({"border": "4px solid #ffea00"});
  296. var dskImg = MWF.defaultPath+"/xDesktop/$Layout/"+desktopImg+"/desktop.jpg";
  297. layout.desktop.node.setStyle("background-image", "url("+dskImg+")");
  298. }.bind(this));
  299. },
  300. loadIdeaConfigNode: function(){
  301. this.ideaConfigNode = new Element("div", {"styles": this.css.configNode}).inject(this.content);
  302. this.ideasArea = new Element("textarea", {"styles": this.css.ideasArea}).inject(this.ideaConfigNode);
  303. this.ideasSaveAction = new Element("div", {"styles": this.css.ideasSaveAction, "text": this.lp.saveIdea}).inject(this.ideaConfigNode);
  304. if (MWF.AC.isAdministrator()){
  305. this.ideasSaveDefaultAction = new Element("div", {"styles": this.css.ideasSaveAction, "text": this.lp.saveIdeaDefault}).inject(this.ideaConfigNode);
  306. this.ideasSaveDefaultAction.addEvent("click", function(){
  307. MWF.require("MWF.widget.UUID", function(){
  308. var data = {};
  309. data.ideas = this.ideasArea.get("value").split("\n");
  310. MWF.UD.putPublicData("idea", data, function(){
  311. this.notice(this.lp.ideaSaveOk, "success");
  312. }.bind(this));
  313. }.bind(this));
  314. }.bind(this))
  315. }
  316. MWF.require("MWF.widget.UUID", function(){
  317. MWF.UD.getDataJson("idea", function(json){
  318. if (json){
  319. if (json.ideas) this.ideasArea.set("value", json.ideas.join("\n"));
  320. }
  321. }.bind(this));
  322. }.bind(this));
  323. this.ideasSaveAction.addEvent("click", function(){
  324. MWF.require("MWF.widget.UUID", function(){
  325. var data = {};
  326. data.ideas = this.ideasArea.get("value").split("\n");
  327. MWF.UD.putData("idea", data, function(){
  328. this.notice(this.lp.ideaSaveOk, "success");
  329. }.bind(this));
  330. }.bind(this));
  331. }.bind(this))
  332. },
  333. loadPasswordConfigNode: function(){
  334. this.passwordConfigNode = new Element("div", {"styles": this.css.configNode});
  335. this.passwordConfigAreaNode = new Element("div", {"styles": this.css.inforConfigAreaNode}).inject(this.passwordConfigNode);
  336. var _self = this;
  337. var lineNode = new Element("div", {"styles": this.css.inforLineNode}).inject(this.passwordConfigAreaNode);
  338. var titleNode = new Element("div", {"styles": this.css.inforTitleNode, "text": this.lp.oldPassword}).inject(lineNode);
  339. var contentNode = new Element("div", {"styles": this.css.inforContentNode}).inject(lineNode);
  340. this.oldPasswordInputNode = new Element("input", {"type": "password", "styles": this.css.inforContentInputNode, "events": {
  341. "blur": function(){this.setStyles(_self.css.inforContentInputNode);},
  342. "focus": function(){this.setStyles(_self.css.inforContentInputNode_focus);}
  343. }}).inject(contentNode);
  344. var lineNode = new Element("div", {"styles": this.css.inforLineNode}).inject(this.passwordConfigAreaNode);
  345. var titleNode = new Element("div", {"styles": this.css.inforTitleNode, "text": this.lp.password}).inject(lineNode);
  346. var contentNode = new Element("div", {"styles": this.css.inforContentNode}).inject(lineNode);
  347. this.passwordInputNode = new Element("input", {"type": "password", "styles": this.css.inforContentInputNode, "events": {
  348. "blur": function(){
  349. this.setStyles(_self.css.inforContentInputNode);
  350. },
  351. "focus": function(){this.setStyles(_self.css.inforContentInputNode_focus);},
  352. "keyup" : function(){ this.checkPassowrdStrength( this.passwordInputNode.get("value") ) }.bind(this)
  353. }}).inject(contentNode);
  354. var lineNode = new Element("div", {"styles": this.css.inforLineNode}).inject(this.passwordConfigAreaNode);
  355. var titleNode = new Element("div", {"styles": this.css.inforTitleNode}).inject(lineNode);
  356. this.passwordRemindContainer = new Element("div", {"styles": this.css.inforContentNode}).inject(lineNode);
  357. var lineNode = new Element("div", {"styles": this.css.inforLineNode}).inject(this.passwordConfigAreaNode);
  358. var titleNode = new Element("div", {"styles": this.css.inforTitleNode, "text": this.lp.morePassword}).inject(lineNode);
  359. var contentNode = new Element("div", {"styles": this.css.inforContentNode}).inject(lineNode);
  360. this.morePasswordInputNode = new Element("input", {"type": "password", "styles": this.css.inforContentInputNode, "events": {
  361. "blur": function(){this.setStyles(_self.css.inforContentInputNode);},
  362. "focus": function(){this.setStyles(_self.css.inforContentInputNode_focus);}
  363. }}).inject(contentNode);
  364. var lineNode = new Element("div", {"styles": this.css.inforLineNode}).inject(this.passwordConfigAreaNode);
  365. this.saveAction = new Element("div", {"styles": this.css.saveAction, "text": this.lp.passwordConfig}).inject(lineNode);
  366. this.saveAction.addEvent("click", function(){
  367. this.changePassword();
  368. }.bind(this));
  369. this.createPasswordStrengthNode();
  370. this.passworRemindNode = new Element("div",{"styles": this.css.passwordRemindNode, "text": this.lp.paswordRule }).inject( this.passwordRemindContainer );
  371. },
  372. changePassword: function(){
  373. var oldPassword = this.oldPasswordInputNode.get("value");
  374. var password = this.passwordInputNode.get("value");
  375. var morePassword = this.morePasswordInputNode.get("value");
  376. if (password!=morePassword){
  377. this.notice(this.lp.passwordNotMatch, "error");
  378. this.passwordInputNode.setStyles(this.css.inforContentInputNode_error);
  379. this.morePasswordInputNode.setStyles(this.css.inforContentInputNode_error);
  380. }else{
  381. this.action.changePassword(oldPassword, password, morePassword, function(){
  382. this.oldPasswordInputNode.set("value", "");
  383. this.passwordInputNode.set("value", "");
  384. this.morePasswordInputNode.set("value", "");
  385. this.notice(this.lp.changePasswordOk, "success");
  386. }.bind(this));
  387. if (layout.config.mail){
  388. var url = "http://"+layout.config.mail+"//names.nsf?changepassword&password="+encodeURIComponent(oldPassword)+"&passwordnew="+encodeURIComponent(password)+"&passwordconfirm="+encodeURIComponent(password);
  389. var iframe = new Element("iframe", {"styles": {"display": "none"}}).inject(this.desktop.desktopNode);
  390. iframe.set("src", url);
  391. window.setTimeout(function(){
  392. iframe.destroy();
  393. }.bind(this), 2000);
  394. }
  395. }
  396. },
  397. getAction: function(callback){
  398. if (!this.acrion){
  399. MWF.xDesktop.requireApp("Profile", "Actions.RestActions", function(){
  400. this.action = new MWF.xApplication.Profile.Actions.RestActions();
  401. if (callback) callback();
  402. }.bind(this));
  403. }else{
  404. if (callback) callback();
  405. }
  406. },
  407. createPasswordStrengthNode : function(){
  408. var passwordStrengthArea = this.passwordRemindContainer;
  409. var lowNode = new Element( "div", {styles : this.css.passwordStrengthNode }).inject( passwordStrengthArea );
  410. this.lowColorNode = new Element( "div", {styles : this.css.passwordStrengthColor }).inject( lowNode );
  411. this.lowTextNode = new Element( "div", {styles : this.css.passwordStrengthText, text : this.lp.weak }).inject( lowNode );
  412. var middleNode = new Element( "div" , {styles : this.css.passwordStrengthNode }).inject( passwordStrengthArea );
  413. this.middleColorNode = new Element( "div", {styles : this.css.passwordStrengthColor }).inject( middleNode );
  414. this.middleTextNode = new Element( "div", {styles : this.css.passwordStrengthText, text : this.lp.middle }).inject( middleNode );
  415. var highNode = new Element("div", {styles : this.css.passwordStrengthNode }).inject( passwordStrengthArea );
  416. this.highColorNode = new Element( "div", {styles : this.css.passwordStrengthColor }).inject( highNode );
  417. this.highTextNode = new Element( "div", {styles : this.css.passwordStrengthText, text : this.lp.high }).inject( highNode );
  418. },
  419. getPasswordLevel: function( password, callback ){
  420. /*Level(级别)
  421. •0-3 : [easy]
  422. •4-6 : [midium]
  423. •7-9 : [strong]
  424. •10-12 : [very strong]
  425. •>12 : [extremely strong]
  426. */
  427. this.getAction( function( ){
  428. this.action.checkPassword( password, function( json ){
  429. debugger;
  430. if(callback)callback( json.data.value );
  431. }.bind(this), null, false );
  432. }.bind(this) );
  433. },
  434. checkPassowrdStrength: function(pwd){
  435. this.lowColorNode.setStyles( this.css.passwordStrengthColor );
  436. this.lowTextNode.setStyles( this.css.passwordStrengthText );
  437. this.middleColorNode.setStyles( this.css.passwordStrengthColor );
  438. this.middleTextNode.setStyles( this.css.passwordStrengthText );
  439. this.highColorNode.setStyles( this.css.passwordStrengthColor );
  440. this.highTextNode.setStyles( this.css.passwordStrengthText );
  441. if (pwd==null||pwd==''){
  442. }else{
  443. this.getPasswordLevel( pwd, function( level ){
  444. switch(level) {
  445. case 0:
  446. case 1:
  447. case 2:
  448. case 3:
  449. this.lowColorNode.setStyles( this.css.passwordStrengthColor_low );
  450. this.lowTextNode.setStyles( this.css.passwordStrengthText_current );
  451. break;
  452. case 4:
  453. case 5:
  454. case 6:
  455. this.middleColorNode.setStyles( this.css.passwordStrengthColor_middle );
  456. this.middleTextNode.setStyles( this.css.passwordStrengthText_current );
  457. break;
  458. default:
  459. this.highColorNode.setStyles( this.css.passwordStrengthColor_high );
  460. this.highTextNode.setStyles( this.css.passwordStrengthText_current );
  461. }
  462. }.bind(this) )
  463. }
  464. }
  465. });