Skip to content

Commit

Permalink
Small fixes for exhibits copy&paste feature
Browse files Browse the repository at this point in the history
  • Loading branch information
alterm4nn committed Jun 30, 2015
1 parent 2e8b5ab commit 8327bf6
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 16 deletions.
8 changes: 4 additions & 4 deletions Source/Chronozoom.UI/cz.merged.js
Original file line number Diff line number Diff line change
Expand Up @@ -4934,9 +4934,9 @@ var CZ;
//adding edit and copy button
if (CZ.Authoring.isEnabled) {
var imageSize = (titleTop - infodot.y) * 0.75;
var editButton = VCContent.addImage(infodot, layerid, id + "__edit", time - imageSize / 2, infodot.y + imageSize * 0.2, imageSize, imageSize, "/images/edit.svg");
var copyButton = VCContent.addImage(infodot, layerid, id + "__copy", time - imageSize / 2 - imageSize * 1.3, infodot.y + imageSize * 0.2, imageSize, imageSize, "/images/copy.svg");

var copyButton = VCContent.addImage(infodot, layerid, id + "__copy", time - imageSize, infodot.y + imageSize * 0.2, imageSize, imageSize, "/images/copy.svg");
var editButton = VCContent.addImage(infodot, layerid, id + "__edit", time, infodot.y + imageSize * 0.2, imageSize, imageSize, "/images/edit.svg");
editButton.reactsOnMouse = true;
copyButton.reactsOnMouse = true;

Expand Down Expand Up @@ -21189,4 +21189,4 @@ var CZ;

})(CZ.HomePageViewModel || (CZ.HomePageViewModel = {}));
var HomePageViewModel = CZ.HomePageViewModel;
})(CZ || (CZ = {}));
})(CZ || (CZ = {}));
102 changes: 96 additions & 6 deletions Source/Chronozoom.UI/czmin.merged.js
Original file line number Diff line number Diff line change
Expand Up @@ -3311,7 +3311,7 @@ var CZ;
this.pasteButton.onmousehover = function (event)
{
this.vc.element.css('cursor', 'pointer');
this.vc.element.attr('title', 'Paste Timeline');
this.vc.element.attr('title', 'Paste Timeline/Exhibit');
this.parent.settings.strokeStyle = "yellow";
}

Expand All @@ -3325,15 +3325,26 @@ var CZ;
this.pasteButton.onmouseclick = function (event)
{
var newTimeline = localStorage.getItem('ExportedTimeline');
var newExhibit = localStorage.getItem('ExportedExhibit');

if ((localStorage.getItem('ExportedSchemaVersion') == constants.schemaVersion) && newTimeline != null)
var sameDbSchema = localStorage.getItem('ExportedSchemaVersion') == constants.schemaVersion;

if (sameDbSchema && newTimeline != null)
{
// timeline from same db schema version is on "clipboard" so attempt "paste"
CZ.Service.importTimelines(this.parent.guid, newTimeline).then(function (importMessage)
{
CZ.Authoring.showMessageWindow(importMessage);
});
}
else if (sameDbSchema && newExhibit != null)
{
// exhibit from same db schema version is on "clipboard" so attempt "paste"
CZ.Service.importExhibit(this.parent.guid, newExhibit).then(function (importMessage)
{
CZ.Authoring.showMessageWindow(importMessage);
});
}
else
{
// unable to paste as nothing suitable is on "clipboard" so inform user
Expand Down Expand Up @@ -3380,7 +3391,8 @@ var CZ;
CZ.Service.exportTimelines(this.parent.guid).then(function (exportData)
{
localStorage.setItem('ExportedSchemaVersion', constants.schemaVersion);
localStorage.setItem('ExportedTimeline', JSON.stringify(exportData));
localStorage.setItem('ExportedTimeline', JSON.stringify(exportData));
localStorage.removeItem('ExportedExhibit');
CZ.Authoring.showMessageWindow('"' + exportData[0].timeline.title + '" has been copied to your clip-board. You can paste this into a different timeline.');
});
}
Expand Down Expand Up @@ -4919,12 +4931,14 @@ var CZ;
numberOfLines: 2
}, titleWidth);

