mirror of
https://github.com/php-flasher/php-flasher.git
synced 2026-03-31 15:07:47 +01:00
fix noty library
This commit is contained in:
@@ -6,4 +6,169 @@ use Flasher\Prime\Notification\NotificationBuilder;
|
||||
|
||||
final class NotyBuilder extends NotificationBuilder
|
||||
{
|
||||
/**
|
||||
* @param string $text
|
||||
*
|
||||
* @return NotyBuilder
|
||||
*/
|
||||
public function text($text)
|
||||
{
|
||||
return $this->message($text);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $message
|
||||
* @param array $options
|
||||
*
|
||||
* @return NotyBuilder
|
||||
*/
|
||||
public function alert($message = null, array $options = array())
|
||||
{
|
||||
return $this->type('alert', $message, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $layout
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function layout($layout)
|
||||
{
|
||||
$this->option('layout', $layout);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $theme
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function theme($theme)
|
||||
{
|
||||
$this->option('theme', $theme);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int|bool $timeout
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function timeout($timeout)
|
||||
{
|
||||
$this->option('timeout', $timeout);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $progressBar
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function progressBar($progressBar = false)
|
||||
{
|
||||
$this->option('progressBar', $progressBar);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $closeWith
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function closeWith($closeWith)
|
||||
{
|
||||
$this->option('closeWith', $closeWith);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $animation
|
||||
* @param string $effect
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function animation($animation, $effect)
|
||||
{
|
||||
$this->option('animation.'.$animation, $effect);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $option
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function sounds($option, $value)
|
||||
{
|
||||
$this->option('sounds.'.$option, $value);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $modal
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function modal($modal = true)
|
||||
{
|
||||
$this->option('modal', $modal);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $force
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function force($force = true)
|
||||
{
|
||||
$this->option('force', $force);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|bool $killer
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function killer($killer)
|
||||
{
|
||||
$this->option('killer', $killer);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|bool $container
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function container($container)
|
||||
{
|
||||
$this->option('container', $container);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $buttons
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function buttons($buttons)
|
||||
{
|
||||
$this->option('buttons', $buttons);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,10 +47,10 @@ final class NotyRenderer implements RendererInterface, HasScriptsInterface, HasS
|
||||
$notification = $envelope->getNotification();
|
||||
$options = $envelope->getOptions();
|
||||
|
||||
$options['message'] = $envelope->getMessage();
|
||||
$options['text'] = $envelope->getMessage();
|
||||
$options['type'] = $envelope->getType();
|
||||
|
||||
return sprintf("new Noty(%s);", json_encode($options));
|
||||
return sprintf("new Noty(%s).show();", json_encode($options));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -41,7 +41,7 @@ final class Configuration implements ConfigurationInterface
|
||||
->defaultValue(array(
|
||||
'layout' => 'topRight',
|
||||
'theme' => 'mint',
|
||||
'timeout' => 5000,
|
||||
'timeout' => false,
|
||||
'progressBar' => true,
|
||||
'animation.open' => 'noty_effects_open',
|
||||
'animation.close' => 'noty_effects_close',
|
||||
|
||||
Reference in New Issue
Block a user