Skip to content

Instantly share code, notes, and snippets.

@krusynth
Created January 9, 2014 19:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save krusynth/8339996 to your computer and use it in GitHub Desktop.
Save krusynth/8339996 to your computer and use it in GitHub Desktop.
Using binding to add parameters to a function
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