diff --git a/src/Resources/contao/dca/tl_rocksolid_slide.php b/src/Resources/contao/dca/tl_rocksolid_slide.php
index 50308f9..d631f8e 100644
--- a/src/Resources/contao/dca/tl_rocksolid_slide.php
+++ b/src/Resources/contao/dca/tl_rocksolid_slide.php
@@ -85,8 +85,8 @@
),
'toggle' => array(
'label' => &$GLOBALS['TL_LANG']['tl_rocksolid_slide']['toggle'],
+ 'href' => 'act=toggle&field=published',
'icon' => 'visible.gif',
- 'attributes' => 'onclick="Backend.getScrollOffset();return AjaxRequest.toggleVisibility(this,%s)"',
'button_callback' => array('MadeYourDay\\RockSolidSlider\\Slider', 'toggleSlideIcon'),
),
'show' => array(
@@ -415,6 +415,7 @@
'label' => &$GLOBALS['TL_LANG']['tl_rocksolid_slide']['published'],
'exclude' => true,
'filter' => true,
+ 'toggle' => true,
'flag' => 1,
'inputType' => 'checkbox',
'eval' => array('doNotCopy'=>true),
diff --git a/src/Slider.php b/src/Slider.php
index 06b41ce..5c7c5ac 100644
--- a/src/Slider.php
+++ b/src/Slider.php
@@ -39,43 +39,13 @@ class Slider extends Backend
*/
public function toggleSlideIcon($row, $href, $label, $title, $icon, $attributes)
{
- if (strlen(Input::get('tid'))) {
- $this->toggleVisibility(Input::get('tid'), (Input::get('state') == 1));
- if (Environment::get('isAjaxRequest')) {
- exit;
- }
- $this->redirect($this->getReferer());
- }
-
- $href .= '&id=' . Input::get('id') . '&tid=' . $row['id'] . '&state=' . ($row['published'] ? '' : 1);
+ $href .= '&id=' . $row['id'];
if (! $row['published']) {
$icon = 'invisible.gif';
}
- return '' . Image::getHtml($icon, $label) . ' ';
- }
-
- /**
- * Disable/enable a slide
- */
- public function toggleVisibility($intId, $blnVisible)
- {
- $this->createInitialVersion('tl_rocksolid_slide', $intId);
-
- // Trigger the save_callback
- if (is_array($GLOBALS['TL_DCA']['tl_rocksolid_slide']['fields']['published']['save_callback'] ?? null)) {
- foreach ($GLOBALS['TL_DCA']['tl_rocksolid_slide']['fields']['published']['save_callback'] as $callback) {
- $this->import($callback[0]);
- $blnVisible = $this->{$callback[0]}->{$callback[1]}($blnVisible, $this);
- }
- }
-
- $this->Database
- ->prepare("UPDATE tl_rocksolid_slide SET tstamp=". time() .", published='" . ($blnVisible ? 1 : '') . "' WHERE id=?")
- ->execute($intId);
-
- $this->createNewVersion('tl_rocksolid_slide', $intId);
+ return '' . Image::getHtml($icon, $label, 'data-icon="' . Image::getPath('visible.svg') . '" data-icon-disabled="' . Image::getPath('invisible.svg') . '" data-state="' . ($row['published'] ? 1 : 0) . '"') . ' ';
}
public function sliderLicenseButton($href, $label, $title, $class, $attributes)