I’m very new to this, but I have two javascripts that I’m trying to implement on my site, but one is interfering with the other…I’ve checked that the variables are unique (I think) and I’m lost as to why. π‘
here are the two scripts that I’m using:
the first (a slide panel):
[CODE]
window.addEvent(‘domready’, function(){
$(‘login’).setStyle(‘height’,’auto’);
var mySlide = new Fx.Slide(‘login’).hide(); //starts the panel in closed state
$(‘toggleLogin’).addEvent(‘click’, function(e){
e = new Event(e);
mySlide.toggle();
e.stop();
});
$(‘closeLogin’).addEvent(‘click’, function(e){
e = new Event(e);
mySlide.slideOut();
e.stop();
});
});
And the second script (a menu):
[CODE]
$(document).ready(function(){
$(“#nicemenu img.arrow”).click(function(){
$(“span.head_menu”).removeClass(‘active’);
submenu = $(this).parent().parent().find(“div.sub_menu”);
if(submenu.css(‘display’)==”block”){
$(this).parent().removeClass(“active”);
submenu.hide();
$(this).attr(‘src’,’images/arrow_hover.png’);
}else{
$(this).parent().addClass(“active”);
submenu.fadeIn();
$(this).attr(‘src’,’images/arrow_select.png’);
}
$(“div.sub_menu:visible”).not(submenu).hide();
$(“#nicemenu img.arrow”).not(this).attr(‘src’,’images/arrow.png’);
})
.mouseover(function(){ $(this).attr(‘src’,’images/arrow_hover.png’); })
.mouseout(function(){
if($(this).parent().parent().find(“div.sub_menu”).css(‘display’)!=”block”){
$(this).attr(‘src’,’images/arrow.png’);
}else{
$(this).attr(‘src’,’images/arrow_select.png’);
}
});
$(“#nicemenu span.head_menu”).mouseover(function(){ $(this).addClass(‘over’)})
.mouseout(function(){ $(this).removeClass(‘over’) });
$(“#nicemenu div.sub_menu”).mouseover(function(){ $(this).fadeIn(); })
.blur(function(){
$(this).hide();
$(“span.head_menu”).removeClass(‘active’);
});
$(document).click(function(event){
var target = $(event.target);
if (target.parents(“#nicemenu”).length == 0) {
$(“#nicemenu span.head_menu”).removeClass(‘active’);
$(“#nicemenu div.sub_menu”).hide();
$(“#nicemenu img.arrow”).attr(‘src’,’images/arrow.png’);
}
});
});
There are also are two other scripts that are involved with the first one, but I’m not sure if they’re the problem.
mootools-1.2-core.js
mootools-1.2-more.js
Should I paste that code as well? Or is the problem in the first two?
Thanks very much for any advice or direction!
[CODE]<script>
jQuery.noConflict();
// Use jQuery via jQuery(...)
jQuery(document).ready(function(){
jQuery("div").hide();
});
// Use Mootools with $(...), etc.
$('someid').hide();
</script>
[/CODE]
[CODE]
jQuery(document).ready(function(){
jQuery("#nicemenu img.arrow").click(function(){
jQuery("span.head_menu").removeClass('active');
submenu = jQuery(this).parent().parent().find("div.sub_menu");
if(submenu.css('display')=="block"){
jQuery(this).parent().removeClass("active");
submenu.hide();
jQuery(this).attr('src','images/arrow_hover.png');
}else{
jQuery(this).parent().addClass("active");
submenu.fadeIn();
jQuery(this).attr('src','images/arrow_select.png');
}
jQuery("div.sub_menu:visible").not(submenu).hide();
jQuery("#nicemenu img.arrow").not(this).attr('src','images/arrow.png');
})
.mouseover(function(){ jQuery(this).attr('src','images/arrow_hover.png'); })
.mouseout(function(){
if(jQuery(this).parent().parent().find("div.sub_menu").css('display')!="block"){
jQuery(this).attr('src','images/arrow.png');
}else{
jQuery(this).attr('src','images/arrow_select.png');
}
});
jQuery("#nicemenu span.head_menu").mouseover(function(){ jQuery(this).addClass('over')})
.mouseout(function(){ jQuery(this).removeClass('over') });
$("#nicemenu div.sub_menu").mouseover(function(){ jQuery(this).fadeIn(); })
.blur(function(){
jQuery(this).hide();
jQuery("span.head_menu").removeClass('active');
});
jQuery(document).click(function(event){
var target = jQuery(event.target);
if (target.parents("#nicemenu").length == 0) {
jQuery("#nicemenu span.head_menu").removeClass('active');
jQuery("#nicemenu div.sub_menu").hide();
jQuery("#nicemenu img.arrow").attr('src','images/arrow.png');
}
});
});
[/CODE]
[CODE] $('someid').hide();
[/CODE]
not sure how to provide a working link.[/QUOTE]
...since both of them are badly written...[/quote]How so?
...and tend to create a good deal of overhead for visitors on websites[/quote]I can only speak for jQuery. And when jQuery is compressed properly, it's less than 15K. I've seen JPEGs bigger than that. So it doesn't make nearly the "good deal of overhead" you claim it to.
[CODE]
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script>
jQuery.noConflict();
// Do something with jQuery
jQuery("div p").hide();
// Do something with another library's $()
$("content").style.display = 'none';
</script>
<script type="text/javascript" src="scripts/menu.js"></script>
<!-- START Fx.Slide -->
<!-- The CSS -->
<link rel="stylesheet" href="fx.slide.css" type="text/css" media="screen" />
<!-- Mootools - the core -->
<script type="text/javascript" src="scripts/mootools-1.2-core-yc.js"></script>
<!--Toggle effect (show/hide login form) -->
<script type="text/javascript" src="scripts/mootools-1.2-more.js"></script>
<script type="text/javascript" src="scripts/fx.slide.js"></script>
<!-- End Fx.Slide -->
</head>
/*navigation*/
#navigation {
float: left;
height: 30px;
width: 600px;
color: #333;
padding: 10px;
border: none;
margin: 0px 0px 0px 0px;
background: none;
}
ul, li{margin:0; border:0; list-style:none; padding:0;}
ul{height:21px;}
h1 { font-size:18px; }
p { line-height:18px; }
#info { margin:auto; width:600px; color:#333333; padding:10px; background:#f4f4f4; border:1px solid #DDD; }
#nicemenu { margin:0 0px 0 195px; width:615px; border-bottom:none; height:23px; }
#nicemenu a { color:#8a7e5a; text-decoration:none; }
#nicemenu a:hover { text-decoration:underline; }
#nicemenu li { display:inline; position:relative; padding-left: 5px; }
#nicemenu li span { position:relative; z-index:10; padding:4px 4px 4px 6px; border-bottom:none; line-height:18px; }
#nicemenu li span a { font-weight:normal; padding:0 8px 0px 2px; font-size:12px; font-family:"Lucida Grande"; }
#nicemenu li span.over { padding:4px 3px 4px 5px; border-top:solid 1px #E5E5E5; border-left:solid 1px #E5E5E5; border-right:solid 1px #999999; border-bottom:solid 1px #fff; }
*+html #nicemenu li span.over { border-top:solid 2px #E5E5E5; padding-bottom:3px; } /* IE6 */
#nicemenu li span.over a { }
#nicemenu li span.over a:hover { text-decoration:none; }
#nicemenu li span.active { padding:4px 3px 4px 5px; border-top:solid 1px #E5E5E5; border-left:solid 1px #E5E5E5; border-right:solid 1px #999999; border-bottom:solid 1px #fff; }
*+html #nicemenu li span.active { border-top:solid 2px #E5E5E5; padding-bottom:3px; }
#nicemenu li span.active a { }
#nicemenu li span.active a:hover { text-decoration:none; }
#nicemenu img.arrow { /*margin-left:4px;*/ cursor:pointer; }
#nicemenu div.sub_menu { display:none; position:absolute; left:0; top:0px; margin-top:18px; border-top:solid 1px #E5E5E5; border-left:solid 1px #E5E5E5; border-right:solid 1px #999999; border-bottom:solid 1px #999999; padding:4px; top:2px; width:160px; background:#FFFFFF; }
* html #nicemenu div.sub_menu { margin-top:23px; } /* IE6 */
*+html #nicemenu div.sub_menu { margin-top:23px; } /* IE7 */
#nicemenu div.sub_menu a:link,
#nicemenu div.sub_menu a:visited,
#nicemenu div.sub_menu a:hover{ display:block; font-size:11px; padding:4px;}
#nicemenu a.item_line { border-top:solid 1px #E5E5E5; padding-top:6px !important; margin-top:3px; }
/*end navigation*/
/*start top panel*/
#top-panel{
background:#e8f3c6;
border-bottom:3px solid #a6c34e;
padding:14px 20px;
text-align:right;
}
#sub-panel{
text-align:center;
}
#sub-panel a{
width:150px;
float:right;
color:#FFFFFF;
text-decoration:none;
margin-right:30px;
font-weight:bold;
background:url(images/sub-left.png) bottom left no-repeat #a6c34e;
}
#sub-panel a span{
padding:6px;
background:url(images/sub-right.png) right bottom no-repeat;
display:block;
}
strong{color:#000000;}
.face{border:solid 2px #a6c34e; margin-left:10px; float:right;}
/*end top panel*/
</style>
<body>
<div id="login">
<div class="loginContent">
<form action="#" method="post">
<label for="log"><b>Username: </b></label>
<input class="field" type="text" name="log" id="log" value="" size="23" />
<label for="pwd"><b>Password:</b></label>
<input class="field" type="password" name="pwd" id="pwd" size="23" />
<input type="submit" name="submit" value="" class="button_login" />
<input type="hidden" name="redirect_to" value=""/>
</form>
<div class="left">
<label for="rememberme"><input name="rememberme" id="rememberme" class="rememberme" type="checkbox" checked="checked" value="forever" /> Remember me</label></div>
<div class="right">Not a member? <a href="#">Register</a> | <a href="#">Lost your password?</a></div>
</div>
<div class="loginClose"><a href="#" id="closeLogin">Close Panel</a></div>
</div> <!-- /login -->
<div id="container">
<div id="top">
<!-- login -->
<ul class="login">
<li class="left"> </li>
<li>Hello!</li>
<li>|</li>
<li><a id="toggleLogin" href="#">Log In</a></li>
</ul> <!-- / login -->
</div> <!-- / top -->
<div class="clearfix"></div>
</div>
<!-- Begin Wrapper -->
<div id="wrapper">
<!-- Begin Header -->
<div id="header">
<img src='images/head.jpg' style="margin-left:240px">
</div>
<!-- End Header -->
<!-- Begin Navigation -->
<div id='navigation'>
<div id="nicemenu">
<ul>
<li><span class="head_menu"><a href="index.html">home</a></span>
<li><span class="head_menu"><a href="index.html">collections</a><img src="images/arrow.png" width="18" height="20" align="top" class="arrow" /></span>
<div class="sub_menu">
<a href="index.html">Your Photos</a>
<a href="index.html">Your Sets</a>
<a href="index.html">Your Archives</a>
<a href="index.html">Your Tags</a>
<a href="index.html">Your Map</a>
<a href="index.html">Your Favorites</a>
<a href="index.html">Your Stats</a>
<a href="index.html" class="item_line">Recent Activity</a>
<a href="index.html">Comments You've Made</a>
<a href="index.html" class="item_line">Upload Photos</a>
<a href="index.html" class="item_line">Your Account</a>
<a href="index.html">Your Profile</a>
<a href="index.html" class="item_line">FlickrMail</a>
</div>
</li>
<li><span class="head_menu"><a href="index.html">warranty</a><img src="images/arrow.png" width="18" height="20" align="top" class="arrow" /></span>
<div class="sub_menu">
<a href="index.html">All your photos</a>
<a href="index.html">Most recently uploaded photos</a>
<a href="index.html">Your Sets</a>
<a href="index.html">Your Map</a>
</div>
</li>
<li><span class="head_menu"><a href="index.html">retailers</a><img src="images/arrow.png" width="18" height="20" align="top" class="arrow" /></span>
<div class="sub_menu">
<a href="index.html">Latest Photos</a>
<a href="index.html">Contact List</a>
<a href="index.html">People Search</a>
<a href="index.html" class="item_line">Invite your Friends</a>
<a href="index.html">Invite History</a>
<a href="index.html">Guest Pass History</a>
<a href="index.html" class="item_line">Give the gift of Flickr</a>
</div>
</li>
<li><span class="head_menu"><a href="index.html">links</a><img src="images/arrow.png" width="18" height="20" align="top" class="arrow" /></span>
<div class="sub_menu">
<a href="index.html">Your Groups</a>
<a href="index.html">Recent Changes</a>
<a href="index.html" class="item_line">Search for a Group</a>
<a href="index.html" class="item_line">Create a New Group</a>
</div>
</li>
<li><span class="head_menu"><a href="index.html">contact</a><img src="images/arrow.png" width="18" height="20" align="top" class="arrow" /></span>
<div class="sub_menu">
<a href="index.html">Explore Page</a>
<a href="index.html">Last 7 Days Interesting</a>
<a href="index.html">Calendar</a>
<a href="index.html">A Year Ago Today</a>
<a href="index.html" class="item_line">World Map</a>
<a href="index.html">Places</a>
<a href="index.html">Camera Finder</a>
<a href="index.html" class="item_line">Popular Tags</a>
<a href="index.html">Most Recent Photos</a>
<a href="index.html">Creative Commons</a>
<a href="index.html" class="item_line">FlickrBlog</a>
<a href="index.html" class="item_line">Do More with Your Photos</a>
<a href="index.html">Flickr Services</a>
</div>
</li>
</ul>
</div>
</div>
<!-- End Navigation -->
<!-- Begin Left Column -->
<div id="leftcolumn">
<img src='images/thumb.jpg' style="margin-left:349px">
</div>
<!-- End Left Column -->
<!-- Begin Right Column -->
<div id="rightcolumn">
</div>
<!-- End Right Column -->
</div>
<!-- End Wrapper -->
</body>
<div id="footer">coinwatch north america / castle peak web design</div>
</html>
[/CODE]
[CODE]
<head>
<script>
jQuery.noConflict();
// Do something with jQuery
jQuery("div p").hide();
// Do something with another library's $()
$("content").style.display = 'none';
</script>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.pack.js"></script>
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery("#nicemenu img.arrow").click(function(){
jQuery("span.head_menu").removeClass('active');
submenu = jQuery(this).parent().parent().find("div.sub_menu");
if(submenu.css('display')=="block"){
jQuery(this).parent().removeClass("active");
submenu.hide();
jQuery(this).attr('src','images/arrow_hover.png');
}else{
jQuery(this).parent().addClass("active");
submenu.fadeIn();
jQuery(this).attr('src','images/arrow_select.png');
}
jQuery("div.sub_menu:visible").not(submenu).hide();
jQuery("#nicemenu img.arrow").not(this).attr('src','images/arrow.png');
})
.mouseover(function(){ jQuery(this).attr('src','images/arrow_hover.png'); })
.mouseout(function(){
if(jQuery(this).parent().parent().find("div.sub_menu").css('display')!="block"){
jQuery(this).attr('src','images/arrow.png');
}else{
jQuery(this).attr('src','images/arrow_select.png');
}
});
jQuery("#nicemenu span.head_menu").mouseover(function(){ jQuery(this).addClass('over')})
.mouseout(function(){ jQuery(this).removeClass('over') });
jQuery("#nicemenu div.sub_menu").mouseover(function(){ jQuery(this).fadeIn(); })
.blur(function(){
jQuery(this).hide();
jQuery("span.head_menu").removeClass('active');
});
jQuery(document).click(function(event){
var target = jQuery(event.target);
if (target.parents("#nicemenu").length == 0) {
jQuery("#nicemenu span.head_menu").removeClass('active');
jQuery("#nicemenu div.sub_menu").hide();
jQuery("#nicemenu img.arrow").attr('src','images/arrow.png');
}
});
});
</script>
<!-- START Fx.Slide -->
<!-- The CSS -->
<link rel="stylesheet" href="fx.slide.css" type="text/css" media="screen" />
<!-- Mootools - the core -->
<script type="text/javascript" src="scripts/mootools-1.2-core-yc.js"></script>
<!--Toggle effect (show/hide login form) -->
<script type="text/javascript" src="scripts/mootools-1.2-more.js"></script>
<script type="text/javascript" src="scripts/fx.slide.js"></script>
<!-- End Fx.Slide -->
</head>[/CODE]
How so?
I can only speak for jQuery. And when jQuery is compressed properly, it's less than 15K. I've seen JPEGs bigger than that. So it doesn't make nearly the "good deal of overhead" you claim it to.[/QUOTE]
[CODE]$("a").click(function() {
$('#Content').toggle();
}); [/CODE]
They are not true API's.. serveral of their features are just duplications of existing functionality built into javascript as opposed to creating functionality that does not already exist in javascript[/quote]CSS2 & 3 selectors? XPath? Commonly used animations, like fades and slides? Cross-browser compatible events?
$("a").click(function() {That particular example happens to map nicely to native functionality, yes, but there are plenty of situations that don't map nicely. A jQuery selector I wrote recently is [font=courier]$("#top .search label")[/font]. If I were to write that manually, I'd be getting an element by ID, searching through all its descendants for a particular class name, and then getting an element by tag name for each of those.
$('#Content').toggle();
});[/quote]
...not environmentally friendly; ie they cause conflicts with other tool-kits...[/quote]For MooTools and Prototype, you're probably right. jQuery is one of the exceptions. The only names it exports to the global namespace are "jQuery" and "$". And if you ask it to, it will not touch "$".
They encourage a poor programming practices -- using proprietary function names...[/quote]You don't seem to understand the word "proprietary". You should
4. They encourage a poor programming practices -- using proprietary function names that will break if you were to move your code to a different api.. forcing you to write a bridge, etc.[/quote]
Lets just say I haven't really seen any good public api's for javascript yet over the last 12 years of javascript programming I have done.[/quote]And you never will because the code is guaranteed to break if you remove the library, as the library's API has to differ from the native API or otherwise it wouldn't be a library and would overwrite the existing API which is certainly terrible practice.
some of the reasons I advise people not use these [i]so called[/i] api's are because[/quote](emphasis added)
0.1.9 β BETA 5.4