Merge "Hide wikitext warning notification when the user removes the markup"

This commit is contained in:
jenkins-bot 2014-02-07 22:54:56 +00:00 committed by Gerrit Code Review
commit 814513113a

View file

@ -671,13 +671,16 @@ ve.init.mw.ViewPageTarget.prototype.recordLastTransactionTime = function () {
ve.init.mw.ViewPageTarget.prototype.checkForWikitextWarning = function () { ve.init.mw.ViewPageTarget.prototype.checkForWikitextWarning = function () {
var text, doc = this.surface.getView().getDocument(), var text, doc = this.surface.getView().getDocument(),
selection = this.surface.getModel().getSelection(), selection = this.surface.getModel().getSelection(),
node = doc.getNodeFromOffset( selection.start ); node = doc.getNodeFromOffset( selection.start ),
textMatches,
viewPageTarget = this;
if ( !( node instanceof ve.ce.ContentBranchNode ) ) { if ( !( node instanceof ve.ce.ContentBranchNode ) ) {
return; return;
} }
text = ve.ce.getDomText( node.$element[0] ); text = ve.ce.getDomText( node.$element[0] );
textMatches = text.match( /\[\[|\{\{|''|<nowiki|<ref|~~~|^==|^\*|^\#/ );
if ( text.match( /\[\[|\{\{|''|<nowiki|<ref|~~~|^==|^\*|^\#/ ) ) { if ( textMatches && !this.wikitextWarning ) {
mw.notify( mw.notify(
$( $.parseHTML( ve.init.platform.getParsedMessage( 'visualeditor-wikitext-warning' ) ) ) $( $.parseHTML( ve.init.platform.getParsedMessage( 'visualeditor-wikitext-warning' ) ) )
.filter( 'a' ).attr( 'target', '_blank' ).end(), .filter( 'a' ).attr( 'target', '_blank' ).end(),
@ -686,10 +689,12 @@ ve.init.mw.ViewPageTarget.prototype.checkForWikitextWarning = function () {
'tag': 'visualeditor-wikitext-warning', 'tag': 'visualeditor-wikitext-warning',
'autoHide': false 'autoHide': false
} }
); ).done( function ( notif ) {
this.surface.getModel().disconnect( viewPageTarget.wikitextWarning = notif;
this, { 'documentUpdate': 'checkForWikitextWarning' } } );
); } else if ( !textMatches && this.wikitextWarning ) {
this.wikitextWarning.close();
this.wikitextWarning = undefined;
} }
}; };