Declined
Last Updated: 12 Jun 2013 23:36 by ADMIN
OnaBai
Created on: 13 Sep 2012 10:31
Category: Kendo UI for jQuery
Type: Feature Request
1
Suggested change/enhance/bug-fixing in parseOptions in kendo.core.js
Right now, it is not possible to specify data-max or data-min for fields as time or dates (data-role="datepicker", data-role="timepicker"...) since the parsing of the options only recognizes null, true, false, float and JSON objects (NOTE: it works fine if you use kendoTimPicker({min:...}).

So I propose to change parseOption in kendo.core.js for adding an extra condition as:
else if (evalRegExp.test(value)) {
            var res = evalRegExp.exec(value);
            if (res[1] !== null) {
                value = eval(res[1]);
            }
        }
where evalRegExp is:
evalRegExp = /^eval\((.*)\)/
and its usage would be define data-min="eval(new Date(2000,1,1,6,0,0))"
Any option that matches eval(.*) would be returned as result of evaluating it.

The final code would be:
    var templateRegExp = /template$/i,
        jsonRegExp = /^\s*(?:\{(?:.|\n)*\}|\[(?:.|\n)*\])\s*$/,
        jsonFormatRegExp = /^\{(\d+)(:[^\}]+)?\}/,
        dashRegExp = /([A-Z])/g,
        evalRegExp = /^eval\((.*)\)/;

    function parseOption(element, option) {
        var value;

        if (option.indexOf("data") === 0) {
            option = option.substring(4);
            option = option.charAt(0).toLowerCase() + option.substring(1);
        }

        option = option.replace(dashRegExp, "-$1");
        value = element.getAttribute("data-" + kendo.ns + option);

        if (value === null) {
            value = undefined;
        } else if (value === "null") {
            value = null;
        } else if (value === "true") {
            value = true;
        } else if (value === "false") {
            value = false;
        } else if (!isNaN(parseFloat(value))) {
            value = parseFloat(value);
        } else if (jsonRegExp.test(value) && !jsonFormatRegExp.test(value)) {
            value = $.parseJSON(value);
        } else if (evalRegExp.test(value)) {
            var res = evalRegExp.exec(value);
            if (res[1] !== null) {
                value = eval(res[1]);
            }
        }

        return value;
    }
1 comment
ADMIN
Brandon
Posted on: 12 Jun 2013 23:36
duplicate