plugin: switching hazelnut to use the Plugin class (wip)
[myslice.git] / plugins / myplugin / static / js / myplugin.js
1 /**
2  * MyPlugin:    demonstration plugin
3  * Version:     0.1
4  * Description: Template for writing new plugins and illustrating the different
5  *              possibilities of the plugin API.
6  *              This file is part of the Manifold project 
7  * Requires:    js/plugin.js
8  * URL:         http://www.myslice.info
9  * Author:      Jordan AugĂ© <jordan.auge@lip6.fr>
10  * Copyright:   Copyright 2012-2013 UPMC Sorbonne UniversitĂ©s
11  * License:     GPLv3
12  */
13
14 (function($){
15
16     var MyPlugin = Plugin.extend({
17
18         // Constructor
19         init: function(options, element) {
20             // Call the parent constructor, see FAQ when forgotten
21             this._super(options, element);
22
23             // Explain this will allow query events to be handled
24             // What happens when we don't define some events ?
25             // Some can be less efficient
26             this.listen_query(options.query_uuid);
27             this.listen_query(options.query_uuid, 'all');
28
29             // GUI Event binding
30             // call function
31
32         },
33
34         /* GUI EVENTS */
35
36         // a function to bind events here
37         // how to raise manifold events
38
39         /* GUI MANIPULATION */
40
41         // We advise you to write function to change behaviour of the GUI
42         // Will use naming helpers to access content _inside_ the plugin
43         // always refer to these functions in the remaining of the code
44
45         show_hide_button: function() 
46         {
47             // this.id, this.el, this.cl, this.els
48             // same output as a jquery selector with some guarantees
49         },
50
51         /* TEMPLATES */
52
53         // see in the html template
54         // How to load a template, use of mustache
55
56         /* QUERY HANDLERS */
57
58         // How to make sure the plugin is not desynchronized
59         // He should manifest its interest in filters, fields or records
60         // functions triggered only if the proper listen is done
61
62         // no prefix
63
64         on_filter_added: function(filter)
65         {
66
67         },
68
69         // ... be sure to list all events here
70
71         /* RECORD HANDLERS */
72         
73         on_record_received: function(record)
74         {
75             //
76         },
77
78     });
79
80     // TODO Here use cases for instanciating plugins in different ways like in the pastie.
81
82 })(jQuery);