MediaWiki talk:Common.js/Archive 4: Difference between revisions
Content deleted Content added
Shadowbot3 (talk | contribs) m Automated archival of 2 sections from MediaWiki talk:Common.js |
m Andrybak moved page MediaWiki talk:Common.js/Archive Apr 2007 to MediaWiki talk:Common.js/Archive 4: Template talk:Automatic archive navigator#Later archives are not linked |
||
(8 intermediate revisions by 6 users not shown) | |||
Line 1:
<span id="63298023827" ></span>
==vandal problem==
Line 13 ⟶ 12:
:Any changes we could make here would be fairly easy for the vandal to work around. It would probably be more effective to get the anti-vandalism bots to automatically revert such edits and report the users making them. It's not as if detecting them should be hard, given that we have the source for the script that makes them. —[[User:Ilmari Karonen|Ilmari Karonen]] <small>([[User talk:Ilmari Karonen|talk]])</small> 00:23, 1 March 2007 (UTC)
<span id="63298253943" ></span>
== Access key for project page: why change it? ==
Line 21 ⟶ 20:
::Thanks Ruud! For the explanation and the fix. [[User:Grouse|Grouse]] 16:19, 3 March 2007 (UTC)
<span id="63298430893" ></span>
== escape() and replace() in importScript function ==
I read this [[MediaWiki_talk:Common.js/Archive_2#Import_Module|December discussion about import module]] but I still don't see why <
Same question for <
— [[User:Alex Smotrov|Alex Smotrov]] 20:48, 3 March 2007 (UTC)
Line 35 ⟶ 34:
::::You're correct that it avoids an HTTP redirect. I just tested it. [[User talk:Mike Dillon|Mike Dillon]] 17:28, 5 March 2007 (UTC)
<span id="63298753350" ></span>
== Collapsible tables ==
Line 50 ⟶ 49:
::I have added a test for whether any header row exists: HTH HAND —[[User:Phil Boswell|Phil]] | [[User talk:Phil Boswell|Talk]] 11:02, 9 March 2007 (UTC)
<span id="63298677990" ></span>
== Optimizing [[Mediawiki:Edittools]] ==
Line 110 ⟶ 109:
:As Ruud just said, there is no need for a fallback, since the edit tools already do not work (and cannot work) without Javascript. --[[User:CesarB|cesarb]] 14:06, 8 March 2007 (UTC)
<span id="63299025922" ></span>
== Placing the cursor after the section name ==
A long time ago, [[User_talk:Quarl/Archive_2006-02#User:Quarl.2Fauto_summary.js|Quarl and I discussed]]{{Broken anchor|date=2024-04-21|bot=User:Cewbot/log/20201008/configuration|target_link=User_talk:Quarl/Archive_2006-02#User:Quarl.2Fauto summary.js|reason= }} some user scripts and made a little snippet of code that, when you press ''tab'' to go to the Summary field, puts your cursor after the section name, so you can just start typing. It's a tremendously helpful little tweak, and now that I've removed Quarl's code from my monobook.js, I miss it. :-) It would be a good thing to implement site-wide, though. This was my version, though I think he improved on it in his Power Tools scripts:
<pre>
/* When the summary box is clicked, select only the part *after* the section title/place the cursor after the auto summary */
addOnloadHook(function () {
if (document.getElementById('wpSummary')) {
summary = document.getElementById('wpSummary');
function selectSummary() {
section = summary.value.match(/(?:\/\*(?:.*)\*\/)?\s*(?:«(?:.*)»)? ?/);
if (section) {
sectlen = section[0].length;
end = summary.textLength;
summary.setSelectionRange(sectlen,end);
}
}
summary.onclick = selectSummary;
}
});
</pre>
I don't know enough about JavaScript to follow his code, but I think this is equivalent:
<pre>
// auto focus
$autosummary._focusSummaryEvent = function(event) {
var sumField = document.editform.wpSummary;
if (sumField.value.match(/^(?:\/\*.*?\*\/)?\s*(?:«(?:.*)»)? ?/)) {
var n = RegExp.lastMatch.length;
var m = sumField.value.length;
// apparently you can't setSelectionRange in an onFocus handler, but
// you can set a timer to do it 0 seconds from now.
setTimeout(function() { sumField.setSelectionRange(n, m) }, 0);
}
}
</pre>
Found on http://www.cubewano.org/wpt/scripts/COMBINED.js
— [[User:Omegatron|Omegatron]] 00:13, 2 March 2007 (UTC)
:Please check that code on multiple browsers; I think I remember something about selection code being different on IE and FireFox. --[[User:ais523|ais523]] 11:21, 9 March 2007 ([[User:ais523|U]][[User talk:ais523|T]][[Special:Contributions/Ais523|C]])
:: I don't know enough to check it for compatibility with all browsers and situations. I'm just proposing that someone with the knowledge include it site-wide. — [[User:Omegatron|Omegatron]] 03:59, 10 March 2007 (UTC)
:::Your version is a syntax error in IE6. Code shouldn't be added to the site-wide JS unless it works on ''all'' browsers! --[[User:ais523|ais523]] 14:45, 12 March 2007 ([[User:ais523|U]][[User talk:ais523|T]][[Special:Contributions/Ais523|C]])
<span id="63299562298" ></span>
:Further work at [[bugzilla:9937]]. --[[User:Brion VIBBER|brion]] 15:59, 17 May 2007 (UTC)
== Proposal: Edittools with Javascript ==
Replace all those <code><a … onlcick=InsertTags </code> lines now generated from [[MediaWiki:Edittools]] with javascript code inside <code>MediaWiki:Editpage.js</code>. Sample version of this code: [[User:Alex Smotrov/createEditTools]], see discussion page for instructions on how to test it. Advantages:
* ease of removing (not just hiding) unnecessary characters and adding your own
* Js code is about 10 times smaller
* Js code should be cached by browser because it's a separate file
— [[User:Alex Smotrov|Alex Smotrov]] 20:47, 8 March 2007 (UTC)
:Great idea! I like the js, but I have one idea. Once we're doing this, why don't we have a drop-down menu like at [[:commons:]]? —<span style="color: red;">[[User:Mets501|M<small>ETS</small>501]] ([[User talk:Mets501|talk]])</span> 21:03, 8 March 2007 (UTC)
::Question: What happens for users with javascript disabled? [[User:Prodego|<span style="color:darkgreen;">''Prodego''</span>]] [[User talk:Prodego|<sup style="color:darkgreen;">talk</sup>]] 19:23, 18 March 2007 (UTC)
:::The edit tools don't appear. Since clicking on them relies on JavaScript anyways, this is not a problem. It's actually better than the current situation since right now the tools show up if you don't have JS enabled, but they don't actually work. [[User talk:Mike Dillon|Mike Dillon]] 19:44, 18 March 2007 (UTC)
<span id="63298081396" ></span>
== Collapsible sections ==
I was wondering whether it would be possible to adjust the collapsible table code a little to allow a table to be collapsed section-by-section?
What I was thinking was that you could have a table like this:
{|
|+ <span style="float:right; color: blue;">[hide]</span>Caption
|-
! colspan="2" | <span style="float:right; color: blue;">[hide]</span>Section 1
|-
| some stuff || …and more stuff
|-
! colspan="2" | <span style="float:right; color: blue;">[hide]</span>Section 2
|-
| some stuff || …and more stuff
|}
where clicking the <span style="color: blue;">[hide]</span> link in the caption hid the entire table whereas the corresponding link in each header-row hid the rows from there up to the next header-row.
Would it be difficult to arrange that the intermediate rows, those to be hidden, could have "header cells" in the first column?
This would be helpful in quite a few places, like in some infoboxes, where it would be helpful to have much of the information hidden until required.
HTH HAND —[[User:Phil Boswell|Phil]] | [[User talk:Phil Boswell|Talk]] 16:23, 1 March 2007 (UTC)
<span id="63298702036" ></span>
== Proposal: Editpage.js ==
Create another «common» javascript file <code>MediaWiki:Editpage.js</code> and «call» it from [[MediaWiki:Common.js]] (already implemented e.g. in [[:pl:MediaWiki:Monobook.js]] and [[:ru:MediaWiki:Common.js]]: search for "<code>Onlyifediting.js</code>")
if (document.___URL.indexOf('action=edit') > 0 || document.___URL.indexOf('action=submit') > 0)
importScript('MediaWiki:Editpage.js');
Then move from [[MediaWiki:Common.js]] → <code>MediaWiki:Editpage.js</code>
* code «Extra toolbar options» (mwCustomEditButtons)
* code «fix edit summary prompt for undo»
— [[User:Alex Smotrov|Alex Smotrov]] 20:47, 8 March 2007 (UTC)
<span id="63299899636" ></span>
== notcollapsed class in collapsible tables and navframes ==
Tables and navframes have collapsed and autocollapse classes, but what about a notcollapsed class that would specify to keep that specific table or frame open by default on a page, but still allow it to be closed. This would come in handy for the Climate Statistics box on [[Denver, Colorado]] (we could leave one of the boxes open by default, but have the other three collapse) and the behavior is not unprecedented (Table of Contents allows show/hide and defaults to open). --[[User:MattWright|MattWright]] ([[User talk:MattWright|talk]]) 18:36, 21 March 2007 (UTC)
: Just give it the collapse class, without specifying collaped or autocollapse. —''[[User:Ruud Koot|Ruud]]'' 10:31, 22 March 2007 (UTC)
::Thanks for the reply Ruud. --[[User:MattWright|MattWright]] ([[User talk:MattWright|talk]]) 17:27, 22 March 2007 (UTC)
|