jackmoore/colorbox — pull request #461 by xfra35 (2013-06-21 14:04:16+00:00)
Title: Bugfix loading overlay/graphic order

Hi Jack,

Thanks for your plugin. It is excellent!

I bring here a small contribution to fix a bug which appears on Mac Safari with colorbox v1.4.22: the loading overlay elements are inserted in the wrong order in the DOM:
```

```
As a result, the loading gif is hidden behind the overlay.

After looking at your code, it appears that you use the jQuery `add()` function, which doesn't guarantee the elements order. Taken from the [doc](http://api.jquery.com/add/):
> Do not assume that this method appends the elements to the existing collection in the order they are passed to the .add() method. [...] If the collection consists of elements [...] not in any document, the sort order is **undefined**. To create a jQuery object with elements in a well-defined order, use the $(array_of_DOM_elements) signature.

Regards.