2019-04-09 00:21:00 +02:00
|
|
|
import Vue from 'vue'
|
|
|
|
import store from 'vuejs/store'
|
2019-04-10 10:47:45 +02:00
|
|
|
import VUserBlock from 'vuejs/components/User/UserBlock'
|
2019-05-23 18:11:06 +02:00
|
|
|
import VMainContent from 'vuejs/components/Content/MainContent'
|
2019-04-11 00:12:23 +02:00
|
|
|
|
|
|
|
import { mapState } from 'vuex'
|
2019-03-25 18:27:56 +01:00
|
|
|
|
2019-04-09 00:21:00 +02:00
|
|
|
// require('theme/assets/styles/main.scss');
|
|
|
|
import 'theme/assets/styles/main.scss'
|
|
|
|
|
|
|
|
(function(Drupal, drupalSettings) {
|
|
|
|
|
|
|
|
var MaterioTheme = function(){
|
2019-04-11 00:12:23 +02:00
|
|
|
|
2019-05-23 18:11:06 +02:00
|
|
|
var v_user_block, v_main_content;
|
2019-03-25 18:27:56 +01:00
|
|
|
// var _is_front = drupalSettings.path.isFront;
|
|
|
|
|
2019-04-11 00:12:23 +02:00
|
|
|
|
|
|
|
console.log('drupalSettings', drupalSettings);
|
|
|
|
|
2019-03-25 18:27:56 +01:00
|
|
|
// ___ _ _
|
|
|
|
// |_ _|_ _ (_) |_
|
|
|
|
// | || ' \| | _|
|
|
|
|
// |___|_||_|_|\__|
|
|
|
|
function init(){
|
2019-04-11 00:12:23 +02:00
|
|
|
console.log("MaterioTheme init()")
|
|
|
|
initVues()
|
|
|
|
}
|
|
|
|
|
|
|
|
function initVues(){
|
|
|
|
initUserVBlock()
|
2019-05-23 18:11:06 +02:00
|
|
|
initVMainContent()
|
2019-04-11 00:12:23 +02:00
|
|
|
}
|
2019-03-25 18:27:56 +01:00
|
|
|
|
2019-04-11 00:12:23 +02:00
|
|
|
function initUserVBlock(){
|
2019-05-23 17:52:46 +02:00
|
|
|
let mount_point = drupalSettings.user.uid !== 0 ? '#block-userblock' : '#block-userlogin';
|
2019-05-21 14:56:34 +02:00
|
|
|
let props = {
|
|
|
|
title: ""
|
|
|
|
};
|
|
|
|
switch (mount_point) {
|
|
|
|
case '#block-userlogin':
|
|
|
|
let $block = document.querySelector(mount_point);
|
|
|
|
props = {
|
|
|
|
title: $block.querySelector('h2').textContent,
|
|
|
|
form: {
|
|
|
|
ph_email: $block.querySelector('input#edit-name').getAttribute('placeholder'),
|
|
|
|
ph_pass: $block.querySelector('input#edit-pass').getAttribute('placeholder'),
|
|
|
|
btn_value: $block.querySelector('input#edit-submit').getAttribute('value'),
|
|
|
|
register: {
|
|
|
|
title: $block.querySelector('a.create-account-link').textContent,
|
|
|
|
href: $block.querySelector('a.create-account-link').getAttribute('href')
|
|
|
|
},
|
|
|
|
reset: {
|
|
|
|
title: $block.querySelector('a.request-password-link').textContent,
|
|
|
|
href: $block.querySelector('a.request-password-link').getAttribute('href')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case '#block-userblock':
|
|
|
|
default:
|
2019-05-23 17:52:46 +02:00
|
|
|
break;
|
2019-05-21 14:56:34 +02:00
|
|
|
}
|
2019-05-23 17:52:46 +02:00
|
|
|
// console.log(props);
|
|
|
|
|
2019-04-11 00:12:23 +02:00
|
|
|
v_user_block = new Vue({
|
|
|
|
store,
|
|
|
|
computed: {
|
|
|
|
...mapState({
|
|
|
|
isloggedin: state => state.User.isloggedin
|
|
|
|
})
|
|
|
|
},
|
|
|
|
created () {
|
|
|
|
if(drupalSettings.user.uid !== 0){
|
|
|
|
this.$store.commit('User/setUid', drupalSettings.user.uid)
|
|
|
|
this.$store.dispatch('User/getUser')
|
|
|
|
}
|
|
|
|
},
|
2019-05-21 14:56:34 +02:00
|
|
|
render: h => h(VUserBlock, {props:props})
|
2019-04-11 00:12:23 +02:00
|
|
|
}).$mount(mount_point)
|
2019-05-21 14:56:34 +02:00
|
|
|
console.log('initUserVBlock', v_user_block);
|
2019-04-11 00:12:23 +02:00
|
|
|
}
|
2019-03-25 18:27:56 +01:00
|
|
|
|
2019-05-23 18:11:06 +02:00
|
|
|
function initVMainContent(){
|
|
|
|
let $main_content = document.querySelector('#main-content')
|
|
|
|
console.log('main-content', $main_content);
|
|
|
|
let main_html = $main_content.innerHTML
|
|
|
|
v_main_content = new Vue({
|
2019-04-11 00:12:23 +02:00
|
|
|
store,
|
2019-05-23 18:11:06 +02:00
|
|
|
render: h => h(VMainContent, {props:{html:main_html}})
|
|
|
|
}).$mount('#main-content')
|
2019-05-21 14:56:34 +02:00
|
|
|
// console.log('initTestVContent', v_test_content);
|
2019-04-11 00:12:23 +02:00
|
|
|
}
|
2019-03-25 18:27:56 +01:00
|
|
|
|
2019-04-11 00:12:23 +02:00
|
|
|
init()
|
2019-03-25 18:27:56 +01:00
|
|
|
} // end MaterioTheme()
|
|
|
|
|
2019-04-11 00:12:23 +02:00
|
|
|
var materiotheme = new MaterioTheme();
|
2019-03-25 18:27:56 +01:00
|
|
|
|
2019-04-09 00:21:00 +02:00
|
|
|
})(Drupal, drupalSettings);
|