1
0
Fork 0
This repository has been archived on 2023-03-27. You can view files and clone it, but cannot push or open issues or pull requests.
lpr-partynest/app/assets/javascripts/application.js

53 lines
1 KiB
JavaScript

//= require rails-ujs
//= require activestorage
//= require turbolinks
//= require jquery3
//= require popper
//= require bootstrap-sprockets
//= require viewerjs/dist/viewer
//= require jquery-viewer/dist/jquery-viewer
//= require_tree .
$(document).ready(function() {
$('#image').passportImageViewer()
$("input[name='passport[images]']").change(function() {
if (!this.files) { return }
var file = this.files[0]
if (!file) { return }
var reader = new FileReader()
reader.onload = function(e) {
$('#image').attr('src', e.target.result)
$('#image').passportImageViewer()
}
reader.readAsDataURL(file)
})
})
$.fn.passportImageViewer = function() {
$(this).viewer('destroy')
$(this).viewer({
inline: true,
title: false,
navbar: false,
toolbar: {
zoomIn: true,
zoomOut: true,
oneToOne: true,
reset: true,
prev: false,
play: false,
next: false,
rotateLeft: true,
rotateRight: true,
flipHorizontal: true,
flipVertical: true,
},
})
}