mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-05-25 12:34:47 -04:00
Refactores localization.
This commit is contained in:
parent
1152c00018
commit
a796bd606f
13 changed files with 286 additions and 267 deletions
|
@ -20,8 +20,8 @@
|
||||||
},
|
},
|
||||||
fetchStatus = function (pathname, callback) {
|
fetchStatus = function (pathname, callback) {
|
||||||
|
|
||||||
if (h5ai.core.settings.folderStatus[pathname]) {
|
if (h5ai.settings.folderStatus[pathname]) {
|
||||||
callback(h5ai.core.settings.folderStatus[pathname]);
|
callback(h5ai.settings.folderStatus[pathname]);
|
||||||
return;
|
return;
|
||||||
} else if (pathnameStatusCache[pathname]) {
|
} else if (pathnameStatusCache[pathname]) {
|
||||||
callback(pathnameStatusCache[pathname]);
|
callback(pathnameStatusCache[pathname]);
|
||||||
|
@ -30,13 +30,13 @@
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: pathname,
|
url: pathname,
|
||||||
type: "HEAD",
|
type: 'HEAD',
|
||||||
complete: function (xhr) {
|
complete: function (xhr) {
|
||||||
|
|
||||||
var status = xhr.status;
|
var status = xhr.status;
|
||||||
|
|
||||||
if (status === 200 && contentTypeRegEx.test(xhr.getResponseHeader("Content-Type"))) {
|
if (status === 200 && contentTypeRegEx.test(xhr.getResponseHeader('Content-Type'))) {
|
||||||
status = "h5ai";
|
status = 'h5ai';
|
||||||
}
|
}
|
||||||
pathnameStatusCache[pathname] = status;
|
pathnameStatusCache[pathname] = status;
|
||||||
callback(status);
|
callback(status);
|
||||||
|
@ -48,7 +48,7 @@
|
||||||
if (path.isFolder && !path.isParentFolder && path.status === undefined) {
|
if (path.isFolder && !path.isParentFolder && path.status === undefined) {
|
||||||
fetchStatus(path.absHref, function (status) {
|
fetchStatus(path.absHref, function (status) {
|
||||||
|
|
||||||
if (status !== "h5ai") {
|
if (status !== 'h5ai') {
|
||||||
path.status = status;
|
path.status = status;
|
||||||
}
|
}
|
||||||
h5ai.html.updateHtml(path);
|
h5ai.html.updateHtml(path);
|
||||||
|
@ -66,15 +66,15 @@
|
||||||
|
|
||||||
fetchStatus(pathname, function (status) {
|
fetchStatus(pathname, function (status) {
|
||||||
|
|
||||||
if (status !== "h5ai") {
|
if (status !== 'h5ai') {
|
||||||
callback(status, {});
|
callback(status, {});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: pathname,
|
url: pathname,
|
||||||
type: "GET",
|
type: 'GET',
|
||||||
dataType: "html",
|
dataType: 'html',
|
||||||
error: function (xhr) {
|
error: function (xhr) {
|
||||||
|
|
||||||
callback(xhr.status, {}); // since it was checked before this should never happen
|
callback(xhr.status, {}); // since it was checked before this should never happen
|
||||||
|
@ -83,12 +83,12 @@
|
||||||
|
|
||||||
var content = {};
|
var content = {};
|
||||||
|
|
||||||
if (!contentTypeRegEx.test(xhr.getResponseHeader("Content-Type"))) {
|
if (!contentTypeRegEx.test(xhr.getResponseHeader('Content-Type'))) {
|
||||||
callback(xhr.status, {}); // since it was checked before this should never happen
|
callback(xhr.status, {}); // since it was checked before this should never happen
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$(html).find("#table td").closest("tr").each(function () {
|
$(html).find('#table td').closest('tr').each(function () {
|
||||||
|
|
||||||
var path = getPath(pathname, this);
|
var path = getPath(pathname, this);
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@
|
||||||
updatePath(path);
|
updatePath(path);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
callback("h5ai", content);
|
callback('h5ai', content);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
},
|
},
|
||||||
init = function () {
|
init = function () {
|
||||||
|
|
||||||
qrCodesSize = h5ai.core.settings.qrCodesSize;
|
qrCodesSize = h5ai.settings.qrCodesSize;
|
||||||
if (!qrCodesSize) {
|
if (!qrCodesSize) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,38 +1,8 @@
|
||||||
|
|
||||||
(function (window, $, h5ai, config) {
|
(function (window, $, h5ai) {
|
||||||
|
|
||||||
var $window = $(window),
|
var $window = $(window),
|
||||||
defaults = {
|
settings = h5ai.settings,
|
||||||
store: {
|
|
||||||
viewmode: "h5ai.pref.viewmode",
|
|
||||||
lang: "h5ai.pref.lang"
|
|
||||||
},
|
|
||||||
callbacks: {
|
|
||||||
pathClick: []
|
|
||||||
},
|
|
||||||
|
|
||||||
rootAbsHref: "/",
|
|
||||||
h5aiAbsHref: "/_h5ai/",
|
|
||||||
customHeader: null,
|
|
||||||
customFooter: null,
|
|
||||||
viewmodes: ["details", "icons"],
|
|
||||||
sortorder: "na",
|
|
||||||
showTree: true,
|
|
||||||
slideTree: true,
|
|
||||||
folderStatus: {},
|
|
||||||
lang: "en",
|
|
||||||
useBrowserLang: true,
|
|
||||||
setParentFolderLabels: true,
|
|
||||||
linkHoverStates: true,
|
|
||||||
dateFormat: "yyyy-MM-dd HH:mm",
|
|
||||||
showThumbs: false,
|
|
||||||
thumbTypes: ["bmp", "gif", "ico", "image", "jpg", "png", "tiff"],
|
|
||||||
zippedDownload: false,
|
|
||||||
qrCodesSize: null,
|
|
||||||
showFilter: false
|
|
||||||
},
|
|
||||||
settings = $.extend({}, defaults, config.options),
|
|
||||||
currentDateFormat = settings.dateFormat,
|
|
||||||
extToFileType = (function (types) {
|
extToFileType = (function (types) {
|
||||||
var map = {};
|
var map = {};
|
||||||
$.each(types, function (type, exts) {
|
$.each(types, function (type, exts) {
|
||||||
|
@ -41,7 +11,7 @@
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return map;
|
return map;
|
||||||
}(config.types)),
|
}(h5ai.config.types)),
|
||||||
hash = function (obj) {
|
hash = function (obj) {
|
||||||
|
|
||||||
if ($.isPlainObject(obj)) {
|
if ($.isPlainObject(obj)) {
|
||||||
|
@ -248,97 +218,6 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
formatDates = function (dateFormat) {
|
|
||||||
|
|
||||||
if (dateFormat) {
|
|
||||||
currentDateFormat = dateFormat;
|
|
||||||
}
|
|
||||||
|
|
||||||
$("#extended .entry .date").each(function () {
|
|
||||||
|
|
||||||
var $this = $(this),
|
|
||||||
time = $this.data("time"),
|
|
||||||
formattedDate = time ? new Date(time).toString(currentDateFormat) : "";
|
|
||||||
|
|
||||||
$this.text(formattedDate);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
localize = function (langs, lang, useBrowserLang) {
|
|
||||||
|
|
||||||
var storedLang = amplify.store(settings.store.lang),
|
|
||||||
browserLang, selected, key;
|
|
||||||
|
|
||||||
if (langs[storedLang]) {
|
|
||||||
lang = storedLang;
|
|
||||||
} else if (useBrowserLang) {
|
|
||||||
browserLang = navigator.language || navigator.browserLanguage;
|
|
||||||
if (browserLang) {
|
|
||||||
if (langs[browserLang]) {
|
|
||||||
lang = browserLang;
|
|
||||||
} else if (browserLang.length > 2 && langs[browserLang.substr(0, 2)]) {
|
|
||||||
lang = browserLang.substr(0, 2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!langs[lang]) {
|
|
||||||
lang = "en";
|
|
||||||
}
|
|
||||||
|
|
||||||
selected = langs[lang];
|
|
||||||
if (selected) {
|
|
||||||
$.each(selected, function (key, value) {
|
|
||||||
$(".l10n-" + key).text(value);
|
|
||||||
});
|
|
||||||
$(".lang").text(lang);
|
|
||||||
$(".langOption").removeClass("current");
|
|
||||||
$(".langOption." + lang).addClass("current");
|
|
||||||
h5ai.core.hash({lang: lang});
|
|
||||||
}
|
|
||||||
|
|
||||||
formatDates(selected.dateFormat || settings.dateFormat);
|
|
||||||
},
|
|
||||||
initLangSelector = function (langs) {
|
|
||||||
|
|
||||||
var $langOptions = $("#langSelector .langOptions"),
|
|
||||||
sortedLangsKeys = [],
|
|
||||||
$ul;
|
|
||||||
|
|
||||||
$.each(langs, function (lang) {
|
|
||||||
sortedLangsKeys.push(lang);
|
|
||||||
});
|
|
||||||
sortedLangsKeys.sort();
|
|
||||||
|
|
||||||
$ul = $("<ul />");
|
|
||||||
$.each(sortedLangsKeys, function (idx, lang) {
|
|
||||||
$("<li class='langOption' />")
|
|
||||||
.addClass(lang)
|
|
||||||
.text(lang + " - " + langs[lang].lang)
|
|
||||||
.appendTo($ul)
|
|
||||||
.click(function () {
|
|
||||||
amplify.store(settings.store.lang, lang);
|
|
||||||
localize(langs, lang, false);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
$langOptions
|
|
||||||
.append($ul)
|
|
||||||
.scrollpanel();
|
|
||||||
|
|
||||||
$("#langSelector").hover(
|
|
||||||
function () {
|
|
||||||
$langOptions
|
|
||||||
.css("top", "-" + $langOptions.outerHeight() + "px")
|
|
||||||
.stop(true, true)
|
|
||||||
.fadeIn();
|
|
||||||
$langOptions.get(0).updateScrollbar();
|
|
||||||
},
|
|
||||||
function () {
|
|
||||||
$langOptions
|
|
||||||
.stop(true, true)
|
|
||||||
.fadeOut();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
},
|
|
||||||
onIndicatorClick = function (event) {
|
onIndicatorClick = function (event) {
|
||||||
|
|
||||||
var $indicator = $(this),
|
var $indicator = $(this),
|
||||||
|
@ -414,15 +293,12 @@
|
||||||
initTopSpace();
|
initTopSpace();
|
||||||
initTree();
|
initTree();
|
||||||
linkHoverStates();
|
linkHoverStates();
|
||||||
initLangSelector(config.langs);
|
|
||||||
localize(config.langs, settings.lang, settings.useBrowserLang);
|
|
||||||
formatSizes();
|
formatSizes();
|
||||||
setTotals();
|
setTotals();
|
||||||
initIndicators();
|
initIndicators();
|
||||||
};
|
};
|
||||||
|
|
||||||
h5ai.core = {
|
h5ai.core = {
|
||||||
settings: settings,
|
|
||||||
hash: hash,
|
hash: hash,
|
||||||
api: api,
|
api: api,
|
||||||
image: image,
|
image: image,
|
||||||
|
@ -430,9 +306,8 @@
|
||||||
shiftTree: shiftTree,
|
shiftTree: shiftTree,
|
||||||
linkHoverStates: linkHoverStates,
|
linkHoverStates: linkHoverStates,
|
||||||
initIndicators: initIndicators,
|
initIndicators: initIndicators,
|
||||||
formatDates: formatDates,
|
|
||||||
getFileType: getFileType,
|
getFileType: getFileType,
|
||||||
init: init
|
init: init
|
||||||
};
|
};
|
||||||
|
|
||||||
}(window, jQuery, h5ai, H5AI_CONFIG));
|
}(window, jQuery, h5ai));
|
||||||
|
|
|
@ -51,9 +51,9 @@
|
||||||
},
|
},
|
||||||
customize = function () {
|
customize = function () {
|
||||||
|
|
||||||
if (h5ai.core.settings.customHeader) {
|
if (h5ai.settings.customHeader) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: h5ai.core.settings.customHeader,
|
url: h5ai.settings.customHeader,
|
||||||
dataType: "html",
|
dataType: "html",
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
$("#content > header").append($(data)).show();
|
$("#content > header").append($(data)).show();
|
||||||
|
@ -61,9 +61,9 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (h5ai.core.settings.customFooter) {
|
if (h5ai.settings.customFooter) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: h5ai.core.settings.customFooter,
|
url: h5ai.settings.customFooter,
|
||||||
dataType: "html",
|
dataType: "html",
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
$("#content > footer").prepend($(data)).show();
|
$("#content > footer").prepend($(data)).show();
|
||||||
|
@ -117,7 +117,7 @@
|
||||||
initExtendedView();
|
initExtendedView();
|
||||||
customize();
|
customize();
|
||||||
h5ai.connector.updatePaths();
|
h5ai.connector.updatePaths();
|
||||||
if (h5ai.core.settings.showTree) {
|
if (h5ai.settings.showTree) {
|
||||||
populateTree();
|
populateTree();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -59,15 +59,15 @@
|
||||||
},
|
},
|
||||||
init = function () {
|
init = function () {
|
||||||
|
|
||||||
if (h5ai.core.settings.showFilter) {
|
if (h5ai.settings.showFilter) {
|
||||||
$("<li id='filter'><span class='element'><img alt='filter' /><input type='text' value='' placeholder='filter' /></span></li>")
|
$('<li id="filter"><span class="element"><img alt="filter" /><input type="text" value="" placeholder="filter" /></span></li>')
|
||||||
.on('click', function () {
|
.on('click', function () {
|
||||||
|
|
||||||
var $input = $(this).find('input');
|
var $input = $(this).find('input');
|
||||||
$input.focus();
|
$input.focus();
|
||||||
})
|
})
|
||||||
.find("img").attr("src", h5ai.core.image("filter")).end()
|
.find('img').attr('src', h5ai.core.image('filter')).end()
|
||||||
.find("input")
|
.find('input')
|
||||||
.on('focus', function () {
|
.on('focus', function () {
|
||||||
|
|
||||||
checkState(true);
|
checkState(true);
|
||||||
|
@ -89,7 +89,7 @@
|
||||||
checkState($input.is(':focus'));
|
checkState($input.is(':focus'));
|
||||||
})
|
})
|
||||||
.end()
|
.end()
|
||||||
.appendTo($("#navbar"));
|
.appendTo($('#navbar'));
|
||||||
|
|
||||||
var initialFilter = h5ai.core.hash('filter');
|
var initialFilter = h5ai.core.hash('filter');
|
||||||
if (initialFilter) {
|
if (initialFilter) {
|
||||||
|
|
|
@ -1,40 +1,75 @@
|
||||||
|
|
||||||
(function ($) {
|
(function ($, config) {
|
||||||
'use strict';
|
'use strict';
|
||||||
/*jslint browser: true, confusion: true, regexp: true, vars: true, white: true */
|
/*jslint browser: true, confusion: true, regexp: true, vars: true, white: true */
|
||||||
/*global Modernizr, jQuery, amplify, Base64, H5AI_CONFIG */
|
/*global Modernizr, jQuery, amplify, Base64, H5AI_CONFIG */
|
||||||
|
|
||||||
var h5ai = function () {
|
var defaults = {
|
||||||
|
store: {
|
||||||
|
viewmode: 'h5ai.pref.viewmode',
|
||||||
|
lang: 'h5ai.pref.lang'
|
||||||
|
},
|
||||||
|
callbacks: {
|
||||||
|
pathClick: []
|
||||||
|
},
|
||||||
|
|
||||||
|
rootAbsHref: '/',
|
||||||
|
h5aiAbsHref: '/_h5ai/',
|
||||||
|
customHeader: null,
|
||||||
|
customFooter: null,
|
||||||
|
viewmodes: ['details', 'icons'],
|
||||||
|
sortorder: 'na',
|
||||||
|
showTree: true,
|
||||||
|
slideTree: true,
|
||||||
|
folderStatus: {},
|
||||||
|
lang: 'en',
|
||||||
|
useBrowserLang: true,
|
||||||
|
setParentFolderLabels: true,
|
||||||
|
linkHoverStates: true,
|
||||||
|
dateFormat: 'yyyy-MM-dd HH:mm',
|
||||||
|
showThumbs: false,
|
||||||
|
thumbTypes: ['bmp', 'gif', 'ico', 'image', 'jpg', 'png', 'tiff'],
|
||||||
|
zippedDownload: false,
|
||||||
|
qrCodesSize: null,
|
||||||
|
showFilter: false
|
||||||
},
|
},
|
||||||
init = function () {
|
h5ai = 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;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
h5ai.config = config;
|
||||||
|
h5ai.settings = $.extend({}, defaults, config.options);
|
||||||
|
|
||||||
|
h5ai.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.localize.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 "Util.js"
|
||||||
// @include "Core.js"
|
// @include "Core.js"
|
||||||
|
// @include "Localize.js"
|
||||||
// @include "Sort.js"
|
// @include "Sort.js"
|
||||||
// @include "ZippedDownload.js"
|
// @include "ZippedDownload.js"
|
||||||
// @include "Finder.js"
|
// @include "Finder.js"
|
||||||
|
@ -45,6 +80,6 @@
|
||||||
// @include "Html.js"
|
// @include "Html.js"
|
||||||
// @include "Extended.js"
|
// @include "Extended.js"
|
||||||
|
|
||||||
$(init);
|
$(h5ai.init);
|
||||||
|
|
||||||
}(jQuery));
|
}(jQuery, H5AI_CONFIG));
|
||||||
|
|
|
@ -52,7 +52,7 @@
|
||||||
updateExtendedHtml = function (path) {
|
updateExtendedHtml = function (path) {
|
||||||
|
|
||||||
var $html, $a, $label,
|
var $html, $a, $label,
|
||||||
formattedDate = path.date ? path.date.toString(h5ai.core.settings.dateFormat) : "",
|
formattedDate = path.date ? path.date.toString(h5ai.settings.dateFormat) : "",
|
||||||
imgClass = "",
|
imgClass = "",
|
||||||
icon16 = h5ai.core.icon(path.type),
|
icon16 = h5ai.core.icon(path.type),
|
||||||
icon48 = h5ai.core.icon(path.type, true);
|
icon48 = h5ai.core.icon(path.type, true);
|
||||||
|
@ -69,7 +69,7 @@
|
||||||
$html.data("status", path.status);
|
$html.data("status", path.status);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (h5ai.core.settings.showThumbs === true && $.inArray(path.type, h5ai.core.settings.thumbTypes) >= 0) {
|
if (h5ai.settings.showThumbs === true && $.inArray(path.type, h5ai.settings.thumbTypes) >= 0) {
|
||||||
imgClass = "class='thumb'";
|
imgClass = "class='thumb'";
|
||||||
var escapedHref = path.absHref.replace(/'/g, "%27").replace(/"/g, "%22");
|
var escapedHref = path.absHref.replace(/'/g, "%27").replace(/"/g, "%22");
|
||||||
icon16 = h5ai.core.api() + "?action=thumb&href=" + escapedHref + "&width=16&height=16&mode=square";
|
icon16 = h5ai.core.api() + "?action=thumb&href=" + escapedHref + "&width=16&height=16&mode=square";
|
||||||
|
@ -113,7 +113,7 @@
|
||||||
);
|
);
|
||||||
|
|
||||||
if (path.isParentFolder) {
|
if (path.isParentFolder) {
|
||||||
if (!h5ai.core.settings.setParentFolderLabels) {
|
if (!h5ai.settings.setParentFolderLabels) {
|
||||||
$label.addClass("l10n-parentDirectory");
|
$label.addClass("l10n-parentDirectory");
|
||||||
}
|
}
|
||||||
$html.addClass("folder-parent");
|
$html.addClass("folder-parent");
|
||||||
|
|
108
src/_h5ai/js/inc/Localize.js
Normal file
108
src/_h5ai/js/inc/Localize.js
Normal file
|
@ -0,0 +1,108 @@
|
||||||
|
|
||||||
|
(function ($, h5ai) {
|
||||||
|
|
||||||
|
var settings = h5ai.settings,
|
||||||
|
langs = h5ai.config.langs,
|
||||||
|
currentDateFormat = settings.dateFormat,
|
||||||
|
formatDates = function (dateFormat) {
|
||||||
|
|
||||||
|
if (dateFormat) {
|
||||||
|
currentDateFormat = dateFormat;
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#extended .entry .date').each(function () {
|
||||||
|
|
||||||
|
var $this = $(this),
|
||||||
|
time = $this.data('time'),
|
||||||
|
formattedDate = time ? new Date(time).toString(currentDateFormat) : '';
|
||||||
|
|
||||||
|
$this.text(formattedDate);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
localize = function (langs, lang, useBrowserLang) {
|
||||||
|
|
||||||
|
var storedLang = amplify.store(settings.store.lang),
|
||||||
|
browserLang, selected, key;
|
||||||
|
|
||||||
|
if (langs[storedLang]) {
|
||||||
|
lang = storedLang;
|
||||||
|
} else if (useBrowserLang) {
|
||||||
|
browserLang = navigator.language || navigator.browserLanguage;
|
||||||
|
if (browserLang) {
|
||||||
|
if (langs[browserLang]) {
|
||||||
|
lang = browserLang;
|
||||||
|
} else if (browserLang.length > 2 && langs[browserLang.substr(0, 2)]) {
|
||||||
|
lang = browserLang.substr(0, 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!langs[lang]) {
|
||||||
|
lang = 'en';
|
||||||
|
}
|
||||||
|
|
||||||
|
selected = langs[lang];
|
||||||
|
if (selected) {
|
||||||
|
$.each(selected, function (key, value) {
|
||||||
|
$('.l10n-' + key).text(value);
|
||||||
|
});
|
||||||
|
$('.lang').text(lang);
|
||||||
|
$('.langOption').removeClass('current');
|
||||||
|
$('.langOption.' + lang).addClass('current');
|
||||||
|
h5ai.core.hash({lang: lang});
|
||||||
|
}
|
||||||
|
|
||||||
|
formatDates(selected.dateFormat || settings.dateFormat);
|
||||||
|
},
|
||||||
|
initLangSelector = function (langs) {
|
||||||
|
|
||||||
|
var $langOptions = $('#langSelector .langOptions'),
|
||||||
|
sortedLangsKeys = [],
|
||||||
|
$ul;
|
||||||
|
|
||||||
|
$.each(langs, function (lang) {
|
||||||
|
sortedLangsKeys.push(lang);
|
||||||
|
});
|
||||||
|
sortedLangsKeys.sort();
|
||||||
|
|
||||||
|
$ul = $('<ul />');
|
||||||
|
$.each(sortedLangsKeys, function (idx, lang) {
|
||||||
|
$('<li class="langOption" />')
|
||||||
|
.addClass(lang)
|
||||||
|
.text(lang + ' - ' + langs[lang].lang)
|
||||||
|
.appendTo($ul)
|
||||||
|
.click(function () {
|
||||||
|
amplify.store(settings.store.lang, lang);
|
||||||
|
localize(langs, lang, false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
$langOptions
|
||||||
|
.append($ul)
|
||||||
|
.scrollpanel();
|
||||||
|
|
||||||
|
$('#langSelector').hover(
|
||||||
|
function () {
|
||||||
|
$langOptions
|
||||||
|
.css('top', '-' + $langOptions.outerHeight() + 'px')
|
||||||
|
.stop(true, true)
|
||||||
|
.fadeIn();
|
||||||
|
$langOptions.get(0).updateScrollbar();
|
||||||
|
},
|
||||||
|
function () {
|
||||||
|
$langOptions
|
||||||
|
.stop(true, true)
|
||||||
|
.fadeOut();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
init = function () {
|
||||||
|
|
||||||
|
initLangSelector(langs);
|
||||||
|
localize(langs, settings.lang, settings.useBrowserLang);
|
||||||
|
};
|
||||||
|
|
||||||
|
h5ai.localize = {
|
||||||
|
init: init
|
||||||
|
};
|
||||||
|
|
||||||
|
}(jQuery, h5ai));
|
|
@ -18,7 +18,7 @@
|
||||||
// path.isCurrentFolder: undefined
|
// path.isCurrentFolder: undefined
|
||||||
// path.isDomain: undefined
|
// path.isDomain: undefined
|
||||||
|
|
||||||
path.status = undefined; // undefined, "h5ai" or HTTP response code
|
path.status = undefined; // undefined, 'h5ai' or HTTP response code
|
||||||
path.content = undefined; // associative array path.absHref -> path
|
path.content = undefined; // associative array path.absHref -> path
|
||||||
path.html = {
|
path.html = {
|
||||||
$crumb: undefined,
|
$crumb: undefined,
|
||||||
|
@ -28,30 +28,30 @@
|
||||||
path.treeOpen = false;
|
path.treeOpen = false;
|
||||||
|
|
||||||
if (!h5ai.util.pathEndsWithSlash(folder)) {
|
if (!h5ai.util.pathEndsWithSlash(folder)) {
|
||||||
folder += "/";
|
folder += '/';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tableRow) {
|
if (tableRow) {
|
||||||
$tds = $(tableRow).find("td");
|
$tds = $(tableRow).find('td');
|
||||||
$a = $tds.eq(1).find("a");
|
$a = $tds.eq(1).find('a');
|
||||||
date = Date.parse($tds.eq(2).text());
|
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.parentFolder = folder;
|
||||||
path.label = $a.text();
|
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.href = $a.attr('href');
|
||||||
path.time = date ? date.getTime() : 0;
|
path.time = date ? date.getTime() : 0;
|
||||||
path.size = size;
|
path.size = size;
|
||||||
} else {
|
} else {
|
||||||
splits = h5ai.util.splitPath(folder);
|
splits = h5ai.util.splitPath(folder);
|
||||||
|
|
||||||
path.parentFolder = splits.parent || "";
|
path.parentFolder = splits.parent || '';
|
||||||
path.label = h5ai.util.checkedDecodeUri(splits.name);
|
path.label = h5ai.util.checkedDecodeUri(splits.name);
|
||||||
if (path.label === "/") {
|
if (path.label === '/') {
|
||||||
path.label = h5ai.util.checkedDecodeUri(document.domain);
|
path.label = h5ai.util.checkedDecodeUri(document.domain);
|
||||||
}
|
}
|
||||||
path.type = "folder";
|
path.type = 'folder';
|
||||||
path.href = splits.name;
|
path.href = splits.name;
|
||||||
path.time = 0;
|
path.time = 0;
|
||||||
path.size = -1;
|
path.size = -1;
|
||||||
|
@ -61,17 +61,17 @@
|
||||||
path.label = path.label.slice(0, -1);
|
path.label = path.label.slice(0, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
path.isFolder = (path.type === "folder");
|
path.isFolder = (path.type === 'folder');
|
||||||
path.isParentFolder = (path.label === "Parent Directory");
|
path.isParentFolder = (path.label === 'Parent Directory');
|
||||||
if (path.isParentFolder) {
|
if (path.isParentFolder) {
|
||||||
path.isFolder = true;
|
path.isFolder = true;
|
||||||
path.type = "folder-parent";
|
path.type = 'folder-parent';
|
||||||
}
|
}
|
||||||
path.absHref = path.isParentFolder ? path.href : path.parentFolder + path.href;
|
path.absHref = path.isParentFolder ? path.href : path.parentFolder + path.href;
|
||||||
path.isCurrentFolder = (path.absHref === document.location.pathname);
|
path.isCurrentFolder = (path.absHref === document.location.pathname);
|
||||||
path.isDomain = (path.absHref === "/");
|
path.isDomain = (path.absHref === '/');
|
||||||
|
|
||||||
if (path.isParentFolder && h5ai.core.settings.setParentFolderLabels) {
|
if (path.isParentFolder && h5ai.settings.setParentFolderLabels) {
|
||||||
if (path.isDomain) {
|
if (path.isDomain) {
|
||||||
path.label = h5ai.util.checkedDecodeUri(document.domain);
|
path.label = h5ai.util.checkedDecodeUri(document.domain);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -5,9 +5,9 @@
|
||||||
|
|
||||||
var $entry = $(entry);
|
var $entry = $(entry);
|
||||||
|
|
||||||
if ($entry.hasClass("folder-parent")) {
|
if ($entry.hasClass('folder-parent')) {
|
||||||
return 0;
|
return 0;
|
||||||
} else if ($entry.hasClass("folder")) {
|
} else if ($entry.hasClass('folder')) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 2;
|
return 2;
|
||||||
|
@ -33,117 +33,117 @@
|
||||||
cmpName = function (entry1, entry2) {
|
cmpName = function (entry1, entry2) {
|
||||||
|
|
||||||
return cmp(entry1, entry2, false, function (entry) {
|
return cmp(entry1, entry2, false, function (entry) {
|
||||||
return $(entry).find(".label").text().toLowerCase();
|
return $(entry).find('.label').text().toLowerCase();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
cmpTime = function (entry1, entry2) {
|
cmpTime = function (entry1, entry2) {
|
||||||
|
|
||||||
return cmp(entry1, entry2, false, function (entry) {
|
return cmp(entry1, entry2, false, function (entry) {
|
||||||
return $(entry).find(".date").data("time");
|
return $(entry).find('.date').data('time');
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
cmpSize = function (entry1, entry2) {
|
cmpSize = function (entry1, entry2) {
|
||||||
|
|
||||||
return cmp(entry1, entry2, false, function (entry) {
|
return cmp(entry1, entry2, false, function (entry) {
|
||||||
return $(entry).find(".size").data("bytes");
|
return $(entry).find('.size').data('bytes');
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
cmpNameRev = function (entry1, entry2) {
|
cmpNameRev = function (entry1, entry2) {
|
||||||
|
|
||||||
return cmp(entry1, entry2, true, function (entry) {
|
return cmp(entry1, entry2, true, function (entry) {
|
||||||
return $(entry).find(".label").text().toLowerCase();
|
return $(entry).find('.label').text().toLowerCase();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
cmpTimeRev = function (entry1, entry2) {
|
cmpTimeRev = function (entry1, entry2) {
|
||||||
|
|
||||||
return cmp(entry1, entry2, true, function (entry) {
|
return cmp(entry1, entry2, true, function (entry) {
|
||||||
return $(entry).find(".date").data("time");
|
return $(entry).find('.date').data('time');
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
cmpSizeRev = function (entry1, entry2) {
|
cmpSizeRev = function (entry1, entry2) {
|
||||||
|
|
||||||
return cmp(entry1, entry2, true, function (entry) {
|
return cmp(entry1, entry2, true, function (entry) {
|
||||||
return $(entry).find(".size").data("bytes");
|
return $(entry).find('.size').data('bytes');
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
sort = function (fn) {
|
sort = function (fn) {
|
||||||
|
|
||||||
$("#extended .entry").detach().sort(fn).appendTo($("#extended > ul"));
|
$('#extended .entry').detach().sort(fn).appendTo($('#extended > ul'));
|
||||||
},
|
},
|
||||||
$all, orders,
|
$all, orders,
|
||||||
sortBy = function (id) {
|
sortBy = function (id) {
|
||||||
|
|
||||||
var order = orders[id];
|
var order = orders[id];
|
||||||
|
|
||||||
$all.removeClass("ascending").removeClass("descending");
|
$all.removeClass('ascending').removeClass('descending');
|
||||||
order.head.addClass(order.clas);
|
order.head.addClass(order.clas);
|
||||||
sort(order.fn);
|
sort(order.fn);
|
||||||
h5ai.core.hash({sort: id});
|
h5ai.core.hash({sort: id});
|
||||||
},
|
},
|
||||||
init = function () {
|
init = function () {
|
||||||
|
|
||||||
var $ascending = $("<img src='" + h5ai.core.image("ascending") + "' class='sort ascending' alt='ascending' />"),
|
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' />"),
|
$descending = $('<img src="' + h5ai.core.image('descending') + '" class="sort descending" alt="descending" />'),
|
||||||
initialOrder = h5ai.core.hash('sort'),
|
initialOrder = h5ai.core.hash('sort'),
|
||||||
$header = $("#extended li.header"),
|
$header = $('#extended li.header'),
|
||||||
$label = $header.find("a.label"),
|
$label = $header.find('a.label'),
|
||||||
$date = $header.find("a.date"),
|
$date = $header.find('a.date'),
|
||||||
$size = $header.find("a.size");
|
$size = $header.find('a.size');
|
||||||
|
|
||||||
$all = $header.find("a.label,a.date,a.size");
|
$all = $header.find('a.label,a.date,a.size');
|
||||||
orders = {
|
orders = {
|
||||||
na: {
|
na: {
|
||||||
head: $label,
|
head: $label,
|
||||||
clas: "ascending",
|
clas: 'ascending',
|
||||||
fn: cmpName
|
fn: cmpName
|
||||||
},
|
},
|
||||||
nd: {
|
nd: {
|
||||||
head: $label,
|
head: $label,
|
||||||
clas: "descending",
|
clas: 'descending',
|
||||||
fn: cmpNameRev
|
fn: cmpNameRev
|
||||||
},
|
},
|
||||||
da: {
|
da: {
|
||||||
head: $date,
|
head: $date,
|
||||||
clas: "ascending",
|
clas: 'ascending',
|
||||||
fn: cmpTime
|
fn: cmpTime
|
||||||
},
|
},
|
||||||
dd: {
|
dd: {
|
||||||
head: $date,
|
head: $date,
|
||||||
clas: "descending",
|
clas: 'descending',
|
||||||
fn: cmpTimeRev
|
fn: cmpTimeRev
|
||||||
},
|
},
|
||||||
sa: {
|
sa: {
|
||||||
head: $size,
|
head: $size,
|
||||||
clas: "ascending",
|
clas: 'ascending',
|
||||||
fn: cmpSize
|
fn: cmpSize
|
||||||
},
|
},
|
||||||
sd: {
|
sd: {
|
||||||
head: $size,
|
head: $size,
|
||||||
clas: "descending",
|
clas: 'descending',
|
||||||
fn: cmpSizeRev
|
fn: cmpSizeRev
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
sortBy(initialOrder ? initialOrder : h5ai.core.settings.sortorder);
|
sortBy(initialOrder ? initialOrder : h5ai.settings.sortorder);
|
||||||
|
|
||||||
$label
|
$label
|
||||||
.append($ascending.clone()).append($descending.clone())
|
.append($ascending.clone()).append($descending.clone())
|
||||||
.click(function (event) {
|
.click(function (event) {
|
||||||
sortBy("n" + ($label.hasClass("ascending") ? "d" : "a"));
|
sortBy('n' + ($label.hasClass('ascending') ? 'd' : 'a'));
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
$date
|
$date
|
||||||
.prepend($ascending.clone()).prepend($descending.clone())
|
.prepend($ascending.clone()).prepend($descending.clone())
|
||||||
.click(function (event) {
|
.click(function (event) {
|
||||||
sortBy("d" + ($date.hasClass("ascending") ? "d" : "a"));
|
sortBy('d' + ($date.hasClass('ascending') ? 'd' : 'a'));
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
$size
|
$size
|
||||||
.prepend($ascending.clone()).prepend($descending.clone())
|
.prepend($ascending.clone()).prepend($descending.clone())
|
||||||
.click(function (event) {
|
.click(function (event) {
|
||||||
sortBy("s" + ($size.hasClass("ascending") ? "d" : "a"));
|
sortBy('s' + ($size.hasClass('ascending') ? 'd' : 'a'));
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,15 +3,20 @@
|
||||||
|
|
||||||
var reSplitPath = /^\/([^\/]+\/?)$/,
|
var reSplitPath = /^\/([^\/]+\/?)$/,
|
||||||
reSplitPath2 = /^(\/(?:.*\/)*?([^\/]+)\/)([^\/]+\/?)$/,
|
reSplitPath2 = /^(\/(?:.*\/)*?([^\/]+)\/)([^\/]+\/?)$/,
|
||||||
|
rePathEndsWithSlash = /\/$/,
|
||||||
|
reParseSize = /^\s*([\.\d]+)\s*([kmg]?)b?\s*$/i,
|
||||||
|
kilo = 1000.0,
|
||||||
|
sizeUnits = ['B', 'KB', 'MB', 'GB', 'TB'],
|
||||||
|
|
||||||
splitPath = function (pathname) {
|
splitPath = function (pathname) {
|
||||||
|
|
||||||
var match;
|
var match;
|
||||||
|
|
||||||
if (pathname === "/") {
|
if (pathname === '/') {
|
||||||
return {
|
return {
|
||||||
parent: null,
|
parent: null,
|
||||||
parentname: null,
|
parentname: null,
|
||||||
name: "/"
|
name: '/'
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
match = reSplitPath2.exec(pathname);
|
match = reSplitPath2.exec(pathname);
|
||||||
|
@ -25,13 +30,12 @@
|
||||||
match = reSplitPath.exec(pathname);
|
match = reSplitPath.exec(pathname);
|
||||||
if (match) {
|
if (match) {
|
||||||
return {
|
return {
|
||||||
parent: "/",
|
parent: '/',
|
||||||
parentname: "/",
|
parentname: '/',
|
||||||
name: match[1]
|
name: match[1]
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
rePathEndsWithSlash = /\/$/,
|
|
||||||
pathEndsWithSlash = function (pathname) {
|
pathEndsWithSlash = function (pathname) {
|
||||||
|
|
||||||
return rePathEndsWithSlash.test(pathname);
|
return rePathEndsWithSlash.test(pathname);
|
||||||
|
@ -41,18 +45,16 @@
|
||||||
var $a, isParentFolder, href;
|
var $a, isParentFolder, href;
|
||||||
|
|
||||||
if (!pathEndsWithSlash(folder)) {
|
if (!pathEndsWithSlash(folder)) {
|
||||||
folder += "/";
|
folder += '/';
|
||||||
}
|
}
|
||||||
if (!tableRow) {
|
if (!tableRow) {
|
||||||
return folder;
|
return folder;
|
||||||
}
|
}
|
||||||
$a = $(tableRow).find("td").eq(1).find("a");
|
$a = $(tableRow).find('td').eq(1).find('a');
|
||||||
isParentFolder = ($a.text() === "Parent Directory");
|
isParentFolder = ($a.text() === 'Parent Directory');
|
||||||
href = $a.attr("href");
|
href = $a.attr('href');
|
||||||
return isParentFolder ? undefined : folder + href;
|
return isParentFolder ? undefined : folder + href;
|
||||||
},
|
},
|
||||||
kilo = 1000.0,
|
|
||||||
reParseSize = /^\s*([\.\d]+)\s*([kmg]?)b?\s*$/i,
|
|
||||||
parseSize = function (str) {
|
parseSize = function (str) {
|
||||||
|
|
||||||
var match = reParseSize.exec(str),
|
var match = reParseSize.exec(str),
|
||||||
|
@ -64,18 +66,17 @@
|
||||||
|
|
||||||
val = parseFloat(match[1]);
|
val = parseFloat(match[1]);
|
||||||
unit = match[2].toLowerCase();
|
unit = match[2].toLowerCase();
|
||||||
if (unit === "k") {
|
if (unit === 'k') {
|
||||||
val *= kilo;
|
val *= kilo;
|
||||||
} else if (unit === "m") {
|
} else if (unit === 'm') {
|
||||||
val *= kilo * kilo;
|
val *= kilo * kilo;
|
||||||
} else if (unit === "g") {
|
} else if (unit === 'g') {
|
||||||
val *= kilo * kilo * kilo;
|
val *= kilo * kilo * kilo;
|
||||||
} else if (unit === "t") {
|
} else if (unit === 't') {
|
||||||
val *= kilo * kilo * kilo * kilo;
|
val *= kilo * kilo * kilo * kilo;
|
||||||
}
|
}
|
||||||
return val;
|
return val;
|
||||||
},
|
},
|
||||||
sizeUnits = ["B", "KB", "MB", "GB", "TB"],
|
|
||||||
formatSize = function (size) {
|
formatSize = function (size) {
|
||||||
|
|
||||||
var th = 1000.0,
|
var th = 1000.0,
|
||||||
|
@ -90,7 +91,7 @@
|
||||||
size /= kilo;
|
size /= kilo;
|
||||||
i += 1;
|
i += 1;
|
||||||
}
|
}
|
||||||
return (i <= 1 ? Math.round(size) : size.toFixed(1)).toString() + " " + sizeUnits[i];
|
return (i <= 1 ? Math.round(size) : size.toFixed(1)).toString() + ' ' + sizeUnits[i];
|
||||||
},
|
},
|
||||||
checkedDecodeUri = function (uri) {
|
checkedDecodeUri = function (uri) {
|
||||||
|
|
||||||
|
|
|
@ -4,21 +4,21 @@
|
||||||
var x = 0,
|
var x = 0,
|
||||||
y = 0,
|
y = 0,
|
||||||
$document = $(document),
|
$document = $(document),
|
||||||
$selectionRect = $("#selection-rect"),
|
$selectionRect = $('#selection-rect'),
|
||||||
selectedHrefsStr = "",
|
selectedHrefsStr = '',
|
||||||
$download, $img, $downloadAuth, $downloadUser, $downloadPassword,
|
$download, $img, $downloadAuth, $downloadUser, $downloadPassword,
|
||||||
|
|
||||||
updateDownloadBtn = function () {
|
updateDownloadBtn = function () {
|
||||||
|
|
||||||
var $selected = $("#extended a.selected"),
|
var $selected = $('#extended a.selected'),
|
||||||
$downloadBtn = $("#download");
|
$downloadBtn = $('#download');
|
||||||
|
|
||||||
selectedHrefsStr = "";
|
selectedHrefsStr = '';
|
||||||
if ($selected.length) {
|
if ($selected.length) {
|
||||||
$selected.each(function () {
|
$selected.each(function () {
|
||||||
|
|
||||||
var href = $(this).attr("href");
|
var href = $(this).attr('href');
|
||||||
selectedHrefsStr = selectedHrefsStr ? selectedHrefsStr + ":" + href : href;
|
selectedHrefsStr = selectedHrefsStr ? selectedHrefsStr + ':' + href : href;
|
||||||
});
|
});
|
||||||
$downloadBtn.show();
|
$downloadBtn.show();
|
||||||
} else {
|
} else {
|
||||||
|
@ -37,24 +37,24 @@
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
$selectionRect.css({left: l, top: t, width: w, height: h});
|
$selectionRect.css({left: l, top: t, width: w, height: h});
|
||||||
|
|
||||||
selRect = $selectionRect.fracs("rect");
|
selRect = $selectionRect.fracs('rect');
|
||||||
$("#extended a").removeClass("selecting").each(function () {
|
$('#extended a').removeClass('selecting').each(function () {
|
||||||
|
|
||||||
var $a = $(this),
|
var $a = $(this),
|
||||||
rect = $a.fracs("rect"),
|
rect = $a.fracs('rect'),
|
||||||
inter = selRect.intersection(rect);
|
inter = selRect.intersection(rect);
|
||||||
if (inter && !$a.closest(".entry").hasClass("folder-parent")) {
|
if (inter && !$a.closest('.entry').hasClass('folder-parent')) {
|
||||||
$a.addClass("selecting");
|
$a.addClass('selecting');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
selectionEnd = function (event) {
|
selectionEnd = function (event) {
|
||||||
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
$document.off("mousemove", selectionUpdate);
|
$document.off('mousemove', selectionUpdate);
|
||||||
$selectionRect.hide().css({left: 0, top: 0, width: 0, height: 0});
|
$selectionRect.hide().css({left: 0, top: 0, width: 0, height: 0});
|
||||||
$("#extended a.selecting.selected").removeClass("selecting").removeClass("selected");
|
$('#extended a.selecting.selected').removeClass('selecting').removeClass('selected');
|
||||||
$("#extended a.selecting").removeClass("selecting").addClass("selected");
|
$('#extended a.selecting').removeClass('selecting').addClass('selected');
|
||||||
updateDownloadBtn();
|
updateDownloadBtn();
|
||||||
},
|
},
|
||||||
selectionStart = function (event) {
|
selectionStart = function (event) {
|
||||||
|
@ -156,18 +156,18 @@
|
||||||
},
|
},
|
||||||
init = function () {
|
init = function () {
|
||||||
|
|
||||||
if (h5ai.core.settings.zippedDownload) {
|
if (h5ai.settings.zippedDownload) {
|
||||||
$("<li id='download'><a href='#'><img alt='download' /><span class='l10n-download'>download</span></a></li>")
|
$('<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) {
|
.find('a').click(function (event) {
|
||||||
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
$downloadAuth.hide();
|
$downloadAuth.hide();
|
||||||
requestZipping(selectedHrefsStr);
|
requestZipping(selectedHrefsStr);
|
||||||
}).end()
|
}).end()
|
||||||
.appendTo($("#navbar"));
|
.appendTo($('#navbar'));
|
||||||
$("<div id='download-auth'><input id='download-auth-user' type='text' value='' placeholder='user' /><input id='download-auth-password' type='text' value='' placeholder='password' /></div>")
|
$('<div id="download-auth"><input id="download-auth-user" type="text" value="" placeholder="user" /><input id="download-auth-password" type="text" value="" placeholder="password" /></div>')
|
||||||
.appendTo($("body"));
|
.appendTo($('body'));
|
||||||
|
|
||||||
$download = $('#download');
|
$download = $('#download');
|
||||||
$downloadAuth = $('#download-auth');
|
$downloadAuth = $('#download-auth');
|
||||||
|
@ -175,9 +175,9 @@
|
||||||
$downloadPassword = $('#download-auth-password');
|
$downloadPassword = $('#download-auth-password');
|
||||||
$img = $download.find('img');
|
$img = $download.find('img');
|
||||||
|
|
||||||
$("body>nav,body>footer,#tree,input").on("mousedown", noSelection);
|
$('body>nav,body>footer,#tree,input').on('mousedown', noSelection);
|
||||||
$("#content").on("mousedown", "a", noSelectionUnlessCtrl);
|
$('#content').on('mousedown', 'a', noSelectionUnlessCtrl);
|
||||||
$document.on("mousedown", selectionStart);
|
$document.on('mousedown', selectionStart);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,6 @@
|
||||||
// @include "inc/lib/base64.js"
|
// @include "inc/lib/base64.js"
|
||||||
// @include "inc/lib/date.js"
|
// @include "inc/lib/date.js"
|
||||||
|
|
||||||
// app scripts
|
// h5ai
|
||||||
// -----------
|
// ----
|
||||||
// @include "inc/H5ai.js"
|
// @include "inc/H5ai.js"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue