PluginProbe ʕ •ᴥ•ʔ
Hustle – Email Marketing, Lead Generation, Optins, Popups / 7.3.7
Hustle – Email Marketing, Lead Generation, Optins, Popups v7.3.7
7.8.13 7.8.13.1 trunk 3.0 3.1 3.1.1 3.1.2 3.1.3 3.1.4 4.3.2 4.4.4 4.4.5 4.4.5.1 4.4.5.4 4.6 4.6.1.1 4.6.1.4 4.7.0.2 4.7.0.3 4.7.0.7 4.7.0.9 4.7.1.0 4.7.1.1 4.8.0.0 5.0.0 5.0.1 5.0.1.1 5.0.1.2 5.1 5.1.1 5.1.2 5.1.3 5.1.3.1 5.1.3.2 5.1.4 5.1.5 6.0 6.0.1 6.0.2 6.0.3 6.0.4.2 6.0.5 6.0.6.1 6.0.7 6.0.8.1 6.0.9 7.0.0.1 7.0.2 7.0.3 7.0.4 7.1.0 7.1.1 7.2.0 7.2.1 7.3.0 7.3.1 7.3.3 7.3.5 7.3.6 7.3.7 7.4.0 7.4.1 7.4.11 7.4.13 7.4.13.1 7.4.2 7.4.3 7.4.4 7.4.5 7.4.5.1 7.4.5.2 7.4.6 7.4.7 7.5.0 7.6.0 7.6.1 7.6.3 7.6.4 7.6.6 7.7.0 7.7.1 7.8.0 7.8.1 7.8.10 7.8.10.1 7.8.10.2 7.8.11 7.8.12 7.8.12.1 7.8.2 7.8.3 7.8.4 7.8.5 7.8.6 7.8.7 7.8.8 7.8.9 7.8.9.1 7.8.9.2 7.8.9.3
wordpress-popup / assets / js / front.debug.js
wordpress-popup / assets / js Last commit date
vendor 5 years ago adblock.js 5 years ago admin.debug.js 5 years ago admin.min.js 5 years ago front.debug.js 5 years ago front.min.js 5 years ago preview.debug.js 5 years ago preview.min.js 5 years ago shared-ui.min.js 5 years ago wp-dashboard.debug.js 5 years ago wp-dashboard.min.js 5 years ago
front.debug.js
3048 lines
1 function _typeof(obj) { "@babel/helpers - typeof"; 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); }
2
3 (function (t) {
4 var e = (typeof self === "undefined" ? "undefined" : _typeof(self)) == "object" && self.self === self && self || (typeof global === "undefined" ? "undefined" : _typeof(global)) == "object" && global.global === global && global;
5
6 if (typeof define === "function" && define.amd) {
7 define(["underscore", "jquery", "exports"], function (i, r, n) {
8 e.Backbone = t(e, n, i, r);
9 });
10 } else if (typeof exports !== "undefined") {
11 var i = require("underscore"),
12 r;
13
14 try {
15 r = require("jquery");
16 } catch (n) {}
17
18 t(e, exports, i, r);
19 } else {
20 e.Backbone = t(e, {}, e._, e.jQuery || e.Zepto || e.ender || e.$);
21 }
22 })(function (t, e, i, r) {
23 var n = t.Backbone;
24 var s = Array.prototype.slice;
25 e.VERSION = "1.3.3";
26 e.$ = r;
27
28 e.noConflict = function () {
29 t.Backbone = n;
30 return this;
31 };
32
33 e.emulateHTTP = false;
34 e.emulateJSON = false;
35
36 var a = function a(t, e, r) {
37 switch (t) {
38 case 1:
39 return function () {
40 return i[e](this[r]);
41 };
42
43 case 2:
44 return function (t) {
45 return i[e](this[r], t);
46 };
47
48 case 3:
49 return function (t, n) {
50 return i[e](this[r], o(t, this), n);
51 };
52
53 case 4:
54 return function (t, n, s) {
55 return i[e](this[r], o(t, this), n, s);
56 };
57
58 default:
59 return function () {
60 var t = s.call(arguments);
61 t.unshift(this[r]);
62 return i[e].apply(i, t);
63 };
64 }
65 };
66
67 var h = function h(t, e, r) {
68 i.each(e, function (e, n) {
69 if (i[n]) t.prototype[n] = a(e, n, r);
70 });
71 };
72
73 var o = function o(t, e) {
74 if (i.isFunction(t)) return t;
75 if (i.isObject(t) && !e._isModel(t)) return l(t);
76 if (i.isString(t)) return function (e) {
77 return e.get(t);
78 };
79 return t;
80 };
81
82 var l = function l(t) {
83 var e = i.matches(t);
84 return function (t) {
85 return e(t.attributes);
86 };
87 };
88
89 var u = e.Events = {};
90 var c = /\s+/;
91
92 var f = function f(t, e, r, n, s) {
93 var a = 0,
94 h;
95
96 if (r && _typeof(r) === "object") {
97 if (n !== void 0 && "context" in s && s.context === void 0) s.context = n;
98
99 for (h = i.keys(r); a < h.length; a++) {
100 e = f(t, e, h[a], r[h[a]], s);
101 }
102 } else if (r && c.test(r)) {
103 for (h = r.split(c); a < h.length; a++) {
104 e = t(e, h[a], n, s);
105 }
106 } else {
107 e = t(e, r, n, s);
108 }
109
110 return e;
111 };
112
113 u.on = function (t, e, i) {
114 return d(this, t, e, i);
115 };
116
117 var d = function d(t, e, i, r, n) {
118 t._events = f(v, t._events || {}, e, i, {
119 context: r,
120 ctx: t,
121 listening: n
122 });
123
124 if (n) {
125 var s = t._listeners || (t._listeners = {});
126 s[n.id] = n;
127 }
128
129 return t;
130 };
131
132 u.listenTo = function (t, e, r) {
133 if (!t) return this;
134 var n = t._listenId || (t._listenId = i.uniqueId("l"));
135 var s = this._listeningTo || (this._listeningTo = {});
136 var a = s[n];
137
138 if (!a) {
139 var h = this._listenId || (this._listenId = i.uniqueId("l"));
140 a = s[n] = {
141 obj: t,
142 objId: n,
143 id: h,
144 listeningTo: s,
145 count: 0
146 };
147 }
148
149 d(t, e, r, this, a);
150 return this;
151 };
152
153 var v = function v(t, e, i, r) {
154 if (i) {
155 var n = t[e] || (t[e] = []);
156 var s = r.context,
157 a = r.ctx,
158 h = r.listening;
159 if (h) h.count++;
160 n.push({
161 callback: i,
162 context: s,
163 ctx: s || a,
164 listening: h
165 });
166 }
167
168 return t;
169 };
170
171 u.off = function (t, e, i) {
172 if (!this._events) return this;
173 this._events = f(g, this._events, t, e, {
174 context: i,
175 listeners: this._listeners
176 });
177 return this;
178 };
179
180 u.stopListening = function (t, e, r) {
181 var n = this._listeningTo;
182 if (!n) return this;
183 var s = t ? [t._listenId] : i.keys(n);
184
185 for (var a = 0; a < s.length; a++) {
186 var h = n[s[a]];
187 if (!h) break;
188 h.obj.off(e, r, this);
189 }
190
191 return this;
192 };
193
194 var g = function g(t, e, r, n) {
195 if (!t) return;
196 var s = 0,
197 a;
198 var h = n.context,
199 o = n.listeners;
200
201 if (!e && !r && !h) {
202 var l = i.keys(o);
203
204 for (; s < l.length; s++) {
205 a = o[l[s]];
206 delete o[a.id];
207 delete a.listeningTo[a.objId];
208 }
209
210 return;
211 }
212
213 var u = e ? [e] : i.keys(t);
214
215 for (; s < u.length; s++) {
216 e = u[s];
217 var c = t[e];
218 if (!c) break;
219 var f = [];
220
221 for (var d = 0; d < c.length; d++) {
222 var v = c[d];
223
224 if (r && r !== v.callback && r !== v.callback._callback || h && h !== v.context) {
225 f.push(v);
226 } else {
227 a = v.listening;
228
229 if (a && --a.count === 0) {
230 delete o[a.id];
231 delete a.listeningTo[a.objId];
232 }
233 }
234 }
235
236 if (f.length) {
237 t[e] = f;
238 } else {
239 delete t[e];
240 }
241 }
242
243 return t;
244 };
245
246 u.once = function (t, e, r) {
247 var n = f(p, {}, t, e, i.bind(this.off, this));
248 if (typeof t === "string" && r == null) e = void 0;
249 return this.on(n, e, r);
250 };
251
252 u.listenToOnce = function (t, e, r) {
253 var n = f(p, {}, e, r, i.bind(this.stopListening, this, t));
254 return this.listenTo(t, n);
255 };
256
257 var p = function p(t, e, r, n) {
258 if (r) {
259 var s = t[e] = i.once(function () {
260 n(e, s);
261 r.apply(this, arguments);
262 });
263 s._callback = r;
264 }
265
266 return t;
267 };
268
269 u.trigger = function (t) {
270 if (!this._events) return this;
271 var e = Math.max(0, arguments.length - 1);
272 var i = Array(e);
273
274 for (var r = 0; r < e; r++) {
275 i[r] = arguments[r + 1];
276 }
277
278 f(m, this._events, t, void 0, i);
279 return this;
280 };
281
282 var m = function m(t, e, i, r) {
283 if (t) {
284 var n = t[e];
285 var s = t.all;
286 if (n && s) s = s.slice();
287 if (n) _(n, r);
288 if (s) _(s, [e].concat(r));
289 }
290
291 return t;
292 };
293
294 var _ = function _(t, e) {
295 var i,
296 r = -1,
297 n = t.length,
298 s = e[0],
299 a = e[1],
300 h = e[2];
301
302 switch (e.length) {
303 case 0:
304 while (++r < n) {
305 (i = t[r]).callback.call(i.ctx);
306 }
307
308 return;
309
310 case 1:
311 while (++r < n) {
312 (i = t[r]).callback.call(i.ctx, s);
313 }
314
315 return;
316
317 case 2:
318 while (++r < n) {
319 (i = t[r]).callback.call(i.ctx, s, a);
320 }
321
322 return;
323
324 case 3:
325 while (++r < n) {
326 (i = t[r]).callback.call(i.ctx, s, a, h);
327 }
328
329 return;
330
331 default:
332 while (++r < n) {
333 (i = t[r]).callback.apply(i.ctx, e);
334 }
335
336 return;
337 }
338 };
339
340 u.bind = u.on;
341 u.unbind = u.off;
342 i.extend(e, u);
343
344 var y = e.Model = function (t, e) {
345 var r = t || {};
346 e || (e = {});
347 this.cid = i.uniqueId(this.cidPrefix);
348 this.attributes = {};
349 if (e.collection) this.collection = e.collection;
350 if (e.parse) r = this.parse(r, e) || {};
351 var n = i.result(this, "defaults");
352 r = i.defaults(i.extend({}, n, r), n);
353 this.set(r, e);
354 this.changed = {};
355 this.initialize.apply(this, arguments);
356 };
357
358 i.extend(y.prototype, u, {
359 changed: null,
360 validationError: null,
361 idAttribute: "id",
362 cidPrefix: "c",
363 initialize: function initialize() {},
364 toJSON: function toJSON(t) {
365 return i.clone(this.attributes);
366 },
367 sync: function sync() {
368 return e.sync.apply(this, arguments);
369 },
370 get: function get(t) {
371 return this.attributes[t];
372 },
373 escape: function escape(t) {
374 return i.escape(this.get(t));
375 },
376 has: function has(t) {
377 return this.get(t) != null;
378 },
379 matches: function matches(t) {
380 return !!i.iteratee(t, this)(this.attributes);
381 },
382 set: function set(t, e, r) {
383 if (t == null) return this;
384 var n;
385
386 if (_typeof(t) === "object") {
387 n = t;
388 r = e;
389 } else {
390 (n = {})[t] = e;
391 }
392
393 r || (r = {});
394 if (!this._validate(n, r)) return false;
395 var s = r.unset;
396 var a = r.silent;
397 var h = [];
398 var o = this._changing;
399 this._changing = true;
400
401 if (!o) {
402 this._previousAttributes = i.clone(this.attributes);
403 this.changed = {};
404 }
405
406 var l = this.attributes;
407 var u = this.changed;
408 var c = this._previousAttributes;
409
410 for (var f in n) {
411 e = n[f];
412 if (!i.isEqual(l[f], e)) h.push(f);
413
414 if (!i.isEqual(c[f], e)) {
415 u[f] = e;
416 } else {
417 delete u[f];
418 }
419
420 s ? delete l[f] : l[f] = e;
421 }
422
423 if (this.idAttribute in n) this.id = this.get(this.idAttribute);
424
425 if (!a) {
426 if (h.length) this._pending = r;
427
428 for (var d = 0; d < h.length; d++) {
429 this.trigger("change:" + h[d], this, l[h[d]], r);
430 }
431 }
432
433 if (o) return this;
434
435 if (!a) {
436 while (this._pending) {
437 r = this._pending;
438 this._pending = false;
439 this.trigger("change", this, r);
440 }
441 }
442
443 this._pending = false;
444 this._changing = false;
445 return this;
446 },
447 unset: function unset(t, e) {
448 return this.set(t, void 0, i.extend({}, e, {
449 unset: true
450 }));
451 },
452 clear: function clear(t) {
453 var e = {};
454
455 for (var r in this.attributes) {
456 e[r] = void 0;
457 }
458
459 return this.set(e, i.extend({}, t, {
460 unset: true
461 }));
462 },
463 hasChanged: function hasChanged(t) {
464 if (t == null) return !i.isEmpty(this.changed);
465 return i.has(this.changed, t);
466 },
467 changedAttributes: function changedAttributes(t) {
468 if (!t) return this.hasChanged() ? i.clone(this.changed) : false;
469 var e = this._changing ? this._previousAttributes : this.attributes;
470 var r = {};
471
472 for (var n in t) {
473 var s = t[n];
474 if (i.isEqual(e[n], s)) continue;
475 r[n] = s;
476 }
477
478 return i.size(r) ? r : false;
479 },
480 previous: function previous(t) {
481 if (t == null || !this._previousAttributes) return null;
482 return this._previousAttributes[t];
483 },
484 previousAttributes: function previousAttributes() {
485 return i.clone(this._previousAttributes);
486 },
487 fetch: function fetch(t) {
488 t = i.extend({
489 parse: true
490 }, t);
491 var e = this;
492 var r = t.success;
493
494 t.success = function (i) {
495 var n = t.parse ? e.parse(i, t) : i;
496 if (!e.set(n, t)) return false;
497 if (r) r.call(t.context, e, i, t);
498 e.trigger("sync", e, i, t);
499 };
500
501 B(this, t);
502 return this.sync("read", this, t);
503 },
504 save: function save(t, e, r) {
505 var n;
506
507 if (t == null || _typeof(t) === "object") {
508 n = t;
509 r = e;
510 } else {
511 (n = {})[t] = e;
512 }
513
514 r = i.extend({
515 validate: true,
516 parse: true
517 }, r);
518 var s = r.wait;
519
520 if (n && !s) {
521 if (!this.set(n, r)) return false;
522 } else if (!this._validate(n, r)) {
523 return false;
524 }
525
526 var a = this;
527 var h = r.success;
528 var o = this.attributes;
529
530 r.success = function (t) {
531 a.attributes = o;
532 var e = r.parse ? a.parse(t, r) : t;
533 if (s) e = i.extend({}, n, e);
534 if (e && !a.set(e, r)) return false;
535 if (h) h.call(r.context, a, t, r);
536 a.trigger("sync", a, t, r);
537 };
538
539 B(this, r);
540 if (n && s) this.attributes = i.extend({}, o, n);
541 var l = this.isNew() ? "create" : r.patch ? "patch" : "update";
542 if (l === "patch" && !r.attrs) r.attrs = n;
543 var u = this.sync(l, this, r);
544 this.attributes = o;
545 return u;
546 },
547 destroy: function destroy(t) {
548 t = t ? i.clone(t) : {};
549 var e = this;
550 var r = t.success;
551 var n = t.wait;
552
553 var s = function s() {
554 e.stopListening();
555 e.trigger("destroy", e, e.collection, t);
556 };
557
558 t.success = function (i) {
559 if (n) s();
560 if (r) r.call(t.context, e, i, t);
561 if (!e.isNew()) e.trigger("sync", e, i, t);
562 };
563
564 var a = false;
565
566 if (this.isNew()) {
567 i.defer(t.success);
568 } else {
569 B(this, t);
570 a = this.sync("delete", this, t);
571 }
572
573 if (!n) s();
574 return a;
575 },
576 url: function url() {
577 var t = i.result(this, "urlRoot") || i.result(this.collection, "url") || F();
578 if (this.isNew()) return t;
579 var e = this.get(this.idAttribute);
580 return t.replace(/[^\/]$/, "$&/") + encodeURIComponent(e);
581 },
582 parse: function parse(t, e) {
583 return t;
584 },
585 clone: function clone() {
586 return new this.constructor(this.attributes);
587 },
588 isNew: function isNew() {
589 return !this.has(this.idAttribute);
590 },
591 isValid: function isValid(t) {
592 return this._validate({}, i.extend({}, t, {
593 validate: true
594 }));
595 },
596 _validate: function _validate(t, e) {
597 if (!e.validate || !this.validate) return true;
598 t = i.extend({}, this.attributes, t);
599 var r = this.validationError = this.validate(t, e) || null;
600 if (!r) return true;
601 this.trigger("invalid", this, r, i.extend(e, {
602 validationError: r
603 }));
604 return false;
605 }
606 });
607 var b = {
608 keys: 1,
609 values: 1,
610 pairs: 1,
611 invert: 1,
612 pick: 0,
613 omit: 0,
614 chain: 1,
615 isEmpty: 1
616 };
617 h(y, b, "attributes");
618
619 var x = e.Collection = function (t, e) {
620 e || (e = {});
621 if (e.model) this.model = e.model;
622 if (e.comparator !== void 0) this.comparator = e.comparator;
623
624 this._reset();
625
626 this.initialize.apply(this, arguments);
627 if (t) this.reset(t, i.extend({
628 silent: true
629 }, e));
630 };
631
632 var w = {
633 add: true,
634 remove: true,
635 merge: true
636 };
637 var E = {
638 add: true,
639 remove: false
640 };
641
642 var I = function I(t, e, i) {
643 i = Math.min(Math.max(i, 0), t.length);
644 var r = Array(t.length - i);
645 var n = e.length;
646 var s;
647
648 for (s = 0; s < r.length; s++) {
649 r[s] = t[s + i];
650 }
651
652 for (s = 0; s < n; s++) {
653 t[s + i] = e[s];
654 }
655
656 for (s = 0; s < r.length; s++) {
657 t[s + n + i] = r[s];
658 }
659 };
660
661 i.extend(x.prototype, u, {
662 model: y,
663 initialize: function initialize() {},
664 toJSON: function toJSON(t) {
665 return this.map(function (e) {
666 return e.toJSON(t);
667 });
668 },
669 sync: function sync() {
670 return e.sync.apply(this, arguments);
671 },
672 add: function add(t, e) {
673 return this.set(t, i.extend({
674 merge: false
675 }, e, E));
676 },
677 remove: function remove(t, e) {
678 e = i.extend({}, e);
679 var r = !i.isArray(t);
680 t = r ? [t] : t.slice();
681
682 var n = this._removeModels(t, e);
683
684 if (!e.silent && n.length) {
685 e.changes = {
686 added: [],
687 merged: [],
688 removed: n
689 };
690 this.trigger("update", this, e);
691 }
692
693 return r ? n[0] : n;
694 },
695 set: function set(t, e) {
696 if (t == null) return;
697 e = i.extend({}, w, e);
698
699 if (e.parse && !this._isModel(t)) {
700 t = this.parse(t, e) || [];
701 }
702
703 var r = !i.isArray(t);
704 t = r ? [t] : t.slice();
705 var n = e.at;
706 if (n != null) n = +n;
707 if (n > this.length) n = this.length;
708 if (n < 0) n += this.length + 1;
709 var s = [];
710 var a = [];
711 var h = [];
712 var o = [];
713 var l = {};
714 var u = e.add;
715 var c = e.merge;
716 var f = e.remove;
717 var d = false;
718 var v = this.comparator && n == null && e.sort !== false;
719 var g = i.isString(this.comparator) ? this.comparator : null;
720 var p, m;
721
722 for (m = 0; m < t.length; m++) {
723 p = t[m];
724
725 var _ = this.get(p);
726
727 if (_) {
728 if (c && p !== _) {
729 var y = this._isModel(p) ? p.attributes : p;
730 if (e.parse) y = _.parse(y, e);
731
732 _.set(y, e);
733
734 h.push(_);
735 if (v && !d) d = _.hasChanged(g);
736 }
737
738 if (!l[_.cid]) {
739 l[_.cid] = true;
740 s.push(_);
741 }
742
743 t[m] = _;
744 } else if (u) {
745 p = t[m] = this._prepareModel(p, e);
746
747 if (p) {
748 a.push(p);
749
750 this._addReference(p, e);
751
752 l[p.cid] = true;
753 s.push(p);
754 }
755 }
756 }
757
758 if (f) {
759 for (m = 0; m < this.length; m++) {
760 p = this.models[m];
761 if (!l[p.cid]) o.push(p);
762 }
763
764 if (o.length) this._removeModels(o, e);
765 }
766
767 var b = false;
768 var x = !v && u && f;
769
770 if (s.length && x) {
771 b = this.length !== s.length || i.some(this.models, function (t, e) {
772 return t !== s[e];
773 });
774 this.models.length = 0;
775 I(this.models, s, 0);
776 this.length = this.models.length;
777 } else if (a.length) {
778 if (v) d = true;
779 I(this.models, a, n == null ? this.length : n);
780 this.length = this.models.length;
781 }
782
783 if (d) this.sort({
784 silent: true
785 });
786
787 if (!e.silent) {
788 for (m = 0; m < a.length; m++) {
789 if (n != null) e.index = n + m;
790 p = a[m];
791 p.trigger("add", p, this, e);
792 }
793
794 if (d || b) this.trigger("sort", this, e);
795
796 if (a.length || o.length || h.length) {
797 e.changes = {
798 added: a,
799 removed: o,
800 merged: h
801 };
802 this.trigger("update", this, e);
803 }
804 }
805
806 return r ? t[0] : t;
807 },
808 reset: function reset(t, e) {
809 e = e ? i.clone(e) : {};
810
811 for (var r = 0; r < this.models.length; r++) {
812 this._removeReference(this.models[r], e);
813 }
814
815 e.previousModels = this.models;
816
817 this._reset();
818
819 t = this.add(t, i.extend({
820 silent: true
821 }, e));
822 if (!e.silent) this.trigger("reset", this, e);
823 return t;
824 },
825 push: function push(t, e) {
826 return this.add(t, i.extend({
827 at: this.length
828 }, e));
829 },
830 pop: function pop(t) {
831 var e = this.at(this.length - 1);
832 return this.remove(e, t);
833 },
834 unshift: function unshift(t, e) {
835 return this.add(t, i.extend({
836 at: 0
837 }, e));
838 },
839 shift: function shift(t) {
840 var e = this.at(0);
841 return this.remove(e, t);
842 },
843 slice: function slice() {
844 return s.apply(this.models, arguments);
845 },
846 get: function get(t) {
847 if (t == null) return void 0;
848 return this._byId[t] || this._byId[this.modelId(t.attributes || t)] || t.cid && this._byId[t.cid];
849 },
850 has: function has(t) {
851 return this.get(t) != null;
852 },
853 at: function at(t) {
854 if (t < 0) t += this.length;
855 return this.models[t];
856 },
857 where: function where(t, e) {
858 return this[e ? "find" : "filter"](t);
859 },
860 findWhere: function findWhere(t) {
861 return this.where(t, true);
862 },
863 sort: function sort(t) {
864 var e = this.comparator;
865 if (!e) throw new Error("Cannot sort a set without a comparator");
866 t || (t = {});
867 var r = e.length;
868 if (i.isFunction(e)) e = i.bind(e, this);
869
870 if (r === 1 || i.isString(e)) {
871 this.models = this.sortBy(e);
872 } else {
873 this.models.sort(e);
874 }
875
876 if (!t.silent) this.trigger("sort", this, t);
877 return this;
878 },
879 pluck: function pluck(t) {
880 return this.map(t + "");
881 },
882 fetch: function fetch(t) {
883 t = i.extend({
884 parse: true
885 }, t);
886 var e = t.success;
887 var r = this;
888
889 t.success = function (i) {
890 var n = t.reset ? "reset" : "set";
891 r[n](i, t);
892 if (e) e.call(t.context, r, i, t);
893 r.trigger("sync", r, i, t);
894 };
895
896 B(this, t);
897 return this.sync("read", this, t);
898 },
899 create: function create(t, e) {
900 e = e ? i.clone(e) : {};
901 var r = e.wait;
902 t = this._prepareModel(t, e);
903 if (!t) return false;
904 if (!r) this.add(t, e);
905 var n = this;
906 var s = e.success;
907
908 e.success = function (t, e, i) {
909 if (r) n.add(t, i);
910 if (s) s.call(i.context, t, e, i);
911 };
912
913 t.save(null, e);
914 return t;
915 },
916 parse: function parse(t, e) {
917 return t;
918 },
919 clone: function clone() {
920 return new this.constructor(this.models, {
921 model: this.model,
922 comparator: this.comparator
923 });
924 },
925 modelId: function modelId(t) {
926 return t[this.model.prototype.idAttribute || "id"];
927 },
928 _reset: function _reset() {
929 this.length = 0;
930 this.models = [];
931 this._byId = {};
932 },
933 _prepareModel: function _prepareModel(t, e) {
934 if (this._isModel(t)) {
935 if (!t.collection) t.collection = this;
936 return t;
937 }
938
939 e = e ? i.clone(e) : {};
940 e.collection = this;
941 var r = new this.model(t, e);
942 if (!r.validationError) return r;
943 this.trigger("invalid", this, r.validationError, e);
944 return false;
945 },
946 _removeModels: function _removeModels(t, e) {
947 var i = [];
948
949 for (var r = 0; r < t.length; r++) {
950 var n = this.get(t[r]);
951 if (!n) continue;
952 var s = this.indexOf(n);
953 this.models.splice(s, 1);
954 this.length--;
955 delete this._byId[n.cid];
956 var a = this.modelId(n.attributes);
957 if (a != null) delete this._byId[a];
958
959 if (!e.silent) {
960 e.index = s;
961 n.trigger("remove", n, this, e);
962 }
963
964 i.push(n);
965
966 this._removeReference(n, e);
967 }
968
969 return i;
970 },
971 _isModel: function _isModel(t) {
972 return t instanceof y;
973 },
974 _addReference: function _addReference(t, e) {
975 this._byId[t.cid] = t;
976 var i = this.modelId(t.attributes);
977 if (i != null) this._byId[i] = t;
978 t.on("all", this._onModelEvent, this);
979 },
980 _removeReference: function _removeReference(t, e) {
981 delete this._byId[t.cid];
982 var i = this.modelId(t.attributes);
983 if (i != null) delete this._byId[i];
984 if (this === t.collection) delete t.collection;
985 t.off("all", this._onModelEvent, this);
986 },
987 _onModelEvent: function _onModelEvent(t, e, i, r) {
988 if (e) {
989 if ((t === "add" || t === "remove") && i !== this) return;
990 if (t === "destroy") this.remove(e, r);
991
992 if (t === "change") {
993 var n = this.modelId(e.previousAttributes());
994 var s = this.modelId(e.attributes);
995
996 if (n !== s) {
997 if (n != null) delete this._byId[n];
998 if (s != null) this._byId[s] = e;
999 }
1000 }
1001 }
1002
1003 this.trigger.apply(this, arguments);
1004 }
1005 });
1006 var S = {
1007 forEach: 3,
1008 each: 3,
1009 map: 3,
1010 collect: 3,
1011 reduce: 0,
1012 foldl: 0,
1013 inject: 0,
1014 reduceRight: 0,
1015 foldr: 0,
1016 find: 3,
1017 detect: 3,
1018 filter: 3,
1019 select: 3,
1020 reject: 3,
1021 every: 3,
1022 all: 3,
1023 some: 3,
1024 any: 3,
1025 include: 3,
1026 includes: 3,
1027 contains: 3,
1028 invoke: 0,
1029 max: 3,
1030 min: 3,
1031 toArray: 1,
1032 size: 1,
1033 first: 3,
1034 head: 3,
1035 take: 3,
1036 initial: 3,
1037 rest: 3,
1038 tail: 3,
1039 drop: 3,
1040 last: 3,
1041 without: 0,
1042 difference: 0,
1043 indexOf: 3,
1044 shuffle: 1,
1045 lastIndexOf: 3,
1046 isEmpty: 1,
1047 chain: 1,
1048 sample: 3,
1049 partition: 3,
1050 groupBy: 3,
1051 countBy: 3,
1052 sortBy: 3,
1053 indexBy: 3,
1054 findIndex: 3,
1055 findLastIndex: 3
1056 };
1057 h(x, S, "models");
1058
1059 var k = e.View = function (t) {
1060 this.cid = i.uniqueId("view");
1061 i.extend(this, i.pick(t, P));
1062
1063 this._ensureElement();
1064
1065 this.initialize.apply(this, arguments);
1066 };
1067
1068 var T = /^(\S+)\s*(.*)$/;
1069 var P = ["model", "collection", "el", "id", "attributes", "className", "tagName", "events"];
1070 i.extend(k.prototype, u, {
1071 tagName: "div",
1072 $: function $(t) {
1073 return this.$el.find(t);
1074 },
1075 initialize: function initialize() {},
1076 render: function render() {
1077 return this;
1078 },
1079 remove: function remove() {
1080 this._removeElement();
1081
1082 this.stopListening();
1083 return this;
1084 },
1085 _removeElement: function _removeElement() {
1086 this.$el.remove();
1087 },
1088 setElement: function setElement(t) {
1089 this.undelegateEvents();
1090
1091 this._setElement(t);
1092
1093 this.delegateEvents();
1094 return this;
1095 },
1096 _setElement: function _setElement(t) {
1097 this.$el = t instanceof e.$ ? t : e.$(t);
1098 this.el = this.$el[0];
1099 },
1100 delegateEvents: function delegateEvents(t) {
1101 t || (t = i.result(this, "events"));
1102 if (!t) return this;
1103 this.undelegateEvents();
1104
1105 for (var e in t) {
1106 var r = t[e];
1107 if (!i.isFunction(r)) r = this[r];
1108 if (!r) continue;
1109 var n = e.match(T);
1110 this.delegate(n[1], n[2], i.bind(r, this));
1111 }
1112
1113 return this;
1114 },
1115 delegate: function delegate(t, e, i) {
1116 this.$el.on(t + ".delegateEvents" + this.cid, e, i);
1117 return this;
1118 },
1119 undelegateEvents: function undelegateEvents() {
1120 if (this.$el) this.$el.off(".delegateEvents" + this.cid);
1121 return this;
1122 },
1123 undelegate: function undelegate(t, e, i) {
1124 this.$el.off(t + ".delegateEvents" + this.cid, e, i);
1125 return this;
1126 },
1127 _createElement: function _createElement(t) {
1128 return document.createElement(t);
1129 },
1130 _ensureElement: function _ensureElement() {
1131 if (!this.el) {
1132 var t = i.extend({}, i.result(this, "attributes"));
1133 if (this.id) t.id = i.result(this, "id");
1134 if (this.className) t["class"] = i.result(this, "className");
1135 this.setElement(this._createElement(i.result(this, "tagName")));
1136
1137 this._setAttributes(t);
1138 } else {
1139 this.setElement(i.result(this, "el"));
1140 }
1141 },
1142 _setAttributes: function _setAttributes(t) {
1143 this.$el.attr(t);
1144 }
1145 });
1146
1147 e.sync = function (t, r, n) {
1148 var s = H[t];
1149 i.defaults(n || (n = {}), {
1150 emulateHTTP: e.emulateHTTP,
1151 emulateJSON: e.emulateJSON
1152 });
1153 var a = {
1154 type: s,
1155 dataType: "json"
1156 };
1157
1158 if (!n.url) {
1159 a.url = i.result(r, "url") || F();
1160 }
1161
1162 if (n.data == null && r && (t === "create" || t === "update" || t === "patch")) {
1163 a.contentType = "application/json";
1164 a.data = JSON.stringify(n.attrs || r.toJSON(n));
1165 }
1166
1167 if (n.emulateJSON) {
1168 a.contentType = "application/x-www-form-urlencoded";
1169 a.data = a.data ? {
1170 model: a.data
1171 } : {};
1172 }
1173
1174 if (n.emulateHTTP && (s === "PUT" || s === "DELETE" || s === "PATCH")) {
1175 a.type = "POST";
1176 if (n.emulateJSON) a.data._method = s;
1177 var h = n.beforeSend;
1178
1179 n.beforeSend = function (t) {
1180 t.setRequestHeader("X-HTTP-Method-Override", s);
1181 if (h) return h.apply(this, arguments);
1182 };
1183 }
1184
1185 if (a.type !== "GET" && !n.emulateJSON) {
1186 a.processData = false;
1187 }
1188
1189 var o = n.error;
1190
1191 n.error = function (t, e, i) {
1192 n.textStatus = e;
1193 n.errorThrown = i;
1194 if (o) o.call(n.context, t, e, i);
1195 };
1196
1197 var l = n.xhr = e.ajax(i.extend(a, n));
1198 r.trigger("request", r, l, n);
1199 return l;
1200 };
1201
1202 var H = {
1203 create: "POST",
1204 update: "PUT",
1205 patch: "PATCH",
1206 "delete": "DELETE",
1207 read: "GET"
1208 };
1209
1210 e.ajax = function () {
1211 return e.$.ajax.apply(e.$, arguments);
1212 };
1213
1214 var $ = e.Router = function (t) {
1215 t || (t = {});
1216 if (t.routes) this.routes = t.routes;
1217
1218 this._bindRoutes();
1219
1220 this.initialize.apply(this, arguments);
1221 };
1222
1223 var A = /\((.*?)\)/g;
1224 var C = /(\(\?)?:\w+/g;
1225 var R = /\*\w+/g;
1226 var j = /[\-{}\[\]+?.,\\\^$|#\s]/g;
1227 i.extend($.prototype, u, {
1228 initialize: function initialize() {},
1229 route: function route(t, r, n) {
1230 if (!i.isRegExp(t)) t = this._routeToRegExp(t);
1231
1232 if (i.isFunction(r)) {
1233 n = r;
1234 r = "";
1235 }
1236
1237 if (!n) n = this[r];
1238 var s = this;
1239 e.history.route(t, function (i) {
1240 var a = s._extractParameters(t, i);
1241
1242 if (s.execute(n, a, r) !== false) {
1243 s.trigger.apply(s, ["route:" + r].concat(a));
1244 s.trigger("route", r, a);
1245 e.history.trigger("route", s, r, a);
1246 }
1247 });
1248 return this;
1249 },
1250 execute: function execute(t, e, i) {
1251 if (t) t.apply(this, e);
1252 },
1253 navigate: function navigate(t, i) {
1254 e.history.navigate(t, i);
1255 return this;
1256 },
1257 _bindRoutes: function _bindRoutes() {
1258 if (!this.routes) return;
1259 this.routes = i.result(this, "routes");
1260 var t,
1261 e = i.keys(this.routes);
1262
1263 while ((t = e.pop()) != null) {
1264 this.route(t, this.routes[t]);
1265 }
1266 },
1267 _routeToRegExp: function _routeToRegExp(t) {
1268 t = t.replace(j, "\\$&").replace(A, "(?:$1)?").replace(C, function (t, e) {
1269 return e ? t : "([^/?]+)";
1270 }).replace(R, "([^?]*?)");
1271 return new RegExp("^" + t + "(?:\\?([\\s\\S]*))?$");
1272 },
1273 _extractParameters: function _extractParameters(t, e) {
1274 var r = t.exec(e).slice(1);
1275 return i.map(r, function (t, e) {
1276 if (e === r.length - 1) return t || null;
1277 return t ? decodeURIComponent(t) : null;
1278 });
1279 }
1280 });
1281
1282 var N = e.History = function () {
1283 this.handlers = [];
1284 this.checkUrl = i.bind(this.checkUrl, this);
1285
1286 if (typeof window !== "undefined") {
1287 this.location = window.location;
1288 this.history = window.history;
1289 }
1290 };
1291
1292 var M = /^[#\/]|\s+$/g;
1293 var O = /^\/+|\/+$/g;
1294 var U = /#.*$/;
1295 N.started = false;
1296 i.extend(N.prototype, u, {
1297 interval: 50,
1298 atRoot: function atRoot() {
1299 var t = this.location.pathname.replace(/[^\/]$/, "$&/");
1300 return t === this.root && !this.getSearch();
1301 },
1302 matchRoot: function matchRoot() {
1303 var t = this.decodeFragment(this.location.pathname);
1304 var e = t.slice(0, this.root.length - 1) + "/";
1305 return e === this.root;
1306 },
1307 decodeFragment: function decodeFragment(t) {
1308 return decodeURI(t.replace(/%25/g, "%2525"));
1309 },
1310 getSearch: function getSearch() {
1311 var t = this.location.href.replace(/#.*/, "").match(/\?.+/);
1312 return t ? t[0] : "";
1313 },
1314 getHash: function getHash(t) {
1315 var e = (t || this).location.href.match(/#(.*)$/);
1316 return e ? e[1] : "";
1317 },
1318 getPath: function getPath() {
1319 var t = this.decodeFragment(this.location.pathname + this.getSearch()).slice(this.root.length - 1);
1320 return t.charAt(0) === "/" ? t.slice(1) : t;
1321 },
1322 getFragment: function getFragment(t) {
1323 if (t == null) {
1324 if (this._usePushState || !this._wantsHashChange) {
1325 t = this.getPath();
1326 } else {
1327 t = this.getHash();
1328 }
1329 }
1330
1331 return t.replace(M, "");
1332 },
1333 start: function start(t) {
1334 if (N.started) throw new Error("Backbone.history has already been started");
1335 N.started = true;
1336 this.options = i.extend({
1337 root: "/"
1338 }, this.options, t);
1339 this.root = this.options.root;
1340 this._wantsHashChange = this.options.hashChange !== false;
1341 this._hasHashChange = "onhashchange" in window && (document.documentMode === void 0 || document.documentMode > 7);
1342 this._useHashChange = this._wantsHashChange && this._hasHashChange;
1343 this._wantsPushState = !!this.options.pushState;
1344 this._hasPushState = !!(this.history && this.history.pushState);
1345 this._usePushState = this._wantsPushState && this._hasPushState;
1346 this.fragment = this.getFragment();
1347 this.root = ("/" + this.root + "/").replace(O, "/");
1348
1349 if (this._wantsHashChange && this._wantsPushState) {
1350 if (!this._hasPushState && !this.atRoot()) {
1351 var e = this.root.slice(0, -1) || "/";
1352 this.location.replace(e + "#" + this.getPath());
1353 return true;
1354 } else if (this._hasPushState && this.atRoot()) {
1355 this.navigate(this.getHash(), {
1356 replace: true
1357 });
1358 }
1359 }
1360
1361 if (!this._hasHashChange && this._wantsHashChange && !this._usePushState) {
1362 this.iframe = document.createElement("iframe");
1363 this.iframe.src = "javascript:0";
1364 this.iframe.style.display = "none";
1365 this.iframe.tabIndex = -1;
1366 var r = document.body;
1367 var n = r.insertBefore(this.iframe, r.firstChild).contentWindow;
1368 n.document.open();
1369 n.document.close();
1370 n.location.hash = "#" + this.fragment;
1371 }
1372
1373 var s = window.addEventListener || function (t, e) {
1374 return attachEvent("on" + t, e);
1375 };
1376
1377 if (this._usePushState) {
1378 s("popstate", this.checkUrl, false);
1379 } else if (this._useHashChange && !this.iframe) {
1380 s("hashchange", this.checkUrl, false);
1381 } else if (this._wantsHashChange) {
1382 this._checkUrlInterval = setInterval(this.checkUrl, this.interval);
1383 }
1384
1385 if (!this.options.silent) return this.loadUrl();
1386 },
1387 stop: function stop() {
1388 var t = window.removeEventListener || function (t, e) {
1389 return detachEvent("on" + t, e);
1390 };
1391
1392 if (this._usePushState) {
1393 t("popstate", this.checkUrl, false);
1394 } else if (this._useHashChange && !this.iframe) {
1395 t("hashchange", this.checkUrl, false);
1396 }
1397
1398 if (this.iframe) {
1399 document.body.removeChild(this.iframe);
1400 this.iframe = null;
1401 }
1402
1403 if (this._checkUrlInterval) clearInterval(this._checkUrlInterval);
1404 N.started = false;
1405 },
1406 route: function route(t, e) {
1407 this.handlers.unshift({
1408 route: t,
1409 callback: e
1410 });
1411 },
1412 checkUrl: function checkUrl(t) {
1413 var e = this.getFragment();
1414
1415 if (e === this.fragment && this.iframe) {
1416 e = this.getHash(this.iframe.contentWindow);
1417 }
1418
1419 if (e === this.fragment) return false;
1420 if (this.iframe) this.navigate(e);
1421 this.loadUrl();
1422 },
1423 loadUrl: function loadUrl(t) {
1424 if (!this.matchRoot()) return false;
1425 t = this.fragment = this.getFragment(t);
1426 return i.some(this.handlers, function (e) {
1427 if (e.route.test(t)) {
1428 e.callback(t);
1429 return true;
1430 }
1431 });
1432 },
1433 navigate: function navigate(t, e) {
1434 if (!N.started) return false;
1435 if (!e || e === true) e = {
1436 trigger: !!e
1437 };
1438 t = this.getFragment(t || "");
1439 var i = this.root;
1440
1441 if (t === "" || t.charAt(0) === "?") {
1442 i = i.slice(0, -1) || "/";
1443 }
1444
1445 var r = i + t;
1446 t = this.decodeFragment(t.replace(U, ""));
1447 if (this.fragment === t) return;
1448 this.fragment = t;
1449
1450 if (this._usePushState) {
1451 this.history[e.replace ? "replaceState" : "pushState"]({}, document.title, r);
1452 } else if (this._wantsHashChange) {
1453 this._updateHash(this.location, t, e.replace);
1454
1455 if (this.iframe && t !== this.getHash(this.iframe.contentWindow)) {
1456 var n = this.iframe.contentWindow;
1457
1458 if (!e.replace) {
1459 n.document.open();
1460 n.document.close();
1461 }
1462
1463 this._updateHash(n.location, t, e.replace);
1464 }
1465 } else {
1466 return this.location.assign(r);
1467 }
1468
1469 if (e.trigger) return this.loadUrl(t);
1470 },
1471 _updateHash: function _updateHash(t, e, i) {
1472 if (i) {
1473 var r = t.href.replace(/(javascript:|#).*$/, "");
1474 t.replace(r + "#" + e);
1475 } else {
1476 t.hash = "#" + e;
1477 }
1478 }
1479 });
1480 e.history = new N();
1481
1482 var q = function q(t, e) {
1483 var r = this;
1484 var n;
1485
1486 if (t && i.has(t, "constructor")) {
1487 n = t.constructor;
1488 } else {
1489 n = function n() {
1490 return r.apply(this, arguments);
1491 };
1492 }
1493
1494 i.extend(n, r, e);
1495 n.prototype = i.create(r.prototype, t);
1496 n.prototype.constructor = n;
1497 n.__super__ = r.prototype;
1498 return n;
1499 };
1500
1501 y.extend = x.extend = $.extend = k.extend = N.extend = q;
1502
1503 var F = function F() {
1504 throw new Error('A "url" property or function must be specified');
1505 };
1506
1507 var B = function B(t, e) {
1508 var i = e.error;
1509
1510 e.error = function (r) {
1511 if (i) i.call(e.context, t, r, e);
1512 t.trigger("error", t, r, e);
1513 };
1514 };
1515
1516 return e;
1517 });
1518 (function () {
1519 'use strict';
1520 /**
1521 * Defines the Hustle Object
1522 *
1523 * @type {{define, getModules, get, modules}}
1524 */
1525
1526 window.Hustle = function ($, doc, win) {
1527 var currentModules = {},
1528 _modules = {},
1529 _TemplateOptions = {
1530 evaluate: /<#([\s\S]+?)#>/g,
1531 interpolate: /\{\{\{([\s\S]+?)\}\}\}/g,
1532 escape: /\{\{([^\}]+?)\}\}(?!\})/g
1533 };
1534
1535 var define = function define(moduleName, module) {
1536 var splits = moduleName.split('.');
1537
1538 if (splits.length) {
1539 // if module_name has more than one object name, then add the module definition recursively
1540 var recursive = function recursive(incomingModuleName, modules) {
1541 var arr = incomingModuleName.split('.'),
1542 _moduleName = arr.splice(0, 1)[0];
1543 var invoked;
1544
1545 if (!_moduleName) {
1546 return;
1547 }
1548
1549 if (!arr.length) {
1550 invoked = module.call(null, $, doc, win);
1551 modules[_moduleName] = _.isFunction(invoked) || 'undefined' === typeof invoked ? invoked : _.extend(modules[_moduleName] || {}, invoked);
1552 } else {
1553 modules[_moduleName] = modules[_moduleName] || {};
1554 }
1555
1556 if (arr.length && _moduleName) {
1557 recursive(arr.join('.'), modules[_moduleName]);
1558 }
1559 };
1560
1561 recursive(moduleName, _modules);
1562 } else {
1563 var m = _modules[moduleName] || {};
1564 _modules[moduleName] = _.extend(m, module.call(null, $, doc, win));
1565 }
1566 },
1567 get = function get(moduleName) {
1568 var module, _recursive;
1569
1570 if (moduleName.split('.').length) {
1571 // recursively fetch the module
1572 module = false;
1573
1574 _recursive = function recursive(incomingModuleName, modules) {
1575 var arr = incomingModuleName.split('.'),
1576 _moduleName = arr.splice(0, 1)[0];
1577 module = modules[_moduleName];
1578
1579 if (arr.length) {
1580 _recursive(arr.join('.'), modules[_moduleName]);
1581 }
1582 };
1583
1584 _recursive(moduleName, _modules);
1585
1586 return module;
1587 }
1588
1589 return _modules[moduleName] || false;
1590 },
1591 Events = _.extend({}, Backbone.Events),
1592 View = Backbone.View.extend({
1593 initialize: function initialize() {
1594 if (_.isFunction(this.initMix)) {
1595 this.initMix.apply(this, arguments);
1596 }
1597
1598 if (this.render) {
1599 this.render = _.wrap(this.render, function (render) {
1600 this.trigger('before_render');
1601 render.call(this);
1602 Events.trigger('view.rendered', this);
1603 this.trigger('rendered');
1604 });
1605 }
1606
1607 if (_.isFunction(this.init)) {
1608 this.init.apply(this, arguments);
1609 }
1610 }
1611 }),
1612 template = _.memoize(function (id) {
1613 var compiled;
1614 return function (data) {
1615 compiled = compiled || _.template(document.getElementById(id).innerHTML, null, _TemplateOptions);
1616 return compiled(data).replace('/*<![CDATA[*/', '').replace('/*]]>*/', '');
1617 };
1618 }),
1619 createTemplate = _.memoize(function (str) {
1620 var cache;
1621 return function (data) {
1622 cache = cache || _.template(str, null, _TemplateOptions);
1623 return cache(data);
1624 };
1625 }),
1626 getTemplateOptions = function getTemplateOptions() {
1627 return $.extend(true, {}, _TemplateOptions);
1628 },
1629 setModule = function setModule(moduleId, moduleView) {
1630 currentModules[moduleId] = moduleView;
1631 },
1632 getModules = function getModules() {
1633 return currentModules;
1634 },
1635 getModule = function getModule(moduleId) {
1636 return currentModules[moduleId];
1637 },
1638 consts = function () {
1639 return {
1640 ModuleShowCount: 'hustle_module_show_count-'
1641 };
1642 }();
1643
1644 return {
1645 define: define,
1646 setModule: setModule,
1647 getModules: getModules,
1648 getModule: getModule,
1649 get: get,
1650 Events: Events,
1651 View: View,
1652 template: template,
1653 createTemplate: createTemplate,
1654 getTemplateOptions: getTemplateOptions,
1655 consts: consts
1656 };
1657 }(jQuery, document, window);
1658 })(jQuery);
1659 var Optin = window.Optin || {};
1660 Optin.Models = {};
1661
1662 (function ($) {
1663 'use strict';
1664
1665 Optin.NEVER_SEE_PREFIX = 'inc_optin_never_see_again-';
1666 Optin.COOKIE_PREFIX = 'inc_optin_long_hidden-';
1667 Optin.POPUP_COOKIE_PREFIX = 'inc_optin_popup_long_hidden-';
1668 Optin.SLIDE_IN_COOKIE_PREFIX = 'inc_optin_slide_in_long_hidden-';
1669 Optin.EMBEDDED_COOKIE_PREFIX = 'inc_optin_embedded_long_hidden-';
1670 Optin.template = _.memoize(function (id) {
1671 var compiled;
1672 var options = {
1673 evaluate: /<#([\s\S]+?)#>/g,
1674 interpolate: /\{\{\{([\s\S]+?)\}\}\}/g,
1675 escape: /\{\{([^\}]+?)\}\}(?!\})/g
1676 };
1677 return function (data) {
1678 compiled = compiled || _.template($('#' + id).html(), null, options);
1679 return compiled(data).replace('/*<![CDATA[*/', '').replace('/*]]>*/', '');
1680 };
1681 });
1682 /**
1683 * Compatibility with other plugin/theme e.g. upfront
1684 *
1685 */
1686
1687 Optin.templateCompat = _.memoize(function (id) {
1688 var compiled;
1689 return function (data) {
1690 compiled = compiled || _.template($('#' + id).html());
1691 return compiled(data).replace('/*<![CDATA[*/', '').replace('/*]]>*/', '');
1692 };
1693 });
1694 Optin.cookie = {
1695 // Get a cookie value.
1696 get: function get(name) {
1697 var c;
1698 var cookiesArray = document.cookie.split(';'),
1699 cookiesArrayLength = cookiesArray.length,
1700 cookieName = name + '=';
1701
1702 for (var i = 0; i < cookiesArrayLength; i += 1) {
1703 c = cookiesArray[i];
1704
1705 while (' ' === c.charAt(0)) {
1706 c = c.substring(1, c.length);
1707 }
1708
1709 if (0 === c.indexOf(cookieName)) {
1710 var _val = c.substring(cookieName.length, c.length);
1711
1712 return _val ? JSON.parse(_val) : _val;
1713 }
1714 }
1715
1716 return null;
1717 },
1718 // Saves the value into a cookie.
1719 set: function set(name, value, days) {
1720 var date, expires;
1721 value = Array.isArray(value) || $.isPlainObject(value) ? JSON.stringify(value) : value;
1722
1723 if (!isNaN(days)) {
1724 date = new Date();
1725 date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
1726 expires = '; expires=' + date.toGMTString();
1727 } else {
1728 expires = '';
1729 }
1730
1731 document.cookie = name + '=' + value + expires + '; path=/';
1732 }
1733 };
1734 Optin.Mixins = {
1735 _mixins: {},
1736 _servicesMixins: {},
1737 _desingMixins: {},
1738 _displayMixins: {},
1739 add: function add(id, obj) {
1740 this._mixins[id] = obj;
1741 },
1742 getMixins: function getMixins() {
1743 return this._mixins;
1744 },
1745 addServicesMixin: function addServicesMixin(id, obj) {
1746 this._servicesMixins[id] = obj;
1747 },
1748 getServicesMixins: function getServicesMixins() {
1749 return this._servicesMixins;
1750 }
1751 };
1752 })(jQuery);
1753 function _typeof(obj) { "@babel/helpers - typeof"; 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); }
1754
1755 /* global incOpt */
1756 // the semi-colon before function invocation is a safety net against concatenated
1757 // scripts and/or other plugins which may not be closed properly.
1758 // noinspection JSUnusedLocalSymbols
1759 (function ($) {
1760 'use strict';
1761
1762 var Optin = window.Optin || {};
1763
1764 if (incOpt.is_admin) {
1765 return;
1766 }
1767
1768 Optin.moduleLogView = Backbone.Model.extend({
1769 url: incOpt.ajaxurl + '?action=hustle_module_viewed',
1770 defaults: {
1771 page_id: incOpt.page_id
1772 },
1773 parse: function parse(res) {
1774 if (res.success) {
1775 console.log('Log success!'); // eslint-disable-line no-console
1776 } else {
1777 console.log('Log failed!'); // eslint-disable-line no-console
1778 }
1779 }
1780 });
1781 /**
1782 * Log module view when it's being viewed
1783 */
1784
1785 $(document).on('hustle:module:loaded', function (e, module) {
1786 if ('object' === _typeof(module)) {
1787 var type = module.moduleType; // set cookies used for "show less than" display condition
1788
1789 var showCountKey = Hustle.consts.ModuleShowCount + type + '-' + module.moduleId,
1790 currentShowCount = Optin.cookie.get(showCountKey);
1791 Optin.cookie.set(showCountKey, currentShowCount + 1, 30); // Log number of times this module type has been shown so far
1792
1793 var logType = 'undefined' !== module.$el.data('sub-type') ? module.$el.data('sub-type') : null; // TODO: check tracking types for embeds.
1794
1795 if ('undefined' !== typeof Optin.moduleLogView && module.isTrackingEnabled) {
1796 var logView = new Optin.moduleLogView();
1797 logView.set('module_sub_type', logType);
1798 logView.set('module_type', type);
1799 logView.set('module_id', module.moduleId);
1800 logView.save();
1801 }
1802 }
1803 });
1804
1805 Optin.updateSshareNetworks = function () {
1806 var networksToRetrieve = Optin.networksToRetrieve;
1807
1808 if ('undefined' === typeof networksToRetrieve || !networksToRetrieve.length) {
1809 return;
1810 } // Retrieve the counters via ajax.
1811
1812
1813 $.ajax({
1814 type: 'POST',
1815 url: incOpt.ajaxurl,
1816 dataType: 'json',
1817 data: {
1818 action: 'hustle_update_network_shares',
1819 postId: incOpt.page_id,
1820 networks: networksToRetrieve
1821 }
1822 }).done(function (res) {
1823 if (res.success) {
1824 var response = res.data;
1825 $.each(response.networks, function (network, counter) {
1826 var $containers = $(".hustle-share-icon[data-counter=\"native\"][data-network=\"".concat(network, "\"]"));
1827
1828 if ($containers.length) {
1829 $containers.each(function () {
1830 var $counter = $(this).find('.hustle-counter'),
1831 defaultCounter = parseInt($(this).data('count'), 10);
1832
1833 if (defaultCounter > parseInt(counter, 10)) {
1834 counter = parseInt(defaultCounter, 10);
1835 }
1836
1837 var formatted = '';
1838
1839 if (1000 > counter) {
1840 formatted = counter;
1841 } else if (1000000 > counter) {
1842 formatted = (counter / 1000).toFixed(1) + response.shorten.thousand;
1843 } else {
1844 formatted = (counter / 1000000).toFixed(1) + response.shorten.million;
1845 }
1846
1847 $counter.text(formatted);
1848 });
1849 }
1850 });
1851 }
1852 });
1853 };
1854 })(jQuery);
1855 /* global incOpt */
1856 // the semi-colon before function invocation is a safety net against concatenated
1857 // scripts and/or other plugins which may not be closed properly.
1858 // noinspection JSUnusedLocalSymbols
1859 (function ($) {
1860 $(document).on('submit', 'form.hustle-unsubscribe-form', function (e) {
1861 e.preventDefault();
1862 var $form = $(e.target),
1863 $emailHolder = $form.find('.hustle-email-section'),
1864 data = $form.serialize(),
1865 $button = $form.find('button'),
1866 $failure = $form.find('.wpoi-submit-failure');
1867 $button.attr('disabled', true);
1868 $button.addClass('sui-button-onload');
1869 $form.on('keypress', function () {
1870 return $failure.hide();
1871 });
1872 $.ajax({
1873 type: 'POST',
1874 url: incOpt.ajaxurl,
1875 dataType: 'json',
1876 data: {
1877 action: 'hustle_unsubscribe_form_submission',
1878 data: data
1879 },
1880 success: function success(res) {
1881 if (res.success && true === res.success) {
1882 $emailHolder.hide();
1883 $failure.hide();
1884
1885 if (res.data.wrapper && res.data.html) {
1886 $form.find(res.data.wrapper).html(res.data.html);
1887 }
1888 } else if (res.data.html) {
1889 $failure.text(res.data.html);
1890 $failure.show();
1891 }
1892 },
1893 error: function error() {
1894 $failure.text($failure.data('default-error'));
1895 $failure.show();
1896 },
1897 complete: function complete() {
1898 $button.attr('disabled', false);
1899 $button.removeClass('sui-button-onload');
1900 }
1901 });
1902 return false;
1903 });
1904 })(jQuery);
1905 /* global incOpt, Modules, grecaptcha */
1906 // the semi-colon before function invocation is a safety net against concatenated
1907 // scripts and/or other plugins which may not be closed properly.
1908 // noinspection JSUnusedLocalSymbols
1909 (function ($, doc, win) {
1910 'use strict';
1911
1912 if (incOpt.is_upfront) {
1913 return;
1914 }
1915
1916 if (!incOpt.is_admin) {
1917 Optin.ModuleLogConversion = Backbone.Model.extend({
1918 url: incOpt.ajaxurl + '?action=hustle_module_converted',
1919 defaults: {
1920 page_id: incOpt.page_id
1921 },
1922 parse: function parse(res) {
1923 if (res.success) {
1924 console.log('Log success!'); // eslint-disable-line no-console
1925 } else {
1926 console.log('Log failed!'); // eslint-disable-line no-console
1927 }
1928 }
1929 });
1930 }
1931 /**
1932 * Front View Model
1933 **/
1934
1935
1936 Optin.Module = Backbone.View.extend({
1937 moduleId: '',
1938 moduleType: '',
1939 settings: {},
1940 data: {},
1941 appearAfter: 'time',
1942 parent: 'body',
1943 cookieKey: '',
1944 neverSeeCookieKey: '',
1945 isShown: false,
1946 events: {
1947 'click .hustle-button-cta': 'ctaClicked'
1948 },
1949 close: _.noop,
1950 initialize: function initialize(opts) {
1951 this.data = opts;
1952 this.moduleId = opts.module_id;
1953 this.settings = opts.settings;
1954 this.moduleType = opts.module_type;
1955 this.isTrackingEnabled = 'enabled' === this.$el.data('tracking');
1956 this.setOnInit(opts);
1957 this.handleDisplay();
1958 },
1959 setOnInit: function setOnInit() {
1960 // Listen to successful Hustle's submission for optin to set cookies if needed.
1961 if ('optin' === this.data.module_mode) {
1962 this.$el.off('submit').on('submit', $.proxy(this, 'handleSubmission'));
1963 this.$el.find('.hustle-layout-form').off('change').on('change', $.proxy(this, 'onInputChange'));
1964 } // Calculate expiration days depends on what's been set
1965
1966
1967 this.expiration = parseInt(this.settings.expiration, 10);
1968 this.expirationDays = this.getExpirationDays();
1969 this.triggers = this.settings.triggers;
1970
1971 if ('popup' === this.moduleType) {
1972 this.cookieKey = Optin.POPUP_COOKIE_PREFIX + this.moduleId;
1973 } else if ('slidein' === this.moduleType) {
1974 this.cookieKey = Optin.SLIDE_IN_COOKIE_PREFIX + this.moduleId;
1975 } else if ('embedded' === this.moduleType) {
1976 this.cookieKey = Optin.EMBEDDED_COOKIE_PREFIX + this.moduleId;
1977 }
1978
1979 this.neverSeeCookieKey = Optin.NEVER_SEE_PREFIX + this.moduleType + '-' + this.moduleId;
1980 },
1981 // Check if module should display.
1982 shouldDisplay: function shouldDisplay() {
1983 if (!this.$el.length) {
1984 return false;
1985 }
1986
1987 var display,
1988 neverSee = Optin.cookie.get(this.neverSeeCookieKey);
1989 neverSee = parseInt(neverSee) === parseInt(this.moduleId);
1990
1991 if (neverSee) {
1992 display = false;
1993 return display;
1994 } // Hide after close.
1995
1996
1997 if ('no_show_on_post' === this.settings.after_close) {
1998 if (0 < parseInt(incOpt.page_id, 10)) {
1999 display = !Optin.cookie.get(this.cookieKey + '_' + incOpt.page_id);
2000 } else if (0 === parseInt(incOpt.page_id, 10) && incOpt.page_slug) {
2001 display = !Optin.cookie.get(this.cookieKey + '_' + incOpt.page_slug);
2002 } else {
2003 display = true;
2004 }
2005 } else if ('no_show_all' === this.settings.after_close) {
2006 display = !Optin.cookie.get(this.cookieKey);
2007 } else {
2008 display = true;
2009 }
2010
2011 if (!display) {
2012 return display;
2013 } // Hide after subscription.
2014
2015
2016 if ('no_show_on_post' === this.data.settings.hide_after_subscription) {
2017 if (0 < parseInt(incOpt.page_id, 10)) {
2018 display = !Optin.cookie.get(this.cookieKey + '_success_' + incOpt.page_id);
2019 } else if (0 === parseInt(incOpt.page_id, 10) && incOpt.page_slug) {
2020 display = !Optin.cookie.get(this.cookieKey + '_' + incOpt.page_slug);
2021 } else {
2022 display = true;
2023 }
2024 } else if ('no_show_all' === this.data.settings.hide_after_subscription) {
2025 display = !Optin.cookie.get(this.cookieKey + '_success');
2026 }
2027
2028 if (!display) {
2029 return display;
2030 } // Hide after CTA.
2031
2032
2033 if ('no_show_on_post' === this.data.settings.hide_after_cta) {
2034 if (0 < parseInt(incOpt.page_id, 10)) {
2035 display = !Optin.cookie.get(this.cookieKey + '_cta_success_' + incOpt.page_id);
2036 } else if (0 === parseInt(incOpt.page_id, 10) && incOpt.page_slug) {
2037 display = !Optin.cookie.get(this.cookieKey + '_cta_' + incOpt.page_slug);
2038 } else {
2039 display = true;
2040 }
2041 } else if ('no_show_all' === this.data.settings.hide_after_cta) {
2042 display = !Optin.cookie.get(this.cookieKey + '_cta_success');
2043 }
2044
2045 return display;
2046 },
2047 getExpirationDays: function getExpirationDays() {
2048 switch (this.settings.expiration_unit) {
2049 case 'months':
2050 return this.expiration * 30;
2051
2052 case 'weeks':
2053 return this.expiration * 7;
2054
2055 case 'hours':
2056 return this.expiration / 24;
2057
2058 case 'minutes':
2059 return this.expiration / (24 * 60);
2060
2061 case 'seconds':
2062 return this.expiration / (24 * 60 * 60);
2063
2064 default:
2065 return this.expiration;
2066 }
2067 },
2068 handleDisplay: function handleDisplay() {
2069 if (!this.shouldDisplay()) {
2070 this.$el.css('display', 'none');
2071 return;
2072 }
2073
2074 this.beforeListenForDisplay();
2075 this.displayOnTrigger();
2076 },
2077 displayOnTrigger: function displayOnTrigger() {
2078 var triggerName = this.settings.triggers.trigger; // Queue the display for each trigger.
2079
2080 if ('function' === typeof this[triggerName + 'Trigger']) {
2081 this[triggerName + 'Trigger']();
2082 }
2083 },
2084 beforeListenForDisplay: function beforeListenForDisplay() {
2085 this.$el.off('hustle:module:closed').on('hustle:module:closed', $.proxy(this, 'onModuleClosed', 'click_close_icon'));
2086 this.$el.off('hustle:module:hidden').on('hustle:module:hidden', $.proxy(this, 'onModuleClosed', 'auto_hide'));
2087 this.$el.off('hustle:module:click_outside').on('hustle:module:click_outside', $.proxy(this, 'onModuleClosed', 'click_outside'));
2088 this.$el.off('hustle:module:esc_key_pressed').on('hustle:module:esc_key_pressed', $.proxy(this, 'onModuleClosed', 'esc_key'));
2089 this.$el.off('hustle:module:clicked_never_see').on('hustle:module:clicked_never_see', $.proxy(this, 'onModuleClosed', 'click_never_see'));
2090 },
2091 executeRecaptcha: function executeRecaptcha($form, $recaptchaContainer) {
2092 var _$recaptchaContainer$ = $recaptchaContainer.data(),
2093 version = _$recaptchaContainer$.version;
2094
2095 if ('v2_checkbox' === version) {
2096 this.doSubmit($form);
2097 } else {
2098 var data = {};
2099
2100 if ('v3_recaptcha' === version) {
2101 data.action = 'contact';
2102 }
2103
2104 grecaptcha.execute($recaptchaContainer.attr('recaptcha-id'), data);
2105 }
2106 },
2107 display: function display() {
2108 // If it's showing, return.
2109 if (this.isShown) {
2110 return;
2111 } // Make sure the module wasn't dismissed in between displays.
2112
2113
2114 if (!this.shouldDisplay()) {
2115 return;
2116 } // Setup the stuff before showing the module.
2117
2118
2119 this.beforeShowModule();
2120 $(document).trigger('hustle:module:before_show', this);
2121 this.showModule();
2122 $(document).trigger('hustle:module:loaded', this); // It's being shown.
2123
2124 this.isShown = true;
2125 },
2126 beforeShowModule: function beforeShowModule() {
2127 this.handleCompatibility();
2128 HUI.maybeRenderRecaptcha(this.$el, this); // Load select2 if this module has select fields.
2129
2130 if (this.$el.find('.hustle-select2').length) {
2131 HUI.select2();
2132 } // If there's a timepicker.
2133
2134
2135 if (this.$el.find('.hustle-time').length) {
2136 HUI.timepicker('.hustle-time');
2137 } // If there's a datepicker.
2138
2139
2140 if (this.$el.find('.hustle-date').length) {
2141 var date = $('.hustle-date'),
2142 _incOpt = incOpt,
2143 strings = _incOpt.days_and_months;
2144
2145 _.each(date, function (e) {
2146 HUI.datepicker(e, strings.days_full, strings.days_short, strings.days_min, strings.months_full, strings.months_short);
2147 });
2148 } // Add the proper class if the field is filled.
2149
2150
2151 HUI.inputFilled();
2152 },
2153 // ==============================
2154 // Start trigger functions
2155 // ==============================
2156 timeTrigger: function timeTrigger() {
2157 var delay = parseInt(this.triggers.on_time_delay, 10) * 1000;
2158
2159 if ('minutes' === this.triggers.on_time_unit) {
2160 delay *= 60;
2161 } else if ('hours' === this.triggers.on_time_unit) {
2162 delay *= 60 * 60;
2163 } // Display after a certain time.
2164
2165
2166 _.delay($.proxy(this, 'display'), delay);
2167 },
2168 clickTrigger: function clickTrigger() {
2169 var self = this,
2170 selector = this.triggers.on_click_element.trim();
2171
2172 if ('1' === this.triggers.enable_on_click_element && '' !== selector) {
2173 var $clickable = $(selector);
2174
2175 if ($clickable.length) {
2176 $(document).on('click', selector, function (e) {
2177 e.preventDefault();
2178 self.display();
2179 });
2180 }
2181 }
2182
2183 if ('1' === this.triggers.enable_on_click_shortcode) {
2184 // Clickable button added with shortcode
2185 $(document).on('click', '.hustle_module_shortcode_trigger', function (e) {
2186 e.preventDefault();
2187
2188 if ($(this).data('id') === parseInt(self.moduleId) && $(this).data('type') === self.type) {
2189 self.display();
2190 }
2191 });
2192 }
2193 },
2194 scrollTrigger: function scrollTrigger() {
2195 var self = this;
2196 var moduleShown = false;
2197
2198 if ('scrolled' === this.triggers.on_scroll) {
2199 $(win).on('scroll', _.debounce(function () {
2200 if (moduleShown) {
2201 return;
2202 }
2203
2204 if (win.pageYOffset * 100 / $(doc).height() >= parseInt(self.triggers.on_scroll_page_percent)) {
2205 self.display();
2206 moduleShown = true;
2207 }
2208 }, 50));
2209 }
2210
2211 if ('selector' === this.triggers.on_scroll) {
2212 var $el = $(this.triggers.on_scroll_css_selector);
2213
2214 if ($el.length) {
2215 $(win).on('scroll', _.debounce(function () {
2216 if (moduleShown) {
2217 return;
2218 }
2219
2220 if (win.pageYOffset >= $el.offset().top) {
2221 self.display();
2222 moduleShown = true;
2223 }
2224 }, 50));
2225 }
2226 }
2227 },
2228 exit_intentTrigger: function exit_intentTrigger() {
2229 //eslint-disable-line camelcase
2230 var self = this;
2231 var delay = 0; // handle delay
2232
2233 if ('1' === this.triggers.on_exit_intent_delayed) {
2234 delay = parseInt(this.triggers.on_exit_intent_delayed_time, 10) * 1000;
2235
2236 if ('minutes' === this.triggers.on_exit_intent_delayed_unit) {
2237 delay *= 60;
2238 } else if ('hours' === this.triggers.on_exit_intent_delayed_unit) {
2239 delay *= 60 * 60;
2240 }
2241 } // handle per session
2242
2243
2244 if ('1' === this.triggers.on_exit_intent_per_session) {
2245 $(doc).on('mouseleave', _.debounce(function (e) {
2246 if (!$('input').is(':focus')) {
2247 self.setExitTimer();
2248 $(this).off(e);
2249 }
2250 }, 300));
2251 } else {
2252 $(doc).on('mouseleave', _.debounce(function () {
2253 if (!$('input').is(':focus')) {
2254 self.setExitTimer();
2255 }
2256 }, 300));
2257 } // When user moves cursor back into window, reset timer.
2258
2259
2260 $('html').on('mousemove', _.debounce(function () {
2261 self.resetExitTimer();
2262 }, 300)); // Timer variable to be set or reset.
2263
2264 this.exitTimer = null; // When user moves cursor back into window, reset timer.
2265
2266 this.resetExitTimer = function () {
2267 // Only run if timer is still going.
2268 if (self.exitTimer) {
2269 // Reset the timer.
2270 clearTimeout(self.exitTimer);
2271 }
2272 }; // When cursor is out of window, set timer for trigger.
2273
2274
2275 this.setExitTimer = function () {
2276 // Set the timer, allowing it to be reset.
2277 self.exitTimer = setTimeout(function trigger() {
2278 // Timer is done.
2279 self.exitTimer = null; // Display module
2280
2281 self.display();
2282 }, delay);
2283 };
2284 },
2285 adblockTrigger: function adblockTrigger() {
2286 var _this = this;
2287
2288 var adblock = !$('#hustle_optin_adBlock_detector').length;
2289
2290 if (adblock && '1' === this.triggers.on_adblock) {
2291 if ('1' !== this.triggers.enable_on_adblock_delay) {
2292 this.display();
2293 } else {
2294 var value = this.triggers.on_adblock_delay,
2295 unit = this.triggers.on_adblock_delay_unit,
2296 delay = this.convertToMicroseconds(value, unit);
2297 setTimeout(function () {
2298 return _this.display();
2299 }, delay);
2300 }
2301 }
2302 },
2303 // End trigger functions.
2304 convertToMicroseconds: function convertToMicroseconds(value, unit) {
2305 if ('seconds' === unit) {
2306 return parseInt(value, 10) * 1000;
2307 } else if ('minutes' === unit) {
2308 return parseInt(value, 10) * 60 * 1000;
2309 }
2310
2311 return parseInt(value, 10) * 60 * 60 * 1000;
2312 },
2313 onModuleClosed: function onModuleClosed(closedBy) {
2314 this.clearRunningCompatInterval();
2315 this.$el.find('iframe').each(function () {
2316 $(this).attr('src', $(this).attr('src'));
2317 });
2318
2319 if (Array.isArray(this.settings.after_close_trigger) && -1 !== this.settings.after_close_trigger.indexOf(closedBy)) {
2320 // save cookies for 'after_close' property
2321 if ('no_show_on_post' === this.settings.after_close) {
2322 if (0 < parseInt(incOpt.page_id, 10)) {
2323 Optin.cookie.set(this.cookieKey + '_' + incOpt.page_id, this.moduleId, this.expirationDays);
2324 } else if (0 === parseInt(incOpt.page_id, 10) && incOpt.page_slug) {
2325 Optin.cookie.set(this.cookieKey + '_' + incOpt.page_slug, this.moduleId, this.expirationDays);
2326 }
2327 } else if ('no_show_all' === this.settings.after_close) {
2328 Optin.cookie.set(this.cookieKey, this.moduleId, this.expirationDays);
2329 }
2330 } else if ('click_never_see' === closedBy) {
2331 Optin.cookie.set(this.neverSeeCookieKey, this.moduleId, this.expirationDays);
2332 }
2333
2334 this.isShown = false;
2335 this.stopPlayingAudioVideo();
2336 },
2337 redirectOnExternalFormSubmit: function redirectOnExternalFormSubmit(e, submitDelay) {
2338 this.setCookiesAfterSubscription();
2339 var $form = $(e.target);
2340
2341 if ($form.attr('action')) {
2342 setTimeout(function () {
2343 return window.location.replace($form.attr('action'));
2344 }, submitDelay);
2345 }
2346 },
2347
2348 /**
2349 * Some form plugins have their own form submit listener,
2350 * so we have to tackle each one of them and apply the 'on_submit' behavior.
2351 */
2352 handleCompatibility: function handleCompatibility() {
2353 var me = this,
2354 afterSubmit = this.data.settings.on_submit,
2355 submitDelay = this.convertToMicroseconds(this.data.settings.on_submit_delay, this.data.settings.on_submit_delay_unit);
2356
2357 if (-1 !== $.inArray(afterSubmit, ['close', 'default']) && 'embedded' !== this.moduleType) {
2358 // CF7.
2359 if (this.$el.find('form.wpcf7-form').length) {
2360 this.$el.on('wpcf7mailsent', function () {
2361 return me.closeAfterSubmission(me.el, submitDelay);
2362 });
2363 } // Forminator's Custom form.
2364
2365
2366 if (this.$('.forminator-custom-form').length) {
2367 this.$el.on('forminator:form:submit:success', function () {
2368 return me.closeAfterSubmission(me.el, submitDelay);
2369 });
2370 } // Gravity forms.
2371
2372
2373 if (this.$('.gform_wrapper').length) {
2374 $(document).on('gform_confirmation_loaded', function () {
2375 return me.closeAfterSubmission(me.el, submitDelay);
2376 });
2377 } // Ninja forms.
2378
2379
2380 if (this.$('.nf-form-cont').length) {
2381 $(document).on('nfFormSubmitResponse', function () {
2382 return me.closeAfterSubmission(me.el, submitDelay);
2383 });
2384 }
2385 } else if ('redirect' === afterSubmit) {
2386 // CF7.
2387 if (this.$el.find('form.wpcf7-form').length) {
2388 this.$el.on('wpcf7mailsent', function (e) {
2389 return me.redirectOnExternalFormSubmit(e, submitDelay);
2390 });
2391 } // Forminator's Custom form.
2392
2393
2394 if (this.$('.forminator-custom-form').length) {
2395 this.$el.on('forminator:form:submit:success', function (e) {
2396 return me.redirectOnExternalFormSubmit(e, submitDelay);
2397 });
2398 } // Gravity forms.
2399
2400
2401 if (this.$('.gform_wrapper').length) {
2402 $(document).on('gform_confirmation_loaded', function (e) {
2403 return me.redirectOnExternalFormSubmit(e, submitDelay);
2404 });
2405 } // Ninja forms.
2406
2407
2408 if (this.$('.nf-form-cont').length) {
2409 $(document).on('nfFormSubmitResponse', function (e) {
2410 return me.redirectOnExternalFormSubmit(e, submitDelay);
2411 });
2412 }
2413 } // e-newsletter, when a shortcode was added on module content.
2414
2415
2416 var $enewsletterForm = this.$el.find('form#subscribes_form'),
2417 enewsletterMaxWait = 216000000; // 1 hour
2418
2419 var enewsletterWaited = 1000;
2420
2421 if ($enewsletterForm.length) {
2422 me.waitEnewsletterResult = setInterval(function () {
2423 enewsletterWaited += 1000;
2424 var $enewsletterMessage = me.$el.find('#message');
2425
2426 if (!_.isEmpty($enewsletterMessage.text().trim()) || enewsletterMaxWait === enewsletterWaited) {
2427 me.close();
2428 }
2429 }, 1000);
2430 }
2431 },
2432 closeAfterSubmission: function closeAfterSubmission(el, submitDelay) {
2433 var _this2 = this;
2434
2435 this.setCookiesAfterSubscription();
2436 setTimeout(function () {
2437 return _this2.close(el);
2438 }, submitDelay);
2439 },
2440 maybeCloseAfterCtaClick: function maybeCloseAfterCtaClick(el, delay) {
2441 if ('undefined' !== typeof this.data.settings.close_cta && '0' !== this.data.settings.close_cta) {
2442 var self = this;
2443 setTimeout(function () {
2444 return self.close(el);
2445 }, delay);
2446 }
2447 },
2448 setCookiesAfterSubscription: function setCookiesAfterSubscription() {
2449 // Save cookies for 'hide_after_subscription' property
2450 if ('undefined' !== typeof this.data.settings.hide_after_subscription && 'keep_show' !== this.data.settings.hide_after_subscription) {
2451 var moduleId = this.data.module_id;
2452 var cookieKey;
2453
2454 if ('popup' === this.data.module_type) {
2455 cookieKey = Optin.POPUP_COOKIE_PREFIX + moduleId;
2456 } else if ('slidein' === this.data.module_type) {
2457 cookieKey = Optin.SLIDE_IN_COOKIE_PREFIX + moduleId;
2458 } else if ('embedded' === this.data.module_type) {
2459 cookieKey = Optin.EMBEDDED_COOKIE_PREFIX + moduleId;
2460 }
2461
2462 if ('no_show_on_post' === this.data.settings.hide_after_subscription) {
2463 Optin.cookie.set(cookieKey + '_success_' + incOpt.page_id, moduleId);
2464 } else if ('no_show_all' === this.data.settings.hide_after_subscription) {
2465 Optin.cookie.set(cookieKey + '_success', moduleId);
2466 }
2467 }
2468 },
2469 maybeSetCookiesAfterCtaClick: function maybeSetCookiesAfterCtaClick() {
2470 // Save cookies for 'hide_after_cta' property
2471 if ('undefined' !== typeof this.data.settings.hide_after_cta && 'keep_show' !== this.data.settings.hide_after_cta) {
2472 var moduleId = this.data.module_id;
2473 var cookieKey;
2474
2475 if ('popup' === this.data.module_type) {
2476 cookieKey = Optin.POPUP_COOKIE_PREFIX + moduleId;
2477 } else if ('slidein' === this.data.module_type) {
2478 cookieKey = Optin.SLIDE_IN_COOKIE_PREFIX + moduleId;
2479 } else if ('embedded' === this.data.module_type) {
2480 cookieKey = Optin.EMBEDDED_COOKIE_PREFIX + moduleId;
2481 }
2482
2483 if ('no_show_on_post' === this.data.settings.hide_after_cta) {
2484 Optin.cookie.set(cookieKey + '_cta_success_' + incOpt.page_id, moduleId);
2485 } else if ('no_show_all' === this.data.settings.hide_after_cta) {
2486 Optin.cookie.set(cookieKey + '_cta_success', moduleId);
2487 }
2488 }
2489 },
2490 handleSubmission: function handleSubmission(e) {
2491 e.preventDefault();
2492 var $form = $(e.target);
2493
2494 if ($form.data('sending')) {
2495 return;
2496 }
2497
2498 var errors = HUI.optinValidate(this.$el);
2499 errors = this.validateSubmission(errors);
2500
2501 if (errors.length) {
2502 HUI.optinError($form.find('.hustle-error-message'), errors);
2503 return;
2504 }
2505
2506 HUI.optinSubmit($form.find('.hustle-button-submit')); // If no recaptcha, do the submit.
2507
2508 var $recaptchaContainer = $form.find('.hustle-recaptcha');
2509
2510 if (!$recaptchaContainer.length) {
2511 this.doSubmit($form);
2512 } else {
2513 // Execute recaptcha. It'll trigger the form submit after its execution.
2514 this.executeRecaptcha($form, $recaptchaContainer);
2515 }
2516 },
2517 doSubmit: function doSubmit($form) {
2518 var self = this,
2519 formData = $form.serialize(),
2520 moduleId = $form.find('input[name="hustle_module_id"]').val(),
2521 gdpr = $form.find('#hustle-modal-gdpr-' + moduleId + ':checked').val(),
2522 $errorContainer = $form.find('.hustle-error-message'),
2523 module = _.find(Modules, function (mod) {
2524 return parseInt(moduleId, 10) === parseInt(mod.module_id, 10);
2525 });
2526
2527 $form.trigger('hustle:module:submit', formData);
2528 $form.data('sending', true);
2529 $.ajax({
2530 type: 'POST',
2531 url: incOpt.ajaxurl,
2532 dataType: 'json',
2533 data: {
2534 action: 'hustle_module_form_submit',
2535 data: {
2536 form: formData,
2537 module_id: moduleId,
2538 gdpr: gdpr,
2539 uri: encodeURI(window.location.href)
2540 }
2541 },
2542 success: function success(res) {
2543 if (res && res.success) {
2544 $form.trigger('hustle:module:submit:success', formData);
2545 self.setCookiesAfterSubscription(); // Save cookies for 'hide_after_subscription' property
2546
2547 if ('undefined' !== typeof module.settings.hide_after_subscription) {
2548 var cookieKey;
2549
2550 if ('popup' === module.module_type) {
2551 cookieKey = Optin.POPUP_COOKIE_PREFIX + moduleId;
2552 } else if ('slidein' === module.module_type) {
2553 cookieKey = Optin.SLIDE_IN_COOKIE_PREFIX + moduleId;
2554 } else if ('embedded' === module.module_type) {
2555 cookieKey = Optin.EMBEDDED_COOKIE_PREFIX + moduleId;
2556 }
2557
2558 if ('no_show_on_post' === module.settings.hide_after_subscription) {
2559 if (0 < parseInt(incOpt.page_id, 10)) {
2560 Optin.cookie.set(cookieKey + '_success_' + incOpt.page_id, moduleId);
2561 } else if (0 === parseInt(incOpt.page_id, 10) && incOpt.page_slug) {
2562 Optin.cookie.set(cookieKey + '_success_' + incOpt.page_slug, moduleId);
2563 }
2564
2565 Optin.cookie.set(cookieKey + '_success_' + incOpt.page_id, moduleId);
2566 } else if ('no_show_all' === module.settings.hide_after_subscription) {
2567 Optin.cookie.set(cookieKey + '_success', moduleId);
2568 }
2569 }
2570
2571 if ('redirect' === res.data.behavior.after_submit && 0 < res.data.behavior.url.length) {
2572 window.location.assign(res.data.behavior.url);
2573 } else {
2574 var $success = self.$('.hustle-success'),
2575 $succesContainer = self.$('.hustle-success-content');
2576
2577 if (res.data.message && $succesContainer.length) {
2578 $succesContainer.html(res.data.message);
2579 }
2580
2581 HUI.optinSuccess($success, $success.data('close-delay'));
2582 }
2583 } else {
2584 $form.trigger('hustle:module:submit:failed', formData); // Reset recaptcha.
2585
2586 var id = $form.find('.hustle-recaptcha').attr('recaptcha-id');
2587
2588 if (id) {
2589 grecaptcha.reset(id);
2590 }
2591
2592 HUI.optinError($errorContainer, res.data.errors);
2593 }
2594 },
2595 error: function error() {
2596 $form.trigger('hustle:module:submit:failed', formData);
2597 HUI.optinError($errorContainer);
2598 },
2599 complete: function complete() {
2600 $form.data('sending', false);
2601 $form.find('.hustle-button-onload').removeClass('hustle-button-onload');
2602 }
2603 });
2604 },
2605 validateSubmission: function validateSubmission(errors) {
2606 var self = this;
2607 var fields = this.$el.find('[data-validate="1"]'),
2608 emailRe = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/i,
2609 urlProtocolRe = /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)?/i; // urlNoProtocolRe = /[-a-zA-Z0-9@:%_\+.~#?&//=]{2,256}\.[a-z]{2,4}\b(\/[-a-zA-Z0-9@:%_\+.~#?&//=]*)?/i;
2610
2611 $.each(fields, function (i, field) {
2612 var $field = $(field),
2613 value = String($field.val()).trim().toLowerCase();
2614
2615 if (!value.length) {
2616 return;
2617 }
2618
2619 var isValid = true;
2620
2621 if ('email' === $field.attr('type')) {
2622 isValid = emailRe.test(value);
2623 } else if ('url' === $field.attr('type')) {
2624 isValid = urlProtocolRe.test(value);
2625 } else if ('datepicker' === $field.attr('type')) {
2626 var format = $field.data('format').toString();
2627 var dateRe = '';
2628
2629 if ('mm/dd/yy' === format || 'mm/dd/yy' === format || 'mm.dd.yy' === format || 'mm.dd.yy' === format || 'mm-dd-yy' === format || 'mm-dd-yy' === format) {
2630 dateRe = /^(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d/;
2631 } else if ('dd/mm/yy' === format || 'dd/mm/yy' === format || 'dd.mm.yy' === format || 'dd.mm.yy' === format || 'dd-mm-yy' === format || 'dd-mm-yy' === format) {
2632 dateRe = /^(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)\d\d/;
2633 } else if ('yy/mm/dd' === format || 'Y/m/d' === format || 'yy.mm.dd' === format || 'Y.m.d' === format || 'yy-mm-dd' === format || 'Y-m-d' === format) {
2634 dateRe = /^(19|20)\d\d[- /.](0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])/;
2635 }
2636
2637 if ('' !== dateRe) {
2638 isValid = dateRe.test(value);
2639 }
2640 } else if ('timepicker' === $field.attr('type')) {
2641 isValid = self.validateTime(value, $field.data('time-format'));
2642 }
2643
2644 if (!isValid) {
2645 $field.closest('.hustle-field').addClass('hustle-field-error');
2646 errors.push($field.data('validation-error'));
2647 }
2648 });
2649 return errors;
2650 },
2651 validateTime: function validateTime(time, format) {
2652 var re = /^(\d{1,2}):(\d{2})(:00)?( [apAP][mM])?$/,
2653 regs = time.match(re);
2654
2655 if (regs) {
2656 if ('HH:mm' === format) {
2657 //24-hour time format
2658 if (23 < regs[1]) {
2659 return false;
2660 }
2661
2662 if (59 < regs[2]) {
2663 return false;
2664 }
2665
2666 return true;
2667 } //12-hour time format with am/pm
2668
2669
2670 if (1 > regs[1] || 12 < regs[1]) {
2671 return false;
2672 }
2673
2674 if (59 < regs[2]) {
2675 return false;
2676 }
2677
2678 if ('am' !== regs[4].toLowerCase().trim() && 'pm' !== regs[4].toLowerCase().trim()) {
2679 return false;
2680 }
2681
2682 return true;
2683 }
2684
2685 return false;
2686 },
2687 onInputChange: function onInputChange(e) {
2688 var $this = $(e.target);
2689 $this.closest('.hustle-field').removeClass('hustle-field-error');
2690 },
2691 stopPlayingAudioVideo: function stopPlayingAudioVideo() {
2692 this.$el.find('audio, video').trigger('pause');
2693 },
2694 clearRunningCompatInterval: function clearRunningCompatInterval() {
2695 if ('undefined' !== typeof this.waitEnewsletterResult) {
2696 // e-newsletter
2697 clearInterval(this.waitEnewsletterResult);
2698 }
2699 },
2700 ctaClicked: function ctaClicked(e) {
2701 var $this = $(e.target),
2702 submitDelay = this.convertToMicroseconds(this.data.settings.close_cta_time, this.data.settings.close_cta_unit);
2703
2704 if ('undefined' !== typeof Optin.ModuleLogConversion && this.isTrackingEnabled && !$this.hasClass('hustle-cta-close')) {
2705 var logCtaConversion = new Optin.ModuleLogConversion(),
2706 cta = 'undefined' !== $this.data('cta-type') ? $this.data('cta-type') : '',
2707 subType = 'undefined' !== this.$el.data('sub-type') ? this.$el.data('sub-type') : '';
2708 logCtaConversion.set('module_sub_type', subType);
2709 logCtaConversion.set('module_id', this.moduleId);
2710 logCtaConversion.set('cta', cta);
2711 logCtaConversion.save();
2712 }
2713
2714 this.maybeSetCookiesAfterCtaClick();
2715 this.maybeCloseAfterCtaClick($this, submitDelay);
2716 }
2717 });
2718 })(jQuery, document, window);
2719 // the semi-colon before function invocation is a safety net against concatenated
2720 // scripts and/or other plugins which may not be closed properly.
2721 // noinspection JSUnusedLocalSymbols
2722 (function ($) {
2723 'use strict';
2724
2725 Optin = window.Optin || {};
2726 Optin.Embedded = Optin.Module.extend({
2727 type: 'embedded',
2728
2729 /**
2730 * Overriding.
2731 * Embeds don't need to attach onClose actions
2732 * but we need to handle the screen resize for inline.
2733 */
2734 beforeListenForDisplay: function beforeListenForDisplay() {
2735 var container = this.el;
2736 $(window).on('resize', function () {
2737 HUI.inlineResize(container);
2738 });
2739 },
2740
2741 /**
2742 * Overriding.
2743 * Embeds don't have triggers so show right away.
2744 */
2745 displayOnTrigger: function displayOnTrigger() {
2746 this.display();
2747 },
2748 showModule: function showModule() {
2749 HUI.inlineResize(this.el);
2750 this.$el.trigger('hustle:module:beforeEmbedLoad', this.$el);
2751 HUI.inlineLoad(this.el);
2752 this.$el.trigger('hustle:module:afterEmbedLoad', this.$el);
2753 }
2754 });
2755 })(jQuery);
2756 /* global incOpt */
2757 // the semi-colon before function invocation is a safety net against concatenated
2758 // scripts and/or other plugins which may not be closed properly.
2759 // eslint-disable-next-line no-extra-semi
2760 ;
2761
2762 (function ($) {
2763 'use strict';
2764
2765 if (incOpt.is_upfront) {
2766 return;
2767 }
2768
2769 Optin = window.Optin || {};
2770 Optin.PopUp = Optin.Module.extend({
2771 type: 'popup',
2772 showModule: function showModule() {
2773 if ('0' === this.settings.allow_scroll_page) {
2774 $('html').addClass('hustle-no-scroll');
2775 this.$el.addClass('hustle-scroll-forbidden');
2776 }
2777
2778 var autohideDelay = 'false' === String(this.$el.data('close-delay')) ? false : this.$el.data('close-delay');
2779 this.$el.trigger('hustle:module:beforePopupLoad', this.$el);
2780 HUI.popupLoad(this.el, autohideDelay);
2781 this.$el.trigger('hustle:module:afterPopupLoad', this.$el);
2782 },
2783 close: function close() {
2784 var delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
2785 HUI.popupClose(this.$el, delay);
2786 }
2787 });
2788 })(jQuery);
2789 /* global incOpt */
2790 // the semi-colon before function invocation is a safety net against concatenated
2791 // scripts and/or other plugins which may not be closed properly.
2792 // eslint-disable-next-line no-extra-semi
2793 ;
2794
2795 (function ($) {
2796 'use strict';
2797
2798 if (incOpt.is_upfront) {
2799 return;
2800 }
2801
2802 Optin = window.Optin || {};
2803 Optin.SlideIn = Optin.Module.extend({
2804 type: 'slidein',
2805 showModule: function showModule() {
2806 var self = this,
2807 autohideDelay = 'false' === String(this.$el.data('close-delay')) ? false : this.$el.data('close-delay');
2808 HUI.slideinLayouts(this.$el);
2809 $(window).on('resize', function () {
2810 HUI.slideinLayouts(self.$el);
2811 });
2812 this.$el.trigger('hustle:module:beforeSlideInLoad', this.$el);
2813 HUI.slideinLoad(this.$el, autohideDelay);
2814 this.$el.trigger('hustle:module:afterSlideInLoad', this.$el);
2815 },
2816 close: function close() {
2817 var delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
2818 HUI.slideinClose(this.$el, delay);
2819 }
2820 });
2821 })(jQuery);
2822 /* global incOpt, PinUtils */
2823 // the semi-colon before function invocation is a safety net against concatenated
2824 // scripts and/or other plugins which may not be closed properly.
2825 // eslint-disable-next-line no-extra-semi
2826 ;
2827
2828 (function ($) {
2829 'use strict';
2830
2831 var Optin = window.Optin || {};
2832 Optin.SShare = Optin.Module.extend({
2833 type: 'social_sharing',
2834 beforeShowModule: _.noop,
2835 events: {
2836 'click .hustle-share-icon': 'iconClicked'
2837 },
2838
2839 /**
2840 * Overriding.
2841 * Embeds don't need to attach onClose actions
2842 * but they need to collect the networks' native counters.
2843 */
2844 beforeListenForDisplay: function beforeListenForDisplay() {
2845 this.collectNativeCounters();
2846 },
2847
2848 /**
2849 * Overriding.
2850 * Sshares don't have triggers so show right away.
2851 */
2852 handleDisplay: function handleDisplay() {
2853 this.beforeListenForDisplay();
2854 this.display();
2855 },
2856 showModule: function showModule() {
2857 var data = this.$el.data(),
2858 self = this;
2859
2860 if ('floating' === data.subType) {
2861 this.$el.trigger('hustle:module:beforeSshareLoad', this.$el);
2862 HUI.floatLoad(this.el);
2863 this.$el.trigger('hustle:module:afterSshareLoad', this.$el);
2864 $(window).on('resize', function () {
2865 return HUI.floatLoad(self.el);
2866 });
2867 } else {
2868 this.$el.trigger('hustle:module:beforeSshareLoad', this.$el);
2869 HUI.inlineLoad(this.el);
2870 this.$el.trigger('hustle:module:afterSshareLoad', this.$el);
2871 }
2872 },
2873 setOnInit: function setOnInit(opts) {
2874 if ('undefined' !== typeof opts.parent) {
2875 this.parent = opts.parent;
2876 }
2877 },
2878 // Overridding.
2879 shouldDisplay: function shouldDisplay() {
2880 return true;
2881 },
2882 iconClicked: function iconClicked(e) {
2883 var $icon = $(e.currentTarget),
2884 counter = $icon.data('counter'),
2885 linkType = $icon.data('link'); // Track the conversion if enabled.
2886
2887 if (this.isTrackingEnabled) {
2888 this.logConversion();
2889 } // Open a window with the network's native sharing endpoint if no custom url was provided.
2890
2891
2892 if ('native' === linkType) {
2893 e.preventDefault();
2894 this.openNativeSharingUrl($icon);
2895 } // Check what to do with the counter when the icon is clicked.
2896
2897
2898 if ('native' === counter) {
2899 // Show a check and don't increment the number.
2900 this.updateSocialCounter($icon, 'native');
2901 } else if ('click' === counter) {
2902 // Increment the counter number.
2903 this.updateSocialCounter($icon, 'click');
2904 }
2905 },
2906 logConversion: function logConversion() {
2907 if ('undefined' !== typeof Optin.ModuleLogConversion && this.isTrackingEnabled) {
2908 var logCtaConversion = new Optin.ModuleLogConversion(),
2909 subType = 'undefined' !== this.$el.data('sub-type') ? this.$el.data('sub-type') : '';
2910 logCtaConversion.set('module_sub_type', subType);
2911 logCtaConversion.set('module_id', this.moduleId);
2912 logCtaConversion.save();
2913 }
2914 },
2915 openNativeSharingUrl: function openNativeSharingUrl($icon) {
2916 var network = $icon.data('network');
2917
2918 if (network && 'undefined' !== typeof incOpt.native_share_enpoints[network]) {
2919 if ('pinterest' === network) {
2920 this.updateSocialCounter($icon, 'click');
2921 PinUtils.pinAny();
2922 } else {
2923 window.open(incOpt.native_share_enpoints[network], 'MsgWindow', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes');
2924 }
2925 }
2926 },
2927 updateSocialCounter: function updateSocialCounter($button, counterType) {
2928 var network = $button.data('network'),
2929 containerClass = '.hustle_module_id_' + this.$el.data('id');
2930
2931 if ('click' === counterType) {
2932 this.storeUpdatedClickCounter(network);
2933 setTimeout(function () {
2934 $(containerClass + ' a[data-network="' + network + '"]').not('a[data-counter="native"]').each(function () {
2935 var $counter = $(this).find('.hustle-counter');
2936
2937 if ($counter.length) {
2938 // Add one to the counter.
2939 var val = parseInt($counter.text()) + 1;
2940 $counter.text(val);
2941 }
2942 });
2943 }, 5000);
2944 } else {
2945 setTimeout(function () {
2946 $(containerClass + ' a[data-network="' + network + '"]').not('a[data-counter="click"]').each(function () {
2947 var $counter = $(this).find('.hustle-counter');
2948
2949 if ($counter.length) {
2950 // Add a checkmark icon.
2951 var val = '<i class="hustle-icon-check" aria-hidden="true"></i>';
2952 $counter.html(val);
2953 }
2954 });
2955 }, 5000);
2956 }
2957 },
2958 storeUpdatedClickCounter: function storeUpdatedClickCounter(network) {
2959 $.post({
2960 url: incOpt.ajaxurl,
2961 dataType: 'json',
2962 data: {
2963 action: 'hustle_sshare_click_counted',
2964 moduleId: this.moduleId,
2965 network: network
2966 }
2967 });
2968 },
2969 collectNativeCounters: function collectNativeCounters() {
2970 var $nativeCounterNetworks = this.$el.find('.hustle-share-icon[data-counter="native"]'); // Return if this module doesn't have native counters.
2971
2972 if (!$nativeCounterNetworks.length) {
2973 return;
2974 }
2975
2976 Optin.networksToRetrieve = Optin.networksToRetrieve || []; // Get all the networks with a native counters from this module.
2977
2978 $nativeCounterNetworks.each(function () {
2979 var network = $(this).data('network');
2980
2981 if (-1 === Optin.networksToRetrieve.indexOf(network)) {
2982 Optin.networksToRetrieve.push(network);
2983 }
2984 });
2985 }
2986 });
2987 })(jQuery);
2988 /* global incOpt, Modules */
2989 // the semi-colon before function invocation is a safety net against concatenated
2990 // scripts and/or other plugins which may not be closed properly.
2991 // eslint-disable-next-line no-extra-semi
2992 ;
2993
2994 (function ($) {
2995 'use strict';
2996
2997 if (incOpt.is_upfront) {
2998 return;
2999 }
3000
3001 $(document).ready(function () {
3002 _.each(Modules, function (module) {
3003 var moduleId = module.module_id;
3004 module.el = '.hustle_module_id_' + moduleId;
3005
3006 if ('popup' === module.module_type) {
3007 Hustle.setModule(moduleId, new Optin.PopUp(module));
3008 } else if ('slidein' === module.module_type) {
3009 Hustle.setModule(moduleId, new Optin.SlideIn(module));
3010 } else if ('embedded' === module.module_type) {
3011 var embedsViews = [];
3012 var embededs = $(module.el);
3013
3014 if (embededs.length) {
3015 embededs.each(function () {
3016 module.el = this;
3017 embedsViews.push(new Optin.Embedded(module));
3018 });
3019 Hustle.setModule(moduleId, embedsViews);
3020 } else {
3021 //lazy load this so that modules loaded by ajax
3022 //can run properly
3023 setTimeout(function () {
3024 embededs = $(module.el);
3025 embededs.each(function () {
3026 module.el = this;
3027 embedsViews.push(new Optin.Embedded(module));
3028 });
3029 Hustle.setModule(moduleId, embedsViews);
3030 }, incOpt.script_delay);
3031 }
3032 } else if ('social_sharing' === module.module_type) {
3033 var sshares = $(module.el),
3034 sshareViews = [];
3035 sshares.each(function () {
3036 module.el = this;
3037 sshareViews.push(new Optin.SShare(module));
3038 });
3039 Hustle.setModule(moduleId, sshareViews);
3040 }
3041 }); // Initialize HUI handler for form's inputs.
3042
3043
3044 HUI.inputFilled();
3045 $(document).trigger('hustleInitialized');
3046 Optin.updateSshareNetworks();
3047 });
3048 })(jQuery);