From 7214b6bb6e927792e44b5361458788ee10a21f22 Mon Sep 17 00:00:00 2001 From: Andrej Kabachnik Date: Wed, 8 Jul 2015 09:33:43 +0200 Subject: [PATCH] v1.1 Added onKeypadOpen and onKeypadClose --- HISTORY.md | 9 +++++++++ README.md | 2 -- jquery.numpad.js | 12 +++++++++++- 3 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 HISTORY.md diff --git a/HISTORY.md b/HISTORY.md new file mode 100644 index 0000000..dc87180 --- /dev/null +++ b/HISTORY.md @@ -0,0 +1,9 @@ +### v1.1 + * Added onKeypadOpen and onKeypadClose callbacks and corresponding numpad.open and numpad.close events + +### v1.0.1 + * Added support for Bootstrap + * Added Bootstrap demo + +### v1.0 + * Initial Releas \ No newline at end of file diff --git a/README.md b/README.md index 9ae36ea..b20fc5b 100644 --- a/README.md +++ b/README.md @@ -30,8 +30,6 @@ function($){ - Add support for negative numbers - Add support for fractions - Add position options to place the keypad above or aside the target element -- Add an onClose callback to support custom target elements -- Add an onOpen callback to support custom initial values - Make a simple calculator ## License diff --git a/jquery.numpad.js b/jquery.numpad.js index fc28b1c..32d0b18 100644 --- a/jquery.numpad.js +++ b/jquery.numpad.js @@ -78,6 +78,12 @@ if (options.onKeypadCreate){ nmpd.on('numpad.create', options.onKeypadCreate); } + if (options.onKeypadOpen){ + nmpd.on('numpad.open', options.onKeypadOpen); + } + if (options.onKeypadClose){ + nmpd.on('numpad.close', options.onKeypadClose); + } (options.appendKeypadTo ? options.appendKeypadTo : $(document.body)).append(nmpd); $('#'+id+' .numero').bind('click', function(){ @@ -110,6 +116,7 @@ } } nmpd.hide(); + nmpd.trigger('numpad.close'); return nmpd; }; @@ -127,6 +134,7 @@ nmpd.show().find('.cancel').focus(); position(nmpd.find('.nmpd-grid'), options.position, options.positionX, options.positionY); $('#'+id+' .done').one('click', function(){ nmpd.close(target); }); + nmpd.trigger('numpad.open'); return nmpd; }; }); @@ -183,6 +191,8 @@ position: 'fixed', positionX: 'center', positionY: 'middle', - onKeypadCreate: false + onKeypadCreate: false, + onKeypadOpen: false, + onKeypadClose: false }; })(jQuery); \ No newline at end of file