{"version":3,"sources":["app.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"scripts.js","sourcesContent":["(function($){\n //Validacao de email e Mascara de telefone\n jQuery.validator.addMethod(\"testEmail\", function (value, element) {\n return this.optional(element) || /[-0-9a-zA-Z.+_]+@[-0-9a-zA-Z.+_]+\\.[a-zA-Z]{2,4}/i.test(value);\n }, \"Digite e-mail valido.\");\n\n var SPMaskBehavior = function (val) {\n return val.replace(/\\D/g, '').length === 11 ? '(00) 00000-0000' : '(00) 0000-00009';\n }, spOptions = {\n onKeyPress: function (val, e, field, options) {\n field.mask(SPMaskBehavior.apply({}, arguments), options);\n }\n };\n $('.celular-input').mask(SPMaskBehavior, spOptions);\n var CPFMaskBehavior = function (val) {\n return val.replace(/\\D/g, '').length === 11 ? '000.000.000-00' : '000.000.000-00';\n }, cpfOptions = {\n onKeyPress: function (val, e, field, options) {\n field.mask(CPFMaskBehavior.apply({}, arguments), options);\n }\n }\n $('.cpf-input').mask(CPFMaskBehavior, cpfOptions);\n var DateMaskBehavior = function (val) {\n return val.replace(/\\D/g, '').length === 8 ? '00-00-0000' : '00-00-0000';\n }, DateOptions= {\n onKeyPress: function (val, e, field, options) {\n field.mask(DateMaskBehavior.apply({}, arguments), options);\n }\n }\n $('.date-input').mask(DateMaskBehavior, DateOptions);\n var AppForm = function(){\n return{\n searchForm: function () {\n var cont = 0;\n $('#formConsulta').validate({\n rules: {\n chassi: {\n required: true,\n minlength: 7\n },\n optionCliente: {\n required: true\n }\n },\n messages: {\n chassi: {\n required: 'Informe o número do chassi',\n minlength: 'Informe o número completo do chassi'\n },\n optionCliente: {\n required: 'Selecione o tipo de Cliente'\n }\n }, submitHandler: function (form) {\n data = $('#formConsulta').serialize();\n var actBtn = $(form).find('button[type=\"submit\"]');\n var oldText = actBtn.text();\n var url = '/chassi';\n var divTarget = $('.content-sect');\n oldText = actBtn.text();\n actBtn.text('Consultando ...');\n actBtn.prop('disabled', true);\n $.ajax({\n url: url,\n data: data,\n dataType: 'json',\n method: 'post'\n }).done(function(jsondata){\n console.info(jsondata);\n if(jsondata.length == 0){\n if($('label.main.error').length == 0){\n element = '';\n actBtn.text(oldText);\n actBtn.prop('disabled', false);\n divTarget.removeClass('loaded');\n $('.newsletter-sect').removeClass('loaded');\n $('.main-sect .content-wrapper').append(element);\n }\n else {\n divTarget.removeClass('loaded');\n $('.newsletter-sect').removeClass('loaded');\n actBtn.text(oldText);\n actBtn.prop('disabled', false);\n return false;\n }\n }else{\n $('label.error').remove();\n divTarget.find('.block').remove();\n divTarget.find('.car-info .chassi .value').html(jsondata[0].num_chassi);\n divTarget.find('.car-info .modelo .value').html(jsondata[0].modelo);\n $.each(jsondata, function (data) {\n element =\n '
' +\n '
' +\n '
Nome da Campanha
' +\n '
' + jsondata[data].descricao_campanha+ '
' +\n '
'+\n '
' +\n '
Status
' +\n '
' + jsondata[data].status+ '
' +\n '
'+\n '
' +\n '
Observações
' +\n '
' + jsondata[data].observacao+ '
' +\n '
'+\n '
';\n divTarget.find('.block-wrapper').append(element);\n })\n setTimeout(function(){\n divTarget.addClass('loaded');\n $('.newsletter-sect').addClass('loaded');\n actBtn.text(oldText);\n actBtn.prop('disabled', false)\n }, 1000);\n if(divTarget.find('.block').length > 1){\n divTarget.find('.block').last().addClass('last');\n }\n }\n });\n value = $('#formConsulta input[name=\"chassi\"]').val();\n target = $('input#chassiNews');\n target.val(value);\n return false;\n }\n })\n },\n newsForm: function () {\n $('#formNewsletter').validate({\n rules: {\n nome: {\n required: true,\n minlength: 2,\n },\n email: {\n required: true,\n testEmail: true,\n email: true\n },\n cpf: {\n required: true,\n minlength: 11\n }\n },\n messages:{\n nome: {\n required: 'Informe seu nome',\n minlength: 'Informe seu nome'\n },\n email: {\n required: 'Informe seu e-mail',\n email: 'Informe um e-mail válido'\n },\n cpf:{\n required: 'Informe seu CPF',\n minlength: 'Informe seu CPF'\n }\n }, submitHandler: function(form){\n var actBtn = $(form).find('button[type=\"submit\"]');\n var oldText = actBtn.text();\n actBtn.text('Enviando...');\n actBtn.prop('disabled', true);\n var data = $(form).serialize();\n $.ajax({\n data: data,\n url: '/cliente',\n method: 'post'\n }).done(function (data) {\n console.warn('Dados do form: ', data);\n element = '';\n $(form).find('.info').append(element);\n $.each($(form).find('input'), function () {\n $(this).val('');\n $(this).removeClass('valid');\n })\n setTimeout(function () {\n $('.info label.success').hide();\n }, 5000);\n actBtn.text(oldText);\n actBtn.prop('disabled', false);\n }).error(function () {\n actBtn.text(oldText);\n actBtn.prop('disabled', false);\n })\n\n }\n });\n },\n init: function () {\n AppForm.searchForm();\n AppForm.newsForm();\n }\n }\n }();\n\n //Doc Ready\n $(function(){\n AppForm.init();\n });\n})(jQuery);"],"sourceRoot":"/source/"}