2 * MyPlugin: demonstration plugin
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
16 var MyPlugin = Plugin.extend({
19 * @brief Plugin constructor
20 * @param options : an associative array of setting values
22 * @return : a jQuery collection of objects on which the plugin is
23 * applied, which allows to maintain chainability of calls
25 init: function(options, element) {
26 // Call the parent constructor, see FAQ when forgotten
27 this._super(options, element);
29 /* Member variables */
33 /* Setup query and record handlers */
35 // Explain this will allow query events to be handled
36 // What happens when we don't define some events ?
37 // Some can be less efficient
38 this.listen_query(options.query_uuid);
39 this.listen_query(options.query_uuid, 'all');
41 /* GUI setup and event binding */
47 // on_show like in hazelnut
52 // a function to bind events here: click change
53 // how to raise manifold events
56 /* GUI MANIPULATION */
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
62 show_hide_button: function()
64 // this.id, this.el, this.cl, this.elts
65 // same output as a jquery selector with some guarantees
70 // see in the html template
71 // How to load a template, use of mustache
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
81 on_filter_added: function(filter)
86 // ... be sure to list all events here
89 on_all_new_record: function(record)
94 /* INTERNAL FUNCTIONS */
96 // only convention, not strictly enforced at the moment
101 /* Plugin registration */
102 $.plugin('MyPlugin', MyPlugin);
104 // TODO Here use cases for instanciating plugins in different ways like in the pastie.