https://www.mediawiki.org/wiki/Special:Code/MediaWiki/113579

Revision: 113579
Author:   ialex
Date:     2012-03-11 18:38:27 +0000 (Sun, 11 Mar 2012)
Log Message:
-----------
svn:eol-style native

Modified Paths:
--------------
    trunk/extensions/VisualEditor/modules/ve/ce/ve.ce.ContentObserver.js
    trunk/extensions/VisualEditor/modules/ve/ce/ve.ce.CursorObserver.js

Property Changed:
----------------
    trunk/extensions/VisualEditor/modules/ve/ce/ve.ce.ContentObserver.js
    trunk/extensions/VisualEditor/modules/ve/ce/ve.ce.CursorObserver.js

Modified: trunk/extensions/VisualEditor/modules/ve/ce/ve.ce.ContentObserver.js
===================================================================
--- trunk/extensions/VisualEditor/modules/ve/ce/ve.ce.ContentObserver.js        
2012-03-11 18:36:55 UTC (rev 113578)
+++ trunk/extensions/VisualEditor/modules/ve/ce/ve.ce.ContentObserver.js        
2012-03-11 18:38:27 UTC (rev 113579)
@@ -1,59 +1,59 @@
-ve.ce.ContentObserver = function( documentView ) {
-       // Inheritance
-       ve.EventEmitter.call( this );
-       
-       this.$node = null;
-       this.interval = null;
-       this.frequency = 100;
-       this.prevText = null;
-       this.prevHash = null;
-};
-
-ve.ce.ContentObserver.prototype.setElement = function( $node ) {
-       if ( this.$node !== $node ) {
-               this.stop();
-
-               this.$node = $node;
-               this.prevText = ve.ce.Surface.getDOMText2( this.$node[0] );
-               this.prevHash = ve.ce.Surface.getDOMHash( this.$node[0] );
-
-               this.start();
-       }
-};
-
-ve.ce.ContentObserver.prototype.stop = function() {
-       if ( this.interval !== null ) {
-               clearInterval( this.interval );
-               this.interval = null;
-               this.poll();
-               this.$node = null;
-       }
-};
-
-ve.ce.ContentObserver.prototype.start = function() {
-       this.poll();
-       var _this = this;
-       setTimeout( function() { _this.poll(); }, 0);
-       this.interval = setInterval( function() { _this.poll(); }, 
this.frequency );
-};
-
-ve.ce.ContentObserver.prototype.poll = function() {
-       var text = ve.ce.Surface.getDOMText2( this.$node[0] );
-       var hash = ve.ce.Surface.getDOMHash( this.$node[0] );
-
-       if ( text !== this.prevText || hash !== this.prevHash ) {
-               this.emit('change', {
-                       $node: this.$node,
-                       prevText: this.prevText,
-                       text: text,
-                       prevHash: this.prevHash,
-                       hash: hash
-               } );
-               this.prevText = text;
-               this.prevHash = hash;
-       }
-};
-
-/* Inheritance */
-
+ve.ce.ContentObserver = function( documentView ) {
+       // Inheritance
+       ve.EventEmitter.call( this );
+       
+       this.$node = null;
+       this.interval = null;
+       this.frequency = 100;
+       this.prevText = null;
+       this.prevHash = null;
+};
+
+ve.ce.ContentObserver.prototype.setElement = function( $node ) {
+       if ( this.$node !== $node ) {
+               this.stop();
+
+               this.$node = $node;
+               this.prevText = ve.ce.Surface.getDOMText2( this.$node[0] );
+               this.prevHash = ve.ce.Surface.getDOMHash( this.$node[0] );
+
+               this.start();
+       }
+};
+
+ve.ce.ContentObserver.prototype.stop = function() {
+       if ( this.interval !== null ) {
+               clearInterval( this.interval );
+               this.interval = null;
+               this.poll();
+               this.$node = null;
+       }
+};
+
+ve.ce.ContentObserver.prototype.start = function() {
+       this.poll();
+       var _this = this;
+       setTimeout( function() { _this.poll(); }, 0);
+       this.interval = setInterval( function() { _this.poll(); }, 
this.frequency );
+};
+
+ve.ce.ContentObserver.prototype.poll = function() {
+       var text = ve.ce.Surface.getDOMText2( this.$node[0] );
+       var hash = ve.ce.Surface.getDOMHash( this.$node[0] );
+
+       if ( text !== this.prevText || hash !== this.prevHash ) {
+               this.emit('change', {
+                       $node: this.$node,
+                       prevText: this.prevText,
+                       text: text,
+                       prevHash: this.prevHash,
+                       hash: hash
+               } );
+               this.prevText = text;
+               this.prevHash = hash;
+       }
+};
+
+/* Inheritance */
+
 ve.extendClass( ve.ce.ContentObserver , ve.EventEmitter );
