Skip to content
This repository has been archived by the owner on Nov 14, 2018. It is now read-only.

use slideshow as image preview in files & public shares #1123

Merged
merged 3 commits into from
May 25, 2013
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions gallery/appinfo/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,15 @@
'name' => $l->t('Pictures'))
);

// make slideshow available in files and public shares
OCP\Util::addScript('gallery', 'jquery.mousewheel-3.1.1');
OCP\Util::addScript( 'gallery', 'slideshow' );
OCP\Util::addStyle( 'gallery', 'slideshow' );

// register filesystem hooks to update thumbnails
OCP\Util::connectHook('OC_Filesystem', 'post_write', 'OCA\Gallery\Thumbnail', 'writeHook');
OCP\Util::connectHook('OC_Filesystem', 'post_delete', 'OCA\Gallery\Thumbnail', 'removeHook');

// register share backend
OCP\Share::registerBackend('picture', 'OCA\Gallery\Share\Picture', null, array('gif', 'jpeg', 'jpg', 'png', 'svg', 'svgz'));
OCP\Share::registerBackend('gallery', 'OCA\Gallery\Share\Gallery', 'picture');
101 changes: 101 additions & 0 deletions gallery/css/slideshow.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@

#slideshow {
position: fixed;
left: 0;
top: 0;
width: 100%;
height: 100%;
z-index: 1000;
display: none;
background-color: black;
background-repeat: no-repeat;
background-image: url("../img/progress.gif");
background-size: 16px 16px;
background-position: center center;
}

#slideshow>img {
position: relative;
vertical-align: middle;
display: block;
margin-left: auto;
margin-right: auto;
}

#slideshow > input {
background: none;
border: 0 transparent;
outline: 0;
box-shadow: none;
width: 52px;
height: 52px;
position: absolute;
z-index: 1100;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=30)";
filter: alpha(opacity=30);
opacity: .3;
background-position: center center;
background-repeat: no-repeat;
}

#slideshow > * {
-webkit-transition: opacity 300ms;
-moz-transition: opacity 300ms;
-o-transition: opacity 300ms;
transition: opacity 300ms;
}

#slideshow > input:hover {
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=60)";
filter: alpha(opacity=60);
opacity: .6;
}

#slideshow > .next, #slideshow > .previous {
top: 50%;
margin-top: -21px;
}

#slideshow > .next {
right: 0;
background-image: url("%webroot%/core/img/actions/view-next.svg");
}

#slideshow > .previous {
left: 0;
background-image: url("%webroot%/core/img/actions/view-previous.svg");
}

#slideshow > .exit {
right: 0;
top: 0;
background-image: url("%webroot%/core/img/actions/view-close.svg");
}

#slideshow > .pause, #slideshow > .play {
bottom: 0;
right: 0;
margin-top: -21px;
}

#slideshow > .play {
display: none;
background-image: url("%webroot%/core/img/actions/view-play.svg");
}

#slideshow > .pause {
background-image: url("%webroot%/core/img/actions/view-pause.svg");
}

#slideshow > .progress {
position: fixed;
bottom: 10px;
right: 10px;
background-position: 0 100%;
width: 32px;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=30)";
background-image: url("%webroot%/core/img/actions/view-pause.svg");
filter: alpha(opacity=30);
opacity: .3;
height: 0;
}
103 changes: 1 addition & 102 deletions gallery/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -66,105 +66,4 @@ button.share {
right: 0;
margin-right: 0;
border-bottom-right-radius: 0;
}

#slideshow {
position: fixed;
left: 0;
top: 0;
width: 100%;
height: 100%;
z-index: 1000;
display: none;
background-color: black;
background-repeat: no-repeat;
background-image: url("../img/progress.gif");
background-size: 16px 16px;
background-position: center center;
}

#slideshow>img {
position: relative;
vertical-align: middle;
display: block;
margin-left: auto;
margin-right: auto;
}

#slideshow > input {
background: none;
border: 0 transparent;
outline: 0;
box-shadow: none;
width: 52px;
height: 52px;
position: absolute;
z-index: 1100;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=30)";
filter: alpha(opacity=30);
opacity: .3;
background-position: center center;
background-repeat: no-repeat;
}

#slideshow > * {
-webkit-transition: opacity 300ms;
-moz-transition: opacity 300ms;
-o-transition: opacity 300ms;
transition: opacity 300ms;
}

#slideshow > input:hover {
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=60)";
filter: alpha(opacity=60);
opacity: .6;
}

#slideshow > .next, #slideshow > .previous {
top: 50%;
margin-top: -21px;
}

#slideshow > .next {
right: 0;
background-image: url("%webroot%/core/img/actions/view-next.svg");
}

#slideshow > .previous {
left: 0;
background-image: url("%webroot%/core/img/actions/view-previous.svg");
}

#slideshow > .exit {
right: 0;
top: 0;
background-image: url("%webroot%/core/img/actions/view-close.svg");
}

#slideshow > .pause, #slideshow > .play {
bottom: 0;
right: 0;
margin-top: -21px;
}

#slideshow > .play {
display: none;
background-image: url("%webroot%/core/img/actions/view-play.svg");
}

