@@ -4,32 +4,37 @@ $(function (){
44
55 ripples . init ( ".btn:not(.btn-link), .navbar a, .nav-tabs a, .withripple" ) ;
66
7- // Add fake-checkbox to material checkboxes
8- $ ( ".checkbox > label > input" ) . after ( "<span class=check></span>" ) ;
7+ $ ( document ) . bind ( "DOMSubtreeModified" , function ( ) {
8+ // Add fake-checkbox to material checkboxes
9+ $ ( ".checkbox > label > input" ) . not ( ".bs-material" ) . addClass ( "bs-material" ) . after ( "<span class=check></span>" ) ;
910
10- // Add fake-radio to material radios
11- $ ( ".radio > label > input" ) . after ( "<span class=circle></span><span class=check></span>" ) ;
11+ // Add fake-radio to material radios
12+ $ ( ".radio > label > input" ) . not ( ".bs-material" ) . addClass ( "bs-material ") . after ( "<span class=circle></span><span class=check></span>" ) ;
1213
13- // Add elements for material inputs
14- $ ( "input.form-control, textarea.form-control, select.form-control" ) . each ( function ( ) {
15- $ ( this ) . wrap ( "<div class=form-control-wrapper></div>" ) ;
16- $ ( this ) . after ( "<span class=material-input></span>" ) ;
17- if ( $ ( this ) . hasClass ( "floating-label" ) ) {
18- var placeholder = $ ( this ) . attr ( "placeholder" ) ;
19- $ ( this ) . attr ( "placeholder" , null ) . removeClass ( "floating-label" ) ;
20- $ ( this ) . after ( "<div class=floating-label>" + placeholder + "</div>" ) ;
21- }
22- if ( $ ( this ) . is ( ":empty" ) || $ ( this ) . val ( ) === null || $ ( this ) . val ( ) == "undefined" || $ ( this ) . val ( ) === "" ) {
23- $ ( this ) . addClass ( "empty" ) ;
24- }
14+ // Add elements for material inputs
15+ $ ( "input.form-control, textarea.form-control, select.form-control" ) . not ( ".bs-material" ) . each ( function ( ) {
16+ $ ( this ) . addClass ( "bs-material" ) ;
17+ $ ( this ) . wrap ( "<div class=form-control-wrapper></div>" ) ;
18+ $ ( this ) . after ( "<span class=material-input></span>" ) ;
19+ if ( $ ( this ) . hasClass ( "floating-label" ) ) {
20+ var placeholder = $ ( this ) . attr ( "placeholder" ) ;
21+ $ ( this ) . attr ( "placeholder" , null ) . removeClass ( "floating-label" ) ;
22+ $ ( this ) . after ( "<div class=floating-label>" + placeholder + "</div>" ) ;
23+ }
24+ if ( $ ( this ) . is ( ":empty" ) || $ ( this ) . val ( ) === null || $ ( this ) . val ( ) == "undefined" || $ ( this ) . val ( ) === "" ) {
25+ $ ( this ) . addClass ( "empty" ) ;
26+ }
27+
28+ if ( $ ( this ) . parent ( ) . next ( ) . is ( "[type=file]" ) ) {
29+ $ ( this ) . parent ( ) . addClass ( "fileinput" ) ;
30+ var $input = $ ( this ) . parent ( ) . next ( ) . detach ( ) ;
31+ $ ( this ) . after ( $input ) ;
32+ }
33+ } ) ;
2534
26- if ( $ ( this ) . parent ( ) . next ( ) . is ( "[type=file]" ) ) {
27- $ ( this ) . parent ( ) . addClass ( "fileinput" ) ;
28- var $input = $ ( this ) . parent ( ) . next ( ) . detach ( ) ;
29- $ ( this ) . after ( $input ) ;
30- }
3135 } ) ;
3236
37+
3338 $ ( document ) . on ( "keyup change" , ".form-control" , function ( ) {
3439 var self = $ ( this ) ;
3540 setTimeout ( function ( ) {
0 commit comments