Im trying to add all my social media buttons js into an external js file.
When moved the scrtips over the twitter and google buttons dont output…
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s);
js.id = id;
js.src = "//connect.facebook.net/en_GB/sdk.js#xfbml=1&appId=811917092162618&version=v2.2";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'
));
$(document).ready(function(){
js.src = "https://apis.google.com/js/platform.js"
async defer > {
lang: 'en-GB'
}
//Please call pinit.js only once per page
defer src = "//assets.pinterest.com/js/pinit.js"
});
$(document).ready(function(){
window.twttr = (function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0],
t = window.twttr || {};
if (d.getElementById(id)) return;
js = d.createElement(s);
js.id = id;
js.src = "https://platform.twitter.com/widgets.js";
fjs.parentNode.insertBefore(js, fjs);
t._e = [];
t.ready = function(f) {
t._e.push(f);
};
return t;
}(document, "script", "twitter-wjs"));
});
Is there anything amiss in my code above?
Full external js file is;
/* imgsizer (flexible images for fluid sites) */
var imgSizer = {
Config: {
imgCache: [],
spacer: "/path/to/your/spacer.gif"
},
collate: function(aScope) {
var isOldIE = (document.all && !window.opera && !window.XDomainRequest) ? 1 : 0;
if (isOldIE && document.getElementsByTagName) {
var c = imgSizer;
var imgCache = c.Config.imgCache;
var images = (aScope && aScope.length) ? aScope : document.getElementsByTagName("img");
for (var i = 0; i < images.length; i++) {
images[i].origWidth = images[i].offsetWidth;
images[i].origHeight = images[i].offsetHeight;
imgCache.push(images[i]);
c.ieAlpha(images[i]);
images[i].style.width = "100%";
}
if (imgCache.length) {
c.resize(function() {
for (var i = 0; i < imgCache.length; i++) {
var ratio = (imgCache[i].offsetWidth / imgCache[i].origWidth);
imgCache[i].style.height = (imgCache[i].origHeight * ratio) + "px";
}
});
}
}
},
ieAlpha: function(img) {
var c = imgSizer;
if (img.oldSrc) {
img.src = img.oldSrc;
}
var src = img.src;
img.style.width = img.offsetWidth + "px";
img.style.height = img.offsetHeight + "px";
img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='scale')"
img.oldSrc = src;
img.src = c.Config.spacer;
},
resize: function(func) {
var oldonresize = window.onresize;
if (typeof window.onresize != 'function') {
window.onresize = func;
} else {
window.onresize = function() {
if (oldonresize) {
oldonresize();
}
func();
}
}
}
}
// add twitter bootstrap classes and color based on how many times tag is used
function addTwitterBSClass(thisObj) {
var title = jQuery(thisObj).attr('title');
if (title) {
var titles = title.split(' ');
if (titles[0]) {
var num = parseInt(titles[0]);
if (num > 0)
jQuery(thisObj).addClass('label label-default');
if (num == 2)
jQuery(thisObj).addClass('label label-info');
if (num > 2 && num < 4)
jQuery(thisObj).addClass('label label-success');
if (num >= 5 && num < 10)
jQuery(thisObj).addClass('label label-warning');
if (num >= 10)
jQuery(thisObj).addClass('label label-important');
}
} else
jQuery(thisObj).addClass('label');
return true;
}
// as the page loads, call these scripts
jQuery(document).ready(function($) {
// modify tag cloud links to match up with twitter bootstrap
$("#tag-cloud a").each(function() {
addTwitterBSClass(this);
return true;
});
$("p.tags a").each(function() {
addTwitterBSClass(this);
return true;
});
$("ol.commentlist a.comment-reply-link").each(function() {
$(this).addClass('btn btn-success btn-mini');
return true;
});
$('#cancel-comment-reply-link').each(function() {
$(this).addClass('btn btn-danger btn-mini');
return true;
});
$('article.post').hover(function() {
$('a.edit-post').show();
}, function() {
$('a.edit-post').hide();
});
// Input placeholder text fix for IE
// $('[placeholder]').focus(function() {
// var input = $(this);
// if (input.val() == input.attr('placeholder')) {
// input.val('');
// input.removeClass('placeholder');
// }
// }).blur(function() {
// var input = $(this);
// if (input.val() == '' || input.val() == input.attr('placeholder')) {
// input.addClass('placeholder');
// input.val(input.attr('placeholder'));
// }
// }).blur();
// Prevent submission of empty form
$('[placeholder]').parents('form').submit(function() {
$(this).find('[placeholder]').each(function() {
var input = $(this);
if (input.val() == input.attr('placeholder')) {
input.val('');
}
})
});
// $('#s').focus(function(){
// if( $(window).width() < 940 ){
// $(this).animate({ width: '200px' });
// }
// });
// $('#s').blur(function(){
// if( $(window).width() < 940 ){
// $(this).animate({ width: '100px' });
// }
// });
$('.alert-message').alert();
$('.dropdown-toggle').dropdown();
//overlay on gallery
$('.thumbnail').hover(
function() {
$(this).find('.caption').slideDown(250); //.fadeIn(250)
},
function() {
$(this).find('.caption').slideUp(250); //.fadeOut(205)
}
);
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s);
js.id = id;
js.src = "//connect.facebook.net/en_GB/sdk.js#xfbml=1&appId=811917092162618&version=v2.2";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
< script src = "https://apis.google.com/js/platform.js"
async defer > {
lang: 'en-GB'
}
<!-- Please call pinit.js only once per page -->
defer src = "//assets.pinterest.com/js/pinit.js"
window.twttr = (function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0],
t = window.twttr || {};
if (d.getElementById(id)) return;
js = d.createElement(s);
js.id = id;
js.src = "https://platform.twitter.com/widgets.js";
fjs.parentNode.insertBefore(js, fjs);
t._e = [];
t.ready = function(f) {
t._e.push(f);
};
return t;
}(document, "script", "twitter-wjs"));
});
Its a wordpress site.
EDIT
This post has been reformatted by enclosing the code block in 3 backticks
```
on their own lines.