jQuery(document).ready(function($){
if($('.as-slider').length > 0 ) {
$('.as-slider').each(function(){
var cap = $(this).find('.as-slide-caption');
var img = $(this).find('.as-slide-image');
cap.each(function(){
var cap_h = $(this).outerHeight();
var cap_more_h = 0;
if($(this).find('.as-slide-more.default').length > 0 ){
cap_more_h += 49;
}
$(this).css({
'top' : '50%',
'margin-top' : -((cap_h - cap_more_h) / 2)
});
});
img.each(function(){
var img_h = $(this).parents('.as-slide-item').outerHeight();
$(this).css({
'line-height': img_h + 'px'
})
});
$(this).bxSlider({
slideSelector: '.as-slide-item',
pager: $(this).data('pager') ? $(this).data('pager') : false,
controls: $(this).data('controls') ? $(this).data('controls') : false,
nextSelector: "#" + $(this).parent().find('.as-slider-control').attr('id'),
prevSelector: "#" + $(this).parent().find('.as-slider-control').attr('id'),
auto: $(this).data('auto') ? $(this).data('auto') : false,
autoStart: true,
pause: $(this).data('pause') ? $(this).data('pause') : 5000,
speed: $(this).data('duration') ? $(this).data('duration') : 5000,
mode: $(this).data('mode') == 'fade' ? "fade": "horizontal" ,
nextText: '',
prevText: '',
adaptiveHeight: true,
onSliderLoad: function( index ) {
if( this.mode != 'fade') {
index = index + 1;
}
var img = $(this.slideSelector).eq(index).find('.as-slide-image');
img.each(function(){
var img_h = $(this).parents('.as-slide-item').outerHeight();
$(this).css({
'line-height': img_h + 'px'
})
});
$(this.slideSelector).eq(index).delay(80).queue(function(){
$(this).addClass('active');
$(this).dequeue();
});
animClass( this.slideSelector, index, "start");
},
onSlideBefore: function($elem, oldI, newI){
if( this.mode != 'fade') {
newI = newI + 1;
oldI = oldI + 1;
}
var img = $(this.slideSelector).eq(newI).find('.as-slide-image');
img.each(function(){
var img_h = $(this).parents('.as-slide-item').outerHeight();
$(this).css({
'line-height': img_h + 'px'
})
});
//$(this.slideSelector).eq(oldI).removeClass('active');
$(this.slideSelector).eq(oldI).delay(80).queue(function(){
$(this).removeClass('active');
$(this).dequeue();
});
animClass( this.slideSelector, oldI, "end");
},
onSlideAfter: function($elem, oldI, newI){
console.log("hola datevid");
if( this.mode != 'fade') {
newI = newI + 1;
oldI = oldI + 1;
}
var img = $(this.slideSelector).eq(newI).find('.as-slide-image');
img.each(function(){
var img_h = $(this).parents('.as-slide-item').outerHeight();
$(this).css({
'line-height': img_h + 'px'
})
});
//$(this.slideSelector).eq(newI).addClass('active');
$(this.slideSelector).eq(newI).delay(80).queue(function(){
$(this).addClass('active');
$(this).dequeue();
});
animClass( this.slideSelector, newI, "start");
}
});
});
}
function animClass(selector, index, state = "start") {
var b = $(selector).eq(index).find('.as-slide-more'),
t = $(selector).eq(index).find('.as-slide-title'),
c = $(selector).eq(index).find('.as-slide-content'),
i = $(selector).eq(index).find('.as-slide-image'),
ti = t.data('in-anim'),
to = t.data('out-anim'),
ci = c.data('in-anim'),
co = c.data('out-anim'),
bi = b.data('in-anim'),
bo = b.data('out-anim'),
ii = i.data('in-anim'),
io = i.data('out-anim');
if( state == "start") {
if( "undefined" !== typeof ti && t.length > 0 ) {
t.removeClass(to).addClass(ti);
}
if( "undefined" !== typeof ci && c.length > 0 ) {
c.removeClass(co).addClass(ci);
}
if( "undefined" !== typeof bi && b.length > 0 ) {
b.removeClass(bo).addClass(bi);
}
if( "undefined" !== typeof ii && i.length > 0 ) {
i.removeClass(io).addClass(ii);
}
} else {
if( "undefined" !== typeof to && t.length > 0 ) {
t.removeClass(ti).addClass(to);
}
if( "undefined" !== typeof co && c.length > 0 ) {
c.removeClass(ci).addClass(co);
}
if( "undefined" !== typeof bo && b.length > 0 ) {
b.removeClass(bi).addClass(bo);
}
if( "undefined" !== typeof io && i.length > 0 ) {
i.removeClass(ii).addClass(io);
}
}
}
});