Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slideshow will not close if started directly from image link. #460

Closed
setnes opened this issue Nov 2, 2015 · 4 comments
Closed

Slideshow will not close if started directly from image link. #460

setnes opened this issue Nov 2, 2015 · 4 comments

Comments

@setnes
Copy link
Contributor

setnes commented Nov 2, 2015

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.

@oparoz
Copy link
Contributor

oparoz commented Nov 2, 2015

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...

@setnes
Copy link
Contributor Author

setnes commented Nov 8, 2015

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();
  }

},

@setnes
Copy link
Contributor Author

setnes commented Nov 8, 2015

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. 😄

 _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();
  }

},

@oparoz
Copy link
Contributor

oparoz commented Sep 4, 2016

This issue was moved to nextcloud/gallery#102

@oparoz oparoz closed this as completed Sep 4, 2016
@oparoz oparoz removed the in progress label Sep 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants