Ext.define("IceCap.view.WebContainer", {

	extend: "Ext.Component",

	xtype: "icecap-webcontainer",

	alias: [
		"widget.icecap.view.webcontainer"
	],

	config: {
		src: ""
	},

	autoEl: {
		tag: "iframe",
		style: "height: 100%; width: 100%; border: none;",
		src: ""
	},

	listeners: {
		render: {
			fn: function (i_self) {

				var i_element = i_self.getEl();

				if (i_element) {
					i_element.dom.src = i_self.getSrc();
					i_self.setLoading(true);
				}
			}
		},
		load: {
			element: "el",
			fn: function (i_element) {

				var i_self = this.component;
				i_self.setLoading(false);
			}
		}
	},

	initComponent: function () {

		var i_self = this;
		i_self.callParent(arguments);

	},

	updateSrc: function(s_url) {

		var i_self = this;
		var i_element = i_self.getEl();

		if (i_element) {
			i_element.dom.src = s_url;
			i_self.setLoading(true);
		}
	}
});
