Consistency, add settings component, trigger ready

This commit is contained in:
Jiiks 2018-01-29 20:15:58 +02:00
parent ca5467addb
commit 5cdd9948e8
7 changed files with 89 additions and 17 deletions

View File

@ -1,8 +1,8 @@
/**
* BetterDiscord Client Core
* Copyright (c) 2015-present JsSucks - https://github.com/JsSucks
* Copyright (c) 2015-present Jiiks/JsSucks - https://github.com/Jiiks / https://github.com/JsSucks
* All rights reserved.
* https://github.com/JsSucks - https://betterdiscord.net
* https://betterdiscord.net
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
@ -16,6 +16,7 @@ class BetterDiscord {
constructor() {
DOM.injectStyle(BdCss, 'bdmain');
Events.on('global-ready', this.globalReady.bind(this));
Events.emit('global-ready'); // Emit for now
}
globalReady() {
@ -28,4 +29,4 @@ if (window.BetterDiscord) {
} else {
let bdInstance = new BetterDiscord();
window.BetterDiscord = { 'vendor': Vendor };
}
}

View File

@ -1,11 +1,11 @@
/**
* BetterDiscord Events Module
* Copyright (c) 2015-present JsSucks - https://github.com/JsSucks
* Copyright (c) 2015-present Jiiks/JsSucks - https://github.com/Jiiks / https://github.com/JsSucks
* All rights reserved.
* https://github.com/JsSucks - https://betterdiscord.net
* https://betterdiscord.net
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
* LICENSE file in the root directory of this source tree.
*/
import { EventEmitter } from 'events';
@ -23,4 +23,4 @@ export default class {
static emit(...args) {
emitter.emit(...args);
}
}
}

View File

@ -1,8 +1,8 @@
/**
* BetterDiscord Client UI Module
* Copyright (c) 2015-present JsSucks - https://github.com/JsSucks
* Copyright (c) 2015-present Jiiks/JsSucks - https://github.com/Jiiks / https://github.com/JsSucks
* All rights reserved.
* https://github.com/JsSucks - https://betterdiscord.net
* https://betterdiscord.net
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
@ -33,4 +33,4 @@ export default class {
return vueInstance;
}
}
}

View File

@ -0,0 +1,20 @@
/**
* BetterDiscord Settings Component
* Copyright (c) 2015-present Jiiks/JsSucks - https://github.com/Jiiks / https://github.com/JsSucks
* All rights reserved.
* https://betterdiscord.net
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
<template>
<div class="bd-settings" :class="{active: active}" @keyup="close">
Bd Settings
</div>
</template>
<script>
export default {
}
</script>

View File

@ -1,6 +1,56 @@
/**
* BetterDiscord Settings Wrapper Component
* Copyright (c) 2015-present Jiiks/JsSucks - https://github.com/Jiiks / https://github.com/JsSucks
* All rights reserved.
* https://betterdiscord.net
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
<template>
<div></div>
<div class="bd-settings-wrapper" :class="[{active: active}, 'platform-' + this.platform]">
<div class="bd-settings-button" :class="{active: active}" @click="showSettings">
<div class="bd-settings-button-btn" :class="[{'bd-loading': !loaded}]"></div>
</div>
<BdSettings :active="active" :close="hideSettings" />
</div>
</template>
<script>
export default {}
</script>
// Imports
import { Events } from '../../modules';
import { BdSettings } from './';
export default {
data() {
return {
loaded: false,
active: false
}
},
components: {
BdSettings
},
methods: {
showSettings() {
if (!this.loaded) return;
this.active = true;
},
hideSettings() { this.active = false },
toggleSettings() { this.active = !this.active },
keyupListener(e) {
if (this.active && e.which === 27) return this.hideSettings();
if (!e.metaKey && !e.ctrlKey || e.key !== 'b') return;
this.toggleSettings();
e.stopImmediatePropagation();
}
},
created() {
Events.on('ready', e => this.loaded = true);
window.addEvenetListener('keyup', this.keyupListener);
},
destroyed() {
window.removeEventListener('keyup', this.keyupListener);
}
}
</script>

View File

@ -1 +1,2 @@
export { default as BdSettingsWrapper } from './BdSettingsWrapper.vue';
export { default as BdSettingsWrapper } from './BdSettingsWrapper.vue';
export { default as BdSettings } from './BdSettings.vue';

View File

@ -1,8 +1,8 @@
/**
* BetterDiscord Client DOM Module
* Copyright (c) 2015-present JsSucks - https://github.com/JsSucks
* Copyright (c) 2015-present Jiiks/JsSucks - https://github.com/Jiiks / https://github.com/JsSucks
* All rights reserved.
* https://github.com/JsSucks - https://betterdiscord.net
* https://betterdiscord.net
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
@ -88,4 +88,4 @@ class DOM {
}
}
export default DOM;
export default DOM;