From a21383af58203bf0e6dc36a07ea78fae0b58c1ef Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Mon, 12 Nov 2012 20:57:27 +0100 Subject: crossbrowser fixes for quicksearch shortening FS#2660 fixes the problem with missing innerText in Firefox (and other browsers) and corrects shortening in regard to paddings and the use of the text-overflow attribute --- lib/scripts/qsearch.js | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'lib/scripts/qsearch.js') diff --git a/lib/scripts/qsearch.js b/lib/scripts/qsearch.js index a309f9e29..c3d0d94fb 100644 --- a/lib/scripts/qsearch.js +++ b/lib/scripts/qsearch.js @@ -92,12 +92,18 @@ var dw_qsearch = { .show() .css('white-space', 'nowrap'); - // shorten namespaces if too long - max = dw_qsearch.$outObj[0].clientWidth; + // disable overflow during shortening + dw_qsearch.$outObj.find('li').css('overflow', 'visible'); + $links = dw_qsearch.$outObj.find('a'); - too_big = (document.documentElement.dir === 'rtl') - ? function (l) { return l.offsetLeft < 0; } - : function (l) { return l.offsetWidth + l.offsetLeft > max; }; + max = dw_qsearch.$outObj[0].clientWidth; // maximum width allowed (but take away paddings below) + if(document.documentElement.dir === 'rtl'){ + max -= parseInt(dw_qsearch.$outObj.css('padding-left')); + too_big = function (l) { return l.offsetLeft < 0; }; + }else{ + max -= parseInt(dw_qsearch.$outObj.css('padding-right')); + too_big = function (l) { return l.offsetWidth + l.offsetLeft > max; }; + } $links.each(function () { var start, length, replace, nsL, nsR, eli, runaway; @@ -106,6 +112,12 @@ var dw_qsearch = { return; } + // make IE's innerText available to W3C conform browsers + if(this.textContent){ + this.__defineGetter__('innerText', function(){ return this.textContent }); + this.__defineSetter__('innerText', function(val){ this.textContent = val }); + } + nsL = this.innerText.indexOf('('); nsR = this.innerText.indexOf(')'); eli = 0; @@ -138,6 +150,9 @@ var dw_qsearch = { nsR = this.innerText.indexOf(')'); } }); + + // reenable overflow + dw_qsearch.$outObj.find('li').css('overflow', 'hidden').css('text-overflow','ellipsis'); } }; -- cgit v1.2.3