|
@@ -80,9 +80,9 @@ import { MA } from 'vuejs/api/ma-axios'
|
|
|
function checkNoVuePages () {
|
|
|
// return drupalDecoupled.sys_path != '/cart'
|
|
|
// && drupalDecoupled.sys_path.indexOf('checkout') != 1;
|
|
|
- if (drupalDecoupled.route_name.indexOf('commerce') == -1 &&
|
|
|
- drupalDecoupled.route_name.indexOf('flagging_collection') == -1 &&
|
|
|
- drupalDecoupled.route_name.indexOf('user') == -1) {
|
|
|
+ if (drupalDecoupled.route_name.indexOf('commerce') === -1 &&
|
|
|
+ drupalDecoupled.route_name.indexOf('flagging_collection') === -1 &&
|
|
|
+ drupalDecoupled.route_name.indexOf('user') === -1) {
|
|
|
return false
|
|
|
} else {
|
|
|
return true
|
|
@@ -122,7 +122,7 @@ import { MA } from 'vuejs/api/ma-axios'
|
|
|
function initVRouter () {
|
|
|
// we need this to update the title and body classes while using history nav
|
|
|
router.beforeEach((to, from, next) => {
|
|
|
- // console.log('router beforeEach to ', to);
|
|
|
+ console.log('router beforeEach to ', to)
|
|
|
// commit new title to store
|
|
|
let title = null
|
|
|
switch (to.name) {
|
|
@@ -142,7 +142,7 @@ import { MA } from 'vuejs/api/ma-axios'
|
|
|
// remove all path related body classes
|
|
|
const body_classes = document.querySelector('body').classList
|
|
|
const classes_to_rm = []
|
|
|
- for (var i = 0; i < body_classes.length; i++) {
|
|
|
+ for (let i = 0; i < body_classes.length; i++) {
|
|
|
if (body_classes[i].startsWith('path-')) {
|
|
|
classes_to_rm.push(body_classes[i])
|
|
|
}
|
|
@@ -150,26 +150,26 @@ import { MA } from 'vuejs/api/ma-axios'
|
|
|
document.querySelector('body').classList.remove(...classes_to_rm)
|
|
|
// add new path classes to body
|
|
|
const classes = []
|
|
|
- if (to.name == 'home') {
|
|
|
+ if (to.name === 'home') {
|
|
|
classes.push('path-home')
|
|
|
} else {
|
|
|
const path_parts = to.path
|
|
|
.replace(/^\//, '')
|
|
|
- // remove language relative prefix from path classes (fr, en, etc)
|
|
|
- .replace(/^\D{2,3}\//, '')
|
|
|
- .split('/')
|
|
|
- for (var i = 0; i < path_parts.length; i++) {
|
|
|
- if (i == 0) {
|
|
|
- var c = 'path-' + path_parts[i]
|
|
|
- } else if (path_parts[i] !== '') {
|
|
|
- var c = classes[i - 1] + '-' + path_parts[i]
|
|
|
+ .replace(/^\D{2,3}\//, '') // remove language relative prefix from path classes (fr, en, etc)
|
|
|
+ .split('/')
|
|
|
+ let c
|
|
|
+ for (let j = 0; j < path_parts.length; j++) {
|
|
|
+ if (j === 0) {
|
|
|
+ c = 'path-' + path_parts[j]
|
|
|
+ } else if (path_parts[j] !== '') {
|
|
|
+ c = classes[j - 1] + '-' + path_parts[j]
|
|
|
}
|
|
|
classes.push(c)
|
|
|
}
|
|
|
}
|
|
|
document.querySelector('body').classList.add(...classes)
|
|
|
|
|
|
- updateLanguageLinksBlock(to.path);
|
|
|
+ updateLanguageLinksBlock(to.path)
|
|
|
|
|
|
// close the hamburger menu
|
|
|
store.dispatch('Common/openCloseHamMenu', false)
|
|
@@ -179,32 +179,32 @@ import { MA } from 'vuejs/api/ma-axios'
|
|
|
})
|
|
|
}
|
|
|
|
|
|
- function updateLanguageLinksBlock(path){
|
|
|
+ function updateLanguageLinksBlock (path) {
|
|
|
// update block language selection
|
|
|
- console.log("updateLanguageLinksBlock, path:", path);
|
|
|
- let links = document.querySelectorAll('#block-languageswitcher a.language-link')
|
|
|
+ console.log('router beforeEach path ', path)
|
|
|
+ const links = document.querySelectorAll('#block-languageswitcher a.language-link')
|
|
|
|
|
|
- let params = {
|
|
|
+ const params = {
|
|
|
path: path
|
|
|
// XDEBUG_SESSION_START: true
|
|
|
}
|
|
|
|
|
|
- MA.post(`materio_decoupled/path_translation_links?`, params)
|
|
|
+ MA.post('materio_decoupled/path_translation_links?', params)
|
|
|
.then(({ data }) => {
|
|
|
console.log('Path translations links', data)
|
|
|
if (data.error) {
|
|
|
- console.warn("error getting translation paths", data.error);
|
|
|
+ console.warn('error getting translation paths', data.error)
|
|
|
}
|
|
|
|
|
|
links.forEach((link, i) => {
|
|
|
- console.log("language link",path , link)
|
|
|
- let hreflang = link.getAttribute('hreflang')
|
|
|
+ console.log('language link', path, link)
|
|
|
+ const hreflang = link.getAttribute('hreflang')
|
|
|
|
|
|
link.setAttribute('href', data.links[hreflang].url)
|
|
|
link.setAttribute('data-drupal-link-system-path', data.links[hreflang].sys_path)
|
|
|
|
|
|
link.innerHTML = data.links[hreflang].title
|
|
|
- });
|
|
|
+ })
|
|
|
})
|
|
|
.catch(error => {
|
|
|
console.warn('Path translations links', error)
|
|
@@ -219,9 +219,9 @@ import { MA } from 'vuejs/api/ma-axios'
|
|
|
el: '#block-sitebranding',
|
|
|
methods: {
|
|
|
onclick (event) {
|
|
|
- // console.log("Clicked on logo event", event);
|
|
|
+ // console.log('router beforeEach to ', to)
|
|
|
const href = event.target.getAttribute('href')
|
|
|
- // console.log("Clicked on logo href", href);
|
|
|
+ // console.log('router beforeEach to ', to)
|
|
|
this.$router.push(href)
|
|
|
// replaced by router.beforeEach
|
|
|
// this.$store.commit('Common/setPagetitle', null)
|
|
@@ -290,14 +290,14 @@ import { MA } from 'vuejs/api/ma-axios'
|
|
|
},
|
|
|
render: h => h(VUserBlock, { props: props })
|
|
|
}).$mount('#' + mount_point)
|
|
|
- // console.log('initVUserBlock', _v_user_block);
|
|
|
+ // console.log('router beforeEach to ', to)
|
|
|
}
|
|
|
|
|
|
function initVHeaderMenu () {
|
|
|
- // console.log('initVHeaderMenu');
|
|
|
+ // console.log('router beforeEach to ', to)
|
|
|
const id = 'block-header'
|
|
|
const $html_obj = document.querySelector('#' + id)
|
|
|
- // console.log('main-content', $main_content);
|
|
|
+ // console.log('router beforeEach to ', to)
|
|
|
const html = $html_obj.outerHTML
|
|
|
_v_header_menu = new Vue({
|
|
|
store,
|
|
@@ -307,10 +307,10 @@ import { MA } from 'vuejs/api/ma-axios'
|
|
|
}).$mount('#' + id)
|
|
|
}
|
|
|
|
|
|
- function initHamburgerMenu(){
|
|
|
+ function initHamburgerMenu () {
|
|
|
const input = document.querySelector('input#header-block-right-toggle')
|
|
|
input.addEventListener('change', (e) => {
|
|
|
- console.log("block header right toggle", e, this);
|
|
|
+ console.log('initHamburgerMenu input change ', e)
|
|
|
store.dispatch('Common/openCloseHamMenu', e.currentTarget.checked)
|
|
|
})
|
|
|
}
|
|
@@ -318,7 +318,7 @@ import { MA } from 'vuejs/api/ma-axios'
|
|
|
function initVMainContent () {
|
|
|
const id = 'main-content'
|
|
|
const $main_content = document.querySelector('#' + id)
|
|
|
- // console.log('main-content', $main_content);
|
|
|
+ // console.log('router beforeEach to ', to)
|
|
|
const main_html = $main_content.innerHTML
|
|
|
_v_main_content = new Vue({
|
|
|
store,
|
|
@@ -334,7 +334,7 @@ import { MA } from 'vuejs/api/ma-axios'
|
|
|
}
|
|
|
|
|
|
function initVSearchBlock () {
|
|
|
- // console.log('initVSearchBlock');
|
|
|
+ // console.log('router beforeEach to ', to)
|
|
|
const id = 'block-materiosapisearchblock'
|
|
|
let $search_block = document.getElementById(id)
|
|
|
let formhtml = null
|
|
@@ -360,7 +360,7 @@ import { MA } from 'vuejs/api/ma-axios'
|
|
|
}
|
|
|
function initVLeftContent () {
|
|
|
const id = 'content-left'
|
|
|
- const $leftContent = document.getElementById(id)
|
|
|
+ // const $leftContent = document.getElementById(id)
|
|
|
// in any case create the vue
|
|
|
_v_left_content = new Vue({
|
|
|
store,
|
|
@@ -371,5 +371,6 @@ import { MA } from 'vuejs/api/ma-axios'
|
|
|
init()
|
|
|
} // end MaterioTheme()
|
|
|
|
|
|
- const materiotheme = new MaterioTheme()
|
|
|
+ // const materiotheme = new MaterioTheme()
|
|
|
+ MaterioTheme()
|
|
|
})(Drupal, drupalSettings, drupalDecoupled)
|