[JS]Help

Joined
Dec 15, 2009
Messages
1,382
Reaction score
236
I'm halfway coding my blog....but I couldn't find a proper way to end this...cuz I left something..
Basically a login form :(

I need a script that can works similar with this (http://forums.bukkit.org/)..you see the when you press the login or sign up button...it scrolls down a div and pushes down the whole content...

I couldn't find my answer for this....

Could anybody teach me or show me some resourceful link or tut?

Thank you :)
 
Last edited:
For closing a div when clicking outside of it: Let me google that for you

You could inspect the code on websites that have what you're looking for using Chrome's Inspect Element and Firefox's FireBug (Add-on), find the code that handles it, then work from that.
 
If you actually are having an overlay, then you could just use

Code:
$('#overlay').click(function() {
[INDENT]$('#header').hide();[/INDENT]
});

but if you were trying it without the overlay, then all it would take is

Code:
$('#header').blur(function() {
[INDENT]$('#header').hide();[/INDENT]
}
mhm I dun really get it....


==========================================
Here it is:
https://dl.dropbox.com/u/32360643/login_panel_mooslide/index.html

As you can see...when you click the "Login", the panel slide down....okay..now..instead of pressing the "X"..I want to close it if u click outside the panel (not inside)....well I'm stuck atm...need help!!!

PS:
I still dun get it even with this
http://stackoverflow.com/questions/714471/jquery-hide-element-when-clicked-anywhere-on-the-page
 
Last edited:
Chris is quite correct.

To elaborate, the idea is that you have a hidden-by-default div that will be toggled visible/hidden when something is clicked.

Most of the work is going to be the HTML+CSS design. Put it where you want it to appear and make it look how you want it to look.
Then, set the CSS of that element to display: none;.

Here comes the javascript. We're going to use jQuery's show/hide methods. Check out the link, it leads to the API documentation of the show method. The second example shows both .show and .hide being used as how you intend to use it.

What you need to do is just have a way for the .show and .hide methods to be invoked, i.e. have a link/button somewhere, and you should be fine.

Now, the overlay. The CSS/HTML is pretty straight forward. If you inspect the CSS of their overlay, it's pretty routine.
Code:
style="position: absolute; top: 0px; left: 0px; width: 1903px; height: 2310px; display: block; opacity: 0.6; z-index: 9998; background-color: rgb(255, 255, 255);"

That's the CSS they use, although I would personally set the position to fixed and just use a width and height of 100%, which would work fine as well. Remember though, the div with this CSS will be the overlay div. So make sure it doesn't cover the div that is being shown with the jQuery .show method.

Bukkit invokes the .hide method when the overlay is clicked, which explains why clicking on the forums will get rid of both the overlay and the login box.

Oh, and you'll want to keep the overlay div hidden until the login/whatever div is shown. So when your login div is shown, you'll want to simultaneously show the overlay div. When the login div is hidden, you'll also want to simultaneously hide your overlay div. Simple enough... $('#login').hide(); $('#overlay').hide();

I hope this helped.
 
Chris is quite correct.

To elaborate, the idea is that you have a hidden-by-default div that will be toggled visible/hidden when something is clicked.

Most of the work is going to be the HTML+CSS design. Put it where you want it to appear and make it look how you want it to look.
Then, set the CSS of that element to display: none;.

Here comes the javascript. We're going to use jQuery's show/hide methods. Check out the link, it leads to the API documentation of the show method. The second example shows both .show and .hide being used as how you intend to use it.

What you need to do is just have a way for the .show and .hide methods to be invoked, i.e. have a link/button somewhere, and you should be fine.

Now, the overlay. The CSS/HTML is pretty straight forward. If you inspect the CSS of their overlay, it's pretty routine.
Code:
style="position: absolute; top: 0px; left: 0px; width: 1903px; height: 2310px; display: block; opacity: 0.6; z-index: 9998; background-color: rgb(255, 255, 255);"

That's the CSS they use, although I would personally set the position to fixed and just use a width and height of 100%, which would work fine as well. Remember though, the div with this CSS will be the overlay div. So make sure it doesn't cover the div that is being shown with the jQuery .show method.

Bukkit invokes the .hide method when the overlay is clicked, which explains why clicking on the forums will get rid of both the overlay and the login box.

Oh, and you'll want to keep the overlay div hidden until the login/whatever div is shown. So when your login div is shown, you'll want to simultaneously show the overlay div. When the login div is hidden, you'll also want to simultaneously hide your overlay div. Simple enough... $('#login').hide(); $('#overlay').hide();

I hope this helped.
shitt....mootools and jquery kinda mess up everything...

btw thanks :) ima gonna try making my own...
 
Yea I noticed that after I post...but the forum went offline...thanks anyway :)
Btw, how to define whether login panel is collapse or not? Cuz I want to use *login* to trigger down and up the panel

Refer to my previous post for that information. It's as simple as hiding it by default, then using some simple jQuery to hide/show it.
 
Refer to my previous post for that information. It's as simple as hiding it by default, then using some simple jQuery to hide/show it.
hell yeah :) gonna try it out tomorrow :P

I have to use the if and else syntax? I'm not good in javascripting

ps
****....I fucking don't know how...do to with the if and else statement and visible thingy :(
 
Last edited:
Back