Skip to content
Snippets Groups Projects
Commit 993b5eef authored by Regis Houssin's avatar Regis Houssin
Browse files

Fix: wrong blank space for jquery combobox

Fix: uniformize code
parent 8dc8297a
Branches
Tags
No related merge requests found
...@@ -668,7 +668,7 @@ class Form ...@@ -668,7 +668,7 @@ class Form
} }
$out.= '<select id="'.$htmlname.'" class="flat" name="'.$htmlname.'">'; $out.= '<select id="'.$htmlname.'" class="flat" name="'.$htmlname.'">';
if ($showempty) $out.= '<option value="-1">&nbsp;</option>'; if ($showempty) $out.= '<option value="-1"></option>';
$num = $this->db->num_rows($resql); $num = $this->db->num_rows($resql);
$i = 0; $i = 0;
if ($num) if ($num)
......
...@@ -631,31 +631,31 @@ function hideMessage(fieldId,message) { ...@@ -631,31 +631,31 @@ function hideMessage(fieldId,message) {
/* This is to allow to transform all select box into ajax autocomplete box /* This is to allow to transform all select box into ajax autocomplete box
* with just one line: jQuery(function() { jQuery( "#listmotifcons" ).combobox(); }); * with just one line: $(function() { $( "#listmotifcons" ).combobox(); });
*/ */
(function( jQuery ) { (function( $ ) {
jQuery.widget( "ui.combobox", { $.widget( "ui.combobox", {
_create: function() { _create: function() {
var self = this, var self = this,
select = this.element.hide(), select = this.element.hide(),
selected = select.children( ":selected" ), selected = select.children( ":selected" ),
value = selected.val() ? selected.text() : ""; value = selected.val() ? selected.text() : "";
var input = this.input = jQuery( "<input>" ) var input = this.input = $( "<input>" )
.insertAfter( select ) .insertAfter( select )
.val( value ) .val( value )
.autocomplete({ .autocomplete({
delay: 0, delay: 0,
minLength: 0, minLength: 0,
source: function( request, response ) { source: function( request, response ) {
var matcher = new RegExp( jQuery.ui.autocomplete.escapeRegex(request.term), "i" ); var matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), "i" );
response( select.children( "option" ).map(function() { response( select.children( "option" ).map(function() {
var text = jQuery( this ).text(); var text = $( this ).text();
if ( this.value && ( !request.term || matcher.test(text) ) ) if ( this.value && ( !request.term || matcher.test(text) ) )
return { return {
label: text.replace( label: text.replace(
new RegExp( new RegExp(
"(?![^&;]+;)(?!<[^<>]*)(" + "(?![^&;]+;)(?!<[^<>]*)(" +
jQuery.ui.autocomplete.escapeRegex(request.term) + $.ui.autocomplete.escapeRegex(request.term) +
")(?![^<>]*>)(?![^&;]+;)", "gi" ")(?![^<>]*>)(?![^&;]+;)", "gi"
), "<strong>$1</strong>" ), ), "<strong>$1</strong>" ),
value: text, value: text,
...@@ -671,17 +671,17 @@ function hideMessage(fieldId,message) { ...@@ -671,17 +671,17 @@ function hideMessage(fieldId,message) {
}, },
change: function( event, ui ) { change: function( event, ui ) {
if ( !ui.item ) { if ( !ui.item ) {
var matcher = new RegExp( "^" + jQuery.ui.autocomplete.escapeRegex( jQuery(this).val() ) + "$", "i" ), var matcher = new RegExp( "^" + $.ui.autocomplete.escapeRegex( $(this).val() ) + "$", "i" ),
valid = false; valid = false;
select.children( "option" ).each(function() { select.children( "option" ).each(function() {
if ( jQuery( this ).text().match( matcher ) ) { if ( $( this ).text().match( matcher ) ) {
this.selected = valid = true; this.selected = valid = true;
return false; return false;
} }
}); });
if ( !valid ) { if ( !valid ) {
// remove invalid value, as it didnt match anything // remove invalid value, as it didnt match anything
jQuery( this ).val( "" ); $( this ).val( "" );
select.val( "" ); select.val( "" );
input.data( "autocomplete" ).term = ""; input.data( "autocomplete" ).term = "";
return false; return false;
...@@ -692,13 +692,13 @@ function hideMessage(fieldId,message) { ...@@ -692,13 +692,13 @@ function hideMessage(fieldId,message) {
.addClass( "ui-widget ui-widget-content ui-corner-left dolibarrcombobox" ); .addClass( "ui-widget ui-widget-content ui-corner-left dolibarrcombobox" );
input.data( "autocomplete" )._renderItem = function( ul, item ) { input.data( "autocomplete" )._renderItem = function( ul, item ) {
return jQuery( "<li></li>" ) return $( "<li></li>" )
.data( "item.autocomplete", item ) .data( "item.autocomplete", item )
.append( "<a>" + item.label + "</a>" ) .append( "<a>" + item.label + "</a>" )
.appendTo( ul ); .appendTo( ul );
}; };
this.button = jQuery( "<button type=\'button\'>&nbsp;</button>" ) this.button = $( "<button type=\'button\'>&nbsp;</button>" )
.attr( "tabIndex", -1 ) .attr( "tabIndex", -1 )
.attr( "title", "Show All Items" ) .attr( "title", "Show All Items" )
.insertAfter( input ) .insertAfter( input )
...@@ -727,7 +727,7 @@ function hideMessage(fieldId,message) { ...@@ -727,7 +727,7 @@ function hideMessage(fieldId,message) {
this.input.remove(); this.input.remove();
this.button.remove(); this.button.remove();
this.element.show(); this.element.show();
jQuery.Widget.prototype.destroy.call( this ); $.Widget.prototype.destroy.call( this );
} }
}); });
})( jQuery ); })( jQuery );
...@@ -261,7 +261,7 @@ if ($id || $ref) ...@@ -261,7 +261,7 @@ if ($id || $ref)
print_fiche_titre($langs->trans("AddSupplierPrice")); print_fiche_titre($langs->trans("AddSupplierPrice"));
} }
print '<form action="fournisseurs.php?id='.$product->id.'" method="post">'; print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$product->id.'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="updateprice">'; print '<input type="hidden" name="action" value="updateprice">';
...@@ -427,8 +427,8 @@ if ($id || $ref) ...@@ -427,8 +427,8 @@ if ($id || $ref)
print '<td align="center">'; print '<td align="center">';
if ($user->rights->produit->creer || $user->rights->service->creer) if ($user->rights->produit->creer || $user->rights->service->creer)
{ {
print '<a href="fournisseurs.php?id='.$product->id.'&amp;socid='.$productfourn->fourn_id.'&amp;action=add_price&amp;rowid='.$productfourn->product_fourn_price_id.'">'.img_edit()."</a>"; print '<a href="'.$_SERVER['PHP_SELF'].'?id='.$product->id.'&amp;socid='.$productfourn->fourn_id.'&amp;action=add_price&amp;rowid='.$productfourn->product_fourn_price_id.'">'.img_edit()."</a>";
print '<a href="fournisseurs.php?id='.$product->id.'&amp;socid='.$productfourn->fourn_id.'&amp;action=remove_pf&amp;rowid='.$productfourn->product_fourn_price_id.'">'.img_picto($langs->trans("Remove"),'disable.png').'</a>'; print '<a href="'.$_SERVER['PHP_SELF'].'?id='.$product->id.'&amp;socid='.$productfourn->fourn_id.'&amp;action=remove_pf&amp;rowid='.$productfourn->product_fourn_price_id.'">'.img_picto($langs->trans("Remove"),'disable.png').'</a>';
} }
print '</td>'; print '</td>';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment