将 jquery 脚本转换为 Prototype Scriptaculous?
您好,我在 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
});
Hi I hAVE my code here in jquery for my footer chat panel And it is conflict with Scriptaculous. I want it to convert into pure js or Using Prototype Scriptaculous.
Any Help?
Thank you!
$(document).ready(function(){
$.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
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以将 jQuery 与其他库结合使用。
You can use jQuery with other libraries.
使用 jQuery noConflict
示例:
Use jQuery noConflict
Example:
将上面的代码替换为此代码
Replace your code above with this