functioncall-sidebar.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import $ from 'jquery';
  2. import { Types } from '../types';
  3. import * as Models from '../ivprog_elements_sidebar';
  4. import { LocalizedStrings } from '../../services/localizedStringsService';
  5. import * as GlobalsManagement from '../globals';
  6. import * as VariablesManagement from '../variables';
  7. import * as VariableValueMenu from './variable_value_menu';
  8. import * as CommandsManagement from '../commands';
  9. export function createFloatingCommand () {
  10. return $('<div class="ui functioncall created_element"> <i class="hand point right icon"></i> <span> funcao() </span></div>');
  11. }
  12. export function renderCommand (command, function_obj) {
  13. var el = $('<div class="ui functioncall command_container"> <i class="hand point right icon command_drag"></i> <i class="ui icon times red button_remove_command"></i> <div class="var_value_menu_div"></div> </div>');
  14. el.data('command', command);
  15. if (command.function_called) {
  16. console.log("command.function_called");
  17. }
  18. VariableValueMenu.renderMenu(command, command.function_called, el.find('.var_value_menu_div'), function_obj);
  19. addHandlers(command, function_obj, el);
  20. return el;
  21. }
  22. function addHandlers (command, function_obj, functioncall_dom) {
  23. functioncall_dom.find('.button_remove_command').on('click', function() {
  24. if (CommandsManagement.removeCommand(command, function_obj, functioncall_dom)) {
  25. functioncall_dom.remove();
  26. }
  27. });
  28. }