Skip to content

Commit

Permalink
Merged in JulianKniephoff/annotation-tool/i28/print-view (pull request
Browse files Browse the repository at this point in the history
…#19)

Show the title of the video
  • Loading branch information
JulianKniephoff authored and rrolf committed Jul 4, 2017
2 parents 1f70d47 + b7cbb53 commit e2d00ea
Show file tree
Hide file tree
Showing 14 changed files with 336 additions and 383 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -445,9 +445,9 @@ define(["jquery",
}
mediapackage = result.mediapackage;

video_title = result.DcTitle;
video_creator = result.DcCreator;
video_creation_date = result.DcCreated;
video_title = result.dcTitle;
video_creator = result.dcCreator;
video_creation_date = result.dcCreated;

$.each(videoTypesForFallBack, function (idx, mimetype) {
videosFallback[mimetype] = {};
Expand Down
12 changes: 3 additions & 9 deletions frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
</head>
<body>
<!--[if lt IE 7]><p class=chromeframe>Your browser is <em>ancient!</em> <a href="http://browsehappy.com/">Upgrade to a different browser</a> or <a href="http://www.google.com/chromeframe/?redirect=true">install Google Chrome Frame</a> to experience this site.</p><![endif]-->

<div id="screen">
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container-fluid">
Expand Down Expand Up @@ -88,12 +88,6 @@ <h1>Loading</h1>
<div class="row-fluid">
<div class="span6" id="left-column">

<div id="title-container">
<div id="video-title"></div>
<div id="video-owner"></div>
<div id="video-date"></div>
</div>

<!-- container for the video -->
<div id="video-container" class="window" style="display:none">
<video id="example" style="width:100%" controls >
Expand Down Expand Up @@ -232,7 +226,7 @@ <h1>Loading</h1>
<div class="modal" id="scale-editor" style="display:none"></div>
<div class="modal" id="alert" style="display:none"></div>
<div class="modal" id="tracks-selection" style="display:none"></div>
<!-- Containter for the categories legend, only displayed in print mode -->
<div id="categories-legend" class="print"></div>
</div>
<div id="print-view"></div>
</body>
</html>
1 change: 1 addition & 0 deletions frontend/js/annotations-tool.js
Original file line number Diff line number Diff line change
Expand Up @@ -983,6 +983,7 @@ define(["jquery",
videos.add({video_extid: this.getVideoExtId()});
video = videos.at(0);
this.video = video;
video.set(self.getVideoParameters());
video.save();
if (video.get("ready")) {
createDefaultTrack();
Expand Down
9 changes: 1 addition & 8 deletions frontend/js/views/list-annotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,10 @@ define(["jquery",
"templates/list-annotation",
"templates/list-annotation-expanded",
"templates/list-annotation-edit",
"templates/list-annotation-print",
"backbone",
"handlebarsHelpers"],

function ($, _, PlayerAdapter, Annotation, User, CommentsContainer, TmplCollapsed, TmplExpanded, TmplEdit, TmplPrint, Backbone) {
function ($, _, PlayerAdapter, Annotation, User, CommentsContainer, TmplCollapsed, TmplExpanded, TmplEdit, Backbone) {

"use strict";

Expand Down Expand Up @@ -736,12 +735,6 @@ define(["jquery",
"dblclick span.text" : "toggleEditState",
"dblclick span.category" : "toggleEditState"
}
},
PRINT: {
render: TmplPrint,
withComments: true,
id: "print",
events: {}
}
}
});
Expand Down
50 changes: 8 additions & 42 deletions frontend/js/views/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ define(["jquery",
"views/login",
"views/scale-editor",
"views/tracks-selection",
"views/print",
"collections/annotations",
"collections/users",
"collections/videos",
"models/user",
"models/track",
"models/video",
"templates/categories-legend",
"roles",
"backbone",
"handlebars",
Expand All @@ -65,8 +65,8 @@ define(["jquery",
"tab"],

function ($, _, Mousetrap, PlayerAdapter, AnnotateView, ListView, ListAnnotationView, TimelineView, LoginView,
ScaleEditorView, TracksSelectionView, Annotations, Users, Videos, User, Track, Video,
CategoriesLegendTmpl, ROLES, Backbone) {
ScaleEditorView, TracksSelectionView, PrintView, Annotations, Users, Videos, User, Track, Video,
ROLES, Backbone) {

"use strict";

Expand Down Expand Up @@ -101,14 +101,6 @@ define(["jquery",
loadingBox: $("div#loading"),


/**
* Template for the categories legend
* @alias module:views-main.MainView#categoriesLegendTmpl
* @type {HandlebarsTemplate}
*/
categoriesLegendTmpl: CategoriesLegendTmpl,


/**
* Events to handle by the main view
* @alias module:views-main.MainView#event
Expand All @@ -130,7 +122,6 @@ define(["jquery",
_.bindAll(this, "layoutUpdate",
"checkUserAndLogin",
"createViews",
"generateCategoriesLegend",
"logout",
"loadPlugins",
"onDeletePressed",
Expand All @@ -139,8 +130,7 @@ define(["jquery",
"ready",
"setupKeyboardShortcuts",
"tracksSelection",
"setLoadingProgress",
"updateTitle");
"setLoadingProgress");
annotationsTool.bind(annotationsTool.EVENTS.NOTIFICATION, function (message) {
this.setLoadingProgress(this.loadingPercent, message);
}, this);
Expand Down Expand Up @@ -179,8 +169,6 @@ define(["jquery",

annotationsTool.once(annotationsTool.EVENTS.READY, function () {
this.loadPlugins(annotationsTool.plugins);
this.generateCategoriesLegend(annotationsTool.video.get("categories").toExportJSON(true));
this.updateTitle(annotationsTool.video);

if (!annotationsTool.isFreeTextEnabled()) {
$("#opt-annotate-text").parent().hide();
Expand Down Expand Up @@ -208,30 +196,6 @@ define(["jquery",
}, this);
},

/**
* Updates the title of the page for print mode
* @param {object} video The video model
* @alias module:views-main.MainView#updateTitle
*/
updateTitle: function (video) {
this.$el.find("#video-title").html(video.get("title"));
this.$el.find("#video-owner").html("Owner: " + video.get("src_owner"));
if (_.isUndefined(video.get("src_creation_date"))) {
this.$el.find("#video-date").remove();
} else {
this.$el.find("#video-date").html("Date: " + video.get("src_creation_date"));
}
},

/**
* Generates the legend for all the categories (for printing)
* @param {array} categories The array containing all the categories
* @alias module:views-main.MainView#generateCategoriesLegend
*/
generateCategoriesLegend: function (categories) {
this.$el.find("#categories-legend").html(this.categoriesLegendTmpl(categories));
},

/**
* Creates the views for the annotations
* @alias module:views-main.MainView#createViews
Expand Down Expand Up @@ -458,19 +422,21 @@ define(["jquery",
* @alias module:views-main.MainView#print
*/
print: function () {
var oldStates = this.listView.setStateToAllViews(ListAnnotationView.STATES.PRINT);
window.focus();
if (document.readyState === "complete") {
var printView = new PrintView(annotationsTool);
printView.render();
window.print();
printView.remove();

// If is Chrome, we need to refresh the window
// TODO WHY??!?!
if (/chrome/i.test(navigator.userAgent)) {
document.location.reload(false);
}
} else {
setTimeout(this.print, 1000);
}
this.listView.setStates(oldStates);
},

/**
Expand Down
Loading

0 comments on commit e2d00ea

Please sign in to comment.