mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-29 01:59:39 +01:00
moving egw_openWindowCentered() to egw(window).openPopup()
This commit is contained in:
parent
e6cf7c95d3
commit
fa0a10a840
@ -49,9 +49,6 @@ var fw_base = Class.extend({
|
|||||||
//Register the key press handler
|
//Register the key press handler
|
||||||
//$j(document).keypress(this.keyPressHandler);
|
//$j(document).keypress(this.keyPressHandler);
|
||||||
|
|
||||||
//Override the old egw_openWindowCentered2
|
|
||||||
window.egw_openWindowCentered2 = this.egw_openWindowCentered2;
|
|
||||||
|
|
||||||
//Override the app_window function
|
//Override the app_window function
|
||||||
window.egw_appWindow = this.egw_appWindow;
|
window.egw_appWindow = this.egw_appWindow;
|
||||||
|
|
||||||
@ -731,26 +728,19 @@ var fw_base = Class.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Opens popup window at the center
|
* Open a (centered) popup window with given size and url
|
||||||
*
|
*
|
||||||
* @param {type} _url popup url
|
* @param {string} _url
|
||||||
* @param {type} _windowName name of popup window
|
* @param {number} _width
|
||||||
* @param {type} _width width of window
|
* @param {number} _height
|
||||||
* @param {type} _height height of window
|
* @param {string} _windowName or "_blank"
|
||||||
* @param {type} _status
|
* @param {string|boolean} _app app-name for framework to set correct opener or false for current app
|
||||||
* @param {type} _app application which popup belongs to it
|
* @param {boolean} _returnID true: return window, false: return undefined
|
||||||
* @param {type} _returnID
|
* @param {type} _status "yes" or "no" to display status bar of popup
|
||||||
* @returns {window} returns window
|
* @returns {DOMWindow|undefined}
|
||||||
*/
|
*/
|
||||||
egw_openWindowCentered2: function(_url, _windowName, _width, _height, _status, _app, _returnID)
|
openPopup: function(_url, _width, _height, _windowName, _app, _returnID, _status)
|
||||||
{
|
{
|
||||||
if (typeof _returnID == 'undefined') _returnID = false;
|
|
||||||
var windowWidth = egw_getWindowOuterWidth();
|
|
||||||
var windowHeight = egw_getWindowOuterHeight();
|
|
||||||
|
|
||||||
var positionLeft = (windowWidth/2)-(_width/2)+egw_getWindowLeft();
|
|
||||||
var positionTop = (windowHeight/2)-(_height/2)+egw_getWindowTop();
|
|
||||||
|
|
||||||
//Determine the window the popup should be opened in - normally this is the iframe of the currently active application
|
//Determine the window the popup should be opened in - normally this is the iframe of the currently active application
|
||||||
var parentWindow = window;
|
var parentWindow = window;
|
||||||
var navigate = false;
|
var navigate = false;
|
||||||
@ -771,27 +761,16 @@ var fw_base = Class.extend({
|
|||||||
if (appEntry != null && appEntry.browser.iframe != null)
|
if (appEntry != null && appEntry.browser.iframe != null)
|
||||||
parentWindow = appEntry.browser.iframe.contentWindow;
|
parentWindow = appEntry.browser.iframe.contentWindow;
|
||||||
|
|
||||||
var windowID = parentWindow.open(_url, _windowName, "width=" + _width + ",height=" + _height +
|
var windowID = egw(parentWindow).openPopup(_url, _width, _height, _windowName, _app, true, _status, true);
|
||||||
",screenX=" + positionLeft + ",left=" + positionLeft + ",screenY=" + positionTop + ",top=" + positionTop +
|
|
||||||
",location=no,menubar=no,directories=no,toolbar=no,scrollbars=yes,resizable=yes,status="+_status);
|
|
||||||
|
|
||||||
// inject framework and egw object, because opener might not yet be loaded and therefore has no egw object!
|
windowID.framework = this;
|
||||||
windowID.egw = window.egw;
|
|
||||||
windowID.framework = framework;
|
|
||||||
|
|
||||||
if (navigate)
|
if (navigate)
|
||||||
{
|
{
|
||||||
window.setTimeout("framework.applicationTabNavigate(framework.activeApp, framework.activeApp.indexUrl);", 500);
|
window.setTimeout("framework.applicationTabNavigate(framework.activeApp, framework.activeApp.indexUrl);", 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_returnID === false)
|
if (_returnID !== false) return windowID;
|
||||||
{
|
|
||||||
// return nothing
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return windowID;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -280,14 +280,7 @@ egw.extend('open', egw.MODULE_WND_LOCAL, function(_egw, _wnd)
|
|||||||
{
|
{
|
||||||
var w_h = _popup.split('x');
|
var w_h = _popup.split('x');
|
||||||
if (w_h[1] == 'availHeight') w_h[1] = this.availHeight();
|
if (w_h[1] == 'availHeight') w_h[1] = this.availHeight();
|
||||||
if (_wnd.framework && (egwIsMobile() || egw.preference('theme') == 'mobile'))
|
var popup_window = this.openPopup(url, w_h[0], w_h[1], _target || '_blank', _target_app, true);
|
||||||
{
|
|
||||||
var popup_window = _wnd.framework.egw_openWindowCentered2(url, _target || '_blank', w_h[0], w_h[1], false, _target_app, true, _wnd);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var popup_window = _wnd.egw_openWindowCentered2(url, _target || '_blank', w_h[0], w_h[1], false, _target_app, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remember which windows are open
|
// Remember which windows are open
|
||||||
egw().storeWindow(_target_app, popup_window);
|
egw().storeWindow(_target_app, popup_window);
|
||||||
@ -310,6 +303,51 @@ egw.extend('open', egw.MODULE_WND_LOCAL, function(_egw, _wnd)
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open a (centered) popup window with given size and url
|
||||||
|
*
|
||||||
|
* @param {string} _url
|
||||||
|
* @param {number} _width
|
||||||
|
* @param {number} _height
|
||||||
|
* @param {string} _windowName or "_blank"
|
||||||
|
* @param {string|boolean} _app app-name for framework to set correct opener or false for current app
|
||||||
|
* @param {boolean} _returnID true: return window, false: return undefined
|
||||||
|
* @param {string} _status "yes" or "no" to display status bar of popup
|
||||||
|
* @param {boolean} _skip_framework
|
||||||
|
* @returns {DOMWindow|undefined}
|
||||||
|
*/
|
||||||
|
openPopup: function(_url, _width, _height, _windowName, _app, _returnID, _status, _skip_framework)
|
||||||
|
{
|
||||||
|
// Log for debugging purposes
|
||||||
|
egw.debug("navigation", "openPopup(%s, %s, %s, %o, %s, %s)",_url,_windowName,_width,_height,_status,_app);
|
||||||
|
|
||||||
|
// if we have a framework and we use mobile template --> let framework deal with opening popups
|
||||||
|
if (!_skip_framework && _wnd.framework)
|
||||||
|
{
|
||||||
|
return _wnd.framework.openPopup(_url, _width, _height, _windowName, _app, _returnID, _status, _wnd);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof(_app) == 'undefined') _app = false;
|
||||||
|
if (typeof(_returnID) == 'undefined') _returnID = false;
|
||||||
|
|
||||||
|
var $wnd = jQuery(_wnd.top);
|
||||||
|
var positionLeft = ($wnd.outerWidth()/2)-(_width/2)+_wnd.screenX;
|
||||||
|
var positionTop = ($wnd.outerHeight()/2)-(_height/2)+_wnd.screenY;
|
||||||
|
|
||||||
|
// IE fails, if name contains eg. a dash (-)
|
||||||
|
if (navigator.userAgent.match(/msie/i)) _windowName = !_windowName ? '_blank' : _windowName.replace(/[^a-zA-Z0-9_]+/,'');
|
||||||
|
|
||||||
|
var windowID = _wnd.open(_url, _windowName || '_blank', "width=" + _width + ",height=" + _height +
|
||||||
|
",screenX=" + positionLeft + ",left=" + positionLeft + ",screenY=" + positionTop + ",top=" + positionTop +
|
||||||
|
",location=no,menubar=no,directories=no,toolbar=no,scrollbars=yes,resizable=yes,status="+_status);
|
||||||
|
|
||||||
|
// inject egw object
|
||||||
|
windowID.egw = _wnd.egw;
|
||||||
|
|
||||||
|
// returning something, replaces whole window in FF, if used in link as "javascript:egw_openWindowCentered2()"
|
||||||
|
if (_returnID !== false) return windowID;
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get available height of screen
|
* Get available height of screen
|
||||||
*/
|
*/
|
||||||
|
@ -373,40 +373,27 @@ function egw_set_checkbox_multiselect_enabled(_id, _enabled)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// works only correctly in Mozilla/FF and Konqueror
|
/**
|
||||||
|
* Open a (centered) popup window with given size and url
|
||||||
|
*
|
||||||
|
* @param {string} _url
|
||||||
|
* @param {string} _windowName or "_blank"
|
||||||
|
* @param {number} _width
|
||||||
|
* @param {number} _height
|
||||||
|
* @param {type} _status "yes" or "no" to display status bar of popup
|
||||||
|
* @param {string|boolean} _app app-name for framework to set correct opener or false for current app
|
||||||
|
* @param {boolean} _returnID true: return window, false: return undefined
|
||||||
|
* @returns {DOMWindow|undefined}
|
||||||
|
* @deprecated use egw.openPopup(_url, _width, _height, _windowName, _app, _returnID, _status)
|
||||||
|
*/
|
||||||
function egw_openWindowCentered2(_url, _windowName, _width, _height, _status, _app, _returnID)
|
function egw_openWindowCentered2(_url, _windowName, _width, _height, _status, _app, _returnID)
|
||||||
{
|
{
|
||||||
// Log for debugging purposes
|
return egw(window).openPopup(_url, _width, _height, _windowName, _app, _returnID, _status);
|
||||||
egw.debug("navigation", "egw_openWindowCentered2(%s, %s, %s, %o, %s, %s)",_url,_windowName,_width,_height,_status,_app);
|
|
||||||
|
|
||||||
if (typeof(_app) == 'undefined') _app = false;
|
|
||||||
if (typeof(_returnID) == 'undefined') _returnID = false;
|
|
||||||
windowWidth = egw_getWindowOuterWidth();
|
|
||||||
windowHeight = egw_getWindowOuterHeight();
|
|
||||||
|
|
||||||
positionLeft = (windowWidth/2)-(_width/2)+egw_getWindowLeft();
|
|
||||||
positionTop = (windowHeight/2)-(_height/2)+egw_getWindowTop();
|
|
||||||
|
|
||||||
if (is_ie) _windowName = !_windowName ? '_blank' : _windowName.replace(/[^a-zA-Z0-9_]+/,''); // IE fails, if name contains eg. a dash (-)
|
|
||||||
|
|
||||||
windowID = window.open(_url, _windowName || '_blank', "width=" + _width + ",height=" + _height +
|
|
||||||
",screenX=" + positionLeft + ",left=" + positionLeft + ",screenY=" + positionTop + ",top=" + positionTop +
|
|
||||||
",location=no,menubar=no,directories=no,toolbar=no,scrollbars=yes,resizable=yes,status="+_status);
|
|
||||||
|
|
||||||
// inject egw object
|
|
||||||
windowID.egw = window.egw;
|
|
||||||
|
|
||||||
// returning something, replaces whole window in FF, if used in link as "javascript:egw_openWindowCentered2()"
|
|
||||||
if (_returnID === false)
|
|
||||||
{
|
|
||||||
// return nothing
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return windowID;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use egw.openPopup(_url, _width, _height, _windowName, _app, _returnID, _status)
|
||||||
|
*/
|
||||||
function egw_openWindowCentered(_url, _windowName, _width, _height)
|
function egw_openWindowCentered(_url, _windowName, _width, _height)
|
||||||
{
|
{
|
||||||
return egw_openWindowCentered2(_url, _windowName, _width, _height, 'no', false, true);
|
return egw_openWindowCentered2(_url, _windowName, _width, _height, 'no', false, true);
|
||||||
|
Loading…
Reference in New Issue
Block a user