Move JS plugins out of domready area.
This commit is contained in:
@ -551,107 +551,6 @@ window.log = function f(){ log.history = log.history || []; log.history.push(arg
|
||||
|
||||
}( window.serendipity = window.serendipity || {}, jQuery ));
|
||||
|
||||
(function($) {
|
||||
// Source: https://github.com/yatil/accessifyhtml5.js
|
||||
var AccessifyHTML5 = function (defaults, more_fixes) {
|
||||
"use strict";
|
||||
|
||||
var fixes = {
|
||||
'article' : { 'role': 'article' },
|
||||
'aside' : { 'role': 'complementary' },
|
||||
'nav' : { 'role': 'navigation' },
|
||||
'main' : { 'role': 'main' },
|
||||
'output' : { 'aria-live': 'polite' },
|
||||
'section' : { 'role': 'region' },
|
||||
'[required]': { 'aria-required': 'true' }
|
||||
},
|
||||
fix, elems, attr, value, key, obj, i, mo, by_match, el_label,
|
||||
ATTR_SECURE = /aria-[a-z]+|role|tabindex|title|alt|data-[\w\-]+|lang|style|maxlength|placeholder|pattern|type/,
|
||||
ID_PREFIX = "acfy-id-",
|
||||
n_label = 0,
|
||||
Doc = document;
|
||||
|
||||
if (Doc.querySelectorAll) {
|
||||
|
||||
if (defaults) {
|
||||
if (defaults.header) {
|
||||
fixes[defaults.header] = {
|
||||
'role': 'banner'
|
||||
};
|
||||
}
|
||||
if (defaults.footer) {
|
||||
fixes[defaults.footer] = {
|
||||
'role': 'contentinfo'
|
||||
};
|
||||
}
|
||||
if (defaults.main) {
|
||||
fixes[defaults.main] = {
|
||||
'role': 'main'
|
||||
};
|
||||
fixes.main = {
|
||||
'role': ''
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
for (mo in more_fixes) {
|
||||
fixes[mo] = more_fixes[mo];
|
||||
}
|
||||
|
||||
for (fix in fixes) {
|
||||
if (fixes.hasOwnProperty(fix)) {
|
||||
|
||||
elems = Doc.querySelectorAll(fix);
|
||||
obj = fixes[fix];
|
||||
|
||||
for (i = 0; i < elems.length; i++) {
|
||||
|
||||
for (key in obj) {
|
||||
if (obj.hasOwnProperty(key)) {
|
||||
|
||||
attr = key;
|
||||
value = obj[key];
|
||||
|
||||
if (!attr.match(ATTR_SECURE)) {
|
||||
continue;
|
||||
}
|
||||
if (!(typeof value).match(/string|number/)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
by_match = attr.match(/(describ|label)l?edby/);
|
||||
if (by_match) {
|
||||
el_label = Doc.querySelector(value);
|
||||
|
||||
if (! el_label) { continue; }
|
||||
|
||||
if (! el_label.id) {
|
||||
el_label.id = ID_PREFIX + n_label;
|
||||
}
|
||||
|
||||
value = el_label.id;
|
||||
attr = "aria-" + ("label" === by_match[1] ? "labelledby" : "describedby");
|
||||
|
||||
n_label++;
|
||||
}
|
||||
|
||||
if (!elems[i].hasAttribute(attr)) {
|
||||
elems[i].setAttribute(attr, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Accessibility helper script
|
||||
AccessifyHTML5({
|
||||
header: '#top>div>div',
|
||||
footer: '#meta'
|
||||
});
|
||||
|
||||
// Source: https://github.com/viljamis/responsive-nav.js
|
||||
var responsiveNav = (function (window, document) {
|
||||
|
||||
@ -1050,6 +949,101 @@ window.log = function f(){ log.history = log.history || []; log.history.push(arg
|
||||
return rn;
|
||||
})(window, document);
|
||||
|
||||
// Source: https://github.com/yatil/accessifyhtml5.js
|
||||
var AccessifyHTML5 = function (defaults, more_fixes) {
|
||||
"use strict";
|
||||
|
||||
var fixes = {
|
||||
'article' : { 'role': 'article' },
|
||||
'aside' : { 'role': 'complementary' },
|
||||
'nav' : { 'role': 'navigation' },
|
||||
'main' : { 'role': 'main' },
|
||||
'output' : { 'aria-live': 'polite' },
|
||||
'section' : { 'role': 'region' },
|
||||
'[required]': { 'aria-required': 'true' }
|
||||
},
|
||||
fix, elems, attr, value, key, obj, i, mo, by_match, el_label,
|
||||
ATTR_SECURE = /aria-[a-z]+|role|tabindex|title|alt|data-[\w\-]+|lang|style|maxlength|placeholder|pattern|type/,
|
||||
ID_PREFIX = "acfy-id-",
|
||||
n_label = 0,
|
||||
Doc = document;
|
||||
|
||||
if (Doc.querySelectorAll) {
|
||||
|
||||
if (defaults) {
|
||||
if (defaults.header) {
|
||||
fixes[defaults.header] = {
|
||||
'role': 'banner'
|
||||
};
|
||||
}
|
||||
if (defaults.footer) {
|
||||
fixes[defaults.footer] = {
|
||||
'role': 'contentinfo'
|
||||
};
|
||||
}
|
||||
if (defaults.main) {
|
||||
fixes[defaults.main] = {
|
||||
'role': 'main'
|
||||
};
|
||||
fixes.main = {
|
||||
'role': ''
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
for (mo in more_fixes) {
|
||||
fixes[mo] = more_fixes[mo];
|
||||
}
|
||||
|
||||
for (fix in fixes) {
|
||||
if (fixes.hasOwnProperty(fix)) {
|
||||
|
||||
elems = Doc.querySelectorAll(fix);
|
||||
obj = fixes[fix];
|
||||
|
||||
for (i = 0; i < elems.length; i++) {
|
||||
|
||||
for (key in obj) {
|
||||
if (obj.hasOwnProperty(key)) {
|
||||
|
||||
attr = key;
|
||||
value = obj[key];
|
||||
|
||||
if (!attr.match(ATTR_SECURE)) {
|
||||
continue;
|
||||
}
|
||||
if (!(typeof value).match(/string|number/)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
by_match = attr.match(/(describ|label)l?edby/);
|
||||
if (by_match) {
|
||||
el_label = Doc.querySelector(value);
|
||||
|
||||
if (! el_label) { continue; }
|
||||
|
||||
if (! el_label.id) {
|
||||
el_label.id = ID_PREFIX + n_label;
|
||||
}
|
||||
|
||||
value = el_label.id;
|
||||
attr = "aria-" + ("label" === by_match[1] ? "labelledby" : "describedby");
|
||||
|
||||
n_label++;
|
||||
}
|
||||
|
||||
if (!elems[i].hasAttribute(attr)) {
|
||||
elems[i].setAttribute(attr, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
(function($) {
|
||||
// Fire responsive nav
|
||||
var navigation = responsiveNav('#main_menu', {
|
||||
animate: true, // Boolean: Use CSS3 transitions, true or false
|
||||
@ -1069,6 +1063,12 @@ window.log = function f(){ log.history = log.history || []; log.history.push(arg
|
||||
// Fire WYSIWYG editor(s)
|
||||
serendipity.spawn();
|
||||
|
||||
// Fire a11y helper script
|
||||
AccessifyHTML5({
|
||||
header: '#top>div>div',
|
||||
footer: '#meta'
|
||||
});
|
||||
|
||||
// Editor-area
|
||||
var $entryEditor = $('body').has('#serendipityEntry');
|
||||
|
||||
|
Reference in New Issue
Block a user