1// sm = sitemunicipal 2window.sm = window.sm || {}; 3 4// configuracao de hora e data local 5window.sm.ptBrLocale = { 6 months: 'janeiro_fevereiro_março_abril_maio_junho_julho_agosto_setembro_outubro_novembro_dezembro'.split('_'), 7 monthsShort: 'jan_fev_mar_abr_mai_jun_jul_ago_set_out_nov_dez'.split('_'), 8 weekdays: 'domingo_segunda-feira_terça-feira_quarta-feira_quinta-feira_sexta-feira_sábado'.split('_'), 9 weekdaysShort: 'dom_seg_ter_qua_qui_sex_sáb'.split('_'), 10 weekdaysMin: 'D_S_T_Q_Q_S_S'.split('_'), 11 weekdaysParseExact: true, 12 longDateFormat: { 13 LT: 'HH:mm', 14 LTS: 'HH:mm:ss', 15 L: 'DD/MM/YYYY', 16 LL: 'D [de] MMMM [de] YYYY', 17 LLL: 'D [de] MMMM [de] YYYY [à s] HH:mm', 18 LLLL: 'dddd, D [de] MMMM [de] YYYY [à s] HH:mm', 19 }, 20 calendar: { 21 sameDay: '[Hoje à s] LT', 22 nextDay: '[Amanhã à s] LT', 23 nextWeek: 'dddd [à s] LT', 24 lastDay: '[Ontem à s] LT', 25 lastWeek: function () { 26 return this.day() === 0 || this.day() === 6 27 ? '[Ãltimo] dddd [à s] LT' // Saturday + Sunday 28 : '[Ãltima] dddd [à s] LT'; // Monday - Friday 29 }, 30 sameElse: 'L', 31 }, 32 relativeTime: { 33 future: 'em %s', 34 past: 'há %s', 35 s: 'poucos segundos', 36 ss: '%d segundos', 37 m: 'um minuto', 38 mm: '%d minutos', 39 h: 'uma hora', 40 hh: '%d horas', 41 d: 'um dia', 42 dd: '%d dias', 43 M: 'um mês', 44 MM: '%d meses', 45 y: 'um ano', 46 yy: '%d anos', 47 }, 48 dayOfMonthOrdinalParse: /\d{1,2}º/, 49 ordinal: '%dº', 50 invalidDate: 'Data inválida', 51 week: { 52 dow: 1, // Monday is the first day of the week. 53 doy: 4, // The week that contains Jan 4th is the first week of the year. 54 }, 55}; 56 57// detector do browser 58window.sm.BrowserDetect = { 59 init: function () { 60 this.browser = this.searchString(this.dataBrowser) || "Other"; 61 this.version = this.searchVersion(navigator.userAgent) || 62 this.searchVersion(navigator.appVersion) || 63 "Unknown"; 64 }, 65 searchString: function (data) { 66 for (var i = 0; i < data.length; i++) { 67 var dataString = data[i].string; 68 this.versionSearchString = data[i].subString; 69 if (dataString.indexOf(data[i].subString) !== -1) return data[i].identity; 70 } 71 }, 72 searchVersion: function (dataString) { 73 var index = dataString.indexOf(this.versionSearchString); 74 if (index === -1) return; 75 var rv = dataString.indexOf("rv:"); 76 if (this.versionSearchString === "Trident" && rv !== -1) { 77 return parseFloat(dataString.substring(rv + 3)); 78 } else { 79 return parseFloat(dataString.substring( 80 index + this.versionSearchString.length + 1 81 )); 82 } 83 }, 84 dataBrowser: [ 85 {string: navigator.userAgent, subString: "Edge", identity: "MS Edge"}, 86 {string: navigator.userAgent, subString: "MSIE", identity: "Explorer"}, 87 {string: navigator.userAgent, subString: "Trident", identity: "Explorer"}, 88 {string: navigator.userAgent, subString: "Firefox", identity: "Firefox"}, 89 {string: navigator.userAgent, subString: "Opera", identity: "Opera"}, 90 {string: navigator.userAgent, subString: "OPR", identity: "Opera"}, 91 {string: navigator.userAgent, subString: "Chrome", identity: "Chrome"}, 92 {string: navigator.userAgent, subString: "Safari", identity: "Safari"} 93 ] 94}; 95 96/* 97 * alerts 98 * REFERENCE: https://github.com/kamranahmedse/jquery-toast-plugin 99 */ 100window.sm.alert = { 101 config: function(opt={}){ 102 return { 103 heading: opt.heading || 'Ops...', 104 hideAfter: opt.hideAfter === false ? false : (opt.hideAfter || 7000), 105 showHideTransition: opt.showHideTransition || 'plain', 106 icon: opt.icon || 'success', 107 position: opt.position || 'top-right', 108 }; 109 }, 110 success: function(txt, opt={}){ 111 opt.heading = txt; 112 opt.icon = 'success'; 113 if ($.toast) $.toast(this.config(opt)); 114 else alert(opt.heading || 'Ops... Algo deu errado =/') 115 console.log('SUCCESS', opt) 116 }, 117 error: function(txt, opt={}){ 118 opt.heading = txt; 119 opt.icon = 'error'; 120 if ($.toast) $.toast(this.config(opt)); 121 else alert(opt.heading || 'Ops... Algo deu errado =/') 122 console.log('ERROR', opt) 123 }, 124 warning: function(txt, opt={}){ 125 opt.heading = txt; 126 opt.icon = 'warning'; 127 if ($.toast) $.toast(this.config(opt)); 128 else alert(opt.heading || 'Ops... Algo deu errado =/') 129 console.log('WARNING', opt) 130 }, 131 info: function(txt, opt={}){ 132 opt.heading = txt; 133 opt.icon = 'info'; 134 if ($.toast) $.toast(this.config(opt)); 135 else alert(opt.heading || 'Ops... Algo deu errado =/') 136 console.log('INFO', opt) 137 }, 138}; 139 140// criador de mapa 141window.sm.createMap = function(args = {}) { 142 var ctn_id = args.container_id || 'map'; 143 var cont = document.getElementById(ctn_id); 144 var la = args.lat || -3.79; 145 var lo = args.lon || -38.58; 146 var zoom = args.zoom || 13; 147 var icon = args.icon || window.location.href+'imgs/icons/map.png'; 148 if (!cont) return args.callback ? args.callback(null) : null; 149 var map = new google.maps.Map(cont, { 150 center: {lat: la, lng: lo}, 151 zoom: zoom, 152 mapTypeId: 'roadmap', 153 zoomControl: args.zoomControl || false, 154 mapTypeControl: args.mapTypeControl || false, 155 scaleControl: args.scaleControl || false, 156 panControl: args.panControl || false, 157 streetViewControl: args.streetViewControl || false, 158 rotateControl: args.rotateControl || false, 159 fullscreenControl: args.fullscreenControl || false, 160 }); 161 var marker = new google.maps.Marker({ 162 map: map, 163 position: map.getCenter(), // OR // position: {lat: la, lng: lo}, 164 animation: google.maps.Animation.DROP, 165 icon: { 166 url: icon, 167 size: new google.maps.Size(36, 36) 168 }, 169 }); 170 var iconTimer = setInterval(function() { // tratar classe CSS do marcador 171 $('#'+ctn_id+' img').each(function(i, $el) { 172 if ($el.currentSrc == icon) { 173 $el.className = 'map-icon'; 174 clearInterval(iconTimer); 175 } 176 }); 177 }, 100); 178 return args.callback ? args.callback(map) : map; 179}; 180 181/* 182 * agenda / calendario 183 * reference: https://github.com/kylestetz/CLNDR#introduction-you-write-the-markup 184 */ 185window.sm.calendar = { 186 load: function(selector='#agenda-calendario', opt={}){ // carregar eventos 187 if (!$(selector).length) return; 188 var self = this; 189 var url = window.location.protocol + '//'+window.location.hostname+'/api/v3/eventos'; 190 setTimeout(function(){ 191 $.get(url, { 192 orderBy:'data_hora_inicial', 193 order: 'DESC', 194 limit: -1, 195 }).done(function(res){ 196 if (!Array.isArray(res)) return fail(res); 197 var events = self.formatEvents(res);
198 self.displayNextEvent(events); 199 $('#agenda-loader').hide('slow'); 200 $('#calendar').clndr({ 201 template: $('#agenda-template').html(), 202 events: events, 203 clickEvents: { 204 click: opt.clickEvents || function (obj) { 205 if (obj.events[0]) self.displayDay(obj); 206 } 207 }, 208 multiDayEvents: { 209 singleDay: 'date', 210 endDate: 'data_hora_final', 211 startDate: 'data_hora_inicial' 212 }, 213 showAdjacentMonths: false, 214 adjacentDaysChangeMonth: false 215 }); 216 setTimeout(function(){ 217 $('#agenda-calendario').show('slow'); 218 $('#calendar').show('slow'); 219 }, 500); 220 }).fail(fail); 221 function fail(err){ 222 $('#agenda-loader').after('<p class="color-b text-center w-100">Nenhum Evento Cadastrado</p>'); 223 $('#agenda-loader').hide('slow'); 224 } 225 }, 1000); 226 }, 227 formatEvents: function(arr){ // formatar eventos 228 var gestores = []; 229 var entidades = []; 230 arr.forEach(function(obj){ 231 obj.title = obj.titulo; 232 if (obj.pessoas) { 233 var gestor = false; 234 var entidade = false; 235 obj.pessoas = obj.pessoas.sort(function(a, b){ 236 if (a.nome > b.nome) return 1; 237 if (a.nome < b.nome) return -1; 238 return 0; 239 }
239).forEach(function(pessoa){ 240 if ( 241 pessoa.categoria.slug == 'secretario' || 242 pessoa.categoria.slug == 'prefeito' || 243 pessoa.categoria.slug == 'vice-prefeito' 244 ) gestor = true; 245 if (pessoa.categoria.slug == 'secretaria') entidade = true; 246 }); 247 if (gestor) gestores.push(obj); 248 if (entidade) entidades.push(obj); 249 } else entidades.push(obj); 250 }); 251 store.set('eventosGestores', gestores); 252 store.set('eventosEntidades', entidades); 253 return arr; 254 }, 255 displayEvent: function(obj){ 256 $('#agenda-divisor').show('slow'); 257 $('#agenda-evento').show('slow'); 258 $('#age_titulo').attr('href', './calendario/'+obj.slug); 259 this.displayEventItem('#age_titulo', obj.titulo, obj.titulo); 260 this.displayEventItem('#age_day', obj.data_hora_inicial, moment(obj.data_hora_inicial).format('DD')); 261 this.displayEventItem('#age_month', obj.data_hora_inicial, moment(obj.data_hora_inicial).format('MMM')); 262 this.displayEventItem('#age_data', obj.data_hora_inicial, '<strong>Data do compromisso:</strong> '+moment(obj.data_hora_inicial).format('DD/MM/YYYY')); 263 this.displayEventItem('#age_hora', obj.data_hora_inicial, '<strong>Horário previsto:</strong> '+moment(obj.data_hora_inicial).format('HH:mm')+'h'); 264 this.displayEventItem('#end_google', obj.end_google, '<strong>Local:</strong> '+obj.end_google); 265 if (obj.pessoas) { // cargos e entidades 266 var gestores = []; 267 var entidades = []; 268 obj.pessoas.forEach(function(person){ 269 if ( 270 person.categoria.slug == 'secretario' || 271 person.categoria.slug == 'prefeito' || 272 person.categoria.slug == 'vice-prefeito' 273 ) gestores.push(person); 274 if (person.categoria.slug == 'secretaria') entidades.push(person); 275 }); 276 this.displayCargos(gestores); 277 this.displaySecretarias(entidades); 278 } 279 }, 280 displayDay: function(obj={events: []}){ 281 if (obj.events) { 282 if (obj.events.length > 0) this.displayEvent(obj.events[0]); 283 if (obj.events.length > 1) $('#age_veja_mais').show('slow'); 284 else $('#age_veja_mais').hide('slow'); 285 } 286 }, 287 displayNextEvent: function(arr){ // exibe eventos do proximo dia a partir de hoje 288 var now = moment(); 289 var nexts = []; 290 var res = []; 291 arr.forEach(function(obj){ 292 var now = moment(); 293 var date = moment(obj.data_hora_inicial); 294 if (date > now) nexts.push(obj); 295 }); 296 nexts = nexts.sort(function(a, b){ 297 var date_a = moment(a.data_hora_inicial); 298 var date_b = moment(b.data_hora_inicial); 299 if (date_a > date_b) return 1; 300 if (date_a < date_b) return -1; 301 return 0; 302 }); 303 res = nexts.filter(function(obj){ 304 var first = moment(nexts[0].data_hora_inicial); 305 var compare = moment(obj.data_hora_inicial); 306 return first.diff(compare, 'days') == 0 && 307 first.format('DD') == compare.format('DD'); 308 }); 309 this.displayDay({events: res}); 310 }, 311 displayEventItem: function(selector, test, html){ 312 if (test) $(selector).html(html); 313 else $(selector).html(''); 314 }, 315 displayCargos: function(arr){ 316 var html = ''; 317 var cargos = []; 318 var hierarchy = [ 319 'Prefeito', 320 'Vice-Prefeito', 321 'Secretário', 322 ]; 323 for (var i = 0; i < arr.length; i++) { 324 if (i == 0) html += '<strong>Cargo(s):</strong> '; 325 cargos.push(arr[i].categoria.titulo); 326 } 327 cargos = cargos.filter(function(test, i) { // remove duplicados 328 return cargos.indexOf(test) === i; 329 }).sort(function(a, b){ 330 a = hierarchy.indexOf(a) || 0; 331 b = hierarchy.indexOf(b) || 0; 332 if (a > b) return 1; 333 if (a < b) return -1; 334 return 0; 335 });
336 $('#age_cargos').html(html + cargos.join(', ').replace('Secretário', 'Secretário(s)')); 337 }, 338 displaySecretarias: function(arr){ 339 var html = ''; 340 arr = arr.sort(); 341 for (var i = 0; i < arr.length; i++) { 342 if (i == 0) html += '<strong>Secretaria(s):</strong> '; 343 else html += ', '; 344 html += arr[i].nome; 345 } 346 $('#age_secretarias').html(html); 347 } 348}; 349 350// configuracao de hora e data local 351(function(){ 352 moment.defineLocale('pt-br', window.sm.ptBrLocale); 353 moment.locale('pt-br'); 354})(); 355 356// buttons like links 357$(function() { 358 $('body').on('click', '[data-href]', function(ev) { 359 window.location.href = $(this).data('href'); 360 }); 361}); 362 363// tooltips 364$(function() { 365 $('[data-toggle="tooltip"]').tooltip(); 366}); 367 368// abrir modal 369$(function() { 370 $('body').on('click', '[data-open-modal]', function() { 371 $($(this).data('openModal')).modal('show'); 372 }); 373}); 374 375// graficos // REFERENCE: https://www.chartjs.org/ 376$(function() { 377 $('[data-chart]').each(function(i, $el){ 378 var ctx = $el.getContext('2d'); 379 var config = window.sm.charts[$($el).data('chart')]; 380 new Chart(ctx, config); 381 }); 382}); 383 384// igualar larguras // igualar larguras 385$(function() { 386 $(window).on('resize', matchWidths); 387 $(window).on('resize', matchHeights); 388 matchWidths(); 389 matchHeights(); 390 function matchWidths(){ 391 var ids = []; 392 $('[data-equal-widths]').each(function(ev){ 393 var id = $(this).data('equalWidths'); 394 if (!ids.includes(id)) ids.push(id); 395 }); 396 ids.forEach(function(id){ 397 var selector = '[data-equal-widths="'+id+'"]'; 398 var width = 0; 399 $(selector).width('auto'); 400 $(selector).each(function(i, el){ 401 var w = $(el).width(); 402 if (w > width) width = w; 403 }); 404 $(selector).width(width); 405 }); 406 } 407 function matchHeights(){ 408 var ids = []; 409 $('[data-equal-heights]').each(function(ev){ 410 var id = $(this).data('equalHeights'); 411 if (!ids.includes(id)) ids.push(id); 412 }); 413 ids.forEach(function(id){ 414 var selector = '[data-equal-heights="'+id+'"]'; 415 var height = 0; 416 $(selector).height('auto'); 417 $(selector).each(function(i, el){ 418 var h = $(el).height(); 419 if (h > height) height = h; 420 }); 421 $(selector).height(height); 422 }); 423 } 424}); 425 426// click to show / hide (toggle) 427$(function() { 428 $('body').on('click', '[data-click-show]', function() { 429 var self = $(this); 430 var selector = self.data('clickShow'); 431 var opt = formatElementOpt(self); 432 $(selector).show(opt); 433 }); 434 $('body').on('click', '[data-click-hide]', function() { 435 var self = $(this); 436 var selector = self.data('clickHide'); 437 var opt = formatElementOpt(self); 438 $(selector).hide(opt); 439 }); 440 $('body').on('click', '[data-click-show-hide]', function() { 441 var self = $(this); 442 var selector = self.data('clickShowHide'); 443 var opt = formatElementOpt(self); 444 $(selector).toggle(opt); 445 }); 446 function formatElementOpt($el){ 447 var data = $el.data(); 448 return { 449 duration: data.clickDuration == 0 ? data.clickDuration : data.clickDuration || 400, 450 easing: data.clickEasing == '' ? data.clickEasing : data.clickEasing || 'swing', 451 queue: data.clickQueue == false ? data.clickQueue : data.clickQueue || true, 452 }; 453 } 454}); 455 456// scroll do menu 457$(function() { 458 $('#main-menu') 459 .clone() 460 .attr('id', 'fixed-menu') 461 .removeClass('bg-a') 462 .addClass('fixed bg-a-fade blur-40') 463 .appendTo('#main-header'); 464 $('body').on('scroll', scrolling); 465 scrolling(); 466 function scrolling(ev) { 467 var n = $('body').scrollTop(); 468 if (n > 80) { 469 $('#fixed-menu').addClass('show'); 470 $('#links-acesso-a-informacao').show('slow'); 471 } else { 472 $('#fixed-menu').removeClass('show'); 473 $('#links-acesso-a-informacao').hide('slow'); 474 } 475 }; 476}); 477 478// integracao transparencia no topo do site 479$(function() { 480 var key = $('#menu-transparencia').data('key'); 481 if (!key) return; 482 $.get('https://www.governotransparente.com.br/transparencia/remessa/'+key).done(function(data) { 483 $('.data-ultima-remessa').html(moment(data.dataUltimaRemessa).format('DD/MM/YYYY'));
484 $('.data-primeiro-movimento').html(moment(data.dataPrimeiroMovimento).format('MM/YYYY')); 485 $('.data-ultimo-movimento').html(moment(data.dataUltimoMovimento).format('MM/YYYY')); 486 $('.integracao-govtrans').show('slow'); 487 }).fail(function(data) { 488 window.sm.alert.error('Ops... Erro de integração da API. Código: 386-8'); 489 }).always(function(data) { 490 $('#loader-transparencia').hide('fast'); 491 }); 492}); 493 494// acessibilidade - zoom 495$(function() { 496 var currentZoom = store.get('zoom') || 0; 497 setZoom(currentZoom); 498 if (!window.sm.BrowserDetect.browser) window.sm.BrowserDetect.init(); 499 $('#b-access-more-zoom').on('click',function() { 500 currentZoom++; 501 setZoom(currentZoom); 502 }); 503 $('#b-access-less-zoom').on('click',function() { 504 currentZoom--; 505 setZoom(currentZoom); 506 }); 507 $('#b-access-default-zoom').on('click',function() { 508 currentZoom = 0; 509 setZoom(currentZoom); 510 }); 511 function setZoom(num) { 512 store.set('zoom', currentZoom); 513 if (window.sm.BrowserDetect.browser != 'Chrome') { // TODO - REFAZER PARA O FIREFOX ... 514 // var calc = 1 + (num * 0.04); 515 // $('body').css('MozTransform','scale(' + calc + ')'); 516 } else { 517 var calc = 100 + (num * 4); 518 $('body').css('zoom', ' ' + calc + '%'); 519 } 520 if (num != 0) $('#b-access-default-zoom').removeClass('d-none'); 521 else $('#b-access-default-zoom').addClass('d-none'); 522 } 523}); 524 525// acessibilidade - contrast 526$(function() { 527 var current = store.get('contrast') || 'default'; 528 if (current !== 'default') setContrast(current); 529 $('body').on('click', '#b-access-contrast', changeContrast); 530 function setContrast(str) { 531 $('#loader').show('fast'); 532 var random = Math.floor(Math.random()*(9999-99))+99; 533 if(!$('.contrast-css').length) [ 534 window.location.protocol+'//'+window.location.hostname+'/themes/pop-line/css/contrast-white.css?v='+random, 535 window.location.protocol+'//'+window.location.hostname+'/themes/pop-line/css/contrast-black.css?v='+random, 536 ].forEach(function(url){ 537 $('head').append('<link class="contrast-css" rel="stylesheet" type="text/css" href="'+url+'" crossorigin="anonymous">'); 538 }); 539 setTimeout(function(){ 540 store.set('contrast', str); 541 $('body').removeClass('contrast-white contrast-black contrast-default'); 542 $('body').addClass('contrast-'+str); 543 $('#loader').hide('fast'); 544 }, 600); 545 } 546 function changeContrast(el) { 547 var current = store.get('contrast') || 'default'; 548 var arr = ['default', 'white', 'black']; 549 var pos = arr.indexOf(current); 550 setContrast(pos == arr.length -1 ? arr[0] : arr[pos +1]); 551 } 552}); 553 554// setar altura minima da main 555$(function() { 556 var hWindow = $(window).height(); 557 var hTop = $('#main-header').height() + $('#navbar-fixed').height(); 558 var hFoo = $('#main-footer').height(); 559 var hRes = hWindow - hTop - hFoo - 8; 560 $('#main').css('min-height', hRes+'px'); 561}); 562 563// weather (clima) 564$(function() { 565 var weather = { 566 dateFormat: 'MM-DD-YYYY', 567 init: function() { 568 var stored = store.get('weather'); 569 var data = $('#weather-box').data(); 570 if (!data) return; 571 else if (stored) { 572 var today = moment().set({hour:0,minute:0,second:0,millisecond:0}); 573 var expiration = moment(stored.expiration, this.dateFormat); 574 var diff = expiration.diff(today, 'days'); 575 if (diff > 0) this.setBox(store.get('weather')); 576 else this.load(data); 577 } else this.load(data); 578 }, 579 setBox: function(obj={}) { 580 obj.min = obj.min || ''; 581 obj.max = obj.max || ''; 582 obj.nextDay = obj.nextDay || ''; 583 obj.nextMin = obj.nextMin || ''; 584 obj.nextMax = obj.nextMax || ''; 585 obj.description = obj.description || ''; 586 obj.icon = $('#icon-'+obj.slug).html() || $('#icon-none_day').html(); 587 var html = $('#weather-content').html(); 588 for (var prop in obj) { html = html.replace('{{'+prop+'}}', obj[prop]); } 589 $('#weather-content').html(html).removeClass('d-none'); 590 $('#weather-icon') 591 .html(obj.icon) 592 .attr('title', obj.description) 593 .tooltip({title: obj.description, placement: 'bottom'}); 594 $('#mobile-weather-box').append($('#weather-box').html()); // for mobile sidebar 595 }, 596 load: function(data) { 597 var self = this; 598 var weekDays = { 599 'Seg': 'Segunda', 'Ter': 'Terça', 'Qua': 'Quarta',
600 'Qui': 'Quinta', 'Sex': 'Sexta', 'Sáb': 'Sábado', 601 'Dom': 'Domingo' 602 }; 603 $.get('https://api.hgbrasil.com/weather', { 604 locale: 'pt', 605 key: data.key, 606 format: 'json-cors', 607 lat: data.lat, 608 lon: data.lon, 609 array_limit: 3 610 }).done(function(data) { 611 var obj = { 612 expiration: moment().add(1, 'days').format(self.dateFormat), 613 description: data.results.description, 614 slug: data.results.condition_slug, 615 min: data.results.forecast[0].min, 616 max: data.results.forecast[0].max, 617 nextDay: weekDays[data.results.forecast[1].weekday], 618 nextIcon: data.results.forecast[1].condition, 619 nextMin: data.results.forecast[1].min, 620 nextMax: data.results.forecast[1].max, 621 }; 622 store.set('weather', obj); 623 self.setBox(obj); 624 }).fail(function(data) { 625 var weatherTimer = setInterval(function() { 626 var html = '\ 627 <div class="col">\ 628 <small class="d-block">Serviço IndisponÃvel</small>\ 629 </div>\ 630 '; 631 $('#weather-icon').html('<i class="material-icons font-size-45 mr-3 mt-2 color-a">bug_report</i>'); 632 $('#weather-content').html(html); 633 $('#weather-content').removeClass('d-none'); 634 clearInterval(weatherTimer); 635 }, 5000); 636 }); 637 } 638 }; 639 weather.init(); 640}); 641 642// slider destaques 643$(function() { 644 if (!$('#slider-destaques').length) return; 645 $('#slider-destaques').owlCarousel({ 646 items: 4, 647 margin: 30, 648 dots: true, 649 loop: true, 650 nav: true, 651 navText: [ 652 $('.destaques-home-nav-prev').html(), 653 $('.destaques-home-nav-next').html() 654 ], 655 responsive: { 656 0: {items: 1}, 657 576: {items: 1}, 658 768: {items: 2}, 659 992: {items: 3}, 660 1024: {items: 3}, 661 1140: {items: 4}, 662 }, 663 }); 664}); 665 666// slider secretarias 667$(function() { 668 if (!$('#secretarias-slider').length) return; 669 $('#secretarias-slider').owlCarousel({ 670 items: 4, 671 margin: 30, 672 dots: true, 673 nav: true, 674 navText: [ 675 $('.secretarias-slider-nav-prev').html(), 676 $('.secretarias-slider-nav-next').html() 677 ], 678 responsive: { 679 0: {items: 1}, 680 576: {items: 1}, 681 768: {items: 2}, 682 992: {items: 3}, 683 1024: {items: 4}, 684 }, 685 }); 686}); 687 688// enquete 689$(function() { 690 $('body').on('click', '#b-enquete', function() { 691 var id = $('input[name=enquete]:checked').val(); 692 var txt = $('#enquete-label-'+id).html(); 693 $('#enquete-escolha').html(txt); 694 if (id) $('#modal-enquete').modal('show'); 695 else window.sm.alert.error('Escolha sua opção'); 696 }); 697 $('body').on('click', '#b-confirm-choice', function() { 698 $('#loader').show('slow'); 699 $('#modal-enquete').modal('hide'); 700 grecaptcha.ready(function() { 701 try { 702 grecaptcha.execute($('#captcha-script').data('recaptchaKey'), {action: 'submit'}).then(function(token) { 703 var id = $('input[name=enquete]:checked').val(); 704 $.ajax({ 705 url: './api/votar-enquete/'+id, 706 type: 'POST', 707 contentType: 'application/json', 708 data: JSON.stringify({ 709 enqueteId: $('[data-enquete-id]').data('enqueteId'), 710 token: token, 711 email: 'EMAIL_CADASTRO', // TODO - email para cadastro ... 712 }) 713 }).done(res).fail(res); 714 function res(data) { 715 $('#loader').hide('slow'); 716 $('#modal-enquete').modal('hide'); 717 if (data.id && data.id > 0) { 718 window.sm.alert.success('Obrigado por responder nossa enquete.'); 719 $('#form-enquete')[0].reset(); 720 } else window.sm.alert.error('=/ Ops... Algo deu errado.'); 721 }; 722 }); 723 } catch(error) { 724 $('#loader').hide('slow'); 725 window.sm.alert.error('=/ Ops... Algo deu errado com a validação de usuário (reCAPTCHA).'); 726 } 727 }); 728 }); 729}); 730 731// form cadastre-se 732$(function() { 733 if ($("#form-newsletter").length) $("#form-newsletter").validate({ 734 submitHandler: function(form) { 735 $('#loader').show('slow'); 736 $.ajax({ 737 url: './api/v3/newsletter', 738 type: 'POST', 739 contentType: 'application/json', 740 data: JSON.stringify({ 741 name: $('[name="name"]').val(), 742 mail: $('[name="mail"]').val(), 743 phone: $('[name="phone"]').val(), 744 }) 745 }).done(res).fail(res); 746 function res(data) { 747 $('#loader').hide('slow'); 748 if (data.id > 0) { 749 $('#form-newsletter')[0].reset(); 750 window.sm.alert.success('Acesse seu email para confirmar seu cadastro'); 751 } else window.sm.alert.error('Ops... Algo deu errado =/'); 752 }; 753 return false;
754 } 755 }); 756}); 757 758// mascaras 759$(function() { 760 761 // phone mask 762 $('[data-mask="phone"]').on('keyup', function(e) { 763 $(this).val($(this).val() 764 .replace(/\D|\s/g,'') // retirar nao-numeros 765 .substring(0,11) // limitar a 11 caracteres 766 .replace(/(.{1})/, '($1').replace(/(.{3})(.{1})/, '$1)$2') // inserir os () 767 .replace(/(\(\d{2}\)\d{5})(\d{4})/, '$1.$2') // inserir . para 8 digitos 768 .replace(/(\(\d{2}\)\d{4})(\d{4})/, '$1.$2') // inserir . para 9 digitos 769 ); 770 }); 771 772 // currency mask 773 $('[data-mask="currency"]').on('keyup', function(e) { 774 var str = $(this).val(); 775 str = str.replace(/\D/g,''); // remove virgulas e pontos 776 str = (str/100).toFixed(2) + ''; // transforma em ponto flutuante (empurrando os numeros para a direita) 777 str = str.substring(0, 14); 778 str = str.replace(".", ","); // remove os pontos 779 str = str.replace(/(\d)(\d{3})(\d{3})(\d{3}),/g, "$1.$2.$3.$4,"); // se passar de 11 caracteres, adiciona . (casa dos bilhões) 780 str = str.replace(/(\d)(\d{3})(\d{3}),/g, "$1.$2.$3,"); // se passar de 8 caracteres, adiciona . (casa dos milhões) 781 str = str.replace(/(\d)(\d{3}),/g, "$1.$2,"); // se passar de 5 caracteres, adiciona . (casa dos milhares) 782 $(this).val(str); 783 }); 784}); 785 786// expand/contract contents (ex: interna de servicos) 787$(function() { 788 $('[data-accordion-container]').each(function() { 789 var $container = $(this); 790 var $contents = $($container.data('contents')); 791 var contents = $container.data('contents'); 792 var expandButton = $container.data('expandButton'); 793 var contractButton = $container.data('contractButton'); 794 var height = $container.height(); 795 $container.data('height', height); 796 if ($contents.height() <= height) { 797 $(expandButton).hide(); 798 $container.find('.hide-on-expand').hide('fast'); 799 $container.find('.show-on-expand').show('fast'); 800 return; 801 } 802 if ($(expandButton).length) { 803 $('body').on('click', expandButton, function() { 804 var aaa = $container.height(); 805 var bbb = $contents.height(); 806 $container.find('.hide-on-expand').hide('fast'); 807 $container.find('.show-on-expand').show('fast'); 808 $(expandButton).hide('fast'); 809 $(contractButton).show('fast'); 810 $container.animate({maxHeight: $contents.height() + $container.height()}); 811 }); 812 } 813 if ($(contractButton).length) { 814 $('body').on('click', contractButton, function() { 815 $container.find('.hide-on-contract').hide('fast'); 816 $container.find('.show-on-contract').show('fast'); 817 $(contractButton).hide('fast'); 818 $(expandButton).show('fast'); 819 $container.animate({maxHeight: $container.data('height')}); 820 }); 821 } 822 }); 823}); 824 825// acessibilidade - atalhos de teclado 826$(function() { 827 $(document).on('keydown', function(e) { 828 if ((e.altKey) && (e.which === 72)) { // alt+H (pagina inicial) 829 e.preventDefault(); 830 window.location.href = window.location.protocol+'//'+window.location.hostname; 831 } 832 if ((e.altKey) && (e.which === 57)) { // alt+9 (voltar ao topo da pagina) 833 e.preventDefault(); 834 $('html, body').animate({scrollTop:0}, 'slow'); 835 } 836 if ((e.altKey) && (e.which === 67)) { // alt+c (direto para conteudo) 837 var num = $('[data-main]')[0].offsetTop; 838 $('[data-main]').focus(); 839 $('html, body').animate({scrollTop: num - 120}, 'slow'); 840 e.preventDefault(); 841 } 842 if ((e.altKey) && (e.shiftKey) && (e.which === 49)) { // alt+shift+1 (acessibilidade do site) 843 e.preventDefault(); 844 window.location.href = window.location.protocol+'//'+window.location.hostname+'/acessibilidade'; 845 } 846 if ((e.altKey) && (e.which === 65)) { // alt+a (aumentar letras) 847 e.preventDefault(); 848 $('#b-access-more-zoom').click(); 849 } 850 if ((e.altKey) && (e.shiftKey) && (e.which === 68)) { // alt+shift+d (diminuir letras) 851 e.preventDefault(); 852 $('#b-access-less-zoom').click(); 853 } 854 if ((e.altKey) && (e.which === 78)) { // alt+n (tamanho normal) 855 e.preventDefault(); 856 $('#b-access-default-zoom').click(); 857 } 858 }); 859}); 860 861// GDPR 862$(function() { 863 var labels = $('label.control-switch'); 864 if (!store.get('GDPR_ACCEPT')) $('#GDPR').show('fast'); 865 $('#b-gdpr-accept, #btn-save-accept').on('click', function() { 866 $('#GDPR').hide('fast'); 867 $('#loader').show('fast'); 868 $.ajax({ 869 url: '/api/v3/lgpd', 870 type: 'POST', 871 contentType: 'application/json; charset=utf-8', 872 dataType: 'json', 873 data: JSON.stringify({ 874 necessarios: true, 875 analiticos: $('#gdpr-analiticos').is(':checked'), 876 funcionais: $('#gdpr-funcional').is(':checked'), 877 outros: $('#gdpr-outros').is(':checked'), 878 performances: $('#gdpr-performance').is(':checked'), 879 propagandas: $('#gdpr-propaganda').is(':checked') 880 }), 881 success: function() { 882 $('#loader').hide('fast'); 883 store.set('GDPR_ACCEPT', true); 884 window.sm.alert.success('Termo enviado'); 885 }, 886 error: function(res) { 887 $('#loader').hide('fast'); 888 $('#GDPR').hide('fast'); 889 console.log(res); 890 } 891 }); 892 }); 893 $('input.custom-control-input').each(function(i, $el) { 894 $($el).on('change', function() { 895 if (labels[i].innerText === 'Ativado') labels[i].innerText = 'Desativado'; 896 else labels[i].innerText = 'Ativado'; 897 }); 898 }); 899}); 900 901// aviso banner 902$(function() { 903 var hours = moment().diff(store.get('avisoBanner')) / (1000 * 60 * 60); 904 if (!store.get('avisoBanner') || hours > 24) $('#aviso-banner').modal('show'); 905 $('#close-aviso-banner').on('click', function() { 906 store.set('avisoBanner', moment()); 907 }); 908}); 909 910// abrir modal 911$(function() { 912 $('.modal[data-active="true"').modal('show'); 913});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.