Index: trunk/phase3/js2/js2stopgap.js |
— | — | @@ -804,9 +804,11 @@ |
805 | 805 | name = "float"; |
806 | 806 | |
807 | 807 | name = name.replace( /([A-Z])/g, "-$1" ).toLowerCase(); |
808 | | - |
809 | | - var computedStyle = defaultView.getComputedStyle( elem, null ); |
810 | | - |
| 808 | + try{ |
| 809 | + var computedStyle = defaultView.getComputedStyle( elem, null ); |
| 810 | + }catch(e){ |
| 811 | + // Error in getting computedStyle |
| 812 | + } |
811 | 813 | if ( computedStyle ) |
812 | 814 | ret = computedStyle.getPropertyValue( name ); |
813 | 815 | |
Index: trunk/phase3/js2/js2stopgap.min.js |
— | — | @@ -88,8 +88,8 @@ |
89 | 89 | if(name.match(/float/i)) |
90 | 90 | name=styleFloat;if(!force&&style&&style[name]) |
91 | 91 | ret=style[name];else if(defaultView.getComputedStyle){if(name.match(/float/i)) |
92 | | -name="float";name=name.replace(/([A-Z])/g,"-$1").toLowerCase();var computedStyle=defaultView.getComputedStyle(elem,null);if(computedStyle) |
93 | | -ret=computedStyle.getPropertyValue(name);if(name=="opacity"&&ret=="") |
| 92 | +name="float";name=name.replace(/([A-Z])/g,"-$1").toLowerCase();try{var computedStyle=defaultView.getComputedStyle(elem,null);if(computedStyle) |
| 93 | +ret=computedStyle.getPropertyValue(name);}catch(e){};if(name=="opacity"&&ret=="") |
94 | 94 | ret="1";}else if(elem.currentStyle){var camelCase=name.replace(/\-(\w)/g,function(all,letter){return letter.toUpperCase();});ret=elem.currentStyle[name]||elem.currentStyle[camelCase];if(!/^\d+(px)?$/i.test(ret)&&/^\d/.test(ret)){var left=style.left,rsLeft=elem.runtimeStyle.left;elem.runtimeStyle.left=elem.currentStyle.left;style.left=ret||0;ret=style.pixelLeft+"px";style.left=left;elem.runtimeStyle.left=rsLeft;}} |
95 | 95 | return ret;},clean:function(elems,context,fragment){context=context||document;if(typeof context.createElement==="undefined") |
96 | 96 | context=context.ownerDocument||context[0]&&context[0].ownerDocument||document;if(!fragment&&elems.length===1&&typeof elems[0]==="string"){var match=/^<(\w+)\s*\/?>$/.exec(elems[0]);if(match) |
Index: branches/js2-work/phase3/js/mwEmbed/jquery/plugins/jquery.textSelection.js |
— | — | @@ -1,15 +1,28 @@ |
2 | 2 | /** |
3 | 3 | * These plugins provide extra functionality for interaction with textareas. |
4 | 4 | */ |
5 | | -( function( $ ) { $.fn.extend( { |
| 5 | +( function( $ ) { |
| 6 | +$.fn.textSelection = function( command, options ) { |
| 7 | +var fn = { |
6 | 8 | /** |
| 9 | + * Get the contents of the textarea |
| 10 | + */ |
| 11 | +getContents: function() { |
| 12 | + return this.val(); |
| 13 | +}, |
| 14 | + |
| 15 | +setContents: function( options ) { |
| 16 | + return this.val( options.contents ); |
| 17 | +}, |
| 18 | + |
| 19 | +/** |
7 | 20 | * Get the currently selected text in this textarea. Will focus the textarea |
8 | 21 | * in some browsers (IE/Opera) |
9 | 22 | */ |
10 | | -textSelection: function() { |
11 | | - var e = this.jquery ? this[0] : this; |
| 23 | +getSelection: function() { |
| 24 | + var e = this.get( 0 ); |
12 | 25 | var retval = ''; |
13 | | - if ( e.style.display == 'none' ) { |
| 26 | + if ( $(e).is( ':hidden' ) ) { |
14 | 27 | // Do nothing |
15 | 28 | } else if ( document.selection && document.selection.createRange ) { |
16 | 29 | e.focus(); |
— | — | @@ -23,34 +36,28 @@ |
24 | 37 | /** |
25 | 38 | * Ported from skins/common/edit.js by Trevor Parscal |
26 | 39 | * (c) 2009 Wikimedia Foundation (GPLv2) - http://www.wikimedia.org |
27 | | - * |
| 40 | + * |
28 | 41 | * Inserts text at the begining and end of a text selection, optionally |
29 | 42 | * inserting text at the caret when selection is empty. |
30 | | - * |
31 | | - * @param pre Text to insert before selection |
32 | | - * @param peri Text to insert at caret if selection is empty |
33 | | - * @param post Text to insert after selection |
34 | | - * @param ownline If true, put the inserted text is on its own line |
35 | | - * @param replace If true, replaces any selected text with peri; if false, peri is ignored and selected text is left alone |
36 | 43 | */ |
37 | | -encapsulateSelection: function( pre, peri, post, ownline, replace ) { |
| 44 | +encapsulateSelection: function( options ) { |
38 | 45 | return this.each( function() { |
39 | 46 | /** |
40 | 47 | * Check if the selected text is the same as the insert text |
41 | | - */ |
| 48 | + */ |
42 | 49 | function checkSelectedText() { |
43 | 50 | if ( !selText ) { |
44 | | - selText = peri; |
| 51 | + selText = options.peri; |
45 | 52 | isSample = true; |
46 | | - } else if ( replace ) { |
47 | | - selText = peri; |
| 53 | + } else if ( options.replace ) { |
| 54 | + selText = options.peri; |
48 | 55 | } else if ( selText.charAt( selText.length - 1 ) == ' ' ) { |
49 | 56 | // Exclude ending space char |
50 | 57 | selText = selText.substring(0, selText.length - 1); |
51 | | - post += ' '; |
| 58 | + options.post += ' '; |
52 | 59 | } |
53 | 60 | } |
54 | | - var selText = $(this).getSelection(); |
| 61 | + var selText = $(this).textSelection( 'getSelection' ); |
55 | 62 | var isSample = false; |
56 | 63 | if ( this.style.display == 'none' ) { |
57 | 64 | // Do nothing |
— | — | @@ -60,57 +67,60 @@ |
61 | 68 | var startPos = this.selectionStart; |
62 | 69 | var endPos = this.selectionEnd; |
63 | 70 | checkSelectedText(); |
64 | | - if ( ownline ) { |
| 71 | + if ( options.ownline ) { |
65 | 72 | if ( startPos != 0 && this.value.charAt( startPos - 1 ) != "\n" ) { |
66 | | - pre = "\n" + pre; |
| 73 | + options.pre = "\n" + options.pre; |
67 | 74 | } |
68 | 75 | if ( this.value.charAt( endPos ) != "\n" ) { |
69 | | - post += "\n"; |
| 76 | + options.post += "\n"; |
70 | 77 | } |
71 | 78 | } |
72 | | - this.value = this.value.substring( 0, startPos ) + pre + selText + post + this.value.substring( endPos, this.value.length ); |
| 79 | + this.value = this.value.substring( 0, startPos ) + options.pre + selText + options.post + |
| 80 | + this.value.substring( endPos, this.value.length ); |
73 | 81 | if ( window.opera ) { |
74 | | - pre = pre.replace( /\r?\n/g, "\r\n" ); |
| 82 | + options.pre = options.pre.replace( /\r?\n/g, "\r\n" ); |
75 | 83 | selText = selText.replace( /\r?\n/g, "\r\n" ); |
76 | | - post = post.replace( /\r?\n/g, "\r\n" ); |
| 84 | + options.post = options.post.replace( /\r?\n/g, "\r\n" ); |
77 | 85 | } |
78 | 86 | if ( isSample ) { |
79 | | - this.selectionStart = startPos + pre.length; |
80 | | - this.selectionEnd = startPos + pre.length + selText.length; |
| 87 | + this.selectionStart = startPos + options.pre.length; |
| 88 | + this.selectionEnd = startPos + options.pre.length + selText.length; |
81 | 89 | } else { |
82 | | - this.selectionStart = startPos + pre.length + selText.length + post.length; |
| 90 | + this.selectionStart = startPos + options.pre.length + selText.length + |
| 91 | + options.post.length; |
83 | 92 | this.selectionEnd = this.selectionStart; |
84 | 93 | } |
85 | 94 | } else if ( document.selection && document.selection.createRange ) { |
86 | 95 | // IE |
87 | 96 | $(this).focus(); |
88 | 97 | var range = document.selection.createRange(); |
89 | | - if ( ownline && range.moveStart ) { |
| 98 | + if ( options.ownline && range.moveStart ) { |
90 | 99 | var range2 = document.selection.createRange(); |
91 | 100 | range2.collapse(); |
92 | 101 | range2.moveStart( 'character', -1 ); |
93 | 102 | // FIXME: Which check is correct? |
94 | 103 | if ( range2.text != "\r" && range2.text != "\n" && range2.text != "" ) { |
95 | | - pre = "\n" + pre; |
| 104 | + options.pre = "\n" + options.pre; |
96 | 105 | } |
97 | 106 | var range3 = document.selection.createRange(); |
98 | 107 | range3.collapse( false ); |
99 | 108 | range3.moveEnd( 'character', 1 ); |
100 | 109 | if ( range3.text != "\r" && range3.text != "\n" && range3.text != "" ) { |
101 | | - post += "\n"; |
| 110 | + options.post += "\n"; |
102 | 111 | } |
103 | 112 | } |
104 | 113 | checkSelectedText(); |
105 | | - range.text = pre + selText + post; |
| 114 | + range.text = options.pre + selText + options.post; |
106 | 115 | if ( isSample && range.moveStart ) { |
107 | | - range.moveStart( 'character', - post.length - selText.length ); |
108 | | - range.moveEnd( 'character', - post.length ); |
| 116 | + range.moveStart( 'character', - options.post.length - selText.length ); |
| 117 | + range.moveEnd( 'character', - options.post.length ); |
109 | 118 | } |
110 | 119 | range.select(); |
111 | 120 | } |
112 | 121 | // Scroll the textarea to the inserted text |
113 | | - $(this).scrollToCaretPosition(); |
114 | | - $(this).trigger( 'encapsulateSelection', [ pre, peri, post, ownline, replace ] ); |
| 122 | + $(this).textSelection( 'scrollToCaretPosition' ); |
| 123 | + $(this).trigger( 'encapsulateSelection', [ options.pre, options.peri, options.post, options.ownline, |
| 124 | + options.replace ] ); |
115 | 125 | }); |
116 | 126 | }, |
117 | 127 | /** |
— | — | @@ -120,9 +130,9 @@ |
121 | 131 | * http://www.dedestruct.com/2008/03/22/howto-cross-browser-cursor-position-in-textareas/ |
122 | 132 | * |
123 | 133 | * Get the position (in resolution of bytes not nessecarily characters) |
124 | | - * in a textarea |
| 134 | + * in a textarea |
125 | 135 | */ |
126 | | - getCaretPosition: function( startAndEnd ) { |
| 136 | + getCaretPosition: function( options ) { |
127 | 137 | function getCaret( e ) { |
128 | 138 | var caretPos = 0, endPos = 0; |
129 | 139 | if ( $.browser.msie ) { |
— | — | @@ -200,31 +210,31 @@ |
201 | 211 | caretPos = e.selectionStart; |
202 | 212 | endPos = e.selectionEnd; |
203 | 213 | } |
204 | | - return startAndEnd ? [ caretPos, endPos ] : caretPos; |
| 214 | + return options.startAndEnd ? [ caretPos, endPos ] : caretPos; |
205 | 215 | } |
206 | 216 | return getCaret( this.get( 0 ) ); |
207 | 217 | }, |
208 | | -setSelection: function( start, end ) { |
209 | | - if ( typeof end == 'undefined' ) |
210 | | - end = start; |
| 218 | +setSelection: function( options ) { |
211 | 219 | return this.each( function() { |
212 | | - if ( this.selectionStart || this.selectionStart == '0' ) { |
| 220 | + if ( $(this).is( ':hidden' ) ) { |
| 221 | + // Do nothing |
| 222 | + } else if ( this.selectionStart || this.selectionStart == '0' ) { |
213 | 223 | // Opera 9.0 doesn't allow setting selectionStart past |
214 | 224 | // selectionEnd; any attempts to do that will be ignored |
215 | 225 | // Make sure to set them in the right order |
216 | | - if ( start > this.selectionEnd ) { |
217 | | - this.selectionEnd = end; |
218 | | - this.selectionStart = start; |
| 226 | + if ( options.start > this.selectionEnd ) { |
| 227 | + this.selectionEnd = options.end; |
| 228 | + this.selectionStart = options.start; |
219 | 229 | } else { |
220 | | - this.selectionStart = start; |
221 | | - this.selectionEnd = end; |
| 230 | + this.selectionStart = options.start; |
| 231 | + this.selectionEnd = options.end; |
222 | 232 | } |
223 | 233 | } else if ( document.body.createTextRange ) { |
224 | 234 | var selection = document.body.createTextRange(); |
225 | 235 | selection.moveToElementText( this ); |
226 | 236 | var length = selection.text.length; |
227 | | - selection.moveStart( 'character', start ); |
228 | | - selection.moveEnd( 'character', -length + end ); |
| 237 | + selection.moveStart( 'character', options.start ); |
| 238 | + selection.moveEnd( 'character', -length + options.end ); |
229 | 239 | selection.select(); |
230 | 240 | } |
231 | 241 | }); |
— | — | @@ -232,13 +242,13 @@ |
233 | 243 | /** |
234 | 244 | * Ported from Wikia's LinkSuggest extension |
235 | 245 | * https://svn.wikia-code.com/wikia/trunk/extensions/wikia/LinkSuggest |
236 | | - * |
| 246 | + * |
237 | 247 | * Scroll a textarea to the current cursor position. You can set the cursor |
238 | 248 | * position with setSelection() |
239 | 249 | * @param force boolean Whether to force a scroll even if the caret position |
240 | 250 | * is already visible. Defaults to false |
241 | 251 | */ |
242 | | -scrollToCaretPosition: function( force ) { |
| 252 | +scrollToCaretPosition: function( options ) { |
243 | 253 | function getLineLength( e ) { |
244 | 254 | return Math.floor( e.scrollWidth / ( $.os.name == 'linux' ? 7 : 8 ) ); |
245 | 255 | } |
— | — | @@ -246,7 +256,7 @@ |
247 | 257 | // FIXME: This functions sucks and is off by a few lines most |
248 | 258 | // of the time. It should be replaced by something decent. |
249 | 259 | var text = e.value.replace( /\r/g, "" ); |
250 | | - var caret = $( e ).getCaretPosition(); |
| 260 | + var caret = $( e ).textSelection( 'getCaretPosition' ); |
251 | 261 | var lineLength = getLineLength( e ); |
252 | 262 | var row = 0; |
253 | 263 | var charInLine = 0; |
— | — | @@ -286,10 +296,12 @@ |
287 | 297 | return ( $.os.name == 'mac' ? 13 : ( $.os.name == 'linux' ? 15 : 16 ) ) * row; |
288 | 298 | } |
289 | 299 | return this.each(function() { |
290 | | - if ( this.selectionStart || this.selectionStart == '0' ) { |
| 300 | + if ( $(this).is( ':hidden' ) ) { |
| 301 | + // Do nothing |
| 302 | + } else if ( this.selectionStart || this.selectionStart == '0' ) { |
291 | 303 | // Mozilla |
292 | 304 | var scroll = getCaretScrollPosition( this ); |
293 | | - if ( force || scroll < $(this).scrollTop() || |
| 305 | + if ( options.force || scroll < $(this).scrollTop() || |
294 | 306 | scroll > $(this).scrollTop() + $(this).height() ) |
295 | 307 | $(this).scrollTop( scroll ); |
296 | 308 | } else if ( document.selection && document.selection.createRange ) { |
— | — | @@ -303,7 +315,7 @@ |
304 | 316 | * character back and forth. |
305 | 317 | */ |
306 | 318 | var range = document.selection.createRange(); |
307 | | - var pos = $(this).getCaretPosition(); |
| 319 | + var pos = $(this).textSelection( 'getCaretPosition' ); |
308 | 320 | var oldScrollTop = this.scrollTop; |
309 | 321 | range.moveToElementText( this ); |
310 | 322 | range.collapse(); |
— | — | @@ -311,7 +323,7 @@ |
312 | 324 | range.select(); |
313 | 325 | if ( this.scrollTop != oldScrollTop ) |
314 | 326 | this.scrollTop += range.offsetTop; |
315 | | - else if ( force ) { |
| 327 | + else if ( options.force ) { |
316 | 328 | range.move( 'character', -1 ); |
317 | 329 | range.select(); |
318 | 330 | } |
— | — | @@ -319,5 +331,51 @@ |
320 | 332 | $(this).trigger( 'scrollToPosition' ); |
321 | 333 | } ); |
322 | 334 | } |
| 335 | +}; |
| 336 | + // Apply defaults |
| 337 | + switch ( command ) { |
| 338 | + //case 'getContents': // no params |
| 339 | + //case 'setContents': // no params with defaults |
| 340 | + //case 'getSelection': // no params |
| 341 | + case 'encapsulateSelection': |
| 342 | + options = $.extend( { |
| 343 | + 'pre': '', // Text to insert before the cursor/selection |
| 344 | + 'peri': '', // Text to insert between pre and post and select afterwards |
| 345 | + 'post': '', // Text to insert after the cursor/selection |
| 346 | + 'ownline': false, // Put the inserted text on a line of its own |
| 347 | + 'replace': false // If there is a selection, replace it with peri instead of leaving it alone |
| 348 | + }, options ); |
| 349 | + break; |
| 350 | + case 'getCaretPosition': |
| 351 | + options = $.extend( { |
| 352 | + 'startAndEnd': false // Return [start, end] instead of just start |
| 353 | + }, options ); |
| 354 | + // FIXME: We may not need character position-based functions if we insert markers in the right places |
| 355 | + break; |
| 356 | + case 'setSelection': |
| 357 | + options = $.extend( { |
| 358 | + 'start': undefined, // Position to start selection at |
| 359 | + 'end': undefined, // Position to end selection at. Defaults to start |
| 360 | + 'startContainer': undefined, // Element to start selection in (iframe only) |
| 361 | + 'endContainer': undefined // Element to end selection in (iframe only). Defaults to startContainer |
| 362 | + }, options ); |
| 363 | + if ( options.end === undefined ) |
| 364 | + options.end = options.start; |
| 365 | + if ( options.endContainer == undefined ) |
| 366 | + options.endContainer = options.startContainer; |
| 367 | + // FIXME: We may not need character position-based functions if we insert markers in the right places |
| 368 | + break; |
| 369 | + case 'scrollToCaretPosition': |
| 370 | + options = $.extend( { |
| 371 | + 'force': false // Force a scroll even if the caret position is already visible |
| 372 | + }, options ); |
| 373 | + break; |
| 374 | + } |
| 375 | + var context = $(this).data( 'wikiEditor-context' ); |
| 376 | + var hasIframe = context !== undefined && context.$iframe !== undefined; |
| 377 | + // iframe functions have not been implemented yet, this is a temp hack |
| 378 | + //var hasIframe = false; |
| 379 | + return ( hasIframe ? context.fn : fn )[command].call( this, options ); |
| 380 | +}; |
323 | 381 | |
324 | | -} ); } )( jQuery ); |
\ No newline at end of file |
| 382 | +} )( jQuery ); |
\ No newline at end of file |
Property changes on: branches/js2-work/phase3/js/mwEmbed/jquery/plugins/jquery.textSelection.js |
___________________________________________________________________ |
Name: svn:mergeinfo |
325 | 383 | + /branches/REL1_15/phase3/js2/mwEmbed/jquery/plugins/jquery.textSelection.js:51646 |
/branches/sqlite/js2/mwEmbed/jquery/plugins/jquery.textSelection.js:58211-58321 |
Index: branches/js2-work/phase3/js/mwEmbed/jquery/plugins/jquery.browserTest.js |
— | — | @@ -0,0 +1,82 @@ |
| 2 | +/* |
| 3 | + |
| 4 | +jQuery Browser Plugin |
| 5 | + * Version 2.3 |
| 6 | + * 2008-09-17 19:27:05 |
| 7 | + * URL: http://jquery.thewikies.com/browser |
| 8 | + * Description: jQuery Browser Plugin extends browser detection capabilities and can assign browser selectors to CSS classes. |
| 9 | + * Author: Nate Cavanaugh, Minhchau Dang, & Jonathan Neal |
| 10 | + * Copyright: Copyright (c) 2008 Jonathan Neal under dual MIT/GPL license. |
| 11 | + * JSLint: This javascript file passes JSLint verification. |
| 12 | +*//*jslint |
| 13 | + bitwise: true, |
| 14 | + browser: true, |
| 15 | + eqeqeq: true, |
| 16 | + forin: true, |
| 17 | + nomen: true, |
| 18 | + plusplus: true, |
| 19 | + undef: true, |
| 20 | + white: true |
| 21 | +*//*global |
| 22 | + jQuery |
| 23 | +*/ |
| 24 | + |
| 25 | +(function ($) { |
| 26 | + $.browserTest = function (a, z) { |
| 27 | + var u = 'unknown', x = 'X', m = function (r, h) { |
| 28 | + for (var i = 0; i < h.length; i = i + 1) { |
| 29 | + r = r.replace(h[i][0], h[i][1]); |
| 30 | + } |
| 31 | + |
| 32 | + return r; |
| 33 | + }, c = function (i, a, b, c) { |
| 34 | + var r = { |
| 35 | + name: m((a.exec(i) || [u, u])[1], b) |
| 36 | + }; |
| 37 | + |
| 38 | + r[r.name] = true; |
| 39 | + |
| 40 | + r.version = (c.exec(i) || [x, x, x, x])[3]; |
| 41 | + |
| 42 | + if (r.name.match(/safari/) && r.version > 400) { |
| 43 | + r.version = '2.0'; |
| 44 | + } |
| 45 | + |
| 46 | + if (r.name === 'presto') { |
| 47 | + r.version = ($.browser.version > 9.27) ? 'futhark' : 'linear_b'; |
| 48 | + } |
| 49 | + r.versionNumber = parseFloat(r.version, 10) || 0; |
| 50 | + r.versionX = (r.version !== x) ? (r.version + '').substr(0, 1) : x; |
| 51 | + r.className = r.name + r.versionX; |
| 52 | + |
| 53 | + return r; |
| 54 | + }; |
| 55 | + |
| 56 | + a = (a.match(/Opera|Navigator|Minefield|KHTML|Chrome/) ? m(a, [ |
| 57 | + [/(Firefox|MSIE|KHTML,\slike\sGecko|Konqueror)/, ''], |
| 58 | + ['Chrome Safari', 'Chrome'], |
| 59 | + ['KHTML', 'Konqueror'], |
| 60 | + ['Minefield', 'Firefox'], |
| 61 | + ['Navigator', 'Netscape'] |
| 62 | + ]) : a).toLowerCase(); |
| 63 | + |
| 64 | + $.browser = $.extend((!z) ? $.browser : {}, c(a, /(camino|chrome|firefox|netscape|konqueror|lynx|msie|opera|safari)/, [], /(camino|chrome|firefox|netscape|netscape6|opera|version|konqueror|lynx|msie|safari)(\/|\s)([a-z0-9\.\+]*?)(\;|dev|rel|\s|$)/)); |
| 65 | + |
| 66 | + $.layout = c(a, /(gecko|konqueror|msie|opera|webkit)/, [ |
| 67 | + ['konqueror', 'khtml'], |
| 68 | + ['msie', 'trident'], |
| 69 | + ['opera', 'presto'] |
| 70 | + ], /(applewebkit|rv|konqueror|msie)(\:|\/|\s)([a-z0-9\.]*?)(\;|\)|\s)/); |
| 71 | + |
| 72 | + $.os = { |
| 73 | + name: (/(win|mac|linux|sunos|solaris|iphone)/.exec(navigator.platform.toLowerCase()) || [u])[0].replace('sunos', 'solaris') |
| 74 | + }; |
| 75 | + |
| 76 | + if (!z) { |
| 77 | + $('html').addClass([$.os.name, $.browser.name, $.browser.className, $.layout.name, $.layout.className].join(' ')); |
| 78 | + } |
| 79 | + }; |
| 80 | + |
| 81 | + $.browserTest(navigator.userAgent); |
| 82 | +})(jQuery); |
| 83 | + |
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/loader.js |
— | — | @@ -14,7 +14,7 @@ |
15 | 15 | "mw.Firefogg" : "modules/AddMedia/mw.Firefogg.js", |
16 | 16 | "mw.FirefoggGUI" : "modules/AddMedia/mw.FirefoggGUI.js", |
17 | 17 | "mw.FirefoggRender" : "modules/libSequencer/mw.FirefoggRender.js", |
18 | | - "mw.RemoteSearchDriver" : "modules/AddMedia/mw.RemoteSearchDriver.js", |
| 18 | + "mw.RemoteSearchDriver" : "modules/AddMedia/mw.RemoteSearchDriver.js", |
19 | 19 | |
20 | 20 | "baseRemoteSearch" : "modules/AddMedia/searchLibs/baseRemoteSearch.js", |
21 | 21 | "mediaWikiSearch" : "modules/AddMedia/searchLibs/mediaWikiSearch.js", |
— | — | @@ -33,10 +33,11 @@ |
34 | 34 | //Setup the addMediaWizard module |
35 | 35 | mw.addModuleLoader( 'AddMedia.addMediaWizard', function( callback ){ |
36 | 36 | // Load all the required libs: |
37 | | - mw.load( [ |
| 37 | + var libReq = [ |
38 | 38 | [ 'mw.RemoteSearchDriver', |
39 | 39 | '$j.cookie', |
40 | 40 | '$j.fn.textSelection', |
| 41 | + '$j.browserTest', |
41 | 42 | '$j.ui' |
42 | 43 | ], [ |
43 | 44 | '$j.ui.resizable', |
— | — | @@ -45,7 +46,8 @@ |
46 | 47 | '$j.ui.tabs', |
47 | 48 | '$j.ui.sortable' |
48 | 49 | ] |
49 | | - ], function() { |
| 50 | + ]; |
| 51 | + mw.load( libReq , function() { |
50 | 52 | callback( 'AddMedia.addMediaWizard' ); |
51 | 53 | } ); |
52 | 54 | }); |
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.RemoteSearchDriver.js |
— | — | @@ -1366,8 +1366,7 @@ |
1367 | 1367 | } |
1368 | 1368 | |
1369 | 1369 | mw.log( 'did numResults :: ' + numResults + |
1370 | | - ' append: ' + $j( '#rsd_q' ).val() ); |
1371 | | - |
| 1370 | + ' append: ' + $j( '#rsd_q' ).val() ); |
1372 | 1371 | // Remove any old search res |
1373 | 1372 | $j( '#rsd_no_search_res' ).remove(); |
1374 | 1373 | if ( numResults == 0 ) { |
— | — | @@ -1907,7 +1906,7 @@ |
1908 | 1907 | var _this = this; |
1909 | 1908 | |
1910 | 1909 | // Clone the resource. Not sure why this not-working clone was put here... |
1911 | | - // using the actual resource does not really affect things |
| 1910 | + // using the actual resource should be fine |
1912 | 1911 | /* |
1913 | 1912 | var proto = {}; |
1914 | 1913 | proto.prototype = resource; |
— | — | @@ -1927,7 +1926,8 @@ |
1928 | 1927 | // Check if the file is local ( can be shared repo ) |
1929 | 1928 | if ( provider.check_shared ) { |
1930 | 1929 | _this.findFileInLocalWiki( resource.target_resource_title, function( imagePage ) { |
1931 | | - if ( imagePage && imagePage['imagerepository'] == 'shared' ) { |
| 1930 | + if ( imagePage && imagePage['imagerepository'] == 'shared' || |
| 1931 | + imagePage['imagerepository'] == 'commons') { |
1932 | 1932 | myCallback( 'shared' ); |
1933 | 1933 | } else { |
1934 | 1934 | _this.isFileAlreadyImported( resource, myCallback ); |
— | — | @@ -2346,8 +2346,10 @@ |
2347 | 2347 | } ); |
2348 | 2348 | |
2349 | 2349 | // Get the preview wikitext |
| 2350 | + var embed_code = _this.getEmbedCode( resource ); |
| 2351 | + $j( _this.target_textbox ).textSelection( 'encapsulateSelection', { 'post' : embed_code } ); |
2350 | 2352 | _this.parse( |
2351 | | - _this.getPreviewText( resource ), |
| 2353 | + $j( _this.target_textbox ).val(), |
2352 | 2354 | _this.target_title, |
2353 | 2355 | function( phtml ) { |
2354 | 2356 | $j( '#rsd_preview_display' ).html( phtml ); |
— | — | @@ -2386,7 +2388,7 @@ |
2387 | 2389 | * |
2388 | 2390 | * @param {Object} resource Resource to get preview text for. |
2389 | 2391 | */ |
2390 | | - getPreviewText: function( resource ) { |
| 2392 | + /*getPreviewText: function( resource ) { |
2391 | 2393 | var _this = this; |
2392 | 2394 | var text; |
2393 | 2395 | |
— | — | @@ -2408,7 +2410,7 @@ |
2409 | 2411 | text = text + '<references/>'; |
2410 | 2412 | } |
2411 | 2413 | return text; |
2412 | | - }, |
| 2414 | + },*/ |
2413 | 2415 | |
2414 | 2416 | /** |
2415 | 2417 | * issues the wikitext parse call |
— | — | @@ -2439,9 +2441,9 @@ |
2440 | 2442 | */ |
2441 | 2443 | insertResource: function( resource ) { |
2442 | 2444 | mw.log( 'insertResource: ' + resource.title ); |
2443 | | - var _this = this; |
| 2445 | + var _this = this; |
2444 | 2446 | // Double check that the resource is present: |
2445 | | - this.isFileLocallyAvailable( resource, function( status ) { |
| 2447 | + this.isFileLocallyAvailable( resource, function( status ) { |
2446 | 2448 | if ( status === 'missing' ) { |
2447 | 2449 | _this.showImportUI( resource, function() { |
2448 | 2450 | _this.insertResourceToOutput( resource ); |
— | — | @@ -2451,7 +2453,7 @@ |
2452 | 2454 | if ( status === 'local' || status === 'shared' || status === 'imported' ) { |
2453 | 2455 | _this.insertResourceToOutput( resource ); |
2454 | 2456 | } |
2455 | | - //NOTE: should hannlde errors or other status states? |
| 2457 | + //NOTE: should hanndle errors or other status states? |
2456 | 2458 | } ); |
2457 | 2459 | }, |
2458 | 2460 | |
— | — | @@ -2461,10 +2463,10 @@ |
2462 | 2464 | * @param {Object} resource Resource to be inserted into the output targets |
2463 | 2465 | */ |
2464 | 2466 | insertResourceToOutput: function( resource ){ |
2465 | | - var _this = this; |
2466 | | - $j( _this.target_textbox ).val( _this.getPreviewText( resource ) ); |
2467 | | - _this.clearTextboxCache(); |
2468 | | - |
| 2467 | + var _this = this; |
| 2468 | + var embed_code = _this.getEmbedCode( resource ); |
| 2469 | + $j( _this.target_textbox ).textSelection( 'encapsulateSelection', { 'post' : embed_code } ); |
| 2470 | + |
2469 | 2471 | // Update the render area for HTML output of video tag with mwEmbed "player" |
2470 | 2472 | var embedCode = _this.getEmbedCode( resource ); |
2471 | 2473 | if ( _this.target_render_area && embedCode ) { |
Index: branches/js2-work/phase3/js/mwEmbed/mwEmbed.js |
— | — | @@ -2383,7 +2383,8 @@ |
2384 | 2384 | "$j.cookie" : "jquery/plugins/jquery.cookie.js", |
2385 | 2385 | "$j.contextMenu" : "jquery/plugins/jquery.contextMenu.js", |
2386 | 2386 | "$j.fn.suggestions" : "jquery/plugins/jquery.suggestions.js", |
2387 | | - "$j.fn.textSelection" : "jquery/plugins/jquery.textSelection.js", |
| 2387 | + "$j.fn.textSelection" : "jquery/plugins/jquery.textSelection.js", |
| 2388 | + "$j.browserTest" : "jquery/plugins/jquery.browserTest.js", |
2388 | 2389 | |
2389 | 2390 | "$j.effects.blind" : "jquery/jquery.ui/ui/effects.blind.js", |
2390 | 2391 | "$j.effects.drop" : "jquery/jquery.ui/ui/effects.drop.js", |
Index: branches/js2-work/phase3/js/js2stopgap.js |
— | — | @@ -804,12 +804,14 @@ |
805 | 805 | name = "float"; |
806 | 806 | |
807 | 807 | name = name.replace( / ( [A - Z] ) /g, "-$1" ).toLowerCase(); |
| 808 | + try{ |
| 809 | + var computedStyle = defaultView.getComputedStyle( elem, null ); |
| 810 | + if ( computedStyle ) |
| 811 | + ret = computedStyle.getPropertyValue( name ); |
| 812 | + }catch(e){ |
| 813 | + // failed to get computedStyle |
| 814 | + } |
808 | 815 | |
809 | | - var computedStyle = defaultView.getComputedStyle( elem, null ); |
810 | | - |
811 | | - if ( computedStyle ) |
812 | | - ret = computedStyle.getPropertyValue( name ); |
813 | | - |
814 | 816 | // We should always get a number back from opacity |
815 | 817 | if ( name == "opacity" && ret == "" ) |
816 | 818 | ret = "1"; |