MUtilities = MUtilities || {};

var readyProps = function($form) {
	var props = {};

	$form.find('input, select, textarea, .input').each(function() {
		var $this = $(this),
			key = $this.data('name');

		// only prepare those have data-name attributes
		if (key) {
			// split the key by '.'
			var tokens = key.split('.');

			if (tokens.length === 1) {
				// check if is number
				if ($this.attr('type') === 'number' || $this.hasClass('number')) {
					props[key] = _.isNaN(parseFloat(value)) ? value : parseFloat(value);
				} else {
					props[key] = $this.val();
				}
			} else {
				var tmp;

				// reverse traversing the keys
				for (var x = tokens.length-1; x >= 0 ; x--) {
					// if it is the last token, set the value, else just keep concatenate upwards
					if (x === tokens.length-1) {
						if ($this.attr('type') === 'number' || $this.hasClass('number')) {
							tmp = _.isNaN(parseFloat(value)) ? value : parseFloat(value);
						} else {
							tmp = $this.val();
						}
					}

					tmp = _.object([tokens[x]], [tmp]);
				}
			}

			// need to make sure this wont cause too much calculation
			$.extend(true, props, tmp);
		}
	});

	return props;
};

MUtilities.readyProps = readyProps;
@@ -74,19 +74,304 @@
 rops = %7B
+%7D,%0A%09%09setValue = function($this) %7B%0A%09%09%09var value = $this.val(),%0A%09%09%09%09tmp;%0A%0A%09%09%09// check if is number%0A%09%09%09if ($this.attr('type') === 'number' %7C%7C $this.hasClass('number')) %7B%0A%09%09%09%09tmp = _.isNaN(parseFloat(value)) ? value : parseFloat(value);%0A%09%09%09%7D else %7B%0A%09%09%09%09tmp = value;%0A%09%09%09%7D%0A%0A%09%09%09return tmp;%0A%09%09
 %7D;%0A
-
 %0A%09$form.
@@ -540,16 +540,31 @@
 %09if (key
+ && $this.val()
 ) %7B%0A%09%09%09/
@@ -657,224 +657,37 @@
 %09%09%09%09
-// check if is number%0A%09%09%09%09if ($this.attr('type') === 'number' %7C%7C $this.hasClass('number')) %7B%0A%09%09%09%09%09props%5Bkey%5D = _.isNaN(parseFloat(value)) ? value : parseFloat(value);%0A%09%09%09%09%7D else %7B%0A%09%09%09%09%09props%5Bkey%5D = $this.val();%0A%09%09%09%09%7D
+props%5Bkey%5D = setValue($this);
 %0A%09%09%09
@@ -921,192 +921,30 @@
 %09%09%09%09
-if ($this.attr('type') === 'number' %7C%7C $this.hasClass('number')) %7B%0A%09%09%09%09%09%09%09tmp = _.isNaN(parseFloat(value)) ? value : parseFloat(value);%0A%09%09%09%09%09%09%7D else %7B%0A%09%09%09%09%09%09%09tmp = $this.val();%0A%09%09%09%09%09%09%7D
+tmp = setValue($this);
 %0A%09%09%09

fix number value when parsing the inputs