【问题标题】:How to implement (Noty) jquery notification in wordpress site [closed]如何在wordpress网站中实现(Noty)jquery通知[关闭]
【发布时间】:2015-10-20 15:35:53
【问题描述】:

我是 jquery 世界的新手。我不知道如何在 wordpress 网站中实现“Noty - Notification”插件,如何创建通知和动画等。 文档不包括帮助文件

这些是插件的内容

  • 布局 [FOLDER](包括bottom.js、bottomleft.js、top.js、topright.js 等文件...

  • 打包 [FOLDER](包括两个文件 jquery.noty.packaged.js 和 jquery.noty.packaged.min.js)

  • 主题 [FOLDER](包括 bootstrap.js、defalut.js 和 Relax.js)

  • jquery.noty.js [文件]

  • promise.js [文件]

【问题讨论】:

    标签: javascript jquery wordpress notifications noty


    【解决方案1】:

    文档不包含示例? http://ned.im/noty/#/about 再检查一遍.. 确实如此。

    noty({text: 'magic'});

    // never use eval unless you know what you do. just try this snippet to see some
    // examples in how you can use this.
    // for demonstration purposes i simply added the actual code to the buttons visible text.
    $("button").click(function(){eval($(this).text())})
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-noty/2.3.7/packaged/jquery.noty.packaged.min.js"></script>
    <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.4.0/animate.min.css">
    <button>
        noty({text: "Hello World!"});
    </button><br>
    <button>
        noty({text: "message on top right", layout: "topRight"});
    </button><br>
    <button>
        noty({text: "message on bottom", layout: "bottom"});
    </button><br>
    <button>
        noty({text: "error!", type: "error", layout: "topRight"});
    </button><br>
    <button>
        noty({
            text: "this will disappear after 4 seconds",
            type: "error", layout: "topRight", timeout: 4000, 
            animation: {
                open: 'animated bounceInRight', // in order to use this you'll need animate.css
                close: 'animated bounceOutRight',
                easing: 'swing',
                speed: 500
            }
        });
    </button>

    这些是默认选项:

    $.noty.defaults = {
        layout: 'top',
        theme: 'defaultTheme', // or 'relax'
        type: 'alert',
        text: '', // can be html or string
        dismissQueue: true, // If you want to use queue feature set this true
        template: '<div class="noty_message"><span class="noty_text"></span><div class="noty_close"></div></div>',
        animation: {
            open: {height: 'toggle'}, // or Animate.css class names like: 'animated bounceInLeft'
            close: {height: 'toggle'}, // or Animate.css class names like: 'animated bounceOutLeft'
            easing: 'swing',
            speed: 500 // opening & closing animation speed
        },
        timeout: false, // delay for closing event. Set false for sticky notifications
        force: false, // adds notification to the beginning of queue when set to true
        modal: false,
        maxVisible: 5, // you can set max visible notification for dismissQueue true option,
        killer: false, // for close all notifications before show
        closeWith: ['click'], // ['click', 'button', 'hover', 'backdrop'] // backdrop click will close all notifications
        callback: {
            onShow: function() {},
            afterShow: function() {},
            onClose: function() {},
            afterClose: function() {},
            onCloseClick: function() {},
        },
        buttons: false // an array of buttons
    };
    

    【讨论】:

    • 有demo文件夹。在哪些示例中有效,但我不知道如何在站点中实现它们。我想在我的主页上显示通知,因为它出现在ned.im/noty/#about
    • @FarrukhJavaid 只是尝试运行我的代码 sn-p。如果你仍然不知道如何使用 noty,你可能想先学习 javascript。我所做的就是浏览我提供给您的网址。
    • 感谢您的回复,我得到的正是我想要显示的内容,但它在cdn.frkmusic.info/static/usingWithAnimate.css.html 页面上,我想在主页加载时自动显示在网站主页上。在这件事上你能帮我更多吗?我怎样才能做到这一点。 cdn.frkmusic.info/static中可以看到我上传了哪些文件
    • 当我将此代码添加到主题选项中的附加 CSS 和附加 JavaScript 时,代码不起作用。我已禁用缓存和 cloudflare。有什么解决办法吗?
    • 这个答案现在特别有用,因为 ned.im 已关闭(似乎域已过期)
    猜你喜欢
    • 2023-04-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-07
    • 2019-06-03
    • 1970-01-01
    • 2012-02-23
    • 2016-04-04
    相关资源
    最近更新 更多