Moved cancelEventPropagation into core.js

The cancelEventPropagation function is a general utility function that
can be reused by other widgets. Refs #4120.
This commit is contained in:
Andrew Jesaitis 2013-03-22 22:34:58 -06:00 committed by Claude Paroz
parent d5824ef69d
commit 0a9ea56056
2 changed files with 8 additions and 7 deletions

View File

@ -76,7 +76,7 @@ var DateTimeShortcuts = {
clock_box.className = 'clockbox module';
clock_box.setAttribute('id', DateTimeShortcuts.clockDivName + num);
document.body.appendChild(clock_box);
addEvent(clock_box, 'click', DateTimeShortcuts.cancelEventPropagation);
addEvent(clock_box, 'click', cancelEventPropagation);
quickElement('h2', clock_box, gettext('Choose a time'));
var time_list = quickElement('ul', clock_box, '');
@ -174,7 +174,7 @@ var DateTimeShortcuts = {
cal_box.className = 'calendarbox module';
cal_box.setAttribute('id', DateTimeShortcuts.calendarDivName1 + num);
document.body.appendChild(cal_box);
addEvent(cal_box, 'click', DateTimeShortcuts.cancelEventPropagation);
addEvent(cal_box, 'click', cancelEventPropagation);
// next-prev links
var cal_nav = quickElement('div', cal_box, '');
@ -277,11 +277,6 @@ var DateTimeShortcuts = {
DateTimeShortcuts.calendarInputs[num].value = d.strftime(get_format('DATE_INPUT_FORMATS')[0]);
DateTimeShortcuts.calendarInputs[num].focus();
DateTimeShortcuts.dismissCalendar(num);
},
cancelEventPropagation: function(e) {
if (!e) e = window.event;
e.cancelBubble = true;
if (e.stopPropagation) e.stopPropagation();
}
}

View File

@ -29,6 +29,12 @@ function removeEvent(obj, evType, fn) {
}
}
function cancelEventPropagation(e) {
if (!e) e = window.event;
e.cancelBubble = true;
if (e.stopPropagation) e.stopPropagation();
}
// quickElement(tagType, parentReference, textInChildNode, [, attribute, attributeValue ...]);
function quickElement() {
var obj = document.createElement(arguments[0]);