Permalink
Browse files

Cleans and refactors.

  • Loading branch information...
1 parent aa725f1 commit 24b4f4ce8a2a6a3254764021432fd7362cd1e24c @lrsjng committed Aug 28, 2013
View
2 src/_h5ai/client/js/inc/ext/l10n.js
@@ -34,7 +34,7 @@ modulejs.define('ext/l10n', ['_', '$', 'core/settings', 'core/langs', 'core/form
'</span>',
langOptionTemplate = '<li class="langOption"/>',
- storekey = 'l10n.lang',
+ storekey = 'ext/l10n',
loaded = {
en: _.extend({}, defaultTranslations)
View
2 src/_h5ai/client/js/inc/ext/preview.js
@@ -23,7 +23,7 @@ modulejs.define('ext/preview', ['_', '$', 'core/settings', 'core/resource', 'cor
'</div>' +
'</div>',
- storekey = 'preview.isFullscreen',
+ storekey = 'ext/preview',
currentEntries = [],
currentIdx = 0,
View
2 src/_h5ai/client/js/inc/ext/sort.js
@@ -9,7 +9,7 @@ modulejs.define('ext/sort', ['_', '$', 'core/settings', 'core/resource', 'core/e
natural: false
}, allsettings.sort),
- storekey = 'sort.order',
+ storekey = 'ext/sort',
template = '<img src="' + resource.image('ascending') + '" class="sort ascending" alt="ascending" />' +
'<img src="' + resource.image('descending') + '" class="sort descending" alt="descending" />',
View
57 src/_h5ai/client/js/inc/view/viewmode.js
@@ -25,25 +25,6 @@ modulejs.define('view/viewmode', ['_', '$', 'core/settings', 'core/resource', 'c
'</a>' +
'</li>',
- // sizeSelectorTemplate = '<li id="sizeSelector" class="view">' +
- // '<span class="element">' +
- // '<img src="' + resource.image('size') + '" alt="size"/>' +
- // '<span class="size-current">small</span>' +
- // '</span>' +
- // '<span class="sizeOptions hidden"><ul/></span>' +
- // '</li>',
- // sizeOptionTemplate = '<li class="sizeOption"/>',
-
- // viewSelectorTemplate = '<li id="viewSelector" class="view">' +
- // '<span class="element">' +
- // '<img src="' + resource.image('view-details') + '" alt="view-details"/>' +
- // '<span class="view-current">details</span>' +
- // '</span>' +
- // '<span class="viewOptions hidden"><ul/></span>' +
- // '</li>',
- // viewOptionTemplate = '<li class="viewOption"/>',
-
-
adjustSpacing = function () {
var contentWidth = $('#content').width(),
@@ -53,12 +34,16 @@ modulejs.define('view/viewmode', ['_', '$', 'core/settings', 'core/resource', 'c
$view.width(Math.floor(contentWidth / itemWidth) * itemWidth);
},
- updateMode = function (mode) {
+ update = function (mode, size) {
- var $view = $('#view');
+ var $view = $('#view'),
+ stored = store.get(storekey);
+ mode = mode || stored && stored.mode;
+ size = size || stored && stored.size;
mode = _.contains(settings.modes, mode) ? mode : settings.modes[0];
- store.put(storekey, mode);
+ size = _.contains(settings.sizes, size) ? size : settings.sizes[0];
+ store.put(storekey, {mode: mode, size: size});
_.each(modes, function (m) {
if (m === mode) {
@@ -70,16 +55,6 @@ modulejs.define('view/viewmode', ['_', '$', 'core/settings', 'core/resource', 'c
}
});
- adjustSpacing();
- },
-
- updateSize = function (size) {
-
- var $view = $('#view');
-
- size = _.contains(settings.sizes, size) ? size : settings.sizes[0];
- // store.put(storekey, viewmode);
-
_.each(sizes, function (s) {
if (s === size) {
$('#view-' + s).addClass('current');
@@ -99,41 +74,33 @@ modulejs.define('view/viewmode', ['_', '$', 'core/settings', 'core/resource', 'c
settings.modes = _.intersection(settings.modes, modes);
- if (settings.modes.length) {
+ if (settings.modes.length > 1) {
_.each(modes.slice(0).reverse(), function (mode) {
if (_.contains(settings.modes, mode)) {
$(template.replace(/\[MODE\]/g, mode))
.appendTo($navbar)
.on('click', 'a', function (event) {
- updateMode(mode);
+ update(mode);
event.preventDefault();
});
}
});
}
-
- if (settings.sizes.length) {
+ if (settings.sizes.length > 1) {
_.each(sizes.slice(0).reverse(), function (size) {
if (_.contains(settings.sizes, size)) {
$(sizeTemplate.replace(/\[SIZE\]/g, size))
.appendTo($navbar)
.on('click', 'a', function (event) {
- updateSize(size);
+ update(null, size);
event.preventDefault();
});
}
});
}
- // $(sizeSelectorTemplate)
- // .appendTo($navbar);
-
- // $(viewSelectorTemplate)
- // .appendTo($navbar);
-
- updateMode(store.get(storekey));
- updateSize(sizes[0]);
+ update();
event.sub('location.changed', adjustSpacing);
$(window).on('resize', adjustSpacing);
View
11 src/_h5ai/conf/options.json
@@ -23,13 +23,16 @@ Options
/*
General view options.
- - modes: array of "details", "grid" and/or "icons"
+ - modes: array, subset of ["details", "grid", "icons"]
+ the first value indicates the default view mode. If only one value
+ is given the view mode is fixed and the selector buttons are hidden.
+ The user selected view mode is also stored local in modern browsers
+ so that it will be persistent.
+ - sizes: array, subset of [16, 24, 32, 48, 64, 96]
the first value indicates the default view mode. If only one value
is given the view mode is fixed and the selector buttons are hidden.
The user selected view mode is also stored local in modern browsers
so that it will be persistent.
- - sizes: array of numbers
- the numbers seen below are the only accepted values, you may only remove some
- setParentFolderLabels: set parent folder labels to real folder names
- hideParentFolderLinks: hide parent folder links
- binaryPrefix: set to true uses 1024B=1KiB when formatting file sizes (see http://en.wikipedia.org/wiki/Binary_prefix)
@@ -40,7 +43,7 @@ Options
*/
"view": {
"modes": ["details", "grid", "icons"],
- "sizes": [16, 24, 32, 48, 64, 96],
+ "sizes": [48, 24, 96],
"setParentFolderLabels": true,
"hideParentFolderLinks": false,
"binaryPrefix": false,

0 comments on commit 24b4f4c

Please sign in to comment.