AstroJS/botanjs/src/Astro/Starfall/Layout/MainFrame.js
2016-05-31 23:32:39 +08:00

62 lines
1.9 KiB
JavaScript

(function(){
var ns = __namespace( "Astro.Starfall.Layout.MainFrame" );
/** @type {Dandelion} */
var Dand = __import( "Dandelion" );
/** @type {Dandelion.IDOMObject} */
var IDOMObject = __import( "Dandelion.IDOMObject" );
/** @type {Dandelion.Window} */
var wsupp = __import( "Dandelion.Window" );
/** @type {System.Debug} */
var debug = __import( "System.Debug" );
/** @type {Astro.Bootstrap} */
var Bootstrap = __import( "Astro.Bootstrap" );
// __import( "Astro.Starfall.Element.Layer" ); CSS_RESERVATION
var init = function ()
{
console.log( "HERE" );
// Footer at bottom
var padder = Dand.wrap();
var begin_wrapper = Dand.id( "begin-wrapper" );
var content_wrapper = Dand.id( "mbody" );
var footer = Dand.tag( "footer" );
var fhorizon = Dand.id( "fhorizon" );
if( footer.length )
{
footer = footer[0];
var fheight = footer.scrollHeight || footer.offsetHeight;
var hheight = fhorizon.scrollHeight || fhorizon.offsetHeight;
padder.style.height = ( fheight + hheight ) + "px";
begin_wrapper.style.marginBottom = "-" + fheight + "px";
}
content_wrapper.appendChild( padder );
IDOMObject( window ).addEventListener( "Resize", responsify );
responsify( null, true );
};
var rspd_ratio = 0;
var responsify = function( e, override )
{
// Ratio changes would trigger content
var ratio = wsupp.clientWidth / wsupp.clientHeight;
// Swap only on ration changes from 1 < x OR x < 1
if( ( ratio < 1.2 && 1.2 < rspd_ratio ) || ( 1.2 < ratio && rspd_ratio < 1.2 ) || override )
{
rspd_ratio = ratio;
debug.Info( "Responsive Event: R = " + ratio );
BotanJS.dispatchEvent( new BotanEvent( "Responsive", { "ratio": ratio } ) );
}
};
Bootstrap.regInit( init );
})();