*u%Cgz$jo4n0jgcN
zlA(_Oifx27m_?J3?kxc-=Kh!ySL%atQ{=xAkag
ziMug@o?Ts#Ru7cg{*0&)2FSB#yEBrYfRL^Rnve$|?qmBE7up>q*S-f};{0qmfAlFS
zWQ+)18>G+LYMCJ*`>-kA6Pw2-s;HFhq$iLM1K3a9kf*~7An4O?N@%Q6ImSo}8wC`U
zY8K_)rE$;8T$>Gg)^lnLgCb7=_(2Byl%OrS`}GYGO`ZksqF-Rt06`ZB`F`GZX?9jed{led3lxlLUwKXE`)`I&%kFjrO6Ub(
zWgsY&&tAcbWJ-nTsrdn8X}tq)Jp*_d>H`=J28EZw+nmv0q;&dMW5+D_2C5U<+%ST+
zx=2*e&O+X9t#>cD0*{FsE*&Cm+hALq&2y?efIm*}0iX|rU5MJms8x=38_DHzD~IF?KnMUV
zIpHL}d!sac0T>*w#{)+-UXQyBZb+s2OR0M0jSK+7%eEc$Q28B7H>%A5pk(sV_xM3V
zWlAS9Yk+)D4}>Tsdn)?8#in1F)9Zoq=}H%}Y5>qX%o!o9e1_72>>2<4yqQduVTY;sdbN&o`(!1Ht=6#9-wiHO#l`2U%nTHjsySn*+Q-j<
zHh{i>>cl*Y?6%p>cXDQ_xl(=MePMq3^*DNr`1lIV`&b_+{Ts=Tr}y|;(69jfd>&t*
z;9Grkox3T6L{QBxbgl|r`D#DsstT^ypThkwzyNr(v=B#;25kTU002ovPDHLkV1ko1
BJN^Iw
literal 0
HcmV?d00001
diff --git a/res/img/social/twitter-2.png b/res/img/social/twitter-2.png
new file mode 100644
index 0000000000000000000000000000000000000000..84f8033a30c5cef33bb14ee59b5b8d5398b9162f
GIT binary patch
literal 1519
zcmVeqY
zO9dhH4@opc3o1&nPzZ!p18Iw=v9U2GwXM;_%UyaVX?jU~@A5XDm+fVDXLfJbe(-U}
z-QMhb-@ci7Z)VQ7qiYasMk(?!WDT+!Sz*lx+cCL|#C?g$#mo2=YBIunmq2P>DQ+Jj#PywouA8oZnq0jU3V@_^?y1lYFs>=1yasW#-R;C?i*t*WePFb8>z=X9^&Ii4Z5
zA!kJ+;GoBx*RYvw7wQ5b4k@pqiG8rt1sae?jNYkwWiC8hQJj1w3|zei9}kVgP<$ra
zA{^nmqT7rB<=pQL4J1$BQ3x+om4M>=_p|lE0=RcoJ{;tlY-$ID!iHZ*Em>2HQh)6iqk#t|Hq!xR6bRJMu$t<
zY(_z&o&X`Zc@Rn$U<25@lH)eivd@c&&`vw=c5AL5Iv=eRZf7zv2j?fIp>sHz%rqqw
zOubqJJmrPQMzaZJnEUTv16%GCUJiUh>jE?=)O#s@DY<&SG6;7U3T2q&bC3ksJE&OOO87aR-l~KLPMi&V{=kUT-TR1m91qQ~!
zB(|3q!|t^uZi$4jHV6_v^x>u$3&<^DV|4WD0%!MTWV9nh|2f`lHC!LTnjEu%157Al5JU2#6_t1C-(C6U38
zeg4nBK&wcLZNH8~Vt(GS_@%DYu-bAR*P2=jX!t-REv9Aaj|L--cH$>*UuorMG4^$d
z08|tm5;5rO%M-H7R70q;wkCKewE$Ffz7%?l@1GxaOoYUo=`I&Zf5?i?1ude*(YrtW
z3CA5c7Bd((y(ZX_{($w$H0mGSB8Jg}X&v|r-s$@TYlZ8!3Gn45QzCb#_Weu(5MGk8
zP|`Ct39t2DP7aQ=DkKXeFwHt=B9n&ee)eezd>Q^SLmQ@_$b4e7k?~MT0o)Z(p;*m<
z)p;u*VB+)$tqD>h)G-t_8~(eH9eQ76S`(xn(7_^Ur$%V1l(4I77Kd--e5Nj-;T0`q
z^eEcd2e2vt9W>sJJnli~Pq6L6ho$MP>$Xf`L^EUlUaQDN!Pyf9B){oJ3!T)~al*_ZwiU;t$x
VVe!_=*FFFM002ovPDHLkV1goAzuW)-
literal 0
HcmV?d00001
diff --git a/src/components/views/dialogs/ShareDialog.js b/src/components/views/dialogs/ShareDialog.js
new file mode 100644
index 0000000000..8bfa0ad931
--- /dev/null
+++ b/src/components/views/dialogs/ShareDialog.js
@@ -0,0 +1,211 @@
+/*
+Copyright 2018 Vector Creations Ltd
+
+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.
+*/
+
+import React from 'react';
+import PropTypes from 'prop-types';
+import {Room, User, Group, RoomMember} from 'matrix-js-sdk';
+import sdk from '../../../index';
+import { _t } from '../../../languageHandler';
+import QRCode from 'qrcode-react';
+import {makeEventPermalink, makeGroupPermalink, makeRoomPermalink, makeUserPermalink} from "../../../matrix-to";
+import * as ContextualMenu from "../../structures/ContextualMenu";
+
+const socials = [
+ {
+ name: 'Facebook',
+ img: 'img/social/facebook.png',
+ url: (url) => `https://www.facebook.com/sharer/sharer.php?u=${url}`,
+ }, {
+ name: 'Twitter',
+ img: 'img/social/twitter-2.png',
+ url: (url) => `https://twitter.com/home?status=${url}`,
+ }, /* // icon missing
+ name: 'Google Plus',
+ img: 'img/social/',
+ url: (url) => `https://plus.google.com/share?url=${url}`,
+ },*/ {
+ name: 'Linked In',
+ img: 'img/social/linkedin.png',
+ url: (url) => `https://www.linkedin.com/shareArticle?mini=true&url=${url}`,
+ }, {
+ name: 'Reddit',
+ img: 'img/social/reddit.png',
+ url: (url) => `http://www.reddit.com/submit?url=${url}`,
+ }, {
+ name: 'email',
+ img: 'img/social/email-1.png',
+ url: (url) => `mailto:?body=${url}`,
+ },
+];
+
+export default class ShareDialog extends React.Component {
+ static propTypes = {
+ onFinished: PropTypes.func.isRequired,
+ target: PropTypes.oneOfType([
+ PropTypes.instanceOf(Room),
+ PropTypes.instanceOf(User),
+ PropTypes.instanceOf(Group),
+ PropTypes.instanceOf(RoomMember),
+ // PropTypes.instanceOf(MatrixEvent),
+ ]).isRequired,
+ };
+
+ constructor(props) {
+ super(props);
+
+ this.onCopyClick = this.onCopyClick.bind(this);
+ this.onCheckboxClick = this.onCheckboxClick.bind(this);
+
+ this.state = {
+ ticked: false,
+ };
+ }
+
+ static _selectText(target) {
+ const range = document.createRange();
+ range.selectNodeContents(target);
+
+ const selection = window.getSelection();
+ selection.removeAllRanges();
+ selection.addRange(range);
+ }
+
+ static onLinkClick(e) {
+ e.preventDefault();
+ const {target} = e;
+ ShareDialog._selectText(target);
+ }
+
+ onCopyClick(e) {
+ e.preventDefault();
+
+ ShareDialog._selectText(this.refs.link);
+
+ let successful;
+ try {
+ successful = document.execCommand('copy');
+ } catch (err) {
+ console.error('Failed to copy: ', err);
+ }
+
+ const GenericTextContextMenu = sdk.getComponent('context_menus.GenericTextContextMenu');
+ const buttonRect = e.target.getBoundingClientRect();
+
+ // The window X and Y offsets are to adjust position when zoomed in to page
+ const x = buttonRect.right + window.pageXOffset;
+ const y = (buttonRect.top + (buttonRect.height / 2) + window.pageYOffset) - 19;
+ const {close} = ContextualMenu.createMenu(GenericTextContextMenu, {
+ chevronOffset: 10,
+ left: x,
+ top: y,
+ message: successful ? _t('Copied!') : _t('Failed to copy'),
+ }, false);
+ e.target.onmouseleave = close;
+ }
+
+ onCheckboxClick() {
+ this.setState({
+ ticked: !this.state.ticked,
+ });
+ }
+
+ render() {
+ let title;
+ let matrixToUrl;
+
+ let checkbox;
+
+ if (this.props.target instanceof Room) {
+ title = _t('Share Room');
+
+ const events = this.props.target.getLiveTimeline().getEvents();
+ if (events.length > 0) {
+ checkbox =
+
+
+
;
+ }
+
+ if (this.state.ticked) {
+ matrixToUrl = makeEventPermalink(this.props.target.roomId, events[events.length - 1].getId());
+ } else {
+ matrixToUrl = makeRoomPermalink(this.props.target.roomId);
+ }
+ } else if (this.props.target instanceof User || this.props.target instanceof RoomMember) {
+ title = _t('Share User');
+ matrixToUrl = makeUserPermalink(this.props.target.userId);
+ } else if (this.props.target instanceof Group) {
+ title = _t('Share Community');
+ matrixToUrl = makeGroupPermalink(this.props.target.groupId);
+ }
+
+ const encodedUrl = encodeURIComponent(matrixToUrl);
+
+ const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog');
+ return
+
+
+ { checkbox }
+
+
+
+
+
+
Social
+
+ {
+ socials.map((social) =>
+
+ )
+ }
+
+
+
+
+ ;
+ }
+}