From 3869571a058cfe7dafb47c619a25eedf6f2d99bb Mon Sep 17 00:00:00 2001
From: Alexandr Kirienko <alex@kirienko.net>
Date: Sat, 28 Feb 2015 20:21:01 +0300
Subject: [PATCH] #1678562: Modal may receive negative top css position

---
 js/modal.js | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/js/modal.js b/js/modal.js
index 37908cf..4b1cfbb 100644
--- a/js/modal.js
+++ b/js/modal.js
@@ -438,7 +438,7 @@
 
     // Create our content div, get the dimensions, and hide it
     var modalContent = $('#modalContent').css('top','-1000px');
-    var mdcTop = wt + ( winHeight / 2 ) - (  modalContent.outerHeight() / 2);
+    var mdcTop = wt + Math.max((winHeight / 2) - (modalContent.outerHeight() / 2), 0);
     var mdcLeft = ( winWidth / 2 ) - ( modalContent.outerWidth() / 2);
     $('#modalBackdrop').css(css).css('top', 0).css('height', docHeight + 'px').css('width', docWidth + 'px').show();
     modalContent.css({top: mdcTop + 'px', left: mdcLeft + 'px'}).hide()[animation](speed);
@@ -501,7 +501,7 @@
 
       // Get where we should move content to
       var modalContent = $('#modalContent');
-      var mdcTop = wt + ( winHeight / 2 ) - ( modalContent.outerHeight() / 2);
+      var mdcTop = wt + Math.max((winHeight / 2) - (modalContent.outerHeight() / 2), 0);
       var mdcLeft = ( winWidth / 2 ) - ( modalContent.outerWidth() / 2);
 
       // Apply the changes
-- 
1.9.1

