NormalizedSelection.js 965 B

123456789101112131415161718192021222324252627282930
  1. 'use strict';
  2. /**
  3. * Licensed Materials - Property of IBM
  4. * IBM Cognos Products: BI Cloud (C) Copyright IBM Corp. 2015, 2017
  5. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  6. */
  7. define(['../../../../lib/@waca/core-client/js/core-client/ui/core/Class', './NormalizedRange'], function (Class, NormalizedRange) {
  8. /**
  9. * Represents a selection from the document model, but with normalized positions within its ranges
  10. */
  11. var NormalizedSelection = Class.extend({
  12. /**
  13. * @param {Selection} selection from document.getSelection()
  14. */
  15. init: function init(selection) {
  16. this.original = selection;
  17. this.isCursor = selection.isCollapsed;
  18. this.ranges = [];
  19. for (var i = 0; i < selection.rangeCount; i++) {
  20. this.ranges.push(new NormalizedRange(selection.getRangeAt(i)));
  21. }
  22. }
  23. });
  24. return NormalizedSelection;
  25. });
  26. //# sourceMappingURL=NormalizedSelection.js.map