Permalink
Browse files

Added custom icon options for collapsibles and collapsible sets

  • Loading branch information...
1 parent 27934fe commit 92a2e33789939c534c4a2684eecbdb5a26d46376 @jakeboone02 committed Mar 15, 2012
Showing with 16 additions and 4 deletions.
  1. +16 −4 js/jquery.mobile.collapsible.js
@@ -13,7 +13,6 @@ $.widget( "mobile.collapsible", $.mobile.widget, {
heading: "h1,h2,h3,h4,h5,h6,legend",
theme: null,
contentTheme: null,
- iconTheme: "d",
mini: false,
initSelector: ":jqmData(role='collapsible')"
},
@@ -23,6 +22,8 @@ $.widget( "mobile.collapsible", $.mobile.widget, {
o = this.options,
collapsible = $el.addClass( "ui-collapsible" ),
collapsibleHeading = $el.children( o.heading ).first(),
+ collapsedIcon = $el.jqmData("collapsed-icon") || o.collapsedIcon,
+ expandedIcon = $el.jqmData("expanded-icon") || o.expandedIcon,
collapsibleContent = collapsible.wrapInner( "<div class='ui-collapsible-content'></div>" ).find( ".ui-collapsible-content" ),
collapsibleSet = $el.closest( ":jqmData(role='collapsible-set')" ).addClass( "ui-collapsible-set" );
@@ -43,6 +44,14 @@ $.widget( "mobile.collapsible", $.mobile.widget, {
o.contentTheme = collapsibleSet.jqmData( "content-theme" );
}
+ // Get the preference for collapsed icon in the set
+ if ( !o.collapsedIcon ) {
+ o.collapsedIcon = collapsibleSet.jqmData( "collapsed-icon" );
+ }
+ // Get the preference for expanded icon in the set
+ if ( !o.expandedIcon ) {
+ o.expandedIcon = collapsibleSet.jqmData( "expanded-icon" );
+ }
// Gets the preference icon position in the set
if ( !o.iconPos ) {
o.iconPos = collapsibleSet.jqmData( "iconpos" );
@@ -54,6 +63,9 @@ $.widget( "mobile.collapsible", $.mobile.widget, {
}
collapsibleContent.addClass( ( o.contentTheme ) ? ( "ui-body-" + o.contentTheme ) : "");
+ collapsedIcon = $el.jqmData( "collapsed-icon" ) || o.collapsedIcon || "plus";
+ expandedIcon = $el.jqmData( "expanded-icon" ) || o.expandedIcon || "minus";
+
collapsibleHeading
//drop heading in before content
.insertBefore( collapsibleContent )
@@ -67,7 +79,7 @@ $.widget( "mobile.collapsible", $.mobile.widget, {
shadow: false,
corners: false,
iconpos: $el.jqmData( "iconpos" ) || o.iconPos || "left",
- icon: "plus",
+ icon: collapsedIcon,
mini: o.mini,
theme: o.theme
})
@@ -91,8 +103,8 @@ $.widget( "mobile.collapsible", $.mobile.widget, {
.text( isCollapse ? o.expandCueText : o.collapseCueText )
.end()
.find( ".ui-icon" )
- .toggleClass( "ui-icon-minus", !isCollapse )
- .toggleClass( "ui-icon-plus", isCollapse );
+ .toggleClass( "ui-icon-" + expandedIcon, !isCollapse )
+ .toggleClass( "ui-icon-" + collapsedIcon, isCollapse );
$this.toggleClass( "ui-collapsible-collapsed", isCollapse );
collapsibleContent.toggleClass( "ui-collapsible-content-collapsed", isCollapse ).attr( "aria-hidden", isCollapse );

0 comments on commit 92a2e33

Please sign in to comment.