Follow-up to bug #15354: htmlArea RTE: Remove link option not enabled on double-click...
authorStanislas Rolland <typo3@sjbr.ca>
Mon, 30 Aug 2010 00:58:58 +0000 (00:58 +0000)
committerStanislas Rolland <typo3@sjbr.ca>
Mon, 30 Aug 2010 00:58:58 +0000 (00:58 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/branches/TYPO3_4-4@8737 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
typo3/sysext/rtehtmlarea/ChangeLog
typo3/sysext/rtehtmlarea/htmlarea/plugins/DefaultLink/default-link.js

index d96d205..205ad69 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +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
+       * Follow-up to bug #15354: htmlArea RTE: Remove link option not enabled on double-click in Firefox
 
 2010-08-29  Francois Suter  <francois@typo3.org>
 
index c417c2b..f409f3f 100644 (file)
@@ -1,6 +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
+       * Follow-up to bug #15354: htmlArea RTE: Remove link option not enabled on double-click in Firefox
 
 2010-08-28  Stanislas Rolland  <typo3@sjbr.ca>
 
index f040cdc..33847b0 100644 (file)
@@ -381,19 +381,37 @@ HTMLArea.DefaultLink = 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;
                        }
                }
        }