Update labels on style toggle
This commit is contained in:
parent
cf695c73d6
commit
7cd84038bf
|
@ -188,6 +188,7 @@ Object.assign(handleEvent, {
|
||||||
|
|
||||||
toggle(event, entry) {
|
toggle(event, entry) {
|
||||||
API.toggleStyle(entry.styleId, this.matches('.enable') || this.checked);
|
API.toggleStyle(entry.styleId, this.matches('.enable') || this.checked);
|
||||||
|
UI.addLabels(entry);
|
||||||
},
|
},
|
||||||
|
|
||||||
toggleBulkActions() {
|
toggleBulkActions() {
|
||||||
|
|
|
@ -18,11 +18,11 @@ const UI = {
|
||||||
|
|
||||||
labels: {
|
labels: {
|
||||||
'usercss': {
|
'usercss': {
|
||||||
is: style => typeof style.usercssData !== 'undefined',
|
is: ({style}) => typeof style.usercssData !== 'undefined',
|
||||||
text: 'usercss'
|
text: 'usercss'
|
||||||
},
|
},
|
||||||
'disabled': {
|
'disabled': {
|
||||||
is: style => !style.enabled,
|
is: ({entry}) => !$('.entry-state-toggle', entry).checked,
|
||||||
text: t('genericDisabledLabel')
|
text: t('genericDisabledLabel')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -164,7 +164,7 @@ const UI = {
|
||||||
$('.entry-last-update', entry).title = lastUpdate;
|
$('.entry-last-update', entry).title = lastUpdate;
|
||||||
|
|
||||||
UI.createStyleTargetsElement({entry, style});
|
UI.createStyleTargetsElement({entry, style});
|
||||||
UI.addLabels({entry, style});
|
UI.addLabels(entry);
|
||||||
|
|
||||||
return entry;
|
return entry;
|
||||||
},
|
},
|
||||||
|
@ -264,16 +264,17 @@ const UI = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
addLabels: ({entry, style}) => {
|
addLabels: entry => {
|
||||||
|
const style = entry.styleMeta;
|
||||||
const container = $('.entry-labels', entry);
|
const container = $('.entry-labels', entry);
|
||||||
const label = document.createElement('span');
|
const label = document.createElement('span');
|
||||||
const labels = document.createElement('span');
|
const labels = document.createElement('span');
|
||||||
labels.className = 'entry-labels';
|
labels.className = 'entry-labels';
|
||||||
label.className = 'entry-label ';
|
label.className = 'entry-label ';
|
||||||
Object.keys(UI.labels).forEach(item => {
|
Object.keys(UI.labels).forEach(item => {
|
||||||
if (UI.labels[item].is(style)) {
|
if (UI.labels[item].is({entry, style})) {
|
||||||
const newLabel = label.cloneNode(true);
|
const newLabel = label.cloneNode(true);
|
||||||
newLabel.className += item;
|
newLabel.dataset.label = item;
|
||||||
newLabel.textContent = UI.labels[item].text;
|
newLabel.textContent = UI.labels[item].text;
|
||||||
labels.appendChild(newLabel);
|
labels.appendChild(newLabel);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user