forked from pankajparkar/gridstack-angular
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgridstack.directive.js
More file actions
58 lines (47 loc) · 1.31 KB
/
Copy pathgridstack.directive.js
File metadata and controls
58 lines (47 loc) · 1.31 KB
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
(function() {
'use strict';
var app = angular.module('gridstack-angular');
app.directive('gridstack', ['$timeout', function($timeout) {
return {
restrict: 'A',
controller: 'GridstackController',
scope: {
onChange: '&',
onDragStart: '&',
onDragStop: '&',
onResizeStart: '&',
onResizeStop: '&',
gridstackHandler: '=?',
options: '='
},
link: function(scope, element, attrs, controller, ngModel) {
var gridstack = controller.init(element, scope.options);
scope.gridstackHandler = gridstack;
element.on('change', function(e, items) {
$timeout(function() {
scope.$apply();
scope.onChange({event: e, items: items});
});
});
element.on('dragstart', function(e, ui) {
scope.onDragStart({event: e, ui: ui});
});
element.on('dragstop', function(e, ui) {
$timeout(function() {
scope.$apply();
scope.onDragStop({event: e, ui: ui});
});
});
element.on('resizestart', function(e, ui) {
scope.onResizeStart({event: e, ui: ui});
});
element.on('resizestop', function(e, ui) {
$timeout(function() {
scope.$apply();
scope.onResizeStop({event: e, ui: ui});
});
});
}
};
}]);
})();