01-basic.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. var testLayout = [
  2. {"x":0,"y":0,"w":2,"h":2,"i":"0", static: false},
  3. {"x":2,"y":0,"w":2,"h":4,"i":"1", static: true},
  4. {"x":4,"y":0,"w":2,"h":5,"i":"2", static: false},
  5. {"x":6,"y":0,"w":2,"h":3,"i":"3", static: false},
  6. {"x":8,"y":0,"w":2,"h":3,"i":"4", static: false},
  7. {"x":10,"y":0,"w":2,"h":3,"i":"5", static: false},
  8. {"x":0,"y":5,"w":2,"h":5,"i":"6", static: false},
  9. {"x":2,"y":5,"w":2,"h":5,"i":"7", static: false},
  10. {"x":4,"y":5,"w":2,"h":5,"i":"8", static: false},
  11. {"x":6,"y":3,"w":2,"h":4,"i":"9", static: true},
  12. {"x":8,"y":4,"w":2,"h":4,"i":"10", static: false},
  13. {"x":10,"y":4,"w":2,"h":4,"i":"11", static: false},
  14. {"x":0,"y":10,"w":2,"h":5,"i":"12", static: false},
  15. {"x":2,"y":10,"w":2,"h":5,"i":"13", static: false},
  16. {"x":4,"y":8,"w":2,"h":4,"i":"14", static: false},
  17. {"x":6,"y":8,"w":2,"h":4,"i":"15", static: false},
  18. {"x":8,"y":10,"w":2,"h":5,"i":"16", static: false},
  19. {"x":10,"y":4,"w":2,"h":2,"i":"17", static: false},
  20. {"x":0,"y":9,"w":2,"h":3,"i":"18", static: false},
  21. {"x":2,"y":6,"w":2,"h":2,"i":"19", static: false}
  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. index: 0
  36. },
  37. /*
  38. mounted: function () {
  39. this.index = this.layout.length;
  40. },
  41. */
  42. methods: {
  43. itemTitle(item) {
  44. var result = item.i;
  45. if (item.static) {
  46. result += " - Static";
  47. }
  48. return result;
  49. }
  50. /*
  51. increaseWidth: function(item) {
  52. var width = document.getElementById("content").offsetWidth;
  53. width += 20;
  54. document.getElementById("content").style.width = width+"px";
  55. },
  56. decreaseWidth: function(item) {
  57. var width = document.getElementById("content").offsetWidth;
  58. width -= 20;
  59. document.getElementById("content").style.width = width+"px";
  60. },
  61. removeItem: function(item) {
  62. //console.log("### REMOVE " + item.i);
  63. this.layout.splice(this.layout.indexOf(item), 1);
  64. },
  65. addItem: function() {
  66. var self = this;
  67. //console.log("### LENGTH: " + this.layout.length);
  68. var item = {"x":0,"y":0,"w":2,"h":2,"i":this.index+"", whatever: "bbb"};
  69. this.index++;
  70. this.layout.push(item);
  71. }
  72. */
  73. }
  74. });
  75. /*
  76. function generateLayout() {
  77. return _.map(_.range(0, 25), function (item, i) {
  78. var y = Math.ceil(Math.random() * 4) + 1;
  79. return {
  80. x: _.random(0, 5) * 2 % 12,
  81. y: Math.floor(i / 6) * y,
  82. w: 2,
  83. h: y,
  84. i: i.toString(),
  85. static: Math.random() < 0.05
  86. };
  87. });
  88. }*/