4 api: M.cfg.wwwroot+'/rating/rate_ajax.php',
8 Y.all('select.postratingmenu').each(this.attach_rating_events, this);
10 //hide the submit buttons
11 this.Y.all('input.postratingmenusubmit').setStyle('display', 'none');
14 attach_rating_events : function(selectnode) {
15 selectnode.on('change', this.submit_rating, this, selectnode);
18 submit_rating : function(e, selectnode){
19 var theinputs = selectnode.ancestor('form').all('.ratinginput');
22 var inputssize = theinputs.size();
23 for ( var i=0; i<inputssize; i++ )
25 if(theinputs.item(i).get("name")!="returnurl") {//dont include return url for ajax requests
26 thedata[theinputs.item(i).get("name")] = theinputs.item(i).get("value");
34 complete : function(tid, outcome, args) {
41 var data = scope.Y.JSON.parse(outcome.responseText);
43 //if the user has access to the aggregate then update it
44 if (data.itemid) { //do not test data.aggregate or data.count otherwise it doesn't refresh value=0 or no value
45 var itemid = data.itemid;
47 var node = scope.Y.one('#ratingaggregate'+itemid);
48 node.set('innerHTML',data.aggregate);
50 //empty the count value if no ratings
51 var node = scope.Y.one('#ratingcount'+itemid);
53 node.set('innerHTML',"("+data.count+")");
55 node.set('innerHTML',"");
64 alert(e.message+" "+outcome.responseText);
74 data: build_querystring(thedata)
76 this.Y.io(this.api, cfg);