Index: branches/resourceloader/phase3/resources/mediawiki/legacy/mediawiki.legacy.prefs.js |
— | — | @@ -62,7 +62,7 @@ |
63 | 63 | } |
64 | 64 | var a = document.createElement( 'a' ); |
65 | 65 | a.href = '#' + sections[i].secid; |
66 | | - a.onmousedown = a.onclick = uncoversection; |
| 66 | + a.onmousedown = a.onclick = mw.legacy.uncoversection; |
67 | 67 | a.appendChild( document.createTextNode( sections[i].text ) ); |
68 | 68 | a.secid = sections[i].secid; |
69 | 69 | li.appendChild( a ); |
— | — | @@ -107,11 +107,11 @@ |
108 | 108 | var tzTextbox = document.getElementById( 'mw-input-timecorrection-other' ); |
109 | 109 | |
110 | 110 | if ( tzSelect && tzTextbox ) { |
111 | | - addHandler( tzSelect, 'change', function( e ) { updateTimezoneSelection( false ); } ); |
112 | | - addHandler( tzTextbox, 'blur', function( e ) { updateTimezoneSelection( true ); } ); |
| 111 | + addHandler( tzSelect, 'change', function( e ) { mw.legacy.updateTimezoneSelection( false ); } ); |
| 112 | + addHandler( tzTextbox, 'blur', function( e ) { mw.legacy.updateTimezoneSelection( true ); } ); |
113 | 113 | } |
114 | 114 | |
115 | | - updateTimezoneSelection( false ); |
| 115 | + mw.legacy.updateTimezoneSelection( false ); |
116 | 116 | }, |
117 | 117 | /** |
118 | 118 | * Timezone stuff tz in format [-]HH:MM - won't yet work with non-even tzs |
— | — | @@ -132,15 +132,15 @@ |
133 | 133 | var selector = document.getElementById( 'mw-input-timecorrection' ); |
134 | 134 | |
135 | 135 | selector.value = 'other'; |
136 | | - textbox.value = fetchTimezone(); |
| 136 | + textbox.value = mw.legacy.fetchTimezone(); |
137 | 137 | textbox.disabled = false; // The changed handler doesn't trip, obviously. |
138 | | - updateTimezoneSelection( true ); |
| 138 | + mw.legacy.updateTimezoneSelection( true ); |
139 | 139 | }, |
140 | 140 | 'updateTimezoneSelection': function( force_offset ) { |
141 | 141 | var selector = document.getElementById( 'mw-input-timecorrection' ); |
142 | 142 | |
143 | 143 | if ( selector.value == 'guess' ) { |
144 | | - return guessTimezone(); |
| 144 | + return mw.legacy.guessTimezone(); |
145 | 145 | } |
146 | 146 | |
147 | 147 | var textbox = document.getElementById( 'mw-input-timecorrection-other' ); |
Index: branches/resourceloader/phase3/resources/mediawiki/legacy/mediawiki.legacy.preview.js |
— | — | @@ -14,18 +14,18 @@ |
15 | 15 | |
16 | 16 | 'doLivePreview': function( e ) { |
17 | 17 | e.preventDefault(); |
18 | | - $j( mw ).trigger( 'LivePreviewPrepare' ); |
19 | | - var postData = $j('#editform').formToArray(); |
| 18 | + $( mw ).trigger( 'LivePreviewPrepare' ); |
| 19 | + var postData = $('#editform').formToArray(); |
20 | 20 | postData.push( { 'name' : 'wpPreview', 'value' : '1' } ); |
21 | 21 | // Hide active diff, used templates, old preview if shown |
22 | 22 | var copyElements = ['#wikiPreview', '.templatesUsed', '.hiddencats', '#catlinks']; |
23 | 23 | var copySelector = copyElements.join(','); |
24 | | - $j.each( copyElements, function(k,v) { $j(v).fadeOut('fast'); } ); |
| 24 | + $.each( copyElements, function(k,v) { $(v).fadeOut('fast'); } ); |
25 | 25 | // Display a loading graphic |
26 | | - var loadSpinner = $j('<div class="mw-ajax-loader"/>'); |
27 | | - $j('#wikiPreview').before( loadSpinner ); |
28 | | - var page = $j('<div/>'); |
29 | | - var target = $j('#editform').attr('action'); |
| 26 | + var loadSpinner = $('<div class="mw-ajax-loader"/>'); |
| 27 | + $('#wikiPreview').before( loadSpinner ); |
| 28 | + var page = $('<div/>'); |
| 29 | + var target = $('#editform').attr('action'); |
30 | 30 | if ( !target ) { |
31 | 31 | target = window.location.href; |
32 | 32 | } |
— | — | @@ -35,16 +35,16 @@ |
36 | 36 | // and the real page, empty the element in the real page, and fill it |
37 | 37 | // with the content of the loaded page |
38 | 38 | var copyContent = page.find( copyElements[i] ).contents(); |
39 | | - $j(copyElements[i]).empty().append( copyContent ); |
| 39 | + $(copyElements[i]).empty().append( copyContent ); |
40 | 40 | var newClasses = page.find( copyElements[i] ).attr('class'); |
41 | | - $j(copyElements[i]).attr( 'class', newClasses ); |
| 41 | + $(copyElements[i]).attr( 'class', newClasses ); |
42 | 42 | } |
43 | | - $j.each( copyElements, function(k,v) { |
| 43 | + $.each( copyElements, function(k,v) { |
44 | 44 | // Don't belligerently show elements that are supposed to be hidden |
45 | | - $j(v).fadeIn( 'fast', function() { $j(this).css('display', ''); } ); |
| 45 | + $(v).fadeIn( 'fast', function() { $(this).css('display', ''); } ); |
46 | 46 | } ); |
47 | 47 | loadSpinner.remove(); |
48 | | - $j( mw ).trigger( 'LivePreviewDone', [copyElements] ); |
| 48 | + $( mw ).trigger( 'LivePreviewDone', [copyElements] ); |
49 | 49 | } ); |
50 | 50 | } |
51 | 51 | } ); |
— | — | @@ -54,7 +54,7 @@ |
55 | 55 | $( document ).ready( function() { |
56 | 56 | // Shamelessly stolen from the jQuery form plugin, which is licensed under the GPL. |
57 | 57 | // http://jquery.malsup.com/form/#download |
58 | | - $j.fn.formToArray = function() { |
| 58 | + $.fn.formToArray = function() { |
59 | 59 | var a = []; |
60 | 60 | if (this.length == 0) return a; |
61 | 61 | var form = this[0]; |
— | — | @@ -64,7 +64,7 @@ |
65 | 65 | var el = els[i]; |
66 | 66 | var n = el.name; |
67 | 67 | if (!n) continue; |
68 | | - var v = $j.fieldValue(el, true); |
| 68 | + var v = $.fieldValue(el, true); |
69 | 69 | if (v && v.constructor == Array) { |
70 | 70 | for(var j=0, jmax=v.length; j < jmax; j++) |
71 | 71 | a.push({name: n, value: v[j]}); |
— | — | @@ -85,7 +85,7 @@ |
86 | 86 | /** |
87 | 87 | * Returns the value of the field element. |
88 | 88 | */ |
89 | | - $j.fieldValue = function(el, successful) { |
| 89 | + $.fieldValue = function(el, successful) { |
90 | 90 | var n = el.name, t = el.type, tag = el.tagName.toLowerCase(); |
91 | 91 | if (typeof successful == 'undefined') successful = true; |
92 | 92 | if (successful && (!n || el.disabled || t == 'reset' || t == 'button' || |
— | — | @@ -115,7 +115,7 @@ |
116 | 116 | } |
117 | 117 | return el.value; |
118 | 118 | }; |
119 | | - $j('#wpPreview').click( doLivePreview ); |
| 119 | + $('#wpPreview').click( mw.legacy.doLivePreview ); |
120 | 120 | } ); |
121 | 121 | |
122 | 122 | } )( jQuery, mediaWiki ); |
\ No newline at end of file |
Index: branches/resourceloader/phase3/resources/mediawiki/legacy/mediawiki.legacy.upload.js |
— | — | @@ -41,7 +41,7 @@ |
42 | 42 | return; |
43 | 43 | } |
44 | 44 | } |
45 | | - this.timeoutID = window.setTimeout( 'wgUploadWarningObj.timeout()', this.delay ); |
| 45 | + this.timeoutID = window.setTimeout( 'mw.legacy.wgUploadWarningObj.timeout()', this.delay ); |
46 | 46 | }, |
47 | 47 | 'checkNow': function ( fname ) { |
48 | 48 | if ( !wgAjaxUploadDestCheck || !sajax_init_object() ) return; |
— | — | @@ -118,7 +118,7 @@ |
119 | 119 | var req = sajax_init_object(); |
120 | 120 | req.onreadystatechange = function() { |
121 | 121 | if ( req.readyState == 4 && req.status == 200 ) |
122 | | - wgUploadLicenseObj.processResult( eval( '( ' + req.responseText + ' )' ), license ); |
| 122 | + mw.legacy.wgUploadLicenseObj.processResult( eval( '( ' + req.responseText + ' )' ), license ); |
123 | 123 | }; |
124 | 124 | req.open( 'GET', url, true ); |
125 | 125 | req.send( '' ); |
— | — | @@ -147,7 +147,7 @@ |
148 | 148 | } |
149 | 149 | } |
150 | 150 | // We might show a preview |
151 | | - wgUploadLicenseObj.fetchPreview( selection ); |
| 151 | + mw.legacy.wgUploadLicenseObj.fetchPreview( selection ); |
152 | 152 | }, |
153 | 153 | 'wgUploadSetup': function() { |
154 | 154 | // Disable URL box if the URL copy upload source type is not selected |
— | — | @@ -174,14 +174,14 @@ |
175 | 175 | // Toggle source type |
176 | 176 | var sourceTypeCheckboxes = document.getElementsByName( 'wpSourceType' ); |
177 | 177 | for ( var i = 0; i < sourceTypeCheckboxes.length; i++ ) { |
178 | | - sourceTypeCheckboxes[i].onchange = toggleUploadInputs; |
| 178 | + sourceTypeCheckboxes[i].onchange = mw.legacy.toggleUploadInputs; |
179 | 179 | } |
180 | 180 | // AJAX wpDestFile warnings |
181 | | - if ( wgAjaxUploadDestCheck ) { |
| 181 | + if ( typeof wgAjaxUploadDestCheck !== 'undefined' && wgAjaxUploadDestCheck ) { |
182 | 182 | // Insert an event handler that fetches upload warnings when wpDestFile |
183 | 183 | // has been changed |
184 | 184 | document.getElementById( 'wpDestFile' ).onchange = function ( e ) { |
185 | | - wgUploadWarningObj.checkNow( this.value ); |
| 185 | + mw.legacy.wgUploadWarningObj.checkNow( this.value ); |
186 | 186 | }; |
187 | 187 | // Insert a row where the warnings will be displayed just below the |
188 | 188 | // wpDestFile row |
— | — | @@ -192,9 +192,9 @@ |
193 | 193 | td.colSpan = 2; |
194 | 194 | row.appendChild( td ); |
195 | 195 | } |
196 | | - if ( wgAjaxLicensePreview ) { |
| 196 | + if ( typeof wgAjaxLicensePreview !== 'undefined' && wgAjaxLicensePreview ) { |
197 | 197 | // License selector check |
198 | | - document.getElementById( 'wpLicense' ).onchange = licenseSelectorCheck; |
| 198 | + document.getElementById( 'wpLicense' ).onchange = mw.legacy.licenseSelectorCheck; |
199 | 199 | // License selector table row |
200 | 200 | var wpLicense = document.getElementById( 'wpLicense' ); |
201 | 201 | var wpLicenseRow = wpLicense.parentNode.parentNode; |
— | — | @@ -208,9 +208,10 @@ |
209 | 209 | wpLicenseTbody.insertBefore( row, wpLicenseRow.nextSibling ); |
210 | 210 | } |
211 | 211 | // fillDestFile setup |
| 212 | + if ( typeof wgUploadSourceIds !== 'undefined' && wgUploadSourceIds ) |
212 | 213 | for ( var i = 0; i < wgUploadSourceIds.length; i++ ) |
213 | 214 | document.getElementById( wgUploadSourceIds[i] ).onchange = function ( e ) { |
214 | | - fillDestFilename( this.id ); |
| 215 | + mw.legacy.fillDestFilename( this.id ); |
215 | 216 | }; |
216 | 217 | }, |
217 | 218 | /** |
— | — | @@ -309,7 +310,7 @@ |
310 | 311 | var destFile = document.getElementById( 'wpDestFile' ); |
311 | 312 | if ( destFile ) { |
312 | 313 | destFile.value = fname; |
313 | | - wgUploadWarningObj.checkNow( fname ) ; |
| 314 | + mw.legacy.wgUploadWarningObj.checkNow( fname ) ; |
314 | 315 | } |
315 | 316 | }, |
316 | 317 | 'toggleFilenameFiller': function() { |
Index: branches/resourceloader/phase3/resources/mediawiki/legacy/mediawiki.legacy.wikibits.js |
— | — | @@ -149,9 +149,9 @@ |
150 | 150 | // set this before running any hooks, since any errors below |
151 | 151 | // might cause the function to terminate prematurely |
152 | 152 | mw.legacy.doneOnloadHook = true; |
153 | | - updateTooltipAccessKeys( null ); |
154 | | - setupCheckboxShiftClick(); |
155 | | - sortables_init(); |
| 153 | + mw.legacy.updateTooltipAccessKeys( null ); |
| 154 | + mw.legacy.setupCheckboxShiftClick(); |
| 155 | + mw.legacy.sortables_init(); |
156 | 156 | // Run any added-on functions |
157 | 157 | for ( var i = 0; i < mw.legacy.onloadFuncts.length; i++ ) { |
158 | 158 | mw.legacy.onloadFuncts[i](); |
— | — | @@ -260,12 +260,12 @@ |
261 | 261 | for ( var i in linkContainers ) { |
262 | 262 | var linkContainer = document.getElementById( linkContainers[i] ); |
263 | 263 | if ( linkContainer ) { |
264 | | - updateTooltipAccessKeys( linkContainer.getElementsByTagName( 'a' ) ); |
| 264 | + mw.legacy.updateTooltipAccessKeys( linkContainer.getElementsByTagName( 'a' ) ); |
265 | 265 | } |
266 | 266 | } |
267 | 267 | // these are rare enough that no such optimization is needed |
268 | | - updateTooltipAccessKeys( document.getElementsByTagName( 'input' ) ); |
269 | | - updateTooltipAccessKeys( document.getElementsByTagName( 'label' ) ); |
| 268 | + mw.legacy.updateTooltipAccessKeys( document.getElementsByTagName( 'input' ) ); |
| 269 | + mw.legacy.updateTooltipAccessKeys( document.getElementsByTagName( 'label' ) ); |
270 | 270 | return; |
271 | 271 | } |
272 | 272 | for ( var i = 0; i < nodeList.length; i++ ) { |
— | — | @@ -296,7 +296,7 @@ |
297 | 297 | mw.legacy.checkboxes = []; |
298 | 298 | mw.legacy.lastCheckbox = null; |
299 | 299 | var inputs = document.getElementsByTagName( 'input' ); |
300 | | - addCheckboxClickHandlers( inputs ); |
| 300 | + mw.legacy.addCheckboxClickHandlers( inputs ); |
301 | 301 | }, |
302 | 302 | 'addCheckboxClickHandlers': function( inputs, start ) { |
303 | 303 | if ( !start ) { |
— | — | @@ -314,11 +314,11 @@ |
315 | 315 | var end = mw.legacy.checkboxes.length; |
316 | 316 | mw.legacy.checkboxes[end] = cb; |
317 | 317 | cb.index = end; |
318 | | - addClickHandler( cb, checkboxClickHandler ); |
| 318 | + mw.legacy.addClickHandler( cb, checkboxClickHandler ); |
319 | 319 | } |
320 | 320 | if ( finish < inputs.length ) { |
321 | 321 | setTimeout( function() { |
322 | | - addCheckboxClickHandlers( inputs, finish ); |
| 322 | + mw.legacy.addCheckboxClickHandlers( inputs, finish ); |
323 | 323 | }, 200 ); |
324 | 324 | } |
325 | 325 | }, |
— | — | @@ -431,7 +431,7 @@ |
432 | 432 | 'sortables_init': function() { |
433 | 433 | var idnum = 0; |
434 | 434 | // Find all tables with class sortable and make them sortable |
435 | | - var tables = getElementsByClassName( document, 'table', 'sortable' ); |
| 435 | + var tables = mw.legacy.getElementsByClassName( document, 'table', 'sortable' ); |
436 | 436 | for ( var ti = 0; ti < tables.length ; ti++ ) { |
437 | 437 | if ( !tables[ti].id ) { |
438 | 438 | tables[ti].setAttribute( 'id', 'sortable_table_id_' + idnum ); |
— | — | @@ -1061,7 +1061,7 @@ |
1062 | 1062 | /* Initialization */ |
1063 | 1063 | |
1064 | 1064 | $( document ).ready( function() { |
1065 | | - if ( wgBreakFrames ) { |
| 1065 | + if ( typeof wgBreakFrames !== 'undefined' && wgBreakFrames ) { |
1066 | 1066 | // Un-trap us from framesets |
1067 | 1067 | if ( window.top != window ) { |
1068 | 1068 | window.top.location = window.location; |
— | — | @@ -1070,23 +1070,23 @@ |
1071 | 1071 | // Special stylesheet links for Monobook only (see bug 14717) |
1072 | 1072 | if ( typeof stylepath != 'undefined' && skin == 'monobook' ) { |
1073 | 1073 | if ( mw.legacy.opera6_bugs ) { |
1074 | | - importStylesheetURI( stylepath + '/' + skin + '/Opera6Fixes.css' ); |
| 1074 | + mw.legacy.importStylesheetURI( stylepath + '/' + skin + '/Opera6Fixes.css' ); |
1075 | 1075 | } else if ( mw.legacy.opera7_bugs ) { |
1076 | | - importStylesheetURI( stylepath + '/' + skin + '/Opera7Fixes.css' ); |
| 1076 | + mw.legacy.importStylesheetURI( stylepath + '/' + skin + '/Opera7Fixes.css' ); |
1077 | 1077 | } else if ( mw.legacy.opera95_bugs ) { |
1078 | | - importStylesheetURI( stylepath + '/' + skin + '/Opera9Fixes.css' ); |
| 1078 | + mw.legacy.importStylesheetURI( stylepath + '/' + skin + '/Opera9Fixes.css' ); |
1079 | 1079 | } else if ( mw.legacy.ff2_bugs ) { |
1080 | | - importStylesheetURI( stylepath + '/' + skin + '/FF2Fixes.css' ); |
| 1080 | + mw.legacy.importStylesheetURI( stylepath + '/' + skin + '/FF2Fixes.css' ); |
1081 | 1081 | } |
1082 | 1082 | } |
1083 | 1083 | if ( mw.legacy.ie6_bugs ) { |
1084 | | - importScriptURI( mw.legacy.stylepath + '/common/IEFixes.js' ); |
| 1084 | + mw.legacy.importScriptURI( mw.legacy.stylepath + '/common/IEFixes.js' ); |
1085 | 1085 | } |
1086 | 1086 | |
1087 | | - showTocToggle(); |
| 1087 | + mw.legacy.showTocToggle(); |
1088 | 1088 | |
1089 | 1089 | // NOTE: This replaces the runOnloadHook() call formerly placed at the end of the HTML output |
1090 | | - runOnloadHook(); |
| 1090 | + mw.legacy.runOnloadHook(); |
1091 | 1091 | } ); |
1092 | 1092 | |
1093 | 1093 | } )( jQuery, mediaWiki ); |
\ No newline at end of file |
Index: branches/resourceloader/phase3/resources/mediawiki/legacy/mediawiki.legacy.mwsuggest.js |
— | — | @@ -96,12 +96,12 @@ |
97 | 97 | 'os_AnimationTimer': function( r, target ) { |
98 | 98 | this.r = r; |
99 | 99 | var current = document.getElementById(r.container).offsetWidth; |
100 | | - this.inc = Math.round( ( target - current ) / os_animation_steps ); |
101 | | - if( this.inc < os_animation_min_step && this.inc >=0 ) { |
102 | | - this.inc = os_animation_min_step; // minimal animation step |
| 100 | + this.inc = Math.round( ( target - current ) / mw.legacy.os_animation_steps ); |
| 101 | + if( this.inc < mw.legacy.os_animation_min_step && this.inc >=0 ) { |
| 102 | + this.inc = mw.legacy.os_animation_min_step; // minimal animation step |
103 | 103 | } |
104 | | - if( this.inc > -os_animation_min_step && this.inc < 0 ) { |
105 | | - this.inc = -os_animation_min_step; |
| 104 | + if( this.inc > -mw.legacy.os_animation_min_step && this.inc < 0 ) { |
| 105 | + this.inc = -mw.legacy.os_animation_min_step; |
106 | 106 | } |
107 | 107 | this.target = target; |
108 | 108 | }, |
— | — | @@ -112,12 +112,12 @@ |
113 | 113 | * Initialization, call upon page onload |
114 | 114 | */ |
115 | 115 | 'os_MWSuggestInit': function() { |
116 | | - for( i = 0; i < os_autoload_inputs.length; i++ ) { |
117 | | - var id = os_autoload_inputs[i]; |
118 | | - var form = os_autoload_forms[i]; |
| 116 | + for( i = 0; i < mw.legacy.os_autoload_inputs.length; i++ ) { |
| 117 | + var id = mw.legacy.os_autoload_inputs[i]; |
| 118 | + var form = mw.legacy.os_autoload_forms[i]; |
119 | 119 | element = document.getElementById( id ); |
120 | 120 | if( element != null ) { |
121 | | - os_initHandlers( id, form, element ); |
| 121 | + mw.legacy.os_initHandlers( id, form, element ); |
122 | 122 | } |
123 | 123 | } |
124 | 124 | }, |
— | — | @@ -125,39 +125,39 @@ |
126 | 126 | * Init Result objects and event handlers |
127 | 127 | */ |
128 | 128 | 'os_initHandlers': function( name, formname, element ) { |
129 | | - var r = new os_Results( name, formname ); |
| 129 | + var r = new mw.legacy.os_Results( name, formname ); |
130 | 130 | var formElement = document.getElementById( formname ); |
131 | 131 | if( !formElement ) { |
132 | 132 | // Older browsers (Opera 8) cannot get form elements |
133 | 133 | return; |
134 | 134 | } |
135 | 135 | // event handler |
136 | | - os_hookEvent( element, 'keyup', function( event ) { os_eventKeyup( event ); } ); |
137 | | - os_hookEvent( element, 'keydown', function( event ) { os_eventKeydown( event ); } ); |
138 | | - os_hookEvent( element, 'keypress', function( event ) { os_eventKeypress( event ); } ); |
139 | | - if ( !os_use_datalist ) { |
| 136 | + mw.legacy.os_hookEvent( element, 'keyup', function( event ) { mw.legacy.os_eventKeyup( event ); } ); |
| 137 | + mw.legacy.os_hookEvent( element, 'keydown', function( event ) { mw.legacy.os_eventKeydown( event ); } ); |
| 138 | + mw.legacy.os_hookEvent( element, 'keypress', function( event ) { mw.legacy.os_eventKeypress( event ); } ); |
| 139 | + if ( !mw.legacy.os_use_datalist ) { |
140 | 140 | // These are needed for the div hack to hide it if the user blurs. |
141 | | - os_hookEvent( element, 'blur', function( event ) { os_eventBlur( event ); } ); |
142 | | - os_hookEvent( element, 'focus', function( event ) { os_eventFocus( event ); } ); |
| 141 | + mw.legacy.os_hookEvent( element, 'blur', function( event ) { mw.legacy.os_eventBlur( event ); } ); |
| 142 | + mw.legacy.os_hookEvent( element, 'focus', function( event ) { mw.legacy.os_eventFocus( event ); } ); |
143 | 143 | // We don't want browser auto-suggestions interfering with our div, but |
144 | 144 | // autocomplete must be on for datalist to work (at least in Opera |
145 | 145 | // 10.10). |
146 | 146 | element.setAttribute( 'autocomplete', 'off' ); |
147 | 147 | } |
148 | 148 | // stopping handler |
149 | | - os_hookEvent( formElement, 'submit', function( event ) { return os_eventOnsubmit( event ); } ); |
150 | | - os_map[name] = r; |
| 149 | + mw.legacy.os_hookEvent( formElement, 'submit', function( event ) { return mw.legacy.os_eventOnsubmit( event ); } ); |
| 150 | + mw.legacy.os_map[name] = r; |
151 | 151 | // toggle link |
152 | 152 | if( document.getElementById( r.toggle ) == null ) { |
153 | 153 | // TODO: disable this while we figure out a way for this to work in all browsers |
154 | 154 | /* if( name == 'searchInput' ) { |
155 | 155 | // special case: place above the main search box |
156 | | - var t = os_createToggle( r, 'os-suggest-toggle' ); |
| 156 | + var t = mw.legacy.os_createToggle( r, 'os-suggest-toggle' ); |
157 | 157 | var searchBody = document.getElementById( 'searchBody' ); |
158 | 158 | var first = searchBody.parentNode.firstChild.nextSibling.appendChild(t); |
159 | 159 | } else { |
160 | 160 | // default: place below search box to the right |
161 | | - var t = os_createToggle( r, 'os-suggest-toggle-def' ); |
| 161 | + var t = mw.legacy.os_createToggle( r, 'os-suggest-toggle-def' ); |
162 | 162 | var top = element.offsetTop + element.offsetHeight; |
163 | 163 | var left = element.offsetLeft + element.offsetWidth; |
164 | 164 | t.style.position = 'absolute'; |
— | — | @@ -185,64 +185,64 @@ |
186 | 186 | * Event handler that will fetch results on keyup |
187 | 187 | */ |
188 | 188 | 'os_eventKeyup': function( e ) { |
189 | | - var targ = os_getTarget( e ); |
190 | | - var r = os_map[targ.id]; |
| 189 | + var targ = mw.legacy.os_getTarget( e ); |
| 190 | + var r = mw.legacy.os_map[targ.id]; |
191 | 191 | if( r == null ) { |
192 | 192 | return; // not our event |
193 | 193 | } |
194 | 194 | |
195 | 195 | // some browsers won't generate keypressed for arrow keys, catch it |
196 | | - if( os_keypressed_count == 0 ) { |
197 | | - os_processKey( r, os_cur_keypressed, targ ); |
| 196 | + if( mw.legacy.os_keypressed_count == 0 ) { |
| 197 | + mw.legacy.os_processKey( r, mw.legacy.os_cur_keypressed, targ ); |
198 | 198 | } |
199 | 199 | var query = targ.value; |
200 | | - os_fetchResults( r, query, os_search_timeout ); |
| 200 | + mw.legacy.os_fetchResults( r, query, mw.legacy.os_search_timeout ); |
201 | 201 | }, |
202 | 202 | /** |
203 | 203 | * Catch arrows up/down and escape to hide the suggestions |
204 | 204 | */ |
205 | 205 | 'os_processKey': function( r, keypressed, targ ) { |
206 | | - if ( keypressed == 40 && !r.visible && os_timer == null ) { |
| 206 | + if ( keypressed == 40 && !r.visible && mw.legacy.os_timer == null ) { |
207 | 207 | // If the user hits the down arrow, fetch results immediately if none |
208 | 208 | // are already displayed. |
209 | 209 | r.query = ''; |
210 | | - os_fetchResults( r, targ.value, 0 ); |
| 210 | + mw.legacy.os_fetchResults( r, targ.value, 0 ); |
211 | 211 | } |
212 | 212 | // Otherwise, if we're not using datalist, we need to handle scrolling and |
213 | 213 | // so on. |
214 | | - if ( os_use_datalist ) { |
| 214 | + if ( mw.legacy.os_use_datalist ) { |
215 | 215 | return; |
216 | 216 | } |
217 | 217 | if ( keypressed == 40 ) { // Arrow Down |
218 | 218 | if ( r.visible ) { |
219 | | - os_changeHighlight( r, r.selected, r.selected + 1, true ); |
| 219 | + mw.legacy.os_changeHighlight( r, r.selected, r.selected + 1, true ); |
220 | 220 | } |
221 | 221 | } else if ( keypressed == 38 ) { // Arrow Up |
222 | 222 | if ( r.visible ) { |
223 | | - os_changeHighlight( r, r.selected, r.selected - 1, true ); |
| 223 | + mw.legacy.os_changeHighlight( r, r.selected, r.selected - 1, true ); |
224 | 224 | } |
225 | 225 | } else if( keypressed == 27 ) { // Escape |
226 | 226 | document.getElementById( r.searchbox ).value = r.original; |
227 | 227 | r.query = r.original; |
228 | | - os_hideResults( r ); |
| 228 | + mw.legacy.os_hideResults( r ); |
229 | 229 | } else if( r.query != document.getElementById( r.searchbox ).value ) { |
230 | | - // os_hideResults( r ); // don't show old suggestions |
| 230 | + // mw.legacy.os_hideResults( r ); // don't show old suggestions |
231 | 231 | } |
232 | 232 | }, |
233 | 233 | /** |
234 | 234 | * When keys is held down use a timer to output regular events |
235 | 235 | */ |
236 | 236 | 'os_eventKeypress': function( e ) { |
237 | | - var targ = os_getTarget( e ); |
238 | | - var r = os_map[targ.id]; |
| 237 | + var targ = mw.legacy.os_getTarget( e ); |
| 238 | + var r = mw.legacy.os_map[targ.id]; |
239 | 239 | if( r == null ) { |
240 | 240 | return; // not our event |
241 | 241 | } |
242 | 242 | |
243 | | - var keypressed = os_cur_keypressed; |
| 243 | + var keypressed = mw.legacy.os_cur_keypressed; |
244 | 244 | |
245 | | - os_keypressed_count++; |
246 | | - os_processKey( r, keypressed, targ ); |
| 245 | + mw.legacy.os_keypressed_count++; |
| 246 | + mw.legacy.os_processKey( r, keypressed, targ ); |
247 | 247 | }, |
248 | 248 | /** |
249 | 249 | * Catch the key code (Firefox bug) |
— | — | @@ -251,39 +251,39 @@ |
252 | 252 | if ( !e ) { |
253 | 253 | e = window.event; |
254 | 254 | } |
255 | | - var targ = os_getTarget( e ); |
256 | | - var r = os_map[targ.id]; |
| 255 | + var targ = mw.legacy.os_getTarget( e ); |
| 256 | + var r = mw.legacy.os_map[targ.id]; |
257 | 257 | if( r == null ) { |
258 | 258 | return; // not our event |
259 | 259 | } |
260 | 260 | |
261 | | - os_mouse_moved = false; |
| 261 | + mw.legacy.os_mouse_moved = false; |
262 | 262 | |
263 | | - os_cur_keypressed = ( e.keyCode == undefined ) ? e.which : e.keyCode; |
264 | | - os_keypressed_count = 0; |
| 263 | + mw.legacy.os_cur_keypressed = ( e.keyCode == undefined ) ? e.which : e.keyCode; |
| 264 | + mw.legacy.os_keypressed_count = 0; |
265 | 265 | }, |
266 | 266 | /** |
267 | 267 | * When the form is submitted hide everything, cancel updates... |
268 | 268 | */ |
269 | 269 | 'os_eventOnsubmit': function( e ) { |
270 | | - var targ = os_getTarget( e ); |
| 270 | + var targ = mw.legacy.os_getTarget( e ); |
271 | 271 | |
272 | | - os_is_stopped = true; |
| 272 | + mw.legacy.os_is_stopped = true; |
273 | 273 | // kill timed requests |
274 | | - if( os_timer != null && os_timer.id != null ) { |
275 | | - clearTimeout( os_timer.id ); |
276 | | - os_timer = null; |
| 274 | + if( mw.legacy.os_timer != null && mw.legacy.os_timer.id != null ) { |
| 275 | + clearTimeout( mw.legacy.os_timer.id ); |
| 276 | + mw.legacy.os_timer = null; |
277 | 277 | } |
278 | 278 | // Hide all suggestions |
279 | | - for( i = 0; i < os_autoload_inputs.length; i++ ) { |
280 | | - var r = os_map[os_autoload_inputs[i]]; |
| 279 | + for( i = 0; i < mw.legacy.os_autoload_inputs.length; i++ ) { |
| 280 | + var r = mw.legacy.os_map[mw.legacy.os_autoload_inputs[i]]; |
281 | 281 | if( r != null ) { |
282 | 282 | var b = document.getElementById( r.searchform ); |
283 | 283 | if( b != null && b == targ ) { |
284 | 284 | // set query value so the handler won't try to fetch additional results |
285 | 285 | r.query = document.getElementById( r.searchbox ).value; |
286 | 286 | } |
287 | | - os_hideResults( r ); |
| 287 | + mw.legacy.os_hideResults( r ); |
288 | 288 | } |
289 | 289 | } |
290 | 290 | return true; |
— | — | @@ -292,7 +292,7 @@ |
293 | 293 | * Hide results from the user, either making the div visibility=hidden or detaching the datalist from the input. |
294 | 294 | */ |
295 | 295 | 'os_hideResults': function( r ) { |
296 | | - if ( os_use_datalist ) { |
| 296 | + if ( mw.legacy.os_use_datalist ) { |
297 | 297 | document.getElementById( r.searchbox ).setAttribute( 'list', '' ); |
298 | 298 | } else { |
299 | 299 | var c = document.getElementById( r.container ); |
— | — | @@ -325,38 +325,38 @@ |
326 | 326 | * Handles data from XMLHttpRequest, and updates the suggest results |
327 | 327 | */ |
328 | 328 | 'os_updateResults': function( r, query, text, cacheKey ) { |
329 | | - os_cache[cacheKey] = text; |
| 329 | + mw.legacy.os_cache[cacheKey] = text; |
330 | 330 | r.query = query; |
331 | 331 | r.original = query; |
332 | 332 | if( text == '' ) { |
333 | 333 | r.results = null; |
334 | 334 | r.resultCount = 0; |
335 | | - os_hideResults( r ); |
| 335 | + mw.legacy.os_hideResults( r ); |
336 | 336 | } else { |
337 | 337 | try { |
338 | 338 | var p = eval( '(' + text + ')' ); // simple json parse, could do a safer one |
339 | 339 | if( p.length < 2 || p[1].length == 0 ) { |
340 | 340 | r.results = null; |
341 | 341 | r.resultCount = 0; |
342 | | - os_hideResults( r ); |
| 342 | + mw.legacy.os_hideResults( r ); |
343 | 343 | return; |
344 | 344 | } |
345 | | - if ( os_use_datalist ) { |
346 | | - os_setupDatalist( r, p[1] ); |
| 345 | + if ( mw.legacy.os_use_datalist ) { |
| 346 | + mw.legacy.os_setupDatalist( r, p[1] ); |
347 | 347 | } else { |
348 | | - os_setupDiv( r, p[1] ); |
| 348 | + mw.legacy.os_setupDiv( r, p[1] ); |
349 | 349 | } |
350 | 350 | } catch( e ) { |
351 | 351 | // bad response from server or such |
352 | | - os_hideResults( r ); |
353 | | - os_cache[cacheKey] = null; |
| 352 | + mw.legacy.os_hideResults( r ); |
| 353 | + mw.legacy.os_cache[cacheKey] = null; |
354 | 354 | } |
355 | 355 | } |
356 | 356 | }, |
357 | 357 | /** |
358 | 358 | * Create and populate a <datalist>. |
359 | 359 | * |
360 | | - * @param r os_Result object |
| 360 | + * @param r mw.legacy.os_Result object |
361 | 361 | * @param results Array of the new results to replace existing ones |
362 | 362 | */ |
363 | 363 | 'os_setupDatalist': function( r, results ) { |
— | — | @@ -375,7 +375,7 @@ |
376 | 376 | r.resultCount = results.length; |
377 | 377 | r.visible = true; |
378 | 378 | for ( i = 0; i < results.length; i++ ) { |
379 | | - var title = os_decodeValue( results[i] ); |
| 379 | + var title = mw.legacy.os_decodeValue( results[i] ); |
380 | 380 | var opt = document.createElement( 'option' ); |
381 | 381 | opt.value = title; |
382 | 382 | r.results[i] = title; |
— | — | @@ -414,7 +414,7 @@ |
415 | 415 | 'os_updateIfRelevant': function( r, query, text, cacheKey ) { |
416 | 416 | var t = document.getElementById( r.searchbox ); |
417 | 417 | if( t != null && t.value == query ) { // check if response is still relevant |
418 | | - os_updateResults( r, query, text, cacheKey ); |
| 418 | + mw.legacy.os_updateResults( r, query, text, cacheKey ); |
419 | 419 | } |
420 | 420 | r.query = query; |
421 | 421 | }, |
— | — | @@ -422,27 +422,27 @@ |
423 | 423 | * Fetch results after some timeout |
424 | 424 | */ |
425 | 425 | 'os_delayedFetch': function() { |
426 | | - if( os_timer == null ) { |
| 426 | + if( mw.legacy.os_timer == null ) { |
427 | 427 | return; |
428 | 428 | } |
429 | | - var r = os_timer.r; |
430 | | - var query = os_timer.query; |
431 | | - os_timer = null; |
432 | | - var path = wgMWSuggestTemplate.replace( '{namespaces}', os_getNamespaces( r ) ) |
| 429 | + var r = mw.legacy.os_timer.r; |
| 430 | + var query = mw.legacy.os_timer.query; |
| 431 | + mw.legacy.os_timer = null; |
| 432 | + var path = wgMWSuggestTemplate.replace( '{namespaces}', mw.legacy.os_getNamespaces( r ) ) |
433 | 433 | .replace( '{dbname}', wgDBname ) |
434 | | - .replace( '{searchTerms}', os_encodeQuery( query ) ); |
| 434 | + .replace( '{searchTerms}', mw.legacy.os_encodeQuery( query ) ); |
435 | 435 | // try to get from cache, if not fetch using ajax |
436 | | - var cached = os_cache[path]; |
| 436 | + var cached = mw.legacy.os_cache[path]; |
437 | 437 | if( cached != null && cached != undefined ) { |
438 | | - os_updateIfRelevant( r, query, cached, path ); |
| 438 | + mw.legacy.os_updateIfRelevant( r, query, cached, path ); |
439 | 439 | } else { |
440 | 440 | var xmlhttp = sajax_init_object(); |
441 | 441 | if( xmlhttp ) { |
442 | 442 | try { |
443 | 443 | xmlhttp.open( 'GET', path, true ); |
444 | 444 | xmlhttp.onreadystatechange = function() { |
445 | | - if ( xmlhttp.readyState == 4 && typeof os_updateIfRelevant == 'function' ) { |
446 | | - os_updateIfRelevant( r, query, xmlhttp.responseText, path ); |
| 445 | + if ( xmlhttp.readyState == 4 && typeof mw.legacy.os_updateIfRelevant == 'function' ) { |
| 446 | + mw.legacy.os_updateIfRelevant( r, query, xmlhttp.responseText, path ); |
447 | 447 | } |
448 | 448 | }; |
449 | 449 | xmlhttp.send( null ); |
— | — | @@ -456,29 +456,29 @@ |
457 | 457 | } |
458 | 458 | }, |
459 | 459 | /** |
460 | | - * Init timed update via os_delayedUpdate() |
| 460 | + * Init timed update via mw.legacy.os_delayedUpdate() |
461 | 461 | */ |
462 | 462 | 'os_fetchResults': function( r, query, timeout ) { |
463 | 463 | if( query == '' ) { |
464 | 464 | r.query = ''; |
465 | | - os_hideResults( r ); |
| 465 | + mw.legacy.os_hideResults( r ); |
466 | 466 | return; |
467 | 467 | } else if( query == r.query ) { |
468 | 468 | return; // no change |
469 | 469 | } |
470 | 470 | |
471 | | - os_is_stopped = false; // make sure we're running |
| 471 | + mw.legacy.os_is_stopped = false; // make sure we're running |
472 | 472 | |
473 | 473 | // cancel any pending fetches |
474 | | - if( os_timer != null && os_timer.id != null ) { |
475 | | - clearTimeout( os_timer.id ); |
| 474 | + if( mw.legacy.os_timer != null && mw.legacy.os_timer.id != null ) { |
| 475 | + clearTimeout( mw.legacy.os_timer.id ); |
476 | 476 | } |
477 | 477 | // schedule delayed fetching of results |
478 | 478 | if( timeout != 0 ) { |
479 | | - os_timer = new os_Timer( setTimeout( 'os_delayedFetch()', timeout ), r, query ); |
| 479 | + mw.legacy.os_timer = new mw.legacy.os_Timer( setTimeout( 'mw.legacy.os_delayedFetch()', timeout ), r, query ); |
480 | 480 | } else { |
481 | | - os_timer = new os_Timer( null, r, query ); |
482 | | - os_delayedFetch(); // do it now! |
| 481 | + mw.legacy.os_timer = new mw.legacy.os_Timer( null, r, query ); |
| 482 | + mw.legacy.os_delayedFetch(); // do it now! |
483 | 483 | } |
484 | 484 | }, |
485 | 485 | /** |
— | — | @@ -515,27 +515,27 @@ |
516 | 516 | * Call this to enable suggestions on input (id=inputId), on a form (name=formName) |
517 | 517 | */ |
518 | 518 | 'os_enableSuggestionsOn': function( inputId, formName ) { |
519 | | - os_initHandlers( inputId, formName, document.getElementById( inputId ) ); |
| 519 | + mw.legacy.os_initHandlers( inputId, formName, document.getElementById( inputId ) ); |
520 | 520 | }, |
521 | 521 | /** |
522 | 522 | * Call this to disable suggestios on input box (id=inputId) |
523 | 523 | */ |
524 | 524 | 'os_disableSuggestionsOn': function( inputId ) { |
525 | | - r = os_map[inputId]; |
| 525 | + r = mw.legacy.os_map[inputId]; |
526 | 526 | if( r != null ) { |
527 | 527 | // cancel/hide results |
528 | | - os_timer = null; |
529 | | - os_hideResults( r ); |
| 528 | + mw.legacy.os_timer = null; |
| 529 | + mw.legacy.os_hideResults( r ); |
530 | 530 | // turn autocomplete on ! |
531 | 531 | document.getElementById( inputId ).setAttribute( 'autocomplete', 'on' ); |
532 | 532 | // remove descriptor |
533 | | - os_map[inputId] = null; |
| 533 | + mw.legacy.os_map[inputId] = null; |
534 | 534 | } |
535 | 535 | |
536 | | - // Remove the element from the os_autoload_* arrays |
537 | | - var index = os_autoload_inputs.indexOf( inputId ); |
| 536 | + // Remove the element from the mw.legacy.os_autoload_* arrays |
| 537 | + var index = mw.legacy.os_autoload_inputs.indexOf( inputId ); |
538 | 538 | if ( index >= 0 ) { |
539 | | - os_autoload_inputs[index] = os_autoload_forms[index] = ''; |
| 539 | + mw.legacy.os_autoload_inputs[index] = mw.legacy.os_autoload_forms[index] = ''; |
540 | 540 | } |
541 | 541 | }, |
542 | 542 | |
— | — | @@ -545,28 +545,28 @@ |
546 | 546 | * Event: loss of focus of input box |
547 | 547 | */ |
548 | 548 | 'os_eventBlur': function( e ) { |
549 | | - var targ = os_getTarget( e ); |
550 | | - var r = os_map[targ.id]; |
| 549 | + var targ = mw.legacy.os_getTarget( e ); |
| 550 | + var r = mw.legacy.os_map[targ.id]; |
551 | 551 | if( r == null ) { |
552 | 552 | return; // not our event |
553 | 553 | } |
554 | | - if( !os_mouse_pressed ) { |
555 | | - os_hideResults( r ); |
| 554 | + if( !mw.legacy.os_mouse_pressed ) { |
| 555 | + mw.legacy.os_hideResults( r ); |
556 | 556 | // force canvas to stay hidden |
557 | 557 | r.stayHidden = true; |
558 | 558 | // cancel any pending fetches |
559 | | - if( os_timer != null && os_timer.id != null ) { |
560 | | - clearTimeout( os_timer.id ); |
| 559 | + if( mw.legacy.os_timer != null && mw.legacy.os_timer.id != null ) { |
| 560 | + clearTimeout( mw.legacy.os_timer.id ); |
561 | 561 | } |
562 | | - os_timer = null; |
| 562 | + mw.legacy.os_timer = null; |
563 | 563 | } |
564 | 564 | }, |
565 | 565 | /** |
566 | 566 | * Event: focus (catch only when stopped) |
567 | 567 | */ |
568 | 568 | 'os_eventFocus': function( e ) { |
569 | | - var targ = os_getTarget( e ); |
570 | | - var r = os_map[targ.id]; |
| 569 | + var targ = mw.legacy.os_getTarget( e ); |
| 570 | + var r = mw.legacy.os_map[targ.id]; |
571 | 571 | if( r == null ) { |
572 | 572 | return; // not our event |
573 | 573 | } |
— | — | @@ -575,34 +575,34 @@ |
576 | 576 | /** |
577 | 577 | * Create and populate a <div>, for non-<datalist>-supporting browsers. |
578 | 578 | * |
579 | | - * @param r os_Result object |
| 579 | + * @param r mw.legacy.os_Result object |
580 | 580 | * @param results Array of the new results to replace existing ones |
581 | 581 | */ |
582 | 582 | 'os_setupDiv': function( r, results ) { |
583 | 583 | var c = document.getElementById( r.container ); |
584 | 584 | if ( c == null ) { |
585 | | - c = os_createContainer( r ); |
| 585 | + c = mw.legacy.os_createContainer( r ); |
586 | 586 | } |
587 | | - c.innerHTML = os_createResultTable( r, results ); |
| 587 | + c.innerHTML = mw.legacy.os_createResultTable( r, results ); |
588 | 588 | // init container table sizes |
589 | 589 | var t = document.getElementById( r.resultTable ); |
590 | 590 | r.containerTotal = t.offsetHeight; |
591 | 591 | r.containerRow = t.offsetHeight / r.resultCount; |
592 | | - os_fitContainer( r ); |
593 | | - os_trimResultText( r ); |
594 | | - os_showResults( r ); |
| 592 | + mw.legacy.os_fitContainer( r ); |
| 593 | + mw.legacy.os_trimResultText( r ); |
| 594 | + mw.legacy.os_showResults( r ); |
595 | 595 | }, |
596 | 596 | /** |
597 | 597 | * Create the result table to be placed in the container div |
598 | 598 | */ |
599 | 599 | 'os_createResultTable': function( r, results ) { |
600 | 600 | var c = document.getElementById( r.container ); |
601 | | - var width = c.offsetWidth - os_operaWidthFix( c.offsetWidth ); |
| 601 | + var width = c.offsetWidth - mw.legacy.os_operaWidthFix( c.offsetWidth ); |
602 | 602 | var html = '<table class="os-suggest-results" id="' + r.resultTable + '" style="width: ' + width + 'px;">'; |
603 | 603 | r.results = new Array(); |
604 | 604 | r.resultCount = results.length; |
605 | 605 | for( i = 0; i < results.length; i++ ) { |
606 | | - var title = os_decodeValue( results[i] ); |
| 606 | + var title = mw.legacy.os_decodeValue( results[i] ); |
607 | 607 | r.results[i] = title; |
608 | 608 | html += '<tr><td class="os-suggest-result" id="' + r.resultTable + i + '"><span id="' + r.resultText + i + '">' + title + '</span></td></tr>'; |
609 | 609 | } |
— | — | @@ -613,13 +613,13 @@ |
614 | 614 | * Show results div |
615 | 615 | */ |
616 | 616 | 'os_showResults': function( r ) { |
617 | | - if( os_is_stopped ) { |
| 617 | + if( mw.legacy.os_is_stopped ) { |
618 | 618 | return; |
619 | 619 | } |
620 | 620 | if( r.stayHidden ) { |
621 | 621 | return; |
622 | 622 | } |
623 | | - os_fitContainer( r ); |
| 623 | + mw.legacy.os_fitContainer( r ); |
624 | 624 | var c = document.getElementById( r.container ); |
625 | 625 | r.selected = -1; |
626 | 626 | if( c != null ) { |
— | — | @@ -708,7 +708,7 @@ |
709 | 709 | 'os_createContainer': function( r ) { |
710 | 710 | var c = document.createElement( 'div' ); |
711 | 711 | var s = document.getElementById( r.searchbox ); |
712 | | - var pos = os_getElementPosition( r.searchbox ); |
| 712 | + var pos = mw.legacy.os_getElementPosition( r.searchbox ); |
713 | 713 | var left = pos.left; |
714 | 714 | var top = pos.top + s.offsetHeight; |
715 | 715 | c.className = 'os-suggest'; |
— | — | @@ -723,10 +723,10 @@ |
724 | 724 | c.style.width = s.offsetWidth + 'px'; |
725 | 725 | |
726 | 726 | // mouse event handlers |
727 | | - c.onmouseover = function( event ) { os_eventMouseover( r.searchbox, event ); }; |
728 | | - c.onmousemove = function( event ) { os_eventMousemove( r.searchbox, event ); }; |
729 | | - c.onmousedown = function( event ) { return os_eventMousedown( r.searchbox, event ); }; |
730 | | - c.onmouseup = function( event ) { os_eventMouseup( r.searchbox, event ); }; |
| 727 | + c.onmouseover = function( event ) { mw.legacy.os_eventMouseover( r.searchbox, event ); }; |
| 728 | + c.onmousemove = function( event ) { mw.legacy.os_eventMousemove( r.searchbox, event ); }; |
| 729 | + c.onmousedown = function( event ) { return mw.legacy.os_eventMousedown( r.searchbox, event ); }; |
| 730 | + c.onmouseup = function( event ) { mw.legacy.os_eventMouseup( r.searchbox, event ); }; |
731 | 731 | return c; |
732 | 732 | }, |
733 | 733 | /** |
— | — | @@ -734,14 +734,14 @@ |
735 | 735 | */ |
736 | 736 | 'os_fitContainer': function( r ) { |
737 | 737 | var c = document.getElementById( r.container ); |
738 | | - var h = os_availableHeight( r ) - 20; |
| 738 | + var h = mw.legacy.os_availableHeight( r ) - 20; |
739 | 739 | var inc = r.containerRow; |
740 | 740 | h = parseInt( h / inc ) * inc; |
741 | 741 | if( h < ( 2 * inc ) && r.resultCount > 1 ) { // min: two results |
742 | 742 | h = 2 * inc; |
743 | 743 | } |
744 | | - if( ( h / inc ) > os_max_lines_per_suggest ) { |
745 | | - h = inc * os_max_lines_per_suggest; |
| 744 | + if( ( h / inc ) > mw.legacy.os_max_lines_per_suggest ) { |
| 745 | + h = inc * mw.legacy.os_max_lines_per_suggest; |
746 | 746 | } |
747 | 747 | if( h < r.containerTotal ) { |
748 | 748 | c.style.height = h + 'px'; |
— | — | @@ -768,7 +768,7 @@ |
769 | 769 | if( r.containerCount < r.resultCount ) { |
770 | 770 | fix = 20; // give 20px for scrollbar |
771 | 771 | } else { |
772 | | - fix = os_operaWidthFix( w ); |
| 772 | + fix = mw.legacy.os_operaWidthFix( w ); |
773 | 773 | } |
774 | 774 | if( fix < 4 ) { |
775 | 775 | fix = 4; // basic padding |
— | — | @@ -778,19 +778,19 @@ |
779 | 779 | // resize container to fit more data if permitted |
780 | 780 | var normW = document.getElementById( r.searchbox ).offsetWidth; |
781 | 781 | var prop = maxW / normW; |
782 | | - if( prop > os_container_max_width ) { |
783 | | - prop = os_container_max_width; |
| 782 | + if( prop > mw.legacy.os_container_max_width ) { |
| 783 | + prop = mw.legacy.os_container_max_width; |
784 | 784 | } else if( prop < 1 ) { |
785 | 785 | prop = 1; |
786 | 786 | } |
787 | 787 | var newW = Math.round( normW * prop ); |
788 | 788 | if( w != newW ) { |
789 | 789 | w = newW; |
790 | | - if( os_animation_timer != null ) { |
791 | | - clearInterval( os_animation_timer.id ); |
| 790 | + if( mw.legacy.os_animation_timer != null ) { |
| 791 | + clearInterval( mw.legacy.os_animation_timer.id ); |
792 | 792 | } |
793 | | - os_animation_timer = new os_AnimationTimer( r, w ); |
794 | | - os_animation_timer.id = setInterval( 'os_animateChangeWidth()', os_animation_delay ); |
| 793 | + mw.legacy.os_animation_timer = new mw.legacy.os_AnimationTimer( r, w ); |
| 794 | + mw.legacy.os_animation_timer.id = setInterval( 'mw.legacy.os_animateChangeWidth()', mw.legacy.os_animation_delay ); |
795 | 795 | w -= fix; // this much is reserved |
796 | 796 | } |
797 | 797 | |
— | — | @@ -822,24 +822,24 @@ |
823 | 823 | * Invoked on timer to animate change in container width |
824 | 824 | */ |
825 | 825 | 'os_animateChangeWidth': function() { |
826 | | - var r = os_animation_timer.r; |
| 826 | + var r = mw.legacy.os_animation_timer.r; |
827 | 827 | var c = document.getElementById( r.container ); |
828 | 828 | var w = c.offsetWidth; |
829 | 829 | var normW = document.getElementById( r.searchbox ).offsetWidth; |
830 | | - var normL = os_getElementPosition( r.searchbox ).left; |
831 | | - var inc = os_animation_timer.inc; |
832 | | - var target = os_animation_timer.target; |
| 830 | + var normL = mw.legacy.os_getElementPosition( r.searchbox ).left; |
| 831 | + var inc = mw.legacy.os_animation_timer.inc; |
| 832 | + var target = mw.legacy.os_animation_timer.target; |
833 | 833 | var nw = w + inc; |
834 | 834 | if( ( inc > 0 && nw >= target ) || ( inc <= 0 && nw <= target ) ) { |
835 | 835 | // finished ! |
836 | 836 | c.style.width = target + 'px'; |
837 | | - clearInterval( os_animation_timer.id ); |
838 | | - os_animation_timer = null; |
| 837 | + clearInterval( mw.legacy.os_animation_timer.id ); |
| 838 | + mw.legacy.os_animation_timer = null; |
839 | 839 | } else { |
840 | 840 | // in-progress |
841 | 841 | c.style.width = nw + 'px'; |
842 | 842 | if( document.documentElement.dir == 'rtl' ) { |
843 | | - c.style.left = ( normL + normW + ( target - nw ) - os_animation_timer.target - 1 ) + 'px'; |
| 843 | + c.style.left = ( normL + normW + ( target - nw ) - mw.legacy.os_animation_timer.target - 1 ) + 'px'; |
844 | 844 | } |
845 | 845 | } |
846 | 846 | }, |
— | — | @@ -868,7 +868,7 @@ |
869 | 869 | if( next >= 0 ) { |
870 | 870 | var nextRow = document.getElementById( r.resultTable + next ); |
871 | 871 | if( nextRow != null ) { |
872 | | - nextRow.className = os_HighlightClass(); |
| 872 | + nextRow.className = mw.legacy.os_HighlightClass(); |
873 | 873 | } |
874 | 874 | newText = r.results[next]; |
875 | 875 | } else { |
— | — | @@ -889,7 +889,7 @@ |
890 | 890 | |
891 | 891 | // update the contents of the search box |
892 | 892 | if( updateSearchBox ) { |
893 | | - os_updateSearchQuery( r, newText ); |
| 893 | + mw.legacy.os_updateSearchQuery( r, newText ); |
894 | 894 | } |
895 | 895 | }, |
896 | 896 | 'os_HighlightClass': function() { |
— | — | @@ -916,14 +916,14 @@ |
917 | 917 | * Mouse over the container |
918 | 918 | */ |
919 | 919 | 'os_eventMouseover': function( srcId, e ) { |
920 | | - var targ = os_getTarget( e ); |
921 | | - var r = os_map[srcId]; |
922 | | - if( r == null || !os_mouse_moved ) { |
| 920 | + var targ = mw.legacy.os_getTarget( e ); |
| 921 | + var r = mw.legacy.os_map[srcId]; |
| 922 | + if( r == null || !mw.legacy.os_mouse_moved ) { |
923 | 923 | return; // not our event |
924 | 924 | } |
925 | | - var num = os_getNumberSuffix( targ.id ); |
| 925 | + var num = mw.legacy.os_getNumberSuffix( targ.id ); |
926 | 926 | if( num >= 0 ) { |
927 | | - os_changeHighlight( r, r.selected, num, false ); |
| 927 | + mw.legacy.os_changeHighlight( r, r.selected, num, false ); |
928 | 928 | } |
929 | 929 | }, |
930 | 930 | /** |
— | — | @@ -934,7 +934,7 @@ |
935 | 935 | if( !( num.charAt( 0 ) >= '0' && num.charAt( 0 ) <= '9' ) ) { |
936 | 936 | num = num.substring( 1 ); |
937 | 937 | } |
938 | | - if( os_isNumber( num ) ) { |
| 938 | + if( mw.legacy.os_isNumber( num ) ) { |
939 | 939 | return parseInt( num ); |
940 | 940 | } else { |
941 | 941 | return -1; |
— | — | @@ -944,23 +944,23 @@ |
945 | 945 | * Save mouse move as last action |
946 | 946 | */ |
947 | 947 | 'os_eventMousemove': function( srcId, e ) { |
948 | | - os_mouse_moved = true; |
| 948 | + mw.legacy.os_mouse_moved = true; |
949 | 949 | }, |
950 | 950 | /** |
951 | 951 | * Mouse button held down, register possible click |
952 | 952 | */ |
953 | 953 | 'os_eventMousedown': function( srcId, e ) { |
954 | | - var targ = os_getTarget( e ); |
955 | | - var r = os_map[srcId]; |
| 954 | + var targ = mw.legacy.os_getTarget( e ); |
| 955 | + var r = mw.legacy.os_map[srcId]; |
956 | 956 | if( r == null ) { |
957 | 957 | return; // not our event |
958 | 958 | } |
959 | | - var num = os_getNumberSuffix( targ.id ); |
| 959 | + var num = mw.legacy.os_getNumberSuffix( targ.id ); |
960 | 960 | |
961 | | - os_mouse_pressed = true; |
| 961 | + mw.legacy.os_mouse_pressed = true; |
962 | 962 | if( num >= 0 ) { |
963 | | - os_mouse_num = num; |
964 | | - // os_updateSearchQuery( r, r.results[num] ); |
| 963 | + mw.legacy.os_mouse_num = num; |
| 964 | + // mw.legacy.os_updateSearchQuery( r, r.results[num] ); |
965 | 965 | } |
966 | 966 | // keep the focus on the search field |
967 | 967 | document.getElementById( r.searchbox ).focus(); |
— | — | @@ -971,19 +971,19 @@ |
972 | 972 | * Mouse button released, check for click on some row |
973 | 973 | */ |
974 | 974 | 'os_eventMouseup': function( srcId, e ) { |
975 | | - var targ = os_getTarget( e ); |
976 | | - var r = os_map[srcId]; |
| 975 | + var targ = mw.legacy.os_getTarget( e ); |
| 976 | + var r = mw.legacy.os_map[srcId]; |
977 | 977 | if( r == null ) { |
978 | 978 | return; // not our event |
979 | 979 | } |
980 | | - var num = os_getNumberSuffix( targ.id ); |
| 980 | + var num = mw.legacy.os_getNumberSuffix( targ.id ); |
981 | 981 | |
982 | | - if( num >= 0 && os_mouse_num == num ) { |
983 | | - os_updateSearchQuery( r, r.results[num] ); |
984 | | - os_hideResults( r ); |
| 982 | + if( num >= 0 && mw.legacy.os_mouse_num == num ) { |
| 983 | + mw.legacy.os_updateSearchQuery( r, r.results[num] ); |
| 984 | + mw.legacy.os_hideResults( r ); |
985 | 985 | document.getElementById( r.searchform ).submit(); |
986 | 986 | } |
987 | | - os_mouse_pressed = false; |
| 987 | + mw.legacy.os_mouse_pressed = false; |
988 | 988 | // keep the focus on the search field |
989 | 989 | document.getElementById( r.searchbox ).focus(); |
990 | 990 | }, |
— | — | @@ -996,7 +996,7 @@ |
997 | 997 | t.setAttribute( 'id', r.toggle ); |
998 | 998 | var link = document.createElement( 'a' ); |
999 | 999 | link.setAttribute( 'href', 'javascript:void(0);' ); |
1000 | | - link.onclick = function() { os_toggle( r.searchbox, r.searchform ); }; |
| 1000 | + link.onclick = function() { mw.legacy.os_toggle( r.searchbox, r.searchform ); }; |
1001 | 1001 | var msg = document.createTextNode( wgMWSuggestMessages[0] ); |
1002 | 1002 | link.appendChild( msg ); |
1003 | 1003 | t.appendChild( link ); |
— | — | @@ -1006,14 +1006,14 @@ |
1007 | 1007 | * Call when user clicks on some of the toggle links (dead code?) |
1008 | 1008 | */ |
1009 | 1009 | 'os_toggle': function( inputId, formName ) { |
1010 | | - r = os_map[inputId]; |
| 1010 | + r = mw.legacy.os_map[inputId]; |
1011 | 1011 | var msg = ''; |
1012 | 1012 | if( r == null ) { |
1013 | | - os_enableSuggestionsOn( inputId, formName ); |
1014 | | - r = os_map[inputId]; |
| 1013 | + mw.legacy.os_enableSuggestionsOn( inputId, formName ); |
| 1014 | + r = mw.legacy.os_map[inputId]; |
1015 | 1015 | msg = wgMWSuggestMessages[0]; |
1016 | 1016 | } else{ |
1017 | | - os_disableSuggestionsOn( inputId, formName ); |
| 1017 | + mw.legacy.os_disableSuggestionsOn( inputId, formName ); |
1018 | 1018 | msg = wgMWSuggestMessages[1]; |
1019 | 1019 | } |
1020 | 1020 | // change message |
Index: branches/resourceloader/phase3/resources/mediawiki/legacy/mediawiki.legacy.rightclickedit.js |
— | — | @@ -20,7 +20,7 @@ |
21 | 21 | } |
22 | 22 | } |
23 | 23 | } |
24 | | - } |
| 24 | + }, |
25 | 25 | 'addRightClickEditHandler': function(el) { |
26 | 26 | for (var i = 0; i < el.childNodes.length; i++) { |
27 | 27 | var link = el.childNodes[i]; |