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