repeatNtimes.js 1.2 KB

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