Skip to content

Commit

Permalink
warn: fix display of specialized input prompts
Browse files Browse the repository at this point in the history
Closes wikimedia-gadgets#659.  Changing changing a selection via `jquery.chosen` didn't trigger `change_subcategory`.  We still need the extra `Twinkle.warn.callback.change_subcategory(e)` call from wikimedia-gadgets#432 to update display on simply `change_category` but I don't think we need the initial event in `sub_group` if we're using chosen
  • Loading branch information
Amorymeltzer committed Jun 6, 2019
1 parent 1ca0527 commit ba3c3bf
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions modules/twinklewarn.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ Twinkle.warn.callback = function twinklewarnCallback() {
main_group.append( { type: 'option', label: 'Custom warnings', value: 'custom', selected: ( defaultGroup === 9 ) } );
}

main_select.append( { type: 'select', name: 'sub_group', event:Twinkle.warn.callback.change_subcategory } ); //Will be empty to begin with.
main_select.append( { type: 'select', name: 'sub_group'} ); // Event to be added alongside jquery.chosen later

form.append( {
type: 'input',
Expand Down Expand Up @@ -1149,18 +1149,20 @@ Twinkle.warn.callback.change_category = function twinklewarnCallbackChangeCatego
} );
}

$('select[name=sub_group]').chosen({width: '100%', search_contains: true});

// Limit the max height of select dropdown to prevent dialog box from becoming scrollable
$('.chosen-results').css({'overflow': 'auto', 'max-height': '180px'});

// clear overridden label on article textbox
Morebits.quickForm.setElementTooltipVisibility(e.target.root.article, true);
Morebits.quickForm.resetElementLabel(e.target.root.article);
// hide the big red notice
$("#tw-warn-red-notice").remove();
// add custom label.redWarning
// Trigger custom label/change on main category change
Twinkle.warn.callback.change_subcategory(e);

// Build select menu with jquery.chosen
$('select[name=sub_group]').chosen({width: '100%', search_contains: true}).change(function(e) {
Twinkle.warn.callback.change_subcategory(e);
});
// Limit the max height of select dropdown to prevent dialog box from becoming scrollable
$('.chosen-results').css({'overflow': 'auto', 'max-height': '180px'});
};

Twinkle.warn.callback.change_subcategory = function twinklewarnCallbackChangeSubcategory(e) {
Expand Down

0 comments on commit ba3c3bf

Please sign in to comment.