Created
January 9, 2014 19:06
-
-
Save krusynth/8339996 to your computer and use it in GitHub Desktop.
Using binding to add parameters to a function
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
Annotator.Plugin.Madison = function(element, options){ | |
this.options = options; | |
} | |
$.extend(Annotator.Plugin.Madison.prototype, new Annotator.Plugin(), { | |
events: {}, | |
options: {}, | |
pluginInit: function(){ | |
this.annotator.viewer.addField({ | |
load: load_fn.bind(this, user) | |
}) | |
} | |
}); | |
var load_fn = function(user, field, annotation){ | |
//Add link to annotation in Madison | |
noteLink = $('<div class="annotation-link"></div>'); | |
annotationLink = $('<a></a>').attr('href', window.location.origin + '/note/' + annotation.id).text('View Note'); | |
noteLink.append(annotationLink); | |
$(field).append(noteLink); | |
current_user_id = user.id; | |
if(typeof current_user_id != 'undefined'){ | |
//Add actions to annotation | |
annotationAction = $('<div></div>').addClass('annotation-action'); | |
generalAction = $('<span></span>').addClass('glyphicon').data('annotation-id', annotation.id); | |
annotationLike = generalAction.clone().addClass('glyphicon-thumbs-up'); | |
annotationDislike = generalAction.clone().addClass('glyphicon-thumbs-down'); | |
annotationFlag = generalAction.clone().addClass('glyphicon-flag'); | |
annotationAction.append(annotationLike, annotationDislike, annotationFlag); | |
$(field).append(annotationAction); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment