2 * Description: DebugPlatform plugin
3 * Copyright (c) 2012 UPMC Sorbonne Universite - INRIA
8 * It's a best practice to pass jQuery to an IIFE (Immediately Invoked Function
9 * Expression) that maps it to the dollar sign so it can't be overwritten by
10 * another library in the scope of its execution.
17 jQuery.fn.DebugPlatform = function( method ) {
18 if ( methods[method] ) {
19 return methods[ method ].apply( this, Array.prototype.slice.call( arguments, 1 ));
20 } else if ( typeof method === 'object' || ! method ) {
21 return methods.init.apply( this, arguments );
23 jQuery.error( 'Method ' + method + ' does not exist on jQuery.DebugPlatform' );
27 /***************************************************************************
29 ***************************************************************************/
34 * @brief Plugin initialization
35 * @param options : an associative array of setting values
36 * @return : a jQuery collection of objects on which the plugin is
37 * applied, which allows to maintain chainability of calls
39 init : function ( options ) {
41 var default_code_mirror_options = {
42 gutters: ["note-gutter", "CodeMirror-linenumbers"],
48 tabMode: 'spaces' // or 'shift'
51 /* Default settings */
52 var options = $.extend( {
54 codeMirrorOptions: default_code_mirror_options,
55 syntaxHighlighting: []
58 return this.each(function() {
62 /* An object that will hold private variables and methods */
63 var plugin = new DebugPlatform(options);
64 $this.data('Manifold', plugin);
67 $this.on('show.DebugPlatform', methods.show);
69 // This is the new plugin API meant to replace the weird publish_subscribe mechanism
74 * @brief Plugin destruction
75 * @return : a jQuery collection of objects on which the plugin is
76 * applied, which allows to maintain chainability of calls
78 destroy : function( ) {
80 return this.each(function() {
82 var hazelnut = $this.data('Manifold');
84 // Unbind all events using namespacing
85 $(window).unbind('Manifold');
87 // Remove associated data
89 $this.removeData('Manifold');
95 /***************************************************************************
97 ***************************************************************************/
99 function DebugPlatform(options)
101 /* member variables */
102 this.options = options;
106 } // function DebugPlatform