2
0
forked from Wavyzz/dolibarr

Fix: try jeditable autocomplete

This commit is contained in:
Regis Houssin
2012-03-12 23:02:50 +08:00
parent 117bde13d9
commit 2048c88975
3 changed files with 36 additions and 49 deletions

View File

@@ -242,8 +242,6 @@ class Form
$savemethod = false;
$ext_element = false;
$button_only = false;
//$ext_table_element = false;
//$ext_fk_element = false;
if (is_object($object))
{
@@ -255,8 +253,6 @@ class Form
if (is_object($extObject))
{
$ext_element = $extObject->element;
//$ext_table_element = $extObject->table_element;
//$ext_fk_element = $extObject->id;
}
if (preg_match('/^(string|email|numeric)/',$inputType))
@@ -273,7 +269,7 @@ class Form
$out.= '<input id="timestamp" type="hidden"/>'."\n"; // Use for timestamp format
}
else if (preg_match('/^select/',$inputType))
else if (preg_match('/^(select|autocomplete)/',$inputType))
{
$tmp=explode(':',$inputType);
$inputType=$tmp[0]; $loadmethod=$tmp[1];
@@ -302,11 +298,9 @@ class Form
$out.= '<input id="table_element_'.$htmlname.'" value="'.$table_element.'" type="hidden"/>'."\n";
$out.= '<input id="fk_element_'.$htmlname.'" value="'.$fk_element.'" type="hidden"/>'."\n";
$out.= '<input id="loadmethod_'.$htmlname.'" value="'.$loadmethod.'" type="hidden"/>'."\n";
$out.= '<input id="savemethod_'.$htmlname.'" value="'.$savemethod.'" type="hidden"/>'."\n";
$out.= '<input id="ext_element_'.$htmlname.'" value="'.$ext_element.'" type="hidden"/>'."\n";
if (! empty($savemethod)) $out.= '<input id="savemethod_'.$htmlname.'" value="'.$savemethod.'" type="hidden"/>'."\n";
if (! empty($ext_element)) $out.= '<input id="ext_element_'.$htmlname.'" value="'.$ext_element.'" type="hidden"/>'."\n";
if (! empty($success)) $out.= '<input id="success_'.$htmlname.'" value="'.$success.'" type="hidden"/>'."\n";
//$out.= '<input id="ext_table_element_'.$htmlname.'" value="'.$ext_table_element.'" type="hidden"/>'."\n";
//$out.= '<input id="ext_fk_element_'.$htmlname.'" value="'.$ext_fk_element.'" type="hidden"/>'."\n";
$out.= '<div id="viewval_'.$htmlname.'" class="viewval_'.$inputType.($button_only ? ' inactive' : ' active').'">'.$value.'</div>'."\n";
$out.= '<div id="editval_'.$htmlname.'" class="editval_'.$inputType.($button_only ? ' inactive' : ' active').' hideobject">'.(! empty($editvalue) ? $editvalue : $value).'</div>'."\n";

View File

@@ -37,12 +37,10 @@ $(document).ready(function() {
indicator : indicatorInPlace,
loadurl : urlLoadInPlace,
loaddata : function(result, settings) {
var htmlname = $(this).attr('id').substr(8);
return getParameters('textarea', htmlname);
return getParameters(this, 'textarea');
},
submitdata : function(result, settings) {
var htmlname = $(this).attr('id').substr(8);
return getParameters('textarea', htmlname);
return getParameters(this, 'textarea');
},
callback : function(result, settings) {
getResult(this, result);
@@ -85,8 +83,7 @@ $(document).ready(function() {
toolbar: $('#ckeditor_toolbar').val()
},
submitdata : function(result, settings) {
var htmlname = $(this).attr('id').substr(8);
return getParameters('ckeditor', htmlname);
return getParameters(this, 'ckeditor');
},
callback : function(result, settings) {
getResult(this, result);
@@ -125,8 +122,7 @@ $(document).ready(function() {
submit : submitInPlace,
indicator : indicatorInPlace,
submitdata : function(result, settings) {
var htmlname = $(this).attr('id').substr(8);
return getParameters('string', htmlname);
return getParameters(this, 'string');
},
callback : function(result, settings) {
getResult(this, result);
@@ -165,8 +161,7 @@ $(document).ready(function() {
submit : submitInPlace,
indicator : indicatorInPlace,
submitdata : function(result, settings) {
var htmlname = $(this).attr('id').substr(8);
return getParameters('numeric', htmlname);
return getParameters(this, 'numeric');
},
callback : function(result, settings) {
getResult(this, result);
@@ -205,8 +200,7 @@ $(document).ready(function() {
submit : submitInPlace,
indicator : indicatorInPlace,
submitdata : function(result, settings) {
var htmlname = $(this).attr('id').substr(8);
return getParameters('datepicker', htmlname);
return getParameters(this, 'datepicker');
},
callback : function(result, settings) {
getResult(this, result);
@@ -244,12 +238,10 @@ $(document).ready(function() {
indicator : indicatorInPlace,
loadurl : urlLoadInPlace,
loaddata : function(result, settings) {
var htmlname = $(this).attr('id').substr(8);
return getParameters('select', htmlname);
return getParameters(this, 'select');
},
submitdata : function(result, settings) {
var htmlname = $(this).attr('id').substr(8);
return getParameters('select', htmlname);
return getParameters(this, 'select');
},
callback : function(result, settings) {
getResult(this, result);
@@ -275,7 +267,23 @@ $(document).ready(function() {
$('#editval_' + $(this).attr('id')).show().click();
});
function getParameters(type, htmlname) {
// for test only (not stable)
$('.editval_autocomplete').editable(urlSaveInPlace, {
type : 'autocomplete',
id : 'field',
onblur : 'submit',
tooltip : tooltipInPlace,
indicator : indicatorInPlace,
autocomplete : {
source : urlLoadInPlace,
data : function(result, settings) {
return getParameters(this, 'select');
}
}
});
function getParameters(obj, type) {
var htmlname = $(obj).attr('id').substr(8);
var element = $('#element_' + htmlname).val();
var table_element = $('#table_element_' + htmlname).val();
var fk_element = $('#fk_element_' + htmlname).val();
@@ -283,8 +291,6 @@ $(document).ready(function() {
var savemethod = $('#savemethod_' + htmlname).val();
var ext_element = $('#ext_element_' + htmlname).val();
var timestamp = $('#timestamp').val();
//var ext_table_element = $( '#ext_table_element_' + htmlname ).val();
//var ext_fk_element = $( '#ext_fk_element_' + htmlname ).val();
return {
type: type,
@@ -294,9 +300,7 @@ $(document).ready(function() {
loadmethod: loadmethod,
savemethod: savemethod,
timestamp: timestamp,
ext_element: ext_element,
//ext_table_element: ext_table_element,
//ext_fk_element: ext_fk_element
ext_element: ext_element
};
}
@@ -323,15 +327,4 @@ $(document).ready(function() {
$('#editval_' + htmlname).hide();
$('#viewval_' + htmlname).show();
}
$('.edit_autocomplete').editable(urlSaveInPlace, {
type : 'autocomplete',
id : 'field',
onblur : 'submit',
tooltip : tooltipInPlace,
indicator : indicatorInPlace,
autocomplete : {
data : ["Aberdeen", "Ada", "Adamsville", "Addyston", "Adelphi", "Adena", "Adrian", "Akron"]
}
});
});

View File

@@ -4,6 +4,6 @@
$.editable.addInputType('autocomplete', {
element : $.editable.types.text.element,
plugin : function(settings, original) {
$('input', this).autocomplete(settings.autocomplete.data);
$('input', this).autocomplete(settings.autocomplete);
}
});