IFrameWidget.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*##############################################################################
  2. # HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. ############################################################################## */
  16. define([
  17. "dojo/_base/declare",
  18. "dojo/_base/lang",
  19. "dojo/i18n",
  20. "dojo/i18n!./nls/common",
  21. "dojo/i18n!./nls/IFrameWidget",
  22. "dojo/dom-construct",
  23. "dijit/registry",
  24. "hpcc/_Widget",
  25. "dojo/text!../templates/IFrameWidget.html",
  26. "dijit/layout/BorderContainer",
  27. "dijit/Toolbar",
  28. "dijit/ToolbarSeparator",
  29. "dijit/form/Button",
  30. "dijit/layout/ContentPane"
  31. ], function (declare, lang, i18n, nlsCommon, nlsSpecific, domConstruct,
  32. registry,
  33. _Widget,
  34. template) {
  35. return declare("IFrameWidget", [_Widget], {
  36. templateString: template,
  37. baseClass: "IFrameWidget",
  38. i18n: lang.mixin(nlsCommon, nlsSpecific),
  39. postCreate: function (args) {
  40. this.inherited(arguments);
  41. this.borderContainer = registry.byId(this.id + "BorderContainer");
  42. this.contentPane = registry.byId(this.id + "ContentPane");
  43. },
  44. resize: function (args) {
  45. this.inherited(arguments);
  46. if (this.borderContainer) {
  47. this.borderContainer.resize();
  48. }
  49. },
  50. // Hitched actions ---
  51. _onRefresh: function (event) {
  52. this.contentPane.set("content", domConstruct.create("iframe", {
  53. id: this.id + "IFrame",
  54. src: this.params.src,
  55. style: "border:1px solid lightgray; width: 100%; height: 100%"
  56. }));
  57. },
  58. // Implementation ---
  59. init: function (params) {
  60. if (this.inherited(arguments))
  61. return;
  62. this._onRefresh();
  63. }
  64. });
  65. });