").attr("id", _tmpId));
- jwplayer(_tmpId).setup({
- flashplayer: IriSP.getLib("jwPlayerSWF"),
- file: _audiofile,
- fallback: false,
- primary: "flash",
- controls: false,
- width: 1,
- height: 1,
- events: {
- onPause: function() {
- _this.$.find(".Ldt-AnnotationsList-Play[data-annotation-id=" + _annotation.id + "]").text(_this.l10n.voice_annotation);
- },
- onPlay: function() {
- _this.$.find(".Ldt-AnnotationsList-Play[data-annotation-id=" + _annotation.id + "]").text(_this.l10n.now_playing);
- }
- }
- });
- }
- }
- var _html = Mustache.to_html(_this.annotationTemplate, _data),
- _el = IriSP.jQuery(_html),
- _onselect = function() {
- _this.$.find('.Ldt-AnnotationsList-li').removeClass("selected");
- _el.addClass("selected");
- },
- _onunselect = function() {
- _this.$.find('.Ldt-AnnotationsList-li').removeClass("selected");
- };
+ var _html = Mustache.to_html(_this.annotationTemplate, _data);
+ var _el = IriSP.jQuery(_html);
_el.mouseover(function() {
_annotation.trigger("select");
})
@@ -262,47 +226,35 @@
_annotation.trigger("unselect");
})
.appendTo(_this.list_$);
- IriSP.attachDndData(_el.find("[draggable]"), {
- title: _title,
- description: _description,
- uri: _url,
- image: _annotation.thumbnail
+ _annotation.on("select", function() {
+ _this.annotations_$.removeClass("selected");
+ _el.addClass("selected");
});
- _el.on("remove", function() {
- _annotation.off("select", _onselect);
- _annotation.off("unselect", _onunselect);
- });
- _annotation.on("select", _onselect);
- _annotation.on("unselect", _onunselect);
+ _annotation.on("unselect", function() {
+ _this.annotations_$.removeClass("selected");
+ });;
});
+ this.annotations_$ = this.$.find('.Ldt-AnnotationsList-li');
+
/* Correct the empty tag bug */
this.$.find('.Ldt-AnnotationsList-Tag-Li').each(function() {
var _el = IriSP.jQuery(this);
if (!_el.text().replace(/(^\s+|\s+$)/g,'')) {
- _el.remove();
+ _el.detach();
}
});
this.$.find('.Ldt-AnnotationsList-Tag-Li').click(function() {
- _this.source.getAnnotations().search(IriSP.jQuery(this).text().replace(/(^\s+|\s+$)/g,''));
- });
+ _this.player.popcorn.trigger("IriSP.search.triggeredSearch", IriSP.jQuery(this).text().replace(/(^\s+|\s+$)/g,''));
+ })
- this.$.find(".Ldt-AnnotationsList-Play").click(function() {
- var _el = IriSP.jQuery(this),
- _annid = _el.attr("data-annotation-id");
- if (_this.jwplayers[_annid]) {
- jwplayer(_this.jwplayers[_annid]).play();
- }
- _this.media.pause();
- });
-
- if (this.source.getAnnotations().searching) {
- var rx = _this.source.getAnnotations().regexp || false;
+ if(this.searchString) {
+ var _searchRe = IriSP.Model.regexpFromTextOrArray(this.searchString);
this.$.find(".Ldt-AnnotationsList-Title a, .Ldt-AnnotationsList-Description").each(function() {
var _$ = IriSP.jQuery(this);
- _$.html(IriSP.textFieldHtml(_$.text(), rx));
- });
+ _$.html(_$.text().replace(/(^\s+|\s+$)/g,'').replace(_searchRe, '
$1'))
+ })
}
}
@@ -310,59 +262,26 @@
if (this.mashupMode) {
this.ajaxMashup();
} else {
- if (Math.abs(_currentTime - this.lastAjaxQuery) > (this.ajax_granularity)) {
+ if (Math.abs(_currentTime - this.lastAjaxQuery) > (this.ajax_granularity / 2000)) {
this.ajaxSource();
}
}
}
return _list.length;
-};
+}
IriSP.Widgets.AnnotationsList.prototype.draw = function() {
- this.jwplayers = {};
- this.mashupMode = (this.media.elementType === "mashup");
-
this.renderTemplate();
- var _this = this;
-
this.list_$ = this.$.find(".Ldt-AnnotationsList-ul");
+ this.bindPopcorn("IriSP.search", "onSearch");
+ this.bindPopcorn("IriSP.search.closed", "onSearch");
+ this.bindPopcorn("IriSP.search.cleared", "onSearch");
+ this.bindPopcorn("IriSP.AnnotationsList.refresh","refresh");
- this.source.getAnnotations().on("search", function(_text) {
- _this.searchString = _text;
- if (_this.source !== _this.currentSource) {
- _this.currentSource.getAnnotations().search(_text);
- _this.throttledRefresh();
- }
- });
- this.source.getAnnotations().on("found", function() {
- _this.throttledRefresh();
- });
- this.source.getAnnotations().on("not-found", function() {
- _this.throttledRefresh();
- });
- this.source.getAnnotations().on("clear-search", function() {
- _this.searchString = false;
- if (_this.source !== _this.currentSource) {
- _this.currentSource.getAnnotations().trigger("clear-search");
- }
- });
- this.source.getAnnotations().on("search-cleared", function() {
- _this.throttledRefresh();
- });
-
- this.onMdpEvent("AnnotationsList.refresh", function() {
- if (_this.ajax_url) {
- if (_this.mashupMode) {
- _this.ajaxMashup();
- } else {
- _this.ajaxSource();
- }
- }
- _this.throttledRefresh();
- });
+ var _this = this;
if (this.ajax_url) {
if (this.mashupMode) {
@@ -376,18 +295,18 @@
if (this.refresh_interval) {
window.setInterval(function() {
- _this.currentSource.get();
+ _this.currentSource.get()
}, this.refresh_interval);
}
- this.onMdpEvent("createAnnotationWidget.addedAnnotation");
var _events = [
+ "IriSP.createAnnotationWidget.addedAnnotation",
"timeupdate",
"seeked",
"loadedmetadata"
];
for (var _i = 0; _i < _events.length; _i++) {
- this.onMediaEvent(_events[_i], this.throttledRefresh);
+ this.player.popcorn.listen(_events[_i], this.throttledRefresh);
}
this.throttledRefresh();
diff -r 3ab36f402b0c -r 198c2b79f5e1 src/widgets/Arrow.js
--- a/src/widgets/Arrow.js Thu Jan 02 16:40:25 2014 +0100
+++ b/src/widgets/Arrow.js Thu Jan 02 16:49:20 2014 +0100
@@ -6,25 +6,25 @@
IriSP.Widgets.Arrow.prototype = new IriSP.Widgets.Widget();
IriSP.Widgets.Arrow.prototype.defaults = {
- arrow_height : 12,
- arrow_width : 20,
+ arrow_height : 16,
+ arrow_width : 24,
base_height : 0,
base_curve : 0,
fill_url: IriSP.widgetsDir + '/img/pinstripe.png',
fill_color: "#ffffff", //Gradients can be used, e.g. "90-#000-#fff" for vertical white-to-black
stroke_color: "#b7b7b7",
stroke_width: 1.5,
- animation_speed: 20
-};
+ animation_speed: 20,
+ pilot_widget: "Annotation"
+}
IriSP.Widgets.Arrow.prototype.draw = function() {
this.height = this.arrow_height + this.base_height;
this.$.addClass("Ldt-Arrow").css({
- height: (1+this.height) + "px",
- "margin-top": "1px",
- overflow: "hidden"
+ height: this.height + "px",
+ "margin-top": "1px"
});
- this.paper = new Raphael(this.container, this.width, 1+this.height );
+ this.paper = new Raphael(this.container, this.width, this.height );
window.myArrow = this;
this.svgArrow = this.paper.path('M0,' + this.height + 'L' + this.width + ',' + this.height);
this.svgArrow.attr({
@@ -32,11 +32,14 @@
"stroke-width": this.stroke_width,
fill: this.fill_url ? ( 'url(' + this.fill_url + ')' ) : this.fill_color
});
- this.moveToX(0);
-};
+ this.moveTo(0);
+ this.bindPopcorn("IriSP.Arrow.updatePosition","onUpdatePosition");
+ this.bindPopcorn("IriSP.Arrow.takeover","onTakeover");
+ this.bindPopcorn("IriSP.Arrow.release","onRelease");
+}
IriSP.Widgets.Arrow.prototype.drawAt = function(_x) {
- _x = Math.max(0, Math.min(_x, this.width));
+ _x = Math.floor(Math.max(0, Math.min(_x, this.width)));
var _d = 'M0,' + this.height
+ 'L0,' + Math.min( this.height, this.arrow_height + this.base_curve)
+ 'Q0,' + this.arrow_height
@@ -53,22 +56,18 @@
this.svgArrow.attr({
path: _d
});
-};
+}
-IriSP.Widgets.Arrow.prototype.moveToX = function(_x) {
- this.targetX = Math.max(0, Math.min(_x, this.width));
+IriSP.Widgets.Arrow.prototype.moveTo = function(_x) {
+ this.targetX = Math.floor(Math.max(0, Math.min(_x, this.width)));
if (typeof this.animInterval === "undefined") {
this.animInterval = window.setInterval(
this.functionWrapper("increment"),
40
- );
+ )
}
this.increment();
-};
-
-IriSP.Widgets.Arrow.prototype.moveToTime = function(_t) {
- this.moveToX(this.width * _t / this.media.duration);
-};
+}
IriSP.Widgets.Arrow.prototype.increment = function() {
if (typeof this.currentX === "undefined") {
@@ -85,4 +84,22 @@
this.animInterval = undefined;
}
this.drawAt(this.currentX);
-};
+}
+
+IriSP.Widgets.Arrow.prototype.onUpdatePosition = function(_param) {
+ if (_param.widget === this.current_pilot_widget) {
+ if (typeof _param.x !== "undefined") {
+ this.moveTo(_param.x);
+ } else {
+ this.moveTo(this.width * _param.time / this.source.getDuration());
+ }
+ }
+}
+
+IriSP.Widgets.Arrow.prototype.onTakeover = function(_widget) {
+ this.current_pilot_widget = _widget;
+}
+
+IriSP.Widgets.Arrow.prototype.onRelease = function(_widget) {
+ this.current_pilot_widget = this.pilot_widget;
+}
diff -r 3ab36f402b0c -r 198c2b79f5e1 src/widgets/AutoPlayer.js
--- a/src/widgets/AutoPlayer.js Thu Jan 02 16:40:25 2014 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,76 +0,0 @@
-IriSP.Widgets.AutoPlayer = function(player, config) {
- IriSP.Widgets.Widget.call(this, player, config);
-};
-
-IriSP.Widgets.AutoPlayer.prototype = new IriSP.Widgets.Widget();
-
-IriSP.Widgets.AutoPlayer.prototype.defaults = {
- default_type: "JwpPlayer"
-};
-
-IriSP.Widgets.AutoPlayer.prototype.draw = function() {
-
- if (typeof this.video === "undefined") {
- this.video = this.media.video;
- }
-
- var _props = [ "live", "provider", "autostart", "streamer", "video", "height", "width", "url_transform" ],
- _opts = {},
- _types = [
- {
- regexp: /^rtmp:\/\//,
- type: "JwpPlayer"
- },
- {
- regexp: /\.(mp4|m4v)$/,
- type: "AdaptivePlayer"
- },
- {
- regexp: /\.(ogg|ogv|webm)$/,
- type: "HtmlPlayer"
- },
- {
- regexp: /^(https?:\/\/)?(www\.)?youtube\.com/,
- type: "PopcornPlayer"
- },
- {
- regexp: /^(https?:\/\/)?(www\.)?vimeo\.com/,
- type: "PopcornPlayer"
- },
- {
- regexp: /^(https?:\/\/)?(www\.)?dailymotion\.com/,
- type: "DailymotionPlayer"
- }
- ],
- _rtmprgx = /^rtmp:\/\//;
-
- for (var i = 0; i < _types.length; i++) {
- if (_types[i].regexp.test(this.video)) {
- _opts.type = _types[i].type;
- break;
- }
- }
-
- if (typeof _opts.type === "undefined") {
- _opts.type = this.default_type;
- }
-
- if (_opts.type === "AdaptivePlayer") {
- var _canPlayType = document.createElement('video').canPlayType("video/mp4");
- _opts.type = (_canPlayType == "maybe" || _canPlayType == "probably") ? "HtmlPlayer" : "JwpPlayer";
- }
-
- if (_rtmprgx.test(this.video)) {
- _opts.provider = "rtmp";
- _opts.live = true;
- }
-
- for (var i = 0; i < _props.length; i++) {
- if (typeof this[_props[i]] !== "undefined") {
- _opts[_props[i]] = this[_props[i]];
- }
- }
-
- this.insertSubwidget(this.$, _opts);
-
-};
\ No newline at end of file
diff -r 3ab36f402b0c -r 198c2b79f5e1 src/widgets/Controller.css
--- a/src/widgets/Controller.css Thu Jan 02 16:40:25 2014 +0100
+++ b/src/widgets/Controller.css Thu Jan 02 16:49:20 2014 +0100
@@ -9,7 +9,7 @@
}
.Ldt-Ctrl-Left {
- float:left; width: 300px;
+ float:left;
}
.Ldt-Ctrl-Right {
@@ -82,12 +82,13 @@
}
.Ldt-Ctrl-Search {
- width: 0; float: left; overflow: hidden;
-}
-
-input.Ldt-Ctrl-SearchInput {
- width: 145px; height: 13px; margin: 2px; padding: 3px;
- border: 1px solid #8080a0; border-radius: 3px; font-size: 13px;
+ display: none;
+ width: 165px;
+ height: 25px;
+ border: 1px;
+ border-color: #CFCFCF;
+ float: left;
+ text-align: center;
}
.Ldt-Ctrl-Time {
diff -r 3ab36f402b0c -r 198c2b79f5e1 src/widgets/Controller.js
--- a/src/widgets/Controller.js Thu Jan 02 16:40:25 2014 +0100
+++ b/src/widgets/Controller.js Thu Jan 02 16:49:20 2014 +0100
@@ -1,17 +1,17 @@
/* Displays Play and Pause buttons, Search Button and Form, Volume Control */
IriSP.Widgets.Controller = function(player, config) {
- IriSP.Widgets.Widget.call(this, player, config);
- this.lastSearchValue = "";
+ IriSP.Widgets.Widget.call(this, player, config);
+
+ this._searchLastValue = "";
};
IriSP.Widgets.Controller.prototype = new IriSP.Widgets.Widget();
IriSP.Widgets.Controller.prototype.defaults = {
disable_annotate_btn: false,
- disable_search_btn: false,
- disable_ctrl_f: false
-};
+ disable_search_btn: false
+}
IriSP.Widgets.Controller.prototype.template =
'
'
@@ -56,7 +56,7 @@
annotate: "Annotate",
search: "Search",
elapsed_time: "Elapsed time",
- total_time: "Total duration",
+ total_time: "Total time",
volume: "Volume",
volume_control: "Volume control"
},
@@ -69,7 +69,7 @@
unmute: "Activer le son",
annotate: "Annoter",
search: "Rechercher",
- elapsed_time: "Temps écoulé",
+ elapsed_time: "Durée écoulée",
total_time: "Durée totale",
volume: "Niveau sonore",
volume_control: "Réglage du niveau sonore"
@@ -87,21 +87,25 @@
this.$volumeBar = this.$.find(".Ldt-Ctrl-Volume-Bar");
// handle events
- this.onMediaEvent("play","playButtonUpdater");
- this.onMediaEvent("pause","playButtonUpdater");
- this.onMediaEvent("volumechange","volumeUpdater");
- this.onMediaEvent("timeupdate","timeDisplayUpdater");
- this.onMediaEvent("loadedmetadata","volumeUpdater");
+ this.bindPopcorn("play","playButtonUpdater");
+ this.bindPopcorn("pause","playButtonUpdater");
+ this.bindPopcorn("volumechange","volumeUpdater");
+ this.bindPopcorn("timeupdate","timeDisplayUpdater");
+ this.bindPopcorn("loadedmetadata","timeDisplayUpdater");
+ this.bindPopcorn("loadedmetadata","volumeUpdater");
+ this.bindPopcorn("IriSP.search.matchFound","searchMatch");
+ this.bindPopcorn("IriSP.search.noMatchFound","searchNoMatch");
+ this.bindPopcorn("IriSP.search.triggeredSearch","triggeredSearch");
// handle clicks
this.$playButton.click(this.functionWrapper("playHandler"));
this.$.find(".Ldt-Ctrl-Annotate").click(function() {
- _this.player.trigger("CreateAnnotation.toggle");
+ _this.player.popcorn.trigger("IriSP.CreateAnnotation.toggle");
});
this.$.find(".Ldt-Ctrl-SearchBtn").click(this.functionWrapper("searchButtonHandler"));
- this.$searchInput.keyup(this.functionWrapper("searchHandler"));
+ this.$searchInput.keyup(this.functionWrapper("searchHandler") );
var _volctrl = this.$.find(".Ldt-Ctrl-Volume-Control");
this.$.find('.Ldt-Ctrl-Sound')
@@ -117,28 +121,13 @@
}).mouseout(function() {
_volctrl.hide();
});
-
- // Handle CTRL-F
- if (!this.disable_ctrl_f) {
- var _fKey = "F".charCodeAt(0),
- _lastCtrlFTime = 0;
- IriSP.jQuery(document).keydown(function(_event) {
- if (_event.keyCode === _fKey && (_event.ctrlKey || _event.metaKey)) {
- var _time = IriSP.jQuery.now();
- if (_time - _lastCtrlFTime > 2000) {
- _this.searchButtonHandler();
- }
- _lastCtrlFTime = _time;
- return false;
- }
- });
- }
+
// Allow Volume Cursor Dragging
this.$volumeBar.slider({
slide: function(event, ui) {
_this.$volumeBar.attr("title",_this.l10n.volume+': ' + ui.value + '%');
- _this.media.setVolume(ui.value / 100);
+ _this.player.popcorn.volume(ui.value / 100);
},
stop: this.functionWrapper("volumeUpdater")
});
@@ -146,38 +135,33 @@
// trigger an IriSP.Player.MouseOver to the widgets that are interested (i.e : sliderWidget)
this.$.hover(
function() {
- _this.player.trigger("Player.MouseOver");
+ _this.player.popcorn.trigger("IriSP.Player.MouseOver");
},
function() {
- _this.player.trigger("Player.MouseOut");
+ _this.player.popcorn.trigger("IriSP.Player.MouseOut");
});
-
- this.timeDisplayUpdater(new IriSP.Model.Time(0));
-
- var annotations = this.source.getAnnotations();
- annotations.on("search", function(_text) {
- _this.$searchInput.val(_text);
- _this.showSearchBlock();
- });
- annotations.on("found", function(_text) {
- _this.$searchInput.css('background-color','#e1ffe1');
- });
- annotations.on("not-found", function(_text) {
- _this.$searchInput.css('background-color', "#d62e3a");
- });
- annotations.on("search-cleared", function() {
- _this.hideSearchBlock();
- });
+ /* some players - including jwplayer - save the state of the mute button between sessions */
+
+ window.setTimeout(this.functionWrapper("volumeUpdater"), 1000);
};
/* Update the elasped time div */
-IriSP.Widgets.Controller.prototype.timeDisplayUpdater = function(_time) {
+IriSP.Widgets.Controller.prototype.timeDisplayUpdater = function() {
+ var _curTime = this.player.popcorn.roundTime();
+ if (typeof this._previousSecond !== "undefined" && _curTime === this._previousSecond) {
+ return;
+ }
// we get it at each call because it may change.
- var _totalTime = this.media.duration;
- this.$.find(".Ldt-Ctrl-Time-Elapsed").html(_time.toString());
+ var _totalTime = this.source.getDuration(),
+ _elapsedTime = new IriSP.Model.Time();
+
+ _elapsedTime.setSeconds(_curTime);
+
+ this.$.find(".Ldt-Ctrl-Time-Elapsed").html(_elapsedTime.toString());
this.$.find(".Ldt-Ctrl-Time-Total").html(_totalTime.toString());
+ this._previousSecond = _curTime;
};
/* update the icon of the button - separate function from playHandler
@@ -185,7 +169,10 @@
the jwplayer window) we have to change the icon without playing/pausing
*/
IriSP.Widgets.Controller.prototype.playButtonUpdater = function() {
- if (this.media.getPaused()) {
+
+ var status = this.player.popcorn.media.paused;
+
+ if (status) {
/* the background sprite is changed by adding/removing the correct classes */
this.$playButton
.attr("title", this.l10n.play)
@@ -201,20 +188,23 @@
IriSP.Widgets.Controller.prototype.playHandler = function() {
- if (this.media.getPaused()) {
- this.media.play();
+
+ var status = this.player.popcorn.media.paused;
+
+ if (status) {
+ this.player.popcorn.play();
} else {
- this.media.pause();
+ this.player.popcorn.pause();
}
};
IriSP.Widgets.Controller.prototype.muteHandler = function() {
- this.media.setMuted(!this.media.getMuted());
+ this.player.popcorn.muted(!this.player.popcorn.muted());
};
IriSP.Widgets.Controller.prototype.volumeUpdater = function() {
- var _muted = this.media.getMuted(),
- _vol = this.media.getVolume();
+ var _muted = this.player.popcorn.muted(),
+ _vol = this.player.popcorn.volume();
if (_vol === false) {
_vol = .5;
}
@@ -225,29 +215,43 @@
.addClass("Ldt-Ctrl-Sound-Mute");
} else {
_soundCtl.attr("title", this.l10n.mute)
- .addClass(_vol < .5 ? "Ldt-Ctrl-Sound-Half" : "Ldt-Ctrl-Sound-Full" );
+ .addClass(_vol < .5 ? "Ldt-Ctrl-Sound-Half" : "Ldt-Ctrl-Sound-Full" )
}
this.$volumeBar.slider("value", _muted ? 0 : 100 * _vol);
};
IriSP.Widgets.Controller.prototype.showSearchBlock = function() {
- this.$searchBlock.animate({ width:"160px" }, 200);
+ this.$searchBlock.show("blind", { direction: "horizontal"}, 100);
this.$searchInput.css('background-color','#fff');
+
this.$searchInput.focus();
+
+ // we need this variable because some widgets can find a match in
+ // their data while at the same time others don't. As we want the
+ // search field to become green when there's a match, we need a
+ // variable to remember that we had one.
+ this._positiveMatch = false;
+
+ // tell the world the field is open
+ this.player.popcorn.trigger("IriSP.search.open");
};
IriSP.Widgets.Controller.prototype.hideSearchBlock = function() {
- this.$searchBlock.animate( { width: 0 }, 200);
+ this._searchLastValue = this.$searchInput.val();
+ this.$searchInput.val('');
+ this.$searchBlock.hide("blind", { direction: "horizontal"}, 75);
+
+ this._positiveMatch = false;
+
+ this.player.popcorn.trigger("IriSP.search.closed");
};
/** react to clicks on the search button */
IriSP.Widgets.Controller.prototype.searchButtonHandler = function() {
- if ( !this.$searchBlock.width() ) {
+ if ( this.$searchBlock.is(":hidden") ) {
this.showSearchBlock();
- var _val = this.$searchInput.val();
- if (_val) {
- this.source.getAnnotations().search(_val);
- }
+ this.$searchInput.val(this._searchLastValue);
+ this.player.popcorn.trigger("IriSP.search", this._searchLastValue); // trigger the search to make it more natural.
} else {
this.hideSearchBlock();
}
@@ -256,22 +260,40 @@
/** this handler is called whenever the content of the search
field changes */
IriSP.Widgets.Controller.prototype.searchHandler = function() {
- if ( !this.$searchBlock.width() ) {
- this.$searchBlock.css({ width:"160px" });
- this.$searchInput.css('background-color','#fff');
- }
- var _val = this.$searchInput.val();
+ this._searchLastValue = this.$searchInput.val();
this._positiveMatch = false;
-
+
// do nothing if the search field is empty, instead of highlighting everything.
- if (_val !== this.lastSearchValue) {
- if (_val) {
- this.source.getAnnotations().search(_val);
- } else {
- this.source.getAnnotations().trigger("clear-search");
- this.$searchInput.css('background-color','');
- }
+ if (this._searchLastValue == "") {
+ this.player.popcorn.trigger("IriSP.search.cleared");
+ this.$searchInput.css('background-color','');
+ } else {
+ this.player.popcorn.trigger("IriSP.search", this._searchLastValue);
}
- this.lastSearchValue = _val;
};
+/**
+ handler for the IriSP.search.found message, which is sent by some views when they
+ highlight a match.
+*/
+IriSP.Widgets.Controller.prototype.searchMatch = function() {
+ this._positiveMatch = true;
+ this.$searchInput.css('background-color','#e1ffe1');
+};
+
+/** the same, except that no value could be found */
+IriSP.Widgets.Controller.prototype.searchNoMatch = function() {
+ if (this._positiveMatch !== true) {
+ this.$searchInput.css('background-color', "#d62e3a");
+ }
+};
+
+/** react to an IriSP.Player.triggeredSearch - that is, when
+ a widget ask the.Player to do a search on his behalf */
+IriSP.Widgets.Controller.prototype.triggeredSearch = function(searchString) {
+ this.showSearchBlock();
+ this.$searchInput.attr('value', searchString);
+ this.player.popcorn.trigger("IriSP.search", searchString); // trigger the search to make it more natural.
+};
+
+
diff -r 3ab36f402b0c -r 198c2b79f5e1 src/widgets/CreateAnnotation.css
--- a/src/widgets/CreateAnnotation.css Thu Jan 02 16:40:25 2014 +0100
+++ b/src/widgets/CreateAnnotation.css Thu Jan 02 16:49:20 2014 +0100
@@ -11,11 +11,13 @@
}
.Ldt-CreateAnnotation-Inner {
- background: url(img/pinstripe.png); padding: 5px; margin: 0; position: relative;
+ background: url(img/pinstripe.png);
+ padding: 5px;
+ margin: 0;
}
.Ldt-CreateAnnotation-Inner h3 {
- margin: 5px 0; font-size: 14px; font-weight: bold; text-align: right; clear:both; color: #0068c4;
+ margin: 5px 0; font-size: 14px; font-weight: bold; text-align: right;
}
.Ldt-CreateAnnotation-h3Left {
@@ -34,11 +36,6 @@
border-radius: 2px;
}
-.Ldt-CreateAnnotation-Title.empty, .Ldt-CreateAnnotation-Creator.empty {
- font-style: italic;
- color: #90b0d0;
-}
-
.Ldt-CreateAnnotation-Times {
color: #ff3b77
}
@@ -72,10 +69,6 @@
border-radius: 2px;
}
-.Ldt-CreateAnnotation-Description.empty {
- font-style: italic; color: #999999;
-}
-
.Ldt-CreateAnnotation-Avatar {
float: right;
width: 48px;
@@ -93,11 +86,11 @@
border: 1px solid #bbbbbb;
}
-.Ldt-CreateAnnotation-RecBlock {
- width: 220px; float: left;
+.Ldt-CreateAnnotation-Tags, .Ldt-CreateAnnotation-Polemics {
+ width: 520px;
}
-.Ldt-CreateAnnotation-TagTitle, .Ldt-CreateAnnotation-PolemicTitle, .Ldt-CreateAnnotation-RecLabel {
+.Ldt-CreateAnnotation-TagTitle, .Ldt-CreateAnnotation-PolemicTitle {
display: block; margin: 5px 0 2px; font-size: 12px;
}
diff -r 3ab36f402b0c -r 198c2b79f5e1 src/widgets/CreateAnnotation.js
--- a/src/widgets/CreateAnnotation.js Thu Jan 02 16:40:25 2014 +0100
+++ b/src/widgets/CreateAnnotation.js Thu Jan 02 16:49:20 2014 +0100
@@ -1,4 +1,4 @@
-/* TODO: Add Social Network Sharing */
+/* TODO: Add Social Network Sharing, Finish Current Timecode Sync & Arrow Takeover */
IriSP.Widgets.CreateAnnotation = function(player, config) {
IriSP.Widgets.Widget.call(this, player, config);
@@ -7,14 +7,12 @@
IriSP.Widgets.CreateAnnotation.prototype = new IriSP.Widgets.Widget();
IriSP.Widgets.CreateAnnotation.prototype.defaults = {
- show_title_field : true,
+ show_title_field : false, /* For the moment, titles can't be sent to ldtplatform */
show_creator_field : true,
start_visible : true,
always_visible : false,
- show_slice : true,
- show_arrow : true,
- show_mic_record: false,
- show_mic_play: false,
+ sync_on_slice_widget : true, /* If false, syncs on current timecode */
+ takeover_arrow : false,
minimize_annotation_widget : true,
creator_name : "",
creator_avatar : "",
@@ -39,15 +37,13 @@
background_color: "#f0e000",
text_color: "#000000"
}],
- slice_annotation_type: "chap",
annotation_type: "Contributions",
api_serializer: "ldt_annotate",
api_endpoint_template: "",
- api_method: "POST",
+ api_method: "PUT",
after_send_timeout: 0,
close_after_send: false,
- tag_prefix: "#"
-};
+}
IriSP.Widgets.CreateAnnotation.prototype.messages = {
en: {
@@ -56,85 +52,59 @@
at_time: "at",
submit: "Submit",
add_keywords_: "Add keywords:",
- add_polemic_keywords_: "Add polemic attributes :",
+ add_polemic_keywords_: "Add polemic keywords:",
your_name_: "Your name:",
- annotate_video: "Annotate this video",
+ no_title: "Annotate this video",
type_title: "Annotation title",
- type_description: "Type the full contents of your annotation here.",
- wait_while_processing: "Please wait while your annotation is being processed...",
+ type_description: "Type the full description of your annotation here.",
+ wait_while_processing: "Please wait while your request is being processed...",
error_while_contacting: "An error happened while contacting the server. Your annotation has not been saved.",
+ empty_annotation: "Your annotation is empty. Please write something before submitting.",
annotation_saved: "Thank you, your annotation has been saved.",
share_annotation: "Would you like to share it on social networks ?",
- close_widget: "Hide the annotation form",
- "polemic++": "Agree",
- "polemic--": "Disagree",
- "polemic??": "Question",
- "polemic==": "Reference"
+ share_on: "Share on",
+ more_tags: "More tags",
+ cancel: "Cancel",
+ close_widget: "Cacher la zone de création d'annotations"
},
fr: {
from_time: "de",
to_time: "à",
at_time: "à",
submit: "Envoyer",
- add_keywords_: "Ajouter des mots-clés\u00a0:",
- add_polemic_keywords_: "Ajouter des attributs polémiques\u00a0:",
- your_name_: "Votre nom\u00a0:",
- annotate_video: "Annoter cette vidéo",
+ add_keywords_: "Ajouter des mots-clés :",
+ add_polemic_keywords_: "Ajouter des mots-clés polémiques :",
+ your_name_: "Votre nom :",
+ no_title: "Annoter cette vidéo",
type_title: "Titre de l'annotation",
- type_description: "Rédigez ici le contenu de votre annotation.",
- wait_while_processing: "Veuillez patienter pendant le traitement de votre annotation...",
- error_while_contacting: "Une erreur s'est produite en contactant le serveur. Votre annotation n'a pas été enregistrée.",
+ type_description: "Rédigez le contenu de votre annotation ici.",
+ wait_while_processing: "Veuillez patienter pendant le traitement de votre requête...",
+ error_while_contacting: "Une erreur s'est produite en contactant le serveur. Votre annotation n'a pas été enregistrée",
+ empty_annotation: "Votre annotation est vide. Merci de rédiger un texte avant de l'envoyer.",
annotation_saved: "Merci, votre annotation a été enregistrée.",
share_annotation: "Souhaitez-vous la partager sur les réseaux sociaux ?",
- close_widget: "Cacher le formulaire de création d'annotations",
- "polemic++": "Accord",
- "polemic--": "Désaccord",
- "polemic??": "Question",
- "polemic==": "Référence"
+ share_on: "Partager sur",
+ more_tags: "Plus de mots-clés",
+ cancel: "Cancel",
+ close_widget: "Hide the annotation creating block"
}
-};
+}
IriSP.Widgets.CreateAnnotation.prototype.template =
- '{{#show_slice}}
{{/show_slice}}'
- + '{{^show_slice}}{{#show_arrow}}
{{/show_arrow}}{{/show_slice}}'
- + '
'
+ '
{{/tags.length}}'
+ '{{#polemics.length}}
{{l10n.add_polemic_keywords_}}
'
- + '{{#polemics}}- {{keyword}}
{{/polemics}}
{{/polemics.length}}'
+ + '{{#polemics}}
{{keyword}}{{/polemics}}
{{/polemics.length}}'
+ '
'
+ '
{{l10n.wait_while_processing}}
'
+ '
{{^always_visible}}
{{/always_visible}}
{{l10n.error_while_contacting}}
'
@@ -143,31 +113,18 @@
IriSP.Widgets.CreateAnnotation.prototype.draw = function() {
var _this = this;
-
- this.begin = new IriSP.Model.Time();
- this.end = this.source.getDuration();
-
- this.tag_prefix = this.tag_prefix || "";
-
if (this.tag_titles && !this.tags) {
- if(!(this.tag_titles.length==1 && this.tag_titles[0]=="")){
- this.tags = IriSP._(this.tag_titles).map(function(_tag_title) {
- var _tag,
- _tags = _this.source.getTags().searchByTitle(_tag_title, true);
- if (_tags.length) {
- _tag = _tags[0];
- } else {
- _tag = new IriSP.Model.Tag(false, _this.source);
- _this.source.getTags().push(_tag);
- _tag.title = _tag_title;
- }
- return _tag;
- });
- }
- else{
- // we forced no tags if this.tag_titles = [''] (and not false)
- this.tags = true;
- }
+ this.tags = IriSP._(this.tag_titles).map(function(_tag_title) {
+ var _tag,
+ _tags = _this.source.getTags().searchByTitle(_tag_title);
+ if (_tags.length) {
+ _tag = _tags[0];
+ } else {
+ _tag = new IriSP.Model.Tag(false, _this.source);
+ _tag.title = _tag_title;
+ }
+ return _tag;
+ });
}
if (!this.tags) {
this.tags = this.source.getTags()
@@ -180,44 +137,7 @@
});
/* We have to use the map function because Mustache doesn't like our tags object */
}
- this.record_swf = IriSP.getLib("recordMicSwf");
this.renderTemplate();
- if (this.show_mic_record) {
- this.recorder = this.$.find("embed")[0];
-
- window.setAudioUrl = function(_url) {
- _this.audio_url = _url;
- }
- }
- if (this.show_slice) {
- this.insertSubwidget(
- this.$.find(".Ldt-CreateAnnotation-Slice"),
- {
- type: "Slice",
- show_arrow: this.show_arrow,
- annotation_type: this.slice_annotation_type,
- onBoundsChanged: function(_from, _to) {
- _this.begin = new IriSP.Model.Time(_from || 0);
- _this.end = new IriSP.Model.Time(_to || 0);
- _this.$.find(".Ldt-CreateAnnotation-Begin").html(_this.begin.toString());
- _this.$.find(".Ldt-CreateAnnotation-End").html(_this.end.toString());
- }
- },
- "slice"
- );
- } else {
- if (this.show_arrow) {
- this.insertSubwidget(this.$.find(".Ldt-CreateAnnotation-Arrow"), {type: "Arrow"},"arrow");
- }
- this.onMediaEvent("timeupdate", function(_time) {
- _this.begin = new IriSP.Model.Time(_time || 0);
- _this.end = new IriSP.Model.Time(_time || 0);
- _this.$.find(".Ldt-CreateAnnotation-Begin").html(_this.begin.toString());
- if (_this.arrow) {
- _this.arrow.moveToTime(_time);
- }
- });
- }
this.$.find(".Ldt-CreateAnnotation-Close").click(function() {
_this.close_after_send
? _this.hide()
@@ -225,17 +145,9 @@
return false;
});
this.$.find(".Ldt-CreateAnnotation-TagLi, .Ldt-CreateAnnotation-PolemicLi").click(function() {
- _this.addKeyword(IriSP.jQuery(this).attr("data-text"));
+ _this.addKeyword(IriSP.jQuery(this).text().replace(/(^\s+|\s+$)/g,''));
return false;
});
- this.$.find(".Ldt-CreateAnnotation-PolemicLi").each(function() {
- var _el = IriSP.jQuery(this),
- _kw = _el.attr("data-text"),
- _msg = _this.l10n["polemic" + _kw];
- if (_msg) {
- _el.attr("title",_msg);
- }
- });
this.$.find(".Ldt-CreateAnnotation-Description").bind("change keyup input paste", this.functionWrapper("onDescriptionChange"));
if (this.show_title_field) {
this.$.find(".Ldt-CreateAnnotation-Title").bind("change keyup input paste", this.functionWrapper("onTitleChange"));
@@ -251,9 +163,12 @@
this.hide();
}
- this.onMdpEvent("CreateAnnotation.toggle","toggle");
+ this.bindPopcorn("IriSP.CreateAnnotation.toggle","toggle");
+ this.bindPopcorn("IriSP.Slice.boundsChanged","onBoundsChanged");
+ this.begin = new IriSP.Model.Time();
+ this.end = this.source.getDuration();
this.$.find("form").submit(this.functionWrapper("onSubmit"));
-};
+}
IriSP.Widgets.CreateAnnotation.prototype.showScreen = function(_screenName) {
this.$.find('.Ldt-CreateAnnotation-' + _screenName).show()
@@ -263,35 +178,31 @@
IriSP.Widgets.CreateAnnotation.prototype.show = function() {
this.visible = true;
this.showScreen('Main');
- this.$.find(".Ldt-CreateAnnotation-Description").val("").css("border-color", "#666666").addClass("empty");
+ this.$.find(".Ldt-CreateAnnotation-Description").val("").css("border-color", "#666666");
if (this.show_title_field) {
- this.$.find(".Ldt-CreateAnnotation-Title").val("").css("border-color", "#666666").addClass("empty");
+ this.$.find(".Ldt-CreateAnnotation-Title").val("").css("border-color", "#666666");
}
if (this.show_creator_field) {
this.$.find(".Ldt-CreateAnnotation-Creator").val(this.creator_name).css("border-color", "#666666");
- if (!this.creator_name) {
- this.$.find(".Ldt-CreateAnnotation-Creator").addClass("empty");
- }
}
this.$.find(".Ldt-CreateAnnotation-TagLi, .Ldt-CreateAnnotation-PolemicLi").removeClass("selected");
this.$.slideDown();
if (this.minimize_annotation_widget) {
- this.player.trigger("Annotation.minimize");
+ this.player.popcorn.trigger("IriSP.Annotation.minimize");
}
-};
+ this.player.popcorn.trigger("IriSP.Slice.show");
+}
IriSP.Widgets.CreateAnnotation.prototype.hide = function() {
- if (this.recorder) {
- this.recorder.stopRecord();
- }
if (!this.always_visible) {
this.visible = false;
this.$.slideUp();
if (this.minimize_annotation_widget) {
- this.player.trigger("Annotation.maximize");
+ this.player.popcorn.trigger("IriSP.Annotation.maximize");
}
+ this.player.popcorn.trigger("IriSP.Slice.hide");
}
-};
+}
IriSP.Widgets.CreateAnnotation.prototype.toggle = function() {
if (!this.always_visible) {
@@ -301,7 +212,14 @@
this.show();
}
}
-};
+}
+
+IriSP.Widgets.CreateAnnotation.prototype.onBoundsChanged = function(_values) {
+ this.begin = new IriSP.Model.Time(_values[0] || 0);
+ this.end = new IriSP.Model.Time(_values[1] || 0);
+ this.$.find(".Ldt-CreateAnnotation-Begin").html(this.begin.toString());
+ this.$.find(".Ldt-CreateAnnotation-End").html(this.end.toString());
+}
IriSP.Widgets.CreateAnnotation.prototype.addKeyword = function(_keyword) {
var _field = this.$.find(".Ldt-CreateAnnotation-Description"),
@@ -313,25 +231,20 @@
);
_field.val(_contents.replace(/\s{2,}/g,' ').replace(/(^\s+|\s+$)/g,''));
this.onDescriptionChange();
-};
+}
IriSP.Widgets.CreateAnnotation.prototype.pauseOnWrite = function() {
- if (this.pause_on_write && !this.media.getPaused()) {
- this.media.pause();
+ if (this.pause_on_write && !this.player.popcorn.media.paused) {
+ this.player.popcorn.pause();
}
-};
+}
IriSP.Widgets.CreateAnnotation.prototype.onDescriptionChange = function() {
var _field = this.$.find(".Ldt-CreateAnnotation-Description"),
_contents = _field.val();
_field.css("border-color", !!_contents ? "#666666" : "#ff0000");
- if (!!_contents) {
- _field.removeClass("empty");
- } else {
- _field.addClass("empty");
- }
this.$.find(".Ldt-CreateAnnotation-TagLi, .Ldt-CreateAnnotation-PolemicLi").each(function() {
- var _rx = IriSP.Model.regexpFromTextOrArray(IriSP.jQuery(this).attr("data-text"));
+ var _rx = IriSP.Model.regexpFromTextOrArray(IriSP.jQuery(this).text().replace(/(^\s+|\s+$)/g,''));
if (_contents.match(_rx)) {
IriSP.jQuery(this).addClass("selected");
} else {
@@ -340,51 +253,36 @@
});
this.pauseOnWrite();
return !!_contents;
-};
+}
IriSP.Widgets.CreateAnnotation.prototype.onTitleChange = function() {
var _field = this.$.find(".Ldt-CreateAnnotation-Title"),
_contents = _field.val();
_field.css("border-color", !!_contents ? "#666666" : "#ff0000");
- if (!!_contents) {
- _field.removeClass("empty");
- } else {
- _field.addClass("empty");
- }
this.pauseOnWrite();
return !!_contents;
-};
+}
IriSP.Widgets.CreateAnnotation.prototype.onCreatorChange = function() {
var _field = this.$.find(".Ldt-CreateAnnotation-Creator"),
_contents = _field.val();
_field.css("border-color", !!_contents ? "#666666" : "#ff0000");
- if (!!_contents) {
- _field.removeClass("empty");
- } else {
- _field.addClass("empty");
- }
this.pauseOnWrite();
return !!_contents;
-};
+}
/* Fonction effectuant l'envoi des annotations */
IriSP.Widgets.CreateAnnotation.prototype.onSubmit = function() {
/* Si les champs obligatoires sont vides, on annule l'envoi */
if (!this.onDescriptionChange() || (this.show_title_field && !this.onTitleChange()) || (this.show_creator_field && !this.onCreatorChange())) {
- return false;
+ return;
}
- if (this.recorder) {
- this.recorder.stopRecord();
- }
-
- var _this = this,
- _exportedAnnotations = new IriSP.Model.List(this.player.sourceManager), /* Création d'une liste d'annotations contenant une annotation afin de l'envoyer au serveur */
+ var _exportedAnnotations = new IriSP.Model.List(this.player.sourceManager), /* Création d'une liste d'annotations contenant une annotation afin de l'envoyer au serveur */
_export = this.player.sourceManager.newLocalSource({serializer: IriSP.serializers[this.api_serializer]}), /* Création d'un objet source utilisant un sérialiseur spécifique pour l'export */
_annotation = new IriSP.Model.Annotation(false, _export), /* Création d'une annotation dans cette source avec un ID généré à la volée (param. false) */
- _annotationTypes = this.source.getAnnotationTypes().searchByTitle(this.annotation_type, true), /* Récupération du type d'annotation dans lequel l'annotation doit être ajoutée */
+ _annotationTypes = this.source.getAnnotationTypes().searchByTitle(this.annotation_type), /* Récupération du type d'annotation dans lequel l'annotation doit être ajoutée */
_annotationType = (_annotationTypes.length ? _annotationTypes[0] : new IriSP.Model.AnnotationType(false, _export)), /* Si le Type d'Annotation n'existe pas, il est créé à la volée */
_url = Mustache.to_html(this.api_endpoint_template, {id: this.source.projectId}); /* Génération de l'URL à laquelle l'annotation doit être envoyée, qui doit inclure l'ID du projet */
@@ -400,9 +298,9 @@
* Nous remplissons les données de l'annotation générée à la volée
* ATTENTION: Si nous sommes sur un MASHUP, ces éléments doivent se référer AU MEDIA D'ORIGINE
* */
- _annotation.setMedia(this.source.currentMedia.id); /* Id du média annoté */
_annotation.setBegin(this.begin); /*Timecode de début */
_annotation.setEnd(this.end); /* Timecode de fin */
+ _annotation.setMedia(this.source.currentMedia.id); /* Id du média annoté */
_annotation.setAnnotationType(_annotationType.id); /* Id du type d'annotation */
if (this.show_title_field) {
@@ -411,42 +309,16 @@
}
_annotation.created = new Date(); /* Date de création de l'annotation */
_annotation.description = this.$.find(".Ldt-CreateAnnotation-Description").val(); /* Champ description */
-
- var tagIds = Array.prototype.map.call(
- this.$.find(".Ldt-CreateAnnotation-TagLi.selected"),
- function(el) { return IriSP.jQuery(el).attr("tag-id")}
- );
-
- IriSP._(_annotation.description.match(/#[^\s#.,;]+/g)).each(function(_tt) {
- var _tag,
- _tag_title = _tt.replace(/^#/,''),
- _tags = _this.source.getTags().searchByTitle(_tag_title, true);
- if (_tags.length) {
- _tag = _tags[0];
- } else {
- _tag = new IriSP.Model.Tag(false, _this.source);
- _this.source.getTags().push(_tag);
- _tag.title = _tag_title;
- }
- if (tagIds.indexOf(_tag.id) === -1) {
- tagIds.push(_tag.id);
- }
-
- })
-
- _annotation.setTags(IriSP._(tagIds).uniq()); /*Liste des ids de tags */
- if (this.audio_url) {
- _annotation.audio = {
- src: "mic",
- mimetype: "audio/mp3",
- href: this.audio_url
- };
+ _annotation.setTags(this.$.find(".Ldt-CreateAnnotation-TagLi.selected")
+ .map(function() { return IriSP.jQuery(this).attr("tag-id")})); /*Liste des ids de tags */
+
+ /* Les données créateur/date de création sont envoyées non pas dans l'annotation, mais dans le projet */
+ if (this.show_creator_field) {
+ _export.creator = this.$.find(".Ldt-CreateAnnotation-Creator").val();
+ } else {
+ _export.creator = this.creator_name;
}
- if (this.show_creator_field) {
- _annotation.creator = this.$.find(".Ldt-CreateAnnotation-Creator").val();
- } else {
- _annotation.creator = this.creator_name;
- }
+ _export.created = new Date();
_exportedAnnotations.push(_annotation); /* Ajout de l'annotation à la liste à exporter */
_export.addList("annotation",_exportedAnnotations); /* Ajout de la liste à exporter à l'objet Source */
@@ -464,7 +336,7 @@
function() {
_this.close_after_send
? _this.hide()
- : _this.show();
+ : _this.showScreen("Main");
},
_this.after_send_timeout
);
@@ -472,10 +344,10 @@
_export.getAnnotations().removeElement(_annotation, true); /* Pour éviter les doublons, on supprime l'annotation qui a été envoyée */
_export.deSerialize(_data); /* On désérialise les données reçues pour les réinjecter */
_this.source.merge(_export); /* On récupère les données réimportées dans l'espace global des données */
- if (_this.pause_on_write && _this.media.getPaused()) {
- _this.media.play();
+ if (_this.pause_on_write && _this.player.popcorn.media.paused) {
+ _this.player.popcorn.play();
}
- _this.player.trigger("AnnotationsList.refresh"); /* On force le rafraîchissement du widget AnnotationsList */
+ _this.player.popcorn.trigger("IriSP.AnnotationsList.refresh"); /* On force le rafraîchissement du widget AnnotationsList */
},
error: function(_xhr, _error, _thrown) {
IriSP.log("Error when sending annotation", _thrown);
@@ -490,5 +362,5 @@
this.showScreen('Wait');
return false;
-};
+}
diff -r 3ab36f402b0c -r 198c2b79f5e1 src/widgets/DailymotionPlayer.js
--- a/src/widgets/DailymotionPlayer.js Thu Jan 02 16:40:25 2014 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,104 +0,0 @@
-IriSP.Widgets.DailymotionPlayer = function(player, config) {
- IriSP.Widgets.Widget.call(this, player, config);
-};
-
-IriSP.Widgets.DailymotionPlayer.prototype = new IriSP.Widgets.Widget();
-
-IriSP.Widgets.DailymotionPlayer.prototype.defaults = {
- aspect_ratio: 14/9
-};
-
-IriSP.Widgets.DailymotionPlayer.prototype.draw = function() {
-
- if (typeof this.video === "undefined") {
- this.video = this.media.video;
- }
-
- this.height = this.height || Math.floor(this.width / this.aspect_ratio);
-
- var _media = this.media,
- _this = this,
- _pauseState = true;
-
- /* Dailymotion utilise un système de fonctions référencées dans
- * des variables globales pour la gestion des événements.
- */
-
- window.onDailymotionPlayerReady = function() {
-
- var _player = document.getElementById(_this.container);
-
- _media.getCurrentTime = function() {
- return new IriSP.Model.Time(1000*_player.getCurrentTime());
- };
- _media.getVolume = function() {
- return _player.getVolume() / 100;
- };
- _media.getPaused = function() {
- return _pauseState;
- };
- _media.getMuted = function() {
- return _player.isMuted();
- };
- _media.setCurrentTime = function(_milliseconds) {
- _seekPause = _pauseState;
- return _player.seekTo(_milliseconds / 1000);
- };
- _media.setVolume = function(_vol) {
- return _player.setVolume(Math.floor(_vol*100));
- };
- _media.mute = function() {
- return _player.mute();
- };
- _media.unmute = function() {
- return _player.unMute();
- };
- _media.play = function() {
- return _player.playVideo();
- };
- _media.pause = function() {
- return _player.pauseVideo();
- };
-
- _player.addEventListener("onStateChange", "onDailymotionStateChange");
- _player.addEventListener("onVideoProgress", "onDailymotionVideoProgress");
-
- _player.cueVideoByUrl(_this.video);
-
- _media.trigger("loadedmetadata");
- };
-
- window.onDailymotionStateChange = function(_state) {
- switch(_state) {
- case 1:
- _media.trigger("play");
- _pauseState = false;
- break;
-
- case 2:
- _media.trigger("pause");
- _pauseState = true;
- break;
-
- case 3:
- _media.trigger("seeked");
- break;
- }
- };
-
- window.onDailymotionVideoProgress = function(_progress) {
- _media.trigger("timeupdate", new IriSP.Model.Time(_progress.mediaTime * 1000));
- };
-
- var params = {
- "allowScriptAccess" : "always",
- "wmode": "opaque"
- };
-
- var atts = {
- id : this.container
- };
-
- swfobject.embedSWF("http://www.dailymotion.com/swf?chromeless=1&enableApi=1", this.container, this.width, this.height, "8", null, null, params, atts);
-
-};
\ No newline at end of file
diff -r 3ab36f402b0c -r 198c2b79f5e1 src/widgets/HelloWorld.js
--- a/src/widgets/HelloWorld.js Thu Jan 02 16:40:25 2014 +0100
+++ b/src/widgets/HelloWorld.js Thu Jan 02 16:49:20 2014 +0100
@@ -7,13 +7,13 @@
IriSP.Widgets.HelloWorld = function(player, config) {
console.log("Calling IriSP.Widget's constructor from IriSP.HelloWorldWidget");
IriSP.Widgets.Widget.call(this, player, config);
-};
+}
IriSP.Widgets.HelloWorld.prototype = new IriSP.Widgets.Widget();
IriSP.Widgets.HelloWorld.prototype.defaults = {
text: "world"
-};
+}
IriSP.Widgets.HelloWorld.prototype.template =
'
{{l10n.Hello}} {{text}}
Looks like we have {{source.contents.annotation.length}} annotations in this feed
';
@@ -25,9 +25,9 @@
"en" : {
"Hello" : "Hello,"
}
-};
+}
IriSP.Widgets.HelloWorld.prototype.draw = function() {
this.renderTemplate();
console.log("HelloWorldWidget was drawn");
-};
\ No newline at end of file
+}
\ No newline at end of file
diff -r 3ab36f402b0c -r 198c2b79f5e1 src/widgets/HtmlPlayer.js
--- a/src/widgets/HtmlPlayer.js Thu Jan 02 16:40:25 2014 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,15 +0,0 @@
-IriSP.Widgets.HtmlPlayer = function(player, config) {
- IriSP.Widgets.Widget.call(this, player, config);
-};
-
-IriSP.Widgets.HtmlPlayer.prototype = new IriSP.Widgets.Widget();
-
-
-IriSP.Widgets.HtmlPlayer.prototype.defaults = {
-};
-
-IriSP.Widgets.HtmlPlayer.prototype.draw = function() {
-
- IriSP.htmlPlayer(this.media, this.$, this);
-
-};
\ No newline at end of file
diff -r 3ab36f402b0c -r 198c2b79f5e1 src/widgets/JwpPlayer.js
--- a/src/widgets/JwpPlayer.js Thu Jan 02 16:40:25 2014 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,122 +0,0 @@
-IriSP.Widgets.JwpPlayer = function(player, config) {
- IriSP.Widgets.Widget.call(this, player, config);
-};
-
-IriSP.Widgets.JwpPlayer.prototype = new IriSP.Widgets.Widget();
-
-IriSP.Widgets.JwpPlayer.prototype.defaults = {
-};
-
-IriSP.Widgets.JwpPlayer.prototype.draw = function() {
-
- var _opts = {},
- _player = jwplayer(this.$[0]),
- _seekPause = false,
- _pauseState = true;
-
- if (typeof this.video === "undefined") {
- this.video = this.media.video;
- }
-
- _opts.file = this.video;
- _opts.flashplayer = IriSP.getLib("jwPlayerSWF");
- _opts.primary = "flash";
- _opts.fallback = false;
- _opts.controls = false;
- _opts.width = this.width;
- if (this.height) {
- _opts.height = this.height;
- }
-
- if (this.autostart) { // There seems to be an autostart bug
- //_opts.autostart = true;
- //_pauseState = false;
- //this.media.trigger("play");
- }
-
- if (this.url_transform) {
- _opts.file = this.url_transform(_opts.file);
- }
-
- // Binding functions to jwplayer
-
- var _media = this.media;
-
- _media.on("setcurrenttime", function(_milliseconds) {
- _seekPause = _pauseState;
- _player.seek(_milliseconds / 1000);
- });
-
- _media.on("setvolume", function(_vol) {
- _player.setVolume(Math.floor(_vol*100));
- _media.volume = _vol;
- });
-
- _media.on("setmuted", function(_muted) {
- _player.setMute(_muted);
- _media.muted = _muted;
- });
-
- _media.on("setplay", function() {
- _player.play(true);
- _media.paused = false;
- });
-
- _media.on("setpause", function() {
- _player.pause(true);
- _media.paused = true;
- });
-
- // Binding jwplater events to media
-
- function getVolume() {
- _media.muted = _player.getMute();
- _media.volume = _player.getVolume() / 100;
- }
-
- _opts.events = {
- onReady: function() {
- getVolume();
- _media.currentTime = new IriSP.Model.Time(1000*_player.getPosition() || 0);
- _media.trigger("loadedmetadata");
- },
- onTime: function(_progress) {
- if (_seekPause) {
- _player.pause(true);
- _seekPause = false;
- } else {
- if (_pauseState && _player.getState() === "PLAYING") {
- _pauseState = false;
- _media.trigger("play");
- }
- }
- _media.trigger("timeupdate", new IriSP.Model.Time(_progress.position * 1000));
- },
- onPlay: function() {
- if (!_seekPause) {
- _pauseState = false;
- _media.trigger("play");
- }
- },
- onPause: function() {
- _pauseState = true;
- _media.trigger("pause");
- },
- onSeek: function() {
- _media.trigger("seeked");
- },
- onMute: function(_event) {
- _media.muted = _event.mute;
- _media.trigger("volumechange");
- },
- onVolume: function(_event) {
- _media.volume = _event.volume / 100;
- _media.trigger("volumechange");
- }
- };
-
- _player = _player.setup(_opts);
-
- this.jwplayer = _player;
-
-};
\ No newline at end of file
diff -r 3ab36f402b0c -r 198c2b79f5e1 src/widgets/KnowledgeConcierge.css
--- a/src/widgets/KnowledgeConcierge.css Thu Jan 02 16:40:25 2014 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,97 +0,0 @@
-.Ldt-Kc-Slider {
- width: 100%; height: 8px; margin: 3px 0; font-size: 8px;
-}
-
-.Ldt-Kc-Canvas {
- border: 1px solid #999999;
-}
-
-.Ldt-Kc-Related {
- display: none;
-}
-
-.Ldt-Kc-Related-Empty {
- text-align: center; font-weight: bold; font-style: italic;
- font-size: 14px; color: #999999; margin: 5px 0;
-}
-
-.Ldt-Kc-Related h2 {
- border: none;
- color: #330099;
- font-size: 18px;
- margin: 8px 0 2px;
- padding: 0 5px;
-}
-
-h3.Ldt-Kc-For-Keywords {
- border-bottom: 1px solid #666666;
- color: #000000;
- font-size: 12px;
- margin: 2px 0 5px;
- padding: 0 5px 5px;
- text-align: right;
-}
-
-.Ldt-Kc-Keywords {
- color: #d000c0; font-weight: bold;
-}
-
-.Ldt-Kc-Related-Item {
- width: 235px; float: left; margin: 4px 0; padding: 4px 0;
-}
-
-.Ldt-Kc-Related-Item:hover {
- background: #e8e8e8;
-}
-
-.Ldt-Kc-Related-Item:nth-child(even) {
- margin-left: 10px;
-}
-
-.Ldt-Kc-Related-Item a {
- text-decoration: none;
-}
-
-.Ldt-Kc-Related-Item img {
- max-width: 80px; max-height: 60px; float: left;
-}
-
-.Ldt-Kc-Related-Item h3, .Ldt-Kc-Related-Item p {
- margin: 0 0 5px 85px;
-}
-
-.Ldt-Kc-Related-Item h3 {
- font-size: 14px; font-weight: 600;
-}
-
-.Ldt-Kc-Related-Item h3 a {
- color: #330099;
-}
-
-.Ldt-Kc-Related-Item h3 a:hover {
- text-decoration: underline;
-}
-
-.Ldt-Kc-Related-Item p {
- font-size: 12px;
-}
-
-.Ldt-Kc-Item-Duration {
- color: #c00000;
-}
-
-.Ldt-Kc-Row {
- border-bottom: 1px solid #CCCCCC;
- clear: both; float: left; width: 100%;
-}
-
-.Ldt-Kc-Clearer {
- clear: both;
-}
-
-.Ldt-Kc-Waiting {
- display: none;
- height: 128px;
- width: 100%;
- background:url(img/loader.gif) center no-repeat;
-}
diff -r 3ab36f402b0c -r 198c2b79f5e1 src/widgets/KnowledgeConcierge.js
--- a/src/widgets/KnowledgeConcierge.js Thu Jan 02 16:40:25 2014 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,333 +0,0 @@
-IriSP.Widgets.KnowledgeConcierge = function(player, config) {
- IriSP.Widgets.Widget.call(this, player, config);
-};
-
-IriSP.Widgets.KnowledgeConcierge.prototype = new IriSP.Widgets.Widget();
-
-IriSP.Widgets.KnowledgeConcierge.prototype.defaults = {
- width: 600,
- height: 500,
- sketch_path: "tmgraph",
- sketch_files: [ "tmgraph.pde", "physics.pde", "model.pde", "javascript.pde", "menu.pde", "event.pde", "constants.pde", "initialdata.pde"],
- kc_api_root: "/kn-concierge/",
- related_api_endpoint: "",
- use_word_boundaries: false,
- related_data_type: 'json', // SET TO "jsonp" FOR CROSS-DOMAIN OPERATION
- related_count: 8,
-};
-
-IriSP.Widgets.KnowledgeConcierge.prototype.messages = {
- "fr": {
- related_videos: "Vidéos liées",
- duration_: "Durée\u00a0:",
- for_keywords_: "pour le(s) mots-clé(s)\u00a0:",
- no_matching_videos: "Pas de vidéos correspondantes"
- },
- "en": {
- related_videos: "Related Videos",
- duration_: "Duration:",
- for_keywords_: "for keyword(s):",
- no_matching_videos: "No matching videos"
- }
-};
-
-IriSP.Widgets.KnowledgeConcierge.prototype.template =
- '
'
- + '
';
-
-IriSP.Widgets.KnowledgeConcierge.prototype.draw = function() {
- this.renderTemplate();
- var _canvasHeight = this.height - 16,
- _canvasWidth = this.width - 2,
- _canvas = this.$.find(".Ldt-Kc-Canvas"),
- _tmpId = IriSP._.uniqueId("Processing-"),
- _slider = this.$.find(".Ldt-Kc-Slider"),
- radius = .375 * Math.min(_canvasHeight, _canvasWidth);
- _canvas.attr({
- width: _canvasWidth,
- height: _canvasHeight,
- id: _tmpId
- }).css({
- width: _canvasWidth,
- height: _canvasHeight
- });
- var _this = this,
- _pjsfiles = IriSP._(this.sketch_files).map(function(_f) { return _this.sketch_path + "/" + _f; }),
- _selectedText = "",
- currentNodesList = "",
- relatedCache = {},
- relatedRequests = {},
- relatedTemplate = '
';
-
- Processing.loadSketchFromSources(_canvas[0],_pjsfiles);
-
- function renderRelated() {
- var keywords = currentNodesList;
- _this.$.find(".Ldt-Kc-Related").show();
- if (typeof relatedCache[keywords] === "undefined") {
- return;
- }
- _this.$.find(".Ldt-Kc-Waiting").hide();
- if (relatedCache[keywords].length) {
- var _html = '
';
- IriSP._(relatedCache[keywords]).each(function(media, i) {
- var _tmpldata = {
- widget: _this,
- media: media,
- description: media.description.replace(/(\n|\r|\r\n)/mg,' ').replace(/(^.{120,140})[\s].+$/m,'$1…'),
- duration: new IriSP.Model.Time(media.duration).toString(),
- escaped_keyword: encodeURIComponent(keywords.split(",")[0])
- };
- _html += Mustache.to_html(relatedTemplate, _tmpldata);
- if (i % 2) {
- _html += '
';
- }
- });
- _html += '
';
- _this.$.find(".Ldt-Kc-Related-List").html(_html);
- } else {
- _this.$.find(".Ldt-Kc-Related-List").html("
" + _this.l10n.no_matching_videos + "
");
- }
- }
-
- function triggerSearch(text) {
- if (_selectedText !== text) {
- _selectedText = text;
- _this.source.getAnnotations().search(text);
- }
- }
-
- function searchNodes(tags) {
- var _tlist = (_this.use_word_boundaries ? IriSP._(tags).map(function(t) { return "\\\\y" + t + "\\\\y" }) : tags),
- _q = "(?i)(" + _tlist.join("|") + ")";
- jQuery.getJSON(
- _this.kc_api_root + "topics.jsp",
- {
- proj: _this.project_id,
- q: _q
- },
- function(data) {
- if (data && data.items && data.items.length) {
- for (var i=0, l=data.items.length; i
1) {
- node.position(Math.floor(radius*Math.sin(2 * Math.PI * i / l)),Math.floor(radius*Math.cos(2 * Math.PI * i / l)));
- }
- }
- }
- }
- );
- }
-
- function showRelated(nodetexts) {
- currentNodesList = nodetexts;
- _this.$.find(".Ldt-Kc-Related-List").html("");
- _this.$.find(".Ldt-Kc-Keywords").html(nodetexts.replace(/\,/g,", "));
- if (typeof relatedCache[nodetexts] === "undefined") {
- _this.$.find(".Ldt-Kc-Waiting").show();
- if (relatedRequests[nodetexts]) {
- return;
- }
- relatedRequests[nodetexts] = true;
- IriSP.jQuery.ajax({
- url: _this.related_api_endpoint,
- data: {
- format: _this.related_data_type,
- keywords: nodetexts
- },
- dataType: _this.related_data_type,
- success: function(data) {
- relatedCache[nodetexts] = IriSP._(data.objects)
- .chain()
- .filter(function(o) {
- return o.iri_id !== _this.media.id;
- })
- .sortBy(function(o) {
- return - o.score;
- })
- .first(_this.related_count)
- .value();
- renderRelated();
- }
- });
- } else {
- renderRelated();
- }
- }
-
- function rootNode(id, proj) {
- jQuery.getJSON(
- _this.kc_api_root + "topic.jsp",
- {
- id: id,
- proj: proj
- },
- function(response) {
- if (response != null && response.items.length > 0){
- item = response.items[0];
- _pjs.initNode(item.id, item.name, item.grp, item.uid, item.proj);
- _fns.countassoc(item.id, item.proj);
- }
- }
- );
- }
-
- function bindJavascript() {
- _pjs = Processing.getInstanceById(_tmpId);
- if (_pjs && typeof _pjs.bindJavascript === "function") {
- setTimeout(function() {
- _pjs.bindJavascript(_fns);
- _pjs.setSize(_canvasWidth,_canvasHeight);
- var _edit = false,
- _teamMode = true;
- _pjs.saveMode("en",false,_teamMode,false,"both",_edit);
- rootNode(_this.topic_id, _this.project_id);
- _slider.slider({
- min: -20,
- max: 20,
- value: 0,
- range: "min",
- slide: function(event, ui) {
- _pjs.zoom(Math.exp(ui.value / 10));
- }
- });
- }, 1000);
- } else {
- setTimeout(bindJavascript, 1000);
- }
- }
- var currentSelection = null;
- var _fns = {
- adjacentnodes: function(id, proj, adj, both) {
- jQuery.ajax({
- url: _this.kc_api_root + "associations-bd.jsp",
- cache: false,
- data: {
- id: id,
- proj: proj,
- both: both,
- adj: adj
- },
- success: function(response) {
- if (response.items.length > 0){
- for(i = 0, end = response.items.length; i < end; i++) {
- item = response.items[i];
- _pjs.addEdge(item.asc_id, item.id, item.from_proj, item.to_id, item.to_proj,
- item.r_name, item.r_from, item.r_to, item.uid, item.proj);
- _pjs.setNodeName( item.id, item.from_proj,item.name);
- _pjs.setNodeValue(item.id, item.from_proj,item.name, item.grp, item.abst, item.from_uid);
- if (item.from_assoc!=null) {
- _pjs.setNodeAssoc(item.id, item.from_proj, item.from_assoc);
- }
- _pjs.setNodeName( item.to_id,item.to_proj, item.to_name);
- _pjs.setNodeValue(item.to_id,item.to_proj, item.to_name,item.to_grp,item.to_abst,item.to_uid);
- if (item.to_assoc!=null) {
- _pjs.setNodeAssoc(item.to_id, item.to_proj, item.to_assoc);
- }
- }
- return response;
- } else {
- //.debug('No such topic.');
- return null;
- }
- }
- });
- },
- setscale: function(scl){
- _slider.slider("value", 10*Math.log(scl));
- },
- countassoc: function(id, proj) {
- jQuery.ajax({
- url: _this.kc_api_root + "count-assoc.jsp",
- data: {
- id: id,
- proj: proj
- },
- success: function(response) {
- if (response.items.length > 0){
- for(i = 0, end = response.items.length; i < end; i++) {
- item = response.items[i];
- _pjs.setNodeValue(item.id, item.proj, item.name, item.grp, item.abst);
- if (item.assoc!=null) _pjs.setNodeAssoc(item.id, item.proj, item.assoc);
- if (item.mass!=null) _pjs.setNodeMass( item.id, item.proj, item.mass);
- }
- }
- }
- });
- },
- username: function() {
- var nodes = _pjs.getNodes().values().toArray(),
- nodetexts = IriSP._(nodes).chain().pluck("name").sortBy().value().join(",");
- showRelated(nodetexts);
- },
- mousemove: function(selection) {
- if (selection !== currentSelection) {
- if (selection) {
- triggerSearch(selection.name);
- }
- currentSelection = selection;
- }
- },
- click: function(selection) {
- if (selection) {
- triggerSearch(selection.name);
- showRelated(selection.name);
- } else {
- triggerSearch();
- }
- }
- };
- var uselessfuncts = [
- "selectnode", "selectedge", "topicnode","group_shapes",
- "allbackup", "allretrieve", "new_topic", "pedia", "set_mode",
- "new_relation", "startexpand", "endexpand", "new_select" //, "mouseover" //, "username"
- ];
-
- IriSP._(uselessfuncts).each(function(funcname) {
- _fns[funcname] = function() {
-// console.log("Function", funcname, "called with arguments", arguments);
- }
- });
-
- this.getWidgetAnnotations().forEach(function(annotation) {
- annotation.on("click", function() {
- var _tags = annotation.getTagTexts();
- if (_tags.length) {
- searchNodes(_tags);
- }
- });
- });
-
- this.source.getTags().forEach(function(tag) {
- tag.on("click", function() {
- if (tag.title) {
- searchNodes([tag.title]);
- }
- });
- });
-
- var keywmatch = document.location.hash.match(/keyword=([^#?&]+)/);
- if (keywmatch) {
- this.player.on("widgets-loaded", function() {
- triggerSearch(decodeURIComponent(keywmatch[1]));
- });
- }
-
- bindJavascript();
-
-};
diff -r 3ab36f402b0c -r 198c2b79f5e1 src/widgets/MediaList.js
--- a/src/widgets/MediaList.js Thu Jan 02 16:40:25 2014 +0100
+++ b/src/widgets/MediaList.js Thu Jan 02 16:49:20 2014 +0100
@@ -7,16 +7,16 @@
IriSP.Widgets.MediaList.prototype.messages = {
"fr": {
- now_playing: "Vidéo en cours",
- all_media: "Toutes les vidéos",
- other_media: "Autres vidéos"
+ now_playing: "Média en cours",
+ all_media: "Tous les medias",
+ other_media: "Autres médias"
},
"en": {
now_playing: "Now playing",
- all_media: "All videos",
- other_media: "Other videos"
+ all_media: "All media",
+ other_media: "Other media"
}
-};
+}
IriSP.Widgets.MediaList.prototype.defaults = {
default_thumbnail : "http://ldt.iri.centrepompidou.fr/static/site/ldt/css/imgs/video_sequence.png",
@@ -49,22 +49,17 @@
var _n = this.refresh(true);
if (this.searchString) {
if (_n) {
- this.player.trigger("search.matchFound");
+ this.player.popcorn.trigger("IriSP.search.matchFound");
} else {
- this.player.trigger("search.noMatchFound");
+ this.player.popcorn.trigger("IriSP.search.noMatchFound");
}
}
-};
+}
IriSP.Widgets.MediaList.prototype.draw = function() {
+ this.bindPopcorn("timeupdate","onTimeupdate");
this.$.addClass("Ldt-MediaListWidget")
this.renderTemplate();
- var _this = this;
- if (typeof this.media.getMedias === "function") {
- this.media.on("enter-annotation", function(_a) {
- _this.redraw(_a.getMedia());
- });
- }
this.redraw();
};
@@ -81,9 +76,9 @@
left: _scale * _annotation.begin,
width: _scale * (_annotation.end - _annotation.begin),
color: ( typeof _annotation.color !== "undefined" && _annotation.color ? _annotation.color : _this.default_color )
- };
- });
-};
+ }
+ })
+}
IriSP.Widgets.MediaList.prototype.redraw = function(_media) {
if (typeof _media !== "undefined") {
@@ -121,10 +116,21 @@
title: _media.title,
description: _media.description,
segments: _this.getSegments(_media)
- });
+ })
}).join("");
this.$.find('.Ldt-MediaList-OtherList').html(_html);
} else {
this.$.find('.Ldt-MediaList-Other').hide();
}
};
+
+IriSP.Widgets.MediaList.prototype.onTimeupdate = function() {
+ var _media = this.source.currentMedia;
+ if (_media.elementType === "mashup") {
+ _media = _media.getMediaAtTime(this.player.popcorn.currentTime() * 1000);
+ }
+ if (typeof _media !== "undefined" && _media.id !== this.lastMedia) {
+ this.lastMedia = _media.id;
+ this.redraw(_media);
+ }
+}
diff -r 3ab36f402b0c -r 198c2b79f5e1 src/widgets/Mediafragment.js
--- a/src/widgets/Mediafragment.js Thu Jan 02 16:40:25 2014 +0100
+++ b/src/widgets/Mediafragment.js Thu Jan 02 16:49:20 2014 +0100
@@ -4,33 +4,23 @@
this.last_hash_value = "";
window.onhashchange = this.functionWrapper("goToHash");
if (typeof window.addEventListener !== "undefined") {
- var _this = this;
window.addEventListener('message', function(_msg) {
if (/^#/.test(_msg.data)) {
- _this.setWindowHash(_msg.data);
+ this.setWindowHash(_msg.data);
}
- });
+ })
};
- this.onMdpEvent("Mediafragment.setHashToAnnotation","setHashToAnnotation");
+ this.bindPopcorn("pause","setHashToTime");
+ this.bindPopcorn("seeked","setHashToTime");
+ this.bindPopcorn("IriSP.Mediafragment.setHashToAnnotation","setHashToAnnotation");
this.blocked = false;
-};
+}
IriSP.Widgets.Mediafragment.prototype = new IriSP.Widgets.Widget();
IriSP.Widgets.Mediafragment.prototype.draw = function() {
- this.onMediaEvent("setpause","setHashToTime");
- var _this = this;
- this.getWidgetAnnotations().forEach(function(_annotation) {
- _annotation.on("click", function() {
- _this.setHashToAnnotation(_annotation.id);
- });
- });
- if (this.media.loadedMetadata) {
- this.goToHash();
- } else {
- this.onMediaEvent("loadedmetadata","goToHash");
- }
-};
+ this.goToHash();
+}
IriSP.Widgets.Mediafragment.prototype.setWindowHash = function(_hash) {
if (typeof window.history !== "undefined" && typeof window.history.replaceState !== "undefined") {
@@ -38,7 +28,7 @@
} else {
document.location.hash = _hash;
}
-};
+}
IriSP.Widgets.Mediafragment.prototype.getLastHash = function() {
var _tab = document.location.hash.replace(/^#/,'').split('&');
@@ -49,7 +39,7 @@
_tab.push(this.last_hash_key + '=' + this.last_hash_value);
}
return '#' + _tab.join('&');
-};
+}
IriSP.Widgets.Mediafragment.prototype.goToHash = function() {
if (document.location.hash !== this.getLastHash()) {
@@ -62,25 +52,27 @@
if (this.last_hash_key == "id") {
var _annotation = this.source.getElement(this.last_hash_value);
if (typeof _annotation !== "undefined") {
- this.media.setCurrentTime(_annotation.begin);
+ this.player.popcorn.currentTime(_annotation.begin.getSeconds());
}
}
if (this.last_hash_key == "t") {
- this.media.setCurrentTime(1000*this.last_hash_value);
+ this.player.popcorn.currentTime(this.last_hash_value);
}
break;
}
}
}
-};
+}
IriSP.Widgets.Mediafragment.prototype.setHashToAnnotation = function(_annotationId) {
this.setHash( 'id', _annotationId );
-};
+}
-IriSP.Widgets.Mediafragment.prototype.setHashToTime = function() {
- this.setHash( 't', this.media.getCurrentTime().getSeconds() );
-};
+IriSP.Widgets.Mediafragment.prototype.setHashToTime = function(_time) {
+ if (_time !== NaN) {
+ this.setHash( 't', this.player.popcorn.currentTime() );
+ }
+}
IriSP.Widgets.Mediafragment.prototype.setHash = function(_key, _value) {
if (!this.blocked && (this.last_hash_key !== _key || this.last_hash_value !== _value)) {
@@ -89,11 +81,11 @@
var _hash = this.getLastHash();
this.setWindowHash(_hash);
if (window.parent !== window) {
- window.parent.postMessage(_hash,"*");
+ window.parent.postMessage(_hash,"*")
}
this.block();
}
-};
+}
IriSP.Widgets.Mediafragment.prototype.unblock = function() {
if (typeof this.blockTimeout !== "undefined") {
@@ -101,12 +93,12 @@
}
this.blockTimeout = undefined;
this.blocked = false;
-};
+}
IriSP.Widgets.Mediafragment.prototype.block = function() {
if (typeof this.blockTimeout !== "undefined") {
window.clearTimeout(this.blockTimeout);
}
this.blocked = true;
- this.blockTimeout = window.setTimeout(this.functionWrapper("unblock"), 1500);
-};
+ this.blockTimeout = window.setTimeout(this.functionWrapper("unblock"), 1000);
+}
diff -r 3ab36f402b0c -r 198c2b79f5e1 src/widgets/MultiSegments.js
--- a/src/widgets/MultiSegments.js Thu Jan 02 16:40:25 2014 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,136 +0,0 @@
-IriSP.Widgets.MultiSegments = function(player, config) {
- IriSP.Widgets.Widget.call(this, player, config);
-};
-
-IriSP.Widgets.MultiSegments.prototype = new IriSP.Widgets.Widget();
-
-IriSP.Widgets.MultiSegments.prototype.defaults = {
- annotation_show_arrow: true,
- annotation_start_minimized: false,
- annotation_show_annotation_type: true,
- show_all: false
-};
-
-IriSP.Widgets.MultiSegments.prototype.draw = function() {
- var _this = this,
- lines = [],
- currentLine = null,
- segmentsopts = {},
- annotationopts = {};
- IriSP._(this).each(function(_v,_k) {
- if (/^segments_/.test(_k)) {
- segmentsopts[_k.replace(/^segments_/,"")] = _v;
- }
- if (/^annotation_/.test(_k)) {
- annotationopts[_k.replace(/^annotation_/,"")] = _v;
- }
- });
- this.source.getAnnotationTypes().forEach(function(_anntype) {
- var segments = _anntype.getAnnotations().filter(function(_ann) {
- return _ann.getDuration() > 0;
- });
- if (segments.length) {
-
- var visible = false;
-
- var line = {
- segmentWidget: IriSP.jQuery(""),
- annotationWidget: IriSP.jQuery("
"),
- hasSegmentsNow: function() {
- var _time = _this.media.getCurrentTime();
- return !!segments.filter(function(_annotation) {
- return _annotation.begin <= _time && _annotation.end > _time;
- }).length;
- },
- hide: function() {
- if (visible) {
- visible = false;
- this.annotationWidget.slideUp();
- }
- },
- show: function() {
- if (!visible) {
- visible = true;
- this.annotationWidget.slideDown();
- }
- }
- };
-
-
- line.segmentWidget
- .addClass("Ldt-MultiSegments-Segment")
- .appendTo(_this.$);
-
- if (!_this.show_all) {
- line.segmentWidget.mouseenter(function() {
- if (line.hasSegmentsNow()) {
- currentLine = line;
- checkVisibilities();
- }
- });
- }
-
- line.annotationWidget
- .addClass("Ldt-MultiSegments-Annotation")
- .appendTo(_this.$)
- .hide();
-
- _this.insertSubwidget(
- line.segmentWidget,
- IriSP._({
- type: "Segments",
- annotation_type: _anntype,
- width: _this.width
- }).extend(segmentsopts)
- );
-
- _this.insertSubwidget(
- line.annotationWidget,
- IriSP._({
- type: "Annotation",
- annotation_type: _anntype,
- width: _this.width
- }).extend(annotationopts)
- );
-
- lines.push(line);
- }
- });
-
- // open line on segment click
- $j(document).on("click",".Ldt-Segments-Segment",function(e){
- if (!_this.show_all && currentLine && !currentLine.hasSegmentsNow()) {
- currentLine = undefined;
- }
- IriSP._(lines).each(function(line) {
- if($j(e.target).parent().parent()[0]==line.segmentWidget[0]){
- currentLine = line;
- line.show();
- } else {
- line.hide();
- }
- });
- });
-
- //var _annotationWidgets = _this.$.find(".Ldt-MultiSegments-Annotation");
-
- function checkVisibilities(_time) {
- /*if (!_this.show_all && currentLine && !currentLine.hasSegmentsNow()) {
- currentLine = undefined;
- }
- IriSP._(lines).each(function(line) {
- if (line.hasSegmentsNow()) {
- if (!_this.show_all && !currentLine) {
- currentLine = line;
- }
- if (_this.show_all || line === currentLine) {
- line.show();
- } else {
- line.hide();
- }
- } else {
- line.hide();
- }
- });*/
- }
-};
\ No newline at end of file
diff -r 3ab36f402b0c -r 198c2b79f5e1 src/widgets/Polemic.js
--- a/src/widgets/Polemic.js Thu Jan 02 16:40:25 2014 +0100
+++ b/src/widgets/Polemic.js Thu Jan 02 16:49:20 2014 +0100
@@ -15,12 +15,11 @@
_to_: " to ",
_annotations: " annotation(s)"
}
-};
-
+}
IriSP.Widgets.Polemic.prototype.defaults = {
element_width : 5,
element_height : 5,
- max_elements: 20,
+ max_elements : 15,
annotation_type : "tweet",
defaultcolor : "#585858",
foundcolor : "#fc00ff",
@@ -48,9 +47,45 @@
]
};
+IriSP.Widgets.Polemic.prototype.onSearch = function(searchString) {
+ this.searchString = typeof searchString !== "undefined" ? searchString : '';
+ var _found = 0,
+ _re = IriSP.Model.regexpFromTextOrArray(searchString, true),
+ _this = this;
+ this.$tweets.each(function() {
+ var _el = IriSP.jQuery(this);
+ if (_this.searchString) {
+ if (_re.test(_el.attr("tweet-title"))) {
+ _el.css({
+ "background" : _this.foundcolor,
+ "opacity" : 1
+ });
+ _found++;
+ } else {
+ _el.css({
+ "background" : _el.attr("polemic-color"),
+ "opacity" : .3
+ });
+ }
+ } else {
+ _el.css({
+ "background" : _el.attr("polemic-color"),
+ "opacity" : 1
+ });
+ }
+ });
+ if (this.searchString) {
+ if (_found) {
+ this.player.popcorn.trigger("IriSP.search.matchFound");
+ } else {
+ this.player.popcorn.trigger("IriSP.search.noMatchFound");
+ }
+ }
+}
+
IriSP.Widgets.Polemic.prototype.draw = function() {
- this.onMediaEvent("timeupdate", "onTimeupdate");
+ this.bindPopcorn("timeupdate", "onTimeupdate");
this.$zone = IriSP.jQuery('
');
this.$zone.addClass("Ldt-Polemic");
this.$.append(this.$zone);
@@ -67,7 +102,6 @@
this.$zone.append(this.$elapsed);
- // we don't filter with null duration anymore
var _slices = [],
_slice_count = Math.floor( this.width / this.element_width ),
_duration = this.source.getDuration(),
@@ -83,10 +117,10 @@
begin : _begin.toString(),
end : _end.toString(),
annotations : _list.filter(function(_annotation) {
- return _annotation.begin >= _begin && _annotation.begin < _end;
+ return _annotation.begin >= _begin && _annotation.end < _end;
}),
polemicStacks : []
- };
+ }
for (var _j = 0; _j < this.polemics.length; _j++) {
var _polemic = _res.annotations.searchByDescription(this.polemics[_j].keywords);
@@ -115,7 +149,7 @@
function displayAnnotation(_elx, _ely, _pol, _col, _annotation) {
var _html = Mustache.to_html(
- '',
{
id: _annotation.id,
@@ -126,8 +160,7 @@
color: _col,
width: (_this.element_width-1),
height: _this.element_height,
- title: _annotation.title,
- time: _annotation.begin.toString()
+ title: _annotation.title
});
var _el = IriSP.jQuery(_html);
_el.mouseover(function() {
@@ -135,34 +168,16 @@
}).mouseout(function() {
_annotation.trigger("unselect");
}).click(function() {
- _annotation.trigger("click");
- return false;
- });
- IriSP.attachDndData(_el, {
- title: _annotation.title,
- description: _annotation.description,
- image: _annotation.thumbnail,
- uri: (typeof _annotation.url !== "undefined"
- ? _annotation.url
- : (document.location.href.replace(/#.*$/,'') + '#id=' + _annotation.id))
+ _this.player.popcorn.trigger("IriSP.Mediafragment.setHashToAnnotation", _annotation.id);
+ _this.player.popcorn.trigger("IriSP.Tweet.show", _annotation.id);
});
- // test if annotation has several colors.
- var colAr = [];
- for (var _j = 0; _j < _this.polemics.length; _j++) {
- if( IriSP.Model.regexpFromTextOrArray( _this.polemics[_j].keywords ).test( _annotation.title ) ){
- colAr.push(_this.polemics[_j].color);
- }
- }
- // display annotation
_annotation.on("select", function() {
- if (_this.tooltip) {
- _this.tooltip.show(
- + Math.floor(_elx + (_this.element_width - 1) / 2),
- + _ely,
- _annotation.title,
- ( (colAr.length>1) ? colAr : _col )
- );
- }
+ _this.tooltip.show(
+ Math.floor(_elx + (_this.element_width - 1) / 2),
+ _ely,
+ _annotation.title,
+ _col
+ );
_this.$tweets.each(function() {
var _e = IriSP.jQuery(this);
_e.css(
@@ -172,23 +187,9 @@
});
});
_annotation.on("unselect", function() {
- if (_this.tooltip) {
- _this.tooltip.hide();
- }
+ _this.tooltip.hide();
_this.$tweets.css("opacity",1);
});
- _annotation.on("found", function() {
- _el.css({
- "background" : _this.foundcolor,
- "opacity" : 1
- });
- });
- _annotation.on("not-found", function() {
- _el.css({
- "background" : _col,
- "opacity" : .3
- });
- });
_this.$zone.append(_el);
}
@@ -213,15 +214,9 @@
this.$tweets = this.$.find(".Ldt-Polemic-TweetDiv");
- this.source.getAnnotations().on("search-cleared", function() {
- _this.$tweets.each(function() {
- var _el = IriSP.jQuery(this);
- _el.css({
- "background" : _el.attr("polemic-color"),
- "opacity" : 1
- });
- });
- });
+ this.bindPopcorn("IriSP.search", "onSearch");
+ this.bindPopcorn("IriSP.search.closed", "onSearch");
+ this.bindPopcorn("IriSP.search.cleared", "onSearch");
} else {
this.$zone.hide();
@@ -262,7 +257,7 @@
IriSP._(_slices).forEach(function(_slice) {
var _y = _this.height,
_nums = _slice.annotations.length + "," + IriSP._(_slice.polemicStacks).map(function(_annotations) {
- return _annotations.length;
+ return _annotations.length
}).join(",");
if (_slice.annotations.length) {
var _h = Math.ceil(_scale * _slice.annotations.length);
@@ -292,19 +287,15 @@
_html = '
' + _this.l10n.from_ + _el.attr("begin-time") + _this.l10n._to_ + _el.attr("end-time") + '
';
for (var _i = 0; _i <= _this.polemics.length; _i++) {
var _color = _i ? _this.polemics[_i - 1].color : _this.defaultcolor;
- _html += '
' + _nums[_i] + _this.l10n._annotations + '
';
+ _html += '
' + _nums[_i] + _this.l10n._annotations + '
'
}
- if (_this.tooltip) {
- _this.tooltip.show(+ _el.attr("pos-x"), + _el.attr("pos-y"), _html);
- }
+ _this.tooltip.show(_el.attr("pos-x"), _el.attr("pos-y"), _html);
})
.mouseout(function() {
- if (_this.tooltip) {
- _this.tooltip.hide();
- }
- });
+ _this.tooltip.hide();
+ })
- };
+ }
this.$position = IriSP.jQuery('
').addClass("Ldt-Polemic-Position");
@@ -312,28 +303,20 @@
this.$zone.click(function(_e) {
var _x = _e.pageX - _this.$zone.offset().left;
- _this.media.setCurrentTime(_this.media.duration * _x / _this.width);
+ _this.player.popcorn.currentTime(_this.source.getDuration().getSeconds() * _x / _this.width);
});
this.$.append('
');
- this.insertSubwidget(
- this.$.find(".Ldt-Polemic-Tooltip"),
- {
- type: "Tooltip",
- min_x: 0,
- max_x: this.width
- },
- "tooltip"
- );
-};
+ this.insertSubwidget(this.$.find(".Ldt-Polemic-Tooltip"), "tooltip", { type: "Tooltip" });
+}
-IriSP.Widgets.Polemic.prototype.onTimeupdate = function(_time) {
- var _x = Math.floor( this.width * _time / this.media.duration);
+IriSP.Widgets.Polemic.prototype.onTimeupdate = function() {
+ var _x = Math.floor( this.width * this.player.popcorn.currentTime() / this.source.getDuration().getSeconds());
this.$elapsed.css({
width: _x + "px"
});
this.$position.css({
left: _x + "px"
- });
-};
+ })
+}
diff -r 3ab36f402b0c -r 198c2b79f5e1 src/widgets/PopcornPlayer.js
--- a/src/widgets/PopcornPlayer.js Thu Jan 02 16:40:25 2014 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,138 +0,0 @@
-IriSP.Widgets.PopcornPlayer = function(player, config) {
- IriSP.Widgets.Widget.call(this, player, config);
-};
-
-IriSP.Widgets.PopcornPlayer.prototype = new IriSP.Widgets.Widget();
-
-/* A Popcorn-based player for HTML5 Video, Youtube and Vimeo */
-
-IriSP.Widgets.PopcornPlayer.prototype.defaults = {
-};
-
-IriSP.Widgets.PopcornPlayer.prototype.draw = function() {
-
-
- if (typeof this.video === "undefined") {
- this.video = this.media.video;
- }
-
- if (this.url_transform) {
- this.video = this.url_transform(this.video);
- }
-
- if (/^(https?:\/\/)?(www\.)?vimeo\.com/.test(this.video)) {
-
- /* VIMEO */
-
- var _popcorn = Popcorn.vimeo(this.container, this.video);
-
- } else if (/^(https?:\/\/)?(www\.)?youtube\.com/.test(this.video)) {
-
- /* YOUTUBE */
-
- var _urlparts = this.video.split(/[?&]/),
- _params = {};
- for (var i = 1; i < _urlparts.length; i++) {
- var _ppart = _urlparts[i].split('=');
- _params[_ppart[0]] = decodeURIComponent(_ppart[1]);
- }
- _params.controls = 0;
- _params.modestbranding = 1;
- if (this.autostart || this.autoplay) {
- _params.autoplay = 1;
- }
- _url = _urlparts[0] + '?' + IriSP.jQuery.param(_params);
-
- var _popcorn = Popcorn.youtube(this.container, _url);
-
- } else {
-
- /* DEFAULT HTML5 */
-
- var _tmpId = IriSP._.uniqueId("popcorn"),
- _videoEl = IriSP.jQuery('