mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-10-04 19:05:37 +08:00
Added large preview [SCI-694]
This commit is contained in:
parent
8738b3e09d
commit
b537feb8a0
6 changed files with 9 additions and 10 deletions
|
@ -5,7 +5,7 @@ $(document).ready(function() {
|
||||||
$('.image-preview-link').click(function(e) {
|
$('.image-preview-link').click(function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var name = $(this).find('p').text();
|
var name = $(this).find('p').text();
|
||||||
var url = $(this).find('img').attr('src');
|
var url = $(this).find('img').data('large-url');
|
||||||
var downloadUrl = $(this).attr('href');
|
var downloadUrl = $(this).attr('href');
|
||||||
var description = $(this).data('description');
|
var description = $(this).data('description');
|
||||||
openPreviewModal(name, url, downloadUrl, description);
|
openPreviewModal(name, url, downloadUrl, description);
|
||||||
|
|
|
@ -49,6 +49,7 @@
|
||||||
-webkit-box-shadow: none;
|
-webkit-box-shadow: none;
|
||||||
box-shadow: none;
|
box-shadow: none;
|
||||||
color: $color-white;
|
color: $color-white;
|
||||||
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.modal-dialog {
|
.modal-dialog {
|
||||||
|
@ -59,17 +60,13 @@
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.modal-content {
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.modal-header {
|
.modal-header {
|
||||||
background: $color-black;
|
background: $color-black;
|
||||||
border: 0;
|
border: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.modal-body {
|
.modal-body {
|
||||||
height: 100%;
|
padding: 0;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,8 @@ class Asset < ActiveRecord::Base
|
||||||
|
|
||||||
# Paperclip validation
|
# Paperclip validation
|
||||||
has_attached_file :file,
|
has_attached_file :file,
|
||||||
styles: { medium: [Constants::MEDIUM_PIC_FORMAT, :jpg] },
|
styles: { medium: [Constants::MEDIUM_PIC_FORMAT, :jpg],
|
||||||
|
large: [Constants::LARGE_PIC_FORMAT, :jpg] },
|
||||||
convert_options: { medium: '-quality 70 -strip' }
|
convert_options: { medium: '-quality 70 -strip' }
|
||||||
|
|
||||||
validates_attachment :file,
|
validates_attachment :file,
|
||||||
|
@ -28,7 +29,7 @@ class Asset < ActiveRecord::Base
|
||||||
%r{^image/#{ Regexp.union(
|
%r{^image/#{ Regexp.union(
|
||||||
Constants::WHITELISTED_IMAGE_TYPES
|
Constants::WHITELISTED_IMAGE_TYPES
|
||||||
) }}
|
) }}
|
||||||
[:medium]
|
[:medium, :large]
|
||||||
else
|
else
|
||||||
{}
|
{}
|
||||||
end
|
end
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
<%= image_tag 'medium/processing.gif' %>
|
<%= image_tag 'medium/processing.gif' %>
|
||||||
</span>
|
</span>
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= image_tag(preview_asset_path result.asset) if result.asset.is_image? %>
|
<%= image_tag(result.asset.url(:medium), data: {large_url: result.asset.url(:large)}) if result.asset.is_image? %>
|
||||||
<p><%= result.asset.file_file_name %></p>
|
<p><%= result.asset.file_file_name %></p>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -76,7 +76,7 @@
|
||||||
<%= image_tag 'medium/processing.gif' %>
|
<%= image_tag 'medium/processing.gif' %>
|
||||||
</span>
|
</span>
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= image_tag preview_asset_path(asset) if asset.is_image? %>
|
<%= image_tag asset.url(:medium), data: {large_url: asset.url(:large)} if asset.is_image? %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<p><%= truncate(asset.file_file_name,
|
<p><%= truncate(asset.file_file_name,
|
||||||
length: Constants::FILENAME_TRUNCATION_LENGTH) %></p>
|
length: Constants::FILENAME_TRUNCATION_LENGTH) %></p>
|
||||||
|
|
|
@ -73,6 +73,7 @@ class Constants
|
||||||
|
|
||||||
# Picture size formats
|
# Picture size formats
|
||||||
MEDIUM_PIC_FORMAT = '300x300>'.freeze
|
MEDIUM_PIC_FORMAT = '300x300>'.freeze
|
||||||
|
LARGE_PIC_FORMAT = '800x600>'.freeze
|
||||||
THUMB_PIC_FORMAT = '100x100>'.freeze
|
THUMB_PIC_FORMAT = '100x100>'.freeze
|
||||||
ICON_PIC_FORMAT = '40x40>'.freeze
|
ICON_PIC_FORMAT = '40x40>'.freeze
|
||||||
ICON_SMALL_PIC_FORMAT = '30x30>'.freeze
|
ICON_SMALL_PIC_FORMAT = '30x30>'.freeze
|
||||||
|
|
Loading…
Add table
Reference in a new issue