</div>\
<div id='sws-control-panel-options'>\
<span title='Change the aspect ratio' class='sws-symbol' >💻</span><select id='sws-aspect-select' onchange='SWS.Presentation.changeAspect();'>\
-<option value='sws-aspect-4-3'>4:3</option>\
+<option value='sws-aspect-4-3' selected='selected'>4:3</option>\
<option value='sws-aspect-16-9'>16:9</option>\
<option value='sws-aspect-16-10'>16:10</option>\
</select>\
});
};
self.changeAspect = function() {
+ var newClass = $("#sws-aspect-select").val();
+ var args = newClass.split("-");
+ var targetRatio = (args[2] - 0) / (args[3] - 0);
+ var realRatio = window.innerWidth / window.innerHeight;
+ var byClass = (targetRatio > realRatio ) ? "sws-by-height" : "sws-by-width";
+ console.log(byClass);
+
+ if ($("html").hasClass(newClass)
+ && $("html").hasClass(byClass))
+ return;
+
$("html").removeClass("sws-aspect-4-3")
.removeClass("sws-aspect-16-9")
.removeClass("sws-aspect-16-10")
- .addClass($("#sws-aspect-select").val());
+ .removeClass("sws-by-width")
+ .removeClass("sws-by-height")
+ .addClass(newClass).addClass(byClass);
self.redraw();
};
}
else {
if (self.showHelpAtStartup()) $("#sws-help-panel-canvas").show().delay(5000).hide();
+ self.changeAspect();
self.refresh();
};
$(document).keydown(self.inputHandler);
document.body.addEventListener('touchstart',self.inputHandler, false);
document.body.addEventListener('touchend',self.inputHandler, false);
+ $(window).resize(self.changeAspect);
_initialized = true;
};
- setTimeout(f, 100);
+ //setTimeout(f, 100);
+ f();
};
};