r98503 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98502‎ | r98503 | r98504 >
Date:10:28, 30 September 2011
Author:inez
Status:deferred
Tags:
Comment:
Code cleanup
Modified paths:
  • /trunk/parsers/wikidom/lib/synth/views/es.HeadingBlockView.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/views/es.ListBlockItemView.js
@@ -24,7 +24,6 @@
2525
2626 /* Methods */
2727
28 -
2928 /**
3029 * Render content.
3130 *
@@ -35,28 +34,6 @@
3635 };
3736
3837 /**
39 - * Gets offset within content of position.
40 - *
41 - * @method
42 - * @param position {es.Position} Position to get offset for
43 - * @returns {Integer} Offset nearest to position
44 - */
45 -es.ListBlockItemView.prototype.getContentOffset = function( position ) {
46 - return this.contentView.getOffset( position );
47 -};
48 -
49 -/**
50 - * Gets rendered position of offset within content.
51 - *
52 - * @method
53 - * @param offset {Integer} Offset to get position for
54 - * @returns {es.Position} Position of offset
55 - */
56 -es.ListBlockItemView.prototype.getRenderedPosition = function( offset ) {
57 - return this.contentView.getPosition( position );
58 -};
59 -
60 -/**
6138 * Draw selection around a given range.
6239 *
6340 * @method
@@ -81,6 +58,28 @@
8259 };
8360
8461 /**
 62+ * Gets offset within content of position.
 63+ *
 64+ * @method
 65+ * @param position {es.Position} Position to get offset for
 66+ * @returns {Integer} Offset nearest to position
 67+ */
 68+es.ListBlockItemView.prototype.getOffsetFromPosition = function( position ) {
 69+ return this.contentView.getOffset( position );
 70+};
 71+
 72+/**
 73+ * Gets rendered position of offset within content.
 74+ *
 75+ * @method
 76+ * @param offset {Integer} Offset to get position for
 77+ * @returns {es.Position} Position of offset
 78+ */
 79+es.ListBlockItemView.prototype.getRenderedPosition = function( offset ) {
 80+ return this.contentView.getPosition( position );
 81+};
 82+
 83+/**
8584 * Gets HTML rendering of block.
8685 *
8786 * @method
@@ -93,7 +92,7 @@
9493 { 'class': this.$.attr( 'class' ) },
9594 this.contentView.getHtml()
9695 );
97 -}
 96+};
9897
9998 /**
10099 * Sets the number label of the item, used for unordered lists
@@ -106,4 +105,4 @@
107106
108107 /* Inheritance */
109108
110 -es.extend( es.ListBlockItemView, es.ViewListItem );
 109+es.extend( es.ListBlockItemView, es.ViewListItem );
