From f88643ceadd12f4eb047ffec8557d293963de4f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=9F=E9=85=8C=20=E9=B5=AC=E5=85=84?= Date: Sat, 15 Aug 2015 01:13:54 +0800 Subject: [PATCH] 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(-) create mode 100644 botanjs/src/Astro/Blog/Layout/PureColumn.css create mode 100644 botanjs/src/Astro/Blog/Layout/PureColumn.js 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 ); +})();