| |
|
1 |
ad_library { |
| |
|
2 |
|
| |
|
3 |
Widgets for acs-lang. |
| |
|
4 |
|
| |
|
5 |
Currently just a special version of the select widget which adds a "lang" |
| |
|
6 |
attribute to each option, as required by accessibility standards. |
| |
|
7 |
|
| |
|
8 |
@author Don Baccus (dhogaza@pacifier.com) |
| |
|
9 |
@creation-date November 3, 2006 |
| |
|
10 |
@cvs-id $Id$ |
| |
|
11 |
} |
| |
|
12 |
|
| |
|
13 |
namespace eval template {} |
| |
|
14 |
namespace eval template::widget {} |
| |
|
15 |
|
| |
|
16 |
ad_proc -public template::widget::select_locales { element_reference tag_attributes } { |
| |
|
17 |
|
| |
|
18 |
upvar $element_reference element |
| |
|
19 |
|
| |
|
20 |
if { [info exists element(html)] } { |
| |
|
21 |
array set attributes $element(html) |
| |
|
22 |
} |
| |
|
23 |
|
| |
|
24 |
array set attributes $tag_attributes |
| |
|
25 |
|
| |
|
26 |
append output "<select name=\"$element(name)\" " |
| |
|
27 |
|
| |
|
28 |
foreach name [array names attributes] { |
| |
|
29 |
if { [string equal $attributes($name) {}] } { |
| |
|
30 |
append output " $name=\"$name\"" |
| |
|
31 |
} else { |
| |
|
32 |
append output " $name=\"$attributes($name)\"" |
| |
|
33 |
} |
| |
|
34 |
} |
| |
|
35 |
append output ">\n" |
| |
|
36 |
|
| |
|
37 |
foreach option $element(options) { |
| |
|
38 |
|
| |
|
39 |
set label [lindex $option 0] |
| |
|
40 |
set value [lindex $option 1] |
| |
|
41 |
|
| |
|
42 |
set value [template::util::quote_html $value] |
| |
|
43 |
append output " <option lang=\"[string range $value 0 1]\" value=\"$value\"" |
| |
|
44 |
if { [info exists values($value)] } { |
| |
|
45 |
append output " selected=\"selected\"" |
| |
|
46 |
} |
| |
|
47 |
|
| |
|
48 |
append output ">$label</option>\n" |
| |
|
49 |
} |
| |
|
50 |
append output "</select>" |
| |
|
51 |
|
| |
|
52 |
return $output |
| |
|
53 |
|
| |
|
54 |
} |