\ No newline at end of file


Property changes on: 
trunk/extensions/VisualEditor/modules/ve/ce/ve.ce.ContentObserver.js
___________________________________________________________________
Added: svn:eol-style
   + native

Modified: trunk/extensions/VisualEditor/modules/ve/ce/ve.ce.CursorObserver.js
===================================================================
--- trunk/extensions/VisualEditor/modules/ve/ce/ve.ce.CursorObserver.js 
2012-03-11 18:36:55 UTC (rev 113578)
+++ trunk/extensions/VisualEditor/modules/ve/ce/ve.ce.CursorObserver.js 
2012-03-11 18:38:27 UTC (rev 113579)
@@ -1,98 +1,98 @@
-ve.ce.CursorObserver = function( documentView ) {
-       // Inheritance
-       ve.EventEmitter.call( this );
-
-       this.documentView = documentView;
-       this.anchorNode = null;
-       this.anchorOffset = null;
-       this.focusNode = null;
-       this.focusOffset = null;
-};
-
-ve.ce.CursorObserver.prototype.update = function() {
-       var _this = this;
-
-       setTimeout( function() {
-               if ( !_this.documentView.$.is(':focus') ) {
-                       if (
-                               _this.anchorNode !== null ||
-                               _this.anchorOffset !== null ||
-                               _this.focusNode !== null ||
-                               _this.focusOffset !== null
-                       ) {
-                               _this.anchorNode = _this.anchorOffset = 
_this.focusNode = _this.focusOffset = null;
-                               _this.emit( 'change', null );
-                       }
-               } else {
-                       var     rangySel = rangy.getSelection(),
-                               range;
-                       if ( rangySel.anchorNode !== _this.anchorNode ||
-                               rangySel.anchorOffset !== _this.anchorOffset ||
-                               rangySel.focusNode !== _this.focusNode ||
-                               rangySel.focusOffset !== _this.focusOffset
-                       ) {
-                               _this.anchorNode = rangySel.anchorNode;
-                               _this.anchorOffset = rangySel.anchorOffset;
-                               _this.focusNode = rangySel.focusNode;
-                               _this.focusOffset = rangySel.focusOffset;
-       
-                               if ( rangySel.isCollapsed ) {
-                                       range = new ve.Range( _this.getOffset( 
_this.anchorNode, _this.anchorOffset ) );
-                               } else {
-                                       range = new ve.Range(
-                                               _this.getOffset( 
_this.anchorNode, _this.anchorOffset ),
-                                               _this.getOffset( 
_this.focusNode, _this.focusOffset )
-                                       );
-                               }
-                               _this.emit( 'change', range );
-                       }
-               }
-       }, 0 );
-};
-
-ve.ce.CursorObserver.prototype.getOffset = function( selectionNode, 
selectionOffset ) {
-       var     $leafNode = ve.ce.Surface.getLeafNode( selectionNode ),
-               current = [$leafNode.contents(), 0],
-               stack = [current],
-               offset = 0;
-
-       while ( stack.length > 0 ) {
-               if ( current[1] >= current[0].length ) {
-                       stack.pop();
-                       current = stack[ stack.length - 1 ];
-                       continue;
-               }
-               var item = current[0][current[1]];
-               var $item = current[0].eq( current[1] );
-               
-               if ( item.nodeType === 3 ) {
-                       if ( item === selectionNode ) {
-                               offset += selectionOffset;
-                               break;
-                       } else {
-                               offset += item.textContent.length;
-                       }
-               } else if ( item.nodeType === 1 ) {
-                       if ( $( item ).attr( 'contentEditable' ) === 'false' ) {
-                               offset += 1;
-                       } else {
-                               if ( item === selectionNode ) {
-                                       offset += selectionOffset;
-                                       break;
-                               }                       
-                               stack.push( [$item.contents(), 0] );
-                               current[1]++;
-                               current = stack[stack.length-1];
-                               continue;
-                       }
-               }
-               current[1]++;
-       }
-       return this.documentView.getOffsetFromNode(
-               $leafNode.data( 'view' )
-       ) + 1 + offset;
-};
-
-/* Inheritance */
-
-ve.extendClass( ve.ce.CursorObserver , ve.EventEmitter );
+ve.ce.CursorObserver = function( documentView ) {
+       // Inheritance
+       ve.EventEmitter.call( this );
+
+       this.documentView = documentView;
+       this.anchorNode = null;
+       this.anchorOffset = null;
+       this.focusNode = null;
+       this.focusOffset = null;
+};
+
+ve.ce.CursorObserver.prototype.update = function() {
+       var _this = this;
+
+       setTimeout( function() {
+               if ( !_this.documentView.$.is(':focus') ) {
+                       if (
+                               _this.anchorNode !== null ||
+                               _this.anchorOffset !== null ||
+                               _this.focusNode !== null ||
+                               _this.focusOffset !== null
+                       ) {
+                               _this.anchorNode = _this.anchorOffset = 
_this.focusNode = _this.focusOffset = null;
+                               _this.emit( 'change', null );
+                       }
+               } else {
+                       var     rangySel = rangy.getSelection(),
+                               range;
+                       if ( rangySel.anchorNode !== _this.anchorNode ||
+                               rangySel.anchorOffset !== _this.anchorOffset ||
+                               rangySel.focusNode !== _this.focusNode ||
+                               rangySel.focusOffset !== _this.focusOffset
+                       ) {
+                               _this.anchorNode = rangySel.anchorNode;
+                               _this.anchorOffset = rangySel.anchorOffset;
+                               _this.focusNode = rangySel.focusNode;
+                               _this.focusOffset = rangySel.focusOffset;
+       
+                               if ( rangySel.isCollapsed ) {
+                                       range = new ve.Range( _this.getOffset( 
_this.anchorNode, _this.anchorOffset ) );
+                               } else {
+                                       range = new ve.Range(
+                                               _this.getOffset( 
_this.anchorNode, _this.anchorOffset ),
+                                               _this.getOffset( 
_this.focusNode, _this.focusOffset )
+                                       );
+                               }
+                               _this.emit( 'change', range );
+                       }
+               }
+       }, 0 );
+};
+
+ve.ce.CursorObserver.prototype.getOffset = function( selectionNode, 
selectionOffset ) {
+       var     $leafNode = ve.ce.Surface.getLeafNode( selectionNode ),
+               current = [$leafNode.contents(), 0],
+               stack = [current],
+               offset = 0;
+
+       while ( stack.length > 0 ) {
+               if ( current[1] >= current[0].length ) {
+                       stack.pop();
+                       current = stack[ stack.length - 1 ];
+                       continue;
+               }
+               var item = current[0][current[1]];
+               var $item = current[0].eq( current[1] );
+               
+               if ( item.nodeType === 3 ) {
+                       if ( item === selectionNode ) {
+                               offset += selectionOffset;
+                               break;
+                       } else {
+                               offset += item.textContent.length;
+                       }
+               } else if ( item.nodeType === 1 ) {
+                       if ( $( item ).attr( 'contentEditable' ) === 'false' ) {
+                               offset += 1;
+                       } else {
+                               if ( item === selectionNode ) {
+                                       offset += selectionOffset;
+                                       break;
+                               }                       
+                               stack.push( [$item.contents(), 0] );
+                               current[1]++;
+                               current = stack[stack.length-1];
+                               continue;
+                       }
+               }
+               current[1]++;
+       }
+       return this.documentView.getOffsetFromNode(
+               $leafNode.data( 'view' )
+       ) + 1 + offset;
+};
+
+/* Inheritance */
+
+ve.extendClass( ve.ce.CursorObserver , ve.EventEmitter );


Property changes on: 
trunk/extensions/VisualEditor/modules/ve/ce/ve.ce.CursorObserver.js
___________________________________________________________________
Added: svn:eol-style
   + native


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to