1
0
mirror of https://github.com/flarum/core.git synced 2025-07-23 17:51:24 +02:00

Improve Button component to only show tooltip if textual content is available

This commit is contained in:
Franz Liedke
2016-04-01 09:51:18 +09:00
parent 9fb7d170a8
commit 38e0fc53ab
3 changed files with 16 additions and 24 deletions

View File

@@ -17862,7 +17862,11 @@ System.register('flarum/components/Button', ['flarum/Component', 'flarum/helpers
attrs.className = attrs.className || '';
attrs.type = attrs.type || 'button';
attrs.title = attrs.title || this.getDefaultTitle();
// If nothing else is provided, we use the textual button content as tooltip
if (!attrs.title && this.props.children) {
attrs.title = extractText(attrs.title);
}
var iconName = extract(attrs, 'icon');
if (iconName) attrs.className += ' hasIcon';
@@ -17879,11 +17883,6 @@ System.register('flarum/components/Button', ['flarum/Component', 'flarum/helpers
this.getButtonContent()
);
}
}, {
key: 'getDefaultTitle',
value: function getDefaultTitle() {
return extractText(this.props.children);
}
}, {
key: 'getButtonContent',
value: function getButtonContent() {
@@ -18576,7 +18575,7 @@ System.register('flarum/components/ExtensionsPage', ['flarum/components/Page', '
method: 'PATCH',
data: { enabled: !enabled }
}).then(function () {
if (enabled) localStorage.setItem('enabledExtension', id);
if (!enabled) localStorage.setItem('enabledExtension', id);
window.location.reload();
});