87,984
社区成员
发帖
与我相关
我的任务
分享
function $(id) { return document.getElementById(id); }
function addLoadEvent(func){
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function(){
oldonload();
func();
}
}
}
function moveElement(elementID,final_x,final_y,interval) {
if (!document.getElementById) return false;
if (!document.getElementById(elementID)) return false;
var elem = document.getElementById(elementID);
if (elem.movement) {
clearTimeout(elem.movement);
}
if (!elem.style.left) {
elem.style.left = "0px";
}
if (!elem.style.top) {
elem.style.top = "0px";
}
var xpos = parseInt(elem.style.left);
var ypos = parseInt(elem.style.top);
if (xpos == final_x && ypos == final_y) {
return true;
}
if (xpos < final_x) {
var dist = Math.ceil((final_x - xpos)/10);
xpos = xpos + dist;
}
if (xpos > final_x) {
var dist = Math.ceil((xpos - final_x)/10);
xpos = xpos - dist;
}
if (ypos < final_y) {
var dist = Math.ceil((final_y - ypos)/10);
ypos = ypos + dist;
}
if (ypos > final_y) {
var dist = Math.ceil((ypos - final_y)/10);
ypos = ypos - dist;
}
elem.style.left = xpos + "px";
elem.style.top = ypos + "px";
var repeat = "moveElement('"+elementID+"',"+final_x+","+final_y+","+interval+")";
elem.movement = setTimeout(repeat,interval);
}
function classNormal(iFocusBtnID,iFocusTxID){
var iFocusBtns= $(iFocusBtnID).getElementsByTagName('li');
var iFocusTxs = $(iFocusTxID).getElementsByTagName('li');
for(var i=0; i<iFocusBtns.length; i++) {
iFocusBtns[i].className='normal';
iFocusTxs[i].className='normal';
}
}
function classCurrent(iFocusBtnID,iFocusTxID,n){
var iFocusBtns= $(iFocusBtnID).getElementsByTagName('li');
var iFocusTxs = $(iFocusTxID).getElementsByTagName('li');
iFocusBtns[n].className='current';
iFocusTxs[n].className='current';
}
function iFocusChange() {
if(!$('ifocus')) return false;
$('ifocus').onmouseover = function(){atuokey = true};
$('ifocus').onmouseout = function(){atuokey = false};
var iFocusBtns = $('ifocus_btn').getElementsByTagName('li');
var iFocusImgs = $('ifocus_btn').getElementsByTagName('img');
var listLength = iFocusBtns.length;
iFocusBtns[0].onmouseover = function() {
moveElement('ifocus_piclist',0,0,7);
classNormal('ifocus_btn','ifocus_tx');
classCurrent('ifocus_btn','ifocus_tx',0);
}
if (listLength>=2) {
iFocusBtns[1].onmouseover = function() {
moveElement('ifocus_piclist',0,-384,7);
classNormal('ifocus_btn','ifocus_tx');
classCurrent('ifocus_btn','ifocus_tx',1);
}
}
if (listLength>=3) {
iFocusBtns[2].onmouseover = function() {
moveElement('ifocus_piclist',0,-768,7);
classNormal('ifocus_btn','ifocus_tx');
classCurrent('ifocus_btn','ifocus_tx',2);
}
}
if (listLength>=4) {
iFocusBtns[3].onmouseover = function() {
moveElement('ifocus_piclist',0,-1152,7);
classNormal('ifocus_btn','ifocus_tx');
classCurrent('ifocus_btn','ifocus_tx',3);
}
}
if (listLength>=5) {
iFocusBtns[4].onmouseover = function() {
moveElement('ifocus_piclist',0,-1536,7);
classNormal('ifocus_btn','ifocus_tx');
classCurrent('ifocus_btn','ifocus_tx',4);
}
}
if (listLength>=6) {
iFocusBtns[5].onmouseover = function() {
moveElement('ifocus_piclist',0,-1920,7);
classNormal('ifocus_btn','ifocus_tx');
classCurrent('ifocus_btn','ifocus_tx',5);
}
}
}
setInterval('autoiFocus()',5000);
var atuokey = false;
function autoiFocus() {
if(!$('ifocus')) return false;
if(atuokey) return false;
var focusBtnList = $('ifocus_btn').getElementsByTagName('li');
var listLength = focusBtnList.length;
for(var i=0; i<listLength; i++) {
if (focusBtnList[i].className == 'current') var currentNum = i;
}
if (currentNum==0 && listLength!=1 ){
moveElement('ifocus_piclist',0,-384,7);
classNormal('ifocus_btn','ifocus_tx');
classCurrent('ifocus_btn','ifocus_tx',1);
}
if (currentNum==1 && listLength!=2 ){
moveElement('ifocus_piclist',0,-768,7);
classNormal('ifocus_btn','ifocus_tx');
classCurrent('ifocus_btn','ifocus_tx',2);
}
if (currentNum==2 && listLength!=3 ){
moveElement('ifocus_piclist',0,-1152,7);
classNormal('ifocus_btn','ifocus_tx');
classCurrent('ifocus_btn','ifocus_tx',3);
}
if (currentNum==3 && listLength!=4 ){
moveElement('ifocus_piclist',0,-1536,7);
classNormal('ifocus_btn','ifocus_tx');
classCurrent('ifocus_btn','ifocus_tx',4);
}
if (currentNum==4 && listLength!=5 ){
moveElement('ifocus_piclist',0,-1920,7);
classNormal('ifocus_btn','ifocus_tx');
classCurrent('ifocus_btn','ifocus_tx',5);
}
if (currentNum==5 ){
moveElement('ifocus_piclist',0,0,7);
classNormal('ifocus_btn','ifocus_tx');
classCurrent('ifocus_btn','ifocus_tx',0);
}
}
addLoadEvent(iFocusChange);
function $(id) { return document.getElementById(id); }
function addLoadEvent(func){
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function(){
oldonload();
func();
}
}
}
怎么修改啊?
/* index */
function sidemenu(id){
var $obj = $(id), sideMenuIndex = -1;
$obj.children("li").each(function(i){
if(window.location.href.indexOf($(this).children("a").attr("href")) > -1){
sideMenuIndex = i;
if($(this).find("li").size() > 0){
$(this).addClass("withsub");
}
$(this).children("a").eq(0).addClass("on");
$(this).children("ul").show();
}
});
$obj.find("li:has(li) li").each(function(i){
if(window.location.href.indexOf($(this).children("a").attr("href")) > -1){
sideMenuIndex = i;
$(this).addClass("hover");
$(this).parent().parent().addClass("withsub").children("a").eq(0).addClass("on");
$(this).parent("ul").show();
}
});
}
(function (b) {
b.fn.superfish = function (k) {
var g = b.fn.superfish,
j = g.c,
f = b(['<span class="', j.arrowClass, '"> »</span>'].join("")),
i = function () {
var c = b(this),
l = d(c);
clearTimeout(l.sfTimer);
c.showSuperfishUl().siblings().hideSuperfishUl()
},
e = function () {
var c = b(this),
m = d(c),
l = g.op;
clearTimeout(m.sfTimer);
m.sfTimer = setTimeout(function () {
l.retainPath = (b.inArray(c[0], l.$path) > -1);
c.hideSuperfishUl();
if (l.$path.length && c.parents(["li.", l.hoverClass].join("")).length < 1) {
i.call(l.$path)
}
}, l.delay)
},
d = function (c) {
var l = c.parents(["ul.", j.menuClass, ":first"].join(""))[0];
g.op = g.o[l.serial];
return l
},
h = function (c) {
c.addClass(j.anchorClass).append(f.clone())
};
return this.each(function () {
var c = this.serial = g.o.length;
var m = b.extend({}, g.defaults, k);
m.$path = b("li." + m.pathClass, this).slice(0, m.pathLevels).each(function () {
b(this).addClass([m.hoverClass, j.bcClass].join(" ")).filter("li:has(ul)").removeClass(m.pathClass)
});
g.o[c] = g.op = m;
b("li:has(ul)", this)[(b.fn.hoverIntent && !m.disableHI) ? "hoverIntent" : "hover"](i, e).each(function () {
if (m.autoArrows) {
h(b(">a:first-child", this))
}
}).not("." + j.bcClass).hideSuperfishUl();
var l = b("a", this);
l.each(function (n) {
var o = l.eq(n).parents("li");
l.eq(n).focus(function () {
i.call(o)
}).blur(function () {
e.call(o)
})
});
m.onInit.call(this)
}).each(function () {
var c = [j.menuClass];
if (g.op.dropShadows && !(b.browser.msie && b.browser.version < 7)) {
c.push(j.shadowClass)
}
b(this).addClass(c.join(" "))
})
};
var a = b.fn.superfish;
a.o = [];
a.op = {};
a.IE7fix = function () {
var c = a.op;
if (b.browser.msie && b.browser.version > 6 && c.dropShadows && c.animation.opacity != undefined) {
this.toggleClass(a.c.shadowClass + "-off")
}
};
a.c = {
bcClass: "sf-breadcrumb",
menuClass: "sf-js-enabled",
anchorClass: "sf-with-ul",
arrowClass: "sf-sub-indicator",
shadowClass: "sf-shadow"
};
a.defaults = {
hoverClass: "sfHover",
pathClass: "overideThisToUse",
pathLevels: 1,
delay: 800,
animation: {
opacity: "show"
},
speed: "normal",
autoArrows: true,
dropShadows: true,
disableHI: false,
onInit: function () {},
onBeforeShow: function () {},
onShow: function () {},
onHide: function () {}
};
b.fn.extend({
hideSuperfishUl: function () {
var e = a.op,
d = (e.retainPath === true) ? e.$path : "";
e.retainPath = false;
var c = b(["li.", e.hoverClass].join(""), this).add(this).not(d).removeClass(e.hoverClass).find(">ul").hide().css("visibility", "hidden");
e.onHide.call(c);
return this
},
showSuperfishUl: function () {
var e = a.op,
d = a.c.shadowClass + "-off",
c = this.addClass(e.hoverClass).find(">ul:hidden").css("visibility", "visible");
a.IE7fix.call(c);
e.onBeforeShow.call(c);
c.animate(e.animation, e.speed, function () {
a.IE7fix.call(c);
e.onShow.call(c)
});
return this
}
})
})(jQuery);
//导航3级栏目下拉
$(document).ready(function() {
$("#nav").superfish({
delay: 500,
animation: {opacity:'show',height:'show'},
speed: 'fast',
autoArrows: false,
dropShadows: false
});
});
$(function(){
$("#nav ul.third").each(function(){
var hasthird = $(this).find("li").size();
if(hasthird==0)
{
$(this).addClass("thirdNone");
}
})
})
请高手帮忙