Ejemplo n.º 1
0
    def service(self):
        """
    Description:
    ------------
    Create and store a function to do simple services calls and return a temporary message.

    TODO: To be improved and extended.
    """
        self._js_src.setdefault('functions', {})["serviceCall"] = {
            'content':
            self.page.js.post(JsUtils.jsWrap("url"), {
                "data": JsUtils.jsWrap("data")
            }).onSuccess([self.page.js.msg.status()]).toStr(),
            'pmt': ["url", "data"]
        }
        return "serviceCall"
Ejemplo n.º 2
0
 def reset(self):
     """
 Description:
 -----------
 Reset TUIEditor.
 """
     return JsUtils.jsWrap("%s.reset()" % self.component.var)
Ejemplo n.º 3
0
 def reset(js_code: str):
     """
 Attributes:
 ----------
 :param str js_code: The variable reference.
 """
     return JsUtils.jsWrap("%s.reset()" % js_code)
Ejemplo n.º 4
0
  def remove(self):
    """
    Destroys the map and clears all related event listeners.

    https://leafletjs.com/reference-1.7.1.html#map-remove
    """
    return JsUtils.jsWrap("%s; %s.remove()" % (self.toStr(), self.varName))
Ejemplo n.º 5
0
    def set(js_funcs, delay, js_code: str, profile=None):
        """
    Description:
    ------------
    Creates a throttled function that only invokes fn at most once per every interval milliseconds.
    You can use this throttle short time repeatedly invoking functions. (e.g MouseMove, Resize ...)
    if you need reuse throttled method. you must remove slugs (e.g. flag variable) related with throttling.

    Related Pages:

      https://nhn.github.io/tui.code-snippet/latest/tricks#debounce

    Attributes:
    ----------
    :param js_funcs: List | String. Javascript functions.
    :param delay: Integer. The delay to run the function.
    :param str js_code: the variable reference.
    :param profile: Boolean | Dictionary. Optional. A flag to set the component performance storage.
    """
        delay = JsUtils.jsConvertData(delay, None)
        return JsUtils.jsWrap(
            "window['%s'] = tui.util.debounce(function(){%s}, %s)" %
            (js_code,
             JsUtils.jsConvertFncs(js_funcs, toStr=True,
                                   profile=profile), delay))
Ejemplo n.º 6
0
 def get_width(self):
   """
   Description:
   -----------
   Get the container available with in pixel (including the padding).
   """
   return self._config_get(JsUtils.jsWrap(
     "function(component){return component.clientWidth - (parseFloat(component.style.paddingLeft) + parseFloat(component.style.paddingRight)) }"))
Ejemplo n.º 7
0
 def get_height(self):
   """
   Description:
   -----------
   Get the container available height in pixel (including the padding).
   """
   return self._config_get(JsUtils.jsWrap(
     "function(component){return component.clientHeight - (parseFloat(component.style.paddingTop) + parseFloat(component.style.paddingBottom))}"))
Ejemplo n.º 8
0
 def current_cell_id(self):
     """
 Description:
 ------------
 Get the id of the current cell.
 """
     return JsUtils.jsWrap(
         "window.Jupyter.notebook.get_cell_elements().index($(event.target).parents('.cell'))"
     )
Ejemplo n.º 9
0
  def on(self, typeEvent, js_funcs: Union[list, str], profile: Optional[Union[dict, bool]] = None):
    """

    :param typeEvent:
    :param js_funcs:
    :param profile:
    """
    return JsUtils.jsWrap("%s; %s.on('%s', function(event){%s})" % (
      self.toStr(), self.varName, typeEvent, JsUtils.jsConvertFncs(js_funcs, toStr=True, profile=profile)))
Ejemplo n.º 10
0
    def index(self):
        """
    Description:
    -----------
    Get the active series index.

    :return: A javaScript number.
    """
        return JsUtils.jsWrap("config.seriesIndex")
Ejemplo n.º 11
0
  def enable(self, i=None):
    """
    Description:
    -----------
    Enables a tab.

    Related Pages:

      https://api.jqueryui.com/tabs/

    Attributes:
    ----------
    :param i: Array<Integer>. Optional. The zero-based index of the tab to disable.
    """
    if i is None:
      return JsUtils.jsWrap("%s.tabs('enable')" % self.component.var)

    return JsUtils.jsWrap("%s.tabs('enable', %s)" % (self.component.var, i))
Ejemplo n.º 12
0
  def disable(self, i=None):
    """
    Description:
    -----------
    Disables all tabs. This signature does not accept any arguments.

    Related Pages:

      https://api.jqueryui.com/tabs/

    Attributes:
    ----------
    :param i: Array<Integer>. Optional. The zero-based index of the tab to disable.
    """
    if i is None:
      return JsUtils.jsWrap("%s.tabs('disable')" % self.component.var)

    return JsUtils.jsWrap("%s.tabs('disable', %s)" % (self.component.var, i))
Ejemplo n.º 13
0
    def show(self):
        """
    Description:
    ------------

    :return:
    """
        return JsUtils.jsWrap(
            "$(Jupyter.notebook.get_cell(%s).element).show()" % self._cell_ref)
Ejemplo n.º 14
0
    def run(self):
        """
    Description:
    ------------

    :return:
    """
        return JsUtils.jsWrap("window.Jupyter.notebook.execute_cells([%s])" %
                              self._cell_ref)
