Commit 4ce70630 by lduarte1991

Annotation Tools: Fixing Share Indentation, Grep Functions and Equality

parent eace1413
...@@ -60,7 +60,6 @@ Annotator.Plugin.Share = (function(_super) { ...@@ -60,7 +60,6 @@ Annotator.Plugin.Share = (function(_super) {
Share.prototype.input = null; Share.prototype.input = null;
Share.prototype.pluginInit = function() { Share.prototype.pluginInit = function() {
console.log("Share-pluginInit");
//Check that annotator is working //Check that annotator is working
if (!Annotator.supported()) { if (!Annotator.supported()) {
return; return;
...@@ -136,22 +135,22 @@ Annotator.Plugin.Share = (function(_super) { ...@@ -136,22 +135,22 @@ Annotator.Plugin.Share = (function(_super) {
}); });
// Share button // Share button
$(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, 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, annotation); 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();
//build buttons //build buttons
$(this).parent().find('.share-popup-items').html(share.buildHTMLPopup(title)); $(this).parent().find('.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) {
$(_field).parent().find('.share-'+item+'-annotator.share-button').click(function() { $(_field).parent().find('.share-'+item+'-annotator.share-button').click(function() {
...@@ -245,7 +244,6 @@ Annotator.Plugin.Share = (function(_super) { ...@@ -245,7 +244,6 @@ Annotator.Plugin.Share = (function(_super) {
}; };
Share.prototype.initAPI = function() { Share.prototype.initAPI = function() {
console.log("initAPI");
// -- 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
...@@ -293,7 +291,6 @@ Annotator.Plugin.Share = (function(_super) { ...@@ -293,7 +291,6 @@ Annotator.Plugin.Share = (function(_super) {
return API; return API;
} }
Share.prototype.runningAPI = function (annotations,API){ Share.prototype.runningAPI = function (annotations,API){
console.log("runningAPI");
var wrapper = $('.annotator-wrapper').parent()[0], var wrapper = $('.annotator-wrapper').parent()[0],
mplayer, mplayer,
osda, osda,
...@@ -332,10 +329,11 @@ Annotator.Plugin.Share = (function(_super) { ...@@ -332,10 +329,11 @@ Annotator.Plugin.Share = (function(_super) {
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({scrollTop: $("#"+an.target.container).offset().top},'slow');},250 $('html,body').animate({
); scrollTop: $("#"+an.target.container).offset().top
},'slow');
},250);
}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:'';
...@@ -452,14 +450,14 @@ Annotator.Plugin.Share = (function(_super) { ...@@ -452,14 +450,14 @@ Annotator.Plugin.Share = (function(_super) {
} }
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), //results = regex.exec(location.search),
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, " "));
}; };
...@@ -476,13 +474,9 @@ Annotator.Plugin.Share = (function(_super) { ...@@ -476,13 +474,9 @@ Annotator.Plugin.Share = (function(_super) {
Share.prototype.getAnnotationFromId = function(ovaId){ Share.prototype.getAnnotationFromId = function(ovaId){
var annotationList = this.annotator.plugins.Store.annotations; var annotationList = this.annotator.plugins.Store.annotations;
var value = undefined; return $.grep(annotationList, function(elementOfArray, indexInArray){
$.each(annotationList, function(key, val){ return parseInt(elementOfArray.id) === parseInt(ovaId.nodeValue);
if(val.id == ovaId.nodeValue){ })[0];
value = val;
}
});
return value;
} }
Share.prototype.updateViewer = function(field, annotation) { Share.prototype.updateViewer = function(field, annotation) {
......
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