Show full button content as tooltip

Refs #494.
This commit is contained in:
Franz Liedke 2016-03-30 10:04:08 +09:00
parent 43c4c1fe9f
commit 630215b742
3 changed files with 32 additions and 4 deletions

View File

@ -17830,8 +17830,8 @@ System.register('flarum/components/BasicsPage', ['flarum/components/Page', 'flar
});;
'use strict';
System.register('flarum/components/Button', ['flarum/Component', 'flarum/helpers/icon', 'flarum/utils/extract', 'flarum/components/LoadingIndicator'], function (_export, _context) {
var Component, icon, extract, LoadingIndicator, Button;
System.register('flarum/components/Button', ['flarum/Component', 'flarum/helpers/icon', 'flarum/utils/extract', 'flarum/utils/extractText', 'flarum/components/LoadingIndicator'], function (_export, _context) {
var Component, icon, extract, extractText, LoadingIndicator, Button;
return {
setters: [function (_flarumComponent) {
Component = _flarumComponent.default;
@ -17839,6 +17839,8 @@ System.register('flarum/components/Button', ['flarum/Component', 'flarum/helpers
icon = _flarumHelpersIcon.default;
}, function (_flarumUtilsExtract) {
extract = _flarumUtilsExtract.default;
}, function (_flarumUtilsExtractText) {
extractText = _flarumUtilsExtractText.default;
}, function (_flarumComponentsLoadingIndicator) {
LoadingIndicator = _flarumComponentsLoadingIndicator.default;
}],
@ -17860,6 +17862,7 @@ System.register('flarum/components/Button', ['flarum/Component', 'flarum/helpers
attrs.className = attrs.className || '';
attrs.type = attrs.type || 'button';
attrs.title = attrs.title || this.getDefaultTitle();
var iconName = extract(attrs, 'icon');
if (iconName) attrs.className += ' hasIcon';
@ -17876,6 +17879,11 @@ 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() {

View File

@ -19153,8 +19153,8 @@ System.register('flarum/components/Badge', ['flarum/Component', 'flarum/helpers/
});;
'use strict';
System.register('flarum/components/Button', ['flarum/Component', 'flarum/helpers/icon', 'flarum/utils/extract', 'flarum/components/LoadingIndicator'], function (_export, _context) {
var Component, icon, extract, LoadingIndicator, Button;
System.register('flarum/components/Button', ['flarum/Component', 'flarum/helpers/icon', 'flarum/utils/extract', 'flarum/utils/extractText', 'flarum/components/LoadingIndicator'], function (_export, _context) {
var Component, icon, extract, extractText, LoadingIndicator, Button;
return {
setters: [function (_flarumComponent) {
Component = _flarumComponent.default;
@ -19162,6 +19162,8 @@ System.register('flarum/components/Button', ['flarum/Component', 'flarum/helpers
icon = _flarumHelpersIcon.default;
}, function (_flarumUtilsExtract) {
extract = _flarumUtilsExtract.default;
}, function (_flarumUtilsExtractText) {
extractText = _flarumUtilsExtractText.default;
}, function (_flarumComponentsLoadingIndicator) {
LoadingIndicator = _flarumComponentsLoadingIndicator.default;
}],
@ -19183,6 +19185,7 @@ System.register('flarum/components/Button', ['flarum/Component', 'flarum/helpers
attrs.className = attrs.className || '';
attrs.type = attrs.type || 'button';
attrs.title = attrs.title || this.getDefaultTitle();
var iconName = extract(attrs, 'icon');
if (iconName) attrs.className += ' hasIcon';
@ -19199,6 +19202,11 @@ 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() {

View File

@ -1,6 +1,7 @@
import Component from 'flarum/Component';
import icon from 'flarum/helpers/icon';
import extract from 'flarum/utils/extract';
import extractText from 'flarum/utils/extractText';
import LoadingIndicator from 'flarum/components/LoadingIndicator';
/**
@ -27,6 +28,7 @@ export default class Button extends Component {
attrs.className = attrs.className || '';
attrs.type = attrs.type || 'button';
attrs.title = attrs.title || this.getDefaultTitle();
const iconName = extract(attrs, 'icon');
if (iconName) attrs.className += ' hasIcon';
@ -40,6 +42,16 @@ export default class Button extends Component {
return <button {...attrs}>{this.getButtonContent()}</button>;
}
/**
* Get the default value for the title attribute.
*
* @return string
* @protected
*/
getDefaultTitle() {
return extractText(this.props.children);
}
/**
* Get the template for the button's content.
*