* Feature #6712: htmlArea RTE: make hotkeys configurable in PageTSConfig
authorStanislas Rolland <typo3@sjbr.ca>
Wed, 14 Nov 2007 17:04:02 +0000 (17:04 +0000)
committerStanislas Rolland <typo3@sjbr.ca>
Wed, 14 Nov 2007 17:04:02 +0000 (17:04 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@2706 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
typo3/sysext/rtehtmlarea/ChangeLog
typo3/sysext/rtehtmlarea/htmlarea/htmlarea.js
typo3/sysext/rtehtmlarea/htmlarea/plugins/DefaultInline/default-inline.js

index 56b6bfb..a283a53 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2007-11-14  Stanislas Rolland  <stanislas.rolland@fructifor.ca>
+
+       * Feature #6712: htmlArea RTE: make hotkeys configurable in PageTSConfig
+
 2007-11-14  Ingmar Schlecht  <ingmar@typo3.org>
 
        * Cleanup-up to prior commit #529: "TypoScript help" module
index bd7c653..efdaeb7 100644 (file)
@@ -1,3 +1,7 @@
+2007-11-14  Stanislas Rolland  <stanislas.rolland@fructifor.ca>
+
+       * Feature #6712: htmlArea RTE: make hotkeys configurable in PageTSConfig
+
 2007-11-13  Stanislas Rolland  <stanislas.rolland@fructifor.ca>
 
        * Feature #6705: htmlArea RTE: Display all classes of an element in the statusbar
index e57c40b..43b9f65 100644 (file)
@@ -3365,15 +3365,26 @@ HTMLArea.plugin = HTMLArea.Base.extend({
         *                                      context         : will be disabled if not inside one of listed elements
         *                                      hide            : hide in menu and show only in context menu?
         *                                      selection       : will be disabled if there is no selection?
+        *                                      hotkey          : hotkey character
         *
         * @return      boolean         true if the button was successfully registered
         */
        registerButton : function (buttonConfiguration) {
                if (this.isButtonInToolbar(buttonConfiguration.id)) {
                        if ((typeof(buttonConfiguration.action) === "string") && (typeof(this[buttonConfiguration.action]) === "function")) {
+                               var hotKeyAction = buttonConfiguration.action;
                                var actionFunctionReference = this.makeFunctionReference(buttonConfiguration.action);
                                buttonConfiguration.action = actionFunctionReference;
-                               return this.editorConfiguration.registerButton(buttonConfiguration);
+                               if (this.editorConfiguration.registerButton(buttonConfiguration)) {
+                                       if (buttonConfiguration.hotKey) {
+                                               var hotKeyConfiguration = {
+                                                       id      : buttonConfiguration.hotKey,
+                                                       action  : hotKeyAction
+                                               };
+                                               return this.registerHotKey(hotKeyConfiguration);
+                                       }
+                                       return true;
+                               }
                        } else {
                                this.appendToLog("registerButton", "Function " + buttonConfiguration.action + " was not defined when registering button " + buttonConfiguration.id);
                        }
@@ -3443,6 +3454,7 @@ HTMLArea.plugin = HTMLArea.Base.extend({
                        return this.editorConfiguration.registerHotKey(hotKeyConfiguration);
                } else {
                        this.appendToLog("registerHotKey", "Function " + hotKeyConfiguration.action + " was not defined when registering hotkey " + hotKeyConfiguration.id);
+                       return false;
                }
        },
        
index 0b4c98b..bf795bf 100644 (file)
@@ -67,31 +67,21 @@ DefaultInline = HTMLArea.plugin.extend({
                                tooltip         : this.localize(buttonId + "-Tooltip"),
                                textMode        : false,
                                action          : "onButtonPress",
-                               context         : button[1]
+                               context         : button[1],
+                               hotKey          : (this.editorConfiguration.buttons[buttonId.toLowerCase()]?this.editorConfiguration.buttons[buttonId.toLowerCase()].hotKey:null)
                        };
                        this.registerButton(buttonConfiguration);
                }
                
-               /*
-                * Registering the hotkeys
-                */
-               for (var hotKey in DefaultInline.hotKeyList) {
-                       if (DefaultInline.hotKeyList.hasOwnProperty(hotKey)) {
-                               var hotKeyConfiguration = {
-                                       id      : hotKey,
-                                       action  : "onHotKey"
-                               };
-                       this.registerHotKey(hotKeyConfiguration);
-                       }
-               }
-               
                return true;
         },
         
        /*
         * This function gets called when some inline element button was pressed.
         */
-       onButtonPress : function (editor, buttonId, UI, param) {
+       onButtonPress : function (editor, id, UI, param) {
+                       // Could be a button or its hotkey
+               var buttonId = DefaultInline.hotKeyList[id]?DefaultInline.hotKeyList[id]:id;
                editor.focusEditor();
                try {
                        editor._doc.execCommand(buttonId, UI, param);
@@ -104,21 +94,6 @@ DefaultInline = HTMLArea.plugin.extend({
        },
        
        /*
-        * This function gets called when some hot key is pressed
-        */
-       onHotKey : function(editor, key) {
-               if (DefaultInline.hotKeyList[key] && this.editor._toolbarObjects[DefaultInline.hotKeyList[key]]) {
-                       var toolbarObject = this.editor._toolbarObjects[DefaultInline.hotKeyList[key]];
-                       var toolbarHTMLObject = document.getElementById(toolbarObject.elementId);
-                       if (!toolbarHTMLObject.disabled) {
-                               return this.onButtonPress(this.editor, DefaultInline.hotKeyList[key]);
-                       }
-               } else {
-                       return true;
-               }
-       },
-       
-       /*
         * This function gets called when the toolbar is updated
         */
        onUpdateToolbar : function () {