Adding SettingsController

This commit is contained in:
Vince 2013-06-16 10:17:50 +02:00
parent 19b213129a
commit 955a49d2dd
4 changed files with 40 additions and 25 deletions

View File

@ -142,6 +142,7 @@
<script src="js/controller/ToolController.js"></script>
<script src="js/controller/PaletteController.js"></script>
<script src="js/controller/NotificationController.js"></script>
<script src="js/controller/SettingsController.js"></script>
<!-- Services -->
<script src="js/service/LocalStorageService.js"></script>
<script src="js/service/HistoryService.js"></script>

View File

@ -0,0 +1,37 @@
(function () {
var ns = $.namespace("pskl.controller");
ns.SettingsController = function () {};
/**
* Get state for the checkbox that control the display of the grid
* on the drawing canvas.
* @private
*/
ns.SettingsController.prototype.isShowGridChecked_ = function() {
var showGridCheckbox = $('#show-grid');
var isChecked = showGridCheckbox.is(':checked');
return isChecked;
};
/**
* @public
*/
ns.SettingsController.prototype.init = function() {
// Show/hide the grid on drawing canvas:
$.publish(Events.GRID_DISPLAY_STATE_CHANGED, [this.isShowGridChecked_()]);
$('#show-grid').change($.proxy(function(evt) {
var checked = this.isShowGridChecked_();
$.publish(Events.GRID_DISPLAY_STATE_CHANGED, [checked]);
}, this));
// Handle canvas background changes:
$('#canvas-picker').change(function(evt) {
$('#canvas-picker option:selected').each(function() {
console.log($(this).val());
$('html')[0].className = $(this).val();
});
});
};
})();

View File

@ -83,17 +83,6 @@
$('#tools-container').html(toolMarkup);
};
/**
* Get state for the checkbox that control the display of the grid
* on the drawing canvas.
* @private
*/
ns.ToolController.prototype.isShowGridChecked_ = function() {
var showGridCheckbox = $('#show-grid');
var isChecked = showGridCheckbox.is(':checked');
return isChecked;
};
/**
* @public
*/
@ -106,12 +95,5 @@
this.selectTool_(this.toolInstances.simplePen);
// Activate listener on tool panel:
$("#tool-section").click($.proxy(this.onToolIconClicked_, this));
// Show/hide the grid on drawing canvas:
$.publish(Events.GRID_DISPLAY_STATE_CHANGED, [this.isShowGridChecked_()]);
$('#show-grid').change($.proxy(function(evt) {
var checked = this.isShowGridChecked_();
$.publish(Events.GRID_DISPLAY_STATE_CHANGED, [checked]);
}, this));
};
})();

View File

@ -24,6 +24,7 @@ $.namespace("pskl");
this.drawingController = new pskl.controller.DrawingController(frameSheet, $('#drawing-canvas-container'));
this.animationController = new pskl.controller.AnimatedPreviewController(frameSheet, $('#preview-canvas-container'));
this.previewsController = new pskl.controller.PreviewFilmController(frameSheet, $('#preview-list'));
this.settingsController = new pskl.controller.SettingsController();
// To catch the current active frame, the selection manager have to be initialized before
// the 'frameSheet.setCurrentFrameIndex(0);' line below.
@ -39,6 +40,7 @@ $.namespace("pskl");
this.animationController.init();
this.previewsController.init();
this.settingsController.init();
this.historyService = new pskl.service.HistoryService(frameSheet);
this.historyService.init();
@ -74,13 +76,6 @@ $.namespace("pskl");
$('#settings').click(function(evt) {
$('.right-sticky-section').toggleClass('expanded');
});
$('#canvas-picker').change(function(evt) {
$('#canvas-picker option:selected').each(function() {
console.log($(this).val());
$('html')[0].className = $(this).val();
});
});
},
render : function (delta) {