Skip to content

Commit 9bb4d7e

Browse files
committed
Merge pull request #12 from tsawler/Development
Development
2 parents 76c3643 + 7a7f283 commit 9bb4d7e

File tree

7 files changed

+80
-23
lines changed

7 files changed

+80
-23
lines changed

src/controllers/CropController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,5 @@ public function getCropimage()
5151
$thumb_img->fit(200, 200)
5252
->save(base_path() . "/" . Config::get('lfm.images_dir') . $dir . "/thumbs/" . basename($img));
5353
}
54-
}
54+
55+
}

src/controllers/DownloadController.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ public function getDownload()
3939
{
4040
$file_to_download = Input::get('file');
4141
$dir = Input::get('dir');
42-
return Response::download(base_path() . "/" . $this->file_location . $dir . "/" . $file_to_download);
42+
return Response::download(base_path()
43+
. "/"
44+
. $this->file_location
45+
. $dir
46+
. "/"
47+
. $file_to_download);
4348
}
49+
4450
}
Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
* Class ScaleController
1111
* @package Tsawler\Laravelfilemanager\controllers
1212
*/
13-
class ScaleController extends Controller {
13+
class ResizeController extends Controller {
1414

1515
/**
1616
* Dipsplay image for resizing
1717
*
1818
* @return mixed
1919
*/
20-
public function getScale()
20+
public function getResize()
2121
{
2222
$ratio = 1.0;
2323
$image = Input::get('img');
@@ -48,7 +48,7 @@ public function getScale()
4848
$scaled = true;
4949
}
5050

51-
return View::make('laravel-filemanager::scale')
51+
return View::make('laravel-filemanager::resize')
5252
->with('img', Config::get('lfm.images_url') . $dir . "/" . $image)
5353
->with('dir', $dir)
5454
->with('image', $image)
@@ -59,4 +59,27 @@ public function getScale()
5959
->with('scaled', $scaled)
6060
->with('ratio', $ratio);
6161
}
62+
63+
64+
public function performResize()
65+
{
66+
$img = Input::get('img');
67+
$dir = Input::get('dir');
68+
$dataX = Input::get('dataX');
69+
$dataY= Input::get('dataY');
70+
$height = Input::get('dataHeight');
71+
$width = Input::get('dataWidth');
72+
73+
try
74+
{
75+
Image::make(public_path() . $img)->resize($width, $height)->save();
76+
return "OK";
77+
} catch (Exception $e)
78+
{
79+
return "width : " . $width . " height: " . $height;
80+
return $e;
81+
}
82+
83+
}
84+
6285
}

src/routes.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
Route::get('/laravel-filemanager/rename', 'Tsawler\Laravelfilemanager\controllers\RenameController@getRename');
2929

3030
// scale/resize
31-
Route::get('/laravel-filemanager/scale', 'Tsawler\Laravelfilemanager\controllers\ScaleController@getScale');
31+
Route::get('/laravel-filemanager/resize', 'Tsawler\Laravelfilemanager\controllers\ResizeController@getResize');
32+
Route::get('/laravel-filemanager/doresize', 'Tsawler\Laravelfilemanager\controllers\ResizeController@performResize');
3233

3334
// download
3435
Route::get('/laravel-filemanager/download', 'Tsawler\Laravelfilemanager\controllers\DownloadController@getDownload');

src/views/images.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ class="btn btn-default btn-xs">
5555
</button>
5656
<ul class="dropdown-menu" role="menu">
5757
<li><a href="javascript:rename('{!! basename($file) !!}')">Rename</a></li>
58-
<li><a href="javascript:notImp()">View</a></li>
58+
<li><a href="javascript:fileView('{!! basename($file) !!}')">View</a></li>
5959
<li><a href="javascript:download('{!! basename($file) !!}')">Download</a></li>
6060
<li class="divider"></li>
6161
<li><a href="javascript:notImp()">Rotate</a></li>
62-
<li><a href="javascript:scaleImage('{!! basename($file) !!}')">Scale</a></li>
62+
<li><a href="javascript:resizeImage('{!! basename($file) !!}')">Resize</a></li>
6363
<li><a href="javascript:cropImage('{!! basename($file) !!}')">Crop</a></li>
6464
<li class="divider"></li>
6565
<li><a href="javascript:trash('{!! basename($file) !!}')">Delete</a></li>

