Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding custom buttons #420

Closed
tpaksu opened this issue Aug 9, 2016 · 9 comments
Closed

Adding custom buttons #420

tpaksu opened this issue Aug 9, 2016 · 9 comments

Comments

@tpaksu
Copy link

tpaksu commented Aug 9, 2016

Hello,

Can we add custom buttons to the top controls bar and then binding callbacks to the new buttons in this gallery? For example, I want pagination in my gallery and I want to display page links on the button bar. When I click one of them, I'll make a new dynamic request and show a new lightGallery with the new information.

@mdod
Copy link

mdod commented Aug 9, 2016

You can add buttons in the lightgallery.js file here
screen shot 2016-08-09 at 4 26 50 pm

@tpaksu
Copy link
Author

tpaksu commented Aug 10, 2016

Modifying the core would be a problem when updating the script. I'll try to create a plugin.

@ctf0
Copy link

ctf0 commented Sep 12, 2016

@tpaksu maybe u can instead use something like onAfterOpen.lg to add the new button after the gallery opens ?

@skar3
Copy link

skar3 commented Oct 26, 2016

A plugin will be very helpful

@rochapablo
Copy link

rochapablo commented Nov 3, 2016

I've found a good way to create your own plugin without alter the core.

(function($, window, document, undefined) {

    'use strict';

    // ...

    $.fn.lightGallery.modules.MyCode = MyCode;

})(jQuery, window, document);

In my case, I had add a new tab at the bottom, close to thumbs.

@skakraze5
Copy link

Here's an example of what @ctf0 suggested related to a feature I wanted with adding caption a toggle. I don't think it will fully help with everything original problem stated. But it was at least a way I found to add a custom items to the toolbar without having to make a full plugin.

$lg = $(strSelector);
$lg.lightGallery(oOptions);
$lg.on('onAfterOpen.lg',function(event){
   $('.lg-toolbar').append('<a class=\"lg-icon\" href=\"javascript:toggleCaption()\">CC</a>');
});

function toggleCaption() {
   var curVal = $('.lg-sub-html').css('visibility');
   $('.lg-sub-html').css('visibility', curVal == 'hidden' ? 'visible' : 'hidden');
}

@tpaksu
Copy link
Author

tpaksu commented Nov 7, 2016

@rochapablo I've done the same by creating a plugin. It just appends like @skakraze5 pointed out. I think it should be an official plugin.

@sachinchoolur
Copy link
Owner

Hi Guys,
Here is the documentation for creating lightGallery plugin.
Also, you can refer any of the simple existing lightGallery plugins such as fullscreen or autoplay

Sorry for the delayed response :)

@xmon
Copy link

xmon commented Dec 21, 2016

Hi, here a very basic plugin example ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants