-
Notifications
You must be signed in to change notification settings - Fork 3
/
toolbar.js
38 lines (33 loc) · 1.13 KB
/
toolbar.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
angular.module('directives').directive('toolbar', ['editSession', '$log', '$timeout', function(session, $log, $timeout) {
// this directive shares scope with the current active segment area
// the toolbar communicates with the segment area to perform queries and populate new data
return {
restrict: 'E',
templateUrl: 'scripts/directives/toolbar.html',
link: function($scope, el, attrs){
$timeout(function(){
$scope.$watch(
function () {
return session.activeSegment;
},
function(index) {
$log.log('toolbar: ACTIVE SEGMENT CHANGED');
$log.log(index);
var above = $('#segment-' + index);
$(above).after(el);
}
)},0);
// when the directive gets initialized
var index = session.activeSegment;
var above = $('#segment-' + index);
$(above).after(el);
$scope.$on('update-glossary-area', function(evt, data) {
$log.log('toolbar: update-glossary-area');
$log.log(data);
$scope.glossaryMatches = data.map(function(item) {
return item.text;
});
})
}
}
}]);