From 26e76dfdd89f0183466f2d3354ff741680137c6f Mon Sep 17 00:00:00 2001
From: thomascube <thomas@roundcube.net>
Date: Fri, 21 Jan 2011 12:12:43 -0500
Subject: [PATCH] Fix window size detection on IE

---
 skins/default/functions.js |   23 +++++++++++++----------
 1 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/skins/default/functions.js b/skins/default/functions.js
index 77cdeb8..9eed5f0 100644
--- a/skins/default/functions.js
+++ b/skins/default/functions.js
@@ -25,9 +25,8 @@
 // Warning: don't place "caller" <script> inside page element (id)
 function rcube_init_tabs(id, current)
 {
-  var content = document.getElementById(id),
-    // get fieldsets of the higher-level (skip nested fieldsets)
-    fs = $('fieldset', content).not('fieldset > fieldset');
+  var content = $('#'+id),
+    fs = content.children('fieldset');
 
   if (!fs.length)
     return;
@@ -42,9 +41,7 @@
 
   // convert fildsets into tabs
   fs.each(function(idx) {
-    var tab, a, elm = $(this),
-      // get first legend element
-      legend = $(elm).children('legend');
+    var tab, a, elm = $(this), legend = elm.children('legend');
 
     // create a tab
     a   = $('<a>').text(legend.text()).attr('href', '#');
@@ -66,8 +63,7 @@
 
 function rcube_show_tab(id, index)
 {
-  var content = document.getElementById(id),
-    fs = $('fieldset', content);
+  var fs = $('#'+id).children('fieldset');
 
   fs.each(function(idx) {
     // Show/hide fieldset (tab content)
@@ -94,7 +90,8 @@
     mailboxmenu:    {id:'mailboxoptionsmenu', above:1},
     composemenu:    {id:'composeoptionsmenu', editable:1},
     // toggle: #1486823, #1486930
-    uploadmenu:     {id:'attachment-form', editable:1, above:1, toggle:!bw.ie&&!bw.linux }
+    uploadmenu:     {id:'attachment-form', editable:1, above:1, toggle:!bw.ie&&!bw.linux },
+    uploadform:     {id:'upload-form', editable:1, toggle:!bw.ie&&!bw.linux }
   };
 
   var obj;
@@ -131,10 +128,13 @@
 
   if (show && ref) {
     var parent = $(ref).parent(),
+      win = $(window),
       pos = parent.hasClass('dropbutton') ? parent.offset() : $(ref).offset();
 
-    if (!above && pos.top + ref.offsetHeight + obj.height() > window.innerHeight)
+    if (!above && pos.top + ref.offsetHeight + obj.height() > win.height())
       above = true;
+    if (pos.left + obj.width() > win.width())
+      pos.left = win.width() - obj.width() - 30;
 
     obj.css({ left:pos.left, top:(pos.top + (above ? -obj.height() : ref.offsetHeight)) });
   }
@@ -500,6 +500,9 @@
     if (rcmail.env.action == 'compose')
       rcmail_ui.init_compose_form();
   }
+  else if (rcmail.env.task == 'addressbook') {
+    rcmail.addEventListener('afterupload-photo', function(){ rcmail_ui.show_popup('uploadform', false); });
+  }
 }
 
 // Events handling in iframes (eg. preview pane)

--
Gitblit v1.9.1