From 2b27946d6f0b559f900d064414a8ce21288073d9 Mon Sep 17 00:00:00 2001 From: Klaus Leithoff Date: Mon, 4 Mar 2013 11:50:17 +0000 Subject: [PATCH] * eMail/api: attempt to fix the focus on body issue with FF; thanks to CKEditor support --- phpgwapi/inc/class.html.inc.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/phpgwapi/inc/class.html.inc.php b/phpgwapi/inc/class.html.inc.php index 609f63b285..62ea43653a 100644 --- a/phpgwapi/inc/class.html.inc.php +++ b/phpgwapi/inc/class.html.inc.php @@ -519,10 +519,11 @@ class html * @param string $_width='100%' * @param string $_start_path='' if passed activates the browser for image at absolute path passed * @param boolean $_purify=true run $_content through htmlpurifier before handing it to fckEditor + * @param mixed (boolean/string) $_focusToBody USED only for CKEDIOR true means yes, focus on top, you may specify TOP or BOTTOM (to focus on the end of the editor area) * @return string the necessary html for the textarea */ static function fckEditor($_name, $_content, $_mode, $_options=array('toolbar_expanded' =>'true'), - $_height='400px', $_width='100%',$_start_path='',$_purify=true) + $_height='400px', $_width='100%',$_start_path='',$_purify=true, $_focusToBody=false) { if (!self::htmlarea_availible() || $_mode == 'ascii') { @@ -562,6 +563,16 @@ class html "instanceReady", function (ev) { +'.($_focusToBody?' + ev.editor.focus(); + var d = ev.editor.document; + var r = new CKEDITOR.dom.range(d); + r.collapse(true); + r.selectNodeContents(d.getBody()); + r.collapse('.($_focusToBody==='BOTTOM'?'false':'true').'); + r.select(); +':''). +' ev.editor.resize("100%", '.str_replace('px', '', $pxheight).'); } );'. @@ -582,9 +593,10 @@ class html * @param string $_width='100%' * @param boolean $_purify=true * @param string $_border='0px' NOT used for CKEditor + * @param mixed (boolean/string) $_focusToBody USED only for CKEDIOR true means yes, focus on top, you may specify TOP or BOTTOM (to focus on the end of the editor area) * @return string the necessary html for the textarea */ - static function fckEditorQuick($_name, $_mode, $_content='', $_height='400px', $_width='100%',$_purify=true, $_border='0px') + static function fckEditorQuick($_name, $_mode, $_content='', $_height='400px', $_width='100%',$_purify=true, $_border='0px',$_focusToBody=false) { if (!self::htmlarea_availible() || $_mode == 'ascii') { @@ -593,7 +605,7 @@ class html } else { - return self::fckEditor($_name, $_content, $_mode, array(), $_height, $_width,'',$_purify); + return self::fckEditor($_name, $_content, $_mode, array(), $_height, $_width,'',$_purify,$_focusToBody); } }