izemize / yii2-noty

Yii小部件,用于Noty jQuery通知插件

维护者

详细信息

github.com/izemize/yii2-noty

源代码

安装: 1

依赖: 0

建议者: 0

安全性: 0

星级: 1

关注者: 1

分支: 4

类型:yii2-extension

v1.0.1 2016-01-10 09:21 UTC

This package is not auto-updated.

Last update: 2024-09-20 19:40:18 UTC


README

Yii2小部件,用于Noty jQuery通知插件,访问Noty

对于Yii1:请检查yii-noty

安装

安装此扩展的首选方法是通过composer

注意:以下说明针对全局composer安装。您可能需要将composer替换为您的设置中的php composer.phar(或类似)。

直接安装

composer require shifrin/yii2-noty 1.0.1

或将它手动添加到composer.json中,然后更新composer

"shifrin/yii2-noty": "1.0.1",
composer update

使用说明

将小部件添加到主布局文件中,如下所示:

\shifrin\noty\NotyWidget::widget([
  'options' => [ // you can add js options here, see noty plugin page for available options
    'dismissQueue' => true,
    'layout' => 'topCenter',
    'theme' => 'relax',
    'animation' => [
      'open' => 'animated flipInX',
      'close' => 'animated flipOutX',
    ],
    'timeout' => false
  ],
  'enableSessionFlash' => true
  'enableIcon' => true,
  'registerAnimateCss' => true,
  'registerButtonsCss' => true,
  'registerFontAwesomeCss' => true,
]);

此小部件将创建一个JS函数Noty(),因此它将全局可用,您可以在自定义JS代码中调用此函数。请参阅以下示例。

var n = Noty('id');
$.noty.setText(n.options.id, 'Welcome to our site!');
$.noty.setType(n.options.id, 'information');

您可以在控制器中或需要的地方设置闪存消息,例如这样。然而,如果您将enableSessionFlash设置为false,则它将不受影响。

\Yii::$app->session->setFlash('type', 'Message here');

type替换为可用的类型

可用类型

  • success
  • error
  • warning
  • information
  • alert