application.js
1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
function noosfero_init() {
focus_first_field();
}
/* If applicable, find the first field in which the user can type and move the
* keyboard focus to it.
*/
function focus_first_field() {
form = document.forms[0];
if (form == undefined) {
return;
}
for (var i = 0; i < form.elements.length; i++) {
field = form.elements[i];
if (field.type == 'text' || field.type == 'textarea') {
try {
field.focus();
return;
} catch(e) { }
}
}
}
/* * * Template Box Size Help * * */
function resizePrincipalTemplateBox() {
var box1 = $$( "div.box-1" )[0];
var otherBoxSum = 0;
var i = 2;
var b = $$( "div.box-" + i++ )[0];
while ( b.nodeName ) {
otherBoxSum += b.clientWidth;
b = $$( "div.box-" + i++ )[0] || false;
}
box1.style.width = ( $("boxes").clientWidth - otherBoxSum ) +"px"
}
if ( window.addEventListener ) {
window.addEventListener( 'resize', resizePrincipalTemplateBox, false );
window.addEventListener( 'load', resizePrincipalTemplateBox, false );
}