Compare commits
4 Commits
AndriiFunc
...
kolory,poł
| Author | SHA1 | Date | |
|---|---|---|---|
| 11c2222536 | |||
| 1541d62bb5 | |||
| cd13d21e5f | |||
| d8e3dc8cee |
@@ -19,9 +19,9 @@ Funkcjonalności aplikacji koncentrują się na tworzeniu i modyfikacji kształt
|
||||
- [x] 7. Zaznaczenie kształtu
|
||||
- [x] 8. Kopiowanie kształtu
|
||||
- [x] 9. Wklejanie kształtu
|
||||
- [ ] 10. Zmiana kolorów kształtów
|
||||
- [ ] 11. Połączenie kształtów (strzałka ->)
|
||||
- [ ] 12. Usunięcie kształtów
|
||||
- [x] 10. Zmiana kolorów kształtów
|
||||
- [x] 11. Połączenie kształtów (strzałka ->)
|
||||
- [x] 12. Usunięcie kształtów
|
||||
|
||||
### Tekst
|
||||
- [x] 13. Dodanie tekstu
|
||||
|
||||
157
index.html
157
index.html
@@ -10,55 +10,123 @@
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="toolbar">
|
||||
<p>Kształty - przeciągnij i upuść</p>
|
||||
<div class="shape-wrapper toolbar-wrapper">
|
||||
<div id="shape-rectangle" class="shape" data-type="rectangle"></div>
|
||||
<div id="shape-ellipse" class="shape" data-type="ellipse"></div>
|
||||
<div id="shape-diamond" class="shape" data-type="diamond"></div>
|
||||
<div id="shape-text" class="shape" data-type="text">Tekst</div>
|
||||
</div>
|
||||
<p>Akcje</p>
|
||||
<div class="tools-wrapper toolbar-wrapper">
|
||||
<button id="btn-delete">Usuń</button>
|
||||
<button id="btn-copy">Kopiuj</button>
|
||||
<button id="btn-paste">Wklej</button>
|
||||
</div>
|
||||
<p>Zoom</p>
|
||||
<div class="zoom-wrapper toolbar-wrapper">
|
||||
<button id="zoom-in">+</button>
|
||||
<button id="zoom-out">-</button>
|
||||
</div>
|
||||
<div class="toolbar">
|
||||
<p>Kształty - przeciągnij i upuść</p>
|
||||
<div class="shape-wrapper toolbar-wrapper">
|
||||
<div id="shape-rectangle" class="shape" data-type="rectangle"></div>
|
||||
<div id="shape-ellipse" class="shape" data-type="ellipse"></div>
|
||||
<div id="shape-diamond" class="shape" data-type="diamond"></div>
|
||||
<div id="shape-text" class="shape" data-type="text">Tekst</div>
|
||||
</div>
|
||||
|
||||
<div id="resize-handle" style="position: absolute; display: none; border: 2px dashed #4A90E2; z-index: 10;"></div>
|
||||
<div class="canvas-container">
|
||||
<div id="paper"></div>
|
||||
<p>Akcje</p>
|
||||
<div class="tools-wrapper toolbar-wrapper">
|
||||
<button id="btn-delete">Usuń</button>
|
||||
<button id="btn-copy">Kopiuj</button>
|
||||
<button id="btn-paste">Wklej</button>
|
||||
<button id="btn-connect">Połącz</button>
|
||||
<div class="color-wrapper"><!-- DODANE -->
|
||||
<button id="btn-change-color">Kolor</button> <!-- DODANE -->
|
||||
<div id="color-palette" style="position:absolute; display:none; padding:8px; background:#fff; border:1px solid #ccc; border-radius:6px; gap:6px; z-index:2000;"></div>
|
||||
</div>
|
||||
</div>
|
||||
<p>Zoom</p>
|
||||
<div class="zoom-wrapper toolbar-wrapper">
|
||||
<button id="zoom-in">+</button>
|
||||
<button id="zoom-out">-</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
|
||||
<script src="https://code.jquery.com/ui/1.13.2/jquery-ui.min.js"></script>
|
||||
<script src="joint.js"></script>
|
||||
<script>
|
||||
let selectedElement = null;
|
||||
let activeElementView = null;
|
||||
let clipboard = null;
|
||||
<div id="resize-handle" style="position: absolute; display: none; border: 2px dashed #4A90E2; z-index: 10;"></div>
|
||||
<div class="canvas-container">
|
||||
<div id="paper"></div>
|
||||
</div>
|
||||
|
||||
$(document).ready(function () {
|
||||
//init paper - Start
|
||||
const graph = new joint.dia.Graph();
|
||||
const paper = new joint.dia.Paper({
|
||||
el: $('#paper'),
|
||||
model: graph,
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight,
|
||||
gridSize: 20,
|
||||
<!-- DODANY KONTAINER DLA PALETY KOLORÓW -->
|
||||
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
|
||||
<script src="https://code.jquery.com/ui/1.13.2/jquery-ui.min.js"></script>
|
||||
<script src="joint.js"></script>
|
||||
<script>
|
||||
let selectedElement = null;
|
||||
let activeElementView = null;
|
||||
let clipboard = null;
|
||||
|
||||
|
||||
$(document).ready(function () {
|
||||
const graph = new joint.dia.Graph();
|
||||
const paper = new joint.dia.Paper({
|
||||
el: $('#paper'),
|
||||
model: graph,
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight,
|
||||
gridSize: 20,
|
||||
preventContextMenu: false,
|
||||
});
|
||||
|
||||
const $resizeHandle = $('#resize-handle');
|
||||
|
||||
// --- DODANE FUNKCJE START ---
|
||||
let connectMode = false;
|
||||
|
||||
$('#btn-connect').click(function() {
|
||||
if (!selectedElement) return;
|
||||
connectMode = !connectMode;
|
||||
$(this).css('background', connectMode ? '#e3f2fd' : '#fff');
|
||||
});
|
||||
|
||||
const paletteColors = ['#FF4B4B','#FFA500','#FFD700','#4CAF50','#00BCD4','#2196F3','#9C27B0','#795548','#000000'];
|
||||
const $palette = $('#color-palette');
|
||||
$palette.css({ gridTemplateColumns:'repeat(3,28px)' });
|
||||
|
||||
paletteColors.forEach(c => {
|
||||
// ZMIANA TUTAJ: Dodajemy width, height, border i cursor
|
||||
const tile = $('<div></div>').css({
|
||||
background: c,
|
||||
width: '28px', // Dodane
|
||||
height: '28px', // Dodane
|
||||
border: '1px solid #444', // Dodane dla widoczności
|
||||
cursor: 'pointer' // Dodane dla kursora rączki
|
||||
});
|
||||
//init paper - END
|
||||
|
||||
const $resizeHandle = $('#resize-handle');
|
||||
tile.on('click', function() {
|
||||
if (selectedElement) {
|
||||
try {
|
||||
// Ustawianie koloru
|
||||
selectedElement.attr('body/fill', c);
|
||||
if (selectedElement.attributes.type === 'standard.TextBlock') {
|
||||
selectedElement.attr('label/fill', c);
|
||||
}
|
||||
} catch(e) { /* ignoruj */ }
|
||||
}
|
||||
$palette.hide();
|
||||
});
|
||||
$palette.append(tile);
|
||||
});
|
||||
|
||||
// obwódka i znaczek usuwanie
|
||||
$('#btn-change-color').on('click', function() {
|
||||
$palette.toggleClass('active');
|
||||
});
|
||||
$(document).on('click', function(e) {
|
||||
if (!$(e.target).closest('#color-palette,#btn-change-color').length)
|
||||
if($palette.hasClass('active'))
|
||||
$palette.toggleClass('active');
|
||||
});
|
||||
|
||||
|
||||
paper.on('element:pointerclick', function (elementView) {
|
||||
if (connectMode && selectedElement && selectedElement !== elementView.model) {
|
||||
const link = new joint.shapes.standard.Link();
|
||||
link.source(selectedElement);
|
||||
link.target(elementView.model);
|
||||
graph.addCell(link);
|
||||
connectMode = false;
|
||||
$('#btn-connect').css('background','#fff');
|
||||
}
|
||||
});
|
||||
// --- DODANE FUNKCJE KONIEC ---
|
||||
|
||||
// obwódka i znaczek usuwanie
|
||||
function createToolsView() {
|
||||
return new joint.dia.ToolsView({
|
||||
tools: [
|
||||
@@ -310,8 +378,10 @@
|
||||
});
|
||||
|
||||
//add text to text block - START
|
||||
paper.on('element:pointerdblclick', function (elementView) {
|
||||
paper.on('element:contextmenu', function (elementView,ev) {
|
||||
ev.preventDefault();
|
||||
if (elementView.model.attributes.type === 'standard.TextBlock') {
|
||||
|
||||
const currentText = elementView.model.attr('label/text');
|
||||
const newText = prompt('Edytuj tekst:', currentText);
|
||||
if (newText != null) {
|
||||
@@ -431,6 +501,7 @@
|
||||
|
||||
|
||||
|
||||
|
||||
// Zoom
|
||||
const zoomStep = 0.2;
|
||||
const minScale = 0.2;
|
||||
|
||||
Reference in New Issue
Block a user