diff options
author | Paul Gardiner <paulg.artifex@glidos.net> | 2012-08-16 17:12:50 +0100 |
---|---|---|
committer | Paul Gardiner <paulg.artifex@glidos.net> | 2012-08-16 17:12:50 +0100 |
commit | 69480439c1204760ac6aa9cc8b713b56c4f5b513 (patch) | |
tree | 50bd5f9e904c22be96688732ef7afbf6096a6e9e /pdf | |
parent | 7e1e898d5862e503a61a6496fdc885a95b9195e5 (diff) | |
download | mupdf-69480439c1204760ac6aa9cc8b713b56c4f5b513.tar.xz |
Javascript: implement main Keystroke and Validate functions
Diffstat (limited to 'pdf')
-rw-r--r-- | pdf/pdf_util.js | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/pdf/pdf_util.js b/pdf/pdf_util.js index d709661b..a70cb3ce 100644 --- a/pdf/pdf_util.js +++ b/pdf/pdf_util.js @@ -301,6 +301,19 @@ function AFParseDateEx(d, fmt) return AFParseTime(dt[1], dout); } +function AFDate_KeystrokeEx(fmt) +{ + if (event.willCommit && !AFParseDateEx(event.value)) + event.rc = false; +} + +function AFDate_Keystroke(index) +{ + var formats = ['m/d','m/d/yy','mm/dd/yy','mm/yy','d-mmm','d-mmm-yy','dd-mm-yy','yy-mm-dd', + 'mmm-yy','mmmm-yy','mmm d, yyyy','mmmm d, yyyy','m/d/yy h:MM tt','m/d/yy HH:MM']; + AFDate_KeystrokeEx(formats[index]); +} + function AFDate_FormatEx(fmt) { var d = AFParseDateEx(event.value, fmt); @@ -315,6 +328,12 @@ function AFDate_Format(index) AFDate_FormatEx(formats[index]); } +function AFTime_Keystroke(index) +{ + if (event.willCommit && !AFParseTime(event.value, null)) + event.rc = false; +} + function AFTime_FormatEx(fmt) { var d = AFParseTime(event.value, null); @@ -353,6 +372,29 @@ function AFSpecial_Format(index) event.value = res ? res : ''; } +function AFNumber_Keystroke(nDec, sepStyle, negStyle, currStyle, strCurrency, bCurrencyPrepend) +{ + if (sepStyle & 2) + { + if (!event.value.match(/^[+-]?\d*[,.]?\d*$/)) + { + event.rc = false; + return; + } + } + else + { + if (!event.value.match(/^[+-]?\d*\.?\d*$/)) + { + event.rc = false; + return; + } + } + + if (event.willCommit && !event.value.match(/\d/)) + event.rc = false; +} + function AFNumber_Format(nDec,sepStyle,negStyle,currStyle,strCurrency,bCurrencyPrepend) { var val = event.value; @@ -482,3 +524,12 @@ function AFSimple_Calculate(op, list) event.value = res; } + +function AFRange_Validate(lowerCheck, lowerLimit, upperCheck, upperLimit) +{ + if (upperCheck && event.value > upperLimit) + event.rc = false; + + if (lowerCheck && event.value < lowerLimit) + event.rc = false; +} |