-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Contributors List on the About Dialog #2934
Changes from all commits
9e204b9
ff36310
e36617e
c3eaea7
0600c7f
d82c112
0365cb0
0fca970
5949dd4
0f5c15c
fa22529
ea93581
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,7 @@ | |
|
||
|
||
/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */ | ||
/*global define, $, brackets, window, Mustache */ | ||
/*global define, $, brackets, window, PathUtils, Mustache */ | ||
|
||
define(function (require, exports, module) { | ||
"use strict"; | ||
|
@@ -39,10 +39,32 @@ define(function (require, exports, module) { | |
FileUtils = require("file/FileUtils"), | ||
NativeApp = require("utils/NativeApp"), | ||
StringUtils = require("utils/StringUtils"), | ||
AboutDialogTemplate = require("text!htmlContent/about-dialog.html"); | ||
AboutDialogTemplate = require("text!htmlContent/about-dialog.html"), | ||
ContributorsTemplate = require("text!htmlContent/contributors-list.html"); | ||
|
||
var buildInfo; | ||
|
||
|
||
|
||
/** | ||
* @private | ||
* Gets a data structure that has the information for all the contributors of Brackets. | ||
* The information is fetched from brackets.config.contributors_url using the github API. | ||
* @return {$.Promise} jQuery Promise object that is resolved or rejected after the information is fetched. | ||
*/ | ||
function _getContributorsInformation() { | ||
var result = new $.Deferred(); | ||
|
||
$.getJSON(brackets.config.contributors_url) | ||
.done(function (data) { | ||
result.resolve(data); | ||
}).fail(function () { | ||
result.reject(); | ||
}); | ||
|
||
return result.promise(); | ||
} | ||
|
||
|
||
function _handleCheckForUpdates() { | ||
UpdateNotification.checkForUpdate(true); | ||
} | ||
|
@@ -69,7 +91,46 @@ define(function (require, exports, module) { | |
APP_NAME_ABOUT_BOX : brackets.config.app_name_about, | ||
BUILD_INFO : buildInfo || "" | ||
}, Strings); | ||
|
||
Dialogs.showModalDialogUsingTemplate(Mustache.render(AboutDialogTemplate, templateVars)); | ||
|
||
// Get all the project contributors and add them to the dialog | ||
_getContributorsInformation().done(function (contributorsInfo) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure why this is, but there seems to be a long pause before the About dialog appears now (compared to master). I don't know why that should be, because the fetch of the contributor info is asynchronous, so it shouldn't actually block the dialog from appearing. Are you seeing that at all? If so, any ideas what could be happening? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Long pause seems to be gone. |
||
|
||
// Populate the contributors data | ||
var $dlg = $(".about-dialog.instance"); | ||
var $contributors = $dlg.find(".about-contributors"); | ||
var totalContributors = contributorsInfo.length; | ||
var contributorsCount = 0; | ||
|
||
$contributors.html(Mustache.render(ContributorsTemplate, contributorsInfo)); | ||
|
||
// This is used to create an opacity transition when each image is loaded | ||
$contributors.find("img").one("load", function () { | ||
$(this).css("opacity", 1); | ||
|
||
// Count the contributors loaded and hide the spinner once all are loaded | ||
contributorsCount++; | ||
if (contributorsCount >= totalContributors) { | ||
$dlg.find(".about-spinner").css("display", "none"); | ||
} | ||
}).each(function () { | ||
if (this.complete) { | ||
$(this).trigger("load"); | ||
} | ||
}); | ||
|
||
// Create a link for each contributor image to their github account | ||
$contributors.on("click", "img", function (e) { | ||
var url = $(e.target).data("url"); | ||
if (url) { | ||
// Make sure the URL has a domain that we know about | ||
if (/(^|\.)github\.com$/i.test(PathUtils.parseUrl(url).hostname)) { | ||
NativeApp.openURLInDefaultBrowser(url); | ||
} | ||
} | ||
}); | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yup, there should be a |
||
} | ||
|
||
// Read "build number" SHAs off disk immediately at APP_READY, instead | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{{#.}} | ||
<img class="clickable-link" data-url="{{html_url}}" src="{{avatar_url}}" title="{{login}}" alt="{{login}}" width="30" height="30" /> | ||
{{/.}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be simplified now to just
return $.getJSON(brackets.config.contributors_url)
, I think (in fact, you probably don't really need this function anymore).