raoul2000/yii2-pnotify-widget Wrapper around the PNotify JQuery plugin

extensionjquerypluginnotification

yii2-pnotify-widget

Wrapper around PNotify, a JavaScript notifications plugin for Bootstrap and jQuery UI.

Check out the PNotify Website for a demo of the Plugin.

important : please note that this widget only includes the basic PNotify modules : desktop and buttons

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist raoul2000/yii2-pnotify-widget "*"

or add

"raoul2000/yii2-pnotify-widget": "*"

to the require section of your composer.json file.

Usage

Once the extension is installed, simply use it in your code like this :

<?php 
    \raoul2000\widget\pnotify\PNotify::widget([
        'pluginOptions' => [
            'title' => 'My Notification',
            'text' => 'this is my \'first\' Notification using <b>PNotify</b>.',
        ]
    ]);
?>

Stacks

This widget includes an easy way of creating and using custom stacks that will drive the way PNotify displays notification messages.

To know more about PNotify Stacks, please refer to the documentation.

Defining a stack with the widget is easy. The example below defines a stack that will display notification vertically in the top-left corner. Then, use this stack (called "stack_top_left") to display a notification. The CSS class stack-topleft is part of the built-in CSS classes provided by PNotify.

<?php 

    // define "stack_top_left' stack

    \raoul2000\widget\pnotify\PNotify::registerStack( 
        [
            'stack_top_left' => [
                'dir1' => 'right',
                'dir2' => 'right',
                'push' => 'top'
            ]
        ],
        $this
    );

    // display a notification using the "stack_top_left" stack.
    // Note that you must use yii\web\JsExpression for the "stack" plugin option value. 

    \raoul2000\widget\pnotify\PNotify::widget([
        'pluginOptions' => [
            'title' => 'Information',
            'text' => 'This is a very intresting information message : read it !',
            'type' => 'info',
            'stack' => new yii\web\JsExpression('stack_top_left'),
            'addclass' => 'stack-topleft',
            'desktop' => [
                'desktop' => true
            ],
            'buttons' => [
                'closer_hover' => false
            ]
        ]
    ]); 

?>

As you may have noted, the widget above defines specific settings for the desktop and buttons modules.

For more information on the plugin options, please refer to PNotify@github.

License

yii2-pnotify-widget is released under the BSD 3-Clause License. See the bundled LICENSE.md for details.

Changelog

version 1.1.0

  • enh : use minified assets when not in DEV (i.e. YII_ENV_DEV not defined)
  • enh : add registerStack to allow easy PNotify stack creation

version 1.0.0

  • Initial release (based on PNotify 2.0)

Statistics

Downloads
GitHub Stars
GitHub Forks

Releases

Comments



1.1.0 is the latest of 2 releases



BSD-3-Clause license
Stats
1 github stars & 1 github forks
2 downloads in the last day
191 downloads in the last 30 days
11685 total downloads