* Added feature #8791 (revisited): Let htmlArea RTE context menu use the RTE API
authorStanislas Rolland <typo3@sjbr.ca>
Sun, 29 Jun 2008 15:26:04 +0000 (15:26 +0000)
committerStanislas Rolland <typo3@sjbr.ca>
Sun, 29 Jun 2008 15:26:04 +0000 (15:26 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@3851 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
typo3/sysext/rtehtmlarea/ChangeLog
typo3/sysext/rtehtmlarea/htmlarea/plugins/ContextMenu/context-menu.js

index 1d871fe..c3ae929 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2008-06-29  Stanislas Rolland  <typo3@sjbr.ca>
+
+       * Added feature #8791 (revisited): Let htmlArea RTE context menu use the RTE API
+
 2008-06-27  Stanislas Rolland  <typo3@sjbr.ca>
 
        * Fixed bug 8314: rtehtmlarea: Argument 1 passed to t3lib_div::array_merge_recursive_overrule() must be an array, null given
index 177c483..a4f4332 100644 (file)
@@ -1,3 +1,7 @@
+2008-06-29  Stanislas Rolland  <typo3@sjbr.ca>
+
+       * Added feature #8791 (revisited): Let htmlArea RTE context menu use the RTE API
+
 2008-06-27  Stanislas Rolland  <typo3@sjbr.ca>
 
        * Fixed bug 8314: rtehtmlarea: Argument 1 passed to t3lib_div::array_merge_recursive_overrule() must be an array, null given
index cd51e1e..a1242b2 100644 (file)
@@ -179,7 +179,7 @@ ContextMenu = HTMLArea.Plugin.extend({
                        }
                        this.currentMenu = list;
                        this.timeStamp = (new Date()).getTime();
-                       this.eventHandlers["documentClick"] = ContextMenu.documentClickHandler(this);
+                       this.eventHandlers["documentClick"] = this.makeFunctionReference("documentClickHandler");
                        HTMLArea._addEvent((HTMLArea.is_ie ? document.body : document), "mousedown", this.eventHandlers["documentClick"]);
                        HTMLArea._addEvent((HTMLArea.is_ie ? editor._doc.body : editor._doc), "mousedown", this.eventHandlers["documentClick"]);
                        if (this.keys.length > 0) {
@@ -287,15 +287,15 @@ ContextMenu = HTMLArea.Plugin.extend({
                                        if (menu.length) menu.push(null);
                                        menu.push(
                                                [this.localize("Modify Link"),
-                                                       ContextMenu.linkHandler(editor, link, "ModifyLink"),
+                                                       this.linkHandler(link, "ModifyLink"),
                                                        this.localize("Current URL is") + ': ' + link.href,
                                                        btnList["CreateLink"][1], "CreateLink"],
                                                [this.localize("Check Link"),
-                                                       ContextMenu.linkHandler(editor, link, "CheckLink"),
+                                                       this.linkHandler(link, "CheckLink"),
                                                        this.localize("Opens this link in a new window"),
                                                        null, null],
                                                [this.localize("Remove Link"),
-                                                       ContextMenu.linkHandler(editor, link, "RemoveLink"),
+                                                       this.linkHandler(link, "RemoveLink"),
                                                        this.localize("Unlink the current element"),
                                                        editor.imgURL("ed_unlink.gif"), "UnLink"]
                                        );
@@ -342,7 +342,7 @@ ContextMenu = HTMLArea.Plugin.extend({
                if (selection && !link) {
                        if (menu.length) menu.push(null);
                        menu.push([this.localize("Make link"),
-                               ContextMenu.linkHandler(editor, link, "MakeLink"),
+                               this.linkHandler(link, "MakeLink"),
                                this.localize("Create a link"),
                                btnList["CreateLink"][1],"CreateLink"]);
                }
@@ -360,7 +360,7 @@ ContextMenu = HTMLArea.Plugin.extend({
                        if (menu.length) menu.push(null);
                        menu.push(
                          [this.localize("Remove the") + " &lt;" + tmp.tagName.toLowerCase() + "&gt; " + this.localize("Element"),
-                               ContextMenu.deleteElementHandler(editor, tmp, table), this.localize("Remove this node from the document")],
+                               this.deleteElementHandler(tmp, table), this.localize("Remove this node from the document")],
                          [this.localize("Insert paragraph before"),
                                ContextMenu.blockElementsHandler(editor, tmp, "InsertParagraphBefore"), this.localize("Insert a paragraph before the current node"), null, "InsertParagraphBefore"],
                          [this.localize("Insert paragraph after"),
@@ -399,6 +399,69 @@ ContextMenu = HTMLArea.Plugin.extend({
                this.currentMenu = null;
                this.keys = [];
                if (HTMLArea.is_ie) this.iePopup.hide();
+       },
+       
+       linkHandler : function (link, opcode) {
+               var editor = this.editor;
+               var self = this;
+               switch (opcode) {
+                       case "MakeLink":
+                       case "ModifyLink":
+                               return (function() {
+                                       var obj = editor._toolbarObjects.CreateLink;
+                                       obj.cmd(editor, "CreateLink", link);
+                               });
+                       case "CheckLink":
+                               return (function() {
+                                       window.open(link.href);
+                               });
+                       case "RemoveLink":
+                               return (function() {
+                                       if (confirm(self.localize("Please confirm unlink") + "\n" +
+                                               self.localize("Link points to:") + " " + link.href)) {
+                                                       var obj = editor._toolbarObjects.CreateLink;
+                                                       obj.cmd(editor, "UnLink", link);
+                                       }
+                               });
+               }
+       },
+       
+       deleteElementHandler : function (tmp,table) {
+               var editor = this.editor;
+               var self = this;
+               return (function() {
+                       if(confirm(self.localize("Please confirm remove") + " " + tmp.tagName.toLowerCase())) {
+                               var el = tmp;
+                               var p = el.parentNode;
+                               p.removeChild(el);
+                               if(HTMLArea.is_gecko) {
+                                       if(p.tagName.toLowerCase() == "td" && !p.hasChildNodes()) p.appendChild(editor._doc.createElement("br"));
+                                       editor.forceRedraw();
+                                       editor.focusEditor();
+                                       editor.updateToolbar();
+                                       if(table) {
+                                               var save_collapse = table.style.borderCollapse;
+                                               table.style.borderCollapse = "collapse";
+                                               table.style.borderCollapse = "separate";
+                                               table.style.borderCollapse = save_collapse;
+                                       }
+                               }
+                       }
+               });
+       },
+       
+       documentClickHandler : function (ev) {
+               if (!ev) var ev = window.event;
+               if (!this.currentMenu) {
+                       alert(this.localize("How did you get here? (Please report!)"));
+                       return false;
+               }
+               var el = (ev.target) ? ev.target : ev.srcElement;
+               for (; el != null && el != this.currentMenu; el = el.parentNode);
+               if (el == null) {
+                       this.closeMenu();
+                       this.editor.updateToolbar();
+               }
        }
 });
 
@@ -421,29 +484,6 @@ ContextMenu.imageHandler = function(editor, currentTarget) {
        });
 };
 
-ContextMenu.linkHandler = function(editor, link, opcode) {
-       switch (opcode) {
-               case "MakeLink":
-               case "ModifyLink":
-                       return (function() {
-                               var obj = editor._toolbarObjects.CreateLink;
-                               obj.cmd(editor, "CreateLink", link);
-                       });
-               case "CheckLink":
-                       return (function() {
-                               window.open(link.href);
-                       });
-               case "RemoveLink":
-                       return (function() {
-                               if (confirm(ContextMenu.I18N["Please confirm unlink"] + "\n" +
-                                       ContextMenu.I18N["Link points to:"] + " " + link.href)) {
-                                               var obj = editor._toolbarObjects.CreateLink;
-                                               obj.cmd(editor, "UnLink", link);
-                               }
-                       });
-       }
-};
-
 ContextMenu.execCommandHandler = function(editor,opcode) {
        return (function() {
                editor.execCommand(opcode);
@@ -470,28 +510,6 @@ ContextMenu.blockElementsHandler = function(editor, currentTarget, buttonId) {
        });
 };
 
-ContextMenu.deleteElementHandler = function(editor,tmp,table) {
-       return (function() {
-               if(confirm(ContextMenu.I18N["Please confirm remove"] + " " + tmp.tagName.toLowerCase())) {
-                       var el = tmp;
-                       var p = el.parentNode;
-                       p.removeChild(el);
-                       if(HTMLArea.is_gecko) {
-                               if(p.tagName.toLowerCase() == "td" && !p.hasChildNodes()) p.appendChild(editor._doc.createElement("br"));
-                               editor.forceRedraw();
-                               editor.focusEditor();
-                               editor.updateToolbar();
-                               if(table) {
-                                       var save_collapse = table.style.borderCollapse;
-                                       table.style.borderCollapse = "collapse";
-                                       table.style.borderCollapse = "separate";
-                                       table.style.borderCollapse = save_collapse;
-                               }
-                       }
-               }
-       });
-};
-
 ContextMenu.mouseOverHandler = function(editor,item) {
        return (function() {
                item.className += " hover";
@@ -537,22 +555,6 @@ ContextMenu.activateHandler = function(item,instance) {
        });
 };
 
-ContextMenu.documentClickHandler = function(instance) {
-       return (function(ev) {
-               if (!ev) var ev = window.event;
-               if (!instance.currentMenu) {
-                       alert(ContextMenu.I18N["How did you get here? (Please report!)"]);
-                       return false;
-               }
-               var el = (ev.target) ? ev.target : ev.srcElement;
-               for (; el != null && el != instance.currentMenu; el = el.parentNode);
-               if (el == null) {
-                       instance.closeMenu();
-                       instance.editor.updateToolbar();
-               }
-       });
-};
-
 ContextMenu.keyPressHandler = function(instance) {
        return (function(ev) {
                if (!ev) var ev = window.event;