Renames main script file to H5ai.js and main h5ai reference to h5ai.

This commit is contained in:
Lars Jung 2012-03-07 02:33:48 +01:00
parent fbff8686bf
commit 194a202a0b
14 changed files with 159 additions and 151 deletions

View file

@ -50,8 +50,8 @@
</target>
<target name="lint" depends="build-prepare">
<wepp file="${build.dir}/_h5ai/js/inc/main.js" tofile="${build.dir}/_h5ai/js/inc/main.js" />
<jslint files="${build.dir}/_h5ai/js/inc/main.js" />
<wepp file="${build.dir}/_h5ai/js/inc/H5ai.js" tofile="${build.dir}/_h5ai/js/inc/H5ai.js" />
<jslint files="${build.dir}/_h5ai/js/inc/H5ai.js" />
</target>

View file

@ -1,16 +1,16 @@
(function ($, H5AI) {
(function ($, h5ai) {
var cache = {},
pathnameStatusCache = {},
contentTypeRegEx = /^text\/html;h5ai=/,
getPath = function (folder, tableRow) {
var absHref = H5AI.util.getAbsHref(folder, tableRow),
var absHref = h5ai.util.getAbsHref(folder, tableRow),
path = cache[absHref];
if (!path) {
path = H5AI.Path(folder, tableRow);
path = h5ai.Path(folder, tableRow);
if (!path.isParentFolder) {
cache[path.absHref] = path;
}
@ -20,8 +20,8 @@
},
fetchStatus = function (pathname, callback) {
if (H5AI.core.settings.folderStatus[pathname]) {
callback(H5AI.core.settings.folderStatus[pathname]);
if (h5ai.core.settings.folderStatus[pathname]) {
callback(h5ai.core.settings.folderStatus[pathname]);
return;
} else if (pathnameStatusCache[pathname]) {
callback(pathnameStatusCache[pathname]);
@ -51,8 +51,8 @@
if (status !== "h5ai") {
path.status = status;
}
H5AI.html.updateHtml(path);
H5AI.core.linkHoverStates();
h5ai.html.updateHtml(path);
h5ai.core.linkHoverStates();
});
}
},
@ -103,10 +103,10 @@
});
};
H5AI.connector = {
h5ai.connector = {
getPath: getPath,
updatePaths: updatePaths,
fetchStatusAndContent: fetchStatusAndContent
};
}(jQuery, H5AI));
}(jQuery, h5ai));

View file

@ -1,5 +1,5 @@
(function ($, H5AI) {
(function ($, h5ai) {
var $context,
qrCodesSize,
@ -18,7 +18,7 @@
},
init = function () {
qrCodesSize = H5AI.core.settings.qrCodesSize;
qrCodesSize = h5ai.core.settings.qrCodesSize;
if (!qrCodesSize) {
return;
}
@ -44,8 +44,8 @@
});
};
H5AI.context = {
h5ai.context = {
init: init
};
}(jQuery, H5AI));
}(jQuery, h5ai));

View file

@ -1,5 +1,5 @@
(function (window, $, H5AI, config) {
(function (window, $, h5ai, config) {
var $window = $(window),
defaults = {
@ -95,7 +95,7 @@
viewmode = amplify.store(settings.store.viewmode);
}
viewmode = $.inArray(viewmode, settings.viewmodes) >= 0 ? viewmode : settings.viewmodes[0];
H5AI.core.hash({view: viewmode});
h5ai.core.hash({view: viewmode});
$viewDetails.add($viewIcons).removeClass("current");
if (viewmode === "details") {
@ -293,7 +293,7 @@
$(".lang").text(lang);
$(".langOption").removeClass("current");
$(".langOption." + lang).addClass("current");
H5AI.core.hash({lang: lang});
h5ai.core.hash({lang: lang});
}
formatDates(selected.dateFormat || settings.dateFormat);
@ -395,7 +395,7 @@
var $this = $(this),
bytes = $this.data("bytes"),
formattedSize = bytes >= 0 ? H5AI.util.formatSize(bytes) : "";
formattedSize = bytes >= 0 ? h5ai.util.formatSize(bytes) : "";
$this.text(formattedSize);
});
@ -421,7 +421,7 @@
initIndicators();
};
H5AI.core = {
h5ai.core = {
settings: settings,
hash: hash,
api: api,
@ -435,4 +435,4 @@
init: init
};
}(window, jQuery, H5AI, H5AI_CONFIG));
}(window, jQuery, h5ai, H5AI_CONFIG));

