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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
function layout() {
c = document.getElementById('contentcontainer');
l = document.getElementById('border-left');
r = document.getElementById('border-right');
// set the height
if (c.offsetHeight > l.offsetHeight) {
l.style.height = r.style.height = c.offsetHeight + 'px';
} else {
c.style.height = l.offsetHeight + 'px';
}
// correct the width
if (window.innerWidth <= 832) {
l.style.width = '14px';
}
if (window.innerWidth > 832) {
l.style.width = '7%';
}
}
/* add on to mootools provided by digitarold
* http://dev.digitarald.de/form.html
* adds the setValue() function to select lists */
/**
* Element - setValue / populate
*
* @version 1.0rc1
*
* @license MIT-style license
* @author Harald Kirschner <mail [at] digitarald.de>
* @copyright Author
*/
Element.extend({
setValue: function(val) {
switch(this.getTag()){
case 'select':
this.selectedIndex = -1;
if (!val) break;
if ($type(val) != 'array') val = [val];
$each(this.options, function(opt){
opt.selected = val.test($pick(opt.value, opt.text));
});
break;
case 'input':
if (['checkbox', 'radio'].test(this.type)) {
this.checked = ($type(val) == 'array') ? val.test(this.value) : (val == this.value);
break;
}
if (!['hidden', 'text', 'password'].test(this.type)) break;
case 'textarea': this.value = $type(val) ? val : '';
}
},
populate: function(obj) {
this.getFormElements().each(function(el){
el.setValue(obj[el.name] || null);
});
}
});
|