From 81047877cdb45b16a567f003da24c42b3559c608 Mon Sep 17 00:00:00 2001
From: renato <renato@rezo.net>
Date: Fri, 17 Nov 2006 16:26:45 +0000
Subject: [PATCH] fix the customized thumbnails upload interface

---
 dist/javascript/async_upload.js | 54 +++++++++++++++++++--------------
 ecrire/inc/legender.php         |  8 +++--
 2 files changed, 36 insertions(+), 26 deletions(-)

diff --git a/dist/javascript/async_upload.js b/dist/javascript/async_upload.js
index 275cc9da2b..0e8c50fb98 100644
--- a/dist/javascript/async_upload.js
+++ b/dist/javascript/async_upload.js
@@ -62,29 +62,37 @@ jQuery.fn.async_upload = function(add_function) {
 
 function async_upload_article_edit(res,jForm){
       var cont;
-      //add a class to new documents
-      res.
-      find(">div[@class]")
-        .addClass("documents_added")
-        .css("display","none")
-      .end();
-      if (jForm.find("input[@name='arg']").val().search("vignette")!=-1)
-        cont = $("#liste_images");
-      else
-        cont = $("#liste_documents");
-      cont
-      .prepend(res.html());
-      //find added documents, remove label and show them nicely
-      cont.
-      find("div.documents_added")
-        .removeClass("documents_added")
-        .show("slow",function(){
-            var anim = $(this).css("height","");
-            //bug explorer-opera-safari
-            if(!jQuery.browser.mozilla) anim.width(this.orig.width-2);
-            $(anim).find("img[@onclick]").get(0).onclick();
-        })
-        .overflow("");
+      //verify if a new document or a customized vignette
+      var anchor = $(res.find(">a:first"));
+      res.end(); 
+			if($("#"+anchor.id()).size()) {
+				cont = $("#"+anchor.id()).next().next().html(anchor.next().next().html());
+			} else {
+	      //add a class to new documents
+	      res.
+	      find(">div[@class]")
+	        .addClass("documents_added")
+	        .css("display","none")
+	      .end();
+	      if (jForm.find("input[@name='arg']").val().search("/0/vignette")!=-1)
+	        cont = $("#liste_images");
+	      else
+	        cont = $("#liste_documents");
+	      cont
+	      .prepend(res.html());
+	      //find added documents, remove label and show them nicely
+	      cont.
+	      find("div.documents_added")
+	        .removeClass("documents_added")
+	        .show("slow",function(){
+	            var anim = $(this).css("height","");
+	            //bug explorer-opera-safari
+	            if(!jQuery.browser.mozilla) anim.width(this.orig.width-2);
+	            $(anim).find("img[@onclick]").get(0).onclick();
+	        })
+	        .overflow("");
+	    }
+			$("form.form_upload",cont).async_upload(async_upload_article_edit);
       verifForm(cont);
       return true;
 }
diff --git a/ecrire/inc/legender.php b/ecrire/inc/legender.php
index 41516db1b2..fe183f0a83 100644
--- a/ecrire/inc/legender.php
+++ b/ecrire/inc/legender.php
@@ -130,9 +130,11 @@ function vignette_formulaire_legender($id_document, $document, $script, $type, $
 	$id_vignette = $document['id_vignette'];
 	$texte = _T('info_supprimer_vignette');
 
-	if (preg_match('/_edit$/', $script))
+	if (preg_match('/_edit$/', $script)) {
+		$iframe_redirect = generer_url_ecrire("documents_colonne","id=$id&type=$type",true);
 		$action = redirige_action_auteur('supprimer', "document-$id_vignette", $script, "id_$type=$id&show_docs=$id_document#$ancre");
-	else {
+	} else {
+		$iframe_redirect = generer_url_ecrire("documenter","id_$type=$id&type=$type",true);
 		$s = ($ancre =='documents' ? '': '-');
 		$action = ajax_action_auteur('documenter', "$s$id/$type/$id_vignette", $script, "id_$type=$id&type=$type&s=$s&show_docs=$id_document#$ancre", array($texte),'',"function(r,noeud) {noeud.innerHTML = r; \$('.form_upload',noeud).async_upload(async_upload_portfolio_documents);}");
 	}
@@ -141,7 +143,7 @@ function vignette_formulaire_legender($id_document, $document, $script, $type, $
 
 	return "<hr style='margin-left: -5px; margin-right: -5px; height: 1px; border: 0px; color: #eeeeee; background-color: white;' />"
 	. (!$id_vignette
-	   ? $joindre($script, "id_$type=$id",$id, _T('info_vignette_personnalisee'), 'vignette', $type, $ancre, $id_document,generer_url_ecrire("documenter","id_$type=$id&type=$type",true))
+	   ? $joindre($script, "id_$type=$id",$id, _T('info_vignette_personnalisee'), 'vignette', $type, $ancre, $id_document,$iframe_redirect)
 	   : icone_horizontale($texte, $action, "vignette-24.png", "supprimer.gif", false));
 }
 
-- 
GitLab