- var PLUGIN_NAME = 'QueryEditor';
-
- // routing calls
- jQuery.fn.QueryEditor = function( method ) {
- if ( methods[method] ) {
- return methods[ method ].apply( this, Array.prototype.slice.call( arguments, 1 ));
- } else if ( typeof method === 'object' || ! method ) {
- return methods.init.apply( this, arguments );
- } else {
- jQuery.error( 'Method ' + method + ' does not exist on jQuery.' + PLUGIN_NAME );
- }
- };
-
- /***************************************************************************
- * Public methods
- ***************************************************************************/
-
- var methods = {
-
- /**
- * @brief Plugin initialization
- * @param options : an associative array of setting values
- * @return : a jQuery collection of objects on which the plugin is
- * applied, which allows to maintain chainability of calls
- */
- init : function ( options ) {
-
- return this.each(function() {
-
- var $this = $(this);
-
- /* An object that will hold private variables and methods */
- var plugin = new QueryEditor(options);
- $this.data('Manifold', plugin);
-
- }); // this.each
- }, // init
-
- /**
- * @brief Plugin destruction
- * @return : a jQuery collection of objects on which the plugin is
- * applied, which allows to maintain chainability of calls
- */
- destroy : function( ) {
-
- return this.each(function() {
- var $this = $(this);
- var hazelnut = $this.data('Manifold');
-
- // Unbind all events using namespacing
- $(window).unbind(PLUGIN_NAME);
-
- // Remove associated data
- hazelnut.remove();
- $this.removeData('Manifold');
-
- $this.set_query_handler(options.query_uuid, hazelnut.query_handler);
- $this.set_record_handler(options.query_uuid, hazelnut.record_handler);