MyBB Community Forums

Full Version: jQuery in MyBB
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hello,

I tried to add some jQuey code in MyBB 1.6.5, but if I try to save the template, the board notices me:

Quote:The following errors were encountered:

A potential security issue was found in the template. Please review your changes or contact the MyBB Group for support.

I tried it again, installing jSnippet but anything changed... :/

Here you my jQuery code...

<script type="text/javascript" src="http://www.sharefenix.com/skinfenix_utlimate/jquery-b14.js"></script> <script type="text/javascript">
 
var $box = $("#display");
$(document.body).click(function(){
    if (!$box.has(this).length) { // if the click was not within $box
        $box.fadeOut();
    }
});

$("#topnav .li1,#topnav .li1 .sub").hover(function(){$('.menulink1').css("color","#333");},function(){     $('.menulink1').css("color","#fff");});

$("#topnav .li2").hover(function(){$('.menulink2').css("color","#333");},function(){     $('.menulink2').css("color","#fff");});

$("#topnav .li3").hover(function(){$('.menulink3').css("color","#333");},function(){     $('.menulink3').css("color","#fff");});

$("#topnav .li4").hover(function(){$('.menulink4').css("color","#333");},function(){     $('.menulink4').css("color","#fff");});

$("#topnav .li5").hover(function(){$('.menulink5').css("color","#333");},function(){     $('.menulink5').css("color","#fff");});

$("#topnav .li6").hover(function(){$('.menulink6').css("color","#333");},function(){     $('.menulink6').css("color","#fff");});

$("#topnav .li7").hover(function(){$('.menulink7').css("color","#333");},function(){     $('.menulink7').css("color","#fff");});

$("#topnav .li8").hover(function(){$('.menulink8').css("color","#333");},function(){     $('.menulink8').css("color","#fff");});
$("#max-menu .sub a").click(function(){
$("#max-menu .sub").fadeOut();
});

$(function() {
$("#top-link").click(
		function (e) {
			$("html, body").animate({scrollTop: "0px"}, 800);
		}
	);
 });

$(document).ready(function() {
	$("#footer-subscribe").val("[email protected]");
});
$("#footer-subscribe").click(function(){
	var value = $(this).val();
	if(value == "[email protected]"){
		$(this).val("");
	}
});
$("body").click(function(){
	var value = $("#footer-subscribe").val();
	 $("#footer-subscribe").click(function(event){
		 event.stopPropagation();
	 });
	if(value == "" ){
		$("#footer-subscribe").val("[email protected]");
	}
});

$("#footer-subscribe-submit").click(function(event){
	event.preventDefault();
	alert("In costruione!");
});



</script> 
<script type="text/javascript">
//<![CDATA[

window.orig_onload = window.onload;
window.onload = function() {
if (is_ie || is_moz) { var cpost=document.location.hash;if(cpost){ if(cobj = fetch_object(cpost.substring(1,cpost.length)))cobj.scrollIntoView(true); }}

if(typeof window.orig_onload == "function") window.orig_onload();
}

//]]>
</script>

Try this Smile.

<script type="text/javascript" src="http://www.sharefenix.com/skinfenix_utlimate/jquery-b14.js"></script> 
<script type="text/javascript">
jQuery.noConflict();
var $box = $("#display");
$(document.body).click(function(){
    if (!$box.has(this).length) { // if the click was not within $box
        $box.fadeOut();
    }
});

$("#topnav .li1,#topnav .li1 .sub").hover(function(){$('.menulink1').css("color","#333");},function(){     $('.menulink1').css("color","#fff");});

$("#topnav .li2").hover(function(){$('.menulink2').css("color","#333");},function(){     $('.menulink2').css("color","#fff");});

$("#topnav .li3").hover(function(){$('.menulink3').css("color","#333");},function(){     $('.menulink3').css("color","#fff");});

$("#topnav .li4").hover(function(){$('.menulink4').css("color","#333");},function(){     $('.menulink4').css("color","#fff");});

$("#topnav .li5").hover(function(){$('.menulink5').css("color","#333");},function(){     $('.menulink5').css("color","#fff");});

