diff -r 984ba20c150b -r 1bc0ec8ed05b Resources/public/js/wikiTag.js
--- a/Resources/public/js/wikiTag.js Fri Dec 09 02:27:20 2011 +0100
+++ b/Resources/public/js/wikiTag.js Fri Dec 09 04:53:56 2011 +0100
@@ -4,17 +4,27 @@
// Tag simple operations : activate/unactivate wp link, reset wp info, remove wp link, remove tag from list
$(".wikitag_reset_wp_info").click(function(e){
if(confirm("Confirmez-vous le rétablissement du label original de ce tag ?")){
- wikitag_update_tag(this);
+ var id_tag = $(this).html();
+ var btn = this;
+ $(this).html("
");
+ wikitag_update_tag(this, reset_wp_info_url, id_tag, function(){ $(btn).html(id_tag); });
+ }
+ });
+ $(".wikitag_relaunch_wp_search").click(function(e){
+ if(confirm("Confirmez-vous la relance de la recherche Wikipédia pour le tag \"" + $(this).attr('alt') + "\" ?")){
+ $(this).toggleClass("wikitag_relaunch_wp_search wikitag_indicator");
+ var btn = this;
+ wikitag_update_tag(this, relaunch_wp_search_url, $(this).attr('id'), function() { $(btn).toggleClass("wikitag_relaunch_wp_search wikitag_indicator");});
}
});
$(".wikitag_remove_wp_link").click(function(e){
if(confirm("Confirmez-vous le suppression du lien Wikipédia pour le tag \"" + $(this).attr('alt') + "\" ?")){
- wikitag_update_tag(this);
+ wikitag_update_tag(this, remove_wp_link_url, $(this).attr('id'));
}
});
$(".wikitag_remove_tag_from_list").click(function(){
if(confirm("Confirmez-vous la suppression du tag \"" + $(this).attr('alt') + "\" de la liste courante ?")){
- wikitag_update_tag(this);
+ wikitag_update_tag(this,remove_tag_from_list_url,$(this).attr('id'));
}
});
@@ -316,23 +326,9 @@
});
}
-function wikitag_update_tag(btn)
+function wikitag_update_tag(btn, url, id_tag, error_callback)
{
new_checked = false;
- if ($(btn).is(".wikitag_remove_tag_from_list")) {
- var url = remove_tag_from_list_url;
- var id_tag = $(btn).attr('id');
- }
- else if ($(btn).is(".wikitag_reset_wp_info")) {
- var url = reset_wp_info_url;
- var id_tag = $(btn).html();
- $(btn).html("
");
- }
- else if ($(btn).is(".wikitag_remove_wp_link")) {
- var url = remove_wp_link_url;
- var id_tag = $(btn).attr('id');
- }
-
// 2 cases :
// - ordered tag for one datasheet : $('#wikitag_document_id') is not null
// - all tags list : $('#wikitag_document_id') is null and $('#num_page') and $('#nb_by_page') are not null
@@ -358,7 +354,7 @@
error: function(jqXHR, textStatus, errorThrown) {
resp = $.parseJSON(jqXHR.responseText);
alert(resp.message);
- $(btn).html(id_tag);
+ error_callback && error_callback();
}
});
}