2 * MySlice MyPlugin demonstration plugin
4 * URL: http://www.myslice.info
5 * Description: Template for writing new plugins and illustrating the different possibilities of the plugin API
7 * Author: The MySlice Team
8 * Copyright: Copyright 2012-2013 UPMC Sorbonne Universités
13 * It's a best practice to pass jQuery to an IIFE (Immediately Invoked Function
14 * Expression) that maps it to the dollar sign so it can't be overwritten by
15 * another library in the scope of its execution.
19 var PLUGIN_NAME = 'MyPlugin';
22 jQuery.fn.ResourcesSelected = function( method ) {
23 if ( methods[method] ) {
24 return methods[ method ].apply( this, Array.prototype.slice.call( arguments, 1 ));
25 } else if ( typeof method === 'object' || ! method ) {
26 return methods.init.apply( this, arguments );
28 jQuery.error( 'Method ' + method + ' does not exist on jQuery' + PLUGIN_NAME );
33 /***************************************************************************
35 ***************************************************************************/
40 * @brief Plugin initialization
41 * @param options : an associative array of setting values
42 * @return : a jQuery collection of objects on which the plugin is
43 * applied, which allows to maintain chainability of calls
45 init : function( options ) {
47 return this.each(function(){
51 /* An object that will hold private variables and methods */
52 var s = new ResourcesSelected(options);
53 $(this).data('Manifold', s);
59 * @brief Plugin destruction
60 * @return : a jQuery collection of objects on which the plugin is
61 * applied, which allows to maintain chainability of calls
63 destroy : function( ) {
65 return this.each(function(){
66 var $this = jQuery(this), data = $this.data('Manifold');
67 jQuery(window).unbind('Manifold');
68 data.Manifold.remove();
69 $this.removeData('Manifold');
76 /***************************************************************************
77 * ResourcesSelected object
78 ***************************************************************************/
80 function MyPlugin(options)
82 /* member variables */
84 this.options = options;
90 } // function MyPlugin