Commit 0a9ea560 authored by Andrew Jesaitis's avatar Andrew Jesaitis Committed by Claude Paroz
Browse files

Moved cancelEventPropagation into core.js

The cancelEventPropagation function is a general utility function that
can be reused by other widgets. Refs #4120.
parent d5824ef6
Loading
Loading
Loading
Loading
+2 −7
Original line number Diff line number Diff line
@@ -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();
    }
}

+6 −0
Original line number Diff line number Diff line
@@ -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]);