Advertisement
bongzilla

Untitled

Oct 9th, 2021
967
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script>
  2. $(document).ready(function(e) {
  3.     /*
  4.     A simple jQuery function that can add listeners on attribute change.
  5.     http://meetselva.github.io/attrchange/
  6.     About License:
  7.     Copyright (C) 2013-2014 Selvakumar Arumugam
  8.     You may use attrchange plugin under the terms of the MIT Licese.
  9.     https://github.com/meetselva/attrchange/blob/master/MIT-License.txt
  10.      */
  11.     !function(a){function b(){var a=document.createElement("p"),b=!1;if(a.addEventListener)a.addEventListener("DOMAttrModified",function(){b=!0},!1);else{if(!a.attachEvent)return!1;a.attachEvent("onDOMAttrModified",function(){b=!0})}return a.setAttribute("id","target"),b}function c(b,c){if(b){var d=this.data("attr-old-value");if(c.attributeName.indexOf("style")>=0){d.style||(d.style={});var e=c.attributeName.split(".");c.attributeName=e[0],c.oldValue=d.style[e[1]],c.newValue=e[1]+":"+this.prop("style")[a.camelCase(e[1])],d.style[e[1]]=c.newValue}else c.oldValue=d[c.attributeName],c.newValue=this.attr(c.attributeName),d[c.attributeName]=c.newValue;this.data("attr-old-value",d)}}var d=window.MutationObserver||window.WebKitMutationObserver;a.fn.attrchange=function(e,f){if("object"==typeof e){var g={trackValues:!1,callback:a.noop};if("function"==typeof e?g.callback=e:a.extend(g,e),g.trackValues&&this.each(function(b,c){for(var e,d={},b=0,f=c.attributes,g=f.length;g>b;b++)e=f.item(b),d[e.nodeName]=e.value;a(this).data("attr-old-value",d)}),d){var h={subtree:!1,attributes:!0,attributeOldValue:g.trackValues},i=new d(function(b){b.forEach(function(b){var c=b.target;g.trackValues&&(b.newValue=a(c).attr(b.attributeName)),"undefined"==typeof a(this).data("attrchange-tdisconnect")&&g.callback.call(c,b)})});return this.data("attrchange-method","Mutation Observer").data("attrchange-obs",i).each(function(){i.observe(this,h)})}return b()?this.data("attrchange-method","DOMAttrModified").on("DOMAttrModified",function(b){b.originalEvent&&(b=b.originalEvent),b.attributeName=b.attrName,b.oldValue=b.prevValue,"undefined"==typeof a(this).data("attrchange-tdisconnect")&&g.callback.call(this,b)}):"onpropertychange"in document.body?this.data("attrchange-method","propertychange").on("propertychange",function(b){b.attributeName=window.event.propertyName,c.call(a(this),g.trackValues,b),"undefined"==typeof a(this).data("attrchange-tdisconnect")&&g.callback.call(this,b)}):this}return"string"==typeof e&&a.fn.attrchange.hasOwnProperty("extensions")&&a.fn.attrchange.extensions.hasOwnProperty(e)?a.fn.attrchange.extensions[e].call(this,f):void 0}}(jQuery);
  12.     /* end of attrchange  */
  13.  
  14.     const sliders = $(".b-slider");
  15.  
  16.     sliders.each(function(idx, el) {
  17.         const currentSlideNumDiv = $(el).find(".b-slider__numbers-active");
  18.         const overallSlidesNumDiv = $(el).find(".b-slider__numbers-all");
  19.         const currentSlideDots = $(el).find(".w-slider-dot");
  20.  
  21.         currentSlideDots.attrchange({
  22.             trackValues: true,
  23.             callback: function(e){
  24.                currentSlideNumDiv.text($(el).find(".w-slider-dot.w-active").index() + 1);
  25.             }
  26.         })
  27.  
  28.         overallSlidesNumDiv.text(currentSlideDots.length)
  29.     })
  30. });
  31. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement