JS: Add and Update JSDoc for responsive tab bar behavior

refs #8590
This commit is contained in:
Florian Strohmaier 2016-03-29 15:10:03 +02:00
parent 28b8b32290
commit 98e754cb11

View File

@ -11,15 +11,37 @@
cacheBreakpoints($this, _this); cacheBreakpoints($this, _this);
}); });
} }
/**
* Flag container as being rendered
*
* @param {object} e - The behavior
*/
function onFixControls(e) { function onFixControls(e) {
var $this = $(this); var $this = $(this);
var _this = e.data.self; var _this = e.data.self;
if ($this.find('.tabs')) { if ($this.find('.tabs')) {
/**
* Cache break points for #col1 and #col2
*
* @param {object} e - The behavior
*/
updateBreakIndex($this, _this); updateBreakIndex($this, _this);
/**
* Update container's break index if it has been already rendered
*
* @param {object} e - The behavior
*/
} }
} }
/**
* Cache tab break points in container
*
* @param {jQuery} $container - Element containing the tabs
*
* @param {object} e - The behavior
*/
function cacheBreakpoints($container, e) { function cacheBreakpoints($container, e) {
var containerData = {}; var containerData = {};
var w = $container.find('.dropdown-nav-item').outerWidth(true)+1; var w = $container.find('.dropdown-nav-item').outerWidth(true)+1;
@ -30,6 +52,13 @@
e.containerData[$container.attr('id')] = containerData; e.containerData[$container.attr('id')] = containerData;
} }
/**
* Check Breakpoints and accordingly set the breakIndex
*
* @param {jQuery} $container - Element containing the tabs
*
* @param {object} e - The behavior
*/
function updateBreakIndex($container, e) { function updateBreakIndex($container, e) {
var b = false; var b = false;
var breakPoints = e.containerData[$container.attr('id')].breakPoints; var breakPoints = e.containerData[$container.attr('id')].breakPoints;
@ -42,12 +71,14 @@
setBreakIndex($container, b, e); setBreakIndex($container, b, e);
} }
/** /**
* Set the breakIndex and if value has changed render Tabs * Set the breakIndex and if value has changed render Tabs
* *
* @param {jQuery} $container Element containing the tabs * @param {jQuery} $container - Element containing the tabs
* *
* @param {Int} NewIndex New Value for the breakIndex * @param {int} newIndex - The index to be set
*
* @param {object} e - The behavior
*/ */
function setBreakIndex($container, newIndex, e) { function setBreakIndex($container, newIndex, e) {
var containerData = e.containerData[$container.attr("id")]; var containerData = e.containerData[$container.attr("id")];
@ -62,7 +93,9 @@
/** /**
* Render Tabs of a container according to the updated breakIndex * Render Tabs of a container according to the updated breakIndex
* *
* @param {jQuery} $container Element containing the tabs * @param {jQuery} $container - Element containing the tabs
*
* @param {object} e - The behavior
*/ */
function renderTabs($container, e) { function renderTabs($container, e) {
var breakIndex = e.containerData[$container.attr('id')].breakIndex; var breakIndex = e.containerData[$container.attr('id')].breakIndex;