Merge branch '1758-Error-tamaño-al-crear-elemento-de-imagen-en-consola-visual-dev' into 'develop'

Fixed element size of type icon, group and static graph

See merge request artica/pandorafms!1247
This commit is contained in:
vgilc 2018-02-05 16:39:02 +01:00
commit 024367d601
1 changed files with 37 additions and 32 deletions

View File

@ -374,8 +374,7 @@ function update_button_palette_callback() {
}
if($('#preview > img').attr('naturalWidth') == null || $('#preview > img')[0].naturalWidth > 150 || $('#preview > img')[0].naturalHeight > 150){
if($('#preview > img').prop('naturalWidth') == null || $('#preview > img')[0].naturalWidth > 150 || $('#preview > img')[0].naturalHeight > 150){
$("#image_" + idItem).removeAttr('width');
$("#image_" + idItem).removeAttr('height');
$("#image_" + idItem).attr('width', 70);
@ -503,7 +502,7 @@ function update_button_palette_callback() {
}
if($('#preview > img').attr('naturalWidth') == null || $('#preview > img')[0].naturalWidth > 150 || $('#preview > img')[0].naturalHeight > 150){
if($('#preview > img').prop('naturalWidth') == null || $('#preview > img')[0].naturalWidth > 150 || $('#preview > img')[0].naturalHeight > 150){
$("#image_" + idItem).removeAttr('width');
$("#image_" + idItem).removeAttr('height');
$("#image_" + idItem).attr('width', 70);
@ -679,7 +678,7 @@ function update_button_palette_callback() {
}
$("#image_" + idItem).attr('src', "images/spinner.gif");
if ((values['width'] == 0) || (values['height'] == 0)) {
if($('#preview > img').attr('naturalWidth') == null || $('#preview > img')[0].naturalWidth > 150 || $('#preview > img')[0].naturalHeight > 150){
if($('#preview > img').prop('naturalWidth') == null || $('#preview > img')[0].naturalWidth > 150 || $('#preview > img')[0].naturalHeight > 150){
$("#image_" + idItem).removeAttr('width');
$("#image_" + idItem).removeAttr('height');
$("#image_" + idItem).attr('width', 70);
@ -2719,7 +2718,9 @@ function createItem(type, values, id_data) {
break;
case 'group_item':
class_type = "group_item";
img_src = "images/spinner.gif";
@ -2797,25 +2798,20 @@ function createItem(type, values, id_data) {
if ((values['width'] == 0) || (values['height'] == 0)) {
// Do none
if(values['image'] != '' && values['image'] != 'none'){
if($('#preview > img').attr('naturalWidth') == null || $('#preview > img')[0].naturalWidth > 150 || $('#preview > img')[0].naturalHeight > 150){
if(values['image'] != '' && values['image'] != 'none'){
if(values['naturalWidth'] == null || values['naturalWidth'] > 150 || values['naturalHeight'] > 150){
$image.attr('width', '70')
.attr('height', '70');
}
else{
$image.attr('width', values['naturalWidth'])
.attr('height', values['naturalHeight']);
}
}
else{
$image.attr('width', '70')
.attr('height', '70');
}
else{
$image.attr('width', $('#preview > img')[0].naturalWidth)
.attr('height', $('#preview > img')[0].naturalHeight);
}
}
else{
$image.attr('width', '70')
.attr('height', '70');
}
}
else {
$image.attr('width', values['width'])
@ -2917,13 +2913,13 @@ function createItem(type, values, id_data) {
if(values['image'] != '' && values['image'] != 'none'){
// Do none
if($('#preview > img').attr('naturalWidth') == null || $('#preview > img')[0].naturalWidth > 150 || $('#preview > img')[0].naturalHeight > 150){
if(values['naturalWidth'] == null || values['naturalWidth'] > 150 || values['naturalHeight'] > 150){
$image.attr('width', '70')
.attr('height', '70');
}
else{
$image.attr('width', $('#preview > img')[0].naturalWidth)
.attr('height', $('#preview > img')[0].naturalHeight);
$image.attr('width', values['naturalWidth'])
.attr('height', values['naturalHeight']);
}
}
else{
@ -2962,7 +2958,7 @@ function createItem(type, values, id_data) {
case 'static_graph':
class_type = "static_graph";
img_src = "images/spinner.gif";
item = $('<div></div>')
@ -3008,13 +3004,13 @@ function createItem(type, values, id_data) {
if ((values['width'] == 0) || (values['height'] == 0)) {
// Do none
if(values['image'] != '' && values['image'] != 'none'){
if($('#preview > img').attr('naturalWidth') == null || $('#preview > img')[0].naturalWidth > 150 || $('#preview > img')[0].naturalHeight > 150){
if(values['naturalWidth'] == null || values['naturalWidth'] > 150 || values['naturalHeight'] > 150){
$image.attr('width', '70')
.attr('height', '70');
}
else{
$image.attr('width', $('#preview > img')[0].naturalWidth)
.attr('height', $('#preview > img')[0].naturalHeight);
$image.attr('width', values['naturalWidth'])
.attr('height', values['naturalHeight']);
}
}
else{
@ -3141,13 +3137,13 @@ function createItem(type, values, id_data) {
if(values['image'] != '' && values['image'] != 'none'){
// Do none
if($('#preview > img').attr('naturalWidth') == null || $('#preview > img')[0].naturalWidth > 150 || $('#preview > img')[0].naturalHeight > 150){
if(values['naturalWidth'] == null || values['naturalWidth'] > 150 || values['naturalHeight'] > 150){
$image.attr('width', '70')
.attr('height', '70');
}
else{
$image.attr('width', $('#preview > img')[0].naturalWidth)
.attr('height', $('#preview > img')[0].naturalHeight);
$image.attr('width', values['naturalWidth'])
.attr('height', values['naturalHeight']);
}
}
else{
@ -3422,7 +3418,7 @@ function createItem(type, values, id_data) {
break;
case 'icon':
if ((values['width'] == 0) || (values['height'] == 0)) {
if($('#preview > img').attr('naturalWidth') == null || $('#preview > img')[0].naturalWidth > 150 || $('#preview > img')[0].naturalHeight > 150){
if(values['naturalWidth'] == null || values['naturalWidth'] > 150 || values['naturalWidth'] > 150){
sizeStyle = 'width: ' + '70' + 'px; height: ' + '70' + 'px;';
imageSize = 'width="' + '70' + '" height="' + '70' + '"';
}
@ -3527,6 +3523,10 @@ function insertDB(type, values) {
success: function (data) {
if (data['correct']) {
id = data['id_data'];
if((type === 'group_item') || (type === 'icon') || (type === 'static_graph')){
values['naturalWidth'] = $('#preview > img')[0].naturalWidth;
values['naturalHeight'] = $('#preview > img')[0].naturalHeight;
}
createItem(type, values, id);
addItemSelectParents(id, data['text']);
//Reload all events for the item and new item.
@ -3866,7 +3866,12 @@ function copyDB(idItem) {
values = data['values'];
type = data['type'];
id = data['id_data'];
if((type === 'group_item') || (type === 'icon') || (type === 'static_graph')){
values['naturalWidth'] = $('#image_'+idItem).prop('naturalWidth');
values['naturalHeight'] = $('#image_'+idItem).prop('naturalHeight');
}
createItem(type, values, id);
addItemSelectParents(id, data['text']);