Cleans js. Fixes js. Updates ru translation.

This commit is contained in:
Lars Jung 2012-09-16 21:02:40 +02:00
parent aa92ab9e83
commit 6b5556f338
27 changed files with 83 additions and 168 deletions

View file

@ -1,11 +1,9 @@
modulejs.define('core/settings', ['config', '_'], function (config, _) {
var defaults = {
var settings = _.extend({
h5aiAbsHref: '/_h5ai/'
};
var settings = _.extend({}, defaults, config.options);
}, config.options);
settings.h5aiAbsHref = settings.h5aiAbsHref.replace(/\/*$/, '/');
settings.rootAbsHref = /^(.*\/)[^\/]+\/?$/.exec(settings.h5aiAbsHref)[1];

View file

@ -1,12 +1,10 @@
modulejs.define('ext/autorefresh', ['_', '$', 'core/settings', 'core/event', 'core/refresh'], function (_, $, allsettings, event, refresh) {
var defaults = {
var settings = _.extend({
enabled: false,
interval: 5000
},
settings = _.extend({}, defaults, allsettings.autorefresh),
}, allsettings.autorefresh),
heartbeat = function () {

View file

@ -1,11 +1,9 @@
modulejs.define('ext/crumb', ['_', '$', 'core/settings', 'core/resource', 'core/event', 'core/entry'], function (_, $, allsettings, resource, event, entry) {
var defaults = {
var settings = _.extend({
enabled: false
},
settings = _.extend({}, defaults, allsettings.crumb),
}, allsettings.crumb),
template = '<li class="crumb">' +
'<a>' +

View file

@ -1,13 +1,11 @@
modulejs.define('ext/custom', ['_', '$', 'core/settings', 'core/ajax'], function (_, $, allsettings, ajax) {
var defaults = {
var settings = _.extend({
enabled: false,
header: '_h5ai.header.html',
footer: '_h5ai.footer.html'
},
settings = _.extend({}, defaults, allsettings.custom),
}, allsettings.custom),
init = function () {

View file

@ -1,11 +1,9 @@
modulejs.define('ext/delete', ['_', '$', 'core/settings', 'core/entry', 'core/event', 'core/resource', 'core/refresh'], function (_, $, allsettings, entry, event, resource, refresh) {
var defaults = {
var settings = _.extend({
enabled: false
},
settings = _.extend({}, defaults, allsettings['delete']),
}, allsettings['delete']),
deleteBtnTemplate = '<li id="delete">' +
'<a href="#">' +

View file

@ -1,13 +1,11 @@
modulejs.define('ext/download', ['_', '$', 'core/settings', 'core/resource', 'core/event', 'core/ajax'], function (_, $, allsettings, resource, event, ajax) {
var defaults = {
var settings = _.extend({
enabled: false,
execution: 'php',
format: 'zip'
},
settings = _.extend({}, defaults, allsettings.download),
}, allsettings.download),
// formats = ['tar', 'zip'],

View file

@ -1,15 +1,13 @@
modulejs.define('ext/dropbox', ['_', '$', 'core/settings', 'core/entry', 'core/resource', 'core/refresh'], function (_, $, allsettings, entry, resource, refresh) {
var defaults = {
var settings = _.extend({
enabled: false,
maxfiles: 5,
maxfilesize: 20
},
}, allsettings.dropbox),
settings = _.extend({}, defaults, allsettings.dropbox),
template = '<ul id="uploads" />',
template = '<ul id="uploads"/>',
uploadTemplate = '<li class="upload clearfix">' +
'<span class="name"/>' +

View file

@ -1,11 +1,9 @@
modulejs.define('ext/filter', ['_', '$', 'core/settings', 'core/resource'], function (_, $, allsettings, resource) {
var defaults = {
var settings = _.extend({
enabled: false
},
settings = _.extend({}, defaults, allsettings.filter),
}, allsettings.filter),
template = '<li id="filter">' +
'<span class="element">' +
@ -47,17 +45,6 @@ modulejs.define('ext/filter', ['_', '$', 'core/settings', 'core/resource'], func
$(noMatch).fadeOut(duration);
},
checkState = function (focus) {
var val = $input.val();
if (val || focus) {
$filter.addClass('current');
} else {
$filter.removeClass('current');
}
},
escapeRegExp = function (sequence) {
return sequence.replace(/[\-\[\]{}()*+?.,\\$\^|#\s]/g, '\\$&');
@ -75,8 +62,6 @@ modulejs.define('ext/filter', ['_', '$', 'core/settings', 'core/resource'], func
return escapeRegExp(char);
}).join('.*?');
// return escapeRegExp(part);
}).join('|');
return new RegExp(sequence, 'i');
@ -88,10 +73,11 @@ modulejs.define('ext/filter', ['_', '$', 'core/settings', 'core/resource'], func
if (val) {
filter(parseFilterSequence(val));
$filter.addClass('current');
} else {
filter();
$filter.removeClass('current');
}
checkState($input.is(':focus'));
},
init = function () {
@ -100,7 +86,7 @@ modulejs.define('ext/filter', ['_', '$', 'core/settings', 'core/resource'], func
return;
}
$filter = $(template);
$filter = $(template).appendTo('#navbar');
$input = $filter.find('input');
$noMatch = $(noMatchTemplate).appendTo('#extended');
@ -108,35 +94,25 @@ modulejs.define('ext/filter', ['_', '$', 'core/settings', 'core/resource'], func
.on('click', function () {
$input.focus();
})
.appendTo('#navbar');
});
$input
.on('focus', function () {
checkState(true);
$filter.addClass('current');
})
.on('blur', function () {
checkState(false);
})
.on('keyup', update);
.on('blur keyup', update);
$(document)
.on('keydown', function (event) {
if (event.which === 27) {
$input.attr('value','').blur();
checkState(false);
}
})
.on('keypress', function (event) {
$input.focus();
})
.on('keyup', function (event) {
checkState(false);
});
};

View file

@ -1,14 +1,10 @@
modulejs.define('ext/folderstatus', ['_', 'core/settings'], function (_, allsettings) {
var defaults = {
var settings = _.extend({
enabled: false,
folders: {}
},
}, allsettings.folderstatus);
settings = _.extend({}, defaults, allsettings.folderstatus),
folders = settings.enabled ? settings.folders : defaults.folders;
return folders;
return settings.enabled ? settings.folders : {};
});

View file

@ -1,12 +1,10 @@
modulejs.define('ext/google-analytics', ['_', 'core/settings'], function (_, allsettings) {
var defaults = {
var settings = _.extend({
enabled: false,
gaq: []
},
settings = _.extend({}, defaults, allsettings['google-analytics']),
}, allsettings['google-analytics']),
init = function () {

View file

@ -1,11 +1,11 @@
modulejs.define('ext/l10n', ['_', '$', 'core/settings', 'core/langs', 'core/format', 'core/store', 'core/event'], function (_, $, allsettings, langs, format, store, event) {
var defaults = {
var settings = _.extend({
enabled: true,
lang: 'en',
useBrowserLang: true
},
}, allsettings.l10n),
defaultTranslations = {
lang: 'english',
@ -26,8 +26,6 @@ modulejs.define('ext/l10n', ['_', '$', 'core/settings', 'core/langs', 'core/form
filter: 'filter'
},
settings = _.extend({}, defaults, allsettings.l10n),
template = '<span id="langSelector">' +
'<span class="lang">en</span> - <span class="l10n-lang">english</span>' +
'<span class="langOptions"><ul/></span>' +

View file

@ -1,11 +1,9 @@
modulejs.define('ext/link-hover-states', ['_', '$', 'core/settings'], function (_, $, allsettings) {
var defaults = {
var settings = _.extend({
enabled: false
},
settings = _.extend({}, defaults, allsettings['link-hover-states']),
}, allsettings['link-hover-states']),
selector = "a[href^='/']",

View file

@ -1,12 +1,10 @@
modulejs.define('ext/mode', ['_', '$', 'core/mode', 'core/settings'], function (_, $, mode, allsettings) {
var defaults = {
var settings = _.extend({
enabled: false,
display: 0
},
settings = _.extend({}, defaults, allsettings.mode),
}, allsettings.mode),
init = function () {

View file

@ -1,13 +1,11 @@
modulejs.define('ext/piwik-analytics', ['_', '$', 'core/settings'], function (_, $, allsettings) {
var defaults = {
var settings = _.extend({
enabled: false,
baseURL: 'not-set',
idSite: 0
},
settings = _.extend({}, defaults, allsettings['piwik-analytics']),
}, allsettings['piwik-analytics']),
init = function () {

View file

@ -1,12 +1,10 @@
modulejs.define('ext/preview-img', ['_', '$', 'core/settings', 'core/resource', 'core/store', 'core/event', 'core/entry'], function (_, $, allsettings, resource, store, event, entry) {
var defaults = {
var settings = _.extend({
enabled: false,
types: ['bmp', 'gif', 'ico', 'image', 'jpg', 'png', 'tiff']
},
settings = _.extend({}, defaults, allsettings['preview-img']),
}, allsettings['preview-img']),
template = '<div id="pv-img-overlay" class="noSelection">' +
'<div id="pv-img-content">' +
@ -139,7 +137,7 @@ modulejs.define('ext/preview-img', ['_', '$', 'core/settings', 'core/resource',
$img.attr('src', src).fadeIn(200);
// small timeout, so $img is visible and therefor $img.width is available
// small timeout, so $img is visible and therefore $img.width is available
setTimeout(function () {
adjustSize();
$('#pv-img-bar-percent').text('' + (100 * $img.width() / width).toFixed(0) + '%');
@ -199,8 +197,8 @@ modulejs.define('ext/preview-img', ['_', '$', 'core/settings', 'core/resource',
onFullscreen();
}
event.preventDefault();
event.stopImmediatePropagation();
return false;
},
initEntry = function (entry) {
@ -227,10 +225,7 @@ modulejs.define('ext/preview-img', ['_', '$', 'core/settings', 'core/resource',
return;
}
_.each(entry.content, function (e) {
initEntry(e);
});
_.each(entry.content, initEntry);
$(template).appendTo('body');
$('#pv-img-bar-prev, #pv-img-prev').on('click', onPrevious);
@ -264,11 +259,6 @@ modulejs.define('ext/preview-img', ['_', '$', 'core/settings', 'core/resource',
$('#pv-img-overlay')
.on('keydown', onKeydown)
.on('click mousedown mousemove keydown keypress', function (event) {
event.stopImmediatePropagation();
return false;
})
.on('mousemove', function (event) {
if (isFullscreen) {
@ -280,12 +270,13 @@ modulejs.define('ext/preview-img', ['_', '$', 'core/settings', 'core/resource',
$('#pv-img-bottombar').fadeOut(400);
}
}
})
.on('click mousedown mousemove keydown keypress', function (event) {
event.stopImmediatePropagation();
});
event.sub('entry.created', function (entry) {
initEntry(entry);
});
event.sub('entry.created', initEntry);
$(window).on('resize load', adjustSize);
};

View file

@ -1,7 +1,7 @@
modulejs.define('ext/preview-txt', ['_', '$', 'core/settings', 'core/resource', 'core/store', 'core/event', 'core/entry'], function (_, $, allsettings, resource, store, event, entry) {
var defaults = {
var settings = _.extend({
enabled: false,
types: {
authors: 'plain',
@ -26,9 +26,7 @@ modulejs.define('ext/preview-txt', ['_', '$', 'core/settings', 'core/resource',
js: 'js',
xml: 'xml'
}
},
settings = _.extend({}, defaults, allsettings['preview-txt']),
}, allsettings['preview-txt']),
template = '<div id="pv-txt-overlay" class="noSelection">' +
'<div id="pv-txt-close"/>' +
@ -206,8 +204,8 @@ modulejs.define('ext/preview-txt', ['_', '$', 'core/settings', 'core/resource',
onNext();
}
event.preventDefault();
event.stopImmediatePropagation();
return false;
},
initEntry = function (entry) {
@ -234,10 +232,7 @@ modulejs.define('ext/preview-txt', ['_', '$', 'core/settings', 'core/resource',
return;
}
_.each(entry.content, function (e) {
initEntry(e);
});
_.each(entry.content, initEntry);
$(template).appendTo('body');
$('#pv-txt-bar-prev').on('click', onPrevious);
@ -258,13 +253,9 @@ modulejs.define('ext/preview-txt', ['_', '$', 'core/settings', 'core/resource',
.on('click mousedown mousemove keydown keypress', function (event) {
event.stopImmediatePropagation();
return false;
});
event.sub('entry.created', function (entry) {
initEntry(entry);
});
event.sub('entry.created', initEntry);
$(window).on('resize load', adjustSize);
};

View file

@ -1,12 +1,10 @@
modulejs.define('ext/qrcode', ['_', '$', 'modernizr', 'core/settings', 'core/event'], function (_, $, modernizr, allsettings, event) {
var defaults = {
var settings = _.extend({
enabled: false,
size: 150
},
settings = _.extend({}, defaults, allsettings.qrcode),
}, allsettings.qrcode),
template = '<div id="qrcode"/>',

View file

@ -1,11 +1,9 @@
modulejs.define('ext/select', ['_', '$', 'core/settings', 'core/event'], function (_, $, allsettings, event) {
var defaults = {
var settings = _.extend({
enabled: false
},
settings = _.extend({}, defaults, allsettings.select),
}, allsettings.select),
x = 0, y = 0,
l = 0, t = 0, w = 0, h = 0,

View file

@ -1,12 +1,10 @@
modulejs.define('ext/sort', ['_', '$', 'core/settings', 'core/resource', 'core/event', 'core/store'], function (_, $, allsettings, resource, event, store) {
var defaults = {
var settings = _.extend({
enabled: false,
order: 'na'
},
settings = _.extend({}, defaults, allsettings.sort),
}, allsettings.sort),
storekey = 'h5ai.sortorder',

View file

@ -1,11 +1,9 @@
modulejs.define('ext/statusbar', ['_', '$', 'core/settings', 'core/format', 'core/event', 'core/entry'], function (_, $, allsettings, format, event, entry) {
var defaults = {
var settings = _.extend({
enabled: false
},
settings = _.extend({}, defaults, allsettings.statusbar),
}, allsettings.statusbar),
template = '<span class="statusbar">' +
'<span class="status default">' +

View file

@ -1,15 +1,13 @@
modulejs.define('ext/thumbnails', ['_', 'core/settings', 'core/entry', 'core/event', 'core/ajax'], function (_, allsettings, entry, event, ajax) {
var defaults = {
var settings = _.extend({
enabled: false,
img: ['bmp', 'gif', 'ico', 'image', 'jpg', 'png', 'tiff'],
mov: ['video'],
doc: ['pdf', 'ps'],
delay: 1000
},
settings = _.extend({}, defaults, allsettings.thumbnails),
}, allsettings.thumbnails),
checkEntry = function (entry) {

View file

@ -1,11 +1,9 @@
modulejs.define('ext/title', ['_', 'core/settings', 'core/entry'], function (_, allsettings, entry) {
var defaults = {
var settings = _.extend({
enabled: false
},
settings = _.extend({}, defaults, allsettings.title),
}, allsettings.title),
init = function (entry) {

View file

@ -1,12 +1,10 @@
modulejs.define('ext/tree', ['_', '$', 'core/settings', 'core/resource', 'core/event', 'core/entry', 'core/parser'], function (_, $, allsettings, resource, event, entry, parser) {
var defaults = {
var settings = _.extend({
enabled: false,
slide: true
},
settings = _.extend({}, defaults, allsettings.tree),
}, allsettings.tree),
template = '<div class="entry">' +
'<span class="indicator none">' +

View file

@ -1,13 +1,11 @@
modulejs.define('view/extended', ['_', '$', 'core/settings', 'core/resource', 'core/format', 'core/event', 'core/entry'], function (_, $, allsettings, resource, format, event, entry) {
var defaults = {
var settings = _.extend({
modes: ['details', 'icons'],
setParentFolderLabels: false,
binaryPrefix: false
},
settings = _.extend({}, defaults, allsettings.view),
}, allsettings.view),
template = '<li class="entry">' +
'<a>' +

View file

@ -1,15 +1,13 @@
modulejs.define('view/spacing', ['_', '$', 'core/settings', 'core/event'], function (_, $, allsettings, event) {
var defaults = {
var settings = _.extend({
maxWidth: 960,
top: 50,
right: "auto",
bottom: 50,
left: "auto"
},
settings = _.extend({}, defaults, allsettings.spacing),
}, allsettings.spacing),
adjustSpacing = function () {

View file

@ -1,12 +1,19 @@
{
"lang": "русский",
"details": "детали",
"icons": "иконки",
"details": "Детали",
"list": "Список",
"grid": "Сетка",
"icons": "Иконки",
"name": "Имя",
"lastModified": "Последние изменения",
"size": "Размер",
"parentDirectory": "Главная директория",
"empty": "пусто",
"folders": "папки",
"files": "файлы"
"empty": "Пусто",
"folders": "Папки",
"files": "Файлы",
"download": "Скачать",
"noMatch": "Нет совпадений",
"dateFormat": "YYYY-MM-DD HH:mm",
"filter": "Фильтр",
"delete": "Удалить"
}

View file

@ -3,13 +3,9 @@
| $h5ai_php = str_replace("\\", "/", dirname(__FILE__)) . "/inc/H5ai.php";
| if (!file_exists($h5ai_php)) {
| function find_h5ai($path, $h5ai) {
| if (file_exists($path . $h5ai)) {
| return $path . $h5ai;
| }
| if (file_exists($path . $h5ai)) { return $path . $h5ai; }
| $parent = str_replace("\\", "/", dirname($path));
| if ($parent !== $path) {
| return find_h5ai($parent, $h5ai);
| }
| if ($parent !== $path) { return find_h5ai($parent, $h5ai); }
| error_log("h5ai not found: " . __FILE__);
| }
| $h5ai_php = find_h5ai(str_replace("\\", "/", dirname(__FILE__)), "/_h5ai/php/inc/H5ai.php");