|
@@ -1167,88 +1167,154 @@ $(document).ready(function(){
|
1167
|
1167
|
|
1168
|
1168
|
// Ajout d'un element #ajouter (première partie)
|
1169
|
1169
|
|
1170
|
|
- // Click sur "ajouter" (l'url)
|
1171
|
|
- $('a#form_add_check_url').click(function(){
|
1172
|
|
-
|
1173
|
|
- // On fait tourner notre gif loader
|
1174
|
|
- $('img#form_add_loader').show();
|
1175
|
|
-
|
1176
|
|
- $.ajax({
|
1177
|
|
- type: 'POST',
|
1178
|
|
- url: url_datas_api,
|
1179
|
|
- data: {'url':$('input#element_add_url').val()},
|
1180
|
|
- success: function(response){
|
1181
|
|
-
|
1182
|
|
- if (response.status == 'mustbeconnected')
|
1183
|
|
- {
|
1184
|
|
- $(location).attr('href', url_index);
|
1185
|
|
- }
|
|
1170
|
+// // Click sur "ajouter" (l'url)
|
|
1171
|
+// $('a#form_add_check_url').click(function(){
|
|
1172
|
+//
|
|
1173
|
+// // On fait tourner notre gif loader
|
|
1174
|
+// $('img#form_add_loader').show();
|
|
1175
|
+//
|
|
1176
|
+// $.ajax({
|
|
1177
|
+// type: 'POST',
|
|
1178
|
+// url: url_datas_api,
|
|
1179
|
+// data: {'url':$('input#element_add_url').val()},
|
|
1180
|
+// success: function(response){
|
|
1181
|
+//
|
|
1182
|
+// if (response.status == 'mustbeconnected')
|
|
1183
|
+// {
|
|
1184
|
+// $(location).attr('href', url_index);
|
|
1185
|
+// }
|
|
1186
|
+//
|
|
1187
|
+// if (response.status == 'success')
|
|
1188
|
+// {
|
|
1189
|
+// // On cache notre gif loader.
|
|
1190
|
+// $('img#form_add_loader').hide();
|
|
1191
|
+//
|
|
1192
|
+// // On commence par renseigner les champs si on a du concret
|
|
1193
|
+// // name
|
|
1194
|
+// if (response.name)
|
|
1195
|
+// {
|
|
1196
|
+// $('input#element_add_name').val(response.name);
|
|
1197
|
+// }
|
|
1198
|
+//
|
|
1199
|
+// // thumb
|
|
1200
|
+// $('div#form_add_thumb img').attr('src', '/bundles/muzichcore/img/nothumb.png');
|
|
1201
|
+// if (response.thumb)
|
|
1202
|
+// {
|
|
1203
|
+// $('div#form_add_thumb img').attr('src', response.thumb);
|
|
1204
|
+// }
|
|
1205
|
+//
|
|
1206
|
+// // Proposition de tags
|
|
1207
|
+// if (response.tags)
|
|
1208
|
+// {
|
|
1209
|
+// $('ul#form_add_prop_tags li').remove();
|
|
1210
|
+// $('ul#form_add_prop_tags').show();
|
|
1211
|
+// $('ul#form_add_prop_tags_text').show();
|
|
1212
|
+//
|
|
1213
|
+// for (tags_index = 0; tags_index < response.tags.length; tags_index++)
|
|
1214
|
+// {
|
|
1215
|
+// var tag = response.tags[tags_index];
|
|
1216
|
+// var tag_id = '';
|
|
1217
|
+// var tag_name = tag.original_name;
|
|
1218
|
+// // Si il y a des équivalent en base.
|
|
1219
|
+// if (tag.like_found)
|
|
1220
|
+// {
|
|
1221
|
+// tag_id = tag.like.id;
|
|
1222
|
+// tag_name = tag.like.name;
|
|
1223
|
+// }
|
|
1224
|
+//
|
|
1225
|
+// // On aura plus qu'a vérifie le href pour savoir si c'est une demande d'ajout de tags =)
|
|
1226
|
+// $('ul#form_add_prop_tags').append(
|
|
1227
|
+// '<li>'+
|
|
1228
|
+// '<a href="#'+tag_id+'" class="form_add_prop_tag">'+
|
|
1229
|
+// tag_name+
|
|
1230
|
+// '</a>'+
|
|
1231
|
+// '</li>'
|
|
1232
|
+// );
|
|
1233
|
+// }
|
|
1234
|
+// }
|
|
1235
|
+//
|
|
1236
|
+// // On a plus qu'a afficher les champs
|
|
1237
|
+// $('div#form_add_second_part').slideDown();
|
|
1238
|
+// $('div#form_add_first_part').slideUp();
|
|
1239
|
+// form_add_hide_errors();
|
|
1240
|
+// }
|
|
1241
|
+// else if (response.status == 'error')
|
|
1242
|
+// {
|
|
1243
|
+// form_add_display_errors(response.errors);
|
|
1244
|
+// $('#form_add_loader').hide();
|
|
1245
|
+// return false;
|
|
1246
|
+// }
|
|
1247
|
+// },
|
|
1248
|
+// dataType: 'json'
|
|
1249
|
+// });
|
|
1250
|
+//
|
|
1251
|
+// });
|
|
1252
|
+
|
|
1253
|
+ function element_add_proceed_data_apis(response)
|
|
1254
|
+ {
|
|
1255
|
+ if (response.status == 'mustbeconnected')
|
|
1256
|
+ {
|
|
1257
|
+ $(location).attr('href', url_index);
|
|
1258
|
+ }
|
1186
|
1259
|
|
1187
|
|
- if (response.status == 'success')
|
|
1260
|
+ if (response.status == 'success')
|
|
1261
|
+ {
|
|
1262
|
+ // On cache notre gif loader.
|
|
1263
|
+ $('img#form_add_loader').hide();
|
|
1264
|
+
|
|
1265
|
+ // On commence par renseigner les champs si on a du concret
|
|
1266
|
+ // name
|
|
1267
|
+ if (response.name)
|
|
1268
|
+ {
|
|
1269
|
+ $('input#element_add_name').val(response.name);
|
|
1270
|
+ }
|
|
1271
|
+
|
|
1272
|
+ // thumb
|
|
1273
|
+ $('div#form_add_thumb img').attr('src', '/bundles/muzichcore/img/nothumb.png');
|
|
1274
|
+ if (response.thumb)
|
|
1275
|
+ {
|
|
1276
|
+ $('div#form_add_thumb img').attr('src', response.thumb);
|
|
1277
|
+ }
|
|
1278
|
+
|
|
1279
|
+ // Proposition de tags
|
|
1280
|
+ if (response.tags)
|
|
1281
|
+ {
|
|
1282
|
+ $('ul#form_add_prop_tags li').remove();
|
|
1283
|
+ $('ul#form_add_prop_tags').show();
|
|
1284
|
+ $('ul#form_add_prop_tags_text').show();
|
|
1285
|
+
|
|
1286
|
+ for (tags_index = 0; tags_index < response.tags.length; tags_index++)
|
1188
|
1287
|
{
|
1189
|
|
- // On cache notre gif loader.
|
1190
|
|
- $('img#form_add_loader').hide();
|
1191
|
|
-
|
1192
|
|
- // On commence par renseigner les champs si on a du concret
|
1193
|
|
- // name
|
1194
|
|
- if (response.name)
|
1195
|
|
- {
|
1196
|
|
- $('input#element_add_name').val(response.name);
|
1197
|
|
- }
|
1198
|
|
-
|
1199
|
|
- // thumb
|
1200
|
|
- $('div#form_add_thumb img').attr('src', '/bundles/muzichcore/img/nothumb.png');
|
1201
|
|
- if (response.thumb)
|
1202
|
|
- {
|
1203
|
|
- $('div#form_add_thumb img').attr('src', response.thumb);
|
1204
|
|
- }
|
1205
|
|
-
|
1206
|
|
- // Proposition de tags
|
1207
|
|
- if (response.tags)
|
|
1288
|
+ var tag = response.tags[tags_index];
|
|
1289
|
+ var tag_id = '';
|
|
1290
|
+ var tag_name = tag.original_name;
|
|
1291
|
+ // Si il y a des équivalent en base.
|
|
1292
|
+ if (tag.like_found)
|
1208
|
1293
|
{
|
1209
|
|
- $('ul#form_add_prop_tags li').remove();
|
1210
|
|
- $('ul#form_add_prop_tags').show();
|
1211
|
|
- $('ul#form_add_prop_tags_text').show();
|
1212
|
|
-
|
1213
|
|
- for (tags_index = 0; tags_index < response.tags.length; tags_index++)
|
1214
|
|
- {
|
1215
|
|
- var tag = response.tags[tags_index];
|
1216
|
|
- var tag_id = '';
|
1217
|
|
- var tag_name = tag.original_name;
|
1218
|
|
- // Si il y a des équivalent en base.
|
1219
|
|
- if (tag.like_found)
|
1220
|
|
- {
|
1221
|
|
- tag_id = tag.like.id;
|
1222
|
|
- tag_name = tag.like.name;
|
1223
|
|
- }
|
1224
|
|
-
|
1225
|
|
- // On aura plus qu'a vérifie le href pour savoir si c'est une demande d'ajout de tags =)
|
1226
|
|
- $('ul#form_add_prop_tags').append(
|
1227
|
|
- '<li>'+
|
1228
|
|
- '<a href="#'+tag_id+'" class="form_add_prop_tag">'+
|
1229
|
|
- tag_name+
|
1230
|
|
- '</a>'+
|
1231
|
|
- '</li>'
|
1232
|
|
- );
|
1233
|
|
- }
|
|
1294
|
+ tag_id = tag.like.id;
|
|
1295
|
+ tag_name = tag.like.name;
|
1234
|
1296
|
}
|
1235
|
|
-
|
1236
|
|
- // On a plus qu'a afficher les champs
|
1237
|
|
- $('div#form_add_second_part').slideDown();
|
1238
|
|
- $('div#form_add_first_part').slideUp();
|
1239
|
|
- form_add_hide_errors();
|
1240
|
|
- }
|
1241
|
|
- else if (response.status == 'error')
|
1242
|
|
- {
|
1243
|
|
- form_add_display_errors(response.errors);
|
1244
|
|
- $('#form_add_loader').hide();
|
1245
|
|
- return false;
|
|
1297
|
+
|
|
1298
|
+ // On aura plus qu'a vérifie le href pour savoir si c'est une demande d'ajout de tags =)
|
|
1299
|
+ $('ul#form_add_prop_tags').append(
|
|
1300
|
+ '<li>'+
|
|
1301
|
+ '<a href="#'+tag_id+'" class="form_add_prop_tag">'+
|
|
1302
|
+ tag_name+
|
|
1303
|
+ '</a>'+
|
|
1304
|
+ '</li>'
|
|
1305
|
+ );
|
1246
|
1306
|
}
|
1247
|
|
- },
|
1248
|
|
- dataType: 'json'
|
1249
|
|
- });
|
|
1307
|
+ }
|
|
1308
|
+
|
|
1309
|
+ return true;
|
|
1310
|
+ }
|
|
1311
|
+ else if (response.status == 'error')
|
|
1312
|
+ {
|
|
1313
|
+ return false;
|
|
1314
|
+ }
|
1250
|
1315
|
|
1251
|
|
- });
|
|
1316
|
+ return true;
|
|
1317
|
+ }
|
1252
|
1318
|
|
1253
|
1319
|
/*
|
1254
|
1320
|
* Formulaire d'ajout: click sur proposition de tags du a une api
|
|
@@ -1293,9 +1359,32 @@ $(document).ready(function(){
|
1293
|
1359
|
|
1294
|
1360
|
$('form[name="add"] img.tag_loader').hide();
|
1295
|
1361
|
|
1296
|
|
- if (element_add_proceed_json_response(response))
|
|
1362
|
+ // Si on en est a la promière étape la réponse sera des données récupérés auprès
|
|
1363
|
+ // des apis
|
|
1364
|
+ if ($('input#form_add_step').val() == '1')
|
|
1365
|
+ {
|
|
1366
|
+ if (element_add_proceed_data_apis(response))
|
|
1367
|
+ {
|
|
1368
|
+ // On a plus qu'a afficher les champs
|
|
1369
|
+ $('div#form_add_second_part').slideDown();
|
|
1370
|
+ $('div#form_add_first_part').slideUp();
|
|
1371
|
+ form_add_hide_errors();
|
|
1372
|
+ $('#form_add_loader').hide();
|
|
1373
|
+ $('input#form_add_step').val('2');
|
|
1374
|
+ $('form[name="add"]').attr('action', url_element_add);
|
|
1375
|
+ }
|
|
1376
|
+ else
|
|
1377
|
+ {
|
|
1378
|
+ form_add_display_errors(response.errors);
|
|
1379
|
+ $('#form_add_loader').hide();
|
|
1380
|
+ }
|
|
1381
|
+ }
|
|
1382
|
+ else if ($('input#form_add_step').val() == '2')
|
1297
|
1383
|
{
|
|
1384
|
+ if (element_add_proceed_json_response(response))
|
|
1385
|
+ {
|
1298
|
1386
|
form_add_reinit();
|
|
1387
|
+ }
|
1299
|
1388
|
}
|
1300
|
1389
|
|
1301
|
1390
|
|