Browse Source

Update scripts. Goodbye, Slick.

pull/13/head
Ned Zimmerman 7 years ago
parent
commit
90bce3b69b
No known key found for this signature in database
GPG Key ID: FF56334A013120CA
  1. 1
      package.json
  2. 7
      resources/assets/scripts/main.js
  3. 5
      resources/assets/scripts/routes/about.js
  4. 7
      resources/assets/scripts/routes/catalog.js
  5. 58
      resources/assets/scripts/routes/home.js
  6. 13
      resources/assets/styles/layouts/_pages.scss
  7. 8
      yarn.lock

1
package.json

@ -128,7 +128,6 @@
},
"dependencies": {
"jquery": "1.12.4 - 3",
"slick-carousel": "^1.7.1",
"tachyons-sass": "~4.7",
"wpapi": "^1.1.2"
}

7
resources/assets/scripts/main.js

@ -1,12 +1,11 @@
// import external dependencies
import 'jquery';
import 'slick-carousel';
// import local dependencies
import Router from './util/Router';
import common from './routes/common';
import home from './routes/home';
import aboutUs from './routes/about';
import catalog from './routes/catalog';
/** Populate Router instance with DOM routes */
const routes = new Router({
@ -14,8 +13,8 @@ const routes = new Router({
common,
// Home page
home,
// About Us page, note the change from about-us to aboutUs.
aboutUs,
// Catalog page
catalog,
});
// Load Events

5
resources/assets/scripts/routes/about.js

@ -1,5 +0,0 @@
export default {
init() {
// JavaScript to be fired on the about us page
},
};

7
resources/assets/scripts/routes/catalog.js

@ -0,0 +1,7 @@
export default {
init() {
// JavaScript to be fired on the catalog page
},
finalize() {
},
};

58
resources/assets/scripts/routes/home.js

@ -1,64 +1,6 @@
const WPAPI = require( 'wpapi' );
export default {
init() {
// JavaScript to be fired on the home page
// let books = $('.books');
let pb = new WPAPI({ endpoint: 'http://pressbooks.dev/wp-json' });
pb.books = pb.registerRoute( 'pressbooks/v2', '/books/' );
/* function loadNextPage() {
let nextpage = books.attr('data-next-page');
if (typeof nextpage !== typeof undefined && nextpage !== false) {
const total = parseInt($('.books').attr('data-total-pages'));
const page = parseInt($('.books').attr('data-next-page'));
pb.books().perPage(3).page(page).then(function(data) {
data.forEach((book) => {
books.slick('slickAdd', `<div class="book w-100 bg-secondary b--secondary">
<p class="subject tc ma0"><a href="">Fiction</a></p>
<p class="title tc ma0"><a href="${book.link}">${book.metadata.name}</a></p>
<p class="read-more tl ma0"><a href="${book.link}">About this book &rarr;</a></p>
</div>`); // TODO Localize
});
if (page < total) {
books.attr('data-next-page', page + 1);
} else {
books.removeAttr('data-next-page');
}
}).catch(function(err) { // TODO handle error
console.error(err); // eslint-disable-line
});
}
} */
/* books.on('init', () => {
loadNextPage();
})
books.slick({
slidesToShow: 1,
slidesToScroll: 1,
infinite: false,
mobileFirst: true,
prevArrow: '.latest-books .navigation .previous',
nextArrow: '.latest-books .navigation .next',
responsive: [
{
breakpoint: 960,
settings: {
slidesToShow: 3,
slidesToScroll: 3,
},
},
],
variableWidth: true,
});
books.on('afterChange', (slick, currentSlide) => {
if((parseInt($('.slick-active:last').attr('data-slick-index')) + 1) === currentSlide.slideCount) {
loadNextPage(true);
}
}); */
},
finalize() {
},

13
resources/assets/styles/layouts/_pages.scss

@ -61,6 +61,19 @@
}
}
.blocks.blocks-2 .widget_text:nth-child(2),
.blocks.blocks-3 .widget_text:nth-child(2),
.blocks.blocks-4 .widget_text:nth-child(3) {
&::after {
content: "";
display: block;
width: 100vw;
height: rem(444);
background: green;
position: absolute;
}
}
.block,
.latest-books {
h3 {

8
yarn.lock

@ -3221,7 +3221,7 @@ jpegtran-bin@^3.0.0:
bin-wrapper "^3.0.0"
logalot "^2.0.0"
"jquery@1.12.4 - 3", jquery@>=1.7.2:
"jquery@1.12.4 - 3":
version "3.2.1"
resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.2.1.tgz#5c4d9de652af6cd0a770154a631bba12b015c787"
@ -5608,12 +5608,6 @@ slice-ansi@0.0.4:
version "0.0.4"
resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-0.0.4.tgz#edbf8903f66f7ce2f8eafd6ceed65e264c831b35"
slick-carousel@^1.7.1:
version "1.7.1"
resolved "https://registry.yarnpkg.com/slick-carousel/-/slick-carousel-1.7.1.tgz#51f5489bbb52212542ccbe9f42689f818bd29ed2"
dependencies:
jquery ">=1.7.2"
sntp@1.x.x:
version "1.0.9"
resolved "https://registry.yarnpkg.com/sntp/-/sntp-1.0.9.tgz#6541184cc90aeea6c6e7b35e2659082443c66198"

Loading…
Cancel
Save