penguin/AstroJS

Javascript framework for my blog

botanjs/src/Astro/Blog/Components/Footnote.js

raw ยท 1229 bytes

(function(){
	var ns = __namespace( "Astro.Blog.Components.Footnote" );
	/** @type {Dandelion} */
	var Dand                             = __import( "Dandelion" );
	/** @type {Dandelion.IDOMElement} */
	var IDOMElement                      = __import( "Dandelion.IDOMElement" );
	/** @type {Astro.Bootstrap} */
	var Bootstrap                        = __import( "Astro.Bootstrap" );
	/** @type {Astro.Blog.Config} */
	var Config                           = __import( "Astro.Blog.Config" );
	/** @type {Astro.utils.Date} */
	var XDate                            = __import( "Astro.utils.Date" );

	/** @param {Dandelion.IDOMElement} elem */
	var Footnote = function( elem )
	{
		var jumpers = Dand.glass( "ft", true );
		if( !jumpers.length ) return;

		var notes = Dand.glass( "footnote", true )[0];

		jumpers.forEach( function( e ) {

			var a = e.first( 1 );
			IDOMElement( a ).addEventListener( "Click", function()
			{
				var clicked = a.hash.substr( 1 );
				notes.foreach( 1, function( e ) {
					if( e.id == clicked )
					{
						e.setAttribute( "focused", 1 );
					}
					else
					{
						e.removeAttribute( "focused" );
					}
				});
			});
		} );
	};

	Bootstrap.regInit(function() {
		new Footnote();
	});

})();