Commit 7c0497a3 authored by Gaus Surahman's avatar Gaus Surahman Committed by Gaus Surahman
Browse files

Issue #3262447 by gausarts, Grimreaper: Configuration parsing for object is broken

parent 87b92b0e
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line

Splide 1.0.0-dev, 2022-02-04
----------------------------
- Issue #3262447 by gausarts, Grimreaper: Configuration parsing for object is
  broken.

Splide 1.0.0-dev, 2022-02-03
----------------------------
- Issue #3256953 by wrd-oaitsd, gausarts: Pagination options.
+8 −5
Original line number Diff line number Diff line
@@ -44,10 +44,11 @@
    var de = _doc.documentElement;
    var wh = _win.innerHeight || de.clientHeight;
    var ww = _win.innerWidth || de.clientWidth;
    var dataCw = 'data-splide-cw';
    var dataCh = 'data-splide-ch';
    var dataNw = 'data-splide-nw';
    var dataNh = 'data-splide-nh';
    var _dataSplide = 'data-splide';
    var dataCw = _dataSplide + '-cw';
    var dataCh = _dataSplide + '-ch';
    var dataNw = _dataSplide + '-nw';
    var dataNh = _dataSplide + '-nh';
    var _scrollRaf = null;

    return {
@@ -148,7 +149,9 @@
      },

      bindWheel: function (el, bind, callback) {
        $[bind ? 'bindEvent' : 'unbindEvent'](el, 'wheel', callback, false);
        $[bind ? 'bindEvent' : 'unbindEvent'](el, 'wheel', callback, {
          passive: true
        });
      },

      prepare: function () {
+1 −1
Original line number Diff line number Diff line
!function(F,I,L,O){"use strict";I.extend({Zoom:function(d,h){var r,t,l,a,c,u,e=d.root,f=d.options.zoom||{},m=f.max||1.5,p=f.min||.6,n=f.on||!1,y=f.scale||!1,g=f.click||!1,o=f.root||!1,i=f.rootClass||"is-zoomed",x=f.target||".slide__media",v=f.dragClass||"is-dragging",Z="is-zoomable",s=1,b={x:0,y:0},z=null,w=null,S=null,q=0,E={},k=O.documentElement,A=L.innerHeight||k.clientHeight,C=L.innerWidth||k.clientWidth,D="data-splide-cw",M="data-splide-ch",W="data-splide-nh",_=null;return{currSlide:null,unZoomed:!1,mount:function(){var e=this;n&&(d.on("mounted.spz",function(){L.setTimeout(function(){e.wheelZoom()},500)}),d.on("active.spz",function(t){e.currSlide=t,e.unZoomed=!1,e.prepare()}),d.on("inactive.spz",function(t){e.currSlide=null,e.toogleClass(!1);t=t.slide.querySelector("."+Z);e.scale(!1,t)}),e.dragon())},wheelZoom:function(){var n=this;(t=e.querySelectorAll(x)).length&&F.forEach(t,function(t){var e=t.querySelector("."+Z);null!==e&&(n.fit(e),n.scale(!1,e),n.bindWheel(t,!0,n.zoom.bind(n)))})},fit:function(t){var e=this,n=t.offsetHeight,o=t.offsetWidth,i=parseInt(I.attr(t,"height",0)),s=parseInt(I.attr(t,"width",0));A<n&&(u=C/o<A/n?n*((c=C)/o):(c=o*(A/n),A));n=e.sizes(t);e.isEmpty(n)||!n.nw&&!n.w||(l=n.w,a=n.h,c=n.nw||c,u=n.nh||u,e.toData(t),I.attr(t,W)||(t.setAttribute(D,l),t.setAttribute(M,a),t.setAttribute("data-splide-nw",c),t.setAttribute(W,u))),i<A&&(u=i,c=s,t.dataset.splideFit=1),t.style.width=c+"px",t.style.height=u+"px"},bindWheel:function(t,e,n){F[e?"bindEvent":"unbindEvent"](t,"wheel",n,!1)},prepare:function(){this.currSlide&&null!==(w=this.currSlide.slide.querySelector(x))&&(S=w.querySelector("."+Z))},zoomRoot:function(){return null===z&&o&&(z="string"==typeof o?document.querySelector(o):o),z||e},zoom:function(t){var e=this,n=I.wheelDelta(t);t.preventDefault(),e.prepare(),s+=-.01*n,s=Math.min(Math.max(1,s),m),e.isZoomed()?(e.unZoomed=!1,e.scrollon(t)):e.unZoomed?(s=1,e.scale(!1,S)):e.scale(!e.isZoomed(),S)},scale:function(t,e){0;var n,o,i,s,l=t;this.toogleClass(l),null!==e&&y&&(i=F.closest(e,".slide"),o=F.closest(e,".slide__content"),n=parseInt(I.attr(e,"width",0)),s=parseInt(I.attr(e,"height",0)),o=o.offsetWidth,i.classList.add(Z+"-slide"),i=p,s=4<(m=s/A)?m/2:m,n<o&&(i=.8,s=1),r=t?s:i,e.style.transform="scale("+r+")"),!w||l&&this.isZoomed()&&null!==e||(w.style.transform="translate(0px)")},scrollon:function(t){var e=this;_&&L.cancelAnimationFrame(_),e.sizes(),!e.isEmpty(E)&&e.isValid()&&(_=L.requestAnimationFrame(function(){e._scrollon(t)}))},_scrollon:function(t){t.preventDefault(),t.stopPropagation();var e=w.querySelector("."+Z),n=null!==e&&e.dataset.splideFit,o=Math.abs(E.h-E.ph)/1.5,e=I.wheelDelta(t),t=.5*o;return b.y+=0<e?-t:t,b.x=0,q=Math.abs(b.y)>=o,0<e&&q?b.y=-o:e<0&&q&&(b.y=o),w&&!n&&(w.style.transform="translate("+b.x+"px,"+b.y+"px)"),_=null,!1},dragon:function(){var n,o,i=this,t=i.zoomRoot(),s=!1,e=f,l=w,r=0;e.onClick=!!g&&i.clicked.bind(i),e.callback=function(t,e){l=e.el||l,b.x=e.x||0,b.y=e.y||0,i.sizes(),r=Math.ceil((E.h-E.ph)/2),o=e.dir,n=e.phase,l&&("start"===n?u("off"):"move"===n?i.isZoomed()?l.style.transform="translate("+b.x+"px,"+b.y+"px)":c():"end"===n&&function(){q=Math.abs(b.y)>=r;var t="right"===o;t||"left"===o?(s=!0,b.x=t?0:-1):q&&(s=!0,b.y="down"===o&&0<b.y?r:-r),L.setTimeout(function(){u("on"),i.isZoomed()?s&&(l.style.transform="translate("+b.x+"px,"+b.y+"px)"):c()},300)}())},e.dragClass=v;var a=[];function c(){l.style.transform="translate(0px)"}function u(t){i[t](),d.options={drag:!i.isZoomed()}}F.forEach(h.Elements.slides,function(t){t=t.querySelector(x);t&&a.push(t)}),e.elms=a,new SwipeDetect(t,e)},clicked:function(t){t.target.classList.contains(Z)?(this.unZoomed=!1,s=m,this.scale(!this.isZoomed(),t.target)):this.unZoomed=!0},sizes:function(t){return S=t||S,E=I.checkSizes(S,w)},isEmpty:function(t){return t&&0===Object.keys(t).length&&Object.getPrototypeOf(t)===Object.prototype},toData:function(t){l=I.attr(t,D,l),a=I.attr(t,M,a)},isValid:function(){return this.prepare(),null!==w},isZoomed:function(){return n&&this.zoomRoot().classList.contains(i)},toogleClass:function(t){this.zoomRoot().classList[t?"add":"remove"](i)},on:function(){this.unZoomed=!1},off:function(){this.unZoomed=!0}}}})}(dBlazy,dSplide,this,this.document);
!function(F,I,L,O){"use strict";I.extend({Zoom:function(d,h){var r,t,l,a,c,u,e=d.root,f=d.options.zoom||{},m=f.max||1.5,p=f.min||.6,n=f.on||!1,y=f.scale||!1,g=f.click||!1,o=f.root||!1,i=f.rootClass||"is-zoomed",v=f.target||".slide__media",x=f.dragClass||"is-dragging",Z="is-zoomable",s=1,b={x:0,y:0},z=null,w=null,S=null,q=0,E={},k=O.documentElement,A=L.innerHeight||k.clientHeight,C=L.innerWidth||k.clientWidth,k="data-splide",D=k+"-cw",M=k+"-ch",W=k+"-nh",_=null;return{currSlide:null,unZoomed:!1,mount:function(){var e=this;n&&(d.on("mounted.spz",function(){L.setTimeout(function(){e.wheelZoom()},500)}),d.on("active.spz",function(t){e.currSlide=t,e.unZoomed=!1,e.prepare()}),d.on("inactive.spz",function(t){e.currSlide=null,e.toogleClass(!1);t=t.slide.querySelector("."+Z);e.scale(!1,t)}),e.dragon())},wheelZoom:function(){var n=this;(t=e.querySelectorAll(v)).length&&F.forEach(t,function(t){var e=t.querySelector("."+Z);null!==e&&(n.fit(e),n.scale(!1,e),n.bindWheel(t,!0,n.zoom.bind(n)))})},fit:function(t){var e=this,n=t.offsetHeight,o=t.offsetWidth,i=parseInt(I.attr(t,"height",0)),s=parseInt(I.attr(t,"width",0));A<n&&(u=C/o<A/n?n*((c=C)/o):(c=o*(A/n),A));n=e.sizes(t);e.isEmpty(n)||!n.nw&&!n.w||(l=n.w,a=n.h,c=n.nw||c,u=n.nh||u,e.toData(t),I.attr(t,W)||(t.setAttribute(D,l),t.setAttribute(M,a),t.setAttribute("data-splide-nw",c),t.setAttribute(W,u))),i<A&&(u=i,c=s,t.dataset.splideFit=1),t.style.width=c+"px",t.style.height=u+"px"},bindWheel:function(t,e,n){F[e?"bindEvent":"unbindEvent"](t,"wheel",n,{passive:!0})},prepare:function(){this.currSlide&&null!==(w=this.currSlide.slide.querySelector(v))&&(S=w.querySelector("."+Z))},zoomRoot:function(){return null===z&&o&&(z="string"==typeof o?document.querySelector(o):o),z||e},zoom:function(t){var e=this,n=I.wheelDelta(t);t.preventDefault(),e.prepare(),s+=-.01*n,s=Math.min(Math.max(1,s),m),e.isZoomed()?(e.unZoomed=!1,e.scrollon(t)):e.unZoomed?(s=1,e.scale(!1,S)):e.scale(!e.isZoomed(),S)},scale:function(t,e){0;var n,o,i,s,l=t;this.toogleClass(l),null!==e&&y&&(i=F.closest(e,".slide"),o=F.closest(e,".slide__content"),n=parseInt(I.attr(e,"width",0)),s=parseInt(I.attr(e,"height",0)),o=o.offsetWidth,i.classList.add(Z+"-slide"),i=p,s=4<(m=s/A)?m/2:m,n<o&&(i=.8,s=1),r=t?s:i,e.style.transform="scale("+r+")"),!w||l&&this.isZoomed()&&null!==e||(w.style.transform="translate(0px)")},scrollon:function(t){var e=this;_&&L.cancelAnimationFrame(_),e.sizes(),!e.isEmpty(E)&&e.isValid()&&(_=L.requestAnimationFrame(function(){e._scrollon(t)}))},_scrollon:function(t){t.preventDefault(),t.stopPropagation();var e=w.querySelector("."+Z),n=null!==e&&e.dataset.splideFit,o=Math.abs(E.h-E.ph)/1.5,e=I.wheelDelta(t),t=.5*o;return b.y+=0<e?-t:t,b.x=0,q=Math.abs(b.y)>=o,0<e&&q?b.y=-o:e<0&&q&&(b.y=o),w&&!n&&(w.style.transform="translate("+b.x+"px,"+b.y+"px)"),_=null,!1},dragon:function(){var n,o,i=this,t=i.zoomRoot(),s=!1,e=f,l=w,r=0;e.onClick=!!g&&i.clicked.bind(i),e.callback=function(t,e){l=e.el||l,b.x=e.x||0,b.y=e.y||0,i.sizes(),r=Math.ceil((E.h-E.ph)/2),o=e.dir,n=e.phase,l&&("start"===n?u("off"):"move"===n?i.isZoomed()?l.style.transform="translate("+b.x+"px,"+b.y+"px)":c():"end"===n&&function(){q=Math.abs(b.y)>=r;var t="right"===o;t||"left"===o?(s=!0,b.x=t?0:-1):q&&(s=!0,b.y="down"===o&&0<b.y?r:-r),L.setTimeout(function(){u("on"),i.isZoomed()?s&&(l.style.transform="translate("+b.x+"px,"+b.y+"px)"):c()},300)}())},e.dragClass=x;var a=[];function c(){l.style.transform="translate(0px)"}function u(t){i[t](),d.options={drag:!i.isZoomed()}}F.forEach(h.Elements.slides,function(t){t=t.querySelector(v);t&&a.push(t)}),e.elms=a,new SwipeDetect(t,e)},clicked:function(t){t.target.classList.contains(Z)?(this.unZoomed=!1,s=m,this.scale(!this.isZoomed(),t.target)):this.unZoomed=!0},sizes:function(t){return S=t||S,E=I.checkSizes(S,w)},isEmpty:function(t){return t&&0===Object.keys(t).length&&Object.getPrototypeOf(t)===Object.prototype},toData:function(t){l=I.attr(t,D,l),a=I.attr(t,M,a)},isValid:function(){return this.prepare(),null!==w},isZoomed:function(){return n&&this.zoomRoot().classList.contains(i)},toogleClass:function(t){this.zoomRoot().classList[t?"add":"remove"](i)},on:function(){this.unZoomed=!1},off:function(){this.unZoomed=!0}}}})}(dBlazy,dSplide,this,this.document);
+3 −4
Original line number Diff line number Diff line
@@ -474,7 +474,7 @@ class SplideForm extends SplideFormBase {
      $elements['padding'] = [
        'type'         => 'textfield',
        'title'        => $this->t('Padding'),
        'description'  => $this->t("Set padding-left/right in horizontal mode or padding-top/bottom in vertical one. E.g.: <code>{ left : 0, right: '2rem' }</code>, including braces _only for multiple values. Must be a valid JSON object. Or just <code>10</code> for single value without braces, meaning padding left/right(top/bottom) will be 10px."),
        'description'  => $this->t("Set padding-left/right in horizontal mode or padding-top/bottom in vertical one. E.g.: <code>{ 'left' : 0, 'right': '2rem' }</code>, including braces _only for multiple values. Must be a valid JSON object. Or just <code>10</code> for single value without braces, meaning padding left/right(top/bottom) will be 10px."),
      ];

      $elements['easing'] = [
@@ -679,14 +679,13 @@ class SplideForm extends SplideFormBase {
      $elements['classes'] = [
        'type'        => 'textarea',
        'title'       => $this->t('Classes'),
        'description' => $this->t("Collection of class names. To add your own classes to arrows or pagination buttons, provide them with original classes like this: <b><br><br>{ <br>arrows: 'splide__arrows your-class-arrows', <br>arrow: 'splide__arrow your-class-arrow', <br>prev: 'splide__arrow--prev your-class-prev', <br>next: 'splide__arrow--next your-class-next', <br>pagination: 'splide__pagination your-class-pagination', <br>page: 'splide__pagination__page your-class-page' <br>}</b><br><br>Including braces. Must be a valid JSON object like the sample. Be sure the original class (the first one) is always included to avoid broken displays."),
        'description' => $this->t("Collection of class names. To add your own classes to arrows or pagination buttons, provide them with original classes like this: <b><br><br>{ <br>'arrows': 'splide__arrows your-class-arrows', <br>'arrow': 'splide__arrow your-class-arrow', <br>'prev': 'splide__arrow--prev your-class-prev', <br>'next': 'splide__arrow--next your-class-next', <br>'pagination': 'splide__pagination your-class-pagination', <br>'page': 'splide__pagination__page your-class-page' <br>}</b><br><br>Including braces. Must be a valid JSON object like the sample. Be sure the original class (the first one) is always included to avoid broken displays."),
      ];

      $elements['i18n'] = [
        'type'        => 'textarea',
        'title'       => $this->t('i18n'),
        'description' => $this->t("Here is a list of default texts. `%s` will be replaced by a slide or page number: <b><br><br>{ <br>prev: 'Previous slide', <br>next: 'Next slide', <br>first: 'Go to first slide', <br>last: 'Go to last slide', <br>slideX: 'Go to slide %s', <br>pageX: 'Go to page %s', <br>play: 'Start autoplay',
        <br>pause: 'Pause autoplay' <br>}</b><br><br>Including braces. Must be a valid JSON object like the sample."),
        'description' => $this->t("Here is a list of default texts. `%s` will be replaced by a slide or page number: <b><br><br>{ <br>'prev': 'Previous slide', <br>'next': 'Next slide', <br>'first': 'Go to first slide', <br>'last': 'Go to last slide', <br>'slideX': 'Go to slide %s', <br>'pageX': 'Go to page %s', <br>'play': 'Start autoplay', <br>'pause': 'Pause autoplay' <br>}</b><br><br>Including braces. Must be a valid JSON object like the sample."),
      ];

      // Defines the default values if available.
+3 −2
Original line number Diff line number Diff line
@@ -134,7 +134,7 @@ class Splide extends SplideBase implements SplideInterface {
    $config   = [];
    $defaults = self::typecast(self::defaultSettings(), FALSE);

    foreach (['video', 'zoom'] as $key) {
    foreach (self::getObjects() as $key) {
      unset($defaults[$key]);
    }

@@ -337,7 +337,7 @@ class Splide extends SplideBase implements SplideInterface {
        $value = &$config[$item];
        try {
          if (is_string($value) && strpos($value, "{") !== FALSE) {
            $results[$item] = (object) Json::decode($value);
            $results[$item] = (object) Json::decode(str_replace("'", '"', trim($value)));
          }
          else {
            $results[$item] = is_numeric($value) ? (int) $value : $value;
@@ -399,6 +399,7 @@ class Splide extends SplideBase implements SplideInterface {
      'classes',
      'i18n',
      'video',
      'zoom',
    ];
  }