7d698b1d2680245d8c724daf153ad8bae0f9cfbc
jdarwood007 Cleanup, enforce style and...

jdarwood007 authored 3 years ago

1) (function (factory) {
2) 	if (typeof define === 'function' && define.amd) {
3) 		// AMD. Register as an anonymous module.
4) 		define(['jquery'], factory);
5) 	} else if (typeof module === 'object' && module.exports) {
6) 		// Node/CommonJS
jdarwood007 Add bg-body to default tabl...

jdarwood007 authored 5 months ago

7) 		module.exports = function (root, jQuery) {
8) 			if (jQuery === undefined) {
jdarwood007 Cleanup, enforce style and...

jdarwood007 authored 3 years ago

9) 				// require('jQuery') returns a factory that requires window to
10) 				// build a jQuery instance, we normalize how we use modules
11) 				// that require this pattern but the window provided is a noop
12) 				// if it's defined (how jquery works)
jdarwood007 Add bg-body to default tabl...

jdarwood007 authored 5 months ago

13) 				if (typeof window !== 'undefined') {
jdarwood007 Cleanup, enforce style and...

jdarwood007 authored 3 years ago

14) 					jQuery = require('jquery');
15) 				}
16) 				else {
17) 					jQuery = require('jquery')(root);
18) 				}
19) 			}
20) 			factory(jQuery);
21) 			return jQuery;
22) 		};
23) 	} else {
24) 		// Browser globals
25) 		factory(jQuery);
26) 	}
27) }(function ($) {
28) 	'use strict'
jdarwood007 Destroy the plugin better....

jdarwood007 authored 3 years ago

29) 	$.fn.numbercontrol = function (methodOrProps) {
jdarwood007 Fixes issues with destroy....

jdarwood007 authored 2 years ago

30) 		if (methodOrProps === 'destory' || (typeof methodOrProps === 'object' && methodOrProps.destroy !== undefined)) {
jdarwood007 Destroy the plugin better....

jdarwood007 authored 3 years ago

31) 			this.each(function () {
32) 				$(this).parent().children().each(function (index, value) {
33) 					var thisSelector = $(value);
34) 
jdarwood007 Fixes issues with destroy....

jdarwood007 authored 2 years ago

35) 					if (typeof options === 'object' && options.onBeforeDestoryInitialize !== undefined)
jdarwood007 Destroy the plugin better....

jdarwood007 authored 3 years ago

36) 						options.onBeforeDestoryInitialize(this);
37) 
38) 					if (!thisSelector.is('input'))
39) 						thisSelector.remove();
40) 
jdarwood007 Fixes issues with destroy....

jdarwood007 authored 2 years ago

41) 					if (typeof options === 'object' && options.onAfterDestoryInitialize !== undefined)
jdarwood007 Destroy the plugin better....

jdarwood007 authored 3 years ago

42) 						options.onAfterDestoryInitialize(this);
43) 				});
44) 
45) 				$(this).parent().removeClass().addClass('numberControlDestoryed');
jdarwood007 Fixes issues with destroy....

jdarwood007 authored 2 years ago

46) 			});
47) 
jdarwood007 Cleanup, enforce style and...

jdarwood007 authored 3 years ago

48) 			return this;
49) 		}
jdarwood007 Initial commit

jdarwood007 authored 3 years ago

50) 
51) 		// Allow customizing the options.
jdarwood007 Cleanup, enforce style and...

jdarwood007 authored 3 years ago

52) 		var options = {
53) 			debug: false,
54) 			separator: '.',
55) 			type: 'number',
56) 			prependHtml: '<div class="input-group-prepend"><button class="btn btn-decrease btn-outline-secondary px-1"><span class="oi oi-minus" /></button></div>',
jdarwood007 Destroy the plugin better....

jdarwood007 authored 3 years ago

57) 			appendHtml: '<div class="input-group-append"><button class="btn btn-increase btn-outline-secondary px-1"><span class="oi oi-plus" /></button></div>',
58) 			inputParentCss: 'input-group numberControl',
jdarwood007 Cleanup, enforce style and...

jdarwood007 authored 3 years ago

59) 			inputParent: 'div',
60) 			inputCss: 'numberControlInput form-control px-1',
Jeremy D Touchstart and click may ca...

Jeremy D authored 2 years ago

61) 			bindButtonEvents: 'click touchend',
jdarwood007 Cleanup, enforce style and...

