summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwebchick2013-09-27 12:34:52 (GMT)
committerwebchick2013-09-27 12:34:52 (GMT)
commit82f8f24dc2bb12f8c0a3c552e1cc82b26e2ba522 (patch)
tree6c22f9302f1f6698186971148d7497683fd87766
parentab6961d0d8ce388c933dc50808584ad55e6f170a (diff)
Issue #2095225 by nod_, pameeela: Fixed Scrolling is broken on modals.
-rw-r--r--core/misc/dialog.js33
-rw-r--r--core/modules/ckeditor/js/ckeditor.js4
2 files changed, 21 insertions, 16 deletions
diff --git a/core/misc/dialog.js b/core/misc/dialog.js
index 44fd736..94f2101 100644
--- a/core/misc/dialog.js
+++ b/core/misc/dialog.js
@@ -10,10 +10,12 @@
drupalSettings.dialog = {
autoOpen: true,
+ // This option will turn off resizable and draggable.
autoResize: true,
+ maxHeight: '95%',
dialogClass: '',
- close: function (e) {
- Drupal.detachBehaviors(e.target, null, 'unload');
+ close: function (event) {
+ Drupal.detachBehaviors(event.target, null, 'unload');
}
};
@@ -24,9 +26,13 @@ Drupal.dialog = function (element, options) {
// Trigger a global event to allow scripts to bind events to the dialog.
$(window).trigger('dialog:beforecreate', [dialog, $element, settings]);
$element.dialog(settings);
- if (settings.autoResize !== 'false' && settings.autoResize !== false) {
- $(window).on('resize.dialogResize scroll.dialogResize', autoResize);
- resetPosition();
+ 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', settings, autoResize)
+ .trigger('resize.dialogResize');
}
dialog.open = true;
$(window).trigger('dialog:aftercreate', [dialog, $element, settings]);
@@ -49,22 +55,23 @@ Drupal.dialog = function (element, options) {
* be disabled by setting autoResize: false in the options array when creating
* a new Drupal.dialog().
*/
- function resetPosition () {
+ function resetPosition (event) {
var positionOptions = ['width', 'height', 'minWidth', 'minHeight', 'maxHeight', 'maxWidth', 'position'];
var windowHeight = $(window).height();
- var adjustedOptions = $.extend({ position: { my: "center", at: "center", of: window }}, options);
- var optionValue, adjustedValue;
+ var adjustedOptions = {};
+ var option, optionValue, adjustedValue;
for (var n = 0; n < positionOptions.length; n++) {
- if (adjustedOptions[positionOptions[n]]) {
- optionValue = adjustedOptions[positionOptions[n]];
+ option = positionOptions[n];
+ optionValue = event.data[option];
+ if (optionValue) {
// jQuery UI does not support percentages on heights, convert to pixels.
- if (positionOptions[n].match(/height/i) && typeof optionValue === 'string' && optionValue.match(/%$/)) {
+ if (typeof optionValue === 'string' && /%$/.test(optionValue) && /height/i.test(option)) {
adjustedValue = parseInt(0.01 * parseInt(optionValue, 10) * windowHeight, 10);
// Don't force the dialog to be bigger vertically than needed.
- if (positionOptions[n] === 'height' && $element.parent().outerHeight() < adjustedValue) {
+ if (option === 'height' && $element.parent().outerHeight() < adjustedValue) {
adjustedValue = 'auto';
}
- adjustedOptions[positionOptions[n]] = adjustedValue;
+ adjustedOptions[option] = adjustedValue;
}
}
}
diff --git a/core/modules/ckeditor/js/ckeditor.js b/core/modules/ckeditor/js/ckeditor.js
index 140f031..2d1d426 100644
--- a/core/modules/ckeditor/js/ckeditor.js
+++ b/core/modules/ckeditor/js/ckeditor.js
@@ -217,9 +217,7 @@ Drupal.ckeditor = {
var classes = dialogSettings.dialogClass ? dialogSettings.dialogClass.split(' ') : [];
classes.push('editor-dialog');
dialogSettings.dialogClass = classes.join(' ');
- dialogSettings.maxHeight = '95%';
- dialogSettings.resizable = false;
- dialogSettings.autoResize = $(window).width() > 600;
+ dialogSettings.autoResize = Drupal.checkWidthBreakpoint(600);
// Add a "Loadingā€¦" message, hide it underneath the CKEditor toolbar, create
// a Drupal.ajax instance to load the dialog and trigger it.