Added contextmenu support in DIMP for Opera
authorMichael M Slusarz <slusarz@curecanti.org>
Tue, 13 Oct 2009 10:53:34 +0000 (04:53 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Tue, 13 Oct 2009 10:53:34 +0000 (04:53 -0600)
imp/docs/CHANGES
imp/js/ContextSensitive.js
imp/js/DimpBase.js
imp/templates/index/index-dimp.inc

index 02ba036..e20095d 100644 (file)
@@ -2,6 +2,7 @@
 v5.0-git
 --------
 
+[mms] Added contextmenu support in DIMP for Opera.
 [mms] Display HTML parts inline by using IFRAMEs (based on code by
       rui.carneiro@portugalmail.net; Request #8592).
 [mms] Add ability to search by relative date intervals (Request #3438).
index 743cf64..d963ee5 100644 (file)
@@ -4,6 +4,9 @@
  * document, and works only where these are possible to override.  It allows
  * contextmenus to be created via both a left and right mouse click.
  *
+ * On Opera, the context menu is triggered by a left click + SHIFT + CTRL
+ * combination.
+ *
  * Requires prototypejs 1.6+ and scriptaculous 1.8+ (effects.js only).
  *
  * Original code by Havard Eide (http://eide.org/) released under the MIT
@@ -39,7 +42,9 @@ var ContextSensitive = Class.create({
         this.submenus = $H();
         this.triggers = [];
 
-        document.observe('contextmenu', this._rightClickHandler.bindAsEventListener(this));
+        if (!Prototype.Browser.Opera) {
+            document.observe('contextmenu', this._rightClickHandler.bindAsEventListener(this));
+        }
         document.observe('click', this._leftClickHandler.bindAsEventListener(this));
         document.observe(Prototype.Browser.Gecko ? 'DOMMouseScroll' : 'mousescroll', this.close.bind(this));
     },
@@ -134,6 +139,12 @@ var ContextSensitive = Class.create({
     {
         var base, elt, elt_up, trigger;
 
+        if (this.operaCheck(e)) {
+            this._rightClickHandler(e, false);
+            e.stop();
+            return;
+        }
+
         // Check for a right click. FF on Linux triggers an onclick event even
         // w/a right click, so disregard.
         if (e.isRightClick()) {
@@ -175,6 +186,14 @@ var ContextSensitive = Class.create({
     },
 
     /**
+     * Checks if the Opera right-click emulation is present.
+     */
+    operaCheck: function(e)
+    {
+        return Prototype.Browser.Opera && e.shiftKey && e.ctrlKey;
+    },
+
+    /**
      * Called when a right click event occurs.
      */
     _rightClickHandler: function(e, left)
index fc32955..f66ea52 100644 (file)
@@ -1635,7 +1635,7 @@ var DimpBase = {
 
     clickHandler: function(parentfunc, e)
     {
-        if (e.isRightClick()) {
+        if (e.isRightClick() || DimpCore.DMenu.operaCheck(e)) {
             return;
         }
 
@@ -2681,7 +2681,11 @@ DimpBase._msgDragConfig = {
         d.selectIfNoDrag = false;
 
         // Handle selection first.
-        if (!args.right && (e.ctrlKey || e.metaKey)) {
+        if (DimpCore.DMenu.operaCheck(e)) {
+            if (!DimpBase.isSelected('domid', id)) {
+                DimpBase.msgSelect(id, { right: true });
+            }
+        } else if (!args.right && (e.ctrlKey || e.metaKey)) {
             DimpBase.msgSelect(id, $H({ ctrl: true }).merge(args).toObject());
         } else if (e.shiftKey) {
             DimpBase.msgSelect(id, $H({ shift: true }).merge(args).toObject());
@@ -2712,21 +2716,28 @@ DimpBase._folderDragConfig = {
     scroll: 'normalfolders',
     threshold: 5,
     onStart: function(d, e) {
-        $('msgBodyCover').clonePosition('msgBody').show();
+        if (DimpCore.DMenu.operaCheck(e)) {
+            d.opera = true;
+        } else {
+            d.opera = false;
+            $('msgBodyCover').clonePosition('msgBody').show();
+        }
     },
     onDrag: function(d, e) {
-        if (!d.wasDragged) {
+        if (!d.opera && !d.wasDragged) {
             $('folderopts').hide();
             $('dropbase').show();
             d.ghost.removeClassName('on');
         }
     },
     onEnd: function(d, e) {
-        if (d.wasDragged) {
-            $('folderopts').show();
-            $('dropbase').hide();
+        if (!d.opera) {
+            if (d.wasDragged) {
+                $('folderopts').show();
+                $('dropbase').hide();
+            }
+            $('msgBodyCover').hide();
         }
-        $('msgBodyCover').hide();
     }
 };
 
index cb11a5e..a02bb47 100644 (file)
@@ -231,7 +231,14 @@ function _simpleButton($id, $text, $image, $imagedir = null)
      <div id="previewPane" style="display:none">
       <span id="msgLoading" class="loadingImg" style="display:none"></span>
       <div id="previewInfo" style="display:none">
-       <?php echo _("To preview a message, select it from the list above. A right-click on the messages will display available actions.") ?><br />
+       <?php echo _("To preview a message, select it from the list above.") ?>
+       <br />
+<?php if ($browser->isBrowser('opera')): ?>
+       <?php echo _("A left click") ?> + <span class="kbd"><?php echo _("Shift") ?></span> + <span class="kbd"><?php echo _("Ctrl") ?></span> <?php echo _("will display available actions.") ?>
+<?php else: ?>
+       <?php echo _("A right-click on a message or a folder will display available actions.") ?>
+<?php endif; ?>
+       <br />
        <?php printf(_("Click on a message while holding down the %s key to select multiple messages.  To select a range of messages, click the first message of the range, navigate to the last message of the range, and then click on the last message while holding down the %s key."), '<span class="kbd">' . _("Ctrl") . '</span>', '<span class="kbd">' . _("Shift") . '</span>') ?><br /><br />
        <?php echo _("The following keyboard shortcuts are available:") ?><br />
        <span class="iconImg keyupImg"></span> / <span class="iconImg keydownImg"></span> : <?php echo _("Move up/down through the message list.") ?><br />