PageRenderTime 19ms CodeModel.GetById 9ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/branches/jsdoc_tk_gui/setup/workingDirectory/Webeo/gui/tooltip/TooltipTemplate.js

http://jsdoc-toolkit.googlecode.com/
JavaScript | 94 lines | 66 code | 17 blank | 11 comment | 1 complexity | 20f9b98be4a53ea96e7b8b4ad5e96cfd MD5 | raw file
 1ek.require("gui.tools.Dom");
 2
 3ek.register("gui.tooltip.TooltipTemplate");
 4
 5TooltipTemplate.DEFAULT = 0;
 6
 7TooltipTemplate.ARRAY = 7;//TODO REMOVE ASAP
 8
 9TooltipTemplate.ARRAY_LEFT_TOP 		= 1;
10TooltipTemplate.ARRAY_TOP 			= 2;
11TooltipTemplate.ARRAY_RIGHT_TOP 	= 3;
12TooltipTemplate.ARRAY_RIGHT 		= 4;
13TooltipTemplate.ARRAY_RIGHT_BOTTOM 	= 5;
14TooltipTemplate.ARRAY_BOTTOM 		= 6;
15TooltipTemplate.ARRAY_LEFT_BOTTOM	= 7;
16TooltipTemplate.ARRAY_LEFT 			= 8;
17
18
19/**
20 *
21 */
22function TooltipTemplate (templateId){
23	this.templateId = (templateId) ? templateId : TooltipTemplate.DEFAULT;
24	this.templateDom = new Array();
25	this.container = new Array();
26}
27
28/** */
29TooltipTemplate.prototype.getTemplate = function (text, clazz, id){
30
31	if(!this.templateDom[id]){
32		switch(this.templateId){
33			case TooltipTemplate.DEFAULT : 
34				this.createDefaultTemplate(id);
35			break;
36			case TooltipTemplate.ARRAY_LEFT_TOP :
37			case TooltipTemplate.ARRAY_TOP :
38			case TooltipTemplate.ARRAY_RIGHT_TOP :
39			case TooltipTemplate.ARRAY_RIGHT :
40			case TooltipTemplate.ARRAY_RIGHT_BOTTOM :
41			case TooltipTemplate.ARRAY_BOTTOM :
42			case TooltipTemplate.ARRAY_LEFT_BOTTOM :
43			case TooltipTemplate.ARRAY_LEFT :
44				this.createArrayTemplate(id);
45			break;
46		}
47		//Set class, id and content
48		this.templateDom[id].setAttribute("class", clazz);
49		this.templateDom[id].setAttribute("id", id);
50		this.container[id].innerHTML = text;
51	}
52	return this.templateDom[id];
53}
54
55/** */
56TooltipTemplate.prototype.createDefaultTemplate = function (id){
57	
58	this.templateDom[id] = Dom.createHTMLDivElement("");
59	this.container[id] = this.templateDom[id];
60}
61
62/** */
63TooltipTemplate.prototype.createArrayTemplate = function (id){
64	this.templateDom[id] = Dom.createHTMLTableElement("");
65	
66	//First Row
67	var row1 = Dom.createHTMLTableRowElement("top");
68	row1.appendChild(this.createOneCell("topleft corner", "leftTopArrow"));
69	row1.appendChild(this.createOneCell("top", "topArrow"));
70	row1.appendChild(this.createOneCell("topright corner", "rightTopArrow"));
71	
72	//Middle Row
73	var row2 = Dom.createHTMLTableRowElement();
74	row2.appendChild(this.createOneCell("left", "leftArrow"));
75	
76	this.container[id] = Dom.createHTMLTableCellElement("", "content");
77	row2.appendChild(this.container[id]);
78	
79	row2.appendChild(this.createOneCell("right", "rightArrow"));
80	
81	//Last Row
82	var row3 = Dom.createHTMLTableRowElement("bottom");
83	row3.appendChild(this.createOneCell("bottomleft corner", "leftBottomArrow"));
84	row3.appendChild(this.createOneCell("bottom", "bottomArrow"));
85	row3.appendChild(this.createOneCell("bottomright corner", "rightBottomArrow"));
86
87	this.templateDom[id].appendChild(row1);
88	this.templateDom[id].appendChild(row2);
89	this.templateDom[id].appendChild(row3);
90}
91/** */
92TooltipTemplate.prototype.createOneCell = function (tdClass, divClass){
93	return Dom.createHTMLTableCellElement(Dom.createHTMLDivElement("", divClass), tdClass);
94}