| 1 |
jQuery(document).ready(function ($) { |
| 2 |
$('.wpa-color-input').wpColorPicker(); |
| 3 |
|
| 4 |
var default_css = document.getElementById( 'wpa_default_css' ); |
| 5 |
if ( null !== default_css ) { |
| 6 |
|
| 7 |
default_css.style.display = 'none'; |
| 8 |
|
| 9 |
var button = document.createElement( 'button' ); |
| 10 |
button.type = 'button'; |
| 11 |
button.innerHTML = 'Show Default CSS <span class="dashicons dashicons-arrow-right" aria-hidden="true"></span>'; |
| 12 |
button.className = 'toggle-css button-secondary'; |
| 13 |
button.setAttribute( 'aria-controls', 'wpa_default_css' ); |
| 14 |
button.setAttribute( 'aria-expanded', false ); |
| 15 |
default_css.insertAdjacentElement( 'beforebegin', button ); |
| 16 |
|
| 17 |
button.addEventListener( 'click', function() { |
| 18 |
var target = this.getAttribute( 'aria-controls' ); |
| 19 |
var css = document.getElementById( target ); |
| 20 |
var visible = ( css.style['display'] == 'none' ) ? false : true; |
| 21 |
if ( ! visible ) { |
| 22 |
css.style.display = 'block'; |
| 23 |
this.setAttribute( 'aria-expanded', true ); |
| 24 |
this.querySelector( '.dashicons' ).classList.add( 'dashicons-arrow-down' ); |
| 25 |
this.querySelector( '.dashicons' ).classList.remove( 'dashicons-arrow-right' ); |
| 26 |
} else { |
| 27 |
css.style.display = 'none'; |
| 28 |
this.setAttribute( 'aria-expanded', false ); |
| 29 |
this.querySelector( '.dashicons' ).classList.remove( 'dashicons-arrow-down' ); |
| 30 |
this.querySelector( '.dashicons' ).classList.add( 'dashicons-arrow-right' ); |
| 31 |
} |
| 32 |
}); |
| 33 |
} |
| 34 |
var wpa_toolbar = document.getElementById( 'wpa_toolbar' ); |
| 35 |
wpa_toolbar.addEventListener( 'change', function() { |
| 36 |
var target = document.querySelector( '.wpa-toolbar-settings' ); |
| 37 |
if ( this.checked ) { |
| 38 |
target.classList.remove( 'hidden' ); |
| 39 |
target.classList.add( 'visible' ); |
| 40 |
} else { |
| 41 |
target.classList.remove( 'visible' ); |
| 42 |
target.classList.add( 'hidden' ); |
| 43 |
} |
| 44 |
}); |
| 45 |
}); |