jdarwood007 authored 3 years ago

62) 			keyboardLanguage: {
jdarwood007 Add bg-body to default tabl...

jdarwood007 authored 5 months ago

63) 				'UP': '<span class="oi oi-chevron-top" />',
64) 				'DOWN': '<span class="oi oi-chevron-bottom" />',
65) 				'INVERSE': '<span class="oi oi-transfer" />',
66) 				'SEP': '<span class="oi oi-media-record" />',
jdarwood007 Cleanup, enforce style and...

jdarwood007 authored 3 years ago

67) 			},
68) 			keyboardControl: {
69) 			},
jdarwood007 Initial commit

jdarwood007 authored 3 years ago

70) 			buttons: [...Array(10).keys(), 'DELETE', 'CLEAR', 'DONE', 'CANCEL', 'UP', 'DOWN', 'SEP', 'INVERSE']
jdarwood007 Cleanup, enforce style and...

jdarwood007 authored 3 years ago

71) 		}
72) 		for (var option in methodOrProps) {
73) 			options[option] = methodOrProps[option]
74) 		}
jdarwood007 Initial commit

jdarwood007 authored 3 years ago

75) 
Jeremy D Handle trailing 0s Trigger...

Jeremy D authored 2 years ago

76) 		// Parse a float with 0s at the end.
77) 		// Reference: https://stackoverflow.com/questions/4868556/how-do-i-stop-parsefloat-from-stripping-zeroes-to-right-of-decimal
jdarwood007 Add bg-body to default tabl...

jdarwood007 authored 5 months ago

78) 		function customParseFloat(number) {
Jeremy D Handle trailing 0s Trigger...

Jeremy D authored 2 years ago

79) 			if (isNaN(parseFloat(number)) !== false)
80) 				return number;
81) 
Jeremy D Cleanup the implantation of...

Jeremy D authored 2 years ago

82) 			let str = String(number),
83) 				arr = str.split(options.separator);
Jeremy D Handle trailing 0s Trigger...

Jeremy D authored 2 years ago

84) 
Jeremy D Cleanup the implantation of...

Jeremy D authored 2 years ago

85) 			return parseFloat(str).toFixed(arr.length === 2 ? arr[1].length : 0);
Jeremy D Handle trailing 0s Trigger...

Jeremy D authored 2 years ago

86) 		}
87) 
jdarwood007 Add bg-body to default tabl...

jdarwood007 authored 5 months ago

88) 		function setNewValue(container, value, event) {
jdarwood007 Destroy the plugin better....

jdarwood007 authored 3 years ago

89) 			if (options.onBeforeSetNewvalue !== undefined)
90) 				options.onBeforeSetNewvalue(this, event, container, value);
91) 
jdarwood007 Fixes issues with destroy....

jdarwood007 authored 2 years ago

92) 			// The Min value was hit with nothing in the container, which could most likely be a blank string that was converted to a int.
93) 			if (Number.MIN_VALUE == parseFloat(value) && $(container).val() == '')
94) 				return false;
95) 
Jeremy D Make a good demo page to sh...

Jeremy D authored 2 years ago

96) 			// No Nans.
97) 			if (options.type !== 'text' && isNaN(value))
98) 				value = 0;
99) 
100) 			if (options.type === 'text')
101) 				$(container).val(value);
102) 			else if (options.type === 'number')
jdarwood007 Initial commit

jdarwood007 authored 3 years ago

103) 				$(container).val(parseInt(value));
Jeremy D Handle trailing 0s Trigger...

Jeremy D authored 2 years ago

104) 			// Handle floats/decmials with 0s at the end.
105) 			else if ((options.disallowTrailingZero === undefined || options.disallowTrailingZero === false) && value[value.length - 1] == 0)
106) 				$(container).val(customParseFloat(value));
jdarwood007 Initial commit

jdarwood007 authored 3 years ago

107) 			else
108) 				$(container).val(parseFloat(value));
jdarwood007 Destroy the plugin better....

jdarwood007 authored 3 years ago

109) 
Jeremy D Handle trailing 0s Trigger...

Jeremy D authored 2 years ago

110) 			// By default, we should trigger a change to the container.
111) 			if (options.ignoreChangeTrigger === undefined || options.ignoreChangeTrigger === false)
112) 				$(container).trigger('change');
113) 
jdarwood007 Destroy the plugin better....

