瀏覽代碼

Continuando os comandos

igorfelix01 5 年之前
父節點
當前提交
8547ca6513

+ 1 - 1
css/ivprog-visual-1.0.css

@@ -122,7 +122,7 @@ body {
 }
 
 .function_name_div, .function_return_div, .function_name_parameter, .created_div_valor_var, .function_return, .var_value_menu_div, .variable_rendered, .variable_rendered div, .var_attributed,
-.expression_operand_1, .expression_operand_2, .operator, .div_comment_text {
+.expression_operand_1, .expression_operand_2, .operator, .div_comment_text, .value_rendered {
 	display: inline;
 }
 

+ 1 - 1
js/visualUI/commands/comment.js

@@ -34,7 +34,7 @@ function addHandlers (command, function_obj, comment_dom) {
 			$(this).remove();
 		});
 
-		$('.width-dynamic').on('keydown', function(e) {
+		$(comment_dom).find('.width-dynamic').on('keydown', function(e) {
 			var code = e.keyCode || e.which;
 			if(code == 13) {
 				if ($(this).val().trim()) {

+ 69 - 7
js/visualUI/commands/variable_value_menu.js

@@ -155,6 +155,9 @@ function addHandlers (command, ref_object, dom_object, menu_var_or_value, functi
 
 function openInputToVariable (command, ref_object, dom_object, menu_var_or_value, function_obj, variable_selected) {
 
+
+	ref_object.content = variable_selected;
+
 	$(menu_var_or_value).find('.text').text(' ');
 	$(dom_object).find('.menu_var_or_value_dom').remove();
 
@@ -177,15 +180,15 @@ function openInputToVariable (command, ref_object, dom_object, menu_var_or_value
 
 
 	if (variable_selected.dimensions == 1) {
-		var nova_var_menu = new Models.VariableValueMenu(VAR_OR_VALUE_TYPES.all, null, null, null, true);
-		renderMenu(command, nova_var_menu, $(variable_render).find('.column_container'), function_obj);
+		ref_object.column = new Models.VariableValueMenu(VAR_OR_VALUE_TYPES.all, null, null, null, true);
+		renderMenu(command, ref_object.column, $(variable_render).find('.column_container'), function_obj);
 	}
 	if (variable_selected.dimensions == 2) {
-		var nova_var_menu_row = new Models.VariableValueMenu(VAR_OR_VALUE_TYPES.all, null, null, null, true);
-		renderMenu(command, nova_var_menu_row, $(variable_render).find('.row_container'), function_obj);
+		ref_object.row = new Models.VariableValueMenu(VAR_OR_VALUE_TYPES.all, null, null, null, true);
+		renderMenu(command, ref_object.row, $(variable_render).find('.row_container'), function_obj);
 
-		var nova_var_menu_column = new Models.VariableValueMenu(VAR_OR_VALUE_TYPES.all, null, null, null, true);
-		renderMenu(command, nova_var_menu_column, $(variable_render).find('.column_container'), function_obj);
+		ref_object.column = new Models.VariableValueMenu(VAR_OR_VALUE_TYPES.all, null, null, null, true);
+		renderMenu(command, ref_object.column, $(variable_render).find('.column_container'), function_obj);
 	}
 
 	var context_menu = '<div class="ui dropdown context_menu_clear"><div class="text"></div><i class="dropdown icon"></i><div class="menu">';
@@ -200,6 +203,7 @@ function openInputToVariable (command, ref_object, dom_object, menu_var_or_value
 		onChange: function(value, text, $selectedItem) {
 	     if ($($selectedItem).data('clear')) {
 	     	$(dom_object).text('');
+	     	ref_object = new Models.VariableValueMenu(VAR_OR_VALUE_TYPES.all, null, null, null, true);
 	     	renderMenu(command, ref_object, dom_object, function_obj);
 	     }
       }
@@ -212,10 +216,19 @@ function openInputToVariable (command, ref_object, dom_object, menu_var_or_value
 
 
 function openInputToValue (command, ref_object, dom_object, menu_var_or_value, function_obj) {
+
+	if (ref_object.content == null) {
+		ref_object.content = "";
+	}
+
 	$(menu_var_or_value).find('.text').text(' ');
-	var field = $('<input type="text" size="2" />');
+	var field = $('<input type="text" size="2" class="width-dynamic-minus" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" />');
 	$( field ).insertBefore($(dom_object).find('.menu_var_or_value_dom'));
+	var rendered = $('<div class="value_rendered"></div>');
+	$( rendered ).insertBefore(field);
+
 	field.focus();
+	$(field).val(ref_object.content);
 
 	$(dom_object).find('.menu_var_or_value_dom').remove();
 
@@ -231,11 +244,60 @@ function openInputToValue (command, ref_object, dom_object, menu_var_or_value, f
 		onChange: function(value, text, $selectedItem) {
 	     if ($($selectedItem).data('clear')) {
 	     	$(dom_object).text('');
+
+	     	ref_object = new Models.VariableValueMenu(VAR_OR_VALUE_TYPES.all, null, null, null, true);
+
+	     	$(dom_object).find('.value_rendered').remove();
+			$(dom_object).find('.context_menu_clear').remove();
+			$(dom_object).find('.width-dynamic-minus').remove();
+
 	     	renderMenu(command, ref_object, dom_object, function_obj);
 	     }
       }
 	});
 
+	$(dom_object).find('.width-dynamic-minus').focusout(function() {
+		if ($(this).val().trim()) {
+			ref_object.content = $(this).val().trim();
+		}
+
+		$(rendered).text(ref_object.content);
+		$(this).remove();
+
+	});
+
+	$(dom_object).find('.width-dynamic-minus').on('keydown', function(e) {
+		var code = e.keyCode || e.which;
+		if(code == 13) {
+			if ($(this).val().trim()) {
+				ref_object.content = $(this).val().trim();
+			}
+			$(rendered).text(ref_object.content);
+
+			$(this).remove();
+		}
+		if(code == 27) {
+			$(rendered).text(ref_object.content);
+
+			$(this).remove();
+		}
+	});
+
+	$(rendered).on('click', function(e) {
+		console.log('no clique, vou passar o seguinte: ');
+		console.log(dom_object);
+		rendered.remove();
+		rendered.empty();
+		$(rendered).remove();
+		$(dom_object).empty();
+		$(dom_object).append('<span class="menu_var_or_value_dom"> </span>');
+		//$('<span class="menu_var_or_value_dom"> </span>').insertBefore($(dom_object).find('.value_rendered'));
+		//$(dom_object).find('.value_rendered').remove();
+		//$(dom_object).find('.context_menu_clear').remove();
+		//$(dom_object).find('.width-dynamic-minus').remove();
+
+		openInputToValue(command, ref_object, dom_object, menu_var_or_value, function_obj)
+	});
 
 	if (command.type == Models.COMMAND_TYPES.attribution) {
 		AttribuitionsManagement.renderMenuOperations(command, ref_object, dom_object, menu_var_or_value, function_obj);

+ 2 - 2
js/visualUI/functions.js

@@ -10,7 +10,7 @@ var counter_new_functions = 0;
 var counter_new_parameters = 0;
 
 const program = new Models.Program();
-const mainFunction = new Models.Function(LocalizedStrings.getUI("start"), Types.VOID, 0, [], true);
+const mainFunction = new Models.Function(LocalizedStrings.getUI("start"), Types.VOID, 0, [], true, false, []);
 mainFunction.function_comment = new Models.Comment(LocalizedStrings.getUI('text_comment_main'));
 program.addFunction(mainFunction);
 
@@ -18,7 +18,7 @@ window.program_obj = program;
 
 function addFunctionHandler () {
 
-	var new_function = new Models.Function(LocalizedStrings.getUI("new_function") + "_" + counter_new_functions, Types.VOID, 0, new Array(), false, false, null, new Models.Comment(LocalizedStrings.getUI('text_comment_start')));
+	var new_function = new Models.Function(LocalizedStrings.getUI("new_function") + "_" + counter_new_functions, Types.VOID, 0, [], false, false, [], new Models.Comment(LocalizedStrings.getUI('text_comment_start')));
 	program.addFunction(new_function);
 
 	counter_new_functions ++;

+ 1 - 1
js/visualUI/ivprog_elements.js

@@ -20,7 +20,7 @@ export class Variable {
 
 export class Function {
 
-  constructor (name, return_type = Types.VOID, return_dimensions = 0, parameters_list = null, is_main = false, is_hidden = false, variables_list = [], function_comment = null) {
+  constructor (name, return_type = Types.VOID, return_dimensions = 0, parameters_list = [], is_main = false, is_hidden = false, variables_list = [], function_comment = null) {
     this.type = COMMAND_TYPES.function;
     this.name = name;
     this.return_type = return_type;

File diff suppressed because it is too large
+ 1551 - 171
package-lock.json


+ 3 - 1
package.json

@@ -47,6 +47,8 @@
   },
   "dependencies": {
     "antlr4": "^4.7.1",
-    "jquery": "^3.3.1"
+    "jquery": "^3.3.1",
+    "melanke-watchjs": "^1.5.0",
+    "server": "^1.0.18"
   }
 }