diff --git a/src/MegaMenu.php b/src/MegaMenu.php index 1ce3c9a..2426379 100644 --- a/src/MegaMenu.php +++ b/src/MegaMenu.php @@ -34,43 +34,13 @@ class MegaMenu extends Backend */ public function toggleColumnIcon($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 column - */ - public function toggleVisibility($intId, $blnVisible) - { - $this->createInitialVersion('tl_rocksolid_mega_menu_column', $intId); - - // Trigger the save_callback - if (is_array($GLOBALS['TL_DCA']['tl_rocksolid_mega_menu_column']['fields']['published']['save_callback'] ?? null)) { - foreach ($GLOBALS['TL_DCA']['tl_rocksolid_mega_menu_column']['fields']['published']['save_callback'] as $callback) { - $this->import($callback[0]); - $blnVisible = $this->{$callback[0]}->{$callback[1]}($blnVisible, $this); - } - } - - $this->Database - ->prepare("UPDATE tl_rocksolid_mega_menu_column SET tstamp=". time() .", published='" . ($blnVisible ? 1 : '') . "' WHERE id=?") - ->execute($intId); - - $this->createNewVersion('tl_rocksolid_mega_menu_column', $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) . '"') . ' '; } /** diff --git a/src/Resources/contao/dca/tl_rocksolid_mega_menu_column.php b/src/Resources/contao/dca/tl_rocksolid_mega_menu_column.php index a2cb3c9..091e13d 100644 --- a/src/Resources/contao/dca/tl_rocksolid_mega_menu_column.php +++ b/src/Resources/contao/dca/tl_rocksolid_mega_menu_column.php @@ -84,9 +84,9 @@ ), 'toggle' => array( 'label' => &$GLOBALS['TL_LANG']['tl_rocksolid_mega_menu_column']['toggle'], + 'href' => 'act=toggle&field=published', 'icon' => 'visible.gif', - 'attributes' => 'onclick="Backend.getScrollOffset();return AjaxRequest.toggleVisibility(this,%s)"', - 'button_callback' => array('MadeYourDay\\RockSolidMegaMenu\\MegaMenu', 'toggleColumnIcon'), + 'button_callback' => array('MadeYourDay\\RockSolidSlider\\Slider', 'toggleSlideIcon'), ), 'show' => array( 'label' => &$GLOBALS['TL_LANG']['tl_rocksolid_mega_menu_column']['show'], @@ -281,6 +281,7 @@ 'label' => &$GLOBALS['TL_LANG']['tl_rocksolid_mega_menu_column']['published'], 'exclude' => true, 'filter' => true, + 'toggle' => true, 'flag' => 1, 'inputType' => 'checkbox', 'eval' => array('doNotCopy'=>true),