jdarwood007 authored 3 years ago

114) 			if (options.onAfterSetNewvalue !== undefined)
115) 				options.onAfterSetNewvalue(this, event, container, value);
jdarwood007 Initial commit

jdarwood007 authored 3 years ago

116) 		}
117) 
jdarwood007 Fixed a issue with precisio...

jdarwood007 authored 2 years ago

118) 		// https://stackoverflow.com/questions/9553354/how-do-i-get-the-decimal-places-of-a-floating-point-number-in-javascript
jdarwood007 Add bg-body to default tabl...

jdarwood007 authored 5 months ago

119) 		function precision(a) {
jdarwood007 Fixed a issue with precisio...

jdarwood007 authored 2 years ago

120) 			if (!isFinite(a))
121) 				return 0;
122) 
123) 			var e = 1, p = 0;
jdarwood007 Add bg-body to default tabl...

jdarwood007 authored 5 months ago

124) 			while (Math.round(a * e) / e !== a) {
jdarwood007 Fixed a issue with precisio...

jdarwood007 authored 2 years ago

125) 				e *= 10;
126) 				p++;
127) 			}
128) 
129) 			return parseInt(p);
130) 		}
131) 
jdarwood007 Add bg-body to default tabl...

jdarwood007 authored 5 months ago

132) 		function FindPercision(v, p) {
jdarwood007 Fixed a issue with precisio...

jdarwood007 authored 2 years ago

133) 			if (!isFinite(v))
134) 				return 0;
135) 			return parseInt(v).toString().length + p;
136) 		}
137) 
jdarwood007 Add bg-body to default tabl...

jdarwood007 authored 5 months ago

138) 		function findMinMaxValue() {
jdarwood007 Initial commit

jdarwood007 authored 3 years ago

139) 			var testValue;
jdarwood007 Add bg-body to default tabl...

jdarwood007 authored 5 months ago

140) 			for (var i = 0; i < arguments.length; i++) {
jdarwood007 Initial commit

jdarwood007 authored 3 years ago

141) 				testValue = arguments[i];
jdarwood007 Add bg-body to default tabl...

jdarwood007 authored 5 months ago

142) 				if (typeof testValue !== 'undefined' && !isNaN(testValue)) {
jdarwood007 Initial commit

jdarwood007 authored 3 years ago

143) 					if (options.type === 'number' && parseInt(testValue) !== null)
144) 						return parseInt(testValue);
145) 					else if (parseFloat(testValue) !== null)
146) 						return parseFloat(testValue);
147) 					continue;
148) 				}
149) 			}
150) 			return 0;
151) 		}
152) 
153) 		// Bind to each input selector
jdarwood007 Cleanup, enforce style and...

jdarwood007 authored 3 years ago

154) 		this.each(function () {
jdarwood007 Initial commit

jdarwood007 authored 3 years ago

155) 			if (options.onBeforeInitialized !== undefined)
156) 				options.onBeforeInitialized(this);
157) 
jdarwood007 Cleanup, enforce style and...

jdarwood007 authored 3 years ago

158) 			var $base = $(this);
jdarwood007 Initial commit

jdarwood007 authored 3 years ago

159) 
160) 			// Some settings we either can pull in from a options, from standard attributes or defaults.
161) 			var $step = findMinMaxValue(parseFloat(options.step), parseFloat($base.attr('step')), 1);
jdarwood007 Fixed a issue with precisio...

jdarwood007 authored 2 years ago

162) 			var $percision = precision($step) + 1;
Jeremy D Make a good demo page to sh...

Jeremy D authored 2 years ago

163) 			var $minValue = findMinMaxValue(options.min, $base.attr('min'), Number.MIN_SAFE_INTEGER);
164) 			var $maxValue = findMinMaxValue(options.max, $base.attr('max'), Number.MAX_SAFE_INTEGER);
jdarwood007 Initial commit

jdarwood007 authored 3 years ago

165) 
166) 			// Build the parent up. 
Jeremy D Fixed a bug where if inputP...

Jeremy D authored 2 years ago

167) 			if (options.inputParent != '' && (!$($base).parent().is('div') || !$($base).parent().hasClass('numberControlDestoryed'))) {
jdarwood007 Destroy the plugin better....

jdarwood007 authored 3 years ago

168) 				$base.wrap('<' + options.inputParent + '></' + options.inputParent + '>');
jdarwood007 Cleanup, enforce style and...

