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 CommandsManagement from '../commands'; import * as ConditionalExpressionManagement from './conditional_expression'; export function createFloatingCommand () { return $('
if (x < 1) { }
'); } export function renderCommand (command, function_obj) { var ret = ''; ret += '
'; ret += ' ' + LocalizedStrings.getUI('text_if') + ''; ret += ' (
) '; ret += ' '; ret += '
'; ret += '
'; ret += '
' + LocalizedStrings.getUI('text_else') + ' '; ret += '
'; ret += '
'; ret += '
'; ret += '
'; var el = $(ret); el.data('command', command); el.find('.block_commands').data('command', command); el.find('.data_block_if').data('command', command); el.find('.data_block_else').data('command', command); addHandlers(command, function_obj, el); ConditionalExpressionManagement.renderExpression(command, command.expression, function_obj, el.find('.conditional_expression')); if (command.commands_block) { for (var j = 0; j < command.commands_block.length; j++) { CommandsManagement.renderCommand(command.commands_block[j], $(el.find('.commands_if')[0]), 3, function_obj); } } if (command.commands_else) { for (var j = 0; j < command.commands_else.length; j++) { CommandsManagement.renderCommand(command.commands_else[j], $(el.find('.commands_else')[0]), 3, function_obj); } } return el; } function addHandlers (command, function_obj, iftrue_dom) { iftrue_dom.find('.button_remove_command').on('click', function() { if (CommandsManagement.removeCommand(command, function_obj, iftrue_dom)) { iftrue_dom.remove(); } }); }