kdf
Version:
55 lines (39 loc) • 1.21 kB
text/coffeescript
KDView = require './../../core/view.coffee'
module.exports = class KDDiaJoint extends KDView
types = ['left', 'right', 'top', 'bottom']
constructor:(options={}, data)->
options.type or= 'left'
unless options.type in types
warn "Unknown joint type '#{options.type}', falling back to 'left'"
options.type = 'left'
options.static ?= no
options.size ?= 10
options.cssClass = \
KD.utils.curry "kddia-joint #{options.type}", options.cssClass
super options, data
= {}
= 'type'
= 'size'
viewAppended:->
super
.attr "dia-id",
getDiaId:->
"dia-#{@parent.getId()}-joint-#{@type}"
getPos:->
.getJointPos this
click:(e)->
'DeleteRequested', , if
.stopDOMEvent e
mouseDown:(e)->
return if
.stopDOMEvent e
.emit "JointRequestsLine", this
return no
inDeleteMode:->
'deleteMode'
showDeleteButton:->
'deleteMode' unless
hideDeleteButton:->
'deleteMode'
isStatic:->
'static'