| @@ 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 |
|
| @@ 3204-3293 (lines=90) @@ | ||
| 3201 | /* global kirkiL10n, kirki */ |
|
| 3202 | wp.customize.controlConstructor['kirki-typography'] = wp.customize.kirkiDynamicControl.extend({ |
|
| 3203 | ||
| 3204 | initKirkiControl: function() { |
|
| 3205 | ||
| 3206 | 'use strict'; |
|
| 3207 | ||
| 3208 | var control = this, |
|
| 3209 | value = control.setting._value, |
|
| 3210 | picker; |
|
| 3211 | ||
| 3212 | control.renderFontSelector(); |
|
| 3213 | control.renderBackupFontSelector(); |
|
| 3214 | control.renderVariantSelector(); |
|
| 3215 | control.renderSubsetSelector(); |
|
| 3216 | ||
| 3217 | // Font-size. |
|
| 3218 | if ( control.params['default']['font-size'] ) { |
|
| 3219 | this.container.on( 'change keyup paste', '.font-size input', function() { |
|
| 3220 | control.saveValue( 'font-size', jQuery( this ).val() ); |
|
| 3221 | }); |
|
| 3222 | } |
|
| 3223 | ||
| 3224 | // Line-height. |
|
| 3225 | if ( control.params['default']['line-height'] ) { |
|
| 3226 | this.container.on( 'change keyup paste', '.line-height input', function() { |
|
| 3227 | control.saveValue( 'line-height', jQuery( this ).val() ); |
|
| 3228 | }); |
|
| 3229 | } |
|
| 3230 | ||
| 3231 | // Margin-top. |
|
| 3232 | if ( control.params['default']['margin-top'] ) { |
|
| 3233 | this.container.on( 'change keyup paste', '.margin-top input', function() { |
|
| 3234 | control.saveValue( 'margin-top', jQuery( this ).val() ); |
|
| 3235 | }); |
|
| 3236 | } |
|
| 3237 | ||
| 3238 | // Margin-bottom. |
|
| 3239 | if ( control.params['default']['margin-bottom'] ) { |
|
| 3240 | this.container.on( 'change keyup paste', '.margin-bottom input', function() { |
|
| 3241 | control.saveValue( 'margin-bottom', jQuery( this ).val() ); |
|
| 3242 | }); |
|
| 3243 | } |
|
| 3244 | ||
| 3245 | // Letter-spacing. |
|
| 3246 | if ( control.params['default']['letter-spacing'] ) { |
|
| 3247 | value['letter-spacing'] = ( jQuery.isNumeric( value['letter-spacing'] ) ) ? value['letter-spacing'] + 'px' : value['letter-spacing']; |
|
| 3248 | this.container.on( 'change keyup paste', '.letter-spacing input', function() { |
|
| 3249 | value['letter-spacing'] = ( jQuery.isNumeric( jQuery( this ).val() ) ) ? jQuery( this ).val() + 'px' : jQuery( this ).val(); |
|
| 3250 | control.saveValue( 'letter-spacing', value['letter-spacing'] ); |
|
| 3251 | }); |
|
| 3252 | } |
|
| 3253 | ||
| 3254 | // Word-spacing. |
|
| 3255 | if ( control.params['default']['word-spacing'] ) { |
|
| 3256 | this.container.on( 'change keyup paste', '.word-spacing input', function() { |
|
| 3257 | control.saveValue( 'word-spacing', jQuery( this ).val() ); |
|
| 3258 | }); |
|
| 3259 | } |
|
| 3260 | ||
| 3261 | // Text-align. |
|
| 3262 | if ( control.params['default']['text-align'] ) { |
|
| 3263 | this.container.on( 'change', '.text-align input', function() { |
|
| 3264 | control.saveValue( 'text-align', jQuery( this ).val() ); |
|
| 3265 | }); |
|
| 3266 | } |
|
| 3267 | ||
| 3268 | // Text-transform. |
|
| 3269 | if ( control.params['default']['text-transform'] ) { |
|
| 3270 | jQuery( control.selector + ' .text-transform select' ).selectWoo().on( 'change', function() { |
|
| 3271 | control.saveValue( 'text-transform', jQuery( this ).val() ); |
|
| 3272 | }); |
|
| 3273 | } |
|
| 3274 | ||
| 3275 | // Text-decoration. |
|
| 3276 | if ( control.params['default']['text-decoration'] ) { |
|
| 3277 | jQuery( control.selector + ' .text-decoration select' ).selectWoo().on( 'change', function() { |
|
| 3278 | control.saveValue( 'text-decoration', jQuery( this ).val() ); |
|
| 3279 | }); |
|
| 3280 | } |
|
| 3281 | ||
| 3282 | // Color. |
|
| 3283 | if ( control.params['default'].color ) { |
|
| 3284 | picker = this.container.find( '.kirki-color-control' ); |
|
| 3285 | picker.wpColorPicker({ |
|
| 3286 | change: function() { |
|
| 3287 | setTimeout( function() { |
|
| 3288 | control.saveValue( 'color', picker.val() ); |
|
| 3289 | }, 100 ); |
|
| 3290 | } |
|
| 3291 | }); |
|
| 3292 | } |
|
| 3293 | }, |
|
| 3294 | ||
| 3295 | /** |
|
| 3296 | * Adds the font-families to the font-family dropdown |
|
| @@ 3260-3342 (lines=83) @@ | ||
| 3257 | } |
|
| 3258 | }, |
|
| 3259 | ||
| 3260 | initKirkiControl: function() { |
|
| 3261 | ||
| 3262 | 'use strict'; |
|
| 3263 | ||
| 3264 | var control = this, |
|
| 3265 | value = control.getValue(), |
|
| 3266 | picker; |
|
| 3267 | ||
| 3268 | control.renderFontSelector(); |
|
| 3269 | control.renderBackupFontSelector(); |
|
| 3270 | control.renderVariantSelector(); |
|
| 3271 | control.renderSubsetSelector(); |
|
| 3272 | ||
| 3273 | // Font-size. |
|
| 3274 | if ( control.params['default']['font-size'] ) { |
|
| 3275 | this.container.on( 'change keyup paste', '.font-size input', function() { |
|
| 3276 | control.saveValue( 'font-size', jQuery( this ).val() ); |
|
| 3277 | }); |
|
| 3278 | } |
|
| 3279 | ||
| 3280 | // Line-height. |
|
| 3281 | if ( control.params['default']['line-height'] ) { |
|
| 3282 | this.container.on( 'change keyup paste', '.line-height input', function() { |
|
| 3283 | control.saveValue( 'line-height', jQuery( this ).val() ); |
|
| 3284 | }); |
|
| 3285 | } |
|
| 3286 | ||
| 3287 | // Margin-top. |
|
| 3288 | if ( control.params['default']['margin-top'] ) { |
|
| 3289 | this.container.on( 'change keyup paste', '.margin-top input', function() { |
|
| 3290 | control.saveValue( 'margin-top', jQuery( this ).val() ); |
|
| 3291 | }); |
|
| 3292 | } |
|
| 3293 | ||
| 3294 | // Margin-bottom. |
|
| 3295 | if ( control.params['default']['margin-bottom'] ) { |
|
| 3296 | this.container.on( 'change keyup paste', '.margin-bottom input', function() { |
|
| 3297 | control.saveValue( 'margin-bottom', jQuery( this ).val() ); |
|
| 3298 | }); |
|
| 3299 | } |
|
| 3300 | ||
| 3301 | // Letter-spacing. |
|
| 3302 | if ( control.params['default']['letter-spacing'] ) { |
|
| 3303 | value['letter-spacing'] = ( jQuery.isNumeric( value['letter-spacing'] ) ) ? value['letter-spacing'] + 'px' : value['letter-spacing']; |
|
| 3304 | this.container.on( 'change keyup paste', '.letter-spacing input', function() { |
|
| 3305 | value['letter-spacing'] = ( jQuery.isNumeric( jQuery( this ).val() ) ) ? jQuery( this ).val() + 'px' : jQuery( this ).val(); |
|
| 3306 | control.saveValue( 'letter-spacing', value['letter-spacing'] ); |
|
| 3307 | }); |
|
| 3308 | } |
|
| 3309 | ||
| 3310 | // Word-spacing. |
|
| 3311 | if ( control.params['default']['word-spacing'] ) { |
|
| 3312 | this.container.on( 'change keyup paste', '.word-spacing input', function() { |
|
| 3313 | control.saveValue( 'word-spacing', jQuery( this ).val() ); |
|
| 3314 | }); |
|
| 3315 | } |
|
| 3316 | ||
| 3317 | // Text-align. |
|
| 3318 | if ( control.params['default']['text-align'] ) { |
|
| 3319 | this.container.on( 'change', '.text-align input', function() { |
|
| 3320 | control.saveValue( 'text-align', jQuery( this ).val() ); |
|
| 3321 | }); |
|
| 3322 | } |
|
| 3323 | ||
| 3324 | // Text-transform. |
|
| 3325 | if ( control.params['default']['text-transform'] ) { |
|
| 3326 | jQuery( control.selector + ' .text-transform select' ).selectWoo().on( 'change', function() { |
|
| 3327 | control.saveValue( 'text-transform', jQuery( this ).val() ); |
|
| 3328 | }); |
|
| 3329 | } |
|
| 3330 | ||
| 3331 | // Color. |
|
| 3332 | if ( control.params['default'].color ) { |
|
| 3333 | picker = this.container.find( '.kirki-color-control' ); |
|
| 3334 | picker.wpColorPicker({ |
|
| 3335 | change: function() { |
|
| 3336 | setTimeout( function() { |
|
| 3337 | control.saveValue( 'color', picker.val() ); |
|
| 3338 | }, 100 ); |
|
| 3339 | } |
|
| 3340 | }); |
|
| 3341 | } |
|
| 3342 | }, |
|
| 3343 | ||
| 3344 | /** |
|
| 3345 | * Adds the font-families to the font-family dropdown |
|