From 86958f70d2970704e9ec6935d65e294c077143ea Mon Sep 17 00:00:00 2001
From: thomascube <thomas@roundcube.net>
Date: Sun, 18 Mar 2007 14:46:03 -0400
Subject: [PATCH] Improved contacts drop down; HTML output improvements; JS code cleanup

---
 skins/default/common.css    |    3 
 CHANGELOG                   |   11 +++
 index.php                   |    2 
 program/js/common.js        |   10 +-
 program/include/main.inc    |    2 
 program/steps/mail/func.inc |    3 +
 program/js/app.js           |   94 ++++++++++++++++---------------
 7 files changed, 71 insertions(+), 54 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 3d1796d..6288cbc 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,17 @@
 CHANGELOG RoundCube Webmail
 ---------------------------
 
+2007/03/18 (thomasb)
+----------
+- Also use user_id for unique key in messages table (closes #1484074)
+- Hide contacts drop down on blur (closes #1484203)
+- Make entries in contacts drop down clickable
+- Turn off browser autocompletion on login page
+- Quote <? in text/html message parts
+- Hide border around radio buttons
+- Replaced old JS function calls.
+
+
 2007/03/13 (thomasb)
 ----------
 - Applied patch for attachment download by crichardson (closes #1484198)
diff --git a/index.php b/index.php
index 8219be4..eaecfdf 100644
--- a/index.php
+++ b/index.php
@@ -195,7 +195,7 @@
   }
 
 // check session and auth cookie
-else if ($_action!='login' && $_SESSION['user_id'])
+else if ($_action != 'login' && $_SESSION['user_id'] && $_action != 'send')
   {
   if (!rcmail_authenticate_session() ||
       (!empty($CONFIG['session_lifetime']) && isset($SESS_CHANGED) && $SESS_CHANGED + $CONFIG['session_lifetime']*60 < mktime()))
diff --git a/program/include/main.inc b/program/include/main.inc
index 68cc903..e522b43 100644
--- a/program/include/main.inc
+++ b/program/include/main.inc
@@ -1846,7 +1846,7 @@
   $labels['pass'] = rcube_label('password');
   $labels['host'] = rcube_label('server');
   
-  $input_user = new textfield(array('name' => '_user', 'id' => 'rcmloginuser', 'size' => 30));
+  $input_user = new textfield(array('name' => '_user', 'id' => 'rcmloginuser', 'size' => 30, 'autocomplete' => 'off'));
   $input_pass = new passwordfield(array('name' => '_pass', 'id' => 'rcmloginpwd', 'size' => 30));
   $input_action = new hiddenfield(array('name' => '_action', 'value' => 'login'));
     
diff --git a/program/js/app.js b/program/js/app.js
index c19a3e1..2f4b471 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -3,7 +3,7 @@
  | RoundCube Webmail Client Script                                       |
  |                                                                       |
  | This file is part of the RoundCube Webmail client                     |
- | Copyright (C) 2005-2006, RoundCube Dev, - Switzerland                 |
+ | Copyright (C) 2005-2007, RoundCube Dev, - Switzerland                 |
  | Licensed under the GNU GPL                                            |
  |                                                                       |
  +-----------------------------------------------------------------------+
@@ -178,7 +178,7 @@
           this.enable_command('add-attachment', 'send-attachment', 'remove-attachment', 'send', true);
           if (this.env.spellcheck)
             {
-            this.env.spellcheck.spelling_state_observer = function(s){ rcube_webmail_client.set_spellcheck_state(s); };
+            this.env.spellcheck.spelling_state_observer = function(s){ ref.set_spellcheck_state(s); };
             this.set_spellcheck_state('ready');
             }
           if (this.env.drafts_mailbox)
@@ -386,18 +386,19 @@
 
   this.init_address_input_events = function(obj)
     {
-    var handler = function(e){ return rcube_webmail_client.ksearch_keypress(e,this); };
-    var handler2 = function(e){ return rcube_webmail_client.ksearch_blur(e,this); };
-
-    if (bw.safari)
-      obj.addEventListener('keydown', handler, false);
-    else if (bw.mz)
-      {
-      obj.addEventListener('keypress', handler, false);
+    var handler = function(e){ return ref.ksearch_keypress(e,this); };
+    var handler2 = function(e){ return ref.ksearch_blur(e,this); };
+    
+    if (obj.addEventListener)
+    {
+      obj.addEventListener(bw.safari ? 'keydown' : 'keypress', handler, false);
       obj.addEventListener('blur', handler2, false);
-      }
-    else if (bw.ie)
+    }
+    else
+    {
       obj.onkeydown = handler;
+      obj.onblur = handler2;
+    }
 
     obj.setAttribute('autocomplete', 'off');       
     };
@@ -1682,9 +1683,9 @@
 
   this.set_spellcheck_state = function(s)
     {
-  this.spellcheck_ready = (s=='check_spelling' || s=='ready');
+    this.spellcheck_ready = (s=='check_spelling' || s=='ready');
     this.enable_command('spellcheck', this.spellcheck_ready);
-  };
+    };
 
 
   this.auto_save_start = function()
@@ -1986,7 +1987,6 @@
         if (highlight && (next = dir ? highlight.previousSibling : highlight.nextSibling))
           {
           highlight.removeAttribute('id');
-          //highlight.removeAttribute('class');
           this.set_classname(highlight, 'selected', false);
           }
 
@@ -1997,9 +1997,7 @@
           this.ksearch_selected = next._rcm_id;
           }
 
-        if (e.preventDefault)
-          e.preventDefault();
-        return false;
+        return rcube_event.cancel(e);
 
       case 9:  // tab
         if(e.shiftKey)
@@ -2009,30 +2007,11 @@
         if (this.ksearch_selected===null || !this.ksearch_input || !this.ksearch_value)
           break;
 
-        // get cursor pos
-        var inp_value = this.ksearch_input.value.toLowerCase();
-        var cpos = this.get_caret_pos(this.ksearch_input);
-        var p = inp_value.lastIndexOf(this.ksearch_value, cpos);
-        
-        // replace search string with full address
-        var pre = this.ksearch_input.value.substring(0, p);
-        var end = this.ksearch_input.value.substring(p+this.ksearch_value.length, this.ksearch_input.value.length);
-        var insert = this.env.contacts[this.ksearch_selected]+', ';
-        this.ksearch_input.value = pre + insert + end;
-        
-        //this.ksearch_input.value = this.ksearch_input.value.substring(0, p)+insert;
-        
-        // set caret to insert pos
-        cpos = p+insert.length;
-        if (this.ksearch_input.setSelectionRange)
-          this.ksearch_input.setSelectionRange(cpos, cpos);
-        
-        // hide ksearch pane
+        // insert selected address and hide ksearch pane
+        this.insert_recipient(this.ksearch_selected);
         this.ksearch_hide();
-      
-        if (e.preventDefault)
-          e.preventDefault();
-        return false;
+
+        return rcube_event.cancel(e);
 
       case 27:  // escape
         this.ksearch_hide();
@@ -2046,6 +2025,30 @@
     
     return true;
     };
