\r
// Entry point to start the kiwi application\r
init: function (opts, callback) {\r
- var continueStart, locale, jobs, igniteTextTheme, text_theme;\r
+ var jobs, locale, localeLoaded, textThemeLoaded, text_theme;\r
opts = opts || {};\r
\r
jobs = new JobManager();\r
- jobs.onFinish(callback);\r
-\r
- continueInit = function (locale, s, xhr) {\r
- if (locale) {\r
- _kiwi.global.i18n = new Jed(locale);\r
- } else {\r
- _kiwi.global.i18n = new Jed();\r
- }\r
-\r
+ jobs.onFinish(function(locale, s, xhr) {\r
_kiwi.app = new _kiwi.model.Application(opts);\r
\r
// Start the client up\r
// Now everything has started up, load the plugin manager for third party plugins\r
_kiwi.global.plugins = new _kiwi.model.PluginManager();\r
\r
- jobs.finishJob('load_locale');\r
- };\r
+ callback();\r
+ });\r
\r
- igniteTextTheme = function(text_theme, s, xhr) {\r
- _kiwi.global.text_theme = new _kiwi.view.TextTheme(text_theme);\r
+ textThemeLoaded = function(text_theme, s, xhr) {\r
+ opts.text_theme = text_theme;\r
\r
jobs.finishJob('load_text_theme');\r
};\r
\r
+ localeLoaded = function(locale, s, xhr) {\r
+ if (locale) {\r
+ _kiwi.global.i18n = new Jed(locale);\r
+ } else {\r
+ _kiwi.global.i18n = new Jed();\r
+ }\r
+\r
+ jobs.finishJob('load_locale');\r
+ };\r
+\r
// Set up the settings datastore\r
_kiwi.global.settings = _kiwi.model.DataStore.instance('kiwi.settings');\r
_kiwi.global.settings.load();\r
jobs.registerJob('load_locale');\r
locale = _kiwi.global.settings.get('locale');\r
if (!locale) {\r
- $.getJSON(opts.base_path + '/assets/locales/magic.json', continueInit);\r
+ $.getJSON(opts.base_path + '/assets/locales/magic.json', localeLoaded);\r
} else {\r
- $.getJSON(opts.base_path + '/assets/locales/' + locale + '.json', continueInit);\r
+ $.getJSON(opts.base_path + '/assets/locales/' + locale + '.json', localeLoaded);\r
}\r
\r
jobs.registerJob('load_text_theme');\r
text_theme = opts.text_theme;\r
if (!text_theme) {\r
- $.getJSON(opts.base_path + '/assets/text_themes/default.json', igniteTextTheme);\r
+ $.getJSON(opts.base_path + '/assets/text_themes/default.json', textThemeLoaded);\r
} else {\r
- $.getJSON(opts.base_path + '/assets/text_themes/' + text_theme + '.json', igniteTextTheme);\r
+ $.getJSON(opts.base_path + '/assets/text_themes/' + text_theme + '.json', textThemeLoaded);\r
}\r
},\r
\r