Commit 98446d1c by lduarte1991

Annotation Tools: Code clean-up, formatting, spacing

parent 9751244e
/* Editor */ /* Editor */
.share-container-annotator{ .share-container-annotator {
display: block; display: block;
min-width: 100%; min-width: 100%;
border: none; border: none;
...@@ -16,16 +16,16 @@ ...@@ -16,16 +16,16 @@
height: 3.1em; height: 3.1em;
} }
.share-container-annotator .share-text-annotator{ .share-container-annotator .share-text-annotator {
float:left; float:left;
padding-top: 1em; padding-top: 1em;
} }
.annotator-editor .share-container-annotator .share-text-annotator{ .annotator-editor .share-container-annotator .share-text-annotator {
height: 2.1em; height: 2.1em;
} }
.share-container-annotator .share-button, .annotator-wrapper .share-button{ .share-container-annotator .share-button, .annotator-wrapper .share-button {
top: 0.3em; top: 0.3em;
outline: 0; outline: 0;
float:left; float:left;
...@@ -40,14 +40,14 @@ ...@@ -40,14 +40,14 @@
background-size: 2.5em; background-size: 2.5em;
} }
.share-container-annotator .share-button:hover, .annotator-wrapper .share-button:hover{ .share-container-annotator .share-button:hover, .annotator-wrapper .share-button:hover {
opacity: .6; opacity: .6;
cursor: pointer; cursor: pointer;
} }
/* Popup */ /* Popup */
.annotator-wrapper .share-popup-overlay-bg{ .annotator-wrapper .share-popup-overlay-bg {
display: none; display: none;
position: fixed; position: fixed;
top: 0; top: 0;
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
background: rgba(0,0,0,0.75); background: rgba(0,0,0,0.75);
padding: 0; padding: 0;
} }
.annotator-wrapper .share-popup-overlay-bg .share-popup{ .annotator-wrapper .share-popup-overlay-bg .share-popup {
background: #fff; background: #fff;
padding: 1% !important; padding: 1% !important;
width: 30%; width: 30%;
...@@ -72,7 +72,7 @@ ...@@ -72,7 +72,7 @@
box-shadow: 0 0 5px rgba(0,0,0,0.9); box-shadow: 0 0 5px rgba(0,0,0,0.9);
} }
.annotator-wrapper .share-popup-overlay-bg .share-popup-copy, .annotator-wrapper .share-popup-overlay-bg .share-popup-copy,
.annotator-wrapper .share-popup-overlay-bg .share-popup-title{ .annotator-wrapper .share-popup-overlay-bg .share-popup-title {
font-style: normal; font-style: normal;
font-weight: bold; font-weight: bold;
font-size: 21px; font-size: 21px;
...@@ -80,20 +80,20 @@ ...@@ -80,20 +80,20 @@
padding-bottom: 20px; padding-bottom: 20px;
color: #222; color: #222;
} }
.annotator-wrapper .share-popup-overlay-bg .share-popup-uri{ .annotator-wrapper .share-popup-overlay-bg .share-popup-uri {
width:100%; width:100%;
border: 1px solid rgb(144, 144, 144); border: 1px solid rgb(144, 144, 144);
height: 24px; height: 24px;
margin-bottom: 10px; margin-bottom: 10px;
} }
.annotator-wrapper .share-popup-overlay-bg .share-popup-copy{ .annotator-wrapper .share-popup-overlay-bg .share-popup-copy {
font-size: 15px; font-size: 15px;
float: left; float: left;
width: 100%; width: 100%;
padding:0; padding:0;
margin: 1.0em 0em 0.5em 0em !important; margin: 1.0em 0em 0.5em 0em !important;
} }
.annotator-wrapper .share-popup-overlay-bg .share-popup .share-button{ .annotator-wrapper .share-popup-overlay-bg .share-popup .share-button {
width: 50%; width: 50%;
padding: 0; padding: 0;
-webkit-box-sizing: border-box; -webkit-box-sizing: border-box;
...@@ -163,7 +163,7 @@ ...@@ -163,7 +163,7 @@
.annotator-viewer .share-viewer-annotator div.share-text-annotator, .annotator-viewer .share-viewer-annotator div.share-text-annotator,
.annotator-viewer .share-viewer-annotator div.share-button, .annotator-viewer .share-viewer-annotator div.share-button,
.annotator-wrapper div.share-button, .annotator-wrapper div.share-button,
.annotator-wrapper div.share-text-annotator{ .annotator-wrapper div.share-text-annotator {
border-top: 0; border-top: 0;
padding: 0; padding: 0;
background-size: 2em; background-size: 2em;
...@@ -185,12 +185,12 @@ ...@@ -185,12 +185,12 @@
} }
.share-container-annotator .share-google-annotator, .annotator-wrapper .share-google-annotator{ .share-container-annotator .share-google-annotator, .annotator-wrapper .share-google-annotator {
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAABmJLR0QA/wD/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AWquWcgbaZaLNdedaIsLnHOU5s3jF488wt4X93PRRRfx2127uO22W7lqw3o2b97M6dNfEASWu++5h741fTifmc5Xj6b71MJetnoXp9mcKhV4kAustUu6Fiz4HsZks4zJdTIiwpM7d7Lx2xt54P77eWHPHmZmZigVi3R2djI2NsYbBw/S37+eRYsuZGzsLIfee6+5Cc1VilZKaW2KnXOnJiYnX7atRN1KMapKtVrlpptvZt26fl77y2t8+OERSqUShgZdJM5hjGF0dJQdj20nDAt0dXU1U4m/T3LWzHspX0GkXQySxqCnCONcVmdr9Tpr+vqI45gkSXDONapAztqpkh9//DGqyokTx3FJ0tShz9X3Scu7tlmsuRjUFm4yxvCvw4ep1Wps2DDABd0XEMexH3BcZoFKHDMwcBUjIyO89eabmfXSmJPc2jz9tLo39WT7maSl2IsIYRjyh927+eijj6jX6zy1axfr+vspFAqEYYi1lqhQ4NLLLuNHDz7I9m3bOHHiRLMCaZLkQLpcAmaVJ0fSqVdCYFkQBFcu6el5SVUx6YjpKSftijs6Orh10+30r+vnm70rOTs2xsjICFNTU0xNTjE+fpYDB/7M558NEUXFpjmn7RSXb2bzVNNQ4NDJ4eEtswCKL2nGx1d270th2nYZYymV5iG+UQBwviFtd3Ki7UDmO+r8mNEAeejk8PCWsN0BEKqotdkJkslNcelAZIyhVqs2Wbjd7Puls3BuBsmefbvXOtWpc66ayTD+cCaXQKblyNVo7tzGrzW+uWidsZuUz2d0m7+5mTsBNPTrHTAuqiPAItPcQWSdjvElsOnYtY07TZsBPA+u9d7kvJACrdfrhwAN0uM3YL6InC1G0Xpoc/jZEgKznluG/Vnv53D/LOWMwYkcHT1z5llV/Tw9NJ8PLAZ6wyDoK5fLA9baC77mQ3Q1IHG1eqwSx++KyIfAf1IARWCBB7kM6AbKQOFrOu1P60QVGAdGgM+A0yZXUQpApwfW6UEHc4XU//ln/MSRADEwBUwC8X8BTYvqIryh+pIAAAAASUVORK5CYII='); background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgA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otator .share-email-annotator, .annotator-wrapper .share-email-annotator{ .share-container-annotator .share-email-annotator, .annotator-wrapper .share-email-annotator {
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAABIUExURf///7KysrKyss/Pz9DQ0NHR0dLS0u7u7vDw8PHx8fLy8vPz8/T09PX19fb29vf39/j4+Pn5+fr6+vv7+/z8/P39/f7+/v///37mbPQAAAACdFJOUwCWb//7SQAAAQNJREFUSMft1M2SgyAQRtHkC0RtbP6V93/TWZikFDuQ2c7krrCKU1gKXC7f/lNX9LvuAVB6AUdw78y/V2CEXltpjEcwmabQMNMR0GwbQsPOVAF2AXqR0wiOK2DYh/RGaKTg2VTA+pgXUWgsOXorghUq1ymsDVBOQqE0QYFK+xRKBxyFQumCvVAoH4ACFbe2+f0VnkKhfLICnmsoPJ46X2l7q1u4PUYdgNdxeY2aQDp4b/40+5AyxM2NLGw+YhcisrhbM+J5e9NsPWLKUinCnw7QZBg+hCgVggfXR3QksHVezlkGVZfAADIzs5Ving1hqO6lYZyIjBzRNA7He+nXV+W3v98P7gg+L5LCf08AAAAASUVORK5CYII='); background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAABIUExURf///7KysrKyss/Pz9DQ0NHR0dLS0u7u7vDw8PHx8fLy8vPz8/T09PX19fb29vf39/j4+Pn5+fr6+vv7+/z8/P39/f7+/v///37mbPQAAAACdFJOUwCWb//7SQAAAQNJREFUSMft1M2SgyAQRtHkC0RtbP6V93/TWZikFDuQ2c7krrCKU1gKXC7f/lNX9LvuAVB6AUdw78y/V2CEXltpjEcwmabQMNMR0GwbQsPOVAF2AXqR0wiOK2DYh/RGaKTg2VTA+pgXUWgsOXorghUq1ymsDVBOQqE0QYFK+xRKBxyFQumCvVAoH4ACFbe2+f0VnkKhfLICnmsoPJ46X2l7q1u4PUYdgNdxeY2aQDp4b/40+5AyxM2NLGw+YhcisrhbM+J5e9NsPWLKUinCnw7QZBg+hCgVggfXR3QksHVezlkGVZfAADIzs5Ving1hqO6lYZyIjBzRNA7He+nXV+W3v98P7gg+L5LCf08AAAAASUVORK5CYII=');
} }
......
...@@ -44,18 +44,18 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ...@@ -44,18 +44,18 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
.subscribe("annotationsLoaded", function (annotations){ .subscribe("annotationsLoaded", function (annotations){
if (!self.annotationInstance) { if (!self.annotationInstance) {
//annotation instance should include the OSD item and annotator // annotation instance should include the OSD item and annotator
self.annotationInstance = new $._annotation({ self.annotationInstance = new $._annotation({
viewer: self, viewer: self,
annotator: annotator, annotator: annotator,
}); });
//this collection of items is included as an item of annotator so // this collection of items is included as an item of annotator so
//that there is a method to communicate back and forth. // that there is a method to communicate back and forth.
annotator.osda = self.annotationInstance; annotator.osda = self.annotationInstance;
//Because it takes a while for both OSD to open and for annotator // Because it takes a while for both OSD to open and for annotator
//to get items from the backend, we wait until we get the "open" call // to get items from the backend, we wait until we get the "open" call
function refreshDisplay(){ function refreshDisplay(){
if(!isOpenViewer){ if(!isOpenViewer){
setTimeout(refreshDisplay,200); setTimeout(refreshDisplay,200);
...@@ -75,21 +75,21 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ...@@ -75,21 +75,21 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* @constructor * @constructor
*/ */
$._annotation = function(options) { $._annotation = function(options) {
//options // options
options = options || {}; options = options || {};
if (!options.viewer) { if (!options.viewer) {
throw new Error("A viewer must be specified."); throw new Error("A viewer must be specified.");
} }
//variables // variables
this.viewer = options.viewer; this.viewer = options.viewer;
this.annotator = options.annotator; this.annotator = options.annotator;
this.options = options; this.options = options;
this.isAnnotating = false; //If the user is annotating this.isAnnotating = false; // If the user is annotating
this.isDrawing = false; //if the user is drawing something this.isDrawing = false; // if the user is drawing something
this.rectPosition = undefined; this.rectPosition = undefined;
//Init // Init
this.init(); this.init();
}; };
...@@ -102,21 +102,21 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ...@@ -102,21 +102,21 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
init: function(){ init: function(){
var viewer = this.viewer; var viewer = this.viewer;
//create Buttons // create Buttons
this._createNewButton(); this._createNewButton();
/* canvas Events */ /* canvas Events */
//- Bind canvas functions // Bind canvas functions
var onCanvasMouseDown = this.__bind(this._onCanvasMouseDown,this); var onCanvasMouseDown = this.__bind(this._onCanvasMouseDown,this);
var onCanvasMouseMove = this.__bind(this._onCanvasMouseMove,this); var onCanvasMouseMove = this.__bind(this._onCanvasMouseMove,this);
var onDocumentMouseUp = this.__bind(this._onDocumentMouseUp,this); var onDocumentMouseUp = this.__bind(this._onDocumentMouseUp,this);
//- Add canvas events // Add canvas events
$.addEvent(viewer.canvas, "mousedown", onCanvasMouseDown, true); $.addEvent(viewer.canvas, "mousedown", onCanvasMouseDown, true);
$.addEvent(viewer.canvas, "mousemove", onCanvasMouseMove, true); $.addEvent(viewer.canvas, "mousemove", onCanvasMouseMove, true);
$.addEvent(document, "mouseup", onDocumentMouseUp, true); $.addEvent(document, "mouseup", onDocumentMouseUp, true);
//Viewer events // Viewer events
var self = this; var self = this;
}, },
...@@ -128,17 +128,17 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ...@@ -128,17 +128,17 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
newAnnotation:function(){ newAnnotation:function(){
var annotator = this.annotator; var annotator = this.annotator;
//This variable tells editor that we want create an image annotation // This variable tells editor that we want create an image annotation
annotator.editor.OpenSeaDragon = this.viewer.id; annotator.editor.OpenSeaDragon = this.viewer.id;
//allows the adder to actually show up // allows the adder to actually show up
annotator.adder.show(); annotator.adder.show();
//takes into account the various wrappers and instances to put the shape // takes into account the various wrappers and instances to put the shape
//over the correct place. // over the correct place.
this._setOverShape(annotator.adder); this._setOverShape(annotator.adder);
//Open a new annotator dialog // Open a new annotator dialog
annotator.onAdderClick(); annotator.onAdderClick();
}, },
...@@ -148,16 +148,16 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ...@@ -148,16 +148,16 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* @param {TinyMCEEditor} editor The item that pops up when you edit an annotation. * @param {TinyMCEEditor} editor The item that pops up when you edit an annotation.
*/ */
editAnnotation: function(annotation,editor){ editAnnotation: function(annotation,editor){
//Stupid check: is the annotation you're trying to edit an image? // Stupid check: is the annotation you're trying to edit an image?
if (this._isOpenSeaDragon(annotation)){ if (this._isOpenSeaDragon(annotation)){
var editor = editor || this.annotator.editor; var editor = editor || this.annotator.editor;
//set the editor over the highlighted element // set the editor over the highlighted element
this._setOverShape(editor.element); this._setOverShape(editor.element);
editor.checkOrientation(); editor.checkOrientation();
//makes sure that we are making an image annotation // makes sure that we are making an image annotation
editor.OpenSeaDragon = this.viewer.id; editor.OpenSeaDragon = this.viewer.id;
} }
}, },
...@@ -171,22 +171,22 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ...@@ -171,22 +171,22 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
var allannotations = this.annotator.plugins['Store'].annotations; var allannotations = this.annotator.plugins['Store'].annotations;
var annotator = this.annotator; var annotator = this.annotator;
//Sort the annotations by date // Sort the annotations by date
this._sortByDate(allannotations); this._sortByDate(allannotations);
//remove all of the overlays // remove all of the overlays
this.viewer.drawer.clearOverlays(); this.viewer.drawer.clearOverlays();
for (var item in allannotations) { for (var item in allannotations) {
var an = allannotations[item]; var an = allannotations[item];
//check if the annotation is an OpenSeaDragon annotation // check if the annotation is an OpenSeaDragon annotation
if (this._isOpenSeaDragon(an)){ if (this._isOpenSeaDragon(an)){
this.drawRect(an); this.drawRect(an);
} }
} }
//if the colored highlights by tags plugin it is notified to colorize // if the colored highlights by tags plugin it is notified to colorize
annotator.publish('colorizeHighlight', [an]); annotator.publish('colorizeHighlight', [an]);
}, },
...@@ -199,15 +199,15 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ...@@ -199,15 +199,15 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
this._reset(); this._reset();
var viewer = this.viewer; var viewer = this.viewer;
if (!this.isAnnotating){ if (!this.isAnnotating){
//When annotating, the cursor turns into a crosshair and there is a // When annotating, the cursor turns into a crosshair and there is a
//green border around the OSD instance. // green border around the OSD instance.
jQuery('.openseadragon1').css('cursor', 'crosshair'); jQuery('.openseadragon1').css('cursor', 'crosshair');
jQuery('.openseadragon1').css('border', '2px solid rgb(51,204,102)'); jQuery('.openseadragon1').css('border', '2px solid rgb(51,204,102)');
e.eventSource.imgGroup.src = this.resolveUrl( viewer.prefixUrl,"newan_hover.png"); e.eventSource.imgGroup.src = this.resolveUrl( viewer.prefixUrl,"newan_hover.png");
e.eventSource.imgRest.src = this.resolveUrl( viewer.prefixUrl,"newan_hover.png"); e.eventSource.imgRest.src = this.resolveUrl( viewer.prefixUrl,"newan_hover.png");
e.eventSource.imgHover.src = this.resolveUrl( viewer.prefixUrl,"newan_grouphover.png"); e.eventSource.imgHover.src = this.resolveUrl( viewer.prefixUrl,"newan_grouphover.png");
}else{ }else{
//Otherwise, the cursor is a cross with four arrows to indicate movement // Otherwise, the cursor is a cross with four arrows to indicate movement
jQuery('.openseadragon1').css('cursor', 'all-scroll'); jQuery('.openseadragon1').css('cursor', 'all-scroll');
jQuery('.openseadragon1').css('border', 'inherit'); jQuery('.openseadragon1').css('border', 'inherit');
e.eventSource.imgGroup.src = this.resolveUrl( viewer.prefixUrl,"newan_grouphover.png"); e.eventSource.imgGroup.src = this.resolveUrl( viewer.prefixUrl,"newan_grouphover.png");
...@@ -215,7 +215,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ...@@ -215,7 +215,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
e.eventSource.imgHover.src = this.resolveUrl( viewer.prefixUrl,"newan_hover.png"); e.eventSource.imgHover.src = this.resolveUrl( viewer.prefixUrl,"newan_hover.png");
} }
//toggles the annotating flag // toggles the annotating flag
this.isAnnotating = !this.isAnnotating?true:false; this.isAnnotating = !this.isAnnotating?true:false;
}, },
...@@ -225,28 +225,28 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ...@@ -225,28 +225,28 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* @param {Object} an Annotation item from the list in the Annotator instance. * @param {Object} an Annotation item from the list in the Annotator instance.
*/ */
drawRect:function(an){ drawRect:function(an){
//Stupid check: Does this annotation actually have an area of annotation // Stupid check: Does this annotation actually have an area of annotation
if (typeof an.rangePosition!='undefined'){ if (typeof an.rangePosition!='undefined'){
//Sets up the visual aspects of the area for the user // Sets up the visual aspects of the area for the user
var span = document.createElement('span'); var span = document.createElement('span');
var rectPosition = an.rangePosition; var rectPosition = an.rangePosition;
span.className = "annotator-hl"; span.className = "annotator-hl";
span.style.border = '2px solid rgba(0,0,0,0.5)'; span.style.border = '2px solid rgba(0,0,0,0.5)';
span.style.background = 'rgba(0,0,0,0)'; span.style.background = 'rgba(0,0,0,0)';
//Adds listening items for the viewer and editor // Adds listening items for the viewer and editor
var onAnnotationMouseMove = this.__bind(this._onAnnotationMouseMove,this); var onAnnotationMouseMove = this.__bind(this._onAnnotationMouseMove,this);
var onAnnotationClick = this.__bind(this._onAnnotationClick,this); var onAnnotationClick = this.__bind(this._onAnnotationClick,this);
$.addEvent(span, "mousemove", onAnnotationMouseMove, true); $.addEvent(span, "mousemove", onAnnotationMouseMove, true);
$.addEvent(span, "click", onAnnotationClick, true); $.addEvent(span, "click", onAnnotationClick, true);
//Set the object in the div // Set the object in the div
jQuery.data(span, 'annotation', an); jQuery.data(span, 'annotation', an);
//Add the highlights to the annotation // Add the highlights to the annotation
an.highlights = jQuery(span); an.highlights = jQuery(span);
//Sends the element created to the proper location within the OSD instance // Sends the element created to the proper location within the OSD instance
var olRect = new OpenSeadragon.Rect(rectPosition.left, rectPosition.top, rectPosition.width, rectPosition.height); var olRect = new OpenSeadragon.Rect(rectPosition.left, rectPosition.top, rectPosition.width, rectPosition.height);
return this.viewer.drawer.addOverlay({ return this.viewer.drawer.addOverlay({
element: span, element: span,
...@@ -262,19 +262,19 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ...@@ -262,19 +262,19 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* screen coordinates and OSD image coordinates. * screen coordinates and OSD image coordinates.
*/ */
setRectPosition:function(){ setRectPosition:function(){
//Get the actual locations of the rectangle // Get the actual locations of the rectangle
var left = parseInt(this.rect.style.left); var left = parseInt(this.rect.style.left);
var top = parseInt(this.rect.style.top); var top = parseInt(this.rect.style.top);
var width = parseInt(this.rect.style.left)+parseInt(this.rect.style.width); var width = parseInt(this.rect.style.left) + parseInt(this.rect.style.width);
var height = parseInt(this.rect.style.top)+parseInt(this.rect.style.height); var height = parseInt(this.rect.style.top) + parseInt(this.rect.style.height);
var startPoint = new $.Point(left,top); var startPoint = new $.Point(left,top);
var endPoint = new $.Point(width,height); var endPoint = new $.Point(width,height);
//return the proper value of the rectangle // return the proper value of the rectangle
this.rectPosition = {left:this._physicalToLogicalXY(startPoint).x, this.rectPosition = {left:this._physicalToLogicalXY(startPoint).x,
top:this._physicalToLogicalXY(startPoint).y, top:this._physicalToLogicalXY(startPoint).y,
width:this._physicalToLogicalXY(endPoint).x-this._physicalToLogicalXY(startPoint).x, width:this._physicalToLogicalXY(endPoint).x - this._physicalToLogicalXY(startPoint).x,
height:this._physicalToLogicalXY(endPoint).y-this._physicalToLogicalXY(startPoint).y height:this._physicalToLogicalXY(endPoint).y - this._physicalToLogicalXY(startPoint).y
}; };
}, },
...@@ -287,18 +287,18 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ...@@ -287,18 +287,18 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/ */
_onCanvasMouseDown: function(event) { _onCanvasMouseDown: function(event) {
//action is ONLY performed if we are in annotation creation mode // action is ONLY performed if we are in annotation creation mode
if (this.isAnnotating){ if (this.isAnnotating){
var viewer = this.viewer; var viewer = this.viewer;
event.preventDefault(); event.preventDefault();
//reset the display // reset the display
this._reset(); this._reset();
//set mode drawing // set mode drawing
this.isDrawing = true; this.isDrawing = true;
//Create rect element // Create rect element
var mouse = $.getMousePosition( event ); var mouse = $.getMousePosition( event );
var elementPosition = $.getElementPosition(viewer.canvas); var elementPosition = $.getElementPosition(viewer.canvas);
var position = mouse.minus( elementPosition ); var position = mouse.minus( elementPosition );
...@@ -308,18 +308,18 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ...@@ -308,18 +308,18 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
this.rect.style.border = '2px solid rgba(0,0,0,0.5)'; this.rect.style.border = '2px solid rgba(0,0,0,0.5)';
this.rect.style.position = 'absolute'; this.rect.style.position = 'absolute';
this.rect.className = 'DrawingRect'; this.rect.className = 'DrawingRect';
//set the initial position // set the initial position
this.rect.style.top = position.y+"px"; this.rect.style.top = position.y + "px";
this.rect.style.left = position.x+"px"; this.rect.style.left = position.x + "px";
this.rect.style.width = "1px"; this.rect.style.width = "1px";
this.rect.style.height = "1px"; this.rect.style.height = "1px";
//save the start Position // save the start Position
this.startPosition = position; this.startPosition = position;
//save rectPosition as initial rectangle parameter to Draw in the canvas // save rectPosition as initial rectangle parameter to Draw in the canvas
this.setRectPosition(); this.setRectPosition();
//append Child to the canvas // append Child to the canvas
viewer.canvas.appendChild(this.rect); viewer.canvas.appendChild(this.rect);
} }
}, },
...@@ -330,31 +330,31 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ...@@ -330,31 +330,31 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/ */
_onCanvasMouseMove: function(event) { _onCanvasMouseMove: function(event) {
//of course, this only runs when we are in annotation creation mode and // of course, this only runs when we are in annotation creation mode and
//when the user has clicked down (and is therefore drawing the rectangle) // when the user has clicked down (and is therefore drawing the rectangle)
if (this.isAnnotating && this.isDrawing){ if (this.isAnnotating && this.isDrawing){
var viewer = this.viewer; var viewer = this.viewer;
//Calculate the new end position // Calculate the new end position
var mouse = $.getMousePosition( event ); var mouse = $.getMousePosition( event );
var elementPosition = $.getElementPosition(viewer.canvas); var elementPosition = $.getElementPosition(viewer.canvas);
var endPosition = mouse.minus( elementPosition ); var endPosition = mouse.minus( elementPosition );
//retrieve start position // retrieve start position
var startPosition = this.startPosition; var startPosition = this.startPosition;
var newWidth= endPosition.x-startPosition.x; var newWidth= endPosition.x-startPosition.x;
var newHeight =endPosition.y-startPosition.y; var newHeight =endPosition.y-startPosition.y;
//Set new position // Set new position
this.rect.style.width = (newWidth<0) ? (-1*newWidth) +'px' : newWidth +'px'; this.rect.style.width = (newWidth < 0) ? (-1*newWidth) + 'px' : newWidth + 'px';
this.rect.style.left = (newWidth<0) ? (startPosition.x + newWidth) +'px' : startPosition.x +'px'; this.rect.style.left = (newWidth < 0) ? (startPosition.x + newWidth) + 'px' : startPosition.x + 'px';
this.rect.style.height = (newHeight<0) ? (-1*newHeight) +'px' : newHeight +'px'; this.rect.style.height = (newHeight < 0) ? (-1*newHeight) + 'px' : newHeight + 'px';
this.rect.style.top = (newHeight<0) ? (startPosition.y + newHeight) +'px' : startPosition.y +'px'; this.rect.style.top = (newHeight < 0) ? (startPosition.y + newHeight) + 'px' : startPosition.y + 'px';
//Modify the rectPosition with the new this.rect values // Modify the rectPosition with the new this.rect values
this.setRectPosition(); this.setRectPosition();
//Show adder and hide editor // Show adder and hide editor
this.annotator.editor.element[0].style.display = 'none'; this.annotator.editor.element[0].style.display = 'none';
this._setOverShape(this.annotator.adder); this._setOverShape(this.annotator.adder);
} }
...@@ -366,21 +366,21 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ...@@ -366,21 +366,21 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/ */
_onDocumentMouseUp: function() { _onDocumentMouseUp: function() {
//Stupid check: only do it when in annotation creation mode and // Stupid check: only do it when in annotation creation mode and
//when the user has begun making a rectangle over the annotation area // when the user has begun making a rectangle over the annotation area
if (this.isAnnotating && this.isDrawing){ if (this.isAnnotating && this.isDrawing){
var viewer = this.viewer; var viewer = this.viewer;
viewer.innerTracker.setTracking(true); viewer.innerTracker.setTracking(true);
this.isDrawing = false; this.isDrawing = false;
//Set the new position for the rectangle // Set the new position for the rectangle
this.setRectPosition(); this.setRectPosition();
//Open Annotator editor // Open Annotator editor
this.newAnnotation(); this.newAnnotation();
//Hide adder and show editor // Hide adder and show editor
this.annotator.editor.element[0].style.display = 'block'; this.annotator.editor.element[0].style.display = 'block';
this._setOverShape(this.annotator.editor.element); this._setOverShape(this.annotator.editor.element);
this.annotator.editor.checkOrientation(); this.annotator.editor.checkOrientation();
...@@ -396,11 +396,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ...@@ -396,11 +396,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
var annotator = this.annotator; var annotator = this.annotator;
var elem = jQuery(event.target).parents('.annotator-hl').andSelf(); var elem = jQuery(event.target).parents('.annotator-hl').andSelf();
//if there is a opened annotation then show the new annotation mouse over // if there is a opened annotation then show the new annotation mouse over
if (typeof annotator!='undefined' && elem.hasClass("annotator-hl") && !this.isDrawing){ if (typeof annotator!='undefined' && elem.hasClass("annotator-hl") && !this.isDrawing){
//hide the last open viewer // hide the last open viewer
annotator.viewer.hide(); annotator.viewer.hide();
//get the annotation over the mouse // get the annotation over the mouse
var annotations = jQuery(event.target.parentNode).find('.annotator-hl').map(function() { var annotations = jQuery(event.target.parentNode).find('.annotator-hl').map(function() {
var self = jQuery(this); var self = jQuery(this);
var offset = self.offset(); var offset = self.offset();
...@@ -414,21 +414,21 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ...@@ -414,21 +414,21 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
var maxx = l + w; var maxx = l + w;
var maxy = t + h; var maxy = t + h;
//if the current position of the mouse is within the bounds of an area // if the current position of the mouse is within the bounds of an area
//change the background of that area to a light yellow to simulate // change the background of that area to a light yellow to simulate
//a hover. Otherwise, keep it translucent. // a hover. Otherwise, keep it translucent.
this.style.background = (y <= maxy && y >= t) && (x <= maxx && x >= l)? this.style.background = (y <= maxy && y >= t) && (x <= maxx && x >= l)?
'rgba(255, 255, 10, 0.05)':'rgba(0, 0, 0, 0)'; 'rgba(255, 255, 10, 0.05)':'rgba(0, 0, 0, 0)';
return (y <= maxy && y >= t) && (x <= maxx && x >= l)? jQuery(this).data("annotation") : null; return (y <= maxy && y >= t) && (x <= maxx && x >= l)? jQuery(this).data("annotation") : null;
}); });
//show the annotation in the viewer // show the annotation in the viewer
var mousePosition = { var mousePosition = {
top:$.getMousePosition(event).y, top:$.getMousePosition(event).y,
left:$.getMousePosition(event).x, left:$.getMousePosition(event).x,
}; };
//if the user is hovering over multiple annotation areas, // if the user is hovering over multiple annotation areas,
//they will be stacked as usual // they will be stacked as usual
if (annotations.length>0) annotator.showViewer(jQuery.makeArray(annotations), mousePosition); if (annotations.length>0) annotator.showViewer(jQuery.makeArray(annotations), mousePosition);
} }
}, },
...@@ -438,17 +438,17 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ...@@ -438,17 +438,17 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* @param {Event} event The actual action of clicking down within an annotation area. * @param {Event} event The actual action of clicking down within an annotation area.
*/ */
_onAnnotationClick: function(event){ _onAnnotationClick: function(event){
//gets the annotation from the data stored in the element // gets the annotation from the data stored in the element
var an = jQuery.data(event.target, 'annotation'); var an = jQuery.data(event.target, 'annotation');
//gets the bound within the annotation data // gets the bound within the annotation data
var bounds = typeof an.bounds!='undefined'?an.bounds:{}; var bounds = typeof an.bounds!='undefined'?an.bounds:{};
var currentBounds = this.viewer.drawer.viewport.getBounds(); var currentBounds = this.viewer.drawer.viewport.getBounds();
//if the area is not already panned and zoomed in to the correct area // if the area is not already panned and zoomed in to the correct area
if (typeof bounds.x!='undefined') currentBounds.x = bounds.x; if (typeof bounds.x!='undefined') currentBounds.x = bounds.x;
if (typeof bounds.y!='undefined') currentBounds.y = bounds.y; if (typeof bounds.y!='undefined') currentBounds.y = bounds.y;
if (typeof bounds.width!='undefined') currentBounds.width = bounds.width; if (typeof bounds.width!='undefined') currentBounds.width = bounds.width;
if (typeof bounds.height!='undefined') currentBounds.height = bounds.height; if (typeof bounds.height!='undefined') currentBounds.height = bounds.height;
//change the zoom to the saved parameter // change the zoom to the saved parameter
this.viewer.drawer.viewport.fitBounds(currentBounds); this.viewer.drawer.viewport.fitBounds(currentBounds);
}, },
...@@ -459,13 +459,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ...@@ -459,13 +459,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* @param {String} type Either 'asc' for ascending or 'desc' for descending * @param {String} type Either 'asc' for ascending or 'desc' for descending
*/ */
_sortByDate: function (annotations,type){ _sortByDate: function (annotations,type){
var type = type || 'asc'; //asc => The value [0] will be the most recent date var type = type || 'asc'; // asc => The value [0] will be the most recent date
annotations.sort(function(a,b){ annotations.sort(function(a,b){
//gets the date from when they were last updated // gets the date from when they were last updated
a = new Date(typeof a.updated!='undefined'?createDateFromISO8601(a.updated):''); a = new Date(typeof a.updated!='undefined'?createDateFromISO8601(a.updated):'');
b = new Date(typeof b.updated!='undefined'?createDateFromISO8601(b.updated):''); b = new Date(typeof b.updated!='undefined'?createDateFromISO8601(b.updated):'');
//orders them based on type passed in // orders them based on type passed in
if (type == 'asc') if (type == 'asc')
return b<a?-1:b>a?1:0; return b<a?-1:b>a?1:0;
else else
...@@ -507,8 +507,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ...@@ -507,8 +507,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
clickDistThreshold: viewer.clickDistThreshold clickDistThreshold: viewer.clickDistThreshold
}); });
//area makes sure that the annotation button only appears when everyone is // area makes sure that the annotation button only appears when everyone is
//allowed to annotate or if you are an instructor // allowed to annotate or if you are an instructor
if(this.options.viewer.annotation_mode == "everyone" || this.options.viewer.flags){ if(this.options.viewer.annotation_mode == "everyone" || this.options.viewer.flags){
/* Set elements to the control menu */ /* Set elements to the control menu */
viewer.annotatorControl = viewer.wrapperAnnotation.element; viewer.annotatorControl = viewer.wrapperAnnotation.element;
...@@ -531,10 +531,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ...@@ -531,10 +531,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* the last rectangle you drew (but didn't save) gets destroyed. * the last rectangle you drew (but didn't save) gets destroyed.
*/ */
_reset: function(){ _reset: function(){
//Find and remove DrawingRect. This is the previous rectangle // Find and remove DrawingRect. This is the previous rectangle
this._removeElemsByClass('DrawingRect',this.viewer.canvas); this._removeElemsByClass('DrawingRect',this.viewer.canvas);
//Show adder and hide editor // Show adder and hide editor
this.annotator.editor.element[0].style.display = 'none'; this.annotator.editor.element[0].style.display = 'none';
}, },
...@@ -569,19 +569,19 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ...@@ -569,19 +569,19 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
var annotator = this.annotator; var annotator = this.annotator;
var rp = an.rangePosition; var rp = an.rangePosition;
//Makes sure OSD exists and that annotation is an image annotation // Makes sure OSD exists and that annotation is an image annotation
//with a position in the OSD instance // with a position in the OSD instance
var isOpenSeaDragon = (typeof annotator.osda != 'undefined'); var isOpenSeaDragon = (typeof annotator.osda != 'undefined');
var isContainer = (typeof an.target!='undefined' && an.target.container==this.viewer.id ); var isContainer = (typeof an.target!='undefined' && an.target.container==this.viewer.id );
var isImage = (typeof an.media!='undefined' && an.media=='image'); var isImage = (typeof an.media!='undefined' && an.media=='image');
var isRP = (typeof rp!='undefined'); var isRP = (typeof rp!='undefined');
var isSource = false; var isSource = false;
//Double checks that the image being displayed matches the annotations // Double checks that the image being displayed matches the annotations
var source = this.viewer.source; var source = this.viewer.source;
var tilesUrl = typeof source.tilesUrl!='undefined'?source.tilesUrl:''; var tilesUrl = typeof source.tilesUrl!='undefined'?source.tilesUrl:'';
var functionUrl = typeof source.getTileUrl!='undefined'?source.getTileUrl:''; var functionUrl = typeof source.getTileUrl!='undefined'?source.getTileUrl:'';
var compareUrl = tilesUrl!=''?tilesUrl:(''+functionUrl).replace(/\s+/g, ' '); var compareUrl = tilesUrl!=''?tilesUrl:('' + functionUrl).replace(/\s+/g, ' ');
if(isContainer) isSource = (an.target.src == compareUrl); if(isContainer) isSource = (an.target.src == compareUrl);
return (isOpenSeaDragon && isContainer && isImage && isRP && isSource); return (isOpenSeaDragon && isContainer && isImage && isRP && isSource);
...@@ -594,25 +594,25 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ...@@ -594,25 +594,25 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* @param {HTMLElement} elem Element where shape is overlayed * @param {HTMLElement} elem Element where shape is overlayed
*/ */
_setOverShape: function(elem){ _setOverShape: function(elem){
//Calculate Point absolute positions // Calculate Point absolute positions
var rectPosition = this.rectPosition || {}; var rectPosition = this.rectPosition || {};
var startPoint = this._logicalToPhysicalXY(new $.Point(rectPosition.left,rectPosition.top)); var startPoint = this._logicalToPhysicalXY(new $.Point(rectPosition.left,rectPosition.top));
var endPoint = this._logicalToPhysicalXY(new $.Point(rectPosition.left+rectPosition.width,rectPosition.top+rectPosition.height)); var endPoint = this._logicalToPhysicalXY(new $.Point(rectPosition.left + rectPosition.width,rectPosition.top + rectPosition.height));
//Calculate Point absolute positions // Calculate Point absolute positions
var wrapper = jQuery('.annotator-wrapper')[0]; var wrapper = jQuery('.annotator-wrapper')[0];
var positionAnnotator = $.getElementPosition(wrapper); var positionAnnotator = $.getElementPosition(wrapper);
var positionCanvas = $.getElementPosition(this.viewer.canvas); var positionCanvas = $.getElementPosition(this.viewer.canvas);
var positionAdder = {}; var positionAdder = {};
//Fix with positionCanvas based on annotator wrapper and OSD area // Fix with positionCanvas based on annotator wrapper and OSD area
startPoint = startPoint.plus(positionCanvas); startPoint = startPoint.plus(positionCanvas);
endPoint = endPoint.plus(positionCanvas); endPoint = endPoint.plus(positionCanvas);
elem[0].style.display = 'block'; //Show the adder elem[0].style.display = 'block'; // Show the adder
positionAdder.left = (startPoint.x - positionAnnotator.x) + (endPoint.x - startPoint.x) / 2; positionAdder.left = (startPoint.x - positionAnnotator.x) + (endPoint.x - startPoint.x) / 2;
positionAdder.top = (startPoint.y - positionAnnotator.y) + (endPoint.y - startPoint.y) / 2; //It is not necessary fix with - positionAnnotator.y positionAdder.top = (startPoint.y - positionAnnotator.y) + (endPoint.y - startPoint.y) / 2; // It is not necessary fix with - positionAnnotator.y
elem.css(positionAdder); elem.css(positionAdder);
}, },
...@@ -717,12 +717,12 @@ Annotator.Plugin.OpenSeaDragon = (function(_super) { ...@@ -717,12 +717,12 @@ Annotator.Plugin.OpenSeaDragon = (function(_super) {
this.pluginSubmit = __bind(this.pluginSubmit, this); this.pluginSubmit = __bind(this.pluginSubmit, this);
_ref = OpenSeaDragon.__super__.constructor.apply(this, arguments); _ref = OpenSeaDragon.__super__.constructor.apply(this, arguments);
//To facilitate calling items, we want to be able to get the index of a value // To facilitate calling items, we want to be able to get the index of a value
this.__indexOf = [].indexOf; this.__indexOf = [].indexOf;
if(!this.__indexOf){ if(!this.__indexOf){
//Basically you iterate through every item on the list, if it matches // Basically you iterate through every item on the list, if it matches
//the item you are looking for return the current index, otherwise return -1 // the item you are looking for return the current index, otherwise return -1
this.__indexOf = function(item) { this.__indexOf = function(item) {
for (var i = 0, l = this.length; i < l; i++) { for (var i = 0, l = this.length; i < l; i++) {
if (i in this && this[i] === item) if (i in this && this[i] === item)
...@@ -743,7 +743,7 @@ Annotator.Plugin.OpenSeaDragon = (function(_super) { ...@@ -743,7 +743,7 @@ Annotator.Plugin.OpenSeaDragon = (function(_super) {
* annotation and the viewer that appears when you hover over an item. * annotation and the viewer that appears when you hover over an item.
*/ */
OpenSeaDragon.prototype.pluginInit = function() { OpenSeaDragon.prototype.pluginInit = function() {
//Check that annotator is working // Check that annotator is working
if (!Annotator.supported()) { if (!Annotator.supported()) {
return; return;
} }
...@@ -751,12 +751,12 @@ Annotator.Plugin.OpenSeaDragon = (function(_super) { ...@@ -751,12 +751,12 @@ Annotator.Plugin.OpenSeaDragon = (function(_super) {
//-- Editor //-- Editor
this.field = this.annotator.editor.addField({ this.field = this.annotator.editor.addField({
id: 'osd-input-rangePosition-annotations', id: 'osd-input-rangePosition-annotations',
type: 'input', //options (textarea,input,select,checkbox) type: 'input', // options (textarea,input,select,checkbox)
submit: this.pluginSubmit, submit: this.pluginSubmit,
EditOpenSeaDragonAn: this.EditOpenSeaDragonAn EditOpenSeaDragonAn: this.EditOpenSeaDragonAn
}); });
//Modify the element created with annotator to be an invisible span // Modify the element created with annotator to be an invisible span
var select = '<li><span id="osd-input-rangePosition-annotations"></span></li>'; var select = '<li><span id="osd-input-rangePosition-annotations"></span></li>';
var newfield = Annotator.$(select); var newfield = Annotator.$(select);
Annotator.$(this.field).replaceWith(newfield); Annotator.$(this.field).replaceWith(newfield);
...@@ -774,27 +774,27 @@ Annotator.Plugin.OpenSeaDragon = (function(_super) { ...@@ -774,27 +774,27 @@ Annotator.Plugin.OpenSeaDragon = (function(_super) {
* metadata for the image in an object that will be passed to the backend. * metadata for the image in an object that will be passed to the backend.
*/ */
OpenSeaDragon.prototype.pluginSubmit = function(field, annotation) { OpenSeaDragon.prototype.pluginSubmit = function(field, annotation) {
//Select the new JSON for the Object to save // Select the new JSON for the Object to save
if (this.EditOpenSeaDragonAn()){ if (this.EditOpenSeaDragonAn()){
var annotator = this.annotator; var annotator = this.annotator;
var osda = annotator.osda; var osda = annotator.osda;
var position = osda.rectPosition || {}; var position = osda.rectPosition || {};
var isNew = typeof annotation.media=='undefined'; var isNew = typeof annotation.media=='undefined';
if(isNew){ if(isNew){
//if it's undefined, we know it's an image because the editor within // if it's undefined, we know it's an image because the editor within
//the OSD instance was open // the OSD instance was open
if (typeof annotation.media == 'undefined') annotation.media = "image"; // - media if (typeof annotation.media == 'undefined') annotation.media = "image"; // - media
annotation.target = annotation.target || {}; // - target annotation.target = annotation.target || {}; // - target
annotation.target.container = osda.viewer.id || ""; // - target.container annotation.target.container = osda.viewer.id || ""; // - target.container
//Save source url // Save source url
var source = osda.viewer.source; var source = osda.viewer.source;
var tilesUrl = typeof source.tilesUrl!='undefined'?source.tilesUrl:''; var tilesUrl = typeof source.tilesUrl!='undefined'?source.tilesUrl:'';
var functionUrl = typeof source.getTileUrl!='undefined'?source.getTileUrl:''; var functionUrl = typeof source.getTileUrl!='undefined'?source.getTileUrl:'';
annotation.target.src = tilesUrl!=''?tilesUrl:(''+functionUrl).replace(/\s+/g, ' '); // - target.src (media source) annotation.target.src = tilesUrl!=''?tilesUrl:('' + functionUrl).replace(/\s+/g, ' '); // - target.src (media source)
annotation.target.ext = source.fileFormat || ""; // - target.ext (extension) annotation.target.ext = source.fileFormat || ""; // - target.ext (extension)
//Gets the bounds in order to save them for zooming in and highlight properties // Gets the bounds in order to save them for zooming in and highlight properties
annotation.bounds = osda.viewer.drawer.viewport.getBounds() || {}; // - bounds annotation.bounds = osda.viewer.drawer.viewport.getBounds() || {}; // - bounds
var finalimagelink = source["@id"].replace("/info.json", ""); var finalimagelink = source["@id"].replace("/info.json", "");
var highlightX = Math.round(position.left * source["width"]); var highlightX = Math.round(position.left * source["width"]);
...@@ -802,12 +802,12 @@ Annotator.Plugin.OpenSeaDragon = (function(_super) { ...@@ -802,12 +802,12 @@ Annotator.Plugin.OpenSeaDragon = (function(_super) {
var highlightWidth = Math.round(position.width * source["width"]); var highlightWidth = Math.round(position.width * source["width"]);
var highlightHeight = Math.round(position.height * source["width"]); var highlightHeight = Math.round(position.height * source["width"]);
//creates a link to the OSD server that contains the image to get // creates a link to the OSD server that contains the image to get
//the thumbnail of the selected portion of the image // the thumbnail of the selected portion of the image
annotation.target.thumb = finalimagelink + "/" + highlightX + "," + highlightY + "," + highlightWidth + "," + highlightHeight + "/full/0/native." + source["formats"][0]; annotation.target.thumb = finalimagelink + "/" + highlightX + "," + highlightY + "," + highlightWidth + "," + highlightHeight + "/full/0/native." + source["formats"][0];
if(isNew) annotation.rangePosition = position || {}; // - rangePosition if(isNew) annotation.rangePosition = position || {}; // - rangePosition
//updates the dates associated with creation and update // updates the dates associated with creation and update
annotation.updated = new Date().toISOString(); // - updated annotation.updated = new Date().toISOString(); // - updated
if (typeof annotation.created == 'undefined') if (typeof annotation.created == 'undefined')
annotation.created = annotation.updated; // - created annotation.created = annotation.updated; // - created
...@@ -838,19 +838,19 @@ Annotator.Plugin.OpenSeaDragon = (function(_super) { ...@@ -838,19 +838,19 @@ Annotator.Plugin.OpenSeaDragon = (function(_super) {
var annotator = this.annotator; var annotator = this.annotator;
var rp = an.rangePosition; var rp = an.rangePosition;
//Makes sure OSD exists and that annotation is an image annotation // Makes sure OSD exists and that annotation is an image annotation
//with a position in the OSD instance // with a position in the OSD instance
var isOpenSeaDragon = (typeof annotator.osda != 'undefined'); var isOpenSeaDragon = (typeof annotator.osda != 'undefined');
var isContainer = (typeof an.target!='undefined' && an.target.container==this.viewer.id ); var isContainer = (typeof an.target!='undefined' && an.target.container==this.viewer.id );
var isImage = (typeof an.media!='undefined' && an.media=='image'); var isImage = (typeof an.media!='undefined' && an.media=='image');
var isRP = (typeof rp!='undefined'); var isRP = (typeof rp!='undefined');
var isSource = false; var isSource = false;
//Double checks that the image being displayed matches the annotations // Double checks that the image being displayed matches the annotations
var source = this.viewer.source; var source = this.viewer.source;
var tilesUrl = typeof source.tilesUrl!='undefined'?source.tilesUrl:''; var tilesUrl = typeof source.tilesUrl!='undefined'?source.tilesUrl:'';
var functionUrl = typeof source.getTileUrl!='undefined'?source.getTileUrl:''; var functionUrl = typeof source.getTileUrl!='undefined'?source.getTileUrl:'';
var compareUrl = tilesUrl!=''?tilesUrl:(''+functionUrl).replace(/\s+/g, ' '); var compareUrl = tilesUrl!=''?tilesUrl:('' + functionUrl).replace(/\s+/g, ' ');
if(isContainer) isSource = (an.target.src == compareUrl); if(isContainer) isSource = (an.target.src == compareUrl);
return (isOpenSeaDragon && isContainer && isImage && isRP && isSource); return (isOpenSeaDragon && isContainer && isImage && isRP && isSource);
...@@ -861,14 +861,14 @@ Annotator.Plugin.OpenSeaDragon = (function(_super) { ...@@ -861,14 +861,14 @@ Annotator.Plugin.OpenSeaDragon = (function(_super) {
* @param {Object} an Annotation object from the Annotator instance * @param {Object} an Annotation object from the Annotator instance
*/ */
OpenSeaDragon.prototype._deleteAnnotation = function(an){ OpenSeaDragon.prototype._deleteAnnotation = function(an){
//Remove the annotation of the plugin Store // Remove the annotation of the plugin Store
var annotations = this.annotator.plugins['Store'].annotations; var annotations = this.annotator.plugins['Store'].annotations;
//Failsafe in case annotation is not immediately removed from annotations list // Failsafe in case annotation is not immediately removed from annotations list
if (annotations.indexOf(an)>-1) if (annotations.indexOf(an)>-1)
annotations.splice(annotations.indexOf(an), 1); annotations.splice(annotations.indexOf(an), 1);
//Refresh the annotations in the display // Refresh the annotations in the display
this.annotator.osda.refreshDisplay(); this.annotator.osda.refreshDisplay();
}; };
...@@ -881,12 +881,12 @@ Annotator.Plugin.OpenSeaDragon = (function(_super) { ...@@ -881,12 +881,12 @@ Annotator.Plugin.OpenSeaDragon = (function(_super) {
var isOpenSeaDragon = this.isOpenSeaDragon; var isOpenSeaDragon = this.isOpenSeaDragon;
var self = this; var self = this;
//local functions // local functions
//-- Editor //-- Editor
function annotationEditorHidden(editor) { function annotationEditorHidden(editor) {
if (EditOpenSeaDragonAn()){ if (EditOpenSeaDragonAn()){
annotator.osda._reset(); annotator.osda._reset();
annotator.osda.refreshDisplay(); //Reload the display of annotations annotator.osda.refreshDisplay(); // Reload the display of annotations
} }
annotator.editor.OpenSeaDragon=-1; annotator.editor.OpenSeaDragon=-1;
annotator.unsubscribe("annotationEditorHidden", annotationEditorHidden); annotator.unsubscribe("annotationEditorHidden", annotationEditorHidden);
...@@ -910,7 +910,7 @@ Annotator.Plugin.OpenSeaDragon = (function(_super) { ...@@ -910,7 +910,7 @@ Annotator.Plugin.OpenSeaDragon = (function(_super) {
function annotationViewerShown(viewer,annotations) { function annotationViewerShown(viewer,annotations) {
var wrapper = jQuery('.annotator-wrapper').offset(); var wrapper = jQuery('.annotator-wrapper').offset();
//Fix with positionCanvas // Fix with positionCanvas
var startPoint = {x: parseFloat(viewer.element[0].style.left), var startPoint = {x: parseFloat(viewer.element[0].style.left),
y: parseFloat(viewer.element[0].style.top)}; y: parseFloat(viewer.element[0].style.top)};
...@@ -921,12 +921,12 @@ Annotator.Plugin.OpenSeaDragon = (function(_super) { ...@@ -921,12 +921,12 @@ Annotator.Plugin.OpenSeaDragon = (function(_super) {
}; };
viewer.element.css(newpos); viewer.element.css(newpos);
//Remove the time to wait until disapear, to be more faster that annotator by default // Remove the time to wait until disapear, to be more faster that annotator by default
viewer.element.find('.annotator-controls').removeClass(viewer.classes.showControls); viewer.element.find('.annotator-controls').removeClass(viewer.classes.showControls);
annotator.viewer.subscribe("hide", hideViewer); annotator.viewer.subscribe("hide", hideViewer);
}; };
//subscribe to Annotator // subscribe to Annotator
annotator.subscribe("annotationEditorShown", annotationEditorShown) annotator.subscribe("annotationEditorShown", annotationEditorShown)
.subscribe("annotationDeleted", annotationDeleted) .subscribe("annotationDeleted", annotationDeleted)
.subscribe("annotationViewerShown", annotationViewerShown); .subscribe("annotationViewerShown", annotationViewerShown);
...@@ -940,18 +940,18 @@ Annotator.Plugin.OpenSeaDragon = (function(_super) { ...@@ -940,18 +940,18 @@ Annotator.Plugin.OpenSeaDragon = (function(_super) {
//----------------PUBLIC OBJECT TO CONTROL THE ANNOTATIONS----------------// //----------------PUBLIC OBJECT TO CONTROL THE ANNOTATIONS----------------//
//The name of the plugin that the user will write in the html // The name of the plugin that the user will write in the html
OpenSeadragonAnnotation = ("OpenSeadragonAnnotation" in window) ? OpenSeadragonAnnotation : {}; OpenSeadragonAnnotation = ("OpenSeadragonAnnotation" in window) ? OpenSeadragonAnnotation : {};
OpenSeadragonAnnotation = function (element, options) { OpenSeadragonAnnotation = function (element, options) {
//local variables // local variables
var $ = jQuery; var $ = jQuery;
var options = options || {}; var options = options || {};
options.optionsOpenSeadragon = options.optionsOpenSeadragon || {}; options.optionsOpenSeadragon = options.optionsOpenSeadragon || {};
options.optionsOSDA = options.optionsOSDA || {}; options.optionsOSDA = options.optionsOSDA || {};
options.optionsAnnotator = options.optionsAnnotator || {}; options.optionsAnnotator = options.optionsAnnotator || {};
//if there isn't store optinos it will create a uri and limit variables for the Back-end of Annotations // if there isn't store optinos it will create a uri and limit variables for the Back-end of Annotations
if (typeof options.optionsAnnotator.store=='undefined') if (typeof options.optionsAnnotator.store=='undefined')
options.optionsAnnotator.store = {}; options.optionsAnnotator.store = {};
var store = options.optionsAnnotator.store; var store = options.optionsAnnotator.store;
...@@ -968,11 +968,11 @@ OpenSeadragonAnnotation = function (element, options) { ...@@ -968,11 +968,11 @@ OpenSeadragonAnnotation = function (element, options) {
if (typeof store.loadFromSearch.limit=='undefined') if (typeof store.loadFromSearch.limit=='undefined')
store.loadFromSearch.limit = 10000; store.loadFromSearch.limit = 10000;
//global variables // global variables
this.currentUser = null; this.currentUser = null;
//-- Init all the classes --/ //-- Init all the classes --/
//Annotator // Annotator
this.annotator = $(element).annotator(options.optionsAnnotator.annotator).data('annotator'); this.annotator = $(element).annotator(options.optionsAnnotator.annotator).data('annotator');
//-- Activate all the Annotator plugins --// //-- Activate all the Annotator plugins --//
...@@ -1011,10 +1011,10 @@ OpenSeadragonAnnotation = function (element, options) { ...@@ -1011,10 +1011,10 @@ OpenSeadragonAnnotation = function (element, options) {
//- OpenSeaDragon Plugins //- OpenSeaDragon Plugins
this.viewer.annotation(options.optionsOSDA); this.viewer.annotation(options.optionsOSDA);
//Set annotator.editor.OpenSeaDragon by default // Set annotator.editor.OpenSeaDragon by default
this.annotator.editor.OpenSeaDragon=-1; this.annotator.editor.OpenSeaDragon=-1;
//We need to make sure that osda is accessible via annotator // We need to make sure that osda is accessible via annotator
this.annotator.osda = this; this.annotator.osda = this;
function reloadEditor(){ function reloadEditor(){
......
...@@ -25,27 +25,27 @@ var _ref, ...@@ -25,27 +25,27 @@ var _ref,
Annotator.Plugin.Share = (function(_super) { Annotator.Plugin.Share = (function(_super) {
__extends(Share, _super); __extends(Share, _super);
//Default Share configuration // Default Share configuration
Share.prototype.options = { Share.prototype.options = {
shareIn:['facebook','twitter','email','google'], shareIn: ['facebook', 'twitter', 'email', 'google'],
getUrl:{ getUrl: {
'facebook':function(title,link,noteText){ 'facebook':function(title, link, noteText){
return 'https://www.facebook.com/sharer/sharer.php?s=100&p[url]='+link+'&p[title]='+encodeURIComponent('Open Video Annotation')+'&p[summary]='+noteText; return 'https://www.facebook.com/sharer/sharer.php?s=100&p[url]=' + link + '&p[title]=' + encodeURIComponent('Open Video Annotation') + '&p[summary]=' + noteText;
}, },
'twitter':function(title,link,noteText){ 'twitter':function(title, link, noteText){
return 'https://twitter.com/intent/tweet?original_referer='+link+'&source=tweetbutton&url='+link+ "&via=OpenVideoAnnotation&text=" +encodeURIComponent('I want to share the following Open Video Annotation: '); return 'https://twitter.com/intent/tweet?original_referer=' + link + '&source=tweetbutton&url=' + link + "&via=OpenVideoAnnotation&text=" + encodeURIComponent('I want to share the following Open Video Annotation: ');
}, },
'google':function(title,link,noteText){ 'google':function(title, link, noteText){
return 'https://plus.google.com/share?url='+link; return 'https://plus.google.com/share?url=' + link;
}, },
'email': function(title,link,noteText){ 'email': function(title, link, noteText){
return 'mailto:?subject='+title+'&body='+link; return 'mailto:?subject=' + title + '&body=' + link;
} }
}, },
baseUrl:'', //baseUrl = the base url for all the shared annotations baseUrl: '', // baseUrl = the base url for all the shared annotations
}; };
function Share(element,options) { function Share(element, options) {
if (typeof options!='undefined') if (typeof options!='undefined')
this.options.shareIn = typeof options.shareIn!='undefined'?options.shareIn:this.options.shareIn; this.options.shareIn = typeof options.shareIn!='undefined'?options.shareIn:this.options.shareIn;
this.buildHTMLShareButton = __bind(this.buildHTMLShareButton, this); this.buildHTMLShareButton = __bind(this.buildHTMLShareButton, this);
...@@ -60,30 +60,30 @@ Annotator.Plugin.Share = (function(_super) { ...@@ -60,30 +60,30 @@ Annotator.Plugin.Share = (function(_super) {
Share.prototype.input = null; Share.prototype.input = null;
Share.prototype.pluginInit = function() { Share.prototype.pluginInit = function() {
//Check that annotator is working // Check that annotator is working
if (!Annotator.supported()) { if (!Annotator.supported()) {
return; return;
} }
//-- Editor // -- Editor
this.field = this.annotator.editor.addField({ this.field = this.annotator.editor.addField({
type: 'input', //options (textarea,input,select,checkbox) type: 'input', // options (textarea, input, select, checkbox)
}); });
//Modify the element created with annotator to be an invisible span // Modify the element created with annotator to be an invisible span
var newfield = Annotator.$('<li class="annotator-item">'+this.buildHTMLShareButton('Share without saving:')+'</li>'); var newfield = Annotator.$('<li class="annotator-item">' + this.buildHTMLShareButton('Share without saving:') + '</li>');
Annotator.$(this.field).replaceWith(newfield); Annotator.$(this.field).replaceWith(newfield);
this.field=newfield[0]; this.field=newfield[0];
//Create the actions for the buttons // Create the actions for the buttons
this.buttonsActions(this.field,2,this.options.baseUrl); //2 is the method of the API that will be for share without saving this.buttonsActions(this.field, 2, this.options.baseUrl); // 2 is the method of the API that will be for share without saving
//Init the API plugin // Init the API plugin
var APIoptions = this.initAPI(); var APIoptions = this.initAPI();
this.runAPI(APIoptions); this.runAPI(APIoptions);
//-- Viewer // -- Viewer
var newview = this.annotator.viewer.addField({ var newview = this.annotator.viewer.addField({
load: this.updateViewer, load: this.updateViewer,
}); });
...@@ -91,36 +91,37 @@ Annotator.Plugin.Share = (function(_super) { ...@@ -91,36 +91,37 @@ Annotator.Plugin.Share = (function(_super) {
return this.input = $(this.field).find(':input'); return this.input = $(this.field).find(':input');
}; };
//Share button HTML // Share button HTML
Share.prototype.buildHTMLShareButton = function(title,id) { Share.prototype.buildHTMLShareButton = function(title, id) {
var title = title || '', var title = title || '';
id = typeof id!='undefined'?'annotationId="'+id+'"':'', var id = typeof id!='undefined'?'annotationId="' + id + '"':'';
titleText = title!=''?'<div class="share-text-annotator">'+title+'</div>':'', var titleText = title!=''?'<div class="share-text-annotator">' + title + '</div>':'';
shareButton = '<div class="share-button-annotator share-button" '+id+'></div>', var shareButton = '<div class="share-button-annotator share-button" ' + id + '></div>';
popup = '<div class="share-popup-overlay-bg" style="z-index:30000000000"><div class="share-popup"><div class="share-popup-items"></div><div class="close-btn">Close</div></div></div>'; var popup = '<div class="share-popup-overlay-bg" style="z-index:30000000000"><div class="share-popup"><div class="share-popup-items"></div><div class="close-btn">Close</div></div></div>';
// checks to make sure that no popup overlay already exists (though hidden) and creates a new one if it does not exist
if($('.share-popup-overlay-bg').length === 0) if($('.share-popup-overlay-bg').length === 0)
$('.annotator-wrapper').append(popup); $('.annotator-wrapper').append(popup);
return '<div class="share-container-annotator">'+titleText+shareButton+'</div>'; return '<div class="share-container-annotator">' + titleText + shareButton + '</div>';
} }
//template for the design of the Share Plugin // template for the design of the Share Plugin
Share.prototype.buildHTMLPopup = function(title) { Share.prototype.buildHTMLPopup = function(title) {
var buttons = ''; var buttons = '';
if (typeof this.options.shareIn!='undefined'){ if (typeof this.options.shareIn != 'undefined'){
this.options.shareIn.forEach(function(item) { this.options.shareIn.forEach(function(item) {
buttons += '<div class="share-'+item+'-annotator share-button">'+item.charAt(0).toUpperCase() + item.slice(1)+'</div>'; buttons += '<div class="share-' + item + '-annotator share-button">' + item.charAt(0).toUpperCase() + item.slice(1) + '</div>';
}); });
} }
this.uri = typeof this.uri!='undefined'?this.uri:''; this.uri = (typeof this.uri != 'undefined') ? this.uri : '';
var title = '<div class="share-popup-title">'+title.replace(":","")+'</div>', var title = '<div class="share-popup-title">' + title.replace(":", "") + '</div>';
copy = '<div class="share-popup-copy">Copy and Share:</div>', var copy = '<div class="share-popup-copy">Copy and Share:</div>';
uri = '<input type="text" class="share-popup-uri" onclick="javascript:this.select();" readonly="true" value="'+this.uri+'">', var uri = '<input type="text" class="share-popup-uri" onclick="javascript:this.select();" readonly="true" value="' + this.uri + '">';
popup = title + buttons + copy + uri; var popup = title + buttons + copy + uri;
return popup; return popup;
} }
//Create the actions for the buttons // Create the actions for the buttons
Share.prototype.buttonsActions = function(field,method,url, annotation) { Share.prototype.buttonsActions = function(field, method, url, annotation) {
var share = this; var share = this;
// hide popup when user clicks on close button // hide popup when user clicks on close button
...@@ -139,35 +140,40 @@ Annotator.Plugin.Share = (function(_super) { ...@@ -139,35 +140,40 @@ Annotator.Plugin.Share = (function(_super) {
$(field).find('.share-button-annotator.share-button').click(function(event) { $(field).find('.share-button-annotator.share-button').click(function(event) {
event.preventDefault(); // disable normal link function so that it doesn't refresh the page event.preventDefault(); // disable normal link function so that it doesn't refresh the page
annotation = share.getAnnotationFromId(event.currentTarget.attributes.annotationid); annotation = share.getAnnotationFromId(event.currentTarget.attributes.annotationid);
var _field = this, var _field = this;
ovaId = annotation.id, var ovaId = annotation.id,
title = method == 1?'Share':'Share without saving'; var title;
if (method == 1) {
title = 'Share';
} else {
title = 'Share without saving';
}
// share.uri will be useful for buildHTMLPopup functions // share.uri will be useful for buildHTMLPopup functions
share.uri = share.createAPIURL(method,ovaId,url, annotation); share.uri = share.createAPIURL(method, ovaId, url, annotation);
//display your popup // display your popup
$('.share-popup-overlay-bg').show(); $('.share-popup-overlay-bg').show();
//build buttons // build buttons
$('.share-popup-items').html(share.buildHTMLPopup(title)); $('.share-popup-items').html(share.buildHTMLPopup(title));
//buttons actions // buttons actions
if (typeof share.options.shareIn!='undefined'){ if (typeof share.options.shareIn!='undefined'){
share.options.shareIn.forEach(function(item) { share.options.shareIn.forEach(function(item) {
$('.share-'+item+'-annotator.share-button').click(function() { $('.share-' + item + '-annotator.share-button').click(function() {
var url = share.createAPIURL(method,ovaId,url, annotation), var url = share.createAPIURL(method, ovaId, url, annotation);
title = "Sharing a annotation with Open Video Annotation"; var title = "Sharing a annotation with Open Video Annotation";
link = encodeURIComponent(url), var link = encodeURIComponent(url);
noteText = share.getSource('ovaText'), var noteText = share.getSource('ovaText');
finalUrl = ''; var finalUrl = '';
if (method==1){ if (method==1){
var viewer = share.annotator.viewer, var viewer = share.annotator.viewer;
textarea = $(viewer.element).find('div:first').html(); var textarea = $(viewer.element).find('div:first').html();
noteText = encodeURIComponent(textarea); noteText = encodeURIComponent(textarea);
} }
finalUrl = typeof share.options.getUrl[item]!='undefined'?share.options.getUrl[item](title,link,noteText):''; finalUrl = typeof share.options.getUrl[item]!='undefined'?share.options.getUrl[item](title, link, noteText):'';
if(typeof share.options.getUrl[item]!='undefined') if (typeof share.options.getUrl[item]!='undefined')
window.open(finalUrl); window.open(finalUrl);
}); });
}); });
...@@ -176,35 +182,34 @@ Annotator.Plugin.Share = (function(_super) { ...@@ -176,35 +182,34 @@ Annotator.Plugin.Share = (function(_super) {
}; };
Share.prototype.createAPIURL = function(method,ovaId,url, annotation) { Share.prototype.createAPIURL = function(method, ovaId, url, annotation) {
var annotator = this.annotator, var annotator = this.annotator;
editor = annotator.editor, var editor = annotator.editor;
method = method || 1, var method = method || 1;
//url = location.protocol + '//' + location.host + location.pathname, var url = annotation.uri || window.location.href;
url = annotation.uri || window.location.href;
url += (url.indexOf('?') >= 0)?'&':'?'; url += (url.indexOf('?') >= 0)? '&' : '?';
if (method === 1){ if (method === 1){
var ovaId = typeof ovaId!='undefined'?ovaId:''; var ovaId = (typeof ovaId !='undefined') ? ovaId : '';
url += 'ovaId=' + ovaId; url += 'ovaId=' + ovaId;
}else if (method === 2){ } else if (method === 2){
var ovaStart = this.getSource('ovaStart'), var ovaStart = this.getSource('ovaStart');
ovaEnd = this.getSource('ovaEnd'), var ovaEnd = this.getSource('ovaEnd');
ovaText = this.getSource('ovaText'); var ovaText = this.getSource('ovaText');
url += 'ovaStart='+ ovaStart
+'&ovaEnd='+ ovaEnd url += 'ovaStart=' + ovaStart
+'&ovaText='+ ovaText; + '&ovaEnd=' + ovaEnd
if(typeof editor.VideoJS!='undefined' && editor.VideoJS !== -1){//Video Annotation + '&ovaText=' + ovaText;
var ovaContainer = this.getSource('ovaContainer'), if (typeof editor.VideoJS != 'undefined' && editor.VideoJS !== -1){// Video Annotation
ovaSrc = this.getSource('ovaSrc'); var ovaContainer = this.getSource('ovaContainer');
url += '&ovaContainer='+ovaContainer var ovaSrc = this.getSource('ovaSrc');
+'&ovaSrc='+ ovaSrc; url += '&ovaContainer=' + ovaContainer
}else{//Text Annotation + '&ovaSrc=' + ovaSrc;
var ovastartOffset = this.getSource('ovastartOffset'), } else {// Text Annotation
ovaendOffset = this.getSource('ovaendOffset'); var ovastartOffset = this.getSource('ovastartOffset');
url += '&ovastartOffset='+ovastartOffset var ovaendOffset = this.getSource('ovaendOffset');
+'&ovaendOffset='+ ovaendOffset; url += '&ovastartOffset=' + ovastartOffset + '&ovaendOffset=' + ovaendOffset;
} }
} }
return url; return url;
...@@ -212,33 +217,35 @@ Annotator.Plugin.Share = (function(_super) { ...@@ -212,33 +217,35 @@ Annotator.Plugin.Share = (function(_super) {
Share.prototype.getSource = function(source) { Share.prototype.getSource = function(source) {
var source = source || ''; var source = source || '';
if (source == 'ovaId') {//method 1 if (source == 'ovaId') {// method 1
source=this.annotation.id; source=this.annotation.id;
}else{//method 2 } else {// method 2
var annotator = this.annotator, var annotator = this.annotator;
editor = annotator.editor, var editor = annotator.editor,
textarea = $(editor.element).find('textarea')[0]; var textarea = $(editor.element).find('textarea')[0];
if(source == 'ovaText')
if (source == 'ovaText')
source = textarea.value; source = textarea.value;
if (typeof editor.VideoJS!='undefined' && editor.VideoJS !== -1){//Video Annotation
if(source == 'ovaContainer') if (typeof editor.VideoJS!='undefined' && editor.VideoJS !== -1){// Video Annotation
if (source == 'ovaContainer')
source = editor.VideoJS; source = editor.VideoJS;
else if(source == 'ovaSrc') else if (source == 'ovaSrc')
source = annotator.mplayer[editor.VideoJS].tech.options_.source.src; source = annotator.mplayer[editor.VideoJS].tech.options_.source.src;
else if(source == 'ovaStart') else if (source == 'ovaStart')
source = annotator.mplayer[editor.VideoJS].rangeslider.getValues().start; source = annotator.mplayer[editor.VideoJS].rangeslider.getValues().start;
else if(source == 'ovaEnd') else if (source == 'ovaEnd')
source = annotator.mplayer[editor.VideoJS].rangeslider.getValues().end; source = annotator.mplayer[editor.VideoJS].rangeslider.getValues().end;
}else{//Text Annotation } else {// Text Annotation
var annotation = editor.annotation; var annotation = editor.annotation;
if(source == 'ovastartOffset') if(source == 'ovastartOffset')
source = annotation.ranges[0].startOffset; source = annotation.ranges[0].startOffset;
else if(source == 'ovaendOffset') else if (source == 'ovaendOffset')
source = annotation.ranges[0].endOffset; source = annotation.ranges[0].endOffset;
else if(source == 'ovaStart') else if (source == 'ovaStart')
source = annotation.ranges[0].start; source = annotation.ranges[0].start;
else if(source == 'ovaEnd') else if (source == 'ovaEnd')
source = annotation.ranges[0].end; source = annotation.ranges[0].end;
} }
} }
...@@ -249,20 +256,20 @@ Annotator.Plugin.Share = (function(_super) { ...@@ -249,20 +256,20 @@ Annotator.Plugin.Share = (function(_super) {
// -- Detect API in the URL -- // // -- Detect API in the URL -- //
/* /*
The first option is to give a known id of an annotation The first option is to give a known id of an annotation
Example http://url.com/#id=rTcpOjIMT2aF1apDtboC-Q Example http:// url.com/#id=rTcpOjIMT2aF1apDtboC-Q
*/ */
var API = {}, var API = {},
ovaId = this.getParameterByName('ovaId'), //Method 1 (Obligatory) var ovaId = this.getParameterByName('ovaId'); // Method 1 (Obligatory)
start = this.getParameterByName('ovaStart'), //Method 2 (Obligatory) var start = this.getParameterByName('ovaStart'); // Method 2 (Obligatory)
end = this.getParameterByName('ovaEnd'), //Method 2 (Obligatory) var end = this.getParameterByName('ovaEnd'); // Method 2 (Obligatory)
container = this.getParameterByName('ovaContainer'), //Method 2 (Obligatory) var container = this.getParameterByName('ovaContainer'); // Method 2 (Obligatory)
src = this.getParameterByName('ovaSrc'),//Method 2 (Obligatory) var src = this.getParameterByName('ovaSrc'); // Method 2 (Obligatory)
text = this.getParameterByName('ovaText'),//Method 2 var text = this.getParameterByName('ovaText'); // Method 2
user = this.getParameterByName('ovaUser'),//Method 2 var user = this.getParameterByName('ovaUser'); // Method 2
startOffset = this.getParameterByName('ovastartOffset'),//Method 2 var startOffset = this.getParameterByName('ovastartOffset'); // Method 2
endOffset = this.getParameterByName('ovaendOffset');//Method 2 var endOffset = this.getParameterByName('ovaendOffset');// Method 2
//remove the variables from the url browser // remove the variables from the url browser
var stripped_url = top.location.href; var stripped_url = top.location.href;
if (ovaId != '') stripped_url = this.removeVariableFromURL(stripped_url, 'ovaId'); if (ovaId != '') stripped_url = this.removeVariableFromURL(stripped_url, 'ovaId');
if (start != '') stripped_url = this.removeVariableFromURL(stripped_url, 'ovaStart'); if (start != '') stripped_url = this.removeVariableFromURL(stripped_url, 'ovaStart');
...@@ -277,44 +284,44 @@ Annotator.Plugin.Share = (function(_super) { ...@@ -277,44 +284,44 @@ Annotator.Plugin.Share = (function(_super) {
// Method 1 API with the Id of the annotation // Method 1 API with the Id of the annotation
//Example: http://danielcebrian.com/annotations/demo.html?&ovaId=wtva_SjnQb2HtqppDihKug // Example: http://danielcebrian.com/annotations/demo.html?&ovaId=wtva_SjnQb2HtqppDihKug
if(ovaId != ''){ if (ovaId != '') {
$.extend(API,{method:1,ovaId:ovaId}); $.extend(API, {method:1, ovaId:ovaId});
} }
//Method 2 API with all the parameter to load the annotation // Method 2 API with all the parameter to load the annotation
//Example with video: http://danielcebrian.com/annotations/demo.html?ovaContainer=vid1&ovaSrc=http%3A%2F%2Fvideo-js.zencoder.com%2Foceans-clip.mp4&ovaStart=2&ovaEnd=10&ovaText=This%20is%20test&ovaUser=Test%20User // Example with video: http://danielcebrian.com/annotations/demo.html?ovaContainer=vid1&ovaSrc=http%3A%2F%2Fvideo-js.zencoder.com%2Foceans-clip.mp4&ovaStart=2&ovaEnd=10&ovaText=This%20is%20test&ovaUser=Test%20User
//Example with text: http://danielcebrian.com/annotations/demo.html?ovaStart=%2Fp%5B1%5D&ovaEnd=%2Fp%5B1%5D&ovastartOffset=542&ovaendOffset=572&ovaText=API // Example with text: http://danielcebrian.com/annotations/demo.html?ovaStart=%2Fp%5B1%5D&ovaEnd=%2Fp%5B1%5D&ovastartOffset=542&ovaendOffset=572&ovaText=API
if(start!='' && end!='' && container!='' && src!=''){//video api if (start!='' && end!='' && container!='' && src!='') {// video api
$.extend(API,{method:2,start:start,end:end,container:container,src:src,text:text,user:user}); $.extend(API, {method:2, start:start, end:end, container:container, src:src, text:text, user:user});
}else if(start!='' && end!='' && startOffset!='' && endOffset!=''){//text api } else if(start!='' && end!='' && startOffset!='' && endOffset!='') {// text api
$.extend(API,{method:2,start:start,end:end,startOffset:startOffset,endOffset:endOffset,text:text,user:user}); $.extend(API, {method:2, start:start, end:end, startOffset:startOffset, endOffset:endOffset, text:text, user:user});
} }
return API; return API;
} }
Share.prototype.runningAPI = function (annotations,API){ Share.prototype.runningAPI = function (annotations, API) {
var wrapper = $('.annotator-wrapper').parent()[0], var wrapper = $('.annotator-wrapper').parent()[0];
mplayer, var mplayer;
osda, var osda;
self=this; var self=this;
//Set Annotator in wrapper to fix quick DOM // Set Annotator in wrapper to fix quick DOM
$.data(wrapper, 'annotator', self.annotator);//Set the object in the span $.data(wrapper, 'annotator', self.annotator);// Set the object in the span
annotator = window.annotator = $.data(wrapper, 'annotator'); annotator = window.annotator = $.data(wrapper, 'annotator');
mplayer = typeof annotator.mplayer!='undefined'?annotator.mplayer:[]; mplayer = (typeof annotator.mplayer != 'undefined') ? annotator.mplayer : [];
osda = typeof annotator.osda!='undefined'?annotator.osda:[]; osda = (typeof annotator.osda != 'undefined') ? annotator.osda : [];
//Detect if the URL has an API element // Detect if the URL has an API element
if (typeof API!='undefined' && typeof API.method!='undefined' && (API.method=='1'||API.method=='2')) { if (typeof API != 'undefined' && typeof API.method != 'undefined' && (API.method == '1' || API.method == '2')) {
if(API.method=='1'){ if (API.method=='1'){
var allannotations = annotator.plugins['Store'].annotations, var allannotations = annotator.plugins['Store'].annotations;
ovaId = decodeURIComponent(API.ovaId); var ovaId = decodeURIComponent(API.ovaId);
for (var item in allannotations) { for (var item in allannotations) {
var an = allannotations[item]; var an = allannotations[item];
if (typeof an.id!='undefined' && an.id == ovaId){//this is the annotation if (typeof an.id!='undefined' && an.id == ovaId){// this is the annotation
if(self._isVideo(an)){//It is a video if (self._isVideo(an)){// It is a video
if (typeof mplayer[an.target.container]!='undefined'){ if (typeof mplayer[an.target.container] != 'undefined'){
var player = mplayer[an.target.container]; var player = mplayer[an.target.container];
if (player.id_ == an.target.container){ if (player.id_ == an.target.container){
var anFound = an; var anFound = an;
...@@ -327,64 +334,63 @@ Annotator.Plugin.Share = (function(_super) { ...@@ -327,64 +334,63 @@ Annotator.Plugin.Share = (function(_super) {
}); });
} }
} }
}else if(self._isImage(an)){//It is a OpenSeaDragon Annotation } else if (self._isImage(an)) {// It is a OpenSeaDragon Annotation
var bounds = new OpenSeadragon.Rect(an.bounds.x, an.bounds.y, an.bounds.width, an.bounds.height); var bounds = new OpenSeadragon.Rect(an.bounds.x, an.bounds.y, an.bounds.width, an.bounds.height);
setTimeout(function(){ setTimeout(function() {
osda.viewer.viewport.fitBounds(bounds, false); osda.viewer.viewport.fitBounds(bounds, false);
$('html,body').animate({ $('html, body').animate( {
scrollTop: $("#"+an.target.container).offset().top scrollTop: $("#" + an.target.container).offset().top
},'slow'); }, 'slow');
},250); }, 250);
}else{//It is a text } else {// It is a text
var hasRanges = typeof an.ranges!='undefined' && typeof an.ranges[0] !='undefined', var hasRanges = typeof an.ranges != 'undefined' && typeof an.ranges[0] != 'undefined';
startOffset = hasRanges?an.ranges[0].startOffset:'', var startOffset = hasRanges?an.ranges[0].startOffset:'';
endOffset = hasRanges?an.ranges[0].endOffset:''; var endOffset = hasRanges?an.ranges[0].endOffset:'';
if(typeof startOffset!='undefined' && typeof endOffset!='undefined'){ if (typeof startOffset != 'undefined' && typeof endOffset != 'undefined'){
//change the color // change the color
$(an.highlights).addClass('api'); $(an.highlights).addClass('api');
//animate to the annotation // animate to the annotation
$('html,body').animate({ $('html, body').animate({
scrollTop: $(an.highlights[0]).offset().top}, scrollTop: $(an.highlights[0]).offset().top}, 'slow');
'slow');
} }
} }
} }
} }
}else if (API.method=='2'){ } else if (API.method == '2'){
if (typeof mplayer!='undefined'){ if (typeof mplayer != 'undefined'){
//variable for Video // variable for Video
var container = decodeURIComponent(API.container), var container = decodeURIComponent(API.container);
player = mplayer[container], var player = mplayer[container];
isVideo = (typeof player!='undefined' && container==player.id_), var isVideo = (typeof player != 'undefined' && container == player.id_);
isNumber = (!isNaN(parseFloat(API.start)) && isFinite(API.start) && !isNaN(parseFloat(API.end)) && isFinite(API.end)), var isNumber = (!isNaN(parseFloat(API.start)) && isFinite(API.start) && !isNaN(parseFloat(API.end)) && isFinite(API.end));
isSource = false; var isSource = false;
if(isVideo){ if (isVideo){
//Compare without extension // Compare without extension
var src = decodeURIComponent(API.src), var src = decodeURIComponent(API.src);
targetSrc = src.substring(0,src.lastIndexOf(".")), var targetSrc = src.substring(0, src.lastIndexOf("."));
playerSrc = player.tech.options_.source.src==''?player.tag.currentSrc:player.tech.options_.source.src; var playerSrc = (player.tech.options_.source.src == '') ? player.tag.currentSrc : player.tech.options_.source.src;
playerSrc = playerSrc.substring(0,playerSrc.lastIndexOf(".")) playerSrc = playerSrc.substring(0, playerSrc.lastIndexOf("."))
isSource = (targetSrc == playerSrc); isSource = (targetSrc == playerSrc);
} }
//Open Video Annotation // Open Video Annotation
if(isVideo && isNumber && isSource){ if (isVideo && isNumber && isSource){
var annotation = { var annotation = {
rangeTime: { rangeTime: {
start:API.start, start: API.start,
end:API.end end: API.end
}, },
created: new Date().toISOString(), created: new Date().toISOString(),
updated: new Date().toISOString(), updated: new Date().toISOString(),
target:{ target: {
container: container, container: container,
src: src src: src
}, },
media: 'video', media: 'video',
text:decodeURIComponent(API.text), text: decodeURIComponent(API.text),
user:decodeURIComponent(API.user) user: decodeURIComponent(API.user)
}; };
videojs(player.id_).ready(function(){ videojs(player.id_).ready(function(){
if (player.techName != 'Youtube'){ if (player.techName != 'Youtube'){
...@@ -395,72 +401,71 @@ Annotator.Plugin.Share = (function(_super) { ...@@ -395,72 +401,71 @@ Annotator.Plugin.Share = (function(_super) {
}); });
} }
} }
//variable for text // variable for text
var startOffset = API.startOffset, var startOffset = API.startOffset;
endOffset = API.endOffset; var endOffset = API.endOffset;
//Text Annotation // Text Annotation
if(!isVideo && typeof startOffset!='undefined' && typeof endOffset!='undefined'){ if (!isVideo && typeof startOffset != 'undefined' && typeof endOffset != 'undefined'){
var annotation = { var annotation = {
ranges: [{ ranges: [{
start:decodeURIComponent(API.start), start: decodeURIComponent(API.start),
end:decodeURIComponent(API.end), end: decodeURIComponent(API.end),
startOffset:decodeURIComponent(API.startOffset), startOffset: decodeURIComponent(API.startOffset),
endOffset:decodeURIComponent(API.endOffset), endOffset: decodeURIComponent(API.endOffset),
}], }],
created: new Date().toISOString(), created: new Date().toISOString(),
updated: new Date().toISOString(), updated: new Date().toISOString(),
media: 'text', media: 'text',
text:decodeURIComponent(API.text), text: decodeURIComponent(API.text),
user:decodeURIComponent(API.user) user: decodeURIComponent(API.user)
}; };
//show the annotation // show the annotation
annotator.setupAnnotation(annotation); annotator.setupAnnotation(annotation);
//to change the color // to change the color
$(annotation.highlights).addClass('api'); $(annotation.highlights).addClass('api');
//animate to the annotation // animate to the annotation
$('html,body').animate({ $('html, body').animate({
scrollTop: $(annotation.highlights[0]).offset().top}, scrollTop: $(annotation.highlights[0]).offset().top},
'slow'); 'slow');
} }
} }
} }
//Let know to others API that this plugin is loaded // Let know to others API that this plugin is loaded
annotator.isShareLoaded = true; annotator.isShareLoaded = true;
annotator.publish('shareloaded'); annotator.publish('shareloaded');
} }
Share.prototype.runAPI = function(API) { Share.prototype.runAPI = function(API) {
var self = this; var self = this;
var func = function (annotations){ var func = function(annotations) {
self.runningAPI(annotations,API); self.runningAPI(annotations, API);
self.annotator.unsubscribe("annotationsLoaded",func); self.annotator.unsubscribe("annotationsLoaded", func);
}; };
this.annotator this.annotator
//-- Finished the Annotator DOM // -- Finished the Annotator DOM
.subscribe("annotationsLoaded",func); .subscribe("annotationsLoaded", func);
} }
Share.prototype._isVideo = function(an){ Share.prototype._isVideo = function(an){
//Detect if the annotation is a Open Video Annotation // Detect if the annotation is a Open Video Annotation
var an = an || {} var an = an || {};
rt = an.rangeTime, var rt = an.rangeTime;
isVideo = (typeof an.media!='undefined' && an.media=='video'), var isVideo = (typeof an.media != 'undefined' && an.media == 'video');
hasContainer = (typeof an.target!='undefined' && typeof an.target.container!='undefined' ), var hasContainer = (typeof an.target != 'undefined' && typeof an.target.container != 'undefined' );
isNumber = (typeof rt!='undefined' && !isNaN(parseFloat(rt.start)) && isFinite(rt.start) && !isNaN(parseFloat(rt.end)) && isFinite(rt.end)); var isNumber = (typeof rt != 'undefined' && !isNaN(parseFloat(rt.start)) && isFinite(rt.start) && !isNaN(parseFloat(rt.end)) && isFinite(rt.end));
return (isVideo && hasContainer && isNumber); return (isVideo && hasContainer && isNumber);
} }
Share.prototype._isImage = function(annotation){ Share.prototype._isImage = function(annotation) {
return annotation.media === 'image'; return annotation.media === 'image';
} }
Share.prototype.getParameterByName = function(name) { Share.prototype.getParameterByName = function(name) {
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]"); name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), var regex = new RegExp("[\\?&]" + name + "=([^&#]*)");
//results = regex.exec(location.search), var results = regex.exec('?' + window.location.href.split('?')[1]);
results = regex.exec('?'+window.location.href.split('?')[1]); return results == null ? "" : decodeURIComponent(results[1].replace(/\ + /g, " "));
return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}; };
Share.prototype.removeVariableFromURL = function(url_string, variable_name) { Share.prototype.removeVariableFromURL = function(url_string, variable_name) {
...@@ -474,25 +479,24 @@ Annotator.Plugin.Share = (function(_super) { ...@@ -474,25 +479,24 @@ Annotator.Plugin.Share = (function(_super) {
return URL; return URL;
} }
Share.prototype.getAnnotationFromId = function(ovaId){ Share.prototype.getAnnotationFromId = function(ovaId) {
var annotationList = this.annotator.plugins.Store.annotations; var annotationList = this.annotator.plugins.Store.annotations;
return $.grep(annotationList, function(elementOfArray, indexInArray){ return $.grep(annotationList, function(elementOfArray, indexInArray){
return parseInt(elementOfArray.id) === parseInt(ovaId.nodeValue); return parseInt(elementOfArray.id, 10) === parseInt(ovaId.nodeValue, 10);
})[0]; })[0];
} }
Share.prototype.updateViewer = function(field, annotation) { Share.prototype.updateViewer = function(field, annotation) {
this.annotation = annotation; this.annotation = annotation;
var self = this, var self = this;
field = $(field), var field = $(field);
ret = field.addClass('share-viewer-annotator').html(function() { var ret = field.addClass('share-viewer-annotator').html(function() {
var string; return self.buildHTMLShareButton('Share:', self.getSource('ovaId'));
return self.buildHTMLShareButton('Share:',self.getSource('ovaId'));
}); });
//Create the actions for the buttons // Create the actions for the buttons
this.buttonsActions(field[0],1,this.options.baseUrl, annotation); //1 is the method of the API that will be for share some annotation in the database this.buttonsActions(field[0], 1, this.options.baseUrl, annotation); // 1 is the method of the API that will be for share some annotation in the database
return ret; return ret;
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment