vityakut / yii2-toastr
Simple javascript toast notifications
Installs: 670
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 14
Open Issues: 0
Type:yii2-extension
Requires
- bower-asset/toastr: ^2.1
- yiisoft/yii2: ~2.0
README
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
Установка расширения через Composer, выполнить следующую команду:
composer require --prefer-dist vityakut/yii2-toastr
или (master)
composer require --prefer-dist vityakut/yii2-toastr "dev-master"
или внести изменения в секцию require
в composer.json
и выполнить composer update
"vityakut/yii2-toastr": "^2.0"
или (master)
"vityakut/yii2-toastr": "dev-master"
Уведомления Notification::widget()
use vityakut\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' => Notification::TYPE_ERROR, 'title' => 'Toast Notifications', 'message' => 'Simple javascript toast notifications', 'options' => [ "closeButton" => false, "debug" => false, "newestOnTop" => false, "progressBar" => false, "positionClass" => Notification::POSITION_TOP_RIGHT, "preventDuplicates" => false, "onclick" => null, "showDuration" => "300", "hideDuration" => "1000", "timeOut" => "5000", "extendedTimeOut" => "1000", "showEasing" => "swing", "hideEasing" => "linear", "showMethod" => "fadeIn", "hideMethod" => "fadeOut" ] ]);
Уведомления NotificationFlash::widget()
Подключение осуществляеться глобально допустим в layouts проекта.
<?= \vityakut\widgets\toastr\NotificationFlash::widget() ?>
Также присутствует возможность настройки уведомлений, по параметрам предусмотренным разработчиками Toastr by CodeSeven
<?= \vityakut\widgets\toastr\NotificationFlash::widget([ 'options' => [ "closeButton" => true, "debug" => false, "newestOnTop" => false, "progressBar" => false, "positionClass" => \vityakut\widgets\toastr\NotificationFlash::POSITION_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'
TYPE_ERROR = 'error'
TYPE_SUCCESS = 'success'
TYPE_WARNING = 'warning'
Допустимые константы положения:
POSITION_TOP_RIGHT = 'toast-top-right';
POSITION_TOP_LEFT = 'toast-top-left';
POSITION_TOP_CENTER = 'toast-top-center';
POSITION_TOP_FULL_WIDTH = 'toast-top-full-width';
POSITION_BOTTOM_RIGHT = 'toast-bottom-right';
POSITION_BOTTOM_LEFT = 'toast-bottom-left';
POSITION_BOTTOM_CENTER = 'toast-bottom-center';
POSITION_BOTTOM_FULL_WIDTH = 'toast-bottom-full-width';
Демонстрация
- Demo can be found at http://codeseven.github.io/toastr/demo.html