// Generated by CoffeeScript 1.12.7
var ExampleExportManagerPlugin,
  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;

ExampleExportManagerPlugin = (function(superClass) {
  extend(ExampleExportManagerPlugin, superClass);

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

  ExampleExportManagerPlugin.prototype.name = function() {
    return "example_export";
  };

  ExampleExportManagerPlugin.prototype.nameLocalized = function() {
    return $$("example.export.manager.plugin.name");
  };

  ExampleExportManagerPlugin.prototype.getExportData = function() {
    var exportData;
    exportData = ExampleExportManagerPlugin.__super__.getExportData.call(this);
    if (!exportData.produce_options) {
      exportData.produce_options = {};
    }
    exportData.produce_options.with_tags = this.__data.with_tags;
    exportData.json = this.__data.type === "json";
    exportData.xml = this.__data.type === "xml";
    return exportData;
  };

  ExampleExportManagerPlugin.prototype.renderForm = function() {
    var form;
    this.__data = this.__initData();
    form = new CUI.Form({
      data: this.__data,
      "class": "ez5-example-export-form",
      fields: [
        {
          type: CUI.Select,
          name: "type",
          form: {
            label: $$("example.export.manager.form.type.label")
          },
          text: $$("example.export.manager.form.type.text"),
          options: [
            {
              value: "json"
            }, {
              value: "xml"
            }
          ]
        }, {
          type: CUI.Checkbox,
          name: "with_tags",
          form: {
            label: $$("example.export.manager.form.with_tags.label")
          },
          text: $$("example.export.manager.form.with_tags.text")
        }
      ]
    });
    return form.start();
  };

  ExampleExportManagerPlugin.prototype.saveAllowed = function() {
    return true;
  };

  ExampleExportManagerPlugin.prototype.__initData = function() {
    var data, exportData, ref, ref1;
    data = {
      with_tags: false,
      type: "json"
    };
    exportData = (ref = this._export.data) != null ? ref["export"] : void 0;
    if (exportData) {
      data.with_tags = (ref1 = exportData.produce_options) != null ? ref1.with_tags : void 0;
      if (exportData.xml) {
        data.type = "xml";
      }
    }
    return data;
  };

  return ExampleExportManagerPlugin;

})(ExportManagerPlugin);

ez5.session_ready(function() {
  return ExportManager.registerPlugin(new ExampleExportManagerPlugin());
});
