Browse Source

fix: resolve linting errors, migrate Sass division to new syntax (#257)

pull/260/head
Ned Zimmerman 3 years ago committed by GitHub
parent
commit
4bae343fc5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      assets/scripts/aldine.js
  2. 14
      assets/scripts/call-to-action.js
  3. 3
      assets/scripts/customizer-toggle.js
  4. 14
      assets/scripts/page-section.js
  5. 20
      assets/scripts/routes/catalog.js
  6. 6
      assets/scripts/routes/home.js
  7. 12
      assets/scripts/util/Router.js
  8. 3
      assets/scripts/util/camelCase.js
  9. 25
      dist/mix-manifest.json
  10. 2
      dist/scripts/aldine.js
  11. 2
      dist/scripts/call-to-action.js
  12. 2
      dist/scripts/catalog-admin.js
  13. 2
      dist/scripts/customizer-toggle.js
  14. 2
      dist/scripts/customizer.js
  15. 2
      dist/scripts/page-section.js
  16. 2
      dist/styles/aldine.css
  17. 2
      dist/styles/editor.css
  18. 20
      package.json

4
assets/scripts/aldine.js

@ -1,8 +1,8 @@
// import local dependencies
import Router from './util/Router';
import catalog from './routes/catalog';
import common from './routes/common';
import home from './routes/home';
import catalog from './routes/catalog';
import Router from './util/Router';
/** Populate Router instance with DOM routes */
const routes = new Router( {

14
assets/scripts/call-to-action.js

@ -1,9 +1,16 @@
( function () {
tinymce.create( 'tinymce.plugins.aldine_call_to_action', {
/**
* @param editor
* @param url
*/
init: function ( editor, url ) {
editor.addButton( 'aldine_call_to_action', {
title: aldine.call_to_action.title,
icon: 'icon dashicons-flag',
/**
*
*/
onclick: function () {
editor.windowManager.open( {
title: aldine.call_to_action.title,
@ -21,6 +28,9 @@
value: '#',
},
],
/**
* @param e
*/
onsubmit: function ( e ) {
editor.insertContent(
'[aldine_call_to_action text="' +
@ -34,6 +44,10 @@
},
} );
},
/**
* @param n
* @param cm
*/
createControl: function ( n, cm ) {
return null;
},

3
assets/scripts/customizer-toggle.js

@ -6,6 +6,9 @@ document.addEventListener( 'DOMContentLoaded', function () {
checkbox.addEventListener( 'click', toggleReadOnly );
/**
*
*/
function toggleReadOnly() {
if ( checkbox.checked === false ) {
email.classList.add( 'hidden' );

14
assets/scripts/page-section.js

@ -1,9 +1,16 @@
( function () {
tinymce.create( 'tinymce.plugins.aldine_page_section', {
/**
* @param editor
* @param url
*/
init: function ( editor, url ) {
editor.addButton( 'aldine_page_section', {
title: aldine.page_section.title,
icon: 'icon dashicons-layout',
/**
*
*/
onclick: function () {
editor.windowManager.open( {
title: aldine.page_section.title,
@ -39,6 +46,9 @@
value: '', // Sets the default
},
],
/**
* @param e
*/
onsubmit: function ( e ) {
editor.insertContent(
'[aldine_page_section title="' +
@ -52,6 +62,10 @@
},
} );
},
/**
* @param n
* @param cm
*/
createControl: function ( n, cm ) {
return null;
},

20
assets/scripts/routes/catalog.js

@ -1,7 +1,10 @@
const jQueryBridget = require( 'jquery-bridget' );
const Isotope = require( 'isotope-layout' );
const jQueryBridget = require( 'jquery-bridget' );
export default {
/**
*
*/
init() {
// JavaScript to be fired on the catalog page
( function () {
@ -19,6 +22,9 @@ export default {
// Function to create a node list
// of the content between this <h2> and the next
/**
* @param elem
*/
const getContent = elem => {
let elems = [];
while (
@ -56,6 +62,9 @@ export default {
// Assign the button
let btn = heading.querySelector( 'button' );
/**
*
*/
btn.onclick = () => {
// Cast the state as a boolean
let expanded = btn.getAttribute( 'aria-expanded' ) === 'true' || false;
@ -83,6 +92,9 @@ export default {
// Function to create a node list
// of the content between this <h2> and the next
/**
* @param elem
*/
const getContent = elem => {
let elems = [];
while (
@ -120,6 +132,9 @@ export default {
// Assign the button
let btn = heading.querySelector( 'button' );
/**
*
*/
btn.onclick = () => {
// Cast the state as a boolean
let expanded = btn.getAttribute( 'aria-expanded' ) === 'true' || false;
@ -296,5 +311,8 @@ export default {
// });
} );
},
/**
*
*/
finalize() {},
};

6
assets/scripts/routes/home.js

@ -1,6 +1,12 @@
export default {
/**
*
*/
init() {
// JavaScript to be fired on the home page
},
/**
*
*/
finalize() {},
};

12
assets/scripts/util/Router.js

@ -11,7 +11,8 @@ import camelCase from './camelCase';
class Router {
/**
* Create a new Router
* @param {Object} routes
*
* @param {object} routes
*/
constructor( routes ) {
this.routes = routes;
@ -19,6 +20,7 @@ class Router {
/**
* Fire Router events
*
* @param {string} route DOM-based route derived from body classes (`<body class="...">`)
* @param {string} [event] Events on the route. By default, `init` and `finalize` events are called.
* @param {string} [arg] Any custom argument to be passed to the event.
@ -37,10 +39,10 @@ class Router {
* Automatically load and fire Router events
*
* Events are fired in the following order:
* * common init
* * page-specific init
* * page-specific finalize
* * common finalize
* common init
* page-specific init
* page-specific finalize
* common finalize
*/
loadEvents() {
// Fire common init JS

3
assets/scripts/util/camelCase.js

@ -1,7 +1,8 @@
/**
* the most terrible camelizer on the internet, guaranteed!
*
* @param {string} str String that isn't camel-case, e.g., CAMeL_CaSEiS-harD
* @return {string} String converted to camel-case, e.g., camelCaseIsHard
* @returns {string} String converted to camel-case, e.g., camelCaseIsHard
*/
export default str =>
`${str.charAt( 0 ).toLowerCase()}${str

25
dist/mix-manifest.json vendored

@ -1,10 +1,19 @@
{
"/scripts/aldine.js": "/scripts/aldine.js?id=24a75fe45555163733a7",
"/styles/aldine.css": "/styles/aldine.css?id=76e97fa4ea15ad04df17",
"/styles/editor.css": "/styles/editor.css?id=c45cb52a8c16b5642bf6",
"/scripts/call-to-action.js": "/scripts/call-to-action.js?id=14b2ac09b5fc52660522",
"/scripts/catalog-admin.js": "/scripts/catalog-admin.js?id=2eac08aee521dcb38f28",
"/scripts/customizer.js": "/scripts/customizer.js?id=379b2c9a57b903659698",
"/scripts/customizer-toggle.js": "/scripts/customizer-toggle.js?id=21056ebdee6d334bd081",
"/scripts/page-section.js": "/scripts/page-section.js?id=b62a3319a10d83a36aea"
"/scripts/aldine.js": "/scripts/aldine.js?id=d1502669a08aba6476ef",
"/scripts/call-to-action.js": "/scripts/call-to-action.js?id=33370b66c7af12320fc0",
"/scripts/catalog-admin.js": "/scripts/catalog-admin.js?id=c750be8d290dd92a61a5",
"/scripts/customizer.js": "/scripts/customizer.js?id=14dca3944228dd789c27",
"/scripts/customizer-toggle.js": "/scripts/customizer-toggle.js?id=c31594589675d7c5662a",
"/scripts/page-section.js": "/scripts/page-section.js?id=19d5c30146ea1a763bcf",
"/styles/editor.css": "/styles/editor.css?id=b7c2449babe566571767",
"/styles/aldine.css": "/styles/aldine.css?id=55b4e080cb57b22723b5",
"/fonts/pressbooks-theme.woff": "/fonts/pressbooks-theme.woff?id=2a7aae81673f4707bbe7",
"/images/banner.jpg": "/images/banner.jpg?id=04a813e0b4f94ddfef19",
"/images/catalog-header.jpg": "/images/catalog-header.jpg?id=223b9f7a23985f2a72df",
"/images/header.jpg": "/images/header.jpg?id=c6712212b6aa749cf1cf",
"/images/left-arrow.svg": "/images/left-arrow.svg?id=91d479e2d001857a3ee4",
"/images/logo.svg": "/images/logo.svg?id=d71cb98d33ef823ffd27",
"/images/pb.svg": "/images/pb.svg?id=c08fb158c15a470648a7",
"/images/right-arrow.svg": "/images/right-arrow.svg?id=ee2d7230318ea54ae20b",
"/images/yt_icon_mono_dark.png": "/images/yt_icon_mono_dark.png?id=ee68b73409979a929440"
}

2
dist/scripts/aldine.js vendored

File diff suppressed because one or more lines are too long

2
dist/scripts/call-to-action.js vendored

@ -1 +1 @@
!function(t){var n={};function e(l){if(n[l])return n[l].exports;var o=n[l]={i:l,l:!1,exports:{}};return t[l].call(o.exports,o,o.exports,e),o.l=!0,o.exports}e.m=t,e.c=n,e.d=function(t,n,l){e.o(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:l})},e.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},e.t=function(t,n){if(1&n&&(t=e(t)),8&n)return t;if(4&n&&"object"==typeof t&&t&&t.__esModule)return t;var l=Object.create(null);if(e.r(l),Object.defineProperty(l,"default",{enumerable:!0,value:t}),2&n&&"string"!=typeof t)for(var o in t)e.d(l,o,function(n){return t[n]}.bind(null,o));return l},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},e.p="/",e(e.s=1)}({1:function(t,n,e){t.exports=e("2+Yl")},"2+Yl":function(t,n){tinymce.create("tinymce.plugins.aldine_call_to_action",{init:function(t,n){t.addButton("aldine_call_to_action",{title:aldine.call_to_action.title,icon:"icon dashicons-flag",onclick:function(){t.windowManager.open({title:aldine.call_to_action.title,body:[{type:"textbox",name:"text",label:aldine.call_to_action.text,value:aldine.call_to_action.title},{type:"textbox",name:"link",label:aldine.call_to_action.link,value:"#"}],onsubmit:function(n){t.insertContent('[aldine_call_to_action text="'+n.data.text+'" link="'+n.data.link+'"]')}})}})},createControl:function(t,n){return null}}),tinymce.PluginManager.add("aldine_call_to_action",tinymce.plugins.aldine_call_to_action)}});
tinymce.create("tinymce.plugins.aldine_call_to_action",{init:function(t,n){t.addButton("aldine_call_to_action",{title:aldine.call_to_action.title,icon:"icon dashicons-flag",onclick:function(){t.windowManager.open({title:aldine.call_to_action.title,body:[{type:"textbox",name:"text",label:aldine.call_to_action.text,value:aldine.call_to_action.title},{type:"textbox",name:"link",label:aldine.call_to_action.link,value:"#"}],onsubmit:function(n){t.insertContent('[aldine_call_to_action text="'+n.data.text+'" link="'+n.data.link+'"]')}})}})},createControl:function(t,n){return null}}),tinymce.PluginManager.add("aldine_call_to_action",tinymce.plugins.aldine_call_to_action);

2
dist/scripts/catalog-admin.js vendored

File diff suppressed because one or more lines are too long

2
dist/scripts/customizer-toggle.js vendored

@ -1 +1 @@
!function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/",n(n.s=4)}({4:function(e,t,n){e.exports=n("5MvR")},"5MvR":function(e,t){document.addEventListener("DOMContentLoaded",(function(){var e=document.getElementById("_customize-input-pb_network_contact_form"),t=document.getElementById("customize-control-pb_network_contact_email"),n=document.getElementById("customize-control-pb_network_contact_link"),o=document.getElementById("customize-control-pb_network_contact_form_title");function r(){!1===e.checked?(t.classList.add("hidden"),t.style.cssText=null,o.classList.add("hidden"),o.style.cssText=null,n.classList.remove("hidden"),n.style.cssText="display: list-item;"):(t.classList.remove("hidden"),t.style.cssText="display: list-item;",o.classList.remove("hidden"),o.style.cssText="display: list-item;",n.classList.add("hidden"),n.style.cssText=null)}e.addEventListener("click",r),r()}))}});
document.addEventListener("DOMContentLoaded",(function(){var t=document.getElementById("_customize-input-pb_network_contact_form"),e=document.getElementById("customize-control-pb_network_contact_email"),s=document.getElementById("customize-control-pb_network_contact_link"),n=document.getElementById("customize-control-pb_network_contact_form_title");function c(){!1===t.checked?(e.classList.add("hidden"),e.style.cssText=null,n.classList.add("hidden"),n.style.cssText=null,s.classList.remove("hidden"),s.style.cssText="display: list-item;"):(e.classList.remove("hidden"),e.style.cssText="display: list-item;",n.classList.remove("hidden"),n.style.cssText="display: list-item;",s.classList.add("hidden"),s.style.cssText=null)}t.addEventListener("click",c),c()}));

2
dist/scripts/customizer.js vendored

@ -1 +1 @@
!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/",n(n.s=3)}({3:function(e,t,n){e.exports=n("6yDc")},"6yDc":function(e,t){wp.customize("blogname",(function(e){e.bind((function(e){return document.querySelector(".home .entry-title").textContent=e}))})),wp.customize("blogdescription",(function(e){e.bind((function(e){return document.querySelector(".home .entry-description").textContent=e}))}))}});
wp.customize("blogname",(function(t){t.bind((function(t){return document.querySelector(".home .entry-title").textContent=t}))})),wp.customize("blogdescription",(function(t){t.bind((function(t){return document.querySelector(".home .entry-description").textContent=t}))}));

2
dist/scripts/page-section.js vendored

@ -1 +1 @@
!function(e){var t={};function n(i){if(t[i])return t[i].exports;var a=t[i]={i:i,l:!1,exports:{}};return e[i].call(a.exports,a,a.exports,n),a.l=!0,a.exports}n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)n.d(i,a,function(t){return e[t]}.bind(null,a));return i},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/",n(n.s=5)}({5:function(e,t,n){e.exports=n("eeN9")},eeN9:function(e,t){tinymce.create("tinymce.plugins.aldine_page_section",{init:function(e,t){e.addButton("aldine_page_section",{title:aldine.page_section.title,icon:"icon dashicons-layout",onclick:function(){e.windowManager.open({title:aldine.page_section.title,body:[{type:"textbox",name:"title",label:aldine.page_section.title_label,value:aldine.page_section.title},{type:"listbox",name:"variant",label:"Variant",values:[{text:aldine.page_section.standard,value:""},{text:aldine.page_section.accent,value:"accent"},{text:aldine.page_section.bordered,value:"bordered"},{text:aldine.page_section.borderless,value:"borderless"}],value:""}],onsubmit:function(t){e.insertContent('[aldine_page_section title="'+t.data.title+'" variant="'+t.data.variant+'"]<p>Insert your page section content here.</p>[/aldine_page_section]')}})}})},createControl:function(e,t){return null}}),tinymce.PluginManager.add("aldine_page_section",tinymce.plugins.aldine_page_section)}});
tinymce.create("tinymce.plugins.aldine_page_section",{init:function(e,t){e.addButton("aldine_page_section",{title:aldine.page_section.title,icon:"icon dashicons-layout",onclick:function(){e.windowManager.open({title:aldine.page_section.title,body:[{type:"textbox",name:"title",label:aldine.page_section.title_label,value:aldine.page_section.title},{type:"listbox",name:"variant",label:"Variant",values:[{text:aldine.page_section.standard,value:""},{text:aldine.page_section.accent,value:"accent"},{text:aldine.page_section.bordered,value:"bordered"},{text:aldine.page_section.borderless,value:"borderless"}],value:""}],onsubmit:function(t){e.insertContent('[aldine_page_section title="'+t.data.title+'" variant="'+t.data.variant+'"]<p>Insert your page section content here.</p>[/aldine_page_section]')}})}})},createControl:function(e,t){return null}}),tinymce.PluginManager.add("aldine_page_section",tinymce.plugins.aldine_page_section);

2
dist/styles/aldine.css vendored

File diff suppressed because one or more lines are too long

2
dist/styles/editor.css vendored

File diff suppressed because one or more lines are too long

20
package.json

@ -35,7 +35,17 @@
"aldine": true,
"PB_A11y": true,
"tinymce": true
}
},
"rules": {
"import/no-anonymous-default-export": ["error", {
"allowArrowFunction": true,
"allowObject": true
}],
"jsdoc/require-param-type": "off",
"jsdoc/require-returns": "off",
"jsdoc/require-param-description": "off",
"jsdoc/no-undefined-types": "off"
}
},
"eslintIgnore": [
"assets/scripts/catalog-admin.js",
@ -46,15 +56,15 @@
},
"scripts": {
"install-build-tools": "npm install --no-save pressbooks-build-tools",
"watch": "npm run production -- --watch",
"watch": "mix watch",
"prod": "npm run production",
"build:production": "npm run production",
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"production": "mix --production",
"rmdist": "rimraf dist",
"test": "npm run -s lint",
"lint": "npm run -s lint:scripts && npm run -s lint:styles",
"lint:scripts": "cross-env NODE_ENV=development node_modules/eslint/bin/eslint.js \"assets/scripts/**/*.js\"",
"lint:styles": "cross-env NODE_ENV=development node_modules/stylelint/bin/stylelint.js \"assets/styles/**/*.scss\" --syntax scss"
"lint:scripts": "eslint \"assets/scripts/**/*.js\"",
"lint:styles": "stylelint \"assets/styles/**/*.scss\" --syntax scss"
},
"engines": {
"node": ">= 10"

Loading…
Cancel
Save