2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
23 var popupWindowDirective = function($log, $window) {
25 function getZIndex(element) {
27 $(window.document).find("*").each(function() {
28 var zIndex = parseInt($(this).css("z-index"));
29 if (zIndex > maxZIndex) {
37 var scrollPosition = {
42 var link = function(scope, element, attrs, controller, transcludeFn) {
44 var zIndex = getZIndex(element.parent()) + 1;
46 element.css("z-index", zIndex + 1);
48 var backgroundStyle = "display: none; position: fixed; z-index:"
49 + zIndex + ";" + "top: 0; left: 0; width: 100%; height: 100%;"
50 + "background-color: #000000; opacity: 0.5";
52 var className = attrs["class"];
54 if (className !== undefined && className !== null && className !== "") {
55 element.children().children().children().children().addClass(
57 element.removeClass(className);
60 element.before("<div style='" + backgroundStyle + "'></div>");
62 attrs.$observe("ngxShow", function(value) {
63 if (value === "true") {
65 x : $window.pageXOffset,
66 y : $window.pageYOffset
68 $window.scrollTo(0, 0);
69 element.css("display", "table");
70 element.prev().css("display", "block");
71 } else if (value === "false") {
72 element.css("display", "none");
73 element.prev().css("display", "none");
74 $window.scrollTo(scrollPosition.x, scrollPosition.y);
84 templateUrl : "app/vid/scripts/view-models/popupWindow.htm"
88 app.directive("popupWindow", [ "$log", "$window", popupWindowDirective ]);