-
-
Save rajatanotheraccount/3cec6565718058107681c3ac207504bf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(".social_link").on('click', function (event) { | |
var isMobile = window.matchMedia("only screen and (max-width: 767px)"); | |
if ($('.search-field-effect').is(":visible")) { | |
checkEventOutsidePlusSearchMenu(); | |
if (!isMobile.matches) { | |
$("div.social_menu").toggleClass('hide_social'); | |
} | |
} | |
else { | |
$("div.social_menu").toggleClass('hide_social'); | |
} | |
}); | |
$(window).click(function (event) { | |
checkEventOutsideShare(); | |
checkEventOutsideSearch(); | |
}); | |
$(".search-form-transition").on('click', function (event) { | |
var current_search_field_right = $(".new-search-icon").position().left; | |
var body_width = $(".new-search-icon").offsetParent().width(); | |
var current_left = current_search_field_right / body_width; | |
var left_calculate_percent = ((current_left * 100)) + "%"; | |
left_pixel_for_grey_search = left_calculate_percent; | |
var top_pixel = "21px"; | |
var left_pixel = "86%"; | |
var search_width = "75%"; | |
var isMobile = window.matchMedia("only screen and (max-width: 767px)"); | |
if (isMobile.matches) { | |
top_pixel = "21px"; | |
left_pixel = "86%"; | |
search_width = "95%"; | |
if ($(".search-lc").length > 0) { | |
search_width = "115%"; | |
left_pixel = "106%" | |
} | |
var current_search_field_right = 0; | |
var body_width = $(".search-field").offsetParent().width(); | |
var current_left = current_search_field_right / body_width; | |
var left_calculate_percent = ((current_left * 100) - 10 + parseInt(search_width.substr(0, search_width.length - 1))) + "%"; | |
left_pixel = left_calculate_percent; | |
if ($(".search-lc").length > 0) { | |
var left_calculate_percent = ((current_left * 100) - (search_width.substr(0, search_width.length - 1) / 10) + parseInt(search_width.substr(0, search_width.length - 1))) + "%"; | |
left_pixel = left_calculate_percent; | |
} | |
} | |
else { | |
top_pixel = "15px"; | |
left_pixel = "75%"; | |
search_width = "75%"; | |
if ($(window).width() == 768 && $(window).height() == 1024) { | |
search_width = "69%"; //Ipad Portrait View | |
} | |
if ($(window).width() == 1024 && $(window).height() == 768) { | |
search_width = "69%"; //Ipad Portrait View | |
} | |
if ($(window).width() >= 960 && $(window).width() <= 1024) { | |
search_width = "69%";//Ipad Portrait View | |
} | |
if ($(".search-lc").length > 0) { | |
left_pixel = "78%"; | |
} | |
if (search_width === "75%") | |
left_pixel = search_width; | |
else | |
left_pixel = parseInt(search_width.substr(0, search_width.length - 1)) - 7 + "%"; | |
//Problem is there between 768px to 1024px we need to do -1 in left_pixel for Articles | |
if ($(window).width() >= 768 && $(window).width() <= 1024 && $(".search-lc").length === 0) { | |
left_pixel = parseInt(search_width.substr(0, search_width.length - 1)) - 7 + "%"; | |
} | |
if (window.matchMedia("(orientation: portrait)").matches && search_width === "69%" && $(window).width() == 768 && $(window).height() == 1024) { | |
left_pixel = search_width; | |
} | |
} | |
$(".search-icon-full").show(); | |
$(".new-search-icon").hide(); | |
$(".search_text_float").hide(150); | |
$(".search-field").css({"visibility": "visible", "transition": "none"}); | |
$(".search-field").animate({ | |
"width": search_width, | |
"visibility": "visible" | |
}, { | |
queue: false | |
}); | |
$(".search-icon-full").animate({ | |
left: left_pixel, | |
position: 'absolute', | |
height: '17px', | |
width: '17px' | |
}, { | |
queue: false, | |
complete: function () { | |
$(".search-field").toggleClass("search-field-effect"); | |
$(".search-field").focus(); | |
$(".new-search-icon").addClass("new-moving-icon"); | |
if (isMobile.matches) { | |
} | |
else { | |
$(".new-search-icon").animate({"left": "90%"}); | |
} | |
} | |
} | |
); | |
if (isMobile.matches) { | |
$(".social_link").children("span").css({"visibility": "hidden"}); | |
$(".social_link").children("span").css({"display": "none"}); | |
$(".social_wrapper").animate( | |
{"left": "80%"}, | |
{queue: false} | |
); | |
} | |
}); | |
function checkEventOutsideSearch() { | |
if (!$(event.target).closest('.search-bar').length) { | |
checkEventOutsidePlusSearchMenu(); | |
} | |
} | |
function checkEventOutsidePlusSearchMenu() { | |
if ($('.search-field-effect').is(":visible")) { | |
$(".search-field").toggleClass("search-field-effect", 200).promise().done(function () { | |
$(".search-field").animate({"width": "0px"}, { | |
duration: 200, complete: function () { | |
$(".search-field").css({"visibility": "hidden"}); | |
} | |
}); | |
$(".search-icon-full").hide(); | |
$(".new-search-icon").show(); | |
var top_pixel = "5px"; | |
var left_pixel = "87%"; | |
var isMobile = window.matchMedia("only screen and (max-width: 767px)"); | |
if (isMobile.matches) { | |
top_pixel = "50px"; | |
left_pixel = "2%"; | |
} | |
else { | |
top_pixel = "5px"; | |
left_pixel = "63%"; | |
left_pixel = left_pixel_for_grey_search; | |
} | |
if (isMobile.matches) { | |
$(".social_wrapper").animate( | |
{"left": "30%"}, | |
{queue: false}); | |
} | |
$(".new-search-icon").animate({ | |
left: left_pixel, | |
height: '17px', | |
width: '17px' | |
}, { | |
duration: 300, | |
complete: function () { | |
$(".search_text_float").css({"margin-left": "21px"}); | |
$(".search_text_float").fadeIn(70, function () { | |
if (isMobile.matches) { | |
$(".search-icon-full").animate({"left": "0%"}); | |
$(".social_link").children("span").css({"visibility": "visible"}); | |
$(".social_link").children("span").css({"display": "inline"}); | |
} | |
else { | |
$(".search-icon-full").animate({"left": "61%"}); | |
} | |
}); | |
} | |
} | |
); | |
}); | |
$(".social_wrapper").toggleClass("expanded_desktop_social"); | |
} | |
} | |
function checkEventOutsideShare() { | |
if (!$(event.target).closest('.social_link').length) { | |
if ($('div.social_menu').is(":visible")) { | |
if ($(event.target).attr("class") && !$(event.target).attr("class").includes('copy_text')) | |
$("div.social_menu").toggleClass('hide_social'); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment