Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Rev 1239 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
990 isa 1
$(document).ready(function() {
2
	// Popover
3
	$('.btn-pop').popover();
4
 
5
	// CSS switcher
6
	$('.toggle-button').click(function(e) {
7
        $('link#custom-css').attr('href', $(this).attr('CssUrl'));
8
        return false;
9
    });
10
 
11
	// Slider images : photoswipe
12
	if (document.getElementById('galerie_carte')) {
13
		var psc = $('#galerie_carte a').photoSwipe({
14
			enableMouseWheel: false ,
15
			enableKeyboard: false,
16
			preventSlideshow: true
17
		});
18
	}
19
	if (document.getElementById('galerie_images')) {
20
		var psi = $('#galerie_images a').photoSwipe({
21
			enableMouseWheel: false ,
22
			enableKeyboard: false ,
23
			captionAndToolbarAutoHideDelay: 0
24
		});
25
	}
26
 
27
	// Slider images : bootstrap
28
	if (document.getElementById('slider-pictures')) {
29
		$('#slider-pictures').hide();
30
		$('#slider-pictures').swiperight(function() {
31
			$('#slider-pictures').carousel('prev');
32
		});
33
		$('#slider-pictures').swipeleft(function() {
34
			$('#slider-pictures').carousel('next');
35
		});
36
	}
37
});
38
 
39
/*----------------------------------------------------------------------------------------------------------*/
40
// POPOVER
41
var nbrPopup = 0,
42
	popupOuverte = false;
43
 
44
function gestionPopover() {
45
	if (popupOuverte && nbrPopup != 0) {
46
		$('.btn-pop').popover('hide');
47
		popupOuverte = false;
48
	}
49
	nbrPopup++;
50
}
51
 
52
function resetPopover() {
53
	nbrPopup = 0;
54
	popupOuverte = true;
55
}
56
 
57
/*----------------------------------------------------------------------------------------------------------*/
58
// SLIDER BOOTSTRAP
59
function gestionSlider() {
60
	if ($('#slider-pictures').is(':visible')) {
61
		$('#gstn-img').show();
62
		$('#slider-pictures').hide();
63
	} else {
64
		$('#gstn-img').hide();
65
		$('#slider-pictures').show();
66
	}
67
}
68
 
69
/*----------------------------------------------------------------------------------------------------------*/
70
// CANVAS FLORAISON, FRUCTIFICATION
71
var moisAbbr = new Array('J', 'F', 'M', 'A', 'M', 'J', 'J', 'A', 'S', 'O', 'N', 'D', ''),
72
	intervalle = false;
73
 
74
function dessinCanvas(canvas, color, valeur) {
75
	var ctx = canvas.getContext('2d'),
76
		i = 0,
77
		arr = getTableauMois(valeur),
78
		index0 = arr[0],
79
		index1 = -1,
80
		size = canvas.width;
81
 
82
	if (intervalle) {
83
		index1 = arr[arr.length - 1];
84
	}
85
 
86
	for (var abscisse = 10; abscisse < size; abscisse += (size/13)) {
87
		ctx.beginPath();
88
		ctx.moveTo(abscisse, 0);
89
		ctx.lineTo(abscisse, 55);
90
		ctx.stroke();
91
 
92
		if (in_array(i, arr)) {
93
			if (i == index0 && index1 != -1) {
94
				var linearGradient = ctx.createLinearGradient(abscisse, 10, abscisse+30, 10);
95
 
96
				linearGradient.addColorStop(0, "#fff");
97
				linearGradient.addColorStop(1, color);
98
				ctx.beginPath();
99
				ctx.fillStyle = linearGradient;
100
				ctx.moveTo(abscisse, 25);
101
				ctx.lineTo(abscisse+(size/13), 25);
102
				ctx.lineTo(abscisse+(size/13), 10);
103
				ctx.lineTo(abscisse, 25);
104
				ctx.fill();
105
			} else {
106
				if (i == index1) {
107
					var linearGradient = ctx.createLinearGradient(abscisse, 10, abscisse+25, 10);
108
 
109
					linearGradient.addColorStop(0, color);
110
					linearGradient.addColorStop(1, "#fff");
111
					ctx.beginPath();
112
					ctx.fillStyle = linearGradient;
113
					ctx.moveTo(abscisse, 10);
114
					ctx.lineTo(abscisse, 25);
115
					ctx.lineTo(abscisse+(size/13), 25);
116
					ctx.lineTo(abscisse, 10);
117
					ctx.fill();
118
				} else {
119
					ctx.fillStyle = color;
120
					ctx.fillRect(abscisse, 10, (size/13), 15);
121
				}
122
			}
123
		}
124
 
125
		ctx.font = '20px Georgia';
126
		ctx.fillStyle = '#000';
127
		ctx.fillText(moisAbbr[i++], abscisse + 5, 50);
128
	}
129
}
130
 
131
function getTableauMois(elt) {
132
	var arr = new Array(),
133
		temp = elt.split('-');
134
 
135
	if (typeof temp[1] === 'undefined') {
136
		arr.push(elt);
137
	} else {
138
		intervalle = true;
139
		temp[0] = parseInt(temp[0]);
140
		temp[1] = parseInt(temp[1]);
141
		if (temp[0] < temp[1]) {
142
			for (var c = temp[0]; c <= temp[1]; c++) {
143
				arr.push(c);
144
			}
145
		} else {
146
			for (var c = temp[0]; c < 12; c++) {
147
				arr.push(c);
148
			}
149
			for (var c = 0; c <= temp[1]; c++) {
150
				arr.push(c);
151
			}
152
		}
153
	}
154
	return arr;
155
}
156
 
157
function in_array(needle, haystack) {
158
    var inArray = 0;
159
	for (var i in haystack) {
160
        if (haystack[i] == needle) {
161
        	inArray++;
162
        }
163
    }
164
    return (inArray != 0);
165
}