Created
January 4, 2017 17:51
-
-
Save ethanhinson/06beff3fa9b2af1d254854d0ca33e5a4 to your computer and use it in GitHub Desktop.
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
(function ($, tag) { | |
var flickrParams, | |
vimeoParams, | |
apiCalls = []; | |
tag.photosets = null; | |
tag.videos = null; | |
if(opts.flickr && opts.flickr.api_key && opts.flickr.user_id) { | |
flickrParams = { | |
api_key: opts.flickr.api_key, | |
user_id: opts.flickr.user_id, | |
format: 'json', | |
nojsoncallback: 1, | |
primary_photo_extras: 'url_m' | |
}; | |
apiCalls.push($.ajax({ | |
url: "/vms/api/flickr/flickr.photosets.getList?" + $.param(flickrParams) | |
}).done(function (resp) { | |
var ph = JSON.parse(resp); | |
tag.photosets = ph.photosets.photoset; | |
})); | |
} | |
if(opts.vimeo && opts.vimeo.token) { | |
vimeoParams = { | |
Authorization: "Bearer " + opts.vimeo.token | |
}; | |
apiCalls.push($.ajax({ | |
url: "/vms/api/vimeo/", | |
headers: vimeoParams | |
}).done(function (resp) { | |
var vids = JSON.parse(resp); | |
tag.videos = vids.data; | |
})) | |
} | |
if(apiCalls.length) { | |
$.when.apply($, apiCalls).done(function() { | |
tag.update(); | |
}); | |
} | |
})(jQuery, this); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment