B
    @\                 @   s   d Z ddlmZmZmZmZ ddlZeeZ	ddl
mZ ddlmZ ddlmZmZmZmZ ddlmZ dd	lmZ dd
lmZmZ dZeG dd deZG dd deZG dd deZdS )z Client-side interactivity.

    )absolute_importdivisionprint_functionunicode_literalsN)FunctionType   )abstract)DictStringBoolAnyRef)Model)import_required)nodejs_compileCompilationError)CallbackOpenURLCustomJSc               @   s   e Zd ZdZdS )r   z+ Base class for interactive callback.

    N)__name__
__module____qualname____doc__ r   r   5lib/python3.7/site-packages/bokeh/models/callbacks.pyr   2   s   r   c               @   s   e Zd ZdZedddZdS )r   z= Open a URL in a new tab or window (browser dependent).

    zhttp://z
    The URL to direct the web browser to. This can be a template string,
    which will be formatted with data from the data source.
    )helpN)r   r   r   r   r
   Zurlr   r   r   r   r   9   s   r   c               @   sR   e Zd ZdZedd Zei fddZeee	ddZ
edd	d
Zeddd
ZdS )r   aU   Execute a JavaScript function.

    .. warning::
        The explicit purpose of this Bokeh Model is to embed *raw JavaScript
        code* for a browser to execute. If any part of the code is derived
        from untrusted user inputs, then you must take appropriate care to
        sanitize the user input prior to passing to Bokeh.

    c             C   sv   t |tstdtdd}|j}|jjdt| }tt	||}|
dd ||ddd|  }| ||d	S )
z Create a ``CustomJS`` instance from a Python function. The
        function is translated to JavaScript using PScript.
        z,CustomJS.from_py_func needs function object.pscriptzxTo use Python functions for CustomJS, you need PScript ("conda install -c conda-forge pscript" or "pip install pscript")NZwindowcbzcb(%s);
z, )codeargs)
isinstancer   
ValueErrorr   __defaults____code__co_varnameslendictzippopZpy2jsjoin)clsfuncr   Zdefault_valuesZdefault_namesr   r   r   r   r   from_py_funcO   s    
zCustomJS.from_py_funcc             C   s4   t |ddd}d|kr"t|jn| |j|dS dS )zA Create a ``CustomJS`` instance from CoffeeScript code.

        Zcoffeescriptz???)Zlangfileerror)r   r   N)r   r   r-   r   )r)   r   r   Zcompiledr   r   r   from_coffeescriptc   s    zCustomJS.from_coffeescriptz
    A mapping of names to Python objects. In particular those can be bokeh's models.
    These objects are made available to the callback's code snippet as the values of
    named parameters to the callback.
    )r    a  
    A snippet of JavaScript code to execute in the browser. The
    code is made into the body of a function, and all of of the named objects in
    ``args`` are available as parameters that the code can use. Additionally,
    a ``cb_obj`` parameter contains the object that triggered the callback
    and an optional ``cb_data`` parameter that contains any tool-specific data
    (i.e. mouse coordinates and hovered glyph indices for the ``HoverTool``).

    .. note:: Use ``CustomJS.from_coffeescript()`` for CoffeeScript source code.

    )defaultr   FzU
    Enables or disables automatic insertion of ``"use strict";`` into ``code``.
    N)r   r   r   r   classmethodr+   r.   r	   r
   r   r   r   r   Z
use_strictr   r   r   r   r   D   s   	

r   )r   Z
__future__r   r   r   r   ZloggingZ	getLoggerr   logtypesr   Zcore.has_propsr   Zcore.propertiesr	   r
   r   r   Zmodelr   Zutil.dependenciesr   Zutil.compilerr   r   __all__r   r   r   r   r   r   r   <module>
   s   
	