easier direct editing of list items
[sgn.git] / js / CXGN / Phenome / Publication.js
blob538f6b041834a81929ab0ab60bb16227e3a054cd
1 /** 
2 * @class Publiction
3 * Function used for manipulating publication status, and curating
4 * @author Naama Menda <nm249@cornell.edu>
6 */
8 JSAN.use('MochiKit.DOM');
9 JSAN.use('MochiKit.Visual');
10 JSAN.use('MochiKit.Async');
12 JSAN.use('CXGN.Effects');
13 JSAN.use('CXGN.Phenome.Tools');
15 var Publication = {
17     //update status of pub_crator
18     updatePubCuratorStat: function(stat, pub_id) {
19         if (stat == '' || !pub_id ) { MochiKit.Logging.log('Cannot update status! '); }
20         else {
21             var action = "change_stat";
22             //alert ('About to update pub_curator status to -' +  stat + ' - (pub_id= ' + pub_id + ')') ;
23             new Ajax.Request('/curator/pub_curator.pl', {
24                     parameters: {stat: stat, pub_id: pub_id , action: action}, 
25                     onException: function(request) {
26                         var json=request.responseText;
27                         var x = eval("("+json+")");
28                         MochiKit.Logging.log("Failed updating  pub_curator", x.error);
29                     },
30                     onSuccess: function(request) {
31                         var json=request.responseText;
32                         var x = eval("("+json+")");
33                         MochiKit.Logging.log("JSON message:", x.error);
34                     }
35             });
36         }
37     },
38     //update assigned curator
39     updatePubCuratorAssigned: function(curator_id, pub_id) {
40         if (pub_id && curator_id) {
41             var action= "assign_curator";
42             new Ajax.Request('/curator/pub_curator.pl', {
43                     parameters: {curator_id: curator_id, pub_id:pub_id, action: action},
44                     onSuccess: function(response) {
45                         var json = response.responseText;
46                         var x = eval("("+json+")"); 
47                         //alert(x.error);
48                         MochiKit.Logging.log("stored pub_curator. " , x.error);
49                     },
50                     onFailure: function(response) {  //this does not work as expected! 
51                         var json = response.responseText;
52                         var x = eval("("+json+")"); 
53                         alert ("Failed assigning a pub curator! "  + x.error) ; 
54                     }
55             });
56         }
57     },
62 JSAN.use('jquery');
64 // add show/hide functionality to toggle-able publications
65 jQuery( function() {
66   jQuery('div.publication_embedded a.toggle_abstract').click(function() {
67     jQuery(this).next().toggle();
68     return false;
69   }).next().hide();
70 });