Refactor core/settings module.

This commit is contained in:
Lars Jung 2014-05-29 18:51:54 +02:00
parent 3d54b886dd
commit 2b26796719
5 changed files with 15 additions and 24 deletions

View file

@ -3,13 +3,13 @@ modulejs.define('core/resource', ['core/settings'], function (settings) {
var image = function (id) {
return settings.h5aiAbsHref + 'client/images/' + id + '.svg';
return settings.appUrl + 'client/images/' + id + '.svg';
},
icon = function (id) {
// return settings.h5aiAbsHref + 'client/themes/faenza/icons/' + id + '.png';
return settings.h5aiAbsHref + 'client/themes/evolvere/icons/' + id + '.svg';
// return settings.appUrl + 'client/themes/faenza/icons/' + id + '.png';
return settings.appUrl + 'client/themes/evolvere/icons/' + id + '.svg';
};
return {

View file

@ -1,17 +1,8 @@
modulejs.define('core/settings', ['config', '_', '$'], function (config, _, $) {
modulejs.define('core/settings', ['config', '_'], function (config, _) {
var filename = 'client/js/scripts.js',
src = $('script[src$="' + filename + '"]').attr('src'),
appHref = src.substr(0, src.length - filename.length),
h5aiAbsHref = src.substr(0, src.length - filename.length).replace(/\/*$/, '/'),
rootAbsHref = /^(.*\/)[^\/]+\/?$/.exec(h5aiAbsHref)[1],
settings = _.extend({}, config.options, {
h5aiAbsHref: h5aiAbsHref,
rootAbsHref: rootAbsHref
});
return settings;
return _.extend({}, config.options, {
appUrl: config.setup.APP_URL,
rootUrl: config.setup.ROOT_URL
});
});

View file

@ -63,11 +63,11 @@ modulejs.define('ext/preview-txt', ['_', '$', 'core/settings', 'core/event', 'ex
},
loadSyntaxhighlighter = function (callback) {
loadScript(allsettings.h5aiAbsHref + 'client/js/syntaxhighlighter.js', 'SyntaxHighlighter', callback);
loadScript(allsettings.appUrl + 'client/js/syntaxhighlighter.js', 'SyntaxHighlighter', callback);
},
loadMarkdown = function (callback) {
loadScript(allsettings.h5aiAbsHref + 'client/js/markdown.js', 'markdown', callback);
loadScript(allsettings.appUrl + 'client/js/markdown.js', 'markdown', callback);
},
preloadText = function (absHref, callback) {

View file

@ -16,7 +16,7 @@ modulejs.define('ext/qrcode', ['_', '$', 'modernizr', 'core/settings', 'core/eve
callback();
} else {
$.ajax({
url: allsettings.h5aiAbsHref + 'client/js/qrcode.js',
url: allsettings.appUrl + 'client/js/qrcode.js',
dataType: 'script',
complete: function () {

View file

@ -30,7 +30,7 @@ modulejs.define('model/item', ['_', 'core/types', 'core/event', 'core/settings',
if (match) {
var split = { parent: match[1], name: match[2] };
if (split.parent && !startsWith(split.parent, settings.rootAbsHref)) {
if (split.parent && !startsWith(split.parent, settings.rootUrl)) {
split.parent = null;
}
return split;
@ -45,7 +45,7 @@ modulejs.define('model/item', ['_', 'core/types', 'core/event', 'core/settings',
absHref = location.forceEncoding(absHref);
if (!startsWith(absHref, settings.rootAbsHref)) {
if (!startsWith(absHref, settings.rootUrl)) {
return null;
}
@ -164,12 +164,12 @@ modulejs.define('model/item', ['_', 'core/types', 'core/event', 'core/settings',
isRoot: function () {
return this.absHref === settings.rootAbsHref;
return this.absHref === settings.rootUrl;
},
isH5ai: function () {
return this.absHref === settings.h5aiAbsHref;
return this.absHref === settings.appUrl;
},
isEmpty: function () {