Go Back   vb.org Archive > vBulletin 5 Connect Discussion > vB5 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 10-07-2016, 05:27 PM
delicjous's Avatar
delicjous delicjous is offline
 
Join Date: Nov 2014
Posts: 352
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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>
This script is in a template and the template is loading at the hook footer_before_body_end.
The template is loading but it isn't doing what it should do...

Would be nice to get some help.

Thanks
Reply With Quote
  #2  
Old 10-07-2016, 11:04 PM
Replicant's Avatar
Replicant Replicant is offline
 
Join Date: Sep 2014
Location: Phoenix, Az. USA
Posts: 485
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #3  
Old 10-08-2016, 02:09 AM
delicjous's Avatar
delicjous delicjous is offline
 
Join Date: Nov 2014
Posts: 352
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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>
The script should add the class to display the login-form and after timeout remove the class to make the login-form disappear.
Reply With Quote
  #4  
Old 10-08-2016, 11:49 AM
Replicant's Avatar
Replicant Replicant is offline
 
Join Date: Sep 2014
Location: Phoenix, Az. USA
Posts: 485
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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>
Reply With Quote
  #5  
Old 10-08-2016, 04:20 PM
noypiscripter's Avatar
noypiscripter noypiscripter is offline
 
Join Date: Jul 2013
Posts: 468
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #6  
Old 10-08-2016, 06:36 PM
delicjous's Avatar
delicjous delicjous is offline
 
Join Date: Nov 2014
Posts: 352
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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 ;-)
Reply With Quote
  #7  
Old 10-08-2016, 07:55 PM
Replicant's Avatar
Replicant Replicant is offline
 
Join Date: Sep 2014
Location: Phoenix, Az. USA
Posts: 485
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by noypiscripter View Post
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.
Great tip Glenn. I didn't even think about doing it that way even though you've directed the same advice to me in the past.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:12 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05538 seconds
  • Memory Usage 2,225KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (2)bbcode_html
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete