skinka/yii2-alert-gritter

Gritter. Popup messages

Installs: 1 694

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 2

Forks: 3

Type:yii2-extension

1.3 2015-09-13 05:36 UTC

This package is not auto-updated.

Last update: 2024-12-21 18:37:20 UTC


README

#Yii2 Alert Gritter v.1.3 jQuery plugin a small notifications

#Install The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist skinka/yii2-alert-gritter

or add

"skinka/yii2-alert-gritter": "*"

to the require section of your composer.json file.

#Used ##Widget 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:

Create message:

\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:

<?= skinka\widgets\gritter\AlertGritterWidget::widget() ?>

Widget options:

Enabled icons for alert message

'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
'options' => [
    'error' => [
        'class' => 'gritter-danger',
        'icon' => 'fa fa-times',
        'title' => 'Error',
    ],
];

Options for Jquery Gritter plugin

'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:

<?php $this->registerAssetBundle(skinka\widgets\gritter\GritterAsset::className()); ?>
<?php $this->registerJs("gritterAdd('Title', 'Text', 'myClass');"); ?>

Params of function:

gritterAdd(title, text, class_name, image, options);

where

  • title = title notify text;

  • text = message notify text;

  • class_name = block notify css class;

  • image = url image in block notify;

  • options = {

    time: '', (int | optional) the time you want it to be alive for before fading out

    position: 'bottom-left', possibilities: bottom-left, bottom-right, top-left, top-right

    fade_in_speed: 100, how fast notifications fade in (string or int)

    fade_out_speed: 100, how fast the notices fade out

    before_open: function(){}, (function | optional) function called before it opens

    after_open: function(e){}, (function | optional) function called after it opens

    before_close: function(e, manual_close){}, (function | optional) function called before it closes

    after_close: function(e, manual_close){}, (function | optional) function called after it closes

}