define(['scripts/knockout-3.3.0','scripts/ACTComponent.js'], function(ko, ACTComponent) {

    function ProgressComponentViewModel(params, element) {
		this.base = new ACTComponent($(element), params);
		this.message = ko.observable("");
		this.width = ko.observable(0);
		this.element = element;
		this.cancelButtonIsVisible = ko.observable(false);

		self.transTextCancel = ko.observable(params.Model.TranslatedTexts["Cancel"]);

		this.base.onRefresh = function(obj) {
			if (obj.TriggerCancel)
			{
				$(element).find(".cancelButton").trigger("click");
				return;
			}

			this.CancelClicked = obj.CancelClicked;
			this.message(obj.Message);

			this.base.addCallback(this, "__click", "CancelClicked", []);
			this.click = function(e) {
				params.baseModel.onTriggerAction("TriggerCancel", []);
				this.__click();
			}

			var pct = obj.Position;
			this.width(pct);
			this.cancelButtonIsVisible(obj.HandleCancel);
		}.bind(this);

		this.base.initialize();
		params.ready(true);
    }

	return {
		createViewModel: function(params, componentInfo) {
            return new ProgressComponentViewModel(params, componentInfo.element);
        }
	};

});

