Statistics
| Branch: | Revision:

blinker / firefox.plugin / data / scripts / models / dwell.js @ 76dd22bd

History | View | Annotate | Download (1.96 KB)

1 76dd22bd KevinTaron
/*
2
 * Copyright 2015 Thies Pfeiffer and Dimitri Heil and Kevin Taron
3
 * Blinker is distributed under the terms of the GNU General Public License
4
 * 
5
 * This file is part of Blinker.
6
 * 
7
 * Blinker is free software: you can redistribute it and/or modify
8
 * it under the terms of the GNU General Public License as published by
9
 * the Free Software Foundation, either version 3 of the License, or
10
 * (at your option) any later version.
11
 * 
12
 * Blinker is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
 * GNU General Public License for more details.
16
 * 
17
 * You should have received a copy of the GNU General Public License
18
 * along with Blinker. If not, see <http://www.gnu.org/licenses/>.
19
 */
20
21
var clickPossible = true;
22
23
function dwellAction(element) {
24
        var gazeObject = $(element);
25
26
        gazeObject.off("isFixated");
27
        gazeObject.on("isFixated", { fixelement: element } , clickDwellAction);
28
}
29
30
31
32
function clickDwellAction(event) {
33
34
        // Only Click if Possible -- No doubleClicks
35
        if(clickPossible) {
36
                clickPossible = false;        
37
                var gazeElement = $(event.data.fixelement);
38
                var target = gazeElement;
39
                var ownFunc = "";
40
                var afterFunc = "";
41
42
                // Set Target Element
43
                if(gazeElement.attr('data-gaze-target') != null) {
44
                        target = $(gazeElement.attr('data-gaze-target'))[0];
45
                }
46
47
                // Set Gaze Function or Use Click
48
                if(gazeElement.attr('data-gaze-function') != null) {
49
                        ownFunc = gazeElement.attr('data-gaze-function');
50
                        eval(ownFunc);
51
                } else {
52
                        target.click();
53
                }
54
55
                // Set After Gaze Function
56
                if(gazeElement.attr('data-gaze-function-after') != null) {
57
                        afterFunc = gazeElement.attr('data-gaze-function-after');
58
                        eval(afterFunc);
59
                }
60
61
                // Make CLick Possible in 500ms
62
                setTimeout(madeClickPossible, 500);
63
        }
64
}
65
66
// Make Click Possible Again
67
function madeClickPossible() {
68
        clickPossible = true;
69
}