Difference between #2 and #3 of
Customize your Growl/Alert msg easy and quickly

Revision #3 has been created by Scott_Huang on Apr 24, 2015, 3:32:30 PM with the memo:

Add timer and mouse_over option
« previous (#2)

Changes

Title unchanged

Customize your Growl/Alert msg easy and quickly

Category unchanged

Tips

Yii version unchanged

Tags unchanged

Notification, Hzl, Yii2

Content changed

**I leverage Kartik's notification widgets.** And try to wrap the notification to own quickly static function for easy revoke. The type[info, success, warning, danger] will according **title text** to auto change. Also add timer and mouse_over option.

The below code block contain 3 small functions, you can put into Yourclass.
[...]
* @param array $additional parameters which you may want to change.
*/
 public static function showMsg($title = 'info', $body = 'info msg', $additional = [])
{
[...]
'alertType' => 'Growl',
'useSessionFlash' => false,
            'mouse_over'=>'pause',
 
            'timer'=>1000,
 
 
], $additional);

$typeIndex = 'info';
[...]
];

        $delay = $additional['delay'];
 
if ($additional['useSessionFlash']) { $flashes = \yii::$app->session->getAllFlashes(true);             if ($delay == 0  and $additional['alertType']=="Alert") $delay += 2000;
 
//self::dump(($flashes)); } else { $flashes = [$title => $body]; }         $delay = $additional['delay'];
 
        if (empty($delay) and $additional['alertType']=="Alert") $delay += 2000;
 
foreach ($flashes as $title => $body) {
$typeIndex = 'info';
if (!empty($title)) {
[...]
'delay' => $delay,
'pluginOptions' => [
                    'timer'=>$additional['timer'],
 
                    'mouse_over'=>$additional['mouse_over'],
 
'placement' => [
'from' => $additional['from'],
'align' => $additional['align'],
]
]
];
[...]
0 1
2 followers
Viewed: 16 575 times
Version: 2.0
Category: Tips
Written by: Scott_Huang
Last updated by: Scott_Huang
Created on: Apr 24, 2015
Last updated: 9 years ago
Update Article

Revisions

View all history