complete zoom migration
parent
462d7ba9dc
commit
01fbee459b
|
@ -15,8 +15,7 @@ openGraph: Option[lila.app.ui.OpenGraph] = None,
|
|||
atom: Option[Html] = None,
|
||||
chessground: Boolean = true,
|
||||
withLangAnnotations: Boolean = true,
|
||||
withGtm: Boolean = false,
|
||||
zoomable: Boolean = true)(body: Html)(implicit ctx: Context)
|
||||
withGtm: Boolean = false)(body: Html)(implicit ctx: Context)
|
||||
<!doctype html>
|
||||
<html lang="@lang.language">
|
||||
<head>
|
||||
|
@ -31,7 +30,10 @@ zoomable: Boolean = true)(body: Html)(implicit ctx: Context)
|
|||
}
|
||||
@cssTag("common.css")
|
||||
@cssTag("board.css")
|
||||
@ctx.zoom.ifTrue(zoomable).map { z => @zoomStyle(z / 100f) }
|
||||
@if(!chessground) {
|
||||
@ctx.zoom.map { z =>
|
||||
@zoomStyle(z / 100f) }
|
||||
}
|
||||
@if(ctx.is3d) { @cssTag("board-3d.css") }
|
||||
@if(ctx.pref.coords == 1) { @cssTag("board.coords.inner.css") }
|
||||
@moreCss
|
||||
|
@ -70,7 +72,8 @@ zoomable: Boolean = true)(body: Html)(implicit ctx: Context)
|
|||
data-bg="@ctx.currentBg"
|
||||
data-asset-url="@assetBaseUrl"
|
||||
data-asset-version="@ctx.pageData.assetVersion"
|
||||
data-accept-languages="@acceptLanguages.mkString(",")">
|
||||
data-accept-languages="@acceptLanguages.mkString(",")"
|
||||
data-zoom="@ctx.zoomOrDefault">
|
||||
<form id="blind_mode" action="@routes.Main.toggleBlindMode" method="POST">
|
||||
<input type="hidden" name="enable" value="@ctx.blindMode.fold(0,1)" />
|
||||
<input type="hidden" name="redirect" value="@ctx.req.path" />
|
||||
|
|
|
@ -72,6 +72,8 @@ sealed trait Context extends lila.user.UserContextWrapper {
|
|||
|
||||
def zoom: Option[Int] = req.session get "zoom" flatMap parseIntOption filter (100<)
|
||||
|
||||
def zoomOrDefault = zoom | 100
|
||||
|
||||
private def ctxPref(name: String): Option[String] =
|
||||
req.session get name orElse { pref get name }
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// var start = new Date(); var millis = 2000; while (new Date() - millis < start) {}
|
||||
// var start = new Date(); var millis = 500; while (new Date() - millis < start) {}
|
||||
|
||||
lichess.challengeApp = (function() {
|
||||
var instance, booted;
|
||||
|
@ -557,7 +557,7 @@ lichess.notifyApp = (function() {
|
|||
$('link[href*="board.css"]').clone().each(function() {
|
||||
$(this).attr('href', $(this).attr('href').replace(/board\.css/, 'board-3d.css')).appendTo('head');
|
||||
});
|
||||
setZoom(getZoom());
|
||||
setZoom(currentZoom);
|
||||
};
|
||||
$themepicker.find('.background a').click(function() {
|
||||
background = $(this).data('bg');
|
||||
|
@ -593,7 +593,7 @@ lichess.notifyApp = (function() {
|
|||
max: 2,
|
||||
range: 'min',
|
||||
step: 0.01,
|
||||
value: getZoom(),
|
||||
value: currentZoom,
|
||||
slide: function(e, ui) {
|
||||
manuallySetZoom(ui.value);
|
||||
}
|
||||
|
@ -612,11 +612,11 @@ lichess.notifyApp = (function() {
|
|||
});
|
||||
|
||||
// Zoom
|
||||
var getZoom = function() {
|
||||
return lichess.isTrident ? 1 : (lichess.storage.get('zoom') || 1);
|
||||
};
|
||||
var currentZoom = lichess.isTrident ? 1 : $('body').data('zoom') / 100;
|
||||
|
||||
var setZoom = function(zoom) {
|
||||
lichess.storage.set('zoom', zoom);
|
||||
|
||||
currentZoom = zoom;
|
||||
|
||||
var $lichessGame = $('.lichess_game, .board_and_ground');
|
||||
var $boardWrap = $lichessGame.find('.cg-board-wrap').not('.mini_board .cg-board-wrap');
|
||||
|
@ -662,20 +662,27 @@ lichess.notifyApp = (function() {
|
|||
};
|
||||
|
||||
var saveZoom = lichess.fp.debounce(function() {
|
||||
console.log(currentZoom);
|
||||
$.ajax({
|
||||
method: 'post',
|
||||
url: '/pref/zoom?v=' + Math.round(getZoom() * 100)
|
||||
url: '/pref/zoom?v=' + Math.round(currentZoom * 100)
|
||||
});
|
||||
}, 500);
|
||||
var manuallySetZoom = lichess.fp.debounce(function(z) {
|
||||
setZoom(z);
|
||||
saveZoom();
|
||||
}, 10);
|
||||
if (getZoom() > 1) setZoom(getZoom()); // Instantiate the page's zoom
|
||||
lichess.pubsub.on('reset_zoom', function() {
|
||||
if (getZoom() > 1) setZoom(getZoom());
|
||||
if (currentZoom > 1) setZoom(currentZoom);
|
||||
});
|
||||
|
||||
// migrate from storage to cookie DELETE ME - 09/03/17
|
||||
var oldZoom = lichess.storage.get('zoom');
|
||||
if (oldZoom) {
|
||||
manuallySetZoom(oldZoom);
|
||||
lichess.storage.remove('zoom');
|
||||
}
|
||||
|
||||
function translateTexts() {
|
||||
$('.trans_me').each(function() {
|
||||
var t = $(this).removeClass('trans_me');
|
||||
|
|
Loading…
Reference in New Issue