/**
* @license
* Visual Blocks Editor
*
* Copyright 2011 Google Inc.
* https://blockly.googlecode.com/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @fileoverview Functionality for the right-click context menus.
* @author fraser@google.com (Neil Fraser)
*/
'use strict';
goog.provide('Blockly.ContextMenu');
/**
* Horizontal padding on either side of each option.
*/
Blockly.ContextMenu.X_PADDING = 20;
/**
* Vertical height of each option.
*/
Blockly.ContextMenu.Y_HEIGHT = 20;
/**
* Is a context menu currently showing?
*/
Blockly.ContextMenu.visible = false;
/**
* Creates the context menu's DOM. Only needs to be called once.
* @return {!SVGGElement} The context menu's SVG group.
*/
Blockly.ContextMenu.createDom = function() {
/*
*/
var svgGroup = /** @type {!SVGGElement} */ (
Blockly.createSvgElement('g', {'class': 'blocklyHidden'}, null));
Blockly.ContextMenu.svgGroup = svgGroup;
Blockly.ContextMenu.svgShadow = Blockly.createSvgElement('rect',
{'class': 'blocklyContextMenuShadow',
'x': 2, 'y': -2, 'rx': 4, 'ry': 4}, svgGroup);
Blockly.ContextMenu.svgBackground = Blockly.createSvgElement('rect',
{'class': 'blocklyContextMenuBackground',
'y': -4, 'rx': 4, 'ry': 4}, svgGroup);
Blockly.ContextMenu.svgOptions = Blockly.createSvgElement('g',
{'class': 'blocklyContextMenuOptions'}, svgGroup);
return svgGroup;
};
/**
* Construct the menu based on the list of options and show the menu.
* @param {!Object} xy Coordinates of anchor point, contains x and y properties.
* @param {!Array.