Mercurial > kallithea
annotate rhodecode/public/js/rhodecode.js @ 4128:bbbb013a0e94 rhodecode-2.2.5-gpl
Import some of the files from Select2 3.5.0 Javascript system.
RhodeCode 2.2.5 used a version of Select2. Herein, we bring into
Kallithea only a few files directly from Select2 3.5.0 (6ef7155) upstream,
using the commands indicated below:
(cd /tmp; \
git clone https://github.com/ivaynberg/select2.git; \
cd select2; \
git checkout 3.5.0 \
)
mkdir rhodecode/public/js/select2
cp -pa /tmp/select2/select2.{js,css,png} rhodecode/public/js/select2/
cp -pa /tmp/select2/select2x2.png rhodecode/public/js/select2/
cp -pa /tmp/select2/select2-spinner.gif rhodecode/public/js/select2/
hg add rhodecode/public/js/select2/
author | Bradley M. Kuhn <bkuhn@sfconservancy.org> |
---|---|
date | Fri, 16 May 2014 18:07:12 -0400 |
parents | 182a25646cf4 |
children | cc28a05562d3 |
rev | line source |
---|---|
1421
c6b811f11c94
Javascripts rewrite: updated yui to latest 2.9, simplified ajax loading for multiple pages. Removed YUI dev package
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
1 /** |
c6b811f11c94
Javascripts rewrite: updated yui to latest 2.9, simplified ajax loading for multiple pages. Removed YUI dev package
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
2 RhodeCode JS Files |
c6b811f11c94
Javascripts rewrite: updated yui to latest 2.9, simplified ajax loading for multiple pages. Removed YUI dev package
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
3 **/ |
c6b811f11c94
Javascripts rewrite: updated yui to latest 2.9, simplified ajax loading for multiple pages. Removed YUI dev package
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
4 |
c6b811f11c94
Javascripts rewrite: updated yui to latest 2.9, simplified ajax loading for multiple pages. Removed YUI dev package
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
5 if (typeof console == "undefined" || typeof console.log == "undefined"){ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
6 console = { log: function() {} } |
1421
c6b811f11c94
Javascripts rewrite: updated yui to latest 2.9, simplified ajax loading for multiple pages. Removed YUI dev package
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
7 } |
c6b811f11c94
Javascripts rewrite: updated yui to latest 2.9, simplified ajax loading for multiple pages. Removed YUI dev package
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
8 |
c6b811f11c94
Javascripts rewrite: updated yui to latest 2.9, simplified ajax loading for multiple pages. Removed YUI dev package
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
9 |
1699
623b228cf325
cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents:
1685
diff
changeset
|
10 var str_repeat = function(i, m) { |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
11 for (var o = []; m > 0; o[--m] = i); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
12 return o.join(''); |
1699
623b228cf325
cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents:
1685
diff
changeset
|
13 }; |
1421
c6b811f11c94
Javascripts rewrite: updated yui to latest 2.9, simplified ajax loading for multiple pages. Removed YUI dev package
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
14 |
c6b811f11c94
Javascripts rewrite: updated yui to latest 2.9, simplified ajax loading for multiple pages. Removed YUI dev package
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
15 /** |
c6b811f11c94
Javascripts rewrite: updated yui to latest 2.9, simplified ajax loading for multiple pages. Removed YUI dev package
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
16 * INJECT .format function into String |
c6b811f11c94
Javascripts rewrite: updated yui to latest 2.9, simplified ajax loading for multiple pages. Removed YUI dev package
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
17 * Usage: "My name is {0} {1}".format("Johny","Bravo") |
c6b811f11c94
Javascripts rewrite: updated yui to latest 2.9, simplified ajax loading for multiple pages. Removed YUI dev package
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
18 * Return "My name is Johny Bravo" |
c6b811f11c94
Javascripts rewrite: updated yui to latest 2.9, simplified ajax loading for multiple pages. Removed YUI dev package
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
19 * Inspired by https://gist.github.com/1049426 |
c6b811f11c94
Javascripts rewrite: updated yui to latest 2.9, simplified ajax loading for multiple pages. Removed YUI dev package
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
20 */ |
c6b811f11c94
Javascripts rewrite: updated yui to latest 2.9, simplified ajax loading for multiple pages. Removed YUI dev package
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
21 String.prototype.format = function() { |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
22 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
23 function format() { |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
24 var str = this; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
25 var len = arguments.length+1; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
26 var safe = undefined; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
27 var arg = undefined; |
1421
c6b811f11c94
Javascripts rewrite: updated yui to latest 2.9, simplified ajax loading for multiple pages. Removed YUI dev package
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
28 |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
29 // For each {0} {1} {n...} replace with the argument in that position. If |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
30 // the argument is an object or an array it will be stringified to JSON. |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
31 for (var i=0; i < len; arg = arguments[i++]) { |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
32 safe = typeof arg === 'object' ? JSON.stringify(arg) : arg; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
33 str = str.replace(RegExp('\\{'+(i-1)+'\\}', 'g'), safe); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
34 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
35 return str; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
36 } |
1421
c6b811f11c94
Javascripts rewrite: updated yui to latest 2.9, simplified ajax loading for multiple pages. Removed YUI dev package
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
37 |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
38 // Save a reference of what may already exist under the property native. |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
39 // Allows for doing something like: if("".format.native) { /* use native */ } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
40 format.native = String.prototype.format; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
41 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
42 // Replace the prototype property |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
43 return format; |
1421
c6b811f11c94
Javascripts rewrite: updated yui to latest 2.9, simplified ajax loading for multiple pages. Removed YUI dev package
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
44 |
1458
9d9e491e2a21
added author to main page tooltip
Marcin Kuzminski <marcin@python-works.com>
parents:
1426
diff
changeset
|
45 }(); |
1421
c6b811f11c94
Javascripts rewrite: updated yui to latest 2.9, simplified ajax loading for multiple pages. Removed YUI dev package
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
46 |
2369
c2f131502037
Autocomplete fixes
Marcin Kuzminski <marcin@python-works.com>
parents:
2368
diff
changeset
|
47 String.prototype.strip = function(char) { |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
48 if(char === undefined){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
49 char = '\\s'; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
50 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
51 return this.replace(new RegExp('^'+char+'+|'+char+'+$','g'), ''); |
2369
c2f131502037
Autocomplete fixes
Marcin Kuzminski <marcin@python-works.com>
parents:
2368
diff
changeset
|
52 } |
c2f131502037
Autocomplete fixes
Marcin Kuzminski <marcin@python-works.com>
parents:
2368
diff
changeset
|
53 String.prototype.lstrip = function(char) { |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
54 if(char === undefined){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
55 char = '\\s'; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
56 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
57 return this.replace(new RegExp('^'+char+'+'),''); |
2369
c2f131502037
Autocomplete fixes
Marcin Kuzminski <marcin@python-works.com>
parents:
2368
diff
changeset
|
58 } |
c2f131502037
Autocomplete fixes
Marcin Kuzminski <marcin@python-works.com>
parents:
2368
diff
changeset
|
59 String.prototype.rstrip = function(char) { |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
60 if(char === undefined){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
61 char = '\\s'; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
62 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
63 return this.replace(new RegExp(''+char+'+$'),''); |
2369
c2f131502037
Autocomplete fixes
Marcin Kuzminski <marcin@python-works.com>
parents:
2368
diff
changeset
|
64 } |
1465
ef31d0c6bae9
Added smart color generator to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
1458
diff
changeset
|
65 |
2612
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
66 |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
67 if(!Array.prototype.indexOf) { |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
68 Array.prototype.indexOf = function(needle) { |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
69 for(var i = 0; i < this.length; i++) { |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
70 if(this[i] === needle) { |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
71 return i; |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
72 } |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
73 } |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
74 return -1; |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
75 }; |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
76 } |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
77 |
2698
4debfe3b50be
ie8 fixes for inline comments :/
Marcin Kuzminski <marcin@python-works.com>
parents:
2694
diff
changeset
|
78 // IE(CRAP) doesn't support previousElementSibling |
4debfe3b50be
ie8 fixes for inline comments :/
Marcin Kuzminski <marcin@python-works.com>
parents:
2694
diff
changeset
|
79 var prevElementSibling = function( el ) { |
4debfe3b50be
ie8 fixes for inline comments :/
Marcin Kuzminski <marcin@python-works.com>
parents:
2694
diff
changeset
|
80 if( el.previousElementSibling ) { |
4debfe3b50be
ie8 fixes for inline comments :/
Marcin Kuzminski <marcin@python-works.com>
parents:
2694
diff
changeset
|
81 return el.previousElementSibling; |
4debfe3b50be
ie8 fixes for inline comments :/
Marcin Kuzminski <marcin@python-works.com>
parents:
2694
diff
changeset
|
82 } else { |
4debfe3b50be
ie8 fixes for inline comments :/
Marcin Kuzminski <marcin@python-works.com>
parents:
2694
diff
changeset
|
83 while( el = el.previousSibling ) { |
4debfe3b50be
ie8 fixes for inline comments :/
Marcin Kuzminski <marcin@python-works.com>
parents:
2694
diff
changeset
|
84 if( el.nodeType === 1 ) return el; |
4debfe3b50be
ie8 fixes for inline comments :/
Marcin Kuzminski <marcin@python-works.com>
parents:
2694
diff
changeset
|
85 } |
4debfe3b50be
ie8 fixes for inline comments :/
Marcin Kuzminski <marcin@python-works.com>
parents:
2694
diff
changeset
|
86 } |
4debfe3b50be
ie8 fixes for inline comments :/
Marcin Kuzminski <marcin@python-works.com>
parents:
2694
diff
changeset
|
87 } |
4debfe3b50be
ie8 fixes for inline comments :/
Marcin Kuzminski <marcin@python-works.com>
parents:
2694
diff
changeset
|
88 |
1465
ef31d0c6bae9
Added smart color generator to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
1458
diff
changeset
|
89 /** |
ef31d0c6bae9
Added smart color generator to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
1458
diff
changeset
|
90 * SmartColorGenerator |
ef31d0c6bae9
Added smart color generator to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
1458
diff
changeset
|
91 * |
ef31d0c6bae9
Added smart color generator to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
1458
diff
changeset
|
92 *usage:: |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
93 * var CG = new ColorGenerator(); |
1465
ef31d0c6bae9
Added smart color generator to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
1458
diff
changeset
|
94 * var col = CG.getColor(key); //returns array of RGB |
ef31d0c6bae9
Added smart color generator to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
1458
diff
changeset
|
95 * 'rgb({0})'.format(col.join(',') |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
96 * |
1465
ef31d0c6bae9
Added smart color generator to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
1458
diff
changeset
|
97 * @returns {ColorGenerator} |
ef31d0c6bae9
Added smart color generator to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
1458
diff
changeset
|
98 */ |
1699
623b228cf325
cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents:
1685
diff
changeset
|
99 var ColorGenerator = function(){ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
100 this.GOLDEN_RATIO = 0.618033988749895; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
101 this.CURRENT_RATIO = 0.22717784590367374 // this can be random |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
102 this.HSV_1 = 0.75;//saturation |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
103 this.HSV_2 = 0.95; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
104 this.color; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
105 this.cacheColorMap = {}; |
1465
ef31d0c6bae9
Added smart color generator to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
1458
diff
changeset
|
106 }; |
ef31d0c6bae9
Added smart color generator to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
1458
diff
changeset
|
107 |
ef31d0c6bae9
Added smart color generator to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
1458
diff
changeset
|
108 ColorGenerator.prototype = { |
ef31d0c6bae9
Added smart color generator to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
1458
diff
changeset
|
109 getColor:function(key){ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
110 if(this.cacheColorMap[key] !== undefined){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
111 return this.cacheColorMap[key]; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
112 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
113 else{ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
114 this.cacheColorMap[key] = this.generateColor(); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
115 return this.cacheColorMap[key]; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
116 } |
1465
ef31d0c6bae9
Added smart color generator to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
1458
diff
changeset
|
117 }, |
ef31d0c6bae9
Added smart color generator to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
1458
diff
changeset
|
118 _hsvToRgb:function(h,s,v){ |
ef31d0c6bae9
Added smart color generator to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
1458
diff
changeset
|
119 if (s == 0.0) |
ef31d0c6bae9
Added smart color generator to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
1458
diff
changeset
|
120 return [v, v, v]; |
ef31d0c6bae9
Added smart color generator to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
1458
diff
changeset
|
121 i = parseInt(h * 6.0) |
ef31d0c6bae9
Added smart color generator to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
1458
diff
changeset
|
122 f = (h * 6.0) - i |
ef31d0c6bae9
Added smart color generator to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
1458
diff
changeset
|
123 p = v * (1.0 - s) |
ef31d0c6bae9
Added smart color generator to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
1458
diff
changeset
|
124 q = v * (1.0 - s * f) |
ef31d0c6bae9
Added smart color generator to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
1458
diff
changeset
|
125 t = v * (1.0 - s * (1.0 - f)) |
ef31d0c6bae9
Added smart color generator to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
1458
diff
changeset
|
126 i = i % 6 |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
127 if (i == 0) |
1465
ef31d0c6bae9
Added smart color generator to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
1458
diff
changeset
|
128 return [v, t, p] |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
129 if (i == 1) |
1465
ef31d0c6bae9
Added smart color generator to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
1458
diff
changeset
|
130 return [q, v, p] |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
131 if (i == 2) |
1465
ef31d0c6bae9
Added smart color generator to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
1458
diff
changeset
|
132 return [p, v, t] |
ef31d0c6bae9
Added smart color generator to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
1458
diff
changeset
|
133 if (i == 3) |
ef31d0c6bae9
Added smart color generator to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
1458
diff
changeset
|
134 return [p, q, v] |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
135 if (i == 4) |
1465
ef31d0c6bae9
Added smart color generator to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
1458
diff
changeset
|
136 return [t, p, v] |
ef31d0c6bae9
Added smart color generator to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
1458
diff
changeset
|
137 if (i == 5) |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
138 return [v, p, q] |
1465
ef31d0c6bae9
Added smart color generator to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
1458
diff
changeset
|
139 }, |
ef31d0c6bae9
Added smart color generator to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
1458
diff
changeset
|
140 generateColor:function(){ |
ef31d0c6bae9
Added smart color generator to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
1458
diff
changeset
|
141 this.CURRENT_RATIO = this.CURRENT_RATIO+this.GOLDEN_RATIO; |
ef31d0c6bae9
Added smart color generator to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
1458
diff
changeset
|
142 this.CURRENT_RATIO = this.CURRENT_RATIO %= 1; |
ef31d0c6bae9
Added smart color generator to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
1458
diff
changeset
|
143 HSV_tuple = [this.CURRENT_RATIO, this.HSV_1, this.HSV_2] |
ef31d0c6bae9
Added smart color generator to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
1458
diff
changeset
|
144 RGB_tuple = this._hsvToRgb(HSV_tuple[0],HSV_tuple[1],HSV_tuple[2]); |
ef31d0c6bae9
Added smart color generator to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
1458
diff
changeset
|
145 function toRgb(v){ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
146 return ""+parseInt(v*256) |
1465
ef31d0c6bae9
Added smart color generator to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
1458
diff
changeset
|
147 } |
ef31d0c6bae9
Added smart color generator to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
1458
diff
changeset
|
148 return [toRgb(RGB_tuple[0]),toRgb(RGB_tuple[1]),toRgb(RGB_tuple[2])]; |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
149 |
1465
ef31d0c6bae9
Added smart color generator to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
1458
diff
changeset
|
150 } |
ef31d0c6bae9
Added smart color generator to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
1458
diff
changeset
|
151 } |
ef31d0c6bae9
Added smart color generator to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
1458
diff
changeset
|
152 |
3388
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
153 /** |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
154 * PyRoutesJS |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
155 * |
3388
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
156 * Usage pyroutes.url('mark_error_fixed',{"error_id":error_id}) // /mark_error_fixed/<error_id> |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
157 */ |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
158 var pyroutes = (function() { |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
159 // access global map defined in special file pyroutes |
3388
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
160 var matchlist = PROUTES_MAP; |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
161 var sprintf = (function() { |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
162 function get_type(variable) { |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
163 return Object.prototype.toString.call(variable).slice(8, -1).toLowerCase(); |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
164 } |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
165 function str_repeat(input, multiplier) { |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
166 for (var output = []; multiplier > 0; output[--multiplier] = input) {/* do nothing */} |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
167 return output.join(''); |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
168 } |
1465
ef31d0c6bae9
Added smart color generator to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
1458
diff
changeset
|
169 |
3388
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
170 var str_format = function() { |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
171 if (!str_format.cache.hasOwnProperty(arguments[0])) { |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
172 str_format.cache[arguments[0]] = str_format.parse(arguments[0]); |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
173 } |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
174 return str_format.format.call(null, str_format.cache[arguments[0]], arguments); |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
175 }; |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
176 |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
177 str_format.format = function(parse_tree, argv) { |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
178 var cursor = 1, tree_length = parse_tree.length, node_type = '', arg, output = [], i, k, match, pad, pad_character, pad_length; |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
179 for (i = 0; i < tree_length; i++) { |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
180 node_type = get_type(parse_tree[i]); |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
181 if (node_type === 'string') { |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
182 output.push(parse_tree[i]); |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
183 } |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
184 else if (node_type === 'array') { |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
185 match = parse_tree[i]; // convenience purposes only |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
186 if (match[2]) { // keyword argument |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
187 arg = argv[cursor]; |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
188 for (k = 0; k < match[2].length; k++) { |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
189 if (!arg.hasOwnProperty(match[2][k])) { |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
190 throw(sprintf('[sprintf] property "%s" does not exist', match[2][k])); |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
191 } |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
192 arg = arg[match[2][k]]; |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
193 } |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
194 } |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
195 else if (match[1]) { // positional argument (explicit) |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
196 arg = argv[match[1]]; |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
197 } |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
198 else { // positional argument (implicit) |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
199 arg = argv[cursor++]; |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
200 } |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
201 |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
202 if (/[^s]/.test(match[8]) && (get_type(arg) != 'number')) { |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
203 throw(sprintf('[sprintf] expecting number but found %s', get_type(arg))); |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
204 } |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
205 switch (match[8]) { |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
206 case 'b': arg = arg.toString(2); break; |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
207 case 'c': arg = String.fromCharCode(arg); break; |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
208 case 'd': arg = parseInt(arg, 10); break; |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
209 case 'e': arg = match[7] ? arg.toExponential(match[7]) : arg.toExponential(); break; |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
210 case 'f': arg = match[7] ? parseFloat(arg).toFixed(match[7]) : parseFloat(arg); break; |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
211 case 'o': arg = arg.toString(8); break; |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
212 case 's': arg = ((arg = String(arg)) && match[7] ? arg.substring(0, match[7]) : arg); break; |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
213 case 'u': arg = Math.abs(arg); break; |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
214 case 'x': arg = arg.toString(16); break; |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
215 case 'X': arg = arg.toString(16).toUpperCase(); break; |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
216 } |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
217 arg = (/[def]/.test(match[8]) && match[3] && arg >= 0 ? '+'+ arg : arg); |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
218 pad_character = match[4] ? match[4] == '0' ? '0' : match[4].charAt(1) : ' '; |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
219 pad_length = match[6] - String(arg).length; |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
220 pad = match[6] ? str_repeat(pad_character, pad_length) : ''; |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
221 output.push(match[5] ? arg + pad : pad + arg); |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
222 } |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
223 } |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
224 return output.join(''); |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
225 }; |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
226 |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
227 str_format.cache = {}; |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
228 |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
229 str_format.parse = function(fmt) { |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
230 var _fmt = fmt, match = [], parse_tree = [], arg_names = 0; |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
231 while (_fmt) { |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
232 if ((match = /^[^\x25]+/.exec(_fmt)) !== null) { |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
233 parse_tree.push(match[0]); |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
234 } |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
235 else if ((match = /^\x25{2}/.exec(_fmt)) !== null) { |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
236 parse_tree.push('%'); |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
237 } |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
238 else if ((match = /^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(_fmt)) !== null) { |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
239 if (match[2]) { |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
240 arg_names |= 1; |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
241 var field_list = [], replacement_field = match[2], field_match = []; |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
242 if ((field_match = /^([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) { |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
243 field_list.push(field_match[1]); |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
244 while ((replacement_field = replacement_field.substring(field_match[0].length)) !== '') { |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
245 if ((field_match = /^\.([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) { |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
246 field_list.push(field_match[1]); |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
247 } |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
248 else if ((field_match = /^\[(\d+)\]/.exec(replacement_field)) !== null) { |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
249 field_list.push(field_match[1]); |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
250 } |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
251 else { |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
252 throw('[sprintf] huh?'); |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
253 } |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
254 } |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
255 } |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
256 else { |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
257 throw('[sprintf] huh?'); |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
258 } |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
259 match[2] = field_list; |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
260 } |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
261 else { |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
262 arg_names |= 2; |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
263 } |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
264 if (arg_names === 3) { |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
265 throw('[sprintf] mixing positional and named placeholders is not (yet) supported'); |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
266 } |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
267 parse_tree.push(match); |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
268 } |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
269 else { |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
270 throw('[sprintf] huh?'); |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
271 } |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
272 _fmt = _fmt.substring(match[0].length); |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
273 } |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
274 return parse_tree; |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
275 }; |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
276 |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
277 return str_format; |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
278 })(); |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
279 |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
280 var vsprintf = function(fmt, argv) { |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
281 argv.unshift(fmt); |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
282 return sprintf.apply(null, argv); |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
283 }; |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
284 return { |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
285 'url': function(route_name, params) { |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
286 var result = route_name; |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
287 if (typeof(params) != 'object'){ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
288 params = {}; |
3388
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
289 } |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
290 if (matchlist.hasOwnProperty(route_name)) { |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
291 var route = matchlist[route_name]; |
3403
07f4193083fd
extra params in pyroutes now generate GET params
Marcin Kuzminski <marcin@python-works.com>
parents:
3388
diff
changeset
|
292 // param substitution |
3388
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
293 for(var i=0; i < route[1].length; i++) { |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
294 |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
295 if (!params.hasOwnProperty(route[1][i])) |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
296 throw new Error(route[1][i] + ' missing in "' + route_name + '" route generation'); |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
297 } |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
298 result = sprintf(route[0], params); |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
299 |
3403
07f4193083fd
extra params in pyroutes now generate GET params
Marcin Kuzminski <marcin@python-works.com>
parents:
3388
diff
changeset
|
300 var ret = []; |
07f4193083fd
extra params in pyroutes now generate GET params
Marcin Kuzminski <marcin@python-works.com>
parents:
3388
diff
changeset
|
301 //extra params => GET |
07f4193083fd
extra params in pyroutes now generate GET params
Marcin Kuzminski <marcin@python-works.com>
parents:
3388
diff
changeset
|
302 for(param in params){ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
303 if (route[1].indexOf(param) == -1){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
304 ret.push(encodeURIComponent(param) + "=" + encodeURIComponent(params[param])); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
305 } |
3403
07f4193083fd
extra params in pyroutes now generate GET params
Marcin Kuzminski <marcin@python-works.com>
parents:
3388
diff
changeset
|
306 } |
07f4193083fd
extra params in pyroutes now generate GET params
Marcin Kuzminski <marcin@python-works.com>
parents:
3388
diff
changeset
|
307 var _parts = ret.join("&"); |
07f4193083fd
extra params in pyroutes now generate GET params
Marcin Kuzminski <marcin@python-works.com>
parents:
3388
diff
changeset
|
308 if(_parts){ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
309 result = result +'?'+ _parts |
3403
07f4193083fd
extra params in pyroutes now generate GET params
Marcin Kuzminski <marcin@python-works.com>
parents:
3388
diff
changeset
|
310 } |
3388
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
311 } |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
312 |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
313 return result; |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
314 }, |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
315 'register': function(route_name, route_tmpl, req_params) { |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
316 if (typeof(req_params) != 'object') { |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
317 req_params = []; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
318 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
319 //fix escape |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
320 route_tmpl = unescape(route_tmpl); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
321 keys = []; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
322 for (o in req_params){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
323 keys.push(req_params[o]) |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
324 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
325 matchlist[route_name] = [ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
326 route_tmpl, |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
327 keys |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
328 ] |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
329 }, |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
330 '_routes': function(){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
331 return matchlist; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
332 } |
3388
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
333 } |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
334 })(); |
1465
ef31d0c6bae9
Added smart color generator to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
1458
diff
changeset
|
335 |
ef31d0c6bae9
Added smart color generator to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
1458
diff
changeset
|
336 |
ef31d0c6bae9
Added smart color generator to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
1458
diff
changeset
|
337 |
1421
c6b811f11c94
Javascripts rewrite: updated yui to latest 2.9, simplified ajax loading for multiple pages. Removed YUI dev package
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
338 /** |
c6b811f11c94
Javascripts rewrite: updated yui to latest 2.9, simplified ajax loading for multiple pages. Removed YUI dev package
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
339 * GLOBAL YUI Shortcuts |
c6b811f11c94
Javascripts rewrite: updated yui to latest 2.9, simplified ajax loading for multiple pages. Removed YUI dev package
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
340 */ |
c6b811f11c94
Javascripts rewrite: updated yui to latest 2.9, simplified ajax loading for multiple pages. Removed YUI dev package
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
341 var YUC = YAHOO.util.Connect; |
c6b811f11c94
Javascripts rewrite: updated yui to latest 2.9, simplified ajax loading for multiple pages. Removed YUI dev package
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
342 var YUD = YAHOO.util.Dom; |
c6b811f11c94
Javascripts rewrite: updated yui to latest 2.9, simplified ajax loading for multiple pages. Removed YUI dev package
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
343 var YUE = YAHOO.util.Event; |
c6b811f11c94
Javascripts rewrite: updated yui to latest 2.9, simplified ajax loading for multiple pages. Removed YUI dev package
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
344 var YUQ = YAHOO.util.Selector.query; |
c6b811f11c94
Javascripts rewrite: updated yui to latest 2.9, simplified ajax loading for multiple pages. Removed YUI dev package
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
345 |
c6b811f11c94
Javascripts rewrite: updated yui to latest 2.9, simplified ajax loading for multiple pages. Removed YUI dev package
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
346 // defines if push state is enabled for this browser ? |
c6b811f11c94
Javascripts rewrite: updated yui to latest 2.9, simplified ajax loading for multiple pages. Removed YUI dev package
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
347 var push_state_enabled = Boolean( |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
348 window.history && window.history.pushState && window.history.replaceState |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
349 && !( /* disable for versions of iOS before version 4.3 (8F190) */ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
350 (/ Mobile\/([1-7][a-z]|(8([abcde]|f(1[0-8]))))/i).test(navigator.userAgent) |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
351 /* disable for the mercury iOS browser, or at least older versions of the webkit engine */ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
352 || (/AppleWebKit\/5([0-2]|3[0-2])/i).test(navigator.userAgent) |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
353 ) |
1699
623b228cf325
cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents:
1685
diff
changeset
|
354 ); |
1421
c6b811f11c94
Javascripts rewrite: updated yui to latest 2.9, simplified ajax loading for multiple pages. Removed YUI dev package
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
355 |
1717
7ff304d3028f
Notification fixes
Marcin Kuzminski <marcin@python-works.com>
parents:
1712
diff
changeset
|
356 var _run_callbacks = function(callbacks){ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
357 if (callbacks !== undefined){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
358 var _l = callbacks.length; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
359 for (var i=0;i<_l;i++){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
360 var func = callbacks[i]; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
361 if(typeof(func)=='function'){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
362 try{ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
363 func(); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
364 }catch (err){}; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
365 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
366 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
367 } |
1717
7ff304d3028f
Notification fixes
Marcin Kuzminski <marcin@python-works.com>
parents:
1712
diff
changeset
|
368 } |
7ff304d3028f
Notification fixes
Marcin Kuzminski <marcin@python-works.com>
parents:
1712
diff
changeset
|
369 |
1421
c6b811f11c94
Javascripts rewrite: updated yui to latest 2.9, simplified ajax loading for multiple pages. Removed YUI dev package
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
370 /** |
3715
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
371 * turns objects into GET query string |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
372 */ |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
373 var toQueryString = function(o) { |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
374 if(typeof o !== 'object') { |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
375 return false; |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
376 } |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
377 var _p, _qs = []; |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
378 for(_p in o) { |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
379 _qs.push(encodeURIComponent(_p) + '=' + encodeURIComponent(o[_p])); |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
380 } |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
381 return _qs.join('&'); |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
382 }; |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
383 |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
384 /** |
1421
c6b811f11c94
Javascripts rewrite: updated yui to latest 2.9, simplified ajax loading for multiple pages. Removed YUI dev package
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
385 * Partial Ajax Implementation |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
386 * |
1421
c6b811f11c94
Javascripts rewrite: updated yui to latest 2.9, simplified ajax loading for multiple pages. Removed YUI dev package
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
387 * @param url: defines url to make partial request |
c6b811f11c94
Javascripts rewrite: updated yui to latest 2.9, simplified ajax loading for multiple pages. Removed YUI dev package
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
388 * @param container: defines id of container to input partial result |
c6b811f11c94
Javascripts rewrite: updated yui to latest 2.9, simplified ajax loading for multiple pages. Removed YUI dev package
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
389 * @param s_call: success callback function that takes o as arg |
c6b811f11c94
Javascripts rewrite: updated yui to latest 2.9, simplified ajax loading for multiple pages. Removed YUI dev package
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
390 * o.tId |
c6b811f11c94
Javascripts rewrite: updated yui to latest 2.9, simplified ajax loading for multiple pages. Removed YUI dev package
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
391 * o.status |
c6b811f11c94
Javascripts rewrite: updated yui to latest 2.9, simplified ajax loading for multiple pages. Removed YUI dev package
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
392 * o.statusText |
c6b811f11c94
Javascripts rewrite: updated yui to latest 2.9, simplified ajax loading for multiple pages. Removed YUI dev package
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
393 * o.getResponseHeader[ ] |
c6b811f11c94
Javascripts rewrite: updated yui to latest 2.9, simplified ajax loading for multiple pages. Removed YUI dev package
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
394 * o.getAllResponseHeaders |
c6b811f11c94
Javascripts rewrite: updated yui to latest 2.9, simplified ajax loading for multiple pages. Removed YUI dev package
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
395 * o.responseText |
c6b811f11c94
Javascripts rewrite: updated yui to latest 2.9, simplified ajax loading for multiple pages. Removed YUI dev package
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
396 * o.responseXML |
c6b811f11c94
Javascripts rewrite: updated yui to latest 2.9, simplified ajax loading for multiple pages. Removed YUI dev package
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
397 * o.argument |
c6b811f11c94
Javascripts rewrite: updated yui to latest 2.9, simplified ajax loading for multiple pages. Removed YUI dev package
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
398 * @param f_call: failure callback |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
399 * @param args arguments |
1421
c6b811f11c94
Javascripts rewrite: updated yui to latest 2.9, simplified ajax loading for multiple pages. Removed YUI dev package
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
400 */ |
c6b811f11c94
Javascripts rewrite: updated yui to latest 2.9, simplified ajax loading for multiple pages. Removed YUI dev package
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
401 function ypjax(url,container,s_call,f_call,args){ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
402 var method='GET'; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
403 if(args===undefined){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
404 args=null; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
405 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
406 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
407 // Set special header for partial ajax == HTTP_X_PARTIAL_XHR |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
408 YUC.initHeader('X-PARTIAL-XHR',true); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
409 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
410 // wrapper of passed callback |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
411 var s_wrapper = (function(o){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
412 return function(o){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
413 YUD.get(container).innerHTML=o.responseText; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
414 YUD.setStyle(container,'opacity','1.0'); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
415 //execute the given original callback |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
416 if (s_call !== undefined){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
417 s_call(o); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
418 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
419 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
420 })() |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
421 YUD.setStyle(container,'opacity','0.3'); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
422 YUC.asyncRequest(method,url,{ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
423 success:s_wrapper, |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
424 failure:function(o){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
425 console.log(o); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
426 YUD.get(container).innerHTML='<span class="error_red">ERROR: {0}</span>'.format(o.status); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
427 YUD.setStyle(container,'opacity','1.0'); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
428 }, |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
429 cache:false |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
430 },args); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
431 |
1699
623b228cf325
cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents:
1685
diff
changeset
|
432 }; |
1421
c6b811f11c94
Javascripts rewrite: updated yui to latest 2.9, simplified ajax loading for multiple pages. Removed YUI dev package
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
433 |
2971
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
434 var ajaxGET = function(url,success) { |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
435 // Set special header for ajax == HTTP_X_PARTIAL_XHR |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
436 YUC.initHeader('X-PARTIAL-XHR',true); |
2971
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
437 |
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
438 var sUrl = url; |
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
439 var callback = { |
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
440 success: success, |
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
441 failure: function (o) { |
3553
72c8917108ee
journal: don't show "error" popup when navigating away from page while lazy info is loading
Mads Kiilerich <madski@unity3d.com>
parents:
3552
diff
changeset
|
442 if (o.status != 0) { |
72c8917108ee
journal: don't show "error" popup when navigating away from page while lazy info is loading
Mads Kiilerich <madski@unity3d.com>
parents:
3552
diff
changeset
|
443 alert("error: " + o.statusText); |
72c8917108ee
journal: don't show "error" popup when navigating away from page while lazy info is loading
Mads Kiilerich <madski@unity3d.com>
parents:
3552
diff
changeset
|
444 }; |
2971
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
445 }, |
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
446 }; |
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
447 |
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
448 var request = YAHOO.util.Connect.asyncRequest('GET', sUrl, callback); |
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
449 return request; |
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
450 }; |
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
451 |
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
452 |
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
453 |
2187
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
454 var ajaxPOST = function(url,postData,success) { |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
455 // Set special header for ajax == HTTP_X_PARTIAL_XHR |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
456 YUC.initHeader('X-PARTIAL-XHR',true); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
457 |
2187
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
458 var sUrl = url; |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
459 var callback = { |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
460 success: success, |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
461 failure: function (o) { |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
462 alert("error"); |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
463 }, |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
464 }; |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
465 var postData = toQueryString(postData); |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
466 var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, callback, postData); |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
467 return request; |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
468 }; |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
469 |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
470 |
1421
c6b811f11c94
Javascripts rewrite: updated yui to latest 2.9, simplified ajax loading for multiple pages. Removed YUI dev package
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
471 /** |
c6b811f11c94
Javascripts rewrite: updated yui to latest 2.9, simplified ajax loading for multiple pages. Removed YUI dev package
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
472 * tooltip activate |
c6b811f11c94
Javascripts rewrite: updated yui to latest 2.9, simplified ajax loading for multiple pages. Removed YUI dev package
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
473 */ |
1458
9d9e491e2a21
added author to main page tooltip
Marcin Kuzminski <marcin@python-works.com>
parents:
1426
diff
changeset
|
474 var tooltip_activate = function(){ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
475 yt = YAHOO.yuitip.main; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
476 YUE.onDOMReady(yt.init); |
1699
623b228cf325
cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents:
1685
diff
changeset
|
477 }; |
1426
91708b96e991
Fixed show more links.
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
478 |
91708b96e991
Fixed show more links.
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
479 /** |
91708b96e991
Fixed show more links.
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
480 * show more |
91708b96e991
Fixed show more links.
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
481 */ |
1458
9d9e491e2a21
added author to main page tooltip
Marcin Kuzminski <marcin@python-works.com>
parents:
1426
diff
changeset
|
482 var show_more_event = function(){ |
1426
91708b96e991
Fixed show more links.
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
483 YUE.on(YUD.getElementsByClassName('show_more'),'click',function(e){ |
91708b96e991
Fixed show more links.
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
484 var el = e.target; |
91708b96e991
Fixed show more links.
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
485 YUD.setStyle(YUD.get(el.id.substring(1)),'display',''); |
91708b96e991
Fixed show more links.
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
486 YUD.setStyle(el.parentNode,'display','none'); |
91708b96e991
Fixed show more links.
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
487 }); |
1699
623b228cf325
cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents:
1685
diff
changeset
|
488 }; |
1426
91708b96e991
Fixed show more links.
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
489 |
2971
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
490 /** |
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
491 * show changeset tooltip |
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
492 */ |
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
493 var show_changeset_tooltip = function(){ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
494 YUE.on(YUD.getElementsByClassName('lazy-cs'), 'mouseover', function(e){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
495 var target = e.currentTarget; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
496 var rid = YUD.getAttribute(target,'raw_id'); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
497 var repo_name = YUD.getAttribute(target,'repo_name'); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
498 var ttid = 'tt-'+rid; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
499 var success = function(o){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
500 var json = JSON.parse(o.responseText); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
501 YUD.addClass(target,'tooltip') |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
502 YUD.setAttribute(target, 'title',json['message']); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
503 YAHOO.yuitip.main.show_yuitip(e, target); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
504 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
505 if(rid && !YUD.hasClass(target, 'tooltip')){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
506 YUD.setAttribute(target,'id',ttid); |
3966
636ff0369986
fixed hover loading ... info on lazy-cs
Marcin Kuzminski <marcin@python-works.com>
parents:
3784
diff
changeset
|
507 YUD.setAttribute(target, 'title',_TM['loading ...']); |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
508 YAHOO.yuitip.main.set_listeners(target); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
509 YAHOO.yuitip.main.show_yuitip(e, target); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
510 var url = pyroutes.url('changeset_info', {"repo_name":repo_name, "revision": rid}); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
511 ajaxGET(url, success) |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
512 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
513 }); |
2971
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
514 }; |
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
515 |
3066 | 516 var onSuccessFollow = function(target){ |
3527
87c97fcea029
Adding the context bar too all pages related to a Repository.
Leonardo <leo@unity3d.com>
parents:
3388
diff
changeset
|
517 var f = YUD.get(target); |
3066 | 518 var f_cnt = YUD.get('current_followers_count'); |
519 | |
520 if(YUD.hasClass(f, 'follow')){ | |
521 f.setAttribute('class','following'); | |
522 f.setAttribute('title',_TM['Stop following this repository']); | |
523 | |
524 if(f_cnt){ | |
525 var cnt = Number(f_cnt.innerHTML)+1; | |
526 f_cnt.innerHTML = cnt; | |
527 } | |
528 } | |
529 else{ | |
530 f.setAttribute('class','follow'); | |
531 f.setAttribute('title',_TM['Start following this repository']); | |
532 if(f_cnt){ | |
533 var cnt = Number(f_cnt.innerHTML)-1; | |
534 f_cnt.innerHTML = cnt; | |
535 } | |
536 } | |
537 } | |
538 | |
539 var toggleFollowingUser = function(target,fallows_user_id,token,user_id){ | |
540 args = 'follows_user_id='+fallows_user_id; | |
541 args+= '&auth_token='+token; | |
542 if(user_id != undefined){ | |
543 args+="&user_id="+user_id; | |
544 } | |
545 YUC.asyncRequest('POST',TOGGLE_FOLLOW_URL,{ | |
546 success:function(o){ | |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
547 onSuccessFollow(target); |
3066 | 548 } |
549 },args); | |
550 return false; | |
551 } | |
552 | |
553 var toggleFollowingRepo = function(target,fallows_repo_id,token,user_id){ | |
554 | |
555 args = 'follows_repo_id='+fallows_repo_id; | |
556 args+= '&auth_token='+token; | |
557 if(user_id != undefined){ | |
558 args+="&user_id="+user_id; | |
559 } | |
560 YUC.asyncRequest('POST',TOGGLE_FOLLOW_URL,{ | |
561 success:function(o){ | |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
562 onSuccessFollow(target); |
3066 | 563 } |
564 },args); | |
565 return false; | |
566 } | |
567 | |
3246
b9ba0d4d3abf
implemented #83 show repo size on summary page
Marcin Kuzminski <marcin@python-works.com>
parents:
3160
diff
changeset
|
568 var showRepoSize = function(target, repo_name, token){ |
b9ba0d4d3abf
implemented #83 show repo size on summary page
Marcin Kuzminski <marcin@python-works.com>
parents:
3160
diff
changeset
|
569 var args= 'auth_token='+token; |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
570 |
3247
ed2fa8b1ccca
disallow triggering repo size action more than once after loading
Marcin Kuzminski <marcin@python-works.com>
parents:
3246
diff
changeset
|
571 if(!YUD.hasClass(target, 'loaded')){ |
3516 | 572 YUD.get(target).innerHTML = _TM['Loading ...']; |
3388
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
573 var url = pyroutes.url('repo_size', {"repo_name":repo_name}); |
3247
ed2fa8b1ccca
disallow triggering repo size action more than once after loading
Marcin Kuzminski <marcin@python-works.com>
parents:
3246
diff
changeset
|
574 YUC.asyncRequest('POST',url,{ |
ed2fa8b1ccca
disallow triggering repo size action more than once after loading
Marcin Kuzminski <marcin@python-works.com>
parents:
3246
diff
changeset
|
575 success:function(o){ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
576 YUD.get(target).innerHTML = JSON.parse(o.responseText); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
577 YUD.addClass(target, 'loaded'); |
3247
ed2fa8b1ccca
disallow triggering repo size action more than once after loading
Marcin Kuzminski <marcin@python-works.com>
parents:
3246
diff
changeset
|
578 } |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
579 },args); |
3247
ed2fa8b1ccca
disallow triggering repo size action more than once after loading
Marcin Kuzminski <marcin@python-works.com>
parents:
3246
diff
changeset
|
580 } |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
581 return false; |
3246
b9ba0d4d3abf
implemented #83 show repo size on summary page
Marcin Kuzminski <marcin@python-works.com>
parents:
3160
diff
changeset
|
582 } |
2971
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
583 |
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
584 /** |
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
585 * TOOLTIP IMPL. |
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
586 */ |
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
587 YAHOO.namespace('yuitip'); |
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
588 YAHOO.yuitip.main = { |
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
589 |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
590 $: YAHOO.util.Dom.get, |
2971
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
591 |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
592 bgColor: '#000', |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
593 speed: 0.3, |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
594 opacity: 0.9, |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
595 offset: [15,15], |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
596 useAnim: false, |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
597 maxWidth: 600, |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
598 add_links: false, |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
599 yuitips: [], |
2976
45a8e0051280
Optimized new tooltip, and fixed events on lazy loaded ones
Marcin Kuzminski <marcin@python-works.com>
parents:
2974
diff
changeset
|
600 |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
601 set_listeners: function(tt){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
602 YUE.on(tt, 'mouseover', yt.show_yuitip, tt); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
603 YUE.on(tt, 'mousemove', yt.move_yuitip, tt); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
604 YUE.on(tt, 'mouseout', yt.close_yuitip, tt); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
605 }, |
2971
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
606 |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
607 init: function(){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
608 yt.tipBox = yt.$('tip-box'); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
609 if(!yt.tipBox){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
610 yt.tipBox = document.createElement('div'); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
611 document.body.appendChild(yt.tipBox); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
612 yt.tipBox.id = 'tip-box'; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
613 } |
2971
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
614 |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
615 YUD.setStyle(yt.tipBox, 'display', 'none'); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
616 YUD.setStyle(yt.tipBox, 'position', 'absolute'); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
617 if(yt.maxWidth !== null){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
618 YUD.setStyle(yt.tipBox, 'max-width', yt.maxWidth+'px'); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
619 } |
2971
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
620 |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
621 var yuitips = YUD.getElementsByClassName('tooltip'); |
2971
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
622 |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
623 if(yt.add_links === true){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
624 var links = document.getElementsByTagName('a'); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
625 var linkLen = links.length; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
626 for(i=0;i<linkLen;i++){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
627 yuitips.push(links[i]); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
628 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
629 } |
2971
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
630 |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
631 var yuiLen = yuitips.length; |
2971
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
632 |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
633 for(i=0;i<yuiLen;i++){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
634 yt.set_listeners(yuitips[i]); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
635 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
636 }, |
2971
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
637 |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
638 show_yuitip: function(e, el){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
639 YUE.stopEvent(e); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
640 if(el.tagName.toLowerCase() === 'img'){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
641 yt.tipText = el.alt ? el.alt : ''; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
642 } else { |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
643 yt.tipText = el.title ? el.title : ''; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
644 } |
2971
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
645 |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
646 if(yt.tipText !== ''){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
647 // save org title |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
648 YUD.setAttribute(el, 'tt_title', yt.tipText); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
649 // reset title to not show org tooltips |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
650 YUD.setAttribute(el, 'title', ''); |
2971
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
651 |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
652 yt.tipBox.innerHTML = yt.tipText; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
653 YUD.setStyle(yt.tipBox, 'display', 'block'); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
654 if(yt.useAnim === true){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
655 YUD.setStyle(yt.tipBox, 'opacity', '0'); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
656 var newAnim = new YAHOO.util.Anim(yt.tipBox, |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
657 { |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
658 opacity: { to: yt.opacity } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
659 }, yt.speed, YAHOO.util.Easing.easeOut |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
660 ); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
661 newAnim.animate(); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
662 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
663 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
664 }, |
2971
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
665 |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
666 move_yuitip: function(e, el){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
667 YUE.stopEvent(e); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
668 var movePos = YUE.getXY(e); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
669 YUD.setStyle(yt.tipBox, 'top', (movePos[1] + yt.offset[1]) + 'px'); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
670 YUD.setStyle(yt.tipBox, 'left', (movePos[0] + yt.offset[0]) + 'px'); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
671 }, |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
672 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
673 close_yuitip: function(e, el){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
674 YUE.stopEvent(e); |
2971
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
675 |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
676 if(yt.useAnim === true){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
677 var newAnim = new YAHOO.util.Anim(yt.tipBox, |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
678 { |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
679 opacity: { to: 0 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
680 }, yt.speed, YAHOO.util.Easing.easeOut |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
681 ); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
682 newAnim.animate(); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
683 } else { |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
684 YUD.setStyle(yt.tipBox, 'display', 'none'); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
685 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
686 YUD.setAttribute(el,'title', YUD.getAttribute(el, 'tt_title')); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
687 } |
2971
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
688 } |
1653
b1e1dffd595c
one generic qfilter function.
Marcin Kuzminski <marcin@python-works.com>
parents:
1651
diff
changeset
|
689 |
b1e1dffd595c
one generic qfilter function.
Marcin Kuzminski <marcin@python-works.com>
parents:
1651
diff
changeset
|
690 /** |
b1e1dffd595c
one generic qfilter function.
Marcin Kuzminski <marcin@python-works.com>
parents:
1651
diff
changeset
|
691 * Quick filter widget |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
692 * |
1653
b1e1dffd595c
one generic qfilter function.
Marcin Kuzminski <marcin@python-works.com>
parents:
1651
diff
changeset
|
693 * @param target: filter input target |
b1e1dffd595c
one generic qfilter function.
Marcin Kuzminski <marcin@python-works.com>
parents:
1651
diff
changeset
|
694 * @param nodes: list of nodes in html we want to filter. |
b1e1dffd595c
one generic qfilter function.
Marcin Kuzminski <marcin@python-works.com>
parents:
1651
diff
changeset
|
695 * @param display_element function that takes current node from nodes and |
b1e1dffd595c
one generic qfilter function.
Marcin Kuzminski <marcin@python-works.com>
parents:
1651
diff
changeset
|
696 * does hide or show based on the node |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
697 * |
1653
b1e1dffd595c
one generic qfilter function.
Marcin Kuzminski <marcin@python-works.com>
parents:
1651
diff
changeset
|
698 */ |
b1e1dffd595c
one generic qfilter function.
Marcin Kuzminski <marcin@python-works.com>
parents:
1651
diff
changeset
|
699 var q_filter = function(target,nodes,display_element){ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
700 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
701 var nodes = nodes; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
702 var q_filter_field = YUD.get(target); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
703 var F = YAHOO.namespace(target); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
704 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
705 YUE.on(q_filter_field,'keyup',function(e){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
706 clearTimeout(F.filterTimeout); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
707 F.filterTimeout = setTimeout(F.updateFilter,600); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
708 }); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
709 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
710 F.filterTimeout = null; |
1653
b1e1dffd595c
one generic qfilter function.
Marcin Kuzminski <marcin@python-works.com>
parents:
1651
diff
changeset
|
711 |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
712 var show_node = function(node){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
713 YUD.setStyle(node,'display','') |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
714 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
715 var hide_node = function(node){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
716 YUD.setStyle(node,'display','none'); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
717 } |
1653
b1e1dffd595c
one generic qfilter function.
Marcin Kuzminski <marcin@python-works.com>
parents:
1651
diff
changeset
|
718 |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
719 F.updateFilter = function() { |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
720 // Reset timeout |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
721 F.filterTimeout = null; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
722 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
723 var obsolete = []; |
1653
b1e1dffd595c
one generic qfilter function.
Marcin Kuzminski <marcin@python-works.com>
parents:
1651
diff
changeset
|
724 |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
725 var req = q_filter_field.value.toLowerCase(); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
726 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
727 var l = nodes.length; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
728 var i; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
729 var showing = 0; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
730 |
1653
b1e1dffd595c
one generic qfilter function.
Marcin Kuzminski <marcin@python-works.com>
parents:
1651
diff
changeset
|
731 for (i=0;i<l;i++ ){ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
732 var n = nodes[i]; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
733 var target_element = display_element(n) |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
734 if(req && n.innerHTML.toLowerCase().indexOf(req) == -1){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
735 hide_node(target_element); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
736 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
737 else{ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
738 show_node(target_element); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
739 showing+=1; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
740 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
741 } |
1653
b1e1dffd595c
one generic qfilter function.
Marcin Kuzminski <marcin@python-works.com>
parents:
1651
diff
changeset
|
742 |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
743 // if repo_count is set update the number |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
744 var cnt = YUD.get('repo_count'); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
745 if(cnt){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
746 YUD.get('repo_count').innerHTML = showing; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
747 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
748 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
749 } |
1699
623b228cf325
cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents:
1685
diff
changeset
|
750 }; |
1653
b1e1dffd595c
one generic qfilter function.
Marcin Kuzminski <marcin@python-works.com>
parents:
1651
diff
changeset
|
751 |
2787
423a14349ef3
Don't use .innerHTML for tr field, I'm looking at you IE
Marcin Kuzminski <marcin@python-works.com>
parents:
2759
diff
changeset
|
752 var tableTr = function(cls, body){ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
753 var _el = document.createElement('div'); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
754 var cont = new YAHOO.util.Element(body); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
755 var comment_id = fromHTML(body).children[0].id.split('comment-')[1]; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
756 var id = 'comment-tr-{0}'.format(comment_id); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
757 var _html = ('<table><tbody><tr id="{0}" class="{1}">'+ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
758 '<td class="lineno-inline new-inline"></td>'+ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
759 '<td class="lineno-inline old-inline"></td>'+ |
2787
423a14349ef3
Don't use .innerHTML for tr field, I'm looking at you IE
Marcin Kuzminski <marcin@python-works.com>
parents:
2759
diff
changeset
|
760 '<td>{2}</td>'+ |
2789
d3e5c259fe71
Fixing inline comment for IE.
Marcin Kuzminski <marcin@python-works.com>
parents:
2787
diff
changeset
|
761 '</tr></tbody></table>').format(id, cls, body); |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
762 _el.innerHTML = _html; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
763 return _el.children[0].children[0].children[0]; |
1674
6f0143e5efe5
#71 code review
Marcin Kuzminski <marcin@python-works.com>
parents:
1667
diff
changeset
|
764 }; |
1653
b1e1dffd595c
one generic qfilter function.
Marcin Kuzminski <marcin@python-works.com>
parents:
1651
diff
changeset
|
765 |
1677
7276b170ce8b
#71 code-review
Marcin Kuzminski <marcin@python-works.com>
parents:
1674
diff
changeset
|
766 /** comments **/ |
7276b170ce8b
#71 code-review
Marcin Kuzminski <marcin@python-works.com>
parents:
1674
diff
changeset
|
767 var removeInlineForm = function(form) { |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
768 form.parentNode.removeChild(form); |
1699
623b228cf325
cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents:
1685
diff
changeset
|
769 }; |
1677
7276b170ce8b
#71 code-review
Marcin Kuzminski <marcin@python-works.com>
parents:
1674
diff
changeset
|
770 |
1682
1f2ba96de73e
#71 code review
Marcin Kuzminski <marcin@python-works.com>
parents:
1679
diff
changeset
|
771 var createInlineForm = function(parent_tr, f_path, line) { |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
772 var tmpl = YUD.get('comment-inline-form-template').innerHTML; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
773 tmpl = tmpl.format(f_path, line); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
774 var form = tableTr('comment-form-inline',tmpl) |
2787
423a14349ef3
Don't use .innerHTML for tr field, I'm looking at you IE
Marcin Kuzminski <marcin@python-works.com>
parents:
2759
diff
changeset
|
775 |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
776 // create event for hide button |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
777 form = new YAHOO.util.Element(form); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
778 var form_hide_button = new YAHOO.util.Element(YUD.getElementsByClassName('hide-inline-form',null,form)[0]); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
779 form_hide_button.on('click', function(e) { |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
780 var newtr = e.currentTarget.parentNode.parentNode.parentNode.parentNode.parentNode; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
781 if(YUD.hasClass(newtr.nextElementSibling,'inline-comments-button')){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
782 YUD.setStyle(newtr.nextElementSibling,'display',''); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
783 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
784 removeInlineForm(newtr); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
785 YUD.removeClass(parent_tr, 'form-open'); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
786 YUD.removeClass(parent_tr, 'hl-comment'); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
787 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
788 }); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
789 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
790 return form |
1699
623b228cf325
cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents:
1685
diff
changeset
|
791 }; |
2187
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
792 |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
793 /** |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
794 * Inject inline comment for on given TR this tr should be always an .line |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
795 * tr containing the line. Code will detect comment, and always put the comment |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
796 * block at the very bottom |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
797 */ |
1705
5e4827a8e942
added reply comment button on top of inline comments
Marcin Kuzminski <marcin@python-works.com>
parents:
1699
diff
changeset
|
798 var injectInlineForm = function(tr){ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
799 if(!YUD.hasClass(tr, 'line')){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
800 return |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
801 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
802 var submit_url = AJAX_COMMENT_URL; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
803 var _td = YUD.getElementsByClassName('code',null,tr)[0]; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
804 if(YUD.hasClass(tr,'form-open') || YUD.hasClass(tr,'context') || YUD.hasClass(_td,'no-comment')){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
805 return |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
806 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
807 YUD.addClass(tr,'form-open'); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
808 YUD.addClass(tr,'hl-comment'); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
809 var node = YUD.getElementsByClassName('full_f_path',null,tr.parentNode.parentNode.parentNode)[0]; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
810 var f_path = YUD.getAttribute(node,'path'); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
811 var lineno = getLineNo(tr); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
812 var form = createInlineForm(tr, f_path, lineno, submit_url); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
813 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
814 var parent = tr; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
815 while (1){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
816 var n = parent.nextElementSibling; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
817 // next element are comments ! |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
818 if(YUD.hasClass(n,'inline-comments')){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
819 parent = n; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
820 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
821 else{ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
822 break; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
823 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
824 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
825 YUD.insertAfter(form,parent); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
826 var f = YUD.get(form); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
827 var overlay = YUD.getElementsByClassName('overlay',null,f)[0]; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
828 var _form = YUD.getElementsByClassName('inline-form',null,f)[0]; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
829 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
830 YUE.on(YUD.get(_form), 'submit',function(e){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
831 YUE.preventDefault(e); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
832 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
833 //ajax submit |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
834 var text = YUD.get('text_'+lineno).value; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
835 var postData = { |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
836 'text':text, |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
837 'f_path':f_path, |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
838 'line':lineno |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
839 }; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
840 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
841 if(lineno === undefined){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
842 alert('missing line !'); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
843 return |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
844 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
845 if(f_path === undefined){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
846 alert('missing file path !'); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
847 return |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
848 } |
2187
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
849 |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
850 if(text == ""){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
851 return |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
852 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
853 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
854 var success = function(o){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
855 YUD.removeClass(tr, 'form-open'); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
856 removeInlineForm(f); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
857 var json_data = JSON.parse(o.responseText); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
858 renderInlineComment(json_data); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
859 }; |
3695
45df84d36b44
Implemented preview for comments
Marcin Kuzminski <marcin@python-works.com>
parents:
3665
diff
changeset
|
860 |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
861 if (YUD.hasClass(overlay,'overlay')){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
862 var w = _form.offsetWidth; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
863 var h = _form.offsetHeight; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
864 YUD.setStyle(overlay,'width',w+'px'); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
865 YUD.setStyle(overlay,'height',h+'px'); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
866 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
867 YUD.addClass(overlay, 'submitting'); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
868 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
869 ajaxPOST(submit_url, postData, success); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
870 }); |
3695
45df84d36b44
Implemented preview for comments
Marcin Kuzminski <marcin@python-works.com>
parents:
3665
diff
changeset
|
871 |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
872 YUE.on('preview-btn_'+lineno, 'click', function(e){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
873 var _text = YUD.get('text_'+lineno).value; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
874 if(!_text){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
875 return |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
876 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
877 var post_data = {'text': _text}; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
878 YUD.addClass('preview-box_'+lineno, 'unloaded'); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
879 YUD.get('preview-box_'+lineno).innerHTML = _TM['Loading ...']; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
880 YUD.setStyle('edit-container_'+lineno, 'display', 'none'); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
881 YUD.setStyle('preview-container_'+lineno, 'display', ''); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
882 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
883 var url = pyroutes.url('changeset_comment_preview', {'repo_name': REPO_NAME}); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
884 ajaxPOST(url,post_data,function(o){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
885 YUD.get('preview-box_'+lineno).innerHTML = o.responseText; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
886 YUD.removeClass('preview-box_'+lineno, 'unloaded'); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
887 }) |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
888 }) |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
889 YUE.on('edit-btn_'+lineno, 'click', function(e){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
890 YUD.setStyle('edit-container_'+lineno, 'display', ''); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
891 YUD.setStyle('preview-container_'+lineno, 'display', 'none'); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
892 }) |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
893 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
894 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
895 setTimeout(function(){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
896 // callbacks |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
897 tooltip_activate(); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
898 MentionsAutoComplete('text_'+lineno, 'mentions_container_'+lineno, |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
899 _USERS_AC_DATA, _GROUPS_AC_DATA); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
900 var _e = YUD.get('text_'+lineno); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
901 if(_e){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
902 _e.focus(); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
903 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
904 },10) |
1705
5e4827a8e942
added reply comment button on top of inline comments
Marcin Kuzminski <marcin@python-works.com>
parents:
1699
diff
changeset
|
905 }; |
5e4827a8e942
added reply comment button on top of inline comments
Marcin Kuzminski <marcin@python-works.com>
parents:
1699
diff
changeset
|
906 |
2187
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
907 var deleteComment = function(comment_id){ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
908 var url = AJAX_COMMENT_DELETE_URL.replace('__COMMENT_ID__',comment_id); |
2187
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
909 var postData = {'_method':'delete'}; |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
910 var success = function(o){ |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
911 var n = YUD.get('comment-tr-'+comment_id); |
2698
4debfe3b50be
ie8 fixes for inline comments :/
Marcin Kuzminski <marcin@python-works.com>
parents:
2694
diff
changeset
|
912 var root = prevElementSibling(prevElementSibling(n)); |
2187
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
913 n.parentNode.removeChild(n); |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
914 |
3695
45df84d36b44
Implemented preview for comments
Marcin Kuzminski <marcin@python-works.com>
parents:
3665
diff
changeset
|
915 // scann nodes, and attach add button to last one only for TR |
45df84d36b44
Implemented preview for comments
Marcin Kuzminski <marcin@python-works.com>
parents:
3665
diff
changeset
|
916 // which are the inline comments |
45df84d36b44
Implemented preview for comments
Marcin Kuzminski <marcin@python-works.com>
parents:
3665
diff
changeset
|
917 if(root && root.tagName == 'TR'){ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
918 placeAddButton(root); |
3695
45df84d36b44
Implemented preview for comments
Marcin Kuzminski <marcin@python-works.com>
parents:
3665
diff
changeset
|
919 } |
2187
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
920 } |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
921 ajaxPOST(url,postData,success); |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
922 } |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
923 |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
924 var createInlineAddButton = function(tr){ |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
925 |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
926 var label = TRANSLATION_MAP['Add another comment']; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
927 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
928 var html_el = document.createElement('div'); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
929 YUD.addClass(html_el, 'add-comment'); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
930 html_el.innerHTML = '<span class="ui-btn">{0}</span>'.format(label); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
931 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
932 var add = new YAHOO.util.Element(html_el); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
933 add.on('click', function(e) { |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
934 injectInlineForm(tr); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
935 }); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
936 return add; |
1705
5e4827a8e942
added reply comment button on top of inline comments
Marcin Kuzminski <marcin@python-works.com>
parents:
1699
diff
changeset
|
937 }; |
1699
623b228cf325
cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents:
1685
diff
changeset
|
938 |
1677
7276b170ce8b
#71 code-review
Marcin Kuzminski <marcin@python-works.com>
parents:
1674
diff
changeset
|
939 var getLineNo = function(tr) { |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
940 var line; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
941 var o = tr.children[0].id.split('_'); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
942 var n = tr.children[1].id.split('_'); |
1677
7276b170ce8b
#71 code-review
Marcin Kuzminski <marcin@python-works.com>
parents:
1674
diff
changeset
|
943 |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
944 if (n.length >= 2) { |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
945 line = n[n.length-1]; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
946 } else if (o.length >= 2) { |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
947 line = o[o.length-1]; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
948 } |
1677
7276b170ce8b
#71 code-review
Marcin Kuzminski <marcin@python-works.com>
parents:
1674
diff
changeset
|
949 |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
950 return line |
1699
623b228cf325
cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents:
1685
diff
changeset
|
951 }; |
623b228cf325
cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents:
1685
diff
changeset
|
952 |
2187
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
953 var placeAddButton = function(target_tr){ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
954 if(!target_tr){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
955 return |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
956 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
957 var last_node = target_tr; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
958 //scann |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
959 while (1){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
960 var n = last_node.nextElementSibling; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
961 // next element are comments ! |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
962 if(YUD.hasClass(n,'inline-comments')){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
963 last_node = n; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
964 //also remove the comment button from previous |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
965 var comment_add_buttons = YUD.getElementsByClassName('add-comment',null,last_node); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
966 for(var i=0;i<comment_add_buttons.length;i++){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
967 var b = comment_add_buttons[i]; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
968 b.parentNode.removeChild(b); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
969 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
970 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
971 else{ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
972 break; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
973 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
974 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
975 |
2187
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
976 var add = createInlineAddButton(target_tr); |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
977 // get the comment div |
2723
04aa0ea1ddd0
fixed comment addition and deletion functionality on IE9
Dies Koper <diesk@fast.au.fujitsu.com>
parents:
2699
diff
changeset
|
978 var comment_block = YUD.getElementsByClassName('comment',null,last_node)[0]; |
2187
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
979 // attach add button |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
980 YUD.insertAfter(add,comment_block); |
2187
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
981 } |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
982 |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
983 /** |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
984 * Places the inline comment into the changeset block in proper line position |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
985 */ |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
986 var placeInline = function(target_container,lineno,html){ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
987 var lineid = "{0}_{1}".format(target_container,lineno); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
988 var target_line = YUD.get(lineid); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
989 var comment = new YAHOO.util.Element(tableTr('inline-comments',html)) |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
990 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
991 // check if there are comments already ! |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
992 var parent = target_line.parentNode; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
993 var root_parent = parent; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
994 while (1){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
995 var n = parent.nextElementSibling; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
996 // next element are comments ! |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
997 if(YUD.hasClass(n,'inline-comments')){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
998 parent = n; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
999 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1000 else{ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1001 break; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1002 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1003 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1004 // put in the comment at the bottom |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1005 YUD.insertAfter(comment,parent); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1006 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1007 // scann nodes, and attach add button to last one |
2187
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
1008 placeAddButton(root_parent); |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
1009 |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1010 return target_line; |
2187
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
1011 } |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
1012 |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
1013 /** |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
1014 * make a single inline comment and place it inside |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
1015 */ |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
1016 var renderInlineComment = function(json_data){ |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
1017 try{ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1018 var html = json_data['rendered_text']; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1019 var lineno = json_data['line_no']; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1020 var target_id = json_data['target_id']; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1021 placeInline(target_id, lineno, html); |
2187
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
1022 |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
1023 }catch(e){ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1024 console.log(e); |
2187
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
1025 } |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
1026 } |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
1027 |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
1028 /** |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
1029 * Iterates over all the inlines, and places them inside proper blocks of data |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
1030 */ |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
1031 var renderInlineComments = function(file_comments){ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1032 for (f in file_comments){ |
2187
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
1033 // holding all comments for a FILE |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1034 var box = file_comments[f]; |
2187
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
1035 |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1036 var target_id = YUD.getAttribute(box,'target_id'); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1037 // actually comments with line numbers |
2187
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
1038 var comments = box.children; |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
1039 for(var i=0; i<comments.length; i++){ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1040 var data = { |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1041 'rendered_text': comments[i].outerHTML, |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1042 'line_no': YUD.getAttribute(comments[i],'line'), |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1043 'target_id': target_id |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1044 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1045 renderInlineComment(data); |
2187
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
1046 } |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1047 } |
2187
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
1048 } |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
1049 |
2428
530bd12fc18a
removed JSON array envelope from filter files function
Marcin Kuzminski <marcin@python-works.com>
parents:
2369
diff
changeset
|
1050 var fileBrowserListeners = function(current_url, node_list_url, url_base){ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1051 var current_url_branch = +"?branch=__BRANCH__"; |
1699
623b228cf325
cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents:
1685
diff
changeset
|
1052 |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1053 YUE.on('stay_at_branch','click',function(e){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1054 if(e.target.checked){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1055 var uri = current_url_branch; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1056 uri = uri.replace('__BRANCH__',e.target.value); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1057 window.location = uri; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1058 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1059 else{ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1060 window.location = current_url; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1061 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1062 }) |
1699
623b228cf325
cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents:
1685
diff
changeset
|
1063 |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1064 var n_filter = YUD.get('node_filter'); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1065 var F = YAHOO.namespace('node_filter'); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1066 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1067 F.filterTimeout = null; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1068 var nodes = null; |
1699
623b228cf325
cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents:
1685
diff
changeset
|
1069 |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1070 F.initFilter = function(){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1071 YUD.setStyle('node_filter_box_loading','display',''); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1072 YUD.setStyle('search_activate_id','display','none'); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1073 YUD.setStyle('add_node_id','display','none'); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1074 YUC.initHeader('X-PARTIAL-XHR',true); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1075 YUC.asyncRequest('GET', node_list_url, { |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1076 success:function(o){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1077 nodes = JSON.parse(o.responseText).nodes; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1078 YUD.setStyle('node_filter_box_loading','display','none'); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1079 YUD.setStyle('node_filter_box','display',''); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1080 n_filter.focus(); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1081 if(YUD.hasClass(n_filter,'init')){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1082 n_filter.value = ''; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1083 YUD.removeClass(n_filter,'init'); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1084 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1085 }, |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1086 failure:function(o){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1087 console.log('failed to load'); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1088 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1089 },null); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1090 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1091 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1092 F.updateFilter = function(e) { |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1093 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1094 return function(){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1095 // Reset timeout |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1096 F.filterTimeout = null; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1097 var query = e.target.value.toLowerCase(); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1098 var match = []; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1099 var matches = 0; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1100 var matches_max = 20; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1101 if (query != ""){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1102 for(var i=0;i<nodes.length;i++){ |
1699
623b228cf325
cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents:
1685
diff
changeset
|
1103 |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1104 var pos = nodes[i].name.toLowerCase().indexOf(query) |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1105 if(query && pos != -1){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1106 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1107 matches++ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1108 //show only certain amount to not kill browser |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1109 if (matches > matches_max){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1110 break; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1111 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1112 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1113 var n = nodes[i].name; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1114 var t = nodes[i].type; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1115 var n_hl = n.substring(0,pos) |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1116 +"<b>{0}</b>".format(n.substring(pos,pos+query.length)) |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1117 +n.substring(pos+query.length) |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1118 var new_url = url_base.replace('__FPATH__',n); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1119 match.push('<tr><td><a class="browser-{0}" href="{1}">{2}</a></td><td colspan="5"></td></tr>'.format(t,new_url,n_hl)); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1120 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1121 if(match.length >= matches_max){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1122 match.push('<tr><td>{0}</td><td colspan="5"></td></tr>'.format(_TM['Search truncated'])); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1123 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1124 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1125 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1126 if(query != ""){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1127 YUD.setStyle('tbody','display','none'); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1128 YUD.setStyle('tbody_filtered','display',''); |
1699
623b228cf325
cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents:
1685
diff
changeset
|
1129 |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1130 if (match.length==0){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1131 match.push('<tr><td>{0}</td><td colspan="5"></td></tr>'.format(_TM['No matching files'])); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1132 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1133 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1134 YUD.get('tbody_filtered').innerHTML = match.join(""); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1135 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1136 else{ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1137 YUD.setStyle('tbody','display',''); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1138 YUD.setStyle('tbody_filtered','display','none'); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1139 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1140 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1141 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1142 }; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1143 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1144 YUE.on(YUD.get('filter_activate'),'click',function(){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1145 F.initFilter(); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1146 }) |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1147 YUE.on(n_filter,'click',function(){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1148 if(YUD.hasClass(n_filter,'init')){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1149 n_filter.value = ''; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1150 YUD.removeClass(n_filter,'init'); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1151 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1152 }); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1153 YUE.on(n_filter,'keyup',function(e){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1154 clearTimeout(F.filterTimeout); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1155 F.filterTimeout = setTimeout(F.updateFilter(e),600); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1156 }); |
1699
623b228cf325
cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents:
1685
diff
changeset
|
1157 }; |
623b228cf325
cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents:
1685
diff
changeset
|
1158 |
623b228cf325
cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents:
1685
diff
changeset
|
1159 |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1160 var initCodeMirror = function(textAreadId,resetUrl){ |
1699
623b228cf325
cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents:
1685
diff
changeset
|
1161 var myCodeMirror = CodeMirror.fromTextArea(YUD.get(textAreadId),{ |
623b228cf325
cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents:
1685
diff
changeset
|
1162 mode: "null", |
4026
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
3966
diff
changeset
|
1163 lineNumbers:true, |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
3966
diff
changeset
|
1164 indentUnit: 4 |
1699
623b228cf325
cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents:
1685
diff
changeset
|
1165 }); |
623b228cf325
cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents:
1685
diff
changeset
|
1166 YUE.on('reset','click',function(e){ |
623b228cf325
cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents:
1685
diff
changeset
|
1167 window.location=resetUrl |
623b228cf325
cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents:
1685
diff
changeset
|
1168 }); |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1169 |
1699
623b228cf325
cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents:
1685
diff
changeset
|
1170 YUE.on('file_enable','click',function(){ |
623b228cf325
cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents:
1685
diff
changeset
|
1171 YUD.setStyle('editor_container','display',''); |
623b228cf325
cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents:
1685
diff
changeset
|
1172 YUD.setStyle('upload_file_container','display','none'); |
623b228cf325
cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents:
1685
diff
changeset
|
1173 YUD.setStyle('filename_container','display',''); |
623b228cf325
cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents:
1685
diff
changeset
|
1174 }); |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1175 |
1699
623b228cf325
cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents:
1685
diff
changeset
|
1176 YUE.on('upload_file_enable','click',function(){ |
623b228cf325
cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents:
1685
diff
changeset
|
1177 YUD.setStyle('editor_container','display','none'); |
623b228cf325
cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents:
1685
diff
changeset
|
1178 YUD.setStyle('upload_file_container','display',''); |
623b228cf325
cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents:
1685
diff
changeset
|
1179 YUD.setStyle('filename_container','display','none'); |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1180 }); |
4026
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
3966
diff
changeset
|
1181 |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
3966
diff
changeset
|
1182 return myCodeMirror |
1699
623b228cf325
cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents:
1685
diff
changeset
|
1183 }; |
623b228cf325
cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents:
1685
diff
changeset
|
1184 |
4026
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
3966
diff
changeset
|
1185 var setCodeMirrorMode = function(codeMirrorInstance, mode) { |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
3966
diff
changeset
|
1186 codeMirrorInstance.setOption("mode", mode); |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
3966
diff
changeset
|
1187 CodeMirror.autoLoadMode(codeMirrorInstance, mode); |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
3966
diff
changeset
|
1188 } |
1699
623b228cf325
cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents:
1685
diff
changeset
|
1189 |
623b228cf325
cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents:
1685
diff
changeset
|
1190 |
623b228cf325
cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents:
1685
diff
changeset
|
1191 var getIdentNode = function(n){ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1192 //iterate thru nodes untill matched interesting node ! |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1193 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1194 if (typeof n == 'undefined'){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1195 return -1 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1196 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1197 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1198 if(typeof n.id != "undefined" && n.id.match('L[0-9]+')){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1199 return n |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1200 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1201 else{ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1202 return getIdentNode(n.parentNode); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1203 } |
1699
623b228cf325
cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents:
1685
diff
changeset
|
1204 }; |
623b228cf325
cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents:
1685
diff
changeset
|
1205 |
3001
37c7abd34d44
implements #636, lazy loading of history and authors to speed up page responsiveness.
Marcin Kuzminski <marcin@python-works.com>
parents:
2979
diff
changeset
|
1206 var getSelectionLink = function(e) { |
3081
b2c7f7c5ce11
fixed source selection link pop-up tooltip
Marcin Kuzminski <marcin@python-works.com>
parents:
3066
diff
changeset
|
1207 |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1208 //get selection from start/to nodes |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1209 if (typeof window.getSelection != "undefined") { |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1210 s = window.getSelection(); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1211 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1212 from = getIdentNode(s.anchorNode); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1213 till = getIdentNode(s.focusNode); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1214 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1215 f_int = parseInt(from.id.replace('L','')); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1216 t_int = parseInt(till.id.replace('L','')); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1217 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1218 if (f_int > t_int){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1219 //highlight from bottom |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1220 offset = -35; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1221 ranges = [t_int,f_int]; |
3081
b2c7f7c5ce11
fixed source selection link pop-up tooltip
Marcin Kuzminski <marcin@python-works.com>
parents:
3066
diff
changeset
|
1222 |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1223 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1224 else{ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1225 //highligth from top |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1226 offset = 35; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1227 ranges = [f_int,t_int]; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1228 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1229 // if we select more than 2 lines |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1230 if (ranges[0] != ranges[1]){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1231 if(YUD.get('linktt') == null){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1232 hl_div = document.createElement('div'); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1233 hl_div.id = 'linktt'; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1234 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1235 hl_div.innerHTML = ''; |
3081
b2c7f7c5ce11
fixed source selection link pop-up tooltip
Marcin Kuzminski <marcin@python-works.com>
parents:
3066
diff
changeset
|
1236 |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1237 anchor = '#L'+ranges[0]+'-'+ranges[1]; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1238 var link = document.createElement('a'); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1239 link.href = location.href.substring(0,location.href.indexOf('#'))+anchor; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1240 link.innerHTML = _TM['Selection link']; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1241 hl_div.appendChild(link); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1242 YUD.get('body').appendChild(hl_div); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1243 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1244 xy = YUD.getXY(till.id); |
3081
b2c7f7c5ce11
fixed source selection link pop-up tooltip
Marcin Kuzminski <marcin@python-works.com>
parents:
3066
diff
changeset
|
1245 |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1246 YUD.addClass('linktt', 'hl-tip-box'); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1247 YUD.setStyle('linktt','top',xy[1]+offset+'px'); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1248 YUD.setStyle('linktt','left',xy[0]+'px'); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1249 YUD.setStyle('linktt','visibility','visible'); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1250 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1251 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1252 else{ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1253 YUD.setStyle('linktt','visibility','hidden'); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1254 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1255 } |
1699
623b228cf325
cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents:
1685
diff
changeset
|
1256 }; |
1712
cac5109ac3b6
Notification system improvements
Marcin Kuzminski <marcin@python-works.com>
parents:
1705
diff
changeset
|
1257 |
1717
7ff304d3028f
Notification fixes
Marcin Kuzminski <marcin@python-works.com>
parents:
1712
diff
changeset
|
1258 var deleteNotification = function(url, notification_id,callbacks){ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1259 var callback = { |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1260 success:function(o){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1261 var obj = YUD.get(String("notification_"+notification_id)); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1262 if(obj.parentNode !== undefined){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1263 obj.parentNode.removeChild(obj); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1264 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1265 _run_callbacks(callbacks); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1266 }, |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1267 failure:function(o){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1268 alert("error"); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1269 }, |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1270 }; |
1712
cac5109ac3b6
Notification system improvements
Marcin Kuzminski <marcin@python-works.com>
parents:
1705
diff
changeset
|
1271 var postData = '_method=delete'; |
cac5109ac3b6
Notification system improvements
Marcin Kuzminski <marcin@python-works.com>
parents:
1705
diff
changeset
|
1272 var sUrl = url.replace('__NOTIFICATION_ID__',notification_id); |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1273 var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1274 callback, postData); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1275 }; |
1778
defcf245f3e9
fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
1276 |
2610
3fdf7c3be2c9
added mark as read for single notifications
Marcin Kuzminski <marcin@python-works.com>
parents:
2608
diff
changeset
|
1277 var readNotification = function(url, notification_id,callbacks){ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1278 var callback = { |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1279 success:function(o){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1280 var obj = YUD.get(String("notification_"+notification_id)); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1281 YUD.removeClass(obj, 'unread'); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1282 var r_button = YUD.getElementsByClassName('read-notification',null,obj.children[0])[0]; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1283 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1284 if(r_button.parentNode !== undefined){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1285 r_button.parentNode.removeChild(r_button); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1286 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1287 _run_callbacks(callbacks); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1288 }, |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1289 failure:function(o){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1290 alert("error"); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1291 }, |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1292 }; |
2610
3fdf7c3be2c9
added mark as read for single notifications
Marcin Kuzminski <marcin@python-works.com>
parents:
2608
diff
changeset
|
1293 var postData = '_method=put'; |
3fdf7c3be2c9
added mark as read for single notifications
Marcin Kuzminski <marcin@python-works.com>
parents:
2608
diff
changeset
|
1294 var sUrl = url.replace('__NOTIFICATION_ID__',notification_id); |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1295 var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1296 callback, postData); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1297 }; |
1778
defcf245f3e9
fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
1298 |
2142
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1299 /** MEMBERS AUTOCOMPLETE WIDGET **/ |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1300 |
2759
c61c2ccea2b4
#538 form for permissions can handle multiple users at once
Marcin Kuzminski <marcin@python-works.com>
parents:
2723
diff
changeset
|
1301 var MembersAutoComplete = function (divid, cont, users_list, groups_list) { |
2142
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1302 var myUsers = users_list; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1303 var myGroups = groups_list; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1304 |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1305 // Define a custom search function for the DataSource of users |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1306 var matchUsers = function (sQuery) { |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1307 // Case insensitive matching |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1308 var query = sQuery.toLowerCase(); |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1309 var i = 0; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1310 var l = myUsers.length; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1311 var matches = []; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1312 |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1313 // Match against each name of each contact |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1314 for (; i < l; i++) { |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1315 contact = myUsers[i]; |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1316 if (((contact.fname+"").toLowerCase().indexOf(query) > -1) || |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1317 ((contact.lname+"").toLowerCase().indexOf(query) > -1) || |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1318 ((contact.nname) && ((contact.nname).toLowerCase().indexOf(query) > -1))) { |
2369
c2f131502037
Autocomplete fixes
Marcin Kuzminski <marcin@python-works.com>
parents:
2368
diff
changeset
|
1319 matches[matches.length] = contact; |
c2f131502037
Autocomplete fixes
Marcin Kuzminski <marcin@python-works.com>
parents:
2368
diff
changeset
|
1320 } |
2142
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1321 } |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1322 return matches; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1323 }; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1324 |
3417
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3403
diff
changeset
|
1325 // Define a custom search function for the DataSource of userGroups |
2142
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1326 var matchGroups = function (sQuery) { |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1327 // Case insensitive matching |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1328 var query = sQuery.toLowerCase(); |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1329 var i = 0; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1330 var l = myGroups.length; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1331 var matches = []; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1332 |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1333 // Match against each name of each contact |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1334 for (; i < l; i++) { |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1335 matched_group = myGroups[i]; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1336 if (matched_group.grname.toLowerCase().indexOf(query) > -1) { |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1337 matches[matches.length] = matched_group; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1338 } |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1339 } |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1340 return matches; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1341 }; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1342 |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1343 //match all |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1344 var matchAll = function (sQuery) { |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1345 u = matchUsers(sQuery); |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1346 g = matchGroups(sQuery); |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1347 return u.concat(g); |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1348 }; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1349 |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1350 // DataScheme for members |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1351 var memberDS = new YAHOO.util.FunctionDataSource(matchAll); |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1352 memberDS.responseSchema = { |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1353 fields: ["id", "fname", "lname", "nname", "grname", "grmembers", "gravatar_lnk"] |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1354 }; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1355 |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1356 // DataScheme for owner |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1357 var ownerDS = new YAHOO.util.FunctionDataSource(matchUsers); |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1358 ownerDS.responseSchema = { |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1359 fields: ["id", "fname", "lname", "nname", "gravatar_lnk"] |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1360 }; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1361 |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1362 // Instantiate AutoComplete for perms |
2759
c61c2ccea2b4
#538 form for permissions can handle multiple users at once
Marcin Kuzminski <marcin@python-works.com>
parents:
2723
diff
changeset
|
1363 var membersAC = new YAHOO.widget.AutoComplete(divid, cont, memberDS); |
2142
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1364 membersAC.useShadow = false; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1365 membersAC.resultTypeList = false; |
2611
e83be26bb8d8
disable animation on autocomplete widget
Marcin Kuzminski <marcin@python-works.com>
parents:
2610
diff
changeset
|
1366 membersAC.animVert = false; |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1367 membersAC.animHoriz = false; |
2611
e83be26bb8d8
disable animation on autocomplete widget
Marcin Kuzminski <marcin@python-works.com>
parents:
2610
diff
changeset
|
1368 membersAC.animSpeed = 0.1; |
2142
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1369 |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1370 // Instantiate AutoComplete for owner |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1371 var ownerAC = new YAHOO.widget.AutoComplete("user", "owner_container", ownerDS); |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1372 ownerAC.useShadow = false; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1373 ownerAC.resultTypeList = false; |
2611
e83be26bb8d8
disable animation on autocomplete widget
Marcin Kuzminski <marcin@python-works.com>
parents:
2610
diff
changeset
|
1374 ownerAC.animVert = false; |
e83be26bb8d8
disable animation on autocomplete widget
Marcin Kuzminski <marcin@python-works.com>
parents:
2610
diff
changeset
|
1375 ownerAC.animHoriz = false; |
e83be26bb8d8
disable animation on autocomplete widget
Marcin Kuzminski <marcin@python-works.com>
parents:
2610
diff
changeset
|
1376 ownerAC.animSpeed = 0.1; |
2142
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1377 |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1378 // Helper highlight function for the formatter |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1379 var highlightMatch = function (full, snippet, matchindex) { |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1380 return full.substring(0, matchindex) |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1381 + "<span class='match'>" |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1382 + full.substr(matchindex, snippet.length) |
2142
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1383 + "</span>" + full.substring(matchindex + snippet.length); |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1384 }; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1385 |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1386 // Custom formatter to highlight the matching letters |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1387 var custom_formatter = function (oResultData, sQuery, sResultMatch) { |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1388 var query = sQuery.toLowerCase(); |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1389 var _gravatar = function(res, em, group){ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1390 if (group !== undefined){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1391 em = '/images/icons/group.png' |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1392 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1393 tmpl = '<div class="ac-container-wrap"><img class="perm-gravatar-ac" src="{0}"/>{1}</div>' |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1394 return tmpl.format(em,res) |
2142
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1395 } |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1396 // group |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1397 if (oResultData.grname != undefined) { |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1398 var grname = oResultData.grname; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1399 var grmembers = oResultData.grmembers; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1400 var grnameMatchIndex = grname.toLowerCase().indexOf(query); |
2369
c2f131502037
Autocomplete fixes
Marcin Kuzminski <marcin@python-works.com>
parents:
2368
diff
changeset
|
1401 var grprefix = "{0}: ".format(_TM['Group']); |
2142
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1402 var grsuffix = " (" + grmembers + " )"; |
2369
c2f131502037
Autocomplete fixes
Marcin Kuzminski <marcin@python-works.com>
parents:
2368
diff
changeset
|
1403 var grsuffix = " ({0} {1})".format(grmembers, _TM['members']); |
2142
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1404 |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1405 if (grnameMatchIndex > -1) { |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1406 return _gravatar(grprefix + highlightMatch(grname, query, grnameMatchIndex) + grsuffix,null,true); |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1407 } |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1408 return _gravatar(grprefix + oResultData.grname + grsuffix, null,true); |
2142
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1409 // Users |
2369
c2f131502037
Autocomplete fixes
Marcin Kuzminski <marcin@python-works.com>
parents:
2368
diff
changeset
|
1410 } else if (oResultData.nname != undefined) { |
c2f131502037
Autocomplete fixes
Marcin Kuzminski <marcin@python-works.com>
parents:
2368
diff
changeset
|
1411 var fname = oResultData.fname || ""; |
c2f131502037
Autocomplete fixes
Marcin Kuzminski <marcin@python-works.com>
parents:
2368
diff
changeset
|
1412 var lname = oResultData.lname || ""; |
c2f131502037
Autocomplete fixes
Marcin Kuzminski <marcin@python-works.com>
parents:
2368
diff
changeset
|
1413 var nname = oResultData.nname; |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1414 |
2369
c2f131502037
Autocomplete fixes
Marcin Kuzminski <marcin@python-works.com>
parents:
2368
diff
changeset
|
1415 // Guard against null value |
c2f131502037
Autocomplete fixes
Marcin Kuzminski <marcin@python-works.com>
parents:
2368
diff
changeset
|
1416 var fnameMatchIndex = fname.toLowerCase().indexOf(query), |
2142
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1417 lnameMatchIndex = lname.toLowerCase().indexOf(query), |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1418 nnameMatchIndex = nname.toLowerCase().indexOf(query), |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1419 displayfname, displaylname, displaynname; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1420 |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1421 if (fnameMatchIndex > -1) { |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1422 displayfname = highlightMatch(fname, query, fnameMatchIndex); |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1423 } else { |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1424 displayfname = fname; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1425 } |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1426 |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1427 if (lnameMatchIndex > -1) { |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1428 displaylname = highlightMatch(lname, query, lnameMatchIndex); |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1429 } else { |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1430 displaylname = lname; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1431 } |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1432 |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1433 if (nnameMatchIndex > -1) { |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1434 displaynname = "(" + highlightMatch(nname, query, nnameMatchIndex) + ")"; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1435 } else { |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1436 displaynname = nname ? "(" + nname + ")" : ""; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1437 } |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1438 |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1439 return _gravatar(displayfname + " " + displaylname + " " + displaynname, oResultData.gravatar_lnk); |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1440 } else { |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1441 return ''; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1442 } |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1443 }; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1444 membersAC.formatResult = custom_formatter; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1445 ownerAC.formatResult = custom_formatter; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1446 |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1447 var myHandler = function (sType, aArgs) { |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1448 var nextId = divid.split('perm_new_member_name_')[1]; |
2142
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1449 var myAC = aArgs[0]; // reference back to the AC instance |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1450 var elLI = aArgs[1]; // reference to the selected LI element |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1451 var oData = aArgs[2]; // object literal of selected item's result data |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1452 //fill the autocomplete with value |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1453 if (oData.nname != undefined) { |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1454 //users |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1455 myAC.getInputEl().value = oData.nname; |
2759
c61c2ccea2b4
#538 form for permissions can handle multiple users at once
Marcin Kuzminski <marcin@python-works.com>
parents:
2723
diff
changeset
|
1456 YUD.get('perm_new_member_type_'+nextId).value = 'user'; |
2142
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1457 } else { |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1458 //groups |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1459 myAC.getInputEl().value = oData.grname; |
2759
c61c2ccea2b4
#538 form for permissions can handle multiple users at once
Marcin Kuzminski <marcin@python-works.com>
parents:
2723
diff
changeset
|
1460 YUD.get('perm_new_member_type_'+nextId).value = 'users_group'; |
2142
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1461 } |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1462 }; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1463 |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1464 membersAC.itemSelectEvent.subscribe(myHandler); |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1465 if(ownerAC.itemSelectEvent){ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1466 ownerAC.itemSelectEvent.subscribe(myHandler); |
2142
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1467 } |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1468 |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1469 return { |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1470 memberDS: memberDS, |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1471 ownerDS: ownerDS, |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1472 membersAC: membersAC, |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1473 ownerAC: ownerAC, |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1474 }; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1475 } |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1476 |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1477 |
2369
c2f131502037
Autocomplete fixes
Marcin Kuzminski <marcin@python-works.com>
parents:
2368
diff
changeset
|
1478 var MentionsAutoComplete = function (divid, cont, users_list, groups_list) { |
2368
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1479 var myUsers = users_list; |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1480 var myGroups = groups_list; |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1481 |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1482 // Define a custom search function for the DataSource of users |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1483 var matchUsers = function (sQuery) { |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1484 var org_sQuery = sQuery; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1485 if(this.mentionQuery == null){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1486 return [] |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1487 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1488 sQuery = this.mentionQuery; |
2368
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1489 // Case insensitive matching |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1490 var query = sQuery.toLowerCase(); |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1491 var i = 0; |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1492 var l = myUsers.length; |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1493 var matches = []; |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1494 |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1495 // Match against each name of each contact |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1496 for (; i < l; i++) { |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1497 contact = myUsers[i]; |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1498 if (((contact.fname+"").toLowerCase().indexOf(query) > -1) || |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1499 ((contact.lname+"").toLowerCase().indexOf(query) > -1) || |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1500 ((contact.nname) && ((contact.nname).toLowerCase().indexOf(query) > -1))) { |
2368
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1501 matches[matches.length] = contact; |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1502 } |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1503 } |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1504 return matches |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1505 }; |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1506 |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1507 //match all |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1508 var matchAll = function (sQuery) { |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1509 u = matchUsers(sQuery); |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1510 return u |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1511 }; |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1512 |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1513 // DataScheme for owner |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1514 var ownerDS = new YAHOO.util.FunctionDataSource(matchUsers); |
2369
c2f131502037
Autocomplete fixes
Marcin Kuzminski <marcin@python-works.com>
parents:
2368
diff
changeset
|
1515 |
2368
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1516 ownerDS.responseSchema = { |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1517 fields: ["id", "fname", "lname", "nname", "gravatar_lnk"] |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1518 }; |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1519 |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1520 // Instantiate AutoComplete for mentions |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1521 var ownerAC = new YAHOO.widget.AutoComplete(divid, cont, ownerDS); |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1522 ownerAC.useShadow = false; |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1523 ownerAC.resultTypeList = false; |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1524 ownerAC.suppressInputUpdate = true; |
2611
e83be26bb8d8
disable animation on autocomplete widget
Marcin Kuzminski <marcin@python-works.com>
parents:
2610
diff
changeset
|
1525 ownerAC.animVert = false; |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1526 ownerAC.animHoriz = false; |
2611
e83be26bb8d8
disable animation on autocomplete widget
Marcin Kuzminski <marcin@python-works.com>
parents:
2610
diff
changeset
|
1527 ownerAC.animSpeed = 0.1; |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1528 |
2368
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1529 // Helper highlight function for the formatter |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1530 var highlightMatch = function (full, snippet, matchindex) { |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1531 return full.substring(0, matchindex) |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1532 + "<span class='match'>" |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1533 + full.substr(matchindex, snippet.length) |
2368
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1534 + "</span>" + full.substring(matchindex + snippet.length); |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1535 }; |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1536 |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1537 // Custom formatter to highlight the matching letters |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1538 ownerAC.formatResult = function (oResultData, sQuery, sResultMatch) { |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1539 var org_sQuery = sQuery; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1540 if(this.dataSource.mentionQuery != null){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1541 sQuery = this.dataSource.mentionQuery; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1542 } |
2368
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1543 |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1544 var query = sQuery.toLowerCase(); |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1545 var _gravatar = function(res, em, group){ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1546 if (group !== undefined){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1547 em = '/images/icons/group.png' |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1548 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1549 tmpl = '<div class="ac-container-wrap"><img class="perm-gravatar-ac" src="{0}"/>{1}</div>' |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1550 return tmpl.format(em,res) |
2368
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1551 } |
2369
c2f131502037
Autocomplete fixes
Marcin Kuzminski <marcin@python-works.com>
parents:
2368
diff
changeset
|
1552 if (oResultData.nname != undefined) { |
c2f131502037
Autocomplete fixes
Marcin Kuzminski <marcin@python-works.com>
parents:
2368
diff
changeset
|
1553 var fname = oResultData.fname || ""; |
c2f131502037
Autocomplete fixes
Marcin Kuzminski <marcin@python-works.com>
parents:
2368
diff
changeset
|
1554 var lname = oResultData.lname || ""; |
c2f131502037
Autocomplete fixes
Marcin Kuzminski <marcin@python-works.com>
parents:
2368
diff
changeset
|
1555 var nname = oResultData.nname; |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1556 |
2369
c2f131502037
Autocomplete fixes
Marcin Kuzminski <marcin@python-works.com>
parents:
2368
diff
changeset
|
1557 // Guard against null value |
c2f131502037
Autocomplete fixes
Marcin Kuzminski <marcin@python-works.com>
parents:
2368
diff
changeset
|
1558 var fnameMatchIndex = fname.toLowerCase().indexOf(query), |
2368
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1559 lnameMatchIndex = lname.toLowerCase().indexOf(query), |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1560 nnameMatchIndex = nname.toLowerCase().indexOf(query), |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1561 displayfname, displaylname, displaynname; |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1562 |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1563 if (fnameMatchIndex > -1) { |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1564 displayfname = highlightMatch(fname, query, fnameMatchIndex); |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1565 } else { |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1566 displayfname = fname; |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1567 } |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1568 |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1569 if (lnameMatchIndex > -1) { |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1570 displaylname = highlightMatch(lname, query, lnameMatchIndex); |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1571 } else { |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1572 displaylname = lname; |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1573 } |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1574 |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1575 if (nnameMatchIndex > -1) { |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1576 displaynname = "(" + highlightMatch(nname, query, nnameMatchIndex) + ")"; |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1577 } else { |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1578 displaynname = nname ? "(" + nname + ")" : ""; |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1579 } |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1580 |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1581 return _gravatar(displayfname + " " + displaylname + " " + displaynname, oResultData.gravatar_lnk); |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1582 } else { |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1583 return ''; |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1584 } |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1585 }; |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1586 |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1587 if(ownerAC.itemSelectEvent){ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1588 ownerAC.itemSelectEvent.subscribe(function (sType, aArgs) { |
2368
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1589 |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1590 var myAC = aArgs[0]; // reference back to the AC instance |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1591 var elLI = aArgs[1]; // reference to the selected LI element |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1592 var oData = aArgs[2]; // object literal of selected item's result data |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1593 //fill the autocomplete with value |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1594 if (oData.nname != undefined) { |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1595 //users |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1596 //Replace the mention name with replaced |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1597 var re = new RegExp(); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1598 var org = myAC.getInputEl().value; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1599 var chunks = myAC.dataSource.chunks |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1600 // replace middle chunk(the search term) with actuall match |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1601 chunks[1] = chunks[1].replace('@'+myAC.dataSource.mentionQuery, |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1602 '@'+oData.nname+' '); |
2368
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1603 myAC.getInputEl().value = chunks.join('') |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1604 YUD.get(myAC.getInputEl()).focus(); // Y U NO WORK !? |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1605 } else { |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1606 //groups |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1607 myAC.getInputEl().value = oData.grname; |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1608 YUD.get('perm_new_member_type').value = 'users_group'; |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1609 } |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1610 }); |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1611 } |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1612 |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1613 // in this keybuffer we will gather current value of search ! |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1614 // since we need to get this just when someone does `@` then we do the |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1615 // search |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1616 ownerAC.dataSource.chunks = []; |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1617 ownerAC.dataSource.mentionQuery = null; |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1618 |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1619 ownerAC.get_mention = function(msg, max_pos) { |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1620 var org = msg; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1621 var re = new RegExp('(?:^@|\s@)([a-zA-Z0-9]{1}[a-zA-Z0-9\-\_\.]+)$') |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1622 var chunks = []; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1623 |
2368
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1624 |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1625 // cut first chunk until curret pos |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1626 var to_max = msg.substr(0, max_pos); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1627 var at_pos = Math.max(0,to_max.lastIndexOf('@')-1); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1628 var msg2 = to_max.substr(at_pos); |
2368
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1629 |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1630 chunks.push(org.substr(0,at_pos))// prefix chunk |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1631 chunks.push(msg2) // search chunk |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1632 chunks.push(org.substr(max_pos)) // postfix chunk |
2368
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1633 |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1634 // clean up msg2 for filtering and regex match |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1635 var msg2 = msg2.lstrip(' ').lstrip('\n'); |
2368
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1636 |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1637 if(re.test(msg2)){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1638 var unam = re.exec(msg2)[1]; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1639 return [unam, chunks]; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1640 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1641 return [null, null]; |
2612
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1642 }; |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1643 |
2698
4debfe3b50be
ie8 fixes for inline comments :/
Marcin Kuzminski <marcin@python-works.com>
parents:
2694
diff
changeset
|
1644 if (ownerAC.textboxKeyUpEvent){ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1645 ownerAC.textboxKeyUpEvent.subscribe(function(type, args){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1646 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1647 var ac_obj = args[0]; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1648 var currentMessage = args[1]; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1649 var currentCaretPosition = args[0]._elTextbox.selectionStart; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1650 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1651 var unam = ownerAC.get_mention(currentMessage, currentCaretPosition); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1652 var curr_search = null; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1653 if(unam[0]){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1654 curr_search = unam[0]; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1655 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1656 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1657 ownerAC.dataSource.chunks = unam[1]; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1658 ownerAC.dataSource.mentionQuery = curr_search; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1659 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1660 }) |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1661 } |
2368
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1662 return { |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1663 ownerDS: ownerDS, |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1664 ownerAC: ownerAC, |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1665 }; |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1666 } |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1667 |
3388
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
1668 var addReviewMember = function(id,fname,lname,nname,gravatar_link){ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1669 var members = YUD.get('review_members'); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1670 var tmpl = '<li id="reviewer_{2}">'+ |
3388
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
1671 '<div class="reviewers_member">'+ |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
1672 '<div class="gravatar"><img alt="gravatar" src="{0}"/> </div>'+ |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
1673 '<div style="float:left">{1}</div>'+ |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
1674 '<input type="hidden" value="{2}" name="review_members" />'+ |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
1675 '<span class="delete_icon action_button" onclick="removeReviewMember({2})"></span>'+ |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
1676 '</div>'+ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1677 '</li>' ; |
3388
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
1678 var displayname = "{0} {1} ({2})".format(fname,lname,nname); |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1679 var element = tmpl.format(gravatar_link,displayname,id); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1680 // check if we don't have this ID already in |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1681 var ids = []; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1682 var _els = YUQ('#review_members li'); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1683 for (el in _els){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1684 ids.push(_els[el].id) |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1685 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1686 if(ids.indexOf('reviewer_'+id) == -1){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1687 //only add if it's not there |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1688 members.innerHTML += element; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1689 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1690 |
3388
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
1691 } |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
1692 |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
1693 var removeReviewMember = function(reviewer_id, repo_name, pull_request_id){ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1694 var el = YUD.get('reviewer_{0}'.format(reviewer_id)); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1695 if (el.parentNode !== undefined){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1696 el.parentNode.removeChild(el); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1697 } |
3388
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
1698 } |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
1699 |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
1700 var updateReviewers = function(reviewers_ids, repo_name, pull_request_id){ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1701 if (reviewers_ids === undefined){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1702 var reviewers_ids = []; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1703 var ids = YUQ('#review_members input'); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1704 for(var i=0; i<ids.length;i++){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1705 var id = ids[i].value |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1706 reviewers_ids.push(id); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1707 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1708 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1709 var url = pyroutes.url('pullrequest_update', {"repo_name":repo_name, |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1710 "pull_request_id": pull_request_id}); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1711 var postData = {'_method':'put', |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1712 'reviewers_ids': reviewers_ids}; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1713 var success = function(o){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1714 window.location.reload(); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1715 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1716 ajaxPOST(url,postData,success); |
3388
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
1717 } |
2368
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1718 |
2612
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1719 var PullRequestAutoComplete = function (divid, cont, users_list, groups_list) { |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1720 var myUsers = users_list; |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1721 var myGroups = groups_list; |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1722 |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1723 // Define a custom search function for the DataSource of users |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1724 var matchUsers = function (sQuery) { |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1725 // Case insensitive matching |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1726 var query = sQuery.toLowerCase(); |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1727 var i = 0; |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1728 var l = myUsers.length; |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1729 var matches = []; |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1730 |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1731 // Match against each name of each contact |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1732 for (; i < l; i++) { |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1733 contact = myUsers[i]; |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1734 if (((contact.fname+"").toLowerCase().indexOf(query) > -1) || |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1735 ((contact.lname+"").toLowerCase().indexOf(query) > -1) || |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1736 ((contact.nname) && ((contact.nname).toLowerCase().indexOf(query) > -1))) { |
2612
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1737 matches[matches.length] = contact; |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1738 } |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1739 } |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1740 return matches; |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1741 }; |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1742 |
3417
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3403
diff
changeset
|
1743 // Define a custom search function for the DataSource of userGroups |
2612
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1744 var matchGroups = function (sQuery) { |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1745 // Case insensitive matching |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1746 var query = sQuery.toLowerCase(); |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1747 var i = 0; |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1748 var l = myGroups.length; |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1749 var matches = []; |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1750 |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1751 // Match against each name of each contact |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1752 for (; i < l; i++) { |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1753 matched_group = myGroups[i]; |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1754 if (matched_group.grname.toLowerCase().indexOf(query) > -1) { |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1755 matches[matches.length] = matched_group; |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1756 } |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1757 } |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1758 return matches; |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1759 }; |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1760 |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1761 //match all |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1762 var matchAll = function (sQuery) { |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1763 u = matchUsers(sQuery); |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1764 return u |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1765 }; |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1766 |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1767 // DataScheme for owner |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1768 var ownerDS = new YAHOO.util.FunctionDataSource(matchUsers); |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1769 |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1770 ownerDS.responseSchema = { |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1771 fields: ["id", "fname", "lname", "nname", "gravatar_lnk"] |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1772 }; |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1773 |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1774 // Instantiate AutoComplete for mentions |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1775 var reviewerAC = new YAHOO.widget.AutoComplete(divid, cont, ownerDS); |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1776 reviewerAC.useShadow = false; |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1777 reviewerAC.resultTypeList = false; |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1778 reviewerAC.suppressInputUpdate = true; |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1779 reviewerAC.animVert = false; |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1780 reviewerAC.animHoriz = false; |
2612
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1781 reviewerAC.animSpeed = 0.1; |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1782 |
2612
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1783 // Helper highlight function for the formatter |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1784 var highlightMatch = function (full, snippet, matchindex) { |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1785 return full.substring(0, matchindex) |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1786 + "<span class='match'>" |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1787 + full.substr(matchindex, snippet.length) |
2612
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1788 + "</span>" + full.substring(matchindex + snippet.length); |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1789 }; |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1790 |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1791 // Custom formatter to highlight the matching letters |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1792 reviewerAC.formatResult = function (oResultData, sQuery, sResultMatch) { |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1793 var org_sQuery = sQuery; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1794 if(this.dataSource.mentionQuery != null){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1795 sQuery = this.dataSource.mentionQuery; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1796 } |
2612
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1797 |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1798 var query = sQuery.toLowerCase(); |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1799 var _gravatar = function(res, em, group){ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1800 if (group !== undefined){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1801 em = '/images/icons/group.png' |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1802 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1803 tmpl = '<div class="ac-container-wrap"><img class="perm-gravatar-ac" src="{0}"/>{1}</div>' |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1804 return tmpl.format(em,res) |
2612
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1805 } |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1806 if (oResultData.nname != undefined) { |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1807 var fname = oResultData.fname || ""; |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1808 var lname = oResultData.lname || ""; |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1809 var nname = oResultData.nname; |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1810 |
2612
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1811 // Guard against null value |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1812 var fnameMatchIndex = fname.toLowerCase().indexOf(query), |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1813 lnameMatchIndex = lname.toLowerCase().indexOf(query), |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1814 nnameMatchIndex = nname.toLowerCase().indexOf(query), |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1815 displayfname, displaylname, displaynname; |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1816 |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1817 if (fnameMatchIndex > -1) { |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1818 displayfname = highlightMatch(fname, query, fnameMatchIndex); |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1819 } else { |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1820 displayfname = fname; |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1821 } |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1822 |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1823 if (lnameMatchIndex > -1) { |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1824 displaylname = highlightMatch(lname, query, lnameMatchIndex); |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1825 } else { |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1826 displaylname = lname; |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1827 } |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1828 |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1829 if (nnameMatchIndex > -1) { |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1830 displaynname = "(" + highlightMatch(nname, query, nnameMatchIndex) + ")"; |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1831 } else { |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1832 displaynname = nname ? "(" + nname + ")" : ""; |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1833 } |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1834 |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1835 return _gravatar(displayfname + " " + displaylname + " " + displaynname, oResultData.gravatar_lnk); |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1836 } else { |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1837 return ''; |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1838 } |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1839 }; |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1840 |
2612
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1841 //members cache to catch duplicates |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1842 reviewerAC.dataSource.cache = []; |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1843 // hack into select event |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1844 if(reviewerAC.itemSelectEvent){ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1845 reviewerAC.itemSelectEvent.subscribe(function (sType, aArgs) { |
2612
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1846 |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1847 var myAC = aArgs[0]; // reference back to the AC instance |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1848 var elLI = aArgs[1]; // reference to the selected LI element |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1849 var oData = aArgs[2]; // object literal of selected item's result data |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1850 |
2612
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1851 //fill the autocomplete with value |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1852 |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1853 if (oData.nname != undefined) { |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1854 addReviewMember(oData.id, oData.fname, oData.lname, oData.nname, |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1855 oData.gravatar_lnk); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1856 myAC.dataSource.cache.push(oData.id); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1857 YUD.get('user').value = '' |
2612
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1858 } |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1859 }); |
2612
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1860 } |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1861 return { |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1862 ownerDS: ownerDS, |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1863 reviewerAC: reviewerAC, |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1864 }; |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1865 } |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1866 |
1778
defcf245f3e9
fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
1867 /** |
1779
9edd6ac132f0
Added sorting into journal and admin pages
Marcin Kuzminski <marcin@python-works.com>
parents:
1778
diff
changeset
|
1868 * QUICK REPO MENU |
9edd6ac132f0
Added sorting into journal and admin pages
Marcin Kuzminski <marcin@python-works.com>
parents:
1778
diff
changeset
|
1869 */ |
9edd6ac132f0
Added sorting into journal and admin pages
Marcin Kuzminski <marcin@python-works.com>
parents:
1778
diff
changeset
|
1870 var quick_repo_menu = function(){ |
2088
382df4e69dfc
quick_repo_menu changed from mouseclick to popup
Marcin Kuzminski <marcin@python-works.com>
parents:
2087
diff
changeset
|
1871 YUE.on(YUQ('.quick_repo_menu'),'mouseenter',function(e){ |
382df4e69dfc
quick_repo_menu changed from mouseclick to popup
Marcin Kuzminski <marcin@python-works.com>
parents:
2087
diff
changeset
|
1872 var menu = e.currentTarget.firstElementChild.firstElementChild; |
382df4e69dfc
quick_repo_menu changed from mouseclick to popup
Marcin Kuzminski <marcin@python-works.com>
parents:
2087
diff
changeset
|
1873 if(YUD.hasClass(menu,'hidden')){ |
382df4e69dfc
quick_repo_menu changed from mouseclick to popup
Marcin Kuzminski <marcin@python-works.com>
parents:
2087
diff
changeset
|
1874 YUD.replaceClass(e.currentTarget,'hidden', 'active'); |
382df4e69dfc
quick_repo_menu changed from mouseclick to popup
Marcin Kuzminski <marcin@python-works.com>
parents:
2087
diff
changeset
|
1875 YUD.replaceClass(menu, 'hidden', 'active'); |
382df4e69dfc
quick_repo_menu changed from mouseclick to popup
Marcin Kuzminski <marcin@python-works.com>
parents:
2087
diff
changeset
|
1876 } |
382df4e69dfc
quick_repo_menu changed from mouseclick to popup
Marcin Kuzminski <marcin@python-works.com>
parents:
2087
diff
changeset
|
1877 }) |
382df4e69dfc
quick_repo_menu changed from mouseclick to popup
Marcin Kuzminski <marcin@python-works.com>
parents:
2087
diff
changeset
|
1878 YUE.on(YUQ('.quick_repo_menu'),'mouseleave',function(e){ |
382df4e69dfc
quick_repo_menu changed from mouseclick to popup
Marcin Kuzminski <marcin@python-works.com>
parents:
2087
diff
changeset
|
1879 var menu = e.currentTarget.firstElementChild.firstElementChild; |
382df4e69dfc
quick_repo_menu changed from mouseclick to popup
Marcin Kuzminski <marcin@python-works.com>
parents:
2087
diff
changeset
|
1880 if(YUD.hasClass(menu,'active')){ |
382df4e69dfc
quick_repo_menu changed from mouseclick to popup
Marcin Kuzminski <marcin@python-works.com>
parents:
2087
diff
changeset
|
1881 YUD.replaceClass(e.currentTarget, 'active', 'hidden'); |
382df4e69dfc
quick_repo_menu changed from mouseclick to popup
Marcin Kuzminski <marcin@python-works.com>
parents:
2087
diff
changeset
|
1882 YUD.replaceClass(menu, 'active', 'hidden'); |
382df4e69dfc
quick_repo_menu changed from mouseclick to popup
Marcin Kuzminski <marcin@python-works.com>
parents:
2087
diff
changeset
|
1883 } |
382df4e69dfc
quick_repo_menu changed from mouseclick to popup
Marcin Kuzminski <marcin@python-works.com>
parents:
2087
diff
changeset
|
1884 }) |
1779
9edd6ac132f0
Added sorting into journal and admin pages
Marcin Kuzminski <marcin@python-works.com>
parents:
1778
diff
changeset
|
1885 }; |
9edd6ac132f0
Added sorting into journal and admin pages
Marcin Kuzminski <marcin@python-works.com>
parents:
1778
diff
changeset
|
1886 |
9edd6ac132f0
Added sorting into journal and admin pages
Marcin Kuzminski <marcin@python-works.com>
parents:
1778
diff
changeset
|
1887 |
9edd6ac132f0
Added sorting into journal and admin pages
Marcin Kuzminski <marcin@python-works.com>
parents:
1778
diff
changeset
|
1888 /** |
1778
defcf245f3e9
fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
1889 * TABLE SORTING |
defcf245f3e9
fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
1890 */ |
defcf245f3e9
fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
1891 |
defcf245f3e9
fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
1892 // returns a node from given html; |
defcf245f3e9
fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
1893 var fromHTML = function(html){ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1894 var _html = document.createElement('element'); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1895 _html.innerHTML = html; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1896 return _html; |
1778
defcf245f3e9
fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
1897 } |
defcf245f3e9
fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
1898 var get_rev = function(node){ |
defcf245f3e9
fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
1899 var n = node.firstElementChild.firstElementChild; |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1900 |
1778
defcf245f3e9
fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
1901 if (n===null){ |
defcf245f3e9
fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
1902 return -1 |
defcf245f3e9
fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
1903 } |
defcf245f3e9
fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
1904 else{ |
defcf245f3e9
fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
1905 out = n.firstElementChild.innerHTML.split(':')[0].replace('r',''); |
defcf245f3e9
fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
1906 return parseInt(out); |
defcf245f3e9
fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
1907 } |
defcf245f3e9
fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
1908 } |
defcf245f3e9
fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
1909 |
defcf245f3e9
fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
1910 var get_name = function(node){ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1911 var name = node.firstElementChild.children[2].innerHTML; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1912 return name |
1778
defcf245f3e9
fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
1913 } |
defcf245f3e9
fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
1914 var get_group_name = function(node){ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1915 var name = node.firstElementChild.children[1].innerHTML; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1916 return name |
1778
defcf245f3e9
fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
1917 } |
1782
eaf09acf6872
added sorting to bookmarks tags and branches
Marcin Kuzminski <marcin@python-works.com>
parents:
1779
diff
changeset
|
1918 var get_date = function(node){ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1919 var date_ = YUD.getAttribute(node.firstElementChild,'date'); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1920 return date_ |
1782
eaf09acf6872
added sorting to bookmarks tags and branches
Marcin Kuzminski <marcin@python-works.com>
parents:
1779
diff
changeset
|
1921 } |
eaf09acf6872
added sorting to bookmarks tags and branches
Marcin Kuzminski <marcin@python-works.com>
parents:
1779
diff
changeset
|
1922 |
2548
0ff919f1c283
Fixed sorting by data when using custom date format from settings
Marcin Kuzminski <marcin@python-works.com>
parents:
2441
diff
changeset
|
1923 var get_age = function(node){ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1924 return node |
2548
0ff919f1c283
Fixed sorting by data when using custom date format from settings
Marcin Kuzminski <marcin@python-works.com>
parents:
2441
diff
changeset
|
1925 } |
0ff919f1c283
Fixed sorting by data when using custom date format from settings
Marcin Kuzminski <marcin@python-works.com>
parents:
2441
diff
changeset
|
1926 |
2658
80d837028c40
implemented admin panel Users table with YUI datatable
Marcin Kuzminski <marcin@python-works.com>
parents:
2614
diff
changeset
|
1927 var get_link = function(node){ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1928 return node.firstElementChild.text; |
2658
80d837028c40
implemented admin panel Users table with YUI datatable
Marcin Kuzminski <marcin@python-works.com>
parents:
2614
diff
changeset
|
1929 } |
80d837028c40
implemented admin panel Users table with YUI datatable
Marcin Kuzminski <marcin@python-works.com>
parents:
2614
diff
changeset
|
1930 |
1778
defcf245f3e9
fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
1931 var revisionSort = function(a, b, desc, field) { |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1932 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1933 var a_ = fromHTML(a.getData(field)); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1934 var b_ = fromHTML(b.getData(field)); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1935 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1936 // extract revisions from string nodes |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1937 a_ = get_rev(a_) |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1938 b_ = get_rev(b_) |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1939 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1940 var comp = YAHOO.util.Sort.compare; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1941 var compState = comp(a_, b_, desc); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1942 return compState; |
1778
defcf245f3e9
fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
1943 }; |
defcf245f3e9
fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
1944 var ageSort = function(a, b, desc, field) { |
2548
0ff919f1c283
Fixed sorting by data when using custom date format from settings
Marcin Kuzminski <marcin@python-works.com>
parents:
2441
diff
changeset
|
1945 var a_ = fromHTML(a.getData(field)); |
0ff919f1c283
Fixed sorting by data when using custom date format from settings
Marcin Kuzminski <marcin@python-works.com>
parents:
2441
diff
changeset
|
1946 var b_ = fromHTML(b.getData(field)); |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1947 |
2548
0ff919f1c283
Fixed sorting by data when using custom date format from settings
Marcin Kuzminski <marcin@python-works.com>
parents:
2441
diff
changeset
|
1948 // extract name from table |
0ff919f1c283
Fixed sorting by data when using custom date format from settings
Marcin Kuzminski <marcin@python-works.com>
parents:
2441
diff
changeset
|
1949 a_ = get_date(a_) |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1950 b_ = get_date(b_) |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1951 |
1778
defcf245f3e9
fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
1952 var comp = YAHOO.util.Sort.compare; |
defcf245f3e9
fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
1953 var compState = comp(a_, b_, desc); |
defcf245f3e9
fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
1954 return compState; |
defcf245f3e9
fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
1955 }; |
defcf245f3e9
fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
1956 |
2699
4eef5eeb81a3
fixed sorting by last_login in users admin page
Marcin Kuzminski <marcin@python-works.com>
parents:
2698
diff
changeset
|
1957 var lastLoginSort = function(a, b, desc, field) { |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1958 var a_ = a.getData('last_login_raw') || 0; |
2699
4eef5eeb81a3
fixed sorting by last_login in users admin page
Marcin Kuzminski <marcin@python-works.com>
parents:
2698
diff
changeset
|
1959 var b_ = b.getData('last_login_raw') || 0; |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1960 |
2699
4eef5eeb81a3
fixed sorting by last_login in users admin page
Marcin Kuzminski <marcin@python-works.com>
parents:
2698
diff
changeset
|
1961 var comp = YAHOO.util.Sort.compare; |
4eef5eeb81a3
fixed sorting by last_login in users admin page
Marcin Kuzminski <marcin@python-works.com>
parents:
2698
diff
changeset
|
1962 var compState = comp(a_, b_, desc); |
4eef5eeb81a3
fixed sorting by last_login in users admin page
Marcin Kuzminski <marcin@python-works.com>
parents:
2698
diff
changeset
|
1963 return compState; |
4eef5eeb81a3
fixed sorting by last_login in users admin page
Marcin Kuzminski <marcin@python-works.com>
parents:
2698
diff
changeset
|
1964 }; |
4eef5eeb81a3
fixed sorting by last_login in users admin page
Marcin Kuzminski <marcin@python-works.com>
parents:
2698
diff
changeset
|
1965 |
1778
defcf245f3e9
fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
1966 var nameSort = function(a, b, desc, field) { |
4087
182a25646cf4
change repo sorting to raw_nam so it's UI independent
Marcin Kuzminski <marcin@python-works.com>
parents:
4026
diff
changeset
|
1967 var a_ = a.getData('raw_name') || 0; |
182a25646cf4
change repo sorting to raw_nam so it's UI independent
Marcin Kuzminski <marcin@python-works.com>
parents:
4026
diff
changeset
|
1968 var b_ = b.getData('raw_name') || 0; |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1969 |
1778
defcf245f3e9
fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
1970 var comp = YAHOO.util.Sort.compare; |
defcf245f3e9
fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
1971 var compState = comp(a_, b_, desc); |
defcf245f3e9
fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
1972 return compState; |
defcf245f3e9
fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
1973 }; |
defcf245f3e9
fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
1974 |
2127
b745d5d2563c
implemented #377 Users view own permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
2088
diff
changeset
|
1975 var permNameSort = function(a, b, desc, field) { |
b745d5d2563c
implemented #377 Users view own permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
2088
diff
changeset
|
1976 var a_ = fromHTML(a.getData(field)); |
b745d5d2563c
implemented #377 Users view own permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
2088
diff
changeset
|
1977 var b_ = fromHTML(b.getData(field)); |
b745d5d2563c
implemented #377 Users view own permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
2088
diff
changeset
|
1978 // extract name from table |
2128
e29c688e6885
linkify perms and make global ones display better
Marcin Kuzminski <marcin@python-works.com>
parents:
2127
diff
changeset
|
1979 |
e29c688e6885
linkify perms and make global ones display better
Marcin Kuzminski <marcin@python-works.com>
parents:
2127
diff
changeset
|
1980 a_ = a_.children[0].innerHTML; |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1981 b_ = b_.children[0].innerHTML; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1982 |
2127
b745d5d2563c
implemented #377 Users view own permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
2088
diff
changeset
|
1983 var comp = YAHOO.util.Sort.compare; |
b745d5d2563c
implemented #377 Users view own permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
2088
diff
changeset
|
1984 var compState = comp(a_, b_, desc); |
b745d5d2563c
implemented #377 Users view own permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
2088
diff
changeset
|
1985 return compState; |
b745d5d2563c
implemented #377 Users view own permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
2088
diff
changeset
|
1986 }; |
b745d5d2563c
implemented #377 Users view own permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
2088
diff
changeset
|
1987 |
1778
defcf245f3e9
fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
1988 var groupNameSort = function(a, b, desc, field) { |
defcf245f3e9
fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
1989 var a_ = fromHTML(a.getData(field)); |
defcf245f3e9
fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
1990 var b_ = fromHTML(b.getData(field)); |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1991 |
1778
defcf245f3e9
fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
1992 // extract name from table |
defcf245f3e9
fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
1993 a_ = get_group_name(a_) |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1994 b_ = get_group_name(b_) |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1995 |
1778
defcf245f3e9
fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
1996 var comp = YAHOO.util.Sort.compare; |
defcf245f3e9
fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
1997 var compState = comp(a_, b_, desc); |
defcf245f3e9
fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
1998 return compState; |
1782
eaf09acf6872
added sorting to bookmarks tags and branches
Marcin Kuzminski <marcin@python-works.com>
parents:
1779
diff
changeset
|
1999 }; |
eaf09acf6872
added sorting to bookmarks tags and branches
Marcin Kuzminski <marcin@python-works.com>
parents:
1779
diff
changeset
|
2000 var dateSort = function(a, b, desc, field) { |
eaf09acf6872
added sorting to bookmarks tags and branches
Marcin Kuzminski <marcin@python-works.com>
parents:
1779
diff
changeset
|
2001 var a_ = fromHTML(a.getData(field)); |
eaf09acf6872
added sorting to bookmarks tags and branches
Marcin Kuzminski <marcin@python-works.com>
parents:
1779
diff
changeset
|
2002 var b_ = fromHTML(b.getData(field)); |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2003 |
1782
eaf09acf6872
added sorting to bookmarks tags and branches
Marcin Kuzminski <marcin@python-works.com>
parents:
1779
diff
changeset
|
2004 // extract name from table |
eaf09acf6872
added sorting to bookmarks tags and branches
Marcin Kuzminski <marcin@python-works.com>
parents:
1779
diff
changeset
|
2005 a_ = get_date(a_) |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2006 b_ = get_date(b_) |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2007 |
1782
eaf09acf6872
added sorting to bookmarks tags and branches
Marcin Kuzminski <marcin@python-works.com>
parents:
1779
diff
changeset
|
2008 var comp = YAHOO.util.Sort.compare; |
eaf09acf6872
added sorting to bookmarks tags and branches
Marcin Kuzminski <marcin@python-works.com>
parents:
1779
diff
changeset
|
2009 var compState = comp(a_, b_, desc); |
eaf09acf6872
added sorting to bookmarks tags and branches
Marcin Kuzminski <marcin@python-works.com>
parents:
1779
diff
changeset
|
2010 return compState; |
2394
6776f4e569d7
Moved select widget to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
2369
diff
changeset
|
2011 }; |
6776f4e569d7
Moved select widget to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
2369
diff
changeset
|
2012 |
3638
dddf48cd1eb9
fixed users sorting in admin pannel
Marcin Kuzminski <marcin@python-works.com>
parents:
3622
diff
changeset
|
2013 var usernamelinkSort = function(a, b, desc, field) { |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2014 var a_ = fromHTML(a.getData(field)); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2015 var b_ = fromHTML(b.getData(field)); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2016 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2017 // extract url text from string nodes |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2018 a_ = get_link(a_) |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2019 b_ = get_link(b_) |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2020 var comp = YAHOO.util.Sort.compare; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2021 var compState = comp(a_, b_, desc); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2022 return compState; |
2658
80d837028c40
implemented admin panel Users table with YUI datatable
Marcin Kuzminski <marcin@python-works.com>
parents:
2614
diff
changeset
|
2023 } |
2394
6776f4e569d7
Moved select widget to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
2369
diff
changeset
|
2024 |
2759
c61c2ccea2b4
#538 form for permissions can handle multiple users at once
Marcin Kuzminski <marcin@python-works.com>
parents:
2723
diff
changeset
|
2025 var addPermAction = function(_html, users_list, groups_list){ |
c61c2ccea2b4
#538 form for permissions can handle multiple users at once
Marcin Kuzminski <marcin@python-works.com>
parents:
2723
diff
changeset
|
2026 var elmts = YUD.getElementsByClassName('last_new_member'); |
c61c2ccea2b4
#538 form for permissions can handle multiple users at once
Marcin Kuzminski <marcin@python-works.com>
parents:
2723
diff
changeset
|
2027 var last_node = elmts[elmts.length-1]; |
c61c2ccea2b4
#538 form for permissions can handle multiple users at once
Marcin Kuzminski <marcin@python-works.com>
parents:
2723
diff
changeset
|
2028 if (last_node){ |
c61c2ccea2b4
#538 form for permissions can handle multiple users at once
Marcin Kuzminski <marcin@python-works.com>
parents:
2723
diff
changeset
|
2029 var next_id = (YUD.getElementsByClassName('new_members')).length; |
c61c2ccea2b4
#538 form for permissions can handle multiple users at once
Marcin Kuzminski <marcin@python-works.com>
parents:
2723
diff
changeset
|
2030 _html = _html.format(next_id); |
c61c2ccea2b4
#538 form for permissions can handle multiple users at once
Marcin Kuzminski <marcin@python-works.com>
parents:
2723
diff
changeset
|
2031 last_node.innerHTML = _html; |
c61c2ccea2b4
#538 form for permissions can handle multiple users at once
Marcin Kuzminski <marcin@python-works.com>
parents:
2723
diff
changeset
|
2032 YUD.setStyle(last_node, 'display', ''); |
c61c2ccea2b4
#538 form for permissions can handle multiple users at once
Marcin Kuzminski <marcin@python-works.com>
parents:
2723
diff
changeset
|
2033 YUD.removeClass(last_node, 'last_new_member'); |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2034 MembersAutoComplete("perm_new_member_name_"+next_id, |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2035 "perm_container_"+next_id, users_list, groups_list); |
2759
c61c2ccea2b4
#538 form for permissions can handle multiple users at once
Marcin Kuzminski <marcin@python-works.com>
parents:
2723
diff
changeset
|
2036 //create new last NODE |
c61c2ccea2b4
#538 form for permissions can handle multiple users at once
Marcin Kuzminski <marcin@python-works.com>
parents:
2723
diff
changeset
|
2037 var el = document.createElement('tr'); |
c61c2ccea2b4
#538 form for permissions can handle multiple users at once
Marcin Kuzminski <marcin@python-works.com>
parents:
2723
diff
changeset
|
2038 el.id = 'add_perm_input'; |
c61c2ccea2b4
#538 form for permissions can handle multiple users at once
Marcin Kuzminski <marcin@python-works.com>
parents:
2723
diff
changeset
|
2039 YUD.addClass(el,'last_new_member'); |
c61c2ccea2b4
#538 form for permissions can handle multiple users at once
Marcin Kuzminski <marcin@python-works.com>
parents:
2723
diff
changeset
|
2040 YUD.addClass(el,'new_members'); |
c61c2ccea2b4
#538 form for permissions can handle multiple users at once
Marcin Kuzminski <marcin@python-works.com>
parents:
2723
diff
changeset
|
2041 YUD.insertAfter(el, last_node); |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2042 } |
2759
c61c2ccea2b4
#538 form for permissions can handle multiple users at once
Marcin Kuzminski <marcin@python-works.com>
parents:
2723
diff
changeset
|
2043 } |
3715
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
2044 function ajaxActionRevokePermission(url, obj_id, obj_type, field_id, extra_data) { |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
2045 var callback = { |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
2046 success: function (o) { |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
2047 var tr = YUD.get(String(field_id)); |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
2048 tr.parentNode.removeChild(tr); |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
2049 }, |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
2050 failure: function (o) { |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
2051 alert(_TM['Failed to remoke permission'] + ": " + o.status); |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
2052 }, |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
2053 }; |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
2054 query_params = { |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
2055 '_method': 'delete' |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
2056 } |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
2057 // put extra data into POST |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
2058 if (extra_data !== undefined && (typeof extra_data === 'object')){ |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
2059 for(k in extra_data){ |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
2060 query_params[k] = extra_data[k]; |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
2061 } |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
2062 } |
2394
6776f4e569d7
Moved select widget to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
2369
diff
changeset
|
2063 |
3715
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
2064 if (obj_type=='user'){ |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
2065 query_params['user_id'] = obj_id; |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
2066 query_params['obj_type'] = 'user'; |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
2067 } |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
2068 else if (obj_type=='user_group'){ |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
2069 query_params['user_group_id'] = obj_id; |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
2070 query_params['obj_type'] = 'user_group'; |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
2071 } |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
2072 |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
2073 var request = YAHOO.util.Connect.asyncRequest('POST', url, callback, |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
2074 toQueryString(query_params)); |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
2075 }; |
2394
6776f4e569d7
Moved select widget to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
2369
diff
changeset
|
2076 /* Multi selectors */ |
6776f4e569d7
Moved select widget to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
2369
diff
changeset
|
2077 |
6776f4e569d7
Moved select widget to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
2369
diff
changeset
|
2078 var MultiSelectWidget = function(selected_id, available_id, form_id){ |
6776f4e569d7
Moved select widget to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
2369
diff
changeset
|
2079 |
6776f4e569d7
Moved select widget to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
2369
diff
changeset
|
2080 |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2081 //definition of containers ID's |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2082 var selected_container = selected_id; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2083 var available_container = available_id; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2084 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2085 //temp container for selected storage. |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2086 var cache = new Array(); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2087 var av_cache = new Array(); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2088 var c = YUD.get(selected_container); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2089 var ac = YUD.get(available_container); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2090 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2091 //get only selected options for further fullfilment |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2092 for(var i = 0;node =c.options[i];i++){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2093 if(node.selected){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2094 //push selected to my temp storage left overs :) |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2095 cache.push(node); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2096 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2097 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2098 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2099 //get all available options to cache |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2100 for(var i = 0;node =ac.options[i];i++){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2101 //push selected to my temp storage left overs :) |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2102 av_cache.push(node); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2103 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2104 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2105 //fill available only with those not in chosen |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2106 ac.options.length=0; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2107 tmp_cache = new Array(); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2108 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2109 for(var i = 0;node = av_cache[i];i++){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2110 var add = true; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2111 for(var i2 = 0;node_2 = cache[i2];i2++){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2112 if(node.value == node_2.value){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2113 add=false; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2114 break; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2115 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2116 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2117 if(add){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2118 tmp_cache.push(new Option(node.text, node.value, false, false)); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2119 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2120 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2121 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2122 for(var i = 0;node = tmp_cache[i];i++){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2123 ac.options[i] = node; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2124 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2125 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2126 function prompts_action_callback(e){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2127 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2128 var chosen = YUD.get(selected_container); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2129 var available = YUD.get(available_container); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2130 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2131 //get checked and unchecked options from field |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2132 function get_checked(from_field){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2133 //temp container for storage. |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2134 var sel_cache = new Array(); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2135 var oth_cache = new Array(); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2136 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2137 for(var i = 0;node = from_field.options[i];i++){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2138 if(node.selected){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2139 //push selected fields :) |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2140 sel_cache.push(node); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2141 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2142 else{ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2143 oth_cache.push(node) |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2144 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2145 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2146 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2147 return [sel_cache,oth_cache] |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2148 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2149 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2150 //fill the field with given options |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2151 function fill_with(field,options){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2152 //clear firtst |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2153 field.options.length=0; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2154 for(var i = 0;node = options[i];i++){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2155 field.options[i]=new Option(node.text, node.value, |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2156 false, false); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2157 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2158 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2159 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2160 //adds to current field |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2161 function add_to(field,options){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2162 for(var i = 0;node = options[i];i++){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2163 field.appendChild(new Option(node.text, node.value, |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2164 false, false)); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2165 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2166 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2167 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2168 // add action |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2169 if (this.id=='add_element'){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2170 var c = get_checked(available); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2171 add_to(chosen,c[0]); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2172 fill_with(available,c[1]); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2173 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2174 // remove action |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2175 if (this.id=='remove_element'){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2176 var c = get_checked(chosen); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2177 add_to(available,c[0]); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2178 fill_with(chosen,c[1]); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2179 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2180 // add all elements |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2181 if(this.id=='add_all_elements'){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2182 for(var i=0; node = available.options[i];i++){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2183 chosen.appendChild(new Option(node.text, |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2184 node.value, false, false)); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2185 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2186 available.options.length = 0; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2187 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2188 //remove all elements |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2189 if(this.id=='remove_all_elements'){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2190 for(var i=0; node = chosen.options[i];i++){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2191 available.appendChild(new Option(node.text, |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2192 node.value, false, false)); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2193 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2194 chosen.options.length = 0; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2195 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2196 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2197 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2198 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2199 YUE.addListener(['add_element','remove_element', |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2200 'add_all_elements','remove_all_elements'],'click', |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2201 prompts_action_callback) |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2202 if (form_id !== undefined) { |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2203 YUE.addListener(form_id,'submit',function(){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2204 var chosen = YUD.get(selected_container); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2205 for (var i = 0; i < chosen.options.length; i++) { |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2206 chosen.options[i].selected = 'selected'; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2207 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2208 }); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2209 } |
2723
04aa0ea1ddd0
fixed comment addition and deletion functionality on IE9
Dies Koper <diesk@fast.au.fujitsu.com>
parents:
2699
diff
changeset
|
2210 } |
3419
efc00d363d1e
collapsable diff container in changeset, makes quick review easier
Marcin Kuzminski <marcin@python-works.com>
parents:
3417
diff
changeset
|
2211 |
3784
62fb395a459d
make sure we hide the spans
Marcin Kuzminski <marcin@python-works.com>
parents:
3776
diff
changeset
|
2212 // custom paginator |
62fb395a459d
make sure we hide the spans
Marcin Kuzminski <marcin@python-works.com>
parents:
3776
diff
changeset
|
2213 var YUI_paginator = function(links_per_page, containers){ |
3776
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2214 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2215 (function () { |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2216 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2217 var Paginator = YAHOO.widget.Paginator, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2218 l = YAHOO.lang, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2219 setId = YAHOO.util.Dom.generateId; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2220 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2221 Paginator.ui.MyFirstPageLink = function (p) { |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2222 this.paginator = p; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2223 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2224 p.subscribe('recordOffsetChange',this.update,this,true); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2225 p.subscribe('rowsPerPageChange',this.update,this,true); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2226 p.subscribe('totalRecordsChange',this.update,this,true); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2227 p.subscribe('destroy',this.destroy,this,true); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2228 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2229 // TODO: make this work |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2230 p.subscribe('firstPageLinkLabelChange',this.update,this,true); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2231 p.subscribe('firstPageLinkClassChange',this.update,this,true); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2232 }; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2233 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2234 Paginator.ui.MyFirstPageLink.init = function (p) { |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2235 p.setAttributeConfig('firstPageLinkLabel', { |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2236 value : 1, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2237 validator : l.isString |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2238 }); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2239 p.setAttributeConfig('firstPageLinkClass', { |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2240 value : 'yui-pg-first', |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2241 validator : l.isString |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2242 }); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2243 p.setAttributeConfig('firstPageLinkTitle', { |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2244 value : 'First Page', |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2245 validator : l.isString |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2246 }); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2247 }; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2248 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2249 // Instance members and methods |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2250 Paginator.ui.MyFirstPageLink.prototype = { |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2251 current : null, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2252 leftmost_page: null, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2253 rightmost_page: null, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2254 link : null, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2255 span : null, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2256 dotdot : null, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2257 getPos : function(cur_page, max_page, items){ |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2258 var edge = parseInt(items / 2) + 1; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2259 if (cur_page <= edge){ |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2260 var radius = Math.max(parseInt(items / 2), items - cur_page); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2261 } |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2262 else if ((max_page - cur_page) < edge) { |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2263 var radius = (items - 1) - (max_page - cur_page); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2264 } |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2265 else{ |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2266 var radius = parseInt(items / 2); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2267 } |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2268 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2269 var left = Math.max(1, (cur_page - (radius))) |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2270 var right = Math.min(max_page, cur_page + (radius)) |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2271 return [left, cur_page, right] |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2272 }, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2273 render : function (id_base) { |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2274 var p = this.paginator, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2275 c = p.get('firstPageLinkClass'), |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2276 label = p.get('firstPageLinkLabel'), |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2277 title = p.get('firstPageLinkTitle'); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2278 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2279 this.link = document.createElement('a'); |
3784
62fb395a459d
make sure we hide the spans
Marcin Kuzminski <marcin@python-works.com>
parents:
3776
diff
changeset
|
2280 this.span = document.createElement('span'); |
62fb395a459d
make sure we hide the spans
Marcin Kuzminski <marcin@python-works.com>
parents:
3776
diff
changeset
|
2281 YUD.setStyle(this.span, 'display', 'none'); |
3776
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2282 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2283 var _pos = this.getPos(p.getCurrentPage(), p.getTotalPages(), 5); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2284 this.leftmost_page = _pos[0]; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2285 this.rightmost_page = _pos[2]; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2286 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2287 setId(this.link, id_base + '-first-link'); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2288 this.link.href = '#'; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2289 this.link.className = c; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2290 this.link.innerHTML = label; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2291 this.link.title = title; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2292 YAHOO.util.Event.on(this.link,'click',this.onClick,this,true); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2293 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2294 setId(this.span, id_base + '-first-span'); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2295 this.span.className = c; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2296 this.span.innerHTML = label; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2297 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2298 this.current = p.getCurrentPage() > 1 ? this.link : this.span; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2299 return this.current; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2300 }, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2301 update : function (e) { |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2302 var p = this.paginator; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2303 var _pos = this.getPos(p.getCurrentPage(), p.getTotalPages(), 5); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2304 this.leftmost_page = _pos[0]; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2305 this.rightmost_page = _pos[2]; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2306 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2307 if (e && e.prevValue === e.newValue) { |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2308 return; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2309 } |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2310 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2311 var par = this.current ? this.current.parentNode : null; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2312 if (this.leftmost_page > 1) { |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2313 if (par && this.current === this.span) { |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2314 par.replaceChild(this.link,this.current); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2315 this.current = this.link; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2316 } |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2317 } else { |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2318 if (par && this.current === this.link) { |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2319 par.replaceChild(this.span,this.current); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2320 this.current = this.span; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2321 } |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2322 } |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2323 }, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2324 destroy : function () { |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2325 YAHOO.util.Event.purgeElement(this.link); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2326 this.current.parentNode.removeChild(this.current); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2327 this.link = this.span = null; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2328 }, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2329 onClick : function (e) { |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2330 YAHOO.util.Event.stopEvent(e); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2331 this.paginator.setPage(1); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2332 } |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2333 }; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2334 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2335 })(); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2336 (function () { |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2337 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2338 var Paginator = YAHOO.widget.Paginator, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2339 l = YAHOO.lang, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2340 setId = YAHOO.util.Dom.generateId; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2341 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2342 Paginator.ui.MyLastPageLink = function (p) { |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2343 this.paginator = p; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2344 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2345 p.subscribe('recordOffsetChange',this.update,this,true); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2346 p.subscribe('rowsPerPageChange',this.update,this,true); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2347 p.subscribe('totalRecordsChange',this.update,this,true); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2348 p.subscribe('destroy',this.destroy,this,true); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2349 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2350 // TODO: make this work |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2351 p.subscribe('lastPageLinkLabelChange',this.update,this,true); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2352 p.subscribe('lastPageLinkClassChange', this.update,this,true); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2353 }; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2354 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2355 Paginator.ui.MyLastPageLink.init = function (p) { |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2356 p.setAttributeConfig('lastPageLinkLabel', { |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2357 value : -1, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2358 validator : l.isString |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2359 }); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2360 p.setAttributeConfig('lastPageLinkClass', { |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2361 value : 'yui-pg-last', |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2362 validator : l.isString |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2363 }); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2364 p.setAttributeConfig('lastPageLinkTitle', { |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2365 value : 'Last Page', |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2366 validator : l.isString |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2367 }); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2368 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2369 }; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2370 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2371 Paginator.ui.MyLastPageLink.prototype = { |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2372 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2373 current : null, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2374 leftmost_page: null, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2375 rightmost_page: null, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2376 link : null, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2377 span : null, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2378 dotdot : null, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2379 na : null, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2380 getPos : function(cur_page, max_page, items){ |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2381 var edge = parseInt(items / 2) + 1; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2382 if (cur_page <= edge){ |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2383 var radius = Math.max(parseInt(items / 2), items - cur_page); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2384 } |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2385 else if ((max_page - cur_page) < edge) { |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2386 var radius = (items - 1) - (max_page - cur_page); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2387 } |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2388 else{ |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2389 var radius = parseInt(items / 2); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2390 } |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2391 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2392 var left = Math.max(1, (cur_page - (radius))) |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2393 var right = Math.min(max_page, cur_page + (radius)) |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2394 return [left, cur_page, right] |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2395 }, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2396 render : function (id_base) { |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2397 var p = this.paginator, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2398 c = p.get('lastPageLinkClass'), |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2399 label = p.get('lastPageLinkLabel'), |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2400 last = p.getTotalPages(), |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2401 title = p.get('lastPageLinkTitle'); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2402 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2403 var _pos = this.getPos(p.getCurrentPage(), p.getTotalPages(), 5); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2404 this.leftmost_page = _pos[0]; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2405 this.rightmost_page = _pos[2]; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2406 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2407 this.link = document.createElement('a'); |
3784
62fb395a459d
make sure we hide the spans
Marcin Kuzminski <marcin@python-works.com>
parents:
3776
diff
changeset
|
2408 this.span = document.createElement('span'); |
62fb395a459d
make sure we hide the spans
Marcin Kuzminski <marcin@python-works.com>
parents:
3776
diff
changeset
|
2409 YUD.setStyle(this.span, 'display', 'none'); |
62fb395a459d
make sure we hide the spans
Marcin Kuzminski <marcin@python-works.com>
parents:
3776
diff
changeset
|
2410 |
3776
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2411 this.na = this.span.cloneNode(false); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2412 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2413 setId(this.link, id_base + '-last-link'); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2414 this.link.href = '#'; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2415 this.link.className = c; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2416 this.link.innerHTML = label; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2417 this.link.title = title; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2418 YAHOO.util.Event.on(this.link,'click',this.onClick,this,true); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2419 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2420 setId(this.span, id_base + '-last-span'); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2421 this.span.className = c; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2422 this.span.innerHTML = label; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2423 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2424 setId(this.na, id_base + '-last-na'); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2425 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2426 if (this.rightmost_page < p.getTotalPages()){ |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2427 this.current = this.link; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2428 } |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2429 else{ |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2430 this.current = this.span; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2431 } |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2432 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2433 this.current.innerHTML = p.getTotalPages(); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2434 return this.current; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2435 }, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2436 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2437 update : function (e) { |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2438 var p = this.paginator; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2439 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2440 var _pos = this.getPos(p.getCurrentPage(), p.getTotalPages(), 5); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2441 this.leftmost_page = _pos[0]; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2442 this.rightmost_page = _pos[2]; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2443 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2444 if (e && e.prevValue === e.newValue) { |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2445 return; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2446 } |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2447 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2448 var par = this.current ? this.current.parentNode : null, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2449 after = this.link; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2450 if (par) { |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2451 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2452 // only show the last page if the rightmost one is |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2453 // lower, so we don't have doubled entries at the end |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2454 if (!(this.rightmost_page < p.getTotalPages())){ |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2455 after = this.span |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2456 } |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2457 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2458 if (this.current !== after) { |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2459 par.replaceChild(after,this.current); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2460 this.current = after; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2461 } |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2462 } |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2463 this.current.innerHTML = this.paginator.getTotalPages(); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2464 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2465 }, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2466 destroy : function () { |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2467 YAHOO.util.Event.purgeElement(this.link); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2468 this.current.parentNode.removeChild(this.current); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2469 this.link = this.span = null; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2470 }, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2471 onClick : function (e) { |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2472 YAHOO.util.Event.stopEvent(e); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2473 this.paginator.setPage(this.paginator.getTotalPages()); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2474 } |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2475 }; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2476 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2477 })(); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2478 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2479 var pagi = new YAHOO.widget.Paginator({ |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2480 rowsPerPage: links_per_page, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2481 alwaysVisible: false, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2482 template : "{PreviousPageLink} {MyFirstPageLink} {PageLinks} {MyLastPageLink} {NextPageLink}", |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2483 pageLinks: 5, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2484 containerClass: 'pagination-wh', |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2485 currentPageClass: 'pager_curpage', |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2486 pageLinkClass: 'pager_link', |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2487 nextPageLinkLabel: '>', |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2488 previousPageLinkLabel: '<', |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2489 containers:containers |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2490 }) |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2491 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2492 return pagi |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2493 } |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2494 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2495 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2496 |
3419
efc00d363d1e
collapsable diff container in changeset, makes quick review easier
Marcin Kuzminski <marcin@python-works.com>
parents:
3417
diff
changeset
|
2497 // global hooks after DOM is loaded |
efc00d363d1e
collapsable diff container in changeset, makes quick review easier
Marcin Kuzminski <marcin@python-works.com>
parents:
3417
diff
changeset
|
2498 |
efc00d363d1e
collapsable diff container in changeset, makes quick review easier
Marcin Kuzminski <marcin@python-works.com>
parents:
3417
diff
changeset
|
2499 YUE.onDOMReady(function(){ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2500 YUE.on(YUQ('.diff-collapse-button'), 'click', function(e){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2501 var button = e.currentTarget; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2502 var t = YUD.get(button).getAttribute('target'); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2503 console.log(t); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2504 if(YUD.hasClass(t, 'hidden')){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2505 YUD.removeClass(t, 'hidden'); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2506 YUD.get(button).innerHTML = "↑ {0} ↑".format(_TM['Collapse diff']); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2507 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2508 else if(!YUD.hasClass(t, 'hidden')){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2509 YUD.addClass(t, 'hidden'); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2510 YUD.get(button).innerHTML = "↓ {0} ↓".format(_TM['Expand diff']); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2511 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2512 }); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2513 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2514 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2515 |
3419
efc00d363d1e
collapsable diff container in changeset, makes quick review easier
Marcin Kuzminski <marcin@python-works.com>
parents:
3417
diff
changeset
|
2516 }); |