­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ var WPML_String_Translation = WPML_String_Translation || {}; WPML_String_Translation.ModalForm = function($trigger, dialog, settings) { this.$trigger = $trigger; this.dialog = dialog; this.settings = settings || {}; this.form = dialog.find('form'); this.rmConfirmMsgTimeout = null; if(typeof this.settings.onSave === 'undefined') { this.settings.onSave = function() {}; } this.create_dialog(); }; WPML_String_Translation.ModalForm.prototype = { create_dialog: function () { var that = this; var dialogSettings = { autoOpen: false, width: 'auto', modal: true, buttons: [ { class: 'wpml-st-cancel-button', text: that.dialog.attr('data-cancelButtonTitle'), click: function() { that.rmConfirmMsg.call(that); jQuery( this ).dialog( 'close' ); } }, { text: that.dialog.attr('data-saveButtonTitle'), class: 'button-primary js-wpml-st-apply-button', click: function() { that.rmConfirmMsg.call(that); that.settings.onSave(); }, } ], create: function() { jQuery(this).css('maxWidth', '650px'); }, }; if(this.settings.width) { dialogSettings.width = this.settings.width; } this.dialog.dialog(dialogSettings); this.dialog.on('click', '.checkbox-label', function(event) { jQuery(this).parent().find('input[type="checkbox"]').trigger('click'); }); this.$trigger.on('click', {'dialog' : this.dialog}, function(event) { event.preventDefault(); event.data.dialog.dialog('open'); event.data.dialog.closest('.ui-dialog').addClass('wpml-st-modal-form'); // We need to set title as block element to put inside block element with icon on new line, so should replace span with div. var titleEl = event.data.dialog.closest('.ui-dialog').find('.ui-dialog-title')[0]; titleEl.outerHTML = titleEl.outerHTML.replace(/'; this.dialog.closest('.wpml-st-modal-form').find('.ui-dialog-buttonset').append(jQuery(html)); this.rmConfirmMsgTimeout = setTimeout(function() { self.rmConfirmMsg.call(self); }, 3000); }, rmConfirmMsg: function() { clearTimeout(this.rmConfirmMsgTimeout); this.dialog.closest('.wpml-st-modal-form').find('.icl_ajx_response').remove(); }, };