From 548ff266282654c62842a0fa681de55a0df48546 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 21 Nov 2015 13:42:01 +0100 Subject: [PATCH] Focus on textarea works also when ckeditor is on --- htdocs/core/tpl/objectline_create.tpl.php | 28 +++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 886c3fb9d1f..d7949fa1d52 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -138,7 +138,8 @@ else { // Show type selector if ($forceall >= 0) { - echo $langs->trans("FreeLineOfType"); + if (empty($conf->product->enabled) || empty($conf->service->enabled)) echo $langs->trans("Type"); + else echo $langs->trans("FreeLineOfType"); echo ' '; } } @@ -512,7 +513,17 @@ jQuery(document).ready(function() { $("#select_type").change(function() { setforfree(); - if (jQuery('#select_type').val() >= 0) jQuery('#dp_desc').focus(); + if (jQuery('#select_type').val() >= 0) + { + /* focus work on a standard textarea but not if field was replaced with CKEDITOR */ + jQuery('#dp_desc').focus(); + /* focus if CKEDITOR */ + if (CKEDITOR) + { + var editor = CKEDITOR.instances['dp_desc']; + if (editor) { editor.focus(); } + } + } if (jQuery('#select_type').val() == '0') jQuery('#trlinefordates').hide(); else jQuery('#trlinefordates').show(); }); @@ -608,8 +619,17 @@ jQuery(document).ready(function() { /* To set focus */ - if (jQuery('#idprod').val() > 0) jQuery('#dp_desc').focus(); - if (jQuery('#idprodfournprice').val() > 0) jQuery('#dp_desc').focus(); + if (jQuery('#idprod').val() > 0 || jQuery('#idprodfournprice').val() > 0) + { + /* focus work on a standard textarea but not if field was replaced with CKEDITOR */ + jQuery('#dp_desc').focus(); + /* focus if CKEDITOR */ + if (CKEDITOR) + { + var editor = CKEDITOR.instances['dp_desc']; + if (editor) { editor.focus(); } + } + } });