\ No newline at end of file
Index: trunk/parsers/wikidom/lib/synth/views/es.ListBlockView.js
@@ -19,27 +19,14 @@
2020 /* Methods */
2121
2222 /**
23 - * Gets the offset of a position.
 23+ * Render content.
2424 *
2525 * @method
26 - * @param position {es.Position} Position to translate
27 - * @returns {Integer} Offset nearest to position
2826 */
29 -es.ListBlockView.prototype.getOffsetFromPosition = function( position ) {
30 - if ( this.items.length === 0 ) {
31 - return 0;
32 - }
33 -
34 - var listItemView = this.items[0];
35 -
 27+es.ListBlockView.prototype.renderContent = function() {
3628 for ( var i = 0; i < this.items.length; i++ ) {
37 - if ( this.items[i].$.offset().top >= position.top ) {
38 - break;
39 - }
40 - listItemView = this.items[i];
 29+ this.items[i].renderContent();
4130 }
42 -
43 - return listItemView.list.items.offsetOf( listItemView ) + listItemView.getContentOffset( position );
4431 };
4532
4633 /**
@@ -66,25 +53,37 @@
6754 };
6855
6956 /**
70 - * Render content.
 57+ * Gets length of contents.
7158 *
7259 * @method
 60+ * @returns {Integer} Length of content, including any virtual spaces within the block
7361 */
74 -es.ListBlockView.prototype.renderContent = function() {
75 - for ( var i = 0; i < this.items.length; i++ ) {
76 - this.items[i].renderContent();
77 - }
 62+es.ListBlockView.prototype.getLength = function() {
 63+ return this.model.items.getLengthOfItems();
7864 };
7965
8066 /**
81 - * Gets offset within content of position.
 67+ * Gets the offset of a position.
8268 *
8369 * @method
84 - * @param position {es.Position} Position to get offset for
 70+ * @param position {es.Position} Position to translate
8571 * @returns {Integer} Offset nearest to position
8672 */
87 -es.ListBlockView.prototype.getContentOffset = function( position ) {
88 - // TODO
 73+es.ListBlockView.prototype.getOffsetFromPosition = function( position ) {
 74+ if ( this.items.length === 0 ) {
 75+ return 0;
 76+ }
 77+
 78+ var listItemView = this.items[0];
 79+
 80+ for ( var i = 0; i < this.items.length; i++ ) {
 81+ if ( this.items[i].$.offset().top >= position.top ) {
 82+ break;
 83+ }
 84+ listItemView = this.items[i];
 85+ }
 86+
 87+ return listItemView.list.items.offsetOf( listItemView ) + listItemView.getOffsetFromPosition( position );
8988 };
9089
9190 /**
@@ -99,16 +98,6 @@
10099 };
101100
102101 /**
103 - * Gets length of contents.
104 - *
105 - * @method
106 - * @returns {Integer} Length of content, including any virtual spaces within the block
107 - */
108 -es.ListBlockView.prototype.getLength = function() {
109 - return this.model.items.getLengthOfItems();
110 -};
111 -
112 -/**
113102 * Gets HTML rendering of block.
114103 *
115104 * @method
@@ -149,4 +138,4 @@
150139 /* Inheritance */
151140
152141 es.extend( es.ListBlockView, es.ViewList );
153 -es.extend( es.ListBlockView, es.BlockView );
 142+es.extend( es.ListBlockView, es.BlockView );
\ No newline at end of file
Index: trunk/parsers/wikidom/lib/synth/views/es.HeadingBlockView.js
@@ -8,6 +8,12 @@
99 } );
1010 };
1111
 12+/* Methods */
 13+
 14+es.HeadingBlockView.prototype.renderContent = function() {
 15+ this.contentView.render();
 16+};
 17+
1218 es.HeadingBlockView.prototype.drawSelection = function( range ) {
1319 this.contentView.drawSelection( range );
1420 };
@@ -16,10 +22,6 @@
1723 this.contentView.clearSelection();
1824 };
1925
20 -es.HeadingBlockView.prototype.renderContent = function() {
21 - this.contentView.render();
22 -};
23 -
2426 es.HeadingBlockView.prototype.getLength = function() {
2527 return this.model.getContentLength();
2628 };
@@ -28,4 +30,6 @@
2931 return this.contentView.getOffset( position );
3032 };
3133
 34+/* Inheritance */
 35+
