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 SlaDialog = 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 // for debugging tools
27 this.classname="SlaDialog";
28 // Call the parent constructor, see FAQ when forgotten
29 this._super(options, element);
31 /* Member variables */
35 /* Setup query and record handlers */
37 // Explain this will allow query events to be handled
38 // What happens when we don't define some events ?
39 // Some can be less efficient
40 this.listen_query(options.query_uuid);
42 /* GUI setup and event binding */
47 find_row: function(key)
49 // key in third position, column id = 2
52 var cols = $.grep(this.table.fnSettings().aoData, function(col) {
53 return (col._aData[KEY_POS] == key);
59 throw "Too many same-key rows in ResourceSelected plugin";
65 // on_show like in querytable
70 uncheck: function(urn)
72 $('#slamodal').on('hidden.bs.modal', function(e){
73 $('#' + (urn).replace(/"/g,'')).click();
74 console.log('#' + (data.value).replace(/"/g,''));
78 // a function to bind events here: click change
79 // how to raise manifold events
80 set_state: function(data, username)
85 post_agreement: function()
87 console.log(this.options.user);
90 /* GUI MANIPULATION */
92 // We advise you to write function to change behaviour of the GUI
93 // Will use naming helpers to access content _inside_ the plugin
94 // always refer to these functions in the remaining of the code
96 show_hide_button: function()
98 // this.id, this.el, this.cl, this.elts
99 // same output as a jquery selector with some guarantees
104 // see in the html template
105 // How to load a template, use of mustache
109 // How to make sure the plugin is not desynchronized
110 // He should manifest its interest in filters, fields or records
111 // functions triggered only if the proper listen is done
115 on_filter_added: function(filter)
120 on_field_state_changed: function(result)
122 console.log("triggered state_changed: "+result);
123 // this.set_state(result, this.options.username);
126 // ... be sure to list all events here
128 /* RECORD HANDLERS */
129 on_all_new_record: function(record)
134 on_new_record: function(record)
139 /* INTERNAL FUNCTIONS */
141 // only convention, not strictly enforced at the moment
146 /* Plugin registration */
147 $.plugin('SlaDialog', SlaDialog);
149 // TODO Here use cases for instanciating plugins in different ways like in the pastie.