Facebook feed iframe lazy loading - facebook

For performance purposes, I'm looking for a way to lazy load the fan page feed from facebook to my site.
As this feed is visible after user interaction (click), I was wondering if , rather than implementing the
<fb:fan profile_id="XXXXXX" href="http://www.facebook.com/XXXX.XXX" width="292" show_faces="0" stream="true" height="390px" header="false" css="XXX"></fb:fan>
tag in my markup (while being invisible ti the user), I could by any means request the facebook servers to build the iframe and it's content on demand ?

If you can use an iframe instead of XFBML, do this using jQuery (jsFiddle):
$(document).ready(function()
{
$('#container_for_fb_box').append($('<iframe>')
.attr({
'src': "http://www.facebook.com/plugins/likebox.php?href=http%3A%2F%2Fwww.facebook.com%2Fplatform&width=292&colorscheme=light&show_faces=false&stream=true&header=false&height=395",
'scrolling': 'no',
'allowTransparency': 'true'
})
.css({
'border':'none',
'overflow': 'hidden',
'width': '292px',
'height': '395px'
})
);
});

An example setting the title with the URL instead of the src so that jquery can dynamically set the the src with the required URL to load the iframe.
//Trying to load the URL dynamically did not work for me
//hence using the title as a workaround
<iframe id="facebookFrame" title="http://www.facebook.com/plugins/likebox.php?href=http%3A%2F%2Fwww.facebook.com%2Fpages%xxxxxx%xxxxxx&width=300&colorscheme=light&show_faces=true&border_color&stream=true&header=true&height=590" scrolling="no" frameborder="0" style="border: none; overflow: hidden; width: 300px; height: 590px;"></iframe>
//on click
$("#yourButton").click(function(event) {
$("#facebookFrame").attr("src", $("#facebookFrame").attr("title"));
$("#facebookFrame").removeAttr("title");
});
//using a timer to load the iframe after 2 seconds
window.setTimeout(function() {
$("#facebookFrame").attr("src", $("#facebookFrame").attr("title"));
$("#facebookFrame").removeAttr("title");
}, 2000);
//on user scroll
$(window).bind("scroll", function(event) {
$("#facebookFrame").attr("src", $("#facebookFrame").attr("title"));
$("#facebookFrame").removeAttr("title");
});

Related

Global footer in Ionic

