|
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="en"> |
| 3 | +<head> |
| 4 | + <meta charset="utf-8"> |
| 5 | + <meta http-equiv="X-UA-Compatible" content="IE=edge"> |
| 6 | + <meta name="viewport" content="width=device-width, initial-scale=1"> |
| 7 | + <title>#1143 test</title> |
| 8 | + |
| 9 | + <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"> |
| 10 | + <link rel="stylesheet" href="../../../demo/demo.css"/> |
| 11 | + |
| 12 | + <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.js"></script> |
| 13 | + <script src="../../../dist/jquery-ui.js"></script> |
| 14 | + <script src="../../../src/gridstack.js"></script> |
| 15 | + <script src="../../../src/gridstack.jQueryUI.js"></script> |
| 16 | + |
| 17 | + <style type="text/css"> |
| 18 | + .grid-stack-item-removing { |
| 19 | + opacity: 0.8; |
| 20 | + filter: blur(5px); |
| 21 | + } |
| 22 | + #advanced-grid .grid-stack-item-content { |
| 23 | + background-color: transparent; |
| 24 | + } |
| 25 | + #advanced-grid .nested1 .grid-stack-item-content { |
| 26 | + background-color: #18bc9c; |
| 27 | + } |
| 28 | + </style> |
| 29 | +</head> |
| 30 | +<body> |
| 31 | + <div class="row"> |
| 32 | + <div class="col-md-2 d-none d-md-block"> |
| 33 | + <div class="newWidget grid-stack-item"> |
| 34 | + <div class="card-body grid-stack-item-content"> |
| 35 | + <span>Drag me in into the dashboard!</span> |
| 36 | + </div> |
| 37 | + </div> |
| 38 | + </div> |
| 39 | + <div class="col-sm-12 col-md-10"> |
| 40 | + <div class="grid-stack" id="advanced-grid" data-gs-animate="yes"> |
| 41 | + <div class="grid-stack-item" data-gs-x="0" data-gs-y="0" data-gs-width="12" data-gs-height="3"> |
| 42 | + <div class="grid-stack-item-content"> |
| 43 | + This nested grid accepts new widget with class "newWidget"<br/> |
| 44 | + The parent grid also accepts new widget but with a differenent class 'otherWidgetType'<br/> |
| 45 | + <div class="grid-stack nested1"> |
| 46 | + <div class="grid-stack-item sub" data-gs-x="0" data-gs-y="0" data-gs-width="3" data-gs-height="1"><div class="grid-stack-item-content">1</div></div> |
| 47 | + <div class="grid-stack-item sub" data-gs-x="3" data-gs-y="0" data-gs-width="3" data-gs-height="1"><div class="grid-stack-item-content">2</div></div> |
| 48 | + <div class="grid-stack-item sub" data-gs-x="6" data-gs-y="0" data-gs-width="3" data-gs-height="1"><div class="grid-stack-item-content">3</div></div> |
| 49 | + <div class="grid-stack-item sub" data-gs-x="9" data-gs-y="0" data-gs-width="3" data-gs-height="1"><div class="grid-stack-item-content">4</div></div> |
| 50 | + <div class="grid-stack-item sub" data-gs-x="0" data-gs-y="1" data-gs-width="3" data-gs-height="1"><div class="grid-stack-item-content">5</div></div> |
| 51 | + <div class="grid-stack-item sub" data-gs-x="3" data-gs-y="1" data-gs-width="3" data-gs-height="1"><div class="grid-stack-item-content">6</div></div> |
| 52 | + </div> |
| 53 | + |
| 54 | + </div> |
| 55 | + </div> |
| 56 | + </div> |
| 57 | + </div> |
| 58 | + </div> |
| 59 | + |
| 60 | + <script type="text/javascript"> |
| 61 | + $(function () { |
| 62 | + var $grid = $('#advanced-grid'); |
| 63 | + $grid.gridstack({ acceptWidgets: '.otherWidgetType' }); |
| 64 | + $('.grid-stack.nested1').gridstack({ acceptWidgets: '.newWidget' }); |
| 65 | + |
| 66 | + $grid.on('added', function(e, items) { log(' added ', items) }); |
| 67 | + $grid.on('removed', function(e, items) { log(' removed ', items) }); |
| 68 | + $grid.on('change', function(e, items) { log(' change ', items) }); |
| 69 | + function log(type, items) { |
| 70 | + var str = ''; |
| 71 | + for (let i=0; items && i<items.length && items[i]; i++) { str += ' (x,y)=' + items[i].x + ',' + items[i].y; } |
| 72 | + console.log(type + items.length + ' items.' + str ); |
| 73 | + } |
| 74 | + |
| 75 | + $('.newWidget').draggable({ |
| 76 | + revert: 'invalid', |
| 77 | + scroll: false, |
| 78 | + appendTo: 'body', |
| 79 | + helper: 'clone' |
| 80 | + }); |
| 81 | + }); |
| 82 | + </script> |
| 83 | +</body> |
| 84 | +</html> |
0 commit comments