docbrown/app/javascript/internal/controllers/article_controller.js
Ben Halpern d447d0cadf
[deploy] Update design and functionality of internal/articles (#7517)
* Update design and functionality of internal/articles

* Fix spec

* Update specs

* Fiddle with test

* Fix request spec
2020-04-26 18:27:09 -04:00

33 lines
906 B
JavaScript

import { Controller } from 'stimulus';
export default class ArticleController extends Controller {
static targets = ['featuredNumber'];
increaseFeaturedNumber() {
// Increases the article's chances of being seen
const seconds = new Date().getTime() / 1000;
this.featuredNumberTarget.value = (Math.round(seconds) + 300);
}
decreaseFeaturedNumber() {
// Decreases the article's chances of being seen
const seconds = new Date().getTime() / 1080;
this.featuredNumberTarget.value = Math.round(seconds);
}
highlightElement() {
const card = this.element.querySelector('.card-body');
card.classList.add('bg-highlighted', 'border-highlighted');
setTimeout(() => {
card.classList.remove('bg-highlighted');
}, 350);
}
get articleId() {
return parseInt(this.data.get('id'), 10);
}
set articleId(value) {
this.data.set('id', value);
}
}