MyBB Community Forums

Full Version: MyAlerts
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Try this:

jQuery.noConflict();

jQuery(document).ready(function($)
{
    $('body').on({
        click: function(event)
        {
            event.preventDefault();
            var popup_id = $(this).attr('id') + '_popup';

            $('#' + popup_id).attr('top', $(this).height() + 'px').toggle(function() {
                var toMarkRead = new Array;
                $('[id^="alert_row_popup_"]').each(function() {
                    toMarkRead.push($(this).attr('id').substr(16));
                });

                $.get('xmlhttp.php?action=markRead', {
                    my_post_key: my_post_key,
                    toMarkRead: toMarkRead
                }, function(data) {

                });
            });
            return false;
        }
    }, '.myalerts_popup_hook');

    $('#getUnreadAlerts').on('click', function(event) {
        event.preventDefault();
        $.get('xmlhttp.php?action=getNewAlerts', function(data) {
            $('#latestAlertsListing').prepend(data);
        });
    });

    $('.deleteAlertButton').on('click', function(event) {
        event.preventDefault();
        var deleteButton = $(this);

        $.getJSON(deleteButton.attr('href'), {accessMethod: 'js'}, function(data) {
            if (data['success'])
            {
                deleteButton.parents('tr').get(0).remove();
                if (data['template'])
                {
                    $('#latestAlertsListing').html(data['template']);
                }
            }
            else
            {
                alert(data['error']);
            }
        });
    });

    if (typeof myalerts_autorefresh !== 'undefined' && myalerts_autorefresh > 0)
    {
        window.setInterval(function() {
            $.get('xmlhttp.php?action=getNewAlerts', function(data) {
                $('#latestAlertsListing').prepend(data);
            });
        }, myalerts_autorefresh * 1000);
    }

    if (typeof unreadAlerts !== 'undefined' && unreadAlerts > 0)
    {
        document.title = document.title + ' (' + unreadAlerts + ')';
    }

});
It works again, but it's still animated Confused
(2012-12-01, 10:57 AM)euantor Wrote: [ -> ]Try this:

jQuery.noConflict();

jQuery(document).ready(function($)
{
    $('body').on({
        click: function(event)
        {
            event.preventDefault();
            var popup_id = $(this).attr('id') + '_popup';

            $('#' + popup_id).attr('top', $(this).height() + 'px').toggle(function() {
                var toMarkRead = new Array;
                $('[id^="alert_row_popup_"]').each(function() {
                    toMarkRead.push($(this).attr('id').substr(16));
                });

                $.get('xmlhttp.php?action=markRead', {
                    my_post_key: my_post_key,
                    toMarkRead: toMarkRead
                }, function(data) {

                });
            });
            return false;
        }
    }, '.myalerts_popup_hook');

    $('#getUnreadAlerts').on('click', function(event) {
        event.preventDefault();
        $.get('xmlhttp.php?action=getNewAlerts', function(data) {
            $('#latestAlertsListing').prepend(data);
        });
    });

    $('.deleteAlertButton').on('click', function(event) {
        event.preventDefault();
        var deleteButton = $(this);

        $.getJSON(deleteButton.attr('href'), {accessMethod: 'js'}, function(data) {
            if (data['success'])
            {
                deleteButton.parents('tr').get(0).remove();
                if (data['template'])
                {
                    $('#latestAlertsListing').html(data['template']);
                }
            }
            else
            {
                alert(data['error']);
            }
        });
    });

    if (typeof myalerts_autorefresh !== 'undefined' && myalerts_autorefresh > 0)
    {
        window.setInterval(function() {
            $.get('xmlhttp.php?action=getNewAlerts', function(data) {
                $('#latestAlertsListing').prepend(data);
            });
        }, myalerts_autorefresh * 1000);
    }

    if (typeof unreadAlerts !== 'undefined' && unreadAlerts > 0)
    {
        document.title = document.title + ' (' + unreadAlerts + ')';
    }

});

Euan, the way you're doing it by using height jQuery is accustomed to adjusting it in 1px intervals so it does 1px, 2px, 3px, 4px, etc. You'll have to change that.
Darn, I'll have to look into the best way of doing it then.
Some other enhancements I'd like to suggest you to add to MyAlerts:
  • 'Shade edited your post'
  • 'Shade deleted your post', 'Shade deleted your thread'
  • 'Shade moved your thread'
  • 'euantor warned you adding 25% to your warning level (total 75%)'
  • 'You were promoted to XXX usergroup' (automatic core promotion system)

These notifications would be really appreciated and would grow a little bit the notification action list.
I'll think about it. Originally I intended it for social type notifications really. I could always bundle those notification types into a separate "extra alerts" plugin though.
Some more things for the "extra alerts" plugin:
  • JordanM suspended your signature
  • JordanM edited your signature
  • JordanM remove your avatar
  • JordanM changed your avatar
  • JordanM updated your profile
  • JordanM updated your account settings
  • JordanM suspended you from posting
  • JordanM set your posts to be moderated
  • JordanM unsuspended you from posting
  • JordanM unset your posts to be moderated
  • You are now not suspended from posting
  • Your posts now don't have to be moderated
It would end up to be times better than IPBoard or XenForo's ones.
I do like moderation alerts. I had in mind, would be nice to see.
Just installed it on OPF and it seems to be working good.

Again, thank you for this plugin. Smile