|
1 | | -<div class="row pt-5"> |
2 | | - <div class="col-md-8" id="containment"> |
| 1 | +<style> |
| 2 | + #work_space { |
| 3 | + padding: 30px; |
| 4 | + height: 100vw; |
| 5 | + display: flex; |
| 6 | + justify-content: center; |
| 7 | + align-items: center; |
| 8 | + } |
| 9 | +
|
| 10 | + @media screen and (min-width: 768px) { |
| 11 | + #work_space { |
| 12 | + width: unset; |
| 13 | + height: unset; |
| 14 | + } |
| 15 | + } |
| 16 | +</style> |
| 17 | + |
| 18 | +<div class="container"> |
| 19 | + <div class="row"> |
| 20 | + <div class="col-md-8 bg-light" id="work_space"> |
| 21 | + <div id="containment" class="d-none d-md-inline"> |
3 | 22 | <img id="resize" src="{{ $img->url . '?timestamp=' . $img->time }}" height="{{ $height }}" width="{{ $width }}"> |
| 23 | + </div> |
| 24 | + <div id="resize_mobile" style="background-image: url({{ $img->url . '?timestamp=' . $img->time }})" class="d-block d-md-none"></div> |
4 | 25 | </div> |
5 | | - <div class="col-md-4"> |
6 | | - <table class="table table-compact table-striped"> |
| 26 | + <div class="col-md-4 pt-3"> |
| 27 | + <table class="table table-compact table-striped"> |
7 | 28 | <thead></thead> |
8 | 29 | <tbody> |
9 | | - @if ($scaled) |
10 | | - <tr> |
11 | | - <td>{{ trans('laravel-filemanager::lfm.resize-ratio') }}</td> |
12 | | - <td>{{ number_format($ratio, 2) }}</td> |
13 | | - </tr> |
14 | | - <tr> |
15 | | - <td>{{ trans('laravel-filemanager::lfm.resize-scaled') }}</td> |
16 | | - <td> |
17 | | - {{ trans('laravel-filemanager::lfm.resize-true') }} |
18 | | - </td> |
19 | | - </tr> |
20 | | - @endif |
21 | | - <tr> |
22 | | - <td>{{ trans('laravel-filemanager::lfm.resize-old-height') }}</td> |
23 | | - <td>{{ $original_height }}px</td> |
24 | | - </tr> |
25 | | - <tr> |
26 | | - <td>{{ trans('laravel-filemanager::lfm.resize-old-width') }}</td> |
27 | | - <td>{{ $original_width }}px</td> |
28 | | - </tr> |
29 | | - <tr> |
30 | | - <td>{{ trans('laravel-filemanager::lfm.resize-new-height') }}</td> |
31 | | - <td><span id="height_display"></span></td> |
32 | | - </tr> |
33 | | - <tr> |
34 | | - <td>{{ trans('laravel-filemanager::lfm.resize-new-width') }}</td> |
35 | | - <td><span id="width_display"></span></td> |
36 | | - </tr> |
| 30 | + @if ($scaled) |
| 31 | + <tr> |
| 32 | + <td class="text-nowrap">{{ trans('laravel-filemanager::lfm.resize-ratio') }}</td> |
| 33 | + <td class="text-right">{{ number_format($ratio, 2) }}</td> |
| 34 | + </tr> |
| 35 | + <tr> |
| 36 | + <td class="text-nowrap">{{ trans('laravel-filemanager::lfm.resize-scaled') }}</td> |
| 37 | + <td class="text-right"> |
| 38 | + {{ trans('laravel-filemanager::lfm.resize-true') }} |
| 39 | + </td> |
| 40 | + </tr> |
| 41 | + @endif |
| 42 | + <tr> |
| 43 | + <td class="text-nowrap">{{ trans('laravel-filemanager::lfm.resize-old-height') }}</td> |
| 44 | + <td class="text-right">{{ $original_height }}px</td> |
| 45 | + </tr> |
| 46 | + <tr> |
| 47 | + <td class="text-nowrap">{{ trans('laravel-filemanager::lfm.resize-old-width') }}</td> |
| 48 | + <td class="text-right">{{ $original_width }}px</td> |
| 49 | + </tr> |
| 50 | + <tr> |
| 51 | + <td class="text-nowrap" style="vertical-align: middle">{{ trans('laravel-filemanager::lfm.resize-new-height') }}</td> |
| 52 | + <td class="text-right"><input type="text" id="height_display" class="form-control w-50 d-inline mr-2" value="{{ $height }}">px</td> |
| 53 | + </tr> |
| 54 | + <tr> |
| 55 | + <td class="text-nowrap" style="vertical-align: middle">{{ trans('laravel-filemanager::lfm.resize-new-width') }}</td> |
| 56 | + <td class="text-right"><input type="text" id="width_display" class="form-control w-50 d-inline mr-2" value="{{ $width }}">px</td> |
| 57 | + </tr> |
37 | 58 | </tbody> |
38 | | - </table> |
39 | | - <button class="btn btn-primary" onclick="doResize()">{{ trans('laravel-filemanager::lfm.btn-resize') }}</button> |
40 | | - <button class="btn btn-info" onclick="loadItems()">{{ trans('laravel-filemanager::lfm.btn-cancel') }}</button> |
41 | | - <input type="hidden" id="img" name="img" value="{{ $img->name }}"> |
42 | | - <input type="hidden" name="ratio" value="{{ $ratio }}"><br> |
43 | | - <input type="hidden" name="scaled" value="{{ $scaled }}"><br> |
44 | | - <input type="hidden" id="original_height" name="original_height" value="{{ $original_height }}"><br> |
45 | | - <input type="hidden" id="original_width" name="original_width" value="{{ $original_width }}"><br> |
46 | | - <input type="hidden" id="height" name="height" value="{{ $height }}"><br> |
47 | | - <input type="hidden" id="width" name="width" value="{{ $width }}"> |
48 | | -</div> |
| 59 | + </table> |
| 60 | + <div class="d-flex mb-3"> |
| 61 | + <button class="btn btn-secondary w-50 mr-1" onclick="loadItems()">{{ trans('laravel-filemanager::lfm.btn-cancel') }}</button> |
| 62 | + <button class="btn btn-primary w-50" onclick="doResize()">{{ trans('laravel-filemanager::lfm.btn-resize') }}</button> |
| 63 | + </div> |
| 64 | + |
| 65 | + <input type="hidden" id="img" name="img" value="{{ $img->name }}"> |
| 66 | + <input type="hidden" name="ratio" value="{{ $ratio }}"> |
| 67 | + <input type="hidden" name="scaled" value="{{ $scaled }}"> |
| 68 | + <input type="hidden" id="original_height" name="original_height" value="{{ $original_height }}"> |
| 69 | + <input type="hidden" id="original_width" name="original_width" value="{{ $original_width }}"> |
| 70 | + <input type="hidden" id="height" name="height" value="{{ $height }}"> |
| 71 | + <input type="hidden" id="width" name="width" value="{{ $width }}"> |
| 72 | + </div> |
| 73 | + </div> |
49 | 74 | </div> |
50 | 75 |
|
51 | 76 | <script> |
52 | 77 | $(document).ready(function () { |
53 | | - $("#height_display").html($("#resize").height() + "px"); |
54 | | - $("#width_display").html($("#resize").width() + "px"); |
| 78 | + renderResizedValues($("#width_display").val(), $("#height_display").val()); |
55 | 79 |
|
56 | 80 | $("#resize").resizable({ |
57 | 81 | aspectRatio: {{ config('lfm.resize_aspectRatio')?'true':'false' }}, |
|
60 | 84 | @endif |
61 | 85 | handles: "n, e, s, w, se, sw, ne, nw", |
62 | 86 | resize: function (event, ui) { |
63 | | - $("#width").val($("#resize").width()); |
64 | | - $("#height").val($("#resize").height()); |
65 | | - $("#height_display").html($("#resize").height() + "px"); |
66 | | - $("#width_display").html($("#resize").width() + "px"); |
| 87 | + renderResizedValues(ui.size.width, ui.size.height); |
67 | 88 | } |
68 | 89 | }); |
69 | 90 | }); |
70 | 91 |
|
| 92 | + $('#width_display, #height_display').change(function () { |
| 93 | + var newWidth = $("#width_display").val(); |
| 94 | + var newHeight = $("#height_display").val(); |
| 95 | +
|
| 96 | + renderResizedValues(newWidth, newHeight); |
| 97 | + $("#containment > .ui-wrapper").width(newWidth).height(newHeight); |
| 98 | + $("#resize").width(newWidth).height(newHeight); |
| 99 | + }); |
| 100 | +
|
| 101 | + function renderResizedValues(newWidth, newHeight) { |
| 102 | + $("#width").val(newWidth); |
| 103 | + $("#height").val(newHeight); |
| 104 | + $("#width_display").val(newWidth); |
| 105 | + $("#height_display").val(newHeight); |
| 106 | +
|
| 107 | + $('#resize_mobile').css('background-size', '100% 100%'); |
| 108 | +
|
| 109 | + if (newWidth < newHeight) { |
| 110 | + $('#resize_mobile').css('width', (newWidth / newHeight * 100) + '%').css('padding-bottom', '100%'); |
| 111 | + } else if (newWidth > newHeight) { |
| 112 | + $('#resize_mobile').css('width', '100%').css('padding-bottom', (newHeight / newWidth * 100) + '%'); |
| 113 | + } else { // newWidth === newHeight |
| 114 | + $('#resize_mobile').css('width', '100%').css('padding-bottom', '100%'); |
| 115 | + } |
| 116 | + } |
| 117 | +
|
71 | 118 | function doResize() { |
72 | 119 | performLfmRequest('doresize', { |
73 | 120 | img: $("#img").val(), |
|
0 commit comments