Bladeren bron

Ponto de restauração

Igor Félix 6 jaren geleden
bovenliggende
commit
215b53d312
6 gewijzigde bestanden met toevoegingen van 142 en 5 verwijderingen
  1. 8 0
      css/ivprog-visual-1.0.css
  2. 15 0
      i18n/i18n-database.json
  3. 3 4
      js/ivprog-visual-1.0.js
  4. 99 1
      js/ivprog-visual-functions-1.0.js
  5. 15 0
      js/semantic/semantic-buttons.js
  6. 2 0
      main.html

+ 8 - 0
css/ivprog-visual-1.0.css

@@ -257,4 +257,12 @@ div.buttons_manage_columns {
 .list_globals, .global_const {
 	display: inline;
 	cursor: pointer;
+}
+
+.created_element {
+	position: absolute;
+	width: 50%;
+	z-index: 99999999;
+	opacity: .8;
+	cursor: move;
 }

+ 15 - 0
i18n/i18n-database.json

@@ -98,5 +98,20 @@
 		"en": "This is the main function...",
 		"es": "Esta es la función principal...",
 		"pt": "Esta é a função principal..."
+	},
+	"text_read_var": {
+		"en": "Reading data",
+		"es": "Leyendo datos",
+		"pt": "Leitura de dados"
+	},
+	"text_write_var": {
+		"en": "Writing data",
+		"es": "Escribir datos",
+		"pt": "Escrita de dados"
+	},
+	"text_comment": {
+		"en": "Comment",
+		"es": "Comentario",
+		"pt": "Comentário"
 	}
 }

+ 3 - 4
js/ivprog-visual-1.0.js

@@ -3,7 +3,7 @@
 // Não adicionar elementos ao tipoDados, pois existem componentes que dependem do seu tamanho e isso afetará seu funcionamento
 var tiposDados = Object.freeze({void:"void", integer:"integer", real:"real", text:"text", boolean:"boolean", vector:"vector"});
 
