From: <par...@us...> - 2010-02-12 17:56:54
|
Update of /cvsroot/phpicalendar/phpicalendar/nicetitle In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv10002/nicetitle Modified Files: nicetitle.js Log Message: Remove browser detection and cleanup the NiceTitle JavaScript Index: nicetitle.js =================================================================== RCS file: /cvsroot/phpicalendar/phpicalendar/nicetitle/nicetitle.js,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** nicetitle.js 7 Jul 2009 15:22:21 -0000 1.2 --- nicetitle.js 12 Feb 2010 17:56:44 -0000 1.3 *************** *** 31,35 **** var XHTMLNS = "http://www.w3.org/1999/xhtml"; var CURRENT_NICE_TITLE; - var browser = new Browser(); function makeNiceTitles() { --- 31,34 ---- *************** *** 109,113 **** if (el.length > l) l = el.length; }); ! return l; } --- 108,112 ---- if (el.length > l) l = el.length; }); ! return l; } *************** *** 116,124 **** if (!CURRENT_NICE_TITLE) return; var d = CURRENT_NICE_TITLE; ! if (window.event && window.event.srcElement) { ! var el = window.event.srcElement ! } else if (e && e.currentTarget) { var el = e.currentTarget } // Browser size --- 115,124 ---- if (!CURRENT_NICE_TITLE) return; var d = CURRENT_NICE_TITLE; ! if (e && e.currentTarget && (typeof(e.currentTarget) != "undefined")) { var el = e.currentTarget } + else if (window.event && window.event.srcElement) { + var el = window.event.srcElement + } // Browser size *************** *** 151,155 **** var sx = 0; var sy = 0; ! // Title element position within document var elPos = findPosition(el); --- 151,155 ---- var sx = 0; var sy = 0; ! // Title element position within document var elPos = findPosition(el); *************** *** 173,177 **** SNAP_BOTTOM = true; } ! // Ensure mouse can never enter the title in the lower right corner of the window if (FOLLOW_MOUSE && SNAP_RIGHT && SNAP_BOTTOM) { --- 173,177 ---- SNAP_BOTTOM = true; } ! // Ensure mouse can never enter the title in the lower right corner of the window if (FOLLOW_MOUSE && SNAP_RIGHT && SNAP_BOTTOM) { *************** *** 182,187 **** } ! d.style.left = x + 'px'; ! d.style.top = y + 'px'; } --- 182,187 ---- } ! d.style.left = x + "px"; ! d.style.top = y + "px"; } *************** *** 189,216 **** if (CURRENT_NICE_TITLE) hideNiceTitle(CURRENT_NICE_TITLE); if (!document.getElementsByTagName) return; ! if (window.event && window.event.srcElement) { ! var lnk = window.event.srcElement ! } else if (e && e.currentTarget) { var lnk = e.currentTarget } if (!lnk) return; ! if (lnk.nodeName.toUpperCase() != 'A') { // lnk is not actually the link -- ascend parents until we hit a link ! lnk = getParent(lnk,"A"); } if (!lnk) return; var nicetitle = lnk.getAttribute("nicetitle"); ! ! var d = document.createElementNS(XHTMLNS,"div"); ! if (browser.isIE) { ! /* ! * IE likes to display the element as soon as it is created. ! * So let's hide it now and show it after it's been appended to the body ! */ ! d.style.display = 'none'; ! } d.className = "nicetitle"; ! var nicetitle_parts = nicetitle.split('\n'); nicetitle_parts.forEach(function(textpart) { var pat = document.createElementNS(XHTMLNS, "p"); --- 189,212 ---- if (CURRENT_NICE_TITLE) hideNiceTitle(CURRENT_NICE_TITLE); if (!document.getElementsByTagName) return; ! if (e && e.currentTarget && (typeof(e.currentTarget) != "undefined")) { var lnk = e.currentTarget } + else if (window.event && window.event.srcElement) { + var lnk = window.event.srcElement + } + if (!lnk) return; ! if (lnk.nodeName.toUpperCase() != "A") { // lnk is not actually the link -- ascend parents until we hit a link ! lnk = getParent(lnk, "A"); } if (!lnk) return; var nicetitle = lnk.getAttribute("nicetitle"); ! ! var d = document.createElementNS(XHTMLNS, "div"); ! d.style.display = "none"; d.className = "nicetitle"; ! var nicetitle_parts = nicetitle.split("\n"); nicetitle_parts.forEach(function(textpart) { var pat = document.createElementNS(XHTMLNS, "p"); *************** *** 230,251 **** d.appendChild(pad); } ! var l = get_longest(nicetitle_parts); ! // Approximate pixel width of longest line in the title var w = ((lnk.href && SHOW_LINKS) ? lnk.href.length : 0) * 6; var t = (l ? l : 0) * 8; ! // Use the greatest width: title text, link URL, or MIN_WIDTH. Limited to MAX_WIDTH w = ((w > MIN_WIDTH) ? w : MIN_WIDTH); w = ((w > t) ? w : t); w = ((w > MAX_WIDTH) ? MAX_WIDTH : w); ! d.style.width = w + 'px'; document.getElementsByTagName("body")[0].appendChild(d); ! if (browser.isIE) { ! d.style.display = 'block'; ! } ! CURRENT_NICE_TITLE = d; moveNiceTitle(e); --- 226,245 ---- d.appendChild(pad); } ! var l = get_longest(nicetitle_parts); ! // Approximate pixel width of longest line in the title var w = ((lnk.href && SHOW_LINKS) ? lnk.href.length : 0) * 6; var t = (l ? l : 0) * 8; ! // Use the greatest width: title text, link URL, or MIN_WIDTH. Limited to MAX_WIDTH w = ((w > MIN_WIDTH) ? w : MIN_WIDTH); w = ((w > t) ? w : t); w = ((w > MAX_WIDTH) ? MAX_WIDTH : w); ! d.style.width = w + "px"; document.getElementsByTagName("body")[0].appendChild(d); ! d.style.display = "block"; ! CURRENT_NICE_TITLE = d; moveNiceTitle(e); *************** *** 267,271 **** return true; } else if (obj.attachEvent) { ! return obj.attachEvent("on"+evType, fn); } else { return false; --- 261,265 ---- return true; } else if (obj.attachEvent) { ! return obj.attachEvent("on" + evType, fn); } else { return false; *************** *** 275,279 **** function getParent(el, pTagName) { if (el == null) return null; ! else if (el.nodeType == 1 && el.tagName.toLowerCase() == pTagName.toLowerCase()) // Gecko bug, supposed to be uppercase return el; else --- 269,273 ---- function getParent(el, pTagName) { if (el == null) return null; ! else if (el.nodeType == 1 && el.tagName.toLowerCase() == pTagName.toLowerCase()) return el; else *************** *** 281,354 **** } ! function getMousePosition(event) { ! if (browser.isIE) { ! var x = window.event.clientX + document.documentElement.scrollLeft;// + document.body.scrollLeft; ! var y = window.event.clientY + document.documentElement.scrollTop;// + document.body.scrollTop; } ! if (browser.isNS) { ! var x = event.clientX + window.scrollX;// window.pageXOffset; ! var y = event.clientY + window.scrollY;// window.pageYOffset; } ! return [x,y]; } function getScrollPosition() { ! if (browser.isIE) { ! var x = document.documentElement.scrollLeft;// + document.body.scrollLeft; ! var y = document.documentElement.scrollTop;// + document.body.scrollTop; } ! if (browser.isNS) { ! var x = window.scrollX;// window.pageXOffset; ! var y = window.scrollY;// window.pageYOffset; } ! return [x,y]; } function getWindowSize() { ! if (browser.isIE) { ! var x = document.documentElement.clientWidth; ! var y = document.documentElement.clientHeight; } ! if (browser.isNS) { ! var x = window.innerWidth; ! var y = window.innerHeight; } - return [x,y]; - } - - // Determine browser and version. - - function Browser() { - // blah, browser detect, but mouse-position stuff doesn't work any other way - var ua, s, i; - - this.isIE = false; - this.isNS = false; - this.version = null; - - ua = navigator.userAgent; - - s = "MSIE"; - if ((i = ua.indexOf(s)) >= 0) { - this.isIE = true; - this.version = parseFloat(ua.substr(i + s.length)); - return; - } - - s = "Netscape6/"; - if ((i = ua.indexOf(s)) >= 0) { - this.isNS = true; - this.version = parseFloat(ua.substr(i + s.length)); - return; - } ! // Treat any other "Gecko" browser as NS 6.1. ! ! s = "Gecko"; ! if ((i = ua.indexOf(s)) >= 0) { ! this.isNS = true; ! this.version = 6.1; ! return; ! } } --- 275,326 ---- } ! function getMousePosition(e) { ! var x = 0; ! var y = 0; ! ! if (e && (typeof(window.scrollX) != "undefined")) { ! x = e.clientX + window.scrollX; ! y = e.clientY + window.scrollY; } ! else if (window.event) { ! x = window.event.clientX + document.documentElement.scrollLeft; ! y = window.event.clientY + document.documentElement.scrollTop; } ! ! return [x, y]; } function getScrollPosition() { ! var x = 0; ! var y = 0; ! ! if (window.scrollX && window.scrollY) { ! x = window.scrollX; ! y = window.scrollY; } ! else if (document.documentElement.scrollLeft && ! document.documentElement.scrollTop) { ! x = document.documentElement.scrollLeft; ! y = document.documentElement.scrollTop; } ! ! return [x, y]; } function getWindowSize() { ! var x = 0; ! var y = 0; ! ! if (window.innerWidth && window.innerHeight) { ! x = window.innerWidth; ! y = window.innerHeight; } ! else if (document.documentElement.clientWidth && ! document.documentElement.clientHeight) { ! x = document.documentElement.clientWidth; ! y = document.documentElement.clientHeight; } ! return [x, y]; } |