// Generated by CoffeeScript 1.12.7
var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  hasProp = {}.hasOwnProperty;

ez5.PdfCreator.Node.EAS = (function(superClass) {
  extend(EAS, superClass);

  function EAS() {
    return EAS.__super__.constructor.apply(this, arguments);
  }

  EAS.getName = function() {
    return "eas";
  };

  EAS.prototype.__renderPdfContent = function() {
    var asset, data, div, fileData, span;
    data = this.getData();
    div = CUI.dom.div();
    fileData = data["file:eas_file"];
    if (fileData != null ? fileData._id : void 0) {
      asset = new AssetPlain({
        value: fileData
      });
      CUI.dom.append(div, asset.getImgElement(null, "original", {
        for_print: true
      }));
    } else {
      span = CUI.dom.span();
      span.textContent = "< " + ($$("pdf-creator.settings.node.eas.no-file-selected")) + " >";
      CUI.dom.append(div, span);
    }
    return div;
  };

  EAS.prototype.__getSettingsFields = function() {
    var eas_field, fields;
    eas_field = new EASField({
      name: "file:eas_file"
    });
    fields = [
      {
        type: CUI.DataFieldProxy,
        form: {
          label: $$("pdf-creator.settings.node.eas.file")
        },
        name: "file:eas_file",
        element: (function(_this) {
          return function(df) {
            return eas_field.renderEditorInput(df.getData(), null);
          };
        })(this)
      }
    ];
    return fields;
  };

  EAS.prototype.getSaveData = function() {
    var _data, ref, saveData;
    saveData = EAS.__super__.getSaveData.call(this);
    _data = saveData.data;
    if (_data != null ? (ref = _data["file:eas_file"]) != null ? ref._id : void 0 : void 0) {
      _data["file:eas_file"] = {
        _id: _data["file:eas_file"]._id
      };
    } else {
      delete _data["file:eas_file"];
    }
    return saveData;
  };

  EAS.prototype.__getStyleSettings = function() {
    return ["class-name", "width"];
  };

  return EAS;

})(ez5.PdfCreator.Node.Div);

ez5.PdfCreator.plugins.registerPlugin(ez5.PdfCreator.Node.EAS);
