123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387 |
- /**
- * Created by CXY on 2017/5/8.
- */
- MWF.xApplication.Forum.TopNode = new Class({
- Extends: MWF.widget.Common,
- Implements: [Options, Events],
- options: {
- "style": "default",
- "settingEnable" : false,
- "logoutEnable" : true,
- "naviModeEnable" : false
- },
- initialize : function( container, app, explorer, options ){
- this.setOptions(options);
- this.container = container;
- this.app = app;
- this.lp = app.lp;
- this.restActions = app.restActions;
- this.access = app.access;
- this.explorer = explorer;
- this.userName = layout.desktop.session.user.distinguishedName || "";
- this.displayName = MWFForum.getDisplayName();
- this.path = "../x_component_Forum/$TopNode/";
- this.cssPath = "../x_component_Forum/$TopNode/" + this.options.style + "/css.wcss";
- this._loadCss();
- },
- load: function(){
- this.createTopNode();
- },
- getMainPageTitle : function(){
- var tail = (this.app.inBrowser && !this.access.isAnonymous()) ? (MWFForum.getSystemConfigValue( MWFForum.BBS_TITLE_TAIL ) || "") : "";
- return ( MWFForum.getBBSName() || MWF.xApplication.Forum.LP.title ) + tail;
- },
- openMainPage : function(){
- if( this.app.inBrowser || this.options.naviMode ){
- this.app.clearContent();
- if(this.app.node)this.app.node.destroy();
- MWF.xDesktop.requireApp("Forum", "MainInContainer", null, false);
- var forum = new MWF.xApplication.Forum.MainInContainer( this.app.desktop, {
- "hasTop" : true,
- "hasBreadCrumb" : true,
- "naviMode" : false,
- "autoWidth" : false
- }, this.app.content, this.app.content , this.app.content );
- forum.inBrowser = this.app.inBrowser;
- forum.window = this.app.window;
- forum.taskitem = this.app.taskitem;
- forum.load();
- this.app.setTitle( this.getMainPageTitle() );
- }else{
- var appId = "Forum";
- if (this.app.desktop.apps[appId]){
- var app = this.app.desktop.apps[appId];
- app.setCurrent();
- app.clearContent();
- app.loadApplicationLayout();
- }else {
- this.app.desktop.openApplication(null, "Forum", { "appId": appId });
- this.app.close();
- }
- }
- },
- createTopNode: function () {
- this.topContainerNode = new Element("div.topContainerNode", {
- "styles": this.css.topContainerNode
- }).inject(this.container);
- this.topNode = new Element("div.topNode", {
- "styles": this.css.topNode
- }).inject(this.topContainerNode);
- this.topMainPageNode = new Element("div.topMainPageNode",{
- "styles" : { "cursor" : "pointer" }
- }).inject(this.topNode);
- this.topMainPageNode.addEvent("click", function(){
- this.openMainPage();
- }.bind(this));
- //this.getSystemSetting( "BBS_LOGO_NAME", function( data ){
- this.restActions.getBBSName( function( json ){
- var data = json.data;
- if( data.configValue && data.configValue!="" && data.configValue!="O2社区" ){
- this.bbsName = data.configValue;
- this.topTextNode = new Element("div.topTextNode", {
- "styles": this.css.topTextNode,
- "text": data.configValue
- }).inject(this.topMainPageNode)
- }else{
- this.topIconNode = new Element("div", {
- "styles": this.css.topIconNode
- }).inject(this.topMainPageNode)
- }
- }.bind(this), null, false );
- //}.bind(this), false )
- this.topContentNode = new Element("div", {
- "styles": this.css.topContentNode
- }).inject(this.topNode);
- if( this.access.isAnonymous() ){
- if( this.access.signUpMode != "disable" ){
- this.signupNode = new Element("div", {
- "styles": this.css.signupNode
- }).inject(this.topContentNode);
- //this.signupIconNode = new Element("div", {
- // "styles": this.css.signupIconNode
- //}).inject(this.signupNode);
- this.signupTextNode = new Element("div", {
- "styles": this.css.signupTextNode,
- "text": this.lp.signup
- }).inject(this.signupNode);
- this.signupNode.addEvent("click", function(){ this.openSignUpForm( ) }.bind(this));
- new Element("div",{
- "styles" : this.css.topSepNode,
- "text" : "|"
- }).inject(this.topContentNode);
- }
- this.loginNode = new Element("div", {
- "styles": this.css.loginNode
- }).inject(this.topContentNode);
- //this.loginIconNode = new Element("div", {
- // "styles": this.css.loginIconNode
- //}).inject(this.loginNode);
- this.loginTextNode = new Element("div", {
- "styles": this.css.loginTextNode,
- "text": this.lp.login
- }).inject(this.loginNode);
- this.loginNode.addEvent("click", function(){ this.openLoginForm( ) }.bind(this));
- if( this.options.naviModeEnable ){
- new Element("div",{
- "styles" : this.css.topSepNode,
- "text" : "|"
- }).inject(this.topContentNode);
- this.loadNaviNode();
- }
- }else{
- if( this.app.inBrowser && this.options.logoutEnable ){
- this.logoutNode = new Element("div", {
- "styles": this.css.logoutNode
- }).inject(this.topContentNode);
- //this.logoutIconNode = new Element("div", {
- // "styles": this.css.logoutIconNode
- //}).inject(this.logoutNode);
- this.logoutTextNode = new Element("div", {
- "styles": this.css.logoutTextNode,
- "text": this.lp.logout
- }).inject(this.logoutNode);
- this.logoutNode.addEvent("click", function(){ this.logout( ) }.bind(this));
- new Element("div",{
- "styles" : this.css.topSepNode,
- "text" : "|"
- }).inject(this.topContentNode);
- }
- if( this.options.settingEnable ){
- this.settingArea = new Element("div", {
- styles : { float : "right" }
- }).inject(this.topContentNode);
- this.access.getUserPermission(function (permission) {
- if( this.access.isAdmin() || permission.bbsAdmin || permission.bbsForumAdmin || permission.bbsSectionAdmin ){
- this.settingNode = new Element("div", {
- "styles": this.css.settingNode
- }).inject(this.settingArea);
- //this.settingIconNode = new Element("div", {
- // "styles": this.css.settingIconNode
- //}).inject(this.settingNode);
- this.settingTextNode = new Element("div", {
- "styles": this.css.settingTextNode,
- "text": this.lp.setting,
- "title" : this.lp.forumConfig
- }).inject(this.settingNode);
- this.settingNode.addEvent("click", function(){ this.app.openSetting( ) }.bind(this));
- new Element("div", {
- "styles": this.css.topSepNode,
- "text": "|"
- }).inject(this.settingArea);
- }else{
- this.settingArea.hide();
- }
- }.bind(this))
- }
- if( this.options.naviModeEnable ){
- this.loadNaviNode();
- new Element("div", {
- "styles": this.css.topSepNode,
- "text": "|"
- }).inject(this.topContentNode);
- }
- this.personNode = new Element("div", {
- "styles": this.css.personNode
- }).inject(this.topContentNode);
- //this.personIconNode = new Element("div", {
- // "styles": this.css.personIconNode
- //}).inject(this.personNode);
- this.personTextNode = new Element("div", {
- "styles": this.css.personTextNode,
- "text": MWF.xApplication.Forum.LP.welcomeTitle.replace("{user}", ( this.displayName || "").split("@")[0]),
- "title" : MWF.xApplication.Forum.LP.seePersonCenter
- }).inject(this.personNode);
- this.personNode.addEvent("click", function(){ this.openPerson(this.userName ) }.bind(this))
- }
- this.searchDiv = new Element("div.searchDiv",{
- "styles" : this.css.searchDiv
- }).inject(this.topNode);
- this.searchInput = new Element("input.searchInput",{
- "styles" : this.css.searchInput,
- "value" : this.lp.searchKey,
- "title" : (!this.app.access.isAnonymous() && MWFForum.isUseNickName()) ? this.lp.searchTitleNick : this.lp.searchTitle
- }).inject(this.searchDiv);
- var _self = this;
- this.searchInput.addEvents({
- "focus": function(){
- if (this.value==_self.lp.searchKey) this.set("value", "");
- },
- "blur": function(){if (!this.value) this.set("value", _self.lp.searchKey);},
- "keydown": function(e){
- if (e.code==13){
- this.search();
- e.preventDefault();
- }
- }.bind(this)
- });
- this.searchAction = new Element("div.searchAction",{
- "styles" : this.css.searchAction
- }).inject(this.searchDiv);
- this.searchAction.addEvents({
- "click": function(){ this.search(); }.bind(this),
- "mouseover": function(e){
- this.searchAction.setStyles( this.css.searchAction_over2 );
- e.stopPropagation();
- }.bind(this),
- "mouseout": function(){ this.searchAction.setStyles( this.css.searchAction ) }.bind(this)
- });
- this.searchDiv.addEvents( {
- "mouseover" : function(){
- this.searchInput.setStyles( this.css.searchInput_over );
- this.searchAction.setStyles( this.css.searchAction_over )
- }.bind(this),
- "mouseout" : function(){
- this.searchInput.setStyles( this.css.searchInput );
- this.searchAction.setStyles( this.css.searchAction )
- }.bind(this)
- });
- this._createTopContent();
- },
- loadNaviNode : function(){
- if( this.options.naviModeEnable ){
- this.naviNode = new Element("div", {
- "styles": this.css.settingNode
- }).inject(this.topContentNode);
- if( this.options.naviMode ){
- this.closeNaviTextNode = new Element("div", {
- "styles": this.css.settingTextNode,
- "text": MWF.xApplication.Forum.LP.closeNavi,
- "title" : MWF.xApplication.Forum.LP.closeNavi
- }).inject(this.naviNode);
- this.closeNaviTextNode.addEvent("click", function(){ this.app.closeNavi( ) }.bind(this));
- }else{
- this.naviTextNode = new Element("div", {
- "styles": this.css.settingTextNode,
- "text": MWF.xApplication.Forum.LP.navi,
- "title" : MWF.xApplication.Forum.LP.naviLayout
- }).inject(this.naviNode);
- this.naviTextNode.addEvent("click", function(){
- this.app.openNavi( )
- }.bind(this));
- }
- }
- },
- _createTopContent: function () {
- },
- getSystemSetting : function( code, callback, async ){
- this.restActions.getSystemSettingByCode( {configCode : code }, function(json) {
- if (callback)callback(json.data);
- }.bind(this), null, async )
- },
- search : function(){
- var val = this.searchInput.get("value");
- if( val == "" || val == this.lp.searchKey ){
- this.notice( this.lp.noSearchContentNotice, "error" );
- return;
- }
- var appId = "ForumSearch";
- if( this.app.options.name == "ForumSearch" ){
- this.app.search( val );
- }else if (this.app.desktop.apps[appId] && !this.app.inBrowser){
- var app = this.app.desktop.apps[appId];
- app.setCurrent();
- app.search( val );
- }else{
- this.app.desktop.openApplication(null, "ForumSearch", {
- "appId": appId,
- "searchContent" : val
- });
- }
- },
- openPerson : function( userName, data ){
- MWFForum.openPersonCenter( userName, data );
- },
- openLoginForm : function(){
- MWF.require("MWF.xDesktop.Authentication", null, false);
- var authentication = new MWF.xDesktop.Authentication({
- "style" : "flat",
- "popupStyle_password": "o2platformSignupFlat",
- onPostOk : function(){
- window.location.reload();
- }
- },this.app);
- authentication.popupOptions = {
- "draggable": true,
- "closeAction": true,
- "hasMask": true,
- "relativeToApp": true,
- "width": "420",
- "height": "640"
- };
- // authentication.loadLogin(this.app.content);
- authentication.openLoginForm();
- },
- openSignUpForm : function(){
- MWF.require("MWF.xDesktop.Authentication", null, false);
- var authentication = new MWF.xDesktop.Authentication( {
- style : "flat",
- "popupStyle_password": "o2platformSignupFlat",
- onPostOk : function(){
- }
- }, this.app);
- authentication.popupOptions = {
- "draggable": true,
- "closeAction": true,
- "hasMask": true,
- "relativeToApp": true,
- "width": "420",
- "height": "640"
- };
- authentication.openSignUpForm();
- },
- logout: function(){
- MWF.Actions.get("x_organization_assemble_authentication").logout(function () {
- if (this.socket) {
- this.socket.close();
- this.socket = null;
- }
- Cookie.dispose(o2.tokenName);
- if (layout.session && layout.session.user) layout.session.user.token = "";
- if( layout.session )layout.session.token = "";
- layout.desktop.session.user.distinguishedName = "anonymous";
- this.app.clearContent();
- this.app.loadApplicationContent();
- this.openLoginForm();
- // if( callback ){
- // callback()
- // }else{
- // window.location.reload();
- // }
- }.bind(this));
- }
- });
|