r24436 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r24435‎ | r24436 | r24437 >
Date:19:53, 29 July 2007
Author:robchurch
Status:old
Tags:
Comment:
Refactor addClickHandler() and introduce addHandler()
Modified paths:
  • /trunk/phase3/skins/common/wikibits.js (modified) (history)

Diff [purge]

Index: trunk/phase3/skins/common/wikibits.js
@@ -1303,19 +1303,29 @@
13041304 }
13051305
13061306 /**
1307 - * Add a click event handler to an element
 1307+ * Add an event handler to an element
13081308 *
13091309 * @param Element element Element to add handler to
 1310+ * @param String attach Event to attach to
13101311 * @param callable handler Event handler callback
13111312 */
1312 -function addClickHandler( element, handler ) {
 1313+function addHandler( element, attach, handler ) {
13131314 if( window.addEventListener ) {
1314 - element.addEventListener( 'click', handler, false );
 1315+ element.addEventListener( attach, handler, false );
13151316 } else if( window.attachEvent ) {
1316 - element.attachEvent( 'onclick', handler );
 1317+ element.attachEvent( 'on' + attach, handler );
13171318 }
13181319 }
13191320
 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+}
13201330 //note: all skins should call runOnloadHook() at the end of html output,
13211331 // so the below should be redundant. It's there just in case.
13221332 hookEvent("load", runOnloadHook);

Follow-up revisions

RevisionCommit summaryAuthorDate
r24502Merged revisions 24415-24479 via svnmerge from...david22:31, 31 July 2007

Status & tagging log