49
| <![CDATA[<script type="text/javascript">
jQuery(function($) {
$('.hasTip').each(function() {
var title = $(this).attr('title');
if (title) {
var parts = title.split('::', 2);
var mtelement = document.id(this);
mtelement.store('tip:title', parts[0]);
mtelement.store('tip:text', parts[1]);
}
});
var JTooltips = new Tips($('.hasTip').get(), {"maxTitleChars": 50,"fixed": false});
});
jQuery(function ($) {
initChosen();
$("body").on("subform-row-add", initChosen);
function initChosen(event, container)
{
container = container || document;
$(container).find("select").chosen({"disable_search_threshold":10,"search_contains":true,"allow_single_deselect":true,"placeholder_text_multiple":"Digite ou selecione algumas op\u00e7\u00f5es","placeholder_text_single":"Selecione uma op\u00e7\u00e3o","no_results_text":"Selecione alguma op\u00e7\u00e3o"});
}
});
jQuery(document).ready(function($){
jQuery('.hasTooltip').tooltip({"html": true});
if(window.MooTools) {
// Mootools conflict fix for toggle with Bootstrap 3/JQuery
window.addEvent('load', function() {
$$('[rel=tooltip],[data-toggle],a[data-toggle],button[data-toggle],[data-toggle=collapse],a[data-toggle=dropdown],.hasTooltip').each(function (e) {
e.getParent().hide = null;
e.hide = null;
});
});
}
});
(function($,b){$.fn.BlackAndWhite_init=function(){var a=$(this);a.find("img").not(".slide-img").parent().BlackAndWhite({invertHoverEffect:1,intensity:1,responsive:true,speed:{fadeIn:500,fadeOut:500}})}})(jQuery);jQuery(window).load(function($){jQuery(".item_img a").find("img").not(".lazy").parent().BlackAndWhite_init()});
var path = "templates/theme3308/js/";
(function($){$(document).ready(function(){var o=$("#back-top");$(window).scroll(function(){if($(this).scrollTop()>100){o.fadeIn()}else{o.fadeOut()}});var $scrollEl=($.browser.mozilla||$.browser.msie)?$("html"):$("body,html");o.find("a").click(function(){$scrollEl.animate({scrollTop:0},400);return false})})})(jQuery);
</script>]]>
|
135
| <![CDATA[<script type="text/javascript">
var Remediador = {
form: null,
municipioSelect: null,
estadoSelect: null,
arrayPaisFabricante: [],
arrayPaisImportador: [],
arrayCNPJFabricante:[],
arrayCNPJImportador:[],
arrayFabricante : {
"estado":[],
"municipio":[]
},
arrayImportadores : {
"estado":[],
"municipio":[]
},
init: function () {
this.setChange();
this.startForm();
this.setClickEvents();
this.validateForm();
this.validateCPF();
this.validateCNPJ();
this.mascaras();
jQuery('#block-fabricantes table th a.group-add').click();
jQuery('#block-produto table th a.group-add').click();
jQuery('#block-toxicidade table th a.group-add').click();
},
startForm: function(){
jQuery('.cpf').attr( "required", "true" );
jQuery(".municipio-ofertante").append('<option value="">Selecione</option>').trigger('liszt:updated');
Remediador.fabricantes();
Remediador.importadores();
},
setChange: function() {
jQuery('.estado-ofertante').change(function () {
let obj = jQuery(this);
let uf = obj.val();
Remediador.municipioSelect = jQuery(".municipio-ofertante");
Remediador.loadMunicipiosAjax(uf);
});
jQuery('.registrado-ibama').change(function () {
if(jQuery('.registrado-ibama').prop('checked')){
jQuery('#numero-processo-registro').show();
jQuery("#numero-processo-registro :input").attr("required", "true");
jQuery("#numero-processo-registro :input").attr("aria-required", "true");
jQuery('.dados-produtos').hide();
jQuery(".dados-produtos :input").removeAttr("aria-required");
jQuery(".dados-produtos :input").removeAttr("required");
}else{
jQuery("#numero-processo-registro :input").removeAttr( "required");
jQuery("#numero-processo-registro :input").removeAttr( "aria-required");
jQuery('#numero-processo-registro').hide();
jQuery('.dados-produtos').show();
jQuery(".dados-produtos :input").attr('required');
jQuery(".dados-produtos :input").attr('aria-required');
}
});
jQuery('.seguranca-aplicacao').change(function () {
if(jQuery('.seguranca-aplicacao').prop('checked')){
jQuery("#ficha-seguranca :input").removeAttr('aria-required');
jQuery("#ficha-seguranca :input").removeAttr('required');
jQuery('#ficha-seguranca').hide();
}else{
jQuery('#ficha-seguranca').show();
jQuery("#ficha-seguranca :input").attr('aria-required');
jQuery("#ficha-seguranca :input").attr('required');
}
});
jQuery('.bio-aplicacao').change(function () {
if(jQuery('.bio-aplicacao').prop('checked')){
jQuery('#biorremediadores').hide();
jQuery("#biorremediadores:input").removeAttr('aria-required');
jQuery("#biorremediadores:input").removeAttr('required');
}else{
jQuery('#biorremediadores').show();
jQuery("#biorremediadores :input").attr('required');
jQuery("#biorremediadores :input").attr('aria-required');
}
});
},
loadEstadosAjax: function(vp){
Remediador.estadoSelect.html('')
jQuery.ajax({
type: "GET",
dataType: "json",
url: "http://ibama.gov.br/index.php?option=com_remediadores&task=remediadorform.getEstados",
success: function(data){
Remediador.estadoSelect.append('<option>Selecione o estado</option>').trigger('liszt:updated');
jQuery.each(data.data, function (key, value) {
Remediador.estadoSelect.append("<option value='" +value.uf+ "'>" + value.nome_estado + "</option>");
});
Remediador.estadoSelect.trigger('liszt:updated');
},
});
},
loadMunicipiosAjax: function(vuf){
Remediador.municipioSelect.html('')
jQuery.ajax({
type: "GET",
dataType: "json",
url: "http://ibama.gov.br/index.php?option=com_remediadores&task=remediadorform.getMunicipios",
data: {uf: vuf},
success: function(data){
Remediador.municipioSelect.append('<option>Selecione uma cidade</option>').trigger('liszt:updated');
jQuery.each(data.data, function (key, value) {
Remediador.municipioSelect.append("<option value='" +value.muncod+ "'>" + value.nome_municipio + "</option>");
});
Remediador.municipioSelect.trigger('liszt:updated');
},
});
},
setClickEvents: function () {
jQuery('input[type="radio"]').click(function(){
let tipoPessoa = jQuery("input[name='jform[tipo_pessoa]']:checked").val();
if(tipoPessoa == 1){
jQuery('.cpf').attr( "required", "true" );
jQuery('.cnpj').removeAttr( "required");
}else{
jQuery('.cnpj').attr( "required", "true" );
jQuery('.cpf').removeAttr( "required");
}
});
jQuery("#block-fabricantes .group-add").click(function(){
Remediador.fabricantes();
});
jQuery("#block-importadores .group-add").click(function(){
Remediador.importadores();
});
},
fabricantes: function(){
setTimeout(function () {
Remediador.mascaras();
Remediador.validateCNPJFabricante();
jQuery("#block-fabricantes .group-add").unbind();
Remediador.setClickEvents();
Remediador.arrayPaisFabricante.length= 0;
Remediador.arrayCNPJFabricante.length= 0;
Remediador.arrayFabricante["estado"].length = 0;
Remediador.arrayFabricante["municipio"].length = 0;
jQuery( "#block-fabricantes .pais-fabricante" ).each(function( index ) {
Remediador.arrayPaisFabricante.push(this.id);
});
jQuery( "#block-fabricantes .cnpj-fabricante" ).each(function( index ) {
Remediador.arrayCNPJFabricante.push(this.id);
});
jQuery( "#block-fabricantes .estado-fabricante" ).each(function( index ) {
Remediador.arrayFabricante["estado"].push(this.id);
});
jQuery( "#block-fabricantes .municipio-fabricante" ).each(function( index ) {
Remediador.arrayFabricante["municipio"].push(this.id);
});
jQuery.each(Remediador.arrayPaisFabricante, function (key, value) {
jQuery.each(Remediador.arrayFabricante.estado, function (chave, valor) {
jQuery("#"+value).change(function () {
let obj = jQuery(this);
let p = obj.val();
if(p == "BR"){
Remediador.estadoSelect = jQuery("#"+valor);
Remediador.loadEstadosAjax();
}
});
});
});
jQuery.each(Remediador.arrayFabricante.estado, function (key, value) {
jQuery.each(Remediador.arrayFabricante.municipio, function (chave, valor) {
jQuery("#"+value).change(function () {
let obj = jQuery(this);
let uf = obj.val();
Remediador.municipioSelect = jQuery("#"+valor);
Remediador.loadMunicipiosAjax(uf);
});
});
});
jQuery.each(Remediador.arrayCNPJFabricante, function (key, value) {
Remediador.validateCNPJFabricante(value);
});
}, 200);
},
importadores: function(){
setTimeout(function () {
Remediador.mascaras();
Remediador.validateCNPJImportador();
jQuery("#block-importadores .group-add").unbind();
Remediador.setClickEvents();
Remediador.arrayPaisImportador.length= 0;
Remediador.arrayCNPJImportador.length= 0;
Remediador.arrayImportadores["estado"].length = 0;
Remediador.arrayImportadores["municipio"].length = 0;
jQuery( "#block-importadores .pais-importador" ).each(function( index ) {
Remediador.arrayPaisImportador.push(this.id);
});
jQuery( "#block-importadores .cnpj-importador" ).each(function( index ) {
Remediador.arrayCNPJImportador.push(this.id);
});
jQuery( "#block-importadores .estado-importador" ).each(function( index ) {
Remediador.arrayImportadores["estado"].push(this.id);
});
jQuery( "#block-importadores .municipio-importador" ).each(function( index ) {
Remediador.arrayImportadores["municipio"].push(this.id);
});
jQuery.each(Remediador.arrayPaisImportador, function (key, value) {
jQuery.each(Remediador.arrayImportadores.estado, function (chave, valor) {
jQuery("#"+value).change(function () {
let obj = jQuery(this);
let p = obj.val();
if(p == "BR"){
Remediador.estadoSelect = jQuery("#"+valor);
Remediador.loadEstadosAjax();
}
});
});
});
jQuery.each(Remediador.arrayImportadores.estado, function (key, value) {
jQuery.each(Remediador.arrayImportadores.municipio, function (chave, valor) {
jQuery("#"+value).change(function () {
let obj = jQuery(this);
let uf = obj.val();
Remediador.municipioSelect = jQuery("#"+valor);
Remediador.loadMunicipiosAjax(uf);
});
});
});
jQuery.each(Remediador.arrayCNPJImportador, function (key, value) {
Remediador.validateCNPJImportador(value);
});
}, 200);
},
validateCPF: function(){
jQuery( ".cpf" ).change(function() {
jQuery("#error-cpfcnpj").hide();
var Soma;
var Resto;
var cpf = jQuery( ".cpf" ).val();
cpf = cpf.replace(/[^\d]+/g,'');
Soma = 0;
if (cpf == "00000000000") return jQuery("#error-cpfcnpj").html('CPF inválido').show();
for (i=1; i<=9; i++) Soma = Soma + parseInt(cpf.substring(i-1, i)) * (11 - i);
Resto = (Soma * 10) % 11;
if ((Resto == 10) || (Resto == 11)) Resto = 0;
if (Resto != parseInt(cpf.substring(9, 10)) ) return jQuery("#error-cpfcnpj").html('CPF inválido').show();
Soma = 0;
for (i = 1; i <= 10; i++) Soma = Soma + parseInt(cpf.substring(i-1, i)) * (12 - i);
Resto = (Soma * 10) % 11;
if ((Resto == 10) || (Resto == 11)) Resto = 0;
if (Resto != parseInt(cpf.substring(10, 11) ) ) return jQuery("#error-cpfcnpj").html('CPF inválido').show();
return true;
});
},
validateCNPJ: function(){
jQuery( ".cnpj" ).change(function() {
jQuery("#error-cpfcnpj").hide();
var cnpj = jQuery( ".cnpj" ).val();
cnpj = cnpj.replace(/[^\d]+/g,'');
if(cnpj == ''){
return jQuery("error-cpfcnpj").html('CNPJ inválido').show();
}
if (cnpj.length != 14){
return jQuery("#error-cpfcnpj").html('CNPJ inválido').show();
}
// Elimina CNPJs invalidos conhecidos
if (cnpj == "00000000000000" ||
cnpj == "11111111111111" ||
cnpj == "22222222222222" ||
cnpj == "33333333333333" ||
cnpj == "44444444444444" ||
cnpj == "55555555555555" ||
cnpj == "66666666666666" ||
cnpj == "77777777777777" ||
cnpj == "88888888888888" ||
cnpj == "99999999999999"){
return jQuery("#error-cpfcnpj").html('CNPJ inválido').show();
}
// Valida DVs
var tamanho = cnpj.length - 2
var numeros = cnpj.substring(0,tamanho);
var digitos = cnpj.substring(tamanho);
var soma = 0;
var pos = tamanho - 7;
for (i = tamanho; i >= 1; i--) {
soma += numeros.charAt(tamanho - i) * pos--;
if (pos < 2){
pos = 9;
}
}
var resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;
if (resultado != digitos.charAt(0)){
return jQuery("#error-cpfcnpj").html('CNPJ inválido').show();
}
tamanho = tamanho + 1;
numeros = cnpj.substring(0,tamanho);
soma = 0;
pos = tamanho - 7;
for (var i = tamanho; i >= 1; i--) {
soma += numeros.charAt(tamanho - i) * pos--;
if (pos < 2)
pos = 9;
}
resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;
if (resultado != digitos.charAt(1)){
return jQuery("#error-cpfcnpj").html('CNPJ inválido').show();
}
return true;
});
},
validateCNPJFabricante : function(campocnpj){
jQuery( "#"+campocnpj ).change(function() {
jQuery("#error-cnpj-fabricante").hide();
var cnpj = jQuery( "#"+campocnpj ).val();
cnpj = cnpj.replace(/[^\d]+/g,'');
if(cnpj == ''){
return jQuery("#error-cnpj-fabricante").html('CNPJ inválido').show();
}
if (cnpj.length != 14){
return jQuery("#error-cnpj-fabricante").html('CNPJ inválido').show();
}
// Elimina CNPJs invalidos conhecidos
if (cnpj == "00000000000000" ||
cnpj == "11111111111111" ||
cnpj == "22222222222222" ||
cnpj == "33333333333333" ||
cnpj == "44444444444444" ||
cnpj == "55555555555555" ||
cnpj == "66666666666666" ||
cnpj == "77777777777777" ||
cnpj == "88888888888888" ||
cnpj == "99999999999999"){
return jQuery("#error-cnpj-fabricante").html('CNPJ inválido').show();
}
// Valida DVs
var tamanho = cnpj.length - 2
var numeros = cnpj.substring(0,tamanho);
var digitos = cnpj.substring(tamanho);
var soma = 0;
var pos = tamanho - 7;
for (i = tamanho; i >= 1; i--) {
soma += numeros.charAt(tamanho - i) * pos--;
if (pos < 2){
pos = 9;
}
}
var resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;
if (resultado != digitos.charAt(0)){
return jQuery("#error-cnpj-fabricante").html('CNPJ inválido').show();
}
tamanho = tamanho + 1;
numeros = cnpj.substring(0,tamanho);
soma = 0;
pos = tamanho - 7;
for (var i = tamanho; i >= 1; i--) {
soma += numeros.charAt(tamanho - i) * pos--;
if (pos < 2)
pos = 9;
}
resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;
if (resultado != digitos.charAt(1)){
return jQuery("#error-cnpj-fabricante").html('CNPJ inválido').show();
}
return true;
});
},
validateCNPJImportador : function(campocnpj){
jQuery( "#"+campocnpj ).change(function() {
jQuery("#error-cnpj-importador").hide();
var cnpj = jQuery( "#"+campocnpj ).val();
cnpj = cnpj.replace(/[^\d]+/g,'');
if(cnpj == ''){
return jQuery("#error-cnpj-importador").html('CNPJ inválido').show();
}
if (cnpj.length != 14){
return jQuery("#error-cnpj-importador").html('CNPJ inválido').show();
}
// Elimina CNPJs invalidos conhecidos
if (cnpj == "00000000000000" ||
cnpj == "11111111111111" ||
cnpj == "22222222222222" ||
cnpj == "33333333333333" ||
cnpj == "44444444444444" ||
cnpj == "55555555555555" ||
cnpj == "66666666666666" ||
cnpj == "77777777777777" ||
cnpj == "88888888888888" ||
cnpj == "99999999999999"){
return jQuery("#error-cnpj-importador").html('CNPJ inválido').show();
}
// Valida DVs
var tamanho = cnpj.length - 2
var numeros = cnpj.substring(0,tamanho);
var digitos = cnpj.substring(tamanho);
var soma = 0;
var pos = tamanho - 7;
for (i = tamanho; i >= 1; i--) {
soma += numeros.charAt(tamanho - i) * pos--;
if (pos < 2){
pos = 9;
}
}
var resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;
if (resultado != digitos.charAt(0)){
return jQuery("#error-cnpj-importador").html('CNPJ inválido').show();
}
tamanho = tamanho + 1;
numeros = cnpj.substring(0,tamanho);
soma = 0;
pos = tamanho - 7;
for (var i = tamanho; i >= 1; i--) {
soma += numeros.charAt(tamanho - i) * pos--;
if (pos < 2)
pos = 9;
}
resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;
if (resultado != digitos.charAt(1)){
return jQuery("#error-cnpj-importador").html('CNPJ inválido').show();
}
return true;
});
},
mascaras: function () {
jQuery('.telefone').focusout(function(){
var phone, element;
element = jQuery(this);
element.unmask();
phone = element.val().replace(/\D/g, '');
if(phone.length > 12) {
element.mask("(99) 99999-9999");
} else {
element.mask("(99) 9999-9999?9");
}
}).trigger('focusout');
jQuery(".cpf").mask("999.999.999-99");
jQuery(".cnpj").mask("99.999.999/9999-99");
jQuery(".cnpj-fabricante").mask("99.999.999/9999-99");
jQuery(".cnpj-importador").mask("99.999.999/9999-99");
},
validateForm: function(){
this.form = jQuery("#form-remediador");
this.form.validate({
errorPlacement: function(error, element) {
error.insertBefore(element);
},
rules: {
field: {
required: true
},
email: {
email: true
}
}
});
},
}
jQuery(function () {
Remediador.init();
});
</script>]]>
|