public/torress/assets/js/main.js
/*  Torress's Product View Mode
/*----------------------------------------*/
Torress's Product View Mode
Torress ' s Product View Mode
function porductViewMode() {
		$(window).on({
			load: function() {
				var activeChild = $('.product-view-mode a.active');
				var firstChild = $('.product-view-mode').children().first();
				var window_width = $(window).width();
				if (window_width < 576) {
					$('.product-view-mode a').removeClass('active');
					$('.product-view-mode').children().first().addClass('active');
					$('.shop-product-wrap').removeClass('gridview-3 gridview-4 gridview-5').addClass('gridview-2');
				}
			},
			resize: function() {
				var ww = $(window).width();
				var activeChild = $('.product-view-mode a.active');
				var firstChild = $('.product-view-mode').children().first();
				var defaultView = $('.product-view-mode').data('default');
				if (ww < 1200 && ww > 575) {
					if (activeChild.hasClass('grid-5')) {
						$('.product-view-mode a.grid-5').removeClass('active');
						if (defaultView == 4) {
							$('.product-view-mode a.grid-4').addClass('active');
							$('.shop-product-wrap')
								.removeClass('gridview-2 gridview-3 gridview-5')
								.addClass('gridview-4');
						} else if (defaultView == 'list') {
							$('.product-view-mode a.list').addClass('active');
							$('.shop-product-wrap')
								.removeClass('gridview-2 gridview-3 gridview-4 gridview-5')
								.addClass('listview');
						} else {
							$('.product-view-mode a.grid-3').addClass('active');
							$('.shop-product-wrap')
								.removeClass('gridview-2 gridview-4 gridview-5')
								.addClass('gridview-3');
						}
					}
				}
				if (ww < 768 && ww > 575) {
					if (activeChild.hasClass('grid-4')) {
						$('.product-view-mode a.grid-4').removeClass('active');
						if (defaultView == 'list') {
							$('.product-view-mode a.list').addClass('active');
							$('.shop-product-wrap')
								.removeClass('gridview-2 gridview-3 gridview-4 gridview-5')
								.addClass('listview');
						} else {
							$('.product-view-mode a.grid-3').addClass('active');
							$('.shop-product-wrap')
								.removeClass('gridview-2 gridview-4 gridview-5')
								.addClass('gridview-3');
						}
					}
				}
				if (activeChild.hasClass('list')) {
				} else {
					if (ww < 576) {
						$('.product-view-mode a').removeClass('active');
						$('.product-view-mode').children().first().addClass('active');
						$('.shop-product-wrap').removeClass('gridview-3 gridview-4 gridview-5').addClass('gridview-2');
					} else {
						if (activeChild.hasClass('grid-2')) {
							if (ww < 1200) {
								$('.product-view-mode a:not(:first-child)').removeClass('active');
							} else {
								$('.product-view-mode a').removeClass('active');
								$('.product-view-mode a:nth-child(2)').addClass('active');
								$('.shop-product-wrap')
									.removeClass('gridview-2 gridview-4 gridview-5')
									.addClass('gridview-3');
							}
						}
					}
				}
			}
		});
		$('.product-view-mode a').on('click', function(e) {
			e.preventDefault();
			var shopProductWrap = $('.shop-product-wrap');
			var viewMode = $(this).data('target');
			$('.product-view-mode a').removeClass('active');
			$(this).addClass('active');
			if (viewMode == 'listview') {
				shopProductWrap.removeClass('grid');
			} else {
				if (shopProductWrap.not('.grid')) shopProductWrap.addClass('grid');
			}
			shopProductWrap.removeClass('gridview-2 gridview-3 gridview-4 gridview-5 listview').addClass(viewMode);
		});
	}
