Permalink
Browse files

feature(lightbox): More sensible handling of href options

If an elgg-lightbox element has no href/src properties, {href:null} is no
longer passed to colorbox. Also, if data-colorbox-opts has an href, it
overrides the element’s href/src.
  • Loading branch information...
mrclay committed May 13, 2015
1 parent 1fc3502 commit 765fcd0563239b76b1b2a0bb0c0d3d5d719edf63
Showing with 6 additions and 2 deletions.
  1. +6 −2 views/default/js/lightbox.php
@@ -88,14 +88,18 @@ function registerDeprecationError() {
var $this = $(this),
href = $this.prop('href') || $this.prop('src'),
dataOpts = $this.data('colorboxOpts');
// Q: why not use "colorbox"? A: https://github.com/jackmoore/colorbox/issues/435
// Note: data-colorbox was reserved https://github.com/jackmoore/colorbox/issues/435
if (!$.isPlainObject(dataOpts)) {
dataOpts = {};
}
if (!dataOpts.href && href) {
dataOpts.href = href;
}
// merge data- options into opts
$.colorbox($.extend({href: href}, opts, dataOpts));
$.colorbox($.extend({}, opts, dataOpts));
e.preventDefault();
});
};

0 comments on commit 765fcd0

Please sign in to comment.