penguin/AstroJS

Javascript framework for my blog

commit aa38487f9f143be722cfd2b86f58d32c8b2bf77a

author斟酌 鵬兄 <tgckpg@gmail.com>
date2016-03-06T15:26:15Z
subjectAllow MessageBox to be updated via show
commit aa38487f9f143be722cfd2b86f58d32c8b2bf77a
Author: 斟酌 鵬兄 <tgckpg@gmail.com>
Date:   2016-03-06T15:26:15Z

    Allow MessageBox to be updated via show
---
 botanjs/src/Components/MessageBox.js | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/botanjs/src/Components/MessageBox.js b/botanjs/src/Components/MessageBox.js
index b004115..9dea0ce 100644
--- a/botanjs/src/Components/MessageBox.js
+++ b/botanjs/src/Components/MessageBox.js
@@ -88,13 +88,21 @@
 				]
 			)
 		);
+
+		this.showned = false;
 	};
 
 	MessageBox.prototype.setHandler = function( handler ) { this.clickHandler = handler };
 
 	MessageBox.prototype.show = function ()
 	{
-		document.body.appendChild( this.stage );
+		var update = this.showned;
+		if( !update )
+		{
+			this.showned = true;
+			document.body.appendChild( this.stage );
+		}
+
 		// Center the box
 		var m_style = this.mbox.style;
 
@@ -103,6 +111,7 @@
 		m_style.marginLeft = String( -0.5 * this.mbox.clientWidth ) + "px";
 		m_style.overflow = "hidden";
 		m_style.minHeight = m_style.opacity = m_style.height = 0;
+
 		// The interval in firefox seems independent to etablishing element style
 		// using heightTriggers-hack instead
 		var by = function( el )
@@ -110,11 +119,13 @@
 			var tRect = el.getBoundingClientRect();
 			return tRect.y || tRect.top;
 		};
+
 		var bh = function( el )
 		{
 			var tRect = el.getBoundingClientRect();
 			return tRect.height;
 		};
+
 		Trigger.height(
 			this.mbox, 0
 			, function()