Skip to content

Commit

Permalink
Merge branch 'release-2.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Levia committed Feb 5, 2019
2 parents a72839a + 5216b44 commit e378eff
Show file tree
Hide file tree
Showing 35 changed files with 780 additions and 30 deletions.
3 changes: 2 additions & 1 deletion .bowerrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"registry": "https://registry.bower.io"
"registry": "https://registry.bower.io",
"directory": "vendor/assets/bower_components"
}
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
### 2.2.0

* Link DOIs to preferred resolver (reference links)
* Add carousel with slides on the home page

### 2.1.7

* Add PAME importer to list of monthly importers
Expand Down
Binary file modified app/assets/images/social.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions app/assets/javascripts/home.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
//= require 'vue'
//= require base
//= require 'modules/home/base'
//= require 'vue/components/carousel/carousel-helpers'
//= require vue/components/carousel/Carousel
//= require vue/components/carousel/CarouselSlide
10 changes: 9 additions & 1 deletion app/assets/javascripts/modules/home/base.js.coffee
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
$(document).ready( -> )
$(document).ready( ->
new Vue({
el: '.home-parent',
components: {
'carousel': VComponents['vue/components/carousel/Carousel']
'carousel-slide': VComponents['vue/components/carousel/CarouselSlide']
}
})
)
2 changes: 1 addition & 1 deletion app/assets/javascripts/vue/components/StickyTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
methods: {
toggleTab: function () {
if (!this.isActive) {
const self = this
var self = this
window.setTimeout(function () {
self.isActive = false
Expand Down
14 changes: 7 additions & 7 deletions app/assets/javascripts/vue/components/TwitterShare.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
computed: {
twitterUrl: function () {
const quoteLimit = this.charLimit - 6 - this.twitterHandle.length - 5 // the 6 is for "" ... and 1 space // the 5 is for via and 2 spaces
var quoteLimit = this.charLimit - 6 - this.twitterHandle.length - 5 // the 6 is for "" ... and 1 space // the 5 is for via and 2 spaces
var quote = this.quote
if (quote.length > quoteLimit) {
Expand All @@ -64,7 +64,7 @@
methods: {
getPageUrl: function () {
const href = window.location.href
var href = window.location.href
this.url = href.split('#')[0]
},
Expand All @@ -74,7 +74,7 @@
},
addListeners: function () {
const that = this
var that = this
// listen for text being selected
document.addEventListener("selectionchange", function() {
Expand All @@ -88,17 +88,17 @@
document.addEventListener("mouseup", function(e) {
// get selected text
const selected = window.getSelection().toString()
var selected = window.getSelection().toString()
// remove flag
that.watchingMouseUp = false
// only update the quote and show the share box if the selected text isn't blank
// otherwise hide the twitter share pop up
if (selected.length > 0) {
const textPosition = window.getSelection().getRangeAt(0).getBoundingClientRect()
const top = window.pageYOffset + textPosition.top - 5
const left = textPosition.left + ( .5 * textPosition.width)
var textPosition = window.getSelection().getRangeAt(0).getBoundingClientRect()
var top = window.pageYOffset + textPosition.top - 5
var left = textPosition.left + ( .5 * textPosition.width)
that.isActive = true
that.styleObject.top = top + 'px'
Expand Down
277 changes: 277 additions & 0 deletions app/assets/javascripts/vue/components/carousel/Carousel.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,277 @@
<template>
<aside class="carousel" aria-labelledby="carousel-heading">

<h1 id="carousel-heading" :class="{'screen-reader': !showTitle}">{{ title }}</h1>

<h2 :class="{'screen-reader': !showSlideCount}">{{ currentSlide }} of {{ totalSlides }}</h2>

<div class="carousel__slides-container">

<ul id="carousel-slides" class="carousel__slides transition" aria-live="off" aria-atomic="true">
<template v-for="n in 3">
<slot :slidesScope="slidesScope"></slot>
</template>
</ul>

<div v-if="showArrows && hasMutlipleSlides" class="carousel__arrow-buttons">
<button aria-controls="carousel-slides" title="Previous slide" class="carousel__arrow carousel__arrow--left" @click="slideToPrevious()">
<span class="fas fa-chevron-left"></span>
</button>
<button aria-controls="carousel-slides" title="Next slide" class="carousel__arrow carousel__arrow--right" @click="slideToNext()">
<span class="fas fa-chevron-right"></span>
</button>
</div>

</div>

<div v-if="hasMutlipleSlides" class="carousel__control-bar">
<template v-if="showIndicators">
<button
v-for="slide in totalSlides"
:title="indicatorTitle(slide)"
aria-controls="carousel-slides"
:aria-pressed="isCurrentSlide(slide)"
:class="['carousel__indicator', selectedSlideClass(slide)]"
@click="changeSlide(slide)"></button>
</template>

<button :title="pauseTitle" v-if="slideIntervalLength" class="carousel__pause" @click="toggleSlideInterval">
<span :class="[pauseIconClass]"></span>
</button>
</div>

</aside>
</template>

<script>
var smallTimeout = 20
module.exports = {
name: 'carousel',
props: {
title: {
default: 'Carousel',
type: String
},
showTitle: {
default: false,
type: Boolean
},
showArrows: {
default: true,
type: Boolean
},
showCount: {
default: false,
type: Boolean
},
slideIntervalLength: {
default: 0,
type: Number
},
showAllIndicators: {
default: false,
type: Boolean
}
},
data: function () {
return {
currentSlide: 1,
totalSlides: 0,
childSlideComponents: this.$children,
slideContainer: {},
containerWidth: 0,
slideWidth: 0,
slidesScope: {},
nextSlideInterval: {},
transitioning: false,
transitionendHandler: {},
isPaused: Boolean(this.slideIntervalLength)
}
},
created: function() {
window.onresize = function () {
this.setSlideWidth()
this.initSlideContainerPosition()
}.bind(this)
},
mounted: function () {
this.initData()
this.initSlideOrders()
this.setSlideWidth()
this.initSlideContainerPosition()
this.setActiveStateOnChildren()
this.setSlideIntervalIfConfigured()
},
computed: {
hasMutlipleSlides: function () {
return this.childSlideComponents.length > 3
},
showSlideCount: function () {
return this.showCount && this.hasMutlipleSlides
},
pauseIconClass: function () {
return this.isPaused ? 'fas fa-play': 'fas fa-pause'
},
pauseTitle: function () {
return this.isPaused ? 'Resume carousel' : 'Pause carousel'
},
showIndicators: function () {
return this.showAllIndicators || this.totalSlides < 7
}
},
methods: {
selectedSlideClass: function (slide) {
return {'carousel__indicator--selected' : this.isCurrentSlide(slide)}
},
isCurrentSlide: function (slide) {
return slide === this.currentSlide
},
isCurrentSlideElement: function (slideElement) {
return slideElement.style.order == this.totalSlides
},
indicatorTitle: function (slide) {
return 'Move to slide ' + slide
},
initData: function () {
this.totalSlides = this.childSlideComponents.length / 3
this.slideContainer = this.$el.querySelector('#carousel-slides')
},
initSlideOrders: function () {
Array.prototype.forEach.call(this.childSlideComponents, function (child, index) {
child.$el.style.order = index
})
},
setSlideWidth: function () {
this.slideWidth = getWidthWithMargins(this.childSlideComponents[0].$el)
},
initSlideContainerPosition: function () {
this.slideContainer.style.left = - this.totalSlides * this.slideWidth + 'px'
},
resetSlideIntervalIfNotPaused: function () {
if (!this.isPaused) {
this.clearSlideInterval()
this.setSlideIntervalIfConfigured()
}
},
toggleSlideInterval: function () {
this.isPaused ? this.setSlideIntervalIfConfigured() : this.clearSlideInterval()
},
setSlideIntervalIfConfigured: function () {
if (this.slideIntervalLength) { this.setSlideInterval() }
},
setSlideInterval: function () {
this.nextSlideInterval = setInterval(function () {
this.slideToNext(false)
}.bind(this), this.slideIntervalLength)
this.isPaused = false
},
clearSlideInterval: function () {
clearInterval(this.nextSlideInterval)
this.isPaused = true
},
slideToNext: function (resetNextSlideInterval) {
if(resetNextSlideInterval === undefined) {resetNextSlideInterval = true}
this.changeSlide(modGreaterThanZero(this.currentSlide + 1, this.totalSlides), resetNextSlideInterval, 1)
},
slideToPrevious: function (resetNextSlideInterval) {
if(resetNextSlideInterval === undefined) {resetNextSlideInterval = true}
this.changeSlide(modGreaterThanZero(this.currentSlide - 1, this.totalSlides), resetNextSlideInterval, -1)
},
changeSlide: function (slide, resetNextSlideInterval, forceDirection) {
if(resetNextSlideInterval === undefined) {resetNextSlideInterval = true}
if(forceDirection === undefined) {forceDirection = 0}
if (this.transitioning || slide === this.currentSlide) { return }
if (resetNextSlideInterval) { this.resetSlideIntervalIfNotPaused() }
this.slideBy(getChangeInIndex(slide, this.currentSlide, this.totalSlides, forceDirection))
this.currentSlide = slide
},
slideBy: function (changeInIndex) {
this.transitioning = true
this.moveSlideContainer(changeInIndex)
this.replaceTransitionendHandler(changeInIndex)
},
moveSlideContainer: function (changeInIndex) {
this.slideContainer.style.transform = 'translateX('+ (- changeInIndex * this.slideWidth) + 'px)'
},
replaceTransitionendHandler: function (changeInIndex) {
this.slideContainer.removeEventListener('transitionend', this.transitionendHandler)
this.transitionendHandler = this.getOnTransitionEndHandler(changeInIndex)
this.slideContainer.addEventListener('transitionend', this.transitionendHandler)
},
getOnTransitionEndHandler: function (changeInIndex) {
return function () {
this.invisiblyRepositionSlides(changeInIndex)
this.setActiveStateOnChildren()
setTimeout(function () { this.transitioning = false }.bind(this), smallTimeout)
}.bind(this)
},
invisiblyRepositionSlides: function (changeInIndex) {
this.reorderSlides(changeInIndex)
this.resetSlideContainerPosition()
},
resetSlideContainerPosition: function () {
this.brieflyRemoveTransition(this.slideContainer)
this.slideContainer.style.transform = 'none'
},
brieflyRemoveTransition: function (el) {
el.classList.remove('transition')
setTimeout(function () {
el.classList.add('transition')
}, smallTimeout)
},
reorderSlides: function (changeInIndex) {
Array.prototype.forEach.call(this.childSlideComponents, function (child) {
child.$el.style.order = getNewOrder(child.$el.style.order, changeInIndex, this.totalSlides)
}.bind(this))
},
setActiveStateOnChildren: function () {
Array.prototype.forEach.call(this.childSlideComponents, function (child) {
child.isActive = this.isCurrentSlideElement(child.$el)
}.bind(this))
}
}
}
</script>
Loading

0 comments on commit e378eff

Please sign in to comment.