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.
Π£ΡΡΠ°Π½ΠΎΠ²ΠΊΠ° ΒΆ
Π Π°ΡΡΠΈΡΠ΅Π½ΠΈΠ΅ ΡΡΡΠ°Π½Π°Π²Π»ΠΈΠ²Π°Π΅ΡΡΡ Ρ ΠΏΠΎΠΌΠΎΡΡΡ Composer ΠΈΠ½ΡΡΡΡΠΊΡΠΈΡ ΠΏΠΎ ΡΡΡΠ°Π½ΠΎΠ²ΠΊΠ΅ Composer
Π£ΡΡΠ°Π½ΠΎΠ²ΠΊΠ° ΡΠ°ΡΡΠΈΡΠ΅Π½ΠΈΡ ΡΠ΅ΡΠ΅Π· Composer, Π²ΡΠΏΠΎΠ»Π½ΠΈΡΡ ΡΠ»Π΅Π΄ΡΡΡΡΡ ΠΊΠΎΠΌΠ°Π½Π΄Ρ:
composer require --prefer-dist lavrentiev/yii2-toastr
ΠΈΠ»ΠΈ (master)
composer require --prefer-dist lavrentiev/yii2-toastr "dev-master"
ΠΈΠ»ΠΈ Π²Π½Π΅ΡΡΠΈ ΠΈΠ·ΠΌΠ΅Π½Π΅Π½ΠΈΡ Π² ΡΠ΅ΠΊΡΠΈΡ require Π² composer.json ΠΈ Π²ΡΠΏΠΎΠ»Π½ΠΈΡΡ composer update
"lavrentiev/yii2-toastr": "^2.0"
ΠΈΠ»ΠΈ (master)
"lavrentiev/yii2-toastr": "dev-master"
Π£Π²Π΅Π΄ΠΎΠΌΠ»Π΅Π½ΠΈΡ Notification::widget() ΒΆ

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
`php
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 ΠΏΡΠΎΠ΅ΠΊΡΠ°.
<?= \lavrentiev\widgets\toastr\NotificationFlash::widget() ?>
Π’Π°ΠΊΠΆΠ΅ ΠΏΡΠΈΡΡΡΡΡΠ²ΡΠ΅Ρ Π²ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎΡΡΡ Π½Π°ΡΡΡΠΎΠΉΠΊΠΈ ΡΠ²Π΅Π΄ΠΎΠΌΠ»Π΅Π½ΠΈΠΉ, ΠΏΠΎ ΠΏΠ°ΡΠ°ΠΌΠ΅ΡΡΠ°ΠΌ ΠΏΡΠ΅Π΄ΡΡΠΌΠΎΡΡΠ΅Π½Π½ΡΠΌ ΡΠ°Π·ΡΠ°Π±ΠΎΡΡΠΈΠΊΠ°ΠΌΠΈ Toastr by CodeSeven
<?= \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"
]
]) ?>

\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 | [] | ΠΠΎΠ΄ΡΠΎΠ±Π½Π΅ΠΉ... | ΠΠΎΠΏΠΎΠ»Π½ΠΈΡΠ΅Π»ΡΠ½ΡΠ΅ ΠΎΠΏΡΠΈΠΈ |
ΠΠΎΠΏΡΡΡΠΈΠΌΡΠ΅ ΠΊΠΎΠ½ΡΡΠ°Π½ΡΡ ΡΠΈΠΏΠΎΠ²:
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
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.