summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/SemanticMediaWiki/res/smw/util/ext.smw.util.purge.js
diff options
context:
space:
mode:
Diffstat (limited to 'www/wiki/extensions/SemanticMediaWiki/res/smw/util/ext.smw.util.purge.js')
-rw-r--r--www/wiki/extensions/SemanticMediaWiki/res/smw/util/ext.smw.util.purge.js42
1 files changed, 42 insertions, 0 deletions
diff --git a/www/wiki/extensions/SemanticMediaWiki/res/smw/util/ext.smw.util.purge.js b/www/wiki/extensions/SemanticMediaWiki/res/smw/util/ext.smw.util.purge.js
new file mode 100644
index 00000000..52701fd0
--- /dev/null
+++ b/www/wiki/extensions/SemanticMediaWiki/res/smw/util/ext.smw.util.purge.js
@@ -0,0 +1,42 @@
+/*!
+ * This file is part of the Semantic MediaWiki Purge module
+ * @see https://www.semantic-mediawiki.org/wiki/Help:Purge
+ *
+ * @since 2.5
+ * @revision 0.0.1
+ *
+ * @file
+ * @ingroup SMW
+ *
+ * @licence GNU GPL v2+
+ * @author samwilson, mwjames
+ */
+
+/*global jQuery, mediaWiki, smw */
+/*jslint white: true */
+
+( function( $, mw ) {
+
+ 'use strict';
+
+ mw.loader.using( [ 'mediawiki.api', 'mediawiki.notify' ] ).then( function () {
+
+ // JS is loaded, now remove the "soft" disabled functionality
+ $( "#ca-purge" ).removeClass( 'is-disabled' );
+
+ // Observed on the chameleon skin
+ $( "#ca-purge a" ).removeClass( 'is-disabled' );
+
+ $( "#ca-purge a" ).on( 'click', function ( e ) {
+ var postArgs = { action: 'purge', titles: mw.config.get( 'wgPageName' ) };
+ new mw.Api().post( postArgs ).then( function () {
+ location.reload();
+ }, function () {
+ mw.notify( mw.msg( 'smw-purge-failed' ), { type: 'error' } );
+ } );
+ e.preventDefault();
+ } );
+
+ } );
+
+}( jQuery, mediaWiki ) );