How to add like button in fancybox? - fancybox

I'm loading some photo by FancyBox & I need to load some widget of one social net(VKontakte(Russian Facebook)).
How can I add to load "Like Button" script in FancyBox?

You can add like this
$(".fancylink").fancybox({
'titlePosition': 'over',
'titleFormat': function() {
return '<span id="fancybox-title-over"><script src="http:\/\/
connect.facebook.net\/en_US\/all.js#xfbml=1"><\/script><fb:like
href="http:\/\/www.google.com" layout="button_count"
show_faces="false" width="450"></fb:like></span>';
}

Related

How can I submit two forms with one button? CodeIgniter

CODEIGNITER
I want to submit two forms with one button. if a radio button is not checked i only submit the first form, but when i check the radio button appear more information (second form). I want to submit the 2 forms when the radio button is selected.
The problem is that it´s only submiting form 1 even when the radio button is checked.
<script>
submitForms = function(){
if(document.getElementById('tipo').checked) {
document.getElementById("form2").submit();
document.getElementById("form1").submit();
}else{
document.getElementById("form1").submit();
}
}
</script>
This is a native JavaScript solution:
<script>
document.addEventListener("DOMContentLoaded", function (event) {
document.getElementById("myButton").addEventListener("click", function () {
console.log(document.getElementById("form1").value);
if (document.getElementById("tipo").checked) {
console.log(document.getElementById("form2").value);
}
});
});
</script>
You might also take a look at javascript Submit multiple forms with one button

FB share plain text without URL link

I want to share plain text from my web to Facebook without a URL link, I have read the Facebook API, and I found that if I want to share the plain text I must input them to the share page, and Facebook cannot get the text automatically.
Is my conclusion correct?If I am wrong, what should I do? Thanks a lot!
<script>
function fbs_click() {
u = location.href;
t = document.title;
window.open('http://www.facebook.com/sharer.php?u=' + encodeURIComponent(u) + '&t=' + encodeURIComponent(t), 'sharer', 'toolbar=0,status=0,width=626,height=436');
return false; }
</script>
<a rel="nofollow" href="http://www.facebook.com/share.php?u=<;url>" onclick="return fbs_click()" target="_blank">Share on Facebook</a>
see : https://spigotdesign.com/text-only-facebook-share-link/

How create a Facebook share button without SDK or custom app id?

I am looking at the latest update to Facebook's share button.
It seems that it's no longer possible to include a share button in a website without including the Facebook javascript SDK, or having a Facebook app somewhere that provides you with an app id?
Share button example 1 uses the Facebook SDK
FB.ui({
method: 'share',
href: 'https://developers.facebook.com/docs/',
}, function(response){});
Share button example 2 uses a custom app id
https://www.facebook.com/dialog/share?
app_id=145634995501895
&display=popup
&href=https%3A%2F%2Fdevelopers.facebook.com%2Fdocs%2F
&redirect_uri=https%3A%2F%2Fdevelopers.facebook.com%2Ftools%2Fexplorer
Question: how to build a plain and simple share button for Facebook with one line of code, that does not require libraries and app id's?
you can use facebook sharer link and a simple popup to do the job
$("#facebookShareLink").on("click",function(){
var fbpopup = window.open("https://www.facebook.com/sharer/sharer.php?u=http://stackoverflow.com", "pop", "width=600, height=400, scrollbars=no");
return false;
});
It is possible. No need for an FB application for a simple sharing of URL. Create a simple pop up window and use Facebook share dialog.
https://developers.facebook.com/docs/sharing/reference/share-dialog
This is still included in their API as of the moment.
window.open("https://www.facebook.com/sharer/sharer.php?u=http://www.gmanetwork.com/news/", "pop", "width=600, height=400, scrollbars=no");
Create function who will center the pop-up every time.
function openURLInPopup(url, width, height, name) {
if (typeof(width) == "undefined") {
width = 800;
height = 600;
}
if (typeof(height) == "undefined") {
height = 600;
}
popup(url, name || 'window' + Math.floor(Math.random() * 10000 + 1), width, height, 'menubar=0,location=0,toolbar=0,status=0,scrollbars=1');
}
Then your link should look like this
For Twitter:
<a class="btn_twitter" onclick="openURLInPopup('http://twitter.com/home?status=http://www.domain.ro/url.html',600, 400); return false;" href="#" target="_blank">Twitter</a>
For facebook:
<a class="btn_fb" onclick="openURLInPopup('http://www.facebook.com/sharer.php?u=http://www.domain.ro/url.html',600, 400); return false;" href="#" target="_blank">Facebook</a>
For Google
<a class="btn_gplus" onclick="openURLInPopup('https://plus.google.com/share?url=http://www.domain.ro/url.html',600, 400); return false;" href="#">gplus</a>
If you want to add your own (possibly dynamic) text, you can add the quote parameter to the link:
https://www.facebook.com/share.php?u=example.com&quote=YOUR+TEXT+HERE

How to call autocomplete select event from outside the function

I have a location search form that uses jQuery UI autocomplete.
When the user starts typing into the input, our list of locations appear as a drop down menu just below the input. If the user clicks one of the locations, the page redirects to the landing page for that location. The user can also click "enter" on the keyboard instead of explicitly clicking on the item.
Here's the probelm. I can't figure out how to get autocomplete to work if the user clicks the SUBMIT button. I'm not allowed to simply remove the submit button because it's a "call to action". The markup & code look like this: (I'm writing this from memory, so it may not be exact)
<form id="locationSearch">
<input type="text" id="enterLocation" />
<input id="goButton "type="submit" value="GO" />
</form>
<script>
var locations = [<br />
{'value': 'Brooklyn', 'url': '/ny/brooklyn/browse'}
{ 'value' : 'Hoboken; , 'url' : /nj/hoboken/browse'}
];
$('#enterLocation').autocomplete({
autoFocus: true,
source: 'locations',
select: event, ui (function() {
window.location.url
});
});
</script>
What I need to do is something like this:
$('#goButton').click(function() {
// trigger automcomplete select
});
Any suggestions are greatly appreciated!
Try using
$('#enterLocation').trigger("autocompleteselect", function(){});

Problem in facebook share functionality

I have a facebook iframe application where i have provided a share functionality. I am using this code :
<script>
function fbs_click()
{
u='<?php echo $shareURL;?>';
t=document.title;
window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
return false;
}
</script>
<style>
html .fb_share_button {
display: -moz-inline-block; display:inline-block;
padding:1px 20px 0 5px; height:15px; border:1px solid #d8dfea;
background:url(http://b.static.ak.fbcdn.net/rsrc.php/z39E0/hash/ya8q506x.gif)
no-repeat top right;
}
html .fb_share_button:hover {
color:#b5b8d3; border-color:#295582; background:#3b5998
url(http://b.static.ak.fbcdn.net/rsrc.php/z39E0/hash/ya8q506x.gif)
no-repeat top right; text-decoration:none;
}
</style>
Share
The problem i am facing is that if i pass u to my site url then inside share box title is properly displayed but when posted to my profile, clicking on the link redirects me to outside of my facebook application which i don't want i want it to remain inside facebook page.
However if i change u parameter to something like http://apps.facebook.com/app/ then inside share box the title is showing apps.facebook.com and when posted on my profile, clicking on it redirects me inside the facebook application but onto a new tab.
I just want the title should be set according to the value passed and if i click on it on my profile page it should remain inside facebook.
I have found a solution to this problem you have to change the parameters in the window.open and pass the value as urlencode(i have done in php)
I am attaching the changed code:
1)
<?php
$title=urlencode('Facebook Share Platform');
$image=urlencode('imagepath');
$summary=urlencode('Check This Out');
$url=urlencode('http://apps.facebook.com/yourapplication');
?>
2)
window.open('http://www.facebook.com/sharer.php?s=100&p[title]=<?php echo $title;?>&p[summary]=<?php echo $summary;?>&p[url]=<?php echo $url; ?>&&p[images][0]=<?php echo $image;?>', 'sharer', 'toolbar=0,status=0,width=626,height=436');
Hope this helps to others who are facing same issue.
Thanks
def fb_share_knob opts={}
opts.each { |k,v| opts[k] = CGI.escape(v) if v.present? }
sharer_url = "http://www.facebook.com/sharer.php?s=100&p[url]=#{ opts[:url] }&p[title]=#{ opts[:title] }&p[summary]=#{ opts[:summary] }&p[images][0]=#{ opts[:image] }"
<<-FB_SHARE_LINK
<script type="text/javascript">
function fbs_click() {
window.open('#{ sharer_url }','sharer','toolbar=0,status=0,width=626,height=436');
return false;
}
</script>
Share on Facebook
FB_SHARE_LINK
end
Ruby code. Image load problem: if the image you'd like to share is on your test server make sure it's accessible from outside of your firewall