Commit 28f5ed1c by lduarte1991

Annotations Tools: Sharing Plugin Fixed with Proper URI

parent 3c37b972
...@@ -1013,6 +1013,9 @@ OpenSeadragonAnnotation = function (element, options) { ...@@ -1013,6 +1013,9 @@ OpenSeadragonAnnotation = function (element, options) {
//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
this.annotator.osda = this;
function reloadEditor(){ function reloadEditor(){
tinymce.EditorManager.execCommand('mceRemoveEditor',true, "annotator-field-0"); tinymce.EditorManager.execCommand('mceRemoveEditor',true, "annotator-field-0");
......
...@@ -846,7 +846,6 @@ CatchAnnotation.prototype = { ...@@ -846,7 +846,6 @@ CatchAnnotation.prototype = {
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);
osda.viewer.viewport.fitBounds(bounds, false); osda.viewer.viewport.fitBounds(bounds, false);
console.log(an.target.container);
$('html,body').animate({scrollTop: $("#"+an.target.container).offset().top}, $('html,body').animate({scrollTop: $("#"+an.target.container).offset().top},
'slow'); 'slow');
//signifies a selected annotation once OSD has zoomed in on the //signifies a selected annotation once OSD has zoomed in on the
......
...@@ -119,7 +119,7 @@ Annotator.Plugin.Share = (function(_super) { ...@@ -119,7 +119,7 @@ Annotator.Plugin.Share = (function(_super) {
} }
//Create the actions for the buttons //Create the actions for the buttons
Share.prototype.buttonsActions = function(field,method,url) { 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
...@@ -138,11 +138,11 @@ Annotator.Plugin.Share = (function(_super) { ...@@ -138,11 +138,11 @@ Annotator.Plugin.Share = (function(_super) {
$(field).find('.share-button-annotator.share-button').click(function() { $(field).find('.share-button-annotator.share-button').click(function() {
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
var _field = this, var _field = this,
ovaId = $(this).attr('annotationId'), ovaId = annotation.id,
title = method == 1?'Share':'Share without saving'; title = method == 1?'Share':'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); share.uri = share.createAPIURL(method,ovaId,url, annotation);
//display your popup //display your popup
$(this).parent().find('.share-popup-overlay-bg').show(); $(this).parent().find('.share-popup-overlay-bg').show();
...@@ -154,7 +154,7 @@ Annotator.Plugin.Share = (function(_super) { ...@@ -154,7 +154,7 @@ Annotator.Plugin.Share = (function(_super) {
if (typeof share.options.shareIn!='undefined'){ if (typeof share.options.shareIn!='undefined'){
share.options.shareIn.forEach(function(item) { share.options.shareIn.forEach(function(item) {
$(_field).parent().find('.share-'+item+'-annotator.share-button').click(function() { $(_field).parent().find('.share-'+item+'-annotator.share-button').click(function() {
var url = share.createAPIURL(method,ovaId,url), var url = share.createAPIURL(method,ovaId,url, annotation),
title = "Sharing a annotation with Open Video Annotation"; title = "Sharing a annotation with Open Video Annotation";
link = encodeURIComponent(url), link = encodeURIComponent(url),
noteText = share.getSource('ovaText'), noteText = share.getSource('ovaText'),
...@@ -174,12 +174,12 @@ Annotator.Plugin.Share = (function(_super) { ...@@ -174,12 +174,12 @@ Annotator.Plugin.Share = (function(_super) {
}; };
Share.prototype.createAPIURL = function(method,ovaId,url) { Share.prototype.createAPIURL = function(method,ovaId,url, annotation) {
var annotator = this.annotator, var annotator = this.annotator,
editor = annotator.editor, editor = annotator.editor,
method = method || 1, method = method || 1,
//url = location.protocol + '//' + location.host + location.pathname, //url = location.protocol + '//' + location.host + location.pathname,
url = url || window.location.href; url = annotation.uri || window.location.href;
url += (url.indexOf('?') >= 0)?'&':'?'; url += (url.indexOf('?') >= 0)?'&':'?';
...@@ -327,21 +327,13 @@ Annotator.Plugin.Share = (function(_super) { ...@@ -327,21 +327,13 @@ Annotator.Plugin.Share = (function(_super) {
}); });
} }
} }
}else if(self._isVideo(an)){//It is a OpenSeaDragon Annotation }else if(self._isImage(an)){//It is a OpenSeaDragon Annotation
if (typeof mplayer[an.target.container]!='undefined'){ var bounds = new OpenSeadragon.Rect(an.bounds.x, an.bounds.y, an.bounds.width, an.bounds.height);
var player = mplayer[an.target.container]; osda.viewer.viewport.fitBounds(bounds, false);
if (player.id_ == an.target.container){ $('html,body').animate({scrollTop: $("#"+an.target.container).offset().top},
var anFound = an; 'slow');
videojs(player.id_).ready(function(){
if (player.techName != 'Youtube'){
player.preload('auto');
}
player.autoPlayAPI = anFound;
player.play();
});
}
}
}else{//It is a text }else{//It is a text
self._isImage(an);
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:'', startOffset = hasRanges?an.ranges[0].startOffset:'',
endOffset = hasRanges?an.ranges[0].endOffset:''; endOffset = hasRanges?an.ranges[0].endOffset:'';
...@@ -457,6 +449,10 @@ Annotator.Plugin.Share = (function(_super) { ...@@ -457,6 +449,10 @@ Annotator.Plugin.Share = (function(_super) {
return (isVideo && hasContainer && isNumber); return (isVideo && hasContainer && isNumber);
} }
Share.prototype._isImage = function(annotation){
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 + "=([^&#]*)"),
...@@ -486,9 +482,8 @@ Annotator.Plugin.Share = (function(_super) { ...@@ -486,9 +482,8 @@ Annotator.Plugin.Share = (function(_super) {
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); //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