Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.

Commit d7dc563

Browse files
committed
Move unique ID functions to core
1 parent f40d341 commit d7dc563

File tree

2 files changed

+22
-12
lines changed

2 files changed

+22
-12
lines changed

js/jquery.mobile.core.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,26 @@ define( [ "jquery", "./jquery.mobile.ns", "json!../package.json" ], function( jQ
350350
$.find.matchesSelector = function( node, expr ) {
351351
return $.find( expr, null, null, [ node ] ).length > 0;
352352
};
353+
//Needed for ui widgets
354+
//TODO: Remove once ui core is pulled in
355+
var uuid = 0,
356+
runiqueId = /^ui-id-\d+$/;
357+
$.fn.extend({
358+
uniqueId: function() {
359+
return this.each(function() {
360+
if ( !this.id ) {
361+
this.id = "ui-id-" + (++uuid);
362+
}
363+
});
364+
},
365+
removeUniqueId: function() {
366+
return this.each(function() {
367+
if ( runiqueId.test( this.id ) ) {
368+
$( this ).removeAttr( "id" );
369+
}
370+
});
371+
}
372+
});
353373
})( jQuery, this );
354374
//>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
355375
});

js/widgets/tabs.js

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,13 @@
77
define( [ "jquery", "../jquery.mobile.widget", "../jquery.mobile.core","../jquery.ui.tabs", "../jquery.mobile.registry" ], function( jQuery ) {
88
//>>excludeEnd("jqmBuildExclude");
99
(function( $, undefined ) {
10-
var uuid = 0,
11-
runiqueId = /^ui-id-\d+$/;
12-
$.fn.extend({
13-
uniqueId: function() {
14-
return this.each(function() {
15-
if ( !this.id ) {
16-
this.id = "ui-id-" + (++uuid);
17-
}
18-
});
19-
}
20-
});
21-
10+
2211
$.widget("mobile.tabs", $.mobile.widget, $.ui.tabs.prototype);
2312

2413
$.mobile.tabs.initSelector = ":jqmData(role='tabs'), :jqmData(content='tabs')";
2514

2615
$.mobile._enhancer.add( "mobile.tabs" );
16+
2717
})( jQuery );
2818
//>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
2919
});

0 commit comments

Comments
 (0)