3236 es.extend( es.HeadingBlockView, es.BlockView );
Index: trunk/parsers/wikidom/lib/synth/views/es.TableBlockRowView.js
@@ -15,30 +15,6 @@
1616 /* Methods */
1717
1818 /**
19 - * Gets the offset of a position.
20 - *
21 - * @method
22 - * @param position {es.Position} Position to translate
23 - * @returns {Integer} Offset nearest to position
24 - */
25 -es.TableBlockRowView.prototype.getOffsetFromPosition = function( position ) {
26 - if ( this.items.length === 0 ) {
27 - return 0;
28 - }
29 -
30 - var cellView = this.items[0];
31 -
32 - for ( var i = 0; i < this.items.length; i++ ) {
33 - if ( this.items[i].$.offset().left >= position.left ) {
34 - break;
35 - }
36 - cellView = this.items[i];
37 - }
38 -
39 - return cellView.list.items.offsetOf( cellView ) + cellView.getOffsetFromPosition( position );
40 -};
41 -
42 -/**
4319 * Render content.
4420 *
4521 * @method
@@ -50,28 +26,6 @@
5127 };
5228
5329 /**
54 - * Gets offset within content of position.
55 - *
56 - * @method
57 - * @param position {es.Position} Position to get offset for
58 - * @returns {Integer} Offset nearest to position
59 - */
60 -es.TableBlockRowView.prototype.getContentOffset = function( position ) {
61 - // TODO
62 -};
63 -
64 -/**
65 - * Gets rendered position of offset within content.
66 - *
67 - * @method
68 - * @param offset {Integer} Offset to get position for
69 - * @returns {es.Position} Position of offset
70 - */
71 -es.TableBlockRowView.prototype.getRenderedPosition = function( offset ) {
72 - // TODO
73 -};
74 -
75 -/**
7630 * Draw selection around a given range.
7731 *
7832 * @method
@@ -105,6 +59,41 @@
10660 };
10761
10862 /**
 63+ * Gets the offset of a position.
 64+ *
 65+ * @method
 66+ * @param position {es.Position} Position to translate
 67+ * @returns {Integer} Offset nearest to position
 68+ */
 69+es.TableBlockRowView.prototype.getOffsetFromPosition = function( position ) {
 70+ if ( this.items.length === 0 ) {
 71+ return 0;
 72+ }
 73+
 74+ var cellView = this.items[0];
 75+
 76+ for ( var i = 0; i < this.items.length; i++ ) {
 77+ if ( this.items[i].$.offset().left >= position.left ) {
 78+ break;
 79+ }
 80+ cellView = this.items[i];
 81+ }
 82+
 83+ return cellView.list.items.offsetOf( cellView ) + cellView.getOffsetFromPosition( position );
 84+};
 85+
 86+/**
 87+ * Gets rendered position of offset within content.
 88+ *
 89+ * @method
 90+ * @param offset {Integer} Offset to get position for
 91+ * @returns {es.Position} Position of offset
 92+ */
 93+es.TableBlockRowView.prototype.getRenderedPosition = function( offset ) {
 94+ // TODO
 95+};
 96+
 97+/**
10998 * Gets HTML rendering of block.
11099 *
111100 * @method
@@ -115,9 +104,9 @@
116105 return es.Html.makeTag( 'tr', this.model.attributes, $.map( this.items, function( view ) {
117106 return view.getHtml();
118107 } ).join( '' ) );
119 -}
 108+};
120109
121110 /* Inheritance */
122111
123112 es.extend( es.TableBlockRowView, es.ViewList );
124 -es.extend( es.TableBlockRowView, es.ViewListItem );
 113+es.extend( es.TableBlockRowView, es.ViewListItem );
\ No newline at end of file
Index: trunk/parsers/wikidom/lib/synth/views/es.ParagraphBlockView.js
@@ -18,17 +18,6 @@
1919 /* Methods */
2020
2121 /**
22 - * Gets the offset of a position.
23 - *
24 - * @method
25 - * @param position {es.Position} Position to translate
26 - * @returns {Integer} Offset nearest to position
27 - */
28 -es.ParagraphBlockView.prototype.getOffsetFromPosition = function( position ) {
29 - return this.contentView.getOffset( position );
30 -};
31 -
32 -/**
3322 * Render content.
3423 *
3524 * @method
@@ -38,28 +27,6 @@
3928 };
4029
4130 /**
42 - * Gets offset within content of position.
43 - *
44 - * @method
45 - * @param position {es.Position} Position to get offset for
46 - * @returns {Integer} Offset nearest to position
47 - */
48 -es.ParagraphBlockView.prototype.getContentOffset = function( position ) {
49 - return this.contentView.getOffset( position );
50 -};
51 -
52 -/**
53 - * Gets rendered position of offset within content.
54 - *
55 - * @method
56 - * @param offset {Integer} Offset to get position for
57 - * @returns {es.Position} Position of offset
58 - */
59 -es.ParagraphBlockView.prototype.getRenderedPosition = function( offset ) {
60 - return this.contentView.getPosition( position );
61 -};
62 -
63 -/**
6431 * Draw selection around a given range.
6532 *
6633 * @method
@@ -84,6 +51,28 @@
8552 };
8653
8754 /**
 55+ * Gets the offset of a position.
 56+ *
 57+ * @method
 58+ * @param position {es.Position} Position to translate
 59+ * @returns {Integer} Offset nearest to position
 60+ */
 61+es.ParagraphBlockView.prototype.getOffsetFromPosition = function( position ) {
 62+ return this.contentView.getOffset( position );
 63+};
 64+
 65+/**
 66+ * Gets rendered position of offset within content.
 67+ *
 68+ * @method
 69+ * @param offset {Integer} Offset to get position for
 70+ * @returns {es.Position} Position of offset
 71+ */
 72+es.ParagraphBlockView.prototype.getRenderedPosition = function( offset ) {
 73+ return this.contentView.getPosition( position );
 74+};
 75+
 76+/**
8877 * Gets HTML rendering of block.
8978 *
9079 * @method
@@ -100,4 +89,4 @@
10190
10291 /* Inheritance */
10392
104 -es.extend( es.ParagraphBlockView, es.BlockView );
 93+es.extend( es.ParagraphBlockView, es.BlockView );
