Introducing new responsive classes

This commit is contained in:
斟酌 鵬兄 2017-09-26 13:01:10 +08:00
parent 6945834de5
commit 6c72ee9def
6 changed files with 23 additions and 95 deletions

View File

@ -704,17 +704,6 @@
} }
} }
var stage = c_body.parentNode
BotanJS.addEventListener( "Responsive"
/** e @type {Astro.Starfall.Events.Responsive} */
, function( e ) {
e.data.ratio < 1
? stage.style.width = "100%"
: stage.style.width = ""
;
}
);
if( !loggedIn ) if( !loggedIn )
{ {
var limit = 5; var limit = 5;

View File

@ -10,22 +10,11 @@
text-align: right; text-align: right;
} }
[data-narrow] .h_info {
position: relative;
width: auto;
text-align: center;
}
.h_body { .h_body {
margin-left: 7em; margin-left: 7em;
margin-right: 0.5em; margin-right: 0.5em;
} }
[data-narrow] .h_body
, [data-narrow] .h_bodyWrapper {
margin: 0 auto;
}
.h_bodyWrapper { .h_bodyWrapper {
border: 1px solid #D4D7C9; border: 1px solid #D4D7C9;
background-color: #FAFAFA; background-color: #FAFAFA;
@ -57,7 +46,6 @@
width: 80px; width: 80px;
height: 80px; height: 80px;
} }
[data-narrow] .h_avatarWrapper { display: inline; }
.h_avatar, .a_avatarWrapper { .h_avatar, .a_avatarWrapper {
width: 80px; width: 80px;

View File

@ -34,26 +34,6 @@
} }
content_wrapper.appendChild( padder ); 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 ); Bootstrap.regInit( init );

View File

@ -1,19 +1,22 @@
.contentWrap { /* Responsive class: if smaller than N em */
position: relative; @media print, screen and (max-width: 79em) {
width: 100%; .rs .rs-w100 { width: 100%; }
} .rs .rs-child-w100 > div { width: 100%; }
.rs .rs-auto-margin { margin: 0 auto; }
#dockleft { .rs .rs-auto-width { width: auto; }
position: absolute; .rs .rs-text-center { text-align: center; }
z-index: 0; .rs .rs-rel-on { position: relative; }
.rs .rs-inline-on { display: inline; }
} }
.main { .main {
/* background-color: #FAFAFA; */
vertical-align: top; vertical-align: top;
min-width: 70%; min-width: 70%;
position: relative; position: relative;
/*background-color: #FAFAFA;*/
/*border-right: #76400C solid 0.2em;*/
} }
/** /**
@ -32,12 +35,11 @@ ul.breadcrumb > li.sep:after { content: "\2022"; }
min-width: 30%; min-width: 30%;
} }
#dockright { .dockright {
position: relative; position: relative;
/*border-right: #76400C solid 0.2em;*/
} }
#dockright > div { .dockright > div {
float: right; float: right;
margin: 0 -.3em; margin: 0 -.3em;
@ -50,7 +52,7 @@ ul.breadcrumb > li.sep:after { content: "\2022"; }
min-height: 7px; min-height: 7px;
} }
#extend_sec, #dockright { #extend_sec, .dockright {
/* Same as dockright */ /* Same as dockright */
width: 100%; width: 100%;
} }

View File

@ -1,32 +1 @@
(function(){ // __namespace( "Astro.Starfall.Layout.TwoColumn" );
var ns = __namespace( "Astro.Starfall.Layout.TwoColumn" );
/** @type {Dandelion} */
var Dand = __import( "Dandelion" );
/** @type {Astro.Bootstrap} */
var Bootstrap = __import( "Astro.Bootstrap" );
var init = function ()
{
var rspd = Dand.id( "dockright", true );
if( rspd )
{
BotanJS.addEventListener( "Responsive"
/** e @type {Astro.Starfall.Events.Responsive} */
, function( e ) {
if( e.data.ratio < 1.2 )
{
document.body.setAttribute( "data-narrow", 1 );
rspd.foreach( document.ELEMENT_NODE, function( elem ) { elem.style.width = "100%"; } );
}
else
{
document.body.removeAttribute( "data-narrow" );
rspd.foreach( document.ELEMENT_NODE, function( elem ) { elem.style.width = ""; } );
}
});
}
};
Bootstrap.regInit( init );
})();

View File

@ -115,14 +115,14 @@
// returns a suffix string // returns a suffix string
// st, nd, rd, th // st, nd, rd, th
var getOrdinalSuffix = function(day) var getOrdinalSuffix = function( day )
{ {
if (day < 4 || ( 20 < day && day < 24 )) { if( day < 1 || 31 < day )
if (day == 1 || day == 21) return "st"; throw new Error( "Day is out of range 1 <= day <= 31" );
else if (day == 2 || day == 22) return "nd";
else if (day == 3 || day == 23) return "rd"; if ( day == 1 || day == 21 || day == 31 ) return "st";
} else if ( day == 2 || day == 22 ) return "nd";
else if (day == 31) return "st"; else if ( day == 3 || day == 23 ) return "rd";
return "th"; return "th";
}; };