2018-01-05 01:21:38 +03:00
|
|
|
/*
|
2018-01-05 01:51:49 +03:00
|
|
|
Copyright 2018 New Vector Ltd
|
2018-01-05 01:21:38 +03:00
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
2018-02-26 17:01:33 +03:00
|
|
|
import MImageBody from "./MImageBody";
|
2018-02-28 02:07:59 +03:00
|
|
|
import sdk from '../../../index';
|
2018-01-05 01:21:38 +03:00
|
|
|
|
2018-02-26 17:01:33 +03:00
|
|
|
export default class MStickerBody extends MImageBody {
|
|
|
|
displayName: 'MStickerBody'
|
2018-01-05 01:21:38 +03:00
|
|
|
|
2018-02-26 17:01:33 +03:00
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
2018-02-28 02:07:59 +03:00
|
|
|
|
|
|
|
this._onMouseEnter = this._onMouseEnter.bind(this);
|
|
|
|
this._onMouseLeave = this._onMouseLeave.bind(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
_onMouseEnter() {
|
|
|
|
this.setState({showTooltip: true});
|
|
|
|
}
|
|
|
|
|
|
|
|
_onMouseLeave() {
|
|
|
|
this.setState({showTooltip: false});
|
2018-02-26 17:01:33 +03:00
|
|
|
}
|
2018-01-05 01:21:38 +03:00
|
|
|
|
2018-02-26 17:01:33 +03:00
|
|
|
_messageContent(contentUrl, thumbUrl, content) {
|
2018-02-28 02:07:59 +03:00
|
|
|
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"
|
2018-02-28 16:43:19 +03:00
|
|
|
label={tooltipBody} />;
|
2018-02-28 02:07:59 +03:00
|
|
|
}
|
|
|
|
|
2018-01-05 01:21:38 +03:00
|
|
|
return (
|
2018-02-26 17:01:33 +03:00
|
|
|
<span className="mx_MImageBody" ref="body">
|
2018-03-06 13:48:32 +03:00
|
|
|
<div className="mx_MImageBody_thumbnail_container">
|
|
|
|
<img className="mx_MImageBody_thumbnail" src={thumbUrl} ref="image"
|
|
|
|
alt={content.body}
|
|
|
|
onLoad={this.props.onWidgetLoad}
|
|
|
|
onMouseEnter={this._onMouseEnter}
|
|
|
|
onMouseLeave={this._onMouseLeave}
|
|
|
|
/>
|
|
|
|
{ tooltip }
|
|
|
|
</div>
|
2018-02-26 17:01:33 +03:00
|
|
|
</span>
|
2018-01-05 01:21:38 +03:00
|
|
|
);
|
2018-02-26 17:01:33 +03:00
|
|
|
}
|
2018-01-05 01:21:38 +03:00
|
|
|
|
2018-02-26 17:01:33 +03:00
|
|
|
onClick() {
|
|
|
|
}
|
|
|
|
}
|