Fixed #1181 - Reimplement EventBus
parent
f586985d4d
commit
f200fc102e
|
@ -365,6 +365,7 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
outsideClickListener: null,
|
outsideClickListener: null,
|
||||||
|
themeChangeListener: null,
|
||||||
watch: {
|
watch: {
|
||||||
$route() {
|
$route() {
|
||||||
if (this.active) {
|
if (this.active) {
|
||||||
|
@ -373,15 +374,20 @@ export default {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
beforeUnmount() {
|
||||||
|
EventBus.off('change-theme', this.themeChangeListener);
|
||||||
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
EventBus.on('change-theme', event => {
|
this.themeChangeListener = (event) => {
|
||||||
if (event.theme === 'nano')
|
if (event.theme === 'nano')
|
||||||
this.scale = 12;
|
this.scale = 12;
|
||||||
else
|
else
|
||||||
this.scale = 14;
|
this.scale = 14;
|
||||||
|
|
||||||
this.applyScale();
|
this.applyScale();
|
||||||
});
|
};
|
||||||
|
|
||||||
|
EventBus.on('change-theme', this.themeChangeListener);
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
toggleConfigurator(event) {
|
toggleConfigurator(event) {
|
||||||
|
|
|
@ -16,13 +16,15 @@ export default {
|
||||||
component: null,
|
component: null,
|
||||||
github: null
|
github: null
|
||||||
},
|
},
|
||||||
|
viewGithubListener: null,
|
||||||
mounted() {
|
mounted() {
|
||||||
EventBus.on('view-github', () => {
|
this.viewGithubListener = () => {
|
||||||
window.open('https://github.com/primefaces/primevue/blob/master/src/views/' + this.github, '_blank');
|
window.open('https://github.com/primefaces/primevue/blob/master/src/views/' + this.github, '_blank');
|
||||||
});
|
};
|
||||||
|
EventBus.on('view-github', this.viewGithubListener);
|
||||||
},
|
},
|
||||||
beforeUnmount() {
|
beforeUnmount() {
|
||||||
EventBus.off('view-github');
|
EventBus.off('view-github', this.viewGithubListener);
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
renderPanels() {
|
renderPanels() {
|
||||||
|
|
|
@ -23,6 +23,8 @@ export default {
|
||||||
default: null
|
default: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
confirmListener: null,
|
||||||
|
closeListener: null,
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
visible: false,
|
visible: false,
|
||||||
|
@ -30,7 +32,7 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
ConfirmationEventBus.on('confirm', (options) => {
|
this.confirmListener = (options) => {
|
||||||
if (!options) {
|
if (!options) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -39,16 +41,18 @@ export default {
|
||||||
this.confirmation = options;
|
this.confirmation = options;
|
||||||
this.visible = true;
|
this.visible = true;
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
|
||||||
ConfirmationEventBus.on('close', () => {
|
this.closeListener = () => {
|
||||||
this.visible = false;
|
this.visible = false;
|
||||||
this.confirmation = null;
|
this.confirmation = null;
|
||||||
});
|
};
|
||||||
|
ConfirmationEventBus.on('confirm', this.confirmListener);
|
||||||
|
ConfirmationEventBus.on('close', this.closeListener);
|
||||||
},
|
},
|
||||||
beforeUnmount() {
|
beforeUnmount() {
|
||||||
ConfirmationEventBus.off('confirm');
|
ConfirmationEventBus.off('confirm', this.confirmListener);
|
||||||
ConfirmationEventBus.off('close');
|
ConfirmationEventBus.off('close', this.closeListener);
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
accept() {
|
accept() {
|
||||||
|
|
|
@ -37,8 +37,10 @@ export default {
|
||||||
scrollHandler: null,
|
scrollHandler: null,
|
||||||
resizeListener: null,
|
resizeListener: null,
|
||||||
container: null,
|
container: null,
|
||||||
|
confirmListener: null,
|
||||||
|
closeListener: null,
|
||||||
mounted() {
|
mounted() {
|
||||||
ConfirmationEventBus.on('confirm', (options) => {
|
this.confirmListener = (options) => {
|
||||||
if (!options) {
|
if (!options) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -48,16 +50,17 @@ export default {
|
||||||
this.target = options.target;
|
this.target = options.target;
|
||||||
this.visible = true;
|
this.visible = true;
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
this.closeListener = () => {
|
||||||
ConfirmationEventBus.on('close', () => {
|
|
||||||
this.visible = false;
|
this.visible = false;
|
||||||
this.confirmation = null;
|
this.confirmation = null;
|
||||||
});
|
};
|
||||||
|
ConfirmationEventBus.on('confirm', this.confirmListener);
|
||||||
|
ConfirmationEventBus.on('close', this.closeListener);
|
||||||
},
|
},
|
||||||
beforeUnmount() {
|
beforeUnmount() {
|
||||||
ConfirmationEventBus.off('confirm');
|
ConfirmationEventBus.off('confirm', this.confirmListener);
|
||||||
ConfirmationEventBus.off('close');
|
ConfirmationEventBus.off('close', this.closeListener);
|
||||||
|
|
||||||
this.unbindOutsideClickListener();
|
this.unbindOutsideClickListener();
|
||||||
if (this.scrollHandler) {
|
if (this.scrollHandler) {
|
||||||
|
|
|
@ -80,6 +80,7 @@ export default {
|
||||||
},
|
},
|
||||||
documentEditListener: null,
|
documentEditListener: null,
|
||||||
selfClick: false,
|
selfClick: false,
|
||||||
|
overlayEventListener: null,
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
d_editing: this.editing,
|
d_editing: this.editing,
|
||||||
|
@ -101,6 +102,12 @@ export default {
|
||||||
this.updateStickyPosition();
|
this.updateStickyPosition();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
beforeUnmount() {
|
||||||
|
if (this.overlayEventListener) {
|
||||||
|
OverlayEventBus.off('overlay-click', this.overlayEventListener);
|
||||||
|
this.overlayEventListener = null;
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
columnProp(prop) {
|
columnProp(prop) {
|
||||||
return this.column.props ? ((this.column.type.props[prop].type === Boolean && this.column.props[prop] === '') ? true : this.column.props[prop]) : null;
|
return this.column.props ? ((this.column.type.props[prop].type === Boolean && this.column.props[prop] === '') ? true : this.column.props[prop]) : null;
|
||||||
|
@ -145,7 +152,8 @@ export default {
|
||||||
switchCellToViewMode() {
|
switchCellToViewMode() {
|
||||||
this.d_editing = false;
|
this.d_editing = false;
|
||||||
this.unbindDocumentEditListener();
|
this.unbindDocumentEditListener();
|
||||||
OverlayEventBus.off('overlay-click', this.eventBusKey);
|
OverlayEventBus.off('overlay-click', this.overlayEventListener);
|
||||||
|
this.overlayEventListener = null;
|
||||||
},
|
},
|
||||||
onClick(event) {
|
onClick(event) {
|
||||||
if (this.editMode === 'cell' && this.isEditable()) {
|
if (this.editMode === 'cell' && this.isEditable()) {
|
||||||
|
@ -156,11 +164,12 @@ export default {
|
||||||
this.bindDocumentEditListener();
|
this.bindDocumentEditListener();
|
||||||
this.$emit('cell-edit-init', {originalEvent: event, data: this.rowData, field: this.columnProp('field'), index: this.index});
|
this.$emit('cell-edit-init', {originalEvent: event, data: this.rowData, field: this.columnProp('field'), index: this.index});
|
||||||
|
|
||||||
OverlayEventBus.on('overlay-click', e => {
|
this.overlayEventListener = (e) => {
|
||||||
if (this.$el && this.$el.contains(e.target)) {
|
if (this.$el && this.$el.contains(e.target)) {
|
||||||
this.selfClick = true;
|
this.selfClick = true;
|
||||||
}
|
}
|
||||||
}, this.eventBusKey);
|
}
|
||||||
|
OverlayEventBus.on('overlay-click', this.overlayEventListener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -142,7 +142,13 @@ export default {
|
||||||
},
|
},
|
||||||
overlay: null,
|
overlay: null,
|
||||||
selfClick: false,
|
selfClick: false,
|
||||||
|
overlayEventListener: null,
|
||||||
beforeUnmount() {
|
beforeUnmount() {
|
||||||
|
if (this.overlayEventListener) {
|
||||||
|
OverlayEventBus.off('overlay-click', this.overlayEventListener);
|
||||||
|
this.overlayEventListener = null;
|
||||||
|
}
|
||||||
|
|
||||||
if (this.overlay) {
|
if (this.overlay) {
|
||||||
ZIndexUtils.clear(this.overlay);
|
ZIndexUtils.clear(this.overlay);
|
||||||
this.onOverlayHide();
|
this.onOverlayHide();
|
||||||
|
@ -352,11 +358,12 @@ export default {
|
||||||
this.bindScrollListener();
|
this.bindScrollListener();
|
||||||
this.bindResizeListener();
|
this.bindResizeListener();
|
||||||
|
|
||||||
OverlayEventBus.on('overlay-click', e => {
|
this.overlayEventListener = (e) => {
|
||||||
if (this.overlay.contains(e.target)) {
|
if (this.overlay.contains(e.target)) {
|
||||||
this.selfClick = true;
|
this.selfClick = true;
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
OverlayEventBus.on('overlay-click', this.overlayEventListener);
|
||||||
},
|
},
|
||||||
onOverlayLeave() {
|
onOverlayLeave() {
|
||||||
this.onOverlayHide();
|
this.onOverlayHide();
|
||||||
|
@ -369,7 +376,8 @@ export default {
|
||||||
this.unbindResizeListener();
|
this.unbindResizeListener();
|
||||||
this.unbindScrollListener();
|
this.unbindScrollListener();
|
||||||
this.overlay = null;
|
this.overlay = null;
|
||||||
OverlayEventBus.off('overlay-click');
|
OverlayEventBus.off('overlay-click', this.overlayEventListener);
|
||||||
|
this.overlayEventListener = null;
|
||||||
},
|
},
|
||||||
overlayRef(el) {
|
overlayRef(el) {
|
||||||
this.overlay = el;
|
this.overlay = el;
|
||||||
|
|
|
@ -62,6 +62,7 @@ export default {
|
||||||
resizeListener: null,
|
resizeListener: null,
|
||||||
container: null,
|
container: null,
|
||||||
styleElement: null,
|
styleElement: null,
|
||||||
|
overlayEventListener: null,
|
||||||
beforeUnmount() {
|
beforeUnmount() {
|
||||||
if (this.dismissable) {
|
if (this.dismissable) {
|
||||||
this.unbindOutsideClickListener();
|
this.unbindOutsideClickListener();
|
||||||
|
@ -78,6 +79,12 @@ export default {
|
||||||
if (this.container && this.autoZIndex) {
|
if (this.container && this.autoZIndex) {
|
||||||
ZIndexUtils.clear(this.container);
|
ZIndexUtils.clear(this.container);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.overlayEventListener) {
|
||||||
|
OverlayEventBus.off('overlay-click', this.overlayEventListener);
|
||||||
|
this.overlayEventListener = null;
|
||||||
|
}
|
||||||
|
|
||||||
this.container = null;
|
this.container = null;
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
@ -116,17 +123,20 @@ export default {
|
||||||
ZIndexUtils.set('overlay', el, this.baseZIndex + this.$primevue.config.zIndex.overlay);
|
ZIndexUtils.set('overlay', el, this.baseZIndex + this.$primevue.config.zIndex.overlay);
|
||||||
}
|
}
|
||||||
|
|
||||||
OverlayEventBus.on('overlay-click', e => {
|
this.overlayEventListener = (e) => {
|
||||||
if (this.container && this.container.contains(e.target)) {
|
if (this.container.contains(e.target)) {
|
||||||
this.selfClick = true;
|
this.selfClick = true;
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
|
||||||
|
OverlayEventBus.on('overlay-click', this.overlayEventListener);
|
||||||
},
|
},
|
||||||
onLeave() {
|
onLeave() {
|
||||||
this.unbindOutsideClickListener();
|
this.unbindOutsideClickListener();
|
||||||
this.unbindScrollListener();
|
this.unbindScrollListener();
|
||||||
this.unbindResizeListener();
|
this.unbindResizeListener();
|
||||||
OverlayEventBus.off('overlay-click');
|
OverlayEventBus.off('overlay-click', this.overlayEventListener);
|
||||||
|
this.overlayEventListener = null;
|
||||||
},
|
},
|
||||||
onAfterLeave(el) {
|
onAfterLeave(el) {
|
||||||
if (this.autoZIndex) {
|
if (this.autoZIndex) {
|
||||||
|
|
|
@ -41,19 +41,9 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
ToastEventBus.on('add', (message) => {
|
ToastEventBus.on('add', this.onAdd);
|
||||||
if (this.group == message.group) {
|
ToastEventBus.on('remove-group', this.onRemoveGroup);
|
||||||
this.add(message);
|
ToastEventBus.on('remove-all-groups', this.onRemoveAllGroups);
|
||||||
}
|
|
||||||
});
|
|
||||||
ToastEventBus.on('remove-group', (group) => {
|
|
||||||
if (this.group === group) {
|
|
||||||
this.messages = [];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
ToastEventBus.on('remove-all-groups', () => {
|
|
||||||
this.messages = [];
|
|
||||||
});
|
|
||||||
|
|
||||||
if (this.autoZIndex) {
|
if (this.autoZIndex) {
|
||||||
ZIndexUtils.set('modal', this.$refs.container, this.baseZIndex || this.$primevue.config.zIndex.modal);
|
ZIndexUtils.set('modal', this.$refs.container, this.baseZIndex || this.$primevue.config.zIndex.modal);
|
||||||
|
@ -63,6 +53,10 @@ export default {
|
||||||
if (this.$refs.container && this.autoZIndex) {
|
if (this.$refs.container && this.autoZIndex) {
|
||||||
ZIndexUtils.clear(this.$refs.container);
|
ZIndexUtils.clear(this.$refs.container);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ToastEventBus.off('add', this.onAdd);
|
||||||
|
ToastEventBus.off('remove-group', this.onRemoveGroup);
|
||||||
|
ToastEventBus.off('remove-all-groups', this.onRemoveAllGroups);
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
add(message) {
|
add(message) {
|
||||||
|
@ -82,6 +76,19 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.messages.splice(index, 1);
|
this.messages.splice(index, 1);
|
||||||
|
},
|
||||||
|
onAdd(message) {
|
||||||
|
if (this.group == message.group) {
|
||||||
|
this.add(message);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onRemoveGroup(group) {
|
||||||
|
if (this.group === group) {
|
||||||
|
this.messages = [];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onRemoveAllGroıps() {
|
||||||
|
this.messages = [];
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
|
|
|
@ -1,39 +1,29 @@
|
||||||
export default function() {
|
export default function primebus() {
|
||||||
let eventTarget, eventListener, eventKey;
|
const allHandlers = new Map();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
on(type, listener, key) {
|
on(type, handler) {
|
||||||
eventTarget = eventTarget || document.body.appendChild(document.createComment(''));
|
let handlers = allHandlers.get(type);
|
||||||
eventKey = key;
|
if (!handlers)
|
||||||
eventListener = function(e) { listener(e.detail); };
|
handlers = [handler];
|
||||||
eventTarget.addEventListener(type, eventListener);
|
else
|
||||||
return this;
|
handlers.push(handler);
|
||||||
},
|
|
||||||
once(type, listener, key) {
|
allHandlers.set(type, handlers);
|
||||||
eventTarget = eventTarget || document.body.appendChild(document.createComment(''));
|
},
|
||||||
eventKey = key;
|
|
||||||
eventListener = function(e) { listener(e.detail); };
|
off(type, handler) {
|
||||||
eventTarget.addEventListener(type, eventListener, { once: true });
|
let handlers = allHandlers.get(type);
|
||||||
return this;
|
if (handlers) {
|
||||||
},
|
handlers.splice(handlers.indexOf(handler) >>> 0, 1);
|
||||||
off(type, key) {
|
}
|
||||||
if (eventTarget && eventListener && eventKey === key) {
|
},
|
||||||
eventTarget.removeEventListener(type, eventListener);
|
|
||||||
|
emit(type, evt) {
|
||||||
|
let handlers = allHandlers.get(type);
|
||||||
|
if (handlers) {
|
||||||
|
handlers.slice().map((handler) => { handler(evt);});
|
||||||
}
|
}
|
||||||
return this;
|
}
|
||||||
},
|
};
|
||||||
emit(type, detail) {
|
}
|
||||||
if (eventTarget) {
|
|
||||||
eventTarget.dispatchEvent(new CustomEvent(type, { detail }));
|
|
||||||
}
|
|
||||||
return this;
|
|
||||||
},
|
|
||||||
reset() {
|
|
||||||
if (eventTarget) {
|
|
||||||
document.body.removeChild(eventTarget);
|
|
||||||
eventTarget = eventListener = eventKey = undefined;
|
|
||||||
}
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -231,6 +231,7 @@ export default {
|
||||||
dark: false
|
dark: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
themeChangeListener: null,
|
||||||
mounted() {
|
mounted() {
|
||||||
let afId = this.$route.query['af_id'];
|
let afId = this.$route.query['af_id'];
|
||||||
if (afId) {
|
if (afId) {
|
||||||
|
@ -240,21 +241,21 @@ export default {
|
||||||
document.cookie = 'primeaffiliateid=' + afId + ';expires=' + expire.toUTCString() + ';path=/; domain:primefaces.org';
|
document.cookie = 'primeaffiliateid=' + afId + ';expires=' + expire.toUTCString() + ';path=/; domain:primefaces.org';
|
||||||
}
|
}
|
||||||
|
|
||||||
EventBus.on('change-theme', event => {
|
this.themeChangeListener = (event) => {
|
||||||
if (event.dark)
|
if (event.dark)
|
||||||
this.dark = true;
|
this.dark = true;
|
||||||
else
|
else
|
||||||
this.dark = false;
|
this.dark = false;
|
||||||
});
|
};
|
||||||
|
EventBus.on('change-theme', this.themeChangeListener);
|
||||||
},
|
},
|
||||||
beforeUnmount() {
|
beforeUnmount() {
|
||||||
EventBus.off('change-theme');
|
EventBus.off('change-theme', this.themeChangeListener);
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
introductionClass() {
|
introductionClass() {
|
||||||
return ['introduction', {'introduction-dark': this.dark}];
|
return ['introduction', {'introduction-dark': this.dark}];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -39,20 +39,22 @@ import BarChartDoc from './BarChartDoc';
|
||||||
import EventBus from '@/AppEventBus';
|
import EventBus from '@/AppEventBus';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
themeChangeListener: null,
|
||||||
mounted() {
|
mounted() {
|
||||||
EventBus.on('change-theme', event => {
|
this.themeChangeListener = (event) => {
|
||||||
if (event.dark)
|
if (event.dark)
|
||||||
this.applyDarkTheme();
|
this.applyDarkTheme();
|
||||||
else
|
else
|
||||||
this.applyLightTheme();
|
this.applyLightTheme();
|
||||||
});
|
};
|
||||||
|
EventBus.on('change-theme', this.themeChangeListener);
|
||||||
|
|
||||||
if (this.isDarkTheme()) {
|
if (this.isDarkTheme()) {
|
||||||
this.applyDarkTheme();
|
this.applyDarkTheme();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
beforeUnmount() {
|
beforeUnmount() {
|
||||||
EventBus.off('change-theme');
|
EventBus.off('change-theme', this.themeChangeListener);
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -23,20 +23,22 @@ import ComboChartDoc from './ComboChartDoc';
|
||||||
import EventBus from '@/AppEventBus';
|
import EventBus from '@/AppEventBus';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
mounted() {
|
themeChangeListener: null,
|
||||||
EventBus.on('change-theme', event => {
|
mounted() {
|
||||||
|
this.themeChangeListener = (event) => {
|
||||||
if (event.dark)
|
if (event.dark)
|
||||||
this.applyDarkTheme();
|
this.applyDarkTheme();
|
||||||
else
|
else
|
||||||
this.applyLightTheme();
|
this.applyLightTheme();
|
||||||
});
|
};
|
||||||
|
EventBus.on('change-theme', this.themeChangeListener);
|
||||||
|
|
||||||
if (this.isDarkTheme()) {
|
if (this.isDarkTheme()) {
|
||||||
this.applyDarkTheme();
|
this.applyDarkTheme();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
beforeUnmount() {
|
beforeUnmount() {
|
||||||
EventBus.off('change-theme');
|
EventBus.off('change-theme', this.themeChangeListener);
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -23,16 +23,18 @@ import DoughnutChartDoc from './DoughnutChartDoc';
|
||||||
import EventBus from '@/AppEventBus';
|
import EventBus from '@/AppEventBus';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
themeChangeListener = null,
|
||||||
mounted() {
|
mounted() {
|
||||||
EventBus.on('change-theme', event => {
|
this.themeChangeListener = (event) => {
|
||||||
if (event.dark)
|
if (event.dark)
|
||||||
this.chartOptions = this.getDarkTheme();
|
this.chartOptions = this.getDarkTheme();
|
||||||
else
|
else
|
||||||
this.chartOptions = this.getLightTheme();
|
this.chartOptions = this.getLightTheme();
|
||||||
});
|
}
|
||||||
|
EventBus.on('change-theme', this.themeChangeListener );
|
||||||
},
|
},
|
||||||
beforeUnmount() {
|
beforeUnmount() {
|
||||||
EventBus.off('change-theme');
|
EventBus.off('change-theme', this.themeChangeListener );
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -34,20 +34,22 @@ import LineChartDoc from './LineChartDoc';
|
||||||
import EventBus from '@/AppEventBus';
|
import EventBus from '@/AppEventBus';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
themeChangeListener: null,
|
||||||
mounted() {
|
mounted() {
|
||||||
EventBus.on('change-theme', event => {
|
this.themeChangeListener = (event) => {
|
||||||
if (event.dark)
|
if (event.dark)
|
||||||
this.applyDarkTheme();
|
this.applyDarkTheme();
|
||||||
else
|
else
|
||||||
this.applyLightTheme();
|
this.applyLightTheme();
|
||||||
});
|
};
|
||||||
|
EventBus.on('change-theme', this.themeChangeListener);
|
||||||
|
|
||||||
if (this.isDarkTheme()) {
|
if (this.isDarkTheme()) {
|
||||||
this.applyDarkTheme();
|
this.applyDarkTheme();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
beforeUnmount() {
|
beforeUnmount() {
|
||||||
EventBus.off('change-theme');
|
EventBus.off('change-theme', this.themeChangeListener);
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -23,16 +23,18 @@ import PieChartDoc from './PieChartDoc';
|
||||||
import EventBus from '@/AppEventBus';
|
import EventBus from '@/AppEventBus';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
themeChangeListener = null,
|
||||||
mounted() {
|
mounted() {
|
||||||
EventBus.on('change-theme', event => {
|
this.themeChangeListener = (event) => {
|
||||||
if (event.dark)
|
if (event.dark)
|
||||||
this.chartOptions = this.getDarkTheme();
|
this.chartOptions = this.getDarkTheme();
|
||||||
else
|
else
|
||||||
this.chartOptions = this.getLightTheme();
|
this.chartOptions = this.getLightTheme();
|
||||||
});
|
}
|
||||||
|
EventBus.on('change-theme', this.themeChangeListener );
|
||||||
},
|
},
|
||||||
beforeUnmount() {
|
beforeUnmount() {
|
||||||
EventBus.off('change-theme');
|
EventBus.off('change-theme', this.themeChangeListener);
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -23,16 +23,18 @@ import PolarAreaChartDoc from './PolarAreaChartDoc';
|
||||||
import EventBus from '@/AppEventBus';
|
import EventBus from '@/AppEventBus';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
themeChangeListener = null,
|
||||||
mounted() {
|
mounted() {
|
||||||
EventBus.on('change-theme', event => {
|
this.themeChangeListener = (event) => {
|
||||||
if (event.dark)
|
if (event.dark)
|
||||||
this.chartOptions = this.getDarkTheme();
|
this.chartOptions = this.getDarkTheme();
|
||||||
else
|
else
|
||||||
this.chartOptions = this.getLightTheme();
|
this.chartOptions = this.getLightTheme();
|
||||||
});
|
}
|
||||||
|
EventBus.on('change-theme', this.themeChangeListener );
|
||||||
},
|
},
|
||||||
beforeUnmount() {
|
beforeUnmount() {
|
||||||
EventBus.off('change-theme');
|
EventBus.off('change-theme', this.themeChangeListener );
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -23,16 +23,18 @@ import RadarChartDoc from './RadarChartDoc';
|
||||||
import EventBus from '@/AppEventBus';
|
import EventBus from '@/AppEventBus';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
themeChangeListener = null,
|
||||||
mounted() {
|
mounted() {
|
||||||
EventBus.on('change-theme', event => {
|
this.themeChangeListener = (event) => {
|
||||||
if (event.dark)
|
if (event.dark)
|
||||||
this.chartOptions = this.getDarkTheme();
|
this.chartOptions = this.getDarkTheme();
|
||||||
else
|
else
|
||||||
this.chartOptions = this.getLightTheme();
|
this.chartOptions = this.getLightTheme();
|
||||||
});
|
}
|
||||||
|
EventBus.on('change-theme', this.themeChangeListener );
|
||||||
},
|
},
|
||||||
beforeUnmount() {
|
beforeUnmount() {
|
||||||
EventBus.off('change-theme');
|
EventBus.off('change-theme', this.themeChangeListener );
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -53,13 +53,15 @@ export default {
|
||||||
default: null
|
default: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
runDemoListener: null,
|
||||||
mounted() {
|
mounted() {
|
||||||
EventBus.on('run-demo', type => {
|
this.runDemoListener = (type) => {
|
||||||
this.postSandboxParameters(type);
|
this.postSandboxParameters(type);
|
||||||
});
|
};
|
||||||
|
EventBus.on('run-demo', this.runDemoListener);
|
||||||
},
|
},
|
||||||
beforeUnmount() {
|
beforeUnmount() {
|
||||||
EventBus.off('run-demo').reset();
|
EventBus.off('run-demo', this.runDemoListener);
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
postSandboxParameters(sourceType) {
|
postSandboxParameters(sourceType) {
|
||||||
|
|
|
@ -158,19 +158,21 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
timeout: null,
|
timeout: null,
|
||||||
|
themeChangeListener: null,
|
||||||
mounted() {
|
mounted() {
|
||||||
EventBus.on('change-theme', () => {
|
this.themeChangeListener = () => {
|
||||||
this.timeout = setTimeout(() => {
|
this.timeout = setTimeout(() => {
|
||||||
this.$refs.tabview1.updateInkBar();
|
this.$refs.tabview1.updateInkBar();
|
||||||
this.$refs.tabview2.updateInkBar();
|
this.$refs.tabview2.updateInkBar();
|
||||||
this.$refs.tabview3.updateInkBar();
|
this.$refs.tabview3.updateInkBar();
|
||||||
this.$refs.tabview4.updateInkBar();
|
this.$refs.tabview4.updateInkBar();
|
||||||
}, 50);
|
}, 50);
|
||||||
});
|
};
|
||||||
|
EventBus.on('change-theme', this.themeChangeListener);
|
||||||
},
|
},
|
||||||
beforeUnmount() {
|
beforeUnmount() {
|
||||||
clearTimeout(this.timeout);
|
clearTimeout(this.timeout);
|
||||||
EventBus.off('change-theme');
|
EventBus.off('change-theme', this.themeChangeListener);
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
'TabViewDoc': TabViewDoc
|
'TabViewDoc': TabViewDoc
|
||||||
|
|
Loading…
Reference in New Issue