make the clock adjust its size on window resizing

This commit is contained in:
Manuel Friedli 2014-08-11 19:19:11 +02:00
parent 633401862f
commit c0742a6f11
2 changed files with 22 additions and 6 deletions

View file

@ -49,13 +49,24 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
(function($) {
var width = $(window).width();
var height = $(window).height();
var size = (width < height ? width : height) + 'px';
var size = Math.min(width, height) + 'px';
$('#uhr').uhr({
width: size,
color: 'black',
language: 'de_CH',
controls: true
});
$(window).on('resize', function (event) {
var $uhr = $('#uhr');
var $parent = $uhr.parent();
var $window = $(window);
var parentWidth = $parent.width();
var parentHeight = $parent.height();
var windowWidth = $window.width();
var windowHeight = $window.height();
var size = Math.min(parentWidth, parentHeight, windowWidth, windowHeight) + 'px';
$uhr.uhr("width", size);
});
})(jQuery);
</script>
</body>