diff --git a/app/assets/javascripts/my_modules/image_preview.js b/app/assets/javascripts/my_modules/image_preview.js new file mode 100644 index 000000000..30538da9a --- /dev/null +++ b/app/assets/javascripts/my_modules/image_preview.js @@ -0,0 +1,27 @@ +$(document).ready(function() { + var modal = $('#imagePreviewModal'); + + function initPreviewModal() { + $('.image-preview-link').click(function(e) { + e.preventDefault(); + var name = $(this).find('p').text(); + var url = $(this).find('img').attr('src'); + var downloadUrl = $(this).attr('href'); + var description = $(this).data('description'); + openPreviewModal(name, url, downloadUrl, description); + }); + } + + function openPreviewModal(name, url, downloadUrl, description) { + modal.find('.image-name').text(name); + var link = modal.find('.image-download-link'); + link.attr('href', downloadUrl); + var image = modal.find('.modal-body img'); + image.attr('src', url); + image.attr('alt', name); + modal.find('.modal-footer .image-description').text(description); + modal.modal(); + } + + initPreviewModal(); +}); diff --git a/app/assets/stylesheets/my_modules.scss b/app/assets/stylesheets/my_modules.scss index 250029f54..f2749867b 100644 --- a/app/assets/stylesheets/my_modules.scss +++ b/app/assets/stylesheets/my_modules.scss @@ -2,6 +2,8 @@ // They will automatically be included in application.css. // You can use Sass (SCSS) here: http://sass-lang.com/ +@import 'constants'; + /* Results index page */ #results { @@ -28,3 +30,86 @@ word-wrap: break-word; } } + +.modal-image-preview { + background: transparent; + font-size: 16px; + + .preview-close { + background: transparent; + border: 0; + color: $color-white; + display: inline-block; + float: right; + } + + .modal-content { + background: transparent; + border: 0; + -webkit-box-shadow: none; + box-shadow: none; + color: $color-white; + } + + .modal-dialog { + margin: 0; + margin-left: auto; + margin-right: auto; + padding: 0; + width: 100%; + } + + .modal-content { + height: 100%; + } + + .modal-header { + background: $color-black; + border: 0; + } + + .modal-body { + height: 100%; + text-align: center; + } + + .modal-footer { + background: $color-black; + border: 0; + text-align: center; + } + + .image-download-link { + color: $color-white; + display: inline-block; + float: right; + margin-right: 20px; + } +} + +.modal-backdrop.modal-image-preview { + background: $color-black; + + .in { + filter: alpha(opacity = 99); + opacity: .99; + } +} + +@media (min-width: 768px) { + .modal-image-preview .modal-dialog { + width: 760px; + } +} + +@media (min-width: 992px) { + .modal-image-preview .modal-dialog { + width: 980px; + } +} + +@media (min-width: 1200px) { + .modal-image-preview .modal-dialog { + width: 1180px; + } +} diff --git a/app/views/my_modules/protocols.html.erb b/app/views/my_modules/protocols.html.erb index ff4b97a1a..bf6bc22f9 100644 --- a/app/views/my_modules/protocols.html.erb +++ b/app/views/my_modules/protocols.html.erb @@ -43,5 +43,9 @@ <%= render partial: "protocols/import_export/import_elements.html.erb" %> + +<%= render partial: "shared/image_preview_modal.html.erb" %> + <%= stylesheet_link_tag 'datatables' %> <%= javascript_include_tag("my_modules/protocols") %> +<%= javascript_include_tag("my_modules/image_preview") %> diff --git a/app/views/shared/_image_preview_modal.html.erb b/app/views/shared/_image_preview_modal.html.erb new file mode 100644 index 000000000..9baac98c1 --- /dev/null +++ b/app/views/shared/_image_preview_modal.html.erb @@ -0,0 +1,19 @@ +
diff --git a/app/views/steps/_step.html.erb b/app/views/steps/_step.html.erb index df3ef201f..1d55d407c 100644 --- a/app/views/steps/_step.html.erb +++ b/app/views/steps/_step.html.erb @@ -66,7 +66,10 @@