//$("#imgFotografia").click(function(e){ $("#imgFotografia, .imgFotografia").click(function(e){ var boton = $(this); var mensaje = '
\
\
\ \
\ \
\
\
\
\
\ \
\
\ \
\
\
\
\ \
\
\
\ \ \
\
\ \
\
\
\
\
\
'; BootstrapDialog.show({ title: "Biblioteca de imágenes", type: BootstrapDialog.TYPE_DEFAULT, message: mensaje, draggable: true, cssClass: "ModalBiblioteca", onshown: function(dialogRef){ $("#flImagen").dropzone({ url: $("#hdnRutaImagenes").val(), maxFiles: 1, acceptedFiles: "image/jpeg,image/png,image/gif", maxFilesize: 1, success: function(file, response){ if(response.success){ var value = response.imagen; var img = new Image(); img.src = value; img.onload = function(){ if(img.height != 0){ //$("#imgFotografia").attr("src", value); boton.attr("src", value); if( boton[0].hasAttribute("data-hdn") ){ var eliminar = false; if( $("#"+boton.attr("data-hdn")).length == 1 ){ if( $("#"+boton.attr("data-hdn")).attr("name") == "fotografia_extra[]" ){ eliminar = true; } } else{ eliminar = true; } if( eliminar ){ $("#"+boton.attr("data-hdn")).remove(); var numero = boton.attr("data-hdn").replace( /^\D+/g, ""); boton.after(''); } $("#"+boton.attr("data-hdn")).val(value); } else{ $("#hdnFotografia").val(value); } $("#btnCrearImagen").html("Usar imágen").prop("disabled", false); dialogRef.close(); $.isLoading("hide"); NProgress.done(); } else{ new PNotify({ title: "Error", text: "La imágen no pudo ser cargada, por favor vuelve a intentarlo", type: "error" }); $("#btnCrearImagen").html("Usar imágen").prop("disabled", false); dialogRef.close(); $.isLoading("hide"); NProgress.done(); } } img.onerror = function(){ new PNotify({ title: "Error", text: "La imágen no pudo ser cargada, por favor vuelve a intentarlo", type: "error" }); $("#btnCrearImagen").html("Usar imágen").prop("disabled", false); dialogRef.close(); $.isLoading("hide"); NProgress.done(); }; } else{ dialogRef.close(); new PNotify({ title: "Error", text: "Ha ocurrido un error, por favor notificalo a soporte!", type: "error" }); } }, init: function() { this.on("addedfile", function(file){ var dropzone = this; if(this.files.length > 1){ new PNotify({ title: "Error", text: "No puedes subir más de 1 archivo", type: "error" }); $.each(this.files, function(i, file){ dropzone.removeFile(file); }); } }); this.on("maxfilesexceeded", function(file){ new PNotify({ title: "Error", text: "No puedes subir más de 1 archivo", type: "error" }); $.each(this.files, function(i, file){ dropzone.removeFile(file); }); }); this.on("error", function(file, message){ console.log( message ); var mensaje = message; var borrar = false; if( mensaje.indexOf("Max filesize:") !== -1 ){ borrar = true; var texto = "El archivo no debe de tener un tamaño mayor a 1MB"; } else if( mensaje.indexOf("You can't upload files of this type.") !== -1 ){ borrar = true; var texto = "El formato del archivo que intentas cargar no es soportado"; } if( borrar ){ var dropzone = this; $.each(this.files, function(i, file){ dropzone.removeFile(file); }); } new PNotify({ title: "Error", text: texto, type: "error" }); }); this.on("processing", function(file){ $.isLoading({ text: "Cargando..." }); NProgress.start(); $("#btnCrearImagen").prop("disabled", true).html(' Procesando...'); }); } }).on("thumbnail", function(file, dataUri) { console.log(dataUri); }); $.get( $("#rutabibliotecascliente").val()+$("#cid").val(), function(data){ if(data.success){ $("#slBiblioteca").html("").append(''); $.each(data.biblioteca, function(index, val){ $("#slBiblioteca").append("