File: Souris.js

package info (click to toggle)
openboard 1.7.3%2Bdfsg-0.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 57,404 kB
  • sloc: cpp: 76,443; javascript: 10,089; xml: 234; ansic: 38; makefile: 23; sh: 8
file content (92 lines) | stat: -rw-r--r-- 1,702 bytes parent folder | download | duplicates (3)
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

var souris = {
	active : false,
	xInit : 0,
	yInit : 0,
	
	down : function(event){
		var x = event.clientX;
		var y = event.clientY;
		this.active = true;
		this.xInit = x;
		this.yInit = y;
		if(event.button != 2 && !ctxMenu.ouvert){
			outil.down(x, y);
		}
		ctxMenu.fermer();
	},
	up : function(){
		this.active = false;
	},
	move : function(event){
		var x = event.clientX;
		var y = event.clientY;
		outil.move(x, y, souris.xInit, souris.yInit, souris.active);
	},
	out : function(event){
		outil.dessinerListe();
		if(event.relatedTarget && event.relatedTarget.className != "flecheDeplacement"){
			this.active = false;
		}
	},
	wheel : function(event){
		if(!event) event = window.event;
		if(event.wheelDelta){
			if(event.wheelDelta < 0){
				affichage.zoom(1.25);
			}
			else{
				affichage.zoom(0.8);
			}
		}
		else if(event.detail){
			if(event.detail > 0){
				affichage.zoom(1.25);
			}
			else{
				affichage.zoom(0.8);
			}
		}
	},
	dblClick : function(event){
		if(event.ctrlKey){
			affichage.zoom(1.25)
			display3D.zoom(1.25)
		}
		else{
			affichage.zoom(0.8)
			display3D.zoom(0.8)
		}
	}
}

var ctxMenu = {
	id : "ctxMenu",
	ouvert : false,
	
	ouvrir : function(){
		if(!fonction3D){
			ctxMenu.ouvert = true;
			
			var element = document.getElementById("ctxMenu");
			var x = souris.xInit;
			var y = souris.yInit;
	// 		var x = 300;
	// 		var y = 300;
			element.style.display = "block";
			element.style.left = (x+1)+"px";
			element.style.top = (y+1)+"px";
			
			// Désactive le menu du navigateur
			return false;
		}
	},
	
	fermer : function(){
		ctxMenu.ouvert = false;
		
		var element = document.getElementById("ctxMenu");
		element.style.display = "none";
	}
}