Early album draft

This commit is contained in:
2015-09-30 00:46:54 +08:00
parent be4d5c6ce2
commit 3e8e6362b2
8 changed files with 376 additions and 135 deletions
@@ -0,0 +1,92 @@
(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 )
{
// remove loading bubbles
while( ostage.hasChildNodes() ) ostage.removeChild( ostage.firstChild );
/** @type {_AstJson_.SiteFile} */
var finfo = JSON.parse( obj );
var files = finfo.files;
var l = files.length;
for( var i = 0; i < l; i ++ )
{
/** @type {_AstJson_.SiteFile} */
var file = files[i];
var uuid = Perf.uuid;
ostage.appendChild(
Dand.wrapna( "div", [
new IKey( "id", uuid )
, new DataKey( "size", "medium" )
] )
);
Cycle.next( function()
{
new SiteFile( this.id, this.hash );
}.bind({ id: uuid, hash: file.hash }) );
}
console.log( finfo );
};
var loadFailed = function( obj )
{
console.log( obj );
};
sf.loadInfo( applyStructure, loadFailed );
};
var init = function()
{
config = Conf.get( "SiteFile" );
if( config )
{
for( var i in config.files )
{
var f = config.files[i];
new Album( f[0], f[1] );
}
}
};
Bootstrap.regInit( init );
ns[ NS_EXPORT ]( EX_CLASS, "Album", Album );
})();