Show More
@@ -1,83 +1,87 b'' | |||
|
1 | 1 | // # Copyright (C) 2010-2017 RhodeCode GmbH |
|
2 | 2 | // # |
|
3 | 3 | // # This program is free software: you can redistribute it and/or modify |
|
4 | 4 | // # it under the terms of the GNU Affero General Public License, version 3 |
|
5 | 5 | // # (only), as published by the Free Software Foundation. |
|
6 | 6 | // # |
|
7 | 7 | // # This program is distributed in the hope that it will be useful, |
|
8 | 8 | // # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
9 | 9 | // # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
10 | 10 | // # GNU General Public License for more details. |
|
11 | 11 | // # |
|
12 | 12 | // # You should have received a copy of the GNU Affero General Public License |
|
13 | 13 | // # along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
14 | 14 | // # |
|
15 | 15 | // # This program is dual-licensed. If you wish to learn more about the |
|
16 | 16 | // # RhodeCode Enterprise Edition, including its added features, Support services, |
|
17 | 17 | // # and proprietary license terms, please see https://rhodecode.com/licenses/ |
|
18 | 18 | |
|
19 | 19 | /** |
|
20 | 20 | * SmartColorGenerator |
|
21 | 21 | * |
|
22 | 22 | *usage:: |
|
23 | 23 | * var CG = new ColorGenerator(); |
|
24 | 24 | * var col = CG.getColor(key); //returns array of RGB |
|
25 | * 'rgb({0})'.format(col.join(',') | |
|
25 | * CG.asRGB(col) === 'rgb({0})'.format(col.join(',') | |
|
26 | * | |
|
26 | 27 | * |
|
27 | 28 | * @returns {ColorGenerator} |
|
28 | 29 | */ |
|
29 | 30 | |
|
30 | 31 | // TODO: no usages found. Maybe it's time to remove it |
|
31 | 32 | var ColorGenerator = function(){ |
|
32 | 33 | this.GOLDEN_RATIO = 0.618033988749895; |
|
33 | 34 | this.CURRENT_RATIO = 0.22717784590367374; // this can be random |
|
34 | 35 | this.HSV_1 = 0.75;// saturation |
|
35 | 36 | this.HSV_2 = 0.95; |
|
36 | 37 | this.color; |
|
37 | 38 | this.cacheColorMap = {}; |
|
38 | 39 | }; |
|
39 | 40 | |
|
40 | 41 | ColorGenerator.prototype = { |
|
41 | 42 | getColor:function(key){ |
|
42 | 43 | if(this.cacheColorMap[key] !== undefined){ |
|
43 | 44 | return this.cacheColorMap[key]; |
|
44 | 45 | } |
|
45 | 46 | else{ |
|
46 | 47 | this.cacheColorMap[key] = this.generateColor(); |
|
47 | 48 | return this.cacheColorMap[key]; |
|
48 | 49 | } |
|
49 | 50 | }, |
|
51 | asRGB:function(color_tuple) { | |
|
52 | return 'rgb({0})'.format(color_tuple.join(',')); | |
|
53 | }, | |
|
50 | 54 | _hsvToRgb:function(h,s,v){ |
|
51 | 55 | if (s === 0.0) |
|
52 | 56 | return [v, v, v]; |
|
53 | 57 | i = parseInt(h * 6.0); |
|
54 | 58 | f = (h * 6.0) - i; |
|
55 | 59 | p = v * (1.0 - s); |
|
56 | 60 | q = v * (1.0 - s * f); |
|
57 | 61 | t = v * (1.0 - s * (1.0 - f)); |
|
58 | 62 | i = i % 6; |
|
59 | 63 | if (i === 0) |
|
60 | 64 | return [v, t, p]; |
|
61 | 65 | if (i === 1) |
|
62 | 66 | return [q, v, p]; |
|
63 | 67 | if (i === 2) |
|
64 | 68 | return [p, v, t]; |
|
65 | 69 | if (i === 3) |
|
66 | 70 | return [p, q, v]; |
|
67 | 71 | if (i === 4) |
|
68 | 72 | return [t, p, v]; |
|
69 | 73 | if (i === 5) |
|
70 | 74 | return [v, p, q]; |
|
71 | 75 | }, |
|
72 | 76 | generateColor:function(){ |
|
73 | 77 | this.CURRENT_RATIO = this.CURRENT_RATIO+this.GOLDEN_RATIO; |
|
74 | 78 | this.CURRENT_RATIO = this.CURRENT_RATIO %= 1; |
|
75 | 79 | HSV_tuple = [this.CURRENT_RATIO, this.HSV_1, this.HSV_2]; |
|
76 | 80 | RGB_tuple = this._hsvToRgb(HSV_tuple[0],HSV_tuple[1],HSV_tuple[2]); |
|
77 | 81 | function toRgb(v){ |
|
78 | 82 | return ""+parseInt(v*256); |
|
79 | 83 | } |
|
80 | 84 | return [toRgb(RGB_tuple[0]),toRgb(RGB_tuple[1]),toRgb(RGB_tuple[2])]; |
|
81 | 85 | |
|
82 | 86 | } |
|
83 | 87 | }; |
@@ -1,109 +1,125 b'' | |||
|
1 | 1 | <%text> |
|
2 | 2 | <div style="display: none"> |
|
3 | 3 | |
|
4 | 4 | <script id="ejs_gravatarWithUser" type="text/template" class="ejsTemplate"> |
|
5 | 5 | |
|
6 | 6 | <% |
|
7 | 7 | if (size > 16) { |
|
8 | 8 | var gravatar_class = 'gravatar gravatar-large'; |
|
9 | 9 | } else { |
|
10 | 10 | var gravatar_class = 'gravatar'; |
|
11 | 11 | } |
|
12 | 12 | %> |
|
13 | 13 | |
|
14 | 14 | <% |
|
15 | 15 | if (show_disabled) { |
|
16 | 16 | var user_cls = 'user user-disabled'; |
|
17 | 17 | } else { |
|
18 | 18 | var user_cls = 'user'; |
|
19 | 19 | } |
|
20 | 20 | %> |
|
21 | 21 | |
|
22 | 22 | <div class="rc-user"> |
|
23 | 23 | <img class="<%= gravatar_class %>" src="<%- gravatar_url -%>" height="<%= size %>" width="<%= size %>"> |
|
24 | 24 | <span class="<%= user_cls %>"> <%- user_link -%> </span> |
|
25 | 25 | </div> |
|
26 | 26 | |
|
27 | 27 | </script> |
|
28 | 28 | |
|
29 | <script> | |
|
30 | var CG = new ColorGenerator(); | |
|
31 | </script> | |
|
29 | 32 | |
|
30 | 33 | <script id="ejs_reviewMemberEntry" type="text/template" class="ejsTemplate"> |
|
31 | 34 | |
|
32 | 35 | <li id="reviewer_<%= member.user_id %>" class="reviewer_entry"> |
|
33 | <div class="reviewers_member"> | |
|
36 | <% | |
|
37 | ||
|
38 | if (member.user_group && member.user_group.vote_rule) { | |
|
39 | var groupStyle = 'border-left: 1px solid '+CG.asRGB(CG.getColor(member.user_group.vote_rule)); | |
|
40 | } else { | |
|
41 | var groupStyle = 'border-left: 1px solid white'; | |
|
42 | } | |
|
43 | ||
|
44 | %> | |
|
45 | ||
|
46 | <div class="reviewers_member" style="<%= groupStyle%>" > | |
|
34 | 47 | <div class="reviewer_status tooltip" title="<%= review_status_label %>"> |
|
35 | 48 | <div class="flag_status <%= review_status %> pull-left reviewer_member_status"></div> |
|
36 | 49 | </div> |
|
37 | 50 | <div id="reviewer_<%= member.user_id %>_name" class="reviewer_name"> |
|
38 | 51 | <% if (mandatory) { %> |
|
39 | 52 | <div class="reviewer_member_mandatory tooltip" title="Mandatory reviewer"> |
|
40 | 53 | <i class="icon-lock"></i> |
|
41 | 54 | </div> |
|
42 | 55 | <% } %> |
|
43 | 56 | |
|
44 | <%if (member.user_group && member.user_group.vote_rule) {%> | |
|
45 | <div style="float:right"> | |
|
46 | <%if (member.user_group.vote_rule == -1) {%> | |
|
47 | Min votes: ALL | |
|
48 | <%} else {%> | |
|
49 | Min votes: <%= member.user_group.vote_rule %> | |
|
50 | <%}%> | |
|
51 | </div> | |
|
52 | <%}%> | |
|
53 | 57 | <%- |
|
54 | 58 | renderTemplate('gravatarWithUser', { |
|
55 | 59 | 'size': 16, |
|
56 | 60 | 'show_disabled': false, |
|
57 | 61 | 'user_link': member.user_link, |
|
58 | 62 | 'gravatar_url': member.gravatar_link |
|
59 | 63 | }) |
|
60 | 64 | %> |
|
61 | 65 | </div> |
|
62 | 66 | |
|
63 | 67 | <input type="hidden" name="__start__" value="reviewer:mapping"> |
|
64 | 68 | |
|
69 | ||
|
70 | <%if (member.user_group && member.user_group.vote_rule) {%> | |
|
71 | <div class="reviewer_reason"> | |
|
72 | ||
|
73 | <%if (member.user_group.vote_rule == -1) {%> | |
|
74 | - group votes required: ALL | |
|
75 | <%} else {%> | |
|
76 | - group votes required: <%= member.user_group.vote_rule %> | |
|
77 | <%}%> | |
|
78 | </div> | |
|
79 | <%}%> | |
|
80 | ||
|
65 | 81 | <input type="hidden" name="__start__" value="reasons:sequence"> |
|
66 | 82 | <% for (var i = 0; i < reasons.length; i++) { %> |
|
67 | 83 | <% var reason = reasons[i] %> |
|
68 | 84 | <div class="reviewer_reason">- <%= reason %></div> |
|
69 | 85 | <input type="hidden" name="reason" value="<%= reason %>"> |
|
70 | 86 | <% } %> |
|
71 | 87 | <input type="hidden" name="__end__" value="reasons:sequence"> |
|
72 | 88 | |
|
73 | 89 | <input type="hidden" name="__start__" value="rules:sequence"> |
|
74 | 90 | <% for (var i = 0; i < member.rules.length; i++) { %> |
|
75 | 91 | <% var rule = member.rules[i] %> |
|
76 | 92 | <input type="hidden" name="rule_id" value="<%= rule %>"> |
|
77 | 93 | <% } %> |
|
78 | 94 | <input type="hidden" name="__end__" value="rules:sequence"> |
|
79 | 95 | |
|
80 | 96 | <input id="reviewer_<%= member.user_id %>_input" type="hidden" value="<%= member.user_id %>" name="user_id" /> |
|
81 | 97 | <input type="hidden" name="mandatory" value="<%= mandatory %>"/> |
|
82 | 98 | |
|
83 | 99 | <input type="hidden" name="__end__" value="reviewer:mapping"> |
|
84 | 100 | |
|
85 | 101 | <% if (mandatory) { %> |
|
86 | 102 | <div class="reviewer_member_mandatory_remove" style="visibility: hidden;"> |
|
87 | 103 | <i class="icon-remove-sign"></i> |
|
88 | 104 | </div> |
|
89 | 105 | <% } else { %> |
|
90 | 106 | <% if (allowed_to_update) { %> |
|
91 | 107 | <div class="reviewer_member_remove action_button" onclick="reviewersController.removeReviewMember(<%= member.user_id %>, true)" style="visibility: hidden;"> |
|
92 | 108 | <i class="icon-remove-sign" ></i> |
|
93 | 109 | </div> |
|
94 | 110 | <% } %> |
|
95 | 111 | <% } %> |
|
96 | 112 | </div> |
|
97 | 113 | </li> |
|
98 | 114 | |
|
99 | 115 | </script> |
|
100 | 116 | |
|
101 | 117 | |
|
102 | 118 | </div> |
|
103 | 119 | |
|
104 | 120 | <script> |
|
105 | 121 | // registers the templates into global cache |
|
106 | 122 | registerTemplates(); |
|
107 | 123 | </script> |
|
108 | 124 | |
|
109 | </%text> No newline at end of file | |
|
125 | </%text> |
General Comments 0
You need to be logged in to leave comments.
Login now