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