define(['scripts/knockout-3.3.0', 'mod/properties/propertyutils'], function(ko, PropertyUtils) {

    function PropertyApplyCancelViewModel(params, element) {
		this.utils = new PropertyUtils();
		this.utils.Init(this, params, element);

		params.clickEdit = function() {
			var divCaptionELement = element.children[0].children[1].children[0];
			var captionELement = divCaptionELement.children[0];
			var offset = captionELement.getBoundingClientRect();
			var height = captionELement.offsetHeight;

			// width format : "XXXpx"
			var widthText = divCaptionELement.style.width;
			widthText = widthText.split("p")[0];
			var width = Number(widthText);

			this.onclick("edit", offset.left, offset.top, width, height);
		}.bind(params);
		params.clickCancel = function() {
			this.onclick("cancel");
		}.bind(params);
		params.clickApply = function() {
			this.onclick("apply");
		}.bind(params);

		this.utils.Ready(params);
		return params;
    }

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