4c84a90c6c2a3de6bf9e1e95b6b4707b017b8757
[myslice.git] / plugins / univbris / static / js / univbris.js
1 /**
2  * univbris:    test plugin for Bristol University
3  * Version:     0.1
4  * Description: just testing plugin in myslice
5  * Requires:    js/plugin.js
6  * URL:         http://www.myslice.info
7  * Author:      Frederic Francois <f.francois@bristol.ac.uk>
8  * Copyright:   Copyright 2012-2013 Bristol University
9  * License:     GPLv3
10  */
11
12 (function($){
13
14     var Univbris = Plugin.extend({
15
16         /** XXX to check
17          * @brief Plugin constructor
18          * @param options : an associative array of setting values
19          * @param element : 
20          * @return : a jQuery collection of objects on which the plugin is
21          *     applied, which allows to maintain chainability of calls
22          */
23         init: function(options, element) {
24             // Call the parent constructor, see FAQ when forgotten
25             this._super(options, element);
26
27             /* Member variables */
28
29             /* Plugin events */
30
31             /* Setup query and record handlers */
32
33             // Explain this will allow query events to be handled
34             // What happens when we don't define some events ?
35             // Some can be less efficient
36             this.listen_query(options.query_uuid);
37             this.listen_query(options.query_uuid, 'all');
38
39             /* GUI setup and event binding */
40             // call function
41
42             alert("univbris plugin 2");
43
44         },
45
46         /* PLUGIN EVENTS */
47         // on_show like in querytable
48
49
50         /* GUI EVENTS */
51
52         // a function to bind events here: click change
53         // how to raise manifold events
54
55
56         /* GUI MANIPULATION */
57
58         // We advise you to write function to change behaviour of the GUI
59         // Will use naming helpers to access content _inside_ the plugin
60         // always refer to these functions in the remaining of the code
61
62         show_hide_button: function() 
63         {
64             // this.id, this.el, this.cl, this.elts
65             // same output as a jquery selector with some guarantees
66         },
67
68         /* TEMPLATES */
69
70         // see in the html template
71         // How to load a template, use of mustache
72
73         /* QUERY HANDLERS */
74
75         // How to make sure the plugin is not desynchronized
76         // He should manifest its interest in filters, fields or records
77         // functions triggered only if the proper listen is done
78
79         // no prefix
80
81         on_filter_added: function(filter)
82         {
83
84         },
85
86         // ... be sure to list all events here
87
88         /* RECORD HANDLERS */
89         on_all_new_record: function(record)
90         {
91             //
92         },
93
94         /* INTERNAL FUNCTIONS */
95         _dummy: function() {
96             // only convention, not strictly enforced at the moment
97         },
98
99     });
100
101     /* Plugin registration */
102     $.plugin('Univbris', Univbris);
103
104     // TODO Here use cases for instanciating plugins in different ways like in the pastie.
105
106 })(jQuery);