mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-05-24 20:14:37 -04:00
Clean code.
This commit is contained in:
parent
ba10f70b12
commit
8951732f3c
42 changed files with 2547 additions and 2572 deletions
30
mkrfile.js
30
mkrfile.js
|
@ -14,21 +14,19 @@ var build = path.join(root, 'build');
|
|||
var mapSrc = $.map.p(src, build).s('.less', '.css').s('.jade', '');
|
||||
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 {
|
||||
var lines = out.trim().split(/\r?\n/);
|
||||
callback('+' + ('000' + lines.length).substr(-3) + '~' + lines[0].substring(0, 7));
|
||||
} catch (e) {
|
||||
callback('+X');
|
||||
}
|
||||
});
|
||||
};
|
||||
try {
|
||||
var lines = out.trim().split(/\r?\n/);
|
||||
callback('+' + ('000' + lines.length).substr(-3) + '~' + lines[0].substring(0, 7));
|
||||
} catch (e) {
|
||||
callback('+X');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
$.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 env = {pkg: pkg};
|
||||
|
||||
$(src + ': _h5ai/client/js/*.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 env = {pkg: pkg};
|
||||
|
||||
$(src + ': _h5ai/client/js/*.js')
|
||||
.newerThan(mapSrc, $(src + ': _h5ai/client/js/**'))
|
||||
|
|
|
@ -1,41 +1,42 @@
|
|||
|
||||
modulejs.define('core/event', ['_'], function (_) {
|
||||
|
||||
var slice = Array.prototype.slice,
|
||||
subscriptions = {},
|
||||
var slice = Array.prototype.slice;
|
||||
var subscriptions = {};
|
||||
|
||||
sub = function (topic, callback) {
|
||||
|
||||
if (_.isString(topic) && _.isFunction(callback)) {
|
||||
function sub(topic, callback) {
|
||||
|
||||
if (!subscriptions[topic]) {
|
||||
subscriptions[topic] = [];
|
||||
}
|
||||
subscriptions[topic].push(callback);
|
||||
if (_.isString(topic) && _.isFunction(callback)) {
|
||||
|
||||
if (!subscriptions[topic]) {
|
||||
subscriptions[topic] = [];
|
||||
}
|
||||
},
|
||||
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);
|
||||
|
||||
// console.log('EVENT PUB', topic, args);
|
||||
if (_.isString(topic) && subscriptions[topic]) {
|
||||
// console.log('EVENT PUB', topic, args);
|
||||
if (_.isString(topic) && subscriptions[topic]) {
|
||||
|
||||
_.each(subscriptions[topic], function (callback) {
|
||||
_.each(subscriptions[topic], function (callback) {
|
||||
|
||||
callback.apply(topic, args);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
callback.apply(topic, args);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
sub: sub,
|
||||
|
|
|
@ -1,51 +1,52 @@
|
|||
|
||||
modulejs.define('core/format', ['_', 'moment'], function (_, moment) {
|
||||
|
||||
var decimalMetric = {
|
||||
t: 1000.0,
|
||||
k: 1000.0,
|
||||
u: ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
|
||||
},
|
||||
binaryMetric = {
|
||||
};
|
||||
var binaryMetric = {
|
||||
t: 1024.0,
|
||||
k: 1024.0,
|
||||
u: ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB']
|
||||
},
|
||||
defaultMetric = decimalMetric,
|
||||
defaultDateFormat = 'YYYY-MM-DD HH:mm',
|
||||
|
||||
setDefaultMetric = function (useBinaryMetric) {
|
||||
|
||||
defaultMetric = useBinaryMetric ? binaryMetric : decimalMetric;
|
||||
},
|
||||
|
||||
formatSize = function (size, metric) {
|
||||
|
||||
metric = metric || defaultMetric;
|
||||
|
||||
if (!_.isNumber(size) || size < 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
var i = 0,
|
||||
maxI = metric.u.length - 1;
|
||||
|
||||
while (size >= metric.t && i < maxI) {
|
||||
size /= metric.k;
|
||||
i += 1;
|
||||
}
|
||||
return (i <= 1 ? Math.round(size) : size.toFixed(1)).toString() + ' ' + metric.u[i];
|
||||
},
|
||||
|
||||
setDefaultDateFormat = function (dateFormat) {
|
||||
|
||||
defaultDateFormat = dateFormat;
|
||||
},
|
||||
|
||||
formatDate = function (millis) {
|
||||
|
||||
return _.isNumber(millis) && millis ? moment(millis).format(defaultDateFormat) : '';
|
||||
};
|
||||
var defaultMetric = decimalMetric;
|
||||
var defaultDateFormat = 'YYYY-MM-DD HH:mm';
|
||||
|
||||
|
||||
function setDefaultMetric(useBinaryMetric) {
|
||||
|
||||
defaultMetric = useBinaryMetric ? binaryMetric : decimalMetric;
|
||||
}
|
||||
|
||||
function formatSize(size, metric) {
|
||||
|
||||
metric = metric || defaultMetric;
|
||||
|
||||
if (!_.isNumber(size) || size < 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
var i = 0;
|
||||
var maxI = metric.u.length - 1;
|
||||
|
||||
while (size >= metric.t && i < maxI) {
|
||||
size /= metric.k;
|
||||
i += 1;
|
||||
}
|
||||
return (i <= 1 ? Math.round(size) : size.toFixed(1)).toString() + ' ' + metric.u[i];
|
||||
}
|
||||
|
||||
function setDefaultDateFormat(dateFormat) {
|
||||
|
||||
defaultDateFormat = dateFormat;
|
||||
}
|
||||
|
||||
function formatDate(millis) {
|
||||
|
||||
return _.isNumber(millis) && millis ? moment(millis).format(defaultDateFormat) : '';
|
||||
}
|
||||
|
||||
|
||||
return {
|
||||
setDefaultMetric: setDefaultMetric,
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
modulejs.define('core/langs', ['config', '_'], function (config, _) {
|
||||
|
||||
return _.extend({}, config.langs);
|
||||
|
|
|
@ -1,184 +1,180 @@
|
|||
|
||||
modulejs.define('core/location', ['_', 'modernizr', 'core/settings', 'core/event', 'core/notify'], function (_, modernizr, allsettings, event, notify) {
|
||||
|
||||
var settings = _.extend({
|
||||
smartBrowsing: 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
|
||||
.replace(/\/+/g, '/')
|
||||
|
||||
return href
|
||||
.replace(/\/+/g, '/')
|
||||
.replace(/ /g, '%20')
|
||||
.replace(/!/g, '%21')
|
||||
.replace(/#/g, '%23')
|
||||
.replace(/\$/g, '%24')
|
||||
.replace(/&/g, '%26')
|
||||
.replace(/'/g, '%27')
|
||||
.replace(/\(/g, '%28')
|
||||
.replace(/\)/g, '%29')
|
||||
.replace(/\*/g, '%2A')
|
||||
.replace(/\+/g, '%2B')
|
||||
.replace(/\,/g, '%2C')
|
||||
// .replace(/\//g, '%2F')
|
||||
.replace(/:/g, '%3A')
|
||||
.replace(/;/g, '%3B')
|
||||
.replace(/=/g, '%3D')
|
||||
.replace(/\?/g, '%3F')
|
||||
.replace(/@/g, '%40')
|
||||
.replace(/\[/g, '%5B')
|
||||
.replace(/\]/g, '%5D');
|
||||
}
|
||||
|
||||
.replace(/ /g, '%20')
|
||||
.replace(/!/g, '%21')
|
||||
.replace(/#/g, '%23')
|
||||
.replace(/\$/g, '%24')
|
||||
.replace(/&/g, '%26')
|
||||
.replace(/'/g, '%27')
|
||||
.replace(/\(/g, '%28')
|
||||
.replace(/\)/g, '%29')
|
||||
.replace(/\*/g, '%2A')
|
||||
.replace(/\+/g, '%2B')
|
||||
.replace(/\,/g, '%2C')
|
||||
// .replace(/\//g, '%2F')
|
||||
.replace(/:/g, '%3A')
|
||||
.replace(/;/g, '%3B')
|
||||
.replace(/=/g, '%3D')
|
||||
.replace(/\?/g, '%3F')
|
||||
.replace(/@/g, '%40')
|
||||
.replace(/\[/g, '%5B')
|
||||
.replace(/\]/g, '%5D');
|
||||
},
|
||||
function uriToPathname(uri) {
|
||||
|
||||
reUriToPathname = /^.*:\/\/[^\/]*|[^\/]*$/g,
|
||||
uriToPathname = function (uri) {
|
||||
return uri.replace(reUriToPathname, '');
|
||||
}
|
||||
|
||||
return uri.replace(reUriToPathname, '');
|
||||
},
|
||||
var hrefsAreDecoded = (function () {
|
||||
|
||||
hrefsAreDecoded = (function () {
|
||||
|
||||
var testpathname = '/a b',
|
||||
a = doc.createElement('a');
|
||||
var testpathname = '/a b';
|
||||
var a = doc.createElement('a');
|
||||
|
||||
a.href = testpathname;
|
||||
return uriToPathname(a.href) === testpathname;
|
||||
}()),
|
||||
}());
|
||||
|
||||
encodedHref = function (href) {
|
||||
function encodedHref(href) {
|
||||
|
||||
var a = doc.createElement('a'),
|
||||
location;
|
||||
var a = doc.createElement('a');
|
||||
var location;
|
||||
|
||||
a.href = href;
|
||||
location = uriToPathname(a.href);
|
||||
a.href = href;
|
||||
location = uriToPathname(a.href);
|
||||
|
||||
if (hrefsAreDecoded) {
|
||||
location = encodeURIComponent(location).replace(/%2F/ig, '/');
|
||||
}
|
||||
if (hrefsAreDecoded) {
|
||||
location = encodeURIComponent(location).replace(/%2F/ig, '/');
|
||||
}
|
||||
|
||||
return forceEncoding(location);
|
||||
};
|
||||
return forceEncoding(location);
|
||||
}
|
||||
|
||||
function getDomain() {
|
||||
|
||||
var absHref = null,
|
||||
return doc.domain;
|
||||
}
|
||||
|
||||
getDomain = function () {
|
||||
function getAbsHref() {
|
||||
|
||||
return doc.domain;
|
||||
},
|
||||
return absHref;
|
||||
}
|
||||
|
||||
getAbsHref = function () {
|
||||
function getItem() {
|
||||
|
||||
return absHref;
|
||||
},
|
||||
return modulejs.require('model/item').get(absHref);
|
||||
}
|
||||
|
||||
getItem = function () {
|
||||
function load(callback) {
|
||||
|
||||
return modulejs.require('model/item').get(absHref);
|
||||
},
|
||||
modulejs.require('core/server').request({action: 'get', items: true, itemsHref: absHref, itemsWhat: 1}, function (json) {
|
||||
|
||||
load = function (callback) {
|
||||
var Item = modulejs.require('model/item');
|
||||
var item = Item.get(absHref);
|
||||
|
||||
modulejs.require('core/server').request({action: 'get', items: true, itemsHref: absHref, itemsWhat: 1}, function (json) {
|
||||
if (json) {
|
||||
|
||||
var Item = modulejs.require('model/item'),
|
||||
item = Item.get(absHref);
|
||||
var found = {};
|
||||
|
||||
if (json) {
|
||||
_.each(json.items, function (jsonItem) {
|
||||
|
||||
var found = {};
|
||||
var e = Item.get(jsonItem.absHref, jsonItem.time, jsonItem.size, jsonItem.is_managed, jsonItem.content, jsonItem.md5, jsonItem.sha1);
|
||||
found[e.absHref] = true;
|
||||
});
|
||||
|
||||
_.each(json.items, function (jsonItem) {
|
||||
_.each(item.content, function (e) {
|
||||
|
||||
var e = Item.get(jsonItem.absHref, jsonItem.time, jsonItem.size, jsonItem.is_managed, jsonItem.content, jsonItem.md5, jsonItem.sha1);
|
||||
found[e.absHref] = true;
|
||||
});
|
||||
|
||||
_.each(item.content, function (e) {
|
||||
|
||||
if (!found[e.absHref]) {
|
||||
Item.remove(e.absHref);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (_.isFunction(callback)) {
|
||||
callback(item);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
setLocation = function (newAbsHref, keepBrowserUrl) {
|
||||
|
||||
event.pub('location.beforeChange');
|
||||
|
||||
newAbsHref = encodedHref(newAbsHref);
|
||||
|
||||
if (absHref !== newAbsHref) {
|
||||
absHref = newAbsHref;
|
||||
|
||||
if (history) {
|
||||
if (keepBrowserUrl) {
|
||||
history.replaceState({absHref: absHref}, '', absHref);
|
||||
} else {
|
||||
history.pushState({absHref: absHref}, '', absHref);
|
||||
if (!found[e.absHref]) {
|
||||
Item.remove(e.absHref);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (_.isFunction(callback)) {
|
||||
callback(item);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function setLocation(newAbsHref, keepBrowserUrl) {
|
||||
|
||||
event.pub('location.beforeChange');
|
||||
|
||||
newAbsHref = encodedHref(newAbsHref);
|
||||
|
||||
if (absHref !== newAbsHref) {
|
||||
absHref = newAbsHref;
|
||||
|
||||
if (history) {
|
||||
if (keepBrowserUrl) {
|
||||
history.replaceState({absHref: absHref}, '', absHref);
|
||||
} else {
|
||||
history.pushState({absHref: absHref}, '', absHref);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var item = getItem();
|
||||
if (item.isLoaded) {
|
||||
event.pub('location.changed', item);
|
||||
refresh();
|
||||
} else {
|
||||
notify.set('loading...');
|
||||
load(function () {
|
||||
item.isLoaded = true;
|
||||
notify.set();
|
||||
event.pub('location.changed', item);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
refresh = function () {
|
||||
|
||||
var item = getItem(),
|
||||
oldItems = _.values(item.content);
|
||||
|
||||
event.pub('location.beforeRefresh');
|
||||
|
||||
var item = getItem();
|
||||
if (item.isLoaded) {
|
||||
event.pub('location.changed', item);
|
||||
refresh();
|
||||
} else {
|
||||
notify.set('loading...');
|
||||
load(function () {
|
||||
|
||||
var newItems = _.values(item.content),
|
||||
added = _.difference(newItems, oldItems),
|
||||
removed = _.difference(oldItems, newItems);
|
||||
|
||||
event.pub('location.refreshed', item, added, removed);
|
||||
item.isLoaded = true;
|
||||
notify.set();
|
||||
event.pub('location.changed', item);
|
||||
});
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
setLink = function ($el, item) {
|
||||
function refresh() {
|
||||
|
||||
$el.attr('href', item.absHref);
|
||||
var item = getItem();
|
||||
var oldItems = _.values(item.content);
|
||||
|
||||
if (history && item.isFolder() && item.isManaged) {
|
||||
$el.on('click', function () {
|
||||
event.pub('location.beforeRefresh');
|
||||
|
||||
setLocation(item.absHref);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
load(function () {
|
||||
|
||||
if (settings.unmanagedInNewWindow && !item.isManaged) {
|
||||
$el.attr('target', '_blank');
|
||||
}
|
||||
};
|
||||
var newItems = _.values(item.content);
|
||||
var added = _.difference(newItems, oldItems);
|
||||
var removed = _.difference(oldItems, newItems);
|
||||
|
||||
event.pub('location.refreshed', item, added, removed);
|
||||
});
|
||||
}
|
||||
|
||||
function setLink($el, item) {
|
||||
|
||||
$el.attr('href', item.absHref);
|
||||
|
||||
if (history && item.isFolder() && item.isManaged) {
|
||||
$el.on('click', function () {
|
||||
|
||||
setLocation(item.absHref);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
if (settings.unmanagedInNewWindow && !item.isManaged) {
|
||||
$el.attr('target', '_blank');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (history) {
|
||||
|
@ -190,7 +186,6 @@ modulejs.define('core/location', ['_', 'modernizr', 'core/settings', 'core/event
|
|||
};
|
||||
}
|
||||
|
||||
|
||||
event.sub('ready', function () {
|
||||
|
||||
setLocation(document.location.href, true);
|
||||
|
|
|
@ -1,23 +1,17 @@
|
|||
|
||||
modulejs.define('core/notify', ['$'], function ($) {
|
||||
|
||||
var template = '<div id="notify"/>',
|
||||
var template = '<div id="notify"/>';
|
||||
|
||||
set = function (content) {
|
||||
function set(content) {
|
||||
|
||||
if (content) {
|
||||
$('#notify').stop(true, true).html(content).fadeIn(400);
|
||||
} else {
|
||||
$('#notify').stop(true, true).fadeOut(400);
|
||||
}
|
||||
},
|
||||
if (content) {
|
||||
$('#notify').stop(true, true).html(content).fadeIn(400);
|
||||
} else {
|
||||
$('#notify').stop(true, true).fadeOut(400);
|
||||
}
|
||||
}
|
||||
|
||||
init = function () {
|
||||
|
||||
$(template).hide().appendTo('body');
|
||||
};
|
||||
|
||||
init();
|
||||
$(template).hide().appendTo('body');
|
||||
|
||||
return {
|
||||
set: set
|
||||
|
|
|
@ -1,38 +1,38 @@
|
|||
|
||||
modulejs.define('core/resource', ['_', '$', 'config', 'core/settings'], function (_, $, config, settings) {
|
||||
|
||||
var win = window,
|
||||
appHref = settings.appHref,
|
||||
imagesHref = appHref + 'client/images/',
|
||||
fallbackHref = appHref + 'client/images/fallback/',
|
||||
themesHref = appHref + 'client/themes/',
|
||||
scriptsHref = appHref + 'client/js/',
|
||||
fallbacks = ['file', 'folder', 'folder-page', 'folder-parent', 'ar', 'aud', 'bin', 'img', 'txt', 'vid'],
|
||||
var win = window;
|
||||
var appHref = settings.appHref;
|
||||
var imagesHref = appHref + 'client/images/';
|
||||
var fallbackHref = appHref + 'client/images/fallback/';
|
||||
var themesHref = appHref + 'client/themes/';
|
||||
var scriptsHref = appHref + 'client/js/';
|
||||
var fallbacks = ['file', 'folder', 'folder-page', 'folder-parent', 'ar', 'aud', 'bin', 'img', 'txt', 'vid'];
|
||||
|
||||
image = function (id) {
|
||||
|
||||
return imagesHref + id + '.svg';
|
||||
},
|
||||
function image(id) {
|
||||
|
||||
icon = function (id) {
|
||||
return imagesHref + id + '.svg';
|
||||
}
|
||||
|
||||
var baseId = id.split('-')[0],
|
||||
href = config.theme[id] || config.theme[baseId];
|
||||
function icon(id) {
|
||||
|
||||
if (href) {
|
||||
return themesHref + href;
|
||||
}
|
||||
var baseId = id.split('-')[0],
|
||||
href = config.theme[id] || config.theme[baseId];
|
||||
|
||||
if (_.indexOf(fallbacks, id) >= 0) {
|
||||
return fallbackHref + id + '.svg';
|
||||
}
|
||||
if (href) {
|
||||
return themesHref + href;
|
||||
}
|
||||
|
||||
if (_.indexOf(fallbacks, baseId) >= 0) {
|
||||
return fallbackHref + baseId + '.svg';
|
||||
}
|
||||
if (_.indexOf(fallbacks, id) >= 0) {
|
||||
return fallbackHref + id + '.svg';
|
||||
}
|
||||
|
||||
return fallbackHref + 'file.svg';
|
||||
};
|
||||
if (_.indexOf(fallbacks, baseId) >= 0) {
|
||||
return fallbackHref + baseId + '.svg';
|
||||
}
|
||||
|
||||
return fallbackHref + 'file.svg';
|
||||
}
|
||||
|
||||
|
||||
return {
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
modulejs.define('core/server', ['$', '_', 'config', 'core/location'], function ($, _, config, location) {
|
||||
|
||||
var server = {
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
modulejs.define('core/settings', ['config', '_'], function (config, _) {
|
||||
|
||||
return _.extend({}, config.options, {
|
||||
|
|
|
@ -1,38 +1,38 @@
|
|||
|
||||
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) {
|
||||
try {
|
||||
return JSON.parse(store[key]);
|
||||
} catch (e) {}
|
||||
}
|
||||
return {};
|
||||
},
|
||||
if (store) {
|
||||
try {
|
||||
return JSON.parse(store[key]);
|
||||
} catch (e) {}
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
save = function (obj) {
|
||||
function save(obj) {
|
||||
|
||||
if (store) {
|
||||
store[key] = JSON.stringify(obj);
|
||||
}
|
||||
},
|
||||
if (store) {
|
||||
store[key] = JSON.stringify(obj);
|
||||
}
|
||||
}
|
||||
|
||||
put = function (key, value) {
|
||||
function put(key, value) {
|
||||
|
||||
var obj = load();
|
||||
obj[key] = value;
|
||||
return save(obj);
|
||||
},
|
||||
var obj = load();
|
||||
obj[key] = value;
|
||||
return save(obj);
|
||||
}
|
||||
|
||||
get = function (key) {
|
||||
function get(key) {
|
||||
|
||||
return load()[key];
|
||||
}
|
||||
|
||||
return load()[key];
|
||||
};
|
||||
|
||||
return {
|
||||
put: put,
|
||||
|
|
|
@ -1,43 +1,44 @@
|
|||
|
||||
modulejs.define('core/types', ['config', '_'], function (config, _) {
|
||||
|
||||
var reEndsWithSlash = /\/$/,
|
||||
regexps = {},
|
||||
var reEndsWithSlash = /\/$/;
|
||||
var regexps = {};
|
||||
|
||||
escapeRegExp = function (sequence) {
|
||||
|
||||
return sequence.replace(/[\-\[\]\/\{\}\(\)\+\?\.\\\^\$]/g, "\\$&");
|
||||
// return sequence.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
|
||||
},
|
||||
function escapeRegExp(sequence) {
|
||||
|
||||
parse = function (types) {
|
||||
return sequence.replace(/[\-\[\]\/\{\}\(\)\+\?\.\\\^\$]/g, "\\$&");
|
||||
// return sequence.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
|
||||
}
|
||||
|
||||
_.each(types, function (patterns, type) {
|
||||
function parse(types) {
|
||||
|
||||
var pattern = '^(' + _.map(patterns, function (p) { return '(' + escapeRegExp(p).replace(/\*/g, '.*') + ')'; }).join('|') + ')$';
|
||||
regexps[type] = new RegExp(pattern, 'i');
|
||||
});
|
||||
},
|
||||
_.each(types, function (patterns, type) {
|
||||
|
||||
getType = function (sequence) {
|
||||
var pattern = '^(' + _.map(patterns, function (p) { return '(' + escapeRegExp(p).replace(/\*/g, '.*') + ')'; }).join('|') + ')$';
|
||||
regexps[type] = new RegExp(pattern, 'i');
|
||||
});
|
||||
}
|
||||
|
||||
if (reEndsWithSlash.test(sequence)) {
|
||||
return 'folder';
|
||||
}
|
||||
function getType(sequence) {
|
||||
|
||||
var slashidx = sequence.lastIndexOf('/'),
|
||||
name = slashidx >= 0 ? sequence.substr(slashidx + 1) : sequence;
|
||||
if (reEndsWithSlash.test(sequence)) {
|
||||
return 'folder';
|
||||
}
|
||||
|
||||
for (var type in regexps) {
|
||||
if (regexps.hasOwnProperty(type)) {
|
||||
if (regexps[type].test(name)) {
|
||||
return type;
|
||||
}
|
||||
var slashidx = sequence.lastIndexOf('/');
|
||||
var name = slashidx >= 0 ? sequence.substr(slashidx + 1) : sequence;
|
||||
|
||||
for (var type in regexps) {
|
||||
if (regexps.hasOwnProperty(type)) {
|
||||
if (regexps[type].test(name)) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 'file';
|
||||
}
|
||||
|
||||
return 'file';
|
||||
};
|
||||
|
||||
parse(_.extend({}, config.types));
|
||||
|
||||
|
|
|
@ -1,42 +1,42 @@
|
|||
|
||||
modulejs.define('ext/autorefresh', ['_', '$', 'core/settings', 'core/event', 'core/location'], function (_, $, allsettings, event, location) {
|
||||
|
||||
var settings = _.extend({
|
||||
enabled: false,
|
||||
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);
|
||||
timeoutId = setTimeout(heartbeat, settings.interval);
|
||||
},
|
||||
clearTimeout(timeoutId);
|
||||
timeoutId = setTimeout(heartbeat, settings.interval);
|
||||
}
|
||||
|
||||
init = function () {
|
||||
function init() {
|
||||
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
}
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
settings.interval = Math.max(1000, settings.interval);
|
||||
settings.interval = Math.max(1000, settings.interval);
|
||||
|
||||
event.sub('location.beforeChange', before);
|
||||
event.sub('location.beforeRefresh', before);
|
||||
event.sub('location.changed', after);
|
||||
event.sub('location.refreshed', after);
|
||||
}
|
||||
|
||||
event.sub('location.beforeChange', before);
|
||||
event.sub('location.beforeRefresh', before);
|
||||
event.sub('location.changed', after);
|
||||
event.sub('location.refreshed', after);
|
||||
};
|
||||
|
||||
init();
|
||||
});
|
||||
|
|
|
@ -1,96 +1,96 @@
|
|||
|
||||
modulejs.define('ext/crumb', ['_', '$', 'core/settings', 'core/resource', 'core/event', 'core/location'], function (_, $, allsettings, resource, event, location) {
|
||||
|
||||
var settings = _.extend({
|
||||
enabled: false
|
||||
}, allsettings.crumb),
|
||||
|
||||
template =
|
||||
}, allsettings.crumb);
|
||||
var template =
|
||||
'<li class="crumb">' +
|
||||
'<a>' +
|
||||
'<img src="' + resource.image('crumb') + '" alt=">"/>' +
|
||||
'<span/>' +
|
||||
'</a>' +
|
||||
'</li>',
|
||||
pageHintTemplate = '<img class="hint" src="' + resource.image('page') + '" alt="has index page"/>',
|
||||
statusHintTemplate = '<span class="hint"/>',
|
||||
'</li>';
|
||||
var pageHintTemplate = '<img class="hint" src="' + resource.image('page') + '" alt="has index page"/>';
|
||||
var statusHintTemplate = '<span class="hint"/>';
|
||||
|
||||
update = function (item, force) {
|
||||
|
||||
if (!force && item.$crumb) {
|
||||
return item.$crumb;
|
||||
}
|
||||
function update(item, force) {
|
||||
|
||||
var $html = $(template),
|
||||
$a = $html.find('a');
|
||||
if (!force && item.$crumb) {
|
||||
return item.$crumb;
|
||||
}
|
||||
|
||||
$html
|
||||
.addClass(item.isFolder() ? 'folder' : 'file')
|
||||
.data('item', item);
|
||||
var $html = $(template);
|
||||
var $a = $html.find('a');
|
||||
|
||||
location.setLink($a, item);
|
||||
$a.find('span').text(item.label).end();
|
||||
$html
|
||||
.addClass(item.isFolder() ? 'folder' : 'file')
|
||||
.data('item', item);
|
||||
|
||||
if (item.isDomain()) {
|
||||
$html.addClass('domain');
|
||||
$a.find('img').attr('src', resource.image('home'));
|
||||
}
|
||||
location.setLink($a, item);
|
||||
$a.find('span').text(item.label).end();
|
||||
|
||||
if (item.isRoot()) {
|
||||
$html.addClass('root');
|
||||
$a.find('img').attr('src', resource.image('home'));
|
||||
}
|
||||
if (item.isDomain()) {
|
||||
$html.addClass('domain');
|
||||
$a.find('img').attr('src', resource.image('home'));
|
||||
}
|
||||
|
||||
if (item.isCurrentFolder()) {
|
||||
if (item.isRoot()) {
|
||||
$html.addClass('root');
|
||||
$a.find('img').attr('src', resource.image('home'));
|
||||
}
|
||||
|
||||
if (item.isCurrentFolder()) {
|
||||
$html.addClass('current');
|
||||
}
|
||||
|
||||
if (!item.isManaged) {
|
||||
$a.append($(pageHintTemplate));
|
||||
}
|
||||
|
||||
if (item.$crumb) {
|
||||
item.$crumb.replaceWith($html);
|
||||
}
|
||||
item.$crumb = $html;
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
function onLocationChanged(item) {
|
||||
|
||||
var crumb = item.getCrumb();
|
||||
var $ul = $('#navbar');
|
||||
var found = false;
|
||||
|
||||
$ul.find('.crumb').each(function () {
|
||||
|
||||
var $html = $(this);
|
||||
if ($html.data('item') === item) {
|
||||
found = true;
|
||||
$html.addClass('current');
|
||||
} else {
|
||||
$html.removeClass('current');
|
||||
}
|
||||
});
|
||||
|
||||
if (!item.isManaged) {
|
||||
$a.append($(pageHintTemplate));
|
||||
}
|
||||
if (!found) {
|
||||
$ul.find('.crumb').remove();
|
||||
_.each(crumb, function (e) {
|
||||
|
||||
if (item.$crumb) {
|
||||
item.$crumb.replaceWith($html);
|
||||
}
|
||||
item.$crumb = $html;
|
||||
|
||||
return $html;
|
||||
},
|
||||
|
||||
onLocationChanged = function (item) {
|
||||
|
||||
var crumb = item.getCrumb(),
|
||||
$ul = $('#navbar'),
|
||||
found = false;
|
||||
|
||||
$ul.find('.crumb').each(function () {
|
||||
|
||||
var $html = $(this);
|
||||
if ($html.data('item') === item) {
|
||||
found = true;
|
||||
$html.addClass('current');
|
||||
} else {
|
||||
$html.removeClass('current');
|
||||
}
|
||||
$ul.append(update(e, true));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
$ul.find('.crumb').remove();
|
||||
_.each(crumb, function (e) {
|
||||
function init() {
|
||||
|
||||
$ul.append(update(e, true));
|
||||
});
|
||||
}
|
||||
},
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
init = function () {
|
||||
event.sub('location.changed', onLocationChanged);
|
||||
}
|
||||
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.sub('location.changed', onLocationChanged);
|
||||
};
|
||||
|
||||
init();
|
||||
});
|
||||
|
|
|
@ -1,61 +1,61 @@
|
|||
|
||||
modulejs.define('ext/custom', ['_', '$', 'marked', 'core/settings', 'core/server', 'core/event', 'core/resource'], function (_, $, marked, allsettings, server, event, resource) {
|
||||
|
||||
var settings = _.extend({
|
||||
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) {
|
||||
|
||||
var has_header, has_footer, data, content;
|
||||
var has_header, has_footer, data, content;
|
||||
|
||||
if (response) {
|
||||
data = response.custom;
|
||||
if (response) {
|
||||
data = response.custom;
|
||||
|
||||
if (data.header) {
|
||||
content = data.header;
|
||||
if (data.header_type === 'md') {
|
||||
content = marked(content);
|
||||
}
|
||||
$header.html(content).stop().slideDown(duration);
|
||||
has_header = true;
|
||||
if (data.header) {
|
||||
content = data.header;
|
||||
if (data.header_type === 'md') {
|
||||
content = marked(content);
|
||||
}
|
||||
$header.html(content).stop().slideDown(duration);
|
||||
has_header = true;
|
||||
}
|
||||
|
||||
if (data.footer) {
|
||||
content = data.footer;
|
||||
if (data.footer_type === 'md') {
|
||||
content = marked(content);
|
||||
}
|
||||
$footer.html(content).stop().slideDown(duration);
|
||||
has_footer = true;
|
||||
if (data.footer) {
|
||||
content = data.footer;
|
||||
if (data.footer_type === 'md') {
|
||||
content = marked(content);
|
||||
}
|
||||
$footer.html(content).stop().slideDown(duration);
|
||||
has_footer = true;
|
||||
}
|
||||
|
||||
if (!has_header) {
|
||||
$header.stop().slideUp(duration);
|
||||
}
|
||||
if (!has_footer) {
|
||||
$footer.stop().slideUp(duration);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
init = function () {
|
||||
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
$header = $('<div id="content-header"/>').hide().prependTo('#content');
|
||||
$footer = $('<div id="content-footer"/>').hide().appendTo('#content');
|
||||
if (!has_header) {
|
||||
$header.stop().slideUp(duration);
|
||||
}
|
||||
if (!has_footer) {
|
||||
$footer.stop().slideUp(duration);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function init() {
|
||||
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
$header = $('<div id="content-header"/>').hide().prependTo('#content');
|
||||
$footer = $('<div id="content-footer"/>').hide().appendTo('#content');
|
||||
|
||||
event.sub('location.changed', onLocationChanged);
|
||||
}
|
||||
|
||||
event.sub('location.changed', onLocationChanged);
|
||||
};
|
||||
|
||||
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) {
|
||||
|
||||
var settings = _.extend({
|
||||
|
@ -6,60 +5,60 @@ modulejs.define('ext/download', ['_', '$', 'core/settings', 'core/resource', 'co
|
|||
type: 'php-tar',
|
||||
packageName: 'package',
|
||||
alwaysVisible: false
|
||||
}, allsettings.download),
|
||||
|
||||
downloadBtnTemplate =
|
||||
}, allsettings.download);
|
||||
var downloadBtnTemplate =
|
||||
'<li id="download">' +
|
||||
'<a href="#">' +
|
||||
'<img src="' + resource.image('download') + '" alt="download"/>' +
|
||||
'<span class="l10n-download"/>' +
|
||||
'</a>' +
|
||||
'</li>',
|
||||
'</li>';
|
||||
var selectedItems = [];
|
||||
|
||||
selectedItems = [],
|
||||
|
||||
onSelection = function (items) {
|
||||
function onSelection(items) {
|
||||
|
||||
var $download = $('#download');
|
||||
var $download = $('#download');
|
||||
|
||||
selectedItems = items.slice(0);
|
||||
if (selectedItems.length) {
|
||||
$download.show();
|
||||
} else if (!settings.alwaysVisible) {
|
||||
$download.hide();
|
||||
}
|
||||
},
|
||||
selectedItems = items.slice(0);
|
||||
if (selectedItems.length) {
|
||||
$download.show();
|
||||
} else if (!settings.alwaysVisible) {
|
||||
$download.hide();
|
||||
}
|
||||
}
|
||||
|
||||
onClick = function (event) {
|
||||
function onClick(event) {
|
||||
|
||||
var type = settings.type,
|
||||
extension = (type === 'shell-zip') ? 'zip' : 'tar',
|
||||
query = {
|
||||
action: 'download',
|
||||
as: (settings.packageName || location.getItem().label) + '.' + extension,
|
||||
type: type,
|
||||
hrefs: _.pluck(selectedItems, 'absHref').join('|:|')
|
||||
};
|
||||
var type = settings.type;
|
||||
var extension = (type === 'shell-zip') ? 'zip' : 'tar';
|
||||
var query = {
|
||||
action: 'download',
|
||||
as: (settings.packageName || location.getItem().label) + '.' + extension,
|
||||
type: type,
|
||||
hrefs: _.pluck(selectedItems, 'absHref').join('|:|')
|
||||
};
|
||||
|
||||
server.formRequest(query);
|
||||
},
|
||||
server.formRequest(query);
|
||||
}
|
||||
|
||||
init = function () {
|
||||
function init() {
|
||||
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
}
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
$(downloadBtnTemplate)
|
||||
.find('a').on('click', onClick).end()
|
||||
.appendTo('#navbar');
|
||||
$(downloadBtnTemplate)
|
||||
.find('a').on('click', onClick).end()
|
||||
.appendTo('#navbar');
|
||||
|
||||
if (settings.alwaysVisible) {
|
||||
$('#download').show();
|
||||
}
|
||||
if (settings.alwaysVisible) {
|
||||
$('#download').show();
|
||||
}
|
||||
|
||||
event.sub('selection', onSelection);
|
||||
}
|
||||
|
||||
event.sub('selection', onSelection);
|
||||
};
|
||||
|
||||
init();
|
||||
});
|
||||
|
|
|
@ -1,121 +1,128 @@
|
|||
|
||||
modulejs.define('ext/filter', ['_', '$', 'core/settings', 'core/resource', 'core/event'], function (_, $, allsettings, resource, event) {
|
||||
|
||||
var settings = _.extend({
|
||||
enabled: false
|
||||
}, allsettings.filter),
|
||||
|
||||
template =
|
||||
}, allsettings.filter);
|
||||
var template =
|
||||
'<li id="filter">' +
|
||||
'<span class="element">' +
|
||||
'<img src="' + resource.image('filter') + '" alt="filter"/>' +
|
||||
'<input type="text" value="" placeholder="filter"/>' +
|
||||
'</span>' +
|
||||
'</li>',
|
||||
noMatchTemplate = '<div class="no-match l10n-noMatch"/>',
|
||||
'</li>';
|
||||
var noMatchTemplate = '<div class="no-match l10n-noMatch"/>';
|
||||
var $filter, $input, $noMatch;
|
||||
|
||||
$filter, $input, $noMatch,
|
||||
|
||||
filter = function (re) {
|
||||
function filter(re) {
|
||||
|
||||
var match = [],
|
||||
noMatch = [],
|
||||
duration = 200;
|
||||
var match = [];
|
||||
var noMatch = [];
|
||||
var duration = 200;
|
||||
|
||||
if (re) {
|
||||
$('#items .item').not('.folder-parent').each(function () {
|
||||
if (re) {
|
||||
$('#items .item').not('.folder-parent').each(function () {
|
||||
|
||||
var label = $(this).find('.label').text();
|
||||
var label = $(this).find('.label').text();
|
||||
|
||||
if (label.match(re)) {
|
||||
match.push(this);
|
||||
} else {
|
||||
noMatch.push(this);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
match = $('#items .item').not('.folder-parent');
|
||||
}
|
||||
if (label.match(re)) {
|
||||
match.push(this);
|
||||
} else {
|
||||
noMatch.push(this);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
match = $('#items .item').not('.folder-parent');
|
||||
}
|
||||
|
||||
if (match.length) {
|
||||
$noMatch.hide();
|
||||
} else if (noMatch.length) {
|
||||
setTimeout(function () { $noMatch.show(); }, duration);
|
||||
}
|
||||
$(match).fadeIn(duration);
|
||||
$(noMatch).fadeOut(duration);
|
||||
},
|
||||
if (match.length) {
|
||||
$noMatch.hide();
|
||||
} else if (noMatch.length) {
|
||||
setTimeout(function () { $noMatch.show(); }, duration);
|
||||
}
|
||||
$(match).fadeIn(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:') {
|
||||
return new RegExp(sequence.substr(3));
|
||||
}
|
||||
if (sequence.substr(0, 3) === 're:') {
|
||||
return new RegExp(sequence.substr(3));
|
||||
}
|
||||
|
||||
sequence = $.map($.trim(sequence).split(/\s+/), function (part) {
|
||||
sequence = $.map($.trim(sequence).split(/\s+/), function (part) {
|
||||
|
||||
return _.map(part.split(''), function (character) {
|
||||
return _.map(part.split(''), function (character) {
|
||||
|
||||
return escapeRegExp(character);
|
||||
}).join('.*?');
|
||||
}).join('|');
|
||||
return escapeRegExp(character);
|
||||
}).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();
|
||||
|
||||
if (focus) {
|
||||
$input.focus();
|
||||
}
|
||||
if (focus) {
|
||||
$input.focus();
|
||||
}
|
||||
|
||||
if (val || focus) {
|
||||
filter(parseFilterSequence(val));
|
||||
$filter.addClass('current');
|
||||
} else {
|
||||
filter();
|
||||
$filter.removeClass('current');
|
||||
}
|
||||
},
|
||||
updt = function () { update(true); },
|
||||
updf = function () { update(false); },
|
||||
if (val || focus) {
|
||||
filter(parseFilterSequence(val));
|
||||
$filter.addClass('current');
|
||||
} else {
|
||||
filter();
|
||||
$filter.removeClass('current');
|
||||
}
|
||||
}
|
||||
|
||||
init = function () {
|
||||
function updt() {
|
||||
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
}
|
||||
update(true);
|
||||
}
|
||||
|
||||
$filter = $(template).appendTo('#navbar');
|
||||
$input = $filter.find('input');
|
||||
$noMatch = $(noMatchTemplate).appendTo('#view');
|
||||
function updf() {
|
||||
|
||||
$filter.on('click', updt);
|
||||
$input.on('focus blur keyup', updf);
|
||||
update(false);
|
||||
}
|
||||
|
||||
$(document)
|
||||
.on('keydown', function (event) {
|
||||
function init() {
|
||||
|
||||
if (event.which === 27) {
|
||||
reset();
|
||||
}
|
||||
})
|
||||
.on('keypress', updt);
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
$filter = $(template).appendTo('#navbar');
|
||||
$input = $filter.find('input');
|
||||
$noMatch = $(noMatchTemplate).appendTo('#view');
|
||||
|
||||
$filter.on('click', updt);
|
||||
$input.on('focus blur keyup', updf);
|
||||
|
||||
$(document)
|
||||
.on('keydown', function (event) {
|
||||
|
||||
if (event.which === 27) {
|
||||
reset();
|
||||
}
|
||||
})
|
||||
.on('keypress', updt);
|
||||
|
||||
event.sub('location.changed', reset);
|
||||
}
|
||||
|
||||
event.sub('location.changed', reset);
|
||||
};
|
||||
|
||||
init();
|
||||
});
|
||||
|
|
|
@ -1,28 +1,29 @@
|
|||
|
||||
modulejs.define('ext/google-analytics-ga', ['_', 'core/settings'], function (_, allsettings) {
|
||||
|
||||
var settings = _.extend({
|
||||
enabled: false,
|
||||
gaq: []
|
||||
}, allsettings['google-analytics-ga']),
|
||||
}, allsettings['google-analytics-ga']);
|
||||
|
||||
init = function () {
|
||||
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
}
|
||||
function init() {
|
||||
|
||||
window._gaq = settings.gaq;
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
var scriptLiteral = 'script',
|
||||
doc = document,
|
||||
newScriptTag = doc.createElement(scriptLiteral),
|
||||
firstScriptTag = doc.getElementsByTagName(scriptLiteral)[0];
|
||||
window._gaq = settings.gaq;
|
||||
|
||||
var scriptLiteral = 'script';
|
||||
var doc = document;
|
||||
var newScriptTag = doc.createElement(scriptLiteral);
|
||||
var firstScriptTag = doc.getElementsByTagName(scriptLiteral)[0];
|
||||
|
||||
newScriptTag.async = true;
|
||||
newScriptTag.src = ('https:' === location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
firstScriptTag.parentNode.insertBefore(newScriptTag, firstScriptTag);
|
||||
}
|
||||
|
||||
newScriptTag.async = true;
|
||||
newScriptTag.src = ('https:' === location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
firstScriptTag.parentNode.insertBefore(newScriptTag, firstScriptTag);
|
||||
};
|
||||
|
||||
init();
|
||||
});
|
||||
|
@ -33,45 +34,46 @@ modulejs.define('ext/google-analytics-ua', ['_', 'core/settings', 'core/event'],
|
|||
var settings = _.extend({
|
||||
enabled: false,
|
||||
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) {
|
||||
return;
|
||||
}
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
var el, firstScriptElement;
|
||||
var el, firstScriptElement;
|
||||
|
||||
win.GoogleAnalyticsObject = id;
|
||||
win[id] = win[id] || function () {
|
||||
(win[id].q = win[id].q || []).push(arguments);
|
||||
};
|
||||
win[id].l = 1 * new Date();
|
||||
|
||||
el = doc.createElement(scriptLiteral);
|
||||
el.async = true;
|
||||
el.src = '//www.google-analytics.com/analytics.js';
|
||||
|
||||
firstScriptElement = doc.getElementsByTagName(scriptLiteral)[0];
|
||||
firstScriptElement.parentNode.insertBefore(el, firstScriptElement);
|
||||
|
||||
win[id]('create', settings.id, 'auto');
|
||||
|
||||
event.sub('location.changed', function (item) {
|
||||
|
||||
var loc = win.location;
|
||||
win[id]('send', 'pageview', {
|
||||
location: loc.protocol + '//' + loc.host + item.absHref,
|
||||
title: _.pluck(item.getCrumb(), 'label').join(' > ')
|
||||
});
|
||||
});
|
||||
win.GoogleAnalyticsObject = id;
|
||||
win[id] = win[id] || function () {
|
||||
(win[id].q = win[id].q || []).push(arguments);
|
||||
};
|
||||
win[id].l = 1 * new Date();
|
||||
|
||||
el = doc.createElement(scriptLiteral);
|
||||
el.async = true;
|
||||
el.src = '//www.google-analytics.com/analytics.js';
|
||||
|
||||
firstScriptElement = doc.getElementsByTagName(scriptLiteral)[0];
|
||||
firstScriptElement.parentNode.insertBefore(el, firstScriptElement);
|
||||
|
||||
win[id]('create', settings.id, 'auto');
|
||||
|
||||
event.sub('location.changed', function (item) {
|
||||
|
||||
var loc = win.location;
|
||||
win[id]('send', 'pageview', {
|
||||
location: loc.protocol + '//' + loc.host + item.absHref,
|
||||
title: _.pluck(item.getCrumb(), 'label').join(' > ')
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
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) {
|
||||
|
||||
var settings = _.extend({
|
||||
enabled: false,
|
||||
lang: 'en',
|
||||
useBrowserLang: true
|
||||
}, allsettings.l10n),
|
||||
|
||||
defaultTranslations = {
|
||||
}, allsettings.l10n);
|
||||
var defaultTranslations = {
|
||||
isoCode: 'en',
|
||||
lang: 'english',
|
||||
details: 'details',
|
||||
|
@ -26,117 +24,116 @@ modulejs.define('ext/l10n', ['_', '$', 'core/settings', 'core/langs', 'core/form
|
|||
dateFormat: 'YYYY-MM-DD HH:mm',
|
||||
filter: 'filter',
|
||||
'delete': 'delete'
|
||||
},
|
||||
|
||||
blockTemplate = '<div class="block"><div class="select"><select id="langs"/></div></div>',
|
||||
optionTemplate = '<option/>',
|
||||
|
||||
storekey = 'ext/l10n',
|
||||
|
||||
loaded = {
|
||||
};
|
||||
var blockTemplate = '<div class="block"><div class="select"><select id="langs"/></div></div>';
|
||||
var optionTemplate = '<option/>';
|
||||
var storekey = 'ext/l10n';
|
||||
var loaded = {
|
||||
en: _.extend({}, defaultTranslations)
|
||||
},
|
||||
currentLang = loaded.en,
|
||||
};
|
||||
var currentLang = loaded.en;
|
||||
|
||||
update = function (lang) {
|
||||
|
||||
if (lang) {
|
||||
currentLang = lang;
|
||||
}
|
||||
function update(lang) {
|
||||
|
||||
$('#langs option')
|
||||
.removeAttr('selected').removeProp('selected')
|
||||
.filter('.' + currentLang.isoCode)
|
||||
.attr('selected', 'selected').prop('selected', 'selected');
|
||||
if (lang) {
|
||||
currentLang = lang;
|
||||
}
|
||||
|
||||
$.each(currentLang, function (key, value) {
|
||||
$('.l10n-' + key).text(value);
|
||||
});
|
||||
format.setDefaultDateFormat(currentLang.dateFormat);
|
||||
$('#langs option')
|
||||
.removeAttr('selected').removeProp('selected')
|
||||
.filter('.' + currentLang.isoCode)
|
||||
.attr('selected', 'selected').prop('selected', 'selected');
|
||||
|
||||
$('#items .item .date').each(function () {
|
||||
$.each(currentLang, function (key, value) {
|
||||
$('.l10n-' + key).text(value);
|
||||
});
|
||||
format.setDefaultDateFormat(currentLang.dateFormat);
|
||||
|
||||
var $this = $(this);
|
||||
$('#items .item .date').each(function () {
|
||||
|
||||
$this.text(format.formatDate($this.data('time')));
|
||||
});
|
||||
var $this = $(this);
|
||||
|
||||
$('#filter input').attr('placeholder', currentLang.filter);
|
||||
},
|
||||
$this.text(format.formatDate($this.data('time')));
|
||||
});
|
||||
|
||||
loadLanguage = function (isoCode, callback) {
|
||||
$('#filter input').attr('placeholder', currentLang.filter);
|
||||
}
|
||||
|
||||
if (loaded[isoCode]) {
|
||||
function loadLanguage(isoCode, callback) {
|
||||
|
||||
if (loaded[isoCode]) {
|
||||
|
||||
callback(loaded[isoCode]);
|
||||
} else {
|
||||
|
||||
server.request({action: 'get', l10n: true, l10nCodes: isoCode}, function (response) {
|
||||
|
||||
var json = response.l10n && response.l10n[isoCode] ? response.l10n[isoCode] : {};
|
||||
loaded[isoCode] = _.extend({}, defaultTranslations, json, {isoCode: isoCode});
|
||||
callback(loaded[isoCode]);
|
||||
} else {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
server.request({action: 'get', l10n: true, l10nCodes: isoCode}, function (response) {
|
||||
function localize(langs, isoCode, useBrowserLang) {
|
||||
|
||||
var json = response.l10n && response.l10n[isoCode] ? response.l10n[isoCode] : {};
|
||||
loaded[isoCode] = _.extend({}, defaultTranslations, json, {isoCode: isoCode});
|
||||
callback(loaded[isoCode]);
|
||||
});
|
||||
}
|
||||
},
|
||||
var storedIsoCode = store.get(storekey);
|
||||
|
||||
localize = function (langs, isoCode, useBrowserLang) {
|
||||
|
||||
var storedIsoCode = store.get(storekey);
|
||||
|
||||
if (langs[storedIsoCode]) {
|
||||
isoCode = storedIsoCode;
|
||||
} else if (useBrowserLang) {
|
||||
var browserLang = navigator.language || navigator.browserLanguage;
|
||||
if (browserLang) {
|
||||
if (langs[browserLang]) {
|
||||
isoCode = browserLang;
|
||||
} else if (browserLang.length > 2 && langs[browserLang.substr(0, 2)]) {
|
||||
isoCode = browserLang.substr(0, 2);
|
||||
}
|
||||
if (langs[storedIsoCode]) {
|
||||
isoCode = storedIsoCode;
|
||||
} else if (useBrowserLang) {
|
||||
var browserLang = navigator.language || navigator.browserLanguage;
|
||||
if (browserLang) {
|
||||
if (langs[browserLang]) {
|
||||
isoCode = browserLang;
|
||||
} else if (browserLang.length > 2 && langs[browserLang.substr(0, 2)]) {
|
||||
isoCode = browserLang.substr(0, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!langs[isoCode]) {
|
||||
isoCode = 'en';
|
||||
}
|
||||
if (!langs[isoCode]) {
|
||||
isoCode = 'en';
|
||||
}
|
||||
|
||||
loadLanguage(isoCode, update);
|
||||
},
|
||||
loadLanguage(isoCode, update);
|
||||
}
|
||||
|
||||
initLangSelector = function (langs) {
|
||||
function initLangSelector(langs) {
|
||||
|
||||
var isoCodes = _.keys(langs).sort(),
|
||||
$block = $(blockTemplate),
|
||||
$select = $block.find('select')
|
||||
.on('change', function (event) {
|
||||
var isoCode = event.target.value;
|
||||
store.put(storekey, isoCode);
|
||||
localize(langs, isoCode, false);
|
||||
});
|
||||
var isoCodes = _.keys(langs).sort();
|
||||
var $block = $(blockTemplate);
|
||||
var $select = $block.find('select')
|
||||
.on('change', function (event) {
|
||||
var isoCode = event.target.value;
|
||||
store.put(storekey, isoCode);
|
||||
localize(langs, isoCode, false);
|
||||
});
|
||||
|
||||
$.each(isoCodes, function (idx, isoCode) {
|
||||
$(optionTemplate)
|
||||
.attr('value', isoCode)
|
||||
.addClass(isoCode)
|
||||
.text(isoCode + ' - ' + (_.isString(langs[isoCode]) ? langs[isoCode] : langs[isoCode].lang))
|
||||
.appendTo($select);
|
||||
});
|
||||
$.each(isoCodes, function (idx, isoCode) {
|
||||
$(optionTemplate)
|
||||
.attr('value', isoCode)
|
||||
.addClass(isoCode)
|
||||
.text(isoCode + ' - ' + (_.isString(langs[isoCode]) ? langs[isoCode] : langs[isoCode].lang))
|
||||
.appendTo($select);
|
||||
});
|
||||
|
||||
$block.appendTo('#settings');
|
||||
},
|
||||
$block.appendTo('#settings');
|
||||
}
|
||||
|
||||
init = function () {
|
||||
function init() {
|
||||
|
||||
if (settings.enabled) {
|
||||
initLangSelector(langs);
|
||||
}
|
||||
if (settings.enabled) {
|
||||
initLangSelector(langs);
|
||||
}
|
||||
|
||||
event.sub('location.changed', function () {
|
||||
event.sub('location.changed', function () {
|
||||
|
||||
localize(langs, settings.lang, settings.useBrowserLang);
|
||||
});
|
||||
}
|
||||
|
||||
localize(langs, settings.lang, settings.useBrowserLang);
|
||||
});
|
||||
};
|
||||
|
||||
init();
|
||||
});
|
||||
|
|
|
@ -1,51 +1,51 @@
|
|||
|
||||
modulejs.define('ext/link-hover-states', ['_', '$', 'core/settings', 'core/event'], function (_, $, allsettings, event) {
|
||||
|
||||
var settings = _.extend({
|
||||
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) {
|
||||
return;
|
||||
}
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
$('body')
|
||||
.on('mouseenter', selector, onMouseEnter)
|
||||
.on('mouseleave', selector, onMouseLeave);
|
||||
$('body')
|
||||
.on('mouseenter', selector, onMouseEnter)
|
||||
.on('mouseleave', selector, onMouseLeave);
|
||||
|
||||
event.sub('location.changed', onLocationChanged);
|
||||
}
|
||||
|
||||
event.sub('location.changed', onLocationChanged);
|
||||
};
|
||||
|
||||
init();
|
||||
});
|
||||
|
|
|
@ -1,31 +1,32 @@
|
|||
|
||||
modulejs.define('ext/piwik-analytics', ['_', '$', 'core/settings'], function (_, $, allsettings) {
|
||||
|
||||
var settings = _.extend({
|
||||
enabled: false,
|
||||
baseURL: 'not-set',
|
||||
idSite: 0
|
||||
}, allsettings['piwik-analytics']),
|
||||
}, allsettings['piwik-analytics']);
|
||||
|
||||
init = function () {
|
||||
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
}
|
||||
function init() {
|
||||
|
||||
// reference: http://piwik.org/docs/javascript-tracking/
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
var pkBaseURL = (("https:" === document.location.protocol) ? "https://" : "http://") + settings.baseURL + '/';
|
||||
// reference: http://piwik.org/docs/javascript-tracking/
|
||||
|
||||
$('<script/>').attr('src', pkBaseURL + 'piwik.js').appendTo('body');
|
||||
$(window).load(function () {
|
||||
/*global Piwik */
|
||||
var pkBaseURL = (("https:" === document.location.protocol) ? "https://" : "http://") + settings.baseURL + '/';
|
||||
|
||||
$('<script/>').attr('src', pkBaseURL + 'piwik.js').appendTo('body');
|
||||
$(window).load(function () {
|
||||
/*global Piwik */
|
||||
|
||||
var piwikTracker = Piwik.getTracker(pkBaseURL + 'piwik.php', settings.idSite);
|
||||
piwikTracker.trackPageView();
|
||||
piwikTracker.enableLinkTracking();
|
||||
});
|
||||
}
|
||||
|
||||
var piwikTracker = Piwik.getTracker(pkBaseURL + 'piwik.php', settings.idSite);
|
||||
piwikTracker.trackPageView();
|
||||
piwikTracker.enableLinkTracking();
|
||||
});
|
||||
};
|
||||
|
||||
init();
|
||||
});
|
||||
|
|
|
@ -1,122 +1,123 @@
|
|||
|
||||
modulejs.define('ext/preview-audio', ['_', '$', 'moment', 'core/settings', 'core/event', 'ext/preview'], function (_, $, moment, allsettings, event, preview) {
|
||||
|
||||
var settings = _.extend({
|
||||
enabled: false,
|
||||
types: []
|
||||
}, allsettings['preview-aud']),
|
||||
}, allsettings['preview-aud']);
|
||||
|
||||
preloadAudio = function (src, callback) {
|
||||
|
||||
var $audio = $('<audio/>')
|
||||
.one('loadedmetadata', function () {
|
||||
function preloadAudio(src, callback) {
|
||||
|
||||
callback($audio);
|
||||
// setTimeout(function () { callback($img); }, 1000); // for testing
|
||||
})
|
||||
.attr('autoplay', 'autoplay')
|
||||
.attr('controls', 'controls')
|
||||
.attr('src', src);
|
||||
},
|
||||
var $audio = $('<audio/>')
|
||||
.one('loadedmetadata', function () {
|
||||
|
||||
onEnter = function (items, idx) {
|
||||
callback($audio);
|
||||
// setTimeout(function () { callback($img); }, 1000); // for testing
|
||||
})
|
||||
.attr('autoplay', 'autoplay')
|
||||
.attr('controls', 'controls')
|
||||
.attr('src', src);
|
||||
}
|
||||
|
||||
var currentItems = items,
|
||||
currentIdx = idx,
|
||||
currentItem = items[idx],
|
||||
function onEnter(items, idx) {
|
||||
|
||||
onAdjustSize = function () {
|
||||
var currentItems = items;
|
||||
var currentIdx = idx;
|
||||
var currentItem = items[idx];
|
||||
|
||||
var $content = $('#pv-content'),
|
||||
$audio = $('#pv-aud-audio');
|
||||
function onAdjustSize() {
|
||||
|
||||
if ($audio.length) {
|
||||
var $content = $('#pv-content');
|
||||
var $audio = $('#pv-aud-audio');
|
||||
|
||||
$audio.css({
|
||||
'left': '' + (($content.width()-$audio.width())*0.5) + 'px',
|
||||
'top': '' + (($content.height()-$audio.height())*0.5) + 'px'
|
||||
});
|
||||
if ($audio.length) {
|
||||
|
||||
preview.setLabels([
|
||||
currentItem.label,
|
||||
moment(0).add('seconds', $audio[0].duration).format('m:ss')
|
||||
]);
|
||||
}
|
||||
},
|
||||
|
||||
onIdxChange = function (rel) {
|
||||
|
||||
currentIdx = (currentIdx + rel + currentItems.length) % currentItems.length;
|
||||
currentItem = currentItems[currentIdx];
|
||||
|
||||
var spinnerTimeout = setTimeout(function () { preview.showSpinner(true); }, 200);
|
||||
|
||||
if ($('#pv-aud-audio').length) {
|
||||
$('#pv-aud-audio')[0].pause();
|
||||
}
|
||||
preloadAudio(currentItem.absHref, function ($preloaded_audio) {
|
||||
|
||||
clearTimeout(spinnerTimeout);
|
||||
preview.showSpinner(false);
|
||||
|
||||
$('#pv-content').fadeOut(100, function () {
|
||||
|
||||
$('#pv-content').empty().append($preloaded_audio.attr('id', 'pv-aud-audio')).fadeIn(200);
|
||||
|
||||
// small timeout, so $preloaded_audio is visible and therefore $preloaded_audio.width is available
|
||||
setTimeout(function () {
|
||||
onAdjustSize();
|
||||
|
||||
preview.setIndex(currentIdx + 1, currentItems.length);
|
||||
preview.setRawLink(currentItem.absHref);
|
||||
}, 10);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
onIdxChange(0);
|
||||
preview.setOnIndexChange(onIdxChange);
|
||||
preview.setOnAdjustSize(onAdjustSize);
|
||||
preview.enter();
|
||||
},
|
||||
|
||||
initItem = function (item) {
|
||||
|
||||
if (item.$view && _.indexOf(settings.types, item.type) >= 0) {
|
||||
item.$view.find('a').on('click', function (event) {
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
var matchedEntries = _.compact(_.map($('#items .item'), function (item) {
|
||||
|
||||
item = $(item).data('item');
|
||||
return _.indexOf(settings.types, item.type) >= 0 ? item : null;
|
||||
}));
|
||||
|
||||
onEnter(matchedEntries, _.indexOf(matchedEntries, item));
|
||||
$audio.css({
|
||||
'left': '' + (($content.width()-$audio.width())*0.5) + 'px',
|
||||
'top': '' + (($content.height()-$audio.height())*0.5) + 'px'
|
||||
});
|
||||
|
||||
preview.setLabels([
|
||||
currentItem.label,
|
||||
moment(0).add('seconds', $audio[0].duration).format('m:ss')
|
||||
]);
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
onLocationChanged = function (item) {
|
||||
function onIdxChange(rel) {
|
||||
|
||||
_.each(item.content, initItem);
|
||||
},
|
||||
currentIdx = (currentIdx + rel + currentItems.length) % currentItems.length;
|
||||
currentItem = currentItems[currentIdx];
|
||||
|
||||
onLocationRefreshed = function (item, added, removed) {
|
||||
var spinnerTimeout = setTimeout(function () { preview.showSpinner(true); }, 200);
|
||||
|
||||
_.each(added, initItem);
|
||||
},
|
||||
|
||||
init = function () {
|
||||
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
if ($('#pv-aud-audio').length) {
|
||||
$('#pv-aud-audio')[0].pause();
|
||||
}
|
||||
preloadAudio(currentItem.absHref, function ($preloaded_audio) {
|
||||
|
||||
clearTimeout(spinnerTimeout);
|
||||
preview.showSpinner(false);
|
||||
|
||||
$('#pv-content').fadeOut(100, function () {
|
||||
|
||||
$('#pv-content').empty().append($preloaded_audio.attr('id', 'pv-aud-audio')).fadeIn(200);
|
||||
|
||||
// small timeout, so $preloaded_audio is visible and therefore $preloaded_audio.width is available
|
||||
setTimeout(function () {
|
||||
onAdjustSize();
|
||||
|
||||
preview.setIndex(currentIdx + 1, currentItems.length);
|
||||
preview.setRawLink(currentItem.absHref);
|
||||
}, 10);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
onIdxChange(0);
|
||||
preview.setOnIndexChange(onIdxChange);
|
||||
preview.setOnAdjustSize(onAdjustSize);
|
||||
preview.enter();
|
||||
}
|
||||
|
||||
function initItem(item) {
|
||||
|
||||
if (item.$view && _.indexOf(settings.types, item.type) >= 0) {
|
||||
item.$view.find('a').on('click', function (event) {
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
var matchedEntries = _.compact(_.map($('#items .item'), function (item) {
|
||||
|
||||
item = $(item).data('item');
|
||||
return _.indexOf(settings.types, item.type) >= 0 ? item : null;
|
||||
}));
|
||||
|
||||
onEnter(matchedEntries, _.indexOf(matchedEntries, item));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function onLocationChanged(item) {
|
||||
|
||||
_.each(item.content, initItem);
|
||||
}
|
||||
|
||||
function onLocationRefreshed(item, added, removed) {
|
||||
|
||||
_.each(added, initItem);
|
||||
}
|
||||
|
||||
function init() {
|
||||
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.sub('location.changed', onLocationChanged);
|
||||
event.sub('location.refreshed', onLocationRefreshed);
|
||||
}
|
||||
|
||||
event.sub('location.changed', onLocationChanged);
|
||||
event.sub('location.refreshed', onLocationRefreshed);
|
||||
};
|
||||
|
||||
init();
|
||||
});
|
||||
|
|
|
@ -1,124 +1,125 @@
|
|||
|
||||
modulejs.define('ext/preview-img', ['_', '$', 'core/settings', 'core/event', 'ext/preview'], function (_, $, allsettings, event, preview) {
|
||||
|
||||
var settings = _.extend({
|
||||
enabled: false,
|
||||
types: []
|
||||
}, allsettings['preview-img']),
|
||||
}, allsettings['preview-img']);
|
||||
|
||||
preloadImg = function (src, callback) {
|
||||
|
||||
var $img = $('<img/>')
|
||||
.one('load', function () {
|
||||
function preloadImg(src, callback) {
|
||||
|
||||
callback($img);
|
||||
// setTimeout(function () { callback($img); }, 1000); // for testing
|
||||
})
|
||||
.attr('src', src);
|
||||
},
|
||||
var $img = $('<img/>')
|
||||
.one('load', function () {
|
||||
|
||||
onEnter = function (items, idx) {
|
||||
callback($img);
|
||||
// setTimeout(function () { callback($img); }, 1000); // for testing
|
||||
})
|
||||
.attr('src', src);
|
||||
}
|
||||
|
||||
var currentItems = items,
|
||||
currentIdx = idx,
|
||||
currentItem = items[idx],
|
||||
function onEnter(items, idx) {
|
||||
|
||||
onAdjustSize = function () {
|
||||
var currentItems = items;
|
||||
var currentIdx = idx;
|
||||
var currentItem = items[idx];
|
||||
|
||||
var $content = $('#pv-content'),
|
||||
$img = $('#pv-img-image');
|
||||
function onAdjustSize() {
|
||||
|
||||
if ($img.length) {
|
||||
var $content = $('#pv-content');
|
||||
var $img = $('#pv-img-image');
|
||||
|
||||
$img.css({
|
||||
'left': '' + (($content.width()-$img.width())*0.5) + 'px',
|
||||
'top': '' + (($content.height()-$img.height())*0.5) + 'px'
|
||||
});
|
||||
if ($img.length) {
|
||||
|
||||
$img.css({
|
||||
'left': '' + (($content.width()-$img.width())*0.5) + 'px',
|
||||
'top': '' + (($content.height()-$img.height())*0.5) + 'px'
|
||||
});
|
||||
|
||||
preview.setLabels([
|
||||
currentItem.label,
|
||||
'' + $img[0].naturalWidth + 'x' + $img[0].naturalHeight,
|
||||
'' + (100 * $img.width() / $img[0].naturalWidth).toFixed(0) + '%'
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
function onIdxChange(rel) {
|
||||
|
||||
currentIdx = (currentIdx + rel + currentItems.length) % currentItems.length;
|
||||
currentItem = currentItems[currentIdx];
|
||||
|
||||
var spinnerTimeout = setTimeout(function () { preview.showSpinner(true); }, 200);
|
||||
|
||||
preloadImg(currentItem.absHref, function ($preloaded_img) {
|
||||
|
||||
clearTimeout(spinnerTimeout);
|
||||
preview.showSpinner(false);
|
||||
|
||||
$('#pv-content').fadeOut(100, function () {
|
||||
|
||||
$('#pv-content').empty().append($preloaded_img.attr('id', 'pv-img-image')).fadeIn(200);
|
||||
|
||||
// small timeout, so $preloaded_img is visible and therefore $preloaded_img.width is available
|
||||
setTimeout(function () {
|
||||
|
||||
onAdjustSize();
|
||||
|
||||
preview.setIndex(currentIdx + 1, currentItems.length);
|
||||
preview.setLabels([
|
||||
currentItem.label,
|
||||
'' + $img[0].naturalWidth + 'x' + $img[0].naturalHeight,
|
||||
'' + (100 * $img.width() / $img[0].naturalWidth).toFixed(0) + '%'
|
||||
'' + $preloaded_img[0].naturalWidth + 'x' + $preloaded_img[0].naturalHeight,
|
||||
'' + (100 * $preloaded_img.width() / $preloaded_img[0].naturalWidth).toFixed(0) + '%'
|
||||
]);
|
||||
}
|
||||
},
|
||||
|
||||
onIdxChange = function (rel) {
|
||||
|
||||
currentIdx = (currentIdx + rel + currentItems.length) % currentItems.length;
|
||||
currentItem = currentItems[currentIdx];
|
||||
|
||||
var spinnerTimeout = setTimeout(function () { preview.showSpinner(true); }, 200);
|
||||
|
||||
preloadImg(currentItem.absHref, function ($preloaded_img) {
|
||||
|
||||
clearTimeout(spinnerTimeout);
|
||||
preview.showSpinner(false);
|
||||
|
||||
$('#pv-content').fadeOut(100, function () {
|
||||
|
||||
$('#pv-content').empty().append($preloaded_img.attr('id', 'pv-img-image')).fadeIn(200);
|
||||
|
||||
// small timeout, so $preloaded_img is visible and therefore $preloaded_img.width is available
|
||||
setTimeout(function () {
|
||||
|
||||
onAdjustSize();
|
||||
|
||||
preview.setIndex(currentIdx + 1, currentItems.length);
|
||||
preview.setLabels([
|
||||
currentItem.label,
|
||||
'' + $preloaded_img[0].naturalWidth + 'x' + $preloaded_img[0].naturalHeight,
|
||||
'' + (100 * $preloaded_img.width() / $preloaded_img[0].naturalWidth).toFixed(0) + '%'
|
||||
]);
|
||||
preview.setRawLink(currentItem.absHref);
|
||||
}, 10);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
onIdxChange(0);
|
||||
preview.setOnIndexChange(onIdxChange);
|
||||
preview.setOnAdjustSize(onAdjustSize);
|
||||
preview.enter();
|
||||
},
|
||||
|
||||
initItem = function (item) {
|
||||
|
||||
if (item.$view && _.indexOf(settings.types, item.type) >= 0) {
|
||||
item.$view.find('a').on('click', function (event) {
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
var matchedEntries = _.compact(_.map($('#items .item'), function (item) {
|
||||
|
||||
item = $(item).data('item');
|
||||
return _.indexOf(settings.types, item.type) >= 0 ? item : null;
|
||||
}));
|
||||
|
||||
onEnter(matchedEntries, _.indexOf(matchedEntries, item));
|
||||
preview.setRawLink(currentItem.absHref);
|
||||
}, 10);
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
onLocationChanged = function (item) {
|
||||
onIdxChange(0);
|
||||
preview.setOnIndexChange(onIdxChange);
|
||||
preview.setOnAdjustSize(onAdjustSize);
|
||||
preview.enter();
|
||||
}
|
||||
|
||||
_.each(item.content, initItem);
|
||||
},
|
||||
function initItem(item) {
|
||||
|
||||
onLocationRefreshed = function (item, added, removed) {
|
||||
if (item.$view && _.indexOf(settings.types, item.type) >= 0) {
|
||||
item.$view.find('a').on('click', function (event) {
|
||||
|
||||
_.each(added, initItem);
|
||||
},
|
||||
event.preventDefault();
|
||||
|
||||
init = function () {
|
||||
var matchedEntries = _.compact(_.map($('#items .item'), function (item) {
|
||||
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
}
|
||||
item = $(item).data('item');
|
||||
return _.indexOf(settings.types, item.type) >= 0 ? item : null;
|
||||
}));
|
||||
|
||||
onEnter(matchedEntries, _.indexOf(matchedEntries, item));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function onLocationChanged(item) {
|
||||
|
||||
_.each(item.content, initItem);
|
||||
}
|
||||
|
||||
function onLocationRefreshed(item, added, removed) {
|
||||
|
||||
_.each(added, initItem);
|
||||
}
|
||||
|
||||
function init() {
|
||||
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.sub('location.changed', onLocationChanged);
|
||||
event.sub('location.refreshed', onLocationRefreshed);
|
||||
}
|
||||
|
||||
event.sub('location.changed', onLocationChanged);
|
||||
event.sub('location.refreshed', onLocationRefreshed);
|
||||
};
|
||||
|
||||
init();
|
||||
});
|
||||
|
|
|
@ -1,138 +1,138 @@
|
|||
|
||||
modulejs.define('ext/preview-txt', ['_', '$', 'marked', 'prism', 'core/settings', 'core/event', 'ext/preview'], function (_, $, marked, prism, allsettings, event, preview) {
|
||||
|
||||
var settings = _.extend({
|
||||
enabled: false,
|
||||
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({
|
||||
url: absHref,
|
||||
dataType: 'text'
|
||||
})
|
||||
.done(function (content) {
|
||||
$.ajax({
|
||||
url: absHref,
|
||||
dataType: 'text'
|
||||
})
|
||||
.done(function (content) {
|
||||
|
||||
callback(content);
|
||||
// setTimeout(function () { callback(content); }, 1000); // for testing
|
||||
})
|
||||
.fail(function (jqXHR, textStatus, errorThrown) {
|
||||
callback(content);
|
||||
// setTimeout(function () { callback(content); }, 1000); // for testing
|
||||
})
|
||||
.fail(function (jqXHR, textStatus, errorThrown) {
|
||||
|
||||
callback('[ajax error] ' + textStatus);
|
||||
});
|
||||
},
|
||||
callback('[ajax error] ' + textStatus);
|
||||
});
|
||||
}
|
||||
|
||||
onEnter = function (items, idx) {
|
||||
function onEnter(items, idx) {
|
||||
|
||||
var currentItems = items,
|
||||
currentIdx = idx,
|
||||
currentItem = items[idx],
|
||||
var currentItems = items;
|
||||
var currentIdx = idx;
|
||||
var currentItem = items[idx];
|
||||
|
||||
onAdjustSize = function () {
|
||||
function onAdjustSize() {
|
||||
|
||||
var $content = $('#pv-content'),
|
||||
$text = $('#pv-txt-text');
|
||||
var $content = $('#pv-content');
|
||||
var $text = $('#pv-txt-text');
|
||||
|
||||
if ($text.length) {
|
||||
if ($text.length) {
|
||||
|
||||
$text.height($content.height() - 16);
|
||||
$text.height($content.height() - 16);
|
||||
}
|
||||
}
|
||||
|
||||
function onIdxChange(rel) {
|
||||
|
||||
currentIdx = (currentIdx + rel + currentItems.length) % currentItems.length;
|
||||
currentItem = currentItems[currentIdx];
|
||||
|
||||
var spinnerTimeout = setTimeout(function () { preview.showSpinner(true); }, 200);
|
||||
|
||||
preloadText(currentItem.absHref, function (textContent) {
|
||||
|
||||
clearTimeout(spinnerTimeout);
|
||||
preview.showSpinner(false);
|
||||
|
||||
$('#pv-content').fadeOut(100, function () {
|
||||
|
||||
var type = settings.types[currentItem.type];
|
||||
var $text, $code;
|
||||
|
||||
if (type === 'none') {
|
||||
$text = $(templateMarkdown).text(textContent);
|
||||
} else if (type === 'fixed') {
|
||||
$text = $(templateText).text(textContent);
|
||||
} else if (type === 'markdown') {
|
||||
$text = $(templateMarkdown).html(marked(textContent));
|
||||
} else {
|
||||
$text = $(templateText);
|
||||
$code = $('<code/>').appendTo($text);
|
||||
|
||||
if (textContent.length < 20000) {
|
||||
$code.empty().html(prism.highlight(textContent, prism.languages[type]));
|
||||
} else {
|
||||
$code.empty().text(textContent);
|
||||
setTimeout(function () { $code.empty().html(prism.highlight(textContent, prism.languages[type])); }, 300);
|
||||
}
|
||||
}
|
||||
},
|
||||
$('#pv-content').empty().append($text).fadeIn(200);
|
||||
onAdjustSize();
|
||||
|
||||
onIdxChange = function (rel) {
|
||||
|
||||
currentIdx = (currentIdx + rel + currentItems.length) % currentItems.length;
|
||||
currentItem = currentItems[currentIdx];
|
||||
|
||||
var spinnerTimeout = setTimeout(function () { preview.showSpinner(true); }, 200);
|
||||
|
||||
preloadText(currentItem.absHref, function (textContent) {
|
||||
|
||||
clearTimeout(spinnerTimeout);
|
||||
preview.showSpinner(false);
|
||||
|
||||
$('#pv-content').fadeOut(100, function () {
|
||||
|
||||
var type = settings.types[currentItem.type],
|
||||
$text, $code;
|
||||
|
||||
if (type === 'none') {
|
||||
$text = $(templateMarkdown).text(textContent);
|
||||
} else if (type === 'fixed') {
|
||||
$text = $(templateText).text(textContent);
|
||||
} else if (type === 'markdown') {
|
||||
$text = $(templateMarkdown).html(marked(textContent));
|
||||
} else {
|
||||
$text = $(templateText);
|
||||
$code = $('<code/>').appendTo($text);
|
||||
|
||||
if (textContent.length < 20000) {
|
||||
$code.empty().html(prism.highlight(textContent, prism.languages[type]));
|
||||
} else {
|
||||
$code.empty().text(textContent);
|
||||
setTimeout(function () { $code.empty().html(prism.highlight(textContent, prism.languages[type])); }, 300);
|
||||
}
|
||||
}
|
||||
$('#pv-content').empty().append($text).fadeIn(200);
|
||||
onAdjustSize();
|
||||
|
||||
preview.setIndex(currentIdx + 1, currentItems.length);
|
||||
preview.setLabels([
|
||||
currentItem.label,
|
||||
'' + currentItem.size + ' bytes'
|
||||
]);
|
||||
preview.setRawLink(currentItem.absHref);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
onIdxChange(0);
|
||||
preview.setOnIndexChange(onIdxChange);
|
||||
preview.setOnAdjustSize(onAdjustSize);
|
||||
preview.enter();
|
||||
},
|
||||
|
||||
initItem = function (item) {
|
||||
|
||||
if (item.$view && _.indexOf(_.keys(settings.types), item.type) >= 0) {
|
||||
item.$view.find('a').on('click', function (event) {
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
var matchedEntries = _.compact(_.map($('#items .item'), function (item) {
|
||||
|
||||
item = $(item).data('item');
|
||||
return _.indexOf(_.keys(settings.types), item.type) >= 0 ? item : null;
|
||||
}));
|
||||
|
||||
onEnter(matchedEntries, _.indexOf(matchedEntries, item));
|
||||
preview.setIndex(currentIdx + 1, currentItems.length);
|
||||
preview.setLabels([
|
||||
currentItem.label,
|
||||
'' + currentItem.size + ' bytes'
|
||||
]);
|
||||
preview.setRawLink(currentItem.absHref);
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
onLocationChanged = function (item) {
|
||||
onIdxChange(0);
|
||||
preview.setOnIndexChange(onIdxChange);
|
||||
preview.setOnAdjustSize(onAdjustSize);
|
||||
preview.enter();
|
||||
}
|
||||
|
||||
_.each(item.content, initItem);
|
||||
},
|
||||
function initItem(item) {
|
||||
|
||||
onLocationRefreshed = function (item, added, removed) {
|
||||
if (item.$view && _.indexOf(_.keys(settings.types), item.type) >= 0) {
|
||||
item.$view.find('a').on('click', function (event) {
|
||||
|
||||
_.each(added, initItem);
|
||||
},
|
||||
event.preventDefault();
|
||||
|
||||
init = function () {
|
||||
var matchedEntries = _.compact(_.map($('#items .item'), function (item) {
|
||||
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
}
|
||||
item = $(item).data('item');
|
||||
return _.indexOf(_.keys(settings.types), item.type) >= 0 ? item : null;
|
||||
}));
|
||||
|
||||
onEnter(matchedEntries, _.indexOf(matchedEntries, item));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function onLocationChanged(item) {
|
||||
|
||||
_.each(item.content, initItem);
|
||||
}
|
||||
|
||||
function onLocationRefreshed(item, added, removed) {
|
||||
|
||||
_.each(added, initItem);
|
||||
}
|
||||
|
||||
function init() {
|
||||
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.sub('location.changed', onLocationChanged);
|
||||
event.sub('location.refreshed', onLocationRefreshed);
|
||||
}
|
||||
|
||||
event.sub('location.changed', onLocationChanged);
|
||||
event.sub('location.refreshed', onLocationRefreshed);
|
||||
};
|
||||
|
||||
init();
|
||||
});
|
||||
|
|
|
@ -1,123 +1,124 @@
|
|||
|
||||
modulejs.define('ext/preview-vid', ['_', '$', 'core/settings', 'core/event', 'ext/preview'], function (_, $, allsettings, event, preview) {
|
||||
|
||||
var settings = _.extend({
|
||||
enabled: false,
|
||||
types: []
|
||||
}, allsettings['preview-vid']),
|
||||
}, allsettings['preview-vid']);
|
||||
|
||||
preloadVid = function (src, callback) {
|
||||
|
||||
var $video = $('<video/>')
|
||||
.one('loadedmetadata', function () {
|
||||
function preloadVid(src, callback) {
|
||||
|
||||
callback($video);
|
||||
// setTimeout(function () { callback($video); }, 1000); // for testing
|
||||
})
|
||||
.attr('autoplay', 'autoplay')
|
||||
.attr('controls', 'controls')
|
||||
.attr('src', src);
|
||||
},
|
||||
var $video = $('<video/>')
|
||||
.one('loadedmetadata', function () {
|
||||
|
||||
onEnter = function (items, idx) {
|
||||
callback($video);
|
||||
// setTimeout(function () { callback($video); }, 1000); // for testing
|
||||
})
|
||||
.attr('autoplay', 'autoplay')
|
||||
.attr('controls', 'controls')
|
||||
.attr('src', src);
|
||||
}
|
||||
|
||||
var currentItems = items,
|
||||
currentIdx = idx,
|
||||
currentItem = items[idx],
|
||||
function onEnter(items, idx) {
|
||||
|
||||
onAdjustSize = function () {
|
||||
var currentItems = items;
|
||||
var currentIdx = idx;
|
||||
var currentItem = items[idx];
|
||||
|
||||
var $content = $('#pv-content'),
|
||||
$vid = $('#pv-vid-video');
|
||||
function onAdjustSize() {
|
||||
|
||||
if ($vid.length) {
|
||||
var $content = $('#pv-content'),
|
||||
$vid = $('#pv-vid-video');
|
||||
|
||||
$vid.css({
|
||||
'left': '' + (($content.width()-$vid.width())*0.5) + 'px',
|
||||
'top': '' + (($content.height()-$vid.height())*0.5) + 'px'
|
||||
});
|
||||
if ($vid.length) {
|
||||
|
||||
preview.setLabels([
|
||||
currentItem.label,
|
||||
'' + $vid[0].videoWidth + 'x' + $vid[0].videoHeight,
|
||||
'' + (100 * $vid.width() / $vid[0].videoWidth).toFixed(0) + '%'
|
||||
]);
|
||||
}
|
||||
},
|
||||
|
||||
onIdxChange = function (rel) {
|
||||
|
||||
currentIdx = (currentIdx + rel + currentItems.length) % currentItems.length;
|
||||
currentItem = currentItems[currentIdx];
|
||||
|
||||
var spinnerTimeout = setTimeout(function () { preview.showSpinner(true); }, 200);
|
||||
|
||||
if ($('#pv-vid-video').length) {
|
||||
$('#pv-vid-video')[0].pause();
|
||||
}
|
||||
preloadVid(currentItem.absHref, function ($preloaded_vid) {
|
||||
|
||||
clearTimeout(spinnerTimeout);
|
||||
preview.showSpinner(false);
|
||||
|
||||
$('#pv-content').fadeOut(100, function () {
|
||||
|
||||
$('#pv-content').empty().append($preloaded_vid.attr('id', 'pv-vid-video')).fadeIn(200);
|
||||
|
||||
// small timeout, so $preloaded_vid is visible and therefore $preloaded_vid.width is available
|
||||
setTimeout(function () {
|
||||
onAdjustSize();
|
||||
|
||||
preview.setIndex(currentIdx + 1, currentItems.length);
|
||||
preview.setRawLink(currentItem.absHref);
|
||||
}, 10);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
onIdxChange(0);
|
||||
preview.setOnIndexChange(onIdxChange);
|
||||
preview.setOnAdjustSize(onAdjustSize);
|
||||
preview.enter();
|
||||
},
|
||||
|
||||
initItem = function (item) {
|
||||
|
||||
if (item.$view && _.indexOf(settings.types, item.type) >= 0) {
|
||||
item.$view.find('a').on('click', function (event) {
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
var matchedEntries = _.compact(_.map($('#items .item'), function (item) {
|
||||
|
||||
item = $(item).data('item');
|
||||
return _.indexOf(settings.types, item.type) >= 0 ? item : null;
|
||||
}));
|
||||
|
||||
onEnter(matchedEntries, _.indexOf(matchedEntries, item));
|
||||
$vid.css({
|
||||
'left': '' + (($content.width()-$vid.width())*0.5) + 'px',
|
||||
'top': '' + (($content.height()-$vid.height())*0.5) + 'px'
|
||||
});
|
||||
|
||||
preview.setLabels([
|
||||
currentItem.label,
|
||||
'' + $vid[0].videoWidth + 'x' + $vid[0].videoHeight,
|
||||
'' + (100 * $vid.width() / $vid[0].videoWidth).toFixed(0) + '%'
|
||||
]);
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
onLocationChanged = function (item) {
|
||||
function onIdxChange(rel) {
|
||||
|
||||
_.each(item.content, initItem);
|
||||
},
|
||||
currentIdx = (currentIdx + rel + currentItems.length) % currentItems.length;
|
||||
currentItem = currentItems[currentIdx];
|
||||
|
||||
onLocationRefreshed = function (item, added, removed) {
|
||||
var spinnerTimeout = setTimeout(function () { preview.showSpinner(true); }, 200);
|
||||
|
||||
_.each(added, initItem);
|
||||
},
|
||||
|
||||
init = function () {
|
||||
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
if ($('#pv-vid-video').length) {
|
||||
$('#pv-vid-video')[0].pause();
|
||||
}
|
||||
preloadVid(currentItem.absHref, function ($preloaded_vid) {
|
||||
|
||||
clearTimeout(spinnerTimeout);
|
||||
preview.showSpinner(false);
|
||||
|
||||
$('#pv-content').fadeOut(100, function () {
|
||||
|
||||
$('#pv-content').empty().append($preloaded_vid.attr('id', 'pv-vid-video')).fadeIn(200);
|
||||
|
||||
// small timeout, so $preloaded_vid is visible and therefore $preloaded_vid.width is available
|
||||
setTimeout(function () {
|
||||
onAdjustSize();
|
||||
|
||||
preview.setIndex(currentIdx + 1, currentItems.length);
|
||||
preview.setRawLink(currentItem.absHref);
|
||||
}, 10);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
onIdxChange(0);
|
||||
preview.setOnIndexChange(onIdxChange);
|
||||
preview.setOnAdjustSize(onAdjustSize);
|
||||
preview.enter();
|
||||
}
|
||||
|
||||
function initItem(item) {
|
||||
|
||||
if (item.$view && _.indexOf(settings.types, item.type) >= 0) {
|
||||
item.$view.find('a').on('click', function (event) {
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
var matchedEntries = _.compact(_.map($('#items .item'), function (item) {
|
||||
|
||||
item = $(item).data('item');
|
||||
return _.indexOf(settings.types, item.type) >= 0 ? item : null;
|
||||
}));
|
||||
|
||||
onEnter(matchedEntries, _.indexOf(matchedEntries, item));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function onLocationChanged(item) {
|
||||
|
||||
_.each(item.content, initItem);
|
||||
}
|
||||
|
||||
function onLocationRefreshed(item, added, removed) {
|
||||
|
||||
_.each(added, initItem);
|
||||
}
|
||||
|
||||
function init() {
|
||||
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.sub('location.changed', onLocationChanged);
|
||||
event.sub('location.refreshed', onLocationRefreshed);
|
||||
}
|
||||
|
||||
event.sub('location.changed', onLocationChanged);
|
||||
event.sub('location.refreshed', onLocationRefreshed);
|
||||
};
|
||||
|
||||
init();
|
||||
});
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
|
||||
modulejs.define('ext/preview', ['_', '$', 'core/settings', 'core/resource', 'core/store'], function (_, $, allsettings, resource, store) {
|
||||
|
||||
var settings = _.extend({
|
||||
enabled: true
|
||||
}, allsettings.preview),
|
||||
|
||||
template =
|
||||
}, allsettings.preview);
|
||||
var template =
|
||||
'<div id="pv-overlay" class="noSelection">' +
|
||||
'<div id="pv-content"/>' +
|
||||
'<div id="pv-spinner"><img src="' + resource.image('spinner') + '"/></div>' +
|
||||
|
@ -21,217 +19,217 @@ 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>' +
|
||||
'</ul>' +
|
||||
'</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 = [],
|
||||
currentIdx = 0,
|
||||
isFullscreen = store.get(storekey) || false,
|
||||
function adjustSize() {
|
||||
|
||||
adjustSize = function () {
|
||||
var rect = $(window).fracs('viewport');
|
||||
var $container = $('#pv-content');
|
||||
var $spinner = $('#pv-spinner');
|
||||
var margin = isFullscreen ? 0 : 20;
|
||||
var barheight = isFullscreen ? 0 : 31;
|
||||
|
||||
var rect = $(window).fracs('viewport'),
|
||||
$container = $('#pv-content'),
|
||||
$spinner = $('#pv-spinner'),
|
||||
margin = isFullscreen ? 0 : 20,
|
||||
barheight = isFullscreen ? 0 : 31;
|
||||
$container.css({
|
||||
width: rect.width - 2 * margin,
|
||||
height: rect.height - 2 * margin - barheight,
|
||||
left: margin,
|
||||
top: margin
|
||||
});
|
||||
|
||||
$container.css({
|
||||
width: rect.width - 2 * margin,
|
||||
height: rect.height - 2 * margin - barheight,
|
||||
left: margin,
|
||||
top: margin
|
||||
});
|
||||
$spinner.css({
|
||||
left: rect.width * 0.5,
|
||||
top: rect.height * 0.5
|
||||
});
|
||||
|
||||
$spinner.css({
|
||||
left: rect.width * 0.5,
|
||||
top: rect.height * 0.5
|
||||
});
|
||||
if (isFullscreen) {
|
||||
$('#pv-overlay').addClass('fullscreen');
|
||||
$('#pv-bar-fullscreen').find('img').attr('src', resource.image('preview/no-fullscreen'));
|
||||
} else {
|
||||
$('#pv-overlay').removeClass('fullscreen');
|
||||
$('#pv-bar-fullscreen').find('img').attr('src', resource.image('preview/fullscreen'));
|
||||
}
|
||||
|
||||
if (isFullscreen) {
|
||||
$('#pv-overlay').addClass('fullscreen');
|
||||
$('#pv-bar-fullscreen').find('img').attr('src', resource.image('preview/no-fullscreen'));
|
||||
} else {
|
||||
$('#pv-overlay').removeClass('fullscreen');
|
||||
$('#pv-bar-fullscreen').find('img').attr('src', resource.image('preview/fullscreen'));
|
||||
}
|
||||
if (_.isFunction(onAdjustSize)) {
|
||||
onAdjustSize(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (_.isFunction(onAdjustSize)) {
|
||||
onAdjustSize(1);
|
||||
}
|
||||
},
|
||||
function onEnter() {
|
||||
|
||||
onEnter = function () {
|
||||
$('#pv-content').empty();
|
||||
setLabels([]);
|
||||
$('#pv-overlay').stop(true, true).fadeIn(200);
|
||||
$(window).on('keydown', onKeydown);
|
||||
|
||||
adjustSize();
|
||||
}
|
||||
|
||||
function onExit() {
|
||||
|
||||
$(window).off('keydown', onKeydown);
|
||||
$('#pv-overlay').stop(true, true).fadeOut(200, function () {
|
||||
$('#pv-content').empty();
|
||||
setLabels([]);
|
||||
$('#pv-overlay').stop(true, true).fadeIn(200);
|
||||
$(window).on('keydown', onKeydown);
|
||||
});
|
||||
}
|
||||
|
||||
adjustSize();
|
||||
},
|
||||
function onNext() {
|
||||
|
||||
onExit = function () {
|
||||
if (_.isFunction(onIndexChange)) {
|
||||
onIndexChange(1);
|
||||
}
|
||||
}
|
||||
|
||||
$(window).off('keydown', onKeydown);
|
||||
$('#pv-overlay').stop(true, true).fadeOut(200, function () {
|
||||
$('#pv-content').empty();
|
||||
setLabels([]);
|
||||
});
|
||||
},
|
||||
function onPrevious() {
|
||||
|
||||
onNext = function () {
|
||||
if (_.isFunction(onIndexChange)) {
|
||||
onIndexChange(-1);
|
||||
}
|
||||
}
|
||||
|
||||
if (_.isFunction(onIndexChange)) {
|
||||
onIndexChange(1);
|
||||
}
|
||||
},
|
||||
function userAlive() {
|
||||
|
||||
onPrevious = function () {
|
||||
clearTimeout(userAliveTimeoutId);
|
||||
$('#pv-overlay .hof').stop(true, true).fadeIn(200);
|
||||
|
||||
if (_.isFunction(onIndexChange)) {
|
||||
onIndexChange(-1);
|
||||
}
|
||||
},
|
||||
if (isFullscreen) {
|
||||
userAliveTimeoutId = setTimeout(function () {
|
||||
|
||||
userAliveTimeoutId = null,
|
||||
userAlive = function () {
|
||||
$('#pv-overlay .hof').stop(true, true).fadeOut(2000);
|
||||
}, 2000);
|
||||
}
|
||||
}
|
||||
|
||||
clearTimeout(userAliveTimeoutId);
|
||||
$('#pv-overlay .hof').stop(true, true).fadeIn(200);
|
||||
function onFullscreen() {
|
||||
|
||||
if (isFullscreen) {
|
||||
userAliveTimeoutId = setTimeout(function () {
|
||||
isFullscreen = !isFullscreen;
|
||||
store.put(storekey, isFullscreen);
|
||||
|
||||
$('#pv-overlay .hof').stop(true, true).fadeOut(2000);
|
||||
}, 2000);
|
||||
}
|
||||
},
|
||||
userAlive();
|
||||
adjustSize();
|
||||
}
|
||||
|
||||
onFullscreen = function () {
|
||||
function onKeydown(ev) {
|
||||
|
||||
isFullscreen = !isFullscreen;
|
||||
store.put(storekey, isFullscreen);
|
||||
var key = ev.which;
|
||||
var delay = 300;
|
||||
|
||||
userAlive();
|
||||
adjustSize();
|
||||
},
|
||||
if (key === 27) { // esc
|
||||
ev.preventDefault();
|
||||
ev.stopImmediatePropagation();
|
||||
onExit();
|
||||
} else if (key === 8 || key === 37) { // backspace, left
|
||||
ev.preventDefault();
|
||||
ev.stopImmediatePropagation();
|
||||
$('#pv-bar-prev').addClass('hover');
|
||||
setTimeout(function () { $('#pv-bar-prev').removeClass('hover'); }, delay);
|
||||
onPrevious();
|
||||
} else if (key === 13 || key === 32 || key === 39) { // enter, space, right
|
||||
ev.preventDefault();
|
||||
ev.stopImmediatePropagation();
|
||||
$('#pv-bar-next').addClass('hover');
|
||||
setTimeout(function () { $('#pv-bar-next').removeClass('hover'); }, delay);
|
||||
onNext();
|
||||
} else if (key === 70) { // f
|
||||
ev.preventDefault();
|
||||
ev.stopImmediatePropagation();
|
||||
$('#pv-bar-fullscreen').addClass('hover');
|
||||
setTimeout(function () { $('#pv-bar-fullscreen').removeClass('hover'); }, delay);
|
||||
onFullscreen();
|
||||
}
|
||||
}
|
||||
|
||||
onKeydown = function (event) {
|
||||
function setIndex(idx, total) {
|
||||
|
||||
var key = event.which,
|
||||
delay = 300;
|
||||
if (_.isNumber(idx)) {
|
||||
$('#pv-bar-idx').text('' + idx + (_.isNumber(total) ? '/' + total : '')).show();
|
||||
} else {
|
||||
$('#pv-bar-idx').text('').hide();
|
||||
}
|
||||
}
|
||||
|
||||
if (key === 27) { // esc
|
||||
event.preventDefault();
|
||||
event.stopImmediatePropagation();
|
||||
onExit();
|
||||
} else if (key === 8 || key === 37) { // backspace, left
|
||||
event.preventDefault();
|
||||
event.stopImmediatePropagation();
|
||||
$('#pv-bar-prev').addClass('hover');
|
||||
setTimeout(function () { $('#pv-bar-prev').removeClass('hover'); }, delay);
|
||||
onPrevious();
|
||||
} else if (key === 13 || key === 32 || key === 39) { // enter, space, right
|
||||
event.preventDefault();
|
||||
event.stopImmediatePropagation();
|
||||
$('#pv-bar-next').addClass('hover');
|
||||
setTimeout(function () { $('#pv-bar-next').removeClass('hover'); }, delay);
|
||||
onNext();
|
||||
} else if (key === 70) { // f
|
||||
event.preventDefault();
|
||||
event.stopImmediatePropagation();
|
||||
$('#pv-bar-fullscreen').addClass('hover');
|
||||
setTimeout(function () { $('#pv-bar-fullscreen').removeClass('hover'); }, delay);
|
||||
onFullscreen();
|
||||
}
|
||||
},
|
||||
function setRawLink(href) {
|
||||
|
||||
setIndex = function (idx, total) {
|
||||
if (href) {
|
||||
$('#pv-bar-raw').find('a').attr('href', href).end().show();
|
||||
} else {
|
||||
$('#pv-bar-raw').find('a').attr('href', '#').end().hide();
|
||||
}
|
||||
}
|
||||
|
||||
if (_.isNumber(idx)) {
|
||||
$('#pv-bar-idx').text('' + idx + (_.isNumber(total) ? '/' + total : '')).show();
|
||||
} else {
|
||||
$('#pv-bar-idx').text('').hide();
|
||||
}
|
||||
},
|
||||
function setLabels(labels) {
|
||||
|
||||
setRawLink = function (href) {
|
||||
$('#pv-buttons .bar-left').remove();
|
||||
_.each(labels, function (label) {
|
||||
|
||||
if (href) {
|
||||
$('#pv-bar-raw').find('a').attr('href', href).end().show();
|
||||
} else {
|
||||
$('#pv-bar-raw').find('a').attr('href', '#').end().hide();
|
||||
}
|
||||
},
|
||||
$('<li/>')
|
||||
.addClass('bar-left bar-label')
|
||||
.text(label)
|
||||
.appendTo('#pv-buttons');
|
||||
});
|
||||
}
|
||||
|
||||
setLabels = function (labels) {
|
||||
function setOnIndexChange(fn) {
|
||||
|
||||
$('#pv-buttons .bar-left').remove();
|
||||
_.each(labels, function (label) {
|
||||
onIndexChange = fn;
|
||||
}
|
||||
|
||||
$('<li/>')
|
||||
.addClass('bar-left bar-label')
|
||||
.text(label)
|
||||
.appendTo('#pv-buttons');
|
||||
});
|
||||
},
|
||||
function setOnAdjustSize(fn) {
|
||||
|
||||
onIndexChange = null,
|
||||
setOnIndexChange = function (fn) {
|
||||
onAdjustSize = fn;
|
||||
}
|
||||
|
||||
onIndexChange = fn;
|
||||
},
|
||||
function showSpinner(show, millis) {
|
||||
|
||||
onAdjustSize = null,
|
||||
setOnAdjustSize = function (fn) {
|
||||
if (!_.isNumber(millis)) {
|
||||
millis = 400;
|
||||
}
|
||||
|
||||
onAdjustSize = fn;
|
||||
},
|
||||
if (show) {
|
||||
$('#pv-spinner').stop(true, true).fadeIn(millis);
|
||||
} else {
|
||||
$('#pv-spinner').stop(true, true).fadeOut(millis);
|
||||
}
|
||||
}
|
||||
|
||||
showSpinner = function (show, millis) {
|
||||
function init() {
|
||||
|
||||
if (!_.isNumber(millis)) {
|
||||
millis = 400;
|
||||
}
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (show) {
|
||||
$('#pv-spinner').stop(true, true).fadeIn(millis);
|
||||
} else {
|
||||
$('#pv-spinner').stop(true, true).fadeOut(millis);
|
||||
}
|
||||
},
|
||||
$(template).appendTo('body');
|
||||
|
||||
init = function () {
|
||||
$('#pv-spinner').hide();
|
||||
$('#pv-bar-prev, #pv-prev-area').on('click', onPrevious);
|
||||
$('#pv-bar-next, #pv-next-area').on('click', onNext);
|
||||
$('#pv-bar-close, #pv-close-area').on('click', onExit);
|
||||
$('#pv-bar-fullscreen').on('click', onFullscreen);
|
||||
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
}
|
||||
$('#pv-overlay')
|
||||
.on('keydown', onKeydown)
|
||||
.on('mousemove mousedown', userAlive)
|
||||
.on('click mousedown mousemove keydown keypress', function (ev) {
|
||||
|
||||
$(template).appendTo('body');
|
||||
|
||||
$('#pv-spinner').hide();
|
||||
$('#pv-bar-prev, #pv-prev-area').on('click', onPrevious);
|
||||
$('#pv-bar-next, #pv-next-area').on('click', onNext);
|
||||
$('#pv-bar-close, #pv-close-area').on('click', onExit);
|
||||
$('#pv-bar-fullscreen').on('click', onFullscreen);
|
||||
|
||||
$('#pv-overlay')
|
||||
.on('keydown', onKeydown)
|
||||
.on('mousemove mousedown', userAlive)
|
||||
.on('click mousedown mousemove keydown keypress', function (event) {
|
||||
|
||||
if (event.type === 'click') {
|
||||
if (event.target.id === 'pv-overlay' || event.target.id === 'pv-content') {
|
||||
onExit();
|
||||
}
|
||||
if (ev.type === 'click') {
|
||||
if (ev.target.id === 'pv-overlay' || ev.target.id === 'pv-content') {
|
||||
onExit();
|
||||
}
|
||||
event.stopImmediatePropagation();
|
||||
});
|
||||
}
|
||||
ev.stopImmediatePropagation();
|
||||
});
|
||||
|
||||
$(window).on('resize load', adjustSize);
|
||||
}
|
||||
|
||||
$(window).on('resize load', adjustSize);
|
||||
};
|
||||
|
||||
init();
|
||||
|
||||
|
|
|
@ -1,55 +1,53 @@
|
|||
|
||||
modulejs.define('ext/qrcode', ['_', '$', 'modernizr', 'core/settings', 'core/event'], function (_, $, modernizr, allsettings, event) {
|
||||
|
||||
var settings = _.extend({
|
||||
enabled: false,
|
||||
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({
|
||||
render: modernizr.canvas ? 'canvas' : 'div',
|
||||
width: settings.size,
|
||||
height: settings.size,
|
||||
color: '#333',
|
||||
bgColor: '#fff',
|
||||
text: window.location.protocol + '//' + window.location.host + item.absHref
|
||||
});
|
||||
}
|
||||
|
||||
$qrcode.empty().qrcode({
|
||||
render: modernizr.canvas ? 'canvas' : 'div',
|
||||
width: settings.size,
|
||||
height: settings.size,
|
||||
color: '#333',
|
||||
bgColor: '#fff',
|
||||
text: window.location.protocol + '//' + window.location.host + item.absHref
|
||||
});
|
||||
},
|
||||
function onMouseenter(item) {
|
||||
|
||||
onMouseenter = function (item) {
|
||||
if (!item.isFolder()) {
|
||||
update(item);
|
||||
clearTimeout(hideTimeoutId);
|
||||
$qrcode.stop(true, true).fadeIn(400);
|
||||
}
|
||||
}
|
||||
|
||||
if (!item.isFolder()) {
|
||||
update(item);
|
||||
clearTimeout(hideTimeoutId);
|
||||
$qrcode.stop(true, true).fadeIn(400);
|
||||
}
|
||||
},
|
||||
function onMouseleave(item) {
|
||||
|
||||
onMouseleave = function (item) {
|
||||
hideTimeoutId = setTimeout(function () {
|
||||
|
||||
hideTimeoutId = setTimeout(function () {
|
||||
$qrcode.stop(true, true).fadeOut(400);
|
||||
}, 200);
|
||||
}
|
||||
|
||||
$qrcode.stop(true, true).fadeOut(400);
|
||||
}, 200);
|
||||
},
|
||||
function init() {
|
||||
|
||||
init = function () {
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
}
|
||||
$qrcode = $(template).appendTo('body');
|
||||
|
||||
$qrcode = $(template).appendTo('body');
|
||||
|
||||
event.sub('item.mouseenter', onMouseenter);
|
||||
event.sub('item.mouseleave', onMouseleave);
|
||||
};
|
||||
event.sub('item.mouseenter', onMouseenter);
|
||||
event.sub('item.mouseleave', onMouseleave);
|
||||
}
|
||||
|
||||
init();
|
||||
});
|
||||
|
|
|
@ -1,180 +1,179 @@
|
|||
|
||||
modulejs.define('ext/select', ['_', '$', 'core/settings', 'core/resource', 'core/event'], function (_, $, allsettings, resource, event) {
|
||||
|
||||
var settings = _.extend({
|
||||
enabled: 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,
|
||||
l = 0, t = 0, w = 0, h = 0,
|
||||
shrink = 1/3,
|
||||
$document = $(document),
|
||||
$selectionRect = $('<div id="selection-rect"/>'),
|
||||
function publish() {
|
||||
|
||||
publish = function () {
|
||||
|
||||
var items = _.map($('#items .item.selected'), function (itemElement) {
|
||||
var items = _.map($('#items .item.selected'), function (itemElement) {
|
||||
|
||||
return $(itemElement).data('item');
|
||||
});
|
||||
|
||||
event.pub('selection', items);
|
||||
},
|
||||
event.pub('selection', items);
|
||||
}
|
||||
|
||||
selectionUpdate = function (event) {
|
||||
function selectionUpdate(event) {
|
||||
|
||||
l = Math.min(x, event.pageX);
|
||||
t = Math.min(y, event.pageY);
|
||||
w = Math.abs(x - event.pageX);
|
||||
h = Math.abs(y - event.pageY);
|
||||
l = Math.min(x, event.pageX);
|
||||
t = Math.min(y, event.pageY);
|
||||
w = Math.abs(x - event.pageX);
|
||||
h = Math.abs(y - event.pageY);
|
||||
|
||||
event.preventDefault();
|
||||
$selectionRect
|
||||
.stop(true, true)
|
||||
.css({left: l, top: t, width: w, height: h, opacity: 1})
|
||||
.show();
|
||||
event.preventDefault();
|
||||
$selectionRect
|
||||
.stop(true, true)
|
||||
.css({left: l, top: t, width: w, height: h, opacity: 1})
|
||||
.show();
|
||||
|
||||
var selRect = $selectionRect.fracs('rect');
|
||||
$('#items .item').removeClass('selecting').each(function () {
|
||||
var selRect = $selectionRect.fracs('rect');
|
||||
$('#items .item').removeClass('selecting').each(function () {
|
||||
|
||||
var $item = $(this),
|
||||
rect = $item.find('a').fracs('rect'),
|
||||
inter = selRect.intersection(rect);
|
||||
if (inter && !$item.hasClass('folder-parent')) {
|
||||
$item.addClass('selecting');
|
||||
var $item = $(this);
|
||||
var rect = $item.find('a').fracs('rect');
|
||||
var inter = selRect.intersection(rect);
|
||||
|
||||
if (inter && !$item.hasClass('folder-parent')) {
|
||||
$item.addClass('selecting');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function selectionEnd(event) {
|
||||
|
||||
event.preventDefault();
|
||||
$document.off('mousemove', selectionUpdate);
|
||||
$('#items .item.selecting.selected').removeClass('selecting').removeClass('selected');
|
||||
$('#items .item.selecting').removeClass('selecting').addClass('selected');
|
||||
publish();
|
||||
|
||||
$selectionRect
|
||||
.stop(true, true)
|
||||
.animate(
|
||||
{
|
||||
left: l + w * 0.5 * shrink,
|
||||
top: t + h * 0.5 * shrink,
|
||||
width: w * (1 - shrink),
|
||||
height: h * (1 - shrink),
|
||||
opacity: 0
|
||||
},
|
||||
300,
|
||||
function () {
|
||||
$selectionRect.hide();
|
||||
}
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
selectionEnd = function (event) {
|
||||
function selectionStart(event) {
|
||||
|
||||
event.preventDefault();
|
||||
$document.off('mousemove', selectionUpdate);
|
||||
$('#items .item.selecting.selected').removeClass('selecting').removeClass('selected');
|
||||
$('#items .item.selecting').removeClass('selecting').addClass('selected');
|
||||
var $window = $(window);
|
||||
var viewRight = $window.scrollLeft() + $window.width();
|
||||
var viewBottom = $window.scrollTop() + $window.height();
|
||||
|
||||
x = event.pageX;
|
||||
y = event.pageY;
|
||||
|
||||
// only on left button and don't block the scrollbars
|
||||
if (event.button !== 0 || x >= viewRight || y >= viewBottom) {
|
||||
return;
|
||||
}
|
||||
|
||||
$(':focus').blur();
|
||||
if (!event.ctrlKey && !event.metaKey) {
|
||||
$('#items .item').removeClass('selected');
|
||||
publish();
|
||||
}
|
||||
|
||||
$selectionRect
|
||||
.stop(true, true)
|
||||
.animate(
|
||||
{
|
||||
left: l + w * 0.5 * shrink,
|
||||
top: t + h * 0.5 * shrink,
|
||||
width: w * (1 - shrink),
|
||||
height: h * (1 - shrink),
|
||||
opacity: 0
|
||||
},
|
||||
300,
|
||||
function () {
|
||||
$selectionRect.hide();
|
||||
}
|
||||
);
|
||||
},
|
||||
$document
|
||||
.on('mousemove', selectionUpdate)
|
||||
.one('mouseup', selectionEnd);
|
||||
|
||||
selectionStart = function (event) {
|
||||
selectionUpdate(event);
|
||||
}
|
||||
|
||||
var $window = $(window),
|
||||
viewRight = $window.scrollLeft() + $window.width(),
|
||||
viewBottom = $window.scrollTop() + $window.height();
|
||||
function noSelection(event) {
|
||||
|
||||
x = event.pageX;
|
||||
y = event.pageY;
|
||||
event.stopImmediatePropagation();
|
||||
return false;
|
||||
}
|
||||
|
||||
// only on left button and don't block the scrollbars
|
||||
if (event.button !== 0 || x >= viewRight || y >= viewBottom) {
|
||||
return;
|
||||
function noSelectionUnlessCtrl(event) {
|
||||
|
||||
if (!event.ctrlKey && !event.metaKey) {
|
||||
noSelection(event);
|
||||
}
|
||||
}
|
||||
|
||||
function initItem(item) {
|
||||
|
||||
if (item.$view) {
|
||||
$(template)
|
||||
.appendTo(item.$view.find('a'))
|
||||
.on('click', function (event) {
|
||||
|
||||
event.stopImmediatePropagation();
|
||||
event.preventDefault();
|
||||
|
||||
item.$view.toggleClass('selected');
|
||||
publish();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function onLocationChanged(item) {
|
||||
|
||||
if (settings.checkboxes) {
|
||||
_.each(item.content, initItem);
|
||||
}
|
||||
publish();
|
||||
}
|
||||
|
||||
function onLocationRefreshed(item, added, removed) {
|
||||
|
||||
var selectionChanged = false;
|
||||
|
||||
if (settings.checkboxes) {
|
||||
_.each(added, initItem);
|
||||
}
|
||||
_.each(removed, function (item) {
|
||||
|
||||
if (item.$view && item.$view.hasClass('selected')) {
|
||||
item.$view.removeClass('selected');
|
||||
selectionChanged = true;
|
||||
}
|
||||
});
|
||||
|
||||
$(':focus').blur();
|
||||
if (!event.ctrlKey && !event.metaKey) {
|
||||
$('#items .item').removeClass('selected');
|
||||
publish();
|
||||
}
|
||||
|
||||
$document
|
||||
.on('mousemove', selectionUpdate)
|
||||
.one('mouseup', selectionEnd);
|
||||
|
||||
selectionUpdate(event);
|
||||
},
|
||||
|
||||
noSelection = function (event) {
|
||||
|
||||
event.stopImmediatePropagation();
|
||||
return false;
|
||||
},
|
||||
|
||||
noSelectionUnlessCtrl = function (event) {
|
||||
|
||||
if (!event.ctrlKey && !event.metaKey) {
|
||||
noSelection(event);
|
||||
}
|
||||
},
|
||||
|
||||
initItem = function (item) {
|
||||
|
||||
if (item.$view) {
|
||||
|
||||
$(template)
|
||||
.appendTo(item.$view.find('a'))
|
||||
.on('click', function (event) {
|
||||
|
||||
event.stopImmediatePropagation();
|
||||
event.preventDefault();
|
||||
|
||||
item.$view.toggleClass('selected');
|
||||
publish();
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
onLocationChanged = function (item) {
|
||||
|
||||
if (settings.checkboxes) {
|
||||
_.each(item.content, initItem);
|
||||
}
|
||||
if (selectionChanged) {
|
||||
publish();
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
onLocationRefreshed = function (item, added, removed) {
|
||||
function init() {
|
||||
|
||||
var selectionChanged = false;
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (settings.checkboxes) {
|
||||
_.each(added, initItem);
|
||||
}
|
||||
_.each(removed, function (item) {
|
||||
$selectionRect.hide().appendTo('body');
|
||||
|
||||
if (item.$view && item.$view.hasClass('selected')) {
|
||||
item.$view.removeClass('selected');
|
||||
selectionChanged = true;
|
||||
}
|
||||
});
|
||||
event.sub('location.changed', onLocationChanged);
|
||||
event.sub('location.refreshed', onLocationRefreshed);
|
||||
|
||||
if (selectionChanged) {
|
||||
publish();
|
||||
}
|
||||
},
|
||||
$document
|
||||
.on('mousedown', '.noSelection', noSelection)
|
||||
.on('mousedown', '.noSelectionUnlessCtrl,input,select,a', noSelectionUnlessCtrl)
|
||||
.on('mousedown', selectionStart);
|
||||
}
|
||||
|
||||
init = function () {
|
||||
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
$selectionRect.hide().appendTo('body');
|
||||
|
||||
event.sub('location.changed', onLocationChanged);
|
||||
event.sub('location.refreshed', onLocationRefreshed);
|
||||
|
||||
$document
|
||||
.on('mousedown', '.noSelection', noSelection)
|
||||
.on('mousedown', '.noSelectionUnlessCtrl,input,select,a', noSelectionUnlessCtrl)
|
||||
.on('mousedown', selectionStart);
|
||||
};
|
||||
|
||||
init();
|
||||
});
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
modulejs.define('ext/sort', ['_', '$', 'core/settings', 'core/resource', 'core/event', 'core/store'], function (_, $, allsettings, resource, event, store) {
|
||||
|
||||
var settings = _.extend({
|
||||
|
@ -8,210 +7,210 @@ modulejs.define('ext/sort', ['_', '$', 'core/settings', 'core/resource', 'core/e
|
|||
ignorecase: true,
|
||||
natural: false,
|
||||
folders: 0
|
||||
}, allsettings.sort),
|
||||
|
||||
storekey = 'ext/sort',
|
||||
template =
|
||||
}, allsettings.sort);
|
||||
var storekey = 'ext/sort';
|
||||
var template =
|
||||
'<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) {
|
||||
|
||||
var $item = $(item);
|
||||
function getType(item) {
|
||||
|
||||
if ($item.hasClass('folder-parent')) {
|
||||
return 0;
|
||||
var $item = $(item);
|
||||
|
||||
if ($item.hasClass('folder-parent')) {
|
||||
return 0;
|
||||
}
|
||||
if ($item.hasClass('folder')) {
|
||||
if (settings.folders === 1) {
|
||||
return 2;
|
||||
} else if (settings.folders === 2) {
|
||||
return 3;
|
||||
}
|
||||
if ($item.hasClass('folder')) {
|
||||
if (settings.folders === 1) {
|
||||
return 2;
|
||||
} else if (settings.folders === 2) {
|
||||
return 3;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return 2;
|
||||
},
|
||||
return 1;
|
||||
}
|
||||
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,
|
||||
1: getTime,
|
||||
2: getSize
|
||||
},
|
||||
|
||||
columnClasses = {
|
||||
};
|
||||
var columnClasses = {
|
||||
0: 'label',
|
||||
1: 'date',
|
||||
2: 'size'
|
||||
},
|
||||
|
||||
// Natural Sort algorithm for Javascript - Version 0.7 - Released under MIT license
|
||||
// Author: Jim Palmer (based on chunking idea from Dave Koelle)
|
||||
//
|
||||
// Modified to make it work with h5ai
|
||||
naturalCmpFn = function (val1, val2) {
|
||||
|
||||
var re = /(^-?[0-9]+(\.?[0-9]*)[df]?e?[0-9]?$|^0x[0-9a-f]+$|[0-9]+)/gi,
|
||||
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})/,
|
||||
hre = /^0x[0-9a-f]+$/i,
|
||||
ore = /^0/,
|
||||
// convert all to strings strip whitespace
|
||||
x = ('' + val1).replace(sre, ''),
|
||||
y = ('' + val2).replace(sre, ''),
|
||||
// chunk/tokenize
|
||||
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'),
|
||||
// numeric, hex or date detection
|
||||
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,
|
||||
oFxNcL, oFyNcL;
|
||||
// first try and sort Hex codes or Dates
|
||||
if (yD) {
|
||||
if (xD < yD) {
|
||||
return -1;
|
||||
} else if (xD > yD) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
// natural sorting through split numeric strings and default strings
|
||||
for(var cLoc=0, numS=Math.max(xN.length, yN.length); cLoc < numS; cLoc += 1) {
|
||||
// find floats not starting with '0', string or 0 if not defined (Clint Priest)
|
||||
oFxNcL = !(xN[cLoc] || '').match(ore) && parseFloat(xN[cLoc]) || xN[cLoc] || 0;
|
||||
oFyNcL = !(yN[cLoc] || '').match(ore) && parseFloat(yN[cLoc]) || yN[cLoc] || 0;
|
||||
// handle numeric vs string comparison - number < string - (Kyle Adams)
|
||||
if (isNaN(oFxNcL) !== isNaN(oFyNcL)) { return (isNaN(oFxNcL)) ? 1 : -1; }
|
||||
// rely on string comparison if different types - i.e. '02' < 2 != '02' < '2'
|
||||
else if (typeof oFxNcL !== typeof oFyNcL) {
|
||||
oFxNcL += '';
|
||||
oFyNcL += '';
|
||||
}
|
||||
if (oFxNcL < oFyNcL) {
|
||||
return -1;
|
||||
}
|
||||
if (oFxNcL > oFyNcL) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
},
|
||||
|
||||
cmpFn = function (getValue, reverse, ignorecase, natural) {
|
||||
|
||||
return function (item1, item2) {
|
||||
|
||||
var res, val1, val2;
|
||||
|
||||
res = getType(item1) - getType(item2);
|
||||
if (res !== 0) {
|
||||
return res;
|
||||
}
|
||||
|
||||
val1 = getValue(item1);
|
||||
val2 = getValue(item2);
|
||||
|
||||
if (isNaN(val1) || isNaN(val2)) {
|
||||
val1 = '' + val1;
|
||||
val2 = '' + val2;
|
||||
|
||||
if (ignorecase) {
|
||||
val1 = val1.toLowerCase();
|
||||
val2 = val2.toLowerCase();
|
||||
}
|
||||
}
|
||||
|
||||
if (natural) {
|
||||
res = naturalCmpFn(val1, val2);
|
||||
} else {
|
||||
res = val1 < val2 ? -1 : (val1 > val2 ? 1 : 0);
|
||||
}
|
||||
|
||||
return reverse ? -res : res;
|
||||
};
|
||||
},
|
||||
|
||||
sortItems = function (column, reverse) {
|
||||
|
||||
var headers = $('#items li.header a'),
|
||||
header = $('#items li.header a.' + columnClasses[column]),
|
||||
|
||||
fn = cmpFn(columnGetters[column], reverse, settings.ignorecase, column === 0 && settings.natural),
|
||||
|
||||
current = $('#items .item'),
|
||||
sorted = $('#items .item').sort(fn);
|
||||
|
||||
store.put(storekey, {column: column, reverse: reverse});
|
||||
|
||||
headers.removeClass('ascending descending');
|
||||
header.addClass(reverse ? 'descending' : 'ascending');
|
||||
|
||||
for (var i = 0, l = current.length; i < l; i += 1) {
|
||||
if (current[i] !== sorted[i]) {
|
||||
sorted.detach().sort(fn).appendTo('#items');
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
onContentChanged = function (item) {
|
||||
|
||||
var order = store.get(storekey),
|
||||
column = order && order.column || settings.column,
|
||||
reverse = order && order.reverse || settings.reverse;
|
||||
|
||||
sortItems(column, reverse);
|
||||
},
|
||||
|
||||
init = function () {
|
||||
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
$('#items li.header')
|
||||
|
||||
.find('a.label')
|
||||
.append(template)
|
||||
.click(function (event) {
|
||||
sortItems(0, $(this).hasClass('ascending'));
|
||||
event.preventDefault();
|
||||
})
|
||||
.end()
|
||||
|
||||
.find('a.date')
|
||||
.prepend(template)
|
||||
.click(function (event) {
|
||||
sortItems(1, $(this).hasClass('ascending'));
|
||||
event.preventDefault();
|
||||
})
|
||||
.end()
|
||||
|
||||
.find('a.size')
|
||||
.prepend(template)
|
||||
.click(function (event) {
|
||||
sortItems(2, $(this).hasClass('ascending'));
|
||||
event.preventDefault();
|
||||
})
|
||||
.end();
|
||||
|
||||
event.sub('location.changed', onContentChanged);
|
||||
event.sub('location.refreshed', onContentChanged);
|
||||
};
|
||||
|
||||
|
||||
// Natural Sort algorithm for Javascript - Version 0.7 - Released under MIT license
|
||||
// Author: Jim Palmer (based on chunking idea from Dave Koelle)
|
||||
//
|
||||
// Modified to make it work with h5ai
|
||||
function naturalCmpFn(val1, val2) {
|
||||
|
||||
var re = /(^-?[0-9]+(\.?[0-9]*)[df]?e?[0-9]?$|^0x[0-9a-f]+$|[0-9]+)/gi;
|
||||
var sre = /(^[ ]*|[ ]*$)/g;
|
||||
var dre = /(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/;
|
||||
var hre = /^0x[0-9a-f]+$/i;
|
||||
var ore = /^0/;
|
||||
// convert all to strings strip whitespace
|
||||
var x = ('' + val1).replace(sre, '');
|
||||
var y = ('' + val2).replace(sre, '');
|
||||
// chunk/tokenize
|
||||
var xN = x.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
|
||||
var xD = parseInt(x.match(hre), 10) || (xN.length !== 1 && x.match(dre) && Date.parse(x));
|
||||
var yD = parseInt(y.match(hre), 10) || xD && y.match(dre) && Date.parse(y) || null;
|
||||
var oFxNcL, oFyNcL;
|
||||
// first try and sort Hex codes or Dates
|
||||
if (yD) {
|
||||
if (xD < yD) {
|
||||
return -1;
|
||||
} else if (xD > yD) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
// natural sorting through split numeric strings and default strings
|
||||
for(var cLoc=0, numS=Math.max(xN.length, yN.length); cLoc < numS; cLoc += 1) {
|
||||
// find floats not starting with '0', string or 0 if not defined (Clint Priest)
|
||||
oFxNcL = !(xN[cLoc] || '').match(ore) && parseFloat(xN[cLoc]) || xN[cLoc] || 0;
|
||||
oFyNcL = !(yN[cLoc] || '').match(ore) && parseFloat(yN[cLoc]) || yN[cLoc] || 0;
|
||||
// handle numeric vs string comparison - number < string - (Kyle Adams)
|
||||
if (isNaN(oFxNcL) !== isNaN(oFyNcL)) { return (isNaN(oFxNcL)) ? 1 : -1; }
|
||||
// rely on string comparison if different types - i.e. '02' < 2 != '02' < '2'
|
||||
else if (typeof oFxNcL !== typeof oFyNcL) {
|
||||
oFxNcL += '';
|
||||
oFyNcL += '';
|
||||
}
|
||||
if (oFxNcL < oFyNcL) {
|
||||
return -1;
|
||||
}
|
||||
if (oFxNcL > oFyNcL) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
function cmpFn(getValue, reverse, ignorecase, natural) {
|
||||
|
||||
return function (item1, item2) {
|
||||
|
||||
var res, val1, val2;
|
||||
|
||||
res = getType(item1) - getType(item2);
|
||||
if (res !== 0) {
|
||||
return res;
|
||||
}
|
||||
|
||||
val1 = getValue(item1);
|
||||
val2 = getValue(item2);
|
||||
|
||||
if (isNaN(val1) || isNaN(val2)) {
|
||||
val1 = '' + val1;
|
||||
val2 = '' + val2;
|
||||
|
||||
if (ignorecase) {
|
||||
val1 = val1.toLowerCase();
|
||||
val2 = val2.toLowerCase();
|
||||
}
|
||||
}
|
||||
|
||||
if (natural) {
|
||||
res = naturalCmpFn(val1, val2);
|
||||
} else {
|
||||
res = val1 < val2 ? -1 : (val1 > val2 ? 1 : 0);
|
||||
}
|
||||
|
||||
return reverse ? -res : res;
|
||||
};
|
||||
}
|
||||
|
||||
function sortItems(column, reverse) {
|
||||
|
||||
var headers = $('#items li.header a');
|
||||
var header = $('#items li.header a.' + columnClasses[column]);
|
||||
var fn = cmpFn(columnGetters[column], reverse, settings.ignorecase, column === 0 && settings.natural);
|
||||
var current = $('#items .item');
|
||||
var sorted = $('#items .item').sort(fn);
|
||||
|
||||
store.put(storekey, {column: column, reverse: reverse});
|
||||
|
||||
headers.removeClass('ascending descending');
|
||||
header.addClass(reverse ? 'descending' : 'ascending');
|
||||
|
||||
for (var i = 0, l = current.length; i < l; i += 1) {
|
||||
if (current[i] !== sorted[i]) {
|
||||
sorted.detach().sort(fn).appendTo('#items');
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onContentChanged(item) {
|
||||
|
||||
var order = store.get(storekey);
|
||||
var column = order && order.column || settings.column;
|
||||
var reverse = order && order.reverse || settings.reverse;
|
||||
|
||||
sortItems(column, reverse);
|
||||
}
|
||||
|
||||
function init() {
|
||||
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
$('#items li.header')
|
||||
|
||||
.find('a.label')
|
||||
.append(template)
|
||||
.click(function (event) {
|
||||
sortItems(0, $(this).hasClass('ascending'));
|
||||
event.preventDefault();
|
||||
})
|
||||
.end()
|
||||
|
||||
.find('a.date')
|
||||
.prepend(template)
|
||||
.click(function (event) {
|
||||
sortItems(1, $(this).hasClass('ascending'));
|
||||
event.preventDefault();
|
||||
})
|
||||
.end()
|
||||
|
||||
.find('a.size')
|
||||
.prepend(template)
|
||||
.click(function (event) {
|
||||
sortItems(2, $(this).hasClass('ascending'));
|
||||
event.preventDefault();
|
||||
})
|
||||
.end();
|
||||
|
||||
event.sub('location.changed', onContentChanged);
|
||||
event.sub('location.refreshed', onContentChanged);
|
||||
}
|
||||
|
||||
|
||||
init();
|
||||
});
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
|
||||
modulejs.define('ext/statusbar', ['_', '$', 'core/settings', 'core/format', 'core/event'], function (_, $, allsettings, format, event) {
|
||||
|
||||
var settings = _.extend({
|
||||
enabled: false
|
||||
}, allsettings.statusbar),
|
||||
|
||||
template =
|
||||
}, allsettings.statusbar);
|
||||
var template =
|
||||
'<span class="statusbar">' +
|
||||
'<span class="status default">' +
|
||||
'<span class="folderTotal"/> <span class="l10n-folders"/>' +
|
||||
|
@ -13,71 +11,72 @@ modulejs.define('ext/statusbar', ['_', '$', 'core/settings', 'core/format', 'cor
|
|||
'<span class="fileTotal"/> <span class="l10n-files"/>' +
|
||||
'</span>' +
|
||||
'<span class="status dynamic"/>' +
|
||||
'</span>',
|
||||
sepTemplate = '<span class="sep"/>',
|
||||
'</span>';
|
||||
var sepTemplate = '<span class="sep"/>';
|
||||
var $statusDynamic;
|
||||
var $statusDefault;
|
||||
|
||||
$statusDynamic,
|
||||
$statusDefault,
|
||||
|
||||
update = function (html) {
|
||||
function update(html) {
|
||||
|
||||
if (html) {
|
||||
$statusDefault.hide();
|
||||
$statusDynamic.empty().append(html).show();
|
||||
} else {
|
||||
$statusDynamic.empty().hide();
|
||||
$statusDefault.show();
|
||||
}
|
||||
},
|
||||
if (html) {
|
||||
$statusDefault.hide();
|
||||
$statusDynamic.empty().append(html).show();
|
||||
} else {
|
||||
$statusDynamic.empty().hide();
|
||||
$statusDefault.show();
|
||||
}
|
||||
}
|
||||
|
||||
init = function () {
|
||||
function init() {
|
||||
|
||||
if (!settings.enabled) {
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
var $statusbar = $(template);
|
||||
var $folderTotal = $statusbar.find('.folderTotal');
|
||||
var $fileTotal = $statusbar.find('.fileTotal');
|
||||
var onLocationChanged = function (item) {
|
||||
|
||||
var stats = item.getStats();
|
||||
$folderTotal.text(stats.folders);
|
||||
$fileTotal.text(stats.files);
|
||||
};
|
||||
|
||||
$statusDefault = $statusbar.find('.status.default');
|
||||
$statusDynamic = $statusbar.find('.status.dynamic');
|
||||
|
||||
$('#bottombar > .center').append($statusbar);
|
||||
|
||||
event.sub('statusbar', update);
|
||||
event.sub('location.changed', onLocationChanged);
|
||||
event.sub('location.refreshed', onLocationChanged);
|
||||
|
||||
event.sub('item.mouseenter', function (item) {
|
||||
|
||||
if (item.isCurrentParentFolder()) {
|
||||
return;
|
||||
}
|
||||
|
||||
var $statusbar = $(template),
|
||||
$folderTotal = $statusbar.find('.folderTotal'),
|
||||
$fileTotal = $statusbar.find('.fileTotal'),
|
||||
onLocationChanged = function (item) {
|
||||
var $span = $('<span/>').append(item.label);
|
||||
|
||||
var stats = item.getStats();
|
||||
$folderTotal.text(stats.folders);
|
||||
$fileTotal.text(stats.files);
|
||||
};
|
||||
if (_.isNumber(item.time)) {
|
||||
$span.append(sepTemplate).append(format.formatDate(item.time));
|
||||
}
|
||||
if (_.isNumber(item.size)) {
|
||||
$span.append(sepTemplate).append(format.formatSize(item.size));
|
||||
}
|
||||
|
||||
$statusDefault = $statusbar.find('.status.default');
|
||||
$statusDynamic = $statusbar.find('.status.dynamic');
|
||||
update($span);
|
||||
});
|
||||
|
||||
$('#bottombar > .center').append($statusbar);
|
||||
event.sub('item.mouseleave', function (item) {
|
||||
|
||||
event.sub('statusbar', update);
|
||||
event.sub('location.changed', onLocationChanged);
|
||||
event.sub('location.refreshed', onLocationChanged);
|
||||
update();
|
||||
});
|
||||
}
|
||||
|
||||
event.sub('item.mouseenter', function (item) {
|
||||
|
||||
if (item.isCurrentParentFolder()) {
|
||||
return;
|
||||
}
|
||||
|
||||
var $span = $('<span/>').append(item.label);
|
||||
|
||||
if (_.isNumber(item.time)) {
|
||||
$span.append(sepTemplate).append(format.formatDate(item.time));
|
||||
}
|
||||
if (_.isNumber(item.size)) {
|
||||
$span.append(sepTemplate).append(format.formatSize(item.size));
|
||||
}
|
||||
|
||||
update($span);
|
||||
});
|
||||
|
||||
event.sub('item.mouseleave', function (item) {
|
||||
|
||||
update();
|
||||
});
|
||||
};
|
||||
|
||||
init();
|
||||
});
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
modulejs.define('ext/thumbnails', ['_', 'core/settings', 'core/event', 'core/server'], function (_, allsettings, event, server) {
|
||||
|
||||
var settings = _.extend({
|
||||
|
@ -8,83 +7,85 @@ modulejs.define('ext/thumbnails', ['_', 'core/settings', 'core/event', 'core/ser
|
|||
doc: ['pdf', 'ps'],
|
||||
delay: 1000,
|
||||
size: 96
|
||||
}, allsettings.thumbnails),
|
||||
}, allsettings.thumbnails);
|
||||
|
||||
requestThumb = function (type, href, mode, ratio, callback) {
|
||||
|
||||
server.request({
|
||||
action: 'getThumbHref',
|
||||
type: type,
|
||||
href: href,
|
||||
mode: mode,
|
||||
width: settings.size * ratio,
|
||||
height: settings.size
|
||||
}, function (json) {
|
||||
function requestThumb(type, href, mode, ratio, callback) {
|
||||
|
||||
callback(json && json.code === 0 ? json.absHref : null);
|
||||
});
|
||||
},
|
||||
server.request({
|
||||
action: 'getThumbHref',
|
||||
type: type,
|
||||
href: href,
|
||||
mode: mode,
|
||||
width: settings.size * ratio,
|
||||
height: settings.size
|
||||
}, function (json) {
|
||||
|
||||
checkItem = function (item) {
|
||||
callback(json && json.code === 0 ? json.absHref : null);
|
||||
});
|
||||
}
|
||||
|
||||
var type = null;
|
||||
function checkItem(item) {
|
||||
|
||||
if (_.contains(settings.img, item.type)) {
|
||||
type = 'img';
|
||||
} else if (_.contains(settings.mov, item.type)) {
|
||||
type = 'mov';
|
||||
} else if (_.contains(settings.doc, item.type)) {
|
||||
type = 'doc';
|
||||
var type = null;
|
||||
|
||||
if (_.contains(settings.img, item.type)) {
|
||||
type = 'img';
|
||||
} else if (_.contains(settings.mov, item.type)) {
|
||||
type = 'mov';
|
||||
} else if (_.contains(settings.doc, item.type)) {
|
||||
type = 'doc';
|
||||
}
|
||||
|
||||
if (type) {
|
||||
if (item.thumbSquare) {
|
||||
item.$view.find('.icon.square img').addClass('thumb').attr('src', item.thumbSquare);
|
||||
} else {
|
||||
requestThumb(type, item.absHref, 'square', 1, function (src) {
|
||||
|
||||
if (src && item.$view) {
|
||||
item.thumbSquare = src;
|
||||
item.$view.find('.icon.square img').addClass('thumb').attr('src', src);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (item.thumbRational) {
|
||||
item.$view.find('.icon.rational img').addClass('thumb').attr('src', item.thumbRational);
|
||||
} else {
|
||||
requestThumb(type, item.absHref, 'rational', 2, function (src) {
|
||||
|
||||
if (type) {
|
||||
if (item.thumbSquare) {
|
||||
item.$view.find('.icon.square img').addClass('thumb').attr('src', item.thumbSquare);
|
||||
} else {
|
||||
requestThumb(type, item.absHref, 'square', 1, function (src) {
|
||||
|
||||
if (src && item.$view) {
|
||||
item.thumbSquare = src;
|
||||
item.$view.find('.icon.square img').addClass('thumb').attr('src', src);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (item.thumbRational) {
|
||||
item.$view.find('.icon.rational img').addClass('thumb').attr('src', item.thumbRational);
|
||||
} else {
|
||||
requestThumb(type, item.absHref, 'rational', 2, function (src) {
|
||||
|
||||
if (src && item.$view) {
|
||||
item.thumbRational = src;
|
||||
item.$view.find('.icon.rational img').addClass('thumb').attr('src', src);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (src && item.$view) {
|
||||
item.thumbRational = src;
|
||||
item.$view.find('.icon.rational img').addClass('thumb').attr('src', src);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
onLocationChanged = function (item) {
|
||||
function onLocationChanged(item) {
|
||||
|
||||
setTimeout(function () {
|
||||
setTimeout(function () {
|
||||
|
||||
_.each(item.content, checkItem);
|
||||
}, settings.delay);
|
||||
},
|
||||
_.each(item.content, checkItem);
|
||||
}, 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) {
|
||||
return;
|
||||
}
|
||||
if (!settings.enabled || !server.api) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.sub('location.changed', onLocationChanged);
|
||||
event.sub('location.refreshed', onLocationRefreshed);
|
||||
}
|
||||
|
||||
event.sub('location.changed', onLocationChanged);
|
||||
event.sub('location.refreshed', onLocationRefreshed);
|
||||
};
|
||||
|
||||
init();
|
||||
});
|
||||
|
|
|
@ -1,30 +1,29 @@
|
|||
|
||||
modulejs.define('ext/title', ['_', 'core/settings', 'core/event'], function (_, allsettings, event) {
|
||||
|
||||
var settings = _.extend({
|
||||
enabled: false
|
||||
}, allsettings.title),
|
||||
}, allsettings.title);
|
||||
|
||||
onLocationChanged = function (item) {
|
||||
function onLocationChanged(item) {
|
||||
|
||||
var labels = _.pluck(item.getCrumb(), 'label'),
|
||||
title = labels.join(' > ');
|
||||
var labels = _.pluck(item.getCrumb(), 'label'),
|
||||
title = labels.join(' > ');
|
||||
|
||||
if (labels.length > 1) {
|
||||
title = labels[labels.length - 1] + ' - ' + title;
|
||||
}
|
||||
if (labels.length > 1) {
|
||||
title = labels[labels.length - 1] + ' - ' + title;
|
||||
}
|
||||
|
||||
document.title = title;
|
||||
},
|
||||
document.title = title;
|
||||
}
|
||||
|
||||
init = function () {
|
||||
function init() {
|
||||
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
}
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.sub('location.changed', onLocationChanged);
|
||||
};
|
||||
event.sub('location.changed', onLocationChanged);
|
||||
}
|
||||
|
||||
init();
|
||||
});
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
|
||||
modulejs.define('ext/tree', ['_', '$', 'core/settings', 'core/resource', 'core/event', 'core/location'], function (_, $, allsettings, resource, event, location) {
|
||||
|
||||
var settings = _.extend({
|
||||
enabled: false,
|
||||
slide: true,
|
||||
maxSubfolders: 50
|
||||
}, allsettings.tree),
|
||||
|
||||
template =
|
||||
}, allsettings.tree);
|
||||
var template =
|
||||
'<div class="item">' +
|
||||
'<span class="indicator none">' +
|
||||
'<img src="' + resource.image('tree') + '"/>' +
|
||||
|
@ -16,222 +14,225 @@ modulejs.define('ext/tree', ['_', '$', 'core/settings', 'core/resource', 'core/e
|
|||
'<span class="icon"><img/></span>' +
|
||||
'<span class="label"/>' +
|
||||
'</a>' +
|
||||
'</span>',
|
||||
statusHintTemplate = '<span class="hint"/>',
|
||||
|
||||
update = function (item) {
|
||||
|
||||
var $html = $(template),
|
||||
$indicator = $html.find('.indicator'),
|
||||
$a = $html.find('a'),
|
||||
$img = $html.find('.icon img'),
|
||||
$label = $html.find('.label');
|
||||
|
||||
$html
|
||||
.addClass(item.isFolder() ? 'folder' : 'file')
|
||||
.data('item', item);
|
||||
|
||||
location.setLink($a, item);
|
||||
$img.attr('src', resource.image('folder'));
|
||||
$label.text(item.label);
|
||||
|
||||
if (item.isFolder()) {
|
||||
|
||||
var subfolders = item.getSubfolders();
|
||||
|
||||
// indicator
|
||||
if ((item.isManaged && !item.isContentFetched) || subfolders.length) {
|
||||
|
||||
$indicator.removeClass('none');
|
||||
|
||||
if ((item.isManaged && !item.isContentFetched)) {
|
||||
$indicator.addClass('unknown');
|
||||
} else if (item.isContentVisible) {
|
||||
$indicator.addClass('open');
|
||||
} else {
|
||||
$indicator.addClass('close');
|
||||
}
|
||||
}
|
||||
|
||||
// is it the domain?
|
||||
if (item.isDomain()) {
|
||||
$html.addClass('domain');
|
||||
$img.attr('src', resource.image('home'));
|
||||
}
|
||||
|
||||
// is it the root?
|
||||
if (item.isRoot()) {
|
||||
$html.addClass('root');
|
||||
$img.attr('src', resource.image('home'));
|
||||
}
|
||||
|
||||
// is it the current folder?
|
||||
if (item.isCurrentFolder()) {
|
||||
$html.addClass('current');
|
||||
// $img.attr('src', resource.image('folder-open'));
|
||||
}
|
||||
|
||||
// does it have subfolders?
|
||||
if (subfolders.length) {
|
||||
var $ul = $('<ul class="content"/>').appendTo($html),
|
||||
counter = 0;
|
||||
_.each(subfolders, function (e) {
|
||||
counter += 1;
|
||||
if (counter <= settings.maxSubfolders) {
|
||||
$('<li/>').append(update(e)).appendTo($ul);
|
||||
}
|
||||
});
|
||||
if (subfolders.length > settings.maxSubfolders) {
|
||||
$('<li class="summary">… ' + (subfolders.length - settings.maxSubfolders) + ' more subfolders</li>').appendTo($ul);
|
||||
}
|
||||
if (!item.isContentVisible) {
|
||||
$ul.hide();
|
||||
}
|
||||
}
|
||||
|
||||
// reflect folder status
|
||||
if (!item.isManaged) {
|
||||
$img.attr('src', resource.image('folder-page'));
|
||||
}
|
||||
}
|
||||
'</span>';
|
||||
var statusHintTemplate = '<span class="hint"/>';
|
||||
|
||||
|
||||
if (item.$tree) {
|
||||
item.$tree.replaceWith($html);
|
||||
}
|
||||
item.$tree = $html;
|
||||
function update(item) {
|
||||
|
||||
return $html;
|
||||
},
|
||||
var $html = $(template);
|
||||
var $indicator = $html.find('.indicator');
|
||||
var $a = $html.find('a');
|
||||
var $img = $html.find('.icon img');
|
||||
var $label = $html.find('.label');
|
||||
|
||||
createOnIndicatorClick = function () {
|
||||
$html
|
||||
.addClass(item.isFolder() ? 'folder' : 'file')
|
||||
.data('item', item);
|
||||
|
||||
var $tree = $('#tree'),
|
||||
slide = function (item, $indicator, $content, down) {
|
||||
location.setLink($a, item);
|
||||
$img.attr('src', resource.image('folder'));
|
||||
$label.text(item.label);
|
||||
|
||||
item.isContentVisible = down;
|
||||
$indicator.removeClass('open close').addClass(down ? 'open' : 'close');
|
||||
$tree.scrollpanel('update', true);
|
||||
$content[down ? 'slideDown' : 'slideUp'](function () {
|
||||
if (item.isFolder()) {
|
||||
|
||||
$tree.scrollpanel('update');
|
||||
});
|
||||
};
|
||||
var subfolders = item.getSubfolders();
|
||||
|
||||
return function () {
|
||||
// indicator
|
||||
if ((item.isManaged && !item.isContentFetched) || subfolders.length) {
|
||||
|
||||
var $indicator = $(this),
|
||||
$item = $indicator.closest('.item'),
|
||||
item = $item.data('item'),
|
||||
$content = $item.find('> ul.content');
|
||||
$indicator.removeClass('none');
|
||||
|
||||
if ($indicator.hasClass('unknown')) {
|
||||
|
||||
item.fetchContent(function (item) {
|
||||
|
||||
item.isContentVisible = false;
|
||||
|
||||
var $item = update(item),
|
||||
$indicator = $item.find('> .indicator'),
|
||||
$content = $item.find('> ul.content');
|
||||
|
||||
if (!$indicator.hasClass('none')) {
|
||||
slide(item, $indicator, $content, true);
|
||||
}
|
||||
});
|
||||
|
||||
} else if ($indicator.hasClass('open')) {
|
||||
|
||||
slide(item, $indicator, $content, false);
|
||||
|
||||
} else if ($indicator.hasClass('close')) {
|
||||
|
||||
slide(item, $indicator, $content, true);
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
shiftTree = function (forceVisible, dontAnimate) {
|
||||
|
||||
var $tree = $("#tree"),
|
||||
$view = $("#view"),
|
||||
left = ((settings.slide && $tree.outerWidth() < $view.offset().left) || forceVisible || !$view.is(':visible')) ? 0 : 18 - $tree.outerWidth();
|
||||
|
||||
if (dontAnimate) {
|
||||
$tree.stop().css({ left: left });
|
||||
} else {
|
||||
$tree.stop().animate({ left: left });
|
||||
}
|
||||
},
|
||||
|
||||
fetchTree = function (item, callback) {
|
||||
|
||||
item.isContentVisible = true;
|
||||
item.fetchContent(function (item) {
|
||||
|
||||
if (item.parent) {
|
||||
fetchTree(item.parent, callback);
|
||||
if ((item.isManaged && !item.isContentFetched)) {
|
||||
$indicator.addClass('unknown');
|
||||
} else if (item.isContentVisible) {
|
||||
$indicator.addClass('open');
|
||||
} else {
|
||||
callback(item);
|
||||
$indicator.addClass('close');
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
adjustSpacing = function () {
|
||||
|
||||
var $tree = $('#tree'),
|
||||
winHeight = $(window).height(),
|
||||
navHeight = $('#topbar').outerHeight(),
|
||||
footerHeight = $('#bottombar').outerHeight();
|
||||
|
||||
$tree.css({
|
||||
top: navHeight,
|
||||
height: winHeight - navHeight - footerHeight - 16
|
||||
});
|
||||
|
||||
$tree.scrollpanel('update');
|
||||
},
|
||||
|
||||
onLocationChanged = function (item) {
|
||||
|
||||
fetchTree(item, function (root) {
|
||||
|
||||
$('#tree')
|
||||
.find('.sp-container').append(update(root)).end()
|
||||
.show();
|
||||
adjustSpacing();
|
||||
shiftTree(false, true);
|
||||
});
|
||||
},
|
||||
|
||||
init = function () {
|
||||
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
var $tree = $('<div id="tree"/>')
|
||||
.appendTo('body')
|
||||
.scrollpanel()
|
||||
.on('click', '.indicator', createOnIndicatorClick())
|
||||
.on('mouseenter', function () {
|
||||
// is it the domain?
|
||||
if (item.isDomain()) {
|
||||
$html.addClass('domain');
|
||||
$img.attr('src', resource.image('home'));
|
||||
}
|
||||
|
||||
shiftTree(true);
|
||||
})
|
||||
.on('mouseleave', function () {
|
||||
// is it the root?
|
||||
if (item.isRoot()) {
|
||||
$html.addClass('root');
|
||||
$img.attr('src', resource.image('home'));
|
||||
}
|
||||
|
||||
shiftTree();
|
||||
// is it the current folder?
|
||||
if (item.isCurrentFolder()) {
|
||||
$html.addClass('current');
|
||||
// $img.attr('src', resource.image('folder-open'));
|
||||
}
|
||||
|
||||
// does it have subfolders?
|
||||
if (subfolders.length) {
|
||||
var $ul = $('<ul class="content"/>').appendTo($html),
|
||||
counter = 0;
|
||||
_.each(subfolders, function (e) {
|
||||
counter += 1;
|
||||
if (counter <= settings.maxSubfolders) {
|
||||
$('<li/>').append(update(e)).appendTo($ul);
|
||||
}
|
||||
});
|
||||
if (subfolders.length > settings.maxSubfolders) {
|
||||
$('<li class="summary">… ' + (subfolders.length - settings.maxSubfolders) + ' more subfolders</li>').appendTo($ul);
|
||||
}
|
||||
if (!item.isContentVisible) {
|
||||
$ul.hide();
|
||||
}
|
||||
}
|
||||
|
||||
// reflect folder status
|
||||
if (!item.isManaged) {
|
||||
$img.attr('src', resource.image('folder-page'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (item.$tree) {
|
||||
item.$tree.replaceWith($html);
|
||||
}
|
||||
item.$tree = $html;
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
function createOnIndicatorClick() {
|
||||
|
||||
var $tree = $('#tree');
|
||||
|
||||
function slide(item, $indicator, $content, down) {
|
||||
|
||||
item.isContentVisible = down;
|
||||
$indicator.removeClass('open close').addClass(down ? 'open' : 'close');
|
||||
$tree.scrollpanel('update', true);
|
||||
$content[down ? 'slideDown' : 'slideUp'](function () {
|
||||
|
||||
$tree.scrollpanel('update');
|
||||
});
|
||||
}
|
||||
|
||||
return function () {
|
||||
|
||||
var $indicator = $(this);
|
||||
var $item = $indicator.closest('.item');
|
||||
var item = $item.data('item');
|
||||
var $content = $item.find('> ul.content');
|
||||
|
||||
if ($indicator.hasClass('unknown')) {
|
||||
|
||||
item.fetchContent(function (item) {
|
||||
|
||||
item.isContentVisible = false;
|
||||
|
||||
var $item = update(item);
|
||||
var $indicator = $item.find('> .indicator');
|
||||
var $content = $item.find('> ul.content');
|
||||
|
||||
if (!$indicator.hasClass('none')) {
|
||||
slide(item, $indicator, $content, true);
|
||||
}
|
||||
});
|
||||
|
||||
event.sub('ready', adjustSpacing);
|
||||
event.sub('location.changed', onLocationChanged);
|
||||
} else if ($indicator.hasClass('open')) {
|
||||
|
||||
$(window).on('resize', function () {
|
||||
slide(item, $indicator, $content, false);
|
||||
|
||||
adjustSpacing();
|
||||
shiftTree();
|
||||
});
|
||||
} else if ($indicator.hasClass('close')) {
|
||||
|
||||
slide(item, $indicator, $content, true);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function shiftTree(forceVisible, dontAnimate) {
|
||||
|
||||
var $tree = $("#tree");
|
||||
var $view = $("#view");
|
||||
var left = ((settings.slide && $tree.outerWidth() < $view.offset().left) || forceVisible || !$view.is(':visible')) ? 0 : 18 - $tree.outerWidth();
|
||||
|
||||
if (dontAnimate) {
|
||||
$tree.stop().css({ left: left });
|
||||
} else {
|
||||
$tree.stop().animate({ left: left });
|
||||
}
|
||||
}
|
||||
|
||||
function fetchTree(item, callback) {
|
||||
|
||||
item.isContentVisible = true;
|
||||
item.fetchContent(function (item) {
|
||||
|
||||
if (item.parent) {
|
||||
fetchTree(item.parent, callback);
|
||||
} else {
|
||||
callback(item);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function adjustSpacing() {
|
||||
|
||||
var $tree = $('#tree');
|
||||
var winHeight = $(window).height();
|
||||
var navHeight = $('#topbar').outerHeight();
|
||||
var footerHeight = $('#bottombar').outerHeight();
|
||||
|
||||
$tree.css({
|
||||
top: navHeight,
|
||||
height: winHeight - navHeight - footerHeight - 16
|
||||
});
|
||||
|
||||
$tree.scrollpanel('update');
|
||||
}
|
||||
|
||||
function onLocationChanged(item) {
|
||||
|
||||
fetchTree(item, function (root) {
|
||||
|
||||
$('#tree')
|
||||
.find('.sp-container').append(update(root)).end()
|
||||
.show();
|
||||
adjustSpacing();
|
||||
shiftTree(false, true);
|
||||
});
|
||||
}
|
||||
|
||||
function init() {
|
||||
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
var $tree = $('<div id="tree"/>')
|
||||
.appendTo('body')
|
||||
.scrollpanel()
|
||||
.on('click', '.indicator', createOnIndicatorClick())
|
||||
.on('mouseenter', function () {
|
||||
|
||||
shiftTree(true);
|
||||
})
|
||||
.on('mouseleave', function () {
|
||||
|
||||
shiftTree();
|
||||
});
|
||||
|
||||
event.sub('ready', adjustSpacing);
|
||||
event.sub('location.changed', onLocationChanged);
|
||||
|
||||
$(window).on('resize', function () {
|
||||
|
||||
adjustSpacing();
|
||||
shiftTree();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
init();
|
||||
});
|
||||
|
|
|
@ -1,19 +1,16 @@
|
|||
|
||||
modulejs.define('info', ['$', 'config'], function ($, config) {
|
||||
|
||||
var testsTemp =
|
||||
'<div id="tests-wrapper">' +
|
||||
'<ul id="tests">' +
|
||||
'</div>',
|
||||
|
||||
testTemp =
|
||||
'</div>';
|
||||
var testTemp =
|
||||
'<li class="test">' +
|
||||
'<span class="label"></span>' +
|
||||
'<span class="result"></span>' +
|
||||
'<div class="info"></div>' +
|
||||
'</li>',
|
||||
|
||||
loginTemp =
|
||||
'</li>';
|
||||
var loginTemp =
|
||||
'<div id="login-wrapper">' +
|
||||
'<input id="pass" type="password" placeholder="password"/>' +
|
||||
'<span id="login">login</span>' +
|
||||
|
@ -22,157 +19,159 @@ modulejs.define('info', ['$', 'config'], function ($, config) {
|
|||
'The preset password is the empty string, so just hit login. ' +
|
||||
'You might change it in the index file to keep this information private.' +
|
||||
'</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)
|
||||
.find('.label')
|
||||
.text(label)
|
||||
.end()
|
||||
.find('.result')
|
||||
.addClass(passed ? 'passed' : 'failed')
|
||||
.text(result ? result : (passed ? 'yes' : 'no'))
|
||||
.end()
|
||||
.find('.info')
|
||||
.html(info)
|
||||
.end()
|
||||
.appendTo('#tests');
|
||||
}
|
||||
|
||||
$(testTemp)
|
||||
.find('.label')
|
||||
.text(label)
|
||||
.end()
|
||||
.find('.result')
|
||||
.addClass(passed ? 'passed' : 'failed')
|
||||
.text(result ? result : (passed ? 'yes' : 'no'))
|
||||
.end()
|
||||
.find('.info')
|
||||
.html(info)
|
||||
.end()
|
||||
.appendTo('#tests');
|
||||
};
|
||||
function addTests() {
|
||||
|
||||
$(testsTemp).appendTo('body');
|
||||
$(testsTemp).appendTo('body');
|
||||
|
||||
addTest(
|
||||
'Index file found', 'Add <code>' + setup.INDEX_HREF + '</code> to your index file list',
|
||||
setup.INDEX_HREF
|
||||
);
|
||||
addTest(
|
||||
'Index file found', 'Add <code>' + setup.INDEX_HREF + '</code> to your index file list',
|
||||
setup.INDEX_HREF
|
||||
);
|
||||
|
||||
addTest(
|
||||
'Options parsable', 'File <code>options.json</code> is readable and syntax is correct',
|
||||
config.options !== null
|
||||
);
|
||||
addTest(
|
||||
'Options parsable', 'File <code>options.json</code> is readable and syntax is correct',
|
||||
config.options !== null
|
||||
);
|
||||
|
||||
addTest(
|
||||
'Types parsable', 'File <code>types.json</code> is readable and syntax is correct',
|
||||
config.types !== null
|
||||
);
|
||||
addTest(
|
||||
'Types parsable', 'File <code>types.json</code> is readable and syntax is correct',
|
||||
config.types !== null
|
||||
);
|
||||
|
||||
addTest(
|
||||
'Server software', 'Server is one of apache, lighttpd, nginx or cherokee',
|
||||
setup.HAS_SERVER, setup.SERVER_NAME + ' ' + setup.SERVER_VERSION
|
||||
);
|
||||
addTest(
|
||||
'Server software', 'Server is one of apache, lighttpd, nginx or cherokee',
|
||||
setup.HAS_SERVER, setup.SERVER_NAME + ' ' + setup.SERVER_VERSION
|
||||
);
|
||||
|
||||
addTest(
|
||||
'PHP version', 'PHP version >= ' + setup.MIN_PHP_VERSION,
|
||||
setup.HAS_PHP_VERSION, setup.PHP_VERSION
|
||||
);
|
||||
addTest(
|
||||
'PHP version', 'PHP version >= ' + setup.MIN_PHP_VERSION,
|
||||
setup.HAS_PHP_VERSION, setup.PHP_VERSION
|
||||
);
|
||||
|
||||
addTest(
|
||||
'Cache directory', 'Web server has write access',
|
||||
setup.HAS_WRITABLE_CACHE
|
||||
);
|
||||
addTest(
|
||||
'Cache directory', 'Web server has write access',
|
||||
setup.HAS_WRITABLE_CACHE
|
||||
);
|
||||
|
||||
addTest(
|
||||
'Image thumbs', 'PHP GD extension with JPEG support available',
|
||||
setup.HAS_PHP_JPG
|
||||
);
|
||||
addTest(
|
||||
'Image thumbs', 'PHP GD extension with JPEG support available',
|
||||
setup.HAS_PHP_JPG
|
||||
);
|
||||
|
||||
addTest(
|
||||
'Use EXIF thumbs', 'PHP EXIF extension available',
|
||||
setup.HAS_PHP_EXIF
|
||||
);
|
||||
addTest(
|
||||
'Use EXIF thumbs', 'PHP EXIF extension available',
|
||||
setup.HAS_PHP_EXIF
|
||||
);
|
||||
|
||||
addTest(
|
||||
'Movie thumbs', 'Command line program <code>avconv</code> or <code>ffmpeg</code> available',
|
||||
setup.HAS_CMD_AVCONV || setup.HAS_CMD_FFMPEG
|
||||
);
|
||||
addTest(
|
||||
'Movie thumbs', 'Command line program <code>avconv</code> or <code>ffmpeg</code> available',
|
||||
setup.HAS_CMD_AVCONV || setup.HAS_CMD_FFMPEG
|
||||
);
|
||||
|
||||
addTest(
|
||||
'PDF thumbs', 'Command line program <code>convert</code> available',
|
||||
setup.HAS_CMD_CONVERT
|
||||
);
|
||||
addTest(
|
||||
'PDF thumbs', 'Command line program <code>convert</code> available',
|
||||
setup.HAS_CMD_CONVERT
|
||||
);
|
||||
|
||||
addTest(
|
||||
'Shell tar', 'Command line program <code>tar</code> available',
|
||||
setup.HAS_CMD_TAR
|
||||
);
|
||||
addTest(
|
||||
'Shell tar', 'Command line program <code>tar</code> available',
|
||||
setup.HAS_CMD_TAR
|
||||
);
|
||||
|
||||
addTest(
|
||||
'Shell zip', 'Command line program <code>zip</code> available',
|
||||
setup.HAS_CMD_ZIP
|
||||
);
|
||||
addTest(
|
||||
'Shell zip', 'Command line program <code>zip</code> available',
|
||||
setup.HAS_CMD_ZIP
|
||||
);
|
||||
|
||||
addTest(
|
||||
'Shell du', 'Command line program <code>du</code> available',
|
||||
setup.HAS_CMD_DU
|
||||
);
|
||||
},
|
||||
addTest(
|
||||
'Shell du', 'Command line program <code>du</code> available',
|
||||
setup.HAS_CMD_DU
|
||||
);
|
||||
}
|
||||
|
||||
addLogin = function () {
|
||||
function request(data) {
|
||||
|
||||
var request = function (data) {
|
||||
$.ajax({
|
||||
url: 'server/php/index.php',
|
||||
type: 'POST',
|
||||
dataType: 'JSON',
|
||||
data: data
|
||||
})
|
||||
.always(function () {
|
||||
|
||||
$.ajax({
|
||||
url: 'server/php/index.php',
|
||||
type: 'POST',
|
||||
dataType: 'JSON',
|
||||
data: data
|
||||
})
|
||||
.always(function () {
|
||||
window.location.reload();
|
||||
});
|
||||
}
|
||||
|
||||
window.location.reload();
|
||||
});
|
||||
},
|
||||
function onLogin() {
|
||||
|
||||
onLogin = function () {
|
||||
request({
|
||||
'action': 'login',
|
||||
'pass': $('#pass').val()
|
||||
});
|
||||
}
|
||||
|
||||
request({
|
||||
'action': 'login',
|
||||
'pass': $('#pass').val()
|
||||
});
|
||||
},
|
||||
function onLogout() {
|
||||
|
||||
onLogout = function () {
|
||||
request({
|
||||
'action': 'logout'
|
||||
});
|
||||
}
|
||||
|
||||
request({
|
||||
'action': 'logout'
|
||||
});
|
||||
},
|
||||
function onKeydown(event) {
|
||||
|
||||
onKeydown = function (event) {
|
||||
if (event.which === 13) {
|
||||
onLogin();
|
||||
}
|
||||
}
|
||||
|
||||
if (event.which === 13) {
|
||||
onLogin();
|
||||
}
|
||||
};
|
||||
function addLogin() {
|
||||
|
||||
$(loginTemp).appendTo('body');
|
||||
|
||||
if (setup.AS_ADMIN) {
|
||||
$('#pass').remove();
|
||||
$('#login').remove();
|
||||
$('#logout').on('click', onLogout);
|
||||
} else {
|
||||
$('#pass').on('keydown', onKeydown).focus();
|
||||
$('#login').on('click', onLogin);
|
||||
$('#logout').remove();
|
||||
}
|
||||
if (setup.HAS_CUSTOM_PASSHASH) {
|
||||
$('#hint').remove();
|
||||
}
|
||||
},
|
||||
$(loginTemp).appendTo('body');
|
||||
|
||||
init = function () {
|
||||
if (setup.AS_ADMIN) {
|
||||
$('#pass').remove();
|
||||
$('#login').remove();
|
||||
$('#logout').on('click', onLogout);
|
||||
} else {
|
||||
$('#pass').on('keydown', onKeydown).focus();
|
||||
$('#login').on('click', onLogin);
|
||||
$('#logout').remove();
|
||||
}
|
||||
if (setup.HAS_CUSTOM_PASSHASH) {
|
||||
$('#hint').remove();
|
||||
}
|
||||
}
|
||||
|
||||
function init() {
|
||||
|
||||
addLogin();
|
||||
if (setup.AS_ADMIN) {
|
||||
addTests();
|
||||
}
|
||||
}
|
||||
|
||||
addLogin();
|
||||
if (setup.AS_ADMIN) {
|
||||
addTests();
|
||||
}
|
||||
};
|
||||
|
||||
init();
|
||||
});
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
modulejs.define('main', ['_', 'core/event'], function (_, event) {
|
||||
|
||||
modulejs.require('view/ensure');
|
||||
|
|
|
@ -1,123 +1,115 @@
|
|||
|
||||
modulejs.define('model/item', ['_', 'core/types', 'core/event', 'core/settings', 'core/server', 'core/location'], function (_, types, event, settings, server, location) {
|
||||
|
||||
|
||||
var reEndsWithSlash = /\/$/,
|
||||
|
||||
startsWith = function (sequence, part) {
|
||||
|
||||
return sequence.slice && part.length && sequence.slice(0, part.length) === part;
|
||||
},
|
||||
var reEndsWithSlash = /\/$/;
|
||||
var reSplitPath = /^(.*\/)([^\/]+\/?)$/;
|
||||
var cache = {};
|
||||
|
||||
|
||||
createLabel = function (sequence) {
|
||||
function startsWith(sequence, part) {
|
||||
|
||||
sequence = sequence.replace(reEndsWithSlash, '');
|
||||
try { sequence = decodeURIComponent(sequence); } catch (e) {}
|
||||
return sequence;
|
||||
},
|
||||
return sequence.slice && part.length && sequence.slice(0, part.length) === part;
|
||||
}
|
||||
|
||||
function createLabel(sequence) {
|
||||
|
||||
reSplitPath = /^(.*\/)([^\/]+\/?)$/,
|
||||
sequence = sequence.replace(reEndsWithSlash, '');
|
||||
try { sequence = decodeURIComponent(sequence); } catch (e) {}
|
||||
return sequence;
|
||||
}
|
||||
|
||||
splitPath = function (sequence) {
|
||||
function splitPath(sequence) {
|
||||
|
||||
if (sequence === '/') {
|
||||
return { parent: null, name: '/' };
|
||||
if (sequence === '/') {
|
||||
return { parent: null, name: '/' };
|
||||
}
|
||||
|
||||
var match = reSplitPath.exec(sequence);
|
||||
if (match) {
|
||||
var split = { parent: match[1], name: match[2] };
|
||||
|
||||
if (split.parent && !startsWith(split.parent, settings.rootHref)) {
|
||||
split.parent = null;
|
||||
}
|
||||
return split;
|
||||
}
|
||||
}
|
||||
|
||||
var match = reSplitPath.exec(sequence);
|
||||
if (match) {
|
||||
var split = { parent: match[1], name: match[2] };
|
||||
function getItem(absHref, time, size, isManaged, isContentFetched, md5, sha1) {
|
||||
|
||||
if (split.parent && !startsWith(split.parent, settings.rootHref)) {
|
||||
split.parent = null;
|
||||
absHref = location.forceEncoding(absHref);
|
||||
|
||||
if (!startsWith(absHref, settings.rootHref)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var self = cache[absHref] || new Item(absHref);
|
||||
|
||||
if (_.isNumber(time)) {
|
||||
self.time = time;
|
||||
}
|
||||
if (_.isNumber(size)) {
|
||||
self.size = size;
|
||||
}
|
||||
if (isManaged) {
|
||||
self.isManaged = true;
|
||||
}
|
||||
if (isContentFetched) {
|
||||
self.isContentFetched = true;
|
||||
}
|
||||
if (md5) {
|
||||
self.md5 = md5;
|
||||
}
|
||||
if (sha1) {
|
||||
self.sha1 = sha1;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
function removeItem(absHref) {
|
||||
|
||||
absHref = location.forceEncoding(absHref);
|
||||
|
||||
var self = cache[absHref];
|
||||
|
||||
if (self) {
|
||||
delete cache[absHref];
|
||||
if (self.parent) {
|
||||
delete self.parent.content[self.absHref];
|
||||
}
|
||||
_.each(self.content, function (item) {
|
||||
|
||||
removeItem(item.absHref);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function fetchContent(absHref, callback) {
|
||||
|
||||
var self = getItem(absHref);
|
||||
|
||||
if (!_.isFunction(callback)) {
|
||||
callback = function () {};
|
||||
}
|
||||
|
||||
if (self.isContentFetched) {
|
||||
callback(self);
|
||||
} else {
|
||||
server.request({action: 'get', items: true, itemsHref: self.absHref, itemsWhat: 1}, function (response) {
|
||||
|
||||
if (response.items) {
|
||||
_.each(response.items, function (item) {
|
||||
getItem(item.absHref, item.time, item.size, item.is_managed, item.content, item.md5, item.sha1);
|
||||
});
|
||||
}
|
||||
return split;
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
|
||||
cache = {},
|
||||
|
||||
getItem = function (absHref, time, size, isManaged, isContentFetched, md5, sha1) {
|
||||
|
||||
absHref = location.forceEncoding(absHref);
|
||||
|
||||
if (!startsWith(absHref, settings.rootHref)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var self = cache[absHref] || new Item(absHref);
|
||||
|
||||
if (_.isNumber(time)) {
|
||||
self.time = time;
|
||||
}
|
||||
if (_.isNumber(size)) {
|
||||
self.size = size;
|
||||
}
|
||||
if (isManaged) {
|
||||
self.isManaged = true;
|
||||
}
|
||||
if (isContentFetched) {
|
||||
self.isContentFetched = true;
|
||||
}
|
||||
if (md5) {
|
||||
self.md5 = md5;
|
||||
}
|
||||
if (sha1) {
|
||||
self.sha1 = sha1;
|
||||
}
|
||||
|
||||
return self;
|
||||
},
|
||||
|
||||
removeItem = function (absHref) {
|
||||
|
||||
absHref = location.forceEncoding(absHref);
|
||||
|
||||
var self = cache[absHref];
|
||||
|
||||
if (self) {
|
||||
delete cache[absHref];
|
||||
if (self.parent) {
|
||||
delete self.parent.content[self.absHref];
|
||||
}
|
||||
_.each(self.content, function (item) {
|
||||
|
||||
removeItem(item.absHref);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
fetchContent = function (absHref, callback) {
|
||||
|
||||
var self = getItem(absHref);
|
||||
|
||||
if (!_.isFunction(callback)) {
|
||||
callback = function () {};
|
||||
}
|
||||
|
||||
if (self.isContentFetched) {
|
||||
callback(self);
|
||||
} else {
|
||||
server.request({action: 'get', items: true, itemsHref: self.absHref, itemsWhat: 1}, function (response) {
|
||||
|
||||
if (response.items) {
|
||||
_.each(response.items, function (item) {
|
||||
getItem(item.absHref, item.time, item.size, item.is_managed, item.content, item.md5, item.sha1);
|
||||
});
|
||||
}
|
||||
|
||||
callback(self);
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
var Item = function (absHref) {
|
||||
function Item(absHref) {
|
||||
|
||||
var split = splitPath(absHref);
|
||||
|
||||
|
@ -139,7 +131,7 @@ modulejs.define('model/item', ['_', 'core/types', 'core/event', 'core/settings',
|
|||
this.parent.isContentFetched = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
_.extend(Item.prototype, {
|
||||
|
||||
|
@ -190,8 +182,8 @@ modulejs.define('model/item', ['_', 'core/types', 'core/event', 'core/settings',
|
|||
|
||||
getCrumb: function () {
|
||||
|
||||
var item = this,
|
||||
crumb = [item];
|
||||
var item = this;
|
||||
var crumb = [item];
|
||||
|
||||
while (item.parent) {
|
||||
item = item.parent;
|
||||
|
@ -214,8 +206,8 @@ modulejs.define('model/item', ['_', 'core/types', 'core/event', 'core/settings',
|
|||
|
||||
getStats: function () {
|
||||
|
||||
var folders = 0,
|
||||
files = 0;
|
||||
var folders = 0;
|
||||
var files = 0;
|
||||
|
||||
_.each(this.content, function (item) {
|
||||
|
||||
|
@ -226,8 +218,8 @@ modulejs.define('model/item', ['_', 'core/types', 'core/event', 'core/settings',
|
|||
}
|
||||
});
|
||||
|
||||
var depth = 0,
|
||||
item = this;
|
||||
var depth = 0;
|
||||
var item = this;
|
||||
|
||||
while (item.parent) {
|
||||
depth += 1;
|
||||
|
@ -242,6 +234,7 @@ modulejs.define('model/item', ['_', 'core/types', 'core/event', 'core/settings',
|
|||
}
|
||||
});
|
||||
|
||||
|
||||
return {
|
||||
get: getItem,
|
||||
remove: removeItem
|
||||
|
|
|
@ -1,50 +1,51 @@
|
|||
|
||||
modulejs.define('view/ensure', ['$', 'config', 'core/event'], function ($, config, event) {
|
||||
|
||||
var selb = '#bottombar',
|
||||
selr = selb + ' .right',
|
||||
sela = selr + ' a',
|
||||
sequence = 'powered by h5ai ' + config.setup.VERSION,
|
||||
url = 'http://larsjung.de/h5ai/',
|
||||
isVisible = ':visible',
|
||||
styleKey = 'style',
|
||||
styleVal = 'display: inline !important',
|
||||
var selb = '#bottombar';
|
||||
var selr = selb + ' .right';
|
||||
var sela = selr + ' a';
|
||||
var sequence = 'powered by h5ai ' + config.setup.VERSION;
|
||||
var url = 'http://larsjung.de/h5ai/';
|
||||
var isVisible = ':visible';
|
||||
var styleKey = 'style';
|
||||
var styleVal = 'display: inline !important';
|
||||
|
||||
ensure = function () {
|
||||
|
||||
if (
|
||||
$(selr).text() !== sequence ||
|
||||
$(sela).attr('href') !== url ||
|
||||
$(sela).filter(isVisible).length !== 1 ||
|
||||
$(selr).filter(isVisible).length !== 1 ||
|
||||
$(selb).filter(isVisible).length !== 1
|
||||
) {
|
||||
if ($(selb).filter(isVisible).length !== 1) {
|
||||
$(selb).remove();
|
||||
$('<div id="bottombar"/>').attr(styleKey, styleVal).appendTo('body');
|
||||
}
|
||||
$(selr).remove();
|
||||
$('<span><a/></span>')
|
||||
.addClass('right')
|
||||
.attr(styleKey, styleVal)
|
||||
.find('a')
|
||||
.attr('href', url)
|
||||
.attr('title', sequence)
|
||||
.text(sequence)
|
||||
.attr(styleKey, styleVal)
|
||||
.end()
|
||||
.prependTo(selb);
|
||||
function ensure() {
|
||||
|
||||
if (
|
||||
$(selr).text() !== sequence ||
|
||||
$(sela).attr('href') !== url ||
|
||||
$(sela).filter(isVisible).length !== 1 ||
|
||||
$(selr).filter(isVisible).length !== 1 ||
|
||||
$(selb).filter(isVisible).length !== 1
|
||||
) {
|
||||
if ($(selb).filter(isVisible).length !== 1) {
|
||||
$(selb).remove();
|
||||
$('<div id="bottombar"/>').attr(styleKey, styleVal).appendTo('body');
|
||||
}
|
||||
},
|
||||
$(selr).remove();
|
||||
$('<span><a/></span>')
|
||||
.addClass('right')
|
||||
.attr(styleKey, styleVal)
|
||||
.find('a')
|
||||
.attr('href', url)
|
||||
.attr('title', sequence)
|
||||
.text(sequence)
|
||||
.attr(styleKey, styleVal)
|
||||
.end()
|
||||
.prependTo(selb);
|
||||
}
|
||||
}
|
||||
|
||||
init = function () {
|
||||
function init() {
|
||||
|
||||
event.sub('ready', function () {
|
||||
event.sub('ready', function () {
|
||||
|
||||
ensure();
|
||||
setInterval(ensure, 60000);
|
||||
});
|
||||
}
|
||||
|
||||
ensure();
|
||||
setInterval(ensure, 60000);
|
||||
});
|
||||
};
|
||||
|
||||
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) {
|
||||
|
||||
var settings = _.extend({
|
||||
|
@ -6,9 +5,8 @@ modulejs.define('view/items', ['_', '$', 'core/settings', 'core/resource', 'core
|
|||
hideFolders: false,
|
||||
hideParentFolder: false,
|
||||
setParentFolderLabels: false
|
||||
}, allsettings.view),
|
||||
|
||||
itemTemplate =
|
||||
}, allsettings.view);
|
||||
var itemTemplate =
|
||||
'<li class="item">' +
|
||||
'<a>' +
|
||||
'<span class="icon square"><img/></span>' +
|
||||
|
@ -17,9 +15,9 @@ modulejs.define('view/items', ['_', '$', 'core/settings', 'core/resource', 'core
|
|||
'<span class="date"/>' +
|
||||
'<span class="size"/>' +
|
||||
'</a>' +
|
||||
'</li>',
|
||||
hintTemplate = '<span class="hint"/>',
|
||||
contentTemplate =
|
||||
'</li>';
|
||||
var hintTemplate = '<span class="hint"/>';
|
||||
var contentTemplate =
|
||||
'<div id="content">' +
|
||||
'<div id="view">' +
|
||||
'<ul id="items" class="clearfix">' +
|
||||
|
@ -32,136 +30,138 @@ modulejs.define('view/items', ['_', '$', 'core/settings', 'core/resource', 'core
|
|||
'</ul>' +
|
||||
'<div class="empty l10n-empty"/>' +
|
||||
'</div>' +
|
||||
'</div>',
|
||||
'</div>';
|
||||
|
||||
update = function (item, force) {
|
||||
|
||||
if (!force && item.$view) {
|
||||
return item.$view;
|
||||
function update(item, force) {
|
||||
|
||||
if (!force && item.$view) {
|
||||
return item.$view;
|
||||
}
|
||||
|
||||
var $html = $(itemTemplate);
|
||||
var $a = $html.find('a');
|
||||
var $iconImg = $html.find('.icon img');
|
||||
var $label = $html.find('.label');
|
||||
var $date = $html.find('.date');
|
||||
var $size = $html.find('.size');
|
||||
|
||||
$html
|
||||
.addClass(item.isFolder() ? 'folder' : 'file')
|
||||
.data('item', item);
|
||||
|
||||
location.setLink($a, item);
|
||||
|
||||
$iconImg.attr('src', resource.icon(item.type)).attr('alt', item.type);
|
||||
$label.text(item.label);
|
||||
$date.data('time', item.time).text(format.formatDate(item.time));
|
||||
$size.data('bytes', item.size).text(format.formatSize(item.size));
|
||||
|
||||
if (item.isFolder() && !item.isManaged) {
|
||||
$html.addClass('page');
|
||||
$iconImg.attr('src', resource.icon('folder-page'));
|
||||
}
|
||||
|
||||
if (item.isCurrentParentFolder()) {
|
||||
$iconImg.attr('src', resource.icon('folder-parent'));
|
||||
if (!settings.setParentFolderLabels) {
|
||||
$label.addClass('l10n-parentDirectory');
|
||||
}
|
||||
$html.addClass('folder-parent');
|
||||
}
|
||||
|
||||
var $html = $(itemTemplate),
|
||||
$a = $html.find('a'),
|
||||
$iconImg = $html.find('.icon img'),
|
||||
$label = $html.find('.label'),
|
||||
$date = $html.find('.date'),
|
||||
$size = $html.find('.size');
|
||||
if (item.$view) {
|
||||
item.$view.replaceWith($html);
|
||||
}
|
||||
item.$view = $html;
|
||||
|
||||
$html
|
||||
.addClass(item.isFolder() ? 'folder' : 'file')
|
||||
.data('item', item);
|
||||
return $html;
|
||||
}
|
||||
|
||||
location.setLink($a, item);
|
||||
function onMouseenter() {
|
||||
|
||||
$iconImg.attr('src', resource.icon(item.type)).attr('alt', item.type);
|
||||
$label.text(item.label);
|
||||
$date.data('time', item.time).text(format.formatDate(item.time));
|
||||
$size.data('bytes', item.size).text(format.formatSize(item.size));
|
||||
var item = $(this).closest('.item').data('item');
|
||||
event.pub('item.mouseenter', item);
|
||||
}
|
||||
|
||||
if (item.isFolder() && !item.isManaged) {
|
||||
$html.addClass('page');
|
||||
$iconImg.attr('src', resource.icon('folder-page'));
|
||||
function onMouseleave() {
|
||||
|
||||
var item = $(this).closest('.item').data('item');
|
||||
event.pub('item.mouseleave', item);
|
||||
}
|
||||
|
||||
function onLocationChanged(item) {
|
||||
|
||||
var $items = $('#items');
|
||||
var $empty = $('#view').find('.empty');
|
||||
|
||||
$items.find('.item').remove();
|
||||
|
||||
if (item.parent && !settings.hideParentFolder) {
|
||||
$items.append(update(item.parent, true));
|
||||
}
|
||||
|
||||
_.each(item.content, function (e) {
|
||||
|
||||
if (!(e.isFolder() && settings.hideFolders)) {
|
||||
$items.append(update(e, true));
|
||||
}
|
||||
});
|
||||
|
||||
if (item.isCurrentParentFolder()) {
|
||||
$iconImg.attr('src', resource.icon('folder-parent'));
|
||||
if (!settings.setParentFolderLabels) {
|
||||
$label.addClass('l10n-parentDirectory');
|
||||
}
|
||||
$html.addClass('folder-parent');
|
||||
if (item.isEmpty()) {
|
||||
$empty.show();
|
||||
} else {
|
||||
$empty.hide();
|
||||
}
|
||||
|
||||
$('html,body').scrollLeft(0).scrollTop(0);
|
||||
}
|
||||
|
||||
function onLocationRefreshed(item, added, removed) {
|
||||
|
||||
var $items = $('#items');
|
||||
var $empty = $('#view').find('.empty');
|
||||
|
||||
_.each(added, function (item) {
|
||||
|
||||
if (!(item.isFolder() && settings.hideFolders)) {
|
||||
update(item, true).hide().appendTo($items).fadeIn(400);
|
||||
}
|
||||
});
|
||||
|
||||
if (item.$view) {
|
||||
item.$view.replaceWith($html);
|
||||
}
|
||||
item.$view = $html;
|
||||
_.each(removed, function (item) {
|
||||
|
||||
return $html;
|
||||
},
|
||||
|
||||
onMouseenter = function () {
|
||||
|
||||
var item = $(this).closest('.item').data('item');
|
||||
event.pub('item.mouseenter', item);
|
||||
},
|
||||
|
||||
onMouseleave = function () {
|
||||
|
||||
var item = $(this).closest('.item').data('item');
|
||||
event.pub('item.mouseleave', item);
|
||||
},
|
||||
|
||||
onLocationChanged = function (item) {
|
||||
|
||||
var $items = $('#items'),
|
||||
$empty = $('#view').find('.empty');
|
||||
|
||||
$items.find('.item').remove();
|
||||
|
||||
if (item.parent && !settings.hideParentFolder) {
|
||||
$items.append(update(item.parent, true));
|
||||
}
|
||||
|
||||
_.each(item.content, function (e) {
|
||||
|
||||
if (!(e.isFolder() && settings.hideFolders)) {
|
||||
$items.append(update(e, true));
|
||||
}
|
||||
item.$view.fadeOut(400, function () {
|
||||
item.$view.remove();
|
||||
});
|
||||
});
|
||||
|
||||
if (item.isEmpty()) {
|
||||
$empty.show();
|
||||
} else {
|
||||
$empty.hide();
|
||||
}
|
||||
if (item.isEmpty()) {
|
||||
setTimeout(function () { $empty.show(); }, 400);
|
||||
} else {
|
||||
$empty.hide();
|
||||
}
|
||||
}
|
||||
|
||||
$('html,body').scrollLeft(0).scrollTop(0);
|
||||
},
|
||||
function init() {
|
||||
|
||||
onLocationRefreshed = function (item, added, removed) {
|
||||
var $content = $(contentTemplate);
|
||||
var $view = $content.find('#view');
|
||||
var $items = $view.find('#items');
|
||||
var $emtpy = $view.find('.empty').hide();
|
||||
|
||||
var $items = $('#items'),
|
||||
$empty = $('#view').find('.empty');
|
||||
format.setDefaultMetric(settings.binaryPrefix);
|
||||
|
||||
_.each(added, function (item) {
|
||||
$items
|
||||
.on('mouseenter', '.item a', onMouseenter)
|
||||
.on('mouseleave', '.item a', onMouseleave);
|
||||
|
||||
if (!(item.isFolder() && settings.hideFolders)) {
|
||||
update(item, true).hide().appendTo($items).fadeIn(400);
|
||||
}
|
||||
});
|
||||
event.sub('location.changed', onLocationChanged);
|
||||
event.sub('location.refreshed', onLocationRefreshed);
|
||||
|
||||
_.each(removed, function (item) {
|
||||
$content.appendTo('body');
|
||||
}
|
||||
|
||||
item.$view.fadeOut(400, function () {
|
||||
item.$view.remove();
|
||||
});
|
||||
});
|
||||
|
||||
if (item.isEmpty()) {
|
||||
setTimeout(function () { $empty.show(); }, 400);
|
||||
} else {
|
||||
$empty.hide();
|
||||
}
|
||||
},
|
||||
|
||||
init = function () {
|
||||
|
||||
var $content = $(contentTemplate),
|
||||
$view = $content.find('#view'),
|
||||
$items = $view.find('#items'),
|
||||
$emtpy = $view.find('.empty').hide();
|
||||
|
||||
format.setDefaultMetric(settings.binaryPrefix);
|
||||
|
||||
$items
|
||||
.on('mouseenter', '.item a', onMouseenter)
|
||||
.on('mouseleave', '.item a', onMouseleave);
|
||||
|
||||
event.sub('location.changed', onLocationChanged);
|
||||
event.sub('location.refreshed', onLocationRefreshed);
|
||||
|
||||
$content.appendTo('body');
|
||||
};
|
||||
|
||||
init();
|
||||
});
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
modulejs.define('view/spacing', ['_', '$', 'core/settings', 'core/event'], function (_, $, allsettings, event) {
|
||||
|
||||
var settings = _.extend({
|
||||
|
@ -7,27 +6,29 @@ modulejs.define('view/spacing', ['_', '$', 'core/settings', 'core/event'], funct
|
|||
right: 'auto',
|
||||
bottom: 50,
|
||||
left: 'auto'
|
||||
}, allsettings.spacing),
|
||||
}, allsettings.spacing);
|
||||
|
||||
adjustSpacing = function () {
|
||||
|
||||
$('#content').css({
|
||||
'margin-top': settings.top + $('#topbar').outerHeight(),
|
||||
'margin-bottom': settings.bottom + $('#bottombar').outerHeight()
|
||||
});
|
||||
},
|
||||
function adjustSpacing() {
|
||||
|
||||
init = function () {
|
||||
$('#content').css({
|
||||
'margin-top': settings.top + $('#topbar').outerHeight(),
|
||||
'margin-bottom': settings.bottom + $('#bottombar').outerHeight()
|
||||
});
|
||||
}
|
||||
|
||||
$('#content').css({
|
||||
'max-width': settings.maxWidth,
|
||||
'margin-right': settings.right,
|
||||
'margin-left': settings.left
|
||||
});
|
||||
function init() {
|
||||
|
||||
$('#content').css({
|
||||
'max-width': settings.maxWidth,
|
||||
'margin-right': settings.right,
|
||||
'margin-left': settings.left
|
||||
});
|
||||
|
||||
event.sub('ready', adjustSpacing);
|
||||
$(window).on('resize', adjustSpacing);
|
||||
}
|
||||
|
||||
event.sub('ready', adjustSpacing);
|
||||
$(window).on('resize', adjustSpacing);
|
||||
};
|
||||
|
||||
init();
|
||||
});
|
||||
|
|
|
@ -1,129 +1,125 @@
|
|||
|
||||
modulejs.define('view/viewmode', ['_', '$', 'core/settings', 'core/resource', 'core/store', 'core/event'], function (_, $, allsettings, resource, store, event) {
|
||||
|
||||
var modes = ['details', 'grid', 'icons'],
|
||||
sizes = [16, 24, 32, 48, 64, 96, 128, 192, 256, 384],
|
||||
|
||||
settings = _.extend({}, {
|
||||
var modes = ['details', 'grid', 'icons'];
|
||||
var sizes = [16, 24, 32, 48, 64, 96, 128, 192, 256, 384];
|
||||
var settings = _.extend({}, {
|
||||
modes: modes,
|
||||
sizes: sizes
|
||||
}, allsettings.view),
|
||||
|
||||
storekey = 'viewmode',
|
||||
menuIsVisible = false,
|
||||
|
||||
sidebarToggleTemplate =
|
||||
}, allsettings.view);
|
||||
var storekey = 'viewmode';
|
||||
var menuIsVisible = false;
|
||||
var sidebarToggleTemplate =
|
||||
'<li id="menu-toggle" class="view">' +
|
||||
'<a href="#">' +
|
||||
'<img src="' + resource.image('settings') + '" alt="settings"/>' +
|
||||
'</a>' +
|
||||
'</li>',
|
||||
|
||||
modeTemplate =
|
||||
'</li>';
|
||||
var modeTemplate =
|
||||
'<div id="view-[MODE]" class="view">' +
|
||||
'<a href="#">' +
|
||||
'<img src="' + resource.image('view-[MODE]') + '" alt="view-[MODE]"/>' +
|
||||
'</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(),
|
||||
$view = $('#view'),
|
||||
itemWidth = ($view.hasClass('view-icons') || $view.hasClass('view-grid')) ? ($view.find('.item').eq(0).outerWidth(true) || 1) : 1;
|
||||
var contentWidth = $('#content').width();
|
||||
var $view = $('#view');
|
||||
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'),
|
||||
stored = store.get(storekey);
|
||||
var $view = $('#view');
|
||||
var stored = store.get(storekey);
|
||||
|
||||
mode = mode || stored && stored.mode;
|
||||
size = size || stored && stored.size;
|
||||
mode = _.contains(settings.modes, mode) ? mode : settings.modes[0];
|
||||
size = _.contains(settings.sizes, size) ? size : settings.sizes[0];
|
||||
store.put(storekey, {mode: mode, size: size});
|
||||
mode = mode || stored && stored.mode;
|
||||
size = size || stored && stored.size;
|
||||
mode = _.contains(settings.modes, mode) ? mode : settings.modes[0];
|
||||
size = _.contains(settings.sizes, size) ? size : settings.sizes[0];
|
||||
store.put(storekey, {mode: mode, size: size});
|
||||
|
||||
_.each(modes, function (m) {
|
||||
if (m === mode) {
|
||||
$('#view-' + m).addClass('current');
|
||||
$view.addClass('view-' + m).show();
|
||||
} else {
|
||||
$('#view-' + m).removeClass('current');
|
||||
$view.removeClass('view-' + m);
|
||||
}
|
||||
});
|
||||
_.each(modes, function (m) {
|
||||
if (m === mode) {
|
||||
$('#view-' + m).addClass('current');
|
||||
$view.addClass('view-' + m).show();
|
||||
} else {
|
||||
$('#view-' + m).removeClass('current');
|
||||
$view.removeClass('view-' + m);
|
||||
}
|
||||
});
|
||||
|
||||
_.each(sizes, function (s) {
|
||||
if (s === size) {
|
||||
$view.addClass('size-' + s).show();
|
||||
} else {
|
||||
$view.removeClass('size-' + s);
|
||||
}
|
||||
});
|
||||
_.each(sizes, function (s) {
|
||||
if (s === size) {
|
||||
$view.addClass('size-' + s).show();
|
||||
} else {
|
||||
$view.removeClass('size-' + s);
|
||||
}
|
||||
});
|
||||
|
||||
$('#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'),
|
||||
$settings = $('#settings'),
|
||||
$viewBlock = $('<div class="block"/>'),
|
||||
max;
|
||||
var $sidebar = $('#sidebar');
|
||||
var $settings = $('#settings');
|
||||
var $viewBlock = $('<div class="block"/>');
|
||||
var max;
|
||||
|
||||
$(sidebarToggleTemplate)
|
||||
.on('click', 'a', function (event) {
|
||||
$(sidebarToggleTemplate)
|
||||
.on('click', 'a', function (event) {
|
||||
|
||||
menuIsVisible = !menuIsVisible;
|
||||
$sidebar.stop().animate({
|
||||
right: menuIsVisible ? 0 : -$sidebar.outerWidth()-1
|
||||
});
|
||||
event.preventDefault();
|
||||
})
|
||||
.appendTo('#navbar');
|
||||
|
||||
settings.modes = _.intersection(settings.modes, modes);
|
||||
|
||||
if (settings.modes.length > 1) {
|
||||
_.each(modes, function (mode) {
|
||||
if (_.contains(settings.modes, mode)) {
|
||||
$(modeTemplate.replace(/\[MODE\]/g, mode))
|
||||
.appendTo($viewBlock)
|
||||
.on('click', 'a', function (event) {
|
||||
|
||||
update(mode);
|
||||
event.preventDefault();
|
||||
});
|
||||
}
|
||||
menuIsVisible = !menuIsVisible;
|
||||
$sidebar.stop().animate({
|
||||
right: menuIsVisible ? 0 : -$sidebar.outerWidth()-1
|
||||
});
|
||||
}
|
||||
event.preventDefault();
|
||||
})
|
||||
.appendTo('#navbar');
|
||||
|
||||
if (settings.sizes.length > 1) {
|
||||
max = settings.sizes.length-1;
|
||||
$(sizeTemplate)
|
||||
.prop('max', max).attr('max', max)
|
||||
.on('input change', function (event) {
|
||||
settings.modes = _.intersection(settings.modes, modes);
|
||||
|
||||
update(null, settings.sizes[parseInt(event.target.value, 10)]);
|
||||
})
|
||||
.appendTo($viewBlock);
|
||||
}
|
||||
if (settings.modes.length > 1) {
|
||||
_.each(modes, function (mode) {
|
||||
if (_.contains(settings.modes, mode)) {
|
||||
$(modeTemplate.replace(/\[MODE\]/g, mode))
|
||||
.appendTo($viewBlock)
|
||||
.on('click', 'a', function (event) {
|
||||
|
||||
$viewBlock.appendTo($settings);
|
||||
update(mode);
|
||||
event.preventDefault();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
update();
|
||||
if (settings.sizes.length > 1) {
|
||||
max = settings.sizes.length-1;
|
||||
$(sizeTemplate)
|
||||
.prop('max', max).attr('max', max)
|
||||
.on('input change', function (event) {
|
||||
|
||||
update(null, settings.sizes[parseInt(event.target.value, 10)]);
|
||||
})
|
||||
.appendTo($viewBlock);
|
||||
}
|
||||
|
||||
$viewBlock.appendTo($settings);
|
||||
|
||||
update();
|
||||
|
||||
event.sub('location.changed', adjustSpacing);
|
||||
$(window).on('resize', adjustSpacing);
|
||||
}
|
||||
|
||||
event.sub('location.changed', adjustSpacing);
|
||||
$(window).on('resize', adjustSpacing);
|
||||
};
|
||||
|
||||
init();
|
||||
});
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
// other libs
|
||||
// ----------
|
||||
// @include "lib/modernizr-*.js"
|
||||
|
@ -16,7 +15,7 @@
|
|||
// app
|
||||
// ---
|
||||
(function () {
|
||||
'use strict';
|
||||
'use strict';
|
||||
|
||||
/*global jQuery, marked, Modernizr, moment, Prism, _ */
|
||||
modulejs.define('$', function () { return jQuery; });
|
||||
|
@ -28,10 +27,10 @@
|
|||
|
||||
// @include "inc/**/*.js"
|
||||
|
||||
var $ = jQuery,
|
||||
module = $('script[data-module]').data('module'),
|
||||
data = {action: 'get', setup: true, options: true, types: true, theme: true, langs: true},
|
||||
url;
|
||||
var $ = jQuery;
|
||||
var module = $('script[data-module]').data('module');
|
||||
var data = {action: 'get', setup: true, options: true, types: true, theme: true, langs: true};
|
||||
var url;
|
||||
|
||||
if ($('html').hasClass('no-browser')) {
|
||||
return;
|
||||
|
@ -56,5 +55,4 @@
|
|||
modulejs.define('config', config);
|
||||
$(function () { modulejs.require(module); });
|
||||
});
|
||||
|
||||
}());
|
||||
|
|
|
@ -1,43 +1,42 @@
|
|||
doctype html
|
||||
//if lt IE 10
|
||||
<html class="no-js no-browser" lang="en">
|
||||
//[if gt IE 9]><!
|
||||
html.no-js.browser( lang="en" )
|
||||
//<![endif]
|
||||
<!--[if lt IE 10]><html class="no-js no-browser" lang="en"><![endif]-->
|
||||
<!--[if gt IE 9]><!--><html class="no-js browser" lang="en"><!--<![endif]-->
|
||||
|
||||
head
|
||||
meta( charset="utf-8" )
|
||||
meta( http-equiv="X-UA-Compatible", content="IE=edge" )
|
||||
title {{pkg.name}} {{pkg.version}} Server Setup
|
||||
meta( name="description", content="{{pkg.name}} {{pkg.version}} Server Setup" )
|
||||
meta( name="viewport", content="width=device-width, initial-scale=1" )
|
||||
link( rel="shortcut icon", href="client/images/favicon/favicon-16-32.ico" )
|
||||
link( rel="apple-touch-icon-precomposed", type="image/png", href="client/images/favicon/favicon-152.png" )
|
||||
link( rel="stylesheet", href="client/css/styles.css" )
|
||||
script( src="client/js/scripts.js", data-module="info" )
|
||||
head
|
||||
meta( charset="utf-8" )
|
||||
meta( http-equiv="X-UA-Compatible", content="IE=edge" )
|
||||
title {{pkg.name}} {{pkg.version}} Server Setup
|
||||
meta( name="description", content="{{pkg.name}} {{pkg.version}} Server Setup" )
|
||||
meta( name="viewport", content="width=device-width, initial-scale=1" )
|
||||
link( rel="shortcut icon", href="client/images/favicon/favicon-16-32.ico" )
|
||||
link( rel="apple-touch-icon-precomposed", type="image/png", href="client/images/favicon/favicon-152.png" )
|
||||
link( rel="stylesheet", href="client/css/styles.css" )
|
||||
script( src="client/js/scripts.js", data-module="info" )
|
||||
|
||||
body#h5ai-info
|
||||
body#h5ai-info
|
||||
|
||||
h1
|
||||
a( href="{{pkg.homepage}}" ) {{pkg.name}}
|
||||
h1
|
||||
a( href="{{pkg.homepage}}" ) {{pkg.name}}
|
||||
|
||||
div#support
|
||||
| show your love and support for h5ai with a small donation
|
||||
div.paypal
|
||||
form( action="https://www.paypal.com/cgi-bin/webscr", method="post", target="_top" )
|
||||
input( type="hidden", name="cmd", value="_s-xclick" )
|
||||
input( type="hidden", name="hosted_button_id", value="8WSPKWT7YBTSQ" )
|
||||
input( type="image", src="client/images/paypal.png", border="0", name="submit", alt="PayPal - The safer, easier way to pay online!" )
|
||||
div#support
|
||||
| show your love and support for h5ai with a small donation
|
||||
div.paypal
|
||||
form( action="https://www.paypal.com/cgi-bin/webscr", method="post", target="_top" )
|
||||
input( type="hidden", name="cmd", value="_s-xclick" )
|
||||
input( type="hidden", name="hosted_button_id", value="8WSPKWT7YBTSQ" )
|
||||
input( type="image", src="client/images/paypal.png", border="0", name="submit", alt="PayPal - The safer, easier way to pay online!" )
|
||||
|
||||
div#bottombar.clearfix
|
||||
span.left
|
||||
span.noJsMsg
|
||||
| ⚡ JavaScript disabled! ⚡
|
||||
span.noBrowserMsg
|
||||
| ⚡ Works best in
|
||||
a( href="http://browsehappy.com" ) modern browsers
|
||||
| ! ⚡
|
||||
span.right
|
||||
a( href="{{pkg.homepage}}", title="{{pkg.name}} {{pkg.version}} · {{pkg.description}}" )
|
||||
| powered by {{pkg.name}} {{pkg.version}}
|
||||
span.center
|
||||
div#bottombar.clearfix
|
||||
span.left
|
||||
span.noJsMsg
|
||||
| ⚡ JavaScript disabled! ⚡
|
||||
span.noBrowserMsg
|
||||
| ⚡ Works best in
|
||||
a( href="http://browsehappy.com" ) modern browsers
|
||||
| ! ⚡
|
||||
span.right
|
||||
a( href="{{pkg.homepage}}", title="{{pkg.name}} {{pkg.version}} · {{pkg.description}}" )
|
||||
| powered by {{pkg.name}} {{pkg.version}}
|
||||
span.center
|
||||
|
||||
</html>
|
||||
|
|
|
@ -4,42 +4,41 @@
|
|||
|
||||
<?php header("Content-type: text/html;charset=utf-8"); ?>
|
||||
doctype html
|
||||
//if lt IE 10
|
||||
<html class="no-js no-browser" lang="en">
|
||||
//[if gt IE 9]><!
|
||||
html.no-js.browser( lang="en" )
|
||||
//<![endif]
|
||||
<!--[if lt IE 10]><html class="no-js no-browser" lang="en"><![endif]-->
|
||||
<!--[if gt IE 9]><!--><html class="no-js browser" lang="en"><!--<![endif]-->
|
||||
|
||||
head
|
||||
meta( charset="utf-8" )
|
||||
meta( http-equiv="X-UA-Compatible", content="IE=edge" )
|
||||
title index · powered by {{pkg.name}} {{pkg.version}} ({{pkg.homepage}})
|
||||
meta( name="description", content="index - powered by {{pkg.name}} {{pkg.version}} ({{pkg.homepage}})" )
|
||||
meta( name="viewport", content="width=device-width, initial-scale=1" )
|
||||
link( rel="shortcut icon", href!="#{app_href}client/images/favicon/favicon-16-32.ico" )
|
||||
link( rel="apple-touch-icon-precomposed", type="image/png", href!="#{app_href}client/images/favicon/favicon-152.png" )
|
||||
link( rel="stylesheet", href!="#{app_href}client/css/styles.css" )
|
||||
script( src!="#{app_href}client/js/scripts.js", data-module="main" )
|
||||
head
|
||||
meta( charset="utf-8" )
|
||||
meta( http-equiv="X-UA-Compatible", content="IE=edge" )
|
||||
title index · powered by {{pkg.name}} {{pkg.version}} ({{pkg.homepage}})
|
||||
meta( name="description", content="index - powered by {{pkg.name}} {{pkg.version}} ({{pkg.homepage}})" )
|
||||
meta( name="viewport", content="width=device-width, initial-scale=1" )
|
||||
link( rel="shortcut icon", href!="#{app_href}client/images/favicon/favicon-16-32.ico" )
|
||||
link( rel="apple-touch-icon-precomposed", type="image/png", href!="#{app_href}client/images/favicon/favicon-152.png" )
|
||||
link( rel="stylesheet", href!="#{app_href}client/css/styles.css" )
|
||||
script( src!="#{app_href}client/js/scripts.js", data-module="main" )
|
||||
|
||||
body
|
||||
body
|
||||
|
||||
div#topbar.clearfix
|
||||
ul#navbar
|
||||
div#topbar.clearfix
|
||||
ul#navbar
|
||||
|
||||
div#bottombar.clearfix
|
||||
span.left
|
||||
span.noJsMsg
|
||||
| ⚡ JavaScript disabled! ⚡
|
||||
span.noBrowserMsg
|
||||
| ⚡ Works best in
|
||||
a( href="http://browsehappy.com" ) modern browsers
|
||||
| ! ⚡
|
||||
span.right
|
||||
a( href="{{pkg.homepage}}", title="{{pkg.name}} {{pkg.version}} · {{pkg.description}}" )
|
||||
| powered by {{pkg.name}} {{pkg.version}}
|
||||
span.center
|
||||
div#bottombar.clearfix
|
||||
span.left
|
||||
span.noJsMsg
|
||||
| ⚡ JavaScript disabled! ⚡
|
||||
span.noBrowserMsg
|
||||
| ⚡ Works best in
|
||||
a( href="http://browsehappy.com" ) modern browsers
|
||||
| ! ⚡
|
||||
span.right
|
||||
a( href="{{pkg.homepage}}", title="{{pkg.name}} {{pkg.version}} · {{pkg.description}}" )
|
||||
| powered by {{pkg.name}} {{pkg.version}}
|
||||
span.center
|
||||
|
||||
div#sidebar
|
||||
div#settings
|
||||
div#sidebar
|
||||
div#settings
|
||||
|
||||
div#fallback !{fallback}
|
||||
div#fallback !{fallback}
|
||||
|
||||
</html>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue