diff --git a/common/js/common.js b/common/js/common.js
index 75f86ed23..982fcea53 100644
--- a/common/js/common.js
+++ b/common/js/common.js
@@ -811,7 +811,7 @@ $(function() {
}
}
});
- $('body').on('click', 'a[target]', function(event) {
+ $(document).on('click', 'a[target]', function(event) {
const $this = $(this);
const href = String($this.attr('href')).trim();
const target = String($this.attr('target')).trim();
@@ -831,47 +831,6 @@ $(function() {
}
});
- /**
- * Display any pending alert messages
- */
- if(Cookies.get('rhymix_alert_message')) {
- rhymix_alert(Cookies.get('rhymix_alert_message'), null, Cookies.get('rhymix_alert_delay'));
- Cookies.remove('rhymix_alert_message', { path: '/' });
- Cookies.remove('rhymix_alert_delay', { path: '/' });
- }
- $('#rhymix_alert').on('click', rhymix_alert_close);
-
- /**
- * Intercept form submission and handle them with AJAX
- */
- $(document).on('submit', 'form.rx_ajax', function(event) {
- if (!$(this).attr('target')) {
- event.preventDefault();
- Rhymix.ajaxForm(this);
- }
- });
-
- /**
- * Editor preview replacement
- */
- $('.editable_preview').addClass('rhymix_content xe_content').attr('tabindex', 0);
- $('.editable_preview').on('click', function() {
- var input = $(this).siblings('.editable_preview_content');
- if (input.size()) {
- $(this).off('click').off('focus').hide();
- input = input.first();
- if (input.attr('type') !== 'hidden') {
- input.hide();
- }
- var iframe = $('');
- iframe.attr('src', current_url.setQuery('module', 'editor').setQuery('act', 'dispEditorFrame').setQuery('parent_input_id', input.attr('id')).replace(/^https?:/, ''));
- iframe.insertAfter(input);
- }
- });
- $('.editable_preview').on('focus', function() {
- $(this).triggerHandler('click');
- });
-
/**
* Enforce max filesize on file uploaeds
*/
@@ -891,17 +850,26 @@ $(function() {
}
});
+ /**
+ * Intercept form submission and handle them with AJAX
+ */
+ $(document).on('submit', 'form.rx_ajax', function(event) {
+ if (!$(this).attr('target')) {
+ event.preventDefault();
+ Rhymix.ajaxForm(this);
+ }
+ });
+
/**
* Prevent repeated click on submit button
*/
- $('input[type="submit"],button[type="submit"]').on('click', function(e) {
- const target = $(e.currentTarget);
+ $(document).on('click', 'input[type="submit"],button[type="submit"]', function(e) {
const timeout = 3000;
setTimeout(function() {
- target.prop('disabled', true);
- }, 0);
+ $(this).prop('disabled', true);
+ }, 100);
setTimeout(function() {
- target.prop('disabled', false);
+ $(this).prop('disabled', false);
}, timeout);
});
@@ -977,7 +945,7 @@ $(function() {
/**
* Create popup windows automatically for _xe_popup links
*/
- $('body').on('click', 'a._xe_popup', function(e) {
+ $(document).on('click', 'a._xe_popup', function(e) {
var $this = $(this);
var name = $this.attr('name');
var href = $this.attr('href');
@@ -988,6 +956,27 @@ $(function() {
winopen(href, name, 'left=10,top=10,width=10,height=10,resizable=no,scrollbars=no,toolbars=no');
});
+ /**
+ * Editor preview replacement
+ */
+ $('.editable_preview').addClass('rhymix_content xe_content').attr('tabindex', 0);
+ $('.editable_preview').on('click', function() {
+ var input = $(this).siblings('.editable_preview_content');
+ if (input.size()) {
+ $(this).off('click').off('focus').hide();
+ input = input.first();
+ if (input.attr('type') !== 'hidden') {
+ input.hide();
+ }
+ var iframe = $('');
+ iframe.attr('src', current_url.setQuery('module', 'editor').setQuery('act', 'dispEditorFrame').setQuery('parent_input_id', input.attr('id')).replace(/^https?:/, ''));
+ iframe.insertAfter(input);
+ }
+ });
+ $('.editable_preview').on('focus', function() {
+ $(this).triggerHandler('click');
+ });
+
/**
* Datepicker default settings
*/
@@ -997,6 +986,16 @@ $(function() {
});
}
+ /**
+ * Display any pending alert messages
+ */
+ if(Cookies.get('rhymix_alert_message')) {
+ rhymix_alert(Cookies.get('rhymix_alert_message'), null, Cookies.get('rhymix_alert_delay'));
+ Cookies.remove('rhymix_alert_message', { path: '/' });
+ Cookies.remove('rhymix_alert_delay', { path: '/' });
+ }
+ $('#rhymix_alert').on('click', rhymix_alert_close);
+
});
/**