MyBB Community Forums

Full Version: MyAlerts
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I tried searching whole thread and internet to fix this issue, but could not, so that why asking you here.

I have got an issue regarding MyAlerts plugin, It is not a big one, I am just a noob on java script stuff thats why asking it here from experts.

MyBB Version : Latest
MyAlert Version : Latest - Downloaded from github page of this plugin.

Issue : This code which MyAlert added in headerinclude, conflicts with some other jQuerry of the theme which I am using.

<script type="text/javascript">
    var unreadAlerts = {$mybb->user['unreadAlerts']};
</script>
<script type="text/javascript" src="{$mybb->settings['bburl']}/jscripts/myalerts.js"></script>


So I had to remove this code and resort to other method which was described in main github page of this plugin (to add following lines in headerinclude instead of above myalert code snippet).

<script type="text/javascript" src="{$mybb->settings['bburl']}/jscripts/scriptaculous.js?load=effects"></script>
<script type="text/javascript" src="{$mybb->settings['bburl']}/jscripts/myalerts.prototype.js"></script>

So now I am getting an issue, that drop down of MyAlert are not working when I click on alert button, it takes me to alert page. When I "Inspected Element" in chrome browser, I am getting this error.

Quote:Uncaught script.aculo.us requires the Prototype JavaScript framework >= 1.6.0.3 scriptaculous.js:53

Uncaught TypeError: undefined is not a function ----- myalerts.prototype.js:1

How can I get MyAlerts to work properly without any conflict ?
Are you using MyBB 1.8? If so, Prototype was removed and replaced with jQuery. MyAlerts isn't fully supported for 1.8 yet, but you could try this JavaScript instead:

;
(function ($, window, document, my_post_key, undefined) {
    this.MybbStuff = this.MybbStuff || {};

    this.MybbStuff.MyAlerts = (function MyAlertsModule(window, $) {
        var module = function MyAlerts() {
            $("body").on("click", ".myalerts_popup_hook", this.openPopup);

            $("body").on("click", ".myalerts_popup", this.stopMultiSlide);

            $("body").on("click", "body:not('.myalerts_popup:visible')", this.closeVisiblePopup);

            $("body").on("click", "#getUnreadAlerts", this.getUnreadAlerts);

            $("body").on("click", ".deleteAlertButton", this.deleteAlert);

            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 + ')';
            }
        };

        module.prototype.openPopup = function openPopup(event) {
            event.preventDefault();
            var clickedElement = $(event.currentTarget),
                popup_id = "#" + clickedElement.attr("id") + "_popup";

            if ($(popup_id).length > 0) {
                $(popup_id).attr("top", clickedElement.height() + "px").slideToggle("fast", function() {
                    var toMarkRead = [];
                    $('[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
                    });
                });
            }
        };

        module.prototype.stopMultiSlide = function stopMultiSlide(event) {
            event.preventPropagation();
        };

        module.prototype.closeVisiblePopup = function closeVisiblePopup(event) {
            $('.myalerts_popup:visible').hide();
        };

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

        module.prototype.deleteAlert = function deleteAlert(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);
                }
            });
        };

        return module;
    })(window, jQuery);

    $(document).ready(function() {
        var myalerts = new MybbStuff.MyAlerts();
    });
})(jQuery, window, document, my_post_key);

If that doesn't work, please post the specific error(s) you are seeing.
Or wait for new version Smile
Or that, which will hopefully be very soon Big Grin
@Euan T - I hope so Big Grin because we need rewritten PM system soon Big Grin
The order will hopefully be:

-MyAlerts
-SimpleLikes
-Conversations
-FollowMe

They all rely on MyAlerts so it's the top priority, alongside actual core development Wink
Hi, Euan T.
Add new message notification subscribed threads to myalerts
Thanks Euan, I used that code which you told above in post # 1322. This is the error I am getting this time.

Uncaught script.aculo.us requires the Prototype JavaScript framework >= 1.6.0.3    --------   scriptaculous.js:53

Uncaught ReferenceError: my_post_key is not defined   ---------  myalerts.prototype.js:93

93 is last line of code actually.

(2014-11-10, 08:26 PM)Eldenroot Wrote: [ -> ]Or wait for new version Smile

Users in my site heavily rely on alerts, thats why while I wait for 100 % compatible version, I needed some thing which I can give to them for time being . Undecided
Why don't introduce your plugin on MyBB core and make it more easy to make other plugins compatible with it?
By the way, thanks for the amazing plugin, waiting for 1.8 version
(2014-11-11, 03:58 AM)Yadomi Wrote: [ -> ]Why don't introduce your plugin on MyBB core and make it more easy to make other plugins compatible with it?
By the way, thanks for the amazing plugin, waiting for 1.8 version

I agree, but I doubt that's going to happen considering there likely won't be any additional major feature changes for 1.8.x. Hopefully something of this sort makes it into MyBB 2.0. It would certainly be nice. Big Grin