Simple javascript toast notifications - Javascript library for non-blocking notifications. jQuery is required. The goal is to create a simple core library that can be customized and extended.
Расширение устанавливается с помощью Composer интсрукция по установке Composer
Требуемые зависимости для расширения:
- Yii PHP Framework Version 2 >=
2.0.6
- Toastr by CodeSeven =
v2.1.1
- PHP >=
5.4.0
Установка расширения через Composer, выполнить следующую команду:
php composer.phar require --prefer-dist lavrentiev/yii2-toastr "~2.0.0"
или (master)
php composer.phar require --prefer-dist lavrentiev/yii2-toastr "dev-master"
или внести изменения в секцию require
в composer.json
и выполнить composer update
"lavrentiev/yii2-toastr": "~2.0.0"
или (master)
"lavrentiev/yii2-toastr": "dev-master"
use lavrentiev\widgets\toastr\Notification;
Notification::widget([
'type' => 'info',
'title' => 'Toast Notifications',
'message' => 'Simple javascript toast notifications'
]);
Notification::widget([
'type' => 'error',
'title' => 'Toast Notifications',
'message' => 'Simple javascript toast notifications'
]);
Notification::widget([
'type' => 'success',
'title' => 'Toast Notifications',
'message' => 'Simple javascript toast notifications'
]);
Notification::widget([
'type' => 'warning',
'title' => 'Toast Notifications',
'message' => 'Simple javascript toast notifications'
]);
Notification::widget([
'type' => 'info',
'message' => 'Simple javascript toast notifications'
]);
Notification::widget([
'type' => 'error',
'message' => 'Simple javascript toast notifications'
]);
Notification::widget([
'type' => 'success',
'message' => 'Simple javascript toast notifications'
]);
Notification::widget([
'type' => 'warning',
'message' => 'Simple javascript toast notifications'
]);
Также присутствует возможность настройки произвольного уведомления, по параметрам предусмотренным разработчиками Toastr by CodeSeven
Notification::widget([
'type' => 'error',
'title' => 'Toast Notifications',
'message' => 'Simple javascript toast notifications',
'options' => [
"closeButton" => false,
"debug" => false,
"newestOnTop" => false,
"progressBar" => false,
"positionClass" => "toast-top-right",
"preventDuplicates" => false,
"onclick" => null,
"showDuration" => "300",
"hideDuration" => "1000",
"timeOut" => "5000",
"extendedTimeOut" => "1000",
"showEasing" => "swing",
"hideEasing" => "linear",
"showMethod" => "fadeIn",
"hideMethod" => "fadeOut"
]
]);
Подключение осуществляеться глобально допустим в layouts проекта.
<?= \lavrentiev\widgets\toastr\NotificationFlash::widget() ?>
Также присутствует возможность настройки уведомлений, по параметрам предусмотренным разработчиками Toastr by CodeSeven
<?= \lavrentiev\widgets\toastr\NotificationFlash::widget([
'options' => [
"closeButton" => false,
"debug" => false,
"newestOnTop" => false,
"progressBar" => false,
"positionClass" => "toast-top-right",
"preventDuplicates" => false,
"onclick" => null,
"showDuration" => "300",
"hideDuration" => "1000",
"timeOut" => "5000",
"extendedTimeOut" => "1000",
"showEasing" => "swing",
"hideEasing" => "linear",
"showMethod" => "fadeIn",
"hideMethod" => "fadeOut"
]
]) ?>
\Yii::$app->session->setFlash('error', 'This is the message');
\Yii::$app->session->setFlash('success', 'This is the message');
\Yii::$app->session->setFlash('info', 'This is the message');
\Yii::$app->session->setFlash('warning', 'This is the message');
\Yii::$app->session->setFlash('warning', ['Error 1', 'Error 2', 'Error 3']);
\Yii::$app->session->setFlash('success', ['Error 1', 'Error 2', 'Error 3']);
Параметр | Значение по умолчанию | Допустимые значения | Описание |
---|---|---|---|
type | info |
info , error , success , warning |
Тип уведомления |
title | --- | --- | Заголовок уведомления |
message | Simple javascript toast notifications |
--- | Текст уведомления |
options | [] |
Подробней... | Дополнительные опции |
- Demo can be found at http://codeseven.github.io/toastr/demo.html
@lavrentiev has just created a chat room. You can visit it here: https://gitter.im/lavrentiev/yii2-toastr.