MediaWiki:Common.js:修订间差异

Baneq​(留言 | 贡献)
无编辑摘要
Baneq​(留言 | 贡献)
无编辑摘要
第78行: 第78行:
{ pre: '{{色|' + hex + '|', peri: '文字', post: '}}', selectPeri: true } );
{ pre: '{{色|' + hex + '|', peri: '文字', post: '}}', selectPeri: true } );
ncClosePanel();
ncClosePanel();
}
function ncCopyHex( hex, $btn ) {
try { localStorage.setItem( 'nc-last-color', hex ); } catch ( e ) {}
function flash() {
var orig = $btn.html();
$btn.html( '✓ ' + hex ).css( 'background', '#d4edda' );
setTimeout( function () { $btn.html( orig ).css( 'background', '#fff' ); }, 1200 );
}
if ( navigator.clipboard && navigator.clipboard.writeText ) {
navigator.clipboard.writeText( hex ).then( flash, fallback );
} else { fallback(); }
function fallback() {
var $tmp = $( '<input>' ).val( hex ).appendTo( document.body );
$tmp[0].select();
try { document.execCommand( 'copy' ); } catch ( e ) {}
$tmp.remove();
flash();
}
}
}
function ncClosePanel() {
function ncClosePanel() {
第98行: 第116行:
$( '<button type="button" class="nc-colorpop-ok">应用</button>' )
$( '<button type="button" class="nc-colorpop-ok">应用</button>' )
.on( 'click', function () { ncApplyColor( $native.val() ); } ).appendTo( $row );
.on( 'click', function () { ncApplyColor( $native.val() ); } ).appendTo( $row );
var $copyBtn = $( '<button type="button" class="nc-colorpop-copy" title="复制色值(粘到 {{信息框|颜色=}} 等参数里)">📋</button>' )
.css( {
padding: '3px 10px', border: '1px solid #c8c2b4', background: '#fff',
borderRadius: '4px', cursor: 'pointer', marginLeft: '4px', fontSize: '13px', minWidth: '40px'
} );
$copyBtn.on( 'click', function () { ncCopyHex( $native.val(), $copyBtn ); } );
$copyBtn.appendTo( $row );
$ncPanel.appendTo( document.body );
$ncPanel.appendTo( document.body );
var $btn = $( '.tool[rel="nccolorpicker"]' );
var $btn = $( '.tool[rel="nccolorpicker"]' );