2018-06-05 14:36:21 +02:00
|
|
|
<template>
|
2018-06-08 01:38:32 +02:00
|
|
|
<div class="dnpfarvgbnfmyzbdquhhzyxcmstpdqzs" :class="{ naked, narrow, active, isStacked, draghover, dragging }">
|
|
|
|
<header :class="{ indicate: count > 0 }"
|
|
|
|
draggable="true"
|
|
|
|
@click="toggleActive"
|
|
|
|
@dragstart="onDragstart"
|
|
|
|
@dragend="onDragend"
|
|
|
|
@dragover.prevent.stop="onDragover"
|
|
|
|
@dragenter.prevent="onDragenter"
|
|
|
|
@dragleave="onDragleave"
|
|
|
|
@drop.prevent.stop="onDrop"
|
|
|
|
>
|
2018-06-05 15:54:03 +02:00
|
|
|
<slot name="header"></slot>
|
2018-06-07 22:04:21 +02:00
|
|
|
<span class="count" v-if="count > 0">({{ count }})</span>
|
2018-06-07 21:21:06 +02:00
|
|
|
<button ref="menu" @click.stop="showMenu">%fa:caret-down%</button>
|
2018-06-05 14:36:21 +02:00
|
|
|
</header>
|
2018-06-07 22:48:27 +02:00
|
|
|
<div ref="body" v-show="active">
|
2018-06-05 15:54:03 +02:00
|
|
|
<slot></slot>
|
2018-06-05 14:36:21 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
2018-06-05 22:18:08 +02:00
|
|
|
import Menu from '../../../../common/views/components/menu.vue';
|
2018-06-05 14:36:21 +02:00
|
|
|
|
|
|
|
export default Vue.extend({
|
2018-06-05 22:18:08 +02:00
|
|
|
props: {
|
2018-06-07 22:48:27 +02:00
|
|
|
column: {
|
|
|
|
type: Object,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
isStacked: {
|
|
|
|
type: Boolean,
|
|
|
|
required: true
|
|
|
|
},
|
2018-06-06 23:13:57 +02:00
|
|
|
name: {
|
|
|
|
type: String,
|
|
|
|
required: false
|
|
|
|
},
|
2018-06-06 12:22:45 +02:00
|
|
|
menu: {
|
|
|
|
type: Array,
|
2018-06-07 21:21:06 +02:00
|
|
|
required: false,
|
|
|
|
default: null
|
2018-06-06 12:22:45 +02:00
|
|
|
},
|
|
|
|
naked: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false
|
|
|
|
},
|
|
|
|
narrow: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false
|
2018-06-05 22:18:08 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2018-06-07 21:21:06 +02:00
|
|
|
inject: {
|
|
|
|
getColumnVm: { from: 'getColumnVm' }
|
|
|
|
},
|
|
|
|
|
2018-06-05 18:54:24 +02:00
|
|
|
data() {
|
|
|
|
return {
|
2018-06-07 22:04:21 +02:00
|
|
|
count: 0,
|
2018-06-08 01:38:32 +02:00
|
|
|
active: true,
|
|
|
|
dragging: false,
|
|
|
|
draghover: false
|
2018-06-05 18:54:24 +02:00
|
|
|
};
|
2018-06-05 14:36:21 +02:00
|
|
|
},
|
2018-06-05 18:54:24 +02:00
|
|
|
|
2018-06-07 22:04:21 +02:00
|
|
|
watch: {
|
2018-06-07 22:48:27 +02:00
|
|
|
active(v) {
|
2018-06-07 22:04:21 +02:00
|
|
|
if (v && this.isScrollTop()) {
|
|
|
|
this.$emit('top');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2018-06-05 15:54:03 +02:00
|
|
|
provide() {
|
|
|
|
return {
|
2018-06-05 18:54:24 +02:00
|
|
|
column: this,
|
|
|
|
isScrollTop: this.isScrollTop,
|
2018-06-07 22:04:21 +02:00
|
|
|
count: v => this.count = v
|
2018-06-05 15:54:03 +02:00
|
|
|
};
|
|
|
|
},
|
2018-06-05 18:54:24 +02:00
|
|
|
|
2018-06-05 14:36:21 +02:00
|
|
|
mounted() {
|
2018-06-06 18:52:03 +02:00
|
|
|
this.$refs.body.addEventListener('scroll', this.onScroll, { passive: true });
|
2018-06-05 18:54:24 +02:00
|
|
|
},
|
|
|
|
beforeDestroy() {
|
|
|
|
this.$refs.body.removeEventListener('scroll', this.onScroll);
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
2018-06-07 21:21:06 +02:00
|
|
|
toggleActive() {
|
|
|
|
if (!this.isStacked) return;
|
|
|
|
const vms = this.$store.state.settings.deck.layout.find(ids => ids.indexOf(this.column.id) != -1).map(id => this.getColumnVm(id));
|
2018-06-07 22:48:27 +02:00
|
|
|
if (this.active && vms.filter(vm => vm.$el.classList.contains('active')).length == 1) return;
|
|
|
|
this.active = !this.active;
|
2018-06-07 21:21:06 +02:00
|
|
|
},
|
|
|
|
|
2018-06-05 18:54:24 +02:00
|
|
|
isScrollTop() {
|
2018-06-07 22:48:27 +02:00
|
|
|
return this.active && this.$refs.body.scrollTop == 0;
|
2018-06-05 18:54:24 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
onScroll() {
|
|
|
|
if (this.isScrollTop()) {
|
|
|
|
this.$emit('top');
|
|
|
|
}
|
2018-06-05 15:54:03 +02:00
|
|
|
|
2018-06-05 18:54:24 +02:00
|
|
|
if (this.$store.state.settings.fetchOnScroll !== false) {
|
|
|
|
const current = this.$refs.body.scrollTop + this.$refs.body.clientHeight;
|
|
|
|
if (current > this.$refs.body.scrollHeight - 1) this.$emit('bottom');
|
|
|
|
}
|
2018-06-05 22:18:08 +02:00
|
|
|
},
|
|
|
|
|
2018-06-06 12:22:45 +02:00
|
|
|
showMenu() {
|
|
|
|
const items = [{
|
2018-06-06 23:13:57 +02:00
|
|
|
content: '%fa:pencil-alt% %i18n:common.deck.rename%',
|
|
|
|
onClick: () => {
|
|
|
|
(this as any).apis.input({
|
|
|
|
title: '%i18n:common.deck.rename%',
|
|
|
|
default: this.name,
|
|
|
|
allowEmpty: false
|
|
|
|
}).then(name => {
|
2018-06-07 21:21:06 +02:00
|
|
|
this.$store.dispatch('settings/renameDeckColumn', { id: this.column.id, name });
|
2018-06-06 23:13:57 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}, null, {
|
2018-06-06 18:17:29 +02:00
|
|
|
content: '%fa:arrow-left% %i18n:common.deck.swap-left%',
|
2018-06-06 12:22:45 +02:00
|
|
|
onClick: () => {
|
2018-06-07 21:21:06 +02:00
|
|
|
this.$store.dispatch('settings/swapLeftDeckColumn', this.column.id);
|
2018-06-06 12:22:45 +02:00
|
|
|
}
|
|
|
|
}, {
|
2018-06-06 18:17:29 +02:00
|
|
|
content: '%fa:arrow-right% %i18n:common.deck.swap-right%',
|
2018-06-06 12:22:45 +02:00
|
|
|
onClick: () => {
|
2018-06-07 21:21:06 +02:00
|
|
|
this.$store.dispatch('settings/swapRightDeckColumn', this.column.id);
|
|
|
|
}
|
2018-06-07 21:34:15 +02:00
|
|
|
}, this.isStacked ? {
|
|
|
|
content: '%fa:arrow-up% %i18n:common.deck.swap-up%',
|
|
|
|
onClick: () => {
|
|
|
|
this.$store.dispatch('settings/swapUpDeckColumn', this.column.id);
|
|
|
|
}
|
|
|
|
} : undefined, this.isStacked ? {
|
|
|
|
content: '%fa:arrow-down% %i18n:common.deck.swap-down%',
|
|
|
|
onClick: () => {
|
|
|
|
this.$store.dispatch('settings/swapDownDeckColumn', this.column.id);
|
|
|
|
}
|
|
|
|
} : undefined, null, {
|
2018-06-07 21:21:06 +02:00
|
|
|
content: '%fa:window-restore R% %i18n:common.deck.stack-left%',
|
|
|
|
onClick: () => {
|
|
|
|
this.$store.dispatch('settings/stackLeftDeckColumn', this.column.id);
|
|
|
|
}
|
2018-06-07 21:34:15 +02:00
|
|
|
}, this.isStacked ? {
|
2018-06-07 21:46:31 +02:00
|
|
|
content: '%fa:window-maximize R% %i18n:common.deck.pop-right%',
|
2018-06-07 21:21:06 +02:00
|
|
|
onClick: () => {
|
|
|
|
this.$store.dispatch('settings/popRightDeckColumn', this.column.id);
|
2018-06-06 12:22:45 +02:00
|
|
|
}
|
2018-06-07 21:34:15 +02:00
|
|
|
} : undefined, null, {
|
2018-06-06 18:17:29 +02:00
|
|
|
content: '%fa:trash-alt R% %i18n:common.deck.remove%',
|
2018-06-06 12:22:45 +02:00
|
|
|
onClick: () => {
|
2018-06-07 21:21:06 +02:00
|
|
|
this.$store.dispatch('settings/removeDeckColumn', this.column.id);
|
2018-06-06 12:22:45 +02:00
|
|
|
}
|
|
|
|
}];
|
|
|
|
|
|
|
|
if (this.menu) {
|
|
|
|
items.unshift(null);
|
|
|
|
this.menu.reverse().forEach(i => items.unshift(i));
|
|
|
|
}
|
|
|
|
|
2018-06-05 22:18:08 +02:00
|
|
|
this.os.new(Menu, {
|
|
|
|
source: this.$refs.menu,
|
|
|
|
compact: false,
|
2018-06-06 12:22:45 +02:00
|
|
|
items
|
2018-06-05 22:18:08 +02:00
|
|
|
});
|
2018-06-08 01:38:32 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
onDragstart(e) {
|
|
|
|
e.dataTransfer.effectAllowed = 'move';
|
|
|
|
e.dataTransfer.setData('mk-deck-column', this.column.id);
|
|
|
|
this.dragging = true;
|
|
|
|
},
|
|
|
|
|
|
|
|
onDragend(e) {
|
|
|
|
this.dragging = false;
|
|
|
|
},
|
|
|
|
|
|
|
|
onDragover(e) {
|
|
|
|
// 自分自身がドラッグされている場合
|
|
|
|
if (this.dragging) {
|
|
|
|
// 自分自身にはドロップさせない
|
|
|
|
e.dataTransfer.dropEffect = 'none';
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const isDeckColumn = e.dataTransfer.types[0] == 'mk-deck-column';
|
|
|
|
|
|
|
|
e.dataTransfer.dropEffect = isDeckColumn ? 'move' : 'none';
|
|
|
|
},
|
|
|
|
|
|
|
|
onDragenter() {
|
|
|
|
if (!this.dragging) this.draghover = true;
|
|
|
|
},
|
|
|
|
|
|
|
|
onDragleave() {
|
|
|
|
this.draghover = false;
|
|
|
|
},
|
|
|
|
|
|
|
|
onDrop(e) {
|
|
|
|
this.draghover = false;
|
|
|
|
|
|
|
|
const id = e.dataTransfer.getData('mk-deck-column');
|
|
|
|
if (id != null && id != '') {
|
|
|
|
this.$store.dispatch('settings/swapDeckColumn', {
|
|
|
|
a: this.column.id,
|
|
|
|
b: id
|
|
|
|
});
|
|
|
|
}
|
2018-06-05 18:54:24 +02:00
|
|
|
}
|
2018-06-05 14:36:21 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="stylus" scoped>
|
|
|
|
@import '~const.styl'
|
|
|
|
|
|
|
|
root(isDark)
|
2018-06-05 22:18:08 +02:00
|
|
|
$header-height = 42px
|
|
|
|
|
2018-06-07 01:41:58 +02:00
|
|
|
width 330px
|
2018-06-07 21:21:06 +02:00
|
|
|
min-width 330px
|
2018-06-05 14:36:21 +02:00
|
|
|
height 100%
|
|
|
|
background isDark ? #282C37 : #fff
|
|
|
|
border-radius 6px
|
|
|
|
box-shadow 0 2px 16px rgba(#000, 0.1)
|
|
|
|
overflow hidden
|
|
|
|
|
2018-06-08 01:38:32 +02:00
|
|
|
&.draghover
|
|
|
|
&.dragging
|
|
|
|
box-shadow 0 0 0 2px rgba($theme-color, 0.7)
|
|
|
|
|
2018-06-07 22:48:27 +02:00
|
|
|
&:not(.active)
|
2018-06-07 21:21:06 +02:00
|
|
|
flex-basis $header-height
|
|
|
|
min-height $header-height
|
|
|
|
|
|
|
|
&:not(.isStacked).narrow
|
2018-06-07 01:41:58 +02:00
|
|
|
width 285px
|
2018-06-07 21:21:06 +02:00
|
|
|
min-width 285px
|
2018-06-06 12:22:45 +02:00
|
|
|
|
|
|
|
&.naked
|
|
|
|
background rgba(#000, isDark ? 0.25 : 0.1)
|
|
|
|
|
|
|
|
> header
|
|
|
|
background transparent
|
|
|
|
box-shadow none
|
|
|
|
|
|
|
|
if !isDark
|
|
|
|
> button
|
|
|
|
color #bbb
|
|
|
|
|
2018-06-05 14:36:21 +02:00
|
|
|
> header
|
|
|
|
z-index 1
|
2018-06-05 22:18:08 +02:00
|
|
|
line-height $header-height
|
2018-06-05 14:36:21 +02:00
|
|
|
padding 0 16px
|
2018-06-06 22:14:37 +02:00
|
|
|
font-size 14px
|
2018-06-05 14:36:21 +02:00
|
|
|
color isDark ? #e3e5e8 : #888
|
|
|
|
background isDark ? #313543 : #fff
|
|
|
|
box-shadow 0 1px rgba(#000, 0.15)
|
2018-06-08 01:05:25 +02:00
|
|
|
cursor pointer
|
2018-06-05 14:36:21 +02:00
|
|
|
|
2018-06-07 21:21:06 +02:00
|
|
|
&, *
|
|
|
|
user-select none
|
|
|
|
|
2018-06-08 01:38:32 +02:00
|
|
|
*:not(button)
|
|
|
|
pointer-events none
|
|
|
|
|
2018-06-05 18:54:24 +02:00
|
|
|
&.indicate
|
|
|
|
box-shadow 0 3px 0 0 $theme-color
|
|
|
|
|
2018-06-05 22:18:08 +02:00
|
|
|
> span
|
|
|
|
[data-fa]
|
|
|
|
margin-right 8px
|
|
|
|
|
2018-06-07 22:04:21 +02:00
|
|
|
> .count
|
|
|
|
margin-left 4px
|
|
|
|
opacity 0.5
|
|
|
|
|
2018-06-05 22:18:08 +02:00
|
|
|
> button
|
|
|
|
position absolute
|
|
|
|
top 0
|
|
|
|
right 0
|
|
|
|
width $header-height
|
|
|
|
line-height $header-height
|
2018-06-08 01:05:25 +02:00
|
|
|
font-size 16px
|
2018-06-05 22:18:08 +02:00
|
|
|
color isDark ? #9baec8 : #ccc
|
|
|
|
|
|
|
|
&:hover
|
|
|
|
color isDark ? #b2c1d5 : #aaa
|
|
|
|
|
|
|
|
&:active
|
|
|
|
color isDark ? #b2c1d5 : #999
|
|
|
|
|
2018-06-05 14:36:21 +02:00
|
|
|
> div
|
2018-06-05 22:29:31 +02:00
|
|
|
height "calc(100% - %s)" % $header-height
|
2018-06-05 14:36:21 +02:00
|
|
|
overflow auto
|
2018-06-05 14:44:02 +02:00
|
|
|
overflow-x hidden
|
2018-06-05 14:36:21 +02:00
|
|
|
|
|
|
|
.dnpfarvgbnfmyzbdquhhzyxcmstpdqzs[data-darkmode]
|
|
|
|
root(true)
|
|
|
|
|
|
|
|
.dnpfarvgbnfmyzbdquhhzyxcmstpdqzs:not([data-darkmode])
|
|
|
|
root(false)
|
|
|
|
|
|
|
|
</style>
|