r97135 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r97134‎ | r97135 | r97136 >
Date:01:41, 15 September 2011
Author:inez
Status:deferred
Tags:
Comment:
Very early version of selection mechanism that works across paragraphs, lists and tables
Modified paths:
  • /trunk/parsers/wikidom/lib/synth/bases/es.AggregateArray.js (modified) (history)
  • /trunk/parsers/wikidom/lib/synth/bases/es.ModelContainer.js (modified) (history)
  • /trunk/parsers/wikidom/lib/synth/bases/es.ViewContainer.js (modified) (history)
  • /trunk/parsers/wikidom/lib/synth/models/es.ListBlockItemModel.js (modified) (history)
  • /trunk/parsers/wikidom/lib/synth/views/es.ContentView.js (modified) (history)
  • /trunk/parsers/wikidom/lib/synth/views/es.DocumentView.js (modified) (history)
  • /trunk/parsers/wikidom/lib/synth/views/es.ListBlockItemView.js (modified) (history)
  • /trunk/parsers/wikidom/lib/synth/views/es.ListBlockView.js (modified) (history)
  • /trunk/parsers/wikidom/lib/synth/views/es.ParagraphBlockView.js (modified) (history)
  • /trunk/parsers/wikidom/lib/synth/views/es.TableBlockCellView.js (modified) (history)
  • /trunk/parsers/wikidom/lib/synth/views/es.TableBlockRowView.js (modified) (history)
  • /trunk/parsers/wikidom/lib/synth/views/es.TableBlockView.js (modified) (history)

Diff [purge]

Index: trunk/parsers/wikidom/lib/synth/models/es.ListBlockItemModel.js
@@ -41,7 +41,7 @@
4242 * @method
4343 * @returns {Integer} Length of all content
4444 */
45 -es.ListBlockItemModel.prototype.getContentLength = function() {
 45+es.ListBlockItemModel.prototype.getLength = function() {
4646 return this.content.getLength();
4747 };
4848
Index: trunk/parsers/wikidom/lib/synth/bases/es.ModelContainer.js
@@ -15,7 +15,7 @@
1616 listName = 'items';
1717 }
1818 this._listName = listName;
19 - this[this._listName] = [];
 19+ this[this._listName] = new es.AggregateArray();
2020 var container = this;
2121 this.relayUpdate = function() {
2222 container.emit( 'update' );
Index: trunk/parsers/wikidom/lib/synth/bases/es.AggregateArray.js
@@ -73,6 +73,7 @@
7474 // Append items until we reach the end
7575 from = 0;
7676 to = Math.min( right - left - 1, end - left );
 77+
7778 if ( from !== to ) {
7879 items.push( { 'item': this[i], 'from': from, 'to': to } );
7980 }
@@ -83,7 +84,8 @@
8485 inside = true;
8586 // Append first item
8687 from = start - left;
87 - to = Math.min( right - 1, end - left );
 88+ //to = Math.min( right - 1, end - left );
 89+ to = Math.min( right - left - 1, end - left );
8890 if ( from !== to ) {
8991 items.push( { 'item': this[i], 'from': from, 'to': to } );
9092 }
Index: trunk/parsers/wikidom/lib/synth/bases/es.ViewContainer.js
@@ -19,7 +19,7 @@
2020 if ( !this.containerModel ) {
2121 return;
2222 }
23 - this.views = [];
 23+ this.views = new es.AggregateArray();
2424 if ( typeof typeName !== 'string' ) {
2525 typeName = 'viewContainer';
2626 }
Index: trunk/parsers/wikidom/lib/synth/views/es.ListBlockItemView.js
@@ -49,4 +49,12 @@
5050 return this.contentView.getLineIndex( position );
5151 };
5252
 53+es.ListBlockItemView.prototype.getLength = function() {
 54+ return this.model.getLength();
 55+};
 56+
 57+es.ListBlockItemView.prototype.drawSelection = function( range ) {
 58+ this.contentView.drawSelection( range );
 59+};
 60+
5361 es.extend( es.ListBlockItemView, es.ViewContainerItem );
Index: trunk/parsers/wikidom/lib/synth/views/es.ListBlockView.js
@@ -56,5 +56,18 @@
5757 //return this.contentView.getLineIndex( position );
5858 };
5959
 60+es.ListBlockView.prototype.getLength = function() {
 61+ return this.model.items.getLengthOfItems();
 62+};
 63+
 64+es.ListBlockView.prototype.drawSelection = function( range ) {
 65+ var selectedViews = this.views.select( range );
 66+ for ( var i = 0; i < selectedViews.length; i++ ) {
 67+ selectedViews[i].item.drawSelection(
 68+ new es.Range( selectedViews[i].from, selectedViews[i].to )
 69+ );
 70+ }
 71+};
 72+
