annotate rhodecode/public/js/rhodecode.js @ 3695:45df84d36b44 beta

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