From b1dea1d957833d1965999c350a05d365ba56adba Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bartosz=20Dziewo=C5=84ski?= Date: Thu, 28 Aug 2014 18:11:03 +0200 Subject: [PATCH] Move mediawiki.legacy.* modules from skins/common/ to resources/ Also renamed some image files for consistency and sanity. Added temporary symlinks to the new location for ajax.js and wikibits.js, which still seem to get many hits for unknown reasons. I'm going to figure this out and remove them before 1.24 release. shared.css also appears in the access logs from bug 69277, but with many fewer hits (it might just correspond to debug=true requests) and failing to load a style file is a lot less problematic from user's perspective than failing to load a script. Bug: 69277 Change-Id: Id4a8f9470d287c73309ff526ffb88984e2d351b9 --- docs/uidesign/design.html | 2 +- resources/Resources.php | 30 +-- resources/src/mediawiki.legacy/ajax.js | 194 +++++++++++++++++ .../src/mediawiki.legacy}/commonPrint.css | 0 .../mediawiki.legacy}/images/ajax-loader.gif | Bin .../src/mediawiki.legacy/images/checker.png | Bin .../mediawiki.legacy}/images/feed-icon.png | Bin .../mediawiki.legacy}/images/feed-icon.svg | 0 .../images/help-question-hover.gif | Bin .../images/help-question.gif | Bin .../src/mediawiki.legacy/images/question.png | Bin .../src/mediawiki.legacy}/images/question.svg | 0 .../src/mediawiki.legacy}/images/spinner.gif | Bin .../src/mediawiki.legacy}/oldshared.css | 0 .../src/mediawiki.legacy}/protect.js | 0 .../src/mediawiki.legacy}/shared.css | 4 +- .../src/mediawiki.legacy}/upload.js | 0 resources/src/mediawiki.legacy/wikibits.js | 201 +++++++++++++++++ skins/common/ajax.js | 195 +---------------- skins/common/wikibits.js | 202 +----------------- 20 files changed, 408 insertions(+), 420 deletions(-) create mode 100644 resources/src/mediawiki.legacy/ajax.js rename {skins/common => resources/src/mediawiki.legacy}/commonPrint.css (100%) rename {skins/common => resources/src/mediawiki.legacy}/images/ajax-loader.gif (100%) rename skins/common/images/Checker-16x16.png => resources/src/mediawiki.legacy/images/checker.png (100%) rename {skins/common => resources/src/mediawiki.legacy}/images/feed-icon.png (100%) rename {skins/common => resources/src/mediawiki.legacy}/images/feed-icon.svg (100%) rename {skins/common => resources/src/mediawiki.legacy}/images/help-question-hover.gif (100%) rename {skins/common => resources/src/mediawiki.legacy}/images/help-question.gif (100%) rename skins/common/images/question-small.png => resources/src/mediawiki.legacy/images/question.png (100%) rename {skins/common => resources/src/mediawiki.legacy}/images/question.svg (100%) rename {skins/common => resources/src/mediawiki.legacy}/images/spinner.gif (100%) rename {skins/common => resources/src/mediawiki.legacy}/oldshared.css (100%) rename {skins/common => resources/src/mediawiki.legacy}/protect.js (100%) rename {skins/common => resources/src/mediawiki.legacy}/shared.css (99%) rename {skins/common => resources/src/mediawiki.legacy}/upload.js (100%) create mode 100644 resources/src/mediawiki.legacy/wikibits.js mode change 100644 => 120000 skins/common/ajax.js mode change 100644 => 120000 skins/common/wikibits.js diff --git a/docs/uidesign/design.html b/docs/uidesign/design.html index a285a5b22f..51c1b55204 100644 --- a/docs/uidesign/design.html +++ b/docs/uidesign/design.html @@ -1,7 +1,7 @@ - + diff --git a/resources/Resources.php b/resources/Resources.php index 4a9827a2a0..3dc831b3c5 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -1407,24 +1407,18 @@ return array( /* MediaWiki Legacy */ 'mediawiki.legacy.ajax' => array( - 'scripts' => 'common/ajax.js', - 'remoteBasePath' => $GLOBALS['wgStylePath'], - 'localBasePath' => $GLOBALS['wgStyleDirectory'], + 'scripts' => 'resources/src/mediawiki.legacy/ajax.js', 'dependencies' => array( 'mediawiki.util', 'mediawiki.legacy.wikibits', ), - 'position' => 'top', // Temporary hack for legacy support + 'position' => 'top', ), 'mediawiki.legacy.commonPrint' => array( - 'styles' => array( 'common/commonPrint.css' => array( 'media' => 'print' ) ), - 'remoteBasePath' => $GLOBALS['wgStylePath'], - 'localBasePath' => $GLOBALS['wgStyleDirectory'], + 'styles' => array( 'resources/src/mediawiki.legacy/commonPrint.css' => array( 'media' => 'print' ) ), ), 'mediawiki.legacy.protect' => array( - 'scripts' => 'common/protect.js', - 'remoteBasePath' => $GLOBALS['wgStylePath'], - 'localBasePath' => $GLOBALS['wgStyleDirectory'], + 'scripts' => 'resources/src/mediawiki.legacy/protect.js', 'dependencies' => array( 'jquery.byteLimit', ), @@ -1432,19 +1426,13 @@ return array( ), 'mediawiki.legacy.shared' => array( // Used in the web installer. Test it after modifying this definition! - 'styles' => array( 'common/shared.css' => array( 'media' => 'screen' ) ), - 'remoteBasePath' => $GLOBALS['wgStylePath'], - 'localBasePath' => $GLOBALS['wgStyleDirectory'], + 'styles' => array( 'resources/src/mediawiki.legacy/shared.css' => array( 'media' => 'screen' ) ), ), 'mediawiki.legacy.oldshared' => array( - 'styles' => array( 'common/oldshared.css' => array( 'media' => 'screen' ) ), - 'remoteBasePath' => $GLOBALS['wgStylePath'], - 'localBasePath' => $GLOBALS['wgStyleDirectory'], + 'styles' => array( 'resources/src/mediawiki.legacy/oldshared.css' => array( 'media' => 'screen' ) ), ), 'mediawiki.legacy.upload' => array( - 'scripts' => 'common/upload.js', - 'remoteBasePath' => $GLOBALS['wgStylePath'], - 'localBasePath' => $GLOBALS['wgStyleDirectory'], + 'scripts' => 'resources/src/mediawiki.legacy/upload.js', 'dependencies' => array( 'jquery.spinner', 'mediawiki.api', @@ -1453,9 +1441,7 @@ return array( ), ), 'mediawiki.legacy.wikibits' => array( - 'scripts' => 'common/wikibits.js', - 'remoteBasePath' => $GLOBALS['wgStylePath'], - 'localBasePath' => $GLOBALS['wgStyleDirectory'], + 'scripts' => 'resources/src/mediawiki.legacy/wikibits.js', 'dependencies' => array( 'mediawiki.util', ), diff --git a/resources/src/mediawiki.legacy/ajax.js b/resources/src/mediawiki.legacy/ajax.js new file mode 100644 index 0000000000..6b9464a914 --- /dev/null +++ b/resources/src/mediawiki.legacy/ajax.js @@ -0,0 +1,194 @@ +/** + * Remote Scripting Library + * Copyright 2005 modernmethod, inc + * Under the open source BSD license + * http://www.modernmethod.com/sajax/ + */ + +/*jshint camelcase:false */ +/*global alert */ +( function ( mw ) { + +/** + * if sajax_debug_mode is true, this function outputs given the message into + * the element with id = sajax_debug; if no such element exists in the document, + * it is injected. + */ +function debug( text ) { + if ( !window.sajax_debug_mode ) { + return false; + } + + var b, m, + e = document.getElementById( 'sajax_debug' ); + + if ( !e ) { + e = document.createElement( 'p' ); + e.className = 'sajax_debug'; + e.id = 'sajax_debug'; + + b = document.getElementsByTagName( 'body' )[0]; + + if ( b.firstChild ) { + b.insertBefore( e, b.firstChild ); + } else { + b.appendChild( e ); + } + } + + m = document.createElement( 'div' ); + m.appendChild( document.createTextNode( text ) ); + + e.appendChild( m ); + + return true; +} + +/** + * Compatibility wrapper for creating a new XMLHttpRequest object. + */ +function createXhr() { + debug( 'sajax_init_object() called..' ); + var a; + try { + // Try the new style before ActiveX so we don't + // unnecessarily trigger warnings in IE 7 when + // set to prompt about ActiveX usage + a = new XMLHttpRequest(); + } catch ( xhrE ) { + try { + a = new window.ActiveXObject( 'Msxml2.XMLHTTP' ); + } catch ( msXmlE ) { + try { + a = new window.ActiveXObject( 'Microsoft.XMLHTTP' ); + } catch ( msXhrE ) { + a = null; + } + } + } + if ( !a ) { + debug( 'Could not create connection object.' ); + } + + return a; +} + +/** + * Perform an AJAX call to MediaWiki. Calls are handled by AjaxDispatcher.php + * func_name - the name of the function to call. Must be registered in $wgAjaxExportList + * args - an array of arguments to that function + * target - the target that will handle the result of the call. If this is a function, + * if will be called with the XMLHttpRequest as a parameter; if it's an input + * element, its value will be set to the resultText; if it's another type of + * element, its innerHTML will be set to the resultText. + * + * Example: + * sajax_do_call( 'doFoo', [1, 2, 3], document.getElementById( 'showFoo' ) ); + * + * This will call the doFoo function via MediaWiki's AjaxDispatcher, with + * (1, 2, 3) as the parameter list, and will show the result in the element + * with id = showFoo + */ +function doAjaxRequest( func_name, args, target ) { + var i, x, uri, post_data; + uri = mw.util.wikiScript() + '?action=ajax'; + if ( window.sajax_request_type === 'GET' ) { + if ( uri.indexOf( '?' ) === -1 ) { + uri = uri + '?rs=' + encodeURIComponent( func_name ); + } else { + uri = uri + '&rs=' + encodeURIComponent( func_name ); + } + for ( i = 0; i < args.length; i++ ) { + uri = uri + '&rsargs[]=' + encodeURIComponent( args[i] ); + } + //uri = uri + '&rsrnd=' + new Date().getTime(); + post_data = null; + } else { + post_data = 'rs=' + encodeURIComponent( func_name ); + for ( i = 0; i < args.length; i++ ) { + post_data = post_data + '&rsargs[]=' + encodeURIComponent( args[i] ); + } + } + x = createXhr(); + if ( !x ) { + alert( 'AJAX not supported' ); + return false; + } + + try { + x.open( window.sajax_request_type, uri, true ); + } catch ( e ) { + if ( location.hostname === 'localhost' ) { + alert( 'Your browser blocks XMLHttpRequest to "localhost", try using a real hostname for development/testing.' ); + } + throw e; + } + if ( window.sajax_request_type === 'POST' ) { + x.setRequestHeader( 'Method', 'POST ' + uri + ' HTTP/1.1' ); + x.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' ); + } + x.setRequestHeader( 'Pragma', 'cache=yes' ); + x.setRequestHeader( 'Cache-Control', 'no-transform' ); + x.onreadystatechange = function () { + if ( x.readyState !== 4 ) { + return; + } + + debug( 'received (' + x.status + ' ' + x.statusText + ') ' + x.responseText ); + + //if ( x.status != 200 ) + // alert( 'Error: ' + x.status + ' ' + x.statusText + ': ' + x.responseText ); + //else + + if ( typeof target === 'function' ) { + target( x ); + } else if ( typeof target === 'object' ) { + if ( target.tagName === 'INPUT' ) { + if ( x.status === 200 ) { + target.value = x.responseText; + } + //else alert( 'Error: ' + x.status + ' ' + x.statusText + ' (' + x.responseText + ')' ); + } else { + if ( x.status === 200 ) { + target.innerHTML = x.responseText; + } else { + target.innerHTML = '
Error: ' + x.status + + ' ' + x.statusText + ' (' + x.responseText + ')
'; + } + } + } else { + alert( 'Bad target for sajax_do_call: not a function or object: ' + target ); + } + }; + + debug( func_name + ' uri = ' + uri + ' / post = ' + post_data ); + x.send( post_data ); + debug( func_name + ' waiting..' ); + + return true; +} + +/** + * @return {boolean} Whether the browser supports AJAX + */ +function wfSupportsAjax() { + var request = createXhr(), + supportsAjax = request ? true : false; + + request = undefined; + return supportsAjax; +} + +// Expose + Mark as deprecated +var deprecationNotice = 'Sajax is deprecated, use jQuery.ajax or mediawiki.api instead.'; + +// Variables +mw.log.deprecate( window, 'sajax_debug_mode', false, deprecationNotice ); +mw.log.deprecate( window, 'sajax_request_type', 'GET', deprecationNotice ); +// Methods +mw.log.deprecate( window, 'sajax_debug', debug, deprecationNotice ); +mw.log.deprecate( window, 'sajax_init_object', createXhr, deprecationNotice ); +mw.log.deprecate( window, 'sajax_do_call', doAjaxRequest, deprecationNotice ); +mw.log.deprecate( window, 'wfSupportsAjax', wfSupportsAjax, deprecationNotice ); + +}( mediaWiki ) ); diff --git a/skins/common/commonPrint.css b/resources/src/mediawiki.legacy/commonPrint.css similarity index 100% rename from skins/common/commonPrint.css rename to resources/src/mediawiki.legacy/commonPrint.css diff --git a/skins/common/images/ajax-loader.gif b/resources/src/mediawiki.legacy/images/ajax-loader.gif similarity index 100% rename from skins/common/images/ajax-loader.gif rename to resources/src/mediawiki.legacy/images/ajax-loader.gif diff --git a/skins/common/images/Checker-16x16.png b/resources/src/mediawiki.legacy/images/checker.png similarity index 100% rename from skins/common/images/Checker-16x16.png rename to resources/src/mediawiki.legacy/images/checker.png diff --git a/skins/common/images/feed-icon.png b/resources/src/mediawiki.legacy/images/feed-icon.png similarity index 100% rename from skins/common/images/feed-icon.png rename to resources/src/mediawiki.legacy/images/feed-icon.png diff --git a/skins/common/images/feed-icon.svg b/resources/src/mediawiki.legacy/images/feed-icon.svg similarity index 100% rename from skins/common/images/feed-icon.svg rename to resources/src/mediawiki.legacy/images/feed-icon.svg diff --git a/skins/common/images/help-question-hover.gif b/resources/src/mediawiki.legacy/images/help-question-hover.gif similarity index 100% rename from skins/common/images/help-question-hover.gif rename to resources/src/mediawiki.legacy/images/help-question-hover.gif diff --git a/skins/common/images/help-question.gif b/resources/src/mediawiki.legacy/images/help-question.gif similarity index 100% rename from skins/common/images/help-question.gif rename to resources/src/mediawiki.legacy/images/help-question.gif diff --git a/skins/common/images/question-small.png b/resources/src/mediawiki.legacy/images/question.png similarity index 100% rename from skins/common/images/question-small.png rename to resources/src/mediawiki.legacy/images/question.png diff --git a/skins/common/images/question.svg b/resources/src/mediawiki.legacy/images/question.svg similarity index 100% rename from skins/common/images/question.svg rename to resources/src/mediawiki.legacy/images/question.svg diff --git a/skins/common/images/spinner.gif b/resources/src/mediawiki.legacy/images/spinner.gif similarity index 100% rename from skins/common/images/spinner.gif rename to resources/src/mediawiki.legacy/images/spinner.gif diff --git a/skins/common/oldshared.css b/resources/src/mediawiki.legacy/oldshared.css similarity index 100% rename from skins/common/oldshared.css rename to resources/src/mediawiki.legacy/oldshared.css diff --git a/skins/common/protect.js b/resources/src/mediawiki.legacy/protect.js similarity index 100% rename from skins/common/protect.js rename to resources/src/mediawiki.legacy/protect.js diff --git a/skins/common/shared.css b/resources/src/mediawiki.legacy/shared.css similarity index 99% rename from skins/common/shared.css rename to resources/src/mediawiki.legacy/shared.css index af5d82c073..34f084a323 100644 --- a/skins/common/shared.css +++ b/resources/src/mediawiki.legacy/shared.css @@ -179,7 +179,7 @@ table.filehistory td.filehistory-selected { .filehistory a img, #file img:hover { /* @embed */ - background: white url(images/Checker-16x16.png) repeat; + background: white url(images/checker.png) repeat; } /** @@ -244,7 +244,7 @@ td.mw-label { /* SVG support using a transparent gradient to guarantee cross-browser * compatibility (browsers able to understand gradient syntax support also SVG). * http://pauginer.tumblr.com/post/36614680636/invisible-gradient-technique */ - background-image: url(images/question-small.png); + background-image: url(images/question.png); /* @embed */ background-image: -webkit-linear-gradient(transparent, transparent), url(images/question.svg); /* @embed */ diff --git a/skins/common/upload.js b/resources/src/mediawiki.legacy/upload.js similarity index 100% rename from skins/common/upload.js rename to resources/src/mediawiki.legacy/upload.js diff --git a/resources/src/mediawiki.legacy/wikibits.js b/resources/src/mediawiki.legacy/wikibits.js new file mode 100644 index 0000000000..5c6e63b9ee --- /dev/null +++ b/resources/src/mediawiki.legacy/wikibits.js @@ -0,0 +1,201 @@ +/** + * MediaWiki legacy wikibits + */ +( function ( mw, $ ) { + var msg, + win = window, + ua = navigator.userAgent.toLowerCase(), + onloadFuncts = []; + +/** + * User-agent sniffing. + * + * @deprecated since 1.17 Use jquery.client instead + */ + +msg = 'Use feature detection or module jquery.client instead.'; + +mw.log.deprecate( win, 'clientPC', ua, msg ); + +// Ignored dummy values +mw.log.deprecate( win, 'is_gecko', false, msg ); +mw.log.deprecate( win, 'is_chrome_mac', false, msg ); +mw.log.deprecate( win, 'is_chrome', false, msg ); +mw.log.deprecate( win, 'webkit_version', false, msg ); +mw.log.deprecate( win, 'is_safari_win', false, msg ); +mw.log.deprecate( win, 'is_safari', false, msg ); +mw.log.deprecate( win, 'webkit_match', false, msg ); +mw.log.deprecate( win, 'is_ff2', false, msg ); +mw.log.deprecate( win, 'ff2_bugs', false, msg ); +mw.log.deprecate( win, 'is_ff2_win', false, msg ); +mw.log.deprecate( win, 'is_ff2_x11', false, msg ); +mw.log.deprecate( win, 'opera95_bugs', false, msg ); +mw.log.deprecate( win, 'opera7_bugs', false, msg ); +mw.log.deprecate( win, 'opera6_bugs', false, msg ); +mw.log.deprecate( win, 'is_opera_95', false, msg ); +mw.log.deprecate( win, 'is_opera_preseven', false, msg ); +mw.log.deprecate( win, 'is_opera', false, msg ); +mw.log.deprecate( win, 'ie6_bugs', false, msg ); + +/** + * DOM utilities for handling of events, text nodes and selecting elements + * + * @deprecated since 1.17 Use jQuery instead + */ +msg = 'Use jQuery instead.'; + +// Ignored dummy values +mw.log.deprecate( win, 'doneOnloadHook', undefined, msg ); +mw.log.deprecate( win, 'onloadFuncts', [], msg ); +mw.log.deprecate( win, 'runOnloadHook', $.noop, msg ); +mw.log.deprecate( win, 'changeText', $.noop, msg ); +mw.log.deprecate( win, 'killEvt', $.noop, msg ); +mw.log.deprecate( win, 'addHandler', $.noop, msg ); +mw.log.deprecate( win, 'hookEvent', $.noop, msg ); +mw.log.deprecate( win, 'addClickHandler', $.noop, msg ); +mw.log.deprecate( win, 'removeHandler', $.noop, msg ); +mw.log.deprecate( win, 'getElementsByClassName', function () { return []; }, msg ); +mw.log.deprecate( win, 'getInnerText', function () { return ''; }, msg ); + +// Run a function after the window onload event is fired +mw.log.deprecate( win, 'addOnloadHook', function ( hookFunct ) { + if ( onloadFuncts ) { + onloadFuncts.push(hookFunct); + } else { + // If func queue is gone the event has happened already, + // run immediately instead of queueing. + hookFunct(); + } +}, msg ); + +$( win ).on( 'load', function () { + var i, functs; + + // Don't run twice + if ( !onloadFuncts ) { + return; + } + + // Deference and clear onloadFuncts before running any + // hooks to make sure we don't miss any addOnloadHook + // calls. + functs = onloadFuncts.slice(); + onloadFuncts = undefined; + + // Execute the queued functions + for ( i = 0; i < functs.length; i++ ) { + functs[i](); + } +} ); + +/** + * Toggle checkboxes with shift selection + * + * @deprecated since 1.17 Use jquery.checkboxShiftClick instead + */ +msg = 'Use jquery.checkboxShiftClick instead.'; +mw.log.deprecate( win, 'checkboxes', [], msg ); +mw.log.deprecate( win, 'lastCheckbox', null, msg ); +mw.log.deprecate( win, 'setupCheckboxShiftClick', $.noop, msg ); +mw.log.deprecate( win, 'addCheckboxClickHandlers', $.noop, msg ); +mw.log.deprecate( win, 'checkboxClickHandler', $.noop, msg ); + +/** + * Add a button to the default editor toolbar + * + * @deprecated since 1.17 Use mw.toolbar instead + */ +mw.log.deprecate( win, 'mwEditButtons', [], 'Use mw.toolbar instead.' ); +mw.log.deprecate( win, 'mwCustomEditButtons', [], 'Use mw.toolbar instead.' ); + +/** + * Spinner creation, injection and removal + * + * @deprecated since 1.18 Use jquery.spinner instead + */ +mw.log.deprecate( win, 'injectSpinner', $.noop, 'Use jquery.spinner instead.' ); +mw.log.deprecate( win, 'removeSpinner', $.noop, 'Use jquery.spinner instead.' ); + +/** + * Escape utilities + * + * @deprecated since 1.18 Use mw.html instead + */ +mw.log.deprecate( win, 'escapeQuotes', $.noop, 'Use mw.html instead.' ); +mw.log.deprecate( win, 'escapeQuotesHTML', $.noop, 'Use mw.html instead.' ); + +/** + * Display a message to the user + * + * @deprecated since 1.17 Use mediawiki.notify instead + * @param {string|HTMLElement} message To be put inside the message box + */ +mw.log.deprecate( win, 'jsMsg', function ( message ) { + if ( !arguments.length || message === '' || message === null ) { + return true; + } + if ( typeof message !== 'object' ) { + message = $.parseHTML( message ); + } + mw.notify( message, { autoHide: true, tag: 'legacy' } ); + return true; +}, 'Use mediawiki.notify instead.' ); + +/** + * Misc. utilities + * + * @deprecated since 1.17 Use mediawiki.util instead + */ +msg = 'Use mediawiki.util instead.'; +mw.log.deprecate( win, 'updateTooltipAccessKeys', mw.util.updateTooltipAccessKeys, msg ); +mw.log.deprecate( win, 'addPortletLink', mw.util.addPortletLink, msg ); +mw.log.deprecate( win, 'appendCSS', mw.util.addCSS, msg ); +msg = 'Use jquery.accessKeyLabel instead.'; +mw.log.deprecate( win, 'tooltipAccessKeyPrefix', 'alt-', msg ); +mw.log.deprecate( win, 'tooltipAccessKeyRegexp', /\[(alt-)?(.)\]$/, msg ); + +/** + * Wikipage import methods + */ + +// included-scripts tracker +win.loadedScripts = {}; + +win.importScript = function ( page ) { + var uri = mw.config.get( 'wgScript' ) + '?title=' + + mw.util.wikiUrlencode( page ) + + '&action=raw&ctype=text/javascript'; + return win.importScriptURI( uri ); +}; + +win.importScriptURI = function ( url ) { + if ( win.loadedScripts[url] ) { + return null; + } + win.loadedScripts[url] = true; + var s = document.createElement( 'script' ); + s.setAttribute( 'src', url ); + s.setAttribute( 'type', 'text/javascript' ); + document.getElementsByTagName( 'head' )[0].appendChild( s ); + return s; +}; + +win.importStylesheet = function ( page ) { + var uri = mw.config.get( 'wgScript' ) + '?title=' + + mw.util.wikiUrlencode( page ) + + '&action=raw&ctype=text/css'; + return win.importStylesheetURI( uri ); +}; + +win.importStylesheetURI = function ( url, media ) { + var l = document.createElement( 'link' ); + l.rel = 'stylesheet'; + l.href = url; + if ( media ) { + l.media = media; + } + document.getElementsByTagName('head')[0].appendChild( l ); + return l; +}; + +}( mediaWiki, jQuery ) ); diff --git a/skins/common/ajax.js b/skins/common/ajax.js deleted file mode 100644 index 6b9464a914..0000000000 --- a/skins/common/ajax.js +++ /dev/null @@ -1,194 +0,0 @@ -/** - * Remote Scripting Library - * Copyright 2005 modernmethod, inc - * Under the open source BSD license - * http://www.modernmethod.com/sajax/ - */ - -/*jshint camelcase:false */ -/*global alert */ -( function ( mw ) { - -/** - * if sajax_debug_mode is true, this function outputs given the message into - * the element with id = sajax_debug; if no such element exists in the document, - * it is injected. - */ -function debug( text ) { - if ( !window.sajax_debug_mode ) { - return false; - } - - var b, m, - e = document.getElementById( 'sajax_debug' ); - - if ( !e ) { - e = document.createElement( 'p' ); - e.className = 'sajax_debug'; - e.id = 'sajax_debug'; - - b = document.getElementsByTagName( 'body' )[0]; - - if ( b.firstChild ) { - b.insertBefore( e, b.firstChild ); - } else { - b.appendChild( e ); - } - } - - m = document.createElement( 'div' ); - m.appendChild( document.createTextNode( text ) ); - - e.appendChild( m ); - - return true; -} - -/** - * Compatibility wrapper for creating a new XMLHttpRequest object. - */ -function createXhr() { - debug( 'sajax_init_object() called..' ); - var a; - try { - // Try the new style before ActiveX so we don't - // unnecessarily trigger warnings in IE 7 when - // set to prompt about ActiveX usage - a = new XMLHttpRequest(); - } catch ( xhrE ) { - try { - a = new window.ActiveXObject( 'Msxml2.XMLHTTP' ); - } catch ( msXmlE ) { - try { - a = new window.ActiveXObject( 'Microsoft.XMLHTTP' ); - } catch ( msXhrE ) { - a = null; - } - } - } - if ( !a ) { - debug( 'Could not create connection object.' ); - } - - return a; -} - -/** - * Perform an AJAX call to MediaWiki. Calls are handled by AjaxDispatcher.php - * func_name - the name of the function to call. Must be registered in $wgAjaxExportList - * args - an array of arguments to that function - * target - the target that will handle the result of the call. If this is a function, - * if will be called with the XMLHttpRequest as a parameter; if it's an input - * element, its value will be set to the resultText; if it's another type of - * element, its innerHTML will be set to the resultText. - * - * Example: - * sajax_do_call( 'doFoo', [1, 2, 3], document.getElementById( 'showFoo' ) ); - * - * This will call the doFoo function via MediaWiki's AjaxDispatcher, with - * (1, 2, 3) as the parameter list, and will show the result in the element - * with id = showFoo - */ -function doAjaxRequest( func_name, args, target ) { - var i, x, uri, post_data; - uri = mw.util.wikiScript() + '?action=ajax'; - if ( window.sajax_request_type === 'GET' ) { - if ( uri.indexOf( '?' ) === -1 ) { - uri = uri + '?rs=' + encodeURIComponent( func_name ); - } else { - uri = uri + '&rs=' + encodeURIComponent( func_name ); - } - for ( i = 0; i < args.length; i++ ) { - uri = uri + '&rsargs[]=' + encodeURIComponent( args[i] ); - } - //uri = uri + '&rsrnd=' + new Date().getTime(); - post_data = null; - } else { - post_data = 'rs=' + encodeURIComponent( func_name ); - for ( i = 0; i < args.length; i++ ) { - post_data = post_data + '&rsargs[]=' + encodeURIComponent( args[i] ); - } - } - x = createXhr(); - if ( !x ) { - alert( 'AJAX not supported' ); - return false; - } - - try { - x.open( window.sajax_request_type, uri, true ); - } catch ( e ) { - if ( location.hostname === 'localhost' ) { - alert( 'Your browser blocks XMLHttpRequest to "localhost", try using a real hostname for development/testing.' ); - } - throw e; - } - if ( window.sajax_request_type === 'POST' ) { - x.setRequestHeader( 'Method', 'POST ' + uri + ' HTTP/1.1' ); - x.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' ); - } - x.setRequestHeader( 'Pragma', 'cache=yes' ); - x.setRequestHeader( 'Cache-Control', 'no-transform' ); - x.onreadystatechange = function () { - if ( x.readyState !== 4 ) { - return; - } - - debug( 'received (' + x.status + ' ' + x.statusText + ') ' + x.responseText ); - - //if ( x.status != 200 ) - // alert( 'Error: ' + x.status + ' ' + x.statusText + ': ' + x.responseText ); - //else - - if ( typeof target === 'function' ) { - target( x ); - } else if ( typeof target === 'object' ) { - if ( target.tagName === 'INPUT' ) { - if ( x.status === 200 ) { - target.value = x.responseText; - } - //else alert( 'Error: ' + x.status + ' ' + x.statusText + ' (' + x.responseText + ')' ); - } else { - if ( x.status === 200 ) { - target.innerHTML = x.responseText; - } else { - target.innerHTML = '
Error: ' + x.status + - ' ' + x.statusText + ' (' + x.responseText + ')
'; - } - } - } else { - alert( 'Bad target for sajax_do_call: not a function or object: ' + target ); - } - }; - - debug( func_name + ' uri = ' + uri + ' / post = ' + post_data ); - x.send( post_data ); - debug( func_name + ' waiting..' ); - - return true; -} - -/** - * @return {boolean} Whether the browser supports AJAX - */ -function wfSupportsAjax() { - var request = createXhr(), - supportsAjax = request ? true : false; - - request = undefined; - return supportsAjax; -} - -// Expose + Mark as deprecated -var deprecationNotice = 'Sajax is deprecated, use jQuery.ajax or mediawiki.api instead.'; - -// Variables -mw.log.deprecate( window, 'sajax_debug_mode', false, deprecationNotice ); -mw.log.deprecate( window, 'sajax_request_type', 'GET', deprecationNotice ); -// Methods -mw.log.deprecate( window, 'sajax_debug', debug, deprecationNotice ); -mw.log.deprecate( window, 'sajax_init_object', createXhr, deprecationNotice ); -mw.log.deprecate( window, 'sajax_do_call', doAjaxRequest, deprecationNotice ); -mw.log.deprecate( window, 'wfSupportsAjax', wfSupportsAjax, deprecationNotice ); - -}( mediaWiki ) ); diff --git a/skins/common/ajax.js b/skins/common/ajax.js new file mode 120000 index 0000000000..6cf8d71850 --- /dev/null +++ b/skins/common/ajax.js @@ -0,0 +1 @@ +../../resources/src/mediawiki.legacy/ajax.js \ No newline at end of file diff --git a/skins/common/wikibits.js b/skins/common/wikibits.js deleted file mode 100644 index 5c6e63b9ee..0000000000 --- a/skins/common/wikibits.js +++ /dev/null @@ -1,201 +0,0 @@ -/** - * MediaWiki legacy wikibits - */ -( function ( mw, $ ) { - var msg, - win = window, - ua = navigator.userAgent.toLowerCase(), - onloadFuncts = []; - -/** - * User-agent sniffing. - * - * @deprecated since 1.17 Use jquery.client instead - */ - -msg = 'Use feature detection or module jquery.client instead.'; - -mw.log.deprecate( win, 'clientPC', ua, msg ); - -// Ignored dummy values -mw.log.deprecate( win, 'is_gecko', false, msg ); -mw.log.deprecate( win, 'is_chrome_mac', false, msg ); -mw.log.deprecate( win, 'is_chrome', false, msg ); -mw.log.deprecate( win, 'webkit_version', false, msg ); -mw.log.deprecate( win, 'is_safari_win', false, msg ); -mw.log.deprecate( win, 'is_safari', false, msg ); -mw.log.deprecate( win, 'webkit_match', false, msg ); -mw.log.deprecate( win, 'is_ff2', false, msg ); -mw.log.deprecate( win, 'ff2_bugs', false, msg ); -mw.log.deprecate( win, 'is_ff2_win', false, msg ); -mw.log.deprecate( win, 'is_ff2_x11', false, msg ); -mw.log.deprecate( win, 'opera95_bugs', false, msg ); -mw.log.deprecate( win, 'opera7_bugs', false, msg ); -mw.log.deprecate( win, 'opera6_bugs', false, msg ); -mw.log.deprecate( win, 'is_opera_95', false, msg ); -mw.log.deprecate( win, 'is_opera_preseven', false, msg ); -mw.log.deprecate( win, 'is_opera', false, msg ); -mw.log.deprecate( win, 'ie6_bugs', false, msg ); - -/** - * DOM utilities for handling of events, text nodes and selecting elements - * - * @deprecated since 1.17 Use jQuery instead - */ -msg = 'Use jQuery instead.'; - -// Ignored dummy values -mw.log.deprecate( win, 'doneOnloadHook', undefined, msg ); -mw.log.deprecate( win, 'onloadFuncts', [], msg ); -mw.log.deprecate( win, 'runOnloadHook', $.noop, msg ); -mw.log.deprecate( win, 'changeText', $.noop, msg ); -mw.log.deprecate( win, 'killEvt', $.noop, msg ); -mw.log.deprecate( win, 'addHandler', $.noop, msg ); -mw.log.deprecate( win, 'hookEvent', $.noop, msg ); -mw.log.deprecate( win, 'addClickHandler', $.noop, msg ); -mw.log.deprecate( win, 'removeHandler', $.noop, msg ); -mw.log.deprecate( win, 'getElementsByClassName', function () { return []; }, msg ); -mw.log.deprecate( win, 'getInnerText', function () { return ''; }, msg ); - -// Run a function after the window onload event is fired -mw.log.deprecate( win, 'addOnloadHook', function ( hookFunct ) { - if ( onloadFuncts ) { - onloadFuncts.push(hookFunct); - } else { - // If func queue is gone the event has happened already, - // run immediately instead of queueing. - hookFunct(); - } -}, msg ); - -$( win ).on( 'load', function () { - var i, functs; - - // Don't run twice - if ( !onloadFuncts ) { - return; - } - - // Deference and clear onloadFuncts before running any - // hooks to make sure we don't miss any addOnloadHook - // calls. - functs = onloadFuncts.slice(); - onloadFuncts = undefined; - - // Execute the queued functions - for ( i = 0; i < functs.length; i++ ) { - functs[i](); - } -} ); - -/** - * Toggle checkboxes with shift selection - * - * @deprecated since 1.17 Use jquery.checkboxShiftClick instead - */ -msg = 'Use jquery.checkboxShiftClick instead.'; -mw.log.deprecate( win, 'checkboxes', [], msg ); -mw.log.deprecate( win, 'lastCheckbox', null, msg ); -mw.log.deprecate( win, 'setupCheckboxShiftClick', $.noop, msg ); -mw.log.deprecate( win, 'addCheckboxClickHandlers', $.noop, msg ); -mw.log.deprecate( win, 'checkboxClickHandler', $.noop, msg ); - -/** - * Add a button to the default editor toolbar - * - * @deprecated since 1.17 Use mw.toolbar instead - */ -mw.log.deprecate( win, 'mwEditButtons', [], 'Use mw.toolbar instead.' ); -mw.log.deprecate( win, 'mwCustomEditButtons', [], 'Use mw.toolbar instead.' ); - -/** - * Spinner creation, injection and removal - * - * @deprecated since 1.18 Use jquery.spinner instead - */ -mw.log.deprecate( win, 'injectSpinner', $.noop, 'Use jquery.spinner instead.' ); -mw.log.deprecate( win, 'removeSpinner', $.noop, 'Use jquery.spinner instead.' ); - -/** - * Escape utilities - * - * @deprecated since 1.18 Use mw.html instead - */ -mw.log.deprecate( win, 'escapeQuotes', $.noop, 'Use mw.html instead.' ); -mw.log.deprecate( win, 'escapeQuotesHTML', $.noop, 'Use mw.html instead.' ); - -/** - * Display a message to the user - * - * @deprecated since 1.17 Use mediawiki.notify instead - * @param {string|HTMLElement} message To be put inside the message box - */ -mw.log.deprecate( win, 'jsMsg', function ( message ) { - if ( !arguments.length || message === '' || message === null ) { - return true; - } - if ( typeof message !== 'object' ) { - message = $.parseHTML( message ); - } - mw.notify( message, { autoHide: true, tag: 'legacy' } ); - return true; -}, 'Use mediawiki.notify instead.' ); - -/** - * Misc. utilities - * - * @deprecated since 1.17 Use mediawiki.util instead - */ -msg = 'Use mediawiki.util instead.'; -mw.log.deprecate( win, 'updateTooltipAccessKeys', mw.util.updateTooltipAccessKeys, msg ); -mw.log.deprecate( win, 'addPortletLink', mw.util.addPortletLink, msg ); -mw.log.deprecate( win, 'appendCSS', mw.util.addCSS, msg ); -msg = 'Use jquery.accessKeyLabel instead.'; -mw.log.deprecate( win, 'tooltipAccessKeyPrefix', 'alt-', msg ); -mw.log.deprecate( win, 'tooltipAccessKeyRegexp', /\[(alt-)?(.)\]$/, msg ); - -/** - * Wikipage import methods - */ - -// included-scripts tracker -win.loadedScripts = {}; - -win.importScript = function ( page ) { - var uri = mw.config.get( 'wgScript' ) + '?title=' + - mw.util.wikiUrlencode( page ) + - '&action=raw&ctype=text/javascript'; - return win.importScriptURI( uri ); -}; - -win.importScriptURI = function ( url ) { - if ( win.loadedScripts[url] ) { - return null; - } - win.loadedScripts[url] = true; - var s = document.createElement( 'script' ); - s.setAttribute( 'src', url ); - s.setAttribute( 'type', 'text/javascript' ); - document.getElementsByTagName( 'head' )[0].appendChild( s ); - return s; -}; - -win.importStylesheet = function ( page ) { - var uri = mw.config.get( 'wgScript' ) + '?title=' + - mw.util.wikiUrlencode( page ) + - '&action=raw&ctype=text/css'; - return win.importStylesheetURI( uri ); -}; - -win.importStylesheetURI = function ( url, media ) { - var l = document.createElement( 'link' ); - l.rel = 'stylesheet'; - l.href = url; - if ( media ) { - l.media = media; - } - document.getElementsByTagName('head')[0].appendChild( l ); - return l; -}; - -}( mediaWiki, jQuery ) ); diff --git a/skins/common/wikibits.js b/skins/common/wikibits.js new file mode 120000 index 0000000000..c86af5b4ca --- /dev/null +++ b/skins/common/wikibits.js @@ -0,0 +1 @@ +../../resources/src/mediawiki.legacy/wikibits.js \ No newline at end of file -- 2.20.1