6073 es.extend( es.ListBlockView, es.ViewContainer );
6174 es.extend( es.ListBlockView, es.BlockView );
Index: trunk/parsers/wikidom/lib/synth/views/es.ContentView.js
@@ -202,7 +202,7 @@
203203 toLineIndex = this.getLineIndex( range.end ),
204204 fromPosition = this.getPosition( range.start ),
205205 toPosition = this.getPosition( range.end );
206 -
 206+
207207 if ( fromLineIndex === toLineIndex ) {
208208 // Single line selection
209209 this.$rangeStart.css( {
Index: trunk/parsers/wikidom/lib/synth/views/es.TableBlockRowView.js
@@ -21,5 +21,18 @@
2222 }
2323 };
2424
 25+es.TableBlockRowView.prototype.getLength = function() {
 26+ return this.views.getLengthOfItems();
 27+};
 28+
 29+es.TableBlockRowView.prototype.drawSelection = function( range ) {
 30+ var selectedViews = this.views.select( range );
 31+ for ( var i = 0; i < selectedViews.length; i++ ) {
 32+ selectedViews[i].item.drawSelection(
 33+ new es.Range( selectedViews[i].from, selectedViews[i].to )
 34+ );
 35+ }
 36+};
 37+
2538 es.extend( es.TableBlockRowView, es.ViewContainer );
2639 es.extend( es.TableBlockRowView, es.ViewContainerItem );
Index: trunk/parsers/wikidom/lib/synth/views/es.DocumentView.js
@@ -11,6 +11,19 @@
1212 }
1313 };
1414
 15+es.DocumentView.prototype.drawSelection = function( range ) {
 16+ var selectedViews = this.views.select( range );
 17+ for ( var i = 0; i < selectedViews.length; i++ ) {
 18+ selectedViews[i].item.drawSelection(
 19+ new es.Range( selectedViews[i].from, selectedViews[i].to )
 20+ );
 21+ }
 22+};
 23+
 24+es.DocumentView.prototype.getLength = function( ) {
 25+ return this.views.getLengthOfItems();
 26+};
 27+
1528 /* Inheritance */
1629
1730 es.extend( es.DocumentView, es.ViewContainer );
Index: trunk/parsers/wikidom/lib/synth/views/es.ParagraphBlockView.js
@@ -38,4 +38,12 @@
3939 return this.contentView.getLineIndex( position );
4040 };
4141
 42+es.ParagraphBlockView.prototype.getLength = function() {
 43+ return this.model.getContentLength();
 44+};
 45+
 46+es.ParagraphBlockView.prototype.drawSelection = function( range ) {
 47+ this.contentView.drawSelection( range );
 48+};
 49+
4250 es.extend( es.ParagraphBlockView, es.BlockView );
Index: trunk/parsers/wikidom/lib/synth/views/es.TableBlockCellView.js
@@ -18,8 +18,16 @@
1919 * Render content.
2020 */
2121 es.TableBlockCellView.prototype.renderContent = function() {
22 - //debugger;
2322 this.documentView.renderContent();
2423 };
2524
 25+es.TableBlockCellView.prototype.getLength = function() {
 26+ return this.documentView.getLength();
 27+};
 28+
 29+es.TableBlockCellView.prototype.drawSelection = function( range ) {
 30+ this.documentView.drawSelection( range );
 31+};
 32+
 33+
2634 es.extend( es.TableBlockCellView, es.ViewContainerItem );
Index: trunk/parsers/wikidom/lib/synth/views/es.TableBlockView.js
@@ -21,5 +21,18 @@
2222 }
2323 };
2424
 25+es.TableBlockView.prototype.getLength = function() {
 26+ return this.views.getLengthOfItems();
 27+};
 28+
 29+es.TableBlockView.prototype.drawSelection = function( range ) {
 30+ var selectedViews = this.views.select( range );
 31+ for ( var i = 0; i < selectedViews.length; i++ ) {
 32+ selectedViews[i].item.drawSelection(
 33+ new es.Range( selectedViews[i].from, selectedViews[i].to )
 34+ );
 35+ }
 36+};
 37+
2538 es.extend( es.TableBlockView, es.ViewContainer );
2639 es.extend( es.TableBlockView, es.BlockView );

Status & tagging log