     b = parseInt(result[3], 16)
     return (0.2126*r + 0.7152*g + 0.0722*b)/255
 
-  useSwatchColor: (event) ->
-    @colorField.val $(event.currentTarget).attr('data-color')
+  useSwatchColor: (event, code) ->
+    if event
+      code = $(event.currentTarget).attr('data-color')
+    @colorField.val code
     @updateParams()
 
   new: (e) =>

    for key, value of params
      if value != ''
        if paramString != ''
          paramString += ",\n"
        if value == 'true' || value == 'false' || _.isNumber(value)
          paramString += "    #{key}: #{value}"
        else

      url: 'https://images.zammad.com/api/v1/webpage/colors'
      data:
        url: src
        count: 20
      success: @renderSwatches
      dataType: 'json'

