mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-10-03 07:51:58 +02:00
Fix a lot eslint errors.
This commit is contained in:
@@ -7,9 +7,6 @@
|
|||||||
es6: true
|
es6: true
|
||||||
node: true
|
node: true
|
||||||
|
|
||||||
globals:
|
|
||||||
modulejs: false
|
|
||||||
|
|
||||||
ecmaFeatures:
|
ecmaFeatures:
|
||||||
arrowFunctions: true
|
arrowFunctions: true
|
||||||
binaryLiterals: true
|
binaryLiterals: true
|
||||||
@@ -68,7 +65,7 @@
|
|||||||
max-nested-callbacks: [1, 3]
|
max-nested-callbacks: [1, 3]
|
||||||
max-params: [1, 5] ###
|
max-params: [1, 5] ###
|
||||||
max-statements: [1, 80] ###
|
max-statements: [1, 80] ###
|
||||||
new-cap: 1
|
new-cap: 0
|
||||||
new-parens: 2
|
new-parens: 2
|
||||||
newline-after-var: 0
|
newline-after-var: 0
|
||||||
no-alert: 2
|
no-alert: 2
|
||||||
|
11
CHANGELOG.md
11
CHANGELOG.md
@@ -14,7 +14,8 @@
|
|||||||
* fixes preview bottom bar for small screen widths
|
* fixes preview bottom bar for small screen widths
|
||||||
* lots of code cleanup and refactorings
|
* lots of code cleanup and refactorings
|
||||||
* changes API
|
* 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 `lodash` to 3.8.0 (adds debounce and trim)
|
||||||
* updates h5bp styles to 5.1.0
|
* updates h5bp styles to 5.1.0
|
||||||
* updates `normalize.css` to 3.0.3
|
* updates `normalize.css` to 3.0.3
|
||||||
@@ -40,7 +41,7 @@
|
|||||||
* improves drag-select
|
* improves drag-select
|
||||||
* improves image preview
|
* improves image preview
|
||||||
* prevents listing `_h5ai` folder and subfolders
|
* 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` to 2.1.3
|
||||||
* updates `jQuery.qrcode` to 0.11.0
|
* updates `jQuery.qrcode` to 0.11.0
|
||||||
* updates `Lo-Dash` to 3.6.0
|
* updates `Lo-Dash` to 3.6.0
|
||||||
@@ -222,9 +223,9 @@
|
|||||||
* changes language code `gr` to `el`
|
* changes language code `gr` to `el`
|
||||||
* adds localization for filter placeholder
|
* adds localization for filter placeholder
|
||||||
* adds `hu` translation by [Rodolffo](https://github.com/Rodolffo)
|
* adds `hu` translation by [Rodolffo](https://github.com/Rodolffo)
|
||||||
* updates to [jQuery.qrcode](http://larsjung.de/qrcode/) 0.2
|
* updates to [jQuery.qrcode](https://larsjung.de/qrcode/) 0.2
|
||||||
* updates to [jQuery.scrollpanel](http://larsjung.de/scrollpanel/) 0.1
|
* updates to [jQuery.scrollpanel](https://larsjung.de/scrollpanel/) 0.1
|
||||||
* updates to [modulejs](http://larsjung.de/modulejs/) 0.2
|
* updates to [modulejs](https://larsjung.de/modulejs/) 0.2
|
||||||
* updates to [Moment.js](http://momentjs.com) 1.7.0
|
* updates to [Moment.js](http://momentjs.com) 1.7.0
|
||||||
* updates to [Underscore.js](http://underscorejs.org) 1.3.3
|
* 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)
|
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
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
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).
|
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]: https://github.com/lrsjng/h5ai
|
||||||
[github-issues]: https://github.com/lrsjng/h5ai/issues
|
[github-issues]: https://github.com/lrsjng/h5ai/issues
|
||||||
[release]: http://release.larsjung.de/h5ai/
|
[release]: https://release.larsjung.de/h5ai/
|
||||||
[develop]: http://release.larsjung.de/h5ai/develop/
|
[develop]: https://release.larsjung.de/h5ai/develop/
|
||||||
[git]: http://git-scm.com
|
[git]: https://git-scm.com
|
||||||
[node]: https://nodejs.org
|
[node]: https://nodejs.org
|
||||||
[mkr]: http://larsjung.de/mkr/
|
[mkr]: https://larsjung.de/mkr/
|
||||||
[material-design-icons]: https://github.com/google/material-design-icons
|
[material-design-icons]: https://github.com/google/material-design-icons
|
||||||
|
|
||||||
[license-img]: https://img.shields.io/badge/license-MIT-a0a060.svg?style=flat-square
|
[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 dateformat from 'dateformat';
|
||||||
import ghu from 'ghu';
|
import ghu from 'ghu';
|
||||||
import {
|
import {
|
||||||
autoprefixer, babel, cssmin, ife, includeit, jade, jszip,
|
autoprefixer, cssmin, ife, includeit, jade, jszip,
|
||||||
less, mapfn, newerThan, read, remove, run, uglify, watch, wrap, write
|
less, mapfn, newerThan, read, remove, run, uglify, watch, wrap, write
|
||||||
} from 'ghu';
|
} from 'ghu';
|
||||||
|
|
||||||
const ROOT = resolve(__dirname);
|
const ROOT = resolve(__dirname);
|
||||||
const SRC = join(ROOT, 'src');
|
const SRC = join(ROOT, 'src');
|
||||||
|
const TEST = join(ROOT, 'test');
|
||||||
const BUILD = join(ROOT, 'build');
|
const BUILD = join(ROOT, 'build');
|
||||||
|
|
||||||
const mapper = mapfn.p(SRC, BUILD).s('.less', '.css').s('.jade', '');
|
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`)
|
return read(`${SRC}/_h5ai/public/js/*.js`)
|
||||||
.then(newerThan(mapper, `${SRC}/_h5ai/public/js/**`))
|
.then(newerThan(mapper, `${SRC}/_h5ai/public/js/**`))
|
||||||
.then(includeit())
|
.then(includeit())
|
||||||
// .then(babel({compact: false}))
|
|
||||||
.then(ife(() => runtime.args.production, uglify()))
|
.then(ife(() => runtime.args.production, uglify()))
|
||||||
.then(wrap(runtime.commentJs))
|
.then(wrap(runtime.commentJs))
|
||||||
.then(write(mapper, {overwrite: true}));
|
.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 => {
|
ghu.task('build:tests', ['build:scripts', 'build:styles'], 'build the test suite', runtime => {
|
||||||
return Promise.all([
|
return Promise.all([
|
||||||
read(`${ROOT}/test/scripts.js`)
|
read(`${TEST}/scripts.js`)
|
||||||
.then(newerThan(`${BUILD}/test/scripts.js`))
|
.then(newerThan(`${BUILD}/test/scripts.js`))
|
||||||
.then(includeit())
|
.then(includeit())
|
||||||
.then(write(`${BUILD}/test/scripts.js`, {overwrite: true})),
|
.then(write(`${BUILD}/test/scripts.js`, {overwrite: true})),
|
||||||
|
|
||||||
read(`${ROOT}/test/styles.less`)
|
read(`${TEST}/styles.less`)
|
||||||
.then(newerThan(`${BUILD}/test/styles.css`))
|
.then(newerThan(`${BUILD}/test/styles.css`))
|
||||||
.then(includeit())
|
.then(includeit())
|
||||||
.then(less())
|
.then(less())
|
||||||
.then(autoprefixer())
|
.then(autoprefixer())
|
||||||
.then(write(`${BUILD}/test/styles.css`, {overwrite: true})),
|
.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(newerThan(`${BUILD}/test/index.html`))
|
||||||
.then(jade({pkg: runtime.pkg}))
|
.then(jade({pkg: runtime.pkg}))
|
||||||
.then(write(`${BUILD}/test/index.html`, {overwrite: true})),
|
.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 => {
|
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 => {
|
ghu.task('release', ['force-production', 'clean', 'build'], 'create a zipball', runtime => {
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "h5ai",
|
"name": "h5ai",
|
||||||
"version": "0.27.0",
|
"version": "0.27.0",
|
||||||
"develop": true,
|
|
||||||
"description": "A modern HTTP web server index.",
|
"description": "A modern HTTP web server index.",
|
||||||
"homepage": "https://larsjung.de/h5ai/",
|
"homepage": "https://larsjung.de/h5ai/",
|
||||||
"bugs": "https://github.com/lrsjng/h5ai/issues",
|
"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 (_) {
|
modulejs.define('core/event', ['_'], function (_) {
|
||||||
|
|
||||||
var slice = Array.prototype.slice;
|
var slice = Array.prototype.slice;
|
||||||
var subscriptions = {};
|
var subscriptions = {};
|
||||||
|
|
||||||
|
|
||||||
function sub(topic, callback) {
|
function sub(topic, callback) {
|
||||||
|
|
||||||
if (_.isString(topic) && _.isFunction(callback)) {
|
if (_.isString(topic) && _.isFunction(callback)) {
|
||||||
|
|
||||||
if (!subscriptions[topic]) {
|
if (!subscriptions[topic]) {
|
||||||
subscriptions[topic] = [];
|
subscriptions[topic] = [];
|
||||||
}
|
}
|
||||||
@@ -16,21 +12,16 @@ modulejs.define('core/event', ['_'], function (_) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function unsub(topic, callback) {
|
function unsub(topic, callback) {
|
||||||
|
|
||||||
if (_.isString(topic) && _.isFunction(callback) && subscriptions[topic]) {
|
if (_.isString(topic) && _.isFunction(callback) && subscriptions[topic]) {
|
||||||
|
|
||||||
subscriptions[topic] = _.without(subscriptions[topic], callback);
|
subscriptions[topic] = _.without(subscriptions[topic], callback);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function pub(topic) {
|
function pub(topic) {
|
||||||
|
|
||||||
var args = slice.call(arguments, 1);
|
var args = slice.call(arguments, 1);
|
||||||
|
|
||||||
if (_.isString(topic) && subscriptions[topic]) {
|
if (_.isString(topic) && subscriptions[topic]) {
|
||||||
|
|
||||||
_.each(subscriptions[topic], function (callback) {
|
_.each(subscriptions[topic], function (callback) {
|
||||||
|
|
||||||
callback.apply(topic, args);
|
callback.apply(topic, args);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
modulejs.define('core/format', ['_'], function (_) {
|
modulejs.define('core/format', ['_'], function (_) {
|
||||||
|
|
||||||
var decimalMetric = {
|
var decimalMetric = {
|
||||||
t: 1000.0,
|
t: 1000.0,
|
||||||
k: 1000.0,
|
k: 1000.0,
|
||||||
@@ -30,12 +29,10 @@ modulejs.define('core/format', ['_'], function (_) {
|
|||||||
|
|
||||||
|
|
||||||
function setDefaultMetric(useBinaryMetric) {
|
function setDefaultMetric(useBinaryMetric) {
|
||||||
|
|
||||||
defaultMetric = useBinaryMetric ? binaryMetric : decimalMetric;
|
defaultMetric = useBinaryMetric ? binaryMetric : decimalMetric;
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatSize(size, metric) {
|
function formatSize(size, metric) {
|
||||||
|
|
||||||
metric = metric || defaultMetric;
|
metric = metric || defaultMetric;
|
||||||
|
|
||||||
if (!_.isNumber(size) || size < 0) {
|
if (!_.isNumber(size) || size < 0) {
|
||||||
@@ -53,12 +50,10 @@ modulejs.define('core/format', ['_'], function (_) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setDefaultDateFormat(dateFormat) {
|
function setDefaultDateFormat(dateFormat) {
|
||||||
|
|
||||||
defaultDateFormat = dateFormat;
|
defaultDateFormat = dateFormat;
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatNumber(number, padding) {
|
function formatNumber(number, padding) {
|
||||||
|
|
||||||
var str = String(number);
|
var str = String(number);
|
||||||
if (padding) {
|
if (padding) {
|
||||||
str = ('000' + str).substr(-padding);
|
str = ('000' + str).substr(-padding);
|
||||||
@@ -67,7 +62,6 @@ modulejs.define('core/format', ['_'], function (_) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function formatDate(millis, format) {
|
function formatDate(millis, format) {
|
||||||
|
|
||||||
if (!millis || !_.isNumber(millis)) {
|
if (!millis || !_.isNumber(millis)) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,3 @@
|
|||||||
modulejs.define('core/langs', ['_', 'config'], function (_, config) {
|
modulejs.define('core/langs', ['_', 'config'], function (_, config) {
|
||||||
|
|
||||||
return _.extend({}, config.langs);
|
return _.extend({}, config.langs);
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
modulejs.define('core/location', ['_', 'core/event', 'core/modernizr', 'core/settings', 'view/notification'], function (_, event, modernizr, allsettings, notification) {
|
modulejs.define('core/location', ['_', 'core/event', 'core/modernizr', 'core/settings', 'view/notification'], function (_, event, modernizr, allsettings, notification) {
|
||||||
|
|
||||||
var settings = _.extend({
|
var settings = _.extend({
|
||||||
fastBrowsing: true,
|
fastBrowsing: true,
|
||||||
unmanagedInNewWindow: true
|
unmanagedInNewWindow: true
|
||||||
@@ -23,7 +22,7 @@ modulejs.define('core/location', ['_', 'core/event', 'core/modernizr', 'core/set
|
|||||||
[/\,/g, '%2C'],
|
[/\,/g, '%2C'],
|
||||||
[/:/g, '%3A'],
|
[/:/g, '%3A'],
|
||||||
[/;/g, '%3B'],
|
[/;/g, '%3B'],
|
||||||
[/=/g, '%3D'],
|
[/\=/g, '%3D'],
|
||||||
[/\?/g, '%3F'],
|
[/\?/g, '%3F'],
|
||||||
[/@/g, '%40'],
|
[/@/g, '%40'],
|
||||||
[/\[/g, '%5B'],
|
[/\[/g, '%5B'],
|
||||||
@@ -31,20 +30,16 @@ modulejs.define('core/location', ['_', 'core/event', 'core/modernizr', 'core/set
|
|||||||
];
|
];
|
||||||
|
|
||||||
function forceEncoding(href) {
|
function forceEncoding(href) {
|
||||||
|
return reForceEncoding.reduce(function (nuHref, data) {
|
||||||
return reForceEncoding.reduce(function (href, data) {
|
return nuHref.replace(data[0], data[1]);
|
||||||
|
|
||||||
return href.replace(data[0], data[1]);
|
|
||||||
}, href);
|
}, href);
|
||||||
}
|
}
|
||||||
|
|
||||||
function uriToPathname(uri) {
|
function uriToPathname(uri) {
|
||||||
|
|
||||||
return uri.replace(reUriToPathname, '');
|
return uri.replace(reUriToPathname, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
var hrefsAreDecoded = (function () {
|
var hrefsAreDecoded = (function () {
|
||||||
|
|
||||||
var testpathname = '/a b';
|
var testpathname = '/a b';
|
||||||
var a = doc.createElement('a');
|
var a = doc.createElement('a');
|
||||||
|
|
||||||
@@ -53,7 +48,6 @@ modulejs.define('core/location', ['_', 'core/event', 'core/modernizr', 'core/set
|
|||||||
}());
|
}());
|
||||||
|
|
||||||
function encodedHref(href) {
|
function encodedHref(href) {
|
||||||
|
|
||||||
var a = doc.createElement('a');
|
var a = doc.createElement('a');
|
||||||
var location;
|
var location;
|
||||||
|
|
||||||
@@ -68,39 +62,31 @@ modulejs.define('core/location', ['_', 'core/event', 'core/modernizr', 'core/set
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getDomain() {
|
function getDomain() {
|
||||||
|
|
||||||
return doc.domain;
|
return doc.domain;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAbsHref() {
|
function getAbsHref() {
|
||||||
|
|
||||||
return absHref;
|
return absHref;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getItem() {
|
function getItem() {
|
||||||
|
|
||||||
return modulejs.require('model/item').get(absHref);
|
return modulejs.require('model/item').get(absHref);
|
||||||
}
|
}
|
||||||
|
|
||||||
function load(callback) {
|
function load(callback) {
|
||||||
|
|
||||||
modulejs.require('core/server').request({action: 'get', items: {href: absHref, what: 1}}, function (json) {
|
modulejs.require('core/server').request({action: 'get', items: {href: absHref, what: 1}}, function (json) {
|
||||||
|
|
||||||
var Item = modulejs.require('model/item');
|
var Item = modulejs.require('model/item');
|
||||||
var item = Item.get(absHref);
|
var item = Item.get(absHref);
|
||||||
|
|
||||||
if (json) {
|
if (json) {
|
||||||
|
|
||||||
var found = {};
|
var found = {};
|
||||||
|
|
||||||
_.each(json.items, function (jsonItem) {
|
_.each(json.items, function (jsonItem) {
|
||||||
|
|
||||||
var e = Item.get(jsonItem);
|
var e = Item.get(jsonItem);
|
||||||
found[e.absHref] = true;
|
found[e.absHref] = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
_.each(item.content, function (e) {
|
_.each(item.content, function (e) {
|
||||||
|
|
||||||
if (!found[e.absHref]) {
|
if (!found[e.absHref]) {
|
||||||
Item.remove(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');
|
event.pub('location.beforeChange');
|
||||||
|
|
||||||
newAbsHref = encodedHref(newAbsHref);
|
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) {
|
function setLink($el, item) {
|
||||||
|
|
||||||
$el.attr('href', item.absHref);
|
$el.attr('href', item.absHref);
|
||||||
|
|
||||||
if (history && item.isFolder() && item.isManaged) {
|
if (history && item.isFolder() && item.isManaged) {
|
||||||
$el.on('click', function () {
|
$el.on('click', function () {
|
||||||
|
|
||||||
setLocation(item.absHref);
|
setLocation(item.absHref);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
@@ -179,7 +160,6 @@ modulejs.define('core/location', ['_', 'core/event', 'core/modernizr', 'core/set
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onPopState(ev) {
|
function onPopState(ev) {
|
||||||
|
|
||||||
if (ev.state && ev.state.absHref) {
|
if (ev.state && ev.state.absHref) {
|
||||||
setLocation(ev.state.absHref, true);
|
setLocation(ev.state.absHref, true);
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,5 @@
|
|||||||
modulejs.define('core/modernizr', function () {
|
modulejs.define('core/modernizr', function () {
|
||||||
|
|
||||||
var hasCanvas = (function () {
|
var hasCanvas = (function () {
|
||||||
|
|
||||||
var elem = document.createElement('canvas');
|
var elem = document.createElement('canvas');
|
||||||
return Boolean(elem.getContext && elem.getContext('2d'));
|
return Boolean(elem.getContext && elem.getContext('2d'));
|
||||||
}());
|
}());
|
||||||
@@ -9,7 +7,6 @@ modulejs.define('core/modernizr', function () {
|
|||||||
var hasHistory = Boolean(window.history && history.pushState);
|
var hasHistory = Boolean(window.history && history.pushState);
|
||||||
|
|
||||||
var hasLocalStorage = (function () {
|
var hasLocalStorage = (function () {
|
||||||
|
|
||||||
var key = '#test#';
|
var key = '#test#';
|
||||||
try {
|
try {
|
||||||
localStorage.setItem(key, key);
|
localStorage.setItem(key, key);
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
modulejs.define('core/resource', ['_', 'config', 'core/settings'], function (_, config, settings) {
|
modulejs.define('core/resource', ['_', 'config', 'core/settings'], function (_, config, settings) {
|
||||||
|
|
||||||
var imagesHref = settings.publicHref + 'images/';
|
var imagesHref = settings.publicHref + 'images/';
|
||||||
var uiHref = imagesHref + 'ui/';
|
var uiHref = imagesHref + 'ui/';
|
||||||
var themesHref = imagesHref + 'themes/';
|
var themesHref = imagesHref + 'themes/';
|
||||||
@@ -8,12 +7,10 @@ modulejs.define('core/resource', ['_', 'config', 'core/settings'], function (_,
|
|||||||
|
|
||||||
|
|
||||||
function image(id) {
|
function image(id) {
|
||||||
|
|
||||||
return uiHref + id + '.svg';
|
return uiHref + id + '.svg';
|
||||||
}
|
}
|
||||||
|
|
||||||
function icon(id) {
|
function icon(id) {
|
||||||
|
|
||||||
var baseId = (id || '').split('-')[0];
|
var baseId = (id || '').split('-')[0];
|
||||||
var href = config.theme[id] || config.theme[baseId];
|
var href = config.theme[id] || config.theme[baseId];
|
||||||
|
|
||||||
|
@@ -1,7 +1,5 @@
|
|||||||
modulejs.define('core/server', ['_', '$'], function (_, $) {
|
modulejs.define('core/server', ['_', '$'], function (_, $) {
|
||||||
|
|
||||||
function request(data, callback) {
|
function request(data, callback) {
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '?',
|
url: '?',
|
||||||
data: data,
|
data: data,
|
||||||
@@ -9,21 +7,17 @@ modulejs.define('core/server', ['_', '$'], function (_, $) {
|
|||||||
dataType: 'json'
|
dataType: 'json'
|
||||||
})
|
})
|
||||||
.done(function (json) {
|
.done(function (json) {
|
||||||
|
|
||||||
callback(json);
|
callback(json);
|
||||||
})
|
})
|
||||||
.fail(function () {
|
.fail(function () {
|
||||||
|
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function formRequest(data) {
|
function formRequest(data) {
|
||||||
|
|
||||||
var $form = $('<form method="post" action="?" style="display:none;"/>');
|
var $form = $('<form method="post" action="?" style="display:none;"/>');
|
||||||
|
|
||||||
_.each(data, function (val, key) {
|
_.each(data, function (val, key) {
|
||||||
|
|
||||||
$('<input type="hidden"/>')
|
$('<input type="hidden"/>')
|
||||||
.attr('name', key)
|
.attr('name', key)
|
||||||
.attr('value', val)
|
.attr('value', val)
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
modulejs.define('core/settings', ['_', 'config'], function (_, config) {
|
modulejs.define('core/settings', ['_', 'config'], function (_, config) {
|
||||||
|
|
||||||
return _.extend({}, config.options, {
|
return _.extend({}, config.options, {
|
||||||
publicHref: config.setup.PUBLIC_HREF,
|
publicHref: config.setup.PUBLIC_HREF,
|
||||||
rootHref: config.setup.ROOT_HREF
|
rootHref: config.setup.ROOT_HREF
|
||||||
|
@@ -1,31 +1,26 @@
|
|||||||
modulejs.define('core/store', ['core/modernizr'], function (modernizr) {
|
modulejs.define('core/store', ['core/modernizr'], function (modernizr) {
|
||||||
|
|
||||||
var store = modernizr.localstorage ? window.localStorage : {};
|
var store = modernizr.localstorage ? window.localStorage : {};
|
||||||
var storekey = '_h5ai';
|
var storekey = '_h5ai';
|
||||||
|
|
||||||
|
|
||||||
function load() {
|
function load() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return JSON.parse(store[storekey]);
|
return JSON.parse(store[storekey]);
|
||||||
} catch (e) {}
|
} catch (e) {/* skip */}
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
function save(obj) {
|
function save(obj) {
|
||||||
|
|
||||||
store[storekey] = JSON.stringify(obj);
|
store[storekey] = JSON.stringify(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
function put(key, value) {
|
function put(key, value) {
|
||||||
|
|
||||||
var obj = load();
|
var obj = load();
|
||||||
obj[key] = value;
|
obj[key] = value;
|
||||||
save(obj);
|
save(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
function get(key) {
|
function get(key) {
|
||||||
|
|
||||||
return load()[key];
|
return load()[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,26 +1,21 @@
|
|||||||
modulejs.define('core/types', ['_', 'config'], function (_, config) {
|
modulejs.define('core/types', ['_', 'config'], function (_, config) {
|
||||||
|
|
||||||
var reEndsWithSlash = /\/$/;
|
var reEndsWithSlash = /\/$/;
|
||||||
var regexps = {};
|
var regexps = {};
|
||||||
|
|
||||||
|
|
||||||
function escapeRegExp(sequence) {
|
function escapeRegExp(sequence) {
|
||||||
|
|
||||||
return sequence.replace(/[\-\[\]\/\{\}\(\)\+\?\.\\\^\$]/g, '\\$&');
|
return sequence.replace(/[\-\[\]\/\{\}\(\)\+\?\.\\\^\$]/g, '\\$&');
|
||||||
// return sequence.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
|
// return sequence.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
|
||||||
}
|
}
|
||||||
|
|
||||||
function parse(types) {
|
function parse(types) {
|
||||||
|
|
||||||
_.each(types, function (patterns, type) {
|
_.each(types, function (patterns, type) {
|
||||||
|
|
||||||
var pattern = '^(' + _.map(patterns, function (p) { return '(' + escapeRegExp(p).replace(/\*/g, '.*') + ')'; }).join('|') + ')$';
|
var pattern = '^(' + _.map(patterns, function (p) { return '(' + escapeRegExp(p).replace(/\*/g, '.*') + ')'; }).join('|') + ')$';
|
||||||
regexps[type] = new RegExp(pattern, 'i');
|
regexps[type] = new RegExp(pattern, 'i');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function getType(sequence) {
|
function getType(sequence) {
|
||||||
|
|
||||||
if (reEndsWithSlash.test(sequence)) {
|
if (reEndsWithSlash.test(sequence)) {
|
||||||
return 'folder';
|
return 'folder';
|
||||||
}
|
}
|
||||||
@@ -30,7 +25,6 @@ modulejs.define('core/types', ['_', 'config'], function (_, config) {
|
|||||||
var result;
|
var result;
|
||||||
|
|
||||||
_.each(regexps, function (regexp, type) {
|
_.each(regexps, function (regexp, type) {
|
||||||
|
|
||||||
if (regexps[type].test(name)) {
|
if (regexps[type].test(name)) {
|
||||||
result = type;
|
result = type;
|
||||||
return false;
|
return false;
|
||||||
|
@@ -1,8 +1,5 @@
|
|||||||
modulejs.define('core/util', ['_'], function (_) {
|
modulejs.define('core/util', ['_'], function (_) {
|
||||||
|
|
||||||
|
|
||||||
function regularCmpFn(val1, val2) {
|
function regularCmpFn(val1, val2) {
|
||||||
|
|
||||||
if (val1 < val2) {
|
if (val1 < val2) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -17,7 +14,6 @@ modulejs.define('core/util', ['_'], function (_) {
|
|||||||
//
|
//
|
||||||
// Modified to make it work with h5ai
|
// Modified to make it work with h5ai
|
||||||
function naturalCmpFn(val1, val2) {
|
function naturalCmpFn(val1, val2) {
|
||||||
|
|
||||||
var re = /(^-?[0-9]+(\.?[0-9]*)[df]?e?[0-9]?$|^0x[0-9a-f]+$|[0-9]+)/gi;
|
var re = /(^-?[0-9]+(\.?[0-9]*)[df]?e?[0-9]?$|^0x[0-9a-f]+$|[0-9]+)/gi;
|
||||||
var sre = /(^[ ]*|[ ]*$)/g;
|
var sre = /(^[ ]*|[ ]*$)/g;
|
||||||
var dre = /(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/;
|
var 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 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');
|
var yN = y.replace(re, '\0$1\0').replace(/\0$/, '').replace(/^\0/, '').split('\0');
|
||||||
// numeric, hex or date detection
|
// 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 yD = parseInt(y.match(hre), 10) || xD && y.match(dre) && Date.parse(y) || null;
|
||||||
var oFxNcL;
|
var oFxNcL;
|
||||||
var oFyNcL;
|
var oFyNcL;
|
||||||
@@ -49,7 +45,7 @@ modulejs.define('core/util', ['_'], function (_) {
|
|||||||
oFyNcL = !(yN[cLoc] || '').match(ore) && parseFloat(yN[cLoc]) || yN[cLoc] || 0;
|
oFyNcL = !(yN[cLoc] || '').match(ore) && parseFloat(yN[cLoc]) || yN[cLoc] || 0;
|
||||||
// handle numeric vs string comparison - number < string - (Kyle Adams)
|
// handle numeric vs string comparison - number < string - (Kyle Adams)
|
||||||
if (isNaN(oFxNcL) !== isNaN(oFyNcL)) {
|
if (isNaN(oFxNcL) !== isNaN(oFyNcL)) {
|
||||||
return (isNaN(oFxNcL)) ? 1 : -1;
|
return isNaN(oFxNcL) ? 1 : -1;
|
||||||
} else if (typeof oFxNcL !== typeof oFyNcL) {
|
} else if (typeof oFxNcL !== typeof oFyNcL) {
|
||||||
// rely on string comparison if different types - i.e. '02' < 2 != '02' < '2'
|
// rely on string comparison if different types - i.e. '02' < 2 != '02' < '2'
|
||||||
oFxNcL += '';
|
oFxNcL += '';
|
||||||
@@ -66,12 +62,10 @@ modulejs.define('core/util', ['_'], function (_) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function escapePattern(sequence) {
|
function escapePattern(sequence) {
|
||||||
|
|
||||||
return sequence.replace(/[\-\[\]{}()*+?.,\\$\^|#\s]/g, '\\$&');
|
return sequence.replace(/[\-\[\]{}()*+?.,\\$\^|#\s]/g, '\\$&');
|
||||||
}
|
}
|
||||||
|
|
||||||
function parsePattern(sequence, advanced) {
|
function parsePattern(sequence, advanced) {
|
||||||
|
|
||||||
if (!advanced) {
|
if (!advanced) {
|
||||||
return escapePattern(sequence);
|
return escapePattern(sequence);
|
||||||
}
|
}
|
||||||
@@ -81,9 +75,7 @@ modulejs.define('core/util', ['_'], function (_) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sequence = _.map(_.trim(sequence).split(/\s+/), function (part) {
|
sequence = _.map(_.trim(sequence).split(/\s+/), function (part) {
|
||||||
|
|
||||||
return _.map(part.split(''), function (character) {
|
return _.map(part.split(''), function (character) {
|
||||||
|
|
||||||
return escapePattern(character);
|
return escapePattern(character);
|
||||||
}).join('.*?');
|
}).join('.*?');
|
||||||
}).join('|');
|
}).join('|');
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
modulejs.define('ext/autorefresh', ['_', '$', 'core/event', 'core/location', 'core/settings'], function (_, $, event, location, allsettings) {
|
modulejs.define('ext/autorefresh', ['_', '$', 'core/event', 'core/location', 'core/settings'], function (_, $, event, location, allsettings) {
|
||||||
|
|
||||||
var settings = _.extend({
|
var settings = _.extend({
|
||||||
enabled: false,
|
enabled: false,
|
||||||
interval: 5000
|
interval: 5000
|
||||||
@@ -8,23 +7,19 @@ modulejs.define('ext/autorefresh', ['_', '$', 'core/event', 'core/location', 'co
|
|||||||
|
|
||||||
|
|
||||||
function heartbeat() {
|
function heartbeat() {
|
||||||
|
|
||||||
location.refresh();
|
location.refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
function before() {
|
function before() {
|
||||||
|
|
||||||
clearTimeout(timeoutId);
|
clearTimeout(timeoutId);
|
||||||
}
|
}
|
||||||
|
|
||||||
function after() {
|
function after() {
|
||||||
|
|
||||||
clearTimeout(timeoutId);
|
clearTimeout(timeoutId);
|
||||||
timeoutId = setTimeout(heartbeat, settings.interval);
|
timeoutId = setTimeout(heartbeat, settings.interval);
|
||||||
}
|
}
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
|
|
||||||
if (!settings.enabled) {
|
if (!settings.enabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
modulejs.define('ext/contextmenu', ['_', '$', 'core/resource', 'core/settings'], function (_, $, resource, allsettings) {
|
modulejs.define('ext/contextmenu', ['_', '$', 'core/resource', 'core/settings'], function (_, $, resource, allsettings) {
|
||||||
|
|
||||||
var settings = _.extend({
|
var settings = _.extend({
|
||||||
enabled: false
|
enabled: false
|
||||||
}, allsettings.contextmenu);
|
}, allsettings.contextmenu);
|
||||||
@@ -11,12 +10,10 @@ modulejs.define('ext/contextmenu', ['_', '$', 'core/resource', 'core/settings'],
|
|||||||
|
|
||||||
|
|
||||||
function createOverlay(callback) {
|
function createOverlay(callback) {
|
||||||
|
|
||||||
var $overlay = $(templateOverlay);
|
var $overlay = $(templateOverlay);
|
||||||
|
|
||||||
$overlay
|
$overlay
|
||||||
.on('click contextmenu', function (ev) {
|
.on('click contextmenu', function (ev) {
|
||||||
|
|
||||||
ev.stopPropagation();
|
ev.stopPropagation();
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
|
|
||||||
@@ -32,20 +29,16 @@ modulejs.define('ext/contextmenu', ['_', '$', 'core/resource', 'core/settings'],
|
|||||||
}
|
}
|
||||||
|
|
||||||
function createPanel(menu) {
|
function createPanel(menu) {
|
||||||
|
|
||||||
var $panel = $(templatePanel);
|
var $panel = $(templatePanel);
|
||||||
var $ul = $panel.find('ul');
|
var $ul = $panel.find('ul');
|
||||||
var $li;
|
var $li;
|
||||||
|
|
||||||
_.each(menu, function (entry) {
|
_.each(menu, function (entry) {
|
||||||
|
|
||||||
if (entry.type === '-') {
|
if (entry.type === '-') {
|
||||||
$(templateSep).appendTo($ul);
|
$(templateSep).appendTo($ul);
|
||||||
|
|
||||||
} else if (entry.type === 'l') {
|
} else if (entry.type === 'l') {
|
||||||
$(templateLabel).appendTo($ul)
|
$(templateLabel).appendTo($ul)
|
||||||
.find('.cm-text').text(entry.text);
|
.find('.cm-text').text(entry.text);
|
||||||
|
|
||||||
} else if (entry.type === 'e') {
|
} else if (entry.type === 'e') {
|
||||||
$li = $(templateEntry).appendTo($ul);
|
$li = $(templateEntry).appendTo($ul);
|
||||||
$li.data('cm-id', entry.id);
|
$li.data('cm-id', entry.id);
|
||||||
@@ -62,7 +55,6 @@ modulejs.define('ext/contextmenu', ['_', '$', 'core/resource', 'core/settings'],
|
|||||||
}
|
}
|
||||||
|
|
||||||
function positionPanel($overlay, $panel, x, y) {
|
function positionPanel($overlay, $panel, x, y) {
|
||||||
|
|
||||||
var margin = 4;
|
var margin = 4;
|
||||||
|
|
||||||
$panel.css({
|
$panel.css({
|
||||||
@@ -123,7 +115,6 @@ modulejs.define('ext/contextmenu', ['_', '$', 'core/resource', 'core/settings'],
|
|||||||
}
|
}
|
||||||
|
|
||||||
function showMenuAt(x, y, menu, callback) {
|
function showMenuAt(x, y, menu, callback) {
|
||||||
|
|
||||||
var $overlay = createOverlay(callback);
|
var $overlay = createOverlay(callback);
|
||||||
var $panel = createPanel(menu);
|
var $panel = createPanel(menu);
|
||||||
$overlay.append($panel).appendTo('body');
|
$overlay.append($panel).appendTo('body');
|
||||||
@@ -131,20 +122,17 @@ modulejs.define('ext/contextmenu', ['_', '$', 'core/resource', 'core/settings'],
|
|||||||
}
|
}
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
|
|
||||||
// settings.enabled = true;
|
// settings.enabled = true;
|
||||||
if (!settings.enabled) {
|
if (!settings.enabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).on('contextmenu', function (ev) {
|
$(document).on('contextmenu', function (ev) {
|
||||||
|
|
||||||
ev.stopPropagation();
|
ev.stopPropagation();
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
$(ev.target).trigger($.Event('h5ai-contextmenu', {
|
$(ev.target).trigger($.Event('h5ai-contextmenu', {
|
||||||
originalEvent: ev,
|
originalEvent: ev,
|
||||||
showMenu: function (menu, callback) {
|
showMenu: function (menu, callback) {
|
||||||
|
|
||||||
showMenuAt(ev.pageX, ev.pageY, 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) {
|
modulejs.define('ext/crumb', ['_', '$', 'core/event', 'core/location', 'core/resource', 'core/settings', 'view/topbar'], function (_, $, event, location, resource, allsettings, topbar) {
|
||||||
|
|
||||||
var settings = _.extend({
|
var settings = _.extend({
|
||||||
enabled: false
|
enabled: false
|
||||||
}, allsettings.crumb);
|
}, allsettings.crumb);
|
||||||
@@ -13,7 +12,6 @@ modulejs.define('ext/crumb', ['_', '$', 'core/event', 'core/location', 'core/res
|
|||||||
|
|
||||||
|
|
||||||
function createHtml(item) {
|
function createHtml(item) {
|
||||||
|
|
||||||
var $html = $(crumbTemplate).data('item', item);
|
var $html = $(crumbTemplate).data('item', item);
|
||||||
item.$crumb = $html;
|
item.$crumb = $html;
|
||||||
location.setLink($html, item);
|
location.setLink($html, item);
|
||||||
@@ -32,7 +30,6 @@ modulejs.define('ext/crumb', ['_', '$', 'core/event', 'core/location', 'core/res
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onLocationChanged(item) {
|
function onLocationChanged(item) {
|
||||||
|
|
||||||
var $crumb = item.$crumb;
|
var $crumb = item.$crumb;
|
||||||
|
|
||||||
if ($crumb && $crumb.parent()[0] === $crumbbar[0]) {
|
if ($crumb && $crumb.parent()[0] === $crumbbar[0]) {
|
||||||
@@ -40,14 +37,13 @@ modulejs.define('ext/crumb', ['_', '$', 'core/event', 'core/location', 'core/res
|
|||||||
$crumb.addClass('active');
|
$crumb.addClass('active');
|
||||||
} else {
|
} else {
|
||||||
$crumbbar.empty();
|
$crumbbar.empty();
|
||||||
_.each(item.getCrumb(), function (item) {
|
_.each(item.getCrumb(), function (crumbItem) {
|
||||||
$crumbbar.append(createHtml(item));
|
$crumbbar.append(createHtml(crumbItem));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
|
|
||||||
if (!settings.enabled) {
|
if (!settings.enabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
modulejs.define('ext/custom', ['_', '$', 'marked', 'core/event', 'core/server', 'core/settings'], function (_, $, marked, event, server, allsettings) {
|
modulejs.define('ext/custom', ['_', '$', 'marked', 'core/event', 'core/server', 'core/settings'], function (_, $, marked, event, server, allsettings) {
|
||||||
|
|
||||||
var settings = _.extend({
|
var settings = _.extend({
|
||||||
enabled: false
|
enabled: false
|
||||||
}, allsettings.custom);
|
}, allsettings.custom);
|
||||||
@@ -9,9 +8,7 @@ modulejs.define('ext/custom', ['_', '$', 'marked', 'core/event', 'core/server',
|
|||||||
|
|
||||||
|
|
||||||
function onLocationChanged(item) {
|
function onLocationChanged(item) {
|
||||||
|
|
||||||
server.request({action: 'get', custom: item.absHref}, function (response) {
|
server.request({action: 'get', custom: item.absHref}, function (response) {
|
||||||
|
|
||||||
var custom = response && response.custom;
|
var custom = response && response.custom;
|
||||||
var hasHeader;
|
var hasHeader;
|
||||||
var hasFooter;
|
var hasFooter;
|
||||||
@@ -50,7 +47,6 @@ modulejs.define('ext/custom', ['_', '$', 'marked', 'core/event', 'core/server',
|
|||||||
}
|
}
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
|
|
||||||
if (!settings.enabled) {
|
if (!settings.enabled) {
|
||||||
return;
|
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) {
|
modulejs.define('ext/download', ['_', '$', 'core/event', 'core/location', 'core/resource', 'core/server', 'core/settings'], function (_, $, event, location, resource, server, allsettings) {
|
||||||
|
|
||||||
var settings = _.extend({
|
var settings = _.extend({
|
||||||
enabled: false,
|
enabled: false,
|
||||||
type: 'php-tar',
|
type: 'php-tar',
|
||||||
@@ -15,7 +14,6 @@ modulejs.define('ext/download', ['_', '$', 'core/event', 'core/location', 'core/
|
|||||||
|
|
||||||
|
|
||||||
function onSelection(items) {
|
function onSelection(items) {
|
||||||
|
|
||||||
selectedItems = items.slice(0);
|
selectedItems = items.slice(0);
|
||||||
if (selectedItems.length) {
|
if (selectedItems.length) {
|
||||||
$download.show();
|
$download.show();
|
||||||
@@ -25,10 +23,9 @@ modulejs.define('ext/download', ['_', '$', 'core/event', 'core/location', 'core/
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onClick() {
|
function onClick() {
|
||||||
|
|
||||||
var type = settings.type;
|
var type = settings.type;
|
||||||
var name = settings.packageName;
|
var name = settings.packageName;
|
||||||
var extension = (type === 'shell-zip') ? 'zip' : 'tar';
|
var extension = type === 'shell-zip' ? 'zip' : 'tar';
|
||||||
|
|
||||||
if (!name) {
|
if (!name) {
|
||||||
if (selectedItems.length === 1) {
|
if (selectedItems.length === 1) {
|
||||||
@@ -46,7 +43,6 @@ modulejs.define('ext/download', ['_', '$', 'core/event', 'core/location', 'core/
|
|||||||
};
|
};
|
||||||
|
|
||||||
_.each(selectedItems, function (item, idx) {
|
_.each(selectedItems, function (item, idx) {
|
||||||
|
|
||||||
query['hrefs[' + idx + ']'] = item.absHref;
|
query['hrefs[' + idx + ']'] = item.absHref;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -54,7 +50,6 @@ modulejs.define('ext/download', ['_', '$', 'core/event', 'core/location', 'core/
|
|||||||
}
|
}
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
|
|
||||||
if (!settings.enabled) {
|
if (!settings.enabled) {
|
||||||
return;
|
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) {
|
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({
|
var settings = _.extend({
|
||||||
enabled: false,
|
enabled: false,
|
||||||
advanced: false,
|
advanced: false,
|
||||||
@@ -17,7 +16,6 @@ modulejs.define('ext/filter', ['_', '$', 'core/event', 'core/location', 'core/re
|
|||||||
|
|
||||||
|
|
||||||
function filter(pattern) {
|
function filter(pattern) {
|
||||||
|
|
||||||
pattern = pattern || '';
|
pattern = pattern || '';
|
||||||
if (pattern === prevPattern) {
|
if (pattern === prevPattern) {
|
||||||
return;
|
return;
|
||||||
@@ -35,7 +33,6 @@ modulejs.define('ext/filter', ['_', '$', 'core/event', 'core/location', 'core/re
|
|||||||
var matchedItems = [];
|
var matchedItems = [];
|
||||||
|
|
||||||
_.each(location.getItem().content, function (item) {
|
_.each(location.getItem().content, function (item) {
|
||||||
|
|
||||||
if (re.test(item.label)) {
|
if (re.test(item.label)) {
|
||||||
matchedItems.push(item);
|
matchedItems.push(item);
|
||||||
}
|
}
|
||||||
@@ -47,7 +44,6 @@ modulejs.define('ext/filter', ['_', '$', 'core/event', 'core/location', 'core/re
|
|||||||
}
|
}
|
||||||
|
|
||||||
function update() {
|
function update() {
|
||||||
|
|
||||||
if (inputIsVisible) {
|
if (inputIsVisible) {
|
||||||
$filter.addClass('active');
|
$filter.addClass('active');
|
||||||
$input.focus();
|
$input.focus();
|
||||||
@@ -59,20 +55,17 @@ modulejs.define('ext/filter', ['_', '$', 'core/event', 'core/location', 'core/re
|
|||||||
}
|
}
|
||||||
|
|
||||||
function toggle() {
|
function toggle() {
|
||||||
|
|
||||||
inputIsVisible = !inputIsVisible;
|
inputIsVisible = !inputIsVisible;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
function reset() {
|
function reset() {
|
||||||
|
|
||||||
inputIsVisible = false;
|
inputIsVisible = false;
|
||||||
$input.val('');
|
$input.val('');
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
|
|
||||||
if (!settings.enabled) {
|
if (!settings.enabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -1,49 +1,37 @@
|
|||||||
modulejs.define('ext/google-analytics-ua', ['_', 'core/event', 'core/settings'], function (_, event, allsettings) {
|
modulejs.define('ext/google-analytics-ua', ['_', 'core/event', 'core/settings'], function (_, event, allsettings) {
|
||||||
|
|
||||||
var settings = _.extend({
|
var settings = _.extend({
|
||||||
enabled: false,
|
enabled: false,
|
||||||
id: 'UA-000000-0'
|
id: 'UA-000000-0'
|
||||||
}, allsettings['google-analytics-ua']);
|
}, allsettings['google-analytics-ua']);
|
||||||
var win = window;
|
|
||||||
var doc = document;
|
|
||||||
var scriptLiteral = 'script';
|
|
||||||
var id = 'h5ai-ga';
|
|
||||||
|
|
||||||
|
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() {
|
function init() {
|
||||||
|
|
||||||
if (!settings.enabled) {
|
if (!settings.enabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var el;
|
snippet();
|
||||||
var firstScriptElement;
|
|
||||||
|
|
||||||
win.GoogleAnalyticsObject = id;
|
var WIN = window;
|
||||||
win[id] = win[id] || function () {
|
var GA = 'ga';
|
||||||
(win[id].q = win[id].q || []).push(arguments);
|
WIN[GA]('create', settings.id, 'auto');
|
||||||
};
|
|
||||||
win[id].l = 1 * new Date();
|
|
||||||
|
|
||||||
el = doc.createElement(scriptLiteral);
|
|
||||||
el.async = true;
|
|
||||||
el.src = '//www.google-analytics.com/analytics.js';
|
|
||||||
|
|
||||||
firstScriptElement = doc.getElementsByTagName(scriptLiteral)[0];
|
|
||||||
firstScriptElement.parentNode.insertBefore(el, firstScriptElement);
|
|
||||||
|
|
||||||
win[id]('create', settings.id, 'auto');
|
|
||||||
|
|
||||||
event.sub('location.changed', function (item) {
|
event.sub('location.changed', function (item) {
|
||||||
|
var loc = WIN.location;
|
||||||
var loc = win.location;
|
WIN[GA]('send', 'pageview', {
|
||||||
win[id]('send', 'pageview', {
|
|
||||||
location: loc.protocol + '//' + loc.host + item.absHref,
|
location: loc.protocol + '//' + loc.host + item.absHref,
|
||||||
title: _.pluck(item.getCrumb(), 'label').join(' > ')
|
title: _.pluck(item.getCrumb(), 'label').join(' > ')
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
init();
|
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) {
|
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({
|
var settings = _.extend({
|
||||||
enabled: false,
|
enabled: false,
|
||||||
show: false,
|
show: false,
|
||||||
@@ -40,7 +39,6 @@ modulejs.define('ext/info', ['_', '$', 'core/event', 'core/format', 'core/modern
|
|||||||
|
|
||||||
|
|
||||||
function updateSettings() {
|
function updateSettings() {
|
||||||
|
|
||||||
if (store.get(storekey)) {
|
if (store.get(storekey)) {
|
||||||
$('#view-info').addClass('active');
|
$('#view-info').addClass('active');
|
||||||
$('#info').show();
|
$('#info').show();
|
||||||
@@ -51,7 +49,6 @@ modulejs.define('ext/info', ['_', '$', 'core/event', 'core/format', 'core/modern
|
|||||||
}
|
}
|
||||||
|
|
||||||
function update(item) {
|
function update(item) {
|
||||||
|
|
||||||
var src = item.thumbRational || item.icon;
|
var src = item.thumbRational || item.icon;
|
||||||
var isThumb = Boolean(item.thumbRational);
|
var isThumb = Boolean(item.thumbRational);
|
||||||
|
|
||||||
@@ -101,23 +98,19 @@ modulejs.define('ext/info', ['_', '$', 'core/event', 'core/format', 'core/modern
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onMouseenter(item) {
|
function onMouseenter(item) {
|
||||||
|
|
||||||
update(item);
|
update(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onMouseleave() {
|
function onMouseleave() {
|
||||||
|
|
||||||
update(currentFolder);
|
update(currentFolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onLocationChanged(item) {
|
function onLocationChanged(item) {
|
||||||
|
|
||||||
currentFolder = item;
|
currentFolder = item;
|
||||||
update(currentFolder);
|
update(currentFolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
|
|
||||||
if (!settings.enabled) {
|
if (!settings.enabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -140,14 +133,13 @@ modulejs.define('ext/info', ['_', '$', 'core/event', 'core/format', 'core/modern
|
|||||||
.appendTo('#sidebar')
|
.appendTo('#sidebar')
|
||||||
.find('#view-info')
|
.find('#view-info')
|
||||||
.on('click', function (ev) {
|
.on('click', function (ev) {
|
||||||
|
|
||||||
store.put(storekey, !store.get(storekey));
|
store.put(storekey, !store.get(storekey));
|
||||||
updateSettings();
|
updateSettings();
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
// ensure stored value is boolean, otherwise set default
|
// 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);
|
store.put(storekey, settings.show);
|
||||||
}
|
}
|
||||||
updateSettings();
|
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({
|
var settings = _.extend({
|
||||||
enabled: false,
|
enabled: false,
|
||||||
lang: 'en',
|
lang: 'en',
|
||||||
@@ -38,7 +38,6 @@ modulejs.define('ext/l10n', ['_', '$', 'core/event', 'core/format', 'core/langs'
|
|||||||
|
|
||||||
|
|
||||||
function update(lang) {
|
function update(lang) {
|
||||||
|
|
||||||
if (lang) {
|
if (lang) {
|
||||||
currentLang = lang;
|
currentLang = lang;
|
||||||
}
|
}
|
||||||
@@ -55,7 +54,6 @@ modulejs.define('ext/l10n', ['_', '$', 'core/event', 'core/format', 'core/langs'
|
|||||||
format.setDefaultDateFormat(currentLang.dateFormat);
|
format.setDefaultDateFormat(currentLang.dateFormat);
|
||||||
|
|
||||||
$('#items .item .date').each(function () {
|
$('#items .item .date').each(function () {
|
||||||
|
|
||||||
var $this = $(this);
|
var $this = $(this);
|
||||||
|
|
||||||
$this.text(format.formatDate($this.data('time')));
|
$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) {
|
function loadLanguage(isoCode, callback) {
|
||||||
|
|
||||||
if (loaded[isoCode]) {
|
if (loaded[isoCode]) {
|
||||||
|
|
||||||
callback(loaded[isoCode]);
|
callback(loaded[isoCode]);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
server.request({action: 'get', l10n: [isoCode]}, function (response) {
|
server.request({action: 'get', l10n: [isoCode]}, function (response) {
|
||||||
|
|
||||||
var json = response.l10n && response.l10n[isoCode] ? response.l10n[isoCode] : {};
|
var json = response.l10n && response.l10n[isoCode] ? response.l10n[isoCode] : {};
|
||||||
loaded[isoCode] = _.extend({}, defaultTranslations, json, {isoCode: isoCode});
|
loaded[isoCode] = _.extend({}, defaultTranslations, json, {isoCode: isoCode});
|
||||||
callback(loaded[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);
|
var storedIsoCode = store.get(storekey);
|
||||||
|
|
||||||
if (langs[storedIsoCode]) {
|
if (languages[storedIsoCode]) {
|
||||||
isoCode = storedIsoCode;
|
isoCode = storedIsoCode;
|
||||||
} else if (useBrowserLang) {
|
} else if (useBrowserLang) {
|
||||||
var browserLang = navigator.language || navigator.browserLanguage;
|
var browserLang = navigator.language || navigator.browserLanguage;
|
||||||
if (browserLang) {
|
if (browserLang) {
|
||||||
if (langs[browserLang]) {
|
if (languages[browserLang]) {
|
||||||
isoCode = 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);
|
isoCode = browserLang.substr(0, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!langs[isoCode]) {
|
if (!languages[isoCode]) {
|
||||||
isoCode = 'en';
|
isoCode = 'en';
|
||||||
}
|
}
|
||||||
|
|
||||||
loadLanguage(isoCode, update);
|
loadLanguage(isoCode, update);
|
||||||
}
|
}
|
||||||
|
|
||||||
function initLangSelector(langs) {
|
function initLangSelector(languages) {
|
||||||
|
var isoCodes = _.keys(languages).sort();
|
||||||
var isoCodes = _.keys(langs).sort();
|
|
||||||
var $block = $(blockTemplate);
|
var $block = $(blockTemplate);
|
||||||
var $select = $block.find('select')
|
var $select = $block.find('select')
|
||||||
.on('change', function (event) {
|
.on('change', function (ev) {
|
||||||
var isoCode = event.target.value;
|
var isoCode = ev.target.value;
|
||||||
store.put(storekey, isoCode);
|
store.put(storekey, isoCode);
|
||||||
localize(langs, isoCode, false);
|
localize(languages, isoCode, false);
|
||||||
});
|
});
|
||||||
|
|
||||||
$.each(isoCodes, function (idx, isoCode) {
|
$.each(isoCodes, function (idx, isoCode) {
|
||||||
$(optionTemplate)
|
$(optionTemplate)
|
||||||
.attr('value', isoCode)
|
.attr('value', isoCode)
|
||||||
.addClass(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);
|
.appendTo($select);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -125,13 +117,11 @@ modulejs.define('ext/l10n', ['_', '$', 'core/event', 'core/format', 'core/langs'
|
|||||||
}
|
}
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
|
|
||||||
if (settings.enabled) {
|
if (settings.enabled) {
|
||||||
initLangSelector(langs);
|
initLangSelector(langs);
|
||||||
}
|
}
|
||||||
|
|
||||||
event.sub('view.changed', function () {
|
event.sub('view.changed', function () {
|
||||||
|
|
||||||
localize(langs, settings.lang, settings.useBrowserLang);
|
localize(langs, settings.lang, settings.useBrowserLang);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
modulejs.define('ext/peer5', ['_', '$', 'core/settings'], function (_, $, allsettings) {
|
modulejs.define('ext/peer5', ['_', '$', 'core/settings'], function (_, $, allsettings) {
|
||||||
|
|
||||||
var settings = _.extend({
|
var settings = _.extend({
|
||||||
enabled: false,
|
enabled: false,
|
||||||
id: 'z142i5n5qypq4cxr'
|
id: 'z142i5n5qypq4cxr'
|
||||||
@@ -7,7 +6,6 @@ modulejs.define('ext/peer5', ['_', '$', 'core/settings'], function (_, $, allset
|
|||||||
|
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
|
|
||||||
if (!settings.enabled) {
|
if (!settings.enabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -23,9 +21,7 @@ modulejs.define('ext/peer5', ['_', '$', 'core/settings'], function (_, $, allset
|
|||||||
|
|
||||||
// attach to file items, once the DOM is ready
|
// attach to file items, once the DOM is ready
|
||||||
$(function () {
|
$(function () {
|
||||||
|
|
||||||
$('body').on('click', '.item.file > a', function (ev) {
|
$('body').on('click', '.item.file > a', function (ev) {
|
||||||
|
|
||||||
if (window.peer5) {
|
if (window.peer5) {
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
var url = ev.currentTarget.href;
|
var url = ev.currentTarget.href;
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
modulejs.define('ext/piwik-analytics', ['_', '$', 'core/settings'], function (_, $, allsettings) {
|
modulejs.define('ext/piwik-analytics', ['_', '$', 'core/settings'], function (_, $, allsettings) {
|
||||||
|
|
||||||
var settings = _.extend({
|
var settings = _.extend({
|
||||||
enabled: false,
|
enabled: false,
|
||||||
baseURL: 'not-set',
|
baseURL: 'not-set',
|
||||||
@@ -8,18 +7,17 @@ modulejs.define('ext/piwik-analytics', ['_', '$', 'core/settings'], function (_,
|
|||||||
|
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
|
|
||||||
if (!settings.enabled) {
|
if (!settings.enabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// reference: http://piwik.org/docs/javascript-tracking/
|
// 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');
|
$('<script/>').attr('src', pkBaseURL + 'piwik.js').appendTo('body');
|
||||||
$(window).load(function () {
|
$(window).load(function () {
|
||||||
/*global Piwik */
|
/* global Piwik */
|
||||||
|
|
||||||
var piwikTracker = Piwik.getTracker(pkBaseURL + 'piwik.php', settings.idSite);
|
var piwikTracker = Piwik.getTracker(pkBaseURL + 'piwik.php', settings.idSite);
|
||||||
piwikTracker.trackPageView();
|
piwikTracker.trackPageView();
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
modulejs.define('ext/preview-audio', ['_', '$', 'core/event', 'core/format', 'core/settings', 'ext/preview'], function (_, $, event, format, allsettings, preview) {
|
modulejs.define('ext/preview-audio', ['_', '$', 'core/event', 'core/format', 'core/settings', 'ext/preview'], function (_, $, event, format, allsettings, preview) {
|
||||||
|
|
||||||
var settings = _.extend({
|
var settings = _.extend({
|
||||||
enabled: false,
|
enabled: false,
|
||||||
types: []
|
types: []
|
||||||
}, allsettings['preview-aud']);
|
}, allsettings['preview-aud']);
|
||||||
|
|
||||||
|
|
||||||
function preloadAudio(src, callback) {
|
function preloadAudio(src, callback) {
|
||||||
|
|
||||||
var $audio = $('<audio/>')
|
var $audio = $('<audio/>')
|
||||||
.one('loadedmetadata', function () {
|
.one('loadedmetadata', function () {
|
||||||
|
|
||||||
callback($audio);
|
callback($audio);
|
||||||
// setTimeout(function () { callback($img); }, 1000); // for testing
|
// 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) {
|
function onEnter(items, idx) {
|
||||||
|
|
||||||
var currentItems = items;
|
var currentItems = items;
|
||||||
var currentIdx = idx;
|
var currentIdx = idx;
|
||||||
var currentItem = items[idx];
|
var currentItem = items[idx];
|
||||||
|
|
||||||
function onAdjustSize() {
|
function onAdjustSize() {
|
||||||
|
|
||||||
var $content = $('#pv-content');
|
var $content = $('#pv-content');
|
||||||
var $audio = $('#pv-aud-audio');
|
var $audio = $('#pv-aud-audio');
|
||||||
|
|
||||||
if ($audio.length) {
|
if ($audio.length) {
|
||||||
|
|
||||||
$audio.css({
|
$audio.css({
|
||||||
left: String(($content.width() - $audio.width()) * 0.5) + 'px',
|
left: String(($content.width() - $audio.width()) * 0.5) + 'px',
|
||||||
top: String(($content.height() - $audio.height()) * 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) {
|
function onIdxChange(rel) {
|
||||||
|
|
||||||
currentIdx = (currentIdx + rel + currentItems.length) % currentItems.length;
|
currentIdx = (currentIdx + rel + currentItems.length) % currentItems.length;
|
||||||
currentItem = currentItems[currentIdx];
|
currentItem = currentItems[currentIdx];
|
||||||
|
|
||||||
@@ -54,26 +46,31 @@ modulejs.define('ext/preview-audio', ['_', '$', 'core/event', 'core/format', 'co
|
|||||||
if ($('#pv-aud-audio').length) {
|
if ($('#pv-aud-audio').length) {
|
||||||
$('#pv-aud-audio')[0].pause();
|
$('#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);
|
clearTimeout(spinnerTimeout);
|
||||||
preview.showSpinner(false);
|
preview.showSpinner(false);
|
||||||
|
|
||||||
$('#pv-content').fadeOut(100, function () {
|
$('#pv-content').fadeOut(100, function () {
|
||||||
|
swap($preloadedContent);
|
||||||
$('#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);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
preloadAudio(currentItem.absHref, onReady);
|
||||||
|
}
|
||||||
|
|
||||||
onIdxChange(0);
|
onIdxChange(0);
|
||||||
preview.setOnIndexChange(onIdxChange);
|
preview.setOnIndexChange(onIdxChange);
|
||||||
preview.setOnAdjustSize(onAdjustSize);
|
preview.setOnAdjustSize(onAdjustSize);
|
||||||
@@ -81,30 +78,25 @@ modulejs.define('ext/preview-audio', ['_', '$', 'core/event', 'core/format', 'co
|
|||||||
}
|
}
|
||||||
|
|
||||||
function initItem(item) {
|
function initItem(item) {
|
||||||
|
|
||||||
if (item.$view && _.indexOf(settings.types, item.type) >= 0) {
|
if (item.$view && _.indexOf(settings.types, item.type) >= 0) {
|
||||||
item.$view.find('a').on('click', function (event) {
|
item.$view.find('a').on('click', function (ev) {
|
||||||
|
ev.preventDefault();
|
||||||
|
|
||||||
event.preventDefault();
|
var matchedItems = _.compact(_.map($('#items .item'), function (matchedItem) {
|
||||||
|
matchedItem = $(matchedItem).data('item');
|
||||||
var matchedEntries = _.compact(_.map($('#items .item'), function (item) {
|
return _.indexOf(settings.types, matchedItem.type) >= 0 ? matchedItem : null;
|
||||||
|
|
||||||
item = $(item).data('item');
|
|
||||||
return _.indexOf(settings.types, item.type) >= 0 ? item : null;
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
onEnter(matchedEntries, _.indexOf(matchedEntries, item));
|
onEnter(matchedItems, _.indexOf(matchedItems, item));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onViewChanged(added) {
|
function onViewChanged(added) {
|
||||||
|
|
||||||
_.each(added, initItem);
|
_.each(added, initItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
|
|
||||||
if (!settings.enabled) {
|
if (!settings.enabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -112,6 +104,5 @@ modulejs.define('ext/preview-audio', ['_', '$', 'core/event', 'core/format', 'co
|
|||||||
event.sub('view.changed', onViewChanged);
|
event.sub('view.changed', onViewChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
init();
|
init();
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
modulejs.define('ext/preview-img', ['_', '$', 'core/event', 'core/server', 'core/settings', 'ext/preview'], function (_, $, event, server, allsettings, preview) {
|
modulejs.define('ext/preview-img', ['_', '$', 'core/event', 'core/server', 'core/settings', 'ext/preview'], function (_, $, event, server, allsettings, preview) {
|
||||||
|
|
||||||
var settings = _.extend({
|
var settings = _.extend({
|
||||||
enabled: false,
|
enabled: false,
|
||||||
size: null,
|
size: null,
|
||||||
@@ -13,7 +12,6 @@ modulejs.define('ext/preview-img', ['_', '$', 'core/event', 'core/server', 'core
|
|||||||
|
|
||||||
|
|
||||||
function requestSample(href, callback) {
|
function requestSample(href, callback) {
|
||||||
|
|
||||||
if (!settings.size) {
|
if (!settings.size) {
|
||||||
callback(href);
|
callback(href);
|
||||||
return;
|
return;
|
||||||
@@ -28,18 +26,14 @@ modulejs.define('ext/preview-img', ['_', '$', 'core/event', 'core/server', 'core
|
|||||||
height: 0
|
height: 0
|
||||||
}]
|
}]
|
||||||
}, function (json) {
|
}, function (json) {
|
||||||
|
|
||||||
callback(json && json.thumbs && json.thumbs[0] ? json.thumbs[0] : null);
|
callback(json && json.thumbs && json.thumbs[0] ? json.thumbs[0] : null);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function preloadImage(item, callback) {
|
function preloadImage(item, callback) {
|
||||||
|
|
||||||
requestSample(item.absHref, function (src) {
|
requestSample(item.absHref, function (src) {
|
||||||
|
|
||||||
$('<img/>')
|
$('<img/>')
|
||||||
.one('load', function (ev) {
|
.one('load', function (ev) {
|
||||||
|
|
||||||
callback(item, ev.target);
|
callback(item, ev.target);
|
||||||
|
|
||||||
// for testing
|
// for testing
|
||||||
@@ -50,7 +44,6 @@ modulejs.define('ext/preview-img', ['_', '$', 'core/event', 'core/server', 'core
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onAdjustSize() {
|
function onAdjustSize() {
|
||||||
|
|
||||||
var $content = $('#pv-content');
|
var $content = $('#pv-content');
|
||||||
var $img = $('#pv-img-image');
|
var $img = $('#pv-img-image');
|
||||||
|
|
||||||
@@ -72,7 +65,6 @@ modulejs.define('ext/preview-img', ['_', '$', 'core/event', 'core/server', 'core
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onIdxChange(rel) {
|
function onIdxChange(rel) {
|
||||||
|
|
||||||
currentIdx = (currentIdx + rel + currentItems.length) % currentItems.length;
|
currentIdx = (currentIdx + rel + currentItems.length) % currentItems.length;
|
||||||
currentItem = currentItems[currentIdx];
|
currentItem = currentItems[currentIdx];
|
||||||
|
|
||||||
@@ -86,13 +78,11 @@ modulejs.define('ext/preview-img', ['_', '$', 'core/event', 'core/server', 'core
|
|||||||
} else {
|
} else {
|
||||||
clearTimeout(spinnerTimeoutId);
|
clearTimeout(spinnerTimeoutId);
|
||||||
spinnerTimeoutId = setTimeout(function () {
|
spinnerTimeoutId = setTimeout(function () {
|
||||||
|
|
||||||
preview.showSpinner(true, currentItem.thumbSquare);
|
preview.showSpinner(true, currentItem.thumbSquare);
|
||||||
}, spinnerThreshold);
|
}, spinnerThreshold);
|
||||||
}
|
}
|
||||||
|
|
||||||
preloadImage(currentItem, function (item, preloadedImage) {
|
preloadImage(currentItem, function (item, preloadedImage) {
|
||||||
|
|
||||||
if (item !== currentItem) {
|
if (item !== currentItem) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -108,7 +98,6 @@ modulejs.define('ext/preview-img', ['_', '$', 'core/event', 'core/server', 'core
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onEnter(items, idx) {
|
function onEnter(items, idx) {
|
||||||
|
|
||||||
currentItems = items;
|
currentItems = items;
|
||||||
currentIdx = idx;
|
currentIdx = idx;
|
||||||
preview.setOnIndexChange(onIdxChange);
|
preview.setOnIndexChange(onIdxChange);
|
||||||
@@ -118,30 +107,25 @@ modulejs.define('ext/preview-img', ['_', '$', 'core/event', 'core/server', 'core
|
|||||||
}
|
}
|
||||||
|
|
||||||
function initItem(item) {
|
function initItem(item) {
|
||||||
|
|
||||||
if (item.$view && _.indexOf(settings.types, item.type) >= 0) {
|
if (item.$view && _.indexOf(settings.types, item.type) >= 0) {
|
||||||
item.$view.find('a').on('click', function (ev) {
|
item.$view.find('a').on('click', function (ev) {
|
||||||
|
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
|
|
||||||
var matchedEntries = _.compact(_.map($('#items .item'), function (item) {
|
var matchedItems = _.compact(_.map($('#items .item'), function (matchedItem) {
|
||||||
|
matchedItem = $(matchedItem).data('item');
|
||||||
item = $(item).data('item');
|
return _.indexOf(settings.types, matchedItem.type) >= 0 ? matchedItem : null;
|
||||||
return _.indexOf(settings.types, item.type) >= 0 ? item : null;
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
onEnter(matchedEntries, _.indexOf(matchedEntries, item));
|
onEnter(matchedItems, _.indexOf(matchedItems, item));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onViewChanged(added) {
|
function onViewChanged(added) {
|
||||||
|
|
||||||
_.each(added, initItem);
|
_.each(added, initItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
|
|
||||||
if (!settings.enabled) {
|
if (!settings.enabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
modulejs.define('ext/preview-txt', ['_', '$', 'marked', 'prism', 'core/event', 'core/settings', 'ext/preview'], function (_, $, marked, prism, event, allsettings, preview) {
|
modulejs.define('ext/preview-txt', ['_', '$', 'marked', 'prism', 'core/event', 'core/settings', 'ext/preview'], function (_, $, marked, prism, event, allsettings, preview) {
|
||||||
|
|
||||||
var settings = _.extend({
|
var settings = _.extend({
|
||||||
enabled: false,
|
enabled: false,
|
||||||
types: {}
|
types: {}
|
||||||
@@ -14,26 +13,22 @@ modulejs.define('ext/preview-txt', ['_', '$', 'marked', 'prism', 'core/event', '
|
|||||||
|
|
||||||
|
|
||||||
function preloadText(item, callback) {
|
function preloadText(item, callback) {
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: item.absHref,
|
url: item.absHref,
|
||||||
dataType: 'text'
|
dataType: 'text'
|
||||||
})
|
})
|
||||||
.done(function (content) {
|
.done(function (content) {
|
||||||
|
|
||||||
callback(item, content);
|
callback(item, content);
|
||||||
|
|
||||||
// for testing
|
// for testing
|
||||||
// setTimeout(function () { callback(item, content); }, 1000);
|
// setTimeout(function () { callback(item, content); }, 1000);
|
||||||
})
|
})
|
||||||
.fail(function (jqXHR, textStatus) {
|
.fail(function (jqXHR, textStatus) {
|
||||||
|
|
||||||
callback(item, '[ajax error] ' + textStatus);
|
callback(item, '[ajax error] ' + textStatus);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function onAdjustSize() {
|
function onAdjustSize() {
|
||||||
|
|
||||||
var $content = $('#pv-content');
|
var $content = $('#pv-content');
|
||||||
var $text = $('#pv-txt-text');
|
var $text = $('#pv-txt-text');
|
||||||
|
|
||||||
@@ -43,7 +38,6 @@ modulejs.define('ext/preview-txt', ['_', '$', 'marked', 'prism', 'core/event', '
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onIdxChange(rel) {
|
function onIdxChange(rel) {
|
||||||
|
|
||||||
currentIdx = (currentIdx + rel + currentItems.length) % currentItems.length;
|
currentIdx = (currentIdx + rel + currentItems.length) % currentItems.length;
|
||||||
currentItem = currentItems[currentIdx];
|
currentItem = currentItems[currentIdx];
|
||||||
|
|
||||||
@@ -60,13 +54,11 @@ modulejs.define('ext/preview-txt', ['_', '$', 'marked', 'prism', 'core/event', '
|
|||||||
} else {
|
} else {
|
||||||
clearTimeout(spinnerTimeoutId);
|
clearTimeout(spinnerTimeoutId);
|
||||||
spinnerTimeoutId = setTimeout(function () {
|
spinnerTimeoutId = setTimeout(function () {
|
||||||
|
|
||||||
preview.showSpinner(true, currentItem.icon);
|
preview.showSpinner(true, currentItem.icon);
|
||||||
}, spinnerThreshold);
|
}, spinnerThreshold);
|
||||||
}
|
}
|
||||||
|
|
||||||
preloadText(currentItem, function (item, textContent) {
|
preloadText(currentItem, function (item, textContent) {
|
||||||
|
|
||||||
if (item !== currentItem) {
|
if (item !== currentItem) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -104,7 +96,6 @@ modulejs.define('ext/preview-txt', ['_', '$', 'marked', 'prism', 'core/event', '
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onEnter(items, idx) {
|
function onEnter(items, idx) {
|
||||||
|
|
||||||
currentItems = items;
|
currentItems = items;
|
||||||
currentIdx = idx;
|
currentIdx = idx;
|
||||||
currentItem = items[idx];
|
currentItem = items[idx];
|
||||||
@@ -115,30 +106,25 @@ modulejs.define('ext/preview-txt', ['_', '$', 'marked', 'prism', 'core/event', '
|
|||||||
}
|
}
|
||||||
|
|
||||||
function initItem(item) {
|
function initItem(item) {
|
||||||
|
|
||||||
if (item.$view && _.indexOf(_.keys(settings.types), item.type) >= 0) {
|
if (item.$view && _.indexOf(_.keys(settings.types), item.type) >= 0) {
|
||||||
item.$view.find('a').on('click', function (event) {
|
item.$view.find('a').on('click', function (ev) {
|
||||||
|
ev.preventDefault();
|
||||||
|
|
||||||
event.preventDefault();
|
var matchedItems = _.compact(_.map($('#items .item'), function (matchedItem) {
|
||||||
|
matchedItem = $(matchedItem).data('item');
|
||||||
var matchedEntries = _.compact(_.map($('#items .item'), function (item) {
|
return _.indexOf(_.keys(settings.types), matchedItem.type) >= 0 ? matchedItem : null;
|
||||||
|
|
||||||
item = $(item).data('item');
|
|
||||||
return _.indexOf(_.keys(settings.types), item.type) >= 0 ? item : null;
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
onEnter(matchedEntries, _.indexOf(matchedEntries, item));
|
onEnter(matchedItems, _.indexOf(matchedItems, item));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onViewChanged(added) {
|
function onViewChanged(added) {
|
||||||
|
|
||||||
_.each(added, initItem);
|
_.each(added, initItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
|
|
||||||
if (!settings.enabled) {
|
if (!settings.enabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
modulejs.define('ext/preview-vid', ['_', '$', 'core/event', 'core/settings', 'ext/preview'], function (_, $, event, allsettings, preview) {
|
modulejs.define('ext/preview-vid', ['_', '$', 'core/event', 'core/settings', 'ext/preview'], function (_, $, event, allsettings, preview) {
|
||||||
|
|
||||||
var settings = _.extend({
|
var settings = _.extend({
|
||||||
enabled: false,
|
enabled: false,
|
||||||
types: []
|
types: []
|
||||||
}, allsettings['preview-vid']);
|
}, allsettings['preview-vid']);
|
||||||
|
|
||||||
|
|
||||||
function preloadVideo(src, callback) {
|
function preloadVideo(src, callback) {
|
||||||
|
|
||||||
var $video = $('<video/>')
|
var $video = $('<video/>')
|
||||||
.one('loadedmetadata', function () {
|
.one('loadedmetadata', function () {
|
||||||
|
|
||||||
callback($video);
|
callback($video);
|
||||||
// setTimeout(function () { callback($video); }, 1000); // for testing
|
// 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) {
|
function onEnter(items, idx) {
|
||||||
|
|
||||||
var currentItems = items;
|
var currentItems = items;
|
||||||
var currentIdx = idx;
|
var currentIdx = idx;
|
||||||
var currentItem = items[idx];
|
var currentItem = items[idx];
|
||||||
|
|
||||||
function onAdjustSize() {
|
function onAdjustSize() {
|
||||||
|
|
||||||
var $content = $('#pv-content');
|
var $content = $('#pv-content');
|
||||||
var $vid = $('#pv-vid-video');
|
var $vid = $('#pv-vid-video');
|
||||||
|
|
||||||
if ($vid.length) {
|
if ($vid.length) {
|
||||||
|
|
||||||
$vid.css({
|
$vid.css({
|
||||||
left: String(($content.width() - $vid.width()) * 0.5) + 'px',
|
left: String(($content.width() - $vid.width()) * 0.5) + 'px',
|
||||||
top: String(($content.height() - $vid.height()) * 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) {
|
function onIdxChange(rel) {
|
||||||
|
|
||||||
currentIdx = (currentIdx + rel + currentItems.length) % currentItems.length;
|
currentIdx = (currentIdx + rel + currentItems.length) % currentItems.length;
|
||||||
currentItem = currentItems[currentIdx];
|
currentItem = currentItems[currentIdx];
|
||||||
|
|
||||||
@@ -55,26 +47,31 @@ modulejs.define('ext/preview-vid', ['_', '$', 'core/event', 'core/settings', 'ex
|
|||||||
if ($('#pv-vid-video').length) {
|
if ($('#pv-vid-video').length) {
|
||||||
$('#pv-vid-video')[0].pause();
|
$('#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);
|
clearTimeout(spinnerTimeout);
|
||||||
preview.showSpinner(false);
|
preview.showSpinner(false);
|
||||||
|
|
||||||
$('#pv-content').fadeOut(100, function () {
|
$('#pv-content').fadeOut(100, function () {
|
||||||
|
swap($preloadedContent);
|
||||||
$('#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);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
preloadVideo(currentItem.absHref, onReady);
|
||||||
|
}
|
||||||
|
|
||||||
onIdxChange(0);
|
onIdxChange(0);
|
||||||
preview.setOnIndexChange(onIdxChange);
|
preview.setOnIndexChange(onIdxChange);
|
||||||
preview.setOnAdjustSize(onAdjustSize);
|
preview.setOnAdjustSize(onAdjustSize);
|
||||||
@@ -82,30 +79,25 @@ modulejs.define('ext/preview-vid', ['_', '$', 'core/event', 'core/settings', 'ex
|
|||||||
}
|
}
|
||||||
|
|
||||||
function initItem(item) {
|
function initItem(item) {
|
||||||
|
|
||||||
if (item.$view && _.indexOf(settings.types, item.type) >= 0) {
|
if (item.$view && _.indexOf(settings.types, item.type) >= 0) {
|
||||||
item.$view.find('a').on('click', function (event) {
|
item.$view.find('a').on('click', function (ev) {
|
||||||
|
ev.preventDefault();
|
||||||
|
|
||||||
event.preventDefault();
|
var matchedItems = _.compact(_.map($('#items .item'), function (matchedItem) {
|
||||||
|
matchedItem = $(matchedItem).data('item');
|
||||||
var matchedEntries = _.compact(_.map($('#items .item'), function (item) {
|
return _.indexOf(settings.types, matchedItem.type) >= 0 ? matchedItem : null;
|
||||||
|
|
||||||
item = $(item).data('item');
|
|
||||||
return _.indexOf(settings.types, item.type) >= 0 ? item : null;
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
onEnter(matchedEntries, _.indexOf(matchedEntries, item));
|
onEnter(matchedItems, _.indexOf(matchedItems, item));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onViewChanged(added) {
|
function onViewChanged(added) {
|
||||||
|
|
||||||
_.each(added, initItem);
|
_.each(added, initItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
|
|
||||||
if (!settings.enabled) {
|
if (!settings.enabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -113,6 +105,5 @@ modulejs.define('ext/preview-vid', ['_', '$', 'core/event', 'core/settings', 'ex
|
|||||||
event.sub('view.changed', onViewChanged);
|
event.sub('view.changed', onViewChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
init();
|
init();
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
modulejs.define('ext/preview', ['_', '$', 'core/resource', 'core/settings', 'core/store'], function (_, $, resource, allsettings, store) {
|
modulejs.define('ext/preview', ['_', '$', 'core/resource', 'core/settings', 'core/store'], function (_, $, resource, allsettings, store) {
|
||||||
|
|
||||||
var settings = _.extend({
|
var settings = _.extend({
|
||||||
enabled: true
|
enabled: true
|
||||||
}, allsettings.preview);
|
}, allsettings.preview);
|
||||||
@@ -30,7 +29,6 @@ modulejs.define('ext/preview', ['_', '$', 'core/resource', 'core/settings', 'cor
|
|||||||
|
|
||||||
|
|
||||||
function adjustSize() {
|
function adjustSize() {
|
||||||
|
|
||||||
var winWidth = $window.width();
|
var winWidth = $window.width();
|
||||||
var winHeight = $window.height();
|
var winHeight = $window.height();
|
||||||
var $container = $('#pv-content');
|
var $container = $('#pv-content');
|
||||||
@@ -63,53 +61,40 @@ modulejs.define('ext/preview', ['_', '$', 'core/resource', 'core/settings', 'cor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onEnter() {
|
function setLabels(labels) {
|
||||||
|
$('#pv-buttons .bar-left').remove();
|
||||||
setLabels([]);
|
_.each(labels, function (label) {
|
||||||
$('#pv-content').empty();
|
$('<li/>')
|
||||||
$('#pv-overlay').stop(true, true).fadeIn(200);
|
.addClass('bar-left bar-label')
|
||||||
$window.on('keydown', onKeydown);
|
.text(label)
|
||||||
adjustSize();
|
.appendTo('#pv-buttons');
|
||||||
}
|
|
||||||
|
|
||||||
function onExit() {
|
|
||||||
|
|
||||||
$window.off('keydown', onKeydown);
|
|
||||||
$('#pv-overlay').stop(true, true).fadeOut(200, function () {
|
|
||||||
$('#pv-content').empty();
|
|
||||||
setLabels([]);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function onNext() {
|
function onNext() {
|
||||||
|
|
||||||
if (_.isFunction(onIndexChange)) {
|
if (_.isFunction(onIndexChange)) {
|
||||||
onIndexChange(1);
|
onIndexChange(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onPrevious() {
|
function onPrevious() {
|
||||||
|
|
||||||
if (_.isFunction(onIndexChange)) {
|
if (_.isFunction(onIndexChange)) {
|
||||||
onIndexChange(-1);
|
onIndexChange(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function userAlive() {
|
function userAlive() {
|
||||||
|
|
||||||
clearTimeout(userAliveTimeoutId);
|
clearTimeout(userAliveTimeoutId);
|
||||||
$('#pv-overlay .hof').stop(true, true).fadeIn(200);
|
$('#pv-overlay .hof').stop(true, true).fadeIn(200);
|
||||||
|
|
||||||
if (isFullscreen) {
|
if (isFullscreen) {
|
||||||
userAliveTimeoutId = setTimeout(function () {
|
userAliveTimeoutId = setTimeout(function () {
|
||||||
|
|
||||||
$('#pv-overlay .hof').stop(true, true).fadeOut(2000);
|
$('#pv-overlay .hof').stop(true, true).fadeOut(2000);
|
||||||
}, 2000);
|
}, 2000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onFullscreen() {
|
function onFullscreen() {
|
||||||
|
|
||||||
isFullscreen = !isFullscreen;
|
isFullscreen = !isFullscreen;
|
||||||
store.put(storekey, isFullscreen);
|
store.put(storekey, isFullscreen);
|
||||||
|
|
||||||
@@ -118,7 +103,6 @@ modulejs.define('ext/preview', ['_', '$', 'core/resource', 'core/settings', 'cor
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onKeydown(ev) {
|
function onKeydown(ev) {
|
||||||
|
|
||||||
var key = ev.which;
|
var key = ev.which;
|
||||||
|
|
||||||
if (key === 27) { // esc
|
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)) {
|
if (_.isNumber(idx)) {
|
||||||
$('#pv-bar-idx').text(String(idx) + (_.isNumber(total) ? '/' + String(total) : '')).show();
|
$('#pv-bar-idx').text(String(idx) + (_.isNumber(total) ? '/' + String(total) : '')).show();
|
||||||
} else {
|
} else {
|
||||||
@@ -150,7 +149,6 @@ modulejs.define('ext/preview', ['_', '$', 'core/resource', 'core/settings', 'cor
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setRawLink(href) {
|
function setRawLink(href) {
|
||||||
|
|
||||||
if (href) {
|
if (href) {
|
||||||
$('#pv-bar-raw').show().find('a').attr('href', href);
|
$('#pv-bar-raw').show().find('a').attr('href', href);
|
||||||
} else {
|
} 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) {
|
function setOnIndexChange(fn) {
|
||||||
|
|
||||||
onIndexChange = fn;
|
onIndexChange = fn;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setOnAdjustSize(fn) {
|
function setOnAdjustSize(fn) {
|
||||||
|
|
||||||
onAdjustSize = fn;
|
onAdjustSize = fn;
|
||||||
}
|
}
|
||||||
|
|
||||||
function showSpinner(show, src, millis) {
|
function showSpinner(show, src, millis) {
|
||||||
|
|
||||||
if (!_.isNumber(millis)) {
|
if (!_.isNumber(millis)) {
|
||||||
millis = 300;
|
millis = 300;
|
||||||
}
|
}
|
||||||
@@ -204,12 +187,10 @@ modulejs.define('ext/preview', ['_', '$', 'core/resource', 'core/settings', 'cor
|
|||||||
}
|
}
|
||||||
|
|
||||||
function isSpinnerVisible() {
|
function isSpinnerVisible() {
|
||||||
|
|
||||||
return spinnerVisible;
|
return spinnerVisible;
|
||||||
}
|
}
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
|
|
||||||
if (!settings.enabled) {
|
if (!settings.enabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -226,7 +207,6 @@ modulejs.define('ext/preview', ['_', '$', 'core/resource', 'core/settings', 'cor
|
|||||||
.on('keydown', onKeydown)
|
.on('keydown', onKeydown)
|
||||||
.on('mousemove mousedown', userAlive)
|
.on('mousemove mousedown', userAlive)
|
||||||
.on('click mousedown mousemove keydown keypress', function (ev) {
|
.on('click mousedown mousemove keydown keypress', function (ev) {
|
||||||
|
|
||||||
if (ev.type === 'click' && (ev.target.id === 'pv-overlay' || ev.target.id === 'pv-content')) {
|
if (ev.type === 'click' && (ev.target.id === 'pv-overlay' || ev.target.id === 'pv-content')) {
|
||||||
onExit();
|
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) {
|
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({
|
var settings = _.extend({
|
||||||
enabled: false,
|
enabled: false,
|
||||||
advanced: false,
|
advanced: false,
|
||||||
@@ -17,7 +16,6 @@ modulejs.define('ext/search', ['_', '$', 'core/event', 'core/location', 'core/re
|
|||||||
|
|
||||||
|
|
||||||
function search(pattern) {
|
function search(pattern) {
|
||||||
|
|
||||||
pattern = pattern || '';
|
pattern = pattern || '';
|
||||||
if (pattern === prevPattern) {
|
if (pattern === prevPattern) {
|
||||||
return;
|
return;
|
||||||
@@ -38,18 +36,15 @@ modulejs.define('ext/search', ['_', '$', 'core/event', 'core/location', 'core/re
|
|||||||
pattern: pattern
|
pattern: pattern
|
||||||
}
|
}
|
||||||
}, function (response) {
|
}, function (response) {
|
||||||
|
|
||||||
$search.removeClass('pending');
|
$search.removeClass('pending');
|
||||||
view.setHint('noMatch');
|
view.setHint('noMatch');
|
||||||
view.setItems(_.map(response.search, function (item) {
|
view.setItems(_.map(response.search, function (item) {
|
||||||
|
|
||||||
return Item.get(item);
|
return Item.get(item);
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function update() {
|
function update() {
|
||||||
|
|
||||||
if (inputIsVisible) {
|
if (inputIsVisible) {
|
||||||
$search.addClass('active');
|
$search.addClass('active');
|
||||||
$input.focus();
|
$input.focus();
|
||||||
@@ -61,20 +56,17 @@ modulejs.define('ext/search', ['_', '$', 'core/event', 'core/location', 'core/re
|
|||||||
}
|
}
|
||||||
|
|
||||||
function toggle() {
|
function toggle() {
|
||||||
|
|
||||||
inputIsVisible = !inputIsVisible;
|
inputIsVisible = !inputIsVisible;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
function reset() {
|
function reset() {
|
||||||
|
|
||||||
inputIsVisible = false;
|
inputIsVisible = false;
|
||||||
$input.val('');
|
$input.val('');
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
|
|
||||||
if (!settings.enabled) {
|
if (!settings.enabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
modulejs.define('ext/select', ['_', '$', 'core/event', 'core/resource', 'core/settings'], function (_, $, event, resource, allsettings) {
|
modulejs.define('ext/select', ['_', '$', 'core/event', 'core/resource', 'core/settings'], function (_, $, event, resource, allsettings) {
|
||||||
|
|
||||||
var settings = _.extend({
|
var settings = _.extend({
|
||||||
enabled: false,
|
enabled: false,
|
||||||
clickndrag: false,
|
clickndrag: false,
|
||||||
@@ -21,30 +20,26 @@ modulejs.define('ext/select', ['_', '$', 'core/event', 'core/resource', 'core/se
|
|||||||
|
|
||||||
|
|
||||||
function publish() {
|
function publish() {
|
||||||
|
|
||||||
var items = _.map($('#items .item.selected'), function (itemElement) {
|
var items = _.map($('#items .item.selected'), function (itemElement) {
|
||||||
|
|
||||||
return $(itemElement).data('item');
|
return $(itemElement).data('item');
|
||||||
});
|
});
|
||||||
event.pub('selection', items);
|
event.pub('selection', items);
|
||||||
}
|
}
|
||||||
|
|
||||||
function elementRect($element) {
|
function elementRect($element) {
|
||||||
|
|
||||||
if (!$element.is(':visible')) {
|
if (!$element.is(':visible')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var offset = $element.offset();
|
var offset = $element.offset();
|
||||||
var l = offset.left;
|
var elL = offset.left;
|
||||||
var t = offset.top;
|
var elT = offset.top;
|
||||||
var w = $element.outerWidth();
|
var elW = $element.outerWidth();
|
||||||
var h = $element.outerHeight();
|
var elH = $element.outerHeight();
|
||||||
return {l: l, t: t, w: w, h: h, r: l + w, b: t + h};
|
return {l: elL, t: elT, w: elW, h: elH, r: elL + elW, b: elT + elH};
|
||||||
}
|
}
|
||||||
|
|
||||||
function doOverlap(rect1, rect2) {
|
function doOverlap(rect1, rect2) {
|
||||||
|
|
||||||
if (!rect1 || !rect2) {
|
if (!rect1 || !rect2) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -56,11 +51,10 @@ modulejs.define('ext/select', ['_', '$', 'core/event', 'core/resource', 'core/se
|
|||||||
var width = right - left;
|
var width = right - left;
|
||||||
var height = bottom - top;
|
var height = bottom - top;
|
||||||
|
|
||||||
return (width >= 0 && height >= 0);
|
return width >= 0 && height >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectionUpdate(ev) {
|
function selectionUpdate(ev) {
|
||||||
|
|
||||||
l = Math.min(x, ev.pageX);
|
l = Math.min(x, ev.pageX);
|
||||||
t = Math.min(y, ev.pageY);
|
t = Math.min(y, ev.pageY);
|
||||||
w = Math.abs(x - ev.pageX);
|
w = Math.abs(x - ev.pageX);
|
||||||
@@ -86,7 +80,6 @@ modulejs.define('ext/select', ['_', '$', 'core/event', 'core/resource', 'core/se
|
|||||||
|
|
||||||
var selRect = elementRect($selectionRect);
|
var selRect = elementRect($selectionRect);
|
||||||
$('#items .item').removeClass('selecting').each(function () {
|
$('#items .item').removeClass('selecting').each(function () {
|
||||||
|
|
||||||
var $item = $(this);
|
var $item = $(this);
|
||||||
var inter = doOverlap(selRect, elementRect($item.find('a')));
|
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) {
|
function selectionEnd(ev) {
|
||||||
|
|
||||||
$document.off('mousemove', selectionUpdate);
|
$document.off('mousemove', selectionUpdate);
|
||||||
|
|
||||||
if (!isDragSelect) {
|
if (!isDragSelect) {
|
||||||
@@ -112,8 +104,7 @@ modulejs.define('ext/select', ['_', '$', 'core/event', 'core/resource', 'core/se
|
|||||||
$html.removeClass('drag-select');
|
$html.removeClass('drag-select');
|
||||||
$selectionRect
|
$selectionRect
|
||||||
.stop(true, true)
|
.stop(true, true)
|
||||||
.animate(
|
.animate({
|
||||||
{
|
|
||||||
left: l + w * 0.5 * shrink,
|
left: l + w * 0.5 * shrink,
|
||||||
top: t + h * 0.5 * shrink,
|
top: t + h * 0.5 * shrink,
|
||||||
width: w * (1 - shrink),
|
width: w * (1 - shrink),
|
||||||
@@ -123,12 +114,10 @@ modulejs.define('ext/select', ['_', '$', 'core/event', 'core/resource', 'core/se
|
|||||||
300,
|
300,
|
||||||
function () {
|
function () {
|
||||||
$selectionRect.hide();
|
$selectionRect.hide();
|
||||||
}
|
});
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectionStart(ev) {
|
function selectionStart(ev) {
|
||||||
|
|
||||||
// only on left button and don't block scrollbar
|
// only on left button and don't block scrollbar
|
||||||
if (ev.button !== 0 || ev.offsetX >= $('#content').width() - 14) {
|
if (ev.button !== 0 || ev.offsetX >= $('#content').width() - 14) {
|
||||||
return;
|
return;
|
||||||
@@ -145,7 +134,6 @@ modulejs.define('ext/select', ['_', '$', 'core/event', 'core/resource', 'core/se
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onSelectorClick(ev) {
|
function onSelectorClick(ev) {
|
||||||
|
|
||||||
ev.stopImmediatePropagation();
|
ev.stopImmediatePropagation();
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
|
|
||||||
@@ -154,7 +142,6 @@ modulejs.define('ext/select', ['_', '$', 'core/event', 'core/resource', 'core/se
|
|||||||
}
|
}
|
||||||
|
|
||||||
function addCheckbox(item) {
|
function addCheckbox(item) {
|
||||||
|
|
||||||
if (item.$view && !item.isCurrentParentFolder()) {
|
if (item.$view && !item.isCurrentParentFolder()) {
|
||||||
$(template)
|
$(template)
|
||||||
.on('click', onSelectorClick)
|
.on('click', onSelectorClick)
|
||||||
@@ -163,13 +150,11 @@ modulejs.define('ext/select', ['_', '$', 'core/event', 'core/resource', 'core/se
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onViewChanged(added, removed) {
|
function onViewChanged(added, removed) {
|
||||||
|
|
||||||
if (settings.checkboxes) {
|
if (settings.checkboxes) {
|
||||||
_.each(added, addCheckbox);
|
_.each(added, addCheckbox);
|
||||||
}
|
}
|
||||||
|
|
||||||
_.each(removed, function (item) {
|
_.each(removed, function (item) {
|
||||||
|
|
||||||
if (item.$view) {
|
if (item.$view) {
|
||||||
item.$view.removeClass('selected');
|
item.$view.removeClass('selected');
|
||||||
}
|
}
|
||||||
@@ -179,8 +164,7 @@ modulejs.define('ext/select', ['_', '$', 'core/event', 'core/resource', 'core/se
|
|||||||
}
|
}
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
|
if (!settings.enabled || !settings.clickndrag && !settings.checkboxes) {
|
||||||
if (!settings.enabled || (!settings.clickndrag && !settings.checkboxes)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,12 +176,10 @@ modulejs.define('ext/select', ['_', '$', 'core/event', 'core/resource', 'core/se
|
|||||||
$('#content')
|
$('#content')
|
||||||
.on('mousedown', selectionStart)
|
.on('mousedown', selectionStart)
|
||||||
.on('drag dragstart', function (ev) {
|
.on('drag dragstart', function (ev) {
|
||||||
|
|
||||||
ev.stopImmediatePropagation();
|
ev.stopImmediatePropagation();
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
})
|
})
|
||||||
.on('click', function () {
|
.on('click', function () {
|
||||||
|
|
||||||
$('#items .item').removeClass('selected');
|
$('#items .item').removeClass('selected');
|
||||||
publish();
|
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) {
|
modulejs.define('ext/sort', ['_', '$', 'core/event', 'core/resource', 'core/settings', 'core/store', 'core/util'], function (_, $, event, resource, allsettings, store, util) {
|
||||||
|
|
||||||
var settings = _.extend({
|
var settings = _.extend({
|
||||||
enabled: false,
|
enabled: false,
|
||||||
column: 0,
|
column: 0,
|
||||||
@@ -13,7 +12,6 @@ modulejs.define('ext/sort', ['_', '$', 'core/event', 'core/resource', 'core/sett
|
|||||||
|
|
||||||
|
|
||||||
function getType(item) {
|
function getType(item) {
|
||||||
|
|
||||||
var $item = $(item);
|
var $item = $(item);
|
||||||
|
|
||||||
if ($item.hasClass('folder-parent')) {
|
if ($item.hasClass('folder-parent')) {
|
||||||
@@ -31,17 +29,14 @@ modulejs.define('ext/sort', ['_', '$', 'core/event', 'core/resource', 'core/sett
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getName(item) {
|
function getName(item) {
|
||||||
|
|
||||||
return $(item).find('.label').text();
|
return $(item).find('.label').text();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTime(item) {
|
function getTime(item) {
|
||||||
|
|
||||||
return $(item).find('.date').data('time');
|
return $(item).find('.date').data('time');
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSize(item) {
|
function getSize(item) {
|
||||||
|
|
||||||
return $(item).find('.size').data('bytes');
|
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) {
|
function cmpFn(getValue, reverse, ignorecase, natural) {
|
||||||
|
|
||||||
return function (item1, item2) {
|
return function (item1, item2) {
|
||||||
|
|
||||||
var res;
|
var res;
|
||||||
var val1;
|
var val1;
|
||||||
var val2;
|
var val2;
|
||||||
@@ -90,7 +83,6 @@ modulejs.define('ext/sort', ['_', '$', 'core/event', 'core/resource', 'core/sett
|
|||||||
}
|
}
|
||||||
|
|
||||||
function sortItems(column, reverse) {
|
function sortItems(column, reverse) {
|
||||||
|
|
||||||
var $headers = $('#items li.header a');
|
var $headers = $('#items li.header a');
|
||||||
var $header = $('#items li.header a.' + columnClasses[column]);
|
var $header = $('#items li.header a.' + columnClasses[column]);
|
||||||
var fn = cmpFn(columnGetters[column], reverse, settings.ignorecase, column === 0 && settings.natural);
|
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() {
|
function onContentChanged() {
|
||||||
|
|
||||||
var order = store.get(storekey);
|
var order = store.get(storekey);
|
||||||
var column = order && order.column || settings.column;
|
var column = order && order.column || settings.column;
|
||||||
var reverse = order && order.reverse || settings.reverse;
|
var reverse = order && order.reverse || settings.reverse;
|
||||||
@@ -120,7 +111,6 @@ modulejs.define('ext/sort', ['_', '$', 'core/event', 'core/resource', 'core/sett
|
|||||||
}
|
}
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
|
|
||||||
if (!settings.enabled) {
|
if (!settings.enabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
modulejs.define('ext/thumbnails', ['_', 'core/event', 'core/server', 'core/settings'], function (_, event, server, allsettings) {
|
modulejs.define('ext/thumbnails', ['_', 'core/event', 'core/server', 'core/settings'], function (_, event, server, allsettings) {
|
||||||
|
|
||||||
var settings = _.extend({
|
var settings = _.extend({
|
||||||
enabled: false,
|
enabled: false,
|
||||||
img: ['img-bmp', 'img-gif', 'img-ico', 'img-jpg', 'img-png'],
|
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) {
|
function queueItem(queue, item) {
|
||||||
|
|
||||||
var type = null;
|
var type = null;
|
||||||
|
|
||||||
if (_.contains(settings.img, item.type)) {
|
if (_.contains(settings.img, item.type)) {
|
||||||
@@ -34,7 +32,6 @@ modulejs.define('ext/thumbnails', ['_', 'core/event', 'core/server', 'core/setti
|
|||||||
href: item.absHref,
|
href: item.absHref,
|
||||||
ratio: 1,
|
ratio: 1,
|
||||||
callback: function (src) {
|
callback: function (src) {
|
||||||
|
|
||||||
if (src && item.$view) {
|
if (src && item.$view) {
|
||||||
item.thumbSquare = src;
|
item.thumbSquare = src;
|
||||||
item.$view.find('.icon.square img').addClass('thumb').attr('src', 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,
|
href: item.absHref,
|
||||||
ratio: landscapeRatio,
|
ratio: landscapeRatio,
|
||||||
callback: function (src) {
|
callback: function (src) {
|
||||||
|
|
||||||
if (src && item.$view) {
|
if (src && item.$view) {
|
||||||
item.thumbRational = src;
|
item.thumbRational = src;
|
||||||
item.$view.find('.icon.landscape img').addClass('thumb').attr('src', 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) {
|
function requestQueue(queue) {
|
||||||
|
|
||||||
var thumbs = _.map(queue, function (req) {
|
var thumbs = _.map(queue, function (req) {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
type: req.type,
|
type: req.type,
|
||||||
href: req.href,
|
href: req.href,
|
||||||
@@ -77,20 +71,16 @@ modulejs.define('ext/thumbnails', ['_', 'core/event', 'core/server', 'core/setti
|
|||||||
action: 'get',
|
action: 'get',
|
||||||
thumbs: thumbs
|
thumbs: thumbs
|
||||||
}, function (json) {
|
}, function (json) {
|
||||||
|
|
||||||
_.each(queue, function (req, idx) {
|
_.each(queue, function (req, idx) {
|
||||||
|
|
||||||
req.callback(json && json.thumbs ? json.thumbs[idx] : null);
|
req.callback(json && json.thumbs ? json.thumbs[idx] : null);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleItems(items) {
|
function handleItems(items) {
|
||||||
|
|
||||||
var queue = [];
|
var queue = [];
|
||||||
|
|
||||||
_.each(items, function (item) {
|
_.each(items, function (item) {
|
||||||
|
|
||||||
queueItem(queue, item);
|
queueItem(queue, item);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -100,15 +90,12 @@ modulejs.define('ext/thumbnails', ['_', 'core/event', 'core/server', 'core/setti
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onViewChanged(added) {
|
function onViewChanged(added) {
|
||||||
|
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
|
|
||||||
handleItems(added);
|
handleItems(added);
|
||||||
}, settings.delay);
|
}, settings.delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
|
|
||||||
if (!settings.enabled) {
|
if (!settings.enabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -1,11 +1,9 @@
|
|||||||
modulejs.define('ext/title', ['_', 'core/event', 'core/settings'], function (_, event, allsettings) {
|
modulejs.define('ext/title', ['_', 'core/event', 'core/settings'], function (_, event, allsettings) {
|
||||||
|
|
||||||
var settings = _.extend({
|
var settings = _.extend({
|
||||||
enabled: false
|
enabled: false
|
||||||
}, allsettings.title);
|
}, allsettings.title);
|
||||||
|
|
||||||
function onLocationChanged(item) {
|
function onLocationChanged(item) {
|
||||||
|
|
||||||
var labels = _.pluck(item.getCrumb(), 'label');
|
var labels = _.pluck(item.getCrumb(), 'label');
|
||||||
var title = labels.join(' > ');
|
var title = labels.join(' > ');
|
||||||
|
|
||||||
@@ -17,7 +15,6 @@ modulejs.define('ext/title', ['_', 'core/event', 'core/settings'], function (_,
|
|||||||
}
|
}
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
|
|
||||||
if (!settings.enabled) {
|
if (!settings.enabled) {
|
||||||
return;
|
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) {
|
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({
|
var settings = _.extend({
|
||||||
enabled: false,
|
enabled: false,
|
||||||
show: true,
|
show: true,
|
||||||
@@ -28,7 +27,6 @@ modulejs.define('ext/tree', ['_', '$', 'core/event', 'core/location', 'core/reso
|
|||||||
|
|
||||||
|
|
||||||
function cmpFn(item1, item2) {
|
function cmpFn(item1, item2) {
|
||||||
|
|
||||||
var val1 = item1.label;
|
var val1 = item1.label;
|
||||||
var val2 = item2.label;
|
var val2 = item2.label;
|
||||||
|
|
||||||
@@ -41,7 +39,6 @@ modulejs.define('ext/tree', ['_', '$', 'core/event', 'core/location', 'core/reso
|
|||||||
}
|
}
|
||||||
|
|
||||||
function update(item) {
|
function update(item) {
|
||||||
|
|
||||||
var $html = $(template);
|
var $html = $(template);
|
||||||
var $indicator = $html.find('.indicator');
|
var $indicator = $html.find('.indicator');
|
||||||
var $a = $html.find('a');
|
var $a = $html.find('a');
|
||||||
@@ -57,15 +54,13 @@ modulejs.define('ext/tree', ['_', '$', 'core/event', 'core/location', 'core/reso
|
|||||||
$label.text(item.label);
|
$label.text(item.label);
|
||||||
|
|
||||||
if (item.isFolder()) {
|
if (item.isFolder()) {
|
||||||
|
|
||||||
var subfolders = item.getSubfolders();
|
var subfolders = item.getSubfolders();
|
||||||
|
|
||||||
// indicator
|
// indicator
|
||||||
if ((item.isManaged && !item.isContentFetched) || subfolders.length) {
|
if (item.isManaged && !item.isContentFetched || subfolders.length) {
|
||||||
|
|
||||||
$indicator.removeClass('none');
|
$indicator.removeClass('none');
|
||||||
|
|
||||||
if ((item.isManaged && !item.isContentFetched)) {
|
if (item.isManaged && !item.isContentFetched) {
|
||||||
$indicator.addClass('unknown');
|
$indicator.addClass('unknown');
|
||||||
} else if (item.isContentVisible) {
|
} else if (item.isContentVisible) {
|
||||||
$indicator.addClass('open');
|
$indicator.addClass('open');
|
||||||
@@ -114,52 +109,41 @@ modulejs.define('ext/tree', ['_', '$', 'core/event', 'core/location', 'core/reso
|
|||||||
}
|
}
|
||||||
|
|
||||||
function createOnIndicatorClick() {
|
function createOnIndicatorClick() {
|
||||||
|
|
||||||
function slide(item, $indicator, $content, down) {
|
function slide(item, $indicator, $content, down) {
|
||||||
|
|
||||||
item.isContentVisible = down;
|
item.isContentVisible = down;
|
||||||
$indicator.removeClass('open close').addClass(down ? 'open' : 'close');
|
$indicator.removeClass('open close').addClass(down ? 'open' : 'close');
|
||||||
$content[down ? 'slideDown' : 'slideUp']();
|
$content[down ? 'slideDown' : 'slideUp']();
|
||||||
}
|
}
|
||||||
|
|
||||||
return function () {
|
return function () {
|
||||||
|
|
||||||
var $indicator = $(this);
|
var $indicator = $(this);
|
||||||
var $item = $indicator.closest('.item');
|
var $item = $indicator.closest('.item');
|
||||||
var item = $item.data('item');
|
var item = $item.data('item');
|
||||||
var $content = $item.find('> ul.content');
|
var $content = $item.find('> ul.content');
|
||||||
|
|
||||||
if ($indicator.hasClass('unknown')) {
|
if ($indicator.hasClass('unknown')) {
|
||||||
|
item.fetchContent(function () {
|
||||||
item.fetchContent(function (item) {
|
|
||||||
|
|
||||||
item.isContentVisible = false;
|
item.isContentVisible = false;
|
||||||
|
|
||||||
var $item = update(item);
|
$item = update(item);
|
||||||
var $indicator = $item.find('> .indicator');
|
$indicator = $item.find('> .indicator');
|
||||||
var $content = $item.find('> ul.content');
|
$content = $item.find('> ul.content');
|
||||||
|
|
||||||
if (!$indicator.hasClass('none')) {
|
if (!$indicator.hasClass('none')) {
|
||||||
slide(item, $indicator, $content, true);
|
slide(item, $indicator, $content, true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
} else if ($indicator.hasClass('open')) {
|
} else if ($indicator.hasClass('open')) {
|
||||||
|
|
||||||
slide(item, $indicator, $content, false);
|
slide(item, $indicator, $content, false);
|
||||||
|
|
||||||
} else if ($indicator.hasClass('close')) {
|
} else if ($indicator.hasClass('close')) {
|
||||||
|
|
||||||
slide(item, $indicator, $content, true);
|
slide(item, $indicator, $content, true);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function fetchTree(item, callback) {
|
function fetchTree(item, callback) {
|
||||||
|
|
||||||
item.isContentVisible = true;
|
item.isContentVisible = true;
|
||||||
item.fetchContent(function (item) {
|
item.fetchContent(function () {
|
||||||
|
|
||||||
if (item.parent) {
|
if (item.parent) {
|
||||||
fetchTree(item.parent, callback);
|
fetchTree(item.parent, callback);
|
||||||
} else {
|
} else {
|
||||||
@@ -169,7 +153,6 @@ modulejs.define('ext/tree', ['_', '$', 'core/event', 'core/location', 'core/reso
|
|||||||
}
|
}
|
||||||
|
|
||||||
function updateSettings() {
|
function updateSettings() {
|
||||||
|
|
||||||
if (store.get(storekey)) {
|
if (store.get(storekey)) {
|
||||||
$('#view-tree').addClass('active');
|
$('#view-tree').addClass('active');
|
||||||
$('#tree').show();
|
$('#tree').show();
|
||||||
@@ -180,16 +163,13 @@ modulejs.define('ext/tree', ['_', '$', 'core/event', 'core/location', 'core/reso
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onLocationChanged(item) {
|
function onLocationChanged(item) {
|
||||||
|
|
||||||
fetchTree(item, function (root) {
|
fetchTree(item, function (root) {
|
||||||
|
|
||||||
$('#tree').append(update(root));
|
$('#tree').append(update(root));
|
||||||
updateSettings();
|
updateSettings();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
|
|
||||||
if (!settings.enabled) {
|
if (!settings.enabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -202,14 +182,13 @@ modulejs.define('ext/tree', ['_', '$', 'core/event', 'core/location', 'core/reso
|
|||||||
.appendTo('#sidebar')
|
.appendTo('#sidebar')
|
||||||
.find('#view-tree')
|
.find('#view-tree')
|
||||||
.on('click', function (ev) {
|
.on('click', function (ev) {
|
||||||
|
|
||||||
store.put(storekey, !store.get(storekey));
|
store.put(storekey, !store.get(storekey));
|
||||||
updateSettings();
|
updateSettings();
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
// ensure stored value is boolean, otherwise set default
|
// 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);
|
store.put(storekey, settings.show);
|
||||||
}
|
}
|
||||||
updateSettings();
|
updateSettings();
|
||||||
|
@@ -1,9 +1,7 @@
|
|||||||
modulejs.define('main/index', ['_', 'core/location'], function (_, location) {
|
modulejs.define('main/index', ['_', 'core/location'], function (_, location) {
|
||||||
|
|
||||||
modulejs.require('view/viewmode');
|
modulejs.require('view/viewmode');
|
||||||
|
|
||||||
_.each(modulejs.state(), function (state, id) {
|
_.each(modulejs.state(), function (state, id) {
|
||||||
|
|
||||||
if (id.indexOf('ext/') === 0) {
|
if (id.indexOf('ext/') === 0) {
|
||||||
modulejs.require(id);
|
modulejs.require(id);
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
modulejs.define('main/info', ['$', 'config', 'core/resource', 'core/server'], function ($, config, resource, server) {
|
modulejs.define('main/info', ['$', 'config', 'core/resource', 'core/server'], function ($, config, resource, server) {
|
||||||
|
|
||||||
var tplTests =
|
var tplTests =
|
||||||
'<ul id="tests">';
|
'<ul id="tests">';
|
||||||
var tplTest =
|
var tplTest =
|
||||||
@@ -33,17 +32,15 @@ modulejs.define('main/info', ['$', 'config', 'core/resource', 'core/server'], fu
|
|||||||
|
|
||||||
|
|
||||||
function addTest(label, info, passed, result) {
|
function addTest(label, info, passed, result) {
|
||||||
|
|
||||||
var $test = $(tplTest).appendTo('#tests');
|
var $test = $(tplTest).appendTo('#tests');
|
||||||
$test.find('.label').text(label);
|
$test.find('.label').text(label);
|
||||||
$test.find('.result')
|
$test.find('.result')
|
||||||
.addClass(passed ? 'passed' : 'failed')
|
.addClass(passed ? 'passed' : 'failed')
|
||||||
.text(result ? result : (passed ? 'yes' : 'no'));
|
.text(result ? result : passed ? 'yes' : 'no');
|
||||||
$test.find('.info').html(info);
|
$test.find('.info').html(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
function addTests() {
|
function addTests() {
|
||||||
|
|
||||||
if (!setup.AS_ADMIN) {
|
if (!setup.AS_ADMIN) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -52,7 +49,7 @@ modulejs.define('main/info', ['$', 'config', 'core/resource', 'core/server'], fu
|
|||||||
|
|
||||||
addTest(
|
addTest(
|
||||||
'h5ai version', 'Only green if this is an official h5ai release',
|
'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(
|
addTest(
|
||||||
@@ -127,12 +124,10 @@ modulejs.define('main/info', ['$', 'config', 'core/resource', 'core/server'], fu
|
|||||||
}
|
}
|
||||||
|
|
||||||
function reload() {
|
function reload() {
|
||||||
|
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
function onLogin() {
|
function onLogin() {
|
||||||
|
|
||||||
server.request({
|
server.request({
|
||||||
action: 'login',
|
action: 'login',
|
||||||
pass: $('#pass').val()
|
pass: $('#pass').val()
|
||||||
@@ -140,26 +135,22 @@ modulejs.define('main/info', ['$', 'config', 'core/resource', 'core/server'], fu
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onLogout() {
|
function onLogout() {
|
||||||
|
|
||||||
server.request({
|
server.request({
|
||||||
action: 'logout'
|
action: 'logout'
|
||||||
}, reload);
|
}, reload);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onKeydown(event) {
|
function onKeydown(event) {
|
||||||
|
|
||||||
if (event.which === 13) {
|
if (event.which === 13) {
|
||||||
onLogin();
|
onLogin();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function addSupport() {
|
function addSupport() {
|
||||||
|
|
||||||
$(tplSupport).appendTo('#content');
|
$(tplSupport).appendTo('#content');
|
||||||
}
|
}
|
||||||
|
|
||||||
function addLogin() {
|
function addLogin() {
|
||||||
|
|
||||||
$(tplLogin).appendTo('#content');
|
$(tplLogin).appendTo('#content');
|
||||||
|
|
||||||
if (setup.AS_ADMIN) {
|
if (setup.AS_ADMIN) {
|
||||||
@@ -177,7 +168,6 @@ modulejs.define('main/info', ['$', 'config', 'core/resource', 'core/server'], fu
|
|||||||
}
|
}
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
|
|
||||||
addSupport();
|
addSupport();
|
||||||
addLogin();
|
addLogin();
|
||||||
addTests();
|
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) {
|
modulejs.define('model/item', ['_', 'core/event', 'core/location', 'core/server', 'core/settings', 'core/types'], function (_, event, location, server, settings, types) {
|
||||||
|
|
||||||
var reEndsWithSlash = /\/$/;
|
var reEndsWithSlash = /\/$/;
|
||||||
var reSplitPath = /^(.*\/)([^\/]+\/?)$/;
|
var reSplitPath = /^(.*\/)([^\/]+\/?)$/;
|
||||||
var cache = {};
|
var cache = {};
|
||||||
|
|
||||||
|
|
||||||
function startsWith(sequence, part) {
|
function startsWith(sequence, part) {
|
||||||
|
|
||||||
if (!sequence || !sequence.indexOf) {
|
if (!sequence || !sequence.indexOf) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -15,16 +13,14 @@ modulejs.define('model/item', ['_', 'core/event', 'core/location', 'core/server'
|
|||||||
}
|
}
|
||||||
|
|
||||||
function createLabel(sequence) {
|
function createLabel(sequence) {
|
||||||
|
|
||||||
sequence = sequence.replace(reEndsWithSlash, '');
|
sequence = sequence.replace(reEndsWithSlash, '');
|
||||||
try {
|
try {
|
||||||
sequence = decodeURIComponent(sequence);
|
sequence = decodeURIComponent(sequence);
|
||||||
} catch (e) {}
|
} catch (e) {/* skip */}
|
||||||
return sequence;
|
return sequence;
|
||||||
}
|
}
|
||||||
|
|
||||||
function splitPath(sequence) {
|
function splitPath(sequence) {
|
||||||
|
|
||||||
if (sequence === '/') {
|
if (sequence === '/') {
|
||||||
return {
|
return {
|
||||||
parent: null,
|
parent: null,
|
||||||
@@ -47,7 +43,6 @@ modulejs.define('model/item', ['_', 'core/event', 'core/location', 'core/server'
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getItem(options) {
|
function getItem(options) {
|
||||||
|
|
||||||
if (_.isString(options)) {
|
if (_.isString(options)) {
|
||||||
options = {href: options};
|
options = {href: options};
|
||||||
} else if (!options || !_.isString(options.href)) {
|
} else if (!options || !_.isString(options.href)) {
|
||||||
@@ -60,70 +55,64 @@ modulejs.define('model/item', ['_', 'core/event', 'core/location', 'core/server'
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var self = cache[href] || new Item(href);
|
var item = cache[href] || new Item(href);
|
||||||
|
|
||||||
if (_.isNumber(options.time)) {
|
if (_.isNumber(options.time)) {
|
||||||
self.time = options.time;
|
item.time = options.time;
|
||||||
}
|
}
|
||||||
if (_.isNumber(options.size)) {
|
if (_.isNumber(options.size)) {
|
||||||
self.size = options.size;
|
item.size = options.size;
|
||||||
}
|
}
|
||||||
if (options.managed) {
|
if (options.managed) {
|
||||||
self.isManaged = true;
|
item.isManaged = true;
|
||||||
}
|
}
|
||||||
if (options.fetched) {
|
if (options.fetched) {
|
||||||
self.isContentFetched = true;
|
item.isContentFetched = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeItem(absHref) {
|
function removeItem(absHref) {
|
||||||
|
|
||||||
absHref = location.forceEncoding(absHref);
|
absHref = location.forceEncoding(absHref);
|
||||||
|
|
||||||
var self = cache[absHref];
|
var item = cache[absHref];
|
||||||
|
|
||||||
if (self) {
|
if (item) {
|
||||||
delete cache[absHref];
|
delete cache[absHref];
|
||||||
if (self.parent) {
|
if (item.parent) {
|
||||||
delete self.parent.content[self.absHref];
|
delete item.parent.content[item.absHref];
|
||||||
}
|
}
|
||||||
_.each(self.content, function (item) {
|
_.each(item.content, function (child) {
|
||||||
|
removeItem(child.absHref);
|
||||||
removeItem(item.absHref);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function fetchContent(absHref, callback) {
|
function fetchContent(absHref, callback) {
|
||||||
|
var item = getItem(absHref);
|
||||||
var self = getItem(absHref);
|
|
||||||
|
|
||||||
if (!_.isFunction(callback)) {
|
if (!_.isFunction(callback)) {
|
||||||
callback = function () {};
|
callback = function () {};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self.isContentFetched) {
|
if (item.isContentFetched) {
|
||||||
callback(self);
|
callback(item);
|
||||||
} else {
|
} 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) {
|
if (response.items) {
|
||||||
_.each(response.items, function (jsonItem) {
|
_.each(response.items, function (jsonItem) {
|
||||||
|
|
||||||
getItem(jsonItem);
|
getItem(jsonItem);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
callback(self);
|
callback(item);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function Item(absHref) {
|
function Item(absHref) {
|
||||||
|
|
||||||
var split = splitPath(absHref);
|
var split = splitPath(absHref);
|
||||||
|
|
||||||
cache[absHref] = this;
|
cache[absHref] = this;
|
||||||
@@ -149,49 +138,40 @@ modulejs.define('model/item', ['_', 'core/event', 'core/location', 'core/server'
|
|||||||
_.extend(Item.prototype, {
|
_.extend(Item.prototype, {
|
||||||
|
|
||||||
isFolder: function () {
|
isFolder: function () {
|
||||||
|
|
||||||
return reEndsWithSlash.test(this.absHref);
|
return reEndsWithSlash.test(this.absHref);
|
||||||
},
|
},
|
||||||
|
|
||||||
isCurrentFolder: function () {
|
isCurrentFolder: function () {
|
||||||
|
|
||||||
return this.absHref === location.getAbsHref();
|
return this.absHref === location.getAbsHref();
|
||||||
},
|
},
|
||||||
|
|
||||||
isInCurrentFolder: function () {
|
isInCurrentFolder: function () {
|
||||||
|
|
||||||
return Boolean(this.parent) && this.parent.isCurrentFolder();
|
return Boolean(this.parent) && this.parent.isCurrentFolder();
|
||||||
},
|
},
|
||||||
|
|
||||||
isCurrentParentFolder: function () {
|
isCurrentParentFolder: function () {
|
||||||
|
|
||||||
var item = getItem(location.getAbsHref());
|
var item = getItem(location.getAbsHref());
|
||||||
return Boolean(item) && this === item.parent;
|
return Boolean(item) && this === item.parent;
|
||||||
},
|
},
|
||||||
|
|
||||||
isDomain: function () {
|
isDomain: function () {
|
||||||
|
|
||||||
return this.absHref === '/';
|
return this.absHref === '/';
|
||||||
},
|
},
|
||||||
|
|
||||||
isRoot: function () {
|
isRoot: function () {
|
||||||
|
|
||||||
return this.absHref === settings.rootHref;
|
return this.absHref === settings.rootHref;
|
||||||
},
|
},
|
||||||
|
|
||||||
isEmpty: function () {
|
isEmpty: function () {
|
||||||
|
|
||||||
return _.keys(this.content).length === 0;
|
return _.keys(this.content).length === 0;
|
||||||
},
|
},
|
||||||
|
|
||||||
fetchContent: function (callback) {
|
fetchContent: function (callback) {
|
||||||
|
|
||||||
return fetchContent(this.absHref, callback);
|
return fetchContent(this.absHref, callback);
|
||||||
},
|
},
|
||||||
|
|
||||||
getCrumb: function () {
|
getCrumb: function () {
|
||||||
|
var item = this; // eslint-disable-line consistent-this
|
||||||
var item = this;
|
|
||||||
var crumb = [item];
|
var crumb = [item];
|
||||||
|
|
||||||
while (item.parent) {
|
while (item.parent) {
|
||||||
@@ -203,23 +183,18 @@ modulejs.define('model/item', ['_', 'core/event', 'core/location', 'core/server'
|
|||||||
},
|
},
|
||||||
|
|
||||||
getSubfolders: function () {
|
getSubfolders: function () {
|
||||||
|
|
||||||
return _.sortBy(_.filter(this.content, function (item) {
|
return _.sortBy(_.filter(this.content, function (item) {
|
||||||
|
|
||||||
return item.isFolder();
|
return item.isFolder();
|
||||||
}), function (item) {
|
}), function (item) {
|
||||||
|
|
||||||
return item.label.toLowerCase();
|
return item.label.toLowerCase();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
getStats: function () {
|
getStats: function () {
|
||||||
|
|
||||||
var folders = 0;
|
var folders = 0;
|
||||||
var files = 0;
|
var files = 0;
|
||||||
|
|
||||||
_.each(this.content, function (item) {
|
_.each(this.content, function (item) {
|
||||||
|
|
||||||
if (item.isFolder()) {
|
if (item.isFolder()) {
|
||||||
folders += 1;
|
folders += 1;
|
||||||
} else {
|
} else {
|
||||||
@@ -228,7 +203,7 @@ modulejs.define('model/item', ['_', 'core/event', 'core/location', 'core/server'
|
|||||||
});
|
});
|
||||||
|
|
||||||
var depth = 0;
|
var depth = 0;
|
||||||
var item = this;
|
var item = this; // eslint-disable-line consistent-this
|
||||||
|
|
||||||
while (item.parent) {
|
while (item.parent) {
|
||||||
depth += 1;
|
depth += 1;
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
modulejs.define('view/content', ['$', 'view/mainrow'], function ($, mainrow) {
|
modulejs.define('view/content', ['$', 'view/mainrow'], function ($, mainrow) {
|
||||||
|
|
||||||
var $el = $('<div id="content"/>').appendTo(mainrow.$el);
|
var $el = $('<div id="content"/>').appendTo(mainrow.$el);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
modulejs.define('view/mainrow', ['$', 'view/root'], function ($, root) {
|
modulejs.define('view/mainrow', ['$', 'view/root'], function ($, root) {
|
||||||
|
|
||||||
var $el = $('<div id="mainrow"/>').appendTo(root.$el);
|
var $el = $('<div id="mainrow"/>').appendTo(root.$el);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@@ -1,9 +1,7 @@
|
|||||||
modulejs.define('view/notification', ['$', 'view/root'], function ($, root) {
|
modulejs.define('view/notification', ['$', 'view/root'], function ($, root) {
|
||||||
|
|
||||||
var $el = $('<div id="notification"/>').hide().appendTo(root.$el);
|
var $el = $('<div id="notification"/>').hide().appendTo(root.$el);
|
||||||
|
|
||||||
function set(content) {
|
function set(content) {
|
||||||
|
|
||||||
if (content) {
|
if (content) {
|
||||||
$el.stop(true, true).html(content).fadeIn(400);
|
$el.stop(true, true).html(content).fadeIn(400);
|
||||||
} else {
|
} else {
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
modulejs.define('view/root', ['$'], function ($) {
|
modulejs.define('view/root', ['$'], function ($) {
|
||||||
|
|
||||||
var $el = $('body').attr('id', 'root');
|
var $el = $('body').attr('id', 'root');
|
||||||
|
|
||||||
$('#fallback, #fallback-hints').remove();
|
$('#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) {
|
modulejs.define('view/sidebar', ['$', 'core/resource', 'core/store', 'view/mainrow', 'view/topbar'], function ($, resource, store, mainrow, topbar) {
|
||||||
|
|
||||||
var storekey = 'sidebarIsVisible';
|
var storekey = 'sidebarIsVisible';
|
||||||
var tplSidebar = '<div id="sidebar"/>';
|
var tplSidebar = '<div id="sidebar"/>';
|
||||||
var tplToggle =
|
var tplToggle =
|
||||||
@@ -12,7 +11,6 @@ modulejs.define('view/sidebar', ['$', 'core/resource', 'core/store', 'view/mainr
|
|||||||
|
|
||||||
|
|
||||||
function update(toggle) {
|
function update(toggle) {
|
||||||
|
|
||||||
var isVisible = store.get(storekey);
|
var isVisible = store.get(storekey);
|
||||||
|
|
||||||
if (toggle) {
|
if (toggle) {
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
modulejs.define('view/topbar', ['$', 'view/root'], function ($, root) {
|
modulejs.define('view/topbar', ['$', 'view/root'], function ($, root) {
|
||||||
|
|
||||||
var tplTopbar =
|
var tplTopbar =
|
||||||
'<div id="topbar">' +
|
'<div id="topbar">' +
|
||||||
'<div id="toolbar"/>' +
|
'<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) {
|
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 modes = ['details', 'grid', 'icons'];
|
||||||
var sizes = [20, 40, 60, 80, 100, 150, 200, 250, 300, 350, 400];
|
var sizes = [20, 40, 60, 80, 100, 150, 200, 250, 300, 350, 400];
|
||||||
var settings = _.extend({
|
var settings = _.extend({
|
||||||
@@ -41,12 +40,10 @@ modulejs.define('view/view', ['_', '$', 'core/event', 'core/format', 'core/locat
|
|||||||
|
|
||||||
|
|
||||||
function cropSize(size, min, max) {
|
function cropSize(size, min, max) {
|
||||||
|
|
||||||
return Math.min(max, Math.max(min, size));
|
return Math.min(max, Math.max(min, size));
|
||||||
}
|
}
|
||||||
|
|
||||||
function createStyles(size) {
|
function createStyles(size) {
|
||||||
|
|
||||||
var dsize = cropSize(size, 20, 80);
|
var dsize = cropSize(size, 20, 80);
|
||||||
var gsize = cropSize(size, 40, 160);
|
var gsize = cropSize(size, 40, 160);
|
||||||
var isize = cropSize(size, 80, 1000);
|
var isize = cropSize(size, 80, 1000);
|
||||||
@@ -73,14 +70,12 @@ modulejs.define('view/view', ['_', '$', 'core/event', 'core/format', 'core/locat
|
|||||||
}
|
}
|
||||||
|
|
||||||
function addCssStyles() {
|
function addCssStyles() {
|
||||||
|
|
||||||
var styles = _.map(sortedSizes, function (size) { return createStyles(size); });
|
var styles = _.map(sortedSizes, function (size) { return createStyles(size); });
|
||||||
styles.push('#view .icon img { max-width: ' + settings.maxIconSize + 'px; max-height: ' + settings.maxIconSize + 'px; }');
|
styles.push('#view .icon img { max-width: ' + settings.maxIconSize + 'px; max-height: ' + settings.maxIconSize + 'px; }');
|
||||||
$('<style/>').text(styles.join('\n')).appendTo('head');
|
$('<style/>').text(styles.join('\n')).appendTo('head');
|
||||||
}
|
}
|
||||||
|
|
||||||
function set(mode, size) {
|
function set(mode, size) {
|
||||||
|
|
||||||
var stored = store.get(storekey);
|
var stored = store.get(storekey);
|
||||||
|
|
||||||
mode = mode || stored && stored.mode;
|
mode = mode || stored && stored.mode;
|
||||||
@@ -109,37 +104,30 @@ modulejs.define('view/view', ['_', '$', 'core/event', 'core/format', 'core/locat
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getModes() {
|
function getModes() {
|
||||||
|
|
||||||
return checkedModes;
|
return checkedModes;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSizes() {
|
function getSizes() {
|
||||||
|
|
||||||
return sortedSizes;
|
return sortedSizes;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getMode() {
|
function getMode() {
|
||||||
|
|
||||||
return store.get(storekey).mode;
|
return store.get(storekey).mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setMode(mode) {
|
function setMode(mode) {
|
||||||
|
|
||||||
set(mode, null);
|
set(mode, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSize() {
|
function getSize() {
|
||||||
|
|
||||||
return store.get(storekey).size;
|
return store.get(storekey).size;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setSize(size) {
|
function setSize(size) {
|
||||||
|
|
||||||
set(null, size);
|
set(null, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
function createHtml(item) {
|
function createHtml(item) {
|
||||||
|
|
||||||
var $html = $(tplItem);
|
var $html = $(tplItem);
|
||||||
var $a = $html.find('a');
|
var $a = $html.find('a');
|
||||||
var $iconImg = $html.find('.icon img');
|
var $iconImg = $html.find('.icon img');
|
||||||
@@ -178,56 +166,16 @@ modulejs.define('view/view', ['_', '$', 'core/event', 'core/format', 'core/locat
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onMouseenter() {
|
function onMouseenter() {
|
||||||
|
|
||||||
var item = $(this).closest('.item').data('item');
|
var item = $(this).closest('.item').data('item');
|
||||||
event.pub('item.mouseenter', item);
|
event.pub('item.mouseenter', item);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onMouseleave() {
|
function onMouseleave() {
|
||||||
|
|
||||||
var item = $(this).closest('.item').data('item');
|
var item = $(this).closest('.item').data('item');
|
||||||
event.pub('item.mouseleave', item);
|
event.pub('item.mouseleave', item);
|
||||||
}
|
}
|
||||||
|
|
||||||
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() {
|
function checkHint() {
|
||||||
|
|
||||||
var hasNoItems = $items.find('.item').not('.folder-parent').length === 0;
|
var hasNoItems = $items.find('.item').not('.folder-parent').length === 0;
|
||||||
|
|
||||||
if (hasNoItems) {
|
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);
|
$hint.removeClass().addClass('l10n-' + l10nKey);
|
||||||
checkHint();
|
checkHint();
|
||||||
}
|
}
|
||||||
|
|
||||||
function onLocationChanged(item) {
|
function onLocationChanged(item) {
|
||||||
|
|
||||||
if (!item) {
|
if (!item) {
|
||||||
item = location.getItem();
|
item = location.getItem();
|
||||||
}
|
}
|
||||||
@@ -255,10 +232,9 @@ modulejs.define('view/view', ['_', '$', 'core/event', 'core/format', 'core/locat
|
|||||||
items.push(item.parent);
|
items.push(item.parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
_.each(item.content, function (item) {
|
_.each(item.content, function (child) {
|
||||||
|
if (!(child.isFolder() && settings.hideFolders)) {
|
||||||
if (!(item.isFolder() && settings.hideFolders)) {
|
items.push(child);
|
||||||
items.push(item);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -267,13 +243,11 @@ modulejs.define('view/view', ['_', '$', 'core/event', 'core/format', 'core/locat
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onLocationRefreshed(item, added, removed) {
|
function onLocationRefreshed(item, added, removed) {
|
||||||
|
|
||||||
var add = [];
|
var add = [];
|
||||||
|
|
||||||
_.each(added, function (item) {
|
_.each(added, function (child) {
|
||||||
|
if (!(child.isFolder() && settings.hideFolders)) {
|
||||||
if (!(item.isFolder() && settings.hideFolders)) {
|
add.push(child);
|
||||||
add.push(item);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -282,7 +256,6 @@ modulejs.define('view/view', ['_', '$', 'core/event', 'core/format', 'core/locat
|
|||||||
}
|
}
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
|
|
||||||
addCssStyles();
|
addCssStyles();
|
||||||
set();
|
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) {
|
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({
|
var settings = _.extend({
|
||||||
modeToggle: false
|
modeToggle: false
|
||||||
}, allsettings.view);
|
}, allsettings.view);
|
||||||
@@ -20,7 +19,6 @@ modulejs.define('view/viewmode', ['_', '$', 'core/event', 'core/resource', 'core
|
|||||||
|
|
||||||
|
|
||||||
function onChanged(mode, size) {
|
function onChanged(mode, size) {
|
||||||
|
|
||||||
$('#viewmode-settings .mode').removeClass('active');
|
$('#viewmode-settings .mode').removeClass('active');
|
||||||
$('#viewmode-' + mode).addClass('active');
|
$('#viewmode-' + mode).addClass('active');
|
||||||
$('#viewmode-size').val(_.indexOf(sizes, size));
|
$('#viewmode-size').val(_.indexOf(sizes, size));
|
||||||
@@ -32,7 +30,6 @@ modulejs.define('view/viewmode', ['_', '$', 'core/event', 'core/resource', 'core
|
|||||||
}
|
}
|
||||||
|
|
||||||
function addSettings() {
|
function addSettings() {
|
||||||
|
|
||||||
if (modes.length < 2 && sizes.length < 2) {
|
if (modes.length < 2 && sizes.length < 2) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -43,7 +40,6 @@ modulejs.define('view/viewmode', ['_', '$', 'core/event', 'core/resource', 'core
|
|||||||
_.each(modes, function (mode) {
|
_.each(modes, function (mode) {
|
||||||
$(tplMode.replace(/\[MODE\]/g, mode))
|
$(tplMode.replace(/\[MODE\]/g, mode))
|
||||||
.on('click', function () {
|
.on('click', function () {
|
||||||
|
|
||||||
view.setMode(mode);
|
view.setMode(mode);
|
||||||
})
|
})
|
||||||
.appendTo($viewBlock);
|
.appendTo($viewBlock);
|
||||||
@@ -55,7 +51,6 @@ modulejs.define('view/viewmode', ['_', '$', 'core/event', 'core/resource', 'core
|
|||||||
$(tplSize)
|
$(tplSize)
|
||||||
.prop('max', max).attr('max', max)
|
.prop('max', max).attr('max', max)
|
||||||
.on('input change', function (ev) {
|
.on('input change', function (ev) {
|
||||||
|
|
||||||
view.setSize(sizes[ev.target.valueAsNumber]);
|
view.setSize(sizes[ev.target.valueAsNumber]);
|
||||||
})
|
})
|
||||||
.appendTo($viewBlock);
|
.appendTo($viewBlock);
|
||||||
@@ -65,7 +60,6 @@ modulejs.define('view/viewmode', ['_', '$', 'core/event', 'core/resource', 'core
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onToggle() {
|
function onToggle() {
|
||||||
|
|
||||||
var mode = view.getMode();
|
var mode = view.getMode();
|
||||||
var nextIdx = (modes.indexOf(mode) + 1) % modes.length;
|
var nextIdx = (modes.indexOf(mode) + 1) % modes.length;
|
||||||
var nextMode = modes[nextIdx];
|
var nextMode = modes[nextIdx];
|
||||||
@@ -74,7 +68,6 @@ modulejs.define('view/viewmode', ['_', '$', 'core/event', 'core/resource', 'core
|
|||||||
}
|
}
|
||||||
|
|
||||||
function addToggle() {
|
function addToggle() {
|
||||||
|
|
||||||
if (settings.modeToggle && modes.length > 1) {
|
if (settings.modeToggle && modes.length > 1) {
|
||||||
$(tplToggle)
|
$(tplToggle)
|
||||||
.on('click', onToggle)
|
.on('click', onToggle)
|
||||||
@@ -83,7 +76,6 @@ modulejs.define('view/viewmode', ['_', '$', 'core/event', 'core/resource', 'core
|
|||||||
}
|
}
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
|
|
||||||
modes = view.getModes();
|
modes = view.getModes();
|
||||||
sizes = view.getSizes();
|
sizes = view.getSizes();
|
||||||
|
|
||||||
|
@@ -17,7 +17,7 @@
|
|||||||
// @include 'vendor/prism-*.js'
|
// @include 'vendor/prism-*.js'
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
'use strict'; // eslint-disable-line strict
|
||||||
|
|
||||||
var win = window;
|
var win = window;
|
||||||
modulejs.define('_', function () { return win._; });
|
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,14 +1,14 @@
|
|||||||
doctype html
|
doctype html
|
||||||
html
|
html
|
||||||
head
|
head
|
||||||
meta( charset="utf-8" )
|
meta(charset="utf-8")
|
||||||
meta( http-equiv="x-ua-compatible", content="ie=edge" )
|
meta(http-equiv="x-ua-compatible", content="ie=edge")
|
||||||
title h5ai test suite - v#{pkg.version}
|
title h5ai test suite - v#{pkg.version}
|
||||||
meta( name="viewport", content="width=device-width, initial-scale=1" )
|
meta(name="viewport", content="width=device-width, initial-scale=1")
|
||||||
link( rel="stylesheet", href="h5ai-styles.css" )
|
link(rel="stylesheet", href="h5ai-styles.css")
|
||||||
link( rel="stylesheet", href="styles.css" )
|
link(rel="stylesheet", href="styles.css")
|
||||||
script( src="h5ai-scripts.js" )
|
script(src="h5ai-scripts.js")
|
||||||
script( src="scripts.js" )
|
script(src="scripts.js")
|
||||||
|
|
||||||
body
|
body
|
||||||
div#mocha
|
div#mocha
|
||||||
|
@@ -1,19 +1,21 @@
|
|||||||
// @include "vendor/*.js"
|
// @include "vendor/*.js"
|
||||||
// @include "util/*.js"
|
|
||||||
|
|
||||||
$(function () {
|
(function () {
|
||||||
'use strict';
|
'use strict'; // eslint-disable-line strict
|
||||||
|
// @include "util/*.js"
|
||||||
|
}());
|
||||||
|
|
||||||
|
jQuery(function () {
|
||||||
|
'use strict'; // eslint-disable-line strict
|
||||||
|
|
||||||
util.mockConfigModule();
|
util.mockConfigModule();
|
||||||
util.clearModulejs();
|
util.clearModulejs();
|
||||||
util.setupMocha();
|
util.setupMocha();
|
||||||
|
|
||||||
describe('all tests', function () {
|
describe('all tests', function () {
|
||||||
|
|
||||||
// @include "tests/premisses.js"
|
// @include "tests/premisses.js"
|
||||||
|
|
||||||
describe('unit tests', function () {
|
describe('unit tests', function () {
|
||||||
|
|
||||||
// @include "tests/unit/modulejs.js"
|
// @include "tests/unit/modulejs.js"
|
||||||
// @include "tests/unit/libs.js"
|
// @include "tests/unit/libs.js"
|
||||||
// @include "tests/unit/boot.js"
|
// @include "tests/unit/boot.js"
|
||||||
@@ -23,7 +25,6 @@ $(function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('integration tests', function () {
|
describe('integration tests', function () {
|
||||||
|
|
||||||
// @include "tests/integration/*.js"
|
// @include "tests/integration/*.js"
|
||||||
// @-include "tests/integration/*/*.js"
|
// @-include "tests/integration/*/*.js"
|
||||||
});
|
});
|
||||||
|
@@ -1,10 +1,6 @@
|
|||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
describe('view', function () {
|
||||||
|
|
||||||
describe('view', function () {
|
|
||||||
|
|
||||||
before(function () {
|
before(function () {
|
||||||
|
|
||||||
this.configBackup = modulejs._private.definitions.config;
|
this.configBackup = modulejs._private.definitions.config;
|
||||||
this.storeKey = '_h5ai';
|
this.storeKey = '_h5ai';
|
||||||
this.xConfig = {
|
this.xConfig = {
|
||||||
@@ -16,14 +12,12 @@ describe('view', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
after(function () {
|
after(function () {
|
||||||
|
|
||||||
modulejs._private.definitions.config = this.configBackup;
|
modulejs._private.definitions.config = this.configBackup;
|
||||||
util.clearModulejs();
|
util.clearModulejs();
|
||||||
util.restoreHtml();
|
util.restoreHtml();
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
|
|
||||||
delete modulejs._private.definitions.config;
|
delete modulejs._private.definitions.config;
|
||||||
modulejs.define('config', this.xConfig);
|
modulejs.define('config', this.xConfig);
|
||||||
util.clearModulejs();
|
util.clearModulejs();
|
||||||
@@ -33,97 +27,80 @@ describe('view', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('requiring \'view/viewmode\' sets up basic HTML', function () {
|
describe('requiring \'view/viewmode\' sets up basic HTML', function () {
|
||||||
|
|
||||||
it('runs without errors', function () {
|
it('runs without errors', function () {
|
||||||
|
|
||||||
modulejs.require('view/viewmode');
|
modulejs.require('view/viewmode');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('adds id root to body', function () {
|
it('adds id root to body', function () {
|
||||||
|
|
||||||
modulejs.require('view/viewmode');
|
modulejs.require('view/viewmode');
|
||||||
assert.strictEqual($('body').attr('id'), 'root');
|
assert.strictEqual($('body').attr('id'), 'root');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('removes HTML #fallback', function () {
|
it('removes HTML #fallback', function () {
|
||||||
|
|
||||||
modulejs.require('view/viewmode');
|
modulejs.require('view/viewmode');
|
||||||
assert.lengthOf($('#fallback'), 0);
|
assert.lengthOf($('#fallback'), 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('removes HTML #fallback-hints', function () {
|
it('removes HTML #fallback-hints', function () {
|
||||||
|
|
||||||
modulejs.require('view/viewmode');
|
modulejs.require('view/viewmode');
|
||||||
assert.lengthOf($('#fallback-hints'), 0);
|
assert.lengthOf($('#fallback-hints'), 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('adds HTML #mainrow to #root', function () {
|
it('adds HTML #mainrow to #root', function () {
|
||||||
|
|
||||||
modulejs.require('view/viewmode');
|
modulejs.require('view/viewmode');
|
||||||
assert.lengthOf($('#root > #mainrow'), 1);
|
assert.lengthOf($('#root > #mainrow'), 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('adds HTML #content to #mainrow', function () {
|
it('adds HTML #content to #mainrow', function () {
|
||||||
|
|
||||||
modulejs.require('view/viewmode');
|
modulejs.require('view/viewmode');
|
||||||
assert.lengthOf($('#mainrow > #content'), 1);
|
assert.lengthOf($('#mainrow > #content'), 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('adds HTML #view to #content', function () {
|
it('adds HTML #view to #content', function () {
|
||||||
|
|
||||||
modulejs.require('view/viewmode');
|
modulejs.require('view/viewmode');
|
||||||
assert.lengthOf($('#content > #view'), 1);
|
assert.lengthOf($('#content > #view'), 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('adds HTML #items to #view', function () {
|
it('adds HTML #items to #view', function () {
|
||||||
|
|
||||||
modulejs.require('view/viewmode');
|
modulejs.require('view/viewmode');
|
||||||
assert.lengthOf($('#view > #items'), 1);
|
assert.lengthOf($('#view > #items'), 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('adds HTML #topbar to #root', function () {
|
it('adds HTML #topbar to #root', function () {
|
||||||
|
|
||||||
modulejs.require('view/viewmode');
|
modulejs.require('view/viewmode');
|
||||||
assert.lengthOf($('#root > #topbar'), 1);
|
assert.lengthOf($('#root > #topbar'), 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('adds HTML #toolbar to #topbar', function () {
|
it('adds HTML #toolbar to #topbar', function () {
|
||||||
|
|
||||||
modulejs.require('view/viewmode');
|
modulejs.require('view/viewmode');
|
||||||
assert.lengthOf($('#topbar > #toolbar'), 1);
|
assert.lengthOf($('#topbar > #toolbar'), 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('adds HTML #flowbar to #topbar', function () {
|
it('adds HTML #flowbar to #topbar', function () {
|
||||||
|
|
||||||
modulejs.require('view/viewmode');
|
modulejs.require('view/viewmode');
|
||||||
assert.lengthOf($('#topbar > #flowbar'), 1);
|
assert.lengthOf($('#topbar > #flowbar'), 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('adds HTML #backlink to #topbar', function () {
|
it('adds HTML #backlink to #topbar', function () {
|
||||||
|
|
||||||
modulejs.require('view/viewmode');
|
modulejs.require('view/viewmode');
|
||||||
assert.lengthOf($('#topbar > #backlink'), 1);
|
assert.lengthOf($('#topbar > #backlink'), 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('adds HTML #sidebar-toggle to #toolbar', function () {
|
it('adds HTML #sidebar-toggle to #toolbar', function () {
|
||||||
|
|
||||||
modulejs.require('view/viewmode');
|
modulejs.require('view/viewmode');
|
||||||
assert.lengthOf($('#toolbar > #sidebar-toggle'), 1);
|
assert.lengthOf($('#toolbar > #sidebar-toggle'), 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('adds HTML #viewmode-settings to #sidebar', function () {
|
it('adds HTML #viewmode-settings to #sidebar', function () {
|
||||||
|
|
||||||
modulejs.require('view/viewmode');
|
modulejs.require('view/viewmode');
|
||||||
assert.lengthOf($('#sidebar > #viewmode-settings'), 1);
|
assert.lengthOf($('#sidebar > #viewmode-settings'), 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('adds style to head', function () {
|
it('adds style to head', function () {
|
||||||
|
|
||||||
var styleTagCount = $('head > style').length;
|
var styleTagCount = $('head > style').length;
|
||||||
modulejs.require('view/viewmode');
|
modulejs.require('view/viewmode');
|
||||||
assert.lengthOf($('head > style'), styleTagCount + 1);
|
assert.lengthOf($('head > style'), styleTagCount + 1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
@@ -1,22 +1,16 @@
|
|||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
describe('premisses', function () {
|
||||||
|
|
||||||
describe('premisses', function () {
|
|
||||||
|
|
||||||
it('window is global object', function () {
|
it('window is global object', function () {
|
||||||
|
|
||||||
assert.isObject(window);
|
assert.isObject(window);
|
||||||
assert.strictEqual(window, window.window);
|
assert.strictEqual(window, window.window);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('document is global object', function () {
|
it('document is global object', function () {
|
||||||
|
|
||||||
assert.isObject(document);
|
assert.isObject(document);
|
||||||
assert.strictEqual(document, window.document);
|
assert.strictEqual(document, window.document);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('jQuery and $ are global functions', function () {
|
it('jQuery and $ are global functions', function () {
|
||||||
|
|
||||||
assert.isFunction(jQuery);
|
assert.isFunction(jQuery);
|
||||||
assert.strictEqual(jQuery, window.jQuery);
|
assert.strictEqual(jQuery, window.jQuery);
|
||||||
assert.strictEqual(jQuery.fn.jquery, '2.1.3');
|
assert.strictEqual(jQuery.fn.jquery, '2.1.3');
|
||||||
@@ -26,32 +20,28 @@ describe('premisses', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('_ is global function', function () {
|
it('_ is global function', function () {
|
||||||
|
|
||||||
assert.isFunction(_);
|
assert.isFunction(_);
|
||||||
assert.strictEqual(_, window._);
|
assert.strictEqual(_, window._);
|
||||||
assert.strictEqual(_.VERSION, '3.9.3');
|
assert.strictEqual(_.VERSION, '3.9.3');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('util is global object', function () {
|
it('util is global object', function () {
|
||||||
|
|
||||||
assert.isPlainObject(util);
|
assert.isPlainObject(util);
|
||||||
assert.strictEqual(util, window.util);
|
assert.strictEqual(util, window.util);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('uniq is global object', function () {
|
it('uniq is global object', function () {
|
||||||
|
|
||||||
assert.isPlainObject(uniq);
|
assert.isPlainObject(uniq);
|
||||||
assert.strictEqual(uniq, window.uniq);
|
assert.strictEqual(uniq, window.uniq);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('assert.isPlainObject() works', function () {
|
it('assert.isPlainObject() works', function () {
|
||||||
|
|
||||||
assert.isFunction(assert.isPlainObject);
|
assert.isFunction(assert.isPlainObject);
|
||||||
|
|
||||||
assert.isPlainObject({});
|
assert.isPlainObject({});
|
||||||
assert.isPlainObject({a: 1});
|
assert.isPlainObject({a: 1});
|
||||||
assert.isPlainObject(Object());
|
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(); });
|
||||||
assert.throws(function () { assert.isPlainObject(1); });
|
assert.throws(function () { assert.isPlainObject(1); });
|
||||||
@@ -63,7 +53,6 @@ describe('premisses', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('assert.lengthOfKeys() works', function () {
|
it('assert.lengthOfKeys() works', function () {
|
||||||
|
|
||||||
assert.isFunction(assert.lengthOfKeys);
|
assert.isFunction(assert.lengthOfKeys);
|
||||||
|
|
||||||
assert.lengthOfKeys({}, 0);
|
assert.lengthOfKeys({}, 0);
|
||||||
@@ -76,6 +65,5 @@ describe('premisses', function () {
|
|||||||
assert.throws(function () { assert.lengthOfKeys({}); });
|
assert.throws(function () { assert.lengthOfKeys({}); });
|
||||||
assert.throws(function () { assert.lengthOfKeys({}, 1); });
|
assert.throws(function () { assert.lengthOfKeys({}, 1); });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
@@ -1,13 +1,9 @@
|
|||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
var ID = 'boot';
|
||||||
|
var DEPS = ['$', 'core/server'];
|
||||||
var ID = 'boot';
|
|
||||||
var DEPS = ['$', 'core/server'];
|
|
||||||
|
|
||||||
describe('module \'' + ID + '\'', function () {
|
|
||||||
|
|
||||||
|
describe('module \'' + ID + '\'', function () {
|
||||||
before(function () {
|
before(function () {
|
||||||
|
|
||||||
this.definition = modulejs._private.definitions[ID];
|
this.definition = modulejs._private.definitions[ID];
|
||||||
|
|
||||||
this.xConfig = uniq.obj();
|
this.xConfig = uniq.obj();
|
||||||
@@ -18,7 +14,6 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
};
|
};
|
||||||
|
|
||||||
this.applyFn = function () {
|
this.applyFn = function () {
|
||||||
|
|
||||||
this.xDefine.reset();
|
this.xDefine.reset();
|
||||||
this.xRequire.reset();
|
this.xRequire.reset();
|
||||||
this.xServer.request.reset();
|
this.xServer.request.reset();
|
||||||
@@ -28,60 +23,48 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
after(function () {
|
after(function () {
|
||||||
|
|
||||||
this.xDefine.restore();
|
this.xDefine.restore();
|
||||||
this.xRequire.restore();
|
this.xRequire.restore();
|
||||||
util.restoreHtml();
|
util.restoreHtml();
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
|
|
||||||
util.restoreHtml();
|
util.restoreHtml();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('definition', function () {
|
describe('definition', function () {
|
||||||
|
|
||||||
it('is defined', function () {
|
it('is defined', function () {
|
||||||
|
|
||||||
assert.isPlainObject(this.definition);
|
assert.isPlainObject(this.definition);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has correct id', function () {
|
it('has correct id', function () {
|
||||||
|
|
||||||
assert.strictEqual(this.definition.id, ID);
|
assert.strictEqual(this.definition.id, ID);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('requires correct', function () {
|
it('requires correct', function () {
|
||||||
|
|
||||||
assert.deepEqual(this.definition.deps, DEPS);
|
assert.deepEqual(this.definition.deps, DEPS);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('args for each request', function () {
|
it('args for each request', function () {
|
||||||
|
|
||||||
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has no instance', function () {
|
it('has no instance', function () {
|
||||||
|
|
||||||
assert.notProperty(modulejs._private.instances, ID);
|
assert.notProperty(modulejs._private.instances, ID);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('inits without errors', function () {
|
it('inits without errors', function () {
|
||||||
|
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('application', function () {
|
describe('application', function () {
|
||||||
|
|
||||||
it('returns undefined', function () {
|
it('returns undefined', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isUndefined(instance);
|
assert.isUndefined(instance);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('no data-module', function () {
|
it('no data-module', function () {
|
||||||
|
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
assert.isFalse(this.xServer.request.called);
|
assert.isFalse(this.xServer.request.called);
|
||||||
assert.isFalse(this.xDefine.called);
|
assert.isFalse(this.xDefine.called);
|
||||||
@@ -89,7 +72,6 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('data-module=\'test\'', function () {
|
it('data-module=\'test\'', function () {
|
||||||
|
|
||||||
$('<script/>').attr('data-module', 'test').appendTo('head');
|
$('<script/>').attr('data-module', 'test').appendTo('head');
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
assert.isFalse(this.xServer.request.called);
|
assert.isFalse(this.xServer.request.called);
|
||||||
@@ -98,7 +80,6 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('data-module=\'info\'', function () {
|
it('data-module=\'info\'', function () {
|
||||||
|
|
||||||
var expectedData = {
|
var expectedData = {
|
||||||
action: 'get',
|
action: 'get',
|
||||||
setup: true,
|
setup: true,
|
||||||
@@ -124,7 +105,6 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('data-module=\'index\'', function () {
|
it('data-module=\'index\'', function () {
|
||||||
|
|
||||||
var expectedData = {
|
var expectedData = {
|
||||||
action: 'get',
|
action: 'get',
|
||||||
setup: true,
|
setup: true,
|
||||||
@@ -150,6 +130,5 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
assert.deepEqual(this.xRequire.lastCall.args, ['main/index']);
|
assert.deepEqual(this.xRequire.lastCall.args, ['main/index']);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
@@ -1,61 +1,47 @@
|
|||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
var ID = 'config';
|
||||||
|
var DEPS = [];
|
||||||
var ID = 'config';
|
|
||||||
var DEPS = [];
|
|
||||||
|
|
||||||
describe('module \'' + ID + '\'', function () {
|
|
||||||
|
|
||||||
|
describe('module \'' + ID + '\'', function () {
|
||||||
before(function () {
|
before(function () {
|
||||||
|
|
||||||
this.definition = modulejs._private.definitions[ID];
|
this.definition = modulejs._private.definitions[ID];
|
||||||
|
|
||||||
this.applyFn = function () {
|
this.applyFn = function () {
|
||||||
|
|
||||||
return this.definition.fn($);
|
return this.definition.fn($);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('definition', function () {
|
describe('definition', function () {
|
||||||
|
|
||||||
it('is defined', function () {
|
it('is defined', function () {
|
||||||
|
|
||||||
assert.isPlainObject(this.definition);
|
assert.isPlainObject(this.definition);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has correct id', function () {
|
it('has correct id', function () {
|
||||||
|
|
||||||
assert.strictEqual(this.definition.id, ID);
|
assert.strictEqual(this.definition.id, ID);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('requires correct', function () {
|
it('requires correct', function () {
|
||||||
|
|
||||||
assert.deepEqual(this.definition.deps, DEPS);
|
assert.deepEqual(this.definition.deps, DEPS);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('args for each request', function () {
|
it('args for each request', function () {
|
||||||
|
|
||||||
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has no instance', function () {
|
it('has no instance', function () {
|
||||||
|
|
||||||
assert.notProperty(modulejs._private.instances, ID);
|
assert.notProperty(modulejs._private.instances, ID);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('inits without errors', function () {
|
it('inits without errors', function () {
|
||||||
|
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('is only dummy definition', function () {
|
it('is only dummy definition', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isPlainObject(instance);
|
assert.isPlainObject(instance);
|
||||||
assert.lengthOfKeys(instance, 1);
|
assert.lengthOfKeys(instance, 1);
|
||||||
assert.isTrue(uniq.isId(instance._uniq_id));
|
assert.isTrue(uniq.isId(instance._uniq_id));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
@@ -1,58 +1,44 @@
|
|||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
var ID = 'core/event';
|
||||||
|
var DEPS = ['_'];
|
||||||
var ID = 'core/event';
|
|
||||||
var DEPS = ['_'];
|
|
||||||
|
|
||||||
describe('module \'' + ID + '\'', function () {
|
|
||||||
|
|
||||||
|
describe('module \'' + ID + '\'', function () {
|
||||||
before(function () {
|
before(function () {
|
||||||
|
|
||||||
this.definition = modulejs._private.definitions[ID];
|
this.definition = modulejs._private.definitions[ID];
|
||||||
|
|
||||||
this.applyFn = function () {
|
this.applyFn = function () {
|
||||||
|
|
||||||
return this.definition.fn(_);
|
return this.definition.fn(_);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('definition', function () {
|
describe('definition', function () {
|
||||||
|
|
||||||
it('is defined', function () {
|
it('is defined', function () {
|
||||||
|
|
||||||
assert.isPlainObject(this.definition);
|
assert.isPlainObject(this.definition);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has correct id', function () {
|
it('has correct id', function () {
|
||||||
|
|
||||||
assert.strictEqual(this.definition.id, ID);
|
assert.strictEqual(this.definition.id, ID);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('requires correct', function () {
|
it('requires correct', function () {
|
||||||
|
|
||||||
assert.deepEqual(this.definition.deps, DEPS);
|
assert.deepEqual(this.definition.deps, DEPS);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('args for each request', function () {
|
it('args for each request', function () {
|
||||||
|
|
||||||
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has no instance', function () {
|
it('has no instance', function () {
|
||||||
|
|
||||||
assert.notProperty(modulejs._private.instances, ID);
|
assert.notProperty(modulejs._private.instances, ID);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('inits without errors', function () {
|
it('inits without errors', function () {
|
||||||
|
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('application', function () {
|
describe('application', function () {
|
||||||
|
|
||||||
it('returns plain object with 3 properties', function () {
|
it('returns plain object with 3 properties', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isPlainObject(instance);
|
assert.isPlainObject(instance);
|
||||||
assert.lengthOfKeys(instance, 3);
|
assert.lengthOfKeys(instance, 3);
|
||||||
@@ -60,36 +46,28 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('.sub()', function () {
|
describe('.sub()', function () {
|
||||||
|
|
||||||
it('is function', function () {
|
it('is function', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isFunction(instance.sub);
|
assert.isFunction(instance.sub);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('.unsub()', function () {
|
describe('.unsub()', function () {
|
||||||
|
|
||||||
it('is function', function () {
|
it('is function', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isFunction(instance.unsub);
|
assert.isFunction(instance.unsub);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('.pub()', function () {
|
describe('.pub()', function () {
|
||||||
|
|
||||||
it('is function', function () {
|
it('is function', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isFunction(instance.pub);
|
assert.isFunction(instance.pub);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('works', function () {
|
describe('works', function () {
|
||||||
|
|
||||||
it('works', function () {
|
it('works', function () {
|
||||||
|
|
||||||
var topic = 'topic';
|
var topic = 'topic';
|
||||||
var arg1 = 'arg1';
|
var arg1 = 'arg1';
|
||||||
var arg2 = 'arg2';
|
var arg2 = 'arg2';
|
||||||
@@ -122,6 +100,5 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
assert.deepEqual(subSpy.secondCall.args, [arg1, arg2]);
|
assert.deepEqual(subSpy.secondCall.args, [arg1, arg2]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
@@ -1,58 +1,44 @@
|
|||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
var ID = 'core/format';
|
||||||
|
var DEPS = ['_'];
|
||||||
var ID = 'core/format';
|
|
||||||
var DEPS = ['_'];
|
|
||||||
|
|
||||||
describe('module \'' + ID + '\'', function () {
|
|
||||||
|
|
||||||
|
describe('module \'' + ID + '\'', function () {
|
||||||
before(function () {
|
before(function () {
|
||||||
|
|
||||||
this.definition = modulejs._private.definitions[ID];
|
this.definition = modulejs._private.definitions[ID];
|
||||||
|
|
||||||
this.applyFn = function () {
|
this.applyFn = function () {
|
||||||
|
|
||||||
return this.definition.fn(_);
|
return this.definition.fn(_);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('definition', function () {
|
describe('definition', function () {
|
||||||
|
|
||||||
it('is defined', function () {
|
it('is defined', function () {
|
||||||
|
|
||||||
assert.isPlainObject(this.definition);
|
assert.isPlainObject(this.definition);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has correct id', function () {
|
it('has correct id', function () {
|
||||||
|
|
||||||
assert.strictEqual(this.definition.id, ID);
|
assert.strictEqual(this.definition.id, ID);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('requires correct', function () {
|
it('requires correct', function () {
|
||||||
|
|
||||||
assert.deepEqual(this.definition.deps, DEPS);
|
assert.deepEqual(this.definition.deps, DEPS);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('args for each request', function () {
|
it('args for each request', function () {
|
||||||
|
|
||||||
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has no instance', function () {
|
it('has no instance', function () {
|
||||||
|
|
||||||
assert.notProperty(modulejs._private.instances, ID);
|
assert.notProperty(modulejs._private.instances, ID);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('inits without errors', function () {
|
it('inits without errors', function () {
|
||||||
|
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('application', function () {
|
describe('application', function () {
|
||||||
|
|
||||||
it('returns plain object with 4 properties', function () {
|
it('returns plain object with 4 properties', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isPlainObject(instance);
|
assert.isPlainObject(instance);
|
||||||
assert.lengthOfKeys(instance, 4);
|
assert.lengthOfKeys(instance, 4);
|
||||||
@@ -60,24 +46,19 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('.setDefaultMetric()', function () {
|
describe('.setDefaultMetric()', function () {
|
||||||
|
|
||||||
it('is function', function () {
|
it('is function', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isFunction(instance.setDefaultMetric);
|
assert.isFunction(instance.setDefaultMetric);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('.formatSize()', function () {
|
describe('.formatSize()', function () {
|
||||||
|
|
||||||
it('is function', function () {
|
it('is function', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isFunction(instance.formatSize);
|
assert.isFunction(instance.formatSize);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('defaults to decimal metric', function () {
|
it('defaults to decimal metric', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.strictEqual(instance.formatSize(1024), '1 KB');
|
assert.strictEqual(instance.formatSize(1024), '1 KB');
|
||||||
instance.setDefaultMetric(true);
|
instance.setDefaultMetric(true);
|
||||||
@@ -87,7 +68,6 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('decimal metric', function () {
|
describe('decimal metric', function () {
|
||||||
|
|
||||||
_.each([
|
_.each([
|
||||||
[0, '0 B'],
|
[0, '0 B'],
|
||||||
[10, '10 B'],
|
[10, '10 B'],
|
||||||
@@ -108,12 +88,10 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
[1000000000000, '1.0 TB'],
|
[1000000000000, '1.0 TB'],
|
||||||
[1250000000000, '1.3 TB']
|
[1250000000000, '1.3 TB']
|
||||||
], function (data) {
|
], function (data) {
|
||||||
|
|
||||||
var arg = data[0];
|
var arg = data[0];
|
||||||
var exp = data[1];
|
var exp = data[1];
|
||||||
|
|
||||||
it(arg + ' => ' + exp, function () {
|
it(arg + ' => ' + exp, function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
instance.setDefaultMetric(false);
|
instance.setDefaultMetric(false);
|
||||||
assert.strictEqual(instance.formatSize(arg), exp);
|
assert.strictEqual(instance.formatSize(arg), exp);
|
||||||
@@ -122,7 +100,6 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('binary metric', function () {
|
describe('binary metric', function () {
|
||||||
|
|
||||||
_.each([
|
_.each([
|
||||||
[0, '0 B'],
|
[0, '0 B'],
|
||||||
[10, '10 B'],
|
[10, '10 B'],
|
||||||
@@ -144,12 +121,10 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
[1000000000000, '931.3 GiB'],
|
[1000000000000, '931.3 GiB'],
|
||||||
[1250000000000, '1.1 TiB']
|
[1250000000000, '1.1 TiB']
|
||||||
], function (data) {
|
], function (data) {
|
||||||
|
|
||||||
var arg = data[0];
|
var arg = data[0];
|
||||||
var exp = data[1];
|
var exp = data[1];
|
||||||
|
|
||||||
it(arg + ' => ' + exp, function () {
|
it(arg + ' => ' + exp, function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
instance.setDefaultMetric(true);
|
instance.setDefaultMetric(true);
|
||||||
assert.strictEqual(instance.formatSize(arg), exp);
|
assert.strictEqual(instance.formatSize(arg), exp);
|
||||||
@@ -159,24 +134,19 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('.setDefaultDateFormat()', function () {
|
describe('.setDefaultDateFormat()', function () {
|
||||||
|
|
||||||
it('is function', function () {
|
it('is function', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isFunction(instance.setDefaultDateFormat);
|
assert.isFunction(instance.setDefaultDateFormat);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('.formatDate()', function () {
|
describe('.formatDate()', function () {
|
||||||
|
|
||||||
it('is function', function () {
|
it('is function', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isFunction(instance.formatDate);
|
assert.isFunction(instance.formatDate);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('default format', function () {
|
it('default format', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.strictEqual(instance.formatDate(0), '');
|
assert.strictEqual(instance.formatDate(0), '');
|
||||||
assert.strictEqual(instance.formatDate(1000), '1970-01-01 01:00');
|
assert.strictEqual(instance.formatDate(1000), '1970-01-01 01:00');
|
||||||
@@ -204,18 +174,15 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
[1400000000000, 'XYYYYXMMXDDXHHXmmXssX', 'X2014X05X13X18X53X20X'],
|
[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']
|
[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) {
|
], function (data) {
|
||||||
|
|
||||||
var arg1 = data[0];
|
var arg1 = data[0];
|
||||||
var arg2 = data[1];
|
var arg2 = data[1];
|
||||||
var exp = data[2];
|
var exp = data[2];
|
||||||
|
|
||||||
it(arg1 + ', ' + arg2 + ' => ' + exp, function () {
|
it(arg1 + ', ' + arg2 + ' => ' + exp, function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.strictEqual(instance.formatDate(arg1, arg2), exp);
|
assert.strictEqual(instance.formatDate(arg1, arg2), exp);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
@@ -1,64 +1,49 @@
|
|||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
var ID = 'core/langs';
|
||||||
|
var DEPS = ['_', 'config'];
|
||||||
var ID = 'core/langs';
|
|
||||||
var DEPS = ['_', 'config'];
|
|
||||||
|
|
||||||
describe('module \'' + ID + '\'', function () {
|
|
||||||
|
|
||||||
|
describe('module \'' + ID + '\'', function () {
|
||||||
before(function () {
|
before(function () {
|
||||||
|
|
||||||
this.definition = modulejs._private.definitions[ID];
|
this.definition = modulejs._private.definitions[ID];
|
||||||
|
|
||||||
this.xConfig = {langs: uniq.obj()};
|
this.xConfig = {langs: uniq.obj()};
|
||||||
this.applyFn = function () {
|
this.applyFn = function () {
|
||||||
|
|
||||||
return this.definition.fn(_, this.xConfig);
|
return this.definition.fn(_, this.xConfig);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('definition', function () {
|
describe('definition', function () {
|
||||||
|
|
||||||
it('is defined', function () {
|
it('is defined', function () {
|
||||||
|
|
||||||
assert.isPlainObject(this.definition);
|
assert.isPlainObject(this.definition);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has correct id', function () {
|
it('has correct id', function () {
|
||||||
|
|
||||||
assert.strictEqual(this.definition.id, ID);
|
assert.strictEqual(this.definition.id, ID);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('requires correct', function () {
|
it('requires correct', function () {
|
||||||
|
|
||||||
assert.deepEqual(this.definition.deps, DEPS);
|
assert.deepEqual(this.definition.deps, DEPS);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('args for each request', function () {
|
it('args for each request', function () {
|
||||||
|
|
||||||
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has no instance', function () {
|
it('has no instance', function () {
|
||||||
|
|
||||||
assert.notProperty(modulejs._private.instances, ID);
|
assert.notProperty(modulejs._private.instances, ID);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('inits without errors', function () {
|
it('inits without errors', function () {
|
||||||
|
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('application', function () {
|
describe('application', function () {
|
||||||
|
|
||||||
it('returns plain object with right content', function () {
|
it('returns plain object with right content', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isPlainObject(instance);
|
assert.isPlainObject(instance);
|
||||||
assert.deepEqual(instance, this.xConfig.langs);
|
assert.deepEqual(instance, this.xConfig.langs);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
@@ -1,13 +1,9 @@
|
|||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
var ID = 'core/location';
|
||||||
|
var DEPS = ['_', 'core/event', 'core/modernizr', 'core/settings', 'view/notification'];
|
||||||
var ID = 'core/location';
|
|
||||||
var DEPS = ['_', 'core/event', 'core/modernizr', 'core/settings', 'view/notification'];
|
|
||||||
|
|
||||||
describe('module \'' + ID + '\'', function () {
|
|
||||||
|
|
||||||
|
describe('module \'' + ID + '\'', function () {
|
||||||
before(function () {
|
before(function () {
|
||||||
|
|
||||||
this.definition = modulejs._private.definitions[ID];
|
this.definition = modulejs._private.definitions[ID];
|
||||||
|
|
||||||
this.xModernizr = {
|
this.xModernizr = {
|
||||||
@@ -25,7 +21,6 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
set: sinon.stub()
|
set: sinon.stub()
|
||||||
};
|
};
|
||||||
this.applyFn = function () {
|
this.applyFn = function () {
|
||||||
|
|
||||||
this.xEvent.pub.reset();
|
this.xEvent.pub.reset();
|
||||||
this.xEvent.sub.reset();
|
this.xEvent.sub.reset();
|
||||||
this.xNotification.set.reset();
|
this.xNotification.set.reset();
|
||||||
@@ -35,59 +30,47 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
after(function () {
|
after(function () {
|
||||||
|
|
||||||
window.onpopstate = null;
|
window.onpopstate = null;
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
|
|
||||||
window.onpopstate = null;
|
window.onpopstate = null;
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('definition', function () {
|
describe('definition', function () {
|
||||||
|
|
||||||
it('is defined', function () {
|
it('is defined', function () {
|
||||||
|
|
||||||
assert.isPlainObject(this.definition);
|
assert.isPlainObject(this.definition);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has correct id', function () {
|
it('has correct id', function () {
|
||||||
|
|
||||||
assert.strictEqual(this.definition.id, ID);
|
assert.strictEqual(this.definition.id, ID);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('requires correct', function () {
|
it('requires correct', function () {
|
||||||
|
|
||||||
assert.deepEqual(this.definition.deps, DEPS);
|
assert.deepEqual(this.definition.deps, DEPS);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('args for each request', function () {
|
it('args for each request', function () {
|
||||||
|
|
||||||
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has no instance', function () {
|
it('has no instance', function () {
|
||||||
|
|
||||||
assert.notProperty(modulejs._private.instances, ID);
|
assert.notProperty(modulejs._private.instances, ID);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('inits without errors', function () {
|
it('inits without errors', function () {
|
||||||
|
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('application', function () {
|
describe('application', function () {
|
||||||
|
|
||||||
it('returns plain object with 7 properties', function () {
|
it('returns plain object with 7 properties', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isPlainObject(instance);
|
assert.isPlainObject(instance);
|
||||||
assert.lengthOfKeys(instance, 7);
|
assert.lengthOfKeys(instance, 7);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('sets window.onpopstate function when history and fastBrowsing', function () {
|
it('sets window.onpopstate function when history and fastBrowsing', function () {
|
||||||
|
|
||||||
this.xModernizr.history = true;
|
this.xModernizr.history = true;
|
||||||
this.xSettings.view.fastBrowsing = 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 () {
|
it('sets window.onpopstate to null when not history and fastBrowsing', function () {
|
||||||
|
|
||||||
this.xModernizr.history = false;
|
this.xModernizr.history = false;
|
||||||
this.xSettings.view.fastBrowsing = true;
|
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 () {
|
it('sets window.onpopstate to null when history and not fastBrowsing', function () {
|
||||||
|
|
||||||
this.xModernizr.history = true;
|
this.xModernizr.history = true;
|
||||||
this.xSettings.view.fastBrowsing = false;
|
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 () {
|
it('sets window.onpopstate to null when not history and not fastBrowsing', function () {
|
||||||
|
|
||||||
this.xModernizr.history = false;
|
this.xModernizr.history = false;
|
||||||
this.xSettings.view.fastBrowsing = false;
|
this.xSettings.view.fastBrowsing = false;
|
||||||
|
|
||||||
@@ -128,9 +108,7 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('.forceEncoding()', function () {
|
describe('.forceEncoding()', function () {
|
||||||
|
|
||||||
it('is function', function () {
|
it('is function', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isFunction(instance.forceEncoding);
|
assert.isFunction(instance.forceEncoding);
|
||||||
});
|
});
|
||||||
@@ -161,12 +139,10 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
['a[b', 'a%5Bb'],
|
['a[b', 'a%5Bb'],
|
||||||
['a]b', 'a%5Db']
|
['a]b', 'a%5Db']
|
||||||
], function (data) {
|
], function (data) {
|
||||||
|
|
||||||
var arg = data[0];
|
var arg = data[0];
|
||||||
var exp = data[1];
|
var exp = data[1];
|
||||||
|
|
||||||
it(arg + ' => ' + exp, function () {
|
it(arg + ' => ' + exp, function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.strictEqual(instance.forceEncoding(arg), exp);
|
assert.strictEqual(instance.forceEncoding(arg), exp);
|
||||||
});
|
});
|
||||||
@@ -174,72 +150,57 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('.getDomain()', function () {
|
describe('.getDomain()', function () {
|
||||||
|
|
||||||
it('is function', function () {
|
it('is function', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isFunction(instance.getDomain);
|
assert.isFunction(instance.getDomain);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns document.domain', function () {
|
it('returns document.domain', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.strictEqual(instance.getDomain(), window.document.domain);
|
assert.strictEqual(instance.getDomain(), window.document.domain);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('.getAbsHref()', function () {
|
describe('.getAbsHref()', function () {
|
||||||
|
|
||||||
it('is function', function () {
|
it('is function', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isFunction(instance.getAbsHref);
|
assert.isFunction(instance.getAbsHref);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns null before .setLocation()', function () {
|
it('returns null before .setLocation()', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isNull(instance.getAbsHref());
|
assert.isNull(instance.getAbsHref());
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('.getItem()', function () {
|
describe('.getItem()', function () {
|
||||||
|
|
||||||
it('is function', function () {
|
it('is function', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isFunction(instance.getItem);
|
assert.isFunction(instance.getItem);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('.setLocation()', function () {
|
describe('.setLocation()', function () {
|
||||||
|
|
||||||
it('is function', function () {
|
it('is function', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isFunction(instance.setLocation);
|
assert.isFunction(instance.setLocation);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('.refresh()', function () {
|
describe('.refresh()', function () {
|
||||||
|
|
||||||
it('is function', function () {
|
it('is function', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isFunction(instance.refresh);
|
assert.isFunction(instance.refresh);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('.setLink()', function () {
|
describe('.setLink()', function () {
|
||||||
|
|
||||||
it('is function', function () {
|
it('is function', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isFunction(instance.setLink);
|
assert.isFunction(instance.setLink);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('sets href correct', function () {
|
it('sets href correct', function () {
|
||||||
|
|
||||||
var $el = $('<a/>');
|
var $el = $('<a/>');
|
||||||
var item = {
|
var item = {
|
||||||
absHref: uniq.id(),
|
absHref: uniq.id(),
|
||||||
@@ -254,7 +215,6 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('sets target=\'_blank\' for unmanaged folders', function () {
|
it('sets target=\'_blank\' for unmanaged folders', function () {
|
||||||
|
|
||||||
this.xSettings.view.unmanagedInNewWindow = true;
|
this.xSettings.view.unmanagedInNewWindow = true;
|
||||||
|
|
||||||
var $el = $('<a/>');
|
var $el = $('<a/>');
|
||||||
@@ -271,7 +231,6 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('does not set target=\'_blank\' for managed folders', function () {
|
it('does not set target=\'_blank\' for managed folders', function () {
|
||||||
|
|
||||||
this.xSettings.view.unmanagedInNewWindow = true;
|
this.xSettings.view.unmanagedInNewWindow = true;
|
||||||
|
|
||||||
var $el = $('<a/>');
|
var $el = $('<a/>');
|
||||||
@@ -288,7 +247,6 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('does not set target=\'_blank\' for unmanaged folders if disabled', function () {
|
it('does not set target=\'_blank\' for unmanaged folders if disabled', function () {
|
||||||
|
|
||||||
this.xSettings.view.unmanagedInNewWindow = false;
|
this.xSettings.view.unmanagedInNewWindow = false;
|
||||||
|
|
||||||
var $el = $('<a/>');
|
var $el = $('<a/>');
|
||||||
@@ -304,6 +262,5 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
assert.isUndefined($el.attr('target'));
|
assert.isUndefined($el.attr('target'));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
@@ -1,58 +1,44 @@
|
|||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
var ID = 'core/modernizr';
|
||||||
|
var DEPS = [];
|
||||||
var ID = 'core/modernizr';
|
|
||||||
var DEPS = [];
|
|
||||||
|
|
||||||
describe('module \'' + ID + '\'', function () {
|
|
||||||
|
|
||||||
|
describe('module \'' + ID + '\'', function () {
|
||||||
before(function () {
|
before(function () {
|
||||||
|
|
||||||
this.definition = modulejs._private.definitions[ID];
|
this.definition = modulejs._private.definitions[ID];
|
||||||
|
|
||||||
this.applyFn = function () {
|
this.applyFn = function () {
|
||||||
|
|
||||||
return this.definition.fn();
|
return this.definition.fn();
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('definition', function () {
|
describe('definition', function () {
|
||||||
|
|
||||||
it('is defined', function () {
|
it('is defined', function () {
|
||||||
|
|
||||||
assert.isPlainObject(this.definition);
|
assert.isPlainObject(this.definition);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has correct id', function () {
|
it('has correct id', function () {
|
||||||
|
|
||||||
assert.strictEqual(this.definition.id, ID);
|
assert.strictEqual(this.definition.id, ID);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('requires correct', function () {
|
it('requires correct', function () {
|
||||||
|
|
||||||
assert.deepEqual(this.definition.deps, DEPS);
|
assert.deepEqual(this.definition.deps, DEPS);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('args for each request', function () {
|
it('args for each request', function () {
|
||||||
|
|
||||||
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has no instance', function () {
|
it('has no instance', function () {
|
||||||
|
|
||||||
assert.notProperty(modulejs._private.instances, ID);
|
assert.notProperty(modulejs._private.instances, ID);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('inits without errors', function () {
|
it('inits without errors', function () {
|
||||||
|
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('application', function () {
|
describe('application', function () {
|
||||||
|
|
||||||
it('returns plain object with 3 properties', function () {
|
it('returns plain object with 3 properties', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isPlainObject(instance);
|
assert.isPlainObject(instance);
|
||||||
assert.lengthOf(_.keys(instance), 3);
|
assert.lengthOf(_.keys(instance), 3);
|
||||||
@@ -60,31 +46,24 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('.canvas', function () {
|
describe('.canvas', function () {
|
||||||
|
|
||||||
it('is boolean', function () {
|
it('is boolean', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isBoolean(instance.canvas);
|
assert.isBoolean(instance.canvas);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('.history', function () {
|
describe('.history', function () {
|
||||||
|
|
||||||
it('is boolean', function () {
|
it('is boolean', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isBoolean(instance.history);
|
assert.isBoolean(instance.history);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('.localstorage', function () {
|
describe('.localstorage', function () {
|
||||||
|
|
||||||
it('is boolean', function () {
|
it('is boolean', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isBoolean(instance.localstorage);
|
assert.isBoolean(instance.localstorage);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
@@ -1,13 +1,9 @@
|
|||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
var ID = 'core/resource';
|
||||||
|
var DEPS = ['_', 'config', 'core/settings'];
|
||||||
var ID = 'core/resource';
|
|
||||||
var DEPS = ['_', 'config', 'core/settings'];
|
|
||||||
|
|
||||||
describe('module \'' + ID + '\'', function () {
|
|
||||||
|
|
||||||
|
describe('module \'' + ID + '\'', function () {
|
||||||
before(function () {
|
before(function () {
|
||||||
|
|
||||||
this.definition = modulejs._private.definitions[ID];
|
this.definition = modulejs._private.definitions[ID];
|
||||||
|
|
||||||
this.xConfig = {
|
this.xConfig = {
|
||||||
@@ -18,48 +14,38 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
};
|
};
|
||||||
this.xSettings = {publicHref: uniq.path('/publicHref/')};
|
this.xSettings = {publicHref: uniq.path('/publicHref/')};
|
||||||
this.applyFn = function () {
|
this.applyFn = function () {
|
||||||
|
|
||||||
return this.definition.fn(_, this.xConfig, this.xSettings);
|
return this.definition.fn(_, this.xConfig, this.xSettings);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('definition', function () {
|
describe('definition', function () {
|
||||||
|
|
||||||
it('is defined', function () {
|
it('is defined', function () {
|
||||||
|
|
||||||
assert.isPlainObject(this.definition);
|
assert.isPlainObject(this.definition);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has correct id', function () {
|
it('has correct id', function () {
|
||||||
|
|
||||||
assert.strictEqual(this.definition.id, ID);
|
assert.strictEqual(this.definition.id, ID);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('requires correct', function () {
|
it('requires correct', function () {
|
||||||
|
|
||||||
assert.deepEqual(this.definition.deps, DEPS);
|
assert.deepEqual(this.definition.deps, DEPS);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('args for each request', function () {
|
it('args for each request', function () {
|
||||||
|
|
||||||
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has no instance', function () {
|
it('has no instance', function () {
|
||||||
|
|
||||||
assert.notProperty(modulejs._private.instances, ID);
|
assert.notProperty(modulejs._private.instances, ID);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('inits without errors', function () {
|
it('inits without errors', function () {
|
||||||
|
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('application', function () {
|
describe('application', function () {
|
||||||
|
|
||||||
it('returns plain object with 2 properties', function () {
|
it('returns plain object with 2 properties', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isPlainObject(instance);
|
assert.isPlainObject(instance);
|
||||||
assert.lengthOfKeys(instance, 2);
|
assert.lengthOfKeys(instance, 2);
|
||||||
@@ -67,15 +53,12 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('.image()', function () {
|
describe('.image()', function () {
|
||||||
|
|
||||||
it('is function', function () {
|
it('is function', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isFunction(instance.image);
|
assert.isFunction(instance.image);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works', function () {
|
it('works', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
var ui = this.xSettings.publicHref + 'images/ui/';
|
var ui = this.xSettings.publicHref + 'images/ui/';
|
||||||
|
|
||||||
@@ -87,15 +70,12 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('.icon()', function () {
|
describe('.icon()', function () {
|
||||||
|
|
||||||
it('is function', function () {
|
it('is function', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isFunction(instance.icon);
|
assert.isFunction(instance.icon);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works', function () {
|
it('works', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
var themes = this.xSettings.publicHref + 'images/themes/';
|
var themes = this.xSettings.publicHref + 'images/themes/';
|
||||||
|
|
||||||
@@ -108,6 +88,5 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
assert.strictEqual(instance.icon('y-sub'), themes + 'default/file.svg');
|
assert.strictEqual(instance.icon('y-sub'), themes + 'default/file.svg');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
@@ -1,14 +1,10 @@
|
|||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
var ID = 'core/server';
|
||||||
|
var DEPS = ['_', '$'];
|
||||||
var ID = 'core/server';
|
var $submitEl;
|
||||||
var DEPS = ['_', '$'];
|
|
||||||
var $submitEl;
|
|
||||||
|
|
||||||
describe('module \'' + ID + '\'', function () {
|
|
||||||
|
|
||||||
|
describe('module \'' + ID + '\'', function () {
|
||||||
before(function () {
|
before(function () {
|
||||||
|
|
||||||
this.definition = modulejs._private.definitions[ID];
|
this.definition = modulejs._private.definitions[ID];
|
||||||
|
|
||||||
this.xAjaxResult = {
|
this.xAjaxResult = {
|
||||||
@@ -18,13 +14,11 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
};
|
};
|
||||||
this.xAjax = sinon.stub($, 'ajax').returns(this.xAjaxResult);
|
this.xAjax = sinon.stub($, 'ajax').returns(this.xAjaxResult);
|
||||||
this.xSubmit = sinon.stub($.fn, 'submit', function () {
|
this.xSubmit = sinon.stub($.fn, 'submit', function () {
|
||||||
|
|
||||||
$submitEl = this;
|
$submitEl = this;
|
||||||
return this;
|
return this;
|
||||||
});
|
});
|
||||||
|
|
||||||
this.applyFn = function () {
|
this.applyFn = function () {
|
||||||
|
|
||||||
this.xAjaxResult.done.reset();
|
this.xAjaxResult.done.reset();
|
||||||
this.xAjaxResult.fail.reset();
|
this.xAjaxResult.fail.reset();
|
||||||
this.xAjaxResult.always.reset();
|
this.xAjaxResult.always.reset();
|
||||||
@@ -37,48 +31,38 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
after(function () {
|
after(function () {
|
||||||
|
|
||||||
this.xAjax.restore();
|
this.xAjax.restore();
|
||||||
this.xSubmit.restore();
|
this.xSubmit.restore();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('definition', function () {
|
describe('definition', function () {
|
||||||
|
|
||||||
it('is defined', function () {
|
it('is defined', function () {
|
||||||
|
|
||||||
assert.isPlainObject(this.definition);
|
assert.isPlainObject(this.definition);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has correct id', function () {
|
it('has correct id', function () {
|
||||||
|
|
||||||
assert.strictEqual(this.definition.id, ID);
|
assert.strictEqual(this.definition.id, ID);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('requires correct', function () {
|
it('requires correct', function () {
|
||||||
|
|
||||||
assert.deepEqual(this.definition.deps, DEPS);
|
assert.deepEqual(this.definition.deps, DEPS);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('args for each request', function () {
|
it('args for each request', function () {
|
||||||
|
|
||||||
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has no instance', function () {
|
it('has no instance', function () {
|
||||||
|
|
||||||
assert.notProperty(modulejs._private.instances, ID);
|
assert.notProperty(modulejs._private.instances, ID);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('inits without errors', function () {
|
it('inits without errors', function () {
|
||||||
|
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('application', function () {
|
describe('application', function () {
|
||||||
|
|
||||||
it('returns plain object with 2 properties', function () {
|
it('returns plain object with 2 properties', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isPlainObject(instance);
|
assert.isPlainObject(instance);
|
||||||
assert.lengthOfKeys(instance, 2);
|
assert.lengthOfKeys(instance, 2);
|
||||||
@@ -86,15 +70,12 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('.request()', function () {
|
describe('.request()', function () {
|
||||||
|
|
||||||
it('is function', function () {
|
it('is function', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isFunction(instance.request);
|
assert.isFunction(instance.request);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('done() works', function () {
|
it('done() works', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
|
|
||||||
var xData = uniq.obj();
|
var xData = uniq.obj();
|
||||||
@@ -121,7 +102,6 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('fail() works', function () {
|
it('fail() works', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
|
|
||||||
var xData = uniq.obj();
|
var xData = uniq.obj();
|
||||||
@@ -148,15 +128,12 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('.formRequest()', function () {
|
describe('.formRequest()', function () {
|
||||||
|
|
||||||
it('is function', function () {
|
it('is function', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isFunction(instance.formRequest);
|
assert.isFunction(instance.formRequest);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works', function () {
|
it('works', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
|
|
||||||
var xData = {
|
var xData = {
|
||||||
@@ -188,6 +165,5 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
assert.strictEqual($children.eq(1).attr('value'), xData.b);
|
assert.strictEqual($children.eq(1).attr('value'), xData.b);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
@@ -1,13 +1,9 @@
|
|||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
var ID = 'core/settings';
|
||||||
|
var DEPS = ['_', 'config'];
|
||||||
var ID = 'core/settings';
|
|
||||||
var DEPS = ['_', 'config'];
|
|
||||||
|
|
||||||
describe('module \'' + ID + '\'', function () {
|
|
||||||
|
|
||||||
|
describe('module \'' + ID + '\'', function () {
|
||||||
before(function () {
|
before(function () {
|
||||||
|
|
||||||
this.definition = modulejs._private.definitions[ID];
|
this.definition = modulejs._private.definitions[ID];
|
||||||
|
|
||||||
this.xConfig = {
|
this.xConfig = {
|
||||||
@@ -22,48 +18,38 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
this.applyFn = function () {
|
this.applyFn = function () {
|
||||||
|
|
||||||
return this.definition.fn(_, this.xConfig);
|
return this.definition.fn(_, this.xConfig);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('definition', function () {
|
describe('definition', function () {
|
||||||
|
|
||||||
it('is defined', function () {
|
it('is defined', function () {
|
||||||
|
|
||||||
assert.isPlainObject(this.definition);
|
assert.isPlainObject(this.definition);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has correct id', function () {
|
it('has correct id', function () {
|
||||||
|
|
||||||
assert.strictEqual(this.definition.id, ID);
|
assert.strictEqual(this.definition.id, ID);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('requires correct', function () {
|
it('requires correct', function () {
|
||||||
|
|
||||||
assert.deepEqual(this.definition.deps, DEPS);
|
assert.deepEqual(this.definition.deps, DEPS);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('args for each request', function () {
|
it('args for each request', function () {
|
||||||
|
|
||||||
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has no instance', function () {
|
it('has no instance', function () {
|
||||||
|
|
||||||
assert.notProperty(modulejs._private.instances, ID);
|
assert.notProperty(modulejs._private.instances, ID);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('inits without errors', function () {
|
it('inits without errors', function () {
|
||||||
|
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('application', function () {
|
describe('application', function () {
|
||||||
|
|
||||||
it('returns plain object with properties', function () {
|
it('returns plain object with properties', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isPlainObject(instance);
|
assert.isPlainObject(instance);
|
||||||
assert.isAbove(_.keys(instance).length, 0);
|
assert.isAbove(_.keys(instance).length, 0);
|
||||||
@@ -71,9 +57,7 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('publics', function () {
|
describe('publics', function () {
|
||||||
|
|
||||||
it('extended from options', function () {
|
it('extended from options', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.strictEqual(instance.someOptions, this.xConfig.options.someOptions);
|
assert.strictEqual(instance.someOptions, this.xConfig.options.someOptions);
|
||||||
assert.strictEqual(instance.otherOptions, this.xConfig.options.otherOptions);
|
assert.strictEqual(instance.otherOptions, this.xConfig.options.otherOptions);
|
||||||
@@ -83,22 +67,17 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('.publicHref', function () {
|
describe('.publicHref', function () {
|
||||||
|
|
||||||
it('set correct', function () {
|
it('set correct', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.strictEqual(instance.publicHref, this.xConfig.setup.PUBLIC_HREF);
|
assert.strictEqual(instance.publicHref, this.xConfig.setup.PUBLIC_HREF);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('.rootHref', function () {
|
describe('.rootHref', function () {
|
||||||
|
|
||||||
it('set correct', function () {
|
it('set correct', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.strictEqual(instance.rootHref, this.xConfig.setup.ROOT_HREF);
|
assert.strictEqual(instance.rootHref, this.xConfig.setup.ROOT_HREF);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
@@ -1,70 +1,54 @@
|
|||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
var ID = 'core/store';
|
||||||
|
var DEPS = ['core/modernizr'];
|
||||||
var ID = 'core/store';
|
|
||||||
var DEPS = ['core/modernizr'];
|
|
||||||
|
|
||||||
describe('module \'' + ID + '\'', function () {
|
|
||||||
|
|
||||||
|
describe('module \'' + ID + '\'', function () {
|
||||||
before(function () {
|
before(function () {
|
||||||
|
|
||||||
this.definition = modulejs._private.definitions[ID];
|
this.definition = modulejs._private.definitions[ID];
|
||||||
|
|
||||||
this.storeKey = '_h5ai';
|
this.storeKey = '_h5ai';
|
||||||
this.xModernizr = {localstorage: true};
|
this.xModernizr = {localstorage: true};
|
||||||
this.applyFn = function () {
|
this.applyFn = function () {
|
||||||
|
|
||||||
return this.definition.fn(this.xModernizr);
|
return this.definition.fn(this.xModernizr);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
after(function () {
|
after(function () {
|
||||||
|
|
||||||
util.restoreHtml();
|
util.restoreHtml();
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
|
|
||||||
util.restoreHtml();
|
util.restoreHtml();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('definition', function () {
|
describe('definition', function () {
|
||||||
|
|
||||||
it('is defined', function () {
|
it('is defined', function () {
|
||||||
|
|
||||||
assert.isPlainObject(this.definition);
|
assert.isPlainObject(this.definition);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has correct id', function () {
|
it('has correct id', function () {
|
||||||
|
|
||||||
assert.strictEqual(this.definition.id, ID);
|
assert.strictEqual(this.definition.id, ID);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('requires correct', function () {
|
it('requires correct', function () {
|
||||||
|
|
||||||
assert.deepEqual(this.definition.deps, DEPS);
|
assert.deepEqual(this.definition.deps, DEPS);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('args for each request', function () {
|
it('args for each request', function () {
|
||||||
|
|
||||||
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has no instance', function () {
|
it('has no instance', function () {
|
||||||
|
|
||||||
assert.notProperty(modulejs._private.instances, ID);
|
assert.notProperty(modulejs._private.instances, ID);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('inits without errors', function () {
|
it('inits without errors', function () {
|
||||||
|
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('application', function () {
|
describe('application', function () {
|
||||||
|
|
||||||
it('returns plain object with 2 properties', function () {
|
it('returns plain object with 2 properties', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isPlainObject(instance);
|
assert.isPlainObject(instance);
|
||||||
assert.lengthOfKeys(instance, 2);
|
assert.lengthOfKeys(instance, 2);
|
||||||
@@ -72,27 +56,21 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('.put()', function () {
|
describe('.put()', function () {
|
||||||
|
|
||||||
it('is function', function () {
|
it('is function', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isFunction(instance.put);
|
assert.isFunction(instance.put);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('.get()', function () {
|
describe('.get()', function () {
|
||||||
|
|
||||||
it('is function', function () {
|
it('is function', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isFunction(instance.get);
|
assert.isFunction(instance.get);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('works', function () {
|
describe('works', function () {
|
||||||
|
|
||||||
it('works', function () {
|
it('works', function () {
|
||||||
|
|
||||||
var key1 = 'test1';
|
var key1 = 'test1';
|
||||||
var value1 = '1234';
|
var value1 = '1234';
|
||||||
var key2 = 'test2';
|
var key2 = 'test2';
|
||||||
@@ -126,6 +104,5 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
assert.strictEqual(window.localStorage.getItem(this.storeKey), '{"test2":"5678"}');
|
assert.strictEqual(window.localStorage.getItem(this.storeKey), '{"test2":"5678"}');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
@@ -1,13 +1,9 @@
|
|||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
var ID = 'core/types';
|
||||||
|
var DEPS = ['_', 'config'];
|
||||||
var ID = 'core/types';
|
|
||||||
var DEPS = ['_', 'config'];
|
|
||||||
|
|
||||||
describe('module \'' + ID + '\'', function () {
|
|
||||||
|
|
||||||
|
describe('module \'' + ID + '\'', function () {
|
||||||
before(function () {
|
before(function () {
|
||||||
|
|
||||||
this.definition = modulejs._private.definitions[ID];
|
this.definition = modulejs._private.definitions[ID];
|
||||||
|
|
||||||
this.xConfig = {types: {
|
this.xConfig = {types: {
|
||||||
@@ -16,48 +12,38 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
c: ['*.c']
|
c: ['*.c']
|
||||||
}};
|
}};
|
||||||
this.applyFn = function () {
|
this.applyFn = function () {
|
||||||
|
|
||||||
return this.definition.fn(_, this.xConfig);
|
return this.definition.fn(_, this.xConfig);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('definition', function () {
|
describe('definition', function () {
|
||||||
|
|
||||||
it('is defined', function () {
|
it('is defined', function () {
|
||||||
|
|
||||||
assert.isPlainObject(this.definition);
|
assert.isPlainObject(this.definition);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has correct id', function () {
|
it('has correct id', function () {
|
||||||
|
|
||||||
assert.strictEqual(this.definition.id, ID);
|
assert.strictEqual(this.definition.id, ID);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('requires correct', function () {
|
it('requires correct', function () {
|
||||||
|
|
||||||
assert.deepEqual(this.definition.deps, DEPS);
|
assert.deepEqual(this.definition.deps, DEPS);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('args for each request', function () {
|
it('args for each request', function () {
|
||||||
|
|
||||||
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has no instance', function () {
|
it('has no instance', function () {
|
||||||
|
|
||||||
assert.notProperty(modulejs._private.instances, ID);
|
assert.notProperty(modulejs._private.instances, ID);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('inits without errors', function () {
|
it('inits without errors', function () {
|
||||||
|
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('application', function () {
|
describe('application', function () {
|
||||||
|
|
||||||
it('returns plain object with 1 property', function () {
|
it('returns plain object with 1 property', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isPlainObject(instance);
|
assert.isPlainObject(instance);
|
||||||
assert.lengthOfKeys(instance, 1);
|
assert.lengthOfKeys(instance, 1);
|
||||||
@@ -65,9 +51,7 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('.getType()', function () {
|
describe('.getType()', function () {
|
||||||
|
|
||||||
it('is function', function () {
|
it('is function', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isFunction(instance.getType);
|
assert.isFunction(instance.getType);
|
||||||
});
|
});
|
||||||
@@ -87,17 +71,14 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
['some/path/foo/', 'folder'],
|
['some/path/foo/', 'folder'],
|
||||||
['/some/path/foo/', 'folder']
|
['/some/path/foo/', 'folder']
|
||||||
], function (data) {
|
], function (data) {
|
||||||
|
|
||||||
var arg = data[0];
|
var arg = data[0];
|
||||||
var exp = data[1];
|
var exp = data[1];
|
||||||
|
|
||||||
it(arg + ' => ' + exp, function () {
|
it(arg + ' => ' + exp, function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.strictEqual(instance.getType(arg), exp);
|
assert.strictEqual(instance.getType(arg), exp);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
@@ -1,58 +1,44 @@
|
|||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
var ID = 'core/util';
|
||||||
|
var DEPS = ['_'];
|
||||||
var ID = 'core/util';
|
|
||||||
var DEPS = ['_'];
|
|
||||||
|
|
||||||
describe('module \'' + ID + '\'', function () {
|
|
||||||
|
|
||||||
|
describe('module \'' + ID + '\'', function () {
|
||||||
before(function () {
|
before(function () {
|
||||||
|
|
||||||
this.definition = modulejs._private.definitions[ID];
|
this.definition = modulejs._private.definitions[ID];
|
||||||
|
|
||||||
this.applyFn = function () {
|
this.applyFn = function () {
|
||||||
|
|
||||||
return this.definition.fn(_);
|
return this.definition.fn(_);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('definition', function () {
|
describe('definition', function () {
|
||||||
|
|
||||||
it('is defined', function () {
|
it('is defined', function () {
|
||||||
|
|
||||||
assert.isPlainObject(this.definition);
|
assert.isPlainObject(this.definition);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has correct id', function () {
|
it('has correct id', function () {
|
||||||
|
|
||||||
assert.strictEqual(this.definition.id, ID);
|
assert.strictEqual(this.definition.id, ID);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('requires correct', function () {
|
it('requires correct', function () {
|
||||||
|
|
||||||
assert.deepEqual(this.definition.deps, DEPS);
|
assert.deepEqual(this.definition.deps, DEPS);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('args for each request', function () {
|
it('args for each request', function () {
|
||||||
|
|
||||||
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has no instance', function () {
|
it('has no instance', function () {
|
||||||
|
|
||||||
assert.notProperty(modulejs._private.instances, ID);
|
assert.notProperty(modulejs._private.instances, ID);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('inits without errors', function () {
|
it('inits without errors', function () {
|
||||||
|
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('application', function () {
|
describe('application', function () {
|
||||||
|
|
||||||
it('returns plain object with 4 properties', function () {
|
it('returns plain object with 4 properties', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isPlainObject(instance);
|
assert.isPlainObject(instance);
|
||||||
assert.lengthOfKeys(instance, 4);
|
assert.lengthOfKeys(instance, 4);
|
||||||
@@ -60,9 +46,7 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('.regularCmpFn()', function () {
|
describe('.regularCmpFn()', function () {
|
||||||
|
|
||||||
it('is function', function () {
|
it('is function', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isFunction(instance.regularCmpFn);
|
assert.isFunction(instance.regularCmpFn);
|
||||||
});
|
});
|
||||||
@@ -76,13 +60,11 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
['a', 'b', -1],
|
['a', 'b', -1],
|
||||||
['a 2', 'a 10', 1]
|
['a 2', 'a 10', 1]
|
||||||
], function (data) {
|
], function (data) {
|
||||||
|
|
||||||
var arg1 = data[0];
|
var arg1 = data[0];
|
||||||
var arg2 = data[1];
|
var arg2 = data[1];
|
||||||
var exp = data[2];
|
var exp = data[2];
|
||||||
|
|
||||||
it(arg1 + ', ' + arg2 + ' => ' + exp, function () {
|
it(arg1 + ', ' + arg2 + ' => ' + exp, function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.strictEqual(instance.regularCmpFn(arg1, arg2), exp);
|
assert.strictEqual(instance.regularCmpFn(arg1, arg2), exp);
|
||||||
});
|
});
|
||||||
@@ -90,9 +72,7 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('.naturalCmpFn()', function () {
|
describe('.naturalCmpFn()', function () {
|
||||||
|
|
||||||
it('is function', function () {
|
it('is function', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isFunction(instance.naturalCmpFn);
|
assert.isFunction(instance.naturalCmpFn);
|
||||||
});
|
});
|
||||||
@@ -106,13 +86,11 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
['a', 'b', -1],
|
['a', 'b', -1],
|
||||||
['a 2', 'a 10', -1]
|
['a 2', 'a 10', -1]
|
||||||
], function (data) {
|
], function (data) {
|
||||||
|
|
||||||
var arg1 = data[0];
|
var arg1 = data[0];
|
||||||
var arg2 = data[1];
|
var arg2 = data[1];
|
||||||
var exp = data[2];
|
var exp = data[2];
|
||||||
|
|
||||||
it(arg1 + ', ' + arg2 + ' => ' + exp, function () {
|
it(arg1 + ', ' + arg2 + ' => ' + exp, function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.strictEqual(instance.naturalCmpFn(arg1, arg2), exp);
|
assert.strictEqual(instance.naturalCmpFn(arg1, arg2), exp);
|
||||||
});
|
});
|
||||||
@@ -120,9 +98,7 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('.escapePattern()', function () {
|
describe('.escapePattern()', function () {
|
||||||
|
|
||||||
it('is function', function () {
|
it('is function', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isFunction(instance.escapePattern);
|
assert.isFunction(instance.escapePattern);
|
||||||
});
|
});
|
||||||
@@ -157,12 +133,10 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
['abc123', 'abc123'],
|
['abc123', 'abc123'],
|
||||||
['a.b+c*1', 'a\\.b\\+c\\*1']
|
['a.b+c*1', 'a\\.b\\+c\\*1']
|
||||||
], function (data) {
|
], function (data) {
|
||||||
|
|
||||||
var arg = data[0];
|
var arg = data[0];
|
||||||
var exp = data[1];
|
var exp = data[1];
|
||||||
|
|
||||||
it(arg + ' => ' + exp, function () {
|
it(arg + ' => ' + exp, function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.strictEqual(instance.escapePattern(arg), exp);
|
assert.strictEqual(instance.escapePattern(arg), exp);
|
||||||
});
|
});
|
||||||
@@ -170,9 +144,7 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('.parsePattern()', function () {
|
describe('.parsePattern()', function () {
|
||||||
|
|
||||||
it('is function', function () {
|
it('is function', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isFunction(instance.parsePattern);
|
assert.isFunction(instance.parsePattern);
|
||||||
});
|
});
|
||||||
@@ -215,18 +187,15 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
['re: .', true, ' .']
|
['re: .', true, ' .']
|
||||||
|
|
||||||
], function (data) {
|
], function (data) {
|
||||||
|
|
||||||
var arg1 = data[0];
|
var arg1 = data[0];
|
||||||
var arg2 = data[1];
|
var arg2 = data[1];
|
||||||
var exp = data[2];
|
var exp = data[2];
|
||||||
|
|
||||||
it(arg1 + ', ' + arg2 + ' => ' + exp, function () {
|
it(arg1 + ', ' + arg2 + ' => ' + exp, function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.strictEqual(instance.parsePattern(arg1, arg2), exp);
|
assert.strictEqual(instance.parsePattern(arg1, arg2), exp);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
@@ -1,13 +1,9 @@
|
|||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
var ID = 'ext/title';
|
||||||
|
var DEPS = ['_', 'core/event', 'core/settings'];
|
||||||
var ID = 'ext/title';
|
|
||||||
var DEPS = ['_', 'core/event', 'core/settings'];
|
|
||||||
|
|
||||||
describe('module \'' + ID + '\'', function () {
|
|
||||||
|
|
||||||
|
describe('module \'' + ID + '\'', function () {
|
||||||
before(function () {
|
before(function () {
|
||||||
|
|
||||||
this.definition = modulejs._private.definitions[ID];
|
this.definition = modulejs._private.definitions[ID];
|
||||||
|
|
||||||
this.xEvent = {
|
this.xEvent = {
|
||||||
@@ -18,7 +14,6 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
}};
|
}};
|
||||||
|
|
||||||
this.applyFn = function () {
|
this.applyFn = function () {
|
||||||
|
|
||||||
this.xEvent.sub.reset();
|
this.xEvent.sub.reset();
|
||||||
|
|
||||||
return this.definition.fn(_, this.xEvent, this.xSettings);
|
return this.definition.fn(_, this.xEvent, this.xSettings);
|
||||||
@@ -26,53 +21,42 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
after(function () {
|
after(function () {
|
||||||
|
|
||||||
util.restoreHtml();
|
util.restoreHtml();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('definition', function () {
|
describe('definition', function () {
|
||||||
|
|
||||||
it('is defined', function () {
|
it('is defined', function () {
|
||||||
|
|
||||||
assert.isPlainObject(this.definition);
|
assert.isPlainObject(this.definition);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has correct id', function () {
|
it('has correct id', function () {
|
||||||
|
|
||||||
assert.strictEqual(this.definition.id, ID);
|
assert.strictEqual(this.definition.id, ID);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('requires correct', function () {
|
it('requires correct', function () {
|
||||||
|
|
||||||
assert.deepEqual(this.definition.deps, DEPS);
|
assert.deepEqual(this.definition.deps, DEPS);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('args for each request', function () {
|
it('args for each request', function () {
|
||||||
|
|
||||||
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has no instance', function () {
|
it('has no instance', function () {
|
||||||
|
|
||||||
assert.notProperty(modulejs._private.instances, ID);
|
assert.notProperty(modulejs._private.instances, ID);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('inits without errors', function () {
|
it('inits without errors', function () {
|
||||||
|
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('application', function () {
|
describe('application', function () {
|
||||||
|
|
||||||
it('returns undefined', function () {
|
it('returns undefined', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isUndefined(instance);
|
assert.isUndefined(instance);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('subscribes to location.changed', function () {
|
it('subscribes to location.changed', function () {
|
||||||
|
|
||||||
this.xSettings.title.enabled = true;
|
this.xSettings.title.enabled = true;
|
||||||
|
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
@@ -81,7 +65,6 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('does not subscribe to events if disabled', function () {
|
it('does not subscribe to events if disabled', function () {
|
||||||
|
|
||||||
this.xSettings.title.enabled = false;
|
this.xSettings.title.enabled = false;
|
||||||
|
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
@@ -90,19 +73,16 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('sets title on location.changed', function () {
|
describe('sets title on location.changed', function () {
|
||||||
|
|
||||||
_.each([
|
_.each([
|
||||||
[''],
|
[''],
|
||||||
['a', 'a'],
|
['a', 'a'],
|
||||||
['a', 'b', 'b - a > b'],
|
['a', 'b', 'b - a > b'],
|
||||||
['a', 'b', 'c', 'c - a > b > c']
|
['a', 'b', 'c', 'c - a > b > c']
|
||||||
], function (data) {
|
], function (data) {
|
||||||
|
|
||||||
var labels = data.slice(0, -1);
|
var labels = data.slice(0, -1);
|
||||||
var exp = data.slice(-1)[0];
|
var exp = data.slice(-1)[0];
|
||||||
|
|
||||||
it(labels + ' => ' + exp, function () {
|
it(labels + ' => ' + exp, function () {
|
||||||
|
|
||||||
this.xSettings.title.enabled = true;
|
this.xSettings.title.enabled = true;
|
||||||
|
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
@@ -120,6 +100,5 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
@@ -1,8 +1,5 @@
|
|||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
describe('libs', function () {
|
||||||
|
|
||||||
describe('libs', function () {
|
|
||||||
|
|
||||||
var libs = {
|
var libs = {
|
||||||
_: window._,
|
_: window._,
|
||||||
$: window.jQuery,
|
$: window.jQuery,
|
||||||
@@ -11,29 +8,22 @@ describe('libs', function () {
|
|||||||
};
|
};
|
||||||
|
|
||||||
_.each(libs, function (lib, id) {
|
_.each(libs, function (lib, id) {
|
||||||
|
|
||||||
describe('module \'' + id + '\'', function () {
|
describe('module \'' + id + '\'', function () {
|
||||||
|
|
||||||
it('is defined', function () {
|
it('is defined', function () {
|
||||||
|
|
||||||
assert.isDefined(modulejs._private.definitions[id]);
|
assert.isDefined(modulejs._private.definitions[id]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has no instance', function () {
|
it('has no instance', function () {
|
||||||
|
|
||||||
assert.notProperty(modulejs._private.instances, id);
|
assert.notProperty(modulejs._private.instances, id);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns global lib', function () {
|
it('returns global lib', function () {
|
||||||
|
|
||||||
var definition = modulejs._private.definitions[id];
|
var definition = modulejs._private.definitions[id];
|
||||||
var instance = definition.fn();
|
var instance = definition.fn();
|
||||||
assert.isDefined(instance);
|
assert.isDefined(instance);
|
||||||
assert.strictEqual(instance, lib);
|
assert.strictEqual(instance, lib);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
@@ -1,20 +1,15 @@
|
|||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
var ID = 'main/index';
|
||||||
|
var DEPS = ['_', 'core/location'];
|
||||||
var ID = 'main/index';
|
|
||||||
var DEPS = ['_', 'core/location'];
|
|
||||||
|
|
||||||
describe('module \'' + ID + '\'', function () {
|
|
||||||
|
|
||||||
|
describe('module \'' + ID + '\'', function () {
|
||||||
before(function () {
|
before(function () {
|
||||||
|
|
||||||
this.definition = modulejs._private.definitions[ID];
|
this.definition = modulejs._private.definitions[ID];
|
||||||
|
|
||||||
this.xLocation = {setLocation: sinon.stub()};
|
this.xLocation = {setLocation: sinon.stub()};
|
||||||
this.xRequire = sinon.stub(modulejs, 'require');
|
this.xRequire = sinon.stub(modulejs, 'require');
|
||||||
|
|
||||||
this.applyFn = function () {
|
this.applyFn = function () {
|
||||||
|
|
||||||
this.xLocation.setLocation.reset();
|
this.xLocation.setLocation.reset();
|
||||||
this.xRequire.reset();
|
this.xRequire.reset();
|
||||||
return this.definition.fn(_, this.xLocation);
|
return this.definition.fn(_, this.xLocation);
|
||||||
@@ -22,65 +17,52 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
after(function () {
|
after(function () {
|
||||||
|
|
||||||
this.xRequire.restore();
|
this.xRequire.restore();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('definition', function () {
|
describe('definition', function () {
|
||||||
|
|
||||||
it('is defined', function () {
|
it('is defined', function () {
|
||||||
|
|
||||||
assert.isPlainObject(this.definition);
|
assert.isPlainObject(this.definition);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has correct id', function () {
|
it('has correct id', function () {
|
||||||
|
|
||||||
assert.strictEqual(this.definition.id, ID);
|
assert.strictEqual(this.definition.id, ID);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('requires correct', function () {
|
it('requires correct', function () {
|
||||||
|
|
||||||
assert.deepEqual(this.definition.deps, DEPS);
|
assert.deepEqual(this.definition.deps, DEPS);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('args for each request', function () {
|
it('args for each request', function () {
|
||||||
|
|
||||||
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has no instance', function () {
|
it('has no instance', function () {
|
||||||
|
|
||||||
assert.notProperty(modulejs._private.instances, ID);
|
assert.notProperty(modulejs._private.instances, ID);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('inits without errors', function () {
|
it('inits without errors', function () {
|
||||||
|
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('application', function () {
|
describe('application', function () {
|
||||||
|
|
||||||
it('returns undefined', function () {
|
it('returns undefined', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isUndefined(instance);
|
assert.isUndefined(instance);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('requires view/viewmode', function () {
|
it('requires view/viewmode', function () {
|
||||||
|
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
assert.isTrue(this.xRequire.calledWithExactly('view/viewmode'));
|
assert.isTrue(this.xRequire.calledWithExactly('view/viewmode'));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('requires all extensions', function () {
|
it('requires all extensions', function () {
|
||||||
|
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
var re = /^ext\//;
|
var re = /^ext\//;
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
_.each(modulejs.state(), function (state, id) {
|
_.each(modulejs.state(), function (state, id) {
|
||||||
|
|
||||||
if (re.test(id)) {
|
if (re.test(id)) {
|
||||||
assert.isTrue(self.xRequire.calledWithExactly(id));
|
assert.isTrue(self.xRequire.calledWithExactly(id));
|
||||||
}
|
}
|
||||||
@@ -88,20 +70,17 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('requires only views and extensions', function () {
|
it('requires only views and extensions', function () {
|
||||||
|
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
assert.isTrue(this.xRequire.alwaysCalledWithMatch(/^(view|ext)\//));
|
assert.isTrue(this.xRequire.alwaysCalledWithMatch(/^(view|ext)\//));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('requires views before extensions', function () {
|
it('requires views before extensions', function () {
|
||||||
|
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
var foundExtension = false;
|
var foundExtension = false;
|
||||||
var reView = /^view\//;
|
var reView = /^view\//;
|
||||||
var reExt = /^ext\//;
|
var reExt = /^ext\//;
|
||||||
|
|
||||||
_.each(this.xRequire.args, function (args) {
|
_.each(this.xRequire.args, function (args) {
|
||||||
|
|
||||||
if (foundExtension) {
|
if (foundExtension) {
|
||||||
assert.match(args[0], reExt);
|
assert.match(args[0], reExt);
|
||||||
} else if (reExt.test(args[0])) {
|
} else if (reExt.test(args[0])) {
|
||||||
@@ -113,13 +92,11 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('calls setLocation with current href, keeping browser url', function () {
|
it('calls setLocation with current href, keeping browser url', function () {
|
||||||
|
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
assert.isTrue(this.xLocation.setLocation.calledOnce);
|
assert.isTrue(this.xLocation.setLocation.calledOnce);
|
||||||
assert.deepEqual(this.xLocation.setLocation.firstCall.args, [document.location.href, true]);
|
assert.deepEqual(this.xLocation.setLocation.firstCall.args, [document.location.href, true]);
|
||||||
assert.isTrue(this.xLocation.setLocation.calledAfter(this.xRequire));
|
assert.isTrue(this.xLocation.setLocation.calledAfter(this.xRequire));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
@@ -1,13 +1,9 @@
|
|||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
var ID = 'main/info';
|
||||||
|
var DEPS = ['$', 'config', 'core/resource', 'core/server'];
|
||||||
var ID = 'main/info';
|
|
||||||
var DEPS = ['$', 'config', 'core/resource', 'core/server'];
|
|
||||||
|
|
||||||
describe('module \'' + ID + '\'', function () {
|
|
||||||
|
|
||||||
|
describe('module \'' + ID + '\'', function () {
|
||||||
before(function () {
|
before(function () {
|
||||||
|
|
||||||
this.definition = modulejs._private.definitions[ID];
|
this.definition = modulejs._private.definitions[ID];
|
||||||
|
|
||||||
this.xConfig = {
|
this.xConfig = {
|
||||||
@@ -24,7 +20,6 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
};
|
};
|
||||||
|
|
||||||
this.applyFn = function () {
|
this.applyFn = function () {
|
||||||
|
|
||||||
this.xServer.request.reset();
|
this.xServer.request.reset();
|
||||||
|
|
||||||
return this.definition.fn($, this.xConfig, this.xResource, this.xServer);
|
return this.definition.fn($, this.xConfig, this.xResource, this.xServer);
|
||||||
@@ -32,59 +27,47 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
after(function () {
|
after(function () {
|
||||||
|
|
||||||
util.restoreHtml();
|
util.restoreHtml();
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
|
|
||||||
util.restoreHtml();
|
util.restoreHtml();
|
||||||
$('<div id="content"/>').appendTo('body');
|
$('<div id="content"/>').appendTo('body');
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('definition', function () {
|
describe('definition', function () {
|
||||||
|
|
||||||
it('is defined', function () {
|
it('is defined', function () {
|
||||||
|
|
||||||
assert.isPlainObject(this.definition);
|
assert.isPlainObject(this.definition);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has correct id', function () {
|
it('has correct id', function () {
|
||||||
|
|
||||||
assert.strictEqual(this.definition.id, ID);
|
assert.strictEqual(this.definition.id, ID);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('requires correct', function () {
|
it('requires correct', function () {
|
||||||
|
|
||||||
assert.deepEqual(this.definition.deps, DEPS);
|
assert.deepEqual(this.definition.deps, DEPS);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('args for each request', function () {
|
it('args for each request', function () {
|
||||||
|
|
||||||
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has no instance', function () {
|
it('has no instance', function () {
|
||||||
|
|
||||||
assert.notProperty(modulejs._private.instances, ID);
|
assert.notProperty(modulejs._private.instances, ID);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('inits without errors', function () {
|
it('inits without errors', function () {
|
||||||
|
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('application', function () {
|
describe('application', function () {
|
||||||
|
|
||||||
it('returns undefined', function () {
|
it('returns undefined', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isUndefined(instance);
|
assert.isUndefined(instance);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('adds HTML #support to #content', function () {
|
it('adds HTML #support to #content', function () {
|
||||||
|
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
assert.lengthOf($('#content > #support'), 1);
|
assert.lengthOf($('#content > #support'), 1);
|
||||||
assert.lengthOf($('#support > .paypal'), 1);
|
assert.lengthOf($('#support > .paypal'), 1);
|
||||||
@@ -92,50 +75,42 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('adds HTML #login-wrapper to #content', function () {
|
it('adds HTML #login-wrapper to #content', function () {
|
||||||
|
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
assert.lengthOf($('#content > #login-wrapper'), 1);
|
assert.lengthOf($('#content > #login-wrapper'), 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('no admin', function () {
|
describe('no admin', function () {
|
||||||
|
|
||||||
it('adds HTML #pass to #login-wrapper', function () {
|
it('adds HTML #pass to #login-wrapper', function () {
|
||||||
|
|
||||||
this.xConfig.setup.AS_ADMIN = false;
|
this.xConfig.setup.AS_ADMIN = false;
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
assert.lengthOf($('#login-wrapper > #pass'), 1);
|
assert.lengthOf($('#login-wrapper > #pass'), 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('sets #pass val to empty string', function () {
|
it('sets #pass val to empty string', function () {
|
||||||
|
|
||||||
this.xConfig.setup.AS_ADMIN = false;
|
this.xConfig.setup.AS_ADMIN = false;
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
assert.strictEqual($('#login-wrapper > #pass').val(), '');
|
assert.strictEqual($('#login-wrapper > #pass').val(), '');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('adds HTML #login to #login-wrapper', function () {
|
it('adds HTML #login to #login-wrapper', function () {
|
||||||
|
|
||||||
this.xConfig.setup.AS_ADMIN = false;
|
this.xConfig.setup.AS_ADMIN = false;
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
assert.lengthOf($('#login-wrapper > #login'), 1);
|
assert.lengthOf($('#login-wrapper > #login'), 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not add HTML #logout to #login-wrapper', function () {
|
it('does not add HTML #logout to #login-wrapper', function () {
|
||||||
|
|
||||||
this.xConfig.setup.AS_ADMIN = false;
|
this.xConfig.setup.AS_ADMIN = false;
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
assert.lengthOf($('#login-wrapper > #logout'), 0);
|
assert.lengthOf($('#login-wrapper > #logout'), 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not add HTML #tests to #content', function () {
|
it('does not add HTML #tests to #content', function () {
|
||||||
|
|
||||||
this.xConfig.setup.AS_ADMIN = false;
|
this.xConfig.setup.AS_ADMIN = false;
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
assert.lengthOf($('#content > #tests'), 0);
|
assert.lengthOf($('#content > #tests'), 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('login works', function () {
|
it('login works', function () {
|
||||||
|
|
||||||
var pass = uniq.id();
|
var pass = uniq.id();
|
||||||
var expectedData = {
|
var expectedData = {
|
||||||
action: 'login',
|
action: 'login',
|
||||||
@@ -155,44 +130,37 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('as admin', function () {
|
describe('as admin', function () {
|
||||||
|
|
||||||
it('does not add HTML #pass to #login-wrapper', function () {
|
it('does not add HTML #pass to #login-wrapper', function () {
|
||||||
|
|
||||||
this.xConfig.setup.AS_ADMIN = true;
|
this.xConfig.setup.AS_ADMIN = true;
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
assert.lengthOf($('#login-wrapper > #pass'), 0);
|
assert.lengthOf($('#login-wrapper > #pass'), 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not add #login to #login-wrapper', function () {
|
it('does not add #login to #login-wrapper', function () {
|
||||||
|
|
||||||
this.xConfig.setup.AS_ADMIN = true;
|
this.xConfig.setup.AS_ADMIN = true;
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
assert.lengthOf($('#login-wrapper > #login'), 0);
|
assert.lengthOf($('#login-wrapper > #login'), 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('adds HTML #logout to #login-wrapper', function () {
|
it('adds HTML #logout to #login-wrapper', function () {
|
||||||
|
|
||||||
this.xConfig.setup.AS_ADMIN = true;
|
this.xConfig.setup.AS_ADMIN = true;
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
assert.lengthOf($('#login-wrapper > #logout'), 1);
|
assert.lengthOf($('#login-wrapper > #logout'), 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('adds HTML #tests to #content', function () {
|
it('adds HTML #tests to #content', function () {
|
||||||
|
|
||||||
this.xConfig.setup.AS_ADMIN = true;
|
this.xConfig.setup.AS_ADMIN = true;
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
assert.lengthOf($('#content > #tests'), 1);
|
assert.lengthOf($('#content > #tests'), 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('adds HTML #test 15x to #tests', function () {
|
it('adds HTML #test 15x to #tests', function () {
|
||||||
|
|
||||||
this.xConfig.setup.AS_ADMIN = true;
|
this.xConfig.setup.AS_ADMIN = true;
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
assert.strictEqual($('#tests > .test').length, 15);
|
assert.strictEqual($('#tests > .test').length, 15);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('logout works', function () {
|
it('logout works', function () {
|
||||||
|
|
||||||
var expectedData = {
|
var expectedData = {
|
||||||
action: 'logout'
|
action: 'logout'
|
||||||
};
|
};
|
||||||
@@ -208,6 +176,5 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
@@ -1,13 +1,9 @@
|
|||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
var ID = 'model/item';
|
||||||
|
var DEPS = ['_', 'core/event', 'core/location', 'core/server', 'core/settings', 'core/types'];
|
||||||
var ID = 'model/item';
|
|
||||||
var DEPS = ['_', 'core/event', 'core/location', 'core/server', 'core/settings', 'core/types'];
|
|
||||||
|
|
||||||
describe('module \'' + ID + '\'', function () {
|
|
||||||
|
|
||||||
|
describe('module \'' + ID + '\'', function () {
|
||||||
before(function () {
|
before(function () {
|
||||||
|
|
||||||
this.definition = modulejs._private.definitions[ID];
|
this.definition = modulejs._private.definitions[ID];
|
||||||
|
|
||||||
this.xRootName = uniq.id();
|
this.xRootName = uniq.id();
|
||||||
@@ -25,48 +21,38 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
getAbsHref: sinon.stub().returns(uniq.id())
|
getAbsHref: sinon.stub().returns(uniq.id())
|
||||||
};
|
};
|
||||||
this.applyFn = function () {
|
this.applyFn = function () {
|
||||||
|
|
||||||
return this.definition.fn(_, this.xEvent, this.xLocation, this.xServer, this.xSettings, this.xTypes);
|
return this.definition.fn(_, this.xEvent, this.xLocation, this.xServer, this.xSettings, this.xTypes);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('definition', function () {
|
describe('definition', function () {
|
||||||
|
|
||||||
it('is defined', function () {
|
it('is defined', function () {
|
||||||
|
|
||||||
assert.isPlainObject(this.definition);
|
assert.isPlainObject(this.definition);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has correct id', function () {
|
it('has correct id', function () {
|
||||||
|
|
||||||
assert.strictEqual(this.definition.id, ID);
|
assert.strictEqual(this.definition.id, ID);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('requires correct', function () {
|
it('requires correct', function () {
|
||||||
|
|
||||||
assert.deepEqual(this.definition.deps, DEPS);
|
assert.deepEqual(this.definition.deps, DEPS);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('args for each request', function () {
|
it('args for each request', function () {
|
||||||
|
|
||||||
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has no instance', function () {
|
it('has no instance', function () {
|
||||||
|
|
||||||
assert.notProperty(modulejs._private.instances, ID);
|
assert.notProperty(modulejs._private.instances, ID);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('inits without errors', function () {
|
it('inits without errors', function () {
|
||||||
|
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('application', function () {
|
describe('application', function () {
|
||||||
|
|
||||||
it('returns plain object with 2 properties', function () {
|
it('returns plain object with 2 properties', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isPlainObject(instance);
|
assert.isPlainObject(instance);
|
||||||
assert.lengthOfKeys(instance, 2);
|
assert.lengthOfKeys(instance, 2);
|
||||||
@@ -74,315 +60,252 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('.get()', function () {
|
describe('.get()', function () {
|
||||||
|
|
||||||
it('is function', function () {
|
it('is function', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isFunction(instance.get);
|
assert.isFunction(instance.get);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns null with no argument', function () {
|
it('returns null with no argument', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isNull(instance.get());
|
assert.isNull(instance.get());
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns null for no string argument', function () {
|
it('returns null for no string argument', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isNull(instance.get(1));
|
assert.isNull(instance.get(1));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns null for href not starting with rootHref', function () {
|
it('returns null for href not starting with rootHref', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isNull(instance.get('/a/'));
|
assert.isNull(instance.get('/a/'));
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('for rootHref', function () {
|
describe('for rootHref', function () {
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
this.item = instance.get(this.xSettings.rootHref);
|
this.item = instance.get(this.xSettings.rootHref);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns object', function () {
|
it('returns object', function () {
|
||||||
|
|
||||||
assert.isObject(this.item);
|
assert.isObject(this.item);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('sets href correct', function () {
|
it('sets href correct', function () {
|
||||||
|
|
||||||
assert.strictEqual(this.item.absHref, this.xSettings.rootHref);
|
assert.strictEqual(this.item.absHref, this.xSettings.rootHref);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('sets type correct', function () {
|
it('sets type correct', function () {
|
||||||
|
|
||||||
assert.strictEqual(this.item.type, this.xTypes.getType(this.absHref));
|
assert.strictEqual(this.item.type, this.xTypes.getType(this.absHref));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('sets label correct', function () {
|
it('sets label correct', function () {
|
||||||
|
|
||||||
assert.strictEqual(this.item.label, this.xRootName);
|
assert.strictEqual(this.item.label, this.xRootName);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('sets time to null', function () {
|
it('sets time to null', function () {
|
||||||
|
|
||||||
assert.isNull(this.item.time);
|
assert.isNull(this.item.time);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('sets size to null', function () {
|
it('sets size to null', function () {
|
||||||
|
|
||||||
assert.isNull(this.item.size);
|
assert.isNull(this.item.size);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('sets parent to null', function () {
|
it('sets parent to null', function () {
|
||||||
|
|
||||||
assert.isNull(this.item.parent);
|
assert.isNull(this.item.parent);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('sets isManaged to null', function () {
|
it('sets isManaged to null', function () {
|
||||||
|
|
||||||
assert.isNull(this.item.isManaged);
|
assert.isNull(this.item.isManaged);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('sets content correct', function () {
|
it('sets content correct', function () {
|
||||||
|
|
||||||
assert.isPlainObject(this.item.content);
|
assert.isPlainObject(this.item.content);
|
||||||
assert.lengthOfKeys(this.item.content, 0);
|
assert.lengthOfKeys(this.item.content, 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('.isFolder() returns true', function () {
|
it('.isFolder() returns true', function () {
|
||||||
|
|
||||||
assert.isTrue(this.item.isFolder());
|
assert.isTrue(this.item.isFolder());
|
||||||
});
|
});
|
||||||
|
|
||||||
it('.isCurrentFolder() returns false', function () {
|
it('.isCurrentFolder() returns false', function () {
|
||||||
|
|
||||||
assert.isFalse(this.item.isCurrentFolder());
|
assert.isFalse(this.item.isCurrentFolder());
|
||||||
});
|
});
|
||||||
|
|
||||||
it('.isInCurrentFolder() returns false', function () {
|
it('.isInCurrentFolder() returns false', function () {
|
||||||
|
|
||||||
assert.isFalse(this.item.isInCurrentFolder());
|
assert.isFalse(this.item.isInCurrentFolder());
|
||||||
});
|
});
|
||||||
|
|
||||||
it('.isCurrentParentFolder() returns false', function () {
|
it('.isCurrentParentFolder() returns false', function () {
|
||||||
|
|
||||||
assert.isFalse(this.item.isCurrentParentFolder());
|
assert.isFalse(this.item.isCurrentParentFolder());
|
||||||
});
|
});
|
||||||
|
|
||||||
it('.isDomain() returns false', function () {
|
it('.isDomain() returns false', function () {
|
||||||
|
|
||||||
assert.isFalse(this.item.isDomain());
|
assert.isFalse(this.item.isDomain());
|
||||||
});
|
});
|
||||||
|
|
||||||
it('.isRoot() returns true', function () {
|
it('.isRoot() returns true', function () {
|
||||||
|
|
||||||
assert.isTrue(this.item.isRoot());
|
assert.isTrue(this.item.isRoot());
|
||||||
});
|
});
|
||||||
|
|
||||||
it('.isEmpty() returns true', function () {
|
it('.isEmpty() returns true', function () {
|
||||||
|
|
||||||
assert.isTrue(this.item.isEmpty());
|
assert.isTrue(this.item.isEmpty());
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('for folder href other than rootHref', function () {
|
describe('for folder href other than rootHref', function () {
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
this.item = instance.get(this.xSettings.rootHref + 'a/');
|
this.item = instance.get(this.xSettings.rootHref + 'a/');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns object', function () {
|
it('returns object', function () {
|
||||||
|
|
||||||
assert.isObject(this.item);
|
assert.isObject(this.item);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('sets href correct', function () {
|
it('sets href correct', function () {
|
||||||
|
|
||||||
assert.strictEqual(this.item.absHref, this.xSettings.rootHref + 'a/');
|
assert.strictEqual(this.item.absHref, this.xSettings.rootHref + 'a/');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('sets type correct', function () {
|
it('sets type correct', function () {
|
||||||
|
|
||||||
assert.strictEqual(this.item.type, this.xTypes.getType(this.absHref));
|
assert.strictEqual(this.item.type, this.xTypes.getType(this.absHref));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('sets label correct', function () {
|
it('sets label correct', function () {
|
||||||
|
|
||||||
assert.strictEqual(this.item.label, 'a');
|
assert.strictEqual(this.item.label, 'a');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('sets time to null', function () {
|
it('sets time to null', function () {
|
||||||
|
|
||||||
assert.isNull(this.item.time);
|
assert.isNull(this.item.time);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('sets size to null', function () {
|
it('sets size to null', function () {
|
||||||
|
|
||||||
assert.isNull(this.item.size);
|
assert.isNull(this.item.size);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('sets parent to object', function () {
|
it('sets parent to object', function () {
|
||||||
|
|
||||||
assert.isObject(this.item.parent);
|
assert.isObject(this.item.parent);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('parent has same constructor', function () {
|
it('parent has same constructor', function () {
|
||||||
|
|
||||||
assert.strictEqual(this.item.constructor, this.item.parent.constructor);
|
assert.strictEqual(this.item.constructor, this.item.parent.constructor);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('sets isManaged to null', function () {
|
it('sets isManaged to null', function () {
|
||||||
|
|
||||||
assert.isNull(this.item.isManaged);
|
assert.isNull(this.item.isManaged);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('sets content correct', function () {
|
it('sets content correct', function () {
|
||||||
|
|
||||||
assert.isPlainObject(this.item.content);
|
assert.isPlainObject(this.item.content);
|
||||||
assert.lengthOfKeys(this.item.content, 0);
|
assert.lengthOfKeys(this.item.content, 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('.isFolder() returns true', function () {
|
it('.isFolder() returns true', function () {
|
||||||
|
|
||||||
assert.isTrue(this.item.isFolder());
|
assert.isTrue(this.item.isFolder());
|
||||||
});
|
});
|
||||||
|
|
||||||
it('.isCurrentFolder() returns false', function () {
|
it('.isCurrentFolder() returns false', function () {
|
||||||
|
|
||||||
assert.isFalse(this.item.isCurrentFolder());
|
assert.isFalse(this.item.isCurrentFolder());
|
||||||
});
|
});
|
||||||
|
|
||||||
it('.isInCurrentFolder() returns false', function () {
|
it('.isInCurrentFolder() returns false', function () {
|
||||||
|
|
||||||
assert.isFalse(this.item.isInCurrentFolder());
|
assert.isFalse(this.item.isInCurrentFolder());
|
||||||
});
|
});
|
||||||
|
|
||||||
it('.isCurrentParentFolder() returns false', function () {
|
it('.isCurrentParentFolder() returns false', function () {
|
||||||
|
|
||||||
assert.isFalse(this.item.isCurrentParentFolder());
|
assert.isFalse(this.item.isCurrentParentFolder());
|
||||||
});
|
});
|
||||||
|
|
||||||
it('.isDomain() returns false', function () {
|
it('.isDomain() returns false', function () {
|
||||||
|
|
||||||
assert.isFalse(this.item.isDomain());
|
assert.isFalse(this.item.isDomain());
|
||||||
});
|
});
|
||||||
|
|
||||||
it('.isRoot() returns false', function () {
|
it('.isRoot() returns false', function () {
|
||||||
|
|
||||||
assert.isFalse(this.item.isRoot());
|
assert.isFalse(this.item.isRoot());
|
||||||
});
|
});
|
||||||
|
|
||||||
it('.isEmpty() returns true', function () {
|
it('.isEmpty() returns true', function () {
|
||||||
|
|
||||||
assert.isTrue(this.item.isEmpty());
|
assert.isTrue(this.item.isEmpty());
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('for file href', function () {
|
describe('for file href', function () {
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
this.item = instance.get(this.xSettings.rootHref + 'a');
|
this.item = instance.get(this.xSettings.rootHref + 'a');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns object', function () {
|
it('returns object', function () {
|
||||||
|
|
||||||
assert.isObject(this.item);
|
assert.isObject(this.item);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('sets href correct', function () {
|
it('sets href correct', function () {
|
||||||
|
|
||||||
assert.strictEqual(this.item.absHref, this.xSettings.rootHref + 'a');
|
assert.strictEqual(this.item.absHref, this.xSettings.rootHref + 'a');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('sets type correct', function () {
|
it('sets type correct', function () {
|
||||||
|
|
||||||
assert.strictEqual(this.item.type, this.xTypes.getType(this.absHref));
|
assert.strictEqual(this.item.type, this.xTypes.getType(this.absHref));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('sets label correct', function () {
|
it('sets label correct', function () {
|
||||||
|
|
||||||
assert.strictEqual(this.item.label, 'a');
|
assert.strictEqual(this.item.label, 'a');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('sets time to null', function () {
|
it('sets time to null', function () {
|
||||||
|
|
||||||
assert.isNull(this.item.time);
|
assert.isNull(this.item.time);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('sets size to null', function () {
|
it('sets size to null', function () {
|
||||||
|
|
||||||
assert.isNull(this.item.size);
|
assert.isNull(this.item.size);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('sets parent to object', function () {
|
it('sets parent to object', function () {
|
||||||
|
|
||||||
assert.isObject(this.item.parent);
|
assert.isObject(this.item.parent);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('parent has same constructor', function () {
|
it('parent has same constructor', function () {
|
||||||
|
|
||||||
assert.strictEqual(this.item.constructor, this.item.parent.constructor);
|
assert.strictEqual(this.item.constructor, this.item.parent.constructor);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('sets isManaged to null', function () {
|
it('sets isManaged to null', function () {
|
||||||
|
|
||||||
assert.isNull(this.item.isManaged);
|
assert.isNull(this.item.isManaged);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('sets content correct', function () {
|
it('sets content correct', function () {
|
||||||
|
|
||||||
assert.isPlainObject(this.item.content);
|
assert.isPlainObject(this.item.content);
|
||||||
assert.lengthOfKeys(this.item.content, 0);
|
assert.lengthOfKeys(this.item.content, 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('.isFolder() returns false', function () {
|
it('.isFolder() returns false', function () {
|
||||||
|
|
||||||
assert.isFalse(this.item.isFolder());
|
assert.isFalse(this.item.isFolder());
|
||||||
});
|
});
|
||||||
|
|
||||||
it('.isCurrentFolder() returns false', function () {
|
it('.isCurrentFolder() returns false', function () {
|
||||||
|
|
||||||
assert.isFalse(this.item.isCurrentFolder());
|
assert.isFalse(this.item.isCurrentFolder());
|
||||||
});
|
});
|
||||||
|
|
||||||
it('.isInCurrentFolder() returns false', function () {
|
it('.isInCurrentFolder() returns false', function () {
|
||||||
|
|
||||||
assert.isFalse(this.item.isInCurrentFolder());
|
assert.isFalse(this.item.isInCurrentFolder());
|
||||||
});
|
});
|
||||||
|
|
||||||
it('.isCurrentParentFolder() returns false', function () {
|
it('.isCurrentParentFolder() returns false', function () {
|
||||||
|
|
||||||
assert.isFalse(this.item.isCurrentParentFolder());
|
assert.isFalse(this.item.isCurrentParentFolder());
|
||||||
});
|
});
|
||||||
|
|
||||||
it('.isDomain() returns false', function () {
|
it('.isDomain() returns false', function () {
|
||||||
|
|
||||||
assert.isFalse(this.item.isDomain());
|
assert.isFalse(this.item.isDomain());
|
||||||
});
|
});
|
||||||
|
|
||||||
it('.isRoot() returns false', function () {
|
it('.isRoot() returns false', function () {
|
||||||
|
|
||||||
assert.isFalse(this.item.isRoot());
|
assert.isFalse(this.item.isRoot());
|
||||||
});
|
});
|
||||||
|
|
||||||
it('.isEmpty() returns true', function () {
|
it('.isEmpty() returns true', function () {
|
||||||
|
|
||||||
assert.isTrue(this.item.isEmpty());
|
assert.isTrue(this.item.isEmpty());
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('parents', function () {
|
describe('parents', function () {
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
this.item = instance.get(this.xSettings.rootHref + 'p/a/');
|
this.item = instance.get(this.xSettings.rootHref + 'p/a/');
|
||||||
this.parent = this.item.parent;
|
this.parent = this.item.parent;
|
||||||
@@ -390,55 +313,44 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('parent is object', function () {
|
it('parent is object', function () {
|
||||||
|
|
||||||
assert.isObject(this.parent);
|
assert.isObject(this.parent);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('parent has correct href', function () {
|
it('parent has correct href', function () {
|
||||||
|
|
||||||
assert.strictEqual(this.parent.absHref, this.xSettings.rootHref + 'p/');
|
assert.strictEqual(this.parent.absHref, this.xSettings.rootHref + 'p/');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('parent has correct label', function () {
|
it('parent has correct label', function () {
|
||||||
|
|
||||||
assert.strictEqual(this.parent.label, 'p');
|
assert.strictEqual(this.parent.label, 'p');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('parent .isEmpty() returns false', function () {
|
it('parent .isEmpty() returns false', function () {
|
||||||
|
|
||||||
assert.isFalse(this.parent.isEmpty());
|
assert.isFalse(this.parent.isEmpty());
|
||||||
});
|
});
|
||||||
|
|
||||||
it('grandpa is object', function () {
|
it('grandpa is object', function () {
|
||||||
|
|
||||||
assert.isObject(this.grandpa);
|
assert.isObject(this.grandpa);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('grandpa has correct href', function () {
|
it('grandpa has correct href', function () {
|
||||||
|
|
||||||
assert.strictEqual(this.grandpa.absHref, this.xSettings.rootHref);
|
assert.strictEqual(this.grandpa.absHref, this.xSettings.rootHref);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('grandpa has correct label', function () {
|
it('grandpa has correct label', function () {
|
||||||
|
|
||||||
assert.strictEqual(this.grandpa.label, this.xRootName);
|
assert.strictEqual(this.grandpa.label, this.xRootName);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('grandpa .isEmpty() returns false', function () {
|
it('grandpa .isEmpty() returns false', function () {
|
||||||
|
|
||||||
assert.isFalse(this.grandpa.isEmpty());
|
assert.isFalse(this.grandpa.isEmpty());
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('.remove()', function () {
|
describe('.remove()', function () {
|
||||||
|
|
||||||
it('is function', function () {
|
it('is function', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isFunction(instance.remove);
|
assert.isFunction(instance.remove);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
@@ -1,48 +1,36 @@
|
|||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
describe('modulejs', function () {
|
||||||
|
|
||||||
describe('modulejs', function () {
|
|
||||||
|
|
||||||
it('is global object', function () {
|
it('is global object', function () {
|
||||||
|
|
||||||
assert.isPlainObject(modulejs);
|
assert.isPlainObject(modulejs);
|
||||||
assert.strictEqual(modulejs, window.modulejs);
|
assert.strictEqual(modulejs, window.modulejs);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('.define() is function', function () {
|
it('.define() is function', function () {
|
||||||
|
|
||||||
assert.isFunction(modulejs.define);
|
assert.isFunction(modulejs.define);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('.require() is function', function () {
|
it('.require() is function', function () {
|
||||||
|
|
||||||
assert.isFunction(modulejs.require);
|
assert.isFunction(modulejs.require);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('.state() is function', function () {
|
it('.state() is function', function () {
|
||||||
|
|
||||||
assert.isFunction(modulejs.state);
|
assert.isFunction(modulejs.state);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('.log() is function', function () {
|
it('.log() is function', function () {
|
||||||
|
|
||||||
assert.isFunction(modulejs.log);
|
assert.isFunction(modulejs.log);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('._private is object', function () {
|
it('._private is object', function () {
|
||||||
|
|
||||||
assert.isObject(modulejs._private);
|
assert.isObject(modulejs._private);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has definitions', function () {
|
it('has definitions', function () {
|
||||||
|
|
||||||
assert.isAbove(_.keys(modulejs._private.definitions).length, 0);
|
assert.isAbove(_.keys(modulejs._private.definitions).length, 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has no instances', function () {
|
it('has no instances', function () {
|
||||||
|
|
||||||
assert.lengthOfKeys(modulejs._private.instances, 0);
|
assert.lengthOfKeys(modulejs._private.instances, 0);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
@@ -1,86 +1,67 @@
|
|||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
var ID = 'view/content';
|
||||||
|
var DEPS = ['$', 'view/mainrow'];
|
||||||
var ID = 'view/content';
|
|
||||||
var DEPS = ['$', 'view/mainrow'];
|
|
||||||
|
|
||||||
describe('module \'' + ID + '\'', function () {
|
|
||||||
|
|
||||||
|
describe('module \'' + ID + '\'', function () {
|
||||||
before(function () {
|
before(function () {
|
||||||
|
|
||||||
this.definition = modulejs._private.definitions[ID];
|
this.definition = modulejs._private.definitions[ID];
|
||||||
|
|
||||||
this.xMainrow = {$el: null};
|
this.xMainrow = {$el: null};
|
||||||
this.applyFn = function () {
|
this.applyFn = function () {
|
||||||
|
|
||||||
return this.definition.fn($, this.xMainrow);
|
return this.definition.fn($, this.xMainrow);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
after(function () {
|
after(function () {
|
||||||
|
|
||||||
util.restoreHtml();
|
util.restoreHtml();
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
|
|
||||||
util.restoreHtml();
|
util.restoreHtml();
|
||||||
this.xMainrow.$el = $('<div id="mainrow"/>').appendTo('body');
|
this.xMainrow.$el = $('<div id="mainrow"/>').appendTo('body');
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('definition', function () {
|
describe('definition', function () {
|
||||||
|
|
||||||
it('is defined', function () {
|
it('is defined', function () {
|
||||||
|
|
||||||
assert.isPlainObject(this.definition);
|
assert.isPlainObject(this.definition);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has correct id', function () {
|
it('has correct id', function () {
|
||||||
|
|
||||||
assert.strictEqual(this.definition.id, ID);
|
assert.strictEqual(this.definition.id, ID);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('requires correct', function () {
|
it('requires correct', function () {
|
||||||
|
|
||||||
assert.deepEqual(this.definition.deps, DEPS);
|
assert.deepEqual(this.definition.deps, DEPS);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('args for each request', function () {
|
it('args for each request', function () {
|
||||||
|
|
||||||
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has no instance', function () {
|
it('has no instance', function () {
|
||||||
|
|
||||||
assert.notProperty(modulejs._private.instances, ID);
|
assert.notProperty(modulejs._private.instances, ID);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('inits without errors', function () {
|
it('inits without errors', function () {
|
||||||
|
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('application', function () {
|
describe('application', function () {
|
||||||
|
|
||||||
it('returns object with 1 property', function () {
|
it('returns object with 1 property', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isPlainObject(instance);
|
assert.isPlainObject(instance);
|
||||||
assert.lengthOfKeys(instance, 1);
|
assert.lengthOfKeys(instance, 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('adds HTML #content to #mainrow', function () {
|
it('adds HTML #content to #mainrow', function () {
|
||||||
|
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
assert.lengthOf($('#mainrow > #content'), 1);
|
assert.lengthOf($('#mainrow > #content'), 1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('.$el', function () {
|
describe('.$el', function () {
|
||||||
|
|
||||||
it('is $(\'#content\')', function () {
|
it('is $(\'#content\')', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isObject(instance.$el);
|
assert.isObject(instance.$el);
|
||||||
assert.lengthOf(instance.$el, 1);
|
assert.lengthOf(instance.$el, 1);
|
||||||
@@ -88,6 +69,5 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
assert.strictEqual(instance.$el.attr('id'), 'content');
|
assert.strictEqual(instance.$el.attr('id'), 'content');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
@@ -1,86 +1,67 @@
|
|||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
var ID = 'view/mainrow';
|
||||||
|
var DEPS = ['$', 'view/root'];
|
||||||
var ID = 'view/mainrow';
|
|
||||||
var DEPS = ['$', 'view/root'];
|
|
||||||
|
|
||||||
describe('module \'' + ID + '\'', function () {
|
|
||||||
|
|
||||||
|
describe('module \'' + ID + '\'', function () {
|
||||||
before(function () {
|
before(function () {
|
||||||
|
|
||||||
this.definition = modulejs._private.definitions[ID];
|
this.definition = modulejs._private.definitions[ID];
|
||||||
|
|
||||||
this.xRoot = {$el: null};
|
this.xRoot = {$el: null};
|
||||||
this.applyFn = function () {
|
this.applyFn = function () {
|
||||||
|
|
||||||
return this.definition.fn($, this.xRoot);
|
return this.definition.fn($, this.xRoot);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
after(function () {
|
after(function () {
|
||||||
|
|
||||||
util.restoreHtml();
|
util.restoreHtml();
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
|
|
||||||
util.restoreHtml();
|
util.restoreHtml();
|
||||||
this.xRoot.$el = $('<div id="root"/>').appendTo('body');
|
this.xRoot.$el = $('<div id="root"/>').appendTo('body');
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('definition', function () {
|
describe('definition', function () {
|
||||||
|
|
||||||
it('is defined', function () {
|
it('is defined', function () {
|
||||||
|
|
||||||
assert.isPlainObject(this.definition);
|
assert.isPlainObject(this.definition);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has correct id', function () {
|
it('has correct id', function () {
|
||||||
|
|
||||||
assert.strictEqual(this.definition.id, ID);
|
assert.strictEqual(this.definition.id, ID);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('requires correct', function () {
|
it('requires correct', function () {
|
||||||
|
|
||||||
assert.deepEqual(this.definition.deps, DEPS);
|
assert.deepEqual(this.definition.deps, DEPS);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('args for each request', function () {
|
it('args for each request', function () {
|
||||||
|
|
||||||
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has no instance', function () {
|
it('has no instance', function () {
|
||||||
|
|
||||||
assert.notProperty(modulejs._private.instances, ID);
|
assert.notProperty(modulejs._private.instances, ID);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('inits without errors', function () {
|
it('inits without errors', function () {
|
||||||
|
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('application', function () {
|
describe('application', function () {
|
||||||
|
|
||||||
it('returns object with 1 property', function () {
|
it('returns object with 1 property', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isPlainObject(instance);
|
assert.isPlainObject(instance);
|
||||||
assert.lengthOfKeys(instance, 1);
|
assert.lengthOfKeys(instance, 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('adds HTML #mainrow to #root', function () {
|
it('adds HTML #mainrow to #root', function () {
|
||||||
|
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
assert.lengthOf($('#root > #mainrow'), 1);
|
assert.lengthOf($('#root > #mainrow'), 1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('.$el', function () {
|
describe('.$el', function () {
|
||||||
|
|
||||||
it('is $(\'#mainrow\')', function () {
|
it('is $(\'#mainrow\')', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isObject(instance.$el);
|
assert.isObject(instance.$el);
|
||||||
assert.lengthOf(instance.$el, 1);
|
assert.lengthOf(instance.$el, 1);
|
||||||
@@ -88,6 +69,5 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
assert.strictEqual(instance.$el.attr('id'), 'mainrow');
|
assert.strictEqual(instance.$el.attr('id'), 'mainrow');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
@@ -1,77 +1,60 @@
|
|||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
var ID = 'view/notification';
|
||||||
|
var DEPS = ['$', 'view/root'];
|
||||||
var ID = 'view/notification';
|
|
||||||
var DEPS = ['$', 'view/root'];
|
|
||||||
|
|
||||||
describe('module \'' + ID + '\'', function () {
|
|
||||||
|
|
||||||
|
describe('module \'' + ID + '\'', function () {
|
||||||
before(function () {
|
before(function () {
|
||||||
|
|
||||||
this.definition = modulejs._private.definitions[ID];
|
this.definition = modulejs._private.definitions[ID];
|
||||||
|
|
||||||
this.xRoot = {$el: null};
|
this.xRoot = {$el: null};
|
||||||
this.applyFn = function () {
|
this.applyFn = function () {
|
||||||
|
|
||||||
return this.definition.fn($, this.xRoot);
|
return this.definition.fn($, this.xRoot);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
after(function () {
|
after(function () {
|
||||||
|
|
||||||
util.restoreHtml();
|
util.restoreHtml();
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
|
|
||||||
util.restoreHtml();
|
util.restoreHtml();
|
||||||
this.xRoot.$el = $('<div id="root"/>').appendTo('body');
|
this.xRoot.$el = $('<div id="root"/>').appendTo('body');
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('definition', function () {
|
describe('definition', function () {
|
||||||
|
|
||||||
it('is defined', function () {
|
it('is defined', function () {
|
||||||
|
|
||||||
assert.isPlainObject(this.definition);
|
assert.isPlainObject(this.definition);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has correct id', function () {
|
it('has correct id', function () {
|
||||||
|
|
||||||
assert.strictEqual(this.definition.id, ID);
|
assert.strictEqual(this.definition.id, ID);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('requires correct', function () {
|
it('requires correct', function () {
|
||||||
|
|
||||||
assert.deepEqual(this.definition.deps, DEPS);
|
assert.deepEqual(this.definition.deps, DEPS);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('args for each request', function () {
|
it('args for each request', function () {
|
||||||
|
|
||||||
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has no instance', function () {
|
it('has no instance', function () {
|
||||||
|
|
||||||
assert.notProperty(modulejs._private.instances, ID);
|
assert.notProperty(modulejs._private.instances, ID);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('inits without errors', function () {
|
it('inits without errors', function () {
|
||||||
|
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('application', function () {
|
describe('application', function () {
|
||||||
|
|
||||||
it('returns plain object with 2 properties', function () {
|
it('returns plain object with 2 properties', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isPlainObject(instance);
|
assert.isPlainObject(instance);
|
||||||
assert.lengthOfKeys(instance, 2);
|
assert.lengthOfKeys(instance, 2);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('adds HTML #notification to #root (hidden)', function () {
|
it('adds HTML #notification to #root (hidden)', function () {
|
||||||
|
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
assert.lengthOf($('#root > #notification'), 1);
|
assert.lengthOf($('#root > #notification'), 1);
|
||||||
assert.lengthOf($('#notification:visible'), 0);
|
assert.lengthOf($('#notification:visible'), 0);
|
||||||
@@ -80,9 +63,7 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('.$el', function () {
|
describe('.$el', function () {
|
||||||
|
|
||||||
it('is $(\'#notification\')', function () {
|
it('is $(\'#notification\')', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isObject(instance.$el);
|
assert.isObject(instance.$el);
|
||||||
assert.lengthOf(instance.$el, 1);
|
assert.lengthOf(instance.$el, 1);
|
||||||
@@ -92,15 +73,12 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('.set()', function () {
|
describe('.set()', function () {
|
||||||
|
|
||||||
it('is function', function () {
|
it('is function', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isTrue(_.isFunction(instance.set));
|
assert.isTrue(_.isFunction(instance.set));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works', function () {
|
it('works', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
|
|
||||||
instance.set();
|
instance.set();
|
||||||
@@ -120,6 +98,5 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
assert.strictEqual($('#notification').text(), 'world');
|
assert.strictEqual($('#notification').text(), 'world');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
@@ -1,98 +1,77 @@
|
|||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
var ID = 'view/root';
|
||||||
|
var DEPS = ['$'];
|
||||||
var ID = 'view/root';
|
|
||||||
var DEPS = ['$'];
|
|
||||||
|
|
||||||
describe('module \'' + ID + '\'', function () {
|
|
||||||
|
|
||||||
|
describe('module \'' + ID + '\'', function () {
|
||||||
before(function () {
|
before(function () {
|
||||||
|
|
||||||
this.definition = modulejs._private.definitions[ID];
|
this.definition = modulejs._private.definitions[ID];
|
||||||
|
|
||||||
this.applyFn = function () {
|
this.applyFn = function () {
|
||||||
|
|
||||||
return this.definition.fn($);
|
return this.definition.fn($);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
after(function () {
|
after(function () {
|
||||||
|
|
||||||
util.restoreHtml();
|
util.restoreHtml();
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
|
|
||||||
util.restoreHtml();
|
util.restoreHtml();
|
||||||
$('<div id="fallback"/>').appendTo('body');
|
$('<div id="fallback"/>').appendTo('body');
|
||||||
$('<div id="fallback-hints"/>').appendTo('body');
|
$('<div id="fallback-hints"/>').appendTo('body');
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('definition', function () {
|
describe('definition', function () {
|
||||||
|
|
||||||
it('is defined', function () {
|
it('is defined', function () {
|
||||||
|
|
||||||
assert.isPlainObject(this.definition);
|
assert.isPlainObject(this.definition);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has correct id', function () {
|
it('has correct id', function () {
|
||||||
|
|
||||||
assert.strictEqual(this.definition.id, ID);
|
assert.strictEqual(this.definition.id, ID);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('requires correct', function () {
|
it('requires correct', function () {
|
||||||
|
|
||||||
assert.deepEqual(this.definition.deps, DEPS);
|
assert.deepEqual(this.definition.deps, DEPS);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('args for each request', function () {
|
it('args for each request', function () {
|
||||||
|
|
||||||
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has no instance', function () {
|
it('has no instance', function () {
|
||||||
|
|
||||||
assert.notProperty(modulejs._private.instances, ID);
|
assert.notProperty(modulejs._private.instances, ID);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('inits without errors', function () {
|
it('inits without errors', function () {
|
||||||
|
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('application', function () {
|
describe('application', function () {
|
||||||
|
|
||||||
it('returns object with 1 property', function () {
|
it('returns object with 1 property', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isPlainObject(instance);
|
assert.isPlainObject(instance);
|
||||||
assert.lengthOfKeys(instance, 1);
|
assert.lengthOfKeys(instance, 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('adds id root to body', function () {
|
it('adds id root to body', function () {
|
||||||
|
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
assert.strictEqual($('body').attr('id'), 'root');
|
assert.strictEqual($('body').attr('id'), 'root');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('removes HTML #fallback', function () {
|
it('removes HTML #fallback', function () {
|
||||||
|
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
assert.lengthOf($('#fallback'), 0);
|
assert.lengthOf($('#fallback'), 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('removes HTML #fallback-hints', function () {
|
it('removes HTML #fallback-hints', function () {
|
||||||
|
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
assert.lengthOf($('#fallback-hints'), 0);
|
assert.lengthOf($('#fallback-hints'), 0);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('.$el', function () {
|
describe('.$el', function () {
|
||||||
|
|
||||||
it('is $(\'#root\')', function () {
|
it('is $(\'#root\')', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isObject(instance.$el);
|
assert.isObject(instance.$el);
|
||||||
assert.lengthOf(instance.$el, 1);
|
assert.lengthOf(instance.$el, 1);
|
||||||
@@ -100,6 +79,5 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
assert.strictEqual(instance.$el.attr('id'), 'root');
|
assert.strictEqual(instance.$el.attr('id'), 'root');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
@@ -1,13 +1,9 @@
|
|||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
var ID = 'view/sidebar';
|
||||||
|
var DEPS = ['$', 'core/resource', 'core/store', 'view/mainrow', 'view/topbar'];
|
||||||
var ID = 'view/sidebar';
|
|
||||||
var DEPS = ['$', 'core/resource', 'core/store', 'view/mainrow', 'view/topbar'];
|
|
||||||
|
|
||||||
describe('module \'' + ID + '\'', function () {
|
|
||||||
|
|
||||||
|
describe('module \'' + ID + '\'', function () {
|
||||||
before(function () {
|
before(function () {
|
||||||
|
|
||||||
this.definition = modulejs._private.definitions[ID];
|
this.definition = modulejs._private.definitions[ID];
|
||||||
|
|
||||||
this.xResource = {
|
this.xResource = {
|
||||||
@@ -23,7 +19,6 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
this.xMainrow = {$el: null};
|
this.xMainrow = {$el: null};
|
||||||
this.xTopbar = {$toolbar: null};
|
this.xTopbar = {$toolbar: null};
|
||||||
this.applyFn = function () {
|
this.applyFn = function () {
|
||||||
|
|
||||||
this.xResource.image.reset();
|
this.xResource.image.reset();
|
||||||
this.xStore.get.reset();
|
this.xStore.get.reset();
|
||||||
this.xStore.put.reset();
|
this.xStore.put.reset();
|
||||||
@@ -33,12 +28,10 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
after(function () {
|
after(function () {
|
||||||
|
|
||||||
util.restoreHtml();
|
util.restoreHtml();
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
|
|
||||||
util.restoreHtml();
|
util.restoreHtml();
|
||||||
this.xMainrow.$el = $('<div id="mainrow"/>').appendTo('body');
|
this.xMainrow.$el = $('<div id="mainrow"/>').appendTo('body');
|
||||||
this.xTopbar.$toolbar = $('<div id="toolbar"/>').appendTo('body');
|
this.xTopbar.$toolbar = $('<div id="toolbar"/>').appendTo('body');
|
||||||
@@ -46,55 +39,44 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
|
|
||||||
|
|
||||||
describe('definition', function () {
|
describe('definition', function () {
|
||||||
|
|
||||||
it('is defined', function () {
|
it('is defined', function () {
|
||||||
|
|
||||||
assert.isPlainObject(this.definition);
|
assert.isPlainObject(this.definition);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has correct id', function () {
|
it('has correct id', function () {
|
||||||
|
|
||||||
assert.strictEqual(this.definition.id, ID);
|
assert.strictEqual(this.definition.id, ID);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('requires correct', function () {
|
it('requires correct', function () {
|
||||||
|
|
||||||
assert.deepEqual(this.definition.deps, DEPS);
|
assert.deepEqual(this.definition.deps, DEPS);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('args for each request', function () {
|
it('args for each request', function () {
|
||||||
|
|
||||||
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has no instance', function () {
|
it('has no instance', function () {
|
||||||
|
|
||||||
assert.notProperty(modulejs._private.instances, ID);
|
assert.notProperty(modulejs._private.instances, ID);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('inits without errors', function () {
|
it('inits without errors', function () {
|
||||||
|
|
||||||
this.instance = this.applyFn();
|
this.instance = this.applyFn();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('application', function () {
|
describe('application', function () {
|
||||||
|
|
||||||
it('returns object with 1 property', function () {
|
it('returns object with 1 property', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isPlainObject(instance);
|
assert.isPlainObject(instance);
|
||||||
assert.lengthOfKeys(instance, 1);
|
assert.lengthOfKeys(instance, 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('adds HTML #sidebar-toggle to #toolbar', function () {
|
it('adds HTML #sidebar-toggle to #toolbar', function () {
|
||||||
|
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
assert.lengthOf($('#toolbar > #sidebar-toggle'), 1);
|
assert.lengthOf($('#toolbar > #sidebar-toggle'), 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('toggle works', function () {
|
it('toggle works', function () {
|
||||||
|
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
assert.lengthOf($('#sidebar:visible'), 0);
|
assert.lengthOf($('#sidebar:visible'), 0);
|
||||||
|
|
||||||
@@ -127,9 +109,7 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('.$el', function () {
|
describe('.$el', function () {
|
||||||
|
|
||||||
it('is $(\'#sidebar\')', function () {
|
it('is $(\'#sidebar\')', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isObject(instance.$el);
|
assert.isObject(instance.$el);
|
||||||
assert.lengthOf(instance.$el, 1);
|
assert.lengthOf(instance.$el, 1);
|
||||||
@@ -137,6 +117,5 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
assert.strictEqual(instance.$el.attr('id'), 'sidebar');
|
assert.strictEqual(instance.$el.attr('id'), 'sidebar');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
@@ -1,113 +1,90 @@
|
|||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
var ID = 'view/topbar';
|
||||||
|
var DEPS = ['$', 'view/root'];
|
||||||
var ID = 'view/topbar';
|
|
||||||
var DEPS = ['$', 'view/root'];
|
|
||||||
|
|
||||||
describe('module \'' + ID + '\'', function () {
|
|
||||||
|
|
||||||
|
describe('module \'' + ID + '\'', function () {
|
||||||
before(function () {
|
before(function () {
|
||||||
|
|
||||||
this.definition = modulejs._private.definitions[ID];
|
this.definition = modulejs._private.definitions[ID];
|
||||||
|
|
||||||
this.xRoot = {$el: null};
|
this.xRoot = {$el: null};
|
||||||
this.applyFn = function () {
|
this.applyFn = function () {
|
||||||
|
|
||||||
return this.definition.fn($, this.xRoot);
|
return this.definition.fn($, this.xRoot);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
after(function () {
|
after(function () {
|
||||||
|
|
||||||
util.restoreHtml();
|
util.restoreHtml();
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
|
|
||||||
util.restoreHtml();
|
util.restoreHtml();
|
||||||
this.xRoot.$el = $('<div id="root"/>').appendTo('body');
|
this.xRoot.$el = $('<div id="root"/>').appendTo('body');
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('definition', function () {
|
describe('definition', function () {
|
||||||
|
|
||||||
it('is defined', function () {
|
it('is defined', function () {
|
||||||
|
|
||||||
assert.isPlainObject(this.definition);
|
assert.isPlainObject(this.definition);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has correct id', function () {
|
it('has correct id', function () {
|
||||||
|
|
||||||
assert.strictEqual(this.definition.id, ID);
|
assert.strictEqual(this.definition.id, ID);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('requires correct', function () {
|
it('requires correct', function () {
|
||||||
|
|
||||||
assert.deepEqual(this.definition.deps, DEPS);
|
assert.deepEqual(this.definition.deps, DEPS);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('args for each request', function () {
|
it('args for each request', function () {
|
||||||
|
|
||||||
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has no instance', function () {
|
it('has no instance', function () {
|
||||||
|
|
||||||
assert.notProperty(modulejs._private.instances, ID);
|
assert.notProperty(modulejs._private.instances, ID);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('inits without errors', function () {
|
it('inits without errors', function () {
|
||||||
|
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('application', function () {
|
describe('application', function () {
|
||||||
|
|
||||||
it('returns object with 3 properties', function () {
|
it('returns object with 3 properties', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isPlainObject(instance);
|
assert.isPlainObject(instance);
|
||||||
assert.lengthOfKeys(instance, 3);
|
assert.lengthOfKeys(instance, 3);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('adds HTML #topbar to #root', function () {
|
it('adds HTML #topbar to #root', function () {
|
||||||
|
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
assert.lengthOf($('#root > #topbar'), 1);
|
assert.lengthOf($('#root > #topbar'), 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('adds HTML #toolbar to #topbar', function () {
|
it('adds HTML #toolbar to #topbar', function () {
|
||||||
|
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
assert.lengthOf($('#topbar > #toolbar'), 1);
|
assert.lengthOf($('#topbar > #toolbar'), 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('adds HTML #flowbar to #topbar', function () {
|
it('adds HTML #flowbar to #topbar', function () {
|
||||||
|
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
assert.lengthOf($('#topbar > #flowbar'), 1);
|
assert.lengthOf($('#topbar > #flowbar'), 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('adds HTML #backlink to #topbar', function () {
|
it('adds HTML #backlink to #topbar', function () {
|
||||||
|
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
assert.lengthOf($('#topbar > #backlink'), 1);
|
assert.lengthOf($('#topbar > #backlink'), 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('#backlink has correct href', function () {
|
it('#backlink has correct href', function () {
|
||||||
|
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
assert.strictEqual($('#backlink').attr('href'), 'https://larsjung.de/h5ai/');
|
assert.strictEqual($('#backlink').attr('href'), 'https://larsjung.de/h5ai/');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('#backlink has correct title', function () {
|
it('#backlink has correct title', function () {
|
||||||
|
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
assert.strictEqual($('#backlink').attr('title'), 'powered by h5ai - https://larsjung.de/h5ai/');
|
assert.strictEqual($('#backlink').attr('title'), 'powered by h5ai - https://larsjung.de/h5ai/');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('#backlink has correct text', function () {
|
it('#backlink has correct text', function () {
|
||||||
|
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
assert.strictEqual($('#backlink > div').eq(0).text(), 'powered');
|
assert.strictEqual($('#backlink > div').eq(0).text(), 'powered');
|
||||||
assert.strictEqual($('#backlink > div').eq(1).text(), 'by h5ai');
|
assert.strictEqual($('#backlink > div').eq(1).text(), 'by h5ai');
|
||||||
@@ -115,9 +92,7 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('.$el', function () {
|
describe('.$el', function () {
|
||||||
|
|
||||||
it('is $(\'#topbar\')', function () {
|
it('is $(\'#topbar\')', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isObject(instance.$el);
|
assert.isObject(instance.$el);
|
||||||
assert.lengthOf(instance.$el, 1);
|
assert.lengthOf(instance.$el, 1);
|
||||||
@@ -127,9 +102,7 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('.$toolbar', function () {
|
describe('.$toolbar', function () {
|
||||||
|
|
||||||
it('is $(\'#toolbar\')', function () {
|
it('is $(\'#toolbar\')', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isObject(instance.$toolbar);
|
assert.isObject(instance.$toolbar);
|
||||||
assert.lengthOf(instance.$toolbar, 1);
|
assert.lengthOf(instance.$toolbar, 1);
|
||||||
@@ -139,9 +112,7 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('.$flowbar', function () {
|
describe('.$flowbar', function () {
|
||||||
|
|
||||||
it('is $(\'#flowbar\')', function () {
|
it('is $(\'#flowbar\')', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isObject(instance.$flowbar);
|
assert.isObject(instance.$flowbar);
|
||||||
assert.lengthOf(instance.$flowbar, 1);
|
assert.lengthOf(instance.$flowbar, 1);
|
||||||
@@ -149,6 +120,5 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
assert.strictEqual(instance.$flowbar.attr('id'), 'flowbar');
|
assert.strictEqual(instance.$flowbar.attr('id'), 'flowbar');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
@@ -1,13 +1,9 @@
|
|||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
var ID = 'view/view';
|
||||||
|
var DEPS = ['_', '$', 'core/event', 'core/format', 'core/location', 'core/resource', 'core/settings', 'core/store', 'view/content'];
|
||||||
var ID = 'view/view';
|
|
||||||
var DEPS = ['_', '$', 'core/event', 'core/format', 'core/location', 'core/resource', 'core/settings', 'core/store', 'view/content'];
|
|
||||||
|
|
||||||
describe('module \'' + ID + '\'', function () {
|
|
||||||
|
|
||||||
|
describe('module \'' + ID + '\'', function () {
|
||||||
before(function () {
|
before(function () {
|
||||||
|
|
||||||
this.definition = modulejs._private.definitions[ID];
|
this.definition = modulejs._private.definitions[ID];
|
||||||
|
|
||||||
this.xEvent = {
|
this.xEvent = {
|
||||||
@@ -40,7 +36,6 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
this.xContent = {$el: null};
|
this.xContent = {$el: null};
|
||||||
|
|
||||||
this.applyFn = function () {
|
this.applyFn = function () {
|
||||||
|
|
||||||
this.xEvent.sub.reset();
|
this.xEvent.sub.reset();
|
||||||
this.xEvent.pub.reset();
|
this.xEvent.pub.reset();
|
||||||
this.xFormat.setDefaultMetric.reset();
|
this.xFormat.setDefaultMetric.reset();
|
||||||
@@ -54,85 +49,69 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
after(function () {
|
after(function () {
|
||||||
|
|
||||||
util.restoreHtml();
|
util.restoreHtml();
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
|
|
||||||
util.restoreHtml();
|
util.restoreHtml();
|
||||||
this.xContent.$el = $('<div id="content"/>').appendTo('body');
|
this.xContent.$el = $('<div id="content"/>').appendTo('body');
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('definition', function () {
|
describe('definition', function () {
|
||||||
|
|
||||||
it('is defined', function () {
|
it('is defined', function () {
|
||||||
|
|
||||||
assert.isPlainObject(this.definition);
|
assert.isPlainObject(this.definition);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has correct id', function () {
|
it('has correct id', function () {
|
||||||
|
|
||||||
assert.strictEqual(this.definition.id, ID);
|
assert.strictEqual(this.definition.id, ID);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('requires correct', function () {
|
it('requires correct', function () {
|
||||||
|
|
||||||
assert.deepEqual(this.definition.deps, DEPS);
|
assert.deepEqual(this.definition.deps, DEPS);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('args for each request', function () {
|
it('args for each request', function () {
|
||||||
|
|
||||||
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has no instance', function () {
|
it('has no instance', function () {
|
||||||
|
|
||||||
assert.notProperty(modulejs._private.instances, ID);
|
assert.notProperty(modulejs._private.instances, ID);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('inits without errors', function () {
|
it('inits without errors', function () {
|
||||||
|
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('application', function () {
|
describe('application', function () {
|
||||||
|
|
||||||
it('returns object with 12 properties', function () {
|
it('returns object with 12 properties', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isPlainObject(instance);
|
assert.isPlainObject(instance);
|
||||||
assert.lengthOfKeys(instance, 12);
|
assert.lengthOfKeys(instance, 12);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('adds HTML #view to #content', function () {
|
it('adds HTML #view to #content', function () {
|
||||||
|
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
assert.lengthOf($('#content > #view'), 1);
|
assert.lengthOf($('#content > #view'), 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('adds HTML #items to #view', function () {
|
it('adds HTML #items to #view', function () {
|
||||||
|
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
assert.lengthOf($('#view > #items'), 1);
|
assert.lengthOf($('#view > #items'), 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('adds HTML #view-hint to #view', function () {
|
it('adds HTML #view-hint to #view', function () {
|
||||||
|
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
assert.lengthOf($('#view > #view-hint'), 1);
|
assert.lengthOf($('#view > #view-hint'), 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('adds style to head', function () {
|
it('adds style to head', function () {
|
||||||
|
|
||||||
var styleTagCount = $('head > style').length;
|
var styleTagCount = $('head > style').length;
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
assert.lengthOf($('head > style'), styleTagCount + 1);
|
assert.lengthOf($('head > style'), styleTagCount + 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('style contains possibly correct text', function () {
|
it('style contains possibly correct text', function () {
|
||||||
|
|
||||||
this.xSettings.sizes = [20];
|
this.xSettings.sizes = [20];
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
var text = $('head > style').eq(0).text();
|
var text = $('head > style').eq(0).text();
|
||||||
@@ -142,26 +121,22 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('sets default metric', function () {
|
it('sets default metric', function () {
|
||||||
|
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
assert.isTrue(this.xFormat.setDefaultMetric.calledOnce);
|
assert.isTrue(this.xFormat.setDefaultMetric.calledOnce);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('subscribes to 2 events', function () {
|
it('subscribes to 2 events', function () {
|
||||||
|
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
assert.isTrue(this.xEvent.sub.calledTwice);
|
assert.isTrue(this.xEvent.sub.calledTwice);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('subscribes to location.changed', function () {
|
it('subscribes to location.changed', function () {
|
||||||
|
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
assert.strictEqual(this.xEvent.sub.firstCall.args[0], 'location.changed');
|
assert.strictEqual(this.xEvent.sub.firstCall.args[0], 'location.changed');
|
||||||
assert.isFunction(this.xEvent.sub.firstCall.args[1]);
|
assert.isFunction(this.xEvent.sub.firstCall.args[1]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('subscribes to location.refreshed', function () {
|
it('subscribes to location.refreshed', function () {
|
||||||
|
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
assert.strictEqual(this.xEvent.sub.secondCall.args[0], 'location.refreshed');
|
assert.strictEqual(this.xEvent.sub.secondCall.args[0], 'location.refreshed');
|
||||||
assert.isFunction(this.xEvent.sub.secondCall.args[1]);
|
assert.isFunction(this.xEvent.sub.secondCall.args[1]);
|
||||||
@@ -169,9 +144,7 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('.$el', function () {
|
describe('.$el', function () {
|
||||||
|
|
||||||
it('is $(\'#view\')', function () {
|
it('is $(\'#view\')', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isObject(instance.$el);
|
assert.isObject(instance.$el);
|
||||||
assert.lengthOf(instance.$el, 1);
|
assert.lengthOf(instance.$el, 1);
|
||||||
@@ -181,9 +154,7 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('.$items', function () {
|
describe('.$items', function () {
|
||||||
|
|
||||||
it('is $(\'#items\')', function () {
|
it('is $(\'#items\')', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isObject(instance.$items);
|
assert.isObject(instance.$items);
|
||||||
assert.lengthOf(instance.$items, 1);
|
assert.lengthOf(instance.$items, 1);
|
||||||
@@ -193,15 +164,12 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('.setItems()', function () {
|
describe('.setItems()', function () {
|
||||||
|
|
||||||
it('is function', function () {
|
it('is function', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isTrue(_.isFunction(instance.setItems));
|
assert.isTrue(_.isFunction(instance.setItems));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('publishes view.changed', function () {
|
it('publishes view.changed', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
instance.setItems();
|
instance.setItems();
|
||||||
assert.isTrue(this.xEvent.pub.calledTwice);
|
assert.isTrue(this.xEvent.pub.calledTwice);
|
||||||
@@ -210,15 +178,12 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('.changeItems()', function () {
|
describe('.changeItems()', function () {
|
||||||
|
|
||||||
it('is function', function () {
|
it('is function', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isTrue(_.isFunction(instance.changeItems));
|
assert.isTrue(_.isFunction(instance.changeItems));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('publishes view.changed', function () {
|
it('publishes view.changed', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
instance.setItems();
|
instance.setItems();
|
||||||
assert.isTrue(this.xEvent.pub.calledTwice);
|
assert.isTrue(this.xEvent.pub.calledTwice);
|
||||||
@@ -227,15 +192,12 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('.setLocation()', function () {
|
describe('.setLocation()', function () {
|
||||||
|
|
||||||
it('is function', function () {
|
it('is function', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isTrue(_.isFunction(instance.setLocation));
|
assert.isTrue(_.isFunction(instance.setLocation));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('publishes view.changed', function () {
|
it('publishes view.changed', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
instance.setItems();
|
instance.setItems();
|
||||||
assert.isTrue(this.xEvent.pub.calledTwice);
|
assert.isTrue(this.xEvent.pub.calledTwice);
|
||||||
@@ -244,15 +206,12 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('.setHint()', function () {
|
describe('.setHint()', function () {
|
||||||
|
|
||||||
it('is function', function () {
|
it('is function', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isTrue(_.isFunction(instance.setHint));
|
assert.isTrue(_.isFunction(instance.setHint));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('sets correct class to #view-hint', function () {
|
it('sets correct class to #view-hint', function () {
|
||||||
|
|
||||||
var key = uniq.id();
|
var key = uniq.id();
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
instance.setHint(key);
|
instance.setHint(key);
|
||||||
@@ -260,7 +219,6 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('removes all other classes from #view-hint', function () {
|
it('removes all other classes from #view-hint', function () {
|
||||||
|
|
||||||
var key = uniq.id();
|
var key = uniq.id();
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
$('#view-hint').addClass('a');
|
$('#view-hint').addClass('a');
|
||||||
@@ -270,33 +228,26 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('.getModes()', function () {
|
describe('.getModes()', function () {
|
||||||
|
|
||||||
it('is function', function () {
|
it('is function', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isTrue(_.isFunction(instance.getModes));
|
assert.isTrue(_.isFunction(instance.getModes));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('.getMode()', function () {
|
describe('.getMode()', function () {
|
||||||
|
|
||||||
it('is function', function () {
|
it('is function', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isTrue(_.isFunction(instance.getMode));
|
assert.isTrue(_.isFunction(instance.getMode));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('.setMode()', function () {
|
describe('.setMode()', function () {
|
||||||
|
|
||||||
it('is function', function () {
|
it('is function', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isTrue(_.isFunction(instance.setMode));
|
assert.isTrue(_.isFunction(instance.setMode));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('.setMode(\'details\') changes #view class to .view-details', function () {
|
it('.setMode(\'details\') changes #view class to .view-details', function () {
|
||||||
|
|
||||||
this.xSettings.view.modes = ['details', 'grid', 'icons'];
|
this.xSettings.view.modes = ['details', 'grid', 'icons'];
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
instance.setMode('details');
|
instance.setMode('details');
|
||||||
@@ -306,7 +257,6 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('.setMode(\'grid\') changes #view class to .view-grid', function () {
|
it('.setMode(\'grid\') changes #view class to .view-grid', function () {
|
||||||
|
|
||||||
this.xSettings.view.modes = ['details', 'grid', 'icons'];
|
this.xSettings.view.modes = ['details', 'grid', 'icons'];
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
instance.setMode('grid');
|
instance.setMode('grid');
|
||||||
@@ -316,7 +266,6 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('.setMode(\'icons\') changes #view class to .view-icons', function () {
|
it('.setMode(\'icons\') changes #view class to .view-icons', function () {
|
||||||
|
|
||||||
this.xSettings.view.modes = ['details', 'grid', 'icons'];
|
this.xSettings.view.modes = ['details', 'grid', 'icons'];
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
instance.setMode('icons');
|
instance.setMode('icons');
|
||||||
@@ -327,22 +276,18 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('.getSizes()', function () {
|
describe('.getSizes()', function () {
|
||||||
|
|
||||||
it('is function', function () {
|
it('is function', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isTrue(_.isFunction(instance.getSizes));
|
assert.isTrue(_.isFunction(instance.getSizes));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns sorted sizes', function () {
|
it('returns sorted sizes', function () {
|
||||||
|
|
||||||
this.xSettings.view.sizes = [20, 60, 40];
|
this.xSettings.view.sizes = [20, 60, 40];
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.deepEqual(instance.getSizes(), [20, 40, 60]);
|
assert.deepEqual(instance.getSizes(), [20, 40, 60]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns sorted sizes', function () {
|
it('returns sorted sizes', function () {
|
||||||
|
|
||||||
this.xSettings.view.sizes = [60, 40, 20];
|
this.xSettings.view.sizes = [60, 40, 20];
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.deepEqual(instance.getSizes(), [20, 40, 60]);
|
assert.deepEqual(instance.getSizes(), [20, 40, 60]);
|
||||||
@@ -350,24 +295,19 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('.getSize()', function () {
|
describe('.getSize()', function () {
|
||||||
|
|
||||||
it('is function', function () {
|
it('is function', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isTrue(_.isFunction(instance.getSize));
|
assert.isTrue(_.isFunction(instance.getSize));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('.setSize()', function () {
|
describe('.setSize()', function () {
|
||||||
|
|
||||||
it('is function', function () {
|
it('is function', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isTrue(_.isFunction(instance.setSize));
|
assert.isTrue(_.isFunction(instance.setSize));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('.setSize(20) changes #view class to .view-size-20', function () {
|
it('.setSize(20) changes #view class to .view-size-20', function () {
|
||||||
|
|
||||||
this.xSettings.view.sizes = [20, 40, 60];
|
this.xSettings.view.sizes = [20, 40, 60];
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
instance.setSize(20);
|
instance.setSize(20);
|
||||||
@@ -377,7 +317,6 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('.setSize(40) changes #view class to .view-size-40', function () {
|
it('.setSize(40) changes #view class to .view-size-40', function () {
|
||||||
|
|
||||||
this.xSettings.view.sizes = [20, 40, 60];
|
this.xSettings.view.sizes = [20, 40, 60];
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
instance.setSize(20);
|
instance.setSize(20);
|
||||||
@@ -388,7 +327,6 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('.setSize(60) changes #view class to .view-size-60', function () {
|
it('.setSize(60) changes #view class to .view-size-60', function () {
|
||||||
|
|
||||||
this.xSettings.view.sizes = [20, 40, 60];
|
this.xSettings.view.sizes = [20, 40, 60];
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
instance.setSize(20);
|
instance.setSize(20);
|
||||||
@@ -400,11 +338,8 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// describe('._.createHtml()', function () {
|
// describe('._.createHtml()', function () {
|
||||||
|
|
||||||
// before(function () {
|
// before(function () {
|
||||||
|
|
||||||
// this.createItem = function () {
|
// this.createItem = function () {
|
||||||
|
|
||||||
// return {
|
// return {
|
||||||
// isFolder: sinon.stub().returns(false),
|
// isFolder: sinon.stub().returns(false),
|
||||||
// label: uniq.id(),
|
// label: uniq.id(),
|
||||||
@@ -419,13 +354,11 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
// });
|
// });
|
||||||
|
|
||||||
// it('is function', function () {
|
// it('is function', function () {
|
||||||
|
|
||||||
// var instance = this.applyFn();
|
// var instance = this.applyFn();
|
||||||
// assert.isFunction(instance._.createHtml);
|
// assert.isFunction(instance._.createHtml);
|
||||||
// });
|
// });
|
||||||
|
|
||||||
// it('returns jQuery instance of single HTML element', function () {
|
// it('returns jQuery instance of single HTML element', function () {
|
||||||
|
|
||||||
// var item = this.createItem();
|
// var item = this.createItem();
|
||||||
// var instance = this.applyFn();
|
// var instance = this.applyFn();
|
||||||
// var $item = instance._.createHtml(item);
|
// var $item = instance._.createHtml(item);
|
||||||
@@ -435,7 +368,6 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
// });
|
// });
|
||||||
|
|
||||||
// it('$item.data(\'item\') is back reference to item', function () {
|
// it('$item.data(\'item\') is back reference to item', function () {
|
||||||
|
|
||||||
// var item = this.createItem();
|
// var item = this.createItem();
|
||||||
// var instance = this.applyFn();
|
// var instance = this.applyFn();
|
||||||
// var $item = instance._.createHtml(item);
|
// var $item = instance._.createHtml(item);
|
||||||
@@ -443,13 +375,11 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
// });
|
// });
|
||||||
|
|
||||||
// it('sets item.$view as reference to $item', function () {
|
// it('sets item.$view as reference to $item', function () {
|
||||||
|
|
||||||
// var item = this.createItem();
|
// var item = this.createItem();
|
||||||
// var instance = this.applyFn();
|
// var instance = this.applyFn();
|
||||||
// var $item = instance._.createHtml(item);
|
// var $item = instance._.createHtml(item);
|
||||||
// assert.strictEqual(item.$view, $item);
|
// assert.strictEqual(item.$view, $item);
|
||||||
// });
|
// });
|
||||||
// });
|
// });
|
||||||
});
|
});
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
@@ -1,13 +1,9 @@
|
|||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
var ID = 'view/viewmode';
|
||||||
|
var DEPS = ['_', '$', 'core/event', 'core/resource', 'core/settings', 'view/sidebar', 'view/topbar', 'view/view'];
|
||||||
var ID = 'view/viewmode';
|
|
||||||
var DEPS = ['_', '$', 'core/event', 'core/resource', 'core/settings', 'view/sidebar', 'view/topbar', 'view/view'];
|
|
||||||
|
|
||||||
describe('module \'' + ID + '\'', function () {
|
|
||||||
|
|
||||||
|
describe('module \'' + ID + '\'', function () {
|
||||||
before(function () {
|
before(function () {
|
||||||
|
|
||||||
this.definition = modulejs._private.definitions[ID];
|
this.definition = modulejs._private.definitions[ID];
|
||||||
|
|
||||||
this.xEvent = {
|
this.xEvent = {
|
||||||
@@ -33,7 +29,6 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
};
|
};
|
||||||
|
|
||||||
this.applyFn = function () {
|
this.applyFn = function () {
|
||||||
|
|
||||||
this.xEvent.sub.reset();
|
this.xEvent.sub.reset();
|
||||||
this.xEvent.pub.reset();
|
this.xEvent.pub.reset();
|
||||||
this.xResource.image.reset();
|
this.xResource.image.reset();
|
||||||
@@ -49,12 +44,10 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
after(function () {
|
after(function () {
|
||||||
|
|
||||||
util.restoreHtml();
|
util.restoreHtml();
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
|
|
||||||
util.restoreHtml();
|
util.restoreHtml();
|
||||||
this.xSidebar.$el = $('<div id="sidebar"/>').appendTo('body');
|
this.xSidebar.$el = $('<div id="sidebar"/>').appendTo('body');
|
||||||
this.xTopbar.$el = $('<div id="topbar"/>').appendTo('body');
|
this.xTopbar.$el = $('<div id="topbar"/>').appendTo('body');
|
||||||
@@ -62,78 +55,63 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('definition', function () {
|
describe('definition', function () {
|
||||||
|
|
||||||
it('is defined', function () {
|
it('is defined', function () {
|
||||||
|
|
||||||
assert.isPlainObject(this.definition);
|
assert.isPlainObject(this.definition);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has correct id', function () {
|
it('has correct id', function () {
|
||||||
|
|
||||||
assert.strictEqual(this.definition.id, ID);
|
assert.strictEqual(this.definition.id, ID);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('requires correct', function () {
|
it('requires correct', function () {
|
||||||
|
|
||||||
assert.deepEqual(this.definition.deps, DEPS);
|
assert.deepEqual(this.definition.deps, DEPS);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('args for each request', function () {
|
it('args for each request', function () {
|
||||||
|
|
||||||
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has no instance', function () {
|
it('has no instance', function () {
|
||||||
|
|
||||||
assert.notProperty(modulejs._private.instances, ID);
|
assert.notProperty(modulejs._private.instances, ID);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('inits without errors', function () {
|
it('inits without errors', function () {
|
||||||
|
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('application', function () {
|
describe('application', function () {
|
||||||
|
|
||||||
it('returns undefined', function () {
|
it('returns undefined', function () {
|
||||||
|
|
||||||
var instance = this.applyFn();
|
var instance = this.applyFn();
|
||||||
assert.isUndefined(instance);
|
assert.isUndefined(instance);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('adds HTML #viewmode-settings to #sidebar', function () {
|
it('adds HTML #viewmode-settings to #sidebar', function () {
|
||||||
|
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
assert.lengthOf($('#sidebar > #viewmode-settings'), 1);
|
assert.lengthOf($('#sidebar > #viewmode-settings'), 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('adds HTML #viewmode-details to #viewmode-settings', function () {
|
it('adds HTML #viewmode-details to #viewmode-settings', function () {
|
||||||
|
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
assert.lengthOf($('#viewmode-settings > #viewmode-details'), 1);
|
assert.lengthOf($('#viewmode-settings > #viewmode-details'), 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('adds HTML #viewmode-grid to #viewmode-settings', function () {
|
it('adds HTML #viewmode-grid to #viewmode-settings', function () {
|
||||||
|
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
assert.lengthOf($('#viewmode-settings > #viewmode-grid'), 1);
|
assert.lengthOf($('#viewmode-settings > #viewmode-grid'), 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('adds HTML #viewmode-icons to #viewmode-settings', function () {
|
it('adds HTML #viewmode-icons to #viewmode-settings', function () {
|
||||||
|
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
assert.lengthOf($('#viewmode-settings > #viewmode-icons'), 1);
|
assert.lengthOf($('#viewmode-settings > #viewmode-icons'), 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('adds HTML #viewmode-size to #viewmode-settings', function () {
|
it('adds HTML #viewmode-size to #viewmode-settings', function () {
|
||||||
|
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
assert.lengthOf($('#viewmode-settings > #viewmode-size'), 1);
|
assert.lengthOf($('#viewmode-settings > #viewmode-size'), 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not add HTML #viewmode-details, #viewmode-grid, #viewmode-icons when only one mode', function () {
|
it('does not add HTML #viewmode-details, #viewmode-grid, #viewmode-icons when only one mode', function () {
|
||||||
|
|
||||||
this.xView.getModes.returns(['details']);
|
this.xView.getModes.returns(['details']);
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
assert.lengthOf($('#viewmode-details'), 0);
|
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 () {
|
it('does not add HTML #viewmode-size when only one size', function () {
|
||||||
|
|
||||||
this.xView.getSizes.returns([20]);
|
this.xView.getSizes.returns([20]);
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
assert.lengthOf($('#viewmode-size'), 0);
|
assert.lengthOf($('#viewmode-size'), 0);
|
||||||
@@ -150,9 +127,7 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('works', function () {
|
describe('works', function () {
|
||||||
|
|
||||||
it('clicking #viewmode-details triggers view.setMode(\'details\')', function () {
|
it('clicking #viewmode-details triggers view.setMode(\'details\')', function () {
|
||||||
|
|
||||||
this.xView.getModes.returns(['details', 'grid', 'icons']);
|
this.xView.getModes.returns(['details', 'grid', 'icons']);
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
$('#viewmode-details').trigger('click');
|
$('#viewmode-details').trigger('click');
|
||||||
@@ -161,7 +136,6 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('clicking #viewmode-grid triggers view.setMode(\'grid\')', function () {
|
it('clicking #viewmode-grid triggers view.setMode(\'grid\')', function () {
|
||||||
|
|
||||||
this.xView.getModes.returns(['details', 'grid', 'icons']);
|
this.xView.getModes.returns(['details', 'grid', 'icons']);
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
$('#viewmode-grid').trigger('click');
|
$('#viewmode-grid').trigger('click');
|
||||||
@@ -170,7 +144,6 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('clicking #viewmode-icons triggers view.setMode(\'icons\')', function () {
|
it('clicking #viewmode-icons triggers view.setMode(\'icons\')', function () {
|
||||||
|
|
||||||
this.xView.getModes.returns(['details', 'grid', 'icons']);
|
this.xView.getModes.returns(['details', 'grid', 'icons']);
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
$('#viewmode-icons').trigger('click');
|
$('#viewmode-icons').trigger('click');
|
||||||
@@ -179,7 +152,6 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('changing #viewmode-size triggers view.setSize(*)', function () {
|
it('changing #viewmode-size triggers view.setSize(*)', function () {
|
||||||
|
|
||||||
this.xView.getSizes.returns([20, 40, 60]);
|
this.xView.getSizes.returns([20, 40, 60]);
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
|
|
||||||
@@ -197,7 +169,6 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('inputing #viewmode-size triggers view.setSize(*)', function () {
|
it('inputing #viewmode-size triggers view.setSize(*)', function () {
|
||||||
|
|
||||||
this.xView.getSizes.returns([20, 40, 60]);
|
this.xView.getSizes.returns([20, 40, 60]);
|
||||||
this.applyFn();
|
this.applyFn();
|
||||||
|
|
||||||
@@ -214,6 +185,5 @@ describe('module \'' + ID + '\'', function () {
|
|||||||
assert.deepEqual(this.xView.setSize.lastCall.args, [60]);
|
assert.deepEqual(this.xView.setSize.lastCall.args, [60]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
@@ -1,17 +1,12 @@
|
|||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
var assert = window.chai.assert;
|
||||||
|
|
||||||
var assert = chai.assert;
|
|
||||||
|
|
||||||
assert.lengthOfKeys = function (val, count, msg) {
|
|
||||||
|
|
||||||
|
assert.lengthOfKeys = function (val, count, msg) {
|
||||||
var keyCount = _.keys(val).length;
|
var keyCount = _.keys(val).length;
|
||||||
assert(keyCount === count, msg ? msg : 'expected ' + val + ' to have ' + count + ' keys, but has ' + keyCount);
|
assert(keyCount === count, msg ? msg : 'expected ' + val + ' to have ' + count + ' keys, but has ' + keyCount);
|
||||||
};
|
};
|
||||||
|
|
||||||
assert.isPlainObject = function (val, msg) {
|
|
||||||
|
|
||||||
|
assert.isPlainObject = function (val, msg) {
|
||||||
assert($.isPlainObject(val), msg ? msg : 'expected ' + val + ' to be a plain Object');
|
assert($.isPlainObject(val), msg ? msg : 'expected ' + val + ' to be a plain Object');
|
||||||
};
|
};
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
@@ -1,19 +1,16 @@
|
|||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
var showOnlyFailures = false;
|
||||||
|
var template =
|
||||||
var showOnlyFailures = false;
|
|
||||||
var template =
|
|
||||||
'<div id="mocha-bar">' +
|
'<div id="mocha-bar">' +
|
||||||
'<a class="title" href="?">' + document.title + '</a>' +
|
'<a class="title" href="?">' + document.title + '</a>' +
|
||||||
'<div class="stats"/>' +
|
'<div class="stats"/>' +
|
||||||
'<div class="progress"/>' +
|
'<div class="progress"/>' +
|
||||||
'</div>';
|
'</div>';
|
||||||
var $mochaBar = $(template);
|
var $mochaBar = $(template);
|
||||||
var $mochaStats = $mochaBar.find('.stats');
|
var $mochaStats = $mochaBar.find('.stats');
|
||||||
var $mochaProgress = $mochaBar.find('.progress');
|
var $mochaProgress = $mochaBar.find('.progress');
|
||||||
|
|
||||||
|
function toggleFailureFilter(ev) {
|
||||||
function toggleFailureFilter(ev) {
|
|
||||||
ev.stopImmediatePropagation();
|
ev.stopImmediatePropagation();
|
||||||
|
|
||||||
showOnlyFailures = !showOnlyFailures;
|
showOnlyFailures = !showOnlyFailures;
|
||||||
@@ -23,9 +20,9 @@ function toggleFailureFilter(ev) {
|
|||||||
} else {
|
} else {
|
||||||
$('.suite, .test').show();
|
$('.suite, .test').show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function addSuiteStats() {
|
function addSuiteStats() {
|
||||||
var $suite = $(this);
|
var $suite = $(this);
|
||||||
|
|
||||||
var tests = $suite.find('.test').length;
|
var tests = $suite.find('.test').length;
|
||||||
@@ -39,7 +36,6 @@ function addSuiteStats() {
|
|||||||
var visible = true;
|
var visible = true;
|
||||||
|
|
||||||
$toggle.on('click', function (ev) {
|
$toggle.on('click', function (ev) {
|
||||||
|
|
||||||
ev.stopImmediatePropagation();
|
ev.stopImmediatePropagation();
|
||||||
|
|
||||||
visible = !visible;
|
visible = !visible;
|
||||||
@@ -59,15 +55,15 @@ function addSuiteStats() {
|
|||||||
$suite.addClass(tests === passed ? 'pass' : 'fail');
|
$suite.addClass(tests === passed ? 'pass' : 'fail');
|
||||||
// $suite.append($toggle);
|
// $suite.append($toggle);
|
||||||
$header.append($count);
|
$header.append($count);
|
||||||
}
|
}
|
||||||
|
|
||||||
function fixCodeFormatting() {
|
function fixCodeFormatting() {
|
||||||
var $code = $(this);
|
var $code = $(this);
|
||||||
$code.text($code.text().trim().replace(/;\n\s*/g, ';\n'));
|
$code.text($code.text().trim().replace(/;\n\s*/g, ';\n'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function onEnd() {
|
function onEnd() {
|
||||||
var runner = this;
|
var runner = this;
|
||||||
var failed = runner.stats.failures > 0;
|
var failed = runner.stats.failures > 0;
|
||||||
var stats = (runner.stats.duration / 1000.0).toFixed(3) + 's';
|
var stats = (runner.stats.duration / 1000.0).toFixed(3) + 's';
|
||||||
@@ -81,9 +77,9 @@ function onEnd() {
|
|||||||
$mochaStats.text(stats);
|
$mochaStats.text(stats);
|
||||||
$('#mocha-report .suite').each(addSuiteStats);
|
$('#mocha-report .suite').each(addSuiteStats);
|
||||||
$('#mocha-report code').each(fixCodeFormatting);
|
$('#mocha-report code').each(fixCodeFormatting);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onTest() {
|
function onTest() {
|
||||||
var runner = this;
|
var runner = this;
|
||||||
var percent = 100.0 * runner.stats.tests / runner.total;
|
var percent = 100.0 * runner.stats.tests / runner.total;
|
||||||
var stats = ((new Date().getTime() - runner.stats.start) / 1000.0).toFixed(3) + 's';
|
var stats = ((new Date().getTime() - runner.stats.start) / 1000.0).toFixed(3) + 's';
|
||||||
@@ -91,22 +87,21 @@ function onTest() {
|
|||||||
if (runner.stats.failures) {
|
if (runner.stats.failures) {
|
||||||
$mochaBar.addClass('fail');
|
$mochaBar.addClass('fail');
|
||||||
}
|
}
|
||||||
$mochaProgress.css('width', (100 - percent) + '%');
|
$mochaProgress.css('width', 100 - percent + '%');
|
||||||
$mochaStats.text(stats);
|
$mochaStats.text(stats);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setupMocha() {
|
function setupMocha() {
|
||||||
window.assert = chai.assert;
|
window.assert = window.chai.assert;
|
||||||
mocha.setup('bdd');
|
mocha.setup('bdd');
|
||||||
$(function () { $mochaBar.appendTo('#mocha'); });
|
$(function () { $mochaBar.appendTo('#mocha'); });
|
||||||
}
|
}
|
||||||
|
|
||||||
function runMocha() {
|
function runMocha() {
|
||||||
mocha.run().on('test', onTest).on('end', onEnd);
|
mocha.run().on('test', onTest).on('end', onEnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
window.util = window.util || {};
|
|
||||||
window.util.setupMocha = setupMocha;
|
|
||||||
window.util.runMocha = runMocha;
|
|
||||||
|
|
||||||
|
window.util = window.util || {};
|
||||||
|
window.util.setupMocha = setupMocha;
|
||||||
|
window.util.runMocha = runMocha;
|
||||||
}());
|
}());
|
||||||
|
@@ -1,21 +1,15 @@
|
|||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
function clearModulejs() {
|
||||||
|
|
||||||
function clearModulejs() {
|
|
||||||
|
|
||||||
_.each(modulejs._private.instances, function (val, key) {
|
_.each(modulejs._private.instances, function (val, key) {
|
||||||
|
|
||||||
delete modulejs._private.instances[key];
|
delete modulejs._private.instances[key];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function mockConfigModule() {
|
|
||||||
|
|
||||||
|
function mockConfigModule() {
|
||||||
modulejs.define('config', window.uniq.obj());
|
modulejs.define('config', window.uniq.obj());
|
||||||
}
|
}
|
||||||
|
|
||||||
window.util = window.util || {};
|
|
||||||
window.util.clearModulejs = clearModulejs;
|
|
||||||
window.util.mockConfigModule = mockConfigModule;
|
|
||||||
|
|
||||||
|
window.util = window.util || {};
|
||||||
|
window.util.clearModulejs = clearModulejs;
|
||||||
|
window.util.mockConfigModule = mockConfigModule;
|
||||||
}());
|
}());
|
||||||
|
@@ -1,25 +1,21 @@
|
|||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
var title;
|
||||||
|
var htmlId;
|
||||||
var title;
|
var htmlClasses;
|
||||||
var htmlId;
|
var bodyId;
|
||||||
var htmlClasses;
|
var bodyClasses;
|
||||||
var bodyId;
|
var $pinnedElements;
|
||||||
var bodyClasses;
|
|
||||||
var $pinnedElements;
|
|
||||||
|
|
||||||
function pinHtml() {
|
|
||||||
|
|
||||||
|
function pinHtml() {
|
||||||
title = document.title;
|
title = document.title;
|
||||||
htmlId = $('html').attr('id');
|
htmlId = $('html').attr('id');
|
||||||
htmlClasses = $('html').attr('class');
|
htmlClasses = $('html').attr('class');
|
||||||
bodyId = $('body').attr('id');
|
bodyId = $('body').attr('id');
|
||||||
bodyClasses = $('body').attr('class');
|
bodyClasses = $('body').attr('class');
|
||||||
$pinnedElements = $('head,body').children();
|
$pinnedElements = $('head,body').children();
|
||||||
}
|
}
|
||||||
|
|
||||||
function restoreHtml() {
|
|
||||||
|
|
||||||
|
function restoreHtml() {
|
||||||
document.title = title;
|
document.title = title;
|
||||||
$('html').attr('id', htmlId);
|
$('html').attr('id', htmlId);
|
||||||
$('html').attr('class', htmlClasses);
|
$('html').attr('class', htmlClasses);
|
||||||
@@ -29,10 +25,9 @@ function restoreHtml() {
|
|||||||
if (window.localStorage && window.localStorage.clear) {
|
if (window.localStorage && window.localStorage.clear) {
|
||||||
window.localStorage.clear();
|
window.localStorage.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
window.util = window.util || {};
|
|
||||||
window.util.pinHtml = pinHtml;
|
|
||||||
window.util.restoreHtml = restoreHtml;
|
|
||||||
|
|
||||||
|
window.util = window.util || {};
|
||||||
|
window.util.pinHtml = pinHtml;
|
||||||
|
window.util.restoreHtml = restoreHtml;
|
||||||
}());
|
}());
|
||||||
|
Reference in New Issue
Block a user