standardise event cancellation

This commit is contained in:
mappu 2017-02-08 18:19:33 +13:00
parent c4e37bf47d
commit 42a8298362

View File

@ -243,8 +243,7 @@ var userMenu = function(u, ev) {
usermenu.show(); usermenu.show();
// //
ev.preventDefault(); return noprop(ev);
return false;
}; };
var userlist = { var userlist = {
@ -525,6 +524,20 @@ var tab_free = function(id) {
} }
}; };
var noprop = function(ev) {
if (ev.preventDefault) {
ev.preventDefault();
}
if (ev.stopPropagation) {
ev.stopPropagation();
} else {
ev.cancelBubble = true; // oldIE
}
return false;
}
var tab_addHandlers = function() { var tab_addHandlers = function() {
var tabitems = $(".tabitem"); var tabitems = $(".tabitem");
for (var i = 0; i < tabitems.length; i++) { for (var i = 0; i < tabitems.length; i++) {
@ -533,13 +546,7 @@ var tab_addHandlers = function() {
tabitems[i].onclick = function(ev) { tabitems[i].onclick = function(ev) {
tab_set( this.getAttribute('data-tab') ); tab_set( this.getAttribute('data-tab') );
// 360nobubble return noprop(ev);
if (ev.stopPropagation) {
ev.stopPropagation();
} else {
ev.cancelBubble = true; // oldIE
}
return false;
}; };
} }
@ -550,13 +557,7 @@ var tab_addHandlers = function() {
tabclosers[i].onclick = function(ev) { tabclosers[i].onclick = function(ev) {
tab_free( this.getAttribute('data-tab') ); tab_free( this.getAttribute('data-tab') );
// 360nobubble return noprop(ev);
if (ev.stopPropagation) {
ev.stopPropagation();
} else {
ev.cancelBubble = true; // oldIE
}
return false;
}; };
} }
}; };
@ -949,26 +950,21 @@ window.onload = function() {
$("#form-none").onsubmit = function(ev) { $("#form-none").onsubmit = function(ev) {
submit(); submit();
// don't submit form return noprop(ev); // don't submit form
ev.preventDefault();
return false;
}; };
$("#chatbox").onkeydown = function(ev) { $("#chatbox").onkeydown = function(ev) {
if (ev.keyCode === 9 /* Tab */) { if (ev.keyCode === 9 /* Tab */) {
tabcompletion_start( ev.shiftKey ? -1 : 1 ); tabcompletion_start( ev.shiftKey ? -1 : 1 );
ev.preventDefault(); return noprop(ev);
return false;
} else if (ev.keyCode == 38 /* ArrowUp */ && ev.ctrlKey) { } else if (ev.keyCode == 38 /* ArrowUp */ && ev.ctrlKey) {
scrollback_move(-1); scrollback_move(-1);
ev.preventDefault(); return noprop(ev);
return false;
} else if (ev.keyCode == 40 /* ArrowDown */ && ev.ctrlKey) { } else if (ev.keyCode == 40 /* ArrowDown */ && ev.ctrlKey) {
scrollback_move(1); scrollback_move(1);
ev.preventDefault(); return noprop(ev);
return false;
} else { } else {
tabcompletion_inactive(); tabcompletion_inactive();
@ -987,9 +983,7 @@ window.onload = function() {
$("#menubutton").onclick = function(ev) { $("#menubutton").onclick = function(ev) {
menu.toggle(); menu.toggle();
ev.preventDefault(); return noprop(ev);
ev.stopPropagation();
return false;
}; };
window.onclick = function() { window.onclick = function() {