123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- 'use strict';
- /**
- * Licensed Materials - Property of IBM
- * IBM Cognos Products: BI Cloud (C) Copyright IBM Corp. 2018
- * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- *
- * Grid Guidelines
- */
- define(['jquery', 'underscore', '../../../../lib/@waca/core-client/js/core-client/ui/core/Class'], function ($, _, Class) {
- var SQUARES_INFO = 60;
- var SQUARES = 100;
- var GridGuidelines = Class.extend({
- gridSize: 0,
- init: function init(options) {
- var $page = $(options.page);
- this.layoutController = options.controller;
- var layoutModel = this.layoutController.boardModel.layout.findModel(options.page.id);
- if (!layoutModel) {
- layoutModel = this.layoutController.boardModel.layout;
- }
- this.snapGrid = layoutModel.getValueFromSelfOrParent('snapGrid');
- this.snapGrid = this.snapGrid === undefined ? false : this.snapGrid;
- var layoutPositioning = layoutModel.getValueFromSelfOrParent('layoutPositioning');
- if (layoutPositioning === 'absolute') {
- this.gridSize = 10;
- } else if (layoutPositioning === 'relative') {
- this.gridSize = this.getGridSize($page);
- }
- },
- getGridSize: function getGridSize($page) {
- var gridSize = 0;
- if ($page) {
- var width = $page.width();
- if ($page.hasClass('infoGraphic')) {
- gridSize = width / SQUARES_INFO;
- } else {
- gridSize = width / SQUARES;
- }
- }
- return gridSize;
- },
- calculateSnapPoint: function calculateSnapPoint(dragEdge) {
- if (this.snapGrid) {
- var distance = dragEdge % this.gridSize;
- if (distance > this.gridSize - 0.5) {
- distance = 0;
- }
- return { 'distance': distance };
- }
- return { 'distance': null };
- }
- });
- return GridGuidelines;
- });
- //# sourceMappingURL=GridGuidelines.js.map
|