// 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.BarcodeEditorPlugin = (function(superClass) {
  extend(BarcodeEditorPlugin, superClass);

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

  BarcodeEditorPlugin.prototype.checkForm = function(opts) {
    var data, findBarcodes;
    data = opts.resultObject.getData()[opts.resultObject.objecttype()];
    findBarcodes = function(_data) {
      var _key, _value, i, key, len, results, value;
      results = [];
      for (key in _data) {
        value = _data[key];
        if (CUI.util.isArray(value)) {
          for (i = 0, len = value.length; i < len; i++) {
            _value = value[i];
            findBarcodes(_value);
          }
          continue;
        }
        if (!key.endsWith(":barcode") || !(value instanceof ez5.Barcode)) {
          continue;
        }
        _key = key.split(":barcode")[0];
        results.push(value.render(_data[_key]));
      }
      return results;
    };
    findBarcodes(data);
    return [];
  };

  return BarcodeEditorPlugin;

})(ez5.EditorPlugin);

ez5.session_ready(function() {
  return Editor.plugins.registerPlugin(ez5.BarcodeEditorPlugin);
});
