1/** 2 * Icegram JS class 3 * Initialize, run and manage all messages 4 * Public interface 5 **/ 6function Icegram() { 7 // var data, defaults, message_data, messages, map_id_to_index, map_type_to_index, timer, message_template_cache, mode; 8 // var tracking_data, powered_by; 9} 10 11Icegram.prototype.init = function ( data ) { 12 if (data == undefined) { 13 return; 14 } 15 // Pre-init - can allow others to modify message data 16 jQuery( window ).trigger( 'preinit.icegram', [ data ] ); 17 18 this.data = data; 19 this.defaults = jQuery.extend( {}, data.defaults ); 20 this.message_data = data.messages; 21 this.messages, this.tracking_data = []; 22 this.message_template_cache = {}; 23 this.map_id_to_index = {}; 24 this.map_type_to_index = {}; 25 this.mode = (window.ig_mode == undefined) ? 'local' : window.ig_mode; 26 this.powered_by = { link: 'https://www.icegram.com/?utm_source=inapp&utm_campaign=poweredby&utm_medium=' }; 27 //this.timer = setInterval( this.timer_tick, 1000 ); 28 29 // Add powered by properties 30 this.powered_by.text = this.defaults.powered_by_text; 31 this.powered_by.logo = this.defaults.powered_by_logo; 32 33 // Add container div for Icegram 34 jQuery('body').append('<div id="icegram_messages_container"></div>'); 35 // Loop over message data and create messages & maps 36 var i = 0; 37 this.messages = []; 38 var self = this; 39 if (this.message_data.length > 0) { 40 jQuery.each( this.message_data, function ( i, v ) { 41 42 try { 43 // dont check cookies in preview mode 44 // if(window.location.href.indexOf("campaign_preview_id") == -1){ 45 // //check cookies in js 46 // if(v['retargeting'] == 'yes' && jQuery.cookie('icegram_campaign_shown_'+v['campaign_id']) == 1){ 47 // return; 48 // } 49 // if(v['retargeting_clicked'] == 'yes' && jQuery.cookie('icegram_campaign_clicked_'+v['campaign_id']) == 1){ 50 // return; 51 // } 52 // } 53 //set delay time of mobile popup as -1 54 if(v['ig_mobile_popup'] !== 'undefined' && v['ig_mobile_popup'] == true){ 55 v['delay_time'] = -1; 56 } 57 var m = null; 58 var classname_suffix = v['type'].split('-').join(' ').ucwords().split(' ').join('_'); 59 60 if (typeof (window['Icegram_Message_Type_' + classname_suffix]) === 'function') { 61 m = new window['Icegram_Message_Type_' + classname_suffix]( v ); 62 } else { 63 m = new Icegram_Message_Type( v ); 64 } 65 66 self.messages.push( m ); 67 self.map_id_to_index['_'+v['id'] ] = i; 68 self.map_type_to_index[ v['type'] ] = jQuery.isArray(self.map_type_to_index[ v['type'] ]) ? self.map_type_to_index[ v['type'] ] : new Array(); 69 self.map_type_to_index[ v['type'] ].push(i); 70 71 } catch(err) { 72 console.log(err); 73 } 74 }); 75 } 76 77 // Submit event data on unload and at every 5 seconds... 78 jQuery( window ).on('unload', function() { 79 if (typeof(window.icegram.submit_tracking_data) === 'function') { 80 window.icegram.submit_tracking_data( false ); 81 } 82 } ); 83 setInterval( function() { 84 if (typeof(window.icegram.submit_tracking_data) === 'function') { 85 window.icegram.submit_tracking_data( true ); 86 } } , 5 * 1000 ); 87 88 89 // Trigger event for others! 90 jQuery( window ).trigger( 'init.icegram', [ this ] ); 91}; 92 93 94Icegram.prototype.timer_tick = function ( ) { 95 96}; 97 98// Message template cache - get / set 99Icegram.prototype.get_template_fn = function ( type ) { 100 return this.message_template_cache[ type ]; 101}; 102Icegram.prototype.set_template_fn = function ( type, fn ) { 103 this.message_template_cache[ type ] = fn; 104}; 105 106// Utility functions to get message instances 107Icegram.prototype.get_message = function ( index ) { 108 if (this.messages.length > index) { 109 return this.messages[ index ]; 110 } 111 return undefined; 112}; 113 114Icegram.prototype.get_message_by_id = function ( id ) { 115 if ( this.map_id_to_index.hasOwnProperty( '_'+id )) { 116 var index = this.map_id_to_index[ '_'+id ]; 117 return this.get_message( index ); 118 } 119 return undefined; 120}; 121Icegram.prototype.get_message_by_campaign_id = function ( ids ) { 122 ids = String(ids); 123 var campaign_messages = []; 124 var ig_messages = this.messages; 125 //spilt ids string 126 if(ids.indexOf(" ")){ 127 ids = ids.split(" "); 128 } 129 jQuery.each(ids,function(i,id){ 130 jQuery.each( ig_messages ,function(k,v){ 131 if(id == v.data.campaign_id){ 132 campaign_messages.push(v); 133 } 134 }); 135 }); 136 return campaign_messages; 137}; 138 139Icegram.prototype.get_messages_by_type = function ( type ) { 140 if ( this.map_type_to_index.hasOwnProperty( type )) { 141 var indices = this.map_type_to_index[ type ]; 142 var matches = []; 143 if (jQuery.isArray( indices )) { 144 var self = this; 145 jQuery.each( indices, function ( i, v ) { 146 matches.push( self.get_message( v ) ); 147 } ); 148 } 149 return matches; 150 } 151 return undefined; 152}; 153 154//Get powered by link 155Icegram.prototype.get_powered_by = function ( type ) { 156 var res = jQuery.extend( {}, this.powered_by ); 157 res.link = res.link + (type || ''); 158 return res; 159} 160 161 162//Event tracking 163Icegram.prototype.track = function ( ev, params ) { 164 if (typeof(params) === 'object' && params.hasOwnProperty('message_id') && params.hasOwnProperty('campaign_id') && params.message_id.indexOf('_00') == -1 ) { 165 jQuery( window ).trigger( 'track.icegram', [ ev, params ] ); 166 this.tracking_data.push( { 'type': ev, 'params': params} ); 167 } 168} 169Icegram.prototype.submit_tracking_data = function ( async ) { 170 var protocol = window.location.protocol.split(':'); 171 var a = protocol[0]; 172 var protocol1 = this.data.ajax_url.split('://'); 173 var b = protocol1[0]; 174 175 if (this.tracking_data.length > 0 && window.location.href.indexOf("campaign_preview_id") == -1 && !this.is_bot()) { 176 var params = { 177 type: 'POST', 178 url: this.data.ajax_url, 179 async: (async || false), 180 data: { 181 action: 'icegram_event_track', 182 event_data: JSON.parse(JSON.stringify(this.tracking_data)), 183 ig_remote_url: (this.mode == 'remote') ? window.location.href : undefined, 184 }, 185 success: function(data, status, xhr) { 186 }, 187 error: function(data, status, xhr) { 188 } 189 }; 190 if (this.mode == 'remote') { 191 params['xhrFields'] = { withCredentials: true }; 192 params['crossDomain'] = true; 193 params['async'] = true; 194 } else { 195 if( a != b ){ 196 params['xhrFields'] = { withCredentials: true }; 197 jQuery.extend(params.data, {ig_local_url_cs: window.location.href }); 198 } 199 } 200 201 jQuery.ajax(params); 202 this.tracking_data = []; 203 } 204} 205 206Icegram.prototype.is_bot = function ( ) { 207 var bot_list = /bot|spider|crawl|sucker|ia_archiver|alexa|spade|slurp|webbug|ZyBorg|Feedfetcher-Google|Mediapartners-Google|aolserver|seamonkey|binlar|casper|comodo|feedfinder|jakarta|java|larbin|libwww|pycurl|linkwalker|steeler|nutch|turnit|zmeu/i; 208 if ( bot_list.test( navigator.userAgent ) ){ 209 return true; 210 } else { 211 return false;
212 } 213} 214 215// hide all messages 216Icegram.prototype.hide_all_messages = function ( ) { 217 if (this.messages.length > 0) { 218 jQuery.each(this.messages , function( i, v ){ 219 v.hide(); 220 }); 221 } 222} 223 224/** 225 * Icegram Message Type - Base class 226 **/ 227function Icegram_Message_Type( data ) { 228 229 var data, template, dom_id, el, type, root_container; 230 231 this.root_container = "#icegram_messages_container"; 232 this.data = data; 233 this.type = data.type; 234 this.data.delay_time = parseInt(this.data.delay_time); 235 //add http:// to link 236 if (typeof(this.data.link) === 'string' && this.data.link != '' && !/^tel:/i.test(this.data.link)) { 237 if (!/^https?:\/\//i.test(this.data.link)) { 238 this.data.link = "http://" + this.data.link; 239 } 240 } 241 this.set_template( this.get_template_default() ); 242 243 jQuery( window ).trigger( 'msg_preinit.icegram', [ this ] ); 244 this.init(); 245} 246 247Icegram_Message_Type.prototype.init = function ( ) { 248 // Render HTML 249 this.render(); 250 // Add handlers 251 this.add_event_handlers(); 252}; 253 254Icegram_Message_Type.prototype.add_event_handlers = function ( ) { 255 this.el.on('click', {self: this}, this.on_click); 256 jQuery( window ).on('resize', {self: this}, this.on_resize); 257} 258// TODO:: add JS animation in this if necessary 259Icegram_Message_Type.prototype.animations = { 260}; 261 262Icegram_Message_Type.prototype.embed_form = function ( ) { 263 if(jQuery.inArray(this.data.type, ['toast', 'badge', 'ribbon', 'exit-redirect']) === -1 ){ 264 var form_text = null; 265 var form_layout = this.data.form_layout; 266 var form_has_label = this.data.form_has_label; 267 var form_style = this.data.form_style || 'none'; 268 var form_button_text = this.data.label || undefined; 269 form_style = form_style.toLowerCase().replace(' ', '_'); 270 271 if(this.data.use_form != undefined && this.data.use_form == 'yes') { 272 form_text = this.data.form_html; 273 } 274 275 //Check for old form code in message_body 276 //If found, process that form 277 if(this.el.find('form.ig_embed_form').length > 0){ 278 var form_old = this.el.find('form.ig_embed_form'); 279 form_layout = 'inline'; 280 // Change form layout handling for messagetype having bottom and inline options only 281 if(jQuery.inArray(this.data.type, ['messenger', 'tab', 'sidebar', 'interstitial', 'sticky']) === -1 ){ 282 if(form_old.hasClass('ig_left') ){ 283 form_layout = 'left'; 284 }else if(form_old.hasClass('ig_right')){ 285 form_layout = 'right'; 286 } 287 } 288 if(form_layout == 'inline'){ 289 this.el.find('form.ig_embed_form').replaceWith('<div class="ig_form_container layout_inline"></div>'); 290 } 291 form_has_label = (form_old.find('.ig_form_el_group label').length > 0) ? 'yes' : undefined; 292 if(form_old.find('.ig_button').length == 0 && form_old.find('button[type=submit]').length == 0){ 293 form_button_text = form_button_text || 'Submit'; 294 form_old.append('<input class="ig_button" type="submit" value="' + form_button_text +'">'); 295 } 296 form_text = jQuery('<div/>').append(form_old).html(); 297 } 298 if(form_text == null) { 299 this.el.find('.ig_form_container').remove(); 300 }else{ 301 var form_code = window.icegram.formProcess(this, form_text); 302 // TODO :: test this properly 303 // if(form_code){ 304 if(form_code && this.el.find('.ig_form_container form').length == 0){ 305 var form_header = (this.data.form_header != undefined && this.data.form_header != '' ) ? ('<div class="ig_form_header">'+this.data.form_header+'</div>') : ''; 306 var form_footer = (this.data.form_footer != undefined && this.data.form_footer != '' ) ? ('<div class="ig_form_footer">'+this.data.form_footer+'</div>') : ''; 307 var form_original_data = jQuery('<div/>').html(form_text); 308 this.el.find('.ig_form_container') 309 .append(form_header) 310 .append(form_code) 311 .append(form_footer); 312 313 //Add rainmaker class, form_type class and append success msg to the processed form container 314 if(this.data.rainmaker_form_code && this.data.rainmaker_form_code != ''){ 315 if(!this.data.cta || this.data.cta === 'form' || !this.data.show_response || !this.data.response_text || (this.data.response_text && this.data.response_text == '') ){ 316 this.data.response_text = form_original_data.find('.rm_form_message').html() || ''; 317 } 318 this.el.find('.ig_form_container') 319 .addClass(form_original_data.find('.rm_form_container').data('type')) 320 .data('form-id', form_original_data.find('.rm_form_container').data('form-id')) 321 .addClass('rainmaker_form') 322 var rm_script = form_original_data.find('#rm_script'); 323 var rm_style = form_original_data.find('#rm_style'); 324 this.el.find('.ig_form_container').prepend(rm_style).append(rm_script); 325 326 var rm_captch_div = form_original_data.find('.rm_captcha'); 327 var rm_error_div = form_original_data.find('.rm_form_error_message'); 328 // this.el.find('.ig_form_container').prepend(rm_style).append(rm_script).after(rm_captcha); 329 330 this.el.find('.ig_form_container form').prepend(rm_error_div).append(rm_c
330aptch_div); 331 } 332 // es form support shortcode 333 if(this.el.find('[data-es_form_id = "es_shortcode_form" ]').length > 0){ 334 this.el.find('[data-es_form_id = "es_shortcode_form" ]').addClass('es_shortcode_form'); 335 var es_captcha_div = jQuery(form_text).find('.es_captcha'); 336 this.el.find('.es_shortcode_form').parent().append(es_captcha_div); 337 this.el.find('.es_shortcode_form').parent().addClass('es_form_container'); 338 } 339 //es form support direct 340 if(this.el.find('form[data-source="ig-es"]').length > 0){ 341 var es_captcha_div = jQuery(form_text).find('.es_captcha'); 342 this.el.find('form[data-source="ig-es"] .ig_button').parent().before(es_captcha_div); 343 this.el.find('form[data-source="ig-es"] .es_captcha').addClass('ig_form_els'); 344 this.el.find('form[data-source="ig-es"]').addClass('es_form_container'); 345 } 346 347 //es form remote site support 348 var url = new URL(this.el.find('form').attr('action'), window.location.href); //Passing second parameter as the current page url to avoid TypeError in case URL in action attribute is not valid 349 var actionparam = url.searchParams.get('action'); 350 351 if( 'ig_es_external_subscription_form_submission' === actionparam ){ 352 this.el.find('form').addClass('ig-es-embeded-from es_form_container'); 353 } 354 355 356 if(form_has_label == undefined ){ 357 this.el.find('.ig_el_label').not('span.ig_el_label').remove(); 358 }else{ 359 this.el.find('input, textarea').removeAttr('placeholder'); 360 this.el.find('select option.ig_el_placeholder').remove(); 361 } 362 if(this.el.find('.ig_form_container .ig_button').length > 0){ 363 this.el.find('.ig_button').not('.ig_form_container .ig_button').hide(); 364 form_button_text = (form_button_text || this.el.find('.ig_button').val()) || 'Submit'; //TODO :: test this 365 this.el.find('.ig_button').val(form_button_text); 366 } 367 this.el.addClass('ig_form_'+ form_layout); 368 369 var inline_style = ''; 370 if(this.data.form_bg_color != undefined && this.data.form_bg_color != '') { 371 this.el.find('.ig_form_container').css('background-color', this.data.form_bg_color); 372 inline_style += '.ig_form_'+ form_layout + '.ig_form_' + form_style + ' .ig_form_container:before{ background-color:' + this.data.form_bg_color + '; border-color:' + this.data.form_bg_color + ';}'; 373 }else{ 374 inline_style += '.ig_form_'+ form_layout + '.ig_form_' + form_style + ' .ig_form_container:before{ display:none;}'; 375 } 376 if(this.data.form_text_color != undefined && this.data.form_text_color != '') { 377 this.el.find('.ig_form_container').css('color', this.data.form_text_color); 378 } 379 this.el.addClass('ig_form_'+ form_style).find('.ig_form_container').prepend('<style type="text/css">'+ inline_style +'</style>'); 380 // this.el.find('.ig_form_container.layout_' + form_layout + ' .ig_form_els') 381 // .first().addClass('ig_form_els_first').end() 382 // .last().addClass('ig_form_els_last'); 383 384 jQuery.each( this.el.find('.ig_form_container') || [], function(i, el){ 385 jQuery(el).find('.ig_form_els') 386 .first().addClass('ig_form_els_first').end() 387 .last().addClass('ig_form_els_last'); 388 }); 389 } 390 } 391 392 } 393 394} 395 396 397Icegram_Message_Type.prototype.render = function ( ) { 398 399 this.pre_render(); 400 401 var html = this.render_template(); 402 403 // Add html to DOM, Setup dom_id, el etc. 404 try { 405 jQuery(this.root_container).append(html); 406 } catch ( e ) {} 407 408 this.dom_id = 'icegram_message_'+this.data.id; 409 this.el = jQuery('#'+this.dom_id); 410 this.set_position(); 411 412 var pb = window.icegram.get_powered_by( this.type ); 413 if ( pb.hasOwnProperty('link') && pb.hasOwnProperty('text') && pb.text != '' ) { 414 this.add_powered_by( pb ); 415 } 416 417 // Hide elements if insufficient data... 418 if(this.data.headline == undefined || this.data.headline == '') { 419 this.el.find('.ig_headline').hide(); 420 } 421 if(this.data.icon == undefined || this.data.icon == '') { 422 this.el.addClass('ig_no_icon').find('.ig_icon').remove(); 423 } 424 if(this.data.message == undefined || this.data.message == '') { 425 this.el.find('.ig_message').hide(); 426 } 427 if(this.data.label == undefined || this.data.label == '') { 428 this.el.find('.ig_button').hide(); 429 } 430 431 // Form Embed 432 this.embed_form(); 433 434 // Apply colors, if theme defaults in not checked 435 if(this.data.use_theme_defaults == undefined || this.data.use_theme_defaults != 'yes'){ 436 if (this.data.text_color != undefined && this.data.text_color != '') { 437 this.el.css('color', this.data.text_color); 438 this.el.find('.ig_container').css('color', this.data.text_color); 439 } 440 if (this.data.bg_color != undefined && this.data.bg_color != '') { 441 this.el.css('background-color', this.data.bg_color); 442 this.el.find('.ig_container').css('background-color', this.data.bg_color); 443 } 444 445 if (this.data.cta_bg_color != undefined && this.data.cta_bg_color != '') { 446 this.el.find('.ig_button, form input[type="submit"]').css('background-color', this.data.cta_bg_color); 447 var bgColorHSL = window.icegram.hexToHsl(this.data.cta_bg_color); // border color based on bg_color 448 this.el.find('.ig_button, form input[type="submit"]').css('border-color', "hsl(" + bgColorHSL.h + "," + (bgColorHSL.s-5) + "%," + (bgColorHSL.l-8) + "%)" ); 449 } 450 if (this.data.cta_text_color != undefined && this.data.cta_text_color != '') { 451 this.el.find('.ig_button, form input[type="submit"]').css('color', this.data.cta_text_color); 452 } 453 } 454 455 // Add Custom CSS and js here. 456 if(this.data.use_custom_code){ 457 if(this.data.custom_css){ 458 // this.el.prepend('<style id="ig_custom_css_'+this.data.id+'" type="text/css">' + this.data.custom_css.replace(/#ig_this_message/g, '#'+this.dom_id).replace(/\.ig_this_message_root/g, '.ig_this_message_root_'+this.data.id) + '</style>'); 459 this.el.prepend('<style id="ig_custom_css_'+this.data.id+'" type="text/css">' + this.data.custom_css.replace(/#ig_this_message/g, '#'+this.dom_id)+ '</style>'); 460 } 461 //TODO:: Add provision to replace #ig_this_message with dom_id and/or message_id 462 // if(this.data.custom_js){ 463 // jQuery('body').append(this.data.custom_js); 464 // } 465 } 466 467 // Hint clickability for buttons / ctas 468 if (typeof(this.data.link) === 'string' && this.data.link != '') { 469 this.el.parent().find('.ig_cta, .ig_button').css('cursor', 'pointer'); 470 } 471 472 this.post_render(); 473 // Hide the message by default 474 this.hide( {}, true ); 475 476 // Set up message display trigger 477 this.set_up_show_trigger(); 478} 479 480//form process on 481Icegram.prototype.formProcess = function(self, form_text) { 482 var form_tags = jQuery('<div/>') 483 .html(form_text) 484 .find('input[name="fake_text"]').data('required_field', true).end() // Arforms 485 .find('input.rm_required_feild').data('required_field', true).end() // detect Rainmaker Forms honeypot fields here 486 .find('.gform_validation_container input').data('required_field', true).end() // detect Gravity Forms honeypot fields here 487 .find('.rm_captcha_input').data('keep_class', true).end() // 488 .find('.es_captcha_input').data('keep_class', true).end() // 489 .find('.gdpr-label').data('keep_class', true).end() // keep GDPR class 490 .find('.required_field').data('required_field', true).end() // detect Form Craft honeypot fields here 491 .find('input, label, select, textarea, button')// Get only these tags from the form 492 .not('.rm_captcha_input, .rm_captcha_verify') 493 .not('.es_captcha_input, .es_captcha_verify ') 494 .not('br'); 495 496 if(form_tags.length > 0){ 497 var form_container = jQuery('<div class="ig_embed_form_container ig_clear_fix"></div>'); 498 var form_object = jQuery('<div/>') 499 .html(form_text) 500 .find('form') 501 .removeAttr('class') 502 .removeAttr('style') 503 .addClass('ig_clear_fix') 504 .empty(); 505 506 var label_text = '.'; 507 var el_count = 0; 508 jQuery.each(form_tags, function(i, form_el){ 509 var el_obj = jQuery(form_el); 510 var el_group = jQuery('<div class="ig_form_els"></div>'); 511 el_obj.removeAttr('style'); 512 if(!el_obj.data('keep_class')){ 513 el_obj.removeAttr('class'); 514 } 515 516 // add all the cases for bot here 517 if( el_obj.attr('tabindex') == -1 518 || el_obj.is('*[name*="[abs]"]') 519 || el_obj.data('required_field') 520 || el_obj.attr('name') == 'data[email]' 521 || el_obj.attr('name') == '_mc4wp_required_but_not_really'){ 522 el_obj.addClass('ig_form_required_field').removeData('required_field'); 523 el_count--; 524 } 525 526 //hidden fields 527 if( el_obj.attr('type') == 'hidden' || el_obj.prop('disabled') === true){ 528 el_obj.addClass('ig_form_hidden_field'); 529 el_count--; 530 } 531 532 if(el_obj.is('label')){ // get the label if found. 533 //GDPR compatibility 534 if(el_obj.attr('class') == 'gdpr-label' || el_obj.find('input[name="es_gdpr_consent"]').length > 0){ 535 el_obj.find('input[type=checkbox]').remove(); 536 label_text = el_obj.not('input, select, textarea, button, span, br').html().replace(/\s+/g, ' ') || '.'; 537 }else{ 538 label_text = el_obj.not('input, select, textarea, button, span, br').text().replace(/\s+/g, ' ') || '.'; 539 } 540 }else if((el_obj.is('input') || el_obj.is('button') || el_obj.is('textarea') || el_obj.is('select')) && !el_obj.is('input[type=radio]' ) && !el_obj.is('input[type=checkbox]' ) ) { 541 542 el_obj.removeAttr('id'); 543 544 if(el_obj.is('button')){ // if button found convert it to input type="submit" 545 var button_text = el_obj.not('br, span, div').text().trim() || ''; 546 el_obj.remove(); 547 el_obj = jQuery('<input type="submit" value="' + button_text +'">'); 548 } 549 550 if((el_obj.is('input[type=submit]') || el_obj.is('input[type=button]') ) && !el_obj.is('.ig_form_hidden_field, .ig_form_required_field')){ // TODO :: check do we need to handle input[type=button] 551 el_obj.addClass('ig_button'); 552 } 553 //TODO :: temp additon Test it, in all cases 554 if(el_obj.is('input[type=text]') || el_obj.is('input[type=email]') ){ 555 el_obj.attr('size', 25); 556 } 557 label_class = 'ig_el_label ig_button_label'; 558 if(label_text != '.'){ 559 label_class = 'ig_el_label'; 560 if(el_obj.is('select')) { 561 jQuery('<option class="ig_el_placeholder">' + label_text + '</option>').prependTo(el_obj); 562 }else{ 563 el_obj.attr('placeholder', label_text); 564 } 565 } 566 jQuery('<label class="'+label_class+ '">' + label_text + '</label>').appendTo(el_group); 567 label_text = '.'; 568 el_group.append(el_obj); 569 form_container.append(el_group); 570 571 el_count++; 572 }else if(el_obj.is('input[type=radio]') || el_obj.is('input[type=checkbox]') ) { 573 574 //For Bottom & Inline position, form fields does not look good so we are giving full width to the fields. 575 if( 'bottom' === self.data.form_layout || 'inline' === self.data.form_layout ){ 576 form_container.addClass('ig_form_full'); 577 } 578 579 label_class = 'ig_el_label ig_button_label'; 580 if(label_text != '.'){ 581 label_class = 'ig_el_label'; 582 } 583 jQuery('<label><span class="'+label_class+'">' + label_text + '</span></label>').prepend(el_obj).appendTo(el_group); 584 label_text = '.'; 585 586 el_group.addClass('ig_form_el_radio'); 587 form_container.append(el_group); 588 el_count++; 589 } 590 }); // loop End 591 592 var elsClass = ['', 'ig_full', 'ig_half', 'ig_third', 'ig_quater']; 593 el_count = (el_count < 4 ) ? el_count : 4; 594 595 //Add bot field if not detected 596 if(form_container.find('.ig_form_required_field').length <= 0){ 597 form_container.append('<div class="ig_form_els"><input class="ig_form_required_field" type="text" tabindex="-1" value="" /></div>'); 598 } 599 //Checking if full width needs to be given to form fields. 600 if( form_container.hasClass('ig_form_full')){ 601 form_container.addClass('ig_full').removeClass('ig_form_full'); 602 } else{ 603 form_container.addClass(elsClass[el_count]); 604 } 605 form_container.find('.ig_form_required_field').parent().removeClass('ig_form_els').css({'position':'absolute' , 'left': '-5000px'}).end().end() 606 .find('.ig_form_hidden_field').parent().removeClass('ig_form_els').css({'display':'none'}); 607 form_object.append(form_container); 608 609 // TODO :: Qucik fix for Rainmaker form submission - success message 610 // return jQuery('<div/>').append(form_object).append(rm_message).html(); 611 return jQuery('<div/>').append(form_object).html(); 612 } 613 return null; 614} 615 616 617Icegram_Message_Type.prototype.render_template = function ( ) { 618 if ( typeof(window.icegram.get_template_fn( this.type ) ) !== 'function') { 619 // Adapted from John Resig's Simple JavaScript Templating 620 window.icegram.set_template_fn( this.type, new Function("obj",
621 "var p=[],print=function(){p.push.apply(p,arguments);};" + 622 "with(obj){p.push('" + 623 this.template 624 .replace(/[\r\t\n]/g, " ") 625 .split("{{").join("\t") 626 .replace(/((^|\}\})[^\t]*)'/g, "$1\r") 627 .replace(/\t=(.*?)\}\}/g, "',$1,'") 628 .split("\t").join("');") 629 .split("}}").join("p.push('") 630 .split("\r").join("\\'") 631 + "');}return p.join('');") ); 632 } 633 return window.icegram.get_template_fn( this.type )( this.data ); 634}; 635 636Icegram_Message_Type.prototype.pre_render = function ( ) { 637}; 638 639Icegram_Message_Type.prototype.post_render = function ( ) { 640} 641 642Icegram_Message_Type.prototype.set_up_show_trigger = function ( ) { 643 if (!isNaN(this.data.delay_time)) { 644 if( this.data.delay_time >= 0 ) { 645 var self = this; 646 this.timer = setTimeout( function() { self.show(); } , this.data.delay_time * 1000 ); 647 } 648 } else { 649 this.show(); 650 } 651}; 652 653Icegram_Message_Type.prototype.set_template = function ( str ) { 654 this.template = str; 655}; 656 657Icegram_Message_Type.prototype.get_template_default = function () { 658 return '<div id="icegram_message_{{=id}}" class="icegram">' + 659 '<div class="ig_headline">{{=headline}}</div>' + 660 '</div>'; 661}; 662 663Icegram_Message_Type.prototype.show = function ( options, silent ) { 664 if ( !this.is_visible() ) { 665 this.animate('in'); 666 this.pre_show(); 667 this.el.show( options ); 668 this.el.addClass('ig_show').removeClass('ig_hide'); 669 silent !== true && this.track( 'shown' ); 670 this.post_show(); 671 } 672 var self = this; 673 window.icegram.adjustFormContainerHeight(self); 674}; 675 676Icegram_Message_Type.prototype.hide = function ( options, silent ) { 677 if ( this.is_visible() ) { 678 var self = this; 679 this.animate('out'); 680 this.pre_hide(); 681 setTimeout(function(){ 682 if(!self.el.hasClass('ig_no_hide')){ 683 self.el.hide( options ); 684 } 685 self.el.addClass('ig_hide').removeClass('ig_show'); 686 },500); 687 silent !== true && this.track( 'closed' ); 688 this.post_hide(); 689 } 690}; 691 692Icegram_Message_Type.prototype.set_position = function ( ) { 693}; 694 695Icegram_Message_Type.prototype.add_powered_by = function ( pb ) { 696}; 697 698Icegram_Message_Type.prototype.pre_show = function ( ) { 699}; 700 701Icegram_Message_Type.prototype.post_show = function ( ) { 702}; 703 704Icegram_Message_Type.prototype.pre_hide = function ( ) { 705}; 706 707Icegram_Message_Type.prototype.post_hide = function ( ) { 708}; 709 710// Event tracking wrapper 711Icegram_Message_Type.prototype.track = function ( e, params ) { 712 if (typeof( window.icegram.track ) === 'function' ) { 713 params = params || {}; 714 jQuery.extend( params, {message_id: this.data.id, campaign_id: this.data.campaign_id, expiry_time:this.data.expiry_time, expiry_time_clicked:this.data.expiry_time_clicked} ); 715 window.icegram.track( e, params); 716 } 717}; 718 719Icegram_Message_Type.prototype.is_visible = function ( ) { 720 return this.el.hasClass('ig_show'); 721}; 722 723// Click and other event handlers 724Icegram_Message_Type.prototype.toggle = function ( options ) { 725 if ( this.is_visible() ) { 726 this.hide( options ); 727 } else { 728 this.show( options ); 729 }; 730}; 731 732Icegram_Message_Type.prototype.on_click = function ( e ) { 733 734 e.data = e.data || { self: this }; 735 // Clicked on close button 736 if (jQuery(e.target).filter('.ig_close').length 737 || jQuery(e.target).parents('.ig_close').length ) { 738 e.data.self.hide(); 739 return; 740 } 741 var form = jQuery(e.target).closest('.icegram').find('form:visible').first(); 742 // Clicking on ig_button or any other link with a class ig_cta will trigger cta click 743 if((jQuery(e.target).filter('.ig_button, .ig_cta, :submit').length 744 || jQuery(e.target).parents('button[type=submit]').length 745 || jQuery(e.target).filter('.es_submit_button').length // Email subscriber form in messagebody-cta compatiblity 746 || (jQuery(e.target).parents('.ig_button, .ig_cta').length && !(form.find('.ig_button, input[type=button], input[type=submit], button[type=submit]' ).length > 0) )) 747 && jQuery(e.target).not('.donot-track').length){ 748 e.data.self.on_cta_click( e ); 749 } 750}; 751 752Icegram_Message_Type.prototype.on_resize = function ( e ) { 753}; 754 755Icegram_Message_Type.prototype.on_cta_click = function ( e ) { 756 e.data = e.data || { self: this }; 757 var form = jQuery(e.target).closest('.icegram').find('form:visible').first(); 758 if(jQuery(form).length && jQuery(form).find('.ig_form_required_field').length 759 && jQuery(form).find('.ig_form_required_field').val() !== ''){ 760 e.preventDefault(); 761 e.data.self.hide(); 762 return; 763 }
764 // Do not track clicks, if form submission has failed because of honeypot 765 e.data.self.track( 'clicked' ); 766 767 if(jQuery(form).length){ 768 jQuery(form).submit(function(e){ 769 if( jQuery(form).hasClass('ig_form_init_done')){ 770 e.preventDefault(); 771 } 772 }); 773 }else if (typeof(e.data.self.data.link) === 'string' && e.data.self.data.link != '') { 774 window.location.href = e.data.self.data.link; 775 e.data.self.hide(); 776 }else if(e.data.self.data.hide !== false){ 777 e.data.self.hide(); 778 } 779 780}; 781 782Icegram_Message_Type.prototype.animate = function ( mode ) { 783 if (typeof(this.data.animation) !== 'undefined') { 784 var fn = this.data.animation; 785 var self = this; 786 if (mode == 'in') { 787 if(typeof(this.animations[fn+'_in']) === 'function'){ 788 this.animations[fn+'_in'](self); 789 } else if (!this.el.hasClass('ig_anim_'+fn+'_in') ) { 790 this.el.removeClass('ig_anim_'+fn+'_out'); 791 setTimeout(function(){ 792 self.el.addClass('ig_anim_'+fn+'_in'); 793 } ,1); 794 } 795 }else if (mode == 'out') { 796 if(typeof(this.animations[fn+'_out']) === 'function'){ 797 this.animations[fn+'_out'](self); 798 } else { 799 this.el.removeClass('ig_anim_'+fn+'_in'); 800 setTimeout(function(){ 801 self.el.addClass('ig_anim_'+fn+'_out'); 802 } ,1); 803 804 } 805 } 806 } 807} 808 809/** 810 * Utilities 811 */ 812String.prototype.ucwords = function() { 813 return this.toLowerCase().replace(/\b[a-z]/g, function(letter) { 814 return letter.toUpperCase(); 815 }); 816} 817// Adjustment of Form container height. 818Icegram.prototype.adjustFormContainerHeight = function(that) { 819 var form_layout = ''; 820 if(that.el.hasClass('ig_form_left') || that.el.hasClass('ig_form_right')){ 821 form_layout = that.el.hasClass('ig_form_left') ? 'left' : 'right'; 822 var height = ( that.el.find('.ig_data').outerHeight() > that.el.find('.ig_form_container.layout_' + form_layout ).outerHeight()) 823 ? that.el.find('.ig_data').outerHeight() 824 : that.el.find('.ig_form_container.layout_' + form_layout ).outerHeight(); 825 that.el.find('.ig_form_container').outerHeight(height); 826 } 827 828 // if(that.el.hasClass('ig_form_bottom') || that.el.hasClass('ig_form_inline')){ 829 // form_layout = that.el.hasClass('ig_form_bottom') ? 'bottom' : 'inline'; 830 // var height = ( that.el.find('.ig_form_container.layout_' + form_layout +' .ig_button').innerHeight() > that.el.find('.ig_form_container input').first().outerHeight()) 831 // ? that.el.find('.ig_form_container.layout_' + form_layout +' .ig_button').innerHeight() 832 // : that.el.find('.ig_form_container input').first().outerHeight(); 833 // that.el.find('.ig_form_container input, .ig_form_container select, .ig_form_container textarea') 834 // .not('.ig_form_container.layout_' + form_layout +' .ig_button, .ig_form_el_radio input').outerHeight(height); 835 // } 836} 837//Color conversion Functions. 838Icegram.prototype.hexToRgb = function(hex) { 839 var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex); 840 return result ? { 841 r: parseInt(result[1], 16), 842 g: parseInt(result[2], 16), 843 b: parseInt(result[3], 16) 844 } : null; 845} 846Icegram.prototype.rgbToHsl = function(r, g, b) { 847 r /= 255, g /= 255, b /= 255; 848 var max = Math.max(r, g, b), min = Math.min(r, g, b); 849 850 var h, s, l = (max + min) / 2; 851 if(max == min){ 852 h = s = 0; // achromatic 853 }else{ 854 var d = max - min; 855 s = l > 0.5 ? d / (2 - max - min) : d / (max + min); 856 switch(max){ 857 case r: h = (g - b) / d; break; 858 case g: h = (b - r) / d + 2; break; 859 case b: h = (r - g) / d + 4; break; 860 } 861 l = Math.floor(l * 100); 862 s = Math.floor(s * 100); 863 h = Math.floor(h * 60); 864 if(h<0){ 865 h += 360; 866 } 867 } 868 return {h: h, s: s, l: l}; 869} 870 871Icegram.prototype.hexToHsl = function (hex) { 872 var rgb = window.icegram.hexToRgb(hex); 873 return window.icegram.rgbToHsl(rgb.r, rgb.g, rgb.b); 874} 875 876if (typeof Object.create != 'function') { 877 (function () { 878 var F = function () {}; 879 Object.create = function (o) { 880 if (arguments.length > 1) { 881 throw Error('Second argument not supported'); 882 } 883 if (o === null) { 884 throw Error('Cannot set a null [[Prototype]]'); 885 } 886 if (typeof o != 'object') { 887 throw TypeError('Argument must be an object'); 888 } 889 F.prototype = o; 890 return new F(); 891 }; 892 })(); 893} 894 895//ES - success event handler 896var es_responseHandler = function (e, data) { 897 if( typeof icegram !== 'undefined'){ 898 var msg_id = ((jQuery(e.target).closest('[id^=icegram_message_]') || {}).attr('id') || '').split('_').pop() || 0 ; 899 var msg = icegram.get_message_by_id(msg_id) || undefined; 900 if(typeof msg !== 'undefined'){ 901 jQuery(e.target).find('.es_msg_ig').remove(); 902 if(msg.data.cta === 'form_via_ajax' && data.detail.es_response === 'success'){ 903 if(msg.data.response_text === ''){ 904 msg.data.response_text = data.detail.msg; 905 } 906 msg.el.trigger('form_success.ig_cta', [msg]); 907 }else{ 908 if(typeof msg.data.use_form !== 'undefined'){ 909 jQuery(e.target).append('<div class="es_msg es_msg_ig es_subscription_message '+data.detail.es_response+'">'+ (data.detail.msg) +'</div>'); 910 } 911 } 912 } 913 } 914}; //success.es 915 916 917jQuery( document ).on( "es_response" ,es_responseHandler ); 918 919// jQuery Cookies 920if(typeof(jQuery.cookie) !== undefined){ 921 (function(e){if(typeof define==="function"&&define.amd){define(["jquery"],e)}else if(typeof exports==="object"){e(require("jquery"))}else{e(jQuery)}})(function(e){function n(e){return u.raw?e:encodeURIComponent(e)}function r(e){return u.raw?e:decodeURIComponent(e)}function i(e){return n(u.json?JSON.stringify(e):String(e))}function s(e){if(e.indexOf('"')===0){e=e.slice(1,-1).replace(/\\"/g,'"').replace(/\\\\/g,"\\")}try{e=decodeURIComponent(e.replace(t," "));return u.json?JSON.parse(e):e}catch(n){}}function o(t,n){var r=u.raw?t:s(t);return e.isFunction(n)?n(r):r}var t=/\+/g;
921var u=e.cookie=function(t,s,a){if(s!==undefined&&!e.isFunction(s)){a=e.extend({},u.defaults,a);if(typeof a.expires==="number"){var f=a.expires,l=a.expires=new Date;l.setTime(+l+f*864e5)}return document.cookie=[n(t),"=",i(s),a.expires?"; expires="+a.expires.toUTCString():"",a.path?"; path="+a.path:"",a.domain?"; domain="+a.domain:"",a.secure?"; secure":""].join("")}var c=t?undefined:{};var h=document.cookie?document.cookie.split("; "):[];for(var p=0,d=h.length;p<d;p++){var v=h[p].split("=");var m=r(v.shift());var g=v.join("=");if(t&&t===m){c=o(g,s);break}if(!t&&(g=o(g))!==undefined){c[m]=g}}return c};u.defaults={};e.removeCookie=function(t,n){if(e.cookie(t)===undefined){return false}e.cookie(t,"",e.extend({},n,{expires:-1}));return!e.cookie(t)}}); 922} 923 924 925/** 926 * Icegram Message Type - Popup 927 **/ 928 function Icegram_Message_Type_Popup( data ) { 929 Icegram_Message_Type.apply(this, arguments); 930} 931Icegram_Message_Type_Popup.prototype = Object.create(Icegram_Message_Type.prototype); 932Icegram_Message_Type_Popup.prototype.constructor = Icegram_Message_Type_Popup; 933 934Icegram_Message_Type_Popup.prototype.get_template_default = function () { 935 return '<div id="icegram_message_{{=id}}" class="icegram ig_popup ig_{{=theme}} ig_container mfp-hide">'+ 936 '<div class="ig_close" id="popup_box_close_{{=id}}"></div>'+ 937 '<div class="ig_clear_fix" data={{=id}}>'+ 938 '<div class="ig_bg_overlay"></div>'+ 939 '<div class="ig_form_container layout_left"></div>'+ 940 '<div class="ig_data ig_clear_fix">'+ 941 '<div class="ig_headline">{{=headline}}</div>'+ 942 '<div class="ig_content">'+ 943 '<div class="ig_message ig_clear_fix">{{=message}}</div>'+ 944 '</div>'+ 945 '<div class="ig_button" >{{=label}}</div>'+ 946 '</div>'+ 947 '<div class="ig_form_container layout_right layout_bottom"></div>'+ 948 '</div>'+ 949 '</div>'; 950}; 951 952Icegram_Message_Type_Popup.prototype.post_render = function ( ) { 953 //Calling parent post_render function 954 Icegram_Message_Type.prototype.post_render.apply(this, arguments); 955 956 if(this.data.use_theme_defaults == undefined || this.data.use_theme_defaults != 'yes'){ 957 if (this.data.bg_color != undefined && this.data.bg_color != '') { 958 // TODO :: test all popup themes with bg overlay 959 // this.el.find('.ig_bg_overlay').css('background-color', this.data.bg_color).css('border-color', this.data.bg_color); 960 this.el.find('.ig_bg_overlay').css('border-color', this.data.bg_color); 961 } 962 } 963}; 964 965Icegram_Message_Type_Popup.prototype.show = function ( options, silent ) { 966 if ( this.is_visible() ) return; 967 var self = this; 968 var popup_id = '#icegram_message_'+this.data.id; 969 this.animate('in'); 970 window.ig_popup = jQuery.magnificPopup; 971 window.ig_popup.open({ 972 items: { 973 src: popup_id, 974 type: 'inline' 975 }, 976 // mainClass: 'ig_this_message_root_'+this.data.id, 977 showCloseBtn :false, 978 callbacks: { 979 close: function() {
980 // Will fire when popup is closed 981 silent !== true && self.track( 'closed' ); 982 self.el.removeClass('ig_show'); 983 }, 984 open: function(){ 985 window.icegram.adjustFormContainerHeight(self); 986 } 987 } 988 }); 989 self.el.addClass('ig_show').removeClass('ig_hide'); 990 silent !== true && this.track( 'shown' ); 991}; 992 993Icegram_Message_Type_Popup.prototype.add_powered_by = function ( pb ) { 994 setTimeout( function() { 995 jQuery('.mfp-wrap').append('<div class="ig_powered_by"><a href="'+pb.link+'" target="_blank">'+pb.text+'</a></div>'); 996 },1000 + this.data.delay_time * 1000); 997}; 998 999Icegram_Message_Type_Popup.prototype.hide = function ( options, silent ) { 1000 if ( !this.is_visible() ) return; 1001 var popup_id = '#icegram_message_'+this.data.id; 1002 var self = this; 1003 this.animate('out'); 1004 setTimeout( function() { 1005 self.el.addClass('ig_hide').removeClass('ig_show'); 1006 jQuery.magnificPopup.close({ items: { 1007 src: popup_id, 1008 type: 'inline' 1009 }})} , 500); 1010}; 1011 1012// Magnific Popup v1.0.0 by Dmitry Semenov 1013// http://bit.ly/magnific-popup#build=inline+image+retina 1014if(typeof(window.ig_popup) === 'undefined'){ 1015 (function(a){typeof define=="function"&&define.amd?define(["jquery"],a):typeof exports=="object"?a(require("jquery")):a(window.jQuery||window.Zepto)})(function(a){var b="Close",c="BeforeClose",d="AfterClose",e="BeforeAppend",f="MarkupParse",g="Open",h="Change",i="mfp",j="."+i,k="mfp-ready",l="mfp-removing",m="mfp-prevent-close",n,o=function(){},p=!!window.jQuery,q,r=a(window),s,t,u,v,w=function(a,b){n.ev.on(i+a+j,b)},x=function(b,c,d,e){var f=document.createElement("div");return f.className="mfp-"+b,d&&(f.innerHTML=d),e?c&&c.appendChild(f):(f=a(f),c&&f.appendTo(c)),f},y=function(b,c){n.ev.triggerHandler(i+b,c),n.st.callbacks&&(b=b.charAt(0).toLowerCase()+b.slice(1),n.st.callbacks[b]&&n.st.callbacks[b].apply(n,a.isArray(c)?c:[c]))},z=function(b){if(b!==v||!n.currTemplate.closeBtn)n.currTemplate.closeBtn=a(n.st.closeMarkup.replace("%title%",n.st.tClose)),v=b;return n.currTemplate.closeBtn},A=function(){a.magnificPopup.instance||(n=new o,n.init(),a.magnificPopup.instance=n)},B=function(){var a=document.createElement("p").style,b=["ms","O","Moz","Webkit"];if(a.transition!==undefined)return!0;while(b.length)if(b.pop()+"Transition"in a)return!0;return!1};o.prototype={constructor:o,init:function(){var b=navigator.appVersion;n.isIE7=b.indexOf("MSIE 7.")!==-1,n.isIE8=b.indexOf("MSIE 8.")!==-1,n.isLowIE=n.isIE7||n.isIE8,n.isAndroid=/android/gi.test(b),n.isIOS=/iphone|ipad|ipod/gi.test(b),n.supportsTransition=B(),n.probablyMobile=n.isAndroid||n.isIOS||/(Opera Mini)|Kindle|webOS|BlackBerry|(Opera Mobi)|(Windows Phone)|IEMobile/i.test(navigator.userAgent),s=a(document),n.popupsCache={}},open:function(b){var c;if(b.isObj===!1){n.items=b.items.toArray(),n.index=0;var d=b.items,e;for(c=0;c<d.length;c++){e=d[c],e.parsed&&(e=e.el[0]);if(e===b.el[0]){n.index=c;break}}}else n.items=a.isArray(b.items)?b.items:[b.items],n.index=b.index||0;if(n.isOpen){n.updateItemHTML();return}n.types=[],u="",b.mainEl&&b.mainEl.length?n.ev=b.mainEl.eq(0):n.ev=s,b.key?(n.popupsCache[b.key]||(n.popupsCache[b.key]={}),n.currTemplate=n.popupsCache[b.key]):n.currTemplate={},n.st=a.extend(!0,{},a.magnificPopup.defaults,b),n.fixedContentPos=n.st.fixedContentPos==="auto"?!n.probablyMobile:n.st.fixedContentPos,n.st.modal&&(n.st.closeOnContentClick=!1,n.st.closeOnBgClick=!1,n.st.showCloseBtn=!1,n.st.enableEscapeKey=!1),n.bgOverlay||(n.bgOverlay=x("bg").on("click"+j,function(){n.close()}),n.wrap=x("wrap").attr("tabindex",-1).on("click"+j,function(a){n._checkIfClose(a.target)&&n.close()}),n.container=x("container",n.wrap)),n.contentContainer=x("content"),n.st.preloader&&(n.preloader=x("preloader",n.container,n.st.tLoading));var h=a.magnificPopup.modules;for(c=0;c<h.length;c++){var i=h[c];i=i.charAt(0).toUpperCase()+i.slice(1),n["init"+i].call(n)}y("BeforeOpen"),n.st.showCloseBtn&&(n.st.closeBtnInside?(w(f,function(a,b,c,d){c.close_replaceWith=z(d.type)}),u+=" mfp-close-btn-in"):n.wrap.append(z())),n.st.alignTop&&(u+=" mfp-align-top"),n.fixedContentPos?n.wrap.css({overflow:n.st.overflowY,overflowX:"hidden",overflowY:n.st.overflowY}):n.wrap.css({top:r.scrollTop(),position:"absolute"}),(n.st.fixedBgPos===!1||n.st.fixedBgPos==="auto"&&!n.fixedContentPos)&&n.bgOverlay.css({height:s.height(),position:"absolute"}),n.st.enableEscapeKey&&s.on("keyup"+j,function(a){a.keyCode===27&&n.close()}),r.on("resize"+j,function(){n.updateSize()}),n.st.closeOnContentClick||(u+=" mfp-auto-cursor"),u&&n.wrap.addClass(u);var l=n.wH=r.height(),m={};if(n.fixedContentPos&&n._hasScrollBar(l)){var o=n._getScrollbarSize();o&&(m.marginRight=o)}n.fixedContentPos&&(n.isIE7?a("body, html").css("overflow","hidden"):m.overflow="hidden");var p=n.st.mainClass;return n.isIE7&&(p+=" mfp-ie7"),p&&n._addClassToMFP(p),n.updateItemHTML(),y("BuildControls"),a("html").css(m),n.bgOverlay.add(n.wrap).prependTo(n.st.prepe
1015ndTo||a(document.body)),n._lastFocusedEl=document.activeElement,setTimeout(function(){n.content?(n._addClassToMFP(k),n._setFocus()):n.bgOverlay.addClass(k),s.on("focusin"+j,n._onFocusIn)},16),n.isOpen=!0,n.updateSize(l),y(g),b},close:function(){if(!n.isOpen)return;y(c),n.isOpen=!1,n.st.removalDelay&&!n.isLowIE&&n.supportsTransition?(n._addClassToMFP(l),setTimeout(function(){n._close()},n.st.removalDelay)):n._close()},_close:function(){y(b);var c=l+" "+k+" ";n.bgOverlay.detach(),n.wrap.detach(),n.container.empty(),n.st.mainClass&&(c+=n.st.mainClass+" "),n._removeClassFromMFP(c);if(n.fixedContentPos){var e={marginRight:""};n.isIE7?a("body, html").css("overflow",""):e.overflow="",a("html").css(e)}s.off("keyup"+j+" focusin"+j),n.ev.off(j),n.wrap.attr("class","mfp-wrap").removeAttr("style"),n.bgOverlay.attr("class","mfp-bg"),n.container.attr("class","mfp-container"),n.st.showCloseBtn&&(!n.st.closeBtnInside||n.currTemplate[n.currItem.type]===!0)&&n.currTemplate.closeBtn&&n.currTemplate.closeBtn.detach(),n._lastFocusedEl&&a(n._lastFocusedEl).focus(),n.currItem=null,n.content=null,n.currTemplate=null,n.prevHeight=0,y(d)},updateSize:function(a){if(n.isIOS){var b=document.documentElement.clientWidth/window.innerWidth,c=window.innerHeight*b;n.wrap.css("height",c),n.wH=c}else n.wH=a||r.height();n.fixedContentPos||n.wrap.css("height",n.wH),y("Resize")},updateItemHTML:function(){var b=n.items[n.index];n.contentContainer.detach(),n.content&&n.content.detach(),b.parsed||(b=n.parseEl(n.index));var c=b.type;y("BeforeChange",[n.currItem?n.currItem.type:"",c]),n.currItem=b;if(!n.currTemplate[c]){var d=n.st[c]?n.st[c].markup:!1;y("FirstMarkupParse",d),d?n.currTemplate[c]=a(d):n.currTemplate[c]=!0}t&&t!==b.type&&n.container.removeClass("mfp-"+t+"-holder");var e=n["get"+c.charAt(0).toUpperCase()+c.slice(1)](b,n.currTemplate[c]);n.appendContent(e,c),b.preloaded=!0,y(h,b),t=b.type,n.container.prepend(n.contentContainer),y("AfterChange")},appendContent:function(a,b){n.content=a,a?n.st.showCloseBtn&&n.st.closeBtnInside&&n.currTemplate[b]===!0?n.content.find(".mfp-close").length||n.content.append(z()):n.content=a:n.content="",y(e),n.container.addClass("mfp-"+b+"-holder"),n.contentContainer.append(n.content)},parseEl:function(b){var c=n.items[b],d;c.tagName?c={el:a(c)}:(d=c.type,c={data:c,src:c.src});if(c.el){var e=n.types;for(var f=0;f<e.length;f++)if(c.el.hasClass("mfp-"+e[f])){d=e[f];break}c.src=c.el.attr("data-mfp-src"),c.src||(c.src=c.el.attr("href"))}return c.type=d||n.st.type||"inline",c.index=b,c.parsed=!0,n.items[b]=c,y("ElementParse",c),n.items[b]},addGroup:function(a,b){var c=function(c){c.mfpEl=this,n._openClick(c,a,b)};b||(b={});var d="click.magnificPopup";b.mainEl=a,b.items?(b.isObj=!0,a.off(d).on(d,c)):(b.isObj=!1,b.delegate?a.off(d).on(d,b.delegate,c):(b.items=a,a.off(d).on(d,c)))},_openClick:function(b,c,d){var e=d.midClick!==undefined?d.midClick:a.magnificPopup.defaults.midClick;if(!e&&(b.which===2||b.ctrlKey||b.metaKey))return;var f=d.disableOn!==undefined?d.disableOn:a.magnificPopup.defaults.disableOn;if(f)if(a.isFunction(f)){if(!f.call(n))return!0}else if(r.width()<f)return!0;b.type&&(b.preventDefault(),n.isOpen&&b.stopPropagation()),d.el=a(b.mfpEl),d.delegate&&(d.items=c.find(d.delegate)),n.open(d)},updateStatus:function(a,b){if(n.preloader){q!==a&&n.container.removeClass("mfp-s-"+q),!b&&a==="loading"&&(b=n.st.tLoading);var c={status:a,text:b};y("UpdateStatus",c),a=c.status,b=c.text,n.preloader.html(b),n.preloader.find("a").on("click",function(a){a.stopImmediatePropagation()}),n.container.addClass("mfp-s-"+a),q=a}},_checkIfClose:function(b){if(a(b).hasClass(m))return;var c=n.st.closeOnContentClick,d=n.st.closeOnBgClick;if(c&&d)return!0;if(!n.content||a(b).hasClass("mfp-close")||n.preloader&&b===n.preloader[0])return!0;if(b!==n.content[0]&&!a.contains(n.content[0],b)){if(d&&a.contains(document,b))return!0}else if(c)return!0;return!1},_addClassToMFP:function(a){n.bgOverlay.addClass(a),n.wrap.addClass(a)},_removeClassFromMFP:function(a){this.bgOverlay.removeClass(a),n.wrap.removeClass(a)},_hasScrollBar:function(a){return(n.isIE7?s.height():document.body.scrollHeight)>
1015(a||r.height())},_setFocus:function(){(n.st.focus?n.content.find(n.st.focus).eq(0):n.wrap).focus()},_onFocusIn:function(b){if(b.target!==n.wrap[0]&&!a.contains(n.wrap[0],b.target))return n._setFocus(),!1},_parseMarkup:function(b,c,d){var e;d.data&&(c=a.extend(d.data,c)),y(f,[b,c,d]),a.each(c,function(a,c){if(c===undefined||c===!1)return!0;e=a.split("_");if(e.length>1){var d=b.find(j+"-"+e[0]);if(d.length>0){var f=e[1];f==="replaceWith"?d[0]!==c[0]&&d.replaceWith(c):f==="img"?d.is("img")?d.attr("src",c):d.replaceWith('<img src="'+c+'" class="'+d.attr("class")+'" />'):d.attr(e[1],c)}}else b.find(j+"-"+a).html(c)})},_getScrollbarSize:function(){if(n.scrollbarSize===undefined){var a=document.createElement("div");a.style.cssText="width: 99px; height: 99px; overflow: scroll; position: absolute; top: -9999px;",document.body.appendChild(a),n.scrollbarSize=a.offsetWidth-a.clientWidth,document.body.removeChild(a)}return n.scrollbarSize}},a.magnificPopup={instance:null,proto:o.prototype,modules:[],open:function(b,c){return A(),b?b=a.extend(!0,{},b):b={},b.isObj=!0,b.index=c||0,this.instance.open(b)},close:function(){return a.magnificPopup.instance&&a.magnificPopup.instance.close()},registerModule:function(b,c){c.options&&(a.magnificPopup.defaults[b]=c.options),a.extend(this.proto,c.proto),this.modules.push(b)},defaults:{disableOn:0,key:null,midClick:!1,mainClass:"",preloader:!0,focus:"",closeOnContentClick:!1,closeOnBgClick:!0,closeBtnInside:!0,showCloseBtn:!0,enableEscapeKey:!0,modal:!1,alignTop:!1,removalDelay:0,prependTo:null,fixedContentPos:"auto",fixedBgPos:"auto",overflowY:"auto",closeMarkup:'<button title="%title%" type="button" class="mfp-close">×</button>',tClose:"Close (Esc)",tLoading:"Loading..."}},a.fn.magnificPopup=function(b){A();var c=a(this);if(typeof b=="string")if(b==="open"){var d,e=p?c.data("magnificPopup"):c[0].magnificPopup,f=parseInt(arguments[1],10)||0;e.items?d=e.items[f]:(d=c,e.delegate&&(d=d.find(e.delegate)),d=d.eq(f)),n._openClick({mfpEl:d},c,e)}else n.isOpen&&n[b].apply(n,Array.prototype.slice.call(arguments,1));else b=a.extend(!0,{},b),p?c.data("magnificPopup",b):c[0].magnificPopup=b,n.addGroup(c,b);return c};var C="inline",D,E,F,G=function(){F&&(E.after(F.addClass(D)).detach(),F=null)};a.magnificPopup.registerModule(C,{options:{hiddenClass:"hide",markup:"",tNotFound:"Content not found"},proto:{initInline:function(){n.types.push(C),w(b+"."+C,function(){G()})},getInline:function(b,c){G();if(b.src){var d=n.st.inline,e=a(b.src);if(e.length){var f=e[0].parentNode;f&&f.tagName&&(E||(D=d.hiddenClass,E=x(D),D="mfp-"+D),F=e.after(E).detach().removeClass(D)),n.updateStatus("ready")}else n.updateStatus("error",d.tNotFound),e=a("<div>");return b.inlineElement=e,e}return n.updateStatus("ready"),n._parseMarkup(c,{},b),c}}});var H,I=function(b){if(b.data&&b.data.title!==undefined)return b.data.title;var c=n.st.image.titleSrc;if(c){if(a.isFunction(c))return c.call(n,b);if(b.el)return b.el.attr(c)||""}return""};a.magnificPopup.registerModule("image",{options:{markup:'<div class="mfp-figure"><div class="mfp-close"></div><figure><div class="mfp-img"></div><figcaption><div class="mfp-bottom-bar"><div class="mfp-title"></div><div class="mfp-counter"></div></div></figcaption></figure></div>',cursor:"mfp-zoom-out-cur",titleSrc:"title",verticalFit:!0,tError:'<a href="%url%">The image</a> could not be loaded.'},proto:{initImage:function(){var c=n.st.image,d=".image";n.types.push("image"),w(g+d,function(){n.currItem.type==="image"&&c.cursor&&a(document.body).addClass(c.cursor)}),w(b+d,function(){c.cursor&&a(document.body).removeClass(c.cursor),r.off("resize"+j)}),w("Resize"+d,n.resizeImage),n.isLowIE&&w("AfterChange",n.resizeImage)},resizeImage:function(){var a=n.currItem;if(!a||!a.img)return;if(n.st.image.verticalFit){var b=0;n.isLowIE&&(b=parseInt(a.img.css("padding-top"),10)+parseInt(a.img.css("padding-bottom"),10)),a.img.css("max-height",n.wH-b)}},_onImageHasSize:function(a){a.img&&(a.hasSize=!0,H&&clearInterval(H),a.isCheckingImgSize=!1,y("ImageHasSize",a),a.imgHidden&&(n.content&&n.content.removeClass("mfp-loading"),a.imgHidden=!1))},findImageSize:function(a){var b=0,c=a.img[0],d=function(e){H&&clearInterval(H),H=setInterval(function(){if(c.naturalWi
1015dth>0){n._onImageHasSize(a);return}b>200&&clearInterval(H),b++,b===3?d(10):b===40?d(50):b===100&&d(500)},e)};d(1)},getImage:function(b,c){var d=0,e=function(){b&&(b.img[0].complete?(b.img.off(".mfploader"),b===n.currItem&&(n._onImageHasSize(b),n.updateStatus("ready")),b.hasSize=!0,b.loaded=!0,y("ImageLoadComplete")):(d++,d<200?setTimeout(e,100):f()))},f=function(){b&&(b.img.off(".mfploader"),b===n.currItem&&(n._onImageHasSize(b),n.updateStatus("error",g.tError.replace("%url%",b.src))),b.hasSize=!0,b.loaded=!0,b.loadError=!0)},g=n.st.image,h=c.find(".mfp-img");if(h.length){var i=document.createElement("img");i.className="mfp-img",b.el&&b.el.find("img").length&&(i.alt=b.el.find("img").attr("alt")),b.img=a(i).on("load.mfploader",e).on("error.mfploader",f),i.src=b.src,h.is("img")&&(b.img=b.img.clone()),i=b.img[0],i.naturalWidth>0?b.hasSize=!0:i.width||(b.hasSize=!1)}return n._parseMarkup(c,{title:I(b),img_replaceWith:b.img},b),n.resizeImage(),b.hasSize?(H&&clearInterval(H),b.loadError?(c.addClass("mfp-loading"),n.updateStatus("error",g.tError.replace("%url%",b.src))):(c.removeClass("mfp-loading"),n.updateStatus("ready")),c):(n.updateStatus("loading"),b.loading=!0,b.hasSize||(b.imgHidden=!0,c.addClass("mfp-loading"),n.findImageSize(b)),c)}}});var J,K=function(){return J===undefined&&(J=document.createElement("p").style.MozTransform!==undefined),J};a.magnificPopup.registerModule("zoom",{options:{enabled:!1,easing:"ease-in-out",duration:300,opener:function(a){return a.is("img")?a:a.find("img")}},proto:{initZoom:function(){var a=n.st.zoom,d=".zoom",e;if(!a.enabled||!n.supportsTransition)return;var f=a.duration,g=function(b){var c=b.clone().removeAttr("style").removeAttr("class").addClass("mfp-animated-image"),d="all "+a.duration/1e3+"s "+a.easing,e={position:"fixed",zIndex:9999,left:0,top:0,"-webkit-backface-visibility":"hidden"},f="transition";return e["-webkit-"+f]=e["-moz-"+f]=e["-o-"+f]=e[f]=d,c.css(e),c},h=function(){n.content.css("visibility","visible")},i,j;w("BuildControls"+d,function(){if(n._allowZoom()){clearTimeout(i),n.content.css("visibility","hidden"),e=n._getItemToZoom();if(!e){h();return}j=g(e),j.css(n._getOffset()),n.wrap.append(j),i=setTimeout(function(){j.css(n._getOffset(!0)),i=setTimeout(function(){h(),setTimeout(function(){j.remove(),e=j=null,y("ZoomAnimationEnded")},16)},f)},16)}}),w(c+d,function(){if(n._allowZoom()){clearTimeout(i),n.st.removalDelay=f;if(!e){e=n._getItemToZoom();if(!e)return;j=g(e)}j.css(n._getOffset(!0)),n.wrap.append(j),n.content.css("visibility","hidden"),setTimeout(function(){j.css(n._getOffset())},16)}}),w(b+d,function(){n._allowZoom()&&(h(),j&&j.remove(),e=null)})},_allowZoom:function(){return n.currItem.type==="image"},_getItemToZoom:function(){return n.currItem.hasSize?n.currItem.img:!1},_getOffset:function(b){var c;b?c=n.currItem.img:c=n.st.zoom.opener(n.currItem.el||n.currItem);var d=c.offset(),e=parseInt(c.css("padding-top"),10),f=parseInt(c.css("padding-bottom"),10);d.top-=a(window).scrollTop()-e;var g={width:c.width(),height:(p?c.innerHeight():c[0].offsetHeight)-f-e};return K()?g["-moz-transform"]=g.transform="translate("+d.left+"px,"+d.top+"px)":(g.left=d.left,g.top=d.top),g}}});var L="retina";a.magnificPopup.registerModule(L,{options:{replaceSrc:function(a){return a.src.replace(/\.\w+$/,function(a){return"@2x"+a})},ratio:1},proto:{initRetina:function(){if(window.devicePixelRatio>1){var a=n.st.retina,b=a.ratio;b=isNaN(b)?b():b,b>1&&(w("ImageHasSize."+L,function(a,c){c.img.css({"max-width":c.img[0].naturalWidth/b,width:"100%"})}),w("ElementParse."+L,function(c,d){d.src=a.replaceSrc(d,b)}))}}}}),A()}); 1016 1017}
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.