Bug #15105
closedshowpic.php does not resize the popup size if necessary
Added by old_martinficzel about 19 years ago. Updated over 13 years ago.
0%
Description
if the image popup (click enlarge) is not closed before opening a new one it is not resized proeperly. I think with javascript it's not a big deal to close an evntually existing showpic frame befor opening a new one.
Additionally a mechanism for templating the whole showpic.php would be nice but is harder to implement.
(issue imported from #M1666)
Files
openPic.js (231 Bytes) openPic.js | Administrator Admin, 2005-10-19 18:14 | ||
showpic-resize-patch.txt (814 Bytes) showpic-resize-patch.txt | Administrator Admin, 2005-11-14 18:30 |
Updated by Mathias Schreiber about 19 years ago
I think this can be done within the body tag by resizing the window depending on the loaded image.
This does not really need a core change since this can be done with typoscript alone
Updated by old_martinficzel about 19 years ago
" I think this can be done within the body tag"
Thats partly true but resizing the window using JS is imho not working with all browsers. So i would prefer a solution wich checks wheather a popup window exists and if so closes it before opening the new one.
The point is that the js Function openPic is defined in class.tslib_fe.php so a user cannot change the javascript easily. Maybe thats a gremlin to.
This is the old function
function openPic(url,winName,winParams) { //
var theWindow = window.open(url,winName,winParams);
if (theWindow) {theWindow.focus();}
}
I would like to do something like that
function openPic(url,winName,winParams) { //
// find the window with name winName
// if a window is found close it
var theWindow = window.open(url,winName,winParams);
if (theWindow) {theWindow.focus();}
}
if it's welcome i will write the javascript lines and post them here later this day
Updated by old_martinficzel about 19 years ago
I uploaded an alternative js function wich closes the popup window before opening a new one with the correct size.
it's quite simple and i patched it into my typo3 3.8 without any problems
function openPic(url,winName,winParams) { //
var theWindow;
theWindow = window.open("",winName);
if (theWindow) {theWindow.close();}
theWindow = window.open(url,winName,winParams);
if (theWindow) {theWindow.focus();}
}
File : tslib/class.tslib_fe.php
Function: setJS
Line : 3416ff
i will try to provide a diff patch but i have to find out how that works with eclipse
i tested with :
Konqueror, Explorer6, Firefox :: are working well
Opera :: seems at least my opera does not like that (quite old version)
Updated by old_martinficzel about 19 years ago
Index: class.tslib_fe.php
===================================================================
RCS file: /cvsroot/typo3/TYPO3core/typo3/sysext/cms/tslib/class.tslib_fe.php,v
retrieving revision 1.78
diff u -r1.78 class.tslib_fe.php class.tslib_fe.php 30 Apr 2005 17:54:42
--0000 1.78>additionalJavaScript[$key]=
++ class.tslib_fe.php 19 Oct 2005 16:54:52 -0000@ -3414,8 +3414,11
@
case 'openPic':
$this
' function openPic(url,winName,winParams) { //
- var theWindow = window.open(url,winName,winParams);
- if (theWindow) {theWindow.focus();}
var theWindow;
+ theWindow = window.open("",winName);
+ if (theWindow) {theWindow.close();}
+ theWindow = window.open(url,winName,winParams);
+ if (theWindow) {theWindow.focus();}
}';
break;
default:
Updated by old_martinficzel about 19 years ago
I just testet the actual opera release and the javascript is working with the current opera too. Maybe my old Version was buggy.
Updated by old_martinficzel about 19 years ago
why is there no response?
[ ] problem is irrelevant
[ ] solution is a browser hack
[ ] known problems with the solution
Updated by Sebastian Kurfuerst about 19 years ago
Hi,
this bug did not get my attention yet. I'll have a look at it.
Greets, Sebastian
Updated by Sebastian Kurfuerst about 19 years ago
Hi Martin,
is it possible for you to attach a unified diff file to this report? Thanks :-)
Sebastian
Updated by Sebastian Kurfuerst about 19 years ago
Hi,
does the following line
theWindow = window.open("",winName,winParams);
work in all browsers? Do I get this right that that's a kind of "browser hack"?
Greets, Sebastian
Updated by Martin Ficzel about 19 years ago
i tested sucesssfully with :
Konqueror, Explorer6, Firefox, Opera
an old installation of Opera did not work( but the whole opera installation was buggy ) after installing a new opera everything worked like a charm.
jes it is something like a browser hack:
it is necessary because there is no direct way to get a handle for a window("name") with js. storing the window handle in js does not work if the main page is reloaded. so the only solution is the suggested one since a window.open("name") within the same domain will always open the same browser window. so "theWindow = window.open("",winName,winParams);" is the solution to get a handle to the window.
the only alternative i know would be a javascript timeout in the popup window that is storing a win-handle variable in the opener window. also not a nice solution and more problematic because of several cross window scripting limitations between different browsers.
regards Martin
Updated by old_martinficzel almost 19 years ago
maybe it's more accaptable to create options for overwriting the default javascript code. especially because hardcoding the js-functions is really not elegant.
that would make it possible for the users to create every popup function they like.
Updated by Michael Stucki almost 19 years ago
I have a question:
What you do is to open a window using an existing name and close it right after that. Why do you do that? Wouldn't it be enought to start with "window.close(theWindow)" and just continue like before.
In case the window was not there, you can probably use try/catch functions like it is done with AJAX.
Updated by old_martinficzel almost 19 years ago
that would work only if the main page is not reloaded.
since theWindow is a js-variable wich will be deletet as soon as the page is changed.
there is definitley no js-solution to get a handle to the window of name "winName" that would make the solution more beatiful.
the solution i use makes use of the fact that in within the same domain an js-operation open("winName".... ) will open a new window or the one with the same name already opened from the requesting domain. this point is standard compliant.
the things wich are a little bit strange are:
1: the url "" (i dont know a standard for that but in all browsers i know that means a blank page. (even if a past / future browser thinks that "" means a different page the script would still work)
2. to open, close and reopen a window in the same javascript.
there are other solutions possible:
1. make a timeout in the popup window wich is restoring the theWindow variable in the opener window so even after reloading the main page the variable would exist and the solution you suggested would work. given that the window would become a global js variable. i tried this several times an could'nt find a good looking solution wich works in all browsers.
2. open the page and use resize to command
function openPic(url,winName,winParams) { //
var theWindow;
theWindow = window.open( url, winName, winParams );
if (theWindow) {
var theWidth = // find width in winParams
var theHeight = // find height in winParams
if ( theWidth && theHeight ) {
theWindow.resizeTo( theWidth , theHeight )
}
theWindow.focus();
}
}
the problem with this solution is that the winParams would have to be parsed und the values for width and height would have to be extracted. the command is using the external size of the window so different browsers cause different inner sizes. if you prefer such a sulution i can try to create a patch with such a code.
redards Martin
Updated by Michael Bernhard over 18 years ago
Principally Your code works fine: window close and window (re)open
But unfortunately there is a big disfigurement now - with the changed code the pop-up-blocker in IE gets its attention on the procedure.
Before the blocker did not care about.
Is this because of the "hack"?
Updated by old_martinficzel over 18 years ago
"with the changed code the pop-up-blocker in IE gets its attention on the procedure. Before the blocker did not care about."
i dont know and i did'nt test the code for i while. do you mean ie7? as long as i remember i always had to enable popups. but i normally use firefox and i'm not shure wich is the default behavior in ie. i tested all available browers when i made the patch and i dont remember any changed behavior.
i see 3 options
1. make the js code configurable and leave the current code as default. (maybe a good idea for other js code in the core too)
2. leave everything as ist is and provide an extension with the features (wich would have to use xclassing)
3. make it a ts-option and include 2 different versions (wich would combine the loss of flexibility with another new ts-option)
i vote for 1
Updated by Michael Bernhard over 18 years ago
I tested IE6 (6.0.2900.2180...sp2...- using windows update) and IE7 Beta3 - both the same.
I use the standard security settings, I think I never changed anything, but I am not 100% sure because of using it for a while.
I watched the phenomenon sometimes before that with some websites the blocker blocks, and sometimes not. I know with the IE7 Beta on my notebook I allowed pop-ups explicit for for specific sites. But I did never allow that to my own server because of testing.
I will research a bit more about the functionality of the different pop-up-blockers.
Updated by Marc Bastian Heinrichs about 18 years ago
The closing/reopen solution doen't work correct in Firefox for me cause clicking an image first time another tab gets the focus and the image popup is in background.
my solution:
adding following javascriptfunction to showpic and call it with body onload
function resize() {
if (document.all) {
bodyWidth = document.body.clientWidth;
bodyHeight = document.body.clientHeight;
widthOffset = '.$imgInfo[0].' - bodyWidth;
heightOffset = '.$imgInfo[1].' - bodyHeight;
window.resizeBy(widthOffset, heightOffset);
} else {
window.innerWidth = '.$imgInfo[0].';
window.innerHeight = '.$imgInfo[1].';
}
}
Updated by Benni Mack over 14 years ago
Hey Marc,
care to write a patch for your solution and send it to the core list?
Thanks.
Updated by Dmitry Dulepov over 13 years ago
- Status changed from Needs Feedback to Closed
- Target version deleted (
0) - TYPO3 Version changed from 3.8.0 to 4.2
- PHP Version deleted (
4)
No feedback provided within 90 days. Closing the issue.