1/*! 2 * imagesLoaded PACKAGED v3.1.8 3 * JavaScript is all like "You images are done yet or what?" 4 * MIT License 5 */ 6(function(){function e(){}function t(e,t){for(var n=e.length;n--;)if(e[n].listener===t)return n;return-1}function n(e){return function(){return this[e].apply(this,arguments)}}var i=e.prototype,r=this,o=r.EventEmitter;i.getListeners=function(e){var t,n,i=this._getEvents();if("object"==typeof e){t={};for(n in i)i.hasOwnProperty(n)&&e.test(n)&&(t[n]=i[n])}else t=i[e]||(i[e]=[]);return t},i.flattenListeners=function(e){var t,n=[];for(t=0;e.length>t;t+=1)n.push(e[t].listener);return n},i.getListenersAsObject=function(e){var t,n=this.getListeners(e);return n instanceof Array&&(t={},t[e]=n),t||n},i.addListener=function(e,n){var i,r=this.getListenersAsObject(e),o="object"==typeof n;for(i in r)r.hasOwnProperty(i)&&-1===t(r[i],n)&&r[i].push(o?n:{listener:n,once:!1});return this},i.on=n("addListener"),i.addOnceListener=function(e,t){return this.addListener(e,{listener:t,once:!0})},i.once=n("addOnceListener"),i.defineEvent=function(e){return this.getListeners(e),this},i.defineEvents=function(e){for(var t=0;e.length>t;t+=1)this.defineEvent(e[t]);return this},i.removeListener=function(e,n){var i,r,o=this.getListenersAsObject(e);for(r in o)o.hasOwnProperty(r)&&(i=t(o[r],n),-1!==i&&o[r].splice(i,1));return this},i.off=n("removeListener"),i.addListeners=function(e,t){return this.manipulateListeners(!1,e,t)},i.removeListeners=function(e,t){return this.manipulateListeners(!0,e,t)},i.manipulateListeners=function(e,t,n){var i,r,o=e?this.removeListener:this.addListener,s=e?this.removeListeners:this.addListeners;if("object"!=typeof t||t instanceof RegExp)for(i=n.length;i--;)o.call(this,t,n[i]);else for(i in t)t.hasOwnProperty(i)&&(r=t[i])&&("function"==typeof r?o.call(this,i,r):s.call(this,i,r));return this},i.removeEvent=function(e){var t,n=typeof e,i=this._getEvents();if("string"===n)delete i[e];else if("object"===n)for(t in i)i.hasOwnProperty(t)&&e.test(t)&&delete i[t];else delete this._events;return this},i.removeAllListeners=n("removeEvent"),i.emitEvent=function(e,t){var n,i,r,o,s=this.getListenersAsObject(e);for(r in s)if(s.hasOwnProperty(r))for(i=s[r].length;i--;)n=s[r][i],n.once===!0&&this.removeListener(e,n.listener),o=n.listener.apply(this,t||[]),o===this._getOnceReturnValue()&&this.removeListener(e,n.listener);return this},i.trigger=n("emitEvent"),i.emit=function(e){var t=Array.prototype.slice.call(arguments,1);return this.emitEvent(e,t)},i.setOnceReturnValue=function(e){return this._onceReturnValue=e,this},i._getOnceReturnValue=function(){return this.hasOwnProperty("_onceReturnValue")?this._onceReturnValue:!0},i._getEvents=function(){return this._events||(this._events={})},e.noConflict=function(){return r.EventEmitter=o,e},"function"==typeof define&&define.amd?define("eventEmitter/EventEmitter",[],function(){return e}):"object"==typeof module&&module.exports?module.exports=e:this.EventEmitter=e}).call(this),function(e){function t(t){var n=e.event;return n.target=n.target||n.srcElement||t,n}var n=document.documentElement,i=function(){};n.addEventListener?i=function(e,t,n){e.addEventListener(t,n,!1)}:n.attachEvent&&(i=function(e,n,i){e[n+i]=i.handleEvent?function(){var n=t(e);i.handleEvent.call(i,n)}:function(){var n=t(e);i.call(e,n)},e.attachEvent("on"+n,e[n+i])});var r=function(){};n.removeEventListener?r=function(e,t,n){e.removeEventListener(t,n,!1)}:n.detachEvent&&(r=function(e,t,n){e.detachEvent("on"+t,e[t+n]);try{delete e[t+n]}catch(i){e[t+n]=void 0}});var o={bind:i,unbind:r};"function"==typeof define&&define.amd?define("eventie/eventie",o):e.eventie=o}(this),function(e,t){"function"==typeof define&&define.amd?define(["eventEmitter/EventEmitter","eventie/eventie"],function(n,i){return t(e,n,i)}):"object"==typeof exports?module.exports=t(e,require("wolfy87-eventemitter"),require("eventie")):e.imagesLoaded=t(e,e.EventEmitter,e.eventie)}(window,function(e,t,n){function i(e,t){for(var n in t)e[n]=t[n];return e}function r(e){return"[object Array]"===d.call(e)}function o(e){var t=[];if(r(e))t=e;else if("number"==typeof e.length)for(var n=0,i=e.length;i>n;n++)t.push(e[n]);else t.push(e);return t}function s(e,t,n){if(!(this instanceof s))return new s(e,t);"string"==typeof e&&(e=document.querySelectorAll(e)),this.elements=o(e),this.options=i({},this.options),"function"==typeof t?n=t:i(this.options,t),n&&this.on("always",n),this.getImages(),a&&(this.jqDeferred=new a.Deferred);var r=this;setTimeout(function(){r.check()})}function f(e){this.img=e}function c(e){this.src=e,v[e]=this}var a=e.jQuery,u=e.console,h=u!==void 0,d=Object.prototype.toString;s.prototype=new t,s.prototype.options={},s.prototype.getImages=function(){this.images=[];for(var e=0,t=this.elements.length;t>e;e++){var n=this.elements[e];"IMG"===n.nodeName&&this.addImage(n);var i=n.nodeType;if(i&&(1===i||9===i||11===i))for(var r=n.querySelectorAll("img"),o=0,s=r.length;s>o;o++){var f=r[o];this.addImage(f)}}},s.prototype.addImage=function(e){var t=new f(e);this.images.push(t)},s.prototype.check=function(){function e(e,r){return t.options.debug&&h&&u.log("confirm",e,r),t.progress(e),n++,n===i&&t.complete(),!0}var t=this,n=0,i=this.images.length;if(this.hasAnyBroken=!1,!i)return this.complete(),void 0;for(var r=0;i>r;r++){var o=this.images[r];o.on("confirm",e),o.check()}},s.prototype.progress=function(e){this.hasAnyBroken=this.hasAnyBroken||!e.isLoaded;var t=this;setTimeout(function(){t.emit("progress",t,e),t.jqDeferred&&t.jqDeferred.notify&&t.jqDeferred.notify(t,e)})},s.prototype.complete=function(){var e=this.hasAnyBroken?"fail":"done";this.isComplete=!0;var t=this;setTimeout(function(){if(t.emit(e,t),t.emit("always",t),t.jqDeferred){var n=t.hasAnyBroken?"reject":"resolve";t.jqDeferred[n](t)}})},a&&(a.fn.imagesLoaded=function(e,t){var n=new s(this,e,t);return n.jqDeferred.promise(a(this))}),f.prototype=new t,f.prototype.check=function(){var e=v[this.img.src]||new c(this.img.src);if(e.isConfirmed)return this.confirm(e.isLoaded,"cached was confirmed"),void 0;
6if(this.img.complete&&void 0!==this.img.naturalWidth)return this.confirm(0!==this.img.naturalWidth,"naturalWidth"),void 0;var t=this;e.on("confirm",function(e,n){return t.confirm(e.isLoaded,n),!0}),e.check()},f.prototype.confirm=function(e,t){this.isLoaded=e,this.emit("confirm",this,t)};var v={};return c.prototype=new t,c.prototype.check=function(){if(!this.isChecked){var e=new Image;n.bind(e,"load",this),n.bind(e,"error",this),e.src=this.src,this.isChecked=!0}},c.prototype.handleEvent=function(e){var t="on"+e.type;this[t]&&this[t](e)},c.prototype.onload=function(e){this.confirm(!0,"onload"),this.unbindProxyEvents(e)},c.prototype.onerror=function(e){this.confirm(!1,"onerror"),this.unbindProxyEvents(e)},c.prototype.confirm=function(e,t){this.isConfirmed=!0,this.isLoaded=e,this.emit("confirm",this,t)},c.prototype.unbindProxyEvents=function(e){n.unbind(e.target,"load",this),n.unbind(e.target,"error",this)},s}); 7 8(function($){ 9 "use strict"; 10 11 var SPU_master = function() { 12 13 var windowHeight = $(window).height(); 14 var isAdmin = spuvar.is_admin; 15 var $boxes = []; 16 17 //remove paddings and margins from first and last items inside box 18 $(".spu-content").children().first().css({ 19 "margin-top": 0, 20 "padding-top": 0 21 }).end().last().css({ 22 'margin-bottom': 0, 23 'padding-bottom': 0 24 }); 25 26 // loop through boxes 27 $(".spu-box").each(function() { 28 29 // move to parent in safe mode 30 if( spuvar.safe_mode ){ 31 32 $(this).prependTo('body'); 33 34 } 35 36 // vars 37 var $box = $(this); 38 var triggerMethod = $box.data('trigger'); 39 var timer = 0; 40 var testMode = (parseInt($box.data('test-mode')) === 1); 41 var id = $box.data('box-id'); 42 var autoHide = (parseInt($box.data('auto-hide')) === 1); 43 var secondsClose = parseInt($box.data('seconds-close')); 44 var triggerSeconds = parseInt( $box.data('trigger-number'), 10 ); 45 var triggerPercentage = ( triggerMethod == 'percentage' ) ? ( parseInt( $box.data('trigger-number'), 10 ) / 100 ) : 0.8; 46 var triggerHeight = ( triggerPercentage * $(document).height() ); 47 48 facebookFix( $box ); 49 50 51 52 53 // Custom links conversion 54 $box.on('click', 'a:not(".spu-close-popup, .flp_wrapper a, .spu-not-close")', function(){ 55 // hide the popup and track conversion 56 toggleBox( id, false, true); 57 }); 58 //close with esc 59 $(document).keyup(function(e) { 60 if (e.keyCode == 27) { 61 toggleBox( id, false, false ); 62 } 63 }); 64 //close on ipads // iphones 65 var ua = navigator.userAgent, 66 event = (ua.match(/iPad/i) || ua.match(/iPhone/i)) ? "touchstart" : "click"; 67 68 $('body').on(event, function (ev) { 69 // test that event is user triggered and not programatically 70 if( ev.originalEvent !== undefined ) { 71 72 toggleBox( id, false, false ); 73 74 } 75 }); 76 //not on the box 77 $('body' ).on(event,'.spu-box,.spu-clickable', function(event) { 78 event.stopPropagation(); 79 }); 80 81 //hide boxes and remove left-99999px we cannot since beggining of facebook won't display 82 $box.hide().css('left',''); 83 84 // add box to global boxes array 85 $boxes[id] = $box; 86 87 // functions that check % of height 88 var triggerHeightCheck = function() 89 { 90 if(timer) { 91 clearTimeout(timer); 92 } 93 94 timer = window.setTimeout(function() { 95 var scrollY = $(window).scrollTop(); 96 var triggered = ((scrollY + windowHeight) >= triggerHeight); 97 98 // show box when criteria for this box is matched 99 if( triggered ) { 100 101 // remove listen event if box shouldn't be hidden again 102 if( ! autoHide ) { 103 $(window).unbind('scroll', triggerHeightCheck); 104 } 105 106 toggleBox( id, true, false ); 107 } else { 108 toggleBox( id, false, false ); 109 } 110 111 }, 100); 112 } 113 // function that show popup after X secs 114 var triggerSecondsCheck = function() 115 { 116 if(timer) { 117 clearTimeout(timer); 118 } 119 120 timer = window.setTimeout(function() { 121 122 toggleBox( id, true, false ); 123 124 }, triggerSeconds * 1000); 125 } 126 127 // show box if cookie not set or if in test mode 128 var cookieValue = spuReadCookie( 'spu_box_' + id ); 129 130 if( ( cookieValue == undefined || cookieValue == '' ) || ( isAdmin && testMode ) ) { 131 132 if(triggerMethod == 'seconds') { 133 triggerSecondsCheck(); 134 } 135 if(triggerMethod == 'percentage'){ 136 $(window).bind( 'scroll', triggerHeightCheck ); 137 // init, check box criteria once 138 triggerHeightCheck(); 139 } 140 141 // shows the box when hash refers to a box 142 if(window.location.hash && window.location.hash.length > 0) { 143 144 var hash = window.location.hash; 145 var $element; 146 147 if( hash.substring(1) === $box.attr( 'id' ) ) { 148 setTimeout(function() { 149 toggleBox( id, true, false ); 150 }, 100); 151 } 152 } 153 } /* end check cookie */ 154 //close popup 155 $box.on('click','.spu-close-popup',function() { 156 157 // hide box 158 toggleBox( id, false, false ); 159 160 if(triggerMethod == 'percentage') { 161 // unbind 162 $(window).unbind( 'scroll', triggerHeightCheck ); 163 } 164 165 }); 166 167 // add link listener for this box 168 $(document.body).on('click','a[href="#spu-' + id +'"], .spu-open-' + id ,function(e) { 169 e.preventDefault(); 170 toggleBox(id, true, false); 171 }); 172 $('a[href="#spu-' + id +'"], .spu-open-' + id).css('cursor','pointer').addClass('spu-clickable'); 173 174 // add class to the gravity form if they exist within the box 175 $box.find('.gform_wrapper form').addClass('gravity-form'); 176 // same for mc4wp 177 $box.find('.mc4wp-form form').addClass('mc4wp-form'); 178 // same for newsletter plugin 179 $box.find('.newsletter form').addClass('newsletter-form'); 180 181 // check if we have forms and perform different actions 182 var box_form = $box.find('form'); 183 if( box_form.length ) { 184 // Only if form is not a known one disable ajax 185 if( ! box_form.is(".newsletter-form, .wpcf7-form, .gravity-form, .infusion-form, .widget_wysija, .ninja-forms-form") ) { 186 var action = box_form.attr('action'), 187 pattern = new RegExp(spuvar.site_url, "i"); 188 if (action && action.length) { 189 if (!pattern.test(action)) 190 box_form.addClass('spu-disable-ajax'); 191 } 192 } 193 // if spu-disable-ajax is on container add it to form (usp forms for example) 194 if( $('.spu-disable-ajax form').length ) { 195 $('.spu-disable-ajax form').addClass('spu-disable-ajax'); 196 } 197 // Disable ajax on form by adding .spu-disable-ajax class to it
198 $box.on('submit','form.spu-disable-ajax:not(".flp_form")', function(){ 199 200 $box.trigger('spu.form_submitted', [id]); 201 toggleBox(id, false, true ); 202 }); 203 204 // Add generic form tracking 205 $box.on('submit','form:not(".newsletter-form, .wpcf7-form, .gravity-form, .infusion-form, .spu-disable-ajax, .widget_wysija, .ninja-forms-form, .flp_form")', function(e){ 206 e.preventDefault(); 207 208 209 var submit = true, 210 form = $(this), 211 data = form.serialize(), 212 url = form.hasClass('mc4wp-form') ? spuvar.site_url +'/' : form.attr('action'), 213 error_cb = function (data, error, errorThrown){ 214 console.log('Spu Form error: ' + error + ' - ' + errorThrown); 215 }, 216 success_cb = function (data){ 217 218 var response = $(data).filter('#spu-'+ id ).html(); 219 $('#spu-' + id ).html(response); 220 221 // check if an error was returned for m4wp 222 if( ! $('#spu-' + id ).find('.mc4wp-form-error').length ) { 223 224 // give 2 seconds for response 225 setTimeout( function(){ 226 227 toggleBox(id, false, true ); 228 229 }, spuvar.seconds_confirmation_close * 1000); 230 231 } 232 }; 233 // Send form by ajax and replace popup with response 234 request(data, url, success_cb, error_cb, 'html'); 235 236 $box.trigger('spu.form_submitted', [id]); 237 238 return submit; 239 }); 240 241 // CF7 support 242 $('body').on('mailsent.wpcf7', function(){ 243 $box.trigger('spu.form_submitted', [id]); 244 toggleBox(id, false, true ); 245 }); 246 247 // Gravity forms support (only AJAX mode) 248 $(document).on('gform_confirmation_loaded', function(){ 249 $box.trigger('spu.form_submitted', [id]); 250 toggleBox(id, false, true ); 251 }); 252 253 // Infusion Software - not ajax 254 $box.on('submit','.infusion-form', function(e){ 255 e.preventDefault(); 256 $box.trigger('spu.form_submitted', [id]); 257 toggleBox(id, false, true ); 258 this.submit(); 259 }); 260 // The newsletter plugin - not ajax 261 $box.on('submit','.newsletter-form', function(e){ 262 e.preventDefault(); 263 $box.trigger('spu.form_submitted', [id]); 264 toggleBox(id, false, true ); 265 this.submit(); 266 }); 267 // Ninja form - popup not ajax, ajax on ninja form 268 $('body').on('submitResponse.default', function(){ 269 $box.trigger('spu.form_submitted', [id]); 270 toggleBox(id, false, true ); 271 }); 272 } 273 274 275 276 }); 277 278 279 280 //function that center popup on screen 281 function fixSize( id ) { 282 var $box = $boxes[id]; 283 var windowWidth = $(window).width(); 284 var windowHeight = $(window).height(); 285 var popupHeight = $box.outerHeight(); 286 var popupWidth = $box.outerWidth(); 287 var intentWidth = $box.data('width'); 288 var left = 0; 289 var top = windowHeight / 2 - popupHeight / 2; 290 var position = 'fixed'; 291 var currentScroll = $(document).scrollTop(); 292 293 if( $box.hasClass('spu-centered') ){ 294 if( intentWidth < windowWidth ) { 295 left = windowWidth / 2 - popupWidth / 2; 296 } 297 $box.css({ 298 "left": left, 299 "position": position, 300 "top": top, 301 }); 302 } 303 304 // if popup is higher than viewport we need to make it absolute 305 if( (popupHeight + 50) > windowHeight ) { 306 position = 'absolute'; 307 top = currentScroll; 308 309 $box.css({ 310 "position": position, 311 "top": top, 312 "bottom": "auto", 313 //"right": "auto", 314 //"left": "auto", 315 }); 316 } 317 318 } 319 320 //facebookBugFix 321 function facebookFix( box ) { 322 323 // Facebook bug that fails to resize 324 var $fbbox = $(box).find('.spu-facebook'); 325 if( $fbbox.length ){ 326 //if exist and width is 0 327 var $fbwidth = $fbbox.find('.fb-like > span').width(); 328 if ( $fbwidth == 0 ) { 329 var $fblayout = $fbbox.find('.fb-like').data('layout'); 330 if( $fblayout == 'box_count' ) { 331 332 $fbbox.append('<style type="text/css"> #'+$(box).attr('id')+' .fb-like iframe, #'+$(box).attr('id')+' .fb_iframe_widget span, #'+$(box).attr('id')+' .fb_iframe_widget{ height: 63px !important;width: 80px !important;}</style>'); 333 334 } else if( $fblayout == 'button_count' ) { 335 336 $fbbox.append('<style type="text/css"> #'+$(box).attr('id')+' .fb-like iframe, #'+$(box).attr('id')+' .fb_iframe_widget span, #'+$(box).attr('id')+' .fb_iframe_widget{ height: 20px !important;min-width: 120px !important;}</style>'); 337 338 } else { 339 340 $fbbox.append('<style type="text/css"> #'+$(box).attr('id')+' .fb-like iframe, #'+$(box).attr('id')+' .fb_iframe_widget span, #'+$(box).attr('id')+' .fb_iframe_widget{ height: 20px !important;width: 80px !important;}</style>'); 341 342 } 343 } 344 } 345 } 346 347 /** 348 * Check all shortcodes and automatically center them 349 * @param box 350 */ 351 function centerShortcodes( box ){ 352 var $box = box; 353 var total = $box.data('total'); //total of shortcodes used 354 if( total ) { //if we have shortcodes 355 SPU_reload_socials(); 356 357 //wrap them all 358 //center spu-shortcodes 359 var swidth = 0; 360 var free_width = 0; 361 var boxwidth = $box.outerWidth(); 362 var cwidth = $box.find(".spu-content").width(); 363 if (!spuvar.disable_style && $(window).width() > boxwidth) { 364 $box.find(".spu-shortcode").wrapAll('<div class="spu_shortcodes"/>'); 365 //calculate total width of shortcodes all togheter 366 $box.find(".spu-shortcode").each(function () { 367 swidth = swidth + $(this).outerWidth(); 368 }); 369 //available space to split margins 370 free_width = cwidth - swidth - (total*20); 371 372 } 373 if (free_width > 0) { 374 //leave some margin 375 $box.find(".spu-shortcode").each(function () { 376 377 $(this).css('margin-left', (free_width / 2 )); 378 379 }); 380 //remove margin when neccesary 381 if (total == 2) { 382 383 $box.find(".spu-shortcode").last().css('margin-left', 0); 384 385 } else if (total == 3) { 386 387 $box.find(".spu-shortcode").first().css('margin-left', 0); 388 389 } 390 } 391 } 392 } 393 /** 394 * Main function to show or hide the popup 395 * @param id int box id 396 * @param show boolean it's hiding or showing? 397 * @param conversion boolean - Its a conversion or we are just closing 398 * @returns {*} 399 */ 400 function toggleBox( id, show, conversion ) { 401 var $box = $boxes[id]; 402 var $bg = $('#spu-bg-'+id); 403 var $bgopa = $box.data('bgopa'); 404 405 // don't do anything if box is undergoing an animation 406 if( $box.is( ":animated" ) ) { 407 return false; 408 } 409 410 // is box already at desired visibility? 411 if( ( show === true && $box.is( ":visible" ) ) || ( show === false && $box.is( ":hidden" ) ) ) { 412 return false; 413 } 414 415 416 //if we are closing , set cookie 417 if( show === false) { 418 // set cookie 419 var days = parseFloat( $box.data('close-cookie') ); 420 if( conversion === true ) 421 days = parseFloat( $box.data('cookie') ); 422 423 424 if( days > 0 ) { 425 spuCreateCookie( 'spu_box_' + id, true, days ); 426 }else{ 427 spuCreateCookie( 'spu_box_' + id, true );// added by Dan 428 } 429 430 $box.trigger('spu.box_close', [id]); 431 } else { 432 setTimeout(function(){ 433 centerShortcodes($box); 434 },1500); 435 $box.trigger('spu.box_open', [id]); 436 //bind for resize 437 $(window).resize(function(){ 438 439 fixSize( id ); 440 441 }); 442 fixSize( id ); 443 444 } 445 446 // show box 447 var animation = $box.data('spuanimation'), 448 conversion_close = $box.data('close-on-conversion'); 449 450 451 if (animation === 'fade') { 452 if (show === true) { 453 $box.fadeIn('slow'); 454 } else if (show === false && ( (conversion_close && conversion ) || !conversion ) ) { 455 $box.fadeOut('slow'); 456 } 457 } else { 458 if (show === true ) { 459 $box.slideDown('slow'); 460 } else if (show === false && ( (conversion_close && conversion ) || !conversion ) ) { 461 $box.slideUp('slow'); 462 } 463 } 464 465 //background 466 if (show === true && $bgopa > 0) { 467 $bg.fadeIn(); 468 } else if (show === false && ( (conversion_close && conversion ) || !conversion ) ) { 469 $bg.fadeOut(); 470 } 471 472 return show; 473 } 474 475 return { 476 show: function( box_id ) { 477 return toggleBox( box_id, true, false ); 478 }, 479 hide: function( box_id, show, conversion ) { 480 return toggleBox( box_id, false, conversion ); 481 }, 482 request: function( data, url, success_cb, error_cb ) { 483 return request( data, url, success_cb, error_cb ); 484 } 485 } 486 487 } 488 if( spuvar.ajax_mode ) { 489 490 var data = { 491 pid : spuvar.pid, 492 referrer : document.referrer, 493 query_string : document.location.search, 494 is_category : spuvar.is_category, 495 is_archive : spuvar.is_archive 496 } 497 ,success_cb = function(response) { 498 499 $('body').append(response); 500 $(".spu-box").imagesLoaded( function() { 501 window.SPU = SPU_master(); 502 SPU_reload_forms(); //remove spu_Action from forms 503 }); 504 }, 505 error_cb = function (data, error, errorThrown){ 506 console.log('Problem loading popups - error: ' + error + ' - ' + errorThrown); 507 } 508 request(data, spuvar.ajax_mode_url , success_cb, error_cb, 'html'); 509 } else { 510 $(".spu-box").imagesLoaded( function(){ 511 window.SPU = SPU_master(); 512 }); 513 } 514 515 /** 516 * Ajax requests 517 * @param data 518 * @param url 519 * @param success_cb 520 * @param error_cb 521 * @param dataType 522 */ 523 function request(data, url, success_cb, error_cb, dataType){ 524 // Prepare variables. 525 var ajax = { 526 url: spuvar.ajax_url, 527 data: data, 528 cache: false, 529 type: 'POST', 530 dataType: 'json', 531 timeout: 30000 532 }, 533 dataType = dataType || false, 534 success_cb = success_cb || false, 535 error_cb = error_cb || false; 536 537 // Set ajax url is supplied 538 if ( url ) { 539 ajax.url = url; 540 } 541 // Set success callback if supplied. 542 if ( success_cb ) { 543 ajax.success = success_cb; 544 } 545 546 // Set error callback if supplied. 547 if ( error_cb ) { 548 ajax.error = error_cb; 549 } 550 551 // Change dataType if supplied. 552 if ( dataType ) { 553 ajax.dataType = dataType; 554 } 555 // Make the ajax request. 556 $.ajax(ajax); 557 558 } 559 /** 560 * Cookie functions 561 */ 562 function spuCreateCookie(name, value, days) { 563 if (days) { 564 var date = new Date(); 565 date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); 566 var expires = "; expires=" + date.toGMTString(); 567 } else var expires = ""; 568 document.cookie = name + "=" + value + expires + "; path=/"; 569 } 570 571 function spuReadCookie(name) { 572 var nameEQ = name + "="; 573 var ca = document.cookie.split(';'); 574 for (var i = 0; i < ca.length; i++) { 575 var c = ca[i];
576 while (c.charAt(0) == ' ') c = c.substring(1, c.length); 577 if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length); 578 } 579 return null; 580 } 581 582 /** 583 * Social Callbacks 584 */ 585 var SPUfb = false; 586 587 var FbTimer = setInterval(function(){ 588 if( typeof FB !== 'undefined' && ! SPUfb) { 589 subscribeFbEvent(); 590 591 } 592 },1000); 593 594 if ( typeof twttr !== 'undefined') { 595 try{ 596 twttr.ready(function(twttr) { 597 twttr.events.bind('tweet', twitterCB); 598 twttr.events.bind('follow', twitterCB); 599 }); 600 }catch(ex){} 601 } 602 603 604 function subscribeFbEvent(){ 605 try { 606 FB.Event.subscribe('edge.create', function (href, html_element) { 607 var box_id = $(html_element).parents('.spu-box').data('box-id'); 608 if (box_id) { 609 SPU.hide(box_id, false, true); 610 } 611 }); 612 }catch(ex){} 613 SPUfb = true; 614 clearInterval(FbTimer); 615 } 616 function twitterCB(intent_event) { 617 618 var box_id = $(intent_event.target).parents('.spu-box').data('box-id'); 619 620 if( box_id) { 621 SPU.hide(box_id, false, true); 622 } 623 } 624 function googleCB(a) { 625 626 if( "on" == a.state ) { 627 628 var box_id = jQuery('.spu-gogl').data('box-id'); 629 if( box_id) { 630 SPU.hide(box_id, false, true); 631 } 632 } 633 } 634 function closeGoogle(a){ 635 if( "confirm" == a.type ) 636 { 637 var box_id = jQuery('.spu-gogl').data('box-id'); 638 if( box_id) { 639 SPU.hide(box_id, false, true); 640 641 } 642 } 643 } 644 function SPU_reload_socials(){ 645 if( typeof spuvar_social != 'undefined' && spuvar_social.facebook) { 646 647 // reload fb 648 try{ 649 FB.XFBML.parse(); 650 }catch(ex){} 651 } 652 if( typeof spuvar_social != 'undefined' && spuvar_social.google){ 653 try { 654 // reload google 655 gapi.plusone.go(); 656 }catch(ex){} 657 } 658 if( typeof spuvar_social != 'undefined' && spuvar_social.twitter ) { 659 try { 660 //reload twitter 661 twttr.widgets.load(); 662 }catch(ex){} 663 } 664 } 665 function SPU_reload_forms(){ 666 // Clear actions 667 $('.spu-box form').each( function(){ 668 var action = $(this).attr('action'); 669 if( action ){ 670 $(this).attr('action' , action.replace('?spu_action=spu_load','')); 671 } 672 }); 673 if ($.fn.wpcf7InitForm) { 674 $('.spu-box div.wpcf7 > form').wpcf7InitForm(); 675 } 676 } 677 678 679})(jQuery);
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.