| author | ymh <ymh.work@gmail.com> |
| Mon, 11 Jul 2011 18:19:45 +0200 | |
| changeset 85 | 2ff78b3ac007 |
| parent 77 | 80023516532f |
| child 99 | 743a4511d93c |
| permissions | -rw-r--r-- |
|
26
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
1 |
// -*- coding: utf-8 -*- |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
2 |
function init_tags_events() |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
3 |
{ |
|
32
ffd77b2b939f
First step of tag list. Enhance js function for datasheet context or tag list context.
cavaliet
parents:
31
diff
changeset
|
4 |
// Tag simple operations : activate/unactivate wp link, reset wp info, remove wp link, remove tag from list |
| 28 | 5 |
$(".reset_wp_info").click(function(e){ |
6 |
if(confirm("Confirmez-vous le rétablissement du label original de ce tag ?")){ |
|
|
31
142d0440c9aa
Remove wp link button activated. Some js function gathered.
cavaliet
parents:
28
diff
changeset
|
7 |
update_tag(this); |
|
142d0440c9aa
Remove wp link button activated. Some js function gathered.
cavaliet
parents:
28
diff
changeset
|
8 |
} |
|
142d0440c9aa
Remove wp link button activated. Some js function gathered.
cavaliet
parents:
28
diff
changeset
|
9 |
}); |
|
142d0440c9aa
Remove wp link button activated. Some js function gathered.
cavaliet
parents:
28
diff
changeset
|
10 |
$(".remove_wp_link").click(function(e){ |
|
142d0440c9aa
Remove wp link button activated. Some js function gathered.
cavaliet
parents:
28
diff
changeset
|
11 |
if(confirm("Confirmez-vous le suppression du lien Wikipédia pour le tag \"" + $(this).attr('alt') + "\" ?")){ |
|
142d0440c9aa
Remove wp link button activated. Some js function gathered.
cavaliet
parents:
28
diff
changeset
|
12 |
update_tag(this); |
| 28 | 13 |
} |
14 |
}); |
|
|
32
ffd77b2b939f
First step of tag list. Enhance js function for datasheet context or tag list context.
cavaliet
parents:
31
diff
changeset
|
15 |
$(".remove_tag_from_list").click(function(){ |
|
ffd77b2b939f
First step of tag list. Enhance js function for datasheet context or tag list context.
cavaliet
parents:
31
diff
changeset
|
16 |
if(confirm("Confirmez-vous la suppression du tag \"" + $(this).attr('alt') + "\" de la liste courante ?")){ |
|
ffd77b2b939f
First step of tag list. Enhance js function for datasheet context or tag list context.
cavaliet
parents:
31
diff
changeset
|
17 |
update_tag(this); |
|
ffd77b2b939f
First step of tag list. Enhance js function for datasheet context or tag list context.
cavaliet
parents:
31
diff
changeset
|
18 |
} |
|
ffd77b2b939f
First step of tag list. Enhance js function for datasheet context or tag list context.
cavaliet
parents:
31
diff
changeset
|
19 |
}); |
| 28 | 20 |
|
| 36 | 21 |
// Wikipedia search management (autocompletion and save changes) |
|
26
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
22 |
$.editable.addInputType('autocomplete', { |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
23 |
element : $.editable.types.text.element, |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
24 |
plugin : function(settings, original) { |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
25 |
$('input', this).autocomplete(settings.autocomplete); |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
26 |
} |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
27 |
}); |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
28 |
$(".wikipediatag").editable(modify_tag_url, { |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
29 |
indicator : "<img src='"+static_url+"hdabo/img/indicator.gif'>", |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
30 |
type : "autocomplete", |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
31 |
tooltip : "Cliquer pour éditer...", |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
32 |
onblur : "submit", |
|
32
ffd77b2b939f
First step of tag list. Enhance js function for datasheet context or tag list context.
cavaliet
parents:
31
diff
changeset
|
33 |
submitdata: { |
|
ffd77b2b939f
First step of tag list. Enhance js function for datasheet context or tag list context.
cavaliet
parents:
31
diff
changeset
|
34 |
csrfmiddlewaretoken:global_csrf_token, |
|
ffd77b2b939f
First step of tag list. Enhance js function for datasheet context or tag list context.
cavaliet
parents:
31
diff
changeset
|
35 |
datasheet_id:$('#datasheet_id').val(), |
|
ffd77b2b939f
First step of tag list. Enhance js function for datasheet context or tag list context.
cavaliet
parents:
31
diff
changeset
|
36 |
num_page:$('#num_page').val(), |
| 51 | 37 |
nb_by_page:$('#nb_by_page').val(), |
| 71 | 38 |
alpha:$('#alpha').val(), |
| 51 | 39 |
searched:$('#searched_str').val() |
|
32
ffd77b2b939f
First step of tag list. Enhance js function for datasheet context or tag list context.
cavaliet
parents:
31
diff
changeset
|
40 |
}, |
|
26
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
41 |
callback : function(value, settings) { |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
42 |
$('#tag_table_container').html(value); |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
43 |
init_tags_events(); |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
44 |
}, |
|
42
861a78f74a37
modify behavior for tag modification on the datasheet
ymh <ymh.work@gmail.com>
parents:
36
diff
changeset
|
45 |
onerror: function(settings, original, jqXHR) { |
|
861a78f74a37
modify behavior for tag modification on the datasheet
ymh <ymh.work@gmail.com>
parents:
36
diff
changeset
|
46 |
resp = $.parseJSON(jqXHR.responseText); |
|
861a78f74a37
modify behavior for tag modification on the datasheet
ymh <ymh.work@gmail.com>
parents:
36
diff
changeset
|
47 |
alert(resp.message); |
|
861a78f74a37
modify behavior for tag modification on the datasheet
ymh <ymh.work@gmail.com>
parents:
36
diff
changeset
|
48 |
original.reset(); |
|
861a78f74a37
modify behavior for tag modification on the datasheet
ymh <ymh.work@gmail.com>
parents:
36
diff
changeset
|
49 |
}, |
|
26
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
50 |
autocomplete : { |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
51 |
source: function( request, response ) { |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
52 |
$.ajax({ |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
53 |
url: "http://fr.wikipedia.org/w/api.php", |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
54 |
dataType: "jsonp", |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
55 |
data: { |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
56 |
action: "opensearch", |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
57 |
limit: "20", |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
58 |
namespace: "0", |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
59 |
format: "json", |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
60 |
search: request.term |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
61 |
}, |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
62 |
success: function( data ) { |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
63 |
response( $.map( data[1], function( item ) { |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
64 |
return { |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
65 |
label: item, |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
66 |
value: item |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
67 |
} |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
68 |
})); |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
69 |
} |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
70 |
}); |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
71 |
}, |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
72 |
minLength: 2, |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
73 |
open: function() { |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
74 |
$( this ).removeClass( "ui-corner-all" ).addClass( "ui-corner-top" ); |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
75 |
}, |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
76 |
close: function() { |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
77 |
$( this ).removeClass( "ui-corner-top" ).addClass( "ui-corner-all" ); |
|
34
26368d096723
Datasheet validation, better repartition of js function, hand cursor on buttons.
cavaliet
parents:
32
diff
changeset
|
78 |
} |
|
26
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
79 |
} |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
80 |
}); |
| 36 | 81 |
|
82 |
// Update alias management |
|
83 |
$(".tag_alias").editable(update_tag_alias_url, { |
|
84 |
indicator : "<img src='"+static_url+"hdabo/img/indicator.gif'>", |
|
85 |
type : "text", |
|
86 |
placeholder:"", |
|
87 |
tooltip : "Cliquer pour éditer...", |
|
88 |
onblur : "submit", |
|
89 |
submitdata: { |
|
90 |
csrfmiddlewaretoken:global_csrf_token, |
|
91 |
datasheet_id:$('#datasheet_id').val(), |
|
92 |
num_page:$('#num_page').val(), |
|
| 51 | 93 |
nb_by_page:$('#nb_by_page').val(), |
| 71 | 94 |
alpha:$('#alpha').val(), |
| 51 | 95 |
searched:$('#searched_str').val() |
| 36 | 96 |
}, |
97 |
callback : function(value, settings) { |
|
98 |
$('#tag_table_container').html(value); |
|
99 |
init_tags_events(); |
|
100 |
} |
|
101 |
}); |
|
|
44
244d805b4921
Reorder taggedsheet by drag and drop. Remove wikipedia_activated for a tag. TagCategory chosen by closed list.
cavaliet
parents:
43
diff
changeset
|
102 |
|
|
244d805b4921
Reorder taggedsheet by drag and drop. Remove wikipedia_activated for a tag. TagCategory chosen by closed list.
cavaliet
parents:
43
diff
changeset
|
103 |
// Tag categories management |
|
244d805b4921
Reorder taggedsheet by drag and drop. Remove wikipedia_activated for a tag. TagCategory chosen by closed list.
cavaliet
parents:
43
diff
changeset
|
104 |
$(".tag_category").editable(update_tag_category_url, { |
|
244d805b4921
Reorder taggedsheet by drag and drop. Remove wikipedia_activated for a tag. TagCategory chosen by closed list.
cavaliet
parents:
43
diff
changeset
|
105 |
indicator : "<img src='"+static_url+"hdabo/img/indicator.gif'>", |
|
244d805b4921
Reorder taggedsheet by drag and drop. Remove wikipedia_activated for a tag. TagCategory chosen by closed list.
cavaliet
parents:
43
diff
changeset
|
106 |
type : "select", |
| 46 | 107 |
data : categories_list, |
|
44
244d805b4921
Reorder taggedsheet by drag and drop. Remove wikipedia_activated for a tag. TagCategory chosen by closed list.
cavaliet
parents:
43
diff
changeset
|
108 |
placeholder:"", |
|
244d805b4921
Reorder taggedsheet by drag and drop. Remove wikipedia_activated for a tag. TagCategory chosen by closed list.
cavaliet
parents:
43
diff
changeset
|
109 |
tooltip : "Cliquer pour éditer...", |
|
244d805b4921
Reorder taggedsheet by drag and drop. Remove wikipedia_activated for a tag. TagCategory chosen by closed list.
cavaliet
parents:
43
diff
changeset
|
110 |
onblur : "submit", |
|
244d805b4921
Reorder taggedsheet by drag and drop. Remove wikipedia_activated for a tag. TagCategory chosen by closed list.
cavaliet
parents:
43
diff
changeset
|
111 |
submitdata: { |
|
244d805b4921
Reorder taggedsheet by drag and drop. Remove wikipedia_activated for a tag. TagCategory chosen by closed list.
cavaliet
parents:
43
diff
changeset
|
112 |
csrfmiddlewaretoken:global_csrf_token, |
| 61 | 113 |
datasheet_id:$('#datasheet_id').val(), |
|
44
244d805b4921
Reorder taggedsheet by drag and drop. Remove wikipedia_activated for a tag. TagCategory chosen by closed list.
cavaliet
parents:
43
diff
changeset
|
114 |
num_page:$('#num_page').val(), |
| 51 | 115 |
nb_by_page:$('#nb_by_page').val(), |
| 71 | 116 |
alpha:$('#alpha').val(), |
| 51 | 117 |
searched:$('#searched_str').val() |
|
44
244d805b4921
Reorder taggedsheet by drag and drop. Remove wikipedia_activated for a tag. TagCategory chosen by closed list.
cavaliet
parents:
43
diff
changeset
|
118 |
}, |
|
244d805b4921
Reorder taggedsheet by drag and drop. Remove wikipedia_activated for a tag. TagCategory chosen by closed list.
cavaliet
parents:
43
diff
changeset
|
119 |
callback : function(value, settings) { |
|
244d805b4921
Reorder taggedsheet by drag and drop. Remove wikipedia_activated for a tag. TagCategory chosen by closed list.
cavaliet
parents:
43
diff
changeset
|
120 |
$('#tag_table_container').html(value); |
|
244d805b4921
Reorder taggedsheet by drag and drop. Remove wikipedia_activated for a tag. TagCategory chosen by closed list.
cavaliet
parents:
43
diff
changeset
|
121 |
init_tags_events(); |
|
244d805b4921
Reorder taggedsheet by drag and drop. Remove wikipedia_activated for a tag. TagCategory chosen by closed list.
cavaliet
parents:
43
diff
changeset
|
122 |
} |
|
244d805b4921
Reorder taggedsheet by drag and drop. Remove wikipedia_activated for a tag. TagCategory chosen by closed list.
cavaliet
parents:
43
diff
changeset
|
123 |
}); |
|
244d805b4921
Reorder taggedsheet by drag and drop. Remove wikipedia_activated for a tag. TagCategory chosen by closed list.
cavaliet
parents:
43
diff
changeset
|
124 |
|
|
244d805b4921
Reorder taggedsheet by drag and drop. Remove wikipedia_activated for a tag. TagCategory chosen by closed list.
cavaliet
parents:
43
diff
changeset
|
125 |
// Tag table drag and drop |
|
244d805b4921
Reorder taggedsheet by drag and drop. Remove wikipedia_activated for a tag. TagCategory chosen by closed list.
cavaliet
parents:
43
diff
changeset
|
126 |
$("#tag_table").tableDnD({ |
|
244d805b4921
Reorder taggedsheet by drag and drop. Remove wikipedia_activated for a tag. TagCategory chosen by closed list.
cavaliet
parents:
43
diff
changeset
|
127 |
onDragClass: "dragged_row", |
|
244d805b4921
Reorder taggedsheet by drag and drop. Remove wikipedia_activated for a tag. TagCategory chosen by closed list.
cavaliet
parents:
43
diff
changeset
|
128 |
onDrop: function(table, row){ |
|
244d805b4921
Reorder taggedsheet by drag and drop. Remove wikipedia_activated for a tag. TagCategory chosen by closed list.
cavaliet
parents:
43
diff
changeset
|
129 |
old_order = row.id; |
| 56 | 130 |
$($(row).children()[1]).html("<img src='"+static_url+"hdabo/img/indicator.gif'/>"); |
|
44
244d805b4921
Reorder taggedsheet by drag and drop. Remove wikipedia_activated for a tag. TagCategory chosen by closed list.
cavaliet
parents:
43
diff
changeset
|
131 |
rows = table.tBodies[0].rows; |
|
244d805b4921
Reorder taggedsheet by drag and drop. Remove wikipedia_activated for a tag. TagCategory chosen by closed list.
cavaliet
parents:
43
diff
changeset
|
132 |
nb_rows = rows.length; |
|
244d805b4921
Reorder taggedsheet by drag and drop. Remove wikipedia_activated for a tag. TagCategory chosen by closed list.
cavaliet
parents:
43
diff
changeset
|
133 |
for(var i=1; i<nb_rows; i++){ |
|
244d805b4921
Reorder taggedsheet by drag and drop. Remove wikipedia_activated for a tag. TagCategory chosen by closed list.
cavaliet
parents:
43
diff
changeset
|
134 |
if(rows[i].id==old_order){ |
|
244d805b4921
Reorder taggedsheet by drag and drop. Remove wikipedia_activated for a tag. TagCategory chosen by closed list.
cavaliet
parents:
43
diff
changeset
|
135 |
new_order = i; // No need to +1 because rows[0] are headers |
|
244d805b4921
Reorder taggedsheet by drag and drop. Remove wikipedia_activated for a tag. TagCategory chosen by closed list.
cavaliet
parents:
43
diff
changeset
|
136 |
$.ajax({ |
|
244d805b4921
Reorder taggedsheet by drag and drop. Remove wikipedia_activated for a tag. TagCategory chosen by closed list.
cavaliet
parents:
43
diff
changeset
|
137 |
url: tag_up_down_url, |
|
244d805b4921
Reorder taggedsheet by drag and drop. Remove wikipedia_activated for a tag. TagCategory chosen by closed list.
cavaliet
parents:
43
diff
changeset
|
138 |
type: 'POST', |
|
244d805b4921
Reorder taggedsheet by drag and drop. Remove wikipedia_activated for a tag. TagCategory chosen by closed list.
cavaliet
parents:
43
diff
changeset
|
139 |
data: {csrfmiddlewaretoken:global_csrf_token, |
|
244d805b4921
Reorder taggedsheet by drag and drop. Remove wikipedia_activated for a tag. TagCategory chosen by closed list.
cavaliet
parents:
43
diff
changeset
|
140 |
datasheet_id:$('#datasheet_id').val(), |
|
244d805b4921
Reorder taggedsheet by drag and drop. Remove wikipedia_activated for a tag. TagCategory chosen by closed list.
cavaliet
parents:
43
diff
changeset
|
141 |
new_order:new_order, |
|
244d805b4921
Reorder taggedsheet by drag and drop. Remove wikipedia_activated for a tag. TagCategory chosen by closed list.
cavaliet
parents:
43
diff
changeset
|
142 |
old_order:old_order |
|
244d805b4921
Reorder taggedsheet by drag and drop. Remove wikipedia_activated for a tag. TagCategory chosen by closed list.
cavaliet
parents:
43
diff
changeset
|
143 |
}, |
|
244d805b4921
Reorder taggedsheet by drag and drop. Remove wikipedia_activated for a tag. TagCategory chosen by closed list.
cavaliet
parents:
43
diff
changeset
|
144 |
// bug with jquery >= 1.5, "json" adds a callback so we don't specify dataType |
|
244d805b4921
Reorder taggedsheet by drag and drop. Remove wikipedia_activated for a tag. TagCategory chosen by closed list.
cavaliet
parents:
43
diff
changeset
|
145 |
//dataType: 'json', |
|
244d805b4921
Reorder taggedsheet by drag and drop. Remove wikipedia_activated for a tag. TagCategory chosen by closed list.
cavaliet
parents:
43
diff
changeset
|
146 |
success: function(msg, textStatus, XMLHttpRequest) { |
|
244d805b4921
Reorder taggedsheet by drag and drop. Remove wikipedia_activated for a tag. TagCategory chosen by closed list.
cavaliet
parents:
43
diff
changeset
|
147 |
$('#tag_table_container').html(msg); |
|
244d805b4921
Reorder taggedsheet by drag and drop. Remove wikipedia_activated for a tag. TagCategory chosen by closed list.
cavaliet
parents:
43
diff
changeset
|
148 |
init_tags_events(); |
|
244d805b4921
Reorder taggedsheet by drag and drop. Remove wikipedia_activated for a tag. TagCategory chosen by closed list.
cavaliet
parents:
43
diff
changeset
|
149 |
} |
|
244d805b4921
Reorder taggedsheet by drag and drop. Remove wikipedia_activated for a tag. TagCategory chosen by closed list.
cavaliet
parents:
43
diff
changeset
|
150 |
}); |
|
244d805b4921
Reorder taggedsheet by drag and drop. Remove wikipedia_activated for a tag. TagCategory chosen by closed list.
cavaliet
parents:
43
diff
changeset
|
151 |
} |
|
244d805b4921
Reorder taggedsheet by drag and drop. Remove wikipedia_activated for a tag. TagCategory chosen by closed list.
cavaliet
parents:
43
diff
changeset
|
152 |
} |
|
244d805b4921
Reorder taggedsheet by drag and drop. Remove wikipedia_activated for a tag. TagCategory chosen by closed list.
cavaliet
parents:
43
diff
changeset
|
153 |
}, |
|
244d805b4921
Reorder taggedsheet by drag and drop. Remove wikipedia_activated for a tag. TagCategory chosen by closed list.
cavaliet
parents:
43
diff
changeset
|
154 |
dragHandle: "updown_td" |
|
244d805b4921
Reorder taggedsheet by drag and drop. Remove wikipedia_activated for a tag. TagCategory chosen by closed list.
cavaliet
parents:
43
diff
changeset
|
155 |
}); |
|
34
26368d096723
Datasheet validation, better repartition of js function, hand cursor on buttons.
cavaliet
parents:
32
diff
changeset
|
156 |
} |
|
26368d096723
Datasheet validation, better repartition of js function, hand cursor on buttons.
cavaliet
parents:
32
diff
changeset
|
157 |
|
|
26368d096723
Datasheet validation, better repartition of js function, hand cursor on buttons.
cavaliet
parents:
32
diff
changeset
|
158 |
function init_datasheet_events() |
|
26368d096723
Datasheet validation, better repartition of js function, hand cursor on buttons.
cavaliet
parents:
32
diff
changeset
|
159 |
{ |
| 77 | 160 |
var select_done = false; |
| 36 | 161 |
// Wikipedia search management (new tag) |
|
34
26368d096723
Datasheet validation, better repartition of js function, hand cursor on buttons.
cavaliet
parents:
32
diff
changeset
|
162 |
$("#wp_search").autocomplete({ |
|
26368d096723
Datasheet validation, better repartition of js function, hand cursor on buttons.
cavaliet
parents:
32
diff
changeset
|
163 |
source: function( request, response ) { |
|
26368d096723
Datasheet validation, better repartition of js function, hand cursor on buttons.
cavaliet
parents:
32
diff
changeset
|
164 |
$.ajax({ |
|
26368d096723
Datasheet validation, better repartition of js function, hand cursor on buttons.
cavaliet
parents:
32
diff
changeset
|
165 |
url: "http://fr.wikipedia.org/w/api.php", |
|
26368d096723
Datasheet validation, better repartition of js function, hand cursor on buttons.
cavaliet
parents:
32
diff
changeset
|
166 |
dataType: "jsonp", |
|
26368d096723
Datasheet validation, better repartition of js function, hand cursor on buttons.
cavaliet
parents:
32
diff
changeset
|
167 |
data: { |
|
26368d096723
Datasheet validation, better repartition of js function, hand cursor on buttons.
cavaliet
parents:
32
diff
changeset
|
168 |
action: "opensearch", |
|
26368d096723
Datasheet validation, better repartition of js function, hand cursor on buttons.
cavaliet
parents:
32
diff
changeset
|
169 |
limit: "20", |
|
26368d096723
Datasheet validation, better repartition of js function, hand cursor on buttons.
cavaliet
parents:
32
diff
changeset
|
170 |
namespace: "0", |
|
26368d096723
Datasheet validation, better repartition of js function, hand cursor on buttons.
cavaliet
parents:
32
diff
changeset
|
171 |
format: "json", |
|
26368d096723
Datasheet validation, better repartition of js function, hand cursor on buttons.
cavaliet
parents:
32
diff
changeset
|
172 |
search: request.term |
|
26368d096723
Datasheet validation, better repartition of js function, hand cursor on buttons.
cavaliet
parents:
32
diff
changeset
|
173 |
}, |
|
26368d096723
Datasheet validation, better repartition of js function, hand cursor on buttons.
cavaliet
parents:
32
diff
changeset
|
174 |
success: function( data ) { |
|
26368d096723
Datasheet validation, better repartition of js function, hand cursor on buttons.
cavaliet
parents:
32
diff
changeset
|
175 |
response( $.map( data[1], function( item ) { |
|
26368d096723
Datasheet validation, better repartition of js function, hand cursor on buttons.
cavaliet
parents:
32
diff
changeset
|
176 |
return { |
|
26368d096723
Datasheet validation, better repartition of js function, hand cursor on buttons.
cavaliet
parents:
32
diff
changeset
|
177 |
label: item, |
|
26368d096723
Datasheet validation, better repartition of js function, hand cursor on buttons.
cavaliet
parents:
32
diff
changeset
|
178 |
value: item |
|
26368d096723
Datasheet validation, better repartition of js function, hand cursor on buttons.
cavaliet
parents:
32
diff
changeset
|
179 |
} |
|
26368d096723
Datasheet validation, better repartition of js function, hand cursor on buttons.
cavaliet
parents:
32
diff
changeset
|
180 |
})); |
|
26368d096723
Datasheet validation, better repartition of js function, hand cursor on buttons.
cavaliet
parents:
32
diff
changeset
|
181 |
} |
|
26368d096723
Datasheet validation, better repartition of js function, hand cursor on buttons.
cavaliet
parents:
32
diff
changeset
|
182 |
}); |
|
26368d096723
Datasheet validation, better repartition of js function, hand cursor on buttons.
cavaliet
parents:
32
diff
changeset
|
183 |
}, |
|
62
953ee4c9c7c3
#5 : new tag integrated in list by click (ok not needed).
cavaliet
parents:
61
diff
changeset
|
184 |
select: function(event, ui) { |
|
953ee4c9c7c3
#5 : new tag integrated in list by click (ok not needed).
cavaliet
parents:
61
diff
changeset
|
185 |
// Since the event still did not update wp_search's val, we force it. |
|
953ee4c9c7c3
#5 : new tag integrated in list by click (ok not needed).
cavaliet
parents:
61
diff
changeset
|
186 |
$("#wp_search").val(ui.item.label); |
| 77 | 187 |
select_done = true; |
|
62
953ee4c9c7c3
#5 : new tag integrated in list by click (ok not needed).
cavaliet
parents:
61
diff
changeset
|
188 |
$("#ok_search").click(); |
|
953ee4c9c7c3
#5 : new tag integrated in list by click (ok not needed).
cavaliet
parents:
61
diff
changeset
|
189 |
}, |
|
34
26368d096723
Datasheet validation, better repartition of js function, hand cursor on buttons.
cavaliet
parents:
32
diff
changeset
|
190 |
minLength: 2, |
|
26368d096723
Datasheet validation, better repartition of js function, hand cursor on buttons.
cavaliet
parents:
32
diff
changeset
|
191 |
open: function() { |
|
26368d096723
Datasheet validation, better repartition of js function, hand cursor on buttons.
cavaliet
parents:
32
diff
changeset
|
192 |
$( this ).removeClass( "ui-corner-all" ).addClass( "ui-corner-top" ); |
|
26368d096723
Datasheet validation, better repartition of js function, hand cursor on buttons.
cavaliet
parents:
32
diff
changeset
|
193 |
}, |
|
26368d096723
Datasheet validation, better repartition of js function, hand cursor on buttons.
cavaliet
parents:
32
diff
changeset
|
194 |
close: function() { |
|
26368d096723
Datasheet validation, better repartition of js function, hand cursor on buttons.
cavaliet
parents:
32
diff
changeset
|
195 |
$( this ).removeClass( "ui-corner-top" ).addClass( "ui-corner-all" ); |
|
26368d096723
Datasheet validation, better repartition of js function, hand cursor on buttons.
cavaliet
parents:
32
diff
changeset
|
196 |
} |
|
26368d096723
Datasheet validation, better repartition of js function, hand cursor on buttons.
cavaliet
parents:
32
diff
changeset
|
197 |
}); |
| 77 | 198 |
$('#wp_search').keyup(function(e){ |
199 |
if((e.keyCode==13) && ($("#wp_search").val()!="") && (select_done==false)){ |
|
200 |
add_tag($("#wp_search").val()); |
|
201 |
} |
|
202 |
select_done = false; |
|
203 |
}); |
|
|
34
26368d096723
Datasheet validation, better repartition of js function, hand cursor on buttons.
cavaliet
parents:
32
diff
changeset
|
204 |
$("#ok_search").click(function(){ |
|
26368d096723
Datasheet validation, better repartition of js function, hand cursor on buttons.
cavaliet
parents:
32
diff
changeset
|
205 |
if($("#wp_search").val()!=""){ |
|
26368d096723
Datasheet validation, better repartition of js function, hand cursor on buttons.
cavaliet
parents:
32
diff
changeset
|
206 |
add_tag($("#wp_search").val()); |
|
26368d096723
Datasheet validation, better repartition of js function, hand cursor on buttons.
cavaliet
parents:
32
diff
changeset
|
207 |
} |
|
26368d096723
Datasheet validation, better repartition of js function, hand cursor on buttons.
cavaliet
parents:
32
diff
changeset
|
208 |
}); |
| 72 | 209 |
$("#tags_sort").click(function(e){ |
210 |
e.preventDefault(); |
|
211 |
if(confirm("Confirmez-vous le tri des tags ?")) { |
|
212 |
reorder_tags(); |
|
213 |
} |
|
214 |
}); |
|
|
34
26368d096723
Datasheet validation, better repartition of js function, hand cursor on buttons.
cavaliet
parents:
32
diff
changeset
|
215 |
// Validate sheet management : the radiobutton name has is "'gr_validated' + datasheet.hda_id" |
|
26368d096723
Datasheet validation, better repartition of js function, hand cursor on buttons.
cavaliet
parents:
32
diff
changeset
|
216 |
$("#validated").click(function(e){ |
|
26368d096723
Datasheet validation, better repartition of js function, hand cursor on buttons.
cavaliet
parents:
32
diff
changeset
|
217 |
e.preventDefault(); |
|
26368d096723
Datasheet validation, better repartition of js function, hand cursor on buttons.
cavaliet
parents:
32
diff
changeset
|
218 |
// We count the number of tags. It has to be between 5 and 25 |
|
26368d096723
Datasheet validation, better repartition of js function, hand cursor on buttons.
cavaliet
parents:
32
diff
changeset
|
219 |
var nb_tags = $('#tag_table tr').length - 1; |
|
26368d096723
Datasheet validation, better repartition of js function, hand cursor on buttons.
cavaliet
parents:
32
diff
changeset
|
220 |
if(nb_tags<5 || nb_tags>25){ |
|
26368d096723
Datasheet validation, better repartition of js function, hand cursor on buttons.
cavaliet
parents:
32
diff
changeset
|
221 |
alert("Cette fiche n'est pas validable : elle doit contenir entre 5 et 25 tags."); |
|
26368d096723
Datasheet validation, better repartition of js function, hand cursor on buttons.
cavaliet
parents:
32
diff
changeset
|
222 |
} |
|
26368d096723
Datasheet validation, better repartition of js function, hand cursor on buttons.
cavaliet
parents:
32
diff
changeset
|
223 |
else{ |
|
26368d096723
Datasheet validation, better repartition of js function, hand cursor on buttons.
cavaliet
parents:
32
diff
changeset
|
224 |
if(confirm("Confirmez-vous la validation de cette fiche ? Elle contient " + nb_tags + " tags.")){ |
|
26368d096723
Datasheet validation, better repartition of js function, hand cursor on buttons.
cavaliet
parents:
32
diff
changeset
|
225 |
window.location = validate_datasheet_url + "/" + $('#datasheet_id').val() + "/true"; |
|
26368d096723
Datasheet validation, better repartition of js function, hand cursor on buttons.
cavaliet
parents:
32
diff
changeset
|
226 |
} |
|
26368d096723
Datasheet validation, better repartition of js function, hand cursor on buttons.
cavaliet
parents:
32
diff
changeset
|
227 |
} |
|
26368d096723
Datasheet validation, better repartition of js function, hand cursor on buttons.
cavaliet
parents:
32
diff
changeset
|
228 |
}); |
|
26368d096723
Datasheet validation, better repartition of js function, hand cursor on buttons.
cavaliet
parents:
32
diff
changeset
|
229 |
$("#not_validated").click(function(e){ |
|
26368d096723
Datasheet validation, better repartition of js function, hand cursor on buttons.
cavaliet
parents:
32
diff
changeset
|
230 |
e.preventDefault(); |
|
26368d096723
Datasheet validation, better repartition of js function, hand cursor on buttons.
cavaliet
parents:
32
diff
changeset
|
231 |
if(confirm("Confirmez-vous l'invalidation de cette fiche ?")){ |
|
26368d096723
Datasheet validation, better repartition of js function, hand cursor on buttons.
cavaliet
parents:
32
diff
changeset
|
232 |
window.location = validate_datasheet_url + "/" + $('#datasheet_id').val() + "/false"; |
|
26368d096723
Datasheet validation, better repartition of js function, hand cursor on buttons.
cavaliet
parents:
32
diff
changeset
|
233 |
} |
|
26368d096723
Datasheet validation, better repartition of js function, hand cursor on buttons.
cavaliet
parents:
32
diff
changeset
|
234 |
}); |
|
26
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
235 |
} |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
236 |
|
|
31
142d0440c9aa
Remove wp link button activated. Some js function gathered.
cavaliet
parents:
28
diff
changeset
|
237 |
function update_tag(btn) |
|
26
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
238 |
{ |
|
32
ffd77b2b939f
First step of tag list. Enhance js function for datasheet context or tag list context.
cavaliet
parents:
31
diff
changeset
|
239 |
new_checked = false; |
|
31
142d0440c9aa
Remove wp link button activated. Some js function gathered.
cavaliet
parents:
28
diff
changeset
|
240 |
if ($(btn).is(".remove_tag_from_list")) { |
|
142d0440c9aa
Remove wp link button activated. Some js function gathered.
cavaliet
parents:
28
diff
changeset
|
241 |
var url = remove_tag_from_list_url; |
|
142d0440c9aa
Remove wp link button activated. Some js function gathered.
cavaliet
parents:
28
diff
changeset
|
242 |
var id_tag = $(btn).attr('id'); |
|
142d0440c9aa
Remove wp link button activated. Some js function gathered.
cavaliet
parents:
28
diff
changeset
|
243 |
} |
|
142d0440c9aa
Remove wp link button activated. Some js function gathered.
cavaliet
parents:
28
diff
changeset
|
244 |
else if ($(btn).is(".reset_wp_info")) { |
|
142d0440c9aa
Remove wp link button activated. Some js function gathered.
cavaliet
parents:
28
diff
changeset
|
245 |
var url = reset_wp_info_url; |
|
142d0440c9aa
Remove wp link button activated. Some js function gathered.
cavaliet
parents:
28
diff
changeset
|
246 |
var id_tag = $(btn).html(); |
|
32
ffd77b2b939f
First step of tag list. Enhance js function for datasheet context or tag list context.
cavaliet
parents:
31
diff
changeset
|
247 |
$(btn).html("<img src='"+static_url+"hdabo/img/indicator.gif'>"); |
|
31
142d0440c9aa
Remove wp link button activated. Some js function gathered.
cavaliet
parents:
28
diff
changeset
|
248 |
} |
|
142d0440c9aa
Remove wp link button activated. Some js function gathered.
cavaliet
parents:
28
diff
changeset
|
249 |
else if ($(btn).is(".remove_wp_link")) { |
|
142d0440c9aa
Remove wp link button activated. Some js function gathered.
cavaliet
parents:
28
diff
changeset
|
250 |
var url = remove_wp_link_url; |
|
142d0440c9aa
Remove wp link button activated. Some js function gathered.
cavaliet
parents:
28
diff
changeset
|
251 |
var id_tag = $(btn).attr('id'); |
|
142d0440c9aa
Remove wp link button activated. Some js function gathered.
cavaliet
parents:
28
diff
changeset
|
252 |
} |
|
32
ffd77b2b939f
First step of tag list. Enhance js function for datasheet context or tag list context.
cavaliet
parents:
31
diff
changeset
|
253 |
|
|
ffd77b2b939f
First step of tag list. Enhance js function for datasheet context or tag list context.
cavaliet
parents:
31
diff
changeset
|
254 |
// 2 cases : |
|
ffd77b2b939f
First step of tag list. Enhance js function for datasheet context or tag list context.
cavaliet
parents:
31
diff
changeset
|
255 |
// - ordered tag for one datasheet : $('#datasheet_id') is not null |
|
ffd77b2b939f
First step of tag list. Enhance js function for datasheet context or tag list context.
cavaliet
parents:
31
diff
changeset
|
256 |
// - all tags list : $('#datasheet_id') is null and $('#num_page') and $('#nb_by_page') are not null |
|
26
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
257 |
$.ajax({ |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
258 |
url: url, |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
259 |
type: 'POST', |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
260 |
data: {csrfmiddlewaretoken:global_csrf_token, |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
261 |
datasheet_id:$('#datasheet_id').val(), |
|
32
ffd77b2b939f
First step of tag list. Enhance js function for datasheet context or tag list context.
cavaliet
parents:
31
diff
changeset
|
262 |
num_page:$('#num_page').val(), |
|
ffd77b2b939f
First step of tag list. Enhance js function for datasheet context or tag list context.
cavaliet
parents:
31
diff
changeset
|
263 |
nb_by_page:$('#nb_by_page').val(), |
| 71 | 264 |
alpha:$('#alpha').val(), |
| 51 | 265 |
searched:$('#searched_str').val(), |
|
32
ffd77b2b939f
First step of tag list. Enhance js function for datasheet context or tag list context.
cavaliet
parents:
31
diff
changeset
|
266 |
tag_id:id_tag, |
|
ffd77b2b939f
First step of tag list. Enhance js function for datasheet context or tag list context.
cavaliet
parents:
31
diff
changeset
|
267 |
activated:new_checked |
|
26
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
268 |
}, |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
269 |
// bug with jquery >= 1.5, "json" adds a callback so we don't specify dataType |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
270 |
//dataType: 'json', |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
271 |
success: function(msg, textStatus, XMLHttpRequest) { |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
272 |
$('#tag_table_container').html(msg); |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
273 |
init_tags_events(); |
| 85 | 274 |
}, |
275 |
error: function(jqXHR, textStatus, errorThrown) { |
|
276 |
resp = $.parseJSON(jqXHR.responseText); |
|
277 |
alert(resp.message); |
|
278 |
$(btn).html(id_tag); |
|
279 |
} |
|
|
26
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
280 |
}); |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
281 |
} |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
282 |
|
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
283 |
function tag_up_down(arrow) |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
284 |
{ |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
285 |
if ($(arrow).is(".up")) { |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
286 |
mv = "u"; |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
287 |
} else { |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
288 |
mv = "d"; |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
289 |
} |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
290 |
var url = tag_up_down_url; |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
291 |
var id_tag = $(arrow).attr('id'); |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
292 |
// This indicates the position (from 0) of the tag in the list. NB : it is different from the TagSheet.order in the database. |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
293 |
var pos_tag = $(arrow).attr('pos'); |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
294 |
$.ajax({ |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
295 |
url: url, |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
296 |
type: 'POST', |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
297 |
data: {csrfmiddlewaretoken:global_csrf_token, |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
298 |
datasheet_id:$('#datasheet_id').val(), |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
299 |
tag_id:id_tag, |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
300 |
move:mv, |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
301 |
tag_pos:pos_tag |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
302 |
}, |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
303 |
// bug with jquery >= 1.5, "json" adds a callback so we don't specify dataType |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
304 |
//dataType: 'json', |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
305 |
success: function(msg, textStatus, XMLHttpRequest) { |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
306 |
$('#tag_table_container').html(msg); |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
307 |
init_tags_events(); |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
308 |
} |
|
699957597026
Add tag feature finished. Full page templates good placed.
cavaliet
parents:
24
diff
changeset
|
309 |
}); |
| 28 | 310 |
} |
311 |
||
|
31
142d0440c9aa
Remove wp link button activated. Some js function gathered.
cavaliet
parents:
28
diff
changeset
|
312 |
function add_tag(tag_label) |
| 28 | 313 |
{ |
|
31
142d0440c9aa
Remove wp link button activated. Some js function gathered.
cavaliet
parents:
28
diff
changeset
|
314 |
$("#ok_search").html("<img src='"+static_url+"hdabo/img/indicator.gif'>"); |
|
142d0440c9aa
Remove wp link button activated. Some js function gathered.
cavaliet
parents:
28
diff
changeset
|
315 |
var url = add_tag_url; |
|
142d0440c9aa
Remove wp link button activated. Some js function gathered.
cavaliet
parents:
28
diff
changeset
|
316 |
$.ajax({ |
|
142d0440c9aa
Remove wp link button activated. Some js function gathered.
cavaliet
parents:
28
diff
changeset
|
317 |
url: url, |
|
142d0440c9aa
Remove wp link button activated. Some js function gathered.
cavaliet
parents:
28
diff
changeset
|
318 |
type: 'POST', |
|
142d0440c9aa
Remove wp link button activated. Some js function gathered.
cavaliet
parents:
28
diff
changeset
|
319 |
data: {csrfmiddlewaretoken:global_csrf_token, |
|
142d0440c9aa
Remove wp link button activated. Some js function gathered.
cavaliet
parents:
28
diff
changeset
|
320 |
datasheet_id:$('#datasheet_id').val(), |
|
142d0440c9aa
Remove wp link button activated. Some js function gathered.
cavaliet
parents:
28
diff
changeset
|
321 |
value:tag_label |
|
142d0440c9aa
Remove wp link button activated. Some js function gathered.
cavaliet
parents:
28
diff
changeset
|
322 |
}, |
|
142d0440c9aa
Remove wp link button activated. Some js function gathered.
cavaliet
parents:
28
diff
changeset
|
323 |
// bug with jquery >= 1.5, "json" adds a callback so we don't specify dataType |
|
142d0440c9aa
Remove wp link button activated. Some js function gathered.
cavaliet
parents:
28
diff
changeset
|
324 |
//dataType: 'json', |
| 28 | 325 |
success: function(msg, textStatus, XMLHttpRequest) { |
326 |
$('#tag_table_container').html(msg); |
|
327 |
init_tags_events(); |
|
|
31
142d0440c9aa
Remove wp link button activated. Some js function gathered.
cavaliet
parents:
28
diff
changeset
|
328 |
// And scroll to the bottom |
|
142d0440c9aa
Remove wp link button activated. Some js function gathered.
cavaliet
parents:
28
diff
changeset
|
329 |
$("html").animate({ scrollTop: $(document).height() }, 500); |
|
142d0440c9aa
Remove wp link button activated. Some js function gathered.
cavaliet
parents:
28
diff
changeset
|
330 |
}, |
| 43 | 331 |
error: function(jqXHR, textStatus, errorThrown) { |
332 |
resp = $.parseJSON(jqXHR.responseText); |
|
333 |
alert(resp.message); |
|
334 |
}, |
|
|
31
142d0440c9aa
Remove wp link button activated. Some js function gathered.
cavaliet
parents:
28
diff
changeset
|
335 |
complete: function(){ |
|
142d0440c9aa
Remove wp link button activated. Some js function gathered.
cavaliet
parents:
28
diff
changeset
|
336 |
// We empty the input and hide the ok button |
|
142d0440c9aa
Remove wp link button activated. Some js function gathered.
cavaliet
parents:
28
diff
changeset
|
337 |
$("#wp_search").val(""); |
|
142d0440c9aa
Remove wp link button activated. Some js function gathered.
cavaliet
parents:
28
diff
changeset
|
338 |
$("#ok_search").html("<b>OK</b>"); |
| 28 | 339 |
} |
|
31
142d0440c9aa
Remove wp link button activated. Some js function gathered.
cavaliet
parents:
28
diff
changeset
|
340 |
}); |
|
142d0440c9aa
Remove wp link button activated. Some js function gathered.
cavaliet
parents:
28
diff
changeset
|
341 |
} |
| 72 | 342 |
|
343 |
function reorder_tags() { |
|
344 |
$('#tags_sort').attr("disabled", "disabled"); |
|
345 |
var tag_sort_old_src = $("#tags_sort").attr("src"); |
|
346 |
$("#tags_sort").attr("src",static_url+"hdabo/img/indicator.gif"); |
|
347 |
$.ajax({ |
|
348 |
url: reorder_tag_datasheet_url, |
|
349 |
type: 'POST', |
|
350 |
data: { |
|
351 |
csrfmiddlewaretoken:global_csrf_token, |
|
352 |
datasheet_id:$('#datasheet_id').val() |
|
353 |
}, |
|
354 |
success: function(msg, textStatus, XMLHttpRequest) { |
|
355 |
$('#tag_table_container').html(msg); |
|
356 |
init_tags_events(); |
|
357 |
// And scroll to the bottom |
|
358 |
$("html").animate({ scrollTop: $(document).height() }, 500); |
|
359 |
}, |
|
360 |
complete: function(){ |
|
361 |
$("#tags_sort").attr("src",tag_sort_old_src); |
|
362 |
$('#tags_sort').removeAttr("disabled"); |
|
363 |
} |
|
364 |
}); |
|
365 |
} |
|
366 |