Diferencia entre revisiones de «MediaWiki:Gadget-Links.js»
De WikiEducator
(convert from MediaWiki:Common.js to Gadget for MW 1.23+) |
m (1 revisión: import from en.WE after update to MW 1.23+) |
(Sin diferencias)
|
Última revisión de 14:48 3 sep 2014
/* add Links button with permanent link, short link, and iframe snippets for each * 2010-12-21 http://WikiEducator.org/User:JimTittsler * short links derived from [[commons:Bugzilla:021572]] -- [[commons:meta:user:Platonides]] */ $( function() { var plink = document.getElementById("t-permalink"); if (wgArticleId && plink) { var permanent_link = wgScript + '?oldid=' + wgCurRevisionId; var short_url = wgScript + '?curid=' + wgArticleId; var height = document.getElementById('content').offsetHeight; plink.innerHTML = ['<a href="#" title="Permanent and short URLs, IFrame snippets for this page" onClick="var weLinks=document.getElementById(\'weLinks\'); if (weLinks.style.display == \'none\') { weLinks.style.display = \'block\'; weSelectMe(document.getElementById(\'we_page_iframe\'));} else { weLinks.style.display = \'none\'; } return false;">Links</a>' , '<ul id="weLinks" style="display:none;">' , '<li><a href="' + permanent_link + '" title="Permanent link to this revision">Permanent Link</a></li>' , '<li>IFrame snippet to this revision:<br>' , '<span class="weLinkSelect"><iframe src="' + wgServer + permanent_link + '" width="100%" height="' , height , '">WikiEducator </iframe></span></li>' , '<li><a href="' + short_url + '" title="Reference page by article id">Short URL</a></li>' , '<li>IFrame snippet to this page:<br>' , '<span id="we_page_iframe" class="weLinkSelect"><iframe src="' + wgServer + short_url + '" width="100%" height="' , height , '">WikiEducator </iframe></span></li>' , '</ul>' ].join(''); // copy to clipboard on click $('.weLinkSelect').click(function() { var node = $(this)[0]; var selection, range, doc, win; if ((doc = node.ownerDocument) && (win=doc.defaultView) && typeof win.getSelection != 'undefined' && typeof doc.createRange != 'undefined' && (selection = window.getSelection()) && typeof selection.removeAllRanges != 'undefined') { range = doc.createRange(); range.selectNode(node); selection.removeAllRanges(); selection.addRange(range); } else if (document.body && typeof document.body.createTextRange != 'undefined' && (range = document.body.createTextRange())) { /* IE */ range.moveToElementText(node); range.select(); } }); } } );