+
+
+  this.insert_recipient = function(id)
+  {
+    if (!this.env.contacts[id] || !this.ksearch_input)
+      return;
+    
+    // get cursor pos
+    var inp_value = this.ksearch_input.value.toLowerCase();
+    var cpos = this.get_caret_pos(this.ksearch_input);
+    var p = inp_value.lastIndexOf(this.ksearch_value, cpos);
+    
+    // replace search string with full address
+    var pre = this.ksearch_input.value.substring(0, p);
+    var end = this.ksearch_input.value.substring(p+this.ksearch_value.length, this.ksearch_input.value.length);
+    var insert  = this.env.contacts[id]+', ';
+    this.ksearch_input.value = pre + insert + end;
+    
+    // set caret to insert pos
+    cpos = p+insert.length;
+    if (this.ksearch_input.setSelectionRange)
+      this.ksearch_input.setSelectionRange(cpos, cpos);
+    
+  };
 
 
   // address search processor
@@ -2113,6 +2116,8 @@
         {
         li = document.createElement('LI');
         li.innerHTML = a_results[i].replace(/</, '&lt;').replace(/>/, '&gt;');
+        li.onmousedown = function(e){ ref.insert_recipient(this._rcm_id); ref.ksearch_pane.show(0); return rcube_event.cancel(e); };
+        li.style.cursor = 'pointer';
         li._rcm_id = a_result_ids[i];
         ul.appendChild(li);
         }
