Skip to content
Browse files

Fix issue #67

  • Loading branch information...
1 parent 4218ec7 commit a58a8181c9098c9457440970d77d8ff4d38961b2 @Mottie Mottie committed Feb 28, 2012
Showing with 11 additions and 6 deletions.
  1. +4 −0 README.markdown
  2. +4 −3 js/jquery.movingboxes.js
  3. +2 −2 js/jquery.movingboxes.min.js
  4. +1 −1 package.json
View
4 README.markdown
@@ -10,6 +10,10 @@
(Only the most recent changes are shown below, see the [wiki page](https://github.com/chriscoyier/MovingBoxes/wiki/Change-Log) for a complete listing)
+### Version 2.2.11 (2/28/2012)
+
+* Fixed cloned panels getting labeled with the "current" class. This will fix [issue #67](https://github.com/chriscoyier/MovingBoxes/issues/67).
+
### Version 2.2.10 (2/28/2012)
* Fixed navFormatter
View
7 js/jquery.movingboxes.js
@@ -1,5 +1,5 @@
/*
- * Moving Boxes v2.2.10
+ * Moving Boxes v2.2.11
* by Chris Coyier
* http://css-tricks.com/moving-boxes/
*/
@@ -78,7 +78,7 @@
// focused link centered in moving box
var loc = base.$panels.index($(this).closest('.mb-panel')) + base.adj;
if (loc !== base.curPanel){
- base.change( base.$panels.index($(this).closest('.mb-panel')) + base.adj, {}, true );
+ base.change( loc, {}, true );
}
});
@@ -258,7 +258,8 @@
base.completed = function(num, flag){
// add current panel class after animating in case it has sizing parameters
- base.$panels.eq(num - base.adj).addClass(o.currentPanel);
+ var loc = base.$panels.eq(num - base.adj);
+ if (!loc.hasClass('cloned')) { loc.addClass(o.currentPanel); }
if (flag !== false) { base.$el.trigger( 'completed.movingBoxes', [ base, num ] ); }
};
View
4 js/jquery.movingboxes.min.js
@@ -1,7 +1,7 @@
/*
- * Moving Boxes v2.2.10 minified
+ * Moving Boxes v2.2.11 minified
* by Chris Coyier
* http://css-tricks.com/moving-boxes/
*/
-(function(d){d.movingBoxes=function(f,i){var b,a=this;a.$el=d(f).addClass("mb-slider");a.el=f;a.$el.data("movingBoxes",a);a.init=function(){a.options=b=d.extend({},d.movingBoxes.defaultOptions,i);a.$el.wrap('<div class="movingBoxes mb-wrapper"><div class="mb-scroll" /></div>');a.$window=a.$el.parent();a.$wrap=a.$window.parent().prepend('<a class="mb-scrollButtons mb-left"></a>').append('<a class="mb-scrollButtons mb-right"></a><div class="mb-left-shadow"></div><div class="mb-right-shadow"></div>'); a.$panels=a.$el.children().addClass("mb-panel");a.runTime=d(".mb-slider").index(a.$el)+1;a.regex=RegExp("slider"+a.runTime+"=(\\d+)","i");a.initialized=!1;a.currentlyMoving=!1;a.curPanel=b.initAnimation?1:b.hashTags?a.getHash()||b.startPanel:b.startPanel;a.width=b.width?parseInt(b.width,10):a.$el.width();a.pWidth=b.panelWidth?2>=b.panelWidth?b.panelWidth*a.width:b.panelWidth:a.$panels.eq(0).width();a.$left=a.$wrap.find(".mb-left").click(function(){a.goBack();return!1});a.$right=a.$wrap.find(".mb-right").click(function(){a.goForward(); return!1});a.update(!1);d(window).load(function(){a.update(!1)});a.$el.delegate(".mb-panel","click",function(c){d(this).hasClass(b.currentPanel)||(c.preventDefault(),a.change(a.$panels.index(d(this))+a.adj,{},!0))});a.$wrap.click(function(){a.$wrap.hasClass("mb-active-slider")||a.active()});a.$panels.delegate("a","focus",function(c){c.preventDefault();a.$panels.index(d(this).closest(".mb-panel"))+a.adj!==a.curPanel&&a.change(a.$panels.index(d(this).closest(".mb-panel"))+a.adj,{},!0)});d(document).keyup(function(c){if(!c.target.tagName.match("TEXTAREA|INPUT|SELECT"))switch(c.which){case 39:case 32:a.$wrap.is(".mb-active-slider")&& a.goForward();break;case 37:a.$wrap.is(".mb-active-slider")&&a.goBack()}});d.each(["preinit","initialized","initChange","beforeAnimation","completed"],function(c,h){d.isFunction(b[h])&&a.$el.bind(h+".movingBoxes",b[h])});a.curPanel=b.hashTags?a.getHash()||b.startPanel:b.startPanel;a.$el.trigger("preinit.movingBoxes",[a,a.curPanel]);setTimeout(function(){a.change(a.curPanel,function(){a.initialized=!0;a.$el.trigger("initialized.movingBoxes",[a,a.curPanel])},!1)},2*b.speed)};a.update=function(c,h){a.$el.children(".cloned").remove(); a.$panels=a.$el.children();a.adj=b.wrap&&1<a.$panels.length?0:1;a.width=b.width?parseInt(b.width,10):a.width;a.$wrap.css("width",a.width);b.wrap&&1<a.$panels.length&&(a.$el.prepend(a.$panels.filter(":last").clone().addClass("cloned")),a.$el.append(a.$panels.filter(":first").clone().addClass("cloned")),a.$el.find(".cloned").each(function(){d(this).find("a,input,textarea,select,button,area").removeAttr("name").attr("disabled","disabled");d(this).find("[id]").andSelf().removeAttr("id")}));a.$panels= a.$el.children().addClass("mb-panel").css("margin",0).each(function(){0===d(this).find(".mb-inside").length&&d(this).wrapInner('<div class="mb-inside" />')});a.totalPanels=a.$panels.filter(":not(.cloned)").length;a.curWidth=b.panelWidth?2>=b.panelWidth?b.panelWidth*a.width:b.panelWidth:a.pWidth;a.regWidth=a.curWidth*b.reducedSize;a.$panels.css({width:a.curWidth,fontSize:"1em"});a.$panels.eq(a.curPanel-a.adj).addClass(b.currentPanel);a.heights=a.$panels.map(function(a,c){return d(c).outerHeight(!0)}).get(); a.returnToNormal(a.curPanel,0);a.growBigger(a.curPanel,0,c);a.updateArrows(a.curPanel);a.$el.css({position:"absolute",width:(a.curWidth+100)*a.$panels.length+(a.width-a.curWidth)/2,height:Math.max.apply(this,a.heights)+10});a.$window.css({height:b.fixedHeight?Math.max.apply(this,a.heights):a.heights[a.curPanel-a.adj]});a.$panels.eq(0).css({"margin-left":(a.width-a.curWidth)/2});a.buildNav();a.change(a.curPanel,h,!1===c?!1:!0)};a.buildNav=function(){a.$nav?a.$nav.find(".mb-links").empty():a.$nav=d('<div class="mb-controls"><span class="mb-links"></span></div>').appendTo(a.$wrap); if(b.buildNav&&1<a.totalPanels){var c,h,g="",e;a.$panels.filter(":not(.cloned)").each(function(f){h=f+1;g='<a class="mb-link mb-panel'+h+'" href="#"></a>';e=d(g);d.isFunction(b.navFormatter)?(c=b.navFormatter(h,d(this)),"string"===typeof c?e.html(c):e=d("<a/>",c)):e.html(h);e.appendTo(a.$nav.find(".mb-links")).addClass("mb-link mb-panel"+h).data("index",h)});a.$nav.find("a.mb-link").bind("click",function(){a.change(d(this).data("index"));return!1})}};a.returnToNormal=function(c,d){var g=a.$panels.not(":eq("+ (c-a.adj)+")").removeClass(b.currentPanel);1===b.reducedSize?g.css({width:a.regWidth}):g.animate({width:a.regWidth,fontSize:b.reducedSize+"em"},0===d?0:b.speed)};a.growBigger=function(c,d,g){var e=a.$panels.eq(c-a.adj);1===b.reducedSize?(e.css({width:a.curWidth}),setTimeout(function(){a.completed(c,g)},0===d?0:b.speed)):e.animate({width:a.curWidth,fontSize:"1em"},0===d?0:b.speed,function(){a.completed(c,g)})};a.completed=function(c,d){a.$panels.eq(c-a.adj).addClass(b.currentPanel);!1!==d&&a.$el.trigger("completed.movingBoxes", [a,c])};a.goForward=function(){a.initialized&&a.change(a.curPanel+1)};a.goBack=function(){a.initialized&&a.change(a.curPanel-1)};a.change=function(c,d,g){if(1>a.totalPanels)"function"===typeof d&&d(a);else{var e,f=!1,g=!1!==g,c=parseInt(c,10);a.initialized&&g&&(a.$wrap.hasClass("mb-active-slider")||a.active(),a.$el.trigger("initChange.movingBoxes",[a,c]));b.wrap&&(c>a.totalPanels?(f=!0,c=1,a.returnToNormal(0,0),a.growBigger(0,0,!1),e=a.$panels.eq(0).position().left-(a.width-a.curWidth)/2,a.$window.scrollLeft(e)): 0===c&&(f=!1,c=a.totalPanels,a.growBigger(c+1,0,!1),e=a.$panels.eq(c+1).position().left-(a.width-a.curWidth)/2,a.$window.scrollLeft(e)));c<a.adj&&(c=b.wrap?a.totalPanels:1);c>a.totalPanels-a.adj&&(c=b.wrap?1:a.totalPanels);if(!a.currentlyMoving||!a.initialized){a.currentlyMoving=!0;a.$curPanel=a.$panels.eq(c-a.adj);e=a.$curPanel.position().left-(a.width-a.curWidth)/2;if(c>a.curPanel||f)e-=a.curWidth-a.regWidth;e=b.fixedHeight?{scrollLeft:e}:{scrollLeft:e,height:a.heights[c-a.adj]};a.curPanel=c;a.initialized&& g&&a.$el.trigger("beforeAnimation.movingBoxes",[a,c]);a.$window.animate(e,{queue:!1,duration:b.speed,easing:b.easing,complete:function(){a.initialized&&a.$window.scrollTop(0);a.currentlyMoving=!1;"function"===typeof d&&d(a)}});a.returnToNormal(c);a.growBigger(c,1,g);a.updateArrows(c);b.hashTags&&a.initialized&&a.setHash(c)}b.buildNav&&a.$nav.length&&a.$nav.find("a.mb-link").removeClass(b.currentPanel).eq(c-1).addClass(b.currentPanel)}};a.updateArrows=function(c){a.$left.toggleClass(b.disabled,!b.wrap&& c===a.adj);a.$right.toggleClass(b.disabled,!b.wrap&&(c===a.totalPanels||0===a.totalPanels))};a.getHash=function(){var c=window.location.hash.match(a.regex);return null===c?"":parseInt(c[1],10)};a.setHash=function(c){var b="slider"+a.runTime+"=",d=window.location.hash;"undefined"!==typeof d&&(window.location.hash=0<d.indexOf(b)?d.replace(a.regex,b+c):d+"&"+b+c)};a.active=function(){d(".mb-active-slider").removeClass("mb-active-slider");a.$wrap.addClass("mb-active-slider")};a.currentPanel=function(b, d){"undefined"!==typeof b&&a.change(b,d);return a.curPanel};a.init()};d.movingBoxes.defaultOptions={startPanel:1,reducedSize:0.8,fixedHeight:!1,speed:500,initAnimation:!0,hashTags:!0,wrap:!1,buildNav:!1,navFormatter:null,easing:"swing",currentPanel:"current",tooltipClass:"tooltip",disabled:"disabled",preinit:null,initialized:null,initChange:null,beforeAnimation:null,completed:null};d.fn.movingBoxes=function(f,i){var b,a;return this.each(function(){a=d(this).data("movingBoxes");(typeof f).match("object|undefined")? a?a.update():new d.movingBoxes(this,f):/\d/.test(f)&&!isNaN(f)&&a&&(b="number"===typeof f?f:parseInt(d.trim(f),10),1<=b&&b<=a.totalPanels&&a.change(b,i))})};d.fn.getMovingBoxes=function(){return this.data("movingBoxes")}})(jQuery);
+(function(d){d.movingBoxes=function(g,i){var b,a=this;a.$el=d(g).addClass("mb-slider");a.el=g;a.$el.data("movingBoxes",a);a.init=function(){a.options=b=d.extend({},d.movingBoxes.defaultOptions,i);a.$el.wrap('<div class="movingBoxes mb-wrapper"><div class="mb-scroll" /></div>');a.$window=a.$el.parent();a.$wrap=a.$window.parent().prepend('<a class="mb-scrollButtons mb-left"></a>').append('<a class="mb-scrollButtons mb-right"></a><div class="mb-left-shadow"></div><div class="mb-right-shadow"></div>'); a.$panels=a.$el.children().addClass("mb-panel");a.runTime=d(".mb-slider").index(a.$el)+1;a.regex=RegExp("slider"+a.runTime+"=(\\d+)","i");a.initialized=!1;a.currentlyMoving=!1;a.curPanel=b.initAnimation?1:b.hashTags?a.getHash()||b.startPanel:b.startPanel;a.width=b.width?parseInt(b.width,10):a.$el.width();a.pWidth=b.panelWidth?2>=b.panelWidth?b.panelWidth*a.width:b.panelWidth:a.$panels.eq(0).width();a.$left=a.$wrap.find(".mb-left").click(function(){a.goBack();return!1});a.$right=a.$wrap.find(".mb-right").click(function(){a.goForward(); return!1});a.update(!1);d(window).load(function(){a.update(!1)});a.$el.delegate(".mb-panel","click",function(c){d(this).hasClass(b.currentPanel)||(c.preventDefault(),a.change(a.$panels.index(d(this))+a.adj,{},!0))});a.$wrap.click(function(){a.$wrap.hasClass("mb-active-slider")||a.active()});a.$panels.delegate("a","focus",function(c){c.preventDefault();c=a.$panels.index(d(this).closest(".mb-panel"))+a.adj;c!==a.curPanel&&a.change(c,{},!0)});d(document).keyup(function(c){if(!c.target.tagName.match("TEXTAREA|INPUT|SELECT"))switch(c.which){case 39:case 32:a.$wrap.is(".mb-active-slider")&& a.goForward();break;case 37:a.$wrap.is(".mb-active-slider")&&a.goBack()}});d.each(["preinit","initialized","initChange","beforeAnimation","completed"],function(c,h){d.isFunction(b[h])&&a.$el.bind(h+".movingBoxes",b[h])});a.curPanel=b.hashTags?a.getHash()||b.startPanel:b.startPanel;a.$el.trigger("preinit.movingBoxes",[a,a.curPanel]);setTimeout(function(){a.change(a.curPanel,function(){a.initialized=!0;a.$el.trigger("initialized.movingBoxes",[a,a.curPanel])},!1)},2*b.speed)};a.update=function(c,h){a.$el.children(".cloned").remove(); a.$panels=a.$el.children();a.adj=b.wrap&&1<a.$panels.length?0:1;a.width=b.width?parseInt(b.width,10):a.width;a.$wrap.css("width",a.width);b.wrap&&1<a.$panels.length&&(a.$el.prepend(a.$panels.filter(":last").clone().addClass("cloned")),a.$el.append(a.$panels.filter(":first").clone().addClass("cloned")),a.$el.find(".cloned").each(function(){d(this).find("a,input,textarea,select,button,area").removeAttr("name").attr("disabled","disabled");d(this).find("[id]").andSelf().removeAttr("id")}));a.$panels= a.$el.children().addClass("mb-panel").css("margin",0).each(function(){0===d(this).find(".mb-inside").length&&d(this).wrapInner('<div class="mb-inside" />')});a.totalPanels=a.$panels.filter(":not(.cloned)").length;a.curWidth=b.panelWidth?2>=b.panelWidth?b.panelWidth*a.width:b.panelWidth:a.pWidth;a.regWidth=a.curWidth*b.reducedSize;a.$panels.css({width:a.curWidth,fontSize:"1em"});a.$panels.eq(a.curPanel-a.adj).addClass(b.currentPanel);a.heights=a.$panels.map(function(a,c){return d(c).outerHeight(!0)}).get(); a.returnToNormal(a.curPanel,0);a.growBigger(a.curPanel,0,c);a.updateArrows(a.curPanel);a.$el.css({position:"absolute",width:(a.curWidth+100)*a.$panels.length+(a.width-a.curWidth)/2,height:Math.max.apply(this,a.heights)+10});a.$window.css({height:b.fixedHeight?Math.max.apply(this,a.heights):a.heights[a.curPanel-a.adj]});a.$panels.eq(0).css({"margin-left":(a.width-a.curWidth)/2});a.buildNav();a.change(a.curPanel,h,!1===c?!1:!0)};a.buildNav=function(){a.$nav?a.$nav.find(".mb-links").empty():a.$nav=d('<div class="mb-controls"><span class="mb-links"></span></div>').appendTo(a.$wrap); if(b.buildNav&&1<a.totalPanels){var c,h,f="",e;a.$panels.filter(":not(.cloned)").each(function(g){h=g+1;f='<a class="mb-link mb-panel'+h+'" href="#"></a>';e=d(f);d.isFunction(b.navFormatter)?(c=b.navFormatter(h,d(this)),"string"===typeof c?e.html(c):e=d("<a/>",c)):e.html(h);e.appendTo(a.$nav.find(".mb-links")).addClass("mb-link mb-panel"+h).data("index",h)});a.$nav.find("a.mb-link").bind("click",function(){a.change(d(this).data("index"));return!1})}};a.returnToNormal=function(c,d){var f=a.$panels.not(":eq("+ (c-a.adj)+")").removeClass(b.currentPanel);1===b.reducedSize?f.css({width:a.regWidth}):f.animate({width:a.regWidth,fontSize:b.reducedSize+"em"},0===d?0:b.speed)};a.growBigger=function(c,d,f){var e=a.$panels.eq(c-a.adj);1===b.reducedSize?(e.css({width:a.curWidth}),setTimeout(function(){a.completed(c,f)},0===d?0:b.speed)):e.animate({width:a.curWidth,fontSize:"1em"},0===d?0:b.speed,function(){a.completed(c,f)})};a.completed=function(c,d){var f=a.$panels.eq(c-a.adj);f.hasClass("cloned")||f.addClass(b.currentPanel); !1!==d&&a.$el.trigger("completed.movingBoxes",[a,c])};a.goForward=function(){a.initialized&&a.change(a.curPanel+1)};a.goBack=function(){a.initialized&&a.change(a.curPanel-1)};a.change=function(c,d,f){if(1>a.totalPanels)"function"===typeof d&&d(a);else{var e,g=!1,f=!1!==f,c=parseInt(c,10);a.initialized&&f&&(a.$wrap.hasClass("mb-active-slider")||a.active(),a.$el.trigger("initChange.movingBoxes",[a,c]));b.wrap&&(c>a.totalPanels?(g=!0,c=1,a.returnToNormal(0,0),a.growBigger(0,0,!1),e=a.$panels.eq(0).position().left- (a.width-a.curWidth)/2,a.$window.scrollLeft(e)):0===c&&(g=!1,c=a.totalPanels,a.growBigger(c+1,0,!1),e=a.$panels.eq(c+1).position().left-(a.width-a.curWidth)/2,a.$window.scrollLeft(e)));c<a.adj&&(c=b.wrap?a.totalPanels:1);c>a.totalPanels-a.adj&&(c=b.wrap?1:a.totalPanels);if(!a.currentlyMoving||!a.initialized){a.currentlyMoving=!0;a.$curPanel=a.$panels.eq(c-a.adj);e=a.$curPanel.position().left-(a.width-a.curWidth)/2;if(c>a.curPanel||g)e-=a.curWidth-a.regWidth;e=b.fixedHeight?{scrollLeft:e}:{scrollLeft:e, height:a.heights[c-a.adj]};a.curPanel=c;a.initialized&&f&&a.$el.trigger("beforeAnimation.movingBoxes",[a,c]);a.$window.animate(e,{queue:!1,duration:b.speed,easing:b.easing,complete:function(){a.initialized&&a.$window.scrollTop(0);a.currentlyMoving=!1;"function"===typeof d&&d(a)}});a.returnToNormal(c);a.growBigger(c,1,f);a.updateArrows(c);b.hashTags&&a.initialized&&a.setHash(c)}b.buildNav&&a.$nav.length&&a.$nav.find("a.mb-link").removeClass(b.currentPanel).eq(c-1).addClass(b.currentPanel)}};a.updateArrows= function(c){a.$left.toggleClass(b.disabled,!b.wrap&&c===a.adj);a.$right.toggleClass(b.disabled,!b.wrap&&(c===a.totalPanels||0===a.totalPanels))};a.getHash=function(){var c=window.location.hash.match(a.regex);return null===c?"":parseInt(c[1],10)};a.setHash=function(c){var b="slider"+a.runTime+"=",d=window.location.hash;"undefined"!==typeof d&&(window.location.hash=0<d.indexOf(b)?d.replace(a.regex,b+c):d+"&"+b+c)};a.active=function(){d(".mb-active-slider").removeClass("mb-active-slider");a.$wrap.addClass("mb-active-slider")}; a.currentPanel=function(c,b){"undefined"!==typeof c&&a.change(c,b);return a.curPanel};a.init()};d.movingBoxes.defaultOptions={startPanel:1,reducedSize:0.8,fixedHeight:!1,speed:500,initAnimation:!0,hashTags:!0,wrap:!1,buildNav:!1,navFormatter:null,easing:"swing",currentPanel:"current",tooltipClass:"tooltip",disabled:"disabled",preinit:null,initialized:null,initChange:null,beforeAnimation:null,completed:null};d.fn.movingBoxes=function(g,i){var b,a;return this.each(function(){a=d(this).data("movingBoxes"); (typeof g).match("object|undefined")?a?a.update():new d.movingBoxes(this,g):/\d/.test(g)&&!isNaN(g)&&a&&(b="number"===typeof g?g:parseInt(d.trim(g),10),1<=b&&b<=a.totalPanels&&a.change(b,i))})};d.fn.getMovingBoxes=function(){return this.data("movingBoxes")}})(jQuery);
View
2 package.json
@@ -1,6 +1,6 @@
{
"name": "MovingBoxes",
- "version": "2.2.10",
+ "version": "2.2.11",
"title": "MovingBoxes",
"author": {
"name": "Chris Coyier",

0 comments on commit a58a818

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