
( function( $, d, undefined )
{
    
    d._ = window.console.debug.bind( window.console );
    
    d.init = function()
    {
        d.initFontSize();
        d.initHelp();
        d.initManager();
    };
    
    d.initManager = function()
    {
        this.manager = new d.Manager();
        
        this.manager.initialize( this.initView.bind( this ) );
    };
    
    d.initFontSize = ( function()
    {
        var $sizes = $( '#fontSize > a' );
        
        return function()
        {
            if( localStorage.fontSize )
            {
                document.body.className = localStorage.fontSize;
                
                $sizes.removeClass( 'selected' );
                $sizes.parent().find( 'a[data-size="' + localStorage.fontSize + '"]' ).addClass( 'selected' );
            }
            
            $sizes.bind( 'click', function( e )
            {
                var $this = $( e.target );
                
                $this.siblings().removeClass( 'selected' );
                $this.addClass( 'selected' );
                
                document.body.className = localStorage.fontSize = $this.attr( 'data-size' );
            } );
        }
    } )();
    
    d.initView = function()
    {
        var self = this;
        
        this.manager.hasBookmarks( function( hasBoomarks )
        {
            if( hasBoomarks )
            {
                self.view = new d.View( $( '#bookmarks' ), self.manager );
                self.view.display();
            }
            else
            {
                self.showHelp();
            }
        } );
    };
    
    d.initHelp = function()
    {
        $( '#help' ).bind( 'click', d.toggleHelp.bind( d ) );
    };
    
    d.showHelp = function()
    {
        $( '#getstarted' ).show();
        $( '#bookmarks' ).hide();
    };
    
    d.toggleHelp = function()
    {
        $( '#getstarted' ).toggle();
        $( '#bookmarks' ).toggle();
    };
    
    d.init();
    
} )( Zepto, this.Dashboard );


( function( mdash, $ )
{
    
    $( document ).ready( function()
    {
        var manager  = new mdash.Manager(),
            fontCtrl = new mdash.FontCtrl( $( '#fontctrl > a' ) ),
            helpCtrl = new mdash.HelpCtrl( $( '#helpctrl' ), $( '#getstarted' ), $( '#bookmarks' ) );
        
        manager.init( function()
        {
            fontCtrl.init();
            helpCtrl.init();
            
            var leftColumn  = new mdash.Column( $( '#bookmarks > .left' ) ),
                rightColumn = new mdash.Column( $( '#bookmarks > .right' ) );
                
            manager.getSections( 'left', function( sections )
            {
                leftColumn.sections = sections;
                leftColumn.render();
            } );
            
            manager.getSections( 'right', function( sections )
            {
                rightColumn.sections = sections;
                rightColumn.render();
            } );
        } );
        
    } );
    
} )( window.mdash, Zepto );

Rewrite the main script according to the whole refactoring.
Rewrite the main script according to the whole refactoring.
