Skip to content

Instantly share code, notes, and snippets.

@anteprimorac
Created January 11, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anteprimorac/b90ea98e81942bf22820 to your computer and use it in GitHub Desktop.
Save anteprimorac/b90ea98e81942bf22820 to your computer and use it in GitHub Desktop.
( function( wp, $ ) {
wp.customize.LayoutControl = wp.customize.Control.extend({
ready: function() {
var control = this,
radios = $( '.radios', this.container ),
selection = $( '.selection', this.container );
radios.hide();
$( '.layout[data-value="' + control.setting.get() + '"]', selection ).addClass( 'selected' );
$( '.layout .icon', selection ).on( 'click', function( event ) {
event.preventDefault();
var layout = $( this ).closest( '.layout' );
if ( layout.hasClass( 'selected' ) ) return;
var container = layout.closest( '.customize-control-layout' );
$( '.selection .layout', container ).removeClass( 'selected' );
layout.addClass( 'selected' );
control.setting.set( layout.data( 'value' ) );
} );
}
});
$.extend( wp.customize.controlConstructor, {
'layout': wp.customize.LayoutControl,
} );
} )( wp, jQuery );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment