Browse Source

Update Aetna, simplify font size button (#163)

Accompanies https://github.com/pressbooks/pressbooks-book/pull/452.
pull/164/head
Ned Zimmerman 6 years ago committed by GitHub
parent
commit
ab7e88c040
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 89
      assets/scripts/routes/common.js
  2. 4
      dist/mix-manifest.json
  3. 2
      dist/scripts/aldine.js
  4. 2
      dist/styles/aldine.css
  5. 703
      package-lock.json
  6. 2
      package.json
  7. 12
      partials/content-accessibility-toolbar.php

89
assets/scripts/routes/common.js

@ -3,52 +3,53 @@ import * as Cookies from 'js-cookie';
export default { export default {
init() { init() {
// JavaScript to be fired on all pages // JavaScript to be fired on all pages
jQuery( $ => { // JavaScript to be fired on all pages
$( 'body' ) document.body.classList.remove( 'no-js' );
.removeClass( 'no-js' ) document.body.classList.add( 'js' );
.addClass( 'js' );
$( document ).ready( function () { // Font Size handler
// Fontsize handler ( function () {
if ( Cookies.get( 'a11y-root-larger-fontsize' ) === '1' ) { const fontSizeButton = document.querySelector( '.a11y-fontsize' );
$( 'html' ).addClass( 'fontsize' );
$( '#is_normal_fontsize' ) if ( Cookies.get( 'a11y-root-larger-fontsize' ) === '1' ) {
.attr( 'id', 'is_large_fontsize' ) document.documentElement.classList.add( 'fontsize' );
.attr( 'aria-checked', true ) fontSizeButton.setAttribute( 'aria-pressed', true );
.addClass( 'active' ) fontSizeButton.textContent = pressbooksBook.decrease_label;
.text( PB_A11y.decrease_label ) }
.attr( 'title', PB_A11y.decrease_label );
}
$( '.toggle-fontsize' ).on( 'click', function () { fontSizeButton.onclick = () => {
if ( $( this ).attr( 'id' ) === 'is_normal_fontsize' ) { // Cast the state as a boolean
$( 'html' ).addClass( 'fontsize' ); let pressed = fontSizeButton.getAttribute( 'aria-pressed' ) === 'true' || false;
$( this )
.attr( 'id', 'is_large_fontsize' )
.attr( 'aria-checked', true )
.addClass( 'active' )
.text( PB_A11y.decrease_label )
.attr( 'title', PB_A11y.decrease_label );
Cookies.set( 'a11y-root-larger-fontsize', '1', {
expires: 365,
path: '/',
} );
return false;
} else {
$( 'html' ).removeClass( 'fontsize' );
$( this )
.attr( 'id', 'is_normal_fontsize' )
.removeAttr( 'aria-checked' )
.removeClass( 'active' )
.text( PB_A11y.increase_label )
.attr( 'title', PB_A11y.increase_label );
Cookies.set( 'a11y-root-larger-fontsize', '0', {
expires: 365,
path: '/',
} );
return false;
}
} );
// Switch the state
fontSizeButton.setAttribute( 'aria-pressed', ! pressed );
if ( ! pressed ) {
document.documentElement.classList.add( 'fontsize' );
fontSizeButton.setAttribute( 'title', pressbooksBook.decrease_label );
fontSizeButton.textContent = pressbooksBook.decrease_label;
document.querySelector( '.nav-reading' ).setAttribute( 'style', '' );
Cookies.set( 'a11y-root-larger-fontsize', '1', {
expires: 365,
path: '/',
} );
return false;
} else {
document.documentElement.classList.remove( 'fontsize' );
fontSizeButton.setAttribute( 'title', pressbooksBook.increase_label );
fontSizeButton.textContent = pressbooksBook.increase_label;
document.querySelector( '.nav-reading' ).setAttribute( 'style', '' );
Cookies.set( 'a11y-root-larger-fontsize', '0', {
expires: 365,
path: '/',
} );
return false;
}
};
} )();
jQuery( $ => {
$( document ).ready( function () {
// Sets a -1 tabindex to ALL sections for .focus()-ing // Sets a -1 tabindex to ALL sections for .focus()-ing
let sections = document.getElementsByTagName( 'section' ); let sections = document.getElementsByTagName( 'section' );
for ( let i = 0, max = sections.length; i < max; i++ ) { for ( let i = 0, max = sections.length; i < max; i++ ) {

4
dist/mix-manifest.json vendored

@ -1,6 +1,6 @@
{ {
"/scripts/aldine.js": "/scripts/aldine.js?id=ee02a6da7afbb08e2da2", "/scripts/aldine.js": "/scripts/aldine.js?id=9c733367c69402ea3d31",
"/styles/aldine.css": "/styles/aldine.css?id=1f8a15821c0738b3ffab", "/styles/aldine.css": "/styles/aldine.css?id=6a420921e1b3f0f42695",
"/styles/editor.css": "/styles/editor.css?id=c45cb52a8c16b5642bf6", "/styles/editor.css": "/styles/editor.css?id=c45cb52a8c16b5642bf6",
"/scripts/call-to-action.js": "/scripts/call-to-action.js?id=14b2ac09b5fc52660522", "/scripts/call-to-action.js": "/scripts/call-to-action.js?id=14b2ac09b5fc52660522",
"/scripts/catalog-admin.js": "/scripts/catalog-admin.js?id=4f9c16093cec65a0274f", "/scripts/catalog-admin.js": "/scripts/catalog-admin.js?id=4f9c16093cec65a0274f",

2
dist/scripts/aldine.js vendored

File diff suppressed because one or more lines are too long

2
dist/styles/aldine.css vendored

File diff suppressed because one or more lines are too long

703
package-lock.json generated

File diff suppressed because it is too large Load Diff

2
package.json

@ -66,7 +66,7 @@
"vue-template-compiler": "^2.5.21" "vue-template-compiler": "^2.5.21"
}, },
"dependencies": { "dependencies": {
"aetna": "^1.0.0-alpha.21", "aetna": "^1.0.0-alpha.22",
"isotope-layout": "^3.0.6", "isotope-layout": "^3.0.6",
"jquery-bridget": "^2.0.1", "jquery-bridget": "^2.0.1",
"js-cookie": "^2.2.0", "js-cookie": "^2.2.0",

12
partials/content-accessibility-toolbar.php

@ -1,13 +1,7 @@
<!-- a11y toolbar --> <!-- a11y toolbar -->
<div class="a11y-toolbar"> <div class="a11y-toolbar">
<div class="wrap"> <button class="a11y-fontsize" aria-pressed="false">
<ul> <?php _e( 'Increase Font Size', 'pressbooks-aldine' ); ?>
<li> </button>
<a href="#" role="button" class="a11y-toggle-fontsize toggle-fontsize" id="is_normal_fontsize" title="<?php _e( 'Increase Font Size', 'pressbooks-aldine' ); ?>">
<?php _e( 'Increase Font Size', 'pressbooks-aldine' ); ?>
</a>
</li>
</ul>
</div>
</div> </div>
<!-- // a11y toolbar --> <!-- // a11y toolbar -->

Loading…
Cancel
Save