Skip to content

Commit

Permalink
Add options to display or hide icons
Browse files Browse the repository at this point in the history
  • Loading branch information
zenorocha committed May 11, 2013
1 parent 6367996 commit 69d16df
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
1 change: 1 addition & 0 deletions assets/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@

.github-box .github-box-header .github-stats .repo-forks {
padding-left: 2px;
border-right: 1px solid #ddd;
}

/* Github Box Content */
Expand Down
2 changes: 1 addition & 1 deletion demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ <h1>jQuery Github</h1>
<script src="../dist/jquery.github.min.js"></script>

<script>
$('[data-repo]').github();
$("[data-repo]").github();
</script>

</body>
Expand Down
31 changes: 30 additions & 1 deletion src/jquery.github.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
var pluginName = "github",
document = window.document,
defaults = {
propertyName: "value"
iconStars: true,
iconForks: true,
iconIssues: false
};

function Plugin( element, options ) {
Expand All @@ -19,6 +21,7 @@
self._name = pluginName;

self.init();
self.displayIcons();
}

// Initializer
Expand All @@ -34,6 +37,31 @@
}
};

// Display or hide icons
Plugin.prototype.displayIcons = function () {
$iconStars = $( ".repo-stars" );
$iconForks = $( ".repo-forks" );
$iconIssues = $( ".repo-issues" );

if ( this.options.iconStars ) {
$iconStars.css( "display", "inline-block" );
} else {
$iconStars.css( "display", "none" );
}

if ( this.options.iconForks ) {
$iconForks.css( "display", "inline-block" );
} else {
$iconForks.css( "display", "none" );
}

if ( this.options.iconIssues ) {
$iconIssues.css( "display", "inline-block" );
} else {
$iconIssues.css( "display", "none" );
}
};

// Apply results to HTML template
Plugin.prototype.applyTemplate = function ( repo ) {
var self = this,
Expand Down Expand Up @@ -110,6 +138,7 @@
<div class='github-stats'> \
<a class='repo-stars' title='Stars' data-icon='7' href='" + repo_url + "/watchers'>" + repo.watchers + "</a> \
<a class='repo-forks' title='Forks' data-icon='f' href='" + repo_url + "/network'>" + repo.forks + "</a> \
<a class='repo-issues' title='Issues' data-icon='i' href='" + repo_url + "/issues'>" + repo.open_issues + "</a> \
</div> \
</div> \
<div class='github-box-content'> \
Expand Down

0 comments on commit 69d16df

Please sign in to comment.