docbrown/app/assets/javascripts/initializers/initializeDashboardSort.js
ludwiczakpawel c9c88c7cc1
[deploy] Dashboard updates (#8879)
* flare tag line height

* .

* .

* .

* .

* specs

* spec

* .

* init

* .

* .

* js refactor

* js

* update spec

* Fix infinite scroll

* typo

* move IF

* pro analytics link fix

* Clean up tests

* Refactor adding of html

Co-authored-by: benhalpern <bendhalpern@gmail.com>
2020-06-25 13:10:17 -04:00

25 lines
571 B
JavaScript

/* global InstantClick */
'use strict';
function selectNavigation(select, urlPrefix) {
const trigger = document.getElementById(select);
if (trigger) {
trigger.addEventListener('change', (event) => {
let url = event.target.value;
if (urlPrefix) {
url = urlPrefix + url;
}
InstantClick.preload(url);
InstantClick.display(url);
});
}
}
function initializeDashboardSort() {
selectNavigation('dashboard_sort', '/dashboard?sort=');
selectNavigation('dashboard_author');
selectNavigation('mobile_nav_dashboard');
}