# This patch file was generated by NetBeans IDE
# Following Index: paths are relative to: /var/www/html/zabbix/trunk/frontends
# This patch can be applied using context Tools: Patch action on respective folder.
# It uses platform neutral UTF-8 encoding and \n newlines.
# Above lines and this line are ignored by the patching process.
Index: php/app/views/monitoring.dashboard.view.js.php
--- php/app/views/monitoring.dashboard.view.js.php Base (BASE)
+++ php/app/views/monitoring.dashboard.view.js.php Locally Modified (Based On LOCAL)
@@ -63,11 +63,14 @@
 <script type="text/javascript">
 	// Change dashboard settings.
 	function dashbrd_config() {
-		var form = jQuery('form[name="dashboard_form"]');
+		var form = jQuery('form[name="dashboard_form"]'),
+			defer = jQuery.Deferred();
+
 		showDialogForm(
 			form,
 			{"title": "<?= _('Dashboard properties') ?>", "action_title": "<?= _('Apply') ?>"},
-			{"name": form.data('data').name, "owner": form.data('data').owner}
+			{"name": form.data('data').name, "owner": form.data('data').owner},
+			defer
 		);
 	};
 
@@ -154,8 +157,8 @@
 	}
 
 	// Function is in global scope, because it should be accessable by html onchange() attribute.
