06-responsive.js 2.6 KB

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