1( function( $, elementor ) { 2 3 "use strict"; 4 5 var JetWidgets = { 6 7 init: function() { 8 9 var widgets = { 10 'jw-carousel.default' : JetWidgets.widgetCarousel, 11 'jw-posts.default' : JetWidgets.widgetPosts, 12 'jw-animated-box.default' : JetWidgets.widgetAnimatedBox, 13 'jw-images-layout.default' : JetWidgets.widgetImagesLayout, 14 'jw-testimonials.default' : JetWidgets.widgetTestimonials, 15 'jw-image-comparison.default' : JetWidgets.widgetImageComparison, 16 'jw-subscribe-form.default' : JetWidgets.widgetSubscribeForm 17 }; 18 19 $.each( widgets, function( widget, callback ) { 20 elementor.hooks.addAction( 'frontend/element_ready/' + widget, callback ); 21 }); 22 }, 23 24 widgetCarousel: function( $scope ) { 25 26 var $carousel = $scope.find( '.jw-carousel' ); 27 28 if ( ! $carousel.length ) { 29 return; 30 } 31 32 JetWidgets.initCarousel( $carousel, $carousel.data( 'slider_options' ) ); 33 34 }, 35 36 widgetPosts: function ( $scope ) { 37 38 var $target = $scope.find( '.jw-carousel' ); 39 40 if ( ! $target.length ) { 41 return; 42 } 43 44 JetWidgets.initCarousel( $target.find( '.jw-posts' ), $target.data( 'slider_options' ) ); 45 46 }, 47 48 widgetAnimatedBox: function( $scope ) { 49 50 JetWidgets.onAnimatedBoxSectionActivated( $scope ); 51 52 var $target = $scope.find( '.jw-animated-box' ), 53 toogleEvents = 'mouseenter mouseleave', 54 scrollOffset = $( window ).scrollTop(); 55 56 if ( ! $target.length ) { 57 return; 58 } 59 60 if ( 'ontouchend' in window || 'ontouchstart' in window ) { 61 $target.on( 'touchstart', function( event ) { 62 scrollOffset = $( window ).scrollTop(); 63 } ); 64 65 $target.on( 'touchend', function( event ) { 66 67 if ( scrollOffset !== $( window ).scrollTop() ) { 68 return false; 69 } 70 71 if ( ! $( this ).hasClass( 'flipped-stop' ) ) { 72 $( this ).toggleClass( 'flipped' ); 73 } 74 } ); 75 76 } else { 77 $target.on( toogleEvents, function( event ) { 78 if ( ! $( this ).hasClass( 'flipped-stop' ) ) { 79 $( this ).toggleClass( 'flipped' ); 80 } 81 } ); 82 } 83 }, 84 85 onAnimatedBoxSectionActivated: function( $scope ) { 86 if ( ! window.elementor ) { 87 return; 88 } 89 90 if ( ! window.JetWidgetsEditor ) { 91 return; 92 } 93 94 if ( ! window.JetWidgetsEditor.activeSection ) { 95 return; 96 } 97 98 var section = window.JetWidgetsEditor.activeSection; 99 var isBackSide = -1 !== [ 'section_action_button_style' ].indexOf( section ); 100 101 if ( isBackSide ) { 102 $scope.find( '.jw-animated-box' ).addClass( 'flipped' ); 103 $scope.find( '.jw-animated-box' ).addClass( 'flipped-stop' ); 104 } else { 105 $scope.find( '.jw-animated-box' ).removeClass( 'flipped' ); 106 $scope.find( '.jw-animated-box' ).removeClass( 'flipped-stop' ); 107 } 108 }, 109 110 widgetImagesLayout: function( $scope ) { 111 var $target = $scope.find( '.jw-images-layout' ), 112 instance = null, 113 settings = {}; 114 115 if ( ! $target.length ) { 116 return; 117 } 118 119 settings = $target.data( 'settings' ); 120 instance = new jwImagesLayout( $target, settings ); 121 instance.init(); 122 }, 123 124 widgetSubscribeForm: function( $scope ) { 125 var $target = $scope.find( '.jw-subscribe-form' ), 126 scoreId = $scope.data( 'id' ), 127 settings = $target.data( 'settings' ), 128 jetSubscribeFormAjax = null, 129 subscribeFormAjaxId = 'jw_subscribe_form_ajax', 130 $subscribeForm = $( '.jw-subscribe-form__form', $target ), 131 $input = $( '.jw-subscribe-form__input', $target ), 132 $inputData = $input.data( 'instance-data' ), 133 $submitButton = $( '.jw-subscribe-form__submit', $target ), 134 $subscribeFormMessage = $( '.jw-subscribe-form__message', $target ), 135 timeout = null, 136 invalidMailMessage = window.jetWidgets.messages.invalidMail || 'Please specify a valid email'; 137 138 jetSubscribeFormAjax = new CherryJsCore.CherryAjaxHandler({ 139 handlerId: subscribeFormAjaxId, 140 141 successCallback: function( data ) { 142 var successType = data.type, 143 message = data.message || '', 144 responceClass = 'jw-subscribe-form--response-' + successType; 145 146 $submitButton.removeClass( 'loading' ); 147 148 $target.removeClass( 'jw-subscribe-form--response-error' ); 149 $target.addClass( responceClass ); 150 151 $( 'span', $subscribeFormMessage ).html( message ); 152 $subscribeFormMessage.css( { 'visibility': 'visible' } ); 153 154 timeout = setTimeout( function() { 155 $subscribeFormMessage.css( { 'visibility': 'hidden' } ); 156 $target.removeClass( responceClass ); 157 }, 20000 ); 158 159 if ( settings['redirect'] ) { 160 window.location.href = settings['redirect_url']; 161 } 162 163 $( window ).trigger( { 164 type: 'jet-widgets/subscribe', 165 elementId: scoreId, 166 successType: successType, 167 inputData: $inputData 168 } ); 169 } 170 }); 171 172 $input.on( 'focus', function() { 173 $input.removeClass( 'mail-invalid' ); 174 } ); 175 176 $( document ).keydown( function( event ) { 177 178 if ( 13 === event.keyCode && $input.is( ':focus' ) ) { 179 subscribeHandle(); 180 181 return false;
182 } 183 } ); 184 185 $submitButton.on( 'click', function() { 186 subscribeHandle(); 187 188 return false; 189 } ); 190 191 function subscribeHandle() { 192 var inputValue = $input.val(); 193 194 if ( JetWidgetsTools.validateEmail( inputValue ) ) { 195 jetSubscribeFormAjax.sendData( 196 { 197 'mail': inputValue, 198 'data': $inputData 199 } 200 ); 201 $submitButton.addClass( 'loading' ); 202 } else { 203 $input.addClass( 'mail-invalid' ); 204 205 $target.addClass( 'jw-subscribe-form--response-error' ); 206 $( 'span', $subscribeFormMessage ).html( invalidMailMessage ); 207 $subscribeFormMessage.css( { 'visibility': 'visible' } ); 208 209 timeout = setTimeout( function() { 210 $target.removeClass( 'jw-subscribe-form--response-error' ); 211 $subscribeFormMessage.css( { 'visibility': 'hidden' } ); 212 $input.removeClass( 'mail-invalid' ); 213 }, 20000 ); 214 } 215 } 216 }, 217 218 widgetTestimonials: function( $scope ) { 219 var $target = $scope.find( '.jw-testimonials__instance' ), 220 $imagesTagList = $( '.jw-testimonials__figure', $target ), 221 instance = null, 222 settings = $target.data( 'settings' ); 223 224 if ( ! $target.length ) { 225 return; 226 } 227 228 settings.adaptiveHeight = settings['adaptiveHeight']; 229 230 JetWidgets.initCarousel( $target, settings ); 231 }, 232 233 widgetImageComparison: function( $scope ) { 234 var $target = $scope.find( '.jw-image-comparison__instance' ), 235 instance = null, 236 imageComparisonItems = $( '.jw-image-comparison__container', $target ), 237 settings = $target.data( 'settings' ), 238 elementId = $scope.data( 'id' ); 239 240 if ( ! $target.length ) { 241 return; 242 } 243 244 settings.draggable = false; 245 246 $target.on( 'init', function( event, slick ){ 247 window.juxtapose.scanPage( '.jw-juxtapose' ); 248 } ); 249 250 JetWidgets.initCarousel( $target, settings ); 251 }, 252 253 initCarousel: function( $target, options ) { 254 255 var defaultOptions, 256 slickOptions, 257 responsive = [], 258 eTarget = $target.closest( '.elementor-widget' ), 259 breakpoints = JetWidgetsTools.getElementorElementSettings( eTarget ), 260 activeBreakpoints = elementor.config.responsive.activeBreakpoints, 261 prevDeviceValue, 262 slidesCount, 263 dotsEnable = options.dots; 264 265 if ( $target.hasClass( 'jw-posts' ) && $target.parent().hasClass( 'jw-carousel' ) ) { 266 function renameKeys( obj, newKeys ) { 267 const keyValues = Object.keys( obj ).map( key => { 268 const newKey = newKeys[key] || key; 269 return { [newKey]: obj[key] }; 270 } ); 271 return Object.assign( {}, ...keyValues ); 272 } 273 274 var newBreakpointsKeys = { 275 columns: "slides_to_show", 276 columns_widescreen: "slides_to_show_widescreen", 277 columns_laptop: "slides_to_show_laptop", 278 columns_tablet_extra: "slides_to_show_tablet_extra", 279 columns_tablet: "slides_to_show_tablet", 280 columns_mobile_extra: "slides_to_show_mobile_extra", 281 columns_mobile: "slides_to_show_mobile" 282 }; 283 284 breakpoints = renameKeys( breakpoints, newBreakpointsKeys ); 285 } 286 287 options.slidesToShow = +breakpoints.slides_to_show; 288 289 Object.keys( activeBreakpoints ).forEach( function( breakpointName ) { 290 if ( 'widescreen' === breakpointName ) { 291 return options.slidesToShow = breakpoints.slides_to_show_widescreen ? +breakpoints.slides_to_show_widescreen : +breakpoints.slides_to_show; 292 } 293 } ); 294 295 slidesCount = $( '> div', $target ).length; 296 297 if ( options.slidesToShow >= slidesCount ) { 298 options.dots = false; 299 } 300 301 prevDeviceValue = options.slidesToShow; 302 303 Object.keys( activeBreakpoints ).reverse().forEach( function( breakpointName ) { 304 305 var breakpointSetting = { 306 breakpoint: null, 307 settings: {} 308 } 309 310 breakpointSetting.breakpoint = 'widescreen' != breakpointName ? activeBreakpoints[breakpointName].value : activeBreakpoints[breakpointName].value - 1; 311 312 if ( 'widescreen' === breakpointName ) { 313 breakpointSetting.settings.slidesToShow = +breakpoints['slides_to_show']; 314 } else { 315 breakpointSetting.settings.slidesToShow = breakpoints['slides_to_show_' + breakpointName] ? +breakpoints['slides_to_show_' + breakpointName] : prevDeviceValue; 316 } 317 318 $target.on( 'init reInit', function(event, slick, currentSlide, nextSlide ){ 319 if ( breakpointSetting.settings.slidesToShow >= slick.slideCount ) { 320 breakpointSetting.settings.dots = false;
321 } else { 322 if ( dotsEnable ) { 323 breakpointSetting.settings.dots = true; 324 } 325 } 326 } ); 327 328 prevDeviceValue = breakpointSetting.settings.slidesToShow; 329 330 responsive.push( breakpointSetting ); 331 } ); 332 333 options.responsive = responsive; 334 335 defaultOptions = { 336 customPaging: function(slider, i) { 337 return $( '<span />' ).text( i + 1 ); 338 }, 339 dotsClass: 'jw-slick-dots', 340 }; 341 342 slickOptions = $.extend( {}, defaultOptions, options ); 343 344 $target.slick( slickOptions ); 345 }, 346 }; 347 348 $( window ).on( 'elementor/frontend/init', JetWidgets.init ); 349 350 var JetWidgetsTools = { 351 debounce: function( threshold, callback ) { 352 var timeout; 353 354 return function debounced( $event ) { 355 function delayed() { 356 callback.call( this, $event ); 357 timeout = null; 358 } 359 360 if ( timeout ) { 361 clearTimeout( timeout ); 362 } 363 364 timeout = setTimeout( delayed, threshold ); 365 }; 366 }, 367 368 getObjectNextKey: function( object, key ) { 369 var keys = Object.keys( object ), 370 idIndex = keys.indexOf( key ), 371 nextIndex = idIndex += 1; 372 373 if( nextIndex >= keys.length ) { 374 //we're at the end, there is no next 375 return false; 376 } 377 378 var nextKey = keys[ nextIndex ]; 379 380 return nextKey; 381 }, 382 383 getObjectPrevKey: function( object, key ) { 384 var keys = Object.keys( object ), 385 idIndex = keys.indexOf( key ), 386 prevIndex = idIndex -= 1; 387 388 if ( 0 > idIndex ) { 389 //we're at the end, there is no next 390 return false; 391 } 392 393 var prevKey = keys[ prevIndex ]; 394 395 return prevKey; 396 }, 397 398 getObjectFirstKey: function( object ) { 399 return Object.keys( object )[0]; 400 }, 401 402 getObjectLastKey: function( object ) { 403 return Object.keys( object )[ Object.keys( object ).length - 1 ]; 404 }, 405 406 validateEmail: function( email ) { 407 var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; 408 409 return re.test( email ); 410 }, 411 412 getElementorElementSettings: function( $scope ) { 413 414 if ( window.elementorFrontend && window.elementorFrontend.isEditMode() ) { 415 return JetWidgetsTools.getEditorElementSettings( $scope ); 416 } 417 418 return $scope.data( 'settings' ) || {}; 419 }, 420 421 getEditorElementSettings: function( $scope ) { 422 var modelCID = $scope.data( 'model-cid' ), 423 elementData; 424 425 if ( ! modelCID ) { 426 return {}; 427 } 428 429 if ( ! elementor.hasOwnProperty( 'config' ) ) { 430 return {}; 431 } 432 433 if ( ! elementor.config.hasOwnProperty( 'elements' ) ) { 434 return {}; 435 } 436 437 if ( ! elementor.config.elements.hasOwnProperty( 'data' ) ) { 438 return {}; 439 } 440 441 elementData = elementor.config.elements.data[ modelCID ]; 442 443 if ( ! elementData ) { 444 return {}; 445 } 446 447 return elementData.toJSON(); 448 } 449 } 450 451 /** 452 * Jet Images Layout Class 453 * 454 * @return {void} 455 */ 456 window.jwImagesLayout = function( $selector, settings ) { 457 var self = this, 458 $instance = $selector, 459 $instanceList = $( '.jw-images-layout__list', $instance ), 460 $itemsList = $( '.jw-images-layout__item', $instance ), 461 defaultSettings = {}, 462 settings = settings || {}; 463 464 /* 465 * Default Settings 466 */ 467 defaultSettings = { 468 layoutType: 'masonry', 469 justifyHeight: 300 470 } 471 472 /** 473 * Checking options, settings and options merging 474 */ 475 $.extend( defaultSettings, settings ); 476 477 /** 478 * Layout build 479 */ 480 self.layoutBuild = function() { 481 switch ( settings['layoutType'] ) { 482 case 'masonry': 483 salvattore.init(); 484 485 $(window).on( 'resize orientationchange', function() { 486 salvattore.rescanMediaQueries(); 487 } ); 488 break; 489 case 'justify': 490 $itemsList.each( function() { 491 var $this = $( this ), 492 $imageInstance = $( '.jw-images-layout__image-instance', $this), 493 imageWidth = $imageInstance.data( 'width' ), 494 imageHeight = $imageInstance.data( 'height' ), 495 imageRatio = +imageWidth / +imageHeight, 496 flexValue = imageRatio * 100, 497 newWidth = +settings['justifyHeight'] * imageRatio, 498 newHeight = 'auto'; 499 500 $this.css( { 501 'flex-grow': flexValue, 502 'flex-basis': newWidth 503 } ); 504 } ); 505 break; 506 } 507 508 $( '.jw-images-layout__image', $itemsList ).imagesLoaded().progress( function( instance, image ) { 509 var $image = $( image.img ), 510 $parentItem = $image.closest( '.jw-images-layout__item' ), 511 $loader = $( '.jw-images-layout__image-loader', $parentItem ); 512 513 $parentItem.addClass( 'image-loaded' ); 514 515 $loader.fadeTo( 500, 0, function() { 516 $( this ).remove(); 517 } ); 518 519 }); 520 } 521 522 /** 523 * Init 524 */ 525 self.init = function() { 526 self.layoutBuild(); 527 } 528 } 529 530}( jQuery, window.elementorFrontend ) );
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.