Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script src="https://connect.facebook.net/en_US/all.js"></script>
- */
- var TenhoInteresse = {
- /* Tenho Interesse */
- blockRedActive: '',
- /* Usado nas páginas de Campanhas */
- esconderForm: true,
- /**
- init: TenhoInteresse.startTenhoInteresse({titulo: 'Tenho Interesse', descricao: 'Preencha o formulário', periodo: true, flOrigem: 'CS', unidade: true})
- @param titulo : String
- @param descricao: String
- @param periodo : true or false,
- @param flOrigem : String,
- @param unidade : true or false,
- @param unidadeDisplay: true or false,
- @param fbConnect: true or false,
- @param double : true or false,
- @param blockDisplay : true or false
- */
- startTenhoInteresse: function(object){
- // sempre será true
- object.unidade = true;
- var hidden = 'inside-hiden-content';
- var iconClose = '<a class="close-content-custom" onclick="TenhoInteresse.closeContent();"></a>';
- // se for true mostrar o bloco, por exemplo, na página de Land Pages
- if(object.blockDisplay){
- object.blockDisplay = 'block';
- hidden = '';
- iconClose = '';
- TenhoInteresse.esconderForm = false;
- }else{
- object.blockDisplay = 'none';
- }
- var html =
- '<span class="content '+hidden+' white" id="tenho-interesse" style="display: '+object.blockDisplay+'">'+
- iconClose+
- ' <article>'+
- ' <hgroup>'+
- ' <h3 style="color: black">'+object.titulo+'</h3>'+
- ' <p>'+
- object.descricao+
- ' </p>'+
- ' </hgroup>'+
- ' <form class="default-container" id="form-tenho-interesse">'+
- //' <input type="hidden" name="txtFilial" id="txtFilial" value="0">'+
- ' <input type="hidden" name="dsParamCanal" id="dsParamCanal" value="">'+
- ' <input type="hidden" name="dsFormatCanal" id="dsFormatCanal" value="">'+
- ' <input type="hidden" name="dsCreativeCanal" id="dsCreativeCanal" value="">'+
- ' <input type="hidden" name="servletCarregaLista" id="servletCarregaLista" value="/wps/PA_CIsaTenhoInteresse/ServletCarregaFiliais">'+
- ' <input type="hidden" name="servletTenhoInteresse" id="servletTenhoInteresse" value="/wps/PA_CIsaTenhoInteresse/ServletCadProspect">'+
- ' <input type="hidden" name="flOrigem" id="flOrigem" value="'+object.flOrigem+'">'+
- ' <input type="hidden" name="txtOrigemPagina" id="txtOrigemPagina" value="">'+
- ' <input type="hidden" name="txtTipoCadastro" id="txtTipoCadastro" value="CI">'+
- ' <span class="field-group field-full">'+
- ' <input type="text" class="input-default input-last" placeholder="Nome Completo" id="txtNome" name="txtNome">'+
- ' </span>'+
- ' <span class="field-group field-full">'+
- ' <input type="email" class="input-default input-last" placeholder="E-mail" id="txtEmail" name="txtEmail">'+
- ' </span>'+
- ' <span class="field-group field-full">'+
- ' <input type="text" class="input-default input-last" placeholder="Telefone" id="txtTelefone" name="txtTelefone">'+
- ' </span>';
- var txtOrigemPaginaCert;
- txtOrigemPaginaCert = window.location.pathname.split('/').pop();
- if(txtOrigemPaginaCert == 'toeflibt' || txtOrigemPaginaCert == 'ieltsukvi' || txtOrigemPaginaCert == 'ieltslifeskills' || txtOrigemPaginaCert == 'ielts' || txtOrigemPaginaCert == 'anac' || txtOrigemPaginaCert == 'celta' || txtOrigemPaginaCert == 'testesproficiencia'){
- html+=
- '<input type="hidden" name="txtFilial" id="txtFilial" value="153">';
- }else if (txtOrigemPaginaCert == 'vila-leopoldina'){
- html+=
- '<input type="hidden" name="txtFilial" id="txtFilial" value="1">';
- }else {
- html+=
- '<input type="hidden" name="txtFilial" id="txtFilial" value="0">';
- }
- if(object.unidade == true){
- // Carrega lista oculta das unidades da Cultura Inglesa
- if(object.unidadeDisplay){
- object.unidadeDisplay = 'block';
- }else{
- object.unidadeDisplay = 'none';
- }
- html +=
- ' <div id="dvFilial" class="field-group field-full active" style="display:'+object.unidadeDisplay+'"></div>'+
- ' <div id="flag" style="display: none;">'+
- ' <span style="display:none">Carrega lista oculta das unidades da Cultura Inglesa</span>'+
- ' </div>';
- }
- html+=
- ' <div id="mensagemRetorno"></div>';
- if(object.periodo == true){
- html +=
- ' <span class="field-group field-full active" id="periodo-contato" style="font-weight: bold; display: block; text-align: center;">'+
- ' <label> <b>Prefiro ser contatado(a) durante: </b></label><br>'+
- ' <input type="checkbox" name="chk_manha" id="chk_manha" value="manha" ></input> <label for="chk_manha" > <b>Manhã </b> </label> '+
- ' <input type="checkbox" name="chk_tarde" id="chk_tarde" value="tarde" ></input> <label for="chk_tarde" > <b>Tarde </b> </label> '+
- ' <input type="checkbox" name="chk_noite" id="chk_noite" value="noite" ></input> <label for="chk_noite" > <b>Noite </b> </label> '+
- ' <input type="checkbox" name="chk_sabado" id="chk_sabado" value="sabado"></input> <label for="chk_sabado"> <b>Sábado </b> </label> '+
- ' </span>';
- }
- if(object.fbConnect == true){
- html +=
- ' <span class="btn-group" id="fb-connect" style="float: left; cursor: pointer">'+
- ' <div class="g-recaptcha" data-sitekey="6LdjNUwUAAAAAHodXKgNJjXvOfZe7X6fDhslgHhf"></div>'+
- ' <a class="btn-block fb-connect" onclick="FacebookConnect.open();dataLayer.push({'event': 'clickEvent', 'eventCategory': ''+txtOrigemPaginaCert+'', 'eventAction': 'clique:facebook', 'eventLabel': ''+txtOrigemPaginaCert+''});" style="background: #3b5998">Facebook</a>'+
- ' </span>';
- }
- html +=
- ' <span class="btn-group" style="float: right; cursor: pointer">'+
- ' <a class="btn-block" id="send" onclick="TenhoInteresse.enviarDados();">Enviar</a>'+
- ' <img src="/wps/wcm/connect/3a597c1b-955c-480f-9a72-373d3e401ff2/loading.gif?MOD=AJPERES&CACHEID=3a597c1b-955c-480f-9a72-373d3e401ff2" id="loading" style="display:none;"/>'+
- ' </span>'+
- ' <p><br /></p>'+
- ' <script src="https://www.google.com/recaptcha/api.js" async defer></script>'+
- ' </form>'+
- ' </article>'+
- '</span>';
- // CSS
- html +=
- ' <style>'+
- ' .close-content-custom {'+
- ' display: block;'+
- ' position: absolute;'+
- ' right: 15px;'+
- ' top: 15px;'+
- ' cursor: pointer;'+
- ' width: 29px;'+
- ' height: 50px;'+
- ' z-index: 10;'+
- ' background: url(/wps/wcm/connect/8f91142b-9775-4868-bc17-6bc4444d4ec0/close-2.png?MOD=AJPERES) no-repeat;'+
- ' cursor: pointer;'+
- ' }'+
- ' #blocks .text-left article hgroup h4, #blocks .text-left article hgroup h6, #blocks .text-left article hgroup h3 {'+
- ' text-align: center;'+
- ' }'+
- // contolar resolução
- ' #mensagemRetorno {'+
- ' position: absolute;'+
- ' bottom: 80px;'+
- ' font-weight: bold;'+
- ' color: red;'+
- ' }'+
- ' @media screen and (min-width: 1220px) and (max-width: 1500px){'+
- ' #mensagemRetorno {'+
- ' bottom: 50px;'+
- ' }'+
- ' }'+
- ' </style>';
- $('#block-tenho-interesse').html(html);
- /* depois de montar o template, chamar as funções necessárias */
- // carregar servlet de filiais
- if(object.unidade == true){
- TenhoInteresse.loadFiliais();
- }
- // obter final da URL
- TenhoInteresse.getURL();
- // obter código CD quando for 'none'
- if(object.unidadeDisplay == 'none'){
- TenhoInteresse.obterCDUnidade();
- }
- $('#dsParamCanal').val(TenhoInteresse.obterParametroUrl('pCanal'));
- $('#dsFormatCanal').val(TenhoInteresse.obterParametroUrl('fmtCanal'));
- $('#dsCreativeCanal').val(TenhoInteresse.obterParametroUrl('ctvCanal'));
- $('#txtTelefone').setMask('cel');
- $('#txtTelefone').blur(function(e){
- TenhoInteresse.formataFone($(this));
- });
- // corrgigir bug block red
- if(object.flOrigem == 'CS' || object.flOrigem == 'CE'){
- //TenhoInteresse.bugBlockRed();
- TenhoInteresse.blockRedActive = object.flOrigem;
- }
- },
- getURL: function(){
- $('#txtOrigemPagina').val(window.location.pathname.split('/').pop());
- },
- bugBlockRed: function(){
- /* Quando o block é red, o layout não fica amigavél */
- if($('#porque-fazer').hasClass('active')){
- $('#porque-fazer').removeClass('active').removeClass('white').addClass('red');
- }else{
- $('#porque-fazer').addClass('active').removeClass('red').addClass('white');
- }
- },
- enviarDados: function(){
- var nome = $("#txtNome").val();
- var email = $("#txtEmail").val();
- var telefone = $("#txtTelefone").val();
- var unidades = $("#txtFilial").val();
- var msg = "";
- var manha = $("#chk_manha").prop('checked');
- var tarde = $("#chk_tarde").prop('checked');
- var noite = $("#chk_noite").prop('checked');
- var sabado = $("#chk_sabado").prop('checked');
- var resultEnviarDados;
- var txtPagina = window.location.pathname.split('/').pop();
- if((nome == null) || (nome == "") || (nome == 'undefined')){
- msg = "*O campo nome completo não foi preenchido.";
- }else if((email == null) || (email == "") || (email == 'undefined') || (!TenhoInteresse.validaEmail(email))) {
- msg = "*O campo email não foi preenchido corretamente.";
- }else if((telefone == null) || (telefone == "") || (telefone == 'undefined')){
- msg = "*O campo telefone não foi preenchido.";
- }else if($('#dvFilial').hasClass('active')){
- if(unidades == "0"){
- msg = "*Selecione a unidade.";
- }
- }
- enviarDados = function() {
- var recaptcha = document.forms["enviarDados"]["g-recaptcha-response"];
- recaptcha.required = true;
- recaptcha.oninvalid = function(e) {
- // Mensagem para o usuário
- alert("Por favor complete o raCaptcha");
- }
- }
- /*if($('#periodo-contato').hasClass('active')){
- if(msg.length == 0){
- if(!manha || !tarde || !noite || !sabado){
- msg = "Selecione pelo menos um horário de contato.";
- }
- }
- }*/
- if(msg.length > 0){
- $('#mensagemRetorno').html(msg);
- //alert(msg);
- resultEnviarDados = "incorreto";
- dataLayer.push({'event': 'clickEvent', 'eventCategory': 'lp:'+txtPagina+'', 'eventAction': 'contato:click', 'eventLabel': 'cadastro:'+resultEnviarDados+''});
- return false;
- } else {
- resultEnviarDados = "sucesso";
- dataLayer.push({'event': 'clickEvent', 'eventCategory': 'lp:'+txtPagina+'', 'eventAction': 'contato:click', 'eventLabel': 'cadastro:'+resultEnviarDados+''});
- $('#loading').show();
- $('#send').hide();
- $('#flag').load($('#servletTenhoInteresse').val(), $('#form-tenho-interesse').serialize(), function() {
- if ($('#flag').html().indexOf('</div>') == -1 && $('#flag').html().indexOf('</DIV>') == -1) {
- eval($('#flag').html());
- //$('#porque-fazer').addClass('red').removeClass('white');
- $('#txtNome').val('');
- $('#txtEmail').val('');
- $('#txtTelefone').val('');
- $('#txtFilialX').val('')
- $('#loading').hide();
- $('#send').show();
- if(TenhoInteresse.esconderForm){
- $('#mensagemRetorno').html("Seu cadastro foi realizado com sucesso!");
- //alert('Seu cadastro foi realizado com sucesso! Em breve a unidade entrará em contato.');
- //TenhoInteresse.closeContent(/*'#tenho-interesse'*/);
- //TenhoInteresse.bugBlockRed();
- }
- } else {
- alert($('#flag').html());
- $('#loading').hide();
- $('#send').show();
- }
- });
- }
- },
- validaEmail: function(email){
- var filter = /^([w-]+(?:.[w-]+)*)@((?:[w-]+.)*w[w-]{0,66}).([a-z]{2,6}(?:.[a-z]{2})?)$/i;
- if(filter.test(email)){
- return true;
- }
- return false;
- },
- formataFone: function(input){
- var telefone = $(input).val();
- if (telefone.trim().length == 14) {
- var v = telefone.trim();
- v=v.replace(/D/g,"") //Remove tudo o que não é dígito
- v=v.replace(/^(dd)(d)/g,"($1) $2") //Coloca parênteses em volta dos dois primeiros dígitos
- v=v.replace(/(d{4})(d)/,"$1-$2") //Coloca hífen entre o quarto e o quinto dígitos
- $(input).val(v);
- }
- else if (telefone.trim().length == 15) {
- var v = telefone.trim();
- v=v.replace(/D/g,"") //Remove tudo o que não é dígito
- v=v.replace(/^(dd)(d)/g,"($1) $2") //Coloca parênteses em volta dos dois primeiros dígitos
- v=v.replace(/(d{5})(d)/,"$1-$2") //Coloca hífen entre o quarto e o quinto dígitos
- $(input).val(v);
- }
- },
- changeContent: function(value){
- $(value).css('display', 'table');
- $(".hiden-content").each(function(){
- if(!$(this).hasClass("inside-hiden-content")){
- if($(this).attr("ref-id")!=$(value).attr("ref-id")){
- $(this).slideUp();
- }
- }
- });
- $(value).slideDown(function(){
- var body = $("html, body"), destino;
- if($(window).width()<768){
- destino = $(value).offset().top-50;
- } else {
- destino = $(value).offset().top-90;
- }
- body.animate({scrollTop:destino}, '300', 'swing');
- });
- // corrgigir bug block red
- if(TenhoInteresse.blockRedActive == 'CS' || TenhoInteresse.blockRedActive == 'CE'){
- TenhoInteresse.bugBlockRed();
- }
- },
- closeContent: function(){
- TenhoInteresse.bugBlockRed();
- $('#porque-fazer').addClass('red').removeClass('white');
- $('#tenho-interesse').hide();
- $('#mensagemRetorno').text('');
- },
- loading: function(){
- $('#send').hide();
- $('#loading').show();
- },
- loadFiliais: function(){
- $('#flag').load($('#servletCarregaLista').val(), $('#form-tenho-interesse').serialize(), function(){
- if ($('#flag').html().indexOf('</div>') > 0 || $('#flag').html().indexOf('</div>') > 0){
- var filial = $('#dvFilial');
- eval(filial.html($('#flag').html()));
- } else {
- alert($('#flag').html());
- }
- });
- },
- setFilial: function(obj){
- var selectedText = document.getElementById("txtFilialX").options[obj.selectedIndex].value;
- $("#txtFilial").val(selectedText);
- },
- obterParametroUrl: function(parametro){
- var parametros = window.location.search.substring(1).split("&");
- for (var i = 0; i < parametros.length; i++) {
- var splitParametro = parametros[i].split("=");
- if (splitParametro[0] == parametro) {
- return splitParametro[1];
- }
- }
- },
- obterCDUnidade: function(){
- var unidades = [
- {value: 245, nome: 'aclimacao'},
- {value: 130, nome: 'alphaville'},
- {value: 269, nome: 'americana'},
- {value: 191, nome: 'aracatuba'},
- {value: 286, nome: 'araraquara'},
- {value: 250, nome: 'baraogeraldo'},
- {value: 218, nome: 'bauru'},
- {value: 199, nome: 'blumenau'},
- {value: 13, nome: 'butanta'},
- {value: 9, nome: 'campinas'},
- {value: 248, nome: 'campolimpo'},
- {value: 238, nome: 'carrao'},
- {value: 91, nome: 'diadema'},
- {value: 239, nome: 'faculdade'},
- {value: 198, nome: 'florianopolis'},
- {value: 129, nome: 'franca'},
- {value: 8, nome: 'granjaviana'},
- {value: 24, nome: 'guarulhos'},
- {value: 1, nome: 'higienopolis'},
- {value: 270, nome: 'indaiatuba'},
- {value: 249, nome: 'interlagos'},
- {value: 217, nome: 'ipiranga'},
- {value: 4, nome: 'itaim'},
- {value: 200, nome: 'itajai'},
- {value: 233, nome: 'itaquera'},
- {value: 244, nome: 'jabaquara'},
- {value: 201, nome: 'joinville'},
- {value: 185, nome: 'jundiai'},
- {value: 285, nome: 'limeira'},
- {value: 220, nome: 'marajoara'},
- {value: 146, nome: 'maua'},
- {value: 192, nome: 'mogidascruzes'},
- {value: 11, nome: 'mooca'},
- {value: 219, nome: 'morumbi'},
- {value: 151, nome: 'osasco'},
- {value: 208, nome: 'penha'},
- {value: 6, nome: 'pinheiros'},
- {value: 194, nome: 'piracicaba'},
- {value: 226, nome: 'pirituba'},
- {value: 190, nome: 'presidenteprudente'},
- {value: 186, nome: 'rioclaro'},
- {value: 12, nome: 'santana'},
- {value: 10, nome: 'santoamaro'},
- {value: 7, nome: 'santoandre'},
- {value: 5, nome: 'santos'},
- {value: 210, nome: 'saobernardocampo'},
- {value: 268, nome: 'saocaetano'},
- {value: 187, nome: 'saocarlos'},
- {value: 31, nome: 'saojosecampos'},
- {value: 134, nome: 'saojoseriopreto'},
- {value: 236, nome: 'sapopemba'},
- {value: 2, nome: 'saude'},
- {value: 152, nome: 'sorocaba'},
- {value: 23, nome: 'tatuape'},
- {value: 193, nome: 'taubate'},
- {value: 3, nome: 'vilamariana'},
- {value: 239, nome: 'faculdade'}
- ];
- var url = window.location.href;
- var index = url.indexOf('unidades');
- var urlUnidade = url.substring(index + 9, url.length);
- // Se a URL receber parametros não funciona o mapa
- urlUnidade = urlUnidade.split('?');
- urlUnidade = urlUnidade[0];
- for(var i = 0; i < unidades.length; i++){
- if(unidades[i].nome == urlUnidade){
- $("#txtFilial").attr('value', unidades[i].value);
- $("#txtFilialX").val(unidades[i].value);
- }
- }
- },
- /* Para saber se o cadastro foi com os dados do facebook ou CI*/
- setCadastro: function(value){
- $('#txtTipoCadastro').val(value);
- }
- }
- /* Facebook Connect */
- var FacebookConnect = {
- status: false,
- statusChangeCallback: function(response){
- console.log(response);
- if (response.status === 'connected') {
- FacebookConnect.me();
- } else if (response.status === 'not_authorized') {
- consonle.log('Please log into this app.');
- } else {
- console.log('Please log into Facebook.');
- }
- },
- checkLoginState: function(){
- FB.getLoginStatus(function(response) {
- FacebookConnect.statusChangeCallback(response);
- });
- },
- me: function(){
- var _fields = 'name,gender,email,age_range,devices';
- console.log('Welcome! Fetching your information.... ');
- FB.api('/me', 'get', {fields: _fields}, function(response) {
- console.log('response: ', response);
- if(FacebookConnect.status){
- FacebookConnect.preencherCampos(response);
- }
- });
- },
- preencherCampos: function(response){
- TenhoInteresse.setCadastro('FB');
- if(response.name != undefined){
- $('#txtNome').val(response.name);
- $('#fb-connect').hide();
- }
- if(response.email == undefined){
- alert('Sua conta no Facebook não permite a exibição do e-mail.');
- }else{
- $('#txtEmail').val(response.email);
- $('#fb-connect').hide();
- }
- },
- open: function(){
- FB.login(function (response) {
- FacebookConnect.status = true;
- FacebookConnect.statusChangeCallback(response);
- }, {scope: 'public_profile,email'});
- return false;
- }
- }
- window.fbAsyncInit = function() {
- FB.init({
- appId : '268154816952574',
- cookie : true,
- xfbml : true,
- version : 'v2.8'
- });
- FB.getLoginStatus(function(response) {
- FacebookConnect.statusChangeCallback(response);
- });
- };
- (function(d, s, id) {
- var js, fjs = d.getElementsByTagName(s)[0];
- if (d.getElementById(id)) return;
- js = d.createElement(s); js.id = id;
- js.src = "https://connect.facebook.net/en_US/sdk.js";
- fjs.parentNode.insertBefore(js, fjs);
- }(document, 'script', 'facebook-jssdk'));
Add Comment
Please, Sign In to add comment