-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
63 lines (33 loc) · 1.5 KB
/
script.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
* GLOBAL FRONT-END SCRIPTS
*/
/* -- PANELS -- */
jQuery( document ).ready( function( $ ) {
if ( $( '[data-cpar-region^="panel"]' ).length ) {
// CONFIGS
var panelSpeed = 375;
// HELPER - CLOSE ACTIVE PANELS
function cparPanels_close() {
$( '[data-cpar-region^="panel"]:visible' ).stop().animate( { width: 'toggle' }, panelSpeed, 'linear' );
}
// ACTIONS - OPEN SPECIFIC PANEL ON CLICK
$( '.cpar-panel-open, .cpar-panel-open a' ).click( function() {
// GET HREF TARGET OF CLICKED LINK
panelName = $( this ).attr( 'href' ); // get link href value
panelName = panelName.replace('#', '').toLowerCase(); // remove # from it
// CLOSE ACTIVE PANELS
cparPanels_close();
// DISPLAY SELECTED PANEL
$( '[data-cpar-region^="'+ panelName +'"]' ).stop().delay( panelSpeed ).animate( { width: 'toggle' }, panelSpeed, 'linear' );
// DISABLE BODY SCROLLING
$( 'body' ).css( { 'overflow-y': 'hidden' } );
} );
// ACTIONS - CLOSE PANELS ON CLICK
$( '.cpar-panel-close' ).click( function() {
// HIDE PANELS
$( '[data-cpar-region^="panel"]:visible' ).stop().animate( { width: 'toggle' }, panelSpeed, 'linear' );
// ENABLE BODY SCROLLING
$( 'body' ).css( { 'overflow-y': 'auto' } );
} );
}
} );