[PATCH 06 of 19] autocomplete: increase reuse of gravatar logic
Thomas De Schampheleire
patrickdepinguin at gmail.com
Tue Jun 30 16:43:16 EDT 2015
# HG changeset patch
# User Thomas De Schampheleire <thomas.de.schampheleire at gmail.com>
# Date 1435261054 -7200
# Thu Jun 25 21:37:34 2015 +0200
# Node ID 2bc67e169d2f80e67d9e32df023e4133d8049948
# Parent c3e99ca8affe70759f62658cdbc248eda297ae8f
autocomplete: increase reuse of gravatar logic
By splitting autocompleteGravatar in a first part that returns the core
gravatar html code, we can remove yet some more duplication. Hooray!
diff --git a/kallithea/public/js/base.js b/kallithea/public/js/base.js
--- a/kallithea/public/js/base.js
+++ b/kallithea/public/js/base.js
@@ -1151,11 +1151,16 @@ var autocompleteHighlightMatch = functio
+ "</span>" + full.substring(matchindex + snippet.length);
};
+var gravatar = function(link, size, cssclass) {
+ var elem = '<img alt="gravatar" class="{2}" style="width: {0}px; height: {0}px" src="{1}"/>'.format(size, link, cssclass);
+ if (!link) {
+ elem = '<i class="icon-user {1}" style="font-size: {0}px;"></i>'.format(size, cssclass);
+ }
+ return elem;
+}
+
var autocompleteGravatar = function(res, link, size, group) {
- var elem = '<img alt="gravatar" class="perm-gravatar-ac" style="width: {0}px; height: {0}px" src="{1}"/>'.format(size, link);
- if (!link) {
- elem = '<i class="icon-user perm-gravatar-ac" style="font-size: {0}px;"></i>'.format(size);
- }
+ var elem = gravatar(link, size, "perm-gravatar-ac");
if (group !== undefined) {
elem = '<i class="perm-gravatar-ac icon-users"></i>';
}
@@ -1433,9 +1438,7 @@ var MentionsAutoComplete = function (div
var addReviewMember = function(id,fname,lname,nname,gravatar_link,gravatar_size){
var displayname = "{0} {1}".format(fname, lname);
- var gravatarelm = '<img alt="gravatar" style="width: {0}px; height: {0}px" src="{1}"/>'.format(gravatar_size, gravatar_link);
- if (!gravatar_link)
- gravatarelm = '<i class="icon-user" style="font-size: {0}px;"></i>'.format(gravatar_size);
+ var gravatarelm = gravatar(gravatar_link, gravatar_size, "");
// WARNING: the HTML below is duplicate with
// kallithea/templates/pullrequests/pullrequest_show.html
// If you change something here it should be reflected in the template too.
More information about the kallithea-general
mailing list