以编程方式更改 Aino Galleria 主题

发布于 2024-12-02 21:17:00 字数 2682 浏览 2 评论 0原文

如何以编程方式更改 Aino Galleria 插件主题,例如...更改单选按钮选项?

我尝试过此方法但没有成功!

我按以下方式使用 Galleria:

<script src="@Url.Content("~/Scripts/JQuery.Galleria/1.2.5/galleria-1.2.5.min.js")" type="text/javascript"></script>
<script type="text/javascript">
    var virtualPath = '@Url.Content("~/")';

    $(document).ready(function () {
        Galleria.loadTheme(virtualPath + '/Scripts/jQuery.Galleria/1.2.5/themes/twelve/galleria.twelve.min.js');

        $("input[name='theme']").bind("click", themeSelected)

        // Initialize Galleria
        $('#galleria').galleria({ autoplay: false, /* true, miliseconds */
                                  thumbnails: true,  /*true, false, numbers, empty */
                                  imageCrop: true,  /*true, false, height, width */
                                  transition: "pulse",  /*fade, fadeslide, slide, flash, pulse */
                                  trasitionSpeed: 500,
                                  thumbFit: true

        });

    });

    function themeSelected() {
        if($(this).val() == "ca"){
            Galleria.loadTheme(virtualPath + '/Scripts/jQuery.Galleria/1.2.5/themes/classic/galleria.classic.min.js');
        }
        else if($(this).val() == "tw"){
            Galleria.loadTheme(virtualPath + '/Scripts/jQuery.Galleria/1.2.5/themes/twelve/galleria.twelve.min.js');
        }
    }


</script>
<div class="content">
    <h1>Galleria Twelve Theme</h1>
    <div id="galleryOptions">
        <label for="classic">Classic</label><input type="radio" name="theme" id="classic" value="ca" />
        <label for="folio">Folio</label><input type="radio" name="theme" id="folio" value="fo" />
        <label for="twelve">Twelve</label><input type="radio" name="theme" id="twelve" checked="checked" value="tw"/>
        <label for="miniml">Miniml</label><input type="radio" name="theme" id="miniml"  value="mi" />
        <label for="fullscreen">Fullscreen</label><input type="radio" name="theme" id="fullscreen" value="fu" />
    </div>

    <div id="galleria">
        <!-- My photo gallery -->
        <!-- ...  -->
        <!-- ...  -->
    </div>
</div>    

但我加载了不同的主题,我发现了几个错误,如“初始化失败:Gallery 实例已初始化”。

How to change the Aino Galleria plugin theme programmatically, say... changing a radio button option?

I´ve tried this method with no success!

I´m using Galleria in the following way:

<script src="@Url.Content("~/Scripts/JQuery.Galleria/1.2.5/galleria-1.2.5.min.js")" type="text/javascript"></script>
<script type="text/javascript">
    var virtualPath = '@Url.Content("~/")';

    $(document).ready(function () {
        Galleria.loadTheme(virtualPath + '/Scripts/jQuery.Galleria/1.2.5/themes/twelve/galleria.twelve.min.js');

        $("input[name='theme']").bind("click", themeSelected)

        // Initialize Galleria
        $('#galleria').galleria({ autoplay: false, /* true, miliseconds */
                                  thumbnails: true,  /*true, false, numbers, empty */
                                  imageCrop: true,  /*true, false, height, width */
                                  transition: "pulse",  /*fade, fadeslide, slide, flash, pulse */
                                  trasitionSpeed: 500,
                                  thumbFit: true

        });

    });

    function themeSelected() {
        if($(this).val() == "ca"){
            Galleria.loadTheme(virtualPath + '/Scripts/jQuery.Galleria/1.2.5/themes/classic/galleria.classic.min.js');
        }
        else if($(this).val() == "tw"){
            Galleria.loadTheme(virtualPath + '/Scripts/jQuery.Galleria/1.2.5/themes/twelve/galleria.twelve.min.js');
        }
    }


</script>
<div class="content">
    <h1>Galleria Twelve Theme</h1>
    <div id="galleryOptions">
        <label for="classic">Classic</label><input type="radio" name="theme" id="classic" value="ca" />
        <label for="folio">Folio</label><input type="radio" name="theme" id="folio" value="fo" />
        <label for="twelve">Twelve</label><input type="radio" name="theme" id="twelve" checked="checked" value="tw"/>
        <label for="miniml">Miniml</label><input type="radio" name="theme" id="miniml"  value="mi" />
        <label for="fullscreen">Fullscreen</label><input type="radio" name="theme" id="fullscreen" value="fu" />
    </div>

    <div id="galleria">
        <!-- My photo gallery -->
        <!-- ...  -->
        <!-- ...  -->
    </div>
</div>    

but I load a different theme I caught several errors as "Init failed: Gallery instance already initialized".

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

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

发布评论

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

评论(1

最笨的告白 2024-12-09 21:17:00

首次加载 Galleria 之前,您必须先加载主题。

这是你应该做的:

<!-- ADD THIS -- >
<script src="@Url.Content("~/Scripts/JQuery.Galleria/1.2.5/theme/twelve/galleria.twelve.min.js")" type="text/javascript"></script>
<!-- ADD THIS (end) -->
<script src="@Url.Content("~/Scripts/JQuery.Galleria/1.2.5/galleria-1.2.5.min.js")" type="text/javascript"></script>

$(document).ready(function () {
    <!-- REMOVE THIS because is preloaded on top -->
    Galleria.loadTheme(virtualPath + '/Scripts/jQuery.Galleria/1.2.5/themes/twelve/galleria.twelve.min.js');
    <!-- REMOVE THIS (end) -->

    <!-- other codes goes here -->
});

希望它有帮助。

You have to load the Theme first before you load Galleria for the first time.

Here's what you should do:

<!-- ADD THIS -- >
<script src="@Url.Content("~/Scripts/JQuery.Galleria/1.2.5/theme/twelve/galleria.twelve.min.js")" type="text/javascript"></script>
<!-- ADD THIS (end) -->
<script src="@Url.Content("~/Scripts/JQuery.Galleria/1.2.5/galleria-1.2.5.min.js")" type="text/javascript"></script>

$(document).ready(function () {
    <!-- REMOVE THIS because is preloaded on top -->
    Galleria.loadTheme(virtualPath + '/Scripts/jQuery.Galleria/1.2.5/themes/twelve/galleria.twelve.min.js');
    <!-- REMOVE THIS (end) -->

    <!-- other codes goes here -->
});

Hope it helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文