| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363 |
- MWF.xApplication.Forum.Navi = new Class({
- Extends: MWF.widget.Common,
- Implements: [Options, Events],
- options : {
- "style" : "default",
- "id" :"" ,
- "type" : "all"
- },
- initialize: function(app, container, options){
- this.setOptions(options);
- this.path = "/x_component_Forum/$Navi/";
- this.cssPath = "/x_component_Forum/$Navi/"+this.options.style+"/css.wcss";
- this._loadCss();
- this.app = app;
- this.container = $(container);
- },
- load: function(){
- var self = this;
- this.node = new Element("div.naviNode", {
- "styles": this.css.naviNode
- }).inject(this.container);
- this.allItem = new MWF.xApplication.Forum.AllItem( this, this.node );
- this.recommandItem = new MWF.xApplication.Forum.RecommandItem( this, this.node );
- this.categoryItemList = [];
- MWF.Actions.get("x_bbs_assemble_control").listCategoryAll( function( json ) {
- (json.data || []).each(function (d) {
- var categoryItem = new MWF.xApplication.Forum.CategoryItem(this, this.node,d );
- this.categoryItemList.push( categoryItem );
- this.fireEvent("postLoad");
- }.bind(this))
- }.bind(this))
- }
- });
- MWF.xApplication.Forum.CategoryItem = new Class({
- initialize: function ( navi, container, data ) {
- this.type = "category";
- this.navi = navi;
- this.app = navi.app;
- this.data = data;
- this.container = $(container);
- this.css = navi.css;
- this.load();
- },
- load: function () {
- var _self = this;
- this.isCurrent = false;
- this.isExpended = true;
- this.hasSub = true;
- this.sectionItemList = [];
- if( this.navi.options.id == this.data.id && this.navi.options.type == "category" ){
- this.isCurrent = true;
- }
- this.node = new Element("div.categoryNode", {
- "styles": this.css.categoryNode
- }).inject(this.container);
- this.expendNode = new Element("div.categoryExpendNode").inject(this.node);
- this.setExpendNodeStyle();
- if( this.hasSub ){
- this.expendNode.addEvent( "click" , function(ev){
- this.triggerExpend();
- ev.stopPropagation();
- }.bind(this));
- }
- this.textNode = new Element("div.categoryTextNode",{
- "styles": this.css.categoryTextNode,
- "text": this.data.forumName
- }).inject(this.node);
- this.node.addEvents({
- "mouseover": function(){ if ( !_self.isCurrent )this.setStyles(_self.css.categoryNode_over) },
- "mouseout": function(){ if ( !_self.isCurrent )this.setStyles( _self.css.categoryNode ) },
- click : function(){ _self.setCurrent(this);}
- });
- this.listNode = new Element("div.sectionListNode",{
- "styles" : this.css.sectionListNode
- }).inject(this.container);
- this.loadListContent();
- if( this.isCurrent ){
- this.setCurrent();
- }
- },
- setExpendNodeStyle : function(){
- var style;
- if( this.hasSub ){
- if( this.isExpended ){
- if( this.isCurrent ){
- style = this.css.categoryExpendNode_selected;
- }else{
- style = this.css.categoryExpendNode;
- }
- }else{
- if( this.isCurrent ){
- style = this.css.categoryCollapseNode_selected;
- }else{
- style = this.css.categoryCollapseNode;
- }
- }
- }else{
- style = this.css.emptyExpendNode;
- }
- this.expendNode.setStyles( style );
- },
- triggerExpend : function(){
- if( this.hasSub ){
- if( this.isExpended ){
- this.isExpended = false;
- this.listNode.setStyle("display","none")
- }else{
- this.isExpended = true;
- this.listNode.setStyle("display","")
- }
- this.setExpendNodeStyle();
- }
- },
- setCurrent : function(){
- if( this.navi.currentItem ){
- this.navi.currentItem.cancelCurrent();
- }
- this.node.setStyles( this.css.categoryNode_selected );
- if( this.hasSub ){
- if( this.isExpended ){
- this.expendNode.setStyles( this.css.categoryExpendNode_selected );
- }else{
- this.expendNode.setStyles( this.css.categoryCollapseNode_selected );
- }
- }
- this.isCurrent = true;
- this.navi.currentItem = this;
- this.loadView();
- },
- cancelCurrent : function(){
- this.isCurrent = false;
- this.node.setStyles( this.css.categoryNode );
- if( this.hasSub ){
- if( this.isExpended ){
- this.expendNode.setStyles( this.css.categoryExpendNode );
- }else{
- this.expendNode.setStyles( this.css.categoryCollapseNode );
- }
- }
- },
- loadView: function( searchkey ){
- this.app.openView( this, this.data, this.viewData || this.defaultRevealData, searchkey || "", this );
- },
- loadListContent : function(){
- var d = this.data;
- if(d.forumStatus != "停用" ){
- MWF.Actions.get("x_bbs_assemble_control").listSection(d.id , function ( json ) {
- (json.data || []).each( function( sectiondata ){
- var sectionItem = new MWF.xApplication.Forum.SectionItem(this.navi, this, this.listNode, sectiondata );
- this.sectionItemList.push( sectionItem );
- }.bind(this))
- }.bind(this));
- }
- new Element("div", {
- "styles": this.css.categorySepartorNode
- }).inject( this.listNode );
- },
- getCategoryId : function(){
- return this.data.id;
- }
- });
- MWF.xApplication.Forum.SectionItem = new Class({
- initialize: function ( navi, category, container, data) {
- this.type = "section";
- this.navi = navi;
- this.category = category;
- this.app = navi.app;
- this.data = data;
- this.container = $(container);
- this.css = navi.css;
- this.load();
- },
- load: function(){
- var _self = this;
- this.isCurrent = false;
- if( this.navi.options.type == "section" && this.navi.options.id == this.data.id ){
- this.isCurrent = true;
- }
- var _self = this;
- this.node = new Element("div.sectionNode", {
- "styles": this.css.sectionNode,
- "text" : this.data.sectionName
- }).inject(this.container);
- this.node.addEvents({
- "mouseover": function(){ if (!_self.isCurrent)this.setStyles(_self.css.sectionNode_over) },
- "mouseout": function(){ if (!_self.isCurrent)this.setStyles( _self.css.sectionNode ) },
- "click": function (el) {
- _self.setCurrent();
- }
- });
- if( this.isCurrent ){
- this.setCurrent()
- }
- },
- setCurrent : function(){
- if( this.navi.currentItem ){
- this.navi.currentItem.cancelCurrent();
- }
- this.node.setStyles( this.css.sectionNode_selected );
- this.isCurrent = true;
- this.navi.currentItem = this;
- this.loadView();
- },
- cancelCurrent : function(){
- this.isCurrent = false;
- this.node.setStyles( this.css.sectionNode );
- },
- getCategoryId : function(){
- return this.category.data.id;
- },
- loadView : function( searchKey ){
- this.app.openView( this, this.category.data, this.data, searchKey || "", this );
- }
- });
- MWF.xApplication.Forum.AllItem = new Class({
- initialize: function ( navi, container) {
- this.type = "all";
- this.navi = navi;
- this.app = navi.app;
- this.container = $(container);
- this.css = navi.css;
- this.load();
- },
- load: function(){
- var _self = this;
- this.isCurrent = false;
- if( this.navi.options.type == "all" ){
- this.isCurrent = true;
- }
- var _self = this;
- this.node = new Element("div.allNode", {
- "styles": this.css.allNode,
- "text" : "全部帖子"
- }).inject(this.container);
- this.node.addEvents({
- "mouseover": function(){ if (!_self.isCurrent)this.setStyles(_self.css.allNode_over) },
- "mouseout": function(){ if (!_self.isCurrent)this.setStyles( _self.css.allNode ) },
- "click": function (el) {
- _self.setCurrent();
- }
- });
- if( this.isCurrent ){
- this.setCurrent()
- }
- },
- setCurrent : function(){
- if( this.navi.currentItem ){
- this.navi.currentItem.cancelCurrent();
- }
- this.node.setStyles( this.css.allNode_selected );
- this.isCurrent = true;
- this.navi.currentItem = this;
- this.loadView();
- },
- cancelCurrent : function(){
- this.isCurrent = false;
- this.node.setStyles( this.css.allNode );
- },
- getCategoryId : function(){
- return null;
- },
- loadView : function( searchKey ){
- this.app.openView( this, null, this.data, searchKey || "", this );
- }
- });
- MWF.xApplication.Forum.RecommandItem = new Class({
- initialize: function ( navi, container) {
- this.type = "recommand";
- this.navi = navi;
- this.app = navi.app;
- this.container = $(container);
- this.css = navi.css;
- this.load();
- },
- load: function(){
- var _self = this;
- this.isCurrent = false;
- if( this.navi.options.type == "recommand" ){
- this.isCurrent = true;
- }
- var _self = this;
- this.node = new Element("div.recommandNode", {
- "styles": this.css.recommandNode,
- "text" : "推荐帖子"
- }).inject(this.container);
- this.node.addEvents({
- "mouseover": function(){ if (!_self.isCurrent)this.setStyles(_self.css.recommandNode_over) },
- "mouseout": function(){ if (!_self.isCurrent)this.setStyles( _self.css.recommandNode ) },
- "click": function (el) {
- _self.setCurrent();
- }
- });
- if( this.isCurrent ){
- this.setCurrent()
- }
- },
- setCurrent : function(){
- if( this.navi.currentItem ){
- this.navi.currentItem.cancelCurrent();
- }
- this.node.setStyles( this.css.recommandNode_selected );
- this.isCurrent = true;
- this.navi.currentItem = this;
- this.loadView();
- },
- cancelCurrent : function(){
- this.isCurrent = false;
- this.node.setStyles( this.css.recommandNode );
- },
- getCategoryId : function(){
- return null;
- },
- loadView : function( searchKey ){
- this.app.openView( this, null, this.data, searchKey || "", this );
- }
- });
|