Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 02-01-2015, 08:56 PM
edgeless edgeless is offline
 
Join Date: Mar 2013
Posts: 115
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default This works... but I need help on getting the page to realign on FB button rendering

The other day I asked about a problem with Showthread running code for Facebook JS that's independent from code I place in the footer. Well I more or less figured out what's going on (I think) and I've come up with a solution. But it's not a perfect one in all ways (yet). As such, I'd very much appreciate some expert opinion, or even just some ideas on how to make it better. Allow me to explain...

If you read my previous post you may recall that I was unable to get Showthread to run a JS timer string for an FB plugin, despite that the timer string worked everywhere else on my vB site. It just wouldn't work on the Showthread pages. So I figured out that Showthread pulls the FB appID from the global vB FB config settings (set in FB Options); while other vB components don't seem to do the same thing. At least that's what happens when the FB Like Button is enabled for threads.

This means that my FB plugin content loads on Showthread pages without needing a presence of an all.js/sdk.js call on the footer template. But conversely, the FB plugin content will NOT load on any non-Showthread pages without that all.js/sdk.js call's presence on the footer template. However, Showthread seems to always get the remote jQuery library calls that I place on the footer template just fine... just as the other vB components do.

So, vB's Facebook Like Button integration for Showthread pages seems to be structured to call and load all.js or sdk.js independently from anything I may include on or omit from the footer template.

I found the source location of the all.js call for the thread Like Button. it's in Facebook Templates > facebook_likebutton.

Here's the original code:

Code:
<vb:if condition="$show['loadfbroot']">
<span id="fb-root"></span>
<script type="text/javascript" src="//connect.facebook.net/{vb:rawphrase facebook_language}/all.js#appId={vb:raw appid}
&amp;xfbml=1"></script>
</vb:if>
<fb:like href="{vb:raw href}" font="tahoma" layout="standard" show_faces="false" width="260" action="like" colorscheme="light"></fb:like>

When I change it to the following, my JS timer string works on Showthread pages:

Code:
<vb:if condition="$show['loadfbroot']">
<span id="fb-root"></span>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
   if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id; js.async=true;
var myTimer = setTimeout(function() {
js.src = "//connect.facebook.net/en_US/sdk.js#appId={vb:raw appid}&xfbml=1&version=v2.0";
}, 7500);
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
</vb:if>
<fb:like href="{vb:raw href}" font="tahoma" layout="standard" show_faces="false" width="260" action="like" colorscheme="light"></fb:like>

The problem I would like help with is this. Now, once the FB Like Button and the FB plugin content are fully loaded (and they load quite nicely after whatever delay I set), the page no longer goes back to perfect vertical alignment in the browser window. It jumps downward the exact distance of the height of the Like Button. With the original code it would jump downward briefly, but then realign so the post header bar was perfectly against the top of the browser window. Does anyone have an idea on how I might fix this?

Thank you in advance

--------------- Added [DATE]1422870705[/DATE] at [TIME]1422870705[/TIME] ---------------

Well, never mind. Sometimes for me the simplest things are the most evasive ones. I merely added a return false; and it solved the problem.
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 01:51 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03213 seconds
  • Memory Usage 2,162KB
  • 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
  • (2)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)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