background.js 1.4 KB

123456789101112131415161718192021222324252627282930313233
  1. ///import core
  2. ///commands 插入背景
  3. ///commandsName background
  4. ///commandsTitle 插入背景
  5. ///commandsDialog dialogs\background
  6. UE.plugins['background'] = function(){
  7. var me = this;
  8. me.addListener("getAllHtml",function(type,headHtml){
  9. var body = this.body,
  10. su = domUtils.getComputedStyle(body,"background-image"),
  11. url="";
  12. if(su.indexOf(me.options.imagePath)>0){
  13. url = su.substring(su.indexOf(me.options.imagePath),su.length-1).replace(/"|\(|\)/ig,"");
  14. }else{
  15. url = su!="none" ? su.replace(/url\("?|"?\)/ig,""):"";
  16. }
  17. var html = '<style type="text/css">body{';
  18. var bgObj = {
  19. "background-color" : domUtils.getComputedStyle(body,"background-color")||"#ffffff",
  20. 'background-image' : url ? 'url('+url+')' : '',
  21. 'background-repeat':domUtils.getComputedStyle(body,"background-repeat")||"",
  22. 'background-position': browser.ie?(domUtils.getComputedStyle(body,"background-position-x")+" "+domUtils.getComputedStyle(body,"background-position-y")):domUtils.getComputedStyle(body,"background-position"),
  23. 'height':domUtils.getComputedStyle(body,"height")
  24. };
  25. for ( var name in bgObj ) {
  26. if ( bgObj.hasOwnProperty( name ) ) {
  27. html += name+":"+bgObj[name]+";";
  28. }
  29. }
  30. html += '}</style> ';
  31. headHtml.push(html);
  32. });
  33. }