Index: trunk/prototype/modules/filters/filters.js
===================================================================
--- trunk/prototype/modules/filters/filters.js	(revision 5542)
+++ trunk/prototype/modules/filters/filters.js	(revision 5543)
@@ -200,12 +200,4 @@
 
 });
-/*
-DataLayer.listen( "filter", function( status ){
- 
-    DataLayer.render( BASE_PATH + 'modules/filters/filter-list.ejs', 'filter:detail', reraster );
-
-});
-*/
-
 
 var BASE_PATH = '../prototype/';
@@ -219,28 +211,14 @@
 /*
 var raster = function( html ){
-	//alert("método raster\nParâmetro a seguir");
-	//alert(html);
     container = $('body.expressomail-module-container').append( html ).find(".expresso-window-container");
-    //alert("método raster 1");
-	//alert(container);
 	list_container = container.find(".rule-list-container");
-    //alert("método raster 2");
 	details_container = container.find(".rule-details-container");
-    //alert("método raster 3");
 	vacation_container = container.find(".vacation-details-container");
-    //alert("método raster 4");
 	form = container.find("form");
-    
-	//alert("método raster 5");
     criterias = details_container.find( 'fieldset input[name="criteriaType[]"]' );
-    //alert("método raster 6");
 	actions = details_container.find( 'fieldset input[name="actionType[]"]' );
-    //alert("método raster 7");
 	nameObj = details_container.find( 'input[name="name"]' );
-    //alert("método raster 8");
 	isExact = details_container.find( 'input[name="isExact"]' );
-	//alert("método raster 9");
     formatter();
-    //alert("método raster 10");
     container = container.dialog({
 	    width:700,
@@ -263,13 +241,11 @@
 	    autoOpen: false
     });
-    //alert("método raster 11");
     details_container.accordion({autoHeight: false});
     
-	//alert("método raster 12");
     DataLayer.render( BASE_PATH + 'api/templates/folderselect.ejs', 'folder:select', function( html ){
 	  details_container.find(".select-folderlist").append( html );
     });
 
-	//alert("método raster 13");
+
     container.find(".button").button()
     
@@ -299,5 +275,5 @@
 
     });
-	//alert("método raster 14");
+
     details_container.find( ".menu-container" )
 
@@ -438,5 +414,5 @@
 		  
     });
-    //alert("método raster 15");
+
     vacation_container.find( ".menu-container" )
 	.find(".button.back").click(function(event){
@@ -456,5 +432,5 @@
 		return( false );
 	}); 
-	//alert("método raster 16");	
+
 }
 
@@ -618,23 +594,4 @@
 	.removeClass('ui-button-icon-only');
 };
-
-//DataLayer.render(BASE_PATH + 'modules/filters/filters.ejs', {}, 'filter:detail', reraster, true);
-//var vamo_ver = DataLayer.render(BASE_PATH + 'modules/filters/filters.ejs', {});
-//raster(vamo_ver);
-//alert(vamo_ver);
-var v = DataLayer.render( BASE_PATH + 'modules/filters/filters.ejs', {});
-raster(v);
-		details_container.accordion('activate',0);
-
-		showGridButton.removeClass('hidden');
-		grid.addClass('hidden').jqGrid('GridDestroy');
-	  
-		list_container.removeClass('hidden');
-		details_container.addClass('hidden');
-		
-DataLayer.render( BASE_PATH + 'modules/filters/filter-list.ejs', 'filter:detail', reraster );
-//var v = DataLayer.get("filter:detail");
-
-//alert(v);
 // ------------------------------------------------------------
 // ------------------------------------------------------------    
@@ -679,110 +636,38 @@
 	$(".ui-dialog-buttonpane.ui-widget-content").css("background-color", "#E0EEEE");
 	var zu = DataLayer.render( BASE_PATH + 'modules/filters/filter-list.ejs', DataLayer.get("filter:detail", true));
-//	DataLayer.render( BASE_PATH + 'modules/filters/filter-list.ejs', 'filter:detail',function(html){
-		list_container.html(zu).find(".button").button();
-		
-		list_container.find(".rule-list").selectable({
-			selecting: function(event, ui) {
-				$(ui.selecting).find(':checkbox').attr('checked', true);
-			},
-			unselecting: function(event, ui) {
-				$(ui.unselecting).find(':checkbox').attr('checked', false);
-			}
-		});
-		
-		$( ".menu-control .button" ).filter(".update").button({
-			icons: {
-				primary: "ui-icon-pencil"
-			},
-			text: false
-		}).click(function(){
-			var id = $(this).parents("li.rule").find('.title').html();
-			var filters = DataLayer.get( 'filter', true);
-			for(var i =0; i < filters.length; i++){
-				if(filters[i].id == id){
-					filters = filters[i];
-					break;
-				}	
-			}
-			DataLayer.render( BASE_PATH + 'modules/filters/edit-filter.ejs', {folders : DataLayer.get("folder", true)},function(html){
-				var details_container = $(".expresso-window-filters").html(html);
-				if(filters.name != "vacation"){
-					form = container.find("form");
-					criterias = details_container.find( 'fieldset input[name="criteriaType[]"]' );
-					actions = details_container.find( 'fieldset input[name="actionType[]"]' );
-					nameObj = details_container.find( 'input[name="name"]' );
-					isExact = details_container.find( 'input[name="isExact"]' );
-					showDetails(filters);
-					var accord = $(".rule-details-container").accordion({autoHeight: false});
-					$(".button").button().filter(".forth").click(function(){
-						accord.accordion('activate',1);
-					}).end().filter(".back").click(function(){
-						accord.accordion('activate',0);
-					}).end().filter(".cancel").click(function(){
-						DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters);
-					}).end().filter(".submit").click(function(){
-						if(nameObj)
-							nameObj.attr("disabled", "false");
-						$(this).submit();
-						DataLayer.commit( 'filter' );
-						DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters);
-					});
-				}else{
-					$(".vacation-details-container").removeClass("hidden");
-					$(".rule-details-container").addClass("hidden");
-					$(".button").button().filter(".back").click(function(){
-						DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters);
-					}).end().filter(".submit").click(function(){
-						$(this).submit();
-						DataLayer.commit( 'filter' );
-						DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters);
-					});
-					details_container.find('[name="vacation"]').val(filters.actions[0].parameter);
-				}
-			});
-		}).end()
-		.filter(".enable").button({
-			icons: {
-				primary: "ui-icon-circle-check"
-			},
-			text: false
-		}).click(function(){
-			var id = $(this).parents("li.rule").find('.title').html();
-			DataLayer.put( 'filter', id, { enabled: "disable"  });
-			DataLayer.commit("filter");
-			DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters);
-		}).end()
-
-		.filter(".disable").button({
-			icons: {
-				primary: "ui-icon-circle-close"
-			},
-			text: false
-		}).click(function(){
-			var id = $(this).parents("li.rule").find('.title').html();
-			DataLayer.put( 'filter', id, { enabled: "enabled" });
-			DataLayer.commit("filter");
-			DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters);
-		}).end()
-		
-		.filter(".close").button({
-			icons: {
-				primary: "ui-icon-close"
-			},
-			text: false
-		}).click(function(){
-			$(event.target)
-			.parents("li.rule").find('.title')
-			.each( function(){
-				DataLayer.remove( 'filter', $(this).html() );
-			});
-			DataLayer.commit("filter");
-			DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters);
-		}).end().removeClass("ui-button-icon-only");
-		
-		$(".button.add:first").click(function(){
-			$(".dialog-head-buttonpane").addClass("hidden");
-			DataLayer.render( BASE_PATH + 'modules/filters/edit-filter.ejs', {folders : DataLayer.get("folder", true)},function(html){
-				$(".expresso-window-filters").html(html);
+	list_container.html(zu).find(".button").button();
+	
+	list_container.find(".rule-list").selectable({
+		selecting: function(event, ui) {
+			$(ui.selecting).find(':checkbox').attr('checked', true);
+		},
+		unselecting: function(event, ui) {
+			$(ui.unselecting).find(':checkbox').attr('checked', false);
+		}
+	});
+	
+	$( ".menu-control .button" ).filter(".update").button({
+		icons: {
+			primary: "ui-icon-pencil"
+		},
+		text: false
+	}).click(function(){
+		var id = $(this).parents("li.rule").find('.title').html();
+		var filters = DataLayer.get( 'filter', true);
+		for(var i =0; i < filters.length; i++){
+			if(filters[i].id == id){
+				filters = filters[i];
+				break;
+			}	
+		}
+		DataLayer.render( BASE_PATH + 'modules/filters/edit-filter.ejs', {folders : DataLayer.get("folder", true)},function(html){
+			var details_container = $(".expresso-window-filters").html(html);
+			if(filters.name != "vacation"){
+				form = container.find("form");
+				criterias = details_container.find( 'fieldset input[name="criteriaType[]"]' );
+				actions = details_container.find( 'fieldset input[name="actionType[]"]' );
+				nameObj = details_container.find( 'input[name="name"]' );
+				isExact = details_container.find( 'input[name="isExact"]' );
+				showDetails(filters);
 				var accord = $(".rule-details-container").accordion({autoHeight: false});
 				$(".button").button().filter(".forth").click(function(){
@@ -793,15 +678,11 @@
 					DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters);
 				}).end().filter(".submit").click(function(){
+					if(nameObj)
+						nameObj.attr("disabled", "false");
 					$(this).submit();
 					DataLayer.commit( 'filter' );
 					DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters);
 				});
-				//$(".rule-edit-container").html(html);
-			});	
-		});
-		$(".button.add.vacation").click(function(){
-			$(".dialog-head-buttonpane").addClass("hidden");
-			DataLayer.render( BASE_PATH + 'modules/filters/edit-filter.ejs', {folders : DataLayer.get("folder", true)},function(html){
-				$(".expresso-window-filters").html(html);
+			}else{
 				$(".vacation-details-container").removeClass("hidden");
 				$(".rule-details-container").addClass("hidden");
@@ -813,10 +694,81 @@
 					DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters);
 				});
-				//$('[name="vacation"]').elastic().unbind('blur');
-				//$(".back").click(function(){
-				//$(".rule-edit-container").html(html);
-			});	
+				details_container.find('[name="vacation"]').val(filters.actions[0].parameter);
+			}
 		});
-//	});
+	}).end()
+	.filter(".enable").button({
+		icons: {
+			primary: "ui-icon-circle-check"
+		},
+		text: false
+	}).click(function(){
+		var id = $(this).parents("li.rule").find('.title').html();
+		DataLayer.put( 'filter', id, { enabled: "disable"  });
+		DataLayer.commit("filter");
+		DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters);
+	}).end()
+
+	.filter(".disable").button({
+		icons: {
+			primary: "ui-icon-circle-close"
+		},
+		text: false
+	}).click(function(){
+		var id = $(this).parents("li.rule").find('.title').html();
+		DataLayer.put( 'filter', id, { enabled: "enabled" });
+		DataLayer.commit("filter");
+		DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters);
+	}).end()
+	
+	.filter(".close").button({
+		icons: {
+			primary: "ui-icon-close"
+		},
+		text: false
+	}).click(function(){
+		$(event.target)
+		.parents("li.rule").find('.title')
+		.each( function(){
+			DataLayer.remove( 'filter', $(this).html() );
+		});
+		DataLayer.commit("filter");
+		DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters);
+	}).end().removeClass("ui-button-icon-only");
+	
+	$(".button.add:first").click(function(){
+		$(".dialog-head-buttonpane").addClass("hidden");
+		DataLayer.render( BASE_PATH + 'modules/filters/edit-filter.ejs', {folders : DataLayer.get("folder", true)},function(html){
+			$(".expresso-window-filters").html(html);
+			var accord = $(".rule-details-container").accordion({autoHeight: false});
+			$(".button").button().filter(".forth").click(function(){
+				accord.accordion('activate',1);
+			}).end().filter(".back").click(function(){
+				accord.accordion('activate',0);
+			}).end().filter(".cancel").click(function(){
+				DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters);
+			}).end().filter(".submit").click(function(){
+				$(this).submit();
+				DataLayer.commit( 'filter' );
+				DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters);
+			});
+			//$(".rule-edit-container").html(html);
+		});	
+	});
+	$(".button.add.vacation").click(function(){
+		$(".dialog-head-buttonpane").addClass("hidden");
+		DataLayer.render( BASE_PATH + 'modules/filters/edit-filter.ejs', {folders : DataLayer.get("folder", true)},function(html){
+			$(".expresso-window-filters").html(html);
+			$(".vacation-details-container").removeClass("hidden");
+			$(".rule-details-container").addClass("hidden");
+			$(".button").button().filter(".back").click(function(){
+				DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters);
+			}).end().filter(".submit").click(function(){
+				$(this).submit();
+				DataLayer.commit( 'filter' );
+				DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters);
+			});
+		});	
+	});
 }
 
