function show_modal() {
    $("#post_tweet").addClass("is-active");

    // If the post tweet button was hit, access the twitter api, and post the input tweet.
    $("#post_tweet_btn").unbind().click(function() {
    	$("#post_tweet_btn").prop("disabled", true);	// Disable the button to avoid a dulicate tweet/error.
    	$("#post_tweet_btn").addClass("is-loading");	// Show the button as loading.
    	
    	// Send the POST request to the twitter api to post the tweet.
    	$.post("scripts/php/post_tweet.php", {tweet: $("#status").val()}, function(response) {
    		// Parse the response from the API.
    		json = JSON.parse(response);
    	}).then(function() {
    		// When the request has finished, check for errors, and handle them accordingly.
    		if(json.hasOwnProperty("errors")) {
    			$("#post_err").html(json.errors[0].message);
    			$("#post_tweet_btn").prop("disabled", false);
	    		$("#post_tweet_btn").removeClass("is-loading");
    		}else {
	    		$("#post_tweet_btn").prop("disabled", false);
	    		$("#post_tweet_btn").removeClass("is-loading");
	    		$("#status").val("");
	    		$("#post_err").html("");
	    		hide_modal();
    		}
    	});
    });
}
/*
* This function will show the modal for the tweet posting functionality, and will post the input tweet.
*/
This function will show the modal for the tweet posting functionality, and will post the input tweet.
This function will show the modal for the tweet posting functionality and will post the input tweet .
function show_modal() {
    $("#post_tweet").addClass("is-active");
    $("#post_tweet_btn").unbind().click(function() {
    	$("#post_tweet_btn").prop("disabled", true);	
    	$("#post_tweet_btn").addClass("is-loading");	
    	$.post("scripts/php/post_tweet.php", {tweet: $("#status").val()}, function(response) {
    		json = JSON.parse(response);
    	}).then(function() {
    		if(json.hasOwnProperty("errors")) {
    			$("#post_err").html(json.errors[0].message);
    			$("#post_tweet_btn").prop("disabled", false);
	    		$("#post_tweet_btn").removeClass("is-loading");
    		}else {
	    		$("#post_tweet_btn").prop("disabled", false);
	    		$("#post_tweet_btn").removeClass("is-loading");
	    		$("#status").val("");
	    		$("#post_err").html("");
	    		hide_modal();
    		}
    	});
    });
}
function show_modal ( ) { $ ( "#post_tweet" ) . addClass ( "is-active" ) ; $ ( "#post_tweet_btn" ) . unbind ( ) . click ( function ( ) { $ ( "#post_tweet_btn" ) . prop ( "disabled" , true ) ; $ ( "#post_tweet_btn" ) . addClass ( "is-loading" ) ; $ . post ( "scripts/php/post_tweet.php" , { tweet : $ ( "#status" ) . val ( ) } , function ( response ) { json = JSON . parse ( response ) ; } ) . then ( function ( ) { if ( json . hasOwnProperty ( "errors" ) ) { $ ( "#post_err" ) . html ( json . errors [ 0 ] . message ) ; $ ( "#post_tweet_btn" ) . prop ( "disabled" , false ) ; $ ( "#post_tweet_btn" ) . removeClass ( "is-loading" ) ; } else { $ ( "#post_tweet_btn" ) . prop ( "disabled" , false ) ; $ ( "#post_tweet_btn" ) . removeClass ( "is-loading" ) ; $ ( "#status" ) . val ( "" ) ; $ ( "#post_err" ) . html ( "" ) ; hide_modal ( ) ; } } ) ; } ) ; }
This function will show the modal for the tweet posting functionality, and will post the input tweet.
This function will show the modal for the tweet posting functionality and will post the input tweet .
// If the post tweet button was hit, access the twitter api, and post the input tweet. // Disable the button to avoid a dulicate tweet/error. // Show the button as loading. // Send the POST request to the twitter api to post the tweet. // Parse the response from the API. // When the request has finished, check for errors, and handle them accordingly.