blinker / firefox.plugin / data / scripts / models / piemenu.js @ 76dd22bd
History | View | Annotate | Download (3.331 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 | |||
22 | function piemenuAction(element) { |
||
23 | var gazeObject = $(element); |
||
24 | |||
25 | gazeObject.off("isFixated");
|
||
26 | gazeObject.on("isFixated", { fixelement: element, action: 'action'} , openPieMenu); |
||
27 | } |
||
28 | |||
29 | function piemenuChoice(element) { |
||
30 | var gazeObject = $(element); |
||
31 | |||
32 | gazeObject.off("isFixated");
|
||
33 | gazeObject.on("isFixated", { fixelement: element, action: 'choice'} , openPieMenu); |
||
34 | } |
||
35 | |||
36 | function piemenuText(element) { |
||
37 | var gazeObject = $(element); |
||
38 | |||
39 | gazeObject.off("isFixated");
|
||
40 | gazeObject.on("isFixated", { fixelement: element, action: 'text'} , openPieMenuKeyboard); |
||
41 | } |
||
42 | |||
43 | |||
44 | // Open the PieMenu
|
||
45 | function openPieMenu(event) { |
||
46 | var element = $(event.data.fixelement); |
||
47 | var myarray = [];
|
||
48 | var pieMenu = '.gaze-piemenu'; |
||
49 | var pieMenuContent = '.gaze-piemenu-content'; |
||
50 | myarray = getItemForPiemenu(element, event.data.action); |
||
51 | |||
52 | var elements = $(myarray); |
||
53 | |||
54 | if(elements.length > 0) { |
||
55 | $('.openedElement').removeClass('openedElement'); |
||
56 | element.addClass('openedElement');
|
||
57 | increasePieMenuSize(300,300); |
||
58 | |||
59 | addItemsToPiemenu(elements, pieMenu, pieMenuContent); |
||
60 | |||
61 | if(elements.length > 3) { increasePieMenuSize(pieMenu, 350,350); } |
||
62 | if(elements.length > 5) { increasePieMenuSize(pieMenu, 450,450); } |
||
63 | |||
64 | var piemenuHeight = $(pieMenu).height(); |
||
65 | var piemenuWidth = $(pieMenu).width(); |
||
66 | |||
67 | $(pieMenu).position({
|
||
68 | my: "right" + (piemenuWidth/2) + " top-" + (piemenuHeight + 20), |
||
69 | at: "right top", |
||
70 | of: '.fixatedElement' |
||
71 | }); |
||
72 | |||
73 | $(pieMenu).show();
|
||
74 | } |
||
75 | } |
||
76 | |||
77 | // Close Piemenu Keyboard
|
||
78 | function openPieMenuKeyboard(event) { |
||
79 | $('body').addClass('openedPieMenuKeyboard'); |
||
80 | var element = $(event.data.fixelement); |
||
81 | if($(element).attr('gaze-piemenu') == 'submenu') { |
||
82 | $('.openedSubMenu').removeClass('openedSubMenu'); |
||
83 | $(element).addClass('openedSubMenu'); |
||
84 | addKeyboardSubmenu(element); |
||
85 | } else {
|
||
86 | $('.openedElement').removeClass('openedElement') |
||
87 | $('.inputGazeKeyboard').removeClass('inputGazeKeyboard'); |
||
88 | element.addClass('openedElement').addClass('inputGazeKeyboard'); |
||
89 | $('#gazeProgress').hide(); |
||
90 | createKeyboard(element); |
||
91 | } |
||
92 | |||
93 | setScrollAtBorder(false);
|
||
94 | } |
||
95 | |||
96 | |||
97 | |||
98 | // Close the PieMenu
|
||
99 | function closePieMenu() { |
||
100 | $('.gaze-piemenu').hide(); |
||
101 | $('#gazeProgress').hide(); |
||
102 | } |
||
103 | |||
104 | function increasePieMenuSize(pieMenu, width, height) { |
||
105 | $(pieMenu).height(height);
|
||
106 | $(pieMenu).width(width);
|
||
107 | } |
||
108 | |||
109 | |||
110 | function closePieMenuKeyboard() { |
||
111 | $('body').removeClass('openedPieMenuKeyboard'); |
||
112 | savePreviewToInput(); |
||
113 | closePieMenu(); |
||
114 | $('.gaze-piemenuKeyboard').hide(); |
||
115 | $('#gazeProgress').hide(); |
||
116 | setScrollAtBorder(); |
||
117 | } |