blinker / firefox.plugin / data / scripts / modules / onscreenOption.js @ 76dd22bd
History | View | Annotate | Download (5.158 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() { |
||
22 | $('body').append('<div class="gaze-onscreen"><div class="gaze-onscreen-content"></div></div>'); |
||
23 | }); |
||
24 | |||
25 | |||
26 | function addItemsToOnscreen(elements) { |
||
27 | var elementsLength = elements.length;
|
||
28 | $('.gaze-onscreen .gaze-onscreen-content').html(''); |
||
29 | |||
30 | elements.each(function(index, el) {
|
||
31 | var mydiv = '<div class="onscreen-option onscreen-option-' + elementsLength + '-' + (index + 1) + '">'; |
||
32 | mydiv += el; |
||
33 | mydiv += '</div>';
|
||
34 | $('.gaze-onscreen-content').append(mydiv); |
||
35 | }); |
||
36 | |||
37 | if(jQuery('.gaze-onscreen-content .onscreen-option').length > 21) { |
||
38 | showOnscreenPagination(); |
||
39 | } |
||
40 | |||
41 | vidFullscreen(); |
||
42 | } |
||
43 | |||
44 | function getItemForOnscreen(element, type) { |
||
45 | if(type == 'text') { return getTextElements(element); } |
||
46 | if(type == 'action') { return getActionElements(element); } |
||
47 | return getChoiceElements(element);
|
||
48 | } |
||
49 | |||
50 | function getItemsForOnscreenKeyboard(element, type) { |
||
51 | var dataValue = "Ok"; |
||
52 | var dataCancel = "Hide"; |
||
53 | var gazeCloseFunction = "closeAll()"; |
||
54 | var gazeFunction = ""; |
||
55 | var gazeFunctionAfter = "closeAll()"; |
||
56 | var gazeTarget = ".openedElement"; |
||
57 | var gazeType = "action"; |
||
58 | var gazeModel = "dwell"; |
||
59 | var isKeyboardButton = false; |
||
60 | var gazeClass = 'gazeOk'; |
||
61 | |||
62 | if($(element).hasClass('ui-keyboard-button')) { isKeyboardButton = true; gazeClass = 'gazeOk gazeKeyBoardOk' } |
||
63 | if($(element).attr('gaze-data-value')) { dataValue = $(element).attr('gaze-data-value'); } |
||
64 | if($(element).attr('data-gaze-function-Close')) { gazeCloseFunction = $(element).attr('data-gaze-function-Close'); } |
||
65 | if($(element).attr('data-gaze-function-After')) { gazeFunctionAfter = $(element).attr('data-gaze-function-After'); } |
||
66 | |||
67 | var gazeCancel = '<div class="gazeCancel" data-gaze="true"'; |
||
68 | gazeCancel += ' data-gaze-type="' + gazeType +'"'; |
||
69 | gazeCancel += ' data-gaze-model="' + gazeModel +'"'; |
||
70 | gazeCancel += ' data-gaze-target="' + gazeTarget +'"'; |
||
71 | gazeCancel += ' data-gaze-function="' + gazeCloseFunction +'"'; |
||
72 | |||
73 | gazeCancel += '>';
|
||
74 | gazeCancel += '<p>';
|
||
75 | gazeCancel += dataCancel; |
||
76 | gazeCancel += '</p>';
|
||
77 | gazeCancel += '</div>';
|
||
78 | |||
79 | |||
80 | var gazeOk = '<div class="keyboardOpenButton ' + gazeClass +'" data-gaze="true"'; |
||
81 | gazeOk += ' data-gaze-type="' + gazeType +'"'; |
||
82 | gazeOk += ' data-gaze-model="' + gazeModel +'"'; |
||
83 | gazeOk += ' data-gaze-target="' + gazeTarget +'"'; |
||
84 | gazeOk += ' data-gaze-function="openKeyboard()"';
|
||
85 | gazeOk += '>';
|
||
86 | gazeOk += '<p>';
|
||
87 | gazeOk += dataValue; |
||
88 | gazeOk += '</p>';
|
||
89 | gazeOk += '</div>';
|
||
90 | |||
91 | var myarray = [];
|
||
92 | |||
93 | |||
94 | myarray.push(gazeCancel); |
||
95 | myarray.push(gazeOk); |
||
96 | |||
97 | |||
98 | |||
99 | return myarray;
|
||
100 | } |
||
101 | |||
102 | function showOnscreenPagination() { |
||
103 | addPaginationButtons(); |
||
104 | jQuery('.gaze-onscreen-content .onscreen-option:hidden').addClass('nextOnscreenElements'); |
||
105 | } |
||
106 | |||
107 | |||
108 | function showOnscreenNextPage() { |
||
109 | var oldElements = jQuery('.gaze-onscreen-content .onscreen-option:visible'); |
||
110 | var newElements = jQuery('.gaze-onscreen-content .onscreen-option.nextOnscreenElements:hidden').slice(0, 21); |
||
111 | |||
112 | oldElements.css('display', 'none').addClass('prevOnscreenElements'); |
||
113 | newElements.css('display', 'block').removeClass('nextOnscreenElements'); |
||
114 | } |
||
115 | |||
116 | function showOnscreenPrevPage() { |
||
117 | var oldElements = jQuery('.gaze-onscreen-content .onscreen-option:visible'); |
||
118 | var newElements = jQuery('.gaze-onscreen-content .onscreen-option.prevOnscreenElements:hidden').slice(-21); |
||
119 | |||
120 | oldElements.css('display', 'none').removeClass('prevOnscreenElements'); |
||
121 | newElements.css('display', 'block').addClass('nextOnscreenElements'); |
||
122 | } |
||
123 | |||
124 | function addPaginationButtons() { |
||
125 | jQuery('.gaze-onscreen-content').prepend('<div class="onscreenPagination next" data-gaze="true" data-gaze-type="action" data-gaze-model="dwell">Next</div>'); |
||
126 | jQuery('.gaze-onscreen-content').prepend('<div class="onscreenPagination prev" data-gaze="true" data-gaze-type="action" data-gaze-model="dwell">Prev</div>'); |
||
127 | |||
128 | jQuery('.onscreenPagination.next').click(function(event) { |
||
129 | showOnscreenNextPage(); |
||
130 | jQuery('.onscreenPagination.prev').show();
|
||
131 | if(jQuery('.gaze-onscreen-content .onscreen-option.nextOnscreenElements:hidden').length <= 0) { |
||
132 | jQuery('.onscreenPagination.next').hide();
|
||
133 | } |
||
134 | }); |
||
135 | |||
136 | jQuery('.onscreenPagination.prev').click(function(event) { |
||
137 | showOnscreenPrevPage(); |
||
138 | jQuery('.onscreenPagination.next').show();
|
||
139 | if(jQuery('.gaze-onscreen-content .onscreen-option.prevOnscreenElements:hidden').length <= 0) { |
||
140 | jQuery('.onscreenPagination.prev').hide();
|
||
141 | } |
||
142 | }); |
||
143 | } |