This topic is locked
[SOLVED]

 Resizing popup

2/25/2020 2:54:10 PM
PHPRunner General questions
E
Eddy Keuninckx author

Hi,
I have a master and detail. When I click to add a new detail from within the master, a popup will open to add a new detail. Is there a way to resize that window because it's to small?
Cheers

W
WilliamBDevClub member 2/25/2020



Hi,
I have a master and detail. When I click to add a new detail from within the master, a popup will open to add a new detail. Is there a way to resize that window because it's to small?
Cheers


Have a look at this https://asprunner.com/forums/topic/23853-bootstrap-add-edit-popup-window-resize/

E
Eddy Keuninckx author 2/25/2020

Thanks for the swift reply!
I tried it, but it only change the position of that popup, not the size.
Possibly I did something wrong. I added this code to the "Javascript OnLoad event" for the "Add page":

//================================Start Popup Window Resize ==================================

//Conditional is to prevent error log from firing when we open this page not via popup (ex: right click open new tab)

if(this.bsWin){

console.log('Yes, opened as a popup');
var widgetNode = $( this.bsWin[0].childNodes[0] );
if (window.screen) {
popup_screen_pct_width = 100;

popup_screen_pct_height = 100;
w = window.screen.availWidth popup_screen_pct_width / 100;

h = window.screen.availHeight
popup_screen_pct_height / 100;
top_pos = (100 - popup_screen_pct_height ) / 2; //give us the left positioning percentage distance to use

top_pos += '%';
};
widgetNode_height = h;
widgetNode_width = w;
widgetNode.css({'height':widgetNode_height, 'width':widgetNode_width,'top': top_pos});
}else{

console.log('No, not opened in a popup');

}

//================================End Popup Window Resize ==================================

E
Eddy Keuninckx author 2/25/2020

This code worked, thanks:

//================================Start Popup Window Resize ==================================

//Conditional is to prevent error log from firing when we open this page not via popup (ex: right click open new tab)

//We default to 90% height and 70% width if not defined

function customPopupSizeController( pct_height = 100, pct_width = 100 , popup_object = pageObj){

//check if mobile device and if so exit function alltogether

if( navigator.userAgent.match(/Android/i)

|| navigator.userAgent.match(/webOS/i)

|| navigator.userAgent.match(/iPhone/i)

|| navigator.userAgent.match(/iPad/i)

|| navigator.userAgent.match(/iPod/i)

|| navigator.userAgent.match(/BlackBerry/i)

|| navigator.userAgent.match(/Windows Phone/i))

{

return true;

}

if(popup_object.bsWin){

console.log('Yes, opened as a popup');
var widgetNodeMain = $( popup_object.bsWin[0].childNodes[0] );//MODAL MAIN (aka div with class "modal-dialog ui-draggable" )
var widgetNodeContent = $( widgetNodeMain[0].childNodes[0] );//MODAL CONTENT
var widgetNodeHeader = $( widgetNodeContent[0].childNodes[0] );//MODAL HEADER
var widgetNodeBody = $( widgetNodeContent[0].childNodes[1] );//MODAL BODY
var widgetNodeFooter = $( widgetNodeContent[0].childNodes[2] );//MODAL FOOTER
if (window.screen) {
w = window.innerWidth pct_width / 100;

h = window.innerHeight
pct_height / 100;
top_pos = (window.innerHeight - h ) / 2;//help us center this on screen

top_pos += 'px';
};
widget_height = h + 'px';

widget_width = w + 'px';
widget_body_height = ( h - widgetNodeHeader[0].clientHeight - widgetNodeFooter[0].clientHeight ) + 'px';
widgetNodeMain.css({'height': widget_height, 'width': widget_width, 'top': top_pos, 'margin-top': '0px'});//aka div with class " modal-dialog ui-draggable

widgetNodeContent.css({'height': widget_height, 'width': '100%'});//aka div with class "modal-content ui-resizable"

widgetNodeBody.css({'height':widget_body_height, 'width': '100%'}); //aka div with class "modal-body"
}else{

console.log('No, not opened in a popup');

}

}

//================================End Popup Window Resize ==================================;
customPopupSizeController( 95, 95 );//call this function passing in height and width as percentage
Credits for FunkDaddy