Skip to content

Commit 693b891

Browse files
committed
migration to vue-cli done, code cleanup
1 parent 12eebaf commit 693b891

15 files changed

+74
-92
lines changed

examples/01-basic.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<title>Vue Grid Layout Example 1 - Basic Responsive</title>
66
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
77
<link rel="stylesheet" href="app.css">
8+
<link rel="stylesheet" href="../dist/vue-grid-layout.css">
89
</head>
910
<body>
1011
<h1>Vue Grid Layout Example 1 - Basic</h1>
@@ -54,7 +55,7 @@ <h1>Vue Grid Layout Example 1 - Basic</h1>
5455

5556
</div>
5657
<script src="vue.min.js"></script>
57-
<script src="../dist/vue-grid-layout.min.js"></script>
58+
<script src="../dist/vue-grid-layout.umd.min.js"></script>
5859
<script src="01-basic.js"></script>
5960
</body>
6061
</html>

examples/01-basic.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,8 @@ var testLayout = [
2626
Vue.config.debug = true;
2727
Vue.config.devtools = true;
2828

29-
var GridLayout = VueGridLayout.GridLayout;
30-
var GridItem = VueGridLayout.GridItem;
31-
3229
new Vue({
3330
el: '#app',
34-
components: {
35-
"GridLayout": GridLayout,
36-
"GridItem": GridItem
37-
},
3831
data: {
3932
layout: testLayout,
4033
draggable: true,

examples/02-events.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<title>Vue Grid Layout Example 1 - Basic Responsive</title>
66
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
77
<link rel="stylesheet" href="app.css">
8+
<link rel="stylesheet" href="../dist/vue-grid-layout.css">
89
</head>
910
<body>
1011
<h1>Vue Grid Layout Example 2 - Move and resize events</h1>
@@ -64,7 +65,7 @@ <h1>Vue Grid Layout Example 2 - Move and resize events</h1>
6465

6566
</div>
6667
<script src="vue.min.js"></script>
67-
<script src="../dist/vue-grid-layout.min.js"></script>
68+
<script src="../dist/vue-grid-layout.umd.min.js"></script>
6869
<script src="02-events.js"></script>
6970
</body>
7071
</html>

examples/02-events.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,8 @@ var testLayout = [
2626
Vue.config.debug = true;
2727
Vue.config.devtools = true;
2828

29-
var GridLayout = VueGridLayout.GridLayout;
30-
var GridItem = VueGridLayout.GridItem;
31-
3229
new Vue({
3330
el: '#app',
34-
components: {
35-
"GridLayout": GridLayout,
36-
"GridItem": GridItem
37-
},
3831
data: {
3932
layout: testLayout,
4033
index: 0,
@@ -53,13 +46,19 @@ new Vue({
5346
console.log(msg);
5447

5548
},
56-
resizeEvent: function(i, newH, newW){
57-
var msg = "RESIZE i=" + i + ", H=" + newH + ", W=" + newW;
49+
movedEvent: function(i, newX, newY){
50+
var msg = "MOVED i=" + i + ", X=" + newX + ", Y=" + newY;
51+
this.eventLog.push(msg);
52+
console.log(msg);
53+
54+
},
55+
resizeEvent: function(i, newH, newW, newHPx, newWPx){
56+
var msg = "RESIZE i=" + i + ", H=" + newH + ", W=" + newW + ", H(px)=" + newHPx + ", W(px)=" + newWPx;
5857
this.eventLog.push(msg);
5958
console.log(msg);
6059
},
61-
movedEvent: function(i, newX, newY){
62-
var msg = "MOVED i=" + i + ", X=" + newX + ", Y=" + newY;
60+
resizedEvent: function(i, newX, newY, newHPx, newWPx){
61+
var msg = "RESIZED i=" + i + ", X=" + newX + ", Y=" + newY + ", H(px)=" + newHPx + ", W(px)=" + newWPx;
6362
this.eventLog.push(msg);
6463
console.log(msg);
6564

examples/03-multiple-grids.html

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<meta charset="utf-8">
55
<title>Vue Grid Layout Example 3 - Multiple grids</title>
66
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
7+
<link rel="stylesheet" href="../dist/vue-grid-layout.css">
78
<link rel="stylesheet" href="app.css">
89
</head>
910
<body>
@@ -81,21 +82,10 @@ <h3>Grid 2</h3>
8182
</div>
8283

8384
<script src="vue.min.js"></script>
84-
<script src="../dist/vue-grid-layout.min.js"></script>
85+
<script src="../dist/vue-grid-layout.umd.min.js"></script>
8586
<script type="text/javascript">
86-
Vue.config.debug = true;
87-
Vue.config.devtools = true;
88-
89-
var GridLayout = VueGridLayout.GridLayout;
90-
var GridItem = VueGridLayout.GridItem;
91-
92-
9387
new Vue({
9488
el: '#app1',
95-
components: {
96-
GridLayout,
97-
GridItem,
98-
},
9989
data: {
10090
layout: [
10191
{"x":0,"y":0,"w":2,"h":2,"i":"0"},
@@ -107,10 +97,6 @@ <h3>Grid 2</h3>
10797

10898
new Vue({
10999
el: '#app2',
110-
components: {
111-
GridLayout,
112-
GridItem,
113-
},
114100
data: {
115101
layout: [
116102
{"x":0,"y":0,"w":2,"h":2,"i":"0"},

examples/04-allow-ignore.html

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<meta charset="utf-8">
55
<title>Vue Grid Layout Example 4 - Drag allow/ignore elements</title>
66
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
7+
<link rel="stylesheet" href="../dist/vue-grid-layout.css">
78
<link rel="stylesheet" href="app.css">
89
</head>
910
<body>
@@ -66,21 +67,10 @@ <h1>Vue Grid Layout Example 4 - Drag allow/ignore elements</h1>
6667
</div>
6768

6869
<script src="vue.min.js"></script>
69-
<script src="../dist/vue-grid-layout.min.js"></script>
70+
<script src="../dist/vue-grid-layout.umd.min.js"></script>
7071
<script type="text/javascript">
71-
Vue.config.debug = true;
72-
Vue.config.devtools = true;
73-
74-
var GridLayout = VueGridLayout.GridLayout;
75-
var GridItem = VueGridLayout.GridItem;
76-
77-
7872
new Vue({
7973
el: '#app',
80-
components: {
81-
GridLayout,
82-
GridItem,
83-
},
8474
data: {
8575
layout: [
8676
{"x":0,"y":0,"w":2,"h":2,"i":"0"},

examples/05-mirrored.html

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<meta charset="utf-8">
55
<title>Vue Grid Layout Example 4 - Mirrored grid layout</title>
66
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
7+
<link rel="stylesheet" href="../dist/vue-grid-layout.css">
78
<link rel="stylesheet" href="app.css">
89
</head>
910
<body>
@@ -57,7 +58,7 @@ <h1>Vue Grid Layout Example 5 - Mirrored grid layout</h1>
5758

5859
</div>
5960
<script src="vue.min.js"></script>
60-
<script src="../dist/vue-grid-layout.min.js"></script>
61+
<script src="../dist/vue-grid-layout.umd.min.js"></script>
6162
<script type="text/javascript">
6263
const testLayout = [
6364
{"x":0,"y":0,"w":2,"h":2,"i":"0"},
@@ -82,18 +83,8 @@ <h1>Vue Grid Layout Example 5 - Mirrored grid layout</h1>
8283
{"x":2,"y":6,"w":2,"h":2,"i":"19"}
8384
];
8485

85-
Vue.config.debug = true;
86-
Vue.config.devtools = true;
87-
88-
const GridLayout = VueGridLayout.GridLayout;
89-
const GridItem = VueGridLayout.GridItem;
90-
9186
new Vue({
9287
el: '#app',
93-
components: {
94-
"GridLayout": GridLayout,
95-
"GridItem": GridItem
96-
},
9788
data: {
9889
layout: testLayout,
9990
draggable: true,

examples/app.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232

3333

34-
.vue-resizable-handle {
34+
/*.vue-resizable-handle {
3535
z-index: 5000;
3636
position: absolute;
3737
width: 20px;
@@ -45,7 +45,7 @@
4545
background-origin: content-box;
4646
box-sizing: border-box;
4747
cursor: se-resize;
48-
}
48+
}*/
4949

5050
.vue-grid-item:not(.vue-grid-placeholder) {
5151
background: #ccc;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"scripts": {
2222
"serve": "vue-cli-service serve",
2323
"build": "vue-cli-service build",
24-
"build-bundle": "vue-cli-service build --target lib --name vue-grid-layout ./src/components/index.js",
24+
"build-bundle": "vue-cli-service build --target lib ./src/components/index.js",
2525
"lint": "vue-cli-service lint"
2626
},
2727
"dependencies": {

src/App.vue

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<div class="layoutJSON">
77
Displayed as <code>[x, y, w, h]</code>:
88
<div class="columns">
9-
<div class="layoutItem" v-for="item in layout">
9+
<div class="layoutItem" v-for="item in layout" :key="item.i">
1010
<b>{{item.i}}</b>: [{{item.x}}, {{item.y}}, {{item.w}}, {{item.h}}]
1111
</div>
1212
</div>
@@ -146,14 +146,13 @@
146146
clicked: function() {
147147
window.alert("CLICK!");
148148
},
149-
increaseWidth: function(item) {
150-
var width = document.getElementById("content").offsetWidth;
149+
increaseWidth: function() {
150+
let width = document.getElementById("content").offsetWidth;
151151
width += 20;
152152
document.getElementById("content").style.width = width+"px";
153153
},
154-
decreaseWidth: function(item) {
155-
156-
var width = document.getElementById("content").offsetWidth;
154+
decreaseWidth: function() {
155+
let width = document.getElementById("content").offsetWidth;
157156
width -= 20;
158157
document.getElementById("content").style.width = width+"px";
159158
},
@@ -162,14 +161,14 @@
162161
this.layout.splice(this.layout.indexOf(item), 1);
163162
},
164163
addItem: function() {
165-
let self = this;
164+
// let self = this;
166165
//console.log("### LENGTH: " + this.layout.length);
167166
let item = {"x":0,"y":0,"w":2,"h":2,"i":this.index+"", whatever: "bbb"};
168167
this.index++;
169168
this.layout.push(item);
170169
},
171170
move: function(i, newX, newY){
172-
// console.log("MOVE i=" + i + ", X=" + newX + ", Y=" + newY);
171+
console.log("MOVE i=" + i + ", X=" + newX + ", Y=" + newY);
173172
},
174173
resize: function(i, newH, newW, newHPx, newWPx){
175174
console.log("RESIZE i=" + i + ", H=" + newH + ", W=" + newW + ", H(px)=" + newHPx + ", W(px)=" + newWPx);

0 commit comments

Comments
 (0)