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

Fix: check if textarea is not empty for free lines

parent eea7127a
No related branches found
No related tags found
No related merge requests found
......@@ -739,7 +739,7 @@ function hideMessage(fieldId,message) {
$.widget("ui.onDelayedKeyup", {
_init : function() {
var self = this;
$(this.element).bind('keyup', function() {
$(this.element).bind('keyup input', function() {
if(typeof(window['inputTimeout']) != "undefined"){
window.clearTimeout(inputTimeout);
}
......
......@@ -136,7 +136,7 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption='', $minLengt
}
if (ui.item.textarea) {
$.each(ui.item.textarea, function(key, value) {
if (typeof CKEDITOR == "object" && typeof CKEDITOR.instances != "undefined" && CKEDITOR.instances["product_desc"] != "undefined") {
if (typeof CKEDITOR == "object" && typeof CKEDITOR.instances != "undefined" && CKEDITOR.instances[key] != "undefined") {
CKEDITOR.instances[key].setData(value);
CKEDITOR.instances[key].focus();
} else {
......
......@@ -238,14 +238,14 @@ $(document).ready(function() {
},
function(data) {
if (typeof data != 'undefined') {
$('#select_type').val(data.type).attr('disabled','disabled').trigger('change');
$('#product_ref').val(data.ref);
$('#product_label').val(data.label).attr('disabled','disabled');
$('#origin_label_cache').val(data.label);
$('#origin_desc_cache').val(data.desc);
$('#price_base_type').val(data.pricebasetype);
$('#price_ht').val(data.price_ht);
$('#price_ht').val(data.price_ht).trigger('change');
$('#origin_price_ht_cache').val(data.price_ht);
$('#select_type').val(data.type).attr('disabled','disabled').trigger('change');
$('#update_label_area').show().trigger('show');
$('#update_desc_area').show().trigger('show');
$('#update_price_area').show().trigger('show');
......@@ -293,7 +293,22 @@ $(document).ready(function() {
$('#service_duration_area').show();
}
//$('#add_product_area').show(); // TODO for add product card
var addline=false;
if ($('#price_ht').val().length > 0 || $('#price_ttc').val().length > 0) {
if ($('#idprod').val() == 0) {
if (typeof CKEDITOR == 'object' && typeof CKEDITOR.instances != 'undefined' && CKEDITOR.instances['product_desc'] != 'undefined') {
var content = CKEDITOR.instances['product_desc'].getData();
} else {
var content = $('#product_desc').val();
}
if (content.length > 0) {
addline=true;
}
} else {
addline=true;
}
}
if (addline) {
$('#addlinebutton').removeAttr('disabled');
} else {
$('#addlinebutton').attr('disabled','disabled');
......@@ -461,21 +476,74 @@ $(document).ready(function() {
'tva_tx': $('#tva_tx').val()
},
function(data) {
var addline=false;
if (typeof data[output] != 'undefined') {
$('#' + output).val(data[output]);
if ($('#select_type').val() >= 0) {
$('#addlinebutton').removeAttr('disabled');
if ($('#idprod').val() == 0 && $('#select_type').val() >= 0) {
if (typeof CKEDITOR == 'object' && typeof CKEDITOR.instances != 'undefined' && CKEDITOR.instances['product_desc'] != 'undefined') {
var content = CKEDITOR.instances['product_desc'].getData();
} else {
$('#addlinebutton').attr('disabled','disabled');
var content = $('#product_desc').val();
}
if (content.length > 0) {
addline=true;
}
} else {
addline=true;
}
} else {
$('#' + input).val('');
$('#' + output).val('');
}
if (addline) {
$('#addlinebutton').removeAttr('disabled');
} else {
$('#addlinebutton').attr('disabled','disabled');
}
}, 'json');
}
// Check if decription is not empty for free line
<?php if (! empty($conf->fckeditor->enabled) && ! empty($conf->global->FCKEDITOR_ENABLE_DETAILS)) { ?>
CKEDITOR.on('instanceReady', function() {
CKEDITOR.instances['product_desc'].on('key', function() {
var addline=false;
if ($('#idprod').val() == 0 && $('#select_type').val() >= 0 && ($('#price_ht').val().length > 0 || $('#price_ttc').val().length > 0)) {
var content = CKEDITOR.instances['product_desc'].getData();
if (content.length > 0) {
addline=true;
}
} else if ($('#idprod').val() > 0 && ($('#price_ht').val().length > 0 || $('#price_ttc').val().length > 0)) {
addline=true;
}
if (addline) {
$('#addlinebutton').removeAttr('disabled');
} else {
$('#addlinebutton').attr('disabled','disabled');
}
});
});
<?php } else { ?>
$('#product_desc').onDelayedKeyup({
'handler': function() {
var addline=false;
if ($('#idprod').val() == 0 && $('#select_type').val() >= 0 && ($('#price_ht').val().length > 0 || $('#price_ttc').val().length > 0)) {
var content = $('#product_desc').val();
if (content.length > 0) {
addline=true;
}
} else if ($('#idprod').val() > 0 && ($('#price_ht').val().length > 0 || $('#price_ttc').val().length > 0)) {
addline=true;
}
if (addline) {
$('#addlinebutton').removeAttr('disabled');
} else {
$('#addlinebutton').attr('disabled','disabled');
}
}
});
<?php } ?>
});
</script>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment