Skip to content
This repository has been archived by the owner on May 22, 2020. It is now read-only.

Added new configuration options that allow specifying which attribute… #276

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

chasepeeler
Copy link

A few simple changes:
1.) allows users to specify alternate attributes to use for the data source, title, and footer. These still default to data-remote, data-title, and data-footer, so it won't break anything.

I have images where the src is a dataUrl. I found that I was having to store the string twice, once in the src attribute, and once in the data-remote attribute. With these updates, I can just specify that the data is in the src attribute:
$(myImage).ekkoLightbox({dataSrc: "src"});

2.) I created a new method called _getAttr(element,attr). If the attribute starts with data-, it'll use $(element).data(), otherwise it'll use $(element).attr().

Users should expect that they can manipulate the values in the data- attributes using the data method. Since data-remote was being accessed directly, any updates made via .data('remote',someUrl); would not get picked up by lightbox. This new method allows accessing the data- attributes via the data method, but, still allows accessing non-data attributes via attr, in order to support the update above for allowing alternate attributes to be specified as the sources for various items.

@chasepeeler
Copy link
Author

chasepeeler commented Oct 25, 2017

Made another small update that allows specifying a callback to use for the dataSrc, titleSrc, or footerSrc elements.

$(img).ekkoLightbox(
    {
        dataSrc: 'src',
        footerSrc: function(){
            return $(this).data('description').trim() || $(this).data('name');
        }
    }
);

@chasepeeler
Copy link
Author

Just made another update to remove a console.log that I left in by accident. While I was at it, I went ahead and squashed my commits.

…s are used for the data source, footer, and title.

Options can be the name of attributes or callbacks.

Added a method called _getAttr which will use the .data method if the attribute starts with data-, otherwise the .attr method.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant