Show More
@@ -1,1740 +1,1740 | |||||
1 | /** |
|
1 | /** | |
2 | RhodeCode JS Files |
|
2 | RhodeCode JS Files | |
3 | **/ |
|
3 | **/ | |
4 |
|
4 | |||
5 | if (typeof console == "undefined" || typeof console.log == "undefined"){ |
|
5 | if (typeof console == "undefined" || typeof console.log == "undefined"){ | |
6 | console = { log: function() {} } |
|
6 | console = { log: function() {} } | |
7 | } |
|
7 | } | |
8 |
|
8 | |||
9 |
|
9 | |||
10 | var str_repeat = function(i, m) { |
|
10 | var str_repeat = function(i, m) { | |
11 | for (var o = []; m > 0; o[--m] = i); |
|
11 | for (var o = []; m > 0; o[--m] = i); | |
12 | return o.join(''); |
|
12 | return o.join(''); | |
13 | }; |
|
13 | }; | |
14 |
|
14 | |||
15 | /** |
|
15 | /** | |
16 | * INJECT .format function into String |
|
16 | * INJECT .format function into String | |
17 | * Usage: "My name is {0} {1}".format("Johny","Bravo") |
|
17 | * Usage: "My name is {0} {1}".format("Johny","Bravo") | |
18 | * Return "My name is Johny Bravo" |
|
18 | * Return "My name is Johny Bravo" | |
19 | * Inspired by https://gist.github.com/1049426 |
|
19 | * Inspired by https://gist.github.com/1049426 | |
20 | */ |
|
20 | */ | |
21 | String.prototype.format = function() { |
|
21 | String.prototype.format = function() { | |
22 |
|
22 | |||
23 | function format() { |
|
23 | function format() { | |
24 | var str = this; |
|
24 | var str = this; | |
25 | var len = arguments.length+1; |
|
25 | var len = arguments.length+1; | |
26 | var safe = undefined; |
|
26 | var safe = undefined; | |
27 | var arg = undefined; |
|
27 | var arg = undefined; | |
28 |
|
28 | |||
29 | // For each {0} {1} {n...} replace with the argument in that position. If |
|
29 | // For each {0} {1} {n...} replace with the argument in that position. If | |
30 | // the argument is an object or an array it will be stringified to JSON. |
|
30 | // the argument is an object or an array it will be stringified to JSON. | |
31 | for (var i=0; i < len; arg = arguments[i++]) { |
|
31 | for (var i=0; i < len; arg = arguments[i++]) { | |
32 | safe = typeof arg === 'object' ? JSON.stringify(arg) : arg; |
|
32 | safe = typeof arg === 'object' ? JSON.stringify(arg) : arg; | |
33 | str = str.replace(RegExp('\\{'+(i-1)+'\\}', 'g'), safe); |
|
33 | str = str.replace(RegExp('\\{'+(i-1)+'\\}', 'g'), safe); | |
34 | } |
|
34 | } | |
35 | return str; |
|
35 | return str; | |
36 | } |
|
36 | } | |
37 |
|
37 | |||
38 | // Save a reference of what may already exist under the property native. |
|
38 | // Save a reference of what may already exist under the property native. | |
39 | // Allows for doing something like: if("".format.native) { /* use native */ } |
|
39 | // Allows for doing something like: if("".format.native) { /* use native */ } | |
40 | format.native = String.prototype.format; |
|
40 | format.native = String.prototype.format; | |
41 |
|
41 | |||
42 | // Replace the prototype property |
|
42 | // Replace the prototype property | |
43 | return format; |
|
43 | return format; | |
44 |
|
44 | |||
45 | }(); |
|
45 | }(); | |
46 |
|
46 | |||
47 | String.prototype.strip = function(char) { |
|
47 | String.prototype.strip = function(char) { | |
48 | if(char === undefined){ |
|
48 | if(char === undefined){ | |
49 | char = '\\s'; |
|
49 | char = '\\s'; | |
50 | } |
|
50 | } | |
51 | return this.replace(new RegExp('^'+char+'+|'+char+'+$','g'), ''); |
|
51 | return this.replace(new RegExp('^'+char+'+|'+char+'+$','g'), ''); | |
52 | } |
|
52 | } | |
53 | String.prototype.lstrip = function(char) { |
|
53 | String.prototype.lstrip = function(char) { | |
54 | if(char === undefined){ |
|
54 | if(char === undefined){ | |
55 | char = '\\s'; |
|
55 | char = '\\s'; | |
56 | } |
|
56 | } | |
57 | return this.replace(new RegExp('^'+char+'+'),''); |
|
57 | return this.replace(new RegExp('^'+char+'+'),''); | |
58 | } |
|
58 | } | |
59 | String.prototype.rstrip = function(char) { |
|
59 | String.prototype.rstrip = function(char) { | |
60 | if(char === undefined){ |
|
60 | if(char === undefined){ | |
61 | char = '\\s'; |
|
61 | char = '\\s'; | |
62 | } |
|
62 | } | |
63 | return this.replace(new RegExp(''+char+'+$'),''); |
|
63 | return this.replace(new RegExp(''+char+'+$'),''); | |
64 | } |
|
64 | } | |
65 |
|
65 | |||
66 |
|
66 | |||
67 | if(!Array.prototype.indexOf) { |
|
67 | if(!Array.prototype.indexOf) { | |
68 | Array.prototype.indexOf = function(needle) { |
|
68 | Array.prototype.indexOf = function(needle) { | |
69 | for(var i = 0; i < this.length; i++) { |
|
69 | for(var i = 0; i < this.length; i++) { | |
70 | if(this[i] === needle) { |
|
70 | if(this[i] === needle) { | |
71 | return i; |
|
71 | return i; | |
72 | } |
|
72 | } | |
73 | } |
|
73 | } | |
74 | return -1; |
|
74 | return -1; | |
75 | }; |
|
75 | }; | |
76 | } |
|
76 | } | |
77 |
|
77 | |||
78 | // IE(CRAP) doesn't support previousElementSibling |
|
78 | // IE(CRAP) doesn't support previousElementSibling | |
79 | var prevElementSibling = function( el ) { |
|
79 | var prevElementSibling = function( el ) { | |
80 | if( el.previousElementSibling ) { |
|
80 | if( el.previousElementSibling ) { | |
81 | return el.previousElementSibling; |
|
81 | return el.previousElementSibling; | |
82 | } else { |
|
82 | } else { | |
83 | while( el = el.previousSibling ) { |
|
83 | while( el = el.previousSibling ) { | |
84 | if( el.nodeType === 1 ) return el; |
|
84 | if( el.nodeType === 1 ) return el; | |
85 | } |
|
85 | } | |
86 | } |
|
86 | } | |
87 | } |
|
87 | } | |
88 |
|
88 | |||
89 |
|
89 | |||
90 |
|
90 | |||
91 |
|
91 | |||
92 | /** |
|
92 | /** | |
93 | * SmartColorGenerator |
|
93 | * SmartColorGenerator | |
94 | * |
|
94 | * | |
95 | *usage:: |
|
95 | *usage:: | |
96 | * var CG = new ColorGenerator(); |
|
96 | * var CG = new ColorGenerator(); | |
97 | * var col = CG.getColor(key); //returns array of RGB |
|
97 | * var col = CG.getColor(key); //returns array of RGB | |
98 | * 'rgb({0})'.format(col.join(',') |
|
98 | * 'rgb({0})'.format(col.join(',') | |
99 | * |
|
99 | * | |
100 | * @returns {ColorGenerator} |
|
100 | * @returns {ColorGenerator} | |
101 | */ |
|
101 | */ | |
102 | var ColorGenerator = function(){ |
|
102 | var ColorGenerator = function(){ | |
103 | this.GOLDEN_RATIO = 0.618033988749895; |
|
103 | this.GOLDEN_RATIO = 0.618033988749895; | |
104 | this.CURRENT_RATIO = 0.22717784590367374 // this can be random |
|
104 | this.CURRENT_RATIO = 0.22717784590367374 // this can be random | |
105 | this.HSV_1 = 0.75;//saturation |
|
105 | this.HSV_1 = 0.75;//saturation | |
106 | this.HSV_2 = 0.95; |
|
106 | this.HSV_2 = 0.95; | |
107 | this.color; |
|
107 | this.color; | |
108 | this.cacheColorMap = {}; |
|
108 | this.cacheColorMap = {}; | |
109 | }; |
|
109 | }; | |
110 |
|
110 | |||
111 | ColorGenerator.prototype = { |
|
111 | ColorGenerator.prototype = { | |
112 | getColor:function(key){ |
|
112 | getColor:function(key){ | |
113 | if(this.cacheColorMap[key] !== undefined){ |
|
113 | if(this.cacheColorMap[key] !== undefined){ | |
114 | return this.cacheColorMap[key]; |
|
114 | return this.cacheColorMap[key]; | |
115 | } |
|
115 | } | |
116 | else{ |
|
116 | else{ | |
117 | this.cacheColorMap[key] = this.generateColor(); |
|
117 | this.cacheColorMap[key] = this.generateColor(); | |
118 | return this.cacheColorMap[key]; |
|
118 | return this.cacheColorMap[key]; | |
119 | } |
|
119 | } | |
120 | }, |
|
120 | }, | |
121 | _hsvToRgb:function(h,s,v){ |
|
121 | _hsvToRgb:function(h,s,v){ | |
122 | if (s == 0.0) |
|
122 | if (s == 0.0) | |
123 | return [v, v, v]; |
|
123 | return [v, v, v]; | |
124 | i = parseInt(h * 6.0) |
|
124 | i = parseInt(h * 6.0) | |
125 | f = (h * 6.0) - i |
|
125 | f = (h * 6.0) - i | |
126 | p = v * (1.0 - s) |
|
126 | p = v * (1.0 - s) | |
127 | q = v * (1.0 - s * f) |
|
127 | q = v * (1.0 - s * f) | |
128 | t = v * (1.0 - s * (1.0 - f)) |
|
128 | t = v * (1.0 - s * (1.0 - f)) | |
129 | i = i % 6 |
|
129 | i = i % 6 | |
130 | if (i == 0) |
|
130 | if (i == 0) | |
131 | return [v, t, p] |
|
131 | return [v, t, p] | |
132 | if (i == 1) |
|
132 | if (i == 1) | |
133 | return [q, v, p] |
|
133 | return [q, v, p] | |
134 | if (i == 2) |
|
134 | if (i == 2) | |
135 | return [p, v, t] |
|
135 | return [p, v, t] | |
136 | if (i == 3) |
|
136 | if (i == 3) | |
137 | return [p, q, v] |
|
137 | return [p, q, v] | |
138 | if (i == 4) |
|
138 | if (i == 4) | |
139 | return [t, p, v] |
|
139 | return [t, p, v] | |
140 | if (i == 5) |
|
140 | if (i == 5) | |
141 | return [v, p, q] |
|
141 | return [v, p, q] | |
142 | }, |
|
142 | }, | |
143 | generateColor:function(){ |
|
143 | generateColor:function(){ | |
144 | this.CURRENT_RATIO = this.CURRENT_RATIO+this.GOLDEN_RATIO; |
|
144 | this.CURRENT_RATIO = this.CURRENT_RATIO+this.GOLDEN_RATIO; | |
145 | this.CURRENT_RATIO = this.CURRENT_RATIO %= 1; |
|
145 | this.CURRENT_RATIO = this.CURRENT_RATIO %= 1; | |
146 | HSV_tuple = [this.CURRENT_RATIO, this.HSV_1, this.HSV_2] |
|
146 | HSV_tuple = [this.CURRENT_RATIO, this.HSV_1, this.HSV_2] | |
147 | RGB_tuple = this._hsvToRgb(HSV_tuple[0],HSV_tuple[1],HSV_tuple[2]); |
|
147 | RGB_tuple = this._hsvToRgb(HSV_tuple[0],HSV_tuple[1],HSV_tuple[2]); | |
148 | function toRgb(v){ |
|
148 | function toRgb(v){ | |
149 | return ""+parseInt(v*256) |
|
149 | return ""+parseInt(v*256) | |
150 | } |
|
150 | } | |
151 | return [toRgb(RGB_tuple[0]),toRgb(RGB_tuple[1]),toRgb(RGB_tuple[2])]; |
|
151 | return [toRgb(RGB_tuple[0]),toRgb(RGB_tuple[1]),toRgb(RGB_tuple[2])]; | |
152 |
|
152 | |||
153 | } |
|
153 | } | |
154 | } |
|
154 | } | |
155 |
|
155 | |||
156 |
|
156 | |||
157 |
|
157 | |||
158 |
|
158 | |||
159 |
|
159 | |||
160 | /** |
|
160 | /** | |
161 | * GLOBAL YUI Shortcuts |
|
161 | * GLOBAL YUI Shortcuts | |
162 | */ |
|
162 | */ | |
163 | var YUC = YAHOO.util.Connect; |
|
163 | var YUC = YAHOO.util.Connect; | |
164 | var YUD = YAHOO.util.Dom; |
|
164 | var YUD = YAHOO.util.Dom; | |
165 | var YUE = YAHOO.util.Event; |
|
165 | var YUE = YAHOO.util.Event; | |
166 | var YUQ = YAHOO.util.Selector.query; |
|
166 | var YUQ = YAHOO.util.Selector.query; | |
167 |
|
167 | |||
168 | // defines if push state is enabled for this browser ? |
|
168 | // defines if push state is enabled for this browser ? | |
169 | var push_state_enabled = Boolean( |
|
169 | var push_state_enabled = Boolean( | |
170 | window.history && window.history.pushState && window.history.replaceState |
|
170 | window.history && window.history.pushState && window.history.replaceState | |
171 | && !( /* disable for versions of iOS before version 4.3 (8F190) */ |
|
171 | && !( /* disable for versions of iOS before version 4.3 (8F190) */ | |
172 | (/ Mobile\/([1-7][a-z]|(8([abcde]|f(1[0-8]))))/i).test(navigator.userAgent) |
|
172 | (/ Mobile\/([1-7][a-z]|(8([abcde]|f(1[0-8]))))/i).test(navigator.userAgent) | |
173 | /* disable for the mercury iOS browser, or at least older versions of the webkit engine */ |
|
173 | /* disable for the mercury iOS browser, or at least older versions of the webkit engine */ | |
174 | || (/AppleWebKit\/5([0-2]|3[0-2])/i).test(navigator.userAgent) |
|
174 | || (/AppleWebKit\/5([0-2]|3[0-2])/i).test(navigator.userAgent) | |
175 | ) |
|
175 | ) | |
176 | ); |
|
176 | ); | |
177 |
|
177 | |||
178 | var _run_callbacks = function(callbacks){ |
|
178 | var _run_callbacks = function(callbacks){ | |
179 | if (callbacks !== undefined){ |
|
179 | if (callbacks !== undefined){ | |
180 | var _l = callbacks.length; |
|
180 | var _l = callbacks.length; | |
181 | for (var i=0;i<_l;i++){ |
|
181 | for (var i=0;i<_l;i++){ | |
182 | var func = callbacks[i]; |
|
182 | var func = callbacks[i]; | |
183 | if(typeof(func)=='function'){ |
|
183 | if(typeof(func)=='function'){ | |
184 | try{ |
|
184 | try{ | |
185 | func(); |
|
185 | func(); | |
186 | }catch (err){}; |
|
186 | }catch (err){}; | |
187 | } |
|
187 | } | |
188 | } |
|
188 | } | |
189 | } |
|
189 | } | |
190 | } |
|
190 | } | |
191 |
|
191 | |||
192 | /** |
|
192 | /** | |
193 | * Partial Ajax Implementation |
|
193 | * Partial Ajax Implementation | |
194 | * |
|
194 | * | |
195 | * @param url: defines url to make partial request |
|
195 | * @param url: defines url to make partial request | |
196 | * @param container: defines id of container to input partial result |
|
196 | * @param container: defines id of container to input partial result | |
197 | * @param s_call: success callback function that takes o as arg |
|
197 | * @param s_call: success callback function that takes o as arg | |
198 | * o.tId |
|
198 | * o.tId | |
199 | * o.status |
|
199 | * o.status | |
200 | * o.statusText |
|
200 | * o.statusText | |
201 | * o.getResponseHeader[ ] |
|
201 | * o.getResponseHeader[ ] | |
202 | * o.getAllResponseHeaders |
|
202 | * o.getAllResponseHeaders | |
203 | * o.responseText |
|
203 | * o.responseText | |
204 | * o.responseXML |
|
204 | * o.responseXML | |
205 | * o.argument |
|
205 | * o.argument | |
206 | * @param f_call: failure callback |
|
206 | * @param f_call: failure callback | |
207 | * @param args arguments |
|
207 | * @param args arguments | |
208 | */ |
|
208 | */ | |
209 | function ypjax(url,container,s_call,f_call,args){ |
|
209 | function ypjax(url,container,s_call,f_call,args){ | |
210 | var method='GET'; |
|
210 | var method='GET'; | |
211 | if(args===undefined){ |
|
211 | if(args===undefined){ | |
212 | args=null; |
|
212 | args=null; | |
213 | } |
|
213 | } | |
214 |
|
214 | |||
215 | // Set special header for partial ajax == HTTP_X_PARTIAL_XHR |
|
215 | // Set special header for partial ajax == HTTP_X_PARTIAL_XHR | |
216 | YUC.initHeader('X-PARTIAL-XHR',true); |
|
216 | YUC.initHeader('X-PARTIAL-XHR',true); | |
217 |
|
217 | |||
218 | // wrapper of passed callback |
|
218 | // wrapper of passed callback | |
219 | var s_wrapper = (function(o){ |
|
219 | var s_wrapper = (function(o){ | |
220 | return function(o){ |
|
220 | return function(o){ | |
221 | YUD.get(container).innerHTML=o.responseText; |
|
221 | YUD.get(container).innerHTML=o.responseText; | |
222 | YUD.setStyle(container,'opacity','1.0'); |
|
222 | YUD.setStyle(container,'opacity','1.0'); | |
223 | //execute the given original callback |
|
223 | //execute the given original callback | |
224 | if (s_call !== undefined){ |
|
224 | if (s_call !== undefined){ | |
225 | s_call(o); |
|
225 | s_call(o); | |
226 | } |
|
226 | } | |
227 | } |
|
227 | } | |
228 | })() |
|
228 | })() | |
229 | YUD.setStyle(container,'opacity','0.3'); |
|
229 | YUD.setStyle(container,'opacity','0.3'); | |
230 | YUC.asyncRequest(method,url,{ |
|
230 | YUC.asyncRequest(method,url,{ | |
231 | success:s_wrapper, |
|
231 | success:s_wrapper, | |
232 | failure:function(o){ |
|
232 | failure:function(o){ | |
233 | console.log(o); |
|
233 | console.log(o); | |
234 | YUD.get(container).innerHTML='<span class="error_red">ERROR: {0}</span>'.format(o.status); |
|
234 | YUD.get(container).innerHTML='<span class="error_red">ERROR: {0}</span>'.format(o.status); | |
235 | YUD.setStyle(container,'opacity','1.0'); |
|
235 | YUD.setStyle(container,'opacity','1.0'); | |
236 | }, |
|
236 | }, | |
237 | cache:false |
|
237 | cache:false | |
238 | },args); |
|
238 | },args); | |
239 |
|
239 | |||
240 | }; |
|
240 | }; | |
241 |
|
241 | |||
242 | var ajaxPOST = function(url,postData,success) { |
|
242 | var ajaxPOST = function(url,postData,success) { | |
243 | // Set special header for ajax == HTTP_X_PARTIAL_XHR |
|
243 | // Set special header for ajax == HTTP_X_PARTIAL_XHR | |
244 | YUC.initHeader('X-PARTIAL-XHR',true); |
|
244 | YUC.initHeader('X-PARTIAL-XHR',true); | |
245 |
|
245 | |||
246 | var toQueryString = function(o) { |
|
246 | var toQueryString = function(o) { | |
247 | if(typeof o !== 'object') { |
|
247 | if(typeof o !== 'object') { | |
248 | return false; |
|
248 | return false; | |
249 | } |
|
249 | } | |
250 | var _p, _qs = []; |
|
250 | var _p, _qs = []; | |
251 | for(_p in o) { |
|
251 | for(_p in o) { | |
252 | _qs.push(encodeURIComponent(_p) + '=' + encodeURIComponent(o[_p])); |
|
252 | _qs.push(encodeURIComponent(_p) + '=' + encodeURIComponent(o[_p])); | |
253 | } |
|
253 | } | |
254 | return _qs.join('&'); |
|
254 | return _qs.join('&'); | |
255 | }; |
|
255 | }; | |
256 |
|
256 | |||
257 | var sUrl = url; |
|
257 | var sUrl = url; | |
258 | var callback = { |
|
258 | var callback = { | |
259 | success: success, |
|
259 | success: success, | |
260 | failure: function (o) { |
|
260 | failure: function (o) { | |
261 | alert("error"); |
|
261 | alert("error"); | |
262 | }, |
|
262 | }, | |
263 | }; |
|
263 | }; | |
264 | var postData = toQueryString(postData); |
|
264 | var postData = toQueryString(postData); | |
265 | var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, callback, postData); |
|
265 | var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, callback, postData); | |
266 | return request; |
|
266 | return request; | |
267 | }; |
|
267 | }; | |
268 |
|
268 | |||
269 |
|
269 | |||
270 | /** |
|
270 | /** | |
271 | * tooltip activate |
|
271 | * tooltip activate | |
272 | */ |
|
272 | */ | |
273 | var tooltip_activate = function(){ |
|
273 | var tooltip_activate = function(){ | |
274 | function toolTipsId(){ |
|
274 | function toolTipsId(){ | |
275 | var ids = []; |
|
275 | var ids = []; | |
276 | var tts = YUQ('.tooltip'); |
|
276 | var tts = YUQ('.tooltip'); | |
277 | for (var i = 0; i < tts.length; i++) { |
|
277 | for (var i = 0; i < tts.length; i++) { | |
278 | // if element doesn't not have and id |
|
278 | // if element doesn't not have and id | |
279 | // autogenerate one for tooltip |
|
279 | // autogenerate one for tooltip | |
280 | if (!tts[i].id){ |
|
280 | if (!tts[i].id){ | |
281 | tts[i].id='tt'+((i*100)+tts.length); |
|
281 | tts[i].id='tt'+((i*100)+tts.length); | |
282 | } |
|
282 | } | |
283 | ids.push(tts[i].id); |
|
283 | ids.push(tts[i].id); | |
284 | } |
|
284 | } | |
285 | return ids |
|
285 | return ids | |
286 | }; |
|
286 | }; | |
287 | var myToolTips = new YAHOO.widget.Tooltip("tooltip", { |
|
287 | var myToolTips = new YAHOO.widget.Tooltip("tooltip", { | |
288 | context: [[toolTipsId()],"tl","bl",null,[0,5]], |
|
288 | context: [[toolTipsId()],"tl","bl",null,[0,5]], | |
289 | monitorresize:false, |
|
289 | monitorresize:false, | |
290 | xyoffset :[0,0], |
|
290 | xyoffset :[0,0], | |
291 | autodismissdelay:300000, |
|
291 | autodismissdelay:300000, | |
292 | hidedelay:5, |
|
292 | hidedelay:5, | |
293 | showdelay:20, |
|
293 | showdelay:20, | |
294 | }); |
|
294 | }); | |
295 | }; |
|
295 | }; | |
296 |
|
296 | |||
297 | /** |
|
297 | /** | |
298 | * show more |
|
298 | * show more | |
299 | */ |
|
299 | */ | |
300 | var show_more_event = function(){ |
|
300 | var show_more_event = function(){ | |
301 | YUE.on(YUD.getElementsByClassName('show_more'),'click',function(e){ |
|
301 | YUE.on(YUD.getElementsByClassName('show_more'),'click',function(e){ | |
302 | var el = e.target; |
|
302 | var el = e.target; | |
303 | YUD.setStyle(YUD.get(el.id.substring(1)),'display',''); |
|
303 | YUD.setStyle(YUD.get(el.id.substring(1)),'display',''); | |
304 | YUD.setStyle(el.parentNode,'display','none'); |
|
304 | YUD.setStyle(el.parentNode,'display','none'); | |
305 | }); |
|
305 | }); | |
306 | }; |
|
306 | }; | |
307 |
|
307 | |||
308 |
|
308 | |||
309 | /** |
|
309 | /** | |
310 | * Quick filter widget |
|
310 | * Quick filter widget | |
311 | * |
|
311 | * | |
312 | * @param target: filter input target |
|
312 | * @param target: filter input target | |
313 | * @param nodes: list of nodes in html we want to filter. |
|
313 | * @param nodes: list of nodes in html we want to filter. | |
314 | * @param display_element function that takes current node from nodes and |
|
314 | * @param display_element function that takes current node from nodes and | |
315 | * does hide or show based on the node |
|
315 | * does hide or show based on the node | |
316 | * |
|
316 | * | |
317 | */ |
|
317 | */ | |
318 | var q_filter = function(target,nodes,display_element){ |
|
318 | var q_filter = function(target,nodes,display_element){ | |
319 |
|
319 | |||
320 | var nodes = nodes; |
|
320 | var nodes = nodes; | |
321 | var q_filter_field = YUD.get(target); |
|
321 | var q_filter_field = YUD.get(target); | |
322 | var F = YAHOO.namespace(target); |
|
322 | var F = YAHOO.namespace(target); | |
323 |
|
323 | |||
324 | YUE.on(q_filter_field,'click',function(){ |
|
324 | YUE.on(q_filter_field,'click',function(){ | |
325 | q_filter_field.value = ''; |
|
325 | q_filter_field.value = ''; | |
326 | }); |
|
326 | }); | |
327 |
|
327 | |||
328 | YUE.on(q_filter_field,'keyup',function(e){ |
|
328 | YUE.on(q_filter_field,'keyup',function(e){ | |
329 | clearTimeout(F.filterTimeout); |
|
329 | clearTimeout(F.filterTimeout); | |
330 | F.filterTimeout = setTimeout(F.updateFilter,600); |
|
330 | F.filterTimeout = setTimeout(F.updateFilter,600); | |
331 | }); |
|
331 | }); | |
332 |
|
332 | |||
333 | F.filterTimeout = null; |
|
333 | F.filterTimeout = null; | |
334 |
|
334 | |||
335 | var show_node = function(node){ |
|
335 | var show_node = function(node){ | |
336 | YUD.setStyle(node,'display','') |
|
336 | YUD.setStyle(node,'display','') | |
337 | } |
|
337 | } | |
338 | var hide_node = function(node){ |
|
338 | var hide_node = function(node){ | |
339 | YUD.setStyle(node,'display','none'); |
|
339 | YUD.setStyle(node,'display','none'); | |
340 | } |
|
340 | } | |
341 |
|
341 | |||
342 | F.updateFilter = function() { |
|
342 | F.updateFilter = function() { | |
343 | // Reset timeout |
|
343 | // Reset timeout | |
344 | F.filterTimeout = null; |
|
344 | F.filterTimeout = null; | |
345 |
|
345 | |||
346 | var obsolete = []; |
|
346 | var obsolete = []; | |
347 |
|
347 | |||
348 | var req = q_filter_field.value.toLowerCase(); |
|
348 | var req = q_filter_field.value.toLowerCase(); | |
349 |
|
349 | |||
350 | var l = nodes.length; |
|
350 | var l = nodes.length; | |
351 | var i; |
|
351 | var i; | |
352 | var showing = 0; |
|
352 | var showing = 0; | |
353 |
|
353 | |||
354 | for (i=0;i<l;i++ ){ |
|
354 | for (i=0;i<l;i++ ){ | |
355 | var n = nodes[i]; |
|
355 | var n = nodes[i]; | |
356 | var target_element = display_element(n) |
|
356 | var target_element = display_element(n) | |
357 | if(req && n.innerHTML.toLowerCase().indexOf(req) == -1){ |
|
357 | if(req && n.innerHTML.toLowerCase().indexOf(req) == -1){ | |
358 | hide_node(target_element); |
|
358 | hide_node(target_element); | |
359 | } |
|
359 | } | |
360 | else{ |
|
360 | else{ | |
361 | show_node(target_element); |
|
361 | show_node(target_element); | |
362 | showing+=1; |
|
362 | showing+=1; | |
363 | } |
|
363 | } | |
364 | } |
|
364 | } | |
365 |
|
365 | |||
366 | // if repo_count is set update the number |
|
366 | // if repo_count is set update the number | |
367 | var cnt = YUD.get('repo_count'); |
|
367 | var cnt = YUD.get('repo_count'); | |
368 | if(cnt){ |
|
368 | if(cnt){ | |
369 | YUD.get('repo_count').innerHTML = showing; |
|
369 | YUD.get('repo_count').innerHTML = showing; | |
370 | } |
|
370 | } | |
371 |
|
371 | |||
372 | } |
|
372 | } | |
373 | }; |
|
373 | }; | |
374 |
|
374 | |||
375 | var tableTr = function(cls,body){ |
|
375 | var tableTr = function(cls,body){ | |
376 | var tr = document.createElement('tr'); |
|
376 | var tr = document.createElement('tr'); | |
377 | YUD.addClass(tr, cls); |
|
377 | YUD.addClass(tr, cls); | |
378 |
|
378 | |||
379 |
|
379 | |||
380 | var cont = new YAHOO.util.Element(body); |
|
380 | var cont = new YAHOO.util.Element(body); | |
381 | var comment_id = fromHTML(body).children[0].id.split('comment-')[1]; |
|
381 | var comment_id = fromHTML(body).children[0].id.split('comment-')[1]; | |
382 | tr.id = 'comment-tr-{0}'.format(comment_id); |
|
382 | tr.id = 'comment-tr-{0}'.format(comment_id); | |
383 | tr.innerHTML = '<td class="lineno-inline new-inline"></td>'+ |
|
383 | tr.innerHTML = '<td class="lineno-inline new-inline"></td>'+ | |
384 | '<td class="lineno-inline old-inline"></td>'+ |
|
384 | '<td class="lineno-inline old-inline"></td>'+ | |
385 | '<td>{0}</td>'.format(body); |
|
385 | '<td>{0}</td>'.format(body); | |
386 | return tr; |
|
386 | return tr; | |
387 | }; |
|
387 | }; | |
388 |
|
388 | |||
389 | /** comments **/ |
|
389 | /** comments **/ | |
390 | var removeInlineForm = function(form) { |
|
390 | var removeInlineForm = function(form) { | |
391 | form.parentNode.removeChild(form); |
|
391 | form.parentNode.removeChild(form); | |
392 | }; |
|
392 | }; | |
393 |
|
393 | |||
394 | var createInlineForm = function(parent_tr, f_path, line) { |
|
394 | var createInlineForm = function(parent_tr, f_path, line) { | |
395 | var tmpl = YUD.get('comment-inline-form-template').innerHTML; |
|
395 | var tmpl = YUD.get('comment-inline-form-template').innerHTML; | |
396 | tmpl = tmpl.format(f_path, line); |
|
396 | tmpl = tmpl.format(f_path, line); | |
397 | var form = tableTr('comment-form-inline',tmpl) |
|
397 | var form = tableTr('comment-form-inline',tmpl) | |
398 |
|
398 | |||
399 | // create event for hide button |
|
399 | // create event for hide button | |
400 | form = new YAHOO.util.Element(form); |
|
400 | form = new YAHOO.util.Element(form); | |
401 |
var form_hide_button = new YAHOO.util.Element( |
|
401 | var form_hide_button = new YAHOO.util.Element(YUD.getElementsByClassName('hide-inline-form',null,form)[0]); | |
402 | form_hide_button.on('click', function(e) { |
|
402 | form_hide_button.on('click', function(e) { | |
403 | var newtr = e.currentTarget.parentNode.parentNode.parentNode.parentNode.parentNode; |
|
403 | var newtr = e.currentTarget.parentNode.parentNode.parentNode.parentNode.parentNode; | |
404 | if(YUD.hasClass(newtr.nextElementSibling,'inline-comments-button')){ |
|
404 | if(YUD.hasClass(newtr.nextElementSibling,'inline-comments-button')){ | |
405 | YUD.setStyle(newtr.nextElementSibling,'display',''); |
|
405 | YUD.setStyle(newtr.nextElementSibling,'display',''); | |
406 | } |
|
406 | } | |
407 | removeInlineForm(newtr); |
|
407 | removeInlineForm(newtr); | |
408 | YUD.removeClass(parent_tr, 'form-open'); |
|
408 | YUD.removeClass(parent_tr, 'form-open'); | |
409 |
|
409 | |||
410 | }); |
|
410 | }); | |
411 |
|
411 | |||
412 | return form |
|
412 | return form | |
413 | }; |
|
413 | }; | |
414 |
|
414 | |||
415 | /** |
|
415 | /** | |
416 | * Inject inline comment for on given TR this tr should be always an .line |
|
416 | * Inject inline comment for on given TR this tr should be always an .line | |
417 | * tr containing the line. Code will detect comment, and always put the comment |
|
417 | * tr containing the line. Code will detect comment, and always put the comment | |
418 | * block at the very bottom |
|
418 | * block at the very bottom | |
419 | */ |
|
419 | */ | |
420 | var injectInlineForm = function(tr){ |
|
420 | var injectInlineForm = function(tr){ | |
421 | if(!YUD.hasClass(tr, 'line')){ |
|
421 | if(!YUD.hasClass(tr, 'line')){ | |
422 | return |
|
422 | return | |
423 | } |
|
423 | } | |
424 | var submit_url = AJAX_COMMENT_URL; |
|
424 | var submit_url = AJAX_COMMENT_URL; | |
425 |
var _td = |
|
425 | var _td = YUD.getElementsByClassName('code',null,tr)[0]; | |
426 | if(YUD.hasClass(tr,'form-open') || YUD.hasClass(tr,'context') || YUD.hasClass(_td,'no-comment')){ |
|
426 | if(YUD.hasClass(tr,'form-open') || YUD.hasClass(tr,'context') || YUD.hasClass(_td,'no-comment')){ | |
427 | return |
|
427 | return | |
428 | } |
|
428 | } | |
429 | YUD.addClass(tr,'form-open'); |
|
429 | YUD.addClass(tr,'form-open'); | |
430 | var node = tr.parentNode.parentNode.parentNode.getElementsByClassName('full_f_path')[0]; |
|
430 | var node = YUD.getElementsByClassName('full_f_path',null,tr.parentNode.parentNode.parentNode)[0]; | |
431 | var f_path = YUD.getAttribute(node,'path'); |
|
431 | var f_path = YUD.getAttribute(node,'path'); | |
432 | var lineno = getLineNo(tr); |
|
432 | var lineno = getLineNo(tr); | |
433 | var form = createInlineForm(tr, f_path, lineno, submit_url); |
|
433 | var form = createInlineForm(tr, f_path, lineno, submit_url); | |
434 |
|
434 | |||
435 | var parent = tr; |
|
435 | var parent = tr; | |
436 | while (1){ |
|
436 | while (1){ | |
437 | var n = parent.nextElementSibling; |
|
437 | var n = parent.nextElementSibling; | |
438 | // next element are comments ! |
|
438 | // next element are comments ! | |
439 | if(YUD.hasClass(n,'inline-comments')){ |
|
439 | if(YUD.hasClass(n,'inline-comments')){ | |
440 | parent = n; |
|
440 | parent = n; | |
441 | } |
|
441 | } | |
442 | else{ |
|
442 | else{ | |
443 | break; |
|
443 | break; | |
444 | } |
|
444 | } | |
445 | } |
|
445 | } | |
446 | YUD.insertAfter(form,parent); |
|
446 | YUD.insertAfter(form,parent); | |
447 |
|
447 | |||
448 | var f = YUD.get(form); |
|
448 | var f = YUD.get(form); | |
449 |
|
449 | |||
450 |
var overlay = |
|
450 | var overlay = YUD.getElementsByClassName('overlay',null,f)[0]; | |
451 |
var _form = |
|
451 | var _form = YUD.getElementsByClassName('inline-form',null,f)[0]; | |
452 |
|
452 | |||
453 | form.on('submit',function(e){ |
|
453 | form.on('submit',function(e){ | |
454 | YUE.preventDefault(e); |
|
454 | YUE.preventDefault(e); | |
455 |
|
455 | |||
456 | //ajax submit |
|
456 | //ajax submit | |
457 | var text = YUD.get('text_'+lineno).value; |
|
457 | var text = YUD.get('text_'+lineno).value; | |
458 | var postData = { |
|
458 | var postData = { | |
459 | 'text':text, |
|
459 | 'text':text, | |
460 | 'f_path':f_path, |
|
460 | 'f_path':f_path, | |
461 | 'line':lineno |
|
461 | 'line':lineno | |
462 | }; |
|
462 | }; | |
463 |
|
463 | |||
464 | if(lineno === undefined){ |
|
464 | if(lineno === undefined){ | |
465 | alert('missing line !'); |
|
465 | alert('missing line !'); | |
466 | return |
|
466 | return | |
467 | } |
|
467 | } | |
468 | if(f_path === undefined){ |
|
468 | if(f_path === undefined){ | |
469 | alert('missing file path !'); |
|
469 | alert('missing file path !'); | |
470 | return |
|
470 | return | |
471 | } |
|
471 | } | |
472 |
|
472 | |||
473 | if(text == ""){ |
|
473 | if(text == ""){ | |
474 | return |
|
474 | return | |
475 | } |
|
475 | } | |
476 |
|
476 | |||
477 | var success = function(o){ |
|
477 | var success = function(o){ | |
478 | YUD.removeClass(tr, 'form-open'); |
|
478 | YUD.removeClass(tr, 'form-open'); | |
479 | removeInlineForm(f); |
|
479 | removeInlineForm(f); | |
480 | var json_data = JSON.parse(o.responseText); |
|
480 | var json_data = JSON.parse(o.responseText); | |
481 | renderInlineComment(json_data); |
|
481 | renderInlineComment(json_data); | |
482 | }; |
|
482 | }; | |
483 |
|
483 | |||
484 | if (YUD.hasClass(overlay,'overlay')){ |
|
484 | if (YUD.hasClass(overlay,'overlay')){ | |
485 | var w = _form.offsetWidth; |
|
485 | var w = _form.offsetWidth; | |
486 | var h = _form.offsetHeight; |
|
486 | var h = _form.offsetHeight; | |
487 | YUD.setStyle(overlay,'width',w+'px'); |
|
487 | YUD.setStyle(overlay,'width',w+'px'); | |
488 | YUD.setStyle(overlay,'height',h+'px'); |
|
488 | YUD.setStyle(overlay,'height',h+'px'); | |
489 | } |
|
489 | } | |
490 | YUD.addClass(overlay, 'submitting'); |
|
490 | YUD.addClass(overlay, 'submitting'); | |
491 |
|
491 | |||
492 | ajaxPOST(submit_url, postData, success); |
|
492 | ajaxPOST(submit_url, postData, success); | |
493 | }); |
|
493 | }); | |
494 |
|
494 | |||
495 | setTimeout(function(){ |
|
495 | setTimeout(function(){ | |
496 | // callbacks |
|
496 | // callbacks | |
497 | tooltip_activate(); |
|
497 | tooltip_activate(); | |
498 | MentionsAutoComplete('text_'+lineno, 'mentions_container_'+lineno, |
|
498 | MentionsAutoComplete('text_'+lineno, 'mentions_container_'+lineno, | |
499 | _USERS_AC_DATA, _GROUPS_AC_DATA); |
|
499 | _USERS_AC_DATA, _GROUPS_AC_DATA); | |
500 | var _e = YUD.get('text_'+lineno); |
|
500 | var _e = YUD.get('text_'+lineno); | |
501 | if(_e){ |
|
501 | if(_e){ | |
502 | _e.focus(); |
|
502 | _e.focus(); | |
503 | } |
|
503 | } | |
504 | },10) |
|
504 | },10) | |
505 | }; |
|
505 | }; | |
506 |
|
506 | |||
507 | var deleteComment = function(comment_id){ |
|
507 | var deleteComment = function(comment_id){ | |
508 | var url = AJAX_COMMENT_DELETE_URL.replace('__COMMENT_ID__',comment_id); |
|
508 | var url = AJAX_COMMENT_DELETE_URL.replace('__COMMENT_ID__',comment_id); | |
509 | var postData = {'_method':'delete'}; |
|
509 | var postData = {'_method':'delete'}; | |
510 | var success = function(o){ |
|
510 | var success = function(o){ | |
511 | var n = YUD.get('comment-tr-'+comment_id); |
|
511 | var n = YUD.get('comment-tr-'+comment_id); | |
512 | var root = prevElementSibling(prevElementSibling(n)); |
|
512 | var root = prevElementSibling(prevElementSibling(n)); | |
513 | n.parentNode.removeChild(n); |
|
513 | n.parentNode.removeChild(n); | |
514 |
|
514 | |||
515 | // scann nodes, and attach add button to last one |
|
515 | // scann nodes, and attach add button to last one | |
516 | placeAddButton(root); |
|
516 | placeAddButton(root); | |
517 | } |
|
517 | } | |
518 | ajaxPOST(url,postData,success); |
|
518 | ajaxPOST(url,postData,success); | |
519 | } |
|
519 | } | |
520 |
|
520 | |||
521 | var updateReviewers = function(reviewers_ids){ |
|
521 | var updateReviewers = function(reviewers_ids){ | |
522 | var url = AJAX_UPDATE_PULLREQUEST; |
|
522 | var url = AJAX_UPDATE_PULLREQUEST; | |
523 | var postData = {'_method':'put', |
|
523 | var postData = {'_method':'put', | |
524 | 'reviewers_ids': reviewers_ids}; |
|
524 | 'reviewers_ids': reviewers_ids}; | |
525 | var success = function(o){ |
|
525 | var success = function(o){ | |
526 | window.location.reload(); |
|
526 | window.location.reload(); | |
527 | } |
|
527 | } | |
528 | ajaxPOST(url,postData,success); |
|
528 | ajaxPOST(url,postData,success); | |
529 | } |
|
529 | } | |
530 |
|
530 | |||
531 | var createInlineAddButton = function(tr){ |
|
531 | var createInlineAddButton = function(tr){ | |
532 |
|
532 | |||
533 | var label = TRANSLATION_MAP['add another comment']; |
|
533 | var label = TRANSLATION_MAP['add another comment']; | |
534 |
|
534 | |||
535 | var html_el = document.createElement('div'); |
|
535 | var html_el = document.createElement('div'); | |
536 | YUD.addClass(html_el, 'add-comment'); |
|
536 | YUD.addClass(html_el, 'add-comment'); | |
537 | html_el.innerHTML = '<span class="ui-btn">{0}</span>'.format(label); |
|
537 | html_el.innerHTML = '<span class="ui-btn">{0}</span>'.format(label); | |
538 |
|
538 | |||
539 | var add = new YAHOO.util.Element(html_el); |
|
539 | var add = new YAHOO.util.Element(html_el); | |
540 | add.on('click', function(e) { |
|
540 | add.on('click', function(e) { | |
541 | injectInlineForm(tr); |
|
541 | injectInlineForm(tr); | |
542 | }); |
|
542 | }); | |
543 | return add; |
|
543 | return add; | |
544 | }; |
|
544 | }; | |
545 |
|
545 | |||
546 | var getLineNo = function(tr) { |
|
546 | var getLineNo = function(tr) { | |
547 | var line; |
|
547 | var line; | |
548 | var o = tr.children[0].id.split('_'); |
|
548 | var o = tr.children[0].id.split('_'); | |
549 | var n = tr.children[1].id.split('_'); |
|
549 | var n = tr.children[1].id.split('_'); | |
550 |
|
550 | |||
551 | if (n.length >= 2) { |
|
551 | if (n.length >= 2) { | |
552 | line = n[n.length-1]; |
|
552 | line = n[n.length-1]; | |
553 | } else if (o.length >= 2) { |
|
553 | } else if (o.length >= 2) { | |
554 | line = o[o.length-1]; |
|
554 | line = o[o.length-1]; | |
555 | } |
|
555 | } | |
556 |
|
556 | |||
557 | return line |
|
557 | return line | |
558 | }; |
|
558 | }; | |
559 |
|
559 | |||
560 | var placeAddButton = function(target_tr){ |
|
560 | var placeAddButton = function(target_tr){ | |
561 | if(!target_tr){ |
|
561 | if(!target_tr){ | |
562 | return |
|
562 | return | |
563 | } |
|
563 | } | |
564 | var last_node = target_tr; |
|
564 | var last_node = target_tr; | |
565 | //scann |
|
565 | //scann | |
566 | while (1){ |
|
566 | while (1){ | |
567 | var n = last_node.nextElementSibling; |
|
567 | var n = last_node.nextElementSibling; | |
568 | // next element are comments ! |
|
568 | // next element are comments ! | |
569 | if(YUD.hasClass(n,'inline-comments')){ |
|
569 | if(YUD.hasClass(n,'inline-comments')){ | |
570 | last_node = n; |
|
570 | last_node = n; | |
571 | //also remove the comment button from previos |
|
571 | //also remove the comment button from previous | |
572 |
var comment_add_buttons = |
|
572 | var comment_add_buttons = YUD.getElementsByClassName('add-comment',null,last_node); | |
573 | for(var i=0;i<comment_add_buttons.length;i++){ |
|
573 | for(var i=0;i<comment_add_buttons.length;i++){ | |
574 | var b = comment_add_buttons[i]; |
|
574 | var b = comment_add_buttons[i]; | |
575 | b.parentNode.removeChild(b); |
|
575 | b.parentNode.removeChild(b); | |
576 | } |
|
576 | } | |
577 | } |
|
577 | } | |
578 | else{ |
|
578 | else{ | |
579 | break; |
|
579 | break; | |
580 | } |
|
580 | } | |
581 | } |
|
581 | } | |
582 |
|
582 | |||
583 | var add = createInlineAddButton(target_tr); |
|
583 | var add = createInlineAddButton(target_tr); | |
584 | // get the comment div |
|
584 | // get the comment div | |
585 |
var comment_block = |
|
585 | var comment_block = YUD.getElementsByClassName('comment',null,last_node)[0]; | |
586 | // attach add button |
|
586 | // attach add button | |
587 | YUD.insertAfter(add,comment_block); |
|
587 | YUD.insertAfter(add,comment_block); | |
588 | } |
|
588 | } | |
589 |
|
589 | |||
590 | /** |
|
590 | /** | |
591 | * Places the inline comment into the changeset block in proper line position |
|
591 | * Places the inline comment into the changeset block in proper line position | |
592 | */ |
|
592 | */ | |
593 | var placeInline = function(target_container,lineno,html){ |
|
593 | var placeInline = function(target_container,lineno,html){ | |
594 | var lineid = "{0}_{1}".format(target_container,lineno); |
|
594 | var lineid = "{0}_{1}".format(target_container,lineno); | |
595 | var target_line = YUD.get(lineid); |
|
595 | var target_line = YUD.get(lineid); | |
596 | var comment = new YAHOO.util.Element(tableTr('inline-comments',html)) |
|
596 | var comment = new YAHOO.util.Element(tableTr('inline-comments',html)) | |
597 |
|
597 | |||
598 | // check if there are comments already ! |
|
598 | // check if there are comments already ! | |
599 | var parent = target_line.parentNode; |
|
599 | var parent = target_line.parentNode; | |
600 | var root_parent = parent; |
|
600 | var root_parent = parent; | |
601 | while (1){ |
|
601 | while (1){ | |
602 | var n = parent.nextElementSibling; |
|
602 | var n = parent.nextElementSibling; | |
603 | // next element are comments ! |
|
603 | // next element are comments ! | |
604 | if(YUD.hasClass(n,'inline-comments')){ |
|
604 | if(YUD.hasClass(n,'inline-comments')){ | |
605 | parent = n; |
|
605 | parent = n; | |
606 | } |
|
606 | } | |
607 | else{ |
|
607 | else{ | |
608 | break; |
|
608 | break; | |
609 | } |
|
609 | } | |
610 | } |
|
610 | } | |
611 | // put in the comment at the bottom |
|
611 | // put in the comment at the bottom | |
612 | YUD.insertAfter(comment,parent); |
|
612 | YUD.insertAfter(comment,parent); | |
613 |
|
613 | |||
614 | // scann nodes, and attach add button to last one |
|
614 | // scann nodes, and attach add button to last one | |
615 | placeAddButton(root_parent); |
|
615 | placeAddButton(root_parent); | |
616 |
|
616 | |||
617 | return target_line; |
|
617 | return target_line; | |
618 | } |
|
618 | } | |
619 |
|
619 | |||
620 | /** |
|
620 | /** | |
621 | * make a single inline comment and place it inside |
|
621 | * make a single inline comment and place it inside | |
622 | */ |
|
622 | */ | |
623 | var renderInlineComment = function(json_data){ |
|
623 | var renderInlineComment = function(json_data){ | |
624 | try{ |
|
624 | try{ | |
625 | var html = json_data['rendered_text']; |
|
625 | var html = json_data['rendered_text']; | |
626 | var lineno = json_data['line_no']; |
|
626 | var lineno = json_data['line_no']; | |
627 | var target_id = json_data['target_id']; |
|
627 | var target_id = json_data['target_id']; | |
628 | placeInline(target_id, lineno, html); |
|
628 | placeInline(target_id, lineno, html); | |
629 |
|
629 | |||
630 | }catch(e){ |
|
630 | }catch(e){ | |
631 | console.log(e); |
|
631 | console.log(e); | |
632 | } |
|
632 | } | |
633 | } |
|
633 | } | |
634 |
|
634 | |||
635 | /** |
|
635 | /** | |
636 | * Iterates over all the inlines, and places them inside proper blocks of data |
|
636 | * Iterates over all the inlines, and places them inside proper blocks of data | |
637 | */ |
|
637 | */ | |
638 | var renderInlineComments = function(file_comments){ |
|
638 | var renderInlineComments = function(file_comments){ | |
639 | for (f in file_comments){ |
|
639 | for (f in file_comments){ | |
640 | // holding all comments for a FILE |
|
640 | // holding all comments for a FILE | |
641 | var box = file_comments[f]; |
|
641 | var box = file_comments[f]; | |
642 |
|
642 | |||
643 | var target_id = YUD.getAttribute(box,'target_id'); |
|
643 | var target_id = YUD.getAttribute(box,'target_id'); | |
644 | // actually comments with line numbers |
|
644 | // actually comments with line numbers | |
645 | var comments = box.children; |
|
645 | var comments = box.children; | |
646 | for(var i=0; i<comments.length; i++){ |
|
646 | for(var i=0; i<comments.length; i++){ | |
647 | var data = { |
|
647 | var data = { | |
648 | 'rendered_text': comments[i].outerHTML, |
|
648 | 'rendered_text': comments[i].outerHTML, | |
649 | 'line_no': YUD.getAttribute(comments[i],'line'), |
|
649 | 'line_no': YUD.getAttribute(comments[i],'line'), | |
650 | 'target_id': target_id |
|
650 | 'target_id': target_id | |
651 | } |
|
651 | } | |
652 | renderInlineComment(data); |
|
652 | renderInlineComment(data); | |
653 | } |
|
653 | } | |
654 | } |
|
654 | } | |
655 | } |
|
655 | } | |
656 |
|
656 | |||
657 | var removeReviewer = function(reviewer_id){ |
|
657 | var removeReviewer = function(reviewer_id){ | |
658 | var el = YUD.get('reviewer_{0}'.format(reviewer_id)); |
|
658 | var el = YUD.get('reviewer_{0}'.format(reviewer_id)); | |
659 | if (el.parentNode !== undefined){ |
|
659 | if (el.parentNode !== undefined){ | |
660 | el.parentNode.removeChild(el); |
|
660 | el.parentNode.removeChild(el); | |
661 | } |
|
661 | } | |
662 | } |
|
662 | } | |
663 |
|
663 | |||
664 | var fileBrowserListeners = function(current_url, node_list_url, url_base){ |
|
664 | var fileBrowserListeners = function(current_url, node_list_url, url_base){ | |
665 |
|
665 | |||
666 | var current_url_branch = +"?branch=__BRANCH__"; |
|
666 | var current_url_branch = +"?branch=__BRANCH__"; | |
667 | var url = url_base; |
|
667 | var url = url_base; | |
668 | var node_url = node_list_url; |
|
668 | var node_url = node_list_url; | |
669 |
|
669 | |||
670 | YUE.on('stay_at_branch','click',function(e){ |
|
670 | YUE.on('stay_at_branch','click',function(e){ | |
671 | if(e.target.checked){ |
|
671 | if(e.target.checked){ | |
672 | var uri = current_url_branch; |
|
672 | var uri = current_url_branch; | |
673 | uri = uri.replace('__BRANCH__',e.target.value); |
|
673 | uri = uri.replace('__BRANCH__',e.target.value); | |
674 | window.location = uri; |
|
674 | window.location = uri; | |
675 | } |
|
675 | } | |
676 | else{ |
|
676 | else{ | |
677 | window.location = current_url; |
|
677 | window.location = current_url; | |
678 | } |
|
678 | } | |
679 | }) |
|
679 | }) | |
680 |
|
680 | |||
681 | var n_filter = YUD.get('node_filter'); |
|
681 | var n_filter = YUD.get('node_filter'); | |
682 | var F = YAHOO.namespace('node_filter'); |
|
682 | var F = YAHOO.namespace('node_filter'); | |
683 |
|
683 | |||
684 | F.filterTimeout = null; |
|
684 | F.filterTimeout = null; | |
685 | var nodes = null; |
|
685 | var nodes = null; | |
686 |
|
686 | |||
687 | F.initFilter = function(){ |
|
687 | F.initFilter = function(){ | |
688 | YUD.setStyle('node_filter_box_loading','display',''); |
|
688 | YUD.setStyle('node_filter_box_loading','display',''); | |
689 | YUD.setStyle('search_activate_id','display','none'); |
|
689 | YUD.setStyle('search_activate_id','display','none'); | |
690 | YUD.setStyle('add_node_id','display','none'); |
|
690 | YUD.setStyle('add_node_id','display','none'); | |
691 | YUC.initHeader('X-PARTIAL-XHR',true); |
|
691 | YUC.initHeader('X-PARTIAL-XHR',true); | |
692 | YUC.asyncRequest('GET',url,{ |
|
692 | YUC.asyncRequest('GET',url,{ | |
693 | success:function(o){ |
|
693 | success:function(o){ | |
694 | nodes = JSON.parse(o.responseText).nodes; |
|
694 | nodes = JSON.parse(o.responseText).nodes; | |
695 | YUD.setStyle('node_filter_box_loading','display','none'); |
|
695 | YUD.setStyle('node_filter_box_loading','display','none'); | |
696 | YUD.setStyle('node_filter_box','display',''); |
|
696 | YUD.setStyle('node_filter_box','display',''); | |
697 | n_filter.focus(); |
|
697 | n_filter.focus(); | |
698 | if(YUD.hasClass(n_filter,'init')){ |
|
698 | if(YUD.hasClass(n_filter,'init')){ | |
699 | n_filter.value = ''; |
|
699 | n_filter.value = ''; | |
700 | YUD.removeClass(n_filter,'init'); |
|
700 | YUD.removeClass(n_filter,'init'); | |
701 | } |
|
701 | } | |
702 | }, |
|
702 | }, | |
703 | failure:function(o){ |
|
703 | failure:function(o){ | |
704 | console.log('failed to load'); |
|
704 | console.log('failed to load'); | |
705 | } |
|
705 | } | |
706 | },null); |
|
706 | },null); | |
707 | } |
|
707 | } | |
708 |
|
708 | |||
709 | F.updateFilter = function(e) { |
|
709 | F.updateFilter = function(e) { | |
710 |
|
710 | |||
711 | return function(){ |
|
711 | return function(){ | |
712 | // Reset timeout |
|
712 | // Reset timeout | |
713 | F.filterTimeout = null; |
|
713 | F.filterTimeout = null; | |
714 | var query = e.target.value.toLowerCase(); |
|
714 | var query = e.target.value.toLowerCase(); | |
715 | var match = []; |
|
715 | var match = []; | |
716 | var matches = 0; |
|
716 | var matches = 0; | |
717 | var matches_max = 20; |
|
717 | var matches_max = 20; | |
718 | if (query != ""){ |
|
718 | if (query != ""){ | |
719 | for(var i=0;i<nodes.length;i++){ |
|
719 | for(var i=0;i<nodes.length;i++){ | |
720 |
|
720 | |||
721 | var pos = nodes[i].name.toLowerCase().indexOf(query) |
|
721 | var pos = nodes[i].name.toLowerCase().indexOf(query) | |
722 | if(query && pos != -1){ |
|
722 | if(query && pos != -1){ | |
723 |
|
723 | |||
724 | matches++ |
|
724 | matches++ | |
725 | //show only certain amount to not kill browser |
|
725 | //show only certain amount to not kill browser | |
726 | if (matches > matches_max){ |
|
726 | if (matches > matches_max){ | |
727 | break; |
|
727 | break; | |
728 | } |
|
728 | } | |
729 |
|
729 | |||
730 | var n = nodes[i].name; |
|
730 | var n = nodes[i].name; | |
731 | var t = nodes[i].type; |
|
731 | var t = nodes[i].type; | |
732 | var n_hl = n.substring(0,pos) |
|
732 | var n_hl = n.substring(0,pos) | |
733 | +"<b>{0}</b>".format(n.substring(pos,pos+query.length)) |
|
733 | +"<b>{0}</b>".format(n.substring(pos,pos+query.length)) | |
734 | +n.substring(pos+query.length) |
|
734 | +n.substring(pos+query.length) | |
735 | node_url = node_url.replace('__FPATH__',n); |
|
735 | node_url = node_url.replace('__FPATH__',n); | |
736 | match.push('<tr><td><a class="browser-{0}" href="{1}">{2}</a></td><td colspan="5"></td></tr>'.format(t,node_url,n_hl)); |
|
736 | match.push('<tr><td><a class="browser-{0}" href="{1}">{2}</a></td><td colspan="5"></td></tr>'.format(t,node_url,n_hl)); | |
737 | } |
|
737 | } | |
738 | if(match.length >= matches_max){ |
|
738 | if(match.length >= matches_max){ | |
739 | match.push('<tr><td>{0}</td><td colspan="5"></td></tr>'.format(_TM['search truncated'])); |
|
739 | match.push('<tr><td>{0}</td><td colspan="5"></td></tr>'.format(_TM['search truncated'])); | |
740 | } |
|
740 | } | |
741 | } |
|
741 | } | |
742 | } |
|
742 | } | |
743 | if(query != ""){ |
|
743 | if(query != ""){ | |
744 | YUD.setStyle('tbody','display','none'); |
|
744 | YUD.setStyle('tbody','display','none'); | |
745 | YUD.setStyle('tbody_filtered','display',''); |
|
745 | YUD.setStyle('tbody_filtered','display',''); | |
746 |
|
746 | |||
747 | if (match.length==0){ |
|
747 | if (match.length==0){ | |
748 | match.push('<tr><td>{0}</td><td colspan="5"></td></tr>'.format(_TM['no matching files'])); |
|
748 | match.push('<tr><td>{0}</td><td colspan="5"></td></tr>'.format(_TM['no matching files'])); | |
749 | } |
|
749 | } | |
750 |
|
750 | |||
751 | YUD.get('tbody_filtered').innerHTML = match.join(""); |
|
751 | YUD.get('tbody_filtered').innerHTML = match.join(""); | |
752 | } |
|
752 | } | |
753 | else{ |
|
753 | else{ | |
754 | YUD.setStyle('tbody','display',''); |
|
754 | YUD.setStyle('tbody','display',''); | |
755 | YUD.setStyle('tbody_filtered','display','none'); |
|
755 | YUD.setStyle('tbody_filtered','display','none'); | |
756 | } |
|
756 | } | |
757 |
|
757 | |||
758 | } |
|
758 | } | |
759 | }; |
|
759 | }; | |
760 |
|
760 | |||
761 | YUE.on(YUD.get('filter_activate'),'click',function(){ |
|
761 | YUE.on(YUD.get('filter_activate'),'click',function(){ | |
762 | F.initFilter(); |
|
762 | F.initFilter(); | |
763 | }) |
|
763 | }) | |
764 | YUE.on(n_filter,'click',function(){ |
|
764 | YUE.on(n_filter,'click',function(){ | |
765 | if(YUD.hasClass(n_filter,'init')){ |
|
765 | if(YUD.hasClass(n_filter,'init')){ | |
766 | n_filter.value = ''; |
|
766 | n_filter.value = ''; | |
767 | YUD.removeClass(n_filter,'init'); |
|
767 | YUD.removeClass(n_filter,'init'); | |
768 | } |
|
768 | } | |
769 | }); |
|
769 | }); | |
770 | YUE.on(n_filter,'keyup',function(e){ |
|
770 | YUE.on(n_filter,'keyup',function(e){ | |
771 | clearTimeout(F.filterTimeout); |
|
771 | clearTimeout(F.filterTimeout); | |
772 | F.filterTimeout = setTimeout(F.updateFilter(e),600); |
|
772 | F.filterTimeout = setTimeout(F.updateFilter(e),600); | |
773 | }); |
|
773 | }); | |
774 | }; |
|
774 | }; | |
775 |
|
775 | |||
776 |
|
776 | |||
777 | var initCodeMirror = function(textAreadId,resetUrl){ |
|
777 | var initCodeMirror = function(textAreadId,resetUrl){ | |
778 | var myCodeMirror = CodeMirror.fromTextArea(YUD.get(textAreadId),{ |
|
778 | var myCodeMirror = CodeMirror.fromTextArea(YUD.get(textAreadId),{ | |
779 | mode: "null", |
|
779 | mode: "null", | |
780 | lineNumbers:true |
|
780 | lineNumbers:true | |
781 | }); |
|
781 | }); | |
782 | YUE.on('reset','click',function(e){ |
|
782 | YUE.on('reset','click',function(e){ | |
783 | window.location=resetUrl |
|
783 | window.location=resetUrl | |
784 | }); |
|
784 | }); | |
785 |
|
785 | |||
786 | YUE.on('file_enable','click',function(){ |
|
786 | YUE.on('file_enable','click',function(){ | |
787 | YUD.setStyle('editor_container','display',''); |
|
787 | YUD.setStyle('editor_container','display',''); | |
788 | YUD.setStyle('upload_file_container','display','none'); |
|
788 | YUD.setStyle('upload_file_container','display','none'); | |
789 | YUD.setStyle('filename_container','display',''); |
|
789 | YUD.setStyle('filename_container','display',''); | |
790 | }); |
|
790 | }); | |
791 |
|
791 | |||
792 | YUE.on('upload_file_enable','click',function(){ |
|
792 | YUE.on('upload_file_enable','click',function(){ | |
793 | YUD.setStyle('editor_container','display','none'); |
|
793 | YUD.setStyle('editor_container','display','none'); | |
794 | YUD.setStyle('upload_file_container','display',''); |
|
794 | YUD.setStyle('upload_file_container','display',''); | |
795 | YUD.setStyle('filename_container','display','none'); |
|
795 | YUD.setStyle('filename_container','display','none'); | |
796 | }); |
|
796 | }); | |
797 | }; |
|
797 | }; | |
798 |
|
798 | |||
799 |
|
799 | |||
800 |
|
800 | |||
801 | var getIdentNode = function(n){ |
|
801 | var getIdentNode = function(n){ | |
802 | //iterate thru nodes untill matched interesting node ! |
|
802 | //iterate thru nodes untill matched interesting node ! | |
803 |
|
803 | |||
804 | if (typeof n == 'undefined'){ |
|
804 | if (typeof n == 'undefined'){ | |
805 | return -1 |
|
805 | return -1 | |
806 | } |
|
806 | } | |
807 |
|
807 | |||
808 | if(typeof n.id != "undefined" && n.id.match('L[0-9]+')){ |
|
808 | if(typeof n.id != "undefined" && n.id.match('L[0-9]+')){ | |
809 | return n |
|
809 | return n | |
810 | } |
|
810 | } | |
811 | else{ |
|
811 | else{ | |
812 | return getIdentNode(n.parentNode); |
|
812 | return getIdentNode(n.parentNode); | |
813 | } |
|
813 | } | |
814 | }; |
|
814 | }; | |
815 |
|
815 | |||
816 | var getSelectionLink = function(selection_link_label) { |
|
816 | var getSelectionLink = function(selection_link_label) { | |
817 | return function(){ |
|
817 | return function(){ | |
818 | //get selection from start/to nodes |
|
818 | //get selection from start/to nodes | |
819 | if (typeof window.getSelection != "undefined") { |
|
819 | if (typeof window.getSelection != "undefined") { | |
820 | s = window.getSelection(); |
|
820 | s = window.getSelection(); | |
821 |
|
821 | |||
822 | from = getIdentNode(s.anchorNode); |
|
822 | from = getIdentNode(s.anchorNode); | |
823 | till = getIdentNode(s.focusNode); |
|
823 | till = getIdentNode(s.focusNode); | |
824 |
|
824 | |||
825 | f_int = parseInt(from.id.replace('L','')); |
|
825 | f_int = parseInt(from.id.replace('L','')); | |
826 | t_int = parseInt(till.id.replace('L','')); |
|
826 | t_int = parseInt(till.id.replace('L','')); | |
827 |
|
827 | |||
828 | if (f_int > t_int){ |
|
828 | if (f_int > t_int){ | |
829 | //highlight from bottom |
|
829 | //highlight from bottom | |
830 | offset = -35; |
|
830 | offset = -35; | |
831 | ranges = [t_int,f_int]; |
|
831 | ranges = [t_int,f_int]; | |
832 |
|
832 | |||
833 | } |
|
833 | } | |
834 | else{ |
|
834 | else{ | |
835 | //highligth from top |
|
835 | //highligth from top | |
836 | offset = 35; |
|
836 | offset = 35; | |
837 | ranges = [f_int,t_int]; |
|
837 | ranges = [f_int,t_int]; | |
838 | } |
|
838 | } | |
839 |
|
839 | |||
840 | if (ranges[0] != ranges[1]){ |
|
840 | if (ranges[0] != ranges[1]){ | |
841 | if(YUD.get('linktt') == null){ |
|
841 | if(YUD.get('linktt') == null){ | |
842 | hl_div = document.createElement('div'); |
|
842 | hl_div = document.createElement('div'); | |
843 | hl_div.id = 'linktt'; |
|
843 | hl_div.id = 'linktt'; | |
844 | } |
|
844 | } | |
845 | anchor = '#L'+ranges[0]+'-'+ranges[1]; |
|
845 | anchor = '#L'+ranges[0]+'-'+ranges[1]; | |
846 | hl_div.innerHTML = ''; |
|
846 | hl_div.innerHTML = ''; | |
847 | l = document.createElement('a'); |
|
847 | l = document.createElement('a'); | |
848 | l.href = location.href.substring(0,location.href.indexOf('#'))+anchor; |
|
848 | l.href = location.href.substring(0,location.href.indexOf('#'))+anchor; | |
849 | l.innerHTML = selection_link_label; |
|
849 | l.innerHTML = selection_link_label; | |
850 | hl_div.appendChild(l); |
|
850 | hl_div.appendChild(l); | |
851 |
|
851 | |||
852 | YUD.get('body').appendChild(hl_div); |
|
852 | YUD.get('body').appendChild(hl_div); | |
853 |
|
853 | |||
854 | xy = YUD.getXY(till.id); |
|
854 | xy = YUD.getXY(till.id); | |
855 |
|
855 | |||
856 | YUD.addClass('linktt','yui-tt'); |
|
856 | YUD.addClass('linktt','yui-tt'); | |
857 | YUD.setStyle('linktt','top',xy[1]+offset+'px'); |
|
857 | YUD.setStyle('linktt','top',xy[1]+offset+'px'); | |
858 | YUD.setStyle('linktt','left',xy[0]+'px'); |
|
858 | YUD.setStyle('linktt','left',xy[0]+'px'); | |
859 | YUD.setStyle('linktt','visibility','visible'); |
|
859 | YUD.setStyle('linktt','visibility','visible'); | |
860 | } |
|
860 | } | |
861 | else{ |
|
861 | else{ | |
862 | YUD.setStyle('linktt','visibility','hidden'); |
|
862 | YUD.setStyle('linktt','visibility','hidden'); | |
863 | } |
|
863 | } | |
864 | } |
|
864 | } | |
865 | } |
|
865 | } | |
866 | }; |
|
866 | }; | |
867 |
|
867 | |||
868 | var deleteNotification = function(url, notification_id,callbacks){ |
|
868 | var deleteNotification = function(url, notification_id,callbacks){ | |
869 | var callback = { |
|
869 | var callback = { | |
870 | success:function(o){ |
|
870 | success:function(o){ | |
871 | var obj = YUD.get(String("notification_"+notification_id)); |
|
871 | var obj = YUD.get(String("notification_"+notification_id)); | |
872 | if(obj.parentNode !== undefined){ |
|
872 | if(obj.parentNode !== undefined){ | |
873 | obj.parentNode.removeChild(obj); |
|
873 | obj.parentNode.removeChild(obj); | |
874 | } |
|
874 | } | |
875 | _run_callbacks(callbacks); |
|
875 | _run_callbacks(callbacks); | |
876 | }, |
|
876 | }, | |
877 | failure:function(o){ |
|
877 | failure:function(o){ | |
878 | alert("error"); |
|
878 | alert("error"); | |
879 | }, |
|
879 | }, | |
880 | }; |
|
880 | }; | |
881 | var postData = '_method=delete'; |
|
881 | var postData = '_method=delete'; | |
882 | var sUrl = url.replace('__NOTIFICATION_ID__',notification_id); |
|
882 | var sUrl = url.replace('__NOTIFICATION_ID__',notification_id); | |
883 | var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, |
|
883 | var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, | |
884 | callback, postData); |
|
884 | callback, postData); | |
885 | }; |
|
885 | }; | |
886 |
|
886 | |||
887 | var readNotification = function(url, notification_id,callbacks){ |
|
887 | var readNotification = function(url, notification_id,callbacks){ | |
888 | var callback = { |
|
888 | var callback = { | |
889 | success:function(o){ |
|
889 | success:function(o){ | |
890 | var obj = YUD.get(String("notification_"+notification_id)); |
|
890 | var obj = YUD.get(String("notification_"+notification_id)); | |
891 | YUD.removeClass(obj, 'unread'); |
|
891 | YUD.removeClass(obj, 'unread'); | |
892 |
var r_button = obj.children[0] |
|
892 | var r_button = YUD.getElementsByClassName('read-notification',null,obj.children[0])[0]; | |
893 |
|
893 | |||
894 | if(r_button.parentNode !== undefined){ |
|
894 | if(r_button.parentNode !== undefined){ | |
895 | r_button.parentNode.removeChild(r_button); |
|
895 | r_button.parentNode.removeChild(r_button); | |
896 | } |
|
896 | } | |
897 | _run_callbacks(callbacks); |
|
897 | _run_callbacks(callbacks); | |
898 | }, |
|
898 | }, | |
899 | failure:function(o){ |
|
899 | failure:function(o){ | |
900 | alert("error"); |
|
900 | alert("error"); | |
901 | }, |
|
901 | }, | |
902 | }; |
|
902 | }; | |
903 | var postData = '_method=put'; |
|
903 | var postData = '_method=put'; | |
904 | var sUrl = url.replace('__NOTIFICATION_ID__',notification_id); |
|
904 | var sUrl = url.replace('__NOTIFICATION_ID__',notification_id); | |
905 | var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, |
|
905 | var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, | |
906 | callback, postData); |
|
906 | callback, postData); | |
907 | }; |
|
907 | }; | |
908 |
|
908 | |||
909 | /** MEMBERS AUTOCOMPLETE WIDGET **/ |
|
909 | /** MEMBERS AUTOCOMPLETE WIDGET **/ | |
910 |
|
910 | |||
911 | var MembersAutoComplete = function (users_list, groups_list) { |
|
911 | var MembersAutoComplete = function (users_list, groups_list) { | |
912 | var myUsers = users_list; |
|
912 | var myUsers = users_list; | |
913 | var myGroups = groups_list; |
|
913 | var myGroups = groups_list; | |
914 |
|
914 | |||
915 | // Define a custom search function for the DataSource of users |
|
915 | // Define a custom search function for the DataSource of users | |
916 | var matchUsers = function (sQuery) { |
|
916 | var matchUsers = function (sQuery) { | |
917 | // Case insensitive matching |
|
917 | // Case insensitive matching | |
918 | var query = sQuery.toLowerCase(); |
|
918 | var query = sQuery.toLowerCase(); | |
919 | var i = 0; |
|
919 | var i = 0; | |
920 | var l = myUsers.length; |
|
920 | var l = myUsers.length; | |
921 | var matches = []; |
|
921 | var matches = []; | |
922 |
|
922 | |||
923 | // Match against each name of each contact |
|
923 | // Match against each name of each contact | |
924 | for (; i < l; i++) { |
|
924 | for (; i < l; i++) { | |
925 | contact = myUsers[i]; |
|
925 | contact = myUsers[i]; | |
926 | if (((contact.fname+"").toLowerCase().indexOf(query) > -1) || |
|
926 | if (((contact.fname+"").toLowerCase().indexOf(query) > -1) || | |
927 | ((contact.lname+"").toLowerCase().indexOf(query) > -1) || |
|
927 | ((contact.lname+"").toLowerCase().indexOf(query) > -1) || | |
928 | ((contact.nname) && ((contact.nname).toLowerCase().indexOf(query) > -1))) { |
|
928 | ((contact.nname) && ((contact.nname).toLowerCase().indexOf(query) > -1))) { | |
929 | matches[matches.length] = contact; |
|
929 | matches[matches.length] = contact; | |
930 | } |
|
930 | } | |
931 | } |
|
931 | } | |
932 | return matches; |
|
932 | return matches; | |
933 | }; |
|
933 | }; | |
934 |
|
934 | |||
935 | // Define a custom search function for the DataSource of usersGroups |
|
935 | // Define a custom search function for the DataSource of usersGroups | |
936 | var matchGroups = function (sQuery) { |
|
936 | var matchGroups = function (sQuery) { | |
937 | // Case insensitive matching |
|
937 | // Case insensitive matching | |
938 | var query = sQuery.toLowerCase(); |
|
938 | var query = sQuery.toLowerCase(); | |
939 | var i = 0; |
|
939 | var i = 0; | |
940 | var l = myGroups.length; |
|
940 | var l = myGroups.length; | |
941 | var matches = []; |
|
941 | var matches = []; | |
942 |
|
942 | |||
943 | // Match against each name of each contact |
|
943 | // Match against each name of each contact | |
944 | for (; i < l; i++) { |
|
944 | for (; i < l; i++) { | |
945 | matched_group = myGroups[i]; |
|
945 | matched_group = myGroups[i]; | |
946 | if (matched_group.grname.toLowerCase().indexOf(query) > -1) { |
|
946 | if (matched_group.grname.toLowerCase().indexOf(query) > -1) { | |
947 | matches[matches.length] = matched_group; |
|
947 | matches[matches.length] = matched_group; | |
948 | } |
|
948 | } | |
949 | } |
|
949 | } | |
950 | return matches; |
|
950 | return matches; | |
951 | }; |
|
951 | }; | |
952 |
|
952 | |||
953 | //match all |
|
953 | //match all | |
954 | var matchAll = function (sQuery) { |
|
954 | var matchAll = function (sQuery) { | |
955 | u = matchUsers(sQuery); |
|
955 | u = matchUsers(sQuery); | |
956 | g = matchGroups(sQuery); |
|
956 | g = matchGroups(sQuery); | |
957 | return u.concat(g); |
|
957 | return u.concat(g); | |
958 | }; |
|
958 | }; | |
959 |
|
959 | |||
960 | // DataScheme for members |
|
960 | // DataScheme for members | |
961 | var memberDS = new YAHOO.util.FunctionDataSource(matchAll); |
|
961 | var memberDS = new YAHOO.util.FunctionDataSource(matchAll); | |
962 | memberDS.responseSchema = { |
|
962 | memberDS.responseSchema = { | |
963 | fields: ["id", "fname", "lname", "nname", "grname", "grmembers", "gravatar_lnk"] |
|
963 | fields: ["id", "fname", "lname", "nname", "grname", "grmembers", "gravatar_lnk"] | |
964 | }; |
|
964 | }; | |
965 |
|
965 | |||
966 | // DataScheme for owner |
|
966 | // DataScheme for owner | |
967 | var ownerDS = new YAHOO.util.FunctionDataSource(matchUsers); |
|
967 | var ownerDS = new YAHOO.util.FunctionDataSource(matchUsers); | |
968 | ownerDS.responseSchema = { |
|
968 | ownerDS.responseSchema = { | |
969 | fields: ["id", "fname", "lname", "nname", "gravatar_lnk"] |
|
969 | fields: ["id", "fname", "lname", "nname", "gravatar_lnk"] | |
970 | }; |
|
970 | }; | |
971 |
|
971 | |||
972 | // Instantiate AutoComplete for perms |
|
972 | // Instantiate AutoComplete for perms | |
973 | var membersAC = new YAHOO.widget.AutoComplete("perm_new_member_name", "perm_container", memberDS); |
|
973 | var membersAC = new YAHOO.widget.AutoComplete("perm_new_member_name", "perm_container", memberDS); | |
974 | membersAC.useShadow = false; |
|
974 | membersAC.useShadow = false; | |
975 | membersAC.resultTypeList = false; |
|
975 | membersAC.resultTypeList = false; | |
976 | membersAC.animVert = false; |
|
976 | membersAC.animVert = false; | |
977 | membersAC.animHoriz = false; |
|
977 | membersAC.animHoriz = false; | |
978 | membersAC.animSpeed = 0.1; |
|
978 | membersAC.animSpeed = 0.1; | |
979 |
|
979 | |||
980 | // Instantiate AutoComplete for owner |
|
980 | // Instantiate AutoComplete for owner | |
981 | var ownerAC = new YAHOO.widget.AutoComplete("user", "owner_container", ownerDS); |
|
981 | var ownerAC = new YAHOO.widget.AutoComplete("user", "owner_container", ownerDS); | |
982 | ownerAC.useShadow = false; |
|
982 | ownerAC.useShadow = false; | |
983 | ownerAC.resultTypeList = false; |
|
983 | ownerAC.resultTypeList = false; | |
984 | ownerAC.animVert = false; |
|
984 | ownerAC.animVert = false; | |
985 | ownerAC.animHoriz = false; |
|
985 | ownerAC.animHoriz = false; | |
986 | ownerAC.animSpeed = 0.1; |
|
986 | ownerAC.animSpeed = 0.1; | |
987 |
|
987 | |||
988 | // Helper highlight function for the formatter |
|
988 | // Helper highlight function for the formatter | |
989 | var highlightMatch = function (full, snippet, matchindex) { |
|
989 | var highlightMatch = function (full, snippet, matchindex) { | |
990 | return full.substring(0, matchindex) |
|
990 | return full.substring(0, matchindex) | |
991 | + "<span class='match'>" |
|
991 | + "<span class='match'>" | |
992 | + full.substr(matchindex, snippet.length) |
|
992 | + full.substr(matchindex, snippet.length) | |
993 | + "</span>" + full.substring(matchindex + snippet.length); |
|
993 | + "</span>" + full.substring(matchindex + snippet.length); | |
994 | }; |
|
994 | }; | |
995 |
|
995 | |||
996 | // Custom formatter to highlight the matching letters |
|
996 | // Custom formatter to highlight the matching letters | |
997 | var custom_formatter = function (oResultData, sQuery, sResultMatch) { |
|
997 | var custom_formatter = function (oResultData, sQuery, sResultMatch) { | |
998 | var query = sQuery.toLowerCase(); |
|
998 | var query = sQuery.toLowerCase(); | |
999 | var _gravatar = function(res, em, group){ |
|
999 | var _gravatar = function(res, em, group){ | |
1000 | if (group !== undefined){ |
|
1000 | if (group !== undefined){ | |
1001 | em = '/images/icons/group.png' |
|
1001 | em = '/images/icons/group.png' | |
1002 | } |
|
1002 | } | |
1003 | tmpl = '<div class="ac-container-wrap"><img class="perm-gravatar-ac" src="{0}"/>{1}</div>' |
|
1003 | tmpl = '<div class="ac-container-wrap"><img class="perm-gravatar-ac" src="{0}"/>{1}</div>' | |
1004 | return tmpl.format(em,res) |
|
1004 | return tmpl.format(em,res) | |
1005 | } |
|
1005 | } | |
1006 | // group |
|
1006 | // group | |
1007 | if (oResultData.grname != undefined) { |
|
1007 | if (oResultData.grname != undefined) { | |
1008 | var grname = oResultData.grname; |
|
1008 | var grname = oResultData.grname; | |
1009 | var grmembers = oResultData.grmembers; |
|
1009 | var grmembers = oResultData.grmembers; | |
1010 | var grnameMatchIndex = grname.toLowerCase().indexOf(query); |
|
1010 | var grnameMatchIndex = grname.toLowerCase().indexOf(query); | |
1011 | var grprefix = "{0}: ".format(_TM['Group']); |
|
1011 | var grprefix = "{0}: ".format(_TM['Group']); | |
1012 | var grsuffix = " (" + grmembers + " )"; |
|
1012 | var grsuffix = " (" + grmembers + " )"; | |
1013 | var grsuffix = " ({0} {1})".format(grmembers, _TM['members']); |
|
1013 | var grsuffix = " ({0} {1})".format(grmembers, _TM['members']); | |
1014 |
|
1014 | |||
1015 | if (grnameMatchIndex > -1) { |
|
1015 | if (grnameMatchIndex > -1) { | |
1016 | return _gravatar(grprefix + highlightMatch(grname, query, grnameMatchIndex) + grsuffix,null,true); |
|
1016 | return _gravatar(grprefix + highlightMatch(grname, query, grnameMatchIndex) + grsuffix,null,true); | |
1017 | } |
|
1017 | } | |
1018 | return _gravatar(grprefix + oResultData.grname + grsuffix, null,true); |
|
1018 | return _gravatar(grprefix + oResultData.grname + grsuffix, null,true); | |
1019 | // Users |
|
1019 | // Users | |
1020 | } else if (oResultData.nname != undefined) { |
|
1020 | } else if (oResultData.nname != undefined) { | |
1021 | var fname = oResultData.fname || ""; |
|
1021 | var fname = oResultData.fname || ""; | |
1022 | var lname = oResultData.lname || ""; |
|
1022 | var lname = oResultData.lname || ""; | |
1023 | var nname = oResultData.nname; |
|
1023 | var nname = oResultData.nname; | |
1024 |
|
1024 | |||
1025 | // Guard against null value |
|
1025 | // Guard against null value | |
1026 | var fnameMatchIndex = fname.toLowerCase().indexOf(query), |
|
1026 | var fnameMatchIndex = fname.toLowerCase().indexOf(query), | |
1027 | lnameMatchIndex = lname.toLowerCase().indexOf(query), |
|
1027 | lnameMatchIndex = lname.toLowerCase().indexOf(query), | |
1028 | nnameMatchIndex = nname.toLowerCase().indexOf(query), |
|
1028 | nnameMatchIndex = nname.toLowerCase().indexOf(query), | |
1029 | displayfname, displaylname, displaynname; |
|
1029 | displayfname, displaylname, displaynname; | |
1030 |
|
1030 | |||
1031 | if (fnameMatchIndex > -1) { |
|
1031 | if (fnameMatchIndex > -1) { | |
1032 | displayfname = highlightMatch(fname, query, fnameMatchIndex); |
|
1032 | displayfname = highlightMatch(fname, query, fnameMatchIndex); | |
1033 | } else { |
|
1033 | } else { | |
1034 | displayfname = fname; |
|
1034 | displayfname = fname; | |
1035 | } |
|
1035 | } | |
1036 |
|
1036 | |||
1037 | if (lnameMatchIndex > -1) { |
|
1037 | if (lnameMatchIndex > -1) { | |
1038 | displaylname = highlightMatch(lname, query, lnameMatchIndex); |
|
1038 | displaylname = highlightMatch(lname, query, lnameMatchIndex); | |
1039 | } else { |
|
1039 | } else { | |
1040 | displaylname = lname; |
|
1040 | displaylname = lname; | |
1041 | } |
|
1041 | } | |
1042 |
|
1042 | |||
1043 | if (nnameMatchIndex > -1) { |
|
1043 | if (nnameMatchIndex > -1) { | |
1044 | displaynname = "(" + highlightMatch(nname, query, nnameMatchIndex) + ")"; |
|
1044 | displaynname = "(" + highlightMatch(nname, query, nnameMatchIndex) + ")"; | |
1045 | } else { |
|
1045 | } else { | |
1046 | displaynname = nname ? "(" + nname + ")" : ""; |
|
1046 | displaynname = nname ? "(" + nname + ")" : ""; | |
1047 | } |
|
1047 | } | |
1048 |
|
1048 | |||
1049 | return _gravatar(displayfname + " " + displaylname + " " + displaynname, oResultData.gravatar_lnk); |
|
1049 | return _gravatar(displayfname + " " + displaylname + " " + displaynname, oResultData.gravatar_lnk); | |
1050 | } else { |
|
1050 | } else { | |
1051 | return ''; |
|
1051 | return ''; | |
1052 | } |
|
1052 | } | |
1053 | }; |
|
1053 | }; | |
1054 | membersAC.formatResult = custom_formatter; |
|
1054 | membersAC.formatResult = custom_formatter; | |
1055 | ownerAC.formatResult = custom_formatter; |
|
1055 | ownerAC.formatResult = custom_formatter; | |
1056 |
|
1056 | |||
1057 | var myHandler = function (sType, aArgs) { |
|
1057 | var myHandler = function (sType, aArgs) { | |
1058 |
|
1058 | |||
1059 | var myAC = aArgs[0]; // reference back to the AC instance |
|
1059 | var myAC = aArgs[0]; // reference back to the AC instance | |
1060 | var elLI = aArgs[1]; // reference to the selected LI element |
|
1060 | var elLI = aArgs[1]; // reference to the selected LI element | |
1061 | var oData = aArgs[2]; // object literal of selected item's result data |
|
1061 | var oData = aArgs[2]; // object literal of selected item's result data | |
1062 | //fill the autocomplete with value |
|
1062 | //fill the autocomplete with value | |
1063 | if (oData.nname != undefined) { |
|
1063 | if (oData.nname != undefined) { | |
1064 | //users |
|
1064 | //users | |
1065 | myAC.getInputEl().value = oData.nname; |
|
1065 | myAC.getInputEl().value = oData.nname; | |
1066 | YUD.get('perm_new_member_type').value = 'user'; |
|
1066 | YUD.get('perm_new_member_type').value = 'user'; | |
1067 | } else { |
|
1067 | } else { | |
1068 | //groups |
|
1068 | //groups | |
1069 | myAC.getInputEl().value = oData.grname; |
|
1069 | myAC.getInputEl().value = oData.grname; | |
1070 | YUD.get('perm_new_member_type').value = 'users_group'; |
|
1070 | YUD.get('perm_new_member_type').value = 'users_group'; | |
1071 | } |
|
1071 | } | |
1072 | }; |
|
1072 | }; | |
1073 |
|
1073 | |||
1074 | membersAC.itemSelectEvent.subscribe(myHandler); |
|
1074 | membersAC.itemSelectEvent.subscribe(myHandler); | |
1075 | if(ownerAC.itemSelectEvent){ |
|
1075 | if(ownerAC.itemSelectEvent){ | |
1076 | ownerAC.itemSelectEvent.subscribe(myHandler); |
|
1076 | ownerAC.itemSelectEvent.subscribe(myHandler); | |
1077 | } |
|
1077 | } | |
1078 |
|
1078 | |||
1079 | return { |
|
1079 | return { | |
1080 | memberDS: memberDS, |
|
1080 | memberDS: memberDS, | |
1081 | ownerDS: ownerDS, |
|
1081 | ownerDS: ownerDS, | |
1082 | membersAC: membersAC, |
|
1082 | membersAC: membersAC, | |
1083 | ownerAC: ownerAC, |
|
1083 | ownerAC: ownerAC, | |
1084 | }; |
|
1084 | }; | |
1085 | } |
|
1085 | } | |
1086 |
|
1086 | |||
1087 |
|
1087 | |||
1088 | var MentionsAutoComplete = function (divid, cont, users_list, groups_list) { |
|
1088 | var MentionsAutoComplete = function (divid, cont, users_list, groups_list) { | |
1089 | var myUsers = users_list; |
|
1089 | var myUsers = users_list; | |
1090 | var myGroups = groups_list; |
|
1090 | var myGroups = groups_list; | |
1091 |
|
1091 | |||
1092 | // Define a custom search function for the DataSource of users |
|
1092 | // Define a custom search function for the DataSource of users | |
1093 | var matchUsers = function (sQuery) { |
|
1093 | var matchUsers = function (sQuery) { | |
1094 | var org_sQuery = sQuery; |
|
1094 | var org_sQuery = sQuery; | |
1095 | if(this.mentionQuery == null){ |
|
1095 | if(this.mentionQuery == null){ | |
1096 | return [] |
|
1096 | return [] | |
1097 | } |
|
1097 | } | |
1098 | sQuery = this.mentionQuery; |
|
1098 | sQuery = this.mentionQuery; | |
1099 | // Case insensitive matching |
|
1099 | // Case insensitive matching | |
1100 | var query = sQuery.toLowerCase(); |
|
1100 | var query = sQuery.toLowerCase(); | |
1101 | var i = 0; |
|
1101 | var i = 0; | |
1102 | var l = myUsers.length; |
|
1102 | var l = myUsers.length; | |
1103 | var matches = []; |
|
1103 | var matches = []; | |
1104 |
|
1104 | |||
1105 | // Match against each name of each contact |
|
1105 | // Match against each name of each contact | |
1106 | for (; i < l; i++) { |
|
1106 | for (; i < l; i++) { | |
1107 | contact = myUsers[i]; |
|
1107 | contact = myUsers[i]; | |
1108 | if (((contact.fname+"").toLowerCase().indexOf(query) > -1) || |
|
1108 | if (((contact.fname+"").toLowerCase().indexOf(query) > -1) || | |
1109 | ((contact.lname+"").toLowerCase().indexOf(query) > -1) || |
|
1109 | ((contact.lname+"").toLowerCase().indexOf(query) > -1) || | |
1110 | ((contact.nname) && ((contact.nname).toLowerCase().indexOf(query) > -1))) { |
|
1110 | ((contact.nname) && ((contact.nname).toLowerCase().indexOf(query) > -1))) { | |
1111 | matches[matches.length] = contact; |
|
1111 | matches[matches.length] = contact; | |
1112 | } |
|
1112 | } | |
1113 | } |
|
1113 | } | |
1114 | return matches |
|
1114 | return matches | |
1115 | }; |
|
1115 | }; | |
1116 |
|
1116 | |||
1117 | //match all |
|
1117 | //match all | |
1118 | var matchAll = function (sQuery) { |
|
1118 | var matchAll = function (sQuery) { | |
1119 | u = matchUsers(sQuery); |
|
1119 | u = matchUsers(sQuery); | |
1120 | return u |
|
1120 | return u | |
1121 | }; |
|
1121 | }; | |
1122 |
|
1122 | |||
1123 | // DataScheme for owner |
|
1123 | // DataScheme for owner | |
1124 | var ownerDS = new YAHOO.util.FunctionDataSource(matchUsers); |
|
1124 | var ownerDS = new YAHOO.util.FunctionDataSource(matchUsers); | |
1125 |
|
1125 | |||
1126 | ownerDS.responseSchema = { |
|
1126 | ownerDS.responseSchema = { | |
1127 | fields: ["id", "fname", "lname", "nname", "gravatar_lnk"] |
|
1127 | fields: ["id", "fname", "lname", "nname", "gravatar_lnk"] | |
1128 | }; |
|
1128 | }; | |
1129 |
|
1129 | |||
1130 | // Instantiate AutoComplete for mentions |
|
1130 | // Instantiate AutoComplete for mentions | |
1131 | var ownerAC = new YAHOO.widget.AutoComplete(divid, cont, ownerDS); |
|
1131 | var ownerAC = new YAHOO.widget.AutoComplete(divid, cont, ownerDS); | |
1132 | ownerAC.useShadow = false; |
|
1132 | ownerAC.useShadow = false; | |
1133 | ownerAC.resultTypeList = false; |
|
1133 | ownerAC.resultTypeList = false; | |
1134 | ownerAC.suppressInputUpdate = true; |
|
1134 | ownerAC.suppressInputUpdate = true; | |
1135 | ownerAC.animVert = false; |
|
1135 | ownerAC.animVert = false; | |
1136 | ownerAC.animHoriz = false; |
|
1136 | ownerAC.animHoriz = false; | |
1137 | ownerAC.animSpeed = 0.1; |
|
1137 | ownerAC.animSpeed = 0.1; | |
1138 |
|
1138 | |||
1139 | // Helper highlight function for the formatter |
|
1139 | // Helper highlight function for the formatter | |
1140 | var highlightMatch = function (full, snippet, matchindex) { |
|
1140 | var highlightMatch = function (full, snippet, matchindex) { | |
1141 | return full.substring(0, matchindex) |
|
1141 | return full.substring(0, matchindex) | |
1142 | + "<span class='match'>" |
|
1142 | + "<span class='match'>" | |
1143 | + full.substr(matchindex, snippet.length) |
|
1143 | + full.substr(matchindex, snippet.length) | |
1144 | + "</span>" + full.substring(matchindex + snippet.length); |
|
1144 | + "</span>" + full.substring(matchindex + snippet.length); | |
1145 | }; |
|
1145 | }; | |
1146 |
|
1146 | |||
1147 | // Custom formatter to highlight the matching letters |
|
1147 | // Custom formatter to highlight the matching letters | |
1148 | ownerAC.formatResult = function (oResultData, sQuery, sResultMatch) { |
|
1148 | ownerAC.formatResult = function (oResultData, sQuery, sResultMatch) { | |
1149 | var org_sQuery = sQuery; |
|
1149 | var org_sQuery = sQuery; | |
1150 | if(this.dataSource.mentionQuery != null){ |
|
1150 | if(this.dataSource.mentionQuery != null){ | |
1151 | sQuery = this.dataSource.mentionQuery; |
|
1151 | sQuery = this.dataSource.mentionQuery; | |
1152 | } |
|
1152 | } | |
1153 |
|
1153 | |||
1154 | var query = sQuery.toLowerCase(); |
|
1154 | var query = sQuery.toLowerCase(); | |
1155 | var _gravatar = function(res, em, group){ |
|
1155 | var _gravatar = function(res, em, group){ | |
1156 | if (group !== undefined){ |
|
1156 | if (group !== undefined){ | |
1157 | em = '/images/icons/group.png' |
|
1157 | em = '/images/icons/group.png' | |
1158 | } |
|
1158 | } | |
1159 | tmpl = '<div class="ac-container-wrap"><img class="perm-gravatar-ac" src="{0}"/>{1}</div>' |
|
1159 | tmpl = '<div class="ac-container-wrap"><img class="perm-gravatar-ac" src="{0}"/>{1}</div>' | |
1160 | return tmpl.format(em,res) |
|
1160 | return tmpl.format(em,res) | |
1161 | } |
|
1161 | } | |
1162 | if (oResultData.nname != undefined) { |
|
1162 | if (oResultData.nname != undefined) { | |
1163 | var fname = oResultData.fname || ""; |
|
1163 | var fname = oResultData.fname || ""; | |
1164 | var lname = oResultData.lname || ""; |
|
1164 | var lname = oResultData.lname || ""; | |
1165 | var nname = oResultData.nname; |
|
1165 | var nname = oResultData.nname; | |
1166 |
|
1166 | |||
1167 | // Guard against null value |
|
1167 | // Guard against null value | |
1168 | var fnameMatchIndex = fname.toLowerCase().indexOf(query), |
|
1168 | var fnameMatchIndex = fname.toLowerCase().indexOf(query), | |
1169 | lnameMatchIndex = lname.toLowerCase().indexOf(query), |
|
1169 | lnameMatchIndex = lname.toLowerCase().indexOf(query), | |
1170 | nnameMatchIndex = nname.toLowerCase().indexOf(query), |
|
1170 | nnameMatchIndex = nname.toLowerCase().indexOf(query), | |
1171 | displayfname, displaylname, displaynname; |
|
1171 | displayfname, displaylname, displaynname; | |
1172 |
|
1172 | |||
1173 | if (fnameMatchIndex > -1) { |
|
1173 | if (fnameMatchIndex > -1) { | |
1174 | displayfname = highlightMatch(fname, query, fnameMatchIndex); |
|
1174 | displayfname = highlightMatch(fname, query, fnameMatchIndex); | |
1175 | } else { |
|
1175 | } else { | |
1176 | displayfname = fname; |
|
1176 | displayfname = fname; | |
1177 | } |
|
1177 | } | |
1178 |
|
1178 | |||
1179 | if (lnameMatchIndex > -1) { |
|
1179 | if (lnameMatchIndex > -1) { | |
1180 | displaylname = highlightMatch(lname, query, lnameMatchIndex); |
|
1180 | displaylname = highlightMatch(lname, query, lnameMatchIndex); | |
1181 | } else { |
|
1181 | } else { | |
1182 | displaylname = lname; |
|
1182 | displaylname = lname; | |
1183 | } |
|
1183 | } | |
1184 |
|
1184 | |||
1185 | if (nnameMatchIndex > -1) { |
|
1185 | if (nnameMatchIndex > -1) { | |
1186 | displaynname = "(" + highlightMatch(nname, query, nnameMatchIndex) + ")"; |
|
1186 | displaynname = "(" + highlightMatch(nname, query, nnameMatchIndex) + ")"; | |
1187 | } else { |
|
1187 | } else { | |
1188 | displaynname = nname ? "(" + nname + ")" : ""; |
|
1188 | displaynname = nname ? "(" + nname + ")" : ""; | |
1189 | } |
|
1189 | } | |
1190 |
|
1190 | |||
1191 | return _gravatar(displayfname + " " + displaylname + " " + displaynname, oResultData.gravatar_lnk); |
|
1191 | return _gravatar(displayfname + " " + displaylname + " " + displaynname, oResultData.gravatar_lnk); | |
1192 | } else { |
|
1192 | } else { | |
1193 | return ''; |
|
1193 | return ''; | |
1194 | } |
|
1194 | } | |
1195 | }; |
|
1195 | }; | |
1196 |
|
1196 | |||
1197 | if(ownerAC.itemSelectEvent){ |
|
1197 | if(ownerAC.itemSelectEvent){ | |
1198 | ownerAC.itemSelectEvent.subscribe(function (sType, aArgs) { |
|
1198 | ownerAC.itemSelectEvent.subscribe(function (sType, aArgs) { | |
1199 |
|
1199 | |||
1200 | var myAC = aArgs[0]; // reference back to the AC instance |
|
1200 | var myAC = aArgs[0]; // reference back to the AC instance | |
1201 | var elLI = aArgs[1]; // reference to the selected LI element |
|
1201 | var elLI = aArgs[1]; // reference to the selected LI element | |
1202 | var oData = aArgs[2]; // object literal of selected item's result data |
|
1202 | var oData = aArgs[2]; // object literal of selected item's result data | |
1203 | //fill the autocomplete with value |
|
1203 | //fill the autocomplete with value | |
1204 | if (oData.nname != undefined) { |
|
1204 | if (oData.nname != undefined) { | |
1205 | //users |
|
1205 | //users | |
1206 | //Replace the mention name with replaced |
|
1206 | //Replace the mention name with replaced | |
1207 | var re = new RegExp(); |
|
1207 | var re = new RegExp(); | |
1208 | var org = myAC.getInputEl().value; |
|
1208 | var org = myAC.getInputEl().value; | |
1209 | var chunks = myAC.dataSource.chunks |
|
1209 | var chunks = myAC.dataSource.chunks | |
1210 | // replace middle chunk(the search term) with actuall match |
|
1210 | // replace middle chunk(the search term) with actuall match | |
1211 | chunks[1] = chunks[1].replace('@'+myAC.dataSource.mentionQuery, |
|
1211 | chunks[1] = chunks[1].replace('@'+myAC.dataSource.mentionQuery, | |
1212 | '@'+oData.nname+' '); |
|
1212 | '@'+oData.nname+' '); | |
1213 | myAC.getInputEl().value = chunks.join('') |
|
1213 | myAC.getInputEl().value = chunks.join('') | |
1214 | YUD.get(myAC.getInputEl()).focus(); // Y U NO WORK !? |
|
1214 | YUD.get(myAC.getInputEl()).focus(); // Y U NO WORK !? | |
1215 | } else { |
|
1215 | } else { | |
1216 | //groups |
|
1216 | //groups | |
1217 | myAC.getInputEl().value = oData.grname; |
|
1217 | myAC.getInputEl().value = oData.grname; | |
1218 | YUD.get('perm_new_member_type').value = 'users_group'; |
|
1218 | YUD.get('perm_new_member_type').value = 'users_group'; | |
1219 | } |
|
1219 | } | |
1220 | }); |
|
1220 | }); | |
1221 | } |
|
1221 | } | |
1222 |
|
1222 | |||
1223 | // in this keybuffer we will gather current value of search ! |
|
1223 | // in this keybuffer we will gather current value of search ! | |
1224 | // since we need to get this just when someone does `@` then we do the |
|
1224 | // since we need to get this just when someone does `@` then we do the | |
1225 | // search |
|
1225 | // search | |
1226 | ownerAC.dataSource.chunks = []; |
|
1226 | ownerAC.dataSource.chunks = []; | |
1227 | ownerAC.dataSource.mentionQuery = null; |
|
1227 | ownerAC.dataSource.mentionQuery = null; | |
1228 |
|
1228 | |||
1229 | ownerAC.get_mention = function(msg, max_pos) { |
|
1229 | ownerAC.get_mention = function(msg, max_pos) { | |
1230 | var org = msg; |
|
1230 | var org = msg; | |
1231 | var re = new RegExp('(?:^@|\s@)([a-zA-Z0-9]{1}[a-zA-Z0-9\-\_\.]+)$') |
|
1231 | var re = new RegExp('(?:^@|\s@)([a-zA-Z0-9]{1}[a-zA-Z0-9\-\_\.]+)$') | |
1232 | var chunks = []; |
|
1232 | var chunks = []; | |
1233 |
|
1233 | |||
1234 |
|
1234 | |||
1235 | // cut first chunk until curret pos |
|
1235 | // cut first chunk until curret pos | |
1236 | var to_max = msg.substr(0, max_pos); |
|
1236 | var to_max = msg.substr(0, max_pos); | |
1237 | var at_pos = Math.max(0,to_max.lastIndexOf('@')-1); |
|
1237 | var at_pos = Math.max(0,to_max.lastIndexOf('@')-1); | |
1238 | var msg2 = to_max.substr(at_pos); |
|
1238 | var msg2 = to_max.substr(at_pos); | |
1239 |
|
1239 | |||
1240 | chunks.push(org.substr(0,at_pos))// prefix chunk |
|
1240 | chunks.push(org.substr(0,at_pos))// prefix chunk | |
1241 | chunks.push(msg2) // search chunk |
|
1241 | chunks.push(msg2) // search chunk | |
1242 | chunks.push(org.substr(max_pos)) // postfix chunk |
|
1242 | chunks.push(org.substr(max_pos)) // postfix chunk | |
1243 |
|
1243 | |||
1244 | // clean up msg2 for filtering and regex match |
|
1244 | // clean up msg2 for filtering and regex match | |
1245 | var msg2 = msg2.lstrip(' ').lstrip('\n'); |
|
1245 | var msg2 = msg2.lstrip(' ').lstrip('\n'); | |
1246 |
|
1246 | |||
1247 | if(re.test(msg2)){ |
|
1247 | if(re.test(msg2)){ | |
1248 | var unam = re.exec(msg2)[1]; |
|
1248 | var unam = re.exec(msg2)[1]; | |
1249 | return [unam, chunks]; |
|
1249 | return [unam, chunks]; | |
1250 | } |
|
1250 | } | |
1251 | return [null, null]; |
|
1251 | return [null, null]; | |
1252 | }; |
|
1252 | }; | |
1253 |
|
1253 | |||
1254 | if (ownerAC.textboxKeyUpEvent){ |
|
1254 | if (ownerAC.textboxKeyUpEvent){ | |
1255 | ownerAC.textboxKeyUpEvent.subscribe(function(type, args){ |
|
1255 | ownerAC.textboxKeyUpEvent.subscribe(function(type, args){ | |
1256 |
|
1256 | |||
1257 | var ac_obj = args[0]; |
|
1257 | var ac_obj = args[0]; | |
1258 | var currentMessage = args[1]; |
|
1258 | var currentMessage = args[1]; | |
1259 | var currentCaretPosition = args[0]._elTextbox.selectionStart; |
|
1259 | var currentCaretPosition = args[0]._elTextbox.selectionStart; | |
1260 |
|
1260 | |||
1261 | var unam = ownerAC.get_mention(currentMessage, currentCaretPosition); |
|
1261 | var unam = ownerAC.get_mention(currentMessage, currentCaretPosition); | |
1262 | var curr_search = null; |
|
1262 | var curr_search = null; | |
1263 | if(unam[0]){ |
|
1263 | if(unam[0]){ | |
1264 | curr_search = unam[0]; |
|
1264 | curr_search = unam[0]; | |
1265 | } |
|
1265 | } | |
1266 |
|
1266 | |||
1267 | ownerAC.dataSource.chunks = unam[1]; |
|
1267 | ownerAC.dataSource.chunks = unam[1]; | |
1268 | ownerAC.dataSource.mentionQuery = curr_search; |
|
1268 | ownerAC.dataSource.mentionQuery = curr_search; | |
1269 |
|
1269 | |||
1270 | }) |
|
1270 | }) | |
1271 | } |
|
1271 | } | |
1272 | return { |
|
1272 | return { | |
1273 | ownerDS: ownerDS, |
|
1273 | ownerDS: ownerDS, | |
1274 | ownerAC: ownerAC, |
|
1274 | ownerAC: ownerAC, | |
1275 | }; |
|
1275 | }; | |
1276 | } |
|
1276 | } | |
1277 |
|
1277 | |||
1278 |
|
1278 | |||
1279 | var PullRequestAutoComplete = function (divid, cont, users_list, groups_list) { |
|
1279 | var PullRequestAutoComplete = function (divid, cont, users_list, groups_list) { | |
1280 | var myUsers = users_list; |
|
1280 | var myUsers = users_list; | |
1281 | var myGroups = groups_list; |
|
1281 | var myGroups = groups_list; | |
1282 |
|
1282 | |||
1283 | // Define a custom search function for the DataSource of users |
|
1283 | // Define a custom search function for the DataSource of users | |
1284 | var matchUsers = function (sQuery) { |
|
1284 | var matchUsers = function (sQuery) { | |
1285 | // Case insensitive matching |
|
1285 | // Case insensitive matching | |
1286 | var query = sQuery.toLowerCase(); |
|
1286 | var query = sQuery.toLowerCase(); | |
1287 | var i = 0; |
|
1287 | var i = 0; | |
1288 | var l = myUsers.length; |
|
1288 | var l = myUsers.length; | |
1289 | var matches = []; |
|
1289 | var matches = []; | |
1290 |
|
1290 | |||
1291 | // Match against each name of each contact |
|
1291 | // Match against each name of each contact | |
1292 | for (; i < l; i++) { |
|
1292 | for (; i < l; i++) { | |
1293 | contact = myUsers[i]; |
|
1293 | contact = myUsers[i]; | |
1294 | if (((contact.fname+"").toLowerCase().indexOf(query) > -1) || |
|
1294 | if (((contact.fname+"").toLowerCase().indexOf(query) > -1) || | |
1295 | ((contact.lname+"").toLowerCase().indexOf(query) > -1) || |
|
1295 | ((contact.lname+"").toLowerCase().indexOf(query) > -1) || | |
1296 | ((contact.nname) && ((contact.nname).toLowerCase().indexOf(query) > -1))) { |
|
1296 | ((contact.nname) && ((contact.nname).toLowerCase().indexOf(query) > -1))) { | |
1297 | matches[matches.length] = contact; |
|
1297 | matches[matches.length] = contact; | |
1298 | } |
|
1298 | } | |
1299 | } |
|
1299 | } | |
1300 | return matches; |
|
1300 | return matches; | |
1301 | }; |
|
1301 | }; | |
1302 |
|
1302 | |||
1303 | // Define a custom search function for the DataSource of usersGroups |
|
1303 | // Define a custom search function for the DataSource of usersGroups | |
1304 | var matchGroups = function (sQuery) { |
|
1304 | var matchGroups = function (sQuery) { | |
1305 | // Case insensitive matching |
|
1305 | // Case insensitive matching | |
1306 | var query = sQuery.toLowerCase(); |
|
1306 | var query = sQuery.toLowerCase(); | |
1307 | var i = 0; |
|
1307 | var i = 0; | |
1308 | var l = myGroups.length; |
|
1308 | var l = myGroups.length; | |
1309 | var matches = []; |
|
1309 | var matches = []; | |
1310 |
|
1310 | |||
1311 | // Match against each name of each contact |
|
1311 | // Match against each name of each contact | |
1312 | for (; i < l; i++) { |
|
1312 | for (; i < l; i++) { | |
1313 | matched_group = myGroups[i]; |
|
1313 | matched_group = myGroups[i]; | |
1314 | if (matched_group.grname.toLowerCase().indexOf(query) > -1) { |
|
1314 | if (matched_group.grname.toLowerCase().indexOf(query) > -1) { | |
1315 | matches[matches.length] = matched_group; |
|
1315 | matches[matches.length] = matched_group; | |
1316 | } |
|
1316 | } | |
1317 | } |
|
1317 | } | |
1318 | return matches; |
|
1318 | return matches; | |
1319 | }; |
|
1319 | }; | |
1320 |
|
1320 | |||
1321 | //match all |
|
1321 | //match all | |
1322 | var matchAll = function (sQuery) { |
|
1322 | var matchAll = function (sQuery) { | |
1323 | u = matchUsers(sQuery); |
|
1323 | u = matchUsers(sQuery); | |
1324 | return u |
|
1324 | return u | |
1325 | }; |
|
1325 | }; | |
1326 |
|
1326 | |||
1327 | // DataScheme for owner |
|
1327 | // DataScheme for owner | |
1328 | var ownerDS = new YAHOO.util.FunctionDataSource(matchUsers); |
|
1328 | var ownerDS = new YAHOO.util.FunctionDataSource(matchUsers); | |
1329 |
|
1329 | |||
1330 | ownerDS.responseSchema = { |
|
1330 | ownerDS.responseSchema = { | |
1331 | fields: ["id", "fname", "lname", "nname", "gravatar_lnk"] |
|
1331 | fields: ["id", "fname", "lname", "nname", "gravatar_lnk"] | |
1332 | }; |
|
1332 | }; | |
1333 |
|
1333 | |||
1334 | // Instantiate AutoComplete for mentions |
|
1334 | // Instantiate AutoComplete for mentions | |
1335 | var reviewerAC = new YAHOO.widget.AutoComplete(divid, cont, ownerDS); |
|
1335 | var reviewerAC = new YAHOO.widget.AutoComplete(divid, cont, ownerDS); | |
1336 | reviewerAC.useShadow = false; |
|
1336 | reviewerAC.useShadow = false; | |
1337 | reviewerAC.resultTypeList = false; |
|
1337 | reviewerAC.resultTypeList = false; | |
1338 | reviewerAC.suppressInputUpdate = true; |
|
1338 | reviewerAC.suppressInputUpdate = true; | |
1339 | reviewerAC.animVert = false; |
|
1339 | reviewerAC.animVert = false; | |
1340 | reviewerAC.animHoriz = false; |
|
1340 | reviewerAC.animHoriz = false; | |
1341 | reviewerAC.animSpeed = 0.1; |
|
1341 | reviewerAC.animSpeed = 0.1; | |
1342 |
|
1342 | |||
1343 | // Helper highlight function for the formatter |
|
1343 | // Helper highlight function for the formatter | |
1344 | var highlightMatch = function (full, snippet, matchindex) { |
|
1344 | var highlightMatch = function (full, snippet, matchindex) { | |
1345 | return full.substring(0, matchindex) |
|
1345 | return full.substring(0, matchindex) | |
1346 | + "<span class='match'>" |
|
1346 | + "<span class='match'>" | |
1347 | + full.substr(matchindex, snippet.length) |
|
1347 | + full.substr(matchindex, snippet.length) | |
1348 | + "</span>" + full.substring(matchindex + snippet.length); |
|
1348 | + "</span>" + full.substring(matchindex + snippet.length); | |
1349 | }; |
|
1349 | }; | |
1350 |
|
1350 | |||
1351 | // Custom formatter to highlight the matching letters |
|
1351 | // Custom formatter to highlight the matching letters | |
1352 | reviewerAC.formatResult = function (oResultData, sQuery, sResultMatch) { |
|
1352 | reviewerAC.formatResult = function (oResultData, sQuery, sResultMatch) { | |
1353 | var org_sQuery = sQuery; |
|
1353 | var org_sQuery = sQuery; | |
1354 | if(this.dataSource.mentionQuery != null){ |
|
1354 | if(this.dataSource.mentionQuery != null){ | |
1355 | sQuery = this.dataSource.mentionQuery; |
|
1355 | sQuery = this.dataSource.mentionQuery; | |
1356 | } |
|
1356 | } | |
1357 |
|
1357 | |||
1358 | var query = sQuery.toLowerCase(); |
|
1358 | var query = sQuery.toLowerCase(); | |
1359 | var _gravatar = function(res, em, group){ |
|
1359 | var _gravatar = function(res, em, group){ | |
1360 | if (group !== undefined){ |
|
1360 | if (group !== undefined){ | |
1361 | em = '/images/icons/group.png' |
|
1361 | em = '/images/icons/group.png' | |
1362 | } |
|
1362 | } | |
1363 | tmpl = '<div class="ac-container-wrap"><img class="perm-gravatar-ac" src="{0}"/>{1}</div>' |
|
1363 | tmpl = '<div class="ac-container-wrap"><img class="perm-gravatar-ac" src="{0}"/>{1}</div>' | |
1364 | return tmpl.format(em,res) |
|
1364 | return tmpl.format(em,res) | |
1365 | } |
|
1365 | } | |
1366 | if (oResultData.nname != undefined) { |
|
1366 | if (oResultData.nname != undefined) { | |
1367 | var fname = oResultData.fname || ""; |
|
1367 | var fname = oResultData.fname || ""; | |
1368 | var lname = oResultData.lname || ""; |
|
1368 | var lname = oResultData.lname || ""; | |
1369 | var nname = oResultData.nname; |
|
1369 | var nname = oResultData.nname; | |
1370 |
|
1370 | |||
1371 | // Guard against null value |
|
1371 | // Guard against null value | |
1372 | var fnameMatchIndex = fname.toLowerCase().indexOf(query), |
|
1372 | var fnameMatchIndex = fname.toLowerCase().indexOf(query), | |
1373 | lnameMatchIndex = lname.toLowerCase().indexOf(query), |
|
1373 | lnameMatchIndex = lname.toLowerCase().indexOf(query), | |
1374 | nnameMatchIndex = nname.toLowerCase().indexOf(query), |
|
1374 | nnameMatchIndex = nname.toLowerCase().indexOf(query), | |
1375 | displayfname, displaylname, displaynname; |
|
1375 | displayfname, displaylname, displaynname; | |
1376 |
|
1376 | |||
1377 | if (fnameMatchIndex > -1) { |
|
1377 | if (fnameMatchIndex > -1) { | |
1378 | displayfname = highlightMatch(fname, query, fnameMatchIndex); |
|
1378 | displayfname = highlightMatch(fname, query, fnameMatchIndex); | |
1379 | } else { |
|
1379 | } else { | |
1380 | displayfname = fname; |
|
1380 | displayfname = fname; | |
1381 | } |
|
1381 | } | |
1382 |
|
1382 | |||
1383 | if (lnameMatchIndex > -1) { |
|
1383 | if (lnameMatchIndex > -1) { | |
1384 | displaylname = highlightMatch(lname, query, lnameMatchIndex); |
|
1384 | displaylname = highlightMatch(lname, query, lnameMatchIndex); | |
1385 | } else { |
|
1385 | } else { | |
1386 | displaylname = lname; |
|
1386 | displaylname = lname; | |
1387 | } |
|
1387 | } | |
1388 |
|
1388 | |||
1389 | if (nnameMatchIndex > -1) { |
|
1389 | if (nnameMatchIndex > -1) { | |
1390 | displaynname = "(" + highlightMatch(nname, query, nnameMatchIndex) + ")"; |
|
1390 | displaynname = "(" + highlightMatch(nname, query, nnameMatchIndex) + ")"; | |
1391 | } else { |
|
1391 | } else { | |
1392 | displaynname = nname ? "(" + nname + ")" : ""; |
|
1392 | displaynname = nname ? "(" + nname + ")" : ""; | |
1393 | } |
|
1393 | } | |
1394 |
|
1394 | |||
1395 | return _gravatar(displayfname + " " + displaylname + " " + displaynname, oResultData.gravatar_lnk); |
|
1395 | return _gravatar(displayfname + " " + displaylname + " " + displaynname, oResultData.gravatar_lnk); | |
1396 | } else { |
|
1396 | } else { | |
1397 | return ''; |
|
1397 | return ''; | |
1398 | } |
|
1398 | } | |
1399 | }; |
|
1399 | }; | |
1400 |
|
1400 | |||
1401 | //members cache to catch duplicates |
|
1401 | //members cache to catch duplicates | |
1402 | reviewerAC.dataSource.cache = []; |
|
1402 | reviewerAC.dataSource.cache = []; | |
1403 | // hack into select event |
|
1403 | // hack into select event | |
1404 | if(reviewerAC.itemSelectEvent){ |
|
1404 | if(reviewerAC.itemSelectEvent){ | |
1405 | reviewerAC.itemSelectEvent.subscribe(function (sType, aArgs) { |
|
1405 | reviewerAC.itemSelectEvent.subscribe(function (sType, aArgs) { | |
1406 |
|
1406 | |||
1407 | var myAC = aArgs[0]; // reference back to the AC instance |
|
1407 | var myAC = aArgs[0]; // reference back to the AC instance | |
1408 | var elLI = aArgs[1]; // reference to the selected LI element |
|
1408 | var elLI = aArgs[1]; // reference to the selected LI element | |
1409 | var oData = aArgs[2]; // object literal of selected item's result data |
|
1409 | var oData = aArgs[2]; // object literal of selected item's result data | |
1410 | var members = YUD.get('review_members'); |
|
1410 | var members = YUD.get('review_members'); | |
1411 | //fill the autocomplete with value |
|
1411 | //fill the autocomplete with value | |
1412 |
|
1412 | |||
1413 | if (oData.nname != undefined) { |
|
1413 | if (oData.nname != undefined) { | |
1414 | if (myAC.dataSource.cache.indexOf(oData.id) != -1){ |
|
1414 | if (myAC.dataSource.cache.indexOf(oData.id) != -1){ | |
1415 | return |
|
1415 | return | |
1416 | } |
|
1416 | } | |
1417 |
|
1417 | |||
1418 | var tmpl = '<li id="reviewer_{2}">'+ |
|
1418 | var tmpl = '<li id="reviewer_{2}">'+ | |
1419 | '<div class="reviewers_member">'+ |
|
1419 | '<div class="reviewers_member">'+ | |
1420 | '<div class="gravatar"><img alt="gravatar" src="{0}"/> </div>'+ |
|
1420 | '<div class="gravatar"><img alt="gravatar" src="{0}"/> </div>'+ | |
1421 | '<div style="float:left">{1}</div>'+ |
|
1421 | '<div style="float:left">{1}</div>'+ | |
1422 | '<input type="hidden" value="{2}" name="review_members" />'+ |
|
1422 | '<input type="hidden" value="{2}" name="review_members" />'+ | |
1423 | '<span class="delete_icon action_button" onclick="removeReviewer({2})"></span>'+ |
|
1423 | '<span class="delete_icon action_button" onclick="removeReviewer({2})"></span>'+ | |
1424 | '</div>'+ |
|
1424 | '</div>'+ | |
1425 | '</li>' |
|
1425 | '</li>' | |
1426 |
|
1426 | |||
1427 | var displayname = "{0} {1} ({2})".format(oData.fname,oData.lname,oData.nname); |
|
1427 | var displayname = "{0} {1} ({2})".format(oData.fname,oData.lname,oData.nname); | |
1428 | var element = tmpl.format(oData.gravatar_lnk,displayname,oData.id); |
|
1428 | var element = tmpl.format(oData.gravatar_lnk,displayname,oData.id); | |
1429 | members.innerHTML += element; |
|
1429 | members.innerHTML += element; | |
1430 | myAC.dataSource.cache.push(oData.id); |
|
1430 | myAC.dataSource.cache.push(oData.id); | |
1431 | YUD.get('user').value = '' |
|
1431 | YUD.get('user').value = '' | |
1432 | } |
|
1432 | } | |
1433 | }); |
|
1433 | }); | |
1434 | } |
|
1434 | } | |
1435 | return { |
|
1435 | return { | |
1436 | ownerDS: ownerDS, |
|
1436 | ownerDS: ownerDS, | |
1437 | reviewerAC: reviewerAC, |
|
1437 | reviewerAC: reviewerAC, | |
1438 | }; |
|
1438 | }; | |
1439 | } |
|
1439 | } | |
1440 |
|
1440 | |||
1441 |
|
1441 | |||
1442 | /** |
|
1442 | /** | |
1443 | * QUICK REPO MENU |
|
1443 | * QUICK REPO MENU | |
1444 | */ |
|
1444 | */ | |
1445 | var quick_repo_menu = function(){ |
|
1445 | var quick_repo_menu = function(){ | |
1446 | YUE.on(YUQ('.quick_repo_menu'),'mouseenter',function(e){ |
|
1446 | YUE.on(YUQ('.quick_repo_menu'),'mouseenter',function(e){ | |
1447 | var menu = e.currentTarget.firstElementChild.firstElementChild; |
|
1447 | var menu = e.currentTarget.firstElementChild.firstElementChild; | |
1448 | if(YUD.hasClass(menu,'hidden')){ |
|
1448 | if(YUD.hasClass(menu,'hidden')){ | |
1449 | YUD.replaceClass(e.currentTarget,'hidden', 'active'); |
|
1449 | YUD.replaceClass(e.currentTarget,'hidden', 'active'); | |
1450 | YUD.replaceClass(menu, 'hidden', 'active'); |
|
1450 | YUD.replaceClass(menu, 'hidden', 'active'); | |
1451 | } |
|
1451 | } | |
1452 | }) |
|
1452 | }) | |
1453 | YUE.on(YUQ('.quick_repo_menu'),'mouseleave',function(e){ |
|
1453 | YUE.on(YUQ('.quick_repo_menu'),'mouseleave',function(e){ | |
1454 | var menu = e.currentTarget.firstElementChild.firstElementChild; |
|
1454 | var menu = e.currentTarget.firstElementChild.firstElementChild; | |
1455 | if(YUD.hasClass(menu,'active')){ |
|
1455 | if(YUD.hasClass(menu,'active')){ | |
1456 | YUD.replaceClass(e.currentTarget, 'active', 'hidden'); |
|
1456 | YUD.replaceClass(e.currentTarget, 'active', 'hidden'); | |
1457 | YUD.replaceClass(menu, 'active', 'hidden'); |
|
1457 | YUD.replaceClass(menu, 'active', 'hidden'); | |
1458 | } |
|
1458 | } | |
1459 | }) |
|
1459 | }) | |
1460 | }; |
|
1460 | }; | |
1461 |
|
1461 | |||
1462 |
|
1462 | |||
1463 | /** |
|
1463 | /** | |
1464 | * TABLE SORTING |
|
1464 | * TABLE SORTING | |
1465 | */ |
|
1465 | */ | |
1466 |
|
1466 | |||
1467 | // returns a node from given html; |
|
1467 | // returns a node from given html; | |
1468 | var fromHTML = function(html){ |
|
1468 | var fromHTML = function(html){ | |
1469 | var _html = document.createElement('element'); |
|
1469 | var _html = document.createElement('element'); | |
1470 | _html.innerHTML = html; |
|
1470 | _html.innerHTML = html; | |
1471 | return _html; |
|
1471 | return _html; | |
1472 | } |
|
1472 | } | |
1473 | var get_rev = function(node){ |
|
1473 | var get_rev = function(node){ | |
1474 | var n = node.firstElementChild.firstElementChild; |
|
1474 | var n = node.firstElementChild.firstElementChild; | |
1475 |
|
1475 | |||
1476 | if (n===null){ |
|
1476 | if (n===null){ | |
1477 | return -1 |
|
1477 | return -1 | |
1478 | } |
|
1478 | } | |
1479 | else{ |
|
1479 | else{ | |
1480 | out = n.firstElementChild.innerHTML.split(':')[0].replace('r',''); |
|
1480 | out = n.firstElementChild.innerHTML.split(':')[0].replace('r',''); | |
1481 | return parseInt(out); |
|
1481 | return parseInt(out); | |
1482 | } |
|
1482 | } | |
1483 | } |
|
1483 | } | |
1484 |
|
1484 | |||
1485 | var get_name = function(node){ |
|
1485 | var get_name = function(node){ | |
1486 | var name = node.firstElementChild.children[2].innerHTML; |
|
1486 | var name = node.firstElementChild.children[2].innerHTML; | |
1487 | return name |
|
1487 | return name | |
1488 | } |
|
1488 | } | |
1489 | var get_group_name = function(node){ |
|
1489 | var get_group_name = function(node){ | |
1490 | var name = node.firstElementChild.children[1].innerHTML; |
|
1490 | var name = node.firstElementChild.children[1].innerHTML; | |
1491 | return name |
|
1491 | return name | |
1492 | } |
|
1492 | } | |
1493 | var get_date = function(node){ |
|
1493 | var get_date = function(node){ | |
1494 | var date_ = YUD.getAttribute(node.firstElementChild,'date'); |
|
1494 | var date_ = YUD.getAttribute(node.firstElementChild,'date'); | |
1495 | return date_ |
|
1495 | return date_ | |
1496 | } |
|
1496 | } | |
1497 |
|
1497 | |||
1498 | var get_age = function(node){ |
|
1498 | var get_age = function(node){ | |
1499 | return node |
|
1499 | return node | |
1500 | } |
|
1500 | } | |
1501 |
|
1501 | |||
1502 | var get_link = function(node){ |
|
1502 | var get_link = function(node){ | |
1503 | return node.firstElementChild.text; |
|
1503 | return node.firstElementChild.text; | |
1504 | } |
|
1504 | } | |
1505 |
|
1505 | |||
1506 | var revisionSort = function(a, b, desc, field) { |
|
1506 | var revisionSort = function(a, b, desc, field) { | |
1507 |
|
1507 | |||
1508 | var a_ = fromHTML(a.getData(field)); |
|
1508 | var a_ = fromHTML(a.getData(field)); | |
1509 | var b_ = fromHTML(b.getData(field)); |
|
1509 | var b_ = fromHTML(b.getData(field)); | |
1510 |
|
1510 | |||
1511 | // extract revisions from string nodes |
|
1511 | // extract revisions from string nodes | |
1512 | a_ = get_rev(a_) |
|
1512 | a_ = get_rev(a_) | |
1513 | b_ = get_rev(b_) |
|
1513 | b_ = get_rev(b_) | |
1514 |
|
1514 | |||
1515 | var comp = YAHOO.util.Sort.compare; |
|
1515 | var comp = YAHOO.util.Sort.compare; | |
1516 | var compState = comp(a_, b_, desc); |
|
1516 | var compState = comp(a_, b_, desc); | |
1517 | return compState; |
|
1517 | return compState; | |
1518 | }; |
|
1518 | }; | |
1519 | var ageSort = function(a, b, desc, field) { |
|
1519 | var ageSort = function(a, b, desc, field) { | |
1520 | var a_ = fromHTML(a.getData(field)); |
|
1520 | var a_ = fromHTML(a.getData(field)); | |
1521 | var b_ = fromHTML(b.getData(field)); |
|
1521 | var b_ = fromHTML(b.getData(field)); | |
1522 |
|
1522 | |||
1523 | // extract name from table |
|
1523 | // extract name from table | |
1524 | a_ = get_date(a_) |
|
1524 | a_ = get_date(a_) | |
1525 | b_ = get_date(b_) |
|
1525 | b_ = get_date(b_) | |
1526 |
|
1526 | |||
1527 | var comp = YAHOO.util.Sort.compare; |
|
1527 | var comp = YAHOO.util.Sort.compare; | |
1528 | var compState = comp(a_, b_, desc); |
|
1528 | var compState = comp(a_, b_, desc); | |
1529 | return compState; |
|
1529 | return compState; | |
1530 | }; |
|
1530 | }; | |
1531 |
|
1531 | |||
1532 | var lastLoginSort = function(a, b, desc, field) { |
|
1532 | var lastLoginSort = function(a, b, desc, field) { | |
1533 | var a_ = a.getData('last_login_raw') || 0; |
|
1533 | var a_ = a.getData('last_login_raw') || 0; | |
1534 | var b_ = b.getData('last_login_raw') || 0; |
|
1534 | var b_ = b.getData('last_login_raw') || 0; | |
1535 |
|
1535 | |||
1536 | var comp = YAHOO.util.Sort.compare; |
|
1536 | var comp = YAHOO.util.Sort.compare; | |
1537 | var compState = comp(a_, b_, desc); |
|
1537 | var compState = comp(a_, b_, desc); | |
1538 | return compState; |
|
1538 | return compState; | |
1539 | }; |
|
1539 | }; | |
1540 |
|
1540 | |||
1541 | var nameSort = function(a, b, desc, field) { |
|
1541 | var nameSort = function(a, b, desc, field) { | |
1542 | var a_ = fromHTML(a.getData(field)); |
|
1542 | var a_ = fromHTML(a.getData(field)); | |
1543 | var b_ = fromHTML(b.getData(field)); |
|
1543 | var b_ = fromHTML(b.getData(field)); | |
1544 |
|
1544 | |||
1545 | // extract name from table |
|
1545 | // extract name from table | |
1546 | a_ = get_name(a_) |
|
1546 | a_ = get_name(a_) | |
1547 | b_ = get_name(b_) |
|
1547 | b_ = get_name(b_) | |
1548 |
|
1548 | |||
1549 | var comp = YAHOO.util.Sort.compare; |
|
1549 | var comp = YAHOO.util.Sort.compare; | |
1550 | var compState = comp(a_, b_, desc); |
|
1550 | var compState = comp(a_, b_, desc); | |
1551 | return compState; |
|
1551 | return compState; | |
1552 | }; |
|
1552 | }; | |
1553 |
|
1553 | |||
1554 | var permNameSort = function(a, b, desc, field) { |
|
1554 | var permNameSort = function(a, b, desc, field) { | |
1555 | var a_ = fromHTML(a.getData(field)); |
|
1555 | var a_ = fromHTML(a.getData(field)); | |
1556 | var b_ = fromHTML(b.getData(field)); |
|
1556 | var b_ = fromHTML(b.getData(field)); | |
1557 | // extract name from table |
|
1557 | // extract name from table | |
1558 |
|
1558 | |||
1559 | a_ = a_.children[0].innerHTML; |
|
1559 | a_ = a_.children[0].innerHTML; | |
1560 | b_ = b_.children[0].innerHTML; |
|
1560 | b_ = b_.children[0].innerHTML; | |
1561 |
|
1561 | |||
1562 | var comp = YAHOO.util.Sort.compare; |
|
1562 | var comp = YAHOO.util.Sort.compare; | |
1563 | var compState = comp(a_, b_, desc); |
|
1563 | var compState = comp(a_, b_, desc); | |
1564 | return compState; |
|
1564 | return compState; | |
1565 | }; |
|
1565 | }; | |
1566 |
|
1566 | |||
1567 | var groupNameSort = function(a, b, desc, field) { |
|
1567 | var groupNameSort = function(a, b, desc, field) { | |
1568 | var a_ = fromHTML(a.getData(field)); |
|
1568 | var a_ = fromHTML(a.getData(field)); | |
1569 | var b_ = fromHTML(b.getData(field)); |
|
1569 | var b_ = fromHTML(b.getData(field)); | |
1570 |
|
1570 | |||
1571 | // extract name from table |
|
1571 | // extract name from table | |
1572 | a_ = get_group_name(a_) |
|
1572 | a_ = get_group_name(a_) | |
1573 | b_ = get_group_name(b_) |
|
1573 | b_ = get_group_name(b_) | |
1574 |
|
1574 | |||
1575 | var comp = YAHOO.util.Sort.compare; |
|
1575 | var comp = YAHOO.util.Sort.compare; | |
1576 | var compState = comp(a_, b_, desc); |
|
1576 | var compState = comp(a_, b_, desc); | |
1577 | return compState; |
|
1577 | return compState; | |
1578 | }; |
|
1578 | }; | |
1579 | var dateSort = function(a, b, desc, field) { |
|
1579 | var dateSort = function(a, b, desc, field) { | |
1580 | var a_ = fromHTML(a.getData(field)); |
|
1580 | var a_ = fromHTML(a.getData(field)); | |
1581 | var b_ = fromHTML(b.getData(field)); |
|
1581 | var b_ = fromHTML(b.getData(field)); | |
1582 |
|
1582 | |||
1583 | // extract name from table |
|
1583 | // extract name from table | |
1584 | a_ = get_date(a_) |
|
1584 | a_ = get_date(a_) | |
1585 | b_ = get_date(b_) |
|
1585 | b_ = get_date(b_) | |
1586 |
|
1586 | |||
1587 | var comp = YAHOO.util.Sort.compare; |
|
1587 | var comp = YAHOO.util.Sort.compare; | |
1588 | var compState = comp(a_, b_, desc); |
|
1588 | var compState = comp(a_, b_, desc); | |
1589 | return compState; |
|
1589 | return compState; | |
1590 | }; |
|
1590 | }; | |
1591 |
|
1591 | |||
1592 | var linkSort = function(a, b, desc, field) { |
|
1592 | var linkSort = function(a, b, desc, field) { | |
1593 | var a_ = fromHTML(a.getData(field)); |
|
1593 | var a_ = fromHTML(a.getData(field)); | |
1594 | var b_ = fromHTML(a.getData(field)); |
|
1594 | var b_ = fromHTML(a.getData(field)); | |
1595 |
|
1595 | |||
1596 | // extract url text from string nodes |
|
1596 | // extract url text from string nodes | |
1597 | a_ = get_link(a_) |
|
1597 | a_ = get_link(a_) | |
1598 | b_ = get_link(b_) |
|
1598 | b_ = get_link(b_) | |
1599 |
|
1599 | |||
1600 | var comp = YAHOO.util.Sort.compare; |
|
1600 | var comp = YAHOO.util.Sort.compare; | |
1601 | var compState = comp(a_, b_, desc); |
|
1601 | var compState = comp(a_, b_, desc); | |
1602 | return compState; |
|
1602 | return compState; | |
1603 | } |
|
1603 | } | |
1604 |
|
1604 | |||
1605 |
|
1605 | |||
1606 | /* Multi selectors */ |
|
1606 | /* Multi selectors */ | |
1607 |
|
1607 | |||
1608 | var MultiSelectWidget = function(selected_id, available_id, form_id){ |
|
1608 | var MultiSelectWidget = function(selected_id, available_id, form_id){ | |
1609 |
|
1609 | |||
1610 |
|
1610 | |||
1611 | //definition of containers ID's |
|
1611 | //definition of containers ID's | |
1612 | var selected_container = selected_id; |
|
1612 | var selected_container = selected_id; | |
1613 | var available_container = available_id; |
|
1613 | var available_container = available_id; | |
1614 |
|
1614 | |||
1615 | //temp container for selected storage. |
|
1615 | //temp container for selected storage. | |
1616 | var cache = new Array(); |
|
1616 | var cache = new Array(); | |
1617 | var av_cache = new Array(); |
|
1617 | var av_cache = new Array(); | |
1618 | var c = YUD.get(selected_container); |
|
1618 | var c = YUD.get(selected_container); | |
1619 | var ac = YUD.get(available_container); |
|
1619 | var ac = YUD.get(available_container); | |
1620 |
|
1620 | |||
1621 | //get only selected options for further fullfilment |
|
1621 | //get only selected options for further fullfilment | |
1622 | for(var i = 0;node =c.options[i];i++){ |
|
1622 | for(var i = 0;node =c.options[i];i++){ | |
1623 | if(node.selected){ |
|
1623 | if(node.selected){ | |
1624 | //push selected to my temp storage left overs :) |
|
1624 | //push selected to my temp storage left overs :) | |
1625 | cache.push(node); |
|
1625 | cache.push(node); | |
1626 | } |
|
1626 | } | |
1627 | } |
|
1627 | } | |
1628 |
|
1628 | |||
1629 | //get all available options to cache |
|
1629 | //get all available options to cache | |
1630 | for(var i = 0;node =ac.options[i];i++){ |
|
1630 | for(var i = 0;node =ac.options[i];i++){ | |
1631 | //push selected to my temp storage left overs :) |
|
1631 | //push selected to my temp storage left overs :) | |
1632 | av_cache.push(node); |
|
1632 | av_cache.push(node); | |
1633 | } |
|
1633 | } | |
1634 |
|
1634 | |||
1635 | //fill available only with those not in choosen |
|
1635 | //fill available only with those not in choosen | |
1636 | ac.options.length=0; |
|
1636 | ac.options.length=0; | |
1637 | tmp_cache = new Array(); |
|
1637 | tmp_cache = new Array(); | |
1638 |
|
1638 | |||
1639 | for(var i = 0;node = av_cache[i];i++){ |
|
1639 | for(var i = 0;node = av_cache[i];i++){ | |
1640 | var add = true; |
|
1640 | var add = true; | |
1641 | for(var i2 = 0;node_2 = cache[i2];i2++){ |
|
1641 | for(var i2 = 0;node_2 = cache[i2];i2++){ | |
1642 | if(node.value == node_2.value){ |
|
1642 | if(node.value == node_2.value){ | |
1643 | add=false; |
|
1643 | add=false; | |
1644 | break; |
|
1644 | break; | |
1645 | } |
|
1645 | } | |
1646 | } |
|
1646 | } | |
1647 | if(add){ |
|
1647 | if(add){ | |
1648 | tmp_cache.push(new Option(node.text, node.value, false, false)); |
|
1648 | tmp_cache.push(new Option(node.text, node.value, false, false)); | |
1649 | } |
|
1649 | } | |
1650 | } |
|
1650 | } | |
1651 |
|
1651 | |||
1652 | for(var i = 0;node = tmp_cache[i];i++){ |
|
1652 | for(var i = 0;node = tmp_cache[i];i++){ | |
1653 | ac.options[i] = node; |
|
1653 | ac.options[i] = node; | |
1654 | } |
|
1654 | } | |
1655 |
|
1655 | |||
1656 | function prompts_action_callback(e){ |
|
1656 | function prompts_action_callback(e){ | |
1657 |
|
1657 | |||
1658 | var choosen = YUD.get(selected_container); |
|
1658 | var choosen = YUD.get(selected_container); | |
1659 | var available = YUD.get(available_container); |
|
1659 | var available = YUD.get(available_container); | |
1660 |
|
1660 | |||
1661 | //get checked and unchecked options from field |
|
1661 | //get checked and unchecked options from field | |
1662 | function get_checked(from_field){ |
|
1662 | function get_checked(from_field){ | |
1663 | //temp container for storage. |
|
1663 | //temp container for storage. | |
1664 | var sel_cache = new Array(); |
|
1664 | var sel_cache = new Array(); | |
1665 | var oth_cache = new Array(); |
|
1665 | var oth_cache = new Array(); | |
1666 |
|
1666 | |||
1667 | for(var i = 0;node = from_field.options[i];i++){ |
|
1667 | for(var i = 0;node = from_field.options[i];i++){ | |
1668 | if(node.selected){ |
|
1668 | if(node.selected){ | |
1669 | //push selected fields :) |
|
1669 | //push selected fields :) | |
1670 | sel_cache.push(node); |
|
1670 | sel_cache.push(node); | |
1671 | } |
|
1671 | } | |
1672 | else{ |
|
1672 | else{ | |
1673 | oth_cache.push(node) |
|
1673 | oth_cache.push(node) | |
1674 | } |
|
1674 | } | |
1675 | } |
|
1675 | } | |
1676 |
|
1676 | |||
1677 | return [sel_cache,oth_cache] |
|
1677 | return [sel_cache,oth_cache] | |
1678 | } |
|
1678 | } | |
1679 |
|
1679 | |||
1680 | //fill the field with given options |
|
1680 | //fill the field with given options | |
1681 | function fill_with(field,options){ |
|
1681 | function fill_with(field,options){ | |
1682 | //clear firtst |
|
1682 | //clear firtst | |
1683 | field.options.length=0; |
|
1683 | field.options.length=0; | |
1684 | for(var i = 0;node = options[i];i++){ |
|
1684 | for(var i = 0;node = options[i];i++){ | |
1685 | field.options[i]=new Option(node.text, node.value, |
|
1685 | field.options[i]=new Option(node.text, node.value, | |
1686 | false, false); |
|
1686 | false, false); | |
1687 | } |
|
1687 | } | |
1688 |
|
1688 | |||
1689 | } |
|
1689 | } | |
1690 | //adds to current field |
|
1690 | //adds to current field | |
1691 | function add_to(field,options){ |
|
1691 | function add_to(field,options){ | |
1692 | for(var i = 0;node = options[i];i++){ |
|
1692 | for(var i = 0;node = options[i];i++){ | |
1693 | field.appendChild(new Option(node.text, node.value, |
|
1693 | field.appendChild(new Option(node.text, node.value, | |
1694 | false, false)); |
|
1694 | false, false)); | |
1695 | } |
|
1695 | } | |
1696 | } |
|
1696 | } | |
1697 |
|
1697 | |||
1698 | // add action |
|
1698 | // add action | |
1699 | if (this.id=='add_element'){ |
|
1699 | if (this.id=='add_element'){ | |
1700 | var c = get_checked(available); |
|
1700 | var c = get_checked(available); | |
1701 | add_to(choosen,c[0]); |
|
1701 | add_to(choosen,c[0]); | |
1702 | fill_with(available,c[1]); |
|
1702 | fill_with(available,c[1]); | |
1703 | } |
|
1703 | } | |
1704 | // remove action |
|
1704 | // remove action | |
1705 | if (this.id=='remove_element'){ |
|
1705 | if (this.id=='remove_element'){ | |
1706 | var c = get_checked(choosen); |
|
1706 | var c = get_checked(choosen); | |
1707 | add_to(available,c[0]); |
|
1707 | add_to(available,c[0]); | |
1708 | fill_with(choosen,c[1]); |
|
1708 | fill_with(choosen,c[1]); | |
1709 | } |
|
1709 | } | |
1710 | // add all elements |
|
1710 | // add all elements | |
1711 | if(this.id=='add_all_elements'){ |
|
1711 | if(this.id=='add_all_elements'){ | |
1712 | for(var i=0; node = available.options[i];i++){ |
|
1712 | for(var i=0; node = available.options[i];i++){ | |
1713 | choosen.appendChild(new Option(node.text, |
|
1713 | choosen.appendChild(new Option(node.text, | |
1714 | node.value, false, false)); |
|
1714 | node.value, false, false)); | |
1715 | } |
|
1715 | } | |
1716 | available.options.length = 0; |
|
1716 | available.options.length = 0; | |
1717 | } |
|
1717 | } | |
1718 | //remove all elements |
|
1718 | //remove all elements | |
1719 | if(this.id=='remove_all_elements'){ |
|
1719 | if(this.id=='remove_all_elements'){ | |
1720 | for(var i=0; node = choosen.options[i];i++){ |
|
1720 | for(var i=0; node = choosen.options[i];i++){ | |
1721 | available.appendChild(new Option(node.text, |
|
1721 | available.appendChild(new Option(node.text, | |
1722 | node.value, false, false)); |
|
1722 | node.value, false, false)); | |
1723 | } |
|
1723 | } | |
1724 | choosen.options.length = 0; |
|
1724 | choosen.options.length = 0; | |
1725 | } |
|
1725 | } | |
1726 |
|
1726 | |||
1727 | } |
|
1727 | } | |
1728 |
|
1728 | |||
1729 | YUE.addListener(['add_element','remove_element', |
|
1729 | YUE.addListener(['add_element','remove_element', | |
1730 | 'add_all_elements','remove_all_elements'],'click', |
|
1730 | 'add_all_elements','remove_all_elements'],'click', | |
1731 | prompts_action_callback) |
|
1731 | prompts_action_callback) | |
1732 | if (form_id !== undefined) { |
|
1732 | if (form_id !== undefined) { | |
1733 | YUE.addListener(form_id,'submit',function(){ |
|
1733 | YUE.addListener(form_id,'submit',function(){ | |
1734 | var choosen = YUD.get(selected_container); |
|
1734 | var choosen = YUD.get(selected_container); | |
1735 | for (var i = 0; i < choosen.options.length; i++) { |
|
1735 | for (var i = 0; i < choosen.options.length; i++) { | |
1736 | choosen.options[i].selected = 'selected'; |
|
1736 | choosen.options[i].selected = 'selected'; | |
1737 | } |
|
1737 | } | |
1738 | }); |
|
1738 | }); | |
1739 | } |
|
1739 | } | |
1740 | } No newline at end of file |
|
1740 | } |
@@ -1,179 +1,185 | |||||
1 | ## -*- coding: utf-8 -*- |
|
1 | ## -*- coding: utf-8 -*- | |
2 |
|
2 | |||
3 | <%inherit file="/base/base.html"/> |
|
3 | <%inherit file="/base/base.html"/> | |
4 |
|
4 | |||
5 | <%def name="title()"> |
|
5 | <%def name="title()"> | |
6 | ${_('%s Changeset') % c.repo_name} - r${c.changeset.revision}:${h.short_id(c.changeset.raw_id)} - ${c.rhodecode_name} |
|
6 | ${_('%s Changeset') % c.repo_name} - r${c.changeset.revision}:${h.short_id(c.changeset.raw_id)} - ${c.rhodecode_name} | |
7 | </%def> |
|
7 | </%def> | |
8 |
|
8 | |||
9 | <%def name="breadcrumbs_links()"> |
|
9 | <%def name="breadcrumbs_links()"> | |
10 | ${h.link_to(_(u'Home'),h.url('/'))} |
|
10 | ${h.link_to(_(u'Home'),h.url('/'))} | |
11 | » |
|
11 | » | |
12 | ${h.link_to(c.repo_name,h.url('summary_home',repo_name=c.repo_name))} |
|
12 | ${h.link_to(c.repo_name,h.url('summary_home',repo_name=c.repo_name))} | |
13 | » |
|
13 | » | |
14 | ${_('Changeset')} - <span class='hash'>r${c.changeset.revision}:${h.short_id(c.changeset.raw_id)}</span> |
|
14 | ${_('Changeset')} - <span class='hash'>r${c.changeset.revision}:${h.short_id(c.changeset.raw_id)}</span> | |
15 | </%def> |
|
15 | </%def> | |
16 |
|
16 | |||
17 | <%def name="page_nav()"> |
|
17 | <%def name="page_nav()"> | |
18 | ${self.menu('changelog')} |
|
18 | ${self.menu('changelog')} | |
19 | </%def> |
|
19 | </%def> | |
20 |
|
20 | |||
21 | <%def name="main()"> |
|
21 | <%def name="main()"> | |
22 | <div class="box"> |
|
22 | <div class="box"> | |
23 | <!-- box / title --> |
|
23 | <!-- box / title --> | |
24 | <div class="title"> |
|
24 | <div class="title"> | |
25 | ${self.breadcrumbs()} |
|
25 | ${self.breadcrumbs()} | |
26 | </div> |
|
26 | </div> | |
27 | <div class="table"> |
|
27 | <div class="table"> | |
28 | <div class="diffblock"> |
|
28 | <div class="diffblock"> | |
29 | <div class="code-header"> |
|
29 | <div class="code-header"> | |
30 | <div class="hash"> |
|
30 | <div class="hash"> | |
31 | r${c.changeset.revision}:${h.short_id(c.changeset.raw_id)} |
|
31 | r${c.changeset.revision}:${h.short_id(c.changeset.raw_id)} | |
32 | </div> |
|
32 | </div> | |
33 | <div class="date"> |
|
33 | <div class="date"> | |
34 | ${h.fmt_date(c.changeset.date)} |
|
34 | ${h.fmt_date(c.changeset.date)} | |
35 | </div> |
|
35 | </div> | |
36 | <div class="changeset-status-container"> |
|
36 | <div class="changeset-status-container"> | |
37 | %if c.statuses: |
|
37 | %if c.statuses: | |
38 | <div title="${_('Changeset status')}" class="changeset-status-lbl">[${h.changeset_status_lbl(c.statuses[0])}]</div> |
|
38 | <div title="${_('Changeset status')}" class="changeset-status-lbl">[${h.changeset_status_lbl(c.statuses[0])}]</div> | |
39 | <div class="changeset-status-ico"><img src="${h.url('/images/icons/flag_status_%s.png' % c.statuses[0])}" /></div> |
|
39 | <div class="changeset-status-ico"><img src="${h.url('/images/icons/flag_status_%s.png' % c.statuses[0])}" /></div> | |
40 | %endif |
|
40 | %endif | |
41 | </div> |
|
41 | </div> | |
42 | <div class="diff-actions"> |
|
42 | <div class="diff-actions"> | |
43 | <a href="${h.url('raw_changeset_home',repo_name=c.repo_name,revision=c.changeset.raw_id,diff='show')}" class="tooltip" title="${h.tooltip(_('raw diff'))}"><img class="icon" src="${h.url('/images/icons/page_white.png')}"/></a> |
|
43 | <a href="${h.url('raw_changeset_home',repo_name=c.repo_name,revision=c.changeset.raw_id,diff='show')}" class="tooltip" title="${h.tooltip(_('raw diff'))}"><img class="icon" src="${h.url('/images/icons/page_white.png')}"/></a> | |
44 | <a href="${h.url('raw_changeset_home',repo_name=c.repo_name,revision=c.changeset.raw_id,diff='download')}" class="tooltip" title="${h.tooltip(_('download diff'))}"><img class="icon" src="${h.url('/images/icons/page_white_get.png')}"/></a> |
|
44 | <a href="${h.url('raw_changeset_home',repo_name=c.repo_name,revision=c.changeset.raw_id,diff='download')}" class="tooltip" title="${h.tooltip(_('download diff'))}"><img class="icon" src="${h.url('/images/icons/page_white_get.png')}"/></a> | |
45 | ${c.ignorews_url(request.GET)} |
|
45 | ${c.ignorews_url(request.GET)} | |
46 | ${c.context_url(request.GET)} |
|
46 | ${c.context_url(request.GET)} | |
47 | </div> |
|
47 | </div> | |
48 | <div class="comments-number" style="float:right;padding-right:5px">${ungettext("%d comment", "%d comments", len(c.comments)) % len(c.comments)} ${ungettext("(%d inline)", "(%d inline)", c.inline_cnt) % c.inline_cnt}</div> |
|
48 | <div class="comments-number" style="float:right;padding-right:5px">${ungettext("%d comment", "%d comments", len(c.comments)) % len(c.comments)} ${ungettext("(%d inline)", "(%d inline)", c.inline_cnt) % c.inline_cnt}</div> | |
49 | </div> |
|
49 | </div> | |
50 | </div> |
|
50 | </div> | |
51 | <div id="changeset_content"> |
|
51 | <div id="changeset_content"> | |
52 | <div class="container"> |
|
52 | <div class="container"> | |
53 | <div class="left"> |
|
53 | <div class="left"> | |
54 | <div class="author"> |
|
54 | <div class="author"> | |
55 | <div class="gravatar"> |
|
55 | <div class="gravatar"> | |
56 | <img alt="gravatar" src="${h.gravatar_url(h.email(c.changeset.author),20)}"/> |
|
56 | <img alt="gravatar" src="${h.gravatar_url(h.email(c.changeset.author),20)}"/> | |
57 | </div> |
|
57 | </div> | |
58 | <span>${h.person(c.changeset.author)}</span><br/> |
|
58 | <span>${h.person(c.changeset.author)}</span><br/> | |
59 | <span><a href="mailto:${h.email_or_none(c.changeset.author)}">${h.email_or_none(c.changeset.author)}</a></span><br/> |
|
59 | <span><a href="mailto:${h.email_or_none(c.changeset.author)}">${h.email_or_none(c.changeset.author)}</a></span><br/> | |
60 | </div> |
|
60 | </div> | |
61 | <div class="message">${h.urlify_commit(c.changeset.message, c.repo_name)}</div> |
|
61 | <div class="message">${h.urlify_commit(c.changeset.message, c.repo_name)}</div> | |
62 | </div> |
|
62 | </div> | |
63 | <div class="right"> |
|
63 | <div class="right"> | |
64 | <div class="changes"> |
|
64 | <div class="changes"> | |
65 | % if len(c.changeset.affected_files) <= c.affected_files_cut_off: |
|
65 | % if len(c.changeset.affected_files) <= c.affected_files_cut_off: | |
66 | <span class="removed" title="${_('removed')}">${len(c.changeset.removed)}</span> |
|
66 | <span class="removed" title="${_('removed')}">${len(c.changeset.removed)}</span> | |
67 | <span class="changed" title="${_('changed')}">${len(c.changeset.changed)}</span> |
|
67 | <span class="changed" title="${_('changed')}">${len(c.changeset.changed)}</span> | |
68 | <span class="added" title="${_('added')}">${len(c.changeset.added)}</span> |
|
68 | <span class="added" title="${_('added')}">${len(c.changeset.added)}</span> | |
69 | % else: |
|
69 | % else: | |
70 | <span class="removed" title="${_('affected %s files') % len(c.changeset.affected_files)}">!</span> |
|
70 | <span class="removed" title="${_('affected %s files') % len(c.changeset.affected_files)}">!</span> | |
71 | <span class="changed" title="${_('affected %s files') % len(c.changeset.affected_files)}">!</span> |
|
71 | <span class="changed" title="${_('affected %s files') % len(c.changeset.affected_files)}">!</span> | |
72 | <span class="added" title="${_('affected %s files') % len(c.changeset.affected_files)}">!</span> |
|
72 | <span class="added" title="${_('affected %s files') % len(c.changeset.affected_files)}">!</span> | |
73 | % endif |
|
73 | % endif | |
74 | </div> |
|
74 | </div> | |
75 |
|
75 | |||
76 | %if c.changeset.parents: |
|
76 | %if c.changeset.parents: | |
77 | %for p_cs in reversed(c.changeset.parents): |
|
77 | %for p_cs in reversed(c.changeset.parents): | |
78 | <div class="parent">${_('Parent')} |
|
78 | <div class="parent">${_('Parent')} | |
79 | <span class="changeset_id">${p_cs.revision}:<span class="changeset_hash">${h.link_to(h.short_id(p_cs.raw_id), |
|
79 | <span class="changeset_id">${p_cs.revision}:<span class="changeset_hash">${h.link_to(h.short_id(p_cs.raw_id), | |
80 | h.url('changeset_home',repo_name=c.repo_name,revision=p_cs.raw_id),title=p_cs.message)}</span></span> |
|
80 | h.url('changeset_home',repo_name=c.repo_name,revision=p_cs.raw_id),title=p_cs.message)}</span></span> | |
81 | </div> |
|
81 | </div> | |
82 | %endfor |
|
82 | %endfor | |
83 | %else: |
|
83 | %else: | |
84 | <div class="parent">${_('No parents')}</div> |
|
84 | <div class="parent">${_('No parents')}</div> | |
85 | %endif |
|
85 | %endif | |
86 | <span class="logtags"> |
|
86 | <span class="logtags"> | |
87 | %if len(c.changeset.parents)>1: |
|
87 | %if len(c.changeset.parents)>1: | |
88 | <span class="merge">${_('merge')}</span> |
|
88 | <span class="merge">${_('merge')}</span> | |
89 | %endif |
|
89 | %endif | |
90 | %if c.changeset.branch: |
|
90 | %if c.changeset.branch: | |
91 | <span class="branchtag" title="${'%s %s' % (_('branch'),c.changeset.branch)}"> |
|
91 | <span class="branchtag" title="${'%s %s' % (_('branch'),c.changeset.branch)}"> | |
92 | ${h.link_to(c.changeset.branch,h.url('files_home',repo_name=c.repo_name,revision=c.changeset.raw_id))} |
|
92 | ${h.link_to(c.changeset.branch,h.url('files_home',repo_name=c.repo_name,revision=c.changeset.raw_id))} | |
93 | </span> |
|
93 | </span> | |
94 | %endif |
|
94 | %endif | |
95 | %for tag in c.changeset.tags: |
|
95 | %for tag in c.changeset.tags: | |
96 | <span class="tagtag" title="${'%s %s' % (_('tag'),tag)}"> |
|
96 | <span class="tagtag" title="${'%s %s' % (_('tag'),tag)}"> | |
97 | ${h.link_to(tag,h.url('files_home',repo_name=c.repo_name,revision=c.changeset.raw_id))}</span> |
|
97 | ${h.link_to(tag,h.url('files_home',repo_name=c.repo_name,revision=c.changeset.raw_id))}</span> | |
98 | %endfor |
|
98 | %endfor | |
99 | </span> |
|
99 | </span> | |
100 | </div> |
|
100 | </div> | |
101 | </div> |
|
101 | </div> | |
102 | <span> |
|
102 | <span> | |
103 | ${_('%s files affected with %s insertions and %s deletions:') % (len(c.changeset.affected_files),c.lines_added,c.lines_deleted)} |
|
103 | ${_('%s files affected with %s insertions and %s deletions:') % (len(c.changeset.affected_files),c.lines_added,c.lines_deleted)} | |
104 | </span> |
|
104 | </span> | |
105 | <div class="cs_files"> |
|
105 | <div class="cs_files"> | |
106 | %for change,filenode,diff,cs1,cs2,stat in c.changes: |
|
106 | %for change,filenode,diff,cs1,cs2,stat in c.changes: | |
107 | <div class="cs_${change}"> |
|
107 | <div class="cs_${change}"> | |
108 | <div class="node"> |
|
108 | <div class="node"> | |
109 | %if change != 'removed': |
|
109 | %if change != 'removed': | |
110 | ${h.link_to(h.safe_unicode(filenode.path),c.anchor_url(filenode.changeset.raw_id,filenode.path,request.GET)+"_target")} |
|
110 | ${h.link_to(h.safe_unicode(filenode.path),c.anchor_url(filenode.changeset.raw_id,filenode.path,request.GET)+"_target")} | |
111 | %else: |
|
111 | %else: | |
112 | ${h.link_to(h.safe_unicode(filenode.path),h.url.current(anchor=h.FID('',filenode.path)))} |
|
112 | ${h.link_to(h.safe_unicode(filenode.path),h.url.current(anchor=h.FID('',filenode.path)))} | |
113 | %endif |
|
113 | %endif | |
114 | </div> |
|
114 | </div> | |
115 | <div class="changes">${h.fancy_file_stats(stat)}</div> |
|
115 | <div class="changes">${h.fancy_file_stats(stat)}</div> | |
116 | </div> |
|
116 | </div> | |
117 | %endfor |
|
117 | %endfor | |
118 | % if c.cut_off: |
|
118 | % if c.cut_off: | |
119 | ${_('Changeset was too big and was cut off...')} |
|
119 | ${_('Changeset was too big and was cut off...')} | |
120 | % endif |
|
120 | % endif | |
121 | </div> |
|
121 | </div> | |
122 | </div> |
|
122 | </div> | |
123 |
|
123 | |||
124 | </div> |
|
124 | </div> | |
125 | <script> |
|
125 | <script> | |
126 | var _USERS_AC_DATA = ${c.users_array|n}; |
|
126 | var _USERS_AC_DATA = ${c.users_array|n}; | |
127 | var _GROUPS_AC_DATA = ${c.users_groups_array|n}; |
|
127 | var _GROUPS_AC_DATA = ${c.users_groups_array|n}; | |
128 | AJAX_COMMENT_URL = "${url('changeset_comment',repo_name=c.repo_name,revision=c.changeset.raw_id)}"; |
|
128 | AJAX_COMMENT_URL = "${url('changeset_comment',repo_name=c.repo_name,revision=c.changeset.raw_id)}"; | |
129 | AJAX_COMMENT_DELETE_URL = "${url('changeset_comment_delete',repo_name=c.repo_name,comment_id='__COMMENT_ID__')}"; |
|
129 | AJAX_COMMENT_DELETE_URL = "${url('changeset_comment_delete',repo_name=c.repo_name,comment_id='__COMMENT_ID__')}"; | |
130 | </script> |
|
130 | </script> | |
131 | ## diff block |
|
131 | ## diff block | |
132 | <%namespace name="diff_block" file="/changeset/diff_block.html"/> |
|
132 | <%namespace name="diff_block" file="/changeset/diff_block.html"/> | |
133 | ${diff_block.diff_block(c.changes)} |
|
133 | ${diff_block.diff_block(c.changes)} | |
134 |
|
134 | |||
135 | ## template for inline comment form |
|
135 | ## template for inline comment form | |
136 | <%namespace name="comment" file="/changeset/changeset_file_comment.html"/> |
|
136 | <%namespace name="comment" file="/changeset/changeset_file_comment.html"/> | |
137 | ${comment.comment_inline_form()} |
|
137 | ${comment.comment_inline_form()} | |
138 |
|
138 | |||
139 | ## render comments and inlines |
|
139 | ## render comments and inlines | |
140 | ${comment.generate_comments()} |
|
140 | ${comment.generate_comments()} | |
141 |
|
141 | |||
142 | ## main comment form and it status |
|
142 | ## main comment form and it status | |
143 | ${comment.comments(h.url('changeset_comment', repo_name=c.repo_name, revision=c.changeset.raw_id), |
|
143 | ${comment.comments(h.url('changeset_comment', repo_name=c.repo_name, revision=c.changeset.raw_id), | |
144 | h.changeset_status(c.rhodecode_db_repo, c.changeset.raw_id))} |
|
144 | h.changeset_status(c.rhodecode_db_repo, c.changeset.raw_id))} | |
145 |
|
145 | |||
146 | ## FORM FOR MAKING JS ACTION AS CHANGESET COMMENTS |
|
146 | ## FORM FOR MAKING JS ACTION AS CHANGESET COMMENTS | |
147 | <script type="text/javascript"> |
|
147 | <script type="text/javascript"> | |
148 | YUE.onDOMReady(function(){ |
|
148 | YUE.onDOMReady(function(){ | |
149 | YUE.on(YUQ('.show-inline-comments'),'change',function(e){ |
|
149 | YUE.on(YUQ('.show-inline-comments'),'change',function(e){ | |
150 | var show = 'none'; |
|
150 | var show = 'none'; | |
151 | var target = e.currentTarget; |
|
151 | var target = e.currentTarget; | |
|
152 | if(target == null){ | |||
|
153 | target = this; | |||
|
154 | } | |||
152 | if(target.checked){ |
|
155 | if(target.checked){ | |
153 | var show = '' |
|
156 | var show = '' | |
154 | } |
|
157 | } | |
155 | var boxid = YUD.getAttribute(target,'id_for'); |
|
158 | var boxid = YUD.getAttribute(target,'id_for'); | |
156 | var comments = YUQ('#{0} .inline-comments'.format(boxid)); |
|
159 | var comments = YUQ('#{0} .inline-comments'.format(boxid)); | |
157 | for(c in comments){ |
|
160 | for(c in comments){ | |
158 | YUD.setStyle(comments[c],'display',show); |
|
161 | YUD.setStyle(comments[c],'display',show); | |
159 | } |
|
162 | } | |
160 | var btns = YUQ('#{0} .inline-comments-button'.format(boxid)); |
|
163 | var btns = YUQ('#{0} .inline-comments-button'.format(boxid)); | |
161 | for(c in btns){ |
|
164 | for(c in btns){ | |
162 | YUD.setStyle(btns[c],'display',show); |
|
165 | YUD.setStyle(btns[c],'display',show); | |
163 | } |
|
166 | } | |
164 | }) |
|
167 | }) | |
165 |
|
168 | |||
166 | YUE.on(YUQ('.line'),'click',function(e){ |
|
169 | YUE.on(YUQ('.line'),'click',function(e){ | |
167 | var tr = e.currentTarget; |
|
170 | var tr = e.currentTarget; | |
|
171 | if(tr == null){ | |||
|
172 | tr = this; | |||
|
173 | } | |||
168 | injectInlineForm(tr); |
|
174 | injectInlineForm(tr); | |
169 | }); |
|
175 | }); | |
170 |
|
176 | |||
171 | // inject comments into they proper positions |
|
177 | // inject comments into they proper positions | |
172 | var file_comments = YUQ('.inline-comment-placeholder'); |
|
178 | var file_comments = YUQ('.inline-comment-placeholder'); | |
173 | renderInlineComments(file_comments); |
|
179 | renderInlineComments(file_comments); | |
174 | }) |
|
180 | }) | |
175 |
|
181 | |||
176 | </script> |
|
182 | </script> | |
177 |
|
183 | |||
178 | </div> |
|
184 | </div> | |
179 | </%def> |
|
185 | </%def> |
General Comments 0
You need to be logged in to leave comments.
Login now