\ No newline at end of file
Index: trunk/parsers/wikidom/lib/synth/views/es.TableBlockCellView.js
@@ -14,27 +14,37 @@
1515 /* Methods */
1616
1717 /**
18 - * Gets the offset of a position.
 18+ * Render content.
1919 *
2020 * @method
21 - * @param position {es.Position} Position to translate
22 - * @returns {Integer} Offset nearest to position
2321 */
24 -es.TableBlockCellView.prototype.getOffsetFromPosition = function( position ) {
25 - if ( this.items.length === 0 ) {
26 - return 0;
 22+es.TableBlockCellView.prototype.renderContent = function() {
 23+ for ( var i = 0; i < this.items.length; i++ ) {
 24+ this.items[i].renderContent();
2725 }
28 -
29 - var blockView = this.items[0];
 26+};
3027
 28+/**
 29+ * Draw selection around a given range.
 30+ *
 31+ * @method
 32+ * @param range {es.Range} Range of content to draw selection around
 33+ */
 34+es.TableBlockCellView.prototype.drawSelection = function( range ) {
 35+ var views = this.items.select( range, null, true );
 36+
 37+ for ( var i = 0; i < views.on.length; i++ ) {
 38+ views.on[i].item.drawSelection( new es.Range( views.on[i].from, views.on[i].to ) );
 39+ }
 40+ for ( var i = 0; i < views.off.length; i++ ) {
 41+ views.off[i].clearSelection();
 42+ }
 43+};
 44+
 45+es.TableBlockCellView.prototype.clearSelection = function( range ) {
3146 for ( var i = 0; i < this.items.length; i++ ) {
32 - if ( this.items[i].$.offset().top >= position.top ) {
33 - break;
34 - }
35 - blockView = this.items[i];
 47+ this.items[i].clearSelection();
3648 }
37 -
38 - return blockView.list.items.offsetOf( blockView ) + blockView.getOffsetFromPosition( position );
3949 };
4050
4151 /**
@@ -48,28 +58,30 @@
4959 };
5060
5161 /**
52 - * Render content.
 62+ * Gets the offset of a position.
5363 *
5464 * @method
 65+ * @param position {es.Position} Position to translate
 66+ * @returns {Integer} Offset nearest to position
5567 */
56 -es.TableBlockCellView.prototype.renderContent = function() {
 68+es.TableBlockCellView.prototype.getOffsetFromPosition = function( position ) {
 69+ if ( this.items.length === 0 ) {
 70+ return 0;
 71+ }
 72+
 73+ var blockView = this.items[0];
 74+
5775 for ( var i = 0; i < this.items.length; i++ ) {
58 - this.items[i].renderContent();
 76+ if ( this.items[i].$.offset().top >= position.top ) {
 77+ break;
 78+ }
 79+ blockView = this.items[i];
5980 }
 81+
 82+ return blockView.list.items.offsetOf( blockView ) + blockView.getOffsetFromPosition( position );
6083 };
6184
6285 /**
63 - * Gets offset within content of position.
64 - *
65 - * @method
66 - * @param position {es.Position} Position to get offset for
67 - * @returns {Integer} Offset nearest to position
68 - */
69 -es.TableBlockCellView.prototype.getContentOffset = function( position ) {
70 - // TODO
71 -};
72 -
73 -/**
7486 * Gets rendered position of offset within content.
7587 *
7688 * @method
@@ -81,29 +93,6 @@
8294 };
8395
8496 /**
85 - * Draw selection around a given range.
86 - *
87 - * @method
88 - * @param range {es.Range} Range of content to draw selection around
89 - */
90 -es.TableBlockCellView.prototype.drawSelection = function( range ) {
91 - var views = this.items.select( range, null, true );
92 -
93 - for ( var i = 0; i < views.on.length; i++ ) {
94 - views.on[i].item.drawSelection( new es.Range( views.on[i].from, views.on[i].to ) );
95 - }
96 - for ( var i = 0; i < views.off.length; i++ ) {
97 - views.off[i].clearSelection();
98 - }
99 -};
100 -
101 -es.TableBlockCellView.prototype.clearSelection = function( range ) {
102 - for ( var i = 0; i < this.items.length; i++ ) {
103 - this.items[i].clearSelection();
104 - }
105 -};
106 -
107 -/**
10897 * Gets HTML rendering of block.
10998 *
11099 * @method
@@ -112,7 +101,7 @@
113102 */
114103 es.TableBlockCellView.prototype.getHtml = function( options ) {
115104 return es.Html.makeTag( 'td', this.model.attributes, this.documentView.getHtml() );
116 -}
 105+};
117106
118107 /* Inheritance */
119108
Index: trunk/parsers/wikidom/lib/synth/views/es.TableBlockView.js
@@ -16,30 +16,6 @@
1717 /* Methods */
1818
1919 /**
20 - * Gets the offset of a position.
21 - *
22 - * @method
23 - * @param position {es.Position} Position to translate
24 - * @returns {Integer} Offset nearest to position
25 - */
26 -es.TableBlockView.prototype.getOffsetFromPosition = function( position ) {
27 - if ( this.items.length === 0 ) {
28 - return 0;
29 - }
30 -
31 - var rowView = this.items[0];
32 -
33 - for ( var i = 0; i < this.items.length; i++ ) {
34 - if ( this.items[i].$.offset().top >= position.top ) {
35 - break;
36 - }
37 - rowView = this.items[i];
38 - }
39 -
40 - return rowView.list.items.offsetOf( rowView ) + rowView.getOffsetFromPosition( position );
41 -};
42 -
43 -/**
4420 * Render content.
4521 *
4622 * @method
@@ -51,28 +27,6 @@
5228 };
5329
5430 /**
55 - * Gets offset within content of position.
56 - *
57 - * @method
58 - * @param position {es.Position} Position to get offset for
59 - * @returns {Integer} Offset nearest to position
60 - */
61 -es.TableBlockView.prototype.getContentOffset = function( position ) {
62 - // TODO
63 -};
64 -
65 -/**
66 - * Gets rendered position of offset within content.
67 - *
68 - * @method
69 - * @param offset {Integer} Offset to get position for
70 - * @returns {es.Position} Position of offset
71 - */
72 -es.TableBlockView.prototype.getRenderedPosition = function( offset ) {
73 - // TODO
74 -};
75 -
76 -/**
7731 * Draw selection around a given range.
7832 *
7933 * @method
@@ -106,6 +60,41 @@
10761 };
10862
10963 /**
 64+ * Gets the offset of a position.
 65+ *
 66+ * @method
 67+ * @param position {es.Position} Position to translate
 68+ * @returns {Integer} Offset nearest to position
 69+ */
 70+es.TableBlockView.prototype.getOffsetFromPosition = function( position ) {
 71+ if ( this.items.length === 0 ) {
 72+ return 0;
 73+ }
 74+
 75+ var rowView = this.items[0];
 76+
 77+ for ( var i = 0; i < this.items.length; i++ ) {
 78+ if ( this.items[i].$.offset().top >= position.top ) {
 79+ break;
 80+ }
 81+ rowView = this.items[i];
 82+ }
 83+
 84+ return rowView.list.items.offsetOf( rowView ) + rowView.getOffsetFromPosition( position );
 85+};
 86+
 87+/**
 88+ * Gets rendered position of offset within content.
 89+ *
 90+ * @method
 91+ * @param offset {Integer} Offset to get position for
 92+ * @returns {es.Position} Position of offset
 93+ */
 94+es.TableBlockView.prototype.getRenderedPosition = function( offset ) {
 95+ // TODO
 96+};
 97+
 98+/**
11099 * Gets HTML rendering of block.
111100 *
112101 * @method
@@ -116,9 +105,9 @@
117106 return es.Html.makeTag( 'table', this.model.attributes, $.map( this.items, function( view ) {
118107 return view.getHtml();
119108 } ).join( '' ) );
120 -}
 109+};
121110
122111 /* Inheritance */
123112
124113 es.extend( es.TableBlockView, es.ViewList );
125 -es.extend( es.TableBlockView, es.BlockView );
 114+es.extend( es.TableBlockView, es.BlockView );
\ No newline at end of file

Status & tagging log