mirror of
https://github.com/wekan/wekan.git
synced 2026-03-07 14:20:15 +01:00
Replace templates:tabs Atmosphere package with inline Blaze implementation
Drop the templates:tabs dependency as part of Meteor 3.0 migration prep. The package is replaced by a lightweight inline basicTabs/tabContent template pair with identical API, so no consumer template changes needed.
This commit is contained in:
parent
ff7729fc35
commit
81d3a08b9b
7 changed files with 91 additions and 7 deletions
50
client/components/lib/basicTabs.js
Normal file
50
client/components/lib/basicTabs.js
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
const { ReactiveVar } = require('meteor/reactive-var');
|
||||
|
||||
Template.basicTabs.onCreated(function () {
|
||||
const activeTab = this.data.activeTab
|
||||
? { slug: this.data.activeTab }
|
||||
: this.data.tabs[0];
|
||||
this._activeTab = new ReactiveVar(activeTab);
|
||||
|
||||
this.isActiveSlug = (slug) => {
|
||||
const current = this._activeTab.get();
|
||||
return current && current.slug === slug;
|
||||
};
|
||||
});
|
||||
|
||||
Template.basicTabs.helpers({
|
||||
isActiveTab(slug) {
|
||||
if (Template.instance().isActiveSlug(slug)) {
|
||||
return 'active';
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
Template.basicTabs.events({
|
||||
'click .tab-item'(e, t) {
|
||||
t._activeTab.set(this);
|
||||
},
|
||||
});
|
||||
|
||||
function findBasicTabsInstance() {
|
||||
let view = Blaze.currentView;
|
||||
while (view) {
|
||||
if (view.name === 'Template.basicTabs' && view.templateInstance) {
|
||||
const inst = view.templateInstance();
|
||||
if (inst && inst.isActiveSlug) {
|
||||
return inst;
|
||||
}
|
||||
}
|
||||
view = view.parentView;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Template.tabContent.helpers({
|
||||
isActiveTab(slug) {
|
||||
const inst = findBasicTabsInstance();
|
||||
if (inst && inst.isActiveSlug(slug)) {
|
||||
return 'active';
|
||||
}
|
||||
},
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue