| @@ 4-93 (lines=90) @@ | ||
| 1 | /* global kirkiL10n, kirki */ |
|
| 2 | wp.customize.controlConstructor['kirki-typography'] = wp.customize.kirkiDynamicControl.extend({ |
|
| 3 | ||
| 4 | initKirkiControl: function() { |
|
| 5 | ||
| 6 | 'use strict'; |
|
| 7 | ||
| 8 | var control = this, |
|
| 9 | value = control.setting._value, |
|
| 10 | picker; |
|
| 11 | ||
| 12 | control.renderFontSelector(); |
|
| 13 | control.renderBackupFontSelector(); |
|
| 14 | control.renderVariantSelector(); |
|
| 15 | control.renderSubsetSelector(); |
|
| 16 | ||
| 17 | // Font-size. |
|
| 18 | if ( control.params['default']['font-size'] ) { |
|
| 19 | this.container.on( 'change keyup paste', '.font-size input', function() { |
|
| 20 | control.saveValue( 'font-size', jQuery( this ).val() ); |
|
| 21 | }); |
|
| 22 | } |
|
| 23 | ||
| 24 | // Line-height. |
|
| 25 | if ( control.params['default']['line-height'] ) { |
|
| 26 | this.container.on( 'change keyup paste', '.line-height input', function() { |
|
| 27 | control.saveValue( 'line-height', jQuery( this ).val() ); |
|
| 28 | }); |
|
| 29 | } |
|
| 30 | ||
| 31 | // Margin-top. |
|
| 32 | if ( control.params['default']['margin-top'] ) { |
|
| 33 | this.container.on( 'change keyup paste', '.margin-top input', function() { |
|
| 34 | control.saveValue( 'margin-top', jQuery( this ).val() ); |
|
| 35 | }); |
|
| 36 | } |
|
| 37 | ||
| 38 | // Margin-bottom. |
|
| 39 | if ( control.params['default']['margin-bottom'] ) { |
|
| 40 | this.container.on( 'change keyup paste', '.margin-bottom input', function() { |
|
| 41 | control.saveValue( 'margin-bottom', jQuery( this ).val() ); |
|
| 42 | }); |
|
| 43 | } |
|
| 44 | ||
| 45 | // Letter-spacing. |
|
| 46 | if ( control.params['default']['letter-spacing'] ) { |
|
| 47 | value['letter-spacing'] = ( jQuery.isNumeric( value['letter-spacing'] ) ) ? value['letter-spacing'] + 'px' : value['letter-spacing']; |
|
| 48 | this.container.on( 'change keyup paste', '.letter-spacing input', function() { |
|
| 49 | value['letter-spacing'] = ( jQuery.isNumeric( jQuery( this ).val() ) ) ? jQuery( this ).val() + 'px' : jQuery( this ).val(); |
|
| 50 | control.saveValue( 'letter-spacing', value['letter-spacing'] ); |
|
| 51 | }); |
|
| 52 | } |
|
| 53 | ||
| 54 | // Word-spacing. |
|
| 55 | if ( control.params['default']['word-spacing'] ) { |
|
| 56 | this.container.on( 'change keyup paste', '.word-spacing input', function() { |
|
| 57 | control.saveValue( 'word-spacing', jQuery( this ).val() ); |
|
| 58 | }); |
|
| 59 | } |
|
| 60 | ||
| 61 | // Text-align. |
|
| 62 | if ( control.params['default']['text-align'] ) { |
|
| 63 | this.container.on( 'change', '.text-align input', function() { |
|
| 64 | control.saveValue( 'text-align', jQuery( this ).val() ); |
|
| 65 | }); |
|
| 66 | } |
|
| 67 | ||
| 68 | // Text-transform. |
|
| 69 | if ( control.params['default']['text-transform'] ) { |
|
| 70 | jQuery( control.selector + ' .text-transform select' ).selectWoo().on( 'change', function() { |
|
| 71 | control.saveValue( 'text-transform', jQuery( this ).val() ); |
|
| 72 | }); |
|
| 73 | } |
|
| 74 | ||
| 75 | // Text-decoration. |
|
| 76 | if ( control.params['default']['text-decoration'] ) { |
|
| 77 | jQuery( control.selector + ' .text-decoration select' ).selectWoo().on( 'change', function() { |
|
| 78 | control.saveValue( 'text-decoration', jQuery( this ).val() ); |
|
| 79 | }); |
|
| 80 | } |
|
| 81 | ||
| 82 | // Color. |
|
| 83 | if ( control.params['default'].color ) { |
|
| 84 | picker = this.container.find( '.kirki-color-control' ); |
|
| 85 | picker.wpColorPicker({ |
|
| 86 | change: function() { |
|
| 87 | setTimeout( function() { |
|
| 88 | control.saveValue( 'color', picker.val() ); |
|
| 89 | }, 100 ); |
|
| 90 | } |
|
| 91 | }); |
|
| 92 | } |
|
| 93 | }, |
|
| 94 | ||
| 95 | /** |
|
| 96 | * Adds the font-families to the font-family dropdown |
|
| @@ 19-101 (lines=83) @@ | ||
| 16 | } |
|
| 17 | }, |
|
| 18 | ||
| 19 | initKirkiControl: function() { |
|
| 20 | ||
| 21 | 'use strict'; |
|
| 22 | ||
| 23 | var control = this, |
|
| 24 | value = control.getValue(), |
|
| 25 | picker; |
|
| 26 | ||
| 27 | control.renderFontSelector(); |
|
| 28 | control.renderBackupFontSelector(); |
|
| 29 | control.renderVariantSelector(); |
|
| 30 | control.renderSubsetSelector(); |
|
| 31 | ||
| 32 | // Font-size. |
|
| 33 | if ( control.params['default']['font-size'] ) { |
|
| 34 | this.container.on( 'change keyup paste', '.font-size input', function() { |
|
| 35 | control.saveValue( 'font-size', jQuery( this ).val() ); |
|
| 36 | }); |
|
| 37 | } |
|
| 38 | ||
| 39 | // Line-height. |
|
| 40 | if ( control.params['default']['line-height'] ) { |
|
| 41 | this.container.on( 'change keyup paste', '.line-height input', function() { |
|
| 42 | control.saveValue( 'line-height', jQuery( this ).val() ); |
|
| 43 | }); |
|
| 44 | } |
|
| 45 | ||
| 46 | // Margin-top. |
|
| 47 | if ( control.params['default']['margin-top'] ) { |
|
| 48 | this.container.on( 'change keyup paste', '.margin-top input', function() { |
|
| 49 | control.saveValue( 'margin-top', jQuery( this ).val() ); |
|
| 50 | }); |
|
| 51 | } |
|
| 52 | ||
| 53 | // Margin-bottom. |
|
| 54 | if ( control.params['default']['margin-bottom'] ) { |
|
| 55 | this.container.on( 'change keyup paste', '.margin-bottom input', function() { |
|
| 56 | control.saveValue( 'margin-bottom', jQuery( this ).val() ); |
|
| 57 | }); |
|
| 58 | } |
|
| 59 | ||
| 60 | // Letter-spacing. |
|
| 61 | if ( control.params['default']['letter-spacing'] ) { |
|
| 62 | value['letter-spacing'] = ( jQuery.isNumeric( value['letter-spacing'] ) ) ? value['letter-spacing'] + 'px' : value['letter-spacing']; |
|
| 63 | this.container.on( 'change keyup paste', '.letter-spacing input', function() { |
|
| 64 | value['letter-spacing'] = ( jQuery.isNumeric( jQuery( this ).val() ) ) ? jQuery( this ).val() + 'px' : jQuery( this ).val(); |
|
| 65 | control.saveValue( 'letter-spacing', value['letter-spacing'] ); |
|
| 66 | }); |
|
| 67 | } |
|
| 68 | ||
| 69 | // Word-spacing. |
|
| 70 | if ( control.params['default']['word-spacing'] ) { |
|
| 71 | this.container.on( 'change keyup paste', '.word-spacing input', function() { |
|
| 72 | control.saveValue( 'word-spacing', jQuery( this ).val() ); |
|
| 73 | }); |
|
| 74 | } |
|
| 75 | ||
| 76 | // Text-align. |
|
| 77 | if ( control.params['default']['text-align'] ) { |
|
| 78 | this.container.on( 'change', '.text-align input', function() { |
|
| 79 | control.saveValue( 'text-align', jQuery( this ).val() ); |
|
| 80 | }); |
|
| 81 | } |
|
| 82 | ||
| 83 | // Text-transform. |
|
| 84 | if ( control.params['default']['text-transform'] ) { |
|
| 85 | jQuery( control.selector + ' .text-transform select' ).selectWoo().on( 'change', function() { |
|
| 86 | control.saveValue( 'text-transform', jQuery( this ).val() ); |
|
| 87 | }); |
|
| 88 | } |
|
| 89 | ||
| 90 | // Color. |
|
| 91 | if ( control.params['default'].color ) { |
|
| 92 | picker = this.container.find( '.kirki-color-control' ); |
|
| 93 | picker.wpColorPicker({ |
|
| 94 | change: function() { |
|
| 95 | setTimeout( function() { |
|
| 96 | control.saveValue( 'color', picker.val() ); |
|
| 97 | }, 100 ); |
|
| 98 | } |
|
| 99 | }); |
|
| 100 | } |
|
| 101 | }, |
|
| 102 | ||
| 103 | /** |
|
| 104 | * Adds the font-families to the font-family dropdown |
|