'use strict'; /** * Licensed Materials - Property of IBM * IBM Cognos Products: BI Cloud (C) Copyright IBM Corp. 2014, 2017 * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ define(['../../lib/@waca/core-client/js/core-client/ui/core/View', 'jquery', 'underscore', '../../lib/@waca/dashboard-common/dist/utils/DialogBlocker'], function (View, $, _, DialogBlocker) { var OverlayView = null; OverlayView = View.extend({ _dHeight: null, _dWidth: null, init: function init(options) { _.extend(this, options); OverlayView.inherited('init', this, arguments); if (options.height) { this._dHeight = options.height; } if (options.width) { this._dWidth = options.width; } }, render: function render() { var _self = this; var container = DialogBlocker.show(document.body); this._container = container; var card = $('
'); container.append(card); // adjust size to available window $(card).width(this._dWidth === null ? $(container).width() * 0.5 : this._dWidth); $(card).height(this._dHeight === null ? $(container).height() * 0.5 : this._dHeight); $(container).css('overflow', 'hidden'); // setup animation var endpos = { height: $(card).css('height'), width: $(card).css('width') }; $(card).css(endpos); container.fadeIn('fast', function () {}.bind(this)); container.hammer(); DialogBlocker.dialogBlockerClasses.forEach(function (classname) { // tap outside card area - same as cancel on mobile devices $('body').on('tap', 'div.' + classname, function () { _self.cancel(); }); }); // tap inside card should not end things container.on('tap', 'div.overlay', function (event) { event.preventDefault(); event.stopImmediatePropagation(); return; }); var content = this._renderContent(); if (content !== null) { content.appendTo(card); } return this; }, _renderContent: function _renderContent() { return null; }, cancel: function cancel() { this._container.fadeOut('fast', function () { this.remove(); }.bind(this)); }, _getPosition: function _getPosition(element) { var xPosition = 0; var yPosition = 0; while (element) { xPosition += element.offsetLeft - element.scrollLeft + element.clientLeft; yPosition += element.offsetTop - element.scrollTop + element.clientTop; element = element.offsetParent; } return { x: xPosition, y: yPosition }; }, remove: function remove() { if (this._container) { this._container.remove(); this._container = null; } return OverlayView.inherited('remove', this, arguments); } }); return OverlayView; }); //# sourceMappingURL=OverlayView.js.map