*
* This will enable collapsible-functionality on all passed elements.
* Will prevent binding twice to the same element.
*
* This will enable collapsible-functionality on all passed elements.
* Will prevent binding twice to the same element.
* Elements made collapsible have class "kr-made-collapsible".
* Except for tables and lists, the inner content is wrapped in "kr-collapsible-content".
*
* Elements made collapsible have class "kr-made-collapsible".
* Except for tables and lists, the inner content is wrapped in "kr-collapsible-content".
*
- * @license CC-BY 2.0 NL <http://creativecommons.org/licenses/by/2.0/nl/deed.en>
+ * @TODO: Remove old "kr-" prefix
+ *
+ * Dual license:
+ * @license CC-BY 3.0 <http://creativecommons.org/licenses/by/3.0>
+ * @license GPL2 <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>
- collapsetext = $(this).attr('data-collapsetext'),
- expandtext = $(this).attr('data-expandtext');
+ collapsetext = $(this).attr( 'data-collapsetext' ),
+ expandtext = $(this).attr( 'data-expandtext' );
- $collapsible = $that.closest('.kr-collapsible.kr-made-collapsible').toggleClass('kr-collapsed');
- if ($that.hasClass('kr-collapsible-toggle-hide')) {
+ $collapsible = $that.closest( '.kr-collapsible.kr-made-collapsible' ).toggleClass( 'kr-collapsed' );
+ if ( $that.hasClass( 'kr-collapsible-toggle-hide' ) ) {
- .removeClass('kr-collapsible-toggle-hide').addClass('kr-collapsible-toggle-show')
- .find('> a').html(expandtext);
+ .removeClass( 'kr-collapsible-toggle-hide' ).addClass( 'kr-collapsible-toggle-show' )
+ .find( '> a' ).html( expandtext );
// Hide all direct childing table rows of this table, except the row containing the link
// Slide doens't work, but fade works fine as of jQuery 1.1.3
// http://stackoverflow.com/questions/467336/jquery-how-to-use-slidedown-or-show-function-on-a-table-row#920480
// Stop to prevent animaties from stacking up
// Hide all direct childing table rows of this table, except the row containing the link
// Slide doens't work, but fade works fine as of jQuery 1.1.3
// http://stackoverflow.com/questions/467336/jquery-how-to-use-slidedown-or-show-function-on-a-table-row#920480
// Stop to prevent animaties from stacking up
- $collapsible.find('> tbody > tr').not($that.parent().parent()).stop(true, true).fadeOut();
- } else if ($collapsible.is('ul') || $collapsible.is('ol')) {
- $collapsible.find('> li').not($that.parent()).stop(true, true).slideUp();
+ $collapsible.find( '> tbody > tr' ).not( $that.parent().parent() ).stop(true, true).fadeOut();
+
+ } else if ( $collapsible.is( 'ul' ) || $collapsible.is( 'ol' ) ) {
+ $collapsible.find( '> li' ).not($that.parent()).stop(true, true).slideUp();
+
- .removeClass('kr-collapsible-toggle-show').addClass('kr-collapsible-toggle-hide')
- .find('> a').html(collapsetext);
+ .removeClass( 'kr-collapsible-toggle-show' ).addClass( 'kr-collapsible-toggle-hide' )
+ .find( '> a' ).html( collapsetext );
- if ($collapsible.is('table')) {
- $collapsible.find('> tbody > tr').not($that.parent().parent()).stop(true, true).fadeIn();
- } else if ($collapsible.is('ul') || $collapsible.is('ol')) {
- $collapsible.find('> li').not($that.parent()).stop(true, true).slideDown();
+ if ( $collapsible.is( 'table' ) ) {
+ $collapsible.find( '> tbody > tr' ).not( $that.parent().parent() ).stop(true, true).fadeIn();
+
+ } else if ( $collapsible.is( 'ul' ) || $collapsible.is( 'ol' ) ) {
+ $collapsible.find( '> li' ).not( $that.parent() ).stop(true, true).slideDown();
+
- var $lastCell = $('tr:first th, tr:first td', that).eq(-1);
- if (!$lastCell.find('> .kr-collapsible-toggle').size()) {
- $lastCell.prepend($toggleLink);
+ var $lastCell = $( 'tr:first th, tr:first td', that ).eq(-1);
+ if ( !$lastCell.find( '> .kr-collapsible-toggle' ).size() ) {
+ $lastCell.prepend( $toggleLink );
- } else if ($that.is('ul') || $that.is('ol')) {
- if (!$('li:first', $that).find('> .kr-collapsible-toggle').size()) {
+ } else if ($that.is( 'ul' ) || $that.is( 'ol' )) {
+ if ( !$( 'li:first', $that).find( '> .kr-collapsible-toggle' ).size() ) {
- if ( $('li:first', $that).attr('value') == '' ) {
- $('li:first', $that).attr('value', '1');
+ if ( $( 'li:first', $that ).attr( 'value' ) == '' ) {
+ $( 'li:first', $that ).attr( 'value', '1' );
}
} else { // <div>, <p> etc.
// Is there an content-wrapper already made ?
// If a direct child with the class does not exists, create the wrap.
}
} else { // <div>, <p> etc.
// Is there an content-wrapper already made ?
// If a direct child with the class does not exists, create the wrap.
- if (!$that.find('g> .kr-collapsible-content').size()) {
- $that.wrapInner('<div class="kr-collapsible-content">');
+ if ( !$that.find( '> .kr-collapsible-content' ).size() ) {
+ $that.wrapInner( '<div class="kr-collapsible-content">' );