function TextTool() { this.m_edited = null; this.m_edit = null; this.m_status = TXT_STATE_NONE; this.m_type = TXT_EDIT_TYPE_EXISTING; this.m_lastCreated = 0; ////////////////////////////////////////////////////////////// //tool interface, each tool must impleent this this.ClearTool = function() { this.ClearEdit(); var wa = document.getElementById("workingArea"); wa.style.cursor = 'default'; } this.GetToolName = function() { return "textEditTool"; } this.GetToolType= function() { return this.m_type; } this.InitTool = function(initVal) { var wa = document.getElementById("workingArea"); wa.style.cursor = 'text'; this.m_type=initVal['type']; if (this.m_type==TXT_EDIT_TYPE_EXISTING) { this.StartEdit(initVal['obj']); } } /////////////////////////////////////////////// //end tool interface this.imposeMaxEditLength = function() { var text = this.innerHTML; if (text.length > this.m_maxLength) this.innerHTML = text.slice(0,this.m_maxLength); } this.CreateEdit = function() { this.m_edit = document.createElement('TEXTAREA'); this.m_edit.style.width = 100+'px'; this.m_edit.style.position = 'absolute'; this.m_edit.style.top='0px'; this.m_edit.style.left='0px'; this.m_edit.style.overflow='visible'; this.m_edit.style.textAlign='center'; this.m_edit.style.cursor="text"; this.m_edit.style.fontSize=HEADER_FONT_SIZE; this.m_edit.style.fontFamily=HEADER_FONT_FAMILY; this.m_edit.style.fontWeight=HEADER_FONT_WEIGHT; this.m_edit.setAttribute("name", "TextEdit"); this.m_edit.id = "TextEdit"; this.m_edit.onkeyup = this.imposeMaxEditLength; this.m_edit.onkeydown = this.imposeMaxEditLength; this.m_edit.onmousedown = this.imposeMaxEditLength; this.m_edit.style.border = "solid 1px #666666"; g_dc.docBody.appendChild(this.m_edit); g_dc.showElem(this.m_edit, false); } this.CreateEdit(); this.InitEditInput = function(l, t, w, h, fSize, fFam, fWeight, maxchars, textAlign, textPadding, initialText) { if (!this.m_edit) this.CreateEdit(); this.m_edit.style.left = l+"px"; this.m_edit.style.top = t+"px"; this.m_edit.style.width = w+"px"; if (h!=null) this.m_edit.style.height = h+"px"; else this.m_edit.style.height = "Auto"; this.m_edit.style.fontFamily = fFam; this.m_edit.style.fontSize = fSize; this.m_edit.style.fontWeight = fWeight; this.m_edit.style.textAlign = textAlign; this.m_edit.style.padding = textPadding; this.m_edit.m_maxLength=maxchars; if (IsDefined(initialText)) this.m_edit.value=initialText; } this.StartEdit=function(obj) { try{ if (!IsDefined(obj.Edit_getText)) //does not support edit interface return; var pos =obj.Edit_getEditPosition(); this.InitEditInput(pos.m_left, pos.m_top, pos.m_width, pos.m_height, obj.Edit_getFontSize(), obj.Edit_getFontFamily(), obj.Edit_getFontWeight(), obj.Edit_getMaxChars(), obj.Edit_getTextAlign(), obj.Edit_getPadding(), obj.Edit_getText()); g_dc.showElem(this.m_edit, true); g_dc.maxZ(this.m_edit); this.m_edit.focus(); this.m_edit.select(); this.m_status = TXT_STATE_EDIT; this.m_edited = obj; } catch (err) { alert(err + "StartEdit"); } } this.StartEditNewHeader =function(x, y) { this.InitEditInput(x, y, 200, null, HEADER_FONT_SIZE, HEADER_FONT_FAMILY, HEADER_FONT_WEIGHT, 2000, "center", "2px 2px 2px 2px"); g_dc.showElem(this.m_edit, true); g_dc.maxZ(this.m_edit); this.m_edit.focus(); this.m_edit.select(); this.m_status = TXT_STATE_EDIT; } this.StartEditNewNote =function(x, y) { this.InitEditInput(x, y, 200, 150, NOTE_FONT_SIZE, NOTE_FONT_FAMILY, NOTE_FONT_WEIGHT, 2000, "left", "6px 6px 6px 6px"); g_dc.showElem(this.m_edit, true); g_dc.maxZ(this.m_edit); this.m_edit.focus(); this.m_edit.select(); this.m_status = TXT_STATE_EDIT; } this.ClearEdit=function() { this.m_edited = null; this.m_edit.value=""; g_dc.showElem(this.m_edit,false); this.m_status = TXT_STATE_NONE; } this.CreateNewNote=function() { var dv = document.createElement("div"); if (g_dc.ie) dv.setAttribute('className', 'topic_note'); else dv.setAttribute('class', 'topic_note'); dv.setAttribute('id','newNote'+this.m_lastCreated); dv.setAttribute('name',"topic_header"); dv.setAttribute('noteID','newNote'+this.m_lastCreated); dv.setAttribute('X',"0"); dv.setAttribute('Y',"0"); dv.setAttribute('W',"0"); dv.setAttribute('H',"0"); dv.setAttribute('isIcn',"0"); var inner = "