Mercurial > hg > mgallery
changeset 81:697846b47d17
Add javascript helper function mgalAddEvent() and use it.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 14 Sep 2016 22:50:29 +0300 |
parents | 121613e40d87 |
children | e0e5e5197bb8 |
files | mgallery.php |
diffstat | 1 files changed, 16 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mgallery.php Wed Sep 14 22:33:51 2016 +0300 +++ b/mgallery.php Wed Sep 14 22:50:29 2016 +0300 @@ -606,6 +606,21 @@ "var mgalExpanded = false;\n". "\n"; ?> +function mgalAddEvent(evobj, evtype, evcallback) +{ + if (evobj == null || typeof(evobj) == 'undefined') + return; + + if (evobj.addEventListener) + evobj.addEventListener(evtype, evcallback, false); + else + if (evobj.attachEvent) + evobj.attachEvent("on" + evtype, evcallback); + else + evobj["on"+evtype] = evcallback; +}; + + function mgalNavigateTo(url) { if (url != "") @@ -641,7 +656,7 @@ return false; } -document.onkeypress = mgalProcessKeyPress; +mgalAddEvent(document, "keypress", mgalProcessKeyPress); <? echo