dd987cde67278d700730e77933afe6ec962b5b17
[myslice.git] / plugins / validatebutton / static / js / validatebutton.js
1 // first application is for the 'validation' button in the topmenu
2 // if the subject query is non empty, then we turn on the subject button
3 // that is provided through button_domid
4
5 (function($){
6
7     var debug=false;
8     debug=true
9
10     var ValidateButton = Plugin.extend({
11
12         init: function(options, element) {
13             this._super(options, element);
14             this.listen_query(options.query_uuid);
15             this.triggered=false;
16         },
17
18         // we have received at least one answer: we'll do something
19         on_new_record: function (record) {
20             // we only need to act on the first record
21             if (this.triggered) return;
22             if (debug) messages.debug("validatebutton.on_query_done - turning on "+this.options.button_domid);
23             $('#'+this.options.button_domid).removeClass('disabled');
24             this.triggered=true;
25         },
26         // for reference only, since there is nothing we need to do at this point
27         on_query_done: function() {
28         },
29     });
30
31     $.plugin('ValidateButton', ValidateButton);
32
33 })(jQuery);