blinker / firefox.plugin / data / scripts / models / onScreen.js @ 76dd22bd
History | View | Annotate | Download (4.633 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 | function onscreenText(element) { |
||
22 | var gazeObject = $(element); |
||
23 | gazeObject.off("isFixated");
|
||
24 | gazeObject.on("isFixated", { fixelement: element, action: 'text' }, openOnscreenboxKeyboard); |
||
25 | // gazeObject.on("isFixated", { fixelement: element, action: 'text' }, openKeyboard);
|
||
26 | } |
||
27 | |||
28 | |||
29 | function onscreenAction(element) { |
||
30 | var gazeObject = $(element); |
||
31 | |||
32 | gazeObject.off("isFixated");
|
||
33 | gazeObject.on("isFixated", { fixelement: element, action: 'action' } , openOnscreenbox); |
||
34 | } |
||
35 | |||
36 | function onscreenChoice(element) { |
||
37 | var gazeObject = $(element); |
||
38 | |||
39 | gazeObject.off("isFixated");
|
||
40 | gazeObject.on("isFixated", { fixelement: element, action: 'choice'}, openOnscreenbox); |
||
41 | } |
||
42 | |||
43 | |||
44 | function openKeyboard(event) { |
||
45 | closeOnscreenbox(); |
||
46 | var element = $('.keyboardInputFixated')[0]; |
||
47 | if(event != null) { element = $(event.data.fixelement); } |
||
48 | gazeInformation.currentElementFixatedAt = Date.now(); |
||
49 | |||
50 | console.log("myelement:" + element);
|
||
51 | getKeyboardLayout(element); |
||
52 | |||
53 | $(element).getkeyboard().reveal();
|
||
54 | $('.ui-keyboard.ui-keyboard-has-focus button').attr('data-gaze', 'true'); |
||
55 | $('.ui-keyboard.ui-keyboard-has-focus button').attr('data-gaze-type', 'action'); |
||
56 | $('.ui-keyboard.ui-keyboard-has-focus button').attr('data-gaze-model', 'onscreen'); |
||
57 | $('.ui-keyboard.ui-keyboard-has-focus button').attr('data-gaze-function-Close', 'closeOnscreenbox()'); |
||
58 | $('.ui-keyboard.ui-keyboard-has-focus button').attr('data-gaze-function-After', 'closeOnscreenbox()'); |
||
59 | $('.ui-keyboard.ui-keyboard-has-focus button').each(function(index, el) { |
||
60 | $(this).attr('gaze-data-value' , $(this).attr('data-value')); |
||
61 | }); |
||
62 | setScrollAtBorder(false);
|
||
63 | |||
64 | $('.gaze-onscreen').addClass('onScreenKeyboard'); |
||
65 | } |
||
66 | |||
67 | function openOnscreenbox(event) { |
||
68 | var element = $(event.data.fixelement); |
||
69 | |||
70 | var myarray = [];
|
||
71 | myarray = getItemForOnscreen(element, event.data.action); |
||
72 | |||
73 | var elements = $(myarray); |
||
74 | |||
75 | if(elements.length > 0) { |
||
76 | $('.openedElement').removeClass('openedElement'); |
||
77 | element.addClass('openedElement');
|
||
78 | |||
79 | addItemsToOnscreen(elements); |
||
80 | |||
81 | if(!$(element).hasClass('ui-keyboard-button')) { |
||
82 | $('.gaze-onscreen').removeClass('onScreenKeyboard'); |
||
83 | $('.gaze-onscreen').position({ |
||
84 | my: "right bottom", |
||
85 | at: "right top-30", |
||
86 | of: '.fixatedElement' |
||
87 | }); |
||
88 | } else {
|
||
89 | $('.gaze-onscreen').addClass('onScreenKeyboard'); |
||
90 | } |
||
91 | |||
92 | |||
93 | $('.gaze-onscreen').show(); |
||
94 | |||
95 | if($('.onscreen-option-4-1').children('.gazeCancel').length > 0) { |
||
96 | $('.onscreen-option-4-1').addClass('posBottonLeft'); |
||
97 | } |
||
98 | } |
||
99 | } |
||
100 | |||
101 | function openOnscreenboxKeyboard(event) { |
||
102 | var element = $(event.data.fixelement); |
||
103 | $('.keyboardInputFixated').removeClass('keyboardInputFixated'); |
||
104 | $(element).addClass('keyboardInputFixated'); |
||
105 | |||
106 | var myarray = [];
|
||
107 | myarray = getItemsForOnscreenKeyboard(element, event.data.action); |
||
108 | |||
109 | var elements = $(myarray); |
||
110 | |||
111 | if(elements.length > 0) { |
||
112 | $('.openedElement').removeClass('openedElement'); |
||
113 | element.addClass('openedElement');
|
||
114 | |||
115 | addItemsToOnscreen(elements); |
||
116 | |||
117 | |||
118 | $('.gaze-onscreen').removeClass('onScreenKeyboard'); |
||
119 | $('.gaze-onscreen').position({ |
||
120 | my: "right bottom", |
||
121 | at: "right top-30", |
||
122 | of: '.fixatedElement' |
||
123 | }); |
||
124 | |||
125 | |||
126 | $('.gaze-onscreen').show(); |
||
127 | } |
||
128 | } |
||
129 | |||
130 | function closeOnscreenbox() { |
||
131 | $(".gaze-onscreen").css("display", "none"); |
||
132 | $(".gaze-onscreen > div").empty(); |
||
133 | removeOpenedClasses(); |
||
134 | } |
||
135 | |||
136 | function acceptKeyboardInput() { |
||
137 | $(".gaze-onscreen").css("display", "none"); |
||
138 | $(".gaze-onscreen > div").empty(); |
||
139 | $('.gaze-onscreen').removeClass('onScreenKeyboard'); |
||
140 | |||
141 | $(".ui-keyboard.ui-keyboard-has-focus .ui-keyboard-accept").click(); |
||
142 | } |
||
143 | |||
144 | function removeOpenedClasses() { |
||
145 | $('.openedElement').removeClass('openedElement'); |
||
146 | $('.openedElementPrev').removeClass('openedElementPrev'); |
||
147 | $('.openedElementNext').removeClass('openedElementNext'); |
||
148 | $('.gaze-onscreen').removeClass('onScreenKeyboard'); |
||
149 | } |
||
150 |