src/views/index.blade.php

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class="fa fa-list"></i> List</a>
9999
{!! Form::label('file_to_upload', 'Choose File', array('class' => 'control-label')); !!}
100100
<div class="controls">
101101
<div class="input-group" style="width: 100%">
102-
<input type="file" name="file_to_upload">
102+
<input type="file" id="file_to_upload" name="file_to_upload">
103103
</div>
104104
</div>
105105
</div>
@@ -115,6 +115,24 @@ class="fa fa-list"></i> List</a>
115115
</div>
116116
</div>
117117

118+
<div class="modal fade" id="fileViewModal" tabindex="-1" role="dialog" aria-labelledby="fileLabel" aria-hidden="true">
119+
<div class="modal-dialog">
120+
<div class="modal-content">
121+
<div class="modal-header">
122+
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
123+
aria-hidden="true">&times;</span></button>
124+
<h4 class="modal-title" id="fileLabel">View Fiile</h4>
125+
</div>
126+
<div class="modal-body" id="fileview_body">
127+
128+
</div>
129+
<div class="modal-footer">
130+
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
131+
</div>
132+
</div>
133+
</div>
134+
</div>
135+
118136
<script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
119137
<script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
120138
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
@@ -154,6 +172,7 @@ function showResponse(responseText, statusText, xhr, $form) {
154172
if (responseText != "OK"){
155173
notify(responseText);
156174
}
175+
$("#file_to_upload").val('');
157176
loadImages();
158177
}
159178
@@ -243,6 +262,7 @@ function trash(x) {
243262
if (data != "OK") {
244263
notify(data);
245264
} else {
265+
loadFiles();
246266
loadImages();
247267
}
248268
});
@@ -251,7 +271,6 @@ function trash(x) {
251271
}
252272
253273
254-
255274
function loadFiles() {
256275
$.ajax({
257276
type: "GET",
@@ -267,8 +286,6 @@ function loadFiles() {
267286
});
268287
}
269288
270-
271-
272289
function cropImage(x) {
273290
$.ajax({
274291
type: "GET",
@@ -374,11 +391,11 @@ function notify(x) {
374391
bootbox.alert(x);
375392
}
376393
377-
function scaleImage(x) {
394+
function resizeImage(x) {
378395
$.ajax({
379396
type: "GET",
380397
dataType: "text",
381-
url: "/laravel-filemanager/scale",
398+
url: "/laravel-filemanager/resize",
382399
data: "img="
383400
+ x
384401
+ "&dir=" + $("#working_dir").val(),
@@ -398,6 +415,13 @@ function scaleImage(x) {
398415
$("#show_list").val(1);
399416
loadImages();
400417
});
418+
419+
function fileView(x){
420+
$('#fileview_body').html(
421+
"<img class='img img-responsive' src='{!! Config::get('lfm.images_url') !!}" + $("#working_dir").val() + "/" + x + "'>"
422+
);
423+
$('#fileViewModal').modal();
424+
}
401425
</script>
402426
</body>
403427
</html>
Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
</tbody>
4040
</table>
4141

42-
<button class="btn btn-primary" onclick="doScale()">Scale</button>
42+
<button class="btn btn-primary" onclick="doResize()">Resize</button>
4343
<button class="btn btn-info" onclick="loadImages()">Cancel</button>
4444

4545
<input type="hidden" name="ratio" value="{!! $ratio !!}"><br>
@@ -70,25 +70,27 @@
7070
});
7171
});
7272
73-
function performScale() {
73+
function doResize() {
7474
7575
$.ajax({
7676
type: "GET",
7777
dataType: "text",
78-
url: "/laravel-filemanager/cropimage",
78+
url: "/laravel-filemanager/doresize",
7979
data: {
80-
img: $("#img").val(),
80+
img: '{!! $img !!}',
8181
dir: $("#dir").val(),
8282
dataX: $("#dataX").val(),
8383
dataY: $("#dataY").val(),
84-
dataHeight: $("#dataHeight").val(),
85-
dataWidth: $("#dataWidth").val()
84+
dataHeight: $("#height").val(),
85+
dataWidth: $("#width").val()
8686
},
8787
cache: false
8888
}).done(function (data) {
89-
loadImages();
89+
if (data == "OK") {
90+
loadImages();
91+
} else {
92+
notify(data);
93+
}
9094
});
91-
92-
//$("#cropForm").submit();
9395
}
9496
</script>

0 commit comments

Comments
 (0)