# HG changeset patch # User hamidouk # Date 1327594998 -3600 # Node ID 7f189d7b9d5a0f8fea152dda50a1fffbef7ca705 # Parent 958e8d29293cdf51cfed8000dd4f427f21a765b2 updated the player version. diff -r 958e8d29293c -r 7f189d7b9d5a src/ldt/ldt/static/ldt/css/LdtPlayer.css --- a/src/ldt/ldt/static/ldt/css/LdtPlayer.css Wed Jan 25 19:20:55 2012 +0100 +++ b/src/ldt/ldt/static/ldt/css/LdtPlayer.css Thu Jan 26 17:23:18 2012 +0100 @@ -689,6 +689,66 @@ color: #D93C71; } +.Ldt-createAnnotation-Minimize { + position: relative; + float: right; + height: 17px; + width: 17px; + right: 0px; +} + +/* polemic tweet annotation buttons */ +.Ldt-createAnnotation-polemics { + padding-top: 2px; +} + +.Ldt-createAnnotation-polemic-button { + margin: 0; + border: 0; + padding: 0; + margin-right: 2px; + width: 38px; + height: 26px; + text-indent: -999px; + background: url(imgs/polemic_buttons_sprite.png); +} + +.Ldt-createAnnotation-polemic-positive:hover { + background-position: 0 -26px; +} +.Ldt-createAnnotation-polemic-positive.Ldt-createAnnotation-polemic-active { + background-position: 0 -52px; +} + +.Ldt-createAnnotation-polemic-negative { + background-position: -38px 0; +} +.Ldt-createAnnotation-polemic-negative:hover { + background-position: -38px -26px; +} +.Ldt-createAnnotation-polemic-negative.Ldt-createAnnotation-polemic-active { + background-position: -38px -52px; +} + +.Ldt-createAnnotation-polemic-reference { + background-position: -76px 0; +} +.Ldt-createAnnotation-polemic-reference:hover { + background-position: -76px -26px; +} +.Ldt-createAnnotation-polemic-reference.Ldt-createAnnotation-polemic-active { + background-position: -76px -52px; +} + +.Ldt-createAnnotation-polemic-question { + background-position: -114px 0; +} +.Ldt-createAnnotation-polemic-question:hover { + background-position: -114px -26px; +} +.Ldt-createAnnotation-polemic-question.Ldt-createAnnotation-polemic-active { + background-position: -114px -52px; +} /* AnnotationsListWidget */ .Ldt-AnnotationsListWidget { @@ -715,6 +775,10 @@ background-color: #e9e9e9; } +.Ldt-AnnotationsListWidget li a { + text-decoration: none; +} + .Ldt-AnnotationsList-Caption { float: left; display: table-cell; @@ -734,3 +798,13 @@ display: table-cell; width: 80%; } + +/* Tagcloud */ + +.Ldt-TagCloud ul { + list-style: none; padding: 0; margin: 5px; text-align: center; +} + +.Ldt-TagCloud li { + display: inline-block; margin: 2px; +} diff -r 958e8d29293c -r 7f189d7b9d5a src/ldt/ldt/static/ldt/css/imgs/polemic_buttons_sprite.png Binary file src/ldt/ldt/static/ldt/css/imgs/polemic_buttons_sprite.png has changed diff -r 958e8d29293c -r 7f189d7b9d5a src/ldt/ldt/static/ldt/js/LdtPlayer-release.js --- a/src/ldt/ldt/static/ldt/js/LdtPlayer-release.js Wed Jan 25 19:20:55 2012 +0100 +++ b/src/ldt/ldt/static/ldt/js/LdtPlayer-release.js Thu Jan 26 17:23:18 2012 +0100 @@ -1,7 +1,7 @@ /* * - * Copyright 2010 Institut de recherche et d'innovation - * contributor(s) : Samuel Huron + * Copyright 2010-2012 Institut de recherche et d'innovation + * contributor(s) : Karim Hamidou, Samuel Huron * * contact@iri.centrepompidou.fr * http://www.iri.centrepompidou.fr @@ -1085,9 +1085,9 @@ IriSP.annotation_template = "{{! template for an annotation displayed in a segmentWidget }}
"; IriSP.annotationWidget_template = "{{! template for the annotation widget }}
share on facebook share on twitter share on google+
"; IriSP.annotation_loading_template = "{{! template shown while the annotation widget is loading }}
 
