mirror of
https://ghproxy.net/https://github.com/AlxMedia/magaziner.git
synced 2025-08-28 19:02:57 +08:00
Initial commit
This commit is contained in:
commit
b0607606ae
369 changed files with 85494 additions and 0 deletions
32
functions/kirki/modules/preset/preset.js
Normal file
32
functions/kirki/modules/preset/preset.js
Normal file
|
@ -0,0 +1,32 @@
|
|||
/* global kirkiSetSettingValue */
|
||||
jQuery( document ).ready( function() {
|
||||
|
||||
// Loop Controls.
|
||||
wp.customize.control.each( function( control ) {
|
||||
|
||||
// Check if we have a preset defined.
|
||||
if ( control.params && control.params.preset && ! _.isEmpty( control.params.preset ) ) {
|
||||
wp.customize( control.id, function( value ) {
|
||||
|
||||
// Listen to value changes.
|
||||
value.bind( function( to ) {
|
||||
|
||||
// Loop preset definitions.
|
||||
_.each( control.params.preset, function( preset, valueToListen ) {
|
||||
|
||||
// Check if the value set want is the same as the one we're looking for.
|
||||
if ( valueToListen === to ) {
|
||||
|
||||
// Loop settings defined inside the preset.
|
||||
_.each( preset.settings, function( controlValue, controlID ) {
|
||||
|
||||
// Set the value.
|
||||
kirkiSetSettingValue.set( controlID, controlValue );
|
||||
} );
|
||||
}
|
||||
} );
|
||||
} );
|
||||
} );
|
||||
}
|
||||
} );
|
||||
} );
|
Loading…
Add table
Add a link
Reference in a new issue