missing egw.js from last commit and egw_framework::window_focus() method

This commit is contained in:
Ralf Becker 2013-08-20 13:25:36 +00:00
parent 8e2d5d0985
commit 73aa652c41
4 changed files with 41 additions and 8 deletions

View File

@ -618,12 +618,18 @@ function etemplate2_handle_load(_type, _response)
}
}
// handle egw_framework::close_window(), this will terminate execution
// handle egw_framework::window_close(), this will terminate execution
if (data['window-close'])
{
window.close();
}
// handle egw_framework::window_focus()
if (data['window-focus'])
{
window.focus();
}
// regular et2 re-load
if (typeof data.url == "string" && typeof data.data === 'object')
{

View File

@ -1207,7 +1207,7 @@ class filemanager_ui
}
}
}
$GLOBALS['egw_info']['flags']['java_script'] = "<script>window.focus();</script>\n";
egw_framework::window_focus();
$GLOBALS['egw_info']['flags']['app_header'] = lang('Preferences').' '.egw_vfs::decodePath($path);
$tpl->exec('filemanager.filemanager_ui.file',$content,$sel_options,$readonlys,$preserve,2);

View File

@ -185,7 +185,7 @@ abstract class egw_framework
*/
public static function refresh_opener($msg, $app, $id=null, $type=null, $targetapp=null, $replace=null, $with=null)
{
error_log(__METHOD__.'('.array2string(func_get_args()).')');
//error_log(__METHOD__.'('.array2string(func_get_args()).')');
self::$extra['refresh-opener'] = func_get_args();
}
@ -194,7 +194,7 @@ abstract class egw_framework
*/
public static function window_close()
{
error_log(__METHOD__."()");
//error_log(__METHOD__."()");
self::$extra['window-close'] = true;
if ($_GET['menuaction'] === 'etemplate_new::ajax_process_content')
@ -209,6 +209,15 @@ abstract class egw_framework
common::egw_exit();
}
/**
* Close (popup) window, use to replace egw_framework::onload('window.close()') in a content security save way
*/
public static function window_focus()
{
//error_log(__METHOD__."()");
self::$extra['window-focus'] = true;
}
/**
* Allow eg. ajax to query content set via refresh_opener or window_close
*

View File

@ -88,6 +88,28 @@
window.location.search += window.location.search ? "&cd=yes" : "?cd=yes";
}
}
// call egw_refresh on opener, if attr specified
var refresh_opener = egw_script.getAttribute('data-refresh-opener');
if (refresh_opener && window.opener)
{
refresh_opener = JSON.parse(refresh_opener) || {};
window.opener.egw_refresh.apply(window.opener, refresh_opener);
}
// close window / call window.close(), if data-window-close is specified
var window_close = egw_script.getAttribute('data-window-close');
if (window_close && JSON.parse(window_close))
{
window.close();
}
// close window / call window.focus(), if data-window-focus is specified
var window_focus = egw_script.getAttribute('data-window-focus');
if (window_focus && JSON.parse(window_focus))
{
window.focus();
}
window.egw_LAB = $LAB.setOptions({AlwaysPreserveOrder:true,BasePath:window.egw_webserverUrl+'/'});
var include = JSON.parse(egw_script.getAttribute('data-include'));
@ -132,9 +154,5 @@
et2.load(data.name,data.url,data.data,callback);
}
}
if (data = egw_script.getAttribute('data-user'))
{
window.egw.set_user(JSON.parse(data));
}
});
})();