|
223 | 223 | if(jtarget.hasClass("publish-checkbox")) { |
224 | 224 | pageId = jtarget.attr("name").split("status-")[1]; |
225 | 225 | // if I don't put data in the post, django doesn't get it |
226 | | - reloadItem( |
227 | | - jtarget, admin_base_url + "cms/page/" + pageId + "/change-status/", |
228 | | - { 1:1 }, |
229 | | - // on success |
230 | | - function(decoded,textStatus){ |
231 | | - response = decoded.content; |
232 | | - status = decoded.status; |
233 | | - if(status==200) { |
234 | | - if (/page_\d+/.test($(jtarget).attr('id'))) { |
235 | | - // one level higher |
236 | | - target = $(jtarget).find('div.cont:first'); |
237 | | - } else { |
238 | | - target = $(jtarget).parents('div.cont:first'); |
239 | | - } |
| 226 | + reloadItem( |
| 227 | + jtarget, admin_base_url + "cms/page/" + pageId + "/change-status/", |
| 228 | + { 1:1 }, |
| 229 | + // on success |
| 230 | + function(decoded,textStatus){ |
| 231 | + response = decoded.content; |
| 232 | + status = decoded.status; |
| 233 | + if(status==200) { |
| 234 | + if (/page_\d+/.test($(jtarget).attr('id'))) { |
| 235 | + // one level higher |
| 236 | + target = $(jtarget).find('div.cont:first'); |
| 237 | + } else { |
| 238 | + target = $(jtarget).parents('div.cont:first'); |
| 239 | + } |
240 | 240 |
|
241 | | - var parent = target.parent(); |
242 | | - if (response == "NotFound") { |
243 | | - return parent.remove(); |
244 | | - } |
245 | | - target.replace(response); |
246 | | - parent.find('div.cont:first').yft(); |
| 241 | + var parent = target.parent(); |
| 242 | + if (response == "NotFound") { |
| 243 | + return parent.remove(); |
| 244 | + } |
| 245 | + target.replace(response); |
| 246 | + parent.find('div.cont:first').yft(); |
247 | 247 |
|
248 | | - return true; |
249 | | - } |
250 | | - else { |
251 | | - $(jtarget).attr("checked",false) |
252 | | - alert(response); |
253 | | - return false; |
254 | | - } |
255 | | - } |
256 | | - ); |
| 248 | + return false; |
| 249 | + } |
| 250 | + else { |
| 251 | + $(jtarget).attr("checked",false) |
| 252 | + alert(response); |
| 253 | + return false; |
| 254 | + } |
| 255 | + } |
| 256 | + ); |
257 | 257 | e.stopPropagation(); |
258 | 258 | return true; |
259 | 259 | } |
|
429 | 429 | }; |
430 | 430 | data = $.extend(data, options); |
431 | 431 |
|
432 | | - $.post("./" + item_id + "/copy-page/", data, function(html) { |
433 | | - if(html=="ok"){ |
| 432 | + $.post("./" + item_id + "/copy-page/", data, function(decoded) { |
| 433 | + response = decoded.content; |
| 434 | + status = decoded.status; |
| 435 | + if(status==200) { |
434 | 436 | // reload tree |
435 | 437 | window.location = window.location.href; |
436 | 438 | }else{ |
437 | | - moveError($('#page_'+item_id + " div.col1:eq(0)")); |
| 439 | + alert(response); |
| 440 | + moveError($('#page_'+item_id + " div.col1:eq(0)"),response); |
438 | 441 | } |
439 | 442 | }); |
440 | 443 | } |
|
468 | 471 | } |
469 | 472 |
|
470 | 473 | function onSuccess(response, textStatus) { |
471 | | - status = true; |
| 474 | + status = true; |
472 | 475 | if (callback) status = callback(response, textStatus); |
473 | 476 |
|
474 | | - if(status==true) { |
475 | | - if (/page_\d+/.test($(el).attr('id'))) { |
476 | | - // one level higher |
477 | | - target = $(el).find('div.cont:first'); |
478 | | - } else { |
479 | | - target = $(el).parents('div.cont:first'); |
480 | | - } |
| 477 | + if(status==true) { |
| 478 | + if (/page_\d+/.test($(el).attr('id'))) { |
| 479 | + // one level higher |
| 480 | + target = $(el).find('div.cont:first'); |
| 481 | + } else { |
| 482 | + target = $(el).parents('div.cont:first'); |
| 483 | + } |
481 | 484 |
|
482 | | - var parent = target.parent(); |
483 | | - if (response == "NotFound") { |
484 | | - return parent.remove(); |
485 | | - } |
486 | | - target.replace(response); |
487 | | - parent.find('div.cont:first').yft(); |
488 | | - } |
| 485 | + var parent = target.parent(); |
| 486 | + if (response == "NotFound") { |
| 487 | + return parent.remove(); |
| 488 | + } |
| 489 | + target.replace(response); |
| 490 | + parent.find('div.cont:first').yft(); |
| 491 | + } |
489 | 492 |
|
490 | 493 | return true; |
491 | 494 | } |
|
509 | 512 | reloadItem( |
510 | 513 | jtarget, "./" + item_id + "/move-page/", |
511 | 514 |
|
512 | | - { position: position, target: target_id }, |
513 | | - |
| 515 | + { position: position, target: target_id }, |
| 516 | + |
514 | 517 | // on success |
515 | | - function(){ |
516 | | - if (tree) { |
517 | | - var tree_pos = {'left': 'before', 'right': 'after'}[position] || 'inside'; |
518 | | - tree.moved("#page_" + item_id, $("#page_" + target_id + " a.title")[0], tree_pos, false, false); |
519 | | - } else { |
520 | | - moveSuccess($('#page_'+item_id + " div.col1:eq(0)")); |
| 518 | + function(decoded,textStatus){ |
| 519 | + response = decoded.content; |
| 520 | + status = decoded.status; |
| 521 | + if(status==200) { |
| 522 | + if (tree) { |
| 523 | + var tree_pos = {'left': 'before', 'right': 'after'}[position] || 'inside'; |
| 524 | + tree.moved("#page_" + item_id, $("#page_" + target_id + " a.title")[0], tree_pos, false, false); |
| 525 | + } else { |
| 526 | + moveSuccess($('#page_'+item_id + " div.col1:eq(0)")); |
| 527 | + } |
| 528 | + return false; |
| 529 | + } |
| 530 | + else { |
| 531 | + moveError($('#page_'+item_id + " div.col1:eq(0)"),response); |
| 532 | + return false; |
521 | 533 | } |
522 | | - return true; |
523 | | - }, |
524 | | - |
525 | | - // on error |
526 | | - function(){ |
527 | | - moveError($('#page_'+item_id + " div.col1:eq(0)")); |
528 | | - return false; |
529 | 534 | } |
530 | 535 | ); |
531 | 536 | } |
|
0 commit comments