Slideshow will not close if started directly from image link.
From @setnes on November 2, 2015 4:59
I didn't notice this when we worked on the back button / slideshow close logic. This is a subtle annoyance related to linking to images inside a shared link folder.
Here are the steps to reproduce this issue.
Share a directory using a link. You will have a link that looks like this... https://files.example.com/index.php/apps/gallery/s/mAg1cT3xT
Now navigate to an image within that folder. Your link now looks like this... https://files.example.com/index.php/apps/gallery/s/mAg1cT3xT#example.jpg
If you hit the slideshow X button from here everything works, but if you share this link (or open it in a new browser), the X button will not work.
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
Copied from original issue: owncloud/gallery#460
Ah yes, it's probably because there is no history if you share the link directly... Not sure how to fix this.
Maybe I can test to see if the domain is in the history already...
From @setnes on November 8, 2015 0:42
I played around with the _exit function in slideshowcontrols.js. This is very much a brute force hack, so there's no pull request yet. It reloads the page (bad). It parses the page URL (bad). It does what I want (good).
_exit: function () {
// Only modern browsers can manipulate history
if (history && history.replaceState) {
if (window.history.length === 1) {
// We have nothing to go back to. Drop the image from the URL and reload the page.
window.location.assign( window.location.href.slice(0,window.location.href.lastIndexOf(this.images[this.current].name)) );
} else {
// We simulate a click on the back button in order to be consistent
window.history.back();
}
} else {
// For ancient browsers supported in core
this.stop();
}
},
From @setnes on November 8, 2015 0:54
There's a much easier way to do this. It was right under my nose. It looks like this.stop() can be called when there is not enough history to use back(); Now it's more of a one line change to the IF condition... and maybe a comment change. :smile:
_exit: function () {
// Only modern browsers can manipulate history
if (history && history.replaceState && window.history.length > 1) {
// We simulate a click on the back button in order to be consistent
window.history.back();
} else {
// For ancient browsers supported in core
this.stop();
}
},