MrAntunes
12/2/2015 - 12:10 PM

- update DOM tree values with DOM state - convert inputs to static text

  • update DOM tree values with DOM state
  • convert inputs to static text
//>>>>>>>>>RÚBRICAS
		//update dos valores das textareas nas rubs pois os alterados entretanto ainda não fazem parte do DOM
		$("#rubTab").find("textarea").each(function () { $(this).text($(this).val());  });
		
		$("#confRubricas").empty().append($("#rubTab").html());
								
			//update dos valores das select nas rubs pois os alterados entretanto ainda não fazem parte do DOM
			$("#confRubricas").find("select").each(function () {
				
				//só executa caso não seja o valor original (não existe valor dinâmico)
				if (!$("option:selected", $("#rubTab #" + $(this).attr('id')))[0].defaultSelected) {
					
					$(this).find('option').removeAttr('selected');					
					$(this).find('option[value="' + $("#rubTab #" + $(this).attr('id')).val() + '"]').attr('selected', 'true');
				}
			});	
			
			//update dos valores das checkboxes nas rubs pois os alterados entretanto ainda não fazem parte do DOM
			$("#confRubricas").find("input:checkbox").each(function () { 
			
				if ($(this).is(":checked") != $("#rubTab #" + $(this).attr('id')).is(":checked")) {
					
					$(this).prop("checked", $("#rubTab #" + $(this).attr('id')).is(":checked"));
				}
			});
		
			$("#confRubricas").find(".delSub").remove(); 
			$("#confRubricas").find(".delRub").remove();
			$("#confRubricas").find("#AddMoreSubRub").remove();	
			
			//insirir divisões entre rúbricas
			$("#confRubricas").find(".rubsMain").each(function () { $("<div class='clearfix' /><hr>").insertAfter($(this)); });
			
			$("#confRubricas").find("input:checkbox").each(function () { 
				
				//remove label obrigatório, "tio-avô" - replace com col-md para a descrição não mudar de linha
				if (!($(this).is(":checked"))) 
					$(this).parent().parent().siblings(".labelObrig").replaceWith("<div class='col-md-5'/>");				
			});
			
			$("#confRubricas").find("span").remove();
			$("#confRubricas").find("select").each(function () { 
									
				$(this).replaceWith($("<span style='margin-left:10px' />").text($("option:selected", this).text()));
			});
			
			$("#confRubricas").find("textarea").each(function () { 
									
				$(this).replaceWith($("<span style='margin-left:50px' />").text($(this).val()));
			});
			
			$("#confRubricas").find('*').removeAttr('id');   
			
			///////////////////////////////////////////////////////////
			
			//update dos valores dos inputs nos artigos pois os alterados entretanto ainda não fazem parte do DOM
            $("#contentArtigos").find("input").each(function () { $(this).attr("value", $(this).val());  });
            $("#confArtigos").html($("#contentArtigos").html());
                $("#confArtigos").find(".btnDeleteArtigo").remove(); 
                $("#confArtigos").find("span").remove();
                $("#confArtigos").find("input").each(function () { 
                                        
                    $(this).replaceWith($("<span />").text($(this).val()));
                });
                $("#confArtigos").find('*').removeAttr('id');