Chargement...
"; -IriSP.annotationsListWidget_template = "{{! template for the annotation list widget }}
"; +IriSP.annotationsListWidget_template = "{{! template for the annotation list widget }}
"; IriSP.arrowWidget_template = "
"; -IriSP.createAnnotationWidget_template = "{{! template for the annotation creation widget }}
Add keywords :
Submit
"; +IriSP.createAnnotationWidget_template = "{{! template for the annotation creation widget }}
{{^cinecast_version}} Cancel {{/cinecast_version}}
Add keywords :
{{#polemic_mode}}
Add polemic keywords
{{/polemic_mode}}
Submit
"; IriSP.createAnnotationWidget_festivalCinecast_template = "{{! template for the annotation creation widget specific for the cinecast festival}}
Add keywords :
Submit
"; IriSP.createAnnotation_errorMessage_template = "

You must enter text to submit an annotation

"; IriSP.overlay_marker_template = "{{! the template for the small bars which is z-indexed over our segment widget }}
"; @@ -1098,208 +1098,7 @@ IriSP.sliderWidget_template = "{{! template for the slider widget - it's composed of two divs we one overlayed on top of the other }}
"; IriSP.tooltip_template = "{{! template used by the jquery ui tooltip }}
{{title}}
{{begin}} : {{end}}
{{description}}
"; IriSP.tooltipWidget_template = "{{! template for the tooltip widget }}
"; -IriSP.tweetWidget_template = "{{! template for the tweet widget }}
";/* wrapper that simulates popcorn.js because - popcorn is a bit unstable at the time */ - -IriSP.PopcornReplacement = { - msgPump : {} /* used by jquery to receive and send messages */, - __delay_seek_signal : false -}; - -IriSP.PopcornReplacement.media = { - "paused": true, - "muted": false -}; - -IriSP.PopcornReplacement.listen = function(msg, callback) { -// IriSP.jQuery(IriSP.PopcornReplacement.msgPump).bind(msg, function(event, rest) { callback(rest); }); - if (!IriSP.PopcornReplacement.msgPump.hasOwnProperty(msg)) - IriSP.PopcornReplacement.msgPump[msg] = []; - - IriSP.PopcornReplacement.msgPump[msg].push(callback); -}; - -IriSP.PopcornReplacement.trigger = function(msg, params) { -// IriSP.jQuery(IriSP.PopcornReplacement.msgPump).trigger(msg, params); - - if (!IriSP.PopcornReplacement.msgPump.hasOwnProperty(msg)) - return; - - var d = IriSP.PopcornReplacement.msgPump[msg]; - - for(var i = 0; i < d.length; i++) { - d[i].call(window, params); - } - -}; - -IriSP.PopcornReplacement.guid = function(prefix) { - var str = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { - var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8); - return v.toString(16); - }); - - return prefix + str; -}; - -IriSP.PopcornReplacement.__initApi = function() { - IriSP.PopcornReplacement.trigger("loadedmetadata"); // we've done more than loading metadata of course, - // but popcorn doesn't need to know more. - IriSP.PopcornReplacement.media.muted = jwplayer(IriSP.PopcornReplacement._container).getMute(); - - /* some programmed segments are supposed to be run at the beginning */ - var i = 0; - for(i = 0; i < IriSP.PopcornReplacement.__codes.length; i++) { - var c = IriSP.PopcornReplacement.__codes[i]; - if (0 == c.start) { - c.onStart(); - } - - if (0 == c.end) { - c.onEnd(); - } - } -}; - -IriSP.PopcornReplacement.jwplayer = function(container, options) { - IriSP.PopcornReplacement._container = container.slice(1); //eschew the '#' - options.events = { - onReady: IriSP.PopcornReplacement.__initApi, - onTime: IriSP.PopcornReplacement.__timeHandler, - onPlay: IriSP.PopcornReplacement.__playHandler, - onPause: IriSP.PopcornReplacement.__pauseHandler, - onSeek: IriSP.PopcornReplacement.__seekHandler - } - - jwplayer(IriSP.PopcornReplacement._container).setup(options); - IriSP.PopcornReplacement.media.duration = options.duration; - return IriSP.PopcornReplacement; -}; - -IriSP.PopcornReplacement.currentTime = function(time) { - if (typeof(time) === "undefined") { - return jwplayer(IriSP.PopcornReplacement._container).getPosition(); - } else { - var currentTime = +time; - jwplayer( IriSP.PopcornReplacement._container ).seek( currentTime ); - IriSP.PopcornReplacement.__delay_seek_signal = true; - IriSP.PopcornReplacement.trigger("seeked"); - return currentTime; - } -}; - -IriSP.PopcornReplacement.play = function() { - IriSP.PopcornReplacement.media.paused = false; - IriSP.PopcornReplacement.trigger("play"); -// IriSP.PopcornReplacement.trigger("playing"); - jwplayer( IriSP.PopcornReplacement._container ).play(); -}; - -IriSP.PopcornReplacement.pause = function() { - if ( !IriSP.PopcornReplacement.media.paused ) { - IriSP.PopcornReplacement.media.paused = true; - IriSP.PopcornReplacement.trigger( "pause" ); - jwplayer( IriSP.PopcornReplacement._container ).pause(); - } -}; - -IriSP.PopcornReplacement.muted = function(val) { - if (typeof(val) !== "undefined") { - - if (jwplayer(IriSP.PopcornReplacement._container).getMute() !== val) { - if (val) { - jwplayer(IriSP.PopcornReplacement._container).setMute(true); - IriSP.PopcornReplacement.media.muted = true; - } else { - jwplayer( IriSP.PopcornReplacement._container ).setMute(false); - IriSP.PopcornReplacement.media.muted = false; - } - - IriSP.PopcornReplacement.trigger( "volumechange" ); - } - - return jwplayer( IriSP.PopcornReplacement._container ).getMute(); - } else { - return jwplayer( IriSP.PopcornReplacement._container ).getMute(); - } -}; - -IriSP.PopcornReplacement.mute = IriSP.PopcornReplacement.muted; - -IriSP.PopcornReplacement.__codes = []; -IriSP.PopcornReplacement.code = function(options) { - IriSP.PopcornReplacement.__codes.push(options); - return IriSP.PopcornReplacement; -}; - -/* called everytime the player updates itself - (onTime event) - */ - -IriSP.PopcornReplacement.__timeHandler = function(event) { - var pos = event.position; - - var i = 0; - for(i = 0; i < IriSP.PopcornReplacement.__codes.length; i++) { - var c = IriSP.PopcornReplacement.__codes[i]; - - if (pos >= c.start && pos < c.end && - pos - 1 <= c.start) { - c.onStart(); - } - - if (pos > c.start && pos > c.end && - pos - 1 <= c.end) { - c.onEnd(); - } - - } - - IriSP.PopcornReplacement.trigger("timeupdate"); -}; - -IriSP.PopcornReplacement.__seekHandler = function(event) { - var i = 0; - - for(i = 0; i < IriSP.PopcornReplacement.__codes.length; i++) { - var c = IriSP.PopcornReplacement.__codes[i]; - - if (event.position >= c.start && event.position < c.end) { - c.onEnd(); - } - } - - for(i = 0; i < IriSP.PopcornReplacement.__codes.length; i++) { - var c = IriSP.PopcornReplacement.__codes[i]; - - if (typeof(event.offset) === "undefined") - event.offset = 0; - - if (event.offset >= c.start && event.offset < c.end) { - c.onStart(); - } - - } - - IriSP.PopcornReplacement.trigger("timeupdate"); -}; - - -IriSP.PopcornReplacement.__playHandler = function(event) { - IriSP.PopcornReplacement.media.paused = false; - IriSP.PopcornReplacement.trigger("play"); -}; - -IriSP.PopcornReplacement.__pauseHandler = function(event) { - IriSP.PopcornReplacement.media.paused = true; - IriSP.PopcornReplacement.trigger("pause"); -}; - -IriSP.PopcornReplacement.roundTime = function() { - var currentTime = IriSP.PopcornReplacement.currentTime(); - return Math.round(currentTime); -}; -/* utils.js - various utils that don't belong anywhere else */ +IriSP.tweetWidget_template = "{{! template for the tweet widget }}
";/* utils.js - various utils that don't belong anywhere else */ /* trace function, for debugging */ @@ -1450,7 +1249,7 @@ /** returns an url to share on google + */ IriSP.mkGplusUrl = function(url, text) { - return ""; + return "https://plusone.google.com/_/+1/confirm?hl=en&url=" + IriSP.shorten_url(url); }; /** test if a value is null or undefined */ @@ -1482,7 +1281,224 @@ } } */ -/* data.js - this file deals with how the players gets and sends data */ +/* wrapper that simulates popcorn.js because + popcorn is a bit unstable at the time */ + +IriSP.PopcornReplacement = { +}; + +/** base class for our popcorn-compatible players. + */ +IriSP.PopcornReplacement.player = function(container, options) { + /* the jwplayer calls the callbacks in the global space so we need to + preserve them using IriSP.wrap */ + this.callbacks = { + onReady: IriSP.wrap(this, this.__initApi), + onTime: IriSP.wrap(this, this.__timeHandler), + onPlay: IriSP.wrap(this, this.__playHandler), + onPause: IriSP.wrap(this, this.__pauseHandler), + onSeek: IriSP.wrap(this, this.__seekHandler) + }; + + this.media = { + "paused": true, + "muted": false + }; + + this.container = container.slice(1); //eschew the '#' + + this.msgPump = {}; /* dictionnary used to receive and send messages */ + this.__codes = []; /* used to schedule the execution of a piece of code in + a segment (similar to the popcorn.code plugin). */ + +}; + +IriSP.PopcornReplacement.player.prototype.listen = function(msg, callback) { + if (!this.msgPump.hasOwnProperty(msg)) + this.msgPump[msg] = []; + + this.msgPump[msg].push(callback); +}; + +IriSP.PopcornReplacement.player.prototype.trigger = function(msg, params) { + if (!this.msgPump.hasOwnProperty(msg)) + return; + + var d = this.msgPump[msg]; + + for(var i = 0; i < d.length; i++) { + d[i].call(window, params); + } + +}; + +IriSP.PopcornReplacement.player.prototype.guid = function(prefix) { + var str = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { + var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8); + return v.toString(16); + }); + + return prefix + str; +}; + +/** init the api after that flash player has been setup - called by the callback + defined by the embedded flash player +*/ +IriSP.PopcornReplacement.player.prototype.__initApi = function() { + this.trigger("loadedmetadata"); // we've done more than loading metadata of course, + // but popcorn doesn't need to know more. + this.media.muted = this.playerFns.getMute(); + /* some programmed segments are supposed to be run at the beginning */ + var i = 0; + for(i = 0; i < this.__codes.length; i++) { + var c = this.__codes[i]; + if (0 == c.start) { + c.onStart(); + } + + if (0 == c.end) { + c.onEnd(); + } + } +}; + +/* +IriSP.PopcornReplacement.jwplayer = function(container, options) { + IriSP.PopcornReplacement._container = container.slice(1); //eschew the '#' + options.events = { + onReady: IriSP.PopcornReplacement.__initApi, + onTime: IriSP.PopcornReplacement.__timeHandler, + onPlay: IriSP.PopcornReplacement.__playHandler, + onPause: IriSP.PopcornReplacement.__pauseHandler, + onSeek: IriSP.PopcornReplacement.__seekHandler + } + + jwplayer(IriSP.PopcornReplacement._container).setup(options); + IriSP.PopcornReplacement.media.duration = options.duration; + return IriSP.PopcornReplacement; +}; +*/ + +IriSP.PopcornReplacement.player.prototype.currentTime = function(time) { + if (typeof(time) === "undefined") { + return this.playerFns.getPosition(); + } else { + var currentTime = +time; + this.playerFns.seek( currentTime ); + return currentTime; + } +}; + +IriSP.PopcornReplacement.player.prototype.play = function() { + this.media.paused = false; + this.trigger("play"); + //IriSP.PopcornReplacement.trigger("playing"); + this.playerFns.play(); +}; + +IriSP.PopcornReplacement.player.prototype.pause = function() { + if ( !this.media.paused ) { + this.media.paused = true; + this.trigger( "pause" ); + this.playerFns.pause(); + } +}; + +IriSP.PopcornReplacement.player.prototype.muted = function(val) { + if (typeof(val) !== "undefined") { + + if (this.playerFns.getMute() !== val) { + if (val) { + this.playerFns.setMute(true); + this.media.muted = true; + } else { + this.playerFns.setMute(false); + this.media.muted = false; + } + + this.trigger( "volumechange" ); + } + + return this.playerFns.getMute(); + } else { + return this.playerFns.getMute(); + } +}; + +IriSP.PopcornReplacement.player.prototype.mute = IriSP.PopcornReplacement.player.prototype.muted; + +IriSP.PopcornReplacement.player.prototype.code = function(options) { + this.__codes.push(options); + return this; +}; + +/* called everytime the player updates itself + (onTime event) + */ + +IriSP.PopcornReplacement.player.prototype.__timeHandler = function(event) { + var pos = event.position; + + var i = 0; + for(i = 0; i < this.__codes.length; i++) { + var c = this.__codes[i]; + + if (pos >= c.start && pos < c.end && + pos - 1 <= c.start) { + c.onStart(); + } + + if (pos > c.start && pos > c.end && + pos - 1 <= c.end) { + c.onEnd(); + } + + } + + this.trigger("timeupdate"); +}; + +IriSP.PopcornReplacement.player.prototype.__seekHandler = function(event) { + var i = 0; + + console.log("pos: %d, off: %d", event.position, event.offset); + for(i = 0; i < this.__codes.length; i++) { + var c = this.__codes[i]; + + if (event.position >= c.start && event.position < c.end) { + c.onEnd(); + } + } + + for(i = 0; i < this.__codes.length; i++) { + var c = this.__codes[i]; + + if (typeof(event.offset) === "undefined") + event.offset = 0; + + if (event.offset >= c.start && event.offset < c.end) { + c.onStart(); + } + + } + + this.trigger("seeked"); +}; + +IriSP.PopcornReplacement.player.prototype.__playHandler = function(event) { + this.media.paused = false; + this.trigger("play"); +}; + +IriSP.PopcornReplacement.player.prototype.__pauseHandler = function(event) { + this.media.paused = true; + this.trigger("pause"); +}; + +IriSP.PopcornReplacement.player.prototype.roundTime = function() { + var currentTime = this.currentTime(); + return Math.round(currentTime); +};/* data.js - this file deals with how the players gets and sends data */ IriSP.DataLoader = function() { this._cache = {}; @@ -1637,7 +1653,13 @@ minimize_period: 850 // how long does the slider stays maximized after the user leaves the zone ? }, "createAnnotationWidget" : { - keywords: ["#faux-raccord", "#mot-clef"], + keywords: ["#faux-raccord", "#mot-clef"], + polemic_mode: true, /* enable polemics ? */ + /* polemics - the corresponding class names defined in the css should be for instance : + Ldt-createAnnotation-polemic-positive for positive + Ldt-createAnnotation-polemic-reference for reference, etc. + */ + polemics: {"++" : "positive", "--" : "negative", "==" : "reference", "??" : "question"}, cinecast_version: true /* put to false to enable the platform version, true for the festival cinecast one. */ }, "SparklineWidget" : { @@ -1655,8 +1677,11 @@ where to get the ajax */ - ajax_granularity: 10000 /* how much ms should we look before and after the + ajax_granularity: 10000, /* how much ms should we look before and after the current timecode */ + project_url: IriSP.platform_url + "/ldtplatform/ldt/front/player/" /* the beginning + of a link to the + new front */ }, }; @@ -2001,14 +2026,15 @@ delete opts.container; delete opts.type; - if (options.provider === "rtmp") { + + /* Try to guess options.file and options.streamer only if file and streamer + are not already defined in the configuration */ + if (options.provider === "rtmp" && !opts.hasOwnProperty("file") && !opts.hasOwnProperty("streamer")) { /* exit if we can't access the metadata */ if (typeof(IriSP.__jsonMetadata) === "undefined") { break; }; - - // the json format is totally illogical //opts.streamer = IriSP.__jsonMetadata["medias"][0]["meta"]["item"]["value"]; //var source = IriSP.__jsonMetadata["medias"][0]["href"]; @@ -2035,8 +2061,7 @@ if (i < pathSplit.length - 1) opts.file += "/"; } - } - + } } else { /* other providers type, video for instance - pass everything as is */ @@ -2050,7 +2075,7 @@ opts["controlbar.position"] = "none"; } - pop = IriSP.PopcornReplacement.jwplayer("#" + containerDiv, opts); + pop = new IriSP.PopcornReplacement.jwplayer("#" + containerDiv, opts); break; case "youtube": @@ -2066,6 +2091,11 @@ pop = Popcorn.youtube("#" + containerDiv, opts.video, opts); break; + case "allocine": + /* pass the options as-is to the allocine player and let it handle everything */ + pop = new IriSP.PopcornReplacement.allocine("#" + containerDiv, options); + break; + default: pop = undefined; }; @@ -2156,6 +2186,33 @@ serializer.sync(IriSP.wrap(widget, function() { this.draw(); })); return widget; }; +/* To wrap a player the develop should create a new class derived from + the IriSP.PopcornReplacement.player and defining the correct functions */ + +/** jwplayer player wrapper */ +IriSP.PopcornReplacement.jwplayer = function(container, options) { + + /* appel du parent pour initialiser les structures communes à tous les players */ + IriSP.PopcornReplacement.player.call(this, container, options); + + this.media.duration = options.duration; /* optional */ + + /* Définition des fonctions de l'API - */ + this.playerFns = { + play: function() { return jwplayer(this.container).play(); }, + pause: function() { return jwplayer(this.container).pause(); }, + getPosition: function() { return jwplayer(this.container).getPosition(); }, + seek: function(pos) { return jwplayer(this.container).seek(pos); }, + getMute: function() { return jwplayer(this.container).getMute() }, + setMute: function(p) { return jwplayer(this.container).setMute(p); } + } + + options.events = this.callbacks; + + jwplayer(this.container).setup(options); +}; + +IriSP.PopcornReplacement.jwplayer.prototype = new IriSP.PopcornReplacement.player("", {}); /* mediafragment module */ IriSP.MediaFragment = function(Popcorn, config, Serializer) { @@ -2257,6 +2314,7 @@ this.__oldList = []; this.ajax_mode = IriSP.widgetsDefaults["AnnotationsListWidget"].ajax_mode; + this.project_url = IriSP.widgetsDefaults["AnnotationsListWidget"].project_url; }; @@ -2374,10 +2432,11 @@ var view_types = serializer.getIds("Contributions"); var l = []; + var media = this._serializer.currentMedia()["id"]; + for (i = 0; i < annotations.length; i++) { var annotation = annotations[i]; - console.log(annotation); - console.log(view_types, annotation.meta["id-ref"]); + /* filter the annotations whose type is not the one we want */ /* We want _all_ the annotations. if (typeof(annotation.meta) !== "undefined" && typeof(annotation.meta["id-ref"]) !== "undefined" @@ -2393,14 +2452,37 @@ obj["desc"] = a.content.description; obj["begin"] = IriSP.msToTime(annotation.begin); obj["end"] = IriSP.msToTime(annotation.end); - obj["url"] = document.location.href.split("#")[0] + "/" + annotation.meta["project"]; + + /* only if the annotation isn't present in the document create an + external link */ + if (!this.annotations_ids.hasOwnProperty(obj["id"])) { + // braindead url; jacques didn't want to create a new one in the platform, + // so we append the cutting id to the url. + obj["url"] = this.project_url + "/" + media + "/" + + annotation.meta["project"] + "/" + + annotation.meta["id-ref"] + "/"; + + // obj["url"] = document.location.href.split("#")[0] + "/" + annotation.meta["project"]; + } + l.push(obj); } - console.log(l); + this.do_redraw(l); }; IriSP.AnnotationsListWidget.prototype.draw = function() { - + + /* build a table of the annotations present in the document for faster + lookup + */ + this.annotations_ids = {}; + + var annotations = this._serializer._data.annotations; + var i = 0; + for(i = 0; i < annotations.length; i++) { + this.annotations_ids[annotations[i]["id"]] = 1; + } + this.drawList(); if (!this.ajax_mode) { @@ -2605,6 +2687,10 @@ IriSP.Widget.call(this, Popcorn, config, Serializer); this._hidden = true; this.keywords = IriSP.widgetsDefaults["createAnnotationWidget"].keywords; + + this.polemic_mode = IriSP.widgetsDefaults["createAnnotationWidget"].polemic_mode; + this.polemics = IriSP.widgetsDefaults["createAnnotationWidget"].polemics; + this.cinecast_version = IriSP.widgetsDefaults["createAnnotationWidget"].cinecast_version; this.ids = {}; /* a dictionnary linking buttons ids to keywords */ @@ -2627,7 +2713,9 @@ IriSP.createAnnotationWidget.prototype.draw = function() { var _this = this; - var annotationMarkup = IriSP.templToHTML(IriSP.createAnnotationWidget_template); + var annotationMarkup = IriSP.templToHTML(IriSP.createAnnotationWidget_template, + {cinecast_version: this.cinecast_version, + polemic_mode: this.polemic_mode}); this.selector.append(annotationMarkup); @@ -2661,10 +2749,43 @@ // change in a textfield. _this.selector.find(".Ldt-createAnnotation-Description").trigger("js_mod"); // also call our update function. - _this.handleTextChanges(); + //_this.handleTextChanges(); } }(keyword)); } + + // add the polemic buttons. + if(this.polemic_mode) + for (var polemic in this.polemics) { + + var classname = IriSP.templToHTML("Ldt-createAnnotation-polemic-{{classname}}", {classname : this.polemics[polemic]}); + + var templ = IriSP.templToHTML("", + {classname: classname, polemic: polemic}); + + this.selector.find(".Ldt-createAnnotation-polemics").append(templ); + this.selector.find("." + classname).click(function(polemic) { return function() { + var contents = _this.selector.find(".Ldt-createAnnotation-Description").val(); + if (contents.indexOf(polemic) != -1) { + var newVal = contents.replace(" " + polemic, ""); + if (newVal == contents) + newVal = contents.replace(polemic, ""); + } else { + if (contents === "") + var newVal = polemic; + else + var newVal = contents + " " + polemic; + } + + _this.selector.find(".Ldt-createAnnotation-Description").val(newVal); + // we use a custom event because there's no simple way to test for a js + // change in a textfield. + _this.selector.find(".Ldt-createAnnotation-Description").trigger("js_mod"); + // also call our update function. + _this.handleTextChanges(); + } + }(polemic)); + } this.selector.find(".Ldt-createAnnotation-Description") .bind("propertychange keyup input paste", IriSP.wrap(this, this.handleTextChanges)); @@ -2699,6 +2820,7 @@ code = {start: annotation.begin / 1000, end: annotation.end / 1000, onStart: function(annotation) { return function() { + console.log("runned ?", annotation); if (typeof(annotation.content) !== "undefined") _this.selector.find(".Ldt-createAnnotation-Title").html(annotation.content.title); @@ -2716,9 +2838,20 @@ this.selector.find(".Ldt-createAnnotation-submitButton").click(IriSP.wrap(this, this.handleButtonClick)); - if (!this.cinecast_version) + if (!this.cinecast_version) { this._Popcorn.listen("IriSP.PlayerWidget.AnnotateButton.clicked", - IriSP.wrap(this, this.handleAnnotateSignal)); + IriSP.wrap(this, this.handleAnnotateSignal)); + + // handle clicks on the cancel button too. + this.selector.find(".Ldt-createAnnotation-Minimize").click(IriSP.wrap(this, + function() { + // we've got to simulate the pressing of the button because there's no + // other way to minimize the widget and show the widgets that were hidden + // same time + this._Popcorn.trigger("IriSP.PlayerWidget.AnnotateButton.clicked"); + } + )); + } }; /** handles clicks on the annotate button. Works only for the non-cinecast version */ @@ -2757,6 +2890,14 @@ this._Popcorn.trigger("IriSP.SliceWidget.position", [left, width]); this._Popcorn.listen("IriSP.SliceWidget.zoneChange", IriSP.wrap(this, this.handleSliderChanges)); this._Popcorn.trigger("IriSP.SliceWidget.show"); + + this.selector.find(".Ldt-createAnnotation-Title").html(currentChapter.content.title); + + this._currentcurrentChapter = currentChapter; + var beginTime = IriSP.msToTime(currentChapter.begin); + var endTime = IriSP.msToTime(currentChapter.end); + var timeTemplate = IriSP.templToHTML("- ({{begin}} - {{ end }})", {begin: beginTime, end: endTime }); + this.selector.find(".Ldt-createAnnotation-TimeFrame").html(timeTemplate); } }; @@ -2782,6 +2923,20 @@ } } } + + if (this.polemic_mode) { + /* Also go through the polemics to highlight the buttons */ + for (var polemic in this.polemics) { + /* Add the active class to the button */ + var classname = "Ldt-createAnnotation-polemic-" + this.polemics[polemic]; + if (contents.indexOf(polemic) != -1) { + this.selector.find("." + classname).addClass("Ldt-createAnnotation-polemic-active"); + } else { + if (this.selector.find("." + classname).addClass("Ldt-createAnnotation-polemic-active")) + this.selector.find("." + classname).removeClass("Ldt-createAnnotation-polemic-active") + } + } + } }; IriSP.createAnnotationWidget.prototype.showStartScreen = function() { @@ -2802,7 +2957,7 @@ this.selector.find(".Ldt-createAnnotation-Title").parent().show(); } - var url = document.location.href + "id=" + annotation.id; + var url = document.location.href + "#id=" + annotation.id; var twStatus = IriSP.mkTweetUrl(url); var gpStatus = IriSP.mkGplusUrl(url); var fbStatus = IriSP.mkFbUrl(url);