mirror of
https://github.com/Mibew/advanced-button-plugin.git
synced 2025-04-12 04:50:10 +03:00
Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
1bd23cf2c0 | |||
9a4dd4e8f5 | |||
d0f5b645bf | |||
bbeda61ab3 | |||
52c54dd5a5 | |||
6c89719f8b | |||
c29c7eeb5b | |||
16da0abed8 | |||
cda4d7041d | |||
3dc6be5a3f | |||
bcca037801 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,5 +1,6 @@
|
|||||||
# Do not index node.js modules that are used for building
|
# Do not index node.js modules that are used for building
|
||||||
node_modules
|
node_modules
|
||||||
|
package-lock.json
|
||||||
|
|
||||||
# Do not index releases
|
# Do not index releases
|
||||||
release
|
release
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
* Copyright 2018 the original author or authors.
|
* Copyright 2018, 2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -18,10 +18,7 @@
|
|||||||
namespace Mibew\Mibew\Plugin\AdvancedButton;
|
namespace Mibew\Mibew\Plugin\AdvancedButton;
|
||||||
|
|
||||||
use Mibew\Asset\Generator\UrlGeneratorInterface as AssetUrlGeneratorInterface;
|
use Mibew\Asset\Generator\UrlGeneratorInterface as AssetUrlGeneratorInterface;
|
||||||
use Mibew\Database;
|
|
||||||
use Mibew\EventDispatcher\EventDispatcher;
|
use Mibew\EventDispatcher\EventDispatcher;
|
||||||
use Mibew\EventDispatcher\Events;
|
|
||||||
use Mibew\Thread;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides an ability to automatically refresh the button and set its
|
* Provides an ability to automatically refresh the button and set its
|
||||||
@ -84,7 +81,7 @@ class Plugin extends \Mibew\Plugin\AbstractPlugin implements \Mibew\Plugin\Plugi
|
|||||||
*/
|
*/
|
||||||
public static function getVersion()
|
public static function getVersion()
|
||||||
{
|
{
|
||||||
return '0.0.3';
|
return '0.1.0';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -95,7 +92,7 @@ class Plugin extends \Mibew\Plugin\AbstractPlugin implements \Mibew\Plugin\Plugi
|
|||||||
public function refreshButton(&$args)
|
public function refreshButton(&$args)
|
||||||
{
|
{
|
||||||
$g = $args['asset_url_generator'];
|
$g = $args['asset_url_generator'];
|
||||||
$args['response']['load']['refresh'] = $g->generate($this->getFilesPath() . '/js/refresh.js', AssetUrlGeneratorInterface::ABSOLUTE_URL);
|
$args['response']['load']['refresh'] = $g->generate(str_replace(DIRECTORY_SEPARATOR, '/', $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);
|
$args['response']['data']['refreshButton'] = array('mode' => $this->mode, 'submode' => $this->submode);
|
||||||
|
@ -6,7 +6,7 @@ var eventStream = require('event-stream'),
|
|||||||
gzip = require('gulp-gzip'),
|
gzip = require('gulp-gzip'),
|
||||||
rename = require('gulp-rename');
|
rename = require('gulp-rename');
|
||||||
|
|
||||||
gulp.task('prepare-release', [], function() {
|
gulp.task('prepare-release', function() {
|
||||||
var version = require('./package.json').version;
|
var version = require('./package.json').version;
|
||||||
|
|
||||||
return eventStream.merge(
|
return eventStream.merge(
|
||||||
@ -21,9 +21,7 @@ gulp.task('prepare-release', [], function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Builds and packs plugins sources
|
// Builds and packs plugins sources
|
||||||
gulp.task('default', ['prepare-release'], function() {
|
gulp.task('default', gulp.series('prepare-release'));
|
||||||
// The "default" task is just an alias for "prepare-release" task.
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns files stream with the plugin sources.
|
* Returns files stream with the plugin sources.
|
||||||
|
@ -1,9 +1,45 @@
|
|||||||
|
/*!
|
||||||
|
* This file is a part of Mibew Advanced Button Plugin
|
||||||
|
*
|
||||||
|
* Copyright 2014, 2018, 2021 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
(function(Mibew) {
|
(function(Mibew) {
|
||||||
Mibew.APIFunctions.refreshButton = function(data) {
|
Mibew.APIFunctions.refreshButton = function(data) {
|
||||||
// Refresh the button image
|
|
||||||
var img = document.getElementById("mibew-agent-button").getElementsByTagName("img")[0];
|
var button_object;
|
||||||
var originalSrc = img.src.replace(/&dummy=\d+/, '');
|
|
||||||
img.src = originalSrc + "&dummy=" + (new Date()).getTime();
|
var button = document.getElementById("mibew-agent-button");
|
||||||
|
if (!button) {
|
||||||
|
// The button is operator code field
|
||||||
|
button_object = document.getElementById("mibew-operator-code-field");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
button_object = button.getElementsByTagName("img")[0];
|
||||||
|
if (!button_object) {
|
||||||
|
// The button is text link
|
||||||
|
button_object = button;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// The button is image, refresh it
|
||||||
|
var originalSrc = button_object.src.replace(/&dummy=\d+/, '');
|
||||||
|
button_object.src = originalSrc + "&dummy=" + (new Date()).getTime();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unable to find button of any type - nothing to do
|
||||||
|
if (!button_object) { return; }
|
||||||
|
|
||||||
// Hide the button if all popups are open or make it visible otherwise
|
// Hide the button if all popups are open or make it visible otherwise
|
||||||
var visible = false;
|
var visible = false;
|
||||||
@ -15,20 +51,20 @@
|
|||||||
// Check whether we actually need to hide the button
|
// Check whether we actually need to hide the button
|
||||||
if (data.refreshButton.mode != 'none') {
|
if (data.refreshButton.mode != 'none') {
|
||||||
if (data.refreshButton.mode == 'visibility') {
|
if (data.refreshButton.mode == 'visibility') {
|
||||||
img.style.visibility = visible ? 'visible' : 'hidden';
|
button_object.style.visibility = visible ? 'visible' : 'hidden';
|
||||||
}
|
}
|
||||||
else if (data.refreshButton.mode == 'display') {
|
else if (data.refreshButton.mode == 'display') {
|
||||||
img.style.display = visible ? data.refreshButton.submode : 'none';
|
button_object.style.display = visible ? data.refreshButton.submode : 'none';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set appropriate class for the button depending on its alleged visibility
|
// Set appropriate class for the button depending on its alleged visibility
|
||||||
img.className = img.className.replace(/ mibew_(visible|hidden)/, '');
|
button_object.className = button_object.className.replace(/ mibew_(visible|hidden)/, '');
|
||||||
if (visible) {
|
if (visible) {
|
||||||
img.className = img.className.concat(' mibew_visible');
|
button_object.className = button_object.className.concat(' mibew_visible');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
img.className = img.className.concat(' mibew_hidden');
|
button_object.className = button_object.className.concat(' mibew_hidden');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})(Mibew);
|
})(Mibew);
|
||||||
|
18
package.json
18
package.json
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"version": "0.0.3",
|
"version": "0.1.0",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"gulp": ">3.8.10",
|
"gulp": "~4.0.0",
|
||||||
"event-stream": ">3.1.7",
|
"event-stream": "~3.3.4",
|
||||||
"gulp-zip": ">2.0.2",
|
"gulp-zip": "~2.0.2",
|
||||||
"gulp-tar": ">1.3.1",
|
"gulp-tar": "~3.1.0",
|
||||||
"gulp-gzip": ">0.0.8",
|
"gulp-gzip": "~0.0.8",
|
||||||
"gulp-chmod": ">1.2.0",
|
"gulp-chmod": "~3.0.0",
|
||||||
"gulp-rename": ">1.2.0"
|
"gulp-rename": "~1.2.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user