Index: trunk/phase3/skins/common/wikibits.js |
— | — | @@ -1303,19 +1303,29 @@ |
1304 | 1304 | } |
1305 | 1305 | |
1306 | 1306 | /** |
1307 | | - * Add a click event handler to an element |
| 1307 | + * Add an event handler to an element |
1308 | 1308 | * |
1309 | 1309 | * @param Element element Element to add handler to |
| 1310 | + * @param String attach Event to attach to |
1310 | 1311 | * @param callable handler Event handler callback |
1311 | 1312 | */ |
1312 | | -function addClickHandler( element, handler ) { |
| 1313 | +function addHandler( element, attach, handler ) { |
1313 | 1314 | if( window.addEventListener ) { |
1314 | | - element.addEventListener( 'click', handler, false ); |
| 1315 | + element.addEventListener( attach, handler, false ); |
1315 | 1316 | } else if( window.attachEvent ) { |
1316 | | - element.attachEvent( 'onclick', handler ); |
| 1317 | + element.attachEvent( 'on' + attach, handler ); |
1317 | 1318 | } |
1318 | 1319 | } |
1319 | 1320 | |
| 1321 | +/** |
| 1322 | + * Add a click event handler to an element |
| 1323 | + * |
| 1324 | + * @param Element element Element to add handler to |
| 1325 | + * @param callable handler Event handler callback |
| 1326 | + */ |
| 1327 | +function addClickHandler( element, handler ) { |
| 1328 | + addHandler( element, 'click', handler ); |
| 1329 | +} |
1320 | 1330 | //note: all skins should call runOnloadHook() at the end of html output, |
1321 | 1331 | // so the below should be redundant. It's there just in case. |
1322 | 1332 | hookEvent("load", runOnloadHook); |