reader.js 1.3 KB

123456789101112131415161718192021222324252627282930
  1. import { LocalizedStrings } from '../../services/localizedStringsService';
  2. import * as VariableValueMenu from './variable_value_menu';
  3. import * as CommandsManagement from '../commands';
  4. export function createFloatingCommand () {
  5. return $('<div class="ui reader created_element"> <i class="ui icon small download"></i> <span> '+LocalizedStrings.getUI('text_command_read')+' var </span></div>');
  6. }
  7. export function renderCommand (command, function_obj) {
  8. 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>';
  9. el = $(el);
  10. el.data('command', command);
  11. VariableValueMenu.renderMenu(command, command.variable_value_menu, el.find('.var_value_menu_div'), function_obj);
  12. addHandlers(command, function_obj, el);
  13. return el;
  14. }
  15. function addHandlers (command, function_obj, reader_dom) {
  16. reader_dom.find('.button_remove_command').on('click', function() {
  17. if (CommandsManagement.removeCommand(command, function_obj, reader_dom)) {
  18. reader_dom.fadeOut(400, function() {
  19. reader_dom.remove();
  20. });
  21. }
  22. });
  23. }