Index: /trunk/prototype/modules/mail/js/label.js
===================================================================
--- /trunk/prototype/modules/mail/js/label.js	(revision 5564)
+++ /trunk/prototype/modules/mail/js/label.js	(revision 5566)
@@ -16,5 +16,4 @@
 	winElement.find(".preview-label-inner").text($(this).text());
 }
-
 
 function editLabel(){	
@@ -42,4 +41,5 @@
 	$(this).addClass("hidden");
 }
+
 function deleteLabel(event){
 	var id = $(this).parents(".label-item").attr("class").match(/label-item-([\d]+[()a-zA-Z]*)/)[1];
@@ -57,4 +57,5 @@
 			]		
 }
+
 function rgb2hex(rgb){
  rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
@@ -76,6 +77,10 @@
 		}
 	});	
-}			
-function save_editLabel(){
+}		
+	
+function save_editLabel(){		
+	var qtdLi = $(".label-list-container ul").find("li").not(".empty-item").length;	
+	// salvar marcador
+	if(qtdLi > 0){
 		$(".save-label").button("disable");
 		var labelEdited = {
@@ -87,87 +92,59 @@
 			borderColor : winElement.find("input[name='borderColor']").val()
 		}
-		var qtdLi = $(".label-list-container ul").find("li").not(".empty-item").length;	
-		// salvar marcador
-		if(qtdLi > 0){
-			$(".label-list-container .label-list li").each(function(){
-				var regex_match_2 = $(this).attr("class").match(/label-item-([\d]+[()a-zA-Z]*)/);
+		$(".label-list-container .label-list li").each(function(){
+			var regex_match_2 = $(this).attr("class").match(/label-item-([\d]+[()a-zA-Z]*)/);
+			
+			 if(regex_match_2 && regex_match_2[1] && regex_match_2[1] == labelEdited.id){
+			   $(this).html("<input type='hidden' name='labelItemId' class='id-item-list' value='"+labelEdited.id+"'>"+"<span class='text-list'>"+labelEdited.name+"</span><div class='button close tiny' style='float: right'></div><div class='button edit tiny' style='float: right'></div>").css({
+				"background" : labelEdited.backgroundColor,
+				"color" : labelEdited.fontColor, 
+				"border-color" : labelEdited.borderColor	
+			   });
+			 }	
+		});
+		
+		$("#MyMarckersList .label-list li").each(function(){
+			var regex_match_2 = $(this).attr("class").match(/label-item-([\d]+[()a-zA-Z]*)/);
+			
+			if(regex_match_2 && regex_match_2[1] && regex_match_2[1] == labelEdited.id){
+				$(this).html("<input type='hidden' name='labelItemId' class='id-item-list' value='"+labelEdited.id+"'>"+"<span>"+labelEdited.name+"</span>");
+				$(this).find(".square-color").css('background', labelEdited.backgroundColor);
+			}	
+		});
+		DataLayer.put('label', labelEdited.id, labelEdited);
+		DataLayer.commit(false, false, function(){
+			winElement.find(".insert-label").val("");
+			$.Watermark.ShowAll();
+			
+			$(".label-list-container .label-list li").find('.button').button()
+				.filter('.edit').button({icons:{primary:'ui-icon-pencil'}, text:false}).end()
+				.filter('.close').button({icons:{primary:'ui-icon-close'}, text:false});
 				
-				 if(regex_match_2 && regex_match_2[1] && regex_match_2[1] == labelEdited.id){
-				   $(this).html("<input type='hidden' name='labelItemId' class='id-item-list' value='"+labelEdited.id+"'>"+"<span class='text-list'>"+labelEdited.name+"</span><div class='button close tiny' style='float: right'></div><div class='button edit tiny' style='float: right'></div>").css({
-					"background" : labelEdited.backgroundColor,
-					"color" : labelEdited.fontColor, 
-					"border-color" : labelEdited.borderColor	
-				   });
-				 }	
-			});
-			
-			$("#MyMarckersList .label-list li").each(function(){
-				var regex_match_2 = $(this).attr("class").match(/label-item-([\d]+[()a-zA-Z]*)/);
-				
-				if(regex_match_2 && regex_match_2[1] && regex_match_2[1] == labelEdited.id){
-					$(this).html("<input type='hidden' name='labelItemId' class='id-item-list' value='"+labelEdited.id+"'>"+"<span>"+labelEdited.name+"</span>");
-					$(this).find(".square-color").css('background', labelEdited.backgroundColor);
-				}	
-			});
-			DataLayer.put('label', labelEdited.id, labelEdited);
-			DataLayer.commit(false, false, function(){
-				$("#MyMarckersList")
-				.html(
-					"<div class='my-labels'>" +
-						"<img src='../prototype/modules/mail/img/tag.png'/>" +
-						"<a class='title-my-labels' tabindex='0' role='button' aria-expanded='false' title='Meus marcadores'>Meus marcadores</a>" +
-						
-						"<span class='status-list-labels ui-icon ui-icon-triangle-1-s'></span>" +
-					"</div>"
-				)
-				.append(DataLayer.render("../prototype/modules/mail/templates/label_list.ejs", {labels:DataLayer.get('label', true)} ))
-				.find("li.label-item").css({"background-color":"#ffffff", "border-color":"#CCCCCC", "color":"#444444"})
-				.find(".square-color").css("display","").click(function(){
-					$(this).parent(".label-item").each(function(){
-						configureLabels({selectedItem: $(this).attr('class').match(/label-item-([\d]+[()a-zA-Z]*)/)[1]});
-						var id_label_item = $(this).attr('class').match(/label-item-([\d]+[()a-zA-Z]*)/)[1];
-						$(".label-list-container .label-list").find(".label-item-"+id_label_item).trigger("click");
-					});
-				});
-				
-				$("#MyMarckersList a.title-my-labels").click(function() {
-					$("#MyMarckersList ul.label-list").toggleClass("hidden")
-					$('#MyMarckersList .status-list-labels').toggleClass("ui-icon-triangle-1-s");
-					$('#MyMarckersList .status-list-labels').toggleClass("ui-icon-triangle-1-n");
-				 });
-	 
-				
-				winElement.find(".insert-label").val("");
-				$.Watermark.ShowAll();
-				$(".label-list-container .label-list li").find('.button').button()
-					.filter('.edit').button({icons:{primary:'ui-icon-pencil'}, text:false}).end()
-					.filter('.close').button({icons:{primary:'ui-icon-close'}, text:false});
-				winElement.find('.edit').unbind("click").click(editLabel);
-				
-				winElement.find('.close').click(deleteLabel);
-			});
-		// criar marcador
+			winElement.find('.edit').unbind("click").click(editLabel);				
+			winElement.find('.close').click(deleteLabel);
+			
+			draw_tree_labels();
+			
+			/**
+			* Atualiza menu remove o menu presente em cada mensagem listada em uma pasta 
+			* e carrega novamente para que os dados sejam atualizados
+			*/
+			$.contextMenu( 'destroy', ".table_box tbody tr");
+			loadMenu();
+		});
+	// criar marcador
+	} else {
+		var nameLabel = winElement.find(".input-nome").val();
+		if(nameLabel.length >= 2){
+			new_label(nameLabel, false);				
+			winElement.find(".insert-label").val("");
+			$.Watermark.ShowAll();				
 		} else {
-		  winElement.find(".add-label-button").click(function(){
-			var nameLabel = winElement.find(".input-nome").val();
-			if(nameLabel.length >= 2){
-				new_label(nameLabel, false);				
-				winElement.find(".insert-label").val("");
-				$.Watermark.ShowAll();				
-			} else {
-				alert("Mínimo 2 caracteres");
-			}
-		   });
-		}		
-		/**
-		* Atualiza menu remove o menu presente em cada mensagem listada em uma pasta 
-		* e carrega novamente para que os dados sejam atualizados
-		*/
-		$.contextMenu( 'destroy', ".table_box tbody tr");
-		loadMenu();
-		
-		$(".label-list-container .label-list").find(".label-item-"+labelEdited.id).trigger("click");
-
-}
+			alert("Mínimo 2 caracteres");
+		}
+	}				
+	$(".label-list-container .label-list").find(".label-item-"+labelEdited.id).trigger("click");
+}
+
 function delete_label(id){
 	$(".label-list li").each(function () {
@@ -210,4 +187,5 @@
 	}		
 }
+
 function new_label(nameLabel, isNew){
 	var labelCreated = {
@@ -241,25 +219,5 @@
 		.fadeIn("slow").click(configureLabel);
 		
-		$("#MyMarckersList")
-		.html(
-			"<div class='my-labels'>" +
-				"<img src='../prototype/modules/mail/img/tag.png'/>" +
-				"<a class='title-my-labels' tabindex='0' role='button' aria-expanded='false' title='"+get_lang("My Labels")+"'>"+get_lang("My Labels")+"</a>" +
-				
-				"<span class='status-list-labels ui-icon ui-icon-triangle-1-s'></span>" +
-			"</div>"
-		)		
-		.append(DataLayer.render("../prototype/modules/mail/templates/label_list.ejs", {labels:DataLayer.get('label', true)} ))
-		.find("li.label-item").css({"background-color":"#ffffff", "border-color":"#CCCCCC", "color":"#444444"})
-		.find(".square-color").css("display","").click(function(){
-			$(this).parent(".label-item").each(function(){
-				configureLabels({selectedItem: $(this).attr('class').match(/label-item-([\d]+[()a-zA-Z]*)/)[1]});
-			});
-		});
-		$("#MyMarckersList a.title-my-labels").click(function() {
-			$("#MyMarckersList ul.label-list").toggleClass("hidden")
-			$('#MyMarckersList .status-list-labels').toggleClass("ui-icon-triangle-1-s");
-			$('#MyMarckersList .status-list-labels').toggleClass("ui-icon-triangle-1-n");
-		 });
+		draw_tree_labels();
 
 		$(".label-list-container .label-list li").not(".empty-item").click(function(){
@@ -290,6 +248,6 @@
 		.addClass("ui-icon ui-icon-plus");
 	});
-
-}
+}
+
 function init_label(data){
 
@@ -469,4 +427,4 @@
  * TODO:
  * * Qunado excluir um marcador deve ser removido das mensagens sem que seja necessario atualizar o Expresso.
- * *
+ * * Quando editado um marcador dever ser atualizado na lista de mensagem onde esse marcador foi aplicado.
  */
Index: /trunk/expressoMail1_2/js/draw_api.js
===================================================================
--- /trunk/expressoMail1_2/js/draw_api.js	(revision 5560)
+++ /trunk/expressoMail1_2/js/draw_api.js	(revision 5566)
@@ -341,7 +341,10 @@
 function draw_tree_labels(){
 	labels = DataLayer.get('label',{criteria:{order: 'name'}});
-
-	$('#content_folders').append("<div id='MyMarckersList' class='acc-list list-label' ></div>").find("#MyMarckersList")
-	.append("<div class='my-labels'>" +
+	if(!$("#MyMarckersList").length)
+		var myLabels = $('#content_folders').append("<div id='MyMarckersList' class='acc-list list-label' ></div>").find("#MyMarckersList");
+	else
+		var myLabels = $("#MyMarckersList");
+		
+	myLabels.html("<div class='my-labels'>" +
 				"<img src='../prototype/modules/mail/img/tag.png'/>" +
 				"<a class='title-my-labels' tabindex='0' role='button' aria-expanded='false' title='"+get_lang("My Labels")+"'>"+get_lang("My Labels")+"</a>" +
@@ -351,5 +354,5 @@
 	)
 	.append(DataLayer.render("../prototype/modules/mail/templates/label_list.ejs", {labels: labels} ))
-	.find("li.label-item").css({"background-color":"#ffffff", "border-color":"#CCCCCC", "color":"#444444"}).find("span").css({"width":"100%"}).click(function(){
+	.find("li.label-item").css({"background-color":"#ffffff", "border-color":"#CCCCCC", "color":"#444444"}).find("span").click(function(){
 		var labelId = $(this).parents("li").attr('class').match(/label-item-([\d]+[()a-zA-Z]*)/)[1];
 		search_emails("UNDELETED KEYWORD \"$Label"+labelId+"\"");
