Last active
September 6, 2018 10:07
-
-
Save tyluudinh/75ac1221dafb4449d78d8c336b61481c 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
// TrangNguyen: update script for home nursing | |
togglePopup('box-item-nursing.item-baby-care', 'parent-babycare-information'); | |
togglePopup('box-item-nursing.item-wound-care', 'parent-woundcare-information'); | |
toggleBackgroundPopup('background-popup.homenursing-information'); | |
function togglePopup(btnTrigger, realBackgroundPopup){ | |
//Open popup | |
$('.'+btnTrigger).on('click', function(event){ | |
event.preventDefault(); | |
$('.'+realBackgroundPopup).addClass('is-visible'); | |
}); | |
//Close popup | |
$('.'+realBackgroundPopup).on('click', function(event){ | |
console.log(event); | |
if($(event.target).is('.btn-popup-close') || $(event.target).is('.popup-page') ) { | |
event.preventDefault(); | |
$(this).removeClass('is-visible'); | |
} | |
if (!$(event.target.offsetParent).is('.popup-page')) { | |
$(this).removeClass('is-visible'); | |
} | |
}); | |
//Close popup when clicking the esc keyboard button | |
$(document).keyup(function(event){ | |
if(event.which === '27'){ | |
$('.'+realBackgroundPopup).removeClass('is-visible'); | |
} | |
}); | |
} | |
function toggleBackgroundPopup(backgroundPopup){ | |
$('.'+backgroundPopup).on('click', function(event){ | |
if($(event.target).is('.popup-page') ) { | |
event.preventDefault(); | |
$(this).removeClass('is-visible'); | |
} | |
if (!$(event.target.offsetParent).is('.popup-page')) { | |
collapseContent('block'); | |
$(this).removeClass('is-visible'); | |
} | |
}); | |
} | |
function showFullNursingServiceList() { | |
$('.background-popup.homenursing-information').addClass('is-visible'); | |
collapseContent('none'); | |
} | |
function handleElement(display) { | |
const element = '.popup-page-both'; | |
const elementOffset = $(element); | |
var homeNursingHeight = 'auto'; | |
if (elementOffset && elementOffset.length && !display) { | |
homeNursingHeight = elementOffset[0].clientHeight + 100 + 'px'; | |
} | |
$('.home-nursing-details-v2').attr('style', 'height: ' + homeNursingHeight) | |
} | |
function collapseContent(display) { | |
$('.top-content').attr('style', 'display: ' + display); | |
handleElement(display === 'block'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment