wp/wp-content/plugins/portfolio/bws_menu/js/bws_menu.js
changeset 19 3d72ae0968f4
parent 12 d8a8807227e4
equal deleted inserted replaced
18:be944660c56a 19:3d72ae0968f4
     1 (function($) {
     1 (function($) {
     2 	$(document).ready( function() {
     2 	"use strict";
     3 		var product = $( '.bws_product_box' ),
     3 	$( document ).ready(
     4 			max = 0;
     4 		function() {
     5 		$( product ).each( function () {
     5 				var product = $( '.bws_product_box' ),
     6 			if ( $( this ).height() > max )
     6 				max         = 0;
     7 				max = $( this ).height();
     7 				$( product ).each(
     8 		});		
     8 					function () {
     9 		$( '.bws_product_box' ).css( 'height', max + 'px' );
     9 						if ( $( this ).height() > max ) {
       
    10 							max = $( this ).height();
       
    11 						}
       
    12 					}
       
    13 				);
       
    14 				$( '.bws_product_box' ).css( 'height', max + 'px' );
    10 
    15 
    11 		if ( $( '.bws-filter' ).length ) {
    16 			if ( $( '.bws-filter' ).length ) {
    12 			var prvPos = $( '.bws-filter' ).offset().top;
    17 				var prvPos = $( '.bws-filter' ).offset().top;
    13 			var maxPos = prvPos + $( '.bws-products' ).outerHeight() - $( '.bws-filter' ).outerHeight();
    18 				var maxPos = prvPos + $( '.bws-products' ).outerHeight() - $( '.bws-filter' ).outerHeight();
    14 
    19 
    15 			$( window ).scroll( function() {
    20 				$( window ).scroll(
    16 				if ( $( window ).width() > 580 ) {
    21 					function() {
    17 					var scrPos = Number( $( document ).scrollTop() ) + 40;
    22 						if ( $( window ).width() > 580 ) {
    18 					if ( scrPos > maxPos ) {
    23 							   var scrPos = Number( $( document ).scrollTop() ) + 40;
    19 						$( '.bws-filter' ).removeClass( 'bws_fixed' );
    24 							if ( scrPos > maxPos ) {
    20 					} else if ( scrPos > prvPos ) {
    25 								$( '.bws-filter' ).removeClass( 'bws_fixed' );
    21 						$( '.bws-filter' ).addClass( 'bws_fixed' );
    26 							} else if ( scrPos > prvPos ) {
    22 					} else {
    27 								$( '.bws-filter' ).addClass( 'bws_fixed' );
    23 						$( '.bws-filter' ).removeClass( 'bws_fixed' );
    28 							} else {
       
    29 								$( '.bws-filter' ).removeClass( 'bws_fixed' );
       
    30 							}
       
    31 						}
    24 					}
    32 					}
    25 				}
    33 				);
    26 			});
    34 			}
       
    35 				$( '.bws-menu-item-icon' ).click(
       
    36 					function() {
       
    37 						if ( $( this ).hasClass( 'bws-active' ) ) {
       
    38 							$( this ).removeClass( 'bws-active' );
       
    39 							$( '.bws-nav-tab-wrapper, .bws-help-links-wrapper' ).hide();
       
    40 						} else {
       
    41 							$( this ).addClass( 'bws-active' );
       
    42 							$( '.bws-nav-tab-wrapper, .bws-help-links-wrapper' ).css( 'display', 'inline-block' );
       
    43 						}
       
    44 					}
       
    45 				);
       
    46 				$( '.bws-filter-top h2' ).click(
       
    47 					function() {
       
    48 						if ( $( '.bws-filter-top' ).hasClass( 'bws-opened' ) ) {
       
    49 							$( '.bws-filter-top' ).removeClass( 'bws-opened' );
       
    50 						} else {
       
    51 							$( '.bws-filter-top' ).addClass( 'bws-opened' );
       
    52 						}
       
    53 					}
       
    54 				);
       
    55 
    27 		}
    56 		}
    28 		$( '.bws-menu-item-icon' ).click( function() {
    57 	);
    29 			if ( $( this ).hasClass( 'bws-active' ) ) {
    58 })( jQuery );
    30 				$( this ).removeClass( 'bws-active' );
       
    31 				$( '.bws-nav-tab-wrapper, .bws-help-links-wrapper' ).hide();
       
    32 			} else {
       
    33 				$( this ).addClass( 'bws-active' );
       
    34 				$( '.bws-nav-tab-wrapper, .bws-help-links-wrapper' ).css( 'display', 'inline-block' );
       
    35 			}
       
    36 		});
       
    37 		$( '.bws-filter-top h2' ).click( function() {
       
    38 			if ( $( '.bws-filter-top' ).hasClass( 'bws-opened' ) ) {
       
    39 				$( '.bws-filter-top' ).removeClass( 'bws-opened' );
       
    40 			} else {
       
    41 				$( '.bws-filter-top' ).addClass( 'bws-opened' );
       
    42 			}
       
    43 		});
       
    44 		
       
    45 	});
       
    46 })(jQuery);