Created
January 19, 2012 20:39
-
-
Save jobicoppola/1642436 to your computer and use it in GitHub Desktop.
Javascript loaded for all Mediawiki users
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* BEGIN extending the Advanced section of the editor toolbar | |
* We wants moar functionality! | |
* | |
* Gist url: https://gist.github.com/1642436 | |
* | |
* Use contents of this gist in: | |
* http://your/wiki/url/MediaWiki:Common.js | |
*/ | |
var prequote = "<div class=\"quotes\">\n\t<p class=\"quote\">"; | |
var postquote = "</p>\n\t<p class=\"quoted\">\n\t\t<b>—Utterer/author of quote</b>\n\t</p>\n</div>"; | |
if ( typeof $j != 'undefined' && typeof $j.fn.wikiEditor != 'undefined' ) { | |
$j( function() { | |
/* Button to easily add the markup for a new quote on our Quotes page */ | |
$j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { | |
'section': 'advanced', | |
'group': 'format', | |
'tools': { | |
'strikethrough': { | |
label: 'Add quote markup', | |
type: 'button', | |
icon: '/skins/common/images/edit-quotation.png', | |
action: { | |
type: 'encapsulate', | |
options: { | |
pre: prequote, | |
post: postquote | |
} | |
} | |
} | |
} | |
}); | |
/* Add strikethrough button */ | |
$j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { | |
'section': 'advanced', | |
'group': 'format', | |
'tools': { | |
'strikethrough': { | |
label: 'Strike', | |
type: 'button', | |
icon: '/skins/common/images/text_strikethrough.png', | |
action: { | |
type: 'encapsulate', | |
options: { | |
pre: "<s>", | |
post: "</s>" | |
} | |
} | |
} | |
} | |
}); | |
/* Add pre tag */ | |
$j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { | |
'section': 'advanced', | |
'group': 'format', | |
'tools': { | |
'pre': { | |
label: 'Add pre tag', | |
type: 'button', | |
icon: '/skins/common/images/markup-tag-pre.png', | |
action: { | |
type: 'encapsulate', | |
options: { | |
pre: "<pre>", | |
post: "</pre>" | |
} | |
} | |
} | |
} | |
}); | |
/* Add code tag */ | |
$j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { | |
'section': 'advanced', | |
'group': 'format', | |
'tools': { | |
'code': { | |
label: 'Add code tag', | |
type: 'button', | |
icon: '/skins/common/images/markup-tag-code.png', | |
action: { | |
type: 'encapsulate', | |
options: { | |
pre: "<code>", | |
post: "</code>" | |
} | |
} | |
} | |
} | |
}); | |
}); | |
} | |
/* END editor toolbar additions */ | |
/** | |
* BEGIN renderGoogleCharts - By [[w:User:Ciencia Al Poder]] "Jesús Martínez Novo" | |
* Replaces links to google charts with images of the chart | |
* The title and alternate text of the image will be the text of the link | |
* If the link is placed inside a element with class="nochart", the link won't be touched | |
*/ | |
function renderGoogleCharts(){ | |
if (!document.getElementById('bodyContent')) return; | |
var as = document.getElementById('bodyContent').getElementsByTagName('a'); | |
for (var i = as.length-1; i>=0; i--){ | |
if (as[i].href.indexOf('http://chart.googleapis.com/chart?') == 0){ | |
if ((' '+as[i].parentNode.className+' ').indexOf(' nochart ') == -1){ | |
var img = document.createElement('img'); | |
img.src = as[i].href; | |
var content = as[i].textContent || as[i].innerHTML || 'This is a chart' | |
img.alt = content; | |
img.title = content; | |
as[i].parentNode.replaceChild(img, as[i]); | |
} | |
} | |
} | |
} | |
addOnloadHook(renderGoogleCharts); | |
/* END renderGoogleCharts */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment