Version Description
Download this release
Release Info
Developer | DvanKooten |
Plugin | Boxzilla |
Version | 3.2.21 |
Comparing to | |
See all releases |
Code changes from version 3.2.20 to 3.2.21
- CHANGELOG.md +5 -0
- assets/js/admin-script.js +176 -183
- assets/js/admin-script.min.js +1 -1
- assets/js/admin-script.min.js.map +1 -1
- assets/js/script.js +171 -662
- assets/js/script.min.js +1 -1
- assets/js/script.min.js.map +1 -1
- boxzilla.php +3 -3
- readme.txt +6 -1
- src/class-loader.php +2 -2
CHANGELOG.md
CHANGED
@@ -1,6 +1,11 @@
|
|
1 |
Changelog
|
2 |
==========
|
3 |
|
|
|
|
|
|
|
|
|
|
|
4 |
#### 3.2.20 - Jan 20, 2020
|
5 |
|
6 |
**Fixes**
|
1 |
Changelog
|
2 |
==========
|
3 |
|
4 |
+
#### 3.2.21 - Feb 18, 2020
|
5 |
+
|
6 |
+
- "If post category" or "if post tag" conditionals now apply to any post-type using built-in WP categories or tags.
|
7 |
+
|
8 |
+
|
9 |
#### 3.2.20 - Jan 20, 2020
|
10 |
|
11 |
**Fixes**
|
assets/js/admin-script.js
CHANGED
@@ -6,175 +6,168 @@ window.Boxzilla_Admin = require('./admin/_admin.js');
|
|
6 |
},{"./admin/_admin.js":2}],2:[function(require,module,exports){
|
7 |
"use strict";
|
8 |
|
9 |
-
|
10 |
-
'use strict';
|
11 |
-
|
12 |
-
var $ = window.jQuery;
|
13 |
|
14 |
-
|
15 |
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
|
20 |
-
|
21 |
-
return;
|
22 |
-
}
|
23 |
|
24 |
-
|
25 |
|
26 |
-
|
27 |
|
28 |
-
|
|
|
|
|
|
|
|
|
29 |
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
|
35 |
-
$optionControls.on('click',
|
36 |
-
$optionControls.on('click',
|
37 |
-
$optionControls.on('change',
|
38 |
$optionControls.find('.boxzilla-auto-show-trigger').on('change', toggleTriggerOptions);
|
39 |
$(ruleComparisonEl).change(toggleAndOrTexts);
|
40 |
-
$(window).load(function () {
|
41 |
-
if (typeof window.tinyMCE === "undefined") {
|
42 |
-
document.getElementById('notice-notinymce').style.display = '';
|
43 |
-
}
|
44 |
-
}); // call contextual helper method for each row
|
45 |
-
|
46 |
$('.boxzilla-rule-row').each(setContextualHelpers);
|
|
|
47 |
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
|
57 |
-
|
58 |
-
|
59 |
|
60 |
-
|
61 |
|
62 |
-
|
63 |
-
|
64 |
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
$(context.querySelectorAll('.boxzilla-helper')).remove(); // prepare better input
|
74 |
-
|
75 |
-
betterInput.removeAttribute('name');
|
76 |
-
betterInput.className = betterInput.className + ' boxzilla-helper';
|
77 |
-
valueInput.parentNode.insertBefore(betterInput, valueInput.nextSibling);
|
78 |
-
$betterInput.change(function () {
|
79 |
-
valueInput.value = this.value;
|
80 |
-
});
|
81 |
-
betterInput.style.display = '';
|
82 |
-
valueInput.style.display = 'none';
|
83 |
-
qualifierInput.style.display = '';
|
84 |
-
qualifierInput.querySelector('option[value="not_contains"]').style.display = 'none';
|
85 |
-
qualifierInput.querySelector('option[value="contains"]').style.display = 'none';
|
86 |
-
|
87 |
-
if (tnLoggedIn.parentNode) {
|
88 |
-
tnLoggedIn.parentNode.removeChild(tnLoggedIn);
|
89 |
-
} // change placeholder for textual help
|
90 |
-
|
91 |
-
|
92 |
-
switch (condition) {
|
93 |
-
default:
|
94 |
-
betterInput.placeholder = i18n.enterCommaSeparatedValues;
|
95 |
-
break;
|
96 |
-
|
97 |
-
case '':
|
98 |
-
case 'everywhere':
|
99 |
-
qualifierInput.value = '1';
|
100 |
-
valueInput.value = '';
|
101 |
-
betterInput.style.display = 'none';
|
102 |
-
qualifierInput.style.display = 'none';
|
103 |
-
break;
|
104 |
-
|
105 |
-
case 'is_single':
|
106 |
-
case 'is_post':
|
107 |
-
betterInput.placeholder = i18n.enterCommaSeparatedPosts;
|
108 |
-
$betterInput.suggest(ajaxurl + "?action=boxzilla_autocomplete&type=post", {
|
109 |
-
multiple: true,
|
110 |
-
multipleSep: ","
|
111 |
-
});
|
112 |
-
break;
|
113 |
|
114 |
-
|
115 |
-
betterInput.placeholder = i18n.enterCommaSeparatedPages;
|
116 |
-
$betterInput.suggest(ajaxurl + "?action=boxzilla_autocomplete&type=page", {
|
117 |
-
multiple: true,
|
118 |
-
multipleSep: ","
|
119 |
-
});
|
120 |
-
break;
|
121 |
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
|
|
149 |
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
154 |
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
|
|
170 |
}
|
|
|
171 |
|
172 |
-
|
173 |
-
|
174 |
-
'
|
175 |
-
'
|
176 |
};
|
177 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
178 |
|
179 |
},{"./_designer.js":3,"./_option.js":4,"wolfy87-eventemitter":5}],3:[function(require,module,exports){
|
180 |
"use strict";
|
@@ -183,43 +176,43 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat
|
|
183 |
|
184 |
var Designer = function Designer($, Option, events) {
|
185 |
// vars
|
186 |
-
var boxId = document.getElementById('post_ID').value || 0
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
var $appearanceControls = $(
|
193 |
-
|
194 |
-
options.borderColor = new Option('border-color');
|
195 |
-
options.borderWidth = new Option('border-width');
|
196 |
-
options.borderStyle = new Option('border-style');
|
197 |
-
options.backgroundColor = new Option('background-color');
|
198 |
-
options.width = new Option('width');
|
199 |
-
options.color = new Option('color'); // functions
|
200 |
|
201 |
function init() {
|
202 |
// Only run if TinyMCE has actually inited
|
203 |
-
if (_typeof(window.tinyMCE) !==
|
204 |
return;
|
205 |
-
} //
|
|
|
206 |
|
|
|
|
|
|
|
|
|
|
|
|
|
207 |
|
208 |
-
$editorFrame = $(
|
209 |
$editor = $editorFrame.contents().find('html');
|
210 |
$editor.css({
|
211 |
-
|
212 |
}); // add content class and padding to TinyMCE <body>
|
213 |
|
214 |
$innerEditor = $editor.find('#tinymce');
|
215 |
$innerEditor.addClass('boxzilla boxzilla-' + boxId);
|
216 |
$innerEditor.css({
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
'min-width': '240px',
|
222 |
-
|
223 |
});
|
224 |
$innerEditor.get(0).style.cssText += ';padding: 25px !important;';
|
225 |
visualEditorInitialised = true;
|
@@ -237,23 +230,23 @@ var Designer = function Designer($, Option, events) {
|
|
237 |
function applyStyles() {
|
238 |
if (!visualEditorInitialised) {
|
239 |
return false;
|
240 |
-
} // Apply styles from CSS editor.
|
241 |
// Use short timeout to make sure color values are updated.
|
242 |
|
243 |
|
244 |
window.setTimeout(function () {
|
245 |
$innerEditor.css({
|
246 |
'border-color': options.borderColor.getColorValue(),
|
247 |
-
//getColorValue( 'borderColor', '' ),
|
248 |
'border-width': options.borderWidth.getPxValue(),
|
249 |
-
//getPxValue( 'borderWidth', '' ),
|
250 |
'border-style': options.borderStyle.getValue(),
|
251 |
-
//getValue('borderStyle', '' ),
|
252 |
'background-color': options.backgroundColor.getColorValue(),
|
253 |
-
//getColorValue( 'backgroundColor', ''),
|
254 |
-
|
255 |
-
//getPxValue( 'width', 'auto' ),
|
256 |
-
|
257 |
|
258 |
});
|
259 |
/* @since 2.0.3 */
|
@@ -283,31 +276,31 @@ var Designer = function Designer($, Option, events) {
|
|
283 |
change: applyStyles,
|
284 |
clear: applyStyles
|
285 |
});
|
286 |
-
$appearanceControls.find(
|
287 |
events.on('editor.init', applyStyles); // public methods
|
288 |
|
289 |
return {
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
};
|
294 |
};
|
295 |
|
296 |
module.exports = Designer;
|
297 |
|
298 |
},{}],4:[function(require,module,exports){
|
299 |
-
|
300 |
|
301 |
var $ = window.jQuery;
|
302 |
|
303 |
var Option = function Option(element) {
|
304 |
// find corresponding element
|
305 |
-
if (typeof element
|
306 |
element = document.getElementById('boxzilla-' + element);
|
307 |
}
|
308 |
|
309 |
if (!element) {
|
310 |
-
console.error(
|
311 |
}
|
312 |
|
313 |
this.element = element;
|
@@ -327,7 +320,7 @@ Option.prototype.getColorValue = function () {
|
|
327 |
|
328 |
Option.prototype.getPxValue = function (fallbackValue) {
|
329 |
if (this.element.value.length > 0) {
|
330 |
-
return parseInt(this.element.value) +
|
331 |
}
|
332 |
|
333 |
return fallbackValue || '';
|
@@ -353,7 +346,7 @@ module.exports = Option;
|
|
353 |
|
354 |
},{}],5:[function(require,module,exports){
|
355 |
/*!
|
356 |
-
* EventEmitter v5.2.
|
357 |
* Unlicense - http://unlicense.org/
|
358 |
* Oliver Caldwell - https://oli.me.uk/
|
359 |
* @preserve
|
6 |
},{"./admin/_admin.js":2}],2:[function(require,module,exports){
|
7 |
"use strict";
|
8 |
|
9 |
+
var $ = window.jQuery;
|
|
|
|
|
|
|
10 |
|
11 |
+
var Option = require('./_option.js');
|
12 |
|
13 |
+
var optionControls = document.getElementById('boxzilla-box-options-controls');
|
14 |
+
var $optionControls = $(optionControls);
|
15 |
+
var tnLoggedIn = document.createTextNode(' logged in');
|
16 |
|
17 |
+
var EventEmitter = require('wolfy87-eventemitter');
|
|
|
|
|
18 |
|
19 |
+
var events = new EventEmitter();
|
20 |
|
21 |
+
var Designer = require('./_designer.js')($, Option, events);
|
22 |
|
23 |
+
var rowTemplate = window.wp.template('rule-row-template');
|
24 |
+
var i18n = window.boxzilla_i18n;
|
25 |
+
var ruleComparisonEl = document.getElementById('boxzilla-rule-comparison');
|
26 |
+
var rulesContainerEl = document.getElementById('boxzilla-box-rules');
|
27 |
+
var ajaxurl = window.ajaxurl; // events
|
28 |
|
29 |
+
$(window).load(function () {
|
30 |
+
if (typeof window.tinyMCE === 'undefined') {
|
31 |
+
document.getElementById('notice-notinymce').style.display = '';
|
32 |
+
}
|
33 |
|
34 |
+
$optionControls.on('click', '.boxzilla-add-rule', addRuleFields);
|
35 |
+
$optionControls.on('click', '.boxzilla-remove-rule', removeRule);
|
36 |
+
$optionControls.on('change', '.boxzilla-rule-condition', setContextualHelpers);
|
37 |
$optionControls.find('.boxzilla-auto-show-trigger').on('change', toggleTriggerOptions);
|
38 |
$(ruleComparisonEl).change(toggleAndOrTexts);
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
$('.boxzilla-rule-row').each(setContextualHelpers);
|
40 |
+
});
|
41 |
|
42 |
+
function toggleAndOrTexts() {
|
43 |
+
var newText = ruleComparisonEl.value === 'any' ? i18n.or : i18n.and;
|
44 |
+
$('.boxzilla-andor').text(newText);
|
45 |
+
}
|
46 |
|
47 |
+
function toggleTriggerOptions() {
|
48 |
+
$optionControls.find('.boxzilla-trigger-options').toggle(this.value !== '');
|
49 |
+
}
|
50 |
|
51 |
+
function removeRule() {
|
52 |
+
var row = $(this).parents('tr'); // delete andor row
|
53 |
|
54 |
+
row.prev().remove(); // delete rule row
|
55 |
|
56 |
+
row.remove();
|
57 |
+
}
|
58 |
|
59 |
+
function setContextualHelpers() {
|
60 |
+
var context = this.tagName.toLowerCase() === 'tr' ? this : $(this).parents('tr').get(0);
|
61 |
+
var condition = context.querySelector('.boxzilla-rule-condition').value;
|
62 |
+
var valueInput = context.querySelector('.boxzilla-rule-value');
|
63 |
+
var qualifierInput = context.querySelector('.boxzilla-rule-qualifier');
|
64 |
+
var betterInput = valueInput.cloneNode(true);
|
65 |
+
var $betterInput = $(betterInput); // remove previously added helpers
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
|
67 |
+
$(context.querySelectorAll('.boxzilla-helper')).remove(); // prepare better input
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
|
69 |
+
betterInput.removeAttribute('name');
|
70 |
+
betterInput.className = betterInput.className + ' boxzilla-helper';
|
71 |
+
valueInput.parentNode.insertBefore(betterInput, valueInput.nextSibling);
|
72 |
+
$betterInput.change(function () {
|
73 |
+
valueInput.value = this.value;
|
74 |
+
});
|
75 |
+
betterInput.style.display = '';
|
76 |
+
valueInput.style.display = 'none';
|
77 |
+
qualifierInput.style.display = '';
|
78 |
+
qualifierInput.querySelector('option[value="not_contains"]').style.display = 'none';
|
79 |
+
qualifierInput.querySelector('option[value="contains"]').style.display = 'none';
|
80 |
+
|
81 |
+
if (tnLoggedIn.parentNode) {
|
82 |
+
tnLoggedIn.parentNode.removeChild(tnLoggedIn);
|
83 |
+
} // change placeholder for textual help
|
84 |
+
|
85 |
+
|
86 |
+
switch (condition) {
|
87 |
+
default:
|
88 |
+
betterInput.placeholder = i18n.enterCommaSeparatedValues;
|
89 |
+
break;
|
90 |
+
|
91 |
+
case '':
|
92 |
+
case 'everywhere':
|
93 |
+
qualifierInput.value = '1';
|
94 |
+
valueInput.value = '';
|
95 |
+
betterInput.style.display = 'none';
|
96 |
+
qualifierInput.style.display = 'none';
|
97 |
+
break;
|
98 |
+
|
99 |
+
case 'is_single':
|
100 |
+
case 'is_post':
|
101 |
+
betterInput.placeholder = i18n.enterCommaSeparatedPosts;
|
102 |
+
$betterInput.suggest(ajaxurl + '?action=boxzilla_autocomplete&type=post', {
|
103 |
+
multiple: true,
|
104 |
+
multipleSep: ','
|
105 |
+
});
|
106 |
+
break;
|
107 |
|
108 |
+
case 'is_page':
|
109 |
+
betterInput.placeholder = i18n.enterCommaSeparatedPages;
|
110 |
+
$betterInput.suggest(ajaxurl + '?action=boxzilla_autocomplete&type=page', {
|
111 |
+
multiple: true,
|
112 |
+
multipleSep: ','
|
113 |
+
});
|
114 |
+
break;
|
115 |
|
116 |
+
case 'is_post_type':
|
117 |
+
betterInput.placeholder = i18n.enterCommaSeparatedPostTypes;
|
118 |
+
$betterInput.suggest(ajaxurl + '?action=boxzilla_autocomplete&type=post_type', {
|
119 |
+
multiple: true,
|
120 |
+
multipleSep: ','
|
121 |
+
});
|
122 |
+
break;
|
123 |
+
|
124 |
+
case 'is_url':
|
125 |
+
qualifierInput.querySelector('option[value="contains"]').style.display = '';
|
126 |
+
qualifierInput.querySelector('option[value="not_contains"]').style.display = '';
|
127 |
+
betterInput.placeholder = i18n.enterCommaSeparatedRelativeUrls;
|
128 |
+
break;
|
129 |
+
|
130 |
+
case 'is_post_in_category':
|
131 |
+
$betterInput.suggest(ajaxurl + '?action=boxzilla_autocomplete&type=category', {
|
132 |
+
multiple: true,
|
133 |
+
multipleSep: ','
|
134 |
+
});
|
135 |
+
break;
|
136 |
|
137 |
+
case 'is_post_with_tag':
|
138 |
+
$betterInput.suggest(ajaxurl + '?action=boxzilla_autocomplete&type=post_tag', {
|
139 |
+
multiple: true,
|
140 |
+
multipleSep: ','
|
141 |
+
});
|
142 |
+
break;
|
143 |
|
144 |
+
case 'is_user_logged_in':
|
145 |
+
betterInput.style.display = 'none';
|
146 |
+
valueInput.parentNode.insertBefore(tnLoggedIn, valueInput.nextSibling);
|
147 |
+
break;
|
148 |
+
|
149 |
+
case 'is_referer':
|
150 |
+
qualifierInput.querySelector('option[value="contains"]').style.display = '';
|
151 |
+
qualifierInput.querySelector('option[value="not_contains"]').style.display = '';
|
152 |
+
break;
|
153 |
}
|
154 |
+
}
|
155 |
|
156 |
+
function addRuleFields() {
|
157 |
+
var data = {
|
158 |
+
key: optionControls.querySelectorAll('.boxzilla-rule-row').length,
|
159 |
+
andor: ruleComparisonEl.value === 'any' ? i18n.or : i18n.and
|
160 |
};
|
161 |
+
var html = rowTemplate(data);
|
162 |
+
$(rulesContainerEl).append(html);
|
163 |
+
return false;
|
164 |
+
}
|
165 |
+
|
166 |
+
module.exports = {
|
167 |
+
Designer: Designer,
|
168 |
+
Option: Option,
|
169 |
+
events: events
|
170 |
+
};
|
171 |
|
172 |
},{"./_designer.js":3,"./_option.js":4,"wolfy87-eventemitter":5}],3:[function(require,module,exports){
|
173 |
"use strict";
|
176 |
|
177 |
var Designer = function Designer($, Option, events) {
|
178 |
// vars
|
179 |
+
var boxId = document.getElementById('post_ID').value || 0;
|
180 |
+
var $editor;
|
181 |
+
var $editorFrame;
|
182 |
+
var $innerEditor;
|
183 |
+
var options = {};
|
184 |
+
var visualEditorInitialised = false;
|
185 |
+
var $appearanceControls = $('#boxzilla-box-appearance-controls'); // functions
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
186 |
|
187 |
function init() {
|
188 |
// Only run if TinyMCE has actually inited
|
189 |
+
if (_typeof(window.tinyMCE) !== 'object' || window.tinyMCE.get('content') === null) {
|
190 |
return;
|
191 |
+
} // create Option objects
|
192 |
+
|
193 |
|
194 |
+
options.borderColor = new Option('border-color');
|
195 |
+
options.borderWidth = new Option('border-width');
|
196 |
+
options.borderStyle = new Option('border-style');
|
197 |
+
options.backgroundColor = new Option('background-color');
|
198 |
+
options.width = new Option('width');
|
199 |
+
options.color = new Option('color'); // add classes to TinyMCE <html>
|
200 |
|
201 |
+
$editorFrame = $('#content_ifr');
|
202 |
$editor = $editorFrame.contents().find('html');
|
203 |
$editor.css({
|
204 |
+
background: 'white'
|
205 |
}); // add content class and padding to TinyMCE <body>
|
206 |
|
207 |
$innerEditor = $editor.find('#tinymce');
|
208 |
$innerEditor.addClass('boxzilla boxzilla-' + boxId);
|
209 |
$innerEditor.css({
|
210 |
+
margin: 0,
|
211 |
+
background: 'white',
|
212 |
+
display: 'inline-block',
|
213 |
+
width: 'auto',
|
214 |
'min-width': '240px',
|
215 |
+
position: 'relative'
|
216 |
});
|
217 |
$innerEditor.get(0).style.cssText += ';padding: 25px !important;';
|
218 |
visualEditorInitialised = true;
|
230 |
function applyStyles() {
|
231 |
if (!visualEditorInitialised) {
|
232 |
return false;
|
233 |
+
} // Apply styles from CSS editor.
|
234 |
// Use short timeout to make sure color values are updated.
|
235 |
|
236 |
|
237 |
window.setTimeout(function () {
|
238 |
$innerEditor.css({
|
239 |
'border-color': options.borderColor.getColorValue(),
|
240 |
+
// getColorValue( 'borderColor', '' ),
|
241 |
'border-width': options.borderWidth.getPxValue(),
|
242 |
+
// getPxValue( 'borderWidth', '' ),
|
243 |
'border-style': options.borderStyle.getValue(),
|
244 |
+
// getValue('borderStyle', '' ),
|
245 |
'background-color': options.backgroundColor.getColorValue(),
|
246 |
+
// getColorValue( 'backgroundColor', ''),
|
247 |
+
width: options.width.getPxValue(),
|
248 |
+
// getPxValue( 'width', 'auto' ),
|
249 |
+
color: options.color.getColorValue() // getColorValue( 'color', '' )
|
250 |
|
251 |
});
|
252 |
/* @since 2.0.3 */
|
276 |
change: applyStyles,
|
277 |
clear: applyStyles
|
278 |
});
|
279 |
+
$appearanceControls.find(':input').not('.boxzilla-color-field').change(applyStyles);
|
280 |
events.on('editor.init', applyStyles); // public methods
|
281 |
|
282 |
return {
|
283 |
+
init: init,
|
284 |
+
resetStyles: resetStyles,
|
285 |
+
options: options
|
286 |
};
|
287 |
};
|
288 |
|
289 |
module.exports = Designer;
|
290 |
|
291 |
},{}],4:[function(require,module,exports){
|
292 |
+
"use strict";
|
293 |
|
294 |
var $ = window.jQuery;
|
295 |
|
296 |
var Option = function Option(element) {
|
297 |
// find corresponding element
|
298 |
+
if (typeof element === 'string') {
|
299 |
element = document.getElementById('boxzilla-' + element);
|
300 |
}
|
301 |
|
302 |
if (!element) {
|
303 |
+
console.error('Unable to find option element.');
|
304 |
}
|
305 |
|
306 |
this.element = element;
|
320 |
|
321 |
Option.prototype.getPxValue = function (fallbackValue) {
|
322 |
if (this.element.value.length > 0) {
|
323 |
+
return parseInt(this.element.value) + 'px';
|
324 |
}
|
325 |
|
326 |
return fallbackValue || '';
|
346 |
|
347 |
},{}],5:[function(require,module,exports){
|
348 |
/*!
|
349 |
+
* EventEmitter v5.2.9 - git.io/ee
|
350 |
* Unlicense - http://unlicense.org/
|
351 |
* Oliver Caldwell - https://oli.me.uk/
|
352 |
* @preserve
|
assets/js/admin-script.min.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1 |
-
!function(){var s=void 0;!function i(l,s,a){function u(t,e){if(!s[t]){if(!l[t]){var n=!1;if(!e&&n)return n(t,!0);if(c)return c(t,!0);var o=new Error("Cannot find module '"+t+"'");throw o.code="MODULE_NOT_FOUND",o}var r=s[t]={exports:{}};l[t][0].call(r.exports,function(e){return u(l[t][1][e]||e)},r,r.exports,i,l,s,a)}return s[t].exports}for(var c=!1,e=0;e<a.length;e++)u(a[e]);return u}({1:[function(e,t,n){"use strict";window.Boxzilla_Admin=e("./admin/_admin.js")},{"./admin/_admin.js":2}],2:[function(
|
2 |
//# sourceMappingURL=admin-script.min.js.map
|
1 |
+
!function(){var s=void 0;!function i(l,s,a){function u(t,e){if(!s[t]){if(!l[t]){var n=!1;if(!e&&n)return n(t,!0);if(c)return c(t,!0);var o=new Error("Cannot find module '"+t+"'");throw o.code="MODULE_NOT_FOUND",o}var r=s[t]={exports:{}};l[t][0].call(r.exports,function(e){return u(l[t][1][e]||e)},r,r.exports,i,l,s,a)}return s[t].exports}for(var c=!1,e=0;e<a.length;e++)u(a[e]);return u}({1:[function(e,t,n){"use strict";window.Boxzilla_Admin=e("./admin/_admin.js")},{"./admin/_admin.js":2}],2:[function(e,t,n){"use strict";var l=window.jQuery,o=e("./_option.js"),r=document.getElementById("boxzilla-box-options-controls"),i=l(r),s=document.createTextNode(" logged in"),a=new(e("wolfy87-eventemitter")),u=e("./_designer.js")(l,o,a),c=window.wp.template("rule-row-template"),p=window.boxzilla_i18n,d=document.getElementById("boxzilla-rule-comparison"),f=document.getElementById("boxzilla-box-rules"),y=window.ajaxurl;function h(){var e="any"===d.value?p.or:p.and;l(".boxzilla-andor").text(e)}function m(){i.find(".boxzilla-trigger-options").toggle(""!==this.value)}function g(){var e=l(this).parents("tr");e.prev().remove(),e.remove()}function v(){var e="tr"===this.tagName.toLowerCase()?this:l(this).parents("tr").get(0),t=e.querySelector(".boxzilla-rule-condition").value,n=e.querySelector(".boxzilla-rule-value"),o=e.querySelector(".boxzilla-rule-qualifier"),r=n.cloneNode(!0),i=l(r);switch(l(e.querySelectorAll(".boxzilla-helper")).remove(),r.removeAttribute("name"),r.className=r.className+" boxzilla-helper",n.parentNode.insertBefore(r,n.nextSibling),i.change(function(){n.value=this.value}),r.style.display="",n.style.display="none",o.style.display="",o.querySelector('option[value="not_contains"]').style.display="none",o.querySelector('option[value="contains"]').style.display="none",s.parentNode&&s.parentNode.removeChild(s),t){default:r.placeholder=p.enterCommaSeparatedValues;break;case"":case"everywhere":o.value="1",n.value="",r.style.display="none",o.style.display="none";break;case"is_single":case"is_post":r.placeholder=p.enterCommaSeparatedPosts,i.suggest(y+"?action=boxzilla_autocomplete&type=post",{multiple:!0,multipleSep:","});break;case"is_page":r.placeholder=p.enterCommaSeparatedPages,i.suggest(y+"?action=boxzilla_autocomplete&type=page",{multiple:!0,multipleSep:","});break;case"is_post_type":r.placeholder=p.enterCommaSeparatedPostTypes,i.suggest(y+"?action=boxzilla_autocomplete&type=post_type",{multiple:!0,multipleSep:","});break;case"is_url":o.querySelector('option[value="contains"]').style.display="",o.querySelector('option[value="not_contains"]').style.display="",r.placeholder=p.enterCommaSeparatedRelativeUrls;break;case"is_post_in_category":i.suggest(y+"?action=boxzilla_autocomplete&type=category",{multiple:!0,multipleSep:","});break;case"is_post_with_tag":i.suggest(y+"?action=boxzilla_autocomplete&type=post_tag",{multiple:!0,multipleSep:","});break;case"is_user_logged_in":r.style.display="none",n.parentNode.insertBefore(s,n.nextSibling);break;case"is_referer":o.querySelector('option[value="contains"]').style.display="",o.querySelector('option[value="not_contains"]').style.display=""}}function b(){var e={key:r.querySelectorAll(".boxzilla-rule-row").length,andor:"any"===d.value?p.or:p.and},t=c(e);return l(f).append(t),!1}l(window).load(function(){void 0===window.tinyMCE&&(document.getElementById("notice-notinymce").style.display=""),i.on("click",".boxzilla-add-rule",b),i.on("click",".boxzilla-remove-rule",g),i.on("change",".boxzilla-rule-condition",v),i.find(".boxzilla-auto-show-trigger").on("change",m),l(d).change(h),l(".boxzilla-rule-row").each(v)}),t.exports={Designer:u,Option:o,events:a}},{"./_designer.js":3,"./_option.js":4,"wolfy87-eventemitter":5}],3:[function(e,t,n){"use strict";function p(e){return(p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}t.exports=function(e,t,n){var o,r,i,l=document.getElementById("post_ID").value||0,s={},a=!1,u=e("#boxzilla-box-appearance-controls");function c(){return!!a&&(window.setTimeout(function(){i.css({"border-color":s.borderColor.getColorValue(),"border-width":s.borderWidth.getPxValue(),"border-style":s.borderStyle.getValue(),"background-color":s.backgroundColor.getColorValue(),width:s.width.getPxValue(),color:s.color.getColorValue()}),n.trigger("editor.styles.apply")},10),!0)}return u.find("input.boxzilla-color-field").wpColorPicker({change:c,clear:c}),u.find(":input").not(".boxzilla-color-field").change(c),n.on("editor.init",c),{init:function(){"object"===p(window.tinyMCE)&&null!==window.tinyMCE.get("content")&&(s.borderColor=new t("border-color"),s.borderWidth=new t("border-width"),s.borderStyle=new t("border-style"),s.backgroundColor=new t("background-color"),s.width=new t("width"),s.color=new t("color"),r=e("#content_ifr"),(o=r.contents().find("html")).css({background:"white"}),(i=o.find("#tinymce")).addClass("boxzilla boxzilla-"+l),i.css({margin:0,background:"white",display:"inline-block",width:"auto","min-width":"240px",position:"relative"}),i.get(0).style.cssText+=";padding: 25px !important;",a=!0,n.trigger("editor.init"))},resetStyles:function(){for(var e in s)"theme"!==e.substring(0,5)&&s[e].clear();c(),n.trigger("editor.styles.reset")},options:s}}},{}],4:[function(e,t,n){"use strict";function o(e){"string"==typeof e&&(e=document.getElementById("boxzilla-"+e)),e||console.error("Unable to find option element."),this.element=e}var r=window.jQuery;o.prototype.getColorValue=function(){return 0<this.element.value.length?r(this.element).hasClass("wp-color-field")?r(this.element).wpColorPicker("color"):this.element.value:""},o.prototype.getPxValue=function(e){return 0<this.element.value.length?parseInt(this.element.value)+"px":e||""},o.prototype.getValue=function(e){return 0<this.element.value.length?this.element.value:e||""},o.prototype.clear=function(){this.element.value=""},o.prototype.setValue=function(e){this.element.value=e},t.exports=o},{}],5:[function(e,l,t){!function(e){"use strict";function t(){}var n=t.prototype,o=e.EventEmitter;function i(e,t){for(var n=e.length;n--;)if(e[n].listener===t)return n;return-1}function r(e){return function(){return this[e].apply(this,arguments)}}n.getListeners=function(e){var t,n,o=this._getEvents();if(e instanceof RegExp)for(n in t={},o)o.hasOwnProperty(n)&&e.test(n)&&(t[n]=o[n]);else t=o[e]||(o[e]=[]);return t},n.flattenListeners=function(e){var t,n=[];for(t=0;t<e.length;t+=1)n.push(e[t].listener);return n},n.getListenersAsObject=function(e){var t,n=this.getListeners(e);return n instanceof Array&&((t={})[e]=n),t||n},n.addListener=function(e,t){if(!function e(t){return"function"==typeof t||t instanceof RegExp||!(!t||"object"!=typeof t)&&e(t.listener)}(t))throw new TypeError("listener must be a function");var n,o=this.getListenersAsObject(e),r="object"==typeof t;for(n in o)o.hasOwnProperty(n)&&-1===i(o[n],t)&&o[n].push(r?t:{listener:t,once:!1});return this},n.on=r("addListener"),n.addOnceListener=function(e,t){return this.addListener(e,{listener:t,once:!0})},n.once=r("addOnceListener"),n.defineEvent=function(e){return this.getListeners(e),this},n.defineEvents=function(e){for(var t=0;t<e.length;t+=1)this.defineEvent(e[t]);return this},n.removeListener=function(e,t){var n,o,r=this.getListenersAsObject(e);for(o in r)r.hasOwnProperty(o)&&-1!==(n=i(r[o],t))&&r[o].splice(n,1);return this},n.off=r("removeListener"),n.addListeners=function(e,t){return this.manipulateListeners(!1,e,t)},n.removeListeners=function(e,t){return this.manipulateListeners(!0,e,t)},n.manipulateListeners=function(e,t,n){var o,r,i=e?this.removeListener:this.addListener,l=e?this.removeListeners:this.addListeners;if("object"!=typeof t||t instanceof RegExp)for(o=n.length;o--;)i.call(this,t,n[o]);else for(o in t)t.hasOwnProperty(o)&&(r=t[o])&&("function"==typeof r?i.call(this,o,r):l.call(this,o,r));return this},n.removeEvent=function(e){var t,n=typeof e,o=this._getEvents();if("string"==n)delete o[e];else if(e instanceof RegExp)for(t in o)o.hasOwnProperty(t)&&e.test(t)&&delete o[t];else delete this._events;return this},n.removeAllListeners=r("removeEvent"),n.emitEvent=function(e,t){var n,o,r,i,l=this.getListenersAsObject(e);for(i in l)if(l.hasOwnProperty(i))for(n=l[i].slice(0),r=0;r<n.length;r++)!0===(o=n[r]).once&&this.removeListener(e,o.listener),o.listener.apply(this,t||[])===this._getOnceReturnValue()&&this.removeListener(e,o.listener);return this},n.trigger=r("emitEvent"),n.emit=function(e){var t=Array.prototype.slice.call(arguments,1);return this.emitEvent(e,t)},n.setOnceReturnValue=function(e){return this._onceReturnValue=e,this},n._getOnceReturnValue=function(){return!this.hasOwnProperty("_onceReturnValue")||this._onceReturnValue},n._getEvents=function(){return this._events||(this._events={})},t.noConflict=function(){return e.EventEmitter=o,t},"function"==typeof s&&s.amd?s(function(){return t}):"object"==typeof l&&l.exports?l.exports=t:e.EventEmitter=t}("undefined"!=typeof window?window:this||{})},{}]},{},[1])}();
|
2 |
//# sourceMappingURL=admin-script.min.js.map
|
assets/js/admin-script.min.js.map
CHANGED
@@ -1 +1 @@
|
|
1 |
-
{"version":3,"sources":["admin-script.js"],"names":["define","undefined","r","e","n","t","o","i","f","c","u","a","Error","code","p","exports","call","length","1","require","module","window","Boxzilla_Admin","./admin/_admin.js","2","$","jQuery","Option","optionControls","document","getElementById","$optionControls","tnLoggedIn","createTextNode","events","Designer","rowTemplate","wp","template","i18n","boxzilla_i18n","ruleComparisonEl","rulesContainerEl","on","data","key","querySelectorAll","andor","value","or","and","html","append","row","this","parents","prev","remove","setContextualHelpers","find","toggle","change","newText","text","load","tinyMCE","style","display","each","context","tagName","toLowerCase","get","condition","querySelector","valueInput","qualifierInput","betterInput","cloneNode","$betterInput","removeAttribute","className","parentNode","insertBefore","nextSibling","removeChild","placeholder","enterCommaSeparatedValues","enterCommaSeparatedPosts","suggest","ajaxurl","multiple","multipleSep","enterCommaSeparatedPages","enterCommaSeparatedPostTypes","enterCommaSeparatedRelativeUrls","./_designer.js","./_option.js","wolfy87-eventemitter","3","_typeof","obj","Symbol","iterator","constructor","prototype","$editor","$editorFrame","$innerEditor","boxId","options","visualEditorInitialised","$appearanceControls","applyStyles","setTimeout","css","border-color","borderColor","getColorValue","border-width","borderWidth","getPxValue","border-style","borderStyle","getValue","background-color","backgroundColor","width","color","trigger","wpColorPicker","clear","not","init","contents","background","addClass","margin","min-width","position","cssText","resetStyles","substring","4","element","console","error","hasClass","fallbackValue","parseInt","setValue","5","EventEmitter","proto","originalGlobalValue","indexOfListener","listeners","listener","alias","name","apply","arguments","getListeners","evt","response","_getEvents","RegExp","hasOwnProperty","test","flattenListeners","flatListeners","push","getListenersAsObject","Array","addListener","isValidListener","TypeError","listenerIsWrapped","once","addOnceListener","defineEvent","defineEvents","evts","removeListener","index","splice","off","addListeners","manipulateListeners","removeListeners","single","removeEvent","type","_events","removeAllListeners","emitEvent","args","listenersMap","slice","_getOnceReturnValue","emit","setOnceReturnValue","_onceReturnValue","noConflict","amd"],"mappings":"CAAA,WAAe,IAA8EA,OAASC,GAAuB,SAASC,EAAEC,EAAEC,EAAEC,GAAG,SAASC,EAAEC,EAAEC,GAAG,IAAIJ,EAAEG,GAAG,CAAC,IAAIJ,EAAEI,GAAG,CAAC,IAAIE,GAAE,EAAoC,IAAID,GAAGC,EAAE,OAAOA,EAAEF,GAAE,GAAI,GAAGG,EAAE,OAAOA,EAAEH,GAAE,GAAI,IAAII,EAAE,IAAIC,MAAM,uBAAuBL,EAAE,KAAK,MAAMI,EAAEE,KAAK,mBAAmBF,EAAE,IAAIG,EAAEV,EAAEG,GAAG,CAACQ,QAAQ,IAAIZ,EAAEI,GAAG,GAAGS,KAAKF,EAAEC,QAAQ,SAASb,GAAoB,OAAOI,EAAlBH,EAAEI,GAAG,GAAGL,IAAeA,IAAIY,EAAEA,EAAEC,QAAQb,EAAEC,EAAEC,EAAEC,GAAG,OAAOD,EAAEG,GAAGQ,QAAQ,IAAI,IAAIL,GAAE,EAAoCH,EAAE,EAAEA,EAAEF,EAAEY,OAAOV,IAAID,EAAED,EAAEE,IAAI,OAAOD,EAA7b,CAA4c,CAACY,EAAE,CAAC,SAASC,EAAQC,EAAOL,GACzlB,aAEAM,OAAOC,eAAiBH,EAAQ,sBAE9B,CAACI,oBAAoB,IAAIC,EAAE,CAAC,SAASL,EAAQC,EAAOL,GACtD,cAEA,WAGE,IAAIU,EAAIJ,OAAOK,OAEXC,EAASR,EAAQ,gBAEjBS,EAAiBC,SAASC,eAAe,iCACzCC,EAAkBN,EAAEG,GACpBI,EAAaH,SAASI,eAAe,cAEzC,GAA+B,IAA3BF,EAAgBd,OAApB,CAIA,IAEIiB,EAAS,IAFMf,EAAQ,yBAIvBgB,EAAWhB,EAAQ,iBAARA,CAA0BM,EAAGE,EAAQO,GAEhDE,EAAcC,GAAGC,SAAS,qBAC1BC,EAAOC,c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,uBAClBjJ,KAAKiI,eAAepB,EAAKN,EAASA,UAMlD,OAAOvG,MAMXmG,EAAMxB,QAAU6B,EAAM,aAUtBL,EAAM+C,KAAO,SAAcrC,GACvB,IAAIiC,EAAOvB,MAAMpE,UAAU6F,MAAMtL,KAAKiJ,UAAW,GACjD,OAAO3G,KAAK6I,UAAUhC,EAAKiC,IAW/B3C,EAAMgD,mBAAqB,SAA4BzJ,GAEnD,OADAM,KAAKoJ,iBAAmB1J,EACjBM,MAWXmG,EAAM8C,oBAAsB,WACxB,OAAIjJ,KAAKiH,eAAe,qBACbjH,KAAKoJ,kBAapBjD,EAAMY,WAAa,WACf,OAAO/G,KAAK2I,UAAY3I,KAAK2I,QAAU,KAQ3CzC,EAAamD,WAAa,WAEtB,OADA5L,EAAQyI,aAAeE,EAChBF,GAIW,mBAAXxJ,GAAyBA,EAAO4M,IACvC5M,EAAO,WACH,OAAOwJ,IAGY,iBAAXpI,GAAuBA,EAAOL,QAC1CK,EAAOL,QAAUyI,EAGjBzI,EAAQyI,aAAeA,EA5d9B,CA8dmB,oBAAXnI,OAAyBA,OAASiC,MAAQ,KAEjD,KAAK,GAAG,CAAC,IAz0BX","file":"admin-script.min.js","sourcesContent":["(function () { var require = undefined; var module = undefined; var exports = undefined; var define = undefined; (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c=\"function\"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error(\"Cannot find module '\"+i+\"'\");throw a.code=\"MODULE_NOT_FOUND\",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u=\"function\"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){\n\"use strict\";\n\nwindow.Boxzilla_Admin = require('./admin/_admin.js');\n\n},{\"./admin/_admin.js\":2}],2:[function(require,module,exports){\n\"use strict\";\n\n(function () {\n 'use strict';\n\n var $ = window.jQuery;\n\n var Option = require('./_option.js');\n\n var optionControls = document.getElementById('boxzilla-box-options-controls');\n var $optionControls = $(optionControls);\n var tnLoggedIn = document.createTextNode(' logged in'); // sanity check, are we on the correct page?\n\n if ($optionControls.length === 0) {\n return;\n }\n\n var EventEmitter = require('wolfy87-eventemitter');\n\n var events = new EventEmitter();\n\n var Designer = require('./_designer.js')($, Option, events);\n\n var rowTemplate = wp.template('rule-row-template');\n var i18n = boxzilla_i18n;\n var ruleComparisonEl = document.getElementById('boxzilla-rule-comparison');\n var rulesContainerEl = document.getElementById('boxzilla-box-rules'); // events\n\n $optionControls.on('click', \".boxzilla-add-rule\", addRuleFields);\n $optionControls.on('click', \".boxzilla-remove-rule\", removeRule);\n $optionControls.on('change', \".boxzilla-rule-condition\", setContextualHelpers);\n $optionControls.find('.boxzilla-auto-show-trigger').on('change', toggleTriggerOptions);\n $(ruleComparisonEl).change(toggleAndOrTexts);\n $(window).load(function () {\n if (typeof window.tinyMCE === \"undefined\") {\n document.getElementById('notice-notinymce').style.display = '';\n }\n }); // call contextual helper method for each row\n\n $('.boxzilla-rule-row').each(setContextualHelpers);\n\n function toggleAndOrTexts() {\n var newText = ruleComparisonEl.value === 'any' ? i18n.or : i18n.and;\n $('.boxzilla-andor').text(newText);\n }\n\n function toggleTriggerOptions() {\n $optionControls.find('.boxzilla-trigger-options').toggle(this.value !== '');\n }\n\n function removeRule() {\n var row = $(this).parents('tr'); // delete andor row\n\n row.prev().remove(); // delete rule row\n\n row.remove();\n }\n\n function setContextualHelpers() {\n var context = this.tagName.toLowerCase() === \"tr\" ? this : $(this).parents('tr').get(0);\n var condition = context.querySelector('.boxzilla-rule-condition').value;\n var valueInput = context.querySelector('.boxzilla-rule-value');\n var qualifierInput = context.querySelector('.boxzilla-rule-qualifier');\n var betterInput = valueInput.cloneNode(true);\n var $betterInput = $(betterInput); // remove previously added helpers\n\n $(context.querySelectorAll('.boxzilla-helper')).remove(); // prepare better input\n\n betterInput.removeAttribute('name');\n betterInput.className = betterInput.className + ' boxzilla-helper';\n valueInput.parentNode.insertBefore(betterInput, valueInput.nextSibling);\n $betterInput.change(function () {\n valueInput.value = this.value;\n });\n betterInput.style.display = '';\n valueInput.style.display = 'none';\n qualifierInput.style.display = '';\n qualifierInput.querySelector('option[value=\"not_contains\"]').style.display = 'none';\n qualifierInput.querySelector('option[value=\"contains\"]').style.display = 'none';\n\n if (tnLoggedIn.parentNode) {\n tnLoggedIn.parentNode.removeChild(tnLoggedIn);\n } // change placeholder for textual help\n\n\n switch (condition) {\n default:\n betterInput.placeholder = i18n.enterCommaSeparatedValues;\n break;\n\n case '':\n case 'everywhere':\n qualifierInput.value = '1';\n valueInput.value = '';\n betterInput.style.display = 'none';\n qualifierInput.style.display = 'none';\n break;\n\n case 'is_single':\n case 'is_post':\n betterInput.placeholder = i18n.enterCommaSeparatedPosts;\n $betterInput.suggest(ajaxurl + \"?action=boxzilla_autocomplete&type=post\", {\n multiple: true,\n multipleSep: \",\"\n });\n break;\n\n case 'is_page':\n betterInput.placeholder = i18n.enterCommaSeparatedPages;\n $betterInput.suggest(ajaxurl + \"?action=boxzilla_autocomplete&type=page\", {\n multiple: true,\n multipleSep: \",\"\n });\n break;\n\n case 'is_post_type':\n betterInput.placeholder = i18n.enterCommaSeparatedPostTypes;\n $betterInput.suggest(ajaxurl + \"?action=boxzilla_autocomplete&type=post_type\", {\n multiple: true,\n multipleSep: \",\"\n });\n break;\n\n case 'is_url':\n qualifierInput.querySelector('option[value=\"contains\"]').style.display = '';\n qualifierInput.querySelector('option[value=\"not_contains\"]').style.display = '';\n betterInput.placeholder = i18n.enterCommaSeparatedRelativeUrls;\n break;\n\n case 'is_post_in_category':\n $betterInput.suggest(ajaxurl + \"?action=boxzilla_autocomplete&type=category\", {\n multiple: true,\n multipleSep: \",\"\n });\n break;\n\n case 'is_post_with_tag':\n $betterInput.suggest(ajaxurl + \"?action=boxzilla_autocomplete&type=post_tag\", {\n multiple: true,\n multipleSep: \",\"\n });\n break;\n\n case 'is_user_logged_in':\n betterInput.style.display = 'none';\n valueInput.parentNode.insertBefore(tnLoggedIn, valueInput.nextSibling);\n break;\n\n case 'is_referer':\n qualifierInput.querySelector('option[value=\"contains\"]').style.display = '';\n qualifierInput.querySelector('option[value=\"not_contains\"]').style.display = '';\n break;\n }\n }\n\n function addRuleFields() {\n var data = {\n 'key': optionControls.querySelectorAll('.boxzilla-rule-row').length,\n 'andor': ruleComparisonEl.value === 'any' ? i18n.or : i18n.and\n };\n var html = rowTemplate(data);\n $(rulesContainerEl).append(html);\n return false;\n }\n\n module.exports = {\n 'Designer': Designer,\n 'Option': Option,\n 'events': events\n };\n})();\n\n},{\"./_designer.js\":3,\"./_option.js\":4,\"wolfy87-eventemitter\":5}],3:[function(require,module,exports){\n\"use strict\";\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nvar Designer = function Designer($, Option, events) {\n // vars\n var boxId = document.getElementById('post_ID').value || 0,\n $editor,\n $editorFrame,\n $innerEditor,\n options = {},\n visualEditorInitialised = false;\n var $appearanceControls = $(\"#boxzilla-box-appearance-controls\"); // create Option objects\n\n options.borderColor = new Option('border-color');\n options.borderWidth = new Option('border-width');\n options.borderStyle = new Option('border-style');\n options.backgroundColor = new Option('background-color');\n options.width = new Option('width');\n options.color = new Option('color'); // functions\n\n function init() {\n // Only run if TinyMCE has actually inited\n if (_typeof(window.tinyMCE) !== \"object\" || tinyMCE.get('content') === null) {\n return;\n } // add classes to TinyMCE <html>\n\n\n $editorFrame = $(\"#content_ifr\");\n $editor = $editorFrame.contents().find('html');\n $editor.css({\n 'background': 'white'\n }); // add content class and padding to TinyMCE <body>\n\n $innerEditor = $editor.find('#tinymce');\n $innerEditor.addClass('boxzilla boxzilla-' + boxId);\n $innerEditor.css({\n 'margin': 0,\n 'background': 'white',\n 'display': 'inline-block',\n 'width': 'auto',\n 'min-width': '240px',\n 'position': 'relative'\n });\n $innerEditor.get(0).style.cssText += ';padding: 25px !important;';\n visualEditorInitialised = true;\n /* @since 2.0.3 */\n\n events.trigger('editor.init');\n }\n /**\n * Applies the styles from the options to the TinyMCE Editor\n *\n * @return bool\n */\n\n\n function applyStyles() {\n if (!visualEditorInitialised) {\n return false;\n } // Apply styles from CSS editor. \n // Use short timeout to make sure color values are updated.\n\n\n window.setTimeout(function () {\n $innerEditor.css({\n 'border-color': options.borderColor.getColorValue(),\n //getColorValue( 'borderColor', '' ),\n 'border-width': options.borderWidth.getPxValue(),\n //getPxValue( 'borderWidth', '' ),\n 'border-style': options.borderStyle.getValue(),\n //getValue('borderStyle', '' ),\n 'background-color': options.backgroundColor.getColorValue(),\n //getColorValue( 'backgroundColor', ''),\n 'width': options.width.getPxValue(),\n //getPxValue( 'width', 'auto' ),\n 'color': options.color.getColorValue() // getColorValue( 'color', '' )\n\n });\n /* @since 2.0.3 */\n\n events.trigger('editor.styles.apply');\n }, 10);\n return true;\n }\n\n function resetStyles() {\n for (var key in options) {\n if (key.substring(0, 5) === 'theme') {\n continue;\n }\n\n options[key].clear();\n }\n\n applyStyles();\n /* @since 2.0.3 */\n\n events.trigger('editor.styles.reset');\n } // event binders\n\n\n $appearanceControls.find('input.boxzilla-color-field').wpColorPicker({\n change: applyStyles,\n clear: applyStyles\n });\n $appearanceControls.find(\":input\").not(\".boxzilla-color-field\").change(applyStyles);\n events.on('editor.init', applyStyles); // public methods\n\n return {\n 'init': init,\n 'resetStyles': resetStyles,\n 'options': options\n };\n};\n\nmodule.exports = Designer;\n\n},{}],4:[function(require,module,exports){\n'use strict';\n\nvar $ = window.jQuery;\n\nvar Option = function Option(element) {\n // find corresponding element\n if (typeof element == \"string\") {\n element = document.getElementById('boxzilla-' + element);\n }\n\n if (!element) {\n console.error(\"Unable to find option element.\");\n }\n\n this.element = element;\n};\n\nOption.prototype.getColorValue = function () {\n if (this.element.value.length > 0) {\n if ($(this.element).hasClass('wp-color-field')) {\n return $(this.element).wpColorPicker('color');\n } else {\n return this.element.value;\n }\n }\n\n return '';\n};\n\nOption.prototype.getPxValue = function (fallbackValue) {\n if (this.element.value.length > 0) {\n return parseInt(this.element.value) + \"px\";\n }\n\n return fallbackValue || '';\n};\n\nOption.prototype.getValue = function (fallbackValue) {\n if (this.element.value.length > 0) {\n return this.element.value;\n }\n\n return fallbackValue || '';\n};\n\nOption.prototype.clear = function () {\n this.element.value = '';\n};\n\nOption.prototype.setValue = function (value) {\n this.element.value = value;\n};\n\nmodule.exports = Option;\n\n},{}],5:[function(require,module,exports){\n/*!\n * EventEmitter v5.2.8 - git.io/ee\n * Unlicense - http://unlicense.org/\n * Oliver Caldwell - https://oli.me.uk/\n * @preserve\n */\n\n;(function (exports) {\n 'use strict';\n\n /**\n * Class for managing events.\n * Can be extended to provide event functionality in other classes.\n *\n * @class EventEmitter Manages event registering and emitting.\n */\n function EventEmitter() {}\n\n // Shortcuts to improve speed and size\n var proto = EventEmitter.prototype;\n var originalGlobalValue = exports.EventEmitter;\n\n /**\n * Finds the index of the listener for the event in its storage array.\n *\n * @param {Function[]} listeners Array of listeners to search through.\n * @param {Function} listener Method to look for.\n * @return {Number} Index of the specified listener, -1 if not found\n * @api private\n */\n function indexOfListener(listeners, listener) {\n var i = listeners.length;\n while (i--) {\n if (listeners[i].listener === listener) {\n return i;\n }\n }\n\n return -1;\n }\n\n /**\n * Alias a method while keeping the context correct, to allow for overwriting of target method.\n *\n * @param {String} name The name of the target method.\n * @return {Function} The aliased method\n * @api private\n */\n function alias(name) {\n return function aliasClosure() {\n return this[name].apply(this, arguments);\n };\n }\n\n /**\n * Returns the listener array for the specified event.\n * Will initialise the event object and listener arrays if required.\n * Will return an object if you use a regex search. The object contains keys for each matched event. So /ba[rz]/ might return an object containing bar and baz. But only if you have either defined them with defineEvent or added some listeners to them.\n * Each property in the object response is an array of listener functions.\n *\n * @param {String|RegExp} evt Name of the event to return the listeners from.\n * @return {Function[]|Object} All listener functions for the event.\n */\n proto.getListeners = function getListeners(evt) {\n var events = this._getEvents();\n var response;\n var key;\n\n // Return a concatenated array of all matching events if\n // the selector is a regular expression.\n if (evt instanceof RegExp) {\n response = {};\n for (key in events) {\n if (events.hasOwnProperty(key) && evt.test(key)) {\n response[key] = events[key];\n }\n }\n }\n else {\n response = events[evt] || (events[evt] = []);\n }\n\n return response;\n };\n\n /**\n * Takes a list of listener objects and flattens it into a list of listener functions.\n *\n * @param {Object[]} listeners Raw listener objects.\n * @return {Function[]} Just the listener functions.\n */\n proto.flattenListeners = function flattenListeners(listeners) {\n var flatListeners = [];\n var i;\n\n for (i = 0; i < listeners.length; i += 1) {\n flatListeners.push(listeners[i].listener);\n }\n\n return flatListeners;\n };\n\n /**\n * Fetches the requested listeners via getListeners but will always return the results inside an object. This is mainly for internal use but others may find it useful.\n *\n * @param {String|RegExp} evt Name of the event to return the listeners from.\n * @return {Object} All listener functions for an event in an object.\n */\n proto.getListenersAsObject = function getListenersAsObject(evt) {\n var listeners = this.getListeners(evt);\n var response;\n\n if (listeners instanceof Array) {\n response = {};\n response[evt] = listeners;\n }\n\n return response || listeners;\n };\n\n function isValidListener (listener) {\n if (typeof listener === 'function' || listener instanceof RegExp) {\n return true\n } else if (listener && typeof listener === 'object') {\n return isValidListener(listener.listener)\n } else {\n return false\n }\n }\n\n /**\n * Adds a listener function to the specified event.\n * The listener will not be added if it is a duplicate.\n * If the listener returns true then it will be removed after it is called.\n * If you pass a regular expression as the event name then the listener will be added to all events that match it.\n *\n * @param {String|RegExp} evt Name of the event to attach the listener to.\n * @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.addListener = function addListener(evt, listener) {\n if (!isValidListener(listener)) {\n throw new TypeError('listener must be a function');\n }\n\n var listeners = this.getListenersAsObject(evt);\n var listenerIsWrapped = typeof listener === 'object';\n var key;\n\n for (key in listeners) {\n if (listeners.hasOwnProperty(key) && indexOfListener(listeners[key], listener) === -1) {\n listeners[key].push(listenerIsWrapped ? listener : {\n listener: listener,\n once: false\n });\n }\n }\n\n return this;\n };\n\n /**\n * Alias of addListener\n */\n proto.on = alias('addListener');\n\n /**\n * Semi-alias of addListener. It will add a listener that will be\n * automatically removed after its first execution.\n *\n * @param {String|RegExp} evt Name of the event to attach the listener to.\n * @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.addOnceListener = function addOnceListener(evt, listener) {\n return this.addListener(evt, {\n listener: listener,\n once: true\n });\n };\n\n /**\n * Alias of addOnceListener.\n */\n proto.once = alias('addOnceListener');\n\n /**\n * Defines an event name. This is required if you want to use a regex to add a listener to multiple events at once. If you don't do this then how do you expect it to know what event to add to? Should it just add to every possible match for a regex? No. That is scary and bad.\n * You need to tell it what event names should be matched by a regex.\n *\n * @param {String} evt Name of the event to create.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.defineEvent = function defineEvent(evt) {\n this.getListeners(evt);\n return this;\n };\n\n /**\n * Uses defineEvent to define multiple events.\n *\n * @param {String[]} evts An array of event names to define.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.defineEvents = function defineEvents(evts) {\n for (var i = 0; i < evts.length; i += 1) {\n this.defineEvent(evts[i]);\n }\n return this;\n };\n\n /**\n * Removes a listener function from the specified event.\n * When passed a regular expression as the event name, it will remove the listener from all events that match it.\n *\n * @param {String|RegExp} evt Name of the event to remove the listener from.\n * @param {Function} listener Method to remove from the event.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.removeListener = function removeListener(evt, listener) {\n var listeners = this.getListenersAsObject(evt);\n var index;\n var key;\n\n for (key in listeners) {\n if (listeners.hasOwnProperty(key)) {\n index = indexOfListener(listeners[key], listener);\n\n if (index !== -1) {\n listeners[key].splice(index, 1);\n }\n }\n }\n\n return this;\n };\n\n /**\n * Alias of removeListener\n */\n proto.off = alias('removeListener');\n\n /**\n * Adds listeners in bulk using the manipulateListeners method.\n * If you pass an object as the first argument you can add to multiple events at once. The object should contain key value pairs of events and listeners or listener arrays. You can also pass it an event name and an array of listeners to be added.\n * You can also pass it a regular expression to add the array of listeners to all events that match it.\n * Yeah, this function does quite a bit. That's probably a bad thing.\n *\n * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to add to multiple events at once.\n * @param {Function[]} [listeners] An optional array of listener functions to add.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.addListeners = function addListeners(evt, listeners) {\n // Pass through to manipulateListeners\n return this.manipulateListeners(false, evt, listeners);\n };\n\n /**\n * Removes listeners in bulk using the manipulateListeners method.\n * If you pass an object as the first argument you can remove from multiple events at once. The object should contain key value pairs of events and listeners or listener arrays.\n * You can also pass it an event name and an array of listeners to be removed.\n * You can also pass it a regular expression to remove the listeners from all events that match it.\n *\n * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to remove from multiple events at once.\n * @param {Function[]} [listeners] An optional array of listener functions to remove.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.removeListeners = function removeListeners(evt, listeners) {\n // Pass through to manipulateListeners\n return this.manipulateListeners(true, evt, listeners);\n };\n\n /**\n * Edits listeners in bulk. The addListeners and removeListeners methods both use this to do their job. You should really use those instead, this is a little lower level.\n * The first argument will determine if the listeners are removed (true) or added (false).\n * If you pass an object as the second argument you can add/remove from multiple events at once. The object should contain key value pairs of events and listeners or listener arrays.\n * You can also pass it an event name and an array of listeners to be added/removed.\n * You can also pass it a regular expression to manipulate the listeners of all events that match it.\n *\n * @param {Boolean} remove True if you want to remove listeners, false if you want to add.\n * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to add/remove from multiple events at once.\n * @param {Function[]} [listeners] An optional array of listener functions to add/remove.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.manipulateListeners = function manipulateListeners(remove, evt, listeners) {\n var i;\n var value;\n var single = remove ? this.removeListener : this.addListener;\n var multiple = remove ? this.removeListeners : this.addListeners;\n\n // If evt is an object then pass each of its properties to this method\n if (typeof evt === 'object' && !(evt instanceof RegExp)) {\n for (i in evt) {\n if (evt.hasOwnProperty(i) && (value = evt[i])) {\n // Pass the single listener straight through to the singular method\n if (typeof value === 'function') {\n single.call(this, i, value);\n }\n else {\n // Otherwise pass back to the multiple function\n multiple.call(this, i, value);\n }\n }\n }\n }\n else {\n // So evt must be a string\n // And listeners must be an array of listeners\n // Loop over it and pass each one to the multiple method\n i = listeners.length;\n while (i--) {\n single.call(this, evt, listeners[i]);\n }\n }\n\n return this;\n };\n\n /**\n * Removes all listeners from a specified event.\n * If you do not specify an event then all listeners will be removed.\n * That means every event will be emptied.\n * You can also pass a regex to remove all events that match it.\n *\n * @param {String|RegExp} [evt] Optional name of the event to remove all listeners for. Will remove from every event if not passed.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.removeEvent = function removeEvent(evt) {\n var type = typeof evt;\n var events = this._getEvents();\n var key;\n\n // Remove different things depending on the state of evt\n if (type === 'string') {\n // Remove all listeners for the specified event\n delete events[evt];\n }\n else if (evt instanceof RegExp) {\n // Remove all events matching the regex.\n for (key in events) {\n if (events.hasOwnProperty(key) && evt.test(key)) {\n delete events[key];\n }\n }\n }\n else {\n // Remove all listeners in all events\n delete this._events;\n }\n\n return this;\n };\n\n /**\n * Alias of removeEvent.\n *\n * Added to mirror the node API.\n */\n proto.removeAllListeners = alias('removeEvent');\n\n /**\n * Emits an event of your choice.\n * When emitted, every listener attached to that event will be executed.\n * If you pass the optional argument array then those arguments will be passed to every listener upon execution.\n * Because it uses `apply`, your array of arguments will be passed as if you wrote them out separately.\n * So they will not arrive within the array on the other side, they will be separate.\n * You can also pass a regular expression to emit to all events that match it.\n *\n * @param {String|RegExp} evt Name of the event to emit and execute listeners for.\n * @param {Array} [args] Optional array of arguments to be passed to each listener.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.emitEvent = function emitEvent(evt, args) {\n var listenersMap = this.getListenersAsObject(evt);\n var listeners;\n var listener;\n var i;\n var key;\n var response;\n\n for (key in listenersMap) {\n if (listenersMap.hasOwnProperty(key)) {\n listeners = listenersMap[key].slice(0);\n\n for (i = 0; i < listeners.length; i++) {\n // If the listener returns true then it shall be removed from the event\n // The function is executed either with a basic call or an apply if there is an args array\n listener = listeners[i];\n\n if (listener.once === true) {\n this.removeListener(evt, listener.listener);\n }\n\n response = listener.listener.apply(this, args || []);\n\n if (response === this._getOnceReturnValue()) {\n this.removeListener(evt, listener.listener);\n }\n }\n }\n }\n\n return this;\n };\n\n /**\n * Alias of emitEvent\n */\n proto.trigger = alias('emitEvent');\n\n /**\n * Subtly different from emitEvent in that it will pass its arguments on to the listeners, as opposed to taking a single array of arguments to pass on.\n * As with emitEvent, you can pass a regex in place of the event name to emit to all events that match it.\n *\n * @param {String|RegExp} evt Name of the event to emit and execute listeners for.\n * @param {...*} Optional additional arguments to be passed to each listener.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.emit = function emit(evt) {\n var args = Array.prototype.slice.call(arguments, 1);\n return this.emitEvent(evt, args);\n };\n\n /**\n * Sets the current value to check against when executing listeners. If a\n * listeners return value matches the one set here then it will be removed\n * after execution. This value defaults to true.\n *\n * @param {*} value The new value to check for when executing listeners.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.setOnceReturnValue = function setOnceReturnValue(value) {\n this._onceReturnValue = value;\n return this;\n };\n\n /**\n * Fetches the current value to check against when executing listeners. If\n * the listeners return value matches this one then it should be removed\n * automatically. It will return true by default.\n *\n * @return {*|Boolean} The current value to check for or the default, true.\n * @api private\n */\n proto._getOnceReturnValue = function _getOnceReturnValue() {\n if (this.hasOwnProperty('_onceReturnValue')) {\n return this._onceReturnValue;\n }\n else {\n return true;\n }\n };\n\n /**\n * Fetches the events object and creates one if required.\n *\n * @return {Object} The events storage object.\n * @api private\n */\n proto._getEvents = function _getEvents() {\n return this._events || (this._events = {});\n };\n\n /**\n * Reverts the global {@link EventEmitter} to its previous value and returns a reference to this version.\n *\n * @return {Function} Non conflicting EventEmitter class.\n */\n EventEmitter.noConflict = function noConflict() {\n exports.EventEmitter = originalGlobalValue;\n return EventEmitter;\n };\n\n // Expose the class either via AMD, CommonJS or the global object\n if (typeof define === 'function' && define.amd) {\n define(function () {\n return EventEmitter;\n });\n }\n else if (typeof module === 'object' && module.exports){\n module.exports = EventEmitter;\n }\n else {\n exports.EventEmitter = EventEmitter;\n }\n}(typeof window !== 'undefined' ? window : this || {}));\n\n},{}]},{},[1]);\n; })();"]}
|
1 |
+
{"version":3,"sources":["admin-script.js"],"names":["define","undefined","r","e","n","t","o","i","f","c","u","a","Error","code","p","exports","call","length","1","require","module","window","Boxzilla_Admin","./admin/_admin.js","2","$","jQuery","Option","optionControls","document","getElementById","$optionControls","tnLoggedIn","createTextNode","events","Designer","rowTemplate","wp","template","i18n","boxzilla_i18n","ruleComparisonEl","rulesContainerEl","ajaxurl","toggleAndOrTexts","newText","value","or","and","text","toggleTriggerOptions","find","toggle","this","removeRule","row","parents","prev","remove","setContextualHelpers","context","tagName","toLowerCase","get","condition","querySelector","valueInput","qualifierInput","betterInput","cloneNode","$betterInput","querySelectorAll","removeAttribute","className","parentNode","insertBefore","nextSibling","change","style","display","removeChild","placeholder","enterCommaSeparatedValues","enterCommaSeparatedPosts","suggest","multiple","multipleSep","enterCommaSeparatedPages","enterCommaSeparatedPostTypes","enterCommaSeparatedRelativeUrls","addRuleFields","data","key","andor","html","append","load","tinyMCE","on","each","./_designer.js","./_option.js","wolfy87-eventemitter","3","_typeof","obj","Symbol","iterator","constructor","prototype","$editor","$editorFrame","$innerEditor","boxId","options","visualEditorInitialised","$appearanceControls","applyStyles","setTimeout","css","border-color","borderColor","getColorValue","border-width","borderWidth","getPxValue","border-style","borderStyle","getValue","background-color","backgroundColor","width","color","trigger","wpColorPicker","clear","not","init","contents","background","addClass","margin","min-width","position","cssText","resetStyles","substring","4","element","console","error","hasClass","fallbackValue","parseInt","setValue","5","EventEmitter","proto","originalGlobalValue","indexOfListener","listeners","listener","alias","name","apply","arguments","getListeners","evt","response","_getEvents","RegExp","hasOwnProperty","test","flattenListeners","flatListeners","push","getListenersAsObject","Array","addListener","isValidListener","TypeError","listenerIsWrapped","once","addOnceListener","defineEvent","defineEvents","evts","removeListener","index","splice","off","addListeners","manipulateListeners","removeListeners","single","removeEvent","type","_events","removeAllListeners","emitEvent","args","listenersMap","slice","_getOnceReturnValue","emit","setOnceReturnValue","_onceReturnValue","noConflict","amd"],"mappings":"CAAA,WAAe,IAA8EA,OAASC,GAAuB,SAASC,EAAEC,EAAEC,EAAEC,GAAG,SAASC,EAAEC,EAAEC,GAAG,IAAIJ,EAAEG,GAAG,CAAC,IAAIJ,EAAEI,GAAG,CAAC,IAAIE,GAAE,EAAoC,IAAID,GAAGC,EAAE,OAAOA,EAAEF,GAAE,GAAI,GAAGG,EAAE,OAAOA,EAAEH,GAAE,GAAI,IAAII,EAAE,IAAIC,MAAM,uBAAuBL,EAAE,KAAK,MAAMI,EAAEE,KAAK,mBAAmBF,EAAE,IAAIG,EAAEV,EAAEG,GAAG,CAACQ,QAAQ,IAAIZ,EAAEI,GAAG,GAAGS,KAAKF,EAAEC,QAAQ,SAASb,GAAoB,OAAOI,EAAlBH,EAAEI,GAAG,GAAGL,IAAeA,IAAIY,EAAEA,EAAEC,QAAQb,EAAEC,EAAEC,EAAEC,GAAG,OAAOD,EAAEG,GAAGQ,QAAQ,IAAI,IAAIL,GAAE,EAAoCH,EAAE,EAAEA,EAAEF,EAAEY,OAAOV,IAAID,EAAED,EAAEE,IAAI,OAAOD,EAA7b,CAA4c,CAACY,EAAE,CAAC,SAASC,EAAQC,EAAOL,GACzlB,aAEAM,OAAOC,eAAiBH,EAAQ,sBAE9B,CAACI,oBAAoB,IAAIC,EAAE,CAAC,SAASL,EAAQC,EAAOL,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MyC,mBAAqBpC,EAAM,eAcjCL,EAAM0C,UAAY,SAAmBhC,EAAKiC,GACtC,IACIxC,EACAC,EACA1J,EACAqF,EAJA6G,EAAepJ,KAAK2H,qBAAqBT,GAO7C,IAAK3E,KAAO6G,EACR,GAAIA,EAAa9B,eAAe/E,GAG5B,IAFAoE,EAAYyC,EAAa7G,GAAK8G,MAAM,GAE/BnM,EAAI,EAAGA,EAAIyJ,EAAU/I,OAAQV,KAKR,KAFtB0J,EAAWD,EAAUzJ,IAER+K,MACTjI,KAAKsI,eAAepB,EAAKN,EAASA,UAG3BA,EAASA,SAASG,MAAM/G,KAAMmJ,GAAQ,MAEhCnJ,KAAKsJ,uBAClBtJ,KAAKsI,eAAepB,EAAKN,EAASA,UAMlD,OAAO5G,MAMXwG,EAAMxB,QAAU6B,EAAM,aAUtBL,EAAM+C,KAAO,SAAcrC,GACvB,IAAIiC,EAAOvB,MAAMpE,UAAU6F,MAAM1L,KAAKqJ,UAAW,GACjD,OAAOhH,KAAKkJ,UAAUhC,EAAKiC,IAW/B3C,EAAMgD,mBAAqB,SAA4B/J,GAEnD,OADAO,KAAKyJ,iBAAmBhK,EACjBO,MAWXwG,EAAM8C,oBAAsB,WACxB,OAAItJ,KAAKsH,eAAe,qBACbtH,KAAKyJ,kBAapBjD,EAAMY,WAAa,WACf,OAAOpH,KAAKgJ,UAAYhJ,KAAKgJ,QAAU,KAQ3CzC,EAAamD,WAAa,WAEtB,OADAhM,EAAQ6I,aAAeE,EAChBF,GAIW,mBAAX5J,GAAyBA,EAAOgN,IACvChN,EAAO,WACH,OAAO4J,IAGY,iBAAXxI,GAAuBA,EAAOL,QAC1CK,EAAOL,QAAU6I,EAGjB7I,EAAQ6I,aAAeA,EA5d9B,CA8dmB,oBAAXvI,OAAyBA,OAASgC,MAAQ,KAEjD,KAAK,GAAG,CAAC,IAl0BX","file":"admin-script.min.js","sourcesContent":["(function () { var require = undefined; var module = undefined; var exports = undefined; var define = undefined; (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c=\"function\"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error(\"Cannot find module '\"+i+\"'\");throw a.code=\"MODULE_NOT_FOUND\",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u=\"function\"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){\n\"use strict\";\n\nwindow.Boxzilla_Admin = require('./admin/_admin.js');\n\n},{\"./admin/_admin.js\":2}],2:[function(require,module,exports){\n\"use strict\";\n\nvar $ = window.jQuery;\n\nvar Option = require('./_option.js');\n\nvar optionControls = document.getElementById('boxzilla-box-options-controls');\nvar $optionControls = $(optionControls);\nvar tnLoggedIn = document.createTextNode(' logged in');\n\nvar EventEmitter = require('wolfy87-eventemitter');\n\nvar events = new EventEmitter();\n\nvar Designer = require('./_designer.js')($, Option, events);\n\nvar rowTemplate = window.wp.template('rule-row-template');\nvar i18n = window.boxzilla_i18n;\nvar ruleComparisonEl = document.getElementById('boxzilla-rule-comparison');\nvar rulesContainerEl = document.getElementById('boxzilla-box-rules');\nvar ajaxurl = window.ajaxurl; // events\n\n$(window).load(function () {\n if (typeof window.tinyMCE === 'undefined') {\n document.getElementById('notice-notinymce').style.display = '';\n }\n\n $optionControls.on('click', '.boxzilla-add-rule', addRuleFields);\n $optionControls.on('click', '.boxzilla-remove-rule', removeRule);\n $optionControls.on('change', '.boxzilla-rule-condition', setContextualHelpers);\n $optionControls.find('.boxzilla-auto-show-trigger').on('change', toggleTriggerOptions);\n $(ruleComparisonEl).change(toggleAndOrTexts);\n $('.boxzilla-rule-row').each(setContextualHelpers);\n});\n\nfunction toggleAndOrTexts() {\n var newText = ruleComparisonEl.value === 'any' ? i18n.or : i18n.and;\n $('.boxzilla-andor').text(newText);\n}\n\nfunction toggleTriggerOptions() {\n $optionControls.find('.boxzilla-trigger-options').toggle(this.value !== '');\n}\n\nfunction removeRule() {\n var row = $(this).parents('tr'); // delete andor row\n\n row.prev().remove(); // delete rule row\n\n row.remove();\n}\n\nfunction setContextualHelpers() {\n var context = this.tagName.toLowerCase() === 'tr' ? this : $(this).parents('tr').get(0);\n var condition = context.querySelector('.boxzilla-rule-condition').value;\n var valueInput = context.querySelector('.boxzilla-rule-value');\n var qualifierInput = context.querySelector('.boxzilla-rule-qualifier');\n var betterInput = valueInput.cloneNode(true);\n var $betterInput = $(betterInput); // remove previously added helpers\n\n $(context.querySelectorAll('.boxzilla-helper')).remove(); // prepare better input\n\n betterInput.removeAttribute('name');\n betterInput.className = betterInput.className + ' boxzilla-helper';\n valueInput.parentNode.insertBefore(betterInput, valueInput.nextSibling);\n $betterInput.change(function () {\n valueInput.value = this.value;\n });\n betterInput.style.display = '';\n valueInput.style.display = 'none';\n qualifierInput.style.display = '';\n qualifierInput.querySelector('option[value=\"not_contains\"]').style.display = 'none';\n qualifierInput.querySelector('option[value=\"contains\"]').style.display = 'none';\n\n if (tnLoggedIn.parentNode) {\n tnLoggedIn.parentNode.removeChild(tnLoggedIn);\n } // change placeholder for textual help\n\n\n switch (condition) {\n default:\n betterInput.placeholder = i18n.enterCommaSeparatedValues;\n break;\n\n case '':\n case 'everywhere':\n qualifierInput.value = '1';\n valueInput.value = '';\n betterInput.style.display = 'none';\n qualifierInput.style.display = 'none';\n break;\n\n case 'is_single':\n case 'is_post':\n betterInput.placeholder = i18n.enterCommaSeparatedPosts;\n $betterInput.suggest(ajaxurl + '?action=boxzilla_autocomplete&type=post', {\n multiple: true,\n multipleSep: ','\n });\n break;\n\n case 'is_page':\n betterInput.placeholder = i18n.enterCommaSeparatedPages;\n $betterInput.suggest(ajaxurl + '?action=boxzilla_autocomplete&type=page', {\n multiple: true,\n multipleSep: ','\n });\n break;\n\n case 'is_post_type':\n betterInput.placeholder = i18n.enterCommaSeparatedPostTypes;\n $betterInput.suggest(ajaxurl + '?action=boxzilla_autocomplete&type=post_type', {\n multiple: true,\n multipleSep: ','\n });\n break;\n\n case 'is_url':\n qualifierInput.querySelector('option[value=\"contains\"]').style.display = '';\n qualifierInput.querySelector('option[value=\"not_contains\"]').style.display = '';\n betterInput.placeholder = i18n.enterCommaSeparatedRelativeUrls;\n break;\n\n case 'is_post_in_category':\n $betterInput.suggest(ajaxurl + '?action=boxzilla_autocomplete&type=category', {\n multiple: true,\n multipleSep: ','\n });\n break;\n\n case 'is_post_with_tag':\n $betterInput.suggest(ajaxurl + '?action=boxzilla_autocomplete&type=post_tag', {\n multiple: true,\n multipleSep: ','\n });\n break;\n\n case 'is_user_logged_in':\n betterInput.style.display = 'none';\n valueInput.parentNode.insertBefore(tnLoggedIn, valueInput.nextSibling);\n break;\n\n case 'is_referer':\n qualifierInput.querySelector('option[value=\"contains\"]').style.display = '';\n qualifierInput.querySelector('option[value=\"not_contains\"]').style.display = '';\n break;\n }\n}\n\nfunction addRuleFields() {\n var data = {\n key: optionControls.querySelectorAll('.boxzilla-rule-row').length,\n andor: ruleComparisonEl.value === 'any' ? i18n.or : i18n.and\n };\n var html = rowTemplate(data);\n $(rulesContainerEl).append(html);\n return false;\n}\n\nmodule.exports = {\n Designer: Designer,\n Option: Option,\n events: events\n};\n\n},{\"./_designer.js\":3,\"./_option.js\":4,\"wolfy87-eventemitter\":5}],3:[function(require,module,exports){\n\"use strict\";\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nvar Designer = function Designer($, Option, events) {\n // vars\n var boxId = document.getElementById('post_ID').value || 0;\n var $editor;\n var $editorFrame;\n var $innerEditor;\n var options = {};\n var visualEditorInitialised = false;\n var $appearanceControls = $('#boxzilla-box-appearance-controls'); // functions\n\n function init() {\n // Only run if TinyMCE has actually inited\n if (_typeof(window.tinyMCE) !== 'object' || window.tinyMCE.get('content') === null) {\n return;\n } // create Option objects\n\n\n options.borderColor = new Option('border-color');\n options.borderWidth = new Option('border-width');\n options.borderStyle = new Option('border-style');\n options.backgroundColor = new Option('background-color');\n options.width = new Option('width');\n options.color = new Option('color'); // add classes to TinyMCE <html>\n\n $editorFrame = $('#content_ifr');\n $editor = $editorFrame.contents().find('html');\n $editor.css({\n background: 'white'\n }); // add content class and padding to TinyMCE <body>\n\n $innerEditor = $editor.find('#tinymce');\n $innerEditor.addClass('boxzilla boxzilla-' + boxId);\n $innerEditor.css({\n margin: 0,\n background: 'white',\n display: 'inline-block',\n width: 'auto',\n 'min-width': '240px',\n position: 'relative'\n });\n $innerEditor.get(0).style.cssText += ';padding: 25px !important;';\n visualEditorInitialised = true;\n /* @since 2.0.3 */\n\n events.trigger('editor.init');\n }\n /**\n * Applies the styles from the options to the TinyMCE Editor\n *\n * @return bool\n */\n\n\n function applyStyles() {\n if (!visualEditorInitialised) {\n return false;\n } // Apply styles from CSS editor.\n // Use short timeout to make sure color values are updated.\n\n\n window.setTimeout(function () {\n $innerEditor.css({\n 'border-color': options.borderColor.getColorValue(),\n // getColorValue( 'borderColor', '' ),\n 'border-width': options.borderWidth.getPxValue(),\n // getPxValue( 'borderWidth', '' ),\n 'border-style': options.borderStyle.getValue(),\n // getValue('borderStyle', '' ),\n 'background-color': options.backgroundColor.getColorValue(),\n // getColorValue( 'backgroundColor', ''),\n width: options.width.getPxValue(),\n // getPxValue( 'width', 'auto' ),\n color: options.color.getColorValue() // getColorValue( 'color', '' )\n\n });\n /* @since 2.0.3 */\n\n events.trigger('editor.styles.apply');\n }, 10);\n return true;\n }\n\n function resetStyles() {\n for (var key in options) {\n if (key.substring(0, 5) === 'theme') {\n continue;\n }\n\n options[key].clear();\n }\n\n applyStyles();\n /* @since 2.0.3 */\n\n events.trigger('editor.styles.reset');\n } // event binders\n\n\n $appearanceControls.find('input.boxzilla-color-field').wpColorPicker({\n change: applyStyles,\n clear: applyStyles\n });\n $appearanceControls.find(':input').not('.boxzilla-color-field').change(applyStyles);\n events.on('editor.init', applyStyles); // public methods\n\n return {\n init: init,\n resetStyles: resetStyles,\n options: options\n };\n};\n\nmodule.exports = Designer;\n\n},{}],4:[function(require,module,exports){\n\"use strict\";\n\nvar $ = window.jQuery;\n\nvar Option = function Option(element) {\n // find corresponding element\n if (typeof element === 'string') {\n element = document.getElementById('boxzilla-' + element);\n }\n\n if (!element) {\n console.error('Unable to find option element.');\n }\n\n this.element = element;\n};\n\nOption.prototype.getColorValue = function () {\n if (this.element.value.length > 0) {\n if ($(this.element).hasClass('wp-color-field')) {\n return $(this.element).wpColorPicker('color');\n } else {\n return this.element.value;\n }\n }\n\n return '';\n};\n\nOption.prototype.getPxValue = function (fallbackValue) {\n if (this.element.value.length > 0) {\n return parseInt(this.element.value) + 'px';\n }\n\n return fallbackValue || '';\n};\n\nOption.prototype.getValue = function (fallbackValue) {\n if (this.element.value.length > 0) {\n return this.element.value;\n }\n\n return fallbackValue || '';\n};\n\nOption.prototype.clear = function () {\n this.element.value = '';\n};\n\nOption.prototype.setValue = function (value) {\n this.element.value = value;\n};\n\nmodule.exports = Option;\n\n},{}],5:[function(require,module,exports){\n/*!\n * EventEmitter v5.2.9 - git.io/ee\n * Unlicense - http://unlicense.org/\n * Oliver Caldwell - https://oli.me.uk/\n * @preserve\n */\n\n;(function (exports) {\n 'use strict';\n\n /**\n * Class for managing events.\n * Can be extended to provide event functionality in other classes.\n *\n * @class EventEmitter Manages event registering and emitting.\n */\n function EventEmitter() {}\n\n // Shortcuts to improve speed and size\n var proto = EventEmitter.prototype;\n var originalGlobalValue = exports.EventEmitter;\n\n /**\n * Finds the index of the listener for the event in its storage array.\n *\n * @param {Function[]} listeners Array of listeners to search through.\n * @param {Function} listener Method to look for.\n * @return {Number} Index of the specified listener, -1 if not found\n * @api private\n */\n function indexOfListener(listeners, listener) {\n var i = listeners.length;\n while (i--) {\n if (listeners[i].listener === listener) {\n return i;\n }\n }\n\n return -1;\n }\n\n /**\n * Alias a method while keeping the context correct, to allow for overwriting of target method.\n *\n * @param {String} name The name of the target method.\n * @return {Function} The aliased method\n * @api private\n */\n function alias(name) {\n return function aliasClosure() {\n return this[name].apply(this, arguments);\n };\n }\n\n /**\n * Returns the listener array for the specified event.\n * Will initialise the event object and listener arrays if required.\n * Will return an object if you use a regex search. The object contains keys for each matched event. So /ba[rz]/ might return an object containing bar and baz. But only if you have either defined them with defineEvent or added some listeners to them.\n * Each property in the object response is an array of listener functions.\n *\n * @param {String|RegExp} evt Name of the event to return the listeners from.\n * @return {Function[]|Object} All listener functions for the event.\n */\n proto.getListeners = function getListeners(evt) {\n var events = this._getEvents();\n var response;\n var key;\n\n // Return a concatenated array of all matching events if\n // the selector is a regular expression.\n if (evt instanceof RegExp) {\n response = {};\n for (key in events) {\n if (events.hasOwnProperty(key) && evt.test(key)) {\n response[key] = events[key];\n }\n }\n }\n else {\n response = events[evt] || (events[evt] = []);\n }\n\n return response;\n };\n\n /**\n * Takes a list of listener objects and flattens it into a list of listener functions.\n *\n * @param {Object[]} listeners Raw listener objects.\n * @return {Function[]} Just the listener functions.\n */\n proto.flattenListeners = function flattenListeners(listeners) {\n var flatListeners = [];\n var i;\n\n for (i = 0; i < listeners.length; i += 1) {\n flatListeners.push(listeners[i].listener);\n }\n\n return flatListeners;\n };\n\n /**\n * Fetches the requested listeners via getListeners but will always return the results inside an object. This is mainly for internal use but others may find it useful.\n *\n * @param {String|RegExp} evt Name of the event to return the listeners from.\n * @return {Object} All listener functions for an event in an object.\n */\n proto.getListenersAsObject = function getListenersAsObject(evt) {\n var listeners = this.getListeners(evt);\n var response;\n\n if (listeners instanceof Array) {\n response = {};\n response[evt] = listeners;\n }\n\n return response || listeners;\n };\n\n function isValidListener (listener) {\n if (typeof listener === 'function' || listener instanceof RegExp) {\n return true\n } else if (listener && typeof listener === 'object') {\n return isValidListener(listener.listener)\n } else {\n return false\n }\n }\n\n /**\n * Adds a listener function to the specified event.\n * The listener will not be added if it is a duplicate.\n * If the listener returns true then it will be removed after it is called.\n * If you pass a regular expression as the event name then the listener will be added to all events that match it.\n *\n * @param {String|RegExp} evt Name of the event to attach the listener to.\n * @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.addListener = function addListener(evt, listener) {\n if (!isValidListener(listener)) {\n throw new TypeError('listener must be a function');\n }\n\n var listeners = this.getListenersAsObject(evt);\n var listenerIsWrapped = typeof listener === 'object';\n var key;\n\n for (key in listeners) {\n if (listeners.hasOwnProperty(key) && indexOfListener(listeners[key], listener) === -1) {\n listeners[key].push(listenerIsWrapped ? listener : {\n listener: listener,\n once: false\n });\n }\n }\n\n return this;\n };\n\n /**\n * Alias of addListener\n */\n proto.on = alias('addListener');\n\n /**\n * Semi-alias of addListener. It will add a listener that will be\n * automatically removed after its first execution.\n *\n * @param {String|RegExp} evt Name of the event to attach the listener to.\n * @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.addOnceListener = function addOnceListener(evt, listener) {\n return this.addListener(evt, {\n listener: listener,\n once: true\n });\n };\n\n /**\n * Alias of addOnceListener.\n */\n proto.once = alias('addOnceListener');\n\n /**\n * Defines an event name. This is required if you want to use a regex to add a listener to multiple events at once. If you don't do this then how do you expect it to know what event to add to? Should it just add to every possible match for a regex? No. That is scary and bad.\n * You need to tell it what event names should be matched by a regex.\n *\n * @param {String} evt Name of the event to create.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.defineEvent = function defineEvent(evt) {\n this.getListeners(evt);\n return this;\n };\n\n /**\n * Uses defineEvent to define multiple events.\n *\n * @param {String[]} evts An array of event names to define.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.defineEvents = function defineEvents(evts) {\n for (var i = 0; i < evts.length; i += 1) {\n this.defineEvent(evts[i]);\n }\n return this;\n };\n\n /**\n * Removes a listener function from the specified event.\n * When passed a regular expression as the event name, it will remove the listener from all events that match it.\n *\n * @param {String|RegExp} evt Name of the event to remove the listener from.\n * @param {Function} listener Method to remove from the event.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.removeListener = function removeListener(evt, listener) {\n var listeners = this.getListenersAsObject(evt);\n var index;\n var key;\n\n for (key in listeners) {\n if (listeners.hasOwnProperty(key)) {\n index = indexOfListener(listeners[key], listener);\n\n if (index !== -1) {\n listeners[key].splice(index, 1);\n }\n }\n }\n\n return this;\n };\n\n /**\n * Alias of removeListener\n */\n proto.off = alias('removeListener');\n\n /**\n * Adds listeners in bulk using the manipulateListeners method.\n * If you pass an object as the first argument you can add to multiple events at once. The object should contain key value pairs of events and listeners or listener arrays. You can also pass it an event name and an array of listeners to be added.\n * You can also pass it a regular expression to add the array of listeners to all events that match it.\n * Yeah, this function does quite a bit. That's probably a bad thing.\n *\n * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to add to multiple events at once.\n * @param {Function[]} [listeners] An optional array of listener functions to add.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.addListeners = function addListeners(evt, listeners) {\n // Pass through to manipulateListeners\n return this.manipulateListeners(false, evt, listeners);\n };\n\n /**\n * Removes listeners in bulk using the manipulateListeners method.\n * If you pass an object as the first argument you can remove from multiple events at once. The object should contain key value pairs of events and listeners or listener arrays.\n * You can also pass it an event name and an array of listeners to be removed.\n * You can also pass it a regular expression to remove the listeners from all events that match it.\n *\n * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to remove from multiple events at once.\n * @param {Function[]} [listeners] An optional array of listener functions to remove.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.removeListeners = function removeListeners(evt, listeners) {\n // Pass through to manipulateListeners\n return this.manipulateListeners(true, evt, listeners);\n };\n\n /**\n * Edits listeners in bulk. The addListeners and removeListeners methods both use this to do their job. You should really use those instead, this is a little lower level.\n * The first argument will determine if the listeners are removed (true) or added (false).\n * If you pass an object as the second argument you can add/remove from multiple events at once. The object should contain key value pairs of events and listeners or listener arrays.\n * You can also pass it an event name and an array of listeners to be added/removed.\n * You can also pass it a regular expression to manipulate the listeners of all events that match it.\n *\n * @param {Boolean} remove True if you want to remove listeners, false if you want to add.\n * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to add/remove from multiple events at once.\n * @param {Function[]} [listeners] An optional array of listener functions to add/remove.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.manipulateListeners = function manipulateListeners(remove, evt, listeners) {\n var i;\n var value;\n var single = remove ? this.removeListener : this.addListener;\n var multiple = remove ? this.removeListeners : this.addListeners;\n\n // If evt is an object then pass each of its properties to this method\n if (typeof evt === 'object' && !(evt instanceof RegExp)) {\n for (i in evt) {\n if (evt.hasOwnProperty(i) && (value = evt[i])) {\n // Pass the single listener straight through to the singular method\n if (typeof value === 'function') {\n single.call(this, i, value);\n }\n else {\n // Otherwise pass back to the multiple function\n multiple.call(this, i, value);\n }\n }\n }\n }\n else {\n // So evt must be a string\n // And listeners must be an array of listeners\n // Loop over it and pass each one to the multiple method\n i = listeners.length;\n while (i--) {\n single.call(this, evt, listeners[i]);\n }\n }\n\n return this;\n };\n\n /**\n * Removes all listeners from a specified event.\n * If you do not specify an event then all listeners will be removed.\n * That means every event will be emptied.\n * You can also pass a regex to remove all events that match it.\n *\n * @param {String|RegExp} [evt] Optional name of the event to remove all listeners for. Will remove from every event if not passed.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.removeEvent = function removeEvent(evt) {\n var type = typeof evt;\n var events = this._getEvents();\n var key;\n\n // Remove different things depending on the state of evt\n if (type === 'string') {\n // Remove all listeners for the specified event\n delete events[evt];\n }\n else if (evt instanceof RegExp) {\n // Remove all events matching the regex.\n for (key in events) {\n if (events.hasOwnProperty(key) && evt.test(key)) {\n delete events[key];\n }\n }\n }\n else {\n // Remove all listeners in all events\n delete this._events;\n }\n\n return this;\n };\n\n /**\n * Alias of removeEvent.\n *\n * Added to mirror the node API.\n */\n proto.removeAllListeners = alias('removeEvent');\n\n /**\n * Emits an event of your choice.\n * When emitted, every listener attached to that event will be executed.\n * If you pass the optional argument array then those arguments will be passed to every listener upon execution.\n * Because it uses `apply`, your array of arguments will be passed as if you wrote them out separately.\n * So they will not arrive within the array on the other side, they will be separate.\n * You can also pass a regular expression to emit to all events that match it.\n *\n * @param {String|RegExp} evt Name of the event to emit and execute listeners for.\n * @param {Array} [args] Optional array of arguments to be passed to each listener.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.emitEvent = function emitEvent(evt, args) {\n var listenersMap = this.getListenersAsObject(evt);\n var listeners;\n var listener;\n var i;\n var key;\n var response;\n\n for (key in listenersMap) {\n if (listenersMap.hasOwnProperty(key)) {\n listeners = listenersMap[key].slice(0);\n\n for (i = 0; i < listeners.length; i++) {\n // If the listener returns true then it shall be removed from the event\n // The function is executed either with a basic call or an apply if there is an args array\n listener = listeners[i];\n\n if (listener.once === true) {\n this.removeListener(evt, listener.listener);\n }\n\n response = listener.listener.apply(this, args || []);\n\n if (response === this._getOnceReturnValue()) {\n this.removeListener(evt, listener.listener);\n }\n }\n }\n }\n\n return this;\n };\n\n /**\n * Alias of emitEvent\n */\n proto.trigger = alias('emitEvent');\n\n /**\n * Subtly different from emitEvent in that it will pass its arguments on to the listeners, as opposed to taking a single array of arguments to pass on.\n * As with emitEvent, you can pass a regex in place of the event name to emit to all events that match it.\n *\n * @param {String|RegExp} evt Name of the event to emit and execute listeners for.\n * @param {...*} Optional additional arguments to be passed to each listener.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.emit = function emit(evt) {\n var args = Array.prototype.slice.call(arguments, 1);\n return this.emitEvent(evt, args);\n };\n\n /**\n * Sets the current value to check against when executing listeners. If a\n * listeners return value matches the one set here then it will be removed\n * after execution. This value defaults to true.\n *\n * @param {*} value The new value to check for when executing listeners.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.setOnceReturnValue = function setOnceReturnValue(value) {\n this._onceReturnValue = value;\n return this;\n };\n\n /**\n * Fetches the current value to check against when executing listeners. If\n * the listeners return value matches this one then it should be removed\n * automatically. It will return true by default.\n *\n * @return {*|Boolean} The current value to check for or the default, true.\n * @api private\n */\n proto._getOnceReturnValue = function _getOnceReturnValue() {\n if (this.hasOwnProperty('_onceReturnValue')) {\n return this._onceReturnValue;\n }\n else {\n return true;\n }\n };\n\n /**\n * Fetches the events object and creates one if required.\n *\n * @return {Object} The events storage object.\n * @api private\n */\n proto._getEvents = function _getEvents() {\n return this._events || (this._events = {});\n };\n\n /**\n * Reverts the global {@link EventEmitter} to its previous value and returns a reference to this version.\n *\n * @return {Function} Non conflicting EventEmitter class.\n */\n EventEmitter.noConflict = function noConflict() {\n exports.EventEmitter = originalGlobalValue;\n return EventEmitter;\n };\n\n // Expose the class either via AMD, CommonJS or the global object\n if (typeof define === 'function' && define.amd) {\n define(function () {\n return EventEmitter;\n });\n }\n else if (typeof module === 'object' && module.exports){\n module.exports = EventEmitter;\n }\n else {\n exports.EventEmitter = EventEmitter;\n }\n}(typeof window !== 'undefined' ? window : this || {}));\n\n},{}]},{},[1]);\n; })();"]}
|
assets/js/script.js
CHANGED
@@ -4,13 +4,9 @@
|
|
4 |
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
5 |
|
6 |
(function () {
|
7 |
-
'use strict';
|
8 |
-
|
9 |
var Boxzilla = require('boxzilla');
|
10 |
|
11 |
-
var options = window.boxzilla_options; //
|
12 |
-
|
13 |
-
window.Boxzilla = Boxzilla; // helper function for setting CSS styles
|
14 |
|
15 |
function css(element, styles) {
|
16 |
if (styles.background_color) {
|
@@ -26,7 +22,7 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat
|
|
26 |
}
|
27 |
|
28 |
if (styles.border_width) {
|
29 |
-
element.style.borderWidth = parseInt(styles.border_width) +
|
30 |
}
|
31 |
|
32 |
if (styles.border_style) {
|
@@ -34,7 +30,7 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat
|
|
34 |
}
|
35 |
|
36 |
if (styles.width) {
|
37 |
-
element.style.maxWidth = parseInt(styles.width) +
|
38 |
}
|
39 |
}
|
40 |
|
@@ -66,8 +62,8 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat
|
|
66 |
css(box.element, boxOpts.css);
|
67 |
|
68 |
try {
|
69 |
-
box.element.firstChild.firstChild.className +=
|
70 |
-
box.element.firstChild.lastChild.className +=
|
71 |
} catch (e) {} // maybe show box right away
|
72 |
|
73 |
|
@@ -85,14 +81,14 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat
|
|
85 |
}
|
86 |
|
87 |
function locationHashRefersBox(box) {
|
88 |
-
if (!window.location.hash ||
|
89 |
return false;
|
90 |
} // parse "boxzilla-{id}" from location hash
|
91 |
|
92 |
|
93 |
var match = window.location.hash.match(/[#&](boxzilla-\d+)/);
|
94 |
|
95 |
-
if (!match || _typeof(match) !==
|
96 |
return false;
|
97 |
}
|
98 |
|
@@ -108,12 +104,12 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat
|
|
108 |
}
|
109 |
|
110 |
function maybeOpenMailChimpForWordPressBox() {
|
111 |
-
if ((_typeof(window.mc4wp_forms_config) !==
|
112 |
return;
|
113 |
}
|
114 |
|
115 |
-
var
|
116 |
-
var selector = '#' +
|
117 |
Boxzilla.boxes.forEach(function (box) {
|
118 |
if (box.element.querySelector(selector)) {
|
119 |
box.show();
|
@@ -135,7 +131,7 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat
|
|
135 |
})();
|
136 |
|
137 |
},{"boxzilla":4}],2:[function(require,module,exports){
|
138 |
-
|
139 |
|
140 |
var duration = 320;
|
141 |
|
@@ -204,7 +200,7 @@ function toggle(element, animation, callbackFn) {
|
|
204 |
}; // store attribute so everyone knows we're animating this element
|
205 |
|
206 |
|
207 |
-
element.setAttribute('data-animated',
|
208 |
|
209 |
if (!nowVisible) {
|
210 |
element.style.display = '';
|
@@ -214,12 +210,12 @@ function toggle(element, animation, callbackFn) {
|
|
214 |
var visibleStyles; // animate properties
|
215 |
|
216 |
if (animation === 'slide') {
|
217 |
-
hiddenStyles = initObjectProperties([
|
218 |
visibleStyles = {};
|
219 |
|
220 |
if (!nowVisible) {
|
221 |
var computedStyles = window.getComputedStyle(element);
|
222 |
-
visibleStyles = copyObjectProperties([
|
223 |
|
224 |
if (!isFinite(visibleStyles.height)) {
|
225 |
var clientRect = element.getBoundingClientRect();
|
@@ -265,7 +261,7 @@ function animate(element, targetStyles, fn) {
|
|
265 |
var to = targetStyles[property];
|
266 |
var current = parseFloat(initialStyles[property]); // is there something to do?
|
267 |
|
268 |
-
if (current
|
269 |
delete targetStyles[property];
|
270 |
continue;
|
271 |
}
|
@@ -299,14 +295,14 @@ function animate(element, targetStyles, fn) {
|
|
299 |
|
300 |
|
301 |
currentStyles[_property] = newValue;
|
302 |
-
|
303 |
-
element.style[_property] = newValue + suffix;
|
304 |
}
|
305 |
|
306 |
-
last = +new Date();
|
307 |
|
308 |
if (!done) {
|
309 |
-
|
|
|
310 |
} else {
|
311 |
// call callback
|
312 |
fn && fn();
|
@@ -317,37 +313,35 @@ function animate(element, targetStyles, fn) {
|
|
317 |
}
|
318 |
|
319 |
module.exports = {
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
};
|
324 |
|
325 |
},{}],3:[function(require,module,exports){
|
326 |
-
|
327 |
|
328 |
var defaults = {
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
};
|
340 |
|
341 |
-
var events = require('./events.js');
|
342 |
-
|
343 |
var Animator = require('./animator.js');
|
344 |
/**
|
345 |
-
* Merge 2 objects, values of the latter overwriting the former.
|
346 |
-
*
|
347 |
-
* @param obj1
|
348 |
-
* @param obj2
|
349 |
-
* @returns {*}
|
350 |
-
*/
|
351 |
|
352 |
|
353 |
function merge(obj1, obj2) {
|
@@ -369,9 +363,9 @@ function merge(obj1, obj2) {
|
|
369 |
return obj3;
|
370 |
}
|
371 |
/**
|
372 |
-
* Get the real height of entire document.
|
373 |
-
* @returns {number}
|
374 |
-
*/
|
375 |
|
376 |
|
377 |
function getDocumentHeight() {
|
@@ -381,8 +375,9 @@ function getDocumentHeight() {
|
|
381 |
} // Box Object
|
382 |
|
383 |
|
384 |
-
function Box(id, config) {
|
385 |
-
this.id = id;
|
|
|
386 |
|
387 |
this.config = merge(defaults, config); // add overlay element to dom and store ref to overlay
|
388 |
|
@@ -404,9 +399,8 @@ function Box(id, config) {
|
|
404 |
this.dom(); // further initialise the box
|
405 |
|
406 |
this.events();
|
407 |
-
}
|
408 |
|
409 |
-
; // initialise the box
|
410 |
|
411 |
Box.prototype.events = function () {
|
412 |
var box = this; // attach event to "close" icon inside box
|
@@ -420,12 +414,12 @@ Box.prototype.events = function () {
|
|
420 |
|
421 |
this.element.addEventListener('click', function (evt) {
|
422 |
if (evt.target.tagName === 'A') {
|
423 |
-
|
424 |
}
|
425 |
}, false);
|
426 |
this.element.addEventListener('submit', function (evt) {
|
427 |
box.setCookie();
|
428 |
-
|
429 |
}, false);
|
430 |
this.overlay.addEventListener('click', function (e) {
|
431 |
var x = e.offsetX;
|
@@ -445,13 +439,13 @@ Box.prototype.dom = function () {
|
|
445 |
var wrapper = document.createElement('div');
|
446 |
wrapper.className = 'boxzilla-container boxzilla-' + this.config.position + '-container';
|
447 |
var box = document.createElement('div');
|
448 |
-
box.
|
449 |
box.className = 'boxzilla boxzilla-' + this.id + ' boxzilla-' + this.config.position;
|
450 |
box.style.display = 'none';
|
451 |
wrapper.appendChild(box);
|
452 |
var content;
|
453 |
|
454 |
-
if (typeof this.config.content ===
|
455 |
content = document.createElement('div');
|
456 |
content.innerHTML = this.config.content;
|
457 |
} else {
|
@@ -465,7 +459,7 @@ Box.prototype.dom = function () {
|
|
465 |
|
466 |
if (this.config.closable && this.config.icon) {
|
467 |
var closeIcon = document.createElement('span');
|
468 |
-
closeIcon.className =
|
469 |
closeIcon.innerHTML = this.config.icon;
|
470 |
box.appendChild(closeIcon);
|
471 |
this.closeIcon = closeIcon;
|
@@ -488,7 +482,7 @@ Box.prototype.setCustomBoxStyling = function () {
|
|
488 |
var boxHeight = this.element.clientHeight; // add scrollbar to box and limit height
|
489 |
|
490 |
if (boxHeight > windowHeight) {
|
491 |
-
this.element.style.maxHeight = windowHeight +
|
492 |
this.element.style.overflowY = 'scroll';
|
493 |
} // set new top margin for boxes which are centered
|
494 |
|
@@ -496,7 +490,7 @@ Box.prototype.setCustomBoxStyling = function () {
|
|
496 |
if (this.config.position === 'center') {
|
497 |
var newTopMargin = (windowHeight - boxHeight) / 2;
|
498 |
newTopMargin = newTopMargin >= 0 ? newTopMargin : 0;
|
499 |
-
this.element.style.marginTop = newTopMargin +
|
500 |
}
|
501 |
|
502 |
this.element.style.display = origDisplay;
|
@@ -504,8 +498,8 @@ Box.prototype.setCustomBoxStyling = function () {
|
|
504 |
|
505 |
|
506 |
Box.prototype.toggle = function (show, animate) {
|
507 |
-
show = typeof show ===
|
508 |
-
animate = typeof animate ===
|
509 |
|
510 |
if (show === this.visible) {
|
511 |
return false;
|
@@ -526,13 +520,13 @@ Box.prototype.toggle = function (show, animate) {
|
|
526 |
|
527 |
this.setCustomBoxStyling(); // trigger event
|
528 |
|
529 |
-
|
530 |
|
531 |
if (this.config.position === 'center') {
|
532 |
this.overlay.classList.toggle('boxzilla-' + this.id + '-overlay');
|
533 |
|
534 |
if (animate) {
|
535 |
-
Animator.toggle(this.overlay,
|
536 |
} else {
|
537 |
this.overlay.style.display = show ? '' : 'none';
|
538 |
}
|
@@ -544,7 +538,7 @@ Box.prototype.toggle = function (show, animate) {
|
|
544 |
return;
|
545 |
}
|
546 |
|
547 |
-
this.contentElement.innerHTML = this.contentElement.innerHTML;
|
548 |
}.bind(this));
|
549 |
} else {
|
550 |
this.element.style.display = show ? '' : 'none';
|
@@ -589,10 +583,10 @@ Box.prototype.fits = function () {
|
|
589 |
}
|
590 |
|
591 |
switch (this.config.screenWidthCondition.condition) {
|
592 |
-
case
|
593 |
return window.innerWidth > this.config.screenWidthCondition.value;
|
594 |
|
595 |
-
case
|
596 |
return window.innerWidth < this.config.screenWidthCondition.value;
|
597 |
} // meh.. condition should be "smaller" or "larger", just return true.
|
598 |
|
@@ -640,8 +634,7 @@ Box.prototype.isCookieSet = function () {
|
|
640 |
return false;
|
641 |
}
|
642 |
|
643 |
-
|
644 |
-
return cookieSet;
|
645 |
}; // set cookie that disables automatically showing the box
|
646 |
|
647 |
|
@@ -665,10 +658,10 @@ Box.prototype.trigger = function () {
|
|
665 |
}
|
666 |
};
|
667 |
/**
|
668 |
-
* Dismisses the box and optionally sets a cookie.
|
669 |
-
* @param animate
|
670 |
-
* @returns {boolean}
|
671 |
-
*/
|
672 |
|
673 |
|
674 |
Box.prototype.dismiss = function (animate) {
|
@@ -685,20 +678,18 @@ Box.prototype.dismiss = function (animate) {
|
|
685 |
}
|
686 |
|
687 |
this.dismissed = true;
|
688 |
-
|
689 |
return true;
|
690 |
};
|
691 |
|
692 |
module.exports = Box;
|
693 |
|
694 |
-
},{"./animator.js":2
|
695 |
-
|
696 |
-
|
697 |
-
var Boxzilla = require('./events.js');
|
698 |
|
699 |
var Box = require('./box.js');
|
700 |
|
701 |
-
var
|
702 |
|
703 |
var styles = require('./styles.js');
|
704 |
|
@@ -711,14 +702,14 @@ var Pageviews = require('./triggers/pageviews.js');
|
|
711 |
var Time = require('./triggers/time.js');
|
712 |
|
713 |
var initialised = false;
|
714 |
-
var boxes = [];
|
|
|
715 |
|
716 |
-
function onKeyUp(
|
717 |
-
if (
|
718 |
-
|
719 |
}
|
720 |
-
}
|
721 |
-
|
722 |
|
723 |
function recalculateHeights() {
|
724 |
boxes.forEach(function (box) {
|
@@ -727,11 +718,10 @@ function recalculateHeights() {
|
|
727 |
}
|
728 |
|
729 |
function onElementClick(evt) {
|
730 |
-
//
|
731 |
-
var el = evt.target
|
732 |
-
var depth = 3;
|
733 |
|
734 |
-
for (var i = 0; i <=
|
735 |
if (!el || el.tagName === 'A') {
|
736 |
break;
|
737 |
}
|
@@ -743,141 +733,152 @@ function onElementClick(evt) {
|
|
743 |
return;
|
744 |
}
|
745 |
|
746 |
-
var
|
747 |
-
var match = href.match(/[#&]boxzilla-(\d+)/);
|
748 |
|
749 |
if (match && match.length > 1) {
|
750 |
-
|
751 |
-
Boxzilla.toggle(boxId);
|
752 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
753 |
} // initialise & add event listeners
|
754 |
|
755 |
|
756 |
-
|
757 |
if (initialised) {
|
758 |
return;
|
759 |
} // insert styles into DOM
|
760 |
|
761 |
|
762 |
var styleElement = document.createElement('style');
|
763 |
-
styleElement.setAttribute("type", "text/css");
|
764 |
styleElement.innerHTML = styles;
|
765 |
-
document.head.appendChild(styleElement); // init
|
766 |
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
document.body.addEventListener('click', onElementClick, true);
|
772 |
-
window.addEventListener('resize',
|
773 |
window.addEventListener('load', recalculateHeights);
|
774 |
document.addEventListener('keyup', onKeyUp);
|
775 |
-
|
776 |
initialised = true; // ensure this function doesn't run again
|
777 |
-
}
|
778 |
-
/**
|
779 |
-
* Create a new Box
|
780 |
-
*
|
781 |
-
* @param string id
|
782 |
-
* @param object opts
|
783 |
-
*
|
784 |
-
* @returns Box
|
785 |
-
*/
|
786 |
-
|
787 |
|
788 |
-
|
789 |
// preserve backwards compat for minimumScreenWidth option
|
790 |
-
if (typeof opts.minimumScreenWidth !==
|
791 |
opts.screenWidthCondition = {
|
792 |
-
condition:
|
793 |
value: opts.minimumScreenWidth
|
794 |
};
|
795 |
}
|
796 |
|
797 |
-
|
|
|
798 |
boxes.push(box);
|
799 |
return box;
|
800 |
-
}
|
|
|
|
|
|
|
801 |
|
802 |
-
Boxzilla.get = function (id) {
|
803 |
for (var i = 0; i < boxes.length; i++) {
|
804 |
-
if (boxes[i].id
|
805 |
return boxes[i];
|
806 |
}
|
807 |
}
|
808 |
|
809 |
-
throw new Error(
|
810 |
-
}
|
811 |
|
812 |
|
813 |
-
|
814 |
-
// if no id given, dismiss all current open boxes
|
815 |
if (id) {
|
816 |
-
|
817 |
} else {
|
818 |
boxes.forEach(function (box) {
|
819 |
return box.dismiss(animate);
|
820 |
});
|
821 |
}
|
822 |
-
}
|
823 |
|
824 |
-
|
825 |
if (id) {
|
826 |
-
|
827 |
} else {
|
828 |
boxes.forEach(function (box) {
|
829 |
return box.hide(animate);
|
830 |
});
|
831 |
}
|
832 |
-
}
|
833 |
|
834 |
-
|
835 |
if (id) {
|
836 |
-
|
837 |
} else {
|
838 |
boxes.forEach(function (box) {
|
839 |
return box.show(animate);
|
840 |
});
|
841 |
}
|
842 |
-
}
|
843 |
|
844 |
-
|
845 |
if (id) {
|
846 |
-
|
847 |
} else {
|
848 |
boxes.forEach(function (box) {
|
849 |
return box.toggle(animate);
|
850 |
});
|
851 |
}
|
852 |
-
}
|
853 |
-
|
854 |
-
|
855 |
-
Boxzilla
|
856 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
857 |
window.Boxzilla = Boxzilla;
|
858 |
|
859 |
if (typeof module !== 'undefined' && module.exports) {
|
860 |
module.exports = Boxzilla;
|
861 |
}
|
862 |
|
863 |
-
},{"./box.js":3,"./
|
864 |
-
'use strict';
|
865 |
-
|
866 |
-
var EventEmitter = require('wolfy87-eventemitter');
|
867 |
-
|
868 |
-
module.exports = Object.create(EventEmitter.prototype);
|
869 |
-
|
870 |
-
},{"wolfy87-eventemitter":13}],6:[function(require,module,exports){
|
871 |
"use strict";
|
872 |
|
873 |
-
var styles =
|
874 |
module.exports = styles;
|
875 |
|
876 |
-
},{}],
|
877 |
"use strict";
|
878 |
|
879 |
-
var Timer = function Timer(
|
880 |
-
this.time =
|
881 |
this.interval = 0;
|
882 |
};
|
883 |
|
@@ -900,7 +901,7 @@ Timer.prototype.stop = function () {
|
|
900 |
|
901 |
module.exports = Timer;
|
902 |
|
903 |
-
},{}],
|
904 |
"use strict";
|
905 |
|
906 |
module.exports = function (boxes) {
|
@@ -930,7 +931,7 @@ module.exports = function (boxes) {
|
|
930 |
timeout = null;
|
931 |
}
|
932 |
|
933 |
-
function onMouseEnter(
|
934 |
clearTimeout();
|
935 |
}
|
936 |
|
@@ -946,12 +947,12 @@ module.exports = function (boxes) {
|
|
946 |
clearTimeout(); // did mouse leave at top of window?
|
947 |
// add small exception space in the top-right corner
|
948 |
|
949 |
-
if (evt.clientY <= getAddressBarY() && evt.clientX < 0.
|
950 |
-
timeout = window.setTimeout(trigger,
|
951 |
}
|
952 |
}
|
953 |
|
954 |
-
function onTouchStart(
|
955 |
clearTimeout();
|
956 |
touchStart = {
|
957 |
timestamp: performance.now(),
|
@@ -968,7 +969,7 @@ module.exports = function (boxes) {
|
|
968 |
} // allow a tiny tiny margin for error, to not fire on clicks
|
969 |
|
970 |
|
971 |
-
if (window.scrollY + 20
|
972 |
return;
|
973 |
}
|
974 |
|
@@ -990,7 +991,7 @@ module.exports = function (boxes) {
|
|
990 |
document.documentElement.addEventListener('click', clearTimeout);
|
991 |
};
|
992 |
|
993 |
-
},{}],
|
994 |
"use strict";
|
995 |
|
996 |
module.exports = function (boxes) {
|
@@ -1005,14 +1006,14 @@ module.exports = function (boxes) {
|
|
1005 |
|
1006 |
window.setTimeout(function () {
|
1007 |
boxes.forEach(function (box) {
|
1008 |
-
if (box.config.trigger.method === 'pageviews' && pageviews
|
1009 |
box.trigger();
|
1010 |
}
|
1011 |
});
|
1012 |
}, 1000);
|
1013 |
};
|
1014 |
|
1015 |
-
},{}],
|
1016 |
"use strict";
|
1017 |
|
1018 |
var throttle = require('../util.js').throttle;
|
@@ -1029,10 +1030,8 @@ module.exports = function (boxes) {
|
|
1029 |
|
1030 |
if (scrollY > box.triggerHeight) {
|
1031 |
box.trigger();
|
1032 |
-
}
|
1033 |
-
|
1034 |
-
|
1035 |
-
if (box.mayRehide() && scrollY < box.triggerHeight - 5) {
|
1036 |
box.hide();
|
1037 |
}
|
1038 |
});
|
@@ -1042,14 +1041,14 @@ module.exports = function (boxes) {
|
|
1042 |
window.addEventListener('scroll', throttle(checkHeightCriteria), true);
|
1043 |
};
|
1044 |
|
1045 |
-
},{"../util.js":
|
1046 |
"use strict";
|
1047 |
|
1048 |
var Timer = require('../timer.js');
|
1049 |
|
1050 |
module.exports = function (boxes) {
|
1051 |
-
var siteTimer = new Timer(
|
1052 |
-
var pageTimer = new Timer(
|
1053 |
var timers = {
|
1054 |
start: function start() {
|
1055 |
try {
|
@@ -1072,7 +1071,7 @@ module.exports = function (boxes) {
|
|
1072 |
|
1073 |
timers.start(); // stop timers when leaving page or switching to other tab
|
1074 |
|
1075 |
-
document.addEventListener(
|
1076 |
document.hidden ? timers.stop() : timers.start();
|
1077 |
});
|
1078 |
window.addEventListener('beforeunload', function () {
|
@@ -1080,28 +1079,26 @@ module.exports = function (boxes) {
|
|
1080 |
});
|
1081 |
window.setInterval(function () {
|
1082 |
boxes.forEach(function (box) {
|
1083 |
-
if (box.config.trigger.method === 'time_on_site' && siteTimer.time
|
1084 |
box.trigger();
|
1085 |
-
}
|
1086 |
-
|
1087 |
-
if (box.config.trigger.method === 'time_on_page' && pageTimer.time >= box.config.trigger.value && box.mayAutoShow()) {
|
1088 |
box.trigger();
|
1089 |
}
|
1090 |
});
|
1091 |
}, 1000);
|
1092 |
};
|
1093 |
|
1094 |
-
},{"../timer.js":
|
1095 |
"use strict";
|
1096 |
|
1097 |
function throttle(fn, threshold, scope) {
|
1098 |
-
threshold || (threshold =
|
1099 |
var last;
|
1100 |
var deferTimer;
|
1101 |
return function () {
|
1102 |
var context = scope || this;
|
1103 |
-
var now = +new Date()
|
1104 |
-
|
1105 |
|
1106 |
if (last && now < last + threshold) {
|
1107 |
// hold on to it
|
@@ -1121,493 +1118,5 @@ module.exports = {
|
|
1121 |
throttle: throttle
|
1122 |
};
|
1123 |
|
1124 |
-
},{}],13:[function(require,module,exports){
|
1125 |
-
/*!
|
1126 |
-
* EventEmitter v5.2.8 - git.io/ee
|
1127 |
-
* Unlicense - http://unlicense.org/
|
1128 |
-
* Oliver Caldwell - https://oli.me.uk/
|
1129 |
-
* @preserve
|
1130 |
-
*/
|
1131 |
-
|
1132 |
-
;(function (exports) {
|
1133 |
-
'use strict';
|
1134 |
-
|
1135 |
-
/**
|
1136 |
-
* Class for managing events.
|
1137 |
-
* Can be extended to provide event functionality in other classes.
|
1138 |
-
*
|
1139 |
-
* @class EventEmitter Manages event registering and emitting.
|
1140 |
-
*/
|
1141 |
-
function EventEmitter() {}
|
1142 |
-
|
1143 |
-
// Shortcuts to improve speed and size
|
1144 |
-
var proto = EventEmitter.prototype;
|
1145 |
-
var originalGlobalValue = exports.EventEmitter;
|
1146 |
-
|
1147 |
-
/**
|
1148 |
-
* Finds the index of the listener for the event in its storage array.
|
1149 |
-
*
|
1150 |
-
* @param {Function[]} listeners Array of listeners to search through.
|
1151 |
-
* @param {Function} listener Method to look for.
|
1152 |
-
* @return {Number} Index of the specified listener, -1 if not found
|
1153 |
-
* @api private
|
1154 |
-
*/
|
1155 |
-
function indexOfListener(listeners, listener) {
|
1156 |
-
var i = listeners.length;
|
1157 |
-
while (i--) {
|
1158 |
-
if (listeners[i].listener === listener) {
|
1159 |
-
return i;
|
1160 |
-
}
|
1161 |
-
}
|
1162 |
-
|
1163 |
-
return -1;
|
1164 |
-
}
|
1165 |
-
|
1166 |
-
/**
|
1167 |
-
* Alias a method while keeping the context correct, to allow for overwriting of target method.
|
1168 |
-
*
|
1169 |
-
* @param {String} name The name of the target method.
|
1170 |
-
* @return {Function} The aliased method
|
1171 |
-
* @api private
|
1172 |
-
*/
|
1173 |
-
function alias(name) {
|
1174 |
-
return function aliasClosure() {
|
1175 |
-
return this[name].apply(this, arguments);
|
1176 |
-
};
|
1177 |
-
}
|
1178 |
-
|
1179 |
-
/**
|
1180 |
-
* Returns the listener array for the specified event.
|
1181 |
-
* Will initialise the event object and listener arrays if required.
|
1182 |
-
* Will return an object if you use a regex search. The object contains keys for each matched event. So /ba[rz]/ might return an object containing bar and baz. But only if you have either defined them with defineEvent or added some listeners to them.
|
1183 |
-
* Each property in the object response is an array of listener functions.
|
1184 |
-
*
|
1185 |
-
* @param {String|RegExp} evt Name of the event to return the listeners from.
|
1186 |
-
* @return {Function[]|Object} All listener functions for the event.
|
1187 |
-
*/
|
1188 |
-
proto.getListeners = function getListeners(evt) {
|
1189 |
-
var events = this._getEvents();
|
1190 |
-
var response;
|
1191 |
-
var key;
|
1192 |
-
|
1193 |
-
// Return a concatenated array of all matching events if
|
1194 |
-
// the selector is a regular expression.
|
1195 |
-
if (evt instanceof RegExp) {
|
1196 |
-
response = {};
|
1197 |
-
for (key in events) {
|
1198 |
-
if (events.hasOwnProperty(key) && evt.test(key)) {
|
1199 |
-
response[key] = events[key];
|
1200 |
-
}
|
1201 |
-
}
|
1202 |
-
}
|
1203 |
-
else {
|
1204 |
-
response = events[evt] || (events[evt] = []);
|
1205 |
-
}
|
1206 |
-
|
1207 |
-
return response;
|
1208 |
-
};
|
1209 |
-
|
1210 |
-
/**
|
1211 |
-
* Takes a list of listener objects and flattens it into a list of listener functions.
|
1212 |
-
*
|
1213 |
-
* @param {Object[]} listeners Raw listener objects.
|
1214 |
-
* @return {Function[]} Just the listener functions.
|
1215 |
-
*/
|
1216 |
-
proto.flattenListeners = function flattenListeners(listeners) {
|
1217 |
-
var flatListeners = [];
|
1218 |
-
var i;
|
1219 |
-
|
1220 |
-
for (i = 0; i < listeners.length; i += 1) {
|
1221 |
-
flatListeners.push(listeners[i].listener);
|
1222 |
-
}
|
1223 |
-
|
1224 |
-
return flatListeners;
|
1225 |
-
};
|
1226 |
-
|
1227 |
-
/**
|
1228 |
-
* Fetches the requested listeners via getListeners but will always return the results inside an object. This is mainly for internal use but others may find it useful.
|
1229 |
-
*
|
1230 |
-
* @param {String|RegExp} evt Name of the event to return the listeners from.
|
1231 |
-
* @return {Object} All listener functions for an event in an object.
|
1232 |
-
*/
|
1233 |
-
proto.getListenersAsObject = function getListenersAsObject(evt) {
|
1234 |
-
var listeners = this.getListeners(evt);
|
1235 |
-
var response;
|
1236 |
-
|
1237 |
-
if (listeners instanceof Array) {
|
1238 |
-
response = {};
|
1239 |
-
response[evt] = listeners;
|
1240 |
-
}
|
1241 |
-
|
1242 |
-
return response || listeners;
|
1243 |
-
};
|
1244 |
-
|
1245 |
-
function isValidListener (listener) {
|
1246 |
-
if (typeof listener === 'function' || listener instanceof RegExp) {
|
1247 |
-
return true
|
1248 |
-
} else if (listener && typeof listener === 'object') {
|
1249 |
-
return isValidListener(listener.listener)
|
1250 |
-
} else {
|
1251 |
-
return false
|
1252 |
-
}
|
1253 |
-
}
|
1254 |
-
|
1255 |
-
/**
|
1256 |
-
* Adds a listener function to the specified event.
|
1257 |
-
* The listener will not be added if it is a duplicate.
|
1258 |
-
* If the listener returns true then it will be removed after it is called.
|
1259 |
-
* If you pass a regular expression as the event name then the listener will be added to all events that match it.
|
1260 |
-
*
|
1261 |
-
* @param {String|RegExp} evt Name of the event to attach the listener to.
|
1262 |
-
* @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling.
|
1263 |
-
* @return {Object} Current instance of EventEmitter for chaining.
|
1264 |
-
*/
|
1265 |
-
proto.addListener = function addListener(evt, listener) {
|
1266 |
-
if (!isValidListener(listener)) {
|
1267 |
-
throw new TypeError('listener must be a function');
|
1268 |
-
}
|
1269 |
-
|
1270 |
-
var listeners = this.getListenersAsObject(evt);
|
1271 |
-
var listenerIsWrapped = typeof listener === 'object';
|
1272 |
-
var key;
|
1273 |
-
|
1274 |
-
for (key in listeners) {
|
1275 |
-
if (listeners.hasOwnProperty(key) && indexOfListener(listeners[key], listener) === -1) {
|
1276 |
-
listeners[key].push(listenerIsWrapped ? listener : {
|
1277 |
-
listener: listener,
|
1278 |
-
once: false
|
1279 |
-
});
|
1280 |
-
}
|
1281 |
-
}
|
1282 |
-
|
1283 |
-
return this;
|
1284 |
-
};
|
1285 |
-
|
1286 |
-
/**
|
1287 |
-
* Alias of addListener
|
1288 |
-
*/
|
1289 |
-
proto.on = alias('addListener');
|
1290 |
-
|
1291 |
-
/**
|
1292 |
-
* Semi-alias of addListener. It will add a listener that will be
|
1293 |
-
* automatically removed after its first execution.
|
1294 |
-
*
|
1295 |
-
* @param {String|RegExp} evt Name of the event to attach the listener to.
|
1296 |
-
* @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling.
|
1297 |
-
* @return {Object} Current instance of EventEmitter for chaining.
|
1298 |
-
*/
|
1299 |
-
proto.addOnceListener = function addOnceListener(evt, listener) {
|
1300 |
-
return this.addListener(evt, {
|
1301 |
-
listener: listener,
|
1302 |
-
once: true
|
1303 |
-
});
|
1304 |
-
};
|
1305 |
-
|
1306 |
-
/**
|
1307 |
-
* Alias of addOnceListener.
|
1308 |
-
*/
|
1309 |
-
proto.once = alias('addOnceListener');
|
1310 |
-
|
1311 |
-
/**
|
1312 |
-
* Defines an event name. This is required if you want to use a regex to add a listener to multiple events at once. If you don't do this then how do you expect it to know what event to add to? Should it just add to every possible match for a regex? No. That is scary and bad.
|
1313 |
-
* You need to tell it what event names should be matched by a regex.
|
1314 |
-
*
|
1315 |
-
* @param {String} evt Name of the event to create.
|
1316 |
-
* @return {Object} Current instance of EventEmitter for chaining.
|
1317 |
-
*/
|
1318 |
-
proto.defineEvent = function defineEvent(evt) {
|
1319 |
-
this.getListeners(evt);
|
1320 |
-
return this;
|
1321 |
-
};
|
1322 |
-
|
1323 |
-
/**
|
1324 |
-
* Uses defineEvent to define multiple events.
|
1325 |
-
*
|
1326 |
-
* @param {String[]} evts An array of event names to define.
|
1327 |
-
* @return {Object} Current instance of EventEmitter for chaining.
|
1328 |
-
*/
|
1329 |
-
proto.defineEvents = function defineEvents(evts) {
|
1330 |
-
for (var i = 0; i < evts.length; i += 1) {
|
1331 |
-
this.defineEvent(evts[i]);
|
1332 |
-
}
|
1333 |
-
return this;
|
1334 |
-
};
|
1335 |
-
|
1336 |
-
/**
|
1337 |
-
* Removes a listener function from the specified event.
|
1338 |
-
* When passed a regular expression as the event name, it will remove the listener from all events that match it.
|
1339 |
-
*
|
1340 |
-
* @param {String|RegExp} evt Name of the event to remove the listener from.
|
1341 |
-
* @param {Function} listener Method to remove from the event.
|
1342 |
-
* @return {Object} Current instance of EventEmitter for chaining.
|
1343 |
-
*/
|
1344 |
-
proto.removeListener = function removeListener(evt, listener) {
|
1345 |
-
var listeners = this.getListenersAsObject(evt);
|
1346 |
-
var index;
|
1347 |
-
var key;
|
1348 |
-
|
1349 |
-
for (key in listeners) {
|
1350 |
-
if (listeners.hasOwnProperty(key)) {
|
1351 |
-
index = indexOfListener(listeners[key], listener);
|
1352 |
-
|
1353 |
-
if (index !== -1) {
|
1354 |
-
listeners[key].splice(index, 1);
|
1355 |
-
}
|
1356 |
-
}
|
1357 |
-
}
|
1358 |
-
|
1359 |
-
return this;
|
1360 |
-
};
|
1361 |
-
|
1362 |
-
/**
|
1363 |
-
* Alias of removeListener
|
1364 |
-
*/
|
1365 |
-
proto.off = alias('removeListener');
|
1366 |
-
|
1367 |
-
/**
|
1368 |
-
* Adds listeners in bulk using the manipulateListeners method.
|
1369 |
-
* If you pass an object as the first argument you can add to multiple events at once. The object should contain key value pairs of events and listeners or listener arrays. You can also pass it an event name and an array of listeners to be added.
|
1370 |
-
* You can also pass it a regular expression to add the array of listeners to all events that match it.
|
1371 |
-
* Yeah, this function does quite a bit. That's probably a bad thing.
|
1372 |
-
*
|
1373 |
-
* @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to add to multiple events at once.
|
1374 |
-
* @param {Function[]} [listeners] An optional array of listener functions to add.
|
1375 |
-
* @return {Object} Current instance of EventEmitter for chaining.
|
1376 |
-
*/
|
1377 |
-
proto.addListeners = function addListeners(evt, listeners) {
|
1378 |
-
// Pass through to manipulateListeners
|
1379 |
-
return this.manipulateListeners(false, evt, listeners);
|
1380 |
-
};
|
1381 |
-
|
1382 |
-
/**
|
1383 |
-
* Removes listeners in bulk using the manipulateListeners method.
|
1384 |
-
* If you pass an object as the first argument you can remove from multiple events at once. The object should contain key value pairs of events and listeners or listener arrays.
|
1385 |
-
* You can also pass it an event name and an array of listeners to be removed.
|
1386 |
-
* You can also pass it a regular expression to remove the listeners from all events that match it.
|
1387 |
-
*
|
1388 |
-
* @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to remove from multiple events at once.
|
1389 |
-
* @param {Function[]} [listeners] An optional array of listener functions to remove.
|
1390 |
-
* @return {Object} Current instance of EventEmitter for chaining.
|
1391 |
-
*/
|
1392 |
-
proto.removeListeners = function removeListeners(evt, listeners) {
|
1393 |
-
// Pass through to manipulateListeners
|
1394 |
-
return this.manipulateListeners(true, evt, listeners);
|
1395 |
-
};
|
1396 |
-
|
1397 |
-
/**
|
1398 |
-
* Edits listeners in bulk. The addListeners and removeListeners methods both use this to do their job. You should really use those instead, this is a little lower level.
|
1399 |
-
* The first argument will determine if the listeners are removed (true) or added (false).
|
1400 |
-
* If you pass an object as the second argument you can add/remove from multiple events at once. The object should contain key value pairs of events and listeners or listener arrays.
|
1401 |
-
* You can also pass it an event name and an array of listeners to be added/removed.
|
1402 |
-
* You can also pass it a regular expression to manipulate the listeners of all events that match it.
|
1403 |
-
*
|
1404 |
-
* @param {Boolean} remove True if you want to remove listeners, false if you want to add.
|
1405 |
-
* @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to add/remove from multiple events at once.
|
1406 |
-
* @param {Function[]} [listeners] An optional array of listener functions to add/remove.
|
1407 |
-
* @return {Object} Current instance of EventEmitter for chaining.
|
1408 |
-
*/
|
1409 |
-
proto.manipulateListeners = function manipulateListeners(remove, evt, listeners) {
|
1410 |
-
var i;
|
1411 |
-
var value;
|
1412 |
-
var single = remove ? this.removeListener : this.addListener;
|
1413 |
-
var multiple = remove ? this.removeListeners : this.addListeners;
|
1414 |
-
|
1415 |
-
// If evt is an object then pass each of its properties to this method
|
1416 |
-
if (typeof evt === 'object' && !(evt instanceof RegExp)) {
|
1417 |
-
for (i in evt) {
|
1418 |
-
if (evt.hasOwnProperty(i) && (value = evt[i])) {
|
1419 |
-
// Pass the single listener straight through to the singular method
|
1420 |
-
if (typeof value === 'function') {
|
1421 |
-
single.call(this, i, value);
|
1422 |
-
}
|
1423 |
-
else {
|
1424 |
-
// Otherwise pass back to the multiple function
|
1425 |
-
multiple.call(this, i, value);
|
1426 |
-
}
|
1427 |
-
}
|
1428 |
-
}
|
1429 |
-
}
|
1430 |
-
else {
|
1431 |
-
// So evt must be a string
|
1432 |
-
// And listeners must be an array of listeners
|
1433 |
-
// Loop over it and pass each one to the multiple method
|
1434 |
-
i = listeners.length;
|
1435 |
-
while (i--) {
|
1436 |
-
single.call(this, evt, listeners[i]);
|
1437 |
-
}
|
1438 |
-
}
|
1439 |
-
|
1440 |
-
return this;
|
1441 |
-
};
|
1442 |
-
|
1443 |
-
/**
|
1444 |
-
* Removes all listeners from a specified event.
|
1445 |
-
* If you do not specify an event then all listeners will be removed.
|
1446 |
-
* That means every event will be emptied.
|
1447 |
-
* You can also pass a regex to remove all events that match it.
|
1448 |
-
*
|
1449 |
-
* @param {String|RegExp} [evt] Optional name of the event to remove all listeners for. Will remove from every event if not passed.
|
1450 |
-
* @return {Object} Current instance of EventEmitter for chaining.
|
1451 |
-
*/
|
1452 |
-
proto.removeEvent = function removeEvent(evt) {
|
1453 |
-
var type = typeof evt;
|
1454 |
-
var events = this._getEvents();
|
1455 |
-
var key;
|
1456 |
-
|
1457 |
-
// Remove different things depending on the state of evt
|
1458 |
-
if (type === 'string') {
|
1459 |
-
// Remove all listeners for the specified event
|
1460 |
-
delete events[evt];
|
1461 |
-
}
|
1462 |
-
else if (evt instanceof RegExp) {
|
1463 |
-
// Remove all events matching the regex.
|
1464 |
-
for (key in events) {
|
1465 |
-
if (events.hasOwnProperty(key) && evt.test(key)) {
|
1466 |
-
delete events[key];
|
1467 |
-
}
|
1468 |
-
}
|
1469 |
-
}
|
1470 |
-
else {
|
1471 |
-
// Remove all listeners in all events
|
1472 |
-
delete this._events;
|
1473 |
-
}
|
1474 |
-
|
1475 |
-
return this;
|
1476 |
-
};
|
1477 |
-
|
1478 |
-
/**
|
1479 |
-
* Alias of removeEvent.
|
1480 |
-
*
|
1481 |
-
* Added to mirror the node API.
|
1482 |
-
*/
|
1483 |
-
proto.removeAllListeners = alias('removeEvent');
|
1484 |
-
|
1485 |
-
/**
|
1486 |
-
* Emits an event of your choice.
|
1487 |
-
* When emitted, every listener attached to that event will be executed.
|
1488 |
-
* If you pass the optional argument array then those arguments will be passed to every listener upon execution.
|
1489 |
-
* Because it uses `apply`, your array of arguments will be passed as if you wrote them out separately.
|
1490 |
-
* So they will not arrive within the array on the other side, they will be separate.
|
1491 |
-
* You can also pass a regular expression to emit to all events that match it.
|
1492 |
-
*
|
1493 |
-
* @param {String|RegExp} evt Name of the event to emit and execute listeners for.
|
1494 |
-
* @param {Array} [args] Optional array of arguments to be passed to each listener.
|
1495 |
-
* @return {Object} Current instance of EventEmitter for chaining.
|
1496 |
-
*/
|
1497 |
-
proto.emitEvent = function emitEvent(evt, args) {
|
1498 |
-
var listenersMap = this.getListenersAsObject(evt);
|
1499 |
-
var listeners;
|
1500 |
-
var listener;
|
1501 |
-
var i;
|
1502 |
-
var key;
|
1503 |
-
var response;
|
1504 |
-
|
1505 |
-
for (key in listenersMap) {
|
1506 |
-
if (listenersMap.hasOwnProperty(key)) {
|
1507 |
-
listeners = listenersMap[key].slice(0);
|
1508 |
-
|
1509 |
-
for (i = 0; i < listeners.length; i++) {
|
1510 |
-
// If the listener returns true then it shall be removed from the event
|
1511 |
-
// The function is executed either with a basic call or an apply if there is an args array
|
1512 |
-
listener = listeners[i];
|
1513 |
-
|
1514 |
-
if (listener.once === true) {
|
1515 |
-
this.removeListener(evt, listener.listener);
|
1516 |
-
}
|
1517 |
-
|
1518 |
-
response = listener.listener.apply(this, args || []);
|
1519 |
-
|
1520 |
-
if (response === this._getOnceReturnValue()) {
|
1521 |
-
this.removeListener(evt, listener.listener);
|
1522 |
-
}
|
1523 |
-
}
|
1524 |
-
}
|
1525 |
-
}
|
1526 |
-
|
1527 |
-
return this;
|
1528 |
-
};
|
1529 |
-
|
1530 |
-
/**
|
1531 |
-
* Alias of emitEvent
|
1532 |
-
*/
|
1533 |
-
proto.trigger = alias('emitEvent');
|
1534 |
-
|
1535 |
-
/**
|
1536 |
-
* Subtly different from emitEvent in that it will pass its arguments on to the listeners, as opposed to taking a single array of arguments to pass on.
|
1537 |
-
* As with emitEvent, you can pass a regex in place of the event name to emit to all events that match it.
|
1538 |
-
*
|
1539 |
-
* @param {String|RegExp} evt Name of the event to emit and execute listeners for.
|
1540 |
-
* @param {...*} Optional additional arguments to be passed to each listener.
|
1541 |
-
* @return {Object} Current instance of EventEmitter for chaining.
|
1542 |
-
*/
|
1543 |
-
proto.emit = function emit(evt) {
|
1544 |
-
var args = Array.prototype.slice.call(arguments, 1);
|
1545 |
-
return this.emitEvent(evt, args);
|
1546 |
-
};
|
1547 |
-
|
1548 |
-
/**
|
1549 |
-
* Sets the current value to check against when executing listeners. If a
|
1550 |
-
* listeners return value matches the one set here then it will be removed
|
1551 |
-
* after execution. This value defaults to true.
|
1552 |
-
*
|
1553 |
-
* @param {*} value The new value to check for when executing listeners.
|
1554 |
-
* @return {Object} Current instance of EventEmitter for chaining.
|
1555 |
-
*/
|
1556 |
-
proto.setOnceReturnValue = function setOnceReturnValue(value) {
|
1557 |
-
this._onceReturnValue = value;
|
1558 |
-
return this;
|
1559 |
-
};
|
1560 |
-
|
1561 |
-
/**
|
1562 |
-
* Fetches the current value to check against when executing listeners. If
|
1563 |
-
* the listeners return value matches this one then it should be removed
|
1564 |
-
* automatically. It will return true by default.
|
1565 |
-
*
|
1566 |
-
* @return {*|Boolean} The current value to check for or the default, true.
|
1567 |
-
* @api private
|
1568 |
-
*/
|
1569 |
-
proto._getOnceReturnValue = function _getOnceReturnValue() {
|
1570 |
-
if (this.hasOwnProperty('_onceReturnValue')) {
|
1571 |
-
return this._onceReturnValue;
|
1572 |
-
}
|
1573 |
-
else {
|
1574 |
-
return true;
|
1575 |
-
}
|
1576 |
-
};
|
1577 |
-
|
1578 |
-
/**
|
1579 |
-
* Fetches the events object and creates one if required.
|
1580 |
-
*
|
1581 |
-
* @return {Object} The events storage object.
|
1582 |
-
* @api private
|
1583 |
-
*/
|
1584 |
-
proto._getEvents = function _getEvents() {
|
1585 |
-
return this._events || (this._events = {});
|
1586 |
-
};
|
1587 |
-
|
1588 |
-
/**
|
1589 |
-
* Reverts the global {@link EventEmitter} to its previous value and returns a reference to this version.
|
1590 |
-
*
|
1591 |
-
* @return {Function} Non conflicting EventEmitter class.
|
1592 |
-
*/
|
1593 |
-
EventEmitter.noConflict = function noConflict() {
|
1594 |
-
exports.EventEmitter = originalGlobalValue;
|
1595 |
-
return EventEmitter;
|
1596 |
-
};
|
1597 |
-
|
1598 |
-
// Expose the class either via AMD, CommonJS or the global object
|
1599 |
-
if (typeof define === 'function' && define.amd) {
|
1600 |
-
define(function () {
|
1601 |
-
return EventEmitter;
|
1602 |
-
});
|
1603 |
-
}
|
1604 |
-
else if (typeof module === 'object' && module.exports){
|
1605 |
-
module.exports = EventEmitter;
|
1606 |
-
}
|
1607 |
-
else {
|
1608 |
-
exports.EventEmitter = EventEmitter;
|
1609 |
-
}
|
1610 |
-
}(typeof window !== 'undefined' ? window : this || {}));
|
1611 |
-
|
1612 |
},{}]},{},[1]);
|
1613 |
; })();
|
4 |
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
5 |
|
6 |
(function () {
|
|
|
|
|
7 |
var Boxzilla = require('boxzilla');
|
8 |
|
9 |
+
var options = window.boxzilla_options; // helper function for setting CSS styles
|
|
|
|
|
10 |
|
11 |
function css(element, styles) {
|
12 |
if (styles.background_color) {
|
22 |
}
|
23 |
|
24 |
if (styles.border_width) {
|
25 |
+
element.style.borderWidth = parseInt(styles.border_width) + 'px';
|
26 |
}
|
27 |
|
28 |
if (styles.border_style) {
|
30 |
}
|
31 |
|
32 |
if (styles.width) {
|
33 |
+
element.style.maxWidth = parseInt(styles.width) + 'px';
|
34 |
}
|
35 |
}
|
36 |
|
62 |
css(box.element, boxOpts.css);
|
63 |
|
64 |
try {
|
65 |
+
box.element.firstChild.firstChild.className += ' first-child';
|
66 |
+
box.element.firstChild.lastChild.className += ' last-child';
|
67 |
} catch (e) {} // maybe show box right away
|
68 |
|
69 |
|
81 |
}
|
82 |
|
83 |
function locationHashRefersBox(box) {
|
84 |
+
if (!window.location.hash || window.location.hash.length === 0) {
|
85 |
return false;
|
86 |
} // parse "boxzilla-{id}" from location hash
|
87 |
|
88 |
|
89 |
var match = window.location.hash.match(/[#&](boxzilla-\d+)/);
|
90 |
|
91 |
+
if (!match || _typeof(match) !== 'object' || match.length < 2) {
|
92 |
return false;
|
93 |
}
|
94 |
|
104 |
}
|
105 |
|
106 |
function maybeOpenMailChimpForWordPressBox() {
|
107 |
+
if ((_typeof(window.mc4wp_forms_config) !== 'object' || !window.mc4wp_forms_config.submitted_form) && _typeof(window.mc4wp_submitted_form) !== 'object') {
|
108 |
return;
|
109 |
}
|
110 |
|
111 |
+
var form = window.mc4wp_submitted_form || window.mc4wp_forms_config.submitted_form;
|
112 |
+
var selector = '#' + form.element_id;
|
113 |
Boxzilla.boxes.forEach(function (box) {
|
114 |
if (box.element.querySelector(selector)) {
|
115 |
box.show();
|
131 |
})();
|
132 |
|
133 |
},{"boxzilla":4}],2:[function(require,module,exports){
|
134 |
+
"use strict";
|
135 |
|
136 |
var duration = 320;
|
137 |
|
200 |
}; // store attribute so everyone knows we're animating this element
|
201 |
|
202 |
|
203 |
+
element.setAttribute('data-animated', 'true'); // toggle element visiblity right away if we're making something visible
|
204 |
|
205 |
if (!nowVisible) {
|
206 |
element.style.display = '';
|
210 |
var visibleStyles; // animate properties
|
211 |
|
212 |
if (animation === 'slide') {
|
213 |
+
hiddenStyles = initObjectProperties(['height', 'borderTopWidth', 'borderBottomWidth', 'paddingTop', 'paddingBottom'], 0);
|
214 |
visibleStyles = {};
|
215 |
|
216 |
if (!nowVisible) {
|
217 |
var computedStyles = window.getComputedStyle(element);
|
218 |
+
visibleStyles = copyObjectProperties(['height', 'borderTopWidth', 'borderBottomWidth', 'paddingTop', 'paddingBottom'], computedStyles); // in some browsers, getComputedStyle returns "auto" value. this falls back to getBoundingClientRect() in those browsers since we need an actual height.
|
219 |
|
220 |
if (!isFinite(visibleStyles.height)) {
|
221 |
var clientRect = element.getBoundingClientRect();
|
261 |
var to = targetStyles[property];
|
262 |
var current = parseFloat(initialStyles[property]); // is there something to do?
|
263 |
|
264 |
+
if (current === to) {
|
265 |
delete targetStyles[property];
|
266 |
continue;
|
267 |
}
|
295 |
|
296 |
|
297 |
currentStyles[_property] = newValue;
|
298 |
+
element.style[_property] = _property !== 'opacity' ? newValue + 'px' : newValue;
|
|
|
299 |
}
|
300 |
|
301 |
+
last = +new Date();
|
302 |
|
303 |
if (!done) {
|
304 |
+
// keep going until we're done for all props
|
305 |
+
window.requestAnimationFrame(tick);
|
306 |
} else {
|
307 |
// call callback
|
308 |
fn && fn();
|
313 |
}
|
314 |
|
315 |
module.exports = {
|
316 |
+
toggle: toggle,
|
317 |
+
animate: animate,
|
318 |
+
animated: animated
|
319 |
};
|
320 |
|
321 |
},{}],3:[function(require,module,exports){
|
322 |
+
"use strict";
|
323 |
|
324 |
var defaults = {
|
325 |
+
animation: 'fade',
|
326 |
+
rehide: false,
|
327 |
+
content: '',
|
328 |
+
cookie: null,
|
329 |
+
icon: '×',
|
330 |
+
screenWidthCondition: null,
|
331 |
+
position: 'center',
|
332 |
+
testMode: false,
|
333 |
+
trigger: false,
|
334 |
+
closable: true
|
335 |
};
|
336 |
|
|
|
|
|
337 |
var Animator = require('./animator.js');
|
338 |
/**
|
339 |
+
* Merge 2 objects, values of the latter overwriting the former.
|
340 |
+
*
|
341 |
+
* @param obj1
|
342 |
+
* @param obj2
|
343 |
+
* @returns {*}
|
344 |
+
*/
|
345 |
|
346 |
|
347 |
function merge(obj1, obj2) {
|
363 |
return obj3;
|
364 |
}
|
365 |
/**
|
366 |
+
* Get the real height of entire document.
|
367 |
+
* @returns {number}
|
368 |
+
*/
|
369 |
|
370 |
|
371 |
function getDocumentHeight() {
|
375 |
} // Box Object
|
376 |
|
377 |
|
378 |
+
function Box(id, config, fireEvent) {
|
379 |
+
this.id = id;
|
380 |
+
this.fireEvent = fireEvent; // store config values
|
381 |
|
382 |
this.config = merge(defaults, config); // add overlay element to dom and store ref to overlay
|
383 |
|
399 |
this.dom(); // further initialise the box
|
400 |
|
401 |
this.events();
|
402 |
+
} // initialise the box
|
403 |
|
|
|
404 |
|
405 |
Box.prototype.events = function () {
|
406 |
var box = this; // attach event to "close" icon inside box
|
414 |
|
415 |
this.element.addEventListener('click', function (evt) {
|
416 |
if (evt.target.tagName === 'A') {
|
417 |
+
this.fireEvent('box.interactions.link', [box, evt.target]);
|
418 |
}
|
419 |
}, false);
|
420 |
this.element.addEventListener('submit', function (evt) {
|
421 |
box.setCookie();
|
422 |
+
this.fireEvent('box.interactions.form', [box, evt.target]);
|
423 |
}, false);
|
424 |
this.overlay.addEventListener('click', function (e) {
|
425 |
var x = e.offsetX;
|
439 |
var wrapper = document.createElement('div');
|
440 |
wrapper.className = 'boxzilla-container boxzilla-' + this.config.position + '-container';
|
441 |
var box = document.createElement('div');
|
442 |
+
box.id = 'boxzilla-' + this.id;
|
443 |
box.className = 'boxzilla boxzilla-' + this.id + ' boxzilla-' + this.config.position;
|
444 |
box.style.display = 'none';
|
445 |
wrapper.appendChild(box);
|
446 |
var content;
|
447 |
|
448 |
+
if (typeof this.config.content === 'string') {
|
449 |
content = document.createElement('div');
|
450 |
content.innerHTML = this.config.content;
|
451 |
} else {
|
459 |
|
460 |
if (this.config.closable && this.config.icon) {
|
461 |
var closeIcon = document.createElement('span');
|
462 |
+
closeIcon.className = 'boxzilla-close-icon';
|
463 |
closeIcon.innerHTML = this.config.icon;
|
464 |
box.appendChild(closeIcon);
|
465 |
this.closeIcon = closeIcon;
|
482 |
var boxHeight = this.element.clientHeight; // add scrollbar to box and limit height
|
483 |
|
484 |
if (boxHeight > windowHeight) {
|
485 |
+
this.element.style.maxHeight = windowHeight + 'px';
|
486 |
this.element.style.overflowY = 'scroll';
|
487 |
} // set new top margin for boxes which are centered
|
488 |
|
490 |
if (this.config.position === 'center') {
|
491 |
var newTopMargin = (windowHeight - boxHeight) / 2;
|
492 |
newTopMargin = newTopMargin >= 0 ? newTopMargin : 0;
|
493 |
+
this.element.style.marginTop = newTopMargin + 'px';
|
494 |
}
|
495 |
|
496 |
this.element.style.display = origDisplay;
|
498 |
|
499 |
|
500 |
Box.prototype.toggle = function (show, animate) {
|
501 |
+
show = typeof show === 'undefined' ? !this.visible : show;
|
502 |
+
animate = typeof animate === 'undefined' ? true : animate; // is box already at desired visibility?
|
503 |
|
504 |
if (show === this.visible) {
|
505 |
return false;
|
520 |
|
521 |
this.setCustomBoxStyling(); // trigger event
|
522 |
|
523 |
+
this.fireEvent('box.' + (show ? 'show' : 'hide'), [this]); // show or hide box using selected animation
|
524 |
|
525 |
if (this.config.position === 'center') {
|
526 |
this.overlay.classList.toggle('boxzilla-' + this.id + '-overlay');
|
527 |
|
528 |
if (animate) {
|
529 |
+
Animator.toggle(this.overlay, 'fade');
|
530 |
} else {
|
531 |
this.overlay.style.display = show ? '' : 'none';
|
532 |
}
|
538 |
return;
|
539 |
}
|
540 |
|
541 |
+
this.contentElement.innerHTML = this.contentElement.innerHTML + '';
|
542 |
}.bind(this));
|
543 |
} else {
|
544 |
this.element.style.display = show ? '' : 'none';
|
583 |
}
|
584 |
|
585 |
switch (this.config.screenWidthCondition.condition) {
|
586 |
+
case 'larger':
|
587 |
return window.innerWidth > this.config.screenWidthCondition.value;
|
588 |
|
589 |
+
case 'smaller':
|
590 |
return window.innerWidth < this.config.screenWidthCondition.value;
|
591 |
} // meh.. condition should be "smaller" or "larger", just return true.
|
592 |
|
634 |
return false;
|
635 |
}
|
636 |
|
637 |
+
return document.cookie.replace(new RegExp('(?:(?:^|.*;)\\s*' + 'boxzilla_box_' + this.id + '\\s*\\=\\s*([^;]*).*$)|^.*$'), '$1') === 'true';
|
|
|
638 |
}; // set cookie that disables automatically showing the box
|
639 |
|
640 |
|
658 |
}
|
659 |
};
|
660 |
/**
|
661 |
+
* Dismisses the box and optionally sets a cookie.
|
662 |
+
* @param animate
|
663 |
+
* @returns {boolean}
|
664 |
+
*/
|
665 |
|
666 |
|
667 |
Box.prototype.dismiss = function (animate) {
|
678 |
}
|
679 |
|
680 |
this.dismissed = true;
|
681 |
+
this.fireEvent('box.dismiss', [this]);
|
682 |
return true;
|
683 |
};
|
684 |
|
685 |
module.exports = Box;
|
686 |
|
687 |
+
},{"./animator.js":2}],4:[function(require,module,exports){
|
688 |
+
"use strict";
|
|
|
|
|
689 |
|
690 |
var Box = require('./box.js');
|
691 |
|
692 |
+
var throttle = require('./util.js').throttle;
|
693 |
|
694 |
var styles = require('./styles.js');
|
695 |
|
702 |
var Time = require('./triggers/time.js');
|
703 |
|
704 |
var initialised = false;
|
705 |
+
var boxes = [];
|
706 |
+
var listeners = {};
|
707 |
|
708 |
+
function onKeyUp(evt) {
|
709 |
+
if (evt.key === 'Escape' || evt.key === 'Esc') {
|
710 |
+
dismiss();
|
711 |
}
|
712 |
+
}
|
|
|
713 |
|
714 |
function recalculateHeights() {
|
715 |
boxes.forEach(function (box) {
|
718 |
}
|
719 |
|
720 |
function onElementClick(evt) {
|
721 |
+
// bubble up to <a> element
|
722 |
+
var el = evt.target;
|
|
|
723 |
|
724 |
+
for (var i = 0; i <= 3; i++) {
|
725 |
if (!el || el.tagName === 'A') {
|
726 |
break;
|
727 |
}
|
733 |
return;
|
734 |
}
|
735 |
|
736 |
+
var match = el.href.match(/[#&]boxzilla-(.+)/i);
|
|
|
737 |
|
738 |
if (match && match.length > 1) {
|
739 |
+
toggle(match[1]);
|
|
|
740 |
}
|
741 |
+
}
|
742 |
+
|
743 |
+
function trigger(event, args) {
|
744 |
+
listeners[event] && listeners[event].forEach(function (f) {
|
745 |
+
return f.apply(null, args);
|
746 |
+
});
|
747 |
+
}
|
748 |
+
|
749 |
+
function on(event, fn) {
|
750 |
+
listeners[event] = listeners[event] || [];
|
751 |
+
listeners[event].push(fn);
|
752 |
+
}
|
753 |
+
|
754 |
+
function off(event, fn) {
|
755 |
+
listeners[event] && listeners[event].filter(function (f) {
|
756 |
+
return f !== fn;
|
757 |
+
});
|
758 |
} // initialise & add event listeners
|
759 |
|
760 |
|
761 |
+
function init() {
|
762 |
if (initialised) {
|
763 |
return;
|
764 |
} // insert styles into DOM
|
765 |
|
766 |
|
767 |
var styleElement = document.createElement('style');
|
|
|
768 |
styleElement.innerHTML = styles;
|
769 |
+
document.head.appendChild(styleElement); // init triggers
|
770 |
|
771 |
+
ExitIntent(boxes);
|
772 |
+
Pageviews(boxes);
|
773 |
+
Scroll(boxes);
|
774 |
+
Time(boxes);
|
775 |
document.body.addEventListener('click', onElementClick, true);
|
776 |
+
window.addEventListener('resize', throttle(recalculateHeights));
|
777 |
window.addEventListener('load', recalculateHeights);
|
778 |
document.addEventListener('keyup', onKeyUp);
|
779 |
+
trigger('ready');
|
780 |
initialised = true; // ensure this function doesn't run again
|
781 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
782 |
|
783 |
+
function create(id, opts) {
|
784 |
// preserve backwards compat for minimumScreenWidth option
|
785 |
+
if (typeof opts.minimumScreenWidth !== 'undefined') {
|
786 |
opts.screenWidthCondition = {
|
787 |
+
condition: 'larger',
|
788 |
value: opts.minimumScreenWidth
|
789 |
};
|
790 |
}
|
791 |
|
792 |
+
id = String(id);
|
793 |
+
var box = new Box(id, opts, trigger);
|
794 |
boxes.push(box);
|
795 |
return box;
|
796 |
+
}
|
797 |
+
|
798 |
+
function get(id) {
|
799 |
+
id = String(id);
|
800 |
|
|
|
801 |
for (var i = 0; i < boxes.length; i++) {
|
802 |
+
if (boxes[i].id === id) {
|
803 |
return boxes[i];
|
804 |
}
|
805 |
}
|
806 |
|
807 |
+
throw new Error('No box exists with ID ' + id);
|
808 |
+
} // dismiss a single box (or all by omitting id param)
|
809 |
|
810 |
|
811 |
+
function dismiss(id, animate) {
|
|
|
812 |
if (id) {
|
813 |
+
get(id).dismiss(animate);
|
814 |
} else {
|
815 |
boxes.forEach(function (box) {
|
816 |
return box.dismiss(animate);
|
817 |
});
|
818 |
}
|
819 |
+
}
|
820 |
|
821 |
+
function hide(id, animate) {
|
822 |
if (id) {
|
823 |
+
get(id).hide(animate);
|
824 |
} else {
|
825 |
boxes.forEach(function (box) {
|
826 |
return box.hide(animate);
|
827 |
});
|
828 |
}
|
829 |
+
}
|
830 |
|
831 |
+
function show(id, animate) {
|
832 |
if (id) {
|
833 |
+
get(id).show(animate);
|
834 |
} else {
|
835 |
boxes.forEach(function (box) {
|
836 |
return box.show(animate);
|
837 |
});
|
838 |
}
|
839 |
+
}
|
840 |
|
841 |
+
function toggle(id, animate) {
|
842 |
if (id) {
|
843 |
+
get(id).toggle(animate);
|
844 |
} else {
|
845 |
boxes.forEach(function (box) {
|
846 |
return box.toggle(animate);
|
847 |
});
|
848 |
}
|
849 |
+
} // expose boxzilla object
|
850 |
+
|
851 |
+
|
852 |
+
var Boxzilla = {
|
853 |
+
off: off,
|
854 |
+
on: on,
|
855 |
+
get: get,
|
856 |
+
init: init,
|
857 |
+
create: create,
|
858 |
+
trigger: trigger,
|
859 |
+
show: show,
|
860 |
+
hide: hide,
|
861 |
+
dismiss: dismiss,
|
862 |
+
toggle: toggle,
|
863 |
+
boxes: boxes
|
864 |
+
};
|
865 |
window.Boxzilla = Boxzilla;
|
866 |
|
867 |
if (typeof module !== 'undefined' && module.exports) {
|
868 |
module.exports = Boxzilla;
|
869 |
}
|
870 |
|
871 |
+
},{"./box.js":3,"./styles.js":5,"./triggers/exit-intent.js":7,"./triggers/pageviews.js":8,"./triggers/scroll.js":9,"./triggers/time.js":10,"./util.js":11}],5:[function(require,module,exports){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
872 |
"use strict";
|
873 |
|
874 |
+
var styles = '#boxzilla-overlay,.boxzilla-overlay{position:fixed;background:rgba(0,0,0,.65);width:100%;height:100%;left:0;top:0;z-index:10000}.boxzilla-center-container{position:fixed;top:0;left:0;right:0;height:0;text-align:center;z-index:11000;line-height:0}.boxzilla-center-container .boxzilla{display:inline-block;text-align:left;position:relative;line-height:normal}.boxzilla{position:fixed;z-index:12000;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;background:#fff;padding:25px}.boxzilla.boxzilla-top-left{top:0;left:0}.boxzilla.boxzilla-top-right{top:0;right:0}.boxzilla.boxzilla-bottom-left{bottom:0;left:0}.boxzilla.boxzilla-bottom-right{bottom:0;right:0}.boxzilla-content>:first-child{margin-top:0;padding-top:0}.boxzilla-content>:last-child{margin-bottom:0;padding-bottom:0}.boxzilla-close-icon{position:absolute;right:0;top:0;text-align:center;padding:6px;cursor:pointer;-webkit-appearance:none;font-size:28px;font-weight:700;line-height:20px;color:#000;opacity:.5}.boxzilla-close-icon:focus,.boxzilla-close-icon:hover{opacity:.8}';
|
875 |
module.exports = styles;
|
876 |
|
877 |
+
},{}],6:[function(require,module,exports){
|
878 |
"use strict";
|
879 |
|
880 |
+
var Timer = function Timer() {
|
881 |
+
this.time = 0;
|
882 |
this.interval = 0;
|
883 |
};
|
884 |
|
901 |
|
902 |
module.exports = Timer;
|
903 |
|
904 |
+
},{}],7:[function(require,module,exports){
|
905 |
"use strict";
|
906 |
|
907 |
module.exports = function (boxes) {
|
931 |
timeout = null;
|
932 |
}
|
933 |
|
934 |
+
function onMouseEnter() {
|
935 |
clearTimeout();
|
936 |
}
|
937 |
|
947 |
clearTimeout(); // did mouse leave at top of window?
|
948 |
// add small exception space in the top-right corner
|
949 |
|
950 |
+
if (evt.clientY <= getAddressBarY() && evt.clientX < 0.8 * window.innerWidth) {
|
951 |
+
timeout = window.setTimeout(trigger, 600);
|
952 |
}
|
953 |
}
|
954 |
|
955 |
+
function onTouchStart() {
|
956 |
clearTimeout();
|
957 |
touchStart = {
|
958 |
timestamp: performance.now(),
|
969 |
} // allow a tiny tiny margin for error, to not fire on clicks
|
970 |
|
971 |
|
972 |
+
if (window.scrollY + 20 > touchStart.scrollY) {
|
973 |
return;
|
974 |
}
|
975 |
|
991 |
document.documentElement.addEventListener('click', clearTimeout);
|
992 |
};
|
993 |
|
994 |
+
},{}],8:[function(require,module,exports){
|
995 |
"use strict";
|
996 |
|
997 |
module.exports = function (boxes) {
|
1006 |
|
1007 |
window.setTimeout(function () {
|
1008 |
boxes.forEach(function (box) {
|
1009 |
+
if (box.config.trigger.method === 'pageviews' && pageviews > box.config.trigger.value && box.mayAutoShow()) {
|
1010 |
box.trigger();
|
1011 |
}
|
1012 |
});
|
1013 |
}, 1000);
|
1014 |
};
|
1015 |
|
1016 |
+
},{}],9:[function(require,module,exports){
|
1017 |
"use strict";
|
1018 |
|
1019 |
var throttle = require('../util.js').throttle;
|
1030 |
|
1031 |
if (scrollY > box.triggerHeight) {
|
1032 |
box.trigger();
|
1033 |
+
} else if (box.mayRehide() && scrollY < box.triggerHeight - 5) {
|
1034 |
+
// if box may auto-hide and scrollY is less than triggerHeight (with small margin of error), hide box
|
|
|
|
|
1035 |
box.hide();
|
1036 |
}
|
1037 |
});
|
1041 |
window.addEventListener('scroll', throttle(checkHeightCriteria), true);
|
1042 |
};
|
1043 |
|
1044 |
+
},{"../util.js":11}],10:[function(require,module,exports){
|
1045 |
"use strict";
|
1046 |
|
1047 |
var Timer = require('../timer.js');
|
1048 |
|
1049 |
module.exports = function (boxes) {
|
1050 |
+
var siteTimer = new Timer();
|
1051 |
+
var pageTimer = new Timer();
|
1052 |
var timers = {
|
1053 |
start: function start() {
|
1054 |
try {
|
1071 |
|
1072 |
timers.start(); // stop timers when leaving page or switching to other tab
|
1073 |
|
1074 |
+
document.addEventListener('visibilitychange', function () {
|
1075 |
document.hidden ? timers.stop() : timers.start();
|
1076 |
});
|
1077 |
window.addEventListener('beforeunload', function () {
|
1079 |
});
|
1080 |
window.setInterval(function () {
|
1081 |
boxes.forEach(function (box) {
|
1082 |
+
if (box.config.trigger.method === 'time_on_site' && siteTimer.time > box.config.trigger.value && box.mayAutoShow()) {
|
1083 |
box.trigger();
|
1084 |
+
} else if (box.config.trigger.method === 'time_on_page' && pageTimer.time > box.config.trigger.value && box.mayAutoShow()) {
|
|
|
|
|
1085 |
box.trigger();
|
1086 |
}
|
1087 |
});
|
1088 |
}, 1000);
|
1089 |
};
|
1090 |
|
1091 |
+
},{"../timer.js":6}],11:[function(require,module,exports){
|
1092 |
"use strict";
|
1093 |
|
1094 |
function throttle(fn, threshold, scope) {
|
1095 |
+
threshold || (threshold = 800);
|
1096 |
var last;
|
1097 |
var deferTimer;
|
1098 |
return function () {
|
1099 |
var context = scope || this;
|
1100 |
+
var now = +new Date();
|
1101 |
+
var args = arguments;
|
1102 |
|
1103 |
if (last && now < last + threshold) {
|
1104 |
// hold on to it
|
1118 |
throttle: throttle
|
1119 |
};
|
1120 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|