Ejemplo n.º 15
0
  def createPane(self, text):
    """
    Stops watching location previously initiated by map.locate({watch: true}) and aborts resetting the map view
    if map.locate was called with {setView: true}.

    https://leafletjs.com/reference-1.7.1.html#map-createpane

    :param text:
    """
    return JsUtils.jsWrap("%s; %s.createPane(%s)" % (self.toStr(), self.varName, JsUtils.jsConvertData(text, None)))
Ejemplo n.º 16
0
  def refresh(self):
    """
    Description:
    -----------
    Process any tabs that were added or removed directly in the DOM and recompute the height of the tab panels.
    Related Pages:

      https://api.jqueryui.com/accordion/
    """
    return JsUtils.jsWrap("%s.accordion('refresh')" % self.component.var)
Ejemplo n.º 17
0
  def setView(self, LatLng, zoom=None):
    """
    Description:
    -----------
    Sets the view of the map (geographical center and zoom) with the given animation options.

    Related Pages:

      https://leafletjs.com/reference-1.7.1.html#map-example

    Attributes:
    ----------
    :param LatLng:
    :param zoom:
    """
    if zoom is not None:
      return JsUtils.jsWrap("%s.setView(%s, %s)" % (self._selector, LatLng, zoom))

    return JsUtils.jsWrap("%s.setView(%s)" % (self._selector, LatLng))
Ejemplo n.º 18
0
  def show(self):
    """
    Description:
    -----------

    Related Pages:

      https://getbootstrap.com/docs/5.0/components/offcanvas/#methods
    """
    return JsUtils.jsWrap("%s.show()" % self.varName)
Ejemplo n.º 19
0
  def zoomIn(self, delta):
    """
    Description:
    -----------
    Increases the zoom of the map by delta (zoomDelta by default).

    Attributes:
    ----------
    :param delta:
    """
    return JsUtils.jsWrap("%s.zoomIn(%s)" % (self._selector, delta))
Ejemplo n.º 20
0
    def locales(self):
        """
    Description:
    ------------
    As of version 2.12.0 it is possible to list all locales that have been loaded and are available to use:

    Related Pages:

      https://momentjs.com/docs/#/i18n/getting-locale/
    """
        return JsUtils.jsWrap("%s.locales()" % self.varId)
Ejemplo n.º 21
0
    def run(js_code: str):
        """
    Description:
    ------------
    Run the function.

    Attributes:
    ----------
    :param str js_code: The variable reference.
    """
        return JsUtils.jsWrap("%s()" % js_code)
Ejemplo n.º 22
0
    def disable(self):
        """
    Description:
    -----------
    Disable all rows.

    Related Pages:

      https://nhn.github.io/tui.grid/latest/Grid#copyToClipboard
    """
        return JsUtils.jsWrap("%s.disable()" % self.component.var)
Ejemplo n.º 23
0
    def enable(self):
        """
    Description:
    -----------
    Enable all rows.

    Related Pages:

      https://nhn.github.io/tui.grid/latest/Grid#disableRowCheck
    """
        return JsUtils.jsWrap("%s.enable()" % self.component.var)
Ejemplo n.º 24
0
    def copyToClipboard(self):
        """
    Description:
    -----------
    Copy to clipboard.

    Related Pages:

      https://nhn.github.io/tui.grid/latest/Grid#copyToClipboard
    """
        return JsUtils.jsWrap("%s.copyToClipboard()" % self.component.var)
Ejemplo n.º 25
0
    def destroy(self):
        """
    Description:
    -----------
    Destroy the instance.

    Related Pages:

      https://nhn.github.io/tui.grid/latest/Grid#copyToClipboard
    """
        return JsUtils.jsWrap("%s.destroy()" % self.component.var)
Ejemplo n.º 26
0
    def collapseAll(self):
        """
    Description:
    -----------
    Collapse all tree row.

    Related Pages:

      https://nhn.github.io/tui.grid/latest/Grid#collapseAll
    """
        return JsUtils.jsWrap("%s.collapseAll()" % self.component.var)
Ejemplo n.º 27
0
    def clear(self):
        """
    Description:
    -----------
    Remove all rows..

    Related Pages:

      https://nhn.github.io/tui.grid/latest/Grid#clear
    """
        return JsUtils.jsWrap("%s.clear()" % self.component.var)
Ejemplo n.º 28
0
    def activateFocus(self):
        """
    Description:
    -----------
    Make view ready to get keyboard input.

    Related Pages:

      https://nhn.github.io/tui.grid/latest/Grid#activateFocus
    """
        return JsUtils.jsWrap("%s.activateFocus()" % self.component.var)
Ejemplo n.º 29
0
    def cancelEditing(self):
        """
    Description:
    -----------
    Cancel the editing.

    Related Pages:

      https://nhn.github.io/tui.grid/latest/Grid#blur
    """
        return JsUtils.jsWrap("%s.cancelEditing()" % self.component.var)
Ejemplo n.º 30
0
    def blur(self):
        """
    Description:
    -----------
    Remove focus from the focused cell.

    Related Pages:

      https://nhn.github.io/tui.grid/latest/Grid#blur
    """
        return JsUtils.jsWrap("%s.blur()" % self.component.var)