Skip to content

Commit

Permalink
Version 0.14.1 which fixes two bugs with read only number and date/ti…
Browse files Browse the repository at this point in the history
…me fields.
  • Loading branch information
kitmenke committed Apr 19, 2016
1 parent b701b63 commit 6661359
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 7 deletions.
29 changes: 26 additions & 3 deletions dist/sputility.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
Name: SPUtility.js
Version: 0.14.0
Built: 2016-03-30
Built: 2016-04-18
Author: Kit Menke
https://sputility.codeplex.com/
Copyright (c) 2016
Expand Down Expand Up @@ -474,6 +474,29 @@ var SPUtility = (function ($) {
return convertStringToNumber($(this.Textbox).val());
};

// override SetValue function to prevent NaN
SPNumberField.prototype.SetValue = function (value) {
$(this.Textbox).val(value);
this._updateReadOnlyLabel(this.GetValueString());
return this;
};

SPNumberField.prototype.GetValueString = function () {
var val = this.GetValue();
if (isNaN(val)) {
val = "";
} else {
val = val.toString();
}
return val;
};

// Override the default MakeReadOnly function to allow displaying
// empty number fields as empty string instead of NaN
SPNumberField.prototype.MakeReadOnly = function () {
return this._makeReadOnly(this.GetValueString());
};


/*
* SPCurrencyField class
Expand Down Expand Up @@ -961,7 +984,7 @@ var SPUtility = (function ($) {
if (date === '' && time === '') {
return '';
} else if (date === '') {
return time;
return '';
} else if (time === '') {
return date;
} else {
Expand Down Expand Up @@ -1031,7 +1054,7 @@ var SPUtility = (function ($) {
};

SPDateTimeField.prototype.SetValue = function (year, month, day, hour, minute) {
if (year === null || year === "") {
if (isUndefined(year) || year === null || year === "") {
this.SetDate(null);
if (!this.IsDateOnly) {
this.SetTime(null);
Expand Down
Loading

0 comments on commit 6661359

Please sign in to comment.