|
8 | 8 | * Dual licensed under the MIT and GPL licenses
|
9 | 9 | * http://www.opensource.org/licenses/mit-license.php
|
10 | 10 | * http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
| - * Date: 2017-05-23 |
| 11 | + * Date: 2017-05-28 |
12 | 12 | */
|
13 | 13 | //jsHint options
|
14 | 14 | /*jshint eqnull:true */
|
|
4977 | 4977 | });
|
4978 | 4978 | p.sortname = sort1.substring(0, sort1.length - p.sortorder.length - 1);
|
4979 | 4979 | },
|
4980 |
| - sortData = function (index, idxcol, reload, sor, obj) { |
| 4980 | + sortData = function (index, idxcol, reload, sor, obj, e) { |
4981 | 4981 | var self = this, mygrid = self.grid, cm = p.colModel[idxcol], disabledClasses = getGuiStyles("states.disabled");
|
4982 | 4982 | if (cm == null || !cm.sortable) { return; }
|
4983 | 4983 | if (p.savedRow.length > 0) { return; }
|
|
5079 | 5079 | index = index.substring(5 + p.id.length + 1); // bad to be changed!?!
|
5080 | 5080 | p.sortname = cm.index || index;
|
5081 | 5081 | }
|
5082 |
| - if (!feedback.call(self, "onSortCol", p.sortname, idxcol, p.sortorder)) { |
| 5082 | + if (!feedback.call(self, "onSortCol", p.sortname, idxcol, p.sortorder, e || {})) { |
5083 | 5083 | p.lastsort = idxcol;
|
5084 | 5084 | return;
|
5085 | 5085 | }
|
|
5594 | 5594 | }
|
5595 | 5595 | var iColByName = getColumnHeaderIndex(this);
|
5596 | 5596 | if (iColByName != null) {
|
5597 |
| - sortData.call(ts, $("div", this)[0].id, iColByName, r, d, this); |
| 5597 | + sortData.call(ts, $("div", this)[0].id, iColByName, r, d, this, e); |
5598 | 5598 | }
|
5599 | 5599 | return false;
|
5600 | 5600 | });
|
|
9260 | 9260 | checkValues: function (val, iCol, customobject, nam, options) {
|
9261 | 9261 | var edtrul, nm, dft, g = this, p = g.p, colModel = p.colModel, cm, isEmpty = jgrid.isEmpty,
|
9262 | 9262 | editMsg = getGridRes.call($(g), "edit.msg"), ret,
|
| 9263 | + getPropertyValue = function (propertyName) { |
| 9264 | + var propValue = edtrul[propertyName]; |
| 9265 | + return $.isFunction(propValue) ? propValue.call(g, options) : propValue; |
| 9266 | + }, |
9263 | 9267 | dateMasks = getGridRes.call($(g), "formatter.date.masks");
|
9264 | 9268 | if (customobject === undefined) {
|
9265 | 9269 | if (typeof iCol === "string") {
|
|
9278 | 9282 | }
|
9279 | 9283 | if (edtrul) {
|
9280 | 9284 | if (!nm) { nm = p.colNames != null ? p.colNames[iCol] : cm.label; }
|
9281 |
| - if (edtrul.required === true) { |
| 9285 | + if (getPropertyValue("required") === true) { |
9282 | 9286 | if (isEmpty(val)) { return [false, nm + ": " + editMsg.required, ""]; }
|
9283 | 9287 | }
|
9284 | 9288 | // force required
|
9285 |
| - var rqfield = edtrul.required === false ? false : true; |
9286 |
| - if (edtrul.number === true) { |
| 9289 | + var rqfield = getPropertyValue("required") === false ? false : true; |
| 9290 | + if (getPropertyValue("number") === true) { |
9287 | 9291 | if (!(rqfield === false && isEmpty(val))) {
|
9288 | 9292 | if (isNaN(val)) { return [false, nm + ": " + editMsg.number, ""]; }
|
9289 | 9293 | }
|
|
9295 | 9299 | if (parseFloat(val) > parseFloat(edtrul.maxValue)) { return [false, nm + ": " + editMsg.maxValue + " " + edtrul.maxValue, ""]; }
|
9296 | 9300 | }
|
9297 | 9301 | var filter;
|
9298 |
| - if (edtrul.email === true) { |
| 9302 | + if (getPropertyValue("email") === true) { |
9299 | 9303 | if (!(rqfield === false && isEmpty(val))) {
|
9300 | 9304 | // taken from $ Validate plugin
|
9301 | 9305 | filter = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i;
|
9302 | 9306 | if (!filter.test(val)) { return [false, nm + ": " + editMsg.email, ""]; }
|
9303 | 9307 | }
|
9304 | 9308 | }
|
9305 |
| - if (edtrul.integer === true) { |
| 9309 | + if (getPropertyValue("integer") === true) { |
9306 | 9310 | if (!(rqfield === false && isEmpty(val))) {
|
9307 | 9311 | if (isNaN(val)) { return [false, nm + ": " + editMsg.integer, ""]; }
|
9308 | 9312 | if ((val % 1 !== 0) || (val.indexOf(".") !== -1)) { return [false, nm + ": " + editMsg.integer, ""]; }
|
9309 | 9313 | }
|
9310 | 9314 | }
|
9311 |
| - if (edtrul.date === true) { |
| 9315 | + if (getPropertyValue("date") === true) { |
9312 | 9316 | if (!(rqfield === false && isEmpty(val))) {
|
9313 | 9317 | if (cm.formatoptions && cm.formatoptions.newformat) {
|
9314 | 9318 | dft = cm.formatoptions.newformat;
|
|
9321 | 9325 | if (!jgrid.checkDate(dft, val)) { return [false, nm + ": " + editMsg.date + " - " + dft, ""]; }
|
9322 | 9326 | }
|
9323 | 9327 | }
|
9324 |
| - if (edtrul.time === true) { |
| 9328 | + if (getPropertyValue("time") === true) { |
9325 | 9329 | if (!(rqfield === false && isEmpty(val))) {
|
9326 | 9330 | if (!jgrid.checkTime(val)) { return [false, nm + ": " + editMsg.date + " - hh:mm (am/pm)", ""]; }
|
9327 | 9331 | }
|
9328 | 9332 | }
|
9329 |
| - if (edtrul.url === true) { |
| 9333 | + if (getPropertyValue("url") === true) { |
9330 | 9334 | if (!(rqfield === false && isEmpty(val))) {
|
9331 | 9335 | filter = /^(((https?)|(ftp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i;
|
9332 | 9336 | if (!filter.test(val)) { return [false, nm + ": " + editMsg.url, ""]; }
|
|
0 commit comments