jdarwood007 authored 3 years ago

169) 			}
jdarwood007 Initial commit

jdarwood007 authored 3 years ago

170) 			var $parent = $base.parent(options.parentSelector);
Jeremy D Fixed a bug where if inputP...

Jeremy D authored 2 years ago

171) 			$parent.addClass(options.inputParentCss);
jdarwood007 Initial commit

jdarwood007 authored 3 years ago

172) 
173) 			// Set the base.
174) 			$base.attr('type', options.type);
175) 			$base.addClass(options.inputCss);
176) 
177) 			// Wrap the buttons around.			
178) 			$base.before(options.prependHtml);
179) 			$base.after(options.appendHtml);
jdarwood007 Destroy the plugin better....

jdarwood007 authored 3 years ago

180) 
jdarwood007 Initial commit

jdarwood007 authored 3 years ago

181) 			// Add the style to the body to cleanup input controls for number.
182) 			if (options.type == 'number' && !options.DisableNumberSpinStyleFix)
183) 				$('body').append('<style>' +
jdarwood007 Add bg-body to default tabl...

jdarwood007 authored 5 months ago

184) 					'.numberControlInput::-webkit-outer-spin-button,.numberControlInput::-webkit-inner-spin-button {' +
185) 					'-webkit-appearance: none;' +
186) 					'}</style>'
jdarwood007 Initial commit

jdarwood007 authored 3 years ago

187) 				);
188) 
189) 			// The decrease event.
190) 			var $decreaseButton = $parent.find('.btn-decrease');
191) 			$decreaseButton.on(options.bindButtonEvents, function (event) {
jdarwood007 Destroy the plugin better....

jdarwood007 authored 3 years ago

192) 				event.preventDefault();
Jeremy D Touchstart and click may ca...

Jeremy D authored 2 years ago

193) 				event.stopPropagation();
jdarwood007 Destroy the plugin better....

jdarwood007 authored 3 years ago

194) 
jdarwood007 Initial commit

jdarwood007 authored 3 years ago

195) 				if (options.onBeforeClickDecrease !== undefined)
196) 					options.onBeforeClickDecrease(this, event);
197) 				if ($base.val() > $minValue)
jdarwood007 Add bg-body to default tabl...

jdarwood007 authored 5 months ago

198) 					setNewValue($base, parseFloat(parseFloat($base.val()) - parseFloat($step)).toPrecision(FindPercision($base.val(), $percision)), event);
jdarwood007 Initial commit

jdarwood007 authored 3 years ago

199) 				if (options.onAfterClickDecrease !== undefined)
200) 					options.onAfterClickDecrease(this, event);
201) 				if (options.debug)
jdarwood007 Fixed a issue with precisio...

jdarwood007 authored 2 years ago

202) 					console.log('numbercontrl: decreaseButton: Click', event, parseFloat($base.val()), $minValue, parseFloat($step));
jdarwood007 Initial commit

jdarwood007 authored 3 years ago

203) 			});
204) 
205) 			// The increase event.
jdarwood007 Cleanup, enforce style and...

jdarwood007 authored 3 years ago

206) 			var $increaseButton = $parent.find('.btn-increase');
207) 			$increaseButton.on(options.bindButtonEvents, function (event) {
jdarwood007 Destroy the plugin better....

jdarwood007 authored 3 years ago

208) 				event.preventDefault();
Jeremy D Touchstart and click may ca...

Jeremy D authored 2 years ago

209) 				event.stopPropagation();
jdarwood007 Destroy the plugin better....

jdarwood007 authored 3 years ago

210) 
jdarwood007 Initial commit

jdarwood007 authored 3 years ago

211) 				if (options.onBeforeClickIncrease !== undefined)
212) 					options.onBeforeClickIncrease(this, event);
213) 				if ($base.val() < $maxValue)
jdarwood007 Add bg-body to default tabl...

jdarwood007 authored 5 months ago

214) 					setNewValue($base, parseFloat(parseFloat($base.val()) + parseFloat($step)).toPrecision(FindPercision($base.val(), $percision)), event);
jdarwood007 Initial commit

jdarwood007 authored 3 years ago

215) 				if (options.onAfterClickIncrease !== undefined)
216) 					options.onAfterClickIncrease(this, event);
217) 				if (options.debug)
jdarwood007 Fixed a issue with precisio...

jdarwood007 authored 2 years ago

218) 					console.log('numbercontrl: increaseButton: Click', event, parseFloat($base.val()), $maxValue, parseFloat($step));
jdarwood007 Initial commit

jdarwood007 authored 3 years ago

219) 			});
220) 
221) 			// The Popup Numberpad
jdarwood007 Add bg-body to default tabl...

jdarwood007 authored 5 months ago

222) 			if (!options.disableVirtualKeyboard) {
jdarwood007 Cleanup, enforce style and...

jdarwood007 authored 3 years ago

223) 				var $KeyboardLayout;
224) 
jdarwood007 Initial commit

jdarwood007 authored 3 years ago

225) 				if (options.onBeforeVirtualKeyboardInitalized !== undefined)
226) 					options.onBeforeVirtualKeyboardInitalized(this);
227) 
228) 				$base.on(options.bindButtonEvents, function (event) {
Jeremy D Touchstart and click may ca...

Jeremy D authored 2 years ago

229) 					event.preventDefault();
jdarwood007 Initial commit

jdarwood007 authored 3 years ago

230) 					event.stopPropagation();
231) 
232) 					if (options.onBeforeVirtualKeyboardOpen !== undefined)
233) 						options.onBeforeVirtualKeyboardOpen(this);
234) 
235) 					var $location = options.virtualKeyboardAttachSelector ? $(options.virtualKeyboardAttachSelector) : $base;
236) 
237) 					if (options.keyboardLayout)
jdarwood007 Cleanup, enforce style and...

jdarwood007 authored 3 years ago

238) 						$KeyboardLayout = options.keyboardLayout;
jdarwood007 Initial commit

jdarwood007 authored 3 years ago

239) 					else
jdarwood007 Add bg-body to default tabl...

jdarwood007 authored 5 months ago

240) 						$KeyboardLayout =
Jeremy D Fixed a bug where if inputP...

Jeremy D authored 2 years ago

241) 							'<div class="modal-dialog modal-dialog-centered m-auto" style="width: 250px;">' +
jdarwood007 Add bg-body to default tabl...

jdarwood007 authored 5 months ago

242) 							'<div class="modal-content">' +
243) 							'<table class="bg-body">' +
244) 							'<tr>' +
245) 							'<td colspan="4">{INPUTBOX}</td>' +
246) 							'</tr><tr>' +
247) 							'<td>{7}</td>' +
248) 							'<td>{8}</td>' +
249) 							'<td>{9}</td>' +
250) 							'<td>{DELETE}</td>' +
251) 							'</tr><tr>' +
252) 							'<td>{4}</td>' +
253) 							'<td>{5}</td>' +
254) 							'<td>{6}</td>' +
255) 							'<td>{CLEAR}</td>' +
256) 							'</tr><tr>' +
257) 							'<td>{1}</td>' +
258) 							'<td>{2}</td>' +
259) 							'<td>{3}</td>' +
260) 							'<td>{DONE}</td>' +
261) 							'</tr><tr>' +
262) 							'<td>{UP}</td>' +
263) 							'<td>{0}</td>' +
264) 							'<td>{DOWN}</td>' +
265) 							'<td>{CANCEL}</td>' +
266) 							'</tr>' +
267) 							'</table>' +
268) 							'</div>' +
jdarwood007 Initial commit

jdarwood007 authored 3 years ago

269) 							'</div>'
jdarwood007 Add bg-body to default tabl...

jdarwood007 authored 5 months ago

270) 							;
jdarwood007 Initial commit

jdarwood007 authored 3 years ago

271) 
272) 					// Fill out the input.
jdarwood007 Cleanup, enforce style and...

jdarwood007 authored 3 years ago

273) 					if (typeof options.keyboardControl['INPUTBOX'] === 'undefined')
Jeremy D Fixed a bug where if inputP...

Jeremy D authored 2 years ago

274) 						options.keyboardControl['INPUTBOX'] = '<input class="numberControlVirtualNumPad numberControlVirtualNumPadINPUT form-control w-100" type="text" readonly value="{VAL}"/>';
jdarwood007 Cleanup, enforce style and...

jdarwood007 authored 3 years ago

275) 					$KeyboardLayout = $KeyboardLayout.replace('{INPUTBOX}', options.keyboardControl['INPUTBOX'].replace('{VAL}', $base.val()).toString());
jdarwood007 Initial commit

