From f6d24d050fa2c9c960677317f6577fe501b8f6ab Mon Sep 17 00:00:00 2001 From: Lars Jung Date: Sat, 14 Jul 2012 16:34:12 +0200 Subject: [PATCH] Splits settings.js. --- src/_h5ai/js/inc/core/langs.js | 33 ++++++++++++ src/_h5ai/js/inc/core/parser.js | 5 ++ src/_h5ai/js/inc/core/settings.js | 83 ------------------------------- src/_h5ai/js/inc/core/types.js | 48 ++++++++++++++++++ src/_h5ai/js/inc/h5ai-main.js | 2 +- src/_h5ai/js/inc/main.js | 2 + 6 files changed, 89 insertions(+), 84 deletions(-) create mode 100644 src/_h5ai/js/inc/core/langs.js create mode 100644 src/_h5ai/js/inc/core/types.js diff --git a/src/_h5ai/js/inc/core/langs.js b/src/_h5ai/js/inc/core/langs.js new file mode 100644 index 00000000..21fc57fb --- /dev/null +++ b/src/_h5ai/js/inc/core/langs.js @@ -0,0 +1,33 @@ + +modulejs.define('core/langs', ['config', '_'], function (config, _) { + + var defaults = { + lang: 'unknown', + details: 'details', + icons: 'icons', + name: 'Name', + lastModified: 'Last modified', + size: 'Size', + parentDirectory: 'Parent Directory', + empty: 'empty', + folders: 'folders', + files: 'files', + download: 'download', + noMatch: 'no match', + dateFormat: 'YYYY-MM-DD HH:mm' + }, + + translations = {}, + + parse = function (langs) { + + _.each(langs, function (trans, lang) { + + translations[lang] = _.extend({}, defaults, trans); + }); + }; + + parse(_.extend({}, config.langs)); + + return translations; +}); diff --git a/src/_h5ai/js/inc/core/parser.js b/src/_h5ai/js/inc/core/parser.js index f840d052..9002ef30 100644 --- a/src/_h5ai/js/inc/core/parser.js +++ b/src/_h5ai/js/inc/core/parser.js @@ -10,6 +10,11 @@ modulejs.define('core/parser', ['$'], function ($) { return { id: 'none', + mode: null, + server: { + name: null, + version: null + }, parse: function () { return []; } diff --git a/src/_h5ai/js/inc/core/settings.js b/src/_h5ai/js/inc/core/settings.js index 25fb084e..5111291e 100644 --- a/src/_h5ai/js/inc/core/settings.js +++ b/src/_h5ai/js/inc/core/settings.js @@ -10,86 +10,3 @@ modulejs.define('core/settings', ['config', '_'], function (config, _) { return _.extend({}, defaults, config.options); }); - - -modulejs.define('core/types', ['config', '_'], function (config, _) { - - var reEndsWithSlash = /\/$/, - reStartsWithDot = /^\./, - - fileExts = {}, - fileNames = {}, - - parse = function (types) { - - _.each(types, function (matches, type) { - - _.each(matches, function (match) { - - match = match.toLowerCase(); - - if (reStartsWithDot.test(match)) { - fileExts[match] = type; - } else { - fileNames[match] = type; - } - }); - }); - }, - - getType = function (sequence) { - - if (reEndsWithSlash.test(sequence)) { - return 'folder'; - } - - sequence = sequence.toLowerCase(); - - var slashidx = sequence.lastIndexOf('/'), - name = slashidx >= 0 ? sequence.substr(slashidx + 1) : sequence, - dotidx = sequence.lastIndexOf('.'), - ext = dotidx >= 0 ? sequence.substr(dotidx) : sequence; - - return fileNames[name] || fileExts[ext] || 'unknown'; - }; - - parse(_.extend({}, config.types)); - - return { - getType: getType - }; -}); - - -modulejs.define('core/langs', ['config', '_'], function (config, _) { - - var defaults = { - lang: 'unknown', - details: 'details', - icons: 'icons', - name: 'Name', - lastModified: 'Last modified', - size: 'Size', - parentDirectory: 'Parent Directory', - empty: 'empty', - folders: 'folders', - files: 'files', - download: 'download', - noMatch: 'no match', - dateFormat: 'YYYY-MM-DD HH:mm' - }, - - translations = {}, - - parse = function (langs) { - - _.each(langs, function (trans, lang) { - - translations[lang] = _.extend({}, defaults, trans); - }); - }; - - parse(_.extend({}, config.langs)); - - return translations; -}); diff --git a/src/_h5ai/js/inc/core/types.js b/src/_h5ai/js/inc/core/types.js new file mode 100644 index 00000000..f02f9dae --- /dev/null +++ b/src/_h5ai/js/inc/core/types.js @@ -0,0 +1,48 @@ + +modulejs.define('core/types', ['config', '_'], function (config, _) { + + var reEndsWithSlash = /\/$/, + reStartsWithDot = /^\./, + + fileExts = {}, + fileNames = {}, + + parse = function (types) { + + _.each(types, function (matches, type) { + + _.each(matches, function (match) { + + match = match.toLowerCase(); + + if (reStartsWithDot.test(match)) { + fileExts[match] = type; + } else { + fileNames[match] = type; + } + }); + }); + }, + + getType = function (sequence) { + + if (reEndsWithSlash.test(sequence)) { + return 'folder'; + } + + sequence = sequence.toLowerCase(); + + var slashidx = sequence.lastIndexOf('/'), + name = slashidx >= 0 ? sequence.substr(slashidx + 1) : sequence, + dotidx = sequence.lastIndexOf('.'), + ext = dotidx >= 0 ? sequence.substr(dotidx) : sequence; + + return fileNames[name] || fileExts[ext] || 'unknown'; + }; + + parse(_.extend({}, config.types)); + + return { + getType: getType + }; +}); diff --git a/src/_h5ai/js/inc/h5ai-main.js b/src/_h5ai/js/inc/h5ai-main.js index cdda40ff..0d6906ce 100644 --- a/src/_h5ai/js/inc/h5ai-main.js +++ b/src/_h5ai/js/inc/h5ai-main.js @@ -4,8 +4,8 @@ modulejs.define('h5ai-main', ['_', 'core/event', 'core/settings'], function (_, event.pub('beforeView'); modulejs.require('view/extended'); - modulejs.require('view/viewmode'); modulejs.require('view/spacing'); + modulejs.require('view/viewmode'); event.pub('beforeExt'); diff --git a/src/_h5ai/js/inc/main.js b/src/_h5ai/js/inc/main.js index 656ce41b..6449574b 100644 --- a/src/_h5ai/js/inc/main.js +++ b/src/_h5ai/js/inc/main.js @@ -7,10 +7,12 @@ // @include "core/entry.js" // @include "core/event.js" // @include "core/format.js" + // @include "core/langs.js" // @include "core/parser.js" // @include "core/resource.js" // @include "core/settings.js" // @include "core/store.js" + // @include "core/types.js" // @include "model/entry.js"