@@ -2138,9 +2143,6 @@
         this.ksearch_selected = a_result_ids[0];
         }
 
-      // resize the containing layer to fit the list
-      //this.ksearch_pane.resize(ul.offsetWidth, ul.offsetHeight);
-    
       // move the results pane right under the input box and make it visible
       var pos = rcube_get_object_pos(this.ksearch_input);
       this.ksearch_pane.move(pos.x, pos.y+this.ksearch_input.offsetHeight);
@@ -3228,8 +3230,8 @@
 
       request_obj.__lock = lock ? true : false;
       request_obj.__action = action;
-      request_obj.onerror = function(o){ rcube_webmail_client.http_error(o); };
-      request_obj.oncomplete = function(o){ rcube_webmail_client.http_response(o); };
+      request_obj.onerror = function(o){ ref.http_error(o); };
+      request_obj.oncomplete = function(o){ ref.http_response(o); };
       request_obj.GET(this.env.comm_path+'&_action='+action+'&'+querystring);
       }
     };
diff --git a/program/js/common.js b/program/js/common.js
index 2df349a..82d7ed1 100644
--- a/program/js/common.js
+++ b/program/js/common.js
@@ -496,7 +496,7 @@
     {
     if(d.layers[id]) obj = d.layers[id];
     for(n=0; !obj && n<d.layers.length; n++)
-      obj = nex_get_object(id, d.layers[n].document);
+      obj = rcube_find_object(id, d.layers[n].document);
     }
 
   return obj;
@@ -507,7 +507,7 @@
 function rcube_get_object_pos(obj)
   {
   if(typeof(obj)=='string')
-    obj = nex_get_object(obj);
+    obj = rcube_find_object(obj);
 
   if(!obj) return {x:0, y:0};
 
@@ -525,8 +525,8 @@
       }
     }
 
-  if(bw.mac && bw.ie5) iX += document.body.leftMargin;
-  if(bw.mac && bw.ie5) iY += document.body.topMargin;
+  //if(bw.mac && bw.ie5) iX += document.body.leftMargin;
+  //if(bw.mac && bw.ie5) iY += document.body.topMargin;
 
   return {x:iX, y:iY};
   }
@@ -548,7 +548,7 @@
 
   var el = html_element;
   if (typeof(html_element)=='string')
-    el = nex_get_object(html_element);
+    el = rcube_find_object(html_element);
 
   if (el && el.currentStyle)
     return el.currentStyle[css_property];
diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc
index 606c977..be9558f 100644
--- a/program/steps/mail/func.inc
+++ b/program/steps/mail/func.inc
@@ -1248,6 +1248,9 @@
                             '</div>'),
                       $out);
 
+  // quote <? of php and xml files that are specified as text/html
+  $out = preg_replace(array('/<\?/', '/\?>/'), array('&lt;?', '?&gt;'), $out);
+
   return $out;
   }
 
diff --git a/skins/default/common.css b/skins/default/common.css
index 2e7c169..afccc8f 100755
--- a/skins/default/common.css
+++ b/skins/default/common.css
@@ -73,7 +73,8 @@
   border: 1px solid #666666;
 }
 
-input[type="checkbox"]
+input[type="checkbox"],
+input[type="radio"]
 {
   border: 0;
   padding: 0;

--
Gitblit v1.9.1