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++) {
24 if(theinputs.item(i).get("name") != "returnurl") { // Dont include return url for ajax requests.
25 thedata[theinputs.item(i).get("name")] = theinputs.item(i).get("value");
33 complete : function(tid, outcome, args) {
40 var data = scope.Y.JSON.parse(outcome.responseText);
42 //if the user has access to the aggregate then update it
43 if (data.itemid) { //do not test data.aggregate or data.count otherwise it doesn't refresh value=0 or no value
44 var itemid = data.itemid;
46 var node = scope.Y.one('#ratingaggregate' + itemid);
47 node.set('innerHTML',data.aggregate);
49 // Empty the count value if no ratings.
50 var node = scope.Y.one('#ratingcount' + itemid);
52 node.set('innerHTML', "(" + data.count + ")");
54 node.set('innerHTML', "");
59 else if (data.error) {
63 alert(e.message + " " + outcome.responseText);
73 data: build_querystring(thedata)
75 this.Y.io(this.api, cfg);