我正在使用自定义版本的twitter bootstrap以及另一个用于移动导航的脚本(ACT Theme)。但由于某种原因,当我添加它们时,它们似乎彼此冲突。
具体来说,点击三次标签后,或点击三次Bootstrap轮播箭头后,它就不再起作用了。但是,如果我删除ACT脚本,则功能正常。
将脚本添加到JSFiddle.net,因为它略大于此处允许的内容。
以下是自定义引导脚本以及ACT主题脚本:
https://jsfiddle.net/2uhaf07L/
/*!
* Act Theme - JavaScript v1.2.10
* (c) Copyright Neambo (www.neambo.com)
* Unminified version: contact@neambo.com
*/
"use strict";/*!
* FitVids 1.1
* Copyright 2013, Chris Coyier - http://css-tricks.com + Dave Rupert - http://daverupert.com
* Credit to Thierry Koblentz - http://www.alistapart.com/articles/creating-intrinsic-ratios-for-video/
* Released under the WTFPL license - http://sam.zoy.org/wtfpl/
*/
!function(t){t.fn.fitVids=function(e){var i={customSelector:null,ignore:null};if(!document.getElementById("fit-vids-style")){var n=document.head||document.getElementsByTagName("head")[0],o=".fluid-width-video-wrapper{width:100%;position:relative;padding:0;}.fluid-width-video-wrapper iframe,.fluid-width-video-wrapper object,.fluid-width-video-wrapper embed {position:absolute;top:0;left:0;width:100%;height:100%;}",s=document.createElement("div");s.innerHTML='<p>x</p><style id="fit-vids-style">'+o+"</style>",n.appendChild(s.childNodes[1])}return e&&t.extend(i,e),this.each(function(){var e=["iframe[src*='player.vimeo.com']","iframe[src*='youtube.com']","iframe[src*='youtube-nocookie.com']","iframe[src*='kickstarter.com'][src*='video.html']","object","embed"];i.customSelector&&e.push(i.customSelector);var n=".fitvidsignore";i.ignore&&(n=n+", "+i.ignore);var o=t(this).find(e.join(","));o=o.not("object object"),o=o.not(n),o.each(function(){var e=t(this);if(!(e.parents(n).length>0||"embed"===this.tagName.toLowerCase()&&e.parent("object").length||e.parent(".fluid-width-video-wrapper").length)){e.css("height")||e.css("width")||!isNaN(e.attr("height"))&&!isNaN(e.attr("width"))||(e.attr("height",9),e.attr("width",16));var i="object"===this.tagName.toLowerCase()||e.attr("height")&&!isNaN(parseInt(e.attr("height"),10))?parseInt(e.attr("height"),10):e.height(),o=isNaN(parseInt(e.attr("width"),10))?e.width():parseInt(e.attr("width"),10),s=i/o;if(!e.attr("id")){var r="fitvid"+Math.floor(999999*Math.random());e.attr("id",r)}e.wrap('<div class="fluid-width-video-wrapper"></div>').parent(".fluid-width-video-wrapper").css("padding-top",100*s+"%"),e.removeAttr("height").removeAttr("width")}})})}}(window.jQuery||window.Zepto),/*!
* Handle lack of OBJECT.BIND() in old IE
*/
Function.prototype.bind||(Function.prototype.bind=function(t){if("function"!=typeof this)throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");var e=Array.prototype.slice.call(arguments,1),i=this,n=function(){},o=function(){return i.apply(this instanceof n&&t?this:t,e.concat(Array.prototype.slice.call(arguments)))};return n.prototype=this.prototype,o.prototype=new n,o}),!function(t,e){"function"==typeof define&&define.amd?define(["jquery"],e):e("object"==typeof exports?require("jquery"):t.jQuery)}(this,function(t){function e(t){var e,i,n,o,s,r,a,c={};for(s=t.replace(/\s*:\s*/g,":").replace(/\s*,\s*/g,",").split(","),a=0,r=s.length;r>a&&(i=s[a],-1===i.search(/^(http|https|ftp):\/\//)&&-1!==i.search(":"));a++)e=i.indexOf(":"),n=i.substring(0,e),o=i.substring(e+1),o||(o=void 0),"string"==typeof o&&(o="true"===o||"false"!==o&&o),"string"==typeof o&&(o=isNaN(o)?o:+o),c[n]=o;return null==n&&null==o?t:c}function i(t){t=""+t;var e,i,n,o=t.split(/\s+/),s="50%",r="50%";for(n=0,e=o.length;e>n;n++)i=o[n],"left"===i?s="0%":"right"===i?s="100%":"top"===i?r="0%":"bottom"===i?r="100%":"center"===i?0===n?s="50%":r="50%":0===n?s=i:r=i;return{x:s,y:r}}function n(e,i){var n=function(){i(this.src)};t('<img src="'+e+'.gif">').load(n),t('<img src="'+e+'.jpg">').load(n),t('<img src="'+e+'.jpeg">').load(n),t('<img src="'+e+'.png">').load(n)}function o(i,n,o){if(this.$element=t(i),"string"==typeof n&&(n=e(n)),o?"string"==typeof o&&(o=e(o)):o={},"string"==typeof n)n=n.replace(/\.\w*$/,"");else if("object"==typeof n)for(var s in n)n.hasOwnProperty(s)&&(n[s]=n[s].replace(/\.\w*$/,""));this.settings=t.extend({},r,o),this.path=n;try{this.init()}catch(t){if(t.message!==a)throw t}}var s="vide",r={volume:1,playbackRate:1,muted:!0,loop:!0,autoplay:!0,position:"50% 50%",posterType:"detect",resizing:!0,bgColor:"transparent"},a="Not implemented";o.prototype.init=function(){var e,o,r=this,c=r.path,u=c,h="",l=r.$element,d=r.settings,p=i(d.position),f=d.posterType;o=r.$wrapper=t("<div>").css({position:"absolute","z-index":-1,top:0,left:0,bottom:0,right:0,overflow:"hidden","-webkit-background-size":"cover","-moz-background-size":"cover","-o-background-size":"cover","background-size":"cover","background-color":d.bgColor,"background-repeat":"no-repeat","background-position":p.x+" "+p.y}),"object"==typeof c&&(c.poster?u=c.poster:c.mp4?u=c.mp4:c.webm?u=c.webm:c.ogv&&(u=c.ogv)),"detect"===f?n(u,function(t){o.css("background-image","url("+t+")")}):"none"!==f&&o.css("background-image","url("+u+"."+f+")"),"static"===l.css("position")&&l.css("position","relative"),l.prepend(o),"object"==typeof c?(c.mp4&&(h+='<source src="'+c.mp4+'.mp4" type="video/mp4">'),c.webm&&(h+='<source src="'+c.webm+'.webm" type="video/webm">'),c.ogv&&(h+='<source src="'+c.ogv+'.ogv" type="video/ogg">'),e=r.$video=t("<video>"+h+"</video>")):e=r.$video=t('<video><source src="'+c+'.mp4" type="video/mp4"><source src="'+c+'.webm" type="video/webm"><source src="'+c+'.ogv" type="video/ogg"></video>');try{e.prop({autoplay:d.autoplay,loop:d.loop,volume:d.volume,muted:d.muted,defaultMuted:d.muted,playbackRate:d.playbackRate,defaultPlaybackRate:d.playbackRate})}catch(t){throw new Error(a)}e.css({margin:"auto",position:"absolute","z-index":-1,top:p.y,left:p.x,"-webkit-transform":"translate(-"+p.x+", -"+p.y+")","-ms-transform":"translate(-"+p.x+", -"+p.y+")","-moz-transform":"translate(-"+p.x+", -"+p.y+")",transform:"translate(-"+p.x+", -"+p.y+")",visibility:"hidden",opacity:0}).one("canplaythrough."+s,function(){r.resize()}).one("playing."+s,function(){e.css({visibility:"visible",opacity:1}),o.css("background-image","none")}),l.on("resize."+s,function(){d.resizing&&r.resize()}),o.append(e)},o.prototype.getVideoObject=function(){return this.$video[0]},o.prototype.resize=function(){if(this.$video){var t=this.$wrapper,e=this.$video,i=e[0],n=i.videoHeight,o=i.videoWidth,s=t.height(),r=t.width();r/o>s/n?e.css({width:r+2,height:"auto"}):e.css({width:"auto",height:s+2})}},o.prototype.destroy=function(){delete t[s].lookup[this.index],this.$video&&this.$video.off(s),this.$element.off(s).removeData(s),this.$wrapper.remove()},t[s]={lookup:[]},t.fn[s]=function(e,i){var n;return this.each(function(){n=t.data(this,s),n&&n.destroy(),n=new o(this,e,i),n.index=t[s].lookup.push(n)-1,t.data(this,s,n)}),this},t(document).ready(function(){var e=t(window);e.on("resize."+s,function(){for(var e,i=t[s].lookup.length,n=0;i>n;n++)e=t[s].lookup[n],e&&e.settings.resizing&&e.resize()}),e.on("unload."+s,function(){return!1}),t(document).find("[data-"+s+"-bg]").each(function(e,i){var n=t(i),o=n.data(s+"-options"),r=n.data(s+"-bg");n[s](r,o)})})});var act={};act.debounce=function(t,e){var i=null;return function(){var n=this,o=arguments;clearTimeout(i),i=setTimeout(function(){t.apply(n,o)},e)}},act.throttle=function(t,e,i){e||(e=250);var n,o;return function(){var s=i||this,r=+new Date,a=arguments;n&&r<n+e?(clearTimeout(o),o=setTimeout(function(){n=r,t.apply(s,a)},e)):(n=r,t.apply(s,a))}},jQuery(function(t){function e(e,i){var n=0;e.css("min-height",e.outerHeight()),i.addClass("notransition").css("min-height","").each(function(){var e=t(this).outerHeight();e>n&&(n=e)}).css("min-height",n).delay(100).queue(function(){t(this).removeClass("notransition").dequeue()}),e.css("min-height","")}function i(){t(".act-slider .hs_cos_flex-slider .superimpose .caption").wrapInner('<div class="centered" />'),t(".act-slider .hs_cos_flex-slider .superimpose .caption p, .act-slider .hs_cos_flex-slider .superimpose .caption h1, .act-slider .hs_cos_flex-slider .superimpose .caption h2, .act-slider .hs_cos_flex-slider .superimpose .caption h3, .act-slider .hs_cos_flex-slider .superimpose .caption h4, .act-slider .hs_cos_flex-slider .superimpose .caption h5, .act-slider .hs_cos_flex-slider .superimpose .caption h6, .act-slider .hs_cos_flex-slider .superimpose .caption blockquote, .act-slider .hs_cos_flex-slider .superimpose .caption q, .act-slider .hs_cos_flex-slider .superimpose .caption code, .act-slider .hs_cos_flex-slider .superimpose .caption pre, .act-slider .hs_cos_flex-slider .superimpose .caption cite").after('<span class="separate-inline-blocks" />')}function n(){var t=s.scrollTop();u.length>0&&(t>d?m.addClass("active"):m.removeClass("active")),g.length>0&&(t>95?g.addClass("active"):g.removeClass("active"))}function o(){a.hasClass("hs-inline-edit")||c.hasClass("inpage-editing")||0==y.length||y.each(function(){t(this).masonry({isInitLayout:!1,transitionDuration:0});var e=t(this).data("masonry");e.on("layoutComplete",function(){a.addClass("flexible-listing-complete")}),e.layout()})}var s=t(window),r=t("html, body"),a=t("html"),c=t("body");a.removeClass("no-js").addClass("js-on"),t('[class*="span"]:not(.large-stack,.medium-stack,.small-stack,.tiny-stack,.never-stack)').addClass("smedium-stack"),t(".lt-ie9 .form-title, .lt-ie9 .page-header.section-header h1:empty, .lt-ie9 .page-header.section-header .section-subheader:empty").addClass("empty"),t(".lt-ie9 .hs-menu-wrapper li:last-child").addClass("last-child"),c.fitVids(),t(".fluid-width-video-wrapper").parent(".hs-responsive-embed").removeClass("hs-responsive-embed hs-responsive-embed-youtube hs-responsive-embed-vimeo"),t(".column-equal-height > div > div").each(function(){var i=t(this),n=i.find('> [class*="span"]:not(.span12)');e(i,n),s.on("load resize",act.throttle(function(){e(i,n)},250)),i.on("DOMNodeInserted DOMNodeRemoved",act.debounce(function(){e(i,n)},500)),t("*",n).on("transitionend webkitTransitionEnd animationend webkitAnimationEnd",act.debounce(function(){e(i,n)},250))}),t(".header-wrapper.with-navigation .header-logo").append('<span class="mobile-menu-button"><i class="mobile-menu-button-line-top"></i><i class="mobile-menu-button-line-middle"></i><i class="mobile-menu-button-line-bottom"></i><span>'),t(".header-wrapper .main-navigation li.hs-item-has-children").append(function(){return t(this).find("ul").length>0?'<span class="mobile-menu-expand-button"></span>':void t(this).removeClass("hs-item-has-children")}),t(".mobile-menu-button").on("click",function(){t(this).toggleClass("expanded"),c.toggleClass("menu-is-open"),t(".header-wrapper .main-navigation .hs-menu-flow-horizontal").toggleClass("expanded"),t(".header-wrapper .main-navigation ul ul").hide(),t(".header-wrapper .main-navigation li.expanded").removeClass("expanded")}),t(".mobile-menu-expand-button").on("click",function(){var e=t(this).parent();e.parent("ul").parent("li");e.hasClass("expanded")?(e.removeClass("expanded").find("ul").hide().find(".expanded").removeClass("expanded"),e.siblings().removeClass("expanded").find("ul").hide().find("li.expanded").removeClass("expanded")):(e.addClass("expanded").find("> ul").show(),e.siblings().removeClass("expanded").find("ul").hide())}),t(".main-navigation ul li a > div").closest("li").addClass("extra-wrapper-primary"),t(".main-navigation ul li a > span").closest("li").addClass("extra-wrapper-secondary");var u=t(".header-wrapper .main-navigation.sticky");if(u.length>0){var h=t(".header-wrapper"),l=u.html(),d=h.height()+h.offset().top+100,p=u.attr("class").split(" "),f="sticky-menu menu-reset main-navigation";t.inArray("flyouts-fade",p)>-1&&(f+=" flyouts-fade"),t.inArray("flyouts-slide",p)>-1&&(f+=" flyouts-slide"),t.inArray("flyouts-flow-left-all",p)>-1&&(f+=" flyouts-flow-left-all"),t.inArray("flyouts-flow-left-last",p)>-1&&(f+=" flyouts-flow-left-last"),t.inArray("flyouts-flow-left-last-two",p)>-1&&(f+=" flyouts-flow-left-last-two"),t.inArray("flyouts-flow-left-last-three",p)>-1&&(f+=" flyouts-flow-left-last-three"),c.append('<div class="'+f+'"><div class="centered">'+l+'</div></div><div class="sticky-menu-option-check"></div>');var m=t(".sticky-menu")}0==t(".sub-menu li").length&&t(".sub-menu").addClass("empty"),t("html.lt-ie9").length>0?lookupInterval=setInterval(function(){t(".act-slider .hs_cos_flex-slider .superimpose .caption").length>0&&(clearInterval(lookupInterval),i())},100):s.on("load",i()),t(".act-slider .hs_cos_gallery_main .caption.superimpose > span").addClass("centered"),t(".act-slider .hs_cos_gallery_main .caption.superimpose p, .act-slider .hs_cos_gallery_main .caption.superimpose h1, .act-slider .hs_cos_gallery_main .caption.superimpose h2, .act-slider .hs_cos_gallery_main .caption.superimpose h3, .act-slider .hs_cos_gallery_main .caption.superimpose h4, .act-slider .hs_cos_gallery_main .caption.superimpose h5, .act-slider .hs_cos_gallery_main .caption.superimpose h6, .act-slider .hs_cos_gallery_main .caption.superimpose blockquote, .act-slider .hs_cos_gallery_main .caption.superimpose q, .act-slider .hs_cos_gallery_main .caption.superimpose code, .act-slider .hs_cos_gallery_main .caption.superimpose pre, .act-slider .hs_cos_gallery_main .caption.superimpose cite").after('<span class="separate-inline-blocks" />'),s.on("load",function(){t(".footer-subscribe .hs-input").on("focus",function(){t(".footer-go-foggy").foggy({blurRadius:2,opacity:.8,cssFilterSupport:!0})}),t(".footer-subscribe .hs-input").on("blur",function(){t(".footer-go-foggy").foggy(!1)})}),t(".map-section").append('<div class="map-overlay" />'),t(".map-overlay").on("click",function(){t(this).css("pointer-events","none")}),t(".next-section").prepend('<a class="next-section-arrow" href="#"><i class="fa fa-angle-down"></i></a>'),t(".next-section-arrow").on("click",function(){var e=t(this).closest(".next-section").offset().top;return r.animate({scrollTop:e},300,"easeOutExpo"),!1}),t(".lp-headlines-section").prepend('<a href="#" class="lp-arrow"></a>'),t(".lp-headlines-section .lp-arrow").on("click",function(){var e=t(".lp-arrow-target");return e.length>0&&r.animate({scrollTop:t(".lp-arrow-target").offset().top},300,"easeOutExpo"),!1}),c.prepend('<a name="top"></a>'),c.append('<span class="scroll-to-top"><i class="fa fa-angle-up"></i></span>');var g=t(".scroll-to-top");g.on("click",function(){r.animate({scrollTop:0},300,"easeOutExpo")}),0==t("html.lt-ie9").length&&t("a[href*=\\#]:not([href=\\#], .popup-link)").on("click",function(){if(location.pathname.replace(/^\//,"")==this.pathname.replace(/^\//,"")&&location.hostname==this.hostname){var e=t(this.hash);if(e=e.length?e:t('[name="'+this.hash.slice(1)+'"]'),e.length){var i=e.offset().top;return t(".sticky-menu").length>0&&t(".sticky-menu-option-check").is(":visible")&&i>=55&&(i-=55),"top"==e.attr("name")&&(i=0),r.animate({scrollTop:i},300,"easeOutExpo"),!1}}}),"ie"===layoutEngine.vendor&&layoutEngine.version>=10&&"fixed"==t(".hero-wrapper, .hero-offer, .bottom-offer").css("background-attachment")&&c.on("mousewheel",function(){event.preventDefault?event.preventDefault():event.returnValue=!1;var t=event.wheelDelta,e=window.pageYOffset;window.scrollTo(0,e-t)});var v=/(iPad|iPhone|iPod)/g.test(navigator.userAgent);v&&c.append("<style>.hero-wrapper, .bottom-offer, .hero-offer { background-attachment: scroll !important; }</style>"),n(),s.on("scroll",function(){window.requestAnimationFrame(n)});var y=t(".flexible-listing:not(.no-masonry) > .hs_cos_wrapper_type_widget_container");if(t(window).on("load",function(){o(),c.hasClass("has-config-tool")&&(t('.nbo-config-select-styles, .slider-range, select[data-var-name="layout"], select[data-var-name="boxed_content_padding"]').on("change",function(){o()}),t(".nbo-config-reset").on("click",function(){o()}))}),t(window).smartresize(function(){window.requestAnimationFrame(function(){o()})}),t(".act-accordion-header").on("click",function(){var e=t(this).closest(".act-accordion-item"),i=e.attr("data-accordion-group");if(e.toggleClass("collapsed"),""!=i){var n=t('.act-accordion-item[data-accordion-group="'+i+'"]');n.not(t(this).closest(".act-accordion-item")).addClass("collapsed")}}),window.location.hash){var b=window.location.hash.replace(/^.*?(#|$)/,"").toLowerCase(),w=t("body").find('.act-accordion-item[data-accordion-anchor="'+b+'"]').first();w.length>0&&(w.removeClass("collapsed"),t('.act-accordion-item[data-accordion-group="'+w.attr("data-accordion-group")+'"]').not(w.closest(".act-accordion-item")).addClass("collapsed"),r.animate({scrollTop:w.offset().top-100},300,"easeOutExpo"))}t(".act-more-button-expand").on("click",function(){return t(this).closest(".act-more").removeClass("collapsed"),!1}),t(".act-more-button-collapse").on("click",function(){var e=t(this).closest(".act-more"),i=e.offset().top;return e.addClass("collapsed"),r.animate({scrollTop:i-100},300,"easeOutExpo"),!1}),t(".section-background-image img").each(function(){var e=t(this).attr("src");t(this).closest(".content-section").css("background-image","url("+e+")").addClass("background-image-defined")}),t(".section-background-color").each(function(){var e=t(this).find(".hs_cos_wrapper").text();t(this).closest(".content-section, .article-section").css("background-color",e).addClass("background-color-defined")}),t(".section-text-color").each(function(){var e=t(this).find(".hs_cos_wrapper").text();t(this).closest(".content-section").css("color",e).addClass("color-defined")});var _=t(".fullscreen-search"),x=_.find(".hs-input"),E=t(".main-navigation .hs-menu-wrapper > ul"),I='<a class="fss-open-btn" href="#"><i class="fa fa-search"></i></a>';_.length>0&&E.length>0&&(a.addClass("fss-on"),_.find("form").before('<div class="fss-overlay"/>'),_.find(".hs-form label").length>0&&x.attr("placeholder",_.find(".hs-form label").text()),_.find(".hs-form label").remove(),_.find(".hs-button").html('<i class="fa fa-search"></i>'),E.append('<li class="menu-search-button">'+I+"</li>"),t(".mobile-menu-button").before('<div class="mobile-menu-search">'+I+"</div>"),_.hasClass("with-close")&&_.append('<a class="fss-close-btn" href="#"><i class="fa fa-times"></i></a>'),t(".fss-open-btn").on("click",function(){return a.addClass("fullscreen-search-open"),/iPad|iPhone|iPod/g.test(navigator.userAgent)||setTimeout(function(){x.focus()},250),!1}),t(".fss-close-btn").on("click",function(){return a.removeClass("fullscreen-search-open"),!1}),t(".fullscreen-search:not(.with-close.only-close)").find(".fss-overlay").on("click",function(){a.removeClass("fullscreen-search-open")}));var C=t(".hero-wrapper"),k={};if(C.find(".video-url").each(function(){var e=t(this).text().trim(),i=e.split(".").pop();i&&(k[i]=e)}),k.mp4){C.addClass("video-bg");var z={position:C.css("background-position"),bgColor:"transparent",posterType:"none"};C.vide(k,z)}t(".rss-cards").each(function(){t(".hs-rss-item",this).addClass("card-box").wrap('<div class="rss-card" />'),t(this).hasClass("full-links")&&t(".hs-rss-item").append(function(){return'<a class="full-link" href="'+t(".hs-rss-description a",this).attr("href")+'" />'}),t(".hs-rss-description a",this).before('<span class="sep" />'),t("img.hs-rss-featured-image",this).each(function(){var e=t(this).closest(".hs-rss-item"),i=t(".hs-rss-description a",e).attr("href");e.addClass("has-image"),t(this).prependTo(e).wrap('<a href="'+i+'" class="rss-item-banner" />')})});var O=t(".rss-cards:not(.no-masonry) .hs-rss-module").masonry({itemSelector:".rss-card",isFitWidth:!0});O.imagesLoaded().progress(function(){O.masonry("layout")}),c.hasClass("has-config-tool")&&(t('.nbo-config-select-styles, .slider-range, select[data-var-name="layout"], select[data-var-name="boxed_content_padding"]').on("change",function(){O.masonry("layout")}),t(".nbo-config-reset").on("click",function(){O.masonry("layout")})),s.on("load resize",function(){O.masonry("layout")})});