mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-05-24 03:57:08 -04:00
Fix a lot eslint errors.
This commit is contained in:
parent
0c6143704a
commit
39ea94daa8
88 changed files with 3872 additions and 4930 deletions
|
@ -7,9 +7,6 @@
|
|||
es6: true
|
||||
node: true
|
||||
|
||||
globals:
|
||||
modulejs: false
|
||||
|
||||
ecmaFeatures:
|
||||
arrowFunctions: true
|
||||
binaryLiterals: true
|
||||
|
@ -68,7 +65,7 @@
|
|||
max-nested-callbacks: [1, 3]
|
||||
max-params: [1, 5] ###
|
||||
max-statements: [1, 80] ###
|
||||
new-cap: 1
|
||||
new-cap: 0
|
||||
new-parens: 2
|
||||
newline-after-var: 0
|
||||
no-alert: 2
|
||||
|
|
11
CHANGELOG.md
11
CHANGELOG.md
|
@ -14,7 +14,8 @@
|
|||
* fixes preview bottom bar for small screen widths
|
||||
* lots of code cleanup and refactorings
|
||||
* changes API
|
||||
* updates build process
|
||||
* updates build process, now uses [ghu](https://larsjung.de/ghu/)
|
||||
* switches from jshint and jscs to [eslint](http://eslint.org/)
|
||||
* updates `lodash` to 3.8.0 (adds debounce and trim)
|
||||
* updates h5bp styles to 5.1.0
|
||||
* updates `normalize.css` to 3.0.3
|
||||
|
@ -40,7 +41,7 @@
|
|||
* improves drag-select
|
||||
* improves image preview
|
||||
* prevents listing `_h5ai` folder and subfolders
|
||||
* updates build process, now uses [mkr](http://larsjung.de/mkr/) and [fQuery](http://larsjung.de/fquery/)
|
||||
* updates build process, now uses [mkr](https://larsjung.de/mkr/) and [fQuery](https://larsjung.de/fquery/)
|
||||
* updates `jQuery` to 2.1.3
|
||||
* updates `jQuery.qrcode` to 0.11.0
|
||||
* updates `Lo-Dash` to 3.6.0
|
||||
|
@ -222,9 +223,9 @@
|
|||
* changes language code `gr` to `el`
|
||||
* adds localization for filter placeholder
|
||||
* adds `hu` translation by [Rodolffo](https://github.com/Rodolffo)
|
||||
* updates to [jQuery.qrcode](http://larsjung.de/qrcode/) 0.2
|
||||
* updates to [jQuery.scrollpanel](http://larsjung.de/scrollpanel/) 0.1
|
||||
* updates to [modulejs](http://larsjung.de/modulejs/) 0.2
|
||||
* updates to [jQuery.qrcode](https://larsjung.de/qrcode/) 0.2
|
||||
* updates to [jQuery.scrollpanel](https://larsjung.de/scrollpanel/) 0.1
|
||||
* updates to [modulejs](https://larsjung.de/modulejs/) 0.2
|
||||
* updates to [Moment.js](http://momentjs.com) 1.7.0
|
||||
* updates to [Underscore.js](http://underscorejs.org) 1.3.3
|
||||
|
||||
|
|
12
README.md
12
README.md
|
@ -40,7 +40,7 @@ To build the frontend test suite run `npm run build-test`. This will output a
|
|||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 Lars Jung (http://larsjung.de)
|
||||
Copyright (c) 2015 Lars Jung (https://larsjung.de)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -67,14 +67,14 @@ THE SOFTWARE.
|
|||
too. Exceptions are the [Material Design icons][material-design-icons] (CC BY 4.0).
|
||||
|
||||
|
||||
[web]: http://larsjung.de/h5ai/
|
||||
[web]: https://larsjung.de/h5ai/
|
||||
[github]: https://github.com/lrsjng/h5ai
|
||||
[github-issues]: https://github.com/lrsjng/h5ai/issues
|
||||
[release]: http://release.larsjung.de/h5ai/
|
||||
[develop]: http://release.larsjung.de/h5ai/develop/
|
||||
[git]: http://git-scm.com
|
||||
[release]: https://release.larsjung.de/h5ai/
|
||||
[develop]: https://release.larsjung.de/h5ai/develop/
|
||||
[git]: https://git-scm.com
|
||||
[node]: https://nodejs.org
|
||||
[mkr]: http://larsjung.de/mkr/
|
||||
[mkr]: https://larsjung.de/mkr/
|
||||
[material-design-icons]: https://github.com/google/material-design-icons
|
||||
|
||||
[license-img]: https://img.shields.io/badge/license-MIT-a0a060.svg?style=flat-square
|
||||
|
|
12
ghu.js
12
ghu.js
|
@ -2,12 +2,13 @@ import {resolve, join} from 'path';
|
|||
import dateformat from 'dateformat';
|
||||
import ghu from 'ghu';
|
||||
import {
|
||||
autoprefixer, babel, cssmin, ife, includeit, jade, jszip,
|
||||
autoprefixer, cssmin, ife, includeit, jade, jszip,
|
||||
less, mapfn, newerThan, read, remove, run, uglify, watch, wrap, write
|
||||
} from 'ghu';
|
||||
|
||||
const ROOT = resolve(__dirname);
|
||||
const SRC = join(ROOT, 'src');
|
||||
const TEST = join(ROOT, 'test');
|
||||
const BUILD = join(ROOT, 'build');
|
||||
|
||||
const mapper = mapfn.p(SRC, BUILD).s('.less', '.css').s('.jade', '');
|
||||
|
@ -54,7 +55,6 @@ ghu.task('build:scripts', runtime => {
|
|||
return read(`${SRC}/_h5ai/public/js/*.js`)
|
||||
.then(newerThan(mapper, `${SRC}/_h5ai/public/js/**`))
|
||||
.then(includeit())
|
||||
// .then(babel({compact: false}))
|
||||
.then(ife(() => runtime.args.production, uglify()))
|
||||
.then(wrap(runtime.commentJs))
|
||||
.then(write(mapper, {overwrite: true}));
|
||||
|
@ -100,19 +100,19 @@ ghu.task('build:copy', runtime => {
|
|||
|
||||
ghu.task('build:tests', ['build:scripts', 'build:styles'], 'build the test suite', runtime => {
|
||||
return Promise.all([
|
||||
read(`${ROOT}/test/scripts.js`)
|
||||
read(`${TEST}/scripts.js`)
|
||||
.then(newerThan(`${BUILD}/test/scripts.js`))
|
||||
.then(includeit())
|
||||
.then(write(`${BUILD}/test/scripts.js`, {overwrite: true})),
|
||||
|
||||
read(`${ROOT}/test/styles.less`)
|
||||
read(`${TEST}/styles.less`)
|
||||
.then(newerThan(`${BUILD}/test/styles.css`))
|
||||
.then(includeit())
|
||||
.then(less())
|
||||
.then(autoprefixer())
|
||||
.then(write(`${BUILD}/test/styles.css`, {overwrite: true})),
|
||||
|
||||
read(`${ROOT}/test/index.html.jade`)
|
||||
read(`${TEST}/index.html.jade`)
|
||||
.then(newerThan(`${BUILD}/test/index.html`))
|
||||
.then(jade({pkg: runtime.pkg}))
|
||||
.then(write(`${BUILD}/test/index.html`, {overwrite: true})),
|
||||
|
@ -146,7 +146,7 @@ ghu.task('deploy', ['build'], 'deploy to a specified path with :dest=/some/path'
|
|||
});
|
||||
|
||||
ghu.task('watch', runtime => {
|
||||
return watch([SRC], () => ghu.run(runtime.sequence.filter(x => x !== 'watch'), runtime.args, true));
|
||||
return watch([SRC, TEST], () => ghu.run(runtime.sequence.filter(x => x !== 'watch'), runtime.args, true));
|
||||
});
|
||||
|
||||
ghu.task('release', ['force-production', 'clean', 'build'], 'create a zipball', runtime => {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
{
|
||||
"name": "h5ai",
|
||||
"version": "0.27.0",
|
||||
"develop": true,
|
||||
"description": "A modern HTTP web server index.",
|
||||
"homepage": "https://larsjung.de/h5ai/",
|
||||
"bugs": "https://github.com/lrsjng/h5ai/issues",
|
||||
|
|
43
src/.eslintrc
Normal file
43
src/.eslintrc
Normal file
|
@ -0,0 +1,43 @@
|
|||
---
|
||||
env:
|
||||
es6: false
|
||||
node: false
|
||||
browser: true
|
||||
mocha: false
|
||||
|
||||
globals:
|
||||
modulejs: false
|
||||
|
||||
ecmaFeatures:
|
||||
arrowFunctions: false
|
||||
binaryLiterals: false
|
||||
blockBindings: false
|
||||
classes: false
|
||||
defaultParams: false
|
||||
destructuring: false
|
||||
forOf: false
|
||||
generators: false
|
||||
globalReturn: false
|
||||
jsx: false
|
||||
modules: false
|
||||
objectLiteralComputedProperties: false
|
||||
objectLiteralDuplicateProperties: false
|
||||
objectLiteralShorthandMethods: false
|
||||
objectLiteralShorthandProperties: false
|
||||
octalLiterals: false
|
||||
regexUFlag: false
|
||||
regexYFlag: false
|
||||
spread: false
|
||||
superInFunctions: false
|
||||
templateStrings: false
|
||||
unicodeCodePointEscapes: false
|
||||
|
||||
rules:
|
||||
consistent-this: 0
|
||||
func-names: 0
|
||||
max-params: [1, 10]
|
||||
no-invalid-this: 0
|
||||
no-var: 0
|
||||
object-shorthand: 0
|
||||
prefer-arrow-callback: 0
|
||||
prefer-reflect: 0
|
|
@ -1,13 +1,9 @@
|
|||
modulejs.define('core/event', ['_'], function (_) {
|
||||
|
||||
var slice = Array.prototype.slice;
|
||||
var subscriptions = {};
|
||||
|
||||
|
||||
function sub(topic, callback) {
|
||||
|
||||
if (_.isString(topic) && _.isFunction(callback)) {
|
||||
|
||||
if (!subscriptions[topic]) {
|
||||
subscriptions[topic] = [];
|
||||
}
|
||||
|
@ -16,21 +12,16 @@ modulejs.define('core/event', ['_'], function (_) {
|
|||
}
|
||||
|
||||
function unsub(topic, callback) {
|
||||
|
||||
if (_.isString(topic) && _.isFunction(callback) && subscriptions[topic]) {
|
||||
|
||||
subscriptions[topic] = _.without(subscriptions[topic], callback);
|
||||
}
|
||||
}
|
||||
|
||||
function pub(topic) {
|
||||
|
||||
var args = slice.call(arguments, 1);
|
||||
|
||||
if (_.isString(topic) && subscriptions[topic]) {
|
||||
|
||||
_.each(subscriptions[topic], function (callback) {
|
||||
|
||||
callback.apply(topic, args);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
modulejs.define('core/format', ['_'], function (_) {
|
||||
|
||||
var decimalMetric = {
|
||||
t: 1000.0,
|
||||
k: 1000.0,
|
||||
|
@ -30,12 +29,10 @@ modulejs.define('core/format', ['_'], function (_) {
|
|||
|
||||
|
||||
function setDefaultMetric(useBinaryMetric) {
|
||||
|
||||
defaultMetric = useBinaryMetric ? binaryMetric : decimalMetric;
|
||||
}
|
||||
|
||||
function formatSize(size, metric) {
|
||||
|
||||
metric = metric || defaultMetric;
|
||||
|
||||
if (!_.isNumber(size) || size < 0) {
|
||||
|
@ -53,12 +50,10 @@ modulejs.define('core/format', ['_'], function (_) {
|
|||
}
|
||||
|
||||
function setDefaultDateFormat(dateFormat) {
|
||||
|
||||
defaultDateFormat = dateFormat;
|
||||
}
|
||||
|
||||
function formatNumber(number, padding) {
|
||||
|
||||
var str = String(number);
|
||||
if (padding) {
|
||||
str = ('000' + str).substr(-padding);
|
||||
|
@ -67,7 +62,6 @@ modulejs.define('core/format', ['_'], function (_) {
|
|||
}
|
||||
|
||||
function formatDate(millis, format) {
|
||||
|
||||
if (!millis || !_.isNumber(millis)) {
|
||||
return '';
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
modulejs.define('core/langs', ['_', 'config'], function (_, config) {
|
||||
|
||||
return _.extend({}, config.langs);
|
||||
});
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
modulejs.define('core/location', ['_', 'core/event', 'core/modernizr', 'core/settings', 'view/notification'], function (_, event, modernizr, allsettings, notification) {
|
||||
|
||||
var settings = _.extend({
|
||||
fastBrowsing: true,
|
||||
unmanagedInNewWindow: true
|
||||
|
@ -23,7 +22,7 @@ modulejs.define('core/location', ['_', 'core/event', 'core/modernizr', 'core/set
|
|||
[/\,/g, '%2C'],
|
||||
[/:/g, '%3A'],
|
||||
[/;/g, '%3B'],
|
||||
[/=/g, '%3D'],
|
||||
[/\=/g, '%3D'],
|
||||
[/\?/g, '%3F'],
|
||||
[/@/g, '%40'],
|
||||
[/\[/g, '%5B'],
|
||||
|
@ -31,20 +30,16 @@ modulejs.define('core/location', ['_', 'core/event', 'core/modernizr', 'core/set
|
|||
];
|
||||
|
||||
function forceEncoding(href) {
|
||||
|
||||
return reForceEncoding.reduce(function (href, data) {
|
||||
|
||||
return href.replace(data[0], data[1]);
|
||||
return reForceEncoding.reduce(function (nuHref, data) {
|
||||
return nuHref.replace(data[0], data[1]);
|
||||
}, href);
|
||||
}
|
||||
|
||||
function uriToPathname(uri) {
|
||||
|
||||
return uri.replace(reUriToPathname, '');
|
||||
}
|
||||
|
||||
var hrefsAreDecoded = (function () {
|
||||
|
||||
var testpathname = '/a b';
|
||||
var a = doc.createElement('a');
|
||||
|
||||
|
@ -53,7 +48,6 @@ modulejs.define('core/location', ['_', 'core/event', 'core/modernizr', 'core/set
|
|||
}());
|
||||
|
||||
function encodedHref(href) {
|
||||
|
||||
var a = doc.createElement('a');
|
||||
var location;
|
||||
|
||||
|
@ -68,39 +62,31 @@ modulejs.define('core/location', ['_', 'core/event', 'core/modernizr', 'core/set
|
|||
}
|
||||
|
||||
function getDomain() {
|
||||
|
||||
return doc.domain;
|
||||
}
|
||||
|
||||
function getAbsHref() {
|
||||
|
||||
return absHref;
|
||||
}
|
||||
|
||||
function getItem() {
|
||||
|
||||
return modulejs.require('model/item').get(absHref);
|
||||
}
|
||||
|
||||
function load(callback) {
|
||||
|
||||
modulejs.require('core/server').request({action: 'get', items: {href: absHref, what: 1}}, function (json) {
|
||||
|
||||
var Item = modulejs.require('model/item');
|
||||
var item = Item.get(absHref);
|
||||
|
||||
if (json) {
|
||||
|
||||
var found = {};
|
||||
|
||||
_.each(json.items, function (jsonItem) {
|
||||
|
||||
var e = Item.get(jsonItem);
|
||||
found[e.absHref] = true;
|
||||
});
|
||||
|
||||
_.each(item.content, function (e) {
|
||||
|
||||
if (!found[e.absHref]) {
|
||||
Item.remove(e.absHref);
|
||||
}
|
||||
|
@ -112,8 +98,22 @@ modulejs.define('core/location', ['_', 'core/event', 'core/modernizr', 'core/set
|
|||
});
|
||||
}
|
||||
|
||||
function setLocation(newAbsHref, keepBrowserUrl) {
|
||||
function refresh() {
|
||||
var item = getItem();
|
||||
var oldItems = _.values(item.content);
|
||||
|
||||
event.pub('location.beforeRefresh');
|
||||
|
||||
load(function () {
|
||||
var newItems = _.values(item.content);
|
||||
var added = _.difference(newItems, oldItems);
|
||||
var removed = _.difference(oldItems, newItems);
|
||||
|
||||
event.pub('location.refreshed', item, added, removed);
|
||||
});
|
||||
}
|
||||
|
||||
function setLocation(newAbsHref, keepBrowserUrl) {
|
||||
event.pub('location.beforeChange');
|
||||
|
||||
newAbsHref = encodedHref(newAbsHref);
|
||||
|
@ -144,30 +144,11 @@ modulejs.define('core/location', ['_', 'core/event', 'core/modernizr', 'core/set
|
|||
}
|
||||
}
|
||||
|
||||
function refresh() {
|
||||
|
||||
var item = getItem();
|
||||
var oldItems = _.values(item.content);
|
||||
|
||||
event.pub('location.beforeRefresh');
|
||||
|
||||
load(function () {
|
||||
|
||||
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;
|
||||
});
|
||||
|
@ -179,7 +160,6 @@ modulejs.define('core/location', ['_', 'core/event', 'core/modernizr', 'core/set
|
|||
}
|
||||
|
||||
function onPopState(ev) {
|
||||
|
||||
if (ev.state && ev.state.absHref) {
|
||||
setLocation(ev.state.absHref, true);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
modulejs.define('core/modernizr', function () {
|
||||
|
||||
var hasCanvas = (function () {
|
||||
|
||||
var elem = document.createElement('canvas');
|
||||
return Boolean(elem.getContext && elem.getContext('2d'));
|
||||
}());
|
||||
|
@ -9,7 +7,6 @@ modulejs.define('core/modernizr', function () {
|
|||
var hasHistory = Boolean(window.history && history.pushState);
|
||||
|
||||
var hasLocalStorage = (function () {
|
||||
|
||||
var key = '#test#';
|
||||
try {
|
||||
localStorage.setItem(key, key);
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
modulejs.define('core/resource', ['_', 'config', 'core/settings'], function (_, config, settings) {
|
||||
|
||||
var imagesHref = settings.publicHref + 'images/';
|
||||
var uiHref = imagesHref + 'ui/';
|
||||
var themesHref = imagesHref + 'themes/';
|
||||
|
@ -8,12 +7,10 @@ modulejs.define('core/resource', ['_', 'config', 'core/settings'], function (_,
|
|||
|
||||
|
||||
function image(id) {
|
||||
|
||||
return uiHref + id + '.svg';
|
||||
}
|
||||
|
||||
function icon(id) {
|
||||
|
||||
var baseId = (id || '').split('-')[0];
|
||||
var href = config.theme[id] || config.theme[baseId];
|
||||
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
modulejs.define('core/server', ['_', '$'], function (_, $) {
|
||||
|
||||
function request(data, callback) {
|
||||
|
||||
$.ajax({
|
||||
url: '?',
|
||||
data: data,
|
||||
|
@ -9,21 +7,17 @@ modulejs.define('core/server', ['_', '$'], function (_, $) {
|
|||
dataType: 'json'
|
||||
})
|
||||
.done(function (json) {
|
||||
|
||||
callback(json);
|
||||
})
|
||||
.fail(function () {
|
||||
|
||||
callback();
|
||||
});
|
||||
}
|
||||
|
||||
function formRequest(data) {
|
||||
|
||||
var $form = $('<form method="post" action="?" style="display:none;"/>');
|
||||
|
||||
_.each(data, function (val, key) {
|
||||
|
||||
$('<input type="hidden"/>')
|
||||
.attr('name', key)
|
||||
.attr('value', val)
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
modulejs.define('core/settings', ['_', 'config'], function (_, config) {
|
||||
|
||||
return _.extend({}, config.options, {
|
||||
publicHref: config.setup.PUBLIC_HREF,
|
||||
rootHref: config.setup.ROOT_HREF
|
||||
|
|
|
@ -1,31 +1,26 @@
|
|||
modulejs.define('core/store', ['core/modernizr'], function (modernizr) {
|
||||
|
||||
var store = modernizr.localstorage ? window.localStorage : {};
|
||||
var storekey = '_h5ai';
|
||||
|
||||
|
||||
function load() {
|
||||
|
||||
try {
|
||||
return JSON.parse(store[storekey]);
|
||||
} catch (e) {}
|
||||
} catch (e) {/* skip */}
|
||||
return {};
|
||||
}
|
||||
|
||||
function save(obj) {
|
||||
|
||||
store[storekey] = JSON.stringify(obj);
|
||||
}
|
||||
|
||||
function put(key, value) {
|
||||
|
||||
var obj = load();
|
||||
obj[key] = value;
|
||||
save(obj);
|
||||
}
|
||||
|
||||
function get(key) {
|
||||
|
||||
return load()[key];
|
||||
}
|
||||
|
||||
|
|
|
@ -1,26 +1,21 @@
|
|||
modulejs.define('core/types', ['_', 'config'], function (_, config) {
|
||||
|
||||
var reEndsWithSlash = /\/$/;
|
||||
var regexps = {};
|
||||
|
||||
|
||||
function escapeRegExp(sequence) {
|
||||
|
||||
return sequence.replace(/[\-\[\]\/\{\}\(\)\+\?\.\\\^\$]/g, '\\$&');
|
||||
// return sequence.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
|
||||
}
|
||||
|
||||
function parse(types) {
|
||||
|
||||
_.each(types, function (patterns, type) {
|
||||
|
||||
var pattern = '^(' + _.map(patterns, function (p) { return '(' + escapeRegExp(p).replace(/\*/g, '.*') + ')'; }).join('|') + ')$';
|
||||
regexps[type] = new RegExp(pattern, 'i');
|
||||
});
|
||||
}
|
||||
|
||||
function getType(sequence) {
|
||||
|
||||
if (reEndsWithSlash.test(sequence)) {
|
||||
return 'folder';
|
||||
}
|
||||
|
@ -30,7 +25,6 @@ modulejs.define('core/types', ['_', 'config'], function (_, config) {
|
|||
var result;
|
||||
|
||||
_.each(regexps, function (regexp, type) {
|
||||
|
||||
if (regexps[type].test(name)) {
|
||||
result = type;
|
||||
return false;
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
modulejs.define('core/util', ['_'], function (_) {
|
||||
|
||||
|
||||
function regularCmpFn(val1, val2) {
|
||||
|
||||
if (val1 < val2) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -17,7 +14,6 @@ modulejs.define('core/util', ['_'], function (_) {
|
|||
//
|
||||
// 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})/;
|
||||
|
@ -30,7 +26,7 @@ modulejs.define('core/util', ['_'], function (_) {
|
|||
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 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;
|
||||
var oFyNcL;
|
||||
|
@ -49,7 +45,7 @@ modulejs.define('core/util', ['_'], function (_) {
|
|||
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;
|
||||
return isNaN(oFxNcL) ? 1 : -1;
|
||||
} else if (typeof oFxNcL !== typeof oFyNcL) {
|
||||
// rely on string comparison if different types - i.e. '02' < 2 != '02' < '2'
|
||||
oFxNcL += '';
|
||||
|
@ -66,12 +62,10 @@ modulejs.define('core/util', ['_'], function (_) {
|
|||
}
|
||||
|
||||
function escapePattern(sequence) {
|
||||
|
||||
return sequence.replace(/[\-\[\]{}()*+?.,\\$\^|#\s]/g, '\\$&');
|
||||
}
|
||||
|
||||
function parsePattern(sequence, advanced) {
|
||||
|
||||
if (!advanced) {
|
||||
return escapePattern(sequence);
|
||||
}
|
||||
|
@ -81,9 +75,7 @@ modulejs.define('core/util', ['_'], function (_) {
|
|||
}
|
||||
|
||||
sequence = _.map(_.trim(sequence).split(/\s+/), function (part) {
|
||||
|
||||
return _.map(part.split(''), function (character) {
|
||||
|
||||
return escapePattern(character);
|
||||
}).join('.*?');
|
||||
}).join('|');
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
modulejs.define('ext/autorefresh', ['_', '$', 'core/event', 'core/location', 'core/settings'], function (_, $, event, location, allsettings) {
|
||||
|
||||
var settings = _.extend({
|
||||
enabled: false,
|
||||
interval: 5000
|
||||
|
@ -8,23 +7,19 @@ modulejs.define('ext/autorefresh', ['_', '$', 'core/event', 'core/location', 'co
|
|||
|
||||
|
||||
function heartbeat() {
|
||||
|
||||
location.refresh();
|
||||
}
|
||||
|
||||
function before() {
|
||||
|
||||
clearTimeout(timeoutId);
|
||||
}
|
||||
|
||||
function after() {
|
||||
|
||||
clearTimeout(timeoutId);
|
||||
timeoutId = setTimeout(heartbeat, settings.interval);
|
||||
}
|
||||
|
||||
function init() {
|
||||
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
modulejs.define('ext/contextmenu', ['_', '$', 'core/resource', 'core/settings'], function (_, $, resource, allsettings) {
|
||||
|
||||
var settings = _.extend({
|
||||
enabled: false
|
||||
}, allsettings.contextmenu);
|
||||
|
@ -11,12 +10,10 @@ modulejs.define('ext/contextmenu', ['_', '$', 'core/resource', 'core/settings'],
|
|||
|
||||
|
||||
function createOverlay(callback) {
|
||||
|
||||
var $overlay = $(templateOverlay);
|
||||
|
||||
$overlay
|
||||
.on('click contextmenu', function (ev) {
|
||||
|
||||
ev.stopPropagation();
|
||||
ev.preventDefault();
|
||||
|
||||
|
@ -32,20 +29,16 @@ modulejs.define('ext/contextmenu', ['_', '$', 'core/resource', 'core/settings'],
|
|||
}
|
||||
|
||||
function createPanel(menu) {
|
||||
|
||||
var $panel = $(templatePanel);
|
||||
var $ul = $panel.find('ul');
|
||||
var $li;
|
||||
|
||||
_.each(menu, function (entry) {
|
||||
|
||||
if (entry.type === '-') {
|
||||
$(templateSep).appendTo($ul);
|
||||
|
||||
} else if (entry.type === 'l') {
|
||||
$(templateLabel).appendTo($ul)
|
||||
.find('.cm-text').text(entry.text);
|
||||
|
||||
} else if (entry.type === 'e') {
|
||||
$li = $(templateEntry).appendTo($ul);
|
||||
$li.data('cm-id', entry.id);
|
||||
|
@ -62,7 +55,6 @@ modulejs.define('ext/contextmenu', ['_', '$', 'core/resource', 'core/settings'],
|
|||
}
|
||||
|
||||
function positionPanel($overlay, $panel, x, y) {
|
||||
|
||||
var margin = 4;
|
||||
|
||||
$panel.css({
|
||||
|
@ -123,7 +115,6 @@ modulejs.define('ext/contextmenu', ['_', '$', 'core/resource', 'core/settings'],
|
|||
}
|
||||
|
||||
function showMenuAt(x, y, menu, callback) {
|
||||
|
||||
var $overlay = createOverlay(callback);
|
||||
var $panel = createPanel(menu);
|
||||
$overlay.append($panel).appendTo('body');
|
||||
|
@ -131,20 +122,17 @@ modulejs.define('ext/contextmenu', ['_', '$', 'core/resource', 'core/settings'],
|
|||
}
|
||||
|
||||
function init() {
|
||||
|
||||
// settings.enabled = true;
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
$(document).on('contextmenu', function (ev) {
|
||||
|
||||
ev.stopPropagation();
|
||||
ev.preventDefault();
|
||||
$(ev.target).trigger($.Event('h5ai-contextmenu', {
|
||||
originalEvent: ev,
|
||||
showMenu: function (menu, callback) {
|
||||
|
||||
showMenuAt(ev.pageX, ev.pageY, menu, callback);
|
||||
}
|
||||
}));
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
modulejs.define('ext/crumb', ['_', '$', 'core/event', 'core/location', 'core/resource', 'core/settings', 'view/topbar'], function (_, $, event, location, resource, allsettings, topbar) {
|
||||
|
||||
var settings = _.extend({
|
||||
enabled: false
|
||||
}, allsettings.crumb);
|
||||
|
@ -13,7 +12,6 @@ modulejs.define('ext/crumb', ['_', '$', 'core/event', 'core/location', 'core/res
|
|||
|
||||
|
||||
function createHtml(item) {
|
||||
|
||||
var $html = $(crumbTemplate).data('item', item);
|
||||
item.$crumb = $html;
|
||||
location.setLink($html, item);
|
||||
|
@ -32,7 +30,6 @@ modulejs.define('ext/crumb', ['_', '$', 'core/event', 'core/location', 'core/res
|
|||
}
|
||||
|
||||
function onLocationChanged(item) {
|
||||
|
||||
var $crumb = item.$crumb;
|
||||
|
||||
if ($crumb && $crumb.parent()[0] === $crumbbar[0]) {
|
||||
|
@ -40,14 +37,13 @@ modulejs.define('ext/crumb', ['_', '$', 'core/event', 'core/location', 'core/res
|
|||
$crumb.addClass('active');
|
||||
} else {
|
||||
$crumbbar.empty();
|
||||
_.each(item.getCrumb(), function (item) {
|
||||
$crumbbar.append(createHtml(item));
|
||||
_.each(item.getCrumb(), function (crumbItem) {
|
||||
$crumbbar.append(createHtml(crumbItem));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function init() {
|
||||
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
modulejs.define('ext/custom', ['_', '$', 'marked', 'core/event', 'core/server', 'core/settings'], function (_, $, marked, event, server, allsettings) {
|
||||
|
||||
var settings = _.extend({
|
||||
enabled: false
|
||||
}, allsettings.custom);
|
||||
|
@ -9,9 +8,7 @@ modulejs.define('ext/custom', ['_', '$', 'marked', 'core/event', 'core/server',
|
|||
|
||||
|
||||
function onLocationChanged(item) {
|
||||
|
||||
server.request({action: 'get', custom: item.absHref}, function (response) {
|
||||
|
||||
var custom = response && response.custom;
|
||||
var hasHeader;
|
||||
var hasFooter;
|
||||
|
@ -50,7 +47,6 @@ modulejs.define('ext/custom', ['_', '$', 'marked', 'core/event', 'core/server',
|
|||
}
|
||||
|
||||
function init() {
|
||||
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
modulejs.define('ext/download', ['_', '$', 'core/event', 'core/location', 'core/resource', 'core/server', 'core/settings'], function (_, $, event, location, resource, server, allsettings) {
|
||||
|
||||
var settings = _.extend({
|
||||
enabled: false,
|
||||
type: 'php-tar',
|
||||
|
@ -15,7 +14,6 @@ modulejs.define('ext/download', ['_', '$', 'core/event', 'core/location', 'core/
|
|||
|
||||
|
||||
function onSelection(items) {
|
||||
|
||||
selectedItems = items.slice(0);
|
||||
if (selectedItems.length) {
|
||||
$download.show();
|
||||
|
@ -25,10 +23,9 @@ modulejs.define('ext/download', ['_', '$', 'core/event', 'core/location', 'core/
|
|||
}
|
||||
|
||||
function onClick() {
|
||||
|
||||
var type = settings.type;
|
||||
var name = settings.packageName;
|
||||
var extension = (type === 'shell-zip') ? 'zip' : 'tar';
|
||||
var extension = type === 'shell-zip' ? 'zip' : 'tar';
|
||||
|
||||
if (!name) {
|
||||
if (selectedItems.length === 1) {
|
||||
|
@ -46,7 +43,6 @@ modulejs.define('ext/download', ['_', '$', 'core/event', 'core/location', 'core/
|
|||
};
|
||||
|
||||
_.each(selectedItems, function (item, idx) {
|
||||
|
||||
query['hrefs[' + idx + ']'] = item.absHref;
|
||||
});
|
||||
|
||||
|
@ -54,7 +50,6 @@ modulejs.define('ext/download', ['_', '$', 'core/event', 'core/location', 'core/
|
|||
}
|
||||
|
||||
function init() {
|
||||
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
modulejs.define('ext/filter', ['_', '$', 'core/event', 'core/location', 'core/resource', 'core/settings', 'core/util', 'view/view'], function (_, $, event, location, resource, allsettings, util, view) {
|
||||
|
||||
var settings = _.extend({
|
||||
enabled: false,
|
||||
advanced: false,
|
||||
|
@ -17,7 +16,6 @@ modulejs.define('ext/filter', ['_', '$', 'core/event', 'core/location', 'core/re
|
|||
|
||||
|
||||
function filter(pattern) {
|
||||
|
||||
pattern = pattern || '';
|
||||
if (pattern === prevPattern) {
|
||||
return;
|
||||
|
@ -35,7 +33,6 @@ modulejs.define('ext/filter', ['_', '$', 'core/event', 'core/location', 'core/re
|
|||
var matchedItems = [];
|
||||
|
||||
_.each(location.getItem().content, function (item) {
|
||||
|
||||
if (re.test(item.label)) {
|
||||
matchedItems.push(item);
|
||||
}
|
||||
|
@ -47,7 +44,6 @@ modulejs.define('ext/filter', ['_', '$', 'core/event', 'core/location', 'core/re
|
|||
}
|
||||
|
||||
function update() {
|
||||
|
||||
if (inputIsVisible) {
|
||||
$filter.addClass('active');
|
||||
$input.focus();
|
||||
|
@ -59,20 +55,17 @@ modulejs.define('ext/filter', ['_', '$', 'core/event', 'core/location', 'core/re
|
|||
}
|
||||
|
||||
function toggle() {
|
||||
|
||||
inputIsVisible = !inputIsVisible;
|
||||
update();
|
||||
}
|
||||
|
||||
function reset() {
|
||||
|
||||
inputIsVisible = false;
|
||||
$input.val('');
|
||||
update();
|
||||
}
|
||||
|
||||
function init() {
|
||||
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,49 +1,37 @@
|
|||
modulejs.define('ext/google-analytics-ua', ['_', 'core/event', 'core/settings'], function (_, event, allsettings) {
|
||||
|
||||
var settings = _.extend({
|
||||
enabled: false,
|
||||
id: 'UA-000000-0'
|
||||
}, allsettings['google-analytics-ua']);
|
||||
var win = window;
|
||||
var doc = document;
|
||||
var scriptLiteral = 'script';
|
||||
var id = 'h5ai-ga';
|
||||
|
||||
function snippet() {
|
||||
/* eslint-disable */
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
||||
/* eslint-enable */
|
||||
}
|
||||
|
||||
function init() {
|
||||
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
var el;
|
||||
var firstScriptElement;
|
||||
snippet();
|
||||
|
||||
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');
|
||||
var WIN = window;
|
||||
var GA = 'ga';
|
||||
WIN[GA]('create', settings.id, 'auto');
|
||||
|
||||
event.sub('location.changed', function (item) {
|
||||
|
||||
var loc = win.location;
|
||||
win[id]('send', 'pageview', {
|
||||
var loc = WIN.location;
|
||||
WIN[GA]('send', 'pageview', {
|
||||
location: loc.protocol + '//' + loc.host + item.absHref,
|
||||
title: _.pluck(item.getCrumb(), 'label').join(' > ')
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
init();
|
||||
});
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
modulejs.define('ext/info', ['_', '$', 'core/event', 'core/format', 'core/modernizr', 'core/resource', 'core/settings', 'core/store'], function (_, $, event, format, modernizr, resource, allsettings, store) {
|
||||
|
||||
var settings = _.extend({
|
||||
enabled: false,
|
||||
show: false,
|
||||
|
@ -40,7 +39,6 @@ modulejs.define('ext/info', ['_', '$', 'core/event', 'core/format', 'core/modern
|
|||
|
||||
|
||||
function updateSettings() {
|
||||
|
||||
if (store.get(storekey)) {
|
||||
$('#view-info').addClass('active');
|
||||
$('#info').show();
|
||||
|
@ -51,7 +49,6 @@ modulejs.define('ext/info', ['_', '$', 'core/event', 'core/format', 'core/modern
|
|||
}
|
||||
|
||||
function update(item) {
|
||||
|
||||
var src = item.thumbRational || item.icon;
|
||||
var isThumb = Boolean(item.thumbRational);
|
||||
|
||||
|
@ -101,23 +98,19 @@ modulejs.define('ext/info', ['_', '$', 'core/event', 'core/format', 'core/modern
|
|||
}
|
||||
|
||||
function onMouseenter(item) {
|
||||
|
||||
update(item);
|
||||
}
|
||||
|
||||
function onMouseleave() {
|
||||
|
||||
update(currentFolder);
|
||||
}
|
||||
|
||||
function onLocationChanged(item) {
|
||||
|
||||
currentFolder = item;
|
||||
update(currentFolder);
|
||||
}
|
||||
|
||||
function init() {
|
||||
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
}
|
||||
|
@ -140,14 +133,13 @@ modulejs.define('ext/info', ['_', '$', 'core/event', 'core/format', 'core/modern
|
|||
.appendTo('#sidebar')
|
||||
.find('#view-info')
|
||||
.on('click', function (ev) {
|
||||
|
||||
store.put(storekey, !store.get(storekey));
|
||||
updateSettings();
|
||||
ev.preventDefault();
|
||||
});
|
||||
|
||||
// ensure stored value is boolean, otherwise set default
|
||||
if (typeof (store.get(storekey)) !== 'boolean') {
|
||||
if (typeof store.get(storekey) !== 'boolean') {
|
||||
store.put(storekey, settings.show);
|
||||
}
|
||||
updateSettings();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
modulejs.define('ext/l10n', ['_', '$', 'core/event', 'core/format', 'core/langs', 'core/server', 'core/settings', 'core/store'], function (_, $, event, format, langs, server, allsettings, store) {
|
||||
|
||||
modulejs.define('ext/l10n', ['_', '$', 'core/event', 'core/format', 'core/langs', 'core/server', 'core/settings', 'core/store'],
|
||||
function (_, $, event, format, langs, server, allsettings, store) {
|
||||
var settings = _.extend({
|
||||
enabled: false,
|
||||
lang: 'en',
|
||||
|
@ -38,7 +38,6 @@ modulejs.define('ext/l10n', ['_', '$', 'core/event', 'core/format', 'core/langs'
|
|||
|
||||
|
||||
function update(lang) {
|
||||
|
||||
if (lang) {
|
||||
currentLang = lang;
|
||||
}
|
||||
|
@ -55,7 +54,6 @@ modulejs.define('ext/l10n', ['_', '$', 'core/event', 'core/format', 'core/langs'
|
|||
format.setDefaultDateFormat(currentLang.dateFormat);
|
||||
|
||||
$('#items .item .date').each(function () {
|
||||
|
||||
var $this = $(this);
|
||||
|
||||
$this.text(format.formatDate($this.data('time')));
|
||||
|
@ -63,14 +61,10 @@ modulejs.define('ext/l10n', ['_', '$', 'core/event', 'core/format', 'core/langs'
|
|||
}
|
||||
|
||||
function loadLanguage(isoCode, callback) {
|
||||
|
||||
if (loaded[isoCode]) {
|
||||
|
||||
callback(loaded[isoCode]);
|
||||
} else {
|
||||
|
||||
server.request({action: 'get', l10n: [isoCode]}, function (response) {
|
||||
|
||||
var json = response.l10n && response.l10n[isoCode] ? response.l10n[isoCode] : {};
|
||||
loaded[isoCode] = _.extend({}, defaultTranslations, json, {isoCode: isoCode});
|
||||
callback(loaded[isoCode]);
|
||||
|
@ -78,46 +72,44 @@ modulejs.define('ext/l10n', ['_', '$', 'core/event', 'core/format', 'core/langs'
|
|||
}
|
||||
}
|
||||
|
||||
function localize(langs, isoCode, useBrowserLang) {
|
||||
|
||||
function localize(languages, isoCode, useBrowserLang) {
|
||||
var storedIsoCode = store.get(storekey);
|
||||
|
||||
if (langs[storedIsoCode]) {
|
||||
if (languages[storedIsoCode]) {
|
||||
isoCode = storedIsoCode;
|
||||
} else if (useBrowserLang) {
|
||||
var browserLang = navigator.language || navigator.browserLanguage;
|
||||
if (browserLang) {
|
||||
if (langs[browserLang]) {
|
||||
if (languages[browserLang]) {
|
||||
isoCode = browserLang;
|
||||
} else if (browserLang.length > 2 && langs[browserLang.substr(0, 2)]) {
|
||||
} else if (browserLang.length > 2 && languages[browserLang.substr(0, 2)]) {
|
||||
isoCode = browserLang.substr(0, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!langs[isoCode]) {
|
||||
if (!languages[isoCode]) {
|
||||
isoCode = 'en';
|
||||
}
|
||||
|
||||
loadLanguage(isoCode, update);
|
||||
}
|
||||
|
||||
function initLangSelector(langs) {
|
||||
|
||||
var isoCodes = _.keys(langs).sort();
|
||||
function initLangSelector(languages) {
|
||||
var isoCodes = _.keys(languages).sort();
|
||||
var $block = $(blockTemplate);
|
||||
var $select = $block.find('select')
|
||||
.on('change', function (event) {
|
||||
var isoCode = event.target.value;
|
||||
.on('change', function (ev) {
|
||||
var isoCode = ev.target.value;
|
||||
store.put(storekey, isoCode);
|
||||
localize(langs, isoCode, false);
|
||||
localize(languages, isoCode, false);
|
||||
});
|
||||
|
||||
$.each(isoCodes, function (idx, isoCode) {
|
||||
$(optionTemplate)
|
||||
.attr('value', isoCode)
|
||||
.addClass(isoCode)
|
||||
.text(isoCode + ' - ' + (_.isString(langs[isoCode]) ? langs[isoCode] : langs[isoCode].lang))
|
||||
.text(isoCode + ' - ' + (_.isString(languages[isoCode]) ? languages[isoCode] : languages[isoCode].lang))
|
||||
.appendTo($select);
|
||||
});
|
||||
|
||||
|
@ -125,13 +117,11 @@ modulejs.define('ext/l10n', ['_', '$', 'core/event', 'core/format', 'core/langs'
|
|||
}
|
||||
|
||||
function init() {
|
||||
|
||||
if (settings.enabled) {
|
||||
initLangSelector(langs);
|
||||
}
|
||||
|
||||
event.sub('view.changed', function () {
|
||||
|
||||
localize(langs, settings.lang, settings.useBrowserLang);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
modulejs.define('ext/peer5', ['_', '$', 'core/settings'], function (_, $, allsettings) {
|
||||
|
||||
var settings = _.extend({
|
||||
enabled: false,
|
||||
id: 'z142i5n5qypq4cxr'
|
||||
|
@ -7,7 +6,6 @@ modulejs.define('ext/peer5', ['_', '$', 'core/settings'], function (_, $, allset
|
|||
|
||||
|
||||
function init() {
|
||||
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
}
|
||||
|
@ -23,9 +21,7 @@ modulejs.define('ext/peer5', ['_', '$', 'core/settings'], function (_, $, allset
|
|||
|
||||
// attach to file items, once the DOM is ready
|
||||
$(function () {
|
||||
|
||||
$('body').on('click', '.item.file > a', function (ev) {
|
||||
|
||||
if (window.peer5) {
|
||||
ev.preventDefault();
|
||||
var url = ev.currentTarget.href;
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
modulejs.define('ext/piwik-analytics', ['_', '$', 'core/settings'], function (_, $, allsettings) {
|
||||
|
||||
var settings = _.extend({
|
||||
enabled: false,
|
||||
baseURL: 'not-set',
|
||||
|
@ -8,14 +7,13 @@ modulejs.define('ext/piwik-analytics', ['_', '$', 'core/settings'], function (_,
|
|||
|
||||
|
||||
function init() {
|
||||
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
// reference: http://piwik.org/docs/javascript-tracking/
|
||||
|
||||
var pkBaseURL = ((document.location.protocol === 'https:') ? 'https://' : 'http://') + settings.baseURL + '/';
|
||||
var pkBaseURL = (document.location.protocol === 'https:' ? 'https://' : 'http://') + settings.baseURL + '/';
|
||||
|
||||
$('<script/>').attr('src', pkBaseURL + 'piwik.js').appendTo('body');
|
||||
$(window).load(function () {
|
||||
|
|
|
@ -1,16 +1,12 @@
|
|||
modulejs.define('ext/preview-audio', ['_', '$', 'core/event', 'core/format', 'core/settings', 'ext/preview'], function (_, $, event, format, allsettings, preview) {
|
||||
|
||||
var settings = _.extend({
|
||||
enabled: false,
|
||||
types: []
|
||||
}, allsettings['preview-aud']);
|
||||
|
||||
|
||||
function preloadAudio(src, callback) {
|
||||
|
||||
var $audio = $('<audio/>')
|
||||
.one('loadedmetadata', function () {
|
||||
|
||||
callback($audio);
|
||||
// setTimeout(function () { callback($img); }, 1000); // for testing
|
||||
})
|
||||
|
@ -20,18 +16,15 @@ modulejs.define('ext/preview-audio', ['_', '$', 'core/event', 'core/format', 'co
|
|||
}
|
||||
|
||||
function onEnter(items, idx) {
|
||||
|
||||
var currentItems = items;
|
||||
var currentIdx = idx;
|
||||
var currentItem = items[idx];
|
||||
|
||||
function onAdjustSize() {
|
||||
|
||||
var $content = $('#pv-content');
|
||||
var $audio = $('#pv-aud-audio');
|
||||
|
||||
if ($audio.length) {
|
||||
|
||||
$audio.css({
|
||||
left: String(($content.width() - $audio.width()) * 0.5) + 'px',
|
||||
top: String(($content.height() - $audio.height()) * 0.5) + 'px'
|
||||
|
@ -45,7 +38,6 @@ modulejs.define('ext/preview-audio', ['_', '$', 'core/event', 'core/format', 'co
|
|||
}
|
||||
|
||||
function onIdxChange(rel) {
|
||||
|
||||
currentIdx = (currentIdx + rel + currentItems.length) % currentItems.length;
|
||||
currentItem = currentItems[currentIdx];
|
||||
|
||||
|
@ -54,26 +46,31 @@ modulejs.define('ext/preview-audio', ['_', '$', 'core/event', 'core/format', 'co
|
|||
if ($('#pv-aud-audio').length) {
|
||||
$('#pv-aud-audio')[0].pause();
|
||||
}
|
||||
preloadAudio(currentItem.absHref, function ($preloadedAudio) {
|
||||
|
||||
function updateMeta() {
|
||||
onAdjustSize();
|
||||
preview.setIndex(currentIdx + 1, currentItems.length);
|
||||
preview.setRawLink(currentItem.absHref);
|
||||
}
|
||||
|
||||
function swap(nuContent) {
|
||||
$('#pv-content').empty().append(nuContent.attr('id', 'pv-vid-audio')).fadeIn(200);
|
||||
// small timeout, so nuContent is visible and therefore its width is available
|
||||
setTimeout(updateMeta, 10);
|
||||
}
|
||||
|
||||
function onReady($preloadedContent) {
|
||||
clearTimeout(spinnerTimeout);
|
||||
preview.showSpinner(false);
|
||||
|
||||
$('#pv-content').fadeOut(100, function () {
|
||||
|
||||
$('#pv-content').empty().append($preloadedAudio.attr('id', 'pv-aud-audio')).fadeIn(200);
|
||||
|
||||
// small timeout, so $preloadedAudio is visible and therefore $preloadedAudio.width is available
|
||||
setTimeout(function () {
|
||||
onAdjustSize();
|
||||
|
||||
preview.setIndex(currentIdx + 1, currentItems.length);
|
||||
preview.setRawLink(currentItem.absHref);
|
||||
}, 10);
|
||||
});
|
||||
swap($preloadedContent);
|
||||
});
|
||||
}
|
||||
|
||||
preloadAudio(currentItem.absHref, onReady);
|
||||
}
|
||||
|
||||
onIdxChange(0);
|
||||
preview.setOnIndexChange(onIdxChange);
|
||||
preview.setOnAdjustSize(onAdjustSize);
|
||||
|
@ -81,30 +78,25 @@ modulejs.define('ext/preview-audio', ['_', '$', 'core/event', 'core/format', 'co
|
|||
}
|
||||
|
||||
function initItem(item) {
|
||||
|
||||
if (item.$view && _.indexOf(settings.types, item.type) >= 0) {
|
||||
item.$view.find('a').on('click', function (event) {
|
||||
item.$view.find('a').on('click', function (ev) {
|
||||
ev.preventDefault();
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
var matchedEntries = _.compact(_.map($('#items .item'), function (item) {
|
||||
|
||||
item = $(item).data('item');
|
||||
return _.indexOf(settings.types, item.type) >= 0 ? item : null;
|
||||
var matchedItems = _.compact(_.map($('#items .item'), function (matchedItem) {
|
||||
matchedItem = $(matchedItem).data('item');
|
||||
return _.indexOf(settings.types, matchedItem.type) >= 0 ? matchedItem : null;
|
||||
}));
|
||||
|
||||
onEnter(matchedEntries, _.indexOf(matchedEntries, item));
|
||||
onEnter(matchedItems, _.indexOf(matchedItems, item));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function onViewChanged(added) {
|
||||
|
||||
_.each(added, initItem);
|
||||
}
|
||||
|
||||
function init() {
|
||||
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
}
|
||||
|
@ -112,6 +104,5 @@ modulejs.define('ext/preview-audio', ['_', '$', 'core/event', 'core/format', 'co
|
|||
event.sub('view.changed', onViewChanged);
|
||||
}
|
||||
|
||||
|
||||
init();
|
||||
});
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
modulejs.define('ext/preview-img', ['_', '$', 'core/event', 'core/server', 'core/settings', 'ext/preview'], function (_, $, event, server, allsettings, preview) {
|
||||
|
||||
var settings = _.extend({
|
||||
enabled: false,
|
||||
size: null,
|
||||
|
@ -13,7 +12,6 @@ modulejs.define('ext/preview-img', ['_', '$', 'core/event', 'core/server', 'core
|
|||
|
||||
|
||||
function requestSample(href, callback) {
|
||||
|
||||
if (!settings.size) {
|
||||
callback(href);
|
||||
return;
|
||||
|
@ -28,18 +26,14 @@ modulejs.define('ext/preview-img', ['_', '$', 'core/event', 'core/server', 'core
|
|||
height: 0
|
||||
}]
|
||||
}, function (json) {
|
||||
|
||||
callback(json && json.thumbs && json.thumbs[0] ? json.thumbs[0] : null);
|
||||
});
|
||||
}
|
||||
|
||||
function preloadImage(item, callback) {
|
||||
|
||||
requestSample(item.absHref, function (src) {
|
||||
|
||||
$('<img/>')
|
||||
.one('load', function (ev) {
|
||||
|
||||
callback(item, ev.target);
|
||||
|
||||
// for testing
|
||||
|
@ -50,7 +44,6 @@ modulejs.define('ext/preview-img', ['_', '$', 'core/event', 'core/server', 'core
|
|||
}
|
||||
|
||||
function onAdjustSize() {
|
||||
|
||||
var $content = $('#pv-content');
|
||||
var $img = $('#pv-img-image');
|
||||
|
||||
|
@ -72,7 +65,6 @@ modulejs.define('ext/preview-img', ['_', '$', 'core/event', 'core/server', 'core
|
|||
}
|
||||
|
||||
function onIdxChange(rel) {
|
||||
|
||||
currentIdx = (currentIdx + rel + currentItems.length) % currentItems.length;
|
||||
currentItem = currentItems[currentIdx];
|
||||
|
||||
|
@ -86,13 +78,11 @@ modulejs.define('ext/preview-img', ['_', '$', 'core/event', 'core/server', 'core
|
|||
} else {
|
||||
clearTimeout(spinnerTimeoutId);
|
||||
spinnerTimeoutId = setTimeout(function () {
|
||||
|
||||
preview.showSpinner(true, currentItem.thumbSquare);
|
||||
}, spinnerThreshold);
|
||||
}
|
||||
|
||||
preloadImage(currentItem, function (item, preloadedImage) {
|
||||
|
||||
if (item !== currentItem) {
|
||||
return;
|
||||
}
|
||||
|
@ -108,7 +98,6 @@ modulejs.define('ext/preview-img', ['_', '$', 'core/event', 'core/server', 'core
|
|||
}
|
||||
|
||||
function onEnter(items, idx) {
|
||||
|
||||
currentItems = items;
|
||||
currentIdx = idx;
|
||||
preview.setOnIndexChange(onIdxChange);
|
||||
|
@ -118,30 +107,25 @@ modulejs.define('ext/preview-img', ['_', '$', 'core/event', 'core/server', 'core
|
|||
}
|
||||
|
||||
function initItem(item) {
|
||||
|
||||
if (item.$view && _.indexOf(settings.types, item.type) >= 0) {
|
||||
item.$view.find('a').on('click', function (ev) {
|
||||
|
||||
ev.preventDefault();
|
||||
|
||||
var matchedEntries = _.compact(_.map($('#items .item'), function (item) {
|
||||
|
||||
item = $(item).data('item');
|
||||
return _.indexOf(settings.types, item.type) >= 0 ? item : null;
|
||||
var matchedItems = _.compact(_.map($('#items .item'), function (matchedItem) {
|
||||
matchedItem = $(matchedItem).data('item');
|
||||
return _.indexOf(settings.types, matchedItem.type) >= 0 ? matchedItem : null;
|
||||
}));
|
||||
|
||||
onEnter(matchedEntries, _.indexOf(matchedEntries, item));
|
||||
onEnter(matchedItems, _.indexOf(matchedItems, item));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function onViewChanged(added) {
|
||||
|
||||
_.each(added, initItem);
|
||||
}
|
||||
|
||||
function init() {
|
||||
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
modulejs.define('ext/preview-txt', ['_', '$', 'marked', 'prism', 'core/event', 'core/settings', 'ext/preview'], function (_, $, marked, prism, event, allsettings, preview) {
|
||||
|
||||
var settings = _.extend({
|
||||
enabled: false,
|
||||
types: {}
|
||||
|
@ -14,26 +13,22 @@ modulejs.define('ext/preview-txt', ['_', '$', 'marked', 'prism', 'core/event', '
|
|||
|
||||
|
||||
function preloadText(item, callback) {
|
||||
|
||||
$.ajax({
|
||||
url: item.absHref,
|
||||
dataType: 'text'
|
||||
})
|
||||
.done(function (content) {
|
||||
|
||||
callback(item, content);
|
||||
|
||||
// for testing
|
||||
// setTimeout(function () { callback(item, content); }, 1000);
|
||||
})
|
||||
.fail(function (jqXHR, textStatus) {
|
||||
|
||||
callback(item, '[ajax error] ' + textStatus);
|
||||
});
|
||||
}
|
||||
|
||||
function onAdjustSize() {
|
||||
|
||||
var $content = $('#pv-content');
|
||||
var $text = $('#pv-txt-text');
|
||||
|
||||
|
@ -43,7 +38,6 @@ modulejs.define('ext/preview-txt', ['_', '$', 'marked', 'prism', 'core/event', '
|
|||
}
|
||||
|
||||
function onIdxChange(rel) {
|
||||
|
||||
currentIdx = (currentIdx + rel + currentItems.length) % currentItems.length;
|
||||
currentItem = currentItems[currentIdx];
|
||||
|
||||
|
@ -60,13 +54,11 @@ modulejs.define('ext/preview-txt', ['_', '$', 'marked', 'prism', 'core/event', '
|
|||
} else {
|
||||
clearTimeout(spinnerTimeoutId);
|
||||
spinnerTimeoutId = setTimeout(function () {
|
||||
|
||||
preview.showSpinner(true, currentItem.icon);
|
||||
}, spinnerThreshold);
|
||||
}
|
||||
|
||||
preloadText(currentItem, function (item, textContent) {
|
||||
|
||||
if (item !== currentItem) {
|
||||
return;
|
||||
}
|
||||
|
@ -104,7 +96,6 @@ modulejs.define('ext/preview-txt', ['_', '$', 'marked', 'prism', 'core/event', '
|
|||
}
|
||||
|
||||
function onEnter(items, idx) {
|
||||
|
||||
currentItems = items;
|
||||
currentIdx = idx;
|
||||
currentItem = items[idx];
|
||||
|
@ -115,30 +106,25 @@ modulejs.define('ext/preview-txt', ['_', '$', 'marked', 'prism', 'core/event', '
|
|||
}
|
||||
|
||||
function initItem(item) {
|
||||
|
||||
if (item.$view && _.indexOf(_.keys(settings.types), item.type) >= 0) {
|
||||
item.$view.find('a').on('click', function (event) {
|
||||
item.$view.find('a').on('click', function (ev) {
|
||||
ev.preventDefault();
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
var matchedEntries = _.compact(_.map($('#items .item'), function (item) {
|
||||
|
||||
item = $(item).data('item');
|
||||
return _.indexOf(_.keys(settings.types), item.type) >= 0 ? item : null;
|
||||
var matchedItems = _.compact(_.map($('#items .item'), function (matchedItem) {
|
||||
matchedItem = $(matchedItem).data('item');
|
||||
return _.indexOf(_.keys(settings.types), matchedItem.type) >= 0 ? matchedItem : null;
|
||||
}));
|
||||
|
||||
onEnter(matchedEntries, _.indexOf(matchedEntries, item));
|
||||
onEnter(matchedItems, _.indexOf(matchedItems, item));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function onViewChanged(added) {
|
||||
|
||||
_.each(added, initItem);
|
||||
}
|
||||
|
||||
function init() {
|
||||
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,16 +1,12 @@
|
|||
modulejs.define('ext/preview-vid', ['_', '$', 'core/event', 'core/settings', 'ext/preview'], function (_, $, event, allsettings, preview) {
|
||||
|
||||
var settings = _.extend({
|
||||
enabled: false,
|
||||
types: []
|
||||
}, allsettings['preview-vid']);
|
||||
|
||||
|
||||
function preloadVideo(src, callback) {
|
||||
|
||||
var $video = $('<video/>')
|
||||
.one('loadedmetadata', function () {
|
||||
|
||||
callback($video);
|
||||
// setTimeout(function () { callback($video); }, 1000); // for testing
|
||||
})
|
||||
|
@ -20,18 +16,15 @@ modulejs.define('ext/preview-vid', ['_', '$', 'core/event', 'core/settings', 'ex
|
|||
}
|
||||
|
||||
function onEnter(items, idx) {
|
||||
|
||||
var currentItems = items;
|
||||
var currentIdx = idx;
|
||||
var currentItem = items[idx];
|
||||
|
||||
function onAdjustSize() {
|
||||
|
||||
var $content = $('#pv-content');
|
||||
var $vid = $('#pv-vid-video');
|
||||
|
||||
if ($vid.length) {
|
||||
|
||||
$vid.css({
|
||||
left: String(($content.width() - $vid.width()) * 0.5) + 'px',
|
||||
top: String(($content.height() - $vid.height()) * 0.5) + 'px'
|
||||
|
@ -46,7 +39,6 @@ modulejs.define('ext/preview-vid', ['_', '$', 'core/event', 'core/settings', 'ex
|
|||
}
|
||||
|
||||
function onIdxChange(rel) {
|
||||
|
||||
currentIdx = (currentIdx + rel + currentItems.length) % currentItems.length;
|
||||
currentItem = currentItems[currentIdx];
|
||||
|
||||
|
@ -55,26 +47,31 @@ modulejs.define('ext/preview-vid', ['_', '$', 'core/event', 'core/settings', 'ex
|
|||
if ($('#pv-vid-video').length) {
|
||||
$('#pv-vid-video')[0].pause();
|
||||
}
|
||||
preloadVideo(currentItem.absHref, function ($preloadedVideo) {
|
||||
|
||||
function updateMeta() {
|
||||
onAdjustSize();
|
||||
preview.setIndex(currentIdx + 1, currentItems.length);
|
||||
preview.setRawLink(currentItem.absHref);
|
||||
}
|
||||
|
||||
function swap(nuContent) {
|
||||
$('#pv-content').empty().append(nuContent.attr('id', 'pv-vid-video')).fadeIn(200);
|
||||
// small timeout, so nuContent is visible and therefore its width is available
|
||||
setTimeout(updateMeta, 10);
|
||||
}
|
||||
|
||||
function onReady($preloadedContent) {
|
||||
clearTimeout(spinnerTimeout);
|
||||
preview.showSpinner(false);
|
||||
|
||||
$('#pv-content').fadeOut(100, function () {
|
||||
|
||||
$('#pv-content').empty().append($preloadedVideo.attr('id', 'pv-vid-video')).fadeIn(200);
|
||||
|
||||
// small timeout, so $preloadedVideo is visible and therefore $preloadedVideo.width is available
|
||||
setTimeout(function () {
|
||||
onAdjustSize();
|
||||
|
||||
preview.setIndex(currentIdx + 1, currentItems.length);
|
||||
preview.setRawLink(currentItem.absHref);
|
||||
}, 10);
|
||||
});
|
||||
swap($preloadedContent);
|
||||
});
|
||||
}
|
||||
|
||||
preloadVideo(currentItem.absHref, onReady);
|
||||
}
|
||||
|
||||
onIdxChange(0);
|
||||
preview.setOnIndexChange(onIdxChange);
|
||||
preview.setOnAdjustSize(onAdjustSize);
|
||||
|
@ -82,30 +79,25 @@ modulejs.define('ext/preview-vid', ['_', '$', 'core/event', 'core/settings', 'ex
|
|||
}
|
||||
|
||||
function initItem(item) {
|
||||
|
||||
if (item.$view && _.indexOf(settings.types, item.type) >= 0) {
|
||||
item.$view.find('a').on('click', function (event) {
|
||||
item.$view.find('a').on('click', function (ev) {
|
||||
ev.preventDefault();
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
var matchedEntries = _.compact(_.map($('#items .item'), function (item) {
|
||||
|
||||
item = $(item).data('item');
|
||||
return _.indexOf(settings.types, item.type) >= 0 ? item : null;
|
||||
var matchedItems = _.compact(_.map($('#items .item'), function (matchedItem) {
|
||||
matchedItem = $(matchedItem).data('item');
|
||||
return _.indexOf(settings.types, matchedItem.type) >= 0 ? matchedItem : null;
|
||||
}));
|
||||
|
||||
onEnter(matchedEntries, _.indexOf(matchedEntries, item));
|
||||
onEnter(matchedItems, _.indexOf(matchedItems, item));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function onViewChanged(added) {
|
||||
|
||||
_.each(added, initItem);
|
||||
}
|
||||
|
||||
function init() {
|
||||
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
}
|
||||
|
@ -113,6 +105,5 @@ modulejs.define('ext/preview-vid', ['_', '$', 'core/event', 'core/settings', 'ex
|
|||
event.sub('view.changed', onViewChanged);
|
||||
}
|
||||
|
||||
|
||||
init();
|
||||
});
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
modulejs.define('ext/preview', ['_', '$', 'core/resource', 'core/settings', 'core/store'], function (_, $, resource, allsettings, store) {
|
||||
|
||||
var settings = _.extend({
|
||||
enabled: true
|
||||
}, allsettings.preview);
|
||||
|
@ -30,7 +29,6 @@ modulejs.define('ext/preview', ['_', '$', 'core/resource', 'core/settings', 'cor
|
|||
|
||||
|
||||
function adjustSize() {
|
||||
|
||||
var winWidth = $window.width();
|
||||
var winHeight = $window.height();
|
||||
var $container = $('#pv-content');
|
||||
|
@ -63,53 +61,40 @@ modulejs.define('ext/preview', ['_', '$', 'core/resource', 'core/settings', 'cor
|
|||
}
|
||||
}
|
||||
|
||||
function onEnter() {
|
||||
|
||||
setLabels([]);
|
||||
$('#pv-content').empty();
|
||||
$('#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([]);
|
||||
function setLabels(labels) {
|
||||
$('#pv-buttons .bar-left').remove();
|
||||
_.each(labels, function (label) {
|
||||
$('<li/>')
|
||||
.addClass('bar-left bar-label')
|
||||
.text(label)
|
||||
.appendTo('#pv-buttons');
|
||||
});
|
||||
}
|
||||
|
||||
function onNext() {
|
||||
|
||||
if (_.isFunction(onIndexChange)) {
|
||||
onIndexChange(1);
|
||||
}
|
||||
}
|
||||
|
||||
function onPrevious() {
|
||||
|
||||
if (_.isFunction(onIndexChange)) {
|
||||
onIndexChange(-1);
|
||||
}
|
||||
}
|
||||
|
||||
function userAlive() {
|
||||
|
||||
clearTimeout(userAliveTimeoutId);
|
||||
$('#pv-overlay .hof').stop(true, true).fadeIn(200);
|
||||
|
||||
if (isFullscreen) {
|
||||
userAliveTimeoutId = setTimeout(function () {
|
||||
|
||||
$('#pv-overlay .hof').stop(true, true).fadeOut(2000);
|
||||
}, 2000);
|
||||
}
|
||||
}
|
||||
|
||||
function onFullscreen() {
|
||||
|
||||
isFullscreen = !isFullscreen;
|
||||
store.put(storekey, isFullscreen);
|
||||
|
||||
|
@ -118,7 +103,6 @@ modulejs.define('ext/preview', ['_', '$', 'core/resource', 'core/settings', 'cor
|
|||
}
|
||||
|
||||
function onKeydown(ev) {
|
||||
|
||||
var key = ev.which;
|
||||
|
||||
if (key === 27) { // esc
|
||||
|
@ -140,8 +124,23 @@ modulejs.define('ext/preview', ['_', '$', 'core/resource', 'core/settings', 'cor
|
|||
}
|
||||
}
|
||||
|
||||
function setIndex(idx, total) {
|
||||
function onEnter() {
|
||||
setLabels([]);
|
||||
$('#pv-content').empty();
|
||||
$('#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([]);
|
||||
});
|
||||
}
|
||||
|
||||
function setIndex(idx, total) {
|
||||
if (_.isNumber(idx)) {
|
||||
$('#pv-bar-idx').text(String(idx) + (_.isNumber(total) ? '/' + String(total) : '')).show();
|
||||
} else {
|
||||
|
@ -150,7 +149,6 @@ modulejs.define('ext/preview', ['_', '$', 'core/resource', 'core/settings', 'cor
|
|||
}
|
||||
|
||||
function setRawLink(href) {
|
||||
|
||||
if (href) {
|
||||
$('#pv-bar-raw').show().find('a').attr('href', href);
|
||||
} else {
|
||||
|
@ -158,30 +156,15 @@ modulejs.define('ext/preview', ['_', '$', 'core/resource', 'core/settings', 'cor
|
|||
}
|
||||
}
|
||||
|
||||
function setLabels(labels) {
|
||||
|
||||
$('#pv-buttons .bar-left').remove();
|
||||
_.each(labels, function (label) {
|
||||
|
||||
$('<li/>')
|
||||
.addClass('bar-left bar-label')
|
||||
.text(label)
|
||||
.appendTo('#pv-buttons');
|
||||
});
|
||||
}
|
||||
|
||||
function setOnIndexChange(fn) {
|
||||
|
||||
onIndexChange = fn;
|
||||
}
|
||||
|
||||
function setOnAdjustSize(fn) {
|
||||
|
||||
onAdjustSize = fn;
|
||||
}
|
||||
|
||||
function showSpinner(show, src, millis) {
|
||||
|
||||
if (!_.isNumber(millis)) {
|
||||
millis = 300;
|
||||
}
|
||||
|
@ -204,12 +187,10 @@ modulejs.define('ext/preview', ['_', '$', 'core/resource', 'core/settings', 'cor
|
|||
}
|
||||
|
||||
function isSpinnerVisible() {
|
||||
|
||||
return spinnerVisible;
|
||||
}
|
||||
|
||||
function init() {
|
||||
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
}
|
||||
|
@ -226,7 +207,6 @@ modulejs.define('ext/preview', ['_', '$', 'core/resource', 'core/settings', 'cor
|
|||
.on('keydown', onKeydown)
|
||||
.on('mousemove mousedown', userAlive)
|
||||
.on('click mousedown mousemove keydown keypress', function (ev) {
|
||||
|
||||
if (ev.type === 'click' && (ev.target.id === 'pv-overlay' || ev.target.id === 'pv-content')) {
|
||||
onExit();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
modulejs.define('ext/search', ['_', '$', 'core/event', 'core/location', 'core/resource', 'core/server', 'core/settings', 'core/util', 'model/item', 'view/view'], function (_, $, event, location, resource, server, allsettings, util, Item, view) {
|
||||
|
||||
var settings = _.extend({
|
||||
enabled: false,
|
||||
advanced: false,
|
||||
|
@ -17,7 +16,6 @@ modulejs.define('ext/search', ['_', '$', 'core/event', 'core/location', 'core/re
|
|||
|
||||
|
||||
function search(pattern) {
|
||||
|
||||
pattern = pattern || '';
|
||||
if (pattern === prevPattern) {
|
||||
return;
|
||||
|
@ -38,18 +36,15 @@ modulejs.define('ext/search', ['_', '$', 'core/event', 'core/location', 'core/re
|
|||
pattern: pattern
|
||||
}
|
||||
}, function (response) {
|
||||
|
||||
$search.removeClass('pending');
|
||||
view.setHint('noMatch');
|
||||
view.setItems(_.map(response.search, function (item) {
|
||||
|
||||
return Item.get(item);
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
if (inputIsVisible) {
|
||||
$search.addClass('active');
|
||||
$input.focus();
|
||||
|
@ -61,20 +56,17 @@ modulejs.define('ext/search', ['_', '$', 'core/event', 'core/location', 'core/re
|
|||
}
|
||||
|
||||
function toggle() {
|
||||
|
||||
inputIsVisible = !inputIsVisible;
|
||||
update();
|
||||
}
|
||||
|
||||
function reset() {
|
||||
|
||||
inputIsVisible = false;
|
||||
$input.val('');
|
||||
update();
|
||||
}
|
||||
|
||||
function init() {
|
||||
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
modulejs.define('ext/select', ['_', '$', 'core/event', 'core/resource', 'core/settings'], function (_, $, event, resource, allsettings) {
|
||||
|
||||
var settings = _.extend({
|
||||
enabled: false,
|
||||
clickndrag: false,
|
||||
|
@ -21,30 +20,26 @@ modulejs.define('ext/select', ['_', '$', 'core/event', 'core/resource', 'core/se
|
|||
|
||||
|
||||
function publish() {
|
||||
|
||||
var items = _.map($('#items .item.selected'), function (itemElement) {
|
||||
|
||||
return $(itemElement).data('item');
|
||||
});
|
||||
event.pub('selection', items);
|
||||
}
|
||||
|
||||
function elementRect($element) {
|
||||
|
||||
if (!$element.is(':visible')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var offset = $element.offset();
|
||||
var l = offset.left;
|
||||
var t = offset.top;
|
||||
var w = $element.outerWidth();
|
||||
var h = $element.outerHeight();
|
||||
return {l: l, t: t, w: w, h: h, r: l + w, b: t + h};
|
||||
var elL = offset.left;
|
||||
var elT = offset.top;
|
||||
var elW = $element.outerWidth();
|
||||
var elH = $element.outerHeight();
|
||||
return {l: elL, t: elT, w: elW, h: elH, r: elL + elW, b: elT + elH};
|
||||
}
|
||||
|
||||
function doOverlap(rect1, rect2) {
|
||||
|
||||
if (!rect1 || !rect2) {
|
||||
return false;
|
||||
}
|
||||
|
@ -56,11 +51,10 @@ modulejs.define('ext/select', ['_', '$', 'core/event', 'core/resource', 'core/se
|
|||
var width = right - left;
|
||||
var height = bottom - top;
|
||||
|
||||
return (width >= 0 && height >= 0);
|
||||
return width >= 0 && height >= 0;
|
||||
}
|
||||
|
||||
function selectionUpdate(ev) {
|
||||
|
||||
l = Math.min(x, ev.pageX);
|
||||
t = Math.min(y, ev.pageY);
|
||||
w = Math.abs(x - ev.pageX);
|
||||
|
@ -86,7 +80,6 @@ modulejs.define('ext/select', ['_', '$', 'core/event', 'core/resource', 'core/se
|
|||
|
||||
var selRect = elementRect($selectionRect);
|
||||
$('#items .item').removeClass('selecting').each(function () {
|
||||
|
||||
var $item = $(this);
|
||||
var inter = doOverlap(selRect, elementRect($item.find('a')));
|
||||
|
||||
|
@ -97,7 +90,6 @@ modulejs.define('ext/select', ['_', '$', 'core/event', 'core/resource', 'core/se
|
|||
}
|
||||
|
||||
function selectionEnd(ev) {
|
||||
|
||||
$document.off('mousemove', selectionUpdate);
|
||||
|
||||
if (!isDragSelect) {
|
||||
|
@ -112,8 +104,7 @@ modulejs.define('ext/select', ['_', '$', 'core/event', 'core/resource', 'core/se
|
|||
$html.removeClass('drag-select');
|
||||
$selectionRect
|
||||
.stop(true, true)
|
||||
.animate(
|
||||
{
|
||||
.animate({
|
||||
left: l + w * 0.5 * shrink,
|
||||
top: t + h * 0.5 * shrink,
|
||||
width: w * (1 - shrink),
|
||||
|
@ -123,12 +114,10 @@ modulejs.define('ext/select', ['_', '$', 'core/event', 'core/resource', 'core/se
|
|||
300,
|
||||
function () {
|
||||
$selectionRect.hide();
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
function selectionStart(ev) {
|
||||
|
||||
// only on left button and don't block scrollbar
|
||||
if (ev.button !== 0 || ev.offsetX >= $('#content').width() - 14) {
|
||||
return;
|
||||
|
@ -145,7 +134,6 @@ modulejs.define('ext/select', ['_', '$', 'core/event', 'core/resource', 'core/se
|
|||
}
|
||||
|
||||
function onSelectorClick(ev) {
|
||||
|
||||
ev.stopImmediatePropagation();
|
||||
ev.preventDefault();
|
||||
|
||||
|
@ -154,7 +142,6 @@ modulejs.define('ext/select', ['_', '$', 'core/event', 'core/resource', 'core/se
|
|||
}
|
||||
|
||||
function addCheckbox(item) {
|
||||
|
||||
if (item.$view && !item.isCurrentParentFolder()) {
|
||||
$(template)
|
||||
.on('click', onSelectorClick)
|
||||
|
@ -163,13 +150,11 @@ modulejs.define('ext/select', ['_', '$', 'core/event', 'core/resource', 'core/se
|
|||
}
|
||||
|
||||
function onViewChanged(added, removed) {
|
||||
|
||||
if (settings.checkboxes) {
|
||||
_.each(added, addCheckbox);
|
||||
}
|
||||
|
||||
_.each(removed, function (item) {
|
||||
|
||||
if (item.$view) {
|
||||
item.$view.removeClass('selected');
|
||||
}
|
||||
|
@ -179,8 +164,7 @@ modulejs.define('ext/select', ['_', '$', 'core/event', 'core/resource', 'core/se
|
|||
}
|
||||
|
||||
function init() {
|
||||
|
||||
if (!settings.enabled || (!settings.clickndrag && !settings.checkboxes)) {
|
||||
if (!settings.enabled || !settings.clickndrag && !settings.checkboxes) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -192,12 +176,10 @@ modulejs.define('ext/select', ['_', '$', 'core/event', 'core/resource', 'core/se
|
|||
$('#content')
|
||||
.on('mousedown', selectionStart)
|
||||
.on('drag dragstart', function (ev) {
|
||||
|
||||
ev.stopImmediatePropagation();
|
||||
ev.preventDefault();
|
||||
})
|
||||
.on('click', function () {
|
||||
|
||||
$('#items .item').removeClass('selected');
|
||||
publish();
|
||||
});
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
modulejs.define('ext/sort', ['_', '$', 'core/event', 'core/resource', 'core/settings', 'core/store', 'core/util'], function (_, $, event, resource, allsettings, store, util) {
|
||||
|
||||
var settings = _.extend({
|
||||
enabled: false,
|
||||
column: 0,
|
||||
|
@ -13,7 +12,6 @@ modulejs.define('ext/sort', ['_', '$', 'core/event', 'core/resource', 'core/sett
|
|||
|
||||
|
||||
function getType(item) {
|
||||
|
||||
var $item = $(item);
|
||||
|
||||
if ($item.hasClass('folder-parent')) {
|
||||
|
@ -31,17 +29,14 @@ modulejs.define('ext/sort', ['_', '$', 'core/event', 'core/resource', 'core/sett
|
|||
}
|
||||
|
||||
function getName(item) {
|
||||
|
||||
return $(item).find('.label').text();
|
||||
}
|
||||
|
||||
function getTime(item) {
|
||||
|
||||
return $(item).find('.date').data('time');
|
||||
}
|
||||
|
||||
function getSize(item) {
|
||||
|
||||
return $(item).find('.size').data('bytes');
|
||||
}
|
||||
|
||||
|
@ -59,9 +54,7 @@ modulejs.define('ext/sort', ['_', '$', 'core/event', 'core/resource', 'core/sett
|
|||
|
||||
|
||||
function cmpFn(getValue, reverse, ignorecase, natural) {
|
||||
|
||||
return function (item1, item2) {
|
||||
|
||||
var res;
|
||||
var val1;
|
||||
var val2;
|
||||
|
@ -90,7 +83,6 @@ modulejs.define('ext/sort', ['_', '$', 'core/event', 'core/resource', 'core/sett
|
|||
}
|
||||
|
||||
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);
|
||||
|
@ -111,7 +103,6 @@ modulejs.define('ext/sort', ['_', '$', 'core/event', 'core/resource', 'core/sett
|
|||
}
|
||||
|
||||
function onContentChanged() {
|
||||
|
||||
var order = store.get(storekey);
|
||||
var column = order && order.column || settings.column;
|
||||
var reverse = order && order.reverse || settings.reverse;
|
||||
|
@ -120,7 +111,6 @@ modulejs.define('ext/sort', ['_', '$', 'core/event', 'core/resource', 'core/sett
|
|||
}
|
||||
|
||||
function init() {
|
||||
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
modulejs.define('ext/thumbnails', ['_', 'core/event', 'core/server', 'core/settings'], function (_, event, server, allsettings) {
|
||||
|
||||
var settings = _.extend({
|
||||
enabled: false,
|
||||
img: ['img-bmp', 'img-gif', 'img-ico', 'img-jpg', 'img-png'],
|
||||
|
@ -13,7 +12,6 @@ modulejs.define('ext/thumbnails', ['_', 'core/event', 'core/server', 'core/setti
|
|||
|
||||
|
||||
function queueItem(queue, item) {
|
||||
|
||||
var type = null;
|
||||
|
||||
if (_.contains(settings.img, item.type)) {
|
||||
|
@ -34,7 +32,6 @@ modulejs.define('ext/thumbnails', ['_', 'core/event', 'core/server', 'core/setti
|
|||
href: item.absHref,
|
||||
ratio: 1,
|
||||
callback: function (src) {
|
||||
|
||||
if (src && item.$view) {
|
||||
item.thumbSquare = src;
|
||||
item.$view.find('.icon.square img').addClass('thumb').attr('src', src);
|
||||
|
@ -51,7 +48,6 @@ modulejs.define('ext/thumbnails', ['_', 'core/event', 'core/server', 'core/setti
|
|||
href: item.absHref,
|
||||
ratio: landscapeRatio,
|
||||
callback: function (src) {
|
||||
|
||||
if (src && item.$view) {
|
||||
item.thumbRational = src;
|
||||
item.$view.find('.icon.landscape img').addClass('thumb').attr('src', src);
|
||||
|
@ -62,9 +58,7 @@ modulejs.define('ext/thumbnails', ['_', 'core/event', 'core/server', 'core/setti
|
|||
}
|
||||
|
||||
function requestQueue(queue) {
|
||||
|
||||
var thumbs = _.map(queue, function (req) {
|
||||
|
||||
return {
|
||||
type: req.type,
|
||||
href: req.href,
|
||||
|
@ -77,20 +71,16 @@ modulejs.define('ext/thumbnails', ['_', 'core/event', 'core/server', 'core/setti
|
|||
action: 'get',
|
||||
thumbs: thumbs
|
||||
}, function (json) {
|
||||
|
||||
_.each(queue, function (req, idx) {
|
||||
|
||||
req.callback(json && json.thumbs ? json.thumbs[idx] : null);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function handleItems(items) {
|
||||
|
||||
var queue = [];
|
||||
|
||||
_.each(items, function (item) {
|
||||
|
||||
queueItem(queue, item);
|
||||
});
|
||||
|
||||
|
@ -100,15 +90,12 @@ modulejs.define('ext/thumbnails', ['_', 'core/event', 'core/server', 'core/setti
|
|||
}
|
||||
|
||||
function onViewChanged(added) {
|
||||
|
||||
setTimeout(function () {
|
||||
|
||||
handleItems(added);
|
||||
}, settings.delay);
|
||||
}
|
||||
|
||||
function init() {
|
||||
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
modulejs.define('ext/title', ['_', 'core/event', 'core/settings'], function (_, event, allsettings) {
|
||||
|
||||
var settings = _.extend({
|
||||
enabled: false
|
||||
}, allsettings.title);
|
||||
|
||||
function onLocationChanged(item) {
|
||||
|
||||
var labels = _.pluck(item.getCrumb(), 'label');
|
||||
var title = labels.join(' > ');
|
||||
|
||||
|
@ -17,7 +15,6 @@ modulejs.define('ext/title', ['_', 'core/event', 'core/settings'], function (_,
|
|||
}
|
||||
|
||||
function init() {
|
||||
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
modulejs.define('ext/tree', ['_', '$', 'core/event', 'core/location', 'core/resource', 'core/settings', 'core/store', 'core/util'], function (_, $, event, location, resource, allsettings, store, util) {
|
||||
|
||||
var settings = _.extend({
|
||||
enabled: false,
|
||||
show: true,
|
||||
|
@ -28,7 +27,6 @@ modulejs.define('ext/tree', ['_', '$', 'core/event', 'core/location', 'core/reso
|
|||
|
||||
|
||||
function cmpFn(item1, item2) {
|
||||
|
||||
var val1 = item1.label;
|
||||
var val2 = item2.label;
|
||||
|
||||
|
@ -41,7 +39,6 @@ modulejs.define('ext/tree', ['_', '$', 'core/event', 'core/location', 'core/reso
|
|||
}
|
||||
|
||||
function update(item) {
|
||||
|
||||
var $html = $(template);
|
||||
var $indicator = $html.find('.indicator');
|
||||
var $a = $html.find('a');
|
||||
|
@ -57,15 +54,13 @@ modulejs.define('ext/tree', ['_', '$', 'core/event', 'core/location', 'core/reso
|
|||
$label.text(item.label);
|
||||
|
||||
if (item.isFolder()) {
|
||||
|
||||
var subfolders = item.getSubfolders();
|
||||
|
||||
// indicator
|
||||
if ((item.isManaged && !item.isContentFetched) || subfolders.length) {
|
||||
|
||||
if (item.isManaged && !item.isContentFetched || subfolders.length) {
|
||||
$indicator.removeClass('none');
|
||||
|
||||
if ((item.isManaged && !item.isContentFetched)) {
|
||||
if (item.isManaged && !item.isContentFetched) {
|
||||
$indicator.addClass('unknown');
|
||||
} else if (item.isContentVisible) {
|
||||
$indicator.addClass('open');
|
||||
|
@ -114,52 +109,41 @@ modulejs.define('ext/tree', ['_', '$', 'core/event', 'core/location', 'core/reso
|
|||
}
|
||||
|
||||
function createOnIndicatorClick() {
|
||||
|
||||
function slide(item, $indicator, $content, down) {
|
||||
|
||||
item.isContentVisible = down;
|
||||
$indicator.removeClass('open close').addClass(down ? 'open' : 'close');
|
||||
$content[down ? 'slideDown' : 'slideUp']();
|
||||
}
|
||||
|
||||
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.fetchContent(function () {
|
||||
item.isContentVisible = false;
|
||||
|
||||
var $item = update(item);
|
||||
var $indicator = $item.find('> .indicator');
|
||||
var $content = $item.find('> ul.content');
|
||||
$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);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function fetchTree(item, callback) {
|
||||
|
||||
item.isContentVisible = true;
|
||||
item.fetchContent(function (item) {
|
||||
|
||||
item.fetchContent(function () {
|
||||
if (item.parent) {
|
||||
fetchTree(item.parent, callback);
|
||||
} else {
|
||||
|
@ -169,7 +153,6 @@ modulejs.define('ext/tree', ['_', '$', 'core/event', 'core/location', 'core/reso
|
|||
}
|
||||
|
||||
function updateSettings() {
|
||||
|
||||
if (store.get(storekey)) {
|
||||
$('#view-tree').addClass('active');
|
||||
$('#tree').show();
|
||||
|
@ -180,16 +163,13 @@ modulejs.define('ext/tree', ['_', '$', 'core/event', 'core/location', 'core/reso
|
|||
}
|
||||
|
||||
function onLocationChanged(item) {
|
||||
|
||||
fetchTree(item, function (root) {
|
||||
|
||||
$('#tree').append(update(root));
|
||||
updateSettings();
|
||||
});
|
||||
}
|
||||
|
||||
function init() {
|
||||
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
}
|
||||
|
@ -202,14 +182,13 @@ modulejs.define('ext/tree', ['_', '$', 'core/event', 'core/location', 'core/reso
|
|||
.appendTo('#sidebar')
|
||||
.find('#view-tree')
|
||||
.on('click', function (ev) {
|
||||
|
||||
store.put(storekey, !store.get(storekey));
|
||||
updateSettings();
|
||||
ev.preventDefault();
|
||||
});
|
||||
|
||||
// ensure stored value is boolean, otherwise set default
|
||||
if (typeof (store.get(storekey)) !== 'boolean') {
|
||||
if (typeof store.get(storekey) !== 'boolean') {
|
||||
store.put(storekey, settings.show);
|
||||
}
|
||||
updateSettings();
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
modulejs.define('main/index', ['_', 'core/location'], function (_, location) {
|
||||
|
||||
modulejs.require('view/viewmode');
|
||||
|
||||
_.each(modulejs.state(), function (state, id) {
|
||||
|
||||
if (id.indexOf('ext/') === 0) {
|
||||
modulejs.require(id);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
modulejs.define('main/info', ['$', 'config', 'core/resource', 'core/server'], function ($, config, resource, server) {
|
||||
|
||||
var tplTests =
|
||||
'<ul id="tests">';
|
||||
var tplTest =
|
||||
|
@ -33,17 +32,15 @@ modulejs.define('main/info', ['$', 'config', 'core/resource', 'core/server'], fu
|
|||
|
||||
|
||||
function addTest(label, info, passed, result) {
|
||||
|
||||
var $test = $(tplTest).appendTo('#tests');
|
||||
$test.find('.label').text(label);
|
||||
$test.find('.result')
|
||||
.addClass(passed ? 'passed' : 'failed')
|
||||
.text(result ? result : (passed ? 'yes' : 'no'));
|
||||
.text(result ? result : passed ? 'yes' : 'no');
|
||||
$test.find('.info').html(info);
|
||||
}
|
||||
|
||||
function addTests() {
|
||||
|
||||
if (!setup.AS_ADMIN) {
|
||||
return;
|
||||
}
|
||||
|
@ -52,7 +49,7 @@ modulejs.define('main/info', ['$', 'config', 'core/resource', 'core/server'], fu
|
|||
|
||||
addTest(
|
||||
'h5ai version', 'Only green if this is an official h5ai release',
|
||||
/^\d+\.\d+\.\d+$/.test(setup.VERSION), setup.VERSION
|
||||
(/^\d+\.\d+\.\d+$/).test(setup.VERSION), setup.VERSION
|
||||
);
|
||||
|
||||
addTest(
|
||||
|
@ -127,12 +124,10 @@ modulejs.define('main/info', ['$', 'config', 'core/resource', 'core/server'], fu
|
|||
}
|
||||
|
||||
function reload() {
|
||||
|
||||
window.location.reload();
|
||||
}
|
||||
|
||||
function onLogin() {
|
||||
|
||||
server.request({
|
||||
action: 'login',
|
||||
pass: $('#pass').val()
|
||||
|
@ -140,26 +135,22 @@ modulejs.define('main/info', ['$', 'config', 'core/resource', 'core/server'], fu
|
|||
}
|
||||
|
||||
function onLogout() {
|
||||
|
||||
server.request({
|
||||
action: 'logout'
|
||||
}, reload);
|
||||
}
|
||||
|
||||
function onKeydown(event) {
|
||||
|
||||
if (event.which === 13) {
|
||||
onLogin();
|
||||
}
|
||||
}
|
||||
|
||||
function addSupport() {
|
||||
|
||||
$(tplSupport).appendTo('#content');
|
||||
}
|
||||
|
||||
function addLogin() {
|
||||
|
||||
$(tplLogin).appendTo('#content');
|
||||
|
||||
if (setup.AS_ADMIN) {
|
||||
|
@ -177,7 +168,6 @@ modulejs.define('main/info', ['$', 'config', 'core/resource', 'core/server'], fu
|
|||
}
|
||||
|
||||
function init() {
|
||||
|
||||
addSupport();
|
||||
addLogin();
|
||||
addTests();
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
modulejs.define('model/item', ['_', 'core/event', 'core/location', 'core/server', 'core/settings', 'core/types'], function (_, event, location, server, settings, types) {
|
||||
|
||||
var reEndsWithSlash = /\/$/;
|
||||
var reSplitPath = /^(.*\/)([^\/]+\/?)$/;
|
||||
var cache = {};
|
||||
|
||||
|
||||
function startsWith(sequence, part) {
|
||||
|
||||
if (!sequence || !sequence.indexOf) {
|
||||
return false;
|
||||
}
|
||||
|
@ -15,16 +13,14 @@ modulejs.define('model/item', ['_', 'core/event', 'core/location', 'core/server'
|
|||
}
|
||||
|
||||
function createLabel(sequence) {
|
||||
|
||||
sequence = sequence.replace(reEndsWithSlash, '');
|
||||
try {
|
||||
sequence = decodeURIComponent(sequence);
|
||||
} catch (e) {}
|
||||
} catch (e) {/* skip */}
|
||||
return sequence;
|
||||
}
|
||||
|
||||
function splitPath(sequence) {
|
||||
|
||||
if (sequence === '/') {
|
||||
return {
|
||||
parent: null,
|
||||
|
@ -47,7 +43,6 @@ modulejs.define('model/item', ['_', 'core/event', 'core/location', 'core/server'
|
|||
}
|
||||
|
||||
function getItem(options) {
|
||||
|
||||
if (_.isString(options)) {
|
||||
options = {href: options};
|
||||
} else if (!options || !_.isString(options.href)) {
|
||||
|
@ -60,70 +55,64 @@ modulejs.define('model/item', ['_', 'core/event', 'core/location', 'core/server'
|
|||
return null;
|
||||
}
|
||||
|
||||
var self = cache[href] || new Item(href);
|
||||
var item = cache[href] || new Item(href);
|
||||
|
||||
if (_.isNumber(options.time)) {
|
||||
self.time = options.time;
|
||||
item.time = options.time;
|
||||
}
|
||||
if (_.isNumber(options.size)) {
|
||||
self.size = options.size;
|
||||
item.size = options.size;
|
||||
}
|
||||
if (options.managed) {
|
||||
self.isManaged = true;
|
||||
item.isManaged = true;
|
||||
}
|
||||
if (options.fetched) {
|
||||
self.isContentFetched = true;
|
||||
item.isContentFetched = true;
|
||||
}
|
||||
|
||||
return self;
|
||||
return item;
|
||||
}
|
||||
|
||||
function removeItem(absHref) {
|
||||
|
||||
absHref = location.forceEncoding(absHref);
|
||||
|
||||
var self = cache[absHref];
|
||||
var item = cache[absHref];
|
||||
|
||||
if (self) {
|
||||
if (item) {
|
||||
delete cache[absHref];
|
||||
if (self.parent) {
|
||||
delete self.parent.content[self.absHref];
|
||||
if (item.parent) {
|
||||
delete item.parent.content[item.absHref];
|
||||
}
|
||||
_.each(self.content, function (item) {
|
||||
|
||||
removeItem(item.absHref);
|
||||
_.each(item.content, function (child) {
|
||||
removeItem(child.absHref);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function fetchContent(absHref, callback) {
|
||||
|
||||
var self = getItem(absHref);
|
||||
var item = getItem(absHref);
|
||||
|
||||
if (!_.isFunction(callback)) {
|
||||
callback = function () {};
|
||||
}
|
||||
|
||||
if (self.isContentFetched) {
|
||||
callback(self);
|
||||
if (item.isContentFetched) {
|
||||
callback(item);
|
||||
} else {
|
||||
server.request({action: 'get', items: {href: self.absHref, what: 1}}, function (response) {
|
||||
|
||||
server.request({action: 'get', items: {href: item.absHref, what: 1}}, function (response) {
|
||||
if (response.items) {
|
||||
_.each(response.items, function (jsonItem) {
|
||||
|
||||
getItem(jsonItem);
|
||||
});
|
||||
}
|
||||
|
||||
callback(self);
|
||||
callback(item);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function Item(absHref) {
|
||||
|
||||
var split = splitPath(absHref);
|
||||
|
||||
cache[absHref] = this;
|
||||
|
@ -149,49 +138,40 @@ modulejs.define('model/item', ['_', 'core/event', 'core/location', 'core/server'
|
|||
_.extend(Item.prototype, {
|
||||
|
||||
isFolder: function () {
|
||||
|
||||
return reEndsWithSlash.test(this.absHref);
|
||||
},
|
||||
|
||||
isCurrentFolder: function () {
|
||||
|
||||
return this.absHref === location.getAbsHref();
|
||||
},
|
||||
|
||||
isInCurrentFolder: function () {
|
||||
|
||||
return Boolean(this.parent) && this.parent.isCurrentFolder();
|
||||
},
|
||||
|
||||
isCurrentParentFolder: function () {
|
||||
|
||||
var item = getItem(location.getAbsHref());
|
||||
return Boolean(item) && this === item.parent;
|
||||
},
|
||||
|
||||
isDomain: function () {
|
||||
|
||||
return this.absHref === '/';
|
||||
},
|
||||
|
||||
isRoot: function () {
|
||||
|
||||
return this.absHref === settings.rootHref;
|
||||
},
|
||||
|
||||
isEmpty: function () {
|
||||
|
||||
return _.keys(this.content).length === 0;
|
||||
},
|
||||
|
||||
fetchContent: function (callback) {
|
||||
|
||||
return fetchContent(this.absHref, callback);
|
||||
},
|
||||
|
||||
getCrumb: function () {
|
||||
|
||||
var item = this;
|
||||
var item = this; // eslint-disable-line consistent-this
|
||||
var crumb = [item];
|
||||
|
||||
while (item.parent) {
|
||||
|
@ -203,23 +183,18 @@ modulejs.define('model/item', ['_', 'core/event', 'core/location', 'core/server'
|
|||
},
|
||||
|
||||
getSubfolders: function () {
|
||||
|
||||
return _.sortBy(_.filter(this.content, function (item) {
|
||||
|
||||
return item.isFolder();
|
||||
}), function (item) {
|
||||
|
||||
return item.label.toLowerCase();
|
||||
});
|
||||
},
|
||||
|
||||
getStats: function () {
|
||||
|
||||
var folders = 0;
|
||||
var files = 0;
|
||||
|
||||
_.each(this.content, function (item) {
|
||||
|
||||
if (item.isFolder()) {
|
||||
folders += 1;
|
||||
} else {
|
||||
|
@ -228,7 +203,7 @@ modulejs.define('model/item', ['_', 'core/event', 'core/location', 'core/server'
|
|||
});
|
||||
|
||||
var depth = 0;
|
||||
var item = this;
|
||||
var item = this; // eslint-disable-line consistent-this
|
||||
|
||||
while (item.parent) {
|
||||
depth += 1;
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
modulejs.define('view/content', ['$', 'view/mainrow'], function ($, mainrow) {
|
||||
|
||||
var $el = $('<div id="content"/>').appendTo(mainrow.$el);
|
||||
|
||||
return {
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
modulejs.define('view/mainrow', ['$', 'view/root'], function ($, root) {
|
||||
|
||||
var $el = $('<div id="mainrow"/>').appendTo(root.$el);
|
||||
|
||||
return {
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
modulejs.define('view/notification', ['$', 'view/root'], function ($, root) {
|
||||
|
||||
var $el = $('<div id="notification"/>').hide().appendTo(root.$el);
|
||||
|
||||
function set(content) {
|
||||
|
||||
if (content) {
|
||||
$el.stop(true, true).html(content).fadeIn(400);
|
||||
} else {
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
modulejs.define('view/root', ['$'], function ($) {
|
||||
|
||||
var $el = $('body').attr('id', 'root');
|
||||
|
||||
$('#fallback, #fallback-hints').remove();
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
modulejs.define('view/sidebar', ['$', 'core/resource', 'core/store', 'view/mainrow', 'view/topbar'], function ($, resource, store, mainrow, topbar) {
|
||||
|
||||
var storekey = 'sidebarIsVisible';
|
||||
var tplSidebar = '<div id="sidebar"/>';
|
||||
var tplToggle =
|
||||
|
@ -12,7 +11,6 @@ modulejs.define('view/sidebar', ['$', 'core/resource', 'core/store', 'view/mainr
|
|||
|
||||
|
||||
function update(toggle) {
|
||||
|
||||
var isVisible = store.get(storekey);
|
||||
|
||||
if (toggle) {
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
modulejs.define('view/topbar', ['$', 'view/root'], function ($, root) {
|
||||
|
||||
var tplTopbar =
|
||||
'<div id="topbar">' +
|
||||
'<div id="toolbar"/>' +
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
modulejs.define('view/view', ['_', '$', 'core/event', 'core/format', 'core/location', 'core/resource', 'core/settings', 'core/store', 'view/content'], function (_, $, event, format, location, resource, allsettings, store, content) {
|
||||
|
||||
var modes = ['details', 'grid', 'icons'];
|
||||
var sizes = [20, 40, 60, 80, 100, 150, 200, 250, 300, 350, 400];
|
||||
var settings = _.extend({
|
||||
|
@ -41,12 +40,10 @@ modulejs.define('view/view', ['_', '$', 'core/event', 'core/format', 'core/locat
|
|||
|
||||
|
||||
function cropSize(size, min, max) {
|
||||
|
||||
return Math.min(max, Math.max(min, size));
|
||||
}
|
||||
|
||||
function createStyles(size) {
|
||||
|
||||
var dsize = cropSize(size, 20, 80);
|
||||
var gsize = cropSize(size, 40, 160);
|
||||
var isize = cropSize(size, 80, 1000);
|
||||
|
@ -73,14 +70,12 @@ modulejs.define('view/view', ['_', '$', 'core/event', 'core/format', 'core/locat
|
|||
}
|
||||
|
||||
function addCssStyles() {
|
||||
|
||||
var styles = _.map(sortedSizes, function (size) { return createStyles(size); });
|
||||
styles.push('#view .icon img { max-width: ' + settings.maxIconSize + 'px; max-height: ' + settings.maxIconSize + 'px; }');
|
||||
$('<style/>').text(styles.join('\n')).appendTo('head');
|
||||
}
|
||||
|
||||
function set(mode, size) {
|
||||
|
||||
var stored = store.get(storekey);
|
||||
|
||||
mode = mode || stored && stored.mode;
|
||||
|
@ -109,37 +104,30 @@ modulejs.define('view/view', ['_', '$', 'core/event', 'core/format', 'core/locat
|
|||
}
|
||||
|
||||
function getModes() {
|
||||
|
||||
return checkedModes;
|
||||
}
|
||||
|
||||
function getSizes() {
|
||||
|
||||
return sortedSizes;
|
||||
}
|
||||
|
||||
function getMode() {
|
||||
|
||||
return store.get(storekey).mode;
|
||||
}
|
||||
|
||||
function setMode(mode) {
|
||||
|
||||
set(mode, null);
|
||||
}
|
||||
|
||||
function getSize() {
|
||||
|
||||
return store.get(storekey).size;
|
||||
}
|
||||
|
||||
function setSize(size) {
|
||||
|
||||
set(null, size);
|
||||
}
|
||||
|
||||
function createHtml(item) {
|
||||
|
||||
var $html = $(tplItem);
|
||||
var $a = $html.find('a');
|
||||
var $iconImg = $html.find('.icon img');
|
||||
|
@ -178,56 +166,16 @@ modulejs.define('view/view', ['_', '$', 'core/event', 'core/format', 'core/locat
|
|||
}
|
||||
|
||||
function onMouseenter() {
|
||||
|
||||
var item = $(this).closest('.item').data('item');
|
||||
event.pub('item.mouseenter', item);
|
||||
}
|
||||
|
||||
function onMouseleave() {
|
||||
|
||||
var item = $(this).closest('.item').data('item');
|
||||
event.pub('item.mouseleave', item);
|
||||
}
|
||||
|
||||
function setItems(items) {
|
||||
|
||||
var removed = _.map($items.find('.item'), function (item) {
|
||||
|
||||
return $(item).data('item');
|
||||
});
|
||||
|
||||
$items.find('.item').remove();
|
||||
|
||||
_.each(items, function (e) {
|
||||
|
||||
$items.append(createHtml(e));
|
||||
});
|
||||
|
||||
content.$el.scrollLeft(0).scrollTop(0);
|
||||
checkHint();
|
||||
event.pub('view.changed', items, removed);
|
||||
}
|
||||
|
||||
function changeItems(add, remove) {
|
||||
|
||||
_.each(add, function (item) {
|
||||
|
||||
createHtml(item).hide().appendTo($items).fadeIn(400);
|
||||
});
|
||||
|
||||
_.each(remove, function (item) {
|
||||
|
||||
item.$view.fadeOut(400, function () {
|
||||
item.$view.remove();
|
||||
});
|
||||
});
|
||||
|
||||
checkHint();
|
||||
event.pub('view.changed', add, remove);
|
||||
}
|
||||
|
||||
function checkHint() {
|
||||
|
||||
var hasNoItems = $items.find('.item').not('.folder-parent').length === 0;
|
||||
|
||||
if (hasNoItems) {
|
||||
|
@ -237,14 +185,43 @@ modulejs.define('view/view', ['_', '$', 'core/event', 'core/format', 'core/locat
|
|||
}
|
||||
}
|
||||
|
||||
function setHint(l10nKey) {
|
||||
function setItems(items) {
|
||||
var removed = _.map($items.find('.item'), function (item) {
|
||||
return $(item).data('item');
|
||||
});
|
||||
|
||||
$items.find('.item').remove();
|
||||
|
||||
_.each(items, function (e) {
|
||||
$items.append(createHtml(e));
|
||||
});
|
||||
|
||||
content.$el.scrollLeft(0).scrollTop(0);
|
||||
checkHint();
|
||||
event.pub('view.changed', items, removed);
|
||||
}
|
||||
|
||||
function changeItems(add, remove) {
|
||||
_.each(add, function (item) {
|
||||
createHtml(item).hide().appendTo($items).fadeIn(400);
|
||||
});
|
||||
|
||||
_.each(remove, function (item) {
|
||||
item.$view.fadeOut(400, function () {
|
||||
item.$view.remove();
|
||||
});
|
||||
});
|
||||
|
||||
checkHint();
|
||||
event.pub('view.changed', add, remove);
|
||||
}
|
||||
|
||||
function setHint(l10nKey) {
|
||||
$hint.removeClass().addClass('l10n-' + l10nKey);
|
||||
checkHint();
|
||||
}
|
||||
|
||||
function onLocationChanged(item) {
|
||||
|
||||
if (!item) {
|
||||
item = location.getItem();
|
||||
}
|
||||
|
@ -255,10 +232,9 @@ modulejs.define('view/view', ['_', '$', 'core/event', 'core/format', 'core/locat
|
|||
items.push(item.parent);
|
||||
}
|
||||
|
||||
_.each(item.content, function (item) {
|
||||
|
||||
if (!(item.isFolder() && settings.hideFolders)) {
|
||||
items.push(item);
|
||||
_.each(item.content, function (child) {
|
||||
if (!(child.isFolder() && settings.hideFolders)) {
|
||||
items.push(child);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -267,13 +243,11 @@ modulejs.define('view/view', ['_', '$', 'core/event', 'core/format', 'core/locat
|
|||
}
|
||||
|
||||
function onLocationRefreshed(item, added, removed) {
|
||||
|
||||
var add = [];
|
||||
|
||||
_.each(added, function (item) {
|
||||
|
||||
if (!(item.isFolder() && settings.hideFolders)) {
|
||||
add.push(item);
|
||||
_.each(added, function (child) {
|
||||
if (!(child.isFolder() && settings.hideFolders)) {
|
||||
add.push(child);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -282,7 +256,6 @@ modulejs.define('view/view', ['_', '$', 'core/event', 'core/format', 'core/locat
|
|||
}
|
||||
|
||||
function init() {
|
||||
|
||||
addCssStyles();
|
||||
set();
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
modulejs.define('view/viewmode', ['_', '$', 'core/event', 'core/resource', 'core/settings', 'view/sidebar', 'view/topbar', 'view/view'], function (_, $, event, resource, allsettings, sidebar, topbar, view) {
|
||||
|
||||
var settings = _.extend({
|
||||
modeToggle: false
|
||||
}, allsettings.view);
|
||||
|
@ -20,7 +19,6 @@ modulejs.define('view/viewmode', ['_', '$', 'core/event', 'core/resource', 'core
|
|||
|
||||
|
||||
function onChanged(mode, size) {
|
||||
|
||||
$('#viewmode-settings .mode').removeClass('active');
|
||||
$('#viewmode-' + mode).addClass('active');
|
||||
$('#viewmode-size').val(_.indexOf(sizes, size));
|
||||
|
@ -32,7 +30,6 @@ modulejs.define('view/viewmode', ['_', '$', 'core/event', 'core/resource', 'core
|
|||
}
|
||||
|
||||
function addSettings() {
|
||||
|
||||
if (modes.length < 2 && sizes.length < 2) {
|
||||
return;
|
||||
}
|
||||
|
@ -43,7 +40,6 @@ modulejs.define('view/viewmode', ['_', '$', 'core/event', 'core/resource', 'core
|
|||
_.each(modes, function (mode) {
|
||||
$(tplMode.replace(/\[MODE\]/g, mode))
|
||||
.on('click', function () {
|
||||
|
||||
view.setMode(mode);
|
||||
})
|
||||
.appendTo($viewBlock);
|
||||
|
@ -55,7 +51,6 @@ modulejs.define('view/viewmode', ['_', '$', 'core/event', 'core/resource', 'core
|
|||
$(tplSize)
|
||||
.prop('max', max).attr('max', max)
|
||||
.on('input change', function (ev) {
|
||||
|
||||
view.setSize(sizes[ev.target.valueAsNumber]);
|
||||
})
|
||||
.appendTo($viewBlock);
|
||||
|
@ -65,7 +60,6 @@ modulejs.define('view/viewmode', ['_', '$', 'core/event', 'core/resource', 'core
|
|||
}
|
||||
|
||||
function onToggle() {
|
||||
|
||||
var mode = view.getMode();
|
||||
var nextIdx = (modes.indexOf(mode) + 1) % modes.length;
|
||||
var nextMode = modes[nextIdx];
|
||||
|
@ -74,7 +68,6 @@ modulejs.define('view/viewmode', ['_', '$', 'core/event', 'core/resource', 'core
|
|||
}
|
||||
|
||||
function addToggle() {
|
||||
|
||||
if (settings.modeToggle && modes.length > 1) {
|
||||
$(tplToggle)
|
||||
.on('click', onToggle)
|
||||
|
@ -83,7 +76,6 @@ modulejs.define('view/viewmode', ['_', '$', 'core/event', 'core/resource', 'core
|
|||
}
|
||||
|
||||
function init() {
|
||||
|
||||
modes = view.getModes();
|
||||
sizes = view.getSizes();
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
// @include 'vendor/prism-*.js'
|
||||
|
||||
(function () {
|
||||
'use strict';
|
||||
'use strict'; // eslint-disable-line strict
|
||||
|
||||
var win = window;
|
||||
modulejs.define('_', function () { return win._; });
|
||||
|
|
51
test/.eslintrc
Normal file
51
test/.eslintrc
Normal file
|
@ -0,0 +1,51 @@
|
|||
---
|
||||
env:
|
||||
es6: false
|
||||
node: false
|
||||
browser: true
|
||||
mocha: true
|
||||
|
||||
globals:
|
||||
modulejs: false
|
||||
jQuery: false
|
||||
$: false
|
||||
_: false
|
||||
util: false
|
||||
assert: false
|
||||
uniq: false
|
||||
sinon: false
|
||||
|
||||
ecmaFeatures:
|
||||
arrowFunctions: false
|
||||
binaryLiterals: false
|
||||
blockBindings: false
|
||||
classes: false
|
||||
defaultParams: false
|
||||
destructuring: false
|
||||
forOf: false
|
||||
generators: false
|
||||
globalReturn: false
|
||||
jsx: false
|
||||
modules: false
|
||||
objectLiteralComputedProperties: false
|
||||
objectLiteralDuplicateProperties: false
|
||||
objectLiteralShorthandMethods: false
|
||||
objectLiteralShorthandProperties: false
|
||||
octalLiterals: false
|
||||
regexUFlag: false
|
||||
regexYFlag: false
|
||||
spread: false
|
||||
superInFunctions: false
|
||||
templateStrings: false
|
||||
unicodeCodePointEscapes: false
|
||||
|
||||
rules:
|
||||
consistent-this: 0
|
||||
func-names: 0
|
||||
max-nested-callbacks: [1, 5]
|
||||
max-params: [1, 10]
|
||||
no-invalid-this: 0
|
||||
no-var: 0
|
||||
object-shorthand: 0
|
||||
prefer-arrow-callback: 0
|
||||
prefer-reflect: 0
|
|
@ -1,19 +1,21 @@
|
|||
// @include "vendor/*.js"
|
||||
// @include "util/*.js"
|
||||
|
||||
$(function () {
|
||||
'use strict';
|
||||
(function () {
|
||||
'use strict'; // eslint-disable-line strict
|
||||
// @include "util/*.js"
|
||||
}());
|
||||
|
||||
jQuery(function () {
|
||||
'use strict'; // eslint-disable-line strict
|
||||
|
||||
util.mockConfigModule();
|
||||
util.clearModulejs();
|
||||
util.setupMocha();
|
||||
|
||||
describe('all tests', function () {
|
||||
|
||||
// @include "tests/premisses.js"
|
||||
|
||||
describe('unit tests', function () {
|
||||
|
||||
// @include "tests/unit/modulejs.js"
|
||||
// @include "tests/unit/libs.js"
|
||||
// @include "tests/unit/boot.js"
|
||||
|
@ -23,7 +25,6 @@ $(function () {
|
|||
});
|
||||
|
||||
describe('integration tests', function () {
|
||||
|
||||
// @include "tests/integration/*.js"
|
||||
// @-include "tests/integration/*/*.js"
|
||||
});
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
(function () {
|
||||
'use strict';
|
||||
|
||||
describe('view', function () {
|
||||
|
||||
before(function () {
|
||||
|
||||
this.configBackup = modulejs._private.definitions.config;
|
||||
this.storeKey = '_h5ai';
|
||||
this.xConfig = {
|
||||
|
@ -16,14 +12,12 @@ describe('view', function () {
|
|||
});
|
||||
|
||||
after(function () {
|
||||
|
||||
modulejs._private.definitions.config = this.configBackup;
|
||||
util.clearModulejs();
|
||||
util.restoreHtml();
|
||||
});
|
||||
|
||||
beforeEach(function () {
|
||||
|
||||
delete modulejs._private.definitions.config;
|
||||
modulejs.define('config', this.xConfig);
|
||||
util.clearModulejs();
|
||||
|
@ -33,97 +27,80 @@ describe('view', function () {
|
|||
});
|
||||
|
||||
describe('requiring \'view/viewmode\' sets up basic HTML', function () {
|
||||
|
||||
it('runs without errors', function () {
|
||||
|
||||
modulejs.require('view/viewmode');
|
||||
});
|
||||
|
||||
it('adds id root to body', function () {
|
||||
|
||||
modulejs.require('view/viewmode');
|
||||
assert.strictEqual($('body').attr('id'), 'root');
|
||||
});
|
||||
|
||||
it('removes HTML #fallback', function () {
|
||||
|
||||
modulejs.require('view/viewmode');
|
||||
assert.lengthOf($('#fallback'), 0);
|
||||
});
|
||||
|
||||
it('removes HTML #fallback-hints', function () {
|
||||
|
||||
modulejs.require('view/viewmode');
|
||||
assert.lengthOf($('#fallback-hints'), 0);
|
||||
});
|
||||
|
||||
it('adds HTML #mainrow to #root', function () {
|
||||
|
||||
modulejs.require('view/viewmode');
|
||||
assert.lengthOf($('#root > #mainrow'), 1);
|
||||
});
|
||||
|
||||
it('adds HTML #content to #mainrow', function () {
|
||||
|
||||
modulejs.require('view/viewmode');
|
||||
assert.lengthOf($('#mainrow > #content'), 1);
|
||||
});
|
||||
|
||||
it('adds HTML #view to #content', function () {
|
||||
|
||||
modulejs.require('view/viewmode');
|
||||
assert.lengthOf($('#content > #view'), 1);
|
||||
});
|
||||
|
||||
it('adds HTML #items to #view', function () {
|
||||
|
||||
modulejs.require('view/viewmode');
|
||||
assert.lengthOf($('#view > #items'), 1);
|
||||
});
|
||||
|
||||
it('adds HTML #topbar to #root', function () {
|
||||
|
||||
modulejs.require('view/viewmode');
|
||||
assert.lengthOf($('#root > #topbar'), 1);
|
||||
});
|
||||
|
||||
it('adds HTML #toolbar to #topbar', function () {
|
||||
|
||||
modulejs.require('view/viewmode');
|
||||
assert.lengthOf($('#topbar > #toolbar'), 1);
|
||||
});
|
||||
|
||||
it('adds HTML #flowbar to #topbar', function () {
|
||||
|
||||
modulejs.require('view/viewmode');
|
||||
assert.lengthOf($('#topbar > #flowbar'), 1);
|
||||
});
|
||||
|
||||
it('adds HTML #backlink to #topbar', function () {
|
||||
|
||||
modulejs.require('view/viewmode');
|
||||
assert.lengthOf($('#topbar > #backlink'), 1);
|
||||
});
|
||||
|
||||
it('adds HTML #sidebar-toggle to #toolbar', function () {
|
||||
|
||||
modulejs.require('view/viewmode');
|
||||
assert.lengthOf($('#toolbar > #sidebar-toggle'), 1);
|
||||
});
|
||||
|
||||
it('adds HTML #viewmode-settings to #sidebar', function () {
|
||||
|
||||
modulejs.require('view/viewmode');
|
||||
assert.lengthOf($('#sidebar > #viewmode-settings'), 1);
|
||||
});
|
||||
|
||||
it('adds style to head', function () {
|
||||
|
||||
var styleTagCount = $('head > style').length;
|
||||
modulejs.require('view/viewmode');
|
||||
assert.lengthOf($('head > style'), styleTagCount + 1);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
}());
|
||||
|
|
|
@ -1,22 +1,16 @@
|
|||
(function () {
|
||||
'use strict';
|
||||
|
||||
describe('premisses', function () {
|
||||
|
||||
it('window is global object', function () {
|
||||
|
||||
assert.isObject(window);
|
||||
assert.strictEqual(window, window.window);
|
||||
});
|
||||
|
||||
it('document is global object', function () {
|
||||
|
||||
assert.isObject(document);
|
||||
assert.strictEqual(document, window.document);
|
||||
});
|
||||
|
||||
it('jQuery and $ are global functions', function () {
|
||||
|
||||
assert.isFunction(jQuery);
|
||||
assert.strictEqual(jQuery, window.jQuery);
|
||||
assert.strictEqual(jQuery.fn.jquery, '2.1.3');
|
||||
|
@ -26,32 +20,28 @@ describe('premisses', function () {
|
|||
});
|
||||
|
||||
it('_ is global function', function () {
|
||||
|
||||
assert.isFunction(_);
|
||||
assert.strictEqual(_, window._);
|
||||
assert.strictEqual(_.VERSION, '3.9.3');
|
||||
});
|
||||
|
||||
it('util is global object', function () {
|
||||
|
||||
assert.isPlainObject(util);
|
||||
assert.strictEqual(util, window.util);
|
||||
});
|
||||
|
||||
it('uniq is global object', function () {
|
||||
|
||||
assert.isPlainObject(uniq);
|
||||
assert.strictEqual(uniq, window.uniq);
|
||||
});
|
||||
|
||||
it('assert.isPlainObject() works', function () {
|
||||
|
||||
assert.isFunction(assert.isPlainObject);
|
||||
|
||||
assert.isPlainObject({});
|
||||
assert.isPlainObject({a: 1});
|
||||
assert.isPlainObject(Object());
|
||||
assert.isPlainObject(new Object());
|
||||
assert.isPlainObject(new Object()); // eslint-disable-line no-new-object
|
||||
|
||||
assert.throws(function () { assert.isPlainObject(); });
|
||||
assert.throws(function () { assert.isPlainObject(1); });
|
||||
|
@ -63,7 +53,6 @@ describe('premisses', function () {
|
|||
});
|
||||
|
||||
it('assert.lengthOfKeys() works', function () {
|
||||
|
||||
assert.isFunction(assert.lengthOfKeys);
|
||||
|
||||
assert.lengthOfKeys({}, 0);
|
||||
|
@ -77,5 +66,4 @@ describe('premisses', function () {
|
|||
assert.throws(function () { assert.lengthOfKeys({}, 1); });
|
||||
});
|
||||
});
|
||||
|
||||
}());
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
(function () {
|
||||
'use strict';
|
||||
|
||||
var ID = 'boot';
|
||||
var DEPS = ['$', 'core/server'];
|
||||
|
||||
describe('module \'' + ID + '\'', function () {
|
||||
|
||||
before(function () {
|
||||
|
||||
this.definition = modulejs._private.definitions[ID];
|
||||
|
||||
this.xConfig = uniq.obj();
|
||||
|
@ -18,7 +14,6 @@ describe('module \'' + ID + '\'', function () {
|
|||
};
|
||||
|
||||
this.applyFn = function () {
|
||||
|
||||
this.xDefine.reset();
|
||||
this.xRequire.reset();
|
||||
this.xServer.request.reset();
|
||||
|
@ -28,60 +23,48 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
after(function () {
|
||||
|
||||
this.xDefine.restore();
|
||||
this.xRequire.restore();
|
||||
util.restoreHtml();
|
||||
});
|
||||
|
||||
beforeEach(function () {
|
||||
|
||||
util.restoreHtml();
|
||||
});
|
||||
|
||||
describe('definition', function () {
|
||||
|
||||
it('is defined', function () {
|
||||
|
||||
assert.isPlainObject(this.definition);
|
||||
});
|
||||
|
||||
it('has correct id', function () {
|
||||
|
||||
assert.strictEqual(this.definition.id, ID);
|
||||
});
|
||||
|
||||
it('requires correct', function () {
|
||||
|
||||
assert.deepEqual(this.definition.deps, DEPS);
|
||||
});
|
||||
|
||||
it('args for each request', function () {
|
||||
|
||||
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
||||
});
|
||||
|
||||
it('has no instance', function () {
|
||||
|
||||
assert.notProperty(modulejs._private.instances, ID);
|
||||
});
|
||||
|
||||
it('inits without errors', function () {
|
||||
|
||||
this.applyFn();
|
||||
});
|
||||
});
|
||||
|
||||
describe('application', function () {
|
||||
|
||||
it('returns undefined', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isUndefined(instance);
|
||||
});
|
||||
|
||||
it('no data-module', function () {
|
||||
|
||||
this.applyFn();
|
||||
assert.isFalse(this.xServer.request.called);
|
||||
assert.isFalse(this.xDefine.called);
|
||||
|
@ -89,7 +72,6 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
it('data-module=\'test\'', function () {
|
||||
|
||||
$('<script/>').attr('data-module', 'test').appendTo('head');
|
||||
this.applyFn();
|
||||
assert.isFalse(this.xServer.request.called);
|
||||
|
@ -98,7 +80,6 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
it('data-module=\'info\'', function () {
|
||||
|
||||
var expectedData = {
|
||||
action: 'get',
|
||||
setup: true,
|
||||
|
@ -124,7 +105,6 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
it('data-module=\'index\'', function () {
|
||||
|
||||
var expectedData = {
|
||||
action: 'get',
|
||||
setup: true,
|
||||
|
@ -151,5 +131,4 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
}());
|
||||
|
|
|
@ -1,55 +1,42 @@
|
|||
(function () {
|
||||
'use strict';
|
||||
|
||||
var ID = 'config';
|
||||
var DEPS = [];
|
||||
|
||||
describe('module \'' + ID + '\'', function () {
|
||||
|
||||
before(function () {
|
||||
|
||||
this.definition = modulejs._private.definitions[ID];
|
||||
|
||||
this.applyFn = function () {
|
||||
|
||||
return this.definition.fn($);
|
||||
};
|
||||
});
|
||||
|
||||
describe('definition', function () {
|
||||
|
||||
it('is defined', function () {
|
||||
|
||||
assert.isPlainObject(this.definition);
|
||||
});
|
||||
|
||||
it('has correct id', function () {
|
||||
|
||||
assert.strictEqual(this.definition.id, ID);
|
||||
});
|
||||
|
||||
it('requires correct', function () {
|
||||
|
||||
assert.deepEqual(this.definition.deps, DEPS);
|
||||
});
|
||||
|
||||
it('args for each request', function () {
|
||||
|
||||
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
||||
});
|
||||
|
||||
it('has no instance', function () {
|
||||
|
||||
assert.notProperty(modulejs._private.instances, ID);
|
||||
});
|
||||
|
||||
it('inits without errors', function () {
|
||||
|
||||
this.applyFn();
|
||||
});
|
||||
|
||||
it('is only dummy definition', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isPlainObject(instance);
|
||||
assert.lengthOfKeys(instance, 1);
|
||||
|
@ -57,5 +44,4 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
}());
|
||||
|
|
|
@ -1,58 +1,44 @@
|
|||
(function () {
|
||||
'use strict';
|
||||
|
||||
var ID = 'core/event';
|
||||
var DEPS = ['_'];
|
||||
|
||||
describe('module \'' + ID + '\'', function () {
|
||||
|
||||
before(function () {
|
||||
|
||||
this.definition = modulejs._private.definitions[ID];
|
||||
|
||||
this.applyFn = function () {
|
||||
|
||||
return this.definition.fn(_);
|
||||
};
|
||||
});
|
||||
|
||||
describe('definition', function () {
|
||||
|
||||
it('is defined', function () {
|
||||
|
||||
assert.isPlainObject(this.definition);
|
||||
});
|
||||
|
||||
it('has correct id', function () {
|
||||
|
||||
assert.strictEqual(this.definition.id, ID);
|
||||
});
|
||||
|
||||
it('requires correct', function () {
|
||||
|
||||
assert.deepEqual(this.definition.deps, DEPS);
|
||||
});
|
||||
|
||||
it('args for each request', function () {
|
||||
|
||||
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
||||
});
|
||||
|
||||
it('has no instance', function () {
|
||||
|
||||
assert.notProperty(modulejs._private.instances, ID);
|
||||
});
|
||||
|
||||
it('inits without errors', function () {
|
||||
|
||||
this.applyFn();
|
||||
});
|
||||
});
|
||||
|
||||
describe('application', function () {
|
||||
|
||||
it('returns plain object with 3 properties', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isPlainObject(instance);
|
||||
assert.lengthOfKeys(instance, 3);
|
||||
|
@ -60,36 +46,28 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
describe('.sub()', function () {
|
||||
|
||||
it('is function', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isFunction(instance.sub);
|
||||
});
|
||||
});
|
||||
|
||||
describe('.unsub()', function () {
|
||||
|
||||
it('is function', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isFunction(instance.unsub);
|
||||
});
|
||||
});
|
||||
|
||||
describe('.pub()', function () {
|
||||
|
||||
it('is function', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isFunction(instance.pub);
|
||||
});
|
||||
});
|
||||
|
||||
describe('works', function () {
|
||||
|
||||
it('works', function () {
|
||||
|
||||
var topic = 'topic';
|
||||
var arg1 = 'arg1';
|
||||
var arg2 = 'arg2';
|
||||
|
@ -123,5 +101,4 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
}());
|
||||
|
|
|
@ -1,58 +1,44 @@
|
|||
(function () {
|
||||
'use strict';
|
||||
|
||||
var ID = 'core/format';
|
||||
var DEPS = ['_'];
|
||||
|
||||
describe('module \'' + ID + '\'', function () {
|
||||
|
||||
before(function () {
|
||||
|
||||
this.definition = modulejs._private.definitions[ID];
|
||||
|
||||
this.applyFn = function () {
|
||||
|
||||
return this.definition.fn(_);
|
||||
};
|
||||
});
|
||||
|
||||
describe('definition', function () {
|
||||
|
||||
it('is defined', function () {
|
||||
|
||||
assert.isPlainObject(this.definition);
|
||||
});
|
||||
|
||||
it('has correct id', function () {
|
||||
|
||||
assert.strictEqual(this.definition.id, ID);
|
||||
});
|
||||
|
||||
it('requires correct', function () {
|
||||
|
||||
assert.deepEqual(this.definition.deps, DEPS);
|
||||
});
|
||||
|
||||
it('args for each request', function () {
|
||||
|
||||
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
||||
});
|
||||
|
||||
it('has no instance', function () {
|
||||
|
||||
assert.notProperty(modulejs._private.instances, ID);
|
||||
});
|
||||
|
||||
it('inits without errors', function () {
|
||||
|
||||
this.applyFn();
|
||||
});
|
||||
});
|
||||
|
||||
describe('application', function () {
|
||||
|
||||
it('returns plain object with 4 properties', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isPlainObject(instance);
|
||||
assert.lengthOfKeys(instance, 4);
|
||||
|
@ -60,24 +46,19 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
describe('.setDefaultMetric()', function () {
|
||||
|
||||
it('is function', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isFunction(instance.setDefaultMetric);
|
||||
});
|
||||
});
|
||||
|
||||
describe('.formatSize()', function () {
|
||||
|
||||
it('is function', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isFunction(instance.formatSize);
|
||||
});
|
||||
|
||||
it('defaults to decimal metric', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.strictEqual(instance.formatSize(1024), '1 KB');
|
||||
instance.setDefaultMetric(true);
|
||||
|
@ -87,7 +68,6 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
describe('decimal metric', function () {
|
||||
|
||||
_.each([
|
||||
[0, '0 B'],
|
||||
[10, '10 B'],
|
||||
|
@ -108,12 +88,10 @@ describe('module \'' + ID + '\'', function () {
|
|||
[1000000000000, '1.0 TB'],
|
||||
[1250000000000, '1.3 TB']
|
||||
], function (data) {
|
||||
|
||||
var arg = data[0];
|
||||
var exp = data[1];
|
||||
|
||||
it(arg + ' => ' + exp, function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
instance.setDefaultMetric(false);
|
||||
assert.strictEqual(instance.formatSize(arg), exp);
|
||||
|
@ -122,7 +100,6 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
describe('binary metric', function () {
|
||||
|
||||
_.each([
|
||||
[0, '0 B'],
|
||||
[10, '10 B'],
|
||||
|
@ -144,12 +121,10 @@ describe('module \'' + ID + '\'', function () {
|
|||
[1000000000000, '931.3 GiB'],
|
||||
[1250000000000, '1.1 TiB']
|
||||
], function (data) {
|
||||
|
||||
var arg = data[0];
|
||||
var exp = data[1];
|
||||
|
||||
it(arg + ' => ' + exp, function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
instance.setDefaultMetric(true);
|
||||
assert.strictEqual(instance.formatSize(arg), exp);
|
||||
|
@ -159,24 +134,19 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
describe('.setDefaultDateFormat()', function () {
|
||||
|
||||
it('is function', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isFunction(instance.setDefaultDateFormat);
|
||||
});
|
||||
});
|
||||
|
||||
describe('.formatDate()', function () {
|
||||
|
||||
it('is function', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isFunction(instance.formatDate);
|
||||
});
|
||||
|
||||
it('default format', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.strictEqual(instance.formatDate(0), '');
|
||||
assert.strictEqual(instance.formatDate(1000), '1970-01-01 01:00');
|
||||
|
@ -204,18 +174,15 @@ describe('module \'' + ID + '\'', function () {
|
|||
[1400000000000, 'XYYYYXMMXDDXHHXmmXssX', 'X2014X05X13X18X53X20X'],
|
||||
[1400000000000, 'YYYY YY Y MM M DD D HH H mm m ss s', '2014 14 2014 05 5 13 13 18 18 53 53 20 20']
|
||||
], function (data) {
|
||||
|
||||
var arg1 = data[0];
|
||||
var arg2 = data[1];
|
||||
var exp = data[2];
|
||||
|
||||
it(arg1 + ', ' + arg2 + ' => ' + exp, function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.strictEqual(instance.formatDate(arg1, arg2), exp);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
}());
|
||||
|
|
|
@ -1,64 +1,49 @@
|
|||
(function () {
|
||||
'use strict';
|
||||
|
||||
var ID = 'core/langs';
|
||||
var DEPS = ['_', 'config'];
|
||||
|
||||
describe('module \'' + ID + '\'', function () {
|
||||
|
||||
before(function () {
|
||||
|
||||
this.definition = modulejs._private.definitions[ID];
|
||||
|
||||
this.xConfig = {langs: uniq.obj()};
|
||||
this.applyFn = function () {
|
||||
|
||||
return this.definition.fn(_, this.xConfig);
|
||||
};
|
||||
});
|
||||
|
||||
describe('definition', function () {
|
||||
|
||||
it('is defined', function () {
|
||||
|
||||
assert.isPlainObject(this.definition);
|
||||
});
|
||||
|
||||
it('has correct id', function () {
|
||||
|
||||
assert.strictEqual(this.definition.id, ID);
|
||||
});
|
||||
|
||||
it('requires correct', function () {
|
||||
|
||||
assert.deepEqual(this.definition.deps, DEPS);
|
||||
});
|
||||
|
||||
it('args for each request', function () {
|
||||
|
||||
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
||||
});
|
||||
|
||||
it('has no instance', function () {
|
||||
|
||||
assert.notProperty(modulejs._private.instances, ID);
|
||||
});
|
||||
|
||||
it('inits without errors', function () {
|
||||
|
||||
this.applyFn();
|
||||
});
|
||||
});
|
||||
|
||||
describe('application', function () {
|
||||
|
||||
it('returns plain object with right content', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isPlainObject(instance);
|
||||
assert.deepEqual(instance, this.xConfig.langs);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
}());
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
(function () {
|
||||
'use strict';
|
||||
|
||||
var ID = 'core/location';
|
||||
var DEPS = ['_', 'core/event', 'core/modernizr', 'core/settings', 'view/notification'];
|
||||
|
||||
describe('module \'' + ID + '\'', function () {
|
||||
|
||||
before(function () {
|
||||
|
||||
this.definition = modulejs._private.definitions[ID];
|
||||
|
||||
this.xModernizr = {
|
||||
|
@ -25,7 +21,6 @@ describe('module \'' + ID + '\'', function () {
|
|||
set: sinon.stub()
|
||||
};
|
||||
this.applyFn = function () {
|
||||
|
||||
this.xEvent.pub.reset();
|
||||
this.xEvent.sub.reset();
|
||||
this.xNotification.set.reset();
|
||||
|
@ -35,59 +30,47 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
after(function () {
|
||||
|
||||
window.onpopstate = null;
|
||||
});
|
||||
|
||||
beforeEach(function () {
|
||||
|
||||
window.onpopstate = null;
|
||||
});
|
||||
|
||||
describe('definition', function () {
|
||||
|
||||
it('is defined', function () {
|
||||
|
||||
assert.isPlainObject(this.definition);
|
||||
});
|
||||
|
||||
it('has correct id', function () {
|
||||
|
||||
assert.strictEqual(this.definition.id, ID);
|
||||
});
|
||||
|
||||
it('requires correct', function () {
|
||||
|
||||
assert.deepEqual(this.definition.deps, DEPS);
|
||||
});
|
||||
|
||||
it('args for each request', function () {
|
||||
|
||||
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
||||
});
|
||||
|
||||
it('has no instance', function () {
|
||||
|
||||
assert.notProperty(modulejs._private.instances, ID);
|
||||
});
|
||||
|
||||
it('inits without errors', function () {
|
||||
|
||||
this.applyFn();
|
||||
});
|
||||
});
|
||||
|
||||
describe('application', function () {
|
||||
|
||||
it('returns plain object with 7 properties', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isPlainObject(instance);
|
||||
assert.lengthOfKeys(instance, 7);
|
||||
});
|
||||
|
||||
it('sets window.onpopstate function when history and fastBrowsing', function () {
|
||||
|
||||
this.xModernizr.history = true;
|
||||
this.xSettings.view.fastBrowsing = true;
|
||||
|
||||
|
@ -97,7 +80,6 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
it('sets window.onpopstate to null when not history and fastBrowsing', function () {
|
||||
|
||||
this.xModernizr.history = false;
|
||||
this.xSettings.view.fastBrowsing = true;
|
||||
|
||||
|
@ -107,7 +89,6 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
it('sets window.onpopstate to null when history and not fastBrowsing', function () {
|
||||
|
||||
this.xModernizr.history = true;
|
||||
this.xSettings.view.fastBrowsing = false;
|
||||
|
||||
|
@ -117,7 +98,6 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
it('sets window.onpopstate to null when not history and not fastBrowsing', function () {
|
||||
|
||||
this.xModernizr.history = false;
|
||||
this.xSettings.view.fastBrowsing = false;
|
||||
|
||||
|
@ -128,9 +108,7 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
describe('.forceEncoding()', function () {
|
||||
|
||||
it('is function', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isFunction(instance.forceEncoding);
|
||||
});
|
||||
|
@ -161,12 +139,10 @@ describe('module \'' + ID + '\'', function () {
|
|||
['a[b', 'a%5Bb'],
|
||||
['a]b', 'a%5Db']
|
||||
], function (data) {
|
||||
|
||||
var arg = data[0];
|
||||
var exp = data[1];
|
||||
|
||||
it(arg + ' => ' + exp, function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.strictEqual(instance.forceEncoding(arg), exp);
|
||||
});
|
||||
|
@ -174,72 +150,57 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
describe('.getDomain()', function () {
|
||||
|
||||
it('is function', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isFunction(instance.getDomain);
|
||||
});
|
||||
|
||||
it('returns document.domain', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.strictEqual(instance.getDomain(), window.document.domain);
|
||||
});
|
||||
});
|
||||
|
||||
describe('.getAbsHref()', function () {
|
||||
|
||||
it('is function', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isFunction(instance.getAbsHref);
|
||||
});
|
||||
|
||||
it('returns null before .setLocation()', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isNull(instance.getAbsHref());
|
||||
});
|
||||
});
|
||||
|
||||
describe('.getItem()', function () {
|
||||
|
||||
it('is function', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isFunction(instance.getItem);
|
||||
});
|
||||
});
|
||||
|
||||
describe('.setLocation()', function () {
|
||||
|
||||
it('is function', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isFunction(instance.setLocation);
|
||||
});
|
||||
});
|
||||
|
||||
describe('.refresh()', function () {
|
||||
|
||||
it('is function', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isFunction(instance.refresh);
|
||||
});
|
||||
});
|
||||
|
||||
describe('.setLink()', function () {
|
||||
|
||||
it('is function', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isFunction(instance.setLink);
|
||||
});
|
||||
|
||||
it('sets href correct', function () {
|
||||
|
||||
var $el = $('<a/>');
|
||||
var item = {
|
||||
absHref: uniq.id(),
|
||||
|
@ -254,7 +215,6 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
it('sets target=\'_blank\' for unmanaged folders', function () {
|
||||
|
||||
this.xSettings.view.unmanagedInNewWindow = true;
|
||||
|
||||
var $el = $('<a/>');
|
||||
|
@ -271,7 +231,6 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
it('does not set target=\'_blank\' for managed folders', function () {
|
||||
|
||||
this.xSettings.view.unmanagedInNewWindow = true;
|
||||
|
||||
var $el = $('<a/>');
|
||||
|
@ -288,7 +247,6 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
it('does not set target=\'_blank\' for unmanaged folders if disabled', function () {
|
||||
|
||||
this.xSettings.view.unmanagedInNewWindow = false;
|
||||
|
||||
var $el = $('<a/>');
|
||||
|
@ -305,5 +263,4 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
}());
|
||||
|
|
|
@ -1,58 +1,44 @@
|
|||
(function () {
|
||||
'use strict';
|
||||
|
||||
var ID = 'core/modernizr';
|
||||
var DEPS = [];
|
||||
|
||||
describe('module \'' + ID + '\'', function () {
|
||||
|
||||
before(function () {
|
||||
|
||||
this.definition = modulejs._private.definitions[ID];
|
||||
|
||||
this.applyFn = function () {
|
||||
|
||||
return this.definition.fn();
|
||||
};
|
||||
});
|
||||
|
||||
describe('definition', function () {
|
||||
|
||||
it('is defined', function () {
|
||||
|
||||
assert.isPlainObject(this.definition);
|
||||
});
|
||||
|
||||
it('has correct id', function () {
|
||||
|
||||
assert.strictEqual(this.definition.id, ID);
|
||||
});
|
||||
|
||||
it('requires correct', function () {
|
||||
|
||||
assert.deepEqual(this.definition.deps, DEPS);
|
||||
});
|
||||
|
||||
it('args for each request', function () {
|
||||
|
||||
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
||||
});
|
||||
|
||||
it('has no instance', function () {
|
||||
|
||||
assert.notProperty(modulejs._private.instances, ID);
|
||||
});
|
||||
|
||||
it('inits without errors', function () {
|
||||
|
||||
this.applyFn();
|
||||
});
|
||||
});
|
||||
|
||||
describe('application', function () {
|
||||
|
||||
it('returns plain object with 3 properties', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isPlainObject(instance);
|
||||
assert.lengthOf(_.keys(instance), 3);
|
||||
|
@ -60,31 +46,24 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
describe('.canvas', function () {
|
||||
|
||||
it('is boolean', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isBoolean(instance.canvas);
|
||||
});
|
||||
});
|
||||
|
||||
describe('.history', function () {
|
||||
|
||||
it('is boolean', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isBoolean(instance.history);
|
||||
});
|
||||
});
|
||||
|
||||
describe('.localstorage', function () {
|
||||
|
||||
it('is boolean', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isBoolean(instance.localstorage);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
}());
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
(function () {
|
||||
'use strict';
|
||||
|
||||
var ID = 'core/resource';
|
||||
var DEPS = ['_', 'config', 'core/settings'];
|
||||
|
||||
describe('module \'' + ID + '\'', function () {
|
||||
|
||||
before(function () {
|
||||
|
||||
this.definition = modulejs._private.definitions[ID];
|
||||
|
||||
this.xConfig = {
|
||||
|
@ -18,48 +14,38 @@ describe('module \'' + ID + '\'', function () {
|
|||
};
|
||||
this.xSettings = {publicHref: uniq.path('/publicHref/')};
|
||||
this.applyFn = function () {
|
||||
|
||||
return this.definition.fn(_, this.xConfig, this.xSettings);
|
||||
};
|
||||
});
|
||||
|
||||
describe('definition', function () {
|
||||
|
||||
it('is defined', function () {
|
||||
|
||||
assert.isPlainObject(this.definition);
|
||||
});
|
||||
|
||||
it('has correct id', function () {
|
||||
|
||||
assert.strictEqual(this.definition.id, ID);
|
||||
});
|
||||
|
||||
it('requires correct', function () {
|
||||
|
||||
assert.deepEqual(this.definition.deps, DEPS);
|
||||
});
|
||||
|
||||
it('args for each request', function () {
|
||||
|
||||
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
||||
});
|
||||
|
||||
it('has no instance', function () {
|
||||
|
||||
assert.notProperty(modulejs._private.instances, ID);
|
||||
});
|
||||
|
||||
it('inits without errors', function () {
|
||||
|
||||
this.applyFn();
|
||||
});
|
||||
});
|
||||
|
||||
describe('application', function () {
|
||||
|
||||
it('returns plain object with 2 properties', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isPlainObject(instance);
|
||||
assert.lengthOfKeys(instance, 2);
|
||||
|
@ -67,15 +53,12 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
describe('.image()', function () {
|
||||
|
||||
it('is function', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isFunction(instance.image);
|
||||
});
|
||||
|
||||
it('works', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
var ui = this.xSettings.publicHref + 'images/ui/';
|
||||
|
||||
|
@ -87,15 +70,12 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
describe('.icon()', function () {
|
||||
|
||||
it('is function', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isFunction(instance.icon);
|
||||
});
|
||||
|
||||
it('works', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
var themes = this.xSettings.publicHref + 'images/themes/';
|
||||
|
||||
|
@ -109,5 +89,4 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
}());
|
||||
|
|
|
@ -1,14 +1,10 @@
|
|||
(function () {
|
||||
'use strict';
|
||||
|
||||
var ID = 'core/server';
|
||||
var DEPS = ['_', '$'];
|
||||
var $submitEl;
|
||||
|
||||
describe('module \'' + ID + '\'', function () {
|
||||
|
||||
before(function () {
|
||||
|
||||
this.definition = modulejs._private.definitions[ID];
|
||||
|
||||
this.xAjaxResult = {
|
||||
|
@ -18,13 +14,11 @@ describe('module \'' + ID + '\'', function () {
|
|||
};
|
||||
this.xAjax = sinon.stub($, 'ajax').returns(this.xAjaxResult);
|
||||
this.xSubmit = sinon.stub($.fn, 'submit', function () {
|
||||
|
||||
$submitEl = this;
|
||||
return this;
|
||||
});
|
||||
|
||||
this.applyFn = function () {
|
||||
|
||||
this.xAjaxResult.done.reset();
|
||||
this.xAjaxResult.fail.reset();
|
||||
this.xAjaxResult.always.reset();
|
||||
|
@ -37,48 +31,38 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
after(function () {
|
||||
|
||||
this.xAjax.restore();
|
||||
this.xSubmit.restore();
|
||||
});
|
||||
|
||||
describe('definition', function () {
|
||||
|
||||
it('is defined', function () {
|
||||
|
||||
assert.isPlainObject(this.definition);
|
||||
});
|
||||
|
||||
it('has correct id', function () {
|
||||
|
||||
assert.strictEqual(this.definition.id, ID);
|
||||
});
|
||||
|
||||
it('requires correct', function () {
|
||||
|
||||
assert.deepEqual(this.definition.deps, DEPS);
|
||||
});
|
||||
|
||||
it('args for each request', function () {
|
||||
|
||||
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
||||
});
|
||||
|
||||
it('has no instance', function () {
|
||||
|
||||
assert.notProperty(modulejs._private.instances, ID);
|
||||
});
|
||||
|
||||
it('inits without errors', function () {
|
||||
|
||||
this.applyFn();
|
||||
});
|
||||
});
|
||||
|
||||
describe('application', function () {
|
||||
|
||||
it('returns plain object with 2 properties', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isPlainObject(instance);
|
||||
assert.lengthOfKeys(instance, 2);
|
||||
|
@ -86,15 +70,12 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
describe('.request()', function () {
|
||||
|
||||
it('is function', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isFunction(instance.request);
|
||||
});
|
||||
|
||||
it('done() works', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
|
||||
var xData = uniq.obj();
|
||||
|
@ -121,7 +102,6 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
it('fail() works', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
|
||||
var xData = uniq.obj();
|
||||
|
@ -148,15 +128,12 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
describe('.formRequest()', function () {
|
||||
|
||||
it('is function', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isFunction(instance.formRequest);
|
||||
});
|
||||
|
||||
it('works', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
|
||||
var xData = {
|
||||
|
@ -189,5 +166,4 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
}());
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
(function () {
|
||||
'use strict';
|
||||
|
||||
var ID = 'core/settings';
|
||||
var DEPS = ['_', 'config'];
|
||||
|
||||
describe('module \'' + ID + '\'', function () {
|
||||
|
||||
before(function () {
|
||||
|
||||
this.definition = modulejs._private.definitions[ID];
|
||||
|
||||
this.xConfig = {
|
||||
|
@ -22,48 +18,38 @@ describe('module \'' + ID + '\'', function () {
|
|||
}
|
||||
};
|
||||
this.applyFn = function () {
|
||||
|
||||
return this.definition.fn(_, this.xConfig);
|
||||
};
|
||||
});
|
||||
|
||||
describe('definition', function () {
|
||||
|
||||
it('is defined', function () {
|
||||
|
||||
assert.isPlainObject(this.definition);
|
||||
});
|
||||
|
||||
it('has correct id', function () {
|
||||
|
||||
assert.strictEqual(this.definition.id, ID);
|
||||
});
|
||||
|
||||
it('requires correct', function () {
|
||||
|
||||
assert.deepEqual(this.definition.deps, DEPS);
|
||||
});
|
||||
|
||||
it('args for each request', function () {
|
||||
|
||||
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
||||
});
|
||||
|
||||
it('has no instance', function () {
|
||||
|
||||
assert.notProperty(modulejs._private.instances, ID);
|
||||
});
|
||||
|
||||
it('inits without errors', function () {
|
||||
|
||||
this.applyFn();
|
||||
});
|
||||
});
|
||||
|
||||
describe('application', function () {
|
||||
|
||||
it('returns plain object with properties', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isPlainObject(instance);
|
||||
assert.isAbove(_.keys(instance).length, 0);
|
||||
|
@ -71,9 +57,7 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
describe('publics', function () {
|
||||
|
||||
it('extended from options', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.strictEqual(instance.someOptions, this.xConfig.options.someOptions);
|
||||
assert.strictEqual(instance.otherOptions, this.xConfig.options.otherOptions);
|
||||
|
@ -83,22 +67,17 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
describe('.publicHref', function () {
|
||||
|
||||
it('set correct', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.strictEqual(instance.publicHref, this.xConfig.setup.PUBLIC_HREF);
|
||||
});
|
||||
});
|
||||
|
||||
describe('.rootHref', function () {
|
||||
|
||||
it('set correct', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.strictEqual(instance.rootHref, this.xConfig.setup.ROOT_HREF);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
}());
|
||||
|
|
|
@ -1,70 +1,54 @@
|
|||
(function () {
|
||||
'use strict';
|
||||
|
||||
var ID = 'core/store';
|
||||
var DEPS = ['core/modernizr'];
|
||||
|
||||
describe('module \'' + ID + '\'', function () {
|
||||
|
||||
before(function () {
|
||||
|
||||
this.definition = modulejs._private.definitions[ID];
|
||||
|
||||
this.storeKey = '_h5ai';
|
||||
this.xModernizr = {localstorage: true};
|
||||
this.applyFn = function () {
|
||||
|
||||
return this.definition.fn(this.xModernizr);
|
||||
};
|
||||
});
|
||||
|
||||
after(function () {
|
||||
|
||||
util.restoreHtml();
|
||||
});
|
||||
|
||||
beforeEach(function () {
|
||||
|
||||
util.restoreHtml();
|
||||
});
|
||||
|
||||
describe('definition', function () {
|
||||
|
||||
it('is defined', function () {
|
||||
|
||||
assert.isPlainObject(this.definition);
|
||||
});
|
||||
|
||||
it('has correct id', function () {
|
||||
|
||||
assert.strictEqual(this.definition.id, ID);
|
||||
});
|
||||
|
||||
it('requires correct', function () {
|
||||
|
||||
assert.deepEqual(this.definition.deps, DEPS);
|
||||
});
|
||||
|
||||
it('args for each request', function () {
|
||||
|
||||
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
||||
});
|
||||
|
||||
it('has no instance', function () {
|
||||
|
||||
assert.notProperty(modulejs._private.instances, ID);
|
||||
});
|
||||
|
||||
it('inits without errors', function () {
|
||||
|
||||
this.applyFn();
|
||||
});
|
||||
});
|
||||
|
||||
describe('application', function () {
|
||||
|
||||
it('returns plain object with 2 properties', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isPlainObject(instance);
|
||||
assert.lengthOfKeys(instance, 2);
|
||||
|
@ -72,27 +56,21 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
describe('.put()', function () {
|
||||
|
||||
it('is function', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isFunction(instance.put);
|
||||
});
|
||||
});
|
||||
|
||||
describe('.get()', function () {
|
||||
|
||||
it('is function', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isFunction(instance.get);
|
||||
});
|
||||
});
|
||||
|
||||
describe('works', function () {
|
||||
|
||||
it('works', function () {
|
||||
|
||||
var key1 = 'test1';
|
||||
var value1 = '1234';
|
||||
var key2 = 'test2';
|
||||
|
@ -127,5 +105,4 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
}());
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
(function () {
|
||||
'use strict';
|
||||
|
||||
var ID = 'core/types';
|
||||
var DEPS = ['_', 'config'];
|
||||
|
||||
describe('module \'' + ID + '\'', function () {
|
||||
|
||||
before(function () {
|
||||
|
||||
this.definition = modulejs._private.definitions[ID];
|
||||
|
||||
this.xConfig = {types: {
|
||||
|
@ -16,48 +12,38 @@ describe('module \'' + ID + '\'', function () {
|
|||
c: ['*.c']
|
||||
}};
|
||||
this.applyFn = function () {
|
||||
|
||||
return this.definition.fn(_, this.xConfig);
|
||||
};
|
||||
});
|
||||
|
||||
describe('definition', function () {
|
||||
|
||||
it('is defined', function () {
|
||||
|
||||
assert.isPlainObject(this.definition);
|
||||
});
|
||||
|
||||
it('has correct id', function () {
|
||||
|
||||
assert.strictEqual(this.definition.id, ID);
|
||||
});
|
||||
|
||||
it('requires correct', function () {
|
||||
|
||||
assert.deepEqual(this.definition.deps, DEPS);
|
||||
});
|
||||
|
||||
it('args for each request', function () {
|
||||
|
||||
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
||||
});
|
||||
|
||||
it('has no instance', function () {
|
||||
|
||||
assert.notProperty(modulejs._private.instances, ID);
|
||||
});
|
||||
|
||||
it('inits without errors', function () {
|
||||
|
||||
this.applyFn();
|
||||
});
|
||||
});
|
||||
|
||||
describe('application', function () {
|
||||
|
||||
it('returns plain object with 1 property', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isPlainObject(instance);
|
||||
assert.lengthOfKeys(instance, 1);
|
||||
|
@ -65,9 +51,7 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
describe('.getType()', function () {
|
||||
|
||||
it('is function', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isFunction(instance.getType);
|
||||
});
|
||||
|
@ -87,17 +71,14 @@ describe('module \'' + ID + '\'', function () {
|
|||
['some/path/foo/', 'folder'],
|
||||
['/some/path/foo/', 'folder']
|
||||
], function (data) {
|
||||
|
||||
var arg = data[0];
|
||||
var exp = data[1];
|
||||
|
||||
it(arg + ' => ' + exp, function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.strictEqual(instance.getType(arg), exp);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
}());
|
||||
|
|
|
@ -1,58 +1,44 @@
|
|||
(function () {
|
||||
'use strict';
|
||||
|
||||
var ID = 'core/util';
|
||||
var DEPS = ['_'];
|
||||
|
||||
describe('module \'' + ID + '\'', function () {
|
||||
|
||||
before(function () {
|
||||
|
||||
this.definition = modulejs._private.definitions[ID];
|
||||
|
||||
this.applyFn = function () {
|
||||
|
||||
return this.definition.fn(_);
|
||||
};
|
||||
});
|
||||
|
||||
describe('definition', function () {
|
||||
|
||||
it('is defined', function () {
|
||||
|
||||
assert.isPlainObject(this.definition);
|
||||
});
|
||||
|
||||
it('has correct id', function () {
|
||||
|
||||
assert.strictEqual(this.definition.id, ID);
|
||||
});
|
||||
|
||||
it('requires correct', function () {
|
||||
|
||||
assert.deepEqual(this.definition.deps, DEPS);
|
||||
});
|
||||
|
||||
it('args for each request', function () {
|
||||
|
||||
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
||||
});
|
||||
|
||||
it('has no instance', function () {
|
||||
|
||||
assert.notProperty(modulejs._private.instances, ID);
|
||||
});
|
||||
|
||||
it('inits without errors', function () {
|
||||
|
||||
this.applyFn();
|
||||
});
|
||||
});
|
||||
|
||||
describe('application', function () {
|
||||
|
||||
it('returns plain object with 4 properties', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isPlainObject(instance);
|
||||
assert.lengthOfKeys(instance, 4);
|
||||
|
@ -60,9 +46,7 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
describe('.regularCmpFn()', function () {
|
||||
|
||||
it('is function', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isFunction(instance.regularCmpFn);
|
||||
});
|
||||
|
@ -76,13 +60,11 @@ describe('module \'' + ID + '\'', function () {
|
|||
['a', 'b', -1],
|
||||
['a 2', 'a 10', 1]
|
||||
], function (data) {
|
||||
|
||||
var arg1 = data[0];
|
||||
var arg2 = data[1];
|
||||
var exp = data[2];
|
||||
|
||||
it(arg1 + ', ' + arg2 + ' => ' + exp, function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.strictEqual(instance.regularCmpFn(arg1, arg2), exp);
|
||||
});
|
||||
|
@ -90,9 +72,7 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
describe('.naturalCmpFn()', function () {
|
||||
|
||||
it('is function', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isFunction(instance.naturalCmpFn);
|
||||
});
|
||||
|
@ -106,13 +86,11 @@ describe('module \'' + ID + '\'', function () {
|
|||
['a', 'b', -1],
|
||||
['a 2', 'a 10', -1]
|
||||
], function (data) {
|
||||
|
||||
var arg1 = data[0];
|
||||
var arg2 = data[1];
|
||||
var exp = data[2];
|
||||
|
||||
it(arg1 + ', ' + arg2 + ' => ' + exp, function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.strictEqual(instance.naturalCmpFn(arg1, arg2), exp);
|
||||
});
|
||||
|
@ -120,9 +98,7 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
describe('.escapePattern()', function () {
|
||||
|
||||
it('is function', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isFunction(instance.escapePattern);
|
||||
});
|
||||
|
@ -157,12 +133,10 @@ describe('module \'' + ID + '\'', function () {
|
|||
['abc123', 'abc123'],
|
||||
['a.b+c*1', 'a\\.b\\+c\\*1']
|
||||
], function (data) {
|
||||
|
||||
var arg = data[0];
|
||||
var exp = data[1];
|
||||
|
||||
it(arg + ' => ' + exp, function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.strictEqual(instance.escapePattern(arg), exp);
|
||||
});
|
||||
|
@ -170,9 +144,7 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
describe('.parsePattern()', function () {
|
||||
|
||||
it('is function', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isFunction(instance.parsePattern);
|
||||
});
|
||||
|
@ -215,18 +187,15 @@ describe('module \'' + ID + '\'', function () {
|
|||
['re: .', true, ' .']
|
||||
|
||||
], function (data) {
|
||||
|
||||
var arg1 = data[0];
|
||||
var arg2 = data[1];
|
||||
var exp = data[2];
|
||||
|
||||
it(arg1 + ', ' + arg2 + ' => ' + exp, function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.strictEqual(instance.parsePattern(arg1, arg2), exp);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
}());
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
(function () {
|
||||
'use strict';
|
||||
|
||||
var ID = 'ext/title';
|
||||
var DEPS = ['_', 'core/event', 'core/settings'];
|
||||
|
||||
describe('module \'' + ID + '\'', function () {
|
||||
|
||||
before(function () {
|
||||
|
||||
this.definition = modulejs._private.definitions[ID];
|
||||
|
||||
this.xEvent = {
|
||||
|
@ -18,7 +14,6 @@ describe('module \'' + ID + '\'', function () {
|
|||
}};
|
||||
|
||||
this.applyFn = function () {
|
||||
|
||||
this.xEvent.sub.reset();
|
||||
|
||||
return this.definition.fn(_, this.xEvent, this.xSettings);
|
||||
|
@ -26,53 +21,42 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
after(function () {
|
||||
|
||||
util.restoreHtml();
|
||||
});
|
||||
|
||||
describe('definition', function () {
|
||||
|
||||
it('is defined', function () {
|
||||
|
||||
assert.isPlainObject(this.definition);
|
||||
});
|
||||
|
||||
it('has correct id', function () {
|
||||
|
||||
assert.strictEqual(this.definition.id, ID);
|
||||
});
|
||||
|
||||
it('requires correct', function () {
|
||||
|
||||
assert.deepEqual(this.definition.deps, DEPS);
|
||||
});
|
||||
|
||||
it('args for each request', function () {
|
||||
|
||||
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
||||
});
|
||||
|
||||
it('has no instance', function () {
|
||||
|
||||
assert.notProperty(modulejs._private.instances, ID);
|
||||
});
|
||||
|
||||
it('inits without errors', function () {
|
||||
|
||||
this.applyFn();
|
||||
});
|
||||
});
|
||||
|
||||
describe('application', function () {
|
||||
|
||||
it('returns undefined', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isUndefined(instance);
|
||||
});
|
||||
|
||||
it('subscribes to location.changed', function () {
|
||||
|
||||
this.xSettings.title.enabled = true;
|
||||
|
||||
this.applyFn();
|
||||
|
@ -81,7 +65,6 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
it('does not subscribe to events if disabled', function () {
|
||||
|
||||
this.xSettings.title.enabled = false;
|
||||
|
||||
this.applyFn();
|
||||
|
@ -90,19 +73,16 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
describe('sets title on location.changed', function () {
|
||||
|
||||
_.each([
|
||||
[''],
|
||||
['a', 'a'],
|
||||
['a', 'b', 'b - a > b'],
|
||||
['a', 'b', 'c', 'c - a > b > c']
|
||||
], function (data) {
|
||||
|
||||
var labels = data.slice(0, -1);
|
||||
var exp = data.slice(-1)[0];
|
||||
|
||||
it(labels + ' => ' + exp, function () {
|
||||
|
||||
this.xSettings.title.enabled = true;
|
||||
|
||||
this.applyFn();
|
||||
|
@ -121,5 +101,4 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
}());
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
(function () {
|
||||
'use strict';
|
||||
|
||||
describe('libs', function () {
|
||||
|
||||
var libs = {
|
||||
_: window._,
|
||||
$: window.jQuery,
|
||||
|
@ -11,29 +8,22 @@ describe('libs', function () {
|
|||
};
|
||||
|
||||
_.each(libs, function (lib, id) {
|
||||
|
||||
describe('module \'' + id + '\'', function () {
|
||||
|
||||
it('is defined', function () {
|
||||
|
||||
assert.isDefined(modulejs._private.definitions[id]);
|
||||
});
|
||||
|
||||
it('has no instance', function () {
|
||||
|
||||
assert.notProperty(modulejs._private.instances, id);
|
||||
});
|
||||
|
||||
it('returns global lib', function () {
|
||||
|
||||
var definition = modulejs._private.definitions[id];
|
||||
var instance = definition.fn();
|
||||
assert.isDefined(instance);
|
||||
assert.strictEqual(instance, lib);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
}());
|
||||
|
|
|
@ -1,20 +1,15 @@
|
|||
(function () {
|
||||
'use strict';
|
||||
|
||||
var ID = 'main/index';
|
||||
var DEPS = ['_', 'core/location'];
|
||||
|
||||
describe('module \'' + ID + '\'', function () {
|
||||
|
||||
before(function () {
|
||||
|
||||
this.definition = modulejs._private.definitions[ID];
|
||||
|
||||
this.xLocation = {setLocation: sinon.stub()};
|
||||
this.xRequire = sinon.stub(modulejs, 'require');
|
||||
|
||||
this.applyFn = function () {
|
||||
|
||||
this.xLocation.setLocation.reset();
|
||||
this.xRequire.reset();
|
||||
return this.definition.fn(_, this.xLocation);
|
||||
|
@ -22,65 +17,52 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
after(function () {
|
||||
|
||||
this.xRequire.restore();
|
||||
});
|
||||
|
||||
describe('definition', function () {
|
||||
|
||||
it('is defined', function () {
|
||||
|
||||
assert.isPlainObject(this.definition);
|
||||
});
|
||||
|
||||
it('has correct id', function () {
|
||||
|
||||
assert.strictEqual(this.definition.id, ID);
|
||||
});
|
||||
|
||||
it('requires correct', function () {
|
||||
|
||||
assert.deepEqual(this.definition.deps, DEPS);
|
||||
});
|
||||
|
||||
it('args for each request', function () {
|
||||
|
||||
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
||||
});
|
||||
|
||||
it('has no instance', function () {
|
||||
|
||||
assert.notProperty(modulejs._private.instances, ID);
|
||||
});
|
||||
|
||||
it('inits without errors', function () {
|
||||
|
||||
this.applyFn();
|
||||
});
|
||||
});
|
||||
|
||||
describe('application', function () {
|
||||
|
||||
it('returns undefined', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isUndefined(instance);
|
||||
});
|
||||
|
||||
it('requires view/viewmode', function () {
|
||||
|
||||
this.applyFn();
|
||||
assert.isTrue(this.xRequire.calledWithExactly('view/viewmode'));
|
||||
});
|
||||
|
||||
it('requires all extensions', function () {
|
||||
|
||||
this.applyFn();
|
||||
var re = /^ext\//;
|
||||
var self = this;
|
||||
|
||||
_.each(modulejs.state(), function (state, id) {
|
||||
|
||||
if (re.test(id)) {
|
||||
assert.isTrue(self.xRequire.calledWithExactly(id));
|
||||
}
|
||||
|
@ -88,20 +70,17 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
it('requires only views and extensions', function () {
|
||||
|
||||
this.applyFn();
|
||||
assert.isTrue(this.xRequire.alwaysCalledWithMatch(/^(view|ext)\//));
|
||||
});
|
||||
|
||||
it('requires views before extensions', function () {
|
||||
|
||||
this.applyFn();
|
||||
var foundExtension = false;
|
||||
var reView = /^view\//;
|
||||
var reExt = /^ext\//;
|
||||
|
||||
_.each(this.xRequire.args, function (args) {
|
||||
|
||||
if (foundExtension) {
|
||||
assert.match(args[0], reExt);
|
||||
} else if (reExt.test(args[0])) {
|
||||
|
@ -113,7 +92,6 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
it('calls setLocation with current href, keeping browser url', function () {
|
||||
|
||||
this.applyFn();
|
||||
assert.isTrue(this.xLocation.setLocation.calledOnce);
|
||||
assert.deepEqual(this.xLocation.setLocation.firstCall.args, [document.location.href, true]);
|
||||
|
@ -121,5 +99,4 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
}());
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
(function () {
|
||||
'use strict';
|
||||
|
||||
var ID = 'main/info';
|
||||
var DEPS = ['$', 'config', 'core/resource', 'core/server'];
|
||||
|
||||
describe('module \'' + ID + '\'', function () {
|
||||
|
||||
before(function () {
|
||||
|
||||
this.definition = modulejs._private.definitions[ID];
|
||||
|
||||
this.xConfig = {
|
||||
|
@ -24,7 +20,6 @@ describe('module \'' + ID + '\'', function () {
|
|||
};
|
||||
|
||||
this.applyFn = function () {
|
||||
|
||||
this.xServer.request.reset();
|
||||
|
||||
return this.definition.fn($, this.xConfig, this.xResource, this.xServer);
|
||||
|
@ -32,59 +27,47 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
after(function () {
|
||||
|
||||
util.restoreHtml();
|
||||
});
|
||||
|
||||
beforeEach(function () {
|
||||
|
||||
util.restoreHtml();
|
||||
$('<div id="content"/>').appendTo('body');
|
||||
});
|
||||
|
||||
describe('definition', function () {
|
||||
|
||||
it('is defined', function () {
|
||||
|
||||
assert.isPlainObject(this.definition);
|
||||
});
|
||||
|
||||
it('has correct id', function () {
|
||||
|
||||
assert.strictEqual(this.definition.id, ID);
|
||||
});
|
||||
|
||||
it('requires correct', function () {
|
||||
|
||||
assert.deepEqual(this.definition.deps, DEPS);
|
||||
});
|
||||
|
||||
it('args for each request', function () {
|
||||
|
||||
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
||||
});
|
||||
|
||||
it('has no instance', function () {
|
||||
|
||||
assert.notProperty(modulejs._private.instances, ID);
|
||||
});
|
||||
|
||||
it('inits without errors', function () {
|
||||
|
||||
this.applyFn();
|
||||
});
|
||||
});
|
||||
|
||||
describe('application', function () {
|
||||
|
||||
it('returns undefined', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isUndefined(instance);
|
||||
});
|
||||
|
||||
it('adds HTML #support to #content', function () {
|
||||
|
||||
this.applyFn();
|
||||
assert.lengthOf($('#content > #support'), 1);
|
||||
assert.lengthOf($('#support > .paypal'), 1);
|
||||
|
@ -92,50 +75,42 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
it('adds HTML #login-wrapper to #content', function () {
|
||||
|
||||
this.applyFn();
|
||||
assert.lengthOf($('#content > #login-wrapper'), 1);
|
||||
});
|
||||
|
||||
describe('no admin', function () {
|
||||
|
||||
it('adds HTML #pass to #login-wrapper', function () {
|
||||
|
||||
this.xConfig.setup.AS_ADMIN = false;
|
||||
this.applyFn();
|
||||
assert.lengthOf($('#login-wrapper > #pass'), 1);
|
||||
});
|
||||
|
||||
it('sets #pass val to empty string', function () {
|
||||
|
||||
this.xConfig.setup.AS_ADMIN = false;
|
||||
this.applyFn();
|
||||
assert.strictEqual($('#login-wrapper > #pass').val(), '');
|
||||
});
|
||||
|
||||
it('adds HTML #login to #login-wrapper', function () {
|
||||
|
||||
this.xConfig.setup.AS_ADMIN = false;
|
||||
this.applyFn();
|
||||
assert.lengthOf($('#login-wrapper > #login'), 1);
|
||||
});
|
||||
|
||||
it('does not add HTML #logout to #login-wrapper', function () {
|
||||
|
||||
this.xConfig.setup.AS_ADMIN = false;
|
||||
this.applyFn();
|
||||
assert.lengthOf($('#login-wrapper > #logout'), 0);
|
||||
});
|
||||
|
||||
it('does not add HTML #tests to #content', function () {
|
||||
|
||||
this.xConfig.setup.AS_ADMIN = false;
|
||||
this.applyFn();
|
||||
assert.lengthOf($('#content > #tests'), 0);
|
||||
});
|
||||
|
||||
it('login works', function () {
|
||||
|
||||
var pass = uniq.id();
|
||||
var expectedData = {
|
||||
action: 'login',
|
||||
|
@ -155,44 +130,37 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
describe('as admin', function () {
|
||||
|
||||
it('does not add HTML #pass to #login-wrapper', function () {
|
||||
|
||||
this.xConfig.setup.AS_ADMIN = true;
|
||||
this.applyFn();
|
||||
assert.lengthOf($('#login-wrapper > #pass'), 0);
|
||||
});
|
||||
|
||||
it('does not add #login to #login-wrapper', function () {
|
||||
|
||||
this.xConfig.setup.AS_ADMIN = true;
|
||||
this.applyFn();
|
||||
assert.lengthOf($('#login-wrapper > #login'), 0);
|
||||
});
|
||||
|
||||
it('adds HTML #logout to #login-wrapper', function () {
|
||||
|
||||
this.xConfig.setup.AS_ADMIN = true;
|
||||
this.applyFn();
|
||||
assert.lengthOf($('#login-wrapper > #logout'), 1);
|
||||
});
|
||||
|
||||
it('adds HTML #tests to #content', function () {
|
||||
|
||||
this.xConfig.setup.AS_ADMIN = true;
|
||||
this.applyFn();
|
||||
assert.lengthOf($('#content > #tests'), 1);
|
||||
});
|
||||
|
||||
it('adds HTML #test 15x to #tests', function () {
|
||||
|
||||
this.xConfig.setup.AS_ADMIN = true;
|
||||
this.applyFn();
|
||||
assert.strictEqual($('#tests > .test').length, 15);
|
||||
});
|
||||
|
||||
it('logout works', function () {
|
||||
|
||||
var expectedData = {
|
||||
action: 'logout'
|
||||
};
|
||||
|
@ -209,5 +177,4 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
}());
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
(function () {
|
||||
'use strict';
|
||||
|
||||
var ID = 'model/item';
|
||||
var DEPS = ['_', 'core/event', 'core/location', 'core/server', 'core/settings', 'core/types'];
|
||||
|
||||
describe('module \'' + ID + '\'', function () {
|
||||
|
||||
before(function () {
|
||||
|
||||
this.definition = modulejs._private.definitions[ID];
|
||||
|
||||
this.xRootName = uniq.id();
|
||||
|
@ -25,48 +21,38 @@ describe('module \'' + ID + '\'', function () {
|
|||
getAbsHref: sinon.stub().returns(uniq.id())
|
||||
};
|
||||
this.applyFn = function () {
|
||||
|
||||
return this.definition.fn(_, this.xEvent, this.xLocation, this.xServer, this.xSettings, this.xTypes);
|
||||
};
|
||||
});
|
||||
|
||||
describe('definition', function () {
|
||||
|
||||
it('is defined', function () {
|
||||
|
||||
assert.isPlainObject(this.definition);
|
||||
});
|
||||
|
||||
it('has correct id', function () {
|
||||
|
||||
assert.strictEqual(this.definition.id, ID);
|
||||
});
|
||||
|
||||
it('requires correct', function () {
|
||||
|
||||
assert.deepEqual(this.definition.deps, DEPS);
|
||||
});
|
||||
|
||||
it('args for each request', function () {
|
||||
|
||||
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
||||
});
|
||||
|
||||
it('has no instance', function () {
|
||||
|
||||
assert.notProperty(modulejs._private.instances, ID);
|
||||
});
|
||||
|
||||
it('inits without errors', function () {
|
||||
|
||||
this.applyFn();
|
||||
});
|
||||
});
|
||||
|
||||
describe('application', function () {
|
||||
|
||||
it('returns plain object with 2 properties', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isPlainObject(instance);
|
||||
assert.lengthOfKeys(instance, 2);
|
||||
|
@ -74,315 +60,252 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
describe('.get()', function () {
|
||||
|
||||
it('is function', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isFunction(instance.get);
|
||||
});
|
||||
|
||||
it('returns null with no argument', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isNull(instance.get());
|
||||
});
|
||||
|
||||
it('returns null for no string argument', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isNull(instance.get(1));
|
||||
});
|
||||
|
||||
it('returns null for href not starting with rootHref', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isNull(instance.get('/a/'));
|
||||
});
|
||||
|
||||
describe('for rootHref', function () {
|
||||
|
||||
beforeEach(function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
this.item = instance.get(this.xSettings.rootHref);
|
||||
});
|
||||
|
||||
it('returns object', function () {
|
||||
|
||||
assert.isObject(this.item);
|
||||
});
|
||||
|
||||
it('sets href correct', function () {
|
||||
|
||||
assert.strictEqual(this.item.absHref, this.xSettings.rootHref);
|
||||
});
|
||||
|
||||
it('sets type correct', function () {
|
||||
|
||||
assert.strictEqual(this.item.type, this.xTypes.getType(this.absHref));
|
||||
});
|
||||
|
||||
it('sets label correct', function () {
|
||||
|
||||
assert.strictEqual(this.item.label, this.xRootName);
|
||||
});
|
||||
|
||||
it('sets time to null', function () {
|
||||
|
||||
assert.isNull(this.item.time);
|
||||
});
|
||||
|
||||
it('sets size to null', function () {
|
||||
|
||||
assert.isNull(this.item.size);
|
||||
});
|
||||
|
||||
it('sets parent to null', function () {
|
||||
|
||||
assert.isNull(this.item.parent);
|
||||
});
|
||||
|
||||
it('sets isManaged to null', function () {
|
||||
|
||||
assert.isNull(this.item.isManaged);
|
||||
});
|
||||
|
||||
it('sets content correct', function () {
|
||||
|
||||
assert.isPlainObject(this.item.content);
|
||||
assert.lengthOfKeys(this.item.content, 0);
|
||||
});
|
||||
|
||||
it('.isFolder() returns true', function () {
|
||||
|
||||
assert.isTrue(this.item.isFolder());
|
||||
});
|
||||
|
||||
it('.isCurrentFolder() returns false', function () {
|
||||
|
||||
assert.isFalse(this.item.isCurrentFolder());
|
||||
});
|
||||
|
||||
it('.isInCurrentFolder() returns false', function () {
|
||||
|
||||
assert.isFalse(this.item.isInCurrentFolder());
|
||||
});
|
||||
|
||||
it('.isCurrentParentFolder() returns false', function () {
|
||||
|
||||
assert.isFalse(this.item.isCurrentParentFolder());
|
||||
});
|
||||
|
||||
it('.isDomain() returns false', function () {
|
||||
|
||||
assert.isFalse(this.item.isDomain());
|
||||
});
|
||||
|
||||
it('.isRoot() returns true', function () {
|
||||
|
||||
assert.isTrue(this.item.isRoot());
|
||||
});
|
||||
|
||||
it('.isEmpty() returns true', function () {
|
||||
|
||||
assert.isTrue(this.item.isEmpty());
|
||||
});
|
||||
});
|
||||
|
||||
describe('for folder href other than rootHref', function () {
|
||||
|
||||
beforeEach(function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
this.item = instance.get(this.xSettings.rootHref + 'a/');
|
||||
});
|
||||
|
||||
it('returns object', function () {
|
||||
|
||||
assert.isObject(this.item);
|
||||
});
|
||||
|
||||
it('sets href correct', function () {
|
||||
|
||||
assert.strictEqual(this.item.absHref, this.xSettings.rootHref + 'a/');
|
||||
});
|
||||
|
||||
it('sets type correct', function () {
|
||||
|
||||
assert.strictEqual(this.item.type, this.xTypes.getType(this.absHref));
|
||||
});
|
||||
|
||||
it('sets label correct', function () {
|
||||
|
||||
assert.strictEqual(this.item.label, 'a');
|
||||
});
|
||||
|
||||
it('sets time to null', function () {
|
||||
|
||||
assert.isNull(this.item.time);
|
||||
});
|
||||
|
||||
it('sets size to null', function () {
|
||||
|
||||
assert.isNull(this.item.size);
|
||||
});
|
||||
|
||||
it('sets parent to object', function () {
|
||||
|
||||
assert.isObject(this.item.parent);
|
||||
});
|
||||
|
||||
it('parent has same constructor', function () {
|
||||
|
||||
assert.strictEqual(this.item.constructor, this.item.parent.constructor);
|
||||
});
|
||||
|
||||
it('sets isManaged to null', function () {
|
||||
|
||||
assert.isNull(this.item.isManaged);
|
||||
});
|
||||
|
||||
it('sets content correct', function () {
|
||||
|
||||
assert.isPlainObject(this.item.content);
|
||||
assert.lengthOfKeys(this.item.content, 0);
|
||||
});
|
||||
|
||||
it('.isFolder() returns true', function () {
|
||||
|
||||
assert.isTrue(this.item.isFolder());
|
||||
});
|
||||
|
||||
it('.isCurrentFolder() returns false', function () {
|
||||
|
||||
assert.isFalse(this.item.isCurrentFolder());
|
||||
});
|
||||
|
||||
it('.isInCurrentFolder() returns false', function () {
|
||||
|
||||
assert.isFalse(this.item.isInCurrentFolder());
|
||||
});
|
||||
|
||||
it('.isCurrentParentFolder() returns false', function () {
|
||||
|
||||
assert.isFalse(this.item.isCurrentParentFolder());
|
||||
});
|
||||
|
||||
it('.isDomain() returns false', function () {
|
||||
|
||||
assert.isFalse(this.item.isDomain());
|
||||
});
|
||||
|
||||
it('.isRoot() returns false', function () {
|
||||
|
||||
assert.isFalse(this.item.isRoot());
|
||||
});
|
||||
|
||||
it('.isEmpty() returns true', function () {
|
||||
|
||||
assert.isTrue(this.item.isEmpty());
|
||||
});
|
||||
});
|
||||
|
||||
describe('for file href', function () {
|
||||
|
||||
beforeEach(function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
this.item = instance.get(this.xSettings.rootHref + 'a');
|
||||
});
|
||||
|
||||
it('returns object', function () {
|
||||
|
||||
assert.isObject(this.item);
|
||||
});
|
||||
|
||||
it('sets href correct', function () {
|
||||
|
||||
assert.strictEqual(this.item.absHref, this.xSettings.rootHref + 'a');
|
||||
});
|
||||
|
||||
it('sets type correct', function () {
|
||||
|
||||
assert.strictEqual(this.item.type, this.xTypes.getType(this.absHref));
|
||||
});
|
||||
|
||||
it('sets label correct', function () {
|
||||
|
||||
assert.strictEqual(this.item.label, 'a');
|
||||
});
|
||||
|
||||
it('sets time to null', function () {
|
||||
|
||||
assert.isNull(this.item.time);
|
||||
});
|
||||
|
||||
it('sets size to null', function () {
|
||||
|
||||
assert.isNull(this.item.size);
|
||||
});
|
||||
|
||||
it('sets parent to object', function () {
|
||||
|
||||
assert.isObject(this.item.parent);
|
||||
});
|
||||
|
||||
it('parent has same constructor', function () {
|
||||
|
||||
assert.strictEqual(this.item.constructor, this.item.parent.constructor);
|
||||
});
|
||||
|
||||
it('sets isManaged to null', function () {
|
||||
|
||||
assert.isNull(this.item.isManaged);
|
||||
});
|
||||
|
||||
it('sets content correct', function () {
|
||||
|
||||
assert.isPlainObject(this.item.content);
|
||||
assert.lengthOfKeys(this.item.content, 0);
|
||||
});
|
||||
|
||||
it('.isFolder() returns false', function () {
|
||||
|
||||
assert.isFalse(this.item.isFolder());
|
||||
});
|
||||
|
||||
it('.isCurrentFolder() returns false', function () {
|
||||
|
||||
assert.isFalse(this.item.isCurrentFolder());
|
||||
});
|
||||
|
||||
it('.isInCurrentFolder() returns false', function () {
|
||||
|
||||
assert.isFalse(this.item.isInCurrentFolder());
|
||||
});
|
||||
|
||||
it('.isCurrentParentFolder() returns false', function () {
|
||||
|
||||
assert.isFalse(this.item.isCurrentParentFolder());
|
||||
});
|
||||
|
||||
it('.isDomain() returns false', function () {
|
||||
|
||||
assert.isFalse(this.item.isDomain());
|
||||
});
|
||||
|
||||
it('.isRoot() returns false', function () {
|
||||
|
||||
assert.isFalse(this.item.isRoot());
|
||||
});
|
||||
|
||||
it('.isEmpty() returns true', function () {
|
||||
|
||||
assert.isTrue(this.item.isEmpty());
|
||||
});
|
||||
});
|
||||
|
||||
describe('parents', function () {
|
||||
|
||||
beforeEach(function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
this.item = instance.get(this.xSettings.rootHref + 'p/a/');
|
||||
this.parent = this.item.parent;
|
||||
|
@ -390,55 +313,44 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
it('parent is object', function () {
|
||||
|
||||
assert.isObject(this.parent);
|
||||
});
|
||||
|
||||
it('parent has correct href', function () {
|
||||
|
||||
assert.strictEqual(this.parent.absHref, this.xSettings.rootHref + 'p/');
|
||||
});
|
||||
|
||||
it('parent has correct label', function () {
|
||||
|
||||
assert.strictEqual(this.parent.label, 'p');
|
||||
});
|
||||
|
||||
it('parent .isEmpty() returns false', function () {
|
||||
|
||||
assert.isFalse(this.parent.isEmpty());
|
||||
});
|
||||
|
||||
it('grandpa is object', function () {
|
||||
|
||||
assert.isObject(this.grandpa);
|
||||
});
|
||||
|
||||
it('grandpa has correct href', function () {
|
||||
|
||||
assert.strictEqual(this.grandpa.absHref, this.xSettings.rootHref);
|
||||
});
|
||||
|
||||
it('grandpa has correct label', function () {
|
||||
|
||||
assert.strictEqual(this.grandpa.label, this.xRootName);
|
||||
});
|
||||
|
||||
it('grandpa .isEmpty() returns false', function () {
|
||||
|
||||
assert.isFalse(this.grandpa.isEmpty());
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('.remove()', function () {
|
||||
|
||||
it('is function', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isFunction(instance.remove);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
}());
|
||||
|
|
|
@ -1,48 +1,36 @@
|
|||
(function () {
|
||||
'use strict';
|
||||
|
||||
describe('modulejs', function () {
|
||||
|
||||
it('is global object', function () {
|
||||
|
||||
assert.isPlainObject(modulejs);
|
||||
assert.strictEqual(modulejs, window.modulejs);
|
||||
});
|
||||
|
||||
it('.define() is function', function () {
|
||||
|
||||
assert.isFunction(modulejs.define);
|
||||
});
|
||||
|
||||
it('.require() is function', function () {
|
||||
|
||||
assert.isFunction(modulejs.require);
|
||||
});
|
||||
|
||||
it('.state() is function', function () {
|
||||
|
||||
assert.isFunction(modulejs.state);
|
||||
});
|
||||
|
||||
it('.log() is function', function () {
|
||||
|
||||
assert.isFunction(modulejs.log);
|
||||
});
|
||||
|
||||
it('._private is object', function () {
|
||||
|
||||
assert.isObject(modulejs._private);
|
||||
});
|
||||
|
||||
it('has definitions', function () {
|
||||
|
||||
assert.isAbove(_.keys(modulejs._private.definitions).length, 0);
|
||||
});
|
||||
|
||||
it('has no instances', function () {
|
||||
|
||||
assert.lengthOfKeys(modulejs._private.instances, 0);
|
||||
});
|
||||
});
|
||||
|
||||
}());
|
||||
|
|
|
@ -1,86 +1,67 @@
|
|||
(function () {
|
||||
'use strict';
|
||||
|
||||
var ID = 'view/content';
|
||||
var DEPS = ['$', 'view/mainrow'];
|
||||
|
||||
describe('module \'' + ID + '\'', function () {
|
||||
|
||||
before(function () {
|
||||
|
||||
this.definition = modulejs._private.definitions[ID];
|
||||
|
||||
this.xMainrow = {$el: null};
|
||||
this.applyFn = function () {
|
||||
|
||||
return this.definition.fn($, this.xMainrow);
|
||||
};
|
||||
});
|
||||
|
||||
after(function () {
|
||||
|
||||
util.restoreHtml();
|
||||
});
|
||||
|
||||
beforeEach(function () {
|
||||
|
||||
util.restoreHtml();
|
||||
this.xMainrow.$el = $('<div id="mainrow"/>').appendTo('body');
|
||||
});
|
||||
|
||||
describe('definition', function () {
|
||||
|
||||
it('is defined', function () {
|
||||
|
||||
assert.isPlainObject(this.definition);
|
||||
});
|
||||
|
||||
it('has correct id', function () {
|
||||
|
||||
assert.strictEqual(this.definition.id, ID);
|
||||
});
|
||||
|
||||
it('requires correct', function () {
|
||||
|
||||
assert.deepEqual(this.definition.deps, DEPS);
|
||||
});
|
||||
|
||||
it('args for each request', function () {
|
||||
|
||||
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
||||
});
|
||||
|
||||
it('has no instance', function () {
|
||||
|
||||
assert.notProperty(modulejs._private.instances, ID);
|
||||
});
|
||||
|
||||
it('inits without errors', function () {
|
||||
|
||||
this.applyFn();
|
||||
});
|
||||
});
|
||||
|
||||
describe('application', function () {
|
||||
|
||||
it('returns object with 1 property', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isPlainObject(instance);
|
||||
assert.lengthOfKeys(instance, 1);
|
||||
});
|
||||
|
||||
it('adds HTML #content to #mainrow', function () {
|
||||
|
||||
this.applyFn();
|
||||
assert.lengthOf($('#mainrow > #content'), 1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('.$el', function () {
|
||||
|
||||
it('is $(\'#content\')', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isObject(instance.$el);
|
||||
assert.lengthOf(instance.$el, 1);
|
||||
|
@ -89,5 +70,4 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
}());
|
||||
|
|
|
@ -1,86 +1,67 @@
|
|||
(function () {
|
||||
'use strict';
|
||||
|
||||
var ID = 'view/mainrow';
|
||||
var DEPS = ['$', 'view/root'];
|
||||
|
||||
describe('module \'' + ID + '\'', function () {
|
||||
|
||||
before(function () {
|
||||
|
||||
this.definition = modulejs._private.definitions[ID];
|
||||
|
||||
this.xRoot = {$el: null};
|
||||
this.applyFn = function () {
|
||||
|
||||
return this.definition.fn($, this.xRoot);
|
||||
};
|
||||
});
|
||||
|
||||
after(function () {
|
||||
|
||||
util.restoreHtml();
|
||||
});
|
||||
|
||||
beforeEach(function () {
|
||||
|
||||
util.restoreHtml();
|
||||
this.xRoot.$el = $('<div id="root"/>').appendTo('body');
|
||||
});
|
||||
|
||||
describe('definition', function () {
|
||||
|
||||
it('is defined', function () {
|
||||
|
||||
assert.isPlainObject(this.definition);
|
||||
});
|
||||
|
||||
it('has correct id', function () {
|
||||
|
||||
assert.strictEqual(this.definition.id, ID);
|
||||
});
|
||||
|
||||
it('requires correct', function () {
|
||||
|
||||
assert.deepEqual(this.definition.deps, DEPS);
|
||||
});
|
||||
|
||||
it('args for each request', function () {
|
||||
|
||||
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
||||
});
|
||||
|
||||
it('has no instance', function () {
|
||||
|
||||
assert.notProperty(modulejs._private.instances, ID);
|
||||
});
|
||||
|
||||
it('inits without errors', function () {
|
||||
|
||||
this.applyFn();
|
||||
});
|
||||
});
|
||||
|
||||
describe('application', function () {
|
||||
|
||||
it('returns object with 1 property', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isPlainObject(instance);
|
||||
assert.lengthOfKeys(instance, 1);
|
||||
});
|
||||
|
||||
it('adds HTML #mainrow to #root', function () {
|
||||
|
||||
this.applyFn();
|
||||
assert.lengthOf($('#root > #mainrow'), 1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('.$el', function () {
|
||||
|
||||
it('is $(\'#mainrow\')', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isObject(instance.$el);
|
||||
assert.lengthOf(instance.$el, 1);
|
||||
|
@ -89,5 +70,4 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
}());
|
||||
|
|
|
@ -1,77 +1,60 @@
|
|||
(function () {
|
||||
'use strict';
|
||||
|
||||
var ID = 'view/notification';
|
||||
var DEPS = ['$', 'view/root'];
|
||||
|
||||
describe('module \'' + ID + '\'', function () {
|
||||
|
||||
before(function () {
|
||||
|
||||
this.definition = modulejs._private.definitions[ID];
|
||||
|
||||
this.xRoot = {$el: null};
|
||||
this.applyFn = function () {
|
||||
|
||||
return this.definition.fn($, this.xRoot);
|
||||
};
|
||||
});
|
||||
|
||||
after(function () {
|
||||
|
||||
util.restoreHtml();
|
||||
});
|
||||
|
||||
beforeEach(function () {
|
||||
|
||||
util.restoreHtml();
|
||||
this.xRoot.$el = $('<div id="root"/>').appendTo('body');
|
||||
});
|
||||
|
||||
describe('definition', function () {
|
||||
|
||||
it('is defined', function () {
|
||||
|
||||
assert.isPlainObject(this.definition);
|
||||
});
|
||||
|
||||
it('has correct id', function () {
|
||||
|
||||
assert.strictEqual(this.definition.id, ID);
|
||||
});
|
||||
|
||||
it('requires correct', function () {
|
||||
|
||||
assert.deepEqual(this.definition.deps, DEPS);
|
||||
});
|
||||
|
||||
it('args for each request', function () {
|
||||
|
||||
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
||||
});
|
||||
|
||||
it('has no instance', function () {
|
||||
|
||||
assert.notProperty(modulejs._private.instances, ID);
|
||||
});
|
||||
|
||||
it('inits without errors', function () {
|
||||
|
||||
this.applyFn();
|
||||
});
|
||||
});
|
||||
|
||||
describe('application', function () {
|
||||
|
||||
it('returns plain object with 2 properties', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isPlainObject(instance);
|
||||
assert.lengthOfKeys(instance, 2);
|
||||
});
|
||||
|
||||
it('adds HTML #notification to #root (hidden)', function () {
|
||||
|
||||
this.applyFn();
|
||||
assert.lengthOf($('#root > #notification'), 1);
|
||||
assert.lengthOf($('#notification:visible'), 0);
|
||||
|
@ -80,9 +63,7 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
describe('.$el', function () {
|
||||
|
||||
it('is $(\'#notification\')', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isObject(instance.$el);
|
||||
assert.lengthOf(instance.$el, 1);
|
||||
|
@ -92,15 +73,12 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
describe('.set()', function () {
|
||||
|
||||
it('is function', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isTrue(_.isFunction(instance.set));
|
||||
});
|
||||
|
||||
it('works', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
|
||||
instance.set();
|
||||
|
@ -121,5 +99,4 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
}());
|
||||
|
|
|
@ -1,98 +1,77 @@
|
|||
(function () {
|
||||
'use strict';
|
||||
|
||||
var ID = 'view/root';
|
||||
var DEPS = ['$'];
|
||||
|
||||
describe('module \'' + ID + '\'', function () {
|
||||
|
||||
before(function () {
|
||||
|
||||
this.definition = modulejs._private.definitions[ID];
|
||||
|
||||
this.applyFn = function () {
|
||||
|
||||
return this.definition.fn($);
|
||||
};
|
||||
});
|
||||
|
||||
after(function () {
|
||||
|
||||
util.restoreHtml();
|
||||
});
|
||||
|
||||
beforeEach(function () {
|
||||
|
||||
util.restoreHtml();
|
||||
$('<div id="fallback"/>').appendTo('body');
|
||||
$('<div id="fallback-hints"/>').appendTo('body');
|
||||
});
|
||||
|
||||
describe('definition', function () {
|
||||
|
||||
it('is defined', function () {
|
||||
|
||||
assert.isPlainObject(this.definition);
|
||||
});
|
||||
|
||||
it('has correct id', function () {
|
||||
|
||||
assert.strictEqual(this.definition.id, ID);
|
||||
});
|
||||
|
||||
it('requires correct', function () {
|
||||
|
||||
assert.deepEqual(this.definition.deps, DEPS);
|
||||
});
|
||||
|
||||
it('args for each request', function () {
|
||||
|
||||
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
||||
});
|
||||
|
||||
it('has no instance', function () {
|
||||
|
||||
assert.notProperty(modulejs._private.instances, ID);
|
||||
});
|
||||
|
||||
it('inits without errors', function () {
|
||||
|
||||
this.applyFn();
|
||||
});
|
||||
});
|
||||
|
||||
describe('application', function () {
|
||||
|
||||
it('returns object with 1 property', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isPlainObject(instance);
|
||||
assert.lengthOfKeys(instance, 1);
|
||||
});
|
||||
|
||||
it('adds id root to body', function () {
|
||||
|
||||
this.applyFn();
|
||||
assert.strictEqual($('body').attr('id'), 'root');
|
||||
});
|
||||
|
||||
it('removes HTML #fallback', function () {
|
||||
|
||||
this.applyFn();
|
||||
assert.lengthOf($('#fallback'), 0);
|
||||
});
|
||||
|
||||
it('removes HTML #fallback-hints', function () {
|
||||
|
||||
this.applyFn();
|
||||
assert.lengthOf($('#fallback-hints'), 0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('.$el', function () {
|
||||
|
||||
it('is $(\'#root\')', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isObject(instance.$el);
|
||||
assert.lengthOf(instance.$el, 1);
|
||||
|
@ -101,5 +80,4 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
}());
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
(function () {
|
||||
'use strict';
|
||||
|
||||
var ID = 'view/sidebar';
|
||||
var DEPS = ['$', 'core/resource', 'core/store', 'view/mainrow', 'view/topbar'];
|
||||
|
||||
describe('module \'' + ID + '\'', function () {
|
||||
|
||||
before(function () {
|
||||
|
||||
this.definition = modulejs._private.definitions[ID];
|
||||
|
||||
this.xResource = {
|
||||
|
@ -23,7 +19,6 @@ describe('module \'' + ID + '\'', function () {
|
|||
this.xMainrow = {$el: null};
|
||||
this.xTopbar = {$toolbar: null};
|
||||
this.applyFn = function () {
|
||||
|
||||
this.xResource.image.reset();
|
||||
this.xStore.get.reset();
|
||||
this.xStore.put.reset();
|
||||
|
@ -33,12 +28,10 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
after(function () {
|
||||
|
||||
util.restoreHtml();
|
||||
});
|
||||
|
||||
beforeEach(function () {
|
||||
|
||||
util.restoreHtml();
|
||||
this.xMainrow.$el = $('<div id="mainrow"/>').appendTo('body');
|
||||
this.xTopbar.$toolbar = $('<div id="toolbar"/>').appendTo('body');
|
||||
|
@ -46,55 +39,44 @@ describe('module \'' + ID + '\'', function () {
|
|||
|
||||
|
||||
describe('definition', function () {
|
||||
|
||||
it('is defined', function () {
|
||||
|
||||
assert.isPlainObject(this.definition);
|
||||
});
|
||||
|
||||
it('has correct id', function () {
|
||||
|
||||
assert.strictEqual(this.definition.id, ID);
|
||||
});
|
||||
|
||||
it('requires correct', function () {
|
||||
|
||||
assert.deepEqual(this.definition.deps, DEPS);
|
||||
});
|
||||
|
||||
it('args for each request', function () {
|
||||
|
||||
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
||||
});
|
||||
|
||||
it('has no instance', function () {
|
||||
|
||||
assert.notProperty(modulejs._private.instances, ID);
|
||||
});
|
||||
|
||||
it('inits without errors', function () {
|
||||
|
||||
this.instance = this.applyFn();
|
||||
});
|
||||
});
|
||||
|
||||
describe('application', function () {
|
||||
|
||||
it('returns object with 1 property', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isPlainObject(instance);
|
||||
assert.lengthOfKeys(instance, 1);
|
||||
});
|
||||
|
||||
it('adds HTML #sidebar-toggle to #toolbar', function () {
|
||||
|
||||
this.applyFn();
|
||||
assert.lengthOf($('#toolbar > #sidebar-toggle'), 1);
|
||||
});
|
||||
|
||||
it('toggle works', function () {
|
||||
|
||||
this.applyFn();
|
||||
assert.lengthOf($('#sidebar:visible'), 0);
|
||||
|
||||
|
@ -127,9 +109,7 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
describe('.$el', function () {
|
||||
|
||||
it('is $(\'#sidebar\')', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isObject(instance.$el);
|
||||
assert.lengthOf(instance.$el, 1);
|
||||
|
@ -138,5 +118,4 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
}());
|
||||
|
|
|
@ -1,113 +1,90 @@
|
|||
(function () {
|
||||
'use strict';
|
||||
|
||||
var ID = 'view/topbar';
|
||||
var DEPS = ['$', 'view/root'];
|
||||
|
||||
describe('module \'' + ID + '\'', function () {
|
||||
|
||||
before(function () {
|
||||
|
||||
this.definition = modulejs._private.definitions[ID];
|
||||
|
||||
this.xRoot = {$el: null};
|
||||
this.applyFn = function () {
|
||||
|
||||
return this.definition.fn($, this.xRoot);
|
||||
};
|
||||
});
|
||||
|
||||
after(function () {
|
||||
|
||||
util.restoreHtml();
|
||||
});
|
||||
|
||||
beforeEach(function () {
|
||||
|
||||
util.restoreHtml();
|
||||
this.xRoot.$el = $('<div id="root"/>').appendTo('body');
|
||||
});
|
||||
|
||||
describe('definition', function () {
|
||||
|
||||
it('is defined', function () {
|
||||
|
||||
assert.isPlainObject(this.definition);
|
||||
});
|
||||
|
||||
it('has correct id', function () {
|
||||
|
||||
assert.strictEqual(this.definition.id, ID);
|
||||
});
|
||||
|
||||
it('requires correct', function () {
|
||||
|
||||
assert.deepEqual(this.definition.deps, DEPS);
|
||||
});
|
||||
|
||||
it('args for each request', function () {
|
||||
|
||||
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
||||
});
|
||||
|
||||
it('has no instance', function () {
|
||||
|
||||
assert.notProperty(modulejs._private.instances, ID);
|
||||
});
|
||||
|
||||
it('inits without errors', function () {
|
||||
|
||||
this.applyFn();
|
||||
});
|
||||
});
|
||||
|
||||
describe('application', function () {
|
||||
|
||||
it('returns object with 3 properties', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isPlainObject(instance);
|
||||
assert.lengthOfKeys(instance, 3);
|
||||
});
|
||||
|
||||
it('adds HTML #topbar to #root', function () {
|
||||
|
||||
this.applyFn();
|
||||
assert.lengthOf($('#root > #topbar'), 1);
|
||||
});
|
||||
|
||||
it('adds HTML #toolbar to #topbar', function () {
|
||||
|
||||
this.applyFn();
|
||||
assert.lengthOf($('#topbar > #toolbar'), 1);
|
||||
});
|
||||
|
||||
it('adds HTML #flowbar to #topbar', function () {
|
||||
|
||||
this.applyFn();
|
||||
assert.lengthOf($('#topbar > #flowbar'), 1);
|
||||
});
|
||||
|
||||
it('adds HTML #backlink to #topbar', function () {
|
||||
|
||||
this.applyFn();
|
||||
assert.lengthOf($('#topbar > #backlink'), 1);
|
||||
});
|
||||
|
||||
it('#backlink has correct href', function () {
|
||||
|
||||
this.applyFn();
|
||||
assert.strictEqual($('#backlink').attr('href'), 'https://larsjung.de/h5ai/');
|
||||
});
|
||||
|
||||
it('#backlink has correct title', function () {
|
||||
|
||||
this.applyFn();
|
||||
assert.strictEqual($('#backlink').attr('title'), 'powered by h5ai - https://larsjung.de/h5ai/');
|
||||
});
|
||||
|
||||
it('#backlink has correct text', function () {
|
||||
|
||||
this.applyFn();
|
||||
assert.strictEqual($('#backlink > div').eq(0).text(), 'powered');
|
||||
assert.strictEqual($('#backlink > div').eq(1).text(), 'by h5ai');
|
||||
|
@ -115,9 +92,7 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
describe('.$el', function () {
|
||||
|
||||
it('is $(\'#topbar\')', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isObject(instance.$el);
|
||||
assert.lengthOf(instance.$el, 1);
|
||||
|
@ -127,9 +102,7 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
describe('.$toolbar', function () {
|
||||
|
||||
it('is $(\'#toolbar\')', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isObject(instance.$toolbar);
|
||||
assert.lengthOf(instance.$toolbar, 1);
|
||||
|
@ -139,9 +112,7 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
describe('.$flowbar', function () {
|
||||
|
||||
it('is $(\'#flowbar\')', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isObject(instance.$flowbar);
|
||||
assert.lengthOf(instance.$flowbar, 1);
|
||||
|
@ -150,5 +121,4 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
}());
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
(function () {
|
||||
'use strict';
|
||||
|
||||
var ID = 'view/view';
|
||||
var DEPS = ['_', '$', 'core/event', 'core/format', 'core/location', 'core/resource', 'core/settings', 'core/store', 'view/content'];
|
||||
|
||||
describe('module \'' + ID + '\'', function () {
|
||||
|
||||
before(function () {
|
||||
|
||||
this.definition = modulejs._private.definitions[ID];
|
||||
|
||||
this.xEvent = {
|
||||
|
@ -40,7 +36,6 @@ describe('module \'' + ID + '\'', function () {
|
|||
this.xContent = {$el: null};
|
||||
|
||||
this.applyFn = function () {
|
||||
|
||||
this.xEvent.sub.reset();
|
||||
this.xEvent.pub.reset();
|
||||
this.xFormat.setDefaultMetric.reset();
|
||||
|
@ -54,85 +49,69 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
after(function () {
|
||||
|
||||
util.restoreHtml();
|
||||
});
|
||||
|
||||
beforeEach(function () {
|
||||
|
||||
util.restoreHtml();
|
||||
this.xContent.$el = $('<div id="content"/>').appendTo('body');
|
||||
});
|
||||
|
||||
describe('definition', function () {
|
||||
|
||||
it('is defined', function () {
|
||||
|
||||
assert.isPlainObject(this.definition);
|
||||
});
|
||||
|
||||
it('has correct id', function () {
|
||||
|
||||
assert.strictEqual(this.definition.id, ID);
|
||||
});
|
||||
|
||||
it('requires correct', function () {
|
||||
|
||||
assert.deepEqual(this.definition.deps, DEPS);
|
||||
});
|
||||
|
||||
it('args for each request', function () {
|
||||
|
||||
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
||||
});
|
||||
|
||||
it('has no instance', function () {
|
||||
|
||||
assert.notProperty(modulejs._private.instances, ID);
|
||||
});
|
||||
|
||||
it('inits without errors', function () {
|
||||
|
||||
this.applyFn();
|
||||
});
|
||||
});
|
||||
|
||||
describe('application', function () {
|
||||
|
||||
it('returns object with 12 properties', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isPlainObject(instance);
|
||||
assert.lengthOfKeys(instance, 12);
|
||||
});
|
||||
|
||||
it('adds HTML #view to #content', function () {
|
||||
|
||||
this.applyFn();
|
||||
assert.lengthOf($('#content > #view'), 1);
|
||||
});
|
||||
|
||||
it('adds HTML #items to #view', function () {
|
||||
|
||||
this.applyFn();
|
||||
assert.lengthOf($('#view > #items'), 1);
|
||||
});
|
||||
|
||||
it('adds HTML #view-hint to #view', function () {
|
||||
|
||||
this.applyFn();
|
||||
assert.lengthOf($('#view > #view-hint'), 1);
|
||||
});
|
||||
|
||||
it('adds style to head', function () {
|
||||
|
||||
var styleTagCount = $('head > style').length;
|
||||
this.applyFn();
|
||||
assert.lengthOf($('head > style'), styleTagCount + 1);
|
||||
});
|
||||
|
||||
it('style contains possibly correct text', function () {
|
||||
|
||||
this.xSettings.sizes = [20];
|
||||
this.applyFn();
|
||||
var text = $('head > style').eq(0).text();
|
||||
|
@ -142,26 +121,22 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
it('sets default metric', function () {
|
||||
|
||||
this.applyFn();
|
||||
assert.isTrue(this.xFormat.setDefaultMetric.calledOnce);
|
||||
});
|
||||
|
||||
it('subscribes to 2 events', function () {
|
||||
|
||||
this.applyFn();
|
||||
assert.isTrue(this.xEvent.sub.calledTwice);
|
||||
});
|
||||
|
||||
it('subscribes to location.changed', function () {
|
||||
|
||||
this.applyFn();
|
||||
assert.strictEqual(this.xEvent.sub.firstCall.args[0], 'location.changed');
|
||||
assert.isFunction(this.xEvent.sub.firstCall.args[1]);
|
||||
});
|
||||
|
||||
it('subscribes to location.refreshed', function () {
|
||||
|
||||
this.applyFn();
|
||||
assert.strictEqual(this.xEvent.sub.secondCall.args[0], 'location.refreshed');
|
||||
assert.isFunction(this.xEvent.sub.secondCall.args[1]);
|
||||
|
@ -169,9 +144,7 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
describe('.$el', function () {
|
||||
|
||||
it('is $(\'#view\')', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isObject(instance.$el);
|
||||
assert.lengthOf(instance.$el, 1);
|
||||
|
@ -181,9 +154,7 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
describe('.$items', function () {
|
||||
|
||||
it('is $(\'#items\')', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isObject(instance.$items);
|
||||
assert.lengthOf(instance.$items, 1);
|
||||
|
@ -193,15 +164,12 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
describe('.setItems()', function () {
|
||||
|
||||
it('is function', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isTrue(_.isFunction(instance.setItems));
|
||||
});
|
||||
|
||||
it('publishes view.changed', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
instance.setItems();
|
||||
assert.isTrue(this.xEvent.pub.calledTwice);
|
||||
|
@ -210,15 +178,12 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
describe('.changeItems()', function () {
|
||||
|
||||
it('is function', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isTrue(_.isFunction(instance.changeItems));
|
||||
});
|
||||
|
||||
it('publishes view.changed', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
instance.setItems();
|
||||
assert.isTrue(this.xEvent.pub.calledTwice);
|
||||
|
@ -227,15 +192,12 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
describe('.setLocation()', function () {
|
||||
|
||||
it('is function', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isTrue(_.isFunction(instance.setLocation));
|
||||
});
|
||||
|
||||
it('publishes view.changed', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
instance.setItems();
|
||||
assert.isTrue(this.xEvent.pub.calledTwice);
|
||||
|
@ -244,15 +206,12 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
describe('.setHint()', function () {
|
||||
|
||||
it('is function', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isTrue(_.isFunction(instance.setHint));
|
||||
});
|
||||
|
||||
it('sets correct class to #view-hint', function () {
|
||||
|
||||
var key = uniq.id();
|
||||
var instance = this.applyFn();
|
||||
instance.setHint(key);
|
||||
|
@ -260,7 +219,6 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
it('removes all other classes from #view-hint', function () {
|
||||
|
||||
var key = uniq.id();
|
||||
var instance = this.applyFn();
|
||||
$('#view-hint').addClass('a');
|
||||
|
@ -270,33 +228,26 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
describe('.getModes()', function () {
|
||||
|
||||
it('is function', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isTrue(_.isFunction(instance.getModes));
|
||||
});
|
||||
});
|
||||
|
||||
describe('.getMode()', function () {
|
||||
|
||||
it('is function', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isTrue(_.isFunction(instance.getMode));
|
||||
});
|
||||
});
|
||||
|
||||
describe('.setMode()', function () {
|
||||
|
||||
it('is function', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isTrue(_.isFunction(instance.setMode));
|
||||
});
|
||||
|
||||
it('.setMode(\'details\') changes #view class to .view-details', function () {
|
||||
|
||||
this.xSettings.view.modes = ['details', 'grid', 'icons'];
|
||||
var instance = this.applyFn();
|
||||
instance.setMode('details');
|
||||
|
@ -306,7 +257,6 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
it('.setMode(\'grid\') changes #view class to .view-grid', function () {
|
||||
|
||||
this.xSettings.view.modes = ['details', 'grid', 'icons'];
|
||||
var instance = this.applyFn();
|
||||
instance.setMode('grid');
|
||||
|
@ -316,7 +266,6 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
it('.setMode(\'icons\') changes #view class to .view-icons', function () {
|
||||
|
||||
this.xSettings.view.modes = ['details', 'grid', 'icons'];
|
||||
var instance = this.applyFn();
|
||||
instance.setMode('icons');
|
||||
|
@ -327,22 +276,18 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
describe('.getSizes()', function () {
|
||||
|
||||
it('is function', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isTrue(_.isFunction(instance.getSizes));
|
||||
});
|
||||
|
||||
it('returns sorted sizes', function () {
|
||||
|
||||
this.xSettings.view.sizes = [20, 60, 40];
|
||||
var instance = this.applyFn();
|
||||
assert.deepEqual(instance.getSizes(), [20, 40, 60]);
|
||||
});
|
||||
|
||||
it('returns sorted sizes', function () {
|
||||
|
||||
this.xSettings.view.sizes = [60, 40, 20];
|
||||
var instance = this.applyFn();
|
||||
assert.deepEqual(instance.getSizes(), [20, 40, 60]);
|
||||
|
@ -350,24 +295,19 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
describe('.getSize()', function () {
|
||||
|
||||
it('is function', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isTrue(_.isFunction(instance.getSize));
|
||||
});
|
||||
});
|
||||
|
||||
describe('.setSize()', function () {
|
||||
|
||||
it('is function', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isTrue(_.isFunction(instance.setSize));
|
||||
});
|
||||
|
||||
it('.setSize(20) changes #view class to .view-size-20', function () {
|
||||
|
||||
this.xSettings.view.sizes = [20, 40, 60];
|
||||
var instance = this.applyFn();
|
||||
instance.setSize(20);
|
||||
|
@ -377,7 +317,6 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
it('.setSize(40) changes #view class to .view-size-40', function () {
|
||||
|
||||
this.xSettings.view.sizes = [20, 40, 60];
|
||||
var instance = this.applyFn();
|
||||
instance.setSize(20);
|
||||
|
@ -388,7 +327,6 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
it('.setSize(60) changes #view class to .view-size-60', function () {
|
||||
|
||||
this.xSettings.view.sizes = [20, 40, 60];
|
||||
var instance = this.applyFn();
|
||||
instance.setSize(20);
|
||||
|
@ -400,11 +338,8 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
// describe('._.createHtml()', function () {
|
||||
|
||||
// before(function () {
|
||||
|
||||
// this.createItem = function () {
|
||||
|
||||
// return {
|
||||
// isFolder: sinon.stub().returns(false),
|
||||
// label: uniq.id(),
|
||||
|
@ -419,13 +354,11 @@ describe('module \'' + ID + '\'', function () {
|
|||
// });
|
||||
|
||||
// it('is function', function () {
|
||||
|
||||
// var instance = this.applyFn();
|
||||
// assert.isFunction(instance._.createHtml);
|
||||
// });
|
||||
|
||||
// it('returns jQuery instance of single HTML element', function () {
|
||||
|
||||
// var item = this.createItem();
|
||||
// var instance = this.applyFn();
|
||||
// var $item = instance._.createHtml(item);
|
||||
|
@ -435,7 +368,6 @@ describe('module \'' + ID + '\'', function () {
|
|||
// });
|
||||
|
||||
// it('$item.data(\'item\') is back reference to item', function () {
|
||||
|
||||
// var item = this.createItem();
|
||||
// var instance = this.applyFn();
|
||||
// var $item = instance._.createHtml(item);
|
||||
|
@ -443,7 +375,6 @@ describe('module \'' + ID + '\'', function () {
|
|||
// });
|
||||
|
||||
// it('sets item.$view as reference to $item', function () {
|
||||
|
||||
// var item = this.createItem();
|
||||
// var instance = this.applyFn();
|
||||
// var $item = instance._.createHtml(item);
|
||||
|
@ -451,5 +382,4 @@ describe('module \'' + ID + '\'', function () {
|
|||
// });
|
||||
// });
|
||||
});
|
||||
|
||||
}());
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
(function () {
|
||||
'use strict';
|
||||
|
||||
var ID = 'view/viewmode';
|
||||
var DEPS = ['_', '$', 'core/event', 'core/resource', 'core/settings', 'view/sidebar', 'view/topbar', 'view/view'];
|
||||
|
||||
describe('module \'' + ID + '\'', function () {
|
||||
|
||||
before(function () {
|
||||
|
||||
this.definition = modulejs._private.definitions[ID];
|
||||
|
||||
this.xEvent = {
|
||||
|
@ -33,7 +29,6 @@ describe('module \'' + ID + '\'', function () {
|
|||
};
|
||||
|
||||
this.applyFn = function () {
|
||||
|
||||
this.xEvent.sub.reset();
|
||||
this.xEvent.pub.reset();
|
||||
this.xResource.image.reset();
|
||||
|
@ -49,12 +44,10 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
after(function () {
|
||||
|
||||
util.restoreHtml();
|
||||
});
|
||||
|
||||
beforeEach(function () {
|
||||
|
||||
util.restoreHtml();
|
||||
this.xSidebar.$el = $('<div id="sidebar"/>').appendTo('body');
|
||||
this.xTopbar.$el = $('<div id="topbar"/>').appendTo('body');
|
||||
|
@ -62,78 +55,63 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
describe('definition', function () {
|
||||
|
||||
it('is defined', function () {
|
||||
|
||||
assert.isPlainObject(this.definition);
|
||||
});
|
||||
|
||||
it('has correct id', function () {
|
||||
|
||||
assert.strictEqual(this.definition.id, ID);
|
||||
});
|
||||
|
||||
it('requires correct', function () {
|
||||
|
||||
assert.deepEqual(this.definition.deps, DEPS);
|
||||
});
|
||||
|
||||
it('args for each request', function () {
|
||||
|
||||
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
||||
});
|
||||
|
||||
it('has no instance', function () {
|
||||
|
||||
assert.notProperty(modulejs._private.instances, ID);
|
||||
});
|
||||
|
||||
it('inits without errors', function () {
|
||||
|
||||
this.applyFn();
|
||||
});
|
||||
});
|
||||
|
||||
describe('application', function () {
|
||||
|
||||
it('returns undefined', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isUndefined(instance);
|
||||
});
|
||||
|
||||
it('adds HTML #viewmode-settings to #sidebar', function () {
|
||||
|
||||
this.applyFn();
|
||||
assert.lengthOf($('#sidebar > #viewmode-settings'), 1);
|
||||
});
|
||||
|
||||
it('adds HTML #viewmode-details to #viewmode-settings', function () {
|
||||
|
||||
this.applyFn();
|
||||
assert.lengthOf($('#viewmode-settings > #viewmode-details'), 1);
|
||||
});
|
||||
|
||||
it('adds HTML #viewmode-grid to #viewmode-settings', function () {
|
||||
|
||||
this.applyFn();
|
||||
assert.lengthOf($('#viewmode-settings > #viewmode-grid'), 1);
|
||||
});
|
||||
|
||||
it('adds HTML #viewmode-icons to #viewmode-settings', function () {
|
||||
|
||||
this.applyFn();
|
||||
assert.lengthOf($('#viewmode-settings > #viewmode-icons'), 1);
|
||||
});
|
||||
|
||||
it('adds HTML #viewmode-size to #viewmode-settings', function () {
|
||||
|
||||
this.applyFn();
|
||||
assert.lengthOf($('#viewmode-settings > #viewmode-size'), 1);
|
||||
});
|
||||
|
||||
it('does not add HTML #viewmode-details, #viewmode-grid, #viewmode-icons when only one mode', function () {
|
||||
|
||||
this.xView.getModes.returns(['details']);
|
||||
this.applyFn();
|
||||
assert.lengthOf($('#viewmode-details'), 0);
|
||||
|
@ -142,7 +120,6 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
it('does not add HTML #viewmode-size when only one size', function () {
|
||||
|
||||
this.xView.getSizes.returns([20]);
|
||||
this.applyFn();
|
||||
assert.lengthOf($('#viewmode-size'), 0);
|
||||
|
@ -150,9 +127,7 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
describe('works', function () {
|
||||
|
||||
it('clicking #viewmode-details triggers view.setMode(\'details\')', function () {
|
||||
|
||||
this.xView.getModes.returns(['details', 'grid', 'icons']);
|
||||
this.applyFn();
|
||||
$('#viewmode-details').trigger('click');
|
||||
|
@ -161,7 +136,6 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
it('clicking #viewmode-grid triggers view.setMode(\'grid\')', function () {
|
||||
|
||||
this.xView.getModes.returns(['details', 'grid', 'icons']);
|
||||
this.applyFn();
|
||||
$('#viewmode-grid').trigger('click');
|
||||
|
@ -170,7 +144,6 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
it('clicking #viewmode-icons triggers view.setMode(\'icons\')', function () {
|
||||
|
||||
this.xView.getModes.returns(['details', 'grid', 'icons']);
|
||||
this.applyFn();
|
||||
$('#viewmode-icons').trigger('click');
|
||||
|
@ -179,7 +152,6 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
it('changing #viewmode-size triggers view.setSize(*)', function () {
|
||||
|
||||
this.xView.getSizes.returns([20, 40, 60]);
|
||||
this.applyFn();
|
||||
|
||||
|
@ -197,7 +169,6 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
|
||||
it('inputing #viewmode-size triggers view.setSize(*)', function () {
|
||||
|
||||
this.xView.getSizes.returns([20, 40, 60]);
|
||||
this.applyFn();
|
||||
|
||||
|
@ -215,5 +186,4 @@ describe('module \'' + ID + '\'', function () {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
}());
|
||||
|
|
|
@ -1,17 +1,12 @@
|
|||
(function () {
|
||||
'use strict';
|
||||
|
||||
var assert = chai.assert;
|
||||
var assert = window.chai.assert;
|
||||
|
||||
assert.lengthOfKeys = function (val, count, msg) {
|
||||
|
||||
var keyCount = _.keys(val).length;
|
||||
assert(keyCount === count, msg ? msg : 'expected ' + val + ' to have ' + count + ' keys, but has ' + keyCount);
|
||||
};
|
||||
|
||||
assert.isPlainObject = function (val, msg) {
|
||||
|
||||
assert($.isPlainObject(val), msg ? msg : 'expected ' + val + ' to be a plain Object');
|
||||
};
|
||||
|
||||
}());
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
(function () {
|
||||
'use strict';
|
||||
|
||||
var showOnlyFailures = false;
|
||||
var template =
|
||||
'<div id="mocha-bar">' +
|
||||
|
@ -12,7 +10,6 @@ var $mochaBar = $(template);
|
|||
var $mochaStats = $mochaBar.find('.stats');
|
||||
var $mochaProgress = $mochaBar.find('.progress');
|
||||
|
||||
|
||||
function toggleFailureFilter(ev) {
|
||||
ev.stopImmediatePropagation();
|
||||
|
||||
|
@ -39,7 +36,6 @@ function addSuiteStats() {
|
|||
var visible = true;
|
||||
|
||||
$toggle.on('click', function (ev) {
|
||||
|
||||
ev.stopImmediatePropagation();
|
||||
|
||||
visible = !visible;
|
||||
|
@ -91,12 +87,12 @@ function onTest() {
|
|||
if (runner.stats.failures) {
|
||||
$mochaBar.addClass('fail');
|
||||
}
|
||||
$mochaProgress.css('width', (100 - percent) + '%');
|
||||
$mochaProgress.css('width', 100 - percent + '%');
|
||||
$mochaStats.text(stats);
|
||||
}
|
||||
|
||||
function setupMocha() {
|
||||
window.assert = chai.assert;
|
||||
window.assert = window.chai.assert;
|
||||
mocha.setup('bdd');
|
||||
$(function () { $mochaBar.appendTo('#mocha'); });
|
||||
}
|
||||
|
@ -108,5 +104,4 @@ function runMocha() {
|
|||
window.util = window.util || {};
|
||||
window.util.setupMocha = setupMocha;
|
||||
window.util.runMocha = runMocha;
|
||||
|
||||
}());
|
||||
|
|
|
@ -1,21 +1,15 @@
|
|||
(function () {
|
||||
'use strict';
|
||||
|
||||
function clearModulejs() {
|
||||
|
||||
_.each(modulejs._private.instances, function (val, key) {
|
||||
|
||||
delete modulejs._private.instances[key];
|
||||
});
|
||||
}
|
||||
|
||||
function mockConfigModule() {
|
||||
|
||||
modulejs.define('config', window.uniq.obj());
|
||||
}
|
||||
|
||||
window.util = window.util || {};
|
||||
window.util.clearModulejs = clearModulejs;
|
||||
window.util.mockConfigModule = mockConfigModule;
|
||||
|
||||
}());
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
(function () {
|
||||
'use strict';
|
||||
|
||||
var title;
|
||||
var htmlId;
|
||||
var htmlClasses;
|
||||
|
@ -9,7 +7,6 @@ var bodyClasses;
|
|||
var $pinnedElements;
|
||||
|
||||
function pinHtml() {
|
||||
|
||||
title = document.title;
|
||||
htmlId = $('html').attr('id');
|
||||
htmlClasses = $('html').attr('class');
|
||||
|
@ -19,7 +16,6 @@ function pinHtml() {
|
|||
}
|
||||
|
||||
function restoreHtml() {
|
||||
|
||||
document.title = title;
|
||||
$('html').attr('id', htmlId);
|
||||
$('html').attr('class', htmlClasses);
|
||||
|
@ -34,5 +30,4 @@ function restoreHtml() {
|
|||
window.util = window.util || {};
|
||||
window.util.pinHtml = pinHtml;
|
||||
window.util.restoreHtml = restoreHtml;
|
||||
|
||||
}());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue