-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
858ff13
commit 435f01d
Showing
5 changed files
with
164 additions
and
16 deletions.
There are no files selected for viewing
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
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,36 @@ | ||
# Bootstrap Notify | ||
!["Bootstrap Notify"](img/bootstrap-notify.jpg) | ||
|
||
Installation | ||
-------- | ||
|
||
```bash | ||
"loveorigami/yii2-notification-wrapper": "*", | ||
"bower-asset/remarkable-bootstrap-notify": "^3.1", | ||
``` | ||
|
||
to the ```require``` section of your `composer.json` file. | ||
|
||
|
||
Usage | ||
----- | ||
|
||
```php | ||
use lo\modules\noty\Wrapper; | ||
|
||
echo Wrapper::widget([ | ||
'layerClass' => 'lo\modules\noty\layers\BootstrapNotify', | ||
// default options | ||
'options' => [ | ||
'newest_on_top' => false, | ||
'showProgressbar' => true, | ||
'placement' => [ | ||
'from' => 'top', | ||
'align' => 'right' | ||
] | ||
|
||
// and more for this library here https://github.com/mouse0270/bootstrap-notify | ||
], | ||
]); | ||
|
||
``` |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,25 @@ | ||
<?php | ||
|
||
namespace lo\modules\noty\assets; | ||
|
||
use yii\web\AssetBundle; | ||
|
||
/** | ||
* Class BootstrapNotifyAsset | ||
* @package lo\modules\noty\layers | ||
*/ | ||
class BootstrapNotifyAsset extends AssetBundle | ||
{ | ||
/** @var string */ | ||
public $sourcePath = '@bower/remarkable-bootstrap-notify'; | ||
|
||
/** @var array $js */ | ||
public $js = [ | ||
'bootstrap-notify.min.js' | ||
]; | ||
|
||
/** @var array $depends */ | ||
public $depends = [ | ||
'yii\bootstrap\BootstrapPluginAsset', | ||
]; | ||
} |
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,85 @@ | ||
<?php | ||
|
||
namespace lo\modules\noty\layers; | ||
|
||
use yii\helpers\Json; | ||
use lo\modules\noty\assets\BootstrapNotifyAsset; | ||
|
||
/** | ||
* Class BootstrapNotify | ||
* @package lo\modules\noty\layers | ||
* | ||
* This widget should be used in your main layout file as follows: | ||
* --------------------------------------- | ||
* use lo\modules\noty\Wrapper; | ||
* | ||
* echo Wrapper::widget([ | ||
* 'layerClass' => 'lo\modules\noty\layers\BootstrapNotify', | ||
* 'options' => [ | ||
* 'fixed' => true, | ||
* 'size' => 'medium', | ||
* 'location' => 'tr', | ||
* 'delayOnHover' => true, | ||
* | ||
* // and more for this library... | ||
* ], | ||
* ]); | ||
* --------------------------------------- | ||
*/ | ||
class BootstrapNotify extends Layer implements LayerInterface | ||
{ | ||
|
||
/** | ||
* @var array $defaultOptions | ||
*/ | ||
protected $defaultOptions = [ | ||
'newest_on_top' => false, | ||
'showProgressbar' => false, | ||
'placement' => [ | ||
'from' => 'top', | ||
'align' => 'right' | ||
] | ||
]; | ||
|
||
/** | ||
* register asset | ||
*/ | ||
public function run() | ||
{ | ||
$view = $this->getView(); | ||
BootstrapNotifyAsset::register($view); | ||
parent::run(); | ||
} | ||
|
||
/** | ||
* @param $options | ||
* @return string | ||
*/ | ||
public function getNotification($options) | ||
{ | ||
$options['type'] = $this->getType(); | ||
$options = Json::encode($options); | ||
|
||
$data['message'] = $this->getMessageWithTitle(); | ||
//$data['title'] = $this->title; | ||
$data = Json::encode($data); | ||
|
||
return "$.notify($data, $options);"; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getType() | ||
{ | ||
switch ($this->type) { | ||
case self::TYPE_ERROR: | ||
$type = 'danger'; | ||
break; | ||
default: | ||
$type = $this->type; | ||
} | ||
return $type; | ||
} | ||
|
||
} |