gpt4 book ai didi

javascript - 将 jquery 脚本转换为 Prototype Scriptaculous?

转载 作者:行者123 更新时间:2023-12-02 20:30:01 24 4
gpt4 key购买 nike

嗨,我在 jquery 中有我的代码,用于我的页脚聊天面板,它与 Scriptaculous 冲突。我希望它转换为纯js或使用Prototype Scriptaculous。有帮助吗?谢谢!

$(文档).ready(函数(){

$.fn.adjustPanel = function(){ 
$(this).find("ul, .subpanel").css({ 'height' : 'auto'});

var windowHeight = $(window).height(); //Get the height of the browser viewport
var panelsub = $(this).find(".subpanel").height(); //Get the height of subpanel
var panelAdjust = windowHeight - 100; //Viewport height - 100px (Sets max height of subpanel)
var ulAdjust = panelAdjust - 25; //Calculate ul size after adjusting sub-panel (27px is the height of the base panel)

if ( panelsub >= panelAdjust ) { //If subpanel is taller than max height...
$(this).find(".subpanel").css({ 'height' : panelAdjust }); //Adjust subpanel to max height
$(this).find("ul").css({ 'height' : ulAdjust}); //Adjust subpanel ul to new size
}
else if ( panelsub < panelAdjust ) { //If subpanel is smaller than max height...
$(this).find("ul").css({ 'height' : 'auto'}); //Set subpanel ul to auto (default size)
}
};
//Execute function on load
$("#chatpanel").adjustPanel(); //Run the adjustPanel function on #chatpanel
$("#alertpanel").adjustPanel(); //Run the adjustPanel function on #alertpanel

//Each time the viewport is adjusted/resized, execute the function
$(window).resize(function () {
$("#chatpanel").adjustPanel();
$("#alertpanel").adjustPanel();
});


//Click event on Chat Panel + Alert Panel
$("#chatpanel a:first, #alertpanel a:first,#alertpanel2 a:first,#likes a:first,#twiter a:first").click(function() { //If clicked on the first link of #chatpanel and #alertpanel...
if($(this).next(".subpanel").is(':visible')){ //If subpanel is already active...
$(this).next(".subpanel").hide(); //Hide active subpanel
$("#footpanel li a").removeClass('active'); //Remove active class on the subpanel trigger
}
else { //if subpanel is not active...
$(".subpanel").hide(); //Hide all subpanels
$(this).next(".subpanel").toggle(); //Toggle the subpanel to make active
$("#footpanel li a").removeClass('active'); //Remove active class on all subpanel trigger
$(this).toggleClass('active'); //Toggle the active class on the subpanel trigger
}
return false; //Prevent browser jump to link anchor
});

//Click event outside of subpanel
$(document).click(function() { //Click anywhere and...
$(".subpanel").hide(); //hide subpanel
$("#footpanel li a").removeClass('active'); //remove active class on subpanel trigger
});
$('.subpanel ul').click(function(e) {
e.stopPropagation(); //Prevents the subpanel ul from closing on click
});

最佳答案

关于javascript - 将 jquery 脚本转换为 Prototype Scriptaculous?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4309991/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com