开发者

How can I automatically toggle showinfo in jQuery Galleria plugin?

开发者 https://www.devze.com 2023-03-12 23:25 出处:网络
I can\'t seem to find this documented anywhere. Basically I just want to have the caption automatically be displa开发者_如何学编程yed throughout the slideshow...

I can't seem to find this documented anywhere. Basically I just want to have the caption automatically be displa开发者_如何学编程yed throughout the slideshow...

Thanks in advance...


Assuming you are using the Classic theme:

$('#gallery').galleria({
    _toggleInfo: false
});

http://galleria.aino.se/docs/1.2/themes/classic/


I wanted to have the caption displayed automatically when the galleria is loaded, but not switch of the toggle button which can hide the caption again. (I am not sure though if this was what Logan wanted).

The solution proposed by rodbot seemed to be what what I was looking for.

But just to complete his proposal - do not forget to ensure, that you trigger the click AFTER the galleria is loaded. As documented on http://galleria.aino.se/docs/1.2/references/extending/ - to do that, you must place the clicking logic inside "extend: function(options)". I am also using more "fancier" Galleria.get(0).$('info-link') to get the element.

Complete example:

$("#gallery").galleria({
    width: 661,
    height: 661,
    extend: function(options) {
        Galleria.get(0).$('info-link').click();
    }
});

Just placing the "$(".galleria-info-link").click()" after the script with galleria loading did not work for me, because the element for displaying the caption (which we want to click) is not yet created.

Hopefully this can save someone a few minutes of googling which I needed to find this solution :-)


If you are using Drupal, here is how you do it once you get Galleria set up properly. I'll assume you're running the Classic theme (same strategy likely works for other themes).

In your sites/all/libraries/galleria/themes/classic folder, you'll see two .js files:

  • galleria.classic.js
  • galleria.classic.min.js

Drupal naturally points to the galleria.classic.min.js file. While the code is different between the two .js files, their implementation is similar. Therefore a simple strategy is to do the following:

  1. Delete the galleria.classic.min.js
  2. Rename galleria.classic.js to galleria.classic.min.js.
  3. Search for _toggleInfo: true and change it to _toggleInfo: false.

If you want you can further theme the Galleria. Just recognize if you upgrade to a newer verision of Galleria you'll have to reimplement you changes, so it might be good to keep a changelog. Also as a sidenote, some people might prefer to make these changes in the original galleria.classic.min.js -- I prefer not to because it's confusing to read.

EDIT: If you decide to use Michael Aron's approach, here is what belongs in your new galleria.classic.min.js file. (v 1.2.7)

defaults: {
    transition: 'slide',
    thumbCrop:  'height',

    // set this to false if you want to show the caption all the time:
    _toggleInfo: true,

    extend: function(options) {
        Galleria.get(0).$('info-link').click();
    }
},


To show the caption automatically, try triggering a click event in jQuery:

$(".galleria-info-link").click()


Here is the solution (using jQuery) to have the caption displayed by default and still have the "X" to close it:

Galleria.ready(function () {
    $(".galleria-info-close").click();
});
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号