2013-06-16 12:17:50 +04:00
|
|
|
(function () {
|
2013-08-10 14:11:16 +04:00
|
|
|
var ns = $.namespace("pskl.controller");
|
2013-06-16 12:17:50 +04:00
|
|
|
|
2013-08-10 14:11:16 +04:00
|
|
|
ns.SettingsController = function () {};
|
2013-06-16 12:17:50 +04:00
|
|
|
|
2013-08-10 14:11:16 +04:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
ns.SettingsController.prototype.init = function() {
|
2013-06-16 12:17:50 +04:00
|
|
|
|
2013-08-10 14:11:16 +04:00
|
|
|
// Highlight selected background picker:
|
|
|
|
var backgroundClass = pskl.UserSettings.get(pskl.UserSettings.CANVAS_BACKGROUND);
|
|
|
|
$('#background-picker-wrapper')
|
|
|
|
.find('.background-picker[data-background-class=' + backgroundClass + ']')
|
|
|
|
.addClass('selected');
|
2013-06-18 01:10:35 +04:00
|
|
|
|
2013-08-10 14:11:16 +04:00
|
|
|
// Initial state for grid display:
|
|
|
|
var show_grid = pskl.UserSettings.get(pskl.UserSettings.SHOW_GRID);
|
|
|
|
$('#show-grid').prop('checked', show_grid);
|
2013-06-17 21:54:43 +04:00
|
|
|
|
2013-08-10 14:11:16 +04:00
|
|
|
// Expand drawer when clicking 'Settings' tab.
|
|
|
|
$('#settings').click(function(evt) {
|
|
|
|
$('.right-sticky-section').toggleClass('expanded');
|
|
|
|
$('#settings').toggleClass('has-expanded-drawer');
|
|
|
|
});
|
2013-06-16 12:36:26 +04:00
|
|
|
|
2013-08-10 14:11:16 +04:00
|
|
|
// Handle grid display changes:
|
|
|
|
$('#show-grid').change($.proxy(function(evt) {
|
|
|
|
var checked = $('#show-grid').prop('checked');
|
|
|
|
pskl.UserSettings.set(pskl.UserSettings.SHOW_GRID, checked);
|
|
|
|
}, this));
|
2013-06-16 12:17:50 +04:00
|
|
|
|
2013-08-10 14:11:16 +04:00
|
|
|
// Handle canvas background changes:
|
|
|
|
$('#background-picker-wrapper').click(function(evt) {
|
|
|
|
var target = $(evt.target).closest('.background-picker');
|
|
|
|
if (target.length) {
|
|
|
|
var backgroundClass = target.data('background-class');
|
|
|
|
pskl.UserSettings.set(pskl.UserSettings.CANVAS_BACKGROUND, backgroundClass);
|
2013-06-17 13:36:56 +04:00
|
|
|
|
2013-08-10 14:11:16 +04:00
|
|
|
$('.background-picker').removeClass('selected');
|
|
|
|
target.addClass('selected');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
2013-06-16 12:17:50 +04:00
|
|
|
})();
|