Permalink
Browse files

"collapsible" property can now also be "0" which works the same as wh…

…en set to FALSE except that all tabs can be collapsed
  • Loading branch information...
stefangabos committed Oct 13, 2017
1 parent 5cd4ed9 commit 6fc3ed9faa354cd204d0b0d67d5f153279b30a2d
Showing with 43 additions and 23 deletions.
  1. +6 −6 README.md
  2. +1 −1 dist/zebra_accordion.min.js
  3. +18 −8 dist/zebra_accordion.src.js
  4. +18 −8 src/zebra_accordion.src.js
View
@@ -148,10 +148,10 @@ $(document).ready(function() {
</tr>
<tr>
<td valign="top"><code>collapsible</code></td>
<td valign="top"><em>boolean</em></td>
<td valign="top"><em>mixed</em></td>
<td valign="top">FALSE</td>
<td valign="top">
When set to TRUE it indicates that all tabs can be collapsed; if set to FALSE, an expanded tab can be collapsed only by expanding another tab.
- when set to <code>TRUE</code> it indicates that all tabs can be collapsed<br>- if set to <code>FALSE</code>, an expanded tab can be collapsed only by expanding another tab<br>- if set to <code>0</code>, the behavior is the same when set to <code>FALSE</code> with the difference that an open tab can also be closed.
</td>
</tr>
<tr>
@@ -194,17 +194,17 @@ $(document).ready(function() {
<td valign="top">0</td>
<td valign="top">
The index (0 based) of the tab to be expanded by default.<br>
The value of this property can also be boolean FALSE, indicating that all tabs should be collapsed by default.<br>
If the value of the <strong>collapsible</strong> property is TRUE, the value of this property can also be boolean TRUE, indicating that all tabs should be expanded by default. In this case, you can also provide <em>an array</em> of indexes to be expanded by default.
The value of this property can also be boolean <code>FALSE</code>, indicating that all tabs should be collapsed by default.<br>
If the value of the <strong>collapsible</strong> property is <code>TRUE</code>, the value of this property can also be boolean <code>TRUE</code>, indicating that all tabs should be expanded by default. In this case, you can also provide <em>an array</em> of indexes to be expanded by default.
</td>
</tr>
<tr>
<td valign="top"><code>toggle_on_mouseover</code></td>
<td valign="top"><em>boolean</em></td>
<td valign="top">FALSE</td>
<td valign="top">
Set this to TRUE if tabs should be expanded when hovering the mouse over their associated <em>titles</em>.<br><br>
<blockquote>If the <strong>collapsible</strong> property is TRUE, this property will always be considered as FALSE!</blockquote>
Set this to <code>TRUE</code> if tabs should be expanded when hovering the mouse over their associated <em>titles</em>.<br><br>
<blockquote>If the <strong>collapsible</strong> property is <code>TRUE</code>, this property will always be considered as <code>FALSE</code>!</blockquote>
</td>
</tr>
</tbody>

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -21,7 +21,7 @@
* Read more {@link https://github.com/stefangabos/Zebra_Accordion/ here}
*
* @author Stefan Gabos <contact@stefangabos.ro>
* @version 1.2.8 (last revision: September 16, 2017)
* @version 1.2.8 (last revision: October 13, 2017)
* @copyright (c) 2011 - 2017 Stefan Gabos
* @license http://www.gnu.org/licenses/lgpl-3.0.txt GNU LESSER GENERAL PUBLIC LICENSE
* @package Zebra_Accordion
@@ -39,10 +39,13 @@
// Default is TRUE
collapsible: false, // If set to TRUE, an open block can also be collapsed
// - in this case, all blocks can be collapsed; if set
// to FALSE, an open block can be collapsed only by
// opening another block - in this case, only a single
// block is open at any given moment;
// - in this case, all blocks can be collapsed;
// if set to FALSE, an open block can be collapsed
// only by opening another block - in this case, only
// a single block is open at any given moment;
// if set to 0, the behavior is the same when set to
// FALSE with the difference that an open tab can
// also be closed.
//
// Default is FALSE
@@ -377,7 +380,8 @@
var block = blocks[index], // get the block's properties
$title = titles[index].element, // reference to the title element
$block = block.element; // reference to the tab element
$block = block.element, // reference to the tab element
collapsed_all = false;
// if any number of blocks can can be expanded/collapsed
// and current block is already expanded, collapse it instead
@@ -389,8 +393,11 @@
// iterate through the tabs
$titles.each(function(key) {
// if we found an expanded tab but it is not the one we're trying to expand
if (titles[key].element.hasClass(plugin.settings.expanded_class) && key !== index) {
// if we found an expanded tab but it is not the one we're trying to expand or we're closing an opened tab when plugin.settings.collapsible === 0
if (titles[key].element.hasClass(plugin.settings.expanded_class) && (key !== index || plugin.settings.collapsible === 0)) {
// if we just collapsed all tabs when plugin.settings.collapsible === 0, set a flag
if (key === index && plugin.settings.collapsible === 0) collapsed_all = true;
// collapse it
plugin.hide(key, noFx);
@@ -402,6 +409,9 @@
});
// if we just collapsed all tabs when plugin.settings.collapsible === 0, don't go further
if (collapsed_all) return false;
// if a callback function needs to be called before expanding the tab
if (plugin.settings.onBeforeOpen && typeof plugin.settings.onBeforeOpen === 'function')
View
@@ -21,7 +21,7 @@
* Read more {@link https://github.com/stefangabos/Zebra_Accordion/ here}
*
* @author Stefan Gabos <contact@stefangabos.ro>
* @version 1.2.8 (last revision: September 16, 2017)
* @version 1.2.8 (last revision: October 13, 2017)
* @copyright (c) 2011 - 2017 Stefan Gabos
* @license http://www.gnu.org/licenses/lgpl-3.0.txt GNU LESSER GENERAL PUBLIC LICENSE
* @package Zebra_Accordion
@@ -39,10 +39,13 @@
// Default is TRUE
collapsible: false, // If set to TRUE, an open block can also be collapsed
// - in this case, all blocks can be collapsed; if set
// to FALSE, an open block can be collapsed only by
// opening another block - in this case, only a single
// block is open at any given moment;
// - in this case, all blocks can be collapsed;
// if set to FALSE, an open block can be collapsed
// only by opening another block - in this case, only
// a single block is open at any given moment;
// if set to 0, the behavior is the same when set to
// FALSE with the difference that an open tab can
// also be closed.
//
// Default is FALSE
@@ -377,7 +380,8 @@
var block = blocks[index], // get the block's properties
$title = titles[index].element, // reference to the title element
$block = block.element; // reference to the tab element
$block = block.element, // reference to the tab element
collapsed_all = false;
// if any number of blocks can can be expanded/collapsed
// and current block is already expanded, collapse it instead
@@ -389,8 +393,11 @@
// iterate through the tabs
$titles.each(function(key) {
// if we found an expanded tab but it is not the one we're trying to expand
if (titles[key].element.hasClass(plugin.settings.expanded_class) && key !== index) {
// if we found an expanded tab but it is not the one we're trying to expand or we're closing an opened tab when plugin.settings.collapsible === 0
if (titles[key].element.hasClass(plugin.settings.expanded_class) && (key !== index || plugin.settings.collapsible === 0)) {
// if we just collapsed all tabs when plugin.settings.collapsible === 0, set a flag
if (key === index && plugin.settings.collapsible === 0) collapsed_all = true;
// collapse it
plugin.hide(key, noFx);
@@ -402,6 +409,9 @@
});
// if we just collapsed all tabs when plugin.settings.collapsible === 0, don't go further
if (collapsed_all) return false;
// if a callback function needs to be called before expanding the tab
if (plugin.settings.onBeforeOpen && typeof plugin.settings.onBeforeOpen === 'function')

0 comments on commit 6fc3ed9

Please sign in to comment.