Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Share modal updates #494

Open
wants to merge 1 commit into
base: horizon
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 1 addition & 66 deletions src/web/js/share.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ window.makeShareAPI = function makeShareAPI(pyretVersion) {
text: importCode
},
{
message: "You can also click Update below to copy the current version to the published version, or click Close to exit this window."
message: "You can also click Update below to copy the current version to the published version, or click Cancel to exit this window."
}
]
});
Expand Down Expand Up @@ -181,71 +181,6 @@ window.makeShareAPI = function makeShareAPI(pyretVersion) {
}
}

function autoHighlightBox(text) {
var textBox = $("<input type='text'>").addClass("auto-highlight");
textBox.attr("size", text.length);
textBox.attr("editable", false);
textBox.on("focus", function() { $(this).select(); });
textBox.on("mouseup", function() { $(this).select(); });
textBox.val(text);
return textBox;
}

function getLanguage() {
if(typeof navigator !== "undefined") {
return navigator.language || "en-US"; // Biased towards USA
}
else {
return "en-US";
}
}

var dateOptions = {
weekday: "short",
year: "numeric",
month: "short",
day: "numeric",
hour: "numeric",
minute: "numeric"
};

function drawShareRow(f) {
var container = $("<div>").addClass("sharebox");
var shareUrl = makeShareUrl(f.getUniqueId());
var displayDate = new Date(f.getModifiedTime()).toLocaleString(getLanguage, dateOptions);
var hoverDate = String(new Date(f.getModifiedTime()));
container.append($("<label>").text(displayDate).attr("alt", hoverDate));
var shareLink = $("<a href='javascript:void()'>").text("(Share Link)").addClass("copy-link");
var importLink = $("<a href='javascript:void()'>").text("(Import Code)").addClass("copy-link");
container.append(shareLink);
container.append(importLink);
function showCopyText(title, text) {
var linkDiv = $("<div>").css({"z-index": 15000});
linkDiv.dialog({
title: title,
modal: true,
overlay : { opacity: 0.5, background: 'black'},
width : "70%",
height : "auto",
closeOnEscape : true
});
var box = autoHighlightBox(text);
linkDiv.append(box);
box.focus();
}
shareLink.click(function() {
showCopyText("Copy Share Link", shareUrl);
});

var importLetter = getImportLetter(f.getName()[0]);
var importCode = "import shared-gdrive(\"" + f.getName() +
"\", \"" + f.getUniqueId() + "\") as " + importLetter;
importLink.click(function() {
showCopyText("Copy Import Code", importCode);
});
return container;
}

return {
makeShareLink: makeShareLink,
//makeHoverMenu: makeHoverMenu,
Expand Down