From 98dcc7117af5ce1a86e8c8d6e2cedba3749172cc Mon Sep 17 00:00:00 2001 From: MatmaRex Date: Thu, 9 Aug 2012 14:27:46 +0200 Subject: [PATCH] support for interwikis in experimental JS preview Add support for previewing interwikis in "experimental" JavaScript live preview. The #p-lang container is not shown when action=edit by default; it is, however, shown when action=submit. We check for its existence and if missing, we add it after #p-tb. (As print/export links are not shown during either editing or previewing.) If #p-tb is missing (as the case is in some skins), nothing happens (and interwikis stay unpreviewable). jQuery is very permissive and keeps chugging along at all costs. If #p-lang is missing in the preview page, nothing bad happens as well. The content of #p-lang is properly cleared and not filled with anything. (See above comment about jQuery being permissive.) Change-Id: Idda2e6f7514ba8b1021c719a08855ee9601fa90e --- skins/common/preview.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/skins/common/preview.js b/skins/common/preview.js index 9e76ca09ea..de4bcff88f 100644 --- a/skins/common/preview.js +++ b/skins/common/preview.js @@ -12,7 +12,7 @@ // Hide active diff, used templates, old preview if shown var copyElements = ['#wikiPreview', '.templatesUsed', '.hiddencats', - '#catlinks']; + '#catlinks', '#p-lang']; var copySelector = copyElements.join(','); $.each( copyElements, function(k,v) { $(v).fadeOut('fast'); } ); @@ -123,6 +123,13 @@ }; $(document).ready( function() { - $('#wpPreview').click( doLivePreview ); + // construct space for interwiki links if missing + // (it is usually not shown when action=edit, but shown if action=submit) + if ( !document.getElementById( 'p-lang' ) && document.getElementById( 'p-tb' ) ) { + // we need not hide this, because it's empty anyway + $( '#p-tb' ).after( $( '
' ).attr( 'id', 'p-lang' ) ); + } + + $( '#wpPreview' ).click( doLivePreview ); } ); }) ( jQuery ); -- 2.20.1