-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path01-basic.js
96 lines (88 loc) · 2.92 KB
/
01-basic.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
var testLayout = [
{"x":0,"y":0,"w":2,"h":2,"i":"0", static: false},
{"x":2,"y":0,"w":2,"h":4,"i":"1", static: true},
{"x":4,"y":0,"w":2,"h":5,"i":"2", static: false},
{"x":6,"y":0,"w":2,"h":3,"i":"3", static: false},
{"x":8,"y":0,"w":2,"h":3,"i":"4", static: false},
{"x":10,"y":0,"w":2,"h":3,"i":"5", static: false},
{"x":0,"y":5,"w":2,"h":5,"i":"6", static: false},
{"x":2,"y":5,"w":2,"h":5,"i":"7", static: false},
{"x":4,"y":5,"w":2,"h":5,"i":"8", static: false},
{"x":6,"y":3,"w":2,"h":4,"i":"9", static: true},
{"x":8,"y":4,"w":2,"h":4,"i":"10", static: false},
{"x":10,"y":4,"w":2,"h":4,"i":"11", static: false},
{"x":0,"y":10,"w":2,"h":5,"i":"12", static: false},
{"x":2,"y":10,"w":2,"h":5,"i":"13", static: false},
{"x":4,"y":8,"w":2,"h":4,"i":"14", static: false},
{"x":6,"y":8,"w":2,"h":4,"i":"15", static: false},
{"x":8,"y":10,"w":2,"h":5,"i":"16", static: false},
{"x":10,"y":4,"w":2,"h":2,"i":"17", static: false},
{"x":0,"y":9,"w":2,"h":3,"i":"18", static: false},
{"x":2,"y":6,"w":2,"h":2,"i":"19", static: false}
];
// var GridLayout = VueGridLayout.GridLayout;
// var GridItem = VueGridLayout.GridItem;
new Vue({
el: '#app',
// components: {
// "GridLayout": GridLayout,
// "GridItem": GridItem
// },
data: {
layout: testLayout,
draggable: true,
resizable: true,
index: 0
},
/*
mounted: function () {
this.index = this.layout.length;
},
*/
methods: {
itemTitle(item) {
var result = item.i;
if (item.static) {
result += " - Static";
}
return result;
}
/*
increaseWidth: function(item) {
var width = document.getElementById("content").offsetWidth;
width += 20;
document.getElementById("content").style.width = width+"px";
},
decreaseWidth: function(item) {
var width = document.getElementById("content").offsetWidth;
width -= 20;
document.getElementById("content").style.width = width+"px";
},
removeItem: function(item) {
//console.log("### REMOVE " + item.i);
this.layout.splice(this.layout.indexOf(item), 1);
},
addItem: function() {
var self = this;
//console.log("### LENGTH: " + this.layout.length);
var item = {"x":0,"y":0,"w":2,"h":2,"i":this.index+"", whatever: "bbb"};
this.index++;
this.layout.push(item);
}
*/
}
});
/*
function generateLayout() {
return _.map(_.range(0, 25), function (item, i) {
var y = Math.ceil(Math.random() * 4) + 1;
return {
x: _.random(0, 5) * 2 % 12,
y: Math.floor(i / 6) * y,
w: 2,
h: y,
i: i.toString(),
static: Math.random() < 0.05
};
});
}*/