mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/WikiEditor
synced 2024-11-24 00:06:49 +00:00
Drop the never-finished "Labs" publish and preview features
These features were ideas in the Usability Initiative but were never finished to the level that they would be deployed on Wikimedia wikis and have been marked as "going to be removed" for years. Now is time to act on that promise. Change-Id: Ia1eb91d2dfb1979518d97badc1477146b4606f7c
This commit is contained in:
parent
202cd0c64d
commit
77cea2697c
|
@ -38,39 +38,6 @@ class WikiEditorHooks {
|
||||||
'ext.wikiEditor.styles',
|
'ext.wikiEditor.styles',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|
||||||
/* Labs Features */
|
|
||||||
|
|
||||||
'preview' => [
|
|
||||||
'preferences' => [
|
|
||||||
'wikieditor-preview' => [
|
|
||||||
'type' => 'toggle',
|
|
||||||
'label-message' => 'wikieditor-preview-preference',
|
|
||||||
'section' => 'editing/labs',
|
|
||||||
],
|
|
||||||
],
|
|
||||||
'requirements' => [
|
|
||||||
'wikieditor-preview' => true,
|
|
||||||
],
|
|
||||||
'modules' => [
|
|
||||||
'ext.wikiEditor.preview',
|
|
||||||
],
|
|
||||||
],
|
|
||||||
'publish' => [
|
|
||||||
'preferences' => [
|
|
||||||
'wikieditor-publish' => [
|
|
||||||
'type' => 'toggle',
|
|
||||||
'label-message' => 'wikieditor-publish-preference',
|
|
||||||
'section' => 'editing/labs',
|
|
||||||
],
|
|
||||||
],
|
|
||||||
'requirements' => [
|
|
||||||
'wikieditor-publish' => true,
|
|
||||||
],
|
|
||||||
'modules' => [
|
|
||||||
'ext.wikiEditor.publish',
|
|
||||||
],
|
|
||||||
]
|
|
||||||
];
|
];
|
||||||
|
|
||||||
/* Static Methods */
|
/* Static Methods */
|
||||||
|
|
|
@ -123,23 +123,6 @@
|
||||||
"dialogReplace.html": "templates/dialogReplace.html"
|
"dialogReplace.html": "templates/dialogReplace.html"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"jquery.wikiEditor.preview": {
|
|
||||||
"group": "ext.wikiEditor",
|
|
||||||
"scripts": "jquery.wikiEditor.preview.js",
|
|
||||||
"styles": "jquery.wikiEditor.preview.less",
|
|
||||||
"dependencies": [
|
|
||||||
"jquery.wikiEditor.core",
|
|
||||||
"mediawiki.api"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"jquery.wikiEditor.publish": {
|
|
||||||
"group": "ext.wikiEditor",
|
|
||||||
"scripts": "jquery.wikiEditor.publish.js",
|
|
||||||
"dependencies": [
|
|
||||||
"jquery.wikiEditor.core",
|
|
||||||
"jquery.wikiEditor.dialogs"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"jquery.wikiEditor.toolbar": {
|
"jquery.wikiEditor.toolbar": {
|
||||||
"group": "ext.wikiEditor",
|
"group": "ext.wikiEditor",
|
||||||
"scripts": "jquery.wikiEditor.toolbar.js",
|
"scripts": "jquery.wikiEditor.toolbar.js",
|
||||||
|
@ -367,37 +350,6 @@
|
||||||
"jquery.wikiEditor.dialogs.config"
|
"jquery.wikiEditor.dialogs.config"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"ext.wikiEditor.preview": {
|
|
||||||
"group": "ext.wikiEditor",
|
|
||||||
"scripts": "ext.wikiEditor.preview.js",
|
|
||||||
"dependencies": [
|
|
||||||
"ext.wikiEditor.core",
|
|
||||||
"jquery.wikiEditor.preview"
|
|
||||||
],
|
|
||||||
"messages": [
|
|
||||||
"wikieditor-preview-tab",
|
|
||||||
"wikieditor-preview-changes-tab",
|
|
||||||
"wikieditor-preview-loading"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"ext.wikiEditor.publish": {
|
|
||||||
"group": "ext.wikiEditor",
|
|
||||||
"scripts": "ext.wikiEditor.publish.js",
|
|
||||||
"dependencies": [
|
|
||||||
"ext.wikiEditor.core",
|
|
||||||
"jquery.wikiEditor.publish"
|
|
||||||
],
|
|
||||||
"messages": [
|
|
||||||
"wikieditor-publish-button-publish",
|
|
||||||
"wikieditor-publish-button-cancel",
|
|
||||||
"wikieditor-publish-dialog-title",
|
|
||||||
"wikieditor-publish-dialog-summary",
|
|
||||||
"wikieditor-publish-dialog-minor",
|
|
||||||
"wikieditor-publish-dialog-watch",
|
|
||||||
"wikieditor-publish-dialog-publish",
|
|
||||||
"wikieditor-publish-dialog-goback"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"ext.wikiEditor.toolbar": {
|
"ext.wikiEditor.toolbar": {
|
||||||
"group": "ext.wikiEditor",
|
"group": "ext.wikiEditor",
|
||||||
"scripts": "ext.wikiEditor.toolbar.js",
|
"scripts": "ext.wikiEditor.toolbar.js",
|
||||||
|
@ -422,14 +374,6 @@
|
||||||
"global": false,
|
"global": false,
|
||||||
"user": true
|
"user": true
|
||||||
},
|
},
|
||||||
"preview": {
|
|
||||||
"global": false,
|
|
||||||
"user": true
|
|
||||||
},
|
|
||||||
"publish": {
|
|
||||||
"global": false,
|
|
||||||
"user": true
|
|
||||||
},
|
|
||||||
"_merge_strategy": "array_plus_2d"
|
"_merge_strategy": "array_plus_2d"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
13
i18n/en.json
13
i18n/en.json
|
@ -8,19 +8,6 @@
|
||||||
"wikieditor-desc": "Provides an extendable wikitext editing interface and many feature-providing modules",
|
"wikieditor-desc": "Provides an extendable wikitext editing interface and many feature-providing modules",
|
||||||
"wikieditor-wikitext-tab": "Wikitext",
|
"wikieditor-wikitext-tab": "Wikitext",
|
||||||
"wikieditor-loading": "Loading...",
|
"wikieditor-loading": "Loading...",
|
||||||
"wikieditor-preview-preference": "Enable side-by-side preview",
|
|
||||||
"wikieditor-preview-tab": "Preview",
|
|
||||||
"wikieditor-preview-changes-tab": "Changes",
|
|
||||||
"wikieditor-preview-loading": "Loading...",
|
|
||||||
"wikieditor-publish-preference": "Enable step-by-step publishing",
|
|
||||||
"wikieditor-publish-button-publish": "Publish",
|
|
||||||
"wikieditor-publish-button-cancel": "Cancel",
|
|
||||||
"wikieditor-publish-dialog-title": "Publish to {{SITENAME}}",
|
|
||||||
"wikieditor-publish-dialog-summary": "Edit summary (briefly describe the changes you have made):",
|
|
||||||
"wikieditor-publish-dialog-minor": "Minor edit",
|
|
||||||
"wikieditor-publish-dialog-watch": "Watch this page",
|
|
||||||
"wikieditor-publish-dialog-publish": "Publish",
|
|
||||||
"wikieditor-publish-dialog-goback": "Go back",
|
|
||||||
"wikieditor-toolbar": "Editing toolbar",
|
"wikieditor-toolbar": "Editing toolbar",
|
||||||
"wikieditor-toolbar-desc": "Edit page toolbar with enhanced usability",
|
"wikieditor-toolbar-desc": "Edit page toolbar with enhanced usability",
|
||||||
"wikieditor-toolbar-preference": "Enable enhanced editing toolbar",
|
"wikieditor-toolbar-preference": "Enable enhanced editing toolbar",
|
||||||
|
|
|
@ -32,19 +32,6 @@
|
||||||
"wikieditor-desc": "{{desc|name=Wiki Editor|url=https://www.mediawiki.org/wiki/Extension:WikiEditor}}\nI guess that \"feature-providing modules\" means the same as \"modules providing features\".",
|
"wikieditor-desc": "{{desc|name=Wiki Editor|url=https://www.mediawiki.org/wiki/Extension:WikiEditor}}\nI guess that \"feature-providing modules\" means the same as \"modules providing features\".",
|
||||||
"wikieditor-wikitext-tab": "Caption of the tab containing the edit box\n{{Identical|Wikitext}}",
|
"wikieditor-wikitext-tab": "Caption of the tab containing the edit box\n{{Identical|Wikitext}}",
|
||||||
"wikieditor-loading": "Explanatory text for the temporary cover placed over the wikieditor while it's being assembled.\n{{Identical|Loading}}",
|
"wikieditor-loading": "Explanatory text for the temporary cover placed over the wikieditor while it's being assembled.\n{{Identical|Loading}}",
|
||||||
"wikieditor-preview-preference": "Option in [[Special:Preferences]], tab ''{{int:prefs-editing}}''",
|
|
||||||
"wikieditor-preview-tab": "Caption of the tab containing the preview\n\n{{Identical|Preview}}",
|
|
||||||
"wikieditor-preview-changes-tab": "Caption of the tab containing a diff of the user's changes, à la ''{{int:Showdiff}}'' ({{msg-mw|Showdiff|notext=1}}).\n\n{{Identical|Change}}",
|
|
||||||
"wikieditor-preview-loading": "Alt text for spinner displayed while preview is being loaded\n{{Identical|Loading}}",
|
|
||||||
"wikieditor-publish-preference": "Option in [[Special:Preferences]], tab ''{{int:prefs-editing}}''",
|
|
||||||
"wikieditor-publish-button-publish": "Button to the right of the Edit/Preview tabs that opens a dialog window that lets the user save their edit\n\n{{Identical|Publish}}",
|
|
||||||
"wikieditor-publish-button-cancel": "Button to the right of the Edit/Preview tabs that has the same effect as the {{msg-mw|Cancel}} link below the edit box.\n\n{{Identical|Cancel}}",
|
|
||||||
"wikieditor-publish-dialog-title": "Title of the dialog that opens when the user clicks the Publish button",
|
|
||||||
"wikieditor-publish-dialog-summary": "Label for the edit summary textbox in the dialog that opens when the user clicks the Publish button. See also {{msg-mw|Summary}}.",
|
|
||||||
"wikieditor-publish-dialog-minor": "Label for the minor edit checkbox in the dialog that opens when the user clicks the Publish button.\n\nSee also:\n* {{msg-mw|Minoredit}}\n{{Identical|Minor edit}}",
|
|
||||||
"wikieditor-publish-dialog-watch": "Label for the watch checkbox in the dialog that opens when the user clicks the Publish button\n\n{{Identical|Watch this page}}",
|
|
||||||
"wikieditor-publish-dialog-publish": "Button that saves the user's edit in the dialog that opens when the user clicks the Publish button\n\n{{Identical|Publish}}",
|
|
||||||
"wikieditor-publish-dialog-goback": "Button that closes the dialog that opens when the user clicks the Publish button.\n{{Identical|Go back}}",
|
|
||||||
"wikieditor-toolbar": "A customizable toolbar for the WikiEditor.\nFor more information, see https://www.mediawiki.org/wiki/Extension:WikiEditor/Toolbar_customization",
|
"wikieditor-toolbar": "A customizable toolbar for the WikiEditor.\nFor more information, see https://www.mediawiki.org/wiki/Extension:WikiEditor/Toolbar_customization",
|
||||||
"wikieditor-toolbar-desc": "Unused at this time.",
|
"wikieditor-toolbar-desc": "Unused at this time.",
|
||||||
"wikieditor-toolbar-preference": "Option in [[Special:Preferences]]",
|
"wikieditor-toolbar-preference": "Option in [[Special:Preferences]]",
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
/*
|
|
||||||
* JavaScript for WikiEditor Preview module
|
|
||||||
*/
|
|
||||||
jQuery( function ( $ ) {
|
|
||||||
// Add preview module
|
|
||||||
$( 'textarea#wpTextbox1' ).wikiEditor( 'addModule', 'preview' );
|
|
||||||
} );
|
|
|
@ -1,7 +0,0 @@
|
||||||
/*
|
|
||||||
* JavaScript for WikiEditor Publish module
|
|
||||||
*/
|
|
||||||
jQuery( function ( $ ) {
|
|
||||||
// Add publish module
|
|
||||||
$( '#wpTextbox1' ).wikiEditor( 'addModule', 'publish' );
|
|
||||||
} );
|
|
|
@ -243,16 +243,3 @@ body.rtl {
|
||||||
.wikiEditor-dialog-editoptions {
|
.wikiEditor-dialog-editoptions {
|
||||||
margin-top: 15px;
|
margin-top: 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Publish dialog */
|
|
||||||
.wikiEditor-publish-dialog-copywarn {
|
|
||||||
margin-top: 0.5em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wikiEditor-publish-dialog-summary {
|
|
||||||
margin-top: 1.5em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wikiEditor-publish-dialog-options {
|
|
||||||
margin-top: 1.5em;
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,179 +0,0 @@
|
||||||
/* Preview module for wikiEditor */
|
|
||||||
( function ( $, mw ) {
|
|
||||||
$.wikiEditor.modules.preview = {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Compatibility map
|
|
||||||
*/
|
|
||||||
browsers: {
|
|
||||||
// Left-to-right languages
|
|
||||||
ltr: {
|
|
||||||
msie: [ [ '>=', 9 ] ],
|
|
||||||
firefox: [ [ '>=', 4 ] ],
|
|
||||||
opera: [ [ '>=', '10.5' ] ],
|
|
||||||
safari: [ [ '>=', 5 ] ],
|
|
||||||
chrome: [ [ '>=', 5 ] ]
|
|
||||||
},
|
|
||||||
// Right-to-left languages
|
|
||||||
rtl: {
|
|
||||||
msie: [ [ '>=', 9 ] ],
|
|
||||||
firefox: [ [ '>=', 4 ] ],
|
|
||||||
opera: [ [ '>=', '10.5' ] ],
|
|
||||||
safari: [ [ '>=', 5 ] ],
|
|
||||||
chrome: [ [ '>=', 5 ] ]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Internally used functions
|
|
||||||
*/
|
|
||||||
fn: {
|
|
||||||
/**
|
|
||||||
* Creates a preview module within a wikiEditor
|
|
||||||
*
|
|
||||||
* @param {Object} context Context object of editor to create module in
|
|
||||||
*/
|
|
||||||
create: function ( context ) {
|
|
||||||
var loadingMsg,
|
|
||||||
api = new mw.Api();
|
|
||||||
|
|
||||||
if ( 'initialized' in context.modules.preview ) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
context.modules.preview = {
|
|
||||||
initialized: true,
|
|
||||||
previewText: null,
|
|
||||||
changesText: null
|
|
||||||
};
|
|
||||||
context.modules.preview.$preview = context.fn.addView( {
|
|
||||||
name: 'preview',
|
|
||||||
titleMsg: 'wikieditor-preview-tab',
|
|
||||||
init: function ( context ) {
|
|
||||||
// Gets the latest copy of the wikitext
|
|
||||||
var wikitext = context.$textarea.textSelection( 'getContents' );
|
|
||||||
// Aborts when nothing has changed since the last preview
|
|
||||||
if ( context.modules.preview.previewText === wikitext ) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
context.modules.preview.$preview.find( '.wikiEditor-preview-contents' ).empty();
|
|
||||||
context.modules.preview.$preview.find( '.wikiEditor-preview-loading' ).show();
|
|
||||||
api.post( {
|
|
||||||
formatversion: 2,
|
|
||||||
action: 'parse',
|
|
||||||
title: mw.config.get( 'wgPageName' ),
|
|
||||||
text: wikitext,
|
|
||||||
pst: '',
|
|
||||||
prop: 'text|modules|jsconfigvars',
|
|
||||||
preview: true,
|
|
||||||
disableeditsection: true,
|
|
||||||
useskin: mw.config.get( 'skin' ),
|
|
||||||
uselang: mw.config.get( 'wgUserLanguage' )
|
|
||||||
} ).always( function () {
|
|
||||||
context.modules.preview.$preview.find( '.wikiEditor-preview-loading' ).hide();
|
|
||||||
} ).done( function ( data ) {
|
|
||||||
var loadmodules, $content;
|
|
||||||
if ( !data.parse || !data.parse.text ) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( data.parse.jsconfigvars ) {
|
|
||||||
mw.config.set( data.parse.jsconfigvars );
|
|
||||||
}
|
|
||||||
loadmodules = data.parse.modules.concat(
|
|
||||||
data.parse.modulescripts,
|
|
||||||
data.parse.modulestyles
|
|
||||||
);
|
|
||||||
mw.loader.load( loadmodules );
|
|
||||||
|
|
||||||
context.modules.preview.previewText = wikitext;
|
|
||||||
$content = context.modules.preview.$preview.find( '.wikiEditor-preview-contents' )
|
|
||||||
.detach()
|
|
||||||
.html( data.parse.text );
|
|
||||||
$content.append( '<div class="visualClear"></div>' )
|
|
||||||
.find( 'a:not([href^="#"])' )
|
|
||||||
.click( false );
|
|
||||||
|
|
||||||
mw.hook( 'wikipage.content' ).fire( $content );
|
|
||||||
context.modules.preview.$preview.append( $content );
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
|
|
||||||
context.$changesTab = context.fn.addView( {
|
|
||||||
name: 'changes',
|
|
||||||
titleMsg: 'wikieditor-preview-changes-tab',
|
|
||||||
init: function ( context ) {
|
|
||||||
// Gets the latest copy of the wikitext
|
|
||||||
var section, postdata, postPromise,
|
|
||||||
wikitext = context.$textarea.textSelection( 'getContents' );
|
|
||||||
// Aborts when nothing has changed since the last time
|
|
||||||
if ( context.modules.preview.changesText === wikitext ) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
context.$changesTab.find( 'table.diff tbody' ).empty();
|
|
||||||
context.$changesTab.find( '.wikiEditor-preview-loading' ).show();
|
|
||||||
|
|
||||||
section = $( '[name="wpSection"]' ).val();
|
|
||||||
postdata = {
|
|
||||||
formatversion: 2,
|
|
||||||
action: 'query',
|
|
||||||
prop: 'revisions',
|
|
||||||
titles: mw.config.get( 'wgPageName' ),
|
|
||||||
rvdifftotext: wikitext,
|
|
||||||
rvdifftotextpst: true,
|
|
||||||
rvprop: '',
|
|
||||||
rvsection: section === '' ? undefined : section
|
|
||||||
};
|
|
||||||
postPromise = api.post( postdata );
|
|
||||||
|
|
||||||
$.when( postPromise, mw.loader.using( 'mediawiki.diff.styles' ) ).always( function () {
|
|
||||||
context.$changesTab.find( '.wikiEditor-preview-loading' ).hide();
|
|
||||||
} ).done( function ( postResult ) {
|
|
||||||
var diff;
|
|
||||||
try {
|
|
||||||
diff = postResult[ 0 ].query.pages[ 0 ]
|
|
||||||
.revisions[ 0 ].diff.body;
|
|
||||||
|
|
||||||
context.$changesTab.find( 'table.diff tbody' )
|
|
||||||
.html( diff )
|
|
||||||
.append( '<div class="visualClear"></div>' );
|
|
||||||
mw.hook( 'wikipage.diff' )
|
|
||||||
.fire( context.$changesTab.find( 'table.diff' ) );
|
|
||||||
context.modules.preview.changesText = wikitext;
|
|
||||||
} catch ( e ) {
|
|
||||||
// "data.blah is undefined" error, ignore
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
|
|
||||||
loadingMsg = mw.msg( 'wikieditor-preview-loading' );
|
|
||||||
context.modules.preview.$preview
|
|
||||||
.add( context.$changesTab )
|
|
||||||
.append( $( '<div>' )
|
|
||||||
.addClass( 'wikiEditor-preview-loading' )
|
|
||||||
.append( $( '<img>' )
|
|
||||||
.addClass( 'wikiEditor-preview-spinner' )
|
|
||||||
.attr( {
|
|
||||||
src: $.wikiEditor.imgPath + 'dialogs/loading.gif',
|
|
||||||
valign: 'absmiddle',
|
|
||||||
alt: loadingMsg,
|
|
||||||
title: loadingMsg
|
|
||||||
} )
|
|
||||||
)
|
|
||||||
.append(
|
|
||||||
$( '<span>' ).text( loadingMsg )
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.append( $( '<div>' )
|
|
||||||
.addClass( 'wikiEditor-preview-contents' )
|
|
||||||
);
|
|
||||||
context.$changesTab.find( '.wikiEditor-preview-contents' )
|
|
||||||
.html( '<table class="diff"><col class="diff-marker"/><col class="diff-content"/>' +
|
|
||||||
'<col class="diff-marker"/><col class="diff-content"/><tbody/></table>' );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}( jQuery, mediaWiki ) );
|
|
|
@ -1,33 +0,0 @@
|
||||||
/**
|
|
||||||
* CSS for WikiEditor Preview jQuery plugin
|
|
||||||
*/
|
|
||||||
|
|
||||||
.wikiEditor-preview-loading {
|
|
||||||
padding: 1em;
|
|
||||||
background-color: #fff;
|
|
||||||
|
|
||||||
span {
|
|
||||||
color: #54595d;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.wikiEditor-preview-spinner {
|
|
||||||
padding-right: 1em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wikiEditor-preview-contents {
|
|
||||||
padding: 1em;
|
|
||||||
background-color: #fff;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* FIXME: This only works for the first wikiEditor on the page! */
|
|
||||||
/* stylelint-disable-next-line selector-max-id */
|
|
||||||
#wikiEditor-0-preview-dialog .wikiEditor-ui-loading {
|
|
||||||
overflow: hidden;
|
|
||||||
border: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ui-dialog .ui-dialog-buttonpane {
|
|
||||||
// stylelint-disable-next-line declaration-no-important
|
|
||||||
margin: 0 !important;
|
|
||||||
}
|
|
|
@ -1,164 +0,0 @@
|
||||||
/* Publish module for wikiEditor */
|
|
||||||
( function ( $, mw ) {
|
|
||||||
|
|
||||||
$.wikiEditor.modules.publish = {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Compatibility map
|
|
||||||
*/
|
|
||||||
browsers: {
|
|
||||||
// Left-to-right languages
|
|
||||||
ltr: {
|
|
||||||
msie: [ [ '>=', 9 ] ],
|
|
||||||
firefox: [ [ '>=', 4 ] ],
|
|
||||||
opera: [ [ '>=', '10.5' ] ],
|
|
||||||
safari: [ [ '>=', 5 ] ],
|
|
||||||
chrome: [ [ '>=', 5 ] ]
|
|
||||||
},
|
|
||||||
// Right-to-left languages
|
|
||||||
rtl: {
|
|
||||||
msie: [ [ '>=', 9 ] ],
|
|
||||||
firefox: [ [ '>=', 4 ] ],
|
|
||||||
opera: [ [ '>=', '10.5' ] ],
|
|
||||||
safari: [ [ '>=', 5 ] ],
|
|
||||||
chrome: [ [ '>=', 5 ] ]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Internally used functions
|
|
||||||
*/
|
|
||||||
fn: {
|
|
||||||
/**
|
|
||||||
* Creates a publish module within a wikiEditor
|
|
||||||
*
|
|
||||||
* @param {Object} context Context object of editor to create module in
|
|
||||||
*/
|
|
||||||
create: function ( context ) {
|
|
||||||
// Build the dialog behind the Publish button
|
|
||||||
var dialogID = 'wikiEditor-' + context.instance + '-dialog';
|
|
||||||
$.wikiEditor.modules.dialogs.fn.create(
|
|
||||||
context,
|
|
||||||
{
|
|
||||||
previewsave: {
|
|
||||||
id: dialogID,
|
|
||||||
titleMsg: 'wikieditor-publish-dialog-title',
|
|
||||||
html:
|
|
||||||
'<div class="wikiEditor-publish-dialog-copywarn"></div>' +
|
|
||||||
'<div class="wikiEditor-publish-dialog-editoptions">' +
|
|
||||||
'<form id="wikieditor-' + context.instance + '-publish-dialog-form">' +
|
|
||||||
'<div class="wikiEditor-publish-dialog-summary">' +
|
|
||||||
'<label for="wikiEditor-' + context.instance + '-dialog-summary"' +
|
|
||||||
'rel="wikieditor-publish-dialog-summary"></label>' +
|
|
||||||
'<br />' +
|
|
||||||
'<input type="text" id="wikiEditor-' + context.instance + '-dialog-summary"' +
|
|
||||||
'style="width: 100%;" />' +
|
|
||||||
'</div>' +
|
|
||||||
'<div class="wikiEditor-publish-dialog-options">' +
|
|
||||||
'<input type="checkbox"' +
|
|
||||||
'id="wikiEditor-' + context.instance + '-dialog-minor" />' +
|
|
||||||
'<label for="wikiEditor-' + context.instance + '-dialog-minor"' +
|
|
||||||
'rel="wikieditor-publish-dialog-minor"></label>' +
|
|
||||||
'<input type="checkbox"' +
|
|
||||||
'id="wikiEditor-' + context.instance + '-dialog-watch" />' +
|
|
||||||
'<label for="wikiEditor-' + context.instance + '-dialog-watch"' +
|
|
||||||
'rel="wikieditor-publish-dialog-watch"></label>' +
|
|
||||||
'</div>' +
|
|
||||||
'</form>' +
|
|
||||||
'</div>',
|
|
||||||
init: function () {
|
|
||||||
var i, copyWarnHTML, copyWarnStatements, copyWarnStatement,
|
|
||||||
newCopyWarnHTML;
|
|
||||||
|
|
||||||
$( this ).find( '[rel]' ).each( function () {
|
|
||||||
$( this ).text( mw.msg( $( this ).attr( 'rel' ) ) );
|
|
||||||
} );
|
|
||||||
|
|
||||||
/* REALLY DIRTY HACK! */
|
|
||||||
// Reformat the copyright warning stuff, if available
|
|
||||||
if ( $( '#editpage-copywarn p' ).length ) {
|
|
||||||
copyWarnHTML = $( '#editpage-copywarn p' ).html();
|
|
||||||
// TODO: internationalize by splitting on other characters that end statements
|
|
||||||
copyWarnStatements = copyWarnHTML.split( '. ' );
|
|
||||||
newCopyWarnHTML = '<ul>';
|
|
||||||
for ( i = 0; i < copyWarnStatements.length; i++ ) {
|
|
||||||
if ( copyWarnStatements[ i ] !== '' ) {
|
|
||||||
copyWarnStatement = $.trim( copyWarnStatements[ i ] ).replace( /\.*$/, '' );
|
|
||||||
newCopyWarnHTML += '<li>' + copyWarnStatement + '.</li>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
newCopyWarnHTML += '</ul>';
|
|
||||||
// No list if there's only one element
|
|
||||||
$( this ).find( '.wikiEditor-publish-dialog-copywarn' ).html(
|
|
||||||
copyWarnStatements.length > 1 ? newCopyWarnHTML : copyWarnHTML
|
|
||||||
);
|
|
||||||
}
|
|
||||||
/* END OF REALLY DIRTY HACK */
|
|
||||||
|
|
||||||
if ( $( '#wpMinoredit' ).length === 0 ) {
|
|
||||||
$( '#wikiEditor-' + context.instance + '-dialog-minor' ).hide();
|
|
||||||
} else if ( $( '#wpMinoredit' ).prop( 'checked' ) ) {
|
|
||||||
$( '#wikiEditor-' + context.instance + '-dialog-minor' )
|
|
||||||
.prop( 'checked', true );
|
|
||||||
}
|
|
||||||
if ( $( '#wpWatchthis' ).length === 0 ) {
|
|
||||||
$( '#wikiEditor-' + context.instance + '-dialog-watch' ).hide();
|
|
||||||
} else if ( $( '#wpWatchthis' ).prop( 'checked' ) ) {
|
|
||||||
$( '#wikiEditor-' + context.instance + '-dialog-watch' )
|
|
||||||
.prop( 'checked', true );
|
|
||||||
}
|
|
||||||
|
|
||||||
$( this ).find( 'form' ).submit( function ( e ) {
|
|
||||||
$( this ).closest( '.ui-dialog' ).find( 'button:first' ).click();
|
|
||||||
e.preventDefault();
|
|
||||||
} );
|
|
||||||
},
|
|
||||||
immediateCreate: true,
|
|
||||||
dialog: {
|
|
||||||
buttons: {
|
|
||||||
'wikieditor-publish-dialog-publish': function () {
|
|
||||||
var minorChecked = $( '#wikiEditor-' + context.instance +
|
|
||||||
'-dialog-minor' ).is( ':checked' ),
|
|
||||||
watchChecked = $( '#wikiEditor-' + context.instance +
|
|
||||||
'-dialog-watch' ).is( ':checked' );
|
|
||||||
$( '#wpMinoredit' ).prop( 'checked', minorChecked );
|
|
||||||
$( '#wpWatchthis' ).prop( 'checked', watchChecked );
|
|
||||||
$( '#wpSummary' ).val( $( '#wikiEditor-' + context.instance +
|
|
||||||
'-dialog-summary' ).val() );
|
|
||||||
$( '#editform' ).submit();
|
|
||||||
},
|
|
||||||
'wikieditor-publish-dialog-goback': function () {
|
|
||||||
$( this ).dialog( 'close' );
|
|
||||||
}
|
|
||||||
},
|
|
||||||
open: function () {
|
|
||||||
$( '#wikiEditor-' + context.instance + '-dialog-summary' ).focus();
|
|
||||||
},
|
|
||||||
width: 500
|
|
||||||
},
|
|
||||||
resizeme: false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
context.fn.addButton( {
|
|
||||||
captionMsg: 'wikieditor-publish-button-publish',
|
|
||||||
action: function () {
|
|
||||||
$( '#' + dialogID ).dialog( 'open' );
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
|
|
||||||
context.fn.addButton( {
|
|
||||||
captionMsg: 'wikieditor-publish-button-cancel',
|
|
||||||
action: function () {
|
|
||||||
window.location.href = $( '#mw-editform-cancel a' ).attr( 'href' );
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}( jQuery, mediaWiki ) );
|
|
Loading…
Reference in a new issue