mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-03-23 05:49:55 +01:00
Merge branch 'redesign-js' into develop
This commit is contained in:
commit
0fcd4e9709
@ -16,5 +16,5 @@ release.dir = release
|
||||
|
||||
|
||||
# tools
|
||||
wepp = tools/wepp
|
||||
tool.wepp = tools/wepp
|
||||
|
||||
|
@ -45,7 +45,7 @@
|
||||
background-color: #f6f6f6;
|
||||
color: #e80;
|
||||
}
|
||||
&.selected {
|
||||
&.selected:not(.selecting), &.selecting:not(.selected) {
|
||||
border-color: rgba(240,100,0,0.2);
|
||||
background-color: rgba(240,100,0,0.2);
|
||||
}
|
||||
@ -193,7 +193,7 @@
|
||||
border-color: #eee;
|
||||
background-color: #f6f6f6;
|
||||
}
|
||||
&.selected {
|
||||
&.selected:not(.selecting), &.selecting:not(.selected) {
|
||||
border-color: rgba(240,100,0,0.2);
|
||||
background-color: rgba(240,100,0,0.2);
|
||||
}
|
||||
|
@ -27,9 +27,7 @@
|
||||
</span>
|
||||
</span>
|
||||
</footer>
|
||||
<script src="/h5ai/js/lib/jquery.min.js"></script>
|
||||
<script src="/h5ai/js/lib/jquery.mousewheel.min.js"></script>
|
||||
<script src="/h5ai/js/lib/jquery.fracs-core.min.js"></script>
|
||||
<script src="/h5ai/js/libs.js"></script>
|
||||
<script src="/h5ai/options.js"></script>
|
||||
<script src="/h5ai/js/main-js.js"></script>
|
||||
</body>
|
||||
|
@ -14,7 +14,7 @@
|
||||
<link rel="apple-touch-icon" type="image/png" href="/h5ai/images/h5ai-48x48.png">
|
||||
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Ubuntu:regular,italic,bold">
|
||||
<link rel="stylesheet" href="/h5ai/css/main-js.css">
|
||||
<script src="/h5ai/js/lib/modernizr.min.js"></script>
|
||||
<script src="/h5ai/js/modernizr.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="selection-rect"></div>
|
||||
|
@ -15,7 +15,7 @@
|
||||
<link rel="apple-touch-icon" type="image/png" href="/h5ai/images/h5ai-48x48.png">
|
||||
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Ubuntu:regular,italic,bold">
|
||||
<link rel="stylesheet" href="/h5ai/css/main-php.css">
|
||||
<script src="/h5ai/js/lib/modernizr.min.js"></script>
|
||||
<script src="/h5ai/js/modernizr.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="selection-rect"></div>
|
||||
@ -60,9 +60,7 @@
|
||||
</span>
|
||||
</span>
|
||||
</footer>
|
||||
<script src="/h5ai/js/lib/jquery.min.js"></script>
|
||||
<script src="/h5ai/js/lib/jquery.mousewheel.min.js"></script>
|
||||
<script src="/h5ai/js/lib/jquery.fracs-core.min.js"></script>
|
||||
<script src="/h5ai/js/libs.js"></script>
|
||||
<script src="/h5ai/options.js"></script>
|
||||
<script src="/h5ai/js/main-php.js"></script>
|
||||
<section id="table">
|
||||
|
@ -1,13 +1,13 @@
|
||||
/*global $, Objects */
|
||||
/*global $, H5aiJs */
|
||||
|
||||
Objects.Tree = function (pathCache, h5ai) {
|
||||
H5aiJs.factory.Connector = function () {
|
||||
|
||||
var contentTypeRegEx = /^text\/html;h5ai=/,
|
||||
pathnameStatusCache = {},
|
||||
fetchStatus = function (pathname, callback) {
|
||||
|
||||
if (h5ai.settings.folderStatus[pathname]) {
|
||||
callback(h5ai.settings.folderStatus[pathname]);
|
||||
if (H5aiJs.h5ai.settings.folderStatus[pathname]) {
|
||||
callback(H5aiJs.h5ai.settings.folderStatus[pathname]);
|
||||
return;
|
||||
} else if (pathnameStatusCache[pathname]) {
|
||||
callback(pathnameStatusCache[pathname]);
|
||||
@ -37,14 +37,14 @@ Objects.Tree = function (pathCache, h5ai) {
|
||||
if (status !== "h5ai") {
|
||||
path.status = status;
|
||||
}
|
||||
path.updateHtml();
|
||||
h5ai.linkHoverStates();
|
||||
H5aiJs.html.updateHtml(path);
|
||||
H5aiJs.h5ai.linkHoverStates();
|
||||
});
|
||||
}
|
||||
},
|
||||
updatePaths = function () {
|
||||
|
||||
$.each(pathCache.cache, function (ref, cached) {
|
||||
$.each(H5aiJs.pathCache.cache, function (ref, cached) {
|
||||
updatePath(cached);
|
||||
});
|
||||
},
|
||||
@ -76,7 +76,7 @@ Objects.Tree = function (pathCache, h5ai) {
|
||||
|
||||
$(html).find("#table td").closest("tr").each(function () {
|
||||
|
||||
var path = pathCache.getPath(pathname, this);
|
||||
var path = H5aiJs.pathCache.getPath(pathname, this);
|
||||
|
||||
if (path.isFolder && (!path.isParentFolder || includeParent)) {
|
||||
content[path.absHref] = path;
|
||||
@ -92,7 +92,7 @@ Objects.Tree = function (pathCache, h5ai) {
|
||||
|
||||
fetchStatusAndContent(pathname, false, function (status, content) {
|
||||
|
||||
var path = pathCache.getPath(pathname);
|
||||
var path = H5aiJs.pathCache.getPath(pathname);
|
||||
|
||||
path.status = status;
|
||||
path.content = content;
|
||||
@ -103,7 +103,7 @@ Objects.Tree = function (pathCache, h5ai) {
|
||||
|
||||
fetchPath(pathname, function (path) {
|
||||
|
||||
var parent = pathCache.splitPathname(pathname)[0];
|
||||
var parent = H5aiJs.pathCache.splitPathname(pathname)[0];
|
||||
|
||||
path.treeOpen = true;
|
||||
if (childPath) {
|
||||
@ -120,25 +120,24 @@ Objects.Tree = function (pathCache, h5ai) {
|
||||
|
||||
fetchTree(document.location.pathname, function (path) {
|
||||
$("#tree")
|
||||
.append(path.updateTreeHtml())
|
||||
.append(H5aiJs.html.updateTreeHtml(path))
|
||||
.scrollpanel()
|
||||
.show();
|
||||
h5ai.shiftTree(false, true);
|
||||
h5ai.linkHoverStates();
|
||||
H5aiJs.h5ai.shiftTree(false, true);
|
||||
H5aiJs.h5ai.linkHoverStates();
|
||||
setTimeout(function () { $("#tree").get(0).updateScrollbar(); }, 1);
|
||||
});
|
||||
},
|
||||
init = function () {
|
||||
|
||||
if (h5ai.settings.showTree) {
|
||||
if (H5aiJs.h5ai.settings.showTree) {
|
||||
updatePaths();
|
||||
populateTree();
|
||||
}
|
||||
},
|
||||
tree = {
|
||||
fetchStatusAndContent: fetchStatusAndContent,
|
||||
init: init
|
||||
};
|
||||
|
||||
return tree;
|
||||
return {
|
||||
fetchStatusAndContent: fetchStatusAndContent,
|
||||
init: init
|
||||
};
|
||||
};
|
@ -1,6 +1,6 @@
|
||||
/*global $, Objects */
|
||||
/*global $, H5aiJs */
|
||||
|
||||
Objects.Extended = function (pathCache, h5ai) {
|
||||
H5aiJs.factory.Extended = function () {
|
||||
|
||||
var settings = {
|
||||
customHeader: "h5ai.header.html",
|
||||
@ -17,15 +17,15 @@ Objects.Extended = function (pathCache, h5ai) {
|
||||
|
||||
var $ul = $("body > nav ul"),
|
||||
pathname = "/",
|
||||
path = pathCache.getPath(pathname),
|
||||
path = H5aiJs.pathCache.getPath(pathname),
|
||||
pathnameParts = document.location.pathname.split("/");
|
||||
|
||||
$ul.append(path.updateCrumbHtml());
|
||||
$ul.append(H5aiJs.html.updateCrumbHtml(path));
|
||||
|
||||
$.each(pathnameParts, function (idx, part) {
|
||||
if (part !== "") {
|
||||
pathname += part + "/";
|
||||
$ul.append(pathCache.getPath(pathname).updateCrumbHtml());
|
||||
$ul.append(H5aiJs.html.updateCrumbHtml(H5aiJs.pathCache.getPath(pathname)));
|
||||
}
|
||||
});
|
||||
},
|
||||
@ -37,8 +37,8 @@ Objects.Extended = function (pathCache, h5ai) {
|
||||
$size = $ths.eq(3).find("a"),
|
||||
sortquery = document.location.search,
|
||||
order = {
|
||||
column: (sortquery.indexOf("C=N") >= 0) ? "name" : (sortquery.indexOf("C=M") >= 0) ? "date" : (sortquery.indexOf("C=S") >= 0) ? "size" : h5ai.settings.sortorder.column,
|
||||
ascending: (sortquery.indexOf("O=A") >= 0) ? true : (sortquery.indexOf("O=D") >= 0) ? false : h5ai.settings.sortorder.ascending
|
||||
column: (sortquery.indexOf("C=N") >= 0) ? "name" : (sortquery.indexOf("C=M") >= 0) ? "date" : (sortquery.indexOf("C=S") >= 0) ? "size" : H5aiJs.h5ai.settings.sortorder.column,
|
||||
ascending: (sortquery.indexOf("O=A") >= 0) ? true : (sortquery.indexOf("O=D") >= 0) ? false : H5aiJs.h5ai.settings.sortorder.ascending
|
||||
},
|
||||
$icon, $ul, $li;
|
||||
|
||||
@ -66,8 +66,8 @@ Objects.Extended = function (pathCache, h5ai) {
|
||||
|
||||
// entries
|
||||
$("#table td").closest("tr").each(function () {
|
||||
var path = pathCache.getPath(document.location.pathname, this);
|
||||
$ul.append(path.updateExtendedHtml());
|
||||
var path = H5aiJs.pathCache.getPath(document.location.pathname, this);
|
||||
$ul.append(H5aiJs.html.updateExtendedHtml(path));
|
||||
});
|
||||
|
||||
$("#extended").append($ul);
|
||||
@ -95,22 +95,18 @@ Objects.Extended = function (pathCache, h5ai) {
|
||||
}
|
||||
});
|
||||
},
|
||||
initCounts = function () {
|
||||
initTotals = function () {
|
||||
|
||||
$(".folderCount").text($("#extended .entry.folder:not(.parentfolder)").size());
|
||||
$(".fileCount").text($("#extended .entry.file").size());
|
||||
},
|
||||
init = function () {
|
||||
|
||||
initTitle();
|
||||
initBreadcrumb();
|
||||
initExtendedView();
|
||||
customize();
|
||||
initCounts();
|
||||
},
|
||||
extended = {
|
||||
init: init
|
||||
};
|
||||
|
||||
return extended;
|
||||
this.init = function () {
|
||||
|
||||
initTitle();
|
||||
initBreadcrumb();
|
||||
initExtendedView();
|
||||
customize();
|
||||
initTotals();
|
||||
};
|
||||
};
|
@ -1,11 +1,13 @@
|
||||
/*global window, $, Objects, localStorage */
|
||||
|
||||
Objects.H5ai = function (options, langs) {
|
||||
H5aiJs.factory.H5ai = function (options, langs) {
|
||||
/*global window, $, amplify*/
|
||||
|
||||
var defaults = {
|
||||
var $window = $(window),
|
||||
$document = $(document),
|
||||
defaults = {
|
||||
store: {
|
||||
viewmode: "h5ai.viewmode",
|
||||
lang: "h5ai.lang"
|
||||
viewmode: "h5ai.pref.viewmode",
|
||||
lang: "h5ai.pref.lang"
|
||||
},
|
||||
callbacks: {
|
||||
pathClick: []
|
||||
@ -41,19 +43,19 @@ Objects.H5ai = function (options, langs) {
|
||||
triggerPathClick = function (path, context) {
|
||||
|
||||
$.each(settings.callbacks.pathClick, function (idx, callback) {
|
||||
callback.call(window, path, context);
|
||||
callback(path, context);
|
||||
});
|
||||
},
|
||||
getViewmode = function () {
|
||||
|
||||
var viewmode = localStorage.getItem(settings.store.viewmode);
|
||||
var viewmode = amplify.store(settings.store.viewmode);
|
||||
|
||||
return $.inArray(viewmode, settings.viewmodes) >= 0 ? viewmode : settings.viewmodes[0];
|
||||
},
|
||||
applyViewmode = function (viewmode) {
|
||||
|
||||
if (viewmode) {
|
||||
localStorage.setItem(settings.store.viewmode, viewmode);
|
||||
amplify.store(settings.store.viewmode, viewmode);
|
||||
}
|
||||
viewmode = getViewmode();
|
||||
|
||||
@ -82,7 +84,7 @@ Objects.H5ai = function (options, langs) {
|
||||
|
||||
var adjustTopSpace = function () {
|
||||
|
||||
var winHeight = $(window).height(),
|
||||
var winHeight = $window.height(),
|
||||
navHeight = $("body > nav").outerHeight(),
|
||||
footerHeight = $("body > footer").outerHeight(),
|
||||
contentSpacing = 50,
|
||||
@ -103,7 +105,7 @@ Objects.H5ai = function (options, langs) {
|
||||
} catch (err) {}
|
||||
};
|
||||
|
||||
$(window).resize(function () {
|
||||
$window.resize(function () {
|
||||
adjustTopSpace();
|
||||
});
|
||||
adjustTopSpace();
|
||||
@ -141,7 +143,7 @@ Objects.H5ai = function (options, langs) {
|
||||
$(".status.default").show();
|
||||
$(".status.dynamic").empty().hide();
|
||||
}
|
||||
);
|
||||
);
|
||||
},
|
||||
shiftTree = function (forceVisible, dontAnimate) {
|
||||
|
||||
@ -168,7 +170,7 @@ Objects.H5ai = function (options, langs) {
|
||||
function () { shiftTree(true); },
|
||||
function () { shiftTree(); }
|
||||
);
|
||||
$(window).resize(function () { shiftTree(); });
|
||||
$window.resize(function () { shiftTree(); });
|
||||
shiftTree(false, true);
|
||||
},
|
||||
linkHoverStates = function () {
|
||||
@ -188,7 +190,7 @@ Objects.H5ai = function (options, langs) {
|
||||
},
|
||||
localize = function (langs, lang, useBrowserLang) {
|
||||
|
||||
var storedLang = localStorage.getItem(settings.store.lang),
|
||||
var storedLang = amplify.store(settings.store.lang),
|
||||
browserLang, selected, key;
|
||||
|
||||
if (langs[storedLang]) {
|
||||
@ -218,7 +220,7 @@ Objects.H5ai = function (options, langs) {
|
||||
},
|
||||
initLangSelector = function (langs) {
|
||||
|
||||
var idx, lang,
|
||||
var $langOptions = $(".langOptions"),
|
||||
sortedLangsKeys = [],
|
||||
$ul;
|
||||
|
||||
@ -234,18 +236,22 @@ Objects.H5ai = function (options, langs) {
|
||||
.text(lang + " - " + langs[lang].lang)
|
||||
.appendTo($ul)
|
||||
.click(function () {
|
||||
localStorage.setItem(settings.store.lang, lang);
|
||||
amplify.store(settings.store.lang, lang);
|
||||
localize(langs, lang, false);
|
||||
});
|
||||
});
|
||||
$("#langSelector .langOptions").append($ul);
|
||||
$("#langSelector").hover(
|
||||
function () {
|
||||
var $ele = $(".langOptions");
|
||||
$ele.css("top", "-" + $ele.outerHeight() + "px").stop(true, true).fadeIn();
|
||||
$langOptions
|
||||
.css("top", "-" + $langOptions.outerHeight() + "px")
|
||||
.stop(true, true)
|
||||
.fadeIn();
|
||||
},
|
||||
function () {
|
||||
$(".langOptions").stop(true, true).fadeOut();
|
||||
$langOptions
|
||||
.stop(true, true)
|
||||
.fadeOut();
|
||||
}
|
||||
);
|
||||
},
|
||||
@ -256,7 +262,7 @@ Objects.H5ai = function (options, langs) {
|
||||
|
||||
if ($indicator.hasClass("unknown")) {
|
||||
$.get("/h5ai/php/treecontent.php", { "href": $entry.find("> a").attr("href") }, function (html) {
|
||||
|
||||
|
||||
var $content = $(html);
|
||||
|
||||
$indicator.removeClass("unknown");
|
||||
@ -266,7 +272,9 @@ Objects.H5ai = function (options, langs) {
|
||||
$indicator.addClass("open");
|
||||
$entry.find("> .content").replaceWith($content);
|
||||
$("#tree").get(0).updateScrollbar();
|
||||
initIndicators();
|
||||
$content.find(".indicator:not(.initiated)")
|
||||
.click(onIndicatorClick)
|
||||
.addClass("initiated");
|
||||
}
|
||||
});
|
||||
} else if ($indicator.hasClass("open")) {
|
||||
@ -285,24 +293,31 @@ Objects.H5ai = function (options, langs) {
|
||||
},
|
||||
initIndicators = function () {
|
||||
|
||||
$("#tree .entry.folder .indicator:not(.initiated)").each(function () {
|
||||
|
||||
$(this).addClass("initiated").click(onIndicatorClick);
|
||||
});
|
||||
$("#tree .entry.folder .indicator:not(.initiated)")
|
||||
.click(onIndicatorClick)
|
||||
.addClass("initiated");
|
||||
},
|
||||
initZippedDownload = function () {
|
||||
|
||||
var x = 0,
|
||||
y = 0,
|
||||
$window = $(window),
|
||||
selected = function (hrefs) {
|
||||
ctrl = false,
|
||||
updateDownloadBtn = function () {
|
||||
|
||||
var query, idx;
|
||||
$.each(hrefs, function (idx, href) {
|
||||
query = query ? query + ":" + href : href;
|
||||
});
|
||||
query = "/h5ai/php/zipcontent.php?hrefs=" + query;
|
||||
$("#download").show().find("a").attr("href", query);
|
||||
var query,
|
||||
href,
|
||||
$selected = $("#extended a.selected");
|
||||
|
||||
if ($selected.size() > 0) {
|
||||
$selected.each(function () {
|
||||
href = $(this).attr("href");
|
||||
query = query ? query + ":" + href : href;
|
||||
});
|
||||
query = "/h5ai/php/zipcontent.php?hrefs=" + query;
|
||||
$("#download").show().find("a").attr("href", query);
|
||||
} else {
|
||||
$("#download").hide().find("a").attr("href", "#");
|
||||
}
|
||||
},
|
||||
selectionUpdate = function (event) {
|
||||
|
||||
@ -316,41 +331,45 @@ Objects.H5ai = function (options, langs) {
|
||||
$("#selection-rect").css({left: l, top: t, width: w, height: h});
|
||||
|
||||
sel = $("#selection-rect").fracs("rect");
|
||||
$("#extended a").removeClass("selected").each(function () {
|
||||
$("#extended a").removeClass("selecting").each(function () {
|
||||
|
||||
var $a = $(this),
|
||||
rect = $a.fracs("rect"),
|
||||
inter = sel.intersection(rect);
|
||||
if (inter && !$a.closest(".entry").hasClass("folder-parent")) {
|
||||
$a.addClass("selected");
|
||||
$a.addClass("selecting");
|
||||
}
|
||||
});
|
||||
},
|
||||
selectionEnd = function (event) {
|
||||
|
||||
event.preventDefault();
|
||||
$document.unbind("mousemove", selectionUpdate);
|
||||
$("#selection-rect").hide().css({left: 0, top: 0, width: 0, height: 0});
|
||||
|
||||
$window.unbind("mousemove", selectionUpdate);
|
||||
|
||||
var hrefs = [];
|
||||
$("#extended a.selected").each(function () {
|
||||
hrefs.push($(this).attr("href"));
|
||||
});
|
||||
if (hrefs.length > 0) {
|
||||
selected(hrefs);
|
||||
}
|
||||
$("#extended a.selecting.selected").removeClass("selecting").removeClass("selected");
|
||||
$("#extended a.selecting").removeClass("selecting").addClass("selected");
|
||||
updateDownloadBtn();
|
||||
},
|
||||
selectionStart = function (event) {
|
||||
|
||||
event.preventDefault();
|
||||
var view = $.fracs.viewport();
|
||||
|
||||
x = event.pageX;
|
||||
y = event.pageY;
|
||||
$("#download").hide().find("a").attr("href", "#");
|
||||
$("#extended a").removeClass("selected");
|
||||
$("#selection-rect").show().css({left: x, top: y, width: 0, height: 0});
|
||||
if (x >= view.right || y >= view.bottom) {
|
||||
// don't block the scrollbars
|
||||
return;
|
||||
}
|
||||
|
||||
$window
|
||||
event.preventDefault();
|
||||
if (!ctrl) {
|
||||
$("#extended a").removeClass("selected");
|
||||
updateDownloadBtn();
|
||||
}
|
||||
$("#selection-rect").show().css({left: x, top: y, width: 0, height: 0});
|
||||
selectionUpdate(event);
|
||||
|
||||
$document
|
||||
.bind("mousemove", selectionUpdate)
|
||||
.one("mouseup", selectionEnd);
|
||||
},
|
||||
@ -358,12 +377,29 @@ Objects.H5ai = function (options, langs) {
|
||||
|
||||
event.stopPropagation();
|
||||
return false;
|
||||
},
|
||||
noSelectionUnlessCtrl = function (event) {
|
||||
|
||||
if (!ctrl) {
|
||||
noSelection(event);
|
||||
}
|
||||
};
|
||||
|
||||
if (settings.zippedDownload) {
|
||||
$("body>nav,body>footer,#tree,#extended a").bind("mousedown", noSelection);
|
||||
$("#extended a").live("mousedown", noSelection);
|
||||
$window.bind("mousedown", selectionStart);
|
||||
$("body>nav,body>footer,#tree").bind("mousedown", noSelection);
|
||||
$("#extended .entry a").bind("mousedown", noSelectionUnlessCtrl).live("mousedown", noSelectionUnlessCtrl);
|
||||
$document
|
||||
.bind("mousedown", selectionStart)
|
||||
.keydown(function (event) {
|
||||
if (event.keyCode === 17) {
|
||||
ctrl = true;
|
||||
}
|
||||
})
|
||||
.keyup(function (event) {
|
||||
if (event.keyCode === 17) {
|
||||
ctrl = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
init = function () {
|
||||
@ -377,16 +413,15 @@ Objects.H5ai = function (options, langs) {
|
||||
localize(langs, settings.lang, settings.useBrowserLang);
|
||||
initIndicators();
|
||||
initZippedDownload();
|
||||
},
|
||||
h5ai = {
|
||||
settings: settings,
|
||||
shiftTree: shiftTree,
|
||||
linkHoverStates: linkHoverStates,
|
||||
pathClick: pathClick,
|
||||
triggerPathClick: triggerPathClick,
|
||||
initIndicators: initIndicators,
|
||||
init: init
|
||||
};
|
||||
|
||||
return h5ai;
|
||||
return {
|
||||
settings: settings,
|
||||
shiftTree: shiftTree,
|
||||
linkHoverStates: linkHoverStates,
|
||||
pathClick: pathClick,
|
||||
triggerPathClick: triggerPathClick,
|
||||
initIndicators: initIndicators,
|
||||
init: init
|
||||
};
|
||||
};
|
260
src/h5ai/js/inc/Html.js
Normal file
260
src/h5ai/js/inc/Html.js
Normal file
@ -0,0 +1,260 @@
|
||||
/*global $, H5aiJs */
|
||||
|
||||
H5aiJs.factory.Html = function () {
|
||||
|
||||
var imagesPath = "/h5ai/images",
|
||||
iconsPath = "/h5ai/icons",
|
||||
image = function (id) {
|
||||
|
||||
return imagesPath + "/" + id + ".png";
|
||||
},
|
||||
icon = function (id, big) {
|
||||
|
||||
return iconsPath + "/" + (big ? "48x48" : "16x16") + "/" + id + ".png";
|
||||
},
|
||||
onClick = function (path, context) {
|
||||
|
||||
H5aiJs.h5ai.triggerPathClick(path, context);
|
||||
},
|
||||
updateCrumbHtml = function (path) {
|
||||
|
||||
var $html, $a;
|
||||
|
||||
if (path.html.$crumb && path.html.$crumb.data("status") === path.status) {
|
||||
return path.html.$crumb;
|
||||
}
|
||||
|
||||
$html = $("<li class='crumb' />")
|
||||
.data("path", path)
|
||||
.addClass(path.isFolder ? "folder" : "file");
|
||||
|
||||
if (path.status) {
|
||||
$html.data("status", path.status);
|
||||
}
|
||||
|
||||
$a = $("<a><img src='" + image("crumb") + "' alt='>' />" + path.label + "</a>")
|
||||
.appendTo($html)
|
||||
.attr("href", path.absHref)
|
||||
.click(function() { onClick(path, "crumb"); });
|
||||
|
||||
if (path.isDomain) {
|
||||
$html.addClass("domain");
|
||||
$a.find("img").attr("src", image("home"));
|
||||
}
|
||||
|
||||
if (path.isCurrentFolder) {
|
||||
$html.addClass("current");
|
||||
}
|
||||
|
||||
if (!isNaN(path.status)) {
|
||||
if (path.status === 200) {
|
||||
$("<img class='hint' src='" + image("page") + "' alt='not listable' />").appendTo($a);
|
||||
} else {
|
||||
$("<span class='hint'>(" + path.status + ")</span>").appendTo($a);
|
||||
}
|
||||
}
|
||||
|
||||
if (path.html.$crumb) {
|
||||
path.html.$crumb.replaceWith($html);
|
||||
}
|
||||
path.html.$crumb = $html;
|
||||
|
||||
return $html;
|
||||
},
|
||||
updateExtendedHtml = function (path) {
|
||||
|
||||
var $html, $a, $label;
|
||||
|
||||
if (path.html.$extended && path.html.$extended.data("status") === path.status) {
|
||||
return path.html.$extended;
|
||||
}
|
||||
|
||||
$html = $("<li class='entry' />")
|
||||
.data("path", path)
|
||||
.addClass(path.isFolder ? "folder" : "file");
|
||||
|
||||
if (path.status) {
|
||||
$html.data("status", path.status);
|
||||
}
|
||||
|
||||
$label = $("<span class='label'>" + path.label + "</span>");
|
||||
$a = $("<a />")
|
||||
.attr("href", path.absHref)
|
||||
.click(function() { onClick(path, "extended"); })
|
||||
.appendTo($html)
|
||||
.append($("<span class='icon small'><img src='" + path.icon16 + "' alt='" + path.alt + "' /></span>"))
|
||||
.append($("<span class='icon big'><img src='" + path.icon48 + "' alt='" + path.alt + "' /></span>"))
|
||||
.append($label)
|
||||
.append($("<span class='date'>" + path.date + "</span>"))
|
||||
.append($("<span class='size'>" + path.size + "</span>"));
|
||||
|
||||
$a.hover(
|
||||
function () {
|
||||
if ($("#extended").hasClass("icons-view")) {
|
||||
var $this = $(this);
|
||||
$(".status.default").hide();
|
||||
$(".status.dynamic")
|
||||
.empty()
|
||||
.append($this.find(".label").clone())
|
||||
.append($("<span class='sep'>·</span>"))
|
||||
.append($this.find(".date").clone())
|
||||
.show();
|
||||
|
||||
if (!$this.closest(".entry").hasClass("folder")) {
|
||||
$(".status.dynamic")
|
||||
.append($("<span class='sep'>·</span>"))
|
||||
.append($this.find(".size").clone());
|
||||
}
|
||||
}
|
||||
},
|
||||
function () {
|
||||
$(".status.default").show();
|
||||
$(".status.dynamic").empty().hide();
|
||||
}
|
||||
);
|
||||
|
||||
if (path.isParentFolder) {
|
||||
if (!H5aiJs.h5ai.settings.setParentFolderLabels) {
|
||||
$label.addClass("l10n-parentDirectory");
|
||||
}
|
||||
$html.addClass("folder-parent");
|
||||
}
|
||||
|
||||
if (!isNaN(path.status)) {
|
||||
if (path.status === 200) {
|
||||
$html.addClass("page");
|
||||
$a.find(".icon.small img").attr("src", icon("folder-page"));
|
||||
$a.find(".icon.big img").attr("src", icon("folder-page", true));
|
||||
} else {
|
||||
$html.addClass("error");
|
||||
$label.append($("<span class='hint'> " + path.status + " </span>"));
|
||||
}
|
||||
}
|
||||
|
||||
if (path.html.$extended) {
|
||||
path.html.$extended.replaceWith($html);
|
||||
}
|
||||
path.html.$extended = $html;
|
||||
|
||||
return $html;
|
||||
},
|
||||
updateTreeHtml = function (path) {
|
||||
|
||||
var $html, $blank, $a, $indicator, $ul, idx;
|
||||
|
||||
$html = $("<div class='entry' />")
|
||||
.data("path", path)
|
||||
.addClass(path.isFolder ? "folder" : "file");
|
||||
|
||||
$blank = $("<span class='blank' />").appendTo($html);
|
||||
|
||||
$a = $("<a />")
|
||||
.attr("href", path.absHref)
|
||||
.click(function() { path.onClick(path, "tree"); })
|
||||
.appendTo($html)
|
||||
.append($("<span class='icon'><img src='" + path.icon16 + "' /></span>"))
|
||||
.append($("<span class='label'>" + path.label + "</span>"));
|
||||
|
||||
if (path.isFolder) {
|
||||
// indicator
|
||||
if (path.status === undefined || !path.isEmpty()) {
|
||||
$indicator = $("<span class='indicator initiated'><img src='" + image("tree") + "' /></span>")
|
||||
.click(function (event) {
|
||||
|
||||
var $entry = $indicator.closest(".entry"); // $html
|
||||
|
||||
if ($indicator.hasClass("unknown")) {
|
||||
H5aiJs.connector.fetchStatusAndContent(path.absHref, false, function (status, content) {
|
||||
|
||||
path.status = status;
|
||||
path.content = content;
|
||||
path.treeOpen = true;
|
||||
$("#tree").get(0).updateScrollbar(true);
|
||||
updateTreeHtml(path);
|
||||
$("#tree").get(0).updateScrollbar();
|
||||
});
|
||||
} else if ($indicator.hasClass("open")) {
|
||||
path.treeOpen = false;
|
||||
$indicator.removeClass("open");
|
||||
$("#tree").get(0).updateScrollbar(true);
|
||||
$entry.find("> ul.content").slideUp(function() {
|
||||
|
||||
$("#tree").get(0).updateScrollbar();
|
||||
});
|
||||
} else {
|
||||
path.treeOpen = true;
|
||||
$indicator.addClass("open");
|
||||
$("#tree").get(0).updateScrollbar(true);
|
||||
$entry.find("> ul.content").slideDown(function() {
|
||||
|
||||
$("#tree").get(0).updateScrollbar();
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
if (path.status === undefined) {
|
||||
$indicator.addClass("unknown");
|
||||
} else if (path.treeOpen) {
|
||||
$indicator.addClass("open");
|
||||
}
|
||||
|
||||
$blank.replaceWith($indicator);
|
||||
}
|
||||
|
||||
// is path the domain?
|
||||
if (path.isDomain) {
|
||||
$html.addClass("domain");
|
||||
$a.find(".icon img").attr("src", icon("folder-home"));
|
||||
}
|
||||
|
||||
// is path the current folder?
|
||||
if (path.isCurrentFolder) {
|
||||
$html.addClass("current");
|
||||
$a.find(".icon img").attr("src", icon("folder-open"));
|
||||
}
|
||||
|
||||
// does it have subfolders?
|
||||
if (!path.isEmpty()) {
|
||||
$ul = $("<ul class='content' />").appendTo($html);
|
||||
$.each(path.content, function (idx, entry) {
|
||||
$("<li />").append(updateTreeHtml(entry)).appendTo($ul);
|
||||
});
|
||||
if (path.status === undefined || !path.treeOpen) {
|
||||
$ul.hide();
|
||||
}
|
||||
}
|
||||
|
||||
// reflect folder status
|
||||
if (!isNaN(path.status)) {
|
||||
if (path.status === 200) {
|
||||
$a.find(".icon img").attr("src", icon("folder-page"));
|
||||
$a.append($("<span class='hint'><img src='" + image("page") + "' /></span>"));
|
||||
} else {
|
||||
$html.addClass("error");
|
||||
$a.append($("<span class='hint'>" + path.status + "</span>"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (path.html.$tree) {
|
||||
path.html.$tree.replaceWith($html);
|
||||
}
|
||||
path.html.$tree = $html;
|
||||
|
||||
return $html;
|
||||
},
|
||||
updateHtml = function (path) {
|
||||
|
||||
updateCrumbHtml(path);
|
||||
updateExtendedHtml(path);
|
||||
updateTreeHtml(path);
|
||||
};
|
||||
|
||||
return {
|
||||
updateCrumbHtml: updateCrumbHtml,
|
||||
updateExtendedHtml: updateExtendedHtml,
|
||||
updateTreeHtml: updateTreeHtml,
|
||||
updateHtml: updateHtml
|
||||
};
|
||||
};
|
96
src/h5ai/js/inc/Path.js
Normal file
96
src/h5ai/js/inc/Path.js
Normal file
@ -0,0 +1,96 @@
|
||||
/*global $, H5aiJs */
|
||||
|
||||
H5aiJs.factory.Path = function (folder, tableRow) {
|
||||
|
||||
var checkedDecodeUri = function (uri) {
|
||||
|
||||
try { return decodeURI(uri); } catch (err) {}
|
||||
return uri;
|
||||
},
|
||||
$tds, $img, $a, splits;
|
||||
|
||||
// parentFolder: undefined,
|
||||
// label: undefined,
|
||||
// date: undefined,
|
||||
// size: undefined,
|
||||
// href: undefined,
|
||||
// absHref: undefined,
|
||||
// alt: undefined,
|
||||
// icon16: undefined,
|
||||
// icon48: undefined,
|
||||
// isFolder: undefined,
|
||||
// isParentFolder: undefined,
|
||||
// isCurrentFolder: undefined,
|
||||
// isDomain: undefined,
|
||||
|
||||
this.status = undefined; // undefined, "h5ai" or HTTP response code
|
||||
this.content = undefined; // associative array path.absHref -> path
|
||||
this.html = {
|
||||
$crumb: undefined,
|
||||
$extended: undefined,
|
||||
$tree: undefined
|
||||
};
|
||||
this.treeOpen = false;
|
||||
|
||||
if (!H5aiJs.pathCache.pathEndsWithSlash(folder)) {
|
||||
folder += "/";
|
||||
}
|
||||
|
||||
if (tableRow) {
|
||||
$tds = $(tableRow).find("td");
|
||||
$img = $tds.eq(0).find("img");
|
||||
$a = $tds.eq(1).find("a");
|
||||
|
||||
this.parentFolder = folder;
|
||||
this.label = $a.text();
|
||||
this.date = $tds.eq(2).text();
|
||||
this.size = $tds.eq(3).text();
|
||||
this.href = $a.attr("href");
|
||||
this.alt = $img.attr("alt");
|
||||
this.icon16 = $img.attr("src");
|
||||
} else {
|
||||
splits = H5aiJs.pathCache.splitPathname(folder);
|
||||
|
||||
this.parentFolder = splits[0];
|
||||
this.label = checkedDecodeUri(splits[1]);
|
||||
if (this.label === "/") {
|
||||
this.label = checkedDecodeUri(document.domain) + "/";
|
||||
}
|
||||
this.date = "";
|
||||
this.size = "";
|
||||
this.href = splits[1];
|
||||
this.alt = "[DIR]";
|
||||
this.icon16 = "/h5ai/icons/16x16/folder.png";
|
||||
}
|
||||
|
||||
if (H5aiJs.pathCache.pathEndsWithSlash(this.label)) {
|
||||
this.label = this.label.slice(0, -1);
|
||||
}
|
||||
|
||||
this.icon48 = this.icon16.replace("16x16", "48x48");
|
||||
this.isFolder = (this.alt === "[DIR]");
|
||||
this.isParentFolder = (this.isFolder && this.label === "Parent Directory");
|
||||
this.absHref = this.isParentFolder ? this.href : this.parentFolder + this.href;
|
||||
this.isCurrentFolder = (this.absHref === document.location.pathname);
|
||||
this.isDomain = (this.absHref === "/");
|
||||
|
||||
if (this.isParentFolder && H5aiJs.h5ai.settings.setParentFolderLabels) {
|
||||
if (this.isDomain) {
|
||||
this.label = checkedDecodeUri(document.domain);
|
||||
} else {
|
||||
this.label = checkedDecodeUri(H5aiJs.pathCache.splitPathname(H5aiJs.pathCache.splitPathname(this.parentFolder)[0])[1].slice(0, -1));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
H5aiJs.factory.Path.prototype = {
|
||||
|
||||
isEmpty: function () {
|
||||
|
||||
return !this.content || $.isEmptyObject(this.content);
|
||||
},
|
||||
onClick: function (context) {
|
||||
|
||||
H5aiJs.h5ai.triggerPathClick(this, context);
|
||||
}
|
||||
};
|
56
src/h5ai/js/inc/PathCache.js
Normal file
56
src/h5ai/js/inc/PathCache.js
Normal file
@ -0,0 +1,56 @@
|
||||
/*global $, H5aiJs */
|
||||
|
||||
H5aiJs.factory.PathCache = function () {
|
||||
|
||||
var cache = {},
|
||||
rePathnameSplit = /^(\/(.*\/)*)([^\/]+\/?)$/,
|
||||
rePathEndsWithSlash = /\/$/,
|
||||
splitPathname = function (pathname) {
|
||||
|
||||
var match;
|
||||
|
||||
if (pathname === "/") {
|
||||
return ["", "/"];
|
||||
}
|
||||
match = rePathnameSplit.exec(pathname);
|
||||
return [match[1], match[3]];
|
||||
},
|
||||
pathEndsWithSlash = function (pathname) {
|
||||
|
||||
return rePathEndsWithSlash.test(pathname);
|
||||
},
|
||||
getAbsHref = function (folder, tableRow) {
|
||||
|
||||
var $a, isParentFolder, href;
|
||||
|
||||
if (!pathEndsWithSlash(folder)) {
|
||||
folder += "/";
|
||||
}
|
||||
if (!tableRow) {
|
||||
return folder;
|
||||
}
|
||||
$a = $(tableRow).find("td").eq(1).find("a");
|
||||
isParentFolder = ($a.text() === "Parent Directory");
|
||||
href = $a.attr("href");
|
||||
return isParentFolder ? undefined : folder + href;
|
||||
},
|
||||
getPath = function (folder, tableRow) {
|
||||
|
||||
var absHref = getAbsHref(folder, tableRow),
|
||||
path = cache[absHref];
|
||||
|
||||
if (!path) {
|
||||
path = new H5aiJs.factory.Path(folder, tableRow);
|
||||
if (!path.isParentFolder) {
|
||||
cache[path.absHref] = path;
|
||||
}
|
||||
}
|
||||
|
||||
return path;
|
||||
};
|
||||
|
||||
this.splitPathname = splitPathname;
|
||||
this.pathEndsWithSlash = pathEndsWithSlash;
|
||||
this.getPath = getPath;
|
||||
this.cache = cache;
|
||||
};
|
@ -1,30 +0,0 @@
|
||||
/*global window, jQuery */
|
||||
|
||||
(function ($) {
|
||||
"use strict";
|
||||
|
||||
// http://paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/
|
||||
// modified
|
||||
$.log = function () {
|
||||
$.log.history = $.log.history || [];
|
||||
$.log.history.push(arguments);
|
||||
if (window.console) {
|
||||
window.console.log(Array.prototype.slice.call(arguments));
|
||||
}
|
||||
};
|
||||
|
||||
$.timer = (function () {
|
||||
var start = $.now(),
|
||||
last = start,
|
||||
timer = {
|
||||
log: function (label) {
|
||||
var now = $.now();
|
||||
$.log("timer", label, "+" + (now - last), "=" + (now - start));
|
||||
last = now;
|
||||
}
|
||||
};
|
||||
|
||||
return timer;
|
||||
}());
|
||||
|
||||
}(jQuery));
|
10
src/h5ai/js/inc/lib/amplify.min.js
vendored
Normal file
10
src/h5ai/js/inc/lib/amplify.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -1,18 +1,18 @@
|
||||
/*global window, jQuery */
|
||||
|
||||
(function ($) {
|
||||
"use strict";
|
||||
/*global window, jQuery */
|
||||
|
||||
var init = function (htmlElement) {
|
||||
|
||||
|
||||
var $element = $(htmlElement),
|
||||
$scrollbar, $drag, $wrapper, $content, mouseOffsetY, updateId,
|
||||
update, scroll;
|
||||
|
||||
|
||||
if (!$element.css("position") || $element.css("position") === "static") {
|
||||
$element.css("position", "relative");
|
||||
}
|
||||
|
||||
|
||||
$scrollbar = $("<div class='scrollbar' />");
|
||||
$drag = $("<div class='drag' />").appendTo($scrollbar);
|
||||
$element
|
||||
@ -21,25 +21,25 @@
|
||||
$wrapper = $element.find("> .wrapper");
|
||||
$content = $wrapper.find("> .content");
|
||||
mouseOffsetY = 0;
|
||||
|
||||
|
||||
update = function (repeat) {
|
||||
|
||||
|
||||
var visibleHeight, contentHeight, scrollTop, scrollTopFrac, visVertFrac;
|
||||
|
||||
|
||||
if (updateId && !repeat) {
|
||||
clearInterval(updateId);
|
||||
updateId = undefined;
|
||||
} else if (!updateId && repeat) {
|
||||
updateId = setInterval(function() { update(true); }, 50);
|
||||
}
|
||||
|
||||
|
||||
$wrapper.css("height", $element.height());
|
||||
visibleHeight = $element.height();
|
||||
contentHeight = $content.outerHeight();
|
||||
scrollTop = $wrapper.scrollTop();
|
||||
scrollTopFrac = scrollTop / contentHeight;
|
||||
visVertFrac = Math.min(visibleHeight / contentHeight, 1);
|
||||
|
||||
|
||||
if (visVertFrac < 1) {
|
||||
$scrollbar
|
||||
.fadeIn(50)
|
||||
@ -55,19 +55,19 @@
|
||||
$scrollbar.fadeOut(50);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
scroll = function (event) {
|
||||
|
||||
|
||||
var clickFrac = (event.pageY - $scrollbar.offset().top - mouseOffsetY) / $scrollbar.height();
|
||||
|
||||
|
||||
$wrapper.scrollTop($content.outerHeight() * clickFrac);
|
||||
update();
|
||||
event.preventDefault();
|
||||
};
|
||||
|
||||
|
||||
$element
|
||||
.mousewheel(function (event, delta) {
|
||||
|
||||
|
||||
$wrapper.scrollTop($wrapper.scrollTop() - 50 * delta);
|
||||
update();
|
||||
event.stopPropagation();
|
||||
@ -90,14 +90,14 @@
|
||||
cursor: "pointer"
|
||||
})
|
||||
.mousedown(function (event) {
|
||||
|
||||
|
||||
mouseOffsetY = $drag.outerHeight() / 2;
|
||||
scroll(event);
|
||||
$scrollbar.addClass("dragOn");
|
||||
$(window)
|
||||
.bind("mousemove", scroll)
|
||||
.one("mouseup", function (event) {
|
||||
|
||||
|
||||
$scrollbar.removeClass("dragOn");
|
||||
$(window).unbind("mousemove", scroll);
|
||||
scroll(event);
|
||||
@ -106,9 +106,9 @@
|
||||
event.preventDefault();
|
||||
})
|
||||
.each(function () {
|
||||
|
||||
|
||||
this.onselectstart = function () {
|
||||
|
||||
|
||||
return false;
|
||||
};
|
||||
});
|
||||
@ -119,14 +119,14 @@
|
||||
width: "100%"
|
||||
})
|
||||
.mousedown(function (event) {
|
||||
|
||||
|
||||
mouseOffsetY = event.pageY - $drag.offset().top;
|
||||
scroll(event);
|
||||
$scrollbar.addClass("dragOn");
|
||||
$(window)
|
||||
.bind("mousemove", scroll)
|
||||
.one("mouseup", function (event) {
|
||||
|
||||
|
||||
$scrollbar.removeClass("dragOn");
|
||||
$(window).unbind("mousemove", scroll);
|
||||
scroll(event);
|
||||
@ -134,7 +134,7 @@
|
||||
});
|
||||
event.stopPropagation();
|
||||
});
|
||||
|
||||
|
||||
update();
|
||||
};
|
||||
|
@ -1,404 +0,0 @@
|
||||
/*global $, Objects */
|
||||
|
||||
Objects.Path = function (pathCache, folder, tableRow) {
|
||||
|
||||
var path,
|
||||
checkedDecodeUri = function (uri) {
|
||||
|
||||
try { return decodeURI(uri); } catch (err) {}
|
||||
return uri;
|
||||
},
|
||||
isEmpty = function () {
|
||||
|
||||
return !path.content || $.isEmptyObject(path.content);
|
||||
},
|
||||
onClick = function (context) {
|
||||
|
||||
h5ai.triggerPathClick(path, context);
|
||||
},
|
||||
updateHtml = function () {
|
||||
|
||||
path.updateCrumbHtml();
|
||||
path.updateExtendedHtml();
|
||||
path.updateTreeHtml();
|
||||
},
|
||||
updateCrumbHtml = function () {
|
||||
|
||||
var $html, $a;
|
||||
|
||||
if (path.html.$crumb && path.html.$crumb.data("status") === path.status) {
|
||||
return path.html.$crumb;
|
||||
}
|
||||
|
||||
$html = $("<li class='crumb' />")
|
||||
.data("path", path)
|
||||
.addClass(path.isFolder ? "folder" : "file");
|
||||
|
||||
if (path.status) {
|
||||
$html.data("status", path.status);
|
||||
}
|
||||
|
||||
$a = $("<a><img src='/h5ai/images/crumb.png' alt='>' />" + path.label + "</a>")
|
||||
.appendTo($html)
|
||||
.attr("href", path.absHref)
|
||||
.click(function() { onClick("crumb"); });
|
||||
|
||||
if (path.isDomain) {
|
||||
$html.addClass("domain");
|
||||
$a.find("img").attr("src", "/h5ai/images/home.png");
|
||||
}
|
||||
|
||||
if (path.isCurrentFolder) {
|
||||
$html.addClass("current");
|
||||
}
|
||||
|
||||
if (!isNaN(path.status)) {
|
||||
if (path.status === 200) {
|
||||
$("<img class='hint' src='/h5ai/images/page.png' alt='not listable' />").appendTo($a);
|
||||
} else {
|
||||
$("<span class='hint'>(" + path.status + ")</span>").appendTo($a);
|
||||
}
|
||||
}
|
||||
|
||||
if (path.html.$crumb) {
|
||||
path.html.$cpathreplaceWith($html);
|
||||
}
|
||||
path.html.$crumb = $html;
|
||||
|
||||
return $html;
|
||||
},
|
||||
updateExtendedHtml = function () {
|
||||
|
||||
var $html, $a, $label;
|
||||
|
||||
if (path.html.$extended && path.html.$extended.data("status") === path.status) {
|
||||
return path.html.$extended;
|
||||
}
|
||||
|
||||
$html = $("<li class='entry' />")
|
||||
.data("path", path)
|
||||
.addClass(path.isFolder ? "folder" : "file");
|
||||
|
||||
if (path.status) {
|
||||
$html.data("status", path.status);
|
||||
}
|
||||
|
||||
$label = $("<span class='label'>" + path.label + "</span>");
|
||||
$a = $("<a />")
|
||||
.attr("href", path.absHref)
|
||||
.click(function() { onClick("extended"); })
|
||||
.appendTo($html)
|
||||
.append($("<span class='icon small'><img src='" + path.icon16 + "' alt='" + path.alt + "' /></span>"))
|
||||
.append($("<span class='icon big'><img src='" + path.icon48 + "' alt='" + path.alt + "' /></span>"))
|
||||
.append($label)
|
||||
.append($("<span class='date'>" + path.date + "</span>"))
|
||||
.append($("<span class='size'>" + path.size + "</span>"));
|
||||
|
||||
$a.hover(
|
||||
function () {
|
||||
if ($("#extended").hasClass("icons-view")) {
|
||||
var $this = $(this);
|
||||
$(".status.default").hide();
|
||||
$(".status.dynamic")
|
||||
.empty()
|
||||
.append($this.find(".label").clone())
|
||||
.append($("<span class='sep'>·</span>"))
|
||||
.append($this.find(".date").clone())
|
||||
.show();
|
||||
|
||||
if (!$this.closest(".entry").hasClass("folder")) {
|
||||
$(".status.dynamic")
|
||||
.append($("<span class='sep'>·</span>"))
|
||||
.append($this.find(".size").clone());
|
||||
}
|
||||
}
|
||||
},
|
||||
function () {
|
||||
$(".status.default").show();
|
||||
$(".status.dynamic").empty().hide();
|
||||
}
|
||||
);
|
||||
|
||||
if (path.isParentFolder) {
|
||||
if (!h5ai.settings.setParentFolderLabels) {
|
||||
$label.addClass("l10n-parentDirectory");
|
||||
}
|
||||
$html.addClass("folder-parent");
|
||||
}
|
||||
|
||||
if (!isNaN(path.status)) {
|
||||
if (path.status === 200) {
|
||||
$html.addClass("page");
|
||||
$a.find(".icon.small img").attr("src", "/h5ai/icons/16x16/folder-page.png");
|
||||
$a.find(".icon.big img").attr("src", "/h5ai/icons/48x48/folder-page.png");
|
||||
} else {
|
||||
$html.addClass("error");
|
||||
$label.append($("<span class='hint'> " + path.status + " </span>"));
|
||||
}
|
||||
}
|
||||
|
||||
if (path.html.$extended) {
|
||||
path.html.$extended.replaceWith($html);
|
||||
}
|
||||
path.html.$extended = $html;
|
||||
|
||||
return $html;
|
||||
},
|
||||
updateTreeHtml = function () {
|
||||
|
||||
var $html, $blank, $a, $indicator, $ul, idx;
|
||||
|
||||
$html = $("<div class='entry' />")
|
||||
.data("path", path)
|
||||
.addClass(path.isFolder ? "folder" : "file");
|
||||
|
||||
$blank = $("<span class='blank' />").appendTo($html);
|
||||
|
||||
$a = $("<a />")
|
||||
.attr("href", path.absHref)
|
||||
.click(function() { path.onClick("tree"); })
|
||||
.appendTo($html)
|
||||
.append($("<span class='icon'><img src='" + path.icon16 + "' /></span>"))
|
||||
.append($("<span class='label'>" + path.label + "</span>"));
|
||||
|
||||
if (path.isFolder) {
|
||||
// indicator
|
||||
if (path.status === undefined || !path.isEmpty()) {
|
||||
$indicator = $("<span class='indicator'><img src='/h5ai/images/tree.png' /></span>");
|
||||
if (path.status === undefined) {
|
||||
$indicator.addClass("unknown");
|
||||
} else if (path.treeOpen) {
|
||||
$indicator.addClass("open");
|
||||
}
|
||||
|
||||
$indicator.click(function(event) {
|
||||
|
||||
if ($indicator.hasClass("unknown")) {
|
||||
tree.fetchStatusAndContent(path.absHref, false, function (status, content) {
|
||||
|
||||
path.status = status;
|
||||
path.content = content;
|
||||
path.treeOpen = true;
|
||||
$("#tree").get(0).updateScrollbar(true);
|
||||
path.updateTreeHtml(function() {
|
||||
|
||||
$("#tree").get(0).updateScrollbar();
|
||||
});
|
||||
});
|
||||
} else if ($indicator.hasClass("open")) {
|
||||
path.treeOpen = false;
|
||||
$indicator.removeClass("open");
|
||||
$("#tree").get(0).updateScrollbar(true);
|
||||
$html.find("> ul.content").slideUp(function() {
|
||||
|
||||
$("#tree").get(0).updateScrollbar();
|
||||
});
|
||||
} else {
|
||||
path.treeOpen = true;
|
||||
$indicator.addClass("open");
|
||||
$("#tree").get(0).updateScrollbar(true);
|
||||
$html.find("> ul.content").slideDown(function() {
|
||||
|
||||
$("#tree").get(0).updateScrollbar();
|
||||
});
|
||||
}
|
||||
});
|
||||
$html.addClass("initiatedIndicator");
|
||||
|
||||
$blank.replaceWith($indicator);
|
||||
}
|
||||
|
||||
// is path the domain?
|
||||
if (path.isDomain) {
|
||||
$html.addClass("domain");
|
||||
$a.find(".icon img").attr("src", "/h5ai/icons/16x16/folder-home.png");
|
||||
}
|
||||
|
||||
// is path the current folder?
|
||||
if (path.isCurrentFolder) {
|
||||
$html.addClass("current");
|
||||
$a.find(".icon img").attr("src", "/h5ai/icons/16x16/folder-open.png");
|
||||
}
|
||||
|
||||
// does it have subfolders?
|
||||
if (!path.isEmpty()) {
|
||||
$ul = $("<ul class='content' />").appendTo($html);
|
||||
$.each(path.content, function (idx, entry) {
|
||||
$("<li />").append(entry.updateTreeHtml()).appendTo($ul);
|
||||
});
|
||||
if (path.status === undefined || !path.treeOpen) {
|
||||
$ul.hide();
|
||||
}
|
||||
}
|
||||
|
||||
// reflect folder status
|
||||
if (!isNaN(path.status)) {
|
||||
if (path.status === 200) {
|
||||
$a.find(".icon img").attr("src", "/h5ai/icons/16x16/folder-page.png");
|
||||
$a.append($("<span class='hint'><img src='/h5ai/images/page.png' /></span>"));
|
||||
} else {
|
||||
$html.addClass("error");
|
||||
$a.append($("<span class='hint'>" + path.status + "</span>"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (path.html.$tree) {
|
||||
path.html.$tree.replaceWith($html);
|
||||
}
|
||||
path.html.$tree = $html;
|
||||
|
||||
return $html;
|
||||
},
|
||||
init = function () {
|
||||
|
||||
var $tds, $img, $a, splits;
|
||||
|
||||
path = {
|
||||
// parentFolder: undefined,
|
||||
// label: undefined,
|
||||
// date: undefined,
|
||||
// size: undefined,
|
||||
// href: undefined,
|
||||
// absHref: undefined,
|
||||
// alt: undefined,
|
||||
// icon16: undefined,
|
||||
// icon48: undefined,
|
||||
// isFolder: undefined,
|
||||
// isParentFolder: undefined,
|
||||
// isCurrentFolder: undefined,
|
||||
// isDomain: undefined,
|
||||
|
||||
status: undefined, // undefined, "h5ai" or HTTP response code
|
||||
content: undefined, // associative array path.absHref -> path
|
||||
html: {
|
||||
$crumb: undefined,
|
||||
$extended: undefined,
|
||||
$tree: undefined
|
||||
},
|
||||
treeOpen: false,
|
||||
|
||||
isEmpty: isEmpty,
|
||||
onClick: onClick,
|
||||
updateHtml: updateHtml,
|
||||
updateCrumbHtml: updateCrumbHtml,
|
||||
updateExtendedHtml: updateExtendedHtml,
|
||||
updateTreeHtml: updateTreeHtml
|
||||
};
|
||||
|
||||
if (!pathCache.pathEndsWithSlash(folder)) {
|
||||
folder += "/";
|
||||
}
|
||||
|
||||
if (tableRow) {
|
||||
$tds = $(tableRow).find("td");
|
||||
$img = $tds.eq(0).find("img");
|
||||
$a = $tds.eq(1).find("a");
|
||||
|
||||
path.parentFolder = folder;
|
||||
path.label = $a.text();
|
||||
path.date = $tds.eq(2).text();
|
||||
path.size = $tds.eq(3).text();
|
||||
path.href = $a.attr("href");
|
||||
path.alt = $img.attr("alt");
|
||||
path.icon16 = $img.attr("src");
|
||||
} else {
|
||||
splits = pathCache.splitPathname(folder);
|
||||
|
||||
path.parentFolder = splits[0];
|
||||
path.label = checkedDecodeUri(splits[1]);
|
||||
if (path.label === "/") {
|
||||
path.label = checkedDecodeUri(document.domain) + "/";
|
||||
}
|
||||
path.date = "";
|
||||
path.size = "";
|
||||
path.href = splits[1];
|
||||
path.alt = "[DIR]";
|
||||
path.icon16 = "/h5ai/icons/16x16/folder.png";
|
||||
}
|
||||
|
||||
if (pathCache.pathEndsWithSlash(path.label)) {
|
||||
path.label = path.label.slice(0, -1);
|
||||
}
|
||||
|
||||
path.icon48 = path.icon16.replace("16x16", "48x48");
|
||||
path.isFolder = (path.alt === "[DIR]");
|
||||
path.isParentFolder = (path.isFolder && path.label === "Parent Directory");
|
||||
path.absHref = path.isParentFolder ? path.href : path.parentFolder + path.href;
|
||||
path.isCurrentFolder = (path.absHref === document.location.pathname);
|
||||
path.isDomain = (path.absHref === "/");
|
||||
|
||||
if (path.isParentFolder && h5ai.settings.setParentFolderLabels) {
|
||||
if (path.isDomain) {
|
||||
path.label = checkedDecodeUri(document.domain);
|
||||
} else {
|
||||
path.label = checkedDecodeUri(pathCache.splitPathname(pathCache.splitPathname(path.parentFolder)[0])[1].slice(0, -1));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
init();
|
||||
|
||||
return path;
|
||||
};
|
||||
|
||||
|
||||
Objects.PathCache = function () {
|
||||
|
||||
var pathCache,
|
||||
cache = {},
|
||||
rePathnameSplit = /^(\/(.*\/)*)([^\/]+\/?)$/,
|
||||
rePathEndsWithSlash = /\/$/,
|
||||
splitPathname = function (pathname) {
|
||||
|
||||
var match;
|
||||
|
||||
if (pathname === "/") {
|
||||
return ["", "/"];
|
||||
}
|
||||
match = rePathnameSplit.exec(pathname);
|
||||
return [match[1], match[3]];
|
||||
},
|
||||
pathEndsWithSlash = function (pathname) {
|
||||
|
||||
return rePathEndsWithSlash.test(pathname);
|
||||
},
|
||||
getAbsHref = function (folder, tableRow) {
|
||||
|
||||
var $a, isParentFolder, href;
|
||||
|
||||
if (!pathEndsWithSlash(folder)) {
|
||||
folder += "/";
|
||||
}
|
||||
if (!tableRow) {
|
||||
return folder;
|
||||
}
|
||||
$a = $(tableRow).find("td").eq(1).find("a");
|
||||
isParentFolder = ($a.text() === "Parent Directory");
|
||||
href = $a.attr("href");
|
||||
return isParentFolder ? undefined : folder + href;
|
||||
},
|
||||
getPath = function (folder, tableRow) {
|
||||
|
||||
var absHref = getAbsHref(folder, tableRow),
|
||||
path = cache[absHref];
|
||||
|
||||
if (!path) {
|
||||
path = new Objects.Path(pathCache, folder, tableRow);
|
||||
if (!path.isParentFolder) {
|
||||
cache[path.absHref] = path;
|
||||
}
|
||||
}
|
||||
|
||||
return path;
|
||||
};
|
||||
|
||||
pathCache = {
|
||||
splitPathname: splitPathname,
|
||||
pathEndsWithSlash: pathEndsWithSlash,
|
||||
getPath: getPath,
|
||||
cache: cache
|
||||
};
|
||||
|
||||
return pathCache;
|
||||
};
|
4
src/h5ai/js/lib/modernizr.min.js
vendored
4
src/h5ai/js/lib/modernizr.min.js
vendored
File diff suppressed because one or more lines are too long
7
src/h5ai/js/libs.js
Normal file
7
src/h5ai/js/libs.js
Normal file
@ -0,0 +1,7 @@
|
||||
|
||||
// @include "inc/lib/jquery.min.js"
|
||||
// @include "inc/lib/jquery.mousewheel.min.js"
|
||||
// @include "inc/lib/jquery.fracs-core.min.js"
|
||||
// @include "inc/lib/jquery.scrollpanel.js"
|
||||
|
||||
// @include "inc/lib/amplify.min.js"
|
@ -1,33 +1,37 @@
|
||||
/*global jQuery, h5aiOptions, h5aiLangs*/
|
||||
|
||||
// @include "inc/jquery.scrollpanel.js"
|
||||
// @include "inc/jquery.utils.js"
|
||||
|
||||
(function($) {
|
||||
"use strict";
|
||||
|
||||
var Objects = {},
|
||||
pathCache, h5ai, extended, tree;
|
||||
var H5aiJs = {
|
||||
factory: {},
|
||||
init: function () {
|
||||
|
||||
// @include "inc/h5ai.js"
|
||||
// @include "inc/path.js"
|
||||
// @include "inc/extended.js"
|
||||
// @include "inc/tree.js"
|
||||
this.h5ai = new this.factory.H5ai(h5aiOptions, h5aiLangs);
|
||||
this.pathCache = new this.factory.PathCache();
|
||||
this.connector = new this.factory.Connector();
|
||||
this.html = new this.factory.Html();
|
||||
this.extended = new this.factory.Extended();
|
||||
|
||||
pathCache = new Objects.PathCache();
|
||||
h5ai = new Objects.H5ai(h5aiOptions, h5aiLangs);
|
||||
extended = new Objects.Extended(pathCache, h5ai);
|
||||
tree = new Objects.Tree(pathCache, h5ai);
|
||||
this.extended.init();
|
||||
this.connector.init();
|
||||
this.h5ai.init();
|
||||
|
||||
$.h5ai = {
|
||||
click: $.proxy(h5ai.pathClick, h5ai)
|
||||
};
|
||||
$.h5ai = {
|
||||
click: $.proxy(this.h5ai.pathClick, this.h5ai)
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
// @include "inc/H5ai.js"
|
||||
// @include "inc/Path.js"
|
||||
// @include "inc/PathCache.js"
|
||||
// @include "inc/Connector.js"
|
||||
// @include "inc/Html.js"
|
||||
// @include "inc/Extended.js"
|
||||
|
||||
$(function () {
|
||||
|
||||
extended.init();
|
||||
tree.init();
|
||||
h5ai.init();
|
||||
H5aiJs.init();
|
||||
});
|
||||
|
||||
}(jQuery));
|
||||
|
@ -1,27 +1,28 @@
|
||||
/*global jQuery, h5aiOptions, h5aiLangs*/
|
||||
|
||||
// @include "inc/jquery.scrollpanel.js"
|
||||
// @include "inc/jquery.utils.js"
|
||||
|
||||
(function($) {
|
||||
"use strict";
|
||||
|
||||
var Objects = {},
|
||||
h5ai;
|
||||
var H5aiJs = {
|
||||
factory: {},
|
||||
init: function () {
|
||||
|
||||
// @include "inc/h5ai.js"
|
||||
this.h5ai = new this.factory.H5ai(h5aiOptions, h5aiLangs);
|
||||
|
||||
h5ai = new Objects.H5ai(h5aiOptions, h5aiLangs);
|
||||
this.h5ai.init();
|
||||
$("#tree").scrollpanel();
|
||||
this.h5ai.shiftTree(false, true);
|
||||
|
||||
$.h5ai = {
|
||||
click: $.proxy(h5ai.pathClick, h5ai)
|
||||
};
|
||||
$.h5ai = {
|
||||
click: $.proxy(this.h5ai.pathClick, this.h5ai)
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
// @include "inc/H5ai.js"
|
||||
|
||||
$(function () {
|
||||
|
||||
h5ai.init();
|
||||
$("#tree").scrollpanel();
|
||||
h5ai.shiftTree(false, true);
|
||||
H5aiJs.init();
|
||||
});
|
||||
|
||||
}(jQuery));
|
||||
|
4
src/h5ai/js/modernizr.min.js
vendored
Normal file
4
src/h5ai/js/modernizr.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -57,7 +57,7 @@ h5aiOptions = {
|
||||
* possible values. Adjust it to your needs. If lang is not found in
|
||||
* h5aiLangs it defaults to "en".
|
||||
*/
|
||||
"lang": null,
|
||||
"lang": "en",
|
||||
|
||||
/*
|
||||
* Try to use browser language, falls back to previous specified lang.
|
||||
@ -103,7 +103,7 @@ h5aiOptions = {
|
||||
* Enable zipped download of selected entries. Requieres
|
||||
* PHP on the server.
|
||||
*/
|
||||
"zippedDownload": true
|
||||
"zippedDownload": false
|
||||
};
|
||||
|
||||
|
||||
@ -194,7 +194,7 @@ h5aiLangs = {
|
||||
"empty": "vide",
|
||||
"folders": "Répertoires",
|
||||
"files": "Fichiers",
|
||||
"download": "download"
|
||||
"download": "télécharger"
|
||||
},
|
||||
|
||||
"it": {
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
if (!array_key_exists("hrefs", $_REQUEST)) {
|
||||
echo "failed";
|
||||
echo "1: no href specified";
|
||||
exit;
|
||||
}
|
||||
|
||||
@ -12,7 +12,6 @@ $h5ai = new H5ai();
|
||||
$zipit = new ZipIt($h5ai);
|
||||
|
||||
$hrefs = explode(":", trim($_REQUEST["hrefs"]));
|
||||
|
||||
$zipFile = $zipit->zip($hrefs);
|
||||
|
||||
if ($zipFile !== false) {
|
||||
@ -22,7 +21,7 @@ if ($zipFile !== false) {
|
||||
header("Connection: close");
|
||||
readfile($zipFile);
|
||||
} else {
|
||||
echo "sorry, something went wrong while building the zip.";
|
||||
echo "2: something went wrong while building the zip";
|
||||
}
|
||||
|
||||
?>
|
@ -27,7 +27,8 @@ IndexIgnore h5ai h5ai.header.html h5ai.footer.html
|
||||
# table options
|
||||
################################
|
||||
|
||||
# syntax for default sort order is: IndexOrderDefault Ascending|Descending Name|Date|Size
|
||||
# syntax for default sort order is:
|
||||
# IndexOrderDefault Ascending|Descending Name|Date|Size
|
||||
IndexOrderDefault Ascending Name
|
||||
|
||||
IndexOptions Type=text/html;h5ai=%BUILD_VERSION%
|
||||
|
@ -6,7 +6,7 @@
|
||||
<attribute name="toFile" />
|
||||
<attribute name="args" default="" />
|
||||
<sequential>
|
||||
<exec executable="${wepp}">
|
||||
<exec executable="${tool.wepp}">
|
||||
<arg line="@{args}" />
|
||||
<arg value="--in" />
|
||||
<arg value="@{file}" />
|
||||
@ -20,7 +20,7 @@
|
||||
<attribute name="dir" />
|
||||
<attribute name="args" default="" />
|
||||
<sequential>
|
||||
<exec executable="${wepp}">
|
||||
<exec executable="${tool.wepp}">
|
||||
<arg line="@{args}" />
|
||||
<arg value="--inDir" />
|
||||
<arg value="@{dir}" />
|
||||
|
Loading…
x
Reference in New Issue
Block a user