mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-05-25 20:44:53 -04:00
Thumbnails and image preview.
This commit is contained in:
parent
ce3ef3a195
commit
4cb9967b39
65 changed files with 1510 additions and 806 deletions
|
@ -1,7 +1,7 @@
|
|||
|
||||
module.define('core/entry', [jQuery, 'core/parser', 'model/entry'], function ($, parser, Entry) {
|
||||
|
||||
var absHref = document.location.pathname;
|
||||
var absHref = document.location.pathname.replace(/[^\/]*$/, '');
|
||||
|
||||
parser.parse(absHref, $('body'));
|
||||
$('#data-apache-autoindex').remove();
|
||||
|
|
|
@ -1,9 +1,17 @@
|
|||
|
||||
module.define('core/parser', [jQuery], function ($) {
|
||||
|
||||
if ($('#data-apache-autoindex').length) {
|
||||
return module.require('parser/apache-autoindex');
|
||||
}
|
||||
if ($('#data-generic-json').length) {
|
||||
return module.require('parser/generic-json');
|
||||
}
|
||||
|
||||
return module.require('parser/apache-autoindex');
|
||||
return {
|
||||
id: 'none',
|
||||
parse: function () {
|
||||
return [];
|
||||
}
|
||||
};
|
||||
});
|
||||
|
|
|
@ -3,7 +3,9 @@ module.define('core/settings', [H5AI_CONFIG], function (config) {
|
|||
|
||||
var defaults = {
|
||||
rootAbsHref: '/',
|
||||
h5aiAbsHref: '/_h5ai/'
|
||||
h5aiAbsHref: '/_h5ai/',
|
||||
server: 'unknown',
|
||||
mode: 'unknown'
|
||||
};
|
||||
|
||||
return _.extend({}, defaults, config.options);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
module.define('ext/crumb', [jQuery, 'core/settings', 'core/resource', 'core/entry'], function ($, allsettings, resource, entry) {
|
||||
|
||||
var defaults = {
|
||||
enabled: true
|
||||
enabled: false
|
||||
},
|
||||
|
||||
settings = _.extend({}, defaults, allsettings.crumb),
|
||||
|
|
|
@ -9,7 +9,7 @@ module.define('ext/download', [jQuery, 'core/settings', 'core/resource', 'core/e
|
|||
|
||||
settings = _.extend({}, defaults, allsettings.download),
|
||||
|
||||
formats = ['tar', 'zip'],
|
||||
// formats = ['tar', 'zip'],
|
||||
|
||||
downloadBtnTemplate = '<li id="download">' +
|
||||
'<a href="#">' +
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
module.define('ext/folderstatus', [jQuery, 'core/settings'], function ($, allsettings) {
|
||||
|
||||
var defaults = {
|
||||
enabled: true,
|
||||
enabled: false,
|
||||
folders: {}
|
||||
},
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
module.define('ext/l10n', [jQuery, 'core/settings', 'core/langs', 'core/format', 'core/store'], function ($, allsettings, langs, format, store) {
|
||||
module.define('ext/l10n', [jQuery, 'core/settings', 'core/langs', 'core/format', 'core/store', 'core/event'], function ($, allsettings, langs, format, store, event) {
|
||||
|
||||
var defaults = {
|
||||
enabled: true,
|
||||
|
@ -21,13 +21,12 @@ module.define('ext/l10n', [jQuery, 'core/settings', 'core/langs', 'core/format',
|
|||
|
||||
localize = function (langs, lang, useBrowserLang) {
|
||||
|
||||
var storedLang = store.get(storekey),
|
||||
browserLang, key;
|
||||
var storedLang = store.get(storekey);
|
||||
|
||||
if (langs[storedLang]) {
|
||||
lang = storedLang;
|
||||
} else if (useBrowserLang) {
|
||||
browserLang = navigator.language || navigator.browserLanguage;
|
||||
var browserLang = navigator.language || navigator.browserLanguage;
|
||||
if (browserLang) {
|
||||
if (langs[browserLang]) {
|
||||
lang = browserLang;
|
||||
|
@ -110,7 +109,11 @@ module.define('ext/l10n', [jQuery, 'core/settings', 'core/langs', 'core/format',
|
|||
}
|
||||
|
||||
initLangSelector(langs);
|
||||
localize(langs, settings.lang, settings.useBrowserLang);
|
||||
|
||||
event.sub('ready', function () {
|
||||
|
||||
localize(langs, settings.lang, settings.useBrowserLang);
|
||||
});
|
||||
};
|
||||
|
||||
init();
|
||||
|
|
35
src/_h5ai/js/inc/ext/mode.js
Normal file
35
src/_h5ai/js/inc/ext/mode.js
Normal file
|
@ -0,0 +1,35 @@
|
|||
|
||||
module.define('ext/mode', [jQuery, 'core/settings', 'core/parser'], function ($, allsettings, parser) {
|
||||
|
||||
var defaults = {
|
||||
enabled: false,
|
||||
display: 0
|
||||
},
|
||||
|
||||
settings = _.extend({}, defaults, allsettings.mode),
|
||||
|
||||
init = function () {
|
||||
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
var info = '';
|
||||
|
||||
if (parser.mode) {
|
||||
info += parser.mode;
|
||||
}
|
||||
if (settings.display > 0 && parser.server.name) {
|
||||
info += (info ? ' on ' : '') + parser.server.name;
|
||||
}
|
||||
if (settings.display > 1 && parser.server.version) {
|
||||
info += (info ? '-' : '') + parser.server.version;
|
||||
}
|
||||
|
||||
if (info) {
|
||||
$('#h5ai-reference').append(' (' + info + ')');
|
||||
}
|
||||
};
|
||||
|
||||
init();
|
||||
});
|
248
src/_h5ai/js/inc/ext/preview-img.js
Normal file
248
src/_h5ai/js/inc/ext/preview-img.js
Normal file
|
@ -0,0 +1,248 @@
|
|||
|
||||
module.define('ext/preview-img', [jQuery, 'core/settings', 'core/resource', 'core/store', 'core/entry'], function ($, allsettings, resource, store, entry) {
|
||||
|
||||
var defaults = {
|
||||
enabled: false,
|
||||
types: ['bmp', 'gif', 'ico', 'image', 'jpg', 'png', 'tiff']
|
||||
},
|
||||
|
||||
settings = _.extend({}, defaults, allsettings['preview-img']),
|
||||
|
||||
template = '<div id="preview-overlay" class="noSelection">' +
|
||||
'<div id="preview-content">' +
|
||||
'<img id="preview-img" />' +
|
||||
'</div>' +
|
||||
'<div id="preview-close" />' +
|
||||
'<div id="preview-prev" />' +
|
||||
'<div id="preview-next" />' +
|
||||
'<div id="preview-bottombar" class="clearfix">' +
|
||||
'<ul id="preview-buttons">' +
|
||||
'<li id="preview-bar-size" class="bar-left bar-label"></li>' +
|
||||
'<li id="preview-bar-percent" class="bar-left bar-label"></li>' +
|
||||
'<li id="preview-bar-label" class="bar-left bar-label"></li>' +
|
||||
'<li id="preview-bar-close" class="bar-right bar-button"><img src="' + resource.image('preview/close') + '" /></li>' +
|
||||
'<li id="preview-bar-original" class="bar-right"><a class="bar-button" target="_blank"><img src="' + resource.image('preview/image') + '" /></a></li>' +
|
||||
'<li id="preview-bar-fullscreen" class="bar-right bar-button"><img src="' + resource.image('preview/fullscreen') + '" /></li>' +
|
||||
'<li id="preview-bar-next" class="bar-right bar-button"><img src="' + resource.image('preview/next') + '" /></li>' +
|
||||
'<li id="preview-bar-idx" class="bar-right bar-label"></li>' +
|
||||
'<li id="preview-bar-prev" class="bar-right bar-button"><img src="' + resource.image('preview/prev') + '" /></li>' +
|
||||
'</ul>' +
|
||||
'</div>' +
|
||||
'</div>',
|
||||
|
||||
storekey = 'h5ai.preview-img.isFullscreen',
|
||||
|
||||
currentEntries = [],
|
||||
currentIdx = 0,
|
||||
isFullscreen = store.get(storekey) || false,
|
||||
|
||||
adjustSize = function () {
|
||||
|
||||
var rect = $(window).fracs('viewport'),
|
||||
$container = $('#preview-content'),
|
||||
$img = $('#preview-img'),
|
||||
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
|
||||
});
|
||||
|
||||
var lr = ($container.width() - $img.width()) / 2,
|
||||
tb = ($container.height() - $img.height()) / 2;
|
||||
|
||||
$img.css({
|
||||
margin: '' + tb + 'px ' + lr + 'px'
|
||||
});
|
||||
|
||||
rect = $img.fracs('rect');
|
||||
if (!rect) {
|
||||
// console.log('RECT FAILED!');
|
||||
return;
|
||||
}
|
||||
rect = rect.relativeTo($('#preview-overlay').fracs('rect'));
|
||||
|
||||
$('#preview-prev').css({
|
||||
'left': rect.left,
|
||||
'top': rect.top,
|
||||
'width': rect.width / 2,
|
||||
'height': rect.height
|
||||
});
|
||||
$('#preview-next').css({
|
||||
'left': rect.left + rect.width / 2,
|
||||
'top': rect.top,
|
||||
'width': rect.width / 2,
|
||||
'height': rect.height
|
||||
});
|
||||
},
|
||||
|
||||
preload = function (src, callback) {
|
||||
|
||||
var $hidden = $('<div><img/></div>')
|
||||
.css({
|
||||
position: 'absolute',
|
||||
overflow: 'hidden',
|
||||
width: 0,
|
||||
height: 0
|
||||
})
|
||||
.appendTo('body'),
|
||||
$img = $hidden.find('img')
|
||||
.one('load', function () {
|
||||
|
||||
var width = $img.width(),
|
||||
height = $img.height();
|
||||
|
||||
$hidden.remove();
|
||||
|
||||
callback(width, height);
|
||||
})
|
||||
.attr('src', src);
|
||||
},
|
||||
|
||||
showImg = function (entries, idx) {
|
||||
|
||||
currentEntries = entries;
|
||||
currentIdx = (idx + currentEntries.length) % currentEntries.length;
|
||||
|
||||
var $container = $('#preview-content'),
|
||||
$img = $('#preview-img'),
|
||||
src = currentEntries[currentIdx].absHref,
|
||||
spinnerTimeout = setTimeout(function () {
|
||||
|
||||
$container.spin({
|
||||
length: 12,
|
||||
width: 4,
|
||||
radius: 24,
|
||||
color: '#ccc',
|
||||
shadow: true
|
||||
});
|
||||
}, 200);
|
||||
|
||||
$('#preview-overlay').stop(true, true).fadeIn(200);
|
||||
$('#preview-bar-idx').text('' + (currentIdx + 1) + ' / ' + currentEntries.length);
|
||||
|
||||
preload(src, function (width, height) {
|
||||
|
||||
clearTimeout(spinnerTimeout);
|
||||
$container.spin(false);
|
||||
|
||||
$img.attr('src', src).show();
|
||||
|
||||
adjustSize();
|
||||
|
||||
$('#preview-bar-label').text(currentEntries[currentIdx].label);
|
||||
$('#preview-bar-percent').text('' + (100 * $img.width() / width).toFixed(0) + '%');
|
||||
$('#preview-bar-size').text('' + width + 'x' + height);
|
||||
$('#preview-bar-idx').text('' + (currentIdx + 1) + ' / ' + currentEntries.length);
|
||||
$('#preview-bar-original').find('a').attr('href', currentEntries[currentIdx].absHref);
|
||||
});
|
||||
},
|
||||
|
||||
checkEntry = function (entry) {
|
||||
|
||||
if (entry.$extended && $.inArray(entry.type, settings.types) >= 0) {
|
||||
|
||||
var $a = entry.$extended.find('a');
|
||||
$a.on('click', function (event) {
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
var entries = _.filter(_.map($('#extended .entry'), function (entry) {
|
||||
|
||||
return $(entry).data('entry');
|
||||
}), function (entry) {
|
||||
|
||||
return _.indexOf(settings.types, entry.type) >= 0;
|
||||
});
|
||||
|
||||
showImg(entries, _.indexOf(entries, entry));
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
init = function (entry) {
|
||||
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
$(template).appendTo('body');
|
||||
|
||||
_.each(entry.content, checkEntry);
|
||||
|
||||
$('#preview-bar-prev, #preview-prev').on('click', function (event) {
|
||||
// event.stopPropagation();
|
||||
showImg(currentEntries, currentIdx - 1);
|
||||
});
|
||||
$('#preview-prev')
|
||||
.on('mouseenter', function (event) {
|
||||
// event.stopPropagation();
|
||||
$('#preview-bar-prev').addClass('hover');
|
||||
})
|
||||
.on('mouseleave', function (event) {
|
||||
// event.stopPropagation();
|
||||
$('#preview-bar-prev').removeClass('hover');
|
||||
});
|
||||
|
||||
$('#preview-bar-next, #preview-next').on('click', function (event) {
|
||||
// event.stopPropagation();
|
||||
showImg(currentEntries, currentIdx + 1);
|
||||
});
|
||||
$('#preview-next')
|
||||
.on('mouseenter', function (event) {
|
||||
// event.stopPropagation();
|
||||
$('#preview-bar-next').addClass('hover');
|
||||
})
|
||||
.on('mouseleave', function (event) {
|
||||
// event.stopPropagation();
|
||||
$('#preview-bar-next').removeClass('hover');
|
||||
});
|
||||
|
||||
$('#preview-bar-close, #preview-close').on('click', function () {
|
||||
// event.stopPropagation();
|
||||
$('#preview-overlay').stop(true, true).fadeOut(200);
|
||||
});
|
||||
$('#preview-close')
|
||||
.on('mouseenter', function (event) {
|
||||
// event.stopPropagation();
|
||||
$('#preview-bar-close').addClass('hover');
|
||||
})
|
||||
.on('mouseleave', function (event) {
|
||||
// event.stopPropagation();
|
||||
$('#preview-bar-close').removeClass('hover');
|
||||
});
|
||||
|
||||
$('#preview-bar-fullscreen').on('click', function (event) {
|
||||
// event.stopPropagation();
|
||||
isFullscreen = !isFullscreen;
|
||||
store.put(storekey, isFullscreen);
|
||||
$('#preview-bar-fullscreen').find('img').attr('src', isFullscreen ? resource.image('preview/no-fullscreen') : resource.image('preview/fullscreen'));
|
||||
adjustSize();
|
||||
});
|
||||
|
||||
$('#preview-overlay')
|
||||
.on('mousedown', function (event) {
|
||||
|
||||
event.stopPropagation();
|
||||
})
|
||||
.on('mousemove', function (event) {
|
||||
|
||||
if (isFullscreen) {
|
||||
var rect = $('#preview-overlay').fracs('rect');
|
||||
|
||||
if (rect.bottom - event.pageY < 64) {
|
||||
$('#preview-bottombar').fadeIn(200);
|
||||
} else {
|
||||
$('#preview-bottombar').fadeOut(400);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$(window).on('resize load', adjustSize);
|
||||
};
|
||||
|
||||
init(entry);
|
||||
});
|
|
@ -57,7 +57,19 @@ module.define('ext/select', [jQuery, 'core/settings', 'core/event'], function ($
|
|||
|
||||
$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);
|
||||
.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();
|
||||
}
|
||||
);
|
||||
},
|
||||
|
||||
selectionStart = function (event) {
|
||||
|
|
|
@ -57,9 +57,16 @@ module.define('ext/statusbar', [jQuery, 'core/settings', 'core/format', 'core/ev
|
|||
|
||||
event.sub('entry.mouseenter', function (entry) {
|
||||
|
||||
var $span = $('<span/>').append(entry.label).append(sepTemplate).append(format.formatDate(entry.time));
|
||||
if (entry.isParentFolder) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!entry.isFolder()) {
|
||||
var $span = $('<span/>').append(entry.label);
|
||||
|
||||
if (_.isNumber(entry.time)) {
|
||||
$span.append(sepTemplate).append(format.formatDate(entry.time));
|
||||
}
|
||||
if (_.isNumber(entry.size)) {
|
||||
$span.append(sepTemplate).append(format.formatSize(entry.size));
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,9 @@ module.define('ext/thumbnails', [jQuery, 'core/settings', 'core/resource', 'core
|
|||
|
||||
var defaults = {
|
||||
enabled: false,
|
||||
types: ["bmp", "gif", "ico", "image", "jpg", "png", "tiff"],
|
||||
img: ['bmp', 'gif', 'ico', 'image', 'jpg', 'png', 'tiff'],
|
||||
mov: ['video'],
|
||||
doc: ['pdf', 'ps'],
|
||||
delay: 1000
|
||||
},
|
||||
|
||||
|
@ -21,25 +23,36 @@ module.define('ext/thumbnails', [jQuery, 'core/settings', 'core/resource', 'core
|
|||
|
||||
checkEntry = function (entry) {
|
||||
|
||||
if (entry.$extended && $.inArray(entry.type, settings.types) >= 0) {
|
||||
if (entry.$extended) {
|
||||
|
||||
var $imgSmall = entry.$extended.find('.icon.small img');
|
||||
var $imgBig = entry.$extended.find('.icon.big img');
|
||||
var type = null;
|
||||
|
||||
requestThumb($imgSmall, {
|
||||
action: 'getthumbsrc',
|
||||
href: entry.absHref,
|
||||
width: 16,
|
||||
height: 16,
|
||||
mode: 'square'
|
||||
});
|
||||
requestThumb($imgBig, {
|
||||
action: 'getthumbsrc',
|
||||
href: entry.absHref,
|
||||
width: 100,
|
||||
height: 48,
|
||||
mode: 'rational'
|
||||
});
|
||||
if ($.inArray(entry.type, settings.img) >= 0) {
|
||||
type = 'img';
|
||||
} else if ($.inArray(entry.type, settings.mov) >= 0) {
|
||||
type = 'mov';
|
||||
} else if ($.inArray(entry.type, settings.doc) >= 0) {
|
||||
type = 'doc';
|
||||
}
|
||||
|
||||
if (type) {
|
||||
requestThumb(entry.$extended.find('.icon.small img'), {
|
||||
action: 'getthumbsrc',
|
||||
type: type,
|
||||
href: entry.absHref,
|
||||
mode: 'square',
|
||||
width: 16,
|
||||
height: 16
|
||||
});
|
||||
requestThumb(entry.$extended.find('.icon.big img'), {
|
||||
action: 'getthumbsrc',
|
||||
type: type,
|
||||
href: entry.absHref,
|
||||
mode: 'rational',
|
||||
width: 100,
|
||||
height: 48
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
|
||||
module.define('h5ai-main', [jQuery, 'core/event'], function ($, event) {
|
||||
|
||||
module.define('h5ai-main', [jQuery, 'core/event', 'core/settings'], function ($, event, settings) {
|
||||
|
||||
event.pub('beforeView');
|
||||
|
||||
|
@ -8,8 +7,6 @@ module.define('h5ai-main', [jQuery, 'core/event'], function ($, event) {
|
|||
module.require('view/viewmode');
|
||||
module.require('view/spacing');
|
||||
|
||||
$('#h5ai-reference').append(module.require('core/parser').id === 'apache-autoindex' ? ' (js)' : ' (php)');
|
||||
|
||||
event.pub('beforeExt');
|
||||
|
||||
_.each(module.getIds(/^ext\/.+/), function (id) {
|
||||
|
|
4
src/_h5ai/js/inc/lib/jquery-1.7.1.min.js
vendored
4
src/_h5ai/js/inc/lib/jquery-1.7.1.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -7,6 +7,15 @@
|
|||
(function (global, name) {
|
||||
'use strict';
|
||||
|
||||
var err = function (message) {
|
||||
|
||||
throw name + ' exception: ' + message;
|
||||
};
|
||||
|
||||
if (!_) {
|
||||
err(name + ' depends on underscore');
|
||||
}
|
||||
|
||||
var self = {},
|
||||
previous = global[name],
|
||||
|
||||
|
@ -18,11 +27,6 @@
|
|||
return self;
|
||||
},
|
||||
|
||||
err = function (message) {
|
||||
|
||||
throw name + ' exception: ' + message;
|
||||
},
|
||||
|
||||
definitions = {},
|
||||
modules = {},
|
||||
|
||||
|
@ -180,16 +184,14 @@
|
|||
return obj;
|
||||
};
|
||||
|
||||
if (!_) {
|
||||
err(name + ' depends on underscore');
|
||||
}
|
||||
|
||||
self.noConflict = noConflict;
|
||||
self.log = log;
|
||||
self.define = define;
|
||||
self.require = require;
|
||||
self.getIds = getIds;
|
||||
self.isDefined = isDefined;
|
||||
_.extend(self, {
|
||||
noConflict: noConflict,
|
||||
log: log,
|
||||
define: define,
|
||||
require: require,
|
||||
getIds: getIds,
|
||||
isDefined: isDefined
|
||||
});
|
||||
|
||||
global[name] = self;
|
||||
|
||||
|
|
18
src/_h5ai/js/inc/lib/spin-1.2.5.min.js
vendored
Normal file
18
src/_h5ai/js/inc/lib/spin-1.2.5.min.js
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
//fgnass.github.com/spin.js#v1.2.5
|
||||
(function(a,b,c){function g(a,c){var d=b.createElement(a||"div"),e;for(e in c)d[e]=c[e];return d}function h(a){for(var b=1,c=arguments.length;b<c;b++)a.appendChild(arguments[b]);return a}function j(a,b,c,d){var g=["opacity",b,~~(a*100),c,d].join("-"),h=.01+c/d*100,j=Math.max(1-(1-a)/b*(100-h),a),k=f.substring(0,f.indexOf("Animation")).toLowerCase(),l=k&&"-"+k+"-"||"";return e[g]||(i.insertRule("@"+l+"keyframes "+g+"{"+"0%{opacity:"+j+"}"+h+"%{opacity:"+a+"}"+(h+.01)+"%{opacity:1}"+(h+b)%100+"%{opacity:"+a+"}"+"100%{opacity:"+j+"}"+"}",0),e[g]=1),g}function k(a,b){var e=a.style,f,g;if(e[b]!==c)return b;b=b.charAt(0).toUpperCase()+b.slice(1);for(g=0;g<d.length;g++){f=d[g]+b;if(e[f]!==c)return f}}function l(a,b){for(var c in b)a.style[k(a,c)||c]=b[c];return a}function m(a){for(var b=1;b<arguments.length;b++){var d=arguments[b];for(var e in d)a[e]===c&&(a[e]=d[e])}return a}function n(a){var b={x:a.offsetLeft,y:a.offsetTop};while(a=a.offsetParent)b.x+=a.offsetLeft,b.y+=a.offsetTop;return b}var d=["webkit","Moz","ms","O"],e={},f,i=function(){var a=g("style");return h(b.getElementsByTagName("head")[0],a),a.sheet||a.styleSheet}(),o={lines:12,length:7,width:5,radius:10,rotate:0,color:"#000",speed:1,trail:100,opacity:.25,fps:20,zIndex:2e9,className:"spinner",top:"auto",left:"auto"},p=function q(a){if(!this.spin)return new q(a);this.opts=m(a||{},q.defaults,o)};p.defaults={},m(p.prototype,{spin:function(a){this.stop();var b=this,c=b.opts,d=b.el=l(g(0,{className:c.className}),{position:"relative",zIndex:c.zIndex}),e=c.radius+c.length+c.width,h,i;a&&(a.insertBefore(d,a.firstChild||null),i=n(a),h=n(d),l(d,{left:(c.left=="auto"?i.x-h.x+(a.offsetWidth>>1):c.left+e)+"px",top:(c.top=="auto"?i.y-h.y+(a.offsetHeight>>1):c.top+e)+"px"})),d.setAttribute("aria-role","progressbar"),b.lines(d,b.opts);if(!f){var j=0,k=c.fps,m=k/c.speed,o=(1-c.opacity)/(m*c.trail/100),p=m/c.lines;!function q(){j++;for(var a=c.lines;a;a--){var e=Math.max(1-(j+a*p)%m*o,c.opacity);b.opacity(d,c.lines-a,e,c)}b.timeout=b.el&&setTimeout(q,~~(1e3/k))}()}return b},stop:function(){var a=this.el;return a&&(clearTimeout(this.timeout),a.parentNode&&a.parentNode.removeChild(a),this.el=c),this},lines:function(a,b){function e(a,d){return l(g(),{position:"absolute",width:b.length+b.width+"px",height:b.width+"px",background:a,boxShadow:d,transformOrigin:"left",transform:"rotate("+~~(360/b.lines*c+b.rotate)+"deg) translate("+b.radius+"px"+",0)",borderRadius:(b.width>>1)+"px"})}var c=0,d;for(;c<b.lines;c++)d=l(g(),{position:"absolute",top:1+~(b.width/2)+"px",transform:b.hwaccel?"translate3d(0,0,0)":"",opacity:b.opacity,animation:f&&j(b.opacity,b.trail,c,b.lines)+" "+1/b.speed+"s linear infinite"}),b.shadow&&h(d,l(e("#000","0 0 4px #000"),{top:"2px"})),h(a,h(d,e(b.color,"0 0 1px rgba(0,0,0,.1)")));return a},opacity:function(a,b,c){b<a.childNodes.length&&(a.childNodes[b].style.opacity=c)}}),!function(){function a(a,b){return g("<"+a+' xmlns="urn:schemas-microsoft.com:vml" class="spin-vml">',b)}var b=l(g("group"),{behavior:"url(#default#VML)"});!k(b,"transform")&&b.adj?(i.addRule(".spin-vml","behavior:url(#default#VML)"),p.prototype.lines=function(b,c){function f(){return l(a("group",{coordsize:e+" "+e,coordorigin:-d+" "+ -d}),{width:e,height:e})}function k(b,e,g){h(i,h(l(f(),{rotation:360/c.lines*b+"deg",left:~~e}),h(l(a("roundrect",{arcsize:1}),{width:d,height:c.width,left:c.radius,top:-c.width>>1,filter:g}),a("fill",{color:c.color,opacity:c.opacity}),a("stroke",{opacity:0}))))}var d=c.length+c.width,e=2*d,g=-(c.width+c.length)*2+"px",i=l(f(),{position:"absolute",top:g,left:g}),j;if(c.shadow)for(j=1;j<=c.lines;j++)k(j,-2,"progid:DXImageTransform.Microsoft.Blur(pixelradius=2,makeshadow=1,shadowopacity=.3)");for(j=1;j<=c.lines;j++)k(j);return h(b,i)},p.prototype.opacity=function(a,b,c,d){var e=a.firstChild;d=d.shadow&&d.lines||0,e&&b+d<e.childNodes.length&&(e=e.childNodes[b+d],e=e&&e.firstChild,e=e&&e.firstChild,e&&(e.opacity=c))}):f=k(b,"animation")}(),a.Spinner=p})(window,document);
|
||||
|
||||
$.fn.spin = function(opts) {
|
||||
this.each(function() {
|
||||
var $this = $(this),
|
||||
data = $this.data();
|
||||
|
||||
if (data.spinner) {
|
||||
data.spinner.stop();
|
||||
delete data.spinner;
|
||||
}
|
||||
if (opts !== false) {
|
||||
data.spinner = new Spinner($.extend({color: $this.css('color')}, opts)).spin(this);
|
||||
}
|
||||
});
|
||||
return this;
|
||||
};
|
|
@ -1,8 +1,6 @@
|
|||
|
||||
(function ($) {
|
||||
'use strict';
|
||||
/*jshint browser: true */
|
||||
/*global _, amplify, Base64, H5AI_CONFIG, jQuery, Modernizr, module, moment */
|
||||
|
||||
// @include "core/entry.js"
|
||||
// @include "core/event.js"
|
||||
|
@ -28,6 +26,8 @@
|
|||
// @include "ext/folderstatus.js"
|
||||
// @include "ext/l10n.js"
|
||||
// @include "ext/link-hover-states.js"
|
||||
// @include "ext/mode.js"
|
||||
// @include "ext/preview-img.js"
|
||||
// @include "ext/qrcode.js"
|
||||
// @include "ext/select.js"
|
||||
// @include "ext/sort.js"
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
module.define('model/entry', [jQuery, 'core/types'], function ($, types) {
|
||||
|
||||
var domain = document.domain,
|
||||
location = document.location.pathname,
|
||||
location = document.location.pathname.replace(/[^\/]*$/, ''),
|
||||
|
||||
|
||||
// utils
|
||||
|
@ -104,10 +104,13 @@ module.define('model/entry', [jQuery, 'core/types'], function ($, types) {
|
|||
if (split.parent) {
|
||||
this.parent = cache[split.parent] || new Entry(split.parent);
|
||||
this.parent.content[this.absHref] = this;
|
||||
if (_.keys(this.parent.content).length > 1) {
|
||||
this.parent.isContentFetched = true;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
get = function (absHref, time, size, status) {
|
||||
get = function (absHref, time, size, status, isContentFetched) {
|
||||
|
||||
absHref = absHref || location;
|
||||
|
||||
|
@ -122,6 +125,9 @@ module.define('model/entry', [jQuery, 'core/types'], function ($, types) {
|
|||
if (status) {
|
||||
self.status = status;
|
||||
}
|
||||
if (isContentFetched) {
|
||||
self.isContentFetched = true;
|
||||
}
|
||||
|
||||
return self;
|
||||
},
|
||||
|
@ -146,8 +152,7 @@ module.define('model/entry', [jQuery, 'core/types'], function ($, types) {
|
|||
|
||||
var self = cache[absHref] || new Entry(absHref);
|
||||
|
||||
if (self.isContentFetched || _.keys(self.content).length > 1) {
|
||||
self.isContentFetched = true;
|
||||
if (self.isContentFetched) {
|
||||
callback(self);
|
||||
} else {
|
||||
fetchStatus(absHref, function (self) {
|
||||
|
@ -215,7 +220,7 @@ module.define('model/entry', [jQuery, 'core/types'], function ($, types) {
|
|||
return entry.isFolder();
|
||||
}), function (entry) {
|
||||
|
||||
return entry.absHref;
|
||||
return entry.label.toLowerCase();
|
||||
});
|
||||
},
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
module.define('parser/apache-autoindex', [jQuery, 'core/format', 'model/entry'], function ($, format, Entry) {
|
||||
module.define('parser/apache-autoindex', [jQuery, 'core/settings', 'core/format', 'model/entry'], function ($, settings, format, Entry) {
|
||||
|
||||
var parseTableRow = function (absHref, tr) {
|
||||
|
||||
|
@ -37,6 +37,11 @@ module.define('parser/apache-autoindex', [jQuery, 'core/format', 'model/entry'],
|
|||
|
||||
return {
|
||||
id: 'apache-autoindex',
|
||||
mode: 'aai',
|
||||
server: {
|
||||
name: 'apache',
|
||||
version: null
|
||||
},
|
||||
parse: parse
|
||||
};
|
||||
});
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
|
||||
module.define('parser/generic-json', [jQuery, 'core/settings', 'model/entry'], function ($, settings, Entry) {
|
||||
|
||||
// expectes an hash of the form
|
||||
// {
|
||||
// entries: [
|
||||
// {absHref: String, time: Number, size: Number, status: Number or "h5ai"}
|
||||
// ]
|
||||
// }
|
||||
var parser = {
|
||||
id: 'generic-json',
|
||||
mode: null,
|
||||
server: {
|
||||
name: null,
|
||||
version: null
|
||||
}
|
||||
},
|
||||
|
||||
var parseJson = function (absHref, json) {
|
||||
parseJson = function (absHref, json) {
|
||||
|
||||
if (json.hasOwnProperty('customHeader')) {
|
||||
settings.custom.header = json.customHeader;
|
||||
|
@ -16,10 +18,16 @@ module.define('parser/generic-json', [jQuery, 'core/settings', 'model/entry'], f
|
|||
if (json.hasOwnProperty('customFooter')) {
|
||||
settings.custom.footer = json.customFooter;
|
||||
}
|
||||
if (json.hasOwnProperty('mode')) {
|
||||
parser.mode = json.mode;
|
||||
}
|
||||
if (json.hasOwnProperty('server')) {
|
||||
parser.server = json.server;
|
||||
}
|
||||
|
||||
return _.map(json.entries, function (jsonEntry) {
|
||||
|
||||
return Entry.get(jsonEntry.absHref, jsonEntry.time, jsonEntry.size, jsonEntry.status);
|
||||
return Entry.get(jsonEntry.absHref, jsonEntry.time, jsonEntry.size, jsonEntry.status, jsonEntry.content);
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -41,8 +49,7 @@ module.define('parser/generic-json', [jQuery, 'core/settings', 'model/entry'], f
|
|||
return parseJsonStr(absHref, $id.text());
|
||||
};
|
||||
|
||||
return {
|
||||
id: 'generic-json',
|
||||
parse: parse
|
||||
};
|
||||
parser.parse = parse;
|
||||
|
||||
return parser;
|
||||
});
|
||||
|
|
|
@ -28,8 +28,6 @@ module.define('view/extended', [jQuery, 'core/settings', 'core/resource', 'core/
|
|||
'</ul>',
|
||||
emptyTemplate = '<div class="empty l10n-empty">empty</div>',
|
||||
|
||||
|
||||
|
||||
// updates this single entry
|
||||
update = function (entry) {
|
||||
|
||||
|
@ -43,28 +41,17 @@ module.define('view/extended', [jQuery, 'core/settings', 'core/resource', 'core/
|
|||
$imgBig = $html.find('.icon.big img'),
|
||||
$label = $html.find('.label'),
|
||||
$date = $html.find('.date'),
|
||||
$size = $html.find('.size'),
|
||||
icon16 = resource.icon(entry.type),
|
||||
icon48 = resource.icon(entry.type, true),
|
||||
escapedHref = entry.absHref.replace(/'/g, "%27").replace(/"/g, "%22");
|
||||
$size = $html.find('.size');
|
||||
// escapedHref = entry.absHref.replace(/'/g, "%27").replace(/"/g, "%22");
|
||||
|
||||
$html
|
||||
.addClass(entry.isFolder() ? 'folder' : 'file')
|
||||
.data('entry', entry)
|
||||
.data('status', entry.status);
|
||||
|
||||
if (entry.isParentFolder) {
|
||||
icon16 = resource.icon('folder-parent');
|
||||
icon48 = resource.icon('folder-parent', true);
|
||||
if (!settings.setParentFolderLabels) {
|
||||
$label.addClass('l10n-parentDirectory');
|
||||
}
|
||||
$html.addClass('folder-parent');
|
||||
}
|
||||
|
||||
$a.attr('href', entry.absHref);
|
||||
$imgSmall.attr('src', icon16).attr('alt', entry.type);
|
||||
$imgBig.attr('src', icon48).attr('alt', entry.type);
|
||||
$imgSmall.attr('src', resource.icon(entry.type)).attr('alt', entry.type);
|
||||
$imgBig.attr('src', resource.icon(entry.type, true)).attr('alt', entry.type);
|
||||
$label.text(entry.label);
|
||||
$date.data('time', entry.time).text(format.formatDate(entry.time));
|
||||
$size.data('bytes', entry.size).text(format.formatSize(entry.size));
|
||||
|
@ -80,6 +67,15 @@ module.define('view/extended', [jQuery, 'core/settings', 'core/resource', 'core/
|
|||
}
|
||||
}
|
||||
|
||||
if (entry.isParentFolder) {
|
||||
$imgSmall.attr('src', resource.icon('folder-parent'));
|
||||
$imgBig.attr('src', resource.icon('folder-parent', true));
|
||||
if (!settings.setParentFolderLabels) {
|
||||
$label.addClass('l10n-parentDirectory');
|
||||
}
|
||||
$html.addClass('folder-parent');
|
||||
}
|
||||
|
||||
if (entry.$extended) {
|
||||
entry.$extended.replaceWith($html);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
module.define('view/viewmode', [jQuery, 'core/settings', 'core/resource', 'core/store'], function ($, allsettings, resource, store) {
|
||||
|
||||
var defaults = {
|
||||
modes: ['details', 'icons'],
|
||||
modes: ['details', 'list', 'icons'],
|
||||
setParentFolderLabels: false
|
||||
},
|
||||
|
||||
|
@ -10,67 +10,51 @@ module.define('view/viewmode', [jQuery, 'core/settings', 'core/resource', 'core/
|
|||
|
||||
storekey = 'h5ai.viewmode',
|
||||
|
||||
templates = {
|
||||
details: '<li id="viewdetails" class="view">' +
|
||||
'<a href="#">' +
|
||||
'<img src="' + resource.image('view-details') + '" alt="view-details" />' +
|
||||
'<span class="l10n-details">details</span>' +
|
||||
'</a>' +
|
||||
'</li>',
|
||||
icons: '<li id="viewicons" class="view">' +
|
||||
'<a href="#">' +
|
||||
'<img src="' + resource.image('view-icons') + '" alt="view-icons" />' +
|
||||
'<span class="l10n-icons">icons</span>' +
|
||||
'</a>' +
|
||||
'</li>'
|
||||
},
|
||||
template = '<li id="view-[MODE]" class="view">' +
|
||||
'<a href="#">' +
|
||||
'<img src="' + resource.image('view-[MODE]') + '" alt="view-[MODE]" />' +
|
||||
'<span class="l10n-[MODE]">[MODE]</span>' +
|
||||
'</a>' +
|
||||
'</li>',
|
||||
|
||||
update = function (viewmode) {
|
||||
|
||||
var $viewDetails = $('#viewdetails'),
|
||||
$viewIcons = $('#viewicons'),
|
||||
$extended = $('#extended');
|
||||
var $extended = $('#extended');
|
||||
|
||||
if (viewmode) {
|
||||
store.put(storekey, viewmode);
|
||||
} else {
|
||||
viewmode = store.get(storekey);
|
||||
}
|
||||
viewmode = $.inArray(viewmode, settings.modes) >= 0 ? viewmode : settings.modes[0];
|
||||
viewmode = _.indexOf(settings.modes, viewmode) >= 0 ? viewmode : settings.modes[0];
|
||||
store.put(storekey, viewmode);
|
||||
|
||||
$viewDetails.add($viewIcons).removeClass('current');
|
||||
if (viewmode === 'details') {
|
||||
$viewDetails.addClass('current');
|
||||
$extended.addClass('details-view').removeClass('icons-view').show();
|
||||
} else if (viewmode === 'icons') {
|
||||
$viewIcons.addClass('current');
|
||||
$extended.removeClass('details-view').addClass('icons-view').show();
|
||||
} else {
|
||||
$extended.hide();
|
||||
}
|
||||
_.each(defaults.modes, function (mode) {
|
||||
if (mode === viewmode) {
|
||||
$('#view-' + mode).addClass('current');
|
||||
$extended.addClass('view-' + mode).show();
|
||||
} else {
|
||||
$('#view-' + mode).removeClass('current');
|
||||
$extended.removeClass('view-' + mode);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
init = function () {
|
||||
|
||||
var $navbar = $('#navbar'),
|
||||
$extended = $('#extended');
|
||||
var $navbar = $('#navbar');
|
||||
|
||||
settings.modes = _.intersection(settings.modes, defaults.modes);
|
||||
|
||||
if (settings.modes.length > 1) {
|
||||
_.each(['icons', 'details'], function (view) {
|
||||
if ($.inArray(view, settings.modes) >= 0) {
|
||||
$(templates[view])
|
||||
_.each(defaults.modes.reverse(), function (mode) {
|
||||
if (_.indexOf(settings.modes, mode) >= 0) {
|
||||
$(template.replace(/\[MODE\]/g, mode))
|
||||
.appendTo($navbar)
|
||||
.on('click', 'a', function (event) {
|
||||
update(view);
|
||||
update(mode);
|
||||
event.preventDefault();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
update();
|
||||
update(store.get(storekey));
|
||||
};
|
||||
|
||||
init();
|
||||
|
|
4
src/_h5ai/js/jquery-1.7.2.min.js
vendored
Normal file
4
src/_h5ai/js/jquery-1.7.2.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
|
@ -1,24 +1,23 @@
|
|||
|
||||
// libs
|
||||
// ----
|
||||
// @include "inc/lib/modernizr-2.5.3.min.js"
|
||||
// @include "inc/lib/moment-1.5.0.min.js"
|
||||
// @include "inc/lib/json2.js"
|
||||
// @include "inc/lib/base64.js"
|
||||
// jQuery libs
|
||||
// -----------
|
||||
// @include "inc/lib/jquery.fracs-0.11.min.js"
|
||||
// @include "inc/lib/jquery.mousewheel-3.0.6.js"
|
||||
// @include "inc/lib/jquery.qrcode.js"
|
||||
// @include "inc/lib/jquery.scrollpanel.js"
|
||||
|
||||
// underscore libs
|
||||
// ---------------
|
||||
// @include "inc/lib/underscore-1.3.1.min.js"
|
||||
// @include "inc/lib/module.js"
|
||||
|
||||
// jQuery libs
|
||||
// -----------
|
||||
// @include "inc/lib/jquery-1.7.1.min.js"
|
||||
// @include "inc/lib/jquery.fracs-0.11.min.js"
|
||||
// @include "inc/lib/jquery.mousewheel-3.0.6.js"
|
||||
// @include "inc/lib/jquery.qrcode.js"
|
||||
// @include "inc/lib/jquery.scrollpanel.js"
|
||||
// other libs
|
||||
// ----------
|
||||
// @include "inc/lib/amplify-1.1.0.min.js"
|
||||
// @include "inc/lib/moment-1.5.0.min.js"
|
||||
// @include "inc/lib/json2.js"
|
||||
// @include "inc/lib/base64.js"
|
||||
// @include "inc/lib/spin-1.2.5.min.js"
|
||||
|
||||
// h5ai
|
||||
// ----
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue