Skip to content

Instantly share code, notes, and snippets.

@glideranderson
Last active September 27, 2015 16:37
Show Gist options
  • Save glideranderson/1299719 to your computer and use it in GitHub Desktop.
Save glideranderson/1299719 to your computer and use it in GitHub Desktop.
Specials page grrr
/*
Specials Page
*/
if($j('.specials-wrapper').length > 0 ) {
$j('.specials-cat-nav li:first-child').addClass('active');
$j('.specials-page').find('.cat-wrapper').not(':first-child').hide();
$j('.specials-page .cat-wrapper:first-child').addClass('active');
// opening new section on click
$j('.specials-cat-nav li a').live('click', function(e) {
e.preventDefault();
$j('.specials-detailed').html('').css('display','');
$j('.specials-page').show();
// remove all active classes, add active to current element
$j(this).closest('ul').find('li').removeClass('active');
$j(this).parent().addClass('active');
// find category name
var catName = $j(this).text();
catName = catName.toLowerCase().replace(/ /g,'_').replace('&', 'and');
window.location.hash = catName;
// local: http://web/flooringbytileexperts/specials-ajax-posts/
// remote: http://glideint.com/clients/flooringbytileexperts/site/specials-ajax-posts/
// ajax loading posts
$j(".ajax-loading").html("loading...");
$j(".specials-page").css('marginTop','800px')
$j.ajax({
type: "POST",
url: 'http://fbteinc.com/specials-ajax-posts/',
data: 'category='+catName,
success: function(html){
$j(".specials-page").html(html).animate({
marginTop: 0
}, '600'); //.fadeIn('1000');
$j(".ajax-loading").html("");
// for IE 8 have to rebind everything only after it exists
/*$j('.fbte_specials a, .services-featured a, .specials-featured a').live('click', function(e) {
e.preventDefault();
var content = $j(this).closest('article').find('.hidden').html();
$j('.specials-detailed').hide().html(content);
$j('.specials-page').toggle('slide', function() {
$j('.specials-detailed').toggle('slide');
// cycle available colors
$j('ul.available_colors').cycle({
fx: 'scrollHorz',
speed: 1000,
timeout:8000,
delay: -2500,
pause: 1,
next: 'a.next',
prev: 'a.prev'
});
});
// bind click to close current section
$j('.specials-detailed a.click').bind('click', function(e) {
e.preventDefault();
$j('.specials-detailed').toggle('slide', function() {
$j('.specials-page').toggle('slide', function() {
$j('.specials-page').scrollTop($j.fbteVars.positionValue);
});
});
});
});
// available colors hover event
var colorsItems = $j('.specials-detailed .available_colors img');
$j(colorsItems).live({
'mouseenter': function() {
var colorImg = $j(this);
$j(colorImg).closest('ul').find('li:first-child').addClass('first');
$j(colorImg).css({ zIndex: 40});
if($j(colorImg).closest('li').hasClass('first')) {
$j(colorImg).stop().animate({ height: '150px', width: '150px', left: 0});
} else {
$j(colorImg).stop().animate({ height: '150px', width: '150px', left: '-20px'});
}
},
'mouseleave': function() {
$j(this).css({ zIndex: 2});
$j(this).stop().animate({ height: '100px', width: '100px', left: '0' });
}
});*/
}
});
});
};
// test comment
if($j('.fbte_specials').length > 0) {
$j('.fbte_specials a, .services-featured a, .specials-featured a').live('click', function(e) {
e.preventDefault();
var content = $j(this).closest('article').find('.hidden').html();
$j('.specials-detailed').hide().html(content);
$j('.specials-page').toggle('slide', function() {
$j('.specials-detailed').toggle('slide');
// cycle available colors
$j('ul.available_colors').cycle({
fx: 'scrollHorz',
speed: 1000,
timeout:8000,
delay: -2500,
pause: 1,
next: 'a.next',
prev: 'a.prev'
});
});
// bind click to close current section
$j('.specials-detailed a.click').bind('click', function(e) {
e.preventDefault();
$j('.specials-detailed').toggle('slide', function() {
$j('.specials-page').toggle('slide', function() {
$j('.specials-page').scrollTop($j.fbteVars.positionValue);
});
});
});
});
// available colors hover event
var colorsItems = $j('.specials-detailed .available_colors img');
$j(colorsItems).live({
'mouseenter': function() {
var colorImg = $j(this);
$j(colorImg).closest('ul').find('li:first-child').addClass('first');
$j(colorImg).css({ zIndex: 40});
if($j(colorImg).closest('li').hasClass('first')) {
$j(colorImg).stop().animate({ height: '150px', width: '150px', left: 0});
} else {
$j(colorImg).stop().animate({ height: '150px', width: '150px', left: '-20px'});
}
},
'mouseleave': function() {
$j(this).css({ zIndex: 2});
$j(this).stop().animate({ height: '100px', width: '100px', left: '0' });
}
});
// test for window location hash, open section
var addressHash = window.location.hash;
if(addressHash) {
var classHash = addressHash.substr(1);
$j('.specials-cat-nav').find('.active').removeClass('active');
$j('.specials-cat-nav').find('.' + classHash + ' a').trigger('click');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment