TopNode.js 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. /**
  2. * Created by CXY on 2017/5/8.
  3. */
  4. MWF.xApplication.Forum.TopNode = new Class({
  5. Extends: MWF.widget.Common,
  6. Implements: [Options, Events],
  7. options: {
  8. "style": "default",
  9. "settingEnable" : false
  10. },
  11. initialize : function( container, app, explorer, options ){
  12. this.setOptions(options);
  13. this.container = container;
  14. this.app = app;
  15. this.lp = app.lp;
  16. this.restActions = app.restActions;
  17. this.access = app.access;
  18. this.explorer = explorer;
  19. this.userName = layout.desktop.session.user.name;
  20. this.path = "/x_component_Forum/$TopNode/";
  21. this.cssPath = "/x_component_Forum/$TopNode/" + this.options.style + "/css.wcss";
  22. this._loadCss();
  23. },
  24. load: function(){
  25. this.createTopNode();
  26. },
  27. openMainPage : function(){
  28. var appId = "Forum";
  29. if (this.app.desktop.apps[appId]){
  30. var app = this.app.desktop.apps[appId];
  31. app.setCurrent();
  32. app.clearContent();
  33. app.loadApplicationLayout();
  34. }else {
  35. this.app.desktop.openApplication(null, "Forum", { "appId": appId });
  36. this.app.close();
  37. }
  38. },
  39. createTopNode: function () {
  40. this.topContainerNode = new Element("div.topContainerNode", {
  41. "styles": this.css.topContainerNode
  42. }).inject(this.container);
  43. this.topNode = new Element("div.topNode", {
  44. "styles": this.css.topNode
  45. }).inject(this.topContainerNode);
  46. this.topMainPageNode = new Element("div.topMainPageNode",{
  47. "styles" : { "cursor" : "pointer" }
  48. }).inject(this.topNode);
  49. this.topMainPageNode.addEvent("click", function(){
  50. this.openMainPage();
  51. }.bind(this));
  52. //this.getSystemSetting( "BBS_LOGO_NAME", function( data ){
  53. this.restActions.getBBSName( function( json ){
  54. var data = json.data;
  55. if( data.configValue && data.configValue!="" && data.configValue!="企业论坛" ){
  56. this.topTextNode = new Element("div.topTextNode", {
  57. "styles": this.css.topTextNode,
  58. "text": data.configValue
  59. }).inject(this.topMainPageNode)
  60. }else{
  61. this.topIconNode = new Element("div", {
  62. "styles": this.css.topIconNode
  63. }).inject(this.topMainPageNode)
  64. }
  65. }.bind(this), null, false );
  66. //}.bind(this), false )
  67. this.topContentNode = new Element("div", {
  68. "styles": this.css.topContentNode
  69. }).inject(this.topNode);
  70. if( this.access.isAnonymous() ){
  71. if( this.access.signUpMode != "disable" ){
  72. this.signupNode = new Element("div", {
  73. "styles": this.css.signupNode
  74. }).inject(this.topContentNode);
  75. //this.signupIconNode = new Element("div", {
  76. // "styles": this.css.signupIconNode
  77. //}).inject(this.signupNode);
  78. this.signupTextNode = new Element("div", {
  79. "styles": this.css.signupTextNode,
  80. "text": this.lp.signup
  81. }).inject(this.signupNode);
  82. this.signupNode.addEvent("click", function(){ this.openSignUpForm( ) }.bind(this))
  83. }
  84. new Element("div",{
  85. "styles" : this.css.topSepNode,
  86. "text" : "/"
  87. }).inject(this.topContentNode);
  88. this.loginNode = new Element("div", {
  89. "styles": this.css.loginNode
  90. }).inject(this.topContentNode);
  91. //this.loginIconNode = new Element("div", {
  92. // "styles": this.css.loginIconNode
  93. //}).inject(this.loginNode);
  94. this.loginTextNode = new Element("div", {
  95. "styles": this.css.loginTextNode,
  96. "text": this.lp.login
  97. }).inject(this.loginNode);
  98. this.loginNode.addEvent("click", function(){ this.openLoginForm( ) }.bind(this))
  99. }else{
  100. if( this.inBrowser ){
  101. this.logoutNode = new Element("div", {
  102. "styles": this.css.logoutNode
  103. }).inject(this.topContentNode);
  104. //this.logoutIconNode = new Element("div", {
  105. // "styles": this.css.logoutIconNode
  106. //}).inject(this.logoutNode);
  107. this.logoutTextNode = new Element("div", {
  108. "styles": this.css.logoutTextNode,
  109. "text": this.lp.logout
  110. }).inject(this.logoutNode);
  111. this.logoutNode.addEvent("click", function(){ this.logout( ) }.bind(this))
  112. new Element("div",{
  113. "styles" : this.css.topSepNode,
  114. "text" : "/"
  115. }).inject(this.topContentNode);
  116. }
  117. if( this.options.settingEnable ){
  118. this.settingNode = new Element("div", {
  119. "styles": this.css.settingNode
  120. }).inject(this.topContentNode);
  121. //this.settingIconNode = new Element("div", {
  122. // "styles": this.css.settingIconNode
  123. //}).inject(this.settingNode);
  124. this.settingTextNode = new Element("div", {
  125. "styles": this.css.settingTextNode,
  126. "text": this.lp.setting
  127. }).inject(this.settingNode);
  128. this.settingNode.addEvent("click", function(){ this.app.openSetting( ) }.bind(this));
  129. }
  130. if( this.options.settingEnable ) {
  131. new Element("div", {
  132. "styles": this.css.topSepNode,
  133. "text": "/"
  134. }).inject(this.topContentNode);
  135. }
  136. this.personNode = new Element("div", {
  137. "styles": this.css.personNode
  138. }).inject(this.topContentNode);
  139. //this.personIconNode = new Element("div", {
  140. // "styles": this.css.personIconNode
  141. //}).inject(this.personNode);
  142. this.personTextNode = new Element("div", {
  143. "styles": this.css.personTextNode,
  144. "text": this.lp.personCenter
  145. }).inject(this.personNode);
  146. this.personNode.addEvent("click", function(){ this.openPerson(this.userName ) }.bind(this))
  147. }
  148. this.searchDiv = new Element("div.searchDiv",{
  149. "styles" : this.css.searchDiv
  150. }).inject(this.topNode);
  151. this.searchInput = new Element("input.searchInput",{
  152. "styles" : this.css.searchInput,
  153. "value" : this.lp.searchKey,
  154. "title" : this.lp.searchTitle
  155. }).inject(this.searchDiv);
  156. var _self = this;
  157. this.searchInput.addEvents({
  158. "focus": function(){
  159. if (this.value==_self.lp.searchKey) this.set("value", "");
  160. },
  161. "blur": function(){if (!this.value) this.set("value", _self.lp.searchKey);},
  162. "keydown": function(e){
  163. if (e.code==13){
  164. this.search();
  165. e.preventDefault();
  166. }
  167. }.bind(this)
  168. });
  169. this.searchAction = new Element("div.searchAction",{
  170. "styles" : this.css.searchAction
  171. }).inject(this.searchDiv);
  172. this.searchAction.addEvents({
  173. "click": function(){ this.search(); }.bind(this),
  174. "mouseover": function(e){
  175. this.searchAction.setStyles( this.css.searchAction_over2 );
  176. e.stopPropagation();
  177. }.bind(this),
  178. "mouseout": function(){ this.searchAction.setStyles( this.css.searchAction ) }.bind(this)
  179. });
  180. this.searchDiv.addEvents( {
  181. "mouseover" : function(){
  182. this.searchInput.setStyles( this.css.searchInput_over );
  183. this.searchAction.setStyles( this.css.searchAction_over )
  184. }.bind(this),
  185. "mouseout" : function(){
  186. this.searchInput.setStyles( this.css.searchInput );
  187. this.searchAction.setStyles( this.css.searchAction )
  188. }.bind(this)
  189. });
  190. this._createTopContent();
  191. },
  192. _createTopContent: function () {
  193. },
  194. getSystemSetting : function( code, callback, async ){
  195. this.restActions.getSystemSettingByCode( {configCode : code }, function(json) {
  196. if (callback)callback(json.data);
  197. }.bind(this), null, async )
  198. },
  199. search : function(){
  200. var val = this.searchInput.get("value");
  201. if( val == "" || val == this.lp.searchKey ){
  202. this.notice( this.lp.noSearchContentNotice, "error" );
  203. return;
  204. }
  205. var appId = "ForumSearch";
  206. if (this.app.desktop.apps[appId] && !this.inBrowser){
  207. this.app.desktop.apps[appId].close();
  208. }
  209. this.app.desktop.openApplication(null, "ForumSearch", {
  210. "appId": appId,
  211. "searchContent" : val
  212. });
  213. },
  214. openPerson : function( userName ){
  215. var appId = "ForumPerson"+userName;
  216. if (this.app.desktop.apps[appId]){
  217. this.app.desktop.apps[appId].setCurrent();
  218. }else {
  219. this.app.desktop.openApplication(null, "ForumPerson", {
  220. "personName" : userName,
  221. "appId": appId
  222. });
  223. }
  224. }
  225. });