renamed validatebutton into topmenuvalidation
[myslice.git] / plugins / topmenuvalidation / static / js / topmenuvalidation.opj
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 TopmenuValidation = 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         // Could be the default in parent
19         on_query_in_progress: function() {
20             var presets = spin_presets();
21             presets.radius=5;
22             presets.length=4;
23             presets.lines=7;
24             presets.width=2;
25             this.spin(presets);
26         },
27
28         // we have received at least one answer: we'll do something
29         on_new_record: function (record) {
30             // we only need to act on the first record
31             if (this.triggered) return;
32             $('#'+this.options.button_domid).removeClass('disabled');
33             this.unspin();
34             this.triggered=true;
35         },
36         // for reference only, since there is nothing we need to do at this point
37         on_query_done: function() {
38             if (!this.triggered) this.unspin();
39         },
40     });
41
42     $.plugin('TopmenuValidation', TopmenuValidation);
43
44 })(jQuery);