Skip to content

Instantly share code, notes, and snippets.

@itskingori
Last active December 18, 2020 17:21
Show Gist options
  • Select an option

  • Save itskingori/2f5d4984fdfe1f1c1646 to your computer and use it in GitHub Desktop.

Select an option

Save itskingori/2f5d4984fdfe1f1c1646 to your computer and use it in GitHub Desktop.

Revisions

  1. King'ori Maina ♛ revised this gist Mar 4, 2015. 1 changed file with 30 additions and 15 deletions.
    45 changes: 30 additions & 15 deletions annotator-example-plugin.js
    Original file line number Diff line number Diff line change
    @@ -1,53 +1,68 @@
    Annotator.Plugin.Voting = function (element, options) {
    var voter = {};
    voter.pluginInit = function () {
    Annotator.Plugin.Example = function (element, options) {
    var myPlugin = {};
    myPlugin.pluginInit = function () {
    // This annotator instance
    this.annotator

    // LOADING
    .subscribe("annotationsLoaded", function (annotations) {
    console.log("annotationsLoaded called when the annotations have been loaded.")
    console.log("annotationsLoaded called when the annotations have been loaded.");
    console.log(annotations);
    })

    // CREATE
    .subscribe("beforeAnnotationCreated", function (annotation) {
    console.log("beforeAnnotationCreated called immediately before an annotation is created. If you need to modify the annotation before it is saved use this event.")
    console.log("beforeAnnotationCreated called immediately before an annotation is created. If you need to modify the annotation before it is saved use this event.");
    console.log(annotation);
    })
    .subscribe("annotationCreated", function (annotation) {
    console.log("annotationCreated called when the annotation is created use this to store the annotations.")
    console.log("annotationCreated called when the annotation is created use this to store the annotations.");
    console.log(annotation);
    })

    // UPDATE
    .subscribe("beforeAnnotationUpdated", function (annotation) {
    console.log("beforeAnnotationUpdated as annotationCreated, but just before an existing annotation is saved.")
    console.log("beforeAnnotationUpdated as annotationCreated, but just before an existing annotation is saved.");
    console.log(annotation);
    })
    .subscribe("annotationUpdated", function (annotation) {
    console.log("annotationUpdated as beforeAnnotationUpdated, but for an existing annotation which has just been edited.")
    console.log("annotationUpdated as beforeAnnotationUpdated, but for an existing annotation which has just been edited.");
    console.log(annotation);
    })

    // DELETE
    .subscribe("annotationDeleted", function (annotation) {
    console.log("annotationDeleted called when the user deletes an annotation.")
    console.log("annotationDeleted called when the user deletes an annotation.");
    console.log(annotation);
    })

    // VIEWER
    .subscribe("annotationViewerShown", function (viewer, annotations) {
    console.log("annotationViewerShown called when the annotation viewer is shown and provides the annotations being displayed.")
    console.log("annotationViewerShown called when the annotation viewer is shown and provides the annotations being displayed.");
    console.log(viewer);
    console.log(annotations);
    })
    .subscribe("annotationViewerTextField", function (field, annotation) {
    console.log("annotationViewerTextField called when the text field displaying the annotation comment in the viewer is created.")
    console.log("annotationViewerTextField called when the text field displaying the annotation comment in the viewer is created.");
    console.log(field);
    console.log(annotation);
    })

    // EDITOR
    .subscribe("annotationEditorShown", function (editor, annotation) {
    console.log("annotationEditorShown called when the annotation editor is presented to the user.")
    console.log("annotationEditorShown called when the annotation editor is presented to the user.");
    console.log(editor);
    console.log(annotation);
    })
    .subscribe("annotationEditorHidden", function (editor) {
    console.log("annotationEditorHidden called when the annotation editor is hidden, both when submitted and when editing is cancelled.")
    console.log("annotationEditorHidden called when the annotation editor is hidden, both when submitted and when editing is cancelled.");
    console.log(editor);
    })
    .subscribe("annotationEditorSubmit", function (editor, annotation) {
    console.log("annotationEditorSubmit called when the annotation editor is submitted.")
    console.log("annotationEditorSubmit called when the annotation editor is submitted.");
    console.log(editor);
    console.log(annotation);
    })
    };
    return voter;
    return myPlugin;
    };
  2. King'ori Maina ♛ revised this gist Mar 4, 2015. 1 changed file with 46 additions and 44 deletions.
    90 changes: 46 additions & 44 deletions annotator-example-plugin.js
    Original file line number Diff line number Diff line change
    @@ -1,51 +1,53 @@
    Annotator.Plugin.Example = function (element, options) {
    var myPlugin = {};
    myPlugin.pluginInit = function () {
    Annotator.Plugin.Voting = function (element, options) {
    var voter = {};
    voter.pluginInit = function () {
    // This annotator instance
    this.annotator
    // LOADING
    // .subscribe("annotationsLoaded", function (annotations) {
    // console.log("annotationsLoaded called when the annotations have been loaded.")
    // })

    // CREATE
    // .subscribe("beforeAnnotationCreated", function (annotation) {
    // console.log("beforeAnnotationCreated called immediately before an annotation is created. If you need to modify the annotation before it is saved use this event.")
    // })
    // .subscribe("annotationCreated", function (annotation) {
    // console.log("annotationCreated called when the annotation is created use this to store the annotations.")
    // })

    // UPDATE
    // .subscribe("beforeAnnotationUpdated", function (annotation) {
    // console.log("beforeAnnotationUpdated as annotationCreated, but just before an existing annotation is saved.")
    // })
    // .subscribe("annotationUpdated", function (annotation) {
    // console.log("annotationUpdated as beforeAnnotationUpdated, but for an existing annotation which has just been edited.")
    // })
    // LOADING
    .subscribe("annotationsLoaded", function (annotations) {
    console.log("annotationsLoaded called when the annotations have been loaded.")
    })

    // DELETE
    // .subscribe("annotationDeleted", function (annotation) {
    // console.log("annotationDeleted called when the user deletes an annotation.")
    // })
    // CREATE
    .subscribe("beforeAnnotationCreated", function (annotation) {
    console.log("beforeAnnotationCreated called immediately before an annotation is created. If you need to modify the annotation before it is saved use this event.")
    })
    .subscribe("annotationCreated", function (annotation) {
    console.log("annotationCreated called when the annotation is created use this to store the annotations.")
    })

    // VIEWER
    // .subscribe("annotationViewerShown", function (viewer, annotations) {
    // console.log("annotationViewerShown called when the annotation viewer is shown and provides the annotations being displayed.")
    // })
    // .subscribe("annotationViewerTextField", function (field, annotation) {
    // console.log("annotationViewerTextField called when the text field displaying the annotation comment in the viewer is created.")
    // })
    // UPDATE
    .subscribe("beforeAnnotationUpdated", function (annotation) {
    console.log("beforeAnnotationUpdated as annotationCreated, but just before an existing annotation is saved.")
    })
    .subscribe("annotationUpdated", function (annotation) {
    console.log("annotationUpdated as beforeAnnotationUpdated, but for an existing annotation which has just been edited.")
    })

    // EDITOR
    // .subscribe("annotationEditorShown", function (editor, annotation) {
    // console.log("annotationEditorShown called when the annotation editor is presented to the user.")
    // })
    // .subscribe("annotationEditorHidden", function (editor) {
    // console.log("annotationEditorHidden called when the annotation editor is hidden, both when submitted and when editing is cancelled.")
    // })
    // .subscribe("annotationEditorSubmit", function (editor, annotation) {
    // console.log("annotationEditorSubmit called when the annotation editor is submitted.")
    // })
    // DELETE
    .subscribe("annotationDeleted", function (annotation) {
    console.log("annotationDeleted called when the user deletes an annotation.")
    })

    // VIEWER
    .subscribe("annotationViewerShown", function (viewer, annotations) {
    console.log("annotationViewerShown called when the annotation viewer is shown and provides the annotations being displayed.")
    })
    .subscribe("annotationViewerTextField", function (field, annotation) {
    console.log("annotationViewerTextField called when the text field displaying the annotation comment in the viewer is created.")
    })

    // EDITOR
    .subscribe("annotationEditorShown", function (editor, annotation) {
    console.log("annotationEditorShown called when the annotation editor is presented to the user.")
    })
    .subscribe("annotationEditorHidden", function (editor) {
    console.log("annotationEditorHidden called when the annotation editor is hidden, both when submitted and when editing is cancelled.")
    })
    .subscribe("annotationEditorSubmit", function (editor, annotation) {
    console.log("annotationEditorSubmit called when the annotation editor is submitted.")
    })
    };
    return myPlugin;
    return voter;
    };
  3. King'ori Maina ♛ revised this gist Mar 4, 2015. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions annotator-example-plugin.js
    Original file line number Diff line number Diff line change
    @@ -2,6 +2,11 @@ Annotator.Plugin.Example = function (element, options) {
    var myPlugin = {};
    myPlugin.pluginInit = function () {
    this.annotator
    // LOADING
    // .subscribe("annotationsLoaded", function (annotations) {
    // console.log("annotationsLoaded called when the annotations have been loaded.")
    // })

    // CREATE
    // .subscribe("beforeAnnotationCreated", function (annotation) {
    // console.log("beforeAnnotationCreated called immediately before an annotation is created. If you need to modify the annotation before it is saved use this event.")
  4. King'ori Maina ♛ renamed this gist Mar 4, 2015. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  5. King'ori Maina ♛ created this gist Mar 4, 2015.
    46 changes: 46 additions & 0 deletions annotator-voting-plugin.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,46 @@
    Annotator.Plugin.Example = function (element, options) {
    var myPlugin = {};
    myPlugin.pluginInit = function () {
    this.annotator
    // CREATE
    // .subscribe("beforeAnnotationCreated", function (annotation) {
    // console.log("beforeAnnotationCreated called immediately before an annotation is created. If you need to modify the annotation before it is saved use this event.")
    // })
    // .subscribe("annotationCreated", function (annotation) {
    // console.log("annotationCreated called when the annotation is created use this to store the annotations.")
    // })

    // UPDATE
    // .subscribe("beforeAnnotationUpdated", function (annotation) {
    // console.log("beforeAnnotationUpdated as annotationCreated, but just before an existing annotation is saved.")
    // })
    // .subscribe("annotationUpdated", function (annotation) {
    // console.log("annotationUpdated as beforeAnnotationUpdated, but for an existing annotation which has just been edited.")
    // })

    // DELETE
    // .subscribe("annotationDeleted", function (annotation) {
    // console.log("annotationDeleted called when the user deletes an annotation.")
    // })

    // VIEWER
    // .subscribe("annotationViewerShown", function (viewer, annotations) {
    // console.log("annotationViewerShown called when the annotation viewer is shown and provides the annotations being displayed.")
    // })
    // .subscribe("annotationViewerTextField", function (field, annotation) {
    // console.log("annotationViewerTextField called when the text field displaying the annotation comment in the viewer is created.")
    // })

    // EDITOR
    // .subscribe("annotationEditorShown", function (editor, annotation) {
    // console.log("annotationEditorShown called when the annotation editor is presented to the user.")
    // })
    // .subscribe("annotationEditorHidden", function (editor) {
    // console.log("annotationEditorHidden called when the annotation editor is hidden, both when submitted and when editing is cancelled.")
    // })
    // .subscribe("annotationEditorSubmit", function (editor, annotation) {
    // console.log("annotationEditorSubmit called when the annotation editor is submitted.")
    // })
    };
    return myPlugin;
    };