Ticket #117: isdirty.patch
File isdirty.patch, 2.7 KB (added by , 17 years ago) |
---|
-
editor/_source/internals/fck.js
47 47 48 48 IsDirty : function() 49 49 { 50 return ( this.StartupValue != this.EditorDocument.body.innerHTML ) ; 50 if ( this.EditMode == FCK_EDITMODE_SOURCE ) 51 return ( this.StartupValue != this.EditingArea.Textarea.value ) ; 52 else 53 return ( this.StartupValue != this.EditorDocument.body.innerHTML ) ; 51 54 }, 52 55 53 56 ResetIsDirty : function() 54 57 { 55 if ( this.EditorDocument.body ) 58 if ( this.EditMode == FCK_EDITMODE_SOURCE ) 59 this.StartupValue = this.EditingArea.Textarea.value ; 60 else if ( this.EditorDocument.body ) 56 61 this.StartupValue = this.EditorDocument.body.innerHTML ; 57 62 }, 58 63 … … 85 90 this.EditingArea.FFSpellChecker = false ; 86 91 87 92 // Set the editor's startup contents 88 this.SetHTML( this.GetLinkedFieldValue() ) ;93 this.SetHTML( this.GetLinkedFieldValue(), true ) ; 89 94 }, 90 95 91 96 Focus : function() … … 299 304 return html ; 300 305 }, 301 306 302 SetHTML : function( html )307 SetHTML : function( html, resetIsDirty ) 303 308 { 304 309 this.EditingArea.Mode = FCK.EditMode ; 305 310 … … 319 324 html = html.replace( FCKRegexLib.EmOpener, '<i$1' ) ; 320 325 html = html.replace( FCKRegexLib.EmCloser, '<\/i>' ) ; 321 326 } 327 328 this._ForceResetIsDirty = ( resetIsDirty === true ) ; 322 329 323 330 var sHtml = '' ; 324 331 … … 415 422 416 423 // Removes the enter key handler. 417 424 FCK.EnterKeyHandler = null ; 425 426 if ( resetIsDirty ) 427 this.ResetIsDirty() ; 418 428 419 429 // Listen for keystroke events. 420 430 FCK.KeystrokeHandler.AttachToElement( this.EditingArea.Textarea ) ; … … 529 539 SwitchEditMode : function( noUndo ) 530 540 { 531 541 var bIsWysiwyg = ( FCK.EditMode == FCK_EDITMODE_WYSIWYG ) ; 542 543 // Save the current IsDirty state, so we may restore it after the switch. 544 var bIsDirty = FCK.IsDirty() ; 545 532 546 var sHtml ; 533 547 534 548 // Update the HTML in the view output to show. … … 547 561 548 562 FCK.EditMode = bIsWysiwyg ? FCK_EDITMODE_SOURCE : FCK_EDITMODE_WYSIWYG ; 549 563 550 FCK.SetHTML( sHtml ) ;551 564 FCK.SetHTML( sHtml, !bIsDirty ) ; 565 552 566 // Set the Focus. 553 567 FCK.Focus() ; 554 568 … … 622 636 623 637 // Listen for keystroke events. 624 638 FCK.KeystrokeHandler.AttachToElement( FCK.EditorDocument ) ; 639 640 if ( FCK._ForceResetIsDirty ) 641 FCK.ResetIsDirty() ; 625 642 626 643 FCK.OnAfterSetHTML() ; 627 644 … … 629 646 if ( FCK.Status != FCK_STATUS_NOTLOADED ) 630 647 return ; 631 648 632 // Save the startup value for the "IsDirty()" check.633 FCK.ResetIsDirty() ;634 635 649 FCK.SetStatus( FCK_STATUS_ACTIVE ) ; 636 650 } 637 651