r54680 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r54679‎ | r54680 | r54681 >
Date:19:16, 9 August 2009
Author:catrope
Status:deferred
Tags:
Comment:
UsabilityInitiative: (bug 20134) Provide wikEd with a hook for text insertion. For usage information see the bug
Modified paths:
  • /trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/js2.combined.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins.combined.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins/jquery.textSelection.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php
@@ -49,16 +49,16 @@
5050 array( 'src' => 'js/plugins/jquery.async.js', 'version' => 3 ),
5151 array( 'src' => 'js/plugins/jquery.browser.js', 'version' => 3 ),
5252 array( 'src' => 'js/plugins/jquery.cookie.js', 'version' => 3 ),
53 - array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 3 ),
 53+ array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 4 ),
5454 array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 4 ),
5555 array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 5 ),
5656 array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 4 ),
5757 ),
5858 'combined' => array(
59 - array( 'src' => 'js/plugins.combined.js', 'version' => 5 ),
 59+ array( 'src' => 'js/plugins.combined.js', 'version' => 6 ),
6060 ),
6161 'minified' => array(
62 - array( 'src' => 'js/plugins.combined.min.js', 'version' => 5 ),
 62+ array( 'src' => 'js/plugins.combined.min.js', 'version' => 6 ),
6363 ),
6464 ),
6565 );
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.textSelection.js
@@ -27,7 +27,7 @@
2828 post += ' '
2929 }
3030 }
31 - var e = this.jquery ? this[0] : this;
 31+ var e = this.jquery ? this[0] : this;
3232 var selText;
3333 var isSample = false;
3434 if ( document.selection && document.selection.createRange ) {
@@ -75,7 +75,7 @@
7676 }
7777 e.scrollTop = textScroll;
7878 }
79 - $(this).trigger( 'encapsulateSelection' );
 79+ $(this).trigger( 'encapsulateSelection', [ pre, peri, post ] );
