Removes UI for print, adds CTRL+P shortcut

This commit is contained in:
Rafael dos Santos Silva 2016-08-10 23:41:32 -03:00
parent 0229df4c73
commit 03ec480c65
8 changed files with 23 additions and 22 deletions

View File

@ -687,6 +687,12 @@ export default Ember.Controller.extend(SelectedPostsCount, BufferedContent, {
this.send('togglePinnedForUser'); this.send('togglePinnedForUser');
}, },
print() {
if (this.siteSettings.max_prints_per_hour_per_user > 0) {
window.open(this.get('model.printUrl'), '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,width=600,height=315');
}
},
canMergeTopic: function() { canMergeTopic: function() {
if (!this.get('model.details.can_move_posts')) return false; if (!this.get('model.details.can_move_posts')) return false;
return this.get('selectedPostsCount') > 0; return this.get('selectedPostsCount') > 0;

View File

@ -13,6 +13,8 @@ const bindings = {
'c': {handler: 'createTopic'}, 'c': {handler: 'createTopic'},
'ctrl+f': {handler: 'showPageSearch', anonymous: true}, 'ctrl+f': {handler: 'showPageSearch', anonymous: true},
'command+f': {handler: 'showPageSearch', anonymous: true}, 'command+f': {handler: 'showPageSearch', anonymous: true},
'ctrl+p': {handler: 'printTopic', anonymous: true},
'command+p': {handler: 'printTopic', anonymous: true},
'd': {postAction: 'deletePost'}, 'd': {postAction: 'deletePost'},
'e': {postAction: 'editPost'}, 'e': {postAction: 'editPost'},
'end': {handler: 'goToLastPost', anonymous: true}, 'end': {handler: 'goToLastPost', anonymous: true},
@ -151,6 +153,15 @@ export default {
}); });
}, },
printTopic(event) {
Ember.run(() => {
if ($('.container.posts').length) {
event.preventDefault(); // We need to stop printing the current page in Firefox
this.container.lookup('controller:topic').print();
}
});
},
createTopic() { createTopic() {
this.container.lookup('controller:composer').open({action: Composer.CREATE_TOPIC, draftKey: Composer.CREATE_TOPIC}); this.container.lookup('controller:composer').open({action: Composer.CREATE_TOPIC, draftKey: Composer.CREATE_TOPIC});
}, },

View File

@ -56,6 +56,7 @@
<li>{{{i18n 'keyboard_shortcuts_help.actions.mark_regular'}}}</li> <li>{{{i18n 'keyboard_shortcuts_help.actions.mark_regular'}}}</li>
<li>{{{i18n 'keyboard_shortcuts_help.actions.mark_tracking'}}}</li> <li>{{{i18n 'keyboard_shortcuts_help.actions.mark_tracking'}}}</li>
<li>{{{i18n 'keyboard_shortcuts_help.actions.mark_watching'}}}</li> <li>{{{i18n 'keyboard_shortcuts_help.actions.mark_watching'}}}</li>
<li>{{{i18n 'keyboard_shortcuts_help.actions.print'}}}</li>
</ul> </ul>
</div> </div>
</div> </div>

View File

@ -1,16 +0,0 @@
import ButtonView from 'discourse/views/button';
import { iconHTML } from 'discourse/helpers/fa-icon';
export default ButtonView.extend({
classNames: ['print'],
textKey: 'topic.print.title',
helpKey: 'topic.print.help',
renderIcon(buffer) {
buffer.push(iconHTML("print"));
},
click() {
window.open(this.get('controller.model.printUrl'), '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,width=600,height=315');
}
});

View File

@ -32,10 +32,6 @@ export default ContainerView.extend({
this.attachViewClass('invite-reply-button'); this.attachViewClass('invite-reply-button');
} }
if (!mobileView && this.siteSettings.max_prints_per_hour_per_user > 0) {
this.attachViewClass('print-button');
}
if (topic.get('isPrivateMessage')) { if (topic.get('isPrivateMessage')) {
this.attachViewClass('archive-button'); this.attachViewClass('archive-button');
} }

View File

@ -11,7 +11,7 @@
} }
.keyboard-shortcuts-modal .modal-body { .keyboard-shortcuts-modal .modal-body {
max-height: 520px; max-height: 560px;
} }
#keyboard-shortcuts-help { #keyboard-shortcuts-help {

View File

@ -80,7 +80,9 @@
<% if @topic_view.print %> <% if @topic_view.print %>
<% content_for :after_body do %> <% content_for :after_body do %>
<script> <script>
document.addEventListener("DOMContentLoaded", function() {
window.print(); window.print();
});
</script> </script>
<% end %> <% end %>
<% end %> <% end %>

View File

@ -2122,6 +2122,7 @@ en:
mark_regular: '<b>m</b>, <b>r</b> Regular (default) topic' mark_regular: '<b>m</b>, <b>r</b> Regular (default) topic'
mark_tracking: '<b>m</b>, <b>t</b> Track topic' mark_tracking: '<b>m</b>, <b>t</b> Track topic'
mark_watching: '<b>m</b>, <b>w</b> Watch topic' mark_watching: '<b>m</b>, <b>w</b> Watch topic'
print: '<b>ctrl</b>+<b>p</b> Print topic'
badges: badges:
earned_n_times: earned_n_times: