IframeDialog.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. 'use strict';
  2. /**
  3. * Licensed Materials - Property of IBM
  4. * IBM Cognos Products: BI Cloud (C) Copyright IBM Corp. 2014, 2018
  5. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  6. */
  7. define(['jquery', '../../../lib/@waca/core-client/js/core-client/ui/dialogs/BaseDialog'], function ($, BaseDialog) {
  8. var Dialog = null;
  9. Dialog = BaseDialog.extend({
  10. init: function init(url, successCheck, okHandler, cancelHandler) {
  11. Dialog.inherited('init', this);
  12. this.url = url;
  13. this.successCheck = successCheck;
  14. this.okHandler = okHandler;
  15. this.cancelHandler = cancelHandler;
  16. },
  17. show: function show() {
  18. var nContainer = this._container();
  19. if (nContainer.length) {
  20. nContainer.empty();
  21. var styles = { width: window.innerWidth - 50, height: window.innerHeight - 50 };
  22. var content = this.renderContent($('<div>', { 'class': 'dialogContent dialogCenter' }).css(styles));
  23. nContainer.append($('<div>', {
  24. 'class': 'modalDialog',
  25. 'tabIndex': '0',
  26. 'role': 'dialog'
  27. }).append(content));
  28. }
  29. },
  30. renderContent: function renderContent(n) {
  31. this.$dialog = $('<iframe>', { 'class': 'iFrameContent' });
  32. this.$dialog.on('load', this._onDialogLoad.bind(this));
  33. $('body').append(this.$dialog);
  34. this.$dialog.attr('src', this.url);
  35. n.append(this.$dialog);
  36. return n;
  37. },
  38. _onDialogLoad: function _onDialogLoad() {
  39. var loc = this.$dialog[0].contentWindow.location.href;
  40. if (loc && loc.indexOf(this.successCheck) !== -1) {
  41. this.hide();
  42. this.okHandler();
  43. $('document').remove(this.$dialog);
  44. this.$dialog = null;
  45. }
  46. }
  47. });
  48. return Dialog;
  49. });
  50. //# sourceMappingURL=IframeDialog.js.map