whiletrue.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  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 CommandsManagement from '../commands';
  8. export function createFloatingCommand () {
  9. return $('<div class="ui whiletrue created_element"> <i class="ui icon small sync"></i> <span> enquanto(x < 10) { } </span></div>');
  10. }
  11. export function renderCommand (command, function_obj) {
  12. var ret = '';
  13. ret += '<div class="ui whiletrue command_container"> <i class="ui icon small random command_drag"></i> <i class="ui icon times red button_remove_command"></i> <span> enquanto (x < 10) { </span>';
  14. ret += '<div class="ui block_commands">';
  15. ret += '</div>';
  16. ret += '<span> }</span>';
  17. ret += '</div>';
  18. var el = $(ret);
  19. el.data('command', command);
  20. addHandlers(command, function_obj, el);
  21. return el;
  22. }
  23. function addHandlers (command, function_obj, whiletrue_dom) {
  24. whiletrue_dom.find('.button_remove_command').on('click', function() {
  25. if (CommandsManagement.removeCommand(command, function_obj, whiletrue_dom)) {
  26. whiletrue_dom.remove();
  27. }
  28. });
  29. }