/*global window, rJS*/
/*jslint indent: 2, maxerr: 3 */
(function (window, rJS) {
  "use strict";

  rJS(window)
    .setState({
      tag: 'img'
    })

    .declareMethod('render', function (options) {
      var state_dict = {
          src: options.value.url,
          alt: options.description || options.key
        };
      return this.changeState(state_dict);
    })

    .onStateChange(function () {
      var gadget = this;
      return this.getDeclaredGadget('image')
        .push(function (input) {
          return input.render(gadget.state);
        });
    })

    .declareMethod('getContent', function () {
      // An Image field never modifies a document
      return {};
    })

    .declareMethod('checkValidity', function () {
      return true;
    });

}(window, rJS));