IFrame.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. dojo.provide("tm1.iwidget.utilities.IFrame");
  2. dojo.require("bux.Helper");
  3. dojo.require("bux.Encodings");
  4. dojo.declare("tm1.iwidget.utilities.IFrame", dijit._Widget, {
  5. url: null,
  6. frameTitle: null,
  7. resizeZone: null,
  8. iframe: null,
  9. constructor: function(params) {
  10. },
  11. setUrl: function(url) {
  12. this.url = url;
  13. if (this.iframe) {
  14. this.iframe.src = this.prepareUrl(url);
  15. }
  16. },
  17. prepareUrl: function(url) {
  18. if (url === null || url === "") {
  19. return url;
  20. }
  21. url = bux.Helper.normalizeURL(url);
  22. return url;
  23. },
  24. setFrameTitle: function(title) {
  25. this.frameTitle = title;
  26. if (this.iframe) {
  27. this.iframe.title = bux.Encodings.htmlencode(title);
  28. }
  29. },
  30. startup: function() {
  31. this.inherited(arguments);
  32. var dn = this.domNode;
  33. var url = this.url;
  34. this.resizeZone = dn.ownerDocument.createElement("div");
  35. dn.appendChild(this.resizeZone);
  36. dn = (this.iframe = dojo.doc.createElement('iframe'));
  37. dn.id = this.id + "_iframe";
  38. dn.style.border = "none";
  39. dn.style.width = "100%";
  40. dn.frameBorder = 0;
  41. dn.tabIndex = 0;
  42. dn.title = this.frameTitle;
  43. dn.setAttribute('src', this.prepareUrl(url));
  44. this.resizeZone.appendChild(dn);
  45. if (dojo.isWebKit) {
  46. setTimeout(function() {
  47. dn.setAttribute('src', this.prepareUrl(url));
  48. }, 0);
  49. }
  50. },
  51. resize: function(size) {
  52. dijit.layout._LayoutWidget.prototype.resize.apply(this, arguments);
  53. if (dojo.isWebKit) {
  54. this.domNode.style.display = "none";
  55. setTimeout(dojo.hitch(this, function(){
  56. this.domNode.style.display = "";
  57. }), 1);
  58. }
  59. },
  60. layout: function() {
  61. this.resizeZone.style.height = this._contentBox.h + "px";
  62. if (this.iframe) {
  63. this.iframe.style.height = "100%";
  64. }
  65. }
  66. });