Open print dialog automatically

This commit is contained in:
Rafael dos Santos Silva 2016-08-01 02:06:55 -03:00
parent c12e533273
commit 70c68f0a7c
4 changed files with 15 additions and 2 deletions

3
.gitignore vendored
View File

@ -108,3 +108,6 @@ bundler_stubs/*
vendor/bundle/*
*.db
#ignore jetbrains ide file
*.iml

View File

@ -71,4 +71,5 @@
<%= raw SiteCustomization.custom_body_tag(session[:preview_style]) %>
<%- end %>
</body>
<%= yield :after_body %>
</html>

View File

@ -76,3 +76,11 @@
<% end %>
<% content_for(:title) { "#{@topic_view.page_title}" } %>
<% if @topic_view.print %>
<% content_for :after_body do %>
<script>
window.print();
</script>
<% end %>
<% end %>

View File

@ -5,7 +5,7 @@ require_dependency 'gaps'
class TopicView
attr_reader :topic, :posts, :guardian, :filtered_posts, :chunk_size
attr_reader :topic, :posts, :guardian, :filtered_posts, :chunk_size, :print
attr_accessor :draft, :draft_key, :draft_sequence, :user_custom_fields, :post_custom_fields
def self.slow_chunk_size
@ -41,6 +41,7 @@ class TopicView
@user = user
@guardian = Guardian.new(@user)
@topic = find_topic(topic_id)
@print = options[:print].present?
check_and_raise_exceptions
options.each do |key, value|
@ -50,7 +51,7 @@ class TopicView
@page = 1 if (!@page || @page.zero?)
@chunk_size = case
when options[:slow_platform] then TopicView.slow_chunk_size
when options[:print] then 1000
when @print then 1000
else TopicView.chunk_size
end
@limit ||= @chunk_size