mirror of
https://github.com/discourse/discourse.git
synced 2024-11-27 11:20:57 -06:00
Pull automatic share link copying
This commit is contained in:
parent
90b85e5b23
commit
5408abd427
@ -1,6 +1,5 @@
|
|||||||
{{#if controller.link}}
|
{{#if controller.link}}
|
||||||
<h3>{{view.title}}</h3>
|
<h3>{{view.title}}</h3>
|
||||||
<span class="copy-text {{if copied "success"}}">{{i18n 'share.copied'}}</span>
|
|
||||||
|
|
||||||
{{#if date}}
|
{{#if date}}
|
||||||
<span class="date">{{displayDate}}</span>
|
<span class="date">{{displayDate}}</span>
|
||||||
@ -19,4 +18,3 @@
|
|||||||
<a href {{action "close"}} aria-label='{{i18n 'share.close'}}' title='{{i18n 'share.close'}}'>{{fa-icon "times-circle"}}</a>
|
<a href {{action "close"}} aria-label='{{i18n 'share.close'}}' title='{{i18n 'share.close'}}'>{{fa-icon "times-circle"}}</a>
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
<span class="hidden" id="copy-target"></span>
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import copyText from 'discourse/lib/copy-text';
|
|
||||||
|
|
||||||
export default Discourse.View.extend({
|
export default Discourse.View.extend({
|
||||||
templateName: 'share',
|
templateName: 'share',
|
||||||
@ -36,6 +35,9 @@ export default Discourse.View.extend({
|
|||||||
var $linkForTouch = $('#share-link .share-for-touch a');
|
var $linkForTouch = $('#share-link .share-for-touch a');
|
||||||
$linkForTouch.attr('href',self.get('controller.link'));
|
$linkForTouch.attr('href',self.get('controller.link'));
|
||||||
$linkForTouch.html(self.get('controller.link'));
|
$linkForTouch.html(self.get('controller.link'));
|
||||||
|
var range = window.document.createRange();
|
||||||
|
range.selectNode($linkForTouch[0]);
|
||||||
|
window.getSelection().addRange(range);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -63,7 +65,6 @@ export default Discourse.View.extend({
|
|||||||
var $currentTarget = $(e.currentTarget),
|
var $currentTarget = $(e.currentTarget),
|
||||||
$currentTargetOffset = $currentTarget.offset(),
|
$currentTargetOffset = $currentTarget.offset(),
|
||||||
$shareLink = $('#share-link'),
|
$shareLink = $('#share-link'),
|
||||||
copyElement = document.getElementById('copy-target'),
|
|
||||||
url = $currentTarget.data('share-url'),
|
url = $currentTarget.data('share-url'),
|
||||||
postNumber = $currentTarget.data('post-number'),
|
postNumber = $currentTarget.data('post-number'),
|
||||||
date = $currentTarget.children().data('time');
|
date = $currentTarget.children().data('time');
|
||||||
@ -94,18 +95,10 @@ export default Discourse.View.extend({
|
|||||||
$shareLink.css({left: "" + x + "px"});
|
$shareLink.css({left: "" + x + "px"});
|
||||||
}
|
}
|
||||||
|
|
||||||
self.set('controller.copied', false);
|
|
||||||
|
|
||||||
const copySuccess = copyText(url, copyElement);
|
|
||||||
|
|
||||||
self.set('controller.link', url);
|
self.set('controller.link', url);
|
||||||
self.set('controller.postNumber', postNumber);
|
self.set('controller.postNumber', postNumber);
|
||||||
self.set('controller.date', date);
|
self.set('controller.date', date);
|
||||||
|
|
||||||
Ember.run.later(null, function() {
|
|
||||||
self.set('controller.copied', copySuccess);
|
|
||||||
}, 50);
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -114,7 +114,6 @@ en:
|
|||||||
topic: 'share a link to this topic'
|
topic: 'share a link to this topic'
|
||||||
post: 'post #%{postNumber}'
|
post: 'post #%{postNumber}'
|
||||||
close: 'close'
|
close: 'close'
|
||||||
copied: 'copied to clipboard'
|
|
||||||
twitter: 'share this link on Twitter'
|
twitter: 'share this link on Twitter'
|
||||||
facebook: 'share this link on Facebook'
|
facebook: 'share this link on Facebook'
|
||||||
google+: 'share this link on Google+'
|
google+: 'share this link on Google+'
|
||||||
|
Loading…
Reference in New Issue
Block a user