r61075 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61074‎ | r61075 | r61076 >
Date:03:10, 15 January 2010
Author:dale
Status:reverted (Comments)
Tags:
Comment:
* puts jquery computeStyle in try catch ( un-breaks usability / js2 integration )
Modified paths:
  • /branches/js2-work/phase3/js/js2stopgap.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/jquery/plugins/jquery.browserTest.js (added) (history)
  • /branches/js2-work/phase3/js/mwEmbed/jquery/plugins/jquery.textSelection.js (replaced) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/loader.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.RemoteSearchDriver.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/mwEmbed.js (modified) (history)
  • /trunk/phase3/js2/js2stopgap.js (modified) (history)
  • /trunk/phase3/js2/js2stopgap.min.js (modified) (history)

Diff [purge]

Index: trunk/phase3/js2/js2stopgap.js
@@ -804,9 +804,11 @@
805805 name = "float";
806806
807807 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+ }
811813 if ( computedStyle )
812814 ret = computedStyle.getPropertyValue( name );
813815
Index: trunk/phase3/js2/js2stopgap.min.js
@@ -88,8 +88,8 @@
8989 if(name.match(/float/i))
9090 name=styleFloat;if(!force&&style&&style[name])
9191 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=="")
9494 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;}}
9595 return ret;},clean:function(elems,context,fragment){context=context||document;if(typeof context.createElement==="undefined")
9696 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 @@
22 /**
33 * These plugins provide extra functionality for interaction with textareas.
44 */
5 -( function( $ ) { $.fn.extend( {
 5+( function( $ ) {
 6+$.fn.textSelection = function( command, options ) {
 7+var fn = {
68 /**
 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+/**
720 * Get the currently selected text in this textarea. Will focus the textarea
821 * in some browsers (IE/Opera)
922 */
10 -textSelection: function() {
11 - var e = this.jquery ? this[0] : this;
 23+getSelection: function() {
 24+ var e = this.get( 0 );
1225 var retval = '';
13 - if ( e.style.display == 'none' ) {
 26+ if ( $(e).is( ':hidden' ) ) {
1427 // Do nothing
1528 } else if ( document.selection && document.selection.createRange ) {
1629 e.focus();
@@ -23,34 +36,28 @@
2437 /**
2538 * Ported from skins/common/edit.js by Trevor Parscal
2639 * (c) 2009 Wikimedia Foundation (GPLv2) - http://www.wikimedia.org
27 - *
 40+ *
2841 * Inserts text at the begining and end of a text selection, optionally
2942 * 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
3643 */
37 -encapsulateSelection: function( pre, peri, post, ownline, replace ) {
 44+encapsulateSelection: function( options ) {
3845 return this.each( function() {
3946 /**
4047 * Check if the selected text is the same as the insert text
41 - */
 48+ */
4249 function checkSelectedText() {
4350 if ( !selText ) {
44 - selText = peri;
 51+ selText = options.peri;
4552 isSample = true;
46 - } else if ( replace ) {
47 - selText = peri;
 53+ } else if ( options.replace ) {
 54+ selText = options.peri;
4855 } else if ( selText.charAt( selText.length - 1 ) == ' ' ) {
4956 // Exclude ending space char
5057 selText = selText.substring(0, selText.length - 1);
51 - post += ' ';
 58+ options.post += ' ';
5259 }
5360 }
54 - var selText = $(this).getSelection();
 61+ var selText = $(this).textSelection( 'getSelection' );
5562 var isSample = false;
5663 if ( this.style.display == 'none' ) {
5764 // Do nothing
@@ -60,57 +67,60 @@
6168 var startPos = this.selectionStart;
6269 var endPos = this.selectionEnd;
6370 checkSelectedText();
64 - if ( ownline ) {
 71+ if ( options.ownline ) {
6572 if ( startPos != 0 && this.value.charAt( startPos - 1 ) != "\n" ) {
66 - pre = "\n" + pre;
 73+ options.pre = "\n" + options.pre;
6774 }
6875 if ( this.value.charAt( endPos ) != "\n" ) {
69 - post += "\n";
 76+ options.post += "\n";
7077 }
7178 }
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 );
7381 if ( window.opera ) {
74 - pre = pre.replace( /\r?\n/g, "\r\n" );
 82+ options.pre = options.pre.replace( /\r?\n/g, "\r\n" );
7583 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" );
7785 }
7886 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;
8189 } else {
82 - this.selectionStart = startPos + pre.length + selText.length + post.length;
 90+ this.selectionStart = startPos + options.pre.length + selText.length +
 91+ options.post.length;
8392 this.selectionEnd = this.selectionStart;
8493 }
8594 } else if ( document.selection && document.selection.createRange ) {
8695 // IE
8796 $(this).focus();
8897 var range = document.selection.createRange();
89 - if ( ownline && range.moveStart ) {
 98+ if ( options.ownline && range.moveStart ) {
9099 var range2 = document.selection.createRange();
91100 range2.collapse();
92101 range2.moveStart( 'character', -1 );
93102 // FIXME: Which check is correct?
94103 if ( range2.text != "\r" && range2.text != "\n" && range2.text != "" ) {
95 - pre = "\n" + pre;
 104+ options.pre = "\n" + options.pre;
96105 }
97106 var range3 = document.selection.createRange();
98107 range3.collapse( false );
99108 range3.moveEnd( 'character', 1 );
100109 if ( range3.text != "\r" && range3.text != "\n" && range3.text != "" ) {
101 - post += "\n";
 110+ options.post += "\n";
102111 }
103112 }
104113 checkSelectedText();
105 - range.text = pre + selText + post;
 114+ range.text = options.pre + selText + options.post;
106115 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 );
109118 }
110119 range.select();
111120 }
112121 // 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 ] );
115125 });
116126 },
117127 /**
@@ -120,9 +130,9 @@
121131 * http://www.dedestruct.com/2008/03/22/howto-cross-browser-cursor-position-in-textareas/
122132 *
123133 * Get the position (in resolution of bytes not nessecarily characters)
124 - * in a textarea
 134+ * in a textarea
125135 */
126 - getCaretPosition: function( startAndEnd ) {
 136+ getCaretPosition: function( options ) {
127137 function getCaret( e ) {
128138 var caretPos = 0, endPos = 0;
129139 if ( $.browser.msie ) {
@@ -200,31 +210,31 @@
201211 caretPos = e.selectionStart;
202212 endPos = e.selectionEnd;
203213 }
204 - return startAndEnd ? [ caretPos, endPos ] : caretPos;
 214+ return options.startAndEnd ? [ caretPos, endPos ] : caretPos;
205215 }
206216 return getCaret( this.get( 0 ) );
207217 },
208 -setSelection: function( start, end ) {
209 - if ( typeof end == 'undefined' )
210 - end = start;
 218+setSelection: function( options ) {
211219 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' ) {
213223 // Opera 9.0 doesn't allow setting selectionStart past
214224 // selectionEnd; any attempts to do that will be ignored
215225 // 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;
219229 } else {
220 - this.selectionStart = start;
221 - this.selectionEnd = end;
 230+ this.selectionStart = options.start;
 231+ this.selectionEnd = options.end;
222232 }
223233 } else if ( document.body.createTextRange ) {
224234 var selection = document.body.createTextRange();
225235 selection.moveToElementText( this );
226236 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 );
229239 selection.select();
230240 }
231241 });
@@ -232,13 +242,13 @@
233243 /**
234244 * Ported from Wikia's LinkSuggest extension
235245 * https://svn.wikia-code.com/wikia/trunk/extensions/wikia/LinkSuggest
236 - *
 246+ *
237247 * Scroll a textarea to the current cursor position. You can set the cursor
238248 * position with setSelection()
239249 * @param force boolean Whether to force a scroll even if the caret position
240250 * is already visible. Defaults to false
241251 */
242 -scrollToCaretPosition: function( force ) {
 252+scrollToCaretPosition: function( options ) {
243253 function getLineLength( e ) {
244254 return Math.floor( e.scrollWidth / ( $.os.name == 'linux' ? 7 : 8 ) );
245255 }
@@ -246,7 +256,7 @@
247257 // FIXME: This functions sucks and is off by a few lines most
248258 // of the time. It should be replaced by something decent.
249259 var text = e.value.replace( /\r/g, "" );
250 - var caret = $( e ).getCaretPosition();
 260+ var caret = $( e ).textSelection( 'getCaretPosition' );
251261 var lineLength = getLineLength( e );
252262 var row = 0;
253263 var charInLine = 0;
@@ -286,10 +296,12 @@
287297 return ( $.os.name == 'mac' ? 13 : ( $.os.name == 'linux' ? 15 : 16 ) ) * row;
288298 }
289299 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' ) {
291303 // Mozilla
292304 var scroll = getCaretScrollPosition( this );
293 - if ( force || scroll < $(this).scrollTop() ||
 305+ if ( options.force || scroll < $(this).scrollTop() ||
294306 scroll > $(this).scrollTop() + $(this).height() )
295307 $(this).scrollTop( scroll );
296308 } else if ( document.selection && document.selection.createRange ) {
@@ -303,7 +315,7 @@
304316 * character back and forth.
305317 */
306318 var range = document.selection.createRange();
307 - var pos = $(this).getCaretPosition();
 319+ var pos = $(this).textSelection( 'getCaretPosition' );
308320 var oldScrollTop = this.scrollTop;
309321 range.moveToElementText( this );
310322 range.collapse();
@@ -311,7 +323,7 @@
312324 range.select();
313325 if ( this.scrollTop != oldScrollTop )
314326 this.scrollTop += range.offsetTop;
315 - else if ( force ) {
 327+ else if ( options.force ) {
316328 range.move( 'character', -1 );
317329 range.select();
318330 }
@@ -319,5 +331,51 @@
320332 $(this).trigger( 'scrollToPosition' );
321333 } );
322334 }
 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+};
323381
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
325383 + /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 @@
1515 "mw.Firefogg" : "modules/AddMedia/mw.Firefogg.js",
1616 "mw.FirefoggGUI" : "modules/AddMedia/mw.FirefoggGUI.js",
1717 "mw.FirefoggRender" : "modules/libSequencer/mw.FirefoggRender.js",
18 - "mw.RemoteSearchDriver" : "modules/AddMedia/mw.RemoteSearchDriver.js",
 18+ "mw.RemoteSearchDriver" : "modules/AddMedia/mw.RemoteSearchDriver.js",
1919
2020 "baseRemoteSearch" : "modules/AddMedia/searchLibs/baseRemoteSearch.js",
2121 "mediaWikiSearch" : "modules/AddMedia/searchLibs/mediaWikiSearch.js",
@@ -33,10 +33,11 @@
3434 //Setup the addMediaWizard module
3535 mw.addModuleLoader( 'AddMedia.addMediaWizard', function( callback ){
3636 // Load all the required libs:
37 - mw.load( [
 37+ var libReq = [
3838 [ 'mw.RemoteSearchDriver',
3939 '$j.cookie',
4040 '$j.fn.textSelection',
 41+ '$j.browserTest',
4142 '$j.ui'
4243 ], [
4344 '$j.ui.resizable',
@@ -45,7 +46,8 @@
4647 '$j.ui.tabs',
4748 '$j.ui.sortable'
4849 ]
49 - ], function() {
 50+ ];
 51+ mw.load( libReq , function() {
5052 callback( 'AddMedia.addMediaWizard' );
5153 } );
5254 });
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.RemoteSearchDriver.js
@@ -1366,8 +1366,7 @@
13671367 }
13681368
13691369 mw.log( 'did numResults :: ' + numResults +
1370 - ' append: ' + $j( '#rsd_q' ).val() );
1371 -
 1370+ ' append: ' + $j( '#rsd_q' ).val() );
13721371 // Remove any old search res
13731372 $j( '#rsd_no_search_res' ).remove();
13741373 if ( numResults == 0 ) {
@@ -1907,7 +1906,7 @@
19081907 var _this = this;
19091908
19101909 // 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
19121911 /*
19131912 var proto = {};
19141913 proto.prototype = resource;
@@ -1927,7 +1926,8 @@
19281927 // Check if the file is local ( can be shared repo )
19291928 if ( provider.check_shared ) {
19301929 _this.findFileInLocalWiki( resource.target_resource_title, function( imagePage ) {
1931 - if ( imagePage && imagePage['imagerepository'] == 'shared' ) {
 1930+ if ( imagePage && imagePage['imagerepository'] == 'shared' ||
 1931+ imagePage['imagerepository'] == 'commons') {
19321932 myCallback( 'shared' );
19331933 } else {
19341934 _this.isFileAlreadyImported( resource, myCallback );
@@ -2346,8 +2346,10 @@
23472347 } );
23482348
23492349 // Get the preview wikitext
 2350+ var embed_code = _this.getEmbedCode( resource );
 2351+ $j( _this.target_textbox ).textSelection( 'encapsulateSelection', { 'post' : embed_code } );
23502352 _this.parse(
2351 - _this.getPreviewText( resource ),
 2353+ $j( _this.target_textbox ).val(),
23522354 _this.target_title,
23532355 function( phtml ) {
23542356 $j( '#rsd_preview_display' ).html( phtml );
@@ -2386,7 +2388,7 @@
23872389 *
23882390 * @param {Object} resource Resource to get preview text for.
23892391 */
2390 - getPreviewText: function( resource ) {
 2392+ /*getPreviewText: function( resource ) {
23912393 var _this = this;
23922394 var text;
23932395
@@ -2408,7 +2410,7 @@
24092411 text = text + '<references/>';
24102412 }
24112413 return text;
2412 - },
 2414+ },*/
24132415
24142416 /**
24152417 * issues the wikitext parse call
@@ -2439,9 +2441,9 @@
24402442 */
24412443 insertResource: function( resource ) {
24422444 mw.log( 'insertResource: ' + resource.title );
2443 - var _this = this;
 2445+ var _this = this;
24442446 // Double check that the resource is present:
2445 - this.isFileLocallyAvailable( resource, function( status ) {
 2447+ this.isFileLocallyAvailable( resource, function( status ) {
24462448 if ( status === 'missing' ) {
24472449 _this.showImportUI( resource, function() {
24482450 _this.insertResourceToOutput( resource );
@@ -2451,7 +2453,7 @@
24522454 if ( status === 'local' || status === 'shared' || status === 'imported' ) {
24532455 _this.insertResourceToOutput( resource );
24542456 }
2455 - //NOTE: should hannlde errors or other status states?
 2457+ //NOTE: should hanndle errors or other status states?
24562458 } );
24572459 },
24582460
@@ -2461,10 +2463,10 @@
24622464 * @param {Object} resource Resource to be inserted into the output targets
24632465 */
24642466 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+
24692471 // Update the render area for HTML output of video tag with mwEmbed "player"
24702472 var embedCode = _this.getEmbedCode( resource );
24712473 if ( _this.target_render_area && embedCode ) {
Index: branches/js2-work/phase3/js/mwEmbed/mwEmbed.js
@@ -2383,7 +2383,8 @@
23842384 "$j.cookie" : "jquery/plugins/jquery.cookie.js",
23852385 "$j.contextMenu" : "jquery/plugins/jquery.contextMenu.js",
23862386 "$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",
23882389
23892390 "$j.effects.blind" : "jquery/jquery.ui/ui/effects.blind.js",
23902391 "$j.effects.drop" : "jquery/jquery.ui/ui/effects.drop.js",
Index: branches/js2-work/phase3/js/js2stopgap.js
@@ -804,12 +804,14 @@
805805 name = "float";
806806
807807 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+ }
808815
809 - var computedStyle = defaultView.getComputedStyle( elem, null );
810 -
811 - if ( computedStyle )
812 - ret = computedStyle.getPropertyValue( name );
813 -
814816 // We should always get a number back from opacity
815817 if ( name == "opacity" && ret == "" )
816818 ret = "1";

Follow-up revisions

RevisionCommit summaryAuthorDate
r61228Update js2stopgap.min.js for at least r61137 and r61075catrope00:58, 19 January 2010

Comments

#Comment by Tim Starling (talk | contribs)   05:35, 26 January 2010

Suggest revert, changes large amounts of code unrelated to the commit message, presumably accidental. The only part that was actually documented in the commit message is patently broken.

Status & tagging log