Navigation Problem (Challenge)

XDirect12345 at 21h21
27
Jan
2012
In response to: /t103628-navigation-bar-import?highlight=navigation

READ CAREFULLY

Sigh, I have tired so many ways so I might as well break this down. This is a tough challenge even for me.

The Problem:
I added this image to my default forum skin. This was created using "Add a customized menu" in the "headers and navigation" secton. I tried to add so many things including:

Code:
#i_icon_mini_contact_us{width:110px; height:50px; background:url(http://zeus.cooltext.com/rendered/cooltext633640344.png) no-repeat 0 0;}
#i_icon_mini_contact_us:hover{background:url(http://zeus.cooltext.com/rendered/cooltext633631723.png) no-repeat  0 0px;}


And this

Code:
td[align="center"] a[href="http://xdirect12345contactus.yolasite.com/"]:hover {
background-image: url("http://zeus.cooltext.com/rendered/cooltext633631723.png");
}


Yet nothing. Sad Anyway I need a normal effect and a hover effect without changing the default skin's "Contact Us" button image on my default forum skin, created using "Add a customized menu" in the "headers and navigation" secton. 'OR' If you have any ideas on how to get an image into the navigation bar without having a custom menu created from the "Add a customized menu" in the "headers and navigation" secton, that would be mostly appreciated.

Here is the image of the problem. I want the image with the blue border, to be replaced with a normal and hover image similar to the other navigations.
1 XDirect12345, on 28/01/2012 at 17h49
Bump
2 XDirect12345, on 31/01/2012 at 20h39
Bump, any help please
3 XDirect12345, on 03/02/2012 at 18h46
bump
4 Sunborn, on 05/02/2012 at 01h58
This is a code i use on my website, but its HTML... You need to make some changes to work in CSS, but you can get an idea... Basically, you need 2 images, not one... and should be definitely a transparent PNG images, NOT JPG!!!

Code:
<td> <a href="http://xdirect12345contactus.yolasite.com/" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image2','','http://yoursite/yoursecondimage.jpg',1)"><img src="http://img710.imageshack.us/img710/6943/0vpqvy1324418550.jpg" name="Image2" width="110" height="50" border="0" id="Image2" /></a></td>


I hope that this helps you a little
5 ankillien, on 05/02/2012 at 05h34
Hi,

If I'm getting it right, this code would work for you...

Code:
$(function(){

$('a.mainmenu:last').after('<a href="http://www.wix.com/andromedavadum/xdirect12345contactus" class="mainmenu contactuslink"><img hspace="0" border="0" title="Contact Us" alt="Contact Us" src="http://images-1.findicons.com/files/icons/1681/siena/48/label_new.png" /></a>');

$('a.contactuslink').mouseenter(function(){
$(this).children('img').attr('src' , 'http://images-4.findicons.com/files/icons/1014/ivista/48/padlock.png');
});

$('a.contactuslink').mouseleave(function(){
$(this).children('img').attr('src' , 'http://images-1.findicons.com/files/icons/1681/siena/48/label_new.png');
});

});


You don't need to add anything from ACP > Headers & Navigation. Just add the above code via ACP > Modules > JS code management. Add it for all pages and see if it works.

Hope that helps Smile

EDIT:

And oh! If the code works, give me URLs of both normal and hover images so I'll add them in the code and make it complete.
6 XDirect12345, on 06/02/2012 at 00h34
I'll run some tests. Will this work without effecting other skins navigations that i created?
7 ankillien, on 06/02/2012 at 03h29
Yes, it should work on other skins as well.
8 XDirect12345, on 06/02/2012 at 18h46
I plan on creating multiple skins. I dont want to have the same "contact us" color or image for all skins, is there a way to create different colors or images on each different skin that I create?

Example: A different contact us button for a different skin that I choose for multiple skins.

Theme 1


Theme 2


Theme 3


Theme 4


There are 4 different buttons for 4 different themes. When a user selects "Theme 1" the button is Yellow. Then the user selects "Theme 3", the button is not yellow anymore but is green. Is there anyway to achieve this effect with css or javascript?
9 ankillien, on 07/02/2012 at 05h09
It is certainly possible but I need to know what method you use to change skins.
10 XDirect12345, on 07/02/2012 at 18h46
I plan on using this:
/t71484-add-multi-themes-to-your-forum

Can you provide me the code so I can put it in bounce
11 ankillien, on 08/02/2012 at 07h25
I don't have any copy-paste codes for this right now. You can try adding background image with CSS for all different themes you use, this way you can apply different image for the contact-us link.

The above code will change to this...

Code:
$(function(){
$('a.mainmenu:last').after('<a href="http://www.wix.com/andromedavadum/xdirect12345contactus" class="mainmenu contactuslink"> </a>');       
});


You can apply background to class .contactuslink.
12 XDirect12345, on 09/02/2012 at 18h35
ok, so can you give me example codes for normal and hover for the .contactuslink. I could figure where to put the images and stuff.
13 ankillien, on 10/02/2012 at 05h10
To add images you can use this CSS code...

Code:
.contactuslink {
display: inline-block;
width: 172px; height: 42px;
background: url(URL OF IMAGE AS PER THEME) no-repeat;
}


Add this code in the CSS of different themes you are using. Just don't forget to change the image URL in the code.
14 LGforum, on 10/02/2012 at 09h14
This code:

Code:

