A Pen by Alex Glover on CodePen.
-
-
Save alexdglover/9e877603b22374640a39cedb33e6a56d to your computer and use it in GitHub Desktop.
oxJgXw
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="container narrow-container";> | |
<div class="row quotes-window"> | |
<div class="row"> | |
<div class="col-lg-1"></div> | |
<div class="col-lg-10 quote-content"> | |
Quotes dude | |
</div> | |
</div> | |
<div class="row"> | |
<div class="col-lg-9"></div> | |
<div class="col-lg-3 quote-author"> | |
Author dude | |
</div> | |
</div><br><br> | |
<div class="row buttons-row"> | |
<div class="col-lg-1"></div> | |
<div class="col-lg-2"> | |
<a href="#" id="twitterWrapper"><button id="twitterBtn" class="btn socialButtons"><i class="icon-twitter"></i></button></a> | |
</div> | |
<div class="col-lg-6"></div> | |
<div class="col-lg-2"> | |
<button id="newQuoteBtn" class="btn btn-default">New Quotes</button> | |
</div> | |
</div> | |
</div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function() { | |
$("#newQuoteBtn").on("click", renderQuote); // End of on click event | |
renderQuote(); | |
function renderQuote(){ | |
$.ajax( { | |
url: 'http://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1', | |
success: function(data) { | |
var post = data.shift(); // The data is an array of posts. Grab the first one. | |
$('.quote-author').text(post.title); | |
$('.quote-content').html(post.content); | |
$('#twitterWrapper').attr("href", "https://twitter.com/intent/tweet?hashtags=quotes&related=freecodecamp&text=" + encodeURIComponent(post.content) + "%20" + encodeURIComponent(post.title)); | |
}, | |
cache: false | |
}); | |
var newColor = '#' + Math.floor(Math.random()*16777215).toString(16); | |
$("body").css("background-color", newColor); | |
$("#newQuoteBtn").css("background-color", newColor); | |
$(".socialButtons").css("background-color", newColor); | |
} | |
});// End of document ready |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script> | |
<script src="//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script> | |
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
background-color:whitesmoke; | |
} | |
.narrow-container { | |
width:50%; | |
margin: 200px auto; | |
} | |
.quotes-window { | |
background-color: white; | |
padding: 20px; | |
} | |
.quote-content { | |
font-size: 36px; | |
} | |
.quote-author { | |
font-style: italic; | |
font-size: 18px; | |
} | |
#newQuoteBtn { | |
color: white; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" /> | |
<link href="http://netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.min.css" rel="stylesheet" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment