diff --git a/phpgwapi/inc/class.egw_framework.inc.php b/phpgwapi/inc/class.egw_framework.inc.php index b1d89c942e..34dba018f8 100644 --- a/phpgwapi/inc/class.egw_framework.inc.php +++ b/phpgwapi/inc/class.egw_framework.inc.php @@ -289,6 +289,28 @@ abstract class egw_framework self::$extra['message'] = func_get_args(); } + /** + * Open a popup independent if we run as json or regular request + * + * @param string $link + * @param string $target + * @param string $popup + */ + public static function popup($link, $target='_blank', $popup='640x480') + { + // default params are not returned by func_get_args! + $args = func_get_args()+array(null, '_blank', '640x480'); + + if (egw_json_request::isJSONRequest()) + { + egw_json_response::get()->apply('egw.open_link', $args); + } + else + { + self::$extra['popup'] = $args; + } + } + /** * Close (popup) window, use to replace egw_framework::onload('window.close()') in a content security save way * diff --git a/phpgwapi/js/jsapi/egw.js b/phpgwapi/js/jsapi/egw.js index 95dda7274d..4deb33e61e 100644 --- a/phpgwapi/js/jsapi/egw.js +++ b/phpgwapi/js/jsapi/egw.js @@ -177,6 +177,14 @@ window.egw_LAB.script(include).wait(function() { + // call egw.open_link, if popup attr specified + var egw_popup = egw_script.getAttribute('data-popup'); + if (egw_popup) + { + egw_popup = JSON.parse(egw_popup) || []; + egw.open_link.apply(egw, egw_popup); + } + if(console.timelineEnd) console.timelineEnd("egw"); var end_time = (new Date).getTime(); var gen_time_div = $j('#divGenTime_'+window.egw_appName);