wordimage.js 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /**
  2. * Created by JetBrains PhpStorm.
  3. * User: dongyancen
  4. * Date: 12-3-26
  5. * Time: 下午3:05
  6. * To change this template use File | Settings | File Templates.
  7. */
  8. module('plugins.wordimage');
  9. test('检查取得word_img的url地址', function () {
  10. var editor = te.obj[0];
  11. editor.setContent('<p><span style="font-size:14px;font-family:&#39;times new roman&#39;, serif"><img width="172px" height="111px" src="/ge/ueditor_1_2_0_0_BRANCH/themes/default/images/spacer.gif" word_img="file:///C:\DOCUME~1\DONGYA~1\LOCALS~1\Temp\msohtmlclip1\01\clip_image001.gif" style="background:url(/ge/ueditor_1_2_0_0_branch/themes/default/images/localimage.png) no-repeat center center;border:1px solid #ddd" /></span><br /></p><p><span style="font-size:14px;font-family:&#39;times new roman&#39;, serif"><img src="http://img.baidu.com/hi/jx2/j_0001.gif" border="0" hspace="0" vspace="0" /><br /> </span></p>');
  12. stop();
  13. setTimeout(function () {
  14. editor.execCommand('wordimage', 'word_img');
  15. equal(editor.body.getElementsByTagName('img')[0].getAttribute('word_img'), "file:///C:DOCUME~1DONGYA~1LOCALS~1Tempmsohtmlclip1clip_image001.gif", '检查url地址');
  16. editor.setContent('<p><a href="http://www.baidu.com" target="_self" title="asdf"><span style="font-size:14px;font-family:&#39;times new roman&#39;, serif"><img width="401px" height="174px" src="/ge/ueditor_1_2_0_0_BRANCH/themes/default/images/spacer.gif" word_img="file:///C:\DOCUME~1\DONGYA~1\LOCALS~1\Temp\msohtmlclip1\01\clip_image001.jpg" style="background:url(/ge/ueditor_1_2_0_0_branch/themes/default/images/localimage.png) no-repeat center center;border:1px solid #ddd" /></span></a><span style="font-size:14px;font-family:&#39;times new roman&#39;, serif"><span style="font-size:14px;font-family:&#39;times new roman&#39;, serif"><img width="172px" height="111px" src="/ge/ueditor_1_2_0_0_BRANCH/themes/default/images/spacer.gif" word_img="file:///C:\DOCUME~1\DONGYA~1\LOCALS~1\Temp\msohtmlclip1\01\clip_image001.gif" style="background:url(/ge/ueditor_1_2_0_0_branch/themes/default/images/localimage.png) no-repeat center center;border:1px solid #ddd" /></span></span></p><p><span style="font-size:14px;font-family:&#39;times new roman&#39;, serif"><span style="font-size:14px;font-family:&#39;times new roman&#39;, serif"><img src="/ge/ueditor_1_2_0_0_BRANCH/server/upload/uploadimages/11171332502507.gif" border="0" hspace="0" vspace="0" /><br /></span></span></p>');
  17. setTimeout(function () {
  18. editor.execCommand('wordimage', 'word_img');
  19. // equal(editor.word_img.length, '2', '有2个wordimg');
  20. equal(editor.body.getElementsByTagName('img')[0].getAttribute('word_img'), "file:///C:\DOCUME~1\DONGYA~1\LOCALS~1\Temp\msohtmlclip1\01\clip_image001.jpg", '检查 第一个url地址');
  21. equal(editor.body.getElementsByTagName('img')[1].getAttribute('word_img'), "file:///C:\DOCUME~1\DONGYA~1\LOCALS~1\Temp\msohtmlclip1\01\clip_image001.gif", '检查 第二个url地址');
  22. equal(editor.queryCommandState('wordimage'), '1', 'queryCommandState');
  23. start();
  24. }, 50);
  25. }, 50);
  26. });
  27. test('多实例编辑器检查取得word_img的url地址', function () {
  28. var div1 = document.createElement('div');
  29. var div2 = document.createElement('div');
  30. document.body.appendChild(div1);
  31. document.body.appendChild(div2);
  32. var editor1 = new UE.Editor({'initialContent':'<p><span style="font-size:14px;font-family:&#39;times new roman&#39;, serif"><img width="172px" height="111px" _src="file:///C:DOCUME~1DONGYA~1LOCALS~1Tempmsohtmlclip1clip_image001.gif" src="/ge/ueditor_1_2_0_0_BRANCH/themes/default/images/spacer.gif" word_img="file:///C:\DOCUME~1\DONGYA~1\LOCALS~1\Temp\msohtmlclip1\01\clip_image001.gif" style="background:url(/ge/ueditor_1_2_0_0_branch/themes/default/images/localimage.png) no-repeat center center;border:1px solid #ddd" /></span><br /></p><p><span style="font-size:14px;font-family:&#39;times new roman&#39;, serif"><img src="http://img.baidu.com/hi/jx2/j_0001.gif" border="0" hspace="0" vspace="0" /><br /> </span></p>','autoFloatEnabled':false});
  33. var editor2 = new UE.Editor({'initialContent':'<p><a href="http://www.baidu.com" target="_self" title="asdf"><span style="font-size:14px;font-family:&#39;times new roman&#39;, serif"><img width="401px" height="174px" src="/ge/ueditor_1_2_0_0_BRANCH/themes/default/images/spacer.gif" word_img="file:///C:\DOCUME~1\DONGYA~1\LOCALS~1\Temp\msohtmlclip1\01\clip_image001.jpg" style="background:url(/ge/ueditor_1_2_0_0_branch/themes/default/images/localimage.png) no-repeat center center;border:1px solid #ddd" /></span></a><span style="font-size:14px;font-family:&#39;times new roman&#39;, serif"><span style="font-size:14px;font-family:&#39;times new roman&#39;, serif"><img width="172px" height="111px" src="/ge/ueditor_1_2_0_0_BRANCH/themes/default/images/spacer.gif" word_img="file:///C:\DOCUME~1\DONGYA~1\LOCALS~1\Temp\msohtmlclip1\01\clip_image001.gif" style="background:url(/ge/ueditor_1_2_0_0_branch/themes/default/images/localimage.png) no-repeat center center;border:1px solid #ddd" /></span></span></p><p><span style="font-size:14px;font-family:&#39;times new roman&#39;, serif"><span style="font-size:14px;font-family:&#39;times new roman&#39;, serif"><img src="/ge/ueditor_1_2_0_0_BRANCH/server/upload/uploadimages/11171332502507.gif" border="0" hspace="0" vspace="0" /><br /></span></span></p>', 'autoFloatEnabled':false});
  34. stop();
  35. setTimeout(function () {
  36. editor1.render(div1);
  37. editor1.ready(function () {
  38. editor2.render(div2);
  39. editor2.ready(function () {
  40. editor1.focus();
  41. editor1.execCommand('wordimage', 'word_img');
  42. // equal(editor1.word_img.length, '1', 'editor1有一个wordimg');
  43. equal(editor1.body.getElementsByTagName('img')[0].getAttribute('word_img'), "file:///C:DOCUME~1DONGYA~1LOCALS~1Tempmsohtmlclip1clip_image001.gif", '检查url地址');
  44. editor2.execCommand('wordimage', 'word_img');
  45. // equal(editor2.word_img.length, '2', 'editor2有2个wordimg');
  46. equal(editor2.body.getElementsByTagName('img')[0].getAttribute('word_img'), "file:///C:\DOCUME~1\DONGYA~1\LOCALS~1\Temp\msohtmlclip1\01\clip_image001.jpg", '检查 第一个url地址');
  47. equal(editor2.body.getElementsByTagName('img')[1].getAttribute('word_img'), "file:///C:\DOCUME~1\DONGYA~1\LOCALS~1\Temp\msohtmlclip1\01\clip_image001.gif", '检查 第二个url地址');
  48. equal(editor1.queryCommandState('wordimage'), '1', 'queryCommandState');
  49. equal(editor2.queryCommandState('wordimage'), '1', 'queryCommandState');
  50. start();
  51. });
  52. });
  53. });
  54. });