function porductViewMode ( ) { $ ( window ) . on ( { load : function ( ) { var activeChild = $ ( '.product-view-mode a.active' ) ; var firstChild = $ ( '.product-view-mode' ) . children ( ) . first ( ) ; var window_width = $ ( window ) . width ( ) ; if ( window_width < 576 ) { $ ( '.product-view-mode a' ) . removeClass ( 'active' ) ; $ ( '.product-view-mode' ) . children ( ) . first ( ) . addClass ( 'active' ) ; $ ( '.shop-product-wrap' ) . removeClass ( 'gridview-3 gridview-4 gridview-5' ) . addClass ( 'gridview-2' ) ; } } , resize : function ( ) { var ww = $ ( window ) . width ( ) ; var activeChild = $ ( '.product-view-mode a.active' ) ; var firstChild = $ ( '.product-view-mode' ) . children ( ) . first ( ) ; var defaultView = $ ( '.product-view-mode' ) . data ( 'default' ) ; if ( ww < 1200 && ww > 575 ) { if ( activeChild . hasClass ( 'grid-5' ) ) { $ ( '.product-view-mode a.grid-5' ) . removeClass ( 'active' ) ; if ( defaultView == 4 ) { $ ( '.product-view-mode a.grid-4' ) . addClass ( 'active' ) ; $ ( '.shop-product-wrap' ) . removeClass ( 'gridview-2 gridview-3 gridview-5' ) . addClass ( 'gridview-4' ) ; } else if ( defaultView == 'list' ) { $ ( '.product-view-mode a.list' ) . addClass ( 'active' ) ; $ ( '.shop-product-wrap' ) . removeClass ( 'gridview-2 gridview-3 gridview-4 gridview-5' ) . addClass ( 'listview' ) ; } else { $ ( '.product-view-mode a.grid-3' ) . addClass ( 'active' ) ; $ ( '.shop-product-wrap' ) . removeClass ( 'gridview-2 gridview-4 gridview-5' ) . addClass ( 'gridview-3' ) ; } } } if ( ww < 768 && ww > 575 ) { if ( activeChild . hasClass ( 'grid-4' ) ) { $ ( '.product-view-mode a.grid-4' ) . removeClass ( 'active' ) ; if ( defaultView == 'list' ) { $ ( '.product-view-mode a.list' ) . addClass ( 'active' ) ; $ ( '.shop-product-wrap' ) . removeClass ( 'gridview-2 gridview-3 gridview-4 gridview-5' ) . addClass ( 'listview' ) ; } else { $ ( '.product-view-mode a.grid-3' ) . addClass ( 'active' ) ; $ ( '.shop-product-wrap' ) . removeClass ( 'gridview-2 gridview-4 gridview-5' ) . addClass ( 'gridview-3' ) ; } } } if ( activeChild . hasClass ( 'list' ) ) { } else { if ( ww < 576 ) { $ ( '.product-view-mode a' ) . removeClass ( 'active' ) ; $ ( '.product-view-mode' ) . children ( ) . first ( ) . addClass ( 'active' ) ; $ ( '.shop-product-wrap' ) . removeClass ( 'gridview-3 gridview-4 gridview-5' ) . addClass ( 'gridview-2' ) ; } else { if ( activeChild . hasClass ( 'grid-2' ) ) { if ( ww < 1200 ) { $ ( '.product-view-mode a:not(:first-child)' ) . removeClass ( 'active' ) ; } else { $ ( '.product-view-mode a' ) . removeClass ( 'active' ) ; $ ( '.product-view-mode a:nth-child(2)' ) . addClass ( 'active' ) ; $ ( '.shop-product-wrap' ) . removeClass ( 'gridview-2 gridview-4 gridview-5' ) . addClass ( 'gridview-3' ) ; } } } } } } ) ; $ ( '.product-view-mode a' ) . on ( 'click' , function ( e ) { e . preventDefault ( ) ; var shopProductWrap = $ ( '.shop-product-wrap' ) ; var viewMode = $ ( this ) . data ( 'target' ) ; $ ( '.product-view-mode a' ) . removeClass ( 'active' ) ; $ ( this ) . addClass ( 'active' ) ; if ( viewMode == 'listview' ) { shopProductWrap . removeClass ( 'grid' ) ; } else { if ( shopProductWrap . not ( '.grid' ) ) shopProductWrap . addClass ( 'grid' ) ; } shopProductWrap . removeClass ( 'gridview-2 gridview-3 gridview-4 gridview-5 listview' ) . addClass ( viewMode ) ; } ) ; }
Torress's Product View Mode
Torress ' s Product View Mode