{"size": 1378, "ext": "js", "max_stars_repo_path": "js/menu-container.js", "max_stars_repo_name": "cse-bristol/multiuser-file-menu", "max_stars_repo_stars_event_min_datetime": "2019-01-10T06:11:12.000Z", "max_stars_repo_stars_event_max_datetime": "2019-01-10T06:11:12.000Z", "max_issues_repo_path": "js/menu-container.js", "max_issues_repo_name": "cse-bristol/multiuser-file-menu", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "js/menu-container.js", "max_forks_repo_name": "cse-bristol/multiuser-file-menu", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 22.2258064516, "max_line_length": 121, "alphanum_fraction": 0.6240928882}
"use strict";

/*global module, require*/

var d3 = require("d3"),
    helpers = require("./helpers.js"),
    callbacks = helpers.callbackHandler;

/*
 Provides UI buttons based on buttonSpec, which should be an array containing objects generated using specify-buttons.js.
 */
module.exports = function(container, helpURL) {
    var onVisibilityChanged = callbacks(),

	updateVisibility = function(visible) {
	    file.datum(visible);

	    if (onVisibilityChanged) {
		onVisibilityChanged(visible);
	    }

	    file.classed("active", visible);
	    fileContents
		.classed("active", visible);
	},
	
	menu = container.append("div")
	    .attr("id", "menu"),

	menuBar = menu.append("div")
	    .attr("id", "menu-bar"),

	file = menuBar.append("div")
	    .attr("id", "file-menu")
	    .classed("menu-item", true)
	    .text("File")
	    .datum(false)
	    .on("click", function(d, i) {
		updateVisibility(!d);
	    }),

	help = menuBar.append("a")
	    .attr("id", "help")
	    .classed("menu-item", true)    
	    .text("? Help")
	    .attr("href", helpURL),

	fileContents = menu.append("div")
	    .attr("id", "file-menu-contents-wrapper")
	    .append("div")
	    .attr("id", "file-menu-contents");

    return {
	menuBar: menuBar,
	contentElement: fileContents,
	hide: function() {
	    updateVisibility(false);
	},
	onVisibilityChanged: onVisibilityChanged.add
    };
};
