vyznev / soup

Stack Overflow Unofficial Patch
27 stars 6 forks source link

mse90713 fix (bounty message in close dialog) broke at some point #50

Open gparyani opened 4 years ago

gparyani commented 4 years ago

The mse90713 fix (which adds a warning to the close dialog on questions with active bounties indicating that they cannot be voted for closure) broke at some point, possibly due to SE design changes. (I can't pinpoint when exactly, since I've not run into a case where I've attempted to close a bountied question in a while.)

double-beep commented 4 years ago

Can be fixed with:

fixes.mse90713 = {
    title:  "Show “this question has an active bounty and cannot be closed” earlier, when it applies",
    url:    "https://meta.stackexchange.com/q/90713",
    // XXX: the bounty detection won't work in review; hopefully bountied questions should rarely appear there
    path:   /^\/questions\/\d+\b/,
    script: function () {
        if ( ! $('.js-post-notice').length || ! $('.js-post-notice').find('b').text().match(/bounty/) ) return; // no bounty notice => nothing to do

        var notice = '<div class="soup-mse90713-notice">This question has an open bounty and cannot be closed.</div>';

        // disable any radio buttons that don't open a submenu
        // TODO: super-disable the submit button instead? (see mso358862 fix below)
        SOUP.hookAjax( /^\/flags\/questions\/\d+\/close\/popup\b/, function () {
            $('#popup-close-question h2.popup-title-container').after( notice );
            $('#popup-close-question input[type=radio]:not([data-subpane-name][data-subpane-name!=""])').disable();
        } );
        // also prevent the dupe finder from enabling the submit button
        SOUP.hookAjax( /^\/posts\/popup\/close\/search-originals\/\d+\b/, function () {
            $('.popup-submit').disable();
        } );
    },
    // the colors are based on the .message.message-error style in all.css on SO
    css:    ".soup-mse90713-notice { color: #F9ECED; background-color: #C04848; text-align: center; padding: 11px; margin-bottom: 4px }"
};

Looks like it broke with the new SE post notices.

gparyani commented 4 years ago

@double-beep Your change won't work now, unfortunately, as changes were made to the close UI in April.