-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathjquery.ui.markup.js
48 lines (39 loc) · 1.22 KB
/
jquery.ui.markup.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
(function( $ ) {
var namespace = "data-ui",
optionsNamespace = namespace+"-";
function attrToOption( attr ) {
attr = attr.substring( optionsNamespace.length ).toLowerCase();
return attr.replace( /-.?/g, function( string ) {
return string.charAt( 1 ).toUpperCase();
});
}
function callUI( element, ui, options ) {
element[ ui ]( options );
}
$( document ).ready(function() {
$( "["+namespace+"]" ).each(function() {
var i, name, options = {}, value,
$this = $( this ),
ui = $this.data("ui");
for ( i = 0; i < this.attributes.length; i++ ) {
name = this.attributes[i].name;
value = this.attributes[i].value;
if ( name.indexOf( optionsNamespace ) === 0 && name.length > optionsNamespace.length ) {
if ( /(true|false)/i.test( value ) ) {
value = value.toLowerCase() === "true";
} else if ( !isNaN( value ) ) {
value = +value;
} else if ( value.charAt(0) === "{" ) {
value = eval("("+value+")");
}
options[ attrToOption( name ) ] = value;
}
}
if ( /(addClass|effect|hide|show|toggle)/i.test( ui ) && options.delay ) {
window.setTimeout(function() { callUI( $this, ui, options ); }, options.delay );
} else {
callUI( $this, ui, options );
}
});
});
}( jQuery ) );