jdarwood007 authored 3 years ago

276) 
277) 					// Fill out all buttons.
jdarwood007 Add bg-body to default tabl...

jdarwood007 authored 5 months ago

278) 					$.each(options.buttons, function (i, v) {
jdarwood007 Initial commit

jdarwood007 authored 3 years ago

279) 						var LanguageBox = options.keyboardLanguage[v] ? options.keyboardLanguage[v] : v;
280) 
281) 						if (typeof options.keyboardControl[v] === 'undefined')
282) 							options.keyboardControl[v] = '<button class="numberControlVirtualNumPad numberControlVirtualNumPad' + v + ' btn btn-outline-secondary w-100" data-function="' + v + '">{' + v + '_LANG}</button>';
283) 						$KeyboardLayout = $KeyboardLayout.replace('{' + v + '}', options.keyboardControl[v].replace('{' + v + '_LANG}', LanguageBox));
284) 					});
285) 
286) 					// Attach the keyboard to the container.
287) 					$location.after('<div class="numberControlVirtualNumPad modal d-block">' + $KeyboardLayout + '</div>');
288) 					var $VirtualKeyboard = $parent.find('.numberControlVirtualNumPad');
289) 					var $VirtualKeyboardInput = $VirtualKeyboard.find('.numberControlVirtualNumPadINPUT');
290) 
291) 					// Bind the virtual Keyboard action.
jdarwood007 Add bg-body to default tabl...

jdarwood007 authored 5 months ago

292) 					$VirtualKeyboard.find('.numberControlVirtualNumPad').on(options.bindButtonEvents, function (event) {
jdarwood007 Destroy the plugin better....

jdarwood007 authored 3 years ago

293) 						event.preventDefault();
Jeremy D Touchstart and click may ca...

Jeremy D authored 2 years ago

294) 						event.stopPropagation();
jdarwood007 Destroy the plugin better....

jdarwood007 authored 3 years ago

295) 
jdarwood007 Initial commit

jdarwood007 authored 3 years ago

296) 						if (options.debug) console.log('numbercontrl: numberControlVirtualNumPad: Click', event, $base.val(), $VirtualKeyboardInput.val().toString(), $(this).attr('data-function'));
297) 
298) 						var thisFunction = $(this).attr('data-function');
299) 
300) 						if (options.onBeforeVirtualKeyboardButton !== undefined)
301) 							options.onBeforeVirtualKeyboardButton(this, event, thisFunction);
302) 
jdarwood007 Add bg-body to default tabl...

jdarwood007 authored 5 months ago

303) 						switch (thisFunction) {
jdarwood007 Initial commit

jdarwood007 authored 3 years ago

304) 							case 'DELETE':
305) 								$VirtualKeyboardInput.val($VirtualKeyboardInput.val().toString().slice(0, -1));
jdarwood007 Cleanup, enforce style and...

jdarwood007 authored 3 years ago

306) 								break;
jdarwood007 Add bg-body to default tabl...

jdarwood007 authored 5 months ago

307) 
jdarwood007 Initial commit

jdarwood007 authored 3 years ago

308) 							case 'CLEAR':
jdarwood007 Cleanup, enforce style and...

jdarwood007 authored 3 years ago

309) 								$VirtualKeyboardInput.val('');
310) 								break;
jdarwood007 Add bg-body to default tabl...

jdarwood007 authored 5 months ago

311) 
jdarwood007 Initial commit

jdarwood007 authored 3 years ago

312) 							case 'DONE':
313) 								if ($VirtualKeyboardInput.val() > $maxValue)
jdarwood007 Add bg-body to default tabl...

jdarwood007 authored 5 months ago

314) 									setNewValue($base, $maxValue, event);
jdarwood007 Initial commit

jdarwood007 authored 3 years ago

315) 								else if ($VirtualKeyboardInput.val() < $minValue)
jdarwood007 Add bg-body to default tabl...

jdarwood007 authored 5 months ago

316) 									setNewValue($base, $minValue, event);
jdarwood007 Initial commit

jdarwood007 authored 3 years ago

317) 								else
jdarwood007 Add bg-body to default tabl...

jdarwood007 authored 5 months ago

318) 									setNewValue($base, $VirtualKeyboardInput.val(), event);
319) 
jdarwood007 Cleanup, enforce style and...

