dowhiletrue.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  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 dowhiletrue created_element"> <i class="ui icon small sync"></i> <span> faça {<br>} enquanto(x < 10) </span></div>');
  10. }
  11. export function renderCommand (command, function_obj) {
  12. var ret = '';
  13. ret += '<div class="ui dowhiletrue command_container"> <i class="ui icon small random command_drag"></i> <i class="ui icon times red button_remove_command"></i> <span> faça { </span>';
  14. ret += '<div class="ui block_commands" data-subblock="" data-idcommand="">';
  15. ret += '</div>';
  16. ret += '<span> } enquanto (x < 10); </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, dowhiletrue_dom) {
  24. dowhiletrue_dom.find('.button_remove_command').on('click', function() {
  25. if (CommandsManagement.removeCommand(command, function_obj, dowhiletrue_dom)) {
  26. dowhiletrue_dom.remove();
  27. }
  28. });
  29. }