$(function(){

$('a.mainmenu:last').after('<a href="http://www.wix.com/andromedavadum/xdirect12345contactus" class="mainmenu contactuslink"><img hspace="0" border="0" title="Contact Us" alt="Contact Us" src="http://images-1.findicons.com/files/icons/1681/siena/48/label_new.png" /></a>');

$('a.contactuslink').mouseenter(function(){
$(this).children('img').attr('src' , 'http://images-4.findicons.com/files/icons/1014/ivista/48/padlock.png');
});

$('a.contactuslink').mouseleave(function(){
$(this).children('img').attr('src' , 'http://images-1.findicons.com/files/icons/1681/siena/48/label_new.png');
});

});


Is an extremely horrible way of doing this. Not to mention inefficient and longer than it needs to be.
Also if your manually inserting a new navbar link with jQuery, why give it a class name and access it childNodes? Why not just give said image an ID and it can be accessed instantly. And also why not include the mouse over events in the HTML string.

Instead of using all that jQuery rubbish just use
onmouseover="this.src='new source';"


Besides what's wrong with using CSS Sprites?
15 ankillien, on 10/02/2012 at 12h38
LGforum, I revised my code and posted new code here : /t103797-navigation-problem-challenge#680028

Also, it doesn't make any considerable difference whether we apply a class name or directly apply ID to the image. While providing quick support, we have to skip some small things like that to save time and solve problems quickly.

The member wants different image for different themes thats why we have to add background image via CSS. And I know about CSS sprites but probably the thread author does not, thats why I didn't suggest to use them Wink
16 LGforum, on 10/02/2012 at 13h56
ankillien wrote:Also, it doesn't make any considerable difference whether we apply a class name or directly apply ID to the image.


On the contrary, it does.
ID's can be access much quicker, especially when using jQuery. Any browsers which don't support the native getElementsByClassName will require looping through all tagNames within the context element, and there are still plenty of browsers not supporting getElementsByClassName.
Not too mention using jQuery to work through the nodes to reach the image from the link. Thats just extra unneeded work (especially with jQuery) when the image can be accessed in one fell swoop with an ID. And also the ':last' selector requires jQuery to find all the elements with such className and choose the last one. Where as it can be access much quicker using native javascript.

I'd recommend changing this:
Code:

$(function(){
$('a.mainmenu:last').after('<a href="http://www.wix.com/andromedavadum/xdirect12345contactus" class="mainmenu contactuslink"> </a>');     
});


to this:

Code:

$(function(){
document.getElementById('page-header').getElementsByTagName('ul')[0].innerHTML+='<a href="http://www.wix.com/andromedavadum/xdirect12345contactus" class="mainmenu contactuslink"> </a>';     
});


And the code in my last post can be altered to just this:
Code:

$(function(){
document.getElementById('page-header').getElementsByTagName('ul')[0].innerHTML+='<a href="http://www.wix.com/andromedavadum/xdirect12345contactus" class="mainmenu"><img title="Contact Us" alt="Contact Us" src="http://images-1.findicons.com/files/icons/1681/siena/48/label_new.png" onmouseover="this.src= 'http://images-4.findicons.com/files/icons/1014/ivista/48/padlock.png';" onmouseout="this.src='http://images-1.findicons.com/files/icons/1681/siena/48/label_new.png';"/></a>';     
});

The mouseover and mouseout functions are just included in the HTML.
17 ankillien, on 10/02/2012 at 15h49
Nice post, mate. But the latest browsers are smart and fast and they will do any calculations pretty quickly. I cannot spend my time thinking for the quickest possible solution to a problem, because it is just waste of time.

Your codes won't make the page load considerably faster. The difference would be minimal and won't even be noticeable. So, I'd choose to avoid wasting time and quickly provide codes that 'work fine'.

Now please avoid judging our codes and lets concentrate on helping members without wasting time finding 'better' solutions.

Thanks
18 LGforum, on 10/02/2012 at 16h06
Time optimising is never time wasted Wink
And believe me, I didn't waste any time thinking of that code.

I'm not judging your codes, I'm offering improvements for educational purposes.
Something that greatly helped me learn what I know nowadays.

On forumotions shaky boards and system script it's becoming quite necessary.

Anyway to conclude, I hope somebody learnt something from my post above.
jQuery isn't often the best route.
There is a post on DionDesigns that explains why perfectly. I think I'll edit the link into this post later when I get the chance.
19 ankillien, on 10/02/2012 at 16h11
I don't really care what DionDesign has to say about jQuery! All I know is that jQuery is perfect and quick and handy solutions for those who don't want to 'waste' their time learning hundreds of properties and methods of native javascript and knowing how quickly they work! Wink

Now no more discussion on this please!
20 XDirect12345, on 10/02/2012 at 19h39
ankillien wrote:To add images you can use this CSS code...

Code:
.contactuslink {
display: inline-block;
width: 172px; height: 42px;
background: url(URL OF IMAGE AS PER THEME) no-repeat;
}


Add this code in the CSS of different themes you are using. Just don't forget to change the image URL in the code.


I'll go with this one for now Smile
Similar topics
Yours truly has struck some gold in finding out where the next challenge is after the duel... Real World Road Rules Challenge 18 is The Pit Posted on May 11, 2009 by Michael Martin The cast left 2 weeks ago on Monday April 27th to Thailan
Hi i have problem to add One navigation button before "forum" button I dont know to add this. Can someone help me ?
Just a few side notes: Melinda and Danny are now divorced (shocking I know), Brad and Tori are now married. Johnny Banana's and Paula back yet again , No Kenny, Big E-Z back . Not thrilled with this cast and also, even though he is not part of the
Replies 1 to 20 on 23 for "Navigation Problem (Challenge)"
12
See also
more_less
Informations

23 Replies For the topic :
"Navigation Problem (Challenge)"

This topic has been viewed 1842 times.

Last message :
27/01/2012 at 21h21 by "XDirect12345"