summaryrefslogtreecommitdiff
path: root/extensions/Cite/modules
diff options
context:
space:
mode:
Diffstat (limited to 'extensions/Cite/modules')
-rw-r--r--extensions/Cite/modules/ext.cite.css16
-rw-r--r--extensions/Cite/modules/ext.cite.js38
-rw-r--r--extensions/Cite/modules/ext.cite.popups.js13
-rw-r--r--extensions/Cite/modules/ext.cite/ext.cite.js12
-rw-r--r--extensions/Cite/modules/ext.rtlcite.css (renamed from extensions/Cite/modules/ext.rtlcite/ext.rtlcite.css)0
-rw-r--r--extensions/Cite/modules/ext.specialcite.css (renamed from extensions/Cite/modules/ext.specialcite/ext.specialcite.css)0
6 files changed, 67 insertions, 12 deletions
diff --git a/extensions/Cite/modules/ext.cite.css b/extensions/Cite/modules/ext.cite.css
new file mode 100644
index 00000000..4ea7a814
--- /dev/null
+++ b/extensions/Cite/modules/ext.cite.css
@@ -0,0 +1,16 @@
+/**
+ * Per http://developer.yahoo.com/blogs/ydn/clip-hidden-content-better-accessibility-53456.html
+ * and https://en.wikipedia.org/w/index.php?oldid=572888139#Scrolling_past_the_bottom_of_the_page...
+ */
+.cite-accessibility-label {
+ position: absolute !important;
+ /* Workaround a Webkit/Blink bug about positioning within columns as many wikis format references with several columns */
+ top: -99999px;
+ clip: rect(1px 1px 1px 1px); /* IE6, IE7 */
+ clip: rect(1px, 1px, 1px, 1px);
+ padding: 0 !important;
+ border: 0 !important;
+ height: 1px !important;
+ width: 1px !important;
+ overflow: hidden;
+}
diff --git a/extensions/Cite/modules/ext.cite.js b/extensions/Cite/modules/ext.cite.js
new file mode 100644
index 00000000..fbec1f32
--- /dev/null
+++ b/extensions/Cite/modules/ext.cite.js
@@ -0,0 +1,38 @@
+/**
+ * Main JavaScript for the Cite extension. The main purpose of this file
+ * is to add accessibility attributes to the citation links as that can
+ * hardly be done server side (bug 38141).
+ *
+ * @author Marius Hoch <hoo@online.de>
+ */
+( function ( mw, $ ) {
+ 'use strict';
+
+ mw.hook( 'wikipage.content' ).add( function ( $content ) {
+ var accessibilityLabelOne = mw.msg( 'cite_references_link_accessibility_label' ),
+ accessibilityLabelMany = mw.msg( 'cite_references_link_many_accessibility_label' );
+
+ $content.find( '.mw-cite-backlink' ).each( function () {
+ var $links = $( this ).find( 'a' ),
+ label;
+
+ if ( $links.length > 1 ) {
+ // This citation is used multiple times. Let's only set the accessibility label on the first link, the
+ // following ones should then be self-explaining. This is needed to make sure this isn't getting
+ // too wordy.
+ label = accessibilityLabelMany;
+ } else {
+ label = accessibilityLabelOne;
+ }
+
+ // We can't use aria-label over here as that's not supported consistently across all screen reader / browser
+ // combinations. We have to use visually hidden spans for the accessibility labels instead.
+ $links.eq( 0 ).prepend(
+ $( '<span>' )
+ .addClass( 'cite-accessibility-label' )
+ // Also make sure we have at least one space between the accessibility label and the visual one
+ .text( label + ' ' )
+ );
+ } );
+ } );
+} )( mediaWiki, jQuery );
diff --git a/extensions/Cite/modules/ext.cite.popups.js b/extensions/Cite/modules/ext.cite.popups.js
new file mode 100644
index 00000000..eb1e5079
--- /dev/null
+++ b/extensions/Cite/modules/ext.cite.popups.js
@@ -0,0 +1,13 @@
+( function ( mw, $ ) {
+ 'use strict';
+
+ mw.hook( 'wikipage.content' ).add( function ( $content ) {
+ $content.find( '.biblio-cite-link,sup.reference a' ).tooltip( {
+ bodyHandler: function () {
+ return $content.find( '#' + this.hash.substr( 1 ) + ' > .reference-text' )
+ .html();
+ },
+ showURL: false
+ } );
+ } );
+} )( mediaWiki, jQuery );
diff --git a/extensions/Cite/modules/ext.cite/ext.cite.js b/extensions/Cite/modules/ext.cite/ext.cite.js
deleted file mode 100644
index dc7328b4..00000000
--- a/extensions/Cite/modules/ext.cite/ext.cite.js
+++ /dev/null
@@ -1,12 +0,0 @@
-( function($) {
- $( function() {
- $('.biblio-cite-link,sup.reference a').tooltip({
- bodyHandler: function() {
- return $( '#' + this.hash.substr(1) + ' > .reference-text' )
- .html();
- },
- showURL : false
- } );
- } );
-
-} )( jQuery );
diff --git a/extensions/Cite/modules/ext.rtlcite/ext.rtlcite.css b/extensions/Cite/modules/ext.rtlcite.css
index 9b88d531..9b88d531 100644
--- a/extensions/Cite/modules/ext.rtlcite/ext.rtlcite.css
+++ b/extensions/Cite/modules/ext.rtlcite.css
diff --git a/extensions/Cite/modules/ext.specialcite/ext.specialcite.css b/extensions/Cite/modules/ext.specialcite.css
index 65a4e40e..65a4e40e 100644
--- a/extensions/Cite/modules/ext.specialcite/ext.specialcite.css
+++ b/extensions/Cite/modules/ext.specialcite.css