From c72651143bc6b92d09fea4cba50c42af81e939d0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=96=9F=E9=85=8C=20=E9=B5=AC=E5=85=84?= <tgckpg@gmail.com>
Date: Mon, 28 Sep 2015 07:16:49 +0800
Subject: [PATCH] broken style when MessageBox overflow

---
 botanjs/src/Components/MessageBox.css | 10 ++++++++++
 botanjs/src/Components/MessageBox.js  | 18 +++++++++++++++---
 botanjs/src/System/Cycle/Trigger.js   |  4 +++-
 3 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/botanjs/src/Components/MessageBox.css b/botanjs/src/Components/MessageBox.css
index fa270560..b0702ae2 100644
--- a/botanjs/src/Components/MessageBox.css
+++ b/botanjs/src/Components/MessageBox.css
@@ -11,8 +11,10 @@
 .mbox_body {
 	min-width: 350px;
 	min-height: 100px;
+
 	max-width: 800px;
 	max-height: 600px;
+
 	position: absolute;
 	background-color: rgba( 0, 0, 0, 0.8 );
 
@@ -34,6 +36,7 @@
 	font-family: sans-serif;
 	color: white;
 
+	overflow: hidden;
 	/*
 	-moz-box-shadow: inset 0 10px 10px -10px black;
 	-webkit-box-shadow: inset 0 10px 10px -10px black;
@@ -41,6 +44,13 @@
 	*/
 }
 
+.mbox-inners {
+	/* This is to hide the scrollbar */
+	padding-right: 50%;
+	margin-right: -50%;
+	overflow-y: scroll;
+}
+
 .mbox_buttons {
 	text-align: right;
 	padding: 1em 0.5em;
diff --git a/botanjs/src/Components/MessageBox.js b/botanjs/src/Components/MessageBox.js
index f628eaab..400db898 100644
--- a/botanjs/src/Components/MessageBox.js
+++ b/botanjs/src/Components/MessageBox.js
@@ -79,8 +79,8 @@
 				"mbox_body cubic500"
 				, [
 					Dand.wrapc( "mbox_titlebar flsf", title )
-					, Dand.wrapc( "mbox_content", content )
-					, Dand.wrapc( "mbox_buttons", no ? [ _yes, _no ] : _yes )
+					, Dand.wrapc( "mbox_content", this.innerBox = Dand.wrapc( "mbox-inners", content ) )
+					, this.buttonBox = Dand.wrapc( "mbox_buttons", no ? [ _yes, _no ] : _yes )
 				]
 			)
 		);
@@ -106,9 +106,21 @@
 			, function()
 			{
 				m_style.transition = m_style.minHeight = m_style.height = m_style.overflow = "";
-				m_style.marginTop = String( -0.5 * this.mbox.clientHeight ) + "px";
+
+				var bBox = this.buttonBox;
+				var mHeight = this.mbox.clientHeight;
+				var innerHeight = this.innerBox.clientHeight;
+				var bBoxHeight = bBox.clientHeight;
+
+				m_style.marginTop = ( -0.5 * mHeight ) + "px";
 
 				m_style.opacity = 1;
+				if( mHeight < ( bBox.getBoundingClientRect().y - bBox.parentNode.getBoundingClientRect().y + bBoxHeight ) )
+				{
+					m_style.height = "100%";
+					this.innerBox.style.maxHeight = ( innerHeight - bBoxHeight ) + "px"
+				}
+
 			}.bind( this )
 		);
 
diff --git a/botanjs/src/System/Cycle/Trigger.js b/botanjs/src/System/Cycle/Trigger.js
index 6d6529c1..1136d4dd 100644
--- a/botanjs/src/System/Cycle/Trigger.js
+++ b/botanjs/src/System/Cycle/Trigger.js
@@ -2,7 +2,9 @@
 	var ns = __namespace( "System.Cycle.Trigger" );
 
 	/** @type {System.Cycle} */
-	var Cycle = __import( "System.Cycle" );
+	var Cycle                   = __import( "System.Cycle" );
+	/** @type {System.Debug} */
+	var debug                   = __import( "System.Debug" );
 
 	// trigger list
 	var tList = [];