r92507 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r92506‎ | r92507 | r92508 >
Date:23:25, 18 July 2011
Author:tparscal
Status:deferred
Tags:
Comment:
Added fallback to current selection/location back into insert/delete/annotate functions
Modified paths:
  • /trunk/parsers/wikidom/lib/es/es.Surface.js (modified) (history)

Diff [purge]

Index: trunk/parsers/wikidom/lib/es/es.Surface.js
@@ -573,14 +573,21 @@
574574 };
575575
576576 Surface.prototype.insertContent = function( location, content ) {
577 - if ( this.selection.from && this.selection.to ) {
578 - this.deleteContent( this.selection );
 577+ if ( typeof location === 'undefined' ) {
 578+ location = this.location;
579579 }
 580+ if ( !location.block || !location.offset ) {
 581+ throw 'Invalid selection error. Properties for from and to locations expected.';
 582+ }
 583+ this.deleteContent( this.selection );
580584 this.location.block.insertContent( location.offset, content );
581585 };
582586
583587 Surface.prototype.deleteContent = function( selection ) {
584 - if ( !selection.from && !selection.to ) {
 588+ if ( typeof selection === 'undefined' ) {
 589+ selection = this.selection;
 590+ }
 591+ if ( !selection.from || !selection.to ) {
585592 throw 'Invalid selection error. Properties for from and to locations expected.';
586593 }
587594 selection.normalize();
@@ -620,11 +627,18 @@
621628 * @param selection {Selection} Range to apply annotation to
622629 */
623630 Surface.prototype.annotateContent = function( method, annotation, selection ) {
 631+<<<<<<< .mine
 632+ if ( typeof selection === 'undefined' ) {
 633+ selection = this.selection;
 634+ }
 635+ if ( !selection.from || !selection.to ) {
 636+=======
624637 if ( selection === undefined ) {
625638 selection = this.selection;
626639 }
627640 /*
628641 if ( !selection.from && !selection.to ) {
 642+>>>>>>> .r92506
629643 throw 'Invalid selection error. Properties for from and to locations expected.';
630644 }
631645 */

Status & tagging log