|
@@ -851,128 +851,15 @@ $(document).ready(function(){
|
851
|
851
|
// Si le tag ne semble pas connu en base
|
852
|
852
|
if (!data.same_found)
|
853
|
853
|
{
|
854
|
|
- // Cette variable nous permettra de stocker le lien nouveau tag
|
855
|
|
- var link_add_tag = null;
|
856
|
|
-
|
857
|
854
|
li_tag =
|
858
|
855
|
$('<li>').addClass('new').append(
|
859
|
856
|
$('<a>').attr('href','#new#'+$.trim(input.val()))
|
860
|
857
|
// qui réagit quand on clique dessus
|
861
|
|
- .click(function(e){
|
862
|
|
-
|
863
|
|
- // Effet fade-in du fond opaque
|
864
|
|
- $('body').append($('<div>').attr('id', 'fade'));
|
865
|
|
- //Apparition du fond - .css({'filter' : 'alpha(opacity=80)'}) pour corriger les bogues de IE
|
866
|
|
- $('#fade').css({'filter' : 'alpha(opacity=80)'}).fadeIn();
|
867
|
|
-
|
868
|
|
- // On met le lien cliqué dans la variabke prévu
|
869
|
|
- link_add_tag = $(this);
|
870
|
|
-
|
871
|
|
- // En premier lieux on fait apparaître la fenêtre de confirmation
|
872
|
|
- var popup = $('<div>')
|
873
|
|
- .attr('id', 'add_tag')
|
874
|
|
- .addClass('popin_block')
|
875
|
|
- .css('width', '400px')
|
876
|
|
- //.append($('<h2>').append(string_tag_add_title))
|
877
|
|
- .append($('<form>')
|
878
|
|
- .attr('action', url_add_tag)
|
879
|
|
- .attr('method', 'post')
|
880
|
|
- .attr('name', 'add_tag')
|
881
|
|
- .ajaxForm(function(response) {
|
882
|
|
- /*
|
883
|
|
- *
|
884
|
|
- */
|
885
|
|
-
|
886
|
|
- if (response.status == 'mustbeconnected')
|
887
|
|
- {
|
888
|
|
- $(location).attr('href', url_index);
|
889
|
|
- }
|
890
|
|
-
|
891
|
|
- if (response.status == 'success')
|
892
|
|
- {
|
893
|
|
- var tag_id = response.tag_id;
|
894
|
|
- var tag_name = response.tag_name;
|
895
|
|
-
|
896
|
|
- $('input#tags_selected_tag_'+form_name).val(tag_id);
|
897
|
|
- inputTag.val(tag_name);
|
898
|
|
- // Et on execute l'évènement selectTag de l'input
|
899
|
|
- inputTag.trigger("selectTag");
|
900
|
|
- // On cache la liste puisque le choix vient d'être fait
|
901
|
|
- divtags.hide();
|
902
|
|
- inputTag.val(tag_text_help);
|
903
|
|
-
|
904
|
|
- link_add_tag.parents('div.search_tag_list').find('img.tag_loader').hide();
|
905
|
|
-
|
906
|
|
- $('#fade').fadeOut(400, function(){$('#fade').remove();});
|
907
|
|
- $('#add_tag').remove();
|
908
|
|
- }
|
909
|
|
-
|
910
|
|
- if (response.status == 'error')
|
911
|
|
- {
|
912
|
|
- $('form[name="add_tag"]').find('ul.error_list').remove();
|
913
|
|
- var ul_errors = $('<ul>').addClass('error_list');
|
914
|
|
-
|
915
|
|
- for (i in response.errors)
|
916
|
|
- {
|
917
|
|
- ul_errors.append($('<li>').append(response.errors[i]));
|
918
|
|
- }
|
919
|
|
-
|
920
|
|
- $('form[name="add_tag"]').prepend(ul_errors);
|
921
|
|
- }
|
922
|
|
-
|
923
|
|
- return false;
|
924
|
|
- })
|
925
|
|
-
|
926
|
|
- .append($('<div>').addClass('tag')
|
927
|
|
- .append($('<ul>')
|
928
|
|
- .append($('<li>').addClass('button')
|
929
|
|
- .append($(this).text()))))
|
930
|
|
- .append($('<p>').append(string_tag_add_text))
|
931
|
|
- .append($('<p>').append(string_tag_add_argument))
|
932
|
|
- .append($('<textarea>').attr('name', 'argument'))
|
933
|
|
- .append($('<div>').addClass('inputs')
|
934
|
|
- .append($('<input>')
|
935
|
|
- .attr('type', 'button')
|
936
|
|
- .attr('value', string_tag_add_inputs_cancel)
|
937
|
|
- .addClass('button')
|
938
|
|
- .click(function(){
|
939
|
|
- $('#fade').fadeOut(1000, function(){$('#fade').remove();});
|
940
|
|
- $('#add_tag').remove();
|
941
|
|
-
|
942
|
|
- return false;
|
943
|
|
- })
|
944
|
|
- )
|
945
|
|
- .append($('<input>')
|
946
|
|
- .attr('type', 'submit')
|
947
|
|
- .attr('value', string_tag_add_inputs_submit)
|
948
|
|
- .addClass('button')
|
949
|
|
- .click(function(){
|
950
|
|
-
|
951
|
|
- link_add_tag.parents('div.search_tag_list').find('img.tag_loader').show();
|
952
|
|
-
|
953
|
|
- })
|
954
|
|
- )
|
955
|
|
- .append($('<input>').attr('type', 'hidden').attr('name', 'tag_name').val($(this).text()))
|
956
|
|
- ))
|
957
|
|
- ;
|
958
|
|
-
|
959
|
|
- // Il faut ajouter le popup au dom avant de le positionner en css
|
960
|
|
- // Sinon la valeur height n'est pas encore calculable
|
961
|
|
- $('body').prepend(popup);
|
962
|
|
-
|
963
|
|
- //Récupération du margin, qui permettra de centrer la fenêtre - on ajuste de 80px en conformité avec le CSS
|
964
|
|
- var popMargTop = (popup.height() + 50) / 2;
|
965
|
|
- var popMargLeft = (popup.width() + 50) / 2;
|
966
|
|
-
|
967
|
|
- //On affecte le margin
|
968
|
|
- $(popup).css({
|
969
|
|
- 'margin-top' : -popMargTop,
|
970
|
|
- 'margin-left' : -popMargLeft
|
971
|
|
- });
|
972
|
|
-
|
973
|
|
- return false;
|
974
|
|
-
|
975
|
|
- })
|
|
858
|
+ .click({
|
|
859
|
+ inputTag: inputTag,
|
|
860
|
+ form_name: form_name,
|
|
861
|
+ divtags: divtags
|
|
862
|
+ }, event_click_new_tag_proposition)
|
976
|
863
|
.append($.trim(input.val()))
|
977
|
864
|
);
|
978
|
865
|
search_tag_list.append(li_tag);
|
|
@@ -991,7 +878,125 @@ $(document).ready(function(){
|
991
|
878
|
|
992
|
879
|
}
|
993
|
880
|
}
|
|
881
|
+
|
|
882
|
+ function event_click_new_tag_proposition(event)
|
|
883
|
+ {
|
|
884
|
+ form_add_open_dialog_for_new_tag($(event.target), event.data.inputTag, event.data.form_name, event.data.divtags);
|
|
885
|
+ }
|
994
|
886
|
|
|
887
|
+ function form_add_open_dialog_for_new_tag(link_add_tag, inputTag, form_name, divtags)
|
|
888
|
+ {
|
|
889
|
+
|
|
890
|
+
|
|
891
|
+ // Effet fade-in du fond opaque
|
|
892
|
+ $('body').append($('<div>').attr('id', 'fade'));
|
|
893
|
+ //Apparition du fond - .css({'filter' : 'alpha(opacity=80)'}) pour corriger les bogues de IE
|
|
894
|
+ $('#fade').css({'filter' : 'alpha(opacity=80)'}).fadeIn();
|
|
895
|
+
|
|
896
|
+ // En premier lieux on fait apparaître la fenêtre de confirmation
|
|
897
|
+ var popup = $('<div>')
|
|
898
|
+ .attr('id', 'add_tag')
|
|
899
|
+ .addClass('popin_block')
|
|
900
|
+ .css('width', '400px')
|
|
901
|
+ //.append($('<h2>').append(string_tag_add_title))
|
|
902
|
+ .append($('<form>')
|
|
903
|
+ .attr('action', url_add_tag)
|
|
904
|
+ .attr('method', 'post')
|
|
905
|
+ .attr('name', 'add_tag')
|
|
906
|
+ .ajaxForm(function(response) {
|
|
907
|
+ /*
|
|
908
|
+ *
|
|
909
|
+ */
|
|
910
|
+
|
|
911
|
+ if (response.status == 'mustbeconnected')
|
|
912
|
+ {
|
|
913
|
+ $(location).attr('href', url_index);
|
|
914
|
+ }
|
|
915
|
+
|
|
916
|
+ if (response.status == 'success')
|
|
917
|
+ {
|
|
918
|
+ var tag_id = response.tag_id;
|
|
919
|
+ var tag_name = response.tag_name;
|
|
920
|
+
|
|
921
|
+ $('input#tags_selected_tag_'+form_name).val(tag_id);
|
|
922
|
+ inputTag.val(tag_name);
|
|
923
|
+ // Et on execute l'évènement selectTag de l'input
|
|
924
|
+ inputTag.trigger("selectTag");
|
|
925
|
+ // On cache la liste puisque le choix vient d'être fait
|
|
926
|
+ divtags.hide();
|
|
927
|
+ inputTag.val(tag_text_help);
|
|
928
|
+
|
|
929
|
+ link_add_tag.parents('div.search_tag_list').find('img.tag_loader').hide();
|
|
930
|
+
|
|
931
|
+ $('#fade').fadeOut(400, function(){$('#fade').remove();});
|
|
932
|
+ $('#add_tag').remove();
|
|
933
|
+ }
|
|
934
|
+
|
|
935
|
+ if (response.status == 'error')
|
|
936
|
+ {
|
|
937
|
+ $('form[name="add_tag"]').find('ul.error_list').remove();
|
|
938
|
+ var ul_errors = $('<ul>').addClass('error_list');
|
|
939
|
+
|
|
940
|
+ for (i in response.errors)
|
|
941
|
+ {
|
|
942
|
+ ul_errors.append($('<li>').append(response.errors[i]));
|
|
943
|
+ }
|
|
944
|
+
|
|
945
|
+ $('form[name="add_tag"]').prepend(ul_errors);
|
|
946
|
+ }
|
|
947
|
+
|
|
948
|
+ return false;
|
|
949
|
+ })
|
|
950
|
+
|
|
951
|
+ .append($('<div>').addClass('tag')
|
|
952
|
+ .append($('<ul>')
|
|
953
|
+ .append($('<li>').addClass('button')
|
|
954
|
+ .append(link_add_tag.text()))))
|
|
955
|
+ .append($('<p>').append(string_tag_add_text))
|
|
956
|
+ .append($('<p>').append(string_tag_add_argument))
|
|
957
|
+ .append($('<textarea>').attr('name', 'argument'))
|
|
958
|
+ .append($('<div>').addClass('inputs')
|
|
959
|
+ .append($('<input>')
|
|
960
|
+ .attr('type', 'button')
|
|
961
|
+ .attr('value', string_tag_add_inputs_cancel)
|
|
962
|
+ .addClass('button')
|
|
963
|
+ .click(function(){
|
|
964
|
+ $('#fade').fadeOut(1000, function(){$('#fade').remove();});
|
|
965
|
+ $('#add_tag').remove();
|
|
966
|
+
|
|
967
|
+ return false;
|
|
968
|
+ })
|
|
969
|
+ )
|
|
970
|
+ .append($('<input>')
|
|
971
|
+ .attr('type', 'submit')
|
|
972
|
+ .attr('value', string_tag_add_inputs_submit)
|
|
973
|
+ .addClass('button')
|
|
974
|
+ .click(function(){
|
|
975
|
+
|
|
976
|
+ link_add_tag.parents('div.search_tag_list').find('img.tag_loader').show();
|
|
977
|
+
|
|
978
|
+ })
|
|
979
|
+ )
|
|
980
|
+ .append($('<input>').attr('type', 'hidden').attr('name', 'tag_name').val(link_add_tag.text()))
|
|
981
|
+ ))
|
|
982
|
+ ;
|
|
983
|
+
|
|
984
|
+ // Il faut ajouter le popup au dom avant de le positionner en css
|
|
985
|
+ // Sinon la valeur height n'est pas encore calculable
|
|
986
|
+ $('body').prepend(popup);
|
|
987
|
+
|
|
988
|
+ //Récupération du margin, qui permettra de centrer la fenêtre - on ajuste de 80px en conformité avec le CSS
|
|
989
|
+ var popMargTop = (popup.height() + 50) / 2;
|
|
990
|
+ var popMargLeft = (popup.width() + 50) / 2;
|
|
991
|
+
|
|
992
|
+ //On affecte le margin
|
|
993
|
+ $(popup).css({
|
|
994
|
+ 'margin-top' : -popMargTop,
|
|
995
|
+ 'margin-left' : -popMargLeft
|
|
996
|
+ });
|
|
997
|
+
|
|
998
|
+ return false;
|
|
999
|
+ }
|
995
|
1000
|
|
996
|
1001
|
var last_keypress = 0;
|
997
|
1002
|
|
|
@@ -1146,19 +1151,20 @@ $(document).ready(function(){
|
1146
|
1151
|
}
|
1147
|
1152
|
}
|
1148
|
1153
|
|
1149
|
|
- // Ajout d'un element #ajouter
|
|
1154
|
+ // Ajout d'un element #ajouter (première partie)
|
1150
|
1155
|
|
1151
|
1156
|
// Click sur "ajouter" (l'url)
|
1152
|
1157
|
$('a#form_add_check_url').click(function(){
|
1153
|
1158
|
|
|
1159
|
+ // On fait tourner notre gif loader
|
|
1160
|
+ $('img#form_add_loader').show();
|
|
1161
|
+
|
1154
|
1162
|
$.ajax({
|
1155
|
1163
|
type: 'POST',
|
1156
|
1164
|
url: url_datas_api,
|
1157
|
1165
|
data: {'url':$('input#element_add_url').val()},
|
1158
|
1166
|
success: function(response){
|
1159
|
1167
|
|
1160
|
|
- console.debug(response);
|
1161
|
|
-
|
1162
|
1168
|
if (response.status == 'mustbeconnected')
|
1163
|
1169
|
{
|
1164
|
1170
|
$(location).attr('href', url_index);
|
|
@@ -1166,7 +1172,57 @@ $(document).ready(function(){
|
1166
|
1172
|
|
1167
|
1173
|
if (response.status == 'success')
|
1168
|
1174
|
{
|
1169
|
|
-
|
|
1175
|
+ // On cache notre gif loader.
|
|
1176
|
+ $('img#form_add_loader').hide();
|
|
1177
|
+
|
|
1178
|
+ // On commence par renseigner les champs si on a du concret
|
|
1179
|
+ // name
|
|
1180
|
+ if (response.name)
|
|
1181
|
+ {
|
|
1182
|
+ $('input#element_add_name').val(response.name);
|
|
1183
|
+ }
|
|
1184
|
+
|
|
1185
|
+ // thumb
|
|
1186
|
+ $('div#form_add_thumb img').attr('src', '/bundles/muzichcore/img/nothumb.png');
|
|
1187
|
+ if (response.thumb)
|
|
1188
|
+ {
|
|
1189
|
+ $('div#form_add_thumb img').attr('src', response.thumb);
|
|
1190
|
+ }
|
|
1191
|
+
|
|
1192
|
+ // Proposition de tags
|
|
1193
|
+ if (response.tags)
|
|
1194
|
+ {
|
|
1195
|
+ $('ul#form_add_prop_tags li').remove();
|
|
1196
|
+ $('ul#form_add_prop_tags').show();
|
|
1197
|
+ $('ul#form_add_prop_tags_text').show();
|
|
1198
|
+
|
|
1199
|
+ for (tags_index = 0; tags_index < response.tags.length; tags_index++)
|
|
1200
|
+ {
|
|
1201
|
+ var tag = response.tags[tags_index];
|
|
1202
|
+ var tag_id = '';
|
|
1203
|
+ var tag_name = tag.original_name;
|
|
1204
|
+ // Si il y a des équivalent en base.
|
|
1205
|
+ if (tag.like_found)
|
|
1206
|
+ {
|
|
1207
|
+ tag_id = tag.like.id;
|
|
1208
|
+ tag_name = tag.like.name;
|
|
1209
|
+ }
|
|
1210
|
+
|
|
1211
|
+ // On aura plus qu'a vérifie le href pour savoir si c'est une demande d'ajout de tags =)
|
|
1212
|
+ $('ul#form_add_prop_tags').append(
|
|
1213
|
+ '<li>'+
|
|
1214
|
+ '<a href="#'+tag_id+'" class="form_add_prop_tag">'+
|
|
1215
|
+ tag_name+
|
|
1216
|
+ '</a>'+
|
|
1217
|
+ '</li>'
|
|
1218
|
+ );
|
|
1219
|
+ }
|
|
1220
|
+ }
|
|
1221
|
+
|
|
1222
|
+ // On a plus qu'a afficher les champs
|
|
1223
|
+ $('div#form_add_second_part').slideDown();
|
|
1224
|
+ $('div#form_add_first_part').slideUp();
|
|
1225
|
+
|
1170
|
1226
|
}
|
1171
|
1227
|
},
|
1172
|
1228
|
dataType: 'json'
|
|
@@ -1174,7 +1230,36 @@ $(document).ready(function(){
|
1174
|
1230
|
|
1175
|
1231
|
});
|
1176
|
1232
|
|
|
1233
|
+ /*
|
|
1234
|
+ * Formulaire d'ajout: click sur proposition de tags du a une api
|
|
1235
|
+ */
|
|
1236
|
+
|
|
1237
|
+ $('a.form_add_prop_tag').live('click', function(){
|
|
1238
|
+
|
|
1239
|
+ var form_name = "add";
|
|
1240
|
+ var tag_id = str_replace('#', '', $(this).attr('href'));
|
|
1241
|
+ var input_tag = $("div.tags_prompt ul.tagbox li.input input");
|
|
1242
|
+
|
|
1243
|
+ // Si on connait le tag id (pas un nouveau tag donc)
|
|
1244
|
+ if (tag_id)
|
|
1245
|
+ {
|
|
1246
|
+ $('input#tags_selected_tag_'+form_name).val(tag_id);
|
|
1247
|
+ input_tag.val($(this).text());
|
|
1248
|
+ // Et on execute l'évènement selectTag de l'input
|
|
1249
|
+ input_tag.trigger("selectTag");
|
|
1250
|
+ input_tag.val(tag_text_help);
|
|
1251
|
+ }
|
|
1252
|
+ else
|
|
1253
|
+ {
|
|
1254
|
+ // Cette var sert a rien ici, mais c'est la refactorisation qui
|
|
1255
|
+ // pose problmeme (corrigeable cela dit)
|
|
1256
|
+ var divtags = $("#search_tag_"+form_name);
|
|
1257
|
+ form_add_open_dialog_for_new_tag($(this), input_tag, form_name, divtags);
|
|
1258
|
+ }
|
|
1259
|
+
|
|
1260
|
+ });
|
1177
|
1261
|
|
|
1262
|
+ // #ajouter ajouter un élément (envoi du formulaire)
|
1178
|
1263
|
$('form[name="add"] input[type="submit"]').live('click', function(){
|
1179
|
1264
|
$('form[name="add"]').find('img.tag_loader').show();
|
1180
|
1265
|
});
|
|
@@ -1187,6 +1272,12 @@ $(document).ready(function(){
|
1187
|
1272
|
$('form[name="add"] img.tag_loader').hide();
|
1188
|
1273
|
element_add_proceed_json_response(response);
|
1189
|
1274
|
|
|
1275
|
+ $('div#element_add_box').slideUp();
|
|
1276
|
+ $('div#form_add_first_part').show();
|
|
1277
|
+ $('div#form_add_second_part').hide();
|
|
1278
|
+ $('ul#form_add_prop_tags').hide();
|
|
1279
|
+ $('ul#form_add_prop_tags_text').hide();
|
|
1280
|
+
|
1190
|
1281
|
return false;
|
1191
|
1282
|
});
|
1192
|
1283
|
|