forked from rc/aircox
		
	work on website; fix stuffs on aircox too
This commit is contained in:
		
							
								
								
									
										11
									
								
								aircox_web/assets/vue/index.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								aircox_web/assets/vue/index.js
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,11 @@
 | 
			
		||||
import Vue from 'vue';
 | 
			
		||||
 | 
			
		||||
import Tab from './tab.vue';
 | 
			
		||||
import Tabs from './tabs.vue';
 | 
			
		||||
 | 
			
		||||
Vue.component('a-tab', Tab);
 | 
			
		||||
Vue.component('a-tabs', Tabs);
 | 
			
		||||
 | 
			
		||||
export {Tab, Tabs};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										31
									
								
								aircox_web/assets/vue/tab.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								aircox_web/assets/vue/tab.vue
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,31 @@
 | 
			
		||||
<template>
 | 
			
		||||
    <li @click.prevent="onclick"
 | 
			
		||||
        :class="{'is-active': $parent.value == value}">
 | 
			
		||||
        <slot></slot>
 | 
			
		||||
    </li>
 | 
			
		||||
</template>
 | 
			
		||||
 | 
			
		||||
<script>
 | 
			
		||||
export default {
 | 
			
		||||
    props: {
 | 
			
		||||
        value: { default: undefined },
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    methods: {
 | 
			
		||||
        select() {
 | 
			
		||||
            this.$parent.selectTab(this);
 | 
			
		||||
        },
 | 
			
		||||
 | 
			
		||||
        onclick(event) {
 | 
			
		||||
            this.select();
 | 
			
		||||
            /*if(event.target.href != document.location)
 | 
			
		||||
                window.history.pushState(
 | 
			
		||||
                    { url: event.target.href },
 | 
			
		||||
                    event.target.innerText + ' - ' + document.title,
 | 
			
		||||
                    event.target.href
 | 
			
		||||
                ) */
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
</script>
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										45
									
								
								aircox_web/assets/vue/tabs.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								aircox_web/assets/vue/tabs.vue
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,45 @@
 | 
			
		||||
<template>
 | 
			
		||||
    <div>
 | 
			
		||||
        <div class="tabs is-centered">
 | 
			
		||||
            <ul><slot name="tabs" :value="value" /></ul>
 | 
			
		||||
        </div>
 | 
			
		||||
 | 
			
		||||
        <slot :value="value"/>
 | 
			
		||||
    </div>
 | 
			
		||||
</template>
 | 
			
		||||
 | 
			
		||||
<script>
 | 
			
		||||
export default {
 | 
			
		||||
    props: {
 | 
			
		||||
        default: { default: null },
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    data() {
 | 
			
		||||
        return {
 | 
			
		||||
            value: this.default,
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    computed: {
 | 
			
		||||
        tab() {
 | 
			
		||||
            const vnode = this.$slots.default && this.$slots.default.find(
 | 
			
		||||
                elm => elm.child && elm.child.value == this.value
 | 
			
		||||
            );
 | 
			
		||||
            return vnode && vnode.child;
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    methods: {
 | 
			
		||||
        selectTab(tab) {
 | 
			
		||||
            const value = tab.value;
 | 
			
		||||
            if(this.value === value)
 | 
			
		||||
                return;
 | 
			
		||||
 | 
			
		||||
            this.value = value;
 | 
			
		||||
            this.$emit('select', {target: this, value: value, tab: tab});
 | 
			
		||||
        },
 | 
			
		||||
    },
 | 
			
		||||
}
 | 
			
		||||
</script>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user