1010 //Add active class to nav-link based on url dynamically
1111 //Active class can be hard coded directly in html file also as required
1212 var current = location . pathname . split ( "/" ) . slice ( - 1 ) [ 0 ] . replace ( / ^ \/ | \/ $ / g, '' ) ;
13- $ ( '.nav li a' , sidebar ) . each ( function ( ) {
14- var $this = $ ( this ) ;
15- if ( current === "" ) {
16- //for root url
17- if ( $this . attr ( 'href' ) . indexOf ( "index.html" ) !== - 1 ) {
18- $ ( this ) . parents ( '.nav-item' ) . last ( ) . addClass ( 'active' ) ;
19- if ( $ ( this ) . parents ( '.sub-menu' ) . length ) {
20- $ ( this ) . closest ( '.collapse' ) . addClass ( 'show' ) ;
21- $ ( this ) . addClass ( 'active' ) ;
22- }
13+ $ ( '.nav li a' , sidebar ) . each ( function ( ) {
14+ var $this = $ ( this ) ;
15+ if ( current === "" ) {
16+ //for root url
17+ if ( $this . attr ( 'href' ) . indexOf ( "index.html" ) !== - 1 ) {
18+ $ ( this ) . parents ( '.nav-item' ) . last ( ) . addClass ( 'active' ) ;
19+ if ( $ ( this ) . parents ( '.sub-menu' ) . length ) {
20+ $ ( this ) . closest ( '.collapse' ) . addClass ( 'show' ) ;
21+ $ ( this ) . addClass ( 'active' ) ;
2322 }
2423 }
25- else {
26- //for other url
27- if ( $this . attr ( 'href' ) . indexOf ( current ) !== - 1 ) {
28- $ ( this ) . parents ( '.nav-item' ) . last ( ) . addClass ( 'active' ) ;
29- if ( $ ( this ) . parents ( '.sub-menu' ) . length ) {
30- $ ( this ) . closest ( '.collapse' ) . addClass ( 'show' ) ;
31- $ ( this ) . addClass ( 'active' ) ;
32- }
24+ } else {
25+ //for other url
26+ if ( $this . attr ( 'href' ) . indexOf ( current ) !== - 1 ) {
27+ $ ( this ) . parents ( '.nav-item' ) . last ( ) . addClass ( 'active' ) ;
28+ if ( $ ( this ) . parents ( '.sub-menu' ) . length ) {
29+ $ ( this ) . closest ( '.collapse' ) . addClass ( 'show' ) ;
30+ $ ( this ) . addClass ( 'active' ) ;
3331 }
3432 }
33+ }
3534 } )
3635
3736 //Close other submenu in sidebar on opening any
3837
39- sidebar . on ( 'show.bs.collapse' , '.collapse' , function ( ) {
38+ sidebar . on ( 'show.bs.collapse' , '.collapse' , function ( ) {
4039 sidebar . find ( '.collapse.show' ) . collapse ( 'hide' ) ;
4140 } ) ;
4241
4342
4443 //Change sidebar and content-wrapper height
4544 applyStyles ( ) ;
45+
4646 function applyStyles ( ) {
4747
4848 //setting content wrapper height
49- setTimeout ( function ( ) {
50- if ( contentWrapper . outerHeight ( ) < ( sidebar . outerHeight ( ) - footer . outerHeight ( ) ) ) {
49+ setTimeout ( function ( ) {
50+ if ( contentWrapper . outerHeight ( ) < ( sidebar . outerHeight ( ) - footer . outerHeight ( ) ) ) {
5151 contentWrapper . css ( {
52- 'min-height' :sidebar . outerHeight ( ) - footer . outerHeight ( )
52+ 'min-height' : sidebar . outerHeight ( ) - footer . outerHeight ( )
5353 } ) ;
5454 }
5555
56- if ( sidebar . outerHeight ( ) < ( contentWrapper . outerHeight ( ) + footer . outerHeight ( ) ) ) {
56+ if ( sidebar . outerHeight ( ) < ( contentWrapper . outerHeight ( ) + footer . outerHeight ( ) ) ) {
5757 sidebar . css ( {
58- 'min-height' :contentWrapper . outerHeight ( ) + footer . outerHeight ( )
58+ 'min-height' : contentWrapper . outerHeight ( ) + footer . outerHeight ( )
5959 } ) ;
6060 }
6161
7070 //Updating content wrapper height to sidebar height on expanding a menu in sidebar
7171 var clickedItem = $ ( this ) ;
7272 console . log ( clickedItem ) ;
73- if ( clickedItem . attr ( 'aria-expanded' ) === 'false' ) {
73+ if ( clickedItem . attr ( 'aria-expanded' ) === 'false' ) {
7474 var scrollTop = scroller . scrollTop ( ) - 20 ;
75- }
76- else {
75+ } else {
7776 var scrollTop = scroller . scrollTop ( ) - 100 ;
7877 }
79- setTimeout ( function ( ) {
80- if ( contentWrapper . outerHeight ( ) + footer . outerHeight ( ) !== sidebar . outerHeight ( ) ) {
81- applyStyles ( ) ;
82- scroller . animate ( { scrollTop : scrollTop } , 350 ) ;
83- }
78+ setTimeout ( function ( ) {
79+ if ( contentWrapper . outerHeight ( ) + footer . outerHeight ( ) !== sidebar . outerHeight ( ) ) {
80+ applyStyles ( ) ;
81+ scroller . animate ( {
82+ scrollTop : scrollTop
83+ } , 350 ) ;
84+ }
8485 } , 400 ) ;
8586 } ) ;
8687
8788 //checkbox and radios
8889 $ ( ".form-check label,.form-radio label" ) . append ( '<i class="input-helper"></i>' ) ;
90+
91+ $ ( ".purchace-popup .popup-dismiss" ) . on ( "click" , function ( ) {
92+ $ ( ".purchace-popup" ) . slideToggle ( ) ;
93+ } ) ;
8994 } ) ;
90- } ) ( jQuery ) ;
95+ } ) ( jQuery ) ;
0 commit comments