Made shot and task links real links with JS click handlers.

This allows "open in new window", while still using XHR for regular clicks.
This commit is contained in:
2016-09-23 10:28:47 +02:00
parent 78111968ab
commit e6e03125f7
6 changed files with 55 additions and 22 deletions

View File

@@ -34,11 +34,16 @@
/**
* Shows a task in the #task-details div.
*/
function task_open(task_id, project_url) {
if (task_id === undefined || project_url === undefined) {
function task_open(task_id) {
if (task_id === undefined) {
throw new ReferenceError("task_open(" + task_id + ") called.");
}
var project_url = ProjectUtils.projectUrl();
if (typeof project_url === 'undefined') {
throw "ProjectUtils.projectUrl() undefined";
}
$('#col_right .col_header span.header_text').text('Task details');
$('[id^="task-"]').removeClass('active');
@@ -60,11 +65,16 @@ function task_open(task_id, project_url) {
/**
* Shows a shot in the #task-details div.
*/
function shot_open(shot_id, project_url) {
if (shot_id === undefined || project_url === undefined) {
function shot_open(shot_id) {
if (shot_id === undefined) {
throw new ReferenceError("shot_open(" + shot_id + ") called.");
}
var project_url = ProjectUtils.projectUrl();
if (typeof project_url === 'undefined') {
throw "ProjectUtils.projectUrl() undefined";
}
$('#col_right .col_header span.header_text').text('Shot details');
$('[id^="shot-"]').removeClass('active');
@@ -209,3 +219,18 @@ function shot_save(shot_id, shot_url) {
type: 'shot'
});
}
$(function() {
$("a.shot-link[data-shot-id]").click(function(e) {
e.preventDefault();
// delegateTarget is the thing the event hander was attached to,
// rather than the thing we clicked on.
var shot_id = e.delegateTarget.dataset.shotId;
shot_open(shot_id);
});
$("a.task-link[data-task-id]").click(function(e) {
e.preventDefault();
var task_id = e.delegateTarget.dataset.taskId;
task_open(task_id);
});
});