This repository has been archived by the owner on Jun 7, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
table.js
115 lines (87 loc) · 3.04 KB
/
table.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
var app = angular.module("umbraco");
app.directive('ngRightClick', function ($parse) {
return function (scope, element, attrs) {
var fn = $parse(attrs.ngRightClick);
element.bind('contextmenu', function (event) {
scope.$apply(function () {
event.preventDefault();
fn(scope, { $event: event });
});
});
};
});
app.controller("my.grideditorcontroller.table", function ($scope) {
document.getElementById("tablegrid-controller").parentElement.parentElement.parentElement.style.overflow = "visible";
$scope.contextMenu = [];
if ($scope.control.rows === undefined) {
$scope.control.rows = 1;
}
if ($scope.control.colls === undefined) {
$scope.control.colls = 1;
}
if ($scope.control.cells === undefined) {
$scope.control.cells = [];
for (var i = 0; i < 4; i++) {
$scope.control.cells.push('');
$scope.contextMenu.push(false);
}
}
else {
for (var i = $scope.control.cells.length; i--;) {
$scope.contextMenu.push(false);
}
}
$scope.toggleContextmenu = function (cellIndex) {
for (var i = $scope.contextMenu.length; i >= 0; i--) {
if (i === cellIndex) {
$scope.contextMenu[i] = !$scope.contextMenu[i];
}
else {
$scope.contextMenu[i] = false;
}
}
console.log($scope.contextMenu);
};
$scope.removeRow = function (rowIndex) {
};
$scope.addRow = function (location) {
$scope.control.rows += 1;
var newArray = [],
rowCounter = 0;
for (var i = 0; i < $scope.control.cells.length; i++) {
newArray.push($scope.control.cells[i]);
if (i % $scope.control.rows === location - 1 && rowCounter++ === location) {
for (var ci = 0; ci <= $scope.control.colls; ci++) {
newArray.push('');
}
}
}
$scope.control.cells = newArray;
$scope.toggleContextmenu(-1);
};
$scope.removeColl = function (collIndex) {
};
$scope.addColl = function (location) {
$scope.control.colls += 1;
var newArray = [];
for (var i = 0; i < $scope.control.cells.length; i++) {
newArray.push($scope.control.cells[i]);
if (i % $scope.control.colls === location - 1) {
newArray.push('');
}
}
$scope.control.cells = newArray;
$scope.toggleContextmenu(-1);
};
$scope.updateCell = function (that, cellIndex) {
$scope.control.cells[cellIndex].value = that.val;
};
$scope.range = function (min, max, step) {
step = step || 1;
var input = [];
for (var i = min; i <= max; i += step) {
input.push(i);
}
return input;
};
});