VISUAL PHYSICS
Unconventional Explorations into Uninhabited Areas of Physics
Through Thought Experiments in the Form of Simulations...


This is NOT an educational site. The views expressed here are not those of mainstream physics.
If you want to contribute to the wiki, email me at the address given in the Contact page.
Legend:  sim  : Article with simulation --  stb  : Article that needs development (stub).

MediaWiki talk:Common.js and Template:PTASR: Difference between pages

From Visual Physics Wiki
(Difference between pages)
Jump to navigation Jump to search
No edit summary
 
No edit summary
 
Line 1: Line 1:
/* Popup links in MediaWiki to new window */
<table align="right" style="margin: 0 0 1em 1em; font-size:85%; border: 1px solid gray; width: 200px; clear: all">
 
<tr style="background:#f2f2f2" align="center">
From http://jimbojw.com/wiki/index.php?title=Popup_links_in_MediaWiki_to_new_window
<td style="border-bottom: 2px solid #ccf">
 
'''[[Proper Time Adjusted Special Relativity]]''' <small><span style="color:green; border: 1px solid green" title="Article with Simulation">&nbsp;sim&nbsp;</span></small></td>
One recurring question I've seen with respect to MediaWiki is "How do I create popup links?" That is, have links which when clicked launch a new window or browser tab.
</tr>
 
<tr align="left" style="background:#f2f2f2">
Although there are some very good reasons NOT to allow this on a site, the following is one solution which requires only sysop permissions on a wiki. No extensions or other filesystem access is required.
<td style="border-bottom: 2px solid #ccf">
 
*[[Speed of Light and the "Rate of Propagation of Time"]] <small><span style="color:green; border: 1px solid green" title="Article with Simulation">&nbsp;sim&nbsp;</span></small>
Installation
*[[The Proper Time of Photons and the Nature of Light]]
 
*[[Linear and Angular Quantities in the Curved Expanding Universe]] <small><span style="color:tomato; border: 1px solid tomato" title="Article that needs development (Stub)">&nbsp;stb&nbsp;</span></small>
To add this functionality to your wiki,
*[[Implications for Theories Based on the Minkowski Spacetime]] <small><span style="color:tomato; border: 1px solid tomato" title="Article that needs development (Stub)">&nbsp;stb&nbsp;</span></small>
 
*[[Inverse Derivation of the Lorentz Transformation]] <small><span style="color:tomato; border: 1px solid tomato" title="Article that needs development (Stub)">&nbsp;stb&nbsp;</span></small>
Log in as a user in the sysop group
*[[Proper Time Adjusted Special Relativity with Gravitation]] <small><span style="color:tomato; border: 1px solid tomato" title="Article that needs development (Stub)">&nbsp;stb&nbsp;</span></small></td>
 
</tr>
Navigate to the MediaWiki:Common.js page.
<tr align="center" style="background:#f2f2f2">
 
<td style="border-bottom: 2px solid #ccf">
Note: To get there, just type MediaWiki:Common.js into the search box an hit "Go". If the page doesn't exist, create it by clicking the "create this page" link towards the top of the page.
'''See also'''</td>
 
</tr>
Edit this page, and add the following:
<tr align="left" style="background:#f2f2f2">
<pre>
<td style="border-bottom: 2px solid #ccf">
addOnloadHook( function() {
*[[Forms of Spacetime Curvature]] <small><span style="color:green; border: 1px solid green" title="Article with Simulation">&nbsp;sim&nbsp;</span></small>
    var pops = function( elems ) {
*[[History of the Visual Physics Project]]</td>
        for (var i=0; i<elems.length; i++) {
</tr>
            if ( !(' '+elems[i].className+' ').match( / pops / ) ) continue;
<tr align="right" style="background:#f2f2f2">
            var anchs = elems[i].getElementsByTagName('a');
<td>
            for (var j=0; j<anchs.length; j++) anchs[j].target = '_blank';
<small>[http://www.visual-physics.com/wiki/index.php?title=Template:PTASR&action=edit edit]</small></td>
        }
</tr>
    };
</table>
    var bc = document.getElementById('bodyContent');
    var tags = ['span', 'div', 'table', 'td', 'th'];
    for (var i=0; i<tags.length; i++) pops( bc.getElementsByTagName( tags[i] ) );
} );
 
</pre>
Note that after doing this, you'll need to clear your browser's cache to start seeing the effects.
 
Usage
 
To make a regular link on your wiki into a popup link, wrap it in a tag with class="pops". Acceptable tags are SPAN, DIV, TABLE, TD and TH.
 
Note: If you need other tags too, just add them to the line from above that starts with "var tags = ".
For example:  
 
<span class="pops">http://jimbojw.com/</span>
 
Or here's one using a table:
 
{| border="1" class="pops"
|-
! Link !! Description
|-
| [http://jimbojw.com/wiki/index.php?title=Blog Jim's Blog] || A fantastic technical blog
|}
 
Styling
 
You may want to create a visual cue for your users that a given link will launch a new window. To do so,
 
Navigate to the MediaWiki:Common.css page.
 
Edit this article and add something like the following:
 
.pops a {
  background-color: #ffc !important;
}
 
The above will make all popup links have a light-yellow background color. Of course, you can use whatever CSS style you like.
 
Hope this helps! As always I'll be happy to answer any questions.

Revision as of 03:28, 3 January 2007