From 5cdd9948e86225b15c75c790e86de0d3e0bb093e Mon Sep 17 00:00:00 2001 From: Jiiks Date: Mon, 29 Jan 2018 20:15:58 +0200 Subject: [PATCH] Consistency, add settings component, trigger ready --- client/src/index.js | 7 ++- client/src/modules/events.js | 8 +-- client/src/ui/bdui.js | 6 +- client/src/ui/components/BdSettings.vue | 20 +++++++ .../src/ui/components/BdSettingsWrapper.vue | 56 ++++++++++++++++++- client/src/ui/components/index.js | 3 +- client/src/ui/dom.js | 6 +- 7 files changed, 89 insertions(+), 17 deletions(-) create mode 100644 client/src/ui/components/BdSettings.vue diff --git a/client/src/index.js b/client/src/index.js index 52a9120a..f2de9d22 100644 --- a/client/src/index.js +++ b/client/src/index.js @@ -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 }; -} \ No newline at end of file +} diff --git a/client/src/modules/events.js b/client/src/modules/events.js index e6c83e2b..479bdaf4 100644 --- a/client/src/modules/events.js +++ b/client/src/modules/events.js @@ -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); } -} \ No newline at end of file +} diff --git a/client/src/ui/bdui.js b/client/src/ui/bdui.js index d5a818b7..48d5a690 100644 --- a/client/src/ui/bdui.js +++ b/client/src/ui/bdui.js @@ -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; } -} \ No newline at end of file +} diff --git a/client/src/ui/components/BdSettings.vue b/client/src/ui/components/BdSettings.vue new file mode 100644 index 00000000..e507cfc0 --- /dev/null +++ b/client/src/ui/components/BdSettings.vue @@ -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. +*/ + + + \ No newline at end of file diff --git a/client/src/ui/components/BdSettingsWrapper.vue b/client/src/ui/components/BdSettingsWrapper.vue index 13b12a1b..f10baa62 100644 --- a/client/src/ui/components/BdSettingsWrapper.vue +++ b/client/src/ui/components/BdSettingsWrapper.vue @@ -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. +*/ + \ No newline at end of file + // 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); + } + } + diff --git a/client/src/ui/components/index.js b/client/src/ui/components/index.js index c6eb6488..3ac7ad1e 100644 --- a/client/src/ui/components/index.js +++ b/client/src/ui/components/index.js @@ -1 +1,2 @@ -export { default as BdSettingsWrapper } from './BdSettingsWrapper.vue'; \ No newline at end of file +export { default as BdSettingsWrapper } from './BdSettingsWrapper.vue'; +export { default as BdSettings } from './BdSettings.vue'; \ No newline at end of file diff --git a/client/src/ui/dom.js b/client/src/ui/dom.js index 0a8034b1..5b26d2f7 100644 --- a/client/src/ui/dom.js +++ b/client/src/ui/dom.js @@ -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; \ No newline at end of file +export default DOM;