Jump to content

MediaWiki talk:Common.js/Archive 11

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Shadowbot3 (talk | contribs) at 00:03, 7 November 2007 (Automated archival of 1 sections from MediaWiki talk:Common.js). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Printable version messed up

The printable versions of pages are messed up for anonymous users. —Ruud 19:25, 30 September 2007 (UTC)[reply]

Can you be any more specific? What browser are you using? —Remember the dot (talk) 02:45, 1 October 2007 (UTC)[reply]
Something about donating money and 10 thing I'm not supposed to know about Wikipedia. 83.83.37.71 03:19, 1 October 2007 (UTC)[reply]
What browser are you using? —Remember the dot (talk) 04:09, 1 October 2007 (UTC)[reply]
FF 2.0.0.6 —Ruud 13:47, 1 October 2007 (UTC)[reply]
Are you saying that you don't want those messages to print? —Remember the dot (talk) 16:12, 1 October 2007 (UTC)[reply]
They probably shouldn't thow up on the print version. They aren't useful on paper, and the footer should cover the donation notice stuff. --Gmaxwell 17:45, 1 October 2007 (UTC)[reply]

Problem with importStylesheet in IE?

Is anyone else having an problem with importStylesheet in Internet Explorer? I am using Internet Explorer 6, and it's giving me a JS error. The error information I get from IE is the following:

  • Line: 58
  • Char: 6
  • Error: Unexpected call to method or property access.
  • Code: 0
  • URL: (Whatever the address in your browser is)

To recreate the error, open IE and edit your skin css file javascript file (fixed by Alex Smotrov). At the bottom of the file put the line importStylesheet( "User:Shardsofmetal/monobook.css" );, then preview the page. When it loads the next page, see if there is an exclaimation icon on the left side of the status bar. If so, double-click it. I had 2 errors, but I know the one related to this is the one I posted. My guess is also that the line number might differ depending on what other javascript has been loaded. I normally use Firefox, I actually only used IE to test this function at my local wiki, to load a custom skin for IE users (since the normal custom skin doesn't look good in IE). However, if I can't get the css file to load, then it was a waste of my time. I don't know javascript, only the basics I've figured out from looking at code, so I can't figure out what the problem is, but I assume that someone who knows javascript can fix the problem. Also, shouldn't the line + '&action=raw&ctype=text/css";' contain a semicolon at the end, to end the declaration of the variable? Anyway, I hope someone can take a look at this.  Shardsofmetal  03:04, 3 October 2007 (UTC)[reply]

You need to specify a fully qualified URL, not a wikilink as you are trying to do. Try this instead:
importStylesheet("http://en.wikipedia.org/w/index.php?title=User:Shardsofmetal/monobook.css&action=raw&ctype=text/css");
EdokterTalk 11:54, 3 October 2007 (UTC)[reply]
No you don't. The function begins:
 function importStylesheet( page ) {
     var sheet = '@import "'
               + wgScriptPath
               + '/index.php?title='
               + encodeURIComponent( page.replace( / /g, '_' ) )
               + '&action=raw&ctype=text/css";'
Therefore, it requests the url /w/index.php?title=THE_PAGE_YOU_REQUESTED&action=raw&ctype=text/css. The function works fine in Firefox, and it looks fine to me, so I don't know why it doesn't work in IE.  Shardsofmetal  12:55, 3 October 2007 (UTC)[reply]
Right, I missed that. Anyway, I tried the test above, and I didn't get the error. EdokterTalk 13:31, 3 October 2007 (UTC)[reply]

Yes, it's a known problem, importStylesheet doesn't work in IE. When I looked into it some time ago, looks like in IE you're not supposed to add a text node as a child of a style element but instead use styleElem.styleSheet.cssText. But even after that it seems IE (at least IE6) simply doesn't like @import in the added text. On the other hand, something like this below seems to work in IE6/Firefox 1.5/Opera 9 ∴ Alex Smotrov 19:20, 3 October 2007 (UTC)[reply]

function importStylesheet(page) {
 var styleEl = document.createElement('link')
 styleEl.type = 'text/css'
 styleEl.rel = 'stylesheet'
 styleEl.href = wgScript + '?title=' 
  + encodeURIComponent(page.replace(/ /g, '_')) + '&action=raw&ctype=text/css'
 document.getElementsByTagName('head')[0].appendChild(styleEl)
}

PNG transparency fix "V1.1"

I have updated the PngFix script. While neither Remember the dot and I could make the "fast" code to work, (see here we did come up with a way to increase the speed by not turning images without border to spans. Further improvements are:

  1. The script no longer depends on the .thumbborder (or any other) class.
  2. Support all PNG images, including imagemaps.

I'll post a message on the Village Pump to be on the lookup for bugs. Please report any problems there. EdokterTalk 09:03, 5 October 2007 (UTC)[reply]

Well, that's not entirely true. Only the CSS border information is copied out of the .thumbborder class, so if .thumbborder is limited to img elements in your skin and there is any other CSS in there, that CSS is discarded. This is what happens in the default skin, only there isn't any other CSS in ther at present. —Remember the dot (talk) 16:59, 5 October 2007 (UTC)[reply]
What I meant was is that the code no longer has to rely on seperately decraled classes like .thumbborder. If need be, other CSS properties can be added to the code. But I don't expect we'll ever need to (maaaybe margin). Images hardly have any other properties then border anyway, but anyone is welcome to prove me wrong... EdokterTalk 19:59, 5 October 2007 (UTC)[reply]