<commit_before>/*======================================================
************   Notifications   ************
======================================================*/
var _tempNotificationElement;
app.addNotification = function (params) {
    if (!params) return;
    
    if (typeof params.media === 'undefined') params.media = app.params.notificationMedia;
    if (typeof params.title === 'undefined') params.title = app.params.notificationTitle;
    if (typeof params.subtitle === 'undefined') params.subtitle = app.params.notificationSubtitle;
    if (typeof params.closeIcon === 'undefined') params.closeIcon = app.params.notificationCloseIcon;
    if (typeof params.hold === 'undefined') params.hold = app.params.notificationHold;
    if (typeof params.closeOnClick === 'undefined') params.closeOnClick = app.params.notificationCloseOnClick;

    if (!_tempNotificationElement) _tempNotificationElement = document.createElement('div');

    var container = $('.notifications');
    if (container.length === 0) {
        $('body').append('<div class="notifications list-block media-list"><ul></ul></div>');
        container = $('.notifications');
    }
    var list = container.children('ul');

    var itemHTML;
    if (params.custom) {
        itemHTML = '<li>' + params.custom + '</li>';
    }
    else {
        itemHTML = '<li class="notification-item notification-hidden"><div class="item-content">' +
                        (params.media ?
                        '<div class="item-media">' +
                            params.media +
                        '</div>' : '') +
                        '<div class="item-inner">' +
                            '<div class="item-title-row">' +
                                (params.title ? '<div class="item-title">' + params.title + '</div>' : '') +
                                (params.closeIcon ? '<div class="item-after"><a href="#" class="close-notification"><span></span></a></div>' : '') +
                            '</div>' +
                            (params.subtitle ? '<div class="item-subtitle">' + params.subtitle + '</div>' : '') +
                            (params.message ? '<div class="item-text">' + params.message + '</div>' : '') +
                        '</div>' +
                    '</div></li>';
    }
    _tempNotificationElement.innerHTML = itemHTML;

    var item = $(_tempNotificationElement).children();

    item.on('click', function (e) {
        if (params.onClick) params.onClick(e, item[0]);
        if (params.closeOnClick) app.closeNotification(item[0]);
        else if ($(e.target).is('.close-notification') || $(e.target).parents('.close-notification').length > 0) app.closeNotification(item[0]);
    });
    if (params.onClose) {
        item.data('f7NotificationOnClose', function () {
            params.onClose(item[0]);
        });
    }
    if (params.additionalClass) {
        item.addClass(params.additionalClass);
    }
    if (params.hold) {
        setTimeout(function () {
            if (item.length > 0) app.closeNotification(item[0]);
        }, params.hold);
    }

    list.prepend(item[0]);
    container.show();
    
    var itemHeight = item.height();
    item.css('marginTop', -itemHeight + 'px');<commit_msg>Fix onClick callback when clicked on close<commit_after>/*======================================================
************   Notifications   ************
======================================================*/
var _tempNotificationElement;
app.addNotification = function (params) {
    if (!params) return;
    
    if (typeof params.media === 'undefined') params.media = app.params.notificationMedia;
    if (typeof params.title === 'undefined') params.title = app.params.notificationTitle;
    if (typeof params.subtitle === 'undefined') params.subtitle = app.params.notificationSubtitle;
    if (typeof params.closeIcon === 'undefined') params.closeIcon = app.params.notificationCloseIcon;
    if (typeof params.hold === 'undefined') params.hold = app.params.notificationHold;
    if (typeof params.closeOnClick === 'undefined') params.closeOnClick = app.params.notificationCloseOnClick;

    if (!_tempNotificationElement) _tempNotificationElement = document.createElement('div');

    var container = $('.notifications');
    if (container.length === 0) {
        $('body').append('<div class="notifications list-block media-list"><ul></ul></div>');
        container = $('.notifications');
    }
    var list = container.children('ul');

    var itemHTML;
    if (params.custom) {
        itemHTML = '<li>' + params.custom + '</li>';
    }
    else {
        itemHTML = '<li class="notification-item notification-hidden"><div class="item-content">' +
                        (params.media ?
                        '<div class="item-media">' +
                            params.media +
                        '</div>' : '') +
                        '<div class="item-inner">' +
                            '<div class="item-title-row">' +
                                (params.title ? '<div class="item-title">' + params.title + '</div>' : '') +
                                (params.closeIcon ? '<div class="item-after"><a href="#" class="close-notification"><span></span></a></div>' : '') +
                            '</div>' +
                            (params.subtitle ? '<div class="item-subtitle">' + params.subtitle + '</div>' : '') +
                            (params.message ? '<div class="item-text">' + params.message + '</div>' : '') +
                        '</div>' +
                    '</div></li>';
    }
    _tempNotificationElement.innerHTML = itemHTML;

    var item = $(_tempNotificationElement).children();

    item.on('click', function (e) {
        var close = false;
        if ($(e.target).is('.close-notification') || $(e.target).parents('.close-notification').length > 0) {
            close = true;
        }
        else {
            if (params.onClick) params.onClick(e, item[0]);
            if (params.closeOnClick) close = true;
        }
        if (close) app.closeNotification(item[0]);
    });
    if (params.onClose) {
        item.data('f7NotificationOnClose', function () {
            params.onClose(item[0]);
        });
    }
    if (params.additionalClass) {
        item.addClass(params.additionalClass);
    }
    if (params.hold) {
        setTimeout(function () {
            if (item.length > 0) app.closeNotification(item[0]);
        }, params.hold);
    }

    list.prepend(item[0]);
    container.show();
    
    var itemHeight = item.height();
    item.css('marginTop', -itemHeight + 'px');
{'fraction_non_alphanumeric': 0.2011173184357542, 'fraction_numerical': 0.002868790578287785, 'mean_word_length': 2.3336688475088074, 'pattern_counts': {'":': 0, '<': 59, '<?xml version=': 0, '>': 63, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1968176', 'n_tokens_mistral': 1763, 'n_tokens_neox': 1724, 'n_words': 325}