2016-07-21 21:56:06 +00:00
|
|
|
/* Third Party */
|
|
|
|
|
import Vue from 'vue';
|
2016-08-02 04:20:35 +00:00
|
|
|
import VueRouter from 'vue-router';
|
|
|
|
|
|
2016-07-21 21:56:06 +00:00
|
|
|
/* Configs */
|
|
|
|
|
import './config.js';
|
2016-08-02 04:20:35 +00:00
|
|
|
import routes from './routes.js';
|
2016-08-30 15:41:16 +00:00
|
|
|
import App from './App';
|
2016-11-23 03:37:50 +00:00
|
|
|
|
|
|
|
|
import PageContent from './components/PageContent';
|
|
|
|
|
import DocsComponent from './components/DocsComponent';
|
|
|
|
|
import ExampleBox from './components/ExampleBox';
|
|
|
|
|
import ApiTable from './components/ApiTable';
|
|
|
|
|
|
2016-09-26 14:14:26 +00:00
|
|
|
import SinglePage from './components/single-page';
|
2016-09-26 14:41:51 +00:00
|
|
|
import SinglePageBanner from './components/single-page-banner';
|
2016-10-05 08:53:01 +00:00
|
|
|
import SinglePageSection from './components/single-page-section';
|
2016-09-18 17:04:02 +00:00
|
|
|
import DemoPage from './components/demo-page';
|
|
|
|
|
import DemoExample from './components/demo-example';
|
2016-10-05 08:53:01 +00:00
|
|
|
import CodeBlock from './components/code-block';
|
|
|
|
|
|
2016-08-16 02:34:05 +00:00
|
|
|
|
2016-11-23 03:37:50 +00:00
|
|
|
Vue.component('page-content', PageContent);
|
|
|
|
|
Vue.component('docs-component', DocsComponent);
|
|
|
|
|
Vue.component('example-box', ExampleBox);
|
|
|
|
|
Vue.component('api-table', ApiTable);
|
|
|
|
|
|
2016-10-05 08:53:01 +00:00
|
|
|
Vue.component('single-page', SinglePage);
|
|
|
|
|
Vue.component('single-page-banner', SinglePageBanner);
|
|
|
|
|
Vue.component('single-page-section', SinglePageSection);
|
|
|
|
|
Vue.component('demo-page', DemoPage);
|
|
|
|
|
Vue.component('demo-example', DemoExample);
|
|
|
|
|
Vue.component('code-block', CodeBlock);
|
2016-08-30 15:41:16 +00:00
|
|
|
|
|
|
|
|
Vue.use(VueRouter);
|
2016-08-02 04:20:35 +00:00
|
|
|
|
|
|
|
|
let router = new VueRouter({
|
2016-11-15 02:42:41 +00:00
|
|
|
base: '/vue-material/',
|
2016-08-30 15:41:16 +00:00
|
|
|
routes
|
2016-08-02 04:20:35 +00:00
|
|
|
});
|
2016-07-21 21:56:06 +00:00
|
|
|
|
2016-08-30 15:41:16 +00:00
|
|
|
let Docs = Vue.component('app', App);
|
2016-11-21 06:09:42 +00:00
|
|
|
let handleSectionTheme = (currentRoute) => {
|
2016-11-23 06:41:06 +00:00
|
|
|
if (currentRoute.name.indexOf('getting') >= 0) {
|
2016-09-26 04:13:27 +00:00
|
|
|
Docs.theme = 'indigo';
|
2016-11-21 06:09:42 +00:00
|
|
|
} else if (currentRoute.name.indexOf('themes') >= 0) {
|
2016-11-23 06:41:06 +00:00
|
|
|
Docs.theme = 'teal';
|
2016-11-21 06:09:42 +00:00
|
|
|
} else if (currentRoute.name.indexOf('ui-elements') >= 0) {
|
2016-10-17 06:33:00 +00:00
|
|
|
Docs.theme = 'blue-grey';
|
2016-11-21 06:09:42 +00:00
|
|
|
} else if (currentRoute.name.indexOf('changelog') >= 0) {
|
2016-09-27 03:53:25 +00:00
|
|
|
Docs.theme = 'orange';
|
2016-11-21 06:09:42 +00:00
|
|
|
} else if (currentRoute.name.indexOf('about') >= 0) {
|
2016-09-27 03:53:25 +00:00
|
|
|
Docs.theme = 'green';
|
2016-09-26 04:13:27 +00:00
|
|
|
} else {
|
|
|
|
|
Docs.theme = 'default';
|
|
|
|
|
}
|
|
|
|
|
};
|
2016-07-21 21:56:06 +00:00
|
|
|
|
2016-08-30 15:41:16 +00:00
|
|
|
Docs = new Docs({
|
|
|
|
|
el: '#app',
|
|
|
|
|
router
|
|
|
|
|
});
|
2016-08-02 04:20:35 +00:00
|
|
|
|
2016-09-26 04:13:27 +00:00
|
|
|
handleSectionTheme(router.currentRoute);
|
|
|
|
|
|
2016-11-28 01:51:13 +00:00
|
|
|
router.afterEach((to) => {
|
|
|
|
|
Vue.nextTick(() => {
|
|
|
|
|
let mainContent = document.querySelector('.main-content');
|
2016-09-09 19:59:55 +00:00
|
|
|
|
2016-11-28 01:51:13 +00:00
|
|
|
if (mainContent) {
|
|
|
|
|
mainContent.scrollTop = 0;
|
|
|
|
|
}
|
2016-09-27 03:53:25 +00:00
|
|
|
|
2016-11-28 01:51:13 +00:00
|
|
|
Docs.closeSidenav();
|
2016-11-21 06:09:42 +00:00
|
|
|
|
2016-11-28 01:51:13 +00:00
|
|
|
handleSectionTheme(to);
|
|
|
|
|
});
|
2016-08-30 15:41:16 +00:00
|
|
|
});
|