22
22
opacity : 0.8 ;
23
23
filter : blur (5px );
24
24
}
25
+ .sidepanel-item {
26
+ background-color : # 18bc9c ;
27
+ text-align : center;
28
+ padding : 5px ;
29
+ margin-bottom : 15px ;
30
+ }
25
31
# trash {
26
- background : rgba (255 , 0 , 0 , 0.4 );
32
+ background-color : rgba (255 , 0 , 0 , 0.4 );
33
+ }
34
+ ion-icon {
35
+ font-size : 300% ;
27
36
}
28
37
</ style >
29
38
</ head >
32
41
< h1 > Advanced Demo</ h1 >
33
42
< div class ="row ">
34
43
< div class ="sidepanel col-md-2 d-none d-md-block ">
35
- < div id ="trash " style ="padding: 5px; margin-bottom: 15px; " class ="text-center ">
36
- < div >
37
- < ion-icon name ="trash " style ="font-size: 300% "> </ ion-icon >
38
- </ div >
39
- < div >
40
- < span > Drop here to remove!</ span >
41
- </ div >
44
+ < div id ="trash " class ="sidepanel-item ">
45
+ < ion-icon name ="trash "> </ ion-icon >
46
+ < div > Drop here to remove!</ div >
42
47
</ div >
43
- < div class ="grid-stack-item " gs-h ="2 ">
44
- < div class ="grid-stack-item-content " style ="padding: 5px; ">
45
- < div >
46
- < ion-icon name ="add-circle " style ="font-size: 300% "> </ ion-icon >
47
- </ div >
48
- < div >
49
- < span > Drag me in the dashboard!</ span >
50
- </ div >
51
- </ div >
48
+ < div class ="grid-stack-item sidepanel-item ">
49
+ < ion-icon name ="add-circle "> </ ion-icon >
50
+ < div > Drag me in the dashboard!</ div >
52
51
</ div >
53
52
</ div >
54
53
< div class ="col-sm-12 col-md-10 ">
@@ -62,17 +61,10 @@ <h1>Advanced Demo</h1>
62
61
el . innerHTML = w . content ;
63
62
} ;
64
63
65
- let grid = GridStack . init ( {
66
- cellHeight : 70 ,
67
- acceptWidgets : true ,
68
- removable : '#trash' , // drag-out delete class
69
- } ) ;
70
- GridStack . setupDragIn ( '.sidepanel>.grid-stack-item' ) ;
71
-
72
- let items = [
64
+ let children = [
73
65
{ x : 0 , y : 0 , w : 4 , h : 2 , content : '1' } ,
74
- { x : 4 , y : 0 , w : 4 , h : 4 , noMove : true , noResize : true , locked : true , content : 'I can\'t be moved or dragged!<br><ion-icon name="ios-lock" style="font-size:300% "></ion-icon>' } ,
75
- { x : 8 , y : 0 , w : 2 , h : 2 , minW : 2 , noResize : true , content : '<p class="card-text text-center" style="margin-bottom: 0">Drag me!<p class="card-text text-center"style="margin-bottom: 0"><ion-icon name="hand" style="font-size: 300%" ></ion-icon><p class="card-text text-center" style="margin-bottom: 0">...but don\'t resize me!' } ,
66
+ { x : 4 , y : 0 , w : 4 , h : 4 , locked : true , content : 'I can\'t be moved or dragged, nor pushed by others !<br><ion-icon name="ios-lock"></ion-icon>' } ,
67
+ { x : 8 , y : 0 , w : 2 , h : 2 , minW : 2 , noResize : true , content : '<p class="card-text text-center" style="margin-bottom: 0">Drag me!<p class="card-text text-center"style="margin-bottom: 0"><ion-icon name="hand"></ion-icon><p class="card-text text-center" style="margin-bottom: 0">...but don\'t resize me!' } ,
76
68
{ x : 10 , y : 0 , w : 2 , h : 2 , content : '4' } ,
77
69
{ x : 0 , y : 2 , w : 2 , h : 2 , content : '5' } ,
78
70
{ x : 2 , y : 2 , w : 2 , h : 4 , content : '6' } ,
@@ -82,7 +74,15 @@ <h1>Advanced Demo</h1>
82
74
{ x : 8 , y : 4 , w : 2 , h : 2 , content : '10' } ,
83
75
{ x : 10 , y : 4 , w : 2 , h : 2 , content : '11' } ,
84
76
] ;
85
- grid . load ( items ) ;
77
+ let insert = [ { h : 2 , content : 'new item' } ] ;
78
+
79
+ let grid = GridStack . init ( {
80
+ cellHeight : 70 ,
81
+ acceptWidgets : true ,
82
+ removable : '#trash' , // drag-out delete class
83
+ children
84
+ } ) ;
85
+ GridStack . setupDragIn ( '.sidepanel>.grid-stack-item' , undefined , insert ) ;
86
86
87
87
grid . on ( 'added removed change' , function ( e , items ) {
88
88
let str = '' ;
0 commit comments