8080 },
8181 /**
8282 * Ported from Wikia's LinkSuggest extension
Index: trunk/extensions/UsabilityInitiative/js/js2.combined.js
@@ -1266,150 +1266,150 @@
12671267 function num(elem, prop) {
12681268 return elem[0] && parseInt( jQuery.curCSS(elem[0], prop, true), 10 ) || 0;
12691269 }
1270 -var expando = "jQuery" + now(), uuid = 0, windowData = {};
1271 -
1272 -jQuery.extend({
1273 - cache: {},
1274 -
1275 - data: function( elem, name, data ) {
1276 - elem = elem == window ?
1277 - windowData :
1278 - elem;
1279 -
1280 - var id = elem[ expando ];
1281 -
1282 - // Compute a unique ID for the element
1283 - if ( !id )
1284 - id = elem[ expando ] = ++uuid;
1285 -
1286 - // Only generate the data cache if we're
1287 - // trying to access or manipulate it
1288 - if ( name && !jQuery.cache[ id ] )
1289 - jQuery.cache[ id ] = {};
1290 -
1291 - // Prevent overriding the named cache with undefined values
1292 - if ( data !== undefined )
1293 - jQuery.cache[ id ][ name ] = data;
1294 -
1295 - // Return the named cache data, or the ID for the element
1296 - return name ?
1297 - jQuery.cache[ id ][ name ] :
1298 - id;
1299 - },
1300 -
1301 - removeData: function( elem, name ) {
1302 - elem = elem == window ?
1303 - windowData :
1304 - elem;
1305 -
1306 - var id = elem[ expando ];
1307 -
1308 - // If we want to remove a specific section of the element's data
1309 - if ( name ) {
1310 - if ( jQuery.cache[ id ] ) {
1311 - // Remove the section of cache data
1312 - delete jQuery.cache[ id ][ name ];
1313 -
1314 - // If we've removed all the data, remove the element's cache
1315 - name = "";
1316 -
1317 - for ( name in jQuery.cache[ id ] )
1318 - break;
1319 -
1320 - if ( !name )
1321 - jQuery.removeData( elem );
1322 - }
1323 -
1324 - // Otherwise, we want to remove all of the element's data
1325 - } else {
1326 - // Clean up the element expando
1327 - try {
1328 - delete elem[ expando ];
1329 - } catch(e){
1330 - // IE has trouble directly removing the expando
1331 - // but it's ok with using removeAttribute
1332 - if ( elem.removeAttribute )
1333 - elem.removeAttribute( expando );
1334 - }
1335 -
1336 - // Completely remove the data cache
1337 - delete jQuery.cache[ id ];
1338 - }
1339 - },
1340 - queue: function( elem, type, data ) {
1341 - if ( elem ){
1342 -
1343 - type = (type || "fx") + "queue";
1344 -
1345 - var q = jQuery.data( elem, type );
1346 -
1347 - if ( !q || jQuery.isArray(data) )
1348 - q = jQuery.data( elem, type, jQuery.makeArray(data) );
1349 - else if( data )
1350 - q.push( data );
1351 -
1352 - }
1353 - return q;
1354 - },
1355 -
1356 - dequeue: function( elem, type ){
1357 - var queue = jQuery.queue( elem, type ),
1358 - fn = queue.shift();
1359 -
1360 - if( !type || type === "fx" )
1361 - fn = queue[0];
1362 -
1363 - if( fn !== undefined )
1364 - fn.call(elem);
1365 - }
1366 -});
1367 -
1368 -jQuery.fn.extend({
1369 - data: function( key, value ){
1370 - var parts = key.split(".");
1371 - parts[1] = parts[1] ? "." + parts[1] : "";
1372 -
1373 - if ( value === undefined ) {
1374 - var data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
1375 -
1376 - if ( data === undefined && this.length )
1377 - data = jQuery.data( this[0], key );
1378 -
1379 - return data === undefined && parts[1] ?
1380 - this.data( parts[0] ) :
1381 - data;
1382 - } else
1383 - return this.trigger("setData" + parts[1] + "!", [parts[0], value]).each(function(){
1384 - jQuery.data( this, key, value );
1385 - });
1386 - },
1387 -
1388 - removeData: function( key ){
1389 - return this.each(function(){
1390 - jQuery.removeData( this, key );
1391 - });
1392 - },
1393 - queue: function(type, data){
1394 - if ( typeof type !== "string" ) {
1395 - data = type;
1396 - type = "fx";
1397 - }
1398 -
1399 - if ( data === undefined )
1400 - return jQuery.queue( this[0], type );
1401 -
1402 - return this.each(function(){
1403 - var queue = jQuery.queue( this, type, data );
1404 -
1405 - if( type == "fx" && queue.length == 1 )
1406 - queue[0].call(this);
1407 - });
1408 - },
1409 - dequeue: function(type){
1410 - return this.each(function(){
1411 - jQuery.dequeue( this, type );
1412 - });
1413 - }
 1270+var expando = "jQuery" + now(), uuid = 0, windowData = {};
 1271+
 1272+jQuery.extend({
 1273+ cache: {},
 1274+
 1275+ data: function( elem, name, data ) {
 1276+ elem = elem == window ?
 1277+ windowData :
 1278+ elem;
 1279+
 1280+ var id = elem[ expando ];
 1281+
 1282+ // Compute a unique ID for the element
 1283+ if ( !id )
 1284+ id = elem[ expando ] = ++uuid;
 1285+
 1286+ // Only generate the data cache if we're
 1287+ // trying to access or manipulate it
 1288+ if ( name && !jQuery.cache[ id ] )
 1289+ jQuery.cache[ id ] = {};
 1290+
 1291+ // Prevent overriding the named cache with undefined values
 1292+ if ( data !== undefined )
 1293+ jQuery.cache[ id ][ name ] = data;
 1294+
 1295+ // Return the named cache data, or the ID for the element
 1296+ return name ?
 1297+ jQuery.cache[ id ][ name ] :
 1298+ id;
 1299+ },
 1300+
 1301+ removeData: function( elem, name ) {
 1302+ elem = elem == window ?
 1303+ windowData :
 1304+ elem;
 1305+
 1306+ var id = elem[ expando ];
 1307+
 1308+ // If we want to remove a specific section of the element's data
 1309+ if ( name ) {
 1310+ if ( jQuery.cache[ id ] ) {
 1311+ // Remove the section of cache data
 1312+ delete jQuery.cache[ id ][ name ];
 1313+
 1314+ // If we've removed all the data, remove the element's cache
 1315+ name = "";
 1316+
 1317+ for ( name in jQuery.cache[ id ] )
 1318+ break;
 1319+
 1320+ if ( !name )
 1321+ jQuery.removeData( elem );
 1322+ }
 1323+
 1324+ // Otherwise, we want to remove all of the element's data
 1325+ } else {
 1326+ // Clean up the element expando
 1327+ try {
 1328+ delete elem[ expando ];
 1329+ } catch(e){
 1330+ // IE has trouble directly removing the expando
 1331+ // but it's ok with using removeAttribute
 1332+ if ( elem.removeAttribute )
 1333+ elem.removeAttribute( expando );
 1334+ }
 1335+
 1336+ // Completely remove the data cache
 1337+ delete jQuery.cache[ id ];
 1338+ }
 1339+ },
 1340+ queue: function( elem, type, data ) {
 1341+ if ( elem ){
 1342+
 1343+ type = (type || "fx") + "queue";
 1344+
 1345+ var q = jQuery.data( elem, type );
 1346+
 1347+ if ( !q || jQuery.isArray(data) )
 1348+ q = jQuery.data( elem, type, jQuery.makeArray(data) );
 1349+ else if( data )
 1350+ q.push( data );
 1351+
 1352+ }
 1353+ return q;
 1354+ },
 1355+
 1356+ dequeue: function( elem, type ){
 1357+ var queue = jQuery.queue( elem, type ),
 1358+ fn = queue.shift();
 1359+
 1360+ if( !type || type === "fx" )
 1361+ fn = queue[0];
 1362+
 1363+ if( fn !== undefined )
 1364+ fn.call(elem);
 1365+ }
 1366+});
 1367+
 1368+jQuery.fn.extend({
 1369+ data: function( key, value ){
 1370+ var parts = key.split(".");
 1371+ parts[1] = parts[1] ? "." + parts[1] : "";
 1372+
 1373+ if ( value === undefined ) {
 1374+ var data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
 1375+
 1376+ if ( data === undefined && this.length )
 1377+ data = jQuery.data( this[0], key );
 1378+
 1379+ return data === undefined && parts[1] ?
 1380+ this.data( parts[0] ) :
 1381+ data;
 1382+ } else
 1383+ return this.trigger("setData" + parts[1] + "!", [parts[0], value]).each(function(){
 1384+ jQuery.data( this, key, value );
 1385+ });
 1386+ },
 1387+
 1388+ removeData: function( key ){
 1389+ return this.each(function(){
 1390+ jQuery.removeData( this, key );
 1391+ });
 1392+ },
 1393+ queue: function(type, data){
 1394+ if ( typeof type !== "string" ) {
 1395+ data = type;
 1396+ type = "fx";
 1397+ }
 1398+
 1399+ if ( data === undefined )
 1400+ return jQuery.queue( this[0], type );
 1401+
 1402+ return this.each(function(){
 1403+ var queue = jQuery.queue( this, type, data );
 1404+
 1405+ if( type == "fx" && queue.length == 1 )
 1406+ queue[0].call(this);
 1407+ });
 1408+ },
 1409+ dequeue: function(type){
 1410+ return this.each(function(){
 1411+ jQuery.dequeue( this, type );
 1412+ });
 1413+ }
14141414 });/*!
14151415 * Sizzle CSS Selector Engine - v0.9.3
14161416 * Copyright 2009, The Dojo Foundation
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js
@@ -284,7 +284,7 @@
285285 post += ' '
286286 }
287287 }
288 - var e = this.jquery ? this[0] : this;
 288+ var e = this.jquery ? this[0] : this;
289289 var selText;
290290 var isSample = false;
291291 if ( document.selection && document.selection.createRange ) {
@@ -332,7 +332,7 @@
333333 }
334334 e.scrollTop = textScroll;
335335 }
336 - $(this).trigger( 'encapsulateSelection' );
 336+ $(this).trigger( 'encapsulateSelection', [ pre, peri, post ] );
337337 },
338338 /**
339339 * Ported from Wikia's LinkSuggest extension
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js
@@ -25,7 +25,7 @@
2626 range.select();if(document.documentElement&&document.documentElement.scrollTop){document.documentElement.scrollTop=winScroll}else if(document.body){document.body.scrollTop=winScroll;}}else if(e.selectionStart||e.selectionStart=='0'){var textScroll=e.scrollTop;$(this).focus();var startPos=e.selectionStart;var endPos=e.selectionEnd;selText=e.value.substring(startPos,endPos);checkSelectedText();e.value=e.value.substring(0,startPos)+pre+selText+post+
2727 e.value.substring(endPos,e.value.length);if(isSample){e.selectionStart=startPos+pre.length;e.selectionEnd=startPos+pre.length+selText.length;}else{e.selectionStart=startPos+pre.length+selText.length+post.length;e.selectionEnd=e.selectionStart;}
2828 e.scrollTop=textScroll;}
29 -$(this).trigger('encapsulateSelection');},getCaretPosition:function(){function getCaret(e){var caretPos=0;if($.browser.msie){var postFinished=false;var periFinished=false;var postFinished=false;var preText,rawPreText,periText;var rawPeriText,postText,rawPostText;var periRange=document.selection.createRange().duplicate();var preRange=document.body.createTextRange();preRange.moveToElementText(e);preRange.setEndPoint("EndToStart",periRange);var postRange=document.body.createTextRange();postRange.moveToElementText(e);postRange.setEndPoint("StartToEnd",periRange);preText=rawPreText=preRange.text;periText=rawPeriText=periRange.text;postText=rawPostText=postRange.text;do{if(!postFinished){if(preRange.compareEndPoints("StartToEnd",preRange)==0){postFinished=true;}else{preRange.moveEnd("character",-1)
 29+$(this).trigger('encapsulateSelection',[pre,peri,post]);},getCaretPosition:function(){function getCaret(e){var caretPos=0;if($.browser.msie){var postFinished=false;var periFinished=false;var postFinished=false;var preText,rawPreText,periText;var rawPeriText,postText,rawPostText;var periRange=document.selection.createRange().duplicate();var preRange=document.body.createTextRange();preRange.moveToElementText(e);preRange.setEndPoint("EndToStart",periRange);var postRange=document.body.createTextRange();postRange.moveToElementText(e);postRange.setEndPoint("StartToEnd",periRange);preText=rawPreText=preRange.text;periText=rawPeriText=periRange.text;postText=rawPostText=postRange.text;do{if(!postFinished){if(preRange.compareEndPoints("StartToEnd",preRange)==0){postFinished=true;}else{preRange.moveEnd("character",-1)
3030 if(preRange.text==preText){rawPreText+="\r\n";}else{postFinished=true;}}}
3131 if(!periFinished){if(periRange.compareEndPoints("StartToEnd",periRange)==0){periFinished=true;}else{periRange.moveEnd("character",-1)
3232 if(periRange.text==periText){rawPeriText+="\r\n";}else{periFinished=true;}}}

Status & tagging log