1(function ($, window) { 2 "use strict"; 3 4 var WooLentorBlocks = { 5 /** 6 * [init] 7 * @return {[void]} Initial Function 8 */ 9 init: function () { 10 this.TabsMenu($(".ht-tab-menus"), ".ht-tab-pane"); 11 this.TabsMenu($(".woolentor-product-video-tabs"), ".video-cus-tab-pane"); 12 if ($("[class*='woolentorblock-'] .ht-product-image-slider").length > 0) { 13 this.productImageThumbnailsSlider($(".ht-product-image-slider")); 14 } 15 this.thumbnailsimagescontroller(); 16 this.ThumbNailsTabs( 17 ".woolentor-thumbanis-image", 18 ".woolentor-advance-product-image-area" 19 ); 20 }, 21 22 /** 23 * [TabsMenu] Active first menu item 24 */ 25 TabsMenu: function ($tabmenus, $tabpane) { 26 $tabmenus.on("click", "a", function (e) { 27 e.preventDefault(); 28 var $this = $(this), 29 $target = $this.attr("href"); 30 $this 31 .addClass("htactive") 32 .parent() 33 .siblings() 34 .children("a") 35 .removeClass("htactive"); 36 $($tabpane + $target) 37 .addClass("htactive") 38 .siblings() 39 .removeClass("htactive"); 40 41 // slick refresh 42 if ($(".slick-slider").length > 0) { 43 var $id = $this.attr("href"); 44 $($id).find(".slick-slider").slick("refresh"); 45 } 46 }); 47 }, 48 49 /** 50 * 51 * @param {TabMen area selector} $tabmenu 52 * @param {Image Area} $area 53 */ 54 ThumbNailsTabs: function ($tabmenu, $area) { 55 $($tabmenu).on("click", "li", function (e) { 56 e.preventDefault(); 57 var $image = $(this).data("wlimage"); 58 if ($image) { 59 $($area) 60 .find(".woocommerce-product-gallery__image .wp-post-image") 61 .attr("src", $image); 62 $($area) 63 .find(".woocommerce-product-gallery__image .wp-post-image") 64 .attr("srcset", $image); 65 } 66 }); 67 }, 68 69 /** 70 * Slick Slider 71 */ 72 initSlickSlider: function ($block) { 73 $($block).css("display", "block"); 74 var settings = WooLentorBlocks.sanitizeObject($($block).data("settings")); 75 if (settings) { 76 var arrows = settings["arrows"]; 77 var dots = settings["dots"]; 78 var autoplay = settings["autoplay"]; 79 var rtl = settings["rtl"]; 80 var autoplay_speed = parseInt(settings["autoplay_speed"]) || 3000; 81 var animation_speed = parseInt(settings["animation_speed"]) || 300; 82 var fade = false;
83 var pause_on_hover = settings["pause_on_hover"]; 84 var display_columns = parseInt(settings["product_items"]) || 4; 85 var scroll_columns = parseInt(settings["scroll_columns"]) || 4; 86 var tablet_width = parseInt(settings["tablet_width"]) || 800; 87 var tablet_display_columns = 88 parseInt(settings["tablet_display_columns"]) || 2; 89 var tablet_scroll_columns = 90 parseInt(settings["tablet_scroll_columns"]) || 2; 91 var mobile_width = parseInt(settings["mobile_width"]) || 480; 92 var mobile_display_columns = 93 parseInt(settings["mobile_display_columns"]) || 1; 94 var mobile_scroll_columns = 95 parseInt(settings["mobile_scroll_columns"]) || 1; 96 97 $($block) 98 .not(".slick-initialized") 99 .slick({ 100 arrows: arrows, 101 prevArrow: 102 '<button type="button" class="slick-prev"><i class="fa fa-angle-left"></i></button>', 103 nextArrow: 104 '<button type="button" class="slick-next"><i class="fa fa-angle-right"></i></button>', 105 dots: dots, 106 infinite: true, 107 autoplay: autoplay, 108 autoplaySpeed: autoplay_speed, 109 speed: animation_speed, 110 fade: fade, 111 pauseOnHover: pause_on_hover, 112 slidesToShow: display_columns, 113 slidesToScroll: scroll_columns, 114 rtl: rtl, 115 responsive: [ 116 { 117 breakpoint: tablet_width, 118 settings: { 119 slidesToShow: tablet_display_columns, 120 slidesToScroll: tablet_scroll_columns, 121 }, 122 }, 123 { 124 breakpoint: mobile_width, 125 settings: { 126 slidesToShow: mobile_display_columns, 127 slidesToScroll: mobile_scroll_columns, 128 }, 129 }, 130 ], 131 }); 132 } 133 }, 134 135 /** 136 * Slick Nav For As Slider Initial 137 * @param {*} $sliderwrap 138 */ 139 initSlickNavForAsSlider: function ($sliderwrap) { 140 $($sliderwrap).find(".woolentor-learg-img").css("display", "block"); 141 $($sliderwrap).find(".woolentor-thumbnails").css("display", "block"); 142 var settings = WooLentorBlocks.sanitizeObject($($sliderwrap).data("settings")); 143 144 if (settings) { 145 $($sliderwrap) 146 .find(".woolentor-learg-img") 147 .not(".slick-initialized") 148 .slick({ 149 slidesToShow: 1, 150 slidesToScroll: 1, 151 dots: settings["mainslider"].dots, 152 arrows: settings["mainslider"].arrows, 153 fade: false, 154 asNavFor: ".woolentor-thumbnails", 155 prevArrow: 156 '<button class="woolentor-slick-large-prev"><i class="sli sli-arrow-left"></i></button>', 157 nextArrow: 158 '<button class="woolentor-slick-large-next"><i class="sli sli-arrow-right"></i></button>', 159 }); 160 $($sliderwrap) 161 .find(".woolentor-thumbnails") 162 .not(".slick-initialized") 163 .slick({ 164 slidesToShow: settings["thumbnailslider"].slider_items, 165 slidesToScroll: 1, 166 asNavFor: ".woolentor-learg-img", 167 centerMode: false, 168 dots: false, 169 arrows: settings["thumbnailslider"].arrows, 170 vertical: settings["thumbnailslider"].slidertype, 171 focusOnSelect: true, 172 prevArrow: 173 '<button class="woolentor-slick-prev"><i class="sli sli-arrow-left"></i></button>', 174 nextArrow: 175 '<button class="woolentor-slick-next"><i class="sli sli-arrow-right"></i></button>', 176 }); 177 } 178 }, 179 180 /** 181 * Accordion 182 */ 183 initAccordion: function ($block) { 184 var settings = $($block).data("settings"); 185 if ($block.length > 0) { 186 var $id = $block.attr("id"); 187 new Accordion("#" + $id, { 188 duration: 500, 189 showItem: settings.showitem, 190 elementClass: "htwoolentor-faq-card", 191 questionClass: "htwoolentor-faq-head", 192 answerClass: "htwoolentor-faq-body", 193 }); 194 } 195 }, 196 197 /** 198 * Senitize HTML 199 */ 200 sanitizeHTML: function (str) { 201 if( str ){ 202 return str.replace(/[&<>"']/g, function (c) { 203 switch (c) { 204 case '&': return '&'; 205 case '<': return '<'; 206 case '>': return '>'; 207 case '"': return '"';
208 case "'": return '''; 209 default: return c; 210 } 211 }); 212 }else{ 213 return ''; 214 } 215 }, 216 217 /** 218 * Object Sanitize 219 */ 220 sanitizeObject: function (inputObj) { 221 const sanitizedObj = {}; 222 223 for (let key in inputObj) { 224 if (inputObj.hasOwnProperty(key)) { 225 let value = inputObj[key]; 226 227 // Sanitize based on the value type 228 if (typeof value === 'string') { 229 // Sanitize strings to prevent injection 230 sanitizedObj[key] = WooLentorBlocks.sanitizeHTML(value); 231 } else if (typeof value === 'number') { 232 // Ensure numbers are valid (you could also set limits if needed) 233 sanitizedObj[key] = Number.isFinite(value) ? value : 0; 234 } else if (typeof value === 'boolean') { 235 // Keep boolean values as they are 236 sanitizedObj[key] = value; 237 } else { 238 // Handle other types if needed (e.g., arrays, objects) 239 sanitizedObj[key] = value; 240 } 241 } 242 } 243 244 return sanitizedObj; 245 }, 246 247 /* 248 * Tool Tip 249 */ 250 woolentorToolTips: function (element, content) { 251 if (content == "html") { 252 var tipText = element.text(); 253 } else { 254 var tipText = element.attr("title"); 255 } 256 element.on("mouseover", function () { 257 if ($(".woolentor-tip").length == 0) { 258 element.before('<span class="woolentor-tip">' + WooLentorBlocks.sanitizeHTML(tipText) + "</span>"); 259 $(".woolentor-tip").css("transition", "all 0.5s ease 0s"); 260 $(".woolentor-tip").css("margin-left", 0); 261 } 262 }); 263 element.on("mouseleave", function () { 264 $(".woolentor-tip").remove(); 265 }); 266 }, 267 268 woolentorToolTipHandler: function () { 269 $("a.woolentor-compare").each(function () { 270 WooLentorBlocks.woolentorToolTips($(this), "title"); 271 }); 272 $( 273 ".woolentor-cart a.add_to_cart_button,.woolentor-cart a.added_to_cart,.woolentor-cart a.button" 274 ).each(function () { 275 WooLentorBlocks.woolentorToolTips($(this), "html"); 276 }); 277 }, 278 279 /* 280 * Universal product 281 */ 282 productImageThumbnailsSlider: function ($slider) { 283 $slider.slick({ 284 dots: true, 285 arrows: true, 286 prevArrow: 287 '<button class="slick-prev"><i class="sli sli-arrow-left"></i></button>', 288 nextArrow: 289 '<button class="slick-next"><i class="sli sli-arrow-right"></i></button>', 290 }); 291 }, 292 293 thumbnailsimagescontroller: function () { 294 this.TabsMenu($(".ht-product-cus-tab-links"), ".ht-product-cus-tab-pane"); 295 this.TabsMenu($(".ht-tab-menus"), ".ht-tab-pane"); 296 297 // Countdown 298 $(".ht-product-countdown").each(function () { 299 var $this = $(this), 300 finalDate = $(this).data("countdown"); 301 var customlavel = $(this).data("customlavel"); 302 $this.countdown(finalDate, function (event) { 303 $this.html( 304 event.strftime( 305 '<div class="cd-single"><div class="cd-single-inner"><h3>%D</h3><p>' + 306 WooLentorBlocks.sanitizeHTML(customlavel.daytxt) + 307 '</p></div></div><div class="cd-single"><div class="cd-single-inner"><h3>%H</h3><p>' + 308 WooLentorBlocks.sanitizeHTML(customlavel.hourtxt) + 309 '</p></div></div><div class="cd-single"><div class="cd-single-inner"><h3>%M</h3><p>' + 310 WooLentorBlocks.sanitizeHTML(customlavel.minutestxt) + 311 '</p></div></div><div class="cd-single"><div class="cd-single-inner"><h3>%S</h3><p>' + 312 WooLentorBlocks.sanitizeHTML(customlavel.secondstxt) + 313 "</p></div></div>" 314 ) 315 ); 316 }); 317 }); 318 }, 319 320 /** 321 * Single Product Quantity Increase/decrease manager 322 */ 323 quantityIncreaseDescrease: function ($area) { 324 $area 325 .find("form.cart") 326 .on( 327 "click", 328 "span.wl-qunatity-plus, span.wl-qunatity-minus", 329 function () { 330 const poductType = $area.data("producttype"); 331 // Get current quantity values 332 if ("grouped" != poductType) { 333 var qty = $(this).closest("form.cart").find(".qty:visible"); 334 var val = parseFloat(qty.val()); 335 var min_val = 1; 336 } else { 337 var qty = $(this) 338 .closest(".wl-quantity-grouped-cal") 339 .find(".qty:visible"); 340 var val = !qty.val() ? 0 : parseFloat(qty.val()); 341 var min_val = 0; 342 } 343 344 var max = parseFloat(qty.attr("max")); 345 var min = parseFloat(qty.attr("min")); 346 var step = parseFloat(qty.attr("step")); 347 348 // Change the value if plus or minus 349 if ($(this).is(".wl-qunatity-plus")) { 350 if (max && max <= val) { 351 qty.val(max); 352 } else { 353 qty.val(val + step); 354 } 355 } else { 356 if (min && min >= val) { 357 qty.val(min); 358 } else if (val > min_val) { 359 qty.val(val - step); 360 } 361 } 362 } 363 ); 364 }, 365 366 CartTableHandler: function () { 367 // Product Details Slide Toggle 368 $('body').on("click", '.woolentor-cart-product-details-toggle', function (e) { 369 e.preventDefault(); 370 371 const $target = $(this).data('target'); 372 373 if($(`[data-id="${$target}"]`).is(':hidden')) { 374 $(`[data-id="${$target}"]`).slideDown(); 375 } else { 376 $(`[data-id="${$target}"]`).slideUp(); 377 } 378 }); 379 } 380 }; 381 382 $(document).ready(function () { 383 WooLentorBlocks.init(); 384 WooLentorBlocks.CartTableHandler(); 385 386 $("[class*='woolentorblock-'] .product-slider").each(function () { 387 WooLentorBlocks.initSlickSlider($(this)); 388 }); 389 390 $("[class*='woolentorblock-'].woolentor-block-slider-navforas").each( 391 function () { 392 WooLentorBlocks.initSlickNavForAsSlider($(this)); 393 } 394 ); 395 396 $("[class*='woolentorblock-'] .htwoolentor-faq").each(function () { 397 WooLentorBlocks.initAccordion($(this)); 398 }); 399 400 $("[class*='woolentorblock-'].woolentor-product-addtocart").each( 401 function () {
402 WooLentorBlocks.quantityIncreaseDescrease($(this)); 403 } 404 ); 405 406 /** 407 * Tooltip Manager 408 */ 409 WooLentorBlocks.woolentorToolTipHandler(); 410 }); 411 412 // For Editor Mode Slider 413 document.addEventListener( 414 "WoolentorEditorModeSlick", 415 function (event) { 416 let editorMainArea = $(".block-editor__container"), 417 editorIframe = $("iframe.edit-site-visual-editor__editor-canvas"), 418 productSliderDiv = 419 editorIframe.length > 0 420 ? editorIframe 421 .contents() 422 .find("body.block-editor-iframe__body") 423 .find( 424 `.woolentorblock-editor-${event.detail.uniqid} .product-slider` 425 ) 426 : editorMainArea.find( 427 `.woolentorblock-editor-${event.detail.uniqid} .product-slider` 428 ); 429 window.setTimeout( 430 WooLentorBlocks.initSlickSlider(productSliderDiv), 431 1000 432 ); 433 }, 434 false 435 ); 436 437 // For Editor Mode Nav For As Slider 438 document.addEventListener( 439 "WoolentorEditorModeNavForSlick", 440 function (event) { 441 let editorMainArea = $(".block-editor__container"), 442 editorIframe = $("iframe.edit-site-visual-editor__editor-canvas"), 443 navForAsSliderDiv = 444 editorIframe.length > 0 445 ? editorIframe 446 .contents() 447 .find("body.block-editor-iframe__body") 448 .find( 449 `.woolentorblock-editor-${event.detail.uniqid} .woolentor-block-slider-navforas` 450 ) 451 : editorMainArea.find( 452 `.woolentorblock-editor-${event.detail.uniqid} .woolentor-block-slider-navforas` 453 ); 454 window.setTimeout( 455 WooLentorBlocks.initSlickNavForAsSlider(navForAsSliderDiv), 456 1000 457 ); 458 }, 459 false 460 ); 461})(jQuery, window);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.