Skip to content

Commit 69d16df

Browse files
committed
Add options to display or hide icons
1 parent 6367996 commit 69d16df

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

assets/base.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@
9393

9494
.github-box .github-box-header .github-stats .repo-forks {
9595
padding-left: 2px;
96+
border-right: 1px solid #ddd;
9697
}
9798

9899
/* Github Box Content */

demo/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ <h1>jQuery Github</h1>
3838
<script src="../dist/jquery.github.min.js"></script>
3939

4040
<script>
41-
$('[data-repo]').github();
41+
$("[data-repo]").github();
4242
</script>
4343

4444
</body>

src/jquery.github.js

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
var pluginName = "github",
44
document = window.document,
55
defaults = {
6-
propertyName: "value"
6+
iconStars: true,
7+
iconForks: true,
8+
iconIssues: false
79
};
810

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

2123
self.init();
24+
self.displayIcons();
2225
}
2326

2427
// Initializer
@@ -34,6 +37,31 @@
3437
}
3538
};
3639

40+
// Display or hide icons
41+
Plugin.prototype.displayIcons = function () {
42+
$iconStars = $( ".repo-stars" );
43+
$iconForks = $( ".repo-forks" );
44+
$iconIssues = $( ".repo-issues" );
45+
46+
if ( this.options.iconStars ) {
47+
$iconStars.css( "display", "inline-block" );
48+
} else {
49+
$iconStars.css( "display", "none" );
50+
}
51+
52+
if ( this.options.iconForks ) {
53+
$iconForks.css( "display", "inline-block" );
54+
} else {
55+
$iconForks.css( "display", "none" );
56+
}
57+
58+
if ( this.options.iconIssues ) {
59+
$iconIssues.css( "display", "inline-block" );
60+
} else {
61+
$iconIssues.css( "display", "none" );
62+
}
63+
};
64+
3765
// Apply results to HTML template
3866
Plugin.prototype.applyTemplate = function ( repo ) {
3967
var self = this,
@@ -110,6 +138,7 @@
110138
<div class='github-stats'> \
111139
<a class='repo-stars' title='Stars' data-icon='7' href='" + repo_url + "/watchers'>" + repo.watchers + "</a> \
112140
<a class='repo-forks' title='Forks' data-icon='f' href='" + repo_url + "/network'>" + repo.forks + "</a> \
141+
<a class='repo-issues' title='Issues' data-icon='i' href='" + repo_url + "/issues'>" + repo.open_issues + "</a> \
113142
</div> \
114143
</div> \
115144
<div class='github-box-content'> \

0 commit comments

Comments
 (0)