hondy.js非成熟版本,每周更新!以hondy.site.login.js.hondy.form.js为准
$(function () {
$(".sethome,.favorite").click(function () {
if ($(this).hasClass("sethome")) {
setHome($(this)[0], '');
} else {
AddFavorite("", "");
}
});
var cur = $("menu ul .on").index();
$("menu ul li").hover(function () {
$("menu ul li").removeClass();
$(this).addClass("on");
}, function () {
$("menu ul li").removeClass();
$("menu ul li").eq(cur).addClass("on");
})
$.getScript("../../../systhemes/js/bootstrap.min.js", function () {
var navbar = $("navbar-toggler");
if (navbar.length > 0) {
for (var i = 0; i < navbar.length; i++) {
var o = navbar.eq(i);
var menu = o.attr("menu");
var show = o.attr("show");
var hide = "";
if (show == true) {
show = ' aria-expanded="true"';
} else {
show = ' aria-expanded="false"';
hide = "display:none";
}
o.html('<button class="navbar-toggler fa fa-navicon ' + o.attr("btn") + '"' + show + '></button><div class="' + o.attr("menu") + '" style="' + hide + '">' + $("#" + o.attr("tar")).html() + '</div>');
o.find("button").click(function () {
switch ($(this).attr("act")) {
case "in":
if ($(this).attr("aria-expanded") == "false") {
$(this).attr("aria-expanded", "true");
$(this).next().fadeIn(800);
} else {
$(this).attr("aria-expanded", "false");
$(this).next().fadeOut(800);
}
break;
default:
if ($(this).attr("aria-expanded") == "false") {
$(this).attr("aria-expanded", "true");
} else {
$(this).attr("aria-expanded", "false");
}
$(this).next().slideToggle(800);
break;
}
});
window.onresize = function () {
o.find("button").attr("aria-expanded", "false");
o.find("button").next().fadeOut();
}
}
}
});
$(".TabTitle").hover(function () {
$(this).closest("#TabStrip").find(".TabContent").addClass("hide");
$(this).closest("#TabStrip").find(".TabContent").eq($(this).index() - 1).removeClass("hide");
})
ulbox();
isImgLoad(carousel);
});
var ulbox = function () {
var o = $(".ul-col");
if (o.length > 0) {
for (var i = 0; i < o.length; i++) {
var w = o.eq(i).find("ul").width();
w = w / responsive(w);
o.eq(i).find("li").css("width", w);
}
}
}
$(window).bind('resize', function () {
ulbox();
});
var rndsearch = function (css, max) {
var kw = $("." + css).find(".Descript").html();
var k = kw.split(' ');
var kws = [];
var html = "";
for (var i = 0; i < k.length; i++) {
if (k != "") {
kws.push(k);
}
}
var rand = [];
rand = rnd(0, kws.length, max);
for (var i = 0; i < rand.length; i++) {
html = html + "<a>" + kws[rand] + "</a>"
}
$("." + css).find(".Descript").html(html).find("a").on("click", function () {
var kw = $(this).html();
$.send("", {
kw: kw,
so: 1
});
});
}
var rnd = function (min, max, count) {
var randoms = [];
while (true) {
var isExists = false;
var random = parseInt(min + (max - min) * (Math.random()))
for (var i = 0; i < randoms.length; i++) {
if (random === randoms) {
isExists = true;
break;
}
}
if (!isExists)
randoms.push(random);
if (randoms.length === count)
break;
}
return randoms;
}
function responsive(v) {
if (v > 1200) {
return 5;
}
if (v > 960) {
return 4;
}
if (v > 720) {
return 3;
}
return 2
}
function AddFavorite(sURL, sTitle) {
try {
if (typeof (sURL) == "undefined" || sURL.length == 0) {
sURL = window.location;
}
if (typeof (sTitle) == "undefined" || sTitle.length == 0) {
sTitle = document.title;
}
window.external.addFavorite(sURL, sTitle);
} catch (e) {
try {
window.sidebar.addPanel(sTitle, sURL, "");
} catch (e) {
alert("您使用的浏览器不支持此功能,请按“Ctrl + D”键手工加入收藏!");
}
}
}
function setHome(objid, urls) {
var a = objid,
b = urls,
c = "unknown";
try {
if (typeof (b) == "undefined" || b.length == 0) {
b = location.href;
}
a.style.behavior = "url(#default#homepage)";
var d = a.isHomePage(b);
d = (d = d || a.isHomePage(b + "/")) || a.isHomePage(b + "/#");
d = "" + d;
if (d != "true") {
a.setHomePage(b);
} else {
alert("您已经设为首页了!");
}
} catch (e) {
alert("您的浏览器不支持自动设置主页,请使用浏览器菜单手动设置!");
return "unknown"
}
};
var marquee = [];
var carousel = function (v) {
if ($(v).length > 0) {
$.getScript("../../../systhemes/js/msclass.js", function () {
var count = $(v).length;
for (var i = 0; i < count; i++) {
if (i == 0) {
var ID = "";
} else {
var ID = i
}
var MSClassID = $(v).eq(i).attr("sid");
if (MSClassID == undefined) {
var MSClassID = v + ID;
} else {
MSClassID = MSClassID + ID
}
$(v).eq(i).find("ul").wrapAll("<div id='" + MSClassID + "'></div>");
var w = $("#" + MSClassID).width();
if ($(v).eq(i).attr("mode") == "full") {
var ContentID = "BoxContent" + ID;
$(v).eq(i).find("ul").attr("id", ContentID);
var delay = 5000;
var dir = 2;
var ss = w;
var st = 2;
var step = 0.1
} else {
var delay = 1000;
var dir = 2;
var ss = parseInt(w / responsive(w));
var st = 0;
var step = 2;
}
$(v).eq(i).find("li").css({
width: ss
});
var h = parseInt($(v).eq(i).find("ul li").outerHeight());
$(v).eq(i).find("ul").css({
"display": "inline-flex",
"flex-wrap": "nowrap"
})
marquee = new Marquee({
MSClassID: MSClassID,
ContentID: ContentID,
Direction: dir,
Step: step,
Width: w,
Height: h,
Timer: 1,
DelayTime: delay,
WaitTime: 3000,
SwitchType: st,
ScrollStep: ss,
AutoStart: 1
});
}
var resizeTimer = null;
$(window).bind('resize', function () {
if (resizeTimer) clearTimeout(resizeTimer);
resizeTimer = setTimeout(function () {
for (var i = 0; i < count; i++) {
$(v).eq(i).find("ul").closest("div").css({
width: "100%",
height: $(v).eq(i).find("ul li").outerHeight()
});
}
}, 500);
});
});
}
}
$.extend({
send: function (url, args) {
var body = $(document.body),
form = $("<form method='post'></form>"),
input;
form.attr({
"action": url
});
$.each(args, function (key, value) {
input = $("<input type='hidden'>");
input.attr({
"name": key
});
input.val(value);
form.append(input)
});
form.appendTo(document.body);
form.submit();
document.body.removeChild(form[0])
}
});
var t_img;
var isLoad = true;
var isImgLoad = function (callback, v) {
if (v == undefined) v = "carousel";
$(v).find('img').each(function () {
if (this.height === 0) {
isLoad = false;
return false;
}
});
if (isLoad) {
clearTimeout(t_img);
callback(v);
} else {
isLoad = true;
t_img = setTimeout(function () {
isImgLoad(callback, v);
}, 500);
}
}
|