Issue #338 : Cleanup public/private in SettingsController

This commit is contained in:
jdescottes 2015-11-25 00:40:12 +01:00
parent 9329a5fd03
commit 8d26d693ff

View File

@ -43,29 +43,29 @@
* @public * @public
*/ */
ns.SettingsController.prototype.init = function() { ns.SettingsController.prototype.init = function() {
pskl.utils.Event.addEventListener(this.settingsContainer, 'click', this.onSettingContainerClick, this); pskl.utils.Event.addEventListener(this.settingsContainer, 'click', this.onSettingsContainerClick_, this);
pskl.utils.Event.addEventListener(document.body, 'click', this.onBodyClick, this); pskl.utils.Event.addEventListener(document.body, 'click', this.onBodyClick_, this);
$.subscribe(Events.CLOSE_SETTINGS_DRAWER, this.closeDrawer.bind(this)); $.subscribe(Events.CLOSE_SETTINGS_DRAWER, this.closeDrawer_.bind(this));
}; };
ns.SettingsController.prototype.onSettingContainerClick = function (evt) { ns.SettingsController.prototype.onSettingsContainerClick_ = function (evt) {
var setting = pskl.utils.Dom.getData(evt.target, 'setting'); var setting = pskl.utils.Dom.getData(evt.target, 'setting');
if (!setting) { if (!setting) {
return; return;
} }
if (this.currentSetting != setting) { if (this.currentSetting != setting) {
this.loadSetting(setting); this.loadSetting_(setting);
} else { } else {
this.closeDrawer(); this.closeDrawer_();
} }
evt.stopPropagation(); evt.stopPropagation();
evt.preventDefault(); evt.preventDefault();
}; };
ns.SettingsController.prototype.onBodyClick = function (evt) { ns.SettingsController.prototype.onBodyClick_ = function (evt) {
var target = evt.target; var target = evt.target;
var isInDrawerContainer = pskl.utils.Dom.isParent(target, this.drawerContainer); var isInDrawerContainer = pskl.utils.Dom.isParent(target, this.drawerContainer);
@ -73,11 +73,11 @@
var isInSettingsContainer = isInDrawerContainer || isInSettingsIcon; var isInSettingsContainer = isInDrawerContainer || isInSettingsIcon;
if (this.isExpanded && !isInSettingsContainer) { if (this.isExpanded && !isInSettingsContainer) {
this.closeDrawer(); this.closeDrawer_();
} }
}; };
ns.SettingsController.prototype.loadSetting = function (setting) { ns.SettingsController.prototype.loadSetting_ = function (setting) {
this.drawerContainer.innerHTML = pskl.utils.Template.get(settings[setting].template); this.drawerContainer.innerHTML = pskl.utils.Template.get(settings[setting].template);
// when switching settings controller, destroy previously loaded controller // when switching settings controller, destroy previously loaded controller
@ -97,7 +97,7 @@
this.isExpanded = true; this.isExpanded = true;
}; };
ns.SettingsController.prototype.closeDrawer = function () { ns.SettingsController.prototype.closeDrawer_ = function () {
pskl.utils.Dom.removeClass(SEL_SETTING_CLS); pskl.utils.Dom.removeClass(SEL_SETTING_CLS);
this.settingsContainer.classList.remove(EXP_DRAWER_CLS); this.settingsContainer.classList.remove(EXP_DRAWER_CLS);