Skip to content

Commit

Permalink
Merge pull request #3 from ruskid/master
Browse files Browse the repository at this point in the history
Update NotyAsset.php
  • Loading branch information
eleiva committed Mar 6, 2015
2 parents fa127fb + 9b7e20a commit 3af35cd
Show file tree
Hide file tree
Showing 10 changed files with 108 additions and 1,345 deletions.
4 changes: 0 additions & 4 deletions .gitignore

This file was deleted.

14 changes: 14 additions & 0 deletions AnimateAsset.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace eleiva\noty;

use yii\web\AssetBundle;

class AnimateAsset extends AssetBundle{

public $sourcePath = '@bower/animate.css';
public function init(){
$this->css[] = YII_DEBUG ? 'animate.css' : 'animate.min.js';
parent::init();
}
}
Empty file modified LICENSE
100644 → 100755
Empty file.
73 changes: 48 additions & 25 deletions Noty.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,68 @@

namespace eleiva\noty;

use yii\helpers\Html;
use yii\helpers\Json;
use yii\base\Widget;

class Noty extends Widget
{
/* Html options for the enclosing element */
public $options = [];
/**
* Noty Notification Wrapper @see http://ned.im/
*
* @author Eduardo Leiva
* @author Victor Demin <[email protected]>
*/
class Noty extends Widget {

/* Client options for noty.js */
/**
* Notification message
* @var string
*/
public $text;

/**
* Notification type
* @var string
*/
public $type = self::ALERT;

/**
* Other Noty options.
* @var array
*/
public $clientOptions = [
'timeout' => 1000,
'layout' => 'topRight',
'dismissQueue' => true,
'theme' => 'defaultTheme' ,
];
'timeout' => 1000,
'layout' => 'topRight',
'dismissQueue' => true,
'theme' => 'defaultTheme',
];

/* Tag of the surrounding element */
public $tag = 'div';
/**
* If to register Animate.css @see https://github.com/daneden/animate.css
* @var boolean
*/
public $useAnimateCss = false;

public $text = '';
public $type = 'information';
const ALERT = 'alert';
const SUCCESS = 'success';
const ERROR = 'error';
const WARNING = 'warning';
const INFORMATION = 'information';

public function init(){
/**
* Init widget
*/
public function init() {
$view = $this->getView();
$asset = new NotyAsset([
'publishOptions' => [
'forceCopy' => true
]
]);
$asset = new NotyAsset();
$asset->register($view);
if ($this->useAnimateCss) {
$cssAsset = new AnimateAsset();
$cssAsset->register($view);
}

$this->clientOptions['text'] = $this->text;
$this->clientOptions['type'] = $this->type;

$opts = !empty($this->clientOptions) ? Json::encode($this->clientOptions) : "{}";
$view->registerJs("noty($opts);");
}

public function run()
{
}
}
9 changes: 4 additions & 5 deletions NotyAsset.php
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
<?
<?php

namespace eleiva\noty;

use yii\web\AssetBundle;

class NotyAsset extends AssetBundle{

public $sourcePath = '@bower/noty/js/noty/packaged';
public $depends =[
'yii\web\JqueryAsset'
];

public function init(){
$this->js[] = YII_DEBUG ? 'jquery.noty.packaged.js' : 'jquery.noty.packaged.min.js';
parent::init();

$this->sourcePath = __DIR__. DIRECTORY_SEPARATOR . 'assets';
$this->js[] = YII_DEBUG ? 'jquery.noty.js' : 'jquery.noty.min.js';
$this->js[] = 'noty.bootstrap.js';
}
}
27 changes: 17 additions & 10 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,23 @@ Once the extension is installed, simply use it in your code by :

```php
use eleiva\noty\Noty;
echo Noty::widget([
'text' => 'Hellooooooooo',
'type' => 'error',
'clientOptions' => [
'timeout' => 1000,
'layout' => 'topRight',
'dismissQueue' => true,
'theme' => 'defaultTheme' ,
]
]);
echo Noty::widget([
'text' => 'Hi! Looks good!',
'type' => Noty::INFORMATION,
'useAnimateCss' => true,
'clientOptions' => [
'timeout' => 5000,
'layout' => 'top',
'dismissQueue' => true,
'theme' => 'relax',
'animation' => [
'open' => 'animated bounceInLeft',
'close' => 'animated bounceOutLeft',
'easing' => 'swing',
'speed' => 500
]
]
]);
```
Or simply
```php
Expand Down
Loading

0 comments on commit 3af35cd

Please sign in to comment.