n33/jquery.poptrox — pull request #16 by joshuaboshi (2014-12-16 17:42:30+00:00)
Title: Make jquery.poptrox work on galleries which are dynamically modified via DOM

This pull request is changing how gallery entries are initialized and opened.

Orignally, each gallery entry was loaded to a plugin variable and onclick handler was attached to it (anchor node) during the initialization step.
This effectively disallowed further dynamic modifications of the gallery via DOM (adding more entries to the gallery, changing the captions etc.).

With commits in this PR, onclick handler is only attached to the gallery container (`$('#gallery').poptrox();`) as a delegate. Meaning that whenever any link (`settings.selector`) is clicked, the event bubbles up to the container, where it is handled.

To implement this, I had removed the `queue`, which was prefilled during the initialization orignally. The JS representation of a gallery entry is now being built everytime the entry is clicked (see the function `open`).

`poptrox_next` and `poptrox_previous` are now reading the entries from DOM on every invocation to take into account any changes in gallery.

Let me know if there are any things to discuss!

Best regards,
Tomas

**Notes:**
* I have tested it on `demo/demo1.html` + some other configuration options
* I have renamed some ambiguous variables on the way of understanding the code
* I have minified the source with [UglifyJS2](https://github.com/mishoo/UglifyJS2) version 2.3.6