A Pen by Aled Wassell on CodePen.
Last active
January 7, 2017 05:11
-
-
Save aledwassell/d983eafadb7a4d6221b31e2efe61be72 to your computer and use it in GitHub Desktop.
Quoter
This file contains hidden or 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> | |
<div class="container"> | |
<div class="jumbotron"> | |
<div class="container"> | |
<div class="text-center"> | |
<h1> | |
Get a Random Quote | |
</h1> | |
</div> | |
<div id="target"> | |
</div> | |
<div class="row"> | |
<div class="col-xs-6 col-sm-6 col-lg-6 col-xl-6"> | |
<button class="btn-primary button" id="twit"> | |
<i class="fa fa-twitter fa-lg" aria-hidden="true"></i> | |
Tweet | |
</button> | |
</div> | |
<div class="col-xs-6 col-sm-6 col-lg-6 col-xl-6 text-right"> | |
<button class="btn-primary button" id="get-quote">Quote Me</button> | |
</div> | |
</div> | |
</div> | |
</div> | |
</div> | |
<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script> | |
<script>window.twttr = (function(d, s, id) { | |
var js, fjs = d.getElementsByTagName(s)[0], | |
t = window.twttr || {}; | |
if (d.getElementById(id)) return t; | |
js = d.createElement(s); | |
js.id = id; | |
js.src = "https://platform.twitter.com/widgets.js"; | |
fjs.parentNode.insertBefore(js, fjs); | |
t._e = []; | |
t.ready = function(f) { | |
t._e.push(f); | |
}; | |
return t; | |
}(document, "script", "twitter-wjs")); | |
</script> | |
</body> |
This file contains hidden or 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(){ | |
function quotes(){ | |
var quoteNow, authorNow; | |
var make = ( data ) => { | |
quoteNow = data.quoteText; | |
authorNow = data.quoteAuthor; | |
$("#target").html( | |
'<h3><i class="fa fa-quote-right fa-2x" aria-hidden="true"></i> ' + quoteNow + ' <i class="fa fa-quote-left fa-2x" aria-hidden="true"></i></h3>' + '</br>' | |
+ '<p>~ ' + authorNow + '</p>' | |
); | |
} | |
$.ajax({ | |
url: "http://api.forismatic.com/api/1.0/?", | |
dataType: "jsonp", | |
data: "method=getQuote&format=jsonp&lang=en&jsonp=?", | |
success: (data) => make(data) | |
}); | |
} | |
function tweet(){ | |
var quote = $("#target").text(); | |
var twit = 'https://twitter.com/intent/tweet?text=' + encodeURIComponent(quote) | |
window.open(twit, '_blank'); | |
} | |
$(() => quotes()); | |
$("#get-quote").on("click", () => quotes()); | |
$("#twit").on("click", () => tweet()); | |
}); | |
// twttr.widgets.createShareButton( | |
// 'http://codepen.io/Alwass89/full/egYMRY/', | |
// document.getElementById('twit'), | |
// { | |
// text: tweet, | |
// size: "large", | |
// hashtags: "coding" | |
// } | |
// ); |
This file contains hidden or 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="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.0/jquery-ui.min.js"></script> |
This file contains hidden or 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
$box-shadow: 0px 2px 6px rgba(0, 0, 0, 0.6) | |
$text: #fff | |
$jumb: #9baec8 | |
$bkgrnd: #d9e1e8 | |
$btn: #2b90d9 | |
body | |
background-color: $bkgrnd | |
.jumbotron | |
margin: 10% auto | |
box-shadow: $box-shadow | |
max-width: 40em | |
background-color: $jumb | |
h1 | |
font-size: 3em | |
color: $text | |
#twit | |
box-shadow: $box-shadow | |
.button | |
border-radius: 5px | |
border: none | |
padding: 5px 12px | |
background-color: $btn | |
box-shadow: $box-shadow | |
#twit | |
// text-align: center | |
// vertical-align: baseline | |
h1, h2, h3, p | |
font-family: Helvetica | |
color: $text | |
This file contains hidden or 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://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" /> | |
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/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