Permalink
Browse files

1.2.0 - fixed check for blackness

  • Loading branch information...
1 parent 99cbcc4 commit aa9f9e32474b23149222497fe9ed0199043e60c4 @drnic committed May 6, 2008
View
1 Rakefile
@@ -52,6 +52,7 @@ task :dist do
FileUtils.copy_file "#{APP_NAME}.js", "#{APP_NAME}-#{APP_VERSION}.js"
FileUtils.copy_file "#{APP_BADGE_NAME}.js", "#{APP_BADGE_NAME}-#{APP_VERSION}.js"
end
+ FileUtils.cp_r "src/ext", "dist/ext"
if File.directory?("website")
FileUtils.rm_rf "website/dist" rescue nil
FileUtils.mkdir_p "website/dist"
View
9 src/ext/stylesheets/badge.css
@@ -7,6 +7,7 @@
#github-badge a {
color: #4183c4; /* blue */
+ background-color: white;
text-decoration: none;
}
@@ -44,10 +45,6 @@
background: transparent none repeat scroll 0%;
}
-#github-badge .watching li {
- font-size: 110%;
-}
-
#github-badge .repos img {
padding-right: .2em;
vertical-align: middle;
@@ -58,6 +55,10 @@
background-color: #f0f0f0;
}
+#github-badge .repos .public a {
+ background-color: #f0f0f0;
+}
+
#github-badge .repos .public .description {
margin-left: 18px;
}
View
9 src/ext/stylesheets/black_badge.css
@@ -7,6 +7,7 @@
#github-badge a {
color: #4183c4; /* blue */
+ background-color: black;
text-decoration: none;
}
@@ -44,10 +45,6 @@
background: transparent none repeat scroll 0%;
}
-#github-badge .watching li {
- font-size: 110%;
-}
-
#github-badge .repos img {
padding-right: .2em;
vertical-align: middle;
@@ -58,6 +55,10 @@
background-color: rgb(20,20,20);
}
+#github-badge .repos .public a {
+ background-color: rgb(20,20,20);
+}
+
#github-badge .repos .public .description {
margin-left: 18px;
}
View
6 src/github-badge-launcher.js
@@ -3,8 +3,8 @@ var GitHubBadge = GitHubBadge || {};
GitHubBadge.Launcher = new function() {
function requestStylesheet( url, style_id ) {
if ("jQuery" in window) {
- jQuery('head').append(
- jQuery('<style rel="stylesheet" type="text/css"></style>')
+ jQuery('head').prepend(
+ jQuery('<link rel="stylesheet" type="text/css"></link>')
.attr('href', url)
.attr('id', style_id)
)
@@ -52,7 +52,7 @@ GitHubBadge.Launcher = new function() {
throw("GitHub Badge requires jQuery and jQuery.template");
var is_black = ("GITHUB_THEME" in window && GITHUB_THEME) || 'white';
- if (is_black == 'black' || jQuery('#github-badge').parent().css('background-color') == 'rgb(0, 0, 0)') {
+ if (is_black == 'black' || jQuery.color.almostBlack(jQuery('#github-badge').parent().css('background-color'))) {
requestStylesheet(this.path + 'ext/stylesheets/black_badge.css', 'black_badge');
} else {
requestStylesheet(this.path + 'ext/stylesheets/badge.css', 'badge');
View
3 src/github-badge.js
@@ -0,0 +1,3 @@
+// This file does nothing - it is just for testing where
+// the launcher looks for a github-badge.js file in the same folder
+// as the launcher file.
View
13 test/unit/github-badge-launcher_test.html → ...unctional/github-badge-launcher_test.html
@@ -25,16 +25,11 @@
<script type="text/javascript" charset="utf-8">
GITHUB_USERNAME = 'drnic';
GITHUB_LIST_LENGTH = 5;
- var GitHubBadge = GitHubBadge || {};
- GitHubBadge.buildUserBadgeExecuted = false;
- GitHubBadge.buildUserBadge = function() {
- GitHubBadge.buildUserBadgeExecuted = true;
- };
</script>
<!-- Put sample/test html here -->
<div id="sample">
<div id="github-badge" width="150px"></div>
- <script src="../../src/github-badge-launcher.js" type="text/javascript"></script>
+ <script src="../../dist/github-badge-launcher.js" type="text/javascript"></script>
<script type="text/javascript" charset="utf-8">
GitHubBadge.Launcher.init();
</script>
@@ -50,12 +45,8 @@
assert(jQuery.template, 'jQuery.template not loaded');
}},
- "test that badge built": function() { with(this) {
- assert(GitHubBadge.buildUserBadgeExecuted, 'Badge code was not executed');
- }},
-
"test that badge.css loaded": function() { with(this) {
- var css = $('style#badge');
+ var css = $('link#badge');
assertEqual(1, css.size(), 'No style#badge added');
}},
View
17 ...nit/github_badge_launcher_black_test.html → ...nal/github_badge_launcher_black_test.html
@@ -9,7 +9,7 @@
<link rel="stylesheet" href="../assets/unittest.css" type="text/css" />
<style type="text/css" media="screen">
div#sample {
- background-color: black;
+ background-color: #202020;
}
</style>
</head>
@@ -30,16 +30,11 @@
<script type="text/javascript" charset="utf-8">
GITHUB_USERNAME = 'drnic';
GITHUB_LIST_LENGTH = 5;
- var GitHubBadge = GitHubBadge || {};
- GitHubBadge.buildUserBadgeExecuted = false;
- GitHubBadge.buildUserBadge = function() {
- GitHubBadge.buildUserBadgeExecuted = true;
- };
</script>
<!-- Put sample/test html here -->
<div id="sample">
<div id="github-badge" width="150px"></div>
- <script src="../../src/github-badge-launcher.js" type="text/javascript"></script>
+ <script src="../../dist/github-badge-launcher.js" type="text/javascript"></script>
<script type="text/javascript" charset="utf-8">
GitHubBadge.Launcher.init();
</script>
@@ -60,16 +55,12 @@
assert(jQuery.template, 'jQuery.template not loaded');
}},
- "test that badge built": function() { with(this) {
- assert(GitHubBadge.buildUserBadgeExecuted, 'Badge code was not executed');
- }},
-
"test that background behind badge is black": function() { with(this) {
- assertEqual(black, badge.parent().css('background-color'));
+ assert($.color.almostBlack(badge.parent().css('background-color')));
}},
"test that black_badge.css loaded": function() { with(this) {
- var css = $('style#black_badge');
+ var css = $('link#black_badge');
assertEqual(1, css.size(), 'No style#black_badge added');
}},

0 comments on commit aa9f9e3

Please sign in to comment.