PERF: don't render share dialog until we have a link.

This commit is contained in:
Sam 2014-12-11 15:46:08 +11:00
parent 46720b1017
commit 8b87f095c6
2 changed files with 17 additions and 12 deletions

View File

@ -1,3 +1,4 @@
{{#if controller.link}}
<h3>{{view.title}}</h3>
{{#if date}}
@ -14,3 +15,4 @@
<div class='link'>
<a href='#' {{action "close"}} title='{{i18n 'share.close'}}'><i class="fa fa-times-circle"></i></a>
</div>
{{/if}}

View File

@ -27,20 +27,23 @@ export default Discourse.View.extend({
}.property('controller.link'),
linkChanged: function() {
var self=this;
if (this.present('controller.link')) {
if (!this.capabilities.touch) {
var $linkInput = $('#share-link input');
$linkInput.val(this.get('controller.link'));
Em.run.next(function(){
if (!self.capabilities.touch) {
var $linkInput = $('#share-link input');
$linkInput.val(self.get('controller.link'));
// Wait for the fade-in transition to finish before selecting the link:
window.setTimeout(function() {
$linkInput.select().focus();
}, 160);
} else {
var $linkForTouch = $('#share-link .share-for-touch a');
$linkForTouch.attr('href', this.get('controller.link'));
$linkForTouch.html(this.get('controller.link'));
}
// Wait for the fade-in transition to finish before selecting the link:
window.setTimeout(function() {
$linkInput.select().focus();
}, 160);
} else {
var $linkForTouch = $('#share-link .share-for-touch a');
$linkForTouch.attr('href',self.get('controller.link'));
$linkForTouch.html(self.get('controller.link'));
}
});
}
}.observes('controller.link'),