Check if a tweet completely done or user close the popup - javascript

I am working on a web app using AngularJs as front-end and Laravel as back-end
In many views I have sharing bar with tweet button, I managed to add a share button using twitter javascript widget
twttr.widgets.createShareButton(
'https://dev.twitter.com/',
document.getElementById('tw'),
{
count: 'none',
text: 'Sharing a URL using the Tweet Button'
}
).then(function (el) {
console.log("Button created.", el);
});
and also I managed to detect the click event on this twitter share button via
twttr.events.bind(
'tweet',
function (event) {
console.log('tweeet', event);
}
);
but this event fires if user clicked on tweet button even if he just closed the popup and didn't tweet !!
I found this thread https://twittercommunity.com/t/need-to-check-if-user-tweet-like-retweet-post-successfully-using-js-intent/61432 on twitter community but it has been since Feb,2015 I hope there is something new after more than one year !
Is there anyway to track a complete successful tweet!!
Thanks in advance.

Related

how to prevent window back button and close tab with javascript

now im doing laravel project. i want to implement javascript code only for preventing the back button and close tab window. i read the article that we can use onbeforeunload(). but this code not suitable with me. because the warning message will display when i want to go to another link menu on my site..
here is my code
window.onbeforeunload = function() {
return "Do you really want to leave?";
};
above code still have problem to me :
i must click at list 1 time on the side. then click close tab, so the pop up will display. if i dont click, the pop up not display and directly close the tab.
im using opera browser but the custom message not display same as what i type. it display "Changes you made may not be saved.". How do i could display the sentence as same as i type?
is there any other code that just prevent only for back button and close the tab? so went i want to navigate to other link menu on my site, the warning message not display.
please help
//you should $event.return = "";
window.addEventListener("beforeunload", function ($event) {
return $event.returnValue = "";
})

how to display an icon in meteor on click of link

How to set viewed icon on click of a link in meteor. I have a list jobs page and when user clicks on one job it is going to the description page and what I want is display an icon on the post which tells user that he or she viewed the post.
Try to use this:
Template.yourTemplate.events({
'click .viewed'(event, instance) {
event.preventDefault();
instance.$('youriconReference').show();
},
});

Exit Feedback Popup when someone click on tab "x"

Can someone help me with a JavaScript code to show an exit popup when someone clicks on tab "x" to leave that specific page/or website only. (not asking about intent exit pop up). I need to take the userfeedback on my order form to find out if he is happy with the prices. I want to integrate it with contact form 7. Using wordpress. Asking it after 5 hours of search around web.
Thorough help is appreciated.
You can use the beforeunload event (https://developer.mozilla.org/fr/docs/Web/Events/beforeunload) :
$(window).on('beforeunload', function () {
alert('Exit site')
});
You can use the beforeunload event to show a form
$(window).on('beforeunload', function () {
$('.feedbackform').show();
});
on close of the feedbackform you close the page

Phantomjs does not see twitter/facebook authorization page

I am testing adding a twitter/facebook account feature from our website. On clicking the 'connect to twitter' button from my website, we get redirected (using oauth for verification and authorization) to twitter api to grant access etc. From my casper test module, after clicking the 'connect to twitter' button, I saw from a screenshot that phantomjs is still there on my current website page and does not go the actual twitter api page. Can anybody help me here ?
Script snippet:
exports.addAccount = function(options) {
this.navToAddService(); //custom function to navigate to particular page
casper.then(function() {
this.click('#add_twitter'); //this is the id of the button 'connect to twitter'
}).then(function() {
this.echo(this.getCurrentUrl());
});
};
How about changing your code to use waitForSelector() before trying to click on the button:
exports.addAccount = function(options) {
this.navToAddService(); //custom function to navigate to particular page
casper.waitForSelector('#add_twitter', function() {
this.click('#add_twitter'); //this is the id of the button 'connect to twitter'
}).then(function() {
this.echo(this.getCurrentUrl());
});
};
This bypasses any potential timing issues with asynchronous code. (E.g. I'm guessing navToAddService() is adding the button that you are then trying to click.)
If you get a time-out you know the button is never appearing, and can start troubleshooting that more specific problem.
Similarly, instead of using then() you could use waitForUrl() with the name of the URL you are expecting.

Link to fancybox content

Not quite sure how to explain this the best way, but i'll give it a go!
I have a php site that uses Fancybox. At the moment, if anyone clicks Login, an overlay appears with the login form. If someone clicks to post a new listing and they're not logged in, I'd like the fancybox overlay to appear again, allowing a user to login.
At the moment, I have a couple lines of php code that check if a session is active - if not, it redirects to a login page, I want this to activate a fancybox popup with the login form... if possible?
I'm not sure how best to achieve this? Any help would be awesome! :)
I'm not sure what programing language you are writing in besides jQuery, but a high-level solution might be to drop a cookie when the user logs in. Then, when they click to post a new listing, check for that cookie. If it's there, let them post. If not show the login window. Here's some pseudo code using the jQuery.Cookie plugin:
$(function(){
$('.login-button').click(function(){
//send login info via ajax
$(this).hide("slow",function(){
// drop a cookie
$.cookie( 'login', '1', { expires: 1, path: '/' } );
});
});
// When the post button is clicked, check for the cookie
// If there's no cookie, show the login box
$('.post-button').click(function(){
if( $.cookie('Login') === null ) {
$("#login-box").fancybox();
} else {
// do nothing
}
});
});
There can be multiple ways of doing so.
First of all, how are you identifying that someone is logged in? Suppose if I can do so with an if condition:
if(user==null) {
//no login
}
I can trigger the click of anchor link for LOGIN and thus, open the fancybox again.
if(user==null) {
$("a#login").trigger('click');
}
Hope it gives you some help.

Categories

Resources