|
| 1 | +var testLayouts = { |
| 2 | + md: [ |
| 3 | + {"x":0, "y":0, "w":2, "h":2, "i":"0"}, |
| 4 | + {"x":2, "y":0, "w":2, "h":4, "i":"1"}, |
| 5 | + {"x":4, "y":0, "w":2, "h":5, "i":"2"}, |
| 6 | + {"x":6, "y":0, "w":2, "h":3, "i":"3"}, |
| 7 | + {"x":2, "y":4, "w":2, "h":3, "i":"4"}, |
| 8 | + {"x":4, "y":5, "w":2, "h":3, "i":"5"}, |
| 9 | + {"x":0, "y":2, "w":2, "h":5, "i":"6"}, |
| 10 | + {"x":2, "y":7, "w":2, "h":5, "i":"7"}, |
| 11 | + {"x":4, "y":8, "w":2, "h":5, "i":"8"}, |
| 12 | + {"x":6, "y":3, "w":2, "h":4, "i":"9"}, |
| 13 | + {"x":0, "y":7, "w":2, "h":4, "i":"10"}, |
| 14 | + {"x":2, "y":19, "w":2, "h":4, "i":"11"}, |
| 15 | + {"x":0, "y":14, "w":2, "h":5, "i":"12"}, |
| 16 | + {"x":2, "y":14, "w":2, "h":5, "i":"13"}, |
| 17 | + {"x":4, "y":13, "w":2, "h":4, "i":"14"}, |
| 18 | + {"x":6, "y":7, "w":2, "h":4, "i":"15"}, |
| 19 | + {"x":0, "y":19, "w":2, "h":5, "i":"16"}, |
| 20 | + {"x":8, "y":0, "w":2, "h":2, "i":"17"}, |
| 21 | + {"x":0, "y":11, "w":2, "h":3, "i":"18"}, |
| 22 | + {"x":2, "y":12, "w":2, "h":2, "i":"19"} |
| 23 | + ], |
| 24 | + lg: [ |
| 25 | + {"x":0,"y":0,"w":2,"h":2,"i":"0"}, |
| 26 | + {"x":2,"y":0,"w":2,"h":4,"i":"1"}, |
| 27 | + {"x":4,"y":0,"w":2,"h":5,"i":"2"}, |
| 28 | + {"x":6,"y":0,"w":2,"h":3,"i":"3"}, |
| 29 | + {"x":8,"y":0,"w":2,"h":3,"i":"4"}, |
| 30 | + {"x":10,"y":0,"w":2,"h":3,"i":"5"}, |
| 31 | + {"x":0,"y":5,"w":2,"h":5,"i":"6"}, |
| 32 | + {"x":2,"y":5,"w":2,"h":5,"i":"7"}, |
| 33 | + {"x":4,"y":5,"w":2,"h":5,"i":"8"}, |
| 34 | + {"x":6,"y":4,"w":2,"h":4,"i":"9"}, |
| 35 | + {"x":8,"y":4,"w":2,"h":4,"i":"10"}, |
| 36 | + {"x":10,"y":4,"w":2,"h":4,"i":"11"}, |
| 37 | + {"x":0,"y":10,"w":2,"h":5,"i":"12"}, |
| 38 | + {"x":2,"y":10,"w":2,"h":5,"i":"13"}, |
| 39 | + {"x":4,"y":8,"w":2,"h":4,"i":"14"}, |
| 40 | + {"x":6,"y":8,"w":2,"h":4,"i":"15"}, |
| 41 | + {"x":8,"y":10,"w":2,"h":5,"i":"16"}, |
| 42 | + {"x":10,"y":4,"w":2,"h":2,"i":"17"}, |
| 43 | + {"x":0,"y":9,"w":2,"h":3,"i":"18"}, |
| 44 | + {"x":2,"y":6,"w":2,"h":2,"i":"19"} |
| 45 | + ], |
| 46 | +}; |
| 47 | + |
| 48 | +// var GridLayout = VueGridLayout.GridLayout; |
| 49 | +// var GridItem = VueGridLayout.GridItem; |
| 50 | + |
| 51 | +new Vue({ |
| 52 | + el: '#app', |
| 53 | + // components: { |
| 54 | + // "GridLayout": GridLayout, |
| 55 | + // "GridItem": GridItem |
| 56 | + // }, |
| 57 | + data: { |
| 58 | + layouts: testLayouts, |
| 59 | + layout: testLayouts["lg"], |
| 60 | + draggable: true, |
| 61 | + resizable: true, |
| 62 | + responsive: true, |
| 63 | + index: 0 |
| 64 | + }, |
| 65 | +/* |
| 66 | + mounted: function () { |
| 67 | + this.index = this.layout.length; |
| 68 | + }, |
| 69 | + methods: { |
| 70 | + increaseWidth: function(item) { |
| 71 | + var width = document.getElementById("content").offsetWidth; |
| 72 | + width += 20; |
| 73 | + document.getElementById("content").style.width = width+"px"; |
| 74 | + }, |
| 75 | + decreaseWidth: function(item) { |
| 76 | +
|
| 77 | + var width = document.getElementById("content").offsetWidth; |
| 78 | + width -= 20; |
| 79 | + document.getElementById("content").style.width = width+"px"; |
| 80 | + }, |
| 81 | + removeItem: function(item) { |
| 82 | + //console.log("### REMOVE " + item.i); |
| 83 | + this.layout.splice(this.layout.indexOf(item), 1); |
| 84 | + }, |
| 85 | + addItem: function() { |
| 86 | + var self = this; |
| 87 | + //console.log("### LENGTH: " + this.layout.length); |
| 88 | + var item = {"x":0,"y":0,"w":2,"h":2,"i":this.index+"", whatever: "bbb"}; |
| 89 | + this.index++; |
| 90 | + this.layout.push(item); |
| 91 | + }, |
| 92 | + breakpointChangedEvent: function(newBreakpoint, newLayout){ |
| 93 | + console.log("BREAKPOINT CHANGED breakpoint=", newBreakpoint, ", layout: ", newLayout ); |
| 94 | + } |
| 95 | + } |
| 96 | +*/ |
| 97 | +}); |
| 98 | + |
| 99 | +/* |
| 100 | +function generateLayout() { |
| 101 | + return _.map(_.range(0, 25), function (item, i) { |
| 102 | + var y = Math.ceil(Math.random() * 4) + 1; |
| 103 | + return { |
| 104 | + x: _.random(0, 5) * 2 % 12, |
| 105 | + y: Math.floor(i / 6) * y, |
| 106 | + w: 2, |
| 107 | + h: y, |
| 108 | + i: i.toString(), |
| 109 | + static: Math.random() < 0.05 |
| 110 | + }; |
| 111 | + }); |
| 112 | +}*/ |
| 113 | + |
| 114 | + |
| 115 | + |
0 commit comments