-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest1
More file actions
206 lines (157 loc) · 4.25 KB
/
test1
File metadata and controls
206 lines (157 loc) · 4.25 KB
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
////CHROME FUNCTIONS
function warn(msg){
return console.warn(msg);
}
function log(msg){
return console.log(msg);
}
function info(msg){
return console.info(msg);
}
function start(){
console.time("app start");
}
function end(){
console.timeEnd("app start");
}
////CHROME FUNCTIONS
var DURATION = 100;
var movingId = 0;
var prevFocused = null;
var isFirstFocus = true;
var keyDownTime = 0;
var checkEvent = true,
throttle = function(func, delay){
if (checkEvent) { window.clearTimeout(checkEvent); }
checkEvent = window.setTimeout(func, delay);
};
$(document).ready(function(e) {
var tooltipSettings = {
position: {
my: "center bottom",
at: "center top",
using: function( position, feedback ) {
$( this ).css( position );
$( "<div>" )
.addClass( "arrow" )
.addClass( feedback.vertical )
.addClass( feedback.horizontal )
.appendTo( this );
}
},
tooltipClass: "custom-tooltip-styling"
};
$( document ).tooltip(tooltipSettings);
(function() {
var htmlBody = $("body");
var skipToolbar = $('.skip-navigation');
var isTabPressed = false;
var skipIndicator = $('<div class="positionDiv" id="position1"></div>');
$(document).on('keydown',function(e){
var code = e.keyCode;
if(code === 9 || (code > 36 && code < 41) && isTabPressed===false){
keyDownTime = now();
isTabPressed = true;
if(!$(".positionDiv").length){
skipIndicator.appendTo("body");
console.log("create");
}else{
console.log("exists");;
}
skipToolbar.show().focus();
}
else if(code === 27){
$("body a:first").focus();
if($(".positionDiv").length) {($(".positionDiv").remove())};
document.activeElement.blur();
}
});
skipToolbar.find("a").each(function(index, element) {
var el = $(element);
el.on("click",function(){
var skipTo = $(this).data("skip");
$("[data-accessibility-navigation="+skipTo+"] :focusable").eq(0).focus();
return false;
});
});
$(document).on('focusin',function(e){
// console.time("focusin start");
var target = e.target,
$target = $(target),
hasTooltip = $target.data().hasOwnProperty("accessibilityTooltip") || false;
if(isTabPressed){
if(skipToolbar.length > 0 && $target.parent().hasClass("skip-navigation")){
}
}
if(hasTooltip){
/*$target.tooltip({
content: $target.data("accessibilityTooltip"),
position: {
my: "center bottom-20",
at: "center top",
using: function( position, feedback ) {
$( this ).css( position );
$( "<div>" )
.addClass( "arrow" )
.addClass( feedback.vertical )
.addClass( feedback.horizontal )
.appendTo( this );
}
}
});*/
}
/* throttle(function() {
$( "#position1" ).position({
my: "top+10px" ,
at: "center",
of: $target,
collision: 'fit',
using: function(css, calc) {
//$(this).animate(css, 200, "linear");
}
}).text($(target).data('accessibilityTooltip')).show();
},100);*/
htmlBody.addClass("skip");
if (isFirstFocus) {
isFirstFocus = false;
return;
}
if (now() - keyDownTime > 42) {
return;
}
onEnd();
prevFocused = $target;
movingId = setTimeout(onEnd, DURATION);
});
$(document).on('blur focusout',function(e){
onEnd();
});
function onEnd() {
if (!movingId) {
return;
}
clearTimeout(movingId);
movingId = 0;
}
function now() {
return new Date().valueOf();
}
})(jQuery);
});
$(document).ready(function() {
var elements = $(".skip-navigation a");
var n = elements.length;
elements
.keydown(function(event){
if (event.keyCode == 9) { //if tab
var currentIndex = elements.index(this);
var newIndex = event.shiftKey ? (currentIndex - 1) % n : (currentIndex + 1) % n;
var el = elements.eq(newIndex);
if (el.attr("type") == "text")
elements.eq(newIndex).select();
else
elements.eq(newIndex).focus();
event.preventDefault();
}
}).eq(0).focus();
});