From ece3a522d89bc77191f1fcb0b43942aa8fdb49f0 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Thu, 30 May 2013 07:57:08 -0400
Subject: [PATCH] Fixed popup windows size issues, unified sizes

---
 program/js/app.js |   35 +++++++++++++++++++----------------
 1 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/program/js/app.js b/program/js/app.js
index 101be65..36b2f0d 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -44,7 +44,9 @@
     comm_path: './',
     blankpage: 'program/resources/blank.gif',
     recipients_separator: ',',
-    recipients_delimiter: ', '
+    recipients_delimiter: ', ',
+    popup_width: 1150,
+    popup_width_small: 900
   };
 
   // create protected reference to myself
@@ -600,11 +602,11 @@
 
           $("input[name='_action']", form).val('compose');
           form.action = this.url('mail/compose', { _id: this.env.compose_id, _extwin: 1 });
-          form.target = this.open_window('', 1100, 900);
+          form.target = this.open_window('');
           form.submit();
         }
         else {
-          this.open_window(this.env.permaurl, 900, 900);
+          this.open_window(this.env.permaurl, true);
         }
         break;
 
@@ -1629,19 +1631,20 @@
     return 0;
   };
 
-  this.open_window = function(url, width, height)
+  // open popup window
+  this.open_window = function(url, small)
   {
-    var dh = (window.outerHeight || 0) - (window.innerHeight || 0),
-      dw = (window.outerWidth || 0) - (window.innerWidth || 0),
-      sh = screen.availHeight || screen.height,
-      sw = screen.availWidth || screen.width,
-      w = Math.min(width, sw),
-      h = Math.min(height, sh),
-      l = Math.max(0, (sw - w) / 2 + (screen.left || 0)),
-      t = Math.max(0, (sh - h) / 2 + (screen.top || 0)),
+    var win = this.is_framed() ? parent.window : window,
+      page = $(win),
+      page_width = page.width(),
+      page_height = bw.mz ? $('body', win).height() : page.height(),
+      w = Math.min(small ? this.env.popup_width_small : this.env.popup_width, page_width),
+      h = page_height, // always use same height
+      l = (win.screenLeft || win.screenX) + 20,
+      t = (win.screenTop || win.screenY) + 20,
       wname = 'rcmextwin' + new Date().getTime(),
       extwin = window.open(url + (url.match(/\?/) ? '&' : '?') + '_extwin=1', wname,
-        'width='+(w-dw)+',height='+(h-dh)+',top='+t+',left='+l+',resizable=yes,toolbar=no,status=no,location=no');
+        'width='+w+',height='+h+',top='+t+',left='+l+',resizable=yes,toolbar=no,status=no,location=no');
 
     // write loading... message to empty windows
     if (!url && extwin.document) {
@@ -1945,7 +1948,7 @@
     }
     else {
       if (!preview && this.env.message_extwin && !this.env.extwin)
-        this.open_window(this.env.comm_path+url, 1000, 1200);
+        this.open_window(this.env.comm_path+url, true);
       else
         this.location_href(this.env.comm_path+url, target, true);
 
@@ -2971,11 +2974,11 @@
 
     // open new compose window
     if (this.env.compose_extwin && !this.env.extwin) {
-      this.open_window(url, 1150, 900);
+      this.open_window(url);
     }
     else {
       this.redirect(url);
-      window.resizeTo(Math.max(1150, $(window).width()), Math.max(900, $(window).height()));
+      window.resizeTo(Math.max(this.env.popup_width, $(window).width()), $(window).height() + 24);
     }
   };
 

--
Gitblit v1.9.1