-	function updateWidgetConfigDialogue() {
-		jQuery('.dashbrd-grid-widget-container').dashboardGrid('updateWidgetConfigDialogue');
+	function updateWidgetConfigDialogue(defer) {
+		jQuery('.dashbrd-grid-widget-container').dashboardGrid('updateWidgetConfigDialogue', defer);
 	}
 
 	/**
Index: php/include/views/js/monitoring.slides.js.php
--- php/include/views/js/monitoring.slides.js.php Base (BASE)
+++ php/include/views/js/monitoring.slides.js.php Locally Modified (Based On LOCAL)
Index: php/js/class.cnavtree.js
--- php/js/class.cnavtree.js Base (BASE)
+++ php/js/class.cnavtree.js Locally Modified (Based On LOCAL)
@@ -615,6 +615,7 @@
 				}
 
 				url.setArgument('action', 'widget.navigationtree.edititemdialog');
+				var defer = jQuery.Deferred()
 
 				jQuery.ajax({
 					url: url.getUrl(),
@@ -739,7 +740,10 @@
 									'action': function() {}
 								}
 							]
-						});
+						}, defer);
+					},
+					complete: function() {
+						defer.notify();
 					}
 				});
 			};
Index: php/js/dashboard.grid.js
--- php/js/dashboard.grid.js Base (BASE)
+++ php/js/dashboard.grid.js Locally Modified (Based On LOCAL)
@@ -672,6 +672,7 @@
 		var edit_mode = (widget !== null);
 
 		data.dialogue = {};
+		data.dialogue.defer = jQuery.Deferred();
 		data.dialogue.widget = widget;
 
 		overlayDialogue({
@@ -692,7 +693,7 @@
 					'action': function() {}
 				}
 			]
-		});
+		}, data.dialogue.defer);
 
 		var overlay_dialogue = $('#overlay_dialogue');
 		data.dialogue.div = overlay_dialogue;
@@ -1238,6 +1239,7 @@
 					footer = $('.overlay-dialogue-footer', data.dialogue['div']),
 					form = $('form', body),
 					widget = data.dialogue['widget'], // widget currently beeing edited
+					defer = data.dialogue.defer || null,
 					url = new Curl('zabbix.php'),
 					ajax_data = {},
 					fields;
@@ -1308,6 +1310,9 @@
 						$('.dialogue-widget-save', footer).prop('disabled', false);
 					},
 					complete: function() {
+						if (defer) {
+							defer.notify();
+						}
 						overlayDialogueOnLoad(true);
 					}
 				});
Index: php/js/functions.js
--- php/js/functions.js Base (BASE)
+++ php/js/functions.js Locally Modified (Based On LOCAL)
@@ -528,10 +528,12 @@
  * @param {bool}   params.buttons[]['focused']   (optional) Focus this button.
  * @param {bool}   params.buttons[]['enabled']   (optional) Should the button be enabled? Default: true.
  * @param {bool}   params.buttons[]['keepOpen']  (optional) Prevent dialogue closing, if button action returned false.
+ * @param {object} defer						 (optional) jQuery.Deferred() object used to trigger resizing once the
+ *												 'notify' method is called
  *
  * @return {bool}
  */
-function overlayDialogue(params) {
+function overlayDialogue(params, defer) {
 	jQuery('<div>', {
 		id: 'overlay_bg',
 		class: 'overlay-bg'
@@ -540,6 +542,7 @@
 
 	var button_focused = null,
 		cancel_action = null,
+		defer = defer || null,
 		overlay_dialogue_footer = jQuery('<div>', {
 			class: 'overlay-dialogue-footer'
 		});
@@ -616,8 +619,32 @@
 				return false;
 			}
 		})
+		.css({'visibility': 'hidden'})
 		.appendTo('body');
 
+	if (defer) {
+		// Triggers modal window resize each time when defer.notify() is called.
+		jQuery.when(defer).progress(function() {
+			overlay_dialogue.css({
+				'left': Math.round((jQuery(window.top).width() - jQuery(overlay_dialogue).width()) / 2) + 'px',
+				'top': Math.round((jQuery(window.top).height() - jQuery(overlay_dialogue).height()) / 2) + 'px',
+				'visibility': 'visible'
+			});
+		});
+
+		jQuery(window).resize(function() {
+			if (jQuery('#overlay_dialogue').length) {
+				defer.notify();
+			}
+		});
+	}
+	else {
+		// This will center dialog in old way if defer is not passed.
+		overlay_dialogue
+			.css('visibility', 'visible')
+			.addClass('autocentered');
+	}
+
 	var focusable = jQuery(':focusable', overlay_dialogue);
 
 	if (focusable.length > 0) {
Index: php/js/menupopup.js
--- php/js/menupopup.js Base (BASE)
+++ php/js/menupopup.js Locally Modified (Based On LOCAL)
@@ -484,7 +484,8 @@
 					item.clickCallback = function () {
 						var	obj = jQuery(this),
 							url = new Curl('zabbix.php'),
-							error_message = t('Something went wrong. Please try again later!');
+							error_message = t('Something went wrong. Please try again later!'),
+							defer = jQuery.Deferred();
 						url.setArgument('action', 'dashboard.get');
 
 						jQuery.ajax({
@@ -496,7 +497,7 @@
 									var form = jQuery('form[name="dashboard_sharing_form"]');
 
 									showDialogForm(form, {"title": t('Dashboard sharing'), "action_title": t('Update')},
-										response.data
+										response.data, defer
 									);
 								}
 								else if (typeof response === 'string' && response.indexOf(t('Access denied')) !== -1) {
@@ -506,6 +507,9 @@
 									alert(error_message);
 								}
 							},
+							complete: function() {
+								defer.notify();
+							},
 							error: function() {
 								alert(error_message);
 							}
@@ -538,10 +542,12 @@
 	return [{label: options.label, items: options.items}];
 }
 
-function showDialogForm(form, options, formData) {
+function showDialogForm(form, options, formData, defer) {
 
 	var oldFormParent = form.parent(),
-		errorBlockId = 'dialog-form-error-container';
+		errorBlockId = 'dialog-form-error-container',
+		defer = defer || null;
+
 	// trick to get outerWidth, outerHeight of "display:none" form
 	form.css('visibility', 'hidden');
 	form.css('display', 'block');
@@ -594,11 +600,15 @@
 				}
 			}
 		]
-	});
+	}, defer);
 
 	form.css('visibility', 'visible');
 	overlayDialogueOnLoad(true);
+
+	if (defer) {
+		defer.notify();
 }
+}
 
 /**
  * Get menu popup trigger section data.
