Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions cms/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,13 @@
],
'output_filename': 'css/cms-style-vendor-tinymce-skin.css',
},
'style-annotator' :{
'source_filenames':[
'css/vendor/ova/annotator.css',
'css/vendor/ova/token-input.css'
],
'output_filename': 'css/lms-style-vendor-ova-annotator.css',
},
'style-app': {
'source_filenames': [
'sass/style-app.css',
Expand Down
55 changes: 55 additions & 0 deletions common/lib/xmodule/xmodule/annotator_mixin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
"""
Annotations Tool Mixin
This file contains global variables and functions used in the various Annotation Tools.
"""
from pkg_resources import resource_string
from lxml import etree
from urlparse import urlparse
from os.path import splitext, basename

def get_instructions(xmltree):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As stated below, I suggest to create a class here and use it later in annotators as mixin.

""" Removes <instructions> from the xmltree and returns them as a string, otherwise None. """
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please write docstring according to edx doc style: https://github.com/edx/edx-platform/wiki/Python-Guidelines

instructions = xmltree.find('instructions')
if instructions is not None:
instructions.tag = 'div'
xmltree.remove(instructions)
return etree.tostring(instructions, encoding='unicode')
return None

def get_extension(srcurl):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will return one of: video/youtube, video/mp4, video/webm, right?

''' get the extension of a given url '''
if 'youtu' in srcurl:
return 'video/youtube'
else:
disassembled = urlparse(srcurl)
file_ext = splitext(basename(disassembled.path))[1]
return 'video/' + file_ext.replace('.', '')

ANNOTATOR_COMMON_JS = [
resource_string(__name__, 'js/src/ova/annotator-full.js'),
resource_string(__name__, 'js/src/ova/annotator-full-firebase-auth.js'),
resource_string(__name__, 'js/src/ova/video.dev.js'),
resource_string(__name__, 'js/src/ova/vjs.youtube.js'),
resource_string(__name__, 'js/src/ova/rangeslider.js'),
resource_string(__name__, 'js/src/ova/share-annotator.js'),
resource_string(__name__, 'js/src/ova/richText-annotator.js'),
resource_string(__name__, 'js/src/ova/reply-annotator.js'),
resource_string(__name__, 'js/src/ova/tags-annotator.js'),
resource_string(__name__, 'js/src/ova/flagging-annotator.js'),
resource_string(__name__, 'js/src/ova/diacritic-annotator.js'),
resource_string(__name__, 'js/src/ova/jquery-Watch.js'),
resource_string(__name__, 'js/src/ova/ova.js'),
resource_string(__name__, 'js/src/ova/catch/js/handlebars-1.1.2.js'),
resource_string(__name__, 'js/src/ova/catch/js/catch.js'),
]

ANNOTATOR_COMMON_CSS = [
resource_string(__name__, 'css/ova/edx-annotator.css'),
resource_string(__name__, 'css/ova/rangeslider.css'),
resource_string(__name__, 'css/ova/share-annotator.css'),
resource_string(__name__, 'css/ova/richText-annotator.css'),
resource_string(__name__, 'css/ova/diacritic-annotator.css'),
resource_string(__name__, 'css/ova/flagging-annotator.css'),
resource_string(__name__, 'css/ova/ova.css'),
resource_string(__name__, 'js/src/ova/catch/css/main.css'),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we have css file inside js directory?

]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No new line at the end of file. Please add it.

8 changes: 8 additions & 0 deletions common/lib/xmodule/xmodule/css/ova/diacritic-annotator.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.mark{
width: 10px;
height: 10px;
position: absolute;
background-size: contain;
background-repeat: no-repeat;
background-position: 50% 0%;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
/*This is written to fix some design problems with edX*/
.annotatable-wrapper .annotatable-header .annotatable-title{
padding-top: 20px !important;
}

.annotator-wrapper .annotator-adder button {
opacity:0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,21 @@
}

.annotator-wrapper .mce-container {
z-index:3000000000!important; /*To fix full-screen problems*/
z-index: 3000000000!important; /*To fix full-screen problems*/
}

.mce-container-body {
min-width: 400px;
}

.iframe[id="annotator-field"] {
width: inherit;
min-width: 400px;
}

div.mce-tinymce.mce-container.mce-panel {
min-width:400px;
}

/* Some change in the design of Annotator */
.annotator-editor .annotator-widget{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,6 @@ CatchAnnotation.prototype = {
var moreBut = this.element.find('.annotationListButtons .moreButtonCatch');
moreBut.html('More');

setTimeout();
},

//
Expand Down Expand Up @@ -1095,11 +1094,10 @@ CatchAnnotation.prototype = {
annotation = item.data('annotation');
var authorized = permissions.options.userAuthorize('delete', annotation,permissions.user);
if(authorized){
//annotator.deleteAnnotation(annotation);
if(confirm('Would you like to delete this reply?')){
annotator.plugins['Store']._apiRequest('destroy', annotation, function(){});
item.remove();
}
}
}
}
}
Expand Down
204 changes: 204 additions & 0 deletions common/lib/xmodule/xmodule/js/src/ova/diacritic-annotator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
/*
Diacritic Annotator Plugin v1.0 (https://github.com/lduarte1991/diacritic-annotator)
Copyright (C) 2014 Luis F Duarte
License: https://github.com/lduarte1991/diacritic-annotator/blob/master/LICENSE.rst

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

var _ref,
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };

Annotator.Plugin.Diacritics = (function(_super) {
__extends(Diacritics, _super);

//Options will include diacritic name, picture used, baseline
Diacritics.prototype.options = null;
Diacritics.prototype.diacriticmarks = null;

//initiate diacritics elements
function Diacritics(element,options) {
this.pluginSubmit = __bind(this.pluginSubmit, this);
this.updateDiacritics = __bind(this.updateDiacritics, this);
this.updateViewer = __bind(this.updateViewer, this);
this.getDiacritics = __bind(this.getDiacritics, this);
this.getPos = __bind(this.getPos, this);
this.putMarkatLocation = __bind(this.putMarkatLocation, this);
this.updateEditorForDiacritics = __bind(this.updateEditorForDiacritics, this);

this.options = options;
this.diacriticmarks = this.getDiacritics();
_ref = Diacritics.__super__.constructor.apply(this, arguments);
return _ref;
}

//example variables to be used to receive input in the annotator view
Diacritics.prototype.field = null;
Diacritics.prototype.input = null;

//this function will initialize the plug in
Diacritics.prototype.pluginInit = function() {
console.log("Diacritics-pluginInit");

//Check that annotator is working
if (!Annotator.supported()) {
return;
}
var di = this.diacriticmarks;

//-- Editor
var self = this;
if(di != 'undefined'){
$.each(di,function(item){
self.field = self.annotator.editor.addField({
type: 'checkbox', //options (textarea,input,select,checkbox)
label: Annotator._t(item),
submit: self.pluginSubmit,
});
});

//-- Viewer
var newview = this.annotator.viewer.addField({
load: this.updateViewer,
});

this.annotator.subscribe('annotationsLoaded', this.updateDiacritics);
this.annotator.subscribe('annotationUploaded', this.updateDiacritics);
this.annotator.subscribe('annotationDeleted', this.updateDiacritics);
this.annotator.subscribe('annotationUpdated', this.updateDiacritics);
this.annotator.subscribe('annotationEditorShown', this.updateEditorForDiacritics, this.field);

var self = this;
$(window).resize(function() {
self.updateDiacritics();
});
}

return this.input = $(this.field).find(':input');
};

//The following function is run when a person hits submit.
Diacritics.prototype.pluginSubmit = function(field, annotation) {
var checkedItems = $(this.field).find(':input');
var self = this;
$.each(checkedItems, function(item){
if(typeof annotation.tags != 'undefined'){
var index = $.inArray(checkedItems[item].placeholder, annotation.tags);
if(index != -1){
annotation.tags.splice(index, 1);
if (typeof $($('.annotator-wrapper')[0]).find('div.'+annotation.id)[0] != 'undefined'){
$($('.annotator-wrapper')[0]).find('div.'+annotation.id)[0].remove();
} else {
$($('.annotator-wrapper')[0]).find('div.undefined')[0].remove();
}
}

if(checkedItems[item].checked == true){
annotation.tags.unshift(checkedItems[item].placeholder);
self.putMarkatLocation(annotation, checkedItems[item].placeholder);
}
} else {
if(checkedItems[item].checked == true){
annotation['tags'] = [checkedItems[item].placeholder];
self.putMarkatLocation(annotation, checkedItems[item].placeholder);
}
}
});

}

Diacritics.prototype.putMarkatLocation = function (annotation, mark){
var loc = this.getPos(annotation.highlights[0]);
var alignment = this.diacriticmarks[mark][1];
var imgurl = this.diacriticmarks[mark][0];

var newdiv = document.createElement('div');
var className = 'mark ' + annotation.id;
newdiv.setAttribute('class',className);
if(alignment == 'top'){
$(newdiv).css('top',""+(loc.y-5)+"px");
} else if(alignment == 'bottom'){
$(newdiv).css('top',""+(loc.y+loc.height-5)+"px");
} else{
$(newdiv).css('top',""+loc.y+"px");
}
$(newdiv).css('left',""+(loc.x+(loc.width/2.0)-5)+"px");
$(newdiv).css('background-image', 'url('+imgurl+')');
$('.annotator-wrapper')[0].appendChild(newdiv);
}

Diacritics.prototype.getDiacritics = function(){
if(typeof this.options.diacritics != 'undefined'){
var self = this;
var final = new Object(), prelim = this.options.diacritics.split(",");
prelim.forEach(function(item){
var temp = item.split(";");
if (temp.length <3) {return undefined;}
final[temp[0]] = [temp[1],temp[2]];
});
return final;
}
console.log("Was undefined");
return undefined;
}

Diacritics.prototype.getPos = function(el) {
var off = $(el).offset();
return {x: off.left-$($('.annotator-wrapper')[0]).offset().left, y: off.top-$($('.annotator-wrapper')[0]).offset().top, width:$(el).width(), height:$(el).height()};
}

Diacritics.prototype.updateDiacritics = function(){
$('.mark').remove();
var annotations = this.annotator.plugins['Store'].annotations;
var self = this;
annotations.forEach(function(ann){
$.each(self.diacriticmarks, function(item){
if($.inArray(item, ann.tags) != -1){
self.putMarkatLocation(ann, item);
}
});
});
}

Diacritics.prototype.updateViewer = function(field,annotation){
$(field).remove();
}

Diacritics.prototype.updateEditorForDiacritics = function(field, annotation){
if (typeof annotation.tags == 'undefined'){
return;
}
var self = this;

var inputItems = $(this.field).find(':input');
var dictOfItems = {}
$.each(inputItems, function(item){
inputItems[item].checked = false;
dictOfItems[inputItems[item].placeholder] = inputItems[item];
});
annotation.tags.forEach(function(tag){
if(typeof self.diacriticmarks[tag] != 'undefined'){
dictOfItems[tag].checked = true;
}
});
}



return Diacritics;

})(Annotator.Plugin);
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// Generated by CoffeeScript 1.6.3
var _ref,
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
__hasProp = {}.hasOwnProperty,
Expand Down Expand Up @@ -101,4 +100,4 @@ Annotator.Plugin.Flagging = (function(_super) {

return Flagging;

})(Annotator.Plugin);
})(Annotator.Plugin);
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Open Video Annotation v1.0 (http://openvideoannotation.org/)
Copyright (C) 2014 CHS (Harvard University), Daniel Cebri�n Robles and Phil Desenne
Copyright (C) 2014 CHS (Harvard University), Daniel Cebrian Robles and Phil Desenne
License: https://github.com/CtrHellenicStudies/OpenVideoAnnotation/blob/master/License.rst

This program is free software; you can redistribute it and/or
Expand Down Expand Up @@ -2389,17 +2389,8 @@ OpenVideoAnnotation.Annotator = function (element, options) {
if (typeof options.optionsAnnotator.highlightTags!='undefined')
this.annotator.addPlugin("HighlightTags", options.optionsAnnotator.highlightTags);


/*
this.annotator.addPlugin("Filter", {
filters: [
{
label: 'Media',
property: 'media'
}
]
});//it is obligatory to have
*/
if (typeof options.optionsAnnotator.diacriticMarks != 'undefined' && typeof Annotator.Plugin["Diacritics"] === 'function')
this.annotator.addPlugin("Diacritics", options.optionsAnnotator.diacriticMarks);

if (typeof Annotator.Plugin["Geolocation"] === 'function')
this.annotator.addPlugin("Geolocation",options.optionsAnnotator.geolocation);
Expand All @@ -2415,7 +2406,7 @@ OpenVideoAnnotation.Annotator = function (element, options) {
if (typeof Annotator.Plugin["Reply"] === 'function')
this.annotator.addPlugin("Reply");

if (typeof Annotator.Plugin["Flagging"] === 'function')
if (typeof Annotator.Plugin["Flagging"] === 'function')
this.annotator.addPlugin("Flagging");

//Will be add the player and the annotations plugin for video-js in the annotator
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
RangeSlider v1.0 (https://github.com/danielcebrian/rangeslider-videojs)
Copyright (C) 2014 Daniel Cebri�n Robles
Copyright (C) 2014 Daniel Cebrian Robles
License: https://github.com/danielcebrian/rangeslider-videojs/blob/master/License.rst

This program is free software; you can redistribute it and/or
Expand Down
Loading