1/** 2* DO NOT EDIT THIS FILE. 3* See the following change record for more information, 4* https://www.drupal.org/node/2815083 5* @preserve 6**/ 7 8(function ($, Drupal) { 9 Drupal.behaviors.bs4_modal = { 10 attach: function attach(context, settings) { 11 var $context = $(context); 12 var self = this; 13 14 if (!$('#drupal-bootstrap4-modal').length) { 15 $('<div id="drupal-bootstrap4-modal" class="bs4-modal modal fade" tabindex="-1" role="dialog"><div class="modal-dialog" role="document"><div class="modal-content"></div></div></div>').hide().appendTo('body'); 16 } 17 18 var $dialog = $context.closest('.modal-content'); 19 if ($dialog.length) { 20 var dialogSettings = $dialog.closest('.bs4-modal').data('settings'); 21 if (dialogSettings && dialogSettings.drupalAutoButtons) { 22 $dialog.trigger('dialogButtonsChange'); 23 } 24 } 25 26 var originalClose = settings.bs4_modal_dialog.close; 27 28 settings.bs4_modal_dialog.close = function (event) { 29 for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { 30 args[_key - 1] = arguments[_key]; 31 } 32 33 originalClose.apply(settings.bs4_modal_dialog, [event].concat(args)); 34 $(event.target).remove(); 35 }; 36 }, 37 prepareDialogButtons: function prepareDialogButtons($dialog) { 38 var buttons = []; 39 var $buttons = $dialog.find('.form-actions input[type=submit], .form-actions button[type=submit], .form-actions a.button'); 40 $buttons.each(function () { 41 var $originalButton = $(this).css({ display: 'none' }); 42 buttons.push({ 43 text: $originalButton.html() || $originalButton.attr('value'), 44 class: $originalButton.attr('class'), 45 click: function click(e) { 46 if ($originalButton.is('a')) { 47 $originalButton[0].click(); 48 } else { 49 $originalButton.trigger('mousedown').trigger('mouseup').trigger('click'); 50 e.preventDefault(); 51 } 52 } 53 }); 54 }); 55 return buttons; 56 } 57 }; 58 59 Drupal.AjaxCommands.prototype.openBootstrap4DialogByUrl = function(ajax, response, status) { 60 var settings = $.extend(response.settings, {}); 61 62 var elementSettings = { 63 progress: { 64 type: 'throbber' 65 }, 66 dialogType: 'bootstrap4_modal', 67 dialog: response.dialogOptions, 68 url: settings.url 69 }; 70 71 var dialogUrlAjax = Drupal.ajax(elementSettings); 72 dialogUrlAjax.execute(); 73 }; 74 75 Drupal.AjaxCommands.prototype.openBootstrap4Dialog = function (ajax, response, status) { 76 if (!response.selector) { 77 return false; 78 } 79 var $dialog = $(response.selector); 80 if (!$dialog.length) { 81 $dialog = $('<div id="' + response.selector.replace(/^#/, '') + '" class="modal fade" tabindex="-1" role="dialog"><div class="modal-dialog" role="document"><div class="modal-content"></div></div></div>').hide().appendTo('body'); 82 } 83 84 if (!ajax.wrapper) { 85 response.selector = response.selector.toString() + ' .modal-content'; 86 } 87 88 response.command = 'insert'; 89 response.method = 'html'; 90 91 // Do some extra things here 92 // Set Drupal.autocomplete options to render autocomplete box inside the modal 93 if (Drupal.autocomplete !== undefined && Drupal.autocomplete.options !== undefined) { 94 Drupal.autocomplete.options.appendTo = response.selector; 95 } 96 97 if (response.dialogOptions.modalDialogWrapBody === undefined || (response.dialogOptions.modalDialogWrapBody === true || response.dialogOptions.modalDialogWrapBody == 'true')) { 98 response.data = '<div class="modal-body">' + response.data + '</div>'; 99 } 100 101 ajax.commands.insert(ajax, response, status); 102 103 if (!response.dialogOptions.drupalAutoButtons || response.dialogOptions.drupalAutoButtons !== 'false') { 104 response.dialogOptions.drupalAutoButtons = true; 105 if (response.dialogOptions.buttons === undefined || response.dialogOptions.buttons.length <= 0) { 106 response.dialogOptions.buttons = Drupal.behaviors.bs4_modal.prepareDialogButtons($dialog); 107 } 108 } else { 109 response.dialogOptions.drupalAutoButtons = false;
110 } 111 112 $dialog.on('dialogButtonsChange', function () { 113 var buttons = Drupal.behaviors.bs4_modal.prepareDialogButtons($dialog); 114 115 var dialog = Drupal.bs4_modal($dialog.get(0)); 116 dialog.updateButtons(buttons); 117 }); 118 119 response.dialogOptions = response.dialogOptions || {}; 120 var dialog = Drupal.bs4_modal($dialog.get(0), response.dialogOptions); 121 if (response.dialogOptions.modal) { 122 dialog.showModal(); 123 } else { 124 dialog.show(); 125 } 126 127 $dialog.parent().find('.ui-dialog-buttonset').addClass('form-actions'); 128 }; 129 130 Drupal.AjaxCommands.prototype.closeBootstrap4Dialog = function (ajax, response, status) { 131 var $dialog = $(response.selector); 132 if ($dialog.length) { 133 Drupal.bs4_modal($dialog.get(0)).close(); 134 } 135 136 $dialog.off('dialogButtonsChange'); 137 }; 138 139 Drupal.AjaxCommands.prototype.setBootstrap4DialogOption = function (ajax, response, status) { 140 var $dialog = $(response.selector); 141 if ($dialog.length) { 142 // $dialog.dialog('option', response.optionName, response.optionValue); 143 } 144 }; 145 146 $(window).on('dialog:aftercreate', function (e, dialog, $element, settings) { 147 // Prevent errors on regular Drupal dialogs. 148 if (!$element.hasClass('bs4-modal')) { 149 return; 150 } 151 $element.on('click.dialog', '.dialog-cancel', function (e) { 152 dialog.close('cancel'); 153 e.preventDefault(); 154 e.stopPropagation(); 155 }); 156 }); 157 158 $(window).on('dialog:beforeclose', function (e, dialog, $element) { 159 $element.off('.dialog'); 160 161 // Do some extra things here 162 // Set Drupal.autocomplete options to render autocomplete box inside the modal 163 if (Drupal.autocomplete !== undefined && Drupal.autocomplete.options !== undefined) { 164 if (Drupal.autocomplete.options.appendTo !== undefined) { 165 delete Drupal.autocomplete.options.appendTo; 166 } 167 } 168 }); 169})(jQuery, Drupal);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.