Skip to content

Instantly share code, notes, and snippets.

@andrepadez
Last active August 29, 2015 13:56
Show Gist options
  • Save andrepadez/8962889 to your computer and use it in GitHub Desktop.
Save andrepadez/8962889 to your computer and use it in GitHub Desktop.
//READER Directive
var initNotes = function($scope, Note, element, $compile){
Note.find({
user: $scope.global.user._id,
module: $scope.module._id
}).then(function(response) {
$scope.notes = response;
angular.forEach($scope.notes, function(note){
var highlighted = element.find('span.phrase:contains("'+note.selectedText+'")');
var html = '<oowli-note _id="'+note._id+'" content="'+note.content+'"></oowli-note>';
highlighted.after($compile(html)($scope));
});
});
};
//NOTES Directive
angular.module('oowli').directive('oowliNote', function() {
var fnLink = function($scope, element, attrs){
element.on('keydown', '.oowli-note span', noteKeyDown($scope));
element.on('click', '.edit', editClick($scope));
element.on('click', '.remove', removeClick($scope));
};
return {
restrict: 'E',
template: [
'<div class="note oowli-note" data-id="{{id}}">',
'<div class="note-buttons">',
'<a href="#" class="glyphicon glyphicon-pencil edit"></a>',
'<a href="#" class="glyphicon glyphicon-remove remove"></a>',
'</div>',
'<span>{{content}}</span> ',
'</div>'
].join('\n'),
scope: {
id: '=_id',
content: '@content'
},
link: fnLink,
makeEditable: makeEditable
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment