|
|
@ -1,3 +1,16 @@
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(c) 2014 Michael Murtaugh and contributors to the Digital Publishing Toolkit
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
License: GPL3
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
This code has been developed as part of the [Digital Publishing Toolkit](http://digitalpublishingtoolkit.org).
|
|
|
|
|
|
|
|
with the support of Institute for [Network Cultures](http://networkcultures.org)
|
|
|
|
|
|
|
|
and [Creating 010](http://creating010.com).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var editor_factory = aa_aceeditor(window.ace),
|
|
|
|
var editor_factory = aa_aceeditor(window.ace),
|
|
|
|
editor = editor_factory.get_editor(),
|
|
|
|
editor = editor_factory.get_editor(),
|
|
|
|
editor_elt = d3.select(editor.elt),
|
|
|
|
editor_elt = d3.select(editor.elt),
|
|
|
@ -21,6 +34,7 @@ var editor_factory = aa_aceeditor(window.ace),
|
|
|
|
.append("div")
|
|
|
|
.append("div")
|
|
|
|
.attr("class", "gear");
|
|
|
|
.attr("class", "gear");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function url_for (script) {
|
|
|
|
function url_for (script) {
|
|
|
|
return cgi_url+script+"?p=" + encodeURIComponent(project);
|
|
|
|
return cgi_url+script+"?p=" + encodeURIComponent(project);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -92,17 +106,30 @@ aa_frames(document.getElementById("split"));
|
|
|
|
|
|
|
|
|
|
|
|
document.getElementById("editor").appendChild(editor.elt);
|
|
|
|
document.getElementById("editor").appendChild(editor.elt);
|
|
|
|
|
|
|
|
|
|
|
|
function edit (url) {
|
|
|
|
var activeURL;
|
|
|
|
editor.href(url);
|
|
|
|
|
|
|
|
|
|
|
|
function updateActiveItem () {
|
|
|
|
|
|
|
|
var item = d3.selectAll("#listing div.item")
|
|
|
|
|
|
|
|
.classed("active", function (d) {
|
|
|
|
|
|
|
|
return d.url == activeURL;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function edit (url, done, forceReload) {
|
|
|
|
|
|
|
|
activeURL = url;
|
|
|
|
|
|
|
|
editor.href(url, done, forceReload);
|
|
|
|
|
|
|
|
editor.aceeditor.focus();
|
|
|
|
editor_elt
|
|
|
|
editor_elt
|
|
|
|
.style("display", "block");
|
|
|
|
.style("display", "block");
|
|
|
|
preview_div
|
|
|
|
preview_div
|
|
|
|
.style("display", "none");
|
|
|
|
.style("display", "none");
|
|
|
|
close_make();
|
|
|
|
close_make();
|
|
|
|
|
|
|
|
updateActiveItem();
|
|
|
|
// make_div.style("display", "none");
|
|
|
|
// make_div.style("display", "none");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function preview (url) {
|
|
|
|
function preview (url) {
|
|
|
|
|
|
|
|
activeURL = url;
|
|
|
|
preview_div
|
|
|
|
preview_div
|
|
|
|
.style("display", "block");
|
|
|
|
.style("display", "block");
|
|
|
|
editor_elt
|
|
|
|
editor_elt
|
|
|
@ -110,6 +137,7 @@ function preview (url) {
|
|
|
|
preview_iframe
|
|
|
|
preview_iframe
|
|
|
|
.attr("src", url);
|
|
|
|
.attr("src", url);
|
|
|
|
close_make();
|
|
|
|
close_make();
|
|
|
|
|
|
|
|
updateActiveItem();
|
|
|
|
// make_div.style("display", "none");
|
|
|
|
// make_div.style("display", "none");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -143,18 +171,11 @@ function make (path, done) {
|
|
|
|
function make_busy (val) {
|
|
|
|
function make_busy (val) {
|
|
|
|
make_div.classed("busy", val);
|
|
|
|
make_div.classed("busy", val);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
|
|
|
|
function select_all () {
|
|
|
|
function select_all () {
|
|
|
|
var checkboxes = d3.selectAll(".itemcheckbox"),
|
|
|
|
d3.selectAll("#listing div.item").each(item_select);
|
|
|
|
checked = d3.selectAll(".itemcheckbox:checked");
|
|
|
|
|
|
|
|
if (checkboxes.size() == checked.size()) {
|
|
|
|
|
|
|
|
checkboxes.property("checked", false);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
checkboxes.property("checked", true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
update_selection();
|
|
|
|
update_selection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function delete_selection () {
|
|
|
|
function delete_selection () {
|
|
|
|
var items_selected = d3.selectAll("#listing div.selected"),
|
|
|
|
var items_selected = d3.selectAll("#listing div.selected"),
|
|
|
@ -181,6 +202,25 @@ function delete_selection () {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function download_selection () {
|
|
|
|
|
|
|
|
var items_selected = d3.selectAll("#listing div.selected"),
|
|
|
|
|
|
|
|
num_selected = items_selected.size(),
|
|
|
|
|
|
|
|
paths = items_selected.data().map(function (d) { return d.path });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (num_selected == 0) return;
|
|
|
|
|
|
|
|
var ok = true; //confirm("Download "+num_selected+" selected file"+((num_selected==1)?"":"s") + "?");
|
|
|
|
|
|
|
|
if (ok) {
|
|
|
|
|
|
|
|
var url = url_for("download.cgi");
|
|
|
|
|
|
|
|
url += paths.map(function(x) { return "&f[]="+encodeURIComponent(x); }).join("");
|
|
|
|
|
|
|
|
// console.log("download", url);
|
|
|
|
|
|
|
|
preview_iframe
|
|
|
|
|
|
|
|
.attr("src", url);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
items_selected.each(item_deselect);
|
|
|
|
|
|
|
|
update_selection();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var longclick_begin;
|
|
|
|
var longclick_begin;
|
|
|
|
|
|
|
|
|
|
|
|
function item_select (d) {
|
|
|
|
function item_select (d) {
|
|
|
@ -256,7 +296,7 @@ function rename () {
|
|
|
|
$("#listing .listing_rename_buttons").hide();
|
|
|
|
$("#listing .listing_rename_buttons").hide();
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var ok = confirm("Rename "+ss.size()+" file"+((ss==1)?"":"s") + "?");
|
|
|
|
var ok = true; // confirm("Rename "+ss.size()+" file"+((ss==1)?"":"s") + "?");
|
|
|
|
if (ok) {
|
|
|
|
if (ok) {
|
|
|
|
ss.each(function (d) {
|
|
|
|
ss.each(function (d) {
|
|
|
|
var newpath = d3.select(this.parentNode).select("input.rename").property("value");
|
|
|
|
var newpath = d3.select(this.parentNode).select("input.rename").property("value");
|
|
|
@ -320,12 +360,16 @@ function refresh_listing(done) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (d.remake) {
|
|
|
|
if (d.remake) {
|
|
|
|
// alert("make");
|
|
|
|
// alert("make");
|
|
|
|
|
|
|
|
activeURL = d.url;
|
|
|
|
|
|
|
|
updateActiveItem();
|
|
|
|
make(d.path, function () {
|
|
|
|
make(d.path, function () {
|
|
|
|
// re-get the d in case of change!
|
|
|
|
// re-get the d in case of change!
|
|
|
|
var d = d3.select(that).datum();
|
|
|
|
var d = d3.select(that).datum();
|
|
|
|
// console.log("d", d, d.binary, d.url);
|
|
|
|
// console.log("d", d, d.binary, d.url);
|
|
|
|
if (!d.binary) {
|
|
|
|
if (!d.binary) {
|
|
|
|
edit(d.url);
|
|
|
|
// force reload!
|
|
|
|
|
|
|
|
console.log("force reload")
|
|
|
|
|
|
|
|
edit(d.url, null, true);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
preview(d.url);
|
|
|
|
preview(d.url);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -364,8 +408,10 @@ refresh_listing();
|
|
|
|
$("#listing .body").niceScroll({cursorcolor:"#0F0"});
|
|
|
|
$("#listing .body").niceScroll({cursorcolor:"#0F0"});
|
|
|
|
$("#editor .make .body").niceScroll({cursorcolor:"#0F0"});
|
|
|
|
$("#editor .make .body").niceScroll({cursorcolor:"#0F0"});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$("#listing_select_all").click(select_all);
|
|
|
|
$("#listing_refresh").click(refresh_listing);
|
|
|
|
$("#listing_refresh").click(refresh_listing);
|
|
|
|
$("#listing_delete").click(delete_selection);
|
|
|
|
$("#listing_delete").click(delete_selection);
|
|
|
|
|
|
|
|
$("#listing_download").click(download_selection);
|
|
|
|
$("#listing_rename").click(rename);
|
|
|
|
$("#listing_rename").click(rename);
|
|
|
|
$("#listing_cancel").click(listing_cancel);
|
|
|
|
$("#listing_cancel").click(listing_cancel);
|
|
|
|
// $("#listing_select_all").click(select_all);
|
|
|
|
// $("#listing_select_all").click(select_all);
|
|
|
|