I'm using Twitter Anywhere to create a Tweet Box on my site. Everything works as expected; but one of the problems with this method is that when the tweet button is pressed but the tweet doesn't go through (like when it's a duplicate tweet, for example), there is no error message or alert; rather, the loading icon just keeps spinning indefinitely. I've been searching all over for a solution, but as far as I can tell, there is no error message callback for this sort of thing through Twitter Anywhere. The best solution I could come up with is to use a setTimeout to alert a message when the tweet doesn't go through within 15 seconds or so.
Something like
.$button.click(function(){
// alert error if not onTweet after 15 seconds
})
I can't figure out where to implement in my block of code. Any thoughts? (You can ignore the ajax submits, they just post the info to the db).
twttr.anywhere(function (T) {
T("#tbox").tweetBox({
height: 131,
width: 249,
defaultContent : genTweet,
counter : true,
label : '',
complete : function (tweetBox) {
me.tweetBox = tweetBox;
try {
me.tweetBox.$editor.attr('maxlength',140);
me.tweetBox.$button.html('Submit');
me.tweetBox.$counter.prepend('<span>Character Count: </span>');
me.tweetBox.$editor.click(function(){
if (me.tweetBox.$counter.children('span').length) {
}
else {
me.tweetBox.$counter.prepend('<span>Character Count: </span>');
};
});
me.tweetBox.$counter.css({
color : '#918e8e',
'font-size' : '8px',
'position': 'absolute',
'right': '12px',
'top': '120px'
});
me.tweetBox.$editor.css({
resize : 'none',
color : '#000',
'font-family': 'Georgia',
'font-size': '15px',
background : 'transparent'
});
me.tweetBox.$button.parent('span').css( {
color : '#fff',
cursor : 'pointer',
'background' : '#ed1c24',
border: '1px solid red',
'font-weight' : 'bold',
padding : '0'
});
me.tweetBox.$button.css( {
color : '#fff',
cursor : 'pointer',
'background' : '#ed1c24',
'font' : 'bold 17px/1em Arial Narrow, Open Sans, sans-serif',
'letter-spacing' : '1px',
'padding' : '10px 12px',
'text-transform' : 'uppercase',
'text-shadow' : '0 0 0 #999'
});
} catch (e) {
//
}
},
onTweet : function (tweet, renderedTweet) {
//alert( "Data Saved: " + renderedTweet );
$.ajax({
type: "POST",
url: "insert.php",
data:{
"tweets":renderedTweet,
"emailForm": $('#email').val()
},
success: function(){
$('#widget-post').ajaxSubmit();
}
});
$('#step-3 .step-content, #steps').slideUp();
$('#thank-you').slideDown();
}
});
$('#step-2 .step-content').slideUp();
$('#step-3 .step-content').slideDown();
});