annotate rhodecode/public/js/rhodecode.js @ 4171:75bf2d4eb890 rhodecode-2.2.5-gpl

rhodecode.js: use classes btn and btn-mini instead of ui-btn in createInlineAddButton
author Mads Kiilerich <madski@unity3d.com>
date Wed, 02 Jul 2014 19:03:28 -0400
parents 211ded263da9
children 031117f7efab
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 = [];
4169
c560a5789512 rhodecode.js: pyroute, don't iterate over req_params, make for loop over its length
Mads Kiilerich <madski@unity3d.com>
parents: 4168
diff changeset
303 for (var i=0; i < req_params.length; i++) {
c560a5789512 rhodecode.js: pyroute, don't iterate over req_params, make for loop over its length
Mads Kiilerich <madski@unity3d.com>
parents: 4168
diff changeset
304 keys.push(req_params[i])
3696
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
5d580e9bc730 JS cleanup
Marcin Kuzminski <marcin@python-works.com>
parents: 3001
diff changeset
484 }
5d580e9bc730 JS cleanup
Marcin Kuzminski <marcin@python-works.com>
parents: 3001
diff changeset
485 }
5d580e9bc730 JS cleanup
Marcin Kuzminski <marcin@python-works.com>
parents: 3001
diff changeset
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
5d580e9bc730 JS cleanup
Marcin Kuzminski <marcin@python-works.com>
parents: 3001
diff changeset
492 }
5d580e9bc730 JS cleanup
Marcin Kuzminski <marcin@python-works.com>
parents: 3001
diff changeset
493 }
5d580e9bc730 JS cleanup
Marcin Kuzminski <marcin@python-works.com>
parents: 3001
diff changeset
494 }
5d580e9bc730 JS cleanup
Marcin Kuzminski <marcin@python-works.com>
parents: 3001
diff changeset
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
5d580e9bc730 JS cleanup
Marcin Kuzminski <marcin@python-works.com>
parents: 3001
diff changeset
498 args+= '&amp;auth_token='+token;
5d580e9bc730 JS cleanup
Marcin Kuzminski <marcin@python-works.com>
parents: 3001
diff changeset
499 if(user_id != undefined){
5d580e9bc730 JS cleanup
Marcin Kuzminski <marcin@python-works.com>
parents: 3001
diff changeset
500 args+="&amp;user_id="+user_id;
5d580e9bc730 JS cleanup
Marcin Kuzminski <marcin@python-works.com>
parents: 3001
diff changeset
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
5d580e9bc730 JS cleanup
Marcin Kuzminski <marcin@python-works.com>
parents: 3001
diff changeset
505 return false;
4160
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
506 };
3066
5d580e9bc730 JS cleanup
Marcin Kuzminski <marcin@python-works.com>
parents: 3001
diff changeset
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'];
4171
75bf2d4eb890 rhodecode.js: use classes btn and btn-mini instead of ui-btn in createInlineAddButton
Mads Kiilerich <madski@unity3d.com>
parents: 4170
diff changeset
798 var $html_el = $('<div class="add-comment"><span class="btn btn-mini">{0}</span></div>'.format(label));
4160
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']));
4166
f0e518891d69 rhodecode.js: break the loop when fileBrowserListeners search is truncated
Mads Kiilerich <madski@unity3d.com>
parents: 4165
diff changeset
926 break;
3696
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 }
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
930 if(query != ""){
4160
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
931 $('#tbody').hide();
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
932 $('#tbody_filtered').show();
1699
623b228cf325 cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents: 1685
diff changeset
933
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
934 if (match.length==0){
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
935 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
936 }
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
937
4160
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
938 $('#tbody_filtered').html(match.join(""));
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
939 }
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
940 else{
4160
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
941 $('#tbody').show();
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
942 $('#tbody_filtered').hide();
3696
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 };
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
946
4160
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
947 $('#filter_activate').click(function(){
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
948 initFilter();
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
949 });
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
950 $node_filter.click(function(){
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
951 if($node_filter.hasClass('init')){
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
952 $node_filter.val('');
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
953 $node_filter.removeClass('init');
4158
e4848cd9c8ae rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents: 4157
diff changeset
954 }
e4848cd9c8ae rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents: 4157
diff changeset
955 });
4160
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
956 $node_filter.keyup(function(e){
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
957 clearTimeout(filterTimeout);
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
958 filterTimeout = setTimeout(updateFilter(e),600);
4158
e4848cd9c8ae rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents: 4157
diff changeset
959 });
1699
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
623b228cf325 cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents: 1685
diff changeset
962
4160
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
963 var initCodeMirror = function(textarea_id, resetUrl){
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
964 var myCodeMirror = CodeMirror.fromTextArea($('#' + textarea_id)[0], {
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
965 mode: "null",
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
966 lineNumbers: true,
4168
7eb8544cefbe rhodecode.js: initialize CodeMirror.fromTextArea with autofocus set
Mads Kiilerich <madski@unity3d.com>
parents: 4166
diff changeset
967 indentUnit: 4,
7eb8544cefbe rhodecode.js: initialize CodeMirror.fromTextArea with autofocus set
Mads Kiilerich <madski@unity3d.com>
parents: 4166
diff changeset
968 autofocus: true,
4158
e4848cd9c8ae rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents: 4157
diff changeset
969 });
4160
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
970 $('#reset').click(function(e){
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
971 window.location=resetUrl;
4158
e4848cd9c8ae rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents: 4157
diff changeset
972 });
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
973
4160
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
974 $('#file_enable').click(function(){
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
975 $('#editor_container').show();
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
976 $('#upload_file_container').hide();
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
977 $('#filename_container').show();
4170
211ded263da9 rhodecode.js: show/hide set_mode_header like filename_container in initCodeMirror file_enable and upload_file_enable
Mads Kiilerich <madski@unity3d.com>
parents: 4169
diff changeset
978 $('#set_mode_header').show();
4158
e4848cd9c8ae rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents: 4157
diff changeset
979 });
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
980
4160
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
981 $('#upload_file_enable').click(function(){
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
982 $('#editor_container').hide();
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
983 $('#upload_file_container').show();
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
984 $('#filename_container').hide();
4170
211ded263da9 rhodecode.js: show/hide set_mode_header like filename_container in initCodeMirror file_enable and upload_file_enable
Mads Kiilerich <madski@unity3d.com>
parents: 4169
diff changeset
985 $('#set_mode_header').hide();
4158
e4848cd9c8ae rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents: 4157
diff changeset
986 });
4026
a60a0e9092c6 added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents: 3966
diff changeset
987
a60a0e9092c6 added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents: 3966
diff changeset
988 return myCodeMirror
1699
623b228cf325 cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents: 1685
diff changeset
989 };
623b228cf325 cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents: 1685
diff changeset
990
4026
a60a0e9092c6 added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents: 3966
diff changeset
991 var setCodeMirrorMode = function(codeMirrorInstance, mode) {
4158
e4848cd9c8ae rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents: 4157
diff changeset
992 codeMirrorInstance.setOption("mode", mode);
e4848cd9c8ae rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents: 4157
diff changeset
993 CodeMirror.autoLoadMode(codeMirrorInstance, mode);
4026
a60a0e9092c6 added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents: 3966
diff changeset
994 }
1699
623b228cf325 cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents: 1685
diff changeset
995
623b228cf325 cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents: 1685
diff changeset
996
4160
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
997 var _getIdentNode = function(n){
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
998 //iterate thrugh nodes until matching interesting node
3696
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 == 'undefined'){
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1001 return -1
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1002 }
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1003
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1004 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
1005 return n
e4848cd9c8ae rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents: 4157
diff changeset
1006 }
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1007 else{
4160
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1008 return _getIdentNode(n.parentNode);
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1009 }
1699
623b228cf325 cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents: 1685
diff changeset
1010 };
623b228cf325 cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents: 1685
diff changeset
1011
4160
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1012 /* 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
1013 * 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
1014 var getSelectionLink = function(e) {
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1015 //get selection from start/to nodes
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1016 if (typeof window.getSelection != "undefined") {
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1017 s = window.getSelection();
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1018
4160
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1019 from = _getIdentNode(s.anchorNode);
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1020 till = _getIdentNode(s.focusNode);
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1021
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1022 f_int = parseInt(from.id.replace('L',''));
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1023 t_int = parseInt(till.id.replace('L',''));
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1024
4160
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1025 var yoffset = 35;
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1026 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
1027 if (ranges[0] > ranges[1]){
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1028 //highlight from bottom
4160
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1029 yoffset = -yoffset;
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1030 ranges = [ranges[1], ranges[0]];
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1031 }
4160
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1032 var $hl_div = $('div#linktt');
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1033 // if we select more than 2 lines
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1034 if (ranges[0] != ranges[1]){
4160
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1035 if ($hl_div.length) {
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1036 $hl_div.html('');
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1037 } else {
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1038 $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
1039 $('body').prepend($hl_div);
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1040 }
3081
b2c7f7c5ce11 fixed source selection link pop-up tooltip
Marcin Kuzminski <marcin@python-works.com>
parents: 3066
diff changeset
1041
4160
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1042 $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
1043 xy = $(till).offset();
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1044 $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
1045 $hl_div.show();
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1046 }
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1047 else{
4160
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1048 $hl_div.hide();
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1049 }
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1050 }
1699
623b228cf325 cleaned up JS files in files templates.
Marcin Kuzminski <marcin@python-works.com>
parents: 1685
diff changeset
1051 };
1712
cac5109ac3b6 Notification system improvements
Marcin Kuzminski <marcin@python-works.com>
parents: 1705
diff changeset
1052
4160
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1053 var deleteNotification = function(url, notification_id, callbacks){
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1054 var callback = {
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1055 success:function(o){
4160
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1056 $("#notification_"+notification_id).remove();
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1057 _run_callbacks(callbacks);
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1058 },
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1059 failure:function(o){
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1060 alert("error");
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1061 },
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1062 };
1712
cac5109ac3b6 Notification system improvements
Marcin Kuzminski <marcin@python-works.com>
parents: 1705
diff changeset
1063 var postData = '_method=delete';
cac5109ac3b6 Notification system improvements
Marcin Kuzminski <marcin@python-works.com>
parents: 1705
diff changeset
1064 var sUrl = url.replace('__NOTIFICATION_ID__',notification_id);
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1065 var request = YAHOO.util.Connect.asyncRequest('POST', sUrl,
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1066 callback, postData);
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1067 };
1778
defcf245f3e9 fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents: 1772
diff changeset
1068
4160
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1069 var readNotification = function(url, notification_id, callbacks){
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1070 var callback = {
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1071 success:function(o){
4160
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1072 var $obj = $("#notification_"+notification_id);
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1073 $obj.removeClass('unread');
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1074 $obj.find('.read-notification').remove();
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1075 _run_callbacks(callbacks);
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1076 },
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1077 failure:function(o){
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1078 alert("error");
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1079 },
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1080 };
2610
3fdf7c3be2c9 added mark as read for single notifications
Marcin Kuzminski <marcin@python-works.com>
parents: 2608
diff changeset
1081 var postData = '_method=put';
3fdf7c3be2c9 added mark as read for single notifications
Marcin Kuzminski <marcin@python-works.com>
parents: 2608
diff changeset
1082 var sUrl = url.replace('__NOTIFICATION_ID__',notification_id);
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1083 var request = YAHOO.util.Connect.asyncRequest('POST', sUrl,
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1084 callback, postData);
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1085 };
1778
defcf245f3e9 fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents: 1772
diff changeset
1086
2142
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1087 /** MEMBERS AUTOCOMPLETE WIDGET **/
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1088
4160
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1089 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
1090 var myUsers = users_list;
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1091 var myGroups = groups_list;
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1092
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1093 // 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
1094 var matchUsers = function (sQuery) {
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1095 // Case insensitive matching
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1096 var query = sQuery.toLowerCase();
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1097 var i = 0;
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1098 var l = myUsers.length;
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1099 var matches = [];
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1100
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1101 // 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
1102 for (; i < l; i++) {
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1103 contact = myUsers[i];
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1104 if (((contact.fname+"").toLowerCase().indexOf(query) > -1) ||
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1105 ((contact.lname+"").toLowerCase().indexOf(query) > -1) ||
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1106 ((contact.nname) && ((contact.nname).toLowerCase().indexOf(query) > -1))) {
4158
e4848cd9c8ae rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents: 4157
diff changeset
1107 matches[matches.length] = contact;
e4848cd9c8ae rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents: 4157
diff changeset
1108 }
2142
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1109 }
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1110 return matches;
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1111 };
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1112
3417
fa6ba6727475 further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents: 3403
diff changeset
1113 // 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
1114 var matchGroups = function (sQuery) {
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1115 // Case insensitive matching
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1116 var query = sQuery.toLowerCase();
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1117 var i = 0;
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1118 var l = myGroups.length;
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1119 var matches = [];
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1120
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1121 // 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
1122 for (; i < l; i++) {
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1123 matched_group = myGroups[i];
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1124 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
1125 matches[matches.length] = matched_group;
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 }
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1128 return matches;
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1129 };
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1130
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1131 //match all
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1132 var matchAll = function (sQuery) {
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1133 u = matchUsers(sQuery);
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1134 g = matchGroups(sQuery);
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1135 return u.concat(g);
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1136 };
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1137
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1138 // DataScheme for members
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1139 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
1140 memberDS.responseSchema = {
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1141 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
1142 };
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1143
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1144 // DataScheme for owner
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1145 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
1146 ownerDS.responseSchema = {
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1147 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
1148 };
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1149
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1150 // 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
1151 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
1152 membersAC.useShadow = false;
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1153 membersAC.resultTypeList = false;
2611
e83be26bb8d8 disable animation on autocomplete widget
Marcin Kuzminski <marcin@python-works.com>
parents: 2610
diff changeset
1154 membersAC.animVert = false;
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1155 membersAC.animHoriz = false;
2611
e83be26bb8d8 disable animation on autocomplete widget
Marcin Kuzminski <marcin@python-works.com>
parents: 2610
diff changeset
1156 membersAC.animSpeed = 0.1;
2142
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1157
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1158 // Instantiate AutoComplete for owner
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1159 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
1160 ownerAC.useShadow = false;
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1161 ownerAC.resultTypeList = false;
2611
e83be26bb8d8 disable animation on autocomplete widget
Marcin Kuzminski <marcin@python-works.com>
parents: 2610
diff changeset
1162 ownerAC.animVert = false;
e83be26bb8d8 disable animation on autocomplete widget
Marcin Kuzminski <marcin@python-works.com>
parents: 2610
diff changeset
1163 ownerAC.animHoriz = false;
e83be26bb8d8 disable animation on autocomplete widget
Marcin Kuzminski <marcin@python-works.com>
parents: 2610
diff changeset
1164 ownerAC.animSpeed = 0.1;
2142
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1165
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1166 // 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
1167 var highlightMatch = function (full, snippet, matchindex) {
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1168 return full.substring(0, matchindex)
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1169 + "<span class='match'>"
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1170 + 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
1171 + "</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
1172 };
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1173
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1174 // 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
1175 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
1176 var query = sQuery.toLowerCase();
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1177 var _gravatar = function(res, em, group){
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1178 if (group !== undefined){
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1179 em = '/images/icons/group.png'
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1180 }
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1181 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
1182 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
1183 }
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1184 // group
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1185 if (oResultData.grname != undefined) {
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1186 var grname = oResultData.grname;
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1187 var grmembers = oResultData.grmembers;
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1188 var grnameMatchIndex = grname.toLowerCase().indexOf(query);
2369
c2f131502037 Autocomplete fixes
Marcin Kuzminski <marcin@python-works.com>
parents: 2368
diff changeset
1189 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
1190 var grsuffix = " (" + grmembers + " )";
2369
c2f131502037 Autocomplete fixes
Marcin Kuzminski <marcin@python-works.com>
parents: 2368
diff changeset
1191 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
1192
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1193 if (grnameMatchIndex > -1) {
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1194 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
1195 }
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1196 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
1197 // Users
2369
c2f131502037 Autocomplete fixes
Marcin Kuzminski <marcin@python-works.com>
parents: 2368
diff changeset
1198 } else if (oResultData.nname != undefined) {
c2f131502037 Autocomplete fixes
Marcin Kuzminski <marcin@python-works.com>
parents: 2368
diff changeset
1199 var fname = oResultData.fname || "";
c2f131502037 Autocomplete fixes
Marcin Kuzminski <marcin@python-works.com>
parents: 2368
diff changeset
1200 var lname = oResultData.lname || "";
c2f131502037 Autocomplete fixes
Marcin Kuzminski <marcin@python-works.com>
parents: 2368
diff changeset
1201 var nname = oResultData.nname;
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1202
2369
c2f131502037 Autocomplete fixes
Marcin Kuzminski <marcin@python-works.com>
parents: 2368
diff changeset
1203 // Guard against null value
c2f131502037 Autocomplete fixes
Marcin Kuzminski <marcin@python-works.com>
parents: 2368
diff changeset
1204 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
1205 lnameMatchIndex = lname.toLowerCase().indexOf(query),
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1206 nnameMatchIndex = nname.toLowerCase().indexOf(query),
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1207 displayfname, displaylname, displaynname;
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1208
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1209 if (fnameMatchIndex > -1) {
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1210 displayfname = highlightMatch(fname, query, fnameMatchIndex);
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1211 } else {
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1212 displayfname = fname;
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1213 }
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1214
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1215 if (lnameMatchIndex > -1) {
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1216 displaylname = highlightMatch(lname, query, lnameMatchIndex);
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1217 } else {
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1218 displaylname = lname;
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1219 }
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1220
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1221 if (nnameMatchIndex > -1) {
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1222 displaynname = "(" + highlightMatch(nname, query, nnameMatchIndex) + ")";
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1223 } else {
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1224 displaynname = nname ? "(" + nname + ")" : "";
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1225 }
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 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
1228 } else {
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1229 return '';
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 };
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1232 membersAC.formatResult = custom_formatter;
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1233 ownerAC.formatResult = custom_formatter;
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1234
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1235 var myHandler = function (sType, aArgs) {
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1236 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
1237 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
1238 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
1239 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
1240 //fill the autocomplete with value
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1241 if (oData.nname != undefined) {
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1242 //users
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1243 myAC.getInputEl().value = oData.nname;
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('user');
2142
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1245 } else {
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1246 //groups
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1247 myAC.getInputEl().value = oData.grname;
4160
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1248 $('#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
1249 }
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1250 };
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 membersAC.itemSelectEvent.subscribe(myHandler);
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1253 if(ownerAC.itemSelectEvent){
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1254 ownerAC.itemSelectEvent.subscribe(myHandler);
2142
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1255 }
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1256
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1257 return {
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1258 memberDS: memberDS,
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1259 ownerDS: ownerDS,
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1260 membersAC: membersAC,
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1261 ownerAC: ownerAC,
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1262 };
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1263 }
a21eab6ff42f Added gravatars into permissions view and permissions autocomplete
Marcin Kuzminski <marcin@python-works.com>
parents: 2128
diff changeset
1264
2369
c2f131502037 Autocomplete fixes
Marcin Kuzminski <marcin@python-works.com>
parents: 2368
diff changeset
1265 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
1266 var myUsers = users_list;
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1267 var myGroups = groups_list;
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1268
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1269 // 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
1270 var matchUsers = function (sQuery) {
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1271 var org_sQuery = sQuery;
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1272 if(this.mentionQuery == null){
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1273 return []
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1274 }
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1275 sQuery = this.mentionQuery;
2368
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1276 // Case insensitive matching
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1277 var query = sQuery.toLowerCase();
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1278 var i = 0;
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1279 var l = myUsers.length;
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1280 var matches = [];
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1281
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1282 // 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
1283 for (; i < l; i++) {
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1284 contact = myUsers[i];
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1285 if (((contact.fname+"").toLowerCase().indexOf(query) > -1) ||
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1286 ((contact.lname+"").toLowerCase().indexOf(query) > -1) ||
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1287 ((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
1288 matches[matches.length] = contact;
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 }
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1291 return matches
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1292 };
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1293
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1294 //match all
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1295 var matchAll = function (sQuery) {
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1296 u = matchUsers(sQuery);
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1297 return u
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1298 };
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1299
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1300 // DataScheme for owner
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1301 var ownerDS = new YAHOO.util.FunctionDataSource(matchUsers);
2369
c2f131502037 Autocomplete fixes
Marcin Kuzminski <marcin@python-works.com>
parents: 2368
diff changeset
1302
2368
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1303 ownerDS.responseSchema = {
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1304 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
1305 };
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1306
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1307 // Instantiate AutoComplete for mentions
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1308 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
1309 ownerAC.useShadow = false;
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1310 ownerAC.resultTypeList = false;
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1311 ownerAC.suppressInputUpdate = true;
2611
e83be26bb8d8 disable animation on autocomplete widget
Marcin Kuzminski <marcin@python-works.com>
parents: 2610
diff changeset
1312 ownerAC.animVert = false;
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1313 ownerAC.animHoriz = false;
2611
e83be26bb8d8 disable animation on autocomplete widget
Marcin Kuzminski <marcin@python-works.com>
parents: 2610
diff changeset
1314 ownerAC.animSpeed = 0.1;
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1315
2368
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1316 // Helper highlight function for the formatter
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1317 var highlightMatch = function (full, snippet, matchindex) {
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1318 return full.substring(0, matchindex)
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1319 + "<span class='match'>"
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1320 + full.substr(matchindex, snippet.length)
2368
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1321 + "</span>" + full.substring(matchindex + snippet.length);
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1322 };
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1323
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1324 // 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
1325 ownerAC.formatResult = function (oResultData, sQuery, sResultMatch) {
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1326 var org_sQuery = sQuery;
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1327 if(this.dataSource.mentionQuery != null){
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1328 sQuery = this.dataSource.mentionQuery;
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1329 }
2368
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1330
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1331 var query = sQuery.toLowerCase();
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1332 var _gravatar = function(res, em, group){
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1333 if (group !== undefined){
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1334 em = '/images/icons/group.png'
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1335 }
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1336 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
1337 return tmpl.format(em,res)
2368
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1338 }
2369
c2f131502037 Autocomplete fixes
Marcin Kuzminski <marcin@python-works.com>
parents: 2368
diff changeset
1339 if (oResultData.nname != undefined) {
c2f131502037 Autocomplete fixes
Marcin Kuzminski <marcin@python-works.com>
parents: 2368
diff changeset
1340 var fname = oResultData.fname || "";
c2f131502037 Autocomplete fixes
Marcin Kuzminski <marcin@python-works.com>
parents: 2368
diff changeset
1341 var lname = oResultData.lname || "";
c2f131502037 Autocomplete fixes
Marcin Kuzminski <marcin@python-works.com>
parents: 2368
diff changeset
1342 var nname = oResultData.nname;
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1343
2369
c2f131502037 Autocomplete fixes
Marcin Kuzminski <marcin@python-works.com>
parents: 2368
diff changeset
1344 // Guard against null value
c2f131502037 Autocomplete fixes
Marcin Kuzminski <marcin@python-works.com>
parents: 2368
diff changeset
1345 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
1346 lnameMatchIndex = lname.toLowerCase().indexOf(query),
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1347 nnameMatchIndex = nname.toLowerCase().indexOf(query),
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1348 displayfname, displaylname, displaynname;
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1349
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1350 if (fnameMatchIndex > -1) {
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1351 displayfname = highlightMatch(fname, query, fnameMatchIndex);
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1352 } else {
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1353 displayfname = fname;
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1354 }
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1355
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1356 if (lnameMatchIndex > -1) {
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1357 displaylname = highlightMatch(lname, query, lnameMatchIndex);
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1358 } else {
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1359 displaylname = lname;
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1360 }
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1361
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1362 if (nnameMatchIndex > -1) {
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1363 displaynname = "(" + highlightMatch(nname, query, nnameMatchIndex) + ")";
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1364 } else {
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1365 displaynname = nname ? "(" + nname + ")" : "";
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1366 }
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 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
1369 } else {
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1370 return '';
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1371 }
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
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1374 if(ownerAC.itemSelectEvent){
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1375 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
1376
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1377 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
1378 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
1379 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
1380 //fill the autocomplete with value
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1381 if (oData.nname != undefined) {
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1382 //users
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1383 //Replace the mention name with replaced
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1384 var re = new RegExp();
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1385 var org = myAC.getInputEl().value;
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1386 var chunks = myAC.dataSource.chunks
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1387 // replace middle chunk(the search term) with actuall match
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1388 chunks[1] = chunks[1].replace('@'+myAC.dataSource.mentionQuery,
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1389 '@'+oData.nname+' ');
2368
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1390 myAC.getInputEl().value = chunks.join('')
4160
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1391 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
1392 } else {
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1393 //groups
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1394 myAC.getInputEl().value = oData.grname;
4160
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1395 $('#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
1396 }
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1397 });
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1398 }
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1399
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1400 // 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
1401 // 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
1402 // search
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1403 ownerAC.dataSource.chunks = [];
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1404 ownerAC.dataSource.mentionQuery = null;
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1405
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1406 ownerAC.get_mention = function(msg, max_pos) {
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1407 var org = msg;
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1408 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
1409 var chunks = [];
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1410
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1411 // cut first chunk until curret pos
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1412 var to_max = msg.substr(0, max_pos);
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1413 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
1414 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
1415
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1416 chunks.push(org.substr(0,at_pos))// prefix chunk
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1417 chunks.push(msg2) // search chunk
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1418 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
1419
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1420 // clean up msg2 for filtering and regex match
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1421 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
1422
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1423 if(re.test(msg2)){
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1424 var unam = re.exec(msg2)[1];
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1425 return [unam, chunks];
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1426 }
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1427 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
1428 };
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1429
2698
4debfe3b50be ie8 fixes for inline comments :/
Marcin Kuzminski <marcin@python-works.com>
parents: 2694
diff changeset
1430 if (ownerAC.textboxKeyUpEvent){
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1431 ownerAC.textboxKeyUpEvent.subscribe(function(type, args){
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 ac_obj = args[0];
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1434 var currentMessage = args[1];
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1435 var currentCaretPosition = args[0]._elTextbox.selectionStart;
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1436
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1437 var unam = ownerAC.get_mention(currentMessage, currentCaretPosition);
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1438 var curr_search = null;
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1439 if(unam[0]){
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1440 curr_search = unam[0];
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 ownerAC.dataSource.chunks = unam[1];
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1444 ownerAC.dataSource.mentionQuery = curr_search;
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1445
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1446 })
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1447 }
2368
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1448 return {
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1449 ownerDS: ownerDS,
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1450 ownerAC: ownerAC,
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1451 };
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1452 }
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1453
3388
cb40b3f6428c review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents: 3247
diff changeset
1454 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
1455 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
1456 '<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
1457 '<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
1458 '<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
1459 '<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
1460 '<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
1461 '</div>'+
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1462 '</li>' ;
3388
cb40b3f6428c review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents: 3247
diff changeset
1463 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
1464 var element = tmpl.format(gravatar_link,displayname,id);
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1465 // 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
1466 var ids = [];
4160
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1467 $('#review_members').find('li').each(function() {
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1468 ids.push(this.id);
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1469 });
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1470 if(ids.indexOf('reviewer_'+id) == -1){
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1471 //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
1472 $('#review_members').append(element);
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1473 }
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
cb40b3f6428c review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents: 3247
diff changeset
1476 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
1477 $('#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
1478 }
cb40b3f6428c review members are dynamically changed based on selected other_repo owner
Marcin Kuzminski <marcin@python-works.com>
parents: 3247
diff changeset
1479
4160
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1480 /* 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
1481 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
1482 if (reviewers_ids === undefined){
4158
e4848cd9c8ae rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents: 4157
diff changeset
1483 var reviewers_ids = [];
4160
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1484 $('#review_members').find('input').each(function(){
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1485 reviewers_ids.push(this.value);
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1486 });
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1487 }
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1488 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
1489 "pull_request_id": pull_request_id});
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1490 var postData = {'_method':'put',
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1491 'reviewers_ids': reviewers_ids};
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1492 var success = function(o){
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1493 window.location.reload();
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1494 }
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1495 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
1496 }
2368
5143b8df576c Added mentions autocomplete into main comments form
Marcin Kuzminski <marcin@python-works.com>
parents: 2189
diff changeset
1497
4160
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1498 /* 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
1499 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
1500 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
1501 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
1502
9364776d1331 Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents: 2611
diff changeset
1503 // 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
1504 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
1505 // 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
1506 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
1507 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
1508 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
1509 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
1510
9364776d1331 Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents: 2611
diff changeset
1511 // 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
1512 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
1513 contact = myUsers[i];
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1514 if (((contact.fname+"").toLowerCase().indexOf(query) > -1) ||
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1515 ((contact.lname+"").toLowerCase().indexOf(query) > -1) ||
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1516 ((contact.nname) && ((contact.nname).toLowerCase().indexOf(query) > -1))) {
4158
e4848cd9c8ae rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents: 4157
diff changeset
1517 matches[matches.length] = contact;
e4848cd9c8ae rhodecode.js: fix indentation
Mads Kiilerich <madski@unity3d.com>
parents: 4157
diff changeset
1518 }
2612
9364776d1331 Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents: 2611
diff changeset
1519 }
9364776d1331 Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents: 2611
diff changeset
1520 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
1521 };
9364776d1331 Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents: 2611
diff changeset
1522
3417
fa6ba6727475 further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents: 3403
diff changeset
1523 // 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
1524 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
1525 // 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
1526 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
1527 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
1528 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
1529 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
1530
9364776d1331 Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents: 2611
diff changeset
1531 // 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
1532 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
1533 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
1534 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
1535 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
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 }
9364776d1331 Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents: 2611
diff changeset
1538 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
1539 };
9364776d1331 Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents: 2611
diff changeset
1540
9364776d1331 Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents: 2611
diff changeset
1541 //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
1542 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
1543 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
1544 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
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
9364776d1331 Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents: 2611
diff changeset
1547 // 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
1548 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
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 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
1551 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
1552 };
9364776d1331 Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents: 2611
diff changeset
1553
9364776d1331 Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents: 2611
diff changeset
1554 // 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
1555 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
1556 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
1557 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
1558 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
1559 reviewerAC.animVert = false;
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1560 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
1561 reviewerAC.animSpeed = 0.1;
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1562
2612
9364776d1331 Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents: 2611
diff changeset
1563 // 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
1564 var highlightMatch = function (full, snippet, matchindex) {
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1565 return full.substring(0, matchindex)
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1566 + "<span class='match'>"
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1567 + 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
1568 + "</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
1569 };
9364776d1331 Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents: 2611
diff changeset
1570
9364776d1331 Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents: 2611
diff changeset
1571 // 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
1572 reviewerAC.formatResult = function (oResultData, sQuery, sResultMatch) {
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1573 var org_sQuery = sQuery;
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1574 if(this.dataSource.mentionQuery != null){
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1575 sQuery = this.dataSource.mentionQuery;
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1576 }
2612
9364776d1331 Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents: 2611
diff changeset
1577
9364776d1331 Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents: 2611
diff changeset
1578 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
1579 var _gravatar = function(res, em, group){
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1580 if (group !== undefined){
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1581 em = '/images/icons/group.png'
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1582 }
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1583 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
1584 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
1585 }
9364776d1331 Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents: 2611
diff changeset
1586 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
1587 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
1588 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
1589 var nname = oResultData.nname;
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1590
2612
9364776d1331 Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents: 2611
diff changeset
1591 // 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
1592 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
1593 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
1594 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
1595 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
1596
9364776d1331 Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents: 2611
diff changeset
1597 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
1598 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
1599 } else {
9364776d1331 Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents: 2611
diff changeset
1600 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
1601 }
9364776d1331 Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents: 2611
diff changeset
1602
9364776d1331 Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents: 2611
diff changeset
1603 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
1604 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
1605 } else {
9364776d1331 Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents: 2611
diff changeset
1606 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
1607 }
9364776d1331 Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents: 2611
diff changeset
1608
9364776d1331 Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents: 2611
diff changeset
1609 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
1610 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
1611 } else {
9364776d1331 Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents: 2611
diff changeset
1612 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
1613 }
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 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
1616 } else {
9364776d1331 Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents: 2611
diff changeset
1617 return '';
9364776d1331 Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents: 2611
diff changeset
1618 }
9364776d1331 Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents: 2611
diff changeset
1619 };
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1620
2612
9364776d1331 Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents: 2611
diff changeset
1621 //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
1622 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
1623 // 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
1624 if(reviewerAC.itemSelectEvent){
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1625 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
1626
9364776d1331 Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents: 2611
diff changeset
1627 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
1628 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
1629 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
1630
2612
9364776d1331 Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents: 2611
diff changeset
1631 //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
1632 if (oData.nname != undefined) {
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1633 addReviewMember(oData.id, oData.fname, oData.lname, oData.nname,
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1634 oData.gravatar_lnk);
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1635 myAC.dataSource.cache.push(oData.id);
4160
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1636 $('#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
1637 }
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1638 });
2612
9364776d1331 Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents: 2611
diff changeset
1639 }
9364776d1331 Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents: 2611
diff changeset
1640 }
9364776d1331 Added autocomplete widget for pull request reviewers, in exchange of 90s style
Marcin Kuzminski <marcin@python-works.com>
parents: 2611
diff changeset
1641
1778
defcf245f3e9 fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents: 1772
diff changeset
1642 /**
4160
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1643 * Activate .quick_repo_menu
1779
9edd6ac132f0 Added sorting into journal and admin pages
Marcin Kuzminski <marcin@python-works.com>
parents: 1778
diff changeset
1644 */
9edd6ac132f0 Added sorting into journal and admin pages
Marcin Kuzminski <marcin@python-works.com>
parents: 1778
diff changeset
1645 var quick_repo_menu = function(){
4160
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1646 $(".quick_repo_menu").mouseenter(function(e) {
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1647 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
1648 if($menu.hasClass('hidden')){
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1649 $menu.removeClass('hidden').addClass('active');
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1650 $(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
1651 }
382df4e69dfc quick_repo_menu changed from mouseclick to popup
Marcin Kuzminski <marcin@python-works.com>
parents: 2087
diff changeset
1652 })
4160
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1653 $(".quick_repo_menu").mouseleave(function(e) {
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1654 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
1655 if($menu.hasClass('active')){
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1656 $menu.removeClass('active').addClass('hidden');
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1657 $(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
1658 }
382df4e69dfc quick_repo_menu changed from mouseclick to popup
Marcin Kuzminski <marcin@python-works.com>
parents: 2087
diff changeset
1659 })
1779
9edd6ac132f0 Added sorting into journal and admin pages
Marcin Kuzminski <marcin@python-works.com>
parents: 1778
diff changeset
1660 };
9edd6ac132f0 Added sorting into journal and admin pages
Marcin Kuzminski <marcin@python-works.com>
parents: 1778
diff changeset
1661
9edd6ac132f0 Added sorting into journal and admin pages
Marcin Kuzminski <marcin@python-works.com>
parents: 1778
diff changeset
1662
9edd6ac132f0 Added sorting into journal and admin pages
Marcin Kuzminski <marcin@python-works.com>
parents: 1778
diff changeset
1663 /**
1778
defcf245f3e9 fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents: 1772
diff changeset
1664 * TABLE SORTING
defcf245f3e9 fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents: 1772
diff changeset
1665 */
defcf245f3e9 fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents: 1772
diff changeset
1666
defcf245f3e9 fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents: 1772
diff changeset
1667 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
1668 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
1669 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
1670
4160
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1671 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
1672 };
4157
bc296381fb6c rhodecode.js: remove unused stuff
Mads Kiilerich <madski@unity3d.com>
parents: 4135
diff changeset
1673
1778
defcf245f3e9 fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents: 1772
diff changeset
1674 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
1675 // 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
1676 var a_ = $(a.getData(field)).attr('date');
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1677 var b_ = $(b.getData(field)).attr('date');
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1678
4160
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1679 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
1680 };
defcf245f3e9 fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents: 1772
diff changeset
1681
2699
4eef5eeb81a3 fixed sorting by last_login in users admin page
Marcin Kuzminski <marcin@python-works.com>
parents: 2698
diff changeset
1682 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
1683 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
1684 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
1685
4160
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1686 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
1687 };
4eef5eeb81a3 fixed sorting by last_login in users admin page
Marcin Kuzminski <marcin@python-works.com>
parents: 2698
diff changeset
1688
1778
defcf245f3e9 fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents: 1772
diff changeset
1689 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
1690 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
1691 var b_ = b.getData('raw_name') || 0;
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1692
4160
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1693 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
1694 };
defcf245f3e9 fixes #229 repo sorting is not working.
Marcin Kuzminski <marcin@python-works.com>
parents: 1772
diff changeset
1695
1782
eaf09acf6872 added sorting to bookmarks tags and branches
Marcin Kuzminski <marcin@python-works.com>
parents: 1779
diff changeset
1696 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
1697 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
1698 var b_ = parseFloat(b.getData('raw_date') || 0);
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1699
4160
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1700 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
1701 };
6776f4e569d7 Moved select widget to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 2369
diff changeset
1702
2759
c61c2ccea2b4 #538 form for permissions can handle multiple users at once
Marcin Kuzminski <marcin@python-works.com>
parents: 2723
diff changeset
1703 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
1704 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
1705 var next_id = $('.new_members').length;
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1706 $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
1707 _MembersAutoComplete("perm_new_member_name_"+next_id,
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1708 "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
1709 }
4157
bc296381fb6c rhodecode.js: remove unused stuff
Mads Kiilerich <madski@unity3d.com>
parents: 4135
diff changeset
1710
3715
25dbbdae3ed9 consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents: 3696
diff changeset
1711 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
1712 var callback = {
25dbbdae3ed9 consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents: 3696
diff changeset
1713 success: function (o) {
4160
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1714 $('#' + field_id).remove();
3715
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 failure: function (o) {
25dbbdae3ed9 consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents: 3696
diff changeset
1717 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
1718 },
25dbbdae3ed9 consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents: 3696
diff changeset
1719 };
25dbbdae3ed9 consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents: 3696
diff changeset
1720 query_params = {
25dbbdae3ed9 consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents: 3696
diff changeset
1721 '_method': 'delete'
25dbbdae3ed9 consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents: 3696
diff changeset
1722 }
25dbbdae3ed9 consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents: 3696
diff changeset
1723 // put extra data into POST
25dbbdae3ed9 consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents: 3696
diff changeset
1724 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
1725 for(k in extra_data){
25dbbdae3ed9 consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents: 3696
diff changeset
1726 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
1727 }
25dbbdae3ed9 consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents: 3696
diff changeset
1728 }
2394
6776f4e569d7 Moved select widget to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 2369
diff changeset
1729
3715
25dbbdae3ed9 consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents: 3696
diff changeset
1730 if (obj_type=='user'){
25dbbdae3ed9 consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents: 3696
diff changeset
1731 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
1732 query_params['obj_type'] = 'user';
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 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
1735 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
1736 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
1737 }
25dbbdae3ed9 consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents: 3696
diff changeset
1738
25dbbdae3ed9 consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents: 3696
diff changeset
1739 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
1740 _toQueryString(query_params));
3715
25dbbdae3ed9 consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents: 3696
diff changeset
1741 };
4157
bc296381fb6c rhodecode.js: remove unused stuff
Mads Kiilerich <madski@unity3d.com>
parents: 4135
diff changeset
1742
2394
6776f4e569d7 Moved select widget to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 2369
diff changeset
1743 /* Multi selectors */
6776f4e569d7 Moved select widget to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 2369
diff changeset
1744
6776f4e569d7 Moved select widget to rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 2369
diff changeset
1745 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
1746 var $availableselect = $('#' + available_id);
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1747 var $selectedselect = $('#' + selected_id);
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1748
4160
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1749 //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
1750 var $selectedoptions = $selectedselect.children('option');
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1751 $availableselect.children('option').filter(function(i, e){
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1752 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
1753 if(node.value == e.value){
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1754 return true;
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1755 }
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1756 }
4160
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1757 return false;
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1758 }).remove();
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1759
4160
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1760 $('#add_element').click(function(e){
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1761 $selectedselect.append($availableselect.children('option:selected'));
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1762 });
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1763 $('#remove_element').click(function(e){
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1764 $availableselect.append($selectedselect.children('option:selected'));
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1765 });
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1766 $('#add_all_elements').click(function(e){
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1767 $selectedselect.append($availableselect.children('option'));
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1768 });
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1769 $('#remove_all_elements').click(function(e){
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1770 $availableselect.append($selectedselect.children('option'));
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1771 });
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1772
4160
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1773 $('#'+form_id).submit(function(){
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1774 $selectedselect.children('option').each(function(i, e){
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1775 e.selected = 'selected';
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1776 });
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
1777 });
2723
04aa0ea1ddd0 fixed comment addition and deletion functionality on IE9
Dies Koper <diesk@fast.au.fujitsu.com>
parents: 2699
diff changeset
1778 }
3419
efc00d363d1e collapsable diff container in changeset, makes quick review easier
Marcin Kuzminski <marcin@python-works.com>
parents: 3417
diff changeset
1779
3784
62fb395a459d make sure we hide the spans
Marcin Kuzminski <marcin@python-works.com>
parents: 3776
diff changeset
1780 // custom paginator
62fb395a459d make sure we hide the spans
Marcin Kuzminski <marcin@python-works.com>
parents: 3776
diff changeset
1781 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
1782
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1783 (function () {
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 var Paginator = YAHOO.widget.Paginator,
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1786 l = YAHOO.lang,
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1787 setId = YAHOO.util.Dom.generateId;
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1788
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1789 Paginator.ui.MyFirstPageLink = function (p) {
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1790 this.paginator = p;
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1791
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1792 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
1793 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
1794 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
1795 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
1796
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1797 // TODO: make this work
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1798 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
1799 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
1800 };
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1801
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1802 Paginator.ui.MyFirstPageLink.init = function (p) {
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1803 p.setAttributeConfig('firstPageLinkLabel', {
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1804 value : 1,
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('firstPageLinkClass', {
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1808 value : 'yui-pg-first',
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 p.setAttributeConfig('firstPageLinkTitle', {
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1812 value : 'First Page',
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1813 validator : l.isString
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1814 });
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1815 };
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1816
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1817 // Instance members and methods
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1818 Paginator.ui.MyFirstPageLink.prototype = {
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1819 current : null,
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1820 leftmost_page: null,
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1821 rightmost_page: null,
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1822 link : null,
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1823 span : null,
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1824 dotdot : null,
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1825 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
1826 var edge = parseInt(items / 2) + 1;
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1827 if (cur_page <= edge){
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1828 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
1829 }
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1830 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
1831 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
1832 }
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1833 else{
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1834 var radius = parseInt(items / 2);
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1835 }
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 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
1838 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
1839 return [left, cur_page, right]
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1840 },
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1841 render : function (id_base) {
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1842 var p = this.paginator,
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1843 c = p.get('firstPageLinkClass'),
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1844 label = p.get('firstPageLinkLabel'),
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1845 title = p.get('firstPageLinkTitle');
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 this.link = document.createElement('a');
3784
62fb395a459d make sure we hide the spans
Marcin Kuzminski <marcin@python-works.com>
parents: 3776
diff changeset
1848 this.span = document.createElement('span');
4160
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1849 $(this.span).hide();
3776
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 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
1852 this.leftmost_page = _pos[0];
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1853 this.rightmost_page = _pos[2];
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1854
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1855 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
1856 this.link.href = '#';
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1857 this.link.className = c;
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1858 this.link.innerHTML = label;
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1859 this.link.title = title;
4160
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1860 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
1861
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1862 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
1863 this.span.className = c;
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1864 this.span.innerHTML = label;
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1865
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1866 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
1867 return this.current;
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1868 },
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1869 update : function (e) {
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1870 var p = this.paginator;
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1871 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
1872 this.leftmost_page = _pos[0];
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1873 this.rightmost_page = _pos[2];
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 if (e && e.prevValue === e.newValue) {
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1876 return;
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1877 }
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1878
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1879 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
1880 if (this.leftmost_page > 1) {
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1881 if (par && this.current === this.span) {
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1882 par.replaceChild(this.link,this.current);
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1883 this.current = this.link;
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1884 }
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1885 } else {
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1886 if (par && this.current === this.link) {
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1887 par.replaceChild(this.span,this.current);
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1888 this.current = this.span;
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1889 }
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1890 }
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1891 },
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1892 destroy : function () {
4160
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1893 YUE.purgeElement(this.link);
3776
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1894 this.current.parentNode.removeChild(this.current);
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1895 this.link = this.span = null;
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 onClick : function (e) {
4160
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1898 YUE.stopEvent(e);
3776
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1899 this.paginator.setPage(1);
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1900 }
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1901 };
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 })();
4157
bc296381fb6c rhodecode.js: remove unused stuff
Mads Kiilerich <madski@unity3d.com>
parents: 4135
diff changeset
1904
3776
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1905 (function () {
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 var Paginator = YAHOO.widget.Paginator,
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1908 l = YAHOO.lang,
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1909 setId = YAHOO.util.Dom.generateId;
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1910
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1911 Paginator.ui.MyLastPageLink = function (p) {
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1912 this.paginator = p;
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1913
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1914 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
1915 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
1916 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
1917 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
1918
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1919 // TODO: make this work
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1920 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
1921 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
1922 };
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1923
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1924 Paginator.ui.MyLastPageLink.init = function (p) {
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1925 p.setAttributeConfig('lastPageLinkLabel', {
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1926 value : -1,
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('lastPageLinkClass', {
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1930 value : 'yui-pg-last',
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 p.setAttributeConfig('lastPageLinkTitle', {
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1934 value : 'Last Page',
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1935 validator : l.isString
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1936 });
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 };
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1939
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1940 Paginator.ui.MyLastPageLink.prototype = {
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1941
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1942 current : null,
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1943 leftmost_page: null,
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1944 rightmost_page: null,
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1945 link : null,
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1946 span : null,
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1947 dotdot : null,
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1948 na : null,
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1949 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
1950 var edge = parseInt(items / 2) + 1;
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1951 if (cur_page <= edge){
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1952 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
1953 }
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1954 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
1955 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
1956 }
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1957 else{
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1958 var radius = parseInt(items / 2);
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1959 }
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 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
1962 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
1963 return [left, cur_page, right]
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1964 },
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1965 render : function (id_base) {
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1966 var p = this.paginator,
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1967 c = p.get('lastPageLinkClass'),
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1968 label = p.get('lastPageLinkLabel'),
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1969 last = p.getTotalPages(),
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1970 title = p.get('lastPageLinkTitle');
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 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
1973 this.leftmost_page = _pos[0];
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1974 this.rightmost_page = _pos[2];
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1975
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1976 this.link = document.createElement('a');
3784
62fb395a459d make sure we hide the spans
Marcin Kuzminski <marcin@python-works.com>
parents: 3776
diff changeset
1977 this.span = document.createElement('span');
4160
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1978 $(this.span).hide();
3784
62fb395a459d make sure we hide the spans
Marcin Kuzminski <marcin@python-works.com>
parents: 3776
diff changeset
1979
3776
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1980 this.na = this.span.cloneNode(false);
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1981
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1982 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
1983 this.link.href = '#';
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1984 this.link.className = c;
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1985 this.link.innerHTML = label;
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1986 this.link.title = title;
4160
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
1987 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
1988
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1989 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
1990 this.span.className = c;
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1991 this.span.innerHTML = label;
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1992
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1993 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
1994
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1995 if (this.rightmost_page < p.getTotalPages()){
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1996 this.current = this.link;
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 else{
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
1999 this.current = this.span;
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 this.current.innerHTML = p.getTotalPages();
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
2003 return this.current;
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
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
2006 update : function (e) {
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
2007 var p = this.paginator;
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 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
2010 this.leftmost_page = _pos[0];
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
2011 this.rightmost_page = _pos[2];
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 if (e && e.prevValue === e.newValue) {
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
2014 return;
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
2015 }
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 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
2018 after = this.link;
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
2019 if (par) {
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
2020
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
2021 // 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
2022 // 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
2023 if (!(this.rightmost_page < p.getTotalPages())){
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
2024 after = this.span
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
2025 }
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 if (this.current !== after) {
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
2028 par.replaceChild(after,this.current);
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
2029 this.current = after;
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 }
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
2032 this.current.innerHTML = this.paginator.getTotalPages();
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
2033
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
2034 },
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
2035 destroy : function () {
4160
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
2036 YUE.purgeElement(this.link);
3776
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
2037 this.current.parentNode.removeChild(this.current);
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
2038 this.link = this.span = null;
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 onClick : function (e) {
4160
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
2041 YUE.stopEvent(e);
3776
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
2042 this.paginator.setPage(this.paginator.getTotalPages());
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 };
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
2045
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
2046 })();
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
2047
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
2048 var pagi = new YAHOO.widget.Paginator({
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
2049 rowsPerPage: links_per_page,
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
2050 alwaysVisible: false,
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
2051 template : "{PreviousPageLink} {MyFirstPageLink} {PageLinks} {MyLastPageLink} {NextPageLink}",
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
2052 pageLinks: 5,
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
2053 containerClass: 'pagination-wh',
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
2054 currentPageClass: 'pager_curpage',
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
2055 pageLinkClass: 'pager_link',
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
2056 nextPageLinkLabel: '&gt;',
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
2057 previousPageLinkLabel: '&lt;',
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
2058 containers:containers
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
2059 })
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
2060
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
2061 return pagi
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
2062 }
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
2063
4164
197bfc8a4f03 rhodecode.js: make YUI_datatable 25 rows configurable as last param
Mads Kiilerich <madski@unity3d.com>
parents: 4163
diff changeset
2064 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
2065 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
2066 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
2067 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
2068 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
2069 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
2070 };
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 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
2072 // 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
2073 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
2074 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
2075 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
2076
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 (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
2078 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
2079 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
2080 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
2081 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
2082 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
2083 }
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 }
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 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
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 $(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
2088 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
2089 }
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
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 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
2092 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
2093 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
2094 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
2095 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
2096 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
2097 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
2098 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
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 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
2101 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
2102 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
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
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 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
2106 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
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 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
2109 // 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
2110 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
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 // 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
2113 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
2114 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
2115
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 // 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
2117 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
2118 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
2119 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
2120 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
2121 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
2122 };
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
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 $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
2125 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
2126 //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
2127 $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
2128 }
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 });
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 $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
2132 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
2133 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
2134 });
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
2135 }
3776
13241a4075e9 Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents: 3715
diff changeset
2136
3419
efc00d363d1e collapsable diff container in changeset, makes quick review easier
Marcin Kuzminski <marcin@python-works.com>
parents: 3417
diff changeset
2137 // 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
2138
4160
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
2139 $(document).ready(function(){
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
2140 $('.diff-collapse-button').click(function(e) {
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
2141 var $button = $(e.currentTarget);
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
2142 var $target = $('#' + $button.attr('target'));
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
2143 if($target.hasClass('hidden')){
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
2144 $target.removeClass('hidden');
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
2145 $button.html("&uarr; {0} &uarr;".format(_TM['Collapse diff']));
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
2146 }
4160
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
2147 else if(!$target.hasClass('hidden')){
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
2148 $target.addClass('hidden');
4451b2eabf64 rhodecode.js: more jQuery and general cleanup
Mads Kiilerich <madski@unity3d.com>
parents: 4159
diff changeset
2149 $button.html("&darr; {0} &darr;".format(_TM['Expand diff']));
3696
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
2150 }
e07b07ac9fbe codecleaner for rhodecode.js
Marcin Kuzminski <marcin@python-works.com>
parents: 3695
diff changeset
2151 });
3419
efc00d363d1e collapsable diff container in changeset, makes quick review easier
Marcin Kuzminski <marcin@python-works.com>
parents: 3417
diff changeset
2152 });