summaryrefslogtreecommitdiff
path: root/resources/mediawiki.action
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2013-12-08 09:55:49 +0100
committerPierre Schmitz <pierre@archlinux.de>2013-12-08 09:55:49 +0100
commit4ac9fa081a7c045f6a9f1cfc529d82423f485b2e (patch)
treeaf68743f2f4a47d13f2b0eb05f5c4aaf86d8ea37 /resources/mediawiki.action
parentaf4da56f1ad4d3ef7b06557bae365da2ea27a897 (diff)
Update to MediaWiki 1.22.0
Diffstat (limited to 'resources/mediawiki.action')
-rw-r--r--resources/mediawiki.action/images/green-checkmark.pngbin0 -> 681 bytes
-rw-r--r--resources/mediawiki.action/mediawiki.action.edit.collapsibleFooter.css17
-rw-r--r--resources/mediawiki.action/mediawiki.action.edit.collapsibleFooter.js54
-rw-r--r--resources/mediawiki.action/mediawiki.action.edit.editWarning.js56
-rw-r--r--resources/mediawiki.action/mediawiki.action.edit.js167
-rw-r--r--resources/mediawiki.action/mediawiki.action.edit.preview.js53
-rw-r--r--resources/mediawiki.action/mediawiki.action.edit.styles.css44
-rw-r--r--resources/mediawiki.action/mediawiki.action.history.js2
-rw-r--r--resources/mediawiki.action/mediawiki.action.view.postEdit.css77
-rw-r--r--resources/mediawiki.action/mediawiki.action.view.postEdit.js75
-rw-r--r--resources/mediawiki.action/mediawiki.action.view.rightClickEdit.js4
11 files changed, 444 insertions, 105 deletions
diff --git a/resources/mediawiki.action/images/green-checkmark.png b/resources/mediawiki.action/images/green-checkmark.png
new file mode 100644
index 00000000..8ec604ea
--- /dev/null
+++ b/resources/mediawiki.action/images/green-checkmark.png
Binary files differ
diff --git a/resources/mediawiki.action/mediawiki.action.edit.collapsibleFooter.css b/resources/mediawiki.action/mediawiki.action.edit.collapsibleFooter.css
new file mode 100644
index 00000000..1af4a7a0
--- /dev/null
+++ b/resources/mediawiki.action/mediawiki.action.edit.collapsibleFooter.css
@@ -0,0 +1,17 @@
+/* Styles for collapsible lists of templates used and hidden categories */
+.mw-editfooter-toggler {
+ cursor: pointer;
+ background-position: left center;
+ padding-left: 16px;
+}
+
+.mw-editfooter-list {
+ margin-bottom: 1em;
+ margin-left: 2.5em;
+}
+
+/* Show/hide animation is incorrect if the table has a margin set. Extra
+ * "table.wikitable" is needed in the selector for CSS specificity. */
+table.wikitable.preview-limit-report {
+ margin: 0;
+}
diff --git a/resources/mediawiki.action/mediawiki.action.edit.collapsibleFooter.js b/resources/mediawiki.action/mediawiki.action.edit.collapsibleFooter.js
new file mode 100644
index 00000000..7ae51aba
--- /dev/null
+++ b/resources/mediawiki.action/mediawiki.action.edit.collapsibleFooter.js
@@ -0,0 +1,54 @@
+jQuery( document ).ready( function ( $ ) {
+ var collapsibleLists, i, handleOne;
+
+ // Collapsible lists of categories and templates
+ collapsibleLists = [
+ {
+ $list: $( '.templatesUsed ul' ),
+ $toggler: $( '.mw-templatesUsedExplanation' ),
+ cookieName: 'templates-used-list'
+ },
+ {
+ $list: $( '.hiddencats ul' ),
+ $toggler: $( '.mw-hiddenCategoriesExplanation' ),
+ cookieName: 'hidden-categories-list'
+ },
+ {
+ $list: $( '.preview-limit-report-wrapper' ),
+ $toggler: $( '.mw-limitReportExplanation' ),
+ cookieName: 'preview-limit-report'
+ }
+ ];
+
+ handleOne = function ( $list, $toggler, cookieName ) {
+ var isCollapsed = $.cookie( cookieName ) !== 'expanded';
+
+ // Style the toggler with an arrow icon and add a tabIndex and a role for accessibility
+ $toggler.addClass( 'mw-editfooter-toggler' ).prop( 'tabIndex', 0 ).attr( 'role', 'button' );
+ $list.addClass( 'mw-editfooter-list' );
+
+ $list.makeCollapsible( {
+ $customTogglers: $toggler,
+ linksPassthru: true,
+ plainMode: true,
+ collapsed: isCollapsed
+ } );
+
+ $toggler.addClass( isCollapsed ? 'mw-icon-arrow-collapsed' : 'mw-icon-arrow-expanded' );
+
+ $list.on( 'beforeExpand.mw-collapsible', function () {
+ $toggler.removeClass( 'mw-icon-arrow-collapsed' ).addClass( 'mw-icon-arrow-expanded' );
+ $.cookie( cookieName, 'expanded' );
+ } );
+
+ $list.on( 'beforeCollapse.mw-collapsible', function () {
+ $toggler.removeClass( 'mw-icon-arrow-expanded' ).addClass( 'mw-icon-arrow-collapsed' );
+ $.cookie( cookieName, 'collapsed' );
+ } );
+ };
+
+ for ( i = 0; i < collapsibleLists.length; i++ ) {
+ // Pass to a function for iteration-local variables
+ handleOne( collapsibleLists[i].$list, collapsibleLists[i].$toggler, collapsibleLists[i].cookieName );
+ }
+} );
diff --git a/resources/mediawiki.action/mediawiki.action.edit.editWarning.js b/resources/mediawiki.action/mediawiki.action.edit.editWarning.js
new file mode 100644
index 00000000..89bb64df
--- /dev/null
+++ b/resources/mediawiki.action/mediawiki.action.edit.editWarning.js
@@ -0,0 +1,56 @@
+/*
+ * Javascript for module editWarning
+ */
+( function ( mw, $ ) {
+ $( function () {
+ // Check if EditWarning is enabled and if we need it
+ if ( $( '#wpTextbox1' ).length === 0 ) {
+ return true;
+ }
+ // Get the original values of some form elements
+ $( '#wpTextbox1, #wpSummary' ).each( function () {
+ $( this ).data( 'origtext', $( this ).val() );
+ });
+ var savedWindowOnBeforeUnload;
+ $( window )
+ .on( 'beforeunload.editwarning', function () {
+ var retval;
+
+ // Check if the current values of some form elements are the same as
+ // the original values
+ if (
+ mw.config.get( 'wgAction' ) === 'submit' ||
+ $( '#wpTextbox1' ).data( 'origtext' ) !== $( '#wpTextbox1' ).val() ||
+ $( '#wpSummary' ).data( 'origtext' ) !== $( '#wpSummary' ).val()
+ ) {
+ // Return our message
+ retval = mw.msg( 'editwarning-warning' );
+ }
+
+ // Unset the onbeforeunload handler so we don't break page caching in Firefox
+ savedWindowOnBeforeUnload = window.onbeforeunload;
+ window.onbeforeunload = null;
+ if ( retval !== undefined ) {
+ // ...but if the user chooses not to leave the page, we need to rebind it
+ setTimeout( function () {
+ window.onbeforeunload = savedWindowOnBeforeUnload;
+ }, 1 );
+ return retval;
+ }
+ } )
+ .on( 'pageshow.editwarning', function () {
+ // Re-add onbeforeunload handler
+ if ( !window.onbeforeunload ) {
+ window.onbeforeunload = savedWindowOnBeforeUnload;
+ }
+ } );
+
+ // Add form submission handler
+ $( '#editform' ).submit( function () {
+ // Unbind our handlers
+ $( window ).off( '.editwarning' );
+ } );
+ } );
+
+}( mediaWiki, jQuery ) );
+
diff --git a/resources/mediawiki.action/mediawiki.action.edit.js b/resources/mediawiki.action/mediawiki.action.edit.js
index 2835c9cc..ba711aae 100644
--- a/resources/mediawiki.action/mediawiki.action.edit.js
+++ b/resources/mediawiki.action/mediawiki.action.edit.js
@@ -1,17 +1,20 @@
+/**
+ * Interface for the classic edit toolbar.
+ *
+ * @class mw.toolbar
+ * @singleton
+ */
( function ( mw, $ ) {
- var isReady, toolbar, currentFocused, queue, $toolbar, slice;
-
- isReady = false;
- queue = [];
- $toolbar = false;
- slice = Array.prototype.slice;
+ var toolbar, isReady, $toolbar, queue, slice, $currentFocused;
/**
- * Internal helper that does the actual insertion
- * of the button into the toolbar.
- * See mw.toolbar.addButton for parameter documentation.
+ * Internal helper that does the actual insertion of the button into the toolbar.
+ *
+ * See #addButton for parameter documentation.
+ *
+ * @private
*/
- function insertButton( b /* imageFile */, speedTip, tagOpen, tagClose, sampleText, imageId, selectText ) {
+ function insertButton( b, speedTip, tagOpen, tagClose, sampleText, imageId ) {
// Backwards compatibility
if ( typeof b !== 'object' ) {
b = {
@@ -20,11 +23,10 @@
tagOpen: tagOpen,
tagClose: tagClose,
sampleText: sampleText,
- imageId: imageId,
- selectText: selectText
+ imageId: imageId
};
}
- var $image = $( '<img>', {
+ var $image = $( '<img>' ).attr( {
width : 23,
height: 22,
src : b.imageFile,
@@ -33,30 +35,43 @@
id : b.imageId || undefined,
'class': 'mw-toolbar-editbutton'
} ).click( function () {
- toolbar.insertTags( b.tagOpen, b.tagClose, b.sampleText, b.selectText );
+ toolbar.insertTags( b.tagOpen, b.tagClose, b.sampleText );
return false;
} );
$toolbar.append( $image );
- return true;
}
+ isReady = false;
+ $toolbar = false;
+ /**
+ * @private
+ * @property {Array}
+ * Contains button objects (and for backwards compatibilty, it can
+ * also contains an arguments array for insertButton).
+ */
+ queue = [];
+ slice = queue.slice;
+
toolbar = {
+
/**
* Add buttons to the toolbar.
+ *
* Takes care of race conditions and time-based dependencies
* by placing buttons in a queue if this method is called before
* the toolbar is created.
- * @param {Object} button: Object with the following properties:
- * - imageFile
- * - speedTip
- * - tagOpen
- * - tagClose
- * - sampleText
- * - imageId
- * - selectText
- * For compatiblity, passing the above as separate arguments
+ *
+ * For compatiblity, passing the properties listed below as separate arguments
* (in the listed order) is also supported.
+ *
+ * @param {Object} button Object with the following properties:
+ * @param {string} button.imageFile
+ * @param {string} button.speedTip
+ * @param {string} button.tagOpen
+ * @param {string} button.tagClose
+ * @param {string} button.sampleText
+ * @param {string} [button.imageId]
*/
addButton: function () {
if ( isReady ) {
@@ -66,18 +81,44 @@
queue.push( slice.call( arguments ) );
}
},
+ /**
+ * Example usage:
+ * addButtons( [ { .. }, { .. }, { .. } ] );
+ * addButtons( { .. }, { .. } );
+ *
+ * @param {Object|Array} [buttons...] An array of button objects or the first
+ * button object in a list of variadic arguments.
+ */
+ addButtons: function ( buttons ) {
+ if ( !$.isArray( buttons ) ) {
+ buttons = slice.call( arguments );
+ }
+ if ( isReady ) {
+ $.each( buttons, function () {
+ insertButton( this );
+ } );
+ } else {
+ // Push each button into the queue
+ queue.push.apply( queue, buttons );
+ }
+ },
/**
- * Apply tagOpen/tagClose to selection in textarea,
- * use sampleText instead of selection if there is none.
+ * Apply tagOpen/tagClose to selection in currently focused textarea.
+ *
+ * Uses `sampleText` if selection is empty.
+ *
+ * @param {string} tagOpen
+ * @param {string} tagClose
+ * @param {string} sampleText
*/
insertTags: function ( tagOpen, tagClose, sampleText ) {
- if ( currentFocused && currentFocused.length ) {
- currentFocused.textSelection(
+ if ( $currentFocused && $currentFocused.length ) {
+ $currentFocused.textSelection(
'encapsulateSelection', {
- 'pre': tagOpen,
- 'peri': sampleText,
- 'post': tagClose
+ pre: tagOpen,
+ peri: sampleText,
+ post: tagClose
}
);
}
@@ -95,64 +136,58 @@
// Explose API publicly
mw.toolbar = toolbar;
- $( document ).ready( function () {
- var buttons, i, b, $iframe;
+ $( function () {
+ var i, b, $iframe, editBox, scrollTop, $editForm;
// currentFocus is used to determine where to insert tags
- currentFocused = $( '#wpTextbox1' );
+ $currentFocused = $( '#wpTextbox1' );
// Populate the selector cache for $toolbar
$toolbar = $( '#toolbar' );
- // Legacy: Merge buttons from mwCustomEditButtons
- buttons = [].concat( queue, window.mwCustomEditButtons );
- // Clear queue
- queue.length = 0;
- for ( i = 0; i < buttons.length; i++ ) {
- b = buttons[i];
+ for ( i = 0; i < queue.length; i++ ) {
+ b = queue[i];
if ( $.isArray( b ) ) {
// Forwarded arguments array from mw.toolbar.addButton
insertButton.apply( toolbar, b );
} else {
- // Raw object from legacy mwCustomEditButtons
+ // Raw object from mw.toolbar.addButtons
insertButton( b );
}
}
+ // Clear queue
+ queue.length = 0;
+
// This causes further calls to addButton to go to insertion directly
- // instead of to the toolbar.buttons queue.
+ // instead of to the queue.
// It is important that this is after the one and only loop through
- // the the toolbar.buttons queue
+ // the the queue
isReady = true;
// Make sure edit summary does not exceed byte limit
$( '#wpSummary' ).byteLimit( 255 );
- /**
- * Restore the edit box scroll state following a preview operation,
- * and set up a form submission handler to remember this state
- */
- ( function scrollEditBox() {
- var editBox, scrollTop, $editForm;
-
- editBox = document.getElementById( 'wpTextbox1' );
- scrollTop = document.getElementById( 'wpScrolltop' );
- $editForm = $( '#editform' );
- if ( $editForm.length && editBox && scrollTop ) {
- if ( scrollTop.value ) {
- editBox.scrollTop = scrollTop.value;
- }
- $editForm.submit( function () {
- scrollTop.value = editBox.scrollTop;
- });
+ // Restore the edit box scroll state following a preview operation,
+ // and set up a form submission handler to remember this state.
+ editBox = document.getElementById( 'wpTextbox1' );
+ scrollTop = document.getElementById( 'wpScrolltop' );
+ $editForm = $( '#editform' );
+ if ( $editForm.length && editBox && scrollTop ) {
+ if ( scrollTop.value ) {
+ editBox.scrollTop = scrollTop.value;
}
- }() );
+ $editForm.submit( function () {
+ scrollTop.value = editBox.scrollTop;
+ });
+ }
- $( 'textarea, input:text' ).focus( function () {
- currentFocused = $(this);
- });
+ // Apply to dynamically created textboxes as well as normal ones
+ $( document ).on( 'focus', 'textarea, input:text', function () {
+ $currentFocused = $( this );
+ } );
- // HACK: make currentFocused work with the usability iframe
+ // HACK: make $currentFocused work with the usability iframe
// With proper focus detection support (HTML 5!) this'll be much cleaner
// TODO: Get rid of this WikiEditor code from MediaWiki core!
$iframe = $( '.wikiEditor-ui-text iframe' );
@@ -161,7 +196,7 @@
// for IE
.add( $iframe.get( 0 ).contentWindow.document.body )
.focus( function () {
- currentFocused = $iframe;
+ $currentFocused = $iframe;
} );
}
});
diff --git a/resources/mediawiki.action/mediawiki.action.edit.preview.js b/resources/mediawiki.action/mediawiki.action.edit.preview.js
index 602aadb0..c5cd61ef 100644
--- a/resources/mediawiki.action/mediawiki.action.edit.preview.js
+++ b/resources/mediawiki.action/mediawiki.action.edit.preview.js
@@ -7,14 +7,16 @@
* @param {jQuery.Event} e
*/
function doLivePreview( e ) {
- var $wikiPreview, copySelectors, removeSelectors, $copyElements, $spinner,
+ var $wikiPreview, $editform, copySelectors, $copyElements, $spinner,
targetUrl, postData, $previewDataHolder;
e.preventDefault();
+ // Deprecated: Use mw.hook instead
$( mw ).trigger( 'LivePreviewPrepare' );
$wikiPreview = $( '#wikiPreview' );
+ $editform = $( '#editform' );
// Show #wikiPreview if it's hidden to be able to scroll to it
// (if it is hidden, it's also empty, so nothing changes in the rendering)
@@ -34,16 +36,13 @@
'#p-lang',
// Editing-related
'.templatesUsed',
+ '.limitreport',
'.mw-summary-preview'
];
$copyElements = $( copySelectors.join( ',' ) );
// Not shown during normal preview, to be removed if present
- removeSelectors = [
- '.mw-newarticletext'
- ];
-
- $( removeSelectors.join( ',' ) ).remove();
+ $( '.mw-newarticletext' ).remove();
$spinner = $.createSpinner( {
size: 'large',
@@ -51,36 +50,29 @@
});
$wikiPreview.before( $spinner );
$spinner.css( {
- position: 'absolute',
marginTop: $spinner.height()
} );
- // Make sure preview area is at least as tall as 2x the height of the spinner.
- // 1x because if its smaller, it will spin behind the edit toolbar.
- // (this happens on the first preview when editPreview is still empty)
- // 2x because the spinner has 1x margin top breathing room.
- $wikiPreview.css( 'minHeight', $spinner.height() * 2 );
// Can't use fadeTo because it calls show(), and we might want to keep some elements hidden
// (e.g. empty #catlinks)
- $copyElements.animate( {
- opacity: 0.4
- }, 'fast' );
+ $copyElements.animate( { opacity: 0.4 }, 'fast' );
$previewDataHolder = $( '<div>' );
- targetUrl = $( '#editform' ).attr( 'action' );
+ targetUrl = $editform.attr( 'action' );
// Gather all the data from the form
- postData = $( '#editform' ).formToArray();
+ postData = $editform.formToArray();
postData.push( {
name: e.target.name,
value: ''
} );
// Load new preview data.
- // TODO: This should use the action=parse API instead of loading the entire page
- // Though that requires figuring out how to conver that raw data into proper HTML.
+ // TODO: This should use the action=parse API instead of loading the entire page,
+ // although that requires figuring out how to convert that raw data into proper HTML.
$previewDataHolder.load( targetUrl + ' ' + copySelectors.join( ',' ), postData, function () {
var i, $from;
+
// Copy the contents of the specified elements from the loaded page to the real page.
// Also copy their class attributes.
for ( i = 0; i < copySelectors.length; i++ ) {
@@ -92,16 +84,19 @@
.attr( 'class', $from.attr( 'class' ) );
}
+ // Deprecated: Use mw.hook instead
+ $( mw ).trigger( 'LivePreviewDone', [copySelectors] );
+
+ mw.hook( 'wikipage.content' ).fire( $wikiPreview );
+
$spinner.remove();
$copyElements.animate( {
opacity: 1
}, 'fast' );
-
- $( mw ).trigger( 'LivePreviewDone', [copySelectors] );
} );
}
- $( document ).ready( function () {
+ $( function () {
// Do not enable on user .js/.css pages, as there's no sane way of "previewing"
// the scripts or styles without reloading the page.
if ( $( '#mw-userjsyoucanpreview' ).length || $( '#mw-usercssyoucanpreview' ).length ) {
@@ -109,32 +104,32 @@
}
// The following elements can change in a preview but are not output
- // by the server when they're empty until the preview reponse.
+ // by the server when they're empty until the preview response.
// TODO: Make the server output these always (in a hidden state), so we don't
// have to fish and (hopefully) put them in the right place (since skins
// can change where they are output).
if ( !document.getElementById( 'p-lang' ) && document.getElementById( 'p-tb' ) ) {
$( '#p-tb' ).after(
- $( '<div>' ).prop( 'id', 'p-lang' )
+ $( '<div>' ).attr( 'id', 'p-lang' )
);
}
if ( !$( '.mw-summary-preview' ).length ) {
$( '.editCheckboxes' ).before(
- $( '<div>' ).prop( 'className', 'mw-summary-preview' )
+ $( '<div>' ).addClass( 'mw-summary-preview' )
);
}
if ( !document.getElementById( 'wikiDiff' ) && document.getElementById( 'wikiPreview' ) ) {
$( '#wikiPreview' ).after(
- $( '<div>' ).prop( 'id', 'wikiDiff')
+ $( '<div>' ).attr( 'id', 'wikiDiff' )
);
}
- // Make sure diff styles are loaded
- mw.loader.load( 'mediawiki.action.history.diff' );
-
+ // This should be moved down to '#editform', but is kept on the body for now
+ // because the LiquidThreads extension is re-using this module with only half
+ // the EditPage (doesn't include #editform presumably, bug 55463).
$( document.body ).on( 'click', '#wpPreview, #wpDiff', doLivePreview );
} );
diff --git a/resources/mediawiki.action/mediawiki.action.edit.styles.css b/resources/mediawiki.action/mediawiki.action.edit.styles.css
new file mode 100644
index 00000000..4a2bab3d
--- /dev/null
+++ b/resources/mediawiki.action/mediawiki.action.edit.styles.css
@@ -0,0 +1,44 @@
+/**
+ * Styles for elements of the editing form.
+ */
+
+/* General layout */
+#wpTextbox1 {
+ margin: 0;
+ display: block;
+}
+
+.editOptions {
+ background-color: #F0F0F0;
+ border: 1px solid silver;
+ border-top: none;
+ padding: 1em 1em 1.5em 1em;
+ margin-bottom: 2em;
+}
+
+/* Adjustments to edit form elements */
+.editCheckboxes {
+ margin-bottom: 1em;
+}
+
+.editCheckboxes input:first-child {
+ margin-left: 0;
+}
+
+.cancelLink {
+ margin-left: 0.5em;
+}
+
+#editpage-copywarn {
+ font-size: 0.9em;
+}
+
+#wpSummary {
+ display: block;
+ margin-top: 0;
+ margin-bottom: 0.5em;
+}
+
+.editButtons input:first-child {
+ margin-left: .1em;
+}
diff --git a/resources/mediawiki.action/mediawiki.action.history.js b/resources/mediawiki.action/mediawiki.action.history.js
index e9d320c1..04f045a5 100644
--- a/resources/mediawiki.action/mediawiki.action.history.js
+++ b/resources/mediawiki.action/mediawiki.action.history.js
@@ -1,7 +1,7 @@
/**
* JavaScript for History action
*/
-jQuery( document ).ready( function ( $ ) {
+jQuery( function ( $ ) {
var $historyCompareForm = $( '#mw-history-compare' ),
$historySubmitter,
$lis = $( '#pagehistory > li' );
diff --git a/resources/mediawiki.action/mediawiki.action.view.postEdit.css b/resources/mediawiki.action/mediawiki.action.view.postEdit.css
new file mode 100644
index 00000000..be88337e
--- /dev/null
+++ b/resources/mediawiki.action/mediawiki.action.view.postEdit.css
@@ -0,0 +1,77 @@
+.postedit-container {
+ margin: 0 auto;
+ position: fixed;
+ top: 0;
+ height: 0;
+ left: 50%;
+ z-index: 1000;
+ font-size: 13px;
+}
+
+.postedit-container:hover {
+ cursor: pointer;
+}
+
+.postedit {
+ position: relative;
+ top: 0.6em;
+ left: -50%;
+ padding: .6em 3.6em .6em 1.1em;
+ line-height: 1.5625em;
+ color: #626465;
+ background-color: #f4f4f4;
+ border: 1px solid #dcd9d9;
+ text-shadow: 0 0.0625em 0 rgba(255, 255, 255, 0.5);
+ border-radius: 5px;
+ -webkit-box-shadow: 0 2px 5px 0 #ccc;
+ box-shadow: 0 2px 5px 0 #ccc;
+ -webkit-transition: all 0.25s ease-in-out;
+ -moz-transition: all 0.25s ease-in-out;
+ -ms-transition: all 0.25s ease-in-out;
+ -o-transition: all 0.25s ease-in-out;
+ transition: all 0.25s ease-in-out;
+}
+
+.skin-monobook .postedit {
+ top: 6em !important;
+}
+
+.postedit-faded {
+ opacity: 0;
+}
+
+.postedit-icon {
+ padding-left: 41px; /* 25 + 8 + 8 */
+ /* like min-height, but old IE compatible and keeps text vertically aligned, too */
+ line-height: 25px;
+ background-repeat: no-repeat;
+ background-position: 8px 50%;
+}
+
+.postedit-icon-checkmark {
+ /* @embed */
+ background-image: url(images/green-checkmark.png);
+ background-position: left;
+}
+
+.postedit-close {
+ position: absolute;
+ padding: 0 .8em;
+ right: 0;
+ top: 0;
+ font-size: 1.25em;
+ font-weight: bold;
+ line-height: 2.3em;
+ color: black;
+ text-shadow: 0 0.0625em 0 white;
+ text-decoration: none;
+ opacity: 0.2;
+ filter: alpha(opacity=20);
+}
+
+.postedit-close:hover {
+ color: black;
+ text-decoration: none;
+ opacity: 0.4;
+ filter: alpha(opacity=40);
+}
diff --git a/resources/mediawiki.action/mediawiki.action.view.postEdit.js b/resources/mediawiki.action/mediawiki.action.view.postEdit.js
index a11233fa..6e4df9f0 100644
--- a/resources/mediawiki.action/mediawiki.action.view.postEdit.js
+++ b/resources/mediawiki.action/mediawiki.action.view.postEdit.js
@@ -1,15 +1,76 @@
( function ( mw, $ ) {
- // Only a view can be a post-edit.
- if ( mw.config.get( 'wgAction' ) !== 'view' ) {
- return;
+ 'use strict';
+
+ /**
+ * @event postEdit
+ * @member mw.hook
+ * @param {Object} [data] Optional data
+ * @param {string|jQuery|Array} [data.message] Message that listeners
+ * should use when displaying notifications. String for plain text,
+ * use array or jQuery object to pass actual nodes.
+ * @param {string|mw.user} [data.user=mw.user] User that made the edit.
+ */
+
+ /**
+ * After the listener for #postEdit removes the notification.
+ *
+ * @event postEdit_afterRemoval
+ * @member mw.hook
+ */
+
+ var config = mw.config.get( [ 'wgAction', 'wgCookiePrefix', 'wgCurRevisionId' ] ),
+ // This should match EditPage::POST_EDIT_COOKIE_KEY_PREFIX:
+ cookieKey = config.wgCookiePrefix + 'PostEditRevision' + config.wgCurRevisionId,
+ $div, id;
+
+ function showConfirmation( data ) {
+ data = data || {};
+ if ( data.message === undefined ) {
+ data.message = $.parseHTML( mw.message( 'postedit-confirmation', data.user || mw.user ).escaped() );
+ }
+
+ $div = $(
+ '<div class="postedit-container">' +
+ '<div class="postedit">' +
+ '<div class="postedit-icon postedit-icon-checkmark postedit-content"></div>' +
+ '<a href="#" class="postedit-close">&times;</a>' +
+ '</div>' +
+ '</div>'
+ );
+
+ if ( typeof data.message === 'string' ) {
+ $div.find( '.postedit-content' ).text( data.message );
+ } else if ( typeof data.message === 'object' ) {
+ $div.find( '.postedit-content' ).append( data.message );
+ }
+
+ $div
+ .click( fadeOutConfirmation )
+ .prependTo( 'body' );
+
+ id = setTimeout( fadeOutConfirmation, 3000 );
}
- // Matches EditPage::POST_EDIT_COOKIE_KEY_PREFIX
- var cookieKey = mw.config.get( 'wgCookiePrefix' ) + 'PostEditRevision' + mw.config.get( 'wgCurRevisionId' );
+ function fadeOutConfirmation() {
+ clearTimeout( id );
+ $div.find( '.postedit' ).addClass( 'postedit postedit-faded' );
+ setTimeout( removeConfirmation, 500 );
- if ( $.cookie( cookieKey ) === '1' ) {
- // We just saved this page
+ return false;
+ }
+
+ function removeConfirmation() {
+ $div.remove();
+ mw.hook( 'postEdit.afterRemoval' ).fire();
+ }
+
+ mw.hook( 'postEdit' ).add( showConfirmation );
+
+ if ( config.wgAction === 'view' && $.cookie( cookieKey ) === '1' ) {
$.cookie( cookieKey, null, { path: '/' } );
mw.config.set( 'wgPostEdit', true );
+
+ mw.hook( 'postEdit' ).fire();
}
+
} ( mediaWiki, jQuery ) );
diff --git a/resources/mediawiki.action/mediawiki.action.view.rightClickEdit.js b/resources/mediawiki.action/mediawiki.action.view.rightClickEdit.js
index 61d9d150..93befe3a 100644
--- a/resources/mediawiki.action/mediawiki.action.view.rightClickEdit.js
+++ b/resources/mediawiki.action/mediawiki.action.view.rightClickEdit.js
@@ -5,10 +5,10 @@
*/
jQuery( function ( $ ) {
// Select all h1-h6 elements that contain editsection links
- // Don't use the ":has:(.editsection a)" selector because it performs very bad.
+ // Don't use the ":has:(.mw-editsection a)" selector because it performs very bad.
// http://jsperf.com/jq-1-7-2-vs-jq-1-8-1-performance-of-mw-has/2
$( document ).on( 'contextmenu', 'h1, h2, h3, h4, h5, h6', function ( e ) {
- var $edit = $( this ).find( '.editsection a' );
+ var $edit = $( this ).find( '.mw-editsection a' );
if ( !$edit.length ) {
return;
}