2734
правки
Изменения
Нет описания правки
/* Keep track of delegated events on dynamic content */
mcw.events = {};
/* Добавляет дополнительные кнопки в классическую панель редактирования */
if ( mw.user.options.get( 'showtoolbar' ) && !mw.user.options.get( 'usebetatoolbar' ) ) {
mw.loader.load( '/index.php?title=MediaWiki:Toolbar.js&action=raw&ctype=text/javascript' );
}
/* Добавляет кнопки вставки часто используемых описаний правки */
if (wgAction == 'edit' || wgAction == 'submit') {
mw.loader.load( '/index.php?title=MediaWiki:AddSumButton.js&action=raw&ctype=text/javascript' );
}
/* Fired whenever wiki content is added. (#mw-content-text, live preview, load page, etc.) */
*
* Replaces normal tooltips. Supports minecraft [[formatting codes]] (except k), and a description with line breaks (/).
* Use mcw.useNativeMinetip = true to use normal tooltips, with the description added
*/
}
return;
}
// Append child title as title may contain formatting codesGet event data from remote trigger e = trigger || e; var top = e.clientY - 34, left = e.clientX + 14, width = tooltip.outerWidth( true ), height = tooltip.outerHeight( true ), $win = $( window ), winWidth = $win.width(), winHeight = $win.height(); // If going off the right of the screen, go to the left of the cursor if ( !title left + width > winWidth ) { title left -= ''width + 36;
}
// Set If now going off to the retrieved title as data for future useleft of the screen, resort to going below the cursor if ( left < 0 ) { left = 0; top += 82; // Go above the cursor if too low if ( top + height > winHeight ) { top -= 77 + height; } // Don't go off the top of the screen $elem} else if ( top < 0 ) { top = 0; // Don't go off the bottom of the screen } else if ( top + height > winHeight ) { top = winHeight - height; } // Apply the positions tooltip.attrcss( { top: top, left: left } ); }, 'data-mouseleave.minetip-title', title : function() { if ( !tooltip ) { return; } tooltip.remove();
}
}, '.minetip, .grid .image, .grid .item, .grid2 .item' ).off( '.minetipNative' );
},
// Remove all events
destroy: function() {
$( '#mw-content-text' ).off( '.minetip .minetipNative' );
$( '#minetip-tooltip' ).remove();
},
// Add native browser tooltip events, removing normal minetip
native: function() {
$( '#mw-content-text' ).on( 'mouseenter.minetipNative', '.minetip, .grid .image, .grid .item, .grid2 .item', function() {
var title = $( this ).data( 'minetip-title' ),
description = $( this ).data( 'minetip-text' ),
existingTitle = $( this ).attr( 'title' ) || $( this ).find( '> a:first' ).attr( 'title' );
if ( !title || title === 0 || $elem( this ).dataattr( 'minetip-readytitle' ) ) { // Remove title attributes titles within so the native tooltip doesnthey don't get in the wayinterfere $elem( this ).find( '[title]' ).addBack().removeAttr( 'title' ); $elem.data( 'minetip-ready', true );
}
if ( title === 0 ) { $( this ).removeAttr( 'title' ) {;
return;
} else if ( !title && ( !existingTitle || !description ) ) {
return;
} else if ( !title && existingTitle ) {
$( this ).data( 'minetip-title', existingTitle );
}
var content text = '<span class="minetip-title">' + escape( title ) + '&r</span>'; var description = $.trim( $elem.attr( 'data-minetip-text' ) )|| existingTitle;
if ( description ) {
}
// Add classes for minecraft Remove formatting codes while ( contenttext = text.searchreplace( /&([0-9a-fl-o])/ g, '' ) > -1 ) { content = content.replace( /\\\//g, '&([0-9a-fl-o]#47;' )( .*?)replace(&r|$)/\//g, '<span class="format-$1">$2</span>&r\n' ); } // Remove reset formatting content = content .replace( /&r#47;/g, '/' );
} );
/* End DOM ready */
}() );