Last active
August 29, 2015 13:56
-
-
Save andrepadez/8962889 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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