(function(){ var ns = __namespace( "Astro.Blog.AstroEdit" ); /** @type {System.utils} */ var utils = __import( "System.utils" ); /** @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.Flag} */ var Flag = __import( "Astro.Blog.AstroEdit.Flag" ); /** @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" ); /** @type {Components.Vim.VimArea} */ var VimArea = __import( "Components.Vim.VimArea" ); // calls the smart bar var SmartInput = __import( "Astro.Blog.AstroEdit.SmartInput" ); // __import( "Astro.Blog.SharedStyle" ); CSS_RESERVATION var wh, ww, cw, html, article; var init = function () { //// Component initializations /** @type {_AstConf_.AstroEdit} */ var a_conf = Config.get( "AstroEdit" ); var base_path = utils.siteProto( 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 , [ new Flag( "tags", "ae_tags", a_conf.paths.tags ) , new Flag( "section", "ae_secs", a_conf.paths.sections ) ] ); // Article modules new Draft( article, a_conf.paths.get_drafts ); var Vis = new Visualizer( article , Dand.id( "ae_visual_snippets" ) , Config.get( "ServiceUri" ) ); new SmartInput( Vis ); // Independent modules new Uploader( a_conf.paths.set_file ); new SiteLibrary( base_path , 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(); VimTrigger(); }; var VimTrigger = function() { var f10Binding = function ( e ) { e = e || window.event; if ( e.keyCode ) code = e.keyCode; else if ( e.which ) code = e.which; if ( code == 121 ) { e.preventDefault(); var node = document.activeElement; if( node.nodeName == "TEXTAREA" ) { new VimArea( node ); node.blur(); node.focus(); } } }; //Attach the var with the event = function if(document.addEventListener) document.addEventListener('keydown', f10Binding, false); else if(document.attachEvent) document.attachEvent('onkeydown', f10Binding); else document.onkeydown = f10Binding; }; var adjustLayout = function () { ww = html.clientWidth; wh = html.clientHeight; cw = ww - 300; Dand.id("ae_body").style.width = String(cw) + "px"; }; Bootstrap.regInit( init ); })();