src/menu.js
function create(cfg = {}) {
    if (created) {
        console.warn('An instance of menu already exists, skipping creation...');
        return;
    }
    // defaults
    _.assign(defaults, cfg);
    
    console.log('creating menu...', defaults);
    
    // set attributes to the menubar element
    setAttributes(menuBarEl, defaults.attributes);
    // set attributes to the menubarTemplate element
    setAttributes(menuBarTpl, defaults.rootTemplateAttributes);
    // add all items to the menubar
    _.each(defaults.items, (item) => addItem(item));
    // indicate done
    created = true;

    return doc;
}
function create(cfg = {}) {
    if (created) {
        console.warn('An instance of menu already exists, skipping creation...');
        return;
    }
    // defaults
    _.assign(defaults, cfg);
    
    console.log('creating menu...', defaults);
    
    // set attributes to the menubar element
    setAttributes(menuBarEl, defaults.attributes);
    // set attributes to the menubarTemplate element
    setAttributes(menuBarTpl, defaults.rootTemplateAttributes);
    // add all items to the menubar
    _.each(defaults.items, (item) => addItem(item));
    // indicate done
    created = true;

    return doc;
}
function create ( cfg = { } ) { if ( created ) { console . warn ( 'An instance of menu already exists, skipping creation...' ) ; return ; } // defaults _ . assign ( defaults , cfg ) ; console . log ( 'creating menu...' , defaults ) ; // set attributes to the menubar element setAttributes ( menuBarEl , defaults . attributes ) ; // set attributes to the menubarTemplate element setAttributes ( menuBarTpl , defaults . rootTemplateAttributes ) ; // add all items to the menubar _ . each ( defaults . items , ( item ) => addItem ( item ) ) ; // indicate done created = true ; return doc ; }
Generates a menu from the configuration object.

@example
ATV.Menu.create({
attributes: {},  // menuBar attributes
rootTemplateAttributes: {}, // menuBarTemplate attributes
items: [{
id: 'search',
name: 'Search',
page: SearchPage
}, {
id: 'homepage',
name: 'Home',
page: HomePage,
attributes: {
autoHighlight: true // auto highlight on navigate
}
}, {
id: 'movies',
name: 'Movies',
page: MoviesPage
}, {
id: 'tvshows',
name: 'TV Shows',
page: TVShowsPage
}]
});

@inner
@alias module:menu.create

@param  {Object} cfg 		Menu related configurations
@return {Document}     		The created menu document
Generates a menu from the configuration object .