var windowOffsetX=32; var windowOffsetY=32; // choose action depending on selected tab function imageAction(filename){ if(selectedImageTab=='select'){ selectThisImage(filename); return false; } if(selectedImageTab=='edit'){ editImage(filename); return false; } } // get current selected tab by tabs-id function getSelectedTab(id){ var selector='#'+id+" li.ui-tabs-active a"; var tabValue=$(selector).attr("value"); return tabValue; } //select image load into selectImage box function selectImage(project_id, studio_id, id, value, imageUrl, series_id){ selectImageId=id; value=value.replace(/[^a-zA-Z0-9]/g,'%'); var url="image.cgi?search="+encodeURIComponent(value)+'&project_id='+project_id+'&studio_id='+studio_id; if((series_id!=null)&&(series_id != '')){ url+='&series_id='+series_id; } if(imageUrl!=null){ var filename=imageUrl.split('%2F').pop(); url+='&filename='+filename; } var x=$(window).width() - windowOffsetX; var y=$(window).height() - windowOffsetY; hideContent(); $('#selectImage').load(url); $('#selectImage').dialog({ appendTo: "#content", title:"select image", width:x, height:y, close: function( event, ui ) { showContent(); } }); return false; } // set editor image and image url to selected image function selectThisImage(filename){ $('#'+selectImageId).val(filename); var url = 'showImage.cgi?project_id='+project_id+'&studio_id='+studio_id+'&filename=' + filename; console.log(url); $('#imagePreview').prop('src',url); try{ $('#selectImage').dialog('close'); }catch(e){ $('#selectImage').parent().remove(); $('html').append('
'); }; return false; } // update selectImage container by images matching to search function searchImage(){ var url='image.cgi?project_id='+project_id+'&studio_id='+studio_id; var value=$('#image_manager input[name=search]').val(); value=value.replace(/[^a-zA-Z0-9]/g,'%'); if (value!=null) url+='&search='+encodeURIComponent(value) value=$('#image_manager input[name=filename]').val(); if (value!=null) url+='&filename='+encodeURIComponent(value); if(selectedImageTab=='edit'){ url+='#image-tabs-edit' } updateContainer('selectImage',url, function(){ $( "#image-tabs" ).tabs(); $( "#image-tabs" ).tabs( "option", "active", 1 ); }); return false; } function hideContent(){ $(window).resize(function () { $('.ui-dialog').css({ 'width': $(window).width() - windowOffsetX, 'height': $(window).height() - windowOffsetY, 'left': windowOffsetX/2+'px', 'top': windowOffsetY/2+'px' }); }).resize(); $('.editor').each( function(){ $(this).hide(); } ); return false; } function showContent(){ $('.editor').each( function(){ $(this).show(); } ); return false; } // open dialog to edit image properties function editImage(filename){ $("#img_editor").load( 'image.cgi?show='+filename+'&template=image_edit.html&project_id='+project_id+'&studio_id='+studio_id, function(){ var x=$(window).width() - windowOffsetX; var y=$(window).height() - windowOffsetY; hideContent(); $('#img_editor').dialog({ appendTo: "#content", width:x, height:y, close: function( event, ui ) { showContent(); } }); } ); } // open dialog to show image preview function showImage(url){ $("#img_image").html('