Yii 1.1: yii-toastmessage

a smal widget to implement the jquery toast message
20 followers

for a complete description of this jquery plugin please visit jquery-toastmessage

for demos Click here...

Requirements

...requirements of using this extension (e.g. Yii 1.1 or above)...

Usage

simply extract the download to your extensions folder

Now you can implement the toastMessage in two ways.

  1. Using the widget itself
//in your view 
//we have four types of message type : Success, Info, Warning and Error
$message = "this is yii at work";
 $this->widget('ext.widgets.toastMessage.toastMessageWidget',
                                     array('message'=>$message,'type'=>'Success',
'options'=>array('sticky'=>true)));
  1. Using the view file in the views directory of the toastMessage extension. I prefer this second method when i dont want to render a view from any action.
$message = "this is a fully customized toastMessage"; 
 
 $this->renderPartial('ext.toastMessage.views.toastView',array('message'=>$message,
'type'=>'warning',                                                                              'options'=>array(  'sticky'=>true,
                   'position'=>'middle-right',
                   'stayTime'=>5000)),false,true);

Change Log

Official release Nov 2 2012.

#### Nov 29 2012

  • added the options property

    • inEffectDuration: 600, // in effect duration in miliseconds
    • stayTime: 3000, // time in miliseconds before the item has to disappear
    • text: '', // content of the item
    • sticky: false, // should the toast item sticky or not?
    • position: 'top-right', // top-left, top-center, top-right, middle-left, middle-center, middle-right // Position of the toast container holding different toast. // Position can be set only once at the very first call, // changing the position after the first call does nothing
    • closeText: '', // text which will be shown as close button, // set to '' when you want to introduce an image via css
    • close: null // callback function when the toastmessage is closed
  • create a new view for none rendered implement

Total 9 comments

#13286 report it
Nur Rochim at 2013/05/20 07:49pm
Error

Parse error: syntax error, unexpected T_OBJECT_OPERATOR in C:\xampp\htdocs\yii\isims\protected\extensions\toastMessage\toastMessageWidget.php on line 49

#10972 report it
Sephiroth at 2012/12/07 08:55am
fix

here!

public function init(){
          //publish the assets folder for the toastmessage 
           $this->assets = Yii::app()->assetManager->publish(dirname(__DIR__).DIRECTORY_SEPARATOR.'toastMessage'.DIRECTORY_SEPARATOR.'assets'); 
 
 
          Yii::app->clientScript()->registerScriptFile($this->assets.'/jquery.toastmessage.js'); 
          Yii::app->clientScript()->registerCssFile($this->assets.'/css/jquery.toastmessage.css');
 
      }
#10970 report it
Sephiroth at 2012/12/07 07:05am
Nice!

Greetings, friend I think you have a problem, check the widget file ...

#10894 report it
binkabir at 2012/11/30 04:03am
@thyseus

thanks for the correction. I actually had some short cut definition for some yii components, which I forgot to replace. now I have replaced it. cheers

#10883 report it
thyseus at 2012/11/29 10:19am
cs()

Please replace cs() with Yii::app()->clientScript in your code. cs() is not available everywhere.

Thanks for this extension!

#10649 report it
Daniel at 2012/11/11 07:32am
@Binkabir

Thank you for the prompt answer, my situation is like this: Currently, I provide container to display the message (error/success/info/warning) on layouts/main.php like below:

<div style="position: fixed; top: 50px; right: 20px; z-index: 10;">
            <?php
            $this->widget('bootstrap.widgets.TbAlert', array(
                'id' => 'msgBox',
                'block' => false, // display a larger alert block?
                'fade' => true, // use transitions?
                'closeText' => '&times;', // close link text - if set to false, no close link is displayed
                'alerts' => array(// configurations per alert type
                    'success' => array('block' => false, 'fade' => true, 'closeText' => '&times;'), // success, info, warning, error or danger
                    'info' => array('block' => false, 'fade' => true, 'closeText' => '&times;'),
                    'warning' => array('block' => false, 'fade' => true, 'closeText' => '&times;'),
                    'error' => array('block' => false, 'fade' => true, 'closeText' => '&times;'),
                    'danger' => array('block' => false, 'fade' => true, 'closeText' => '&times;'),
                ),
            ));
            ?>
        </div>
 
        <?php
        Yii::app()->clientScript->registerScript(
                'myHideEffect', '$("#msgBox").animate({opacity: 0.5}, 5000).fadeOut("slow");', CClientScript::POS_READY
        );
        ?>

From my TbGridView, I called

...
array(
            'class' => 'bootstrap.widgets.TbButtonColumn',
            'template' => '{update} {delete}',
            'afterDelete' => "function(link,success,data){ if(success) { var obj = jQuery.parseJSON(data); $('#msgBox').html(
                                    '<div class=\"alert alert-block alert-' + obj.status + ' fade in\">' +
                                    '<a class=\"close\" data-dismiss=\"alert\">×</a>' +
                                    obj.msg + '</div>'); $('#msgBox').animate({opacity: 0.5}, 5000).fadeOut('slow');} }",
...

I have no idea to replace this with the toast message. Any help?

Cheers,

Daniel

#10631 report it
binkabir at 2012/11/09 05:47am
@ Daniel

yes you can use it for dynamical ajax call but the condition is that because the js script for the extensions are only loaded on request you have to set the param ($processOutput=true) in your renderPartial method. (the default is false)

eg. $this->renderPartial('myView',array('model'=>$model),false,TRUE);

#10629 report it
Daniel at 2012/11/09 03:49am
Use as flash message

Hi,

How to use it to show flash message? Also, display it dynamically after ajax call?

Cheers,

Daniel

#10553 report it
Peter JK at 2012/11/04 10:01am
nice extension

wonderful..

nice extension. just about to remind me Foxpro and foxpro for windows..

Leave a comment

Please to leave your comment.

Create extension