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 / preview.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
preview.debug.js
149 lines
1 /* global hustleVars */
2 (function ($) {
3 'use strict';
4
5 var hustlePreview = {
6 moduleId: null,
7 moduleData: null,
8 $module: null,
9 open: function open(id, type) {
10 var _this = this;
11
12 var previewData = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
13
14 // Abort if we don't have an ID.
15 if ('undefined' === typeof id) {
16 return;
17 }
18
19 var isInline = 'embedded' === type || 'social_sharing' === type,
20 $previewContainer = isInline ? $('#module-preview-inline-container') : $('#module-preview-container');
21 $.ajax({
22 url: hustleVars.ajaxurl,
23 type: 'POST',
24 data: {
25 action: 'hustle_preview_module',
26 id: id,
27 previewData: previewData
28 }
29 }).then(function (res) {
30 if (res.success) {
31 $previewContainer.html(res.data.html);
32 _this.$module = $previewContainer.find('.hustle-ui'); // Load select2 if this module has select fields.
33
34 if (_this.$module.find('.hustle-select2').length) {
35 HUI.select2();
36 } // If there's a timepicker.
37
38
39 if (_this.$module.find('.hustle-time').length) {
40 HUI.timepicker('.hustle-time');
41 } // If there's a datepicker.
42
43
44 if (_this.$module.find('.hustle-date').length) {
45 var _hustleVars = hustleVars,
46 strings = _hustleVars.days_and_months;
47 HUI.datepicker('.hustle-date', strings.days_full, strings.days_short, strings.days_min, strings.months_full, strings.months_short);
48 }
49
50 HUI.nonSharingSimulation(_this.$module);
51 HUI.inputFilled();
52
53 if (res.data.style) {
54 $previewContainer.append(res.data.style);
55 }
56
57 if (res.data.script) {
58 $previewContainer.append(res.data.script);
59 }
60
61 setTimeout(function () {
62 return HUI.maybeRenderRecaptcha(_this.$module);
63 }, 1000);
64 }
65
66 return {
67 id: id,
68 data: res.data.module
69 };
70 }, function () {// TODO: handle errors
71 }).then(function (_ref) {
72 var moduleId = _ref.id,
73 data = _ref.data;
74 _this.moduleId = moduleId;
75 _this.moduleData = data; // Display the module.
76
77 _this.showModule();
78 });
79 },
80 showModule: function showModule() {
81 var autohideDelay = '0' === String(this.$module.data('close-delay')) ? false : this.$module.data('close-delay');
82
83 if ('popup' === this.moduleData.module_type) {
84 HUI.popupLoad(this.$module[0], autohideDelay);
85 } else if ('slidein' === this.moduleData.module_type) {
86 HUI.slideinLayouts(this.$module[0]);
87 HUI.slideinLoad(this.$module[0], autohideDelay);
88 $(window).on('resize', function () {
89 if (this.$module) {
90 HUI.slideinLayouts(this.$module[0]);
91 }
92 });
93 } else {
94 HUI.inlineResize(this.$module[0]);
95 HUI.inlineLoad(this.$module[0]);
96 }
97 },
98 reloadModule: function reloadModule() {
99 var _this2 = this;
100
101 if (this.$module.is(':visible')) {
102 var delay = 0;
103
104 if ('popup' === this.moduleData.module_type) {
105 HUI.popupClose(this.$module[0], 0);
106 delay = 2000;
107 } else if ('slidein' === this.moduleData.module_type) {
108 HUI.slideinClose(this.$module[0], 0);
109 delay = 500;
110 } // TODO: replace this timeout by an event for
111 // when after the module is hidden when introduced into HUI.
112
113
114 setTimeout(function () {
115 return _this2.showModule();
116 }, delay);
117 } else {
118 this.showModule();
119 }
120 },
121 previewClosed: function previewClosed() {
122 this.$module = null;
123 $('#module-preview-container').empty();
124 $('#module-preview-inline-container').empty();
125 }
126 };
127 window.addEventListener('message', hustleReceiveMessage, false);
128
129 function hustleReceiveMessage(event) {
130 if (event.origin !== window.location.origin || event.source !== window.parent) {
131 return;
132 }
133
134 var action = event.data.action;
135
136 if ('open' === action) {
137 hustlePreview.open(event.data.moduleId, event.data.moduleType, event.data.previewData);
138 } else if ('close' === action) {
139 hustlePreview.previewClosed();
140 } else if ('reload' === action) {
141 hustlePreview.reloadModule();
142 }
143 } // Prevent links from doing anything on the preview page.
144
145
146 $('a:not(.hustle-button)').on('click', function (e) {
147 e.preventDefault();
148 });
149 })(jQuery);