diff --git a/app/assets/javascripts/discourse/controllers/topic.js.es6 b/app/assets/javascripts/discourse/controllers/topic.js.es6 index 71a8ca8fc12..067f6510814 100644 --- a/app/assets/javascripts/discourse/controllers/topic.js.es6 +++ b/app/assets/javascripts/discourse/controllers/topic.js.es6 @@ -687,6 +687,12 @@ export default Ember.Controller.extend(SelectedPostsCount, BufferedContent, { 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() { if (!this.get('model.details.can_move_posts')) return false; return this.get('selectedPostsCount') > 0; diff --git a/app/assets/javascripts/discourse/lib/keyboard-shortcuts.js.es6 b/app/assets/javascripts/discourse/lib/keyboard-shortcuts.js.es6 index 5701e4b735e..49e543a52ee 100644 --- a/app/assets/javascripts/discourse/lib/keyboard-shortcuts.js.es6 +++ b/app/assets/javascripts/discourse/lib/keyboard-shortcuts.js.es6 @@ -13,6 +13,8 @@ const bindings = { 'c': {handler: 'createTopic'}, 'ctrl+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'}, 'e': {postAction: 'editPost'}, '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() { this.container.lookup('controller:composer').open({action: Composer.CREATE_TOPIC, draftKey: Composer.CREATE_TOPIC}); }, diff --git a/app/assets/javascripts/discourse/templates/modal/keyboard-shortcuts-help.hbs b/app/assets/javascripts/discourse/templates/modal/keyboard-shortcuts-help.hbs index 4b1053397a2..3e6adc0fd25 100644 --- a/app/assets/javascripts/discourse/templates/modal/keyboard-shortcuts-help.hbs +++ b/app/assets/javascripts/discourse/templates/modal/keyboard-shortcuts-help.hbs @@ -56,6 +56,7 @@
  • {{{i18n 'keyboard_shortcuts_help.actions.mark_regular'}}}
  • {{{i18n 'keyboard_shortcuts_help.actions.mark_tracking'}}}
  • {{{i18n 'keyboard_shortcuts_help.actions.mark_watching'}}}
  • +
  • {{{i18n 'keyboard_shortcuts_help.actions.print'}}}
  • diff --git a/app/assets/javascripts/discourse/views/print-button.js.es6 b/app/assets/javascripts/discourse/views/print-button.js.es6 deleted file mode 100644 index 6a64845f806..00000000000 --- a/app/assets/javascripts/discourse/views/print-button.js.es6 +++ /dev/null @@ -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'); - } -}); diff --git a/app/assets/javascripts/discourse/views/topic-footer-main-buttons.js.es6 b/app/assets/javascripts/discourse/views/topic-footer-main-buttons.js.es6 index 9ea80990c2b..b28b1e9c34c 100644 --- a/app/assets/javascripts/discourse/views/topic-footer-main-buttons.js.es6 +++ b/app/assets/javascripts/discourse/views/topic-footer-main-buttons.js.es6 @@ -32,10 +32,6 @@ export default ContainerView.extend({ this.attachViewClass('invite-reply-button'); } - if (!mobileView && this.siteSettings.max_prints_per_hour_per_user > 0) { - this.attachViewClass('print-button'); - } - if (topic.get('isPrivateMessage')) { this.attachViewClass('archive-button'); } diff --git a/app/assets/stylesheets/common/components/keyboard_shortcuts.css.scss b/app/assets/stylesheets/common/components/keyboard_shortcuts.css.scss index 098bfa420c5..04045f843f9 100644 --- a/app/assets/stylesheets/common/components/keyboard_shortcuts.css.scss +++ b/app/assets/stylesheets/common/components/keyboard_shortcuts.css.scss @@ -11,7 +11,7 @@ } .keyboard-shortcuts-modal .modal-body { - max-height: 520px; + max-height: 560px; } #keyboard-shortcuts-help { diff --git a/app/views/topics/show.html.erb b/app/views/topics/show.html.erb index efeaec35241..3cbef453c7c 100644 --- a/app/views/topics/show.html.erb +++ b/app/views/topics/show.html.erb @@ -80,7 +80,9 @@ <% if @topic_view.print %> <% content_for :after_body do %> <% end %> <% end %> diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 9d1b89442d2..3c583f64403 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -2122,6 +2122,7 @@ en: mark_regular: 'm, r Regular (default) topic' mark_tracking: 'm, t Track topic' mark_watching: 'm, w Watch topic' + print: 'ctrl+p Print topic' badges: earned_n_times: