如何在 jQuery Galleria 插件中自动切换 showinfo?

发布于 2024-11-15 13:34:27 字数 64 浏览 6 评论 0原文

我似乎在任何地方都找不到这个记录。基本上我只是想让标题在整个幻灯片中自动显示...

提前致谢...

I can't seem to find this documented anywhere. Basically I just want to have the caption automatically be displayed throughout the slideshow...

Thanks in advance...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

弱骨蛰伏 2024-11-22 13:34:27

假设您使用的是经典主题:

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

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

Assuming you are using the Classic theme:

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

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

錯遇了你 2024-11-22 13:34:27

我希望在加载画廊时自动显示标题,而不是切换可以再次隐藏标题的切换按钮。 (但我不确定这是否是洛根想要的)。

rodbot 提出的解决方案似乎正是我正在寻找的。

但只是为了完成他的建议 - 不要忘记确保在加载画廊后触发点击。如 http://galleria.aino.se/docs/1.2/references/extending 上所述/ - 为此,您必须将点击逻辑放在“extend: function(options)”内。我还使用更多“更高级”的 Galleria.get(0).$('info-link') 来获取元素。

完整的示例:

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

仅将“$(”.galleria-info-link”).click()”放在带有画廊加载的脚本后面对我来说不起作用,因为用于显示标题的元素(我们要单击的)是尚未创建。

希望这可以节省某人几分钟的谷歌搜索时间,我需要找到这个解决方案:-)

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 :-)

酒几许 2024-11-22 13:34:27

如果您使用 Drupal,正确设置 Galleria 后,您可以按照以下步骤进行操作。我假设您正在运行经典主题(相同的策略可能适用于其他主题)。

在您的sites/all/libraries/galleria/themes/classic 文件夹中,您将看到两个.js 文件:

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

Drupal 自然指向galleria.classic.min.js 文件。虽然两个 .js 文件之间的代码不同,但它们的实现类似。因此,一个简单的策略是执行以下操作:

  1. 删除 galleria.classic.min.js
  2. 将 galleria.classic.js 重命名为 galleria.classic.min.js。
  3. 搜索 _toggleInfo: true 并将其更改为 _toggleInfo: false。

如果您愿意,您可以进一步主题化画廊。只需要认识到,如果您升级到较新版本的 Galleria,您将必须重新实现更改,因此保留更改日志可能会更好。另外,作为旁注,有些人可能更喜欢在原始的 galleria.classic.min.js 中进行这些更改——我不喜欢这样做,因为它读起来很混乱。

编辑:
如果您决定使用 Michael Aron 的方法,以下是新的 galleria.classic.min.js 文件中的内容。 (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();
    }
},

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();
    }
},
唔猫 2024-11-22 13:34:27

要自动显示标题,请尝试在 jQuery 中触发单击事件:

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

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

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

秋日私语 2024-11-22 13:34:27

这是默认显示标题并仍然有“X”来关闭它的解决方案(使用 jQuery):

Galleria.ready(function () {
    $(".galleria-info-close").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();
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文