$("#topnav .li6").hover(function(){$('.menulink6').css("color","#333");},function(){     $('.menulink6').css("color","#fff");});

$("#topnav .li7").hover(function(){$('.menulink7').css("color","#333");},function(){     $('.menulink7').css("color","#fff");});

$("#topnav .li8").hover(function(){$('.menulink8').css("color","#333");},function(){     $('.menulink8').css("color","#fff");});
$("#max-menu .sub a").click(function(){
$("#max-menu .sub").fadeOut();
});

$(function() {
$("#top-link").click(
        function (e) {
            $("html, body").animate({scrollTop: "0px"}, 800);
        }
    );
});

$(document).ready(function() {
    $("#footer-subscribe").val("[email protected]");
});
$("#footer-subscribe").click(function(){
    var value = $(this).val();
    if(value == "[email protected]"){
        $(this).val("");
    }
});
$("body").click(function(){
    var value = $("#footer-subscribe").val();
     $("#footer-subscribe").click(function(event){
         event.stopPropagation();
     });
    if(value == "" ){
        $("#footer-subscribe").val("[email protected]");
    }
});

$("#footer-subscribe-submit").click(function(event){
    event.preventDefault();
    alert("In costruione!");
});



</script> 
<script type="text/javascript">
//<![CDATA[

window.orig_onload = window.onload;
window.onload = function() {
if (is_ie || is_moz) { var cpost=document.location.hash;if(cpost){ if(cobj = fetch_object(cpost.substring(1,cpost.length)))cobj.scrollIntoView(true); }}

if(typeof window.orig_onload == "function") window.orig_onload();
}

//]]>
</script>
Nada, I get the same error again.. Sad
Why not place the code in an outside file then? Would make life a lot easier Wink
I always use it in this way (putting in the footer), how can I put it in external file?
you can make it as an external java script file and include using script tag OR try replacing $( with jQuery( ..
mmm.. with jQuery insted of $( I get no error... But all jQuery effect don't work.

EDIT: I replaced ALL 4 with jQuery and all work fine except navbar...

jQuery("#topnav .li1,#topnav .li1 .sub").hover(function(){jQuery('.menulink1').css("color","#333");},function(){     jQuery('.menulink1').css("color","#fff");});

jQuery("#topnav .li2").hover(function(){jQuery('.menulink2').css("color","#333");},function(){     jQuery('.menulink2').css("color","#fff");});

jQuery("#topnav .li3").hover(function(){jQuery('.menulink3').css("color","#333");},function(){     jQuery('.menulink3').css("color","#fff");});

jQuery("#topnav .li4").hover(function(){jQuery('.menulink4').css("color","#333");},function(){     jQuery('.menulink4').css("color","#fff");});

jQuery("#topnav .li5").hover(function(){jQuery('.menulink5').css("color","#333");},function(){     jQuery('.menulink5').css("color","#fff");});

jQuery("#topnav .li6").hover(function(){jQuery('.menulink6').css("color","#333");},function(){     jQuery('.menulink6').css("color","#fff");});

jQuery("#topnav .li7").hover(function(){jQuery('.menulink7').css("color","#333");},function(){     jQuery('.menulink7').css("color","#fff");});

jQuery("#topnav .li8").hover(function(){jQuery('.menulink8').css("color","#333");},function(){     jQuery('.menulink8').css("color","#fff");});
jQuery("#gib-menu .sub a").click(function(){
jQuery("#gib-menu .sub").fadeOut();
});

But I used the same in vBulletin and it worked very well... so I think it's a css problem even if I think it's ok... When I'll lunch the skin on my web forum I'll ask your help again.

Thanks you, guys!!! (:
^ what is the effect you are trying - give its link ; can we have your forum URL ..

I was editing my previous post, when you write your one Toungue
At the moment it's on local side for testing.
Ok, I set the skin in development as default one... so you can see.

Site link is: www.sharefenix.com/forum/

In the navbar must seem like this one: www.sharefenix.com/forum_vb/
May I just jump in and say that is truly a beautiful theme first of all Wink

Secondly, I don't see what you're trying to do exactly? Are you meaning the navigation saying Forum, News, Panel?
Pages: 1 2