Creator and updater palette respect original size for elements with lower than 150 size - #90

This commit is contained in:
enriquecd 2017-03-07 17:28:22 +01:00
parent e5ec0cb35a
commit 65c31e9b7a
1 changed files with 46 additions and 35 deletions

View File

@ -244,17 +244,23 @@ function update_button_palette_callback() {
}
$("#text_" + idItem).html(values['label']);
if ((values['width'] == 0) || (values['height'] == 0)) {
if($('#preview > img')[0].naturalWidth > 150 || $('#preview > img')[0].naturalHeight > 150){
$("#image_" + idItem).removeAttr('width');
$("#image_" + idItem).removeAttr('height');
$("#image_" + idItem).attr('width', 70);
$("#image_" + idItem).attr('height', 70);
$("#image_" + idItem).css('width', '70px');
$("#image_" + idItem).css('height', '70px');
}
else{
$("#image_" + idItem).removeAttr('width');
$("#image_" + idItem).removeAttr('height');
$("#image_" + idItem).attr('width', $('#preview > img')[0].naturalHeight);
$("#image_" + idItem).attr('height', $('#preview > img')[0].naturalHeight);
$("#image_" + idItem).css('width', $('#preview > img')[0].naturalHeight+'px');
$("#image_" + idItem).css('height', $('#preview > img')[0].naturalHeight+'px');
}
}
else {
$("#image_" + idItem).removeAttr('width');
@ -264,9 +270,6 @@ function update_button_palette_callback() {
$("#image_" + idItem).css('width', values['width'] + 'px');
$("#image_" + idItem).css('height', values['height'] + 'px');
}
break;
case 'percentile_bar':
case 'percentile_item':
@ -333,18 +336,24 @@ function update_button_palette_callback() {
alert('Undefined height');
return false;
}
$("#image_" + idItem).attr('src', "images/spinner.gif");
if ((values['width'] == 0) || (values['height'] == 0)) {
if($('#preview > img')[0].naturalWidth > 150 || $('#preview > img')[0].naturalHeight > 150){
$("#image_" + idItem).removeAttr('width');
$("#image_" + idItem).removeAttr('height');
$("#image_" + idItem).attr('width', 70);
$("#image_" + idItem).attr('height', 70);
$("#image_" + idItem).css('width', '70px');
$("#image_" + idItem).css('height', '70px');
}
else{
$("#image_" + idItem).removeAttr('width');
$("#image_" + idItem).removeAttr('height');
$("#image_" + idItem).attr('width', $('#preview > img')[0].naturalHeight);
$("#image_" + idItem).attr('height', $('#preview > img')[0].naturalHeight);
$("#image_" + idItem).css('width', $('#preview > img')[0].naturalHeight+'px');
$("#image_" + idItem).css('height', $('#preview > img')[0].naturalHeight+'px');
}
}
else {
$("#image_" + idItem).removeAttr('width');
@ -1959,9 +1968,11 @@ function createItem(type, values, id_data) {
if ((values['width'] == 0) || (values['height'] == 0)) {
// Do none
if($('#preview > img')[0].naturalWidth > 150 || $('#preview > img')[0].naturalHeight > 150){
$image.attr('width', '70')
.attr('height', '70');
}
}
else {
$image.attr('width', values['width'])
.attr('height', values['height']);
@ -2159,9 +2170,11 @@ function createItem(type, values, id_data) {
break;
case 'icon':
if ((values['width'] == 0) || (values['height'] == 0)) {
if($('#preview > img')[0].naturalWidth > 150 || $('#preview > img')[0].naturalHeight > 150){
sizeStyle = 'width: ' + '70' + 'px; height: ' + '70' + 'px;';
imageSize = 'width="' + '70' + '" height="' + '70' + '"';
}
}
else {
sizeStyle = 'width: ' + values['width'] + 'px; height: ' + values['height'] + 'px;';
imageSize = 'width="' + values['width'] + '" height="' + values['height'] + '"';
@ -2177,9 +2190,7 @@ function createItem(type, values, id_data) {
default:
//Maybe create in any Enterprise item.
if (typeof(enterprise_createItem) == 'function') {
if (values['image'] == "") {
values['image'] = 'visualmap.services';
}
temp_item = enterprise_createItem(type, values, id_data);
if (temp_item != false) {
item = temp_item;