add callback to setTheme as well

This commit is contained in:
nightwing 2013-06-20 18:04:36 +04:00
commit 3667a15e8d

View file

@ -1257,10 +1257,10 @@ var VirtualRenderer = function(container, theme) {
/** /**
* [Sets a new theme for the editor. `theme` should exist, and be a directory path, like `ace/theme/textmate`.]{: #VirtualRenderer.setTheme} * [Sets a new theme for the editor. `theme` should exist, and be a directory path, like `ace/theme/textmate`.]{: #VirtualRenderer.setTheme}
* @param {String} theme The path to a theme * @param {String} theme The path to a theme
* * @param {Function} cb optional callback
* *
**/ **/
this.setTheme = function(theme) { this.setTheme = function(theme, cb) {
var _self = this; var _self = this;
this.$themeValue = theme; this.$themeValue = theme;
_self._dispatchEvent('themeChange',{theme:theme}); _self._dispatchEvent('themeChange',{theme:theme});
@ -1274,7 +1274,7 @@ var VirtualRenderer = function(container, theme) {
function afterLoad(module) { function afterLoad(module) {
if (_self.$themeValue != theme) if (_self.$themeValue != theme)
return; return cb && cb();
if (!module.cssClass) if (!module.cssClass)
return; return;
dom.importCssString( dom.importCssString(
@ -1304,6 +1304,7 @@ var VirtualRenderer = function(container, theme) {
} }
_self._dispatchEvent('themeLoaded', {theme:module}); _self._dispatchEvent('themeLoaded', {theme:module});
cb && cb();
} }
}; };