ResizeImage.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. draw2d.ResizeImage = function(_url) {
  2. this.url = _url;
  3. this.img = null;
  4. draw2d.Node.call(this);
  5. this.setDimension(100, 100);
  6. this.setColor(null);
  7. };
  8. draw2d.ResizeImage.prototype = new draw2d.Node;
  9. draw2d.ResizeImage.prototype.type = "ResizeImage";
  10. draw2d.ResizeImage.prototype.createHTMLElement = function() {
  11. var item = draw2d.Node.prototype.createHTMLElement.call(this);
  12. if (navigator.appName.toUpperCase() == "MICROSOFT INTERNET EXPLORER") {
  13. this.d = document.createElement("div");
  14. this.d.style.position = "absolute";
  15. this.d.style.left = "0px";
  16. this.d.style.top = "0px";
  17. this.d.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader (src='"
  18. + this.url + "', sizingMethod='scale')";
  19. item.appendChild(this.d);
  20. } else {
  21. this.img = document.createElement("img");
  22. this.img.style.position = "absolute";
  23. this.img.style.left = "0px";
  24. this.img.style.top = "0px";
  25. this.img.src = this.url;
  26. item.appendChild(this.img);
  27. this.d = document.createElement("div");
  28. this.d.style.position = "absolute";
  29. this.d.style.left = "0px";
  30. this.d.style.top = "0px";
  31. item.appendChild(this.d);
  32. }
  33. item.style.left = this.x + "px";
  34. item.style.top = this.y + "px";
  35. return item;
  36. };
  37. draw2d.ResizeImage.prototype.setDimension = function(w, h) {
  38. try{
  39. draw2d.Node.prototype.setDimension.call(this, w, h);
  40. if (this.d !== null) {
  41. this.d.style.width = this.width + "px";
  42. this.d.style.height = this.height + "px";
  43. }
  44. if (this.img !== null) {
  45. this.img.width = this.width;
  46. this.img.height = this.height;
  47. }
  48. }catch(e){
  49. }
  50. };
  51. draw2d.ResizeImage.prototype.setWorkflow = function(_4b06) {
  52. draw2d.Node.prototype.setWorkflow.call(this, _4b06);
  53. };