From 0933d66b591056358b5e645cbd563814308998d2 Mon Sep 17 00:00:00 2001
From: Thomas Bruederli <thomas@roundcube.net>
Date: Wed, 04 Sep 2013 04:08:42 -0400
Subject: [PATCH] Keep current selection on IE browsers by adding unselectable=on to link elements

---
 program/include/rcmail_output_html.php |    2 +-
 program/steps/mail/compose.inc         |    1 +
 program/lib/Roundcube/html.php         |    4 ++--
 skins/larry/images/buttons.png         |    0 
 program/js/app.js                      |    7 ++++---
 skins/larry/templates/compose.html     |    6 +++---
 6 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/program/include/rcmail_output_html.php b/program/include/rcmail_output_html.php
index a2ec29c..006b89c 100644
--- a/program/include/rcmail_output_html.php
+++ b/program/include/rcmail_output_html.php
@@ -1171,7 +1171,7 @@
 
         // generate html code for button
         if ($btn_content) {
-            $attrib_str = html::attrib_string($attrib, $link_attrib);
+            $attrib_str = html::attrib_string($attrib, array_merge(html::$common_attrib, $link_attrib));
             $out = sprintf('<a%s>%s</a>', $attrib_str, $btn_content);
         }
 
diff --git a/program/js/app.js b/program/js/app.js
index cef6882..5233d9c 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -258,12 +258,12 @@
           this.env.address_group_stack = [];
           this.env.compose_commands = ['send-attachment', 'remove-attachment', 'send', 'cancel',
             'toggle-editor', 'list-adresses', 'pushgroup', 'search', 'reset-search', 'extwin',
-            'insert-response', 'save-response', 'edit-responses'];
+            'insert-response', 'save-response'];
 
           if (this.env.drafts_mailbox)
             this.env.compose_commands.push('savedraft')
 
-          this.enable_command(this.env.compose_commands, 'identities', true);
+          this.enable_command(this.env.compose_commands, 'identities', 'responses', true);
 
           // add more commands (not enabled)
           $.merge(this.env.compose_commands, ['add-recipient', 'firstpage', 'previouspage', 'nextpage', 'lastpage']);
@@ -277,6 +277,7 @@
           // init canned response functions
           if (this.gui_objects.responseslist) {
             $('a.insertresponse', this.gui_objects.responseslist)
+              .attr('unselectable', 'on')
               .mousedown(function(e){ return rcube_event.cancel(e); })
               .mouseup(function(e){
                 ref.command('insert-response', $(this).attr('rel'));
@@ -3458,7 +3459,7 @@
 
   this.edit_responses = function()
   {
-    // TODO: decide what to do here...
+    // TODO: implement inline editing of responses
   };
 
   this.delete_response = function(key)
diff --git a/program/lib/Roundcube/html.php b/program/lib/Roundcube/html.php
index 2086aaa..4295f26 100644
--- a/program/lib/Roundcube/html.php
+++ b/program/lib/Roundcube/html.php
@@ -3,7 +3,7 @@
 /*
  +-----------------------------------------------------------------------+
  | This file is part of the Roundcube Webmail client                     |
- | Copyright (C) 2005-2011, The Roundcube Dev Team                       |
+ | Copyright (C) 2005-2013, The Roundcube Dev Team                       |
  |                                                                       |
  | Licensed under the GNU General Public License version 3 or            |
  | any later version with exceptions for skins & plugins.                |
@@ -32,7 +32,7 @@
 
     public static $doctype = 'xhtml';
     public static $lc_tags = true;
-    public static $common_attrib = array('id','class','style','title','align');
+    public static $common_attrib = array('id','class','style','title','align','unselectable');
     public static $containers = array('iframe','div','span','p','h1','h2','h3','ul','form','textarea','table','thead','tbody','tr','th','td','style','script');
 
 
diff --git a/program/steps/mail/compose.inc b/program/steps/mail/compose.inc
index 282a2fd..bce4fd3 100644
--- a/program/steps/mail/compose.inc
+++ b/program/steps/mail/compose.inc
@@ -1713,6 +1713,7 @@
         $item = html::a(array(
             'href '=> '#'.urlencode($response['name']),
             'class' => rtrim('insertresponse ' . $attrib['itemclass']),
+            'unselectable' => 'on',
             'rel' => $key,
         ), Q($response['name']));
 
diff --git a/skins/larry/images/buttons.png b/skins/larry/images/buttons.png
index 3e28d12..03c61ed 100644
--- a/skins/larry/images/buttons.png
+++ b/skins/larry/images/buttons.png
Binary files differ
diff --git a/skins/larry/templates/compose.html b/skins/larry/templates/compose.html
index 0e4568b..863570c 100644
--- a/skins/larry/templates/compose.html
+++ b/skins/larry/templates/compose.html
@@ -30,7 +30,7 @@
 	<roundcube:endif />
 	<roundcube:button name="addattachment" type="link" class="button attach" classAct="button attach" classSel="button attach pressed" label="attach" title="addattachment" onclick="UI.show_uploadform();return false" />
 	<roundcube:button command="insert-sig" type="link" class="button insertsig disabled" classAct="button insertsig" classSel="button insertsig pressed" label="signature" title="insertsignature" />
-	<a href="#responses" class="button responses" label="responses" title="<roundcube:label name='insertresponse' />" id="responsesmenulink" onmousedown="return false" onmouseup="UI.show_popup('responsesmenu');return false"><roundcube:label name="responses" /></a>
+	<a href="#responses" class="button responses" label="responses" title="<roundcube:label name='insertresponse' />" id="responsesmenulink" unselectable="on" onmousedown="return false" onclick="UI.show_popup('responsesmenu');return false"><roundcube:label name="responses" /></a>
 	<roundcube:container name="toolbar" id="compose-toolbar" />
 </div>
 </div>
@@ -200,8 +200,8 @@
 		<li class="separator" id=""><label><roundcube:label name="insertresponse" /></label></li>
 		<roundcube:object name="responseslist" id="responseslist" tagname="ul" itemclass="active" />
 		<li class="separator"><label><roundcube:label name="manageresponses" /></label></li>
-		<li><roundcube:button command="save-response" type="link" label="savenewresponse" classAct="active" /></li>
-		<li><roundcube:button command="edit-responses" type="link" label="editresponses" classAct="active" /></li>
+		<li><roundcube:button command="save-response" type="link" label="savenewresponse" classAct="active" unselectable="on" /></li>
+		<li><roundcube:button command="responses" type="link" label="editresponses" classAct="active" /></li>
 	</ul>
 </div>
 

--
Gitblit v1.9.1