-
Notifications
You must be signed in to change notification settings - Fork 52
/
pets.js
63 lines (55 loc) · 2.01 KB
/
pets.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
$(document).ready(function () {
$('input[type="file"]').on('change', function () {
var reader = new FileReader();
reader.onload = function (e) {
$('#picture').attr('src', e.target.result);
};
reader.readAsDataURL(this.files[0]);
if (this.files[0].size > 8 * 1024 * 1024) {
this.setCustomValidity('Imagem excede tamanho máximo de 8MB');
return;
}
this.setCustomValidity('');
});
$('#id_state').on('change', function () {
var stateWidget = $(this);
var cityWidget = $('#id_city');
stateWidget.prop('disabled', true);
cityWidget.prop('disabled', true);
cityWidget.find('option').remove();
$.get('/api/cities/?limit=1000&state=' + stateWidget.val(), function (data) {
cityWidget.append(new Option('------------', ''));
$.each(data['results'], function (idx, city) {
cityWidget.append(new Option(city.name, city.code));
});
}).done(function () {
cityWidget.prop('disabled', false);
stateWidget.prop('disabled', false);
});
});
$(function () {
$(".found-or-adopted > h2 br")
.before("<span class='spacer'>")
.after("<span class='spacer'>");
});
var links = $('a').not('.pagination a');
for (var i = 0; i < links.length; i++) {
var currentPath = window.location.pathname;
var link = links[i];
if (link.pathname === currentPath && link.href.indexOf('#') === -1) {
$(link.parentNode).addClass('active');
}
}
});
(function () {
if (matchMedia('only screen and (min-width: 768px)').matches) {
$(document).on('scroll', function () {
var scrollPos = $(this).scrollTop();
if (scrollPos > 150) {
$('.navbar-fixed-top').removeClass('navbar-home');
} else {
$('.navbar-fixed-top').addClass('navbar-home');
}
});
}
})();