98 lines
2.4 KiB
JavaScript
98 lines
2.4 KiB
JavaScript
(function(){
|
|
var ns = __namespace( "Astro.Blog.Components" );
|
|
|
|
/** @type {System.Cycle} */
|
|
var Cycle = __import( "System.Cycle" );
|
|
/** @type {System.utils.IKey} */
|
|
var IKey = __import( "System.utils.IKey" );
|
|
/** @type {System.utils.DataKey} */
|
|
var DataKey = __import( "System.utils.DataKey" );
|
|
/** @type {Dandelion} */
|
|
var Dand = __import( "Dandelion" );
|
|
/** @type {Dandelion.IDOMElement} */
|
|
var IDOMElement = __import( "Dandelion.IDOMElement" );
|
|
/** @type {Astro.Bootstrap} */
|
|
var Bootstrap = __import( "Astro.Bootstrap" );
|
|
/** @type {System.utils.Perf} **/
|
|
var Perf = __import( "System.utils.Perf" );
|
|
/** @type {Astro.Blog.Config} */
|
|
var Conf = __import( "Astro.Blog.Config" );
|
|
|
|
/** @type {_AstConf_.SiteFile} */
|
|
var config = null;
|
|
|
|
var SiteFile = ns[ NS_INVOKE ]( "SiteFile" );
|
|
|
|
var Album = function ( id, hash )
|
|
{
|
|
if( !config ) throw new Error( "config is not defined" );
|
|
var stage = Dand.id( id, true );
|
|
|
|
var sf = new SiteFile( id, hash );
|
|
if( sf.type != "album" ) return;
|
|
|
|
var ostage = stage.element;
|
|
|
|
var applyStructure = function( obj )
|
|
{
|
|
/** @type {_AstJson_.SiteFile} */
|
|
var finfo = JSON.parse( obj );
|
|
|
|
var files = finfo.files;
|
|
var l = files.length;
|
|
|
|
// XXX: Not traditional!
|
|
// Maximum of 4 for listing
|
|
if( ostage.parentNode.className == "h_img" && 4 < l )
|
|
{
|
|
l = 4;
|
|
}
|
|
|
|
for( var i = 0; i < l; i ++ )
|
|
{
|
|
/** @type {_AstJson_.SiteFile} */
|
|
var file = files[i];
|
|
var uuid = Perf.uuid;
|
|
|
|
ostage.appendChild( Dand.wrapne(
|
|
"div"
|
|
, Dand.wrapna( "img", [
|
|
new IKey( "src", "data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" )
|
|
] )
|
|
, [ new IKey( "id", uuid ), new DataKey( "size", "medium" ) ]
|
|
) );
|
|
|
|
Cycle.next( function()
|
|
{
|
|
new SiteFile( this.id, this.info.hash, this.info );
|
|
}.bind({ id: uuid, info: file }) );
|
|
}
|
|
};
|
|
|
|
var loadFailed = function( obj )
|
|
{
|
|
console.log( obj );
|
|
};
|
|
|
|
sf.loadInfo( applyStructure, loadFailed );
|
|
};
|
|
|
|
var init = function()
|
|
{
|
|
config = Conf.get( "SiteFile" );
|
|
if( config )
|
|
{
|
|
var SFOs = Conf.get( "SFObjects" );
|
|
for( var i in SFOs )
|
|
{
|
|
var f = SFOs[i];
|
|
new Album( f[0], f[1] );
|
|
}
|
|
}
|
|
};
|
|
|
|
Bootstrap.regInit( init );
|
|
|
|
ns[ NS_EXPORT ]( EX_CLASS, "Album", Album );
|
|
})();
|