Skip to content
This repository has been archived by the owner on May 7, 2019. It is now read-only.

Commit

Permalink
Add image previews on thumbnail hover
Browse files Browse the repository at this point in the history
  • Loading branch information
TheReverend403 committed Jul 3, 2016
1 parent cab5d28 commit 9cc40de
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 9 deletions.
16 changes: 11 additions & 5 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,14 @@ elixir(function(mix) {
'error.scss'
], 'public/assets/css/error.css');

mix.sass('thumbnailhover.scss', 'public/assets/css/thumbnailhover.css');

mix.styles([
'../../../node_modules/dropzone/dist/basic.css'
], 'public/assets/css/dropzone.css');

mix.scripts('thumbnailhover.js', 'public/assets/js/thumbnailhover.js');

mix.scripts([
'../../../node_modules/dropzone/dist/dropzone.js',
'dropzone.js'
Expand All @@ -44,11 +48,13 @@ elixir(function(mix) {
], 'public/assets/js/global.js');

mix.version([
"assets/css/global.css",
"assets/css/error.css",
"assets/css/dropzone.css",
"assets/js/global.js",
"assets/js/dropzone.js",
'assets/css/global.css',
'assets/css/error.css',
'assets/js/thumbnailhover.js',
'assets/css/thumbnailhover.css',
'assets/css/dropzone.css',
'assets/js/global.js',
'assets/js/dropzone.js',
'assets/img/favicon.png',
'assets/img/thumbnail.png'
]);
Expand Down
40 changes: 40 additions & 0 deletions resources/assets/js/thumbnailhover.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Image preview script
* powered by jQuery (http://www.jquery.com)
*
* written by Alen Grakalic (http://cssglobe.com)
*
* for more info visit http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery
*
*/

this.imagePreview = function(){

xOffset = 10;
yOffset = 30;

$("a.preview").hover(function(e){
this.t = this.title;
this.title = "";
var c = (this.t != "") ? "<br/>" + this.t : "";
$("body").append("<p id='preview'><img src='"+ this.href +"' alt='Image preview' />"+ c +"</p>");
$("#preview")
.css("top",(e.pageY - xOffset) + "px")
.css("left",(e.pageX + yOffset) + "px")
.css("z-index", 1000)
.fadeIn("fast");
},
function(){
this.title = this.t;
$("#preview").remove();
});
$("a.preview").mousemove(function(e){
$("#preview")
.css("top",(e.pageY - xOffset) + "px")
.css("left",(e.pageX + yOffset) + "px");
});
};

$(document).ready(function(){
imagePreview();
});
8 changes: 8 additions & 0 deletions resources/assets/sass/thumbnailhover.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#preview {
position: absolute;
border: 1px solid #ccc;
background: #333;
padding: 5px;
display: none;
color: #fff;
}
12 changes: 10 additions & 2 deletions resources/views/account/uploads.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

@section('title', 'My Uploads')

@section('stylesheets')
<link href="{{ elixir('assets/css/thumbnailhover.css') }}" rel="stylesheet">
@stop

@section('content')
@if(count($uploads))
@foreach ($uploads->chunk(2) as $chunk)
Expand All @@ -12,8 +16,8 @@
<div class="panel-body">
<div class="media">
<div class="media-left hidden-sm hidden-xs">
<a href="{{ route('files.get', $upload) }}">
<img src="{{ $upload->getThumbnailUrl() }}" class="img-thumbnail" alt="{{ $upload->original_name }}">
<a href="{{ route('files.get', $upload) }}" class="preview">
<img src="{{ $upload->getThumbnailUrl() }}" class="img-thumbnail" title="{{ $upload->original_name }}" alt="{{ $upload->original_name }}">
</a>
</div>
<div class="media-body">
Expand Down Expand Up @@ -51,3 +55,7 @@
</div>
@endif
@stop

@section('javascript')
<script src="{{ elixir('assets/js/thumbnailhover.js') }}" type="application/javascript"></script>
@endsection
12 changes: 10 additions & 2 deletions resources/views/admin/uploads.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

@section('title', 'AdminCP - Uploads')

@section('stylesheets')
<link href="{{ elixir('assets/css/thumbnailhover.css') }}" rel="stylesheet">
@stop

@section('content')
@if($uploads->count())
<div class="text-center">
Expand All @@ -17,8 +21,8 @@
<div class="panel-body">
<div class="media">
<div class="media-left hidden-sm hidden-xs">
<a href="{{ route('files.get', $upload) }}">
<img src="{{ $upload->getThumbnailUrl() }}" class="img-thumbnail" alt="{{ $upload->original_name }}">
<a href="{{ route('files.get', $upload) }}" class="preview">
<img src="{{ $upload->getThumbnailUrl() }}" class="img-thumbnail" title="{{ $upload->original_name }}" alt="{{ $upload->original_name }}">
</a>
</div>
<div class="media-body">
Expand Down Expand Up @@ -56,3 +60,7 @@
</div>
@endif
@stop

@section('javascript')
<script src="{{ elixir('assets/js/thumbnailhover.js') }}" type="application/javascript"></script>
@endsection

0 comments on commit 9cc40de

Please sign in to comment.