@@ -159,41 +159,44 @@ function tawk_to_render_widget_iframe($base_url, $iframe_url, $widget=array(), $
159
159
</div>
160
160
</div>
161
161
<script type="text/javascript">
162
- var currentHost = window.location.protocol + "//" + window.location.host;
163
- var url = "<?php echo $ iframe_url ; ?> &parentDomain=" + currentHost;
162
+ var currentHost = window.location.protocol + "//" + window.location.host;
163
+ var url = "<?php echo $ iframe_url ; ?> &pltf=drupal&pltfv=7 &parentDomain=" + currentHost;
164
164
165
- jQuery("#tawkIframe").attr("src", url);
165
+ jQuery("#tawkIframe").attr("src", url);
166
166
167
- var iframe = jQuery("#tawk_widget_customization")[0];
167
+ var iframe = jQuery("#tawk_widget_customization")[0];
168
168
169
- window.addEventListener("message", function(e) {
170
- if(e.origin === "<?php echo $ base_url ; ?> ") {
169
+ window.addEventListener("message", function(e) {
170
+ if(e.origin === "<?php echo $ base_url ; ?> ") {
171
+ if(e.data.action === "setWidget") {
172
+ setWidget(e);
173
+ }
171
174
172
- if(e.data.action === "setWidget ") {
173
- setWidget (e);
174
- }
175
+ if(e.data.action === "removeWidget ") {
176
+ removeWidget (e);
177
+ }
175
178
176
- if(e.data.action === "removeWidget" ) {
177
- removeWidget(e );
178
- }
179
- }
180
- });
179
+ if(e.data.action === 'reloadHeight' ) {
180
+ reloadIframeHeight(e.data.height );
181
+ }
182
+ }
183
+ });
181
184
182
- function setWidget(e) {
185
+ function setWidget(e) {
183
186
jQuery.post("/admin/config/tawk/setwidget", {
184
- pageId : e.data.pageId,
185
- widgetId : e.data.widgetId
186
- }, function(r) {
187
- if(r.success) {
188
- $('input[name="page_id"]').val(e.data.pageId);
189
- $('input[name="widget_id"]').val(e.data.widgetId);
190
- $('#widget_already_set').hide();
191
- e.source.postMessage({action: "setDone"}, "<?php echo $ base_url ; ?> ");
192
- } else {
193
- e.source.postMessage({action: "setFail"}, "<?php echo $ base_url ; ?> ");
194
- }
195
- });
196
- }
187
+ pageId : e.data.pageId,
188
+ widgetId : e.data.widgetId
189
+ }, function(r) {
190
+ if(r.success) {
191
+ $('input[name="page_id"]').val(e.data.pageId);
192
+ $('input[name="widget_id"]').val(e.data.widgetId);
193
+ $('#widget_already_set').hide();
194
+ e.source.postMessage({action: "setDone"}, "<?php echo $ base_url ; ?> ");
195
+ } else {
196
+ e.source.postMessage({action: "setFail"}, "<?php echo $ base_url ; ?> ");
197
+ }
198
+ });
199
+ }
197
200
198
201
function removeWidget(e) {
199
202
jQuery.post("/admin/config/tawk/removewidget", function(r) {
@@ -208,42 +211,55 @@ function tawk_to_render_widget_iframe($base_url, $iframe_url, $widget=array(), $
208
211
});
209
212
}
210
213
211
- jQuery(document).ready(function() {
212
- if(jQuery("#always_display").prop("checked")){
213
- jQuery('.show_specific').prop('disabled', true);
214
- } else {
215
- jQuery('.hide_specific').prop('disabled', true);
214
+ function reloadIframeHeight(height) {
215
+ if (!height) {
216
+ return;
217
+ }
218
+
219
+ var iframe = jQuery('#tawkIframe');
220
+ if (height === iframe.height()) {
221
+ return;
222
+ }
223
+
224
+ iframe.height(height);
216
225
}
217
226
218
- jQuery("#always_display").change(function() {
219
- if(this.checked){
220
- jQuery('.hide_specific').prop('disabled', false);
227
+ jQuery(document).ready(function() {
228
+ if(jQuery("#always_display").prop("checked")){
221
229
jQuery('.show_specific').prop('disabled', true);
222
230
} else {
223
231
jQuery('.hide_specific').prop('disabled', true);
224
- jQuery('.show_specific').prop('disabled', false);
225
232
}
226
- });
227
233
228
- // process the form
229
- jQuery('#module_form').submit(function(event) {
230
- $path = "/admin/config/tawk/setoptions";
231
- jQuery.post($path, {
232
- action : 'set_visibility',
233
- ajax : true,
234
- page_id : jQuery('input[name="page_id"]').val(),
235
- widget_id : jQuery('input[name="widget_id"]').val(),
236
- options : jQuery(this).serialize()
237
- }, function(r) {
238
- if(r.success) {
239
- $('#optionsSuccessMessage').toggle().delay(3000).fadeOut();
234
+ jQuery("#always_display").change(function() {
235
+ if(this.checked){
236
+ jQuery('.hide_specific').prop('disabled', false);
237
+ jQuery('.show_specific').prop('disabled', true);
238
+ } else {
239
+ jQuery('.hide_specific').prop('disabled', true);
240
+ jQuery('.show_specific').prop('disabled', false);
240
241
}
241
242
});
242
243
243
- // stop the form from submitting the normal way and refreshing the page
244
- event.preventDefault();
244
+ // process the form
245
+ jQuery('#module_form').submit(function(event) {
246
+ $path = "/admin/config/tawk/setoptions";
247
+ jQuery.post($path, {
248
+ action : 'set_visibility',
249
+ ajax : true,
250
+ page_id : jQuery('input[name="page_id"]').val(),
251
+ widget_id : jQuery('input[name="widget_id"]').val(),
252
+ options : jQuery(this).serialize()
253
+ }, function(r) {
254
+ if(r.success) {
255
+ $('#optionsSuccessMessage').toggle().delay(3000).fadeOut();
256
+ }
257
+ });
258
+
259
+ // stop the form from submitting the normal way and refreshing the page
260
+ event.preventDefault();
261
+ });
245
262
});
246
- });
247
263
</script>
248
264
<?php
249
265
$ markup = ob_get_contents ();
0 commit comments