PageSourceSearch

https://www.washburn.edu/_redesign2018/_files/js/accessibility.js

js washburn.edu collected 2026-09-24 09:01:34 UTC 14,889 bytes, 381 lines download raw bytes

1/*custom js for accessibility */ 
2/*use window.onload for adding to RSS scripts that load late*/
3    window.onload = function() {
4        var title = document.getElementsByTagName("title")[0].innerHTML;
5
6        /*for adding title to twitter iframe for ADA compliance */
7        $('#twitter-widget-0').attr('title', 'twitter iframe');
8
9
10        /*for adding alt tag to flickr stream images */
11        $(".flickr").find("img").each(function(i) {
12            $(this).attr("alt", title + (i+1));
13        });
14
15        /* for adding page title to any iframe without a title */
16
17        $("iframe").each(function(i) {
18            var iframetitle = $("iframe[title]");
19            var iframewidth = $(this).attr("width");
20            var iframemrgnwt = $(this).attr("marginwidth");
21            var iframemrgnht = $(this).attr("marginheight");
22
23            if(iframetitle = "0"){
24                $(this).attr("title", title + (i+1));  
25            } 
26            if(iframewidth !== null && iframewidth !== ""){
27               $(this).css("width", iframewidth);  
28               $(this).removeAttr("width");
29            } 
30
31           if(iframemrgnwt !== null){
32               $(this).css("list-style", iframemrgnwt);
33               $(this).removeAttr('marginwidth');
34           }
35           if(iframemrgnht !== null){
36               $(this).css("list-style", iframemrgnht);
37               $(this).removeAttr('marginheight');
38           }
39 
40        });
41
42//iframe heights can change with dynamically loading content so we will put a delay on getting the height and then change the attribute to inline style for ADA compliance
43        setTimeout(function () {
44            $("iframe").each(function () {
45                var iframeheight;
46                iframeheight = $(this).height();
47                //alert(iframeheight);
48                $(this).css({
49                    //"height": iframeheight + "px"
50                });
51                //$(this).removeAttr("height");
52            })
53        }, 1000);
54
55    $("iframe,table,td,tr,div,span,img").find('[border*="0"]').each(function() {
56        $(this).removeAttr("frameborder");
57        $(this).removeAttr("border");
58        $(this).addClass("noborder");
59       
60    });
61    $("iframe").each(function() {
62        $(this).removeAttr("scrolling");
63        $(this).removeAttr("frameborder");   
64        $(this).addClass("noborder");
65    });
66 
67    $("iframe, table, td, tr, div, span,img").find('[border*="1"]').each(function() {
68        $(this).removeAttr("border");
69        $(this).css("border", "1px");
70    }); 
71
72    $("iframe, table, td, tr, div, span,img").find('[align*="left"]').each(function() {
73        $(this).removeAttr("align");
74        $(this).addClass("alignleft");
75    }); 
76    $("iframe, table, td, tr, div, span,img").find('[align*="right"]').each(function() {
77        $(this).removeAttr("align");
78        $(this).addClass("alignright");
79    });
80        
81    $("iframe, table, td, tr, div, span,img").find('[valign*="top"]').each(function() {
82        $(this).removeAttr("valign");
83        $(this).css("vertical-align", "top");
84    }); 
85    $("iframe, table, td, tr, div, span,img").find('[valign*="middle"]').each(function() {
86        $(this).removeAttr("valign");
87        $(this).css("vertical-align", "middle");
88    });
89    $("iframe, table, td, tr, div, span,img").find('[align*="center"]').each(function() {
90        $(this).removeAttr("align");
91        $(this).addClass("aligncenter");
92    }); 
93 
94    $("iframe, table, td, tr, div, span,img").each(function() {
95        $(this).removeAttr("vspace");
96        $(this).removeAttr("hspace");
97        $(this).removeAttr('cellSpacing');
98        $(this).removeAttr('cellPadding');
99    });
100
101      /*replace bold tags with strong for ADA compliance */
102      var container = document.getElementById("backToTop");
103      if(container){
104      var find = container.getElementsByTagName("b");
105      var bold, strong;
106
107          while (bold = find[0]) {
108              strong = document.createElement("strong");
109              while (bold.firstChild) {
110                  strong.appendChild(bold.firstChild);
111              }
112
113              bold.parentNode.replaceChild(strong, bold);
114           }
115      }
116    
117       /* END replace bold tags */
118
119    //do a check for attribute img 'height'
120    var imgheight = $("img[height]");
121    imgheight.each(function(){ 
122       var attrheight = $(this).attr('height');
123       if ( !(attrheight == null)){
124           $(this).css("height", "auto");
125           $(this).removeAttr('height');
126       };
127    });
128
129    //do a check for attribute 'width'
130    var imgwidth = $("img[width]");
131    imgwidth.each(function(){ 
132       var attrwidth = $(this).attr('width');
133       if ( !(attrwidth == "")){
134           $(this).css("width", attrwidth);
135           $(this).removeAttr('width');
136       };
137    });
138
139    //do a check for attribute 'border'. If it is not controlled by stylesheet, we dont need it.
140    $("img[border]").each(function() {
141        $(this).removeAttr("border");
142    });
143
144    //do a check for obsolete attribute td, tr 'height'
145    var objheight = $("td[height],tr[height]");
146    objheight.each(function(){ 
147       var attrheight = $(this).attr('height');
148       if ( !(attrheight == null)){
149           $(this).css("height", attrheight);
150           $(this).removeAttr('height');
151       };
152    });
153    
154    //do a check for obsolete attribute table, td, tr 'height'
155    
156        var tblheight = $("table[height]");
157    tblheight.each(function(){ 
158       var tableheight = $(this).attr("height");
159       if ( !(tableheight == null)){
160          $(this).css("height", tableheight + "px");
161          $(this).removeAttr('height');
162          
163       };
164    });
165
166   //do a check for attribute hr 'noshade'
167    var hrnoshade = $('hr[noshade*="noshade"]');
168    hrnoshade.each(function(){         
169           $(this).removeAttr('noshade');
170    });
171   //do a check for attribute hr 'size'
172    var hrsize = $('hr[size*="1"]');
173    hrsize.each(function(){         
174           $(this).removeAttr('size');
175    });
176
177    //do a check for obsolete attribute hr, col, table 'width'
178    var hrwidth = $("hr[width],col[width],table[width],tr[width],td[width]");
179    hrwidth.each(function(){ 
180       var attrwidth = $(this).attr('width');
181       if ( !(attrwidth == "")){
182           $(this).css("width", attrwidth);
183           $(this).removeAttr('width');
184       };
185    });
186
187    //do a check for 'title' in a tags
188    $('a').each(function(i){ 
189         var atitle = $(this).attr('title');
190         var atext = $(this).text();
191         var ariaLabel = $(this).attr('aria-label');
192         var ariaLabelledBy = $(this).attr('aria-labelledby');
193         
194         //this adds the preceding h2 or h3 as title if it exists 
195         if ((atitle == null || atitle == "") && (ariaLabel == null || ariaLabel == "") && (ariaLabelledBy == null || ariaLabelledBy == "")){
196         var h3text = $(this).closest(".accordion").children('h3').text();
197         var h2text = $(this).closest(".accordion").children('h2').text();
198         }
199
200         //next is to add a class which removes bottom-border from links without text. bottom border was added to links site wide for accessibility where color contrast ratio was low 
201
202         if(atext == null || atext == ""){
203             $(this).addClass("nontext");
204         }
205
206         //add a title if there is none
207         //
208        var custURL = $(location).attr("href");
209        //for cascade calendar.washburn.edu index
210        var searchURL = window.location.search;
211        if ( custURL == "https://mulvaneartmuseum.org/calendar/index.html" ){
212            var restrictedPage = 'true';
213        }else if (custURL.indexOf("https://calendar-prod.washburn.edu") == 0 || custURL.indexOf("https://calendar.washburn.edu") == 0 || searchURL.indexOf("?id=74fc1e3ec06801167263ecb161145ae0") == 0) {
214            var restrictedPage = 'true';
215        }else if (custURL.indexOf("https://mulvaneartmuseum.org/search.html") == 0) {
216            var restrictedPage = 'true';
217        }else if (custURL.indexOf("https://www.washburn.edu/search-results/index.html") == 0 || custURL.indexOf("https://www.washburn.edu/academics/aos/") == 0 || custURL.indexOf("https://washburn.edu/academics/courses/") == 0 || searchURL.indexOf("?id=4c364303c068011616ecca441b08c06d") == 0 || searchURL.indexOf("?id=cf5f1a96c06801161ecfeb6c42fae5df") == 0){
218            var restrictedPage = 'true';
219        }else {
220            var restrictedPage = 'false';
221        };
222        if (restrictedPage == 'false'){
223            if((atitle == null || atitle == "") && (ariaLabel == null || ariaLabel == "") && (ariaLabelledBy == null || ariaLabelledBy == "")){
224                if(h3text !== null && h3text !== ""){
225                    //$(this).attr('title', h3text + " " + " " + (i+1));
226                }else if(h2text !== null && h2text !== ""){
227                    //$(this).attr('title', h2text + " " + " " + (i+1));
228                }else if(h2text == null || h2text == ""){
229                    //$(this).attr('title', atext + " | " + title + " " + (i+1));
230                }
231            }
232        }
233    }); 
234
235    //do a check for 'alt' in img tags
236    $('img').each(function(i){ 
237         var title = document.getElementsByTagName("title")[0].innerHTML;
238         var imgalt = $(this).attr('alt');
239         if(imgalt == null || imgalt == ""){
240         if(title){
241         $(this).attr('alt', title + " " + (i+1));
242         }
243         }  
244    });
245
246    //do a check for specific image div that loads 3rd party image after page load 'title' in a tags. located on allied health physical therapy page
247     $(".yoshkidiv").find("img").each(function(i){ 
248             var title = document.getElementsByTagName("title")[0].innerHTML;
249             var imgtitle = $(this).attr('title');
250            $(this).attr('alt', title + " " + (i+1));
251    });
252
253    /*for adding title to paypal form for ADA compliance */
254    $( "input[name='os2']" ).attr('title','explain if yes')
255    $( "input[name='os3']" ).attr('title','student name and age if child')
256    $( "input[name='os4']" ).attr('title','emergency contact number')
257    $( "input[name='os0']" ).attr('title','non members / members')
258    $( "input[name='os1']" ).attr('title','yes / no')
259
260    //check td and tr widths except for fullcalendar pages 
261    $("tr").not(".fc-head tr" ).each(function() {
262        var width = $(this).attr("width");
263        if(width){
264            $(this).removeAttr("width");
265            $(this).css('width', width);
266        }    
267    });
268    $("td").not(".fc-head td" ).each(function() {
269        var width = $(this).attr("width");
270        if(width){
271            $(this).removeAttr("width");
272            $(this).css('width', width);
273        }    
274    });
275
276    //do a check for attribute table 'sizcache'
277    var tablesizset = $("table[sizset],tbody[sizset]");
278    tablesizset.each(function(){ 
279           $(this).removeAttr('sizset');
280    });
281
282    //do a check for attribute table 'rules'
283    var tablerules= $("table[rules],tbody[rules]");
284    tablerules.each(function(){ 
285           $(this).removeAttr('rules');
286    });
287
288    //do a check for attribute table 'sizcache'
289    var tablesizcache = $("table[sizcache],tbody[sizcache]");
290    tablesizcache.each(function(){ 
291           $(this).removeAttr('sizcache');
292    });
293    //do a check for attribute table 'frame'
294    var tableframe = $("table[frame]");
295    tableframe.each(function(){ 
296           $(this).removeAttr('frame');
297    });
298
299    //do a check for attribute ul,li 'type'
300    var bulltype = $("ul[type],li[type]");
301    bulltype.each(function(){ 
302           var liststyle = $(this).attr('type');
303           $(this).css("list-style", liststyle);
304           $(this).removeAttr('type');
305    });
306
307    //do a check for attribute img 'align=top'
308    var imgaligntop = $("img[align*=top]");
309    imgaligntop.each(function(){ 
310           $(this).css("vertical-align", "top");
311           $(this).removeAttr('align');
312    });
313    //do a check for attribute img 'align=bottom'
314    var imgalignbottom = $("img[align*=bottom],caption[align*=bottom]");
315    imgalignbottom.each(function(){ 
316           $(this).css("vertical-align", "bottom");
317           $(this).removeAttr('align');
318    });
319
320    //do a check for attribute img 'align=absmiddle'
321    var imgaligncenter= $("img[align*=center],img[align*=absmiddle],img[align*=middle]");
322    imgaligncenter.each(function(){ 
323           $(this).css("text-align", "center");
324           $(this).removeAttr('align');
325    });
326
327    //do a check for obsolete attribute 'border'
328    var tableborder = $("table[border]");
329    tableborder.each(function(){ 
330       var border = $(this).attr('border');
331       //console.log(this,$(this).attr('border'));//show expression (for debug)
332       if ( !(border == "")){
333           $(this).css("border", border + 'px');
334           $(this).removeAttr('border');
335       };
336    });
337  
338    //do a check for obsolete attribute 'bordercolor'
339    var tablebordercolor = $("table[bordercolor]");
340    tablebordercolor.each(function(){ 
341       var bordercolor = $(this).attr('bordercolor');
342       //console.log(this,$(this).attr('bordercolor'));//show expression (for debug)
343       if ( !(bordercolor == "")){
344           $(this).css("border-color", bordercolor);
345           $(this).removeAttr('bordercolor');
346       };
347    });
348
349    //do a check for obsolete attribute 'bgcolor'
350    var tdbgcolor = $("td[bgcolor],tr[bgcolor]");
351    tdbgcolor.each(function(){ 
352       var tdbg = $(this).attr('bgcolor');
353       //console.log(this,$(this).attr('bgcolor'));//show expression (for debug)
354       if ( !(tdbg == "")){
355           $(this).css("background-color", tdbg);
356           $(this).removeAttr('bgcolor');
357       };
358    });
359
360    /* Remove html formatting on google search tables */
361    $("#gsc-search-box").removeAttr("cellpadding cellspacing");
362    $("#gs_id50").removeAttr("cellpadding cellspacing");
363    $("#gs_id51").removeAttr("cellpadding cellspacing");
364    $(".gstl_51 .gstl_50 .gssb_c").removeAttr("cellpadding cellspacing");
365
366    //focus for skip to main content button
367    function homeSkip() {
368        document.getElementById("findYourMajor a").focus();
369    }
370    function intSkip() {
371        document.getElementById("mainContent").focus();
372    }
373    function otherSkip() {
374        document.getElementById("backToTop").focus();
375    }
376    
377    //var sections = document.getElementsByTagName('section');
378    //for (var i = 0, len = sections.length; i < len; i++){
379    //sections[i].setAttribute('tabindex', '-1');}
380       
381}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.