Unverified Commit e51fd4b1 authored by Rishi Kulshreshtha's avatar Rishi Kulshreshtha
Browse files

Feat: Improve FlexSlider initialization and element selection in JavaScript

- Updated the initialization of FlexSlider by using a regular function instead of an arrow function in the `flexslider.load.js` and `flexslider.load.min.js` files.
- Updated the element selection in the `flexslider.load.js` and `flexslider.load.min.js` files to use `$(this)` instead of `$(once(...))` and `$(_this)` respectively.

Changes:
- assets/js/flexslider.load.js: Improved FlexSlider initialization and element selection.
- dist/js/flexslider.load.js: Improved FlexSlider initialization and element selection.
- dist/js/flexslider.load.min.js: Improved FlexSlider initialization and element selection.
parent aefeed65
Loading
Loading
Loading
Loading
+1 −1
Changes for assets/js/flexslider.load.js: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@
   * @private
   */
  function flexsliderInit(id, optionset, context) {
    $(once("flexslider", `#${id}`, context)).each(() => {
    $(once("flexslider", `#${id}`, context)).each(function () {
      // Remove width/height attributes.
      // @todo load the css path from the settings
      $(this)
+4 −5
Changes for dist/js/flexslider.load.js: 4 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -3,11 +3,10 @@

  (function ($) {
    function flexsliderInit(id, optionset, context) {
      var _this = this;
      $(once('flexslider', "#".concat(id), context)).each(function () {
        $(_this).find("ul.slides > li > *").removeAttr("width").removeAttr("height");
      $(once("flexslider", "#".concat(id), context)).each(function () {
        $(this).find("ul.slides > li > *").removeAttr("width").removeAttr("height");
        if (optionset) {
          $(_this).flexslider($.extend(optionset, {
          $(this).flexslider($.extend(optionset, {
            start: function start(slider) {
              slider.trigger("start", [slider]);
            },
@@ -31,7 +30,7 @@
            }
          }));
        } else {
          $(_this).flexslider();
          $(this).flexslider();
        }
      });
    }
+1 −1
Changes for dist/js/flexslider.load.min.js: 1 added line, 1 removed line.
Original line number Diff line number Diff line
!function(){"use strict";!function(e){function i(i,n,t){var r=this;e(once("flexslider","#".concat(i),t)).each((function(){e(r).find("ul.slides > li > *").removeAttr("width").removeAttr("height"),n?e(r).flexslider(e.extend(n,{start:function(e){e.trigger("start",[e])},before:function(e){e.trigger("before",[e])},after:function(e){e.trigger("after",[e])},end:function(e){e.trigger("end",[e])},added:function(e){e.trigger("added",[e])},removed:function(e){e.trigger("removed",[e])},init:function(e){e.trigger("init",[e])}})):e(r).flexslider()}))}Drupal.behaviors.flexslider={attach:function(n,t){var r,s=[];if("undefined"!==e.type(t.flexslider)&&"undefined"!==e.type(t.flexslider.instances))for(r in t.flexslider.instances)t.flexslider.instances.hasOwnProperty(r)&&"undefined"!==e.type(t.flexslider.optionsets)&&t.flexslider.instances[r]in t.flexslider.optionsets&&(""!==t.flexslider.optionsets[t.flexslider.instances[r]].asNavFor?i(r,t.flexslider.optionsets[t.flexslider.instances[r]],n):s[r]=t.flexslider.optionsets[t.flexslider.instances[r]]);for(r in s)s.hasOwnProperty(r)&&i(r,t.flexslider.optionsets[t.flexslider.instances[r]],n)}}}(jQuery)}();
!function(){"use strict";!function(e){function i(i,t,n){e(once("flexslider","#".concat(i),n)).each((function(){e(this).find("ul.slides > li > *").removeAttr("width").removeAttr("height"),t?e(this).flexslider(e.extend(t,{start:function(e){e.trigger("start",[e])},before:function(e){e.trigger("before",[e])},after:function(e){e.trigger("after",[e])},end:function(e){e.trigger("end",[e])},added:function(e){e.trigger("added",[e])},removed:function(e){e.trigger("removed",[e])},init:function(e){e.trigger("init",[e])}})):e(this).flexslider()}))}Drupal.behaviors.flexslider={attach:function(t,n){var s,r=[];if("undefined"!==e.type(n.flexslider)&&"undefined"!==e.type(n.flexslider.instances))for(s in n.flexslider.instances)n.flexslider.instances.hasOwnProperty(s)&&"undefined"!==e.type(n.flexslider.optionsets)&&n.flexslider.instances[s]in n.flexslider.optionsets&&(""!==n.flexslider.optionsets[n.flexslider.instances[s]].asNavFor?i(s,n.flexslider.optionsets[n.flexslider.instances[s]],t):r[s]=n.flexslider.optionsets[n.flexslider.instances[s]]);for(s in r)r.hasOwnProperty(s)&&i(s,n.flexslider.optionsets[n.flexslider.instances[s]],t)}}}(jQuery)}();