// iVProg - www.usp.br/line/ivprog
// LInE - Free Education, Private Data
import { LocalizedStrings } from '../../services/localizedStringsService';
import * as VariableValueMenu from './variable_value_menu';
import * as CommandsManagement from '../commands';
export function createFloatingCommand () {
return $(
'
'
);
}
export function renderCommand (command, function_obj) {
var el = $(
' ' +
' ' +
' ' +
'
' + "\n"
);
el.data('command', command);
addHandlers(command, function_obj, el);
renderTextComment(command, function_obj, el);
return el;
}
function renderTextComment (command, function_obj, el) {
//x VariableValueMenu.renderMenu(command, command.comment_text, el.find('.var_value_menu_div'), function_obj, 20);
let commentText = "";
if (command.comment_text) {
if (typeof command.comment_text === "object") {
commentText = command.comment_text.content || command.comment_text.value || "";
} else if (typeof command.comment_text === "string") {
commentText = command.comment_text;
}
}
if (!commentText) {
commentText = command.value || command.comment || command._text || "";
}
if (commentText) {
el.find(".var_value_menu_div").hide();
el.find(".div_comment_text").text(commentText).show();
} else {
el.find(".var_value_menu_div").hide();
el.find(".div_comment_text").text(LocalizedStrings.getUI("text_comment")).show();
}
}
function addHandlers (command, function_obj, comment_dom) {
comment_dom.find('.button_remove_command').on('click', function() {
if (CommandsManagement.removeCommand(command, function_obj, comment_dom)) {
comment_dom.fadeOut(400, function() {
comment_dom.remove();
});
}
});
}