1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-27 18:00:30 +02:00

Use fadeIn and fadeOut for tab visibility...

This commit is contained in:
Lóna Lore
2017-01-21 11:27:36 +01:00
parent d7846f877c
commit cb73f12d55
2 changed files with 44 additions and 10 deletions

View File

@@ -796,26 +796,27 @@ class page_admin_ui extends e_admin_ui
$tabId = 'additional'; $tabId = 'additional';
$data = array( $data = array(
'tabs' => $this->getTabs(), 'tabs' => $this->getTabs(),
'legend' => '', 'legend' => '',
'fields' => $this->getFields(), 'fields' => $this->getFields(),
); );
$text = $this->getUI()->renderCreateFieldset($elid, $data, $model, $tabId); $text = $this->getUI()->renderCreateFieldset($elid, $data, $model, $tabId);
$displayMode = 'inline-block';
$ajax = e107::getAjax();
$commands = array();
if(empty($text)) if(empty($text))
{ {
$text = ""; // There are no additional fields for the selected chapter. $text = ""; // There are no additional fields for the selected chapter.
$displayMode = 'none'; $commands[] = $ajax->commandInvoke('a[href="#tab' . $tabId . '"]', 'fadeOut');
}
else
{
$commands[] = $ajax->commandInvoke('a[href="#tab' . $tabId . '"]', 'fadeInAdminTab');
} }
$ajax = e107::getAjax();
$commands = array();
$commands[] = $ajax->commandInvoke('#tab' . $tabId, 'html', array($text)); $commands[] = $ajax->commandInvoke('#tab' . $tabId, 'html', array($text));
// Show/hide tab.
$commands[] = $ajax->commandInvoke('a[href="#tab' . $tabId . '"]', 'css', array('display', $displayMode));
$ajax->response($commands); $ajax->response($commands);
exit; exit;

View File

@@ -53,6 +53,39 @@ var e107 = e107 || {'settings': {}, 'behaviors': {}};
})(jQuery); })(jQuery);
(function (jQuery)
{
/**
* jQuery extension to make admin tab 'fadeIn' with 'display: inline-block'.
*
* @param displayMode
* A string determining display mode for element after the animation.
* Default: 'inline-block'.
* @param duration
* A string or number determining how long the animation will run.
* Default: 400.
*/
jQuery.fn.fadeInAdminTab = function (displayMode, duration)
{
var $this = $(this);
if($this.css('display') !== 'none')
{
return;
}
displayMode = displayMode || 'inline-block';
duration = duration || 400;
$this.fadeIn(duration, function ()
{
$this.css('display', displayMode);
});
};
})(jQuery);
$(document).ready(function() $(document).ready(function()
{ {