dojo.provide("tests.webmap.widget.ScrollTable");

dojo.require("doh.runner");
dojo.require("webmap.widget.ScrollTable");
dojo.require("tests.Util");

var data = {identifier:"key",
	items: [
		{"key":0, "Field 1 name": "0.1", "Field two":  "0.2 value",  "3rd Field": "0.Value 3rd" },
		{"key":1, "Field 1 name": "1.1", "Field two":  "1.2 value",  "3rd Field": "1.Value 3rd" },
		{"key":2, "Field 1 name": "2.1", "Field two":  "2.2 value",  "3rd Field": "2.Value 3rd" },
		{"key":3, "Field 1 name": "3.1", "Field two":  "3.2 value",  "3rd Field": "3.Value 3rd" }
	]
};
var div;
function doScrollTableSetup(){
	tests.Util.resetDom();
	div = document.createElement("div");
	document.body.appendChild(div);
}
doh.register("tests.webmap.widget.ScrollTable", 
	[
		{
			name: "buildRendering_viewType_detail",
			widget: null,
			createArgs:[],
			layouts: 0,
			setUp: function(){
				doScrollTableSetup();
				var _this = this;
				this.widget = new webmap.widget.ScrollTable({
					_createTable: function(a0,a1){_this.createArgs.push([a0,a1]);},
					layout: function(){_this.layouts++;},
					data:data,
					viewType:webmap.widget.scrollTableViewTypes.detail
				},div);
			},
			runTest: function(){
				tests.assertEqual(div, this.widget.domNode);
				tests.assertEqual(webmap.widget.scrollTableViewTypes.detail, this.widget.viewType);
				tests.assertEqual([[this.widget.data,this.widget.domNode]], this.createArgs);
				tests.assertEqual(1, this.layouts);
				tests.assertTrue(this.widget._loadedData);
			},
			tearDown: function(){
				this.widget.destroy();
			}
		},
		{
			name: "buildRendering_no_viewType_no_data",
			widget: null,
			createArgs:[],
			layouts: 0,
			setUp: function(){
				doScrollTableSetup();
				var _this = this;
				this.widget = new webmap.widget.ScrollTable({
					_createTable: function(a0,a1){_this.createArgs.push([a0,a1]);},
					layout: function(){_this.layouts++;}
				},div);
			},
			runTest: function(){
				tests.assertEqual(div, this.widget.domNode);
				tests.assertEqual(webmap.widget.scrollTableViewTypes.list, this.widget.viewType);
				tests.assertEqual([], this.createArgs);
				tests.assertEqual(0, this.layouts);
				tests.assertFalse(this.widget._loadedData);
			},
			tearDown: function(){
				this.widget.destroy();
			}
		},
		{
			name: "setData",
			widget: null,
			builds: 0,
			setUp: function(){
				doScrollTableSetup();
				var _this = this;
				this.widget = new webmap.widget.ScrollTable({
					buildRendering: function(){_this.builds++;this.domNode = this.srcNodeRef;}
				},div);
			},
			runTest: function(){
				tests.assertEqual(null, this.widget.data);
				this.widget.setData("data");
				tests.assertEqual("data",this.widget.data);
				tests.assertEqual(2, this.builds);//once from constructor and once from setData
			},
			tearDown: function(){
				this.widget.destroy();
			}
		},
		{
			name: "layout_viewType_list",
			widget: null,
			lists: 0,
			details: 0,
			setUp: function(){
				doScrollTableSetup();
				var _this = this;
				this.widget = new webmap.widget.ScrollTable({
					_loadedData: true,
					viewType: webmap.widget.scrollTableViewTypes.list,
					_layoutList: function(){_this.lists++;},
					_layoutDetail: function(){_this.details++;}
				},div);
			},
			runTest: function(){
				this.widget.layout();
				tests.assertEqual(1, this.lists);
				tests.assertEqual(0, this.details);
				this.widget._loadedData = false;
				this.widget.layout();
				tests.assertEqual(1, this.lists);
				tests.assertEqual(0, this.details);
			},
			tearDown: function(){
				this.widget.destroy();
			}
		},
		{
			name: "layout_viewType_detail",
			widget: null,
			lists: 0,
			details: 0,
			setUp: function(){
				doScrollTableSetup();
				var _this = this;
				this.widget = new webmap.widget.ScrollTable({
					_loadedData: true,
					viewType: webmap.widget.scrollTableViewTypes.detail,
					_layoutList: function(){_this.lists++;},
					_layoutDetail: function(){_this.details++;}
				},div);
			},
			runTest: function(){
				this.widget.layout();
				tests.assertEqual(0, this.lists);
				tests.assertEqual(1, this.details);
				this.widget._loadedData = false;
				this.widget.layout();
				tests.assertEqual(0, this.lists);
				tests.assertEqual(1, this.details);
			},
			tearDown: function(){
				this.widget.destroy();
			}
		},
		{
			name: "_layoutList_ie",
			widget: null,
			widget: null,
			table:null,
			setUp: function(){
				doScrollTableSetup();
				if (!dojo.isIE) return;
				this.widget = new webmap.widget.ScrollTable({data:data},div);
				dojo.style(this.widget.domNode, "width", "200px");
				this.table = this.widget.domNode.firstChild.firstChild;
			},
			runTest: function(){
				if (!dojo.isIE) return;
				tests.assertEqual(this.widget.domNode.offsetWidth - 19, 
					dojo.style(this.table, "width"));
				tests.assertEqual(this.widget.domNode.offsetHeight - 1, 
					dojo.style(this.widget.domNode.firstChild, "height"));
			},
			tearDown: function(){
				if (!dojo.isIE) return;
				this.widget.destroy();
			}
		},
		{
			name: "_layoutList_ff",
			widget: null,
			table:null,
			setUp: function(){
				doScrollTableSetup();
				if (dojo.isIE) return;
				this.widget = new webmap.widget.ScrollTable({data:data},div);
				dojo.style(this.widget.domNode, "width", "200px");
				this.table = this.widget.domNode.firstChild.firstChild;
			},
			runTest: function(){
				if (dojo.isIE) return;
				tests.assertEqual(46, dojo.style(this.table.childNodes[1], "height"));
			},
			tearDown: function(){
				if (dojo.isIE) return;
				this.widget.destroy();
			}
		},
		{
			name: "_layoutDetail",
			widget: null,
			table: null,
			setUp: function(){
				doScrollTableSetup();
				this.widget = new webmap.widget.ScrollTable({data:data},div);
				dojo.style(this.widget.domNode, "width", "200px");
				this.table = this.widget.domNode.firstChild.firstChild;
			},
			runTest: function(){
				tests.assertEqual(200, dojo.style(this.table, "width"));
				tests.assertEqual(71, dojo.style(this.widget.domNode.firstChild, "height"));
			},
			tearDown: function(){
				this.widget.destroy();
			}
		},
		{
			name: "_createTable",
			widget: null,
			headerArgs:[],
			listArgs:[],
			detailArgs:[],
			setUp: function(){
				doScrollTableSetup();
				var _this = this;
				this.widget = new webmap.widget.ScrollTable({data:data,
					viewType: webmap.widget.scrollTableViewTypes.list,
					buildRendering: function(){this.domNode = this.srcNodeRef;},
					_createHeader: function(a0,a1){_this.headerArgs.push([a0,a1]);},
					_createListBody: function(a0,a1){_this.listArgs.push([a0,a1]);},
					_createDetailBody: function(a0,a1){_this.detailArgs.push([a0,a1]);}
				},div);
				dojo.style(this.widget.domNode, "width", "200px");
			},
			runTest: function(){
				var container = this.widget._createTable(this.widget.data, this.widget.domNode);
				var table = container.firstChild;
				tests.assertEqual([[data, table]], this.headerArgs);
				tests.assertEqual([[data, table]], this.listArgs);
				tests.assertEqual([], this.detailArgs);
				tests.assertEqual("webmapScrollTableContainer", container.className);
				tests.assertEqual("webmapScrollTable", table.className);
				if (dojo.isIE) tests.assertEqual("auto", dojo.style(container, "overflow"));
				this.widget.domNode.removeChild(container);
				this.widget.viewType = webmap.widget.scrollTableViewTypes.detail;
				container = this.widget._createTable(this.widget.data, this.widget.domNode);
				tests.assertEqual([[data, table]], this.headerArgs);
				tests.assertEqual([[data, table]], this.listArgs);
				tests.assertEqual([], this.detailArgs);
				tests.assertEqual("webmapScrollTableContainer", container.className);
				tests.assertEqual("webmapScrollTable", table.className);
				tests.assertEqual("auto", dojo.style(container, "overflow"));
			},
			tearDown: function(){
				this.widget.destroy();
			}
		},
		{
			name: "_createHeader_displayIdentifier_true",
			widget: null,
			table: document.createElement("table"),
			setUp: function(){
				doScrollTableSetup();
				var _this = this;
				this.widget = new webmap.widget.ScrollTable({data:data,
					displayIdentifier: true,
					buildRendering: function(){this.domNode = this.srcNodeRef;}
				},div);
				document.body.appendChild(this.table);
			},
			runTest: function(){
				this.widget._createHeader(this.widget.data, this.table);
				if (dojo.isIE)
					tests.assertEqual(
						'<thead><tr><td class="webmapScrollTableHead">key</td><td class="webmapScrollTableHead">Field 1 name</td><td class="webmapScrollTableHead">Field two</td><td class="webmapScrollTableHead">3rd Field</td><td class="headerEnd webmapScrollTableHead">&nbsp;</td></tr></thead>',
						this.table.innerHTML);
				else
					tests.assertEqual(
						'<thead><tr><td class="webmapScrollTableHead">key</td><td class="webmapScrollTableHead">Field 1 name</td><td class="webmapScrollTableHead">Field two</td><td class="webmapScrollTableHead">3rd Field</td><td class="headerEnd webmapScrollTableHead">&nbsp;</td></tr></thead>',
						this.table.innerHTML);
			},
			tearDown: function(){
				document.body.removeChild(this.table);
				this.widget.destroy();
			}
		},
		{
			name: "_createHeader_displayIdentifier_false",
			widget: null,
			table: document.createElement("table"),
			setUp: function(){
				doScrollTableSetup();
				var _this = this;
				this.widget = new webmap.widget.ScrollTable({data:data,
					displayIdentifier: false,
					buildRendering: function(){this.domNode = this.srcNodeRef;}
				},div);
				document.body.appendChild(this.table);
			},
			runTest: function(){
				this.widget._createHeader(this.widget.data, this.table);
				if (dojo.isIE)
					tests.assertEqual(
						'<thead><tr><td class="webmapScrollTableHead">Field 1 name</td><td class="webmapScrollTableHead">Field two</td><td class="webmapScrollTableHead">3rd Field</td><td class="headerEnd webmapScrollTableHead">&nbsp;</td></tr></thead>',
						this.table.innerHTML);
				else
					tests.assertEqual(
						'<thead><tr><td class="webmapScrollTableHead">Field 1 name</td><td class="webmapScrollTableHead">Field two</td><td class="webmapScrollTableHead">3rd Field</td><td class="headerEnd webmapScrollTableHead">&nbsp;</td></tr></thead>',
						this.table.innerHTML);
			},
			tearDown: function(){
				document.body.removeChild(this.table);
				this.widget.destroy();
			}
		},
		{
			name: "_createListBody_displayIdentifier_true",
			widget: null,
			table: document.createElement("table"),
			setUp: function(){
				doScrollTableSetup();
				var _this = this;
				this.widget = new webmap.widget.ScrollTable({data:data,
					displayIdentifier: true,
					buildRendering: function(){this.domNode = this.srcNodeRef;}
				},div);
				document.body.appendChild(this.table);
			},
			runTest: function(){
				this.widget._createListBody(this.widget.data, this.table);
				if (dojo.isIE)
					tests.assertEqual(
						'<tbody><tr id="item_0"><td>0</td><td>0.1</td><td>0.2 value</td><td>0.Value 3rd</td></tr><tr class="other" id="item_1"><td>1</td><td>1.1</td><td>1.2 value</td><td>1.Value 3rd</td></tr><tr id="item_2"><td>2</td><td>2.1</td><td>2.2 value</td><td>2.Value 3rd</td></tr><tr class="other" id="item_3"><td>3</td><td>3.1</td><td>3.2 value</td><td>3.Value 3rd</td></tr></tbody>',
						this.table.innerHTML);
				else
					tests.assertEqual(
						'<tbody><tr id="item_0"><td>0</td><td>0.1</td><td>0.2 value</td><td>0.Value 3rd</td></tr><tr class="other" id="item_1"><td>1</td><td>1.1</td><td>1.2 value</td><td>1.Value 3rd</td></tr><tr id="item_2"><td>2</td><td>2.1</td><td>2.2 value</td><td>2.Value 3rd</td></tr><tr class="other" id="item_3"><td>3</td><td>3.1</td><td>3.2 value</td><td>3.Value 3rd</td></tr></tbody>',
						this.table.innerHTML);
			},
			tearDown: function(){
				document.body.removeChild(this.table);
				this.widget.destroy();
			}
		},
		{
			name: "_createListBody_displayIdentifier_false",
			widget: null,
			table: document.createElement("table"),
			setUp: function(){
				doScrollTableSetup();
				var _this = this;
				this.widget = new webmap.widget.ScrollTable({data:data,
					displayIdentifier: false,
					buildRendering: function(){this.domNode = this.srcNodeRef;}
				},div);
				document.body.appendChild(this.table);
			},
			runTest: function(){
				this.widget._createListBody(this.widget.data, this.table);
				if (dojo.isIE)
					tests.assertEqual(
						'<tbody><tr id="item_0"><td>0.1</td><td>0.2 value</td><td>0.Value 3rd</td></tr><tr class="other" id="item_1"><td>1.1</td><td>1.2 value</td><td>1.Value 3rd</td></tr><tr id="item_2"><td>2.1</td><td>2.2 value</td><td>2.Value 3rd</td></tr><tr class="other" id="item_3"><td>3.1</td><td>3.2 value</td><td>3.Value 3rd</td></tr></tbody>',
						this.table.innerHTML);
				else
					tests.assertEqual(
						'<tbody><tr id="item_0"><td>0.1</td><td>0.2 value</td><td>0.Value 3rd</td></tr><tr class="other" id="item_1"><td>1.1</td><td>1.2 value</td><td>1.Value 3rd</td></tr><tr id="item_2"><td>2.1</td><td>2.2 value</td><td>2.Value 3rd</td></tr><tr class="other" id="item_3"><td>3.1</td><td>3.2 value</td><td>3.Value 3rd</td></tr></tbody>',
						this.table.innerHTML);
			},
			tearDown: function(){
				document.body.removeChild(this.table);
				this.widget.destroy();
			}
		},
		{
			name: "_createDetailBody_displayIdentifier_true",
			widget: null,
			table: document.createElement("table"),
			setUp: function(){
				doScrollTableSetup();
				var _this = this;
				this.widget = new webmap.widget.ScrollTable({data:data,
					displayIdentifier: true,
					buildRendering: function(){this.domNode = this.srcNodeRef;}
				},div);
				document.body.appendChild(this.table);
			},
			runTest: function(){
				this.widget._createDetailBody(this.widget.data, this.table);
				if (dojo.isIE)
					tests.assertEqual(
						'<tbody class="other" id="item_0"><tr><td class="webmapScrollTableField">key</td><td>0</td></tr><tr><td class="webmapScrollTableField">Field 1 name</td><td>0.1</td></tr><tr><td class="webmapScrollTableField">Field two</td><td>0.2 value</td></tr><tr><td class="webmapScrollTableField">3rd Field</td><td>0.Value 3rd</td></tr></tbody><tbody id="item_1"><tr><td class="webmapScrollTableField">key</td><td>1</td></tr><tr><td class="webmapScrollTableField">Field 1 name</td><td>1.1</td></tr><tr><td class="webmapScrollTableField">Field two</td><td>1.2 value</td></tr><tr><td class="webmapScrollTableField">3rd Field</td><td>1.Value 3rd</td></tr></tbody><tbody class="other" id="item_2"><tr><td class="webmapScrollTableField">key</td><td>2</td></tr><tr><td class="webmapScrollTableField">Field 1 name</td><td>2.1</td></tr><tr><td class="webmapScrollTableField">Field two</td><td>2.2 value</td></tr><tr><td class="webmapScrollTableField">3rd Field</td><td>2.Value 3rd</td></tr></tbody><tbody id="item_3"><tr><td class="webmapScrollTableField">key</td><td>3</td></tr><tr><td class="webmapScrollTableField">Field 1 name</td><td>3.1</td></tr><tr><td class="webmapScrollTableField">Field two</td><td>3.2 value</td></tr><tr><td class="webmapScrollTableField">3rd Field</td><td>3.Value 3rd</td></tr></tbody>',
						this.table.innerHTML);
				else
					tests.assertEqual(
						'<tbody class="other" id="item_0"><tr><td class="webmapScrollTableField">key</td><td>0</td></tr><tr><td class="webmapScrollTableField">Field 1 name</td><td>0.1</td></tr><tr><td class="webmapScrollTableField">Field two</td><td>0.2 value</td></tr><tr><td class="webmapScrollTableField">3rd Field</td><td>0.Value 3rd</td></tr></tbody><tbody id="item_1"><tr><td class="webmapScrollTableField">key</td><td>1</td></tr><tr><td class="webmapScrollTableField">Field 1 name</td><td>1.1</td></tr><tr><td class="webmapScrollTableField">Field two</td><td>1.2 value</td></tr><tr><td class="webmapScrollTableField">3rd Field</td><td>1.Value 3rd</td></tr></tbody><tbody class="other" id="item_2"><tr><td class="webmapScrollTableField">key</td><td>2</td></tr><tr><td class="webmapScrollTableField">Field 1 name</td><td>2.1</td></tr><tr><td class="webmapScrollTableField">Field two</td><td>2.2 value</td></tr><tr><td class="webmapScrollTableField">3rd Field</td><td>2.Value 3rd</td></tr></tbody><tbody id="item_3"><tr><td class="webmapScrollTableField">key</td><td>3</td></tr><tr><td class="webmapScrollTableField">Field 1 name</td><td>3.1</td></tr><tr><td class="webmapScrollTableField">Field two</td><td>3.2 value</td></tr><tr><td class="webmapScrollTableField">3rd Field</td><td>3.Value 3rd</td></tr></tbody>',
						this.table.innerHTML);
			},
			tearDown: function(){
				document.body.removeChild(this.table);
				this.widget.destroy();
			}
		},
		{
			name: "_createDetailBody_displayIdentifier_false",
			widget: null,
			table: document.createElement("table"),
			setUp: function(){
				doScrollTableSetup();
				var _this = this;
				this.widget = new webmap.widget.ScrollTable({data:data,
					displayIdentifier: false,
					buildRendering: function(){this.domNode = this.srcNodeRef;}
				},div);
				document.body.appendChild(this.table);
			},
			runTest: function(){
				this.widget._createDetailBody(this.widget.data, this.table);
				if (dojo.isIE)
					tests.assertEqual(
						'<tbody class="other" id="item_0"><tr><td class="webmapScrollTableField">Field 1 name</td><td>0.1</td></tr><tr><td class="webmapScrollTableField">Field two</td><td>0.2 value</td></tr><tr><td class="webmapScrollTableField">3rd Field</td><td>0.Value 3rd</td></tr></tbody><tbody id="item_1"><tr><td class="webmapScrollTableField">Field 1 name</td><td>1.1</td></tr><tr><td class="webmapScrollTableField">Field two</td><td>1.2 value</td></tr><tr><td class="webmapScrollTableField">3rd Field</td><td>1.Value 3rd</td></tr></tbody><tbody class="other" id="item_2"><tr><td class="webmapScrollTableField">Field 1 name</td><td>2.1</td></tr><tr><td class="webmapScrollTableField">Field two</td><td>2.2 value</td></tr><tr><td class="webmapScrollTableField">3rd Field</td><td>2.Value 3rd</td></tr></tbody><tbody id="item_3"><tr><td class="webmapScrollTableField">Field 1 name</td><td>3.1</td></tr><tr><td class="webmapScrollTableField">Field two</td><td>3.2 value</td></tr><tr><td class="webmapScrollTableField">3rd Field</td><td>3.Value 3rd</td></tr></tbody>',
						this.table.innerHTML);
				else
					tests.assertEqual(
						'<tbody class="other" id="item_0"><tr><td class="webmapScrollTableField">Field 1 name</td><td>0.1</td></tr><tr><td class="webmapScrollTableField">Field two</td><td>0.2 value</td></tr><tr><td class="webmapScrollTableField">3rd Field</td><td>0.Value 3rd</td></tr></tbody><tbody id="item_1"><tr><td class="webmapScrollTableField">Field 1 name</td><td>1.1</td></tr><tr><td class="webmapScrollTableField">Field two</td><td>1.2 value</td></tr><tr><td class="webmapScrollTableField">3rd Field</td><td>1.Value 3rd</td></tr></tbody><tbody class="other" id="item_2"><tr><td class="webmapScrollTableField">Field 1 name</td><td>2.1</td></tr><tr><td class="webmapScrollTableField">Field two</td><td>2.2 value</td></tr><tr><td class="webmapScrollTableField">3rd Field</td><td>2.Value 3rd</td></tr></tbody><tbody id="item_3"><tr><td class="webmapScrollTableField">Field 1 name</td><td>3.1</td></tr><tr><td class="webmapScrollTableField">Field two</td><td>3.2 value</td></tr><tr><td class="webmapScrollTableField">3rd Field</td><td>3.Value 3rd</td></tr></tbody>',
						this.table.innerHTML);
			},
			tearDown: function(){
				document.body.removeChild(this.table);
				this.widget.destroy();
			}
		},
		{
			name: "_connectEvents",
			widget: null,
			connect: dojo.connect,
			connects:[],
			node: "node",
			setUp: function(){
				doScrollTableSetup();
				var _this = this;
				this.widget = new webmap.widget.ScrollTable({
					buildRendering: function(){this.domNode = this.srcNodeRef;}
				},div);
				dojo.connect = function(a0,a1,a2,a3){
					_this.connects.push([a0,a1,a2,a3]);
				};
			},
			runTest: function(){
				this.widget._connectEvents(this.node);
				tests.assertEqual([[this.node, "onmouseover", this.widget, "_doMouseOver"],
					[this.node, "onmouseout", this.widget, "_doMouseOut"],
					[this.node, "onclick", this.widget, "_itemClick"]],
					this.connects);
			},
			tearDown: function(){
				dojo.connect = this.connect;
				this.widget.destroy();
			}
		},
		{
			name: "_doMouseOver_doMouseOut",
			widget: null,
			addClass: dojo.addClass,
			addArgs: [],
			removeClass: dojo.removeClass,
			removeArgs: [],
			evt: {target:{parentNode:"parentNode"}},
			setUp: function(){
				doScrollTableSetup();
				var _this = this;
				this.widget = new webmap.widget.ScrollTable({
					buildRendering: function(){this.domNode = this.srcNodeRef;}
				},div);
				dojo.addClass = function(a0,a1){_this.addArgs.push([a0,a1]);};
				dojo.removeClass = function(a0,a1){_this.removeArgs.push([a0,a1]);};
			},
			runTest: function(){
				this.widget._doMouseOver(this.evt);
				tests.assertEqual([[this.evt.target.parentNode, "webmapScrollTableItemHover"]], this.addArgs);
				tests.assertEqual([], this.removeArgs);
				this.widget._doMouseOut(this.evt);
				tests.assertEqual([[this.evt.target.parentNode, "webmapScrollTableItemHover"]], this.addArgs);
				tests.assertEqual([[this.evt.target.parentNode, "webmapScrollTableItemHover"]], this.removeArgs);
			},
			tearDown: function(){
				dojo.addClass = this.addClass;
				dojo.removeClass = this.removeClass;
				this.widget.destroy();
			}
		},
		{
			name: "_itemClick",
			widget: null,
			evt: {target:{parentNode:{id:"item_id1",parentNode:{id:"item_id2"}}}},
			subscription: null,
			args:[],
			setUp: function(){
				doScrollTableSetup();
				var _this = this;
				this.widget = new webmap.widget.ScrollTable({
					viewType: webmap.widget.scrollTableViewTypes.list,
					buildRendering: function(){this.domNode = this.srcNodeRef;},
					itemClick: function(e){tests.assertEqual(_this.evt, e);}
				},div);
				this.subscription = dojo.subscribe("webmap.widget.ScrollTable.itemClicked", 
					function(a){_this.args.push(a);});
			},
			runTest: function(){
				this.widget._itemClick(this.evt);
				tests.assertEqual([{featureId:"id1",scrollTable:this.widget}],this.args)
				this.widget.viewType = webmap.widget.scrollTableViewTypes.detail;
				this.widget._itemClick(this.evt);
				tests.assertEqual([{featureId:"id1",scrollTable:this.widget},
					{featureId:"id2",scrollTable:this.widget}],this.args)
			},
			tearDown: function(){
				dojo.unsubscribe(this.subscription);
				this.widget.destroy();
			}
		}
	]
);