Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save junaidpv/6b200144559a74b7355f to your computer and use it in GitHub Desktop.

Select an option

Save junaidpv/6b200144559a74b7355f to your computer and use it in GitHub Desktop.
Twitter widget of socialmedia module do have a problem with its script. When blocks are rendered as Ajax delivered content. Inline script get exectued before twitter library is loaded. This patch fixes that.
diff --git a/socialmedia.widgets.inc b/socialmedia.widgets.inc
index 3c4dcf5..b2b7dd7 100644
--- a/socialmedia.widgets.inc
+++ b/socialmedia.widgets.inc
@@ -953,33 +953,34 @@ EOF;
function socialmedia_widgets_element_twitter_profile_widget() {
$template = <<<EOF
-<script src="http://widgets.twimg.com/j/2/widget.js"></script>
<script>
-new TWTR.Widget({
- version: 2,
- type: 'profile',
- rpp: [?preferences:number_of_tweets=4?],
- interval: 30000,
- width: [?dimensions:width=[socialmedia:sm-default_width]?],
- height: [?dimensions:height=[socialmedia:sm-default_height]?],
- theme: {
- shell: {
- background: '[?appearance:shell_background_color=[socialmedia:sm-default_color_header_background]?]',
- color: '[?appearance:shell_text_color=[socialmedia:sm-default_color_header_text]?]'
+jQuery.getScript('http://widgets.twimg.com/j/2/widget.js', function(){
+ new TWTR.Widget({
+ version: 2,
+ type: 'profile',
+ rpp: [?preferences:number_of_tweets=4?],
+ interval: 30000,
+ width: [?dimensions:width=[socialmedia:sm-default_width]?],
+ height: [?dimensions:height=[socialmedia:sm-default_height]?],
+ theme: {
+ shell: {
+ background: '[?appearance:shell_background_color=[socialmedia:sm-default_color_header_background]?]',
+ color: '[?appearance:shell_text_color=[socialmedia:sm-default_color_header_text]?]'
+ },
+ tweets: {
+ background: '[?appearance:tweets_background_color=[socialmedia:sm-default_color_body_background]?]',
+ color: '[?appearance:tweets_text_color=[socialmedia:sm-default_color_body_text]?]',
+ links: '[?appearance:link_color=[socialmedia:sm-default_color_body_linktext]?]'
+ }
},
- tweets: {
- background: '[?appearance:tweets_background_color=[socialmedia:sm-default_color_body_background]?]',
- color: '[?appearance:tweets_text_color=[socialmedia:sm-default_color_body_text]?]',
- links: '[?appearance:link_color=[socialmedia:sm-default_color_body_linktext]?]'
+ features: {
+ scrollbar: [?preferences:include_scrollbar=false?],
+ loop: false,
+ live: [?preferences:poll_for_new_results=false?],
+ behavior: 'all'
}
- },
- features: {
- scrollbar: [?preferences:include_scrollbar=false?],
- loop: false,
- live: [?preferences:poll_for_new_results=false?],
- behavior: 'all'
- }
-}).render().setUser('[?settings:twitter_username=[socialmedia:sm-twitter_username]?]').start();
+ }).render().setUser('[?settings:twitter_username=[socialmedia:sm-twitter_username]?]').start();
+});
</script>
EOF;
$elements['socialmedia_twitter-profile-widget'] = array(
@@ -1376,4 +1377,4 @@ function socialmedia_widgets_default_sets() {
);
return $sets;
-}
\ No newline at end of file
+}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment