forked from Botanical/BotanJS
100 lines
3.1 KiB
JavaScript
100 lines
3.1 KiB
JavaScript
(function(){
|
|
var ns = __namespace( "Astro.Blog.AstroEdit" );
|
|
|
|
/** @type {System.Cycle} */
|
|
var Cycle = __import( "System.Cycle" );
|
|
/** @type {Dandelion} */
|
|
var Dand = __import( "Dandelion" );
|
|
/** @type {Astro.Bootstrap} */
|
|
var Bootstrap = __import( "Astro.Bootstrap" );
|
|
/** @type {Astro.Blog.Config} */
|
|
var Config = __import( "Astro.Blog.Config" );
|
|
/** @type {Astro.Blog.AstroEdit.Article} */
|
|
var Article = __import( "Astro.Blog.AstroEdit.Article" );
|
|
/** @type {Astro.Blog.AstroEdit.Draft} */
|
|
var Draft = __import( "Astro.Blog.AstroEdit.Draft" );
|
|
/** @type {Astro.Blog.AstroEdit.Tag} */
|
|
var Tag = __import( "Astro.Blog.AstroEdit.Tag" );
|
|
/** @type {Astro.Blog.AstroEdit.Visualizer} */
|
|
var Visualizer = __import( "Astro.Blog.AstroEdit.Visualizer" );
|
|
/** @type {Astro.Blog.AstroEdit.Uploader} */
|
|
var Uploader = __import( "Astro.Blog.AstroEdit.Uploader" );
|
|
/** @type {Astro.Blog.AstroEdit.SiteLibrary} */
|
|
var SiteLibrary = __import( "Astro.Blog.AstroEdit.SiteLibrary" );
|
|
|
|
var wh, ww, cw, html, article;
|
|
|
|
var init = function ()
|
|
{
|
|
//// Component initializations
|
|
/** @type {_AstConf_.AstroEdit} */
|
|
var a_conf = Config.get( "AstroEdit" );
|
|
var base_path = Config.get( "BasePath" );
|
|
|
|
Cycle.next(
|
|
function()
|
|
{
|
|
article.load(
|
|
a_conf.article_id
|
|
, function( obj, id )
|
|
{
|
|
window.history.replaceState( obj, "", base_path + "astroedit/" + id + "/" );
|
|
}
|
|
);
|
|
}
|
|
);
|
|
|
|
article = new Article( a_conf.paths.set_article );
|
|
|
|
// Article modules
|
|
new Draft( article, a_conf.paths.get_drafts );
|
|
new Tag( article, a_conf.paths.tag_count );
|
|
new Visualizer(
|
|
article
|
|
, Dand.id( "ae_visual_snippets" )
|
|
, Config.get( "ServiceUri" )
|
|
);
|
|
|
|
// Independent modules
|
|
new Uploader( a_conf.paths.set_file );
|
|
new SiteLibrary(
|
|
Config.get( "BasePath" )
|
|
, a_conf.paths.get_files
|
|
, a_conf.paths.set_file
|
|
);
|
|
|
|
var title = Dand.id("ae_title");
|
|
var content = Dand.id("ae_content");
|
|
|
|
// content height
|
|
content.style.minHeight = String(screen.availHeight) + "px";
|
|
|
|
html = document.body.parentNode;
|
|
|
|
window.onresize = adjustLayout;
|
|
|
|
// Setting event handlers
|
|
title.onblur = content.onblur = function () { Dand.id("ae_bgdimmer").style.background = ""; };
|
|
content.onfocus = content.onfocus = function ()
|
|
{
|
|
Dand.id("ae_bgdimmer").style.background = "rgba(255, 255, 255, 0.2)";
|
|
};
|
|
|
|
Dand.id( "ae_publish_btn" ).onclick = function () { article.saveAndPublish(); };
|
|
Dand.id( "ae_preview_btn" ).onclick = function () { article.preview(); };
|
|
Dand.id( "ae_drop_btn" ).onclick = function () { article.drop(); };;
|
|
|
|
adjustLayout();
|
|
};
|
|
|
|
var adjustLayout = function ()
|
|
{
|
|
ww = html.clientWidth;
|
|
wh = html.clientHeight;
|
|
cw = ww - 300;
|
|
Dand.id("ae_body").style.width = String(cw) + "px";
|
|
};
|
|
|
|
Bootstrap.regInit( init );
|
|
})();
|