diff --git a/core/misc/dialog.ajax.js b/core/misc/dialog.ajax.js
deleted file mode 100644
index d2d8d3a..0000000
--- a/core/misc/dialog.ajax.js
+++ /dev/null
@@ -1,168 +0,0 @@
-/**
- * @file
- * Extends the Drupal AJAX functionality to integrate the dialog API.
- */
-
-(function ($, Drupal) {
-
-  "use strict";
-
-  Drupal.behaviors.dialog = {
-    attach: function (context, settings) {
-      var $context = $(context);
-
-      // Provide a known 'drupal-modal' DOM element for Drupal-based modal
-      // dialogs. Non-modal dialogs are responsible for creating their own
-      // elements, since there can be multiple non-modal dialogs at a time.
-      if (!$('#drupal-modal').length) {
-        $('<div id="drupal-modal" />').hide().appendTo('body');
-      }
-
-      // Special behaviors specific when attaching content within a dialog.
-      // These behaviors usually fire after a validation error inside a dialog.
-      var $dialog = $context.closest('.ui-dialog-content');
-      if ($dialog.length) {
-        // Remove and replace the dialog buttons with those from the new form.
-        if ($dialog.dialog('option', 'drupalAutoButtons')) {
-          // Trigger an event to detect/sync changes to buttons.
-          $dialog.trigger('dialogButtonsChange');
-        }
-
-        // Force focus on the modal when the behavior is run.
-        $dialog.dialog('widget').trigger('focus');
-      }
-    },
-
-    /**
-     * Scan a dialog for any primary buttons and move them to the button area.
-     *
-     * @param $dialog
-     *   An jQuery object containing the element that is the dialog target.
-     * @return
-     *   An array of buttons that need to be added to the button area.
-     */
-    prepareDialogButtons: function ($dialog) {
-      var buttons = [];
-      var $buttons = $dialog.find('.form-actions input[type=submit]');
-      $buttons.each(function () {
-        // Hidden form buttons need special attention. For browser consistency,
-        // the button needs to be "visible" in order to have the enter key fire
-        // the form submit event. So instead of a simple "hide" or
-        // "display: none", we set its dimensions to zero.
-        // See http://mattsnider.com/how-forms-submit-when-pressing-enter/
-        var $originalButton = $(this).css({
-          width: 0,
-          height: 0,
-          padding: 0,
-          border: 0
-        });
-        buttons.push({
-          'text': $originalButton.html() || $originalButton.attr('value'),
-          'class': $originalButton.attr('class'),
-          'click': function (e) {
-            $originalButton.trigger('mousedown').trigger('click').trigger('mouseup');
-            e.preventDefault();
-          }
-        });
-      });
-      return buttons;
-    }
-  };
-
-  /**
-   * Command to open a dialog.
-   */
-  Drupal.AjaxCommands.prototype.openDialog = function (ajax, response, status) {
-    if (!response.selector) {
-      return false;
-    }
-    var $dialog = $(response.selector);
-    if (!$dialog.length) {
-      // Create the element if needed.
-      $dialog = $('<div id="' + response.selector.replace(/^#/, '') + '"/>').appendTo('body');
-    }
-    // Set up the wrapper, if there isn't one.
-    if (!ajax.wrapper) {
-      ajax.wrapper = $dialog.attr('id');
-    }
-
-    // Use the ajax.js insert command to populate the dialog contents.
-    response.command = 'insert';
-    response.method = 'html';
-    ajax.commands.insert(ajax, response, status);
-
-    // Move the buttons to the jQuery UI dialog buttons area.
-    if (!response.dialogOptions.buttons) {
-      response.dialogOptions.drupalAutoButtons = true;
-      response.dialogOptions.buttons = Drupal.behaviors.dialog.prepareDialogButtons($dialog);
-    }
-
-    // Bind dialogButtonsChange
-    $dialog.on('dialogButtonsChange', function() {
-      var buttons = Drupal.behaviors.dialog.prepareDialogButtons($dialog);
-      $dialog.dialog('option', 'buttons', buttons);
-    });
-
-    // Open the dialog itself.
-    response.dialogOptions = response.dialogOptions || {};
-    var dialog = Drupal.dialog($dialog.get(0), response.dialogOptions);
-    if (response.dialogOptions.modal) {
-      dialog.showModal();
-    }
-    else {
-      dialog.show();
-    }
-
-    // Add the standard Drupal class for buttons for style consistency.
-    $dialog.parent().find('.ui-dialog-buttonset').addClass('form-actions');
-  };
-
-  /**
-   * Command to close a dialog.
-   *
-   * If no selector is given, it defaults to trying to close the modal.
-   */
-  Drupal.AjaxCommands.prototype.closeDialog = function (ajax, response, status) {
-    var $dialog = $(response.selector);
-    if ($dialog.length) {
-      Drupal.dialog($dialog.get(0)).close();
-      if (!response.persist) {
-        $dialog.remove();
-      }
-    }
-
-    // Unbind dialogButtonsChange
-    $dialog.off('dialogButtonsChange');
-  };
-
-  /**
-   * Command to set a dialog property.
-   *
-   * jQuery UI specific way of setting dialog options.
-   */
-  Drupal.AjaxCommands.prototype.setDialogOption = function (ajax, response, status) {
-    var $dialog = $(response.selector);
-    if ($dialog.length) {
-      $dialog.dialog('option', response.optionName, response.optionValue);
-    }
-  };
-
-  /**
-   * Binds a listener on dialog creation to handle the cancel link.
-   */
-  $(window).on('dialog:aftercreate', function (e, dialog, $element, settings) {
-    $element.on('click.dialog', '.dialog-cancel', function (e) {
-      dialog.close('cancel');
-      e.preventDefault();
-      e.stopPropagation();
-    });
-  });
-
-  /**
-   * Removes all 'dialog' listeners.
-   */
-  $(window).on('dialog:beforeclose', function (e, dialog, $element) {
-    $element.off('.dialog');
-  });
-
-})(jQuery, Drupal);
diff --git a/core/misc/dialog.js b/core/misc/dialog.js
deleted file mode 100644
index 2bb3a32..0000000
--- a/core/misc/dialog.js
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- * @file
- *
- * Dialog API inspired by HTML5 dialog element:
- * http://www.whatwg.org/specs/web-apps/current-work/multipage/commands.html#the-dialog-element
- */
-(function ($, Drupal, drupalSettings) {
-
-"use strict";
-
-drupalSettings.dialog = {
-  autoOpen: true,
-  dialogClass: '',
-  // When using this API directly (when generating dialogs on the client side),
-  // you may want to override this method and do
-  // @code
-  // jQuery(event.target).remove()
-  // @endcode
-  // as well, to remove the dialog on closing.
-  close: function (event) {
-    Drupal.detachBehaviors(event.target, null, 'unload');
-  }
-};
-
-Drupal.dialog = function (element, options) {
-
-  function openDialog (settings) {
-    settings = $.extend({}, drupalSettings.dialog, options, settings);
-    // Trigger a global event to allow scripts to bind events to the dialog.
-    $(window).trigger('dialog:beforecreate', [dialog, $element, settings]);
-    $element.dialog(settings);
-    dialog.open = true;
-    $(window).trigger('dialog:aftercreate', [dialog, $element, settings]);
-  }
-
-  function closeDialog (value) {
-    $(window).trigger('dialog:beforeclose', [dialog, $element]);
-    $element.dialog('close');
-    dialog.returnValue = value;
-    dialog.open = false;
-    $(window).trigger('dialog:afterclose', [dialog, $element]);
-  }
-
-  var undef;
-  var $element = $(element);
-  var dialog = {
-    open: false,
-    returnValue: undef,
-    show: function () {
-      openDialog({modal: false});
-    },
-    showModal: function () {
-      openDialog({modal: true});
-    },
-    close: closeDialog
-  };
-
-  return dialog;
-};
-
-})(jQuery, Drupal, drupalSettings);
diff --git a/core/misc/dialog.position.js b/core/misc/dialog.position.js
deleted file mode 100644
index 7b12055..0000000
--- a/core/misc/dialog.position.js
+++ /dev/null
@@ -1,80 +0,0 @@
-(function ($, Drupal, drupalSettings, debounce, displace) {
-
-  "use strict";
-
-  // autoResize option will turn off resizable and draggable.
-  drupalSettings.dialog = $.extend({ autoResize: true, maxHeight: '95%' }, drupalSettings.dialog);
-
-  /**
-   * Resets the current options for positioning.
-   *
-   * This is used as a window resize and scroll callback to reposition the
-   * jQuery UI dialog. Although not a built-in jQuery UI option, this can
-   * be disabled by setting autoResize: false in the options array when creating
-   * a new Drupal.dialog().
-   */
-  function resetSize (event) {
-    var positionOptions = ['width', 'height', 'minWidth', 'minHeight', 'maxHeight', 'maxWidth', 'position'];
-    var adjustedOptions = {};
-    var windowHeight = $(window).height();
-    var option, optionValue, adjustedValue;
-    for (var n = 0; n < positionOptions.length; n++) {
-      option = positionOptions[n];
-      optionValue = event.data.settings[option];
-      if (optionValue) {
-        // jQuery UI does not support percentages on heights, convert to pixels.
-        if (typeof optionValue === 'string' && /%$/.test(optionValue) && /height/i.test(option)) {
-          // Take offsets in account.
-          windowHeight -= displace.offsets.top + displace.offsets.bottom;
-          adjustedValue = parseInt(0.01 * parseInt(optionValue, 10) * windowHeight, 10);
-          // Don't force the dialog to be bigger vertically than needed.
-          if (option === 'height' && event.data.$element.parent().outerHeight() < adjustedValue) {
-            adjustedValue = 'auto';
-          }
-          adjustedOptions[option] = adjustedValue;
-        }
-      }
-    }
-    // Offset the dialog center to be at the center of Drupal.displace.offsets.
-    adjustedOptions = resetPosition(adjustedOptions);
-    event.data.$element
-      .dialog('option', adjustedOptions)
-      .trigger('dialogContentResize');
-  }
-
-  /**
-   * Position the dialog's center at the center of displace.offsets boundaries.
-   */
-  function resetPosition (options) {
-    var offsets = displace.offsets;
-    var left = offsets.left - offsets.right;
-    var top = offsets.top - offsets.bottom;
-
-    var leftString = (left > 0 ? '+' : '-') + Math.abs(Math.round(left/2)) + 'px';
-    var topString = (top > 0 ? '+' : '-') + Math.abs(Math.round(top/2)) + 'px';
-    options.position = {
-      my: 'center' + (left !== 0 ? leftString : '') + ' center' + (top !== 0 ? topString : '')
-    };
-    return options;
-  }
-
-  $(window).on({
-    'dialog:aftercreate': function (event, dialog, $element, settings) {
-      var autoResize = debounce(resetSize, 20);
-      var eventData = { settings: settings, $element: $element };
-      if (settings.autoResize === true || settings.autoResize === 'true') {
-        $element
-          .dialog('option', { resizable: false, draggable: false })
-          .dialog('widget').css('position', 'fixed');
-        $(window)
-          .on('resize.dialogResize scroll.dialogResize', eventData, autoResize)
-          .trigger('resize.dialogResize');
-        $(document).on('drupalViewportOffsetChange', eventData, autoResize);
-      }
-    },
-    'dialog:beforeclose': function (event, dialog, $element) {
-      $(window).off('.dialogResize');
-    }
-  });
-
-})(jQuery, Drupal, drupalSettings, Drupal.debounce, Drupal.displace);
diff --git a/core/misc/dialog.theme.css b/core/misc/dialog.theme.css
deleted file mode 100644
index 581c03b..0000000
--- a/core/misc/dialog.theme.css
+++ /dev/null
@@ -1,66 +0,0 @@
-/**
- * Presentational styles for Drupal dialogs.
- */
-
-.ui-dialog {
-  position: absolute;
-  z-index: 1260;
-  overflow: visible;
-  color: #000;
-  background: #fff;
-  border: solid 1px #ccc;
-  padding: 0;
-}
-.ui-dialog .ui-dialog-titlebar {
-  font-weight: bold;
-  background: #f3f4ee;
-  border-style: solid;
-  border-radius: 0;
-  border-width: 0 0 1px 0;
-  border-color: #ccc;
-}
-.ui-dialog .ui-dialog-titlebar-close {
-  border: 0;
-  background: none;
-}
-.ui-dialog .ui-dialog-buttonpane {
-  margin-top: 0;
-  background: #f3f4ee;
-  padding: .3em 1em;
-  border-width: 1px 0 0 0;
-  border-color: #ccc;
-}
-.ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset {
-  margin: 0;
-  padding: 0;
-}
-.ui-dialog .ui-dialog-buttonpane .ui-button-text-only .ui-button-text {
-  padding: 0;
-}
-
-/* Form action buttons are moved in dialogs. Remove empty space. */
-.ui-dialog .ui-dialog-content .form-actions {
-  padding: 0;
-  margin: 0;
-}
-.ui-dialog .ajax-progress-throbber {
-  /* Can't do center:50% middle: 50%, so approximate it for a typical window size. */
-  left: 49%;
-  position: fixed;
-  top: 48.5%;
-  z-index: 1000;
-  background-color: #232323;
-  background-image: url("loading-small.gif");
-  background-position: center center;
-  background-repeat: no-repeat;
-  border-radius: 7px;
-  height: 24px;
-  opacity: 0.9;
-  padding: 4px;
-  width: 24px;
-}
-.ui-dialog .ajax-progress-throbber .throbber,
-.ui-dialog .ajax-progress-throbber .message {
-  display: none;
-}
-
diff --git a/core/misc/dialog/dialog.ajax.js b/core/misc/dialog/dialog.ajax.js
new file mode 100644
index 0000000..d2d8d3a
--- /dev/null
+++ b/core/misc/dialog/dialog.ajax.js
@@ -0,0 +1,168 @@
+/**
+ * @file
+ * Extends the Drupal AJAX functionality to integrate the dialog API.
+ */
+
+(function ($, Drupal) {
+
+  "use strict";
+
+  Drupal.behaviors.dialog = {
+    attach: function (context, settings) {
+      var $context = $(context);
+
+      // Provide a known 'drupal-modal' DOM element for Drupal-based modal
+      // dialogs. Non-modal dialogs are responsible for creating their own
+      // elements, since there can be multiple non-modal dialogs at a time.
+      if (!$('#drupal-modal').length) {
+        $('<div id="drupal-modal" />').hide().appendTo('body');
+      }
+
+      // Special behaviors specific when attaching content within a dialog.
+      // These behaviors usually fire after a validation error inside a dialog.
+      var $dialog = $context.closest('.ui-dialog-content');
+      if ($dialog.length) {
+        // Remove and replace the dialog buttons with those from the new form.
+        if ($dialog.dialog('option', 'drupalAutoButtons')) {
+          // Trigger an event to detect/sync changes to buttons.
+          $dialog.trigger('dialogButtonsChange');
+        }
+
+        // Force focus on the modal when the behavior is run.
+        $dialog.dialog('widget').trigger('focus');
+      }
+    },
+
+    /**
+     * Scan a dialog for any primary buttons and move them to the button area.
+     *
+     * @param $dialog
+     *   An jQuery object containing the element that is the dialog target.
+     * @return
+     *   An array of buttons that need to be added to the button area.
+     */
+    prepareDialogButtons: function ($dialog) {
+      var buttons = [];
+      var $buttons = $dialog.find('.form-actions input[type=submit]');
+      $buttons.each(function () {
+        // Hidden form buttons need special attention. For browser consistency,
+        // the button needs to be "visible" in order to have the enter key fire
+        // the form submit event. So instead of a simple "hide" or
+        // "display: none", we set its dimensions to zero.
+        // See http://mattsnider.com/how-forms-submit-when-pressing-enter/
+        var $originalButton = $(this).css({
+          width: 0,
+          height: 0,
+          padding: 0,
+          border: 0
+        });
+        buttons.push({
+          'text': $originalButton.html() || $originalButton.attr('value'),
+          'class': $originalButton.attr('class'),
+          'click': function (e) {
+            $originalButton.trigger('mousedown').trigger('click').trigger('mouseup');
+            e.preventDefault();
+          }
+        });
+      });
+      return buttons;
+    }
+  };
+
+  /**
+   * Command to open a dialog.
+   */
+  Drupal.AjaxCommands.prototype.openDialog = function (ajax, response, status) {
+    if (!response.selector) {
+      return false;
+    }
+    var $dialog = $(response.selector);
+    if (!$dialog.length) {
+      // Create the element if needed.
+      $dialog = $('<div id="' + response.selector.replace(/^#/, '') + '"/>').appendTo('body');
+    }
+    // Set up the wrapper, if there isn't one.
+    if (!ajax.wrapper) {
+      ajax.wrapper = $dialog.attr('id');
+    }
+
+    // Use the ajax.js insert command to populate the dialog contents.
+    response.command = 'insert';
+    response.method = 'html';
+    ajax.commands.insert(ajax, response, status);
+
+    // Move the buttons to the jQuery UI dialog buttons area.
+    if (!response.dialogOptions.buttons) {
+      response.dialogOptions.drupalAutoButtons = true;
+      response.dialogOptions.buttons = Drupal.behaviors.dialog.prepareDialogButtons($dialog);
+    }
+
+    // Bind dialogButtonsChange
+    $dialog.on('dialogButtonsChange', function() {
+      var buttons = Drupal.behaviors.dialog.prepareDialogButtons($dialog);
+      $dialog.dialog('option', 'buttons', buttons);
+    });
+
+    // Open the dialog itself.
+    response.dialogOptions = response.dialogOptions || {};
+    var dialog = Drupal.dialog($dialog.get(0), response.dialogOptions);
+    if (response.dialogOptions.modal) {
+      dialog.showModal();
+    }
+    else {
+      dialog.show();
+    }
+
+    // Add the standard Drupal class for buttons for style consistency.
+    $dialog.parent().find('.ui-dialog-buttonset').addClass('form-actions');
+  };
+
+  /**
+   * Command to close a dialog.
+   *
+   * If no selector is given, it defaults to trying to close the modal.
+   */
+  Drupal.AjaxCommands.prototype.closeDialog = function (ajax, response, status) {
+    var $dialog = $(response.selector);
+    if ($dialog.length) {
+      Drupal.dialog($dialog.get(0)).close();
+      if (!response.persist) {
+        $dialog.remove();
+      }
+    }
+
+    // Unbind dialogButtonsChange
+    $dialog.off('dialogButtonsChange');
+  };
+
+  /**
+   * Command to set a dialog property.
+   *
+   * jQuery UI specific way of setting dialog options.
+   */
+  Drupal.AjaxCommands.prototype.setDialogOption = function (ajax, response, status) {
+    var $dialog = $(response.selector);
+    if ($dialog.length) {
+      $dialog.dialog('option', response.optionName, response.optionValue);
+    }
+  };
+
+  /**
+   * Binds a listener on dialog creation to handle the cancel link.
+   */
+  $(window).on('dialog:aftercreate', function (e, dialog, $element, settings) {
+    $element.on('click.dialog', '.dialog-cancel', function (e) {
+      dialog.close('cancel');
+      e.preventDefault();
+      e.stopPropagation();
+    });
+  });
+
+  /**
+   * Removes all 'dialog' listeners.
+   */
+  $(window).on('dialog:beforeclose', function (e, dialog, $element) {
+    $element.off('.dialog');
+  });
+
+})(jQuery, Drupal);
diff --git a/core/misc/dialog/dialog.jquery-ui.js b/core/misc/dialog/dialog.jquery-ui.js
new file mode 100644
index 0000000..2f425ca
--- /dev/null
+++ b/core/misc/dialog/dialog.jquery-ui.js
@@ -0,0 +1,34 @@
+/**
+ * @file
+ * Adds default classes to buttons for styling purposes.
+ */
+
+(function ($) {
+
+  "use strict";
+
+  $.widget('ui.dialog', $.ui.dialog, {
+    options: {
+      buttonClass: 'button',
+      buttonPrimaryClass: 'button--primary'
+    },
+    _createButtons: function () {
+      var opts = this.options;
+      var primaryIndex;
+      var $buttons;
+      for (var index = 0, il = opts.buttons.length; index < il; index += 1) {
+        if (opts.buttons[index].primary && opts.buttons[index].primary === true) {
+          primaryIndex = index;
+          delete opts.buttons[index].primary;
+          break;
+        }
+      }
+      this._super();
+      $buttons = this.uiButtonSet.children().addClass(opts.buttonClass);
+      if (typeof primaryIndex !== 'undefined') {
+        $buttons.eq(index).addClass(opts.buttonPrimaryClass);
+      }
+    }
+  });
+
+})(jQuery);
diff --git a/core/misc/dialog/dialog.js b/core/misc/dialog/dialog.js
new file mode 100644
index 0000000..3c35c5c
--- /dev/null
+++ b/core/misc/dialog/dialog.js
@@ -0,0 +1,63 @@
+/**
+ * @file
+ * Dialog API inspired by HTML5 dialog element:
+ * http://www.whatwg.org/specs/web-apps/current-work/multipage/commands.html#the-dialog-element
+ */
+(function ($, Drupal, drupalSettings) {
+
+"use strict";
+
+drupalSettings.dialog = {
+  autoOpen: true,
+  dialogClass: '',
+  // Drupal-specific extensions: see dialog.jquery-ui.js.
+  buttonClass: 'button',
+  buttonPrimaryClass: 'button--primary',
+  // When using this API directly (when generating dialogs on the client side),
+  // you may want to override this method and do
+  // @code
+  // jQuery(event.target).remove()
+  // @endcode
+  // as well, to remove the dialog on closing.
+  close: function (event) {
+    Drupal.detachBehaviors(event.target, null, 'unload');
+  }
+};
+
+Drupal.dialog = function (element, options) {
+
+  function openDialog (settings) {
+    settings = $.extend({}, drupalSettings.dialog, options, settings);
+    // Trigger a global event to allow scripts to bind events to the dialog.
+    $(window).trigger('dialog:beforecreate', [dialog, $element, settings]);
+    $element.dialog(settings);
+    dialog.open = true;
+    $(window).trigger('dialog:aftercreate', [dialog, $element, settings]);
+  }
+
+  function closeDialog (value) {
+    $(window).trigger('dialog:beforeclose', [dialog, $element]);
+    $element.dialog('close');
+    dialog.returnValue = value;
+    dialog.open = false;
+    $(window).trigger('dialog:afterclose', [dialog, $element]);
+  }
+
+  var undef;
+  var $element = $(element);
+  var dialog = {
+    open: false,
+    returnValue: undef,
+    show: function () {
+      openDialog({modal: false});
+    },
+    showModal: function () {
+      openDialog({modal: true});
+    },
+    close: closeDialog
+  };
+
+  return dialog;
+};
+
+})(jQuery, Drupal, drupalSettings);
diff --git a/core/misc/dialog/dialog.position.js b/core/misc/dialog/dialog.position.js
new file mode 100644
index 0000000..7b12055
--- /dev/null
+++ b/core/misc/dialog/dialog.position.js
@@ -0,0 +1,80 @@
+(function ($, Drupal, drupalSettings, debounce, displace) {
+
+  "use strict";
+
+  // autoResize option will turn off resizable and draggable.
+  drupalSettings.dialog = $.extend({ autoResize: true, maxHeight: '95%' }, drupalSettings.dialog);
+
+  /**
+   * Resets the current options for positioning.
+   *
+   * This is used as a window resize and scroll callback to reposition the
+   * jQuery UI dialog. Although not a built-in jQuery UI option, this can
+   * be disabled by setting autoResize: false in the options array when creating
+   * a new Drupal.dialog().
+   */
+  function resetSize (event) {
+    var positionOptions = ['width', 'height', 'minWidth', 'minHeight', 'maxHeight', 'maxWidth', 'position'];
+    var adjustedOptions = {};
+    var windowHeight = $(window).height();
+    var option, optionValue, adjustedValue;
+    for (var n = 0; n < positionOptions.length; n++) {
+      option = positionOptions[n];
+      optionValue = event.data.settings[option];
+      if (optionValue) {
+        // jQuery UI does not support percentages on heights, convert to pixels.
+        if (typeof optionValue === 'string' && /%$/.test(optionValue) && /height/i.test(option)) {
+          // Take offsets in account.
+          windowHeight -= displace.offsets.top + displace.offsets.bottom;
+          adjustedValue = parseInt(0.01 * parseInt(optionValue, 10) * windowHeight, 10);
+          // Don't force the dialog to be bigger vertically than needed.
+          if (option === 'height' && event.data.$element.parent().outerHeight() < adjustedValue) {
+            adjustedValue = 'auto';
+          }
+          adjustedOptions[option] = adjustedValue;
+        }
+      }
+    }
+    // Offset the dialog center to be at the center of Drupal.displace.offsets.
+    adjustedOptions = resetPosition(adjustedOptions);
+    event.data.$element
+      .dialog('option', adjustedOptions)
+      .trigger('dialogContentResize');
+  }
+
+  /**
+   * Position the dialog's center at the center of displace.offsets boundaries.
+   */
+  function resetPosition (options) {
+    var offsets = displace.offsets;
+    var left = offsets.left - offsets.right;
+    var top = offsets.top - offsets.bottom;
+
+    var leftString = (left > 0 ? '+' : '-') + Math.abs(Math.round(left/2)) + 'px';
+    var topString = (top > 0 ? '+' : '-') + Math.abs(Math.round(top/2)) + 'px';
+    options.position = {
+      my: 'center' + (left !== 0 ? leftString : '') + ' center' + (top !== 0 ? topString : '')
+    };
+    return options;
+  }
+
+  $(window).on({
+    'dialog:aftercreate': function (event, dialog, $element, settings) {
+      var autoResize = debounce(resetSize, 20);
+      var eventData = { settings: settings, $element: $element };
+      if (settings.autoResize === true || settings.autoResize === 'true') {
+        $element
+          .dialog('option', { resizable: false, draggable: false })
+          .dialog('widget').css('position', 'fixed');
+        $(window)
+          .on('resize.dialogResize scroll.dialogResize', eventData, autoResize)
+          .trigger('resize.dialogResize');
+        $(document).on('drupalViewportOffsetChange', eventData, autoResize);
+      }
+    },
+    'dialog:beforeclose': function (event, dialog, $element) {
+      $(window).off('.dialogResize');
+    }
+  });
+
+})(jQuery, Drupal, drupalSettings, Drupal.debounce, Drupal.displace);
diff --git a/core/misc/dialog/dialog.theme.css b/core/misc/dialog/dialog.theme.css
new file mode 100644
index 0000000..72c2fbc
--- /dev/null
+++ b/core/misc/dialog/dialog.theme.css
@@ -0,0 +1,66 @@
+/**
+ * Presentational styles for Drupal dialogs.
+ */
+
+.ui-dialog {
+  position: absolute;
+  z-index: 1260;
+  overflow: visible;
+  color: #000;
+  background: #fff;
+  border: solid 1px #ccc;
+  padding: 0;
+}
+.ui-dialog .ui-dialog-titlebar {
+  font-weight: bold;
+  background: #f3f4ee;
+  border-style: solid;
+  border-radius: 0;
+  border-width: 0 0 1px 0;
+  border-color: #ccc;
+}
+.ui-dialog .ui-dialog-titlebar-close {
+  border: 0;
+  background: none;
+}
+.ui-dialog .ui-dialog-buttonpane {
+  margin-top: 0;
+  background: #f3f4ee;
+  padding: .3em 1em;
+  border-width: 1px 0 0 0;
+  border-color: #ccc;
+}
+.ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset {
+  margin: 0;
+  padding: 0;
+}
+.ui-dialog .ui-dialog-buttonpane .ui-button-text-only .ui-button-text {
+  padding: 0;
+}
+
+/* Form action buttons are moved in dialogs. Remove empty space. */
+.ui-dialog .ui-dialog-content .form-actions {
+  padding: 0;
+  margin: 0;
+}
+.ui-dialog .ajax-progress-throbber {
+  /* Can't do center:50% middle: 50%, so approximate it for a typical window size. */
+  left: 49%;
+  position: fixed;
+  top: 48.5%;
+  z-index: 1000;
+  background-color: #232323;
+  background-image: url("../loading-small.gif");
+  background-position: center center;
+  background-repeat: no-repeat;
+  border-radius: 7px;
+  height: 24px;
+  opacity: 0.9;
+  padding: 4px;
+  width: 24px;
+}
+.ui-dialog .ajax-progress-throbber .throbber,
+.ui-dialog .ajax-progress-throbber .message {
+  display: none;
+}
+
diff --git a/core/modules/ckeditor/js/ckeditor.admin.js b/core/modules/ckeditor/js/ckeditor.admin.js
index 0e8f5b1..bad1b08 100644
--- a/core/modules/ckeditor/js/ckeditor.admin.js
+++ b/core/modules/ckeditor/js/ckeditor.admin.js
@@ -1356,14 +1356,13 @@ function openGroupNameDialog (view, $group, callback) {
         click: function () {
           closeDialog('apply', this);
         },
-        'class': 'button-primary button'
+        primary: true
       },
       {
         text: Drupal.t('Cancel'),
         click: function () {
           closeDialog('cancel');
         },
-        'class': 'button'
       }
     ],
     open: function () {
diff --git a/core/modules/edit/js/util.js b/core/modules/edit/js/util.js
index da7656e..ea9076f 100644
--- a/core/modules/edit/js/util.js
+++ b/core/modules/edit/js/util.js
@@ -50,7 +50,8 @@ Drupal.edit.util.networkErrorModal = function (title, message) {
         text: Drupal.t('OK'),
         click: function() {
           networkErrorModal.close();
-        }
+        },
+        primary: true
       }
     ],
     create: function () {
diff --git a/core/modules/edit/js/views/AppView.js b/core/modules/edit/js/views/AppView.js
index ba65c3e..aece8d0 100644
--- a/core/modules/edit/js/views/AppView.js
+++ b/core/modules/edit/js/views/AppView.js
@@ -360,7 +360,8 @@ Drupal.edit.AppView = Backbone.View.extend({
             text: Drupal.t('Save'),
             click: function() {
               closeDiscardDialog('save');
-            }
+            },
+            primary: true
           },
           {
             text: Drupal.t('Discard changes'),
diff --git a/core/modules/system/system.module b/core/modules/system/system.module
index fc6f61c..e702ade 100644
--- a/core/modules/system/system.module
+++ b/core/modules/system/system.module
@@ -969,11 +969,12 @@ function system_library_info() {
     'title' => 'Drupal Dialog',
     'version' => \Drupal::VERSION,
     'js' => array(
-      'core/misc/dialog.js' => array('group' => JS_LIBRARY),
-      'core/misc/dialog.position.js' => array('group' => JS_LIBRARY),
+      'core/misc/dialog/dialog.js' => array('group' => JS_LIBRARY),
+      'core/misc/dialog/dialog.position.js' => array('group' => JS_LIBRARY),
+      'core/misc/dialog/dialog.jquery-ui.js' => array('group' => JS_LIBRARY),
     ),
     'css' => array(
-      'core/misc/dialog.theme.css' => array('weight' => 1),
+      'core/misc/dialog/dialog.theme.css' => array('weight' => 1),
     ),
     'dependencies' => array(
       array('system', 'jquery'),
@@ -990,7 +991,7 @@ function system_library_info() {
     'title' => 'Drupal Dialog AJAX',
     'version' => \Drupal::VERSION,
     'js' => array(
-      'core/misc/dialog.ajax.js' => array('group' => JS_LIBRARY, 'weight' => 3),
+      'core/misc/dialog/dialog.ajax.js' => array('group' => JS_LIBRARY, 'weight' => 3),
     ),
     'dependencies' => array(
       array('system', 'jquery'),
diff --git a/core/themes/seven/dialog.theme.css b/core/themes/seven/dialog.theme.css
new file mode 100644
index 0000000..c569785
--- /dev/null
+++ b/core/themes/seven/dialog.theme.css
@@ -0,0 +1,83 @@
+/**
+ * Presentational styles for Drupal dialogs.
+ */
+
+.ui-dialog {
+  background: transparent;
+  border: 0;
+  position: absolute;
+  z-index: 1260;
+  overflow: visible;
+  padding: 0;
+}
+.ui-dialog .ui-dialog-titlebar {
+  background: rgba(107,107,107,0.65);
+  border-top-left-radius: 5px;
+  border-top-right-radius: 5px;
+  padding: 20px;
+}
+.ui-dialog .ui-dialog-title {
+  font-size: 22px;
+  font-weight: 600;
+  margin: 0;
+  color: #ffffff;
+  -webkit-font-smoothing: antialiased;
+}
+.ui-dialog .ui-dialog-titlebar-close {
+  border: 0;
+  background: none;
+  right: 20px;
+  top: 20px;
+  margin: 0;
+  height: 16px;
+  width: 16px;
+}
+.ui-dialog .ui-icon-closethick {
+  background: url('../../misc/icons/ffffff/ex.svg') 0 0 no-repeat;
+}
+.ui-dialog .ui-dialog-content {
+  background: #ffffff;
+}
+.ui-dialog .ui-dialog-buttonpane {
+  background: #f5f5f2;
+  border-top: 1px solid #bfbfbf;
+  margin: 0;
+  padding: 15px 20px;
+  border-bottom-left-radius: 5px;
+  border-bottom-right-radius: 5px;
+}
+.ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset {
+  margin: 0;
+  padding: 0;
+  float: none;
+}
+.ui-dialog .ui-dialog-buttonpane .ui-button-text-only .ui-button-text {
+  padding: 0;
+}
+
+/* Form action buttons are moved in dialogs. Remove empty space. */
+.ui-dialog .ui-dialog-content .form-actions {
+  padding: 0;
+  margin: 0;
+}
+.ui-dialog .ajax-progress-throbber {
+  /* Can't do center:50% middle: 50%, so approximate it for a typical window size. */
+  left: 49%;
+  position: fixed;
+  top: 48.5%;
+  z-index: 1000;
+  background-color: #232323;
+  background-image: url("loading-small.gif");
+  background-position: center center;
+  background-repeat: no-repeat;
+  border-radius: 7px;
+  height: 24px;
+  opacity: 0.9;
+  padding: 4px;
+  width: 24px;
+}
+.ui-dialog .ajax-progress-throbber .throbber,
+.ui-dialog .ajax-progress-throbber .message {
+  display: none;
+}
+
diff --git a/core/themes/seven/seven.info.yml b/core/themes/seven/seven.info.yml
index 582b498..3cc5c6d 100644
--- a/core/themes/seven/seven.info.yml
+++ b/core/themes/seven/seven.info.yml
@@ -13,6 +13,7 @@ stylesheets:
 stylesheets-override:
   - vertical-tabs.css
   - jquery.ui.theme.css
+  - dialog.theme.css
 edit_stylesheets:
   - edit.css
 settings:
