1
0

comment.js 1.5 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 VariableValueMenu from './variable_value_menu';
  8. import * as CommandsManagement from '../commands';
  9. export function createFloatingCommand () {
  10. return $('<div class="ui comment created_element"> <i class="ui icon small quote left"></i> <span class="span_comment_text" "> '+LocalizedStrings.getUI('text_comment')+' </span></div>');
  11. }
  12. export function renderCommand (command, function_obj) {
  13. var el = $('<div class="ui comment command_container"> <i class="ui icon small quote left command_drag"></i> <i class="ui icon times red button_remove_command"></i> <div class="var_value_menu_div"></div> <div class="div_comment_text">'+'</div> </div>');
  14. el.data('command', command);
  15. addHandlers(command, function_obj, el);
  16. renderTextComment(command, function_obj, el);
  17. return el;
  18. }
  19. function renderTextComment (command, function_obj, el) {
  20. VariableValueMenu.renderMenu(command, command.comment_text, el.find('.var_value_menu_div'), function_obj, 20);
  21. }
  22. function addHandlers (command, function_obj, comment_dom) {
  23. comment_dom.find('.button_remove_command').on('click', function() {
  24. if (CommandsManagement.removeCommand(command, function_obj, comment_dom)) {
  25. comment_dom.fadeOut(400, function() {
  26. comment_dom.remove();
  27. });
  28. }
  29. });
  30. }