Преглед изворни кода

Fixed Trac #371: popup dialog's dimensions (welcome screen and create or lookup dialogs) are now adjusted to fit into the screen.

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@1183 a333f486-631f-4898-b8df-5754b55c2be0
dflaven пре 14 година
родитељ
комит
981aa5d70f
3 измењених фајлова са 25 додато и 2 уклоњено
  1. 2 1
      application/ui.extkeywidget.class.inc.php
  2. 18 0
      js/extkeywidget.js
  3. 5 1
      pages/UI.php

+ 2 - 1
application/ui.extkeywidget.class.inc.php

@@ -267,7 +267,8 @@ EOF
 		$oPage->add("<h1>".MetaModel::GetClassIcon($this->sTargetClass)."&nbsp;".Dict::Format('UI:CreationTitle_Class', MetaModel::GetName($this->sTargetClass))."</h1>\n");
 	 	cmdbAbstractObject::DisplayCreationForm($oPage, $this->sTargetClass, null, array(), array('formPrefix' => $this->iId, 'noRelations' => true));	
 		$oPage->add('</div></div></div>');
-			$oPage->add_ready_script("\$('#ac_create_$this->iId').dialog({ width: $(window).width()*0.8, height: 'auto', autoOpen: false, modal: true, title: '$sDialogTitle'});\n");
+//		$oPage->add_ready_script("\$('#ac_create_$this->iId').dialog({ width: $(window).width()*0.8, height: 'auto', autoOpen: false, modal: true, title: '$sDialogTitle'});\n");
+		$oPage->add_ready_script("\$('#ac_create_$this->iId').dialog({ width: 'auto', height: 'auto', autoOpen: false, modal: true, title: '$sDialogTitle'});\n");
 		$oPage->add_ready_script("$('#dcr_{$this->iId} form').removeAttr('onsubmit');");
 		$oPage->add_ready_script("$('#dcr_{$this->iId} form').bind('submit.uilinksWizard', oACWidget_{$this->iId}.DoCreateObject);");
 	}

+ 18 - 0
js/extkeywidget.js

@@ -54,6 +54,15 @@ function ExtKeyWidget(id, sClass, sAttCode, sSuffix, bSelectMode, oWizHelper)
 	this.UpdateSizes = function()
 	{
 		var dlg = $('#ac_dlg_'+me.id);
+		// Adjust the dialog's size to fit into the screen
+		if (dlg.width() > ($(window).width()-40))
+		{
+			dlg.width($(window).width()-40);
+		}
+		if (dlg.height() > ($(window).height()-70))
+		{
+			dlg.height($(window).height()-70);
+		}
 		var searchForm = dlg.find('div.display_block:first'); // Top search form, enclosing display_block
 		var results = $('#dr_'+me.id);
 		padding_right = parseInt(dlg.css('padding-right').replace('px', ''));
@@ -224,6 +233,15 @@ function ExtKeyWidget(id, sClass, sAttCode, sSuffix, bSelectMode, oWizHelper)
 				// Modify the action of the cancel button
 				$('#ac_create_'+me.id+' button.cancel').unbind('click').click( me.CloseCreateObject );
 				me.ajax_request = null;
+				// Adjust the dialog's size to fit into the screen
+				if ($('#ac_create_'+me.id).width() > ($(window).width()-40))
+				{
+					$('#ac_create_'+me.id).width($(window).width()-40);
+				}
+				if ($('#ac_create_'+me.id).height() > ($(window).height()-70))
+				{
+					$('#ac_create_'+me.id).height($(window).height()-70);
+				}
 			},
 			'html'
 		);

+ 5 - 1
pages/UI.php

@@ -420,12 +420,16 @@ function DisplayWelcomePopup(WebPage $oP)
 				$sTitle = addslashes(Dict::S('UI:WelcomeMenu:Title'));
 				$oP->add_ready_script(
 <<<EOF
-	$('#welcome_popup').dialog( { width:'80%', title: '$sTitle', autoOpen: true, modal:true,
+	$('#welcome_popup').dialog( { width:'80%', height: 'auto', title: '$sTitle', autoOpen: true, modal:true,
 								  close: function() {
 								  	var bDisplay = $('#display_welcome_popup:checked').length;
 								  	SetUserPreference('welcome_popup', bDisplay, true); 
 								  }
 								  });
+	if ($('#welcome_popup').height() > ($(window).height()-70))
+	{
+		$('#welcome_popup').height($(window).height()-70);
+	}
 EOF
 );
 				$_SESSION['welcome'] = 'ok';