Kris-B / nanoGALLERY

image gallery simplified - jQuery plugin. Touch enabled, responsive, justified/cascading/grid layout and it supports pulling in Flickr, Google Photos and self hosted images.
https://nanogallery2.nanostudio.org/
439 stars 101 forks source link

Reload current album #64

Closed R-II closed 9 years ago

R-II commented 9 years ago

Hi Kris,

Thanks for your work! I'm glad you've added the JSON feature, but I needed a way to dynamically reload the album.

How it works :

$('#my_gallery').nanoGallery({...});         // Load nanoGallery normally 
$('#my_gallery').nanoGallery('refresh');     // Use the refresh method

Do not hesitate to let me know if you find anything wrong ;-)

Raph

Kris-B commented 9 years ago

Hey Raph!

I just checked quickly your PR, and couldn't find anything wrong ;-) Just 2 points:

Many thanks for this PR! Kris

R-II commented 9 years ago

Thanks for merging !

Concerning removed files, yes, I'll need it too, but I don't know when I'll have the time to do this. Concerning the syntax, you're the boss. I tried to use a common syntax on jQuery widgets (like that : http://api.jqueryui.com/button/), but I'm not an expert.

Raph

Kris-B commented 9 years ago

I made some changes to your code: your feature is now in the new API method reload(). Usage example: $().nanoGallery().reload();

Changes are up to date in the jquery.nanogallery.js file in this repo, but it will be released later with some other features. I will add the support of deleted images, and the method will also be extended for flickr and picasa images.

Thanks for your code!

R-II commented 9 years ago

Hi Kris,

If I understand correctly, your idea is to make this kind of syntax usable :

$("#mydiv")
    .nanoGallery()
    .setJsonProvider('myAlbum.json')
    .reload();

That makes sense. The other possibility would have been to write something like this :

$("#mydiv")
    .nanoGallery("option","jsonProvider","myAlbum.json")
    .nanoGallery("reload");

or

$("#mydiv")
    .nanoGallery({"jsonProvider":"myAlbum.json"})
    .nanoGallery("reload");

For now, I still don't know which one is the best. If you prefer the first one, you are still able to add a getOwner() method at the end, which returns the initial jQuery object $("#mydiv");

$("#mydiv")
    .nanoGallery()
    .setJsonProvider('myAlbum.json')
    .reload()
    .getOwner()
    .closest("h1")
    .text("My Album");

Maybe it would be clearer to write this :

$("#mydiv")
    .nanoGallery("option","jsonProvider","myAlbum.json")
    .nanoGallery("reload")
    .closest("h1")
    .text("My Album");

Concerning the last commit, maybe I have missed something, but when I execute in the console the following code :

// Assuming that nanoGallery is initialized with a jsonProvider on $("#pictures_list")
$("#pictures_list").nanoGallery().reload();

The console returns :

ReferenceError: ReloadJson is not defined

This appends on Firefox 35 and Chrome 39. Any idea?

I've seen a "RealoadJson" private method in the nanoGALLERY() class, it might be a typo and/or a scope problem.

For now, I keep working on my last version, I'll merge my code with your future work.

I am now working on a way to make photos selectable, with a public method that returns the array of the selected photos. The idea is to be able to call an ajax with that array to apply a treatment on one or several photos (delete, enhance, zip and download, send, move to another album, etc.)

Raph