Last active
August 29, 2015 14:05
-
-
Save hacke2/5434a4346a1169f8b97b to your computer and use it in GitHub Desktop.
管理学院Js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function trim(s) { | |
return s.replace(/^\s*/, "").replace(/\s*$/, ""); | |
} | |
/* | |
* 限制字数,第一个传要限制的className,第二个传限制的字数 | |
* @author: wxl | |
**/ | |
function limitTextNum(className, num) { | |
var limitNum = num; | |
$("." + className + "").each(function () { | |
var curText = $.trim($(this).text()); | |
var curLength = curText.length; | |
var i = 0; | |
var myLen = 0; | |
for (; (i < curLength) && (i <= limitNum); i++) { | |
if (curText.charCodeAt(i) > 0 && curText.charCodeAt(i) < 128) | |
myLen += 2; | |
else | |
myLen++; | |
} | |
// alert(curText); | |
//alert(myLen); | |
if (curLength > num) { | |
curText = $(this).text(curText.substring(0, myLen) + '...'); | |
} | |
if (curLength == 0) { | |
$(this).text("点击标题查看详情"); | |
} | |
}); | |
/** | |
* 菜单折叠 | |
* @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) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment