penguin/AstroJS

Javascript framework for my blog

botanjs/src/Astro/Blog/Layout/Article/Control.js

raw ยท 1476 bytes

(function(){
	var ns = __namespace( "Astro.Blog.Layout.Article.Control" );

	/** @type {Dandelion} */
	var Dand                             = __import( "Dandelion" );
	/** @type {Dandelion.IDOMElement} */
	var IDOMElement                      = __import( "Dandelion.IDOMElement" );
	/** @type {Components.MessageBox} */
	var MessageBox                       = __import( "Components.MessageBox" );
	/** @type {Astro.Bootstrap} */
	var Bootstrap                        = __import( "Astro.Bootstrap" );
	/** @type {Astro.Blog.Config} */
	var config                           = __import( "Astro.Blog.Config" );

	var postData                         = __import( "System.Net.postData" );

	var aid = config.get( "ArticleID" );

	/** @type {_AstConf_.Control} */
	var control = config.get( "Control" );

	var init = function()
	{
		var delete_btn = Dand.id( "control_delete", true );
		if( delete_btn ) delete_btn.addEventListener( "Click", a_delete );
	};

	var a_delete = function ()
	{
		new MessageBox(
			"Confirm"
			, "Are you sure you want to delete this article?. Comments will also be deleted!"
			, "Yes", "No"
			, a_doDelete
		).show();
	};

	var a_doDelete = function ( confirmed )
	{
		var a_deleteSuccess = function ( args )
		{
			window.location.reload( true );
		}
		, a_deleteFailed = function ( args )
		{
		
		};

		if ( confirmed ) postData( control.action.del, { "article_id": aid }, a_deleteSuccess, a_deleteFailed );
	};

	Bootstrap.regInit( init );
})();