It seems impossible to create a global footer in an Ionic app.
Within a single page, you can use <ion-footer> and in turn, the <ion-content> component resizes itself using its resize() function, accounting for contained headers and footers, and global <ion-tab> allowing for tabs.
Having a <ion-footer> in app.html will not resize the content accordingly, causing for the footer to overlay the content.
Before I submit a pull request to the Ionic Framework's Content.resize method, does anyone know of a way to achieve a global footer?
If you know the height of the footer, you can style the .ion-page height to calc(100% - #{$global-footer-height}).
Example where global footer can be toggled on/off:
app.component.ts
#HostBinding('class.has-global-footer') public globalFooterEnabled: boolean = true;
constructor(platform: Platform, statusBar: StatusBar) {
// You can toggle the footer from a Service or something.
setTimeout(() => this.globalFooterEnabled = false, 5000);
// myService.somethingHappened$
.subscribe((toggle) => this.globalFooterEnabled = toggle);
}
app.html at the end:
<ion-footer class="global-footer" *ngIf="globalFooterEnabled">
Hello World!
</ion-footer>
app.scss
$global-footer-height: 50px;
.has-global-footer .ion-page {
height: calc(100% - #{$global-footer-height});
}
.global-footer {
height: $global-footer-height;
}

FB app into Tab not getting more than 520px width

I'm testing an app and when not on a page's tab it's fine. I need it to be wider than 520px.
First of all, this is the html's code for setting the proper height.
window.fbAsyncInit = function () {
FB.init({
appId: '1428427990741852',
status: true,
cookie: true,
xfbml: true
});
FB.Canvas.setSize({ height: 1100 });
};
// Load the FB SDK Asynchronously
(function (d) {
var js, id = 'facebook-jssdk'; if (d.getElementById(id)) { return; }
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
d.getElementsByTagName('head')[0].appendChild(js);
} (document));
That's OK, the height is properly set as you can see is the app's iframe
<iframe class="smart_sizing_iframe noresize" frameborder="0" scrolling="yes" id="iframe_canvas" name="iframe_canvas_fb_https" src='javascript:""' height="1100" webkitallowfullscreen="" mozallowfullscreen="" oallowfullscreen="" msallowfullscreen="" allowfullscreen="" style="height: 1100px;"></iframe>
Now, if we check that same iframe after the app is loaded inside a page (as a tab), here's the result.
<iframe name="app_runner_fb_https53cc3ca1018792924747227" id="app_runner_fb_https53cc3ca1018792924747227" style="width: 520px; height: 1100px;" frameborder="0" src="https://s-static.ak.facebook.com/platform/page_proxy/hv09mZVdEP8.js#app_runner_fb_https53cc3ca1018792924747227" class="noresize"></iframe>
As you can see, there's the 520px width automatically set.
I have tried changing the Canvas Fixed Width property to YES so the app's width is set to 760px but I'm still getting a 520px width.
Also, I've tried forcing the width's px right in the code FB.Canvas.setSize({ width:760, height: 1100 }); but still, it's stucked in 520px.
Here you can see the app, alone by itself and as a tab.
Thanks.
TAB
Alone
PS. Not sure if this is of value but I'm using fbootstrap which has a 760/520px grid system but that I assume has nothing to do with fb's iframe itself.
Check the settings of the Page Tab in the App Settings, where you added it as "Platform" (https://developers.facebook.com/apps/[your-app-id]/settings/). There is a switch with the following text: "Wide Page Tab?" Switch that one to "YES" and your Tab should be 810px.

Add Pinterest Button to Fancybox title

I found this script online that add a pin it button to fancybox v2. Here is the working example:
http://scottgale.com/blogsamples/fancybox-pinterest/index.html
Im working on a site on the Hubspot CMS. For those who are familiar, Fancybox 1.3.4 comes included with Hubspot. And you really don't get editing access to any of the files or scripts associated with it.
The Fancybox works as a gallery module (or widget) so users can just upload images.
I was wondering if there is a way to modify this original script to work with how fancybox 1 is implemented on my site.
Here is my page:
http://www.signdealz.com/gallery-test/
Here is the script:
<script type="text/javascript">
//NOTE: this uses fancybox 2
$(document).ready(function() {
$('.fancybox').fancybox({
//set the next and previous effects so that they make sense
//the elastic method is confusing to the user
nextEffect: 'fade',
prevEffect: 'fade',
//set the position of the title
helpers : {
title: {
// title position options:
// 'float', 'inside', 'outside' or 'over'
type: 'inside'
}
},
beforeShow: function () {
//if you already have titles
//on your fancybox you can append
if(this.title) {
//set description to current title
//this will set what posts
var description = this.title;
//add pinterest button for title
this.title = '<a href="http://pinterest.com/pin/create/button/?url='+
encodeURIComponent(document.location.href)+
'&media='+
//put the path to the image you want to share here
encodeURIComponent('http://scottgale.com/blogsamples/fancybox-pinterest/'+this.href)+
'&description='+description+'" class="pin-it-button" count-layout="horizontal">'+
'<img border="0" src="http://assets.pinterest.com/images/PinExt.png" title="Pin It" align="absmiddle"/></a>'
//add title information
+'<span>'+this.title+'</span>';
//if you don't already have titles
//you can just make the title the pinterest button
} else {
//add pinterest button for title
this.title = '<a href="http://pinterest.com/pin/create/button/?url='+
encodeURIComponent(document.location.href)+
'&media=http%3A%2F%2Fwww.homesburlingtonvermont.com'+
encodeURIComponent(this.href)+
'&description=Pin from ScottGale.com" class="pin-it-button" count-layout="horizontal">'+
'<img border="0" src="http://assets.pinterest.com/images/PinExt.png" title="Pin It" /></a>';
}
}
});
});
</script>
Any help is greatly appreciated!
This is an example of how to add the Pinterest button to your fancybox's (v1.3.4) title using the options titlePosition and titleFormat. If your anchor has a title then it will be displayed along the button, otherwise the button will be displayed alone.
This script is based on the script your found for v2.x but tweaking to options for v1.3.4.
$(".fancybox").fancybox({
"titlePosition": "inside",
"titleFormat": function () {
return this.title ?
'<div class="myPint" style="height: 26px"><a href="http://pinterest.com/pin/create/button/?url='+
encodeURIComponent(document.location.href)+
'&media='+
encodeURIComponent('http://scottgale.com/blogsamples/fancybox-pinterest/'+this.href)+
'&description='+this.title+'" class="pin-it-button" count-layout="horizontal">'+
'<img border="0" src="http://assets.pinterest.com/images/PinExt.png" title="Pin It" align="absmiddle"/></a>'+
'<span>'+this.title+'</span></div>'
:
'<div class="myPint" style="height: 26px"><a href="http://pinterest.com/pin/create/button/?url='+
encodeURIComponent(document.location.href)+
'&media=http%3A%2F%2Fwww.homesburlingtonvermont.com'+
encodeURIComponent(this.href)+
'&description=Pin from ScottGale.com" class="pin-it-button" count-layout="horizontal">'+
'<img border="0" src="http://assets.pinterest.com/images/PinExt.png" title="Pin It" /></a>'+
'<span> </span></div>'
}
});
See JSFIDDLE
NOTE : this is for fancybox v1.3.4
EDIT (Jan 30, 2014) :
New JSFIDDLE using CDN for fancybox files to avoid possible 403 forbidden errors while serving the files from fancybox.net server.

GeoJSON map fails to display in .Net MVC2 view

The JavaScript worked just fine when I was running it in a straight HTML page on a local server. But, when I moved it to the .aspx page it no longer displays. Firebug shows no script errors and I know the map data is loading because it lists the attributes on the page properly. But, the map itself does not display. The zoom icon typically in the corner does not display either, the element is left untouched. It didn't work in IE either.
Here is the code for the initialization, it calls when the window loads.
function init() {
var map = new OpenLayers.Map('map', {
allOverlays: true
});
countries = new OpenLayers.Layer.Vector("Countries", {
protocol: new OpenLayers.Protocol.HTTP({
url: "../../Content/simplify3.geojson",
format: new OpenLayers.Format.GeoJSON({
extractAttributes: true,
visibility: true
})
}),
strategies: [new OpenLayers.Strategy.Fixed()]
});
map.addLayer(countries);
select = new OpenLayers.Control.SelectFeature(countries,
{ multiple: true, toggle: true });
countries.events.on({
"featureselected": onFeatureSelect,
"featureunselected": onFeatureUnselect,
"loadend": populateList
});
map.addControl(select);
select.activate();
map.zoomToMaxExtent();
}
The map should go here:
<div id="map" style="width: 800px; height: 400px; border: 2px solid black;">There Should Be A Map Here!</div>
Any thoughts other than shooting the damn thing?

Webview in bottom of page

I am making an app and i want to have the facebook "Like" button in the bottom of a page.
Is it even possible? I have played around with different things and this is what i have right now.
var win = Ti.UI.currentWindow;
win.showNavBar(); // Force the navbar to show
var bgImage = Ti.UI.createImageView({
height : 'auto',
top : -11,
image : 'images/h-4.jpg',
zIndex : 0
});
win.add(bgImage);
var ticksterImage = Ti.UI.createImageView({
height : 'auto',
top : 1,
image : 'images/takida.png',
zIndex : 0
});
win.add(ticksterImage);
var facelike = Ti.UI.createWebView({
html: '<iframe src="//www.facebook.com/plugins/like.php?href=https%3A%2F%2Fwww.facebook.com%2Ftakidamusic&send=false&layout=standard&width=320&show_faces=true&action=like&colorscheme=dark&font&height=80&appId=368268836546636" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:320px; height:80px;" allowTransparency="true"></iframe>',
height: '80dp',
bottom: 1,
});
win.add(facelike);
Am i going about this wrong? Should i have HTML5 or XFBML instead of iframe? I have tried all three but with no result.
I just get: Error loading app://www.facebook.com/plugins/like.php?href=https%3A%2F%2Fwww.facebook.com%2Ftakidamusic&send=false&layout=standard&width=320&show_faces=true&action=like&colorscheme=dark&font&height=80&appId=234826439948817
Is it another way of doing this?
Thanx
//R
— asked 6 hours ago by Rickard Harrysson
I'd recommend not using a webview for it - try using the Ti.Facebook module. That will give you a lot more flexability in allowing the user to login to Facebook via Titanium. See the KitchenSink for examples.
https://github.com/appcelerator/titanium_mobile/blob/master/demos/KitchenSink/Resources/examples/facebook.js
If you must use a website, the html must be a full webpage, not just the iframe. It should start with <html><head/><body>. I recommend creating a webpage outside of Titanium that works, then plug the html of that page in the html property.