raoul2000 / yii2-pnotify-widget
基于 PNotify JQuery 插件的包装器
1.1.0
2014-10-11 13:42 UTC
Requires
- yiisoft/yii2: *
This package is not auto-updated.
Last update: 2024-09-24 06:50:30 UTC
README
包装 PNotify,一个用于 Bootstrap 和 jQuery UI 的 JavaScript 通知插件。
查看PNotify 网站,了解该插件的演示。
重要 : 请注意,此小部件仅包括基本的 PNotify 模块:桌面 和 按钮
安装
安装此扩展的首选方式是通过 composer。
运行
php composer.phar require --prefer-dist raoul2000/yii2-pnotify-widget "*"
或在您的 composer.json
文件的 require 部分添加
"raoul2000/yii2-pnotify-widget": "*"
。
使用
一旦安装了扩展,只需像这样在代码中使用它即可
<?php \raoul2000\widget\pnotify\PNotify::widget([ 'pluginOptions' => [ 'title' => 'My Notification', 'text' => 'this is my \'first\' Notification using <b>PNotify</b>.', ] ]); ?>
堆栈
此小部件包括创建和使用自定义堆栈的简单方法,这将影响 PNotify 显示通知消息的方式。
要了解更多关于 PNotify 堆栈的信息,请参阅文档。
使用小部件定义堆栈很简单。下面的示例定义了一个将在右上角垂直显示通知的堆栈。然后,使用此堆栈(称为 "stack_top_left")来显示通知。CSS 类 stack-topleft 是 PNotify 提供的内置 CSS 类之一。
<?php // define "stack_top_left' stack \raoul2000\widget\pnotify\PNotify::registerStack( [ 'stack_top_left' => [ 'dir1' => 'right', 'dir2' => 'right', 'push' => 'top' ] ], $this ); // display a notification using the "stack_top_left" stack. // Note that you must use yii\web\JsExpression for the "stack" plugin option value. \raoul2000\widget\pnotify\PNotify::widget([ 'pluginOptions' => [ 'title' => 'Information', 'text' => 'This is a very intresting information message : read it !', 'type' => 'info', 'stack' => new yii\web\JsExpression('stack_top_left'), 'addclass' => 'stack-topleft', 'desktop' => [ 'desktop' => true ], 'buttons' => [ 'closer_hover' => false ] ] ]); ?>
如您所注意到的,上述小部件为 桌面 和 按钮 模块定义了特定设置。
有关插件选项的更多信息,请参阅 PNotify@github。
许可证
yii2-pnotify-widget 在 BSD 3-Clause 许可下发布。有关详细信息,请参阅捆绑的 LICENSE.md
文件。