4
4
< meta charset ="utf-8 ">
5
5
< meta http-equiv ="X-UA-Compatible " content ="IE=edge ">
6
6
< meta name ="viewport " content ="width=device-width, initial-scale=1 ">
7
- < title > Two grids demo</ title >
7
+ < title > Two grids JQ demo</ title >
8
8
9
9
< link rel ="stylesheet " href ="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css ">
10
10
< link rel ="stylesheet " href ="demo.css "/>
45
45
</ head >
46
46
< body >
47
47
< div class ="container-fluid ">
48
- < h1 > Two grids demo</ h1 >
48
+ < h1 > Two grids demo (Jquery version) </ h1 >
49
49
50
50
< div class ="row ">
51
51
< div class ="col-md-3 ">
52
52
< div class ="sidebar ">
53
-
54
53
<!-- will size to match content -->
55
54
< div class ="grid-stack-item ">
56
55
< div class ="grid-stack-item-content "> Drag me</ div >
57
56
</ div >
58
57
<!-- manually force a drop size of 2x1 -->
59
- < div class ="grid-stack-item " gs-w ="2 " gs-h ="1 ">
60
- < div class ="grid-stack-item-content "> Drag me 2x1</ div >
58
+ < div class ="grid-stack-item " gs-w ="2 " gs-h ="1 " gs-max-w =" 3 " >
59
+ < div class ="grid-stack-item-content "> 2x1, max=3 </ div >
61
60
</ div >
62
-
63
61
</ div >
64
62
</ div >
65
63
< div class ="col-md-9 ">
@@ -83,19 +81,21 @@ <h1>Two grids demo</h1>
83
81
</ div >
84
82
< script src ="events.js "> </ script >
85
83
< script type ="text/javascript ">
84
+ let grids ;
85
+ $ ( function ( ) { // testing $ works (delay loading here)
86
86
let options = {
87
87
column : 6 ,
88
88
minRow : 1 , // don't collapse when empty
89
89
cellHeight : 70 ,
90
90
disableOneColumnMode : true ,
91
91
float : false ,
92
- dragIn : '.sidebar .grid-stack-item' , // class that can be dragged from outside
92
+ dragIn : '.sidebar .grid-stack-item' , // add draggable to class
93
93
dragInOptions : { revert : 'invalid' , scroll : false , appendTo : 'body' , helper : 'clone' } , // clone
94
94
removable : '.trash' , // drag-out delete class
95
95
removeTimeout : 100 ,
96
96
acceptWidgets : function ( el ) { return true ; } // function example, else can be simple: true | false | '.someClass' value
97
97
} ;
98
- let grids = GridStack . initAll ( options ) ;
98
+ grids = GridStack . initAll ( options ) ;
99
99
grids [ 1 ] . float ( true ) ;
100
100
101
101
let items = [
@@ -110,15 +110,15 @@ <h1>Two grids demo</h1>
110
110
addEvents ( grid , i ) ;
111
111
grid . load ( items ) ;
112
112
} ) ;
113
+ } ) ;
114
+ function toggleFloat ( button , i ) {
115
+ grids [ i ] . float ( ! grids [ i ] . getFloat ( ) ) ;
116
+ button . innerHTML = 'float: ' + grids [ i ] . getFloat ( ) ;
117
+ }
113
118
114
- function toggleFloat ( button , i ) {
115
- grids [ i ] . float ( ! grids [ i ] . getFloat ( ) ) ;
116
- button . innerHTML = 'float: ' + grids [ i ] . getFloat ( ) ;
117
- }
118
-
119
- function compact ( i ) {
120
- grids [ i ] . compact ( ) ;
121
- }
119
+ function compact ( i ) {
120
+ grids [ i ] . compact ( ) ;
121
+ }
122
122
</ script >
123
123
</ body >
124
124
</ html >
0 commit comments