mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-18 20:51:23 +01:00
* eMail/api: attempt to fix the focus on body issue with FF; thanks to CKEditor support
This commit is contained in:
parent
472f262eb1
commit
62541c2c42
@ -739,7 +739,7 @@
|
|||||||
#if (isset($GLOBALS['egw_info']['server']['enabled_spellcheck'])) $mode = 'egw_simple_spellcheck';
|
#if (isset($GLOBALS['egw_info']['server']['enabled_spellcheck'])) $mode = 'egw_simple_spellcheck';
|
||||||
$style="border:0px; width:100%; height:400px;";
|
$style="border:0px; width:100%; height:400px;";
|
||||||
// dont run purify, as we already did that (getCleanHTML).
|
// dont run purify, as we already did that (getCleanHTML).
|
||||||
$this->t->set_var('tinymce', html::fckEditorQuick('body', $mode, $sessionData['body'],'400px','100%',false));
|
$this->t->set_var('tinymce', html::fckEditorQuick('body', $mode, $sessionData['body'],'400px','100%',false,'0px',($_focusElement=='body'?true:false)));
|
||||||
$this->t->set_var('mimeType', 'html');
|
$this->t->set_var('mimeType', 'html');
|
||||||
$ishtml=1;
|
$ishtml=1;
|
||||||
} else {
|
} else {
|
||||||
|
@ -230,23 +230,12 @@ if (toFocus=='body')
|
|||||||
{
|
{
|
||||||
'instanceReady': function (ev) {
|
'instanceReady': function (ev) {
|
||||||
CKEDITOR.instances.body.focus();
|
CKEDITOR.instances.body.focus();
|
||||||
var ckeditor = CKEDITOR.instances['body'];
|
var d = CKEDITOR.document;
|
||||||
var s = ckeditor.getSelection();
|
var r = new CKEDITOR.dom.range(d);
|
||||||
if (typeof s != 'undefined')
|
r.collapse(true);
|
||||||
{
|
r.selectNodeContents(d.getBody());
|
||||||
var selected_ranges = s.getRanges()[0]; // save selected range
|
r.collapse(true);
|
||||||
// do something
|
r.select();
|
||||||
//var spanCont = selected_ranges.startContainer.getAscendant({ span: 1, div: 1});
|
|
||||||
//var newRange = new CKEDIOR.dom.range(selected_ranges);
|
|
||||||
//newRange.setStart(spanCont,selected_ranges.StartOffset);
|
|
||||||
//newRange.setEnd(spanCont,selected_ranges.StartOffset+50);
|
|
||||||
//newRange.select();
|
|
||||||
//s.selectRanges(selected_ranges); // restore it
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
document.doit.fm_compose_subject.focus();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -256,26 +245,12 @@ if (toFocus=='body')
|
|||||||
{
|
{
|
||||||
'pluginsLoaded': function (ev) {
|
'pluginsLoaded': function (ev) {
|
||||||
CKEDITOR.instances.body.focus();
|
CKEDITOR.instances.body.focus();
|
||||||
var ckeditor = CKEDITOR.instances['body'];
|
var d = CKEDITOR.document;
|
||||||
var s = ckeditor.getSelection();
|
var r = new CKEDITOR.dom.range(d);
|
||||||
if (typeof s != 'undefined')
|
r.collapse(true);
|
||||||
{
|
r.selectNodeContents(d.getBody());
|
||||||
var selected_ranges = s.getRanges()[0]; // save selected range
|
r.collapse(true);
|
||||||
// do something
|
r.select();
|
||||||
if (typeof selected_ranges != undefined)
|
|
||||||
{
|
|
||||||
//var spanCont = selected_ranges.startContainer.getAscendant({ span: 1, div: 1});
|
|
||||||
//var newRange = new CKEDIOR.dom.range(selected_ranges);
|
|
||||||
//newRange.setStart(spanCont,selected_ranges.StartOffset);
|
|
||||||
//newRange.setEnd(spanCont,selected_ranges.StartOffset+50);
|
|
||||||
//newRange.select();
|
|
||||||
//s.selectRanges(selected_ranges); // restore it
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
document.doit.fm_compose_subject.focus();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -498,10 +498,11 @@ class html
|
|||||||
* @param string $_width='100%'
|
* @param string $_width='100%'
|
||||||
* @param string $_start_path='' if passed activates the browser for image at absolute path passed
|
* @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 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
|
* @return string the necessary html for the textarea
|
||||||
*/
|
*/
|
||||||
static function fckEditor($_name, $_content, $_mode, $_options=array('toolbar_expanded' =>'true'),
|
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')
|
if (!self::htmlarea_availible() || $_mode == 'ascii')
|
||||||
{
|
{
|
||||||
@ -541,6 +542,16 @@ class html
|
|||||||
"instanceReady",
|
"instanceReady",
|
||||||
function (ev)
|
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).');
|
ev.editor.resize("100%", '.str_replace('px', '', $pxheight).');
|
||||||
}
|
}
|
||||||
);'.
|
);'.
|
||||||
@ -561,9 +572,10 @@ class html
|
|||||||
* @param string $_width='100%'
|
* @param string $_width='100%'
|
||||||
* @param boolean $_purify=true
|
* @param boolean $_purify=true
|
||||||
* @param string $_border='0px' NOT used for CKEditor
|
* @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
|
* @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')
|
if (!self::htmlarea_availible() || $_mode == 'ascii')
|
||||||
{
|
{
|
||||||
@ -572,7 +584,7 @@ class html
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return self::fckEditor($_name, $_content, $_mode, array(), $_height, $_width,'',$_purify);
|
return self::fckEditor($_name, $_content, $_mode, array(), $_height, $_width,'',$_purify,$_focusToBody);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user