Default theme (JavaScript): Fix coding standard
This commit is contained in:
parent
518d9b5aef
commit
d143105279
3 changed files with 26 additions and 7 deletions
11
.phpcs.xml
11
.phpcs.xml
|
@ -41,4 +41,15 @@
|
||||||
<rule ref="PSR2">
|
<rule ref="PSR2">
|
||||||
<exclude name="PSR1.Classes.ClassDeclaration.MissingNamespace"/>
|
<exclude name="PSR1.Classes.ClassDeclaration.MissingNamespace"/>
|
||||||
</rule>
|
</rule>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
The PHP-FIG PSR-2 Coding Style doesn't fully apply to JavaScript files
|
||||||
|
Furthermore, some sniffs aren't able to handle JavaScript peculiarities
|
||||||
|
-->
|
||||||
|
<rule ref="Generic.ControlStructures.InlineControlStructure">
|
||||||
|
<exclude-pattern>*.js</exclude-pattern>
|
||||||
|
</rule>
|
||||||
|
<rule ref="Squiz.Functions.MultiLineFunctionDeclaration">
|
||||||
|
<exclude-pattern>*.js</exclude-pattern>
|
||||||
|
</rule>
|
||||||
</ruleset>
|
</ruleset>
|
||||||
|
|
|
@ -9,7 +9,8 @@
|
||||||
* @version 1.1
|
* @version 1.1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function main() {
|
function main()
|
||||||
|
{
|
||||||
// capability CSS classes
|
// capability CSS classes
|
||||||
document.documentElement.className = 'js';
|
document.documentElement.className = 'js';
|
||||||
|
|
||||||
|
@ -39,7 +40,9 @@ function main() {
|
||||||
if (menuToggle.getAttribute('aria-expanded') === 'false') {
|
if (menuToggle.getAttribute('aria-expanded') === 'false') {
|
||||||
menuToggle.setAttribute('aria-expanded', 'true');
|
menuToggle.setAttribute('aria-expanded', 'true');
|
||||||
utils.slideDown(menu, null, function () {
|
utils.slideDown(menu, null, function () {
|
||||||
if (event.type === 'keydown') menu.focus();
|
if (event.type === 'keydown') {
|
||||||
|
menu.focus();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
menuToggle.setAttribute('aria-expanded', 'false');
|
menuToggle.setAttribute('aria-expanded', 'false');
|
||||||
|
|
|
@ -20,7 +20,8 @@ utils = {};
|
||||||
* to stop the iteration
|
* to stop the iteration
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
utils.forEach = function (object, callback) {
|
utils.forEach = function (object, callback)
|
||||||
|
{
|
||||||
var i = 0,
|
var i = 0,
|
||||||
keys = Object.keys(object),
|
keys = Object.keys(object),
|
||||||
length = keys.length;
|
length = keys.length;
|
||||||
|
@ -36,7 +37,8 @@ utils.forEach = function (object, callback) {
|
||||||
*
|
*
|
||||||
* @return boolean TRUE when the browser supports sliding, FALSE otherwise
|
* @return boolean TRUE when the browser supports sliding, FALSE otherwise
|
||||||
*/
|
*/
|
||||||
utils.canSlide = function () {
|
utils.canSlide = function ()
|
||||||
|
{
|
||||||
return (Modernizr.classlist && Modernizr.requestanimationframe && Modernizr.csstransitions);
|
return (Modernizr.classlist && Modernizr.requestanimationframe && Modernizr.csstransitions);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -49,7 +51,8 @@ utils.canSlide = function () {
|
||||||
* @param function startCallback function to call when the animation starts
|
* @param function startCallback function to call when the animation starts
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
utils.slideUp = function (element, finishCallback, startCallback) {
|
utils.slideUp = function (element, finishCallback, startCallback)
|
||||||
|
{
|
||||||
if (!utils.canSlide()) {
|
if (!utils.canSlide()) {
|
||||||
if (startCallback) startCallback();
|
if (startCallback) startCallback();
|
||||||
element.className += (element.className !== '') ? ' hidden' : 'hidden';
|
element.className += (element.className !== '') ? ' hidden' : 'hidden';
|
||||||
|
@ -96,7 +99,8 @@ utils.slideUp = function (element, finishCallback, startCallback) {
|
||||||
* @param function startCallback function to call when the animation starts
|
* @param function startCallback function to call when the animation starts
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
utils.slideDown = function (element, finishCallback, startCallback) {
|
utils.slideDown = function (element, finishCallback, startCallback)
|
||||||
|
{
|
||||||
if (!utils.canSlide()) {
|
if (!utils.canSlide()) {
|
||||||
if (startCallback) startCallback();
|
if (startCallback) startCallback();
|
||||||
element.className = element.className.replace(/\bhidden\b */g, '');
|
element.className = element.className.replace(/\bhidden\b */g, '');
|
||||||
|
@ -146,6 +150,7 @@ utils.slideDown = function (element, finishCallback, startCallback) {
|
||||||
* @param HTMLElement element the element to check
|
* @param HTMLElement element the element to check
|
||||||
* @return boolean TRUE when the element is visible, FALSE otherwise
|
* @return boolean TRUE when the element is visible, FALSE otherwise
|
||||||
*/
|
*/
|
||||||
utils.isElementVisible = function (element) {
|
utils.isElementVisible = function (element)
|
||||||
|
{
|
||||||
return !!(element.offsetWidth || element.offsetHeight || element.getClientRects().length);
|
return !!(element.offsetWidth || element.offsetHeight || element.getClientRects().length);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue