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

	function AboutExtensionComponentViewModel(params, element) {
		var self = this;

		self.base = new ACTComponent($(element), params);

		self.icon = ko.observable();
		self.name = ko.observable();
		self.author = ko.observable();
		self.version = ko.observable();
		self.description = ko.observable();
		self.format = ko.observable();
		self.folder = ko.observable();
		self.guid = ko.observable();
		self.contexts = ko.observableArray([]);

		self.transTextAuthor      = ko.observable(params.Model.TranslatedTexts["Author"]);
		self.transTextVersion     = ko.observable(params.Model.TranslatedTexts["Version"]);
		self.transTextFormat      = ko.observable(params.Model.TranslatedTexts["Format"]);
		self.transTextFolder      = ko.observable(params.Model.TranslatedTexts["Folder"]);
		self.transTextGuid        = ko.observable(params.Model.TranslatedTexts["Guid"]);
		self.transTextContext     = ko.observable(params.Model.TranslatedTexts["Context"]);
		self.transTextFeature     = ko.observable(params.Model.TranslatedTexts["Feature"]);
		self.transTextInformation = ko.observable(params.Model.TranslatedTexts["Information"]);

		self.base.onRefresh = function(obj) {
			self.icon(obj.Icon);
			self.name(obj.Name);
			self.author(obj.Author);
			self.version(obj.Version);
			self.description(obj.Description);
			self.format(obj.Format);
			self.folder(obj.Folder);
			self.guid(obj.Guid);

			var nameElement = $(element).find(".name");
			var lineHeightValue;
			if (self.description() == "") {
				lineHeightValue = "48px";    // img size
			} else {
				lineHeightValue = "100%";
			}
			nameElement.css("line-height", lineHeightValue);

			var newContexts = [];
			for (var context in obj.Objects) {
				var listObject = obj.Objects[context];
				var newContext = {context: context, types: [], childrenCount: 0};
				for (var typeObject in listObject) {
					var names = listObject[typeObject];
					newContext.types.push({type: typeObject, names: names});
					newContext.childrenCount += names.length;
				}
				newContexts.push(newContext);
			}
			self.contexts(newContexts);
		}

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

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

});

