Show sticker description as a tooltip, on hover.
parent
57c98d96a5
commit
0fdbddf8fd
|
@ -17,22 +17,49 @@ limitations under the License.
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import MImageBody from "./MImageBody";
|
import MImageBody from "./MImageBody";
|
||||||
|
import sdk from '../../../index';
|
||||||
|
|
||||||
export default class MStickerBody extends MImageBody {
|
export default class MStickerBody extends MImageBody {
|
||||||
displayName: 'MStickerBody'
|
displayName: 'MStickerBody'
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
|
this._onMouseEnter = this._onMouseEnter.bind(this);
|
||||||
|
this._onMouseLeave = this._onMouseLeave.bind(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
_onMouseEnter() {
|
||||||
|
this.setState({showTooltip: true});
|
||||||
|
}
|
||||||
|
|
||||||
|
_onMouseLeave() {
|
||||||
|
this.setState({showTooltip: false});
|
||||||
}
|
}
|
||||||
|
|
||||||
_messageContent(contentUrl, thumbUrl, content) {
|
_messageContent(contentUrl, thumbUrl, content) {
|
||||||
|
let tooltip;
|
||||||
|
const tooltipBody = (
|
||||||
|
this.props.mxEvent &&
|
||||||
|
this.props.mxEvent.getContent() &&
|
||||||
|
this.props.mxEvent.getContent().body) ?
|
||||||
|
this.props.mxEvent.getContent().body : null;
|
||||||
|
if (this.state.showTooltip && tooltipBody) {
|
||||||
|
const RoomTooltip = sdk.getComponent("rooms.RoomTooltip");
|
||||||
|
tooltip = <RoomTooltip
|
||||||
|
className="mx_RoleButton_tooltip"
|
||||||
|
label={ tooltipBody } />;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<span className="mx_MImageBody" ref="body">
|
<span className="mx_MImageBody" ref="body">
|
||||||
<img className="mx_MImageBody_thumbnail" src={thumbUrl} ref="image"
|
<img className="mx_MImageBody_thumbnail" src={thumbUrl} ref="image"
|
||||||
alt={content.body}
|
alt={content.body}
|
||||||
onLoad={this.props.onWidgetLoad}
|
onLoad={this.props.onWidgetLoad}
|
||||||
onMouseEnter={this.onImageEnter}
|
onMouseEnter={this._onMouseEnter}
|
||||||
onMouseLeave={this.onImageLeave} />
|
onMouseLeave={this._onMouseLeave}
|
||||||
|
/>
|
||||||
|
{ tooltip }
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue