https://www.mediawiki.org/wiki/Special:Code/MediaWiki/103496
Revision: 103496
Author: tparscal
Date: 2011-11-17 19:19:02 +0000 (Thu, 17 Nov 2011)
Log Message:
-----------
Added documentation to getScope and made it a little less confusing to read
Modified Paths:
--------------
trunk/extensions/VisualEditor/modules/es/es.TransactionProcessor.js
Modified: trunk/extensions/VisualEditor/modules/es/es.TransactionProcessor.js
===================================================================
--- trunk/extensions/VisualEditor/modules/es/es.TransactionProcessor.js
2011-11-17 19:17:58 UTC (rev 103495)
+++ trunk/extensions/VisualEditor/modules/es/es.TransactionProcessor.js
2011-11-17 19:19:02 UTC (rev 103496)
@@ -113,19 +113,30 @@
}
};
+/**
+ * Get the parent node that would be affected by inserting given data into
it's child.
+ *
+ * This is used when inserting data that closes and reopens one or more parent
nodes into a child
+ * node, which requires rebuilding at a higher level.
+ *
+ * @method
+ * @param {es.DocumentNode} node Child node to start from
+ * @param {Array} data Data to inspect for closings
+ * @returns {es.DocumentNode} Lowest level parent node being affected
+ */
es.TransactionProcessor.prototype.getScope = function( node, data ) {
var i,
length,
level = 0,
- maxDepth = 0;
+ max = 0;
for ( i = 0, length = data.length; i < length; i++ ) {
if ( typeof data[i].type === 'string' ) {
- level += data[i].type.charAt( 0 ) === '/' ? -1 : 1;
- maxDepth = Math.max( maxDepth, -level );
+ level += data[i].type.charAt( 0 ) === '/' ? 1 : -1;
+ max = Math.max( max, level );
}
}
- if ( maxDepth > 0 ) {
- for ( i = 0; i < maxDepth - 1; i++ ) {
+ if ( max > 0 ) {
+ for ( i = 0; i < max - 1; i++ ) {
node = node.getParent();
}
}
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs