2019-03-27 13:51:30 +08:00

91 lines
3.4 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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(); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
this.initNoticeList();//<2F><>ʼ<EFBFBD><CABC>ҳ<EFBFBD><D2B3>mainnotice.js
this.windowHeight=$(window).height();
this.noticeHeight=16;
this.speed=300; //<2F><>ʱ<EFBFBD>ٶ<EFBFBD>
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.notcieLength<lastIndex){lastIndex=this.notcieLength}
for(var i=0;i<lastIndex;i++){
if(this.noticeJson[i].BoardTitle=="<22><><EFBFBD><EFBFBD>"){
this.mainNoticeBody.append($("<div class='main_notice_more'>more</div>"));
}else{
var showNotice="<div class='noticecontent'><a onclick=\"";
if(this.noticeJson[i].IsEject=="Y"){
showNotice+="openFile('"+this.noticeJson[i].BoardNo+"','"+this.noticeJson[i].BoardTitle+"');"
}
showNotice+="return false;\" hidefocus href='javascript:void(0)' ><span>"+(i+1)+"<22><>"+this.noticeJson[i].BoardTitle+"</span>";
if(this.noticeJson[i].IsNew=="Y"){
showNotice+="<span class='icon_new'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>"
}
showNotice+="</a></div>"
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(); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
this.initNoticeList();//<2F><>ʼ<EFBFBD><CABC>ҳ<EFBFBD><D2B3>
//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");
}