hide.js
8.5 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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
// Angie Radtke 2009 - 2012 thanks to daniel //
/*global window, localStorage, Cookie, altopen, altclose, big, small, rightopen, rightclose, bildauf, bildzu */
function saveIt(name) {
var x = document.getElementById(name).style.display;
if (!x) {
alert('No cookie available');
} else if (localStorage) {
localStorage[name] = x;
}
}
function readIt(name) {
if (localStorage) {
return localStorage[name];
}
}
function wrapperwidth(width) {
jQuery('#wrapper').css('width', width);
}
// add Wai-Aria landmark-roles
jQuery(function($) {
$('#nav').attr('role', 'navigation');
$('input[id^="mod-search-searchword"]').closest('form').attr('role', 'search');
$('#main').attr('role', 'main');
$('#right').attr('role', 'contentinfo');
});
jQuery(function($) {
// get ankers
var $myankers = $('a.opencloselink');
$myankers.each(function() {
var $element = $(this);
$element.attr('role', 'tab');
var myid = $element.attr('id');
myid = myid.split('_');
myid = 'module_' + myid[1];
$element.attr('aria-controls', myid);
});
var $list = $('div.moduletable_js');
$list.each(function() {
var $element = $(this);
if ($element.find('div.module_content').length) {
var $el = $element.find('div.module_content');
$el.attr('role', 'tabpanel');
var myid = $el.attr('id');
myid = myid.split('_');
myid = 'link_' + myid[1];
$el.attr('aria-labelledby', myid);
var myclass = $el.attr('class');
var one = myclass.split(' ');
// search for active menu-item
var $listelement = $el.find('a.active').first();
var unique = $el.attr('id');
var nocookieset = readIt(unique);
if (($listelement.length) || ((one[1] == 'open') && (nocookieset == null))) {
$el.show();
var $eltern = $el.parent();
var $elternh = $eltern.find('h3').first();
var $elternbild = $eltern.find('img').first();
$elternbild.attr('alt', altopen).attr('src', bildzu);
$elternbild.focus();
} else {
$el.hide();
$el.attr('aria-expanded', 'false');
}
unique = $el.attr('id');
var cookieset = readIt(unique);
if (cookieset === 'block') {
$el.show();
$el.attr('aria-expanded', 'true');
}
}
});
});
jQuery(function($) {
var $what = $('#right');
// if rightcolumn
if ($what.length) {
var whatid = $what.attr('id');
var rightcookie = readIt(whatid);
if (rightcookie === 'none') {
$what.hide();
$('#nav').addClass('leftbigger');
wrapperwidth(big);
var $grafik = $('#bild');
$grafik.html(rightopen);
$grafik.focus();
}
}
});
function auf(key) {
var $ = jQuery.noConflict();
var $el = $('#' + key);
if (!$el.is(':visible')) {
$el.show();
$el.attr('aria-expanded', 'true');
if (key !== 'right') {
$el.hide().toggle('slide');
$el.parent().attr('class', 'slide');
$eltern = $el.parent().parent();
$elternh = $eltern.find('h3').first();
$elternh.addClass('high');
$elternbild = $eltern.find('img').first();
$el.focus();
$elternbild.attr('alt', altopen).attr('src', bildzu);
}
if (key === 'right') {
$('#right').show();
wrapperwidth(small);
$('#nav').removeClass('leftbigger');
$grafik = $('#bild');
$('#bild').html(rightclose);
$grafik.focus();
}
} else {
$el.hide();
$el.attr('aria-expanded', 'false');
$el.removeClass('open');
if (key !== 'right') {
$eltern = $el.parent().parent();
$elternh = $eltern.find('h3').first();
$elternh.removeClass('high');
$elternbild = $eltern.find('img').first();
$elternbild.attr('alt', altclose).attr('src', bildauf);
$elternbild.focus();
}
if (key === 'right') {
$('#right').hide();
wrapperwidth(big);
$('#nav').addClass('leftbigger');
$grafik = $('#bild');
$grafik.html(rightopen);
$grafik.focus();
}
}
// write cookie
saveIt(key);
}
// ########### Tabfunctions ####################
jQuery(function($) {
var $alldivs = $('div.tabcontent');
var $outerdivs = $('div.tabouter');
//outerdivs = outerdivs.getProperty('id');
$outerdivs.each(function() {
var $alldivs = $(this).find('div.tabcontent');
var count = 0;
var countankers = 0;
$alldivs.each(function() {
var $el = $(this);
count++;
$el.attr('role', 'tabpanel');
$el.attr('aria-hidden', 'false');
$el.attr('aria-expanded', 'true');
elid = $el.attr('id');
elid = elid.split('_');
elid = 'link_' + elid[1];
$el.attr('aria-labelledby', elid);
if (count !== 1) {
$el.addClass('tabclosed').removeClass('tabopen');
$el.attr('aria-hidden', 'true');
$el.attr('aria-expanded', 'false');
}
});
$allankers = $(this).find('ul.tabs').first().find('a');
$allankers.each(function() {
countankers++;
var $el = $(this);
$el.attr('aria-selected', 'true');
$el.attr('role', 'tab');
linkid = $el.attr('id');
moduleid = linkid.split('_');
moduleid = 'module_' + moduleid[1];
$el.attr('aria-controls', moduleid);
if (countankers != 1) {
$el.addClass('linkclosed').removeClass('linkopen');
$el.attr('aria-selected', 'false');
}
});
});
});
function tabshow(elid) {
var $ = jQuery.noConflict();
var $el = $('#' + elid);
var $outerdiv = $el.parent();
var $alldivs = $outerdiv.find('div.tabcontent');
var $liste = $outerdiv.find('ul.tabs').first();
$liste.find('a').attr('aria-selected', 'false');
$alldivs.each(function() {
var $element = $(this);
$element.addClass('tabclosed').removeClass('tabopen');
$element.attr('aria-hidden', 'true');
$element.attr('aria-expanded', 'false');
});
$el.addClass('tabopen').removeClass('tabclosed');
$el.attr('aria-hidden', 'false');
$el.attr('aria-expanded', 'true');
$el.focus();
var getid = elid.split('_');
var activelink = '#link_' + getid[1];
$(activelink).attr('aria-selected', 'true');
$liste.find('a').addClass('linkclosed').removeClass('linkopen');
$(activelink).addClass('linkopen').removeClass('linkclosed');
}
function nexttab(el) {
var $ = jQuery.noConflict();
var $outerdiv = $('#' + el).parent();
var $liste = $outerdiv.find('ul.tabs').first();
var getid = el.split('_');
var activelink = '#link_' + getid[1];
var aktiverlink = $(activelink).attr('aria-selected');
var $tablinks = $liste.find('a');
for (var i = 0; i < $tablinks.length; i++) {
if ($($tablinks[i]).attr('id') === activelink) {
if ($($tablinks[i + 1]).length) {
$($tablinks[i + 1]).click();
break;
}
}
}
}
// mobilemenuheader
var mobileMenu = function(){
var $ = jQuery.noConflict(), displayed = false, $mobile, $menu, $menuWrapper;
var getX = function() {
return $(document).width();
};
var createElements = function () {
var Openmenu=Joomla.JText._('TPL_BEEZ3_OPENMENU');
var Closemenu=Joomla.JText._('TPL_BEEZ3_CLOSEMENU');
$menu = $("#header").find('ul.menu').first();
$menuWrapper = $('<div>', {id : 'menuwrapper', role: 'menubar'});
// create the menu opener and assign events
$mobile = $('<div>', {id: 'mobile_select'}).html('<h2><a href="#" id="menuopener" onclick="return false;"><span>'+Openmenu+'</span></a></h2>').show();
$mobile.on('click', function(){
var state = $menuWrapper.css('display');
$menuWrapper.slideToggle();
if (state === 'none') {
$('#menuopener').html(Closemenu);
$('#menuwrapper').attr('aria-expanded', 'true').attr('aria-hidden','false');
} else {
$('#menuopener').html(Openmenu);
$('#menuwrapper').attr('aria-expanded', 'false').attr('aria-hidden', 'true');
}
});
// add the menu to the dom
$menu.wrap($menuWrapper);
// add the menuopener to the dom and hide it
$('#header').find('#menuwrapper').first().before($mobile.hide());
$menuWrapper = $('#menuwrapper');
$mobile = $('#mobile_select');
};
var display = function () {
$menuWrapper.hide();
$mobile.show();
displayed = true;
};
var initialize = function () {
// create the elements once
createElements();
// show the elements if the browser size is smaller
if (getX() <= 461 && !displayed) {
display();
}
// react on resize events
$(window).on('resize', function () {
if (getX() >= 461) {
if (displayed) {
$mobile.hide();
$('#menuwrapper').show();
displayed = false;
}
}
if (getX() < 461) {
if (!displayed) {
display();
}
}
});
};
initialize();
};
jQuery(function () {
new mobileMenu();
});
//For discussion and comments, see: http://remysharp.com/2009/01/07/html5-enabling-script/
(function(){if(!/*@cc_on!@*/0)return;var e = "abbr,article,aside,audio,canvas,datalist,details,eventsource,figure,footer,header,hgroup,mark,menu,meter,nav,output,progress,section,time,video".split(','),i=e.length;while(i--){document.createElement(e[i])}})()