src/Behavior.js
/**
 * With no argument, toggle the text edit on mousedown on/off. Pass in a boolean
 * argument to set the on/off state. The backup state is equal to
 * selectable_mousedown.
 */
With no argument, toggle the text edit on mousedown on/off. Pass in a boolean
argument to set the on/off state. The backup state is equal to
selectable_mousedown.
With no argument toggle the text edit on mousedown on / off . Pass in a boolean argument to set the on / off state . The backup state is equal to selectable_mousedown .
function toggle_text_label_edit (on_off) {
  if (on_off === undefined) {
    on_off = this.text_edit_mousedown == null
  }
  if (on_off) {
    var map = this.map
    var selection = this.selection
    this.text_label_mousedown = function () {
      if (d3_selection.event.defaultPrevented) {
        return 
      }
      var coords_a = utils.d3_transform_catch(d3_select(this).attr('transform'))
          .translate
      var coords = { x: coords_a[0], y: coords_a[1] }
      map.callback_manager.run('edit_text_label', null, d3_select(this), coords)
      d3_selection.event.stopPropagation()
    }
    this.text_label_click = null
    this.map.sel.select('#text-labels')
      .selectAll('.label')
      .classed('edit-text-cursor', true)
    this.map.sel.on('mousedown.new_text_label', function (node) {
      d3_selection.event.preventDefault()
      var coords = {
        x: d3_mouse(node)[0],
        y: d3_mouse(node)[1],
      }
      this.map.callback_manager.run('new_text_label', null, coords)
    }.bind(this, this.map.sel.node()))
  } else {
    this.text_label_mousedown = this.selectable_mousedown
    this.text_label_click = this.selectable_click
    this.map.sel.select('#text-labels')
      .selectAll('.label')
      .classed('edit-text-cursor', false)
    this.map.sel.on('mousedown.new_text_label', null)
    this.map.callback_manager.run('hide_text_label_editor')
  }
}
function toggle_text_label_edit ( on_off ) { if ( on_off === undefined ) { on_off = this . text_edit_mousedown == null } if ( on_off ) { var map = this . map var selection = this . selection this . text_label_mousedown = function ( ) { if ( d3_selection . event . defaultPrevented ) { return } var coords_a = utils . d3_transform_catch ( d3_select ( this ) . attr ( 'transform' ) ) . translate var coords = { x : coords_a [ 0 ] , y : coords_a [ 1 ] } map . callback_manager . run ( 'edit_text_label' , null , d3_select ( this ) , coords ) d3_selection . event . stopPropagation ( ) } this . text_label_click = null this . map . sel . select ( '#text-labels' ) . selectAll ( '.label' ) . classed ( 'edit-text-cursor' , true ) this . map . sel . on ( 'mousedown.new_text_label' , function ( node ) { d3_selection . event . preventDefault ( ) var coords = { x : d3_mouse ( node ) [ 0 ] , y : d3_mouse ( node ) [ 1 ] , } this . map . callback_manager . run ( 'new_text_label' , null , coords ) } . bind ( this , this . map . sel . node ( ) ) ) } else { this . text_label_mousedown = this . selectable_mousedown this . text_label_click = this . selectable_click this . map . sel . select ( '#text-labels' ) . selectAll ( '.label' ) . classed ( 'edit-text-cursor' , false ) this . map . sel . on ( 'mousedown.new_text_label' , null ) this . map . callback_manager . run ( 'hide_text_label_editor' ) } }
With no argument, toggle the text edit on mousedown on/off.
With no argument toggle the text edit on mousedown on / off .
// mousedown suppressed // run the callback // add the new-label listener // silence other listeners // remove the new-label listener