multicheck.js 687 B

123456789101112131415161718192021222324252627
  1. (function( $, undefined ) {
  2. 'use strict';
  3. wp.customize.controlConstructor['vamtam-multicheck'] = wp.customize.Control.extend({
  4. ready: function() {
  5. var control = this;
  6. control.settingField = control.container.find( '[data-customize-setting-link]' ).first();
  7. control.container.on( 'change', 'input[type=checkbox]', function() {
  8. var new_value = {};
  9. // reset values;
  10. for ( var key in control.params.choices ) {
  11. new_value[ key ] = '';
  12. }
  13. control.container.find( 'input[type="checkbox"]:checked' ).each( function() {
  14. new_value[ $( this ).data( 'key' ) ] = this.value;
  15. } );
  16. control.setting.set( new_value );
  17. });
  18. }
  19. });
  20. })( jQuery );