Skip to content
Browse files

twitter fb share buttons are only loaded in English locales

  • Loading branch information...
1 parent e9e68f4 commit 3f6cc0f946d71cb1b1965eb528ff70e457f3f40e @lizhepro committed
Showing with 45 additions and 13 deletions.
  1. +44 −4 public/javascripts/client.js
  2. +1 −9 views/index.jade
View
48 public/javascripts/client.js
@@ -74,12 +74,11 @@ $(document).ready(function() {
var apiNameKeys = Object.keys(apiFileJSON);
for(var j=0, apiName; apiName=apiNameKeys[j]; j++) {
if(rInput.test(apiName)) {
- var obj = {
+ dropDownApiList.push(JSON.stringify({
item: apiName,
type: apiFileJSON[apiName].t,
owner: apiFileName
- }
- dropDownApiList.push(JSON.stringify(obj));
+ }));
}
}
}
@@ -221,5 +220,46 @@ $(document).ready(function() {
}
$('#navigation-content').empty().append(frag);
};
-});
+ //根据用户的地区加载social share buttons
+ var userLanguage = navigator.userLanguage || navigator.language || 'en';
+ if(userLanguage.indexOf('en') != -1) {
+ gplusDiv = $('<div />');
+ gplusDiv.addClass('g-plusone')
+ .attr('data-size', 'medium');
+ (function() {
+ var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
+ po.src = 'https://apis.google.com/js/plusone.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
+ })();
+
+ twitterIframe = $('<iframe />');
+ twitterIframe.attr({
+ src: 'https://platform.twitter.com/widgets/tweet_button.1340179658.html#_=1342285864031&amp;count=horizontal&amp;id=twitter-widget-108&amp;lang=en&amp;original_referer=https%3A%2F%2Ftwitter.com%2Fabout%2Fresources%2Fbuttons%23tweet&amp;size=m&amp;text=NodejsAPI&amp;url=http%3A%2F%2Fnodejsapi.cloudfoundry.com%2F',
+ scrolling: 'no',
+ frameborder: 0,
+ title: 'Twitter Tweet Button'
+ }).css({
+ border: 'none',
+ overflow: 'hidden',
+ width: '106px',
+ height: '20px',
+ allowTransparency: true
+ }).addClass('twitter-share-button twitter-count-horizontal');
+
+ fbIframe = $('<iframe />');
+ fbIframe.attr({
+ src: '//www.facebook.com/plugins/like.php?href=http%3A%2F%2Fnodejsapi.cloudfoundry.com%2F&amp;send=false&amp;layout=button_count&amp;show_faces=true&amp;action=like&amp;colorscheme=light&amp;font&amp;height=21"',
+ scrolling: 'no',
+ frameborder: 0,
+ layout: 'button_count'
+ }).css({
+ border: 'none',
+ overflow: 'hidden',
+ width: '250px',
+ height: '24px',
+ allowTransparency: true
+ });
+ $('div.share').append(gplusDiv).append(twitterIframe).append(fbIframe);
+ }
+});
View
10 views/index.jade
@@ -2,13 +2,7 @@
.title.show-grid
h1 Nodejs API
.share
- .g-plusone(data-size='medium')
script(type='text/javascript', charset='utf-8')
- (function() {
- var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
- po.src = 'https://apis.google.com/js/plusone.js';
- var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
- })();
(function(){
var _w = 90 , _h = 24;
var param = {
@@ -27,9 +21,7 @@
temp.push(p + '=' + encodeURIComponent( param[p] || '' ) )
}
document.write('<iframe allowTransparency="true" frameborder="0" scrolling="no" src="http://hits.sinajs.cn/A1/weiboshare.html?' + temp.join('&') + '" width="'+ _w+'" height="'+_h+'"></iframe>')
- })()
- <iframe frameborder="0" scrolling="no" allowtransparency="true" src="https://platform.twitter.com/widgets/tweet_button.1340179658.html#_=1342285864031&amp;count=horizontal&amp;id=twitter-widget-108&amp;lang=en&amp;original_referer=https%3A%2F%2Ftwitter.com%2Fabout%2Fresources%2Fbuttons%23tweet&amp;size=m&amp;text=NodejsAPI&amp;url=http%3A%2F%2Fnodejsapi.cloudfoundry.com%2F" class="twitter-share-button twitter-count-horizontal" style="width: 106px; height: 20px;" title="Twitter Tweet Button"></iframe>
- <iframe src="//www.facebook.com/plugins/like.php?href=http%3A%2F%2Fnodejsapi.cloudfoundry.com%2F&amp;send=false&amp;layout=button_count&amp;show_faces=true&amp;action=like&amp;colorscheme=light&amp;font&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100px; height:21px;" allowTransparency="true"></iframe>
+ })();
.search.show-grid
<input id='searchinput' type='text' data-provide='typeahead' placeholder='type whatever u like' autocomplete='off' />
div.content.show-grid

0 comments on commit 3f6cc0f

Please sign in to comment.
Something went wrong with that request. Please try again.