'use strict';

var domQuery = require('min-dom/lib/query');

var textField = function(options, defaultParameters) {

  // Default action for the button next to the input-field
  var defaultButtonAction = function (element, inputNode) {
    var input = domQuery('input[name="' + options.modelProperty + '"]', inputNode);
    input.value = '';

    return true;
  };

  // default method to determine if the button should be visible
  var defaultButtonShow = function (element, inputNode) {
    var input = domQuery('input[name="' + options.modelProperty + '"]', inputNode);

    return input.value !== '';
  };

  var resource = defaultParameters,
    label = options.label || resource.id,
    dataValueLabel = options.dataValueLabel,
    buttonLabel = ( options.buttonLabel || 'X' ),
    actionName = ( typeof options.buttonAction != 'undefined' ) ? options.buttonAction.name : 'clear',
    actionMethod = ( typeof options.buttonAction != 'undefined' ) ? options.buttonAction.method : defaultButtonAction,
    showName = ( typeof options.buttonShow != 'undefined' ) ? options.buttonShow.name : 'canClear',
    showMethod = ( typeof options.buttonShow != 'undefined' ) ? options.buttonShow.method : defaultButtonShow,
    canBeDisabled = !!options.disabled && typeof options.disabled === 'function';

  resource.html =
    '<label for="camunda-' + resource.id + '" ' +
      (canBeDisabled ? 'data-show="isDisabled" ' : '') +
      (dataValueLabel ? 'data-value="' + dataValueLabel + '"' : '') + '>'+ label +'</label>' +
    '<div class="pp-field-wrapper" ' +
      (canBeDisabled ? 'data-show="isDisabled"' : '') +
      '>' +
      '<input id="camunda-' + resource.id + '" type="text" name="' + options.modelProperty+'" ' +
        ' />' +
      '<button class="' + actionName + '" data-action="' + actionName + '" data-show="' + showName + '" ' +
        (canBeDisabled ? 'data-disabled="isDisabled"' : '') + '>' +
        '<span>' + buttonLabel + '</span>' +
      '</button>' +
    '</div>';

  resource[actionName] = actionMethod;
  resource[showName] = showMethod;

  if(canBeDisabled) {
    resource.isDisabled = function() {
      return !options.disabled.apply(resource, arguments);
    };
  }

  resource.cssClasses = ['pp-textfield'];

  return resource;
};

module.exports = textField;

@@ -644,16 +644,18 @@
 rs,%0A    
+  
 label = 
@@ -684,16 +684,18 @@
 rce.id,%0A
+  
     data
@@ -735,16 +735,18 @@
 el,%0A    
+  
 buttonLa
@@ -783,16 +783,18 @@
  'X' ),%0A
+  
     acti
@@ -888,24 +888,26 @@
 clear',%0A    
+  
 actionMethod
@@ -1009,16 +1009,18 @@
 Action,%0A
+  
     show
@@ -1111,24 +1111,26 @@
 Clear',%0A    
+  
 showMethod =
@@ -1224,16 +1224,18 @@
 onShow,%0A
+  
     canB

fix code style