var CompanyNotice=function(curHeight){ this.noticeJson={}; this.notcieLength=0; this.maxMayShow=parseInt(curHeight/30); this.maxShowNumber=3000; this.mainNoticeBody=$("#main_notice_body"); this.mainNoticeBody.height($(window).height()+"px"); this.loadNotice(); //加载数据 this.initNoticeList();//初始化页面mainnotice.js this.windowHeight=$(window).height(); this.noticeHeight=16; this.speed=300; //定时速度 if(this.notcieLength>this.maxMayShow){ this.mainNoticeBody.css("margin-top",$(window).height()+"px"); this.setAutoScroll(); this.autoScrollObject=null; } } CompanyNotice.prototype.loadNotice=function(){ var strMenuJson =RunJavaMethodTrans("com.tenwa.homepage.HomeNotice","getNotices","mianshow="+this.maxShowNumber); strMenuJson=strMenuJson.replace(/\//g,""); if(strMenuJson==""){ this.notcieLength=0; }else{ this.noticeJson=JSON.parse(strMenuJson); this.notcieLength=this.noticeJson.length; } } CompanyNotice.prototype.initNoticeList=function(){ this.mainNoticeBody.empty(); if(this.notcieLength>0){ var lastIndex=this.maxShowNumber; if(this.notcieLengthmore")); }else{ var showNotice="
"+(i+1)+"、"+this.noticeJson[i].BoardTitle+""; if(this.noticeJson[i].IsNew=="Y"){ showNotice+="      " } showNotice+="
" this.mainNoticeBody.append($(showNotice)); } } } } CompanyNotice.prototype.initWindowResize=function(){ var tempCompanyNotice=this; $(window).resize(function() { tempCompanyNotice.resizeNotice($(window).height()); }); } CompanyNotice.prototype.resizeNotice=function(curHeight){ this.maxShowNumber=parseInt(curHeight/30); this.loadNotice(); //加载数据 this.initNoticeList();//初始化页面 //this.initNoticeOnclick(); } CompanyNotice.prototype.createCallback=function(fn,args){ return function(){ fn.call(window,args); } } CompanyNotice.prototype.setAutoScroll=function(){ this.autoScrollObject=setInterval(this.createCallback(noticeScoll,this),this.speed); this.mainNoticeBody.mouseover(this.createCallback(removeNotinceScollFuntion,this.autoScrollObject)); this.mainNoticeBody.mouseout(this.createCallback(addNotinceScollFuntion,this)) } var addNotinceScollFuntion=function(noticeObject){ var autoScrollObject=setInterval(noticeObject.createCallback(noticeScoll,noticeObject),noticeObject.speed); noticeObject.mainNoticeBody.mouseover(noticeObject.createCallback(removeNotinceScollFuntion,autoScrollObject)); } var removeNotinceScollFuntion=function(noticeObject){ clearInterval(noticeObject); } var noticeScoll=function(noticeObject){ var c=noticeObject.mainNoticeBody.css("margin-top"); c=parseFloat(c.replace("px","")); c=c-5; if((c*-1)>(noticeObject.noticeHeight*noticeObject.notcieLength)){ c=noticeObject.windowHeight; } noticeObject.mainNoticeBody.css("margin-top",c+"px"); }