Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update responsive-tabs.js #43

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions js/responsive-tabs.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will you remove this extra line break.

var fakewaffle = ( function ( $, fakewaffle ) {
'use strict';

Expand Down Expand Up @@ -32,7 +33,7 @@ var fakewaffle = ( function ( $, fakewaffle ) {
var oldLinkClass = $this.attr( 'class' ) === undefined ? '' : $this.attr( 'class' );
var newLinkClass = 'accordion-toggle';
var oldParentClass = $this.parent().attr( 'class' ) === undefined ? '' : $this.parent().attr( 'class' );
var newParentClass = 'panel panel-default';
var newParentClass = 'panel panel-default responsive';
var newHash = $this.get( 0 ).hash.replace( '#', 'collapse-' );

if ( oldLinkClass.length > 0 ) {
Expand All @@ -52,8 +53,8 @@ var fakewaffle = ( function ( $, fakewaffle ) {

collapseDiv.append(
$( '<div>' ).attr( 'class', newParentClass ).html(
$( '<div>' ).attr( 'class', 'panel-heading' ).html(
$( '<h4>' ).attr( 'class', 'panel-title' ).html(
$( '<div>' ).attr( 'class', 'panel-heading responsive' ).html(
$( '<h4>' ).attr( 'class', 'panel-title responsive' ).html(
$( '<a>', {
'class' : newLinkClass,
'data-toggle' : 'collapse',
Expand All @@ -66,13 +67,13 @@ var fakewaffle = ( function ( $, fakewaffle ) {
).append(
$( '<div>', {
'id' : newHash,
'class' : 'panel-collapse collapse'
'class' : 'panel-collapse collapse responsive'
} )
)
);
} );

$tabGroup.next().after( collapseDiv );
$tabGroup.parent().find('.tab-content.responsive').after( collapseDiv );
$tabGroup.addClass( hidden );
$( '.tab-content.responsive' ).addClass( hidden );
} );
Expand Down Expand Up @@ -105,7 +106,7 @@ var fakewaffle = ( function ( $, fakewaffle ) {
$.each( tabGroups, function ( index, tabGroup ) {

// Find the tab
var tabContents = $( tabGroup ).next( '.tab-content' ).find( '.tab-pane' );
var tabContents = $( tabGroup ).parent().find('.tab-content.responsive').find( '.tab-pane' );;

$.each( tabContents, function ( index, tabContent ) {
// Find the id to move the element to
Expand All @@ -114,7 +115,7 @@ var fakewaffle = ( function ( $, fakewaffle ) {
// Convert tab to panel and move to destination
$( tabContent )
.removeClass( 'tab-pane' )
.addClass( 'panel-body' )
.addClass( 'panel-body responsive' )
.appendTo( $( destinationId ) );

} );
Expand All @@ -133,11 +134,11 @@ var fakewaffle = ( function ( $, fakewaffle ) {
var destination = $( destinationId ).next( '.tab-content' )[ 0 ];

// Find the panel contents
var panelContents = $( panelGroup ).find( '.panel-body' );
var panelContents = $( panelGroup ).find( '.panel-body.responsive' );

// Convert to tab and move to destination
panelContents
.removeClass( 'panel-body' )
.removeClass( 'panel-body responsive' )
.addClass( 'tab-pane' )
.appendTo( $( destination ) );

Expand All @@ -148,7 +149,7 @@ var fakewaffle = ( function ( $, fakewaffle ) {
fakewaffle.bindTabToCollapse = function () {

var tabs = $( '.nav-tabs.responsive' ).find( 'li a' );
var collapse = $( '.panel-group.responsive' ).find( '.panel-collapse' );
var collapse = $( '.panel-group.responsive' ).find( '.panel-collapse responsive' );

// Toggle the panels when the associated tab is toggled
tabs.on( 'shown.bs.tab', function ( e ) {
Expand All @@ -175,8 +176,8 @@ var fakewaffle = ( function ( $, fakewaffle ) {

// Update the content with active
var panelGroup = $( e.currentTarget ).closest( '.panel-group.responsive' );
$( panelGroup ).find( '.panel-body' ).removeClass( 'active' );
$( e.currentTarget ).find( '.panel-body' ).addClass( 'active' );
$( panelGroup ).find( '.panel-body.responsive' ).removeClass( 'active' );
$( e.currentTarget ).find( '.panel-body.responsive' ).addClass( 'active' );
}

} );
Expand Down