reader.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334
  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 reader created_element"> <i class="ui icon small download"></i> <span> '+LocalizedStrings.getUI('text_command_read')+' var </span></div>');
  11. }
  12. export function renderCommand (command, function_obj) {
  13. var el = '<div class="ui reader command_container"> <i class="ui icon small download command_drag"></i> <i class="ui icon times red button_remove_command"></i> <span class="span_command_spec">'+LocalizedStrings.getUI('text_command_read')+' ( </span> <div class="var_value_menu_div"></div> <span class="close_parentheses span_command_spec">)</span> </div>';
  14. el = $(el);
  15. el.data('command', command);
  16. VariableValueMenu.renderMenu(command, command.variable_value_menu, el.find('.var_value_menu_div'), function_obj);
  17. addHandlers(command, function_obj, el);
  18. return el;
  19. }
  20. function addHandlers (command, function_obj, reader_dom) {
  21. reader_dom.find('.button_remove_command').on('click', function() {
  22. if (CommandsManagement.removeCommand(command, function_obj, reader_dom)) {
  23. reader_dom.remove();
  24. }
  25. });
  26. }