preview.js 1.0 KB

1234567891011121314151617181920212223242526272829303132
  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('preview', function(K) {
  10. var self = this, name = 'preview', undefined;
  11. self.clickToolbar(name, function() {
  12. var lang = self.lang(name + '.'),
  13. html = '<div style="padding:10px 20px;">' +
  14. '<iframe class="ke-textarea" frameborder="0" style="width:708px;height:400px;"></iframe>' +
  15. '</div>',
  16. dialog = self.createDialog({
  17. name : name,
  18. width : 750,
  19. title : self.lang(name),
  20. body : html
  21. }),
  22. iframe = K('iframe', dialog.div),
  23. doc = K.iframeDoc(iframe);
  24. doc.open();
  25. doc.write(self.fullHtml());
  26. doc.close();
  27. K(doc.body).css('background-color', '#FFF');
  28. iframe[0].contentWindow.focus();
  29. });
  30. });