The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
Need Help: js/ css active login-window setTimeout
Hi everybody,
I need help with a small javascript. I wanna activate the login-window at pageload and set a timeout to deactivate it again after a few seconds. I try somthing like this but it didn't work: HTML Code:
<vb:if condition="$page['channelid'] == 1"> <vb:if condition="!$user OR $user['userid'] < 1"> <script type="text/javascript"> $(document).ready(function() { $("#main-navbar .username-container").addClass("b_menu__dropdown--active");, function(){ setTimeout("$('#main-navbar .username-container').removeClass("b_menu__dropdown--active");", 5000); }); }); </script> </vb:if> </vb:if> The template is loading but it isn't doing what it should do... Would be nice to get some help. Thanks |
#2
|
||||
|
||||
when the template is called, are you passing the page and user variable reference to it?
ie: page=page, user=user, although not really necessary for something this simple. The channelid and userid are both available in the pageData javascript object on every page. Maybe moving the conditional from the template to an if statement in the javascript is in order. |
#3
|
||||
|
||||
Hey Repli,
thanks for your quick answer. I have more trouble to get the script running then the conditionals meaningful. The script should only loading at channel 1 and if the user is logged out. So the login-window show up for a while and disappear after that. A friend ask and I thought it couldn't be that hard to do it. Could be that the conditions are available in js but Iam not sure what is faster... load the script or get the conditionals. What ever. The conditionals are ok for me... but I have to get the script running Don't try but it should work in 1 condition... HTML Code:
<vb:if condition="$page['channelid'] == 1 AND !$user OR $user['userid'] < 1"> <script type="text/javascript"> $(document).ready(function() { $("#main-navbar .username-container").addClass("b_menu__dropdown--active");, function(){ setTimeout("$('#main-navbar .username-container').removeClass("b_menu__dropdown--active");", 5000); }); }); </script> </vb:if> |
#4
|
||||
|
||||
This should do it(Tested on 5.2.2). The class b_menu__dropdown--active only highlights the button for the drop down login. This code shows the login box for 8 seconds give or take, but I'd suspect the timeout needs to be a little longer to give the user time to react.
Code:
<script type="text/javascript"> $(document).ready(function() { $(".js-menu__dropdown-submenu.b-menu__dropdown-submenu").css("display","block"); setTimeout(function(){$(".js-menu__dropdown-submenu.b-menu__dropdown-submenu").css("display","none");console.log("Dropdown Timed Out")}, 8000); } ); </script> |
#5
|
||||
|
||||
Wouldn't that break the dropdown functionality if you mess with the css directly to show/hide the login dropdown?
Why not just trigger a click event to the button and let the button do its thing to change the CSS to hide/show the login dropdown? No need to worry or know what css class to use or know how the dropdown is hidden or shown. Just programmatically click the button as if user is clicking it. |
#6
|
||||
|
||||
Replicant you are the best! Big big thanks to you! It works perfectly and didn't break the onclick dropdown function or anything else. It works perfectly for me.
It is not to login directly... only to show where the login form actually is. This friends forum is used by (I would say older generation) not that it-specials So they told him they don't find the login... so this is my first and best thought. Again... Big big thanks! It works perfect for me, but if anybody have another idea --> just tell me ;-) |
#7
|
||||
|
||||
Quote:
|
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|