/*///////////////////////////////////////////////////////////////////////// // Rect class*/ function Rect(t,l,w,h) { this.m_top = toInt(t); this.m_left = toInt(l); this.m_width = toInt(w); this.m_height = toInt(h); } Rect.prototype.bottom = function() { return (this.m_top+this.m_height); } Rect.prototype.right = function() { return (this.m_left+this.m_width); } Rect.prototype.isWithin = function(otherRc) { //alert(otherRc.bottom()+ " " +this.bottom()); return (otherRc.m_top>=this.m_top && otherRc.bottom()<=this.bottom() && otherRc.m_left>=this.m_left && otherRc.right()<=this.right()); } Rect.prototype.isPtWithin = function(x,y) { //alert(otherRc.bottom()+ " " +this.bottom()); return (y>=this.m_top && y<=this.bottom() && x>=this.m_left && x<=this.right()); } Rect.prototype.SnapTopLeft = function(snapBy, bLeftUp, bTopUp) { if (bLeftUp) this.m_left = toInt(Math.ceil(this.m_left/snapBy)*snapBy); else this.m_left = toInt(Math.floor(this.m_left/snapBy)*snapBy); if (bTopUp) this.m_top = toInt(Math.ceil(this.m_top/snapBy)*snapBy); else this.m_top = toInt(Math.floor(this.m_top/snapBy)*snapBy); } //////////////////////////////////////////////////////////////////////////// // Document Class function DocObj() { this.nav = navigator.userAgent.toLowerCase(); this.docBody = (document.compatMode && document.compatMode.toLowerCase() != "backcompat")? document.documentElement : (document.body || null); this.op = !!(window.opera && document.getElementById); if(this.op) document.onmousedown = new Function('e', 'if(((e = e || window.event).target || e.srcElement).tagName == "IMAGE") return false;'); this.ie = !!(this.nav.indexOf("msie") >= 0 && document.all && this.docBody && !this.op); this.iemac = !!(this.ie && this.nav.indexOf("mac") >= 0); this.ie4 = !!(this.ie && !document.getElementById); this.n4 = !!(document.layers && typeof document.classes != dd_u); this.n6 = !!(typeof window.getComputedStyle != dd_u && typeof document.createRange != dd_u); this.w3c = !!(!this.op && !this.ie && !this.n6 && document.getElementById); this.ce = !!(document.captureEvents && document.releaseEvents); this.px = this.n4? '' : 'px'; this.m_maxZ = 10; this.m_saveAjaxSender=null; this.m_isDirty = false; this.m_aElements = new Array(0); this.maxZ = function(obj) { try{ obj.style.zIndex = this.m_maxZ; this.m_maxZ++; } catch(err){ alert(err.description); } } this.getWndWidth = function() { return toInt( (this.docBody && !this.op && !this.w3c && this.docBody.clientWidth)? this.docBody.clientWidth : (window.innerWidth || 0)); } this.getWndHeight = function() { return toInt( (this.docBody && !this.op && !this.w3c && this.docBody.clientHeight)? this.docBody.clientHeight : (window.innerHeight || 0)); } this.getScrollX = function() { return toInt(window.pageXOffset || (this.docBody? this.docBody.scrollLeft : 0)); } this.getScrollY = function() { return toInt(window.pageYOffset || (this.docBody? this.docBody.scrollTop : 0)); } this.getDocX = function(obj) { var ret = toInt(obj.offsetLeft); while(obj.offsetParent) {obj=obj.offsetParent;ret+=toInt(obj.offsetLeft);} return ret; } this.getDragContainer= function(obj) { while(IsDefined(obj) && obj ) { if (IsDefined(obj.dragContainer)) { return obj.dragContainer; } obj=obj.parentNode; } return null; } this.getContainer = function(obj) { var ret = toInt(obj.offsetLeft); while(obj.offsetParent) {obj=obj.offsetParent;ret+=toInt(obj.offsetLeft);} return ret; } this.FixPos = function(rc, boundID, maxW, maxH, minW, minH) { var wa = this.GetElementRC(boundID); var mWidth = IsDefined(maxW)?maxW:wa.m_width; rc.m_width=Math.min(rc.m_width, mWidth); var mHeight = IsDefined(maxH)?maxH:wa.m_height; rc.m_height=Math.min(rc.m_height, mHeight); if (IsDefined(minW)) rc.m_width=Math.max(rc.m_width, minW); if (IsDefined(minH)) rc.m_height=Math.max(rc.m_height, minH); rc.m_left = Math.max(rc.m_left,wa.m_left); rc.m_left = Math.min(rc.m_left, wa.right()-rc.m_width); rc.m_top = Math.max(rc.m_top,wa.m_top); rc.m_top = Math.min(rc.m_top, wa.bottom()-rc.m_height); return rc; } this.getDocY = function(obj) { var ret = toInt(obj.offsetTop); while(obj.offsetParent) {obj=obj.offsetParent;ret+=toInt(obj.offsetTop);} return ret; } this.Select = function(obj) { if (this.m_SelectedObj!=null) { this.m_SelectedObj.SetSelected(false); } this.m_SelectedObj = obj; if (obj) obj.SetSelected(true); } this.SetClass=function(obj, classNm) { if (this.ie) obj.setAttribute('className', classNm); else obj.setAttribute('class', classNm); } this.InitRegularTT=function(nm,prnt,txt, ttid) { var btn = g_dc.GetObjInnerByName(prnt, nm)[0]; if (!btn) return; btn.tt = document.createElement('div'); btn.m_ttid = ttid; g_dc.docBody.appendChild(btn.tt); this.SetClass(btn.tt, "regularToolTip"); btn.tt.innerHTML = txt; btn.TTShow = function() { this.tt.style.left = Math.max((g_dc.getDocX(this)-40),0)+"px"; this.tt.style.top = Math.max((g_dc.getDocY(this)-30),0)+"px"; this.tt.style.display="block"; g_dc.maxZ(this.tt); } btn.TTHide = function() { this.tt.style.display="none"; } btn.TTIsSame = function(other) { return (this.TTGetID() == other.TTGetID()); } btn.TTGetID = function() { return (this.m_ttid); } btn.TTInBounds = function(x,y) { var rc = new Rect(g_dc.getDocY(this), g_dc.getDocX(this), this.offsetWidth, this.offsetHeight); return rc.isPtWithin(x,y); } } this.GetObjInnerByName= function(obj, nm) { var all = obj.getElementsByTagName('*'); var ret = new Array(); for (var i=0;i"; str+=""; this.m_saveAjaxSender.SendAjax("POST", 'xml='+str, homeurl+"/saveClip.php", this.showResponse); //var myAjax = new Ajax.Request( // homeurl+"/saveClip.php", // { // method: 'post', // parameters: 'xml='+str, // onComplete: showResponse // }); } this.GetWorkAreaRC = function() { return this.GetElementRC("workingArea"); } this.GetElementRC = function(id) { var elem = document.getElementById(id); var ret = new Rect(this.getDocY(elem), this.getDocX(elem), toInt(elem.offsetWidth), toInt(elem.offsetHeight)); return ret; } this.getElemFormID = function(id, doc) { doc = doc || document; if(this.n4) { if(doc.layers[id]) return doc.layers[id]; for(var d_i = doc.layers.length; d_i--;) { var d_y = this.getElemFormID(id, doc.layers[d_i].document); if(d_y) return d_y; } } if(this.ie) return doc.all[id] || null; if(doc.getElementById) return doc.getElementById(id) || null; return null; } this.GetDivsByName = function(nm) { if (!document.all) return document.getElementsByName(nm); else { var divs=document.getElementsByTagName('div'); var arr = new Array(0); for(var i = divs.length;i--;) { if (divs[i].name==nm) arr.push(divs[i]); } return arr; } } this.init = function() { this.m_clipResidueX = 2; this.m_clipResidueY = 36; var clpMeasure=document.getElementById('clpMeasure'); var ogf = this.GetObjInnerByName(clpMeasure, "origUrlText")[0]; this.m_origTextLength = toInt(ogf.offsetWidth); var clipElements = this.GetDivsByName('expandedClip'); var incompatMsg = this.getElemFormID("incompatMsg"); for(var i = clipElements.length; i--;) { var elem = new ClipObject(clipElements[i].id); if (!(elem) || elem==null){alert('error4');return;} this.m_aElements[elem.m_expObj.id] = this.m_aElements[i] = elem; elem.initSize(); if ((elem.m_BRZ == "ie" && !this.ie) || (elem.m_BRZ == "moz" && this.ie)) { incompatMsg.style.display="block"; } elem.MoveTo(elem.m_posX, elem.m_posY); elem.setFrameReff(); elem.Show(); } var headerElements = this.GetDivsByName('topic_header'); for(var i = headerElements.length; i--;) { var elem = new HeaderObject(headerElements[i].id); if (!(elem) || elem==null){alert('error4');return;} this.m_aElements[elem.m_obj.id] = this.m_aElements[i+clipElements.length] = elem; //elem.initSize(); //elem.MoveTo(elem.m_posX, elem.m_posY); //elem.Show(); } var noteElements = this.GetDivsByName('topic_note'); for(var i = noteElements.length; i--;) { var elem = new NoteObject(noteElements[i].id); if (!(elem) || elem==null){alert('error4');return;} this.m_aElements[elem.m_expObj.id] = this.m_aElements[i+clipElements.length] = elem; } this.SetTool(g_GeneralTool); document.onmousemove = g_eventRouter.onDocumentMouseMove; document.onmouseup = g_eventRouter.onDocumentMouseUp; document.onmousedown = g_eventRouter.onDocumentMouseDown; document.onFrameMouseDown = g_eventRouter.onFrameMouseDown; document.onFrameMouseUp = g_eventRouter.onFrameMouseUp; document.onFrameMouseMove = g_eventRouter.onFrameMouseMove; document.onkeyup = g_eventRouter.onDocKeyUp; //init toolbar var txtBtn = document.getElementById("toolbar_button_text"); txtBtn.checked = false; sdToolbar = document.getElementById("SideToolbar"); this.InitRegularTT("ToolbarSaveButton",sdToolbar,"save changes made in this topic page", "tbsave"); this.InitRegularTT("ToolbarTextButton",sdToolbar,"Add Header. (click
this button, then click anywhere
on the topic page to
create a new header).", "tbheadertool"); this.InitRegularTT("ToolbarNoteButton",sdToolbar,"Add Note. (click
this button, then click anywhere
on the topic page to
create a new note).", "tbnotetool"); document.m_docWrapper =this; g_dc.setDirty(false); } this.setDirty = function(set) { if (this.m_isDirty == set) return; this.m_isDirty = set; SaveButtonNormal(); } this.isDirty = function() { return this.m_isDirty; } this.showElem = function(elem, bShow) { if (!(elem) || elem==null){alert('error7 '+elem);return;} if (elem.style && typeof (elem.style.display)!=dd_u) { elem.style.display = bShow?"block":"none"; } else if (elem.style && typeof (elem.style.visibility)!=dd_u) elem.style.visibility=bShow?"visible":"hidden"; else {alert('error8');return;} } this.GetEvent = function(e) { if ((typeof e)!=dd_u && e!=null) return e; else if (window.event!=null) return window.event; else return null; } this.GetEventCode = function(e) { var code=null; if (this.GetEvent(e).keyCode) code = this.GetEvent(e).keyCode; else if (this.GetEvent(e).which) code = this.GetEvent(e).which; return code; } this.GetEventTarget= function(e) { //if (typeof e == dd_u || e==null) {alert('error22'); return;} return (this.GetEvent(e).target || this.GetEvent(e).srcElement); } //relative to the doc 0,0 this.getEventMouseX = function(e) { //if (typeof e == dd_u || e==null) {alert('error22'); return;} var ev = this.GetEvent(e); if (!ev) return false; var evX = ((typeof ev.realX)!=dd_u && ev.realX!=null)?ev.realX:ev.clientX; return (evX + this.getScrollX()); } this.getEventMouseY = function(e) { //if (typeof e == dd_u || e==null) {alert('error22'); return;} var ev = this.GetEvent(e); if (!ev) return false; var evY = ((typeof ev.realY)!=dd_u && ev.realY!=null)?ev.realY:ev.clientY; return (evY + this.getScrollY()); } this.DeleteSelected = function() { if (this.m_SelectedObj) { this.m_SelectedObj.Delete(); } this.m_SelectedObj = null; } this.m_SelectedObj = null; } var g_dc = new DocObj();