script.js
86 lines
| 1 | jQuery( function( $ ) { |
| 2 | var currentSection = ''; |
| 3 | $( '.page-sections a' ).on( 'click', function( e ) { |
| 4 | e.preventDefault(); |
| 5 | |
| 6 | $( '.page-sections li' ).removeClass( 'active-section' ); |
| 7 | var $$ = $( this ); |
| 8 | |
| 9 | currentSection = $$.data( 'section' ); |
| 10 | $$.parent( 'li' ).addClass( 'active-section' ); |
| 11 | |
| 12 | $( '.siteorigin-installer-item').show(); |
| 13 | if ( currentSection != 'all' ) { |
| 14 | $( '.siteorigin-installer-item:not(.siteorigin-' + currentSection + ')' ).hide(); |
| 15 | } |
| 16 | |
| 17 | $( window ).trigger( 'resize' ); |
| 18 | } ); |
| 19 | |
| 20 | $( 'span.siteorigin-installer' ).on( 'click', function( e ) { |
| 21 | e.preventDefault(); |
| 22 | |
| 23 | var $$ = $( this ); |
| 24 | if ( ! $$.hasClass( 'disabled' ) ) { |
| 25 | $$.addClass( 'disabled' ); |
| 26 | $.post( |
| 27 | soInstallerAdmin.manageUrl, |
| 28 | { |
| 29 | 'type' : $$.data( 'type' ), |
| 30 | 'slug' : $$.data( 'slug' ), |
| 31 | 'task' : $$.data( 'status' ), |
| 32 | 'version' : $$.data( 'version' ) |
| 33 | }, |
| 34 | function( data ) { |
| 35 | if ( $$.data( 'status' ) == 'activate' ) { |
| 36 | if ( $$.data( 'type' ) == 'themes' ) { |
| 37 | var $activeItem = $( '.siteorigin-installer-item-active.siteorigin-themes' ) |
| 38 | $activeItem.addClass( 'siteorigin-installer-item-inactive' ).removeClass( 'siteorigin-installer-item-active' ); |
| 39 | $activeItem.find( '.siteorigin-installer' ).removeClass( 'disabled' ); |
| 40 | $activeItem.removeClass( 'siteorigin-installer-item-active' ); |
| 41 | $( '.siteorigin-themes span.siteorigin-installer' ).show(); |
| 42 | $$.hide(); |
| 43 | } |
| 44 | $$.parents( '.siteorigin-installer-item-inactive' ).removeClass( 'siteorigin-installer-item-inactive' ).addClass( 'siteorigin-installer-item-active' ); |
| 45 | if ( $$.data( 'type' ) == 'plugins' ) { |
| 46 | $$.remove(); |
| 47 | } |
| 48 | } else if ( $$.data( 'status' ) == 'update' ) { |
| 49 | $$.remove(); |
| 50 | } else { |
| 51 | $$.removeClass( 'disabled' ); |
| 52 | $$.text( soInstallerAdmin.activateText ) |
| 53 | $$.data( 'status', 'activate' ); |
| 54 | } |
| 55 | $( window ).trigger( 'resize' ); |
| 56 | } |
| 57 | ); |
| 58 | } |
| 59 | } ); |
| 60 | |
| 61 | $( '.page-sections li:first-of-type a' ).trigger( 'click' ); |
| 62 | |
| 63 | // Make sure product heights are all the same on a row by row basis. |
| 64 | $( window ).on( 'resize', function() { |
| 65 | var $products = $( '.siteorigin-installer-item:visible' ).css( 'height', 'auto' ); |
| 66 | var largestHeight = []; |
| 67 | var column = 0; |
| 68 | |
| 69 | $( '.siteorigin-installer-item-body' ).css( 'height', 'auto' ); |
| 70 | |
| 71 | $products.each( function( index ) { |
| 72 | column = index / 3; |
| 73 | // Turnicate column number - IE 11 friendly. |
| 74 | column = column < 0 ? Math.ceil( column ) : Math.floor( column ); |
| 75 | $( this ).data( 'column', column ) |
| 76 | |
| 77 | largestHeight[ column ] = Math.max( typeof largestHeight[ column ] == 'undefined' ? 0 : largestHeight[ column ], $( this ).height() ); |
| 78 | } ); |
| 79 | |
| 80 | $products.each( function () { |
| 81 | $( this ).find( '.siteorigin-installer-item-body' ).css( 'height', largestHeight[ $( this ).data( 'column' ) ] + 'px' ); |
| 82 | } ); |
| 83 | |
| 84 | } ).trigger( 'resize' ); |
| 85 | } ); |
| 86 |