Mercurial > kallithea
annotate rhodecode/public/js/rhodecode.js @ 4165:330d935054ca rhodecode-2.2.5-gpl
rhodecode.js: use last_rev_raw field for revisionSort and raw_date for dateSort, numerical, default 0
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Wed, 02 Jul 2014 19:03:27 -0400 |
parents | 197bfc8a4f03 |
children | f0e518891d69 |
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 /** |
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
|
10 * 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
|
11 * 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
|
12 * 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
|
13 * 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
|
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 String.prototype.format = function() { |
4158
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
16 function format() { |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
17 var str = this; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
18 var len = arguments.length+1; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
19 var safe = undefined; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
20 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
|
21 |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
22 // 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
|
23 // 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
|
24 for (var i=0; i < len; arg = arguments[i++]) { |
4158
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
25 safe = typeof arg === 'object' ? JSON.stringify(arg) : arg; |
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
26 str = str.replace(RegExp('\\{'+(i-1)+'\\}', 'g'), safe); |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
27 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
28 return str; |
4158
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
29 } |
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
|
30 |
4158
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
31 // Save a reference of what may already exist under the property native. |
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
32 // Allows for doing something like: if("".format.native) { /* use native */ } |
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
33 format.native = String.prototype.format; |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
34 |
4158
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
35 // Replace the prototype property |
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
36 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
|
37 |
1458
9d9e491e2a21
added author to main page tooltip
Marcin Kuzminski <marcin@python-works.com>
parents:
1426
diff
changeset
|
38 }(); |
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
|
39 |
2369
c2f131502037
Autocomplete fixes
Marcin Kuzminski <marcin@python-works.com>
parents:
2368
diff
changeset
|
40 String.prototype.strip = function(char) { |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
41 if(char === undefined){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
42 char = '\\s'; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
43 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
44 return this.replace(new RegExp('^'+char+'+|'+char+'+$','g'), ''); |
2369
c2f131502037
Autocomplete fixes
Marcin Kuzminski <marcin@python-works.com>
parents:
2368
diff
changeset
|
45 } |
4157
bc296381fb6c
rhodecode.js: remove unused stuff
Mads Kiilerich <madski@unity3d.com>
parents:
4135
diff
changeset
|
46 |
2369
c2f131502037
Autocomplete fixes
Marcin Kuzminski <marcin@python-works.com>
parents:
2368
diff
changeset
|
47 String.prototype.lstrip = 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+'+'),''); |
2369
c2f131502037
Autocomplete fixes
Marcin Kuzminski <marcin@python-works.com>
parents:
2368
diff
changeset
|
52 } |
4157
bc296381fb6c
rhodecode.js: remove unused stuff
Mads Kiilerich <madski@unity3d.com>
parents:
4135
diff
changeset
|
53 |
2369
c2f131502037
Autocomplete fixes
Marcin Kuzminski <marcin@python-works.com>
parents:
2368
diff
changeset
|
54 String.prototype.rstrip = function(char) { |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
55 if(char === undefined){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
56 char = '\\s'; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
57 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
58 return this.replace(new RegExp(''+char+'+$'),''); |
2369
c2f131502037
Autocomplete fixes
Marcin Kuzminski <marcin@python-works.com>
parents:
2368
diff
changeset
|
59 } |
1465
ef31d0c6bae9
Added smart color generator to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
1458
diff
changeset
|
60 |
4162
a1b80a0a3e15
rhodecode.js: update array.indexOf for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4161
diff
changeset
|
61 /* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf#Polyfill |
a1b80a0a3e15
rhodecode.js: update array.indexOf for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4161
diff
changeset
|
62 under MIT license / public domain, see |
a1b80a0a3e15
rhodecode.js: update array.indexOf for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4161
diff
changeset
|
63 https://developer.mozilla.org/en-US/docs/MDN/About#Copyrights_and_licenses */ |
2612
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
64 if(!Array.prototype.indexOf) { |
4162
a1b80a0a3e15
rhodecode.js: update array.indexOf for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4161
diff
changeset
|
65 Array.prototype.indexOf = function (searchElement, fromIndex) { |
a1b80a0a3e15
rhodecode.js: update array.indexOf for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4161
diff
changeset
|
66 if ( this === undefined || this === null ) { |
a1b80a0a3e15
rhodecode.js: update array.indexOf for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4161
diff
changeset
|
67 throw new TypeError( '"this" is null or not defined' ); |
a1b80a0a3e15
rhodecode.js: update array.indexOf for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4161
diff
changeset
|
68 } |
a1b80a0a3e15
rhodecode.js: update array.indexOf for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4161
diff
changeset
|
69 |
a1b80a0a3e15
rhodecode.js: update array.indexOf for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4161
diff
changeset
|
70 var length = this.length >>> 0; // Hack to convert object.length to a UInt32 |
a1b80a0a3e15
rhodecode.js: update array.indexOf for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4161
diff
changeset
|
71 |
a1b80a0a3e15
rhodecode.js: update array.indexOf for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4161
diff
changeset
|
72 fromIndex = +fromIndex || 0; |
a1b80a0a3e15
rhodecode.js: update array.indexOf for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4161
diff
changeset
|
73 |
a1b80a0a3e15
rhodecode.js: update array.indexOf for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4161
diff
changeset
|
74 if (Math.abs(fromIndex) === Infinity) { |
a1b80a0a3e15
rhodecode.js: update array.indexOf for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4161
diff
changeset
|
75 fromIndex = 0; |
a1b80a0a3e15
rhodecode.js: update array.indexOf for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4161
diff
changeset
|
76 } |
a1b80a0a3e15
rhodecode.js: update array.indexOf for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4161
diff
changeset
|
77 |
a1b80a0a3e15
rhodecode.js: update array.indexOf for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4161
diff
changeset
|
78 if (fromIndex < 0) { |
a1b80a0a3e15
rhodecode.js: update array.indexOf for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4161
diff
changeset
|
79 fromIndex += length; |
a1b80a0a3e15
rhodecode.js: update array.indexOf for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4161
diff
changeset
|
80 if (fromIndex < 0) { |
a1b80a0a3e15
rhodecode.js: update array.indexOf for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4161
diff
changeset
|
81 fromIndex = 0; |
2612
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
82 } |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
83 } |
4162
a1b80a0a3e15
rhodecode.js: update array.indexOf for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4161
diff
changeset
|
84 |
a1b80a0a3e15
rhodecode.js: update array.indexOf for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4161
diff
changeset
|
85 for (;fromIndex < length; fromIndex++) { |
a1b80a0a3e15
rhodecode.js: update array.indexOf for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4161
diff
changeset
|
86 if (this[fromIndex] === searchElement) { |
a1b80a0a3e15
rhodecode.js: update array.indexOf for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4161
diff
changeset
|
87 return fromIndex; |
a1b80a0a3e15
rhodecode.js: update array.indexOf for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4161
diff
changeset
|
88 } |
a1b80a0a3e15
rhodecode.js: update array.indexOf for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4161
diff
changeset
|
89 } |
a1b80a0a3e15
rhodecode.js: update array.indexOf for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4161
diff
changeset
|
90 |
2612
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
91 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
|
92 }; |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
93 } |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
94 |
4161
f51578556bc2
rhodecode.js: implement array.filter for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4160
diff
changeset
|
95 /* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter#Compatibility |
f51578556bc2
rhodecode.js: implement array.filter for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4160
diff
changeset
|
96 under MIT license / public domain, see |
f51578556bc2
rhodecode.js: implement array.filter for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4160
diff
changeset
|
97 https://developer.mozilla.org/en-US/docs/MDN/About#Copyrights_and_licenses */ |
f51578556bc2
rhodecode.js: implement array.filter for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4160
diff
changeset
|
98 if (!Array.prototype.filter) |
f51578556bc2
rhodecode.js: implement array.filter for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4160
diff
changeset
|
99 { |
f51578556bc2
rhodecode.js: implement array.filter for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4160
diff
changeset
|
100 Array.prototype.filter = function(fun /*, thisArg */) |
f51578556bc2
rhodecode.js: implement array.filter for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4160
diff
changeset
|
101 { |
f51578556bc2
rhodecode.js: implement array.filter for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4160
diff
changeset
|
102 "use strict"; |
f51578556bc2
rhodecode.js: implement array.filter for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4160
diff
changeset
|
103 |
f51578556bc2
rhodecode.js: implement array.filter for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4160
diff
changeset
|
104 if (this === void 0 || this === null) |
f51578556bc2
rhodecode.js: implement array.filter for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4160
diff
changeset
|
105 throw new TypeError(); |
f51578556bc2
rhodecode.js: implement array.filter for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4160
diff
changeset
|
106 |
f51578556bc2
rhodecode.js: implement array.filter for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4160
diff
changeset
|
107 var t = Object(this); |
f51578556bc2
rhodecode.js: implement array.filter for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4160
diff
changeset
|
108 var len = t.length >>> 0; |
f51578556bc2
rhodecode.js: implement array.filter for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4160
diff
changeset
|
109 if (typeof fun !== "function") |
f51578556bc2
rhodecode.js: implement array.filter for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4160
diff
changeset
|
110 throw new TypeError(); |
f51578556bc2
rhodecode.js: implement array.filter for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4160
diff
changeset
|
111 |
f51578556bc2
rhodecode.js: implement array.filter for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4160
diff
changeset
|
112 var res = []; |
f51578556bc2
rhodecode.js: implement array.filter for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4160
diff
changeset
|
113 var thisArg = arguments.length >= 2 ? arguments[1] : void 0; |
f51578556bc2
rhodecode.js: implement array.filter for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4160
diff
changeset
|
114 for (var i = 0; i < len; i++) |
f51578556bc2
rhodecode.js: implement array.filter for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4160
diff
changeset
|
115 { |
f51578556bc2
rhodecode.js: implement array.filter for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4160
diff
changeset
|
116 if (i in t) |
f51578556bc2
rhodecode.js: implement array.filter for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4160
diff
changeset
|
117 { |
f51578556bc2
rhodecode.js: implement array.filter for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4160
diff
changeset
|
118 var val = t[i]; |
f51578556bc2
rhodecode.js: implement array.filter for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4160
diff
changeset
|
119 |
f51578556bc2
rhodecode.js: implement array.filter for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4160
diff
changeset
|
120 // NOTE: Technically this should Object.defineProperty at |
f51578556bc2
rhodecode.js: implement array.filter for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4160
diff
changeset
|
121 // the next index, as push can be affected by |
f51578556bc2
rhodecode.js: implement array.filter for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4160
diff
changeset
|
122 // properties on Object.prototype and Array.prototype. |
f51578556bc2
rhodecode.js: implement array.filter for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4160
diff
changeset
|
123 // But that method's new, and collisions should be |
f51578556bc2
rhodecode.js: implement array.filter for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4160
diff
changeset
|
124 // rare, so use the more-compatible alternative. |
f51578556bc2
rhodecode.js: implement array.filter for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4160
diff
changeset
|
125 if (fun.call(thisArg, val, i, t)) |
f51578556bc2
rhodecode.js: implement array.filter for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4160
diff
changeset
|
126 res.push(val); |
f51578556bc2
rhodecode.js: implement array.filter for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4160
diff
changeset
|
127 } |
f51578556bc2
rhodecode.js: implement array.filter for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4160
diff
changeset
|
128 } |
f51578556bc2
rhodecode.js: implement array.filter for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4160
diff
changeset
|
129 |
f51578556bc2
rhodecode.js: implement array.filter for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4160
diff
changeset
|
130 return res; |
f51578556bc2
rhodecode.js: implement array.filter for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4160
diff
changeset
|
131 }; |
f51578556bc2
rhodecode.js: implement array.filter for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4160
diff
changeset
|
132 } |
f51578556bc2
rhodecode.js: implement array.filter for backward compatibility
Mads Kiilerich <madski@unity3d.com>
parents:
4160
diff
changeset
|
133 |
1465
ef31d0c6bae9
Added smart color generator to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
1458
diff
changeset
|
134 /** |
4135
cc28a05562d3
Clarify copyright and license of PyRoutes.JS
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4087
diff
changeset
|
135 * A customized version of PyRoutes.JS from https://pypi.python.org/pypi/pyroutes.js/ |
cc28a05562d3
Clarify copyright and license of PyRoutes.JS
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4087
diff
changeset
|
136 * which is copyright Stephane Klein and was made available under the BSD License. |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
137 * |
3388
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
138 * 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
|
139 */ |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
140 var pyroutes = (function() { |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
141 // 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
|
142 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
|
143 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
|
144 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
|
145 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
|
146 } |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
147 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
|
148 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
|
149 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
|
150 } |
1465
ef31d0c6bae9
Added smart color generator to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
1458
diff
changeset
|
151 |
3388
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
152 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
|
153 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
|
154 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
|
155 } |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
156 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
|
157 }; |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
158 |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
159 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
|
160 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
|
161 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
|
162 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
|
163 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
|
164 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
|
165 } |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
166 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
|
167 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
|
168 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
|
169 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
|
170 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
|
171 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
|
172 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
|
173 } |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
174 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
|
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 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
|
178 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
|
179 } |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
180 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
|
181 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
|
182 } |
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 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
|
185 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
|
186 } |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
187 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
|
188 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
|
189 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
|
190 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
|
191 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
|
192 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
|
193 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
|
194 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
|
195 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
|
196 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
|
197 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
|
198 } |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
199 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
|
200 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
|
201 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
|
202 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
|
203 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
|
204 } |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
205 } |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
206 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
|
207 }; |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
208 |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
209 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
|
210 |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
211 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
|
212 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
|
213 while (_fmt) { |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
214 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
|
215 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
|
216 } |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
217 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
|
218 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
|
219 } |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
220 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
|
221 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
|
222 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
|
223 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
|
224 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
|
225 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
|
226 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
|
227 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
|
228 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
|
229 } |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
230 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
|
231 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
|
232 } |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
233 else { |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
234 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
|
235 } |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
236 } |
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 { |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
239 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
|
240 } |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
241 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
|
242 } |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
243 else { |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
244 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
|
245 } |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
246 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
|
247 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
|
248 } |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
249 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
|
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 _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
|
255 } |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
256 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
|
257 }; |
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 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
|
260 })(); |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
261 |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
262 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
|
263 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
|
264 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
|
265 }; |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
266 return { |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
267 '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
|
268 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
|
269 if (typeof(params) != 'object'){ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
270 params = {}; |
3388
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 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
|
273 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
|
274 // 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
|
275 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
|
276 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
|
277 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
|
278 } |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
279 result = sprintf(route[0], params); |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
280 |
3403
07f4193083fd
extra params in pyroutes now generate GET params
Marcin Kuzminski <marcin@python-works.com>
parents:
3388
diff
changeset
|
281 var ret = []; |
07f4193083fd
extra params in pyroutes now generate GET params
Marcin Kuzminski <marcin@python-works.com>
parents:
3388
diff
changeset
|
282 //extra params => GET |
07f4193083fd
extra params in pyroutes now generate GET params
Marcin Kuzminski <marcin@python-works.com>
parents:
3388
diff
changeset
|
283 for(param in params){ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
284 if (route[1].indexOf(param) == -1){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
285 ret.push(encodeURIComponent(param) + "=" + encodeURIComponent(params[param])); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
286 } |
3403
07f4193083fd
extra params in pyroutes now generate GET params
Marcin Kuzminski <marcin@python-works.com>
parents:
3388
diff
changeset
|
287 } |
07f4193083fd
extra params in pyroutes now generate GET params
Marcin Kuzminski <marcin@python-works.com>
parents:
3388
diff
changeset
|
288 var _parts = ret.join("&"); |
07f4193083fd
extra params in pyroutes now generate GET params
Marcin Kuzminski <marcin@python-works.com>
parents:
3388
diff
changeset
|
289 if(_parts){ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
290 result = result +'?'+ _parts |
3403
07f4193083fd
extra params in pyroutes now generate GET params
Marcin Kuzminski <marcin@python-works.com>
parents:
3388
diff
changeset
|
291 } |
3388
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
292 } |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
293 |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
294 return result; |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
295 }, |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
296 'register': function(route_name, route_tmpl, req_params) { |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
297 if (typeof(req_params) != 'object') { |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
298 req_params = []; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
299 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
300 //fix escape |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
301 route_tmpl = unescape(route_tmpl); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
302 keys = []; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
303 for (o in req_params){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
304 keys.push(req_params[o]) |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
305 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
306 matchlist[route_name] = [ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
307 route_tmpl, |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
308 keys |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
309 ] |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
310 }, |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
311 '_routes': function(){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
312 return matchlist; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
313 } |
3388
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
314 } |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
315 })(); |
1465
ef31d0c6bae9
Added smart color generator to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
1458
diff
changeset
|
316 |
ef31d0c6bae9
Added smart color generator to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
1458
diff
changeset
|
317 |
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
|
318 /** |
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
|
319 * 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
|
320 */ |
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
|
321 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
|
322 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
|
323 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
|
324 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
|
325 |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
326 /* Invoke all functions in callbacks */ |
1717
7ff304d3028f
Notification fixes
Marcin Kuzminski <marcin@python-works.com>
parents:
1712
diff
changeset
|
327 var _run_callbacks = function(callbacks){ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
328 if (callbacks !== undefined){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
329 var _l = callbacks.length; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
330 for (var i=0;i<_l;i++){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
331 var func = callbacks[i]; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
332 if(typeof(func)=='function'){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
333 try{ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
334 func(); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
335 }catch (err){}; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
336 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
337 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
338 } |
1717
7ff304d3028f
Notification fixes
Marcin Kuzminski <marcin@python-works.com>
parents:
1712
diff
changeset
|
339 } |
7ff304d3028f
Notification fixes
Marcin Kuzminski <marcin@python-works.com>
parents:
1712
diff
changeset
|
340 |
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
|
341 /** |
3715
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
342 * 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
|
343 */ |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
344 var _toQueryString = function(o) { |
3715
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
345 if(typeof o !== 'object') { |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
346 return false; |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
347 } |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
348 var _p, _qs = []; |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
349 for(_p in o) { |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
350 _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
|
351 } |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
352 return _qs.join('&'); |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
353 }; |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
354 |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
355 /** |
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
|
356 * Partial Ajax Implementation |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
357 * |
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
|
358 * @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
|
359 * @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
|
360 * @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
|
361 * 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
|
362 * 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
|
363 * 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
|
364 * 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
|
365 * 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
|
366 * 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
|
367 * 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
|
368 * 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
|
369 * @param f_call: failure callback |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
370 * @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
|
371 */ |
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
|
372 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
|
373 var method='GET'; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
374 if(args===undefined){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
375 args=null; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
376 } |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
377 $container = $('#' + container); |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
378 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
379 // 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
|
380 YUC.initHeader('X-PARTIAL-XHR',true); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
381 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
382 // wrapper of passed callback |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
383 var s_wrapper = (function(o){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
384 return function(o){ |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
385 $container.html(o.responseText); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
386 $container.css('opacity','1.0'); |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
387 //execute the given original callback |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
388 if (s_call !== undefined){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
389 s_call(o); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
390 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
391 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
392 })() |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
393 $container.css('opacity','0.3'); |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
394 YUC.asyncRequest(method,url,{ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
395 success:s_wrapper, |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
396 failure:function(o){ |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
397 console.log('ypjax failure: '+o); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
398 $container.html('<span class="error_red">ERROR: {0}</span>'.format(o.status)); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
399 $container.css('opacity','1.0'); |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
400 }, |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
401 cache:false |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
402 },args); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
403 |
1699
623b228cf325
cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents:
1685
diff
changeset
|
404 }; |
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
|
405 |
2971
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
406 var ajaxGET = function(url,success) { |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
407 // Set special header for 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); |
2971
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
409 |
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
410 var sUrl = url; |
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
411 var callback = { |
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
412 success: success, |
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
413 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
|
414 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
|
415 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
|
416 }; |
2971
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
417 }, |
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
418 }; |
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
419 |
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
420 var request = YAHOO.util.Connect.asyncRequest('GET', sUrl, callback); |
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
421 return request; |
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
422 }; |
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
423 |
2187
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
424 var ajaxPOST = function(url,postData,success) { |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
425 // Set special header for ajax == HTTP_X_PARTIAL_XHR |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
426 YUC.initHeader('X-PARTIAL-XHR',true); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
427 |
2187
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
428 var sUrl = url; |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
429 var callback = { |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
430 success: success, |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
431 failure: function (o) { |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
432 alert("error"); |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
433 }, |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
434 }; |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
435 var postData = _toQueryString(postData); |
2187
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
436 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
|
437 return request; |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
438 }; |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
439 |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
440 |
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
|
441 /** |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
442 * activate .show_more links |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
443 * the .show_more must have an id that is the the id of an element to hide prefixed with _ |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
444 * the parentnode will be displayed |
1426
91708b96e991
Fixed show more links.
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
445 */ |
1458
9d9e491e2a21
added author to main page tooltip
Marcin Kuzminski <marcin@python-works.com>
parents:
1426
diff
changeset
|
446 var show_more_event = function(){ |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
447 $('.show_more').click(function(e){ |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
448 var el = e.currentTarget; |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
449 $('#' + el.id.substring(1)).hide(); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
450 $(el.parentNode).show(); |
1426
91708b96e991
Fixed show more links.
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
451 }); |
1699
623b228cf325
cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents:
1685
diff
changeset
|
452 }; |
1426
91708b96e991
Fixed show more links.
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
453 |
2971
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
454 /** |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
455 * activate .lazy-cs mouseover for showing changeset tooltip |
2971
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
456 */ |
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
457 var show_changeset_tooltip = function(){ |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
458 $('.lazy-cs').mouseover(function(e){ |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
459 var $target = $(e.currentTarget); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
460 var rid = $target.attr('raw_id'); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
461 var repo_name = $target.attr('repo_name'); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
462 if(rid && !$target.hasClass('tooltip')){ |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
463 _show_tooltip(e, _TM['loading ...']); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
464 var url = pyroutes.url('changeset_info', {"repo_name": repo_name, "revision": rid}); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
465 ajaxGET(url, function(o){ |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
466 var json = JSON.parse(o.responseText); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
467 $target.addClass('tooltip') |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
468 _show_tooltip(e, json['message']); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
469 _activate_tooltip($target); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
470 }); |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
471 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
472 }); |
2971
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
473 }; |
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
474 |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
475 var _onSuccessFollow = function(target){ |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
476 var $target = $(target); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
477 var $f_cnt = $('#current_followers_count'); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
478 if($target.hasClass('follow')){ |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
479 $target.attr('class', 'following'); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
480 $target.attr('title', _TM['Stop following this repository']); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
481 if($f_cnt.html()){ |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
482 var cnt = Number($f_cnt.html())+1; |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
483 $f_cnt.html(cnt); |
3066 | 484 } |
485 } | |
486 else{ | |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
487 $target.attr('class', 'follow'); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
488 $target.attr('title', _TM['Start following this repository']); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
489 if($f_cnt.html()){ |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
490 var cnt = Number($f_cnt.html())-1; |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
491 $f_cnt.html(cnt); |
3066 | 492 } |
493 } | |
494 } | |
495 | |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
496 var toggleFollowingRepo = function(target, follows_repo_id, token, user_id){ |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
497 args = 'follows_repo_id='+follows_repo_id; |
3066 | 498 args+= '&auth_token='+token; |
499 if(user_id != undefined){ | |
500 args+="&user_id="+user_id; | |
501 } | |
4159
a991e5c57a8d
rhodecode.js: Get rid of some more YUI
Andrew Shadura <andrew@shadura.me>
parents:
4158
diff
changeset
|
502 $.post(TOGGLE_FOLLOW_URL, args, function(data){ |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
503 _onSuccessFollow(target); |
4159
a991e5c57a8d
rhodecode.js: Get rid of some more YUI
Andrew Shadura <andrew@shadura.me>
parents:
4158
diff
changeset
|
504 }); |
3066 | 505 return false; |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
506 }; |
3066 | 507 |
3246
b9ba0d4d3abf
implemented #83 show repo size on summary page
Marcin Kuzminski <marcin@python-works.com>
parents:
3160
diff
changeset
|
508 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
|
509 var args= 'auth_token='+token; |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
510 |
4159
a991e5c57a8d
rhodecode.js: Get rid of some more YUI
Andrew Shadura <andrew@shadura.me>
parents:
4158
diff
changeset
|
511 if(!$("#" + target).hasClass('loaded')){ |
a991e5c57a8d
rhodecode.js: Get rid of some more YUI
Andrew Shadura <andrew@shadura.me>
parents:
4158
diff
changeset
|
512 $("#" + target).html(_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
|
513 var url = pyroutes.url('repo_size', {"repo_name":repo_name}); |
4159
a991e5c57a8d
rhodecode.js: Get rid of some more YUI
Andrew Shadura <andrew@shadura.me>
parents:
4158
diff
changeset
|
514 $.post(url, args, function(data) { |
a991e5c57a8d
rhodecode.js: Get rid of some more YUI
Andrew Shadura <andrew@shadura.me>
parents:
4158
diff
changeset
|
515 $("#" + target).html(data); |
a991e5c57a8d
rhodecode.js: Get rid of some more YUI
Andrew Shadura <andrew@shadura.me>
parents:
4158
diff
changeset
|
516 $("#" + target).addClass('loaded'); |
a991e5c57a8d
rhodecode.js: Get rid of some more YUI
Andrew Shadura <andrew@shadura.me>
parents:
4158
diff
changeset
|
517 }); |
3247
ed2fa8b1ccca
disallow triggering repo size action more than once after loading
Marcin Kuzminski <marcin@python-works.com>
parents:
3246
diff
changeset
|
518 } |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
519 return false; |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
520 }; |
2971
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
521 |
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
522 /** |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
523 * tooltips |
2971
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
524 */ |
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
525 |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
526 var tooltip_activate = function(){ |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
527 $(document).ready(_init_tooltip); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
528 }; |
2976
45a8e0051280
Optimized new tooltip, and fixed events on lazy loaded ones
Marcin Kuzminski <marcin@python-works.com>
parents:
2974
diff
changeset
|
529 |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
530 var _activate_tooltip = function($tt){ |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
531 $tt.mouseover(_show_tooltip); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
532 $tt.mousemove(_move_tooltip); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
533 $tt.mouseout(_close_tooltip); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
534 }; |
2971
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
535 |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
536 var _init_tooltip = function(){ |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
537 var $tipBox = $('#tip-box'); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
538 if(!$tipBox.length){ |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
539 $tipBox = $('<div id="tip-box"></div>') |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
540 $(document.body).append($tipBox); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
541 } |
2971
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
542 |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
543 $tipBox.hide(); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
544 $tipBox.css('position', 'absolute'); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
545 $tipBox.css('max-width', '600px'); |
2971
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
546 |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
547 _activate_tooltip($('.tooltip')); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
548 }; |
2971
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
549 |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
550 var _show_tooltip = function(e, tipText){ |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
551 e.stopImmediatePropagation(); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
552 var el = e.currentTarget; |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
553 if(tipText){ |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
554 // just use it |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
555 } else if(el.tagName.toLowerCase() === 'img'){ |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
556 tipText = el.alt ? el.alt : ''; |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
557 } else { |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
558 tipText = el.title ? el.title : ''; |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
559 } |
2971
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
560 |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
561 if(tipText !== ''){ |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
562 // save org title |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
563 $(el).attr('tt_title', tipText); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
564 // reset title to not show org tooltips |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
565 $(el).attr('title', ''); |
2971
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
566 |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
567 var $tipBox = $('#tip-box'); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
568 $tipBox.html(tipText); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
569 $tipBox.css('display', 'block'); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
570 } |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
571 }; |
2971
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
572 |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
573 var _move_tooltip = function(e){ |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
574 e.stopImmediatePropagation(); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
575 var $tipBox = $('#tip-box'); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
576 $tipBox.css('top', (e.pageY + 15) + 'px'); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
577 $tipBox.css('left', (e.pageX + 15) + 'px'); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
578 }; |
2971
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2891
diff
changeset
|
579 |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
580 var _close_tooltip = function(e){ |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
581 e.stopImmediatePropagation(); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
582 var $tipBox = $('#tip-box'); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
583 $tipBox.hide(); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
584 var el = e.currentTarget; |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
585 $(el).attr('title', $(el).attr('tt_title')); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
586 }; |
1653
b1e1dffd595c
one generic qfilter function.
Marcin Kuzminski <marcin@python-works.com>
parents:
1651
diff
changeset
|
587 |
b1e1dffd595c
one generic qfilter function.
Marcin Kuzminski <marcin@python-works.com>
parents:
1651
diff
changeset
|
588 /** |
b1e1dffd595c
one generic qfilter function.
Marcin Kuzminski <marcin@python-works.com>
parents:
1651
diff
changeset
|
589 * Quick filter widget |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
590 * |
1653
b1e1dffd595c
one generic qfilter function.
Marcin Kuzminski <marcin@python-works.com>
parents:
1651
diff
changeset
|
591 * @param target: filter input target |
b1e1dffd595c
one generic qfilter function.
Marcin Kuzminski <marcin@python-works.com>
parents:
1651
diff
changeset
|
592 * @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
|
593 * @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
|
594 * does hide or show based on the node |
b1e1dffd595c
one generic qfilter function.
Marcin Kuzminski <marcin@python-works.com>
parents:
1651
diff
changeset
|
595 */ |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
596 var q_filter = function(target, nodes, display_element){ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
597 var nodes = nodes; |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
598 var $q_filter_field = $('#' + target); |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
599 var F = YAHOO.namespace(target); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
600 |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
601 $q_filter_field.keyup(function(e){ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
602 clearTimeout(F.filterTimeout); |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
603 F.filterTimeout = setTimeout(F.updateFilter, 600); |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
604 }); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
605 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
606 F.filterTimeout = null; |
1653
b1e1dffd595c
one generic qfilter function.
Marcin Kuzminski <marcin@python-works.com>
parents:
1651
diff
changeset
|
607 |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
608 F.updateFilter = function() { |
4158
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
609 // Reset timeout |
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
610 F.filterTimeout = null; |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
611 |
4158
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
612 var obsolete = []; |
1653
b1e1dffd595c
one generic qfilter function.
Marcin Kuzminski <marcin@python-works.com>
parents:
1651
diff
changeset
|
613 |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
614 var req = $q_filter_field.val().toLowerCase(); |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
615 |
4158
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
616 var l = nodes.length; |
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
617 var i; |
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
618 var showing = 0; |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
619 |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
620 for (i=0; i<l; i++ ){ |
4158
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
621 var n = nodes[i]; |
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
622 var target_element = display_element(n) |
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
623 if(req && n.innerHTML.toLowerCase().indexOf(req) == -1){ |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
624 $(target_element).hide(); |
4158
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
625 } |
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
626 else{ |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
627 $(target_element).show(); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
628 showing += 1; |
4158
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
629 } |
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
630 } |
1653
b1e1dffd595c
one generic qfilter function.
Marcin Kuzminski <marcin@python-works.com>
parents:
1651
diff
changeset
|
631 |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
632 $('#repo_count').html(showing); /* FIXME: don't hardcode */ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
633 } |
1699
623b228cf325
cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents:
1685
diff
changeset
|
634 }; |
1653
b1e1dffd595c
one generic qfilter function.
Marcin Kuzminski <marcin@python-works.com>
parents:
1651
diff
changeset
|
635 |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
636 /* return jQuery expression with a tr with body in 3rd column and class cls and id named after the body */ |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
637 var _table_tr = function(cls, body){ |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
638 // like: <div class="comment" id="comment-8" line="o92"><div class="comment-wrapp">... |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
639 // except new inlines which are different ... |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
640 var comment_id = ($(body).attr('id') || 'comment-new').split('comment-')[1]; |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
641 var tr_id = 'comment-tr-{0}'.format(comment_id); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
642 return $(('<tr id="{0}" class="{1}">'+ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
643 '<td class="lineno-inline new-inline"></td>'+ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
644 '<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
|
645 '<td>{2}</td>'+ |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
646 '</tr>').format(tr_id, cls, body)); |
1674
6f0143e5efe5
#71 code review
Marcin Kuzminski <marcin@python-works.com>
parents:
1667
diff
changeset
|
647 }; |
1653
b1e1dffd595c
one generic qfilter function.
Marcin Kuzminski <marcin@python-works.com>
parents:
1651
diff
changeset
|
648 |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
649 /** return jQuery expression with new inline form based on template **/ |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
650 var _createInlineForm = function(parent_tr, f_path, line) { |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
651 var $tmpl = $('#comment-inline-form-template').html().format(f_path, line); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
652 var $form = _table_tr('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
|
653 |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
654 // create event for hide button |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
655 $form.find('.hide-inline-form').click(function(e) { |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
656 var newtr = e.currentTarget.parentNode.parentNode.parentNode.parentNode.parentNode; |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
657 if($(newtr).next().hasClass('inline-comments-button')){ |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
658 $(newtr).next().show(); |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
659 } |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
660 $(newtr).remove(); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
661 $(parent_tr).removeClass('form-open'); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
662 $(parent_tr).removeClass('hl-comment'); |
3696
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 |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
665 return $form |
1699
623b228cf325
cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents:
1685
diff
changeset
|
666 }; |
2187
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
667 |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
668 /** |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
669 * Inject inline comment for an given TR. This tr should always be a .line . |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
670 * The form will be inject after any comments. |
2187
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
671 */ |
1705
5e4827a8e942
added reply comment button on top of inline comments
Marcin Kuzminski <marcin@python-works.com>
parents:
1699
diff
changeset
|
672 var injectInlineForm = function(tr){ |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
673 $tr = $(tr); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
674 if(!$tr.hasClass('line')){ |
4158
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
675 return |
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
676 } |
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
677 var submit_url = AJAX_COMMENT_URL; |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
678 var $td = $tr.find('.code'); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
679 if($tr.hasClass('form-open') || $tr.hasClass('context') || $td.hasClass('no-comment')){ |
4158
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
680 return |
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
681 } |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
682 $tr.addClass('form-open hl-comment'); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
683 var $node = $tr.parent().parent().parent().find('.full_f_path'); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
684 var f_path = $node.attr('path'); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
685 var lineno = _getLineNo(tr); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
686 var $form = _createInlineForm(tr, f_path, lineno, submit_url); |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
687 |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
688 var $parent = $tr; |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
689 while ($parent.next().hasClass('inline-comments')){ |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
690 var $parent = $parent.next(); |
4158
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
691 } |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
692 $form.insertAfter($parent); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
693 var $overlay = $form.find('.overlay'); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
694 var $inlineform = $form.find('.inline-form'); |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
695 |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
696 $form.submit(function(e){ |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
697 e.preventDefault(); |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
698 |
4158
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
699 if(lineno === undefined){ |
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
700 alert('missing line !'); |
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
701 return |
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
702 } |
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
703 if(f_path === undefined){ |
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
704 alert('missing file path !'); |
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
705 return |
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
706 } |
2187
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
707 |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
708 var text = $('#text_'+lineno).val(); |
4158
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
709 if(text == ""){ |
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
710 return |
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
711 } |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
712 |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
713 if ($overlay.hasClass('overlay')){ |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
714 $overlay.css('width', $inlineform.offsetWidth + 'px'); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
715 $overlay.css('height', $inlineform.offsetHeight + 'px'); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
716 } |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
717 $overlay.addClass('submitting'); |
3695
45df84d36b44
Implemented preview for comments
Marcin Kuzminski <marcin@python-works.com>
parents:
3665
diff
changeset
|
718 |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
719 var success = function(o){ |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
720 $tr.removeClass('form-open'); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
721 $form.remove(); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
722 var json_data = JSON.parse(o.responseText); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
723 _renderInlineComment(json_data); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
724 }; |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
725 var postData = { |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
726 'text': text, |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
727 'f_path': f_path, |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
728 'line': lineno |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
729 }; |
4158
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
730 ajaxPOST(submit_url, postData, success); |
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
731 }); |
3695
45df84d36b44
Implemented preview for comments
Marcin Kuzminski <marcin@python-works.com>
parents:
3665
diff
changeset
|
732 |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
733 $('#preview-btn_'+lineno).click(function(e){ |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
734 var text = $('#text_'+lineno).val(); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
735 if(!text){ |
4158
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
736 return |
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
737 } |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
738 $('#preview-box_'+lineno).addClass('unloaded'); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
739 $('#preview-box_'+lineno).html(_TM['Loading ...']); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
740 $('#edit-container_'+lineno).hide(); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
741 $('#preview-container_'+lineno).show(); |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
742 |
4158
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
743 var url = pyroutes.url('changeset_comment_preview', {'repo_name': REPO_NAME}); |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
744 var post_data = {'text': text}; |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
745 ajaxPOST(url, post_data, function(o){ |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
746 $('#preview-box_'+lineno).html(o.responseText); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
747 $('#preview-box_'+lineno).removeClass('unloaded'); |
4158
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
748 }) |
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
749 }) |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
750 $('#edit-btn_'+lineno).click(function(e){ |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
751 $('#edit-container_'+lineno).show(); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
752 $('#preview-container_'+lineno).hide(); |
4158
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
753 }) |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
754 |
4158
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
755 setTimeout(function(){ |
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
756 // callbacks |
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
757 tooltip_activate(); |
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
758 MentionsAutoComplete('text_'+lineno, 'mentions_container_'+lineno, |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
759 _USERS_AC_DATA, _GROUPS_AC_DATA); |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
760 $('#text_'+lineno).focus(); |
4158
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
761 },10) |
1705
5e4827a8e942
added reply comment button on top of inline comments
Marcin Kuzminski <marcin@python-works.com>
parents:
1699
diff
changeset
|
762 }; |
5e4827a8e942
added reply comment button on top of inline comments
Marcin Kuzminski <marcin@python-works.com>
parents:
1699
diff
changeset
|
763 |
2187
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
764 var deleteComment = function(comment_id){ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
765 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
|
766 var postData = {'_method':'delete'}; |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
767 var success = function(o){ |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
768 var $deleted = $('#comment-tr-'+comment_id); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
769 var $prev = $deleted.prev('tr'); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
770 $deleted.remove(); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
771 _placeAddButton($prev); |
2187
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
772 } |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
773 ajaxPOST(url,postData,success); |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
774 } |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
775 |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
776 var _getLineNo = function(tr) { |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
777 var line; |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
778 var o = $(tr).children()[0].id.split('_'); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
779 var n = $(tr).children()[1].id.split('_'); |
1677
7276b170ce8b
#71 code-review
Marcin Kuzminski <marcin@python-works.com>
parents:
1674
diff
changeset
|
780 |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
781 if (n.length >= 2) { |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
782 line = n[n.length-1]; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
783 } else if (o.length >= 2) { |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
784 line = o[o.length-1]; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
785 } |
1677
7276b170ce8b
#71 code-review
Marcin Kuzminski <marcin@python-works.com>
parents:
1674
diff
changeset
|
786 |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
787 return line |
1699
623b228cf325
cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents:
1685
diff
changeset
|
788 }; |
623b228cf325
cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents:
1685
diff
changeset
|
789 |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
790 var _placeAddButton = function($line_tr){ |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
791 var $tr = $line_tr; |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
792 while ($tr.next().hasClass('inline-comments')){ |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
793 $tr.find('.add-comment').remove(); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
794 $tr = $tr.next(); |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
795 } |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
796 $tr.find('.add-comment').remove(); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
797 var label = TRANSLATION_MAP['Add another comment']; |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
798 var $html_el = $('<div class="add-comment"><span class="ui-btn">{0}</span></div>'.format(label)); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
799 $html_el.click(function(e) { |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
800 injectInlineForm($line_tr); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
801 }); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
802 $tr.find('.comment').after($html_el); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
803 }; |
2187
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
804 |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
805 /** |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
806 * 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
|
807 */ |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
808 var _placeInline = function(target_id, lineno, html){ |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
809 var $td = $("#{0}_{1}".format(target_id, lineno)); |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
810 |
4158
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
811 // check if there are comments already ! |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
812 var $line_tr = $td.parent(); // the tr |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
813 var $after_tr = $line_tr; |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
814 while ($after_tr.next().hasClass('inline-comments')){ |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
815 $after_tr = $after_tr.next(); |
4158
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
816 } |
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
817 // put in the comment at the bottom |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
818 $after_tr.after(_table_tr('inline-comments', html)); |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
819 |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
820 // scan nodes, and attach add button to last one |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
821 _placeAddButton($line_tr); |
2187
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
822 } |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
823 |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
824 /** |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
825 * 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
|
826 */ |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
827 var _renderInlineComment = function(json_data){ |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
828 var html = json_data['rendered_text']; |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
829 var lineno = json_data['line_no']; |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
830 var target_id = json_data['target_id']; |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
831 _placeInline(target_id, lineno, html); |
2187
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
832 } |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
833 |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
834 /** |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
835 * 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
|
836 */ |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
837 var renderInlineComments = function(file_comments){ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
838 for (f in file_comments){ |
2187
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
839 // holding all comments for a FILE |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
840 var box = file_comments[f]; |
2187
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
841 |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
842 var target_id = $(box).attr('target_id'); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
843 // actual comments with line numbers |
2187
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
844 var comments = box.children; |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
845 for(var i=0; i<comments.length; i++){ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
846 var data = { |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
847 'rendered_text': comments[i].outerHTML, |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
848 'line_no': $(comments[i]).attr('line'), |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
849 'target_id': target_id |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
850 } |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
851 _renderInlineComment(data); |
2187
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
852 } |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
853 } |
2187
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
854 } |
b61e540122f2
#415: Adding comment to changeset causes reload
Marcin Kuzminski <marcin@python-works.com>
parents:
2145
diff
changeset
|
855 |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
856 /* activate files.html stuff */ |
2428
530bd12fc18a
removed JSON array envelope from filter files function
Marcin Kuzminski <marcin@python-works.com>
parents:
2369
diff
changeset
|
857 var fileBrowserListeners = function(current_url, node_list_url, url_base){ |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
858 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
|
859 |
4159
a991e5c57a8d
rhodecode.js: Get rid of some more YUI
Andrew Shadura <andrew@shadura.me>
parents:
4158
diff
changeset
|
860 $('#stay_at_branch').on('click',function(e){ |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
861 if(e.currentTarget.checked){ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
862 var uri = current_url_branch; |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
863 uri = uri.replace('__BRANCH__',e.currentTarget.value); |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
864 window.location = uri; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
865 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
866 else{ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
867 window.location = current_url; |
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 }) |
1699
623b228cf325
cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents:
1685
diff
changeset
|
870 |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
871 var $node_filter = $('#node_filter'); |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
872 |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
873 var filterTimeout = null; |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
874 var nodes = null; |
1699
623b228cf325
cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents:
1685
diff
changeset
|
875 |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
876 var initFilter = function(){ |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
877 $('#node_filter_box_loading').show(); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
878 $('#search_activate_id').hide(); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
879 $('#add_node_id').hide(); |
4158
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
880 YUC.initHeader('X-PARTIAL-XHR',true); |
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
881 YUC.asyncRequest('GET', node_list_url, { |
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
882 success:function(o){ |
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
883 nodes = JSON.parse(o.responseText).nodes; |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
884 $('#node_filter_box_loading').hide(); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
885 $('#node_filter_box').show(); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
886 $node_filter.focus(); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
887 if($node_filter.hasClass('init')){ |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
888 $node_filter.val(''); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
889 $node_filter.removeClass('init'); |
4158
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
890 } |
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
891 }, |
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
892 failure:function(o){ |
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
893 console.log('failed to load'); |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
894 } |
4158
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
895 },null); |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
896 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
897 |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
898 var updateFilter = function(e) { |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
899 return function(){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
900 // Reset timeout |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
901 filterTimeout = null; |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
902 var query = e.currentTarget.value.toLowerCase(); |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
903 var match = []; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
904 var matches = 0; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
905 var matches_max = 20; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
906 if (query != ""){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
907 for(var i=0;i<nodes.length;i++){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
908 var pos = nodes[i].name.toLowerCase().indexOf(query) |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
909 if(query && pos != -1){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
910 matches++ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
911 //show only certain amount to not kill browser |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
912 if (matches > matches_max){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
913 break; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
914 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
915 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
916 var n = nodes[i].name; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
917 var t = nodes[i].type; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
918 var n_hl = n.substring(0,pos) |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
919 +"<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
|
920 +n.substring(pos+query.length) |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
921 var new_url = url_base.replace('__FPATH__',n); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
922 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
|
923 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
924 if(match.length >= matches_max){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
925 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
|
926 } |
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 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
929 if(query != ""){ |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
930 $('#tbody').hide(); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
931 $('#tbody_filtered').show(); |
1699
623b228cf325
cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents:
1685
diff
changeset
|
932 |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
933 if (match.length==0){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
934 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
|
935 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
936 |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
937 $('#tbody_filtered').html(match.join("")); |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
938 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
939 else{ |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
940 $('#tbody').show(); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
941 $('#tbody_filtered').hide(); |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
942 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
943 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
944 }; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
945 |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
946 $('#filter_activate').click(function(){ |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
947 initFilter(); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
948 }); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
949 $node_filter.click(function(){ |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
950 if($node_filter.hasClass('init')){ |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
951 $node_filter.val(''); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
952 $node_filter.removeClass('init'); |
4158
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
953 } |
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
954 }); |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
955 $node_filter.keyup(function(e){ |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
956 clearTimeout(filterTimeout); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
957 filterTimeout = setTimeout(updateFilter(e),600); |
4158
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
958 }); |
1699
623b228cf325
cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents:
1685
diff
changeset
|
959 }; |
623b228cf325
cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents:
1685
diff
changeset
|
960 |
623b228cf325
cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents:
1685
diff
changeset
|
961 |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
962 var initCodeMirror = function(textarea_id, resetUrl){ |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
963 var myCodeMirror = CodeMirror.fromTextArea($('#' + textarea_id)[0], { |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
964 mode: "null", |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
965 lineNumbers: true, |
4158
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
966 indentUnit: 4 |
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
967 }); |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
968 $('#reset').click(function(e){ |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
969 window.location=resetUrl; |
4158
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
970 }); |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
971 |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
972 $('#file_enable').click(function(){ |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
973 $('#editor_container').show(); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
974 $('#upload_file_container').hide(); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
975 $('#filename_container').show(); |
4158
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
976 }); |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
977 |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
978 $('#upload_file_enable').click(function(){ |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
979 $('#editor_container').hide(); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
980 $('#upload_file_container').show(); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
981 $('#filename_container').hide(); |
4158
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
982 }); |
4026
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
3966
diff
changeset
|
983 |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
3966
diff
changeset
|
984 return myCodeMirror |
1699
623b228cf325
cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents:
1685
diff
changeset
|
985 }; |
623b228cf325
cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents:
1685
diff
changeset
|
986 |
4026
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
3966
diff
changeset
|
987 var setCodeMirrorMode = function(codeMirrorInstance, mode) { |
4158
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
988 codeMirrorInstance.setOption("mode", mode); |
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
989 CodeMirror.autoLoadMode(codeMirrorInstance, mode); |
4026
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
3966
diff
changeset
|
990 } |
1699
623b228cf325
cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents:
1685
diff
changeset
|
991 |
623b228cf325
cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents:
1685
diff
changeset
|
992 |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
993 var _getIdentNode = function(n){ |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
994 //iterate thrugh nodes until matching interesting node |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
995 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
996 if (typeof n == 'undefined'){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
997 return -1 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
998 } |
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 if(typeof n.id != "undefined" && n.id.match('L[0-9]+')){ |
4158
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
1001 return n |
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
1002 } |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1003 else{ |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1004 return _getIdentNode(n.parentNode); |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1005 } |
1699
623b228cf325
cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents:
1685
diff
changeset
|
1006 }; |
623b228cf325
cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents:
1685
diff
changeset
|
1007 |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1008 /* generate links for multi line selects that can be shown by files.html page_highlights. |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1009 * This is a mouseup handler for hlcode from CodeHtmlFormatter and pygmentize */ |
4158
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
1010 var getSelectionLink = function(e) { |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1011 //get selection from start/to nodes |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1012 if (typeof window.getSelection != "undefined") { |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1013 s = window.getSelection(); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1014 |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1015 from = _getIdentNode(s.anchorNode); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1016 till = _getIdentNode(s.focusNode); |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1017 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1018 f_int = parseInt(from.id.replace('L','')); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1019 t_int = parseInt(till.id.replace('L','')); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1020 |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1021 var yoffset = 35; |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1022 var ranges = [parseInt(from.id.replace('L','')), parseInt(till.id.replace('L',''))]; |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1023 if (ranges[0] > ranges[1]){ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1024 //highlight from bottom |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1025 yoffset = -yoffset; |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1026 ranges = [ranges[1], ranges[0]]; |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1027 } |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1028 var $hl_div = $('div#linktt'); |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1029 // if we select more than 2 lines |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1030 if (ranges[0] != ranges[1]){ |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1031 if ($hl_div.length) { |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1032 $hl_div.html(''); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1033 } else { |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1034 $hl_div = $('<div id="linktt" class="hl-tip-box">'); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1035 $('body').prepend($hl_div); |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1036 } |
3081
b2c7f7c5ce11
fixed source selection link pop-up tooltip
Marcin Kuzminski <marcin@python-works.com>
parents:
3066
diff
changeset
|
1037 |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1038 $hl_div.append($('<a>').html(_TM['Selection link']).attr('href', location.href.substring(0, location.href.indexOf('#')) + '#L' + ranges[0] + '-'+ranges[1])); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1039 xy = $(till).offset(); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1040 $hl_div.css('top', (xy.top + yoffset) + 'px').css('left', xy.left + 'px'); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1041 $hl_div.show(); |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1042 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1043 else{ |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1044 $hl_div.hide(); |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1045 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1046 } |
1699
623b228cf325
cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents:
1685
diff
changeset
|
1047 }; |
1712
cac5109ac3b6
Notification system improvements
Marcin Kuzminski <marcin@python-works.com>
parents:
1705
diff
changeset
|
1048 |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1049 var deleteNotification = function(url, notification_id, callbacks){ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1050 var callback = { |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1051 success:function(o){ |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1052 $("#notification_"+notification_id).remove(); |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1053 _run_callbacks(callbacks); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1054 }, |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1055 failure:function(o){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1056 alert("error"); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1057 }, |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1058 }; |
1712
cac5109ac3b6
Notification system improvements
Marcin Kuzminski <marcin@python-works.com>
parents:
1705
diff
changeset
|
1059 var postData = '_method=delete'; |
cac5109ac3b6
Notification system improvements
Marcin Kuzminski <marcin@python-works.com>
parents:
1705
diff
changeset
|
1060 var sUrl = url.replace('__NOTIFICATION_ID__',notification_id); |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1061 var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1062 callback, postData); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1063 }; |
1778
defcf245f3e9
fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
1064 |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1065 var readNotification = function(url, notification_id, callbacks){ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1066 var callback = { |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1067 success:function(o){ |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1068 var $obj = $("#notification_"+notification_id); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1069 $obj.removeClass('unread'); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1070 $obj.find('.read-notification').remove(); |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1071 _run_callbacks(callbacks); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1072 }, |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1073 failure:function(o){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1074 alert("error"); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1075 }, |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1076 }; |
2610
3fdf7c3be2c9
added mark as read for single notifications
Marcin Kuzminski <marcin@python-works.com>
parents:
2608
diff
changeset
|
1077 var postData = '_method=put'; |
3fdf7c3be2c9
added mark as read for single notifications
Marcin Kuzminski <marcin@python-works.com>
parents:
2608
diff
changeset
|
1078 var sUrl = url.replace('__NOTIFICATION_ID__',notification_id); |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1079 var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1080 callback, postData); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1081 }; |
1778
defcf245f3e9
fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
1082 |
2142
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1083 /** MEMBERS AUTOCOMPLETE WIDGET **/ |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1084 |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1085 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
|
1086 var myUsers = users_list; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1087 var myGroups = groups_list; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1088 |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1089 // 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
|
1090 var matchUsers = function (sQuery) { |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1091 // Case insensitive matching |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1092 var query = sQuery.toLowerCase(); |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1093 var i = 0; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1094 var l = myUsers.length; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1095 var matches = []; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1096 |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1097 // 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
|
1098 for (; i < l; i++) { |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1099 contact = myUsers[i]; |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1100 if (((contact.fname+"").toLowerCase().indexOf(query) > -1) || |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1101 ((contact.lname+"").toLowerCase().indexOf(query) > -1) || |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1102 ((contact.nname) && ((contact.nname).toLowerCase().indexOf(query) > -1))) { |
4158
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
1103 matches[matches.length] = contact; |
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
1104 } |
2142
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1105 } |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1106 return matches; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1107 }; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1108 |
3417
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3403
diff
changeset
|
1109 // 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
|
1110 var matchGroups = function (sQuery) { |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1111 // Case insensitive matching |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1112 var query = sQuery.toLowerCase(); |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1113 var i = 0; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1114 var l = myGroups.length; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1115 var matches = []; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1116 |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1117 // 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
|
1118 for (; i < l; i++) { |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1119 matched_group = myGroups[i]; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1120 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
|
1121 matches[matches.length] = matched_group; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1122 } |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1123 } |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1124 return matches; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1125 }; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1126 |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1127 //match all |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1128 var matchAll = function (sQuery) { |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1129 u = matchUsers(sQuery); |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1130 g = matchGroups(sQuery); |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1131 return u.concat(g); |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1132 }; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1133 |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1134 // DataScheme for members |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1135 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
|
1136 memberDS.responseSchema = { |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1137 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
|
1138 }; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1139 |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1140 // DataScheme for owner |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1141 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
|
1142 ownerDS.responseSchema = { |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1143 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
|
1144 }; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1145 |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1146 // 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
|
1147 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
|
1148 membersAC.useShadow = false; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1149 membersAC.resultTypeList = false; |
2611
e83be26bb8d8
disable animation on autocomplete widget
Marcin Kuzminski <marcin@python-works.com>
parents:
2610
diff
changeset
|
1150 membersAC.animVert = false; |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1151 membersAC.animHoriz = false; |
2611
e83be26bb8d8
disable animation on autocomplete widget
Marcin Kuzminski <marcin@python-works.com>
parents:
2610
diff
changeset
|
1152 membersAC.animSpeed = 0.1; |
2142
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1153 |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1154 // Instantiate AutoComplete for owner |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1155 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
|
1156 ownerAC.useShadow = false; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1157 ownerAC.resultTypeList = false; |
2611
e83be26bb8d8
disable animation on autocomplete widget
Marcin Kuzminski <marcin@python-works.com>
parents:
2610
diff
changeset
|
1158 ownerAC.animVert = false; |
e83be26bb8d8
disable animation on autocomplete widget
Marcin Kuzminski <marcin@python-works.com>
parents:
2610
diff
changeset
|
1159 ownerAC.animHoriz = false; |
e83be26bb8d8
disable animation on autocomplete widget
Marcin Kuzminski <marcin@python-works.com>
parents:
2610
diff
changeset
|
1160 ownerAC.animSpeed = 0.1; |
2142
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1161 |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1162 // 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
|
1163 var highlightMatch = function (full, snippet, matchindex) { |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1164 return full.substring(0, matchindex) |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1165 + "<span class='match'>" |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1166 + 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
|
1167 + "</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
|
1168 }; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1169 |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1170 // 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
|
1171 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
|
1172 var query = sQuery.toLowerCase(); |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1173 var _gravatar = function(res, em, group){ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1174 if (group !== undefined){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1175 em = '/images/icons/group.png' |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1176 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1177 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
|
1178 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
|
1179 } |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1180 // group |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1181 if (oResultData.grname != undefined) { |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1182 var grname = oResultData.grname; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1183 var grmembers = oResultData.grmembers; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1184 var grnameMatchIndex = grname.toLowerCase().indexOf(query); |
2369
c2f131502037
Autocomplete fixes
Marcin Kuzminski <marcin@python-works.com>
parents:
2368
diff
changeset
|
1185 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
|
1186 var grsuffix = " (" + grmembers + " )"; |
2369
c2f131502037
Autocomplete fixes
Marcin Kuzminski <marcin@python-works.com>
parents:
2368
diff
changeset
|
1187 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
|
1188 |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1189 if (grnameMatchIndex > -1) { |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1190 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
|
1191 } |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1192 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
|
1193 // Users |
2369
c2f131502037
Autocomplete fixes
Marcin Kuzminski <marcin@python-works.com>
parents:
2368
diff
changeset
|
1194 } else if (oResultData.nname != undefined) { |
c2f131502037
Autocomplete fixes
Marcin Kuzminski <marcin@python-works.com>
parents:
2368
diff
changeset
|
1195 var fname = oResultData.fname || ""; |
c2f131502037
Autocomplete fixes
Marcin Kuzminski <marcin@python-works.com>
parents:
2368
diff
changeset
|
1196 var lname = oResultData.lname || ""; |
c2f131502037
Autocomplete fixes
Marcin Kuzminski <marcin@python-works.com>
parents:
2368
diff
changeset
|
1197 var nname = oResultData.nname; |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1198 |
2369
c2f131502037
Autocomplete fixes
Marcin Kuzminski <marcin@python-works.com>
parents:
2368
diff
changeset
|
1199 // Guard against null value |
c2f131502037
Autocomplete fixes
Marcin Kuzminski <marcin@python-works.com>
parents:
2368
diff
changeset
|
1200 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
|
1201 lnameMatchIndex = lname.toLowerCase().indexOf(query), |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1202 nnameMatchIndex = nname.toLowerCase().indexOf(query), |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1203 displayfname, displaylname, displaynname; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1204 |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1205 if (fnameMatchIndex > -1) { |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1206 displayfname = highlightMatch(fname, query, fnameMatchIndex); |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1207 } else { |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1208 displayfname = fname; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1209 } |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1210 |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1211 if (lnameMatchIndex > -1) { |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1212 displaylname = highlightMatch(lname, query, lnameMatchIndex); |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1213 } else { |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1214 displaylname = lname; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1215 } |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1216 |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1217 if (nnameMatchIndex > -1) { |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1218 displaynname = "(" + highlightMatch(nname, query, nnameMatchIndex) + ")"; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1219 } else { |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1220 displaynname = nname ? "(" + nname + ")" : ""; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1221 } |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1222 |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1223 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
|
1224 } else { |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1225 return ''; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1226 } |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1227 }; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1228 membersAC.formatResult = custom_formatter; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1229 ownerAC.formatResult = custom_formatter; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1230 |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1231 var myHandler = function (sType, aArgs) { |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1232 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
|
1233 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
|
1234 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
|
1235 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
|
1236 //fill the autocomplete with value |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1237 if (oData.nname != undefined) { |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1238 //users |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1239 myAC.getInputEl().value = oData.nname; |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1240 $('#perm_new_member_type_'+nextId).val('user'); |
2142
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1241 } else { |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1242 //groups |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1243 myAC.getInputEl().value = oData.grname; |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1244 $('#perm_new_member_type_'+nextId).val('users_group'); |
2142
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1245 } |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1246 }; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1247 |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1248 membersAC.itemSelectEvent.subscribe(myHandler); |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1249 if(ownerAC.itemSelectEvent){ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1250 ownerAC.itemSelectEvent.subscribe(myHandler); |
2142
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1251 } |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1252 |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1253 return { |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1254 memberDS: memberDS, |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1255 ownerDS: ownerDS, |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1256 membersAC: membersAC, |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1257 ownerAC: ownerAC, |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1258 }; |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1259 } |
a21eab6ff42f
Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents:
2128
diff
changeset
|
1260 |
2369
c2f131502037
Autocomplete fixes
Marcin Kuzminski <marcin@python-works.com>
parents:
2368
diff
changeset
|
1261 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
|
1262 var myUsers = users_list; |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1263 var myGroups = groups_list; |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1264 |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1265 // 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
|
1266 var matchUsers = function (sQuery) { |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1267 var org_sQuery = sQuery; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1268 if(this.mentionQuery == null){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1269 return [] |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1270 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1271 sQuery = this.mentionQuery; |
2368
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1272 // Case insensitive matching |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1273 var query = sQuery.toLowerCase(); |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1274 var i = 0; |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1275 var l = myUsers.length; |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1276 var matches = []; |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1277 |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1278 // 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
|
1279 for (; i < l; i++) { |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1280 contact = myUsers[i]; |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1281 if (((contact.fname+"").toLowerCase().indexOf(query) > -1) || |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1282 ((contact.lname+"").toLowerCase().indexOf(query) > -1) || |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1283 ((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
|
1284 matches[matches.length] = contact; |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1285 } |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1286 } |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1287 return matches |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1288 }; |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1289 |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1290 //match all |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1291 var matchAll = function (sQuery) { |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1292 u = matchUsers(sQuery); |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1293 return u |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1294 }; |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1295 |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1296 // DataScheme for owner |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1297 var ownerDS = new YAHOO.util.FunctionDataSource(matchUsers); |
2369
c2f131502037
Autocomplete fixes
Marcin Kuzminski <marcin@python-works.com>
parents:
2368
diff
changeset
|
1298 |
2368
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1299 ownerDS.responseSchema = { |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1300 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
|
1301 }; |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1302 |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1303 // Instantiate AutoComplete for mentions |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1304 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
|
1305 ownerAC.useShadow = false; |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1306 ownerAC.resultTypeList = false; |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1307 ownerAC.suppressInputUpdate = true; |
2611
e83be26bb8d8
disable animation on autocomplete widget
Marcin Kuzminski <marcin@python-works.com>
parents:
2610
diff
changeset
|
1308 ownerAC.animVert = false; |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1309 ownerAC.animHoriz = false; |
2611
e83be26bb8d8
disable animation on autocomplete widget
Marcin Kuzminski <marcin@python-works.com>
parents:
2610
diff
changeset
|
1310 ownerAC.animSpeed = 0.1; |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1311 |
2368
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1312 // Helper highlight function for the formatter |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1313 var highlightMatch = function (full, snippet, matchindex) { |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1314 return full.substring(0, matchindex) |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1315 + "<span class='match'>" |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1316 + full.substr(matchindex, snippet.length) |
2368
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1317 + "</span>" + full.substring(matchindex + snippet.length); |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1318 }; |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1319 |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1320 // 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
|
1321 ownerAC.formatResult = function (oResultData, sQuery, sResultMatch) { |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1322 var org_sQuery = sQuery; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1323 if(this.dataSource.mentionQuery != null){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1324 sQuery = this.dataSource.mentionQuery; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1325 } |
2368
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1326 |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1327 var query = sQuery.toLowerCase(); |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1328 var _gravatar = function(res, em, group){ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1329 if (group !== undefined){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1330 em = '/images/icons/group.png' |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1331 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1332 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
|
1333 return tmpl.format(em,res) |
2368
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1334 } |
2369
c2f131502037
Autocomplete fixes
Marcin Kuzminski <marcin@python-works.com>
parents:
2368
diff
changeset
|
1335 if (oResultData.nname != undefined) { |
c2f131502037
Autocomplete fixes
Marcin Kuzminski <marcin@python-works.com>
parents:
2368
diff
changeset
|
1336 var fname = oResultData.fname || ""; |
c2f131502037
Autocomplete fixes
Marcin Kuzminski <marcin@python-works.com>
parents:
2368
diff
changeset
|
1337 var lname = oResultData.lname || ""; |
c2f131502037
Autocomplete fixes
Marcin Kuzminski <marcin@python-works.com>
parents:
2368
diff
changeset
|
1338 var nname = oResultData.nname; |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1339 |
2369
c2f131502037
Autocomplete fixes
Marcin Kuzminski <marcin@python-works.com>
parents:
2368
diff
changeset
|
1340 // Guard against null value |
c2f131502037
Autocomplete fixes
Marcin Kuzminski <marcin@python-works.com>
parents:
2368
diff
changeset
|
1341 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
|
1342 lnameMatchIndex = lname.toLowerCase().indexOf(query), |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1343 nnameMatchIndex = nname.toLowerCase().indexOf(query), |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1344 displayfname, displaylname, displaynname; |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1345 |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1346 if (fnameMatchIndex > -1) { |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1347 displayfname = highlightMatch(fname, query, fnameMatchIndex); |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1348 } else { |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1349 displayfname = fname; |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1350 } |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1351 |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1352 if (lnameMatchIndex > -1) { |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1353 displaylname = highlightMatch(lname, query, lnameMatchIndex); |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1354 } else { |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1355 displaylname = lname; |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1356 } |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1357 |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1358 if (nnameMatchIndex > -1) { |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1359 displaynname = "(" + highlightMatch(nname, query, nnameMatchIndex) + ")"; |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1360 } else { |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1361 displaynname = nname ? "(" + nname + ")" : ""; |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1362 } |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1363 |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1364 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
|
1365 } else { |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1366 return ''; |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1367 } |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1368 }; |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1369 |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1370 if(ownerAC.itemSelectEvent){ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1371 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
|
1372 |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1373 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
|
1374 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
|
1375 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
|
1376 //fill the autocomplete with value |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1377 if (oData.nname != undefined) { |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1378 //users |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1379 //Replace the mention name with replaced |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1380 var re = new RegExp(); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1381 var org = myAC.getInputEl().value; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1382 var chunks = myAC.dataSource.chunks |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1383 // replace middle chunk(the search term) with actuall match |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1384 chunks[1] = chunks[1].replace('@'+myAC.dataSource.mentionQuery, |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1385 '@'+oData.nname+' '); |
2368
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1386 myAC.getInputEl().value = chunks.join('') |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1387 myAC.getInputEl().focus(); // Y U NO WORK !? |
2368
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1388 } else { |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1389 //groups |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1390 myAC.getInputEl().value = oData.grname; |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1391 $('#perm_new_member_type').val('users_group'); |
2368
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1392 } |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1393 }); |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1394 } |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1395 |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1396 // 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
|
1397 // 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
|
1398 // search |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1399 ownerAC.dataSource.chunks = []; |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1400 ownerAC.dataSource.mentionQuery = null; |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1401 |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1402 ownerAC.get_mention = function(msg, max_pos) { |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1403 var org = msg; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1404 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
|
1405 var chunks = []; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1406 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1407 // cut first chunk until curret pos |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1408 var to_max = msg.substr(0, max_pos); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1409 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
|
1410 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
|
1411 |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1412 chunks.push(org.substr(0,at_pos))// prefix chunk |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1413 chunks.push(msg2) // search chunk |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1414 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
|
1415 |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1416 // clean up msg2 for filtering and regex match |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1417 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
|
1418 |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1419 if(re.test(msg2)){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1420 var unam = re.exec(msg2)[1]; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1421 return [unam, chunks]; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1422 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1423 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
|
1424 }; |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1425 |
2698
4debfe3b50be
ie8 fixes for inline comments :/
Marcin Kuzminski <marcin@python-works.com>
parents:
2694
diff
changeset
|
1426 if (ownerAC.textboxKeyUpEvent){ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1427 ownerAC.textboxKeyUpEvent.subscribe(function(type, args){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1428 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1429 var ac_obj = args[0]; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1430 var currentMessage = args[1]; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1431 var currentCaretPosition = args[0]._elTextbox.selectionStart; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1432 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1433 var unam = ownerAC.get_mention(currentMessage, currentCaretPosition); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1434 var curr_search = null; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1435 if(unam[0]){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1436 curr_search = unam[0]; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1437 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1438 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1439 ownerAC.dataSource.chunks = unam[1]; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1440 ownerAC.dataSource.mentionQuery = curr_search; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1441 |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1442 }) |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1443 } |
2368
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1444 return { |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1445 ownerDS: ownerDS, |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1446 ownerAC: ownerAC, |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1447 }; |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1448 } |
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1449 |
3388
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
1450 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
|
1451 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
|
1452 '<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
|
1453 '<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
|
1454 '<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
|
1455 '<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
|
1456 '<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
|
1457 '</div>'+ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1458 '</li>' ; |
3388
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
1459 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
|
1460 var element = tmpl.format(gravatar_link,displayname,id); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1461 // 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
|
1462 var ids = []; |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1463 $('#review_members').find('li').each(function() { |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1464 ids.push(this.id); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1465 }); |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1466 if(ids.indexOf('reviewer_'+id) == -1){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1467 //only add if it's not there |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1468 $('#review_members').append(element); |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1469 } |
3388
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
1470 } |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
1471 |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
1472 var removeReviewMember = function(reviewer_id, repo_name, pull_request_id){ |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1473 $('#reviewer_{0}'.format(reviewer_id)).remove(); |
3388
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
1474 } |
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
1475 |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1476 /* handle "Save Changes" of addReviewMember and removeReviewMember on PR */ |
3388
cb40b3f6428c
review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents:
3247
diff
changeset
|
1477 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
|
1478 if (reviewers_ids === undefined){ |
4158
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
1479 var reviewers_ids = []; |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1480 $('#review_members').find('input').each(function(){ |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1481 reviewers_ids.push(this.value); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1482 }); |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1483 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1484 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
|
1485 "pull_request_id": pull_request_id}); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1486 var postData = {'_method':'put', |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1487 'reviewers_ids': reviewers_ids}; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1488 var success = function(o){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1489 window.location.reload(); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1490 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1491 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
|
1492 } |
2368
5143b8df576c
Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents:
2189
diff
changeset
|
1493 |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1494 /* activate auto completion of users and groups ... but only used for users as PR reviewers */ |
2612
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1495 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
|
1496 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
|
1497 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
|
1498 |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1499 // 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
|
1500 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
|
1501 // 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
|
1502 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
|
1503 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
|
1504 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
|
1505 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
|
1506 |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1507 // 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
|
1508 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
|
1509 contact = myUsers[i]; |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1510 if (((contact.fname+"").toLowerCase().indexOf(query) > -1) || |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1511 ((contact.lname+"").toLowerCase().indexOf(query) > -1) || |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1512 ((contact.nname) && ((contact.nname).toLowerCase().indexOf(query) > -1))) { |
4158
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
1513 matches[matches.length] = contact; |
e4848cd9c8ae
rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents:
4157
diff
changeset
|
1514 } |
2612
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1515 } |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1516 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
|
1517 }; |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1518 |
3417
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3403
diff
changeset
|
1519 // 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
|
1520 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
|
1521 // 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
|
1522 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
|
1523 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
|
1524 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
|
1525 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
|
1526 |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1527 // 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
|
1528 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
|
1529 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
|
1530 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
|
1531 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
|
1532 } |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1533 } |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1534 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
|
1535 }; |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1536 |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1537 //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
|
1538 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
|
1539 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
|
1540 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
|
1541 }; |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1542 |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1543 // 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
|
1544 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
|
1545 |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1546 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
|
1547 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
|
1548 }; |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1549 |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1550 // 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
|
1551 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
|
1552 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
|
1553 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
|
1554 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
|
1555 reviewerAC.animVert = false; |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1556 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
|
1557 reviewerAC.animSpeed = 0.1; |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1558 |
2612
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1559 // 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
|
1560 var highlightMatch = function (full, snippet, matchindex) { |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1561 return full.substring(0, matchindex) |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1562 + "<span class='match'>" |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1563 + 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
|
1564 + "</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
|
1565 }; |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1566 |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1567 // 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
|
1568 reviewerAC.formatResult = function (oResultData, sQuery, sResultMatch) { |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1569 var org_sQuery = sQuery; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1570 if(this.dataSource.mentionQuery != null){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1571 sQuery = this.dataSource.mentionQuery; |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1572 } |
2612
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1573 |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1574 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
|
1575 var _gravatar = function(res, em, group){ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1576 if (group !== undefined){ |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1577 em = '/images/icons/group.png' |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1578 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1579 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
|
1580 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
|
1581 } |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1582 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
|
1583 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
|
1584 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
|
1585 var nname = oResultData.nname; |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1586 |
2612
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1587 // 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
|
1588 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
|
1589 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
|
1590 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
|
1591 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
|
1592 |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1593 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
|
1594 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
|
1595 } else { |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1596 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
|
1597 } |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1598 |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1599 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
|
1600 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
|
1601 } else { |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1602 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
|
1603 } |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1604 |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1605 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
|
1606 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
|
1607 } else { |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1608 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
|
1609 } |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1610 |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1611 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
|
1612 } else { |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1613 return ''; |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1614 } |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1615 }; |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1616 |
2612
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1617 //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
|
1618 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
|
1619 // 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
|
1620 if(reviewerAC.itemSelectEvent){ |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1621 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
|
1622 |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1623 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
|
1624 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
|
1625 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
|
1626 |
2612
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1627 //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
|
1628 if (oData.nname != undefined) { |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1629 addReviewMember(oData.id, oData.fname, oData.lname, oData.nname, |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1630 oData.gravatar_lnk); |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1631 myAC.dataSource.cache.push(oData.id); |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1632 $('#user').val(''); |
2612
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1633 } |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1634 }); |
2612
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1635 } |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1636 } |
9364776d1331
Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents:
2611
diff
changeset
|
1637 |
1778
defcf245f3e9
fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
1638 /** |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1639 * Activate .quick_repo_menu |
1779
9edd6ac132f0
Added sorting into journal and admin pages
Marcin Kuzminski <marcin@python-works.com>
parents:
1778
diff
changeset
|
1640 */ |
9edd6ac132f0
Added sorting into journal and admin pages
Marcin Kuzminski <marcin@python-works.com>
parents:
1778
diff
changeset
|
1641 var quick_repo_menu = function(){ |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1642 $(".quick_repo_menu").mouseenter(function(e) { |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1643 var $menu = $(e.currentTarget).children().first().children().first(); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1644 if($menu.hasClass('hidden')){ |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1645 $menu.removeClass('hidden').addClass('active'); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1646 $(e.currentTarget).removeClass('hidden').addClass('active'); |
2088
382df4e69dfc
quick_repo_menu changed from mouseclick to popup
Marcin Kuzminski <marcin@python-works.com>
parents:
2087
diff
changeset
|
1647 } |
382df4e69dfc
quick_repo_menu changed from mouseclick to popup
Marcin Kuzminski <marcin@python-works.com>
parents:
2087
diff
changeset
|
1648 }) |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1649 $(".quick_repo_menu").mouseleave(function(e) { |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1650 var $menu = $(e.currentTarget).children().first().children().first(); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1651 if($menu.hasClass('active')){ |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1652 $menu.removeClass('active').addClass('hidden'); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1653 $(e.currentTarget).removeClass('active').addClass('hidden'); |
2088
382df4e69dfc
quick_repo_menu changed from mouseclick to popup
Marcin Kuzminski <marcin@python-works.com>
parents:
2087
diff
changeset
|
1654 } |
382df4e69dfc
quick_repo_menu changed from mouseclick to popup
Marcin Kuzminski <marcin@python-works.com>
parents:
2087
diff
changeset
|
1655 }) |
1779
9edd6ac132f0
Added sorting into journal and admin pages
Marcin Kuzminski <marcin@python-works.com>
parents:
1778
diff
changeset
|
1656 }; |
9edd6ac132f0
Added sorting into journal and admin pages
Marcin Kuzminski <marcin@python-works.com>
parents:
1778
diff
changeset
|
1657 |
9edd6ac132f0
Added sorting into journal and admin pages
Marcin Kuzminski <marcin@python-works.com>
parents:
1778
diff
changeset
|
1658 |
9edd6ac132f0
Added sorting into journal and admin pages
Marcin Kuzminski <marcin@python-works.com>
parents:
1778
diff
changeset
|
1659 /** |
1778
defcf245f3e9
fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
1660 * TABLE SORTING |
defcf245f3e9
fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
1661 */ |
defcf245f3e9
fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
1662 |
defcf245f3e9
fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
1663 var revisionSort = function(a, b, desc, field) { |
4165
330d935054ca
rhodecode.js: use last_rev_raw field for revisionSort and raw_date for dateSort, numerical, default 0
Mads Kiilerich <madski@unity3d.com>
parents:
4164
diff
changeset
|
1664 var a_ = parseInt(a.getData('last_rev_raw') || 0); |
330d935054ca
rhodecode.js: use last_rev_raw field for revisionSort and raw_date for dateSort, numerical, default 0
Mads Kiilerich <madski@unity3d.com>
parents:
4164
diff
changeset
|
1665 var b_ = parseInt(b.getData('last_rev_raw') || 0); |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1666 |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1667 return YAHOO.util.Sort.compare(a_, b_, desc); |
1778
defcf245f3e9
fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
1668 }; |
4157
bc296381fb6c
rhodecode.js: remove unused stuff
Mads Kiilerich <madski@unity3d.com>
parents:
4135
diff
changeset
|
1669 |
1778
defcf245f3e9
fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
1670 var ageSort = function(a, b, desc, field) { |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1671 // data is like: <span class="tooltip" date="2014-06-04 18:18:55.325474" title="Wed, 04 Jun 2014 18:18:55">1 day and 23 hours ago</span> |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1672 var a_ = $(a.getData(field)).attr('date'); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1673 var b_ = $(b.getData(field)).attr('date'); |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1674 |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1675 return YAHOO.util.Sort.compare(a_, b_, desc); |
1778
defcf245f3e9
fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
1676 }; |
defcf245f3e9
fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
1677 |
2699
4eef5eeb81a3
fixed sorting by last_login in users admin page
Marcin Kuzminski <marcin@python-works.com>
parents:
2698
diff
changeset
|
1678 var lastLoginSort = function(a, b, desc, field) { |
4165
330d935054ca
rhodecode.js: use last_rev_raw field for revisionSort and raw_date for dateSort, numerical, default 0
Mads Kiilerich <madski@unity3d.com>
parents:
4164
diff
changeset
|
1679 var a_ = parseFloat(a.getData('last_login_raw') || 0); |
330d935054ca
rhodecode.js: use last_rev_raw field for revisionSort and raw_date for dateSort, numerical, default 0
Mads Kiilerich <madski@unity3d.com>
parents:
4164
diff
changeset
|
1680 var b_ = parseFloat(b.getData('last_login_raw') || 0); |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1681 |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1682 return YAHOO.util.Sort.compare(a_, b_, desc); |
2699
4eef5eeb81a3
fixed sorting by last_login in users admin page
Marcin Kuzminski <marcin@python-works.com>
parents:
2698
diff
changeset
|
1683 }; |
4eef5eeb81a3
fixed sorting by last_login in users admin page
Marcin Kuzminski <marcin@python-works.com>
parents:
2698
diff
changeset
|
1684 |
1778
defcf245f3e9
fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
1685 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
|
1686 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
|
1687 var b_ = b.getData('raw_name') || 0; |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1688 |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1689 return YAHOO.util.Sort.compare(a_, b_, desc); |
1778
defcf245f3e9
fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
1690 }; |
defcf245f3e9
fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
1691 |
1782
eaf09acf6872
added sorting to bookmarks tags and branches
Marcin Kuzminski <marcin@python-works.com>
parents:
1779
diff
changeset
|
1692 var dateSort = function(a, b, desc, field) { |
4165
330d935054ca
rhodecode.js: use last_rev_raw field for revisionSort and raw_date for dateSort, numerical, default 0
Mads Kiilerich <madski@unity3d.com>
parents:
4164
diff
changeset
|
1693 var a_ = parseFloat(a.getData('raw_date') || 0); |
330d935054ca
rhodecode.js: use last_rev_raw field for revisionSort and raw_date for dateSort, numerical, default 0
Mads Kiilerich <madski@unity3d.com>
parents:
4164
diff
changeset
|
1694 var b_ = parseFloat(b.getData('raw_date') || 0); |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1695 |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1696 return YAHOO.util.Sort.compare(a_, b_, desc); |
2394
6776f4e569d7
Moved select widget to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
2369
diff
changeset
|
1697 }; |
6776f4e569d7
Moved select widget to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
2369
diff
changeset
|
1698 |
2759
c61c2ccea2b4
#538 form for permissions can handle multiple users at once
Marcin Kuzminski <marcin@python-works.com>
parents:
2723
diff
changeset
|
1699 var addPermAction = function(_html, users_list, groups_list){ |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1700 var $last_node = $('.last_new_member').last(); // empty tr between last and add |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1701 var next_id = $('.new_members').length; |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1702 $last_node.before($('<tr class="new_members">').append(_html.format(next_id))); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1703 _MembersAutoComplete("perm_new_member_name_"+next_id, |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1704 "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
|
1705 } |
4157
bc296381fb6c
rhodecode.js: remove unused stuff
Mads Kiilerich <madski@unity3d.com>
parents:
4135
diff
changeset
|
1706 |
3715
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
1707 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
|
1708 var callback = { |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
1709 success: function (o) { |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1710 $('#' + field_id).remove(); |
3715
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
1711 }, |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
1712 failure: function (o) { |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
1713 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
|
1714 }, |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
1715 }; |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
1716 query_params = { |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
1717 '_method': 'delete' |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
1718 } |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
1719 // put extra data into POST |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
1720 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
|
1721 for(k in extra_data){ |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
1722 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
|
1723 } |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
1724 } |
2394
6776f4e569d7
Moved select widget to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
2369
diff
changeset
|
1725 |
3715
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
1726 if (obj_type=='user'){ |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
1727 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
|
1728 query_params['obj_type'] = 'user'; |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
1729 } |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
1730 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
|
1731 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
|
1732 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
|
1733 } |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
1734 |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
1735 var request = YAHOO.util.Connect.asyncRequest('POST', url, callback, |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1736 _toQueryString(query_params)); |
3715
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3696
diff
changeset
|
1737 }; |
4157
bc296381fb6c
rhodecode.js: remove unused stuff
Mads Kiilerich <madski@unity3d.com>
parents:
4135
diff
changeset
|
1738 |
2394
6776f4e569d7
Moved select widget to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
2369
diff
changeset
|
1739 /* Multi selectors */ |
6776f4e569d7
Moved select widget to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
2369
diff
changeset
|
1740 |
6776f4e569d7
Moved select widget to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
2369
diff
changeset
|
1741 var MultiSelectWidget = function(selected_id, available_id, form_id){ |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1742 var $availableselect = $('#' + available_id); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1743 var $selectedselect = $('#' + selected_id); |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1744 |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1745 //fill available only with those not in selected |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1746 var $selectedoptions = $selectedselect.children('option'); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1747 $availableselect.children('option').filter(function(i, e){ |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1748 for(var j = 0, node; node = $selectedoptions[j]; j++){ |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1749 if(node.value == e.value){ |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1750 return true; |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1751 } |
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1752 } |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1753 return false; |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1754 }).remove(); |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1755 |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1756 $('#add_element').click(function(e){ |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1757 $selectedselect.append($availableselect.children('option:selected')); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1758 }); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1759 $('#remove_element').click(function(e){ |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1760 $availableselect.append($selectedselect.children('option:selected')); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1761 }); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1762 $('#add_all_elements').click(function(e){ |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1763 $selectedselect.append($availableselect.children('option')); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1764 }); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1765 $('#remove_all_elements').click(function(e){ |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1766 $availableselect.append($selectedselect.children('option')); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1767 }); |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1768 |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1769 $('#'+form_id).submit(function(){ |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1770 $selectedselect.children('option').each(function(i, e){ |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1771 e.selected = 'selected'; |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1772 }); |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
1773 }); |
2723
04aa0ea1ddd0
fixed comment addition and deletion functionality on IE9
Dies Koper <diesk@fast.au.fujitsu.com>
parents:
2699
diff
changeset
|
1774 } |
3419
efc00d363d1e
collapsable diff container in changeset, makes quick review easier
Marcin Kuzminski <marcin@python-works.com>
parents:
3417
diff
changeset
|
1775 |
3784
62fb395a459d
make sure we hide the spans
Marcin Kuzminski <marcin@python-works.com>
parents:
3776
diff
changeset
|
1776 // custom paginator |
62fb395a459d
make sure we hide the spans
Marcin Kuzminski <marcin@python-works.com>
parents:
3776
diff
changeset
|
1777 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
|
1778 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1779 (function () { |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1780 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1781 var Paginator = YAHOO.widget.Paginator, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1782 l = YAHOO.lang, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1783 setId = YAHOO.util.Dom.generateId; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1784 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1785 Paginator.ui.MyFirstPageLink = function (p) { |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1786 this.paginator = p; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1787 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1788 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
|
1789 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
|
1790 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
|
1791 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
|
1792 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1793 // TODO: make this work |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1794 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
|
1795 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
|
1796 }; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1797 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1798 Paginator.ui.MyFirstPageLink.init = function (p) { |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1799 p.setAttributeConfig('firstPageLinkLabel', { |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1800 value : 1, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1801 validator : l.isString |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1802 }); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1803 p.setAttributeConfig('firstPageLinkClass', { |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1804 value : 'yui-pg-first', |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1805 validator : l.isString |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1806 }); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1807 p.setAttributeConfig('firstPageLinkTitle', { |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1808 value : 'First Page', |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1809 validator : l.isString |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1810 }); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1811 }; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1812 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1813 // Instance members and methods |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1814 Paginator.ui.MyFirstPageLink.prototype = { |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1815 current : null, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1816 leftmost_page: null, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1817 rightmost_page: null, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1818 link : null, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1819 span : null, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1820 dotdot : null, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1821 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
|
1822 var edge = parseInt(items / 2) + 1; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1823 if (cur_page <= edge){ |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1824 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
|
1825 } |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1826 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
|
1827 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
|
1828 } |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1829 else{ |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1830 var radius = parseInt(items / 2); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1831 } |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1832 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1833 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
|
1834 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
|
1835 return [left, cur_page, right] |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1836 }, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1837 render : function (id_base) { |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1838 var p = this.paginator, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1839 c = p.get('firstPageLinkClass'), |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1840 label = p.get('firstPageLinkLabel'), |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1841 title = p.get('firstPageLinkTitle'); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1842 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1843 this.link = document.createElement('a'); |
3784
62fb395a459d
make sure we hide the spans
Marcin Kuzminski <marcin@python-works.com>
parents:
3776
diff
changeset
|
1844 this.span = document.createElement('span'); |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1845 $(this.span).hide(); |
3776
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1846 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1847 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
|
1848 this.leftmost_page = _pos[0]; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1849 this.rightmost_page = _pos[2]; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1850 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1851 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
|
1852 this.link.href = '#'; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1853 this.link.className = c; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1854 this.link.innerHTML = label; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1855 this.link.title = title; |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1856 YUE.on(this.link,'click',this.onClick,this,true); |
3776
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1857 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1858 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
|
1859 this.span.className = c; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1860 this.span.innerHTML = label; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1861 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1862 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
|
1863 return this.current; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1864 }, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1865 update : function (e) { |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1866 var p = this.paginator; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1867 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
|
1868 this.leftmost_page = _pos[0]; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1869 this.rightmost_page = _pos[2]; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1870 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1871 if (e && e.prevValue === e.newValue) { |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1872 return; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1873 } |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1874 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1875 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
|
1876 if (this.leftmost_page > 1) { |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1877 if (par && this.current === this.span) { |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1878 par.replaceChild(this.link,this.current); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1879 this.current = this.link; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1880 } |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1881 } else { |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1882 if (par && this.current === this.link) { |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1883 par.replaceChild(this.span,this.current); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1884 this.current = this.span; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1885 } |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1886 } |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1887 }, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1888 destroy : function () { |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1889 YUE.purgeElement(this.link); |
3776
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1890 this.current.parentNode.removeChild(this.current); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1891 this.link = this.span = null; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1892 }, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1893 onClick : function (e) { |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1894 YUE.stopEvent(e); |
3776
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1895 this.paginator.setPage(1); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1896 } |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1897 }; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1898 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1899 })(); |
4157
bc296381fb6c
rhodecode.js: remove unused stuff
Mads Kiilerich <madski@unity3d.com>
parents:
4135
diff
changeset
|
1900 |
3776
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1901 (function () { |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1902 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1903 var Paginator = YAHOO.widget.Paginator, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1904 l = YAHOO.lang, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1905 setId = YAHOO.util.Dom.generateId; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1906 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1907 Paginator.ui.MyLastPageLink = function (p) { |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1908 this.paginator = p; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1909 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1910 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
|
1911 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
|
1912 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
|
1913 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
|
1914 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1915 // TODO: make this work |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1916 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
|
1917 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
|
1918 }; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1919 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1920 Paginator.ui.MyLastPageLink.init = function (p) { |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1921 p.setAttributeConfig('lastPageLinkLabel', { |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1922 value : -1, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1923 validator : l.isString |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1924 }); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1925 p.setAttributeConfig('lastPageLinkClass', { |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1926 value : 'yui-pg-last', |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1927 validator : l.isString |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1928 }); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1929 p.setAttributeConfig('lastPageLinkTitle', { |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1930 value : 'Last Page', |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1931 validator : l.isString |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1932 }); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1933 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1934 }; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1935 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1936 Paginator.ui.MyLastPageLink.prototype = { |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1937 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1938 current : null, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1939 leftmost_page: null, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1940 rightmost_page: null, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1941 link : null, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1942 span : null, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1943 dotdot : null, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1944 na : null, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1945 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
|
1946 var edge = parseInt(items / 2) + 1; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1947 if (cur_page <= edge){ |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1948 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
|
1949 } |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1950 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
|
1951 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
|
1952 } |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1953 else{ |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1954 var radius = parseInt(items / 2); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1955 } |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1956 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1957 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
|
1958 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
|
1959 return [left, cur_page, right] |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1960 }, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1961 render : function (id_base) { |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1962 var p = this.paginator, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1963 c = p.get('lastPageLinkClass'), |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1964 label = p.get('lastPageLinkLabel'), |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1965 last = p.getTotalPages(), |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1966 title = p.get('lastPageLinkTitle'); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1967 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1968 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
|
1969 this.leftmost_page = _pos[0]; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1970 this.rightmost_page = _pos[2]; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1971 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1972 this.link = document.createElement('a'); |
3784
62fb395a459d
make sure we hide the spans
Marcin Kuzminski <marcin@python-works.com>
parents:
3776
diff
changeset
|
1973 this.span = document.createElement('span'); |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1974 $(this.span).hide(); |
3784
62fb395a459d
make sure we hide the spans
Marcin Kuzminski <marcin@python-works.com>
parents:
3776
diff
changeset
|
1975 |
3776
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1976 this.na = this.span.cloneNode(false); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1977 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1978 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
|
1979 this.link.href = '#'; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1980 this.link.className = c; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1981 this.link.innerHTML = label; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1982 this.link.title = title; |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
1983 YUE.on(this.link,'click',this.onClick,this,true); |
3776
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1984 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1985 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
|
1986 this.span.className = c; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1987 this.span.innerHTML = label; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1988 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1989 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
|
1990 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1991 if (this.rightmost_page < p.getTotalPages()){ |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1992 this.current = this.link; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1993 } |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1994 else{ |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1995 this.current = this.span; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1996 } |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1997 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1998 this.current.innerHTML = p.getTotalPages(); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
1999 return this.current; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2000 }, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2001 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2002 update : function (e) { |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2003 var p = this.paginator; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2004 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2005 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
|
2006 this.leftmost_page = _pos[0]; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2007 this.rightmost_page = _pos[2]; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2008 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2009 if (e && e.prevValue === e.newValue) { |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2010 return; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2011 } |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2012 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2013 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
|
2014 after = this.link; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2015 if (par) { |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2016 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2017 // 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
|
2018 // 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
|
2019 if (!(this.rightmost_page < p.getTotalPages())){ |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2020 after = this.span |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2021 } |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2022 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2023 if (this.current !== after) { |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2024 par.replaceChild(after,this.current); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2025 this.current = after; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2026 } |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2027 } |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2028 this.current.innerHTML = this.paginator.getTotalPages(); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2029 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2030 }, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2031 destroy : function () { |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
2032 YUE.purgeElement(this.link); |
3776
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2033 this.current.parentNode.removeChild(this.current); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2034 this.link = this.span = null; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2035 }, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2036 onClick : function (e) { |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
2037 YUE.stopEvent(e); |
3776
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2038 this.paginator.setPage(this.paginator.getTotalPages()); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2039 } |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2040 }; |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2041 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2042 })(); |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2043 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2044 var pagi = new YAHOO.widget.Paginator({ |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2045 rowsPerPage: links_per_page, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2046 alwaysVisible: false, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2047 template : "{PreviousPageLink} {MyFirstPageLink} {PageLinks} {MyLastPageLink} {NextPageLink}", |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2048 pageLinks: 5, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2049 containerClass: 'pagination-wh', |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2050 currentPageClass: 'pager_curpage', |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2051 pageLinkClass: 'pager_link', |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2052 nextPageLinkLabel: '>', |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2053 previousPageLinkLabel: '<', |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2054 containers:containers |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2055 }) |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2056 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2057 return pagi |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2058 } |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2059 |
4164
197bfc8a4f03
rhodecode.js: make YUI_datatable 25 rows configurable as last param
Mads Kiilerich <madski@unity3d.com>
parents:
4163
diff
changeset
|
2060 var YUI_datatable = function(data, fields, columns, countnode, sortkey, rows){ |
4163
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2061 var myDataSource = new YAHOO.util.DataSource(data); |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2062 myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON; |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2063 myDataSource.responseSchema = { |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2064 resultsList: "records", |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2065 fields: fields, |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2066 }; |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2067 myDataSource.doBeforeCallback = function(req, raw, res, cb) { |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2068 // This is the filter function |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2069 var data = res.results || [], |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2070 filtered = [], |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2071 i, l; |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2072 |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2073 if (req) { |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2074 req = req.toLowerCase(); |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2075 for (i = 0; i<data.length; i++) { |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2076 var pos = data[i].raw_name.toLowerCase().indexOf(req) |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2077 if (pos != -1) { |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2078 filtered.push(data[i]); |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2079 } |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2080 } |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2081 res.results = filtered; |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2082 } |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2083 $(countnode).html(res.results.length); |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2084 return res; |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2085 } |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2086 |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2087 var myDataTable = new YAHOO.widget.DataTable("datatable_list_wrap", columns, myDataSource, { |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2088 sortedBy: {key:sortkey, dir:"asc"}, |
4164
197bfc8a4f03
rhodecode.js: make YUI_datatable 25 rows configurable as last param
Mads Kiilerich <madski@unity3d.com>
parents:
4163
diff
changeset
|
2089 paginator: YUI_paginator(rows !== undefined && rows ? rows : 25, ['user-paginator']), |
4163
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2090 MSG_SORTASC: _TM['MSG_SORTASC'], |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2091 MSG_SORTDESC: _TM['MSG_SORTDESC'], |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2092 MSG_EMPTY: _TM['MSG_EMPTY'], |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2093 MSG_ERROR: _TM['MSG_ERROR'], |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2094 MSG_LOADING: _TM['MSG_LOADING'], |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2095 }); |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2096 myDataTable.subscribe('postRenderEvent',function(oArgs) { |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2097 tooltip_activate(); |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2098 quick_repo_menu(); |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2099 }); |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2100 |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2101 var filterTimeout = null; |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2102 var $q_filter = $('#q_filter'); |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2103 |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2104 updateFilter = function () { |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2105 // Reset timeout |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2106 filterTimeout = null; |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2107 |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2108 // Reset sort |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2109 var state = myDataTable.getState(); |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2110 state.sortedBy = {key:sortkey, dir:YAHOO.widget.DataTable.CLASS_ASC}; |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2111 |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2112 // Get filtered data |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2113 myDataSource.sendRequest($q_filter.val(), { |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2114 success : myDataTable.onDataReturnInitializeTable, |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2115 failure : myDataTable.onDataReturnInitializeTable, |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2116 scope : myDataTable, |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2117 argument: state}); |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2118 }; |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2119 |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2120 $q_filter.click(function(){ |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2121 if(!$q_filter.hasClass('loaded')){ |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2122 //TODO: load here full list later to do search within groups |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2123 $q_filter.addClass('loaded'); |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2124 } |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2125 }); |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2126 |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2127 $q_filter.keyup(function (e) { |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2128 clearTimeout(filterTimeout); |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2129 filterTimeout = setTimeout(updateFilter, 600); |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2130 }); |
5046b724a140
rhodecode.js: implement YUI_datatable(data, fields, columns, countnode, sortkey) with body from repos.html
Mads Kiilerich <madski@unity3d.com>
parents:
4162
diff
changeset
|
2131 } |
3776
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
2132 |
3419
efc00d363d1e
collapsable diff container in changeset, makes quick review easier
Marcin Kuzminski <marcin@python-works.com>
parents:
3417
diff
changeset
|
2133 // 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
|
2134 |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
2135 $(document).ready(function(){ |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
2136 $('.diff-collapse-button').click(function(e) { |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
2137 var $button = $(e.currentTarget); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
2138 var $target = $('#' + $button.attr('target')); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
2139 if($target.hasClass('hidden')){ |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
2140 $target.removeClass('hidden'); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
2141 $button.html("↑ {0} ↑".format(_TM['Collapse diff'])); |
3696
e07b07ac9fbe
codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents:
3695
diff
changeset
|
2142 } |
4160
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
2143 else if(!$target.hasClass('hidden')){ |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
2144 $target.addClass('hidden'); |
4451b2eabf64
rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
4159
diff
changeset
|
2145 $button.html("↓ {0} ↓".format(_TM['Expand diff'])); |
3696
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 }); |
3419
efc00d363d1e
collapsable diff container in changeset, makes quick review easier
Marcin Kuzminski <marcin@python-works.com>
parents:
3417
diff
changeset
|
2148 }); |