//>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
//>>description: Generates dividers for listview items
//>>label: Listview Autodividers
define( [ "jquery", "./jquery.mobile.listview" ], function( $ ) {
//>>excludeEnd("jqmBuildExclude");
(function( $, undefined ) {

$.mobile.listview.prototype.options.autodividers = false;
$.mobile.listview.prototype.options.autodividersSelector = function( elt ) {
	// look for the first anchor in the item
	var text = elt.find( 'a' ).text() || elt.text() || null;

	if ( !text ) {
		return null;
	}

	// create the text for the divider (first uppercased letter)
	text = text.slice( 0, 1 ).toUpperCase();

	return text;
};

$( document ).on( "listviewcreate", "ul,ol", function() {

	var list = $( this ),
			listview = list.data( "listview" );

	if ( !listview.options.autodividers ) {
		return;
	}

	var replaceDividers = function () {
		list.find( 'li:jqmData(role=list-divider)' ).remove();

		var lis = list.find( 'li' ),
			lastDividerText = null, li, dividerText;

		for ( var i = 0; i < lis.length ; i++ ) {
			li = lis[i];
			dividerText = listview.options.autodividersSelector( $( li ) );

			if ( dividerText && lastDividerText !== dividerText ) {
				var divider = document.createElement( 'li' );
				divider.appendChild( document.createTextNode( dividerText ) );
				divider.setAttribute( 'data-' + $.mobile.ns + 'role', 'list-divider' );
				li.parentNode.insertBefore( divider, li );
			}

			lastDividerText = dividerText;
		}
	};

	var afterListviewRefresh = function () {
		list.off( 'listviewafterrefresh', afterListviewRefresh );
		replaceDividers();
		listview.refresh();
		list.on( 'listviewafterrefresh', afterListviewRefresh );
	};

	afterListviewRefresh();

});

})( jQuery );
//>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
});
//>>excludeEnd("jqmBuildExclude");

@@ -681,19 +681,34 @@
 ument ).
-on(
+delegate( %22ul,ol%22,
  %22listvi
@@ -717,25 +717,16 @@
 create%22,
- %22ul,ol%22,
  functio
@@ -1550,11 +1550,14 @@
 ist.
-off
+unbind
 ( 'l
@@ -1652,18 +1652,20 @@
 %0A%09%09list.
-on
+bind
 ( 'listv
@@ -1736,17 +1736,16 @@
 resh();%0A
-%0A
 %7D);%0A%0A%7D)(

use 1.6.4 compatible event bindings in autodividers