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, 16 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]

IPA style for IE

{{editprotected}}

The current IPA hack doesn't work in IE 7 (see Template talk:IPA#Solution for IE6/7 problem for details). The following code will load the required CSS rule form script and thus avoid ugly CSS hacks:

if(navigator.userAgent.indexOf("MSIE") != -1 && 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";');
}

This also makes the .IPA style in Common.css unneccessary, after it has worked it's way through the cache. (Excpet for IE users with and javascript turned off, but they will have so many troubles they won't even notice the IPA scripts not working :-) --Tgr 21:24, 4 October 2007 (UTC)[reply]

Are you sure this cannot be done in common.css using condtional (#.IPA) declarations? EdokterTalk 10:14, 6 October 2007 (UTC)[reply]
You mean, some sort of CSS hack? That's the way it has been until now (with the star html hack), but most hacks don't work with IE7. The only one I know to work (lang attribute hack) is semantically incorrect, and the others didn't like that. I have thought of conditional comments, too, but most skins don't have those. --Tgr 16:40, 6 October 2007 (UTC)[reply]
'#' isn't really a 'hack'; as far as I know, # makes CSS rules IE6(7?) only. Don't know if IE7 has it's own conditional character. Forget my comment, I'm still not versed enough in CSS to know what I'm talking about. EdokterTalk 17:39, 6 October 2007 (UTC)[reply]
Done. Cheers. --MZMcBride 19:17, 9 October 2007 (UTC)[reply]

Function to invert checkboxes

Latest addition. Come on ...

  1. Consensus?
  2. Shift-clicking (see MediaWiki:Watchlistedit-normal-explain) is not good enough?
  3. MediaWiki:Sysop.js ?

Alex Smotrov 21:18, 12 October 2007 (UTC)[reply]

This is better than shift-clicking as it makes restoring all but a couple revisions easier, as for MediaWiki:Sysop.js, I personally was unaware of it. Consensus? This does not really require community consensus as it only affects administrators. GDonato (talk) 21:23, 12 October 2007 (UTC)[reply]
The size of the file affects everybody. The unnecessary changes to the file affect everybody. By "consensus" I also mean "just let other users know first", and then maybe somebody will propose a better way. P.S. Clicking the first checkbox and then shift-clicking the last seem as easy to me ∴ Alex Smotrov 21:33, 12 October 2007 (UTC)[reply]
Downloading the code isn't too much of a problem, since I cache it. However, I don't exactly appreciate caching code that is completely inapplicable to me. Having code that is applicable specifically to me is, in fact, what user scripts are for :) GracenotesT § 21:57, 12 October 2007 (UTC)[reply]
Write the (import) code and make a list of the sections that need to be moved and I'd be happy to oblige. --MZMcBride 21:59, 12 October 2007 (UTC)[reply]
Look at the diff at the top of this section and simply move that into MediaWiki:Sysop.js. Although I expected the admin who did the change to correct it. Or maybe I expected him to agree that shift-clicking (it's even mentioned in MediaWiki:Undeleteextrahelp) can achieve the same thing without the extra code ∴ Alex Smotrov 05:03, 13 October 2007 (UTC)[reply]
It works fine, is useful/easier and we use it at de:wp, too. But if there is no consensus I'll remove it. Regards, —DerHexer (Talk) 09:06, 13 October 2007 (UTC)[reply]
Sysop.js is already imported, so moving it to Sysop.js should be no problem. EdokterTalk 10:13, 13 October 2007 (UTC)[reply]
Moved. GDonato (talk) 15:21, 13 October 2007 (UTC)[reply]
Thanks! —DerHexer (Talk) 09:58, 14 October 2007 (UTC)[reply]