From ace123a3374c41937d4483e85ebe27dcb3626dd3 Mon Sep 17 00:00:00 2001 From: Aryeh Gregor Date: Wed, 18 Oct 2006 06:53:19 +0000 Subject: [PATCH] * (bug 4525) Move section links down visually to same level as headings editsection links are now inside the heading elements). * Document structure changed, so some JavaScript/CSS may need tweaking (wikibits.js updated to reflect changes). * Parsertests updated, but don't seem to run, so someone please confirm that there are no (illusory) regressions. * $wgStyleVersion bumped. --- RELEASE-NOTES | 2 + includes/DefaultSettings.php | 2 +- includes/Linker.php | 6 +-- includes/Parser.php | 11 ++-- maintenance/parserTests.txt | 98 ++++++++++++++++++++--------------- skins/chick/main.css | 16 ++++-- skins/common/cologneblue.css | 3 +- skins/common/common.css | 30 +++++++++-- skins/common/commonPrint.css | 5 +- skins/common/common_rtl.css | 2 +- skins/common/wikibits.js | 67 +++++++++++++++++------- skins/common/wikistandard.css | 10 ++-- skins/monobook/main.css | 8 ++- skins/monobook/rtl.css | 2 +- skins/simple/main.css | 26 ++++++++++ 15 files changed, 200 insertions(+), 88 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index d800f7990a..327c101773 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -55,6 +55,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 7581) Update language name for cbk-zam * (bug 7444) Update namespace translations for Telugu (te), kept old values as alias for compatibility +* (bug 4525) Move section links down visually to same level as headings + editsection links are now inside the heading elements) == Languages updated == diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 50694b6421..97a8a2a816 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -1030,7 +1030,7 @@ $wgCacheEpoch = '20030516000000'; * to ensure that client-side caches don't keep obsolete copies of global * styles. */ -$wgStyleVersion = '14'; +$wgStyleVersion = '15'; # Server-side caching: diff --git a/includes/Linker.php b/includes/Linker.php index bc5fb64ba8..53deb39f2b 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -1046,11 +1046,11 @@ class Linker { $editurl = '§ion='.$section; $url = $this->makeKnownLinkObj( $title, wfMsg('editsection'), 'action=edit'.$editurl ); - return "
[".$url."]
"; + return "[".$url."]"; } - /** + /** * @param $title Title object. * @param $section Integer: section number. * @param $hint Link String: title, or default if omitted or empty @@ -1062,7 +1062,7 @@ class Linker { $hint = ( $hint=='' ) ? '' : ' title="' . wfMsgHtml( 'editsectionhint', htmlspecialchars( $hint ) ) . '"'; $url = $this->makeKnownLinkObj( $nt, wfMsg('editsection'), 'action=edit'.$editurl, '', '', '', $hint ); - return "
[".$url."]
"; + return "[".$url."]"; } /** diff --git a/includes/Parser.php b/includes/Parser.php index 845768048d..2d18684f3b 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -3516,6 +3516,9 @@ class Parser if( $enoughToc && ( !isset($wgMaxTocLevel) || $toclevel<$wgMaxTocLevel ) ) { $toc .= $sk->tocLine($anchor, $tocline, $numbering, $toclevel); } + # give headline the correct tag + @$head[$headlineCount] .= "editSectionLink($this->mTitle, $sectionCount+1, $headline_hint); } - - # give headline the correct tag - @$head[$headlineCount] .= "'; + // Yes, the headline logically goes before the edit section. Why isn't it there + // in source? Ask the CSS people. The float gets screwed up if you do that. + // This might be moved to before the editsection at some point so that it will + // display a bit more prettily without CSS, so please don't rely on the order. + $head[$headlineCount] .= ' '.$headline.''; $headlineCount++; if( !$istemplate ) diff --git a/maintenance/parserTests.txt b/maintenance/parserTests.txt index 7f3336e3f9..d06deaded7 100644 --- a/maintenance/parserTests.txt +++ b/maintenance/parserTests.txt @@ -3147,13 +3147,15 @@ More ===Smaller headline=== Blah blah !! result -

Headline 1

+

[edit] Headline 1

+

Some text

-

Headline 2

+

[edit] Headline 2

More

-

Smaller headline

+

[edit] Smaller headline

+

Blah blah

!! end @@ -3172,7 +3174,8 @@ title=[[Parser test script]] Some text ===Another headline=== !! result -

Contents

+

Contents

[hide]
+ + -
-

Headline 1

-

Subheadline 1

