-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from ruskid/master
Update NotyAsset.php
- Loading branch information
Showing
10 changed files
with
108 additions
and
1,345 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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() | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.