From 94b393e760bf0f532b06337ab97bdf88c16ae5a8 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 5 Nov 2011 22:32:25 +0100 Subject: [PATCH] Fix: show icon if edit in place is possible --- htdocs/core/ajax/loadinplace.php | 2 +- htdocs/core/ajax/saveinplace.php | 2 +- htdocs/core/class/html.form.class.php | 36 ++++++----- htdocs/core/js/editinplace.js | 84 ++++++++++++++++++++++++-- htdocs/theme/auguria/style.css.php | 17 ++++-- htdocs/theme/bureau2crea/style.css.php | 27 ++++++--- htdocs/theme/cameleo/style.css.php | 17 ++++-- htdocs/theme/eldy/style.css.php | 17 ++++-- 8 files changed, 159 insertions(+), 43 deletions(-) diff --git a/htdocs/core/ajax/loadinplace.php b/htdocs/core/ajax/loadinplace.php index 639bd5ca5ca..e4ea090d0cf 100644 --- a/htdocs/core/ajax/loadinplace.php +++ b/htdocs/core/ajax/loadinplace.php @@ -46,7 +46,7 @@ if((isset($_GET['field']) && ! empty($_GET['field'])) { $element = GETPOST('element'); $table_element = GETPOST('table_element'); - $field = GETPOST('field'); + $field = substr(GETPOST('field'), 4); // remove prefix val_ $fk_element = GETPOST('fk_element'); $type = GETPOST('type'); diff --git a/htdocs/core/ajax/saveinplace.php b/htdocs/core/ajax/saveinplace.php index 954067d37ee..2c7f87897b0 100644 --- a/htdocs/core/ajax/saveinplace.php +++ b/htdocs/core/ajax/saveinplace.php @@ -47,7 +47,7 @@ if((isset($_POST['field']) && ! empty($_POST['field'])) { $element = GETPOST('element'); $table_element = GETPOST('table_element'); - $field = GETPOST('field'); + $field = substr(GETPOST('field'), 4); // remove prefix val_ $fk_element = GETPOST('fk_element'); $value = GETPOST('value'); $type = GETPOST('type'); diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 648938a7c8c..b54817341dc 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -79,19 +79,27 @@ class Form */ function editfieldkey($text,$htmlname,$preselected,$paramkey,$paramvalue,$perm,$typeofdata='string') { - global $conf,$langs; - - if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) return $langs->trans($text); - else - { - $ret=''; - $ret.=''; - if (GETPOST('action') != 'edit'.$htmlname && $perm) $ret.=''; - $ret.='
'; - $ret.=$langs->trans($text); - $ret.=''.img_edit($langs->trans('Edit'),1).'
'; - return $ret; + global $conf,$langs; + + $ret=''; + + if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) + { + $tmp=explode(':',$typeofdata); + $ret.= "\n".'
'; + $ret.= $langs->trans($text); + $ret.= '
'."\n"; + } + else + { + $ret.=''; + if (GETPOST('action') != 'edit'.$htmlname && $perm) $ret.=''; + $ret.='
'; + $ret.=$langs->trans($text); + $ret.=''.img_edit($langs->trans('Edit'),1).'
'; } + + return $ret; } /** @@ -215,9 +223,9 @@ class Form } } - $out.= '
'; + $out.= "\n".'
'; $out.= $value; - $out.= '
'; + $out.= '
'."\n"; } else { diff --git a/htdocs/core/js/editinplace.js b/htdocs/core/js/editinplace.js index c3ee9146565..8b09731cca5 100644 --- a/htdocs/core/js/editinplace.js +++ b/htdocs/core/js/editinplace.js @@ -11,7 +11,7 @@ $(document).ready(function() { var table_element = $('#jeditable_table_element').html(); var fk_element = $('#jeditable_fk_element').html(); - $('.edit_textarea').editable(urlSaveInPlace, { + $('.editval_textarea').editable(urlSaveInPlace, { type : 'textarea', rows : 4, id : 'field', @@ -44,7 +44,19 @@ $(document).ready(function() { } } }); - $('.edit_ckeditor').editable(urlSaveInPlace, { + $('.editkey_textarea').hover( + function () { + $( '#val_' + $(this).attr('id') ).addClass("editval_hover"); + }, + function () { + $( '#val_' + $(this).attr('id') ).removeClass("editval_hover"); + } + ); + $('.editkey_textarea').click(function() { + $( '#val_' + $(this).attr('id') ).click(); + }); + + $('.editval_ckeditor').editable(urlSaveInPlace, { type : 'ckeditor', id : 'field', onblur : 'ignore', @@ -74,7 +86,19 @@ $(document).ready(function() { } } }); - $('.edit_text').editable(urlSaveInPlace, { + $('.editkey_ckeditor').hover( + function () { + $( '#val_' + $(this).attr('id') ).addClass("editval_hover"); + }, + function () { + $( '#val_' + $(this).attr('id') ).removeClass("editval_hover"); + } + ); + $('.editkey_ckeditor').click(function() { + $( '#val_' + $(this).attr('id') ).click(); + }); + + $('.editval_text').editable(urlSaveInPlace, { type : 'text', id : 'field', width : 300, @@ -100,7 +124,19 @@ $(document).ready(function() { } } }); - $('.edit_numeric').editable(urlSaveInPlace, { + $('.editkey_text').hover( + function () { + $( '#val_' + $(this).attr('id') ).addClass("editval_hover"); + }, + function () { + $( '#val_' + $(this).attr('id') ).removeClass("editval_hover"); + } + ); + $('.editkey_text').click(function() { + $( '#val_' + $(this).attr('id') ).click(); + }); + + $('.editval_numeric').editable(urlSaveInPlace, { type : 'text', id : 'field', width : 100, @@ -126,7 +162,19 @@ $(document).ready(function() { } } }); - $('.edit_datepicker').editable(urlSaveInPlace, { + $('.editkey_numeric').hover( + function () { + $( '#val_' + $(this).attr('id') ).addClass("editval_hover"); + }, + function () { + $( '#val_' + $(this).attr('id') ).removeClass("editval_hover"); + } + ); + $('.editkey_numeric').click(function() { + $( '#val_' + $(this).attr('id') ).click(); + }); + + $('.editval_datepicker').editable(urlSaveInPlace, { type : 'datepicker', id : 'field', onblur : 'ignore', @@ -155,7 +203,19 @@ $(document).ready(function() { } } }); - $('.edit_select').editable(urlSaveInPlace, { + $('.editkey_datepicker').hover( + function () { + $( '#val_' + $(this).attr('id') ).addClass("editval_hover"); + }, + function () { + $( '#val_' + $(this).attr('id') ).removeClass("editval_hover"); + } + ); + $('.editkey_datepicker').click(function() { + $( '#val_' + $(this).attr('id') ).click(); + }); + + $('.editval_select').editable(urlSaveInPlace, { type : 'select', id : 'field', onblur : 'ignore', @@ -191,6 +251,18 @@ $(document).ready(function() { } } }); + $('.editkey_select').hover( + function () { + $( '#val_' + $(this).attr('id') ).addClass("editval_hover"); + }, + function () { + $( '#val_' + $(this).attr('id') ).removeClass("editval_hover"); + } + ); + $('.editkey_select').click(function() { + $( '#val_' + $(this).attr('id') ).click(); + }); + $('.edit_autocomplete').editable(urlSaveInPlace, { type : 'autocomplete', id : 'field', diff --git a/htdocs/theme/auguria/style.css.php b/htdocs/theme/auguria/style.css.php index 4451b2ec24a..c3fbae9bae8 100644 --- a/htdocs/theme/auguria/style.css.php +++ b/htdocs/theme/auguria/style.css.php @@ -1625,16 +1625,25 @@ table.cal_event td { border: 0px; padding-: 0px; padding-) right center no-repeat; +.editkey_textarea, .editkey_ckeditor, .editkey_text, .editkey_numeric, .editkey_select { + background: url() right top no-repeat; cursor: pointer; } -.edit_datepicker:hover { - background: white url() right center no-repeat; +.editkey_datepicker { + background: url() right center no-repeat; cursor: pointer; } +.editval_textarea:hover, .editval_ckeditor:hover, .editval_text:hover, .editval_numeric:hover, .editval_select:hover, .editval_datepicker:hover { + background: white; + cursor: pointer; +} + +.editval_hover { + background: white; +} + /* ============================================================================== */ /* Admin Menu */ diff --git a/htdocs/theme/bureau2crea/style.css.php b/htdocs/theme/bureau2crea/style.css.php index 78901d45668..be308f8e78b 100644 --- a/htdocs/theme/bureau2crea/style.css.php +++ b/htdocs/theme/bureau2crea/style.css.php @@ -1,9 +1,9 @@ - * Copyright (C) 2006 Rodolphe Quiedeville - * Copyright (C) 2007-2010 Regis Houssin - * Copyright (C) 2011 Philippe Grand - * Copyright (C) 2011 Juanjo Menent +/* Copyright (C) 2004-2010 Laurent Destailleur + * Copyright (C) 2006 Rodolphe Quiedeville + * Copyright (C) 2007-2010 Regis Houssin + * Copyright (C) 2011 Philippe Grand + * Copyright (C) 2011 Juanjo Menent * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1844,16 +1844,25 @@ table.cal_event td { border: 0px; padding-: 0px; padding-) right center no-repeat; +.editkey_textarea, .editkey_ckeditor, .editkey_text, .editkey_numeric, .editkey_select { + background: url() right top no-repeat; cursor: pointer; } -.edit_datepicker:hover { - background: white url() right center no-repeat; +.editkey_datepicker { + background: url() right center no-repeat; cursor: pointer; } +.editval_textarea:hover, .editval_ckeditor:hover, .editval_text:hover, .editval_numeric:hover, .editval_select:hover, .editval_datepicker:hover { + background: white; + cursor: pointer; +} + +.editval_hover { + background: white; +} + /* ============================================================================== */ /* Admin Menu */ diff --git a/htdocs/theme/cameleo/style.css.php b/htdocs/theme/cameleo/style.css.php index 94d7b4a4eaf..a4476e1924a 100644 --- a/htdocs/theme/cameleo/style.css.php +++ b/htdocs/theme/cameleo/style.css.php @@ -1792,16 +1792,25 @@ table.cal_event td { border: 0px; padding-: 0px; padding-) right center no-repeat; +.editkey_textarea, .editkey_ckeditor, .editkey_text, .editkey_numeric, .editkey_select { + background: url() right top no-repeat; cursor: pointer; } -.edit_datepicker:hover { - background: white url() right center no-repeat; +.editkey_datepicker { + background: url() right center no-repeat; cursor: pointer; } +.editval_textarea:hover, .editval_ckeditor:hover, .editval_text:hover, .editval_numeric:hover, .editval_select:hover, .editval_datepicker:hover { + background: white; + cursor: pointer; +} + +.editval_hover { + background: white; +} + /* ============================================================================== */ /* Admin Menu */ diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 8f68fcbca1b..408d5fb0c65 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -1704,16 +1704,25 @@ table.cal_event td { border: 0px; padding-: 0px; padding-) right top no-repeat; +.editkey_textarea, .editkey_ckeditor, .editkey_text, .editkey_numeric, .editkey_select { + background: url() right top no-repeat; cursor: pointer; } -.edit_datepicker:hover { - background: white url() right center no-repeat; +.editkey_datepicker { + background: url() right center no-repeat; cursor: pointer; } +.editval_textarea:hover, .editval_ckeditor:hover, .editval_text:hover, .editval_numeric:hover, .editval_select:hover, .editval_datepicker:hover { + background: white; + cursor: pointer; +} + +.editval_hover { + background: white; +} + /* ============================================================================== */ /* Admin Menu */