r98409 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98408‎ | r98409 | r98410 >
Date:15:08, 29 September 2011
Author:inez
Status:deferred
Tags:
Comment:
Cleanup
Modified paths:
  • /trunk/parsers/wikidom/lib/synth/views/es.BlockView.js (modified) (history)
  • /trunk/parsers/wikidom/lib/synth/views/es.DocumentView.js (modified) (history)
  • /trunk/parsers/wikidom/lib/synth/views/es.SurfaceView.js (modified) (history)

Diff [purge]

Index: trunk/parsers/wikidom/lib/synth/views/es.SurfaceView.js
@@ -11,7 +11,7 @@
1212 // Initialize document view
1313 this.documentView = new es.DocumentView( this.model.getDocument() );
1414 this.$.append( this.documentView.$ );
15 -
 15+
1616 // Interaction state
1717 this.width = null;
1818 this.mouse = {
@@ -109,6 +109,9 @@
110110 * @param offset {Position} Offset to be added to position
111111 */
112112 es.SurfaceView.prototype.showCursor = function( position, offset ) {
 113+
 114+ // TODO: test/reimplement
 115+
113116 if ( position ) {
114117 if ( $.isPlainObject( offset ) ) {
115118 position.left += offset.left;
@@ -139,45 +142,15 @@
140143 * @method
141144 */
142145 es.SurfaceView.prototype.hideCursor = function() {
 146+
 147+ // TODO: test/reimplement
 148+
143149 if( this.blinkInterval ) {
144150 clearInterval( this.blinkInterval );
145151 }
146152 this.$cursor.hide();
147153 };
148154
149 -es.SurfaceView.prototype.getLocationFromEvent = function( e ) {
150 - var $target = $( e.target ),
151 - $block = $target.is( '.editSurface-block' )
152 - ? $target : $target.closest( '.editSurface-block' );
153 - // Not a block or child of a block? Find the nearest block...
154 - if ( !$block.length ) {
155 - var $blocks = this.$.find( '> .editSurface-document .editSurface-block' );
156 - $block = $blocks.first();
157 - $blocks.each( function() {
158 - // Stop looking when mouse is above top
159 - if ( e.pageY <= $(this).offset().top ) {
160 - return false;
161 - }
162 - $block = $(this);
163 - } );
164 - }
165 - var block = $block.data( 'block' ),
166 - blockPosition = $block.offset();
167 - return new es.Location(
168 - block,
169 - block.getOffset(
170 - new es.Position(
171 - e.pageX - blockPosition.left,
172 - e.pageY - blockPosition.top
173 - )
174 - )
175 - );
176 -};
177 -
178 -es.SurfaceView.prototype.getLocationFromOffset = function( offset ) {
179 -
180 -};
181 -
182155 es.SurfaceView.prototype.onKeyDown = function( e ) {
183156 switch ( e.keyCode ) {
184157 case 16: // Shift
@@ -291,10 +264,4 @@
292265
293266 es.SurfaceView.prototype.setInputContent = function( content ) {
294267 // TODO: Set the value of this.$input
295 -};
296 -
297 -/* Inheritance */
298 -
299 -es.SurfaceView.prototype.getLocationFromPosition = function( position ) {
300 -
301 -};
 268+};
\ No newline at end of file
Index: trunk/parsers/wikidom/lib/synth/views/es.BlockView.js
@@ -13,6 +13,14 @@
1414 this.$.addClass( 'editSurface-block' );
1515 this.$.data( 'block', this );
1616 };
 17+/**
 18+ * Render content.
 19+ *
 20+ * @method
 21+ */
 22+es.BlockView.prototype.renderContent = function() {
 23+ throw 'BlockView.renderContent not implemented in this subclass.';
 24+};
1725
1826 /**
1927 * Draw selection around a given range.
@@ -24,28 +32,23 @@
2533 throw 'BlockView.drawSelection not implemented in this subclass.';
2634 };
2735
28 -es.BlockView.prototype.clearSelection = function() {
29 - throw 'BlockView.clearSelection not implemented in this subclass.';
30 -};
31 -
3236 /**
33 - * Render content.
 37+ * Clear selection
3438 *
3539 * @method
3640 */
37 -es.BlockView.prototype.renderContent = function() {
38 - throw 'BlockView.renderContent not implemented in this subclass.';
 41+es.BlockView.prototype.clearSelection = function() {
 42+ throw 'BlockView.clearSelection not implemented in this subclass.';
3943 };
4044
4145 /**
42 - * Gets offset within content of position.
 46+ * Gets length of contents.
4347 *
4448 * @method
45 - * @param position {es.Position} Position to get offset for
46 - * @returns {Integer} Offset nearest to position
 49+ * @returns {Integer} Length of content, including any virtual spaces within the block
4750 */
48 -es.BlockView.prototype.getContentOffset = function( position ) {
49 - throw 'BlockView.getContentOffset not implemented in this subclass.';
 51+es.BlockView.prototype.getLength = function() {
 52+ throw 'BlockView.getLength not implemented in this subclass.';
5053 };
5154
5255 /**
@@ -60,26 +63,6 @@
6164 };
6265
6366 /**
64 - * Draw selection around a given range.
65 - *
66 - * @method
67 - * @param range {es.Range} Range of content to draw selection around
68 - */
69 -es.BlockView.prototype.drawSelection = function( range ) {
70 - throw 'BlockView.drawSelection not implemented in this subclass.';
71 -};
72 -
73 -/**
74 - * Gets length of contents.
75 - *
76 - * @method
77 - * @returns {Integer} Length of content, including any virtual spaces within the block
78 - */
79 -es.BlockView.prototype.getLength = function() {
80 - throw 'BlockView.getLength not implemented in this subclass.';
81 -};
82 -
83 -/**
8467 * Gets HTML rendering of block.
8568 *
8669 * @method
Index: trunk/parsers/wikidom/lib/synth/views/es.DocumentView.js
@@ -12,6 +12,50 @@
1313
1414 /* Methods */
1515
 16+/**
 17+ * Render content.
 18+ *
 19+ * @method
 20+ */
 21+es.DocumentView.prototype.renderContent = function() {
 22+ for ( var i = 0; i < this.items.length; i++ ) {
 23+ this.items[i].renderContent();
 24+ }
 25+};
 26+
 27+/**
 28+ * Draw selection around a given range.
 29+ *
 30+ * @method
 31+ * @param range {es.Range} Range of content to draw selection around
 32+ */
 33+es.DocumentView.prototype.drawSelection = function( range ) {
 34+ var views = this.items.select( range, null, true );
 35+ for ( var i = 0; i < views.on.length; i++ ) {
 36+ views.on[i].item.drawSelection( new es.Range( views.on[i].from, views.on[i].to ) );
 37+ }
 38+ for ( var i = 0; i < views.off.length; i++ ) {
 39+ views.off[i].clearSelection();
 40+ }
 41+};
 42+
 43+/**
 44+ * Gets length of contents.
 45+ *
 46+ * @method
 47+ * @returns {Integer} Length of content, including virtual spaces between blocks
 48+ */
 49+es.DocumentView.prototype.getLength = function() {
 50+ return this.items.getLengthOfItems();
 51+};
 52+
 53+/**
 54+ * Get the document offset of a position created from passed DOM event
 55+ *
 56+ * @method
 57+ * @param e {Event} Event to create es.Position from
 58+ * @returns {Integer} Document offset
 59+ */
1660 es.DocumentView.prototype.getOffsetFromEvent = function( e ) {
1761 var $target = $( e.target ),
1862 $block = $target.is( '.editSurface-block' )
@@ -31,6 +75,13 @@
3276 }
3377 };
3478
 79+/**
 80+ * Get the document offset of a position
 81+ *
 82+ * @method
 83+ * @param position {es.Position} Position to translate
 84+ * @returns {Integer} Document offset
 85+ */
3586 es.DocumentView.prototype.getOffsetFromPosition = function( position ) {
3687 if ( this.items.length === 0 ) {
3788 return 0;
@@ -49,28 +100,6 @@
50101 };
51102
52103 /**
53 - * Render content.
54 - *
55 - * @method
56 - */
57 -es.DocumentView.prototype.renderContent = function() {
58 - for ( var i = 0; i < this.items.length; i++ ) {
59 - this.items[i].renderContent();
60 - }
61 -};
62 -
63 -/**
64 - * Gets offset within content of position.
65 - *
66 - * @method
67 - * @param position {es.Position} Position to get offset for
68 - * @returns {Integer} Offset nearest to position
69 - */
70 -es.DocumentView.prototype.getContentOffset = function( position ) {
71 - // TODO
72 -};
73 -
74 -/**
75104 * Gets rendered position of offset within content.
76105 *
77106 * @method
@@ -82,32 +111,6 @@
83112 };
84113
85114 /**
86 - * Draw selection around a given range.
87 - *
88 - * @method
89 - * @param range {es.Range} Range of content to draw selection around
90 - */
91 -es.DocumentView.prototype.drawSelection = function( range ) {
92 - var views = this.items.select( range, null, true );
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 -/**
102 - * Gets length of contents.
103 - *
104 - * @method
105 - * @returns {Integer} Length of content, including virtual spaces between blocks
106 - */
107 -es.DocumentView.prototype.getLength = function() {
108 - return this.items.getLengthOfItems();
109 -};
110 -
111 -/**
112115 * Gets HTML rendering of document.
113116 *
114117 * @method
@@ -126,4 +129,4 @@
127130
128131 /* Inheritance */
129132
130 -es.extend( es.DocumentView, es.ViewList );
 133+es.extend( es.DocumentView, es.ViewList );
\ No newline at end of file

Status & tagging log