var winW;
$(document).ready(function(){
winW = $(window).width();
$('.nav_bar').click(function() {
$(this).toggleClass("open");
if ($('.navigation_responsive').hasClass('slidenav')){
$('.navigation_responsive').removeClass('slidenav');
$('.navigation_responsive').animate({ left: '-220' }, 400);
$('.navwrap ul li span').removeClass("showmenu");
$('.navwrap ul li ul').hide();
} else {
$('.navigation_responsive').addClass('slidenav');
$('.navigation_responsive').animate({ left: '0' }, 400);
}
});
$(".navwrap ul li").children('ul').each(function () {
$(this).parent().prepend('');
});
$(".navwrap ul li span").on('click', function () {
$(this).toggleClass("showmenu");
$(this).next().slideToggle();
});
$(".sroll-hide").hide();
//HEADER FIXED WITH SCROLL
if($(window).width() >=1024)
{
$(window).scroll(function(){
if ($(window).scrollTop() >= 157) {
$('nav').addClass('fixed-header');
$('.sroll-hide').fadeIn('1000');
//$('.navigation li a').css({'padding': '14px'})
}
else if($(window).scrollTop() < 157){
$('nav').removeClass('fixed-header');
$('.sroll-hide').fadeOut('1000');
//$('.navigation li a').css({'padding': '14px 20px'})
}
});
}
//SEARCH TOGGLE
$("#search").on('click', function(){
$(".sreach").slideToggle();
$("#search").attr('style', 'display:none');
})
$(".close").on('click', function(){
$(".sreach").slideToggle("hide");
$("#search").attr('style', 'display:block');
})
$(".moredata").click(function(){
$('.videoFeatured').slideToggle();
});
// $('.navigation li').has('div.megamenu').children('a').append('');
$('.navigation li').has('div.submenu').children('a').append('');
$('.navigation li').has('div.submenu').css('position', 'relative');
//$('.navigation li .megamenu h4').wrapInner('');
//$('.navigation li.more >a').append('');
$('a[href="#reaction_post"]').on('click', function (e) {
e.preventDefault();
var target = this.hash;
var $target = $(target);
$(".reations_nav a").addClass('up');
$('html, body').stop().animate({
'scrollTop': $target.offset().top
}, 500, 'swing', function () {
$(".reaction_wrap").height($(window).height()-60);
$(".reaction_wrap").slideDown(1200);
});
})
$('a[href="#reactions-top"]').on('click', function (e) {
e.preventDefault();
var target = this.hash;
var $target = $(target);
var $target2 = $("#reaction_post");
if ($('.reations_nav a').hasClass('up')){
$('html, body').stop().animate({
'scrollTop': $target.offset().top
}, 500, 'swing');
$(".reaction_wrap").slideUp(1200);
$('.reations_nav a').removeClass('up');
}else{
$('html, body').stop().animate({
'scrollTop': $target2.offset().top
}, 500, 'swing');
$(".reaction_wrap").height($(window).height()-60);
$(".reaction_wrap").slideToggle(1200);
$(this).toggleClass("open");
}
})
/*Initializing Alerts slider on header*/
/* $('.alert').bxSlider({
mode: 'vertical',
startSlide:0,
pager:false,
controls:false
}); */
$('ul.hashnav li').each(function(){
//console.log($(this).width());
var w = $(this).width() + 20;
$(this).css('max-width', w);
})
/*For photowall BX Slider*/
$('.photowall').bxSlider({
mode: 'fade',
captions: true
});
$('.bxslider1').bxSlider({
minSlides: 2,
maxSlides: 3,
slideWidth: 215,
slideMargin: 22,
auto:false
});
$('.show').bxSlider({
minSlides: 1,
maxSlides: 1,
startSlide:0,
speed: 1000,
pause:5000,
auto:true,
pager:true,
controls:false
});
var flipSlider = $('#flipSlider').bxSlider({
mode: 'fade',
startSlide:0,
speed: 1000,
pause:5000,
auto:true,
pager:false,
controls:true,
onSlideBefore: function(slideElement, oldIndex, newIndex){
$('.flip-banner .bx-controls .bx-controls-direction span').html(''+(newIndex+1) + '' + '/' + slideQty)
}
});
// var slideQty = flipSlider.getSlideCount();
var slideQty = $("#flipSlider > li").size();
$('.flip-banner .bx-controls .bx-controls-direction').append('1/' + slideQty +'');
$('#flipSlider > li').each(function( index ) {
$(this).append('
');
})
$(".flip-banner ul li .back .back-content").append('X');
$('#flipSlider li .flip.fronti').on('click', function(){
$(this).hide();;
$(this).parent().find(".backi").show();;
$(".flip-banner .bx-controls .bx-controls-direction").fadeOut(800);
$(this).parents().find(".flipper").toggleClass("flipped");
flipSlider.stopAuto();
})
$('#flipSlider li .flip.backi').on('click', function(){
$(this).hide();
$(this).parent().find(".fronti").show();;
$(".flip-banner .bx-controls .bx-controls-direction").fadeIn(1200);
$(this).parents().find(".flipper").toggleClass("flipped");
flipSlider.startAuto();
})
$('.flip-banner ul li .back .back-content a.backflip').on('click', function(){
$(this).parent().find(".fronti").show();;
$(".flip-banner .bx-controls .bx-controls-direction").fadeIn(1200);
$(this).parents().find(".flipper").toggleClass("flipped");
flipSlider.startAuto();
})
$(".data_featured_list ul.video li figure a, .video .data-list-cat figure").append('');
var photoslideQty = $(".photoFeatured > li").size();
var photogall = $(".photoFeatured").bxSlider({
minSlides: 2,
maxSlides: 7,
startSlide: 0,
slideWidth: 160,
slideMargin: 8,
moveSlides:1,
infiniteLoop:false,
hideControlOnEnd:true,
auto:false,
onSliderLoad: function(currentIndex){
$('ul.photo li').eq(currentIndex).addClass('active');
var getIMG = $('ul.photo li').eq(currentIndex).find('a').attr("data-img");
var getEQ = currentIndex + 1;
var getH = $('ul.photo li').eq(currentIndex).find('p').text();
var getC = $('ul.photo li').eq(currentIndex).find('a').attr("data-category");
var getD = $('ul.photo li').eq(currentIndex).find('a').attr("data-date");
var getE = $('ul.photo li').eq(currentIndex).find('a').attr("data-excerpt");
var getA = $('ul.photo li').eq(currentIndex).find('a').attr("data-author");
$('#photo_top_play figure').append('
');
$("#photo_top_play.photo").append('');
$(".photo_count").append(' ' + getEQ + '/' + photoslideQty + '');
$("#photo_description h1").html(getH);
//$("#photo_description .meta").html('' + getC + ' ' + getD);
$("#photo_description p").html(getE);
$("#photo_description .author").html(getA);
$(".PPrev, .PNext").attr('data-id', (parseInt(getEQ)-1));
}
});
//$(".photo_count").append('< ' + 1 + '/' + photoslideQty + ' >');
$('ul.photo li a').on('click', function(){
$('ul.photo li').removeClass('active');
$(this).parent().parent().addClass('active');
$('.video_top_play img, .photo_count span').remove();
var getIMG = $(this).attr("data-img");
var getEQ = $(this).parent().parent().index() + 1;
var getH = $(this).parent().parent().find('p').text();
//var getC = $(this).parent().parent().find('a').attr("data-category");
var getD = $(this).attr("data-date");
var getE = $(this).attr("data-excerpt");
var getA = $(this).attr("data-author");
//alert(getC);
$('.video_top_play figure').append('
');
$(".photo_count").append(' ' + getEQ + '/' + photoslideQty + ' ');
$(".video_top_discription h1").html(getH);
//$(".video_top_discription .meta").html('' + getC + ' ' + getD);
$(".video_top_discription p").html(getE);
$(".video_top_discription .author").html(getA);
$(".PPrev, .PNext").attr('data-id', (parseInt(getEQ)-1));
if(getEQ > 1){
$(".PPrev").show();
}else{
$(".PPrev").hide();
}
if(getEQ == photoslideQty){
$(".PNext").hide();
}else{
$(".PNext").show();
}
})
$(document).on('click','.PPrev', function(){
var getCurrentSlide = parseInt($(this).attr('data-id')) - 1;
photogall.goToSlide(getCurrentSlide);
$('ul.photo li').removeClass('active');
$('ul.photo li').eq(getCurrentSlide).addClass('active');
$('#photo_top_play img, .photo_count span').remove();
var getIMG = $('ul.photo li').eq(getCurrentSlide).find('a').attr("data-img");
var getEQ = getCurrentSlide + 1;
var getH = $('ul.photo li').eq(getCurrentSlide).find('p').text();
var getC = $('ul.photo li').eq(getCurrentSlide).find('a').attr("data-category");
var getD = $('ul.photo li').eq(getCurrentSlide).find('a').attr("data-date");
var getE = $('ul.photo li').eq(getCurrentSlide).find('a').attr("data-excerpt");
var getA = $('ul.photo li').eq(getCurrentSlide).find('a').attr("data-author");
$('#photo_top_play').append('
');
$(".photo_count").append(' ' + getEQ + '/' + photoslideQty + ' ');
$("#photo_description h1").html(getH);
$("#photo_description .meta").html('' + getC + ' ' + getD);
$("#photo_description p").html(getE);
$("#photo_description .author").html(getA);
$(".PPrev, .PNext").attr('data-id', getCurrentSlide);
if(getCurrentSlide == 0){
$(this).hide();
}
if(getCurrentSlide < (photoslideQty-1)){
$('.PNext').show();
}
//hitGaview();
//hitComscore();
})
$(document).on('click','.PNext',function(){
var getCurrentSlide = parseInt($(this).attr('data-id')) + 1;
photogall.goToSlide(getCurrentSlide);
$('ul.photo li').removeClass('active');
$('ul.photo li').eq(getCurrentSlide).addClass('active');
$('#photo_top_play img, .photo_count span').remove();
var getIMG = $('ul.photo li').eq(getCurrentSlide).find('a').attr("data-img");
var getEQ = getCurrentSlide + 1;
var getH = $('ul.photo li').eq(getCurrentSlide).find('p').text();
var getC = $('ul.photo li').eq(getCurrentSlide).find('a').attr("data-category");
var getD = $('ul.photo li').eq(getCurrentSlide).find('a').attr("data-date");
var getE = $('ul.photo li').eq(getCurrentSlide).find('a').attr("data-excerpt");
var getA = $('ul.photo li').eq(getCurrentSlide).find('a').attr("data-author");
$('#photo_top_play figure').append('
');
$(".photo_count").append(' ' + getEQ + '/' + photoslideQty + ' ');
$("#photo_description h1").html(getH);
$("#photo_description .meta").html('' + getC + ' ' + getD);
$("#photo_description p").html(getE);
$("#photo_description .author").html(getA);
$(".PPrev, .PNext").attr('data-id', getCurrentSlide);
if(getCurrentSlide > 0){
$(".PPrev").show();
}
if(getCurrentSlide == (photoslideQty-1)){
$(this).hide();
}
//hitGaview();
//hitComscore();
})
$(".author-lest-blog.cflip .author-list").append('')
$(".author-lest-blog.cflip .author-list .flipcrt").on('click', function(){
$(this).toggleClass("active");
$(this).prev().toggleClass("flipped");
})
$('ul.video li a').on('click', function(){
$('ul.video li').removeClass('active');
$(this).parent().parent().addClass('active');
$('.video_top_play img, .photo_count span').remove();
var getIMG = $(this).attr("data-img");
var getEQ = $(this).parent().parent().index() + 1;
var getH = $(this).parent().parent().find('p').text();
var getC = $(this).parent().parent().find('a').attr("data-category");
var getD = $(this).attr("data-date");
var getE = $(this).attr("data-excerpt");
var getA = $(this).attr("data-author");
$(".photo_count").append(' ' + getEQ + '/' + photoslideQty + ' ');
$(".video_top_discription h1").html(getH);
//$(".video_top_discription .meta").html('' + getC + ' ' + getD);
$(".video_top_discription p").html(getE);
$(".video_top_discription .author").html(getA);
})
$(".myhotspotCont").append('X');
$(".myhotspotToggle").click(function() {
$(this).next().slideToggle();
});
/*To toggle My Hotspot*/
$(".myhotspotCont .closetoggle").on('click', function(){
$(".myhotspotCont").slideToggle();
})
/*To toggle the reactions*/
$("#viewReaction").click(function() {
$(this).find('i').toggleClass("up");
$(this).parent().parent().next().slideToggle();
});
$("#upnext li figure a").append('');
var articalH = $('.section-blog-left-aricle').height();
$(window).scroll(function(){
if ($(this).scrollTop() > 280) {
$('.social-sticky').css('position', 'fixed');
}
else {
$('.social-sticky').css('position', 'absolute');
}
if ($(this).scrollTop() > articalH) {
$('.social-sticky').hide();
}
else{
$('.social-sticky').show();
}
});
videoSlider();
// For responsive
$(window).load(function(){
//responsive();
});
$(window).resize(function () {
//responsive();
});
$(window).one('resize', function(){
videoSlider();
})
function videoSlider(){
winW = $(window).width();
if(winW > 767){
$(".videoFeatured").bxSlider({
minSlides: 2,
maxSlides: 7,
startSlide: 0,
slideWidth: 160,
slideMargin: 8,
moveSlides:2,
infiniteLoop:false,
hideControlOnEnd:true,
auto:false
});
}
}
/* function responsive(){
winW = $(window).width();
if(winW > 767 && winW < 1244){
$(".resLiftSide").width(winW-330);
}else{
$(".resLiftSide").width('');
}
if(winW > 767 && winW < 980){
$(".resLiftSideFull").width(winW);
}
if(winW > 981 && winW < 1244){
$(".resLiftSideFull").width(winW-330);
} else{
$(".resLiftSideFull").width('');
}
} */
/*To submit the poll answer and to display the poll results*/
$('#submit_poll').click(function(){
var answer = $("input[name='poll_answer']:checked").val();
var pollid = $("#poll_id").val();
var dataString = "ans="+answer+"&pollid="+pollid;
$.ajax
({
type: "get",
url: "http://www.news18.com/ajax_poll_answer.php",
data: dataString,
cache: false,
success: function(html)
{
$("#answers").hide();
$("#poll_result").html(html);
}
});
});
/*To hide the poll results*/
$('.poll_close').click(function(){
$('#poll_result').hide();
});
/*For the latest and popular tab show/hide on Photogallery/Videos/Live TV/Shows pages*/
$('#latest').click(function(){
$('#tab2').hide();
$('#tab1').show();
$( "#most_popular" ).addClass( "dact" );
$( "#latest" ).removeClass( "dact" );
});
/*For the latest and popular tab show/hide on Photogallery pages*/
$('#latest_gallery').click(function(){
$('#tab2_gallery').hide();
$('#tab1_gallery').show();
$( "#most_popular_gallery" ).addClass( "dact" );
$( "#latest_gallery" ).removeClass( "dact" );
});
/*For the latest and popular tab show/hide on Videos Page*/
$('#latest_videos').click(function(){
$('#tab2_videos').hide();
$('#tab1_videos').show();
$( "#most_popular_videos" ).addClass( "dact" );
$( "#latest_videos" ).removeClass( "dact" );
});
/*To load the most popular tab on Photogallery/Videos/Live TV/Shows*/
$('#most_popular').click(function(){
$('#tab1').hide();
$('#tab2').show();
$('#loadingDiv').show();
$( "#latest" ).addClass( "dact" );
$( "#most_popular" ).removeClass( "dact" );
$.ajax
({
type: "get",
url: "http://www.news18.com/most_popular_videos.php",
cache: false,
success: function(html)
{
$('#loadingDiv').hide();
$("#tab2").show();
$("#tab2").html(html);
}
});
});
/*To load the most popular tab on Photogallery*/
$('#most_popular_gallery').click(function(){
$('#tab1_gallery').hide();
$('#tab2_gallery').show();
$('#loadingDiv').show();
$( "#latest_gallery" ).addClass( "dact" );
$( "#most_popular_gallery" ).removeClass( "dact" );
$.ajax
({
type: "get",
url: "http://www.news18.com/most_popular_gallery.php",
cache: false,
success: function(html)
{
$('#loadingDiv').hide();
$("#tab2_gallery").show();
$("#tab2_gallery").html(html);
}
});
});
/*To load the most popular tab on Videos*/
$('#most_popular_videos').click(function(){
$('#tab1_videos').hide();
$('#tab2_videos').show();
$('#loadingDiv').show();
$( "#latest_videos" ).addClass( "dact" );
$( "#most_popular_videos" ).removeClass( "dact" );
$.ajax
({
type: "get",
url: "http://www.news18.com/most_popular_videos.php",
cache: false,
success: function(html)
{
$('#loadingDiv').hide();
$("#tab2_videos").show();
$("#tab2_videos").html(html);
}
});
});
/*To process the Newsletter Signup without page refresh*/
$('#newsletter_signup').click(function(){
var email = $("#email").val();
var dataString = "email="+email;
$.ajax
({
type: "post",
url: "http://www.news18.com/ajax_newsletter.php",
data: dataString,
cache: false,
success: function(html)
{
$("#news_resp").html(html);
}
});
});
/*To process the Newsletter Signup in responsive view*/
$('#newsletter_signup1').click(function(){
var email = $("#email1").val();
var dataString = "email="+email;
$.ajax
({
type: "get",
url: "http://www.news18.com/ajax_newsletter.php",
data: dataString,
cache: false,
success: function(html)
{
$("#news_resp1").html(html);
}
});
});
function RefreshPageUrl(title, url) {
if (history.pushState) {
history.pushState(null, title, url);
} else {
alert("Your Browser will not Support HTML5");
}
}
//To change the playing video by clicking on featured videos
$('.featured-anchor').on('click',function(){
var title = $(this).attr('title');
var pageurl = $(this).attr('data-href');
var date = $(this).attr('data-timestamp');
var vurl = $(this).attr('data-vurl');
RefreshPageUrl(title, pageurl);
var dataString = "date="+date+"&vurl="+vurl;
$.ajax
({
type: "post",
url: "http://www.news18.com/video-script.php",
data: dataString,
cache: false,
success: function(html)
{
$("#embdedcodelivetv").html(html);
}
});
});
/*To change the playing show by clicking on show names*/
$('.showname').on('click',function(){
var showname = $(this).attr('id');
var dataString = "show="+showname;
$.ajax
({
type: "post",
url: "http://www.news18.com/show-script.php",
data: dataString,
cache: false,
success: function(html)
{
$("#show").html(html);
$("#india-at-9,#now-showing,#the-week-that-wasn-t,#news-360,#ibnlive-shorts,#e-lounge").removeClass("red-text");
$("#"+showname).addClass("red-text");
}
});
});
/*To change the playing show by clicking on show names*/
$('#blogger_dd').on('change',function(){
var blogger_url = $(this).val();
window.location.href = blogger_url;
});
/* ipad on hover code*/
$('.navigation ul li a').on('click',function(){
var hrf = $(this).attr('href');
window.location.href = hrf;
});
});