From 898d21a7cc1fe23a48896618e638b63130ac7c8c Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sat, 17 Sep 2016 19:02:51 -0700 Subject: Display and sizing adjustments to handle larger numbers and fit better on small screens (fixes #48) --- public/js/calculator.coffee | 14 +++++++++----- public/js/calculator.js | 16 ++++++++++------ 2 files changed, 19 insertions(+), 11 deletions(-) (limited to 'public/js') diff --git a/public/js/calculator.coffee b/public/js/calculator.coffee index 1b5f5034..cf1e1d24 100644 --- a/public/js/calculator.coffee +++ b/public/js/calculator.coffee @@ -35,7 +35,7 @@ $(-> updateTotal() return - return if n > 1000 + return if n > 100000 if m is '00' n = 100 * n @@ -57,10 +57,14 @@ $(-> $('.tippad .btn').off('click').click((e) -> e.preventDefault() + text = $(this).html() + if text is 'No Tip' + value = 0 + else + value = text.slice(1, -1) + $(this).addClass('active') - value = $(this).html().slice(0, -1) - $(this).siblings().css('font-weight','normal').removeClass('active') - $(this).css('font-weight','bold') + $(this).siblings().removeClass('active') g.tip = 1 + (parseFloat(value)/100) updateTotal() ) @@ -149,7 +153,7 @@ updateTotal = -> time = 0 if g.timeout - time = 1500 + time = 10 clearTimeout(g.timeout) g.timeout = setTimeout(-> diff --git a/public/js/calculator.js b/public/js/calculator.js index f54e70bd..4dccce40 100644 --- a/public/js/calculator.js +++ b/public/js/calculator.js @@ -44,7 +44,7 @@ updateTotal(); return; } - if (n > 1000) { + if (n > 100000) { return; } if (m === '00') { @@ -61,12 +61,16 @@ return updateTotal(); }); $('.tippad .btn').off('click').click(function(e) { - var value; + var text, value; e.preventDefault(); + text = $(this).html(); + if (text === 'No Tip') { + value = 0; + } else { + value = text.slice(1, -1); + } $(this).addClass('active'); - value = $(this).html().slice(0, -1); - $(this).siblings().css('font-weight', 'normal').removeClass('active'); - $(this).css('font-weight', 'bold'); + $(this).siblings().removeClass('active'); g.tip = 1 + (parseFloat(value) / 100); return updateTotal(); }); @@ -151,7 +155,7 @@ $('#qr').css('height', size); time = 0; if (g.timeout) { - time = 1500; + time = 10; } clearTimeout(g.timeout); return g.timeout = setTimeout(function() { -- cgit v1.2.3