How to use the base/js/events.on function in base

To help you get started, we’ve selected a few base examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github minrk / ipython_extensions / nbextensions / inorder.js View on Github external
function load_extension() {
    console.log("Loading inorder extension");

    // when a cell is created we check
    events.on("create.Cell", handle_cell_creation);

    // when there's an error, mark it and invalidate below
    events.on("output_error.InOrderExtension", handle_error);

    // when the kernel restarts, reset all state
    events.on("kernel_restarting.Kernel", function() {
      var cells = Jupyter.notebook.get_cells();
      cells.map(function(cell) {
        unlock_cell(cell);
        cell.element.removeClass("inorder-executed");
      });
    });

    // add our css (!important due to race with cell.selected)
    var style = document.createElement("style");
    style.type = "text/css";
github minrk / ipython_extensions / nbextensions / inorder.js View on Github external
function load_extension() {
    console.log("Loading inorder extension");

    // when a cell is created we check
    events.on("create.Cell", handle_cell_creation);

    // when there's an error, mark it and invalidate below
    events.on("output_error.InOrderExtension", handle_error);

    // when the kernel restarts, reset all state
    events.on("kernel_restarting.Kernel", function() {
      var cells = Jupyter.notebook.get_cells();
      cells.map(function(cell) {
        unlock_cell(cell);
        cell.element.removeClass("inorder-executed");
      });
    });

    // add our css (!important due to race with cell.selected)
    var style = document.createElement("style");
    style.type = "text/css";
    style.innerHTML = "div.cell.code_cell.inorder-locked { background-color: #afa}\n" +
      "div.cell.code_cell.inorder-locked.inorder-error { background-color: #faa}\n";
    document.getElementsByTagName("head")[0].appendChild(style);

    // apply patches when the notebook has been loaded
    if (!Jupyter.notebook) {
github krishnan-r / sparkmonitor / extension / js / SparkMonitor.js View on Github external
//Fixes Reloading the browser
	this.startComm();
	//Fixes Restarting the Kernel
	events.on('kernel_connected.Kernel', $.proxy(this.startComm, this));//Make sure there is a comm always.

	/** Data mapping jobs to cells for delegating further lifecycle events of a job. */
	this.data = {};
	this.appName = "NULL";
	this.appId = "NULL";
	this.app = "NULL";
	this.totalCores = 0;
	this.numExecutors = 0;

	this.display_mode = "shown"; // "shown" || "hidden"

	events.on('clear_output.CodeCell', function (event, data) { //Removing display when output area is cleared
		var cellmonitor = that.getCellMonitor(data.cell.cell_id)
		if (cellmonitor) {
			cellmonitor.removeDisplay();
			that.stopCellMonitor(data.cell.cell_id);
		}
	});

	this.createButtons();
}
github jupyter / notebook / notebook / static-src / base / js / page.js View on Github external
Page.prototype.bind_events = function () {
        // resize site on:
        // - window resize
        // - header change
        // - page load
        var _handle_resize = $.proxy(this._resize_site, this);
        
        $(window).resize(_handle_resize);

        // On document ready, resize codemirror.
        $(document).ready(_handle_resize);
        events.on('resize-header.Page', _handle_resize);
    };
github CermakM / jupyter-require / js / src / extension.js View on Github external
function register_events() {
        events.on('config.JupyterRequire', (e, d) => set_notebook_metadata(d.config));
        events.on('require.JupyterRequire', (e, d) => set_cell_requirements(d.cell, d.require));
    }
github CermakM / jupyter-require / jupyter_require / static / loader.js View on Github external
events.on( 'require.JupyterRequire', ( e, d ) => core.set_cell_requirements( d.cell, d.require ) );

        events.on( {
            'comms_registered.JupyterRequire': ( e, d ) => {
                log.debug( "Comm targets registered." );
            },

            'extension_loaded.JupyterRequire': ( e, d ) => {
                log.debug( "Extension loaded." );
            },
        } );

        events.on( 'execute.CodeCell', ( e, d ) => d.cell.running = true );
        events.on( 'finished_execute.CodeCell', ( e, d ) => d.cell.running = false );

        events.on( 'output_added.OutputArea', ( e, d ) => {
            let display_data = d.output;
            if ( display_data.output_type !== 'display_data' ) return;

            if ( display_data instanceof display.DisplayData || display_data.metadata.frozen === false ) {
                display_data.freeze_output();
            } else {
                if ( _.isFunction( display_data.metadata.execute ) )
                    display.append_javascript( display_data.metadata.execute, d.output_area ).then(
                        ( r ) => log.debug( 'Output appended: ', r )
                    );
            }


        } );

        events.on( 'before_save.Notebook', freeze_cells );
github lgpage / nbtutor / src / es6 / notebook / notebook.es6 View on Github external
_build(){
        this._bindButtons();
        this.$input_area.append(this.$nbtutor_canvas);

        let that = this;
        events.on("global_hide.CellToolBar", () => {
            that.destroy();
        });

        this.toolbar.$select_view.on("change", function(){
            that.memoryUI.destroy();
            let render_view = $(this).val();
            if (render_view == "none"){
                that.markers.clearMarkers();
                that.markers.hideLegend();
                that.$nbtutor_canvas.addClass("nbtutor-hidden");
            } else {
                that.markers.showLegend();
                that.$nbtutor_canvas.removeClass("nbtutor-hidden");
                that.toolbar.$btn_first.trigger("click");
            }
        });
github CermakM / jupyter-require / jupyter_require / static / loader.js View on Github external
function register_events() {
        events.on( 'config.JupyterRequire', ( e, d ) => core.set_notebook_config( d.config ) );
        events.on( 'require.JupyterRequire', ( e, d ) => core.set_cell_requirements( d.cell, d.require ) );

        events.on( {
            'comms_registered.JupyterRequire': ( e, d ) => {
                log.debug( "Comm targets registered." );
            },

            'extension_loaded.JupyterRequire': ( e, d ) => {
                log.debug( "Extension loaded." );
            },
        } );

        events.on( 'execute.CodeCell', ( e, d ) => d.cell.running = true );
        events.on( 'finished_execute.CodeCell', ( e, d ) => d.cell.running = false );

        events.on( 'output_added.OutputArea', ( e, d ) => {
            let display_data = d.output;
            if ( display_data.output_type !== 'display_data' ) return;

            if ( display_data instanceof display.DisplayData || display_data.metadata.frozen === false ) {
                display_data.freeze_output();
            } else {
                if ( _.isFunction( display_data.metadata.execute ) )
                    display.append_javascript( display_data.metadata.execute, d.output_area ).then(
                        ( r ) => log.debug( 'Output appended: ', r )
                    );
            }


        } );
github CermakM / jupyter-require / js / src / extension.js View on Github external
function register_events() {
        events.on('config.JupyterRequire', (e, d) => set_notebook_metadata(d.config));
        events.on('require.JupyterRequire', (e, d) => set_cell_requirements(d.cell, d.require));
    }
github CermakM / jupyter-require / jupyter_require / static / loader.js View on Github external
function register_events() {
        events.on( 'config.JupyterRequire', ( e, d ) => core.set_notebook_config( d.config ) );
        events.on( 'require.JupyterRequire', ( e, d ) => core.set_cell_requirements( d.cell, d.require ) );

        events.on( {
            'comms_registered.JupyterRequire': ( e, d ) => {
                log.debug( "Comm targets registered." );
            },

            'extension_loaded.JupyterRequire': ( e, d ) => {
                log.debug( "Extension loaded." );
            },
        } );

        events.on( 'execute.CodeCell', ( e, d ) => d.cell.running = true );
        events.on( 'finished_execute.CodeCell', ( e, d ) => d.cell.running = false );

        events.on( 'output_added.OutputArea', ( e, d ) => {
            let display_data = d.output;