diff --git a/docs/content/content-collapsible.html b/docs/content/content-collapsible.html index 40dabef3..2e6496ba 100755 --- a/docs/content/content-collapsible.html +++ b/docs/content/content-collapsible.html @@ -39,16 +39,16 @@ -

As the example notes, by default the content will be expanded. To collapse the content when the page loads, add the data-state="collapsed" attribute to the wrapper.

+

As the example notes, by default the content will be expanded. To collapse the content when the page loads, add the data-collapsed="true" attribute to the wrapper.

- <div data-role="collapsible" data-state="collapsed"> + <div data-role="collapsible" data-collapsed="true">

This code will create a collapsible widget like this:

-
+

I'm a header

I'm the collapsible content. I'm hidden by default because I have the "collapsed" state; you need to expand the header to see me.

@@ -58,19 +58,19 @@

Collapsible example

This page has 4 collapsible containers with different types of content inside.

-
+

Section 1: Collapsed text block

-

I'm closed when the page loads because I have the data-state="collapsed" attribute on my container.

+

I'm closed when the page loads because I have the data-collapsed="true" attribute on my container.

I'm the collapsible content. I'm the collapsible content. I'm the collapsible content. I'm the collapsible content. I'm the collapsible content. I'm the collapsible content. I'm the collapsible content.

Section 2: Expanded on load

-

I'm open when the page loads because I don't have the data-state="collapsed" attribute on my container.

+

I'm open when the page loads because I don't have the data-collapsed="true" attribute on my container.

I'm the collapsible content. I'm the collapsible content. I'm the collapsible content. I'm the collapsible content. I'm the collapsible content. I'm the collapsible content.

-
+

Section 3: Form elements

@@ -88,7 +88,7 @@
-
+

Section 4: Collapsed list

  • Acura
  • @@ -120,11 +120,11 @@

    I'm a header in a set of collapsibles

    I'm the collapsible content. I'm hidden by default because I have the "collapsed" state; you need to expand the header to see me.

-
+

I'm a header in a set of collapsibles

I'm the collapsible content. I'm hidden by default because I have the "collapsed" state; you need to expand the header to see me.

-
+

I'm a header in a set of collapsibles

I'm the collapsible content. I'm hidden by default because I have the "collapsed" state; you need to expand the header to see me.

diff --git a/docs/content/content-themes.html b/docs/content/content-themes.html index 7805c356..52a2b2b3 100755 --- a/docs/content/content-themes.html +++ b/docs/content/content-themes.html @@ -28,7 +28,7 @@

To set the color of the collapsible header, add the data-theme attribute to the collapsible container. The icon and body are not currently themable through data attributes, but can be styled directly with custom css.

-<div data-role="collapsible" data-state="collapsed" data-theme="a"> +<div data-role="collapsible" data-collapsed="true" data-theme="a">

Themed examples

@@ -36,7 +36,7 @@

H1 Heading

This is a paragraph that contains strong, emphasized and linked text. Here is more text so you can see how HTML markup works in content. Here is more text so you can see how HTML markup works in content.

-
+

I'm an themed collapsible

I have data-theme attribute set manually on my container to set the color to match the content block I'm in.

@@ -46,7 +46,7 @@

H1 Heading

This is a paragraph that contains strong, emphasized and linked text. Here is more text so you can see how HTML markup works in content. Here is more text so you can see how HTML markup works in content.

-
+

I'm an themed collapsible

I have data-theme attribute set manually on my container to set the color to match the content block I'm in.

@@ -56,7 +56,7 @@

H1 Heading

This is a paragraph that contains strong, emphasized and linked text. Here is more text so you can see how HTML markup works in content. Here is more text so you can see how HTML markup works in content.

-
+

I'm an themed collapsible

I have data-theme attribute set manually on my container to set the color to match the content block I'm in.

@@ -66,7 +66,7 @@

H1 Heading

This is a paragraph that contains strong, emphasized and linked text. Here is more text so you can see how HTML markup works in content. Here is more text so you can see how HTML markup works in content.

-
+

I'm an themed collapsible

I have data-theme attribute set manually on my container to set the color to match the content block I'm in.

@@ -76,7 +76,7 @@

H1 Heading

This is a paragraph that contains strong, emphasized and linked text. Here is more text so you can see how HTML markup works in content. Here is more text so you can see how HTML markup works in content.

-
+

I'm an themed collapsible

I have data-theme attribute set manually on my container to set the color to match the content block I'm in.

diff --git a/js/jquery.mobile.collapsible.js b/js/jquery.mobile.collapsible.js index 5b486eea..8bfd7178 100644 --- a/js/jquery.mobile.collapsible.js +++ b/js/jquery.mobile.collapsible.js @@ -4,23 +4,24 @@ * Dual licensed under the MIT (MIT-LICENSE.txt) and GPL (GPL-LICENSE.txt) licenses. * Note: Code is in draft form and is subject to change */ -(function($){ -$.fn.collapsible = function(options){ - return $(this).each(function(){ - var o = $.extend({ - expandCueText: ' click to expand contents', - collapseCueText: ' click to collapse contents', - collapsed: $(this).is('[data-state="collapsed"]'), - heading: '>h1,>h2,>h3,>h4,>h5,>h6,>legend', - theme: $(this).data('theme'), - iconTheme: $(this).data('icontheme') || 'd' - },options); +(function ( $ ) { +$.widget( "mobile.collapsible", $.mobile.widget, { + options: { + expandCueText: ' click to expand contents', + collapseCueText: ' click to collapse contents', + collapsed: false, + heading: '>:header,>legend', + theme: undefined, + iconTheme: 'd' + }, + _create: function(){ - //define - var collapsibleContain = $(this).addClass('ui-collapsible-contain'), - collapsibleHeading = $(this).find(o.heading).eq(0), + var $el = this.element, + o = this.options, + collapsibleContain = $el.addClass('ui-collapsible-contain'), + collapsibleHeading = $el.find(o.heading).eq(0), collapsibleContent = collapsibleContain.wrapInner('
').find('.ui-collapsible-content'), - collapsibleParent = $(this).closest('[data-role=collapsible-set]').addClass('ui-collapsible-set'); + collapsibleParent = $el.closest('[data-role="collapsible-set"]').addClass('ui-collapsible-set'); //replace collapsibleHeading if it's a legend if(collapsibleHeading.is('legend')){ @@ -141,6 +142,6 @@ $.fn.collapsible = function(options){ return false; }); - }); -}; -})(jQuery); \ No newline at end of file + } +}); +})( jQuery ); \ No newline at end of file