(function () { var require = undefined; var module = undefined; var exports = undefined; var define = undefined; (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o -1; // print message when test mode is enabled if( isLoggedIn && options.testMode ) { console.log( 'Boxzilla: Test mode is enabled. Please disable test mode if you\'re done testing.' ); } // init boxzilla Boxzilla.init(); // create boxes from options for( var i=0; i < options.boxes.length; i++ ) { // get opts var boxOpts = options.boxes[i]; boxOpts.testMode = isLoggedIn && options.testMode; // fix http:// links in box content.... if( window.location.origin.substring(0, 5) === "https" ) { boxOpts.content = boxOpts.content.replace(window.location.origin.replace("https", "http"), window.location.origin); } // create box var box = Boxzilla.create( boxOpts.id, boxOpts); // add custom css to box css(box.element, boxOpts.css); } // helper function for setting CSS styles function css(element, styles) { if( styles.background_color ) { element.style.background = styles.background_color; } if( styles.color ) { element.style.color = styles.color; } if( styles.border_color ) { element.style.borderColor = styles.border_color; } if( styles.border_width ) { element.style.borderWidth = parseInt(styles.border_width) + "px"; } if( styles.border_style ) { element.style.borderStyle = styles.border_style; } if( styles.width ) { element.style.maxWidth = parseInt(styles.width) + "px"; } } /** * If a MailChimp for WordPress form was submitted, open the box containing that form (if any) * * TODO: Just set location hash from MailChimp for WP? */ window.addEventListener('load', function() { if( typeof(window.mc4wp_forms_config) === "object" && window.mc4wp_forms_config.submitted_form ) { var selector = '#' + window.mc4wp_forms_config.submitted_form.element_id; var boxes = Boxzilla.boxes; for( var boxId in boxes ) { if(!boxes.hasOwnProperty(boxId)) { continue; } var box = boxes[boxId]; if( box.element.querySelector(selector)) { box.show(); return; } } } }); window.Boxzilla = Boxzilla; },{"boxzilla":3}],2:[function(require,module,exports){ 'use strict'; var $ = window.jQuery, defaults = { 'animation': 'fade', 'rehide': false, 'content': '', 'cookieTime': 0, 'icon': '×', 'minimumScreenWidth': 0, 'position': 'center', 'testMode': false, 'trigger': false, 'closable': true }, Boxzilla; /** * Merge 2 objects, values of the latter overwriting the former. * * @param obj1 * @param obj2 * @returns {*} */ function merge( obj1, obj2 ) { var obj3 = {}; for (var attrname in obj1) { obj3[attrname] = obj1[attrname]; } for (var attrname in obj2) { obj3[attrname] = obj2[attrname]; } return obj3; } // Box Object var Box = function( id, config ) { this.id = id; // store config values this.config = merge(defaults, config); // store ref to overlay this.overlay = document.getElementById('boxzilla-overlay'); // state this.visible = false; this.closed = false; this.triggered = false; this.triggerHeight = 0; this.cookieSet = false; // if a trigger was given, calculate values once and store if( this.config.trigger ) { if( this.config.trigger.method === 'percentage' || this.config.trigger.method === 'element' ) { this.triggerHeight = this.calculateTriggerHeight(); } this.cookieSet = this.isCookieSet(); } // create dom element for this box this.element = this.dom(); this.$element = $(this.element); // further initialise the box this.events(); }; // initialise the box Box.prototype.events = function() { var box = this; // attach event to "close" icon inside box this.$element.find('.boxzilla-close-icon').click(box.dismiss.bind(this)); this.$element.on('click', 'a', function(e) { Boxzilla.trigger('box.interactions.link', [ box, e.target ] ); }); this.$element.on('submit', 'form', function(e) { box.setCookie(); Boxzilla.trigger('box.interactions.form', [ box, e.target ]); }); // attach event to all links referring #boxzilla-{box_id} $(document.body).on('click', 'a[href="#boxzilla-' + box.id + '"]', function() { box.toggle(); return false; }); // maybe show box right away if( this.fits() && this.locationHashRefersBox() ) { $(window).load(this.show.bind(this)); } }; // generate dom elements for this box Box.prototype.dom = function() { var wrapper = document.createElement('div'); wrapper.className = 'boxzilla-container boxzilla-' + this.config.position + '-container'; var box = document.createElement('div'); box.setAttribute('id', 'boxzilla-' + this.id); box.className = 'boxzilla boxzilla-' + this.id + ' boxzilla-' + this.config.position; box.style.display = 'none'; wrapper.appendChild(box); var content = document.createElement('div'); content.className = 'boxzilla-content'; content.innerHTML = this.config.content; box.appendChild(content); // remove