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