').css(css).appendTo(parent.$('body'));
+ }
+ else {
+ rc = rcmail;
+ target = $('
').css(css).appendTo($('body'));
+ }
+
+ e.target = target;
+ e.rcmail = rc;
+
+ return e;
+};
+
+var kolab_shortcuts_keypress = function(e)
+{
+ var i, handler, key = e.which, alt = e.altKey, ctrl = e.ctrlKey;
+
+ // console.log(e.which);
+
+ // do nothing on input elements
+ if ($(e.target).is('textarea,input')) {
+ return true;
+ }
+
+ // do nothing if any popup menu is displayed
+ if ($('.popupmenu:visible').length) {
+ return true;
+ }
+
+ for (i in kolab_shortcuts) {
+ handler = kolab_shortcuts[i];
+
+ // check if presses key(s) match
+ if (handler.key == key
+ && ((handler.ctrl && ctrl) || (!handler.ctrl && !ctrl))
+ && ((handler.alt && alt) || (!handler.alt && !alt))
+ ) {
+ // ... and action is active here
+ if (handler.active(e)) {
+ // execute action, the real check if action is active
+ // will be done in .action() or in rcmail.command()
+ handler.action(e);
+ return false;
+ }
+
+ // we can break here, there can be only one handler
+ // for the specified shortcut
+ break;
+ }
+ }
+
+ return true;
+};
+
+// register the keypress handler
+window.rcmail && $(document).ready(function() {
+ $(document).on('keypress.kolab_shortcuts', function(e) {
+ return kolab_shortcuts_keypress(e);
+ });
+});
diff --git a/plugins/kolab_shortcuts/kolab_shortcuts.php b/plugins/kolab_shortcuts/kolab_shortcuts.php
new file mode 100644
index 00000000..a6272f1d
--- /dev/null
+++ b/plugins/kolab_shortcuts/kolab_shortcuts.php
@@ -0,0 +1,36 @@
+
+ *
+ * Copyright (C) 2015, Kolab Systems AG
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+class kolab_shortcuts extends rcube_plugin
+{
+ // all task excluding 'login' and 'logout'
+ public $task = '?(?!login|logout).*';
+ // we've got no ajax handlers
+ public $noajax = true;
+
+
+ function init()
+ {
+ $this->include_script('kolab_shortcuts.js');
+ }
+}