Yii2 - Javascript Toast Notifications
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., (*1)
, (*2)
Π£ΡΡΠ°Π½ΠΎΠ²ΠΊΠ°
Π Π°ΡΡΠΈΡΠ΅Π½ΠΈΠ΅ ΡΡΡΠ°Π½Π°Π²Π»ΠΈΠ²Π°Π΅ΡΡΡ Ρ ΠΏΠΎΠΌΠΎΡΡΡ Composer ΠΈΠ½ΡΡΡΡΠΊΡΠΈΡ ΠΏΠΎ ΡΡΡΠ°Π½ΠΎΠ²ΠΊΠ΅ Composer, (*3)
Π£ΡΡΠ°Π½ΠΎΠ²ΠΊΠ° ΡΠ°ΡΡΠΈΡΠ΅Π½ΠΈΡ ΡΠ΅ΡΠ΅Π· Composer, Π²ΡΠΏΠΎΠ»Π½ΠΈΡΡ ΡΠ»Π΅Π΄ΡΡΡΡΡ ΠΊΠΎΠΌΠ°Π½Π΄Ρ:, (*4)
composer require --prefer-dist lavrentiev/yii2-toastr
ΠΈΠ»ΠΈ (master), (*5)
composer require --prefer-dist lavrentiev/yii2-toastr "dev-master"
ΠΈΠ»ΠΈ Π²Π½Π΅ΡΡΠΈ ΠΈΠ·ΠΌΠ΅Π½Π΅Π½ΠΈΡ Π² ΡΠ΅ΠΊΡΠΈΡ require
Π² composer.json
ΠΈ Π²ΡΠΏΠΎΠ»Π½ΠΈΡΡ composer update
, (*6)
"lavrentiev/yii2-toastr": "^2.0"
ΠΈΠ»ΠΈ (master), (*7)
"lavrentiev/yii2-toastr": "dev-master"
, (*8)
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, (*9)
, (*10)
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"
]
]);
ΠΠΎΠ΄ΠΊΠ»ΡΡΠ΅Π½ΠΈΠ΅ ΠΎΡΡΡΠ΅ΡΡΠ²Π»ΡΠ΅ΡΡΡΡ Π³Π»ΠΎΠ±Π°Π»ΡΠ½ΠΎ Π΄ΠΎΠΏΡΡΡΠΈΠΌ Π² layouts ΠΏΡΠΎΠ΅ΠΊΡΠ°., (*11)
<?= \lavrentiev\widgets\toastr\NotificationFlash::widget() ?>
Π’Π°ΠΊΠΆΠ΅ ΠΏΡΠΈΡΡΡΡΡΠ²ΡΠ΅Ρ Π²ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎΡΡΡ Π½Π°ΡΡΡΠΎΠΉΠΊΠΈ ΡΠ²Π΅Π΄ΠΎΠΌΠ»Π΅Π½ΠΈΠΉ, ΠΏΠΎ ΠΏΠ°ΡΠ°ΠΌΠ΅ΡΡΠ°ΠΌ ΠΏΡΠ΅Π΄ΡΡΠΌΠΎΡΡΠ΅Π½Π½ΡΠΌ ΡΠ°Π·ΡΠ°Π±ΠΎΡΡΠΈΠΊΠ°ΠΌΠΈ Toastr by CodeSeven, (*12)
<?= \lavrentiev\widgets\toastr\NotificationFlash::widget([
'options' => [
"closeButton" => true,
"debug" => false,
"newestOnTop" => false,
"progressBar" => false,
"positionClass" => \lavrentiev\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"
]
]) ?>
, (*13)
\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');
, (*14)
\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 |
[] |
ΠΠΎΠ΄ΡΠΎΠ±Π½Π΅ΠΉ... |
ΠΠΎΠΏΠΎΠ»Π½ΠΈΡΠ΅Π»ΡΠ½ΡΠ΅ ΠΎΠΏΡΠΈΠΈ |
ΠΠΎΠΏΡΡΡΠΈΠΌΡΠ΅ ΠΊΠΎΠ½ΡΡΠ°Π½ΡΡ ΡΠΈΠΏΠΎΠ²:, (*15)
TYPE_INFO = 'info'
TYPE_ERROR = 'error'
TYPE_SUCCESS = 'success'
TYPE_WARNING = 'warning'
ΠΠΎΠΏΡΡΡΠΈΠΌΡΠ΅ ΠΊΠΎΠ½ΡΡΠ°Π½ΡΡ ΠΏΠΎΠ»ΠΎΠΆΠ΅Π½ΠΈΡ:, (*16)
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
ΠΠΎΠΏΠΎΠ»Π½ΠΈΡΠ΅Π»ΡΠ½ΠΎ