diff options
author | Alexis Metaireau <alexis@notmyidea.org> | 2012-07-09 07:44:38 -0700 |
---|---|---|
committer | Alexis Metaireau <alexis@notmyidea.org> | 2012-07-09 07:44:38 -0700 |
commit | 5c841277a96336f85ce5f5944e92e4ceec2a89f1 (patch) | |
tree | dae04e7396f1f0a3e72d4e4b62545c4030a7193c /syte/static/js/components/github.js | |
parent | 8363d9701c4c5ab794977c37c4428455e68db78b (diff) | |
parent | 0727752c19ddf32acd3623ded81131f0a8233079 (diff) | |
download | pelican-themes-5c841277a96336f85ce5f5944e92e4ceec2a89f1.tar.gz |
Merge pull request #42 from samrat/master
Added new theme, syte
Diffstat (limited to 'syte/static/js/components/github.js')
-rw-r--r-- | syte/static/js/components/github.js | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/syte/static/js/components/github.js b/syte/static/js/components/github.js new file mode 100644 index 0000000..7bad5ea --- /dev/null +++ b/syte/static/js/components/github.js @@ -0,0 +1,46 @@ + +function setupGithub(url, el) { + var href = el.href; + + if ($('#github-profile').length > 0) { + window.location = href; + return; + } + + var params = url.attr('path').split('/').filter(function(w) { + if (w.length) + return true; + return false; + }) + + if (params.length == 1) { + var username = params[0]; + + var spinner = new Spinner(spin_opts).spin(); + $('#github-link').append(spinner.el); + + require(["json!/github/" + username, "text!templates/github-view.html"], + function(github_data, github_view) { + if (github_data.error || github_data.length == 0) { + window.location = href; + return; + } + + var template = Handlebars.compile(github_view); + github_data.user.following_count = numberWithCommas(github_data.user.following_count) + github_data.user.followers_count = numberWithCommas(github_data.user.followers_count) + + $(template(github_data)).modal().on('hidden', function () { + $(this).remove(); + adjustSelection('home-link'); + }) + + spinner.stop(); + + }); + + return; + } + + window.location = href; +} |