mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-05-25 04:24:45 -04:00
Clean code.
This commit is contained in:
parent
ba10f70b12
commit
8951732f3c
42 changed files with 2547 additions and 2572 deletions
16
mkrfile.js
16
mkrfile.js
|
@ -14,12 +14,10 @@ var build = path.join(root, 'build');
|
||||||
var mapSrc = $.map.p(src, build).s('.less', '.css').s('.jade', '');
|
var mapSrc = $.map.p(src, build).s('.less', '.css').s('.jade', '');
|
||||||
var mapRoot = $.map.p(root, path.join(build, '_h5ai'));
|
var mapRoot = $.map.p(root, path.join(build, '_h5ai'));
|
||||||
|
|
||||||
// bad hack
|
|
||||||
var getBuildSuffix = function (callback) {
|
|
||||||
|
|
||||||
var child_process = require('child_process');
|
function getBuildSuffix(callback) {
|
||||||
|
|
||||||
child_process.exec('git rev-list v' + pkg.version + '..HEAD', {cwd: root}, function (err, out) {
|
require('child_process').exec('git rev-list v' + pkg.version + '..HEAD', {cwd: root}, function (err, out) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var lines = out.trim().split(/\r?\n/);
|
var lines = out.trim().split(/\r?\n/);
|
||||||
|
@ -28,7 +26,7 @@ var getBuildSuffix = function (callback) {
|
||||||
callback('+X');
|
callback('+X');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
$.plugin('fquery-cssmin');
|
$.plugin('fquery-cssmin');
|
||||||
|
@ -96,10 +94,10 @@ module.exports = function (suite) {
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
suite.target('build', ['check-version'], 'build all updated files').task(function () {
|
suite.target('build', ['check-version', 'lint'], 'build all updated files').task(function () {
|
||||||
|
|
||||||
var env = {pkg: pkg};
|
|
||||||
var header = '/* ' + pkg.name + ' ' + pkg.version + ' - ' + pkg.homepage + ' */\n';
|
var header = '/* ' + pkg.name + ' ' + pkg.version + ' - ' + pkg.homepage + ' */\n';
|
||||||
|
var env = {pkg: pkg};
|
||||||
|
|
||||||
$(src + ': _h5ai/client/js/*.js')
|
$(src + ': _h5ai/client/js/*.js')
|
||||||
.newerThan(mapSrc, $(src + ': _h5ai/client/js/**'))
|
.newerThan(mapSrc, $(src + ': _h5ai/client/js/**'))
|
||||||
|
@ -136,10 +134,10 @@ module.exports = function (suite) {
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
suite.target('build-uncompressed', ['check-version'], 'build all updated files').task(function () {
|
suite.target('build-uncompressed', ['check-version', 'lint'], 'build all updated files').task(function () {
|
||||||
|
|
||||||
var env = {pkg: pkg};
|
|
||||||
var header = '/* ' + pkg.name + ' ' + pkg.version + ' - ' + pkg.homepage + ' */\n';
|
var header = '/* ' + pkg.name + ' ' + pkg.version + ' - ' + pkg.homepage + ' */\n';
|
||||||
|
var env = {pkg: pkg};
|
||||||
|
|
||||||
$(src + ': _h5ai/client/js/*.js')
|
$(src + ': _h5ai/client/js/*.js')
|
||||||
.newerThan(mapSrc, $(src + ': _h5ai/client/js/**'))
|
.newerThan(mapSrc, $(src + ': _h5ai/client/js/**'))
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
|
|
||||||
modulejs.define('core/event', ['_'], function (_) {
|
modulejs.define('core/event', ['_'], function (_) {
|
||||||
|
|
||||||
var slice = Array.prototype.slice,
|
var slice = Array.prototype.slice;
|
||||||
subscriptions = {},
|
var subscriptions = {};
|
||||||
|
|
||||||
sub = function (topic, callback) {
|
|
||||||
|
function sub(topic, callback) {
|
||||||
|
|
||||||
if (_.isString(topic) && _.isFunction(callback)) {
|
if (_.isString(topic) && _.isFunction(callback)) {
|
||||||
|
|
||||||
|
@ -13,17 +13,17 @@ modulejs.define('core/event', ['_'], function (_) {
|
||||||
}
|
}
|
||||||
subscriptions[topic].push(callback);
|
subscriptions[topic].push(callback);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
unsub = function (topic, callback) {
|
function unsub(topic, callback) {
|
||||||
|
|
||||||
if (_.isString(topic) && _.isFunction(callback) && subscriptions[topic]) {
|
if (_.isString(topic) && _.isFunction(callback) && subscriptions[topic]) {
|
||||||
|
|
||||||
subscriptions[topic] = _.without(subscriptions[topic], callback);
|
subscriptions[topic] = _.without(subscriptions[topic], callback);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
pub = function (topic, data) {
|
function pub(topic, data) {
|
||||||
|
|
||||||
var args = slice.call(arguments, 1);
|
var args = slice.call(arguments, 1);
|
||||||
|
|
||||||
|
@ -35,7 +35,8 @@ modulejs.define('core/event', ['_'], function (_) {
|
||||||
callback.apply(topic, args);
|
callback.apply(topic, args);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
sub: sub,
|
sub: sub,
|
||||||
|
|
|
@ -1,25 +1,25 @@
|
||||||
|
|
||||||
modulejs.define('core/format', ['_', 'moment'], function (_, moment) {
|
modulejs.define('core/format', ['_', 'moment'], function (_, moment) {
|
||||||
|
|
||||||
var decimalMetric = {
|
var decimalMetric = {
|
||||||
t: 1000.0,
|
t: 1000.0,
|
||||||
k: 1000.0,
|
k: 1000.0,
|
||||||
u: ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
|
u: ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
|
||||||
},
|
};
|
||||||
binaryMetric = {
|
var binaryMetric = {
|
||||||
t: 1024.0,
|
t: 1024.0,
|
||||||
k: 1024.0,
|
k: 1024.0,
|
||||||
u: ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB']
|
u: ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB']
|
||||||
},
|
};
|
||||||
defaultMetric = decimalMetric,
|
var defaultMetric = decimalMetric;
|
||||||
defaultDateFormat = 'YYYY-MM-DD HH:mm',
|
var defaultDateFormat = 'YYYY-MM-DD HH:mm';
|
||||||
|
|
||||||
setDefaultMetric = function (useBinaryMetric) {
|
|
||||||
|
function setDefaultMetric(useBinaryMetric) {
|
||||||
|
|
||||||
defaultMetric = useBinaryMetric ? binaryMetric : decimalMetric;
|
defaultMetric = useBinaryMetric ? binaryMetric : decimalMetric;
|
||||||
},
|
}
|
||||||
|
|
||||||
formatSize = function (size, metric) {
|
function formatSize(size, metric) {
|
||||||
|
|
||||||
metric = metric || defaultMetric;
|
metric = metric || defaultMetric;
|
||||||
|
|
||||||
|
@ -27,25 +27,26 @@ modulejs.define('core/format', ['_', 'moment'], function (_, moment) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
var i = 0,
|
var i = 0;
|
||||||
maxI = metric.u.length - 1;
|
var maxI = metric.u.length - 1;
|
||||||
|
|
||||||
while (size >= metric.t && i < maxI) {
|
while (size >= metric.t && i < maxI) {
|
||||||
size /= metric.k;
|
size /= metric.k;
|
||||||
i += 1;
|
i += 1;
|
||||||
}
|
}
|
||||||
return (i <= 1 ? Math.round(size) : size.toFixed(1)).toString() + ' ' + metric.u[i];
|
return (i <= 1 ? Math.round(size) : size.toFixed(1)).toString() + ' ' + metric.u[i];
|
||||||
},
|
}
|
||||||
|
|
||||||
setDefaultDateFormat = function (dateFormat) {
|
function setDefaultDateFormat(dateFormat) {
|
||||||
|
|
||||||
defaultDateFormat = dateFormat;
|
defaultDateFormat = dateFormat;
|
||||||
},
|
}
|
||||||
|
|
||||||
formatDate = function (millis) {
|
function formatDate(millis) {
|
||||||
|
|
||||||
return _.isNumber(millis) && millis ? moment(millis).format(defaultDateFormat) : '';
|
return _.isNumber(millis) && millis ? moment(millis).format(defaultDateFormat) : '';
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
setDefaultMetric: setDefaultMetric,
|
setDefaultMetric: setDefaultMetric,
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
modulejs.define('core/langs', ['config', '_'], function (config, _) {
|
modulejs.define('core/langs', ['config', '_'], function (config, _) {
|
||||||
|
|
||||||
return _.extend({}, config.langs);
|
return _.extend({}, config.langs);
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
|
|
||||||
modulejs.define('core/location', ['_', 'modernizr', 'core/settings', 'core/event', 'core/notify'], function (_, modernizr, allsettings, event, notify) {
|
modulejs.define('core/location', ['_', 'modernizr', 'core/settings', 'core/event', 'core/notify'], function (_, modernizr, allsettings, event, notify) {
|
||||||
|
|
||||||
var settings = _.extend({
|
var settings = _.extend({
|
||||||
smartBrowsing: true,
|
smartBrowsing: true,
|
||||||
unmanagedInNewWindow: true
|
unmanagedInNewWindow: true
|
||||||
}, allsettings.view),
|
}, allsettings.view);
|
||||||
|
var doc = document;
|
||||||
|
var history = settings.smartBrowsing && modernizr.history ? window.history : null;
|
||||||
|
var reUriToPathname = /^.*:\/\/[^\/]*|[^\/]*$/g;
|
||||||
|
var absHref = null;
|
||||||
|
|
||||||
doc = document,
|
|
||||||
|
|
||||||
history = settings.smartBrowsing && modernizr.history ? window.history : null,
|
function forceEncoding(href) {
|
||||||
|
|
||||||
forceEncoding = function (href) {
|
|
||||||
|
|
||||||
return href
|
return href
|
||||||
.replace(/\/+/g, '/')
|
.replace(/\/+/g, '/')
|
||||||
|
@ -34,27 +34,26 @@ modulejs.define('core/location', ['_', 'modernizr', 'core/settings', 'core/event
|
||||||
.replace(/@/g, '%40')
|
.replace(/@/g, '%40')
|
||||||
.replace(/\[/g, '%5B')
|
.replace(/\[/g, '%5B')
|
||||||
.replace(/\]/g, '%5D');
|
.replace(/\]/g, '%5D');
|
||||||
},
|
}
|
||||||
|
|
||||||
reUriToPathname = /^.*:\/\/[^\/]*|[^\/]*$/g,
|
function uriToPathname(uri) {
|
||||||
uriToPathname = function (uri) {
|
|
||||||
|
|
||||||
return uri.replace(reUriToPathname, '');
|
return uri.replace(reUriToPathname, '');
|
||||||
},
|
}
|
||||||
|
|
||||||
hrefsAreDecoded = (function () {
|
var hrefsAreDecoded = (function () {
|
||||||
|
|
||||||
var testpathname = '/a b',
|
var testpathname = '/a b';
|
||||||
a = doc.createElement('a');
|
var a = doc.createElement('a');
|
||||||
|
|
||||||
a.href = testpathname;
|
a.href = testpathname;
|
||||||
return uriToPathname(a.href) === testpathname;
|
return uriToPathname(a.href) === testpathname;
|
||||||
}()),
|
}());
|
||||||
|
|
||||||
encodedHref = function (href) {
|
function encodedHref(href) {
|
||||||
|
|
||||||
var a = doc.createElement('a'),
|
var a = doc.createElement('a');
|
||||||
location;
|
var location;
|
||||||
|
|
||||||
a.href = href;
|
a.href = href;
|
||||||
location = uriToPathname(a.href);
|
location = uriToPathname(a.href);
|
||||||
|
@ -64,32 +63,29 @@ modulejs.define('core/location', ['_', 'modernizr', 'core/settings', 'core/event
|
||||||
}
|
}
|
||||||
|
|
||||||
return forceEncoding(location);
|
return forceEncoding(location);
|
||||||
};
|
}
|
||||||
|
|
||||||
|
function getDomain() {
|
||||||
var absHref = null,
|
|
||||||
|
|
||||||
getDomain = function () {
|
|
||||||
|
|
||||||
return doc.domain;
|
return doc.domain;
|
||||||
},
|
}
|
||||||
|
|
||||||
getAbsHref = function () {
|
function getAbsHref() {
|
||||||
|
|
||||||
return absHref;
|
return absHref;
|
||||||
},
|
}
|
||||||
|
|
||||||
getItem = function () {
|
function getItem() {
|
||||||
|
|
||||||
return modulejs.require('model/item').get(absHref);
|
return modulejs.require('model/item').get(absHref);
|
||||||
},
|
}
|
||||||
|
|
||||||
load = function (callback) {
|
function load(callback) {
|
||||||
|
|
||||||
modulejs.require('core/server').request({action: 'get', items: true, itemsHref: absHref, itemsWhat: 1}, function (json) {
|
modulejs.require('core/server').request({action: 'get', items: true, itemsHref: absHref, itemsWhat: 1}, function (json) {
|
||||||
|
|
||||||
var Item = modulejs.require('model/item'),
|
var Item = modulejs.require('model/item');
|
||||||
item = Item.get(absHref);
|
var item = Item.get(absHref);
|
||||||
|
|
||||||
if (json) {
|
if (json) {
|
||||||
|
|
||||||
|
@ -112,9 +108,9 @@ modulejs.define('core/location', ['_', 'modernizr', 'core/settings', 'core/event
|
||||||
callback(item);
|
callback(item);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
|
|
||||||
setLocation = function (newAbsHref, keepBrowserUrl) {
|
function setLocation(newAbsHref, keepBrowserUrl) {
|
||||||
|
|
||||||
event.pub('location.beforeChange');
|
event.pub('location.beforeChange');
|
||||||
|
|
||||||
|
@ -144,26 +140,26 @@ modulejs.define('core/location', ['_', 'modernizr', 'core/settings', 'core/event
|
||||||
event.pub('location.changed', item);
|
event.pub('location.changed', item);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
refresh = function () {
|
function refresh() {
|
||||||
|
|
||||||
var item = getItem(),
|
var item = getItem();
|
||||||
oldItems = _.values(item.content);
|
var oldItems = _.values(item.content);
|
||||||
|
|
||||||
event.pub('location.beforeRefresh');
|
event.pub('location.beforeRefresh');
|
||||||
|
|
||||||
load(function () {
|
load(function () {
|
||||||
|
|
||||||
var newItems = _.values(item.content),
|
var newItems = _.values(item.content);
|
||||||
added = _.difference(newItems, oldItems),
|
var added = _.difference(newItems, oldItems);
|
||||||
removed = _.difference(oldItems, newItems);
|
var removed = _.difference(oldItems, newItems);
|
||||||
|
|
||||||
event.pub('location.refreshed', item, added, removed);
|
event.pub('location.refreshed', item, added, removed);
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
|
|
||||||
setLink = function ($el, item) {
|
function setLink($el, item) {
|
||||||
|
|
||||||
$el.attr('href', item.absHref);
|
$el.attr('href', item.absHref);
|
||||||
|
|
||||||
|
@ -178,7 +174,7 @@ modulejs.define('core/location', ['_', 'modernizr', 'core/settings', 'core/event
|
||||||
if (settings.unmanagedInNewWindow && !item.isManaged) {
|
if (settings.unmanagedInNewWindow && !item.isManaged) {
|
||||||
$el.attr('target', '_blank');
|
$el.attr('target', '_blank');
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
if (history) {
|
if (history) {
|
||||||
|
@ -190,7 +186,6 @@ modulejs.define('core/location', ['_', 'modernizr', 'core/settings', 'core/event
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
event.sub('ready', function () {
|
event.sub('ready', function () {
|
||||||
|
|
||||||
setLocation(document.location.href, true);
|
setLocation(document.location.href, true);
|
||||||
|
|
|
@ -1,23 +1,17 @@
|
||||||
|
|
||||||
modulejs.define('core/notify', ['$'], function ($) {
|
modulejs.define('core/notify', ['$'], function ($) {
|
||||||
|
|
||||||
var template = '<div id="notify"/>',
|
var template = '<div id="notify"/>';
|
||||||
|
|
||||||
set = function (content) {
|
function set(content) {
|
||||||
|
|
||||||
if (content) {
|
if (content) {
|
||||||
$('#notify').stop(true, true).html(content).fadeIn(400);
|
$('#notify').stop(true, true).html(content).fadeIn(400);
|
||||||
} else {
|
} else {
|
||||||
$('#notify').stop(true, true).fadeOut(400);
|
$('#notify').stop(true, true).fadeOut(400);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
init = function () {
|
|
||||||
|
|
||||||
$(template).hide().appendTo('body');
|
$(template).hide().appendTo('body');
|
||||||
};
|
|
||||||
|
|
||||||
init();
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
set: set
|
set: set
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
|
|
||||||
modulejs.define('core/resource', ['_', '$', 'config', 'core/settings'], function (_, $, config, settings) {
|
modulejs.define('core/resource', ['_', '$', 'config', 'core/settings'], function (_, $, config, settings) {
|
||||||
|
|
||||||
var win = window,
|
var win = window;
|
||||||
appHref = settings.appHref,
|
var appHref = settings.appHref;
|
||||||
imagesHref = appHref + 'client/images/',
|
var imagesHref = appHref + 'client/images/';
|
||||||
fallbackHref = appHref + 'client/images/fallback/',
|
var fallbackHref = appHref + 'client/images/fallback/';
|
||||||
themesHref = appHref + 'client/themes/',
|
var themesHref = appHref + 'client/themes/';
|
||||||
scriptsHref = appHref + 'client/js/',
|
var scriptsHref = appHref + 'client/js/';
|
||||||
fallbacks = ['file', 'folder', 'folder-page', 'folder-parent', 'ar', 'aud', 'bin', 'img', 'txt', 'vid'],
|
var fallbacks = ['file', 'folder', 'folder-page', 'folder-parent', 'ar', 'aud', 'bin', 'img', 'txt', 'vid'];
|
||||||
|
|
||||||
image = function (id) {
|
|
||||||
|
function image(id) {
|
||||||
|
|
||||||
return imagesHref + id + '.svg';
|
return imagesHref + id + '.svg';
|
||||||
},
|
}
|
||||||
|
|
||||||
icon = function (id) {
|
function icon(id) {
|
||||||
|
|
||||||
var baseId = id.split('-')[0],
|
var baseId = id.split('-')[0],
|
||||||
href = config.theme[id] || config.theme[baseId];
|
href = config.theme[id] || config.theme[baseId];
|
||||||
|
@ -32,7 +32,7 @@ modulejs.define('core/resource', ['_', '$', 'config', 'core/settings'], function
|
||||||
}
|
}
|
||||||
|
|
||||||
return fallbackHref + 'file.svg';
|
return fallbackHref + 'file.svg';
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
modulejs.define('core/server', ['$', '_', 'config', 'core/location'], function ($, _, config, location) {
|
modulejs.define('core/server', ['$', '_', 'config', 'core/location'], function ($, _, config, location) {
|
||||||
|
|
||||||
var server = {
|
var server = {
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
modulejs.define('core/settings', ['config', '_'], function (config, _) {
|
modulejs.define('core/settings', ['config', '_'], function (config, _) {
|
||||||
|
|
||||||
return _.extend({}, config.options, {
|
return _.extend({}, config.options, {
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
|
|
||||||
modulejs.define('core/store', ['modernizr'], function (modernizr) {
|
modulejs.define('core/store', ['modernizr'], function (modernizr) {
|
||||||
|
|
||||||
var store = modernizr.localstorage ? window.localStorage : null,
|
var store = modernizr.localstorage ? window.localStorage : null;
|
||||||
|
var key = '_h5ai';
|
||||||
|
|
||||||
key = '_h5ai',
|
|
||||||
|
|
||||||
load = function () {
|
function load() {
|
||||||
|
|
||||||
if (store) {
|
if (store) {
|
||||||
try {
|
try {
|
||||||
|
@ -13,26 +12,27 @@ modulejs.define('core/store', ['modernizr'], function (modernizr) {
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
},
|
}
|
||||||
|
|
||||||
save = function (obj) {
|
function save(obj) {
|
||||||
|
|
||||||
if (store) {
|
if (store) {
|
||||||
store[key] = JSON.stringify(obj);
|
store[key] = JSON.stringify(obj);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
put = function (key, value) {
|
function put(key, value) {
|
||||||
|
|
||||||
var obj = load();
|
var obj = load();
|
||||||
obj[key] = value;
|
obj[key] = value;
|
||||||
return save(obj);
|
return save(obj);
|
||||||
},
|
}
|
||||||
|
|
||||||
get = function (key) {
|
function get(key) {
|
||||||
|
|
||||||
return load()[key];
|
return load()[key];
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
put: put,
|
put: put,
|
||||||
|
|
|
@ -1,32 +1,32 @@
|
||||||
|
|
||||||
modulejs.define('core/types', ['config', '_'], function (config, _) {
|
modulejs.define('core/types', ['config', '_'], function (config, _) {
|
||||||
|
|
||||||
var reEndsWithSlash = /\/$/,
|
var reEndsWithSlash = /\/$/;
|
||||||
regexps = {},
|
var regexps = {};
|
||||||
|
|
||||||
escapeRegExp = function (sequence) {
|
|
||||||
|
function escapeRegExp(sequence) {
|
||||||
|
|
||||||
return sequence.replace(/[\-\[\]\/\{\}\(\)\+\?\.\\\^\$]/g, "\\$&");
|
return sequence.replace(/[\-\[\]\/\{\}\(\)\+\?\.\\\^\$]/g, "\\$&");
|
||||||
// return sequence.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
|
// return sequence.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
|
||||||
},
|
}
|
||||||
|
|
||||||
parse = function (types) {
|
function parse(types) {
|
||||||
|
|
||||||
_.each(types, function (patterns, type) {
|
_.each(types, function (patterns, type) {
|
||||||
|
|
||||||
var pattern = '^(' + _.map(patterns, function (p) { return '(' + escapeRegExp(p).replace(/\*/g, '.*') + ')'; }).join('|') + ')$';
|
var pattern = '^(' + _.map(patterns, function (p) { return '(' + escapeRegExp(p).replace(/\*/g, '.*') + ')'; }).join('|') + ')$';
|
||||||
regexps[type] = new RegExp(pattern, 'i');
|
regexps[type] = new RegExp(pattern, 'i');
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
|
|
||||||
getType = function (sequence) {
|
function getType(sequence) {
|
||||||
|
|
||||||
if (reEndsWithSlash.test(sequence)) {
|
if (reEndsWithSlash.test(sequence)) {
|
||||||
return 'folder';
|
return 'folder';
|
||||||
}
|
}
|
||||||
|
|
||||||
var slashidx = sequence.lastIndexOf('/'),
|
var slashidx = sequence.lastIndexOf('/');
|
||||||
name = slashidx >= 0 ? sequence.substr(slashidx + 1) : sequence;
|
var name = slashidx >= 0 ? sequence.substr(slashidx + 1) : sequence;
|
||||||
|
|
||||||
for (var type in regexps) {
|
for (var type in regexps) {
|
||||||
if (regexps.hasOwnProperty(type)) {
|
if (regexps.hasOwnProperty(type)) {
|
||||||
|
@ -37,7 +37,8 @@ modulejs.define('core/types', ['config', '_'], function (config, _) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return 'file';
|
return 'file';
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
parse(_.extend({}, config.types));
|
parse(_.extend({}, config.types));
|
||||||
|
|
||||||
|
|
|
@ -1,30 +1,29 @@
|
||||||
|
|
||||||
modulejs.define('ext/autorefresh', ['_', '$', 'core/settings', 'core/event', 'core/location'], function (_, $, allsettings, event, location) {
|
modulejs.define('ext/autorefresh', ['_', '$', 'core/settings', 'core/event', 'core/location'], function (_, $, allsettings, event, location) {
|
||||||
|
|
||||||
var settings = _.extend({
|
var settings = _.extend({
|
||||||
enabled: false,
|
enabled: false,
|
||||||
interval: 5000
|
interval: 5000
|
||||||
}, allsettings.autorefresh),
|
}, allsettings.autorefresh);
|
||||||
|
var timeoutId = null;
|
||||||
|
|
||||||
timeoutId = null,
|
|
||||||
|
|
||||||
heartbeat = function () {
|
function heartbeat() {
|
||||||
|
|
||||||
location.refresh();
|
location.refresh();
|
||||||
},
|
}
|
||||||
|
|
||||||
before = function () {
|
function before() {
|
||||||
|
|
||||||
clearTimeout(timeoutId);
|
clearTimeout(timeoutId);
|
||||||
},
|
}
|
||||||
|
|
||||||
after = function () {
|
function after() {
|
||||||
|
|
||||||
clearTimeout(timeoutId);
|
clearTimeout(timeoutId);
|
||||||
timeoutId = setTimeout(heartbeat, settings.interval);
|
timeoutId = setTimeout(heartbeat, settings.interval);
|
||||||
},
|
}
|
||||||
|
|
||||||
init = function () {
|
function init() {
|
||||||
|
|
||||||
if (!settings.enabled) {
|
if (!settings.enabled) {
|
||||||
return;
|
return;
|
||||||
|
@ -36,7 +35,8 @@ modulejs.define('ext/autorefresh', ['_', '$', 'core/settings', 'core/event', 'co
|
||||||
event.sub('location.beforeRefresh', before);
|
event.sub('location.beforeRefresh', before);
|
||||||
event.sub('location.changed', after);
|
event.sub('location.changed', after);
|
||||||
event.sub('location.refreshed', after);
|
event.sub('location.refreshed', after);
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
init();
|
init();
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,28 +1,27 @@
|
||||||
|
|
||||||
modulejs.define('ext/crumb', ['_', '$', 'core/settings', 'core/resource', 'core/event', 'core/location'], function (_, $, allsettings, resource, event, location) {
|
modulejs.define('ext/crumb', ['_', '$', 'core/settings', 'core/resource', 'core/event', 'core/location'], function (_, $, allsettings, resource, event, location) {
|
||||||
|
|
||||||
var settings = _.extend({
|
var settings = _.extend({
|
||||||
enabled: false
|
enabled: false
|
||||||
}, allsettings.crumb),
|
}, allsettings.crumb);
|
||||||
|
var template =
|
||||||
template =
|
|
||||||
'<li class="crumb">' +
|
'<li class="crumb">' +
|
||||||
'<a>' +
|
'<a>' +
|
||||||
'<img src="' + resource.image('crumb') + '" alt=">"/>' +
|
'<img src="' + resource.image('crumb') + '" alt=">"/>' +
|
||||||
'<span/>' +
|
'<span/>' +
|
||||||
'</a>' +
|
'</a>' +
|
||||||
'</li>',
|
'</li>';
|
||||||
pageHintTemplate = '<img class="hint" src="' + resource.image('page') + '" alt="has index page"/>',
|
var pageHintTemplate = '<img class="hint" src="' + resource.image('page') + '" alt="has index page"/>';
|
||||||
statusHintTemplate = '<span class="hint"/>',
|
var statusHintTemplate = '<span class="hint"/>';
|
||||||
|
|
||||||
update = function (item, force) {
|
|
||||||
|
function update(item, force) {
|
||||||
|
|
||||||
if (!force && item.$crumb) {
|
if (!force && item.$crumb) {
|
||||||
return item.$crumb;
|
return item.$crumb;
|
||||||
}
|
}
|
||||||
|
|
||||||
var $html = $(template),
|
var $html = $(template);
|
||||||
$a = $html.find('a');
|
var $a = $html.find('a');
|
||||||
|
|
||||||
$html
|
$html
|
||||||
.addClass(item.isFolder() ? 'folder' : 'file')
|
.addClass(item.isFolder() ? 'folder' : 'file')
|
||||||
|
@ -55,13 +54,13 @@ modulejs.define('ext/crumb', ['_', '$', 'core/settings', 'core/resource', 'core/
|
||||||
item.$crumb = $html;
|
item.$crumb = $html;
|
||||||
|
|
||||||
return $html;
|
return $html;
|
||||||
},
|
}
|
||||||
|
|
||||||
onLocationChanged = function (item) {
|
function onLocationChanged(item) {
|
||||||
|
|
||||||
var crumb = item.getCrumb(),
|
var crumb = item.getCrumb();
|
||||||
$ul = $('#navbar'),
|
var $ul = $('#navbar');
|
||||||
found = false;
|
var found = false;
|
||||||
|
|
||||||
$ul.find('.crumb').each(function () {
|
$ul.find('.crumb').each(function () {
|
||||||
|
|
||||||
|
@ -81,16 +80,17 @@ modulejs.define('ext/crumb', ['_', '$', 'core/settings', 'core/resource', 'core/
|
||||||
$ul.append(update(e, true));
|
$ul.append(update(e, true));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
init = function () {
|
function init() {
|
||||||
|
|
||||||
if (!settings.enabled) {
|
if (!settings.enabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
event.sub('location.changed', onLocationChanged);
|
event.sub('location.changed', onLocationChanged);
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
init();
|
init();
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
|
|
||||||
modulejs.define('ext/custom', ['_', '$', 'marked', 'core/settings', 'core/server', 'core/event', 'core/resource'], function (_, $, marked, allsettings, server, event, resource) {
|
modulejs.define('ext/custom', ['_', '$', 'marked', 'core/settings', 'core/server', 'core/event', 'core/resource'], function (_, $, marked, allsettings, server, event, resource) {
|
||||||
|
|
||||||
var settings = _.extend({
|
var settings = _.extend({
|
||||||
enabled: false
|
enabled: false
|
||||||
}, allsettings.custom),
|
}, allsettings.custom);
|
||||||
|
var $header, $footer;
|
||||||
|
var duration = 200;
|
||||||
|
|
||||||
$header, $footer,
|
|
||||||
duration = 200,
|
|
||||||
|
|
||||||
onLocationChanged = function (item) {
|
function onLocationChanged(item) {
|
||||||
|
|
||||||
server.request({action: 'get', custom: true, customHref: item.absHref}, function (response) {
|
server.request({action: 'get', custom: true, customHref: item.absHref}, function (response) {
|
||||||
|
|
||||||
|
@ -43,9 +42,9 @@ modulejs.define('ext/custom', ['_', '$', 'marked', 'core/settings', 'core/server
|
||||||
$footer.stop().slideUp(duration);
|
$footer.stop().slideUp(duration);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
|
|
||||||
init = function () {
|
function init() {
|
||||||
|
|
||||||
if (!settings.enabled) {
|
if (!settings.enabled) {
|
||||||
return;
|
return;
|
||||||
|
@ -55,7 +54,8 @@ modulejs.define('ext/custom', ['_', '$', 'marked', 'core/settings', 'core/server
|
||||||
$footer = $('<div id="content-footer"/>').hide().appendTo('#content');
|
$footer = $('<div id="content-footer"/>').hide().appendTo('#content');
|
||||||
|
|
||||||
event.sub('location.changed', onLocationChanged);
|
event.sub('location.changed', onLocationChanged);
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
init();
|
init();
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
modulejs.define('ext/download', ['_', '$', 'core/settings', 'core/resource', 'core/event', 'core/location', 'core/server'], function (_, $, allsettings, resource, event, location, server) {
|
modulejs.define('ext/download', ['_', '$', 'core/settings', 'core/resource', 'core/event', 'core/location', 'core/server'], function (_, $, allsettings, resource, event, location, server) {
|
||||||
|
|
||||||
var settings = _.extend({
|
var settings = _.extend({
|
||||||
|
@ -6,19 +5,18 @@ modulejs.define('ext/download', ['_', '$', 'core/settings', 'core/resource', 'co
|
||||||
type: 'php-tar',
|
type: 'php-tar',
|
||||||
packageName: 'package',
|
packageName: 'package',
|
||||||
alwaysVisible: false
|
alwaysVisible: false
|
||||||
}, allsettings.download),
|
}, allsettings.download);
|
||||||
|
var downloadBtnTemplate =
|
||||||
downloadBtnTemplate =
|
|
||||||
'<li id="download">' +
|
'<li id="download">' +
|
||||||
'<a href="#">' +
|
'<a href="#">' +
|
||||||
'<img src="' + resource.image('download') + '" alt="download"/>' +
|
'<img src="' + resource.image('download') + '" alt="download"/>' +
|
||||||
'<span class="l10n-download"/>' +
|
'<span class="l10n-download"/>' +
|
||||||
'</a>' +
|
'</a>' +
|
||||||
'</li>',
|
'</li>';
|
||||||
|
var selectedItems = [];
|
||||||
|
|
||||||
selectedItems = [],
|
|
||||||
|
|
||||||
onSelection = function (items) {
|
function onSelection(items) {
|
||||||
|
|
||||||
var $download = $('#download');
|
var $download = $('#download');
|
||||||
|
|
||||||
|
@ -28,13 +26,13 @@ modulejs.define('ext/download', ['_', '$', 'core/settings', 'core/resource', 'co
|
||||||
} else if (!settings.alwaysVisible) {
|
} else if (!settings.alwaysVisible) {
|
||||||
$download.hide();
|
$download.hide();
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
onClick = function (event) {
|
function onClick(event) {
|
||||||
|
|
||||||
var type = settings.type,
|
var type = settings.type;
|
||||||
extension = (type === 'shell-zip') ? 'zip' : 'tar',
|
var extension = (type === 'shell-zip') ? 'zip' : 'tar';
|
||||||
query = {
|
var query = {
|
||||||
action: 'download',
|
action: 'download',
|
||||||
as: (settings.packageName || location.getItem().label) + '.' + extension,
|
as: (settings.packageName || location.getItem().label) + '.' + extension,
|
||||||
type: type,
|
type: type,
|
||||||
|
@ -42,9 +40,9 @@ modulejs.define('ext/download', ['_', '$', 'core/settings', 'core/resource', 'co
|
||||||
};
|
};
|
||||||
|
|
||||||
server.formRequest(query);
|
server.formRequest(query);
|
||||||
},
|
}
|
||||||
|
|
||||||
init = function () {
|
function init() {
|
||||||
|
|
||||||
if (!settings.enabled) {
|
if (!settings.enabled) {
|
||||||
return;
|
return;
|
||||||
|
@ -59,7 +57,8 @@ modulejs.define('ext/download', ['_', '$', 'core/settings', 'core/resource', 'co
|
||||||
}
|
}
|
||||||
|
|
||||||
event.sub('selection', onSelection);
|
event.sub('selection', onSelection);
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
init();
|
init();
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,26 +1,24 @@
|
||||||
|
|
||||||
modulejs.define('ext/filter', ['_', '$', 'core/settings', 'core/resource', 'core/event'], function (_, $, allsettings, resource, event) {
|
modulejs.define('ext/filter', ['_', '$', 'core/settings', 'core/resource', 'core/event'], function (_, $, allsettings, resource, event) {
|
||||||
|
|
||||||
var settings = _.extend({
|
var settings = _.extend({
|
||||||
enabled: false
|
enabled: false
|
||||||
}, allsettings.filter),
|
}, allsettings.filter);
|
||||||
|
var template =
|
||||||
template =
|
|
||||||
'<li id="filter">' +
|
'<li id="filter">' +
|
||||||
'<span class="element">' +
|
'<span class="element">' +
|
||||||
'<img src="' + resource.image('filter') + '" alt="filter"/>' +
|
'<img src="' + resource.image('filter') + '" alt="filter"/>' +
|
||||||
'<input type="text" value="" placeholder="filter"/>' +
|
'<input type="text" value="" placeholder="filter"/>' +
|
||||||
'</span>' +
|
'</span>' +
|
||||||
'</li>',
|
'</li>';
|
||||||
noMatchTemplate = '<div class="no-match l10n-noMatch"/>',
|
var noMatchTemplate = '<div class="no-match l10n-noMatch"/>';
|
||||||
|
var $filter, $input, $noMatch;
|
||||||
|
|
||||||
$filter, $input, $noMatch,
|
|
||||||
|
|
||||||
filter = function (re) {
|
function filter(re) {
|
||||||
|
|
||||||
var match = [],
|
var match = [];
|
||||||
noMatch = [],
|
var noMatch = [];
|
||||||
duration = 200;
|
var duration = 200;
|
||||||
|
|
||||||
if (re) {
|
if (re) {
|
||||||
$('#items .item').not('.folder-parent').each(function () {
|
$('#items .item').not('.folder-parent').each(function () {
|
||||||
|
@ -44,14 +42,14 @@ modulejs.define('ext/filter', ['_', '$', 'core/settings', 'core/resource', 'core
|
||||||
}
|
}
|
||||||
$(match).fadeIn(duration);
|
$(match).fadeIn(duration);
|
||||||
$(noMatch).fadeOut(duration);
|
$(noMatch).fadeOut(duration);
|
||||||
},
|
}
|
||||||
|
|
||||||
escapeRegExp = function (sequence) {
|
function escapeRegExp(sequence) {
|
||||||
|
|
||||||
return sequence.replace(/[\-\[\]{}()*+?.,\\$\^|#\s]/g, '\\$&');
|
return sequence.replace(/[\-\[\]{}()*+?.,\\$\^|#\s]/g, '\\$&');
|
||||||
},
|
}
|
||||||
|
|
||||||
parseFilterSequence = function (sequence) {
|
function parseFilterSequence(sequence) {
|
||||||
|
|
||||||
if (sequence.substr(0, 3) === 're:') {
|
if (sequence.substr(0, 3) === 're:') {
|
||||||
return new RegExp(sequence.substr(3));
|
return new RegExp(sequence.substr(3));
|
||||||
|
@ -66,14 +64,14 @@ modulejs.define('ext/filter', ['_', '$', 'core/settings', 'core/resource', 'core
|
||||||
}).join('|');
|
}).join('|');
|
||||||
|
|
||||||
return new RegExp(sequence, 'i');
|
return new RegExp(sequence, 'i');
|
||||||
},
|
}
|
||||||
|
|
||||||
reset = function () {
|
function reset() {
|
||||||
|
|
||||||
$input.val('').blur();
|
$input.val('').blur();
|
||||||
},
|
}
|
||||||
|
|
||||||
update = function (focus) {
|
function update(focus) {
|
||||||
|
|
||||||
var val = $input.val();
|
var val = $input.val();
|
||||||
|
|
||||||
|
@ -88,11 +86,19 @@ modulejs.define('ext/filter', ['_', '$', 'core/settings', 'core/resource', 'core
|
||||||
filter();
|
filter();
|
||||||
$filter.removeClass('current');
|
$filter.removeClass('current');
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
updt = function () { update(true); },
|
|
||||||
updf = function () { update(false); },
|
|
||||||
|
|
||||||
init = function () {
|
function updt() {
|
||||||
|
|
||||||
|
update(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
function updf() {
|
||||||
|
|
||||||
|
update(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
function init() {
|
||||||
|
|
||||||
if (!settings.enabled) {
|
if (!settings.enabled) {
|
||||||
return;
|
return;
|
||||||
|
@ -115,7 +121,8 @@ modulejs.define('ext/filter', ['_', '$', 'core/settings', 'core/resource', 'core
|
||||||
.on('keypress', updt);
|
.on('keypress', updt);
|
||||||
|
|
||||||
event.sub('location.changed', reset);
|
event.sub('location.changed', reset);
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
init();
|
init();
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
|
|
||||||
modulejs.define('ext/google-analytics-ga', ['_', 'core/settings'], function (_, allsettings) {
|
modulejs.define('ext/google-analytics-ga', ['_', 'core/settings'], function (_, allsettings) {
|
||||||
|
|
||||||
var settings = _.extend({
|
var settings = _.extend({
|
||||||
enabled: false,
|
enabled: false,
|
||||||
gaq: []
|
gaq: []
|
||||||
}, allsettings['google-analytics-ga']),
|
}, allsettings['google-analytics-ga']);
|
||||||
|
|
||||||
init = function () {
|
|
||||||
|
function init() {
|
||||||
|
|
||||||
if (!settings.enabled) {
|
if (!settings.enabled) {
|
||||||
return;
|
return;
|
||||||
|
@ -14,15 +14,16 @@ modulejs.define('ext/google-analytics-ga', ['_', 'core/settings'], function (_,
|
||||||
|
|
||||||
window._gaq = settings.gaq;
|
window._gaq = settings.gaq;
|
||||||
|
|
||||||
var scriptLiteral = 'script',
|
var scriptLiteral = 'script';
|
||||||
doc = document,
|
var doc = document;
|
||||||
newScriptTag = doc.createElement(scriptLiteral),
|
var newScriptTag = doc.createElement(scriptLiteral);
|
||||||
firstScriptTag = doc.getElementsByTagName(scriptLiteral)[0];
|
var firstScriptTag = doc.getElementsByTagName(scriptLiteral)[0];
|
||||||
|
|
||||||
newScriptTag.async = true;
|
newScriptTag.async = true;
|
||||||
newScriptTag.src = ('https:' === location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
newScriptTag.src = ('https:' === location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||||
firstScriptTag.parentNode.insertBefore(newScriptTag, firstScriptTag);
|
firstScriptTag.parentNode.insertBefore(newScriptTag, firstScriptTag);
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
init();
|
init();
|
||||||
});
|
});
|
||||||
|
@ -33,14 +34,14 @@ modulejs.define('ext/google-analytics-ua', ['_', 'core/settings', 'core/event'],
|
||||||
var settings = _.extend({
|
var settings = _.extend({
|
||||||
enabled: false,
|
enabled: false,
|
||||||
id: 'UA-000000-0'
|
id: 'UA-000000-0'
|
||||||
}, allsettings['google-analytics-ua']),
|
}, allsettings['google-analytics-ua']);
|
||||||
|
var win = window;
|
||||||
|
var doc = document;
|
||||||
|
var scriptLiteral = 'script';
|
||||||
|
var id = 'h5ai-ga';
|
||||||
|
|
||||||
win = window,
|
|
||||||
doc = document,
|
|
||||||
scriptLiteral = 'script',
|
|
||||||
id = 'h5ai-ga',
|
|
||||||
|
|
||||||
init = function () {
|
function init() {
|
||||||
|
|
||||||
if (!settings.enabled) {
|
if (!settings.enabled) {
|
||||||
return;
|
return;
|
||||||
|
@ -71,7 +72,8 @@ modulejs.define('ext/google-analytics-ua', ['_', 'core/settings', 'core/event'],
|
||||||
title: _.pluck(item.getCrumb(), 'label').join(' > ')
|
title: _.pluck(item.getCrumb(), 'label').join(' > ')
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
init();
|
init();
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
|
|
||||||
modulejs.define('ext/l10n', ['_', '$', 'core/settings', 'core/langs', 'core/format', 'core/store', 'core/event', 'core/server'], function (_, $, allsettings, langs, format, store, event, server) {
|
modulejs.define('ext/l10n', ['_', '$', 'core/settings', 'core/langs', 'core/format', 'core/store', 'core/event', 'core/server'], function (_, $, allsettings, langs, format, store, event, server) {
|
||||||
|
|
||||||
var settings = _.extend({
|
var settings = _.extend({
|
||||||
enabled: false,
|
enabled: false,
|
||||||
lang: 'en',
|
lang: 'en',
|
||||||
useBrowserLang: true
|
useBrowserLang: true
|
||||||
}, allsettings.l10n),
|
}, allsettings.l10n);
|
||||||
|
var defaultTranslations = {
|
||||||
defaultTranslations = {
|
|
||||||
isoCode: 'en',
|
isoCode: 'en',
|
||||||
lang: 'english',
|
lang: 'english',
|
||||||
details: 'details',
|
details: 'details',
|
||||||
|
@ -26,19 +24,17 @@ modulejs.define('ext/l10n', ['_', '$', 'core/settings', 'core/langs', 'core/form
|
||||||
dateFormat: 'YYYY-MM-DD HH:mm',
|
dateFormat: 'YYYY-MM-DD HH:mm',
|
||||||
filter: 'filter',
|
filter: 'filter',
|
||||||
'delete': 'delete'
|
'delete': 'delete'
|
||||||
},
|
};
|
||||||
|
var blockTemplate = '<div class="block"><div class="select"><select id="langs"/></div></div>';
|
||||||
blockTemplate = '<div class="block"><div class="select"><select id="langs"/></div></div>',
|
var optionTemplate = '<option/>';
|
||||||
optionTemplate = '<option/>',
|
var storekey = 'ext/l10n';
|
||||||
|
var loaded = {
|
||||||
storekey = 'ext/l10n',
|
|
||||||
|
|
||||||
loaded = {
|
|
||||||
en: _.extend({}, defaultTranslations)
|
en: _.extend({}, defaultTranslations)
|
||||||
},
|
};
|
||||||
currentLang = loaded.en,
|
var currentLang = loaded.en;
|
||||||
|
|
||||||
update = function (lang) {
|
|
||||||
|
function update(lang) {
|
||||||
|
|
||||||
if (lang) {
|
if (lang) {
|
||||||
currentLang = lang;
|
currentLang = lang;
|
||||||
|
@ -62,9 +58,9 @@ modulejs.define('ext/l10n', ['_', '$', 'core/settings', 'core/langs', 'core/form
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#filter input').attr('placeholder', currentLang.filter);
|
$('#filter input').attr('placeholder', currentLang.filter);
|
||||||
},
|
}
|
||||||
|
|
||||||
loadLanguage = function (isoCode, callback) {
|
function loadLanguage(isoCode, callback) {
|
||||||
|
|
||||||
if (loaded[isoCode]) {
|
if (loaded[isoCode]) {
|
||||||
|
|
||||||
|
@ -78,9 +74,9 @@ modulejs.define('ext/l10n', ['_', '$', 'core/settings', 'core/langs', 'core/form
|
||||||
callback(loaded[isoCode]);
|
callback(loaded[isoCode]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
localize = function (langs, isoCode, useBrowserLang) {
|
function localize(langs, isoCode, useBrowserLang) {
|
||||||
|
|
||||||
var storedIsoCode = store.get(storekey);
|
var storedIsoCode = store.get(storekey);
|
||||||
|
|
||||||
|
@ -102,13 +98,13 @@ modulejs.define('ext/l10n', ['_', '$', 'core/settings', 'core/langs', 'core/form
|
||||||
}
|
}
|
||||||
|
|
||||||
loadLanguage(isoCode, update);
|
loadLanguage(isoCode, update);
|
||||||
},
|
}
|
||||||
|
|
||||||
initLangSelector = function (langs) {
|
function initLangSelector(langs) {
|
||||||
|
|
||||||
var isoCodes = _.keys(langs).sort(),
|
var isoCodes = _.keys(langs).sort();
|
||||||
$block = $(blockTemplate),
|
var $block = $(blockTemplate);
|
||||||
$select = $block.find('select')
|
var $select = $block.find('select')
|
||||||
.on('change', function (event) {
|
.on('change', function (event) {
|
||||||
var isoCode = event.target.value;
|
var isoCode = event.target.value;
|
||||||
store.put(storekey, isoCode);
|
store.put(storekey, isoCode);
|
||||||
|
@ -124,9 +120,9 @@ modulejs.define('ext/l10n', ['_', '$', 'core/settings', 'core/langs', 'core/form
|
||||||
});
|
});
|
||||||
|
|
||||||
$block.appendTo('#settings');
|
$block.appendTo('#settings');
|
||||||
},
|
}
|
||||||
|
|
||||||
init = function () {
|
function init() {
|
||||||
|
|
||||||
if (settings.enabled) {
|
if (settings.enabled) {
|
||||||
initLangSelector(langs);
|
initLangSelector(langs);
|
||||||
|
@ -136,7 +132,8 @@ modulejs.define('ext/l10n', ['_', '$', 'core/settings', 'core/langs', 'core/form
|
||||||
|
|
||||||
localize(langs, settings.lang, settings.useBrowserLang);
|
localize(langs, settings.lang, settings.useBrowserLang);
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
init();
|
init();
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,40 +1,39 @@
|
||||||
|
|
||||||
modulejs.define('ext/link-hover-states', ['_', '$', 'core/settings', 'core/event'], function (_, $, allsettings, event) {
|
modulejs.define('ext/link-hover-states', ['_', '$', 'core/settings', 'core/event'], function (_, $, allsettings, event) {
|
||||||
|
|
||||||
var settings = _.extend({
|
var settings = _.extend({
|
||||||
enabled: false
|
enabled: false
|
||||||
}, allsettings['link-hover-states']),
|
}, allsettings['link-hover-states']);
|
||||||
|
var selector = "a[href^='/']";
|
||||||
|
|
||||||
selector = "a[href^='/']",
|
|
||||||
|
|
||||||
selectLinks = function (href) {
|
function selectLinks(href) {
|
||||||
|
|
||||||
return $(_.filter($(selector), function (el) {
|
return $(_.filter($(selector), function (el) {
|
||||||
|
|
||||||
return $(el).attr('href') === href;
|
return $(el).attr('href') === href;
|
||||||
}));
|
}));
|
||||||
},
|
}
|
||||||
|
|
||||||
onMouseEnter = function () {
|
function onMouseEnter() {
|
||||||
|
|
||||||
var href = $(this).attr('href');
|
var href = $(this).attr('href');
|
||||||
|
|
||||||
selectLinks(href).addClass('hover');
|
selectLinks(href).addClass('hover');
|
||||||
},
|
}
|
||||||
|
|
||||||
onMouseLeave = function () {
|
function onMouseLeave() {
|
||||||
|
|
||||||
var href = $(this).attr('href');
|
var href = $(this).attr('href');
|
||||||
|
|
||||||
selectLinks(href).removeClass('hover');
|
selectLinks(href).removeClass('hover');
|
||||||
},
|
}
|
||||||
|
|
||||||
onLocationChanged = function () {
|
function onLocationChanged() {
|
||||||
|
|
||||||
$('.hover').removeClass('hover');
|
$('.hover').removeClass('hover');
|
||||||
},
|
}
|
||||||
|
|
||||||
init = function () {
|
function init() {
|
||||||
|
|
||||||
if (!settings.enabled) {
|
if (!settings.enabled) {
|
||||||
return;
|
return;
|
||||||
|
@ -45,7 +44,8 @@ modulejs.define('ext/link-hover-states', ['_', '$', 'core/settings', 'core/event
|
||||||
.on('mouseleave', selector, onMouseLeave);
|
.on('mouseleave', selector, onMouseLeave);
|
||||||
|
|
||||||
event.sub('location.changed', onLocationChanged);
|
event.sub('location.changed', onLocationChanged);
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
init();
|
init();
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
|
|
||||||
modulejs.define('ext/piwik-analytics', ['_', '$', 'core/settings'], function (_, $, allsettings) {
|
modulejs.define('ext/piwik-analytics', ['_', '$', 'core/settings'], function (_, $, allsettings) {
|
||||||
|
|
||||||
var settings = _.extend({
|
var settings = _.extend({
|
||||||
enabled: false,
|
enabled: false,
|
||||||
baseURL: 'not-set',
|
baseURL: 'not-set',
|
||||||
idSite: 0
|
idSite: 0
|
||||||
}, allsettings['piwik-analytics']),
|
}, allsettings['piwik-analytics']);
|
||||||
|
|
||||||
init = function () {
|
|
||||||
|
function init() {
|
||||||
|
|
||||||
if (!settings.enabled) {
|
if (!settings.enabled) {
|
||||||
return;
|
return;
|
||||||
|
@ -25,7 +25,8 @@ modulejs.define('ext/piwik-analytics', ['_', '$', 'core/settings'], function (_,
|
||||||
piwikTracker.trackPageView();
|
piwikTracker.trackPageView();
|
||||||
piwikTracker.enableLinkTracking();
|
piwikTracker.enableLinkTracking();
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
init();
|
init();
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
|
|
||||||
modulejs.define('ext/preview-audio', ['_', '$', 'moment', 'core/settings', 'core/event', 'ext/preview'], function (_, $, moment, allsettings, event, preview) {
|
modulejs.define('ext/preview-audio', ['_', '$', 'moment', 'core/settings', 'core/event', 'ext/preview'], function (_, $, moment, allsettings, event, preview) {
|
||||||
|
|
||||||
var settings = _.extend({
|
var settings = _.extend({
|
||||||
enabled: false,
|
enabled: false,
|
||||||
types: []
|
types: []
|
||||||
}, allsettings['preview-aud']),
|
}, allsettings['preview-aud']);
|
||||||
|
|
||||||
preloadAudio = function (src, callback) {
|
|
||||||
|
function preloadAudio(src, callback) {
|
||||||
|
|
||||||
var $audio = $('<audio/>')
|
var $audio = $('<audio/>')
|
||||||
.one('loadedmetadata', function () {
|
.one('loadedmetadata', function () {
|
||||||
|
@ -17,18 +17,18 @@ modulejs.define('ext/preview-audio', ['_', '$', 'moment', 'core/settings', 'core
|
||||||
.attr('autoplay', 'autoplay')
|
.attr('autoplay', 'autoplay')
|
||||||
.attr('controls', 'controls')
|
.attr('controls', 'controls')
|
||||||
.attr('src', src);
|
.attr('src', src);
|
||||||
},
|
}
|
||||||
|
|
||||||
onEnter = function (items, idx) {
|
function onEnter(items, idx) {
|
||||||
|
|
||||||
var currentItems = items,
|
var currentItems = items;
|
||||||
currentIdx = idx,
|
var currentIdx = idx;
|
||||||
currentItem = items[idx],
|
var currentItem = items[idx];
|
||||||
|
|
||||||
onAdjustSize = function () {
|
function onAdjustSize() {
|
||||||
|
|
||||||
var $content = $('#pv-content'),
|
var $content = $('#pv-content');
|
||||||
$audio = $('#pv-aud-audio');
|
var $audio = $('#pv-aud-audio');
|
||||||
|
|
||||||
if ($audio.length) {
|
if ($audio.length) {
|
||||||
|
|
||||||
|
@ -42,9 +42,9 @@ modulejs.define('ext/preview-audio', ['_', '$', 'moment', 'core/settings', 'core
|
||||||
moment(0).add('seconds', $audio[0].duration).format('m:ss')
|
moment(0).add('seconds', $audio[0].duration).format('m:ss')
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
onIdxChange = function (rel) {
|
function onIdxChange(rel) {
|
||||||
|
|
||||||
currentIdx = (currentIdx + rel + currentItems.length) % currentItems.length;
|
currentIdx = (currentIdx + rel + currentItems.length) % currentItems.length;
|
||||||
currentItem = currentItems[currentIdx];
|
currentItem = currentItems[currentIdx];
|
||||||
|
@ -72,15 +72,15 @@ modulejs.define('ext/preview-audio', ['_', '$', 'moment', 'core/settings', 'core
|
||||||
}, 10);
|
}, 10);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
onIdxChange(0);
|
onIdxChange(0);
|
||||||
preview.setOnIndexChange(onIdxChange);
|
preview.setOnIndexChange(onIdxChange);
|
||||||
preview.setOnAdjustSize(onAdjustSize);
|
preview.setOnAdjustSize(onAdjustSize);
|
||||||
preview.enter();
|
preview.enter();
|
||||||
},
|
}
|
||||||
|
|
||||||
initItem = function (item) {
|
function initItem(item) {
|
||||||
|
|
||||||
if (item.$view && _.indexOf(settings.types, item.type) >= 0) {
|
if (item.$view && _.indexOf(settings.types, item.type) >= 0) {
|
||||||
item.$view.find('a').on('click', function (event) {
|
item.$view.find('a').on('click', function (event) {
|
||||||
|
@ -96,19 +96,19 @@ modulejs.define('ext/preview-audio', ['_', '$', 'moment', 'core/settings', 'core
|
||||||
onEnter(matchedEntries, _.indexOf(matchedEntries, item));
|
onEnter(matchedEntries, _.indexOf(matchedEntries, item));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
onLocationChanged = function (item) {
|
function onLocationChanged(item) {
|
||||||
|
|
||||||
_.each(item.content, initItem);
|
_.each(item.content, initItem);
|
||||||
},
|
}
|
||||||
|
|
||||||
onLocationRefreshed = function (item, added, removed) {
|
function onLocationRefreshed(item, added, removed) {
|
||||||
|
|
||||||
_.each(added, initItem);
|
_.each(added, initItem);
|
||||||
},
|
}
|
||||||
|
|
||||||
init = function () {
|
function init() {
|
||||||
|
|
||||||
if (!settings.enabled) {
|
if (!settings.enabled) {
|
||||||
return;
|
return;
|
||||||
|
@ -116,7 +116,8 @@ modulejs.define('ext/preview-audio', ['_', '$', 'moment', 'core/settings', 'core
|
||||||
|
|
||||||
event.sub('location.changed', onLocationChanged);
|
event.sub('location.changed', onLocationChanged);
|
||||||
event.sub('location.refreshed', onLocationRefreshed);
|
event.sub('location.refreshed', onLocationRefreshed);
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
init();
|
init();
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
|
|
||||||
modulejs.define('ext/preview-img', ['_', '$', 'core/settings', 'core/event', 'ext/preview'], function (_, $, allsettings, event, preview) {
|
modulejs.define('ext/preview-img', ['_', '$', 'core/settings', 'core/event', 'ext/preview'], function (_, $, allsettings, event, preview) {
|
||||||
|
|
||||||
var settings = _.extend({
|
var settings = _.extend({
|
||||||
enabled: false,
|
enabled: false,
|
||||||
types: []
|
types: []
|
||||||
}, allsettings['preview-img']),
|
}, allsettings['preview-img']);
|
||||||
|
|
||||||
preloadImg = function (src, callback) {
|
|
||||||
|
function preloadImg(src, callback) {
|
||||||
|
|
||||||
var $img = $('<img/>')
|
var $img = $('<img/>')
|
||||||
.one('load', function () {
|
.one('load', function () {
|
||||||
|
@ -15,18 +15,18 @@ modulejs.define('ext/preview-img', ['_', '$', 'core/settings', 'core/event', 'ex
|
||||||
// setTimeout(function () { callback($img); }, 1000); // for testing
|
// setTimeout(function () { callback($img); }, 1000); // for testing
|
||||||
})
|
})
|
||||||
.attr('src', src);
|
.attr('src', src);
|
||||||
},
|
}
|
||||||
|
|
||||||
onEnter = function (items, idx) {
|
function onEnter(items, idx) {
|
||||||
|
|
||||||
var currentItems = items,
|
var currentItems = items;
|
||||||
currentIdx = idx,
|
var currentIdx = idx;
|
||||||
currentItem = items[idx],
|
var currentItem = items[idx];
|
||||||
|
|
||||||
onAdjustSize = function () {
|
function onAdjustSize() {
|
||||||
|
|
||||||
var $content = $('#pv-content'),
|
var $content = $('#pv-content');
|
||||||
$img = $('#pv-img-image');
|
var $img = $('#pv-img-image');
|
||||||
|
|
||||||
if ($img.length) {
|
if ($img.length) {
|
||||||
|
|
||||||
|
@ -41,9 +41,9 @@ modulejs.define('ext/preview-img', ['_', '$', 'core/settings', 'core/event', 'ex
|
||||||
'' + (100 * $img.width() / $img[0].naturalWidth).toFixed(0) + '%'
|
'' + (100 * $img.width() / $img[0].naturalWidth).toFixed(0) + '%'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
onIdxChange = function (rel) {
|
function onIdxChange(rel) {
|
||||||
|
|
||||||
currentIdx = (currentIdx + rel + currentItems.length) % currentItems.length;
|
currentIdx = (currentIdx + rel + currentItems.length) % currentItems.length;
|
||||||
currentItem = currentItems[currentIdx];
|
currentItem = currentItems[currentIdx];
|
||||||
|
@ -74,15 +74,15 @@ modulejs.define('ext/preview-img', ['_', '$', 'core/settings', 'core/event', 'ex
|
||||||
}, 10);
|
}, 10);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
onIdxChange(0);
|
onIdxChange(0);
|
||||||
preview.setOnIndexChange(onIdxChange);
|
preview.setOnIndexChange(onIdxChange);
|
||||||
preview.setOnAdjustSize(onAdjustSize);
|
preview.setOnAdjustSize(onAdjustSize);
|
||||||
preview.enter();
|
preview.enter();
|
||||||
},
|
}
|
||||||
|
|
||||||
initItem = function (item) {
|
function initItem(item) {
|
||||||
|
|
||||||
if (item.$view && _.indexOf(settings.types, item.type) >= 0) {
|
if (item.$view && _.indexOf(settings.types, item.type) >= 0) {
|
||||||
item.$view.find('a').on('click', function (event) {
|
item.$view.find('a').on('click', function (event) {
|
||||||
|
@ -98,19 +98,19 @@ modulejs.define('ext/preview-img', ['_', '$', 'core/settings', 'core/event', 'ex
|
||||||
onEnter(matchedEntries, _.indexOf(matchedEntries, item));
|
onEnter(matchedEntries, _.indexOf(matchedEntries, item));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
onLocationChanged = function (item) {
|
function onLocationChanged(item) {
|
||||||
|
|
||||||
_.each(item.content, initItem);
|
_.each(item.content, initItem);
|
||||||
},
|
}
|
||||||
|
|
||||||
onLocationRefreshed = function (item, added, removed) {
|
function onLocationRefreshed(item, added, removed) {
|
||||||
|
|
||||||
_.each(added, initItem);
|
_.each(added, initItem);
|
||||||
},
|
}
|
||||||
|
|
||||||
init = function () {
|
function init() {
|
||||||
|
|
||||||
if (!settings.enabled) {
|
if (!settings.enabled) {
|
||||||
return;
|
return;
|
||||||
|
@ -118,7 +118,8 @@ modulejs.define('ext/preview-img', ['_', '$', 'core/settings', 'core/event', 'ex
|
||||||
|
|
||||||
event.sub('location.changed', onLocationChanged);
|
event.sub('location.changed', onLocationChanged);
|
||||||
event.sub('location.refreshed', onLocationRefreshed);
|
event.sub('location.refreshed', onLocationRefreshed);
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
init();
|
init();
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,15 +1,14 @@
|
||||||
|
|
||||||
modulejs.define('ext/preview-txt', ['_', '$', 'marked', 'prism', 'core/settings', 'core/event', 'ext/preview'], function (_, $, marked, prism, allsettings, event, preview) {
|
modulejs.define('ext/preview-txt', ['_', '$', 'marked', 'prism', 'core/settings', 'core/event', 'ext/preview'], function (_, $, marked, prism, allsettings, event, preview) {
|
||||||
|
|
||||||
var settings = _.extend({
|
var settings = _.extend({
|
||||||
enabled: false,
|
enabled: false,
|
||||||
types: {}
|
types: {}
|
||||||
}, allsettings['preview-txt']),
|
}, allsettings['preview-txt']);
|
||||||
|
var templateText = '<pre id="pv-txt-text" class="highlighted"/>';
|
||||||
|
var templateMarkdown = '<div id="pv-txt-text" class="markdown"/>';
|
||||||
|
|
||||||
templateText = '<pre id="pv-txt-text" class="highlighted"/>',
|
|
||||||
templateMarkdown = '<div id="pv-txt-text" class="markdown"/>',
|
|
||||||
|
|
||||||
preloadText = function (absHref, callback) {
|
function preloadText(absHref, callback) {
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: absHref,
|
url: absHref,
|
||||||
|
@ -24,26 +23,26 @@ modulejs.define('ext/preview-txt', ['_', '$', 'marked', 'prism', 'core/settings'
|
||||||
|
|
||||||
callback('[ajax error] ' + textStatus);
|
callback('[ajax error] ' + textStatus);
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
|
|
||||||
onEnter = function (items, idx) {
|
function onEnter(items, idx) {
|
||||||
|
|
||||||
var currentItems = items,
|
var currentItems = items;
|
||||||
currentIdx = idx,
|
var currentIdx = idx;
|
||||||
currentItem = items[idx],
|
var currentItem = items[idx];
|
||||||
|
|
||||||
onAdjustSize = function () {
|
function onAdjustSize() {
|
||||||
|
|
||||||
var $content = $('#pv-content'),
|
var $content = $('#pv-content');
|
||||||
$text = $('#pv-txt-text');
|
var $text = $('#pv-txt-text');
|
||||||
|
|
||||||
if ($text.length) {
|
if ($text.length) {
|
||||||
|
|
||||||
$text.height($content.height() - 16);
|
$text.height($content.height() - 16);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
onIdxChange = function (rel) {
|
function onIdxChange(rel) {
|
||||||
|
|
||||||
currentIdx = (currentIdx + rel + currentItems.length) % currentItems.length;
|
currentIdx = (currentIdx + rel + currentItems.length) % currentItems.length;
|
||||||
currentItem = currentItems[currentIdx];
|
currentItem = currentItems[currentIdx];
|
||||||
|
@ -57,8 +56,8 @@ modulejs.define('ext/preview-txt', ['_', '$', 'marked', 'prism', 'core/settings'
|
||||||
|
|
||||||
$('#pv-content').fadeOut(100, function () {
|
$('#pv-content').fadeOut(100, function () {
|
||||||
|
|
||||||
var type = settings.types[currentItem.type],
|
var type = settings.types[currentItem.type];
|
||||||
$text, $code;
|
var $text, $code;
|
||||||
|
|
||||||
if (type === 'none') {
|
if (type === 'none') {
|
||||||
$text = $(templateMarkdown).text(textContent);
|
$text = $(templateMarkdown).text(textContent);
|
||||||
|
@ -88,15 +87,15 @@ modulejs.define('ext/preview-txt', ['_', '$', 'marked', 'prism', 'core/settings'
|
||||||
preview.setRawLink(currentItem.absHref);
|
preview.setRawLink(currentItem.absHref);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
onIdxChange(0);
|
onIdxChange(0);
|
||||||
preview.setOnIndexChange(onIdxChange);
|
preview.setOnIndexChange(onIdxChange);
|
||||||
preview.setOnAdjustSize(onAdjustSize);
|
preview.setOnAdjustSize(onAdjustSize);
|
||||||
preview.enter();
|
preview.enter();
|
||||||
},
|
}
|
||||||
|
|
||||||
initItem = function (item) {
|
function initItem(item) {
|
||||||
|
|
||||||
if (item.$view && _.indexOf(_.keys(settings.types), item.type) >= 0) {
|
if (item.$view && _.indexOf(_.keys(settings.types), item.type) >= 0) {
|
||||||
item.$view.find('a').on('click', function (event) {
|
item.$view.find('a').on('click', function (event) {
|
||||||
|
@ -112,19 +111,19 @@ modulejs.define('ext/preview-txt', ['_', '$', 'marked', 'prism', 'core/settings'
|
||||||
onEnter(matchedEntries, _.indexOf(matchedEntries, item));
|
onEnter(matchedEntries, _.indexOf(matchedEntries, item));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
onLocationChanged = function (item) {
|
function onLocationChanged(item) {
|
||||||
|
|
||||||
_.each(item.content, initItem);
|
_.each(item.content, initItem);
|
||||||
},
|
}
|
||||||
|
|
||||||
onLocationRefreshed = function (item, added, removed) {
|
function onLocationRefreshed(item, added, removed) {
|
||||||
|
|
||||||
_.each(added, initItem);
|
_.each(added, initItem);
|
||||||
},
|
}
|
||||||
|
|
||||||
init = function () {
|
function init() {
|
||||||
|
|
||||||
if (!settings.enabled) {
|
if (!settings.enabled) {
|
||||||
return;
|
return;
|
||||||
|
@ -132,7 +131,8 @@ modulejs.define('ext/preview-txt', ['_', '$', 'marked', 'prism', 'core/settings'
|
||||||
|
|
||||||
event.sub('location.changed', onLocationChanged);
|
event.sub('location.changed', onLocationChanged);
|
||||||
event.sub('location.refreshed', onLocationRefreshed);
|
event.sub('location.refreshed', onLocationRefreshed);
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
init();
|
init();
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
|
|
||||||
modulejs.define('ext/preview-vid', ['_', '$', 'core/settings', 'core/event', 'ext/preview'], function (_, $, allsettings, event, preview) {
|
modulejs.define('ext/preview-vid', ['_', '$', 'core/settings', 'core/event', 'ext/preview'], function (_, $, allsettings, event, preview) {
|
||||||
|
|
||||||
var settings = _.extend({
|
var settings = _.extend({
|
||||||
enabled: false,
|
enabled: false,
|
||||||
types: []
|
types: []
|
||||||
}, allsettings['preview-vid']),
|
}, allsettings['preview-vid']);
|
||||||
|
|
||||||
preloadVid = function (src, callback) {
|
|
||||||
|
function preloadVid(src, callback) {
|
||||||
|
|
||||||
var $video = $('<video/>')
|
var $video = $('<video/>')
|
||||||
.one('loadedmetadata', function () {
|
.one('loadedmetadata', function () {
|
||||||
|
@ -17,15 +17,15 @@ modulejs.define('ext/preview-vid', ['_', '$', 'core/settings', 'core/event', 'ex
|
||||||
.attr('autoplay', 'autoplay')
|
.attr('autoplay', 'autoplay')
|
||||||
.attr('controls', 'controls')
|
.attr('controls', 'controls')
|
||||||
.attr('src', src);
|
.attr('src', src);
|
||||||
},
|
}
|
||||||
|
|
||||||
onEnter = function (items, idx) {
|
function onEnter(items, idx) {
|
||||||
|
|
||||||
var currentItems = items,
|
var currentItems = items;
|
||||||
currentIdx = idx,
|
var currentIdx = idx;
|
||||||
currentItem = items[idx],
|
var currentItem = items[idx];
|
||||||
|
|
||||||
onAdjustSize = function () {
|
function onAdjustSize() {
|
||||||
|
|
||||||
var $content = $('#pv-content'),
|
var $content = $('#pv-content'),
|
||||||
$vid = $('#pv-vid-video');
|
$vid = $('#pv-vid-video');
|
||||||
|
@ -43,9 +43,9 @@ modulejs.define('ext/preview-vid', ['_', '$', 'core/settings', 'core/event', 'ex
|
||||||
'' + (100 * $vid.width() / $vid[0].videoWidth).toFixed(0) + '%'
|
'' + (100 * $vid.width() / $vid[0].videoWidth).toFixed(0) + '%'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
onIdxChange = function (rel) {
|
function onIdxChange(rel) {
|
||||||
|
|
||||||
currentIdx = (currentIdx + rel + currentItems.length) % currentItems.length;
|
currentIdx = (currentIdx + rel + currentItems.length) % currentItems.length;
|
||||||
currentItem = currentItems[currentIdx];
|
currentItem = currentItems[currentIdx];
|
||||||
|
@ -73,15 +73,15 @@ modulejs.define('ext/preview-vid', ['_', '$', 'core/settings', 'core/event', 'ex
|
||||||
}, 10);
|
}, 10);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
onIdxChange(0);
|
onIdxChange(0);
|
||||||
preview.setOnIndexChange(onIdxChange);
|
preview.setOnIndexChange(onIdxChange);
|
||||||
preview.setOnAdjustSize(onAdjustSize);
|
preview.setOnAdjustSize(onAdjustSize);
|
||||||
preview.enter();
|
preview.enter();
|
||||||
},
|
}
|
||||||
|
|
||||||
initItem = function (item) {
|
function initItem(item) {
|
||||||
|
|
||||||
if (item.$view && _.indexOf(settings.types, item.type) >= 0) {
|
if (item.$view && _.indexOf(settings.types, item.type) >= 0) {
|
||||||
item.$view.find('a').on('click', function (event) {
|
item.$view.find('a').on('click', function (event) {
|
||||||
|
@ -97,19 +97,19 @@ modulejs.define('ext/preview-vid', ['_', '$', 'core/settings', 'core/event', 'ex
|
||||||
onEnter(matchedEntries, _.indexOf(matchedEntries, item));
|
onEnter(matchedEntries, _.indexOf(matchedEntries, item));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
onLocationChanged = function (item) {
|
function onLocationChanged(item) {
|
||||||
|
|
||||||
_.each(item.content, initItem);
|
_.each(item.content, initItem);
|
||||||
},
|
}
|
||||||
|
|
||||||
onLocationRefreshed = function (item, added, removed) {
|
function onLocationRefreshed(item, added, removed) {
|
||||||
|
|
||||||
_.each(added, initItem);
|
_.each(added, initItem);
|
||||||
},
|
}
|
||||||
|
|
||||||
init = function () {
|
function init() {
|
||||||
|
|
||||||
if (!settings.enabled) {
|
if (!settings.enabled) {
|
||||||
return;
|
return;
|
||||||
|
@ -117,7 +117,8 @@ modulejs.define('ext/preview-vid', ['_', '$', 'core/settings', 'core/event', 'ex
|
||||||
|
|
||||||
event.sub('location.changed', onLocationChanged);
|
event.sub('location.changed', onLocationChanged);
|
||||||
event.sub('location.refreshed', onLocationRefreshed);
|
event.sub('location.refreshed', onLocationRefreshed);
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
init();
|
init();
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
|
|
||||||
modulejs.define('ext/preview', ['_', '$', 'core/settings', 'core/resource', 'core/store'], function (_, $, allsettings, resource, store) {
|
modulejs.define('ext/preview', ['_', '$', 'core/settings', 'core/resource', 'core/store'], function (_, $, allsettings, resource, store) {
|
||||||
|
|
||||||
var settings = _.extend({
|
var settings = _.extend({
|
||||||
enabled: true
|
enabled: true
|
||||||
}, allsettings.preview),
|
}, allsettings.preview);
|
||||||
|
var template =
|
||||||
template =
|
|
||||||
'<div id="pv-overlay" class="noSelection">' +
|
'<div id="pv-overlay" class="noSelection">' +
|
||||||
'<div id="pv-content"/>' +
|
'<div id="pv-content"/>' +
|
||||||
'<div id="pv-spinner"><img src="' + resource.image('spinner') + '"/></div>' +
|
'<div id="pv-spinner"><img src="' + resource.image('spinner') + '"/></div>' +
|
||||||
|
@ -21,21 +19,23 @@ modulejs.define('ext/preview', ['_', '$', 'core/settings', 'core/resource', 'cor
|
||||||
'<li id="pv-bar-prev" class="bar-right bar-button"><img src="' + resource.image('preview/prev') + '"/></li>' +
|
'<li id="pv-bar-prev" class="bar-right bar-button"><img src="' + resource.image('preview/prev') + '"/></li>' +
|
||||||
'</ul>' +
|
'</ul>' +
|
||||||
'</div>' +
|
'</div>' +
|
||||||
'</div>',
|
'</div>';
|
||||||
|
var storekey = 'ext/preview';
|
||||||
|
var currentEntries = [];
|
||||||
|
var currentIdx = 0;
|
||||||
|
var isFullscreen = store.get(storekey) || false;
|
||||||
|
var userAliveTimeoutId = null;
|
||||||
|
var onIndexChange = null;
|
||||||
|
var onAdjustSize = null;
|
||||||
|
|
||||||
storekey = 'ext/preview',
|
|
||||||
|
|
||||||
currentEntries = [],
|
function adjustSize() {
|
||||||
currentIdx = 0,
|
|
||||||
isFullscreen = store.get(storekey) || false,
|
|
||||||
|
|
||||||
adjustSize = function () {
|
var rect = $(window).fracs('viewport');
|
||||||
|
var $container = $('#pv-content');
|
||||||
var rect = $(window).fracs('viewport'),
|
var $spinner = $('#pv-spinner');
|
||||||
$container = $('#pv-content'),
|
var margin = isFullscreen ? 0 : 20;
|
||||||
$spinner = $('#pv-spinner'),
|
var barheight = isFullscreen ? 0 : 31;
|
||||||
margin = isFullscreen ? 0 : 20,
|
|
||||||
barheight = isFullscreen ? 0 : 31;
|
|
||||||
|
|
||||||
$container.css({
|
$container.css({
|
||||||
width: rect.width - 2 * margin,
|
width: rect.width - 2 * margin,
|
||||||
|
@ -60,9 +60,9 @@ modulejs.define('ext/preview', ['_', '$', 'core/settings', 'core/resource', 'cor
|
||||||
if (_.isFunction(onAdjustSize)) {
|
if (_.isFunction(onAdjustSize)) {
|
||||||
onAdjustSize(1);
|
onAdjustSize(1);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
onEnter = function () {
|
function onEnter() {
|
||||||
|
|
||||||
$('#pv-content').empty();
|
$('#pv-content').empty();
|
||||||
setLabels([]);
|
setLabels([]);
|
||||||
|
@ -70,33 +70,32 @@ modulejs.define('ext/preview', ['_', '$', 'core/settings', 'core/resource', 'cor
|
||||||
$(window).on('keydown', onKeydown);
|
$(window).on('keydown', onKeydown);
|
||||||
|
|
||||||
adjustSize();
|
adjustSize();
|
||||||
},
|
}
|
||||||
|
|
||||||
onExit = function () {
|
function onExit() {
|
||||||
|
|
||||||
$(window).off('keydown', onKeydown);
|
$(window).off('keydown', onKeydown);
|
||||||
$('#pv-overlay').stop(true, true).fadeOut(200, function () {
|
$('#pv-overlay').stop(true, true).fadeOut(200, function () {
|
||||||
$('#pv-content').empty();
|
$('#pv-content').empty();
|
||||||
setLabels([]);
|
setLabels([]);
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
|
|
||||||
onNext = function () {
|
function onNext() {
|
||||||
|
|
||||||
if (_.isFunction(onIndexChange)) {
|
if (_.isFunction(onIndexChange)) {
|
||||||
onIndexChange(1);
|
onIndexChange(1);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
onPrevious = function () {
|
function onPrevious() {
|
||||||
|
|
||||||
if (_.isFunction(onIndexChange)) {
|
if (_.isFunction(onIndexChange)) {
|
||||||
onIndexChange(-1);
|
onIndexChange(-1);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
userAliveTimeoutId = null,
|
function userAlive() {
|
||||||
userAlive = function () {
|
|
||||||
|
|
||||||
clearTimeout(userAliveTimeoutId);
|
clearTimeout(userAliveTimeoutId);
|
||||||
$('#pv-overlay .hof').stop(true, true).fadeIn(200);
|
$('#pv-overlay .hof').stop(true, true).fadeIn(200);
|
||||||
|
@ -107,66 +106,66 @@ modulejs.define('ext/preview', ['_', '$', 'core/settings', 'core/resource', 'cor
|
||||||
$('#pv-overlay .hof').stop(true, true).fadeOut(2000);
|
$('#pv-overlay .hof').stop(true, true).fadeOut(2000);
|
||||||
}, 2000);
|
}, 2000);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
onFullscreen = function () {
|
function onFullscreen() {
|
||||||
|
|
||||||
isFullscreen = !isFullscreen;
|
isFullscreen = !isFullscreen;
|
||||||
store.put(storekey, isFullscreen);
|
store.put(storekey, isFullscreen);
|
||||||
|
|
||||||
userAlive();
|
userAlive();
|
||||||
adjustSize();
|
adjustSize();
|
||||||
},
|
}
|
||||||
|
|
||||||
onKeydown = function (event) {
|
function onKeydown(ev) {
|
||||||
|
|
||||||
var key = event.which,
|
var key = ev.which;
|
||||||
delay = 300;
|
var delay = 300;
|
||||||
|
|
||||||
if (key === 27) { // esc
|
if (key === 27) { // esc
|
||||||
event.preventDefault();
|
ev.preventDefault();
|
||||||
event.stopImmediatePropagation();
|
ev.stopImmediatePropagation();
|
||||||
onExit();
|
onExit();
|
||||||
} else if (key === 8 || key === 37) { // backspace, left
|
} else if (key === 8 || key === 37) { // backspace, left
|
||||||
event.preventDefault();
|
ev.preventDefault();
|
||||||
event.stopImmediatePropagation();
|
ev.stopImmediatePropagation();
|
||||||
$('#pv-bar-prev').addClass('hover');
|
$('#pv-bar-prev').addClass('hover');
|
||||||
setTimeout(function () { $('#pv-bar-prev').removeClass('hover'); }, delay);
|
setTimeout(function () { $('#pv-bar-prev').removeClass('hover'); }, delay);
|
||||||
onPrevious();
|
onPrevious();
|
||||||
} else if (key === 13 || key === 32 || key === 39) { // enter, space, right
|
} else if (key === 13 || key === 32 || key === 39) { // enter, space, right
|
||||||
event.preventDefault();
|
ev.preventDefault();
|
||||||
event.stopImmediatePropagation();
|
ev.stopImmediatePropagation();
|
||||||
$('#pv-bar-next').addClass('hover');
|
$('#pv-bar-next').addClass('hover');
|
||||||
setTimeout(function () { $('#pv-bar-next').removeClass('hover'); }, delay);
|
setTimeout(function () { $('#pv-bar-next').removeClass('hover'); }, delay);
|
||||||
onNext();
|
onNext();
|
||||||
} else if (key === 70) { // f
|
} else if (key === 70) { // f
|
||||||
event.preventDefault();
|
ev.preventDefault();
|
||||||
event.stopImmediatePropagation();
|
ev.stopImmediatePropagation();
|
||||||
$('#pv-bar-fullscreen').addClass('hover');
|
$('#pv-bar-fullscreen').addClass('hover');
|
||||||
setTimeout(function () { $('#pv-bar-fullscreen').removeClass('hover'); }, delay);
|
setTimeout(function () { $('#pv-bar-fullscreen').removeClass('hover'); }, delay);
|
||||||
onFullscreen();
|
onFullscreen();
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
setIndex = function (idx, total) {
|
function setIndex(idx, total) {
|
||||||
|
|
||||||
if (_.isNumber(idx)) {
|
if (_.isNumber(idx)) {
|
||||||
$('#pv-bar-idx').text('' + idx + (_.isNumber(total) ? '/' + total : '')).show();
|
$('#pv-bar-idx').text('' + idx + (_.isNumber(total) ? '/' + total : '')).show();
|
||||||
} else {
|
} else {
|
||||||
$('#pv-bar-idx').text('').hide();
|
$('#pv-bar-idx').text('').hide();
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
setRawLink = function (href) {
|
function setRawLink(href) {
|
||||||
|
|
||||||
if (href) {
|
if (href) {
|
||||||
$('#pv-bar-raw').find('a').attr('href', href).end().show();
|
$('#pv-bar-raw').find('a').attr('href', href).end().show();
|
||||||
} else {
|
} else {
|
||||||
$('#pv-bar-raw').find('a').attr('href', '#').end().hide();
|
$('#pv-bar-raw').find('a').attr('href', '#').end().hide();
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
setLabels = function (labels) {
|
function setLabels(labels) {
|
||||||
|
|
||||||
$('#pv-buttons .bar-left').remove();
|
$('#pv-buttons .bar-left').remove();
|
||||||
_.each(labels, function (label) {
|
_.each(labels, function (label) {
|
||||||
|
@ -176,21 +175,19 @@ modulejs.define('ext/preview', ['_', '$', 'core/settings', 'core/resource', 'cor
|
||||||
.text(label)
|
.text(label)
|
||||||
.appendTo('#pv-buttons');
|
.appendTo('#pv-buttons');
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
|
|
||||||
onIndexChange = null,
|
function setOnIndexChange(fn) {
|
||||||
setOnIndexChange = function (fn) {
|
|
||||||
|
|
||||||
onIndexChange = fn;
|
onIndexChange = fn;
|
||||||
},
|
}
|
||||||
|
|
||||||
onAdjustSize = null,
|
function setOnAdjustSize(fn) {
|
||||||
setOnAdjustSize = function (fn) {
|
|
||||||
|
|
||||||
onAdjustSize = fn;
|
onAdjustSize = fn;
|
||||||
},
|
}
|
||||||
|
|
||||||
showSpinner = function (show, millis) {
|
function showSpinner(show, millis) {
|
||||||
|
|
||||||
if (!_.isNumber(millis)) {
|
if (!_.isNumber(millis)) {
|
||||||
millis = 400;
|
millis = 400;
|
||||||
|
@ -201,9 +198,9 @@ modulejs.define('ext/preview', ['_', '$', 'core/settings', 'core/resource', 'cor
|
||||||
} else {
|
} else {
|
||||||
$('#pv-spinner').stop(true, true).fadeOut(millis);
|
$('#pv-spinner').stop(true, true).fadeOut(millis);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
init = function () {
|
function init() {
|
||||||
|
|
||||||
if (!settings.enabled) {
|
if (!settings.enabled) {
|
||||||
return;
|
return;
|
||||||
|
@ -220,18 +217,19 @@ modulejs.define('ext/preview', ['_', '$', 'core/settings', 'core/resource', 'cor
|
||||||
$('#pv-overlay')
|
$('#pv-overlay')
|
||||||
.on('keydown', onKeydown)
|
.on('keydown', onKeydown)
|
||||||
.on('mousemove mousedown', userAlive)
|
.on('mousemove mousedown', userAlive)
|
||||||
.on('click mousedown mousemove keydown keypress', function (event) {
|
.on('click mousedown mousemove keydown keypress', function (ev) {
|
||||||
|
|
||||||
if (event.type === 'click') {
|
if (ev.type === 'click') {
|
||||||
if (event.target.id === 'pv-overlay' || event.target.id === 'pv-content') {
|
if (ev.target.id === 'pv-overlay' || ev.target.id === 'pv-content') {
|
||||||
onExit();
|
onExit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
event.stopImmediatePropagation();
|
ev.stopImmediatePropagation();
|
||||||
});
|
});
|
||||||
|
|
||||||
$(window).on('resize load', adjustSize);
|
$(window).on('resize load', adjustSize);
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
init();
|
init();
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,14 @@
|
||||||
|
|
||||||
modulejs.define('ext/qrcode', ['_', '$', 'modernizr', 'core/settings', 'core/event'], function (_, $, modernizr, allsettings, event) {
|
modulejs.define('ext/qrcode', ['_', '$', 'modernizr', 'core/settings', 'core/event'], function (_, $, modernizr, allsettings, event) {
|
||||||
|
|
||||||
var settings = _.extend({
|
var settings = _.extend({
|
||||||
enabled: false,
|
enabled: false,
|
||||||
size: 150
|
size: 150
|
||||||
}, allsettings.qrcode),
|
}, allsettings.qrcode);
|
||||||
|
var template = '<div id="qrcode"/>';
|
||||||
|
var $qrcode, hideTimeoutId;
|
||||||
|
|
||||||
template = '<div id="qrcode"/>',
|
|
||||||
|
|
||||||
$qrcode, hideTimeoutId,
|
function update(item) {
|
||||||
|
|
||||||
update = function (item) {
|
|
||||||
|
|
||||||
$qrcode.empty().qrcode({
|
$qrcode.empty().qrcode({
|
||||||
render: modernizr.canvas ? 'canvas' : 'div',
|
render: modernizr.canvas ? 'canvas' : 'div',
|
||||||
|
@ -20,26 +18,26 @@ modulejs.define('ext/qrcode', ['_', '$', 'modernizr', 'core/settings', 'core/eve
|
||||||
bgColor: '#fff',
|
bgColor: '#fff',
|
||||||
text: window.location.protocol + '//' + window.location.host + item.absHref
|
text: window.location.protocol + '//' + window.location.host + item.absHref
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
|
|
||||||
onMouseenter = function (item) {
|
function onMouseenter(item) {
|
||||||
|
|
||||||
if (!item.isFolder()) {
|
if (!item.isFolder()) {
|
||||||
update(item);
|
update(item);
|
||||||
clearTimeout(hideTimeoutId);
|
clearTimeout(hideTimeoutId);
|
||||||
$qrcode.stop(true, true).fadeIn(400);
|
$qrcode.stop(true, true).fadeIn(400);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
onMouseleave = function (item) {
|
function onMouseleave(item) {
|
||||||
|
|
||||||
hideTimeoutId = setTimeout(function () {
|
hideTimeoutId = setTimeout(function () {
|
||||||
|
|
||||||
$qrcode.stop(true, true).fadeOut(400);
|
$qrcode.stop(true, true).fadeOut(400);
|
||||||
}, 200);
|
}, 200);
|
||||||
},
|
}
|
||||||
|
|
||||||
init = function () {
|
function init() {
|
||||||
|
|
||||||
if (!settings.enabled) {
|
if (!settings.enabled) {
|
||||||
return;
|
return;
|
||||||
|
@ -49,7 +47,7 @@ modulejs.define('ext/qrcode', ['_', '$', 'modernizr', 'core/settings', 'core/eve
|
||||||
|
|
||||||
event.sub('item.mouseenter', onMouseenter);
|
event.sub('item.mouseenter', onMouseenter);
|
||||||
event.sub('item.mouseleave', onMouseleave);
|
event.sub('item.mouseleave', onMouseleave);
|
||||||
};
|
}
|
||||||
|
|
||||||
init();
|
init();
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,20 +1,18 @@
|
||||||
|
|
||||||
modulejs.define('ext/select', ['_', '$', 'core/settings', 'core/resource', 'core/event'], function (_, $, allsettings, resource, event) {
|
modulejs.define('ext/select', ['_', '$', 'core/settings', 'core/resource', 'core/event'], function (_, $, allsettings, resource, event) {
|
||||||
|
|
||||||
var settings = _.extend({
|
var settings = _.extend({
|
||||||
enabled: false,
|
enabled: false,
|
||||||
checkboxes: false
|
checkboxes: false
|
||||||
}, allsettings.select),
|
}, allsettings.select);
|
||||||
|
var template = '<span class="selector"><img src="' + resource.image('selected') + '" alt="selected"/></span>';
|
||||||
|
var x = 0, y = 0;
|
||||||
|
var l = 0, t = 0, w = 0, h = 0;
|
||||||
|
var shrink = 1/3;
|
||||||
|
var $document = $(document);
|
||||||
|
var $selectionRect = $('<div id="selection-rect"/>');
|
||||||
|
|
||||||
template = '<span class="selector"><img src="' + resource.image('selected') + '" alt="selected"/></span>',
|
|
||||||
|
|
||||||
x = 0, y = 0,
|
function publish() {
|
||||||
l = 0, t = 0, w = 0, h = 0,
|
|
||||||
shrink = 1/3,
|
|
||||||
$document = $(document),
|
|
||||||
$selectionRect = $('<div id="selection-rect"/>'),
|
|
||||||
|
|
||||||
publish = function () {
|
|
||||||
|
|
||||||
var items = _.map($('#items .item.selected'), function (itemElement) {
|
var items = _.map($('#items .item.selected'), function (itemElement) {
|
||||||
|
|
||||||
|
@ -22,9 +20,9 @@ modulejs.define('ext/select', ['_', '$', 'core/settings', 'core/resource', 'core
|
||||||
});
|
});
|
||||||
|
|
||||||
event.pub('selection', items);
|
event.pub('selection', items);
|
||||||
},
|
}
|
||||||
|
|
||||||
selectionUpdate = function (event) {
|
function selectionUpdate(event) {
|
||||||
|
|
||||||
l = Math.min(x, event.pageX);
|
l = Math.min(x, event.pageX);
|
||||||
t = Math.min(y, event.pageY);
|
t = Math.min(y, event.pageY);
|
||||||
|
@ -40,16 +38,17 @@ modulejs.define('ext/select', ['_', '$', 'core/settings', 'core/resource', 'core
|
||||||
var selRect = $selectionRect.fracs('rect');
|
var selRect = $selectionRect.fracs('rect');
|
||||||
$('#items .item').removeClass('selecting').each(function () {
|
$('#items .item').removeClass('selecting').each(function () {
|
||||||
|
|
||||||
var $item = $(this),
|
var $item = $(this);
|
||||||
rect = $item.find('a').fracs('rect'),
|
var rect = $item.find('a').fracs('rect');
|
||||||
inter = selRect.intersection(rect);
|
var inter = selRect.intersection(rect);
|
||||||
|
|
||||||
if (inter && !$item.hasClass('folder-parent')) {
|
if (inter && !$item.hasClass('folder-parent')) {
|
||||||
$item.addClass('selecting');
|
$item.addClass('selecting');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
|
|
||||||
selectionEnd = function (event) {
|
function selectionEnd(event) {
|
||||||
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
$document.off('mousemove', selectionUpdate);
|
$document.off('mousemove', selectionUpdate);
|
||||||
|
@ -72,13 +71,13 @@ modulejs.define('ext/select', ['_', '$', 'core/settings', 'core/resource', 'core
|
||||||
$selectionRect.hide();
|
$selectionRect.hide();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
},
|
}
|
||||||
|
|
||||||
selectionStart = function (event) {
|
function selectionStart(event) {
|
||||||
|
|
||||||
var $window = $(window),
|
var $window = $(window);
|
||||||
viewRight = $window.scrollLeft() + $window.width(),
|
var viewRight = $window.scrollLeft() + $window.width();
|
||||||
viewBottom = $window.scrollTop() + $window.height();
|
var viewBottom = $window.scrollTop() + $window.height();
|
||||||
|
|
||||||
x = event.pageX;
|
x = event.pageX;
|
||||||
y = event.pageY;
|
y = event.pageY;
|
||||||
|
@ -99,25 +98,24 @@ modulejs.define('ext/select', ['_', '$', 'core/settings', 'core/resource', 'core
|
||||||
.one('mouseup', selectionEnd);
|
.one('mouseup', selectionEnd);
|
||||||
|
|
||||||
selectionUpdate(event);
|
selectionUpdate(event);
|
||||||
},
|
}
|
||||||
|
|
||||||
noSelection = function (event) {
|
function noSelection(event) {
|
||||||
|
|
||||||
event.stopImmediatePropagation();
|
event.stopImmediatePropagation();
|
||||||
return false;
|
return false;
|
||||||
},
|
}
|
||||||
|
|
||||||
noSelectionUnlessCtrl = function (event) {
|
function noSelectionUnlessCtrl(event) {
|
||||||
|
|
||||||
if (!event.ctrlKey && !event.metaKey) {
|
if (!event.ctrlKey && !event.metaKey) {
|
||||||
noSelection(event);
|
noSelection(event);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
initItem = function (item) {
|
function initItem(item) {
|
||||||
|
|
||||||
if (item.$view) {
|
if (item.$view) {
|
||||||
|
|
||||||
$(template)
|
$(template)
|
||||||
.appendTo(item.$view.find('a'))
|
.appendTo(item.$view.find('a'))
|
||||||
.on('click', function (event) {
|
.on('click', function (event) {
|
||||||
|
@ -129,17 +127,17 @@ modulejs.define('ext/select', ['_', '$', 'core/settings', 'core/resource', 'core
|
||||||
publish();
|
publish();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
onLocationChanged = function (item) {
|
function onLocationChanged(item) {
|
||||||
|
|
||||||
if (settings.checkboxes) {
|
if (settings.checkboxes) {
|
||||||
_.each(item.content, initItem);
|
_.each(item.content, initItem);
|
||||||
}
|
}
|
||||||
publish();
|
publish();
|
||||||
},
|
}
|
||||||
|
|
||||||
onLocationRefreshed = function (item, added, removed) {
|
function onLocationRefreshed(item, added, removed) {
|
||||||
|
|
||||||
var selectionChanged = false;
|
var selectionChanged = false;
|
||||||
|
|
||||||
|
@ -157,9 +155,9 @@ modulejs.define('ext/select', ['_', '$', 'core/settings', 'core/resource', 'core
|
||||||
if (selectionChanged) {
|
if (selectionChanged) {
|
||||||
publish();
|
publish();
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
init = function () {
|
function init() {
|
||||||
|
|
||||||
if (!settings.enabled) {
|
if (!settings.enabled) {
|
||||||
return;
|
return;
|
||||||
|
@ -174,7 +172,8 @@ modulejs.define('ext/select', ['_', '$', 'core/settings', 'core/resource', 'core
|
||||||
.on('mousedown', '.noSelection', noSelection)
|
.on('mousedown', '.noSelection', noSelection)
|
||||||
.on('mousedown', '.noSelectionUnlessCtrl,input,select,a', noSelectionUnlessCtrl)
|
.on('mousedown', '.noSelectionUnlessCtrl,input,select,a', noSelectionUnlessCtrl)
|
||||||
.on('mousedown', selectionStart);
|
.on('mousedown', selectionStart);
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
init();
|
init();
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
modulejs.define('ext/sort', ['_', '$', 'core/settings', 'core/resource', 'core/event', 'core/store'], function (_, $, allsettings, resource, event, store) {
|
modulejs.define('ext/sort', ['_', '$', 'core/settings', 'core/resource', 'core/event', 'core/store'], function (_, $, allsettings, resource, event, store) {
|
||||||
|
|
||||||
var settings = _.extend({
|
var settings = _.extend({
|
||||||
|
@ -8,14 +7,14 @@ modulejs.define('ext/sort', ['_', '$', 'core/settings', 'core/resource', 'core/e
|
||||||
ignorecase: true,
|
ignorecase: true,
|
||||||
natural: false,
|
natural: false,
|
||||||
folders: 0
|
folders: 0
|
||||||
}, allsettings.sort),
|
}, allsettings.sort);
|
||||||
|
var storekey = 'ext/sort';
|
||||||
storekey = 'ext/sort',
|
var template =
|
||||||
template =
|
|
||||||
'<img src="' + resource.image('ascending') + '" class="sort ascending" alt="ascending" />' +
|
'<img src="' + resource.image('ascending') + '" class="sort ascending" alt="ascending" />' +
|
||||||
'<img src="' + resource.image('descending') + '" class="sort descending" alt="descending" />',
|
'<img src="' + resource.image('descending') + '" class="sort descending" alt="descending" />';
|
||||||
|
|
||||||
getType = function (item) {
|
|
||||||
|
function getType(item) {
|
||||||
|
|
||||||
var $item = $(item);
|
var $item = $(item);
|
||||||
|
|
||||||
|
@ -31,56 +30,57 @@ modulejs.define('ext/sort', ['_', '$', 'core/settings', 'core/resource', 'core/e
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 2;
|
return 2;
|
||||||
},
|
}
|
||||||
|
|
||||||
getName = function (item) {
|
function getName(item) {
|
||||||
|
|
||||||
return $(item).find('.label').text();
|
return $(item).find('.label').text();
|
||||||
},
|
}
|
||||||
|
|
||||||
getTime = function (item) {
|
function getTime(item) {
|
||||||
|
|
||||||
return $(item).find('.date').data('time');
|
return $(item).find('.date').data('time');
|
||||||
},
|
}
|
||||||
|
|
||||||
getSize = function (item) {
|
function getSize(item) {
|
||||||
|
|
||||||
return $(item).find('.size').data('bytes');
|
return $(item).find('.size').data('bytes');
|
||||||
},
|
}
|
||||||
|
|
||||||
columnGetters = {
|
|
||||||
|
var columnGetters = {
|
||||||
0: getName,
|
0: getName,
|
||||||
1: getTime,
|
1: getTime,
|
||||||
2: getSize
|
2: getSize
|
||||||
},
|
};
|
||||||
|
var columnClasses = {
|
||||||
columnClasses = {
|
|
||||||
0: 'label',
|
0: 'label',
|
||||||
1: 'date',
|
1: 'date',
|
||||||
2: 'size'
|
2: 'size'
|
||||||
},
|
};
|
||||||
|
|
||||||
|
|
||||||
// Natural Sort algorithm for Javascript - Version 0.7 - Released under MIT license
|
// Natural Sort algorithm for Javascript - Version 0.7 - Released under MIT license
|
||||||
// Author: Jim Palmer (based on chunking idea from Dave Koelle)
|
// Author: Jim Palmer (based on chunking idea from Dave Koelle)
|
||||||
//
|
//
|
||||||
// Modified to make it work with h5ai
|
// Modified to make it work with h5ai
|
||||||
naturalCmpFn = function (val1, val2) {
|
function naturalCmpFn(val1, val2) {
|
||||||
|
|
||||||
var re = /(^-?[0-9]+(\.?[0-9]*)[df]?e?[0-9]?$|^0x[0-9a-f]+$|[0-9]+)/gi,
|
var re = /(^-?[0-9]+(\.?[0-9]*)[df]?e?[0-9]?$|^0x[0-9a-f]+$|[0-9]+)/gi;
|
||||||
sre = /(^[ ]*|[ ]*$)/g,
|
var sre = /(^[ ]*|[ ]*$)/g;
|
||||||
dre = /(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,
|
var dre = /(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/;
|
||||||
hre = /^0x[0-9a-f]+$/i,
|
var hre = /^0x[0-9a-f]+$/i;
|
||||||
ore = /^0/,
|
var ore = /^0/;
|
||||||
// convert all to strings strip whitespace
|
// convert all to strings strip whitespace
|
||||||
x = ('' + val1).replace(sre, ''),
|
var x = ('' + val1).replace(sre, '');
|
||||||
y = ('' + val2).replace(sre, ''),
|
var y = ('' + val2).replace(sre, '');
|
||||||
// chunk/tokenize
|
// chunk/tokenize
|
||||||
xN = x.replace(re, '\0$1\0').replace(/\0$/,'').replace(/^\0/,'').split('\0'),
|
var xN = x.replace(re, '\0$1\0').replace(/\0$/,'').replace(/^\0/,'').split('\0');
|
||||||
yN = y.replace(re, '\0$1\0').replace(/\0$/,'').replace(/^\0/,'').split('\0'),
|
var yN = y.replace(re, '\0$1\0').replace(/\0$/,'').replace(/^\0/,'').split('\0');
|
||||||
// numeric, hex or date detection
|
// numeric, hex or date detection
|
||||||
xD = parseInt(x.match(hre), 10) || (xN.length !== 1 && x.match(dre) && Date.parse(x)),
|
var xD = parseInt(x.match(hre), 10) || (xN.length !== 1 && x.match(dre) && Date.parse(x));
|
||||||
yD = parseInt(y.match(hre), 10) || xD && y.match(dre) && Date.parse(y) || null,
|
var yD = parseInt(y.match(hre), 10) || xD && y.match(dre) && Date.parse(y) || null;
|
||||||
oFxNcL, oFyNcL;
|
var oFxNcL, oFyNcL;
|
||||||
// first try and sort Hex codes or Dates
|
// first try and sort Hex codes or Dates
|
||||||
if (yD) {
|
if (yD) {
|
||||||
if (xD < yD) {
|
if (xD < yD) {
|
||||||
|
@ -109,9 +109,9 @@ modulejs.define('ext/sort', ['_', '$', 'core/settings', 'core/resource', 'core/e
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
},
|
}
|
||||||
|
|
||||||
cmpFn = function (getValue, reverse, ignorecase, natural) {
|
function cmpFn(getValue, reverse, ignorecase, natural) {
|
||||||
|
|
||||||
return function (item1, item2) {
|
return function (item1, item2) {
|
||||||
|
|
||||||
|
@ -143,17 +143,15 @@ modulejs.define('ext/sort', ['_', '$', 'core/settings', 'core/resource', 'core/e
|
||||||
|
|
||||||
return reverse ? -res : res;
|
return reverse ? -res : res;
|
||||||
};
|
};
|
||||||
},
|
}
|
||||||
|
|
||||||
sortItems = function (column, reverse) {
|
function sortItems(column, reverse) {
|
||||||
|
|
||||||
var headers = $('#items li.header a'),
|
var headers = $('#items li.header a');
|
||||||
header = $('#items li.header a.' + columnClasses[column]),
|
var header = $('#items li.header a.' + columnClasses[column]);
|
||||||
|
var fn = cmpFn(columnGetters[column], reverse, settings.ignorecase, column === 0 && settings.natural);
|
||||||
fn = cmpFn(columnGetters[column], reverse, settings.ignorecase, column === 0 && settings.natural),
|
var current = $('#items .item');
|
||||||
|
var sorted = $('#items .item').sort(fn);
|
||||||
current = $('#items .item'),
|
|
||||||
sorted = $('#items .item').sort(fn);
|
|
||||||
|
|
||||||
store.put(storekey, {column: column, reverse: reverse});
|
store.put(storekey, {column: column, reverse: reverse});
|
||||||
|
|
||||||
|
@ -166,18 +164,18 @@ modulejs.define('ext/sort', ['_', '$', 'core/settings', 'core/resource', 'core/e
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
onContentChanged = function (item) {
|
function onContentChanged(item) {
|
||||||
|
|
||||||
var order = store.get(storekey),
|
var order = store.get(storekey);
|
||||||
column = order && order.column || settings.column,
|
var column = order && order.column || settings.column;
|
||||||
reverse = order && order.reverse || settings.reverse;
|
var reverse = order && order.reverse || settings.reverse;
|
||||||
|
|
||||||
sortItems(column, reverse);
|
sortItems(column, reverse);
|
||||||
},
|
}
|
||||||
|
|
||||||
init = function () {
|
function init() {
|
||||||
|
|
||||||
if (!settings.enabled) {
|
if (!settings.enabled) {
|
||||||
return;
|
return;
|
||||||
|
@ -211,7 +209,8 @@ modulejs.define('ext/sort', ['_', '$', 'core/settings', 'core/resource', 'core/e
|
||||||
|
|
||||||
event.sub('location.changed', onContentChanged);
|
event.sub('location.changed', onContentChanged);
|
||||||
event.sub('location.refreshed', onContentChanged);
|
event.sub('location.refreshed', onContentChanged);
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
init();
|
init();
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
|
|
||||||
modulejs.define('ext/statusbar', ['_', '$', 'core/settings', 'core/format', 'core/event'], function (_, $, allsettings, format, event) {
|
modulejs.define('ext/statusbar', ['_', '$', 'core/settings', 'core/format', 'core/event'], function (_, $, allsettings, format, event) {
|
||||||
|
|
||||||
var settings = _.extend({
|
var settings = _.extend({
|
||||||
enabled: false
|
enabled: false
|
||||||
}, allsettings.statusbar),
|
}, allsettings.statusbar);
|
||||||
|
var template =
|
||||||
template =
|
|
||||||
'<span class="statusbar">' +
|
'<span class="statusbar">' +
|
||||||
'<span class="status default">' +
|
'<span class="status default">' +
|
||||||
'<span class="folderTotal"/> <span class="l10n-folders"/>' +
|
'<span class="folderTotal"/> <span class="l10n-folders"/>' +
|
||||||
|
@ -13,13 +11,13 @@ modulejs.define('ext/statusbar', ['_', '$', 'core/settings', 'core/format', 'cor
|
||||||
'<span class="fileTotal"/> <span class="l10n-files"/>' +
|
'<span class="fileTotal"/> <span class="l10n-files"/>' +
|
||||||
'</span>' +
|
'</span>' +
|
||||||
'<span class="status dynamic"/>' +
|
'<span class="status dynamic"/>' +
|
||||||
'</span>',
|
'</span>';
|
||||||
sepTemplate = '<span class="sep"/>',
|
var sepTemplate = '<span class="sep"/>';
|
||||||
|
var $statusDynamic;
|
||||||
|
var $statusDefault;
|
||||||
|
|
||||||
$statusDynamic,
|
|
||||||
$statusDefault,
|
|
||||||
|
|
||||||
update = function (html) {
|
function update(html) {
|
||||||
|
|
||||||
if (html) {
|
if (html) {
|
||||||
$statusDefault.hide();
|
$statusDefault.hide();
|
||||||
|
@ -28,18 +26,18 @@ modulejs.define('ext/statusbar', ['_', '$', 'core/settings', 'core/format', 'cor
|
||||||
$statusDynamic.empty().hide();
|
$statusDynamic.empty().hide();
|
||||||
$statusDefault.show();
|
$statusDefault.show();
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
init = function () {
|
function init() {
|
||||||
|
|
||||||
if (!settings.enabled) {
|
if (!settings.enabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var $statusbar = $(template),
|
var $statusbar = $(template);
|
||||||
$folderTotal = $statusbar.find('.folderTotal'),
|
var $folderTotal = $statusbar.find('.folderTotal');
|
||||||
$fileTotal = $statusbar.find('.fileTotal'),
|
var $fileTotal = $statusbar.find('.fileTotal');
|
||||||
onLocationChanged = function (item) {
|
var onLocationChanged = function (item) {
|
||||||
|
|
||||||
var stats = item.getStats();
|
var stats = item.getStats();
|
||||||
$folderTotal.text(stats.folders);
|
$folderTotal.text(stats.folders);
|
||||||
|
@ -77,7 +75,8 @@ modulejs.define('ext/statusbar', ['_', '$', 'core/settings', 'core/format', 'cor
|
||||||
|
|
||||||
update();
|
update();
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
init();
|
init();
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
modulejs.define('ext/thumbnails', ['_', 'core/settings', 'core/event', 'core/server'], function (_, allsettings, event, server) {
|
modulejs.define('ext/thumbnails', ['_', 'core/settings', 'core/event', 'core/server'], function (_, allsettings, event, server) {
|
||||||
|
|
||||||
var settings = _.extend({
|
var settings = _.extend({
|
||||||
|
@ -8,9 +7,10 @@ modulejs.define('ext/thumbnails', ['_', 'core/settings', 'core/event', 'core/ser
|
||||||
doc: ['pdf', 'ps'],
|
doc: ['pdf', 'ps'],
|
||||||
delay: 1000,
|
delay: 1000,
|
||||||
size: 96
|
size: 96
|
||||||
}, allsettings.thumbnails),
|
}, allsettings.thumbnails);
|
||||||
|
|
||||||
requestThumb = function (type, href, mode, ratio, callback) {
|
|
||||||
|
function requestThumb(type, href, mode, ratio, callback) {
|
||||||
|
|
||||||
server.request({
|
server.request({
|
||||||
action: 'getThumbHref',
|
action: 'getThumbHref',
|
||||||
|
@ -23,9 +23,9 @@ modulejs.define('ext/thumbnails', ['_', 'core/settings', 'core/event', 'core/ser
|
||||||
|
|
||||||
callback(json && json.code === 0 ? json.absHref : null);
|
callback(json && json.code === 0 ? json.absHref : null);
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
|
|
||||||
checkItem = function (item) {
|
function checkItem(item) {
|
||||||
|
|
||||||
var type = null;
|
var type = null;
|
||||||
|
|
||||||
|
@ -61,22 +61,22 @@ modulejs.define('ext/thumbnails', ['_', 'core/settings', 'core/event', 'core/ser
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
onLocationChanged = function (item) {
|
function onLocationChanged(item) {
|
||||||
|
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
|
|
||||||
_.each(item.content, checkItem);
|
_.each(item.content, checkItem);
|
||||||
}, settings.delay);
|
}, settings.delay);
|
||||||
},
|
}
|
||||||
|
|
||||||
onLocationRefreshed = function (item, added, removed) {
|
function onLocationRefreshed(item, added, removed) {
|
||||||
|
|
||||||
_.each(added, checkItem);
|
_.each(added, checkItem);
|
||||||
},
|
}
|
||||||
|
|
||||||
init = function () {
|
function init() {
|
||||||
|
|
||||||
if (!settings.enabled || !server.api) {
|
if (!settings.enabled || !server.api) {
|
||||||
return;
|
return;
|
||||||
|
@ -84,7 +84,8 @@ modulejs.define('ext/thumbnails', ['_', 'core/settings', 'core/event', 'core/ser
|
||||||
|
|
||||||
event.sub('location.changed', onLocationChanged);
|
event.sub('location.changed', onLocationChanged);
|
||||||
event.sub('location.refreshed', onLocationRefreshed);
|
event.sub('location.refreshed', onLocationRefreshed);
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
init();
|
init();
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
|
|
||||||
modulejs.define('ext/title', ['_', 'core/settings', 'core/event'], function (_, allsettings, event) {
|
modulejs.define('ext/title', ['_', 'core/settings', 'core/event'], function (_, allsettings, event) {
|
||||||
|
|
||||||
var settings = _.extend({
|
var settings = _.extend({
|
||||||
enabled: false
|
enabled: false
|
||||||
}, allsettings.title),
|
}, allsettings.title);
|
||||||
|
|
||||||
onLocationChanged = function (item) {
|
function onLocationChanged(item) {
|
||||||
|
|
||||||
var labels = _.pluck(item.getCrumb(), 'label'),
|
var labels = _.pluck(item.getCrumb(), 'label'),
|
||||||
title = labels.join(' > ');
|
title = labels.join(' > ');
|
||||||
|
@ -15,16 +14,16 @@ modulejs.define('ext/title', ['_', 'core/settings', 'core/event'], function (_,
|
||||||
}
|
}
|
||||||
|
|
||||||
document.title = title;
|
document.title = title;
|
||||||
},
|
}
|
||||||
|
|
||||||
init = function () {
|
function init() {
|
||||||
|
|
||||||
if (!settings.enabled) {
|
if (!settings.enabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
event.sub('location.changed', onLocationChanged);
|
event.sub('location.changed', onLocationChanged);
|
||||||
};
|
}
|
||||||
|
|
||||||
init();
|
init();
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
|
|
||||||
modulejs.define('ext/tree', ['_', '$', 'core/settings', 'core/resource', 'core/event', 'core/location'], function (_, $, allsettings, resource, event, location) {
|
modulejs.define('ext/tree', ['_', '$', 'core/settings', 'core/resource', 'core/event', 'core/location'], function (_, $, allsettings, resource, event, location) {
|
||||||
|
|
||||||
var settings = _.extend({
|
var settings = _.extend({
|
||||||
enabled: false,
|
enabled: false,
|
||||||
slide: true,
|
slide: true,
|
||||||
maxSubfolders: 50
|
maxSubfolders: 50
|
||||||
}, allsettings.tree),
|
}, allsettings.tree);
|
||||||
|
var template =
|
||||||
template =
|
|
||||||
'<div class="item">' +
|
'<div class="item">' +
|
||||||
'<span class="indicator none">' +
|
'<span class="indicator none">' +
|
||||||
'<img src="' + resource.image('tree') + '"/>' +
|
'<img src="' + resource.image('tree') + '"/>' +
|
||||||
|
@ -16,16 +14,17 @@ modulejs.define('ext/tree', ['_', '$', 'core/settings', 'core/resource', 'core/e
|
||||||
'<span class="icon"><img/></span>' +
|
'<span class="icon"><img/></span>' +
|
||||||
'<span class="label"/>' +
|
'<span class="label"/>' +
|
||||||
'</a>' +
|
'</a>' +
|
||||||
'</span>',
|
'</span>';
|
||||||
statusHintTemplate = '<span class="hint"/>',
|
var statusHintTemplate = '<span class="hint"/>';
|
||||||
|
|
||||||
update = function (item) {
|
|
||||||
|
|
||||||
var $html = $(template),
|
function update(item) {
|
||||||
$indicator = $html.find('.indicator'),
|
|
||||||
$a = $html.find('a'),
|
var $html = $(template);
|
||||||
$img = $html.find('.icon img'),
|
var $indicator = $html.find('.indicator');
|
||||||
$label = $html.find('.label');
|
var $a = $html.find('a');
|
||||||
|
var $img = $html.find('.icon img');
|
||||||
|
var $label = $html.find('.label');
|
||||||
|
|
||||||
$html
|
$html
|
||||||
.addClass(item.isFolder() ? 'folder' : 'file')
|
.addClass(item.isFolder() ? 'folder' : 'file')
|
||||||
|
@ -102,12 +101,13 @@ modulejs.define('ext/tree', ['_', '$', 'core/settings', 'core/resource', 'core/e
|
||||||
item.$tree = $html;
|
item.$tree = $html;
|
||||||
|
|
||||||
return $html;
|
return $html;
|
||||||
},
|
}
|
||||||
|
|
||||||
createOnIndicatorClick = function () {
|
function createOnIndicatorClick() {
|
||||||
|
|
||||||
var $tree = $('#tree'),
|
var $tree = $('#tree');
|
||||||
slide = function (item, $indicator, $content, down) {
|
|
||||||
|
function slide(item, $indicator, $content, down) {
|
||||||
|
|
||||||
item.isContentVisible = down;
|
item.isContentVisible = down;
|
||||||
$indicator.removeClass('open close').addClass(down ? 'open' : 'close');
|
$indicator.removeClass('open close').addClass(down ? 'open' : 'close');
|
||||||
|
@ -116,14 +116,14 @@ modulejs.define('ext/tree', ['_', '$', 'core/settings', 'core/resource', 'core/e
|
||||||
|
|
||||||
$tree.scrollpanel('update');
|
$tree.scrollpanel('update');
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
return function () {
|
return function () {
|
||||||
|
|
||||||
var $indicator = $(this),
|
var $indicator = $(this);
|
||||||
$item = $indicator.closest('.item'),
|
var $item = $indicator.closest('.item');
|
||||||
item = $item.data('item'),
|
var item = $item.data('item');
|
||||||
$content = $item.find('> ul.content');
|
var $content = $item.find('> ul.content');
|
||||||
|
|
||||||
if ($indicator.hasClass('unknown')) {
|
if ($indicator.hasClass('unknown')) {
|
||||||
|
|
||||||
|
@ -131,9 +131,9 @@ modulejs.define('ext/tree', ['_', '$', 'core/settings', 'core/resource', 'core/e
|
||||||
|
|
||||||
item.isContentVisible = false;
|
item.isContentVisible = false;
|
||||||
|
|
||||||
var $item = update(item),
|
var $item = update(item);
|
||||||
$indicator = $item.find('> .indicator'),
|
var $indicator = $item.find('> .indicator');
|
||||||
$content = $item.find('> ul.content');
|
var $content = $item.find('> ul.content');
|
||||||
|
|
||||||
if (!$indicator.hasClass('none')) {
|
if (!$indicator.hasClass('none')) {
|
||||||
slide(item, $indicator, $content, true);
|
slide(item, $indicator, $content, true);
|
||||||
|
@ -149,22 +149,22 @@ modulejs.define('ext/tree', ['_', '$', 'core/settings', 'core/resource', 'core/e
|
||||||
slide(item, $indicator, $content, true);
|
slide(item, $indicator, $content, true);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
},
|
}
|
||||||
|
|
||||||
shiftTree = function (forceVisible, dontAnimate) {
|
function shiftTree(forceVisible, dontAnimate) {
|
||||||
|
|
||||||
var $tree = $("#tree"),
|
var $tree = $("#tree");
|
||||||
$view = $("#view"),
|
var $view = $("#view");
|
||||||
left = ((settings.slide && $tree.outerWidth() < $view.offset().left) || forceVisible || !$view.is(':visible')) ? 0 : 18 - $tree.outerWidth();
|
var left = ((settings.slide && $tree.outerWidth() < $view.offset().left) || forceVisible || !$view.is(':visible')) ? 0 : 18 - $tree.outerWidth();
|
||||||
|
|
||||||
if (dontAnimate) {
|
if (dontAnimate) {
|
||||||
$tree.stop().css({ left: left });
|
$tree.stop().css({ left: left });
|
||||||
} else {
|
} else {
|
||||||
$tree.stop().animate({ left: left });
|
$tree.stop().animate({ left: left });
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
fetchTree = function (item, callback) {
|
function fetchTree(item, callback) {
|
||||||
|
|
||||||
item.isContentVisible = true;
|
item.isContentVisible = true;
|
||||||
item.fetchContent(function (item) {
|
item.fetchContent(function (item) {
|
||||||
|
@ -175,14 +175,14 @@ modulejs.define('ext/tree', ['_', '$', 'core/settings', 'core/resource', 'core/e
|
||||||
callback(item);
|
callback(item);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
|
|
||||||
adjustSpacing = function () {
|
function adjustSpacing() {
|
||||||
|
|
||||||
var $tree = $('#tree'),
|
var $tree = $('#tree');
|
||||||
winHeight = $(window).height(),
|
var winHeight = $(window).height();
|
||||||
navHeight = $('#topbar').outerHeight(),
|
var navHeight = $('#topbar').outerHeight();
|
||||||
footerHeight = $('#bottombar').outerHeight();
|
var footerHeight = $('#bottombar').outerHeight();
|
||||||
|
|
||||||
$tree.css({
|
$tree.css({
|
||||||
top: navHeight,
|
top: navHeight,
|
||||||
|
@ -190,9 +190,9 @@ modulejs.define('ext/tree', ['_', '$', 'core/settings', 'core/resource', 'core/e
|
||||||
});
|
});
|
||||||
|
|
||||||
$tree.scrollpanel('update');
|
$tree.scrollpanel('update');
|
||||||
},
|
}
|
||||||
|
|
||||||
onLocationChanged = function (item) {
|
function onLocationChanged(item) {
|
||||||
|
|
||||||
fetchTree(item, function (root) {
|
fetchTree(item, function (root) {
|
||||||
|
|
||||||
|
@ -202,9 +202,9 @@ modulejs.define('ext/tree', ['_', '$', 'core/settings', 'core/resource', 'core/e
|
||||||
adjustSpacing();
|
adjustSpacing();
|
||||||
shiftTree(false, true);
|
shiftTree(false, true);
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
|
|
||||||
init = function () {
|
function init() {
|
||||||
|
|
||||||
if (!settings.enabled) {
|
if (!settings.enabled) {
|
||||||
return;
|
return;
|
||||||
|
@ -231,7 +231,8 @@ modulejs.define('ext/tree', ['_', '$', 'core/settings', 'core/resource', 'core/e
|
||||||
adjustSpacing();
|
adjustSpacing();
|
||||||
shiftTree();
|
shiftTree();
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
init();
|
init();
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,19 +1,16 @@
|
||||||
|
|
||||||
modulejs.define('info', ['$', 'config'], function ($, config) {
|
modulejs.define('info', ['$', 'config'], function ($, config) {
|
||||||
|
|
||||||
var testsTemp =
|
var testsTemp =
|
||||||
'<div id="tests-wrapper">' +
|
'<div id="tests-wrapper">' +
|
||||||
'<ul id="tests">' +
|
'<ul id="tests">' +
|
||||||
'</div>',
|
'</div>';
|
||||||
|
var testTemp =
|
||||||
testTemp =
|
|
||||||
'<li class="test">' +
|
'<li class="test">' +
|
||||||
'<span class="label"></span>' +
|
'<span class="label"></span>' +
|
||||||
'<span class="result"></span>' +
|
'<span class="result"></span>' +
|
||||||
'<div class="info"></div>' +
|
'<div class="info"></div>' +
|
||||||
'</li>',
|
'</li>';
|
||||||
|
var loginTemp =
|
||||||
loginTemp =
|
|
||||||
'<div id="login-wrapper">' +
|
'<div id="login-wrapper">' +
|
||||||
'<input id="pass" type="password" placeholder="password"/>' +
|
'<input id="pass" type="password" placeholder="password"/>' +
|
||||||
'<span id="login">login</span>' +
|
'<span id="login">login</span>' +
|
||||||
|
@ -22,13 +19,11 @@ modulejs.define('info', ['$', 'config'], function ($, config) {
|
||||||
'The preset password is the empty string, so just hit login. ' +
|
'The preset password is the empty string, so just hit login. ' +
|
||||||
'You might change it in the index file to keep this information private.' +
|
'You might change it in the index file to keep this information private.' +
|
||||||
'</div>' +
|
'</div>' +
|
||||||
'</div>',
|
'</div>';
|
||||||
|
var setup = config.setup;
|
||||||
|
|
||||||
setup = config.setup,
|
|
||||||
|
|
||||||
addTests = function () {
|
function addTest(label, info, passed, result) {
|
||||||
|
|
||||||
var addTest = function (label, info, passed, result) {
|
|
||||||
|
|
||||||
$(testTemp)
|
$(testTemp)
|
||||||
.find('.label')
|
.find('.label')
|
||||||
|
@ -42,7 +37,9 @@ modulejs.define('info', ['$', 'config'], function ($, config) {
|
||||||
.html(info)
|
.html(info)
|
||||||
.end()
|
.end()
|
||||||
.appendTo('#tests');
|
.appendTo('#tests');
|
||||||
};
|
}
|
||||||
|
|
||||||
|
function addTests() {
|
||||||
|
|
||||||
$(testsTemp).appendTo('body');
|
$(testsTemp).appendTo('body');
|
||||||
|
|
||||||
|
@ -110,11 +107,9 @@ modulejs.define('info', ['$', 'config'], function ($, config) {
|
||||||
'Shell du', 'Command line program <code>du</code> available',
|
'Shell du', 'Command line program <code>du</code> available',
|
||||||
setup.HAS_CMD_DU
|
setup.HAS_CMD_DU
|
||||||
);
|
);
|
||||||
},
|
}
|
||||||
|
|
||||||
addLogin = function () {
|
function request(data) {
|
||||||
|
|
||||||
var request = function (data) {
|
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: 'server/php/index.php',
|
url: 'server/php/index.php',
|
||||||
|
@ -126,29 +121,32 @@ modulejs.define('info', ['$', 'config'], function ($, config) {
|
||||||
|
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
|
|
||||||
onLogin = function () {
|
function onLogin() {
|
||||||
|
|
||||||
request({
|
request({
|
||||||
'action': 'login',
|
'action': 'login',
|
||||||
'pass': $('#pass').val()
|
'pass': $('#pass').val()
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
|
|
||||||
onLogout = function () {
|
function onLogout() {
|
||||||
|
|
||||||
request({
|
request({
|
||||||
'action': 'logout'
|
'action': 'logout'
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
|
|
||||||
onKeydown = function (event) {
|
function onKeydown(event) {
|
||||||
|
|
||||||
if (event.which === 13) {
|
if (event.which === 13) {
|
||||||
onLogin();
|
onLogin();
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
function addLogin() {
|
||||||
|
|
||||||
|
|
||||||
$(loginTemp).appendTo('body');
|
$(loginTemp).appendTo('body');
|
||||||
|
|
||||||
|
@ -164,15 +162,16 @@ modulejs.define('info', ['$', 'config'], function ($, config) {
|
||||||
if (setup.HAS_CUSTOM_PASSHASH) {
|
if (setup.HAS_CUSTOM_PASSHASH) {
|
||||||
$('#hint').remove();
|
$('#hint').remove();
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
init = function () {
|
function init() {
|
||||||
|
|
||||||
addLogin();
|
addLogin();
|
||||||
if (setup.AS_ADMIN) {
|
if (setup.AS_ADMIN) {
|
||||||
addTests();
|
addTests();
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
init();
|
init();
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
modulejs.define('main', ['_', 'core/event'], function (_, event) {
|
modulejs.define('main', ['_', 'core/event'], function (_, event) {
|
||||||
|
|
||||||
modulejs.require('view/ensure');
|
modulejs.require('view/ensure');
|
||||||
|
|
|
@ -1,26 +1,23 @@
|
||||||
|
|
||||||
modulejs.define('model/item', ['_', 'core/types', 'core/event', 'core/settings', 'core/server', 'core/location'], function (_, types, event, settings, server, location) {
|
modulejs.define('model/item', ['_', 'core/types', 'core/event', 'core/settings', 'core/server', 'core/location'], function (_, types, event, settings, server, location) {
|
||||||
|
|
||||||
|
var reEndsWithSlash = /\/$/;
|
||||||
|
var reSplitPath = /^(.*\/)([^\/]+\/?)$/;
|
||||||
|
var cache = {};
|
||||||
|
|
||||||
var reEndsWithSlash = /\/$/,
|
|
||||||
|
|
||||||
startsWith = function (sequence, part) {
|
function startsWith(sequence, part) {
|
||||||
|
|
||||||
return sequence.slice && part.length && sequence.slice(0, part.length) === part;
|
return sequence.slice && part.length && sequence.slice(0, part.length) === part;
|
||||||
},
|
}
|
||||||
|
|
||||||
|
function createLabel(sequence) {
|
||||||
createLabel = function (sequence) {
|
|
||||||
|
|
||||||
sequence = sequence.replace(reEndsWithSlash, '');
|
sequence = sequence.replace(reEndsWithSlash, '');
|
||||||
try { sequence = decodeURIComponent(sequence); } catch (e) {}
|
try { sequence = decodeURIComponent(sequence); } catch (e) {}
|
||||||
return sequence;
|
return sequence;
|
||||||
},
|
}
|
||||||
|
|
||||||
|
function splitPath(sequence) {
|
||||||
reSplitPath = /^(.*\/)([^\/]+\/?)$/,
|
|
||||||
|
|
||||||
splitPath = function (sequence) {
|
|
||||||
|
|
||||||
if (sequence === '/') {
|
if (sequence === '/') {
|
||||||
return { parent: null, name: '/' };
|
return { parent: null, name: '/' };
|
||||||
|
@ -35,13 +32,9 @@ modulejs.define('model/item', ['_', 'core/types', 'core/event', 'core/settings',
|
||||||
}
|
}
|
||||||
return split;
|
return split;
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
|
function getItem(absHref, time, size, isManaged, isContentFetched, md5, sha1) {
|
||||||
|
|
||||||
cache = {},
|
|
||||||
|
|
||||||
getItem = function (absHref, time, size, isManaged, isContentFetched, md5, sha1) {
|
|
||||||
|
|
||||||
absHref = location.forceEncoding(absHref);
|
absHref = location.forceEncoding(absHref);
|
||||||
|
|
||||||
|
@ -71,9 +64,9 @@ modulejs.define('model/item', ['_', 'core/types', 'core/event', 'core/settings',
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
},
|
}
|
||||||
|
|
||||||
removeItem = function (absHref) {
|
function removeItem(absHref) {
|
||||||
|
|
||||||
absHref = location.forceEncoding(absHref);
|
absHref = location.forceEncoding(absHref);
|
||||||
|
|
||||||
|
@ -89,9 +82,9 @@ modulejs.define('model/item', ['_', 'core/types', 'core/event', 'core/settings',
|
||||||
removeItem(item.absHref);
|
removeItem(item.absHref);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
fetchContent = function (absHref, callback) {
|
function fetchContent(absHref, callback) {
|
||||||
|
|
||||||
var self = getItem(absHref);
|
var self = getItem(absHref);
|
||||||
|
|
||||||
|
@ -113,11 +106,10 @@ modulejs.define('model/item', ['_', 'core/types', 'core/event', 'core/settings',
|
||||||
callback(self);
|
callback(self);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function Item(absHref) {
|
||||||
var Item = function (absHref) {
|
|
||||||
|
|
||||||
var split = splitPath(absHref);
|
var split = splitPath(absHref);
|
||||||
|
|
||||||
|
@ -139,7 +131,7 @@ modulejs.define('model/item', ['_', 'core/types', 'core/event', 'core/settings',
|
||||||
this.parent.isContentFetched = true;
|
this.parent.isContentFetched = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
_.extend(Item.prototype, {
|
_.extend(Item.prototype, {
|
||||||
|
|
||||||
|
@ -190,8 +182,8 @@ modulejs.define('model/item', ['_', 'core/types', 'core/event', 'core/settings',
|
||||||
|
|
||||||
getCrumb: function () {
|
getCrumb: function () {
|
||||||
|
|
||||||
var item = this,
|
var item = this;
|
||||||
crumb = [item];
|
var crumb = [item];
|
||||||
|
|
||||||
while (item.parent) {
|
while (item.parent) {
|
||||||
item = item.parent;
|
item = item.parent;
|
||||||
|
@ -214,8 +206,8 @@ modulejs.define('model/item', ['_', 'core/types', 'core/event', 'core/settings',
|
||||||
|
|
||||||
getStats: function () {
|
getStats: function () {
|
||||||
|
|
||||||
var folders = 0,
|
var folders = 0;
|
||||||
files = 0;
|
var files = 0;
|
||||||
|
|
||||||
_.each(this.content, function (item) {
|
_.each(this.content, function (item) {
|
||||||
|
|
||||||
|
@ -226,8 +218,8 @@ modulejs.define('model/item', ['_', 'core/types', 'core/event', 'core/settings',
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var depth = 0,
|
var depth = 0;
|
||||||
item = this;
|
var item = this;
|
||||||
|
|
||||||
while (item.parent) {
|
while (item.parent) {
|
||||||
depth += 1;
|
depth += 1;
|
||||||
|
@ -242,6 +234,7 @@ modulejs.define('model/item', ['_', 'core/types', 'core/event', 'core/settings',
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
get: getItem,
|
get: getItem,
|
||||||
remove: removeItem
|
remove: removeItem
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
|
|
||||||
modulejs.define('view/ensure', ['$', 'config', 'core/event'], function ($, config, event) {
|
modulejs.define('view/ensure', ['$', 'config', 'core/event'], function ($, config, event) {
|
||||||
|
|
||||||
var selb = '#bottombar',
|
var selb = '#bottombar';
|
||||||
selr = selb + ' .right',
|
var selr = selb + ' .right';
|
||||||
sela = selr + ' a',
|
var sela = selr + ' a';
|
||||||
sequence = 'powered by h5ai ' + config.setup.VERSION,
|
var sequence = 'powered by h5ai ' + config.setup.VERSION;
|
||||||
url = 'http://larsjung.de/h5ai/',
|
var url = 'http://larsjung.de/h5ai/';
|
||||||
isVisible = ':visible',
|
var isVisible = ':visible';
|
||||||
styleKey = 'style',
|
var styleKey = 'style';
|
||||||
styleVal = 'display: inline !important',
|
var styleVal = 'display: inline !important';
|
||||||
|
|
||||||
ensure = function () {
|
|
||||||
|
function ensure() {
|
||||||
|
|
||||||
if (
|
if (
|
||||||
$(selr).text() !== sequence ||
|
$(selr).text() !== sequence ||
|
||||||
|
@ -35,16 +35,17 @@ modulejs.define('view/ensure', ['$', 'config', 'core/event'], function ($, confi
|
||||||
.end()
|
.end()
|
||||||
.prependTo(selb);
|
.prependTo(selb);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
init = function () {
|
function init() {
|
||||||
|
|
||||||
event.sub('ready', function () {
|
event.sub('ready', function () {
|
||||||
|
|
||||||
ensure();
|
ensure();
|
||||||
setInterval(ensure, 60000);
|
setInterval(ensure, 60000);
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
init();
|
init();
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
modulejs.define('view/items', ['_', '$', 'core/settings', 'core/resource', 'core/format', 'core/event', 'core/location'], function (_, $, allsettings, resource, format, event, location) {
|
modulejs.define('view/items', ['_', '$', 'core/settings', 'core/resource', 'core/format', 'core/event', 'core/location'], function (_, $, allsettings, resource, format, event, location) {
|
||||||
|
|
||||||
var settings = _.extend({
|
var settings = _.extend({
|
||||||
|
@ -6,9 +5,8 @@ modulejs.define('view/items', ['_', '$', 'core/settings', 'core/resource', 'core
|
||||||
hideFolders: false,
|
hideFolders: false,
|
||||||
hideParentFolder: false,
|
hideParentFolder: false,
|
||||||
setParentFolderLabels: false
|
setParentFolderLabels: false
|
||||||
}, allsettings.view),
|
}, allsettings.view);
|
||||||
|
var itemTemplate =
|
||||||
itemTemplate =
|
|
||||||
'<li class="item">' +
|
'<li class="item">' +
|
||||||
'<a>' +
|
'<a>' +
|
||||||
'<span class="icon square"><img/></span>' +
|
'<span class="icon square"><img/></span>' +
|
||||||
|
@ -17,9 +15,9 @@ modulejs.define('view/items', ['_', '$', 'core/settings', 'core/resource', 'core
|
||||||
'<span class="date"/>' +
|
'<span class="date"/>' +
|
||||||
'<span class="size"/>' +
|
'<span class="size"/>' +
|
||||||
'</a>' +
|
'</a>' +
|
||||||
'</li>',
|
'</li>';
|
||||||
hintTemplate = '<span class="hint"/>',
|
var hintTemplate = '<span class="hint"/>';
|
||||||
contentTemplate =
|
var contentTemplate =
|
||||||
'<div id="content">' +
|
'<div id="content">' +
|
||||||
'<div id="view">' +
|
'<div id="view">' +
|
||||||
'<ul id="items" class="clearfix">' +
|
'<ul id="items" class="clearfix">' +
|
||||||
|
@ -32,20 +30,21 @@ modulejs.define('view/items', ['_', '$', 'core/settings', 'core/resource', 'core
|
||||||
'</ul>' +
|
'</ul>' +
|
||||||
'<div class="empty l10n-empty"/>' +
|
'<div class="empty l10n-empty"/>' +
|
||||||
'</div>' +
|
'</div>' +
|
||||||
'</div>',
|
'</div>';
|
||||||
|
|
||||||
update = function (item, force) {
|
|
||||||
|
function update(item, force) {
|
||||||
|
|
||||||
if (!force && item.$view) {
|
if (!force && item.$view) {
|
||||||
return item.$view;
|
return item.$view;
|
||||||
}
|
}
|
||||||
|
|
||||||
var $html = $(itemTemplate),
|
var $html = $(itemTemplate);
|
||||||
$a = $html.find('a'),
|
var $a = $html.find('a');
|
||||||
$iconImg = $html.find('.icon img'),
|
var $iconImg = $html.find('.icon img');
|
||||||
$label = $html.find('.label'),
|
var $label = $html.find('.label');
|
||||||
$date = $html.find('.date'),
|
var $date = $html.find('.date');
|
||||||
$size = $html.find('.size');
|
var $size = $html.find('.size');
|
||||||
|
|
||||||
$html
|
$html
|
||||||
.addClass(item.isFolder() ? 'folder' : 'file')
|
.addClass(item.isFolder() ? 'folder' : 'file')
|
||||||
|
@ -77,24 +76,24 @@ modulejs.define('view/items', ['_', '$', 'core/settings', 'core/resource', 'core
|
||||||
item.$view = $html;
|
item.$view = $html;
|
||||||
|
|
||||||
return $html;
|
return $html;
|
||||||
},
|
}
|
||||||
|
|
||||||
onMouseenter = function () {
|
function onMouseenter() {
|
||||||
|
|
||||||
var item = $(this).closest('.item').data('item');
|
var item = $(this).closest('.item').data('item');
|
||||||
event.pub('item.mouseenter', item);
|
event.pub('item.mouseenter', item);
|
||||||
},
|
}
|
||||||
|
|
||||||
onMouseleave = function () {
|
function onMouseleave() {
|
||||||
|
|
||||||
var item = $(this).closest('.item').data('item');
|
var item = $(this).closest('.item').data('item');
|
||||||
event.pub('item.mouseleave', item);
|
event.pub('item.mouseleave', item);
|
||||||
},
|
}
|
||||||
|
|
||||||
onLocationChanged = function (item) {
|
function onLocationChanged(item) {
|
||||||
|
|
||||||
var $items = $('#items'),
|
var $items = $('#items');
|
||||||
$empty = $('#view').find('.empty');
|
var $empty = $('#view').find('.empty');
|
||||||
|
|
||||||
$items.find('.item').remove();
|
$items.find('.item').remove();
|
||||||
|
|
||||||
|
@ -116,12 +115,12 @@ modulejs.define('view/items', ['_', '$', 'core/settings', 'core/resource', 'core
|
||||||
}
|
}
|
||||||
|
|
||||||
$('html,body').scrollLeft(0).scrollTop(0);
|
$('html,body').scrollLeft(0).scrollTop(0);
|
||||||
},
|
}
|
||||||
|
|
||||||
onLocationRefreshed = function (item, added, removed) {
|
function onLocationRefreshed(item, added, removed) {
|
||||||
|
|
||||||
var $items = $('#items'),
|
var $items = $('#items');
|
||||||
$empty = $('#view').find('.empty');
|
var $empty = $('#view').find('.empty');
|
||||||
|
|
||||||
_.each(added, function (item) {
|
_.each(added, function (item) {
|
||||||
|
|
||||||
|
@ -142,14 +141,14 @@ modulejs.define('view/items', ['_', '$', 'core/settings', 'core/resource', 'core
|
||||||
} else {
|
} else {
|
||||||
$empty.hide();
|
$empty.hide();
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
init = function () {
|
function init() {
|
||||||
|
|
||||||
var $content = $(contentTemplate),
|
var $content = $(contentTemplate);
|
||||||
$view = $content.find('#view'),
|
var $view = $content.find('#view');
|
||||||
$items = $view.find('#items'),
|
var $items = $view.find('#items');
|
||||||
$emtpy = $view.find('.empty').hide();
|
var $emtpy = $view.find('.empty').hide();
|
||||||
|
|
||||||
format.setDefaultMetric(settings.binaryPrefix);
|
format.setDefaultMetric(settings.binaryPrefix);
|
||||||
|
|
||||||
|
@ -161,7 +160,8 @@ modulejs.define('view/items', ['_', '$', 'core/settings', 'core/resource', 'core
|
||||||
event.sub('location.refreshed', onLocationRefreshed);
|
event.sub('location.refreshed', onLocationRefreshed);
|
||||||
|
|
||||||
$content.appendTo('body');
|
$content.appendTo('body');
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
init();
|
init();
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
modulejs.define('view/spacing', ['_', '$', 'core/settings', 'core/event'], function (_, $, allsettings, event) {
|
modulejs.define('view/spacing', ['_', '$', 'core/settings', 'core/event'], function (_, $, allsettings, event) {
|
||||||
|
|
||||||
var settings = _.extend({
|
var settings = _.extend({
|
||||||
|
@ -7,17 +6,18 @@ modulejs.define('view/spacing', ['_', '$', 'core/settings', 'core/event'], funct
|
||||||
right: 'auto',
|
right: 'auto',
|
||||||
bottom: 50,
|
bottom: 50,
|
||||||
left: 'auto'
|
left: 'auto'
|
||||||
}, allsettings.spacing),
|
}, allsettings.spacing);
|
||||||
|
|
||||||
adjustSpacing = function () {
|
|
||||||
|
function adjustSpacing() {
|
||||||
|
|
||||||
$('#content').css({
|
$('#content').css({
|
||||||
'margin-top': settings.top + $('#topbar').outerHeight(),
|
'margin-top': settings.top + $('#topbar').outerHeight(),
|
||||||
'margin-bottom': settings.bottom + $('#bottombar').outerHeight()
|
'margin-bottom': settings.bottom + $('#bottombar').outerHeight()
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
|
|
||||||
init = function () {
|
function init() {
|
||||||
|
|
||||||
$('#content').css({
|
$('#content').css({
|
||||||
'max-width': settings.maxWidth,
|
'max-width': settings.maxWidth,
|
||||||
|
@ -27,7 +27,8 @@ modulejs.define('view/spacing', ['_', '$', 'core/settings', 'core/event'], funct
|
||||||
|
|
||||||
event.sub('ready', adjustSpacing);
|
event.sub('ready', adjustSpacing);
|
||||||
$(window).on('resize', adjustSpacing);
|
$(window).on('resize', adjustSpacing);
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
init();
|
init();
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,47 +1,42 @@
|
||||||
|
|
||||||
modulejs.define('view/viewmode', ['_', '$', 'core/settings', 'core/resource', 'core/store', 'core/event'], function (_, $, allsettings, resource, store, event) {
|
modulejs.define('view/viewmode', ['_', '$', 'core/settings', 'core/resource', 'core/store', 'core/event'], function (_, $, allsettings, resource, store, event) {
|
||||||
|
|
||||||
var modes = ['details', 'grid', 'icons'],
|
var modes = ['details', 'grid', 'icons'];
|
||||||
sizes = [16, 24, 32, 48, 64, 96, 128, 192, 256, 384],
|
var sizes = [16, 24, 32, 48, 64, 96, 128, 192, 256, 384];
|
||||||
|
var settings = _.extend({}, {
|
||||||
settings = _.extend({}, {
|
|
||||||
modes: modes,
|
modes: modes,
|
||||||
sizes: sizes
|
sizes: sizes
|
||||||
}, allsettings.view),
|
}, allsettings.view);
|
||||||
|
var storekey = 'viewmode';
|
||||||
storekey = 'viewmode',
|
var menuIsVisible = false;
|
||||||
menuIsVisible = false,
|
var sidebarToggleTemplate =
|
||||||
|
|
||||||
sidebarToggleTemplate =
|
|
||||||
'<li id="menu-toggle" class="view">' +
|
'<li id="menu-toggle" class="view">' +
|
||||||
'<a href="#">' +
|
'<a href="#">' +
|
||||||
'<img src="' + resource.image('settings') + '" alt="settings"/>' +
|
'<img src="' + resource.image('settings') + '" alt="settings"/>' +
|
||||||
'</a>' +
|
'</a>' +
|
||||||
'</li>',
|
'</li>';
|
||||||
|
var modeTemplate =
|
||||||
modeTemplate =
|
|
||||||
'<div id="view-[MODE]" class="view">' +
|
'<div id="view-[MODE]" class="view">' +
|
||||||
'<a href="#">' +
|
'<a href="#">' +
|
||||||
'<img src="' + resource.image('view-[MODE]') + '" alt="view-[MODE]"/>' +
|
'<img src="' + resource.image('view-[MODE]') + '" alt="view-[MODE]"/>' +
|
||||||
'</a>' +
|
'</a>' +
|
||||||
'</div>',
|
'</div>';
|
||||||
|
var sizeTemplate =
|
||||||
|
'<input id="view-size" type="range" min="0" max="0" value="0">';
|
||||||
|
|
||||||
sizeTemplate =
|
|
||||||
'<input id="view-size" type="range" min="0" max="0" value="0">',
|
|
||||||
|
|
||||||
adjustSpacing = function () {
|
function adjustSpacing() {
|
||||||
|
|
||||||
var contentWidth = $('#content').width(),
|
var contentWidth = $('#content').width();
|
||||||
$view = $('#view'),
|
var $view = $('#view');
|
||||||
itemWidth = ($view.hasClass('view-icons') || $view.hasClass('view-grid')) ? ($view.find('.item').eq(0).outerWidth(true) || 1) : 1;
|
var itemWidth = ($view.hasClass('view-icons') || $view.hasClass('view-grid')) ? ($view.find('.item').eq(0).outerWidth(true) || 1) : 1;
|
||||||
|
|
||||||
$view.width(Math.floor(contentWidth / itemWidth) * itemWidth);
|
$view.width(Math.floor(contentWidth / itemWidth) * itemWidth);
|
||||||
},
|
}
|
||||||
|
|
||||||
update = function (mode, size) {
|
function update(mode, size) {
|
||||||
|
|
||||||
var $view = $('#view'),
|
var $view = $('#view');
|
||||||
stored = store.get(storekey);
|
var stored = store.get(storekey);
|
||||||
|
|
||||||
mode = mode || stored && stored.mode;
|
mode = mode || stored && stored.mode;
|
||||||
size = size || stored && stored.size;
|
size = size || stored && stored.size;
|
||||||
|
@ -70,14 +65,14 @@ modulejs.define('view/viewmode', ['_', '$', 'core/settings', 'core/resource', 'c
|
||||||
$('#view-size').val(_.indexOf(_.intersection(sizes, settings.sizes), size));
|
$('#view-size').val(_.indexOf(_.intersection(sizes, settings.sizes), size));
|
||||||
|
|
||||||
adjustSpacing();
|
adjustSpacing();
|
||||||
},
|
}
|
||||||
|
|
||||||
init = function () {
|
function init() {
|
||||||
|
|
||||||
var $sidebar = $('#sidebar'),
|
var $sidebar = $('#sidebar');
|
||||||
$settings = $('#settings'),
|
var $settings = $('#settings');
|
||||||
$viewBlock = $('<div class="block"/>'),
|
var $viewBlock = $('<div class="block"/>');
|
||||||
max;
|
var max;
|
||||||
|
|
||||||
$(sidebarToggleTemplate)
|
$(sidebarToggleTemplate)
|
||||||
.on('click', 'a', function (event) {
|
.on('click', 'a', function (event) {
|
||||||
|
@ -123,7 +118,8 @@ modulejs.define('view/viewmode', ['_', '$', 'core/settings', 'core/resource', 'c
|
||||||
|
|
||||||
event.sub('location.changed', adjustSpacing);
|
event.sub('location.changed', adjustSpacing);
|
||||||
$(window).on('resize', adjustSpacing);
|
$(window).on('resize', adjustSpacing);
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
init();
|
init();
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
// other libs
|
// other libs
|
||||||
// ----------
|
// ----------
|
||||||
// @include "lib/modernizr-*.js"
|
// @include "lib/modernizr-*.js"
|
||||||
|
@ -16,7 +15,7 @@
|
||||||
// app
|
// app
|
||||||
// ---
|
// ---
|
||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
/*global jQuery, marked, Modernizr, moment, Prism, _ */
|
/*global jQuery, marked, Modernizr, moment, Prism, _ */
|
||||||
modulejs.define('$', function () { return jQuery; });
|
modulejs.define('$', function () { return jQuery; });
|
||||||
|
@ -28,10 +27,10 @@
|
||||||
|
|
||||||
// @include "inc/**/*.js"
|
// @include "inc/**/*.js"
|
||||||
|
|
||||||
var $ = jQuery,
|
var $ = jQuery;
|
||||||
module = $('script[data-module]').data('module'),
|
var module = $('script[data-module]').data('module');
|
||||||
data = {action: 'get', setup: true, options: true, types: true, theme: true, langs: true},
|
var data = {action: 'get', setup: true, options: true, types: true, theme: true, langs: true};
|
||||||
url;
|
var url;
|
||||||
|
|
||||||
if ($('html').hasClass('no-browser')) {
|
if ($('html').hasClass('no-browser')) {
|
||||||
return;
|
return;
|
||||||
|
@ -56,5 +55,4 @@
|
||||||
modulejs.define('config', config);
|
modulejs.define('config', config);
|
||||||
$(function () { modulejs.require(module); });
|
$(function () { modulejs.require(module); });
|
||||||
});
|
});
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
|
|
@ -1,11 +1,8 @@
|
||||||
doctype html
|
doctype html
|
||||||
//if lt IE 10
|
<!--[if lt IE 10]><html class="no-js no-browser" lang="en"><![endif]-->
|
||||||
<html class="no-js no-browser" lang="en">
|
<!--[if gt IE 9]><!--><html class="no-js browser" lang="en"><!--<![endif]-->
|
||||||
//[if gt IE 9]><!
|
|
||||||
html.no-js.browser( lang="en" )
|
|
||||||
//<![endif]
|
|
||||||
|
|
||||||
head
|
head
|
||||||
meta( charset="utf-8" )
|
meta( charset="utf-8" )
|
||||||
meta( http-equiv="X-UA-Compatible", content="IE=edge" )
|
meta( http-equiv="X-UA-Compatible", content="IE=edge" )
|
||||||
title {{pkg.name}} {{pkg.version}} Server Setup
|
title {{pkg.name}} {{pkg.version}} Server Setup
|
||||||
|
@ -16,7 +13,7 @@ html.no-js.browser( lang="en" )
|
||||||
link( rel="stylesheet", href="client/css/styles.css" )
|
link( rel="stylesheet", href="client/css/styles.css" )
|
||||||
script( src="client/js/scripts.js", data-module="info" )
|
script( src="client/js/scripts.js", data-module="info" )
|
||||||
|
|
||||||
body#h5ai-info
|
body#h5ai-info
|
||||||
|
|
||||||
h1
|
h1
|
||||||
a( href="{{pkg.homepage}}" ) {{pkg.name}}
|
a( href="{{pkg.homepage}}" ) {{pkg.name}}
|
||||||
|
@ -41,3 +38,5 @@ html.no-js.browser( lang="en" )
|
||||||
a( href="{{pkg.homepage}}", title="{{pkg.name}} {{pkg.version}} · {{pkg.description}}" )
|
a( href="{{pkg.homepage}}", title="{{pkg.name}} {{pkg.version}} · {{pkg.description}}" )
|
||||||
| powered by {{pkg.name}} {{pkg.version}}
|
| powered by {{pkg.name}} {{pkg.version}}
|
||||||
span.center
|
span.center
|
||||||
|
|
||||||
|
</html>
|
||||||
|
|
|
@ -4,13 +4,10 @@
|
||||||
|
|
||||||
<?php header("Content-type: text/html;charset=utf-8"); ?>
|
<?php header("Content-type: text/html;charset=utf-8"); ?>
|
||||||
doctype html
|
doctype html
|
||||||
//if lt IE 10
|
<!--[if lt IE 10]><html class="no-js no-browser" lang="en"><![endif]-->
|
||||||
<html class="no-js no-browser" lang="en">
|
<!--[if gt IE 9]><!--><html class="no-js browser" lang="en"><!--<![endif]-->
|
||||||
//[if gt IE 9]><!
|
|
||||||
html.no-js.browser( lang="en" )
|
|
||||||
//<![endif]
|
|
||||||
|
|
||||||
head
|
head
|
||||||
meta( charset="utf-8" )
|
meta( charset="utf-8" )
|
||||||
meta( http-equiv="X-UA-Compatible", content="IE=edge" )
|
meta( http-equiv="X-UA-Compatible", content="IE=edge" )
|
||||||
title index · powered by {{pkg.name}} {{pkg.version}} ({{pkg.homepage}})
|
title index · powered by {{pkg.name}} {{pkg.version}} ({{pkg.homepage}})
|
||||||
|
@ -21,7 +18,7 @@ html.no-js.browser( lang="en" )
|
||||||
link( rel="stylesheet", href!="#{app_href}client/css/styles.css" )
|
link( rel="stylesheet", href!="#{app_href}client/css/styles.css" )
|
||||||
script( src!="#{app_href}client/js/scripts.js", data-module="main" )
|
script( src!="#{app_href}client/js/scripts.js", data-module="main" )
|
||||||
|
|
||||||
body
|
body
|
||||||
|
|
||||||
div#topbar.clearfix
|
div#topbar.clearfix
|
||||||
ul#navbar
|
ul#navbar
|
||||||
|
@ -43,3 +40,5 @@ html.no-js.browser( lang="en" )
|
||||||
div#settings
|
div#settings
|
||||||
|
|
||||||
div#fallback !{fallback}
|
div#fallback !{fallback}
|
||||||
|
|
||||||
|
</html>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue