| @@ -133,8 +133,11 @@ | ||
| 133 | 133 | * |
| 134 | 134 | * @since 1.0.0 |
| 135 | 135 | */ |
| 136 | 136 | $(function() { |
| 137 | + // Common: Initialize the color picker | |
| 138 | + $( '.ayg-color-picker' ).wpColorPicker(); | |
| 139 | + | |
| 137 | 140 | // Dashboard: Save API Key |
| 138 | 141 | $( '#ayg-button-save-api-key' ).on( 'click', function( e ) { |
| 139 | 142 | e.preventDefault(); |
| 140 | 143 | |
| @@ -287,11 +290,21 @@ | ||
| 287 | 290 | |
| 288 | 291 | $elem.addClass( 'ayg-editor-field-theme-' + theme ); |
| 289 | 292 | }); |
| 290 | 293 | |
| 291 | - // Settings: Initialize the color picker | |
| 292 | - $( '.ayg-color-picker', '#ayg-settings' ).wpColorPicker(); | |
| 294 | + // Editor: Show/Hide fields based on the selected pagination type | |
| 295 | + $( document ).on( 'change', '.ayg-editor-field-pagination_type', function( e ) { | |
| 296 | + var pagination_type = $( this ).val(); | |
| 297 | + var $elem = $( this ).closest( '.ayg-editor' ); | |
| 293 | 298 | |
| 299 | + $elem.removeClass(function( index, classes ) { | |
| 300 | + var matches = classes.match( /\ayg-editor-field-pagination_type-\S+/ig ); | |
| 301 | + return ( matches ) ? matches.join(' ') : ''; | |
| 302 | + }); | |
| 303 | + | |
| 304 | + $elem.addClass( 'ayg-editor-field-pagination_type-' + pagination_type ); | |
| 305 | + }); | |
| 306 | + | |
| 294 | 307 | // Settings: Show/Hide fields based on the selected theme |
| 295 | 308 | $( 'tr.theme', '#ayg-settings' ).find( 'select' ).on( 'change', function() { |
| 296 | 309 | var theme = $( this ).val(); |
| 297 | 310 | var $elem = $( '#ayg-settings' ); |
| @@ -301,8 +314,21 @@ | ||
| 301 | 314 | return ( matches ) ? matches.join(' ') : ''; |
| 302 | 315 | }); |
| 303 | 316 | |
| 304 | 317 | $elem.addClass( 'ayg-settings-theme-' + theme ); |
| 318 | + }); | |
| 319 | + | |
| 320 | + // Settings: Show/Hide fields based on the selected pagination type | |
| 321 | + $( 'tr.pagination_type', '#ayg-settings' ).find( 'select' ).on( 'change', function() { | |
| 322 | + var pagination_type = $( this ).val(); | |
| 323 | + var $elem = $( '#ayg-settings' ); | |
| 324 | + | |
| 325 | + $elem.removeClass(function( index, classes ) { | |
| 326 | + var matches = classes.match( /\ayg-settings-pagination_type-\S+/ig ); | |
| 327 | + return ( matches ) ? matches.join(' ') : ''; | |
| 328 | + }); | |
| 329 | + | |
| 330 | + $elem.addClass( 'ayg-settings-pagination_type-' + pagination_type ); | |
| 305 | 331 | }); |
| 306 | 332 | |
| 307 | 333 | // Settings: Browse button |
| 308 | 334 | $( '.ayg-settings-browse' ).on( 'click', function( e ) { |