jdarwood007 authored 3 years ago

320) 								$VirtualKeyboard.remove();
321) 								break;
322) 
jdarwood007 Initial commit

jdarwood007 authored 3 years ago

323) 							case 'CANCEL':
324) 								$VirtualKeyboard.remove();
jdarwood007 Cleanup, enforce style and...

jdarwood007 authored 3 years ago

325) 								break;
jdarwood007 Add bg-body to default tabl...

jdarwood007 authored 5 months ago

326) 
jdarwood007 Initial commit

jdarwood007 authored 3 years ago

327) 							case 'UP':
328) 								if ($VirtualKeyboardInput.val() < $maxValue)
jdarwood007 Add bg-body to default tabl...

jdarwood007 authored 5 months ago

329) 									setNewValue($VirtualKeyboardInput, parseFloat($VirtualKeyboardInput.val()) + parseFloat($step), event);
jdarwood007 Cleanup, enforce style and...

jdarwood007 authored 3 years ago

330) 								break;
jdarwood007 Add bg-body to default tabl...

jdarwood007 authored 5 months ago

331) 
jdarwood007 Initial commit

jdarwood007 authored 3 years ago

332) 							case 'DOWN':
333) 								if ($VirtualKeyboardInput.val() > $minValue)
jdarwood007 Add bg-body to default tabl...

jdarwood007 authored 5 months ago

334) 									setNewValue($VirtualKeyboardInput, parseFloat($VirtualKeyboardInput.val()) - parseFloat($step), event);
jdarwood007 Cleanup, enforce style and...

jdarwood007 authored 3 years ago

335) 								break;
jdarwood007 Initial commit

jdarwood007 authored 3 years ago

336) 
337) 							case 'SEP':
338) 								if ($VirtualKeyboardInput.val().toString().indexOf(options.separator) === -1)
339) 									$VirtualKeyboardInput.val($VirtualKeyboardInput.val().toString() + options.separator);
jdarwood007 Cleanup, enforce style and...

jdarwood007 authored 3 years ago

340) 								break;
jdarwood007 Initial commit

jdarwood007 authored 3 years ago

341) 
342) 							case 'INVERSE':
jdarwood007 Add bg-body to default tabl...

jdarwood007 authored 5 months ago

343) 								setNewValue($VirtualKeyboardInput, parseFloat($VirtualKeyboardInput.val()) * -1, event);
jdarwood007 Cleanup, enforce style and...

jdarwood007 authored 3 years ago

344) 								break;
jdarwood007 Add bg-body to default tabl...

jdarwood007 authored 5 months ago

345) 
jdarwood007 Initial commit

jdarwood007 authored 3 years ago

346) 							// Default to assume its numbers.
347) 							default:
348) 								if ($(this).attr('data-custom-function'))
349) 									$(this).attr('data-custom-function')(this, event, thisFunction);
Jeremy D Make a good demo page to sh...

Jeremy D authored 2 years ago

350) 								else if ($VirtualKeyboardInput.val() == '0' || $VirtualKeyboardInput.val() == '0.000')
jdarwood007 Add bg-body to default tabl...

jdarwood007 authored 5 months ago

351) 									setNewValue($VirtualKeyboardInput, $(this).attr('data-function'), event);
jdarwood007 Initial commit

jdarwood007 authored 3 years ago

352) 								else
jdarwood007 Add bg-body to default tabl...

jdarwood007 authored 5 months ago

353) 									setNewValue($VirtualKeyboardInput, $VirtualKeyboardInput.val().toString() + $(this).attr('data-function'), event);
jdarwood007 Initial commit

jdarwood007 authored 3 years ago

354) 						}
355) 
356) 						if (options.onAfterVirtualKeyboardButton !== undefined)
357) 							options.onAfterVirtualKeyboardButton(this, event, thisFunction);
358) 					});
359) 
360) 					if (options.onAfterVirtualKeyboardOpen !== undefined)
361) 						options.onAfterVirtualKeyboardOpen(this);
362) 				});
363) 
364) 				if (options.onAfterVirtualKeyboardInitalized !== undefined)
365) 					options.onAfterVirtualKeyboardInitalized(this);
366) 			}
367) 
368) 			if (options.onAfterInitialized !== undefined)
369) 				options.onAfterInitialized(this);
370) 			if (options.debug) console.log($base.parent());
371) 		});