kdf
Version:
63 lines (49 loc) • 1.94 kB
text/coffeescript
KDInputView = require './inputview.coffee'
module.exports = class KDHitEnterInputView extends KDInputView
constructor:(options = {}, data)->
options.type or= 'textarea'
options.cssClass = KD.utils.curry 'hitenterview', options.cssClass
options.button or= null
options.showButton ?= no
options.label or= null
options.placeholder or= ""
options.callback or= null
options.togglerPartials or= ['quick update disabled', 'quick update enabled']
super options,data
= .button ? null
if options.label?
if .showButton
'ValidationPassed', =>
{callback} =
callback?.call this,
enableEnterKey:->
"active"
if
.$().html( .togglerPartials[1]) if ?
= yes
disableEnterKey:->
"active"
if
.$().html( .togglerPartials[0]) if ?
= no
setToggler:->
o =
= new KDCustomHTMLView
tagName : "a"
cssClass : "hitenterview-toggle"
partial : if o.showButton then o.togglerPartials[0] else o.togglerPartials[1]
click : "toggleEnterKey"
.addSubView
hideButton:-> .hide()
showButton:-> .show()
toggleEnterKey:->
if then else
keyDown: (event) ->
if event.which is 13 and (event.altKey or event.shiftKey) isnt true and
event.preventDefault()
"EnterPerformed"
no
else if event.which is 27 # escape
"EscapePerformed"