From eef5307464a36019e27bffedd6198d589128c0ac Mon Sep 17 00:00:00 2001 From: peteruithoven Date: Mon, 20 Jan 2014 13:28:33 +0100 Subject: [PATCH] Using onButtonClick only (preventing double print call) #174 --- js/buttonbehaviors.js | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/js/buttonbehaviors.js b/js/buttonbehaviors.js index 776e7b4..87a04bd 100644 --- a/js/buttonbehaviors.js +++ b/js/buttonbehaviors.js @@ -62,7 +62,7 @@ function initButtonBehavior() { btnAdd.on("onButtonClick", onBtnAdd); btnWordArt.on("onButtonClick", onBtnWordArt); btnShape.on("onButtonClick", onBtnShape); - btnPrint.on("onButtonClick", onBtnPrint); + btnPrint.on("onButtonClick", print); btnOops.on("onButtonHold", onBtnOops); // vertical shape buttons btnToggleVerticalShapes.on("onButtonClick", onBtnToggleVerticalShapes); @@ -170,10 +170,6 @@ function initButtonBehavior() { clearDoodle(); } - function onBtnPrint(e) { - print(); - } - function onBtnWordArt(e) { showWordArtDialog(); } @@ -352,23 +348,17 @@ function setState(newState,newHasControl) { // print button var printEnabled = (newState == Printer.IDLE_STATE && newHasControl); if(printEnabled) { - btnPrint.removeClass("disabled"); // enable print button - btnPrint.unbind('touchstart mousedown'); - btnPrint.bind('touchstart mousedown',print); + enableButton(btnPrint,print); } else { - btnPrint.addClass("disabled"); // disable print button - btnPrint.unbind('touchstart mousedown'); + disableButton(btnPrint); } // stop button var stopEnabled = ((newState == Printer.PRINTING_STATE || newState == Printer.BUFFERING_STATE) && newHasControl); if(stopEnabled) { - btnStop.removeClass("disabled"); - btnStop.unbind('touchstart mousedown'); - btnStop.bind('touchstart mousedown',stopPrint); + enableButton(btnStop,stopPrint); } else { - btnStop.addClass("disabled"); - btnStop.unbind('touchstart mousedown'); + disableButton(btnStop); } // thermometer