-var tiposComandos = Object.freeze({comment:"comment"});
+var tiposComandos = Object.freeze({comment:"comment", reader:"reader", writer:"writer"});
 
 var Variavel = function(tipo, nome, valor, dimensoes = 0, eh_constante = false, linhas = 0, colunas = 0) {
 	this.tipo = tipo;
@@ -41,7 +41,6 @@ var Expressao = function(conteudo) {
 
 };
 
-
 var Programa = function () {
 	this.funcoes = new Array();
 	this.globais = new Array();
@@ -62,7 +61,7 @@ function adicionarVariavel(funcao, variavel) {
 
 // Adicionando a função principal automaticamente
 var programa = new Programa();
-var funcaoPrincipal = new Funcao(i18n("start"), tiposDados.void, 0, new Array(), true);
+var funcaoPrincipal = new Funcao(i18n("start"), tiposDados.void, 0, [], true);
 funcaoPrincipal.comentario_funcao = new Comentario(i18n('text_comment_main'));
 
 //funcaoPrincipal.lista_parametros.push(new Variavel(tiposDados.text, "args"));
@@ -70,7 +69,7 @@ funcaoPrincipal.comentario_funcao = new Comentario(i18n('text_comment_main'));
 
 adicionarFuncao(funcaoPrincipal);
 
-var funcaoSomar = new Funcao("somar", tiposDados.integer, 0, new Array(), false, false, null, new Comentario(i18n('text_comment_start')));
+var funcaoSomar = new Funcao("somar", tiposDados.integer, 0, [], false, false, null, new Comentario(i18n('text_comment_start')));
 funcaoSomar.lista_parametros.push(new Variavel(tiposDados.integer, "a"));
 funcaoSomar.lista_parametros.push(new Variavel(tiposDados.integer, "b"));
 

+ 99 - 1
js/ivprog-visual-functions-1.0.js

@@ -201,8 +201,73 @@ function renderGlobals() {
 	$('.list_globals').append(ret); 
 }
 
+var has_element_created_draged = false;
+var which_element_is_draged = null;
+
+function createCommentDragObject() {
+	var ret = '';
+	ret += '<div class="ui comment created_element"> <i class="ui icon small quote left"></i> <span class="span_comment_text" "> Testando </span>';
+	ret += '</div>';
+
+	has_element_created_draged = true;
+	which_element_is_draged = tiposComandos.comment;
+
+	$('body').append(ret);
+}
+
+var myDraggable = null;
+// Yeah... we're going to hack the widget
+var widget = null;
+var clickEvent = null;
+
+function flutuateCreatedElement() {
+	$('.created_element').css('top', mouseY);
+    $('.created_element').css('left', mouseX);
+
+
+      myDraggable = $('.created_element').draggable();
+  
+	  // Yeah... we're going to hack the widget
+	  widget = myDraggable.data('ui-draggable');
+	  clickEvent = null;
+	  
+	  myDraggable.click(function(event){
+
+
+	      if(!clickEvent){
+	        widget._mouseStart(event);
+	        clickEvent = event;
+	      }
+	      else {
+	        widget._mouseUp(event);
+	        clickEvent = null;
+	      }
+	    });
+	    
+	  $(document).mousemove(function(event){
+	    if(clickEvent){
+	      // We need to set this to our own clickEvent, otherwise
+	      // it won't position correctly.
+	      widget._mouseDownEvent = clickEvent;
+	      widget._mouseMove(event);
+	    }
+	  });
+
+}
+
 function addHandlers() {
 
+	$('.ui.buttons .dropdown').dropdown({
+		    onChange: function(value, text, $selectedItem) {
+		    	if (value == tiposComandos.comment) {
+		    		createCommentDragObject();
+		    	}
+
+		    	flutuateCreatedElement();
+
+		    }
+		});
+
 	$('.ui.dropdown.function_return')
     	.dropdown({
 		    onChange: function(value, text, $selectedItem) {
@@ -1717,6 +1782,29 @@ function removeParameter(parent_node, which_function, which_parameter) {
 	renderAlgorithm();
 }
 
+
+function manageDragableCommands(sequence) {
+	var el = document.getElementById('menu_commands_'+sequence);
+
+	var sortable = Sortable.create(el, {
+	    handle: '.created_element',
+	    animation: 100,
+	    draggable: '.item',
+	    ghostClass: 'ghost',
+	    group: {
+	    	name: 'commands_area_'+sequence,
+	    	pull: 'clone'
+	    },
+	    onEnd: function (evt) {
+	      updateSequenceFunctionHandler(evt.oldIndex, evt.newIndex);
+	    }
+    });
+
+
+
+}
+
+
 function appendFunction(function_obj, sequence) {
 	var appender = '<div class="ui secondary segment function_div list-group-item">';
 
@@ -1729,7 +1817,15 @@ function appendFunction(function_obj, sequence) {
 	appender += (!function_obj.eh_principal ? '<button class="ui icon button large remove_function_button" onclick="removeFunctionHandler(this.parentNode, '+sequence+')"><i class="red icon times"></i></button>' : '<div class="div_start_minimize_v"> </div>')
 		+ '<button class="ui icon button tiny minimize_function_button" onclick="minimizeFunctionHandler(this.parentNode, '+sequence+')"><i class="icon window minimize"></i></button>';
 
-	appender += '<div class="ui icon buttons add_var_top_button"><div class="ui icon button" onclick="addVariable('+sequence+')"><i class="icon superscript"></i></div><div class="ui icon button"><i class="icon code"></i></div></div>';
+	appender += '<div class="ui icon buttons add_var_top_button"><div class="ui icon button" onclick="addVariable('+sequence+')"><i class="icon superscript"></i></div>';
+	
+	appender += '<div class="ui icon button dropdown" ><i class="icon code"></i> <div class="menu" id="menu_commands_'+sequence+'"> ';
+	appender += '<a class="item" data-text="'+tiposComandos.reader+'"><i class="download icon"></i> ' +i18n('text_read_var')+ '</a>'
+			  + '<a class="item" data-text="'+tiposComandos.writer+'"><i class="upload icon"></i> '+i18n('text_write_var')+'</a>'
+			  + '<a class="item create_comment" data-text="'+tiposComandos.comment+'"><i class="quote left icon"></i> '+i18n('text_comment')+'</a>'
+				+ '</div></div></div>';
+
+
 
 	appender += '<div class="function_signature_div">'+i18n('function')+' ';
 
@@ -1759,6 +1855,8 @@ function appendFunction(function_obj, sequence) {
 		+ '</div>';
 
 	$('.all_functions').append(appender); 
+
+	manageDragableCommands(sequence);
 }
 
 

+ 15 - 0
js/semantic/semantic-buttons.js

@@ -44,6 +44,18 @@ var button_ready = function() {
 
   $('.ivprog_visual_panel').removeClass("loading");
 
+  $(document).mousemove(function(e){
+    var parentOffset = $('.ivprog_visual_panel').offset();; 
+   
+    mouseX = e.pageX - parentOffset.left + 300;
+    mouseY = e.pageY - parentOffset.top + 100;
+
+    /*$('.created_element').css('top', mouseY);
+    $('.created_element').css('left', mouseX);*/
+
+  });
+
+
   //Sortable:
   Sortable.create(listWithHandle, {
     handle: '.glyphicon-move',
@@ -57,6 +69,9 @@ var button_ready = function() {
 
 };
 
+var mouseX;
+var mouseY;
+
 // attach ready event
 $(document)
   .ready(button_ready)

+ 2 - 0
main.html

@@ -111,6 +111,8 @@
       
     </div>
 
+    <i class="icon trash alternate outline huge" onmouseover="console.log('oi');" ></i>
+