123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- 'use strict';
- /**
- * Licensed Materials - Property of IBM
- * IBM Cognos Products: BI Cloud (C) Copyright IBM Corp. 2013, 2019
- * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- */
- define(['./Absolute', '../../../../lib/@waca/dashboard-common/dist/ui/interaction/Utils', 'jquery'], function (BaseLayout, utils, $) {
- var PageLayout = null;
- PageLayout = BaseLayout.extend({
- init: function init() {
- PageLayout.inherited('init', this, arguments);
- this.specializeConsumeView(['onResize', 'onResizeStep', 'onSelect', 'onDeselect', 'getWidgetPositionUpdate', 'getMinimumTop', 'getMinimumLeft', 'getMaximumHeight', 'getMaximumWidth']);
- },
- createDropZone: function createDropZone() {
- // We do nothing here. We need to disable the absolute layout default dropzone
- },
- /*
- * Return the first ancestor that is not a group
- */
- getFirstNonGroupAncestorView: function getFirstNonGroupAncestorView() {
- var node = null;
- var $nestedGroups = $(this.domNode).parents('.pagegroup');
- if ($nestedGroups.length > 0) {
- node = $nestedGroups[$nestedGroups.length - 1];
- } else {
- node = this.domNode;
- }
- return node._layout.parentLayout;
- },
- onSelect: function onSelect() {
- var children = this.model.items;
- var child;
- for (var i = 0; i < children.length; i++) {
- child = this.layoutController.getLayoutView(children[i].id);
- if (child && child.onSelect) {
- child.onSelect(true); //true [isGroupSelect];
- }
- }
- },
- onDeselect: function onDeselect() {
- var children = this.model.items;
- var child;
- for (var i = 0; i < children.length; i++) {
- child = this.layoutController.getLayoutView(children[i].id);
- if (child && child.onDeselect) {
- child.onDeselect();
- }
- }
- },
- /**
- * Get the position of the group node relative to the first ancestor that is not a group
- */
- getPositionRelativeToPage: function getPositionRelativeToPage() {
- var $node = $(this.domNode);
- var positionRelativeToPage = {
- x: parseInt($node.css('left'), 10),
- y: parseInt($node.css('top'), 10)
- };
- var $nestedGroups = $node.parents('.pagegroup');
- for (var i = 0; i < $nestedGroups.length; i++) {
- positionRelativeToPage.x += parseInt($($nestedGroups[i]).css('left'), 10);
- positionRelativeToPage.y += parseInt($($nestedGroups[i]).css('top'), 10);
- }
- return positionRelativeToPage;
- },
- /**
- * Get the minimum left position that a child can have before reaching the left most boundary of the page
- */
- getMinimumLeft: function getMinimumLeft() {
- var positionRelativeToPage = this.getPositionRelativeToPage();
- var pageView = this.getFirstNonGroupAncestorView();
- return pageView.getMinimumLeft() - positionRelativeToPage.x;
- },
- /**
- * Get the minimum top position that a child can have before reaching the top most boundary of the page
- */
- getMinimumTop: function getMinimumTop() {
- var positionRelativeToPage = this.getPositionRelativeToPage();
- var pageView = this.getFirstNonGroupAncestorView();
- return pageView.getMinimumTop() - positionRelativeToPage.y;
- },
- getMaximumWidth: function getMaximumWidth() {
- var pageView = this.getFirstNonGroupAncestorView();
- var pageMaxWidth = pageView.getMaximumWidth();
- if (pageMaxWidth) {
- var positionRelativeToPage = this.getPositionRelativeToPage();
- pageMaxWidth = pageMaxWidth - positionRelativeToPage.x;
- }
- return pageMaxWidth;
- },
- getMaximumHeight: function getMaximumHeight() {
- var pageView = this.getFirstNonGroupAncestorView();
- var pageMaxHeight = pageView.getMaximumHeight();
- if (pageMaxHeight) {
- var positionRelativeToPage = this.getPositionRelativeToPage();
- pageMaxHeight = pageMaxHeight - positionRelativeToPage.y;
- }
- return pageMaxHeight;
- }
- });
- return PageLayout;
- });
- //# sourceMappingURL=Group.js.map
|