##// END OF EJS Templates
use placeholders in qfilter, not the ugly JS logic
marcink -
r3665:690a955b beta
parent child Browse files
Show More
@@ -1,2174 +1,2170 b''
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 * SmartColorGenerator
90 * SmartColorGenerator
91 *
91 *
92 *usage::
92 *usage::
93 * var CG = new ColorGenerator();
93 * var CG = new ColorGenerator();
94 * var col = CG.getColor(key); //returns array of RGB
94 * var col = CG.getColor(key); //returns array of RGB
95 * 'rgb({0})'.format(col.join(',')
95 * 'rgb({0})'.format(col.join(',')
96 *
96 *
97 * @returns {ColorGenerator}
97 * @returns {ColorGenerator}
98 */
98 */
99 var ColorGenerator = function(){
99 var ColorGenerator = function(){
100 this.GOLDEN_RATIO = 0.618033988749895;
100 this.GOLDEN_RATIO = 0.618033988749895;
101 this.CURRENT_RATIO = 0.22717784590367374 // this can be random
101 this.CURRENT_RATIO = 0.22717784590367374 // this can be random
102 this.HSV_1 = 0.75;//saturation
102 this.HSV_1 = 0.75;//saturation
103 this.HSV_2 = 0.95;
103 this.HSV_2 = 0.95;
104 this.color;
104 this.color;
105 this.cacheColorMap = {};
105 this.cacheColorMap = {};
106 };
106 };
107
107
108 ColorGenerator.prototype = {
108 ColorGenerator.prototype = {
109 getColor:function(key){
109 getColor:function(key){
110 if(this.cacheColorMap[key] !== undefined){
110 if(this.cacheColorMap[key] !== undefined){
111 return this.cacheColorMap[key];
111 return this.cacheColorMap[key];
112 }
112 }
113 else{
113 else{
114 this.cacheColorMap[key] = this.generateColor();
114 this.cacheColorMap[key] = this.generateColor();
115 return this.cacheColorMap[key];
115 return this.cacheColorMap[key];
116 }
116 }
117 },
117 },
118 _hsvToRgb:function(h,s,v){
118 _hsvToRgb:function(h,s,v){
119 if (s == 0.0)
119 if (s == 0.0)
120 return [v, v, v];
120 return [v, v, v];
121 i = parseInt(h * 6.0)
121 i = parseInt(h * 6.0)
122 f = (h * 6.0) - i
122 f = (h * 6.0) - i
123 p = v * (1.0 - s)
123 p = v * (1.0 - s)
124 q = v * (1.0 - s * f)
124 q = v * (1.0 - s * f)
125 t = v * (1.0 - s * (1.0 - f))
125 t = v * (1.0 - s * (1.0 - f))
126 i = i % 6
126 i = i % 6
127 if (i == 0)
127 if (i == 0)
128 return [v, t, p]
128 return [v, t, p]
129 if (i == 1)
129 if (i == 1)
130 return [q, v, p]
130 return [q, v, p]
131 if (i == 2)
131 if (i == 2)
132 return [p, v, t]
132 return [p, v, t]
133 if (i == 3)
133 if (i == 3)
134 return [p, q, v]
134 return [p, q, v]
135 if (i == 4)
135 if (i == 4)
136 return [t, p, v]
136 return [t, p, v]
137 if (i == 5)
137 if (i == 5)
138 return [v, p, q]
138 return [v, p, q]
139 },
139 },
140 generateColor:function(){
140 generateColor:function(){
141 this.CURRENT_RATIO = this.CURRENT_RATIO+this.GOLDEN_RATIO;
141 this.CURRENT_RATIO = this.CURRENT_RATIO+this.GOLDEN_RATIO;
142 this.CURRENT_RATIO = this.CURRENT_RATIO %= 1;
142 this.CURRENT_RATIO = this.CURRENT_RATIO %= 1;
143 HSV_tuple = [this.CURRENT_RATIO, this.HSV_1, this.HSV_2]
143 HSV_tuple = [this.CURRENT_RATIO, this.HSV_1, this.HSV_2]
144 RGB_tuple = this._hsvToRgb(HSV_tuple[0],HSV_tuple[1],HSV_tuple[2]);
144 RGB_tuple = this._hsvToRgb(HSV_tuple[0],HSV_tuple[1],HSV_tuple[2]);
145 function toRgb(v){
145 function toRgb(v){
146 return ""+parseInt(v*256)
146 return ""+parseInt(v*256)
147 }
147 }
148 return [toRgb(RGB_tuple[0]),toRgb(RGB_tuple[1]),toRgb(RGB_tuple[2])];
148 return [toRgb(RGB_tuple[0]),toRgb(RGB_tuple[1]),toRgb(RGB_tuple[2])];
149
149
150 }
150 }
151 }
151 }
152
152
153 /**
153 /**
154 * PyRoutesJS
154 * PyRoutesJS
155 *
155 *
156 * Usage pyroutes.url('mark_error_fixed',{"error_id":error_id}) // /mark_error_fixed/<error_id>
156 * Usage pyroutes.url('mark_error_fixed',{"error_id":error_id}) // /mark_error_fixed/<error_id>
157 */
157 */
158 var pyroutes = (function() {
158 var pyroutes = (function() {
159 // access global map defined in special file pyroutes
159 // access global map defined in special file pyroutes
160 var matchlist = PROUTES_MAP;
160 var matchlist = PROUTES_MAP;
161 var sprintf = (function() {
161 var sprintf = (function() {
162 function get_type(variable) {
162 function get_type(variable) {
163 return Object.prototype.toString.call(variable).slice(8, -1).toLowerCase();
163 return Object.prototype.toString.call(variable).slice(8, -1).toLowerCase();
164 }
164 }
165 function str_repeat(input, multiplier) {
165 function str_repeat(input, multiplier) {
166 for (var output = []; multiplier > 0; output[--multiplier] = input) {/* do nothing */}
166 for (var output = []; multiplier > 0; output[--multiplier] = input) {/* do nothing */}
167 return output.join('');
167 return output.join('');
168 }
168 }
169
169
170 var str_format = function() {
170 var str_format = function() {
171 if (!str_format.cache.hasOwnProperty(arguments[0])) {
171 if (!str_format.cache.hasOwnProperty(arguments[0])) {
172 str_format.cache[arguments[0]] = str_format.parse(arguments[0]);
172 str_format.cache[arguments[0]] = str_format.parse(arguments[0]);
173 }
173 }
174 return str_format.format.call(null, str_format.cache[arguments[0]], arguments);
174 return str_format.format.call(null, str_format.cache[arguments[0]], arguments);
175 };
175 };
176
176
177 str_format.format = function(parse_tree, argv) {
177 str_format.format = function(parse_tree, argv) {
178 var cursor = 1, tree_length = parse_tree.length, node_type = '', arg, output = [], i, k, match, pad, pad_character, pad_length;
178 var cursor = 1, tree_length = parse_tree.length, node_type = '', arg, output = [], i, k, match, pad, pad_character, pad_length;
179 for (i = 0; i < tree_length; i++) {
179 for (i = 0; i < tree_length; i++) {
180 node_type = get_type(parse_tree[i]);
180 node_type = get_type(parse_tree[i]);
181 if (node_type === 'string') {
181 if (node_type === 'string') {
182 output.push(parse_tree[i]);
182 output.push(parse_tree[i]);
183 }
183 }
184 else if (node_type === 'array') {
184 else if (node_type === 'array') {
185 match = parse_tree[i]; // convenience purposes only
185 match = parse_tree[i]; // convenience purposes only
186 if (match[2]) { // keyword argument
186 if (match[2]) { // keyword argument
187 arg = argv[cursor];
187 arg = argv[cursor];
188 for (k = 0; k < match[2].length; k++) {
188 for (k = 0; k < match[2].length; k++) {
189 if (!arg.hasOwnProperty(match[2][k])) {
189 if (!arg.hasOwnProperty(match[2][k])) {
190 throw(sprintf('[sprintf] property "%s" does not exist', match[2][k]));
190 throw(sprintf('[sprintf] property "%s" does not exist', match[2][k]));
191 }
191 }
192 arg = arg[match[2][k]];
192 arg = arg[match[2][k]];
193 }
193 }
194 }
194 }
195 else if (match[1]) { // positional argument (explicit)
195 else if (match[1]) { // positional argument (explicit)
196 arg = argv[match[1]];
196 arg = argv[match[1]];
197 }
197 }
198 else { // positional argument (implicit)
198 else { // positional argument (implicit)
199 arg = argv[cursor++];
199 arg = argv[cursor++];
200 }
200 }
201
201
202 if (/[^s]/.test(match[8]) && (get_type(arg) != 'number')) {
202 if (/[^s]/.test(match[8]) && (get_type(arg) != 'number')) {
203 throw(sprintf('[sprintf] expecting number but found %s', get_type(arg)));
203 throw(sprintf('[sprintf] expecting number but found %s', get_type(arg)));
204 }
204 }
205 switch (match[8]) {
205 switch (match[8]) {
206 case 'b': arg = arg.toString(2); break;
206 case 'b': arg = arg.toString(2); break;
207 case 'c': arg = String.fromCharCode(arg); break;
207 case 'c': arg = String.fromCharCode(arg); break;
208 case 'd': arg = parseInt(arg, 10); break;
208 case 'd': arg = parseInt(arg, 10); break;
209 case 'e': arg = match[7] ? arg.toExponential(match[7]) : arg.toExponential(); break;
209 case 'e': arg = match[7] ? arg.toExponential(match[7]) : arg.toExponential(); break;
210 case 'f': arg = match[7] ? parseFloat(arg).toFixed(match[7]) : parseFloat(arg); break;
210 case 'f': arg = match[7] ? parseFloat(arg).toFixed(match[7]) : parseFloat(arg); break;
211 case 'o': arg = arg.toString(8); break;
211 case 'o': arg = arg.toString(8); break;
212 case 's': arg = ((arg = String(arg)) && match[7] ? arg.substring(0, match[7]) : arg); break;
212 case 's': arg = ((arg = String(arg)) && match[7] ? arg.substring(0, match[7]) : arg); break;
213 case 'u': arg = Math.abs(arg); break;
213 case 'u': arg = Math.abs(arg); break;
214 case 'x': arg = arg.toString(16); break;
214 case 'x': arg = arg.toString(16); break;
215 case 'X': arg = arg.toString(16).toUpperCase(); break;
215 case 'X': arg = arg.toString(16).toUpperCase(); break;
216 }
216 }
217 arg = (/[def]/.test(match[8]) && match[3] && arg >= 0 ? '+'+ arg : arg);
217 arg = (/[def]/.test(match[8]) && match[3] && arg >= 0 ? '+'+ arg : arg);
218 pad_character = match[4] ? match[4] == '0' ? '0' : match[4].charAt(1) : ' ';
218 pad_character = match[4] ? match[4] == '0' ? '0' : match[4].charAt(1) : ' ';
219 pad_length = match[6] - String(arg).length;
219 pad_length = match[6] - String(arg).length;
220 pad = match[6] ? str_repeat(pad_character, pad_length) : '';
220 pad = match[6] ? str_repeat(pad_character, pad_length) : '';
221 output.push(match[5] ? arg + pad : pad + arg);
221 output.push(match[5] ? arg + pad : pad + arg);
222 }
222 }
223 }
223 }
224 return output.join('');
224 return output.join('');
225 };
225 };
226
226
227 str_format.cache = {};
227 str_format.cache = {};
228
228
229 str_format.parse = function(fmt) {
229 str_format.parse = function(fmt) {
230 var _fmt = fmt, match = [], parse_tree = [], arg_names = 0;
230 var _fmt = fmt, match = [], parse_tree = [], arg_names = 0;
231 while (_fmt) {
231 while (_fmt) {
232 if ((match = /^[^\x25]+/.exec(_fmt)) !== null) {
232 if ((match = /^[^\x25]+/.exec(_fmt)) !== null) {
233 parse_tree.push(match[0]);
233 parse_tree.push(match[0]);
234 }
234 }
235 else if ((match = /^\x25{2}/.exec(_fmt)) !== null) {
235 else if ((match = /^\x25{2}/.exec(_fmt)) !== null) {
236 parse_tree.push('%');
236 parse_tree.push('%');
237 }
237 }
238 else if ((match = /^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(_fmt)) !== null) {
238 else if ((match = /^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(_fmt)) !== null) {
239 if (match[2]) {
239 if (match[2]) {
240 arg_names |= 1;
240 arg_names |= 1;
241 var field_list = [], replacement_field = match[2], field_match = [];
241 var field_list = [], replacement_field = match[2], field_match = [];
242 if ((field_match = /^([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) {
242 if ((field_match = /^([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) {
243 field_list.push(field_match[1]);
243 field_list.push(field_match[1]);
244 while ((replacement_field = replacement_field.substring(field_match[0].length)) !== '') {
244 while ((replacement_field = replacement_field.substring(field_match[0].length)) !== '') {
245 if ((field_match = /^\.([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) {
245 if ((field_match = /^\.([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) {
246 field_list.push(field_match[1]);
246 field_list.push(field_match[1]);
247 }
247 }
248 else if ((field_match = /^\[(\d+)\]/.exec(replacement_field)) !== null) {
248 else if ((field_match = /^\[(\d+)\]/.exec(replacement_field)) !== null) {
249 field_list.push(field_match[1]);
249 field_list.push(field_match[1]);
250 }
250 }
251 else {
251 else {
252 throw('[sprintf] huh?');
252 throw('[sprintf] huh?');
253 }
253 }
254 }
254 }
255 }
255 }
256 else {
256 else {
257 throw('[sprintf] huh?');
257 throw('[sprintf] huh?');
258 }
258 }
259 match[2] = field_list;
259 match[2] = field_list;
260 }
260 }
261 else {
261 else {
262 arg_names |= 2;
262 arg_names |= 2;
263 }
263 }
264 if (arg_names === 3) {
264 if (arg_names === 3) {
265 throw('[sprintf] mixing positional and named placeholders is not (yet) supported');
265 throw('[sprintf] mixing positional and named placeholders is not (yet) supported');
266 }
266 }
267 parse_tree.push(match);
267 parse_tree.push(match);
268 }
268 }
269 else {
269 else {
270 throw('[sprintf] huh?');
270 throw('[sprintf] huh?');
271 }
271 }
272 _fmt = _fmt.substring(match[0].length);
272 _fmt = _fmt.substring(match[0].length);
273 }
273 }
274 return parse_tree;
274 return parse_tree;
275 };
275 };
276
276
277 return str_format;
277 return str_format;
278 })();
278 })();
279
279
280 var vsprintf = function(fmt, argv) {
280 var vsprintf = function(fmt, argv) {
281 argv.unshift(fmt);
281 argv.unshift(fmt);
282 return sprintf.apply(null, argv);
282 return sprintf.apply(null, argv);
283 };
283 };
284 return {
284 return {
285 'url': function(route_name, params) {
285 'url': function(route_name, params) {
286 var result = route_name;
286 var result = route_name;
287 if (typeof(params) != 'object'){
287 if (typeof(params) != 'object'){
288 params = {};
288 params = {};
289 }
289 }
290 if (matchlist.hasOwnProperty(route_name)) {
290 if (matchlist.hasOwnProperty(route_name)) {
291 var route = matchlist[route_name];
291 var route = matchlist[route_name];
292 // param substitution
292 // param substitution
293 for(var i=0; i < route[1].length; i++) {
293 for(var i=0; i < route[1].length; i++) {
294
294
295 if (!params.hasOwnProperty(route[1][i]))
295 if (!params.hasOwnProperty(route[1][i]))
296 throw new Error(route[1][i] + ' missing in "' + route_name + '" route generation');
296 throw new Error(route[1][i] + ' missing in "' + route_name + '" route generation');
297 }
297 }
298 result = sprintf(route[0], params);
298 result = sprintf(route[0], params);
299
299
300 var ret = [];
300 var ret = [];
301 //extra params => GET
301 //extra params => GET
302 for(param in params){
302 for(param in params){
303 if (route[1].indexOf(param) == -1){
303 if (route[1].indexOf(param) == -1){
304 ret.push(encodeURIComponent(param) + "=" + encodeURIComponent(params[param]));
304 ret.push(encodeURIComponent(param) + "=" + encodeURIComponent(params[param]));
305 }
305 }
306 }
306 }
307 var _parts = ret.join("&");
307 var _parts = ret.join("&");
308 if(_parts){
308 if(_parts){
309 result = result +'?'+ _parts
309 result = result +'?'+ _parts
310 }
310 }
311 }
311 }
312
312
313 return result;
313 return result;
314 },
314 },
315 'register': function(route_name, route_tmpl, req_params) {
315 'register': function(route_name, route_tmpl, req_params) {
316 if (typeof(req_params) != 'object') {
316 if (typeof(req_params) != 'object') {
317 req_params = [];
317 req_params = [];
318 }
318 }
319 //fix escape
319 //fix escape
320 route_tmpl = unescape(route_tmpl);
320 route_tmpl = unescape(route_tmpl);
321 keys = [];
321 keys = [];
322 for (o in req_params){
322 for (o in req_params){
323 keys.push(req_params[o])
323 keys.push(req_params[o])
324 }
324 }
325 matchlist[route_name] = [
325 matchlist[route_name] = [
326 route_tmpl,
326 route_tmpl,
327 keys
327 keys
328 ]
328 ]
329 },
329 },
330 '_routes': function(){
330 '_routes': function(){
331 return matchlist;
331 return matchlist;
332 }
332 }
333 }
333 }
334 })();
334 })();
335
335
336
336
337
337
338 /**
338 /**
339 * GLOBAL YUI Shortcuts
339 * GLOBAL YUI Shortcuts
340 */
340 */
341 var YUC = YAHOO.util.Connect;
341 var YUC = YAHOO.util.Connect;
342 var YUD = YAHOO.util.Dom;
342 var YUD = YAHOO.util.Dom;
343 var YUE = YAHOO.util.Event;
343 var YUE = YAHOO.util.Event;
344 var YUQ = YAHOO.util.Selector.query;
344 var YUQ = YAHOO.util.Selector.query;
345
345
346 // defines if push state is enabled for this browser ?
346 // defines if push state is enabled for this browser ?
347 var push_state_enabled = Boolean(
347 var push_state_enabled = Boolean(
348 window.history && window.history.pushState && window.history.replaceState
348 window.history && window.history.pushState && window.history.replaceState
349 && !( /* disable for versions of iOS before version 4.3 (8F190) */
349 && !( /* disable for versions of iOS before version 4.3 (8F190) */
350 (/ Mobile\/([1-7][a-z]|(8([abcde]|f(1[0-8]))))/i).test(navigator.userAgent)
350 (/ Mobile\/([1-7][a-z]|(8([abcde]|f(1[0-8]))))/i).test(navigator.userAgent)
351 /* disable for the mercury iOS browser, or at least older versions of the webkit engine */
351 /* disable for the mercury iOS browser, or at least older versions of the webkit engine */
352 || (/AppleWebKit\/5([0-2]|3[0-2])/i).test(navigator.userAgent)
352 || (/AppleWebKit\/5([0-2]|3[0-2])/i).test(navigator.userAgent)
353 )
353 )
354 );
354 );
355
355
356 var _run_callbacks = function(callbacks){
356 var _run_callbacks = function(callbacks){
357 if (callbacks !== undefined){
357 if (callbacks !== undefined){
358 var _l = callbacks.length;
358 var _l = callbacks.length;
359 for (var i=0;i<_l;i++){
359 for (var i=0;i<_l;i++){
360 var func = callbacks[i];
360 var func = callbacks[i];
361 if(typeof(func)=='function'){
361 if(typeof(func)=='function'){
362 try{
362 try{
363 func();
363 func();
364 }catch (err){};
364 }catch (err){};
365 }
365 }
366 }
366 }
367 }
367 }
368 }
368 }
369
369
370 /**
370 /**
371 * Partial Ajax Implementation
371 * Partial Ajax Implementation
372 *
372 *
373 * @param url: defines url to make partial request
373 * @param url: defines url to make partial request
374 * @param container: defines id of container to input partial result
374 * @param container: defines id of container to input partial result
375 * @param s_call: success callback function that takes o as arg
375 * @param s_call: success callback function that takes o as arg
376 * o.tId
376 * o.tId
377 * o.status
377 * o.status
378 * o.statusText
378 * o.statusText
379 * o.getResponseHeader[ ]
379 * o.getResponseHeader[ ]
380 * o.getAllResponseHeaders
380 * o.getAllResponseHeaders
381 * o.responseText
381 * o.responseText
382 * o.responseXML
382 * o.responseXML
383 * o.argument
383 * o.argument
384 * @param f_call: failure callback
384 * @param f_call: failure callback
385 * @param args arguments
385 * @param args arguments
386 */
386 */
387 function ypjax(url,container,s_call,f_call,args){
387 function ypjax(url,container,s_call,f_call,args){
388 var method='GET';
388 var method='GET';
389 if(args===undefined){
389 if(args===undefined){
390 args=null;
390 args=null;
391 }
391 }
392
392
393 // Set special header for partial ajax == HTTP_X_PARTIAL_XHR
393 // Set special header for partial ajax == HTTP_X_PARTIAL_XHR
394 YUC.initHeader('X-PARTIAL-XHR',true);
394 YUC.initHeader('X-PARTIAL-XHR',true);
395
395
396 // wrapper of passed callback
396 // wrapper of passed callback
397 var s_wrapper = (function(o){
397 var s_wrapper = (function(o){
398 return function(o){
398 return function(o){
399 YUD.get(container).innerHTML=o.responseText;
399 YUD.get(container).innerHTML=o.responseText;
400 YUD.setStyle(container,'opacity','1.0');
400 YUD.setStyle(container,'opacity','1.0');
401 //execute the given original callback
401 //execute the given original callback
402 if (s_call !== undefined){
402 if (s_call !== undefined){
403 s_call(o);
403 s_call(o);
404 }
404 }
405 }
405 }
406 })()
406 })()
407 YUD.setStyle(container,'opacity','0.3');
407 YUD.setStyle(container,'opacity','0.3');
408 YUC.asyncRequest(method,url,{
408 YUC.asyncRequest(method,url,{
409 success:s_wrapper,
409 success:s_wrapper,
410 failure:function(o){
410 failure:function(o){
411 console.log(o);
411 console.log(o);
412 YUD.get(container).innerHTML='<span class="error_red">ERROR: {0}</span>'.format(o.status);
412 YUD.get(container).innerHTML='<span class="error_red">ERROR: {0}</span>'.format(o.status);
413 YUD.setStyle(container,'opacity','1.0');
413 YUD.setStyle(container,'opacity','1.0');
414 },
414 },
415 cache:false
415 cache:false
416 },args);
416 },args);
417
417
418 };
418 };
419
419
420 var ajaxGET = function(url,success) {
420 var ajaxGET = function(url,success) {
421 // Set special header for ajax == HTTP_X_PARTIAL_XHR
421 // Set special header for ajax == HTTP_X_PARTIAL_XHR
422 YUC.initHeader('X-PARTIAL-XHR',true);
422 YUC.initHeader('X-PARTIAL-XHR',true);
423
423
424 var sUrl = url;
424 var sUrl = url;
425 var callback = {
425 var callback = {
426 success: success,
426 success: success,
427 failure: function (o) {
427 failure: function (o) {
428 if (o.status != 0) {
428 if (o.status != 0) {
429 alert("error: " + o.statusText);
429 alert("error: " + o.statusText);
430 };
430 };
431 },
431 },
432 };
432 };
433
433
434 var request = YAHOO.util.Connect.asyncRequest('GET', sUrl, callback);
434 var request = YAHOO.util.Connect.asyncRequest('GET', sUrl, callback);
435 return request;
435 return request;
436 };
436 };
437
437
438
438
439
439
440 var ajaxPOST = function(url,postData,success) {
440 var ajaxPOST = function(url,postData,success) {
441 // Set special header for ajax == HTTP_X_PARTIAL_XHR
441 // Set special header for ajax == HTTP_X_PARTIAL_XHR
442 YUC.initHeader('X-PARTIAL-XHR',true);
442 YUC.initHeader('X-PARTIAL-XHR',true);
443
443
444 var toQueryString = function(o) {
444 var toQueryString = function(o) {
445 if(typeof o !== 'object') {
445 if(typeof o !== 'object') {
446 return false;
446 return false;
447 }
447 }
448 var _p, _qs = [];
448 var _p, _qs = [];
449 for(_p in o) {
449 for(_p in o) {
450 _qs.push(encodeURIComponent(_p) + '=' + encodeURIComponent(o[_p]));
450 _qs.push(encodeURIComponent(_p) + '=' + encodeURIComponent(o[_p]));
451 }
451 }
452 return _qs.join('&');
452 return _qs.join('&');
453 };
453 };
454
454
455 var sUrl = url;
455 var sUrl = url;
456 var callback = {
456 var callback = {
457 success: success,
457 success: success,
458 failure: function (o) {
458 failure: function (o) {
459 alert("error");
459 alert("error");
460 },
460 },
461 };
461 };
462 var postData = toQueryString(postData);
462 var postData = toQueryString(postData);
463 var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, callback, postData);
463 var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, callback, postData);
464 return request;
464 return request;
465 };
465 };
466
466
467
467
468 /**
468 /**
469 * tooltip activate
469 * tooltip activate
470 */
470 */
471 var tooltip_activate = function(){
471 var tooltip_activate = function(){
472 yt = YAHOO.yuitip.main;
472 yt = YAHOO.yuitip.main;
473 YUE.onDOMReady(yt.init);
473 YUE.onDOMReady(yt.init);
474 };
474 };
475
475
476 /**
476 /**
477 * show more
477 * show more
478 */
478 */
479 var show_more_event = function(){
479 var show_more_event = function(){
480 YUE.on(YUD.getElementsByClassName('show_more'),'click',function(e){
480 YUE.on(YUD.getElementsByClassName('show_more'),'click',function(e){
481 var el = e.target;
481 var el = e.target;
482 YUD.setStyle(YUD.get(el.id.substring(1)),'display','');
482 YUD.setStyle(YUD.get(el.id.substring(1)),'display','');
483 YUD.setStyle(el.parentNode,'display','none');
483 YUD.setStyle(el.parentNode,'display','none');
484 });
484 });
485 };
485 };
486
486
487 /**
487 /**
488 * show changeset tooltip
488 * show changeset tooltip
489 */
489 */
490 var show_changeset_tooltip = function(){
490 var show_changeset_tooltip = function(){
491 YUE.on(YUD.getElementsByClassName('lazy-cs'), 'mouseover', function(e){
491 YUE.on(YUD.getElementsByClassName('lazy-cs'), 'mouseover', function(e){
492 var target = e.currentTarget;
492 var target = e.currentTarget;
493 var rid = YUD.getAttribute(target,'raw_id');
493 var rid = YUD.getAttribute(target,'raw_id');
494 var repo_name = YUD.getAttribute(target,'repo_name');
494 var repo_name = YUD.getAttribute(target,'repo_name');
495 var ttid = 'tt-'+rid;
495 var ttid = 'tt-'+rid;
496 var success = function(o){
496 var success = function(o){
497 var json = JSON.parse(o.responseText);
497 var json = JSON.parse(o.responseText);
498 YUD.addClass(target,'tooltip')
498 YUD.addClass(target,'tooltip')
499 YUD.setAttribute(target, 'title',json['message']);
499 YUD.setAttribute(target, 'title',json['message']);
500 YAHOO.yuitip.main.show_yuitip(e, target);
500 YAHOO.yuitip.main.show_yuitip(e, target);
501 }
501 }
502 if(rid && !YUD.hasClass(target, 'tooltip')){
502 if(rid && !YUD.hasClass(target, 'tooltip')){
503 YUD.setAttribute(target,'id',ttid);
503 YUD.setAttribute(target,'id',ttid);
504 YUD.setAttribute(target, 'title',_TM['loading...']);
504 YUD.setAttribute(target, 'title',_TM['loading...']);
505 YAHOO.yuitip.main.set_listeners(target);
505 YAHOO.yuitip.main.set_listeners(target);
506 YAHOO.yuitip.main.show_yuitip(e, target);
506 YAHOO.yuitip.main.show_yuitip(e, target);
507 var url = pyroutes.url('changeset_info', {"repo_name":repo_name, "revision": rid});
507 var url = pyroutes.url('changeset_info', {"repo_name":repo_name, "revision": rid});
508 ajaxGET(url, success)
508 ajaxGET(url, success)
509 }
509 }
510 });
510 });
511 };
511 };
512
512
513 var onSuccessFollow = function(target){
513 var onSuccessFollow = function(target){
514 var f = YUD.get(target);
514 var f = YUD.get(target);
515 var f_cnt = YUD.get('current_followers_count');
515 var f_cnt = YUD.get('current_followers_count');
516
516
517 if(YUD.hasClass(f, 'follow')){
517 if(YUD.hasClass(f, 'follow')){
518 f.setAttribute('class','following');
518 f.setAttribute('class','following');
519 f.setAttribute('title',_TM['Stop following this repository']);
519 f.setAttribute('title',_TM['Stop following this repository']);
520
520
521 if(f_cnt){
521 if(f_cnt){
522 var cnt = Number(f_cnt.innerHTML)+1;
522 var cnt = Number(f_cnt.innerHTML)+1;
523 f_cnt.innerHTML = cnt;
523 f_cnt.innerHTML = cnt;
524 }
524 }
525 }
525 }
526 else{
526 else{
527 f.setAttribute('class','follow');
527 f.setAttribute('class','follow');
528 f.setAttribute('title',_TM['Start following this repository']);
528 f.setAttribute('title',_TM['Start following this repository']);
529 if(f_cnt){
529 if(f_cnt){
530 var cnt = Number(f_cnt.innerHTML)-1;
530 var cnt = Number(f_cnt.innerHTML)-1;
531 f_cnt.innerHTML = cnt;
531 f_cnt.innerHTML = cnt;
532 }
532 }
533 }
533 }
534 }
534 }
535
535
536 var toggleFollowingUser = function(target,fallows_user_id,token,user_id){
536 var toggleFollowingUser = function(target,fallows_user_id,token,user_id){
537 args = 'follows_user_id='+fallows_user_id;
537 args = 'follows_user_id='+fallows_user_id;
538 args+= '&amp;auth_token='+token;
538 args+= '&amp;auth_token='+token;
539 if(user_id != undefined){
539 if(user_id != undefined){
540 args+="&amp;user_id="+user_id;
540 args+="&amp;user_id="+user_id;
541 }
541 }
542 YUC.asyncRequest('POST',TOGGLE_FOLLOW_URL,{
542 YUC.asyncRequest('POST',TOGGLE_FOLLOW_URL,{
543 success:function(o){
543 success:function(o){
544 onSuccessFollow(target);
544 onSuccessFollow(target);
545 }
545 }
546 },args);
546 },args);
547 return false;
547 return false;
548 }
548 }
549
549
550 var toggleFollowingRepo = function(target,fallows_repo_id,token,user_id){
550 var toggleFollowingRepo = function(target,fallows_repo_id,token,user_id){
551
551
552 args = 'follows_repo_id='+fallows_repo_id;
552 args = 'follows_repo_id='+fallows_repo_id;
553 args+= '&amp;auth_token='+token;
553 args+= '&amp;auth_token='+token;
554 if(user_id != undefined){
554 if(user_id != undefined){
555 args+="&amp;user_id="+user_id;
555 args+="&amp;user_id="+user_id;
556 }
556 }
557 YUC.asyncRequest('POST',TOGGLE_FOLLOW_URL,{
557 YUC.asyncRequest('POST',TOGGLE_FOLLOW_URL,{
558 success:function(o){
558 success:function(o){
559 onSuccessFollow(target);
559 onSuccessFollow(target);
560 }
560 }
561 },args);
561 },args);
562 return false;
562 return false;
563 }
563 }
564
564
565 var showRepoSize = function(target, repo_name, token){
565 var showRepoSize = function(target, repo_name, token){
566 var args= 'auth_token='+token;
566 var args= 'auth_token='+token;
567
567
568 if(!YUD.hasClass(target, 'loaded')){
568 if(!YUD.hasClass(target, 'loaded')){
569 YUD.get(target).innerHTML = _TM['Loading ...'];
569 YUD.get(target).innerHTML = _TM['Loading ...'];
570 var url = pyroutes.url('repo_size', {"repo_name":repo_name});
570 var url = pyroutes.url('repo_size', {"repo_name":repo_name});
571 YUC.asyncRequest('POST',url,{
571 YUC.asyncRequest('POST',url,{
572 success:function(o){
572 success:function(o){
573 YUD.get(target).innerHTML = JSON.parse(o.responseText);
573 YUD.get(target).innerHTML = JSON.parse(o.responseText);
574 YUD.addClass(target, 'loaded');
574 YUD.addClass(target, 'loaded');
575 }
575 }
576 },args);
576 },args);
577 }
577 }
578 return false;
578 return false;
579 }
579 }
580
580
581 /**
581 /**
582 * TOOLTIP IMPL.
582 * TOOLTIP IMPL.
583 */
583 */
584 YAHOO.namespace('yuitip');
584 YAHOO.namespace('yuitip');
585 YAHOO.yuitip.main = {
585 YAHOO.yuitip.main = {
586
586
587 $: YAHOO.util.Dom.get,
587 $: YAHOO.util.Dom.get,
588
588
589 bgColor: '#000',
589 bgColor: '#000',
590 speed: 0.3,
590 speed: 0.3,
591 opacity: 0.9,
591 opacity: 0.9,
592 offset: [15,15],
592 offset: [15,15],
593 useAnim: false,
593 useAnim: false,
594 maxWidth: 600,
594 maxWidth: 600,
595 add_links: false,
595 add_links: false,
596 yuitips: [],
596 yuitips: [],
597
597
598 set_listeners: function(tt){
598 set_listeners: function(tt){
599 YUE.on(tt, 'mouseover', yt.show_yuitip, tt);
599 YUE.on(tt, 'mouseover', yt.show_yuitip, tt);
600 YUE.on(tt, 'mousemove', yt.move_yuitip, tt);
600 YUE.on(tt, 'mousemove', yt.move_yuitip, tt);
601 YUE.on(tt, 'mouseout', yt.close_yuitip, tt);
601 YUE.on(tt, 'mouseout', yt.close_yuitip, tt);
602 },
602 },
603
603
604 init: function(){
604 init: function(){
605 yt.tipBox = yt.$('tip-box');
605 yt.tipBox = yt.$('tip-box');
606 if(!yt.tipBox){
606 if(!yt.tipBox){
607 yt.tipBox = document.createElement('div');
607 yt.tipBox = document.createElement('div');
608 document.body.appendChild(yt.tipBox);
608 document.body.appendChild(yt.tipBox);
609 yt.tipBox.id = 'tip-box';
609 yt.tipBox.id = 'tip-box';
610 }
610 }
611
611
612 YUD.setStyle(yt.tipBox, 'display', 'none');
612 YUD.setStyle(yt.tipBox, 'display', 'none');
613 YUD.setStyle(yt.tipBox, 'position', 'absolute');
613 YUD.setStyle(yt.tipBox, 'position', 'absolute');
614 if(yt.maxWidth !== null){
614 if(yt.maxWidth !== null){
615 YUD.setStyle(yt.tipBox, 'max-width', yt.maxWidth+'px');
615 YUD.setStyle(yt.tipBox, 'max-width', yt.maxWidth+'px');
616 }
616 }
617
617
618 var yuitips = YUD.getElementsByClassName('tooltip');
618 var yuitips = YUD.getElementsByClassName('tooltip');
619
619
620 if(yt.add_links === true){
620 if(yt.add_links === true){
621 var links = document.getElementsByTagName('a');
621 var links = document.getElementsByTagName('a');
622 var linkLen = links.length;
622 var linkLen = links.length;
623 for(i=0;i<linkLen;i++){
623 for(i=0;i<linkLen;i++){
624 yuitips.push(links[i]);
624 yuitips.push(links[i]);
625 }
625 }
626 }
626 }
627
627
628 var yuiLen = yuitips.length;
628 var yuiLen = yuitips.length;
629
629
630 for(i=0;i<yuiLen;i++){
630 for(i=0;i<yuiLen;i++){
631 yt.set_listeners(yuitips[i]);
631 yt.set_listeners(yuitips[i]);
632 }
632 }
633 },
633 },
634
634
635 show_yuitip: function(e, el){
635 show_yuitip: function(e, el){
636 YUE.stopEvent(e);
636 YUE.stopEvent(e);
637 if(el.tagName.toLowerCase() === 'img'){
637 if(el.tagName.toLowerCase() === 'img'){
638 yt.tipText = el.alt ? el.alt : '';
638 yt.tipText = el.alt ? el.alt : '';
639 } else {
639 } else {
640 yt.tipText = el.title ? el.title : '';
640 yt.tipText = el.title ? el.title : '';
641 }
641 }
642
642
643 if(yt.tipText !== ''){
643 if(yt.tipText !== ''){
644 // save org title
644 // save org title
645 YUD.setAttribute(el, 'tt_title', yt.tipText);
645 YUD.setAttribute(el, 'tt_title', yt.tipText);
646 // reset title to not show org tooltips
646 // reset title to not show org tooltips
647 YUD.setAttribute(el, 'title', '');
647 YUD.setAttribute(el, 'title', '');
648
648
649 yt.tipBox.innerHTML = yt.tipText;
649 yt.tipBox.innerHTML = yt.tipText;
650 YUD.setStyle(yt.tipBox, 'display', 'block');
650 YUD.setStyle(yt.tipBox, 'display', 'block');
651 if(yt.useAnim === true){
651 if(yt.useAnim === true){
652 YUD.setStyle(yt.tipBox, 'opacity', '0');
652 YUD.setStyle(yt.tipBox, 'opacity', '0');
653 var newAnim = new YAHOO.util.Anim(yt.tipBox,
653 var newAnim = new YAHOO.util.Anim(yt.tipBox,
654 {
654 {
655 opacity: { to: yt.opacity }
655 opacity: { to: yt.opacity }
656 }, yt.speed, YAHOO.util.Easing.easeOut
656 }, yt.speed, YAHOO.util.Easing.easeOut
657 );
657 );
658 newAnim.animate();
658 newAnim.animate();
659 }
659 }
660 }
660 }
661 },
661 },
662
662
663 move_yuitip: function(e, el){
663 move_yuitip: function(e, el){
664 YUE.stopEvent(e);
664 YUE.stopEvent(e);
665 var movePos = YUE.getXY(e);
665 var movePos = YUE.getXY(e);
666 YUD.setStyle(yt.tipBox, 'top', (movePos[1] + yt.offset[1]) + 'px');
666 YUD.setStyle(yt.tipBox, 'top', (movePos[1] + yt.offset[1]) + 'px');
667 YUD.setStyle(yt.tipBox, 'left', (movePos[0] + yt.offset[0]) + 'px');
667 YUD.setStyle(yt.tipBox, 'left', (movePos[0] + yt.offset[0]) + 'px');
668 },
668 },
669
669
670 close_yuitip: function(e, el){
670 close_yuitip: function(e, el){
671 YUE.stopEvent(e);
671 YUE.stopEvent(e);
672
672
673 if(yt.useAnim === true){
673 if(yt.useAnim === true){
674 var newAnim = new YAHOO.util.Anim(yt.tipBox,
674 var newAnim = new YAHOO.util.Anim(yt.tipBox,
675 {
675 {
676 opacity: { to: 0 }
676 opacity: { to: 0 }
677 }, yt.speed, YAHOO.util.Easing.easeOut
677 }, yt.speed, YAHOO.util.Easing.easeOut
678 );
678 );
679 newAnim.animate();
679 newAnim.animate();
680 } else {
680 } else {
681 YUD.setStyle(yt.tipBox, 'display', 'none');
681 YUD.setStyle(yt.tipBox, 'display', 'none');
682 }
682 }
683 YUD.setAttribute(el,'title', YUD.getAttribute(el, 'tt_title'));
683 YUD.setAttribute(el,'title', YUD.getAttribute(el, 'tt_title'));
684 }
684 }
685 }
685 }
686
686
687 /**
687 /**
688 * Quick filter widget
688 * Quick filter widget
689 *
689 *
690 * @param target: filter input target
690 * @param target: filter input target
691 * @param nodes: list of nodes in html we want to filter.
691 * @param nodes: list of nodes in html we want to filter.
692 * @param display_element function that takes current node from nodes and
692 * @param display_element function that takes current node from nodes and
693 * does hide or show based on the node
693 * does hide or show based on the node
694 *
694 *
695 */
695 */
696 var q_filter = function(target,nodes,display_element){
696 var q_filter = function(target,nodes,display_element){
697
697
698 var nodes = nodes;
698 var nodes = nodes;
699 var q_filter_field = YUD.get(target);
699 var q_filter_field = YUD.get(target);
700 var F = YAHOO.namespace(target);
700 var F = YAHOO.namespace(target);
701
701
702 YUE.on(q_filter_field,'click',function(){
703 q_filter_field.value = '';
704 });
705
706 YUE.on(q_filter_field,'keyup',function(e){
702 YUE.on(q_filter_field,'keyup',function(e){
707 clearTimeout(F.filterTimeout);
703 clearTimeout(F.filterTimeout);
708 F.filterTimeout = setTimeout(F.updateFilter,600);
704 F.filterTimeout = setTimeout(F.updateFilter,600);
709 });
705 });
710
706
711 F.filterTimeout = null;
707 F.filterTimeout = null;
712
708
713 var show_node = function(node){
709 var show_node = function(node){
714 YUD.setStyle(node,'display','')
710 YUD.setStyle(node,'display','')
715 }
711 }
716 var hide_node = function(node){
712 var hide_node = function(node){
717 YUD.setStyle(node,'display','none');
713 YUD.setStyle(node,'display','none');
718 }
714 }
719
715
720 F.updateFilter = function() {
716 F.updateFilter = function() {
721 // Reset timeout
717 // Reset timeout
722 F.filterTimeout = null;
718 F.filterTimeout = null;
723
719
724 var obsolete = [];
720 var obsolete = [];
725
721
726 var req = q_filter_field.value.toLowerCase();
722 var req = q_filter_field.value.toLowerCase();
727
723
728 var l = nodes.length;
724 var l = nodes.length;
729 var i;
725 var i;
730 var showing = 0;
726 var showing = 0;
731
727
732 for (i=0;i<l;i++ ){
728 for (i=0;i<l;i++ ){
733 var n = nodes[i];
729 var n = nodes[i];
734 var target_element = display_element(n)
730 var target_element = display_element(n)
735 if(req && n.innerHTML.toLowerCase().indexOf(req) == -1){
731 if(req && n.innerHTML.toLowerCase().indexOf(req) == -1){
736 hide_node(target_element);
732 hide_node(target_element);
737 }
733 }
738 else{
734 else{
739 show_node(target_element);
735 show_node(target_element);
740 showing+=1;
736 showing+=1;
741 }
737 }
742 }
738 }
743
739
744 // if repo_count is set update the number
740 // if repo_count is set update the number
745 var cnt = YUD.get('repo_count');
741 var cnt = YUD.get('repo_count');
746 if(cnt){
742 if(cnt){
747 YUD.get('repo_count').innerHTML = showing;
743 YUD.get('repo_count').innerHTML = showing;
748 }
744 }
749
745
750 }
746 }
751 };
747 };
752
748
753 var tableTr = function(cls, body){
749 var tableTr = function(cls, body){
754 var _el = document.createElement('div');
750 var _el = document.createElement('div');
755 var cont = new YAHOO.util.Element(body);
751 var cont = new YAHOO.util.Element(body);
756 var comment_id = fromHTML(body).children[0].id.split('comment-')[1];
752 var comment_id = fromHTML(body).children[0].id.split('comment-')[1];
757 var id = 'comment-tr-{0}'.format(comment_id);
753 var id = 'comment-tr-{0}'.format(comment_id);
758 var _html = ('<table><tbody><tr id="{0}" class="{1}">'+
754 var _html = ('<table><tbody><tr id="{0}" class="{1}">'+
759 '<td class="lineno-inline new-inline"></td>'+
755 '<td class="lineno-inline new-inline"></td>'+
760 '<td class="lineno-inline old-inline"></td>'+
756 '<td class="lineno-inline old-inline"></td>'+
761 '<td>{2}</td>'+
757 '<td>{2}</td>'+
762 '</tr></tbody></table>').format(id, cls, body);
758 '</tr></tbody></table>').format(id, cls, body);
763 _el.innerHTML = _html;
759 _el.innerHTML = _html;
764 return _el.children[0].children[0].children[0];
760 return _el.children[0].children[0].children[0];
765 };
761 };
766
762
767 /** comments **/
763 /** comments **/
768 var removeInlineForm = function(form) {
764 var removeInlineForm = function(form) {
769 form.parentNode.removeChild(form);
765 form.parentNode.removeChild(form);
770 };
766 };
771
767
772 var createInlineForm = function(parent_tr, f_path, line) {
768 var createInlineForm = function(parent_tr, f_path, line) {
773 var tmpl = YUD.get('comment-inline-form-template').innerHTML;
769 var tmpl = YUD.get('comment-inline-form-template').innerHTML;
774 tmpl = tmpl.format(f_path, line);
770 tmpl = tmpl.format(f_path, line);
775 var form = tableTr('comment-form-inline',tmpl)
771 var form = tableTr('comment-form-inline',tmpl)
776
772
777 // create event for hide button
773 // create event for hide button
778 form = new YAHOO.util.Element(form);
774 form = new YAHOO.util.Element(form);
779 var form_hide_button = new YAHOO.util.Element(YUD.getElementsByClassName('hide-inline-form',null,form)[0]);
775 var form_hide_button = new YAHOO.util.Element(YUD.getElementsByClassName('hide-inline-form',null,form)[0]);
780 form_hide_button.on('click', function(e) {
776 form_hide_button.on('click', function(e) {
781 var newtr = e.currentTarget.parentNode.parentNode.parentNode.parentNode.parentNode;
777 var newtr = e.currentTarget.parentNode.parentNode.parentNode.parentNode.parentNode;
782 if(YUD.hasClass(newtr.nextElementSibling,'inline-comments-button')){
778 if(YUD.hasClass(newtr.nextElementSibling,'inline-comments-button')){
783 YUD.setStyle(newtr.nextElementSibling,'display','');
779 YUD.setStyle(newtr.nextElementSibling,'display','');
784 }
780 }
785 removeInlineForm(newtr);
781 removeInlineForm(newtr);
786 YUD.removeClass(parent_tr, 'form-open');
782 YUD.removeClass(parent_tr, 'form-open');
787 YUD.removeClass(parent_tr, 'hl-comment');
783 YUD.removeClass(parent_tr, 'hl-comment');
788
784
789 });
785 });
790
786
791 return form
787 return form
792 };
788 };
793
789
794 /**
790 /**
795 * Inject inline comment for on given TR this tr should be always an .line
791 * Inject inline comment for on given TR this tr should be always an .line
796 * tr containing the line. Code will detect comment, and always put the comment
792 * tr containing the line. Code will detect comment, and always put the comment
797 * block at the very bottom
793 * block at the very bottom
798 */
794 */
799 var injectInlineForm = function(tr){
795 var injectInlineForm = function(tr){
800 if(!YUD.hasClass(tr, 'line')){
796 if(!YUD.hasClass(tr, 'line')){
801 return
797 return
802 }
798 }
803 var submit_url = AJAX_COMMENT_URL;
799 var submit_url = AJAX_COMMENT_URL;
804 var _td = YUD.getElementsByClassName('code',null,tr)[0];
800 var _td = YUD.getElementsByClassName('code',null,tr)[0];
805 if(YUD.hasClass(tr,'form-open') || YUD.hasClass(tr,'context') || YUD.hasClass(_td,'no-comment')){
801 if(YUD.hasClass(tr,'form-open') || YUD.hasClass(tr,'context') || YUD.hasClass(_td,'no-comment')){
806 return
802 return
807 }
803 }
808 YUD.addClass(tr,'form-open');
804 YUD.addClass(tr,'form-open');
809 YUD.addClass(tr,'hl-comment');
805 YUD.addClass(tr,'hl-comment');
810 var node = YUD.getElementsByClassName('full_f_path',null,tr.parentNode.parentNode.parentNode)[0];
806 var node = YUD.getElementsByClassName('full_f_path',null,tr.parentNode.parentNode.parentNode)[0];
811 var f_path = YUD.getAttribute(node,'path');
807 var f_path = YUD.getAttribute(node,'path');
812 var lineno = getLineNo(tr);
808 var lineno = getLineNo(tr);
813 var form = createInlineForm(tr, f_path, lineno, submit_url);
809 var form = createInlineForm(tr, f_path, lineno, submit_url);
814
810
815 var parent = tr;
811 var parent = tr;
816 while (1){
812 while (1){
817 var n = parent.nextElementSibling;
813 var n = parent.nextElementSibling;
818 // next element are comments !
814 // next element are comments !
819 if(YUD.hasClass(n,'inline-comments')){
815 if(YUD.hasClass(n,'inline-comments')){
820 parent = n;
816 parent = n;
821 }
817 }
822 else{
818 else{
823 break;
819 break;
824 }
820 }
825 }
821 }
826 YUD.insertAfter(form,parent);
822 YUD.insertAfter(form,parent);
827 var f = YUD.get(form);
823 var f = YUD.get(form);
828 var overlay = YUD.getElementsByClassName('overlay',null,f)[0];
824 var overlay = YUD.getElementsByClassName('overlay',null,f)[0];
829 var _form = YUD.getElementsByClassName('inline-form',null,f)[0];
825 var _form = YUD.getElementsByClassName('inline-form',null,f)[0];
830
826
831 YUE.on(YUD.get(_form), 'submit',function(e){
827 YUE.on(YUD.get(_form), 'submit',function(e){
832 YUE.preventDefault(e);
828 YUE.preventDefault(e);
833
829
834 //ajax submit
830 //ajax submit
835 var text = YUD.get('text_'+lineno).value;
831 var text = YUD.get('text_'+lineno).value;
836 var postData = {
832 var postData = {
837 'text':text,
833 'text':text,
838 'f_path':f_path,
834 'f_path':f_path,
839 'line':lineno
835 'line':lineno
840 };
836 };
841
837
842 if(lineno === undefined){
838 if(lineno === undefined){
843 alert('missing line !');
839 alert('missing line !');
844 return
840 return
845 }
841 }
846 if(f_path === undefined){
842 if(f_path === undefined){
847 alert('missing file path !');
843 alert('missing file path !');
848 return
844 return
849 }
845 }
850
846
851 if(text == ""){
847 if(text == ""){
852 return
848 return
853 }
849 }
854
850
855 var success = function(o){
851 var success = function(o){
856 YUD.removeClass(tr, 'form-open');
852 YUD.removeClass(tr, 'form-open');
857 removeInlineForm(f);
853 removeInlineForm(f);
858 var json_data = JSON.parse(o.responseText);
854 var json_data = JSON.parse(o.responseText);
859 renderInlineComment(json_data);
855 renderInlineComment(json_data);
860 };
856 };
861
857
862 if (YUD.hasClass(overlay,'overlay')){
858 if (YUD.hasClass(overlay,'overlay')){
863 var w = _form.offsetWidth;
859 var w = _form.offsetWidth;
864 var h = _form.offsetHeight;
860 var h = _form.offsetHeight;
865 YUD.setStyle(overlay,'width',w+'px');
861 YUD.setStyle(overlay,'width',w+'px');
866 YUD.setStyle(overlay,'height',h+'px');
862 YUD.setStyle(overlay,'height',h+'px');
867 }
863 }
868 YUD.addClass(overlay, 'submitting');
864 YUD.addClass(overlay, 'submitting');
869
865
870 ajaxPOST(submit_url, postData, success);
866 ajaxPOST(submit_url, postData, success);
871 });
867 });
872
868
873 setTimeout(function(){
869 setTimeout(function(){
874 // callbacks
870 // callbacks
875 tooltip_activate();
871 tooltip_activate();
876 MentionsAutoComplete('text_'+lineno, 'mentions_container_'+lineno,
872 MentionsAutoComplete('text_'+lineno, 'mentions_container_'+lineno,
877 _USERS_AC_DATA, _GROUPS_AC_DATA);
873 _USERS_AC_DATA, _GROUPS_AC_DATA);
878 var _e = YUD.get('text_'+lineno);
874 var _e = YUD.get('text_'+lineno);
879 if(_e){
875 if(_e){
880 _e.focus();
876 _e.focus();
881 }
877 }
882 },10)
878 },10)
883 };
879 };
884
880
885 var deleteComment = function(comment_id){
881 var deleteComment = function(comment_id){
886 var url = AJAX_COMMENT_DELETE_URL.replace('__COMMENT_ID__',comment_id);
882 var url = AJAX_COMMENT_DELETE_URL.replace('__COMMENT_ID__',comment_id);
887 var postData = {'_method':'delete'};
883 var postData = {'_method':'delete'};
888 var success = function(o){
884 var success = function(o){
889 var n = YUD.get('comment-tr-'+comment_id);
885 var n = YUD.get('comment-tr-'+comment_id);
890 var root = prevElementSibling(prevElementSibling(n));
886 var root = prevElementSibling(prevElementSibling(n));
891 n.parentNode.removeChild(n);
887 n.parentNode.removeChild(n);
892
888
893 // scann nodes, and attach add button to last one
889 // scann nodes, and attach add button to last one
894 placeAddButton(root);
890 placeAddButton(root);
895 }
891 }
896 ajaxPOST(url,postData,success);
892 ajaxPOST(url,postData,success);
897 }
893 }
898
894
899 var createInlineAddButton = function(tr){
895 var createInlineAddButton = function(tr){
900
896
901 var label = TRANSLATION_MAP['Add another comment'];
897 var label = TRANSLATION_MAP['Add another comment'];
902
898
903 var html_el = document.createElement('div');
899 var html_el = document.createElement('div');
904 YUD.addClass(html_el, 'add-comment');
900 YUD.addClass(html_el, 'add-comment');
905 html_el.innerHTML = '<span class="ui-btn">{0}</span>'.format(label);
901 html_el.innerHTML = '<span class="ui-btn">{0}</span>'.format(label);
906
902
907 var add = new YAHOO.util.Element(html_el);
903 var add = new YAHOO.util.Element(html_el);
908 add.on('click', function(e) {
904 add.on('click', function(e) {
909 injectInlineForm(tr);
905 injectInlineForm(tr);
910 });
906 });
911 return add;
907 return add;
912 };
908 };
913
909
914 var getLineNo = function(tr) {
910 var getLineNo = function(tr) {
915 var line;
911 var line;
916 var o = tr.children[0].id.split('_');
912 var o = tr.children[0].id.split('_');
917 var n = tr.children[1].id.split('_');
913 var n = tr.children[1].id.split('_');
918
914
919 if (n.length >= 2) {
915 if (n.length >= 2) {
920 line = n[n.length-1];
916 line = n[n.length-1];
921 } else if (o.length >= 2) {
917 } else if (o.length >= 2) {
922 line = o[o.length-1];
918 line = o[o.length-1];
923 }
919 }
924
920
925 return line
921 return line
926 };
922 };
927
923
928 var placeAddButton = function(target_tr){
924 var placeAddButton = function(target_tr){
929 if(!target_tr){
925 if(!target_tr){
930 return
926 return
931 }
927 }
932 var last_node = target_tr;
928 var last_node = target_tr;
933 //scann
929 //scann
934 while (1){
930 while (1){
935 var n = last_node.nextElementSibling;
931 var n = last_node.nextElementSibling;
936 // next element are comments !
932 // next element are comments !
937 if(YUD.hasClass(n,'inline-comments')){
933 if(YUD.hasClass(n,'inline-comments')){
938 last_node = n;
934 last_node = n;
939 //also remove the comment button from previous
935 //also remove the comment button from previous
940 var comment_add_buttons = YUD.getElementsByClassName('add-comment',null,last_node);
936 var comment_add_buttons = YUD.getElementsByClassName('add-comment',null,last_node);
941 for(var i=0;i<comment_add_buttons.length;i++){
937 for(var i=0;i<comment_add_buttons.length;i++){
942 var b = comment_add_buttons[i];
938 var b = comment_add_buttons[i];
943 b.parentNode.removeChild(b);
939 b.parentNode.removeChild(b);
944 }
940 }
945 }
941 }
946 else{
942 else{
947 break;
943 break;
948 }
944 }
949 }
945 }
950
946
951 var add = createInlineAddButton(target_tr);
947 var add = createInlineAddButton(target_tr);
952 // get the comment div
948 // get the comment div
953 var comment_block = YUD.getElementsByClassName('comment',null,last_node)[0];
949 var comment_block = YUD.getElementsByClassName('comment',null,last_node)[0];
954 // attach add button
950 // attach add button
955 YUD.insertAfter(add,comment_block);
951 YUD.insertAfter(add,comment_block);
956 }
952 }
957
953
958 /**
954 /**
959 * Places the inline comment into the changeset block in proper line position
955 * Places the inline comment into the changeset block in proper line position
960 */
956 */
961 var placeInline = function(target_container,lineno,html){
957 var placeInline = function(target_container,lineno,html){
962 var lineid = "{0}_{1}".format(target_container,lineno);
958 var lineid = "{0}_{1}".format(target_container,lineno);
963 var target_line = YUD.get(lineid);
959 var target_line = YUD.get(lineid);
964 var comment = new YAHOO.util.Element(tableTr('inline-comments',html))
960 var comment = new YAHOO.util.Element(tableTr('inline-comments',html))
965
961
966 // check if there are comments already !
962 // check if there are comments already !
967 var parent = target_line.parentNode;
963 var parent = target_line.parentNode;
968 var root_parent = parent;
964 var root_parent = parent;
969 while (1){
965 while (1){
970 var n = parent.nextElementSibling;
966 var n = parent.nextElementSibling;
971 // next element are comments !
967 // next element are comments !
972 if(YUD.hasClass(n,'inline-comments')){
968 if(YUD.hasClass(n,'inline-comments')){
973 parent = n;
969 parent = n;
974 }
970 }
975 else{
971 else{
976 break;
972 break;
977 }
973 }
978 }
974 }
979 // put in the comment at the bottom
975 // put in the comment at the bottom
980 YUD.insertAfter(comment,parent);
976 YUD.insertAfter(comment,parent);
981
977
982 // scann nodes, and attach add button to last one
978 // scann nodes, and attach add button to last one
983 placeAddButton(root_parent);
979 placeAddButton(root_parent);
984
980
985 return target_line;
981 return target_line;
986 }
982 }
987
983
988 /**
984 /**
989 * make a single inline comment and place it inside
985 * make a single inline comment and place it inside
990 */
986 */
991 var renderInlineComment = function(json_data){
987 var renderInlineComment = function(json_data){
992 try{
988 try{
993 var html = json_data['rendered_text'];
989 var html = json_data['rendered_text'];
994 var lineno = json_data['line_no'];
990 var lineno = json_data['line_no'];
995 var target_id = json_data['target_id'];
991 var target_id = json_data['target_id'];
996 placeInline(target_id, lineno, html);
992 placeInline(target_id, lineno, html);
997
993
998 }catch(e){
994 }catch(e){
999 console.log(e);
995 console.log(e);
1000 }
996 }
1001 }
997 }
1002
998
1003 /**
999 /**
1004 * Iterates over all the inlines, and places them inside proper blocks of data
1000 * Iterates over all the inlines, and places them inside proper blocks of data
1005 */
1001 */
1006 var renderInlineComments = function(file_comments){
1002 var renderInlineComments = function(file_comments){
1007 for (f in file_comments){
1003 for (f in file_comments){
1008 // holding all comments for a FILE
1004 // holding all comments for a FILE
1009 var box = file_comments[f];
1005 var box = file_comments[f];
1010
1006
1011 var target_id = YUD.getAttribute(box,'target_id');
1007 var target_id = YUD.getAttribute(box,'target_id');
1012 // actually comments with line numbers
1008 // actually comments with line numbers
1013 var comments = box.children;
1009 var comments = box.children;
1014 for(var i=0; i<comments.length; i++){
1010 for(var i=0; i<comments.length; i++){
1015 var data = {
1011 var data = {
1016 'rendered_text': comments[i].outerHTML,
1012 'rendered_text': comments[i].outerHTML,
1017 'line_no': YUD.getAttribute(comments[i],'line'),
1013 'line_no': YUD.getAttribute(comments[i],'line'),
1018 'target_id': target_id
1014 'target_id': target_id
1019 }
1015 }
1020 renderInlineComment(data);
1016 renderInlineComment(data);
1021 }
1017 }
1022 }
1018 }
1023 }
1019 }
1024
1020
1025 var fileBrowserListeners = function(current_url, node_list_url, url_base){
1021 var fileBrowserListeners = function(current_url, node_list_url, url_base){
1026 var current_url_branch = +"?branch=__BRANCH__";
1022 var current_url_branch = +"?branch=__BRANCH__";
1027
1023
1028 YUE.on('stay_at_branch','click',function(e){
1024 YUE.on('stay_at_branch','click',function(e){
1029 if(e.target.checked){
1025 if(e.target.checked){
1030 var uri = current_url_branch;
1026 var uri = current_url_branch;
1031 uri = uri.replace('__BRANCH__',e.target.value);
1027 uri = uri.replace('__BRANCH__',e.target.value);
1032 window.location = uri;
1028 window.location = uri;
1033 }
1029 }
1034 else{
1030 else{
1035 window.location = current_url;
1031 window.location = current_url;
1036 }
1032 }
1037 })
1033 })
1038
1034
1039 var n_filter = YUD.get('node_filter');
1035 var n_filter = YUD.get('node_filter');
1040 var F = YAHOO.namespace('node_filter');
1036 var F = YAHOO.namespace('node_filter');
1041
1037
1042 F.filterTimeout = null;
1038 F.filterTimeout = null;
1043 var nodes = null;
1039 var nodes = null;
1044
1040
1045 F.initFilter = function(){
1041 F.initFilter = function(){
1046 YUD.setStyle('node_filter_box_loading','display','');
1042 YUD.setStyle('node_filter_box_loading','display','');
1047 YUD.setStyle('search_activate_id','display','none');
1043 YUD.setStyle('search_activate_id','display','none');
1048 YUD.setStyle('add_node_id','display','none');
1044 YUD.setStyle('add_node_id','display','none');
1049 YUC.initHeader('X-PARTIAL-XHR',true);
1045 YUC.initHeader('X-PARTIAL-XHR',true);
1050 YUC.asyncRequest('GET', node_list_url, {
1046 YUC.asyncRequest('GET', node_list_url, {
1051 success:function(o){
1047 success:function(o){
1052 nodes = JSON.parse(o.responseText).nodes;
1048 nodes = JSON.parse(o.responseText).nodes;
1053 YUD.setStyle('node_filter_box_loading','display','none');
1049 YUD.setStyle('node_filter_box_loading','display','none');
1054 YUD.setStyle('node_filter_box','display','');
1050 YUD.setStyle('node_filter_box','display','');
1055 n_filter.focus();
1051 n_filter.focus();
1056 if(YUD.hasClass(n_filter,'init')){
1052 if(YUD.hasClass(n_filter,'init')){
1057 n_filter.value = '';
1053 n_filter.value = '';
1058 YUD.removeClass(n_filter,'init');
1054 YUD.removeClass(n_filter,'init');
1059 }
1055 }
1060 },
1056 },
1061 failure:function(o){
1057 failure:function(o){
1062 console.log('failed to load');
1058 console.log('failed to load');
1063 }
1059 }
1064 },null);
1060 },null);
1065 }
1061 }
1066
1062
1067 F.updateFilter = function(e) {
1063 F.updateFilter = function(e) {
1068
1064
1069 return function(){
1065 return function(){
1070 // Reset timeout
1066 // Reset timeout
1071 F.filterTimeout = null;
1067 F.filterTimeout = null;
1072 var query = e.target.value.toLowerCase();
1068 var query = e.target.value.toLowerCase();
1073 var match = [];
1069 var match = [];
1074 var matches = 0;
1070 var matches = 0;
1075 var matches_max = 20;
1071 var matches_max = 20;
1076 if (query != ""){
1072 if (query != ""){
1077 for(var i=0;i<nodes.length;i++){
1073 for(var i=0;i<nodes.length;i++){
1078
1074
1079 var pos = nodes[i].name.toLowerCase().indexOf(query)
1075 var pos = nodes[i].name.toLowerCase().indexOf(query)
1080 if(query && pos != -1){
1076 if(query && pos != -1){
1081
1077
1082 matches++
1078 matches++
1083 //show only certain amount to not kill browser
1079 //show only certain amount to not kill browser
1084 if (matches > matches_max){
1080 if (matches > matches_max){
1085 break;
1081 break;
1086 }
1082 }
1087
1083
1088 var n = nodes[i].name;
1084 var n = nodes[i].name;
1089 var t = nodes[i].type;
1085 var t = nodes[i].type;
1090 var n_hl = n.substring(0,pos)
1086 var n_hl = n.substring(0,pos)
1091 +"<b>{0}</b>".format(n.substring(pos,pos+query.length))
1087 +"<b>{0}</b>".format(n.substring(pos,pos+query.length))
1092 +n.substring(pos+query.length)
1088 +n.substring(pos+query.length)
1093 var new_url = url_base.replace('__FPATH__',n);
1089 var new_url = url_base.replace('__FPATH__',n);
1094 match.push('<tr><td><a class="browser-{0}" href="{1}">{2}</a></td><td colspan="5"></td></tr>'.format(t,new_url,n_hl));
1090 match.push('<tr><td><a class="browser-{0}" href="{1}">{2}</a></td><td colspan="5"></td></tr>'.format(t,new_url,n_hl));
1095 }
1091 }
1096 if(match.length >= matches_max){
1092 if(match.length >= matches_max){
1097 match.push('<tr><td>{0}</td><td colspan="5"></td></tr>'.format(_TM['Search truncated']));
1093 match.push('<tr><td>{0}</td><td colspan="5"></td></tr>'.format(_TM['Search truncated']));
1098 }
1094 }
1099 }
1095 }
1100 }
1096 }
1101 if(query != ""){
1097 if(query != ""){
1102 YUD.setStyle('tbody','display','none');
1098 YUD.setStyle('tbody','display','none');
1103 YUD.setStyle('tbody_filtered','display','');
1099 YUD.setStyle('tbody_filtered','display','');
1104
1100
1105 if (match.length==0){
1101 if (match.length==0){
1106 match.push('<tr><td>{0}</td><td colspan="5"></td></tr>'.format(_TM['No matching files']));
1102 match.push('<tr><td>{0}</td><td colspan="5"></td></tr>'.format(_TM['No matching files']));
1107 }
1103 }
1108
1104
1109 YUD.get('tbody_filtered').innerHTML = match.join("");
1105 YUD.get('tbody_filtered').innerHTML = match.join("");
1110 }
1106 }
1111 else{
1107 else{
1112 YUD.setStyle('tbody','display','');
1108 YUD.setStyle('tbody','display','');
1113 YUD.setStyle('tbody_filtered','display','none');
1109 YUD.setStyle('tbody_filtered','display','none');
1114 }
1110 }
1115
1111
1116 }
1112 }
1117 };
1113 };
1118
1114
1119 YUE.on(YUD.get('filter_activate'),'click',function(){
1115 YUE.on(YUD.get('filter_activate'),'click',function(){
1120 F.initFilter();
1116 F.initFilter();
1121 })
1117 })
1122 YUE.on(n_filter,'click',function(){
1118 YUE.on(n_filter,'click',function(){
1123 if(YUD.hasClass(n_filter,'init')){
1119 if(YUD.hasClass(n_filter,'init')){
1124 n_filter.value = '';
1120 n_filter.value = '';
1125 YUD.removeClass(n_filter,'init');
1121 YUD.removeClass(n_filter,'init');
1126 }
1122 }
1127 });
1123 });
1128 YUE.on(n_filter,'keyup',function(e){
1124 YUE.on(n_filter,'keyup',function(e){
1129 clearTimeout(F.filterTimeout);
1125 clearTimeout(F.filterTimeout);
1130 F.filterTimeout = setTimeout(F.updateFilter(e),600);
1126 F.filterTimeout = setTimeout(F.updateFilter(e),600);
1131 });
1127 });
1132 };
1128 };
1133
1129
1134
1130
1135 var initCodeMirror = function(textAreadId,resetUrl){
1131 var initCodeMirror = function(textAreadId,resetUrl){
1136 var myCodeMirror = CodeMirror.fromTextArea(YUD.get(textAreadId),{
1132 var myCodeMirror = CodeMirror.fromTextArea(YUD.get(textAreadId),{
1137 mode: "null",
1133 mode: "null",
1138 lineNumbers:true
1134 lineNumbers:true
1139 });
1135 });
1140 YUE.on('reset','click',function(e){
1136 YUE.on('reset','click',function(e){
1141 window.location=resetUrl
1137 window.location=resetUrl
1142 });
1138 });
1143
1139
1144 YUE.on('file_enable','click',function(){
1140 YUE.on('file_enable','click',function(){
1145 YUD.setStyle('editor_container','display','');
1141 YUD.setStyle('editor_container','display','');
1146 YUD.setStyle('upload_file_container','display','none');
1142 YUD.setStyle('upload_file_container','display','none');
1147 YUD.setStyle('filename_container','display','');
1143 YUD.setStyle('filename_container','display','');
1148 });
1144 });
1149
1145
1150 YUE.on('upload_file_enable','click',function(){
1146 YUE.on('upload_file_enable','click',function(){
1151 YUD.setStyle('editor_container','display','none');
1147 YUD.setStyle('editor_container','display','none');
1152 YUD.setStyle('upload_file_container','display','');
1148 YUD.setStyle('upload_file_container','display','');
1153 YUD.setStyle('filename_container','display','none');
1149 YUD.setStyle('filename_container','display','none');
1154 });
1150 });
1155 };
1151 };
1156
1152
1157
1153
1158
1154
1159 var getIdentNode = function(n){
1155 var getIdentNode = function(n){
1160 //iterate thru nodes untill matched interesting node !
1156 //iterate thru nodes untill matched interesting node !
1161
1157
1162 if (typeof n == 'undefined'){
1158 if (typeof n == 'undefined'){
1163 return -1
1159 return -1
1164 }
1160 }
1165
1161
1166 if(typeof n.id != "undefined" && n.id.match('L[0-9]+')){
1162 if(typeof n.id != "undefined" && n.id.match('L[0-9]+')){
1167 return n
1163 return n
1168 }
1164 }
1169 else{
1165 else{
1170 return getIdentNode(n.parentNode);
1166 return getIdentNode(n.parentNode);
1171 }
1167 }
1172 };
1168 };
1173
1169
1174 var getSelectionLink = function(e) {
1170 var getSelectionLink = function(e) {
1175
1171
1176 //get selection from start/to nodes
1172 //get selection from start/to nodes
1177 if (typeof window.getSelection != "undefined") {
1173 if (typeof window.getSelection != "undefined") {
1178 s = window.getSelection();
1174 s = window.getSelection();
1179
1175
1180 from = getIdentNode(s.anchorNode);
1176 from = getIdentNode(s.anchorNode);
1181 till = getIdentNode(s.focusNode);
1177 till = getIdentNode(s.focusNode);
1182
1178
1183 f_int = parseInt(from.id.replace('L',''));
1179 f_int = parseInt(from.id.replace('L',''));
1184 t_int = parseInt(till.id.replace('L',''));
1180 t_int = parseInt(till.id.replace('L',''));
1185
1181
1186 if (f_int > t_int){
1182 if (f_int > t_int){
1187 //highlight from bottom
1183 //highlight from bottom
1188 offset = -35;
1184 offset = -35;
1189 ranges = [t_int,f_int];
1185 ranges = [t_int,f_int];
1190
1186
1191 }
1187 }
1192 else{
1188 else{
1193 //highligth from top
1189 //highligth from top
1194 offset = 35;
1190 offset = 35;
1195 ranges = [f_int,t_int];
1191 ranges = [f_int,t_int];
1196 }
1192 }
1197 // if we select more than 2 lines
1193 // if we select more than 2 lines
1198 if (ranges[0] != ranges[1]){
1194 if (ranges[0] != ranges[1]){
1199 if(YUD.get('linktt') == null){
1195 if(YUD.get('linktt') == null){
1200 hl_div = document.createElement('div');
1196 hl_div = document.createElement('div');
1201 hl_div.id = 'linktt';
1197 hl_div.id = 'linktt';
1202 }
1198 }
1203 hl_div.innerHTML = '';
1199 hl_div.innerHTML = '';
1204
1200
1205 anchor = '#L'+ranges[0]+'-'+ranges[1];
1201 anchor = '#L'+ranges[0]+'-'+ranges[1];
1206 var link = document.createElement('a');
1202 var link = document.createElement('a');
1207 link.href = location.href.substring(0,location.href.indexOf('#'))+anchor;
1203 link.href = location.href.substring(0,location.href.indexOf('#'))+anchor;
1208 link.innerHTML = _TM['Selection link'];
1204 link.innerHTML = _TM['Selection link'];
1209 hl_div.appendChild(link);
1205 hl_div.appendChild(link);
1210 YUD.get('body').appendChild(hl_div);
1206 YUD.get('body').appendChild(hl_div);
1211
1207
1212 xy = YUD.getXY(till.id);
1208 xy = YUD.getXY(till.id);
1213
1209
1214 YUD.addClass('linktt', 'hl-tip-box');
1210 YUD.addClass('linktt', 'hl-tip-box');
1215 YUD.setStyle('linktt','top',xy[1]+offset+'px');
1211 YUD.setStyle('linktt','top',xy[1]+offset+'px');
1216 YUD.setStyle('linktt','left',xy[0]+'px');
1212 YUD.setStyle('linktt','left',xy[0]+'px');
1217 YUD.setStyle('linktt','visibility','visible');
1213 YUD.setStyle('linktt','visibility','visible');
1218
1214
1219 }
1215 }
1220 else{
1216 else{
1221 YUD.setStyle('linktt','visibility','hidden');
1217 YUD.setStyle('linktt','visibility','hidden');
1222 }
1218 }
1223 }
1219 }
1224 };
1220 };
1225
1221
1226 var deleteNotification = function(url, notification_id,callbacks){
1222 var deleteNotification = function(url, notification_id,callbacks){
1227 var callback = {
1223 var callback = {
1228 success:function(o){
1224 success:function(o){
1229 var obj = YUD.get(String("notification_"+notification_id));
1225 var obj = YUD.get(String("notification_"+notification_id));
1230 if(obj.parentNode !== undefined){
1226 if(obj.parentNode !== undefined){
1231 obj.parentNode.removeChild(obj);
1227 obj.parentNode.removeChild(obj);
1232 }
1228 }
1233 _run_callbacks(callbacks);
1229 _run_callbacks(callbacks);
1234 },
1230 },
1235 failure:function(o){
1231 failure:function(o){
1236 alert("error");
1232 alert("error");
1237 },
1233 },
1238 };
1234 };
1239 var postData = '_method=delete';
1235 var postData = '_method=delete';
1240 var sUrl = url.replace('__NOTIFICATION_ID__',notification_id);
1236 var sUrl = url.replace('__NOTIFICATION_ID__',notification_id);
1241 var request = YAHOO.util.Connect.asyncRequest('POST', sUrl,
1237 var request = YAHOO.util.Connect.asyncRequest('POST', sUrl,
1242 callback, postData);
1238 callback, postData);
1243 };
1239 };
1244
1240
1245 var readNotification = function(url, notification_id,callbacks){
1241 var readNotification = function(url, notification_id,callbacks){
1246 var callback = {
1242 var callback = {
1247 success:function(o){
1243 success:function(o){
1248 var obj = YUD.get(String("notification_"+notification_id));
1244 var obj = YUD.get(String("notification_"+notification_id));
1249 YUD.removeClass(obj, 'unread');
1245 YUD.removeClass(obj, 'unread');
1250 var r_button = YUD.getElementsByClassName('read-notification',null,obj.children[0])[0];
1246 var r_button = YUD.getElementsByClassName('read-notification',null,obj.children[0])[0];
1251
1247
1252 if(r_button.parentNode !== undefined){
1248 if(r_button.parentNode !== undefined){
1253 r_button.parentNode.removeChild(r_button);
1249 r_button.parentNode.removeChild(r_button);
1254 }
1250 }
1255 _run_callbacks(callbacks);
1251 _run_callbacks(callbacks);
1256 },
1252 },
1257 failure:function(o){
1253 failure:function(o){
1258 alert("error");
1254 alert("error");
1259 },
1255 },
1260 };
1256 };
1261 var postData = '_method=put';
1257 var postData = '_method=put';
1262 var sUrl = url.replace('__NOTIFICATION_ID__',notification_id);
1258 var sUrl = url.replace('__NOTIFICATION_ID__',notification_id);
1263 var request = YAHOO.util.Connect.asyncRequest('POST', sUrl,
1259 var request = YAHOO.util.Connect.asyncRequest('POST', sUrl,
1264 callback, postData);
1260 callback, postData);
1265 };
1261 };
1266
1262
1267 /** MEMBERS AUTOCOMPLETE WIDGET **/
1263 /** MEMBERS AUTOCOMPLETE WIDGET **/
1268
1264
1269 var MembersAutoComplete = function (divid, cont, users_list, groups_list) {
1265 var MembersAutoComplete = function (divid, cont, users_list, groups_list) {
1270 var myUsers = users_list;
1266 var myUsers = users_list;
1271 var myGroups = groups_list;
1267 var myGroups = groups_list;
1272
1268
1273 // Define a custom search function for the DataSource of users
1269 // Define a custom search function for the DataSource of users
1274 var matchUsers = function (sQuery) {
1270 var matchUsers = function (sQuery) {
1275 // Case insensitive matching
1271 // Case insensitive matching
1276 var query = sQuery.toLowerCase();
1272 var query = sQuery.toLowerCase();
1277 var i = 0;
1273 var i = 0;
1278 var l = myUsers.length;
1274 var l = myUsers.length;
1279 var matches = [];
1275 var matches = [];
1280
1276
1281 // Match against each name of each contact
1277 // Match against each name of each contact
1282 for (; i < l; i++) {
1278 for (; i < l; i++) {
1283 contact = myUsers[i];
1279 contact = myUsers[i];
1284 if (((contact.fname+"").toLowerCase().indexOf(query) > -1) ||
1280 if (((contact.fname+"").toLowerCase().indexOf(query) > -1) ||
1285 ((contact.lname+"").toLowerCase().indexOf(query) > -1) ||
1281 ((contact.lname+"").toLowerCase().indexOf(query) > -1) ||
1286 ((contact.nname) && ((contact.nname).toLowerCase().indexOf(query) > -1))) {
1282 ((contact.nname) && ((contact.nname).toLowerCase().indexOf(query) > -1))) {
1287 matches[matches.length] = contact;
1283 matches[matches.length] = contact;
1288 }
1284 }
1289 }
1285 }
1290 return matches;
1286 return matches;
1291 };
1287 };
1292
1288
1293 // Define a custom search function for the DataSource of userGroups
1289 // Define a custom search function for the DataSource of userGroups
1294 var matchGroups = function (sQuery) {
1290 var matchGroups = function (sQuery) {
1295 // Case insensitive matching
1291 // Case insensitive matching
1296 var query = sQuery.toLowerCase();
1292 var query = sQuery.toLowerCase();
1297 var i = 0;
1293 var i = 0;
1298 var l = myGroups.length;
1294 var l = myGroups.length;
1299 var matches = [];
1295 var matches = [];
1300
1296
1301 // Match against each name of each contact
1297 // Match against each name of each contact
1302 for (; i < l; i++) {
1298 for (; i < l; i++) {
1303 matched_group = myGroups[i];
1299 matched_group = myGroups[i];
1304 if (matched_group.grname.toLowerCase().indexOf(query) > -1) {
1300 if (matched_group.grname.toLowerCase().indexOf(query) > -1) {
1305 matches[matches.length] = matched_group;
1301 matches[matches.length] = matched_group;
1306 }
1302 }
1307 }
1303 }
1308 return matches;
1304 return matches;
1309 };
1305 };
1310
1306
1311 //match all
1307 //match all
1312 var matchAll = function (sQuery) {
1308 var matchAll = function (sQuery) {
1313 u = matchUsers(sQuery);
1309 u = matchUsers(sQuery);
1314 g = matchGroups(sQuery);
1310 g = matchGroups(sQuery);
1315 return u.concat(g);
1311 return u.concat(g);
1316 };
1312 };
1317
1313
1318 // DataScheme for members
1314 // DataScheme for members
1319 var memberDS = new YAHOO.util.FunctionDataSource(matchAll);
1315 var memberDS = new YAHOO.util.FunctionDataSource(matchAll);
1320 memberDS.responseSchema = {
1316 memberDS.responseSchema = {
1321 fields: ["id", "fname", "lname", "nname", "grname", "grmembers", "gravatar_lnk"]
1317 fields: ["id", "fname", "lname", "nname", "grname", "grmembers", "gravatar_lnk"]
1322 };
1318 };
1323
1319
1324 // DataScheme for owner
1320 // DataScheme for owner
1325 var ownerDS = new YAHOO.util.FunctionDataSource(matchUsers);
1321 var ownerDS = new YAHOO.util.FunctionDataSource(matchUsers);
1326 ownerDS.responseSchema = {
1322 ownerDS.responseSchema = {
1327 fields: ["id", "fname", "lname", "nname", "gravatar_lnk"]
1323 fields: ["id", "fname", "lname", "nname", "gravatar_lnk"]
1328 };
1324 };
1329
1325
1330 // Instantiate AutoComplete for perms
1326 // Instantiate AutoComplete for perms
1331 var membersAC = new YAHOO.widget.AutoComplete(divid, cont, memberDS);
1327 var membersAC = new YAHOO.widget.AutoComplete(divid, cont, memberDS);
1332 membersAC.useShadow = false;
1328 membersAC.useShadow = false;
1333 membersAC.resultTypeList = false;
1329 membersAC.resultTypeList = false;
1334 membersAC.animVert = false;
1330 membersAC.animVert = false;
1335 membersAC.animHoriz = false;
1331 membersAC.animHoriz = false;
1336 membersAC.animSpeed = 0.1;
1332 membersAC.animSpeed = 0.1;
1337
1333
1338 // Instantiate AutoComplete for owner
1334 // Instantiate AutoComplete for owner
1339 var ownerAC = new YAHOO.widget.AutoComplete("user", "owner_container", ownerDS);
1335 var ownerAC = new YAHOO.widget.AutoComplete("user", "owner_container", ownerDS);
1340 ownerAC.useShadow = false;
1336 ownerAC.useShadow = false;
1341 ownerAC.resultTypeList = false;
1337 ownerAC.resultTypeList = false;
1342 ownerAC.animVert = false;
1338 ownerAC.animVert = false;
1343 ownerAC.animHoriz = false;
1339 ownerAC.animHoriz = false;
1344 ownerAC.animSpeed = 0.1;
1340 ownerAC.animSpeed = 0.1;
1345
1341
1346 // Helper highlight function for the formatter
1342 // Helper highlight function for the formatter
1347 var highlightMatch = function (full, snippet, matchindex) {
1343 var highlightMatch = function (full, snippet, matchindex) {
1348 return full.substring(0, matchindex)
1344 return full.substring(0, matchindex)
1349 + "<span class='match'>"
1345 + "<span class='match'>"
1350 + full.substr(matchindex, snippet.length)
1346 + full.substr(matchindex, snippet.length)
1351 + "</span>" + full.substring(matchindex + snippet.length);
1347 + "</span>" + full.substring(matchindex + snippet.length);
1352 };
1348 };
1353
1349
1354 // Custom formatter to highlight the matching letters
1350 // Custom formatter to highlight the matching letters
1355 var custom_formatter = function (oResultData, sQuery, sResultMatch) {
1351 var custom_formatter = function (oResultData, sQuery, sResultMatch) {
1356 var query = sQuery.toLowerCase();
1352 var query = sQuery.toLowerCase();
1357 var _gravatar = function(res, em, group){
1353 var _gravatar = function(res, em, group){
1358 if (group !== undefined){
1354 if (group !== undefined){
1359 em = '/images/icons/group.png'
1355 em = '/images/icons/group.png'
1360 }
1356 }
1361 tmpl = '<div class="ac-container-wrap"><img class="perm-gravatar-ac" src="{0}"/>{1}</div>'
1357 tmpl = '<div class="ac-container-wrap"><img class="perm-gravatar-ac" src="{0}"/>{1}</div>'
1362 return tmpl.format(em,res)
1358 return tmpl.format(em,res)
1363 }
1359 }
1364 // group
1360 // group
1365 if (oResultData.grname != undefined) {
1361 if (oResultData.grname != undefined) {
1366 var grname = oResultData.grname;
1362 var grname = oResultData.grname;
1367 var grmembers = oResultData.grmembers;
1363 var grmembers = oResultData.grmembers;
1368 var grnameMatchIndex = grname.toLowerCase().indexOf(query);
1364 var grnameMatchIndex = grname.toLowerCase().indexOf(query);
1369 var grprefix = "{0}: ".format(_TM['Group']);
1365 var grprefix = "{0}: ".format(_TM['Group']);
1370 var grsuffix = " (" + grmembers + " )";
1366 var grsuffix = " (" + grmembers + " )";
1371 var grsuffix = " ({0} {1})".format(grmembers, _TM['members']);
1367 var grsuffix = " ({0} {1})".format(grmembers, _TM['members']);
1372
1368
1373 if (grnameMatchIndex > -1) {
1369 if (grnameMatchIndex > -1) {
1374 return _gravatar(grprefix + highlightMatch(grname, query, grnameMatchIndex) + grsuffix,null,true);
1370 return _gravatar(grprefix + highlightMatch(grname, query, grnameMatchIndex) + grsuffix,null,true);
1375 }
1371 }
1376 return _gravatar(grprefix + oResultData.grname + grsuffix, null,true);
1372 return _gravatar(grprefix + oResultData.grname + grsuffix, null,true);
1377 // Users
1373 // Users
1378 } else if (oResultData.nname != undefined) {
1374 } else if (oResultData.nname != undefined) {
1379 var fname = oResultData.fname || "";
1375 var fname = oResultData.fname || "";
1380 var lname = oResultData.lname || "";
1376 var lname = oResultData.lname || "";
1381 var nname = oResultData.nname;
1377 var nname = oResultData.nname;
1382
1378
1383 // Guard against null value
1379 // Guard against null value
1384 var fnameMatchIndex = fname.toLowerCase().indexOf(query),
1380 var fnameMatchIndex = fname.toLowerCase().indexOf(query),
1385 lnameMatchIndex = lname.toLowerCase().indexOf(query),
1381 lnameMatchIndex = lname.toLowerCase().indexOf(query),
1386 nnameMatchIndex = nname.toLowerCase().indexOf(query),
1382 nnameMatchIndex = nname.toLowerCase().indexOf(query),
1387 displayfname, displaylname, displaynname;
1383 displayfname, displaylname, displaynname;
1388
1384
1389 if (fnameMatchIndex > -1) {
1385 if (fnameMatchIndex > -1) {
1390 displayfname = highlightMatch(fname, query, fnameMatchIndex);
1386 displayfname = highlightMatch(fname, query, fnameMatchIndex);
1391 } else {
1387 } else {
1392 displayfname = fname;
1388 displayfname = fname;
1393 }
1389 }
1394
1390
1395 if (lnameMatchIndex > -1) {
1391 if (lnameMatchIndex > -1) {
1396 displaylname = highlightMatch(lname, query, lnameMatchIndex);
1392 displaylname = highlightMatch(lname, query, lnameMatchIndex);
1397 } else {
1393 } else {
1398 displaylname = lname;
1394 displaylname = lname;
1399 }
1395 }
1400
1396
1401 if (nnameMatchIndex > -1) {
1397 if (nnameMatchIndex > -1) {
1402 displaynname = "(" + highlightMatch(nname, query, nnameMatchIndex) + ")";
1398 displaynname = "(" + highlightMatch(nname, query, nnameMatchIndex) + ")";
1403 } else {
1399 } else {
1404 displaynname = nname ? "(" + nname + ")" : "";
1400 displaynname = nname ? "(" + nname + ")" : "";
1405 }
1401 }
1406
1402
1407 return _gravatar(displayfname + " " + displaylname + " " + displaynname, oResultData.gravatar_lnk);
1403 return _gravatar(displayfname + " " + displaylname + " " + displaynname, oResultData.gravatar_lnk);
1408 } else {
1404 } else {
1409 return '';
1405 return '';
1410 }
1406 }
1411 };
1407 };
1412 membersAC.formatResult = custom_formatter;
1408 membersAC.formatResult = custom_formatter;
1413 ownerAC.formatResult = custom_formatter;
1409 ownerAC.formatResult = custom_formatter;
1414
1410
1415 var myHandler = function (sType, aArgs) {
1411 var myHandler = function (sType, aArgs) {
1416 var nextId = divid.split('perm_new_member_name_')[1];
1412 var nextId = divid.split('perm_new_member_name_')[1];
1417 var myAC = aArgs[0]; // reference back to the AC instance
1413 var myAC = aArgs[0]; // reference back to the AC instance
1418 var elLI = aArgs[1]; // reference to the selected LI element
1414 var elLI = aArgs[1]; // reference to the selected LI element
1419 var oData = aArgs[2]; // object literal of selected item's result data
1415 var oData = aArgs[2]; // object literal of selected item's result data
1420 //fill the autocomplete with value
1416 //fill the autocomplete with value
1421 if (oData.nname != undefined) {
1417 if (oData.nname != undefined) {
1422 //users
1418 //users
1423 myAC.getInputEl().value = oData.nname;
1419 myAC.getInputEl().value = oData.nname;
1424 YUD.get('perm_new_member_type_'+nextId).value = 'user';
1420 YUD.get('perm_new_member_type_'+nextId).value = 'user';
1425 } else {
1421 } else {
1426 //groups
1422 //groups
1427 myAC.getInputEl().value = oData.grname;
1423 myAC.getInputEl().value = oData.grname;
1428 YUD.get('perm_new_member_type_'+nextId).value = 'users_group';
1424 YUD.get('perm_new_member_type_'+nextId).value = 'users_group';
1429 }
1425 }
1430 };
1426 };
1431
1427
1432 membersAC.itemSelectEvent.subscribe(myHandler);
1428 membersAC.itemSelectEvent.subscribe(myHandler);
1433 if(ownerAC.itemSelectEvent){
1429 if(ownerAC.itemSelectEvent){
1434 ownerAC.itemSelectEvent.subscribe(myHandler);
1430 ownerAC.itemSelectEvent.subscribe(myHandler);
1435 }
1431 }
1436
1432
1437 return {
1433 return {
1438 memberDS: memberDS,
1434 memberDS: memberDS,
1439 ownerDS: ownerDS,
1435 ownerDS: ownerDS,
1440 membersAC: membersAC,
1436 membersAC: membersAC,
1441 ownerAC: ownerAC,
1437 ownerAC: ownerAC,
1442 };
1438 };
1443 }
1439 }
1444
1440
1445
1441
1446 var MentionsAutoComplete = function (divid, cont, users_list, groups_list) {
1442 var MentionsAutoComplete = function (divid, cont, users_list, groups_list) {
1447 var myUsers = users_list;
1443 var myUsers = users_list;
1448 var myGroups = groups_list;
1444 var myGroups = groups_list;
1449
1445
1450 // Define a custom search function for the DataSource of users
1446 // Define a custom search function for the DataSource of users
1451 var matchUsers = function (sQuery) {
1447 var matchUsers = function (sQuery) {
1452 var org_sQuery = sQuery;
1448 var org_sQuery = sQuery;
1453 if(this.mentionQuery == null){
1449 if(this.mentionQuery == null){
1454 return []
1450 return []
1455 }
1451 }
1456 sQuery = this.mentionQuery;
1452 sQuery = this.mentionQuery;
1457 // Case insensitive matching
1453 // Case insensitive matching
1458 var query = sQuery.toLowerCase();
1454 var query = sQuery.toLowerCase();
1459 var i = 0;
1455 var i = 0;
1460 var l = myUsers.length;
1456 var l = myUsers.length;
1461 var matches = [];
1457 var matches = [];
1462
1458
1463 // Match against each name of each contact
1459 // Match against each name of each contact
1464 for (; i < l; i++) {
1460 for (; i < l; i++) {
1465 contact = myUsers[i];
1461 contact = myUsers[i];
1466 if (((contact.fname+"").toLowerCase().indexOf(query) > -1) ||
1462 if (((contact.fname+"").toLowerCase().indexOf(query) > -1) ||
1467 ((contact.lname+"").toLowerCase().indexOf(query) > -1) ||
1463 ((contact.lname+"").toLowerCase().indexOf(query) > -1) ||
1468 ((contact.nname) && ((contact.nname).toLowerCase().indexOf(query) > -1))) {
1464 ((contact.nname) && ((contact.nname).toLowerCase().indexOf(query) > -1))) {
1469 matches[matches.length] = contact;
1465 matches[matches.length] = contact;
1470 }
1466 }
1471 }
1467 }
1472 return matches
1468 return matches
1473 };
1469 };
1474
1470
1475 //match all
1471 //match all
1476 var matchAll = function (sQuery) {
1472 var matchAll = function (sQuery) {
1477 u = matchUsers(sQuery);
1473 u = matchUsers(sQuery);
1478 return u
1474 return u
1479 };
1475 };
1480
1476
1481 // DataScheme for owner
1477 // DataScheme for owner
1482 var ownerDS = new YAHOO.util.FunctionDataSource(matchUsers);
1478 var ownerDS = new YAHOO.util.FunctionDataSource(matchUsers);
1483
1479
1484 ownerDS.responseSchema = {
1480 ownerDS.responseSchema = {
1485 fields: ["id", "fname", "lname", "nname", "gravatar_lnk"]
1481 fields: ["id", "fname", "lname", "nname", "gravatar_lnk"]
1486 };
1482 };
1487
1483
1488 // Instantiate AutoComplete for mentions
1484 // Instantiate AutoComplete for mentions
1489 var ownerAC = new YAHOO.widget.AutoComplete(divid, cont, ownerDS);
1485 var ownerAC = new YAHOO.widget.AutoComplete(divid, cont, ownerDS);
1490 ownerAC.useShadow = false;
1486 ownerAC.useShadow = false;
1491 ownerAC.resultTypeList = false;
1487 ownerAC.resultTypeList = false;
1492 ownerAC.suppressInputUpdate = true;
1488 ownerAC.suppressInputUpdate = true;
1493 ownerAC.animVert = false;
1489 ownerAC.animVert = false;
1494 ownerAC.animHoriz = false;
1490 ownerAC.animHoriz = false;
1495 ownerAC.animSpeed = 0.1;
1491 ownerAC.animSpeed = 0.1;
1496
1492
1497 // Helper highlight function for the formatter
1493 // Helper highlight function for the formatter
1498 var highlightMatch = function (full, snippet, matchindex) {
1494 var highlightMatch = function (full, snippet, matchindex) {
1499 return full.substring(0, matchindex)
1495 return full.substring(0, matchindex)
1500 + "<span class='match'>"
1496 + "<span class='match'>"
1501 + full.substr(matchindex, snippet.length)
1497 + full.substr(matchindex, snippet.length)
1502 + "</span>" + full.substring(matchindex + snippet.length);
1498 + "</span>" + full.substring(matchindex + snippet.length);
1503 };
1499 };
1504
1500
1505 // Custom formatter to highlight the matching letters
1501 // Custom formatter to highlight the matching letters
1506 ownerAC.formatResult = function (oResultData, sQuery, sResultMatch) {
1502 ownerAC.formatResult = function (oResultData, sQuery, sResultMatch) {
1507 var org_sQuery = sQuery;
1503 var org_sQuery = sQuery;
1508 if(this.dataSource.mentionQuery != null){
1504 if(this.dataSource.mentionQuery != null){
1509 sQuery = this.dataSource.mentionQuery;
1505 sQuery = this.dataSource.mentionQuery;
1510 }
1506 }
1511
1507
1512 var query = sQuery.toLowerCase();
1508 var query = sQuery.toLowerCase();
1513 var _gravatar = function(res, em, group){
1509 var _gravatar = function(res, em, group){
1514 if (group !== undefined){
1510 if (group !== undefined){
1515 em = '/images/icons/group.png'
1511 em = '/images/icons/group.png'
1516 }
1512 }
1517 tmpl = '<div class="ac-container-wrap"><img class="perm-gravatar-ac" src="{0}"/>{1}</div>'
1513 tmpl = '<div class="ac-container-wrap"><img class="perm-gravatar-ac" src="{0}"/>{1}</div>'
1518 return tmpl.format(em,res)
1514 return tmpl.format(em,res)
1519 }
1515 }
1520 if (oResultData.nname != undefined) {
1516 if (oResultData.nname != undefined) {
1521 var fname = oResultData.fname || "";
1517 var fname = oResultData.fname || "";
1522 var lname = oResultData.lname || "";
1518 var lname = oResultData.lname || "";
1523 var nname = oResultData.nname;
1519 var nname = oResultData.nname;
1524
1520
1525 // Guard against null value
1521 // Guard against null value
1526 var fnameMatchIndex = fname.toLowerCase().indexOf(query),
1522 var fnameMatchIndex = fname.toLowerCase().indexOf(query),
1527 lnameMatchIndex = lname.toLowerCase().indexOf(query),
1523 lnameMatchIndex = lname.toLowerCase().indexOf(query),
1528 nnameMatchIndex = nname.toLowerCase().indexOf(query),
1524 nnameMatchIndex = nname.toLowerCase().indexOf(query),
1529 displayfname, displaylname, displaynname;
1525 displayfname, displaylname, displaynname;
1530
1526
1531 if (fnameMatchIndex > -1) {
1527 if (fnameMatchIndex > -1) {
1532 displayfname = highlightMatch(fname, query, fnameMatchIndex);
1528 displayfname = highlightMatch(fname, query, fnameMatchIndex);
1533 } else {
1529 } else {
1534 displayfname = fname;
1530 displayfname = fname;
1535 }
1531 }
1536
1532
1537 if (lnameMatchIndex > -1) {
1533 if (lnameMatchIndex > -1) {
1538 displaylname = highlightMatch(lname, query, lnameMatchIndex);
1534 displaylname = highlightMatch(lname, query, lnameMatchIndex);
1539 } else {
1535 } else {
1540 displaylname = lname;
1536 displaylname = lname;
1541 }
1537 }
1542
1538
1543 if (nnameMatchIndex > -1) {
1539 if (nnameMatchIndex > -1) {
1544 displaynname = "(" + highlightMatch(nname, query, nnameMatchIndex) + ")";
1540 displaynname = "(" + highlightMatch(nname, query, nnameMatchIndex) + ")";
1545 } else {
1541 } else {
1546 displaynname = nname ? "(" + nname + ")" : "";
1542 displaynname = nname ? "(" + nname + ")" : "";
1547 }
1543 }
1548
1544
1549 return _gravatar(displayfname + " " + displaylname + " " + displaynname, oResultData.gravatar_lnk);
1545 return _gravatar(displayfname + " " + displaylname + " " + displaynname, oResultData.gravatar_lnk);
1550 } else {
1546 } else {
1551 return '';
1547 return '';
1552 }
1548 }
1553 };
1549 };
1554
1550
1555 if(ownerAC.itemSelectEvent){
1551 if(ownerAC.itemSelectEvent){
1556 ownerAC.itemSelectEvent.subscribe(function (sType, aArgs) {
1552 ownerAC.itemSelectEvent.subscribe(function (sType, aArgs) {
1557
1553
1558 var myAC = aArgs[0]; // reference back to the AC instance
1554 var myAC = aArgs[0]; // reference back to the AC instance
1559 var elLI = aArgs[1]; // reference to the selected LI element
1555 var elLI = aArgs[1]; // reference to the selected LI element
1560 var oData = aArgs[2]; // object literal of selected item's result data
1556 var oData = aArgs[2]; // object literal of selected item's result data
1561 //fill the autocomplete with value
1557 //fill the autocomplete with value
1562 if (oData.nname != undefined) {
1558 if (oData.nname != undefined) {
1563 //users
1559 //users
1564 //Replace the mention name with replaced
1560 //Replace the mention name with replaced
1565 var re = new RegExp();
1561 var re = new RegExp();
1566 var org = myAC.getInputEl().value;
1562 var org = myAC.getInputEl().value;
1567 var chunks = myAC.dataSource.chunks
1563 var chunks = myAC.dataSource.chunks
1568 // replace middle chunk(the search term) with actuall match
1564 // replace middle chunk(the search term) with actuall match
1569 chunks[1] = chunks[1].replace('@'+myAC.dataSource.mentionQuery,
1565 chunks[1] = chunks[1].replace('@'+myAC.dataSource.mentionQuery,
1570 '@'+oData.nname+' ');
1566 '@'+oData.nname+' ');
1571 myAC.getInputEl().value = chunks.join('')
1567 myAC.getInputEl().value = chunks.join('')
1572 YUD.get(myAC.getInputEl()).focus(); // Y U NO WORK !?
1568 YUD.get(myAC.getInputEl()).focus(); // Y U NO WORK !?
1573 } else {
1569 } else {
1574 //groups
1570 //groups
1575 myAC.getInputEl().value = oData.grname;
1571 myAC.getInputEl().value = oData.grname;
1576 YUD.get('perm_new_member_type').value = 'users_group';
1572 YUD.get('perm_new_member_type').value = 'users_group';
1577 }
1573 }
1578 });
1574 });
1579 }
1575 }
1580
1576
1581 // in this keybuffer we will gather current value of search !
1577 // in this keybuffer we will gather current value of search !
1582 // since we need to get this just when someone does `@` then we do the
1578 // since we need to get this just when someone does `@` then we do the
1583 // search
1579 // search
1584 ownerAC.dataSource.chunks = [];
1580 ownerAC.dataSource.chunks = [];
1585 ownerAC.dataSource.mentionQuery = null;
1581 ownerAC.dataSource.mentionQuery = null;
1586
1582
1587 ownerAC.get_mention = function(msg, max_pos) {
1583 ownerAC.get_mention = function(msg, max_pos) {
1588 var org = msg;
1584 var org = msg;
1589 var re = new RegExp('(?:^@|\s@)([a-zA-Z0-9]{1}[a-zA-Z0-9\-\_\.]+)$')
1585 var re = new RegExp('(?:^@|\s@)([a-zA-Z0-9]{1}[a-zA-Z0-9\-\_\.]+)$')
1590 var chunks = [];
1586 var chunks = [];
1591
1587
1592
1588
1593 // cut first chunk until curret pos
1589 // cut first chunk until curret pos
1594 var to_max = msg.substr(0, max_pos);
1590 var to_max = msg.substr(0, max_pos);
1595 var at_pos = Math.max(0,to_max.lastIndexOf('@')-1);
1591 var at_pos = Math.max(0,to_max.lastIndexOf('@')-1);
1596 var msg2 = to_max.substr(at_pos);
1592 var msg2 = to_max.substr(at_pos);
1597
1593
1598 chunks.push(org.substr(0,at_pos))// prefix chunk
1594 chunks.push(org.substr(0,at_pos))// prefix chunk
1599 chunks.push(msg2) // search chunk
1595 chunks.push(msg2) // search chunk
1600 chunks.push(org.substr(max_pos)) // postfix chunk
1596 chunks.push(org.substr(max_pos)) // postfix chunk
1601
1597
1602 // clean up msg2 for filtering and regex match
1598 // clean up msg2 for filtering and regex match
1603 var msg2 = msg2.lstrip(' ').lstrip('\n');
1599 var msg2 = msg2.lstrip(' ').lstrip('\n');
1604
1600
1605 if(re.test(msg2)){
1601 if(re.test(msg2)){
1606 var unam = re.exec(msg2)[1];
1602 var unam = re.exec(msg2)[1];
1607 return [unam, chunks];
1603 return [unam, chunks];
1608 }
1604 }
1609 return [null, null];
1605 return [null, null];
1610 };
1606 };
1611
1607
1612 if (ownerAC.textboxKeyUpEvent){
1608 if (ownerAC.textboxKeyUpEvent){
1613 ownerAC.textboxKeyUpEvent.subscribe(function(type, args){
1609 ownerAC.textboxKeyUpEvent.subscribe(function(type, args){
1614
1610
1615 var ac_obj = args[0];
1611 var ac_obj = args[0];
1616 var currentMessage = args[1];
1612 var currentMessage = args[1];
1617 var currentCaretPosition = args[0]._elTextbox.selectionStart;
1613 var currentCaretPosition = args[0]._elTextbox.selectionStart;
1618
1614
1619 var unam = ownerAC.get_mention(currentMessage, currentCaretPosition);
1615 var unam = ownerAC.get_mention(currentMessage, currentCaretPosition);
1620 var curr_search = null;
1616 var curr_search = null;
1621 if(unam[0]){
1617 if(unam[0]){
1622 curr_search = unam[0];
1618 curr_search = unam[0];
1623 }
1619 }
1624
1620
1625 ownerAC.dataSource.chunks = unam[1];
1621 ownerAC.dataSource.chunks = unam[1];
1626 ownerAC.dataSource.mentionQuery = curr_search;
1622 ownerAC.dataSource.mentionQuery = curr_search;
1627
1623
1628 })
1624 })
1629 }
1625 }
1630 return {
1626 return {
1631 ownerDS: ownerDS,
1627 ownerDS: ownerDS,
1632 ownerAC: ownerAC,
1628 ownerAC: ownerAC,
1633 };
1629 };
1634 }
1630 }
1635
1631
1636 var addReviewMember = function(id,fname,lname,nname,gravatar_link){
1632 var addReviewMember = function(id,fname,lname,nname,gravatar_link){
1637 var members = YUD.get('review_members');
1633 var members = YUD.get('review_members');
1638 var tmpl = '<li id="reviewer_{2}">'+
1634 var tmpl = '<li id="reviewer_{2}">'+
1639 '<div class="reviewers_member">'+
1635 '<div class="reviewers_member">'+
1640 '<div class="gravatar"><img alt="gravatar" src="{0}"/> </div>'+
1636 '<div class="gravatar"><img alt="gravatar" src="{0}"/> </div>'+
1641 '<div style="float:left">{1}</div>'+
1637 '<div style="float:left">{1}</div>'+
1642 '<input type="hidden" value="{2}" name="review_members" />'+
1638 '<input type="hidden" value="{2}" name="review_members" />'+
1643 '<span class="delete_icon action_button" onclick="removeReviewMember({2})"></span>'+
1639 '<span class="delete_icon action_button" onclick="removeReviewMember({2})"></span>'+
1644 '</div>'+
1640 '</div>'+
1645 '</li>' ;
1641 '</li>' ;
1646 var displayname = "{0} {1} ({2})".format(fname,lname,nname);
1642 var displayname = "{0} {1} ({2})".format(fname,lname,nname);
1647 var element = tmpl.format(gravatar_link,displayname,id);
1643 var element = tmpl.format(gravatar_link,displayname,id);
1648 // check if we don't have this ID already in
1644 // check if we don't have this ID already in
1649 var ids = [];
1645 var ids = [];
1650 var _els = YUQ('#review_members li');
1646 var _els = YUQ('#review_members li');
1651 for (el in _els){
1647 for (el in _els){
1652 ids.push(_els[el].id)
1648 ids.push(_els[el].id)
1653 }
1649 }
1654 if(ids.indexOf('reviewer_'+id) == -1){
1650 if(ids.indexOf('reviewer_'+id) == -1){
1655 //only add if it's not there
1651 //only add if it's not there
1656 members.innerHTML += element;
1652 members.innerHTML += element;
1657 }
1653 }
1658
1654
1659 }
1655 }
1660
1656
1661 var removeReviewMember = function(reviewer_id, repo_name, pull_request_id){
1657 var removeReviewMember = function(reviewer_id, repo_name, pull_request_id){
1662 var el = YUD.get('reviewer_{0}'.format(reviewer_id));
1658 var el = YUD.get('reviewer_{0}'.format(reviewer_id));
1663 if (el.parentNode !== undefined){
1659 if (el.parentNode !== undefined){
1664 el.parentNode.removeChild(el);
1660 el.parentNode.removeChild(el);
1665 }
1661 }
1666 }
1662 }
1667
1663
1668 var updateReviewers = function(reviewers_ids, repo_name, pull_request_id){
1664 var updateReviewers = function(reviewers_ids, repo_name, pull_request_id){
1669 if (reviewers_ids === undefined){
1665 if (reviewers_ids === undefined){
1670 var reviewers_ids = [];
1666 var reviewers_ids = [];
1671 var ids = YUQ('#review_members input');
1667 var ids = YUQ('#review_members input');
1672 for(var i=0; i<ids.length;i++){
1668 for(var i=0; i<ids.length;i++){
1673 var id = ids[i].value
1669 var id = ids[i].value
1674 reviewers_ids.push(id);
1670 reviewers_ids.push(id);
1675 }
1671 }
1676 }
1672 }
1677 var url = pyroutes.url('pullrequest_update', {"repo_name":repo_name,
1673 var url = pyroutes.url('pullrequest_update', {"repo_name":repo_name,
1678 "pull_request_id": pull_request_id});
1674 "pull_request_id": pull_request_id});
1679 var postData = {'_method':'put',
1675 var postData = {'_method':'put',
1680 'reviewers_ids': reviewers_ids};
1676 'reviewers_ids': reviewers_ids};
1681 var success = function(o){
1677 var success = function(o){
1682 window.location.reload();
1678 window.location.reload();
1683 }
1679 }
1684 ajaxPOST(url,postData,success);
1680 ajaxPOST(url,postData,success);
1685 }
1681 }
1686
1682
1687 var PullRequestAutoComplete = function (divid, cont, users_list, groups_list) {
1683 var PullRequestAutoComplete = function (divid, cont, users_list, groups_list) {
1688 var myUsers = users_list;
1684 var myUsers = users_list;
1689 var myGroups = groups_list;
1685 var myGroups = groups_list;
1690
1686
1691 // Define a custom search function for the DataSource of users
1687 // Define a custom search function for the DataSource of users
1692 var matchUsers = function (sQuery) {
1688 var matchUsers = function (sQuery) {
1693 // Case insensitive matching
1689 // Case insensitive matching
1694 var query = sQuery.toLowerCase();
1690 var query = sQuery.toLowerCase();
1695 var i = 0;
1691 var i = 0;
1696 var l = myUsers.length;
1692 var l = myUsers.length;
1697 var matches = [];
1693 var matches = [];
1698
1694
1699 // Match against each name of each contact
1695 // Match against each name of each contact
1700 for (; i < l; i++) {
1696 for (; i < l; i++) {
1701 contact = myUsers[i];
1697 contact = myUsers[i];
1702 if (((contact.fname+"").toLowerCase().indexOf(query) > -1) ||
1698 if (((contact.fname+"").toLowerCase().indexOf(query) > -1) ||
1703 ((contact.lname+"").toLowerCase().indexOf(query) > -1) ||
1699 ((contact.lname+"").toLowerCase().indexOf(query) > -1) ||
1704 ((contact.nname) && ((contact.nname).toLowerCase().indexOf(query) > -1))) {
1700 ((contact.nname) && ((contact.nname).toLowerCase().indexOf(query) > -1))) {
1705 matches[matches.length] = contact;
1701 matches[matches.length] = contact;
1706 }
1702 }
1707 }
1703 }
1708 return matches;
1704 return matches;
1709 };
1705 };
1710
1706
1711 // Define a custom search function for the DataSource of userGroups
1707 // Define a custom search function for the DataSource of userGroups
1712 var matchGroups = function (sQuery) {
1708 var matchGroups = function (sQuery) {
1713 // Case insensitive matching
1709 // Case insensitive matching
1714 var query = sQuery.toLowerCase();
1710 var query = sQuery.toLowerCase();
1715 var i = 0;
1711 var i = 0;
1716 var l = myGroups.length;
1712 var l = myGroups.length;
1717 var matches = [];
1713 var matches = [];
1718
1714
1719 // Match against each name of each contact
1715 // Match against each name of each contact
1720 for (; i < l; i++) {
1716 for (; i < l; i++) {
1721 matched_group = myGroups[i];
1717 matched_group = myGroups[i];
1722 if (matched_group.grname.toLowerCase().indexOf(query) > -1) {
1718 if (matched_group.grname.toLowerCase().indexOf(query) > -1) {
1723 matches[matches.length] = matched_group;
1719 matches[matches.length] = matched_group;
1724 }
1720 }
1725 }
1721 }
1726 return matches;
1722 return matches;
1727 };
1723 };
1728
1724
1729 //match all
1725 //match all
1730 var matchAll = function (sQuery) {
1726 var matchAll = function (sQuery) {
1731 u = matchUsers(sQuery);
1727 u = matchUsers(sQuery);
1732 return u
1728 return u
1733 };
1729 };
1734
1730
1735 // DataScheme for owner
1731 // DataScheme for owner
1736 var ownerDS = new YAHOO.util.FunctionDataSource(matchUsers);
1732 var ownerDS = new YAHOO.util.FunctionDataSource(matchUsers);
1737
1733
1738 ownerDS.responseSchema = {
1734 ownerDS.responseSchema = {
1739 fields: ["id", "fname", "lname", "nname", "gravatar_lnk"]
1735 fields: ["id", "fname", "lname", "nname", "gravatar_lnk"]
1740 };
1736 };
1741
1737
1742 // Instantiate AutoComplete for mentions
1738 // Instantiate AutoComplete for mentions
1743 var reviewerAC = new YAHOO.widget.AutoComplete(divid, cont, ownerDS);
1739 var reviewerAC = new YAHOO.widget.AutoComplete(divid, cont, ownerDS);
1744 reviewerAC.useShadow = false;
1740 reviewerAC.useShadow = false;
1745 reviewerAC.resultTypeList = false;
1741 reviewerAC.resultTypeList = false;
1746 reviewerAC.suppressInputUpdate = true;
1742 reviewerAC.suppressInputUpdate = true;
1747 reviewerAC.animVert = false;
1743 reviewerAC.animVert = false;
1748 reviewerAC.animHoriz = false;
1744 reviewerAC.animHoriz = false;
1749 reviewerAC.animSpeed = 0.1;
1745 reviewerAC.animSpeed = 0.1;
1750
1746
1751 // Helper highlight function for the formatter
1747 // Helper highlight function for the formatter
1752 var highlightMatch = function (full, snippet, matchindex) {
1748 var highlightMatch = function (full, snippet, matchindex) {
1753 return full.substring(0, matchindex)
1749 return full.substring(0, matchindex)
1754 + "<span class='match'>"
1750 + "<span class='match'>"
1755 + full.substr(matchindex, snippet.length)
1751 + full.substr(matchindex, snippet.length)
1756 + "</span>" + full.substring(matchindex + snippet.length);
1752 + "</span>" + full.substring(matchindex + snippet.length);
1757 };
1753 };
1758
1754
1759 // Custom formatter to highlight the matching letters
1755 // Custom formatter to highlight the matching letters
1760 reviewerAC.formatResult = function (oResultData, sQuery, sResultMatch) {
1756 reviewerAC.formatResult = function (oResultData, sQuery, sResultMatch) {
1761 var org_sQuery = sQuery;
1757 var org_sQuery = sQuery;
1762 if(this.dataSource.mentionQuery != null){
1758 if(this.dataSource.mentionQuery != null){
1763 sQuery = this.dataSource.mentionQuery;
1759 sQuery = this.dataSource.mentionQuery;
1764 }
1760 }
1765
1761
1766 var query = sQuery.toLowerCase();
1762 var query = sQuery.toLowerCase();
1767 var _gravatar = function(res, em, group){
1763 var _gravatar = function(res, em, group){
1768 if (group !== undefined){
1764 if (group !== undefined){
1769 em = '/images/icons/group.png'
1765 em = '/images/icons/group.png'
1770 }
1766 }
1771 tmpl = '<div class="ac-container-wrap"><img class="perm-gravatar-ac" src="{0}"/>{1}</div>'
1767 tmpl = '<div class="ac-container-wrap"><img class="perm-gravatar-ac" src="{0}"/>{1}</div>'
1772 return tmpl.format(em,res)
1768 return tmpl.format(em,res)
1773 }
1769 }
1774 if (oResultData.nname != undefined) {
1770 if (oResultData.nname != undefined) {
1775 var fname = oResultData.fname || "";
1771 var fname = oResultData.fname || "";
1776 var lname = oResultData.lname || "";
1772 var lname = oResultData.lname || "";
1777 var nname = oResultData.nname;
1773 var nname = oResultData.nname;
1778
1774
1779 // Guard against null value
1775 // Guard against null value
1780 var fnameMatchIndex = fname.toLowerCase().indexOf(query),
1776 var fnameMatchIndex = fname.toLowerCase().indexOf(query),
1781 lnameMatchIndex = lname.toLowerCase().indexOf(query),
1777 lnameMatchIndex = lname.toLowerCase().indexOf(query),
1782 nnameMatchIndex = nname.toLowerCase().indexOf(query),
1778 nnameMatchIndex = nname.toLowerCase().indexOf(query),
1783 displayfname, displaylname, displaynname;
1779 displayfname, displaylname, displaynname;
1784
1780
1785 if (fnameMatchIndex > -1) {
1781 if (fnameMatchIndex > -1) {
1786 displayfname = highlightMatch(fname, query, fnameMatchIndex);
1782 displayfname = highlightMatch(fname, query, fnameMatchIndex);
1787 } else {
1783 } else {
1788 displayfname = fname;
1784 displayfname = fname;
1789 }
1785 }
1790
1786
1791 if (lnameMatchIndex > -1) {
1787 if (lnameMatchIndex > -1) {
1792 displaylname = highlightMatch(lname, query, lnameMatchIndex);
1788 displaylname = highlightMatch(lname, query, lnameMatchIndex);
1793 } else {
1789 } else {
1794 displaylname = lname;
1790 displaylname = lname;
1795 }
1791 }
1796
1792
1797 if (nnameMatchIndex > -1) {
1793 if (nnameMatchIndex > -1) {
1798 displaynname = "(" + highlightMatch(nname, query, nnameMatchIndex) + ")";
1794 displaynname = "(" + highlightMatch(nname, query, nnameMatchIndex) + ")";
1799 } else {
1795 } else {
1800 displaynname = nname ? "(" + nname + ")" : "";
1796 displaynname = nname ? "(" + nname + ")" : "";
1801 }
1797 }
1802
1798
1803 return _gravatar(displayfname + " " + displaylname + " " + displaynname, oResultData.gravatar_lnk);
1799 return _gravatar(displayfname + " " + displaylname + " " + displaynname, oResultData.gravatar_lnk);
1804 } else {
1800 } else {
1805 return '';
1801 return '';
1806 }
1802 }
1807 };
1803 };
1808
1804
1809 //members cache to catch duplicates
1805 //members cache to catch duplicates
1810 reviewerAC.dataSource.cache = [];
1806 reviewerAC.dataSource.cache = [];
1811 // hack into select event
1807 // hack into select event
1812 if(reviewerAC.itemSelectEvent){
1808 if(reviewerAC.itemSelectEvent){
1813 reviewerAC.itemSelectEvent.subscribe(function (sType, aArgs) {
1809 reviewerAC.itemSelectEvent.subscribe(function (sType, aArgs) {
1814
1810
1815 var myAC = aArgs[0]; // reference back to the AC instance
1811 var myAC = aArgs[0]; // reference back to the AC instance
1816 var elLI = aArgs[1]; // reference to the selected LI element
1812 var elLI = aArgs[1]; // reference to the selected LI element
1817 var oData = aArgs[2]; // object literal of selected item's result data
1813 var oData = aArgs[2]; // object literal of selected item's result data
1818
1814
1819 //fill the autocomplete with value
1815 //fill the autocomplete with value
1820
1816
1821 if (oData.nname != undefined) {
1817 if (oData.nname != undefined) {
1822 addReviewMember(oData.id, oData.fname, oData.lname, oData.nname,
1818 addReviewMember(oData.id, oData.fname, oData.lname, oData.nname,
1823 oData.gravatar_lnk);
1819 oData.gravatar_lnk);
1824 myAC.dataSource.cache.push(oData.id);
1820 myAC.dataSource.cache.push(oData.id);
1825 YUD.get('user').value = ''
1821 YUD.get('user').value = ''
1826 }
1822 }
1827 });
1823 });
1828 }
1824 }
1829 return {
1825 return {
1830 ownerDS: ownerDS,
1826 ownerDS: ownerDS,
1831 reviewerAC: reviewerAC,
1827 reviewerAC: reviewerAC,
1832 };
1828 };
1833 }
1829 }
1834
1830
1835 /**
1831 /**
1836 * QUICK REPO MENU
1832 * QUICK REPO MENU
1837 */
1833 */
1838 var quick_repo_menu = function(){
1834 var quick_repo_menu = function(){
1839 YUE.on(YUQ('.quick_repo_menu'),'mouseenter',function(e){
1835 YUE.on(YUQ('.quick_repo_menu'),'mouseenter',function(e){
1840 var menu = e.currentTarget.firstElementChild.firstElementChild;
1836 var menu = e.currentTarget.firstElementChild.firstElementChild;
1841 if(YUD.hasClass(menu,'hidden')){
1837 if(YUD.hasClass(menu,'hidden')){
1842 YUD.replaceClass(e.currentTarget,'hidden', 'active');
1838 YUD.replaceClass(e.currentTarget,'hidden', 'active');
1843 YUD.replaceClass(menu, 'hidden', 'active');
1839 YUD.replaceClass(menu, 'hidden', 'active');
1844 }
1840 }
1845 })
1841 })
1846 YUE.on(YUQ('.quick_repo_menu'),'mouseleave',function(e){
1842 YUE.on(YUQ('.quick_repo_menu'),'mouseleave',function(e){
1847 var menu = e.currentTarget.firstElementChild.firstElementChild;
1843 var menu = e.currentTarget.firstElementChild.firstElementChild;
1848 if(YUD.hasClass(menu,'active')){
1844 if(YUD.hasClass(menu,'active')){
1849 YUD.replaceClass(e.currentTarget, 'active', 'hidden');
1845 YUD.replaceClass(e.currentTarget, 'active', 'hidden');
1850 YUD.replaceClass(menu, 'active', 'hidden');
1846 YUD.replaceClass(menu, 'active', 'hidden');
1851 }
1847 }
1852 })
1848 })
1853 };
1849 };
1854
1850
1855
1851
1856 /**
1852 /**
1857 * TABLE SORTING
1853 * TABLE SORTING
1858 */
1854 */
1859
1855
1860 // returns a node from given html;
1856 // returns a node from given html;
1861 var fromHTML = function(html){
1857 var fromHTML = function(html){
1862 var _html = document.createElement('element');
1858 var _html = document.createElement('element');
1863 _html.innerHTML = html;
1859 _html.innerHTML = html;
1864 return _html;
1860 return _html;
1865 }
1861 }
1866 var get_rev = function(node){
1862 var get_rev = function(node){
1867 var n = node.firstElementChild.firstElementChild;
1863 var n = node.firstElementChild.firstElementChild;
1868
1864
1869 if (n===null){
1865 if (n===null){
1870 return -1
1866 return -1
1871 }
1867 }
1872 else{
1868 else{
1873 out = n.firstElementChild.innerHTML.split(':')[0].replace('r','');
1869 out = n.firstElementChild.innerHTML.split(':')[0].replace('r','');
1874 return parseInt(out);
1870 return parseInt(out);
1875 }
1871 }
1876 }
1872 }
1877
1873
1878 var get_name = function(node){
1874 var get_name = function(node){
1879 var name = node.firstElementChild.children[2].innerHTML;
1875 var name = node.firstElementChild.children[2].innerHTML;
1880 return name
1876 return name
1881 }
1877 }
1882 var get_group_name = function(node){
1878 var get_group_name = function(node){
1883 var name = node.firstElementChild.children[1].innerHTML;
1879 var name = node.firstElementChild.children[1].innerHTML;
1884 return name
1880 return name
1885 }
1881 }
1886 var get_date = function(node){
1882 var get_date = function(node){
1887 var date_ = YUD.getAttribute(node.firstElementChild,'date');
1883 var date_ = YUD.getAttribute(node.firstElementChild,'date');
1888 return date_
1884 return date_
1889 }
1885 }
1890
1886
1891 var get_age = function(node){
1887 var get_age = function(node){
1892 return node
1888 return node
1893 }
1889 }
1894
1890
1895 var get_link = function(node){
1891 var get_link = function(node){
1896 return node.firstElementChild.text;
1892 return node.firstElementChild.text;
1897 }
1893 }
1898
1894
1899 var revisionSort = function(a, b, desc, field) {
1895 var revisionSort = function(a, b, desc, field) {
1900
1896
1901 var a_ = fromHTML(a.getData(field));
1897 var a_ = fromHTML(a.getData(field));
1902 var b_ = fromHTML(b.getData(field));
1898 var b_ = fromHTML(b.getData(field));
1903
1899
1904 // extract revisions from string nodes
1900 // extract revisions from string nodes
1905 a_ = get_rev(a_)
1901 a_ = get_rev(a_)
1906 b_ = get_rev(b_)
1902 b_ = get_rev(b_)
1907
1903
1908 var comp = YAHOO.util.Sort.compare;
1904 var comp = YAHOO.util.Sort.compare;
1909 var compState = comp(a_, b_, desc);
1905 var compState = comp(a_, b_, desc);
1910 return compState;
1906 return compState;
1911 };
1907 };
1912 var ageSort = function(a, b, desc, field) {
1908 var ageSort = function(a, b, desc, field) {
1913 var a_ = fromHTML(a.getData(field));
1909 var a_ = fromHTML(a.getData(field));
1914 var b_ = fromHTML(b.getData(field));
1910 var b_ = fromHTML(b.getData(field));
1915
1911
1916 // extract name from table
1912 // extract name from table
1917 a_ = get_date(a_)
1913 a_ = get_date(a_)
1918 b_ = get_date(b_)
1914 b_ = get_date(b_)
1919
1915
1920 var comp = YAHOO.util.Sort.compare;
1916 var comp = YAHOO.util.Sort.compare;
1921 var compState = comp(a_, b_, desc);
1917 var compState = comp(a_, b_, desc);
1922 return compState;
1918 return compState;
1923 };
1919 };
1924
1920
1925 var lastLoginSort = function(a, b, desc, field) {
1921 var lastLoginSort = function(a, b, desc, field) {
1926 var a_ = a.getData('last_login_raw') || 0;
1922 var a_ = a.getData('last_login_raw') || 0;
1927 var b_ = b.getData('last_login_raw') || 0;
1923 var b_ = b.getData('last_login_raw') || 0;
1928
1924
1929 var comp = YAHOO.util.Sort.compare;
1925 var comp = YAHOO.util.Sort.compare;
1930 var compState = comp(a_, b_, desc);
1926 var compState = comp(a_, b_, desc);
1931 return compState;
1927 return compState;
1932 };
1928 };
1933
1929
1934 var nameSort = function(a, b, desc, field) {
1930 var nameSort = function(a, b, desc, field) {
1935 var a_ = fromHTML(a.getData(field));
1931 var a_ = fromHTML(a.getData(field));
1936 var b_ = fromHTML(b.getData(field));
1932 var b_ = fromHTML(b.getData(field));
1937
1933
1938 // extract name from table
1934 // extract name from table
1939 a_ = get_name(a_)
1935 a_ = get_name(a_)
1940 b_ = get_name(b_)
1936 b_ = get_name(b_)
1941
1937
1942 var comp = YAHOO.util.Sort.compare;
1938 var comp = YAHOO.util.Sort.compare;
1943 var compState = comp(a_, b_, desc);
1939 var compState = comp(a_, b_, desc);
1944 return compState;
1940 return compState;
1945 };
1941 };
1946
1942
1947 var permNameSort = function(a, b, desc, field) {
1943 var permNameSort = function(a, b, desc, field) {
1948 var a_ = fromHTML(a.getData(field));
1944 var a_ = fromHTML(a.getData(field));
1949 var b_ = fromHTML(b.getData(field));
1945 var b_ = fromHTML(b.getData(field));
1950 // extract name from table
1946 // extract name from table
1951
1947
1952 a_ = a_.children[0].innerHTML;
1948 a_ = a_.children[0].innerHTML;
1953 b_ = b_.children[0].innerHTML;
1949 b_ = b_.children[0].innerHTML;
1954
1950
1955 var comp = YAHOO.util.Sort.compare;
1951 var comp = YAHOO.util.Sort.compare;
1956 var compState = comp(a_, b_, desc);
1952 var compState = comp(a_, b_, desc);
1957 return compState;
1953 return compState;
1958 };
1954 };
1959
1955
1960 var groupNameSort = function(a, b, desc, field) {
1956 var groupNameSort = function(a, b, desc, field) {
1961 var a_ = fromHTML(a.getData(field));
1957 var a_ = fromHTML(a.getData(field));
1962 var b_ = fromHTML(b.getData(field));
1958 var b_ = fromHTML(b.getData(field));
1963
1959
1964 // extract name from table
1960 // extract name from table
1965 a_ = get_group_name(a_)
1961 a_ = get_group_name(a_)
1966 b_ = get_group_name(b_)
1962 b_ = get_group_name(b_)
1967
1963
1968 var comp = YAHOO.util.Sort.compare;
1964 var comp = YAHOO.util.Sort.compare;
1969 var compState = comp(a_, b_, desc);
1965 var compState = comp(a_, b_, desc);
1970 return compState;
1966 return compState;
1971 };
1967 };
1972 var dateSort = function(a, b, desc, field) {
1968 var dateSort = function(a, b, desc, field) {
1973 var a_ = fromHTML(a.getData(field));
1969 var a_ = fromHTML(a.getData(field));
1974 var b_ = fromHTML(b.getData(field));
1970 var b_ = fromHTML(b.getData(field));
1975
1971
1976 // extract name from table
1972 // extract name from table
1977 a_ = get_date(a_)
1973 a_ = get_date(a_)
1978 b_ = get_date(b_)
1974 b_ = get_date(b_)
1979
1975
1980 var comp = YAHOO.util.Sort.compare;
1976 var comp = YAHOO.util.Sort.compare;
1981 var compState = comp(a_, b_, desc);
1977 var compState = comp(a_, b_, desc);
1982 return compState;
1978 return compState;
1983 };
1979 };
1984
1980
1985 var usernamelinkSort = function(a, b, desc, field) {
1981 var usernamelinkSort = function(a, b, desc, field) {
1986 var a_ = fromHTML(a.getData(field));
1982 var a_ = fromHTML(a.getData(field));
1987 var b_ = fromHTML(b.getData(field));
1983 var b_ = fromHTML(b.getData(field));
1988
1984
1989 // extract url text from string nodes
1985 // extract url text from string nodes
1990 a_ = get_link(a_)
1986 a_ = get_link(a_)
1991 b_ = get_link(b_)
1987 b_ = get_link(b_)
1992 var comp = YAHOO.util.Sort.compare;
1988 var comp = YAHOO.util.Sort.compare;
1993 var compState = comp(a_, b_, desc);
1989 var compState = comp(a_, b_, desc);
1994 return compState;
1990 return compState;
1995 }
1991 }
1996
1992
1997 var addPermAction = function(_html, users_list, groups_list){
1993 var addPermAction = function(_html, users_list, groups_list){
1998 var elmts = YUD.getElementsByClassName('last_new_member');
1994 var elmts = YUD.getElementsByClassName('last_new_member');
1999 var last_node = elmts[elmts.length-1];
1995 var last_node = elmts[elmts.length-1];
2000 if (last_node){
1996 if (last_node){
2001 var next_id = (YUD.getElementsByClassName('new_members')).length;
1997 var next_id = (YUD.getElementsByClassName('new_members')).length;
2002 _html = _html.format(next_id);
1998 _html = _html.format(next_id);
2003 last_node.innerHTML = _html;
1999 last_node.innerHTML = _html;
2004 YUD.setStyle(last_node, 'display', '');
2000 YUD.setStyle(last_node, 'display', '');
2005 YUD.removeClass(last_node, 'last_new_member');
2001 YUD.removeClass(last_node, 'last_new_member');
2006 MembersAutoComplete("perm_new_member_name_"+next_id,
2002 MembersAutoComplete("perm_new_member_name_"+next_id,
2007 "perm_container_"+next_id, users_list, groups_list);
2003 "perm_container_"+next_id, users_list, groups_list);
2008 //create new last NODE
2004 //create new last NODE
2009 var el = document.createElement('tr');
2005 var el = document.createElement('tr');
2010 el.id = 'add_perm_input';
2006 el.id = 'add_perm_input';
2011 YUD.addClass(el,'last_new_member');
2007 YUD.addClass(el,'last_new_member');
2012 YUD.addClass(el,'new_members');
2008 YUD.addClass(el,'new_members');
2013 YUD.insertAfter(el, last_node);
2009 YUD.insertAfter(el, last_node);
2014 }
2010 }
2015 }
2011 }
2016
2012
2017 /* Multi selectors */
2013 /* Multi selectors */
2018
2014
2019 var MultiSelectWidget = function(selected_id, available_id, form_id){
2015 var MultiSelectWidget = function(selected_id, available_id, form_id){
2020
2016
2021
2017
2022 //definition of containers ID's
2018 //definition of containers ID's
2023 var selected_container = selected_id;
2019 var selected_container = selected_id;
2024 var available_container = available_id;
2020 var available_container = available_id;
2025
2021
2026 //temp container for selected storage.
2022 //temp container for selected storage.
2027 var cache = new Array();
2023 var cache = new Array();
2028 var av_cache = new Array();
2024 var av_cache = new Array();
2029 var c = YUD.get(selected_container);
2025 var c = YUD.get(selected_container);
2030 var ac = YUD.get(available_container);
2026 var ac = YUD.get(available_container);
2031
2027
2032 //get only selected options for further fullfilment
2028 //get only selected options for further fullfilment
2033 for(var i = 0;node =c.options[i];i++){
2029 for(var i = 0;node =c.options[i];i++){
2034 if(node.selected){
2030 if(node.selected){
2035 //push selected to my temp storage left overs :)
2031 //push selected to my temp storage left overs :)
2036 cache.push(node);
2032 cache.push(node);
2037 }
2033 }
2038 }
2034 }
2039
2035
2040 //get all available options to cache
2036 //get all available options to cache
2041 for(var i = 0;node =ac.options[i];i++){
2037 for(var i = 0;node =ac.options[i];i++){
2042 //push selected to my temp storage left overs :)
2038 //push selected to my temp storage left overs :)
2043 av_cache.push(node);
2039 av_cache.push(node);
2044 }
2040 }
2045
2041
2046 //fill available only with those not in chosen
2042 //fill available only with those not in chosen
2047 ac.options.length=0;
2043 ac.options.length=0;
2048 tmp_cache = new Array();
2044 tmp_cache = new Array();
2049
2045
2050 for(var i = 0;node = av_cache[i];i++){
2046 for(var i = 0;node = av_cache[i];i++){
2051 var add = true;
2047 var add = true;
2052 for(var i2 = 0;node_2 = cache[i2];i2++){
2048 for(var i2 = 0;node_2 = cache[i2];i2++){
2053 if(node.value == node_2.value){
2049 if(node.value == node_2.value){
2054 add=false;
2050 add=false;
2055 break;
2051 break;
2056 }
2052 }
2057 }
2053 }
2058 if(add){
2054 if(add){
2059 tmp_cache.push(new Option(node.text, node.value, false, false));
2055 tmp_cache.push(new Option(node.text, node.value, false, false));
2060 }
2056 }
2061 }
2057 }
2062
2058
2063 for(var i = 0;node = tmp_cache[i];i++){
2059 for(var i = 0;node = tmp_cache[i];i++){
2064 ac.options[i] = node;
2060 ac.options[i] = node;
2065 }
2061 }
2066
2062
2067 function prompts_action_callback(e){
2063 function prompts_action_callback(e){
2068
2064
2069 var chosen = YUD.get(selected_container);
2065 var chosen = YUD.get(selected_container);
2070 var available = YUD.get(available_container);
2066 var available = YUD.get(available_container);
2071
2067
2072 //get checked and unchecked options from field
2068 //get checked and unchecked options from field
2073 function get_checked(from_field){
2069 function get_checked(from_field){
2074 //temp container for storage.
2070 //temp container for storage.
2075 var sel_cache = new Array();
2071 var sel_cache = new Array();
2076 var oth_cache = new Array();
2072 var oth_cache = new Array();
2077
2073
2078 for(var i = 0;node = from_field.options[i];i++){
2074 for(var i = 0;node = from_field.options[i];i++){
2079 if(node.selected){
2075 if(node.selected){
2080 //push selected fields :)
2076 //push selected fields :)
2081 sel_cache.push(node);
2077 sel_cache.push(node);
2082 }
2078 }
2083 else{
2079 else{
2084 oth_cache.push(node)
2080 oth_cache.push(node)
2085 }
2081 }
2086 }
2082 }
2087
2083
2088 return [sel_cache,oth_cache]
2084 return [sel_cache,oth_cache]
2089 }
2085 }
2090
2086
2091 //fill the field with given options
2087 //fill the field with given options
2092 function fill_with(field,options){
2088 function fill_with(field,options){
2093 //clear firtst
2089 //clear firtst
2094 field.options.length=0;
2090 field.options.length=0;
2095 for(var i = 0;node = options[i];i++){
2091 for(var i = 0;node = options[i];i++){
2096 field.options[i]=new Option(node.text, node.value,
2092 field.options[i]=new Option(node.text, node.value,
2097 false, false);
2093 false, false);
2098 }
2094 }
2099
2095
2100 }
2096 }
2101 //adds to current field
2097 //adds to current field
2102 function add_to(field,options){
2098 function add_to(field,options){
2103 for(var i = 0;node = options[i];i++){
2099 for(var i = 0;node = options[i];i++){
2104 field.appendChild(new Option(node.text, node.value,
2100 field.appendChild(new Option(node.text, node.value,
2105 false, false));
2101 false, false));
2106 }
2102 }
2107 }
2103 }
2108
2104
2109 // add action
2105 // add action
2110 if (this.id=='add_element'){
2106 if (this.id=='add_element'){
2111 var c = get_checked(available);
2107 var c = get_checked(available);
2112 add_to(chosen,c[0]);
2108 add_to(chosen,c[0]);
2113 fill_with(available,c[1]);
2109 fill_with(available,c[1]);
2114 }
2110 }
2115 // remove action
2111 // remove action
2116 if (this.id=='remove_element'){
2112 if (this.id=='remove_element'){
2117 var c = get_checked(chosen);
2113 var c = get_checked(chosen);
2118 add_to(available,c[0]);
2114 add_to(available,c[0]);
2119 fill_with(chosen,c[1]);
2115 fill_with(chosen,c[1]);
2120 }
2116 }
2121 // add all elements
2117 // add all elements
2122 if(this.id=='add_all_elements'){
2118 if(this.id=='add_all_elements'){
2123 for(var i=0; node = available.options[i];i++){
2119 for(var i=0; node = available.options[i];i++){
2124 chosen.appendChild(new Option(node.text,
2120 chosen.appendChild(new Option(node.text,
2125 node.value, false, false));
2121 node.value, false, false));
2126 }
2122 }
2127 available.options.length = 0;
2123 available.options.length = 0;
2128 }
2124 }
2129 //remove all elements
2125 //remove all elements
2130 if(this.id=='remove_all_elements'){
2126 if(this.id=='remove_all_elements'){
2131 for(var i=0; node = chosen.options[i];i++){
2127 for(var i=0; node = chosen.options[i];i++){
2132 available.appendChild(new Option(node.text,
2128 available.appendChild(new Option(node.text,
2133 node.value, false, false));
2129 node.value, false, false));
2134 }
2130 }
2135 chosen.options.length = 0;
2131 chosen.options.length = 0;
2136 }
2132 }
2137
2133
2138 }
2134 }
2139
2135
2140 YUE.addListener(['add_element','remove_element',
2136 YUE.addListener(['add_element','remove_element',
2141 'add_all_elements','remove_all_elements'],'click',
2137 'add_all_elements','remove_all_elements'],'click',
2142 prompts_action_callback)
2138 prompts_action_callback)
2143 if (form_id !== undefined) {
2139 if (form_id !== undefined) {
2144 YUE.addListener(form_id,'submit',function(){
2140 YUE.addListener(form_id,'submit',function(){
2145 var chosen = YUD.get(selected_container);
2141 var chosen = YUD.get(selected_container);
2146 for (var i = 0; i < chosen.options.length; i++) {
2142 for (var i = 0; i < chosen.options.length; i++) {
2147 chosen.options[i].selected = 'selected';
2143 chosen.options[i].selected = 'selected';
2148 }
2144 }
2149 });
2145 });
2150 }
2146 }
2151 }
2147 }
2152
2148
2153
2149
2154 // global hooks after DOM is loaded
2150 // global hooks after DOM is loaded
2155
2151
2156 YUE.onDOMReady(function(){
2152 YUE.onDOMReady(function(){
2157 YUE.on(YUQ('.diff-collapse-button'), 'click', function(e){
2153 YUE.on(YUQ('.diff-collapse-button'), 'click', function(e){
2158 var button = e.currentTarget;
2154 var button = e.currentTarget;
2159 var t = YUD.get(button).getAttribute('target');
2155 var t = YUD.get(button).getAttribute('target');
2160 console.log(t);
2156 console.log(t);
2161 if(YUD.hasClass(t, 'hidden')){
2157 if(YUD.hasClass(t, 'hidden')){
2162 YUD.removeClass(t, 'hidden');
2158 YUD.removeClass(t, 'hidden');
2163 YUD.get(button).innerHTML = "&uarr; {0} &uarr;".format(_TM['Collapse diff']);
2159 YUD.get(button).innerHTML = "&uarr; {0} &uarr;".format(_TM['Collapse diff']);
2164 }
2160 }
2165 else if(!YUD.hasClass(t, 'hidden')){
2161 else if(!YUD.hasClass(t, 'hidden')){
2166 YUD.addClass(t, 'hidden');
2162 YUD.addClass(t, 'hidden');
2167 YUD.get(button).innerHTML = "&darr; {0} &darr;".format(_TM['Expand diff']);
2163 YUD.get(button).innerHTML = "&darr; {0} &darr;".format(_TM['Expand diff']);
2168 }
2164 }
2169 });
2165 });
2170
2166
2171
2167
2172
2168
2173 });
2169 });
2174
2170
@@ -1,142 +1,141 b''
1 ## -*- coding: utf-8 -*-
1 ## -*- coding: utf-8 -*-
2 <%inherit file="/base/base.html"/>
2 <%inherit file="/base/base.html"/>
3
3
4 <%def name="title()">
4 <%def name="title()">
5 ${_('Repositories administration')} &middot; ${c.rhodecode_name}
5 ${_('Repositories administration')} &middot; ${c.rhodecode_name}
6 </%def>
6 </%def>
7
7
8 <%def name="breadcrumbs_links()">
8 <%def name="breadcrumbs_links()">
9 <input class="q_filter_box" id="q_filter" size="15" type="text" name="filter" value="${_('quick filter...')}"/> ${h.link_to(_('Admin'),h.url('admin_home'))} &raquo; <span id="repo_count">0</span> ${_('repositories')}
9 <input class="q_filter_box" id="q_filter" size="15" type="text" name="filter" placeholder="${_('quick filter...')}" value=""/> ${h.link_to(_('Admin'),h.url('admin_home'))} &raquo; <span id="repo_count">0</span> ${_('repositories')}
10 </%def>
10 </%def>
11 <%def name="page_nav()">
11 <%def name="page_nav()">
12 ${self.menu('admin')}
12 ${self.menu('admin')}
13 </%def>
13 </%def>
14 <%def name="main()">
14 <%def name="main()">
15 <div class="box">
15 <div class="box">
16
16
17 <div class="title">
17 <div class="title">
18 ${self.breadcrumbs()}
18 ${self.breadcrumbs()}
19 <ul class="links">
19 <ul class="links">
20 <li>
20 <li>
21 <span>${h.link_to(_(u'Add repository'),h.url('new_repo'))}</span>
21 <span>${h.link_to(_(u'Add repository'),h.url('new_repo'))}</span>
22 </li>
22 </li>
23 </ul>
23 </ul>
24 </div>
24 </div>
25 <div class="table yui-skin-sam" id="repos_list_wrap"></div>
25 <div class="table yui-skin-sam" id="repos_list_wrap"></div>
26 <div id="user-paginator" style="padding: 0px 0px 0px 20px"></div>
26 <div id="user-paginator" style="padding: 0px 0px 0px 20px"></div>
27
27
28
28
29 </div>
29 </div>
30 <script>
30 <script>
31 var url = "${h.url('formatted_users', format='json')}";
31 var url = "${h.url('formatted_users', format='json')}";
32 var data = ${c.data|n};
32 var data = ${c.data|n};
33 var myDataSource = new YAHOO.util.DataSource(data);
33 var myDataSource = new YAHOO.util.DataSource(data);
34 myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
34 myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
35
35
36 myDataSource.responseSchema = {
36 myDataSource.responseSchema = {
37 resultsList: "records",
37 resultsList: "records",
38 fields: [
38 fields: [
39 {key:"menu"},
39 {key:"menu"},
40 {key:"raw_name"},
40 {key:"raw_name"},
41 {key:"name"},
41 {key:"name"},
42 {key:"desc"},
42 {key:"desc"},
43 {key:"last_changeset"},
43 {key:"last_changeset"},
44 {key:"owner"},
44 {key:"owner"},
45 {key:"action"},
45 {key:"action"},
46 ]
46 ]
47 };
47 };
48 myDataSource.doBeforeCallback = function(req,raw,res,cb) {
48 myDataSource.doBeforeCallback = function(req,raw,res,cb) {
49 // This is the filter function
49 // This is the filter function
50 var data = res.results || [],
50 var data = res.results || [],
51 filtered = [],
51 filtered = [],
52 i,l;
52 i,l;
53
53
54 if (req) {
54 if (req) {
55 req = req.toLowerCase();
55 req = req.toLowerCase();
56 for (i = 0; i<data.length; i++) {
56 for (i = 0; i<data.length; i++) {
57 var pos = data[i].raw_name.toLowerCase().indexOf(req)
57 var pos = data[i].raw_name.toLowerCase().indexOf(req)
58 if (pos != -1) {
58 if (pos != -1) {
59 filtered.push(data[i]);
59 filtered.push(data[i]);
60 }
60 }
61 }
61 }
62 res.results = filtered;
62 res.results = filtered;
63 }
63 }
64 YUD.get('repo_count').innerHTML = res.results.length;
64 YUD.get('repo_count').innerHTML = res.results.length;
65 return res;
65 return res;
66 }
66 }
67
67
68 // main table sorting
68 // main table sorting
69 var myColumnDefs = [
69 var myColumnDefs = [
70 {key:"menu",label:"",sortable:false,className:"quick_repo_menu hidden"},
70 {key:"menu",label:"",sortable:false,className:"quick_repo_menu hidden"},
71 {key:"name",label:"${_('Name')}",sortable:true,
71 {key:"name",label:"${_('Name')}",sortable:true,
72 sortOptions: { sortFunction: nameSort }},
72 sortOptions: { sortFunction: nameSort }},
73 {key:"desc",label:"${_('Description')}",sortable:true},
73 {key:"desc",label:"${_('Description')}",sortable:true},
74 {key:"last_changeset",label:"${_('Tip')}",sortable:true,
74 {key:"last_changeset",label:"${_('Tip')}",sortable:true,
75 sortOptions: { sortFunction: revisionSort }},
75 sortOptions: { sortFunction: revisionSort }},
76 {key:"owner",label:"${_('Owner')}",sortable:true},
76 {key:"owner",label:"${_('Owner')}",sortable:true},
77 {key:"action",label:"${_('Action')}",sortable:false},
77 {key:"action",label:"${_('Action')}",sortable:false},
78 ];
78 ];
79
79
80 var myDataTable = new YAHOO.widget.DataTable("repos_list_wrap", myColumnDefs, myDataSource,{
80 var myDataTable = new YAHOO.widget.DataTable("repos_list_wrap", myColumnDefs, myDataSource,{
81 sortedBy:{key:"name",dir:"asc"},
81 sortedBy:{key:"name",dir:"asc"},
82 paginator: new YAHOO.widget.Paginator({
82 paginator: new YAHOO.widget.Paginator({
83 rowsPerPage: 25,
83 rowsPerPage: 25,
84 alwaysVisible: false,
84 alwaysVisible: false,
85 template : "{PreviousPageLink} {FirstPageLink} {PageLinks} {LastPageLink} {NextPageLink}",
85 template : "{PreviousPageLink} {FirstPageLink} {PageLinks} {LastPageLink} {NextPageLink}",
86 pageLinks: 5,
86 pageLinks: 5,
87 containerClass: 'pagination-wh',
87 containerClass: 'pagination-wh',
88 currentPageClass: 'pager_curpage',
88 currentPageClass: 'pager_curpage',
89 pageLinkClass: 'pager_link',
89 pageLinkClass: 'pager_link',
90 nextPageLinkLabel: '&gt;',
90 nextPageLinkLabel: '&gt;',
91 previousPageLinkLabel: '&lt;',
91 previousPageLinkLabel: '&lt;',
92 firstPageLinkLabel: '&lt;&lt;',
92 firstPageLinkLabel: '&lt;&lt;',
93 lastPageLinkLabel: '&gt;&gt;',
93 lastPageLinkLabel: '&gt;&gt;',
94 containers:['user-paginator']
94 containers:['user-paginator']
95 }),
95 }),
96
96
97 MSG_SORTASC:"${_('Click to sort ascending')}",
97 MSG_SORTASC:"${_('Click to sort ascending')}",
98 MSG_SORTDESC:"${_('Click to sort descending')}",
98 MSG_SORTDESC:"${_('Click to sort descending')}",
99 MSG_EMPTY:"${_('No records found.')}",
99 MSG_EMPTY:"${_('No records found.')}",
100 MSG_ERROR:"${_('Data error.')}",
100 MSG_ERROR:"${_('Data error.')}",
101 MSG_LOADING:"${_('Loading...')}",
101 MSG_LOADING:"${_('Loading...')}",
102 }
102 }
103 );
103 );
104 myDataTable.subscribe('postRenderEvent',function(oArgs) {
104 myDataTable.subscribe('postRenderEvent',function(oArgs) {
105 tooltip_activate();
105 tooltip_activate();
106 quick_repo_menu();
106 quick_repo_menu();
107 });
107 });
108
108
109 var filterTimeout = null;
109 var filterTimeout = null;
110
110
111 updateFilter = function () {
111 updateFilter = function () {
112 // Reset timeout
112 // Reset timeout
113 filterTimeout = null;
113 filterTimeout = null;
114
114
115 // Reset sort
115 // Reset sort
116 var state = myDataTable.getState();
116 var state = myDataTable.getState();
117 state.sortedBy = {key:'name', dir:YAHOO.widget.DataTable.CLASS_ASC};
117 state.sortedBy = {key:'name', dir:YAHOO.widget.DataTable.CLASS_ASC};
118
118
119 // Get filtered data
119 // Get filtered data
120 myDataSource.sendRequest(YUD.get('q_filter').value,{
120 myDataSource.sendRequest(YUD.get('q_filter').value,{
121 success : myDataTable.onDataReturnInitializeTable,
121 success : myDataTable.onDataReturnInitializeTable,
122 failure : myDataTable.onDataReturnInitializeTable,
122 failure : myDataTable.onDataReturnInitializeTable,
123 scope : myDataTable,
123 scope : myDataTable,
124 argument: state
124 argument: state
125 });
125 });
126
126
127 };
127 };
128 YUE.on('q_filter','click',function(){
128 YUE.on('q_filter','click',function(){
129 if(!YUD.hasClass('q_filter', 'loaded')){
129 if(!YUD.hasClass('q_filter', 'loaded')){
130 YUD.get('q_filter').value = '';
131 //TODO: load here full list later to do search within groups
130 //TODO: load here full list later to do search within groups
132 YUD.addClass('q_filter', 'loaded');
131 YUD.addClass('q_filter', 'loaded');
133 }
132 }
134 });
133 });
135
134
136 YUE.on('q_filter','keyup',function (e) {
135 YUE.on('q_filter','keyup',function (e) {
137 clearTimeout(filterTimeout);
136 clearTimeout(filterTimeout);
138 filterTimeout = setTimeout(updateFilter,600);
137 filterTimeout = setTimeout(updateFilter,600);
139 });
138 });
140 </script>
139 </script>
141
140
142 </%def>
141 </%def>
@@ -1,284 +1,283 b''
1 ## -*- coding: utf-8 -*-
1 ## -*- coding: utf-8 -*-
2 <%inherit file="/base/base.html"/>
2 <%inherit file="/base/base.html"/>
3
3
4 <%def name="title()">
4 <%def name="title()">
5 ${_('My account')} ${c.rhodecode_user.username} &middot; ${c.rhodecode_name}
5 ${_('My account')} ${c.rhodecode_user.username} &middot; ${c.rhodecode_name}
6 </%def>
6 </%def>
7
7
8 <%def name="breadcrumbs_links()">
8 <%def name="breadcrumbs_links()">
9 ${_('My Account')}
9 ${_('My Account')}
10 </%def>
10 </%def>
11
11
12 <%def name="page_nav()">
12 <%def name="page_nav()">
13 ${self.menu('admin')}
13 ${self.menu('admin')}
14 </%def>
14 </%def>
15
15
16 <%def name="main()">
16 <%def name="main()">
17
17
18 <div class="box box-left">
18 <div class="box box-left">
19 <!-- box / title -->
19 <!-- box / title -->
20 <div class="title">
20 <div class="title">
21 ${self.breadcrumbs()}
21 ${self.breadcrumbs()}
22 </div>
22 </div>
23 <!-- end box / title -->
23 <!-- end box / title -->
24 ${c.form|n}
24 ${c.form|n}
25 </div>
25 </div>
26
26
27 <div class="box box-right">
27 <div class="box box-right">
28 <!-- box / title -->
28 <!-- box / title -->
29 <div class="title">
29 <div class="title">
30 <h5>
30 <h5>
31 <input class="q_filter_box" id="q_filter" size="15" type="text" name="filter" value="${_('quick filter...')}" style="display: none"/>
31 <input class="q_filter_box" id="q_filter" size="15" type="text" name="filter" placeholder="${_('quick filter...')}" value="" style="display: none"/>
32 </h5>
32 </h5>
33 <ul class="links" style="color:#DADADA">
33 <ul class="links" style="color:#DADADA">
34 <li>
34 <li>
35 <span><a id="show_perms" class="link-white current" href="#perms">${_('My permissions')}</a> </span>
35 <span><a id="show_perms" class="link-white current" href="#perms">${_('My permissions')}</a> </span>
36 </li>
36 </li>
37 <li>
37 <li>
38 <span><a id="show_my" class="link-white" href="#my">${_('My repos')}</a> </span>
38 <span><a id="show_my" class="link-white" href="#my">${_('My repos')}</a> </span>
39 </li>
39 </li>
40 <li>
40 <li>
41 <span><a id="show_pullrequests" class="link-white" href="#pullrequests">${_('My pull requests')}</a> </span>
41 <span><a id="show_pullrequests" class="link-white" href="#pullrequests">${_('My pull requests')}</a> </span>
42 </li>
42 </li>
43 </ul>
43 </ul>
44 </div>
44 </div>
45 <!-- end box / title -->
45 <!-- end box / title -->
46 <div id="perms_container">
46 <div id="perms_container">
47 <div id="perms" class="table">
47 <div id="perms" class="table">
48 %for section in sorted(c.rhodecode_user.permissions.keys()):
48 %for section in sorted(c.rhodecode_user.permissions.keys()):
49 <div class="perms_section_head">${section.replace("_"," ").capitalize()}</div>
49 <div class="perms_section_head">${section.replace("_"," ").capitalize()}</div>
50
50
51 <div id='tbl_list_wrap_${section}' class="yui-skin-sam">
51 <div id='tbl_list_wrap_${section}' class="yui-skin-sam">
52 <table id="tbl_list_${section}">
52 <table id="tbl_list_${section}">
53 <thead>
53 <thead>
54 <tr>
54 <tr>
55 <th class="left">${_('Name')}</th>
55 <th class="left">${_('Name')}</th>
56 <th class="left">${_('Permission')}</th>
56 <th class="left">${_('Permission')}</th>
57 </thead>
57 </thead>
58 <tbody>
58 <tbody>
59 %for k in sorted(c.rhodecode_user.permissions[section], key=lambda s: s.lower):
59 %for k in sorted(c.rhodecode_user.permissions[section], key=lambda s: s.lower):
60 <%
60 <%
61 if section != 'global':
61 if section != 'global':
62 section_perm = c.rhodecode_user.permissions[section].get(k)
62 section_perm = c.rhodecode_user.permissions[section].get(k)
63 _perm = section_perm.split('.')[-1]
63 _perm = section_perm.split('.')[-1]
64 else:
64 else:
65 _perm = section_perm = None
65 _perm = section_perm = None
66 %>
66 %>
67 %if _perm not in ['none']:
67 %if _perm not in ['none']:
68 <tr>
68 <tr>
69 <td>
69 <td>
70 %if section == 'repositories':
70 %if section == 'repositories':
71 <a href="${h.url('summary_home',repo_name=k)}">${k}</a>
71 <a href="${h.url('summary_home',repo_name=k)}">${k}</a>
72 %elif section == 'repositories_groups':
72 %elif section == 'repositories_groups':
73 <a href="${h.url('repos_group_home',group_name=k)}">${k}</a>
73 <a href="${h.url('repos_group_home',group_name=k)}">${k}</a>
74 %else:
74 %else:
75 ${k}
75 ${k}
76 %endif
76 %endif
77 </td>
77 </td>
78 <td>
78 <td>
79 %if section == 'global':
79 %if section == 'global':
80 ${h.boolicon(True)}
80 ${h.boolicon(True)}
81 %else:
81 %else:
82 <span class="perm_tag ${_perm}">${section_perm}</span>
82 <span class="perm_tag ${_perm}">${section_perm}</span>
83 %endif
83 %endif
84 </td>
84 </td>
85 </tr>
85 </tr>
86 %endif
86 %endif
87 %endfor
87 %endfor
88 </tbody>
88 </tbody>
89 </table>
89 </table>
90 </div>
90 </div>
91 %endfor
91 %endfor
92 </div>
92 </div>
93 </div>
93 </div>
94 <div id="my_container" style="display:none">
94 <div id="my_container" style="display:none">
95 <div class="table yui-skin-sam" id="repos_list_wrap"></div>
95 <div class="table yui-skin-sam" id="repos_list_wrap"></div>
96 <div id="user-paginator" style="padding: 0px 0px 0px 20px"></div>
96 <div id="user-paginator" style="padding: 0px 0px 0px 20px"></div>
97 </div>
97 </div>
98 <div id="pullrequests_container" class="table" style="display:none">
98 <div id="pullrequests_container" class="table" style="display:none">
99 ## loaded via AJAX
99 ## loaded via AJAX
100 ${_('Loading...')}
100 ${_('Loading...')}
101 </div>
101 </div>
102 </div>
102 </div>
103
103
104 <script type="text/javascript">
104 <script type="text/javascript">
105 pyroutes.register('admin_settings_my_pullrequests', "${url('admin_settings_my_pullrequests')}", []);
105 pyroutes.register('admin_settings_my_pullrequests', "${url('admin_settings_my_pullrequests')}", []);
106
106
107 var show_perms = function(e){
107 var show_perms = function(e){
108 YUD.addClass('show_perms', 'current');
108 YUD.addClass('show_perms', 'current');
109 YUD.removeClass('show_my','current');
109 YUD.removeClass('show_my','current');
110 YUD.removeClass('show_pullrequests','current');
110 YUD.removeClass('show_pullrequests','current');
111
111
112 YUD.setStyle('my_container','display','none');
112 YUD.setStyle('my_container','display','none');
113 YUD.setStyle('pullrequests_container','display','none');
113 YUD.setStyle('pullrequests_container','display','none');
114 YUD.setStyle('perms_container','display','');
114 YUD.setStyle('perms_container','display','');
115 YUD.setStyle('q_filter','display','none');
115 YUD.setStyle('q_filter','display','none');
116 }
116 }
117 YUE.on('show_perms','click',function(e){
117 YUE.on('show_perms','click',function(e){
118 show_perms();
118 show_perms();
119 })
119 })
120
120
121 var show_my = function(e){
121 var show_my = function(e){
122 YUD.addClass('show_my', 'current');
122 YUD.addClass('show_my', 'current');
123 YUD.removeClass('show_perms','current');
123 YUD.removeClass('show_perms','current');
124 YUD.removeClass('show_pullrequests','current');
124 YUD.removeClass('show_pullrequests','current');
125
125
126 YUD.setStyle('perms_container','display','none');
126 YUD.setStyle('perms_container','display','none');
127 YUD.setStyle('pullrequests_container','display','none');
127 YUD.setStyle('pullrequests_container','display','none');
128 YUD.setStyle('my_container','display','');
128 YUD.setStyle('my_container','display','');
129 YUD.setStyle('q_filter','display','');
129 YUD.setStyle('q_filter','display','');
130 if(!YUD.hasClass('show_my', 'loaded')){
130 if(!YUD.hasClass('show_my', 'loaded')){
131 table_renderer(${c.data |n});
131 table_renderer(${c.data |n});
132 YUD.addClass('show_my', 'loaded');
132 YUD.addClass('show_my', 'loaded');
133 }
133 }
134 }
134 }
135 YUE.on('show_my','click',function(e){
135 YUE.on('show_my','click',function(e){
136 show_my(e);
136 show_my(e);
137 })
137 })
138
138
139 var show_pullrequests = function(e){
139 var show_pullrequests = function(e){
140 YUD.addClass('show_pullrequests', 'current');
140 YUD.addClass('show_pullrequests', 'current');
141 YUD.removeClass('show_my','current');
141 YUD.removeClass('show_my','current');
142 YUD.removeClass('show_perms','current');
142 YUD.removeClass('show_perms','current');
143
143
144 YUD.setStyle('my_container','display','none');
144 YUD.setStyle('my_container','display','none');
145 YUD.setStyle('perms_container','display','none');
145 YUD.setStyle('perms_container','display','none');
146 YUD.setStyle('pullrequests_container','display','');
146 YUD.setStyle('pullrequests_container','display','');
147 YUD.setStyle('q_filter','display','none');
147 YUD.setStyle('q_filter','display','none');
148
148
149 var url = pyroutes.url('admin_settings_my_pullrequests');
149 var url = pyroutes.url('admin_settings_my_pullrequests');
150 if(YUD.get('show_closed') && YUD.get('show_closed').checked) {
150 if(YUD.get('show_closed') && YUD.get('show_closed').checked) {
151 var url = pyroutes.url('admin_settings_my_pullrequests', {'pr_show_closed': '1'});
151 var url = pyroutes.url('admin_settings_my_pullrequests', {'pr_show_closed': '1'});
152 }
152 }
153 ypjax(url, 'pullrequests_container', function(){
153 ypjax(url, 'pullrequests_container', function(){
154 YUE.on('show_closed','change',function (e) {
154 YUE.on('show_closed','change',function (e) {
155 show_pullrequests(e);
155 show_pullrequests(e);
156 });
156 });
157 });
157 });
158 }
158 }
159 YUE.on('show_pullrequests','click',function(e){
159 YUE.on('show_pullrequests','click',function(e){
160 show_pullrequests(e)
160 show_pullrequests(e)
161 })
161 })
162
162
163 var tabs = {
163 var tabs = {
164 'perms': show_perms,
164 'perms': show_perms,
165 'my': show_my,
165 'my': show_my,
166 'pullrequests': show_pullrequests
166 'pullrequests': show_pullrequests
167 }
167 }
168 var url = location.href.split('#');
168 var url = location.href.split('#');
169 if (url[1]) {
169 if (url[1]) {
170 //We have a hash
170 //We have a hash
171 var tabHash = url[1];
171 var tabHash = url[1];
172 var func = tabs[tabHash]
172 var func = tabs[tabHash]
173 if (func){
173 if (func){
174 func();
174 func();
175 }
175 }
176 }
176 }
177
177
178 function table_renderer(data){
178 function table_renderer(data){
179 var myDataSource = new YAHOO.util.DataSource(data);
179 var myDataSource = new YAHOO.util.DataSource(data);
180 myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
180 myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
181
181
182 myDataSource.responseSchema = {
182 myDataSource.responseSchema = {
183 resultsList: "records",
183 resultsList: "records",
184 fields: [
184 fields: [
185 {key:"menu"},
185 {key:"menu"},
186 {key:"raw_name"},
186 {key:"raw_name"},
187 {key:"name"},
187 {key:"name"},
188 {key:"last_changeset"},
188 {key:"last_changeset"},
189 {key:"action"},
189 {key:"action"},
190 ]
190 ]
191 };
191 };
192 myDataSource.doBeforeCallback = function(req,raw,res,cb) {
192 myDataSource.doBeforeCallback = function(req,raw,res,cb) {
193 // This is the filter function
193 // This is the filter function
194 var data = res.results || [],
194 var data = res.results || [],
195 filtered = [],
195 filtered = [],
196 i,l;
196 i,l;
197
197
198 if (req) {
198 if (req) {
199 req = req.toLowerCase();
199 req = req.toLowerCase();
200 for (i = 0; i<data.length; i++) {
200 for (i = 0; i<data.length; i++) {
201 var pos = data[i].raw_name.toLowerCase().indexOf(req)
201 var pos = data[i].raw_name.toLowerCase().indexOf(req)
202 if (pos != -1) {
202 if (pos != -1) {
203 filtered.push(data[i]);
203 filtered.push(data[i]);
204 }
204 }
205 }
205 }
206 res.results = filtered;
206 res.results = filtered;
207 }
207 }
208 return res;
208 return res;
209 }
209 }
210
210
211 // main table sorting
211 // main table sorting
212 var myColumnDefs = [
212 var myColumnDefs = [
213 {key:"menu",label:"",sortable:false,className:"quick_repo_menu hidden"},
213 {key:"menu",label:"",sortable:false,className:"quick_repo_menu hidden"},
214 {key:"name",label:"${_('Name')}",sortable:true,
214 {key:"name",label:"${_('Name')}",sortable:true,
215 sortOptions: { sortFunction: nameSort }},
215 sortOptions: { sortFunction: nameSort }},
216 {key:"last_changeset",label:"${_('Tip')}",sortable:true,
216 {key:"last_changeset",label:"${_('Tip')}",sortable:true,
217 sortOptions: { sortFunction: revisionSort }},
217 sortOptions: { sortFunction: revisionSort }},
218 {key:"action",label:"${_('Action')}",sortable:false},
218 {key:"action",label:"${_('Action')}",sortable:false},
219 ];
219 ];
220
220
221 var myDataTable = new YAHOO.widget.DataTable("repos_list_wrap", myColumnDefs, myDataSource,{
221 var myDataTable = new YAHOO.widget.DataTable("repos_list_wrap", myColumnDefs, myDataSource,{
222 sortedBy:{key:"name",dir:"asc"},
222 sortedBy:{key:"name",dir:"asc"},
223 paginator: new YAHOO.widget.Paginator({
223 paginator: new YAHOO.widget.Paginator({
224 rowsPerPage: 50,
224 rowsPerPage: 50,
225 alwaysVisible: false,
225 alwaysVisible: false,
226 template : "{PreviousPageLink} {FirstPageLink} {PageLinks} {LastPageLink} {NextPageLink}",
226 template : "{PreviousPageLink} {FirstPageLink} {PageLinks} {LastPageLink} {NextPageLink}",
227 pageLinks: 5,
227 pageLinks: 5,
228 containerClass: 'pagination-wh',
228 containerClass: 'pagination-wh',
229 currentPageClass: 'pager_curpage',
229 currentPageClass: 'pager_curpage',
230 pageLinkClass: 'pager_link',
230 pageLinkClass: 'pager_link',
231 nextPageLinkLabel: '&gt;',
231 nextPageLinkLabel: '&gt;',
232 previousPageLinkLabel: '&lt;',
232 previousPageLinkLabel: '&lt;',
233 firstPageLinkLabel: '&lt;&lt;',
233 firstPageLinkLabel: '&lt;&lt;',
234 lastPageLinkLabel: '&gt;&gt;',
234 lastPageLinkLabel: '&gt;&gt;',
235 containers:['user-paginator']
235 containers:['user-paginator']
236 }),
236 }),
237
237
238 MSG_SORTASC:"${_('Click to sort ascending')}",
238 MSG_SORTASC:"${_('Click to sort ascending')}",
239 MSG_SORTDESC:"${_('Click to sort descending')}",
239 MSG_SORTDESC:"${_('Click to sort descending')}",
240 MSG_EMPTY:"${_('No records found.')}",
240 MSG_EMPTY:"${_('No records found.')}",
241 MSG_ERROR:"${_('Data error.')}",
241 MSG_ERROR:"${_('Data error.')}",
242 MSG_LOADING:"${_('Loading...')}",
242 MSG_LOADING:"${_('Loading...')}",
243 }
243 }
244 );
244 );
245 myDataTable.subscribe('postRenderEvent',function(oArgs) {
245 myDataTable.subscribe('postRenderEvent',function(oArgs) {
246 tooltip_activate();
246 tooltip_activate();
247 quick_repo_menu();
247 quick_repo_menu();
248 });
248 });
249
249
250 var filterTimeout = null;
250 var filterTimeout = null;
251
251
252 updateFilter = function() {
252 updateFilter = function() {
253 // Reset timeout
253 // Reset timeout
254 filterTimeout = null;
254 filterTimeout = null;
255
255
256 // Reset sort
256 // Reset sort
257 var state = myDataTable.getState();
257 var state = myDataTable.getState();
258 state.sortedBy = {key:'name', dir:YAHOO.widget.DataTable.CLASS_ASC};
258 state.sortedBy = {key:'name', dir:YAHOO.widget.DataTable.CLASS_ASC};
259
259
260 // Get filtered data
260 // Get filtered data
261 myDataSource.sendRequest(YUD.get('q_filter').value,{
261 myDataSource.sendRequest(YUD.get('q_filter').value,{
262 success : myDataTable.onDataReturnInitializeTable,
262 success : myDataTable.onDataReturnInitializeTable,
263 failure : myDataTable.onDataReturnInitializeTable,
263 failure : myDataTable.onDataReturnInitializeTable,
264 scope : myDataTable,
264 scope : myDataTable,
265 argument: state
265 argument: state
266 });
266 });
267
267
268 };
268 };
269 YUE.on('q_filter','click',function(){
269 YUE.on('q_filter','click',function(){
270 if(!YUD.hasClass('q_filter', 'loaded')){
270 if(!YUD.hasClass('q_filter', 'loaded')){
271 YUD.get('q_filter').value = '';
272 //TODO: load here full list later to do search within groups
271 //TODO: load here full list later to do search within groups
273 YUD.addClass('q_filter', 'loaded');
272 YUD.addClass('q_filter', 'loaded');
274 }
273 }
275 });
274 });
276
275
277 YUE.on('q_filter','keyup',function (e) {
276 YUE.on('q_filter','keyup',function (e) {
278 clearTimeout(filterTimeout);
277 clearTimeout(filterTimeout);
279 filterTimeout = setTimeout(updateFilter,600);
278 filterTimeout = setTimeout(updateFilter,600);
280 });
279 });
281
280
282 }
281 }
283 </script>
282 </script>
284 </%def>
283 </%def>
@@ -1,147 +1,144 b''
1 ## -*- coding: utf-8 -*-
1 ## -*- coding: utf-8 -*-
2 <%inherit file="/base/base.html"/>
2 <%inherit file="/base/base.html"/>
3
3
4 <%def name="title()">
4 <%def name="title()">
5 ${_('Users administration')} &middot; ${c.rhodecode_name}
5 ${_('Users administration')} &middot; ${c.rhodecode_name}
6 </%def>
6 </%def>
7
7
8 <%def name="breadcrumbs_links()">
8 <%def name="breadcrumbs_links()">
9 <input class="q_filter_box" id="q_filter" size="15" type="text" name="filter" value="${_('quick filter...')}"/> ${h.link_to(_('Admin'),h.url('admin_home'))} &raquo; <span id="user_count">0</span> ${_('users')}
9 <input class="q_filter_box" id="q_filter" size="15" type="text" name="filter" placeholder="${_('quick filter...')}" value=""/> ${h.link_to(_('Admin'),h.url('admin_home'))} &raquo; <span id="user_count">0</span> ${_('users')}
10 </%def>
10 </%def>
11
11
12 <%def name="page_nav()">
12 <%def name="page_nav()">
13 ${self.menu('admin')}
13 ${self.menu('admin')}
14 </%def>
14 </%def>
15
15
16 <%def name="main()">
16 <%def name="main()">
17 <div class="box">
17 <div class="box">
18 <!-- box / title -->
18 <!-- box / title -->
19 <div class="title">
19 <div class="title">
20 ${self.breadcrumbs()}
20 ${self.breadcrumbs()}
21 <ul class="links">
21 <ul class="links">
22 <li>
22 <li>
23 <span>${h.link_to(_(u'Add new user'),h.url('new_user'))}</span>
23 <span>${h.link_to(_(u'Add new user'),h.url('new_user'))}</span>
24 </li>
24 </li>
25 </ul>
25 </ul>
26 </div>
26 </div>
27 <!-- end box / title -->
27 <!-- end box / title -->
28 <div class="table yui-skin-sam" id="users_list_wrap"></div>
28 <div class="table yui-skin-sam" id="users_list_wrap"></div>
29 <div id="user-paginator" style="padding: 0px 0px 0px 20px"></div>
29 <div id="user-paginator" style="padding: 0px 0px 0px 20px"></div>
30 </div>
30 </div>
31
31
32 <script>
32 <script>
33 var url = "${h.url('formatted_users', format='json')}";
33 var url = "${h.url('formatted_users', format='json')}";
34 var data = ${c.data|n};
34 var data = ${c.data|n};
35 var myDataSource = new YAHOO.util.DataSource(data);
35 var myDataSource = new YAHOO.util.DataSource(data);
36 myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
36 myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
37
37
38 myDataSource.responseSchema = {
38 myDataSource.responseSchema = {
39 resultsList: "records",
39 resultsList: "records",
40 fields: [
40 fields: [
41 {key: "gravatar"},
41 {key: "gravatar"},
42 {key: "raw_username"},
42 {key: "raw_username"},
43 {key: "username"},
43 {key: "username"},
44 {key: "firstname"},
44 {key: "firstname"},
45 {key: "lastname"},
45 {key: "lastname"},
46 {key: "last_login"},
46 {key: "last_login"},
47 {key: "last_login_raw"},
47 {key: "last_login_raw"},
48 {key: "active"},
48 {key: "active"},
49 {key: "admin"},
49 {key: "admin"},
50 {key: "ldap"},
50 {key: "ldap"},
51 {key: "action"},
51 {key: "action"},
52 ]
52 ]
53 };
53 };
54 myDataSource.doBeforeCallback = function(req,raw,res,cb) {
54 myDataSource.doBeforeCallback = function(req,raw,res,cb) {
55 // This is the filter function
55 // This is the filter function
56 var data = res.results || [],
56 var data = res.results || [],
57 filtered = [],
57 filtered = [],
58 i,l;
58 i,l;
59
59
60 if (req) {
60 if (req) {
61 req = req.toLowerCase();
61 req = req.toLowerCase();
62 for (i = 0; i<data.length; i++) {
62 for (i = 0; i<data.length; i++) {
63 var pos = data[i].raw_username.toLowerCase().indexOf(req)
63 var pos = data[i].raw_username.toLowerCase().indexOf(req)
64 if (pos != -1) {
64 if (pos != -1) {
65 filtered.push(data[i]);
65 filtered.push(data[i]);
66 }
66 }
67 }
67 }
68 res.results = filtered;
68 res.results = filtered;
69 }
69 }
70 YUD.get('user_count').innerHTML = res.results.length;
70 YUD.get('user_count').innerHTML = res.results.length;
71 return res;
71 return res;
72 }
72 }
73
73
74 // main table sorting
74 // main table sorting
75 var myColumnDefs = [
75 var myColumnDefs = [
76 {key:"gravatar",label:"",sortable:false,},
76 {key:"gravatar",label:"",sortable:false,},
77 {key:"username",label:"${_('Username')}",sortable:true,
77 {key:"username",label:"${_('Username')}",sortable:true,
78 sortOptions: { sortFunction: usernamelinkSort }
78 sortOptions: { sortFunction: usernamelinkSort }
79 },
79 },
80 {key:"firstname",label:"${_('Firstname')}",sortable:true,},
80 {key:"firstname",label:"${_('Firstname')}",sortable:true,},
81 {key:"lastname",label:"${_('Lastname')}",sortable:true,},
81 {key:"lastname",label:"${_('Lastname')}",sortable:true,},
82 {key:"last_login",label:"${_('Last login')}",sortable:true,
82 {key:"last_login",label:"${_('Last login')}",sortable:true,
83 sortOptions: { sortFunction: lastLoginSort }},
83 sortOptions: { sortFunction: lastLoginSort }},
84 {key:"active",label:"${_('Active')}",sortable:true,},
84 {key:"active",label:"${_('Active')}",sortable:true,},
85 {key:"admin",label:"${_('Admin')}",sortable:true,},
85 {key:"admin",label:"${_('Admin')}",sortable:true,},
86 {key:"ldap",label:"${_('LDAP')}",sortable:true,},
86 {key:"ldap",label:"${_('LDAP')}",sortable:true,},
87 {key:"action",label:"${_('Action')}",sortable:false},
87 {key:"action",label:"${_('Action')}",sortable:false},
88 ];
88 ];
89
89
90 var myDataTable = new YAHOO.widget.DataTable("users_list_wrap", myColumnDefs, myDataSource,{
90 var myDataTable = new YAHOO.widget.DataTable("users_list_wrap", myColumnDefs, myDataSource,{
91 sortedBy:{key:"username",dir:"asc"},
91 sortedBy:{key:"username",dir:"asc"},
92 paginator: new YAHOO.widget.Paginator({
92 paginator: new YAHOO.widget.Paginator({
93 rowsPerPage: 15,
93 rowsPerPage: 15,
94 alwaysVisible: false,
94 alwaysVisible: false,
95 template : "{PreviousPageLink} {FirstPageLink} {PageLinks} {LastPageLink} {NextPageLink}",
95 template : "{PreviousPageLink} {FirstPageLink} {PageLinks} {LastPageLink} {NextPageLink}",
96 pageLinks: 5,
96 pageLinks: 5,
97 containerClass: 'pagination-wh',
97 containerClass: 'pagination-wh',
98 currentPageClass: 'pager_curpage',
98 currentPageClass: 'pager_curpage',
99 pageLinkClass: 'pager_link',
99 pageLinkClass: 'pager_link',
100 nextPageLinkLabel: '&gt;',
100 nextPageLinkLabel: '&gt;',
101 previousPageLinkLabel: '&lt;',
101 previousPageLinkLabel: '&lt;',
102 firstPageLinkLabel: '&lt;&lt;',
102 firstPageLinkLabel: '&lt;&lt;',
103 lastPageLinkLabel: '&gt;&gt;',
103 lastPageLinkLabel: '&gt;&gt;',
104 containers:['user-paginator']
104 containers:['user-paginator']
105 }),
105 }),
106
106
107 MSG_SORTASC:"${_('Click to sort ascending')}",
107 MSG_SORTASC:"${_('Click to sort ascending')}",
108 MSG_SORTDESC:"${_('Click to sort descending')}",
108 MSG_SORTDESC:"${_('Click to sort descending')}",
109 MSG_EMPTY:"${_('No records found.')}",
109 MSG_EMPTY:"${_('No records found.')}",
110 MSG_ERROR:"${_('Data error.')}",
110 MSG_ERROR:"${_('Data error.')}",
111 MSG_LOADING:"${_('Loading...')}",
111 MSG_LOADING:"${_('Loading...')}",
112 }
112 }
113 );
113 );
114 myDataTable.subscribe('postRenderEvent',function(oArgs) {
114 myDataTable.subscribe('postRenderEvent',function(oArgs) {
115
115
116 });
116 });
117
117
118 var filterTimeout = null;
118 var filterTimeout = null;
119
119
120 updateFilter = function () {
120 updateFilter = function () {
121 // Reset timeout
121 // Reset timeout
122 filterTimeout = null;
122 filterTimeout = null;
123
123
124 // Reset sort
124 // Reset sort
125 var state = myDataTable.getState();
125 var state = myDataTable.getState();
126 state.sortedBy = {key:'username', dir:YAHOO.widget.DataTable.CLASS_ASC};
126 state.sortedBy = {key:'username', dir:YAHOO.widget.DataTable.CLASS_ASC};
127
127
128 // Get filtered data
128 // Get filtered data
129 myDataSource.sendRequest(YUD.get('q_filter').value,{
129 myDataSource.sendRequest(YUD.get('q_filter').value,{
130 success : myDataTable.onDataReturnInitializeTable,
130 success : myDataTable.onDataReturnInitializeTable,
131 failure : myDataTable.onDataReturnInitializeTable,
131 failure : myDataTable.onDataReturnInitializeTable,
132 scope : myDataTable,
132 scope : myDataTable,
133 argument: state
133 argument: state
134 });
134 });
135
135
136 };
136 };
137 YUE.on('q_filter','click',function(){
138 YUD.get('q_filter').value = '';
139 });
140
137
141 YUE.on('q_filter','keyup',function (e) {
138 YUE.on('q_filter','keyup',function (e) {
142 clearTimeout(filterTimeout);
139 clearTimeout(filterTimeout);
143 filterTimeout = setTimeout(updateFilter,600);
140 filterTimeout = setTimeout(updateFilter,600);
144 });
141 });
145 </script>
142 </script>
146
143
147 </%def>
144 </%def>
@@ -1,76 +1,76 b''
1 ## -*- coding: utf-8 -*-
1 ## -*- coding: utf-8 -*-
2 <%inherit file="/base/base.html"/>
2 <%inherit file="/base/base.html"/>
3
3
4 <%def name="title()">
4 <%def name="title()">
5 ${_('%s Bookmarks') % c.repo_name} &middot; ${c.rhodecode_name}
5 ${_('%s Bookmarks') % c.repo_name} &middot; ${c.rhodecode_name}
6 </%def>
6 </%def>
7
7
8 <%def name="breadcrumbs_links()">
8 <%def name="breadcrumbs_links()">
9 <input class="q_filter_box" id="q_filter_bookmarks" size="15" type="text" name="filter" value="${_('quick filter...')}"/>
9 <input class="q_filter_box" id="q_filter_bookmarks" size="15" type="text" name="filter" placeholder="${_('quick filter...')}" value=""/>
10 ${_('Bookmarks')}
10 ${_('Bookmarks')}
11 </%def>
11 </%def>
12
12
13 <%def name="page_nav()">
13 <%def name="page_nav()">
14 ${self.menu('repositories')}
14 ${self.menu('repositories')}
15 </%def>
15 </%def>
16
16
17 <%def name="main()">
17 <%def name="main()">
18 ${self.context_bar('switch-to')}
18 ${self.context_bar('switch-to')}
19 <div class="box">
19 <div class="box">
20 <!-- box / title -->
20 <!-- box / title -->
21 <div class="title">
21 <div class="title">
22 ${self.breadcrumbs()}
22 ${self.breadcrumbs()}
23 </div>
23 </div>
24 <!-- end box / title -->
24 <!-- end box / title -->
25 <div class="table">
25 <div class="table">
26 <%include file='bookmarks_data.html'/>
26 <%include file='bookmarks_data.html'/>
27 </div>
27 </div>
28 </div>
28 </div>
29
29
30 <script type="text/javascript">
30 <script type="text/javascript">
31
31
32 // main table sorting
32 // main table sorting
33 var myColumnDefs = [
33 var myColumnDefs = [
34 {key:"name",label:"${_('Name')}",sortable:true},
34 {key:"name",label:"${_('Name')}",sortable:true},
35 {key:"date",label:"${_('Date')}",sortable:true,
35 {key:"date",label:"${_('Date')}",sortable:true,
36 sortOptions: { sortFunction: dateSort }},
36 sortOptions: { sortFunction: dateSort }},
37 {key:"author",label:"${_('Author')}",sortable:true},
37 {key:"author",label:"${_('Author')}",sortable:true},
38 {key:"revision",label:"${_('Revision')}",sortable:true,
38 {key:"revision",label:"${_('Revision')}",sortable:true,
39 sortOptions: { sortFunction: revisionSort }},
39 sortOptions: { sortFunction: revisionSort }},
40 ];
40 ];
41
41
42 var myDataSource = new YAHOO.util.DataSource(YUD.get("bookmarks_data"));
42 var myDataSource = new YAHOO.util.DataSource(YUD.get("bookmarks_data"));
43
43
44 myDataSource.responseType = YAHOO.util.DataSource.TYPE_HTMLTABLE;
44 myDataSource.responseType = YAHOO.util.DataSource.TYPE_HTMLTABLE;
45
45
46 myDataSource.responseSchema = {
46 myDataSource.responseSchema = {
47 fields: [
47 fields: [
48 {key:"name"},
48 {key:"name"},
49 {key:"date"},
49 {key:"date"},
50 {key:"author"},
50 {key:"author"},
51 {key:"revision"},
51 {key:"revision"},
52 ]
52 ]
53 };
53 };
54
54
55 var myDataTable = new YAHOO.widget.DataTable("table_wrap", myColumnDefs, myDataSource,
55 var myDataTable = new YAHOO.widget.DataTable("table_wrap", myColumnDefs, myDataSource,
56 {
56 {
57 sortedBy:{key:"name",dir:"asc"},
57 sortedBy:{key:"name",dir:"asc"},
58 MSG_SORTASC:"${_('Click to sort ascending')}",
58 MSG_SORTASC:"${_('Click to sort ascending')}",
59 MSG_SORTDESC:"${_('Click to sort descending')}",
59 MSG_SORTDESC:"${_('Click to sort descending')}",
60 MSG_EMPTY:"${_('No records found.')}",
60 MSG_EMPTY:"${_('No records found.')}",
61 MSG_ERROR:"${_('Data error.')}",
61 MSG_ERROR:"${_('Data error.')}",
62 MSG_LOADING:"${_('Loading...')}",
62 MSG_LOADING:"${_('Loading...')}",
63 }
63 }
64 );
64 );
65 myDataTable.subscribe('postRenderEvent',function(oArgs) {
65 myDataTable.subscribe('postRenderEvent',function(oArgs) {
66 tooltip_activate();
66 tooltip_activate();
67 var func = function(node){
67 var func = function(node){
68 return node.parentNode.parentNode.parentNode.parentNode.parentNode;
68 return node.parentNode.parentNode.parentNode.parentNode.parentNode;
69 }
69 }
70 q_filter('q_filter_bookmarks',YUQ('div.table tr td .logbooks .bookbook a'),func);
70 q_filter('q_filter_bookmarks',YUQ('div.table tr td .logbooks .bookbook a'),func);
71 });
71 });
72
72
73 </script>
73 </script>
74
74
75
75
76 </%def>
76 </%def>
@@ -1,90 +1,90 b''
1 ## -*- coding: utf-8 -*-
1 ## -*- coding: utf-8 -*-
2 <%inherit file="/base/base.html"/>
2 <%inherit file="/base/base.html"/>
3
3
4 <%def name="title()">
4 <%def name="title()">
5 ${_('%s Branches') % c.repo_name} &middot; ${c.rhodecode_name}
5 ${_('%s Branches') % c.repo_name} &middot; ${c.rhodecode_name}
6 </%def>
6 </%def>
7
7
8 <%def name="breadcrumbs_links()">
8 <%def name="breadcrumbs_links()">
9 <input class="q_filter_box" id="q_filter_branches" size="15" type="text" name="filter" value="${_('quick filter...')}"/>
9 <input class="q_filter_box" id="q_filter_branches" size="15" type="text" name="filter" placeholder="${_('quick filter...')}" value=""/>
10 ${_('Branches')}
10 ${_('Branches')}
11 </%def>
11 </%def>
12
12
13 <%def name="page_nav()">
13 <%def name="page_nav()">
14 ${self.menu('repositories')}
14 ${self.menu('repositories')}
15 </%def>
15 </%def>
16
16
17 <%def name="main()">
17 <%def name="main()">
18 ${self.context_bar('switch-to')}
18 ${self.context_bar('switch-to')}
19 <div class="box">
19 <div class="box">
20 <!-- box / title -->
20 <!-- box / title -->
21 <div class="title">
21 <div class="title">
22 ${self.breadcrumbs()}
22 ${self.breadcrumbs()}
23 </div>
23 </div>
24 <!-- end box / title -->
24 <!-- end box / title -->
25 %if c.repo_branches:
25 %if c.repo_branches:
26 <div class="info_box" id="compare_branches" style="clear: both;padding: 10px 19px;text-align: right;"><a href="#" class="ui-btn small">${_('Compare branches')}</a></div>
26 <div class="info_box" id="compare_branches" style="clear: both;padding: 10px 19px;text-align: right;"><a href="#" class="ui-btn small">${_('Compare branches')}</a></div>
27 %endif
27 %endif
28 <div class="table">
28 <div class="table">
29 <%include file='branches_data.html'/>
29 <%include file='branches_data.html'/>
30 </div>
30 </div>
31 </div>
31 </div>
32 <script type="text/javascript">
32 <script type="text/javascript">
33 YUE.on('compare_branches','click',function(e){
33 YUE.on('compare_branches','click',function(e){
34 YUE.preventDefault(e);
34 YUE.preventDefault(e);
35 var org = YUQ('input[name=compare_org]:checked')[0];
35 var org = YUQ('input[name=compare_org]:checked')[0];
36 var other = YUQ('input[name=compare_other]:checked')[0];
36 var other = YUQ('input[name=compare_other]:checked')[0];
37
37
38 if(org && other){
38 if(org && other){
39 var compare_url = "${h.url('compare_url',repo_name=c.repo_name,org_ref_type='branch',org_ref='__ORG__',other_ref_type='branch',other_ref='__OTHER__')}";
39 var compare_url = "${h.url('compare_url',repo_name=c.repo_name,org_ref_type='branch',org_ref='__ORG__',other_ref_type='branch',other_ref='__OTHER__')}";
40 var u = compare_url.replace('__ORG__',org.value)
40 var u = compare_url.replace('__ORG__',org.value)
41 .replace('__OTHER__',other.value);
41 .replace('__OTHER__',other.value);
42 window.location=u;
42 window.location=u;
43 }
43 }
44 });
44 });
45 // main table sorting
45 // main table sorting
46 var myColumnDefs = [
46 var myColumnDefs = [
47 {key:"name",label:"${_('Name')}",sortable:true},
47 {key:"name",label:"${_('Name')}",sortable:true},
48 {key:"date",label:"${_('Date')}",sortable:true,
48 {key:"date",label:"${_('Date')}",sortable:true,
49 sortOptions: { sortFunction: dateSort }},
49 sortOptions: { sortFunction: dateSort }},
50 {key:"author",label:"${_('Author')}",sortable:true},
50 {key:"author",label:"${_('Author')}",sortable:true},
51 {key:"revision",label:"${_('Revision')}",sortable:true,
51 {key:"revision",label:"${_('Revision')}",sortable:true,
52 sortOptions: { sortFunction: revisionSort }},
52 sortOptions: { sortFunction: revisionSort }},
53 {key:"compare",label:"${_('Compare')}",sortable:false,},
53 {key:"compare",label:"${_('Compare')}",sortable:false,},
54 ];
54 ];
55
55
56 var myDataSource = new YAHOO.util.DataSource(YUD.get("branches_data"));
56 var myDataSource = new YAHOO.util.DataSource(YUD.get("branches_data"));
57
57
58 myDataSource.responseType = YAHOO.util.DataSource.TYPE_HTMLTABLE;
58 myDataSource.responseType = YAHOO.util.DataSource.TYPE_HTMLTABLE;
59
59
60 myDataSource.responseSchema = {
60 myDataSource.responseSchema = {
61 fields: [
61 fields: [
62 {key:"name"},
62 {key:"name"},
63 {key:"date"},
63 {key:"date"},
64 {key:"author"},
64 {key:"author"},
65 {key:"revision"},
65 {key:"revision"},
66 {key:"compare"},
66 {key:"compare"},
67 ]
67 ]
68 };
68 };
69
69
70 var myDataTable = new YAHOO.widget.DataTable("table_wrap", myColumnDefs, myDataSource,
70 var myDataTable = new YAHOO.widget.DataTable("table_wrap", myColumnDefs, myDataSource,
71 {
71 {
72 sortedBy:{key:"name",dir:"asc"},
72 sortedBy:{key:"name",dir:"asc"},
73 MSG_SORTASC:"${_('Click to sort ascending')}",
73 MSG_SORTASC:"${_('Click to sort ascending')}",
74 MSG_SORTDESC:"${_('Click to sort descending')}",
74 MSG_SORTDESC:"${_('Click to sort descending')}",
75 MSG_EMPTY:"${_('No records found.')}",
75 MSG_EMPTY:"${_('No records found.')}",
76 MSG_ERROR:"${_('Data error.')}",
76 MSG_ERROR:"${_('Data error.')}",
77 MSG_LOADING:"${_('Loading...')}",
77 MSG_LOADING:"${_('Loading...')}",
78 }
78 }
79 );
79 );
80 myDataTable.subscribe('postRenderEvent',function(oArgs) {
80 myDataTable.subscribe('postRenderEvent',function(oArgs) {
81 tooltip_activate();
81 tooltip_activate();
82 var func = function(node){
82 var func = function(node){
83 return node.parentNode.parentNode.parentNode.parentNode.parentNode;
83 return node.parentNode.parentNode.parentNode.parentNode.parentNode;
84 }
84 }
85 q_filter('q_filter_branches',YUQ('div.table tr td .logtags .branchtag a'),func);
85 q_filter('q_filter_branches',YUQ('div.table tr td .logtags .branchtag a'),func);
86 });
86 });
87
87
88 </script>
88 </script>
89
89
90 </%def>
90 </%def>
@@ -1,340 +1,339 b''
1 <%page args="parent" />
1 <%page args="parent" />
2 <div class="box">
2 <div class="box">
3 <!-- box / title -->
3 <!-- box / title -->
4 <div class="title">
4 <div class="title">
5 <h5>
5 <h5>
6 <input class="q_filter_box" id="q_filter" size="15" type="text" name="filter" value="${_('quick filter...')}"/> ${parent.breadcrumbs()} <span id="repo_count">0</span> ${_('repositories')}
6 <input class="q_filter_box" id="q_filter" size="15" type="text" name="filter" placeholder="${_('quick filter...')}" value=""/> ${parent.breadcrumbs()} <span id="repo_count">0</span> ${_('repositories')}
7 </h5>
7 </h5>
8 %if c.rhodecode_user.username != 'default':
8 %if c.rhodecode_user.username != 'default':
9 <ul class="links">
9 <ul class="links">
10 %if h.HasPermissionAny('hg.admin','hg.create.repository')() or h.HasReposGroupPermissionAny('group.write', 'group.admin')(c.group.group_name if c.group else None):
10 %if h.HasPermissionAny('hg.admin','hg.create.repository')() or h.HasReposGroupPermissionAny('group.write', 'group.admin')(c.group.group_name if c.group else None):
11 <li>
11 <li>
12 %if c.group:
12 %if c.group:
13 <span>${h.link_to(_('Add repository'),h.url('new_repo',parent_group=c.group.group_id))}</span>
13 <span>${h.link_to(_('Add repository'),h.url('new_repo',parent_group=c.group.group_id))}</span>
14 %if h.HasPermissionAny('hg.admin')() or h.HasReposGroupPermissionAny('group.admin')(c.group.group_name):
14 %if h.HasPermissionAny('hg.admin')() or h.HasReposGroupPermissionAny('group.admin')(c.group.group_name):
15 <span>${h.link_to(_(u'Add group'),h.url('new_repos_group', parent_group=c.group.group_id))}</span>
15 <span>${h.link_to(_(u'Add group'),h.url('new_repos_group', parent_group=c.group.group_id))}</span>
16 %endif
16 %endif
17 %else:
17 %else:
18 <span>${h.link_to(_('Add repository'),h.url('new_repo'))}</span>
18 <span>${h.link_to(_('Add repository'),h.url('new_repo'))}</span>
19 %if h.HasPermissionAny('hg.admin')():
19 %if h.HasPermissionAny('hg.admin')():
20 <span>${h.link_to(_(u'Add group'),h.url('new_repos_group'))}</span>
20 <span>${h.link_to(_(u'Add group'),h.url('new_repos_group'))}</span>
21 %endif
21 %endif
22 %endif
22 %endif
23 </li>
23 </li>
24 %endif
24 %endif
25 %if c.group and h.HasReposGroupPermissionAny('group.admin')(c.group.group_name):
25 %if c.group and h.HasReposGroupPermissionAny('group.admin')(c.group.group_name):
26 <li>
26 <li>
27 <span>${h.link_to(_('Edit group'),h.url('edit_repos_group',group_name=c.group.group_name), title=_('You have admin right to this group, and can edit it'))}</span>
27 <span>${h.link_to(_('Edit group'),h.url('edit_repos_group',group_name=c.group.group_name), title=_('You have admin right to this group, and can edit it'))}</span>
28 </li>
28 </li>
29 %endif
29 %endif
30 </ul>
30 </ul>
31 %endif
31 %endif
32 </div>
32 </div>
33 <!-- end box / title -->
33 <!-- end box / title -->
34 <div class="table">
34 <div class="table">
35 % if c.groups:
35 % if c.groups:
36 <div id='groups_list_wrap' class="yui-skin-sam">
36 <div id='groups_list_wrap' class="yui-skin-sam">
37 <table id="groups_list">
37 <table id="groups_list">
38 <thead>
38 <thead>
39 <tr>
39 <tr>
40 <th class="left"><a href="#">${_('Group name')}</a></th>
40 <th class="left"><a href="#">${_('Group name')}</a></th>
41 <th class="left"><a href="#">${_('Description')}</a></th>
41 <th class="left"><a href="#">${_('Description')}</a></th>
42 ##<th class="left"><a href="#">${_('Number of repositories')}</a></th>
42 ##<th class="left"><a href="#">${_('Number of repositories')}</a></th>
43 </tr>
43 </tr>
44 </thead>
44 </thead>
45
45
46 ## REPO GROUPS
46 ## REPO GROUPS
47 % for gr in c.groups:
47 % for gr in c.groups:
48 <tr>
48 <tr>
49 <td>
49 <td>
50 <div style="white-space: nowrap">
50 <div style="white-space: nowrap">
51 <img class="icon" alt="${_('Repository group')}" src="${h.url('/images/icons/database_link.png')}"/>
51 <img class="icon" alt="${_('Repository group')}" src="${h.url('/images/icons/database_link.png')}"/>
52 ${h.link_to(gr.name,url('repos_group_home',group_name=gr.group_name))}
52 ${h.link_to(gr.name,url('repos_group_home',group_name=gr.group_name))}
53 </div>
53 </div>
54 </td>
54 </td>
55 %if c.visual.stylify_metatags:
55 %if c.visual.stylify_metatags:
56 <td>${h.urlify_text(h.desc_stylize(gr.group_description))}</td>
56 <td>${h.urlify_text(h.desc_stylize(gr.group_description))}</td>
57 %else:
57 %else:
58 <td>${gr.group_description}</td>
58 <td>${gr.group_description}</td>
59 %endif
59 %endif
60 ## this is commented out since for multi nested repos can be HEAVY!
60 ## this is commented out since for multi nested repos can be HEAVY!
61 ## in number of executed queries during traversing uncomment at will
61 ## in number of executed queries during traversing uncomment at will
62 ##<td><b>${gr.repositories_recursive_count}</b></td>
62 ##<td><b>${gr.repositories_recursive_count}</b></td>
63 </tr>
63 </tr>
64 % endfor
64 % endfor
65 </table>
65 </table>
66 </div>
66 </div>
67 <div id="group-user-paginator" style="padding: 0px 0px 0px 0px"></div>
67 <div id="group-user-paginator" style="padding: 0px 0px 0px 0px"></div>
68 <div style="height: 20px"></div>
68 <div style="height: 20px"></div>
69 % endif
69 % endif
70 <div id="welcome" style="display:none;text-align:center">
70 <div id="welcome" style="display:none;text-align:center">
71 <h1><a href="${h.url('home')}">${c.rhodecode_name} ${c.rhodecode_version}</a></h1>
71 <h1><a href="${h.url('home')}">${c.rhodecode_name} ${c.rhodecode_version}</a></h1>
72 </div>
72 </div>
73 <%cnt=0%>
73 <%cnt=0%>
74 <%namespace name="dt" file="/data_table/_dt_elements.html"/>
74 <%namespace name="dt" file="/data_table/_dt_elements.html"/>
75 % if not c.visual.lightweight_dashboard:
75 % if not c.visual.lightweight_dashboard:
76 ## old full detailed version
76 ## old full detailed version
77 <div id='repos_list_wrap' class="yui-skin-sam">
77 <div id='repos_list_wrap' class="yui-skin-sam">
78 <table id="repos_list">
78 <table id="repos_list">
79 <thead>
79 <thead>
80 <tr>
80 <tr>
81 <th class="left"></th>
81 <th class="left"></th>
82 <th class="left">${_('Name')}</th>
82 <th class="left">${_('Name')}</th>
83 <th class="left">${_('Description')}</th>
83 <th class="left">${_('Description')}</th>
84 <th class="left">${_('Last change')}</th>
84 <th class="left">${_('Last change')}</th>
85 <th class="left">${_('Tip')}</th>
85 <th class="left">${_('Tip')}</th>
86 <th class="left">${_('Owner')}</th>
86 <th class="left">${_('Owner')}</th>
87 <th class="left">${_('Atom')}</th>
87 <th class="left">${_('Atom')}</th>
88 </tr>
88 </tr>
89 </thead>
89 </thead>
90 <tbody>
90 <tbody>
91 %for cnt,repo in enumerate(c.repos_list):
91 %for cnt,repo in enumerate(c.repos_list):
92 <tr class="parity${(cnt+1)%2}">
92 <tr class="parity${(cnt+1)%2}">
93 ##QUICK MENU
93 ##QUICK MENU
94 <td class="quick_repo_menu">
94 <td class="quick_repo_menu">
95 ${dt.quick_menu(repo['name'])}
95 ${dt.quick_menu(repo['name'])}
96 </td>
96 </td>
97 ##REPO NAME AND ICONS
97 ##REPO NAME AND ICONS
98 <td class="reponame">
98 <td class="reponame">
99 ${dt.repo_name(repo['name'],repo['dbrepo']['repo_type'],repo['dbrepo']['private'],h.AttributeDict(repo['dbrepo_fork']),pageargs.get('short_repo_names'))}
99 ${dt.repo_name(repo['name'],repo['dbrepo']['repo_type'],repo['dbrepo']['private'],h.AttributeDict(repo['dbrepo_fork']),pageargs.get('short_repo_names'))}
100 </td>
100 </td>
101 ##DESCRIPTION
101 ##DESCRIPTION
102 <td><span class="tooltip" title="${h.tooltip(repo['description'])}">
102 <td><span class="tooltip" title="${h.tooltip(repo['description'])}">
103 %if c.visual.stylify_metatags:
103 %if c.visual.stylify_metatags:
104 ${h.urlify_text(h.desc_stylize(h.truncate(repo['description'],60)))}</span>
104 ${h.urlify_text(h.desc_stylize(h.truncate(repo['description'],60)))}</span>
105 %else:
105 %else:
106 ${h.truncate(repo['description'],60)}</span>
106 ${h.truncate(repo['description'],60)}</span>
107 %endif
107 %endif
108 </td>
108 </td>
109 ##LAST CHANGE DATE
109 ##LAST CHANGE DATE
110 <td>
110 <td>
111 ${dt.last_change(repo['last_change'])}
111 ${dt.last_change(repo['last_change'])}
112 </td>
112 </td>
113 ##LAST REVISION
113 ##LAST REVISION
114 <td>
114 <td>
115 ${dt.revision(repo['name'],repo['rev'],repo['tip'],repo['author'],repo['last_msg'])}
115 ${dt.revision(repo['name'],repo['rev'],repo['tip'],repo['author'],repo['last_msg'])}
116 </td>
116 </td>
117 ##
117 ##
118 <td title="${repo['contact']}">${h.person(repo['contact'])}</td>
118 <td title="${repo['contact']}">${h.person(repo['contact'])}</td>
119 <td>
119 <td>
120 ${dt.atom(repo['name'])}
120 ${dt.atom(repo['name'])}
121 </td>
121 </td>
122 </tr>
122 </tr>
123 %endfor
123 %endfor
124 </tbody>
124 </tbody>
125 </table>
125 </table>
126 </div>
126 </div>
127 % else:
127 % else:
128 ## lightweight version
128 ## lightweight version
129 <div class="yui-skin-sam" id="repos_list_wrap"></div>
129 <div class="yui-skin-sam" id="repos_list_wrap"></div>
130 <div id="user-paginator" style="padding: 0px 0px 0px 0px"></div>
130 <div id="user-paginator" style="padding: 0px 0px 0px 0px"></div>
131 % endif
131 % endif
132 </div>
132 </div>
133 </div>
133 </div>
134 % if not c.visual.lightweight_dashboard:
134 % if not c.visual.lightweight_dashboard:
135 <script>
135 <script>
136 YUD.get('repo_count').innerHTML = ${cnt+1 if cnt else 0};
136 YUD.get('repo_count').innerHTML = ${cnt+1 if cnt else 0};
137
137
138 // groups table sorting
138 // groups table sorting
139 var myColumnDefs = [
139 var myColumnDefs = [
140 {key:"name",label:"${_('Group name')}",sortable:true,
140 {key:"name",label:"${_('Group name')}",sortable:true,
141 sortOptions: { sortFunction: groupNameSort }},
141 sortOptions: { sortFunction: groupNameSort }},
142 {key:"desc",label:"${_('Description')}",sortable:true},
142 {key:"desc",label:"${_('Description')}",sortable:true},
143 ];
143 ];
144
144
145 var myDataSource = new YAHOO.util.DataSource(YUD.get("groups_list"));
145 var myDataSource = new YAHOO.util.DataSource(YUD.get("groups_list"));
146
146
147 myDataSource.responseType = YAHOO.util.DataSource.TYPE_HTMLTABLE;
147 myDataSource.responseType = YAHOO.util.DataSource.TYPE_HTMLTABLE;
148 myDataSource.responseSchema = {
148 myDataSource.responseSchema = {
149 fields: [
149 fields: [
150 {key:"name"},
150 {key:"name"},
151 {key:"desc"},
151 {key:"desc"},
152 ]
152 ]
153 };
153 };
154
154
155 var myDataTable = new YAHOO.widget.DataTable("groups_list_wrap", myColumnDefs, myDataSource,{
155 var myDataTable = new YAHOO.widget.DataTable("groups_list_wrap", myColumnDefs, myDataSource,{
156 sortedBy:{key:"name",dir:"asc"},
156 sortedBy:{key:"name",dir:"asc"},
157 paginator: new YAHOO.widget.Paginator({
157 paginator: new YAHOO.widget.Paginator({
158 rowsPerPage: 50,
158 rowsPerPage: 50,
159 alwaysVisible: false,
159 alwaysVisible: false,
160 template : "{PreviousPageLink} {FirstPageLink} {PageLinks} {LastPageLink} {NextPageLink}",
160 template : "{PreviousPageLink} {FirstPageLink} {PageLinks} {LastPageLink} {NextPageLink}",
161 pageLinks: 5,
161 pageLinks: 5,
162 containerClass: 'pagination-wh',
162 containerClass: 'pagination-wh',
163 currentPageClass: 'pager_curpage',
163 currentPageClass: 'pager_curpage',
164 pageLinkClass: 'pager_link',
164 pageLinkClass: 'pager_link',
165 nextPageLinkLabel: '&gt;',
165 nextPageLinkLabel: '&gt;',
166 previousPageLinkLabel: '&lt;',
166 previousPageLinkLabel: '&lt;',
167 firstPageLinkLabel: '&lt;&lt;',
167 firstPageLinkLabel: '&lt;&lt;',
168 lastPageLinkLabel: '&gt;&gt;',
168 lastPageLinkLabel: '&gt;&gt;',
169 containers:['group-user-paginator']
169 containers:['group-user-paginator']
170 }),
170 }),
171 MSG_SORTASC:"${_('Click to sort ascending')}",
171 MSG_SORTASC:"${_('Click to sort ascending')}",
172 MSG_SORTDESC:"${_('Click to sort descending')}"
172 MSG_SORTDESC:"${_('Click to sort descending')}"
173 });
173 });
174
174
175 // main table sorting
175 // main table sorting
176 var myColumnDefs = [
176 var myColumnDefs = [
177 {key:"menu",label:"",sortable:false,className:"quick_repo_menu hidden"},
177 {key:"menu",label:"",sortable:false,className:"quick_repo_menu hidden"},
178 {key:"name",label:"${_('Name')}",sortable:true,
178 {key:"name",label:"${_('Name')}",sortable:true,
179 sortOptions: { sortFunction: nameSort }},
179 sortOptions: { sortFunction: nameSort }},
180 {key:"desc",label:"${_('Description')}",sortable:true},
180 {key:"desc",label:"${_('Description')}",sortable:true},
181 {key:"last_change",label:"${_('Last Change')}",sortable:true,
181 {key:"last_change",label:"${_('Last Change')}",sortable:true,
182 sortOptions: { sortFunction: ageSort }},
182 sortOptions: { sortFunction: ageSort }},
183 {key:"tip",label:"${_('Tip')}",sortable:true,
183 {key:"tip",label:"${_('Tip')}",sortable:true,
184 sortOptions: { sortFunction: revisionSort }},
184 sortOptions: { sortFunction: revisionSort }},
185 {key:"owner",label:"${_('Owner')}",sortable:true},
185 {key:"owner",label:"${_('Owner')}",sortable:true},
186 {key:"atom",label:"",sortable:false},
186 {key:"atom",label:"",sortable:false},
187 ];
187 ];
188
188
189 var myDataSource = new YAHOO.util.DataSource(YUD.get("repos_list"));
189 var myDataSource = new YAHOO.util.DataSource(YUD.get("repos_list"));
190
190
191 myDataSource.responseType = YAHOO.util.DataSource.TYPE_HTMLTABLE;
191 myDataSource.responseType = YAHOO.util.DataSource.TYPE_HTMLTABLE;
192
192
193 myDataSource.responseSchema = {
193 myDataSource.responseSchema = {
194 fields: [
194 fields: [
195 {key:"menu"},
195 {key:"menu"},
196 //{key:"raw_name"},
196 //{key:"raw_name"},
197 {key:"name"},
197 {key:"name"},
198 {key:"desc"},
198 {key:"desc"},
199 {key:"last_change"},
199 {key:"last_change"},
200 {key:"tip"},
200 {key:"tip"},
201 {key:"owner"},
201 {key:"owner"},
202 {key:"atom"},
202 {key:"atom"},
203 ]
203 ]
204 };
204 };
205
205
206 var myDataTable = new YAHOO.widget.DataTable("repos_list_wrap", myColumnDefs, myDataSource,
206 var myDataTable = new YAHOO.widget.DataTable("repos_list_wrap", myColumnDefs, myDataSource,
207 {
207 {
208 sortedBy:{key:"name",dir:"asc"},
208 sortedBy:{key:"name",dir:"asc"},
209 MSG_SORTASC:"${_('Click to sort ascending')}",
209 MSG_SORTASC:"${_('Click to sort ascending')}",
210 MSG_SORTDESC:"${_('Click to sort descending')}",
210 MSG_SORTDESC:"${_('Click to sort descending')}",
211 MSG_EMPTY:"${_('No records found.')}",
211 MSG_EMPTY:"${_('No records found.')}",
212 MSG_ERROR:"${_('Data error.')}",
212 MSG_ERROR:"${_('Data error.')}",
213 MSG_LOADING:"${_('Loading...')}",
213 MSG_LOADING:"${_('Loading...')}",
214 }
214 }
215 );
215 );
216 myDataTable.subscribe('postRenderEvent',function(oArgs) {
216 myDataTable.subscribe('postRenderEvent',function(oArgs) {
217 tooltip_activate();
217 tooltip_activate();
218 quick_repo_menu();
218 quick_repo_menu();
219 var func = function(node){
219 var func = function(node){
220 return node.parentNode.parentNode.parentNode.parentNode;
220 return node.parentNode.parentNode.parentNode.parentNode;
221 }
221 }
222 q_filter('q_filter',YUQ('div.table tr td a.repo_name'),func);
222 q_filter('q_filter',YUQ('div.table tr td a.repo_name'),func);
223 });
223 });
224
224
225 </script>
225 </script>
226 % else:
226 % else:
227 <script>
227 <script>
228 var data = ${c.data|n};
228 var data = ${c.data|n};
229 var myDataSource = new YAHOO.util.DataSource(data);
229 var myDataSource = new YAHOO.util.DataSource(data);
230 myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
230 myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
231
231
232 myDataSource.responseSchema = {
232 myDataSource.responseSchema = {
233 resultsList: "records",
233 resultsList: "records",
234 fields: [
234 fields: [
235 {key:"menu"},
235 {key:"menu"},
236 {key:"raw_name"},
236 {key:"raw_name"},
237 {key:"name"},
237 {key:"name"},
238 {key:"desc"},
238 {key:"desc"},
239 {key:"last_change"},
239 {key:"last_change"},
240 {key:"last_changeset"},
240 {key:"last_changeset"},
241 {key:"owner"},
241 {key:"owner"},
242 {key:"atom"},
242 {key:"atom"},
243 ]
243 ]
244 };
244 };
245 myDataSource.doBeforeCallback = function(req,raw,res,cb) {
245 myDataSource.doBeforeCallback = function(req,raw,res,cb) {
246 // This is the filter function
246 // This is the filter function
247 var data = res.results || [],
247 var data = res.results || [],
248 filtered = [],
248 filtered = [],
249 i,l;
249 i,l;
250
250
251 if (req) {
251 if (req) {
252 req = req.toLowerCase();
252 req = req.toLowerCase();
253 for (i = 0; i<data.length; i++) {
253 for (i = 0; i<data.length; i++) {
254 var pos = data[i].raw_name.toLowerCase().indexOf(req)
254 var pos = data[i].raw_name.toLowerCase().indexOf(req)
255 if (pos != -1) {
255 if (pos != -1) {
256 filtered.push(data[i]);
256 filtered.push(data[i]);
257 }
257 }
258 }
258 }
259 res.results = filtered;
259 res.results = filtered;
260 }
260 }
261 YUD.get('repo_count').innerHTML = res.results.length;
261 YUD.get('repo_count').innerHTML = res.results.length;
262 return res;
262 return res;
263 }
263 }
264
264
265 // main table sorting
265 // main table sorting
266 var myColumnDefs = [
266 var myColumnDefs = [
267 {key:"menu",label:"",sortable:false,className:"quick_repo_menu hidden"},
267 {key:"menu",label:"",sortable:false,className:"quick_repo_menu hidden"},
268 {key:"name",label:"${_('Name')}",sortable:true,
268 {key:"name",label:"${_('Name')}",sortable:true,
269 sortOptions: { sortFunction: nameSort }},
269 sortOptions: { sortFunction: nameSort }},
270 {key:"desc",label:"${_('Description')}",sortable:true},
270 {key:"desc",label:"${_('Description')}",sortable:true},
271 {key:"last_change",label:"${_('Last Change')}",sortable:true,
271 {key:"last_change",label:"${_('Last Change')}",sortable:true,
272 sortOptions: { sortFunction: ageSort }},
272 sortOptions: { sortFunction: ageSort }},
273 {key:"last_changeset",label:"${_('Tip')}",sortable:true,
273 {key:"last_changeset",label:"${_('Tip')}",sortable:true,
274 sortOptions: { sortFunction: revisionSort }},
274 sortOptions: { sortFunction: revisionSort }},
275 {key:"owner",label:"${_('Owner')}",sortable:true},
275 {key:"owner",label:"${_('Owner')}",sortable:true},
276 {key:"atom",label:"",sortable:false},
276 {key:"atom",label:"",sortable:false},
277 ];
277 ];
278
278
279 var myDataTable = new YAHOO.widget.DataTable("repos_list_wrap", myColumnDefs, myDataSource,{
279 var myDataTable = new YAHOO.widget.DataTable("repos_list_wrap", myColumnDefs, myDataSource,{
280 sortedBy:{key:"name",dir:"asc"},
280 sortedBy:{key:"name",dir:"asc"},
281 paginator: new YAHOO.widget.Paginator({
281 paginator: new YAHOO.widget.Paginator({
282 rowsPerPage: ${c.visual.lightweight_dashboard_items},
282 rowsPerPage: ${c.visual.lightweight_dashboard_items},
283 alwaysVisible: false,
283 alwaysVisible: false,
284 template : "{PreviousPageLink} {FirstPageLink} {PageLinks} {LastPageLink} {NextPageLink}",
284 template : "{PreviousPageLink} {FirstPageLink} {PageLinks} {LastPageLink} {NextPageLink}",
285 pageLinks: 5,
285 pageLinks: 5,
286 containerClass: 'pagination-wh',
286 containerClass: 'pagination-wh',
287 currentPageClass: 'pager_curpage',
287 currentPageClass: 'pager_curpage',
288 pageLinkClass: 'pager_link',
288 pageLinkClass: 'pager_link',
289 nextPageLinkLabel: '&gt;',
289 nextPageLinkLabel: '&gt;',
290 previousPageLinkLabel: '&lt;',
290 previousPageLinkLabel: '&lt;',
291 firstPageLinkLabel: '&lt;&lt;',
291 firstPageLinkLabel: '&lt;&lt;',
292 lastPageLinkLabel: '&gt;&gt;',
292 lastPageLinkLabel: '&gt;&gt;',
293 containers:['user-paginator']
293 containers:['user-paginator']
294 }),
294 }),
295
295
296 MSG_SORTASC:"${_('Click to sort ascending')}",
296 MSG_SORTASC:"${_('Click to sort ascending')}",
297 MSG_SORTDESC:"${_('Click to sort descending')}",
297 MSG_SORTDESC:"${_('Click to sort descending')}",
298 MSG_EMPTY:"${_('No repositories found.')}",
298 MSG_EMPTY:"${_('No repositories found.')}",
299 MSG_ERROR:"${_('Data error.')}",
299 MSG_ERROR:"${_('Data error.')}",
300 MSG_LOADING:"${_('Loading...')}",
300 MSG_LOADING:"${_('Loading...')}",
301 }
301 }
302 );
302 );
303 myDataTable.subscribe('postRenderEvent',function(oArgs) {
303 myDataTable.subscribe('postRenderEvent',function(oArgs) {
304 tooltip_activate();
304 tooltip_activate();
305 quick_repo_menu();
305 quick_repo_menu();
306 });
306 });
307
307
308 var filterTimeout = null;
308 var filterTimeout = null;
309
309
310 updateFilter = function () {
310 updateFilter = function () {
311 // Reset timeout
311 // Reset timeout
312 filterTimeout = null;
312 filterTimeout = null;
313
313
314 // Reset sort
314 // Reset sort
315 var state = myDataTable.getState();
315 var state = myDataTable.getState();
316 state.sortedBy = {key:'name', dir:YAHOO.widget.DataTable.CLASS_ASC};
316 state.sortedBy = {key:'name', dir:YAHOO.widget.DataTable.CLASS_ASC};
317
317
318 // Get filtered data
318 // Get filtered data
319 myDataSource.sendRequest(YUD.get('q_filter').value,{
319 myDataSource.sendRequest(YUD.get('q_filter').value,{
320 success : myDataTable.onDataReturnInitializeTable,
320 success : myDataTable.onDataReturnInitializeTable,
321 failure : myDataTable.onDataReturnInitializeTable,
321 failure : myDataTable.onDataReturnInitializeTable,
322 scope : myDataTable,
322 scope : myDataTable,
323 argument: state
323 argument: state
324 });
324 });
325
325
326 };
326 };
327 YUE.on('q_filter','click',function(){
327 YUE.on('q_filter','click',function(){
328 if(!YUD.hasClass('q_filter', 'loaded')){
328 if(!YUD.hasClass('q_filter', 'loaded')){
329 YUD.get('q_filter').value = '';
330 //TODO: load here full list later to do search within groups
329 //TODO: load here full list later to do search within groups
331 YUD.addClass('q_filter', 'loaded');
330 YUD.addClass('q_filter', 'loaded');
332 }
331 }
333 });
332 });
334
333
335 YUE.on('q_filter','keyup',function (e) {
334 YUE.on('q_filter','keyup',function (e) {
336 clearTimeout(filterTimeout);
335 clearTimeout(filterTimeout);
337 filterTimeout = setTimeout(updateFilter,600);
336 filterTimeout = setTimeout(updateFilter,600);
338 });
337 });
339 </script>
338 </script>
340 % endif
339 % endif
@@ -1,367 +1,365 b''
1 ## -*- coding: utf-8 -*-
1 ## -*- coding: utf-8 -*-
2 <%inherit file="/base/base.html"/>
2 <%inherit file="/base/base.html"/>
3 <%def name="title()">
3 <%def name="title()">
4 ${_('Journal')} &middot; ${c.rhodecode_name}
4 ${_('Journal')} &middot; ${c.rhodecode_name}
5 </%def>
5 </%def>
6 <%def name="breadcrumbs()">
6 <%def name="breadcrumbs()">
7 <h5>
7 <h5>
8 <form id="filter_form">
8 <form id="filter_form">
9 <input class="q_filter_box ${'' if c.search_term else 'initial'}" id="j_filter" size="15" type="text" name="filter" value="${c.search_term or _('quick filter...')}"/>
9 <input class="q_filter_box ${'' if c.search_term else 'initial'}" id="j_filter" size="15" type="text" name="filter" value="${c.search_term or _('quick filter...')}"/>
10 <span class="tooltip" title="${h.tooltip(h.journal_filter_help())}">?</span>
10 <span class="tooltip" title="${h.tooltip(h.journal_filter_help())}">?</span>
11 <input type='submit' value="${_('filter')}" class="ui-btn" style="padding:0px 2px 0px 2px;margin:0px"/>
11 <input type='submit' value="${_('filter')}" class="ui-btn" style="padding:0px 2px 0px 2px;margin:0px"/>
12 ${_('journal')} - ${ungettext('%s entry', '%s entries', c.journal_pager.item_count) % (c.journal_pager.item_count)}
12 ${_('journal')} - ${ungettext('%s entry', '%s entries', c.journal_pager.item_count) % (c.journal_pager.item_count)}
13 </form>
13 </form>
14 ${h.end_form()}
14 ${h.end_form()}
15 </h5>
15 </h5>
16 </%def>
16 </%def>
17 <%def name="page_nav()">
17 <%def name="page_nav()">
18 ${self.menu('journal')}
18 ${self.menu('journal')}
19 </%def>
19 </%def>
20 <%def name="head_extra()">
20 <%def name="head_extra()">
21 <link href="${h.url('journal_atom', api_key=c.rhodecode_user.api_key)}" rel="alternate" title="${_('ATOM journal feed')}" type="application/atom+xml" />
21 <link href="${h.url('journal_atom', api_key=c.rhodecode_user.api_key)}" rel="alternate" title="${_('ATOM journal feed')}" type="application/atom+xml" />
22 <link href="${h.url('journal_rss', api_key=c.rhodecode_user.api_key)}" rel="alternate" title="${_('RSS journal feed')}" type="application/rss+xml" />
22 <link href="${h.url('journal_rss', api_key=c.rhodecode_user.api_key)}" rel="alternate" title="${_('RSS journal feed')}" type="application/rss+xml" />
23 </%def>
23 </%def>
24 <%def name="main()">
24 <%def name="main()">
25
25
26 <div class="box box-left">
26 <div class="box box-left">
27 <!-- box / title -->
27 <!-- box / title -->
28 <div class="title">
28 <div class="title">
29 ${self.breadcrumbs()}
29 ${self.breadcrumbs()}
30 <ul class="links">
30 <ul class="links">
31 <li>
31 <li>
32 <span><a id="refresh" href="${h.url('journal')}"><img class="icon" title="${_('Refresh')}" alt="${_('Refresh')}" src="${h.url('/images/icons/arrow_refresh.png')}"/></a></span>
32 <span><a id="refresh" href="${h.url('journal')}"><img class="icon" title="${_('Refresh')}" alt="${_('Refresh')}" src="${h.url('/images/icons/arrow_refresh.png')}"/></a></span>
33 </li>
33 </li>
34 <li>
34 <li>
35 <span><a href="${h.url('journal_atom', api_key=c.rhodecode_user.api_key)}"><img class="icon" title="${_('ATOM feed')}" alt="${_('ATOM feed')}" src="${h.url('/images/icons/rss_16.png')}"/></a></span>
35 <span><a href="${h.url('journal_atom', api_key=c.rhodecode_user.api_key)}"><img class="icon" title="${_('ATOM feed')}" alt="${_('ATOM feed')}" src="${h.url('/images/icons/rss_16.png')}"/></a></span>
36 </li>
36 </li>
37 </ul>
37 </ul>
38 </div>
38 </div>
39 <div id="journal">${c.journal_data}</div>
39 <div id="journal">${c.journal_data}</div>
40 </div>
40 </div>
41 <div class="box box-right">
41 <div class="box box-right">
42 <!-- box / title -->
42 <!-- box / title -->
43
43
44 <div class="title">
44 <div class="title">
45 <h5>
45 <h5>
46 <input class="q_filter_box" id="q_filter" size="15" type="text" name="filter" value="${_('quick filter...')}" style="display: none"/>
46 <input class="q_filter_box" id="q_filter" size="15" type="text" name="filter" placeholder="${_('quick filter...')}" value="" style="display: none"/>
47 <input class="q_filter_box" id="q_filter_watched" size="15" type="text" name="filter" value="${_('quick filter...')}" style="display: none"/>
47 <input class="q_filter_box" id="q_filter_watched" size="15" type="text" name="filter" placeholder="${_('quick filter...')}" value="" style="display: none"/>
48 </h5>
48 </h5>
49 <ul class="links" style="color:#DADADA">
49 <ul class="links" style="color:#DADADA">
50 <li>
50 <li>
51 <span><a id="show_watched" class="link-white current" href="#watched">${_('Watched')}</a> </span>
51 <span><a id="show_watched" class="link-white current" href="#watched">${_('Watched')}</a> </span>
52 </li>
52 </li>
53 <li>
53 <li>
54 <span><a id="show_my" class="link-white" href="#my">${_('My repos')}</a> </span>
54 <span><a id="show_my" class="link-white" href="#my">${_('My repos')}</a> </span>
55 </li>
55 </li>
56 </ul>
56 </ul>
57 </div>
57 </div>
58
58
59 <!-- end box / title -->
59 <!-- end box / title -->
60 <div id="my_container" style="display:none">
60 <div id="my_container" style="display:none">
61 <div class="table yui-skin-sam" id="repos_list_wrap"></div>
61 <div class="table yui-skin-sam" id="repos_list_wrap"></div>
62 <div id="user-paginator" style="padding: 0px 0px 0px 20px"></div>
62 <div id="user-paginator" style="padding: 0px 0px 0px 20px"></div>
63 </div>
63 </div>
64
64
65 <div id="watched_container">
65 <div id="watched_container">
66 <div class="table yui-skin-sam" id="watched_repos_list_wrap"></div>
66 <div class="table yui-skin-sam" id="watched_repos_list_wrap"></div>
67 <div id="watched-user-paginator" style="padding: 0px 0px 0px 20px"></div>
67 <div id="watched-user-paginator" style="padding: 0px 0px 0px 20px"></div>
68 </div>
68 </div>
69 </div>
69 </div>
70
70
71 <script type="text/javascript">
71 <script type="text/javascript">
72
72
73 YUE.on('j_filter','click',function(){
73 YUE.on('j_filter','click',function(){
74 var jfilter = YUD.get('j_filter');
74 var jfilter = YUD.get('j_filter');
75 if(YUD.hasClass(jfilter, 'initial')){
75 if(YUD.hasClass(jfilter, 'initial')){
76 jfilter.value = '';
76 jfilter.value = '';
77 }
77 }
78 });
78 });
79 var fix_j_filter_width = function(len){
79 var fix_j_filter_width = function(len){
80 YUD.setStyle(YUD.get('j_filter'),'width',Math.max(80, len*6.50)+'px');
80 YUD.setStyle(YUD.get('j_filter'),'width',Math.max(80, len*6.50)+'px');
81 }
81 }
82 YUE.on('j_filter','keyup',function(){
82 YUE.on('j_filter','keyup',function(){
83 fix_j_filter_width(YUD.get('j_filter').value.length);
83 fix_j_filter_width(YUD.get('j_filter').value.length);
84 });
84 });
85 YUE.on('filter_form','submit',function(e){
85 YUE.on('filter_form','submit',function(e){
86 YUE.preventDefault(e)
86 YUE.preventDefault(e)
87 var val = YUD.get('j_filter').value;
87 var val = YUD.get('j_filter').value;
88 window.location = "${url.current(filter='__FILTER__')}".replace('__FILTER__',val);
88 window.location = "${url.current(filter='__FILTER__')}".replace('__FILTER__',val);
89 });
89 });
90 fix_j_filter_width(YUD.get('j_filter').value.length);
90 fix_j_filter_width(YUD.get('j_filter').value.length);
91
91
92 YUE.on('refresh','click',function(e){
92 YUE.on('refresh','click',function(e){
93 ypjax("${h.url.current(filter=c.search_term)}","journal",function(){
93 ypjax("${h.url.current(filter=c.search_term)}","journal",function(){
94 show_more_event();
94 show_more_event();
95 tooltip_activate();
95 tooltip_activate();
96 show_changeset_tooltip();
96 show_changeset_tooltip();
97 });
97 });
98 YUE.preventDefault(e);
98 YUE.preventDefault(e);
99 });
99 });
100
100
101 var show_my = function(e){
101 var show_my = function(e){
102 YUD.setStyle('watched_container','display','none');
102 YUD.setStyle('watched_container','display','none');
103 YUD.setStyle('my_container','display','');
103 YUD.setStyle('my_container','display','');
104 YUD.setStyle('q_filter','display','');
104 YUD.setStyle('q_filter','display','');
105 YUD.setStyle('q_filter_watched','display','none');
105 YUD.setStyle('q_filter_watched','display','none');
106
106
107 YUD.addClass('show_my', 'current');
107 YUD.addClass('show_my', 'current');
108 YUD.removeClass('show_watched','current');
108 YUD.removeClass('show_watched','current');
109
109
110 if(!YUD.hasClass('show_my', 'loaded')){
110 if(!YUD.hasClass('show_my', 'loaded')){
111 table_renderer(${c.data |n});
111 table_renderer(${c.data |n});
112 YUD.addClass('show_my', 'loaded');
112 YUD.addClass('show_my', 'loaded');
113 }
113 }
114 }
114 }
115 YUE.on('show_my','click',function(e){
115 YUE.on('show_my','click',function(e){
116 show_my(e);
116 show_my(e);
117 })
117 })
118 var show_watched = function(e){
118 var show_watched = function(e){
119 YUD.setStyle('my_container','display','none');
119 YUD.setStyle('my_container','display','none');
120 YUD.setStyle('watched_container','display','');
120 YUD.setStyle('watched_container','display','');
121 YUD.setStyle('q_filter_watched','display','');
121 YUD.setStyle('q_filter_watched','display','');
122 YUD.setStyle('q_filter','display','none');
122 YUD.setStyle('q_filter','display','none');
123
123
124 YUD.addClass('show_watched', 'current');
124 YUD.addClass('show_watched', 'current');
125 YUD.removeClass('show_my','current');
125 YUD.removeClass('show_my','current');
126 if(!YUD.hasClass('show_watched', 'loaded')){
126 if(!YUD.hasClass('show_watched', 'loaded')){
127 watched_renderer(${c.watched_data |n});
127 watched_renderer(${c.watched_data |n});
128 YUD.addClass('show_watched', 'loaded');
128 YUD.addClass('show_watched', 'loaded');
129 }
129 }
130
130
131 return
131 return
132 var nodes = YUQ('#watched_container .watched_repo a');
132 var nodes = YUQ('#watched_container .watched_repo a');
133 var target = 'q_filter';
133 var target = 'q_filter';
134 var func = function(node){
134 var func = function(node){
135 return node.parentNode.parentNode;
135 return node.parentNode.parentNode;
136 }
136 }
137 q_filter(target,nodes,func);
137 q_filter(target,nodes,func);
138 }
138 }
139 YUE.on('show_watched','click',function(e){
139 YUE.on('show_watched','click',function(e){
140 show_watched(e);
140 show_watched(e);
141 })
141 })
142 //init watched
142 //init watched
143 show_watched();
143 show_watched();
144
144
145 var tabs = {
145 var tabs = {
146 'watched': show_watched,
146 'watched': show_watched,
147 'my': show_my,
147 'my': show_my,
148 }
148 }
149 var url = location.href.split('#');
149 var url = location.href.split('#');
150 if (url[1]) {
150 if (url[1]) {
151 //We have a hash
151 //We have a hash
152 var tabHash = url[1];
152 var tabHash = url[1];
153 var func = tabs[tabHash]
153 var func = tabs[tabHash]
154 if (func){
154 if (func){
155 func();
155 func();
156 }
156 }
157 }
157 }
158 function watched_renderer(data){
158 function watched_renderer(data){
159 var myDataSource = new YAHOO.util.DataSource(data);
159 var myDataSource = new YAHOO.util.DataSource(data);
160 myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
160 myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
161
161
162 myDataSource.responseSchema = {
162 myDataSource.responseSchema = {
163 resultsList: "records",
163 resultsList: "records",
164 fields: [
164 fields: [
165 {key:"menu"},
165 {key:"menu"},
166 {key:"raw_name"},
166 {key:"raw_name"},
167 {key:"name"},
167 {key:"name"},
168 {key:"last_changeset"},
168 {key:"last_changeset"},
169 {key:"action"},
169 {key:"action"},
170 ]
170 ]
171 };
171 };
172 myDataSource.doBeforeCallback = function(req,raw,res,cb) {
172 myDataSource.doBeforeCallback = function(req,raw,res,cb) {
173 // This is the filter function
173 // This is the filter function
174 var data = res.results || [],
174 var data = res.results || [],
175 filtered = [],
175 filtered = [],
176 i,l;
176 i,l;
177
177
178 if (req) {
178 if (req) {
179 req = req.toLowerCase();
179 req = req.toLowerCase();
180 for (i = 0; i<data.length; i++) {
180 for (i = 0; i<data.length; i++) {
181 var pos = data[i].raw_name.toLowerCase().indexOf(req)
181 var pos = data[i].raw_name.toLowerCase().indexOf(req)
182 if (pos != -1) {
182 if (pos != -1) {
183 filtered.push(data[i]);
183 filtered.push(data[i]);
184 }
184 }
185 }
185 }
186 res.results = filtered;
186 res.results = filtered;
187 }
187 }
188 return res;
188 return res;
189 }
189 }
190 // main table sorting
190 // main table sorting
191 var myColumnDefs = [
191 var myColumnDefs = [
192 {key:"menu",label:"",sortable:false,className:"quick_repo_menu hidden"},
192 {key:"menu",label:"",sortable:false,className:"quick_repo_menu hidden"},
193 {key:"name",label:"${_('Name')}",sortable:true,
193 {key:"name",label:"${_('Name')}",sortable:true,
194 sortOptions: { sortFunction: nameSort }},
194 sortOptions: { sortFunction: nameSort }},
195 {key:"last_changeset",label:"${_('Tip')}",sortable:true,
195 {key:"last_changeset",label:"${_('Tip')}",sortable:true,
196 sortOptions: { sortFunction: revisionSort }},
196 sortOptions: { sortFunction: revisionSort }},
197 {key:"action",label:"${_('Action')}",sortable:false},
197 {key:"action",label:"${_('Action')}",sortable:false},
198 ];
198 ];
199
199
200 var myDataTable = new YAHOO.widget.DataTable("watched_repos_list_wrap", myColumnDefs, myDataSource,{
200 var myDataTable = new YAHOO.widget.DataTable("watched_repos_list_wrap", myColumnDefs, myDataSource,{
201 sortedBy:{key:"name",dir:"asc"},
201 sortedBy:{key:"name",dir:"asc"},
202 paginator: new YAHOO.widget.Paginator({
202 paginator: new YAHOO.widget.Paginator({
203 rowsPerPage: 25,
203 rowsPerPage: 25,
204 alwaysVisible: false,
204 alwaysVisible: false,
205 template : "{PreviousPageLink} {FirstPageLink} {PageLinks} {LastPageLink} {NextPageLink}",
205 template : "{PreviousPageLink} {FirstPageLink} {PageLinks} {LastPageLink} {NextPageLink}",
206 pageLinks: 5,
206 pageLinks: 5,
207 containerClass: 'pagination-wh',
207 containerClass: 'pagination-wh',
208 currentPageClass: 'pager_curpage',
208 currentPageClass: 'pager_curpage',
209 pageLinkClass: 'pager_link',
209 pageLinkClass: 'pager_link',
210 nextPageLinkLabel: '&gt;',
210 nextPageLinkLabel: '&gt;',
211 previousPageLinkLabel: '&lt;',
211 previousPageLinkLabel: '&lt;',
212 firstPageLinkLabel: '&lt;&lt;',
212 firstPageLinkLabel: '&lt;&lt;',
213 lastPageLinkLabel: '&gt;&gt;',
213 lastPageLinkLabel: '&gt;&gt;',
214 containers:['watched-user-paginator']
214 containers:['watched-user-paginator']
215 }),
215 }),
216
216
217 MSG_SORTASC:"${_('Click to sort ascending')}",
217 MSG_SORTASC:"${_('Click to sort ascending')}",
218 MSG_SORTDESC:"${_('Click to sort descending')}",
218 MSG_SORTDESC:"${_('Click to sort descending')}",
219 MSG_EMPTY:"${_('No records found.')}",
219 MSG_EMPTY:"${_('No records found.')}",
220 MSG_ERROR:"${_('Data error.')}",
220 MSG_ERROR:"${_('Data error.')}",
221 MSG_LOADING:"${_('Loading...')}",
221 MSG_LOADING:"${_('Loading...')}",
222 }
222 }
223 );
223 );
224 myDataTable.subscribe('postRenderEvent',function(oArgs) {
224 myDataTable.subscribe('postRenderEvent',function(oArgs) {
225 tooltip_activate();
225 tooltip_activate();
226 quick_repo_menu();
226 quick_repo_menu();
227 });
227 });
228
228
229 var filterTimeout = null;
229 var filterTimeout = null;
230
230
231 updateFilter = function () {
231 updateFilter = function () {
232 // Reset timeout
232 // Reset timeout
233 filterTimeout = null;
233 filterTimeout = null;
234
234
235 // Reset sort
235 // Reset sort
236 var state = myDataTable.getState();
236 var state = myDataTable.getState();
237 state.sortedBy = {key:'name', dir:YAHOO.widget.DataTable.CLASS_ASC};
237 state.sortedBy = {key:'name', dir:YAHOO.widget.DataTable.CLASS_ASC};
238
238
239 // Get filtered data
239 // Get filtered data
240 myDataSource.sendRequest(YUD.get('q_filter_watched').value,{
240 myDataSource.sendRequest(YUD.get('q_filter_watched').value,{
241 success : myDataTable.onDataReturnInitializeTable,
241 success : myDataTable.onDataReturnInitializeTable,
242 failure : myDataTable.onDataReturnInitializeTable,
242 failure : myDataTable.onDataReturnInitializeTable,
243 scope : myDataTable,
243 scope : myDataTable,
244 argument: state
244 argument: state
245 });
245 });
246
246
247 };
247 };
248 YUE.on('q_filter_watched','click',function(){
248 YUE.on('q_filter_watched','click',function(){
249 if(!YUD.hasClass('q_filter_watched', 'loaded')){
249 if(!YUD.hasClass('q_filter_watched', 'loaded')){
250 YUD.get('q_filter_watched').value = '';
251 //TODO: load here full list later to do search within groups
250 //TODO: load here full list later to do search within groups
252 YUD.addClass('q_filter_watched', 'loaded');
251 YUD.addClass('q_filter_watched', 'loaded');
253 }
252 }
254 });
253 });
255
254
256 YUE.on('q_filter_watched','keyup',function (e) {
255 YUE.on('q_filter_watched','keyup',function (e) {
257 clearTimeout(filterTimeout);
256 clearTimeout(filterTimeout);
258 filterTimeout = setTimeout(updateFilter,600);
257 filterTimeout = setTimeout(updateFilter,600);
259 });
258 });
260 }
259 }
261
260
262 function table_renderer(data){
261 function table_renderer(data){
263 var myDataSource = new YAHOO.util.DataSource(data);
262 var myDataSource = new YAHOO.util.DataSource(data);
264 myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
263 myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
265
264
266 myDataSource.responseSchema = {
265 myDataSource.responseSchema = {
267 resultsList: "records",
266 resultsList: "records",
268 fields: [
267 fields: [
269 {key:"menu"},
268 {key:"menu"},
270 {key:"raw_name"},
269 {key:"raw_name"},
271 {key:"name"},
270 {key:"name"},
272 {key:"last_changeset"},
271 {key:"last_changeset"},
273 {key:"action"},
272 {key:"action"},
274 ]
273 ]
275 };
274 };
276 myDataSource.doBeforeCallback = function(req,raw,res,cb) {
275 myDataSource.doBeforeCallback = function(req,raw,res,cb) {
277 // This is the filter function
276 // This is the filter function
278 var data = res.results || [],
277 var data = res.results || [],
279 filtered = [],
278 filtered = [],
280 i,l;
279 i,l;
281
280
282 if (req) {
281 if (req) {
283 req = req.toLowerCase();
282 req = req.toLowerCase();
284 for (i = 0; i<data.length; i++) {
283 for (i = 0; i<data.length; i++) {
285 var pos = data[i].raw_name.toLowerCase().indexOf(req)
284 var pos = data[i].raw_name.toLowerCase().indexOf(req)
286 if (pos != -1) {
285 if (pos != -1) {
287 filtered.push(data[i]);
286 filtered.push(data[i]);
288 }
287 }
289 }
288 }
290 res.results = filtered;
289 res.results = filtered;
291 }
290 }
292 return res;
291 return res;
293 }
292 }
294 // main table sorting
293 // main table sorting
295 var myColumnDefs = [
294 var myColumnDefs = [
296 {key:"menu",label:"",sortable:false,className:"quick_repo_menu hidden"},
295 {key:"menu",label:"",sortable:false,className:"quick_repo_menu hidden"},
297 {key:"name",label:"${_('Name')}",sortable:true,
296 {key:"name",label:"${_('Name')}",sortable:true,
298 sortOptions: { sortFunction: nameSort }},
297 sortOptions: { sortFunction: nameSort }},
299 {key:"last_changeset",label:"${_('Tip')}",sortable:true,
298 {key:"last_changeset",label:"${_('Tip')}",sortable:true,
300 sortOptions: { sortFunction: revisionSort }},
299 sortOptions: { sortFunction: revisionSort }},
301 {key:"action",label:"${_('Action')}",sortable:false},
300 {key:"action",label:"${_('Action')}",sortable:false},
302 ];
301 ];
303
302
304 var myDataTable = new YAHOO.widget.DataTable("repos_list_wrap", myColumnDefs, myDataSource,{
303 var myDataTable = new YAHOO.widget.DataTable("repos_list_wrap", myColumnDefs, myDataSource,{
305 sortedBy:{key:"name",dir:"asc"},
304 sortedBy:{key:"name",dir:"asc"},
306 paginator: new YAHOO.widget.Paginator({
305 paginator: new YAHOO.widget.Paginator({
307 rowsPerPage: 25,
306 rowsPerPage: 25,
308 alwaysVisible: false,
307 alwaysVisible: false,
309 template : "{PreviousPageLink} {FirstPageLink} {PageLinks} {LastPageLink} {NextPageLink}",
308 template : "{PreviousPageLink} {FirstPageLink} {PageLinks} {LastPageLink} {NextPageLink}",
310 pageLinks: 5,
309 pageLinks: 5,
311 containerClass: 'pagination-wh',
310 containerClass: 'pagination-wh',
312 currentPageClass: 'pager_curpage',
311 currentPageClass: 'pager_curpage',
313 pageLinkClass: 'pager_link',
312 pageLinkClass: 'pager_link',
314 nextPageLinkLabel: '&gt;',
313 nextPageLinkLabel: '&gt;',
315 previousPageLinkLabel: '&lt;',
314 previousPageLinkLabel: '&lt;',
316 firstPageLinkLabel: '&lt;&lt;',
315 firstPageLinkLabel: '&lt;&lt;',
317 lastPageLinkLabel: '&gt;&gt;',
316 lastPageLinkLabel: '&gt;&gt;',
318 containers:['user-paginator']
317 containers:['user-paginator']
319 }),
318 }),
320
319
321 MSG_SORTASC:"${_('Click to sort ascending')}",
320 MSG_SORTASC:"${_('Click to sort ascending')}",
322 MSG_SORTDESC:"${_('Click to sort descending')}",
321 MSG_SORTDESC:"${_('Click to sort descending')}",
323 MSG_EMPTY:"${_('No records found.')}",
322 MSG_EMPTY:"${_('No records found.')}",
324 MSG_ERROR:"${_('Data error.')}",
323 MSG_ERROR:"${_('Data error.')}",
325 MSG_LOADING:"${_('Loading...')}",
324 MSG_LOADING:"${_('Loading...')}",
326 }
325 }
327 );
326 );
328 myDataTable.subscribe('postRenderEvent',function(oArgs) {
327 myDataTable.subscribe('postRenderEvent',function(oArgs) {
329 tooltip_activate();
328 tooltip_activate();
330 quick_repo_menu();
329 quick_repo_menu();
331 });
330 });
332
331
333 var filterTimeout = null;
332 var filterTimeout = null;
334
333
335 updateFilter = function () {
334 updateFilter = function () {
336 // Reset timeout
335 // Reset timeout
337 filterTimeout = null;
336 filterTimeout = null;
338
337
339 // Reset sort
338 // Reset sort
340 var state = myDataTable.getState();
339 var state = myDataTable.getState();
341 state.sortedBy = {key:'name', dir:YAHOO.widget.DataTable.CLASS_ASC};
340 state.sortedBy = {key:'name', dir:YAHOO.widget.DataTable.CLASS_ASC};
342
341
343 // Get filtered data
342 // Get filtered data
344 myDataSource.sendRequest(YUD.get('q_filter').value,{
343 myDataSource.sendRequest(YUD.get('q_filter').value,{
345 success : myDataTable.onDataReturnInitializeTable,
344 success : myDataTable.onDataReturnInitializeTable,
346 failure : myDataTable.onDataReturnInitializeTable,
345 failure : myDataTable.onDataReturnInitializeTable,
347 scope : myDataTable,
346 scope : myDataTable,
348 argument: state
347 argument: state
349 });
348 });
350
349
351 };
350 };
352 YUE.on('q_filter','click',function(){
351 YUE.on('q_filter','click',function(){
353 if(!YUD.hasClass('q_filter', 'loaded')){
352 if(!YUD.hasClass('q_filter', 'loaded')){
354 YUD.get('q_filter').value = '';
355 //TODO: load here full list later to do search within groups
353 //TODO: load here full list later to do search within groups
356 YUD.addClass('q_filter', 'loaded');
354 YUD.addClass('q_filter', 'loaded');
357 }
355 }
358 });
356 });
359
357
360 YUE.on('q_filter','keyup',function (e) {
358 YUE.on('q_filter','keyup',function (e) {
361 clearTimeout(filterTimeout);
359 clearTimeout(filterTimeout);
362 filterTimeout = setTimeout(updateFilter,600);
360 filterTimeout = setTimeout(updateFilter,600);
363 });
361 });
364 }
362 }
365
363
366 </script>
364 </script>
367 </%def>
365 </%def>
@@ -1,16 +1,16 b''
1 ## -*- coding: utf-8 -*-
1 ## -*- coding: utf-8 -*-
2
2
3 <li class="qfilter_rs">
3 <li class="qfilter_rs">
4 <input type="text" style="border:0;width:100%" value="${_('quick filter...')}" name="filter" id="q_filter_rs" />
4 <input type="text" style="border:0;width:100%" placeholder="${_('quick filter...')}" value="" name="filter" id="q_filter_rs" />
5 </li>
5 </li>
6
6
7 %for repo in c.repos_list:
7 %for repo in c.repos_list:
8 <li>
8 <li>
9 %if repo['dbrepo']['private'] and c.visual.show_private_icon:
9 %if repo['dbrepo']['private'] and c.visual.show_private_icon:
10 <img src="${h.url('/images/icons/lock.png')}" alt="${_('Private repository')}" class="repo_switcher_type"/>
10 <img src="${h.url('/images/icons/lock.png')}" alt="${_('Private repository')}" class="repo_switcher_type"/>
11 %elif not repo['dbrepo']['private'] and c.visual.show_public_icon:
11 %elif not repo['dbrepo']['private'] and c.visual.show_public_icon:
12 <img src="${h.url('/images/icons/lock_open.png')}" alt="${_('Public repository')}" class="repo_switcher_type" />
12 <img src="${h.url('/images/icons/lock_open.png')}" alt="${_('Public repository')}" class="repo_switcher_type" />
13 %endif
13 %endif
14 ${h.link_to(repo['name'],h.url('summary_home',repo_name=repo['name']),class_="repo_name thin %s" % repo['dbrepo']['repo_type'])}
14 ${h.link_to(repo['name'],h.url('summary_home',repo_name=repo['name']),class_="repo_name thin %s" % repo['dbrepo']['repo_type'])}
15 </li>
15 </li>
16 %endfor
16 %endfor
@@ -1,90 +1,90 b''
1 ## -*- coding: utf-8 -*-
1 ## -*- coding: utf-8 -*-
2 <%inherit file="/base/base.html"/>
2 <%inherit file="/base/base.html"/>
3
3
4 <%def name="title()">
4 <%def name="title()">
5 ${_('%s Tags') % c.repo_name} &middot; ${c.rhodecode_name}
5 ${_('%s Tags') % c.repo_name} &middot; ${c.rhodecode_name}
6 </%def>
6 </%def>
7
7
8 <%def name="breadcrumbs_links()">
8 <%def name="breadcrumbs_links()">
9 <input class="q_filter_box" id="q_filter_tags" size="15" type="text" name="filter" value="${_('quick filter...')}"/>
9 <input class="q_filter_box" id="q_filter_tags" size="15" type="text" name="filter" placeholder="${_('quick filter...')}" value=""/>
10 ${_('Tags')}
10 ${_('Tags')}
11 </%def>
11 </%def>
12
12
13 <%def name="page_nav()">
13 <%def name="page_nav()">
14 ${self.menu('repositories')}
14 ${self.menu('repositories')}
15 </%def>
15 </%def>
16
16
17 <%def name="main()">
17 <%def name="main()">
18 ${self.context_bar('switch-to')}
18 ${self.context_bar('switch-to')}
19 <div class="box">
19 <div class="box">
20 <!-- box / title -->
20 <!-- box / title -->
21 <div class="title">
21 <div class="title">
22 ${self.breadcrumbs()}
22 ${self.breadcrumbs()}
23 </div>
23 </div>
24 <!-- end box / title -->
24 <!-- end box / title -->
25 %if c.repo_tags:
25 %if c.repo_tags:
26 <div class="info_box" id="compare_tags" style="clear: both;padding: 10px 19px;text-align: right;"><a href="#" class="ui-btn small">${_('Compare tags')}</a></div>
26 <div class="info_box" id="compare_tags" style="clear: both;padding: 10px 19px;text-align: right;"><a href="#" class="ui-btn small">${_('Compare tags')}</a></div>
27 %endif
27 %endif
28 <div class="table">
28 <div class="table">
29 <%include file='tags_data.html'/>
29 <%include file='tags_data.html'/>
30 </div>
30 </div>
31 </div>
31 </div>
32 <script type="text/javascript">
32 <script type="text/javascript">
33 YUE.on('compare_tags','click',function(e){
33 YUE.on('compare_tags','click',function(e){
34 YUE.preventDefault(e);
34 YUE.preventDefault(e);
35 var org = YUQ('input[name=compare_org]:checked')[0];
35 var org = YUQ('input[name=compare_org]:checked')[0];
36 var other = YUQ('input[name=compare_other]:checked')[0];
36 var other = YUQ('input[name=compare_other]:checked')[0];
37
37
38 if(org && other){
38 if(org && other){
39 var compare_url = "${h.url('compare_url',repo_name=c.repo_name,org_ref_type='tag',org_ref='__ORG__',other_ref_type='tag',other_ref='__OTHER__')}";
39 var compare_url = "${h.url('compare_url',repo_name=c.repo_name,org_ref_type='tag',org_ref='__ORG__',other_ref_type='tag',other_ref='__OTHER__')}";
40 var u = compare_url.replace('__ORG__',org.value)
40 var u = compare_url.replace('__ORG__',org.value)
41 .replace('__OTHER__',other.value);
41 .replace('__OTHER__',other.value);
42 window.location=u;
42 window.location=u;
43 }
43 }
44 });
44 });
45
45
46 // main table sorting
46 // main table sorting
47 var myColumnDefs = [
47 var myColumnDefs = [
48 {key:"name",label:"${_('Name')}",sortable:true},
48 {key:"name",label:"${_('Name')}",sortable:true},
49 {key:"date",label:"${_('Date')}",sortable:true,
49 {key:"date",label:"${_('Date')}",sortable:true,
50 sortOptions: { sortFunction: dateSort }},
50 sortOptions: { sortFunction: dateSort }},
51 {key:"author",label:"${_('Author')}",sortable:true},
51 {key:"author",label:"${_('Author')}",sortable:true},
52 {key:"revision",label:"${_('Revision')}",sortable:true,
52 {key:"revision",label:"${_('Revision')}",sortable:true,
53 sortOptions: { sortFunction: revisionSort }},
53 sortOptions: { sortFunction: revisionSort }},
54 {key:"compare",label:"${_('Compare')}",sortable:false,},
54 {key:"compare",label:"${_('Compare')}",sortable:false,},
55 ];
55 ];
56
56
57 var myDataSource = new YAHOO.util.DataSource(YUD.get("tags_data"));
57 var myDataSource = new YAHOO.util.DataSource(YUD.get("tags_data"));
58
58
59 myDataSource.responseType = YAHOO.util.DataSource.TYPE_HTMLTABLE;
59 myDataSource.responseType = YAHOO.util.DataSource.TYPE_HTMLTABLE;
60
60
61 myDataSource.responseSchema = {
61 myDataSource.responseSchema = {
62 fields: [
62 fields: [
63 {key:"name"},
63 {key:"name"},
64 {key:"date"},
64 {key:"date"},
65 {key:"author"},
65 {key:"author"},
66 {key:"revision"},
66 {key:"revision"},
67 {key:"compare"},
67 {key:"compare"},
68 ]
68 ]
69 };
69 };
70
70
71 var myDataTable = new YAHOO.widget.DataTable("table_wrap", myColumnDefs, myDataSource,
71 var myDataTable = new YAHOO.widget.DataTable("table_wrap", myColumnDefs, myDataSource,
72 {
72 {
73 sortedBy:{key:"name",dir:"asc"},
73 sortedBy:{key:"name",dir:"asc"},
74 MSG_SORTASC:"${_('Click to sort ascending')}",
74 MSG_SORTASC:"${_('Click to sort ascending')}",
75 MSG_SORTDESC:"${_('Click to sort descending')}",
75 MSG_SORTDESC:"${_('Click to sort descending')}",
76 MSG_EMPTY:"${_('No records found.')}",
76 MSG_EMPTY:"${_('No records found.')}",
77 MSG_ERROR:"${_('Data error.')}",
77 MSG_ERROR:"${_('Data error.')}",
78 MSG_LOADING:"${_('Loading...')}",
78 MSG_LOADING:"${_('Loading...')}",
79 }
79 }
80 );
80 );
81 myDataTable.subscribe('postRenderEvent',function(oArgs) {
81 myDataTable.subscribe('postRenderEvent',function(oArgs) {
82 tooltip_activate();
82 tooltip_activate();
83 var func = function(node){
83 var func = function(node){
84 return node.parentNode.parentNode.parentNode.parentNode.parentNode;
84 return node.parentNode.parentNode.parentNode.parentNode.parentNode;
85 }
85 }
86 q_filter('q_filter_tags',YUQ('div.table tr td .logtags .tagtag a'),func);
86 q_filter('q_filter_tags',YUQ('div.table tr td .logtags .tagtag a'),func);
87 });
87 });
88
88
89 </script>
89 </script>
90 </%def>
90 </%def>
General Comments 0
You need to be logged in to leave comments. Login now