mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-09-24 02:38:40 +00:00
mw.Target: Remove visible text filter for edit notices
This removes the hack for bug 43013, since T91715 has been fixed. Bug: T87412 Change-Id: I7f477d0815a8b9a7ca2f4405e4c2d6e914868c56
This commit is contained in:
parent
f86b8aef74
commit
97d7da6643
|
@ -95,12 +95,6 @@ $wgVisualEditorResourceTemplate = array(
|
|||
);
|
||||
|
||||
$wgResourceModules += array(
|
||||
'jquery.visibleText' => $wgVisualEditorResourceTemplate + array(
|
||||
'scripts' => array(
|
||||
'lib/ve/lib/jquery/jquery.visibleText.js',
|
||||
),
|
||||
'targets' => array( 'desktop', 'mobile' ),
|
||||
),
|
||||
'Base64.js' => $wgVisualEditorResourceTemplate + array(
|
||||
'scripts' => array(
|
||||
'lib/Base64.js/base64.js',
|
||||
|
@ -311,7 +305,6 @@ $wgResourceModules += array(
|
|||
'modules/ve-mw/init/styles/ve.init.mw.Target.css',
|
||||
),
|
||||
'dependencies' => array(
|
||||
'jquery.visibleText',
|
||||
'jquery.byteLength',
|
||||
'jquery.client',
|
||||
'mediawiki.api',
|
||||
|
|
|
@ -168,15 +168,6 @@
|
|||
]
|
||||
},
|
||||
"ResourceModules": {
|
||||
"jquery.visibleText": {
|
||||
"scripts": [
|
||||
"lib/ve/lib/jquery/jquery.visibleText.js"
|
||||
],
|
||||
"targets": [
|
||||
"desktop",
|
||||
"mobile"
|
||||
]
|
||||
},
|
||||
"Base64.js": {
|
||||
"scripts": [
|
||||
"lib/Base64.js/base64.js"
|
||||
|
@ -394,7 +385,6 @@
|
|||
"modules/ve-mw/init/styles/ve.init.mw.Target.css"
|
||||
],
|
||||
"dependencies": [
|
||||
"jquery.visibleText",
|
||||
"jquery.byteLength",
|
||||
"jquery.client",
|
||||
"mediawiki.api",
|
||||
|
|
|
@ -393,51 +393,22 @@ ve.init.mw.Target.onLoad = function ( response ) {
|
|||
|
||||
/**
|
||||
* Handle the edit notices being ready for rendering.
|
||||
*
|
||||
* @method
|
||||
*/
|
||||
ve.init.mw.Target.prototype.onNoticesReady = function () {
|
||||
var i, len, noticeHtmls, tmp, el;
|
||||
|
||||
// Since we're going to parse them, we might as well save these nodes
|
||||
// so we don't have to parse them again later.
|
||||
this.editNotices = {};
|
||||
|
||||
/* Don't show notices without visible html (bug 43013). */
|
||||
|
||||
// This is a temporary container for parsed notices in the <body>.
|
||||
// We need the elements to be in the DOM in order for stylesheets to apply
|
||||
// and jquery.visibleText to determine whether a node is visible.
|
||||
tmp = document.createElement( 'div' );
|
||||
|
||||
// The following is essentially display none, but we can't use that
|
||||
// since then all descendants will be considered invisible too.
|
||||
tmp.style.cssText = 'position: static; top: 0; width: 0; height: 0; border: 0; visibility: hidden;';
|
||||
document.body.appendChild( tmp );
|
||||
var noticeHtmls,
|
||||
target = this;
|
||||
|
||||
// Merge locally and remotely generated notices
|
||||
noticeHtmls = this.remoteNotices.slice();
|
||||
for ( i = 0, len = this.localNoticeMessages.length; i < len; i++ ) {
|
||||
noticeHtmls.push(
|
||||
'<p>' + ve.init.platform.getParsedMessage( this.localNoticeMessages[i] ) + '</p>'
|
||||
);
|
||||
}
|
||||
noticeHtmls = this.remoteNotices.concat(
|
||||
this.localNoticeMessages.map( function ( msgKey ) {
|
||||
return '<p>' + ve.init.platform.getParsedMessage( msgKey ) + '</p>';
|
||||
} )
|
||||
);
|
||||
|
||||
for ( i = 0, len = noticeHtmls.length; i < len; i++ ) {
|
||||
el = $( '<div>' )
|
||||
// Public class for usage by third parties to change styling of
|
||||
// edit notices within VisualEditor (bug 43013).
|
||||
.addClass( 'mw-ve-editNotice' )
|
||||
.html( noticeHtmls[i] )
|
||||
.get( 0 );
|
||||
|
||||
tmp.appendChild( el );
|
||||
if ( $.getVisibleText( el ).trim() !== '' ) {
|
||||
this.editNotices[i] = el;
|
||||
}
|
||||
tmp.removeChild( el );
|
||||
}
|
||||
document.body.removeChild( tmp );
|
||||
this.editNotices = {};
|
||||
noticeHtmls.forEach( function ( noticeHtml, i ) {
|
||||
target.editNotices[i] = $.parseHTML( noticeHtml )[0];
|
||||
} );
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue