/*exported UIPAddImageLink*/
/*global Picture, designer, Utils, UIProvider */
/**
 * @param {ProviderData} data
 * @constructor
 */
var UIPAddImageLink = function (data) {
    'use strict';
    UIPAddImageLink.superclass.constructor.call(this, data);

    this.control(new Picture());

    var changedEvent = function () {
        var control = this.control();
        if (control._url) {
            $([control]).off("changed", changedEvent);
            designer.projectFacade.insertControl("ImageLink", {image: control});
        }
    }.bind(this);

    $([this.control()]).on("changed", changedEvent);

    this.dispose = function () {
        UIPAddImageLink.superclass.dispose.call(this);
        $([this.control()]).off("changed", changedEvent);
    };
};

Utils.extend(UIPAddImageLink, UIProvider);

