penguin/AstroJS

Javascript framework for my blog

commit f88643ceadd12f4eb047ffec8557d293963de4f1

author斟酌 鵬兄 <tgckpg@gmail.com>
date2015-08-14T17:13:54Z
subjectPure Column
commit f88643ceadd12f4eb047ffec8557d293963de4f1
Author: 斟酌 鵬兄 <tgckpg@gmail.com>
Date:   2015-08-14T17:13:54Z

    Pure Column
---
 botanjs/src/Astro/Blog/Layout/MainFrame.css  |  1 -
 botanjs/src/Astro/Blog/Layout/PureColumn.css | 18 +++++++
 botanjs/src/Astro/Blog/Layout/PureColumn.js  | 76 ++++++++++++++++++++++++++++
 3 files changed, 94 insertions(+), 1 deletion(-)

diff --git a/botanjs/src/Astro/Blog/Layout/MainFrame.css b/botanjs/src/Astro/Blog/Layout/MainFrame.css
index 755839e..919a8e9 100644
--- a/botanjs/src/Astro/Blog/Layout/MainFrame.css
+++ b/botanjs/src/Astro/Blog/Layout/MainFrame.css
@@ -39,7 +39,6 @@ h6, .h6 { font-size: 0.5em; }
     clear: both;
     padding: 0 !important;
     margin: 0 !important;
-
 }
 
 .begin-wrapper {
diff --git a/botanjs/src/Astro/Blog/Layout/PureColumn.css b/botanjs/src/Astro/Blog/Layout/PureColumn.css
new file mode 100644
index 0000000..9e792fd
--- /dev/null
+++ b/botanjs/src/Astro/Blog/Layout/PureColumn.css
@@ -0,0 +1,18 @@
+.clearfix:after {
+    clear: both;
+    content: "";
+    display: block;
+}
+
+.trademark {
+    text-align: right;
+    font-family: custom-sans;
+}
+
+.trademark > a {
+    text-decoration: none;
+}
+
+.trademark > a:hover {
+    text-decoration: underline;
+}
diff --git a/botanjs/src/Astro/Blog/Layout/PureColumn.js b/botanjs/src/Astro/Blog/Layout/PureColumn.js
new file mode 100644
index 0000000..ae0e50f
--- /dev/null
+++ b/botanjs/src/Astro/Blog/Layout/PureColumn.js
@@ -0,0 +1,76 @@
+(function(){
+	var ns = __namespace( "Astro.Blog.Layout.PureColumn" );
+
+	/** @type {Astro.Bootstrap} */
+	var Bootstrap                    = __import( "Astro.Bootstrap" );
+	/** @type {System.Cycle} */
+	var Cycle                        = __import( "System.Cycle" );
+	/** @type {Astro.Blog.Config} */
+	var config                       = __import( "Astro.Blog.Config" );
+	/** @type {System.Debug} */
+	var debug                        = __import( "System.Debug" );
+
+	/** @type {MessageEvent} */
+	var allowedOrigin;
+
+	var catchMessage = function( e )
+	{
+		debug.Info( "Origin: " + e.origin );
+		var allowedOrigins = config.get( "AllowedOrigins" );
+		var j = e.origin;
+
+		for ( var i in allowedOrigins )
+		{
+			if ( j === allowedOrigins[i] )
+			{
+				// Stop listener
+				debug.Info( "  captured" );
+				window.removeEventListener( "message", catchMessage, false );
+				allowedOrigin = e;
+
+				// post the content height
+				postContentHeight();
+				return;
+			}
+		}
+		debug.Info( "  refused. Continue listening..." );
+	}
+	
+	var postContentHeight = function ()
+	{
+		if ( allowedOrigin.source && allowedOrigin.origin )
+		{
+			// per second trigger for body height
+			var pHeight;
+			allowedOrigin.source.postMessage(
+				pHeight = document.body.clientHeight + ""
+				, allowedOrigin.origin
+			);
+
+			var heightUpdate = function()
+			{
+				if( pHeight != document.body.clientHeight )
+				{
+					allowedOrigin.source.postMessage(
+						pHeight = document.body.clientHeight + ""
+						, allowedOrigin.origin
+					);
+				}
+			}
+
+			Cycle.perma( "bodyHeightMonitor", heightUpdate, 500 );
+		}
+	};
+
+	var init = function ()
+	{
+		if ( window.self !== window.top )
+		{
+			debug.Info( "iframe detected, listening ..." );
+			// Wait for parent frame's message
+			window.addEventListener( "message", catchMessage, false );
+		}
+	};
+
+	Bootstrap.regInit( init );
+})();