diff options
author | Aleksander Machniak <alec@alec.pl> | 2014-04-29 19:21:19 +0200 |
---|---|---|
committer | Aleksander Machniak <alec@alec.pl> | 2014-04-29 19:24:28 +0200 |
commit | 50fee948fd6dda6774c3e95469023d15add0d9ea (patch) | |
tree | 94644a97c8bb0a77eb23adea6d114261dcbfd0cd | |
parent | 08953a46d95e0165f0bccf9391254ca03195e0ec (diff) |
Fix redundant warning when switching from html to text in empty editor (#1489819)
We also skip ajax request in such a case. We assume "empty" here means "with no text excluding whitespace".
Conflicts:
program/js/app.js
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | program/js/app.js | 23 |
2 files changed, 14 insertions, 10 deletions
@@ -19,6 +19,7 @@ CHANGELOG Roundcube Webmail - Fix identities_level=4 handling in new_user_dialog plugin (#1489840) - Fix various db_prefix issues (#1489839) - Fix too small length of users.preferences column data type on MySQL +- Fix redundant warning when switching from html to text in empty editor (#1489819) RELEASE 1.0.0 ------------- diff --git a/program/js/app.js b/program/js/app.js index eb646aaff..beb054bf2 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -3389,17 +3389,8 @@ function rcube_webmail() $(tinyMCE.get(props.id).getBody()).css('font-family', rcmail.env.default_font); }, 500); } - else { - var thisMCE = tinyMCE.get(props.id), existingHtml; - - if (existingHtml = thisMCE.getContent()) { - if (!confirm(this.get_label('editorwarning'))) { - return false; - } - this.html2plain(existingHtml, props.id); - } + else if (this.html2plain(tinyMCE.get(props.id).getContent(), props.id)) tinyMCE.execCommand('mceRemoveControl', false, props.id); - } return true; }; @@ -6743,6 +6734,16 @@ function rcube_webmail() this.html2plain = function(htmlText, id) { + // warn the user (if converted content is not empty) + if (!htmlText || !(htmlText.replace(/<[^>]+>| |\s/g, '')).length) { + // without setTimeout() here, textarea is filled with initial (onload) content + setTimeout(function() { $('#'+id).val(''); }, 50); + return true; + } + + if (!confirm(this.get_label('editorwarning'))) + return false; + var rcmail = this, url = '?_task=utils&_action=html2text', lock = this.set_busy(true, 'converting'); @@ -6753,6 +6754,8 @@ function rcube_webmail() error: function(o, status, err) { rcmail.http_error(o, status, err, lock); }, success: function(data) { rcmail.set_busy(false, null, lock); $('#'+id).val(data); rcmail.log(data); } }); + + return true; }; this.plain2html = function(plain, id) |