GitHubButtons is a fork of the famous github-buttons plugin using the original styles with a complete new javascript part based on MooTools/jQuery without the need of iframes. It's targeted on MooTools/jQuery/PHP-Users which are already using various stuff on their pages - all other users should use the original iframe version to save bandwidth! Demo Page
Just add the JS+CSS files to your page and use the following code to inject a button into a given container
<head> .... <link rel="stylesheet" type="text/css" href="Build/GitHubButtons.yui.css" /> ... </head> <body> ....
window.addEvent('domready', function(){ // create a new button var btn = new GitHubButton({ owner : 'AndiDittrich', repo : 'EnlighterJS', large : true, type : 'star', text : 'Starring:' }); // inject the button into the container (magic toElement() method is called by MooTools) document.id('container1').grab(btn); });
<head> .... <link rel="stylesheet" type="text/css" href="Build/GitHubButtons.yui.css" /> ... </head> <body> ....
jQuery(function(jq){ // create first button into "container1" jq('#container1').GitHubButton({ owner : 'AndiDittrich', repo : 'EnlighterJS', large : true, type : 'star', text : 'Starring:' }); ));
<?php // include GitHubButtons require('Build/GitHubButtons.php'); // create new instance of GitHubButtons using current directory as cache $ghb = new GitHubButtons(__DIR__); ?>
<?php // Stargazers echo $ghb->button(array( 'owner' => 'AndiDittrich', 'repo' => 'EnlighterJS', 'large' => true, 'type' => 'star', 'text' => 'Starring:' )); ?>
A GitHubButton instance can be directly handled as an Element (implements the toElement() method)
Instance Style
var el = new GitHubButton(options);
Element Style
document.id(..).GitHubButton(options);
The jQuery part only supports the commonly used element-style-syntax
Element Style
jQuery(...).GitHubButton(options);
Instance Style
// create new instance of GitHubButtons using current directory as cache $ghb = new GitHubButtons(__DIR__); // create a new button echo $ghb->button(options);
Singleton Style
// initialize GitHubButtons singleton using current directory as cache GitHubButtons::getInstance(__DIR__); // create a new button GitHubButtons::getInstance()->button(options)
The following options can be passed to the constructor/function - used by the MooTools and jQuery verison
GitHub-Buttons for MooTools, jQuery and PHP is released under the Apache 2.0 License
A note on comments here: These comments are moderated. No comments will show up until they are approved. Comments that are not productive (i.e. inflammatory, rude, etc) will not be approved.
Found a bug in this plugin? Please report it this repository's Github Issues.
blog comments powered by Disqus