Show More
@@ -1,1498 +1,1506 | |||||
1 | /** |
|
1 | /** | |
2 | RhodeCode JS Files |
|
2 | RhodeCode JS Files | |
3 | **/ |
|
3 | **/ | |
4 |
|
4 | |||
5 | if (typeof console == "undefined" || typeof console.log == "undefined"){ |
|
5 | if (typeof console == "undefined" || typeof console.log == "undefined"){ | |
6 | console = { log: function() {} } |
|
6 | console = { log: function() {} } | |
7 | } |
|
7 | } | |
8 |
|
8 | |||
9 |
|
9 | |||
10 | var str_repeat = function(i, m) { |
|
10 | var str_repeat = function(i, m) { | |
11 | for (var o = []; m > 0; o[--m] = i); |
|
11 | for (var o = []; m > 0; o[--m] = i); | |
12 | return o.join(''); |
|
12 | return o.join(''); | |
13 | }; |
|
13 | }; | |
14 |
|
14 | |||
15 | /** |
|
15 | /** | |
16 | * INJECT .format function into String |
|
16 | * INJECT .format function into String | |
17 | * Usage: "My name is {0} {1}".format("Johny","Bravo") |
|
17 | * Usage: "My name is {0} {1}".format("Johny","Bravo") | |
18 | * Return "My name is Johny Bravo" |
|
18 | * Return "My name is Johny Bravo" | |
19 | * Inspired by https://gist.github.com/1049426 |
|
19 | * Inspired by https://gist.github.com/1049426 | |
20 | */ |
|
20 | */ | |
21 | String.prototype.format = function() { |
|
21 | String.prototype.format = function() { | |
22 |
|
22 | |||
23 | function format() { |
|
23 | function format() { | |
24 | var str = this; |
|
24 | var str = this; | |
25 | var len = arguments.length+1; |
|
25 | var len = arguments.length+1; | |
26 | var safe = undefined; |
|
26 | var safe = undefined; | |
27 | var arg = undefined; |
|
27 | var arg = undefined; | |
28 |
|
28 | |||
29 | // For each {0} {1} {n...} replace with the argument in that position. If |
|
29 | // For each {0} {1} {n...} replace with the argument in that position. If | |
30 | // the argument is an object or an array it will be stringified to JSON. |
|
30 | // the argument is an object or an array it will be stringified to JSON. | |
31 | for (var i=0; i < len; arg = arguments[i++]) { |
|
31 | for (var i=0; i < len; arg = arguments[i++]) { | |
32 | safe = typeof arg === 'object' ? JSON.stringify(arg) : arg; |
|
32 | safe = typeof arg === 'object' ? JSON.stringify(arg) : arg; | |
33 | str = str.replace(RegExp('\\{'+(i-1)+'\\}', 'g'), safe); |
|
33 | str = str.replace(RegExp('\\{'+(i-1)+'\\}', 'g'), safe); | |
34 | } |
|
34 | } | |
35 | return str; |
|
35 | return str; | |
36 | } |
|
36 | } | |
37 |
|
37 | |||
38 | // Save a reference of what may already exist under the property native. |
|
38 | // Save a reference of what may already exist under the property native. | |
39 | // Allows for doing something like: if("".format.native) { /* use native */ } |
|
39 | // Allows for doing something like: if("".format.native) { /* use native */ } | |
40 | format.native = String.prototype.format; |
|
40 | format.native = String.prototype.format; | |
41 |
|
41 | |||
42 | // Replace the prototype property |
|
42 | // Replace the prototype property | |
43 | return format; |
|
43 | return format; | |
44 |
|
44 | |||
45 | }(); |
|
45 | }(); | |
46 |
|
46 | |||
47 | String.prototype.strip = function(char) { |
|
47 | String.prototype.strip = function(char) { | |
48 | if(char === undefined){ |
|
48 | if(char === undefined){ | |
49 | char = '\\s'; |
|
49 | char = '\\s'; | |
50 | } |
|
50 | } | |
51 | return this.replace(new RegExp('^'+char+'+|'+char+'+$','g'), ''); |
|
51 | return this.replace(new RegExp('^'+char+'+|'+char+'+$','g'), ''); | |
52 | } |
|
52 | } | |
53 | String.prototype.lstrip = function(char) { |
|
53 | String.prototype.lstrip = function(char) { | |
54 | if(char === undefined){ |
|
54 | if(char === undefined){ | |
55 | char = '\\s'; |
|
55 | char = '\\s'; | |
56 | } |
|
56 | } | |
57 | return this.replace(new RegExp('^'+char+'+'),''); |
|
57 | return this.replace(new RegExp('^'+char+'+'),''); | |
58 | } |
|
58 | } | |
59 | String.prototype.rstrip = function(char) { |
|
59 | String.prototype.rstrip = function(char) { | |
60 | if(char === undefined){ |
|
60 | if(char === undefined){ | |
61 | char = '\\s'; |
|
61 | char = '\\s'; | |
62 | } |
|
62 | } | |
63 | return this.replace(new RegExp(''+char+'+$'),''); |
|
63 | return this.replace(new RegExp(''+char+'+$'),''); | |
64 | } |
|
64 | } | |
65 |
|
65 | |||
66 | /** |
|
66 | /** | |
67 | * SmartColorGenerator |
|
67 | * SmartColorGenerator | |
68 | * |
|
68 | * | |
69 | *usage:: |
|
69 | *usage:: | |
70 | * var CG = new ColorGenerator(); |
|
70 | * var CG = new ColorGenerator(); | |
71 | * var col = CG.getColor(key); //returns array of RGB |
|
71 | * var col = CG.getColor(key); //returns array of RGB | |
72 | * 'rgb({0})'.format(col.join(',') |
|
72 | * 'rgb({0})'.format(col.join(',') | |
73 | * |
|
73 | * | |
74 | * @returns {ColorGenerator} |
|
74 | * @returns {ColorGenerator} | |
75 | */ |
|
75 | */ | |
76 | var ColorGenerator = function(){ |
|
76 | var ColorGenerator = function(){ | |
77 | this.GOLDEN_RATIO = 0.618033988749895; |
|
77 | this.GOLDEN_RATIO = 0.618033988749895; | |
78 | this.CURRENT_RATIO = 0.22717784590367374 // this can be random |
|
78 | this.CURRENT_RATIO = 0.22717784590367374 // this can be random | |
79 | this.HSV_1 = 0.75;//saturation |
|
79 | this.HSV_1 = 0.75;//saturation | |
80 | this.HSV_2 = 0.95; |
|
80 | this.HSV_2 = 0.95; | |
81 | this.color; |
|
81 | this.color; | |
82 | this.cacheColorMap = {}; |
|
82 | this.cacheColorMap = {}; | |
83 | }; |
|
83 | }; | |
84 |
|
84 | |||
85 | ColorGenerator.prototype = { |
|
85 | ColorGenerator.prototype = { | |
86 | getColor:function(key){ |
|
86 | getColor:function(key){ | |
87 | if(this.cacheColorMap[key] !== undefined){ |
|
87 | if(this.cacheColorMap[key] !== undefined){ | |
88 | return this.cacheColorMap[key]; |
|
88 | return this.cacheColorMap[key]; | |
89 | } |
|
89 | } | |
90 | else{ |
|
90 | else{ | |
91 | this.cacheColorMap[key] = this.generateColor(); |
|
91 | this.cacheColorMap[key] = this.generateColor(); | |
92 | return this.cacheColorMap[key]; |
|
92 | return this.cacheColorMap[key]; | |
93 | } |
|
93 | } | |
94 | }, |
|
94 | }, | |
95 | _hsvToRgb:function(h,s,v){ |
|
95 | _hsvToRgb:function(h,s,v){ | |
96 | if (s == 0.0) |
|
96 | if (s == 0.0) | |
97 | return [v, v, v]; |
|
97 | return [v, v, v]; | |
98 | i = parseInt(h * 6.0) |
|
98 | i = parseInt(h * 6.0) | |
99 | f = (h * 6.0) - i |
|
99 | f = (h * 6.0) - i | |
100 | p = v * (1.0 - s) |
|
100 | p = v * (1.0 - s) | |
101 | q = v * (1.0 - s * f) |
|
101 | q = v * (1.0 - s * f) | |
102 | t = v * (1.0 - s * (1.0 - f)) |
|
102 | t = v * (1.0 - s * (1.0 - f)) | |
103 | i = i % 6 |
|
103 | i = i % 6 | |
104 | if (i == 0) |
|
104 | if (i == 0) | |
105 | return [v, t, p] |
|
105 | return [v, t, p] | |
106 | if (i == 1) |
|
106 | if (i == 1) | |
107 | return [q, v, p] |
|
107 | return [q, v, p] | |
108 | if (i == 2) |
|
108 | if (i == 2) | |
109 | return [p, v, t] |
|
109 | return [p, v, t] | |
110 | if (i == 3) |
|
110 | if (i == 3) | |
111 | return [p, q, v] |
|
111 | return [p, q, v] | |
112 | if (i == 4) |
|
112 | if (i == 4) | |
113 | return [t, p, v] |
|
113 | return [t, p, v] | |
114 | if (i == 5) |
|
114 | if (i == 5) | |
115 | return [v, p, q] |
|
115 | return [v, p, q] | |
116 | }, |
|
116 | }, | |
117 | generateColor:function(){ |
|
117 | generateColor:function(){ | |
118 | this.CURRENT_RATIO = this.CURRENT_RATIO+this.GOLDEN_RATIO; |
|
118 | this.CURRENT_RATIO = this.CURRENT_RATIO+this.GOLDEN_RATIO; | |
119 | this.CURRENT_RATIO = this.CURRENT_RATIO %= 1; |
|
119 | this.CURRENT_RATIO = this.CURRENT_RATIO %= 1; | |
120 | HSV_tuple = [this.CURRENT_RATIO, this.HSV_1, this.HSV_2] |
|
120 | HSV_tuple = [this.CURRENT_RATIO, this.HSV_1, this.HSV_2] | |
121 | RGB_tuple = this._hsvToRgb(HSV_tuple[0],HSV_tuple[1],HSV_tuple[2]); |
|
121 | RGB_tuple = this._hsvToRgb(HSV_tuple[0],HSV_tuple[1],HSV_tuple[2]); | |
122 | function toRgb(v){ |
|
122 | function toRgb(v){ | |
123 | return ""+parseInt(v*256) |
|
123 | return ""+parseInt(v*256) | |
124 | } |
|
124 | } | |
125 | return [toRgb(RGB_tuple[0]),toRgb(RGB_tuple[1]),toRgb(RGB_tuple[2])]; |
|
125 | return [toRgb(RGB_tuple[0]),toRgb(RGB_tuple[1]),toRgb(RGB_tuple[2])]; | |
126 |
|
126 | |||
127 | } |
|
127 | } | |
128 | } |
|
128 | } | |
129 |
|
129 | |||
130 |
|
130 | |||
131 |
|
131 | |||
132 |
|
132 | |||
133 |
|
133 | |||
134 | /** |
|
134 | /** | |
135 | * GLOBAL YUI Shortcuts |
|
135 | * GLOBAL YUI Shortcuts | |
136 | */ |
|
136 | */ | |
137 | var YUC = YAHOO.util.Connect; |
|
137 | var YUC = YAHOO.util.Connect; | |
138 | var YUD = YAHOO.util.Dom; |
|
138 | var YUD = YAHOO.util.Dom; | |
139 | var YUE = YAHOO.util.Event; |
|
139 | var YUE = YAHOO.util.Event; | |
140 | var YUQ = YAHOO.util.Selector.query; |
|
140 | var YUQ = YAHOO.util.Selector.query; | |
141 |
|
141 | |||
142 | // defines if push state is enabled for this browser ? |
|
142 | // defines if push state is enabled for this browser ? | |
143 | var push_state_enabled = Boolean( |
|
143 | var push_state_enabled = Boolean( | |
144 | window.history && window.history.pushState && window.history.replaceState |
|
144 | window.history && window.history.pushState && window.history.replaceState | |
145 | && !( /* disable for versions of iOS before version 4.3 (8F190) */ |
|
145 | && !( /* disable for versions of iOS before version 4.3 (8F190) */ | |
146 | (/ Mobile\/([1-7][a-z]|(8([abcde]|f(1[0-8]))))/i).test(navigator.userAgent) |
|
146 | (/ Mobile\/([1-7][a-z]|(8([abcde]|f(1[0-8]))))/i).test(navigator.userAgent) | |
147 | /* disable for the mercury iOS browser, or at least older versions of the webkit engine */ |
|
147 | /* disable for the mercury iOS browser, or at least older versions of the webkit engine */ | |
148 | || (/AppleWebKit\/5([0-2]|3[0-2])/i).test(navigator.userAgent) |
|
148 | || (/AppleWebKit\/5([0-2]|3[0-2])/i).test(navigator.userAgent) | |
149 | ) |
|
149 | ) | |
150 | ); |
|
150 | ); | |
151 |
|
151 | |||
152 | var _run_callbacks = function(callbacks){ |
|
152 | var _run_callbacks = function(callbacks){ | |
153 | if (callbacks !== undefined){ |
|
153 | if (callbacks !== undefined){ | |
154 | var _l = callbacks.length; |
|
154 | var _l = callbacks.length; | |
155 | for (var i=0;i<_l;i++){ |
|
155 | for (var i=0;i<_l;i++){ | |
156 | var func = callbacks[i]; |
|
156 | var func = callbacks[i]; | |
157 | if(typeof(func)=='function'){ |
|
157 | if(typeof(func)=='function'){ | |
158 | try{ |
|
158 | try{ | |
159 | func(); |
|
159 | func(); | |
160 | }catch (err){}; |
|
160 | }catch (err){}; | |
161 | } |
|
161 | } | |
162 | } |
|
162 | } | |
163 | } |
|
163 | } | |
164 | } |
|
164 | } | |
165 |
|
165 | |||
166 | /** |
|
166 | /** | |
167 | * Partial Ajax Implementation |
|
167 | * Partial Ajax Implementation | |
168 | * |
|
168 | * | |
169 | * @param url: defines url to make partial request |
|
169 | * @param url: defines url to make partial request | |
170 | * @param container: defines id of container to input partial result |
|
170 | * @param container: defines id of container to input partial result | |
171 | * @param s_call: success callback function that takes o as arg |
|
171 | * @param s_call: success callback function that takes o as arg | |
172 | * o.tId |
|
172 | * o.tId | |
173 | * o.status |
|
173 | * o.status | |
174 | * o.statusText |
|
174 | * o.statusText | |
175 | * o.getResponseHeader[ ] |
|
175 | * o.getResponseHeader[ ] | |
176 | * o.getAllResponseHeaders |
|
176 | * o.getAllResponseHeaders | |
177 | * o.responseText |
|
177 | * o.responseText | |
178 | * o.responseXML |
|
178 | * o.responseXML | |
179 | * o.argument |
|
179 | * o.argument | |
180 | * @param f_call: failure callback |
|
180 | * @param f_call: failure callback | |
181 | * @param args arguments |
|
181 | * @param args arguments | |
182 | */ |
|
182 | */ | |
183 | function ypjax(url,container,s_call,f_call,args){ |
|
183 | function ypjax(url,container,s_call,f_call,args){ | |
184 | var method='GET'; |
|
184 | var method='GET'; | |
185 | if(args===undefined){ |
|
185 | if(args===undefined){ | |
186 | args=null; |
|
186 | args=null; | |
187 | } |
|
187 | } | |
188 |
|
188 | |||
189 | // Set special header for partial ajax == HTTP_X_PARTIAL_XHR |
|
189 | // Set special header for partial ajax == HTTP_X_PARTIAL_XHR | |
190 | YUC.initHeader('X-PARTIAL-XHR',true); |
|
190 | YUC.initHeader('X-PARTIAL-XHR',true); | |
191 |
|
191 | |||
192 | // wrapper of passed callback |
|
192 | // wrapper of passed callback | |
193 | var s_wrapper = (function(o){ |
|
193 | var s_wrapper = (function(o){ | |
194 | return function(o){ |
|
194 | return function(o){ | |
195 | YUD.get(container).innerHTML=o.responseText; |
|
195 | YUD.get(container).innerHTML=o.responseText; | |
196 | YUD.setStyle(container,'opacity','1.0'); |
|
196 | YUD.setStyle(container,'opacity','1.0'); | |
197 | //execute the given original callback |
|
197 | //execute the given original callback | |
198 | if (s_call !== undefined){ |
|
198 | if (s_call !== undefined){ | |
199 | s_call(o); |
|
199 | s_call(o); | |
200 | } |
|
200 | } | |
201 | } |
|
201 | } | |
202 | })() |
|
202 | })() | |
203 | YUD.setStyle(container,'opacity','0.3'); |
|
203 | YUD.setStyle(container,'opacity','0.3'); | |
204 | YUC.asyncRequest(method,url,{ |
|
204 | YUC.asyncRequest(method,url,{ | |
205 | success:s_wrapper, |
|
205 | success:s_wrapper, | |
206 | failure:function(o){ |
|
206 | failure:function(o){ | |
207 | console.log(o); |
|
207 | console.log(o); | |
208 | YUD.get(container).innerHTML='ERROR '+o.status; |
|
208 | YUD.get(container).innerHTML='ERROR '+o.status; | |
209 | YUD.setStyle(container,'opacity','1.0'); |
|
209 | YUD.setStyle(container,'opacity','1.0'); | |
210 | YUD.setStyle(container,'color','red'); |
|
210 | YUD.setStyle(container,'color','red'); | |
211 | } |
|
211 | } | |
212 | },args); |
|
212 | },args); | |
213 |
|
213 | |||
214 | }; |
|
214 | }; | |
215 |
|
215 | |||
216 | var ajaxPOST = function(url,postData,success) { |
|
216 | var ajaxPOST = function(url,postData,success) { | |
217 | // Set special header for ajax == HTTP_X_PARTIAL_XHR |
|
217 | // Set special header for ajax == HTTP_X_PARTIAL_XHR | |
218 | YUC.initHeader('X-PARTIAL-XHR',true); |
|
218 | YUC.initHeader('X-PARTIAL-XHR',true); | |
219 |
|
219 | |||
220 | var toQueryString = function(o) { |
|
220 | var toQueryString = function(o) { | |
221 | if(typeof o !== 'object') { |
|
221 | if(typeof o !== 'object') { | |
222 | return false; |
|
222 | return false; | |
223 | } |
|
223 | } | |
224 | var _p, _qs = []; |
|
224 | var _p, _qs = []; | |
225 | for(_p in o) { |
|
225 | for(_p in o) { | |
226 | _qs.push(encodeURIComponent(_p) + '=' + encodeURIComponent(o[_p])); |
|
226 | _qs.push(encodeURIComponent(_p) + '=' + encodeURIComponent(o[_p])); | |
227 | } |
|
227 | } | |
228 | return _qs.join('&'); |
|
228 | return _qs.join('&'); | |
229 | }; |
|
229 | }; | |
230 |
|
230 | |||
231 | var sUrl = url; |
|
231 | var sUrl = url; | |
232 | var callback = { |
|
232 | var callback = { | |
233 | success: success, |
|
233 | success: success, | |
234 | failure: function (o) { |
|
234 | failure: function (o) { | |
235 | alert("error"); |
|
235 | alert("error"); | |
236 | }, |
|
236 | }, | |
237 | }; |
|
237 | }; | |
238 | var postData = toQueryString(postData); |
|
238 | var postData = toQueryString(postData); | |
239 | var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, callback, postData); |
|
239 | var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, callback, postData); | |
240 | return request; |
|
240 | return request; | |
241 | }; |
|
241 | }; | |
242 |
|
242 | |||
243 |
|
243 | |||
244 | /** |
|
244 | /** | |
245 | * tooltip activate |
|
245 | * tooltip activate | |
246 | */ |
|
246 | */ | |
247 | var tooltip_activate = function(){ |
|
247 | var tooltip_activate = function(){ | |
248 | function toolTipsId(){ |
|
248 | function toolTipsId(){ | |
249 | var ids = []; |
|
249 | var ids = []; | |
250 | var tts = YUQ('.tooltip'); |
|
250 | var tts = YUQ('.tooltip'); | |
251 | for (var i = 0; i < tts.length; i++) { |
|
251 | for (var i = 0; i < tts.length; i++) { | |
252 | // if element doesn't not have and id |
|
252 | // if element doesn't not have and id | |
253 | // autogenerate one for tooltip |
|
253 | // autogenerate one for tooltip | |
254 | if (!tts[i].id){ |
|
254 | if (!tts[i].id){ | |
255 | tts[i].id='tt'+((i*100)+tts.length); |
|
255 | tts[i].id='tt'+((i*100)+tts.length); | |
256 | } |
|
256 | } | |
257 | ids.push(tts[i].id); |
|
257 | ids.push(tts[i].id); | |
258 | } |
|
258 | } | |
259 | return ids |
|
259 | return ids | |
260 | }; |
|
260 | }; | |
261 | var myToolTips = new YAHOO.widget.Tooltip("tooltip", { |
|
261 | var myToolTips = new YAHOO.widget.Tooltip("tooltip", { | |
262 | context: [[toolTipsId()],"tl","bl",null,[0,5]], |
|
262 | context: [[toolTipsId()],"tl","bl",null,[0,5]], | |
263 | monitorresize:false, |
|
263 | monitorresize:false, | |
264 | xyoffset :[0,0], |
|
264 | xyoffset :[0,0], | |
265 | autodismissdelay:300000, |
|
265 | autodismissdelay:300000, | |
266 | hidedelay:5, |
|
266 | hidedelay:5, | |
267 | showdelay:20, |
|
267 | showdelay:20, | |
268 | }); |
|
268 | }); | |
269 | }; |
|
269 | }; | |
270 |
|
270 | |||
271 | /** |
|
271 | /** | |
272 | * show more |
|
272 | * show more | |
273 | */ |
|
273 | */ | |
274 | var show_more_event = function(){ |
|
274 | var show_more_event = function(){ | |
275 | YUE.on(YUD.getElementsByClassName('show_more'),'click',function(e){ |
|
275 | YUE.on(YUD.getElementsByClassName('show_more'),'click',function(e){ | |
276 | var el = e.target; |
|
276 | var el = e.target; | |
277 | YUD.setStyle(YUD.get(el.id.substring(1)),'display',''); |
|
277 | YUD.setStyle(YUD.get(el.id.substring(1)),'display',''); | |
278 | YUD.setStyle(el.parentNode,'display','none'); |
|
278 | YUD.setStyle(el.parentNode,'display','none'); | |
279 | }); |
|
279 | }); | |
280 | }; |
|
280 | }; | |
281 |
|
281 | |||
282 |
|
282 | |||
283 | /** |
|
283 | /** | |
284 | * Quick filter widget |
|
284 | * Quick filter widget | |
285 | * |
|
285 | * | |
286 | * @param target: filter input target |
|
286 | * @param target: filter input target | |
287 | * @param nodes: list of nodes in html we want to filter. |
|
287 | * @param nodes: list of nodes in html we want to filter. | |
288 | * @param display_element function that takes current node from nodes and |
|
288 | * @param display_element function that takes current node from nodes and | |
289 | * does hide or show based on the node |
|
289 | * does hide or show based on the node | |
290 | * |
|
290 | * | |
291 | */ |
|
291 | */ | |
292 | var q_filter = function(target,nodes,display_element){ |
|
292 | var q_filter = function(target,nodes,display_element){ | |
293 |
|
293 | |||
294 | var nodes = nodes; |
|
294 | var nodes = nodes; | |
295 | var q_filter_field = YUD.get(target); |
|
295 | var q_filter_field = YUD.get(target); | |
296 | var F = YAHOO.namespace(target); |
|
296 | var F = YAHOO.namespace(target); | |
297 |
|
297 | |||
298 | YUE.on(q_filter_field,'click',function(){ |
|
298 | YUE.on(q_filter_field,'click',function(){ | |
299 | q_filter_field.value = ''; |
|
299 | q_filter_field.value = ''; | |
300 | }); |
|
300 | }); | |
301 |
|
301 | |||
302 | YUE.on(q_filter_field,'keyup',function(e){ |
|
302 | YUE.on(q_filter_field,'keyup',function(e){ | |
303 | clearTimeout(F.filterTimeout); |
|
303 | clearTimeout(F.filterTimeout); | |
304 | F.filterTimeout = setTimeout(F.updateFilter,600); |
|
304 | F.filterTimeout = setTimeout(F.updateFilter,600); | |
305 | }); |
|
305 | }); | |
306 |
|
306 | |||
307 | F.filterTimeout = null; |
|
307 | F.filterTimeout = null; | |
308 |
|
308 | |||
309 | var show_node = function(node){ |
|
309 | var show_node = function(node){ | |
310 | YUD.setStyle(node,'display','') |
|
310 | YUD.setStyle(node,'display','') | |
311 | } |
|
311 | } | |
312 | var hide_node = function(node){ |
|
312 | var hide_node = function(node){ | |
313 | YUD.setStyle(node,'display','none'); |
|
313 | YUD.setStyle(node,'display','none'); | |
314 | } |
|
314 | } | |
315 |
|
315 | |||
316 | F.updateFilter = function() { |
|
316 | F.updateFilter = function() { | |
317 | // Reset timeout |
|
317 | // Reset timeout | |
318 | F.filterTimeout = null; |
|
318 | F.filterTimeout = null; | |
319 |
|
319 | |||
320 | var obsolete = []; |
|
320 | var obsolete = []; | |
321 |
|
321 | |||
322 | var req = q_filter_field.value.toLowerCase(); |
|
322 | var req = q_filter_field.value.toLowerCase(); | |
323 |
|
323 | |||
324 | var l = nodes.length; |
|
324 | var l = nodes.length; | |
325 | var i; |
|
325 | var i; | |
326 | var showing = 0; |
|
326 | var showing = 0; | |
327 |
|
327 | |||
328 | for (i=0;i<l;i++ ){ |
|
328 | for (i=0;i<l;i++ ){ | |
329 | var n = nodes[i]; |
|
329 | var n = nodes[i]; | |
330 | var target_element = display_element(n) |
|
330 | var target_element = display_element(n) | |
331 | if(req && n.innerHTML.toLowerCase().indexOf(req) == -1){ |
|
331 | if(req && n.innerHTML.toLowerCase().indexOf(req) == -1){ | |
332 | hide_node(target_element); |
|
332 | hide_node(target_element); | |
333 | } |
|
333 | } | |
334 | else{ |
|
334 | else{ | |
335 | show_node(target_element); |
|
335 | show_node(target_element); | |
336 | showing+=1; |
|
336 | showing+=1; | |
337 | } |
|
337 | } | |
338 | } |
|
338 | } | |
339 |
|
339 | |||
340 | // if repo_count is set update the number |
|
340 | // if repo_count is set update the number | |
341 | var cnt = YUD.get('repo_count'); |
|
341 | var cnt = YUD.get('repo_count'); | |
342 | if(cnt){ |
|
342 | if(cnt){ | |
343 | YUD.get('repo_count').innerHTML = showing; |
|
343 | YUD.get('repo_count').innerHTML = showing; | |
344 | } |
|
344 | } | |
345 |
|
345 | |||
346 | } |
|
346 | } | |
347 | }; |
|
347 | }; | |
348 |
|
348 | |||
349 | var tableTr = function(cls,body){ |
|
349 | var tableTr = function(cls,body){ | |
350 | var tr = document.createElement('tr'); |
|
350 | var tr = document.createElement('tr'); | |
351 | YUD.addClass(tr, cls); |
|
351 | YUD.addClass(tr, cls); | |
352 |
|
352 | |||
353 |
|
353 | |||
354 | var cont = new YAHOO.util.Element(body); |
|
354 | var cont = new YAHOO.util.Element(body); | |
355 | var comment_id = fromHTML(body).children[0].id.split('comment-')[1]; |
|
355 | var comment_id = fromHTML(body).children[0].id.split('comment-')[1]; | |
356 | tr.id = 'comment-tr-{0}'.format(comment_id); |
|
356 | tr.id = 'comment-tr-{0}'.format(comment_id); | |
357 | tr.innerHTML = '<td class="lineno-inline new-inline"></td>'+ |
|
357 | tr.innerHTML = '<td class="lineno-inline new-inline"></td>'+ | |
358 | '<td class="lineno-inline old-inline"></td>'+ |
|
358 | '<td class="lineno-inline old-inline"></td>'+ | |
359 | '<td>{0}</td>'.format(body); |
|
359 | '<td>{0}</td>'.format(body); | |
360 | return tr; |
|
360 | return tr; | |
361 | }; |
|
361 | }; | |
362 |
|
362 | |||
363 | /** comments **/ |
|
363 | /** comments **/ | |
364 | var removeInlineForm = function(form) { |
|
364 | var removeInlineForm = function(form) { | |
365 | form.parentNode.removeChild(form); |
|
365 | form.parentNode.removeChild(form); | |
366 | }; |
|
366 | }; | |
367 |
|
367 | |||
368 | var createInlineForm = function(parent_tr, f_path, line) { |
|
368 | var createInlineForm = function(parent_tr, f_path, line) { | |
369 | var tmpl = YUD.get('comment-inline-form-template').innerHTML; |
|
369 | var tmpl = YUD.get('comment-inline-form-template').innerHTML; | |
370 | tmpl = tmpl.format(f_path, line); |
|
370 | tmpl = tmpl.format(f_path, line); | |
371 | var form = tableTr('comment-form-inline',tmpl) |
|
371 | var form = tableTr('comment-form-inline',tmpl) | |
372 |
|
372 | |||
373 | // create event for hide button |
|
373 | // create event for hide button | |
374 | form = new YAHOO.util.Element(form); |
|
374 | form = new YAHOO.util.Element(form); | |
375 | var form_hide_button = new YAHOO.util.Element(form.getElementsByClassName('hide-inline-form')[0]); |
|
375 | var form_hide_button = new YAHOO.util.Element(form.getElementsByClassName('hide-inline-form')[0]); | |
376 | form_hide_button.on('click', function(e) { |
|
376 | form_hide_button.on('click', function(e) { | |
377 | var newtr = e.currentTarget.parentNode.parentNode.parentNode.parentNode.parentNode; |
|
377 | var newtr = e.currentTarget.parentNode.parentNode.parentNode.parentNode.parentNode; | |
378 | if(YUD.hasClass(newtr.nextElementSibling,'inline-comments-button')){ |
|
378 | if(YUD.hasClass(newtr.nextElementSibling,'inline-comments-button')){ | |
379 | YUD.setStyle(newtr.nextElementSibling,'display',''); |
|
379 | YUD.setStyle(newtr.nextElementSibling,'display',''); | |
380 | } |
|
380 | } | |
381 | removeInlineForm(newtr); |
|
381 | removeInlineForm(newtr); | |
382 | YUD.removeClass(parent_tr, 'form-open'); |
|
382 | YUD.removeClass(parent_tr, 'form-open'); | |
383 |
|
383 | |||
384 | }); |
|
384 | }); | |
385 |
|
385 | |||
386 | return form |
|
386 | return form | |
387 | }; |
|
387 | }; | |
388 |
|
388 | |||
389 | /** |
|
389 | /** | |
390 | * Inject inline comment for on given TR this tr should be always an .line |
|
390 | * Inject inline comment for on given TR this tr should be always an .line | |
391 | * tr containing the line. Code will detect comment, and always put the comment |
|
391 | * tr containing the line. Code will detect comment, and always put the comment | |
392 | * block at the very bottom |
|
392 | * block at the very bottom | |
393 | */ |
|
393 | */ | |
394 | var injectInlineForm = function(tr){ |
|
394 | var injectInlineForm = function(tr){ | |
395 | if(!YUD.hasClass(tr, 'line')){ |
|
395 | if(!YUD.hasClass(tr, 'line')){ | |
396 | return |
|
396 | return | |
397 | } |
|
397 | } | |
398 | var submit_url = AJAX_COMMENT_URL; |
|
398 | var submit_url = AJAX_COMMENT_URL; | |
399 | var _td = tr.getElementsByClassName('code')[0]; |
|
399 | var _td = tr.getElementsByClassName('code')[0]; | |
400 | if(YUD.hasClass(tr,'form-open') || YUD.hasClass(tr,'context') || YUD.hasClass(_td,'no-comment')){ |
|
400 | if(YUD.hasClass(tr,'form-open') || YUD.hasClass(tr,'context') || YUD.hasClass(_td,'no-comment')){ | |
401 | return |
|
401 | return | |
402 | } |
|
402 | } | |
403 | YUD.addClass(tr,'form-open'); |
|
403 | YUD.addClass(tr,'form-open'); | |
404 | var node = tr.parentNode.parentNode.parentNode.getElementsByClassName('full_f_path')[0]; |
|
404 | var node = tr.parentNode.parentNode.parentNode.getElementsByClassName('full_f_path')[0]; | |
405 | var f_path = YUD.getAttribute(node,'path'); |
|
405 | var f_path = YUD.getAttribute(node,'path'); | |
406 | var lineno = getLineNo(tr); |
|
406 | var lineno = getLineNo(tr); | |
407 | var form = createInlineForm(tr, f_path, lineno, submit_url); |
|
407 | var form = createInlineForm(tr, f_path, lineno, submit_url); | |
408 |
|
408 | |||
409 | var parent = tr; |
|
409 | var parent = tr; | |
410 | while (1){ |
|
410 | while (1){ | |
411 | var n = parent.nextElementSibling; |
|
411 | var n = parent.nextElementSibling; | |
412 | // next element are comments ! |
|
412 | // next element are comments ! | |
413 | if(YUD.hasClass(n,'inline-comments')){ |
|
413 | if(YUD.hasClass(n,'inline-comments')){ | |
414 | parent = n; |
|
414 | parent = n; | |
415 | } |
|
415 | } | |
416 | else{ |
|
416 | else{ | |
417 | break; |
|
417 | break; | |
418 | } |
|
418 | } | |
419 | } |
|
419 | } | |
420 | YUD.insertAfter(form,parent); |
|
420 | YUD.insertAfter(form,parent); | |
421 |
|
421 | |||
422 | var f = YUD.get(form); |
|
422 | var f = YUD.get(form); | |
423 |
|
423 | |||
424 | var overlay = f.getElementsByClassName('overlay')[0]; |
|
424 | var overlay = f.getElementsByClassName('overlay')[0]; | |
425 | var _form = f.getElementsByClassName('inline-form')[0]; |
|
425 | var _form = f.getElementsByClassName('inline-form')[0]; | |
426 |
|
426 | |||
427 | form.on('submit',function(e){ |
|
427 | form.on('submit',function(e){ | |
428 | YUE.preventDefault(e); |
|
428 | YUE.preventDefault(e); | |
429 |
|
429 | |||
430 | //ajax submit |
|
430 | //ajax submit | |
431 | var text = YUD.get('text_'+lineno).value; |
|
431 | var text = YUD.get('text_'+lineno).value; | |
432 | var postData = { |
|
432 | var postData = { | |
433 | 'text':text, |
|
433 | 'text':text, | |
434 | 'f_path':f_path, |
|
434 | 'f_path':f_path, | |
435 | 'line':lineno |
|
435 | 'line':lineno | |
436 | }; |
|
436 | }; | |
437 |
|
437 | |||
438 | if(lineno === undefined){ |
|
438 | if(lineno === undefined){ | |
439 | alert('missing line !'); |
|
439 | alert('missing line !'); | |
440 | return |
|
440 | return | |
441 | } |
|
441 | } | |
442 | if(f_path === undefined){ |
|
442 | if(f_path === undefined){ | |
443 | alert('missing file path !'); |
|
443 | alert('missing file path !'); | |
444 | return |
|
444 | return | |
445 | } |
|
445 | } | |
446 |
|
446 | |||
447 | if(text == ""){ |
|
447 | if(text == ""){ | |
448 | return |
|
448 | return | |
449 | } |
|
449 | } | |
450 |
|
450 | |||
451 | var success = function(o){ |
|
451 | var success = function(o){ | |
452 | YUD.removeClass(tr, 'form-open'); |
|
452 | YUD.removeClass(tr, 'form-open'); | |
453 | removeInlineForm(f); |
|
453 | removeInlineForm(f); | |
454 | var json_data = JSON.parse(o.responseText); |
|
454 | var json_data = JSON.parse(o.responseText); | |
455 | renderInlineComment(json_data); |
|
455 | renderInlineComment(json_data); | |
456 | }; |
|
456 | }; | |
457 |
|
457 | |||
458 | if (YUD.hasClass(overlay,'overlay')){ |
|
458 | if (YUD.hasClass(overlay,'overlay')){ | |
459 | var w = _form.offsetWidth; |
|
459 | var w = _form.offsetWidth; | |
460 | var h = _form.offsetHeight; |
|
460 | var h = _form.offsetHeight; | |
461 | YUD.setStyle(overlay,'width',w+'px'); |
|
461 | YUD.setStyle(overlay,'width',w+'px'); | |
462 | YUD.setStyle(overlay,'height',h+'px'); |
|
462 | YUD.setStyle(overlay,'height',h+'px'); | |
463 | } |
|
463 | } | |
464 | YUD.addClass(overlay, 'submitting'); |
|
464 | YUD.addClass(overlay, 'submitting'); | |
465 |
|
465 | |||
466 | ajaxPOST(submit_url, postData, success); |
|
466 | ajaxPOST(submit_url, postData, success); | |
467 | }); |
|
467 | }); | |
468 |
|
468 | |||
469 | setTimeout(function(){ |
|
469 | setTimeout(function(){ | |
470 | // callbacks |
|
470 | // callbacks | |
471 | tooltip_activate(); |
|
471 | tooltip_activate(); | |
472 | MentionsAutoComplete('text_'+lineno, 'mentions_container_'+lineno, |
|
472 | MentionsAutoComplete('text_'+lineno, 'mentions_container_'+lineno, | |
473 | _USERS_AC_DATA, _GROUPS_AC_DATA); |
|
473 | _USERS_AC_DATA, _GROUPS_AC_DATA); | |
474 | YUD.get('text_'+lineno).focus(); |
|
474 | YUD.get('text_'+lineno).focus(); | |
475 | },10) |
|
475 | },10) | |
476 | }; |
|
476 | }; | |
477 |
|
477 | |||
478 | var deleteComment = function(comment_id){ |
|
478 | var deleteComment = function(comment_id){ | |
479 | var url = AJAX_COMMENT_DELETE_URL.replace('__COMMENT_ID__',comment_id); |
|
479 | var url = AJAX_COMMENT_DELETE_URL.replace('__COMMENT_ID__',comment_id); | |
480 | var postData = {'_method':'delete'}; |
|
480 | var postData = {'_method':'delete'}; | |
481 | var success = function(o){ |
|
481 | var success = function(o){ | |
482 | var n = YUD.get('comment-tr-'+comment_id); |
|
482 | var n = YUD.get('comment-tr-'+comment_id); | |
483 | var root = n.previousElementSibling.previousElementSibling; |
|
483 | var root = n.previousElementSibling.previousElementSibling; | |
484 | n.parentNode.removeChild(n); |
|
484 | n.parentNode.removeChild(n); | |
485 |
|
485 | |||
486 | // scann nodes, and attach add button to last one |
|
486 | // scann nodes, and attach add button to last one | |
487 | placeAddButton(root); |
|
487 | placeAddButton(root); | |
488 | } |
|
488 | } | |
489 | ajaxPOST(url,postData,success); |
|
489 | ajaxPOST(url,postData,success); | |
490 | } |
|
490 | } | |
491 |
|
491 | |||
492 |
|
492 | |||
493 | var createInlineAddButton = function(tr){ |
|
493 | var createInlineAddButton = function(tr){ | |
494 |
|
494 | |||
495 | var label = TRANSLATION_MAP['add another comment']; |
|
495 | var label = TRANSLATION_MAP['add another comment']; | |
496 |
|
496 | |||
497 | var html_el = document.createElement('div'); |
|
497 | var html_el = document.createElement('div'); | |
498 | YUD.addClass(html_el, 'add-comment'); |
|
498 | YUD.addClass(html_el, 'add-comment'); | |
499 | html_el.innerHTML = '<span class="ui-btn">{0}</span>'.format(label); |
|
499 | html_el.innerHTML = '<span class="ui-btn">{0}</span>'.format(label); | |
500 |
|
500 | |||
501 | var add = new YAHOO.util.Element(html_el); |
|
501 | var add = new YAHOO.util.Element(html_el); | |
502 | add.on('click', function(e) { |
|
502 | add.on('click', function(e) { | |
503 | injectInlineForm(tr); |
|
503 | injectInlineForm(tr); | |
504 | }); |
|
504 | }); | |
505 | return add; |
|
505 | return add; | |
506 | }; |
|
506 | }; | |
507 |
|
507 | |||
508 | var getLineNo = function(tr) { |
|
508 | var getLineNo = function(tr) { | |
509 | var line; |
|
509 | var line; | |
510 | var o = tr.children[0].id.split('_'); |
|
510 | var o = tr.children[0].id.split('_'); | |
511 | var n = tr.children[1].id.split('_'); |
|
511 | var n = tr.children[1].id.split('_'); | |
512 |
|
512 | |||
513 | if (n.length >= 2) { |
|
513 | if (n.length >= 2) { | |
514 | line = n[n.length-1]; |
|
514 | line = n[n.length-1]; | |
515 | } else if (o.length >= 2) { |
|
515 | } else if (o.length >= 2) { | |
516 | line = o[o.length-1]; |
|
516 | line = o[o.length-1]; | |
517 | } |
|
517 | } | |
518 |
|
518 | |||
519 | return line |
|
519 | return line | |
520 | }; |
|
520 | }; | |
521 |
|
521 | |||
522 | var placeAddButton = function(target_tr){ |
|
522 | var placeAddButton = function(target_tr){ | |
523 | if(!target_tr){ |
|
523 | if(!target_tr){ | |
524 | return |
|
524 | return | |
525 | } |
|
525 | } | |
526 | var last_node = target_tr; |
|
526 | var last_node = target_tr; | |
527 | //scann |
|
527 | //scann | |
528 | while (1){ |
|
528 | while (1){ | |
529 | var n = last_node.nextElementSibling; |
|
529 | var n = last_node.nextElementSibling; | |
530 | // next element are comments ! |
|
530 | // next element are comments ! | |
531 | if(YUD.hasClass(n,'inline-comments')){ |
|
531 | if(YUD.hasClass(n,'inline-comments')){ | |
532 | last_node = n; |
|
532 | last_node = n; | |
533 | //also remove the comment button from previos |
|
533 | //also remove the comment button from previos | |
534 | var comment_add_buttons = last_node.getElementsByClassName('add-comment'); |
|
534 | var comment_add_buttons = last_node.getElementsByClassName('add-comment'); | |
535 | for(var i=0;i<comment_add_buttons.length;i++){ |
|
535 | for(var i=0;i<comment_add_buttons.length;i++){ | |
536 | var b = comment_add_buttons[i]; |
|
536 | var b = comment_add_buttons[i]; | |
537 | b.parentNode.removeChild(b); |
|
537 | b.parentNode.removeChild(b); | |
538 | } |
|
538 | } | |
539 | } |
|
539 | } | |
540 | else{ |
|
540 | else{ | |
541 | break; |
|
541 | break; | |
542 | } |
|
542 | } | |
543 | } |
|
543 | } | |
544 |
|
544 | |||
545 | var add = createInlineAddButton(target_tr); |
|
545 | var add = createInlineAddButton(target_tr); | |
546 | // get the comment div |
|
546 | // get the comment div | |
547 | var comment_block = last_node.getElementsByClassName('comment')[0]; |
|
547 | var comment_block = last_node.getElementsByClassName('comment')[0]; | |
548 | // attach add button |
|
548 | // attach add button | |
549 | YUD.insertAfter(add,comment_block); |
|
549 | YUD.insertAfter(add,comment_block); | |
550 | } |
|
550 | } | |
551 |
|
551 | |||
552 | /** |
|
552 | /** | |
553 | * Places the inline comment into the changeset block in proper line position |
|
553 | * Places the inline comment into the changeset block in proper line position | |
554 | */ |
|
554 | */ | |
555 | var placeInline = function(target_container,lineno,html){ |
|
555 | var placeInline = function(target_container,lineno,html){ | |
556 | var lineid = "{0}_{1}".format(target_container,lineno); |
|
556 | var lineid = "{0}_{1}".format(target_container,lineno); | |
557 | var target_line = YUD.get(lineid); |
|
557 | var target_line = YUD.get(lineid); | |
558 | var comment = new YAHOO.util.Element(tableTr('inline-comments',html)) |
|
558 | var comment = new YAHOO.util.Element(tableTr('inline-comments',html)) | |
559 |
|
559 | |||
560 | // check if there are comments already ! |
|
560 | // check if there are comments already ! | |
561 | var parent = target_line.parentNode; |
|
561 | var parent = target_line.parentNode; | |
562 | var root_parent = parent; |
|
562 | var root_parent = parent; | |
563 | while (1){ |
|
563 | while (1){ | |
564 | var n = parent.nextElementSibling; |
|
564 | var n = parent.nextElementSibling; | |
565 | // next element are comments ! |
|
565 | // next element are comments ! | |
566 | if(YUD.hasClass(n,'inline-comments')){ |
|
566 | if(YUD.hasClass(n,'inline-comments')){ | |
567 | parent = n; |
|
567 | parent = n; | |
568 | } |
|
568 | } | |
569 | else{ |
|
569 | else{ | |
570 | break; |
|
570 | break; | |
571 | } |
|
571 | } | |
572 | } |
|
572 | } | |
573 | // put in the comment at the bottom |
|
573 | // put in the comment at the bottom | |
574 | YUD.insertAfter(comment,parent); |
|
574 | YUD.insertAfter(comment,parent); | |
575 |
|
575 | |||
576 | // scann nodes, and attach add button to last one |
|
576 | // scann nodes, and attach add button to last one | |
577 | placeAddButton(root_parent); |
|
577 | placeAddButton(root_parent); | |
578 |
|
578 | |||
579 | return target_line; |
|
579 | return target_line; | |
580 | } |
|
580 | } | |
581 |
|
581 | |||
582 | /** |
|
582 | /** | |
583 | * make a single inline comment and place it inside |
|
583 | * make a single inline comment and place it inside | |
584 | */ |
|
584 | */ | |
585 | var renderInlineComment = function(json_data){ |
|
585 | var renderInlineComment = function(json_data){ | |
586 | try{ |
|
586 | try{ | |
587 | var html = json_data['rendered_text']; |
|
587 | var html = json_data['rendered_text']; | |
588 | var lineno = json_data['line_no']; |
|
588 | var lineno = json_data['line_no']; | |
589 | var target_id = json_data['target_id']; |
|
589 | var target_id = json_data['target_id']; | |
590 | placeInline(target_id, lineno, html); |
|
590 | placeInline(target_id, lineno, html); | |
591 |
|
591 | |||
592 | }catch(e){ |
|
592 | }catch(e){ | |
593 | console.log(e); |
|
593 | console.log(e); | |
594 | } |
|
594 | } | |
595 | } |
|
595 | } | |
596 |
|
596 | |||
597 | /** |
|
597 | /** | |
598 | * Iterates over all the inlines, and places them inside proper blocks of data |
|
598 | * Iterates over all the inlines, and places them inside proper blocks of data | |
599 | */ |
|
599 | */ | |
600 | var renderInlineComments = function(file_comments){ |
|
600 | var renderInlineComments = function(file_comments){ | |
601 | for (f in file_comments){ |
|
601 | for (f in file_comments){ | |
602 | // holding all comments for a FILE |
|
602 | // holding all comments for a FILE | |
603 | var box = file_comments[f]; |
|
603 | var box = file_comments[f]; | |
604 |
|
604 | |||
605 | var target_id = YUD.getAttribute(box,'target_id'); |
|
605 | var target_id = YUD.getAttribute(box,'target_id'); | |
606 | // actually comments with line numbers |
|
606 | // actually comments with line numbers | |
607 | var comments = box.children; |
|
607 | var comments = box.children; | |
608 | for(var i=0; i<comments.length; i++){ |
|
608 | for(var i=0; i<comments.length; i++){ | |
609 | var data = { |
|
609 | var data = { | |
610 | 'rendered_text': comments[i].outerHTML, |
|
610 | 'rendered_text': comments[i].outerHTML, | |
611 | 'line_no': YUD.getAttribute(comments[i],'line'), |
|
611 | 'line_no': YUD.getAttribute(comments[i],'line'), | |
612 | 'target_id': target_id |
|
612 | 'target_id': target_id | |
613 | } |
|
613 | } | |
614 | renderInlineComment(data); |
|
614 | renderInlineComment(data); | |
615 | } |
|
615 | } | |
616 | } |
|
616 | } | |
617 | } |
|
617 | } | |
618 |
|
618 | |||
619 |
|
619 | |||
620 | var fileBrowserListeners = function(current_url, node_list_url, url_base){ |
|
620 | var fileBrowserListeners = function(current_url, node_list_url, url_base){ | |
621 |
|
621 | |||
622 | var current_url_branch = +"?branch=__BRANCH__"; |
|
622 | var current_url_branch = +"?branch=__BRANCH__"; | |
623 | var url = url_base; |
|
623 | var url = url_base; | |
624 | var node_url = node_list_url; |
|
624 | var node_url = node_list_url; | |
625 |
|
625 | |||
626 | YUE.on('stay_at_branch','click',function(e){ |
|
626 | YUE.on('stay_at_branch','click',function(e){ | |
627 | if(e.target.checked){ |
|
627 | if(e.target.checked){ | |
628 | var uri = current_url_branch; |
|
628 | var uri = current_url_branch; | |
629 | uri = uri.replace('__BRANCH__',e.target.value); |
|
629 | uri = uri.replace('__BRANCH__',e.target.value); | |
630 | window.location = uri; |
|
630 | window.location = uri; | |
631 | } |
|
631 | } | |
632 | else{ |
|
632 | else{ | |
633 | window.location = current_url; |
|
633 | window.location = current_url; | |
634 | } |
|
634 | } | |
635 | }) |
|
635 | }) | |
636 |
|
636 | |||
637 | var n_filter = YUD.get('node_filter'); |
|
637 | var n_filter = YUD.get('node_filter'); | |
638 | var F = YAHOO.namespace('node_filter'); |
|
638 | var F = YAHOO.namespace('node_filter'); | |
639 |
|
639 | |||
640 | F.filterTimeout = null; |
|
640 | F.filterTimeout = null; | |
641 | var nodes = null; |
|
641 | var nodes = null; | |
642 |
|
642 | |||
643 | F.initFilter = function(){ |
|
643 | F.initFilter = function(){ | |
644 | YUD.setStyle('node_filter_box_loading','display',''); |
|
644 | YUD.setStyle('node_filter_box_loading','display',''); | |
645 | YUD.setStyle('search_activate_id','display','none'); |
|
645 | YUD.setStyle('search_activate_id','display','none'); | |
646 | YUD.setStyle('add_node_id','display','none'); |
|
646 | YUD.setStyle('add_node_id','display','none'); | |
647 | YUC.initHeader('X-PARTIAL-XHR',true); |
|
647 | YUC.initHeader('X-PARTIAL-XHR',true); | |
648 | YUC.asyncRequest('GET',url,{ |
|
648 | YUC.asyncRequest('GET',url,{ | |
649 | success:function(o){ |
|
649 | success:function(o){ | |
650 | nodes = JSON.parse(o.responseText).nodes; |
|
650 | nodes = JSON.parse(o.responseText).nodes; | |
651 | YUD.setStyle('node_filter_box_loading','display','none'); |
|
651 | YUD.setStyle('node_filter_box_loading','display','none'); | |
652 | YUD.setStyle('node_filter_box','display',''); |
|
652 | YUD.setStyle('node_filter_box','display',''); | |
653 | n_filter.focus(); |
|
653 | n_filter.focus(); | |
654 | if(YUD.hasClass(n_filter,'init')){ |
|
654 | if(YUD.hasClass(n_filter,'init')){ | |
655 | n_filter.value = ''; |
|
655 | n_filter.value = ''; | |
656 | YUD.removeClass(n_filter,'init'); |
|
656 | YUD.removeClass(n_filter,'init'); | |
657 | } |
|
657 | } | |
658 | }, |
|
658 | }, | |
659 | failure:function(o){ |
|
659 | failure:function(o){ | |
660 | console.log('failed to load'); |
|
660 | console.log('failed to load'); | |
661 | } |
|
661 | } | |
662 | },null); |
|
662 | },null); | |
663 | } |
|
663 | } | |
664 |
|
664 | |||
665 | F.updateFilter = function(e) { |
|
665 | F.updateFilter = function(e) { | |
666 |
|
666 | |||
667 | return function(){ |
|
667 | return function(){ | |
668 | // Reset timeout |
|
668 | // Reset timeout | |
669 | F.filterTimeout = null; |
|
669 | F.filterTimeout = null; | |
670 | var query = e.target.value.toLowerCase(); |
|
670 | var query = e.target.value.toLowerCase(); | |
671 | var match = []; |
|
671 | var match = []; | |
672 | var matches = 0; |
|
672 | var matches = 0; | |
673 | var matches_max = 20; |
|
673 | var matches_max = 20; | |
674 | if (query != ""){ |
|
674 | if (query != ""){ | |
675 | for(var i=0;i<nodes.length;i++){ |
|
675 | for(var i=0;i<nodes.length;i++){ | |
676 |
|
676 | |||
677 | var pos = nodes[i].name.toLowerCase().indexOf(query) |
|
677 | var pos = nodes[i].name.toLowerCase().indexOf(query) | |
678 | if(query && pos != -1){ |
|
678 | if(query && pos != -1){ | |
679 |
|
679 | |||
680 | matches++ |
|
680 | matches++ | |
681 | //show only certain amount to not kill browser |
|
681 | //show only certain amount to not kill browser | |
682 | if (matches > matches_max){ |
|
682 | if (matches > matches_max){ | |
683 | break; |
|
683 | break; | |
684 | } |
|
684 | } | |
685 |
|
685 | |||
686 | var n = nodes[i].name; |
|
686 | var n = nodes[i].name; | |
687 | var t = nodes[i].type; |
|
687 | var t = nodes[i].type; | |
688 | var n_hl = n.substring(0,pos) |
|
688 | var n_hl = n.substring(0,pos) | |
689 | +"<b>{0}</b>".format(n.substring(pos,pos+query.length)) |
|
689 | +"<b>{0}</b>".format(n.substring(pos,pos+query.length)) | |
690 | +n.substring(pos+query.length) |
|
690 | +n.substring(pos+query.length) | |
691 | match.push('<tr><td><a class="browser-{0}" href="{1}">{2}</a></td><td colspan="5"></td></tr>'.format(t,node_url.replace('__FPATH__',n),n_hl)); |
|
691 | match.push('<tr><td><a class="browser-{0}" href="{1}">{2}</a></td><td colspan="5"></td></tr>'.format(t,node_url.replace('__FPATH__',n),n_hl)); | |
692 | } |
|
692 | } | |
693 | if(match.length >= matches_max){ |
|
693 | if(match.length >= matches_max){ | |
694 | match.push('<tr><td>{0}</td><td colspan="5"></td></tr>'.format(_TM['search truncated'])); |
|
694 | match.push('<tr><td>{0}</td><td colspan="5"></td></tr>'.format(_TM['search truncated'])); | |
695 | } |
|
695 | } | |
696 | } |
|
696 | } | |
697 | } |
|
697 | } | |
698 | if(query != ""){ |
|
698 | if(query != ""){ | |
699 | YUD.setStyle('tbody','display','none'); |
|
699 | YUD.setStyle('tbody','display','none'); | |
700 | YUD.setStyle('tbody_filtered','display',''); |
|
700 | YUD.setStyle('tbody_filtered','display',''); | |
701 |
|
701 | |||
702 | if (match.length==0){ |
|
702 | if (match.length==0){ | |
703 | match.push('<tr><td>{0}</td><td colspan="5"></td></tr>'.format(_TM['no matching files'])); |
|
703 | match.push('<tr><td>{0}</td><td colspan="5"></td></tr>'.format(_TM['no matching files'])); | |
704 | } |
|
704 | } | |
705 |
|
705 | |||
706 | YUD.get('tbody_filtered').innerHTML = match.join(""); |
|
706 | YUD.get('tbody_filtered').innerHTML = match.join(""); | |
707 | } |
|
707 | } | |
708 | else{ |
|
708 | else{ | |
709 | YUD.setStyle('tbody','display',''); |
|
709 | YUD.setStyle('tbody','display',''); | |
710 | YUD.setStyle('tbody_filtered','display','none'); |
|
710 | YUD.setStyle('tbody_filtered','display','none'); | |
711 | } |
|
711 | } | |
712 |
|
712 | |||
713 | } |
|
713 | } | |
714 | }; |
|
714 | }; | |
715 |
|
715 | |||
716 | YUE.on(YUD.get('filter_activate'),'click',function(){ |
|
716 | YUE.on(YUD.get('filter_activate'),'click',function(){ | |
717 | F.initFilter(); |
|
717 | F.initFilter(); | |
718 | }) |
|
718 | }) | |
719 | YUE.on(n_filter,'click',function(){ |
|
719 | YUE.on(n_filter,'click',function(){ | |
720 | if(YUD.hasClass(n_filter,'init')){ |
|
720 | if(YUD.hasClass(n_filter,'init')){ | |
721 | n_filter.value = ''; |
|
721 | n_filter.value = ''; | |
722 | YUD.removeClass(n_filter,'init'); |
|
722 | YUD.removeClass(n_filter,'init'); | |
723 | } |
|
723 | } | |
724 | }); |
|
724 | }); | |
725 | YUE.on(n_filter,'keyup',function(e){ |
|
725 | YUE.on(n_filter,'keyup',function(e){ | |
726 | clearTimeout(F.filterTimeout); |
|
726 | clearTimeout(F.filterTimeout); | |
727 | F.filterTimeout = setTimeout(F.updateFilter(e),600); |
|
727 | F.filterTimeout = setTimeout(F.updateFilter(e),600); | |
728 | }); |
|
728 | }); | |
729 | }; |
|
729 | }; | |
730 |
|
730 | |||
731 |
|
731 | |||
732 | var initCodeMirror = function(textAreadId,resetUrl){ |
|
732 | var initCodeMirror = function(textAreadId,resetUrl){ | |
733 | var myCodeMirror = CodeMirror.fromTextArea(YUD.get(textAreadId),{ |
|
733 | var myCodeMirror = CodeMirror.fromTextArea(YUD.get(textAreadId),{ | |
734 | mode: "null", |
|
734 | mode: "null", | |
735 | lineNumbers:true |
|
735 | lineNumbers:true | |
736 | }); |
|
736 | }); | |
737 | YUE.on('reset','click',function(e){ |
|
737 | YUE.on('reset','click',function(e){ | |
738 | window.location=resetUrl |
|
738 | window.location=resetUrl | |
739 | }); |
|
739 | }); | |
740 |
|
740 | |||
741 | YUE.on('file_enable','click',function(){ |
|
741 | YUE.on('file_enable','click',function(){ | |
742 | YUD.setStyle('editor_container','display',''); |
|
742 | YUD.setStyle('editor_container','display',''); | |
743 | YUD.setStyle('upload_file_container','display','none'); |
|
743 | YUD.setStyle('upload_file_container','display','none'); | |
744 | YUD.setStyle('filename_container','display',''); |
|
744 | YUD.setStyle('filename_container','display',''); | |
745 | }); |
|
745 | }); | |
746 |
|
746 | |||
747 | YUE.on('upload_file_enable','click',function(){ |
|
747 | YUE.on('upload_file_enable','click',function(){ | |
748 | YUD.setStyle('editor_container','display','none'); |
|
748 | YUD.setStyle('editor_container','display','none'); | |
749 | YUD.setStyle('upload_file_container','display',''); |
|
749 | YUD.setStyle('upload_file_container','display',''); | |
750 | YUD.setStyle('filename_container','display','none'); |
|
750 | YUD.setStyle('filename_container','display','none'); | |
751 | }); |
|
751 | }); | |
752 | }; |
|
752 | }; | |
753 |
|
753 | |||
754 |
|
754 | |||
755 |
|
755 | |||
756 | var getIdentNode = function(n){ |
|
756 | var getIdentNode = function(n){ | |
757 | //iterate thru nodes untill matched interesting node ! |
|
757 | //iterate thru nodes untill matched interesting node ! | |
758 |
|
758 | |||
759 | if (typeof n == 'undefined'){ |
|
759 | if (typeof n == 'undefined'){ | |
760 | return -1 |
|
760 | return -1 | |
761 | } |
|
761 | } | |
762 |
|
762 | |||
763 | if(typeof n.id != "undefined" && n.id.match('L[0-9]+')){ |
|
763 | if(typeof n.id != "undefined" && n.id.match('L[0-9]+')){ | |
764 | return n |
|
764 | return n | |
765 | } |
|
765 | } | |
766 | else{ |
|
766 | else{ | |
767 | return getIdentNode(n.parentNode); |
|
767 | return getIdentNode(n.parentNode); | |
768 | } |
|
768 | } | |
769 | }; |
|
769 | }; | |
770 |
|
770 | |||
771 | var getSelectionLink = function(selection_link_label) { |
|
771 | var getSelectionLink = function(selection_link_label) { | |
772 | return function(){ |
|
772 | return function(){ | |
773 | //get selection from start/to nodes |
|
773 | //get selection from start/to nodes | |
774 | if (typeof window.getSelection != "undefined") { |
|
774 | if (typeof window.getSelection != "undefined") { | |
775 | s = window.getSelection(); |
|
775 | s = window.getSelection(); | |
776 |
|
776 | |||
777 | from = getIdentNode(s.anchorNode); |
|
777 | from = getIdentNode(s.anchorNode); | |
778 | till = getIdentNode(s.focusNode); |
|
778 | till = getIdentNode(s.focusNode); | |
779 |
|
779 | |||
780 | f_int = parseInt(from.id.replace('L','')); |
|
780 | f_int = parseInt(from.id.replace('L','')); | |
781 | t_int = parseInt(till.id.replace('L','')); |
|
781 | t_int = parseInt(till.id.replace('L','')); | |
782 |
|
782 | |||
783 | if (f_int > t_int){ |
|
783 | if (f_int > t_int){ | |
784 | //highlight from bottom |
|
784 | //highlight from bottom | |
785 | offset = -35; |
|
785 | offset = -35; | |
786 | ranges = [t_int,f_int]; |
|
786 | ranges = [t_int,f_int]; | |
787 |
|
787 | |||
788 | } |
|
788 | } | |
789 | else{ |
|
789 | else{ | |
790 | //highligth from top |
|
790 | //highligth from top | |
791 | offset = 35; |
|
791 | offset = 35; | |
792 | ranges = [f_int,t_int]; |
|
792 | ranges = [f_int,t_int]; | |
793 | } |
|
793 | } | |
794 |
|
794 | |||
795 | if (ranges[0] != ranges[1]){ |
|
795 | if (ranges[0] != ranges[1]){ | |
796 | if(YUD.get('linktt') == null){ |
|
796 | if(YUD.get('linktt') == null){ | |
797 | hl_div = document.createElement('div'); |
|
797 | hl_div = document.createElement('div'); | |
798 | hl_div.id = 'linktt'; |
|
798 | hl_div.id = 'linktt'; | |
799 | } |
|
799 | } | |
800 | anchor = '#L'+ranges[0]+'-'+ranges[1]; |
|
800 | anchor = '#L'+ranges[0]+'-'+ranges[1]; | |
801 | hl_div.innerHTML = ''; |
|
801 | hl_div.innerHTML = ''; | |
802 | l = document.createElement('a'); |
|
802 | l = document.createElement('a'); | |
803 | l.href = location.href.substring(0,location.href.indexOf('#'))+anchor; |
|
803 | l.href = location.href.substring(0,location.href.indexOf('#'))+anchor; | |
804 | l.innerHTML = selection_link_label; |
|
804 | l.innerHTML = selection_link_label; | |
805 | hl_div.appendChild(l); |
|
805 | hl_div.appendChild(l); | |
806 |
|
806 | |||
807 | YUD.get('body').appendChild(hl_div); |
|
807 | YUD.get('body').appendChild(hl_div); | |
808 |
|
808 | |||
809 | xy = YUD.getXY(till.id); |
|
809 | xy = YUD.getXY(till.id); | |
810 |
|
810 | |||
811 | YUD.addClass('linktt','yui-tt'); |
|
811 | YUD.addClass('linktt','yui-tt'); | |
812 | YUD.setStyle('linktt','top',xy[1]+offset+'px'); |
|
812 | YUD.setStyle('linktt','top',xy[1]+offset+'px'); | |
813 | YUD.setStyle('linktt','left',xy[0]+'px'); |
|
813 | YUD.setStyle('linktt','left',xy[0]+'px'); | |
814 | YUD.setStyle('linktt','visibility','visible'); |
|
814 | YUD.setStyle('linktt','visibility','visible'); | |
815 | } |
|
815 | } | |
816 | else{ |
|
816 | else{ | |
817 | YUD.setStyle('linktt','visibility','hidden'); |
|
817 | YUD.setStyle('linktt','visibility','hidden'); | |
818 | } |
|
818 | } | |
819 | } |
|
819 | } | |
820 | } |
|
820 | } | |
821 | }; |
|
821 | }; | |
822 |
|
822 | |||
823 | var deleteNotification = function(url, notification_id,callbacks){ |
|
823 | var deleteNotification = function(url, notification_id,callbacks){ | |
824 | var callback = { |
|
824 | var callback = { | |
825 | success:function(o){ |
|
825 | success:function(o){ | |
826 | var obj = YUD.get(String("notification_"+notification_id)); |
|
826 | var obj = YUD.get(String("notification_"+notification_id)); | |
827 | if(obj.parentNode !== undefined){ |
|
827 | if(obj.parentNode !== undefined){ | |
828 | obj.parentNode.removeChild(obj); |
|
828 | obj.parentNode.removeChild(obj); | |
829 | } |
|
829 | } | |
830 | _run_callbacks(callbacks); |
|
830 | _run_callbacks(callbacks); | |
831 | }, |
|
831 | }, | |
832 | failure:function(o){ |
|
832 | failure:function(o){ | |
833 | alert("error"); |
|
833 | alert("error"); | |
834 | }, |
|
834 | }, | |
835 | }; |
|
835 | }; | |
836 | var postData = '_method=delete'; |
|
836 | var postData = '_method=delete'; | |
837 | var sUrl = url.replace('__NOTIFICATION_ID__',notification_id); |
|
837 | var sUrl = url.replace('__NOTIFICATION_ID__',notification_id); | |
838 | var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, |
|
838 | var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, | |
839 | callback, postData); |
|
839 | callback, postData); | |
840 | }; |
|
840 | }; | |
841 |
|
841 | |||
842 | var readNotification = function(url, notification_id,callbacks){ |
|
842 | var readNotification = function(url, notification_id,callbacks){ | |
843 | var callback = { |
|
843 | var callback = { | |
844 | success:function(o){ |
|
844 | success:function(o){ | |
845 | var obj = YUD.get(String("notification_"+notification_id)); |
|
845 | var obj = YUD.get(String("notification_"+notification_id)); | |
846 | YUD.removeClass(obj, 'unread'); |
|
846 | YUD.removeClass(obj, 'unread'); | |
847 | var r_button = obj.children[0].getElementsByClassName('read-notification')[0] |
|
847 | var r_button = obj.children[0].getElementsByClassName('read-notification')[0] | |
848 |
|
848 | |||
849 | if(r_button.parentNode !== undefined){ |
|
849 | if(r_button.parentNode !== undefined){ | |
850 | r_button.parentNode.removeChild(r_button); |
|
850 | r_button.parentNode.removeChild(r_button); | |
851 | } |
|
851 | } | |
852 | _run_callbacks(callbacks); |
|
852 | _run_callbacks(callbacks); | |
853 | }, |
|
853 | }, | |
854 | failure:function(o){ |
|
854 | failure:function(o){ | |
855 | alert("error"); |
|
855 | alert("error"); | |
856 | }, |
|
856 | }, | |
857 | }; |
|
857 | }; | |
858 | var postData = '_method=put'; |
|
858 | var postData = '_method=put'; | |
859 | var sUrl = url.replace('__NOTIFICATION_ID__',notification_id); |
|
859 | var sUrl = url.replace('__NOTIFICATION_ID__',notification_id); | |
860 | var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, |
|
860 | var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, | |
861 | callback, postData); |
|
861 | callback, postData); | |
862 | }; |
|
862 | }; | |
863 |
|
863 | |||
864 | /** MEMBERS AUTOCOMPLETE WIDGET **/ |
|
864 | /** MEMBERS AUTOCOMPLETE WIDGET **/ | |
865 |
|
865 | |||
866 | var MembersAutoComplete = function (users_list, groups_list) { |
|
866 | var MembersAutoComplete = function (users_list, groups_list) { | |
867 | var myUsers = users_list; |
|
867 | var myUsers = users_list; | |
868 | var myGroups = groups_list; |
|
868 | var myGroups = groups_list; | |
869 |
|
869 | |||
870 | // Define a custom search function for the DataSource of users |
|
870 | // Define a custom search function for the DataSource of users | |
871 | var matchUsers = function (sQuery) { |
|
871 | var matchUsers = function (sQuery) { | |
872 | // Case insensitive matching |
|
872 | // Case insensitive matching | |
873 | var query = sQuery.toLowerCase(); |
|
873 | var query = sQuery.toLowerCase(); | |
874 | var i = 0; |
|
874 | var i = 0; | |
875 | var l = myUsers.length; |
|
875 | var l = myUsers.length; | |
876 | var matches = []; |
|
876 | var matches = []; | |
877 |
|
877 | |||
878 | // Match against each name of each contact |
|
878 | // Match against each name of each contact | |
879 | for (; i < l; i++) { |
|
879 | for (; i < l; i++) { | |
880 | contact = myUsers[i]; |
|
880 | contact = myUsers[i]; | |
881 | if (((contact.fname+"").toLowerCase().indexOf(query) > -1) || |
|
881 | if (((contact.fname+"").toLowerCase().indexOf(query) > -1) || | |
882 | ((contact.lname+"").toLowerCase().indexOf(query) > -1) || |
|
882 | ((contact.lname+"").toLowerCase().indexOf(query) > -1) || | |
883 | ((contact.nname) && ((contact.nname).toLowerCase().indexOf(query) > -1))) { |
|
883 | ((contact.nname) && ((contact.nname).toLowerCase().indexOf(query) > -1))) { | |
884 | matches[matches.length] = contact; |
|
884 | matches[matches.length] = contact; | |
885 | } |
|
885 | } | |
886 | } |
|
886 | } | |
887 | return matches; |
|
887 | return matches; | |
888 | }; |
|
888 | }; | |
889 |
|
889 | |||
890 | // Define a custom search function for the DataSource of usersGroups |
|
890 | // Define a custom search function for the DataSource of usersGroups | |
891 | var matchGroups = function (sQuery) { |
|
891 | var matchGroups = function (sQuery) { | |
892 | // Case insensitive matching |
|
892 | // Case insensitive matching | |
893 | var query = sQuery.toLowerCase(); |
|
893 | var query = sQuery.toLowerCase(); | |
894 | var i = 0; |
|
894 | var i = 0; | |
895 | var l = myGroups.length; |
|
895 | var l = myGroups.length; | |
896 | var matches = []; |
|
896 | var matches = []; | |
897 |
|
897 | |||
898 | // Match against each name of each contact |
|
898 | // Match against each name of each contact | |
899 | for (; i < l; i++) { |
|
899 | for (; i < l; i++) { | |
900 | matched_group = myGroups[i]; |
|
900 | matched_group = myGroups[i]; | |
901 | if (matched_group.grname.toLowerCase().indexOf(query) > -1) { |
|
901 | if (matched_group.grname.toLowerCase().indexOf(query) > -1) { | |
902 | matches[matches.length] = matched_group; |
|
902 | matches[matches.length] = matched_group; | |
903 | } |
|
903 | } | |
904 | } |
|
904 | } | |
905 | return matches; |
|
905 | return matches; | |
906 | }; |
|
906 | }; | |
907 |
|
907 | |||
908 | //match all |
|
908 | //match all | |
909 | var matchAll = function (sQuery) { |
|
909 | var matchAll = function (sQuery) { | |
910 | u = matchUsers(sQuery); |
|
910 | u = matchUsers(sQuery); | |
911 | g = matchGroups(sQuery); |
|
911 | g = matchGroups(sQuery); | |
912 | return u.concat(g); |
|
912 | return u.concat(g); | |
913 | }; |
|
913 | }; | |
914 |
|
914 | |||
915 | // DataScheme for members |
|
915 | // DataScheme for members | |
916 | var memberDS = new YAHOO.util.FunctionDataSource(matchAll); |
|
916 | var memberDS = new YAHOO.util.FunctionDataSource(matchAll); | |
917 | memberDS.responseSchema = { |
|
917 | memberDS.responseSchema = { | |
918 | fields: ["id", "fname", "lname", "nname", "grname", "grmembers", "gravatar_lnk"] |
|
918 | fields: ["id", "fname", "lname", "nname", "grname", "grmembers", "gravatar_lnk"] | |
919 | }; |
|
919 | }; | |
920 |
|
920 | |||
921 | // DataScheme for owner |
|
921 | // DataScheme for owner | |
922 | var ownerDS = new YAHOO.util.FunctionDataSource(matchUsers); |
|
922 | var ownerDS = new YAHOO.util.FunctionDataSource(matchUsers); | |
923 | ownerDS.responseSchema = { |
|
923 | ownerDS.responseSchema = { | |
924 | fields: ["id", "fname", "lname", "nname", "gravatar_lnk"] |
|
924 | fields: ["id", "fname", "lname", "nname", "gravatar_lnk"] | |
925 | }; |
|
925 | }; | |
926 |
|
926 | |||
927 | // Instantiate AutoComplete for perms |
|
927 | // Instantiate AutoComplete for perms | |
928 | var membersAC = new YAHOO.widget.AutoComplete("perm_new_member_name", "perm_container", memberDS); |
|
928 | var membersAC = new YAHOO.widget.AutoComplete("perm_new_member_name", "perm_container", memberDS); | |
929 | membersAC.useShadow = false; |
|
929 | membersAC.useShadow = false; | |
930 | membersAC.resultTypeList = false; |
|
930 | membersAC.resultTypeList = false; | |
|
931 | membersAC.animVert = false; | |||
|
932 | membersAC.animHoriz = false; | |||
|
933 | membersAC.animSpeed = 0.1; | |||
931 |
|
934 | |||
932 | // Instantiate AutoComplete for owner |
|
935 | // Instantiate AutoComplete for owner | |
933 | var ownerAC = new YAHOO.widget.AutoComplete("user", "owner_container", ownerDS); |
|
936 | var ownerAC = new YAHOO.widget.AutoComplete("user", "owner_container", ownerDS); | |
934 | ownerAC.useShadow = false; |
|
937 | ownerAC.useShadow = false; | |
935 | ownerAC.resultTypeList = false; |
|
938 | ownerAC.resultTypeList = false; | |
936 |
|
939 | ownerAC.animVert = false; | ||
|
940 | ownerAC.animHoriz = false; | |||
|
941 | ownerAC.animSpeed = 0.1; | |||
937 |
|
942 | |||
938 | // Helper highlight function for the formatter |
|
943 | // Helper highlight function for the formatter | |
939 | var highlightMatch = function (full, snippet, matchindex) { |
|
944 | var highlightMatch = function (full, snippet, matchindex) { | |
940 | return full.substring(0, matchindex) |
|
945 | return full.substring(0, matchindex) | |
941 | + "<span class='match'>" |
|
946 | + "<span class='match'>" | |
942 | + full.substr(matchindex, snippet.length) |
|
947 | + full.substr(matchindex, snippet.length) | |
943 | + "</span>" + full.substring(matchindex + snippet.length); |
|
948 | + "</span>" + full.substring(matchindex + snippet.length); | |
944 | }; |
|
949 | }; | |
945 |
|
950 | |||
946 | // Custom formatter to highlight the matching letters |
|
951 | // Custom formatter to highlight the matching letters | |
947 | var custom_formatter = function (oResultData, sQuery, sResultMatch) { |
|
952 | var custom_formatter = function (oResultData, sQuery, sResultMatch) { | |
948 | var query = sQuery.toLowerCase(); |
|
953 | var query = sQuery.toLowerCase(); | |
949 | var _gravatar = function(res, em, group){ |
|
954 | var _gravatar = function(res, em, group){ | |
950 | if (group !== undefined){ |
|
955 | if (group !== undefined){ | |
951 | em = '/images/icons/group.png' |
|
956 | em = '/images/icons/group.png' | |
952 | } |
|
957 | } | |
953 | tmpl = '<div class="ac-container-wrap"><img class="perm-gravatar-ac" src="{0}"/>{1}</div>' |
|
958 | tmpl = '<div class="ac-container-wrap"><img class="perm-gravatar-ac" src="{0}"/>{1}</div>' | |
954 | return tmpl.format(em,res) |
|
959 | return tmpl.format(em,res) | |
955 | } |
|
960 | } | |
956 | // group |
|
961 | // group | |
957 | if (oResultData.grname != undefined) { |
|
962 | if (oResultData.grname != undefined) { | |
958 | var grname = oResultData.grname; |
|
963 | var grname = oResultData.grname; | |
959 | var grmembers = oResultData.grmembers; |
|
964 | var grmembers = oResultData.grmembers; | |
960 | var grnameMatchIndex = grname.toLowerCase().indexOf(query); |
|
965 | var grnameMatchIndex = grname.toLowerCase().indexOf(query); | |
961 | var grprefix = "{0}: ".format(_TM['Group']); |
|
966 | var grprefix = "{0}: ".format(_TM['Group']); | |
962 | var grsuffix = " (" + grmembers + " )"; |
|
967 | var grsuffix = " (" + grmembers + " )"; | |
963 | var grsuffix = " ({0} {1})".format(grmembers, _TM['members']); |
|
968 | var grsuffix = " ({0} {1})".format(grmembers, _TM['members']); | |
964 |
|
969 | |||
965 | if (grnameMatchIndex > -1) { |
|
970 | if (grnameMatchIndex > -1) { | |
966 | return _gravatar(grprefix + highlightMatch(grname, query, grnameMatchIndex) + grsuffix,null,true); |
|
971 | return _gravatar(grprefix + highlightMatch(grname, query, grnameMatchIndex) + grsuffix,null,true); | |
967 | } |
|
972 | } | |
968 | return _gravatar(grprefix + oResultData.grname + grsuffix, null,true); |
|
973 | return _gravatar(grprefix + oResultData.grname + grsuffix, null,true); | |
969 | // Users |
|
974 | // Users | |
970 | } else if (oResultData.nname != undefined) { |
|
975 | } else if (oResultData.nname != undefined) { | |
971 | var fname = oResultData.fname || ""; |
|
976 | var fname = oResultData.fname || ""; | |
972 | var lname = oResultData.lname || ""; |
|
977 | var lname = oResultData.lname || ""; | |
973 | var nname = oResultData.nname; |
|
978 | var nname = oResultData.nname; | |
974 |
|
979 | |||
975 | // Guard against null value |
|
980 | // Guard against null value | |
976 | var fnameMatchIndex = fname.toLowerCase().indexOf(query), |
|
981 | var fnameMatchIndex = fname.toLowerCase().indexOf(query), | |
977 | lnameMatchIndex = lname.toLowerCase().indexOf(query), |
|
982 | lnameMatchIndex = lname.toLowerCase().indexOf(query), | |
978 | nnameMatchIndex = nname.toLowerCase().indexOf(query), |
|
983 | nnameMatchIndex = nname.toLowerCase().indexOf(query), | |
979 | displayfname, displaylname, displaynname; |
|
984 | displayfname, displaylname, displaynname; | |
980 |
|
985 | |||
981 | if (fnameMatchIndex > -1) { |
|
986 | if (fnameMatchIndex > -1) { | |
982 | displayfname = highlightMatch(fname, query, fnameMatchIndex); |
|
987 | displayfname = highlightMatch(fname, query, fnameMatchIndex); | |
983 | } else { |
|
988 | } else { | |
984 | displayfname = fname; |
|
989 | displayfname = fname; | |
985 | } |
|
990 | } | |
986 |
|
991 | |||
987 | if (lnameMatchIndex > -1) { |
|
992 | if (lnameMatchIndex > -1) { | |
988 | displaylname = highlightMatch(lname, query, lnameMatchIndex); |
|
993 | displaylname = highlightMatch(lname, query, lnameMatchIndex); | |
989 | } else { |
|
994 | } else { | |
990 | displaylname = lname; |
|
995 | displaylname = lname; | |
991 | } |
|
996 | } | |
992 |
|
997 | |||
993 | if (nnameMatchIndex > -1) { |
|
998 | if (nnameMatchIndex > -1) { | |
994 | displaynname = "(" + highlightMatch(nname, query, nnameMatchIndex) + ")"; |
|
999 | displaynname = "(" + highlightMatch(nname, query, nnameMatchIndex) + ")"; | |
995 | } else { |
|
1000 | } else { | |
996 | displaynname = nname ? "(" + nname + ")" : ""; |
|
1001 | displaynname = nname ? "(" + nname + ")" : ""; | |
997 | } |
|
1002 | } | |
998 |
|
1003 | |||
999 | return _gravatar(displayfname + " " + displaylname + " " + displaynname, oResultData.gravatar_lnk); |
|
1004 | return _gravatar(displayfname + " " + displaylname + " " + displaynname, oResultData.gravatar_lnk); | |
1000 | } else { |
|
1005 | } else { | |
1001 | return ''; |
|
1006 | return ''; | |
1002 | } |
|
1007 | } | |
1003 | }; |
|
1008 | }; | |
1004 | membersAC.formatResult = custom_formatter; |
|
1009 | membersAC.formatResult = custom_formatter; | |
1005 | ownerAC.formatResult = custom_formatter; |
|
1010 | ownerAC.formatResult = custom_formatter; | |
1006 |
|
1011 | |||
1007 | var myHandler = function (sType, aArgs) { |
|
1012 | var myHandler = function (sType, aArgs) { | |
1008 |
|
1013 | |||
1009 | var myAC = aArgs[0]; // reference back to the AC instance |
|
1014 | var myAC = aArgs[0]; // reference back to the AC instance | |
1010 | var elLI = aArgs[1]; // reference to the selected LI element |
|
1015 | var elLI = aArgs[1]; // reference to the selected LI element | |
1011 | var oData = aArgs[2]; // object literal of selected item's result data |
|
1016 | var oData = aArgs[2]; // object literal of selected item's result data | |
1012 | //fill the autocomplete with value |
|
1017 | //fill the autocomplete with value | |
1013 | if (oData.nname != undefined) { |
|
1018 | if (oData.nname != undefined) { | |
1014 | //users |
|
1019 | //users | |
1015 | myAC.getInputEl().value = oData.nname; |
|
1020 | myAC.getInputEl().value = oData.nname; | |
1016 | YUD.get('perm_new_member_type').value = 'user'; |
|
1021 | YUD.get('perm_new_member_type').value = 'user'; | |
1017 | } else { |
|
1022 | } else { | |
1018 | //groups |
|
1023 | //groups | |
1019 | myAC.getInputEl().value = oData.grname; |
|
1024 | myAC.getInputEl().value = oData.grname; | |
1020 | YUD.get('perm_new_member_type').value = 'users_group'; |
|
1025 | YUD.get('perm_new_member_type').value = 'users_group'; | |
1021 | } |
|
1026 | } | |
1022 | }; |
|
1027 | }; | |
1023 |
|
1028 | |||
1024 | membersAC.itemSelectEvent.subscribe(myHandler); |
|
1029 | membersAC.itemSelectEvent.subscribe(myHandler); | |
1025 | if(ownerAC.itemSelectEvent){ |
|
1030 | if(ownerAC.itemSelectEvent){ | |
1026 | ownerAC.itemSelectEvent.subscribe(myHandler); |
|
1031 | ownerAC.itemSelectEvent.subscribe(myHandler); | |
1027 | } |
|
1032 | } | |
1028 |
|
1033 | |||
1029 | return { |
|
1034 | return { | |
1030 | memberDS: memberDS, |
|
1035 | memberDS: memberDS, | |
1031 | ownerDS: ownerDS, |
|
1036 | ownerDS: ownerDS, | |
1032 | membersAC: membersAC, |
|
1037 | membersAC: membersAC, | |
1033 | ownerAC: ownerAC, |
|
1038 | ownerAC: ownerAC, | |
1034 | }; |
|
1039 | }; | |
1035 | } |
|
1040 | } | |
1036 |
|
1041 | |||
1037 |
|
1042 | |||
1038 | var MentionsAutoComplete = function (divid, cont, users_list, groups_list) { |
|
1043 | var MentionsAutoComplete = function (divid, cont, users_list, groups_list) { | |
1039 | var myUsers = users_list; |
|
1044 | var myUsers = users_list; | |
1040 | var myGroups = groups_list; |
|
1045 | var myGroups = groups_list; | |
1041 |
|
1046 | |||
1042 | // Define a custom search function for the DataSource of users |
|
1047 | // Define a custom search function for the DataSource of users | |
1043 | var matchUsers = function (sQuery) { |
|
1048 | var matchUsers = function (sQuery) { | |
1044 | var org_sQuery = sQuery; |
|
1049 | var org_sQuery = sQuery; | |
1045 | if(this.mentionQuery == null){ |
|
1050 | if(this.mentionQuery == null){ | |
1046 | return [] |
|
1051 | return [] | |
1047 | } |
|
1052 | } | |
1048 | sQuery = this.mentionQuery; |
|
1053 | sQuery = this.mentionQuery; | |
1049 | // Case insensitive matching |
|
1054 | // Case insensitive matching | |
1050 | var query = sQuery.toLowerCase(); |
|
1055 | var query = sQuery.toLowerCase(); | |
1051 | var i = 0; |
|
1056 | var i = 0; | |
1052 | var l = myUsers.length; |
|
1057 | var l = myUsers.length; | |
1053 | var matches = []; |
|
1058 | var matches = []; | |
1054 |
|
1059 | |||
1055 | // Match against each name of each contact |
|
1060 | // Match against each name of each contact | |
1056 | for (; i < l; i++) { |
|
1061 | for (; i < l; i++) { | |
1057 | contact = myUsers[i]; |
|
1062 | contact = myUsers[i]; | |
1058 | if (((contact.fname+"").toLowerCase().indexOf(query) > -1) || |
|
1063 | if (((contact.fname+"").toLowerCase().indexOf(query) > -1) || | |
1059 | ((contact.lname+"").toLowerCase().indexOf(query) > -1) || |
|
1064 | ((contact.lname+"").toLowerCase().indexOf(query) > -1) || | |
1060 | ((contact.nname) && ((contact.nname).toLowerCase().indexOf(query) > -1))) { |
|
1065 | ((contact.nname) && ((contact.nname).toLowerCase().indexOf(query) > -1))) { | |
1061 | matches[matches.length] = contact; |
|
1066 | matches[matches.length] = contact; | |
1062 | } |
|
1067 | } | |
1063 | } |
|
1068 | } | |
1064 | return matches |
|
1069 | return matches | |
1065 | }; |
|
1070 | }; | |
1066 |
|
1071 | |||
1067 | //match all |
|
1072 | //match all | |
1068 | var matchAll = function (sQuery) { |
|
1073 | var matchAll = function (sQuery) { | |
1069 | u = matchUsers(sQuery); |
|
1074 | u = matchUsers(sQuery); | |
1070 | return u |
|
1075 | return u | |
1071 | }; |
|
1076 | }; | |
1072 |
|
1077 | |||
1073 | // DataScheme for owner |
|
1078 | // DataScheme for owner | |
1074 | var ownerDS = new YAHOO.util.FunctionDataSource(matchUsers); |
|
1079 | var ownerDS = new YAHOO.util.FunctionDataSource(matchUsers); | |
1075 |
|
1080 | |||
1076 | ownerDS.responseSchema = { |
|
1081 | ownerDS.responseSchema = { | |
1077 | fields: ["id", "fname", "lname", "nname", "gravatar_lnk"] |
|
1082 | fields: ["id", "fname", "lname", "nname", "gravatar_lnk"] | |
1078 | }; |
|
1083 | }; | |
1079 |
|
1084 | |||
1080 | // Instantiate AutoComplete for mentions |
|
1085 | // Instantiate AutoComplete for mentions | |
1081 | var ownerAC = new YAHOO.widget.AutoComplete(divid, cont, ownerDS); |
|
1086 | var ownerAC = new YAHOO.widget.AutoComplete(divid, cont, ownerDS); | |
1082 | ownerAC.useShadow = false; |
|
1087 | ownerAC.useShadow = false; | |
1083 | ownerAC.resultTypeList = false; |
|
1088 | ownerAC.resultTypeList = false; | |
1084 | ownerAC.suppressInputUpdate = true; |
|
1089 | ownerAC.suppressInputUpdate = true; | |
1085 |
|
1090 | ownerAC.animVert = false; | ||
|
1091 | ownerAC.animHoriz = false; | |||
|
1092 | ownerAC.animSpeed = 0.1; | |||
|
1093 | ||||
1086 | // Helper highlight function for the formatter |
|
1094 | // Helper highlight function for the formatter | |
1087 | var highlightMatch = function (full, snippet, matchindex) { |
|
1095 | var highlightMatch = function (full, snippet, matchindex) { | |
1088 | return full.substring(0, matchindex) |
|
1096 | return full.substring(0, matchindex) | |
1089 | + "<span class='match'>" |
|
1097 | + "<span class='match'>" | |
1090 | + full.substr(matchindex, snippet.length) |
|
1098 | + full.substr(matchindex, snippet.length) | |
1091 | + "</span>" + full.substring(matchindex + snippet.length); |
|
1099 | + "</span>" + full.substring(matchindex + snippet.length); | |
1092 | }; |
|
1100 | }; | |
1093 |
|
1101 | |||
1094 | // Custom formatter to highlight the matching letters |
|
1102 | // Custom formatter to highlight the matching letters | |
1095 | ownerAC.formatResult = function (oResultData, sQuery, sResultMatch) { |
|
1103 | ownerAC.formatResult = function (oResultData, sQuery, sResultMatch) { | |
1096 | var org_sQuery = sQuery; |
|
1104 | var org_sQuery = sQuery; | |
1097 | if(this.dataSource.mentionQuery != null){ |
|
1105 | if(this.dataSource.mentionQuery != null){ | |
1098 | sQuery = this.dataSource.mentionQuery; |
|
1106 | sQuery = this.dataSource.mentionQuery; | |
1099 | } |
|
1107 | } | |
1100 |
|
1108 | |||
1101 | var query = sQuery.toLowerCase(); |
|
1109 | var query = sQuery.toLowerCase(); | |
1102 | var _gravatar = function(res, em, group){ |
|
1110 | var _gravatar = function(res, em, group){ | |
1103 | if (group !== undefined){ |
|
1111 | if (group !== undefined){ | |
1104 | em = '/images/icons/group.png' |
|
1112 | em = '/images/icons/group.png' | |
1105 | } |
|
1113 | } | |
1106 | tmpl = '<div class="ac-container-wrap"><img class="perm-gravatar-ac" src="{0}"/>{1}</div>' |
|
1114 | tmpl = '<div class="ac-container-wrap"><img class="perm-gravatar-ac" src="{0}"/>{1}</div>' | |
1107 | return tmpl.format(em,res) |
|
1115 | return tmpl.format(em,res) | |
1108 | } |
|
1116 | } | |
1109 | if (oResultData.nname != undefined) { |
|
1117 | if (oResultData.nname != undefined) { | |
1110 | var fname = oResultData.fname || ""; |
|
1118 | var fname = oResultData.fname || ""; | |
1111 | var lname = oResultData.lname || ""; |
|
1119 | var lname = oResultData.lname || ""; | |
1112 | var nname = oResultData.nname; |
|
1120 | var nname = oResultData.nname; | |
1113 |
|
1121 | |||
1114 | // Guard against null value |
|
1122 | // Guard against null value | |
1115 | var fnameMatchIndex = fname.toLowerCase().indexOf(query), |
|
1123 | var fnameMatchIndex = fname.toLowerCase().indexOf(query), | |
1116 | lnameMatchIndex = lname.toLowerCase().indexOf(query), |
|
1124 | lnameMatchIndex = lname.toLowerCase().indexOf(query), | |
1117 | nnameMatchIndex = nname.toLowerCase().indexOf(query), |
|
1125 | nnameMatchIndex = nname.toLowerCase().indexOf(query), | |
1118 | displayfname, displaylname, displaynname; |
|
1126 | displayfname, displaylname, displaynname; | |
1119 |
|
1127 | |||
1120 | if (fnameMatchIndex > -1) { |
|
1128 | if (fnameMatchIndex > -1) { | |
1121 | displayfname = highlightMatch(fname, query, fnameMatchIndex); |
|
1129 | displayfname = highlightMatch(fname, query, fnameMatchIndex); | |
1122 | } else { |
|
1130 | } else { | |
1123 | displayfname = fname; |
|
1131 | displayfname = fname; | |
1124 | } |
|
1132 | } | |
1125 |
|
1133 | |||
1126 | if (lnameMatchIndex > -1) { |
|
1134 | if (lnameMatchIndex > -1) { | |
1127 | displaylname = highlightMatch(lname, query, lnameMatchIndex); |
|
1135 | displaylname = highlightMatch(lname, query, lnameMatchIndex); | |
1128 | } else { |
|
1136 | } else { | |
1129 | displaylname = lname; |
|
1137 | displaylname = lname; | |
1130 | } |
|
1138 | } | |
1131 |
|
1139 | |||
1132 | if (nnameMatchIndex > -1) { |
|
1140 | if (nnameMatchIndex > -1) { | |
1133 | displaynname = "(" + highlightMatch(nname, query, nnameMatchIndex) + ")"; |
|
1141 | displaynname = "(" + highlightMatch(nname, query, nnameMatchIndex) + ")"; | |
1134 | } else { |
|
1142 | } else { | |
1135 | displaynname = nname ? "(" + nname + ")" : ""; |
|
1143 | displaynname = nname ? "(" + nname + ")" : ""; | |
1136 | } |
|
1144 | } | |
1137 |
|
1145 | |||
1138 | return _gravatar(displayfname + " " + displaylname + " " + displaynname, oResultData.gravatar_lnk); |
|
1146 | return _gravatar(displayfname + " " + displaylname + " " + displaynname, oResultData.gravatar_lnk); | |
1139 | } else { |
|
1147 | } else { | |
1140 | return ''; |
|
1148 | return ''; | |
1141 | } |
|
1149 | } | |
1142 | }; |
|
1150 | }; | |
1143 |
|
1151 | |||
1144 | if(ownerAC.itemSelectEvent){ |
|
1152 | if(ownerAC.itemSelectEvent){ | |
1145 | ownerAC.itemSelectEvent.subscribe(function (sType, aArgs) { |
|
1153 | ownerAC.itemSelectEvent.subscribe(function (sType, aArgs) { | |
1146 |
|
1154 | |||
1147 | var myAC = aArgs[0]; // reference back to the AC instance |
|
1155 | var myAC = aArgs[0]; // reference back to the AC instance | |
1148 | var elLI = aArgs[1]; // reference to the selected LI element |
|
1156 | var elLI = aArgs[1]; // reference to the selected LI element | |
1149 | var oData = aArgs[2]; // object literal of selected item's result data |
|
1157 | var oData = aArgs[2]; // object literal of selected item's result data | |
1150 | //fill the autocomplete with value |
|
1158 | //fill the autocomplete with value | |
1151 | if (oData.nname != undefined) { |
|
1159 | if (oData.nname != undefined) { | |
1152 | //users |
|
1160 | //users | |
1153 | //Replace the mention name with replaced |
|
1161 | //Replace the mention name with replaced | |
1154 | var re = new RegExp(); |
|
1162 | var re = new RegExp(); | |
1155 | var org = myAC.getInputEl().value; |
|
1163 | var org = myAC.getInputEl().value; | |
1156 | var chunks = myAC.dataSource.chunks |
|
1164 | var chunks = myAC.dataSource.chunks | |
1157 | // replace middle chunk(the search term) with actuall match |
|
1165 | // replace middle chunk(the search term) with actuall match | |
1158 | chunks[1] = chunks[1].replace('@'+myAC.dataSource.mentionQuery, |
|
1166 | chunks[1] = chunks[1].replace('@'+myAC.dataSource.mentionQuery, | |
1159 | '@'+oData.nname+' '); |
|
1167 | '@'+oData.nname+' '); | |
1160 | myAC.getInputEl().value = chunks.join('') |
|
1168 | myAC.getInputEl().value = chunks.join('') | |
1161 | YUD.get(myAC.getInputEl()).focus(); // Y U NO WORK !? |
|
1169 | YUD.get(myAC.getInputEl()).focus(); // Y U NO WORK !? | |
1162 | } else { |
|
1170 | } else { | |
1163 | //groups |
|
1171 | //groups | |
1164 | myAC.getInputEl().value = oData.grname; |
|
1172 | myAC.getInputEl().value = oData.grname; | |
1165 | YUD.get('perm_new_member_type').value = 'users_group'; |
|
1173 | YUD.get('perm_new_member_type').value = 'users_group'; | |
1166 | } |
|
1174 | } | |
1167 | }); |
|
1175 | }); | |
1168 | } |
|
1176 | } | |
1169 |
|
1177 | |||
1170 | // in this keybuffer we will gather current value of search ! |
|
1178 | // in this keybuffer we will gather current value of search ! | |
1171 | // since we need to get this just when someone does `@` then we do the |
|
1179 | // since we need to get this just when someone does `@` then we do the | |
1172 | // search |
|
1180 | // search | |
1173 | ownerAC.dataSource.chunks = []; |
|
1181 | ownerAC.dataSource.chunks = []; | |
1174 | ownerAC.dataSource.mentionQuery = null; |
|
1182 | ownerAC.dataSource.mentionQuery = null; | |
1175 |
|
1183 | |||
1176 | ownerAC.get_mention = function(msg, max_pos) { |
|
1184 | ownerAC.get_mention = function(msg, max_pos) { | |
1177 | var org = msg; |
|
1185 | var org = msg; | |
1178 | var re = new RegExp('(?:^@|\s@)([a-zA-Z0-9]{1}[a-zA-Z0-9\-\_\.]+)$') |
|
1186 | var re = new RegExp('(?:^@|\s@)([a-zA-Z0-9]{1}[a-zA-Z0-9\-\_\.]+)$') | |
1179 | var chunks = []; |
|
1187 | var chunks = []; | |
1180 |
|
1188 | |||
1181 |
|
1189 | |||
1182 | // cut first chunk until curret pos |
|
1190 | // cut first chunk until curret pos | |
1183 | var to_max = msg.substr(0, max_pos); |
|
1191 | var to_max = msg.substr(0, max_pos); | |
1184 | var at_pos = Math.max(0,to_max.lastIndexOf('@')-1); |
|
1192 | var at_pos = Math.max(0,to_max.lastIndexOf('@')-1); | |
1185 | var msg2 = to_max.substr(at_pos); |
|
1193 | var msg2 = to_max.substr(at_pos); | |
1186 |
|
1194 | |||
1187 | chunks.push(org.substr(0,at_pos))// prefix chunk |
|
1195 | chunks.push(org.substr(0,at_pos))// prefix chunk | |
1188 | chunks.push(msg2) // search chunk |
|
1196 | chunks.push(msg2) // search chunk | |
1189 | chunks.push(org.substr(max_pos)) // postfix chunk |
|
1197 | chunks.push(org.substr(max_pos)) // postfix chunk | |
1190 |
|
1198 | |||
1191 | // clean up msg2 for filtering and regex match |
|
1199 | // clean up msg2 for filtering and regex match | |
1192 | var msg2 = msg2.lstrip(' ').lstrip('\n'); |
|
1200 | var msg2 = msg2.lstrip(' ').lstrip('\n'); | |
1193 |
|
1201 | |||
1194 | if(re.test(msg2)){ |
|
1202 | if(re.test(msg2)){ | |
1195 | var unam = re.exec(msg2)[1]; |
|
1203 | var unam = re.exec(msg2)[1]; | |
1196 | return [unam, chunks]; |
|
1204 | return [unam, chunks]; | |
1197 | } |
|
1205 | } | |
1198 | return [null, null]; |
|
1206 | return [null, null]; | |
1199 | }; |
|
1207 | }; | |
1200 | ownerAC.textboxKeyUpEvent.subscribe(function(type, args){ |
|
1208 | ownerAC.textboxKeyUpEvent.subscribe(function(type, args){ | |
1201 |
|
1209 | |||
1202 | var ac_obj = args[0]; |
|
1210 | var ac_obj = args[0]; | |
1203 | var currentMessage = args[1]; |
|
1211 | var currentMessage = args[1]; | |
1204 | var currentCaretPosition = args[0]._elTextbox.selectionStart; |
|
1212 | var currentCaretPosition = args[0]._elTextbox.selectionStart; | |
1205 |
|
1213 | |||
1206 | var unam = ownerAC.get_mention(currentMessage, currentCaretPosition); |
|
1214 | var unam = ownerAC.get_mention(currentMessage, currentCaretPosition); | |
1207 | var curr_search = null; |
|
1215 | var curr_search = null; | |
1208 | if(unam[0]){ |
|
1216 | if(unam[0]){ | |
1209 | curr_search = unam[0]; |
|
1217 | curr_search = unam[0]; | |
1210 | } |
|
1218 | } | |
1211 |
|
1219 | |||
1212 | ownerAC.dataSource.chunks = unam[1]; |
|
1220 | ownerAC.dataSource.chunks = unam[1]; | |
1213 | ownerAC.dataSource.mentionQuery = curr_search; |
|
1221 | ownerAC.dataSource.mentionQuery = curr_search; | |
1214 |
|
1222 | |||
1215 | }) |
|
1223 | }) | |
1216 |
|
1224 | |||
1217 | return { |
|
1225 | return { | |
1218 | ownerDS: ownerDS, |
|
1226 | ownerDS: ownerDS, | |
1219 | ownerAC: ownerAC, |
|
1227 | ownerAC: ownerAC, | |
1220 | }; |
|
1228 | }; | |
1221 | } |
|
1229 | } | |
1222 |
|
1230 | |||
1223 |
|
1231 | |||
1224 | /** |
|
1232 | /** | |
1225 | * QUICK REPO MENU |
|
1233 | * QUICK REPO MENU | |
1226 | */ |
|
1234 | */ | |
1227 | var quick_repo_menu = function(){ |
|
1235 | var quick_repo_menu = function(){ | |
1228 | YUE.on(YUQ('.quick_repo_menu'),'mouseenter',function(e){ |
|
1236 | YUE.on(YUQ('.quick_repo_menu'),'mouseenter',function(e){ | |
1229 | var menu = e.currentTarget.firstElementChild.firstElementChild; |
|
1237 | var menu = e.currentTarget.firstElementChild.firstElementChild; | |
1230 | if(YUD.hasClass(menu,'hidden')){ |
|
1238 | if(YUD.hasClass(menu,'hidden')){ | |
1231 | YUD.replaceClass(e.currentTarget,'hidden', 'active'); |
|
1239 | YUD.replaceClass(e.currentTarget,'hidden', 'active'); | |
1232 | YUD.replaceClass(menu, 'hidden', 'active'); |
|
1240 | YUD.replaceClass(menu, 'hidden', 'active'); | |
1233 | } |
|
1241 | } | |
1234 | }) |
|
1242 | }) | |
1235 | YUE.on(YUQ('.quick_repo_menu'),'mouseleave',function(e){ |
|
1243 | YUE.on(YUQ('.quick_repo_menu'),'mouseleave',function(e){ | |
1236 | var menu = e.currentTarget.firstElementChild.firstElementChild; |
|
1244 | var menu = e.currentTarget.firstElementChild.firstElementChild; | |
1237 | if(YUD.hasClass(menu,'active')){ |
|
1245 | if(YUD.hasClass(menu,'active')){ | |
1238 | YUD.replaceClass(e.currentTarget, 'active', 'hidden'); |
|
1246 | YUD.replaceClass(e.currentTarget, 'active', 'hidden'); | |
1239 | YUD.replaceClass(menu, 'active', 'hidden'); |
|
1247 | YUD.replaceClass(menu, 'active', 'hidden'); | |
1240 | } |
|
1248 | } | |
1241 | }) |
|
1249 | }) | |
1242 | }; |
|
1250 | }; | |
1243 |
|
1251 | |||
1244 |
|
1252 | |||
1245 | /** |
|
1253 | /** | |
1246 | * TABLE SORTING |
|
1254 | * TABLE SORTING | |
1247 | */ |
|
1255 | */ | |
1248 |
|
1256 | |||
1249 | // returns a node from given html; |
|
1257 | // returns a node from given html; | |
1250 | var fromHTML = function(html){ |
|
1258 | var fromHTML = function(html){ | |
1251 | var _html = document.createElement('element'); |
|
1259 | var _html = document.createElement('element'); | |
1252 | _html.innerHTML = html; |
|
1260 | _html.innerHTML = html; | |
1253 | return _html; |
|
1261 | return _html; | |
1254 | } |
|
1262 | } | |
1255 | var get_rev = function(node){ |
|
1263 | var get_rev = function(node){ | |
1256 | var n = node.firstElementChild.firstElementChild; |
|
1264 | var n = node.firstElementChild.firstElementChild; | |
1257 |
|
1265 | |||
1258 | if (n===null){ |
|
1266 | if (n===null){ | |
1259 | return -1 |
|
1267 | return -1 | |
1260 | } |
|
1268 | } | |
1261 | else{ |
|
1269 | else{ | |
1262 | out = n.firstElementChild.innerHTML.split(':')[0].replace('r',''); |
|
1270 | out = n.firstElementChild.innerHTML.split(':')[0].replace('r',''); | |
1263 | return parseInt(out); |
|
1271 | return parseInt(out); | |
1264 | } |
|
1272 | } | |
1265 | } |
|
1273 | } | |
1266 |
|
1274 | |||
1267 | var get_name = function(node){ |
|
1275 | var get_name = function(node){ | |
1268 | var name = node.firstElementChild.children[2].innerHTML; |
|
1276 | var name = node.firstElementChild.children[2].innerHTML; | |
1269 | return name |
|
1277 | return name | |
1270 | } |
|
1278 | } | |
1271 | var get_group_name = function(node){ |
|
1279 | var get_group_name = function(node){ | |
1272 | var name = node.firstElementChild.children[1].innerHTML; |
|
1280 | var name = node.firstElementChild.children[1].innerHTML; | |
1273 | return name |
|
1281 | return name | |
1274 | } |
|
1282 | } | |
1275 | var get_date = function(node){ |
|
1283 | var get_date = function(node){ | |
1276 | var date_ = YUD.getAttribute(node.firstElementChild,'date'); |
|
1284 | var date_ = YUD.getAttribute(node.firstElementChild,'date'); | |
1277 | return date_ |
|
1285 | return date_ | |
1278 | } |
|
1286 | } | |
1279 |
|
1287 | |||
1280 | var get_age = function(node){ |
|
1288 | var get_age = function(node){ | |
1281 | console.log(node); |
|
1289 | console.log(node); | |
1282 | return node |
|
1290 | return node | |
1283 | } |
|
1291 | } | |
1284 |
|
1292 | |||
1285 | var revisionSort = function(a, b, desc, field) { |
|
1293 | var revisionSort = function(a, b, desc, field) { | |
1286 |
|
1294 | |||
1287 | var a_ = fromHTML(a.getData(field)); |
|
1295 | var a_ = fromHTML(a.getData(field)); | |
1288 | var b_ = fromHTML(b.getData(field)); |
|
1296 | var b_ = fromHTML(b.getData(field)); | |
1289 |
|
1297 | |||
1290 | // extract revisions from string nodes |
|
1298 | // extract revisions from string nodes | |
1291 | a_ = get_rev(a_) |
|
1299 | a_ = get_rev(a_) | |
1292 | b_ = get_rev(b_) |
|
1300 | b_ = get_rev(b_) | |
1293 |
|
1301 | |||
1294 | var comp = YAHOO.util.Sort.compare; |
|
1302 | var comp = YAHOO.util.Sort.compare; | |
1295 | var compState = comp(a_, b_, desc); |
|
1303 | var compState = comp(a_, b_, desc); | |
1296 | return compState; |
|
1304 | return compState; | |
1297 | }; |
|
1305 | }; | |
1298 | var ageSort = function(a, b, desc, field) { |
|
1306 | var ageSort = function(a, b, desc, field) { | |
1299 | var a_ = fromHTML(a.getData(field)); |
|
1307 | var a_ = fromHTML(a.getData(field)); | |
1300 | var b_ = fromHTML(b.getData(field)); |
|
1308 | var b_ = fromHTML(b.getData(field)); | |
1301 |
|
1309 | |||
1302 | // extract name from table |
|
1310 | // extract name from table | |
1303 | a_ = get_date(a_) |
|
1311 | a_ = get_date(a_) | |
1304 | b_ = get_date(b_) |
|
1312 | b_ = get_date(b_) | |
1305 |
|
1313 | |||
1306 | var comp = YAHOO.util.Sort.compare; |
|
1314 | var comp = YAHOO.util.Sort.compare; | |
1307 | var compState = comp(a_, b_, desc); |
|
1315 | var compState = comp(a_, b_, desc); | |
1308 | return compState; |
|
1316 | return compState; | |
1309 | }; |
|
1317 | }; | |
1310 |
|
1318 | |||
1311 | var nameSort = function(a, b, desc, field) { |
|
1319 | var nameSort = function(a, b, desc, field) { | |
1312 | var a_ = fromHTML(a.getData(field)); |
|
1320 | var a_ = fromHTML(a.getData(field)); | |
1313 | var b_ = fromHTML(b.getData(field)); |
|
1321 | var b_ = fromHTML(b.getData(field)); | |
1314 |
|
1322 | |||
1315 | // extract name from table |
|
1323 | // extract name from table | |
1316 | a_ = get_name(a_) |
|
1324 | a_ = get_name(a_) | |
1317 | b_ = get_name(b_) |
|
1325 | b_ = get_name(b_) | |
1318 |
|
1326 | |||
1319 | var comp = YAHOO.util.Sort.compare; |
|
1327 | var comp = YAHOO.util.Sort.compare; | |
1320 | var compState = comp(a_, b_, desc); |
|
1328 | var compState = comp(a_, b_, desc); | |
1321 | return compState; |
|
1329 | return compState; | |
1322 | }; |
|
1330 | }; | |
1323 |
|
1331 | |||
1324 | var permNameSort = function(a, b, desc, field) { |
|
1332 | var permNameSort = function(a, b, desc, field) { | |
1325 | var a_ = fromHTML(a.getData(field)); |
|
1333 | var a_ = fromHTML(a.getData(field)); | |
1326 | var b_ = fromHTML(b.getData(field)); |
|
1334 | var b_ = fromHTML(b.getData(field)); | |
1327 | // extract name from table |
|
1335 | // extract name from table | |
1328 |
|
1336 | |||
1329 | a_ = a_.children[0].innerHTML; |
|
1337 | a_ = a_.children[0].innerHTML; | |
1330 | b_ = b_.children[0].innerHTML; |
|
1338 | b_ = b_.children[0].innerHTML; | |
1331 |
|
1339 | |||
1332 | var comp = YAHOO.util.Sort.compare; |
|
1340 | var comp = YAHOO.util.Sort.compare; | |
1333 | var compState = comp(a_, b_, desc); |
|
1341 | var compState = comp(a_, b_, desc); | |
1334 | return compState; |
|
1342 | return compState; | |
1335 | }; |
|
1343 | }; | |
1336 |
|
1344 | |||
1337 | var groupNameSort = function(a, b, desc, field) { |
|
1345 | var groupNameSort = function(a, b, desc, field) { | |
1338 | var a_ = fromHTML(a.getData(field)); |
|
1346 | var a_ = fromHTML(a.getData(field)); | |
1339 | var b_ = fromHTML(b.getData(field)); |
|
1347 | var b_ = fromHTML(b.getData(field)); | |
1340 |
|
1348 | |||
1341 | // extract name from table |
|
1349 | // extract name from table | |
1342 | a_ = get_group_name(a_) |
|
1350 | a_ = get_group_name(a_) | |
1343 | b_ = get_group_name(b_) |
|
1351 | b_ = get_group_name(b_) | |
1344 |
|
1352 | |||
1345 | var comp = YAHOO.util.Sort.compare; |
|
1353 | var comp = YAHOO.util.Sort.compare; | |
1346 | var compState = comp(a_, b_, desc); |
|
1354 | var compState = comp(a_, b_, desc); | |
1347 | return compState; |
|
1355 | return compState; | |
1348 | }; |
|
1356 | }; | |
1349 | var dateSort = function(a, b, desc, field) { |
|
1357 | var dateSort = function(a, b, desc, field) { | |
1350 | var a_ = fromHTML(a.getData(field)); |
|
1358 | var a_ = fromHTML(a.getData(field)); | |
1351 | var b_ = fromHTML(b.getData(field)); |
|
1359 | var b_ = fromHTML(b.getData(field)); | |
1352 |
|
1360 | |||
1353 | // extract name from table |
|
1361 | // extract name from table | |
1354 | a_ = get_date(a_) |
|
1362 | a_ = get_date(a_) | |
1355 | b_ = get_date(b_) |
|
1363 | b_ = get_date(b_) | |
1356 |
|
1364 | |||
1357 | var comp = YAHOO.util.Sort.compare; |
|
1365 | var comp = YAHOO.util.Sort.compare; | |
1358 | var compState = comp(a_, b_, desc); |
|
1366 | var compState = comp(a_, b_, desc); | |
1359 | return compState; |
|
1367 | return compState; | |
1360 | }; |
|
1368 | }; | |
1361 |
|
1369 | |||
1362 |
|
1370 | |||
1363 |
|
1371 | |||
1364 | /* Multi selectors */ |
|
1372 | /* Multi selectors */ | |
1365 |
|
1373 | |||
1366 | var MultiSelectWidget = function(selected_id, available_id, form_id){ |
|
1374 | var MultiSelectWidget = function(selected_id, available_id, form_id){ | |
1367 |
|
1375 | |||
1368 |
|
1376 | |||
1369 | //definition of containers ID's |
|
1377 | //definition of containers ID's | |
1370 | var selected_container = selected_id; |
|
1378 | var selected_container = selected_id; | |
1371 | var available_container = available_id; |
|
1379 | var available_container = available_id; | |
1372 |
|
1380 | |||
1373 | //temp container for selected storage. |
|
1381 | //temp container for selected storage. | |
1374 | var cache = new Array(); |
|
1382 | var cache = new Array(); | |
1375 | var av_cache = new Array(); |
|
1383 | var av_cache = new Array(); | |
1376 | var c = YUD.get(selected_container); |
|
1384 | var c = YUD.get(selected_container); | |
1377 | var ac = YUD.get(available_container); |
|
1385 | var ac = YUD.get(available_container); | |
1378 |
|
1386 | |||
1379 | //get only selected options for further fullfilment |
|
1387 | //get only selected options for further fullfilment | |
1380 | for(var i = 0;node =c.options[i];i++){ |
|
1388 | for(var i = 0;node =c.options[i];i++){ | |
1381 | if(node.selected){ |
|
1389 | if(node.selected){ | |
1382 | //push selected to my temp storage left overs :) |
|
1390 | //push selected to my temp storage left overs :) | |
1383 | cache.push(node); |
|
1391 | cache.push(node); | |
1384 | } |
|
1392 | } | |
1385 | } |
|
1393 | } | |
1386 |
|
1394 | |||
1387 | //get all available options to cache |
|
1395 | //get all available options to cache | |
1388 | for(var i = 0;node =ac.options[i];i++){ |
|
1396 | for(var i = 0;node =ac.options[i];i++){ | |
1389 | //push selected to my temp storage left overs :) |
|
1397 | //push selected to my temp storage left overs :) | |
1390 | av_cache.push(node); |
|
1398 | av_cache.push(node); | |
1391 | } |
|
1399 | } | |
1392 |
|
1400 | |||
1393 | //fill available only with those not in choosen |
|
1401 | //fill available only with those not in choosen | |
1394 | ac.options.length=0; |
|
1402 | ac.options.length=0; | |
1395 | tmp_cache = new Array(); |
|
1403 | tmp_cache = new Array(); | |
1396 |
|
1404 | |||
1397 | for(var i = 0;node = av_cache[i];i++){ |
|
1405 | for(var i = 0;node = av_cache[i];i++){ | |
1398 | var add = true; |
|
1406 | var add = true; | |
1399 | for(var i2 = 0;node_2 = cache[i2];i2++){ |
|
1407 | for(var i2 = 0;node_2 = cache[i2];i2++){ | |
1400 | if(node.value == node_2.value){ |
|
1408 | if(node.value == node_2.value){ | |
1401 | add=false; |
|
1409 | add=false; | |
1402 | break; |
|
1410 | break; | |
1403 | } |
|
1411 | } | |
1404 | } |
|
1412 | } | |
1405 | if(add){ |
|
1413 | if(add){ | |
1406 | tmp_cache.push(new Option(node.text, node.value, false, false)); |
|
1414 | tmp_cache.push(new Option(node.text, node.value, false, false)); | |
1407 | } |
|
1415 | } | |
1408 | } |
|
1416 | } | |
1409 |
|
1417 | |||
1410 | for(var i = 0;node = tmp_cache[i];i++){ |
|
1418 | for(var i = 0;node = tmp_cache[i];i++){ | |
1411 | ac.options[i] = node; |
|
1419 | ac.options[i] = node; | |
1412 | } |
|
1420 | } | |
1413 |
|
1421 | |||
1414 | function prompts_action_callback(e){ |
|
1422 | function prompts_action_callback(e){ | |
1415 |
|
1423 | |||
1416 | var choosen = YUD.get(selected_container); |
|
1424 | var choosen = YUD.get(selected_container); | |
1417 | var available = YUD.get(available_container); |
|
1425 | var available = YUD.get(available_container); | |
1418 |
|
1426 | |||
1419 | //get checked and unchecked options from field |
|
1427 | //get checked and unchecked options from field | |
1420 | function get_checked(from_field){ |
|
1428 | function get_checked(from_field){ | |
1421 | //temp container for storage. |
|
1429 | //temp container for storage. | |
1422 | var sel_cache = new Array(); |
|
1430 | var sel_cache = new Array(); | |
1423 | var oth_cache = new Array(); |
|
1431 | var oth_cache = new Array(); | |
1424 |
|
1432 | |||
1425 | for(var i = 0;node = from_field.options[i];i++){ |
|
1433 | for(var i = 0;node = from_field.options[i];i++){ | |
1426 | if(node.selected){ |
|
1434 | if(node.selected){ | |
1427 | //push selected fields :) |
|
1435 | //push selected fields :) | |
1428 | sel_cache.push(node); |
|
1436 | sel_cache.push(node); | |
1429 | } |
|
1437 | } | |
1430 | else{ |
|
1438 | else{ | |
1431 | oth_cache.push(node) |
|
1439 | oth_cache.push(node) | |
1432 | } |
|
1440 | } | |
1433 | } |
|
1441 | } | |
1434 |
|
1442 | |||
1435 | return [sel_cache,oth_cache] |
|
1443 | return [sel_cache,oth_cache] | |
1436 | } |
|
1444 | } | |
1437 |
|
1445 | |||
1438 | //fill the field with given options |
|
1446 | //fill the field with given options | |
1439 | function fill_with(field,options){ |
|
1447 | function fill_with(field,options){ | |
1440 | //clear firtst |
|
1448 | //clear firtst | |
1441 | field.options.length=0; |
|
1449 | field.options.length=0; | |
1442 | for(var i = 0;node = options[i];i++){ |
|
1450 | for(var i = 0;node = options[i];i++){ | |
1443 | field.options[i]=new Option(node.text, node.value, |
|
1451 | field.options[i]=new Option(node.text, node.value, | |
1444 | false, false); |
|
1452 | false, false); | |
1445 | } |
|
1453 | } | |
1446 |
|
1454 | |||
1447 | } |
|
1455 | } | |
1448 | //adds to current field |
|
1456 | //adds to current field | |
1449 | function add_to(field,options){ |
|
1457 | function add_to(field,options){ | |
1450 | for(var i = 0;node = options[i];i++){ |
|
1458 | for(var i = 0;node = options[i];i++){ | |
1451 | field.appendChild(new Option(node.text, node.value, |
|
1459 | field.appendChild(new Option(node.text, node.value, | |
1452 | false, false)); |
|
1460 | false, false)); | |
1453 | } |
|
1461 | } | |
1454 | } |
|
1462 | } | |
1455 |
|
1463 | |||
1456 | // add action |
|
1464 | // add action | |
1457 | if (this.id=='add_element'){ |
|
1465 | if (this.id=='add_element'){ | |
1458 | var c = get_checked(available); |
|
1466 | var c = get_checked(available); | |
1459 | add_to(choosen,c[0]); |
|
1467 | add_to(choosen,c[0]); | |
1460 | fill_with(available,c[1]); |
|
1468 | fill_with(available,c[1]); | |
1461 | } |
|
1469 | } | |
1462 | // remove action |
|
1470 | // remove action | |
1463 | if (this.id=='remove_element'){ |
|
1471 | if (this.id=='remove_element'){ | |
1464 | var c = get_checked(choosen); |
|
1472 | var c = get_checked(choosen); | |
1465 | add_to(available,c[0]); |
|
1473 | add_to(available,c[0]); | |
1466 | fill_with(choosen,c[1]); |
|
1474 | fill_with(choosen,c[1]); | |
1467 | } |
|
1475 | } | |
1468 | // add all elements |
|
1476 | // add all elements | |
1469 | if(this.id=='add_all_elements'){ |
|
1477 | if(this.id=='add_all_elements'){ | |
1470 | for(var i=0; node = available.options[i];i++){ |
|
1478 | for(var i=0; node = available.options[i];i++){ | |
1471 | choosen.appendChild(new Option(node.text, |
|
1479 | choosen.appendChild(new Option(node.text, | |
1472 | node.value, false, false)); |
|
1480 | node.value, false, false)); | |
1473 | } |
|
1481 | } | |
1474 | available.options.length = 0; |
|
1482 | available.options.length = 0; | |
1475 | } |
|
1483 | } | |
1476 | //remove all elements |
|
1484 | //remove all elements | |
1477 | if(this.id=='remove_all_elements'){ |
|
1485 | if(this.id=='remove_all_elements'){ | |
1478 | for(var i=0; node = choosen.options[i];i++){ |
|
1486 | for(var i=0; node = choosen.options[i];i++){ | |
1479 | available.appendChild(new Option(node.text, |
|
1487 | available.appendChild(new Option(node.text, | |
1480 | node.value, false, false)); |
|
1488 | node.value, false, false)); | |
1481 | } |
|
1489 | } | |
1482 | choosen.options.length = 0; |
|
1490 | choosen.options.length = 0; | |
1483 | } |
|
1491 | } | |
1484 |
|
1492 | |||
1485 | } |
|
1493 | } | |
1486 |
|
1494 | |||
1487 | YUE.addListener(['add_element','remove_element', |
|
1495 | YUE.addListener(['add_element','remove_element', | |
1488 | 'add_all_elements','remove_all_elements'],'click', |
|
1496 | 'add_all_elements','remove_all_elements'],'click', | |
1489 | prompts_action_callback) |
|
1497 | prompts_action_callback) | |
1490 | if (form_id !== undefined) { |
|
1498 | if (form_id !== undefined) { | |
1491 | YUE.addListener(form_id,'submit',function(){ |
|
1499 | YUE.addListener(form_id,'submit',function(){ | |
1492 | var choosen = YUD.get(selected_container); |
|
1500 | var choosen = YUD.get(selected_container); | |
1493 | for (var i = 0; i < choosen.options.length; i++) { |
|
1501 | for (var i = 0; i < choosen.options.length; i++) { | |
1494 | choosen.options[i].selected = 'selected'; |
|
1502 | choosen.options[i].selected = 'selected'; | |
1495 | } |
|
1503 | } | |
1496 | }); |
|
1504 | }); | |
1497 | } |
|
1505 | } | |
1498 | } No newline at end of file |
|
1506 | } |
General Comments 0
You need to be logged in to leave comments.
Login now