/pigeoncms/Plugins/fckeditor/editor/_source/classes/fckiecleanup.js

http://pigeoncms.googlecode.com/ · JavaScript · 68 lines · 30 code · 9 blank · 29 comment · 7 complexity · da0ea252f2aca1fcfa18fbe145366ff7 MD5 · raw file

  1. /*
  2. * FCKeditor - The text editor for Internet - http://www.fckeditor.net
  3. * Copyright (C) 2003-2009 Frederico Caldeira Knabben
  4. *
  5. * == BEGIN LICENSE ==
  6. *
  7. * Licensed under the terms of any of the following licenses at your
  8. * choice:
  9. *
  10. * - GNU General Public License Version 2 or later (the "GPL")
  11. * http://www.gnu.org/licenses/gpl.html
  12. *
  13. * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
  14. * http://www.gnu.org/licenses/lgpl.html
  15. *
  16. * - Mozilla Public License Version 1.1 or later (the "MPL")
  17. * http://www.mozilla.org/MPL/MPL-1.1.html
  18. *
  19. * == END LICENSE ==
  20. *
  21. * FCKIECleanup Class: a generic class used as a tool to remove IE leaks.
  22. */
  23. var FCKIECleanup = function( attachWindow )
  24. {
  25. // If the attachWindow already have a cleanup object, just use that one.
  26. if ( attachWindow._FCKCleanupObj )
  27. this.Items = attachWindow._FCKCleanupObj.Items ;
  28. else
  29. {
  30. this.Items = new Array() ;
  31. attachWindow._FCKCleanupObj = this ;
  32. FCKTools.AddEventListenerEx( attachWindow, 'unload', FCKIECleanup_Cleanup ) ;
  33. // attachWindow.attachEvent( 'onunload', FCKIECleanup_Cleanup ) ;
  34. }
  35. }
  36. FCKIECleanup.prototype.AddItem = function( dirtyItem, cleanupFunction )
  37. {
  38. this.Items.push( [ dirtyItem, cleanupFunction ] ) ;
  39. }
  40. function FCKIECleanup_Cleanup()
  41. {
  42. if ( !this._FCKCleanupObj || ( FCKConfig.MsWebBrowserControlCompat && !window.FCKUnloadFlag ) )
  43. return ;
  44. var aItems = this._FCKCleanupObj.Items ;
  45. while ( aItems.length > 0 )
  46. {
  47. // It is important to remove from the end to the beginning (pop()),
  48. // because of the order things get created in the editor. In the code,
  49. // elements in deeper position in the DOM are placed at the end of the
  50. // cleanup function, so we must cleanup then first, otherwise IE could
  51. // throw some crazy memory errors (IE bug).
  52. var oItem = aItems.pop() ;
  53. if ( oItem )
  54. oItem[1].call( oItem[0] ) ;
  55. }
  56. this._FCKCleanupObj = null ;
  57. if ( CollectGarbage )
  58. CollectGarbage() ;
  59. }