//adding edit button
//adding edit and copy button
if (CZ.Authoring.isEnabled) {
var imageSize = (titleTop - infodot.y) * 0.75;
var editButton = VCContent.addImage(infodot, layerid, id + "__edit", time - imageSize / 2, infodot.y + imageSize * 0.2, imageSize, imageSize, "/images/edit.svg");

var copyButton = VCContent.addImage(infodot, layerid, id + "__copy", time - imageSize, infodot.y + imageSize * 0.2, imageSize, imageSize, "/images/copy.svg");
var editButton = VCContent.addImage(infodot, layerid, id + "__edit", time, infodot.y + imageSize * 0.2, imageSize, imageSize, "/images/edit.svg");

editButton.reactsOnMouse = true;
copyButton.reactsOnMouse = true;

editButton.onmouseclick = function () {
CZ.Authoring.isActive = true;
Expand All @@ -4933,6 +4947,17 @@ var CZ;
return true;
};

copyButton.onmouseclick = function () {
CZ.Service.exportExhibit(this.parent.guid).then(function (exportData) {
localStorage.setItem('ExportedSchemaVersion', constants.schemaVersion);
localStorage.setItem('ExportedExhibit', JSON.stringify(exportData));
localStorage.removeItem('ExportedTimeline');
CZ.Authoring.showMessageWindow('"' + exportData.title + '" has been copied to your clip-board. You can paste this into a different timeline.');
});
return true;
};


editButton.onmouseenter = function ()
{
this.vc.element.css('cursor', 'pointer');
Expand All @@ -4946,6 +4971,18 @@ var CZ;
this.vc.element.attr('title', '');
infodot.settings.strokeStyle = CZ.Settings.infoDotBorderColor;
};

copyButton.onmouseenter = function () {
this.vc.element.css('cursor', 'pointer');
this.vc.element.attr('title', 'Copy Exhibit to Clipboard');
infodot.settings.strokeStyle = "yellow";
};

copyButton.onmouseleave = function () {
this.vc.element.css('cursor', 'default');
this.vc.element.attr('title', '');
infodot.settings.strokeStyle = CZ.Settings.infoDotBorderColor;
};
}

var biblBottom = vyc + centralSquareSize + 63.0 / 450 * 2 * radv;
Expand Down Expand Up @@ -10129,6 +10166,59 @@ var CZ;
}
Service.importTimelines = importTimelines;

// .../export/exhibit/{exhibitId}
function exportExhibit(exhibitId) {
if (typeof exhibitId === 'undefined') {
throw 'exportExhibit(exhibitId) requires a parameter.';
}
if (/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(exhibitId) == false) {
if (exhibitId != "00000000-0000-0000-0000-000000000000")
throw 'exportExhibit(exhibitId) has an invalid parameter. The provided parameter must be a GUID.';
}
CZ.Authoring.resetSessionTimer();
var request = new Request(_serviceUrl);
request.addToPath('export');
request.addToPath('exhibit');
request.addToPath(exhibitId);
return $.ajax
({
type: 'GET',
cache: false,
url: request.url,
dataType: 'json'
});
}
Service.exportExhibit = exportExhibit;

// .../import/exhibit/{intoTimelineId}
function importExhibit(intoTimelineId, newExhibit) {
if (typeof intoTimelineId === 'undefined' || typeof newExhibit === 'undefined') {
throw 'importExhibit(intoTimelineId, newExhibit) is missing a parameter.';
}
if (/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(intoTimelineId) == false) {
if (intoTimelineId != "00000000-0000-0000-0000-000000000000")
throw 'importExhibit(intoTimelineId, newExhibit) has an invalid intoTimelineId parameter. This must be a GUID.';
}
if (typeof newExhibit !== 'string') {
throw 'importExhibit(intoTimelineId, newExhibit) has an invalid newTimelineTree parameter. This must be a JSON.stringify string.';
}
CZ.Authoring.resetSessionTimer();
var request = new Request(_serviceUrl);
request.addToPath('import');
request.addToPath('exhibit');
request.addToPath(intoTimelineId);
return $.ajax
({
type: 'PUT',
cache: false,
url: request.url,
contentType: 'application/json',
dataType: 'json',
data: newExhibit // should already be JSON.stringified
});
}
Service.importExhibit = importExhibit;

// .../import/collection
function importCollection(collectionTree)
{
Expand Down
6 changes: 3 additions & 3 deletions Source/Chronozoom.UI/scripts/vccontent.js
Original file line number Diff line number Diff line change
Expand Up @@ -2797,9 +2797,9 @@ var CZ;
//adding edit and copy button
if (CZ.Authoring.isEnabled) {
var imageSize = (titleTop - infodot.y) * 0.75;
var editButton = VCContent.addImage(infodot, layerid, id + "__edit", time - imageSize / 2, infodot.y + imageSize * 0.2, imageSize, imageSize, "/images/edit.svg");
var copyButton = VCContent.addImage(infodot, layerid, id + "__copy", time - imageSize / 2 - imageSize * 1.3, infodot.y + imageSize * 0.2, imageSize, imageSize, "/images/copy.svg");

var copyButton = VCContent.addImage(infodot, layerid, id + "__copy", time - imageSize, infodot.y + imageSize * 0.2, imageSize, imageSize, "/images/copy.svg");
var editButton = VCContent.addImage(infodot, layerid, id + "__edit", time, infodot.y + imageSize * 0.2, imageSize, imageSize, "/images/edit.svg");
editButton.reactsOnMouse = true;
copyButton.reactsOnMouse = true;

Expand Down
2 changes: 1 addition & 1 deletion Source/Chronozoom.UI/scripts/vccontent.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Source/Chronozoom.UI/scripts/vccontent.min.js.map

Large diffs are not rendered by default.

0 comments on commit 8327bf6

Please sign in to comment.