This repository was archived by the owner on May 22, 2020. It is now read-only.
Added new configuration options that allow specifying which attribute…#276
Open
chasepeeler wants to merge 1 commit intoashleydw:masterfrom
Open
Added new configuration options that allow specifying which attribute…#276chasepeeler wants to merge 1 commit intoashleydw:masterfrom
chasepeeler wants to merge 1 commit intoashleydw:masterfrom
Conversation
Author
|
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');
}
}
); |
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.