2010-01-12 135 views
3

我一直在使用這兩個jquery文件一段時間,試圖調試它們,但我不明白爲什麼它們不能一起工作。2 jquery腳本不能一起工作

任何建議將是真棒,非常感謝。

預先感謝您!

========START JS#1===================== 
window.onerror=function(desc,page,line,chr){ 
/* alert('JavaScript error occurred! \n' 
    +'\nError description: \t'+desc 
    +'\nPage address:  \t'+page 
    +'\nLine number:  \t'+line 
);*/ 
} 

$(function(){ 
$('a').focus(function(){this.blur();}); 
SI.Files.stylizeAll(); 
slider.init(); 
mc.init(); 

$('input.text-default').each(function(){ 
    $(this).attr('default',$(this).val()); 
}).focus(function(){ 
    if($(this).val()==$(this).attr('default')) 
    $(this).val(''); 
}).blur(function(){ 
    if($(this).val()=='') 
    $(this).val($(this).attr('default')); 
}); 

$('input.text,textarea.text').focus(function(){ 
    $(this).addClass('textfocus'); 
}).blur(function(){ 
    $(this).removeClass('textfocus'); 
}); 

var popopenobj=0,popopenaobj=null; 
$('a.popup').click(function(){ 
    var pid=$(this).attr('rel').split('|')[0],_os=parseInt($(this).attr('rel').split('|')[1]); 
    var pobj=$('#'+pid); 
    if(!pobj.length) 
    return false; 
    if(typeof popopenobj=='object' && popopenobj.attr('id')!=pid){ 
    popopenobj.hide(50); 
    $(popopenaobj).parent().removeClass(popopenobj.attr('id').split('-')[1]+'-open'); 
    popopenobj=null; 
    } 
    return false; 
}); 
$('p.images img').click(function(){ 
    var newbg=$(this).attr('src').split('bg/bg')[1].split('-thumb')[0]; 
    $(document.body).css('backgroundImage','url('+_siteRoot+'images/bg/bg'+newbg+'.jpg)'); 

    $(this).parent().find('img').removeClass('on'); 
    $(this).addClass('on'); 
    return false; 
}); 
$(window).load(function(){ 
    $.each(css_ims,function(){(new Image()).src=_siteRoot+'css/images/'+this;}); 
    $.each(css_cims,function(){ 
    var css_im=this; 
    $.each(['blue','purple','pink','red','grey','green','yellow','orange'],function(){ 
    (new Image()).src=_siteRoot+'css/'+this+'/'+css_im; 
    }); 
    }); 
}); 
$('div.sc-large div.img:has(div.tml)').each(function(){ 
    $('div.tml',this).hide(); 
    $(this).append('<a href="#" class="tml_open">&nbsp;</a>').find('a').css({ 
    left:parseInt($(this).offset().left)+864,top:parseInt($(this).offset().top)+1 
    }).click(function(){ 
    $(this).siblings('div.tml').slideToggle(); 
    return false; 
    }).focus(function(){this.blur();}); 
}); 
}); 
var slider={ 
num:-1, 
cur:0, 
cr:[], 
al:null, 
at:10*1000, 
ar:true, 
init:function(){ 
    if(!slider.data || !slider.data.length) 
    return false; 

    var d=slider.data; 
    slider.num=d.length; 
    var pos=Math.floor(Math.random()*1);//slider.num); 
    for(var i=0;i<slider.num;i++){ 
    $('#'+d[i].id).css({left:((i-pos)*1000)}); 
    $('#slide-nav').append('<a id="slide-link-'+i+'" href="#" onclick="slider.slide('+i+');return false;" onfocus="this.blur();">'+(i+1)+'</a>'); 
    } 

    $('img,div#slide-controls',$('div#slide-holder')).fadeIn(); 
    slider.text(d[pos]); 
    slider.on(pos); 
    slider.cur=pos; 
    window.setTimeout('slider.auto();',slider.at); 
}, 
auto:function(){ 
    if(!slider.ar) 
    return false; 

    var next=slider.cur+1; 
    if(next>=slider.num) next=0; 
    slider.slide(next); 
}, 
slide:function(pos){ 
    if(pos<0 || pos>=slider.num || pos==slider.cur) 
    return; 

    window.clearTimeout(slider.al); 
    slider.al=window.setTimeout('slider.auto();',slider.at); 

    var d=slider.data; 
    for(var i=0;i<slider.num;i++) 
    $('#'+d[i].id).stop().animate({left:((i-pos)*1000)},1000,'swing'); 

    slider.on(pos); 
    slider.text(d[pos]); 
    slider.cur=pos; 
}, 
on:function(pos){ 
    $('#slide-nav a').removeClass('on'); 
    $('#slide-nav a#slide-link-'+pos).addClass('on'); 
}, 
text:function(di){ 
    slider.cr['a']=di.client; 
    slider.cr['b']=di.desc; 
    slider.ticker('#slide-client span',di.client,0,'a'); 
    slider.ticker('#slide-desc',di.desc,0,'b'); 
}, 
ticker:function(el,text,pos,unique){ 
    if(slider.cr[unique]!=text) 
    return false; 

    ctext=text.substring(0,pos)+(pos%2?'-':'_'); 
    $(el).html(ctext); 

    if(pos==text.length) 
    $(el).html(text); 
    else 
    window.setTimeout('slider.ticker("'+el+'","'+text+'",'+(pos+1)+',"'+unique+'");',30); 
} 
}; 
// STYLING FILE INPUTS 1.0 | Shaun Inman <http://www.shauninman.com/> | 2007-09-07 
if(!window.SI){var SI={};}; 
SI.Files={ 
htmlClass:'SI-FILES-STYLIZED', 
fileClass:'file', 
wrapClass:'cabinet', 

fini:false, 
able:false, 
init:function(){ 
    this.fini=true; 
}, 
stylize:function(elem){ 
    if(!this.fini){this.init();}; 
    if(!this.able){return;}; 

    elem.parentNode.file=elem; 
    elem.parentNode.onmousemove=function(e){ 
    if(typeof e=='undefined') e=window.event; 
    if(typeof e.pageY=='undefined' && typeof e.clientX=='number' && document.documentElement){ 
    e.pageX=e.clientX+document.documentElement.scrollLeft; 
    e.pageY=e.clientY+document.documentElement.scrollTop; 
    }; 
    var ox=oy=0; 
    var elem=this; 
    if(elem.offsetParent){ 
    ox=elem.offsetLeft; 
    oy=elem.offsetTop; 
    while(elem=elem.offsetParent){ 
    ox+=elem.offsetLeft; 
    oy+=elem.offsetTop; 
    }; 
    }; 
    }; 
}, 
stylizeAll:function(){ 
    if(!this.fini){this.init();}; 
    if(!this.able){return;}; 
} 
}; 


=========END JS FILE #1======================== 


=========START JS FILE #2====================== 


/* 
* Superfish v1.4.8 - jQuery menu widget 
* Copyright (c) 2008 Joel Birch 
* 
* Dual licensed under the MIT and GPL licenses: 
* http://www.opensource.org/licenses/mit-license.php 
* http://www.gnu.org/licenses/gpl.html 
* 
* CHANGELOG: http://users.tpg.com.au/j_birch/plugins/superfish/changelog.txt 
*/ 

;(function($){ 
    $.fn.superfish = function(op){ 

     var sf = $.fn.superfish, 
      c = sf.c, 
      $arrow = $(['<span class="',c.arrowClass,'"> &#187;</span>'].join('')), 
      over = function(){ 
       var $$ = $(this), menu = getMenu($$); 
       clearTimeout(menu.sfTimer); 
       $$.showSuperfishUl().siblings().hideSuperfishUl(); 
      }, 
      out = function(){ 
       var $$ = $(this), menu = getMenu($$), o = sf.op; 
       clearTimeout(menu.sfTimer); 
       menu.sfTimer=setTimeout(function(){ 
        o.retainPath=($.inArray($$[0],o.$path)>-1); 
        $$.hideSuperfishUl(); 
        if (o.$path.length && $$.parents(['li.',o.hoverClass].join('')).length<1){over.call(o.$path);} 
       },o.delay); 
      }, 
      getMenu = function($menu){ 
       var menu = $menu.parents(['ul.',c.menuClass,':first'].join(''))[0]; 
       sf.op = sf.o[menu.serial]; 
       return menu; 
      }, 
      addArrow = function($a){ $a.addClass(c.anchorClass).append($arrow.clone()); }; 

     return this.each(function() { 
      var s = this.serial = sf.o.length; 
      var o = $.extend({},sf.defaults,op); 
      o.$path = $('li.'+o.pathClass,this).slice(0,o.pathLevels).each(function(){ 
       $(this).addClass([o.hoverClass,c.bcClass].join(' ')) 
        .filter('li:has(ul)').removeClass(o.pathClass); 
      }); 
      sf.o[s] = sf.op = o; 

      $('li:has(ul)',this)[($.fn.hoverIntent && !o.disableHI) ? 'hoverIntent' : 'hover'](over,out).each(function() { 
       if (o.autoArrows) addArrow($('>a:first-child',this)); 
      }) 
      .not('.'+c.bcClass) 
       .hideSuperfishUl(); 

      var $a = $('a',this); 
      $a.each(function(i){ 
       var $li = $a.eq(i).parents('li'); 
       $a.eq(i).focus(function(){over.call($li);}).blur(function(){out.call($li);}); 
      }); 
      o.onInit.call(this); 

     }).each(function() { 
      var menuClasses = [c.menuClass]; 
      if (sf.op.dropShadows && !($.browser.msie && $.browser.version < 7)) menuClasses.push(c.shadowClass); 
      $(this).addClass(menuClasses.join(' ')); 
     }); 
    }; 

    var sf = $.fn.superfish; 
    sf.o = []; 
    sf.op = {}; 
    sf.IE7fix = function(){ 
     var o = sf.op; 
     if ($.browser.msie && $.browser.version > 6 && o.dropShadows && o.animation.opacity!=undefined) 
      this.toggleClass(sf.c.shadowClass+'-off'); 
     }; 
    sf.c = { 
     bcClass  : 'sf-breadcrumb', 
     menuClass : 'sf-js-enabled', 
     anchorClass : 'sf-with-ul', 
     arrowClass : 'sf-sub-indicator', 
     shadowClass : 'sf-shadow' 
    }; 
    sf.defaults = { 
     hoverClass : 'sfHover', 
     pathClass : 'overideThisToUse', 
     pathLevels : 1, 
     delay  : 2500, 
     animation : {opacity:'show'}, 
     speed  : 'fast', 
     autoArrows : false, 
     dropShadows : false, 
     disableHI : false,  // true disables hoverIntent detection 
     onInit  : function(){}, // callback functions 
     onBeforeShow: function(){}, 
     onShow  : function(){}, 
     onHide  : function(){} 
    }; 
    $.fn.extend({ 
     hideSuperfishUl : function(){ 
      var o = sf.op, 
       not = (o.retainPath===true) ? o.$path : ''; 
      o.retainPath = false; 
      var $ul = $(['li.',o.hoverClass].join(''),this).add(this).not(not).removeClass(o.hoverClass) 
        .find('>ul').hide().css('visibility','hidden'); 
      o.onHide.call($ul); 
      return this; 
     }, 
     showSuperfishUl : function(){ 
      var o = sf.op, 
       sh = sf.c.shadowClass+'-off', 
       $ul = this.addClass(o.hoverClass) 
        .find('>ul:hidden').css('visibility','visible'); 
      sf.IE7fix.call($ul); 
      o.onBeforeShow.call($ul); 
      $ul.animate(o.animation,o.speed,function(){ sf.IE7fix.call($ul); o.onShow.call($ul); }); 
      return this; 
     } 
    }); 

})(jQuery); 


=============== end js file #2 ============================ 
+0

@wilwaldon - 這不是讓所有*你的工作爲你完成的地方。 ;-)你在添加了這兩個插件的頁面上看到了什麼錯誤? – 2010-01-12 23:31:44

+0

有人可以編輯這個和使用降價所以代碼即更容易閱讀? – 2010-01-12 23:31:57

+1

...你可以請發佈減少版本,仍然複製你有問題嗎?嘗試一次刪除代碼塊,直到事情開始工作(然後將其刪除,然後將其刪除,等等)。 – strager 2010-01-12 23:33:17

回答

1

,當我拉開你的網站,我注意到的第一件事情是,你有你的腳本加載jQuery腳本(特別是assets/jqueryslidemenu.js)之前獲取調用。嘗試將jQuery移動到正在加載的第一個腳本。

編輯:移動該文件到第一個位置後,它看起來像這不是唯一的問題,但。有3個變量我找不到在任何地方聲明。如果這是預期的,則忽略更新。 來自scripts.js的變量mc,css_imscss_cims是未定義的變量。

+0

你我的朋友,是個天才。我剛剛學到了一個寶貴的教訓,非常感謝你:) – wilwaldon 2010-01-12 23:52:22