comment.js 1.3 KB

123456789101112131415161718192021222324252627282930313233
  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 comment created_element"> <i class="ui icon small quote left"></i> <span class="span_comment_text" "> '+LocalizedStrings.getUI('text_comment')+' </span></div>');
  6. }
  7. export function renderCommand (command, function_obj) {
  8. 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>');
  9. el.data('command', command);
  10. addHandlers(command, function_obj, el);
  11. renderTextComment(command, function_obj, el);
  12. return el;
  13. }
  14. function renderTextComment (command, function_obj, el) {
  15. VariableValueMenu.renderMenu(command, command.comment_text, el.find('.var_value_menu_div'), function_obj, 20);
  16. }
  17. function addHandlers (command, function_obj, comment_dom) {
  18. comment_dom.find('.button_remove_command').on('click', function() {
  19. if (CommandsManagement.removeCommand(command, function_obj, comment_dom)) {
  20. comment_dom.fadeOut(400, function() {
  21. comment_dom.remove();
  22. });
  23. }
  24. });
  25. }