#slideshow > .pause {
background-image: url("%webroot%/core/img/actions/view-pause.svg");
}

#slideshow > .progress {
position: fixed;
bottom: 10px;
right: 10px;
background-position: 0 100%;
width: 32px;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=30)";
background-image: url("%webroot%/core/img/actions/view-pause.svg");
filter: alpha(opacity=30);
opacity: .3;
height: 0;
}
}
1 change: 0 additions & 1 deletion gallery/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
OCP\App::setActiveNavigationEntry('gallery_index');

OCP\Util::addScript('gallery', 'gallery');
OCP\Util::addScript('gallery', 'slideshow');
OCP\Util::addScript('gallery', 'thumbnail');
OCP\Util::addStyle('gallery', 'styles');

Expand Down
97 changes: 7 additions & 90 deletions gallery/js/gallery.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ Gallery.share = function (event) {
event.preventDefault();
event.stopPropagation();
Gallery.getAlbumInfo(Gallery.currentAlbum).then(function (info) {
$('a.share').data('item', info.fileid)
$('a.share').data('item', info.fileid).data('link', true)
.data('possible-permissions', info.permissions).
click();
});
Expand Down Expand Up @@ -280,105 +280,22 @@ Gallery.view.showUsers = function () {
}
};

Gallery.slideshow = {};
Gallery.scrollLocation = 0;
Gallery.slideshow.start = function (start, options) {
var content = $('#content');
start = start || 0;
Thumbnail.concurrent = 1; //make sure we can load the image and doesn't get blocked by loading thumbnail
if (content.is(":visible")) {
Gallery.scrollLocation = $(window).scrollTop();
}
$('a.image').slideShow($('#slideshow'), start, options);
content.hide();
};

Gallery.slideshow.end = function () {
jQuery.fn.slideShow.stop();
};

Gallery.slideshow.next = function (event) {
if (event) {
event.stopPropagation();
}
jQuery.fn.slideShow.hideImage();
jQuery.fn.slideShow.next();
};

Gallery.slideshow.previous = function (event) {
if (event) {
event.stopPropagation();
}
jQuery.fn.slideShow.hideImage();
jQuery.fn.slideShow.previous();
};

Gallery.slideshow.pause = function (event) {
if (event) {
event.stopPropagation();
}
$('#slideshow').children('.play').show();
$('#slideshow').children('.pause').hide();
Gallery.slideshow.playPause.playing = false;
jQuery.fn.slideShow.pause();
};

Gallery.slideshow.play = function (event) {
if (event) {
event.stopPropagation();
}
$('#slideshow').children('.play').hide();
$('#slideshow').children('.pause').show();
Gallery.slideshow.playPause.playing = true;
jQuery.fn.slideShow.play();
};

Gallery.slideshow.playPause = function () {
if (Gallery.slideshow.playPause.playing) {
Gallery.slideshow.pause();
} else {
Gallery.slideshow.play();
}
};
Gallery.slideshow.playPause.playing = true;

$(document).ready(function () {
Gallery.fillAlbums().then(function () {
Gallery.view.element = $('#gallery');
OC.Breadcrumb.container = $('#breadcrumbs');
window.onhashchange()

//close slideshow on esc
$(document).keyup(function (e) {
if (e.keyCode === 27) { // esc
Gallery.slideshow.end();
} else if (e.keyCode == 37) { // left
Gallery.slideshow.previous();
} else if (e.keyCode == 39) { // right
Gallery.slideshow.next();
} else if (e.keyCode == 32) { // space
Gallery.slideshow.playPause();
}
});
var slideshow = $('#slideshow');
slideshow.children('.next').click(Gallery.slideshow.next);
slideshow.children('.previous').click(Gallery.slideshow.previous);
slideshow.children('.exit').click(jQuery.fn.slideShow.stop);
slideshow.children('.pause').click(Gallery.slideshow.pause);
slideshow.children('.play').click(Gallery.slideshow.play);
slideshow.click(Gallery.slideshow.next);

window.onhashchange();
$('button.share').click(Gallery.share);
});

$('#gallery').on('click', 'a.image', function (event) {
var i = $('#gallery').children('a.image').index(this),
var images = $('#gallery').children('a.image');
var i = images.index(this),
image = $(this).data('path');
event.preventDefault();
location.hash = image;
Gallery.slideshow.start(i, {play: Gallery.slideshow.playPause.playing});
Slideshow.start(images, i, {play: Slideshow.playPause.playing});
});
$('body').append($('#slideshow')); //move the slideshow outside the content so we can hide the content

jQuery.fn.slideShow.onstop = function () {
$('#content').show();
Expand All @@ -395,10 +312,10 @@ window.onhashchange = function () {
}
console.log(OC.dirname(album));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be removed ;)

if (Gallery.images.indexOf(album) === -1) {
Gallery.slideshow.end();
Slideshow.end();
Gallery.view.viewAlbum(album);
} else {
Gallery.view.viewAlbum(OC.dirname(album));
$('#gallery a.image[data-path="' + album + '"]').click();
//$('#gallery a.image[data-path="' + album + '"]').click();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commenting this out breaks some of the navigation within the gallery app using the back/foreward buttons

}
};