View file

@ -1,27 +1,27 @@
(function (document, $, H5AI) {
(function (document, $, h5ai) {
var initBreadcrumb = function () {
var $ul = $("body > nav ul"),
pathname = "/",
path = H5AI.connector.getPath(pathname),
path = h5ai.connector.getPath(pathname),
pathnameParts = document.location.pathname.split("/"),
lastPart = "",
title = document.domain;
$ul.append(H5AI.html.updateCrumbHtml(path));
$ul.append(h5ai.html.updateCrumbHtml(path));
$.each(pathnameParts, function (idx, part) {
if (part !== "") {
pathname += part + "/";
$ul.append(H5AI.html.updateCrumbHtml(H5AI.connector.getPath(pathname)));
$ul.append(h5ai.html.updateCrumbHtml(h5ai.connector.getPath(pathname)));
lastPart = part + " - ";
title += " > " + part;
}
});
document.title = H5AI.util.checkedDecodeUri(lastPart + title);
document.title = h5ai.util.checkedDecodeUri(lastPart + title);
},
initExtendedView = function () {
@ -37,8 +37,8 @@
// entries
$("#table td").closest("tr").each(function () {
var path = H5AI.connector.getPath(document.location.pathname, this);
$ul.append(H5AI.html.updateExtendedHtml(path));
var path = h5ai.connector.getPath(document.location.pathname, this);
$ul.append(h5ai.html.updateExtendedHtml(path));
});
$("#extended").append($ul);
@ -51,9 +51,9 @@
},
customize = function () {
if (H5AI.core.settings.customHeader) {
if (h5ai.core.settings.customHeader) {
$.ajax({
url: H5AI.core.settings.customHeader,
url: h5ai.core.settings.customHeader,
dataType: "html",
success: function (data) {
$("#content > header").append($(data)).show();
@ -61,9 +61,9 @@
});
}
if (H5AI.core.settings.customFooter) {
if (h5ai.core.settings.customFooter) {
$.ajax({
url: H5AI.core.settings.customFooter,
url: h5ai.core.settings.customFooter,
dataType: "html",
success: function (data) {
$("#content > footer").prepend($(data)).show();
@ -73,9 +73,9 @@
},
fetchPath = function (pathname, callback) {
H5AI.connector.fetchStatusAndContent(pathname, false, function (status, content) {
h5ai.connector.fetchStatusAndContent(pathname, false, function (status, content) {
var path = H5AI.connector.getPath(pathname);
var path = h5ai.connector.getPath(pathname);
path.status = status;
path.content = content;
@ -86,7 +86,7 @@
fetchPath(pathname, function (path) {
var parent = H5AI.util.splitPath(pathname).parent;
var parent = h5ai.util.splitPath(pathname).parent;
path.treeOpen = true;
if (childPath) {
@ -103,11 +103,11 @@
fetchTree(document.location.pathname, function (path) {
$("#tree")
.append(H5AI.html.updateTreeHtml(path))
.append(h5ai.html.updateTreeHtml(path))
.scrollpanel()
.show();
H5AI.core.shiftTree(false, true);
H5AI.core.linkHoverStates();
h5ai.core.shiftTree(false, true);
h5ai.core.linkHoverStates();
setTimeout(function () { $("#tree").get(0).updateScrollbar(); }, 1);
});
},
@ -116,14 +116,14 @@
initBreadcrumb();
initExtendedView();
customize();
H5AI.connector.updatePaths();
if (H5AI.core.settings.showTree) {
h5ai.connector.updatePaths();
if (h5ai.core.settings.showTree) {
populateTree();
}
};
H5AI.extended = {
h5ai.extended = {
init: init
};
}(document, jQuery, H5AI));
}(document, jQuery, h5ai));

View file

@ -1,5 +1,5 @@
(function ($, H5AI) {
(function ($, h5ai) {
var filter = function (re) {
@ -43,7 +43,7 @@
} else {
$filter.removeClass('current');
}
H5AI.core.hash({filter: val});
h5ai.core.hash({filter: val});
},
parseFilterSequence = function (sequence) {
@ -53,20 +53,20 @@
sequence = $.map($.trim(sequence).split(/\s+/), function (part) {
return H5AI.util.reEscape(part);
return h5ai.util.reEscape(part);
}).join('|');
return new RegExp(sequence);
},
init = function () {
if (H5AI.core.settings.showFilter) {
if (h5ai.core.settings.showFilter) {
$("<li id='filter'><span class='element'><img alt='filter' /><input type='text' value='' placeholder='filter' /></span></li>")
.on('click', function () {
var $input = $(this).find('input');
$input.focus();
})
.find("img").attr("src", H5AI.core.image("filter")).end()
.find("img").attr("src", h5ai.core.image("filter")).end()
.find("input")
.on('focus', function () {
@ -91,7 +91,7 @@
.end()
.appendTo($("#navbar"));
var initialFilter = H5AI.core.hash('filter');
var initialFilter = h5ai.core.hash('filter');
if (initialFilter) {
$('#filter input').val(initialFilter);
checkState(false);
@ -99,9 +99,9 @@
}
};
H5AI.finder = {
h5ai.finder = {
init: init,
filter: filter
};
}(jQuery, H5AI));
}(jQuery, h5ai));

50
src/_h5ai/js/inc/H5ai.js Normal file
View file

@ -0,0 +1,50 @@
(function ($) {
'use strict';
/*jslint browser: true, confusion: true, regexp: true, vars: true, white: true */
/*global Modernizr, jQuery, amplify, Base64, H5AI_CONFIG */
var h5ai = function () {
},
init = function () {
var $html = $('html');
h5ai.isJs = $html.hasClass('h5ai-js');
h5ai.isPhp = $html.hasClass('h5ai-php');
if (h5ai.isJs) {
h5ai.extended.init();
}
h5ai.core.init();
h5ai.sort.init();
h5ai.finder.init();
h5ai.zippedDownload.init();
h5ai.context.init();
if (h5ai.isPhp) {
$('#tree').scrollpanel();
h5ai.core.shiftTree(false, true);
}
// publish for testing
window.h5ai = h5ai;
};
// @include "Util.js"
// @include "Core.js"
// @include "Sort.js"
// @include "ZippedDownload.js"
// @include "Finder.js"
// @include "Context.js"
// @include "Path.js"
// @include "Connector.js"
// @include "Html.js"
// @include "Extended.js"
$(init);
}(jQuery));

View file

@ -1,5 +1,5 @@
(function ($, H5AI) {
(function ($, h5ai) {
var onClick = function (path, context) {
@ -22,12 +22,12 @@
$a = $html.find("a")
.attr("href", path.absHref)
.click(function() { onClick(path, "crumb"); })
.find("img").attr("src", H5AI.core.image("crumb")).end()
.find("img").attr("src", h5ai.core.image("crumb")).end()
.find("span").text(path.label).end();
if (path.isDomain) {
$html.addClass("domain");
$a.find("img").attr("src", H5AI.core.image("home"));
$a.find("img").attr("src", h5ai.core.image("home"));
}
if (path.isCurrentFolder) {
@ -36,7 +36,7 @@
if (!isNaN(path.status)) {
if (path.status === 200) {
$a.append($("<img class='hint' src='" + H5AI.core.image("page") + "' alt='not listable' />"));
$a.append($("<img class='hint' src='" + h5ai.core.image("page") + "' alt='not listable' />"));
} else {
$a.append($("<span class='hint'>(" + path.status + ")</span>"));
}
@ -52,10 +52,10 @@
updateExtendedHtml = function (path) {
var $html, $a, $label,
formattedDate = path.date ? path.date.toString(H5AI.core.settings.dateFormat) : "",
formattedDate = path.date ? path.date.toString(h5ai.core.settings.dateFormat) : "",
imgClass = "",
icon16 = H5AI.core.icon(path.type),
icon48 = H5AI.core.icon(path.type, true);
icon16 = h5ai.core.icon(path.type),
icon48 = h5ai.core.icon(path.type, true);
if (path.html.$extended && path.html.$extended.data("status") === path.status) {
return path.html.$extended;
@ -69,11 +69,11 @@
$html.data("status", path.status);
}
if (H5AI.core.settings.showThumbs === true && $.inArray(path.type, H5AI.core.settings.thumbTypes) >= 0) {
if (h5ai.core.settings.showThumbs === true && $.inArray(path.type, h5ai.core.settings.thumbTypes) >= 0) {
imgClass = "class='thumb'";
var escapedHref = path.absHref.replace(/'/g, "%27").replace(/"/g, "%22");
icon16 = H5AI.core.api() + "?action=thumb&href=" + escapedHref + "&width=16&height=16&mode=square";
icon48 = H5AI.core.api() + "?action=thumb&href=" + escapedHref + "&width=96&height=46&mode=rational";
icon16 = h5ai.core.api() + "?action=thumb&href=" + escapedHref + "&width=16&height=16&mode=square";
icon48 = h5ai.core.api() + "?action=thumb&href=" + escapedHref + "&width=96&height=46&mode=rational";
}
$label = $("<span class='label'>" + path.label + "</span>");
@ -113,7 +113,7 @@
);
if (path.isParentFolder) {
if (!H5AI.core.settings.setParentFolderLabels) {
if (!h5ai.core.settings.setParentFolderLabels) {
$label.addClass("l10n-parentDirectory");
}
$html.addClass("folder-parent");
@ -122,8 +122,8 @@
if (!isNaN(path.status)) {
if (path.status === 200) {
$html.addClass("page");
$a.find(".icon.small img").attr("src", H5AI.core.icon("folder-page"));
$a.find(".icon.big img").attr("src", H5AI.core.icon("folder-page", true));
$a.find(".icon.small img").attr("src", h5ai.core.icon("folder-page"));
$a.find(".icon.big img").attr("src", h5ai.core.icon("folder-page", true));
} else {
$html.addClass("error");
$label.append($("<span class='hint'> " + path.status + " </span>"));
@ -132,7 +132,7 @@
if (path.html.$extended) {
path.html.$extended.replaceWith($html);
H5AI.core.formatDates();
h5ai.core.formatDates();
}
path.html.$extended = $html;
@ -152,19 +152,19 @@
.attr("href", path.absHref)
.click(function() { onClick(path, "tree"); })
.appendTo($html)
.append($("<span class='icon'><img src='" + H5AI.core.icon(path.type) + "' /></span>"))
.append($("<span class='icon'><img src='" + h5ai.core.icon(path.type) + "' /></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='" + H5AI.core.image("tree") + "' /></span>")
$indicator = $("<span class='indicator initiated'><img src='" + h5ai.core.image("tree") + "' /></span>")
.click(function (event) {
var $entry = $indicator.closest(".entry"); // $html
if ($indicator.hasClass("unknown")) {
H5AI.connector.fetchStatusAndContent(path.absHref, false, function (status, content) {
h5ai.connector.fetchStatusAndContent(path.absHref, false, function (status, content) {
path.status = status;
path.content = content;
@ -205,13 +205,13 @@
// is path the domain?
if (path.isDomain) {
$html.addClass("domain");
$a.find(".icon img").attr("src", H5AI.core.icon("folder-home"));
$a.find(".icon img").attr("src", h5ai.core.icon("folder-home"));
}
// is path the current folder?
if (path.isCurrentFolder) {
$html.addClass("current");
$a.find(".icon img").attr("src", H5AI.core.icon("folder-open"));
$a.find(".icon img").attr("src", h5ai.core.icon("folder-open"));
}
// does it have subfolders?
@ -228,8 +228,8 @@
// reflect folder status
if (!isNaN(path.status)) {
if (path.status === 200) {
$a.find(".icon img").attr("src", H5AI.core.icon("folder-page"));
$a.append($("<span class='hint'><img src='" + H5AI.core.image("page") + "' /></span>"));
$a.find(".icon img").attr("src", h5ai.core.icon("folder-page"));
$a.append($("<span class='hint'><img src='" + h5ai.core.image("page") + "' /></span>"));
} else {
$html.addClass("error");
$a.append($("<span class='hint'>" + path.status + "</span>"));
@ -251,11 +251,11 @@
updateTreeHtml(path);
};
H5AI.html = {
h5ai.html = {
updateCrumbHtml: updateCrumbHtml,
updateExtendedHtml: updateExtendedHtml,
updateTreeHtml: updateTreeHtml,
updateHtml: updateHtml
};
}(jQuery, H5AI));
}(jQuery, h5ai));

View file

@ -1,7 +1,7 @@
(function (document, $, H5AI) {
(function (document, $, h5ai) {
H5AI.Path = function (folder, tableRow) {
h5ai.Path = function (folder, tableRow) {
var path = {},
$tds, $a, date, size, splits;
@ -27,7 +27,7 @@
};
path.treeOpen = false;
if (!H5AI.util.pathEndsWithSlash(folder)) {
if (!h5ai.util.pathEndsWithSlash(folder)) {
folder += "/";
}
@ -35,21 +35,21 @@
$tds = $(tableRow).find("td");
$a = $tds.eq(1).find("a");
date = Date.parse($tds.eq(2).text());
size = H5AI.util.parseSize($tds.eq(3).text());
size = h5ai.util.parseSize($tds.eq(3).text());
path.parentFolder = folder;
path.label = $a.text();
path.type = H5AI.util.pathEndsWithSlash(path.label) ? "folder" : H5AI.core.getFileType(path.label);
path.type = h5ai.util.pathEndsWithSlash(path.label) ? "folder" : h5ai.core.getFileType(path.label);
path.href = $a.attr("href");
path.time = date ? date.getTime() : 0;
path.size = size;
} else {
splits = H5AI.util.splitPath(folder);
splits = h5ai.util.splitPath(folder);
path.parentFolder = splits.parent || "";
path.label = H5AI.util.checkedDecodeUri(splits.name);
path.label = h5ai.util.checkedDecodeUri(splits.name);
if (path.label === "/") {
path.label = H5AI.util.checkedDecodeUri(document.domain);
path.label = h5ai.util.checkedDecodeUri(document.domain);
}
path.type = "folder";
path.href = splits.name;
@ -57,7 +57,7 @@
path.size = -1;
}
if (H5AI.util.pathEndsWithSlash(path.label)) {
if (h5ai.util.pathEndsWithSlash(path.label)) {
path.label = path.label.slice(0, -1);
}
@ -71,12 +71,12 @@
path.isCurrentFolder = (path.absHref === document.location.pathname);
path.isDomain = (path.absHref === "/");
if (path.isParentFolder && H5AI.core.settings.setParentFolderLabels) {
if (path.isParentFolder && h5ai.core.settings.setParentFolderLabels) {
if (path.isDomain) {
path.label = H5AI.util.checkedDecodeUri(document.domain);
path.label = h5ai.util.checkedDecodeUri(document.domain);
} else {
splits = H5AI.util.splitPath(path.parentFolder);
path.label = H5AI.util.checkedDecodeUri(splits.parentname);
splits = h5ai.util.splitPath(path.parentFolder);
path.label = h5ai.util.checkedDecodeUri(splits.parentname);
}
}
@ -86,10 +86,10 @@
};
path.onClick = function (context) {
H5AI.core.triggerPathClick(path, context);
h5ai.core.triggerPathClick(path, context);
};
return path;
};
}(document, jQuery, H5AI));
}(document, jQuery, h5ai));

View file

@ -1,5 +1,5 @@
(function ($, H5AI) {
(function ($, h5ai) {
var type = function (entry) {
@ -78,13 +78,13 @@
$all.removeClass("ascending").removeClass("descending");
order.head.addClass(order.clas);
sort(order.fn);
H5AI.core.hash({sort: id});
h5ai.core.hash({sort: id});
},
init = function () {
var $ascending = $("<img src='" + H5AI.core.image("ascending") + "' class='sort ascending' alt='ascending' />"),
$descending = $("<img src='" + H5AI.core.image("descending") + "' class='sort descending' alt='descending' />"),
initialOrder = H5AI.core.hash('sort'),
var $ascending = $("<img src='" + h5ai.core.image("ascending") + "' class='sort ascending' alt='ascending' />"),
$descending = $("<img src='" + h5ai.core.image("descending") + "' class='sort descending' alt='descending' />"),
initialOrder = h5ai.core.hash('sort'),
$header = $("#extended li.header"),
$label = $header.find("a.label"),
$date = $header.find("a.date"),
@ -124,7 +124,7 @@
}
};
sortBy(initialOrder ? initialOrder : H5AI.core.settings.sortorder);
sortBy(initialOrder ? initialOrder : h5ai.core.settings.sortorder);
$label
.append($ascending.clone()).append($descending.clone())
@ -148,8 +148,8 @@
});
};
H5AI.sort = {
h5ai.sort = {
init: init
};
}(jQuery, H5AI));
}(jQuery, h5ai));

View file

@ -1,5 +1,5 @@
(function ($, H5AI) {
(function ($, h5ai) {
var reSplitPath = /^\/([^\/]+\/?)$/,
reSplitPath2 = /^(\/(?:.*\/)*?([^\/]+)\/)([^\/]+\/?)$/,
@ -104,7 +104,7 @@
return sequence.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
};
H5AI.util = {
h5ai.util = {
splitPath: splitPath,
pathEndsWithSlash: pathEndsWithSlash,
getAbsHref: getAbsHref,
@ -114,4 +114,4 @@
reEscape: reEscape
};
}(jQuery, H5AI));
}(jQuery, h5ai));

View file

@ -1,5 +1,5 @@
(function ($, H5AI) {
(function ($, h5ai) {
var x = 0,
y = 0,
@ -102,11 +102,11 @@
$download.removeClass('current');
$img.attr('src', H5AI.core.image("download"));
$img.attr('src', h5ai.core.image("download"));
if (response) {
if (response.status === 'ok') {
window.location = H5AI.core.api() + '?action=getzip&id=' + response.id;
window.location = h5ai.core.api() + '?action=getzip&id=' + response.id;
} else {
if (response.code === 401) {
$downloadAuth
@ -126,9 +126,9 @@
requestZipping = function (hrefsStr) {
$download.addClass('current');
$img.attr('src', H5AI.core.image("loading.gif", true));
$img.attr('src', h5ai.core.image("loading.gif", true));
$.ajax({
url: H5AI.core.api(),
url: h5ai.core.api(),
data: {
action: 'zip',
hrefs: selectedHrefsStr
@ -156,9 +156,9 @@
},
init = function () {
if (H5AI.core.settings.zippedDownload) {
if (h5ai.core.settings.zippedDownload) {
$("<li id='download'><a href='#'><img alt='download' /><span class='l10n-download'>download</span></a></li>")
.find("img").attr("src", H5AI.core.image("download")).end()
.find("img").attr("src", h5ai.core.image("download")).end()
.find("a").click(function (event) {
event.preventDefault();
@ -181,8 +181,8 @@
}
};
H5AI.zippedDownload = {
h5ai.zippedDownload = {
init: init
};
}(jQuery, H5AI));
}(jQuery, h5ai));

View file

@ -1,42 +0,0 @@
(function ($) {
'use strict';
/*jslint browser: true, confusion: true, regexp: true, vars: true, white: true */
/*global Modernizr, jQuery, amplify, Base64, H5AI_CONFIG */
var H5AI = {};
// @include "Util.js"
// @include "Core.js"
// @include "Sort.js"
// @include "ZippedDownload.js"
// @include "Finder.js"
// @include "Context.js"
// @include "Path.js"
// @include "Connector.js"
// @include "Html.js"
// @include "Extended.js"
$(function () {
var isPhp = $('html.h5ai-php').length > 0;
if (!isPhp) {
H5AI.extended.init();
}
H5AI.core.init();
H5AI.sort.init();
H5AI.finder.init();
H5AI.zippedDownload.init();
H5AI.context.init();
if (isPhp) {
$('#tree').scrollpanel();
H5AI.core.shiftTree(false, true);
}
});
}(jQuery));

View file

@ -10,4 +10,4 @@
// @include "inc/lib/base64.js"
// @include "inc/lib/date.js"
// @include "inc/main.js"
// @include "inc/H5ai.js"