import $ from 'jquery'; import { Types } from '../types'; import * as Models from '../ivprog_elements'; import { LocalizedStrings } from '../../services/localizedStringsService'; import * as GlobalsManagement from '../globals'; import * as VariablesManagement from '../variables'; import * as VariableValueMenu from './variable_value_menu'; import * as VariableValueMenuManagement from './variable_value_menu'; export function createFloatingCommand () { return $('
x = 1 + 1
'); } export function renderCommand (command, function_obj) { var el = $('
'+LocalizedStrings.getUI('text_receives')+' ' + '
'); $(el).data('command', command); VariableValueMenu.renderMenu(command, command.variable, $(el).find('.var_attributed'), function_obj); VariableValueMenu.renderMenu(command, command.expression, $(el).find('.expression_operand_1'), function_obj); return el; } export function renderMenuOperations (command, ref_object, dom_object, menu_var_or_value, function_obj, variable_selected) { if ($(dom_object).hasClass('var_attributed')) { return; } $(dom_object).find('.context_menu_clear').remove(); var menu_operations = ''; menu_operations = $(menu_operations); $(dom_object).append(menu_operations); $(menu_operations).dropdown({ onChange: function(value, text, $selectedItem) { switch ($($selectedItem).data('option')) { case "clear": $(dom_object).text(''); VariableValueMenu.renderMenu(command, ref_object, dom_object, function_obj); break; default: createExpressionAround(command, ref_object, dom_object, function_obj); $(menu_operations).find('.text').text(''); } } }); } function createExpressionAround (command, ref_object, dom_object, function_obj) { $(' ( ').insertBefore(dom_object); $(' ) ').insertAfter(dom_object); VariableValueMenu.renderMenu(command, new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all, null, null, null, true), dom_object, function_obj); }