Fixed bug #15354: htmlArea RTE: Remove link option not enabled on double-click in...
authorStanislas Rolland <typo3@sjbr.ca>
Sun, 29 Aug 2010 20:09:59 +0000 (20:09 +0000)
committerStanislas Rolland <typo3@sjbr.ca>
Sun, 29 Aug 2010 20:09:59 +0000 (20:09 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/branches/TYPO3_4-4@8735 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
typo3/sysext/rtehtmlarea/ChangeLog
typo3/sysext/rtehtmlarea/htmlarea/plugins/TYPO3Link/typo3link.js

index 81bba0b..d96d205 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2010-08-29  Stanislas Rolland  <typo3@sjbr.ca>
+
+       * Fixed bug #15354: htmlArea RTE: Remove link option not enabled on double-click in Firefox
+
 2010-08-29  Francois Suter  <francois@typo3.org>
 
        * Fixed bug #14143: count_menuItems not working correctly (thanks to Frederic Gaus)
index 68bfc32..c417c2b 100644 (file)
@@ -1,3 +1,7 @@
+2010-08-29  Stanislas Rolland  <typo3@sjbr.ca>
+
+       * Fixed bug #15354: htmlArea RTE: Remove link option not enabled on double-click in Firefox
+
 2010-08-28  Stanislas Rolland  <typo3@sjbr.ca>
 
        * Updated htmlArea RTE version to 2.0.4
index 8968e8a..64bca15 100644 (file)
@@ -419,19 +419,37 @@ HTMLArea.TYPO3Link = HTMLArea.Plugin.extend({
         * This function gets called when the toolbar is updated
         */
        onUpdateToolbar: function (button, mode, selectionEmpty, ancestors) {
-               if (mode === 'wysiwyg' && this.editor.isEditable() && button.itemId === 'CreateLink') {
-                       button.setDisabled(selectionEmpty && !button.isInContext(mode, selectionEmpty, ancestors));
-                       if (!button.disabled) {
-                               var node = this.editor.getParentElement();
-                               var el = HTMLArea.getElementObject(node, 'a');
-                               if (el != null && /^a$/i.test(el.nodeName)) {
-                                       node = el;
-                               }
-                               if (node != null && /^a$/i.test(node.nodeName)) {
-                                       button.setTooltip({ title: this.localize('Modify link') });
-                               } else {
-                                       button.setTooltip({ title: this.localize('Insert link') });
-                               }
+               if (mode === 'wysiwyg' && this.editor.isEditable()) {
+                       switch (button.itemId) {
+                               case 'CreateLink':
+                                       button.setDisabled(selectionEmpty && !button.isInContext(mode, selectionEmpty, ancestors));
+                                       if (!button.disabled) {
+                                               var node = this.editor.getParentElement();
+                                               var el = HTMLArea.getElementObject(node, 'a');
+                                               if (el != null && /^a$/i.test(el.nodeName)) {
+                                                       node = el;
+                                               }
+                                               if (node != null && /^a$/i.test(node.nodeName)) {
+                                                       button.setTooltip({ title: this.localize('Modify link') });
+                                               } else {
+                                                       button.setTooltip({ title: this.localize('Insert link') });
+                                               }
+                                       }
+                                       break;
+                               case 'UnLink':
+                                       var link = false;
+                                               // Let's see if a link was double-clicked in Firefox
+                                       if (Ext.isGecko && !selectionEmpty) {
+                                               var range = this.editor._createRange(this.editor._getSelection());
+                                               if (range.startContainer.nodeType == 1 && range.startContainer == range.endContainer && (range.endOffset - range.startOffset == 1)) {
+                                                       var node = range.startContainer.childNodes[range.startOffset];
+                                                       if (node && /^a$/i.test(node.nodeName) && node.textContent == range.toString()) {
+                                                               link = true;
+                                                       }
+                                               }
+                                       }
+                                       button.setDisabled(!link && !button.isInContext(mode, selectionEmpty, ancestors));
+                                       break;
                        }
                }
        }