27 lines
736 B
JavaScript
27 lines
736 B
JavaScript
/**
|
|
* @file
|
|
* JavaScript behaviors for select menu.
|
|
*/
|
|
|
|
(function ($, Drupal) {
|
|
|
|
'use strict';
|
|
|
|
/**
|
|
* Disable select menu options using JavaScript.
|
|
*
|
|
* @type {Drupal~behavior}
|
|
*/
|
|
Drupal.behaviors.webformSelectOptionsDisabled = {
|
|
attach: function (context) {
|
|
$('select[data-webform-select-options-disabled]', context).once('webform-select-options-disabled').each(function () {
|
|
var $select = $(this);
|
|
var disabled = $select.attr('data-webform-select-options-disabled').split(/\s*,\s*/);
|
|
$select.find('option').filter(function isDisabled() {
|
|
return ($.inArray(this.value, disabled) !== -1);
|
|
}).attr('disabled', 'disabled');
|
|
});
|
|
}
|
|
};
|
|
|
|
})(jQuery, Drupal);
|