1
0

return.js 1.4 KB

1234567891011121314151617181920212223242526272829303132
  1. import $ from 'jquery';
  2. import { Types } from '../types';
  3. import * as Models from '../ivprog_elements';
  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 return created_element"> <i class="ui icon small reply"></i> <span> '+LocalizedStrings.getUI('text_return')+' </span></div>');
  11. }
  12. export function renderCommand (command, function_obj) {
  13. var el = $('<div class="ui return command_container"> <i class="ui icon small reply command_drag"></i> <i class="ui icon times red button_remove_command"></i> <span class="span_command_spec"> '+LocalizedStrings.getUI('text_return')+' </span> <div class="var_value_menu_div"></div></div>');
  14. el.data('command', command);
  15. addHandlers(command, function_obj, el);
  16. VariableValueMenu.renderMenu(command, command.variable_value_menu, el.find('.var_value_menu_div'), function_obj);
  17. return el;
  18. }
  19. function addHandlers (command, function_obj, return_dom) {
  20. return_dom.find('.button_remove_command').on('click', function() {
  21. if (CommandsManagement.removeCommand(command, function_obj, return_dom)) {
  22. return_dom.fadeOut();
  23. }
  24. });
  25. }