|
| 1 | +<!DOCTYPE html> |
| 2 | +<html> |
| 3 | +<head> |
| 4 | + <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
| 5 | + <title>Selected Items Frame</title> |
| 6 | + |
| 7 | + <!-- # include file="../../src.primitives/src.primitives.html"--> |
| 8 | + <script type="text/javascript" src="../../min/primitives.min.js?5100"></script> |
| 9 | + <link href="../../min/primitives.latest.css?2106" media="screen" rel="stylesheet" type="text/css" /> |
| 10 | + |
| 11 | + <script type="text/javascript"> |
| 12 | + var control, |
| 13 | + minimizedItemShapeTypes = [ |
| 14 | + primitives.common.ShapeType.Rectangle, |
| 15 | + primitives.common.ShapeType.Oval, |
| 16 | + primitives.common.ShapeType.Triangle, |
| 17 | + primitives.common.ShapeType.CrossOut, |
| 18 | + primitives.common.ShapeType.Circle, |
| 19 | + primitives.common.ShapeType.Rhombus, |
| 20 | + primitives.common.ShapeType.Wedge, |
| 21 | + primitives.common.ShapeType.FramedOval, |
| 22 | + primitives.common.ShapeType.FramedTriangle, |
| 23 | + primitives.common.ShapeType.FramedWedge, |
| 24 | + primitives.common.ShapeType.FramedRhombus |
| 25 | + ], |
| 26 | + shapeIndex = 0, |
| 27 | + itemTitleColors = [ |
| 28 | + primitives.common.Colors.Red, |
| 29 | + primitives.common.Colors.Green, |
| 30 | + primitives.common.Colors.Navy, |
| 31 | + primitives.common.Colors.Cyan |
| 32 | + ], |
| 33 | + colorIndex = 0; |
| 34 | + |
| 35 | + function getNextShapeType() { |
| 36 | + var result = minimizedItemShapeTypes[shapeIndex]; |
| 37 | + shapeIndex+=1; |
| 38 | + if(shapeIndex == minimizedItemShapeTypes.length) { |
| 39 | + shapeIndex = 0; |
| 40 | + } |
| 41 | + return result; |
| 42 | + } |
| 43 | + |
| 44 | + function getNextColor() { |
| 45 | + var result = itemTitleColors[colorIndex]; |
| 46 | + colorIndex+=1; |
| 47 | + if(colorIndex == itemTitleColors.length) { |
| 48 | + colorIndex = 0; |
| 49 | + } |
| 50 | + return result; |
| 51 | + } |
| 52 | + |
| 53 | + function getMarkerTemplate() { |
| 54 | + var result = new primitives.orgdiagram.TemplateConfig(); |
| 55 | + result.name = "MarkerTemplate"; |
| 56 | + result.minimizedItemSize = new primitives.common.Size(8, 8); |
| 57 | + result.highlightPadding = new primitives.common.Thickness(4, 4, 4, 4); |
| 58 | + return result; |
| 59 | + } |
| 60 | + |
| 61 | + document.addEventListener('DOMContentLoaded', function () { |
| 62 | + var options = new primitives.orgdiagram.Config(); |
| 63 | + |
| 64 | + var rootItem = { |
| 65 | + id: 0, |
| 66 | + parent: null, |
| 67 | + title: "Title 0", |
| 68 | + description: "Description", |
| 69 | + image: "../images/photos/a.png", |
| 70 | + minimizedItemShapeType: (getNextShapeType()), |
| 71 | + itemTitleColor: (getNextColor()) |
| 72 | + }; |
| 73 | + var levelItems = [rootItem]; |
| 74 | + var items = [rootItem]; |
| 75 | + var id = 1; |
| 76 | + for(var levelIndex = 0; levelIndex < 4; levelIndex+=1) { |
| 77 | + var newLevelItems = []; |
| 78 | + for(var index = 0; index < levelItems.length; index+=1) { |
| 79 | + var parent = levelItems[index]; |
| 80 | + for (var index2 = 0; index2 < 2; index2++) { |
| 81 | + var newItem = { |
| 82 | + id: ++id, |
| 83 | + parent: parent.id, |
| 84 | + title: id.toString() + " Title", |
| 85 | + description: id.toString() + " Description", |
| 86 | + image: "../images/photos/b.png", |
| 87 | + minimizedItemShapeType: (getNextShapeType()), |
| 88 | + itemTitleColor: (getNextColor()) |
| 89 | + }; |
| 90 | + items.push(newItem); |
| 91 | + newLevelItems.push(newItem); |
| 92 | + } |
| 93 | + } |
| 94 | + levelItems = newLevelItems; |
| 95 | + } |
| 96 | + |
| 97 | + /* collect all ids */ |
| 98 | + var selectedItems = []; |
| 99 | + for(var index = 0; index < items.length; index+=1) { |
| 100 | + selectedItems.push(items[index].id); |
| 101 | + } |
| 102 | + |
| 103 | + options.items = items; |
| 104 | + options.cursorItem = 0; |
| 105 | + options.showFrame = true; |
| 106 | + options.frameInnerPadding = 4; |
| 107 | + options.frameOuterPadding = 4; |
| 108 | + options.templates = [getMarkerTemplate()]; |
| 109 | + options.defaultTemplateName = "MarkerTemplate"; |
| 110 | + options.hasSelectorCheckbox = primitives.common.Enabled.True; |
| 111 | + options.pageFitMode = primitives.common.PageFitMode.None; |
| 112 | + options.selectedItems = selectedItems; |
| 113 | + control = primitives.orgdiagram.Control(document.getElementById("diagram"), options); |
| 114 | + }); |
| 115 | + </script> |
| 116 | +</head> |
| 117 | +<body> |
| 118 | + <div id="diagram" style="width: 640px; height: 480px; border-style: dotted; border-width: 1px;"></div> |
| 119 | +</body> |
| 120 | +</html> |
0 commit comments