dasher now supports 2d/3d switch
This commit is contained in:
parent
f50df7e991
commit
40a1c24663
|
@ -42,7 +42,10 @@ object Dasher extends LilaController {
|
|||
"current" -> ctx.currentBg,
|
||||
"image" -> ctx.bgImg
|
||||
),
|
||||
"is3d" -> ctx.is3d,
|
||||
"board" -> Json.obj(
|
||||
"is3d" -> ctx.is3d,
|
||||
"zoom" -> ctx.zoom
|
||||
),
|
||||
"kid" -> me.kid,
|
||||
"coach" -> isGranted(_.Coach),
|
||||
"prefs" -> prefs,
|
||||
|
|
|
@ -181,5 +181,5 @@ $(function() {
|
|||
}, 1000);
|
||||
});
|
||||
});
|
||||
lichess.pubsub.emit('reset_zoom')();
|
||||
lichess.pubsub.emit('set_zoom')();
|
||||
});
|
||||
|
|
|
@ -267,7 +267,7 @@ module.exports = function(ctrl) {
|
|||
m('div', {
|
||||
config: function(el, isUpdate) {
|
||||
if (firstRender) firstRender = false;
|
||||
else if (!isUpdate) lichess.pubsub.emit('reset_zoom')();
|
||||
else if (!isUpdate) lichess.pubsub.emit('set_zoom')();
|
||||
},
|
||||
class: classSet({
|
||||
'gauge_displayed': ctrl.showEvalGauge(),
|
||||
|
|
|
@ -61,7 +61,7 @@ export function view(ctrl: BackgroundCtrl): VNode {
|
|||
hook: bind('click', ctrl.close)
|
||||
}, 'Background'),
|
||||
h('div.selector', ctrl.list.map(bg => {
|
||||
return h('a.text.' + bg.key, {
|
||||
return h('a.text', {
|
||||
class: { active: cur === bg.key },
|
||||
attrs: { 'data-icon': 'E' },
|
||||
hook: bind('click', () => ctrl.set(bg.key))
|
||||
|
|
|
@ -20,6 +20,8 @@ export function ctrl(data: BoardData, redraw: Redraw, close: Close): BoardCtrl {
|
|||
data,
|
||||
setIs3d(v: boolean) {
|
||||
data.is3d = v;
|
||||
$.post('/pref/is3d', { is3d: v }, window.lichess.reloadOtherTabs);
|
||||
applyDimension(v);
|
||||
redraw();
|
||||
},
|
||||
close
|
||||
|
@ -33,7 +35,30 @@ export function view(ctrl: BoardCtrl): VNode {
|
|||
attrs: { 'data-icon': 'I' },
|
||||
hook: bind('click', ctrl.close)
|
||||
}, 'Chess board'),
|
||||
h('div.selector', 'gnnh')
|
||||
])
|
||||
h('div.selector', [
|
||||
h('a.text', {
|
||||
class: { active: !ctrl.data.is3d },
|
||||
attrs: { 'data-icon': 'E' },
|
||||
hook: bind('click', () => ctrl.setIs3d(false))
|
||||
}, '2D'),
|
||||
h('a.text', {
|
||||
class: { active: ctrl.data.is3d },
|
||||
attrs: { 'data-icon': 'E' },
|
||||
hook: bind('click', () => ctrl.setIs3d(true))
|
||||
}, '3D')
|
||||
])
|
||||
]);
|
||||
}
|
||||
|
||||
function applyDimension(is3d: boolean) {
|
||||
|
||||
$('body').children('.content').removeClass('is2d is3d').addClass(is3d ? 'is3d' : 'is2d');
|
||||
|
||||
if (is3d && !$('link[href*="board-3d.css"]').length) {
|
||||
$('link[href*="board.css"]').clone().each(function(this: HTMLElement) {
|
||||
$(this).attr('href', $(this).attr('href').replace(/board\.css/, 'board-3d.css')).appendTo('head');
|
||||
});
|
||||
}
|
||||
|
||||
window.lichess.pubsub.emit('set_zoom')();
|
||||
}
|
||||
|
|
|
@ -100,7 +100,7 @@ module.exports = function(ctrl) {
|
|||
m('div', {
|
||||
config: function(el, isUpdate) {
|
||||
if (firstRender) firstRender = false;
|
||||
else if (!isUpdate) lichess.pubsub.emit('reset_zoom')();
|
||||
else if (!isUpdate) lichess.pubsub.emit('set_zoom')();
|
||||
},
|
||||
class: ctrl.showEvalGauge() ? 'gauge_displayed' : ''
|
||||
}, [
|
||||
|
|
|
@ -538,17 +538,11 @@ lichess.topMenuIntent = function() {
|
|||
setZoom(z);
|
||||
saveZoom();
|
||||
}, 10);
|
||||
lichess.pubsub.on('reset_zoom', function() {
|
||||
if (currentZoom > 1 || $('body').data('zoom') > 100) setZoom(currentZoom);
|
||||
lichess.pubsub.on('set_zoom', function(v) {
|
||||
v = v || currentZoom;
|
||||
if (v > 1 || $('body').data('zoom') > 100) setZoom(v);
|
||||
});
|
||||
|
||||
// migrate from storage to cookie DELETE ME - 09/03/17
|
||||
var oldZoom = lichess.storage.get('zoom');
|
||||
if (oldZoom) {
|
||||
manuallySetZoom(oldZoom);
|
||||
lichess.storage.remove('zoom');
|
||||
}
|
||||
|
||||
// themepicker
|
||||
$('#themepicker_toggle').one('mouseover', function() {
|
||||
var button = this;
|
||||
|
|
Loading…
Reference in a new issue