function trim(s) {
return s.replace(/^\s*/, "").replace(/\s*$/, "");
}
/**
* 限制字数,第一个传要限制的className,第二个传限制的字数
* @author: wxl
**/
function limitTextNum(className, num) {
var limitNum = num;
$("."+className+"").each(function () {
var curText = $(this).text();
var curLength = $(this).text().length;
if (curLength > num) {
curText = $(this).text(curText.substring(0, limitNum) + ‘...‘);
}
});
}
/**
* 菜单折叠
* @author: wxl
**/
function initMenu() {
$(".listArea").hide();
$(‘.listArea:first‘).show();
$(‘#dynamic_list .list_title‘).click(
function () {
var checkElement = $(this).next();
if ((checkElement.is(‘div‘)) && (checkElement.is(‘:visible‘))) {
return false;
}
if ((checkElement.is(‘div‘)) && (!checkElement.is(‘:visible‘))) {
$(this).children("div").children("a").css("background", "url(/Content/Images/Home/ico.PNG) no-repeat left center");
$(‘.listArea:visible‘).prev("div").children("div").children("a").css("background", "url(/Content/Images/Home/ico2.PNG) no-repeat left center");
$(‘.listArea:visible‘).slideUp(‘fast‘);
checkElement.slideDown(‘fast‘);
return false;
}
}
);
}
/**
*图片翻滚
*@author wxl
**/
function rollPictures() {
var t = 0, count;
var rollPics = $("#pictureArea div").slice(0, index.rollNewsPicsLength);
count = rollPics.length - 1;
rollPics.not(‘:first‘).hide();
$("#pageStyle .pageUp").click(function () {
t--;
if (t < 0) t = count;
if (t == count) {
$("#pictureArea div").eq(0).hide();
$("#pictureArea div").eq(t).fadeIn("slow");
}
else {
$("#pictureArea div").eq(t + 1).hide();
$("#pictureArea div").eq(t).fadeIn("slow");
}
})
$("#pageStyle .pageDown").click(function () {
t++;
if (t > count) t = 0;
$("#pictureArea div").eq(t).fadeIn("slow");
if (t == 0) {
$("#pictureArea div").eq(count).hide();
} else {
$("#pictureArea div").eq(t - 1).hide();
}
})
//设一个定时器,每三秒翻滚图片
setInterval(function () {
$("#pageStyle .pageDown").click();
}, 5000)
}