// Hide Header on on scroll down var didScroll; var lastScrollTop = 0; var delta = 5; var navbarHeight = $('header').outerHeight(); var emailPattern = /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/; var phonePattern = /^[0-9]{10}$/; var numberPattern = /^\d*$/; $(window).scroll(function(event){ didScroll = true; }); setInterval(function() { if (didScroll) { hasScrolled(); didScroll = false; } }, 250); // footer newsletter js // function isEmail(email) { var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/; return regex.test(email); } function createCookie(name, value, days) { if (days) { var date = new Date(); date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); var expires = "; expires=" + date.toGMTString(); } else var expires = ""; document.cookie = name + "=" + value + expires + "; path=/"; } function readCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for (var i = 0; i < ca.length; i++) { var c = ca[i]; while (c.charAt(0) == ' ') c = c.substring(1, c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length); } return 0; } function eraseCookie(name) { cookie_flag = 0; createCookie(name, "", -1); } script_userid = readCookie('qa_user_id'); $(document).ready(function ($) { $('.customer.share').on("click", function (e) { // $(this).customerPopup(e); }); $("#btnemail").on('click', function(e) { var inputs = { "email": $('#textemail').val() }; $("#newsresponse").css({"display":"block"}); if( !isEmail( $('#textemail').val() ) ){ $("#newsresponse").html("Please enter a valid email id"); $("#newsresponse").fadeOut(5000, function(){ $("#newsresponse").html(""); $("#textemail").val(""); }); return false; } var url =baseurl+ "subs-news.php"; $.ajax({ type: "POST", url: url, data: inputs, dataType: 'json', beforeSend: function( ) { $(".wrapLoader").css({"display":"block"}); }, success: function(data) { $(".wrapLoader").css({"display":"none"}); if( data.ret > 0 ){ $("#newsresponse").html("You already have a subscription"); }else{ $("#newsresponse").html("Thanks for your subscription"); } $("#newsresponse").fadeOut(5000, function(){ $("#newsresponse").html(""); $("#textemail").val(""); }); } }); }); $("form button.btn").on('click', function() { if( $(this).find('a').attr('href') ) { window.location.href = $(this).find('a').attr('href'); } }); }); // end of footer newsletter js // function hasScrolled() { var st = $(this).scrollTop(); // Make sure they scroll more than delta if(Math.abs(lastScrollTop - st) <= delta) return; if (st > lastScrollTop && st > navbarHeight){ // Scroll Down $('header').removeClass('nav-down').addClass('nav-up'); } else { // Scroll Up if(st + $(window).height() < $(document).height()) { $('header').removeClass('nav-up').addClass('nav-down'); } } lastScrollTop = st; } function loginPopup(popupType = '') { $('.wrap_loader').show(); $.ajax({ url: baseurl + "questions/ajax/ajaxLoginPopup.php", method: "POST", }).done(function (data) { $modalEl = $('#mui_popup_modal'); $modalEl.show(); var $formEl = $(data); $modalEl.append($formEl); mui.overlay('on', $modalEl.get(0)); if (popupType == 'signUp') { $("#spanSignUp").click(); } $('.wrap_loader').hide(); }); //window.location.href = baseurl + 'questions/login.php'; } function openNav() { document.getElementById("tp-mobile-right-panel").style.width = "280px"; document.getElementById("tp-mobile-overlaybg").style.display = "block"; } function closeNav() { document.getElementById("tp-mobile-right-panel").style.width = "0"; document.getElementById("tp-mobile-overlaybg").style.display = "none"; } function openLeftNav() { document.getElementById("tp-mobile-left-panel").style.width = "280px"; document.getElementById("tp-mobile-overlaybg").style.display = "block"; document.getElementById("tp-leftbar").style.display = "block"; } $(window).load(function() { if( window.innerWidth > 991 ){ if( $('.middle-col').height() < $('.sidebar').height()){ $('.middle-col').css("height", $('.sidebar').height() + 50 ); } if( $('.middle-col').height() < 1435){ $('.middle-col').css("height", "1435"); } } if(/iPhone|iPad|iPod/i.test(navigator.userAgent)) { $('.android').hide(); $('.microsoft').hide(); $('.hide-me').hide(); } }); function change_media() { if (parseInt($('#fileMedia').get(0).files.length) > 0) { var exts = ['jpeg', 'jpg', 'png', 'doc', 'docx', 'xls', 'xlsx', 'pdf', 'csv', 'odf', 'txt', 'ppt', 'pptx']; for (var i = 0; i < $('#fileMedia').get(0).files.length; ++i) { var ext = $('#fileMedia').get(0).files[i].name.split('.'); ext = ext.reverse(); var size = ($('#fileMedia').get(0).files[i].size / (1024 * 1024)).toFixed(2); if ($.inArray(ext[0].toLowerCase(), exts) < 0) { $('#answerAlert').html('Please select jpeg/png/doc/docx/xls/xlsx/pdf/csv/odf format files only.'); $('#answerAlert').show(); $('#fileMedia').focus(); $('#fileMedia').css('border-color', 'red'); $("#fileMedia").val(''); return false; } } if ($('#fileMedia').get(0).files.length > 10) { $('#answerAlert').html('Max 10 files are allowed to upload at a time.'); $('#answerAlert').show(); $('#fileMedia').focus(); $('#fileMedia').css('border-color', 'red'); $("#fileMedia").val(''); return false; } } var vq = $('#hdQid').val(); var formdata = new FormData(); formdata.append("vq", vq); var file_data = $('#fileMedia')[0].files; for (var i = 0; i < file_data.length; i++) { formdata.append("fileMedia[]", file_data[i]); } $.ajax({ url: baseurl + "questions/ajax/ajaxSaveMedia.php", dataType: 'json', method: "POST", cache: false, data: formdata, processData: false, contentType: false, xhr: function () { var xhr = new window.XMLHttpRequest(); xhr.upload.addEventListener("progress", function (evt) { if (evt.lengthComputable) { $('#mediaProgress').show(); var percentComplete = evt.loaded / evt.total; percentComplete = parseInt(percentComplete * 100); $('.myprogress').text(percentComplete + '%'); $('.myprogress').css('width', percentComplete + '%'); } }, false); return xhr; }, success: function (data) { $('#mediaProgress').hide(); if (data.flag == -99) { window.location = baseurl + "questions/login.php"; } else if (data.flag == 1) { var str = ''; var medias = ''; str += ''; $('#questionsMedia').append(str); } else { $('#fileMedia').next().html('Something went wrong! Please try after some time'); $('#fileMedia').focus(); $('#fileMedia').css('border-color', 'red'); $("#fileMedia").val(''); } } }); } function delete_media(thisObj) { alert(thisObj.attr('data-qid')); } var recaptcha1; var recaptcha2; var $modalEl; $(document).ready(function () { $('#mobile-search').hide(); $('#mobile-icon').click(function(e){ $('#mobile-search').toggle(); e.stopPropagation() }); /*var urlHash = window.location.href.split("#")[1]; if(urlHash != 'undefined'){ $(window).scroll(function (event) { var scroll = $(window).scrollTop(); if(scroll < 80){ $('#' + urlHash).css('margin-top',0); } }); $(window).on("load", function () { $('html,body').animate({ scrollTop: $('#' + urlHash).offset().top }, 300); $('#' + urlHash).css('margin-top',90); }); } */ $(document).on('click', '.media_remove', function () { var medianame = $(this).data('media'); var thisObj = $(this); if (confirm("Are you sure to delete this media!")) { var media = $('#mediaHdn').val(); media = media.replace(medianame + ",", ""); $('#mediaHdn').val(media); thisObj.parent().remove(); } }); // $("#modal_close").click(function () { // $('#mui-overlay').hide(); // }); $(document).on('click', '#modal_close', function () { mui.overlay('off'); $('.wrap_loader').show(); $('.wrap_loader').fadeOut(); }); // header $.ajax({ url: baseurl + "questions/ajax/ajaxGetTopMenu.php", method: "POST", success: function (data) { $('#user_menu').html(data); } }); $.ajax({ url: baseurl + "questions/ajax/ajaxGetTopMenuMobile.php", method: "POST", success: function (data) { $('#user_menu_mobile').html(data); } }); /* $.ajax({ url: baseurl + "questions/ajax/ajaxGetTopMenu1.php", method: "POST", dataType: 'json', success: function (data) { script_userid = data.userid; $('#profile_menu_id, #profile_mobile').html(data.content1); $('#profile_mobile').html(data.content1); if (data.content2 == '') { document.getElementById("profile_menu_block").style.width = "0px"; $('.up-arrow').css('margin-left', '129px!important'); $('.up-arrowL').css('margin-left', '247px!important'); $('.up-arrowS').css('right', '110px'); } $('#profile_menu_block').html(data.content2); $('#profile_menu_block_mobile').html(data.content2); //var_auth = data.var_auth; } }); */ $("#liNotification").on('click', function () { $("#spanNotifyCount").hide(); }); $('input[name="q"]').keydown(function (event) { if (event.keyCode == 13) { event.preventDefault(); return false; } }); $(".tp-profilemenu-dropdown").hide(); $(document).on('click','.profile_menu',function (event) { event.stopPropagation(); $(".tp-profilemenu-dropdown").show("fast"); $(".library_cont").hide(); $(".qa-search-box").hide(); $(".profile_cont").hide(); $("#txtQuestion").val(''); $("#divHeaderQuestions").html(''); $("#txtQuestion").hide(); }); $(".tp-profilemenu-dropdown").on("click", function (event) { event.stopPropagation(); }); $(".library_cont").hide(); $('.vMenuL').click(function (event) { event.stopPropagation(); $.ajax({ url: baseurl + "questions/ajax/ajaxGetTutorialsLibrary.php", method: "GET", success: function (data) { $('.library_cont').html(data); } }); $(".library_cont").slideToggle("fast"); $(".qa-search-box").hide(); $(".video_cont").hide(); $(".profile_cont").hide(); }); $(".library_cont").on("click", function (event) { event.stopPropagation(); }); $(".qa-search-box").hide(); $('.vMenuS').click(function (event) { event.stopPropagation(); $(".qa-search-box").slideToggle("fast"); $(".library_cont").hide(); $(".video_cont").hide(); $(".profile_cont").hide(); }); $(".qa-search-box").on("click", function (event) { event.stopPropagation(); $(".tp-profilemenu-dropdown").hide(); }); $(".profile_cont").hide(); $('.vMenuP').click(function (event) { event.stopPropagation(); $(".profile_cont").slideToggle("fast"); $(".library_cont").hide(); $(".video_cont").hide(); $(".qa-search-box").hide(); }); $(".profile_cont").on("click", function (event) { event.stopPropagation(); }); $(document).on("click", function () { $(".library_cont").html('
'); $(".video_cont").html('
'); $(".tp-profilemenu-dropdown").hide(); $(".library_cont").hide(); $(".qa-search-box").hide(); $("#txtQuestion").val(''); $("#divHeaderQuestions").html(''); }); $('#divMask').on("click", function () { $(".tp-profilemenu-dropdown").hide(); $(this).hide(); $('.profile_cont').hide(); $(".library_cont").hide(); $(".qa-search-box").hide(); $(".qa-search-icon").hide(); $("#txtQuestion").val(''); $("#divHeaderQuestions").html(''); }); $('#profile_menu_id, #profile_mobile').on("click", function () { $(".tp-profilemenu-dropdown").hide(); $('.profile_cont').show(); $(".library_cont").hide(); $(".qa-search-box").hide(); $("#txtQuestion").val(''); $("#divHeaderQuestions").html(''); }); $('.tp-profilemenu-dropdown').mouseleave(function () { $(this).removeClass('vmenuactive'); }); //Check notification count $.ajax({ url: baseurl + 'questions/ajax/ajaxGetNotifications.php', dataType: 'json', success: function (returnData) { if (returnData.flag == 1) { $("#spanNotifyCount").html(returnData.count); $("#spanNotifyCount").show(); $("#spanNotifyCountDropDown").html(returnData.count); $("#spanNotifyCountDropDown").show(); } else { $("#spanNotifyCount").hide(); } }, error: function (returnData) { } }) // user logout $('#ancUserLogout').click(function () { $('.wrap_loader').show(); $.ajax({ url: baseurl + "questions/ajax/ajaxUserLogout.php", success: function (data) { window.location.href = baseurl + 'questions/index.php'; }, error: function (data) {} }); }); // change password $('#update_password').click(function () { var old_password = $('#txtOldPwd').val(); var new_password = $('#txtNewPwd').val(); var confirm_password = $('#txtConfirmPwd').val(); var error_msg = ''; $("#profileForm input,textarea,select").each(function () { $(this).css('border-color', '#ccc'); }); if (old_password == '') { error_msg = 'Please enter old password'; $('#txtOldPwd').focus(); $('#txtOldPwd').css('border-color', 'red'); } else if (new_password == '') { error_msg = 'Please enter new password'; $('#txtNewPwd').focus(); $('#txtNewPwd').css('border-color', 'red'); } else if (confirm_password == '') { error_msg = 'Please re enter new password'; $('#txtConfirmPwd').focus(); $('#txtConfirmPwd').css('border-color', 'red'); } else if (confirm_password != new_password) { error_msg = 'Please enter same new password'; $('#txtConfirmPwd').focus(); $('#txtConfirmPwd').css('border-color', 'red'); } if (error_msg != '') { $('#profileAlert').html(error_msg); $('#profileAlert').show(); setTimeout(function () { $("#profileAlert").hide(); }, 3000); return false; } old_password = $.trim(old_password); new_password = $.trim(new_password); $("#profileForm input,textarea,select").each(function () { $(this).css('border-color', '#ccc'); }); $('#profileAlert').html(''); $('#profileAlert').hide(); $.ajax({ url: baseurl + "questions/ajax/ajaxChangeUserPassword.php", dataType: 'json', method: "POST", data: { "old_password": old_password, "new_password": new_password }, beforeSend: function () { $('.wrap_loader').show(); }, success: function (data) { if (data.flag == 0) { window.location.href = baseurl + 'questions/index.php'; } else if (data.flag == 1) { $('.wrap_loader').hide(); $('#profileAlert').html(data.msg); $('#profileAlert').show(); setTimeout(function () { $("#profileAlert").hide(); window.location.href = baseurl + "questions/user_logout.php"; }, 2000); } else { $('.wrap_loader').hide(); $('#profileAlert').html(data.msg); $('#profileAlert').show(); setTimeout(function () { $("#profileAlert").hide(); }, 3000); } } }); }); // question add $('#btnSaveQuestion').click(function () { if (script_userid != '') { var question = $('#txtQuestion').val(); var desp = $('#txtHeaderDesp').val(); $("#questionForm input,textarea,select").each(function () { $(this).css('border-color', '#ccc'); }); $('.search_bg_mask').css('height', $(document).height() - 40); $('.search_bg_mask').show(); $("#divHeaderQuestions").hide(); if (question == '') { $('#txtQuestion').focus(); $('#txtQuestion').css('border-color', 'red'); $('.alert-danger span').html('Please enter your question'); $('.alert-danger').show(); setTimeout(function () { $('.alert-danger').hide(); $('#txtQuestion').css('border-color', '#ccc'); $('.search_bg_mask').hide(); $('#txtQuestion').focus(); }, 3000); return false; } else if (question.length <= 30) { $('#txtQuestion').focus(); $('#txtQuestion').css('border-color', 'red'); $('.alert-danger span').html('Question is too short'); $('.alert-danger').show(); if (localStorage.question != '') { localStorage.removeItem('question'); } setTimeout(function () { $('.alert-danger').hide(); $('#txtQuestion').css('border-color', '#ccc'); $('.search_bg_mask').hide(); }, 3000); return false; } question = $.trim(question); desp = $.trim(desp); $("#questionForm input,textarea,select").each(function () { $(this).css('border-color', '#ccc'); }); $('#questionAlert').html(''); $('#questionAlert').hide(); $.ajax({ url: baseurl + "questions/ajax/ajaxAddQuestion.php", dataType: 'json', method: "POST", data: { "question": question, "desp": desp, "guestFlag": guestFlag }, beforeSend: function () { $('.wrap_loader').show(); }, success: function (data) { if (data.flag == 0) { // window.location.href = baseurl + 'questions/index.php'; } else if (data.flag == 2) { guestFlag = false; if (localStorage.question != '') { localStorage.removeItem('question'); } if (data.status == 'D') { $('.alert-success span').html(data.msg); $('.alert-success').show(); $('.wrap_loader').hide(); $('.search_bg_mask').hide(); guestFlag = false; setTimeout(function () { $('.alert-success').hide(); $('#txtQuestion').css('border-color', '#ccc'); $('#txtQuestion').val(''); $('#txtQuestion').css('width', '76%'); $('.nav-main-top').show(); $('.nav-right-top-focus').hide(); $('#caret_dpdown_show').hide(); }, 4000); } else if (data.status == 'P') { window.location.href = baseurl + 'questions/' + data.qid; } } else if (data.flag == 1) { if (localStorage.question != '') { localStorage.removeItem('question'); } $('.alert-success span').html(data.msg); $('.alert-success').show(); $('.wrap_loader').hide(); $('.search_bg_mask').hide(); guestFlag = false; setTimeout(function () { $('.alert-success').hide(); $('#txtQuestion').css('border-color', '#ccc'); $('#txtQuestion').val(''); $('#txtQuestion').css('width', '76%'); $('.nav-main-top').show(); $('.nav-right-top-focus').hide(); $('#caret_dpdown_show').hide(); }, 4000); } else if (data.flag == 3) { guestFlag = false; if (localStorage.question != '') { localStorage.removeItem('question'); } $('.alert-success span').html(data.msg); $('.alert-success').show(); $('.wrap_loader').hide(); $('.search_bg_mask').hide(); setTimeout(function () { $('.alert-success').hide(); $('#txtQuestion').css('border-color', '#ccc'); $('#txtQuestion').val(''); $('#txtQuestion').css('width', '76%'); $('.nav-main-top').show(); $('.nav-right-top-focus').hide(); $('#caret_dpdown_show').hide(); location.reload(); }, 3000); } else { $('.alert-danger span').html(data.msg); $('.alert-danger').show(); $('.wrap_loader').hide(); $('.search_bg_mask').hide(); setTimeout(function () { $('.alert-danger').hide(); $('#txtQuestion').css('border-color', '#ccc'); }, 4000); } }, error: function (response) { } }); } else { guestFlag = false; loginPopup(); } }); //login check $(document).on('click', '.ancHeadLogin', function () { $('.wrap_loader').show(); $('#mui_main_modal').html(''); loginPopup($(this).data('type')); $('.wrap_loader').hide(); }); // mislanious $('#caret_dpdown_show').hide(); $('#caret_dpdown').click(function (e) { e.stopPropagation(); $('#caret_dpdown_show').toggle(); var $el = $("#caret_dpdown_show"); if ($el.is(":visible")) { $el.show(); $('#divHeaderQuestions').css('margin-top', '90px'); } else { $('#divHeaderQuestions').css('margin-top', '12px'); } }); $(document).click(function () { $('#mui_main_modal').html(''); $('#feedbox_id').hide(); $('.alert-success').hide(); $('.alert-danger').hide(); $('.alert-warning').hide(); $("#questionAlert").hide(); $('#txtQuestion').css('border-color', '#ccc'); $('.search_bg_mask').hide(); $('#txtQuestion').css('width', '76%'); $('#caret_dpdown_show').hide(); $('.empty-search-alert').css('width', '37.5%'); //$('.nav-main-top').show(); //$('.nav-right-top-focus').hide(); $('#divHeaderQuestions').css('margin-top', '12px'); $('.qa_comments').hide(); var $el = $("#divHeaderQuestions"); var $elvar = $(".nav-right-top-focus"); var $elvar1 = $("#caret_dpdown_show"); if ($el.is(":visible")) { $el.hide(); $('.search_bg_mask').hide(); $('.nav-main-top').show(); $('.nav-right-top-focus').hide(); // $('.top-search').css('width','55%'); $('.empty-search-alert').css('width', '37.5%'); } if ($elvar.is(":visible")) { $elvar.show(); $('.nav-main-top').hide(); $('.search_bg_mask').show(); $('#txtQuestion').css('width', '94%'); $('.empty-search-alert').css('width', '49.5%'); if ($elvar1.is(":visible")) { $elvar1.show(); } } if ($elvar1.is(":visible")) { $elvar1.show(); $('#divHeaderQuestions').css('margin-top', '90px'); } }); $('.alert-success, .alert-danger, .alert-warning').click(function (e) { e.stopPropagation(); e.preventDefault(); if ($(this).is(":visible")) { // $(this).show(); } }); //mui $("#mui-overlay").click(function () { mui.overlay('off'); }); $('#caret_dpdown_show,.qa_comments').click(function (e) { e.stopPropagation(); }); // $('.qa_comments,.qa_comments [input:text]').click(function(e) { // e.preventDefault(); // }); $('.alert-close').click(function () { $('.alert-success').hide(); $('.alert-danger').hide(); $('.alert-warning').hide(); $('.search_bg_mask').hide(); $('.wrap_loader').hide(); }); $('.search_bg_mask').click(function () { $('.search_bg_mask').hide(); $('.nav-main-top').show(); $('.nav-right-top-focus').hide(); $('#txtQuestion').css('width', '76%'); $('.empty-search-alert').css('width', '37.5%'); $('#questionAlert').hide(); $('#txtQuestion').css('border-color', '#ccc'); $('.wrap_loader').hide(); }); var guestFlag = false; $('#chkGuest').click(function (e) { var ischecked = $(this).is(':checked'); if (ischecked) { guestFlag = true; } else { guestFlag = false; } e.stopPropagation(); }); var qflag = 0; $('#txtQuestion').click(function (e) { e.stopPropagation(); $('.search_bg_mask').css('height', $(document).height() - 40); $('.search_bg_mask').show(); $('.nav-main-top').hide(); $('.nav-right-top-focus').show(); // $('#txtQuestion').css('width', '94%'); $('.empty-search-alert').css('width', '49.5%'); // $('#txtQuestion').css('border-color', '#ccc'); $("#questionAlert").hide(); $('.wrap_loader').hide(); }); $('#txtHeaderDesp').click(function (e) { e.stopPropagation(); }); $('#txtQuestion').keyup(function () { $("#questionAlert").hide(); $('#txtQuestion').css('border-color', '#ccc'); $('.wrap_loader').hide(); var questionKey = $('#txtQuestion').val(); if (questionKey != '') { $('.search_bg_mask').css('height', $(document).height() - 40); $('.search_bg_mask').show(); $('.nav-main-top').hide(); $('.nav-right-top-focus').show(); // $('#txtQuestion').css('width', '94%'); $('.empty-search-alert').css('width', '49.5%'); $.ajax({ url: baseurl + "questions/ajax/ajaxGetQuestions.php", dataType: 'json', method: "POST", data: { 'questionKey': questionKey }, success: function (data) { if (data.flag == 0) { window.location.href = baseurl + 'questions/login.php'; } else if (data.flag == 1) { if (data.msg != '') { qflag = 1; $('#divHeaderQuestions').show(); $('#divHeaderQuestions').html(data.msg); } else { $('#divHeaderQuestions').hide(); $('#divHeaderQuestions').html(''); } } else if (data.flag == -1) { $('#divHeaderQuestions').hide(); $('#divHeaderQuestions').html(''); } } }); } else { $('#divHeaderQuestions').hide(); $('#divHeaderQuestions').html(''); $('.search_bg_mask').hide(); $('.nav-main-top').show(); $('.nav-right-top-focus').hide(); $('.top-search').css('width', '55%'); $('.empty-search-alert').css('width', '37.5%'); $('.wrap_loader').hide(); } }); $('#divHeaderQuestions').on('click', '.question_head', function () { var qid = $(this).data('qid'); var type = $(this).data('type'); if (qid != '' && type == 'Q') { window.location.href = homeurl + '/' + qid; } else if (qid != '' && type == 'C') { window.location.href = baseurl + 'questions/category/' + qid; } }); $('#question_index_id').on('click', '.zoomable', function () { var imgurl = $(this).attr('src'); if (imgurl != '') { $.ajax({ url: baseurl + "questions/ajax/ajaxGetZoomImage.php", method: "POST", data: { "imgurl": imgurl } }).done(function (returnData) { $('#imagepopupDivContent').html(returnData); $('#imagepopupDiv').show(); var imgwd = $('.zoom_image').width(); $('.imginndiv').parent().css('width', imgwd); }).error(function (returnData) {}); } }); //image Pop up close $('#imagepopupDiv').click(function (e) { var clickedOn = $(e.target); if (clickedOn.parents().andSelf().is('#imagepopupDivContent')) { } else { $('#imagepopupDivContent').html(''); $('#imagepopupDiv').hide(); } }); //image popup close button $('#imagepopupClose').click(function () { $('#imagepopupDivContent').html(''); $('#imagepopupDiv').hide(); }); // Question update /* $('.question_edit').on('click', function() { if (script_userid != '') { var data = $(this).attr('id'); $.ajax({ url: baseurl + "questions/ajax/ajaxEditQuestionEditor.php", method: "POST", data: { "qval1": data } }).done(function(returnData) { $('#myQuestionModal').modal('show'); $('.wrap_loader').hide(); $('#myQuestionModal .modal-body').html(returnData); }); } else { loginPopup(); } }); */ // Repharse Question $('#user_profile').on('click', '.ancRepharseQuestion', function () { if (script_userid != '') { var data = $(this).attr('id'); var mod = 2; $.ajax({ url: baseurl + "questions/ajax/ajaxEditQuestionEditor.php", method: "POST", data: { "qval1": data, "mod": mod } }).done(function (returnData) { $modalEl = $('#mui_popup_modal'); var $formEl = $(returnData); $modalEl.append($formEl); mui.overlay('on', $modalEl.get(0)); $('.wrap_loader').hide(); }); } else { loginPopup(); } }); // Ask Question $('#ask_question').on('click', function () { if (script_userid != '') { $.ajax({ url: baseurl + "questions/ajax/ajaxAddQuestionEditor.php", method: "POST", }).done(function (returnData) { $modalEl = $('#mui_popup_modal'); $modalEl.show(); var $formEl = $(returnData); $modalEl.append($formEl); mui.overlay('on', $modalEl.get(0)); $('.wrap_loader').hide(); }); } else { loginPopup(); } }); $('#user_profile,#question_index_id,#moderate_posts,#mui_main_modal').on('click', '.question_edit', function () { if (script_userid != '') { var data = $(this).data('qid'); $.ajax({ url: baseurl + "questions/ajax/ajaxEditQuestionEditor.php", method: "POST", data: { "qid": data } }).done(function (returnData) { $modalEl = $('#mui_popup_modal'); $modalEl.show(); var $formEl = $(returnData); $modalEl.append($formEl); mui.overlay('on', $modalEl.get(0)); $('.wrap_loader').hide(); }); } else { loginPopup(); } }); // answers popup /* $('.question_answer').on('click', function () { if (script_userid != '') { changeUrl('Questions', currentURL); var data = $(this).data('qid'); $('.wrap_loader').show(); var thisObj = $(this); $.ajax({ url: baseurl + "questions/ajax/ajaxAddAnswerEditor.php", method: "POST", data: { "qid": data } }).done(function (returnData) { if ($.trim(returnData) != '') { // $('#myQuestionModal').modal('show'); $modalEl = $('#mui_popup_modal'); var $formEl = $(returnData); $modalEl.append($formEl); // show modal mui.overlay('on', $modalEl.get(0)); // $('#myQuestionModal .modal-body').html(returnData); $('.wrap_loader').hide(); } else { $('.alert-warning span').html("You have already answered the question"); $('.alert-warning').show(); $('.wrap_loader').hide(); setTimeout(function () { $('.alert-warning').fadeOut(); $('.alert-warning span').html(''); }, 4000); } }); } else { loginPopup(); } }); */ $('#user_profile,#question_index_id,#mui_main_modal').on('click', '.question_answer', function () { mui.overlay('off'); if (script_userid != '') { var thisObj = $(this); changeUrl('Questions', currentURL); var data = $(this).data('qid'); $('.wrap_loader').show(); $.ajax({ url: baseurl + "questions/ajax/ajaxAddAnswerEditor.php", method: "POST", data: { "qid": data } }).done(function (returnData) { if ($.trim(returnData) != '') { $modalEl = $('#mui_popup_modal'); $modalEl.show(); var $formEl = $(returnData); $modalEl.append($formEl); mui.overlay('on', $modalEl.get(0)); $('.wrap_loader').hide(); } else { $('.alert-warning span').html("You have already answered the question"); $('.alert-warning').show(); setTimeout(function () { $('.alert-warning').fadeOut(); $('.alert-warning span').html(''); }, 4000); } }); } else { loginPopup(); } }); /* $('.answer_edit').on('click', function () { if (script_userid != '') { var qid = $(this).data('qid'); var aid = $(this).data('aid'); $.ajax({ url: baseurl + "questions/ajax/ajaxEditAnswerEditor.php", method: "POST", data: { "qid": qid, "aid": aid } }).done(function (returnData) { $modalEl = $('#mui_popup_modal'); $modalEl.show(); var $formEl = $(returnData); $modalEl.append($formEl); mui.overlay('on', $modalEl.get(0)); }); } else { loginPopup(); } }); */ $('#user_profile,#question_index_id,#mui_main_modal').on('click', '.answer_edit', function () { if (script_userid != '') { $('.wrap_loader').show(); var qid = $(this).data('qid'); var aid = $(this).data('aid'); $.ajax({ url: baseurl + "questions/ajax/ajaxEditAnswerEditor.php", method: "POST", data: { "qid": qid, "aid": aid } }).done(function (returnData) { $('.wrap_loader').hide(); $modalEl = $('#mui_popup_modal'); $modalEl.show(); var $formEl = $(returnData); $modalEl.append($formEl); mui.overlay('on', $modalEl.get(0)); }); } else { loginPopup(); } }); //Delete drafted answers $('#user_profile,#question_index_id,#mui_main_modal').on('click', '.ancDeleteAnswer', function () { var thisObj = $(this); var aid = $(this).data('aid'); var qid = $(this).data('qid'); if (confirm("Are you sure to delete this drafted answer!")) { $('.wrap_loader').show(); $.ajax({ url: baseurl + "questions/ajax/ajaxUserDeleteDraftedAnswer.php", dataType: 'json', method: "POST", data: { "aid": aid, "qid": qid }, success: function (returnData) { if (returnData.flag == 1) { $('.alert-success span').html(returnData.msg); $('.alert-success').show(); $('#answer_' + aid).remove(); } else { $('.alert-danger span').html(returnData.msg); $('.alert-danger').show(); } $('.wrap_loader').hide(); setTimeout(function () { $('.alert-success').fadeOut(); $('.alert-danger').fadeOut(); }, 8000); } }); } else { $('.alert-success').hide(); $('.alert-danger').hide(); } }); //Repharse Answer $('#user_profile,#question_index_id,#mui_main_modal').on('click', '.ancRepharseAnswer', function () { if (script_userid != '') { var qid = $(this).data('qid'); var aid = $(this).data('aid'); $.ajax({ url: baseurl + "questions/ajax/ajaxEditAnswerEditor.php", method: "POST", data: { "qid": qid, "aid": aid, "mod": 2 } }).done(function (returnData) { $modalEl = $('#mui_popup_modal'); $modalEl.show(); var $formEl = $(returnData); $modalEl.append($formEl); mui.overlay('on', $modalEl.get(0)); }).error(function (returnData) { }); } else { loginPopup(); } }); // Edit Drafted Post $('#user_profile,#question_index_id,#moderate_posts,#mui_main_modal').on('click', '.ancEditPost', function () { var mod = 1; var thisObj = $(this); var pid = $(this).data('pid'); var md = $(this).data('mod'); if (md != 0) { mod = md; } $.ajax({ url: baseurl + "questions/ajax/ajaxPostEditor.php", method: "POST", data: { "pid": pid, 'mod': mod }, success: function (returnData) { if (returnData != "") { $modalEl = $('#mui_popup_modal'); $modalEl.show(); var $formEl = $(returnData); $modalEl.append($formEl); mui.overlay('on', $modalEl.get(0)); } } }); }); //Delete Drafted Post $('#user_profile,#question_index_id,#mui_main_modal').on('click', '.ancDeletePost', function () { var thisObj = $(this); var pid = $(this).data('pid'); if (confirm("Are you sure to delete this drafted post!")) { $('.wrap_loader').show(); $.ajax({ url: baseurl + "questions/ajax/ajaxUserDeleteDraftedPost.php", dataType: 'json', method: "POST", data: { "pid": pid }, success: function (returnData) { if (returnData.flag == 1) { $('.alert-success span').html(returnData.msg); $('.alert-success').show(); $('#mdiv_' + pid).remove(); } else { $('.alert-danger span').html(returnData.msg); $('.alert-danger').show(); } $('.wrap_loader').hide(); setTimeout(function () { $('.alert-success').fadeOut(); $('.alert-danger').fadeOut(); }, 8000); } }); } else { $('.alert-success').hide(); $('.alert-danger').hide(); } }); /* $('.question_category').on('click', function () { if (script_userid != '') { var qid = $(this).data('qid'); $('.wrap_loader').show(); $.ajax({ url: baseurl + "questions/ajax/ajaxCategoryEditor.php", method: "POST", data: { "qid": qid } }).done(function (returnData) { $modalEl = $('#mui_popup_modal'); $modalEl.show(); var $formEl = $(returnData); $modalEl.append($formEl); mui.overlay('on', $modalEl.get(0)); $('.wrap_loader').hide(); }); } else { loginPopup(); } }); */ $('#user_profile,#question_index_id,#mui_main_modal').on('click', '.question_category', function () { if (script_userid != '') { var qid = $(this).data('qid'); $('.wrap_loader').show(); $.ajax({ url: baseurl + "questions/ajax/ajaxCategoryEditor.php", method: "POST", data: { "qid": qid } }).done(function (returnData) { $modalEl = $('#mui_popup_modal'); $modalEl.show(); var $formEl = $(returnData); $modalEl.append($formEl); mui.overlay('on', $modalEl.get(0)); $('.wrap_loader').hide(); }); } else { loginPopup(); } }); $('#user_profile,#question_index_id,#mui_main_modal').on('click', '.ancReportAnswer', function () { if (script_userid != '') { var qid = $(this).data('qid'); var aid = $(this).data('aid'); $.ajax({ url: baseurl + "questions/ajax/ajaxReportEditor.php", method: "POST", data: { "qid": qid, "aid": aid } }).done(function (returnData) { if ($.trim(returnData) != '') { $modalEl = $('#mui_popup_modal'); $modalEl.show(); var $formEl = $(returnData); $modalEl.append($formEl); mui.overlay('on', $modalEl.get(0)); } else { $('.search_bg_mask').show(); $('.alert-danger span').html('You have already report this answer!'); $('.alert-danger').show(); setTimeout(function () { $('.alert-danger').hide(); $('.search_bg_mask').hide(); }, 3000); } }); } else { loginPopup(); } }); $('#user_profile,#question_index_id,#mui_main_modal').on('click', '.ancQuestionUpvote', function () { var thisObj = $(this); var data = $(this).attr('id'); question_upvote(thisObj, data); }); function question_upvote(thisObj, data) { if (script_userid != '') { $.ajax({ url: baseurl + "questions/ajax/ajaxQuestionUpvote.php", dataType: 'json', method: "POST", data: { "qval1": data }, success: function (returnData) { if (returnData.flag == 0) { window.location.href = baseurl + 'questions/login.php'; } else if (returnData.flag == 1) { thisObj.find('span').html(returnData.upcount); thisObj.next().find('span').html(returnData.downcount); } else { $('.wrap_loader').show(); $('.search_bg_mask').show(); $('.alert-danger span').html(returnData.msg); $('.alert-danger').show(); $('.wrap_loader').hide(); $('.alert-danger').hide(); $('.search_bg_mask').hide(); } } }); } else { loginPopup(); } } $('#user_profile,#question_index_id,#mui_main_modal').on('click', '.ancQuestionDownvote', function () { var thisObj = $(this); var data = $(this).attr('id'); question_downvote(thisObj, data); }); function question_downvote(thisObj, data) { if (script_userid != '') { $.ajax({ url: baseurl + "questions/ajax/ajaxQuestionDownvote.php", dataType: 'json', method: "POST", data: { "qval1": data }, success: function (returnData) { if (returnData.flag == 0) { window.location.href = baseurl + 'questions/login.php'; } else if (returnData.flag == 1) { thisObj.find('span').html(returnData.downcount); thisObj.prev().find('span').html(returnData.upcount); } else { $('.wrap_loader').show(); $('.search_bg_mask').show(); $('.alert-danger span').html(returnData.msg); $('.alert-danger').show(); $('.wrap_loader').hide(); $('.alert-danger').hide(); $('.search_bg_mask').hide(); } } }); } else { loginPopup(); } } $('#user_profile,#question_index_id,#divTopWriters,#profile_follow,#inner_header,#mui_main_modal,#users_list').on('click', '.user_follow', function () { var thisObj = $(this); var uid = $(this).data('uid'); var uname = $(this).data('name'); follow_user(thisObj, uid, uname); }); function follow_user(thisObj, uid, uname = '') { if (script_userid != '') { $.ajax({ url: baseurl + "questions/ajax/ajaxUpdateUserFollower.php", dataType: 'json', method: "POST", data: { "uid": uid }, success: function (returnData) { if (returnData.flag == 0) { window.location.href = baseurl + 'questions/login.php'; } else if (returnData.flag == 1) { thisObj.attr('title', 'Unfollow ' + uname); thisObj.find('svg').removeClass('fa-user-plus').addClass('fa-user-times'); thisObj.find('svg').addClass('qa_follow_active'); thisObj.find('b').html(' Unfollow'); } else if (returnData.flag == 2) { thisObj.attr('title', 'Follow ' + uname); thisObj.find('svg').removeClass('fa-user-times').addClass('fa-user-plus'); thisObj.find('svg').removeClass('qa_follow_active'); thisObj.find('b').html(' Follow'); } else { $('.wrap_loader').show(); $('.search_bg_mask').show(); $('.alert-danger span').html(returnData.msg); $('.alert-danger').show(); $('.wrap_loader').hide(); $('.alert-danger').hide(); $('.search_bg_mask').hide(); } } }); } else { loginPopup(); } } // follow category event $('#user_profile,#question_index_id,#category_list,#category_header,#feed_list').on('click', '.category_follow', function () { var thisObj = $(this); var cid = $(this).data('cid'); var cflag = $(this).data('cflag'); follow_category(thisObj, cid, cflag); }); function follow_category(thisObj, cid, cflag) { if (script_userid != '') { $.ajax({ url: baseurl + "questions/ajax/ajaxUpdateCategoryFollower.php", dataType: 'json', method: "POST", data: { "cid": cid, "cflag": cflag }, success: function (data) { if (data.flag == 0) { window.location.href = baseurl + 'questions/login.php'; } else if (data.flag == 1) { if (cflag == 'A') { var str = "
  •   " + data.json_data.name + "
  • "; $('#user_feeds').append(str); $("#feeds_box").slideToggle("slow"); } else if (cflag == 'F') { thisObj.find('b').html('Unfollow'); start_from = 0; } } else if (data.flag == 2) { if (cflag == 'R') { thisObj.remove(); $('#user_feeds').find('[id=liCategory' + cid + ']').remove(); $("#feeds_box").slideToggle("slow"); } else if (cflag == 'F') { thisObj.find('b').html('Follow'); start_from = 0; } } else { $('.wrap_loader').show(); $('.search_bg_mask').show(); $('.alert-danger span').html(data.msg); $('.alert-danger').show(); $('.wrap_loader').hide(); $('.alert-danger').hide(); $('.search_bg_mask').hide(); } } }); } else { loginPopup(); } } // follow question event $('#question_index_id,#mui_main_modal,#user_profile,#moderate_posts').on('click', '.question_follow', function (event) { var thisObj = $(this); var data = $(this).data('qid'); event.stopPropagation(); follow_question(thisObj, data); }); function follow_question(thisObj, data) { if (script_userid != '') { $.ajax({ url: baseurl + "questions/ajax/ajaxUpdateQuestionFollower.php", dataType: 'json', method: "POST", data: { "qid": data }, success: function (returnData) { if (returnData.flag == 0) { window.location.href = baseurl + 'questions/login.php'; } else if (returnData.flag == 1) { thisObj.attr('title', returnData.followcount + ' Follower, Unfollow Question'); thisObj.find('svg').addClass('fa fa-minus'); thisObj.find('svg').removeClass('fa fa-plus'); } else if (returnData.flag == 2) { thisObj.attr('title', returnData.followcount + ' Follower, Follow Question'); thisObj.find('svg').addClass('fa fa-plus'); thisObj.find('svg').removeClass('fa fa-minus'); } else { $('.wrap_loader').show(); $('.search_bg_mask').show(); $('.alert-danger span').html(returnData.msg); $('.alert-danger').show(); $('.wrap_loader').hide(); $('.alert-danger').hide(); $('.search_bg_mask').hide(); } }, error: function (response) { } }); } else { loginPopup(); } } //Vote Count $('#user_profile,#question_index_id,#mui_main_modal,#moderate_posts').on('click', '.qa_vote', function () { var thisObj = $(this); var entid = $(this).data('entid'); var evote = $(this).data('evote'); var entity = $(this).data('entity'); if (script_userid != '') { $.ajax({ url: baseurl + "questions/ajax/ajaxVote.php", dataType: 'json', method: "POST", data: { "entid": entid, "evote": evote, "entity": entity }, success: function (data) { if (data.flag == 0) { window.location.href = baseurl + 'questions/login.php'; } else if (data.flag == 1) { if (data.voteflag == 'L') { thisObj.find('b').show(); thisObj.find('b').html(data.upcount); if (data.upcount > 0) { thisObj.addClass('vote_active'); } else { thisObj.removeClass('vote_active'); } thisObj.next().find('b').html(data.downcount); thisObj.next().removeClass('vote_active'); } else if (data.voteflag == 'D') { thisObj.find('b').show(); thisObj.find('b').html(data.downcount); if (data.downcount > 0) { thisObj.addClass('vote_active'); } else { thisObj.removeClass('vote_active'); } thisObj.prev().find('b').html(data.upcount); thisObj.prev().removeClass('vote_active'); } } else { $('.wrap_loader').show(); $('.search_bg_mask').show(); $('.alert-danger span').html(data.msg); $('.alert-danger').show(); setTimeout(function () { $('.wrap_loader').hide(); $('.alert-danger').hide(); $('.search_bg_mask').hide(); }, 5000); } }, error: function (response) { } }); } else { loginPopup(); } }); //Comments $('#user_profile,#question_index_id,#mui_main_modal,#moderate_posts').on('click', '.qa_comments_view', function () { var entid = $(this).data('entid'); var entity = $(this).data('entity'); var divId; if (entity == 'AM' || entity == 'PM') { divId = $('#comments_' + entid + '_' + entity); } else { divId = $('#comments_' + entid); } if ((divId).is(':visible')) { divId.css('display', 'none'); } else { start_from = 0; divId.find('.load_more_comments').css('display', 'block'); getComments(start_from, 5, entid, entity); } }); //Load More Question Comments var start_from = 0; var v = false; var lastFlag = false; $('#user_profile,#question_index_id,#mui_main_modal,#moderate_posts').on('click', '.load_more_comments', function () { var entity_id = $(this).data('entityid'); var entity_type = $(this).data('entity'); $('.wrap_loader').css('height', $(document).height() - 40); $('.search_bg_mask').css('height', $(document).height() - 40); if (v) { start_from = start_from + 5; v = false; } else { start_from = start_from + 5; } if (lastFlag == false) { getComments(start_from, 5, entity_id, entity_type); } }); //Get Comments function getComments(start_from, limit, entity_id, entity_type) { $.ajax({ url: baseurl + "questions/ajax/ajaxGetComments.php", method: "POST", data: { 'start_from': start_from, "limit_val": limit, "entity_id": entity_id, "entity_type": entity_type } }).done(function (returnData) { if ($.trim(returnData) != '') { if (start_from == 0) { if (entity_type == 'AM' || entity_type == 'PM') { $('#comments_list_' + entity_id + '_' + entity_type).html(returnData); $('#comments_' + entity_id + '_' + entity_type).show(); } else { $('#comments_list_' + entity_id).html(returnData); $('#comments_' + entity_id).show(); } } else { if (entity_type == 'AM' || entity_type == 'PM') { $('#comments_list_' + entity_id + '_' + entity_type).append(returnData); $('#comments_' + entity_id + '_' + entity_type).show(); } else { $('#comments_list_' + entity_id).append(returnData); $('#comments_' + entity_id).show(); } } } else { if (entity_type == 'AM' || entity_type == 'PM') { $("#comments_" + entity_id + '_' + entity_type).find('.load_more_comments').css('display', 'none'); } else { $("#comments_" + entity_id).find('.load_more_comments').css('display', 'none'); } } }); } //Add Comments $('#user_profile,#question_index_id,#moderate_posts,#mui_main_modal,.qa_comments').on('click', '.post_comment', function () { //$('.post_comment').click( function () { if (script_userid != '') { var entity_id = $(this).data('entity'); var entity_type = $(this).data('etype'); var comment = $('#txtComment_' + entity_id).val(); if (comment == '') { $('#txtComment_' + entity_id).css('border-color', '#f00'); return false; } $('#txtComment_' + entity_id).css('border', '#d6d6d6'); comment = $.trim(comment); $.ajax({ url: baseurl + "questions/ajax/ajaxAddComment.php", method: "POST", dataType: "json", data: { "entity_id": entity_id, "entity_type": entity_type, "comment": comment } }).done(function (returnData) { if (returnData.flag == 0) { window.location.href = baseurl + 'questions/login.php'; } else if (returnData.flag == 1) { var str = ''; str += '
    '; str += ''; str += '' + returnData.json_data.profile_user_name + ', ' + returnData.json_data.post_time + ''; str += '
    '; str += ' ' + returnData.json_data.upvote_count + ''; str += ' ' + returnData.json_data.downvote_count + ''; str += '
    '; str += '

    ' + returnData.json_data.comment + '

    '; str += '
    '; $('#comment_na' + entity_id).prepend(str); if (entity_type == 'AM' || entity_type == 'PM') { $('#cmt_count_' + entity_id + '_' + entity_type).html(returnData.json_data.comment_count); var res = entity_type.replace('M', ''); $('#cmt_count_' + entity_id + '_' + res).html(returnData.json_data.comment_count); } else { $('#cmt_count_' + entity_id + '_' + entity_type).html(returnData.json_data.comment_count); } $('#txtComment_' + entity_id).val(''); } else { $('.search_bg_mask').show(); $('.alert-danger span').html(returnData.msg); $('.alert-danger').show(); setTimeout(function () { $('.wrap_loader').hide(); $('.alert-danger').hide(); $('.search_bg_mask').hide(); }, 4000); } }); } else { loginPopup(); } }); //Comments Vote $('#user_profile,#question_index_id,#mui_main_modal,#moderate_posts,.qa_comments').on('click', '.comment_vote', function () { var thisObj = $(this); var comment_id = $(this).data('commentid'); var comment_vote_flag = $(this).data('vote'); if (script_userid != '') { $.ajax({ url: baseurl + "questions/ajax/ajaxCommentVote.php", dataType: 'json', method: "POST", data: { "comment_id": comment_id, "comment_vote_flag": comment_vote_flag }, success: function (data) { if (data.flag == 0) { window.location.href = baseurl + 'questions/login.php'; } else if (data.flag == 1) { if (data.cmtFlag == 'L') { thisObj.find('span').html(data.upcount); thisObj.next().find('span').html(data.downcount); } else if (data.cmtFlag == 'D') { thisObj.find('span').html(data.downcount); thisObj.prev().find('span').html(data.upcount); } } else { $('.search_bg_mask').show(); $('.alert-danger span').html(data.msg); $('.alert-danger').show(); setTimeout(function () { $('.wrap_loader').hide(); $('.alert-danger').hide(); $('.search_bg_mask').hide(); }, 5000); } } }); } else { loginPopup(); } }); var feedflag = 0; $('#feedbox_id').click(function (e) { e.stopPropagation(); $('#btnFeedBox').show(); }); $("#btnFeedBox").on('click', function (e) { e.stopPropagation(); if (feedflag) { $('#feedbox_id').html(''); $('#feedbox_id').hide(); feedflag = 0; return false; } $.ajax({ url: baseurl + 'questions/ajax/ajaxGetFeedbackBox.php', beforeSend: function () { $('#feedbox_id').show(); $('#feedbox_id').html('loader'); }, success: function (returnData) { if (returnData != '') { $('#feedbox_id').html(returnData); $('#feedbox_id').show(); feedflag = 1; } else { feedflag = 0; $('#feedbox_id').html(''); $('#feedbox_id').hide(); } } }); }); //feedback button // modal answer $('#user_profile,#question_index_id').on('click', '.qa_answer_modal', function () { var qid = $(this).data('qtitle'); var uid = $(this).data('utitle'); answerModal(qid, uid); }); //modal post $('#user_profile,#question_index_id,#moderate_posts').on('click', '.qa_post_modal', function () { var pid = $(this).data('ptitle'); postModal(pid); }); var currentURL = window.location.href; var changeFlag = false; function answerModal(qid, uid) { $.ajax({ url: baseurl + "questions/ajax/ajaxGetModalAnswer.php", method: "POST", data: { "qid": qid, "uid": uid } }).done(function (returnData) { $modalEl = $('#mui_popup_modal'); $modalEl.show(); var $formEl = $(returnData); $modalEl.append($formEl); mui.overlay('on', $modalEl.get(0)); $('body').addClass('noscroll'); var url = baseurl + 'questions/' + qid + '/answer/' + uid; changeUrl('Questions', url); }); } function postModal(pid) { $.ajax({ url: baseurl + "questions/ajax/ajaxGetModalPost.php", method: "POST", data: { "pid": pid } }).done(function (returnData) { $modalEl = $('#mui_popup_modal'); $modalEl.show(); var $formEl = $(returnData); $modalEl.append($formEl); mui.overlay('on', $modalEl.get(0)); $('body').addClass('noscroll'); var url = baseurl + 'questions/post/' + pid; changeUrl('Questions', url); }); } function changeUrl(title, curl) { if (typeof (history.pushState) != "undefined") { var obj = { Title: title, Url: curl }; currentURL = window.location.href; changeFlag = true; history.pushState(obj, obj.Title, obj.Url); } else { alert("Browser does not support HTML5."); } } function checkQuestionText() { if (localStorage.question && localStorage.question != '') { var question = localStorage.question; $('#txtQuestion').val(question); $("#btnSaveQuestion").trigger('click'); } } checkQuestionText(); $('.wrap_loader').css('height', $(document).height() - 30); $('.search_bg_mask').css('height', $(document).height() - 30); $('.dropdown-toggle').click(function () { determineDropDirection(); }); $('#user_profile,#question_index_id,#mui_main_modal').on('click', '.dropdown-toggle', function () { determineDropDirection(); }); function determineDropDirection() { $(".dropdown-menu").each(function () { // Invisibly expand the dropdown menu so its true height can be calculated $(this).css({ visibility: "hidden", display: "block" }); // Necessary to remove class each time so we don't unwantedly use dropup's offset top $(this).parent().removeClass("dropup"); $(this).addClass('arrow_boxx'); $(this).addClass('dropdown_more'); $(this).removeClass('arrow_btm'); if ($(this).prev().is("button")) { $(this).removeClass('arrow_top'); } if ($(this).parent().is("#liNotification")) { $(this).removeClass('dropdown_more'); } // Determine whether bottom of menu will be below window at current scroll position if ($(this).offset().top + $(this).outerHeight() > $(window).innerHeight() + $(window).scrollTop()) { $(this).parent().addClass("dropup"); $(this).removeClass('dropdown_more'); $(this).removeClass('arrow_boxx'); $(this).addClass('arrow_btm'); if ($(this).prev().is("button")) { $(this).addClass('arrow_top'); } } // Return dropdown menu to fully hidden state $(this).removeAttr("style"); }); } $.ajaxSetup({ cache: true }); $.getScript('//connect.facebook.net/en_US/all.js', function () { FB.init({ appId: '216851252183948', version: 'v2.10' }); }); $("#question_index_id,#user_profile,#mui_main_modal").on("click", ".btnFBShare", function () { if (script_userid != '') { var shareId = $(this).data('shareid'); var qtitle = $("#" + shareId).data('qtitle'); var utitle = $("#" + shareId).data('utitle'); var qshare = $(this).data('qshare'); var question = $("#" + qshare).find("h1 a").html(); question = $.trim(question); FB.ui({ method: 'feed', display: 'popup', link: homeurl + '/' + qtitle, name: question, description: 'content', redirect_uri: baseurl + 'questions/index.php' }, function (response) { if (response && response.post_id) { $('.alert-success span').html("Shared to Facebook"); $('.alert-success').show(); $('.wrap_loader').hide(); $('.search_bg_mask').hide(); setTimeout(function () { $('.alert-success').hide(); }, 4000); } }); } else { guestFlag = false; loginPopup(); } }); //FB question share $("#question_index_id,#user_profile,#mui_main_modal").on("click", ".btnFBQShare", function () { if (script_userid != '') { var shareId = $(this).data('shareid'); var qtitle = $("#" + shareId).data('qtitle'); var qshare = $(this).data('qshare'); var question = $("#" + qshare).find("h1 a").html(); question = $.trim(question); FB.ui({ method: 'feed', display: 'popup', link: homeurl + '/' + qtitle, name: question, description: 'content', redirect_uri: baseurl + 'questions/index.php' }, function (response) { if (response && response.post_id) { $('.alert-success span').html("Shared to Facebook"); $('.alert-success').show(); $('.wrap_loader').hide(); $('.search_bg_mask').hide(); setTimeout(function () { $('.alert-success').hide(); }, 4000); } }); } else { guestFlag = false; loginPopup(); } }); //FB post share $("#question_index_id,#user_profile,#mui_main_modal,#moderate_posts").on("click", ".btnFBSharePost", function () { if (script_userid != '') { var qtitle = $(this).data('qtitle'); FB.ui({ method: 'feed', display: 'popup', link: baseurl + 'questions/post_details.php?postId=' + qtitle, name: 'qries', description: 'content', redirect_uri: baseurl + 'questions/index.php' }, function (response) { if (response && response.post_id) { $('.alert-success span').html("Shared to Facebook"); $('.alert-success').show(); $('.wrap_loader').hide(); $('.search_bg_mask').hide(); setTimeout(function () { $('.alert-success').hide(); }, 4000); } }); } else { guestFlag = false; loginPopup(); } }); $("#question_index_id,#user_profile,#mui_main_modal").on("click", ".btnTwitterShare", function (e) { if (script_userid != '') { var shareId = $(this).data('shareid'); var qtitle = $("#" + shareId).data('qtitle'); var utitle = $("#" + shareId).data('utitle'); var content = $("#" + shareId).data('sharecontent'); var img = $("#" + shareId).data('shareimg'); var qshare = $(this).data('qshare'); var question = $("#" + qshare).find("h1 a").html(); question = $.trim(question); var via = "tutorialspoint"; var shareUrl = homeurl + '/' + qtitle; var link = "https://twitter.com/share?url=" + shareUrl + "&via=" + via + "&related=" + via + "&hashtags=tutorialspoint&text=" + question; $(this).attr("href", link); $(this).customerPopup(e); $(this).attr("href", "javascript:void(0);"); } else { guestFlag = false; loginPopup(); } }); //Twitter question share $("#question_index_id,#user_profile,#mui_main_modal").on("click", ".btnTwitterQShare", function (e) { if (script_userid != '') { var shareId = $(this).data('shareid'); var qtitle = $("#" + shareId).data('qtitle'); var utitle = $("#" + shareId).data('utitle'); var content = $("#" + shareId).data('sharecontent'); var img = $("#" + shareId).data('shareimg'); var qshare = $(this).data('qshare'); var question = $("#" + qshare).find("h1 a").html(); question = $.trim(question); var via = "tutorialspoint"; var shareUrl = homeurl + '/' + qtitle; var link = "https://twitter.com/share?url=" + shareUrl + "&via=" + via + "&related=" + via + "&hashtags=tutorialspoint&text=" + question; $(this).attr("href", link); $(this).customerPopup(e); $(this).attr("href", "javascript:void(0);"); } else { guestFlag = false; loginPopup(); } }); //Twitter post share $("#question_index_id,#user_profile,#mui_main_modal,#moderate_posts").on("click", ".btnTwitterSharePost", function (e) { if (script_userid != '') { var qtitle = $(this).data('qtitle'); var question = qtitle.replace('-', ' '); var via = "qries_tp"; var shareUrl = baseurl + "questions/post_details.php?postId=" + qtitle; var link = "https://twitter.com/share?url=" + shareUrl + "&via=" + via + "&related=" + via + "&hashtags=Qries_tp&text=" + question; $(this).attr("href", link); $(this).customerPopup(e); $(this).attr("href", "javascript:void(0);"); } else { guestFlag = false; loginPopup(); } }); }); // end document ready function entityView(entity_id, entity_type) { if (entity_id != '') { $.ajax({ url: baseurl + "questions/ajax/ajaxUpdateViews.php", method: "POST", data: {'entity_id': entity_id, 'entity_type': entity_type} }).done(function (returnData) { }); } } function getViewCount(entity_id,entity_type) { if (entity_id != '') { $.ajax({ url: baseurl + "questions/ajax/ajaxSetUrlCount.php", method: "POST", dataType:'json', data: {'entity_id': entity_id, 'entity_type': entity_type} }).done(function (returnData) { $('#question_view_count').html(returnData.views_count); }); } } // footer // When the user clicks on the button, scroll to the top of the document function topFunction() { document.body.scrollTop = 0; // For Chrome, Safari and Opera document.documentElement.scrollTop = 0; // For IE and Firefox } var body = document.body, overlay = document.querySelector('.overlay'), overlayBtts = document.querySelectorAll('button[class$="overlay"]'); [].forEach.call(overlayBtts, function (btt) { btt.addEventListener('click', function () { /* Detect the button class name */ var overlayOpen = this.className === 'open-overlay'; /* Toggle the aria-hidden state on the overlay and the no-scroll class on the body */ overlay.setAttribute('aria-hidden', !overlayOpen); body.classList.toggle('noscroll', overlayOpen); /* On some mobile browser when the overlay was previously opened and scrolled, if you open it again it doesn't reset its scrollTop property */ overlay.scrollTop = 0; }, false); }); $(document).ready(function ($) { $('.customer.share').on("click", function (e) { // $(this).customerPopup(e); }); $("#btnemail").on('click', function(e) { var inputs = { "email": $('#textemail').val() }; $("#newsresponse").css({"display":"block"}); if( !isEmail( $('#textemail').val() ) ){ $("#newsresponse").html("Please enter a valid email id"); $("#newsresponse").fadeOut(5000, function(){ $("#newsresponse").html(""); $("#textemail").val(""); }); return false; } var url =baseurl+ "subs-news.php"; $.ajax({ type: "POST", url: url, data: inputs, dataType: 'json', beforeSend: function( ) { $(".wrapLoader").css({"display":"block"}); }, success: function(data) { $(".wrapLoader").css({"display":"none"}); if( data.ret > 0 ){ $("#newsresponse").html("You already have a subscription"); }else{ $("#newsresponse").html("Thanks for your subscription"); } $("#newsresponse").fadeOut(5000, function(){ $("#newsresponse").html(""); $("#textemail").val(""); }); } }); }); $("form button.btn").on('click', function() { if( $(this).find('a').attr('href') ) { window.location.href = $(this).find('a').attr('href'); } }); }); (function ($) { /** * jQuery function to prevent default anchor event and take the href * and the title to make a share popup * * @param {[object]} e [Mouse event] * @param {[integer]} intWidth [Popup width defalut 500] * @param {[integer]} intHeight [Popup height defalut 400] * @param {[boolean]} blnResize [Is popup resizeabel default true] */ $.fn.customerPopup = function (e, intWidth, intHeight, blnResize) { // Prevent default anchor event e.preventDefault(); // Set values for window intWidth = intWidth || '500'; intHeight = intHeight || '400'; strResize = (blnResize ? 'yes' : 'no'); // Set title and open popup with focus on it var strTitle = ((typeof this.attr('title') !== 'undefined') ? this.attr('title') : 'Social Share'), strParam = 'width=' + intWidth + ',height=' + intHeight + ',resizable=' + strResize, objWindow = window.open(this.attr('href'), strTitle, strParam).focus(); } /* ================================================== */ function isEmail(email) { var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/; return regex.test(email); } $(document).ready(function ($) { $('.customer.share').on("click", function (e) { // $(this).customerPopup(e); }); $("#btnemail").on('click', function(e) { var inputs = { "email": $('#textemail').val() }; $("#newsresponse").css({"display":"block"}); if( !isEmail( $('#textemail').val() ) ){ $("#newsresponse").html("Please enter a valid email id"); $("#newsresponse").fadeOut(5000, function(){ $("#newsresponse").html(""); $("#textemail").val(""); }); return false; } var url =baseurl+ "subs-news.php"; $.ajax({ type: "POST", url: url, data: inputs, dataType: 'json', beforeSend: function( ) { $(".wrapLoader").css({"display":"block"}); }, success: function(data) { $(".wrapLoader").css({"display":"none"}); if( data.ret > 0 ){ $("#newsresponse").html("You already have a subscription"); }else{ $("#newsresponse").html("Thanks for your subscription"); } $("#newsresponse").fadeOut(5000, function(){ $("#newsresponse").html(""); $("#textemail").val(""); }); } }); }); $("form button.btn").on('click', function() { if( $(this).find('a').attr('href') ) { window.location.href = $(this).find('a').attr('href'); } }); }); }(jQuery));