Created
February 25, 2013 20:01
-
-
Save bdalziel/5032765 to your computer and use it in GitHub Desktop.
Simple JS for building a DOM tag containing the Pinterest data from the URL and loading the external Pinterest script to parse it.
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
YUI.add("muse-pin-it-button", function (Y) { | |
var isInit = false; | |
var putButtonMarkupOnPage = function () { | |
var urlParams = window.location.search.substr(1) + ""; | |
var params = Y.QueryString.parse(urlParams); | |
var url = params.url; | |
var description = params.description; | |
var media = params.media; | |
Y.one('body').setContent('<a data-pin-config="beside" href="//pinterest.com/pin/create/button/?url=' + url + '&media=' + media + '&description=' + description + '" data-pin-do="buttonPin" ><img src="//assets.pinterest.com/images/pidgets/pin_it_button.png" /></a>'); | |
} | |
var loadExternalPinterestScriptToParsePage = function () { | |
Y.use('pinterestPinit', function (Y1) { | |
Y.log("Pinterest Script Loaded"); | |
}); | |
} | |
Y.PinItButton = { | |
init: function () { | |
if (isInit) { | |
return; | |
} | |
isInit = true; | |
Y.log("Y.PinItButton.init();"); | |
putButtonMarkupOnPage(); | |
loadExternalPinterestScriptToParsePage(); | |
} | |
} | |
}, "0.1", { | |
requires: ["node", "querystring-parse"] | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment