Yii2 Alert Gritter v.1.3
jQuery plugin a small notifications, (*1)
Install
The preferred way to install this extension is through composer., (*2)
Either run, (*3)
php composer.phar require --prefer-dist skinka/yii2-alert-gritter
or add, (*4)
"skinka/yii2-alert-gritter": "*"
to the require section of your composer.json
file., (*5)
Used
Alert widget renders a message from session flash. All flash messages are displayed
in the sequence they were assigned using setFlash. You can set message as following:, (*6)
Create message:, (*7)
\Yii::$app->getSession()->setFlash('error', 'This is the message');
\Yii::$app->getSession()->setFlash('success', 'This is the message');
\Yii::$app->getSession()->setFlash('info', 'This is the message');
Show message:, (*8)
<?= skinka\widgets\gritter\AlertGritterWidget::widget() ?>
Widget options:, (*9)
Enabled icons for alert message, (*10)
'enableIcon' => true;
The alert types configuration for the flash messages.
type
type flash
- class
class block notify
- icon
class icon in message
- title
title type message, (*11)
'options' => [
'error' => [
'class' => 'gritter-danger',
'icon' => 'fa fa-times',
'title' => 'Error',
],
];
Options for Jquery Gritter plugin, (*12)
'gritterOptions' => [
// (bool | optional) if you want it to fade out on its own or just sit there
'sticky' => true,
// (int | optional) the time you want it to be alive for before fading out
'time' => '',
// possibilities: POS_BL, POS_BR, POS_TL, POS_TR
'position' => skinka\widgets\gritter\AlertGritterWidget::POS_BL,
// how fast notifications fade in (string or int)
'fade_in_speed' => 100,
// how fast the notices fade out
'fade_out_speed' => 100,
// (function | optional) function called before it opens
'before_open' => new JsExpression('function(){}'),
// (function | optional) function called after it opens
'after_open' => new JsExpression('function(e){}'),
// (function | optional) function called before it closes
'before_close' => new JsExpression('function(e, manual_close){}'),
// (function | optional) function called after it closes
'after_close' => new JsExpression('function(e, manual_close){}'),
];
JavaScript notify
Show message:, (*13)
<?php $this->registerAssetBundle(skinka\widgets\gritter\GritterAsset::className()); ?>
<?php $this->registerJs("gritterAdd('Title', 'Text', 'myClass');"); ?>
Params of function:, (*14)
gritterAdd(title, text, class_name, image, options);
where, (*15)
- title = title notify text;
- text = message notify text;
- class_name = block notify css class;
- image = url image in block notify;
-
options = {, (*16)
time: '', (int | optional) the time you want it to be alive for before fading out, (*17)
position: 'bottom-left', possibilities: bottom-left, bottom-right, top-left, top-right, (*18)
fade_in_speed: 100, how fast notifications fade in (string or int), (*19)
fade_out_speed: 100, how fast the notices fade out, (*20)
before_open: function(){}, (function | optional) function called before it opens, (*21)
after_open: function(e){}, (function | optional) function called after it opens, (*22)
before_close: function(e, manual_close){}, (function | optional) function called before it closes, (*23)
after_close: function(e, manual_close){}, (function | optional) function called after it closes, (*24)
}, (*25)