forked from qgispt/qgis_pt_website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.js
269 lines (245 loc) · 7.96 KB
/
utils.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
jQuery(document).ready(function() {
//SLIDESHOW AND TIMER EVENT
var slideshow = $('.slideshow-container');
if (slideshow.size() != 0){
//SLIDESHOW
slideshow.backstretch([
"images/slideshow/old_map.jpg",
"images/slideshow/cascais_pi.jpg"
],{
duration: 3000, fade: 1000
});
//TIMER EVENT
var current = new Date();
$('.time-to-event').countdown({
until: new Date(2014, 5, 2, 9, 30, 0),
layout:'<div class="days"><span class="timer-text">{dn}</span> <br>Dias</div> <div class="hours"><span class="timer-text">{hn}</span> <br>Horas</div> <div class="minutes"><span class="timer-text">{mn}</span> <br>Minutos</div> <div class="seconds"><span class="timer-text">{sn}</span> <br>Segundos</div>'
});
}
//EVENT MAP
if ($('#map').size() != 0){
var map = L.map('map', {scrollWheelZoom: false}).setView([40.186475, -8.412373], 13);
var mapquestUrl = 'http://{s}.mqcdn.com/tiles/1.0.0/osm/{z}/{x}/{y}.png';
var subDomains = ['otile1','otile2','otile3','otile4'];
var mapquestAttrib = 'Data, imagery and map information provided by <a href="http://open.mapquest.co.uk" target="_blank">MapQuest</a>, <a href="http://www.openstreetmap.org/" target="_blank">OpenStreetMap</a> and contributors.';
var mapquest = new L.TileLayer(mapquestUrl, {maxZoom: 18, attribution: mapquestAttrib, subdomains: subDomains});
mapquest.addTo(map);
var marker = L.marker([40.186475, -8.412373]).addTo(map);
marker.bindPopup("<b>Morada</b><br>Rua Sílvio Lima, Pólo II da Universidade de Coimbra<br>3030-790 Coimbra<br><br><b>Coordenadas WGS84</b><br>GD: -8.412373; 40.186475<br>GMS: 8º 24' 44.54'' W; 40º 11' 11.31'' N").openPopup();
}
//MAKE SURE FOOTER IS AT THE BOTTOM OF THE PAGE ON LOAD AND RESIZE
var footer = $('footer');
function setFooterPosition() {
var innerHeight = $(window).height();
if (footer.position().top < innerHeight - 106){
footer.css('position', 'fixed');
footer.css('width', '100%');
}
}
$(window).on('load', function(){
setFooterPosition();
});
$(window).on('resize', function(){
footer.css('position', 'inherit');
setFooterPosition();
});
//VALIDATE AND SUBMIT FORM
var form = $('#form-inscricao');
if (form.size() != 0){
//OVERRIDE VALIDATOR FUNCTION TO SUPPORT FIXED MENU MARGIN
$.prototype.bootstrapValidator.Constructor.prototype._submit = function() {
if (!this.isValid()) {
if ('submitted' == this.options.live) {
this.options.live = 'enabled';
this._setLiveValidating();
}
// Focus to the first invalid field
if (this.invalidField) {
var fieldOffset = $('[name="' + this.invalidField + '"]').offset().top;
$(window).scrollTop(fieldOffset - $('.navbar').height() - 40);
this.getFieldElements(this.invalidField).focus();
}
return;
}
this._disableSubmitButtons(true);
// Call the custom submission if enabled
if (this.options.submitHandler && 'function' == typeof this.options.submitHandler) {
// Turn off the submit handler, so user can call form.submit() inside their submitHandler method
this.$form.off('submit.bootstrapValidator');
this.options.submitHandler.call(this, this, this.$form, this.$submitButton);
} else {
// Submit form
this.$form.off('submit.bootstrapValidator').submit();
}
}
//VALIDATOR
form.bootstrapValidator({
live: 'disabled',
message: 'Este valor não é válido',
feedbackIcons: {
valid: 'glyphicon glyphicon-ok',
invalid: 'glyphicon glyphicon-remove',
validating: 'glyphicon glyphicon-refresh'
},
fields: {
nome: {
validators: {
notEmpty:{
message: 'Este campo é obrigatório'
}
}
},
entidade: {
validators: {
notEmpty:{
message: 'Este campo é obrigatório'
}
}
},
email: {
validators: {
notEmpty:{
message: 'Este campo é obrigatório'
},
emailAddress: {
message: 'Este endereço de email não é válido'
}
}
},
funcao: {
validators: {
notEmpty:{
message: 'Este campo é obrigatório'
}
}
},
softsig: {
validators: {
notEmpty:{
message: 'Este campo é obrigatório'
},
stringLength: {
message: 'Este campo só aceita no máximo 50 caracteres',
min: 1,
max: 50
}
}
},
ws1: {
validators: {
notEmpty:{
message: 'Este campo é obrigatório'
}
}
},
ws2: {
validators: {
notEmpty:{
message: 'Este campo é obrigatório'
}
}
},
so: {
validators: {
notEmpty:{
message: 'Este campo é obrigatório'
}
}
},
softsig: {
validators: {
notEmpty:{
message: 'Este campo é obrigatório'
}
}
},
knowhowqgis: {
validators: {
notEmpty:{
message: 'Este campo é obrigatório'
}
}
}
}
});
//PREVENT PAGE RELOAD
form.on('submit', function(e){
e.preventDefault();
});
$('#submit-form').click(
function() {
form.bootstrapValidator('validate');
if (form.data('bootstrapValidator').isValid() == true){
$.ajax({
type: 'POST',
url: 'services/event-register.php',
data: form.serialize()+"&interesses="+encodeURI($("#interesses").val()),
dataType: 'json',
success: function(response){
var formAlert = $('#form-alert');
formAlert.css('display', 'block');
if (response.success == false){
formAlert.addClass('alert-danger');
$('#form-alert-icon').addClass('glyphicon-warning-sign');
} else {
var formIcon = $('#form-alert-icon');
if (formAlert.hasClass('alert-danger') == true){
formAlert.removeClass('alert-danger')
formIcon.removeClass('glyphicon-warning-sign');
}
formAlert.addClass('alert-success');
formIcon.addClass('glyphicon-ok');
form.slideUp('fast');
}
$('#form-alert-text').html(response.message);
}
});
}
}
);
$('#reset-form').click(
function() {
form.data('bootstrapValidator').resetForm(true);
$('textarea').val('');
}
);
}
//UPDATE PROGRESS BARS TRANSLATION
var docsProgress = $('#docs-progress');
if (docsProgress.size() != 0){
$.getJSON('services/stats.json', function(data){
for (var i = 0; i < data.length; i++){
updateProgress(data[i]);
updateStatsText(data[i]);
}
});
}
function updateProgress(data) {
var bar = $('#' + data.project + '-progress');
if (parseInt(data.stats.completed) < 50){
bar.addClass('progress-bar-danger');
} else if (parseInt(data.stats.completed) >= 50 && parseInt(data.stats.completed) < 100){
bar.addClass('progress-bar-warning');
} else {
bar.addClass('progress-bar-success');
}
bar.attr('aria-valuenow', data.stats.completed);
bar.attr('style', 'width:' + data.stats.completed + '%');
bar.html(Math.round(data.stats.completed*10)/10 + '% Completa');
}
function updateStatsText(data) {
var date = $('#' + data.project + '-date');
var untrans = $('#' + data.project + '-untrans');
var trans = $('#' + data.project + '-trans');
date.html(data.updated_on);
untrans.html(data.stats.untrans_entities + ' items por traduzir (' + data.stats.untrans_words + ' palavras)');
trans.html(data.stats.trans_entities + ' items traduzidos (' + data.stats.trans_words + ' palavras)');
}
//prettyPhoto
var imgBox = $("a[rel^='prettyPhoto']");
if (imgBox.size() > 0){
imgBox.prettyPhoto({
social_tools: false
});
}
});