function open_farman_popup()
{
$('body').addClass('OverflowHiddenBody');
$('#transparent_div').css('display','block');
$('#farman_popup').fadeIn('slow');
}
function close_farman_popup()
{
$('body').removeClass('OverflowHiddenBody');
$('#transparent_div').css('display','none');
$('#farman_popup').css('display','none');
}
// ejang dropdown
function myFunction() {
document.getElementById("myDropdown").classList.toggle("show");
}
function loadMoreLatestStory(){
var container = $('.latestNews'),scrollCount= $('.latestScrollPagination').val();
$('.loader').show();
$.ajax({
type: 'GET',
url: BaseURL + 'category/latest/ajax/'+scrollCount,
cache: false,
success: function (response) {
// console.log(response)
$('.loader').hide();
if(response == ""){
$('#loadMoreLatest').html('').html('
No more data.
')
}else{
scrollCount++;
$('.latestScrollPagination').val(scrollCount);
$('.latestNews').append(response);
}
},
error:function (xhr) {
$('.loader').hide();
}
});
}
function loadMoreWriter() {
var slug = $('#slug').val();
var container = $('.latestNews'),scrollCount= container.find('.latestScrollPagination').val();
$('.container .loaderP').show();
scrollCount++;
$.ajax({
type: 'POST',
url: BaseURL + 'writer/'+slug,
data:{
offset:scrollCount
} ,
cache: false,
success: function (response) {
if(response.length == 2){
$('#loadMoreWriter').replaceWith('مزید کوئی پوسٹ نہیں
');
}else{
container.find('.latestScrollPagination').val(scrollCount);
//console.log($(container.find('ul'))
container.find('ul').append(response);
$('.container .loaderP').hide();
}
},
error:function (xhr) {
$('.container .loaderP').hide();
}
});
}
function tvc_video_play(element){
var video_id = $('#video_id').data('video_id');
// var watch_duration = $(element).data('watch_duration');
var video_title = $('#video_title').val();
dataLayer.push({'event':'tvc_video',
'eventCategory':'video',
'eventAction':'play',
'eventLabel':video_title,
'video_id':video_id
});
}
function shareVideo(element) {
var eventLabel = $(element).data('event_label')
var video_title = $('#video_title').val()
var category = $('#category').val()
var video_id = $('#video_id').val()
dataLayer.push({'event':'tvc_video',
'eventCategory':'video',
'eventAction':'share',
'eventLabel':ucfirst(eventLabel,true),
'language':'Urdu',
'page_type':'Video',
'page_category': category,
'sub_category':'NA',
'video_title':video_title,
'video_id':video_id
});
}
function ucfirst(str,force){
//console.log(str,4444);
if(str !== undefined){
str=force ? str.toLowerCase():str;
return str.replace(/(\b)([a-zA-Z])/,
function(firstLetter){
return firstLetter.toUpperCase();
});
}
}
function analyticsFunc(element){
event.preventDefault();
var eventAction = $(element).data('event_action');
var position_type = $(element).data('position_type');
var page_type = ucfirst($(element).data('page_type'),true);
var listing_page_type = ucfirst($(element).data('listing_page_type'),true);
var sub_category = ucfirst($(element).data('sub_category'),true);
if(position_type == 'top_nav' || position_type == 'top_subnav'){
dataLayer.push({'event':'tvc_top_navigation_menu',
'eventCategory':'top_navigation_menu',
'eventAction':eventAction,
'eventLabel':page_type,
'language':'Urdu',
'listing_page_type':listing_page_type
});
}else if(position_type == 'epaper'){
dataLayer.push({'event':'tvc_top_navigation_menu',
'eventCategory':'top_navigation_menu',
'eventAction':'epaper_click',
'eventLabel':page_type,
'language':'Urdu'
});
}else if(position_type == 'tv_click'){
dataLayer.push({'event':'tvc_top_navigation_menu',
'eventCategory':'top_navigation_menu',
'eventAction':'tv_click',
'eventLabel':page_type,
'language':'Urdu'
});
}else if(position_type == 'bottom_nav'){
dataLayer.push({'event':'tvc_bottom_navigation_menu',
'eventCategory':'bottom_navigation_menu',
'eventAction':sub_category,
'eventLabel':eventAction,
'page_type':page_type,
'language':'Urdu',
'listing_page_type':listing_page_type
});
}else if(position_type == 'contact_us'){
dataLayer.push({'event':'tvc_bottom_navigation_menu',
'eventCategory':'bottom_navigation_menu',
'eventAction':'contact_us',
'eventLabel':'NA',
'language':'Urdu',
'page_type':page_type
});
}else if(position_type == 'follow_us'){
dataLayer.push({'event':'tvc_bottom_navigation_menu',
'eventCategory':'bottom_navigation_menu',
'eventAction':'follow_us',
'eventLabel':sub_category,
'language':'Urdu',
'page_type':page_type
});
}
window.location.href = $(element).attr('href');
}
function getClick(element) {
event.preventDefault();
var eventAction = $(element).data('event_action');
var position = $(element).data('position');
var article_name = $(element).data('article_name');
dataLayer.push({
'event': 'article_clicks',
'eventCategory': 'article_clicks',
'eventAction': eventAction, //eg: featured/topstories
'eventLabel': position,
'article_name': article_name
})
window.location.href = $(element).attr('href')
}
function tester(){
var category = ucfirst($('#category').val(),true);
var sub_category = ucfirst($('#sub_category').val());
var video_title = $('#video_title').val();
try{
var myPlayer = videojs('videoplayer');
var watch_duration = 0.0;
watch_duration = myPlayer.currentTime()
dataLayer.push({'event':'tvc_video',
'eventCategory':'video',
'eventAction':'close',
'eventLabel':video_title,
'language':'English',
'page_type':'Detail page',
'page_category':category,
'sub_category':sub_category,
'watch_duration':watch_duration,
'video_time_at': watch_duration
});
}catch (e) {
}
}
window.onbeforeunload = function(){
tester()
}
function millisToMinutesAndSeconds(millis) {
var minutes = Math.floor(millis / 60000);
var seconds = ((millis % 60000) / 1000).toFixed(0);
return minutes + ":" + (seconds < 10 ? '0' : '') + seconds;
}
// Close the dropdown if the user clicks outside of it
window.onclick = function (event) {
if (!event.target.matches(".dropbtn")) {
var customDropdown = document.getElementsByClassName(
"dropdown-content"
);
var i;
for (i = 0; i < customDropdown.length; i++) {
var openDropdown = customDropdown[i];
if (openDropdown.classList.contains("show")) {
openDropdown.classList.remove("show");
}
}
}
};
// ejang dropdown end
// new burger menu start
// Responsive Megamenu
const navModal = document.getElementById("navmodal");
const openMenu = document.getElementById("openmenu");
const closeMenu = document.getElementById("closemenu");
const main = document.querySelector("main");
// Open Megamenu and Make Main Fixed Position
openMenu.addEventListener("click", function () {
navModal.classList.add("active");
main.classList.add("fixed");
});
// Close Megamenu and Remove Main Fixed Position
closeMenu.addEventListener("click", function () {
navModal.classList.remove("active");
main.classList.remove("fixed");
});
$('#openmenu').click(function() {
$('body').addClass("OverflowHiddenBodyMenu");
});
$('#closemenu').click(function() {
$('body').removeClass("OverflowHiddenBodyMenu");
});
// new burger menu end
(function ($) {
var swiper = new Swiper(".opinion-slider", {
pagination: ".opinion-pagination",
nextButton: ".opinion-slider-next",
prevButton: ".opinion-slider-prev",
paginationClickable: true,
slidesPerView: 5,
spaceBetween: 10,
autoplay: 5000,
preventClicks: false,
preventClicksPropagation: false,
nested: true,
loop: false,
breakpoints: { 1200: { slidesPerView: 3, spaceBetween: 20 }, 900: { slidesPerView: 2, spaceBetween: 20 }, 640: { slidesPerView: 2, spaceBetween: 20 }, 480: { slidesPerView: 1, spaceBetween: 10 } },
});
/*var stop = true
setTimeout(function () {
return false;
$(window).on('scroll',scroller);
$(document.body).on('touchmove', scroller);
function scroller() {
var container = $('.scrollPagination'),
scrollCount = $('.scrollPaginationCount').val();
if(scrollCount >= 8){
$('.loader').html("").html('مزید خبریں نہیں
').show()
return false;
}
if (container.length > 0) {
// if(($(window).scrollTop() + window.innerHeight > $(document).height()) && stop) {
// if(($(window).scrollTop() == $(document).height() - $(window).height()) && stop ) {
// if (($(window).scrollTop() == $(document).height() - $(window).height()) && stop) {
// if(($(window).scrollTop() + $(window).height() >= $(document).height() + 10) && stop){
// if($(window).scrollTop() == ($(document).height()-window.innerHeight) ){
if ($(window).scrollTop() >= ($(document).height() - $(window).height() - 10)) {
// if($(window).scrollTop() + window.innerHeight >= document.body.scrollHeight ) {
console.log('start')
console.log($(document).height()-window.innerHeight)
console.log(($(window).scrollTop() - 40))
console.log(($(window).scrollTop()))
// console.log($(document).height())
// console.log($(window).scrollTop() + 200)
// console.log($(window).scrollTop())
stop = false
$('.loader').show();
$.ajax({
type: 'POST',
url: window.location.href,
cache: false,
data:{
offset : scrollCount
},
success: function (response) {
//console.log(response)
if (response == "") {
$('.loader').remove();
//$('.loader').remove();
} else {
scrollCount++;
$('.scrollPaginationCount').val(scrollCount)
container.append(response);
$('.loader').hide();
stop=true
}
},
error: function (xhr) {
$('.loader').hide();
}
});
}
}
}
},2000)*/
var stop = true
setTimeout(function () {
$(window).scroll(function () {
var container = $('.scrollPaginationNew'),
scrollCount = $('.scrollPaginationCount').val();
if(scrollCount >= 8){
$('.loader').html("").html('مزید خبریں نہیں
').show()
return false;
}
if (container.length > 0) {
// if(($(window).scrollTop() + window.innerHeight > $(document).height()) && stop) {
// if(($(window).scrollTop() == $(document).height() - $(window).height()) && stop ) {
// if (($(window).scrollTop() == $(document).height() - $(window).height()) && stop) {
// if(($(window).scrollTop() + $(window).height() >= $(document).height() + 10) && stop){
if($(window).scrollTop() >= ($(document).height()-window.innerHeight-100-$('.footer').height()) && stop === true){
stop = false;
let pageurl = window.location.href;
pageurl = pageurl.replace("#_", "");
console.log(pageurl);
$('.loader').show();
$.ajax({
type: 'GET',
url: pageurl+'?offset='+scrollCount,
cache: false,
/*data:{
offset : scrollCount
},*/
success: function (response) {
//console.log(response)
if (response == "") {
$('.loader').remove();
//$('.loader').remove();
} else {
scrollCount++;
$('.scrollPaginationCount').val(scrollCount)
container.append(response);
$('.loader').hide();
if(scrollCount < 8){
stop=true
}
}
},
error: function (xhr) {
$('.loader').hide();
}
});
}
}
});
},2000)
if($(window).width() <= 480) {
$('.ddd').addClass('menuAccordian');
var acc = document.getElementsByClassName("menuAccordian");
var i;
for (i = 0; i < acc.length; i++) {
acc[i].addEventListener("click", function() {
this.classList.toggle("active");
var panelAccord = this.nextElementSibling;
if (panelAccord.style.maxHeight) {
panelAccord.style.maxHeight = null;
} else {
panelAccord.style.maxHeight = 1230 + "px";
}
});
}
}
$(window).resize(function(){
if($(window).width() >= 480) {
$('.ddd').removeClass('menuAccordian');
}else{
$('.ddd').addClass('menuAccordian');
}
});
if($(window).width() <= 480) {
$('.menuFull').addClass('panelAccord');
}
$(window).resize(function(){
if($(window).width() <= 480) {
$('.menuFull').addClass('panelAccord');
}else{
$('.menuFull').removeClass('panelAccord');
}
});
// var acc = document.getElementsByClassName("menuAccordian");
// var i;
// for (i = 0; i < acc.length; i++) {
// acc[i].addEventListener("click", function() {
// this.classList.toggle("active");
// var panelAccord = this.nextElementSibling;
// if (panelAccord.style.maxHeight) {
// panelAccord.style.maxHeight = null;
// } else {
// panelAccord.style.maxHeight = panelAccord.scrollHeight + "px";
// }
// });
// }
// menu accordian on mobile end
window.open_print_popup = function (page_id, story_type) {
$('#contentArea').html('');
$('html, body').animate({scrollTop: 0}, 500);
$('#transparent_div').css('height', jQuery('body').height());
$('.printContentArea').css('overflow-y', 'scroll');
$('.printContentArea').css('overflow-x', 'hidden');
$('.printContentArea').css('clear', 'both');
$('body').addClass('OverflowHiddenBody');
$('#transparent_div').css('display', 'block');
$('#print_popup').css('display', 'block');
$('.loader_print').css('display', 'block');
$('#printbutton').css('display', 'none');
$.ajax({
type: 'POST',
url: BaseURL + 'detail/print_page',
data: 'id=' + page_id + '&story_type=' + story_type,
cache: false,
success: function (response) {
response = unescape(response);
$('.print_page_popup').css('height', jQuery(window).height() - 40);
$('.printContentArea').css('height', jQuery(window).height() - 100);
$('#printbutton').css('display', 'block');
$('.loader_print').css('display', 'none');
$('#contentArea').html(response);
}
});
}
window.print_story = function (divName) {
var printContents = document.getElementById('contentArea').innerHTML;
var originalContents = document.body.innerHTML;
document.body.innerHTML = printContents;
window.print();
document.body.innerHTML = originalContents;
}
window.close_print_popup = function () {
$('#contentArea').html('');
$('body').removeClass('OverflowHiddenBody');
$('#print_popup').css('height', '');
$('.printContentArea').css('height', '');
$('#transparent_div').css('display', 'none');
$('#printbutton').css('display', 'none');
$('#print_popup').css('display', 'none');
}
window.openNav = function () {
$("#mySidenav").addClass("openNavLeft");
/* $("body").css("overflow","hidden");*/
document.getElementById("leftOverlay").style.display = "block";
$(".install-tuts-icon").addClass("hide");
}
window.closeNav = function () {
$("#mySidenav").removeClass("openNavLeft");
/*$("body").css("overflow","auto");*/
document.getElementById("leftOverlay").style.display = "none";
$(".install-tuts-icon").removeClass("hide");
}
window.get_archive_column_text = function (BASEURL_SITE_URDU) {
var archive_date = jQuery('#filter_archive_date').val();
if (archive_date != '') {
jQuery('.loader').css('display', 'inline-block');
jQuery.ajax({
type: 'POST',
url: BASEURL_SITE_URDU + 'frontend/paper/ajax_columns_archive',
data: 'archive_date=' + archive_date,
cache: false,
success: function (response) {
response = unescape(response);
jQuery('.loader').css('display', 'none');
jQuery('#archiveColumnMain').html(response);
}
});
}
}
var adjsutDrawerHeight = function () {
var windowHeight = $(window).height();
var adjustedHeight = windowHeight - $("#mySidenav .drawer-logo").height();
$("#mySidenav .inner-scroller").height(adjustedHeight);
},
isRtl = true,
punchout = function () {
$(".makeThisFeatured").each(function () {
var isImage = $(this).length,
isIframe = $(this).find("iframe").length,
isTwitterIframe = $(this).find(".media__item--twitter").length;
if (isImage || !isIframe) {
if (!isTwitterIframe)
if (isRtl) {
var offsetRight = Math.round(Math.max(0, $(window).width() - $(this).outerWidth() - $(this).offset().left)),
marginRight = 0 - offsetRight;
$(this).css("margin-right", marginRight + "px"), $(this).css("width", $(window).width()), offsetRight = Math.round(Math.max(0, $(window).width() - $(this).outerWidth() - $(this).offset().left)), marginRight = 0 - offsetRight + marginRight, 0 !== offsetRight && 0 !== marginRight && $(this).css("margin-right", marginRight + "px")
} else {
var offsetLeft = Math.round(Math.max(0, $(this).offset().left)),
marginLeft = 0 - offsetLeft;
$(this).css("margin-left", marginLeft + "px"), $(this).css("width", $(window).width()), offsetLeft = Math.round(Math.max(0, $(this).offset().left)), marginLeft = 0 - offsetLeft + marginLeft, 0 !== offsetLeft && 0 !== marginLeft && $(this).css("margin-left", marginLeft + "px")
}
isImage ? $(this).find("img").css("width", "100%") : isIframe && $(this).find("iframe").css("width", "100%"), $(this).addClass("makeThisFeatured"), $(this).css("max-width", "inherit")
}
})
},
$menus = $(".nav--responsive"),
responsive = function () {
$("html").on("click", function (e) {
var $dropdown = $(this).find(".nav__item--sandwich > .nav--dropdown");
$(this).find(".nav__item--sandwich").removeClass("nav__item--sandwich-expanded"), $dropdown.hide()
}), $menus.each(function () {
var $menu = $(this),
$overflowedItems = [],
$items = $menu.find(">li"),
$sandwich = $(''),
isRtl = $menu.parents().hasClass("rtl"),
itemOffsetRight = 0,
menuOffsetRight = 0;
if ($items.length) {
var hasOverflow = !1,
hasSandwich = $menu.find(".nav__item--sandwich").length > 0,
sandwichWidth = 0;
$tmp = $sandwich.clone(!1), $tmp.css({
visibility: "hidden",
position: "absolute"
}), $tmp.appendTo($menu), sandwichWidth = $tmp.width(), $tmp.remove(), $items.each(function (index) {
var $item = $(this),
isOverflowed = !1;
return $item.show(), isRtl ? (itemOffsetRight = $(window).width() - ($item.outerWidth() + $item.offset().left), menuOffsetRight = $(window).width() - ($menu.outerWidth() + $menu.offset().left), isOverflowed = $menu.width() + menuOffsetRight - $item.outerWidth() - itemOffsetRight - sandwichWidth < 0) : isOverflowed = $menu.width() - $item.outerWidth() - $item.offset().left + $menu.offset().left - sandwichWidth < 0, isOverflowed ? ($overflowedItems = $items.slice(index).hide(), hasOverflow = !0, !1) : void 0
}), hasOverflow ? (hasSandwich ? $sandwich = $menu.find(".nav__item--sandwich").eq(0).show() : ($menu.append($sandwich), $sandwich.on("click", function (e) {
e.stopPropagation();
var $dropdown = $(this).find(".nav--dropdown");
$dropdown.is(":visible") ? $(this).removeClass("nav__item--sandwich-expanded") : $(this).addClass("nav__item--sandwich-expanded"), $dropdown.toggle(250)
})), $sandwich.find(".nav--dropdown").remove(), $dropdown = $(''), $($overflowedItems).each(function () {
var $overflowedItem = $(this);
$overflowedItem.hasClass("nav__item--sandwich") || $overflowedItem.clone().show().appendTo($dropdown)
}), $sandwich.append($dropdown)) : hasSandwich && $menu.find(".nav__item--sandwich").remove(), $menu.css({
overflow: "initial"
})
}
})
};
$(function () {
adjsutDrawerHeight();
punchout();
if ($menus.length) {
responsive();
}
$(".non-clickable").on("click", function (e) {
$(this).next("a").next("ul").slideToggle();
$(this).parents("li").toggleClass("menu-open");
});
if (typeof $("body").find(".embedgallery").attr("class") !== "undefined") {
$("body").find(".embedgallery").each(function () {
var sclass = $(this).attr("id");
var swiper = new Swiper('#' + sclass, {
autoHeight: true, //enable auto height
slidesPerView: 1,
spaceBetween: 20,
pagination: {
el: '.swiper-pagination',
clickable: true
},
navigation: {
nextEl: '.swiper-button-next_gallery',
prevEl: '.swiper-button-prev_gallery'
}
});
$("." + sclass).colorbox({"maxWidth": "95%", maxHeight: "95%"});
});
}
$(".detail-content").find("[contenteditable]").attr('contenteditable', false);
if (typeof $("body").find(".description-area").attr("class") !== "undefined") {
var contentImages = $(".description-area *:not(.vjs-watermark-content)>img:not(.gallery_img):not(.relatedPostImage):not(.showImageAuthor)").length;
if (contentImages) {
//geoZoom(document.querySelectorAll('.description-area *:not(.vjs-watermark-content)>img:not(.gallery_img):not(.relatedPostImage):not(.showImageAuthor)'));
/*geoZoom(document.querySelectorAll('.description-area img:not(.gallery_img):not(.relatedPostImage):not(.showImageAuthor)'));*/
}
}
$(".medium-insert-images figure").append("");
$(".medium-insert-images").each(function () {
var captionLength = $(this).find("figure figcaption").length;
if (captionLength > 0) {
var heightCap = $(this).find("figure figcaption").outerHeight();
$(this).find(" figure .zoom-icon").css({
"bottom": (heightCap + 5) + "px"
});
}
});
var swiper1 = new Swiper('.home-opinion-slider', {
slidesPerView: 5,
spaceBetween: 20,
autoplay: {
delay: 5000,
},
breakpoints: {
1200: {
slidesPerView: 4,
spaceBetween: 20
},
991: {
slidesPerView: 3,
spaceBetween: 20
},
767: {
slidesPerView: 2,
spaceBetween: 20
},
480: {
slidesPerView: 1,
spaceBetween: 10
}
}
});
var swiper2 = new Swiper('.mag-slider-home', {
slidesPerView: 4,
spaceBetween: 30,
autoplay: {
delay: 5000,
},
navigation: {
nextEl: '.swiper-button-next',
prevEl: '.swiper-button-prev',
},
breakpoints: {
1024: {
slidesPerView: 4,
spaceBetween: 40,
},
768: {
slidesPerView: 3,
spaceBetween: 30,
},
640: {
slidesPerView: 2,
spaceBetween: 20,
},
320: {
slidesPerView: 1,
spaceBetween: 10,
}
}
});
var swiper = new Swiper('.detail_top_slider', {
slidesPerView: 4,
spaceBetween: 10,
/*slidesPerGroup: 3,*/
autoplay: {
delay: 5000,
},
navigation: {
nextEl: '.swiper-button-next_top',
prevEl: '.swiper-button-prev_top',
},
breakpoints: {
1200: {
slidesPerView: 3,
spaceBetween: 30,
},
991: {
slidesPerView: 2,
spaceBetween: 20,
},
600: {
slidesPerView: 1,
spaceBetween: 10,
}
}
});
$(".dropdown").hover(
function () {
$('.dropdown-menu', this).not('.in .dropdown-menu').stop(true, true).slideDown("400");
$(this).toggleClass('open');
},
function () {
$('.dropdown-menu', this).not('.in .dropdown-menu').stop(true, true).slideUp("400");
$(this).toggleClass('open');
}
);
/*$('.trending-icon').on('click', function () {
$parent_box = $(this).closest('ul');
$parent_box.siblings().find('.mob-trending-list ul').hide();
$parent_box.find('.mob-trending-list').toggle();
});
$('.trending-icon').click(function () {
$('.mob-bottom-header').toggle(400);
});*/
$(".fa-share-alt").click(function () {
$(".flipbook-shareButtons").toggle();
});
var $window = $(window);
var $sidebar = $(".sidebar");
if(parseInt($('.sidebar').length) > 0)
{
if (typeof $(".footer").offset() !== "undefined")
{
var $footerOffsetTop = $(".footer").offset().top;
var $sidebarOffset = $sidebar.offset();
$window.scroll(function () {
var removeOffset = $footerOffsetTop;
/*if (typeof $("body").find(".detail-page").attr("class") !== "undefined") {
removeOffset = $("body").find(".detail-page").find(".more-content-all").offset().top - $sidebar.height();
} else {
}*/
removeOffset = $(".footer").offset().top - $sidebar.height() - 182;
if (typeof $sidebarOffset !== "undefined" && $window.scrollTop() > $sidebarOffset.top && $window.scrollTop() < removeOffset) {
$sidebar.addClass("fixed");
$sidebar.css({top: 82+"px"});
} else {
$sidebar.removeClass("fixed");
}
});
}
}
var $sidebar2 = $(".sidebar2");
if(parseInt($('.sidebar2').length) > 0)
{
if (typeof $(".footer").offset() !== "undefined")
{
var $sidebarOffset2 = $sidebar2.offset();
$window.scroll(function () {
/* if (typeof $("body").find(".detail-page").attr("class") !== "undefined") {
removeOffset = $("body").find(".detail-page").find(".more-content-all").offset().top - $sidebar2.height();
} else {
removeOffset = $footerOffsetTop - $footerHeight - $sidebar2.height();
}*/
var removeOffset = $(".footer").offset().top - $sidebar2.height() - 182;
/*console.log($(".footer").offset().top);
console.log($footerOffsetTop , 'footerHeight:', $(".footer").height() ,' - ', $sidebar2.height(),' - ', 182);
console.log($window.scrollTop() ,' > ', $sidebarOffset2.top, ' && ', $window.scrollTop(),' < ',removeOffset);*/
if (typeof $sidebarOffset2 !== "undefined" && $window.scrollTop() > $sidebarOffset2.top && $window.scrollTop() < removeOffset) {
$sidebar2.addClass("fixed");
$sidebar2.css({top: 82+"px"});
} else {
$sidebar2.removeClass("fixed");
}
});
}
}
var $topbar = $(".detail_slider_top");
var $topbaroffset = $topbar.offset();
$window.scroll(function () {
/* if (typeof $("body").find(".detail-page").attr("class") !== "undefined") {
removeOffset = $("body").find(".detail-page").find(".more-content-all").offset().top - $sidebar2.height();
} else {
removeOffset = $footerOffsetTop - $footerHeight - $sidebar2.height();
}*/
var removeOffset = $footerOffsetTop - $topbar.height();
/*if (typeof $topbaroffset !== "undefined" && $window.scrollTop() > $topbaroffset.top && $window.scrollTop() < removeOffset) {
$topbar.addClass("fixed-top");
$topbar.css({top: 0});
} else {
$topbar.removeClass("fixed-top");
}*/
});
/**load more section**/
$("body").on("click", ".load-more-news", function () {
$(".bottom-loader").removeClass("hide");
var ele = $(this),
url = ele.attr("data-url"),
offset = parseInt(ele.attr("data-offset")),
data = {
"category_id": ele.attr("data-category_id"),
"parent_slug": ele.attr("data-parent_slug"),
"child_slug": ele.attr("data-child_slug"),
"offset": ++offset
};
$.ajax({
url: url,
type: "get",
data: data,
success: function (result) {
ele.prev("ul").append(result);
ele.attr("data-offset", offset);
},
complete: function () {
$(".bottom-loader").addClass("hide");
}
});
});
$("body").on("click", ".load-more-latest-news", function () {
$(".bottom-loader").removeClass("hide");
var ele = $(this),
url = ele.attr("data-url"),
offset = parseInt(ele.attr("data-offset")),
data = {
"offset": ++offset
};
$.ajax({
url: url + "/" + offset,
type: "post",
success: function (result) {
ele.prev("ul").append(result);
ele.attr("data-offset", offset);
},
complete: function () {
$(".bottom-loader").addClass("hide");
}
});
});
if (typeof($('#filter_archive_date').val()) != "undefined" && $('#filter_archive_date').val() !== null) {
$("#filter_archive_date").datepicker({dateFormat: 'yy-mm-dd', maxDate: 0});
}
});
$(window).resize(function () {
adjsutDrawerHeight();
punchout();
if ($menus.length) {
responsive();
}
});
})(jQuery);
jQuery(document).ready(function() {
$("body").on("click", ".contactus", function(e) {
e.preventDefault();
window.scrollTo(0, 0);
$('#contactPopup').modal('show');
});
$("body").on("click", "#filterSubmit", function() {
var a = true;
var isClick = true;
var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
var phonefilter = /^[0-9-+]+$/;
var contact_related = $.trim($('#contact_related').val());
var contact_name = $.trim($('#contact_name').val());
var contact_email = $.trim($('#contact_email').val());
var contact_phone = $.trim($('#contact_phone').val());
var contact_message = $.trim($('#contact_message').val());
var recaptcha_response = $.trim($('.g-recaptcha-response').val());
$('.frm_submit_msg').remove();
$('.error_contact').remove();
var loaderGif = "";
if (!!isClick) {
if (contact_name == '') {
a = false;
$('#contact_name').after('enter name
');
}
if (contact_email == '') {
a = false;
$('#contact_email').after('enter email
');
} else if (!emailReg.test(contact_email)) {
a = false;
$('#contact_email').after('invalid email
');
}
if (contact_phone == '') {
a = false;
$('#contact_phone').after('enter phone
');
} else if (!phonefilter.test(contact_phone)) {
a = false;
$('#contact_phone').after('invalid phone number
');
}
if (contact_message == '') {
a = false;
$('#contact_message').after('enter message
');
}
if (recaptcha_response == '') {
a = false;
$('.g-recaptcha-response').after('captcha error
');
}
if (a) {
jQuery(this).after(loaderGif);
$.ajax({
type: 'POST',
url: BaseURL + 'contact/submit_contact',
data: 'contact_related=' + contact_related + '&contact_name=' + contact_name + '&contact_email=' + contact_email + '&contact_phone=' + contact_phone + '&contact_message=' + contact_message,
cache: false,
success: function(response) {
response = unescape(response);
$('#contact_name').val('');
$('#contact_email').val('');
$('#contact_phone').val('');
$('#contact_message').val('');
$('#arpp_loading').hide('');
isClick = true;
$('.contactloader').remove();
jQuery('#filterSubmit').before('Thanks for your message. We have received it and someone from the related department will follow up with you soon.
');
}
});
}
}
});
var windowW = $(window).width();
if(windowW <= 600){
setTimeout(function () {
$(".top_lb").removeClass("top_lb");
},10000);
}
/**social image share function**/
$(".open-share-dialog").on("click",function () {
var ele = $(this),
share_action = ele.attr("data-action"),
share_image = "https://jang.com.pk/assets/uploads/updates/2018-08-03/529897_1128319_updates.jpg",//ele.attr("data-image"),
share_title = ele.attr("data-title"),
share_url = "https://jang.com.pk/news/529331#147234";
var button = "https://www.facebook.com/dialog/feed?";
button = button + ("app_id=304196780076842");
button = button + "&display=popup";
button = button + ("&link=" + encodeURIComponent(share_url));
button = button + ("&picture=" + encodeURIComponent(share_image));
button = button + ("&name=" + encodeURIComponent(share_title));
button = button + ("&description=" + encodeURIComponent(share_title));
button = button + ("&redirect_uri=" + encodeURIComponent(share_url));
window.open(button, share_title, "width=670,height=320" + ",status=0,toolbar=0,menubar=0,location=1,scrollbars=1");
});
$('.show').click(function () {
$(this).parent('span').find('.menu').toggle("slide");
});
$('.photoAlbumCats').change(function () {
/*console.log($(this).val());*/
window.location.href = $(this).val();
});
if($('#galleria').length > 0) {
Galleria.loadTheme('https://jang.com.pk/assets/front/js/galleria.twelve.min.js');
Galleria.configure({
imageCrop: false
});
Galleria.run('#galleria' ,{
/*height: 0.667,*/
});
}
});
// ===== Scroll to Top ====
$(window).scroll(function() {
if ($(this).scrollTop() >= 2000) { // If page is scrolled more than 50px
$('#return-to-top').fadeIn(200); // Fade in the arrow
} else {
$('#return-to-top').fadeOut(200); // Else fade out the arrow
}
});
$('#return-to-top').click(function() { // When arrow is clicked
$('body,html').animate({
scrollTop : 0 // Scroll to top of body
}, 500);
});
// ===== Jang Menu ====
$(document).ready(function() {
var $menus = $(".jang_nav--responsive");
if ($menus.length) {
var responsive = function() {
$("html").on("click", function(e) {
var $dropdown = $(this).find(".jang_nav__item--sandwich > .jang_nav--dropdown");
$(this).find(".jang_nav__item--sandwich").removeClass("jang_nav__item--sandwich-expanded"), $dropdown.hide()
}), $menus.each(function() {
var $menu = $(this),
$overflowedItems = [],
$items = $menu.find(">li"),
$sandwich = $(''),
isRtl = $menu.parents().hasClass("rtl"),
itemOffsetRight = 0,
menuOffsetRight = 0;
if ($items.length) {
var hasOverflow = !1,
hasSandwich = $menu.find(".jang_nav__item--sandwich").length > 0,
sandwichWidth = 0;
$tmp = $sandwich.clone(!1), $tmp.css({
visibility: "hidden",
position: "absolute"
}), $tmp.appendTo($menu), sandwichWidth = $tmp.width(), $tmp.remove(), $items.each(function(index) {
var $item = $(this),
isOverflowed = !1;
return $item.show(), isRtl ? (itemOffsetRight = $(window).width() - ($item.outerWidth() + $item.offset().left), menuOffsetRight = $(window).width() - ($menu.outerWidth() + $menu.offset().left), isOverflowed = $menu.width() + menuOffsetRight - $item.outerWidth() - itemOffsetRight - sandwichWidth < 0) : isOverflowed = $menu.width() - $item.outerWidth() - $item.offset().left + $menu.offset().left - sandwichWidth < 0, isOverflowed ? ($overflowedItems = $items.slice(index).hide(), hasOverflow = !0, !1) : void 0
}), hasOverflow ? (hasSandwich ? $sandwich = $menu.find(".jang_nav__item--sandwich").eq(0).show() : ($menu.append($sandwich), $sandwich.on("click", function(e) {
e.stopPropagation();
var $dropdown = $(this).find(".jang_nav--dropdown");
$dropdown.is(":visible") ? $(this).removeClass("jang_nav__item--sandwich-expanded") : $(this).addClass("jang_nav__item--sandwich-expanded"), $dropdown.toggle(250)
})), $sandwich.find(".jang_nav--dropdown").remove(), $dropdown = $(''), $($overflowedItems).each(function() {
var $overflowedItem = $(this);
$overflowedItem.hasClass("jang_nav__item--sandwich") || $overflowedItem.clone().show().appendTo($dropdown)
}), $sandwich.append($dropdown)) : hasSandwich && $menu.find(".jang_nav__item--sandwich").remove(), $menu.css({
overflow: "initial"
})
}
})
};
responsive(), $(window).resize(function() {
responsive()
})
}
});
(function () {
'use strict';
var request = function (type, dataType, url, data, callback, errorcallback) {
var responseData,
ajaxUrl = url;
closeNav();
$("body").css("overflow", "auto");
$.ajax({
url: ajaxUrl,
type: type,
success: function (response) {
responseData = (response);
},
complete: function (event, xhr) {
if (xhr === "error") {
if (typeof errorcallback === "function") {
errorcallback((responseData));
}
} else {
if (typeof callback === "function") {
callback((responseData));
}
}
$(window).scrollTop(0);
closeNav();
$(".loader-jang-main").addClass("hide");
}
});
},
seturl = function (url, title) {
history.pushState({}, title, url);
};
$(function () {
var windowWidth = $(window).width();
// $("body").on("click", ".static_link_notClick,.author_title_img a,.akhbar_page ul li a,.latest_page_right ul li a,.latest_page_sidebar ul li a,.detail_top_slider .swiper-slide a,.brad-cram a,.detail-cat-title a,.cat_m_story ul li a,.cat_menu.rtl ul li ul li a,.cat_menu.rtl li a,.magazine-slider .swiper-slide a,.column_list ul li a,.khabre-list ul li a,.akhbar-comp a, .main-story ul li a,.khas-report-list ul li a,#mySidenav ul li:not(:nth-child(9)):not(:nth-child(10)):not(:nth-child(11)):not(:nth-child(12)) a,.desktop-header li.dropdown a,.desktop-header li:nth-child(3) a,.header-trending ul li a,.cat_detail_list ul li a,.logo a",
// function (e) {
//
// var windowWidth = $(window).width();
// if (windowWidth <= 767 && $(this).attr("href") != "" && !$(this).hasClass("close_ads")) {
//
// //call first load request
// e.preventDefault();
// e.stopPropagation();
//
// var ele = $(this),
// title = typeof ele.attr("title") != "undefined" ? ele.attr("title") : "",
// requestedUrl = $(this).attr("href");
// $(".loader-jang-main").removeClass("hide");
//
// closeNav();
//
// if (window.navigator.onLine) {
// seturl(requestedUrl, title);
// window.top.location = window.top.location;
//
// } else {
// request("get", "JSON", requestedUrl, {isAjax: true}, function (result) {
// seturl(requestedUrl, title);
// window.top.location = window.top.location;
// }, function (result) {
// console.log("No internet connection");
// });
//
// }
//
// }
// });
//
// if (windowWidth <= 767) {
//
// $(window).bind("popstate", function (e) {
//
// var requestedUrl = window.location.href;
// $(".loader-jang-main").removeClass("hide");
//
// if (window.navigator.onLine) {
//
// window.top.location = requestedUrl;
//
// } else {
//
// request("get", "JSON", requestedUrl, {isAjax: true}, function (result) {
//
// window.top.location = requestedUrl;
//
// }, function (result) {
//
// console.log("No internet connection");
//
// });
//
// }
// });
// }
/*if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/OneSignalSDKWorker.js', {scope: '/'})
.then(function (reg) {
reg.onupdatefound = function () {
var installingWorker = reg.installing;
installingWorker.onstatechange = function () {
switch (installingWorker.state) {
case 'installed':
if (navigator.serviceWorker.controller) {
console.log('New or updated content is available.');
} else {
console.log('Content is now available offline!');
}
break;
case 'redundant':
console.error('The installing service worker became redundant.');
break;
}
};
};
}).catch(function (e) {
console.error('Error during service worker registration:', e);
});
}*/
if (window.navigator.onLine) {
$("body").removeClass("grayScale");
$(".offline-mode-container").addClass("hide");
} else {
$("body").addClass("grayScale");
$(".offline-mode-container").removeClass("hide");
}
$(".open-share-btn").on("click",function () {
var ele = $(this);
if (ele.next(".share-button-list").hasClass("open")) {
ele.next(".share-button-list").removeClass("open");
} else {
ele.next(".share-button-list").addClass("open");
}
});
});
window.addEventListener('load', function () {
setTimeout(function () {
window.addEventListener('online', function () {
$("body").removeClass("grayScale");
$(".offline-mode-container").addClass("hide");
window.location.reload(true);
});
window.addEventListener('offline', function () {
$("body").addClass("grayScale");
$(".offline-mode-container").removeClass("hide");
});
}, 200);
});
if($('.ob-dynamic-rec-link').length > 0)
{
setTimeout(function(){
//if(typeof $(".OUTBRAIN").attr("class") !== "undefined"){
document.getElementsByClassName("ob-dynamic-rec-link")[0].setAttribute('target','_blank')
document.getElementsByClassName("ob-dynamic-rec-link")[1].setAttribute('target','_blank');
document.getElementsByClassName("ob-dynamic-rec-link")[2].setAttribute('target','_blank');
document.getElementsByClassName("ob-dynamic-rec-link")[3].setAttribute('target','_blank');
$(document).on('ready',function () {
$( ".OUTBRAIN" ).each(function() {
$(this).find('.ob-dynamic-rec-link').attr('target','_blank');
});
});
//}
}, 15000);
}
$(document).ready(function () {
$(".sponsor_ads_img").click(function () {
window.open(ads_url, '_blank');
});
if (typeof $("body").find(".corona_update_topheader").attr("class") !== "undefined") {
$('body').on('click', '.show_corona_update', function(event) {
var filter_value = $(this).attr('data-filter');
$('.cb_left').find('.cb_btn').removeClass('active_corona_tab');
$(this).parent('.cb_btn').addClass('active_corona_tab');
if(filter_value == 'pakistan'){
$('.show_in_world_corona').hide();
$('.show_in_pak_corona').fadeIn();
}
else{
$('.show_in_pak_corona').hide();
$('.show_in_world_corona').fadeIn();
}
});
$('body').on('change', '.c_udate_bottom .filter_corona_combo', function(event) {
event.preventDefault();
var filter_value = $(this).val();
var filter_session = $(this).parent('.cb_select').find('.corona_section').val();
var filter_value_urdu = $(this).find("option:selected").text();
/*if(filter_value != '')
{*/
jQuery('.loader_block').remove();
var loader_html = '';
$(this).after(loader_html);
var that = this;
jQuery.ajax({
type: 'POST',
url: BaseURL+'assets/front/corona/ajax_corona_update.php',
data: 'filter_value='+filter_value+'&filter_session='+filter_session,
cache: false,
success: function (response) {
response = unescape(response);
jQuery('.loader_block').remove();
if((filter_value == 'all' || filter_value == '') && filter_session == 'pakistan'){
filter_value_urdu = 'پاکستان';
}
else if(filter_value == 'all' && filter_session == 'world'){
filter_value_urdu = 'دنیا';
}
$(that).parents('.cb_left').find('.cv_country_'+filter_session).html(filter_value_urdu);
$('#'+filter_session+'_stats_data').html(response);
//console.log(filter_value_urdu); return false;
}
});
//}
});
}
var isReadMoreClick = true;
$("body").on("click", ".read-more-click", function () {
var ele = $(this),
url = ele.attr("data-url"),
limit = ele.attr("data-limit"),
post_id = ele.attr("data-postid"),
page = parseInt(ele.attr("data-page")),
isFullPage = ele.hasClass("full-page");
$('.container .loaderP').show();
$.ajax({
type: 'POST',
url: BaseURL + '/' + url,
data: 'limit=' + limit + "&page=" + page + "&post_id=" + post_id + "&isFullPage=" + isFullPage,
cache: false,
dataType: 'json',
success: function (response) {
if (response.success) {
page++;
ele.attr("data-page", page);
if (!!isFullPage) {
ele.parents(".related-section").find(".more-long").find("ul").append(response.data);
} else {
ele.parents(".more-content").find(".more-list").append(response.data);
}
}
$('.container .loaderP').hide();
isReadMoreClick = true;
},
error: function (xhr) {
$('.container .loaderP').hide();
isReadMoreClick = true;
}
});
});
$(window).scroll(function () {
var detailLoadMore = $(".read-more-click");
if (detailLoadMore.length > 0) {
if (!!isReadMoreClick) {
let footerHeight = 0;
if($('.footer').length > 0){
footerHeight = $('.footer').height();
}
if ($(document).height() - $(window).height() <= $(window).scrollTop() + footerHeight ) {
isReadMoreClick = false;
detailLoadMore.trigger("click");
}
}
};
});
});
try{
$('video-js').attr('id','videoplayer')
var myPlayer = videojs('videoplayer');
myPlayer.on('play', () => {
var category = ucfirst($('#category').val(),true);
var sub_category = ucfirst($('#sub_category').val());
var video_title = $('#video_title').val();
var watch_duration = 0.0;
watch_duration = myPlayer.currentTime()
dataLayer.push({'event':'tvc_video',
'eventCategory':'video',
'eventAction':'play',
'eventLabel':video_title,
'language':'Urdu',
'page_type':'Detail page',
'page_category':category,
'sub_category':sub_category,
'watch_duration':watch_duration,
'video_time_at': watch_duration
});
});
myPlayer.on('pause', () => {
var category = ucfirst($('#category').val(),true);
var sub_category = ucfirst($('#sub_category').val());
var video_title = $('#video_title').val();
var watch_duration = 0.0;
watch_duration = myPlayer.currentTime()
dataLayer.push({'event':'tvc_video',
'eventCategory':'video',
'eventAction':'pause',
'eventLabel':video_title,
'language':'Urdu',
'page_type':'Detail page',
'page_category':category,
'sub_category':sub_category,
'watch_duration':watch_duration,
'video_time_at': watch_duration
});
});
}catch(e){
}
try{
var lis = $('.rpClass').find('ul > li');
// var i = 0;
// console.log(lis);
$.each(lis,function (k,v) {
// i++;
// console.log(k);
// console.log($(v).children('a').first().text())
$(v).children('a').first().on('click',function () {
dataLayer.push({
'event': 'article_clicks',
'eventCategory': 'article_clicks',
'eventAction': 'readMore_click',
'eventLabel': parseInt(k) + 1,
'article_name': $(v).children('a').first().text()
})
})
})
}catch(e){
}
}());