-
Skipping a level
-
Skipping a level
-

Headline 2

+
+

[edit] Headline 1

+

[edit] Subheadline 1

+ +
[edit] Skipping a level
+
[edit] Skipping a level
+

[edit] Headline 2

+

Some text

-

Another headline

- +

[edit] Another headline

!! end # perl -e 'print "="x$_," Level $_ heading","="x$_,"\n" for 1..10' @@ -3220,7 +3226,8 @@ Handling of sections up to level 6 and beyond ========= Level 9 Heading========= ========== Level 10 Heading========== !! result -

Contents

+

Contents

[hide]
+
-

Level 1 Heading

-

Level 2 Heading

-

Level 3 Heading

-

Level 4 Heading

-
Level 5 Heading
-
Level 6 Heading
-
= Level 7 Heading=
-
== Level 8 Heading==
-
=== Level 9 Heading===
-
==== Level 10 Heading====
+
+

[edit] Level 1 Heading

+

[edit] Level 2 Heading

+ +

[edit] Level 3 Heading

+

[edit] Level 4 Heading

+
[edit] Level 5 Heading
+
[edit] Level 6 Heading
+
[edit] = Level 7 Heading=
+
[edit] == Level 8 Heading==
+ +
[edit] === Level 9 Heading===
+
[edit] ==== Level 10 Heading====
!! end !! test @@ -3270,9 +3282,9 @@ title=[[Parser test script]] == Foo bar == == Foo bar == !! result -

Foo bar

-

Foo bar

+

[edit] Foo bar

+

[edit] Foo bar

!! end !! article @@ -3292,10 +3304,11 @@ __NOTOC__ {{sections}} ==Section 4== !! result -

Section 0

-

Section 1

-

Section 2

-

Section 4

+

[edit] Section 0

+ +

[edit] Section 1

+

[edit] Section 2

+

[edit] Section 4

!! end @@ -3306,9 +3319,9 @@ __NOEDITSECTION__ ==Section 1== ==Section 2== !! result -

Section 1

-

Section 2

+

Section 1

+

Section 2

!! end !! test @@ -3318,8 +3331,7 @@ title=[[Parser test script]] !! input ==Section with a [[Main Page|link]] in it== !! result -

Section with a link in it

- +

[edit] Section with a link in it

!! end @@ -4459,12 +4471,13 @@ Fuzz testing: Parser14 == onmouseover= == http://__TOC__ !! result -

onmouseover=

-http://

Contents

+

[edit] onmouseover=

+http://

Contents

