attribution.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528
  1. // iVProg - www.usp.br/line/ivprog
  2. // LInE - Free Education, Private Data
  3. import * as Models from '../ivprog_elements';
  4. import { LocalizedStrings } from '../../services/localizedStringsService';
  5. import * as VariableValueMenu from './variable_value_menu';
  6. import * as VariableValueMenuManagement from './variable_value_menu';
  7. import * as CommandsManagement from '../commands';
  8. import * as ExpressionManagement from './generic_expression';
  9. import * as CodeGenerator from '../code_generator';
  10. import { renderAlgorithm } from '../algorithm';
  11. export function createFloatingCommand () {
  12. return $('<div class="ui attribution created_element"> <i class="ui icon small arrow left"></i> <span> x <&#8212; 1 + 1 </span></div>');
  13. }
  14. export function renderCommand (command, function_obj) {
  15. var el = $('<div class="ui attribution command_container"><i class="ui icon small arrow left command_drag"></i> <i class="ui icon times red button_remove_command"></i> <div class="var_attributed"></div> <span class="text_attr_receives span_command_spec">'+LocalizedStrings.getUI('text_receives')+'</span> '
  16. + '<div class="expression_elements"></div> <span class="textual_expression"></span> <i class="ui icon i cursor button_write_expression"></i> <i class="ui icon unlock button_alternate_expression"></i> </div>');
  17. el.data('command', command);
  18. VariableValueMenu.renderMenu(command, command.variable, el.find('.var_attributed'), function_obj);
  19. if (!command.expression || command.expression.length < 1) {
  20. var exp = new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all, null, null, null, true);
  21. command.expression.push(exp);
  22. }
  23. addHandlers(command, function_obj, el);
  24. ExpressionManagement.renderExpression(command, function_obj, el.find('.expression_elements'), command.expression);
  25. if (command.lockexpression) {
  26. if (command.expression) {
  27. try {
  28. var text = CodeGenerator.elementExpressionCode(command.expression);
  29. if (text) {
  30. $(el.find('.expression_elements')[0]).toggle();
  31. $(el.find('.textual_expression')[0]).text(text);
  32. $(el.find('.textual_expression')[0]).toggle();
  33. $(el.find('.button_alternate_expression')[0]).toggleClass('unlock').toggleClass('lock');
  34. }
  35. } catch (e) {
  36. command.lockexpression = false;
  37. }
  38. }
  39. }
  40. el.find('.unlock').popup({
  41. content : LocalizedStrings.getUI("text_lock_expression"),
  42. delay: { show: 750, hide: 0 }
  43. });
  44. el.find('.lock').popup({
  45. content : LocalizedStrings.getUI("text_unlock_expression"),
  46. delay: { show: 750, hide: 0 }
  47. });
  48. el.find('.button_write_expression').popup({
  49. content : LocalizedStrings.getUI("text_edit_expression"),
  50. delay: { show: 750, hide: 0 }
  51. });
  52. return el;
  53. }
  54. export function manageExpressionElements (command, ref_object, dom_object, menu_var_or_value, function_obj, selectedItem, expression_element) {
  55. var index_to_move = expression_element.itens.indexOf(ref_object);
  56. switch (selectedItem.data('exp')) {
  57. case Models.EXPRESSION_ELEMENTS.exp_op_exp:
  58. var exp = new Models.ExpressionElement(Models.EXPRESSION_ELEMENTS.exp_op_exp, [expression_element.itens[index_to_move],
  59. Models.ARITHMETIC_TYPES.plus,
  60. new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all, null, null, null, true)]);
  61. expression_element.itens[index_to_move] = exp;
  62. break;
  63. case Models.EXPRESSION_ELEMENTS.op_exp:
  64. var exp = new Models.ExpressionElement(Models.EXPRESSION_ELEMENTS.op_exp, [Models.ARITHMETIC_TYPES.plus,
  65. expression_element.itens[index_to_move] ]);
  66. expression_element.itens[index_to_move] = exp;
  67. break;
  68. case Models.EXPRESSION_ELEMENTS.par_exp_par:
  69. var exp = new Models.ExpressionElement(Models.EXPRESSION_ELEMENTS.par_exp_par, [expression_element.itens[index_to_move]]);
  70. expression_element.itens[index_to_move] = exp;
  71. break;
  72. }
  73. renderExpressionElements(command, function_obj, dom_object);
  74. }
  75. function renderExpressionElements (command, function_obj, el) {
  76. var expression_div = el.find('.expression_elements');
  77. var command_container;
  78. if (el.hasClass("command_container") == false) {
  79. var hier = el.parentsUntil(".command_container");
  80. for (var i = 0; i < hier.length; i++) {
  81. if ($(hier[i]).hasClass("command_container")) {
  82. command_container = $(hier[i]);
  83. break;
  84. }
  85. if ($(hier[i]).hasClass("expression_elements")) {
  86. expression_div = $(hier[i]);
  87. break;
  88. }
  89. }
  90. }
  91. if (command_container) {
  92. expression_div = command_container.find('.expression_elements');
  93. }
  94. expression_div.text('');
  95. for (var i = 0; i < command.expression.length; i++) {
  96. var temp = $('<div class="expression_element"></div>');
  97. temp.data('ref_element', command.expression[i]);
  98. temp.data('ref_index', i);
  99. expression_div.append(temp);
  100. renderElement(command, function_obj, temp, command.expression[i]);
  101. }
  102. }
  103. function renderOperator (command, function_obj, temp_op, expression_element, index_op) {
  104. var context_menu = '<div class="ui dropdown"><div class="text">';
  105. switch (expression_element.itens[index_op]) {
  106. case Models.ARITHMETIC_TYPES.plus:
  107. context_menu += '+';
  108. break;
  109. case Models.ARITHMETIC_TYPES.minus:
  110. context_menu += '-';
  111. break;
  112. case Models.ARITHMETIC_TYPES.multiplication:
  113. context_menu += '*';
  114. break;
  115. case Models.ARITHMETIC_TYPES.division:
  116. context_menu += '/';
  117. break;
  118. case Models.ARITHMETIC_TYPES.module:
  119. context_menu += '%';
  120. break;
  121. case Models.ARITHMETIC_TYPES.none:
  122. context_menu += '...';
  123. break;
  124. }
  125. context_menu += '</div><div class="menu">';
  126. context_menu += '<div class="item" data-value="'+Models.ARITHMETIC_TYPES.plus+'">+</div>';
  127. context_menu += '<div class="item" data-value="'+Models.ARITHMETIC_TYPES.minus+'">-</div>';
  128. context_menu += '<div class="item" data-value="'+Models.ARITHMETIC_TYPES.multiplication+'">*</div>';
  129. context_menu += '<div class="item" data-value="'+Models.ARITHMETIC_TYPES.division+'">/</div>';
  130. context_menu += '<div class="item" data-value="'+Models.ARITHMETIC_TYPES.module+'">%</div>';
  131. context_menu += '<div class="item" data-value="'+Models.ARITHMETIC_TYPES.none+'" data-text="...">Nenhum</div>';
  132. context_menu += '</div></div>';
  133. context_menu = $(context_menu);
  134. temp_op.append(context_menu);
  135. context_menu.dropdown({
  136. onChange: function(value, text, $selectedItem) {
  137. expression_element.itens[index_op] = value;
  138. }
  139. });
  140. }
  141. function renderMenuAddExpression (command, function_obj, el, dom_append_menu, expression_append_new_expression) {
  142. if (el.hasClass("command_container") == false) {
  143. var hier = el.parentsUntil(".commands_list_div");
  144. for (var i = 0; i < hier.length; i++) {
  145. if ($(hier[i]).hasClass("command_container")) {
  146. el = $(hier[i]);
  147. break;
  148. }
  149. }
  150. }
  151. if (dom_append_menu.hasClass("expression_elements") == false) {
  152. var hier = el.parentsUntil(".commands_list_div");
  153. for (var i = 0; i < hier.length; i++) {
  154. if ($(hier[i]).hasClass("expression_elements")) {
  155. dom_append_menu = $(hier[i]);
  156. break;
  157. }
  158. }
  159. }
  160. var context_menu = '<div class="ui dropdown"><div class="text"></div><i class="ui icon arrow alternate circle right outline"></i><div class="menu">';
  161. context_menu += '<div class="item" data-value="'+Models.EXPRESSION_ELEMENTS.exp_op_exp+'">EXP OP EXP</div>';
  162. context_menu += '<div class="item" data-value="'+Models.EXPRESSION_ELEMENTS.op_exp+'">OP EXP</div>';
  163. context_menu += '<div class="item" data-value="'+Models.EXPRESSION_ELEMENTS.par_exp_par+'">( EXP )</div>';
  164. context_menu += '</div></div>';
  165. context_menu = $(context_menu);
  166. dom_append_menu.append(context_menu);
  167. context_menu.dropdown({
  168. onChange: function(value, text, $selectedItem) {
  169. switch (value) {
  170. case Models.EXPRESSION_ELEMENTS.exp_op_exp:
  171. var exp = new Models.ExpressionElement(Models.EXPRESSION_ELEMENTS.exp_op_exp,
  172. [new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all, null, null, null, true),
  173. Models.ARITHMETIC_TYPES.plus,
  174. new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all, null, null, null, true)]);
  175. expression_append_new_expression.push(exp);
  176. break;
  177. case Models.EXPRESSION_ELEMENTS.op_exp:
  178. var exp = new Models.ExpressionElement(Models.EXPRESSION_ELEMENTS.op_exp, [Models.ARITHMETIC_TYPES.plus,
  179. new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all, null, null, null, true)]);
  180. expression_append_new_expression.push(exp);
  181. break;
  182. case Models.EXPRESSION_ELEMENTS.par_exp_par:
  183. var exp = new Models.ExpressionElement(Models.EXPRESSION_ELEMENTS.par_exp_par,
  184. [new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all, null, null, null, true)]);
  185. expression_append_new_expression.push(exp);
  186. break;
  187. }
  188. renderExpressionElements(command, function_obj, el);
  189. }
  190. });
  191. }
  192. function renderElement (command, function_obj, el, expression_element) {
  193. switch (expression_element.type_exp) {
  194. case Models.EXPRESSION_ELEMENTS.exp_op_exp:
  195. var temp_op = $('<div class="component_element"></div>');
  196. var temp_exp_1 = $('<div class="component_element"></div>');
  197. var temp_exp_2 = $('<div class="component_element"></div>');
  198. el.append(temp_exp_1);
  199. el.append(temp_op);
  200. el.append(temp_exp_2);
  201. if (expression_element.itens[0].type) {
  202. VariableValueMenu.renderMenu(command, expression_element.itens[0], temp_exp_1, function_obj, 2, expression_element);
  203. } else {
  204. renderElement(command, function_obj, temp_exp_1, expression_element.itens[0]);
  205. }
  206. renderOperator(command, function_obj, temp_op, expression_element, 1);
  207. if (expression_element.itens[2].type) {
  208. VariableValueMenu.renderMenu(command, expression_element.itens[2], temp_exp_2, function_obj, 2, expression_element);
  209. } else {
  210. renderElement(command, function_obj, temp_exp_2, expression_element.itens[2]);
  211. }
  212. break;
  213. case Models.EXPRESSION_ELEMENTS.op_exp:
  214. var temp_op = $('<div class="component_element"></div>');
  215. var temp_exp = $('<div class="component_element"></div>');
  216. el.append(temp_op);
  217. el.append(temp_exp);
  218. renderOperator(command, function_obj, temp_op, expression_element, 0);
  219. if (expression_element.itens[1].type) {
  220. VariableValueMenu.renderMenu(command, expression_element.itens[1], temp_exp, function_obj, 2, expression_element);
  221. } else {
  222. renderElement(command, function_obj, temp_exp, expression_element.itens[1]);
  223. }
  224. break;
  225. case Models.EXPRESSION_ELEMENTS.par_exp_par:
  226. var temp_par_1 = $('<div class="component_element"> ( </div>');
  227. var temp_exp = $('<div class="component_element"></div>');
  228. var temp_par_2 = $('<div class="component_element"> ) </div>');
  229. el.append(temp_par_1);
  230. el.append(temp_exp);
  231. for (var j = 0; j < expression_element.itens.length; j++) {
  232. if (expression_element.itens[j].type) {
  233. VariableValueMenu.renderMenu(command, expression_element.itens[j], temp_exp, function_obj, 2, expression_element);
  234. } else {
  235. renderElement(command, function_obj, temp_exp, expression_element.itens[j]);
  236. }
  237. }
  238. //renderMenuAddExpression(command, function_obj, el, el, expression_element.itens);
  239. el.append(temp_par_2);
  240. break;
  241. }
  242. } // function renderElement(command, function_obj, el, expression_element)
  243. function renderExpression (command, function_obj, el) {
  244. //D console.log("src/ivprog/js/visualUI/commands/attribution.js: renderExpression(.): command="+JSON.stringify(command)+"\nfunction_obj=|"+JSON.stringify(function_obj)+"|\n");
  245. var expression_div = el.find('.expression_elements');
  246. expression_div.text('');
  247. var menu_add_item = $('<div class="menu_add_item"></div>');
  248. menu_add_item.data('index_add', 0);
  249. expression_div.append(menu_add_item);
  250. for (var i = 0; i < command.expression.length; i++) {
  251. //D console.log(i + " : " + JSON.stringify(command.expression));
  252. if (command.expression[i].type) {
  253. var temp = $('<div class="expression_element"></div>');
  254. temp.data('ref_element', command.expression[i]);
  255. temp.data('ref_index', i);
  256. expression_div.append(temp);
  257. VariableValueMenu.renderMenu(command, command.expression[i], temp, function_obj);
  258. } else if (command.expression[i] == "(" || command.expression[i] == ")") {
  259. var temp = $('<div class="expression_element">'+command.expression[i]+'</div>');
  260. temp.data('ref_element', command.expression[i]);
  261. temp.data('ref_index', i);
  262. expression_div.append(temp);
  263. } else {
  264. var temp = '<div class="expression_element">';
  265. switch(command.expression[i]) {
  266. case Models.ARITHMETIC_TYPES.plus:
  267. temp += '+';
  268. break;
  269. case Models.ARITHMETIC_TYPES.minus:
  270. temp += '-';
  271. break;
  272. case Models.ARITHMETIC_TYPES.multiplication:
  273. temp += '*';
  274. break;
  275. case Models.ARITHMETIC_TYPES.division:
  276. temp += '/';
  277. break;
  278. case Models.ARITHMETIC_TYPES.module:
  279. temp += '%';
  280. break;
  281. }
  282. temp += '</div>';
  283. temp = $(temp);
  284. temp.data('ref_element', command.expression[i]);
  285. temp.data('ref_index', i);
  286. expression_div.append(temp);
  287. }
  288. var menu_add_item_seq = $('<div class="menu_add_item"></div>');
  289. var index_temp = (i + 1);
  290. menu_add_item_seq.data('index_add', index_temp);
  291. expression_div.append(menu_add_item_seq);
  292. }
  293. addMenuItens(command, function_obj, el);
  294. } // function renderExpression(command, function_obj, el)
  295. function addMenuItens (command, function_obj, expression_div) {
  296. var divs_expression = expression_div.find('.menu_add_item');
  297. for (var i = 0; i < divs_expression.length; i++) {
  298. var temp = $(divs_expression[i]).data('index_add');
  299. var context_menu = '<div class="ui dropdown context_menu_clear"><i class="ui icon plus square outline"></i><div class="menu">';
  300. context_menu += '<div class="item" data-option="value" data-index="'+temp+'">'+LocalizedStrings.getUI('text_value')+'</div>';
  301. context_menu += '<div class="item" data-option="operator" data-index="'+temp+'">'+LocalizedStrings.getUI('text_operator')+'</div>';
  302. context_menu += '<div class="item" data-option="parentheses" data-index="'+temp+'">'+LocalizedStrings.getUI('text_parentheses')+'</div>';
  303. context_menu += '</div></div>';
  304. context_menu = $(context_menu);
  305. $(divs_expression[i]).append(context_menu);
  306. context_menu.dropdown({
  307. on: 'hover',
  308. onChange: function(value, text, $selectedItem) {
  309. switch ($selectedItem.data('option')) {
  310. case "value":
  311. command.expression.splice($selectedItem.data('index'), 0, new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all, null, null, null, true));
  312. renderExpression(command, function_obj, expression_div);
  313. break;
  314. case "operator":
  315. command.expression.splice($selectedItem.data('index'), 0, Models.ARITHMETIC_TYPES.plus);
  316. renderExpression(command, function_obj, expression_div);
  317. break;
  318. case "parentheses":
  319. command.expression.splice($selectedItem.data('index'), 0, "(");
  320. command.expression.splice($selectedItem.data('index') + 1, 0, new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all, null, null, null, true));
  321. command.expression.splice($selectedItem.data('index') + 2, 0, ")");
  322. renderExpression(command, function_obj, expression_div);
  323. break;
  324. }
  325. }
  326. });
  327. }
  328. }
  329. function addHandlers (command, function_obj, attribution_dom) {
  330. attribution_dom.find('.button_write_expression').on('click', function() {
  331. window.expressionEdition = true;
  332. window.inputExpression = null;
  333. var afterWhichElement;
  334. var lockButton = $(attribution_dom.find('.button_alternate_expression')[0]);
  335. var editButton = $(this);
  336. afterWhichElement = attribution_dom.find('.expression_elements');
  337. if (command.lockexpression) {
  338. afterWhichElement = attribution_dom.find('.textual_expression');
  339. }
  340. var text = "";
  341. if (command.expression) {
  342. if (command.expression.length == 1 && command.expression[0].content == null && !command.expression[0].function_called) {
  343. text = "";
  344. } else {
  345. try {
  346. text = CodeGenerator.elementExpressionCode(command.expression);
  347. } catch(ex) {
  348. text = "";
  349. }
  350. }
  351. }
  352. var ok_button = $('<i class="ui icon check circle expression-edit-confirm"></i>');
  353. var cancel_button = $('<i class="ui icon undo expression-edit-cancel"></i>');
  354. var input = $('<input type="text" spellcheck="false" autocomplete="off" class="input-expression-field" >');
  355. input.val(text);
  356. input.focusout(function(evt) {
  357. console.log('focosout event!');
  358. ok_button.click();
  359. evt.preventDefault();
  360. return true;
  361. });
  362. input.keyup(function(evt) {
  363. if (evt.keyCode == 27) { // esc
  364. cancel_button.click();
  365. }
  366. if (evt.keyCode == 13) { // enter
  367. ok_button.click();
  368. }
  369. });
  370. ok_button.click(function() {
  371. var parsed = null;
  372. parsed = ExpressionManagement.expressionParserToVisual(input.val(), function_obj, input);
  373. if (parsed) {
  374. window.expressionEdition = false;
  375. command.expression = parsed;
  376. renderAlgorithm();
  377. }
  378. });
  379. cancel_button.mousedown(function(evt) {
  380. var parsed = ExpressionManagement.expressionParserToVisual(text, function_obj, input);
  381. if (parsed) {
  382. window.expressionEdition = false;
  383. command.expression = parsed;
  384. renderAlgorithm();
  385. }
  386. });
  387. input.insertAfter(afterWhichElement);
  388. input.focus();
  389. cancel_button.insertAfter(input);
  390. ok_button.insertAfter(input);
  391. var len = text.length;
  392. input[0].setSelectionRange(len, len);
  393. afterWhichElement.css('display', 'none');
  394. lockButton.css('display', 'none');
  395. editButton.css('display', 'none');
  396. ok_button.popup({
  397. content : LocalizedStrings.getUI("text_edit_expression_confirm"),
  398. delay: { show: 750, hide: 0 }
  399. });
  400. cancel_button.popup({
  401. content : LocalizedStrings.getUI("text_edit_expression_cancel"),
  402. delay: { show: 750, hide: 0 }
  403. });
  404. });
  405. $(attribution_dom.find('.textual_expression')[0]).toggle();
  406. attribution_dom.find('.button_alternate_expression').on('click', function() {
  407. if (command.expression) {
  408. var text = CodeGenerator.elementExpressionCode(command.expression);
  409. if (text) {
  410. $(attribution_dom.find('.expression_elements')[0]).toggle();
  411. $(attribution_dom.find('.textual_expression')[0]).text(text);
  412. $(attribution_dom.find('.textual_expression')[0]).toggle();
  413. $(this).toggleClass('unlock').toggleClass('lock');
  414. command.lockexpression = !command.lockexpression;
  415. }
  416. if (command.lockexpression) {
  417. attribution_dom.find('.lock').popup({
  418. content : LocalizedStrings.getUI("text_unlock_expression"),
  419. delay: { show: 750, hide: 0 }
  420. });
  421. } else {
  422. attribution_dom.find('.unlock').popup({
  423. content : LocalizedStrings.getUI("text_lock_expression"),
  424. delay: { show: 750, hide: 0 }
  425. });
  426. }
  427. }
  428. });
  429. attribution_dom.find('.button_remove_command').on('click', function() {
  430. if (CommandsManagement.removeCommand(command, function_obj, attribution_dom)) {
  431. attribution_dom.fadeOut(400, function() {
  432. attribution_dom.remove();
  433. });
  434. }
  435. });
  436. attribution_dom.find('.button_refresh_attribution').on('click', function() {
  437. renderExpressionElements(command, function_obj, attribution_dom);
  438. });
  439. }
  440. export function renderMenuOperations (command, ref_object, dom_object, menu_var_or_value, function_obj, variable_selected) {
  441. /*console.log("recebido o seguinte DOM: ");
  442. console.log(dom_object);
  443. if (dom_object.hasClass('var_attributed')) { return; } else {
  444. var hier = dom_object.parentsUntil(".command_container");
  445. for (var i = 0; i < hier.length; i++) { if ($(hier[i]).hasClass('var_attributed') || $(hier[i]).hasClass('parameters_function_called')) { return; } }
  446. }
  447. dom_object.find('.context_menu_clear').remove();
  448. var menu_operations = '<div class="ui dropdown menu_operations"><div class="text"></div><i class="dropdown icon"></i><div class="menu">';
  449. for (var tm in Models.ARITHMETIC_TYPES) { menu_operations += '<div class="item" data-option="'+tm+'">'+LocalizedStrings.getUI('btn_arithmetic_' + tm)+'</div>'; }
  450. menu_operations += '<div class="item" data-option="clear">'+LocalizedStrings.getUI('btn_clear')+'</div>';
  451. menu_operations += '</div></div>';
  452. menu_operations = $(menu_operations);
  453. dom_object.append(menu_operations);
  454. menu_operations.dropdown({
  455. onChange: function(value, text, $selectedItem) {
  456. switch ($($selectedItem).data('option')) {
  457. case "clear": $(dom_object).text(''); VariableValueMenu.renderMenu(command, ref_object, dom_object, function_obj); break;
  458. default: createExpressionAround(command, ref_object, dom_object, function_obj); menu_operations.find('.text').text('');
  459. }
  460. }
  461. });*/
  462. }
  463. function createExpressionAround (command, ref_object, dom_object, function_obj) {
  464. $('<span> ( </span>').insertBefore(dom_object);
  465. $('<span> ) </span>').insertAfter(dom_object);
  466. VariableValueMenu.renderMenu(command, new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all, null, null, null, true), dom_object, function_obj);
  467. }