1
Y = YUI().use("node", "io-base", "anim");
3
1
var global_timeout_id = null;
4
2
var global_search_request = null;
10
var search_box = Y.get('#q');
11
if (!Y.Lang.isNull(search_box))
4
window.addEvent('domready', function()
6
var search_box = $('q');
13
function get_suggestions() {
14
var query = search_box.get('value');
15
var url = global_path + 'search?query=' + query;
17
if (!Y.Lang.isNull(global_search_request))
19
global_search_request.abort();
11
if($('q').value == '')
13
$('search_terms').setStyle('display','none');
17
if (null != global_timeout_id)
19
clearTimeout(global_timeout_id);
21
global_timeout_id = setTimeout('$("q").fireEvent("search",$("q").value)',200);
25
search: function(query)
27
url = global_path + 'search?query=' + query;
29
if ($defined(global_search_request))
31
global_search_request.cancel();
33
global_search_request = new Request({'url':url,'method':'get','onComplete':cool_search});
34
global_search_request.send('');
35
var posicion = search_box.getPosition();
36
var size = search_box.getSize();
38
$('search_terms').setStyle('position','absolute');
39
$('search_terms').setStyle('left',posicion.x);
40
$('search_terms').setStyle('top',posicion.y + size.y);
41
$('search_terms').setStyle('display','block');
42
$('search_terms').set('html','Loading...');
44
new Request({'url':url,'method':'get','onComplete':cool_search}).send('');
21
global_search_request = Y.io(
24
on: {complete: cool_search},
29
var region = search_box.get('region');
30
var current_query = search_box.get('value');
32
Y.get('#search_terms').setStyle('display', 'block');
33
Y.get('#search_terms').setStyle('position', 'absolute');
34
Y.get('#search_terms').setStyle('left', region.left);
35
Y.get('#search_terms').setStyle('top', region.bottom);
36
Y.get('#search_terms').set('innerHTML','Loading...');
42
if(search_box.get('value') == '')
44
Y.get('#search_terms').setStyle('display', 'none');
48
if (null != global_timeout_id)
50
clearTimeout(global_timeout_id);
52
global_timeout_id = setTimeout(get_suggestions, 200);
58
function cool_search(tid, response, query)
51
function cool_search(response)
61
var region = q.get('region');
62
var current_query = q.get('value');
63
if (current_query == query)
65
Y.get('#search_terms').set('innerHTML', response.responseText);
66
Y.get('#search_terms').setStyle('display', 'block');
67
Y.get('#search_terms').setStyle('position', 'absolute');
68
Y.get('#search_terms').setStyle('left', region.left);
69
Y.get('#search_terms').setStyle('top', region.bottom);
53
var posicion = $('q').getPosition();
54
var size = $('q').getSize();
55
$('search_terms').set('html',response);
56
$('search_terms').setStyle('display','block');
57
$('search_terms').setStyle('position','absolute');
58
$('search_terms').setStyle('left',posicion.x);
59
$('search_terms').setStyle('top',posicion.y + size.y);
73
62
function hide_search()
75
setTimeout("Y.get('#search_terms').setStyle('display','none')", 300);
78
function Collapsable(config)
80
this.is_open = config.is_open;
81
this.open_node = config.open_node;
82
this.close_node = config.close_node;
83
this.expand_icon = config.expand_icon;
84
this.source = config.source;
85
this.loading = config.loading;
86
this.node_process = config.node_process;
87
this.container = null;
89
this._loading = false;
92
function get_height(node) {
93
node.setStyle('position', 'absolute');
94
node.setStyle('top', -1000000000);
95
node.setStyle('display', 'block');
96
var height = node.get('region').height;
97
node.setStyle('display', 'none');
98
node.setStyle('position', 'static');
99
node.setStyle('top', 'auto');
103
Collapsable.prototype._animate = function (callback)
105
if (this.anim) this.anim.stop();
107
this.anim = new Y.Anim(
109
node: this.container,
111
marginBottom: this.container.getStyle('marginBottom')
120
this.anim.on('end', this.animComplete, this, callback);
123
Collapsable.prototype._load_finished = function(tid, res, args)
125
var l = res.responseText.split('\n');
127
var newNode = Y.Node.create(l.join(''));
128
if (this.node_process)
129
this.node_process(newNode);
131
newNode.setStyle('display', 'none');
132
this.loading.ancestor().insertBefore(newNode, this.loading);
133
var delta = this.loading.get('region').height - get_height(newNode);
134
newNode.setStyle('display', 'block');
135
this.container.setStyle('marginBottom', parseFloat(this.container.getStyle('marginBottom')) + delta);
136
this.loading.ancestor().removeChild(this.loading);
137
this._animate(args[0]);
140
Collapsable.prototype._ensure_container = function(callback)
142
if (this.container == null) {
143
this.container = Y.Node.create('<div></div>');
144
if (this.closed_node) {
145
this.closed_node.ancestor().replaceChild(
146
this.container, this.closed_node);
147
this.container.appendChild(this.closed_node);
148
if (this.open_node) {
149
this.container.appendChild(this.open_node);
153
this.open_node.ancestor().replaceChild(
154
this.container, this.open_node);
155
this.container.appendChild(this.open_node);
157
var outer = Y.Node.create('<div style="overflow:hidden;"></div>');
158
this.container.ancestor().replaceChild(outer, this.container);
159
outer.appendChild(this.container);
163
/* What happens when you click open.
165
* 1. The arrow flips to the expanded position.
167
* 2. If necessary, the div which will be running the animation is
168
* created and the open/closed content stuffed into it (and has height
169
* set to the height of the closed content).
171
* 3. The open content is shown and the closed content is closed.
173
* 4. The animation to expose all of the open content is started.
175
* 5. If we have to do ajax to load content, start the request.
177
* 6. When the request completes, parse the content into a node, run
178
* the node_process callback over it and replace the spinner (assumed
179
* to be appropriately contained in the open node) with the new node.
181
* 7. If the animation showing the open content has not completed,
184
* 8. Start a new animation to show the rest of the new content.
187
Collapsable.prototype.open = function(callback)
189
this.expand_icon.set('src', expanded_icon_path);
191
this._ensure_container();
193
var open_height = get_height(this.open_node);
196
if (this.close_node) {
197
close_height = this.close_node.get('region').height;
203
this.container.setStyle('marginBottom', close_height - open_height);
204
if (this.close_node) {
205
this.close_node.setStyle('display', 'none');
207
this.open_node.setStyle('display', 'block');
209
this._animate(callback);
215
on: {complete: this._load_finished},
216
arguments: [callback],
224
Collapsable.prototype.animComplete = function(evt, callback)
227
if (this._loading) return;
228
if (callback) callback();
232
Collapsable.prototype.close = function()
234
this._ensure_container();
236
var open_height = this.open_node.get('region').height;
239
if (this.close_node) {
240
close_height = get_height(this.close_node);
246
var anim = new Y.Anim(
248
node: this.container,
253
marginBottom: close_height - open_height
257
anim.on("end", this.closeComplete, this);
261
Collapsable.prototype.closeComplete = function () {
262
this.open_node.setStyle('display', 'none');
263
if (this.close_node) {
264
this.close_node.setStyle('display', 'block');
266
this.container.setStyle('marginBottom', 0);
267
this.expand_icon.set('src', collapsed_icon_path);
268
this.is_open = false;
271
Collapsable.prototype.toggle = function()
64
hide_div = setTimeout("$('search_terms').setStyle('display','none')", 300);
66
var Colapsable = new Class({
67
initialize: function(item,expand_icon,open_content,close_content,is_open)
70
if ($defined(is_open))
72
this.is_open = is_open;
75
item.set('colapsable',this);
76
this.open_content = open_content;
77
this.close_content = close_content;
78
this.expand_icon = expand_icon;
80
var expander = new Fx.Slide(this.item, { duration: 200 } );
84
if ($defined(this.expand_icon))
86
this.expand_icon.set('src',this.expand_icon.title);
91
if ($defined(this.expand_icon))
93
this.expand_icon.set('src',this.expand_icon.alt);
100
this.item.setStyle('display', 'block');
101
var expander = this.item.get('slide');
103
if ($defined(this.open_content))
105
for (var i=0;i<this.open_content.length;++i)
107
this.open_content[i].setStyle('display','block');
111
if ($defined(this.close_content))
113
for (var i=0;i<this.close_content.length;++i)
115
this.close_content[i].setStyle('display','none');
119
if ($defined(this.expand_icon))
121
this.expand_icon.set('src',this.expand_icon.alt);
128
var expander = this.item.get('slide');
130
if ($defined(this.open_content))
132
for (var i=0;i<this.open_content.length;++i)
134
this.open_content[i].setStyle('display','none');
138
if ($defined(this.close_content))
140
for (var i=0;i<this.close_content.length;++i)
142
this.close_content[i].setStyle('display','block');
145
if ($defined(this.expand_icon))
147
this.expand_icon.set('src',this.expand_icon.title);
149
this.is_open = false;
171
window.addEvent('domready', function()
173
$$('.revision_log').each(function(item, i)
175
var item_slide = item.getElement('.revisioninfo');
176
var open_content = new Array();
177
var close_content = new Array();
178
open_content.push(item.getElement('.long_description'));
179
close_content.push(item.getElement('.short_description'));
180
var expand_icon = item.getElement('.expand_icon');
181
var colapsable = new Colapsable(item_slide,expand_icon,open_content,close_content);
183
item.getElement('.expand_revisioninfo').addEvent('click',function(){colapsable.toggle();});
184
item.colapsable = colapsable;
187
$$('.diffBox').each(function(item, i)
189
var item_slide = item.getNext('.diffinfo');
190
var expand_icon = item.getElement( '.expand_diff' );
191
var colapsable = new Colapsable(item_slide,expand_icon,null,null,true);
192
item.getElement( '.expand_diff' ).addEvent( 'click', function(){colapsable.toggle();});
193
item.colapsable=colapsable;
197
function toggle_expand_all(action)
199
$$('.revision_log').each(function(item, i)
201
var colapsable = item.colapsable;
202
if(action == 'close')
204
$('expand_all').setStyle('display','block');
205
$('collapse_all').setStyle('display','none');
208
else if(action == 'open')
210
$('expand_all').setStyle('display','none');
211
$('collapse_all').setStyle('display','block');
217
function toggle_expand_all_revisionview(action)
219
$$('.diffBox').each(function(item, i)
221
var colapsable = item.colapsable;
222
if(action == 'close')
224
$('expand_all').setStyle('display','block');
225
$('collapse_all').setStyle('display','none');
228
else if(action == 'open')
230
$('expand_all').setStyle('display','none');
231
$('collapse_all').setStyle('display','block');