[hide]
-
+
!! end @@ -4474,11 +4487,10 @@ Fuzz testing: Parser14-table ==a== {| STYLE=__TOC__ !! result -

a

- - -
- +

[edit] a

+ + +
!! end # Known to produce bogus xml (extra ) @@ -5861,4 +5873,4 @@ more tables math character entities and much more -Try for 100% code coverage +Try for 100% code coverage \ No newline at end of file diff --git a/skins/chick/main.css b/skins/chick/main.css index 00cab8113a..6b52f4a2ed 100644 --- a/skins/chick/main.css +++ b/skins/chick/main.css @@ -50,20 +50,26 @@ h1, h2, h3, h4, h5, h6 { padding-bottom: 0.17em; border-bottom: 1px solid #aaaaaa; } +.editsection { + font-weight: normal; + float: right; + margin-left: 5px; +} h1 { font-size: 188%; } +h1 .editsection { font-size: 53.2%; } h2 { font-size: 150%; } +h2 .editsection { font-size: 66.7%; } h3, h4, h5, h6 { border-bottom: none; font-weight: bold; } h3 { font-size: 132%; } +h3 .editsection { font-size: 75.8%; } h4 { font-size: 116%; } +h4 .editsection { font-size: 86.2%; } h5 { font-size: 100%; } h6 { font-size: 80%; } -.editsection { - float: right; - margin-left: 5px; -} +h6 .editsection { font-size: 125%; } ul { line-height: 1.5em; @@ -482,4 +488,4 @@ div.gallerytext { #jump-to-nav { display: none; -} \ No newline at end of file +} diff --git a/skins/common/cologneblue.css b/skins/common/cologneblue.css index 0c0b21de05..c71eb2daf6 100644 --- a/skins/common/cologneblue.css +++ b/skins/common/cologneblue.css @@ -78,8 +78,9 @@ td.bottom { h1 { color: #666666; font-family: Verdana, Arial, sans-serif; - font-size: 18pt; font-weight: bold; line-height: 21pt; + font-size: 180%; line-height: 21pt; } +h1 .editsection { font-size: 55.6%; } h1.pagetitle { padding-bottom: 0; margin-bottom: 0; } #article p.subtitle { color: #666666; font-size: 11pt; font-weight: bold; diff --git a/skins/common/common.css b/skins/common/common.css index 64dbff7220..2fa3ce9e1e 100644 --- a/skins/common/common.css +++ b/skins/common/common.css @@ -2,6 +2,31 @@ * common.css * This file contains CSS settings common to Wikistandard, Nostalgia and CologneBlue */ + +/* For clarity, explicitly state some recommendations from to make sure the editsection links scale right */ + +h1 { font-size: 2em; } +h2 { font-size: 1.5em; } +h3 { font-size: 1.17em; } +h5 { font-size: .83em; } +h6 { font-size: .75em; } +h1, h2, h3, h4, h5, h6 { font-weight: bolder } + +/* Now the custom parts */ + +/* Make edit sections (which are inside h# tags) normal-sized */ +.editsection { + font-weight: normal; + float: right; + margin-left: 5px; +} +h1 .editsection { font-size: 50% } +h2 .editsection { font-size: 66.7% } +h3 .editsection { font-size: 85.5% } +h5 .editsection { font-size: 120% } +h6 .editsection { font-size: 133% } + #footer { clear: both } /* images */ div.floatright { float: right; clear: right; margin: 0 0 1em 1em; } @@ -315,11 +340,6 @@ li span.deleted { font-style: italic; } -div.editsection { - float: right; - margin-left: 5px; -} - /* Classes for EXIF data display */ table.mw_metadata { margin-left: 0.5em; diff --git a/skins/common/commonPrint.css b/skins/common/commonPrint.css index 1bda4fd1f1..314ff5543e 100644 --- a/skins/common/commonPrint.css +++ b/skins/common/commonPrint.css @@ -132,7 +132,10 @@ ul { h1, h2, h3, h4, h5, h6 { - font-weight: bold; + font-weight: bold; +} +.editsection { + font-weight: normal; } p, .documentDescription { diff --git a/skins/common/common_rtl.css b/skins/common/common_rtl.css index 651c4dc01e..54186bb882 100644 --- a/skins/common/common_rtl.css +++ b/skins/common/common_rtl.css @@ -16,7 +16,7 @@ fieldset.operaprefsection { margin-right: 1.4em; margin-left: 0.4em; } -div.editsection { +.editsection { float: left; margin-right: 5px; } diff --git a/skins/common/wikibits.js b/skins/common/wikibits.js index 3a8fd6c69c..7846fff979 100644 --- a/skins/common/wikibits.js +++ b/skins/common/wikibits.js @@ -503,9 +503,9 @@ function akeytt() { function setupRightClickEdit() { if (document.getElementsByTagName) { - var divs = document.getElementsByTagName('div'); - for (var i = 0; i < divs.length; i++) { - var el = divs[i]; + var spans = document.getElementsByTagName('span'); + for (var i = 0; i < spans.length; i++) { + var el = spans[i]; if(el.className == 'editsection') { addRightClickEditHandler(el); } @@ -518,27 +518,56 @@ function addRightClickEditHandler(el) { var link = el.childNodes[i]; if (link.nodeType == 1 && link.nodeName.toLowerCase() == 'a') { var editHref = link.getAttribute('href'); - - // find the following a - var next = el.nextSibling; - while (next.nodeType != 1) - next = next.nextSibling; - - // find the following header - next = next.nextSibling; - while (next.nodeType != 1) - next = next.nextSibling; - - if (next && next.nodeType == 1 && - next.nodeName.match(/^[Hh][1-6]$/)) { - next.oncontextmenu = function() { - document.location = editHref; - return false; + // find the enclosing (parent) header + var prev = el.parentNode; + if (prev && prev.nodeType == 1 && + prev.nodeName.match(/^[Hh][1-6]$/)) { + prev.oncontextmenu = function(e) { + if (!e) var e = window.event; + // e is now the event in all browsers + if (e.target) var targ = e.target; + else if (e.srcElement) var targ = e.srcElement; + if (targ.nodeType == 3) // defeat Safari bug + targ = targ.parentNode; + // targ is now the target element + + // We don't want to deprive the noble reader of a context menu + // for the section edit link, do we? (Might want to extend this + // to all 's?) + if (targ.nodeName.toLowerCase() != 'a' + || targ.parentNode.className != 'editsection') { + document.location = editHref; + return false; + } } } } } } +/* +function addRightClickEditHandler(el) { + // find the enclosing (parent) header + var par = el.parentNode; + if (par && par.nodeType == 1 && par.nodeName.match(/^[Hh][1-6]$/)) { + par.oncontextmenu = function(e) { + if (!e) var e = window.event; + // e is now the event in all browsers + if (e.target) targ = e.target; + else if (e.srcElement) targ = e.srcElement; + if (targ.nodeType == 3) // defeat Safari bug + targ = targ.parentNode; + // targ is now the target element + // We don't want to deprive the noble reader of a context menu + // for the section edit link, do we? (Might want to extend this + // to all 's.)links + if (targ.className != 'editsection') { + document.location = editHref; + return false; + } + } + } +} +*/ function setupCheckboxShiftClick() { if (document.getElementsByTagName) { diff --git a/skins/common/wikistandard.css b/skins/common/wikistandard.css index dd39ebaed7..2e18a8964b 100644 --- a/skins/common/wikistandard.css +++ b/skins/common/wikistandard.css @@ -29,16 +29,18 @@ textarea { overflow: auto; } h1.pagetitle { padding-top: 0; margin-top: 0; padding-bottom: 0; margin-bottom: 0; font-size:150%; } +h1.pagetitle .editsection { font-size: 66.7%; } h2 { font-size: 120%; } +h2 .editsection { font-size: 83.3%; } h2, h3, h4, h5, h6 { margin-bottom: 0;} h3 { font-size: 106.25%; } +h3 .editsection { font-size: 94.1%; } h4 { font-size: 103.125%; } +h4 .editsection { font-size: 97.0%; } h5 { font-size: 100%; } +h5 .editsection { font-size: 100%; } h6 { font-size: 95%; } -.editsection { - float: right; - margin-left: 5px; -} +h6 .editsection { font-size: 105.3%; } hr.sep { color:gray;height:1px;background-color:gray;} p.subpages { font-size:small;} p.subtitle { padding-top: 0; margin-top: 0;} diff --git a/skins/monobook/main.css b/skins/monobook/main.css index 6b57ed9e6b..78c9a4a4ca 100644 --- a/skins/monobook/main.css +++ b/skins/monobook/main.css @@ -119,17 +119,23 @@ h1, h2, h3, h4, h5, h6 { border-bottom: 1px solid #aaa; } h1 { font-size: 188%; } +h1 .editsection { font-size: 53%; } h2 { font-size: 150%; } +h2 .editsection { font-size: 67%; } h3, h4, h5, h6 { border-bottom: none; font-weight: bold; } h3 { font-size: 132%; } +h3 .editsection { font-size: 76%; font-weight: normal; } h4 { font-size: 116%; } +h4 .editsection { font-size: 86%; font-weight: normal; } h5 { font-size: 100%; } +h5 .editsection { font-weight: normal; } h6 { font-size: 80%; } +h6 .editsection { font-size: 125%; font-weight: normal; } -div.editsection { +.editsection { float: right; margin-left: 5px; } diff --git a/skins/monobook/rtl.css b/skins/monobook/rtl.css index bf88e4349d..f4a67683ca 100644 --- a/skins/monobook/rtl.css +++ b/skins/monobook/rtl.css @@ -41,7 +41,7 @@ html>body .portlet { float: right; clear: right; } -div.editsection { +.editsection { float: left; margin-right: 5px; } diff --git a/skins/simple/main.css b/skins/simple/main.css index e389dfa87c..079cb45c8c 100644 --- a/skins/simple/main.css +++ b/skins/simple/main.css @@ -1,3 +1,29 @@ +/* For clarity, explicitly state some recommendations from to make sure the editsection links scale right */ + +h1 { font-size: 2em; } +h2 { font-size: 1.5em; } +h3 { font-size: 1.17em; } +h5 { font-size: .83em; } +h6 { font-size: .75em; } +h1, h2, h3, h4, h5, h6 { font-weight: bolder } + +/* Now the custom parts */ + +/* Make edit sections (which are inside h# tags) normal-sized + and otherwise format */ +.editsection { + font-weight: normal; + float: right; + margin-left: 5px; +} +h1 .editsection { font-size: 50% } +h2 .editsection { font-size: 66.7% } +h3 .editsection { font-size: 85.5% } +h5 .editsection { font-size: 120% } +h6 .editsection { font-size: 133% } + + #toolbar { display: none; } -- 2.20.1