r101100 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101099‎ | r101100 | r101101 >
Date:00:32, 28 October 2011
Author:inez
Status:deferred
Tags:
Comment:
Get cursor to work for Headings and Paragraphs
Modified paths:
  • /trunk/parsers/wikidom/demos/hype/index.html (modified) (history)
  • /trunk/parsers/wikidom/lib/hype/bases/es.DocumentViewBranchNode.js (modified) (history)
  • /trunk/parsers/wikidom/lib/hype/bases/es.DocumentViewLeafNode.js (modified) (history)
  • /trunk/parsers/wikidom/lib/hype/views/es.DocumentView.js (modified) (history)
  • /trunk/parsers/wikidom/lib/hype/views/es.HeadingView.js (modified) (history)
  • /trunk/parsers/wikidom/lib/hype/views/es.ParagraphView.js (modified) (history)
  • /trunk/parsers/wikidom/lib/hype/views/es.SurfaceView.js (modified) (history)

Diff [purge]

Index: trunk/parsers/wikidom/lib/hype/bases/es.DocumentViewLeafNode.js
@@ -56,7 +56,7 @@
5757 * @returns {Integer} Offset of position
5858 */
5959 es.DocumentViewLeafNode.prototype.getOffsetFromRenderedPosition = function( position ) {
60 - return this.contentView.getOffsetFromRenderedPosition( offset );
 60+ return this.contentView.getOffsetFromRenderedPosition( position );
6161 };
6262
6363 /**
Index: trunk/parsers/wikidom/lib/hype/bases/es.DocumentViewBranchNode.js
@@ -72,10 +72,10 @@
7373 if ( this[i].$.offset().top > position.top ) {
7474 break;
7575 }
76 - node = this.items[i];
 76+ node = this[i];
7777 }
7878 return node.getParent().getOffsetFromNode( node, true ) +
79 - node.getOffsetFromPosition( position );
 79+ node.getOffsetFromRenderedPosition( position );
8080 };
8181
8282 /**
Index: trunk/parsers/wikidom/lib/hype/views/es.ParagraphView.js
@@ -11,3 +11,12 @@
1212 view.$.addClass( 'editSurface-paragraphBlock' );
1313 return view;
1414 };
 15+
 16+es.ParagraphView.prototype.getRenderedPositionFromOffset = function( offset ) {
 17+ var position = this.contentView.getRenderedPositionFromOffset( offset ),
 18+ offset = this.$content.offset();
 19+ position.top += offset.top;
 20+ position.left += offset.left;
 21+ position.bottom += offset.top;
 22+ return position;
 23+};
Index: trunk/parsers/wikidom/lib/hype/views/es.SurfaceView.js
@@ -6,7 +6,35 @@
77 // Initialize document view
88 this.documentView = new es.DocumentView( this.model.getDocument(), this );
99 this.$.append( this.documentView.$ );
 10+
 11+ this.cursor = {
 12+ $: $( '<div class="editSurface-cursor"></div>' ).appendTo( this.$ ),
 13+ interval: null,
 14+ offset: null,
 15+ initialLeft: null
 16+ };
 17+
 18+ // References for use in closures
 19+ var surfaceView = this;
1020
 21+ // MouseDown on surface
 22+ this.$.bind( {
 23+ 'mousedown' : function(e) {
 24+ return surfaceView.onMouseDown( e );
 25+ }
 26+ } );
 27+
1128 // First render
1229 this.documentView.renderContent();
13 -};
\ No newline at end of file
 30+};
 31+
 32+es.SurfaceView.prototype.onMouseDown = function( e ) {
 33+ var offset = this.documentView.getOffsetFromEvent( e );
 34+ var position = this.documentView.getRenderedPositionFromOffset( offset );
 35+
 36+ this.cursor.$.css( {
 37+ 'left': position.left,
 38+ 'top': position.top,
 39+ 'height': position.bottom - position.top
 40+ } ).show();
 41+};
Index: trunk/parsers/wikidom/lib/hype/views/es.DocumentView.js
@@ -3,4 +3,16 @@
44 node.$.addClass( 'editSurface-document' );
55 node.surfaceView = surfaceView;
66 return node;
 7+};
 8+
 9+/**
 10+ * Get the document offset of a position created from passed DOM event
 11+ *
 12+ * @method
 13+ * @param e {Event} Event to create es.Position from
 14+ * @returns {Integer} Document offset
 15+ */
 16+es.DocumentView.prototype.getOffsetFromEvent = function( e ) {
 17+ var position = es.Position.newFromEventPagePosition( e );
 18+ return this.getOffsetFromRenderedPosition( position );
719 };
\ No newline at end of file
Index: trunk/parsers/wikidom/lib/hype/views/es.HeadingView.js
@@ -11,3 +11,12 @@
1212 view.$.addClass( 'editSurface-headingBlock' );
1313 return view;
1414 };
 15+
 16+es.HeadingView.prototype.getRenderedPositionFromOffset = function( offset ) {
 17+ var position = this.contentView.getRenderedPositionFromOffset( offset ),
 18+ offset = this.$content.offset();
 19+ position.top += offset.top;
 20+ position.left += offset.left;
 21+ position.bottom += offset.top;
 22+ return position;
 23+};
\ No newline at end of file
Index: trunk/parsers/wikidom/demos/hype/index.html
@@ -57,6 +57,7 @@
5858 <script src="../../lib/hype/es.js"></script>
5959 <script src="../../lib/hype/es.Range.js"></script>
6060 <script src="../../lib/hype/es.Transaction.js"></script>
 61+ <script src="../../lib/hype/es.Position.js"></script>
6162
6263 <!-- Bases -->
6364 <script src="../../lib/hype/bases/es.EventEmitter.js"></script>

Status & tagging log