autoheight.js 775 B

123456789101112131415161718192021222324252627
  1. /*******************************************************************************
  2. * KindEditor - WYSIWYG HTML Editor for Internet
  3. * Copyright (C) 2006-2011 kindsoft.net
  4. *
  5. * @author Roddy <luolonghao@gmail.com>
  6. * @site http://www.kindsoft.net/
  7. * @licence http://www.kindsoft.net/license.php
  8. *******************************************************************************/
  9. KindEditor.plugin('autoheight', function(K) {
  10. var self = this;
  11. if (!self.autoHeightMode) {
  12. return;
  13. }
  14. var edit = self.edit;
  15. var body = edit.doc.body;
  16. var minHeight = K.removeUnit(self.height);
  17. edit.iframe[0].scroll = 'no';
  18. body.style.overflowY = 'hidden';
  19. edit.afterChange(function() {
  20. self.resize(null, Math.max((K.IE ? body.scrollHeight : body.offsetHeight) + 62, minHeight));
  21. });
  22. });