mirror of
https://github.com/Mibew/advanced-button-plugin.git
synced 2025-01-22 08:50:30 +03:00
Implement different cloacking modes
This commit is contained in:
parent
b716005893
commit
b83f32cd3f
40
Plugin.php
40
Plugin.php
@ -31,6 +31,43 @@ class Plugin extends \Mibew\Plugin\AbstractPlugin implements \Mibew\Plugin\Plugi
|
|||||||
{
|
{
|
||||||
protected $initialized = true;
|
protected $initialized = true;
|
||||||
|
|
||||||
|
// Default operational mode is visibility cloaking
|
||||||
|
protected $mode = 'visibility';
|
||||||
|
|
||||||
|
// Default submode for display cloaking mode
|
||||||
|
protected $submode = 'inline-block';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class constructor.
|
||||||
|
*
|
||||||
|
* @param array $config List of the plugin config.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function __construct($config)
|
||||||
|
{
|
||||||
|
// Set operational mode
|
||||||
|
if (isset($config['mode'])) {
|
||||||
|
switch($config['mode']) {
|
||||||
|
case 'display':
|
||||||
|
$this->mode = 'display';
|
||||||
|
if (isset($config['submode'])) {
|
||||||
|
switch($config['submode']) {
|
||||||
|
case 'block':
|
||||||
|
$this->submode = 'block';
|
||||||
|
break;
|
||||||
|
case 'inline':
|
||||||
|
$this->submode = 'inline';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'none':
|
||||||
|
$this->mode = 'none';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines necessary event listener.
|
* Defines necessary event listener.
|
||||||
*/
|
*/
|
||||||
@ -47,7 +84,7 @@ class Plugin extends \Mibew\Plugin\AbstractPlugin implements \Mibew\Plugin\Plugi
|
|||||||
*/
|
*/
|
||||||
public static function getVersion()
|
public static function getVersion()
|
||||||
{
|
{
|
||||||
return '0.0.1';
|
return '0.0.2';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -61,5 +98,6 @@ class Plugin extends \Mibew\Plugin\AbstractPlugin implements \Mibew\Plugin\Plugi
|
|||||||
$args['response']['load']['refresh'] = $g->generate($this->getFilesPath() . '/js/refresh.js', AssetUrlGeneratorInterface::ABSOLUTE_URL);
|
$args['response']['load']['refresh'] = $g->generate($this->getFilesPath() . '/js/refresh.js', AssetUrlGeneratorInterface::ABSOLUTE_URL);
|
||||||
$args['response']['handlers'][] = 'refreshButton';
|
$args['response']['handlers'][] = 'refreshButton';
|
||||||
$args['response']['dependencies']['refreshButton'] = array('refresh');
|
$args['response']['dependencies']['refreshButton'] = array('refresh');
|
||||||
|
$args['response']['data']['refreshButton'] = array('mode' => $this->mode, 'submode' => $this->submode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
32
README.md
32
README.md
@ -4,6 +4,8 @@ It make the button represents actual operator's state and automatically hides it
|
|||||||
|
|
||||||
The plugin needs the feature "Tracking and inviting" to be enabled. Otherwise it will just not work.
|
The plugin needs the feature "Tracking and inviting" to be enabled. Otherwise it will just not work.
|
||||||
|
|
||||||
|
NB.: If one enabled the feature "Tracking and inviting" for the first time, the button should be regenerated.
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
1. Get the archive with the plugin sources. You can download it from the [official site](https://mibew.org/plugins#mibew-advanced-button) or build the plugin from sources.
|
1. Get the archive with the plugin sources. You can download it from the [official site](https://mibew.org/plugins#mibew-advanced-button) or build the plugin from sources.
|
||||||
@ -12,11 +14,37 @@ The plugin needs the feature "Tracking and inviting" to be enabled. Otherwise it
|
|||||||
|
|
||||||
3. Put files of the plugins to the `<Mibew root>/plugins` folder.
|
3. Put files of the plugins to the `<Mibew root>/plugins` folder.
|
||||||
|
|
||||||
4. Navigate to "`<Mibew Base URL>`/operator/plugin" page and enable the plugin.
|
4. (optional) Add plugins configs to "plugins" structure in
|
||||||
|
"`<Mibew root>`/configs/config.yml". If the "plugins" stucture looks like
|
||||||
|
`plugins: []` it will become:
|
||||||
|
```yaml
|
||||||
|
plugins:
|
||||||
|
"Mibew:AdvancedButton": # Plugin's configurations are described below
|
||||||
|
mode: display
|
||||||
|
submode: block
|
||||||
|
```
|
||||||
|
|
||||||
|
5. Navigate to "`<Mibew Base URL>`/operator/plugin" page and enable the plugin.
|
||||||
|
|
||||||
## Plugin's configurations
|
## Plugin's configurations
|
||||||
|
|
||||||
The plugin has no configuration.
|
The plugin can be configured with values in "`<Mibew root>`/configs/config.yml" file.
|
||||||
|
|
||||||
|
### config.mode
|
||||||
|
|
||||||
|
Type: `String`
|
||||||
|
|
||||||
|
Default: `visibility`
|
||||||
|
|
||||||
|
Specify a mode to hide the button after the start of the chat. Possible values: `visibility` (hide using `visibility` CSS property), `display` (hide using `display` CSS property), `none` (do nothing).
|
||||||
|
|
||||||
|
### config.submode
|
||||||
|
|
||||||
|
Type: `String`
|
||||||
|
|
||||||
|
Default: `inline-block`
|
||||||
|
|
||||||
|
Specify a value of the `display` CSS property for the visible button if mode was set to `display`.
|
||||||
|
|
||||||
## Build from sources
|
## Build from sources
|
||||||
|
|
||||||
|
@ -5,12 +5,20 @@
|
|||||||
var originalSrc = img.src.replace(/&dummy=\d+/, '');
|
var originalSrc = img.src.replace(/&dummy=\d+/, '');
|
||||||
img.src = originalSrc + "&dummy=" + (new Date()).getTime();
|
img.src = originalSrc + "&dummy=" + (new Date()).getTime();
|
||||||
|
|
||||||
// Hide the button if all popups are open or make it visible otherwise
|
// Check whether we need to hide the button
|
||||||
var visible = false;
|
if (data.refreshButton.mode != 'none') {
|
||||||
for(var key in Mibew.Objects.ChatPopups) {
|
// Hide the button if all popups are open or make it visible otherwise
|
||||||
var popup = Mibew.Objects.ChatPopups[key];
|
var visible = false;
|
||||||
visible = visible || !popup.isOpened;
|
for(var key in Mibew.Objects.ChatPopups) {
|
||||||
|
var popup = Mibew.Objects.ChatPopups[key];
|
||||||
|
visible = visible || !popup.isOpened;
|
||||||
|
}
|
||||||
|
if (data.refreshButton.mode == 'visibility') {
|
||||||
|
img.style.visibility = visible ? 'visible' : 'hidden';
|
||||||
|
}
|
||||||
|
else if (data.refreshButton.mode == 'display') {
|
||||||
|
img.style.display = visible ? data.refreshButton.submode : 'none';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
img.style.visibility = visible ? 'visible' : 'hidden';
|
|
||||||
}
|
}
|
||||||
})(Mibew);
|
})(Mibew);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"version": "0.0.1",
|
"version": "0.0.2",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"gulp": ">3.8.10",
|
"gulp": ">3.8.10",
|
||||||
"event-stream": ">3.1.7",
|
"event-stream": ">3.1.7",
|
||||||
|
Loading…
Reference in New Issue
Block a user