Commit 190ebcaa authored by Ghislain Loas's avatar Ghislain Loas

Merge branch 'dev#71411_pike' into 'master'

dev #71411 : jMyCarousel jquery 3 compatibility

See merge request afi/opacce!2519
parents 666add76 52535c42
- ticket #71411 : Affichage : Rétrocompatibilité version 7.12 / 7.10
\ No newline at end of file
......@@ -2,7 +2,7 @@
Class_ScriptLoader::getInstance()
->loadJQuery()
->addOPACPluginStyleSheet('mycarousel_vertical/carousel.css')
->addOPACPluginScript('mycarousel_vertical/jMyCarousel.min.js')
->addOPACPluginScript('mycarousel_horizontal/jMyCarousel.min.js')
->addJqueryReady('
$(".jMyCarousel").jMyCarousel({
visible: ' .$this->preferences["op_visible"] . ',
......@@ -11,5 +11,5 @@ Class_ScriptLoader::getInstance()
speed : ' . $this->preferences["op_speed"] . '});');
echo $this->partial('java/mycarousel_partial.phtml', ['records' => $this->notices,
'preferences' => $this->preferences]);
'preferences' => $this->preferences]);
?>
......@@ -72,11 +72,6 @@
if(li.children().get(0).tagName.toLowerCase() == 'a' && !o.vertical){
li.children().css('float','left');
}
if(o.vertical && jQuery.browser.msie){ // Hack IE (again..) / purpose is to cancel the white space below the image when the carousel is in vertical mode
// The issue comes up when li is not in float:left. so we put it in float:left and adjust the size
li.css('line-height', '4px').children().css('margin-bottom', '-4px');
}
ul.css("margin", "0") // Browsers apply default margin
.css("padding", "0") // and padding. It is reset here.
......
(function(e){function y(a,r){return parseInt(e.css(a[0],r))||0}function G(a){return a[0].offsetHeight+y(a,"marginTop")+y(a,"marginBottom")}e.fn.jMyCarousel=function(a){a=e.extend({btnPrev:null,btnNext:null,mouseWheel:!0,auto:!1,speed:500,easing:"linear",vertical:!1,circular:!0,visible:"4",start:0,scroll:1,step:50,eltByElt:!1,evtStart:"mouseover touchstart",evtStop:"mouseout touchend",beforeStart:null,afterEnd:null},a||{});return this.each(function(){function r(w,b){var c=w?w:s;if(!(!0===g&&"backward"===
n)){if(!a.circular&&d+c+(a.vertical?z:m)>t)c=t-(d+(a.vertical?z:m));k.animate("left"==A?{left:-(d+c)}:{top:-(d+c)},a.speed,a.easing,function(){d+=c;if(a.circular&&d+(a.vertical?z:m)+f>=J)k.css(a.vertical?"top":"left",-d+t),d-=t;!b&&g?(r(),console.log("forward")):b&&(0<--B?r(s,!0):(g=!1,n=null))})}}function C(w,b){var c=w?w:s;!0===g&&"forward"===n||(a.circular||0>d-c&&(c=d-0),k.animate("left"==A?{left:-(d-c)}:{top:-(d-c)},a.speed,a.easing,function(){d-=c;a.circular&&d<=f&&(k.css(a.vertical?"top":"left",
-(d+t)),d+=t);!b&&g?C():b&&(0<--B?C(s,!0):(g=!1,n=null))}))}function H(){a.eltByElt||(k.stop(),d=0-parseInt(k.css(A)));g=!1;n=null}function K(b){var c=b.find("img");return a.vertical?parseInt(b.css("margin-left"))+parseInt(b.css("margin-right"))+parseInt(c.width())+parseInt(b.css("border-left-width"))+parseInt(b.css("border-right-width"))+parseInt(b.css("padding-right"))+parseInt(b.css("padding-left")):parseInt(b.css("margin-top"))+parseInt(b.css("margin-bottom"))+parseInt(c.width())+parseInt(b.css("border-top-height"))+
parseInt(b.css("border-bottom-height"))+parseInt(b.css("padding-top"))+parseInt(b.css("padding-bottom"))}var g=!1,A=a.vertical?"top":"left",E=a.vertical?"height":"width",l=e(this),k=e("ul",l),b=e("li",k),u=b.length,h=a.visible,B=0,p=null===a.btnNext&&null===a.btnPrev?!0:!1,F=-1!=h.toString().indexOf("%")?"%":-1!=h.toString().indexOf("px")?"px":"el",n=null;a.speed=Math.max(20,a.speed);a.circular&&(b=b.clone(),k.prepend(b).append(b.clone()));b=e("li",k);l.css("visibility","visible");b.css("overflow",
"hidden").css("float",a.vertical?"none":"left").children().css("overflow","hidden");a.vertical||b.css("display","inline");"a"==b.children().get(0).tagName.toLowerCase()&&!a.vertical&&b.children().css("float","left");a.vertical&&jQuery.browser.msie&&b.css("line-height","4px").children().css("margin-bottom","-4px");k.css("margin","0").css("padding","0").css("position","relative").css("list-style-type","none").css("z-index","1");l.css("overflow","hidden").css("position","relative").css("z-index","2").css("left",
"0px");var f=a.vertical?G(b):b[0].offsetWidth+y(b,"marginLeft")+y(b,"marginRight"),q=a.vertical?K(b):G(b),d=a.start,c=b.length,I=f*c,t=u*f,J=c*f,s="default"==a.step?f:a.step;a.btnPrev=p?e('<input type="button" class="'+(a.vertical?"up":"prev")+'" />'):e(a.btnPrev);a.btnNext=p?e('<input type="button" class="'+(a.vertical?"down":"next")+'" />'):e(a.btnNext);var c=a.btnPrev,v=a.btnNext;p&&!0!==a.auto&&(c.css({opacity:"0.6"}),v.css({opacity:"0.6"}),l.prepend(c),l.prepend(v),a.btnPrev=c,a.btnNext=v);if(a.eltByElt&&
(s=f,0!==a.start%f))var x=parseInt(a.start/f),d=a.start=x*f;a.circular&&(a.start+=f*u,d+=f*u);var m,D;"%"==F?(m=0,x=parseInt(h),D="%"):("px"==F?(m=parseInt(h),x=parseInt(h)):(m=f*parseInt(h),x=f*parseInt(h)),D="px");k.css(E,I+"px").css(A,-a.start);l.css(E,x+D);a.vertical&&"%"==D&&(u=f*u*(parseInt(h)/100),l.css(E,u+"px"));0===m&&(m=l.width());a.vertical?(l.css("width",q+"px"),k.css("width",q+"px"),b.css("margin-bottom",2*parseInt(b.css("margin-bottom"))+"px"),b.eq(b.length-1).css("margin-bottom",b.css("margin-top"))):
(l.css("height",q+"px"),k.css("height",q+"px"));"%"==F&&(h=m/b.width(),0!==h%1&&(h+=1),h=parseInt(h));var z=l.height();p&&(v.css({"z-index":200,position:"absolute"}),c.css({"z-index":200,position:"absolute"}),a.vertical?(c.css({width:c.width(),height:c.height(),top:"0px",left:parseInt(q/2)-parseInt(c.width()/2)+"px"}),v.css({width:c.width(),height:c.height(),top:z-c.height()+"px",left:parseInt(q/2)-parseInt(c.width()/2)+"px"})):(c.css({left:"0px",top:parseInt(q/2)-parseInt(c.height()/2)+"px"}),v.css({right:"0px",
top:parseInt(q/2)-parseInt(c.height()/2)+"px"})));a.btnPrev&&(e(a.btnPrev).on(a.evtStart,function(b){b.preventDefault();p&&a.btnPrev.css("opacity",0.9);g=!0;n="backward";return C()}),e(a.btnPrev).on(a.evtStop,function(b){b.preventDefault();p&&a.btnPrev.css("opacity",0.6);g=!1;n=null;return H()}));a.btnNext&&(e(a.btnNext).on(a.evtStart,function(b){b.preventDefault();p&&a.btnNext.css("opacity",0.9);g=!0;n="forward";return r()}),e(a.btnNext).on(a.evtStop,function(b){b.preventDefault();p&&a.btnNext.css("opacity",
0.6);g=!1;n=null;return H()}));!0===a.auto&&(g=!0,r());a.mouseWheel&&l.mousewheel&&l.mousewheel(function(b,c){if(!a.circular&&(0<c?d+m<I:0<d)||a.circular)B+=1,!1===g&&(0<c?r(s,!0):C(s,!0),g=!0)})})}})(jQuery);
!function($){function css(el,prop){return parseInt($.css(el[0],prop))||0}function height(el){return el[0].offsetHeight+css(el,"marginTop")+css(el,"marginBottom")}$.fn.jMyCarousel=function(o){return o=$.extend({btnPrev:null,btnNext:null,mouseWheel:!0,auto:!1,speed:500,easing:"linear",vertical:!1,circular:!0,visible:"4",start:0,scroll:1,step:50,eltByElt:!1,evtStart:"mouseover touchstart",evtStop:"mouseout touchend",beforeStart:null,afterEnd:null},o||{}),this.each(function(){var running=!1,animCss=o.vertical?"top":"left",sizeCss=o.vertical?"height":"width",div=$(this),ul=$("ul",div),tLi=$("li",ul),tl=tLi.length,v=o.visible,mousewheelN=0,defaultBtn=null===o.btnNext&&null===o.btnPrev,cssU=-1!=v.toString().indexOf("%")?"%":-1!=v.toString().indexOf("px")?"px":"el",direction=null;if(o.speed=Math.max(20,o.speed),o.circular){var imgSet=tLi.clone();ul.prepend(imgSet).append(imgSet.clone())}var li=$("li",ul);div.css("visibility","visible"),li.css("overflow","hidden").css("float",o.vertical?"none":"left").children().css("overflow","hidden"),o.vertical||li.css("display","inline"),"a"!=li.children().get(0).tagName.toLowerCase()||o.vertical||li.children().css("float","left"),ul.css("margin","0").css("padding","0").css("position","relative").css("list-style-type","none").css("z-index","1"),div.css("overflow","hidden").css("position","relative").css("z-index","2").css("left","0px");var el,liSize=o.vertical?height(li):(el=li)[0].offsetWidth+css(el,"marginLeft")+css(el,"marginRight"),liSizeV=o.vertical?function(el){var elImg=el.find("img");return o.vertical?parseInt(el.css("margin-left"))+parseInt(el.css("margin-right"))+parseInt(elImg.width())+parseInt(el.css("border-left-width"))+parseInt(el.css("border-right-width"))+parseInt(el.css("padding-right"))+parseInt(el.css("padding-left")):parseInt(el.css("margin-top"))+parseInt(el.css("margin-bottom"))+parseInt(elImg.width())+parseInt(el.css("border-top-height"))+parseInt(el.css("border-bottom-height"))+parseInt(el.css("padding-top"))+parseInt(el.css("padding-bottom"))}(li):height(li),curr=o.start,nbAllElts=li.length,ulSize=liSize*nbAllElts,nbElts=tl,eltsSize=nbElts*liSize,allEltsSize=nbAllElts*liSize,step="default"==o.step?liSize:o.step;o.btnPrev=$(defaultBtn?'<input type="button" class="'+(o.vertical?"up":"prev")+'" />':o.btnPrev),o.btnNext=$(defaultBtn?'<input type="button" class="'+(o.vertical?"down":"next")+'" />':o.btnNext);var divSize,cssSize,cssUnity,prev=o.btnPrev,next=o.btnNext;if(defaultBtn&&!0!==o.auto&&(prev.css({opacity:"0.6"}),next.css({opacity:"0.6"}),div.prepend(prev),div.prepend(next),o.btnPrev=prev,o.btnNext=next),o.eltByElt&&(step=liSize,o.start%liSize!=0)){var imgStart=parseInt(o.start/liSize);curr=o.start=imgStart*liSize}if(o.circular&&(o.start+=liSize*tl,curr+=liSize*tl),"%"==cssU?(divSize=0,cssSize=parseInt(v),cssUnity="%"):"px"==cssU?(divSize=parseInt(v),cssSize=parseInt(v),cssUnity="px"):(divSize=liSize*parseInt(v),cssSize=liSize*parseInt(v),cssUnity="px"),ul.css(sizeCss,ulSize+"px").css(animCss,-o.start),div.css(sizeCss,cssSize+cssUnity),o.vertical&&"%"==cssUnity){var pxsize=liSize*nbElts*(parseInt(v)/100);div.css(sizeCss,pxsize+"px")}0===divSize&&(divSize=div.width()),o.vertical?(div.css("width",liSizeV+"px"),ul.css("width",liSizeV+"px"),li.css("margin-bottom",2*parseInt(li.css("margin-bottom"))+"px"),li.eq(li.length-1).css("margin-bottom",li.css("margin-top"))):(div.css("height",liSizeV+"px"),ul.css("height",liSizeV+"px")),"%"==cssU&&((v=divSize/li.width())%1!=0&&(v+=1),v=parseInt(v));var divVSize=div.height();function forward(stepsize,once){var s=stepsize||step;!0===running&&"backward"===direction||(o.circular||curr+s+(o.vertical?divVSize:divSize)>eltsSize&&(s=eltsSize-(curr+(o.vertical?divVSize:divSize))),ul.animate("left"==animCss?{left:-(curr+s)}:{top:-(curr+s)},o.speed,o.easing,function(){curr+=s,o.circular&&curr+(o.vertical?divVSize:divSize)+liSize>=allEltsSize&&(ul.css(o.vertical?"top":"left",-curr+eltsSize),curr-=eltsSize),!once&&running?(forward(),console.log("forward")):once&&(--mousewheelN>0?forward(step,!0):(running=!1,direction=null))}))}function backward(stepsize,once){var s=stepsize||step;!0===running&&"forward"===direction||(o.circular||curr-s<0&&(s=curr-0),ul.animate("left"==animCss?{left:-(curr-s)}:{top:-(curr-s)},o.speed,o.easing,function(){curr-=s,o.circular&&curr<=liSize&&(ul.css(o.vertical?"top":"left",-(curr+eltsSize)),curr+=eltsSize),!once&&running?backward():once&&(--mousewheelN>0?backward(step,!0):(running=!1,direction=null))}))}function stop(){o.eltByElt||(ul.stop(),curr=0-parseInt(ul.css(animCss))),running=!1,direction=null}defaultBtn&&(next.css({"z-index":200,position:"absolute"}),prev.css({"z-index":200,position:"absolute"}),o.vertical?(prev.css({width:prev.width(),height:prev.height(),top:"0px",left:parseInt(liSizeV/2)-parseInt(prev.width()/2)+"px"}),next.css({width:prev.width(),height:prev.height(),top:divVSize-prev.height()+"px",left:parseInt(liSizeV/2)-parseInt(prev.width()/2)+"px"})):(prev.css({left:"0px",top:parseInt(liSizeV/2)-parseInt(prev.height()/2)+"px"}),next.css({right:"0px",top:parseInt(liSizeV/2)-parseInt(prev.height()/2)+"px"}))),o.btnPrev&&($(o.btnPrev).on(o.evtStart,function(event){return event.preventDefault(),defaultBtn&&o.btnPrev.css("opacity",.9),running=!0,direction="backward",backward()}),$(o.btnPrev).on(o.evtStop,function(event){return event.preventDefault(),defaultBtn&&o.btnPrev.css("opacity",.6),running=!1,direction=null,stop()})),o.btnNext&&($(o.btnNext).on(o.evtStart,function(event){return event.preventDefault(),defaultBtn&&o.btnNext.css("opacity",.9),running=!0,direction="forward",forward()}),$(o.btnNext).on(o.evtStop,function(event){return event.preventDefault(),defaultBtn&&o.btnNext.css("opacity",.6),running=!1,direction=null,stop()})),!0===o.auto&&(running=!0,forward()),o.mouseWheel&&div.mousewheel&&div.mousewheel(function(e,d){(!o.circular&&(d>0?curr+divSize<ulSize:curr>0)||o.circular)&&(mousewheelN+=1,!1===running&&(d>0?forward(step,!0):backward(step,!0),running=!0))})})}}(jQuery);
(function(e){function y(a,r){return parseInt(e.css(a[0],r))||0}function G(a){return a[0].offsetHeight+y(a,"marginTop")+y(a,"marginBottom")}e.fn.jMyCarousel=function(a){a=e.extend({btnPrev:null,btnNext:null,mouseWheel:!0,auto:!1,speed:500,easing:"linear",vertical:!1,circular:!0,visible:"4",start:0,scroll:1,step:50,eltByElt:!1,evtStart:"mouseover touchstart",evtStop:"mouseout touchend",beforeStart:null,afterEnd:null},a||{});return this.each(function(){function r(w,b){var c=w?w:s;if(!(!0===g&&"backward"===
n)){if(!a.circular&&d+c+(a.vertical?z:m)>t)c=t-(d+(a.vertical?z:m));k.animate("left"==A?{left:-(d+c)}:{top:-(d+c)},a.speed,a.easing,function(){d+=c;if(a.circular&&d+(a.vertical?z:m)+f>=J)k.css(a.vertical?"top":"left",-d+t),d-=t;!b&&g?(r(),console.log("forward")):b&&(0<--B?r(s,!0):(g=!1,n=null))})}}function C(w,b){var c=w?w:s;!0===g&&"forward"===n||(a.circular||0>d-c&&(c=d-0),k.animate("left"==A?{left:-(d-c)}:{top:-(d-c)},a.speed,a.easing,function(){d-=c;a.circular&&d<=f&&(k.css(a.vertical?"top":"left",
-(d+t)),d+=t);!b&&g?C():b&&(0<--B?C(s,!0):(g=!1,n=null))}))}function H(){a.eltByElt||(k.stop(),d=0-parseInt(k.css(A)));g=!1;n=null}function K(b){var c=b.find("img");return a.vertical?parseInt(b.css("margin-left"))+parseInt(b.css("margin-right"))+parseInt(c.width())+parseInt(b.css("border-left-width"))+parseInt(b.css("border-right-width"))+parseInt(b.css("padding-right"))+parseInt(b.css("padding-left")):parseInt(b.css("margin-top"))+parseInt(b.css("margin-bottom"))+parseInt(c.width())+parseInt(b.css("border-top-height"))+
parseInt(b.css("border-bottom-height"))+parseInt(b.css("padding-top"))+parseInt(b.css("padding-bottom"))}var g=!1,A=a.vertical?"top":"left",E=a.vertical?"height":"width",l=e(this),k=e("ul",l),b=e("li",k),u=b.length,h=a.visible,B=0,p=null===a.btnNext&&null===a.btnPrev?!0:!1,F=-1!=h.toString().indexOf("%")?"%":-1!=h.toString().indexOf("px")?"px":"el",n=null;a.speed=Math.max(20,a.speed);a.circular&&(b=b.clone(),k.prepend(b).append(b.clone()));b=e("li",k);l.css("visibility","visible");b.css("overflow",
"hidden").css("float",a.vertical?"none":"left").children().css("overflow","hidden");a.vertical||b.css("display","inline");"a"==b.children().get(0).tagName.toLowerCase()&&!a.vertical&&b.children().css("float","left");a.vertical&&jQuery.browser.msie&&b.css("line-height","4px").children().css("margin-bottom","-4px");k.css("margin","0").css("padding","0").css("position","relative").css("list-style-type","none").css("z-index","1");l.css("overflow","hidden").css("position","relative").css("z-index","2").css("left",
"0px");var f=a.vertical?G(b):b[0].offsetWidth+y(b,"marginLeft")+y(b,"marginRight"),q=a.vertical?K(b):G(b),d=a.start,c=b.length,I=f*c,t=u*f,J=c*f,s="default"==a.step?f:a.step;a.btnPrev=p?e('<input type="button" class="'+(a.vertical?"up":"prev")+'" />'):e(a.btnPrev);a.btnNext=p?e('<input type="button" class="'+(a.vertical?"down":"next")+'" />'):e(a.btnNext);var c=a.btnPrev,v=a.btnNext;p&&!0!==a.auto&&(c.css({opacity:"0.6"}),v.css({opacity:"0.6"}),l.prepend(c),l.prepend(v),a.btnPrev=c,a.btnNext=v);if(a.eltByElt&&
(s=f,0!==a.start%f))var x=parseInt(a.start/f),d=a.start=x*f;a.circular&&(a.start+=f*u,d+=f*u);var m,D;"%"==F?(m=0,x=parseInt(h),D="%"):("px"==F?(m=parseInt(h),x=parseInt(h)):(m=f*parseInt(h),x=f*parseInt(h)),D="px");k.css(E,I+"px").css(A,-a.start);l.css(E,x+D);a.vertical&&"%"==D&&(u=f*u*(parseInt(h)/100),l.css(E,u+"px"));0===m&&(m=l.width());a.vertical?(l.css("width",q+"px"),k.css("width",q+"px"),b.css("margin-bottom",2*parseInt(b.css("margin-bottom"))+"px"),b.eq(b.length-1).css("margin-bottom",b.css("margin-top"))):
(l.css("height",q+"px"),k.css("height",q+"px"));"%"==F&&(h=m/b.width(),0!==h%1&&(h+=1),h=parseInt(h));var z=l.height();p&&(v.css({"z-index":200,position:"absolute"}),c.css({"z-index":200,position:"absolute"}),a.vertical?(c.css({width:c.width(),height:c.height(),top:"0px",left:parseInt(q/2)-parseInt(c.width()/2)+"px"}),v.css({width:c.width(),height:c.height(),top:z-c.height()+"px",left:parseInt(q/2)-parseInt(c.width()/2)+"px"})):(c.css({left:"0px",top:parseInt(q/2)-parseInt(c.height()/2)+"px"}),v.css({right:"0px",
top:parseInt(q/2)-parseInt(c.height()/2)+"px"})));a.btnPrev&&(e(a.btnPrev).on(a.evtStart,function(b){b.preventDefault();p&&a.btnPrev.css("opacity",0.9);g=!0;n="backward";return C()}),e(a.btnPrev).on(a.evtStop,function(b){b.preventDefault();p&&a.btnPrev.css("opacity",0.6);g=!1;n=null;return H()}));a.btnNext&&(e(a.btnNext).on(a.evtStart,function(b){b.preventDefault();p&&a.btnNext.css("opacity",0.9);g=!0;n="forward";return r()}),e(a.btnNext).on(a.evtStop,function(b){b.preventDefault();p&&a.btnNext.css("opacity",
0.6);g=!1;n=null;return H()}));!0===a.auto&&(g=!0,r());a.mouseWheel&&l.mousewheel&&l.mousewheel(function(b,c){if(!a.circular&&(0<c?d+m<I:0<d)||a.circular)B+=1,!1===g&&(0<c?r(s,!0):C(s,!0),g=!0)})})}})(jQuery);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment