Skip to content
Browse files

Updated whitespace handling for IE8.

  • Loading branch information...
1 parent 12ed41f commit e52a79ba67dba04dd466950a51b9af9d43156072 @nefarioustim committed Sep 24, 2010
Showing with 27 additions and 24 deletions.
  1. +9 −5 css/core.css
  2. +17 −11 js/jquery.carousel.2.1.js
  3. +1 −8 js/jquery.carousel.2.1.min.js
View
14 css/core.css
@@ -1,13 +1,17 @@
html {
- background: #ccc;
- filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#999', endColorstr='#ccc');
- background: #ccc -webkit-gradient(linear, left top, left bottom, from(#999), to(#ccc)) no-repeat;
- background: #ccc -moz-linear-gradient(top, #999, #ccc) no-repeat;
+ background: #ccc;
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#ff999999, endColorstr=#ffcccccc);
+ -ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#ff999999, endColorstr=#ffcccccc)";
+ background: #ccc -webkit-gradient(linear, left top, left bottom, from(#999), to(#ccc)) no-repeat;
+ background: #ccc -moz-linear-gradient(top, #999, #ccc) no-repeat;
+ -moz-background-size: 100%, 100px;
+ -webkit-background-size: 100%, 100px;
+ background-size: 100%, 100px;
}
body {
color: #666;
- font: 14px/1.4 helvetica, "trebuchet ms", sans-serif;
+ font: 14px/1.4 "helvetica neue", arial, sans-serif;
padding: 20px;
text-align: center;
}
View
28 js/jquery.carousel.2.1.js
@@ -17,16 +17,22 @@
}
}
+ // $.fn.cleanWhitespace = function() {
+ // this.contents().filter(function() {
+ // if (this.nodeType != 3) {
+ // $(this).cleanWhitespace();
+ // return false;
+ // }
+ // else {
+ // return !(/\s/.test(this.nodeValue));
+ // }
+ // }).remove();
+ // };
+
+ // Get around IE8 fail
+
$.fn.cleanWhitespace = function() {
- this.contents().filter(function() {
- if (this.nodeType != 3) {
- $(this).cleanWhitespace();
- return false;
- }
- else {
- return !/\S/.test(this.nodeValue);
- }
- }).remove();
+ this.html(this.html().replace(/<\/li>\s+/gi, '</li>'));
};
$.fn.carousel = function(config) {
@@ -60,7 +66,7 @@
list.css({
"position": "relative"
});
- clip.cleanWhitespace();
+ list.cleanWhitespace();
var clipWidth = clip.width(),
clipHeight = clip.get(0).offsetHeight,
@@ -180,7 +186,7 @@
});
carousel.bind("move.carousel", function(e, panes) {
- clip.cleanWhitespace();
+ list.cleanWhitespace();
numPanes = list.find("> li").length;
var lastPane = currentPane;
panes = panes || 1;
View
9 js/jquery.carousel.2.1.min.js
@@ -1,8 +1 @@
-(function(e){e.fn.cleanWhitespace=function(){this.contents().filter(function(){if(this.nodeType!=3){e(this).cleanWhitespace();return false}else return!/\S/.test(this.nodeValue)}).remove()};e.fn.carousel=function(g){var b={visiblePanes:1,panesToMove:1,pagination:true,speed:200,loop:false,autoplay:false,hovercontrols:false,hoverpause:false,delay:2E3,transition:false};g&&e.extend(b,g);this.each(function(){var n,a=e(this),j=a.find(".clip:first"),k=j.find(">ul:first"),s=k.find(">li");b.aspectVert=/(vertical)/i.test(k.get(0).className);
-a.data("playing",false);j.css("overflow","hidden");k.css({position:"relative"});j.cleanWhitespace();var o=j.width(),l=j.get(0).offsetHeight,d=0,i=s.length,q=b.aspectVert?Math.floor(l/b.visiblePanes):Math.floor(o/b.visiblePanes),h={prev:{},play:{},pause:{},next:{}},p=e('<div class="controls" />');basic=e('<ul class="basic" />');e.each(h,function(c){h[c]=e('<li class="'+c+'"><button>'+c+"</button></li>").find("button").data("name",c).end();basic.append(h[c])});basic.appendTo(p.appendTo(a));basic.delegate("button",
-"click",function(c){c.preventDefault();a.trigger(e(this).data("name"))});if(b.pagination){o=e('<ol class="pages" />');for(l=0;l<s.length/b.panesToMove;l++)e('<li><button value="'+l+'">'+parseInt(l+1,10)+"</button></li>").appendTo(o);o.appendTo(a.find(".controls"));o.delegate("button","click",function(c){c.preventDefault();a.trigger("jump",[c.target.value*b.panesToMove,d])})}b.hovercontrols&&p.hide();a.hover(function(){b.hovercontrols&&p.stop().fadeIn({duration:200,queue:false});if(b.hoverpause){if(a.data("playing"))var c=
-true;a.trigger("pause");c&&a.data("playing",true)}},function(){b.hovercontrols&&p.fadeOut({duration:200,queue:false});b.hoverpause&&a.data("playing")&&a.trigger("play")});var m=function(c,f){if(f){c.removeClass("disabled");c.find("button").get(0).disabled=false}else{c.addClass("disabled");c.find("button").get(0).disabled=true}};a.delegate(".clip > ul > li *","focus",function(c){c=e(c.target).closest(".clip > ul > li").index();if(c>b.visiblePanes+d-1){a.trigger("pause");a.trigger("jump",c)}else if(c<
-d){a.trigger("pause");a.trigger("jump",c-b.visiblePanes)}});a.bind("nav-state.carousel",function(){if(!b.loop){m(h.prev,d!=0);m(h.next,d!=i)}if(b.pagination){a.find(".pages .current").removeClass("current");a.find(".pages button").eq(Math.ceil(d/b.panesToMove)).closest("li").addClass("current")}});a.bind("move.carousel",function(c,f){j.cleanWhitespace();i=k.find("> li").length;var r=d;f=f||1;d+=f*b.panesToMove;if(d+(b.visiblePanes-b.panesToMove)>=i){if(b.loop)d=0}else if(d<=-b.panesToMove)if(b.loop)d=
-i+f*b.panesToMove;a.trigger("jump",[d,r]);a.data("playing")&&!b.loop&&d==i&&a.trigger("pause")});a.bind("jump.carousel",function(c,f,r){if(f<0)f=0;if(f>i-b.visiblePanes)f=i-b.visiblePanes;d=f;c={duration:b.speed,complete:function(){a.trigger("nav-state")}};if(b.transition)a.carousel[b.transition]({carousel:a,defaults:b,delta:q,last:r,current:d,anim:c});else b.aspectVert?k.animate({top:-q*f+"px"},c):k.animate({left:-q*f+"px"},c)});a.bind("prev.carousel",function(){a.trigger("pause");a.trigger("move",
--1)});a.bind("next.carousel",function(){a.trigger("pause");a.trigger("move",1)});a.bind("play.carousel",function(){a.data("playing",true);m(h.play,false);m(h.pause,true);n=window.setInterval(function(){a.trigger("move",1)},b.delay)});a.bind("pause.carousel",function(){a.data("playing",false);m(h.pause,false);m(h.play,true);clearInterval(n)});a.trigger("nav-state");b.autoplay?a.trigger("play"):a.trigger("pause")});return this};e.fn.carousel.fade=function(g){var b=g.carousel.find(".clip>ul>li").eq(g.last),
-n=g.carousel.find(".clip>ul>li").eq(g.current);g.carousel.find(".clip>ul");b.css({position:"absolute",top:"0",left:"0","z-index":"1"});n.hide().css({position:"absolute",top:"0",left:"0","z-index":"2"});g.anim.complete=function(){b.hide();g.carousel.trigger("nav-state")};n.fadeIn(g.anim)}})(jQuery);
+(function(f){f.fn.cleanWhitespace=function(){this.html(this.html().replace(/<\/li>\s+/gi,"</li>"))};f.fn.carousel=function(g){var b={visiblePanes:1,panesToMove:1,pagination:true,speed:200,loop:false,autoplay:false,hovercontrols:false,hoverpause:false,delay:2E3,transition:false};g&&f.extend(b,g);this.each(function(){var m,a=f(this),h=a.find(".clip:first"),j=h.find(">ul:first"),r=j.find(">li");b.aspectVert=/(vertical)/i.test(j.get(0).className);a.data("playing",false);h.css("overflow","hidden");j.css({position:"relative"});j.cleanWhitespace();var n=h.width();h=h.get(0).offsetHeight;var d=0,k=r.length,p=b.aspectVert?Math.floor(h/b.visiblePanes):Math.floor(n/b.visiblePanes),i={prev:{},play:{},pause:{},next:{}},o=f('<div class="controls" />');basic=f('<ul class="basic" />');f.each(i,function(c){i[c]=f('<li class="'+c+'"><button>'+c+"</button></li>").find("button").data("name",c).end();basic.append(i[c])});basic.appendTo(o.appendTo(a));basic.delegate("button","click",function(c){c.preventDefault();a.trigger(f(this).data("name"))});if(b.pagination){n=f('<ol class="pages" />');for(h=0;h<r.length/b.panesToMove;h++)f('<li><button value="'+h+'">'+parseInt(h+1,10)+"</button></li>").appendTo(n);n.appendTo(a.find(".controls"));n.delegate("button","click",function(c){c.preventDefault();a.trigger("jump",[c.target.value*b.panesToMove,d])})}b.hovercontrols&&o.hide();a.hover(function(){b.hovercontrols&&o.stop().fadeIn({duration:200,queue:false});if(b.hoverpause){if(a.data("playing"))var c=true;a.trigger("pause");c&&a.data("playing",true)}},function(){b.hovercontrols&&o.fadeOut({duration:200,queue:false});b.hoverpause&&a.data("playing")&&a.trigger("play")});var l=function(c,e){if(e){c.removeClass("disabled");c.find("button").get(0).disabled=false}else{c.addClass("disabled");c.find("button").get(0).disabled=true}};a.delegate(".clip > ul > li *","focus",function(c){c=f(c.target).closest(".clip > ul > li").index();if(c>b.visiblePanes+d-1){a.trigger("pause");a.trigger("jump",c)}else if(c<d){a.trigger("pause");a.trigger("jump",c-b.visiblePanes)}});a.bind("nav-state.carousel",function(){if(!b.loop){l(i.prev,d!=0);l(i.next,d!=k)}if(b.pagination){a.find(".pages .current").removeClass("current");a.find(".pages button").eq(Math.ceil(d/b.panesToMove)).closest("li").addClass("current")}});a.bind("move.carousel",function(c,e){j.cleanWhitespace();k=j.find("> li").length;var q=d;e=e||1;d+=e*b.panesToMove;if(d+(b.visiblePanes-b.panesToMove)>=k){if(b.loop)d=0}else if(d<=-b.panesToMove)if(b.loop)d=k+e*b.panesToMove;a.trigger("jump",[d,q]);a.data("playing")&&!b.loop&&d==k&&a.trigger("pause")});a.bind("jump.carousel",function(c,e,q){if(e<0)e=0;if(e>k-b.visiblePanes)e=k-b.visiblePanes;d=e;c={duration:b.speed,complete:function(){a.trigger("nav-state")}};if(b.transition)a.carousel[b.transition]({carousel:a,defaults:b,delta:p,last:q,current:d,anim:c});else b.aspectVert?j.animate({top:-p*e+"px"},c):j.animate({left:-p*e+"px"},c)});a.bind("prev.carousel",function(){a.trigger("pause");a.trigger("move",-1)});a.bind("next.carousel",function(){a.trigger("pause");a.trigger("move",1)});a.bind("play.carousel",function(){a.data("playing",true);l(i.play,false);l(i.pause,true);m=window.setInterval(function(){a.trigger("move",1)},b.delay)});a.bind("pause.carousel",function(){a.data("playing",false);l(i.pause,false);l(i.play,true);clearInterval(m)});a.trigger("nav-state");b.autoplay?a.trigger("play"):a.trigger("pause")});return this};f.fn.carousel.fade=function(g){var b=g.carousel.find(".clip>ul>li").eq(g.last),m=g.carousel.find(".clip>ul>li").eq(g.current);g.carousel.find(".clip>ul");b.css({position:"absolute",top:"0",left:"0","z-index":"1"});m.hide().css({position:"absolute",top:"0",left:"0","z-index":"2"});g.anim.complete=function(){b.hide();g.carousel.trigger("nav-state")};m.fadeIn(g.anim)}})(jQuery);

0 comments on commit e52a79b

Please sign in to comment.
Something went wrong with that request. Please try again.