| 43 |
render_button($id, 'radio'); |
render_button($id, 'radio'); |
| 44 |
break; |
break; |
| 45 |
case 'radios': |
case 'radios': |
| 46 |
render_button($id, 'radios'); |
render_button($id, 'radios', $element); |
| 47 |
break; |
break; |
| 48 |
case 'select': |
case 'select': |
| 49 |
case 'weight': |
case 'weight': |
| 74 |
/* |
/* |
| 75 |
* Add the javascript/CSS needed to render the button |
* Add the javascript/CSS needed to render the button |
| 76 |
*/ |
*/ |
| 77 |
function render_button($id, $type = 'button') { |
function render_button($id, $type = 'button', $element = NULL) { |
| 78 |
if (!user_access('Access YUI button')) { |
if (!user_access('Access YUI button')) { |
| 79 |
return; |
return; |
| 80 |
} |
} |
| 100 |
var button = new YAHOO.widget.Button(menuID, { label : 'foobar', type : '$type'" . ($type == 'menu' ? ", menu : 'edit-$id'" : '') . " }); |
var button = new YAHOO.widget.Button(menuID, { label : 'foobar', type : '$type'" . ($type == 'menu' ? ", menu : 'edit-$id'" : '') . " }); |
| 101 |
});", "inline", "footer"); |
});", "inline", "footer"); |
| 102 |
} |
} |
| 103 |
else if ($type == 'radios' and $radios == NULL) { |
else if ($type == 'radios') { |
| 104 |
$radios = TRUE; |
if ($radios == NULL) { |
| 105 |
|
$radios = 0; |
| 106 |
|
drupal_add_js(" |
| 107 |
|
YAHOO.util.Event.onDOMReady(function() { |
| 108 |
|
buttons = []; |
| 109 |
|
var id = 0; |
| 110 |
|
var radioGroups = YAHOO.util.Dom.getElementsByClassName('form-radios'); |
| 111 |
|
for (var radioGroup in radioGroups) { |
| 112 |
|
var children = YAHOO.util.Dom.getChildren(radioGroups[radioGroup]); |
| 113 |
|
for (var radio in children) { |
| 114 |
|
YAHOO.util.Dom.setStyle(children[radio], 'display', 'none'); |
| 115 |
|
} |
| 116 |
|
var radioGroupID = 'form-radios-' + id++; |
| 117 |
|
radioGroups[radioGroup].setAttribute('id', radioGroupID); |
| 118 |
|
var button = new YAHOO.widget.ButtonGroup(radioGroupID); |
| 119 |
|
buttons[radioGroupID] = button; |
| 120 |
|
} |
| 121 |
|
});", "inline", "footer"); |
| 122 |
|
} |
| 123 |
|
$count = 0; |
| 124 |
|
foreach ($element['#options'] as $value => $label) { |
| 125 |
|
$labels .= "buttons['form-radios-' + $radios].getButton(" . $count++ . ").set('label', '$label');\n"; |
| 126 |
|
} |
| 127 |
|
$radios++; |
| 128 |
drupal_add_js(" |
drupal_add_js(" |
| 129 |
YAHOO.util.Event.onDOMReady(function() { |
YAHOO.util.Event.onDOMReady(function() { |
| 130 |
var radioGroups = YAHOO.util.Dom.getElementsByClassName('form-radios'); |
$labels; |
| 131 |
for (var radioGroup in radioGroups) { |
});", "inline", "footer"); |
| 132 |
var radioGroupID = YAHOO.util.Dom.generateId(radioGroups[radioGroup], 'form-radios-'); |
} |
| 133 |
var button = new YAHOO.widget.ButtonGroup(radioGroupID); |
else if ($type == 'checkbox') { |
| 134 |
} |
drupal_add_js(" |
| 135 |
|
YAHOO.util.Event.onContentReady('edit-$id', function() { |
| 136 |
|
var button = new YAHOO.widget.Button('edit-${id}', { label : YAHOO.util.Dom.get('edit-${id}').nextSibling.nodeValue, type : '$type' }); |
| 137 |
|
YAHOO.util.Dom.get('edit-${id}').nextSibling.nodeValue = null; |
| 138 |
});", "inline", "footer"); |
});", "inline", "footer"); |
| 139 |
} |
} |
| 140 |
else { |
else { |