Skip to content

Commit 4d96358

Browse files
committed
Apply jQuery's core style
1 parent 0362570 commit 4d96358

File tree

1 file changed

+38
-38
lines changed

1 file changed

+38
-38
lines changed

src/jquery.github.js

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
var self = this;
1111

1212
self.element = element;
13-
self.$container = $(element);
14-
self.repo = self.$container.attr("data-repo");
13+
self.$container = $( element );
14+
self.repo = self.$container.attr( "data-repo" );
1515

16-
self.options = $.extend( {}, defaults, options) ;
16+
self.options = $.extend( {}, defaults, options ) ;
1717

1818
self._defaults = defaults;
1919
self._name = pluginName;
@@ -26,82 +26,82 @@
2626
var self = this,
2727
cached = self.getCache();
2828

29-
if (cached !== null) {
30-
self.applyTemplate(JSON.parse(cached));
29+
if ( cached !== null ) {
30+
self.applyTemplate( JSON.parse( cached ) );
3131
}
3232
else {
33-
self.requestData(self.repo);
33+
self.requestData( self.repo );
3434
}
3535
};
3636

3737
// Apply results to HTML template
38-
Plugin.prototype.applyTemplate = function (repo) {
38+
Plugin.prototype.applyTemplate = function ( repo ) {
3939
var self = this,
40-
$widget = self.parseTemplate(repo);
40+
$widget = self.parseTemplate( repo );
4141

42-
$widget.appendTo(self.$container);
42+
$widget.appendTo( self.$container );
4343
};
4444

4545
// Stores repostories in sessionStorage if available
46-
Plugin.prototype.cacheResults = function (result_data) {
46+
Plugin.prototype.cacheResults = function ( result_data ) {
4747
var self = this;
4848

4949
// Cache data
50-
if (window.sessionStorage) {
51-
window.sessionStorage.setItem("gh-repos:" + self.repo, JSON.stringify(result_data));
50+
if ( window.sessionStorage ) {
51+
window.sessionStorage.setItem( "gh-repos:" + self.repo, JSON.stringify( result_data ) );
5252
}
5353
};
5454

5555
// Grab cached results
56-
Plugin.prototype.getCache = function () {
56+
Plugin.prototype.getCache = function() {
5757
var self = this;
5858

59-
if (window.sessionStorage) {
60-
return window.sessionStorage.getItem("gh-repos:" + self.repo);
59+
if ( window.sessionStorage ) {
60+
return window.sessionStorage.getItem( "gh-repos:" + self.repo );
6161
}
6262
else {
6363
return false;
6464
}
6565
};
6666

6767
// Handle Errors requests
68-
Plugin.prototype.handlerErrorRequests = function (result_data) {
68+
Plugin.prototype.handlerErrorRequests = function ( result_data ) {
6969
var self = this;
7070

71-
console.warn(result_data.message);
71+
console.warn( result_data.message );
7272
return;
7373
};
7474

7575
// Handle Successful request
76-
Plugin.prototype.handlerSuccessfulRequest = function (result_data) {
76+
Plugin.prototype.handlerSuccessfulRequest = function ( result_data ) {
7777
var self = this;
7878

79-
self.applyTemplate(result_data);
80-
self.cacheResults(result_data);
79+
self.applyTemplate( result_data );
80+
self.cacheResults( result_data );
8181
};
8282

8383
// Parses Pushed date with date format
84-
Plugin.prototype.parsePushedDate = function (pushed_at) {
84+
Plugin.prototype.parsePushedDate = function ( pushed_at ) {
8585
var self = this,
86-
date = new Date(pushed_at);
86+
date = new Date( pushed_at );
8787

88-
return date.getDate() + "/" + (date.getMonth() + 1) + "/" + date.getFullYear();
88+
return date.getDate() + "/" + ( date.getMonth() + 1 ) + "/" + date.getFullYear();
8989
};
9090

9191
// Parses repository URL to be friendly
92-
Plugin.prototype.parseRepositoryURL = function (url) {
92+
Plugin.prototype.parseRepositoryURL = function ( url ) {
9393
var self = this;
9494

95-
return url.replace("api.","").replace("repos/","");
95+
return url.replace( "api.", "" ).replace( "repos/", "" );
9696
};
9797

9898
// Parses HTML template
99-
Plugin.prototype.parseTemplate = function (repo) {
99+
Plugin.prototype.parseTemplate = function ( repo ) {
100100
var self = this,
101-
pushed_at = self.parsePushedDate(repo.pushed_at),
102-
repo_url = self.parseRepositoryURL(repo.url);
101+
pushed_at = self.parsePushedDate( repo.pushed_at ),
102+
repo_url = self.parseRepositoryURL( repo.url );
103103

104-
return $($.parseHTML(" \
104+
return $( $.parseHTML(" \
105105
<div class='github-box'> \
106106
<div class='github-box-header'> \
107107
<h3> \
@@ -120,36 +120,36 @@
120120
<a class='repo-download' href='" + repo_url + "'/zipball/master'>Download as zip</a> \
121121
</div> \
122122
</div> \
123-
"));
123+
") );
124124
};
125125

126126
// Request repositories from Github
127-
Plugin.prototype.requestData = function (repo) {
127+
Plugin.prototype.requestData = function ( repo ) {
128128
var self = this;
129129

130130
$.ajax({
131131
url: "https://api.github.com/repos/" + repo,
132132
dataType: "jsonp",
133-
success: function(results) {
133+
success: function( results ) {
134134
var result_data = results.data;
135135

136136
// Handle API failures
137-
if (results.meta.status >= 400 && result_data.message) {
137+
if ( results.meta.status >= 400 && result_data.message ) {
138138
self.handlerErrorRequest();
139139
}
140140
else {
141-
self.handlerSuccessfulRequest(result_data);
141+
self.handlerSuccessfulRequest( result_data );
142142
}
143143
}
144144
});
145145
};
146146

147-
$.fn[pluginName] = function ( options ) {
147+
$.fn[ pluginName ] = function ( options ) {
148148
return this.each(function () {
149-
if (!$.data(this, "plugin_" + pluginName)) {
150-
$.data(this, "plugin_" + pluginName, new Plugin( this, options ));
149+
if ( !$.data( this, "plugin_" + pluginName ) ) {
150+
$.data( this, "plugin_" + pluginName, new Plugin( this, options ) );
151151
}
152152
});
153153
};
154154

155-
}(jQuery, window));
155+
}( jQuery, window ) );

0 commit comments

Comments
 (0)