MediaWiki:Common.js/IEFixes.js

De Clube Atletico Mineiro - Enciclopedia Galo Digital
Ir para navegação Ir para pesquisar

Nota: Após publicar, você pode ter que limpar o "cache" do seu navegador para ver as alterações.

  • Firefox / Safari: Pressione Shift enquanto clica Recarregar, ou pressione Ctrl-F5 ou Ctrl-R (⌘-R no Mac)
  • Google Chrome: Pressione Ctrl-Shift-R (⌘-Shift-R no Mac)
  • Internet Explorer/Edge: PressioneCtrl enquanto clica Recarregar, ou Pressione Ctrl-F5
  • Opera: Pressione Ctrl-F5.
/** 
 * Correctly handle PNG transparency in Internet Explorer 6.
 * http://homepage.ntlworld.com/bobosola. Updated 18-Jan-2006.
 *  
 * Adapted for Wikipedia by Remember_the_dot and Edokter.
 *  
 * http://homepage.ntlworld.com/bobosola/pnginfo.htm states "This page contains more information for
 * the curious or those who wish to amend the script for special needs", which I take as permission to
 * modify or adapt this script freely. I release my changes into the public domain.
 */  
 
if (navigator.appVersion.substr(22, 1) == "6")
{
 
    function PngFix()
    {
        try
        {
            if (!document.body.filters)
            {
                window.PngFixDisabled = true
            }
        }
        catch (e)
        {
            window.PngFixDisabled = true
        }
        if (!window.PngFixDisabled)
        {
            var documentImages = document.images
            var documentCreateElement = document.createElement
            var funcEncodeURI = encodeURI
 
            for (var i = 0; i < documentImages.length;)
            {
                var img = documentImages[i]
                var imgSrc = img.src
 
                if (imgSrc.substr(imgSrc.length - 3).toLowerCase() == "png" && img.complete && !img.onclick)
                {
                    if (img.useMap)
                    {
                        img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + funcEncodeURI(imgSrc) + "')"
                        img.src = "http://upload.wikimedia.org/wikipedia/commons/c/ce/Transparent.gif"
                        i++
                    }
                    else
                    {
                        var outerSpan = documentCreateElement("span")
                        var innerSpan = documentCreateElement("span")
                        var outerSpanStyle = outerSpan.style
                        var innerSpanStyle = innerSpan.style
                        var imgCurrentStyle = img.currentStyle
 
                        outerSpan.id = img.id
                        outerSpan.className = img.className
                        outerSpanStyle.backgroundImage = imgCurrentStyle.backgroundImage
                        outerSpanStyle.borderWidth = imgCurrentStyle.borderWidth
                        outerSpanStyle.borderStyle = imgCurrentStyle.borderStyle
                        outerSpanStyle.borderColor = imgCurrentStyle.borderColor
                        outerSpanStyle.display = "inline-block"
                        outerSpanStyle.fontSize = "0"
                        outerSpanStyle.verticalAlign = "middle"
                        if (img.parentElement.href) outerSpanStyle.cursor = "hand"
 
                        innerSpanStyle.width = "1px"
                        innerSpanStyle.height = "1px"
                        innerSpanStyle.display = "inline-block"
                        innerSpanStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + funcEncodeURI(imgSrc) + "')"
 
                        outerSpan.appendChild(innerSpan)
                        img.parentNode.replaceChild(outerSpan, img)
                    }
                }
                else
                {
                    i++
                }
            }
        }
    }
 
    window.attachEvent("onload", PngFix)
}
 
/** Internet Explorer bug fix **************************************************
 *
 *  Description: Fixes IE horizontal scrollbar bug
 *  Maintainers: [[User:Tom-]]?
 */
 
    var oldWidth;
    var docEl = document.documentElement;
 
    function fixIEScroll()
    {
        if (!oldWidth || docEl.clientWidth > oldWidth)
            doFixIEScroll();
        else
            setTimeout(doFixIEScroll, 1);
 
        oldWidth = docEl.clientWidth;
    }
 
    function doFixIEScroll() {
        docEl.style.overflowX = (docEl.scrollWidth - docEl.clientWidth < 4) ? "hidden" : "";
    }
 
    document.attachEvent("onreadystatechange", fixIEScroll);
    document.attachEvent("onresize", fixIEScroll);
 
 
    /**
     * Remove need for CSS hacks regarding MSIE and IPA.
     */
 
    if (document.createStyleSheet) {
        document.createStyleSheet().addRule('.IPA', 'font-family: "Doulos SIL", "Charis SIL", Gentium, "DejaVu Sans", Code2000, "TITUS Cyberbit Basic", "Arial Unicode MS", "Lucida Sans Unicode", "Chrysanthi Unicode";');
    }