undefined

API Docs for: 5.4.1
Show:

BaseTool Class

BaseTool provides essential functionality for Tools including handling of the activate toggle, setting busy state, injecting output float into the page, and templating the output. It's not required to mixin BaseTool, but it's really helpful; and of course any of the BaseTool methods/properties can be overwritten after mixining it in.

Call initToggle to initialize the tool.

Imports RAMP Modules:

GlobalStorage
TmplHelper
PopupManager
Util

Uses RAMP Templates:

templates/tools_template.json

Constructor

BaseTool

()

Methods

activate

() chainable

Activate the tool by triggering open method on the tool's popup handle.

Returns:

This tool

deactivate

() chainable

Deactivate the tool by triggering close method on the tool's popup handle.

Returns:

This tool

displayOutput

(
  • output
)
chainable

Injects given tool output into the tool's float.

Parameters:

  • output String | JObject

    String or node collection to be injected into the tool output float.

Returns:

this tool

displayTemplateOutput

(
  • templateData
  • [templateName]
)
chainable

Generates output to be injected into the tool's float given a template's name and data object.

Parameters:

  • templateData Object

    data to be put inside the specified template

  • [templateName] String optional

    template name to be completed with provided data; if not supplied, "toolOutputTemplate" property of the options object will be used

Returns:

this tool

initToggle

(
  • selector
  • d
  • [options]
)
chainable

Initializes the tool and sets up popup to handle activating/deactivating of the tool. Tools should call this function on init, unless they employ a different workflow and then need to handle all function activation/deactivation/working themselves.

Parameters:

  • selector JObject

    a target selector that serves as a toggle for the tool

  • d JObject

    a Deferred object to be resolved after tool initiates

  • [options] Object optional

    Additional options

    • [target] JObject optional

      Target where the tool's float should be appended to

    • [outputFloatTemplate] String optional

      Template name to generate the float container with

    • [outputFloatData] Object optional

      Data payload to be passed to the template engine when generate the float container

    • [workingLabelTemplate] String optional

      Template name to generate the busy label

    • [workingLabelData] Object optional

      Data payload to be passed to the template engine when generate the busy label

    • [activate] Function optional

      an activate function to be called when the toggle is clicked

    • [deactivate] Function optional

      a deactivate function to be called when the toggle is clicked

    • [defaultAction] Function optional

      Function to be executed when the float-default-button is clicked

Returns:

this tool

working

(
  • state
)
chainable

Sets the tool into a specified state; if the tool is working, a working label is placed beside the cursor and injected into the tool output float.

Parameters:

  • state Boolean

    indicates the state of the tool: working, idle

Returns:

This tool

Properties

event

Object

Event names published by the BaseTool

Default: null

Example:

 {
     ACTIVATE: "basetool-activate",
     DEACTIVATE: "basetool-deactivate"
 }

handle

JObject

Handle (popup handle) that triggers opening/closing of the tool.

Default: null

name

String

Name of the tool so AdvancedToolbar can distinguish between them.

Default: BaseTool

node

JObject

Node (button) the handle is attached too.

Default: null

options

Object private

Stored options passed to the BaseTool.

Default: null

outputFloat

JObject

Node representing the tool output float container.

Default: templates/tools_template.json:base_tool_float

Example:

 <div class='advanced-output-section-container'>
     <div class='advanced-output-section'>
         <section class='float-content'></section>
         <button class='button button-none float-default-button' >
             <i class='fa fa-trash-o'></i><span class='on-right'>{%= o.clearMapButton %}</span>
         </button>
         <div class='clear'></div>
     </div>
 </div>

template

Object

Stringified and parsed templates

Default: templates/tools_template.json

tooltip

JObject

Tooltip node that appears by the mouse cursor when tools is activated.

Default: $("#mainMap.map > .tooltip")

workingLabel

String

Template string representing working label shown when the tool is in busy state.

Default: templates/tools_template.json:working_label

Example:

 <span class='tool-tooltip'><i class='fa fa-cog fa-spin'></i>{%= o.workingLabel %}</span>

Events

ACTIVATE

Published whenever a Tool is activated.

Event Payload:

DEACTIVATE

Published whenever a Tool is deactivated.

Event Payload: