Преглед изворни кода

#1355 TinyMCE isn't properly removed sometimes

Alex Trofimov пре 8 година
родитељ
комит
78285a305c
4 измењених фајлова са 24 додато и 4 уклоњено
  1. 14 0
      inc/js/editor.tinymce.js
  2. 3 0
      inc/js/functions.js
  3. 4 0
      modules/boonex/froala/js/editor.js
  4. 3 4
      studio/js/builder_page.js

+ 14 - 0
inc/js/editor.tinymce.js

@@ -72,4 +72,18 @@ function bx_editor_get_htmleditable (sEditorSelector)
     return $(eEditor.dom.doc).find('body').get(0);
 }
 
+function bx_editor_remove_all (oElement) 
+{
+    if ('undefined' == typeof(oElement))
+        oElement = window;
+    oElement = $(oElement);
+
+    if ('undefined' == typeof(tinymce) || !tinymce.editors.length)
+        return;
+    $.each(tinymce.editors, function () {
+        if ($(this.getElement()).parents().filter(oElement).length)
+            this.remove();
+    });
+}
+
 /** @} */

+ 3 - 0
inc/js/functions.js

@@ -31,6 +31,9 @@ function processJsonData(oData) {
 	    	else 
 	    		oPopup = $(oData.popup);
 
+            if ('undefined' !== typeof(bx_editor_remove_all))
+                bx_editor_remove_all($('#' + oPopup.attr('id')));
+            
 	    	$('#' + oPopup.attr('id')).remove();
 	        oPopup.hide().prependTo('body').bxProcessHtml().dolPopup(oOptions);
 	    }

+ 4 - 0
modules/boonex/froala/js/editor.js

@@ -65,4 +65,8 @@ function bx_editor_get_htmleditable (sEditorSelector)
     return $(sEditorSelector).data('froala.editor').el;
 }
 
+function bx_editor_remove_all (oElement) 
+{
+}
+
 /** @} */

+ 3 - 4
studio/js/builder_page.js

@@ -197,10 +197,9 @@ BxDolStudioBuilderPage.prototype.onEditBlock = function(oData) {
 };
 
 BxDolStudioBuilderPage.prototype.onEditBlockCancel = function(oButton) {
-	var oTextarea = $(oButton).parents('form:first').find('textarea.bx-form-input-html');
-	if(oTextarea.length > 0 && typeof tinymce == 'object') {
-		oTextarea.tinymce().remove();
-	}
+
+    if ('undefined' !== typeof(bx_editor_remove_all))
+        bx_editor_remove_all($(oButton).parents('form:first'));
 
 	$('.bx-popup-applied:visible').dolPopupHide();
 };