[ADD] pad: new etherpad plugin to remove autofocus
authorHitesh Trivedi <htr@openerp.com>
Wed, 1 Oct 2014 10:47:43 +0000 (16:17 +0530)
committerRichard Mathot <rim@openerp.com>
Fri, 5 Dec 2014 13:45:06 +0000 (14:45 +0100)
In the form views where the pads are used, Etherpad-lite automatically
focus on the pad content, even if the user has already started to type
into another field.

This behavior is quite annoying for "quick changes", so we provide a
(very tiny) plugin for Etherpad-lite that will prevent this autofocus.

Detailed installation instructions are also included.

addons/pad/static/plugin/ep_disable_init_focus/README.md [new file with mode: 0644]
addons/pad/static/plugin/ep_disable_init_focus/ep.json [new file with mode: 0644]
addons/pad/static/plugin/ep_disable_init_focus/package.json [new file with mode: 0644]
addons/pad/static/plugin/ep_disable_init_focus/static/js/disable_init_focus.js [new file with mode: 0644]

diff --git a/addons/pad/static/plugin/ep_disable_init_focus/README.md b/addons/pad/static/plugin/ep_disable_init_focus/README.md
new file mode 100644 (file)
index 0000000..49a904a
--- /dev/null
@@ -0,0 +1,28 @@
+Readme
+======
+
+`ep_disable_init_focus` is a very simple
+[Etherpad-lite](https://github.com/ether/etherpad-lite) plugin, which disable
+the focus on the pad content after its loading.
+
+Rationale
+---------
+
+Etherpad-lite autofocus can be annoying to end-users when it is used in Odoo's
+"pad" widget, because it will override web client focus rules. This plugin is
+design to get rid of this behavior.
+
+
+Installation instructions
+-------------------------
+
+1. Stop your Etherpad-lite server.
+2. Copy the `ep_disabl_init_focus` folder into the `node_modules` folder of
+   your Etherpad-lite installation.
+3. in the folder of your Etherpad-lite installation, run this command to
+   install the plugin:
+
+    ```sh
+    npm install node_modules/ep_disable_init_focus/
+    ```
+4. Restart the Etherpad-lite server.
diff --git a/addons/pad/static/plugin/ep_disable_init_focus/ep.json b/addons/pad/static/plugin/ep_disable_init_focus/ep.json
new file mode 100644 (file)
index 0000000..547cd8a
--- /dev/null
@@ -0,0 +1,10 @@
+{
+    "parts":[
+        {
+            "name":"ep_disable_init_focus",
+            "client_hooks":{
+                "aceEditEvent":"ep_disable_init_focus/static/js/disable_init_focus"
+            }
+        }
+    ]
+}
diff --git a/addons/pad/static/plugin/ep_disable_init_focus/package.json b/addons/pad/static/plugin/ep_disable_init_focus/package.json
new file mode 100644 (file)
index 0000000..e6f307d
--- /dev/null
@@ -0,0 +1,15 @@
+{
+    "name":"ep_disable_init_focus",
+    "version":"0.0.1",
+    "description":"Disables init focus in etherpad-lite.",
+    "dependencies":{
+
+    },
+    "engines":{
+        "node":"*"
+    },
+    "author":{
+        "name":"Odoo S.A. - Hitesh Trivedi",
+        "email":"thiteshm155@gmail.com"
+    }
+}
diff --git a/addons/pad/static/plugin/ep_disable_init_focus/static/js/disable_init_focus.js b/addons/pad/static/plugin/ep_disable_init_focus/static/js/disable_init_focus.js
new file mode 100644 (file)
index 0000000..62f6a55
--- /dev/null
@@ -0,0 +1,8 @@
+exports.aceEditEvent = function(hook, call, editorInfo, rep, documentAttributeManager){
+
+    call.editorInfo.ace_focus = focus;
+    function focus(){
+        // Simple hook to disable the focus on the pad
+    }
+
+};