1if (typeof(WEB_URL) == 'undefined') { 2 if (typeof(BASE_URL) !== 'undefined') { 3 var WEB_URL_AJAX = BASE_URL; 4 }else{ 5 pubUrlAjax = require.s.contexts._.config.baseUrl; 6 arrUrlAjax = pubUrlAjax.split('pub/'); 7 var WEB_URL_AJAX = arrUrlAjax[0]; 8 } 9} 10 11require([ 12 'jquery', 13 'waypoints', 14 'mgslightbox' 15], function(jQuery){ 16 (function($) { 17 $.fn.appear = function(fn, options) { 18 19 var settings = $.extend({ 20 21 //arbitrary data to pass to fn 22 data: undefined, 23 24 //call fn only on the first appear? 25 one: true, 26 27 // X & Y accuracy 28 accX: 0, 29 accY: 0 30 31 }, options); 32 33 return this.each(function() { 34 35 var t = $(this); 36 37 //whether the element is currently visible 38 t.appeared = false; 39 40 if (!fn) { 41 42 //trigger the custom event 43 t.trigger('appear', settings.data); 44 return; 45 } 46 47 var w = $(window); 48 49 //fires the appear event when appropriate 50 var check = function() { 51 52 //is the element hidden? 53 if (!t.is(':visible')) { 54 55 //it became hidden 56 t.appeared = false; 57 return; 58 } 59 60 //is the element inside the visible window? 61 var a = w.scrollLeft(); 62 var b = w.scrollTop(); 63 var o = t.offset(); 64 var x = o.left; 65 var y = o.top; 66 67 var ax = settings.accX; 68 var ay = settings.accY; 69 var th = t.height(); 70 var wh = w.height(); 71 var tw = t.width(); 72 var ww = w.width(); 73 74 if (y + th + ay >= b && 75 y <= b + wh + ay && 76 x + tw + ax >= a && 77 x <= a + ww + ax) { 78 79 //trigger the custom event 80 if (!t.appeared) t.trigger('appear', settings.data); 81 82 } else { 83 84 //it scrolled out of view 85 t.appeared = false; 86 } 87 }; 88 89 //create a modified fn with some additional logic 90 var modifiedFn = function() { 91 92 //mark the element as visible 93 t.appeared = true; 94 95 //is this supposed to happen only once? 96 if (settings.one) { 97 98 //remove the check 99 w.unbind('scroll', check); 100 var i = $.inArray(check, $.fn.appear.checks); 101 if (i >= 0) $.fn.appear.checks.splice(i, 1); 102 } 103 104 //trigger the original fn 105 fn.apply(this, arguments); 106 }; 107 108 //bind the modified fn to the element 109 if (settings.one) t.one('appear', settings.data, modifiedFn); 110 else t.bind('appear', settings.data, modifiedFn); 111 112 //check whenever the window scrolls 113 w.scroll(check); 114 115 //check whenever the dom changes 116 $.fn.appear.checks.push(check); 117 118 //check now 119 (check)(); 120 }); 121 }; 122 123 //keep a queue of appearance checks 124 $.extend($.fn.appear, { 125 126 checks: [], 127 timeout: null, 128 129 //process the queue 130 checkAll: function() { 131 var length = $.fn.appear.checks.length; 132 if (length > 0) while (length--) ($.fn.appear.checks[length])(); 133 }, 134 135 //check the queue asynchronously 136 run: function() { 137 if ($.fn.appear.timeout) clearTimeout($.fn.appear.timeout); 138 $.fn.appear.timeout = setTimeout($.fn.appear.checkAll, 20); 139 } 140 }); 141 142 //run checks when these methods are called 143 $.each(['append', 'prepend', 'after', 'before', 'attr', 144 'removeAttr', 'addClass', 'removeClass', 'toggleClass', 145 'remove', 'css', 'show', 'hide'], function(i, n) { 146 var old = $.fn[n]; 147 if (old) { 148 $.fn[n] = function() { 149 var r = old.apply(this, arguments); 150 $.fn.appear.run(); 151 return r; 152 } 153 } 154 }); 155 156 $(document).ready(function(){ 157 $("[data-appear-animation]").each(function() { 158 $(this).addClass("appear-animation"); 159 if($(window).width() > 767) { 160 $(this).appear(function() { 161 162 var delay = ($(this).attr("data-appear-animation-delay") ? $(this).attr("data-appear-animation-delay") : 1); 163 164 if(delay > 1) $(this).css("animation-delay", delay + "ms"); 165 $(this).addClass($(this).attr("data-appear-animation")); 166 $(this).addClass("animated"); 167 168 setTimeout(function() { 169 $(this).addClass("appear-animation-visible"); 170 }, delay); 171 172 }, {accX: 0, accY: -150}); 173 } else { 174 $(this).addClass("appear-animation-visible"); 175 } 176 }); 177 178 /* Progress Bar */ 179 $('.mgs-progressbar .progress').css("width", 180 function() { 181 return $(this).attr("aria-valuenow") + "%"; 182 } 183 ) 184 185 /* Progress Circle */ 186 $('.mgs-progress-circle').each(function(){ 187 var progressPercent = $(this).attr('progress-to'); 188 $(this).attr('data-progress', progressPercent); 189 }); 190 191 $('.tab-title-ajax').each(function(){ 192 $(this).find('a').trigger('click'); 193 }); 194 195 }); 196 197 198 })(jQuery); 199}); 200 201function setLocation(url) { 202 require([
203 'jquery' 204 ], function (jQuery) { 205 (function () { 206 window.location.href = url; 207 })(jQuery); 208 }); 209} 210 211require([ 212 'jquery', 213 'Magento_Ui/js/modal/modal' 214], function( $, modal ) { 215 $(document).ready(function(){ 216 $('button.mgs-modal-popup-button').on( 'click', 217 function(){ 218 id = $(this).attr('data-button-id'); 219 var popupContent = $('#mgs_modal_container_'+id).html(); 220 if ($('#modal_popup_'+id).length) { 221 var options = { 222 type: 'popup', 223 responsive: true, 224 innerScroll: true, 225 title: '', 226 modalClass: 'mgs-modal modal-'+id, 227 buttons: [] 228 }; 229 var newsletterPopup = modal(options, $('#modal_popup_'+id)); 230 $('#modal_popup_'+id).trigger('openModal'); 231 232 $('.modal-'+id+' .pop-sletter-title').insertBefore('.modal-'+id+' .modal-header button'); 233 $('.modal-'+id+' .action-close').on('click', function(){ 234 $('.modal-'+id+' .modal-header .pop-sletter-title').remove(); 235 setTimeout(function(){ $('.modals-wrapper .modal-'+id).remove(); $('#mgs_modal_container_'+id).html(popupContent) }, 500); 236 }); 237 } 238 } 239 ); 240 }); 241}); 242 243function getAjaxProductCollection(catId, attribute, blockType, productNum, blockId, useSlider, perrowDefault, perrowTablet, perrowMobile, numberRow, slideBy, hideName, hideReview, hidePrice, hideAddcart, hideAddwishlist, hideAddcompare, autoPlay, stopAuto, nav, dot, isLoop, hideNav, navTop, navPos, pagPos, isRtl, slideMargin, activeCatLink, CatLink){ 244 require([ 245 "jquery", 246 "mLazysizes", 247 ], function($){ 248 if(catId!=''){ 249 var $contentContainer = $('#'+catId.toString() + blockId.toString()); 250 }else{ 251 var $contentContainer = $('#'+attribute.toString() + blockId.toString()); 252 } 253 var tabContent = $contentContainer.html(); 254 if(tabContent.trim() == ''){ 255 $contentContainer.addClass('div-loading'); 256 var requestUrl = WEB_URL_AJAX+'fbuilder/index/ajax'; 257 $.ajax({ 258 url: requestUrl, 259 data:{ 260 category_id: catId, 261 attribute_type: attribute, 262 block_type: blockType, 263 limit: productNum, 264 block_id: blockId, 265 use_slider: useSlider, 266 perrow: perrowDefault, 267 perrow_tablet: perrowTablet, 268 perrow_mobile: perrowMobile, 269 number_row: numberRow, 270 slide_by: slideBy, 271 hide_name:hideName, 272 hide_review:hideReview, 273 hide_price:hidePrice, 274 hide_addcart:hideAddcart, 275 hide_addwishlist:hideAddwishlist, 276 hide_addcompare:hideAddcompare, 277 autoplay: autoPlay, 278 stop_auto: stopAuto, 279 navigation: nav, 280 pagination: dot, 281 loop: isLoop, 282 hide_nav: hideNav, 283 nav_top: navTop, 284 navigation_position: navPos, 285 pagination_position: pagPos, 286 rtl: isRtl, 287 slide_margin: slideMargin, 288 use_catlink: activeCatLink, 289 cat_link: CatLink 290 }, 291 success: function(data) { 292 if(data!=''){ 293 $contentContainer.append(data); 294 $contentContainer.removeClass('div-loading'); 295 296 includeQuickviewAction($); 297 298 $('button.tocart').on('click', function(event){ 299 event.preventDefault(); 300 var formEl = $(this).parents('form:first'); 301 302 var data = formEl.serializeArray(); 303 var formData = new FormData(); 304 for(var i = 0; i < data.length; i++){ 305 formData.append(data[i].name, data[i].value); 306 } 307 formData.append('action_url', formEl.attr('action')); 308 initAjaxAddToCart(formEl, 'catalog-add-to-cart-' + $.now(), formEl.attr('action'), formData); 309 }); 310 } 311 } 312 }); 313 } 314 } 315 ); 316} 317 318function initAjaxAddToCart(tag, actionId, url, formData){ 319 require([ 320 'jquery', 321 'MGS_AjaxCart/js/config', 322 'Magento_Ui/js/modal/modal' 323 ],function($, mgsConfig, modal){ 324 var self = this; 325 /* Loading Effect */ 326 if(tag.closest('.product-top').length){ 327 // tag.closest('.product-top').addClass('loading-ajax'); 328 tag.find('.tocart > span').text('Adding...'); 329 }else { 330 if(tag.find('.tocart').length){ 331 tag.find('.tocart > span').text('Adding...'); 332 }else{ 333 tag.find('.tocart > span').text('Adding...'); 334 } 335 } 336 /*========================*/ 337 338 formData.append(mgsConfig.requestParamName, 1); 339 formData.append('ajax', 1); 340 341 jQuery.ajax({ 342 url: url, 343 data: formData, 344 type: 'post', 345 dataType: 'json', 346 contentType: false, 347 cache: false, 348 processData:false, 349 beforeSend: function(xhr, options) { 350 if(tag.find('.tocart').length){ 351 tag.find('.tocart').addClass('disabled'); 352 }else{ 353 tag.addClass('disabled'); 354 } 355 }, 356 success: function(response, status) {
357 /* Remove Loading Effect */ 358 if(tag.closest('.product-top').length){ 359 tag.find('.tocart > span').text('Add to cart'); 360 } 361 if(tag.find('.tocart').length){ 362 tag.find('.tocart > span').text('Add to cart'); 363 tag.find('.tocart').removeClass('disabled'); 364 }else{ 365 tag.find('.tocart > span').text('Add to cart'); 366 tag.removeClass('disabled'); 367 } 368 /*========================*/ 369 370 if (status == 'success') { 371 if(response.backUrl){ 372 formData.append('action_url', response.backUrl); 373 initAjaxAddToCart(tag, actionId, response.backUrl, formData); 374 }else{ 375 if (response.ui) { 376 if(response.productView){ 377 $('#ajaxcart_loading_overlay').addClass('loading'); 378 /* Add to cart false - Show popup options */ 379 if($('body.catalog-product-view').length > 0){ 380 $('body').addClass('origin-catalog-product-view'); 381 }else { 382 $('body').addClass('catalog-product-view'); 383 } 384 $.ajax({ 385 url: response.ui, 386 dataType: 'json', 387 success: function (result) { 388 $('#ajaxcart_loading_overlay').removeClass('loading'); 389 if (result.product_detail) { 390 $('body').append('<div id="ajaxcart_form_popup'+result.id_product+'" class="product_quickview_content"></div>'); 391 var options = 392 { 393 type: 'popup', 394 modalClass: "ajaxCartForm viewBox", 395 responsive: true, 396 innerScroll: true, 397 title: false,
398 buttons: false 399 }; 400 401 var popup = modal(options, $('#ajaxcart_form_popup'+result.id_product)); 402 $('#ajaxcart_form_popup'+result.id_product).html(result.product_detail); 403 $('#ajaxcart_form_popup'+result.id_product).trigger('contentUpdated'); 404 $('#ajaxcart_form_popup'+result.id_product).modal('openModal').on('modalclosed', function() { 405 $('#ajaxcart_form_popup'+result.id_product).parents('.ajaxCartForm').remove(); 406 $('body:not(.origin-catalog-product-view)').removeClass('catalog-product-view'); 407 }); 408 } 409 } 410 }); 411 }else{ 412 /* After Add to cart success */ 413 if(response.animationType == 'popup') { 414 /* Success Cart Popup */ 415 $('body').append('<div id="popup_ajaxcart_success" class="popup__main popup--result"></div>'); 416 417 var options = 418 { 419 type: 'popup', 420 modalClass: "success-ajax--popup viewBox", 421 responsive: true, 422 innerScroll: true, 423 title: false,
424 buttons: false 425 }; 426 427 var popup = modal(options, $('#popup_ajaxcart_success')); 428 $('#popup_ajaxcart_success').html(response.ui + response.related); 429 $('#popup_ajaxcart_success').trigger('contentUpdated'); 430 $('#popup_ajaxcart_success').modal('openModal').on('modalclosed', function() { 431 $('#popup_ajaxcart_success').parents('.success-ajax--popup').remove(); 432 }); 433 }else if(response.animationType == 'flycart'){ 434 /* Success Cart Fly */ 435 var $source = ''; 436 if(tag.find('.tocart').length){ 437 if(tag.closest('.product-item-info').length){ 438 $source = tag.closest('.product-item-info'); 439 }else{ 440 $source = tag.find('.tocart'); 441 } 442 }else{ 443 tag.removeClass('disabled'); 444 $source = tag.closest('.product-item-info'); 445 } 446 447 var $animatedObject = jQuery('<div class="flycart-animated-add" style="position: absolute;z-index: 99999;">'+response.image+'</div>'); 448 449 var $_left = $source.offset().left - 1; 450 var $_top = $source.offset().top - 1; 451 452 $animatedObject.css({top: $_top, left: $_left}); 453 jQuery('html').append($animatedObject); 454 455 if(jQuery(window).width() > 767){ 456 var gotoX = jQuery("#fixed-cart-footer").offset().left + 20; 457 var gotoY = jQuery("#fixed-cart-footer").offset().top; 458 459 jQuery('#footer-cart-trigger').addClass('active'); 460 jQuery('#footer-mini-cart').slideDown(300); 461 }else { 462 var gotoX = jQuery("#cart-top-action").offset().left; 463 var gotoY = jQuery("#cart-top-action").offset().top; 464 } 465 466 $animatedObject.animate({ 467 opacity: 0.6, 468 left: gotoX, 469 top: gotoY 470 }, 2000, 471 function () { 472 $animatedObject.remove(); 473 }); 474 }else { 475 $("header.page-header").addClass("show-sticky-menu"); 476 $('[data-block="minicart"]').find('[data-role="dropdownDialog"]').dropdownDialog("open"); 477 setTimeout(function(){ 478 $("header.page-header").removeClass("show-sticky-menu"); 479 $('[data-block="minicart"]').find('[data-role="dropdownDialog"]').dropdownDialog("close"); 480 },5000); 481 } 482 } 483 } 484 } 485 } 486 }, 487 error: function() { 488 window.location.href = mgsConfig.redirectCartUrl; 489 } 490 }); 491 }); 492}
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.